commspliant-html-editor 0.0.22 → 0.0.23

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"),s=require("react"),au=require("react-dom");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":"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 pl({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 op({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 gl({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 hl({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 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":"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 Cy({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 ip({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 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":"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 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":"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 Qe({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 Lm({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 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":"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 Sy({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 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":"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 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":"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 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":"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 Ry({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 ap({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 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":"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 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":"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 jy({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 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":"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 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":"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 Gs({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 lp({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 _y({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 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":"html",children:[i.jsx("path",{d:"M8 8l-4 4 4 4"}),i.jsx("path",{d:"M16 8l4 4-4 4"})]})}function sp({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 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":"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 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":"italic",children:[i.jsx("path",{d:"M10 4h9"}),i.jsx("path",{d:"M5 20h9"}),i.jsx("path",{d:"M14 4L8 20"})]})}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":"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 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":"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 zy({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 Oy({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 cp({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 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":"open",children:[i.jsx("path",{d:"M3 7h6l2 2h10v3"}),i.jsx("path",{d:"M3 10l2.2 9h13.6L21 10H3z"})]})}function $y({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 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":"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 ti({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 up({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 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":"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 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":"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 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":"plus",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}function qy({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 Zy({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 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":"redo",children:[i.jsx("path",{d:"M21 10H10a5 5 0 0 0 0 10h1"}),i.jsx("path",{d:"M17 6l4 4-4 4"})]})}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":"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 Jy({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 Qy({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 qs({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 Bm({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 Zs({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 ex({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 tx({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 nx({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 rx({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 ox({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 ix({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 Se="---";function Xn(e){return e===Se}function Jn(e){return typeof e=="object"&&e!==null&&"submenu"in e}const lu=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"]),ax=new Set(["file","edit","view","insert","format","table","help"]),dp="custom",mp="custom";function fp(e){return`custom:${e}`}function lx(e){return e==="menu"||e==="both"}function sx(e){return e==="toolbar"||e==="both"}function pp(e){return e.map(t=>Jn(t)?{submenu:t.submenu,items:pp(t.items)}:t)}function cx(e){return{menus:e.menus.map(t=>({id:t.id,items:pp(t.items)})),iconGroups:e.iconGroups.map(t=>({id:t.id,items:[...t.items]}))}}function gp(e){return Xn(e)?!0:Jn(e)?e.items.every(gp):lu.has(e)}function hp(e,t){for(const n of e)if(n===t||Jn(n)&&hp(n.items,t))return!0;return!1}function ux(e){const t=e.tooltip??e.label;return{id:e.id,command:fp(e.id),icon:e.icon??Py,label:e.label,ariaLabel:e.label,tooltip:t}}function dx(e,t,n,r){if(e.menus[n])r&&!e.menus[n].label&&!ax.has(n)&&(e.menus[n]={...e.menus[n],label:r,ariaLabel:r});else if(n===dp&&!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 mx(e,t,n){if(e.groups[n]||(n===mp?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 fx(e,t,n){var a,l;const r={menus:{...t.menus},submenus:{...t.submenus},groups:{...t.groups},items:{...t.items}},o=cx(n);for(const u of e??[])if(!(lu.has(u.id)||Xn(u.id))){if(r.items[u.id]=ux(u),lx(u.showIn)){const d=((a=u.menu)==null?void 0:a.id)??dp;dx(r,o,d,(l=u.menu)==null?void 0:l.label);const f=o.menus.find(g=>g.id===d);if(f&&!hp(f.items,u.id)){const g=f.items[f.items.length-1];g!==void 0&&!Xn(g)&&f.items.every(gp)&&f.items.push(Se),f.items.push(u.id)}}if(sx(u.showIn)){const d=u.toolbarGroup??mp;mx(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 px(e,t,n){const r={};for(const o of e??[])lu.has(o.id)||Xn(o.id)||(r[fp(o.id)]=()=>{n==null||n(),o.onAction(t())});return r}function gx(e){return{cut:async()=>{await e.cut()},copy:async()=>{await e.copy()},deleteSelection:()=>{e.deleteSelection()}}}const hx="_chrome_boy0f_1",bx={chrome:hx},bp=s.createContext(!1);function yx({dark:e,children:t}){return i.jsx(bp.Provider,{value:e,children:t})}function yp(){return s.useContext(bp)}function wc(e){return{className:bx.chrome,"data-wysiwyg-theme":e?"dark":"light"}}function Pe({children:e}){const t=yp(),n=wc(t);return au.createPortal(i.jsx("div",{className:n.className,"data-wysiwyg-theme":n["data-wysiwyg-theme"],children:e}),document.body)}function su(e,t){const n=e[t];n==null||n()}const cu={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",commandBackgroundImageProperties:"Background image properties…",commandBackgroundImagePropertiesAria:"Background image properties",commandDeletePage:"Delete page",commandDeletePageAria:"Delete selected page",deletePageDialogTitle:"Delete page",deletePageDialogCloseAria:"Close",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"),au=require("react-dom");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":"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 ps({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 op({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 gs({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 hs({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 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":"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 Cy({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 ip({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 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":"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 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":"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 Qe({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 Lm({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 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":"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 Sy({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 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":"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 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":"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 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":"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 Ry({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 ap({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 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":"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 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":"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 jy({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 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":"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 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":"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 Gl({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 sp({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 _y({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 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":"html",children:[i.jsx("path",{d:"M8 8l-4 4 4 4"}),i.jsx("path",{d:"M16 8l4 4-4 4"})]})}function lp({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 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":"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 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":"italic",children:[i.jsx("path",{d:"M10 4h9"}),i.jsx("path",{d:"M5 20h9"}),i.jsx("path",{d:"M14 4L8 20"})]})}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":"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 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":"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 zy({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 Oy({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 cp({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 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":"open",children:[i.jsx("path",{d:"M3 7h6l2 2h10v3"}),i.jsx("path",{d:"M3 10l2.2 9h13.6L21 10H3z"})]})}function $y({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 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":"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 ti({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 up({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 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":"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 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":"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 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":"plus",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}function Zy({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 qy({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 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":"redo",children:[i.jsx("path",{d:"M21 10H10a5 5 0 0 0 0 10h1"}),i.jsx("path",{d:"M17 6l4 4-4 4"})]})}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":"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 Jy({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 Qy({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 Zl({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 Bm({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 ql({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 ex({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 tx({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 nx({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 rx({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 ox({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 ix({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 Se="---";function Xn(e){return e===Se}function Jn(e){return typeof e=="object"&&e!==null&&"submenu"in e}const su=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"]),ax=new Set(["file","edit","view","insert","format","table","help"]),dp="custom",mp="custom";function fp(e){return`custom:${e}`}function sx(e){return e==="menu"||e==="both"}function lx(e){return e==="toolbar"||e==="both"}function pp(e){return e.map(t=>Jn(t)?{submenu:t.submenu,items:pp(t.items)}:t)}function cx(e){return{menus:e.menus.map(t=>({id:t.id,items:pp(t.items)})),iconGroups:e.iconGroups.map(t=>({id:t.id,items:[...t.items]}))}}function gp(e){return Xn(e)?!0:Jn(e)?e.items.every(gp):su.has(e)}function hp(e,t){for(const n of e)if(n===t||Jn(n)&&hp(n.items,t))return!0;return!1}function ux(e){const t=e.tooltip??e.label;return{id:e.id,command:fp(e.id),icon:e.icon??Py,label:e.label,ariaLabel:e.label,tooltip:t}}function dx(e,t,n,r){if(e.menus[n])r&&!e.menus[n].label&&!ax.has(n)&&(e.menus[n]={...e.menus[n],label:r,ariaLabel:r});else if(n===dp&&!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 mx(e,t,n){if(e.groups[n]||(n===mp?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 fx(e,t,n){var a,s;const r={menus:{...t.menus},submenus:{...t.submenus},groups:{...t.groups},items:{...t.items}},o=cx(n);for(const u of e??[])if(!(su.has(u.id)||Xn(u.id))){if(r.items[u.id]=ux(u),sx(u.showIn)){const d=((a=u.menu)==null?void 0:a.id)??dp;dx(r,o,d,(s=u.menu)==null?void 0:s.label);const f=o.menus.find(g=>g.id===d);if(f&&!hp(f.items,u.id)){const g=f.items[f.items.length-1];g!==void 0&&!Xn(g)&&f.items.every(gp)&&f.items.push(Se),f.items.push(u.id)}}if(lx(u.showIn)){const d=u.toolbarGroup??mp;mx(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 px(e,t,n){const r={};for(const o of e??[])su.has(o.id)||Xn(o.id)||(r[fp(o.id)]=()=>{n==null||n(),o.onAction(t())});return r}function gx(e){return{cut:async()=>{await e.cut()},copy:async()=>{await e.copy()},deleteSelection:()=>{e.deleteSelection()}}}const hx="_chrome_boy0f_1",bx={chrome:hx},bp=l.createContext(!1);function yx({dark:e,children:t}){return i.jsx(bp.Provider,{value:e,children:t})}function yp(){return l.useContext(bp)}function wc(e){return{className:bx.chrome,"data-wysiwyg-theme":e?"dark":"light"}}function Pe({children:e}){const t=yp(),n=wc(t);return au.createPortal(i.jsx("div",{className:n.className,"data-wysiwyg-theme":n["data-wysiwyg-theme"],children:e}),document.body)}function lu(e,t){const n=e[t];n==null||n()}const cu={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",commandBackgroundImageProperties:"Background image properties…",commandBackgroundImagePropertiesAria:"Background image properties",commandDeletePage:"Delete page",commandDeletePageAria:"Delete selected page",deletePageDialogTitle:"Delete page",deletePageDialogCloseAria:"Close",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"},Cx={en:cu,es:xx},xp=s.createContext(e=>cu[e]);function wx({locale:e="en",children:t}){const n=s.useMemo(()=>{const r=Cx[e]??cu;return o=>r[o]},[e]);return i.jsx(xp.Provider,{value:n,children:t})}function X(){return s.useContext(xp)}const vx="_menu_c1m45_1",kx="_item_c1m45_19",Sx="_separator_c1m45_59",Ys={menu:vx,item:kx,separator:Sx},Aa=8,Px=[{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:"openPageBackgroundImage",labelKey:"commandBackgroundImageProperties",ariaKey:"commandBackgroundImagePropertiesAria",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 Ax(e,t){const n=[];let r=!1;for(const o of Px){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 Fm(){return'[role="menuitem"]:not(:disabled)'}function Tx({open:e,x:t,y:n,kind:r,inTable:o=!1,canMergeCells:a=!1,canUnmergeCells:l=!1,canDeletePage:u=!1,canAddComment:d=!1,commands:f,onClose:g}){const h=X(),y=s.useId(),b=s.useRef(null);if(s.useLayoutEffect(()=>{var R;if(!e)return;const v=b.current;if(!v)return;const k=v.getBoundingClientRect(),S=Math.max(Aa,Math.min(t,window.innerWidth-k.width-Aa)),A=Math.max(Aa,Math.min(n,window.innerHeight-k.height-Aa));v.style.left=`${S}px`,v.style.top=`${A}px`,(R=v.querySelector(Fm()))==null||R.focus()},[e,t,n,r]),s.useEffect(()=>{if(!e)return;const v=R=>{var T;(T=b.current)!=null&&T.contains(R.target)||g()},k=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),g())},S=()=>{g()},A=R=>{var T;if((T=b.current)!=null&&T.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",A),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0),window.removeEventListener("scroll",S,!0),document.removeEventListener("contextmenu",A)}},[e,g]),!e)return null;const C=Ax(r,{inTable:o,canMergeCells:a,canUnmergeCells:l,canDeletePage:u,canAddComment:d}),x=v=>{var T;if(v.key!=="ArrowDown"&&v.key!=="ArrowUp")return;const k=[...((T=b.current)==null?void 0:T.querySelectorAll(Fm()))??[]];if(k.length===0)return;const S=k.indexOf(document.activeElement),A=v.key==="ArrowDown"?1:-1,R=k[(S+A+k.length)%k.length];v.preventDefault(),R==null||R.focus()};return i.jsx(Pe,{children:i.jsxs("div",{ref:b,className:Ys.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:Ys.separator},`separator-${k}`):i.jsx("button",{type:"button",role:"menuitem",className:Ys.item,"aria-label":h(v.ariaKey),onClick:()=>{g(),su(f,v.command)},children:h(v.labelKey)},v.command))]})})}function Rx(e){return e==="touch"||e==="pen"}function Dx(e,t){return e.button===2||e.ctrlKey?!0:!Rx(t)}const Ix=new Set(["span","strong","b","em","i","u","s","strike","del"]);function Re(e,t){return t?e===t||e.contains(t):!1}function gn(e){return Ix.has(e.tagName.toLowerCase())}function jx(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 vt(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&&jx(e,o)&&n.push(o);return n}function fn(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const a=t;if(n>0&&n<a.length){const l=a.splitText(n);e.setStart(l,0),e.endContainer===a&&e.setEnd(l,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 rr(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 or(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),l=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(l.length>0){const u=e.cloneNode(!1);for(const d of l)u.appendChild(d);o.insertBefore(u,e.nextSibling)}}function jr(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 bi(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 bl="data-wysiwyg-font",Ex=[{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 Tr(e){return e.split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean).join(",")}function yi(e,t){return e===t?!0:!e||!t?!1:Tr(e)===Tr(t)}function Cp(e=[]){var r;const t=[],n=new Set;for(const o of[...Ex,...e]){const a=o.family.trim();if(!a)continue;const l=Tr(a);if(n.has(l))continue;n.add(l);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 Mx(e,t){return e?t.find(n=>yi(n.family,e))??null:null}function _x(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Nx(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function yl(e){const t=new Set,n=[];for(const r of e){const o=r.trim();!o||!_x(o)||t.has(o)||(t.add(o),n.push(o))}return n}function Lx(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&amp;/g,"&")}const Bx=new RegExp(`<link\\b[^>]*\\b${bl}\\b[^>]*>`,"gi");function ye(e){if(!e.includes(bl))return{hrefs:[],body:e};const t=[],n=e.replace(Bx,r=>{var a,l;const o=((a=r.match(/\bhref\s*=\s*"([^"]*)"/i))==null?void 0:a[1])??((l=r.match(/\bhref\s*=\s*'([^']*)'/i))==null?void 0:l[1]);return o&&t.push(Lx(o)),""});return{hrefs:yl(t),body:n}}function Ta(e,t){const n=yl(t);return n.length===0?e:`${n.map(o=>`<link rel="stylesheet" href="${Nx(o)}" ${bl}="">`).join("")}${e}`}function uu(e){return e.style.fontFamily.trim()||null}const Fx=32,Xo=new Map;function wp(e,t){return`${Tr(t)}\0${e}`}function Hx(e,t){return Xo.get(wp(e,t))}function Xs(e,t,n){const r=wp(e,t);if(Xo.size>=Fx){const o=Xo.keys().next().value;o!==void 0&&Xo.delete(o)}Xo.set(r,n)}function vp(e,t){const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=n.currentNode;for(;r;){if(r instanceof HTMLElement){const o=uu(r);if(o&&Tr(o)===t)return!0}r=n.nextNode()}return!1}function zx(e,t){const n=Tr(t);return n?vp(e,n):!1}function Ox(e,t){const n=Tr(t);if(!n)return!1;const r=Hx(e,t);if(r!==void 0)return r;const o=e.toLowerCase();if(!o.includes("font-family")&&!o.includes("face="))return Xs(e,t,!1),!1;const a=n.split(",")[0].replace(/['"]/g,"").trim().toLowerCase();if(a&&!o.includes(a))return Xs(e,t,!1),!1;const l=new DOMParser().parseFromString(e,"text/html"),u=vp(l.body,n);return Xs(e,t,u),u}function Ra(e,t,n=[],r){const o=ye(t).hrefs,a=n.filter(l=>l.css?r!=null&&r.liveRoot?zx(r.liveRoot,l.family):Ox(e,l.family):!1).map(l=>l.css??"");return yl([...o,...a])}function Hm(e,t=[]){const n=ye(e).hrefs,r=t.map(o=>o.css??"");return yl([...n,...r])}function Kx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function du(e,t){let n=Kx(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=uu(n);if(r)return r;n=n.parentElement}return null}function vc(e){return e instanceof HTMLElement&&uu(e)!==null}function mu(e){e.style.fontFamily="",e.style.removeProperty("font-family")}function $x(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)||!vc(r)){n=r;continue}if(or(r,n),vc(r)&&(mu(r),rr(r))){Mt(r);continue}n=r}}function kp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Sp(e){const t=kp(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:vt(t).filter(u=>u.data.length>0),o=(n.length>0?n:[t.startContainer]).map(u=>du(e,u)),a=o[0]??null;return o.every(u=>yi(u,a))?{value:a,mixed:!1}:{value:null,mixed:!0}}function kc(e,t){const n=kp(e);if(!n||n.collapsed)return!1;const r=t!=null&&t.trim()?t.trim():null;fn(n);const o=vt(n).filter(a=>a.data.length>0);for(const a of o){const l=du(e,a);if(r===null){if(l===null)continue;$x(e,a);continue}yi(l,r)||bi(a,u=>{u.style.fontFamily=r})}return jr(o),!0}function Ux(e,t){if(t){if(t.value===null){mu(e);return}e.style.fontFamily=t.value}}function Vx(e){return e!=null}function Wx(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 Gx(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 l=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(l,e.startContainer.nextSibling),l}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const l=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(l,e.startContainer),l}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function Sc(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)||!vc(r)){n=r;continue}if(or(r,n),mu(r),rr(r)){Mt(r);continue}n=r.isConnected?r:t}return t}function qx(e,t){Wx(t);const n=Gx(t);return Sc(e,n)}function Zx(e,t,n){return!!(n&&n.value===null&&du(e,t))}const fu=["pt","px","em","rem","%"],so="pt",Yx={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]},Xx={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},Jx=new Set(fu),Qx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function xl(e){return Jx.has(e)}function it(e){return Math.round(e*100)/100}function be(e){const t=it(e);return Number.isInteger(t),String(t)}function pu(e,t){return`${be(e)}${t}`}function gu(e){const t=e.trim();if(!t)return null;const n=t.match(Qx);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 eC(e,t){const n=e.trim();if(!n)return null;const r=gu(n);if(r)return xl(r.unit)?Ar(r.value,r.unit):null;const o=Number(n.replace(",","."));return Number.isFinite(o)?Ar(o,t):null}function Ar(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Xx[t];return{value:it(Math.min(r,Math.max(n,e))),unit:t}}function Pp(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return it(e);case"pt":return it(e*.75);case"em":return it(e/o);case"rem":return it(e/a);case"%":return it(e/o*100)}}function tC(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 it(e);const a=tC(e,t,r,o);return Pp(a,n,r,o)}const hu="pt",nC=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,rC=/^[+-]?0(?:\.0+)?$/;function _e(e){return`${be(e.value)}${e.unit}`}function pt(e){const t=e.trim();if(!t)return null;if(rC.test(t))return{value:0,unit:"px"};const n=t.match(nC);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return xl(o)?{value:it(r),unit:o}:null}function si(e,t,n){const r=e.trim();if(!r)return null;const o=pt(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:it(a),unit:t}:null}function ir(e){return e.value>=0?e:{value:0,unit:e.unit}}function Ot(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function Da(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function oC(e,t){return t?e===t||e.contains(t):!1}function zm(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 Om(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return zm(e,t)+n;let r=0;const o=t.childNodes;for(let l=0;l<n&&l<o.length;l+=1)r+=((a=o[l].textContent)==null?void 0:a.length)??0;return zm(e,t)+r}function Km(e,t){var l,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=((l=o.textContent)==null?void 0:l.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 Tp(e,t,n){const r=document.createRange(),o=Km(e,t),a=Km(e,n);return r.setStart(o.node,o.offset),r.setEnd(a.node,a.offset),r}function Rp(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function Pc(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function ci(e,t){return t.mode!=="visual"?null:t.visualRange&&Rp(t.visualRange,e)?t.visualRange:Tp(e,t.start,t.end)}function iC(e){const t=un({mode:e.mode,visualEl:e.visualEl,htmlEl:e.htmlEl}),n=e.stored;return Pc(n,t)?n:t.visualRange?t:n??t}function aC(e,t,n){if(!n)return null;const r=e.indexOf(n);if(r!==-1)return{start:r,end:r+n.length,corpus:"pageBody"};const o=t.indexOf(n);return o!==-1?{start:o,end:o+n.length,corpus:"visualInner"}:null}function lC(e,t){if(!t)return null;const n=[e,...e.querySelectorAll("*")];for(const a of n){if(a!==e&&a.outerHTML===t){const l=document.createRange();return l.selectNode(a),l}if(a.innerHTML===t){const l=document.createRange();return l.selectNodeContents(a),l}}const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();){const l=(o.textContent??"").indexOf(t);if(l!==-1){const u=document.createRange();return u.setStart(o,l),u.setEnd(o,l+t.length),u}}return null}function sC(e,t,n){if(t.visualRange&&Rp(t.visualRange,e)&&!t.visualRange.collapsed)return t.visualRange;const r=lC(e,n);if(r&&!r.collapsed)return r;if(t.collapsed)return null;const o=ci(e,t);return o&&!o.collapsed?o:null}function cC(e,t,n){if(e.deleteContents(),!t)return;if(n){const o=e.createContextualFragment(t),a=o.lastChild;e.insertNode(o),a&&(e.setStartAfter(a),e.collapse(!0));return}const r=document.createTextNode(t);e.insertNode(r),e.setStartAfter(r),e.collapse(!0)}function uC(e,t){if(t.mode!=="visual"||t.collapsed)return"";const n=ci(e,t);if(!n||n.collapsed)return"";const r=n.cloneContents(),o=document.createElement("div");return o.appendChild(r),o.innerHTML}function un(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(oC(t,a.commonAncestorContainer)){const l=Om(t,a.startContainer,a.startOffset),u=Om(t,a.endContainer,a.endOffset);return{mode:"visual",text:a.toString(),collapsed:a.collapsed,start:Math.min(l,u),end:Math.max(l,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 Js(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $m(e){if(e.snapshot.mode==="html"){const o=e.getHtml(),a=e.snapshot.start,l=e.snapshot.end,u=e.asHtml?e.content:Js(e.content);e.setHtml(o.slice(0,a)+u+o.slice(l));const d=e.htmlEl;if(d){const f=a+u.length;d.focus(),d.setSelectionRange(f,f)}return}const t=e.visualEl;if(!t){const o=e.asHtml?e.content:Js(e.content);e.setHtml(e.getHtml()+o);return}const n=ci(t,e.snapshot);if(!n){const o=e.asHtml?e.content:Js(e.content);e.setHtml(e.getHtml()+o);return}if(n.deleteContents(),e.content)if(e.asHtml){const o=n.createContextualFragment(e.content),a=o.lastChild;n.insertNode(o),a&&(n.setStartAfter(a),n.collapse(!0))}else{const o=document.createTextNode(e.content);n.insertNode(o),n.setStartAfter(o),n.collapse(!0)}const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(n),e.setHtml(t.innerHTML)}const bu=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),Dp=new Set(["table","thead","tbody","tr","td","th"]),yu=new Set([...Dp,"ul","ol","li","pre","hr"]);function Le(e){return e.tagName.toLowerCase()}function xi(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function xu(e){return e instanceof HTMLElement&&(Le(e)==="ul"||Le(e)==="ol")}function Kt(e){return e instanceof HTMLElement&&Le(e)==="li"}function hn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Cu(e){const t=e.collapsed?[]:vt(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function co(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 l=0,u;for(;u=a.nextNode();){if(t.contains(u)||t.compareDocumentPosition(u)&Node.DOCUMENT_POSITION_FOLLOWING)return l+r;l+=((g=u.textContent)==null?void 0:g.length)??0}return l+r}function wu(e,t,n){const r=Tp(e,t,n),o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function ar(e,t){const n=hn(e);if(!n)return!1;const r=co(e,n.startContainer,n.startOffset),o=co(e,n.endContainer,n.endOffset),a=Math.min(r,o),l=Math.max(r,o),u=t();return wu(e,a,l),u}function vu(e,t){if(Le(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 xt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function dC(e,t){let n=xi(t);for(;n&&n!==e;){if(yg(n,e)||kt(n)){n=n.parentElement;continue}const r=Le(n);if(bu.has(r)&&n instanceof HTMLElement)return n;if(Dp.has(r)||r==="pre")return null;n=n.parentElement}return null}function En(e){const t=hn(e);if(!t)return[];const n=new Set,r=[];for(const o of Cu(t)){const a=dC(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Ac(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Le(e);return bu.has(t)||yu.has(t)?!1:gn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function mC(e,t){let n=xi(t);for(;n&&n!==e;){if(yu.has(Le(n)))return!0;n=n.parentElement}return!1}function fC(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function pC(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&Ac(n[o-1]);)o-=1;for(;a<n.length-1&&Ac(n[a+1]);)a+=1;return n.slice(o,a+1)}function Tc(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t)))return t;return null}function gC(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&&kt(r)?Tc(e):r}return n.startContainer===t&&e!==t?Tc(e):fC(e,n.startContainer)}function hC(e,t){const n=Eu(e);if(mC(e,t.startContainer))return null;if(!Tc(n)){const l=document.createElement("p");return l.appendChild(document.createElement("br")),n.appendChild(l),l}const r=gC(n,e,t);if(!r||r instanceof HTMLElement&&kt(r)||r instanceof Element&&yu.has(Le(r))||r instanceof HTMLElement&&bu.has(Le(r))||!Ac(r))return null;const o=pC(n,r),a=document.createElement("p");n.insertBefore(a,o[0]);for(const l of o)a.appendChild(l);return a}function Er(e){const t=En(e);if(t.length>0)return t;const n=hn(e);if(!n)return[];const r=hC(e,n);return r?[r]:[]}function uo(e){const t=e.parentElement;return t&&xu(t)?t:null}function Ip(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&&bC(r,o)?t[t.length-1].push(o):t.push([o])}return t}function bC(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 yC(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Qs(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(l=>Number.isFinite(l))?{r:n,g:r,b:o,a}:null}function ec(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 tc(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 xC={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 CC(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||CC(t))return null;const n=tc(t);if(n)return n;const r=Qs(t);if(r)return r.a===0?null:ec(r.r,r.g,r.b);const o=xC[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 l=String(a.fillStyle);if(l==="#010203"){const d=tc(t);if(d==="#010203")return d;const f=Qs(t);return f&&ec(f.r,f.g,f.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(l.startsWith("#"))return tc(l);const u=Qs(l);return!u||u.a===0?null:ec(u.r,u.g,u.b)}function jp(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?Ue(n):null}function Ka(e,t,n){let r=yC(t);for(;r&&r!==e&&r instanceof HTMLElement;){const o=jp(r,n);if(o)return o;r=r.parentElement}return null}function $a(e,t){return e instanceof HTMLElement?jp(e,t)!==null:!1}function ku(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function Ep(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function wC(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!$a(o,n)){r=o;continue}if(or(o,r),$a(o,n)&&(ku(o,n),rr(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 Re(e,n.commonAncestorContainer)?n:null}function Ua(e,t){const n=Mp(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:vt(n).filter(d=>d.data.length>0),a=(r.length>0?r:[n.startContainer]).map(d=>Ka(e,d,t)),l=a[0]??null;return a.every(d=>d===l)?{value:l,mixed:!1}:{value:null,mixed:!0}}function ni(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;fn(r);const a=vt(r).filter(l=>l.data.length>0);for(const l of a){const u=Ka(e,l,t);if(o===null){if(u===null)continue;wC(e,l,t);continue}u!==o&&bi(l,d=>{Ep(d,t,o)})}return jr(a),!0}function Um(e,t,n){if(n.value===null){ku(e,t);return}const r=Ue(n.value);r&&Ep(e,t,r)}function vC(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function kC(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 SC(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 l=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(l,e.startContainer.nextSibling),l}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const l=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(l,e.startContainer),l}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function _p(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!n.some(a=>$a(o,a))){r=o;continue}or(o,r);for(const a of n)$a(o,a)&&ku(o,a);if(rr(o)){Mt(o);continue}r=o.isConnected?o:t}return t}function PC(e,t,n){kC(t);const r=SC(t);return _p(e,r,n)}function AC(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&Ka(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&Ka(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const Np=["auto","avoid"],Rc=["auto","avoid","page"];new Set(Np);new Set(Rc);function Lp(e){return e.trim().toLowerCase()}function Vm(e){return Lp(e)==="avoid"?"avoid":"auto"}function Va(e){const t=Lp(e);return t==="avoid"?"avoid":t==="page"||t==="always"?"page":"auto"}function Bp(e){const t=e.style.breakInside;if(t)return Vm(t);const n=e.style.pageBreakInside;return n?Vm(n):"auto"}function Fp(e){const t=e.style.breakAfter;if(t)return Va(t);const n=e.style.pageBreakAfter;return n?Va(n):"auto"}function Hp(e){const t=e.style.breakBefore;if(t)return Va(t);const n=e.style.pageBreakBefore;return n?Va(n):"auto"}function TC(e){e.style.removeProperty("break-inside"),e.style.removeProperty("page-break-inside")}function RC(e){e.style.removeProperty("break-after"),e.style.removeProperty("page-break-after")}function DC(e){e.style.removeProperty("break-before"),e.style.removeProperty("page-break-before")}function IC(e){return{breakInside:Bp(e),breakAfter:Fp(e),breakBefore:Hp(e)}}function jC(e,t){return Bp(e)===t?!1:t==="auto"?(TC(e),!0):(e.style.breakInside="avoid",e.style.pageBreakInside="avoid",!0)}function EC(e,t){return Fp(e)===t?!1:t==="auto"?(RC(e),!0):t==="avoid"?(e.style.breakAfter="avoid",e.style.pageBreakAfter="avoid",!0):(e.style.breakAfter="page",e.style.pageBreakAfter="always",!0)}function MC(e,t){return Hp(e)===t?!1:t==="auto"?(DC(e),!0):t==="avoid"?(e.style.breakBefore="avoid",e.style.pageBreakBefore="avoid",!0):(e.style.breakBefore="page",e.style.pageBreakBefore="always",!0)}function _C(e,t){return e===t}function Wm(e,t){return e===t}const at=["top","right","bottom","left"],Cl=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],Jt={top:null,right:null,bottom:null,left:null},Su={style:"none",width:null,color:null},NC=new Set(Cl),Gm={value:0,unit:"px"};function LC(){return{margin:{...Jt},padding:{...Jt},lineHeight:null,border:{...Su},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null,breakInside:"auto",breakAfter:"auto",breakBefore:"auto"}}function Mr(){const e=LC();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 In(e,t){return at.every(n=>Ot(e[n],t[n]))}function zp(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 Op(e,t){return e.style===t.style&&Ot(e.width,t.width)&&e.color===t.color}function Kp(e,t){return e===t?!0:!e||!t?!1:Ot(e.offsetX,t.offsetX)&&Ot(e.offsetY,t.offsetY)&&Ot(e.blur,t.blur)&&Ot(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function BC(e){return e.kind==="normal"?"normal":e.kind==="number"?be(e.value):_e({value:e.value,unit:e.unit})}function FC(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)?Qn(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?Qn(n):null}function Qn(e){return it(Math.min(1,Math.max(0,e)))}function Wa(e){return it(Qn(e)*100)}function $p(e){return Qn(e/100)}function Up(e){return be(Qn(e))}function HC(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:it(r)}}const n=pt(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function zC(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 OC(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 KC(e){const t=[_e(e.offsetX),_e(e.offsetY),_e(e.blur),_e(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function $C(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=zC(t,",")[0];if(!n)return null;const r=OC(n);let o=!1,a=null;const l=[];for(const u of r){if(u.toLowerCase()==="inset"){o=!0;continue}const d=pt(u);if(d){l.push(d);continue}const f=Ue(u);if(f){a=f;continue}return null}return l.length<2||l.length>4?null:{offsetX:l[0],offsetY:l[1],blur:l[2]??Gm,spread:l[3]??Gm,color:a,inset:o}}function no(e,t){return pt(e.style.getPropertyValue(t))}function UC(e,t,n,r){const o=n&&r?ir(n):n,a=o?_e(o):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function qm(e,t){return{top:no(e,`${t}-top`),right:no(e,`${t}-right`),bottom:no(e,`${t}-bottom`),left:no(e,`${t}-left`)}}function Zm(e,t,n,r){let o=!1;for(const a of at)UC(e,`${t}-${a}`,n[a],r)&&(o=!0);return o}function VC(e){const t=e.trim().toLowerCase();return NC.has(t)?t:"none"}function Vp(e){const t=VC(e.style.borderStyle||e.style.borderTopStyle),n=no(e,"border-width")??no(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,o=r?Ue(r):null;return{style:t,width:n,color:o}}function WC(e,t){const n=Vp(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?ir(t.width):null,color:t.color};return Op(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=_e(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Wp(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return pt(n)}function GC(e,t){const n=t?ir(t):null,r=Wp(e);return Ot(r,n)?!1:(n?e.style.borderRadius=_e(n):e.style.removeProperty("border-radius"),!0)}function Gp(e){return $C(e.style.boxShadow)}function qC(e,t){const n=Gp(e),r=t?{...t,blur:ir(t.blur)}:null;return Kp(n,r)?!1:(r?e.style.boxShadow=KC(r):e.style.removeProperty("box-shadow"),!0)}function qp(e){return HC(e.style.lineHeight)}function ZC(e,t){const n=qp(e);return zp(n,t)?!1:(t?e.style.lineHeight=BC(t):e.style.removeProperty("line-height"),!0)}function Zp(e){const t=e.style.backgroundColor;return t?Ue(t):null}function YC(e,t){const n=t?Ue(t):null;return Zp(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Yp(e){return FC(e.style.opacity)}function XC(e,t){const n=Yp(e),r=t===null?null:Qn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=Up(r),!0)}function yo(e){const t=IC(e);return{margin:qm(e,"margin"),padding:qm(e,"padding"),lineHeight:qp(e),border:Vp(e),borderRadius:Wp(e),boxShadow:Gp(e),backgroundColor:Zp(e),opacity:Yp(e),breakInside:t.breakInside,breakAfter:t.breakAfter,breakBefore:t.breakBefore}}function xo(e,t){let n=!1;return!t.marginMixed&&Zm(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&Zm(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&ZC(e,t.lineHeight)&&(n=!0),!t.borderMixed&&WC(e,t.border)&&(n=!0),!t.radiusMixed&&GC(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&qC(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&YC(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&XC(e,t.opacity)&&(n=!0),!t.breakInsideMixed&&jC(e,t.breakInside)&&(n=!0),!t.breakAfterMixed&&EC(e,t.breakAfter)&&(n=!0),!t.breakBeforeMixed&&MC(e,t.breakBefore)&&(n=!0),n&&xt(e),n}function JC(e){const t=Mr(),n=En(e);if(n.length===0)return t;const r=n.map(yo),o=r[0];return{margin:o.margin,marginMixed:r.some(a=>!In(a.margin,o.margin)),padding:o.padding,paddingMixed:r.some(a=>!In(a.padding,o.padding)),lineHeight:o.lineHeight,lineHeightMixed:r.some(a=>!zp(a.lineHeight,o.lineHeight)),border:o.border,borderMixed:r.some(a=>!Op(a.border,o.border)),borderRadius:o.borderRadius,radiusMixed:r.some(a=>!Ot(a.borderRadius,o.borderRadius)),boxShadow:o.boxShadow,shadowMixed:r.some(a=>!Kp(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=>!_C(a.breakInside,o.breakInside)),breakAfter:o.breakAfter,breakAfterMixed:r.some(a=>!Wm(a.breakAfter,o.breakAfter)),breakBefore:o.breakBefore,breakBeforeMixed:r.some(a=>!Wm(a.breakBefore,o.breakBefore))}}function QC(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;let r=!1;for(const o of n)xo(o,t)&&(r=!0);return r})}const ui=96,ew=25.4,Pu=ui/ew,Xp=Pu*10,Jp=72,tw=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt|px|em|rem|%)$/i;function Qp(e){const t=e.trim();if(!t)return null;if(/^[+-]?0(?:\.0+)?$/.test(t))return{value:0,unit:"px"};const n=t.match(tw);if(!n)return null;const r=Number(n[1]);return Number.isFinite(r)?{value:it(r),unit:n[2].toLowerCase()}:null}function di(e,t){switch(t){case"in":return e/ui;case"cm":return e/Xp;case"mm":return e/Pu;case"pt":return e/ui*Jp;case"px":default:return e}}function mi(e,t){switch(t){case"in":return e*ui;case"cm":return e*Xp;case"mm":return e*Pu;case"pt":return e/Jp*ui;case"em":case"rem":return e*16;case"px":default:return e}}function Vn(e,t=0){if(!e)return t;const n=typeof e=="string"?Qp(e):e;return!n||!Number.isFinite(n.value)?t:mi(n.value,n.unit)}function nc(e,t="in"){const n=di(e,t);return{value:Math.round(n*1e3)/1e3,unit:t}}function Jo(e){const t=di(e,"pt");return{value:Math.round(t*1e3)/1e3,unit:"pt"}}function eg(e,t="in"){const n=di(e,t),r=t==="in"?2:t==="cm"?1:0;return`${n.toFixed(r)} ${t}`}function vr(e,t="in",n=!1,r=0){if(n)return e;const o=e-r,l=mi(t==="in"?.125:t==="cm"?.25:t==="mm"?2.5:10,t);if(l<=0)return e;const u=Math.round(o/l)*l;return r+u}function tg(e,t,n="in"){const r=[];if(e<=0)return r;const o=n==="in",a=o?.125:.1;if(mi(a,n)<=0)return r;const u=-di(t,n),d=di(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+mi(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 A={positionPx:Math.round(b),unitValue:y,major:x,height:S};x&&y>=0&&(A.label=String(Math.abs(C))),r.push(A)}return r}function ng(e){const t=pt(e);if(t)return t;const n=Qp(e);return n&&(n.unit==="in"||n.unit==="cm"||n.unit==="mm")?Jo(mi(n.value,n.unit)):null}const Ga="data-page-at-rule";function Wn(){return{sizePreset:"auto",customWidth:null,customHeight:null,orientation:null,margin:{...Jt},marginMixed:!1}}function Au(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function rg(e){return e.body.innerHTML.replace(/\s*data-page=""/g," data-page")}function fi(e){var r;const n=Au(e).querySelector(`style[${Ga}]`);return((r=n==null?void 0:n.textContent)==null?void 0:r.trim())??null}function Ia(e,t){const n=new RegExp(`margin-${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?ng(r[1].trim()):null}function nw(e){const t=e.match(/(?:^|[\s{;])margin\s*:\s*([^;]+)/i);if(!t)return{...Jt};const n=t[1].trim().split(/\s+/).map(u=>ng(u)),[r,o=r,a=r,l=o]=n;return{top:r??null,right:o??null,bottom:a??null,left:l??null}}function rw(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"),l=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:l};if(d[0]==="letter")return{sizePreset:"letter",customWidth:null,customHeight:null,orientation:l};if(d[0]==="legal")return{sizePreset:"legal",customWidth:null,customHeight:null,orientation:l}}if(d.length>=2){const f=pt(d[0]),g=pt(d[1]);if(f&&g)return{sizePreset:"custom",customWidth:f,customHeight:g,orientation:l}}return!u&&l?{sizePreset:"auto",customWidth:null,customHeight:null,orientation:l}:t}function ow(e){const t=Wn();if(!e)return t;const n=e.match(/@page\s*\{([^}]*)\}/is);if(!n)return t;const r=n[1],o=rw(r),a={top:Ia(r,"top"),right:Ia(r,"right"),bottom:Ia(r,"bottom"),left:Ia(r,"left")},u=at.some(d=>a[d]!==null)?a:nw(r);return{...o,margin:u,marginMixed:!1}}function ot(e){return ow(fi(e))}function zt(e,t){return fi(e)||!fi(t)?e:qa(e,ot(t))}function iw(e){const t=at.map(r=>e[r]);if(t.every(r=>r===null))return null;const n=t.map(r=>r?_e(r):"0");return n[0]===n[1]&&n[1]===n[2]&&n[2]===n[3]?`margin: ${n[0]};`:at.map(r=>e[r]?`margin-${r}: ${_e(e[r])};`:null).filter(Boolean).join(" ")}function aw(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(_e(e.customWidth),_e(e.customHeight)),e.orientation&&t.push(e.orientation),t.length===0?null:`size: ${t.join(" ")};`}function lw(e){const t=aw(e),n=iw(e.margin);return!t&&!n?null:`@page { ${[t,n].filter(Boolean).join(" ")} }`}function Xt(e){const t=Au(e);for(const n of t.querySelectorAll(`style[${Ga}]`))n.remove();return rg(t)}function sw(e,t){const n=Au(e);let r=n.querySelector(`style[${Ga}]`);return r||(r=n.createElement("style"),r.setAttribute(Ga,""),n.body.insertBefore(r,n.body.firstChild)),r.textContent=t,rg(n)}function qa(e,t){const n=lw(t);return n?sw(e,n):og(e)}function og(e){return Xt(e)}function ig(e){const t=e.map(n=>fi(n)).filter(n=>!!n);return t.length===0?"":t.join(`
140
- `)}const Tu="data-page-sized",Dc={top:"--wysiwyg-page-margin-top",right:"--wysiwyg-page-margin-right",bottom:"--wysiwyg-page-margin-bottom",left:"--wysiwyg-page-margin-left"},cw="0.75rem",Ic=["top","right","bottom","left"],rc={A4:{width:"210mm",height:"297mm"},letter:{width:"8.5in",height:"11in"},legal:{width:"8.5in",height:"14in"}};function Co(e,t=!1){let n=null;return e.sizePreset==="A4"||e.sizePreset==="letter"||e.sizePreset==="legal"?n={...rc[e.sizePreset]}:e.sizePreset==="custom"&&e.customWidth&&e.customHeight?n={width:_e(e.customWidth),height:_e(e.customHeight)}:e.orientation?n=t?{...rc.letter}:null:n=t?{...rc.letter}:null,n?e.orientation==="landscape"?{width:n.height,height:n.width}:n:null}function ag(e){return Co(e,!1)!==null}function uw(e){const t=Co(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 at){const l=r[a];l&&n.style.setProperty(`padding-${a}`,l)}document.body.appendChild(n);const o={width:n.offsetWidth,height:n.offsetHeight};return n.remove(),o}function Ci(e){return dw(e.margin)}function dw(e){return{top:e.top?_e(e.top):null,right:e.right?_e(e.right):null,bottom:e.bottom?_e(e.bottom):null,left:e.left?_e(e.left):null}}const mw=["width","min-height","padding-top","padding-right","padding-bottom","padding-left"];function lg(e){for(const t of Ic)e.style.removeProperty(Dc[t])}function fw(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 pw(e,t){if(!fw(e)){lg(e);return}const n=ot(t);if(Co(n)){const o=Ci(n);for(const a of Ic){const l=o[a]??"0px";e.style.setProperty(Dc[a],l)}return}for(const o of Ic)e.style.setProperty(Dc[o],cw)}function gw(e){e.removeAttribute(Tu);for(const t of mw)e.style.removeProperty(t);lg(e)}function sg(e,t){const n=ot(e),r={...n.margin};return t.left!==void 0&&(r.left=Jo(t.left)),t.right!==void 0&&(r.right=Jo(t.right)),t.top!==void 0&&(r.top=Jo(t.top)),t.bottom!==void 0&&(r.bottom=Jo(t.bottom)),qa(e,{...n,margin:r})}function hw(e,t,n){wo(e,sg(t,n))}function wo(e,t){const n=ot(t),r=Co(n);if(!r){gw(e);return}e.setAttribute(Tu,""),e.style.width=r.width,e.style.minHeight=r.height;const o=Ci(n);for(const a of at){const l=`padding-${a}`,u=o[a];u?e.style.setProperty(l,u):e.style.removeProperty(l)}pw(e,t)}const cg="data-template-tag",ug=/\{\{/;function Ru(e){return e instanceof HTMLSpanElement&&e.hasAttribute(cg)}function dg(e){return ug.test(e)}function mg(e){return ug.test(e)}function bw(e,t){if(!dg(e))return!0;const n=(e.match(/data-template-tag/g)??[]).length,r=t.querySelectorAll(`[${cg}]`).length;if(n>0&&r<n)return!1;const o=e.match(/\{\{[^}]*\}\}/g)??[],a=t.textContent??"";return o.every(l=>a.includes(l))}const Rr="data-page",mo="data-page-bg",Za="commspliant-background";function kt(e){return e instanceof HTMLElement&&(e.id===Za||e.hasAttribute(mo))}function yw(e){return e.hasAttribute(Rr)&&e.parentElement?e.parentElement:e}function Du(e){const t=yw(e),n=new Set,r=[],o=a=>{a instanceof HTMLElement&&kt(a)&&!n.has(a)&&(n.add(a),r.push(a))};o(t.querySelector(`#${Za}`));for(const a of t.querySelectorAll(`[${mo}]`))o(a);return o(t),r}function Iu(e){return Du(e)[0]??null}function ri(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 fg(e,t){if(!e.hasAttribute(Tu))return ri(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 xw=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","div"]);function pg(e){return xw.has(e.tagName.toLowerCase())}function wl(e){const t=e.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li");return t[t.length-1]??null}function gg(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t))&&t instanceof HTMLElement&&pg(t))return t;return null}function hg(e){const t=gg(e)??wl(e);if(t)return t;const n=e.ownerDocument.createElement("p");return n.appendChild(e.ownerDocument.createElement("br")),e.appendChild(n),n}function vl(e){let t=!1;for(const n of[...e.childNodes]){if(n instanceof HTMLElement&&kt(n)||n instanceof HTMLElement&&Ru(n)||n.nodeType!==Node.TEXT_NODE)continue;const r=n.textContent??"";if(!r.trim()){n.remove(),t=!0;continue}if(mg(r))continue;(wl(e)??hg(e)).appendChild(n),t=!0}return t}function kl(e){const t=ut(e);if(!t)return!1;let n=!1;for(const r of[...e.childNodes])r!==t&&r instanceof HTMLElement&&kt(r)&&(t.insertBefore(r,t.firstChild),n=!0);return n}function pi(e){const t=ut(e);if(!t)return{changed:!1,absorbedBlocks:[]};let n=kl(e);const r=[];for(const o of[...e.childNodes])if(o!==t&&!(o instanceof HTMLElement&&kt(o))){if(o.nodeType===Node.TEXT_NODE){const a=o.textContent??"";if(!a.trim()){o.remove(),n=!0;continue}if(mg(a))continue;let l=wl(t);l||(l=document.createElement("p"),t.appendChild(l)),l.appendChild(o),n=!0;continue}if(o instanceof HTMLElement&&pg(o)&&r.push(o),o instanceof HTMLElement&&Ru(o)){t.appendChild(o),n=!0;continue}t.appendChild(o),n=!0}return vl(t)&&(n=!0),{changed:n,absorbedBlocks:r}}function Cw(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 ww="p, h1, h2, h3, h4, h5, h6, li, blockquote, pre";function bg(e,t){if(t<=0)return;const n=ut(e);if(!n)return;const r=n.querySelectorAll(ww);if(r.length===0)return;const o=r[r.length-1],a=window.getSelection();if(!a||a.rangeCount===0)return;const l=a.getRangeAt(0).startContainer;o.contains(l)||Cw(o)}function yg(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(Rr)}function xg(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function vw(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function ut(e){return xg(e).find(n=>n.hasAttribute(Rr))??null}function kw(e){if(vw(e))return null;const t=xg(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"||kt(n)?null:n}function ju(e){const t=ut(e);if(t)return ri(t),t;const n=kw(e);if(n)return n.setAttribute(Rr,""),ri(n),n;const r=document.createElement("div");for(r.setAttribute(Rr,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),ri(r),r}function Eu(e){return ut(e)??e}function Sw(e,t,n){const{startContainer:r}=n;return r===t||t.contains(r)?!1:r===e?!0:e.contains(r)}function Pw(e,t){const{startContainer:n}=t;return n===e||n.nodeType===Node.TEXT_NODE&&n.parentElement===e}function Aw(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 jc(e){vl(e);const t=wl(e)??gg(e)??hg(e);Aw(t)}function Tw(e){const t=ut(e);e.focus(),t&&jc(t)}function fo(e){const t=ut(e);if(!t)return;vl(t);const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);if(Pw(t,r)){jc(t);return}Sw(e,t,r)&&jc(t)}const Rw=["background-image","background-size","background-position","background-repeat","opacity"];function Dw(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 Sl(e){const t=ut(e);Dw(e,t,"background-color");for(const n of Rw)e.style.removeProperty(n)}const Ya="<!-- wysiwyg-page-separator -->",Dr="data-page-surface";function qn(e){const t=e.trim();return t?t.includes(Ya)?e.split(Ya).map(n=>n.trim()):[e]:[""]}function Et(e){return e.length===0?"":e.length===1?e[0]??"":e.join(`
139
+ Abrir Ayuda: F1`,helpTopicKeyboardShortcutsKeywords:"atajos teclado"},Cx={en:cu,es:xx},xp=l.createContext(e=>cu[e]);function wx({locale:e="en",children:t}){const n=l.useMemo(()=>{const r=Cx[e]??cu;return o=>r[o]},[e]);return i.jsx(xp.Provider,{value:n,children:t})}function X(){return l.useContext(xp)}const vx="_menu_c1m45_1",kx="_item_c1m45_19",Sx="_separator_c1m45_59",Yl={menu:vx,item:kx,separator:Sx},Aa=8,Px=[{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:"openPageBackgroundImage",labelKey:"commandBackgroundImageProperties",ariaKey:"commandBackgroundImagePropertiesAria",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 Ax(e,t){const n=[];let r=!1;for(const o of Px){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 Fm(){return'[role="menuitem"]:not(:disabled)'}function Tx({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=X(),y=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(Aa,Math.min(t,window.innerWidth-k.width-Aa)),A=Math.max(Aa,Math.min(n,window.innerHeight-k.height-Aa));v.style.left=`${S}px`,v.style.top=`${A}px`,(R=v.querySelector(Fm()))==null||R.focus()},[e,t,n,r]),l.useEffect(()=>{if(!e)return;const v=R=>{var T;(T=b.current)!=null&&T.contains(R.target)||g()},k=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),g())},S=()=>{g()},A=R=>{var T;if((T=b.current)!=null&&T.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",A),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0),window.removeEventListener("scroll",S,!0),document.removeEventListener("contextmenu",A)}},[e,g]),!e)return null;const C=Ax(r,{inTable:o,canMergeCells:a,canUnmergeCells:s,canDeletePage:u,canAddComment:d}),x=v=>{var T;if(v.key!=="ArrowDown"&&v.key!=="ArrowUp")return;const k=[...((T=b.current)==null?void 0:T.querySelectorAll(Fm()))??[]];if(k.length===0)return;const S=k.indexOf(document.activeElement),A=v.key==="ArrowDown"?1:-1,R=k[(S+A+k.length)%k.length];v.preventDefault(),R==null||R.focus()};return i.jsx(Pe,{children:i.jsxs("div",{ref:b,className:Yl.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:Yl.separator},`separator-${k}`):i.jsx("button",{type:"button",role:"menuitem",className:Yl.item,"aria-label":h(v.ariaKey),onClick:()=>{g(),lu(f,v.command)},children:h(v.labelKey)},v.command))]})})}function Rx(e){return e==="touch"||e==="pen"}function Dx(e,t){return e.button===2||e.ctrlKey?!0:!Rx(t)}const Ix=new Set(["span","strong","b","em","i","u","s","strike","del"]);function Re(e,t){return t?e===t||e.contains(t):!1}function gn(e){return Ix.has(e.tagName.toLowerCase())}function jx(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 vt(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&&jx(e,o)&&n.push(o);return n}function fn(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 rr(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 or(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 jr(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 bi(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 bs="data-wysiwyg-font",Ex=[{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 Tr(e){return e.split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean).join(",")}function yi(e,t){return e===t?!0:!e||!t?!1:Tr(e)===Tr(t)}function Cp(e=[]){var r;const t=[],n=new Set;for(const o of[...Ex,...e]){const a=o.family.trim();if(!a)continue;const s=Tr(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 Mx(e,t){return e?t.find(n=>yi(n.family,e))??null:null}function _x(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Nx(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function ys(e){const t=new Set,n=[];for(const r of e){const o=r.trim();!o||!_x(o)||t.has(o)||(t.add(o),n.push(o))}return n}function Lx(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&amp;/g,"&")}const Bx=new RegExp(`<link\\b[^>]*\\b${bs}\\b[^>]*>`,"gi");function ye(e){if(!e.includes(bs))return{hrefs:[],body:e};const t=[],n=e.replace(Bx,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(Lx(o)),""});return{hrefs:ys(t),body:n}}function Ta(e,t){const n=ys(t);return n.length===0?e:`${n.map(o=>`<link rel="stylesheet" href="${Nx(o)}" ${bs}="">`).join("")}${e}`}function uu(e){return e.style.fontFamily.trim()||null}const Fx=32,Xo=new Map;function wp(e,t){return`${Tr(t)}\0${e}`}function Hx(e,t){return Xo.get(wp(e,t))}function Xl(e,t,n){const r=wp(e,t);if(Xo.size>=Fx){const o=Xo.keys().next().value;o!==void 0&&Xo.delete(o)}Xo.set(r,n)}function vp(e,t){const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=n.currentNode;for(;r;){if(r instanceof HTMLElement){const o=uu(r);if(o&&Tr(o)===t)return!0}r=n.nextNode()}return!1}function zx(e,t){const n=Tr(t);return n?vp(e,n):!1}function Ox(e,t){const n=Tr(t);if(!n)return!1;const r=Hx(e,t);if(r!==void 0)return r;const o=e.toLowerCase();if(!o.includes("font-family")&&!o.includes("face="))return Xl(e,t,!1),!1;const a=n.split(",")[0].replace(/['"]/g,"").trim().toLowerCase();if(a&&!o.includes(a))return Xl(e,t,!1),!1;const s=new DOMParser().parseFromString(e,"text/html"),u=vp(s.body,n);return Xl(e,t,u),u}function Ra(e,t,n=[],r){const o=ye(t).hrefs,a=n.filter(s=>s.css?r!=null&&r.liveRoot?zx(r.liveRoot,s.family):Ox(e,s.family):!1).map(s=>s.css??"");return ys([...o,...a])}function Hm(e,t=[]){const n=ye(e).hrefs,r=t.map(o=>o.css??"");return ys([...n,...r])}function Kx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function du(e,t){let n=Kx(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=uu(n);if(r)return r;n=n.parentElement}return null}function vc(e){return e instanceof HTMLElement&&uu(e)!==null}function mu(e){e.style.fontFamily="",e.style.removeProperty("font-family")}function $x(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)||!vc(r)){n=r;continue}if(or(r,n),vc(r)&&(mu(r),rr(r))){Mt(r);continue}n=r}}function kp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Sp(e){const t=kp(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:vt(t).filter(u=>u.data.length>0),o=(n.length>0?n:[t.startContainer]).map(u=>du(e,u)),a=o[0]??null;return o.every(u=>yi(u,a))?{value:a,mixed:!1}:{value:null,mixed:!0}}function kc(e,t){const n=kp(e);if(!n||n.collapsed)return!1;const r=t!=null&&t.trim()?t.trim():null;fn(n);const o=vt(n).filter(a=>a.data.length>0);for(const a of o){const s=du(e,a);if(r===null){if(s===null)continue;$x(e,a);continue}yi(s,r)||bi(a,u=>{u.style.fontFamily=r})}return jr(o),!0}function Ux(e,t){if(t){if(t.value===null){mu(e);return}e.style.fontFamily=t.value}}function Vx(e){return e!=null}function Wx(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 Gx(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 Sc(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)||!vc(r)){n=r;continue}if(or(r,n),mu(r),rr(r)){Mt(r);continue}n=r.isConnected?r:t}return t}function Zx(e,t){Wx(t);const n=Gx(t);return Sc(e,n)}function qx(e,t,n){return!!(n&&n.value===null&&du(e,t))}const fu=["pt","px","em","rem","%"],lo="pt",Yx={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]},Xx={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},Jx=new Set(fu),Qx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function xs(e){return Jx.has(e)}function it(e){return Math.round(e*100)/100}function be(e){const t=it(e);return Number.isInteger(t),String(t)}function pu(e,t){return`${be(e)}${t}`}function gu(e){const t=e.trim();if(!t)return null;const n=t.match(Qx);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 eC(e,t){const n=e.trim();if(!n)return null;const r=gu(n);if(r)return xs(r.unit)?Ar(r.value,r.unit):null;const o=Number(n.replace(",","."));return Number.isFinite(o)?Ar(o,t):null}function Ar(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Xx[t];return{value:it(Math.min(r,Math.max(n,e))),unit:t}}function Pp(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return it(e);case"pt":return it(e*.75);case"em":return it(e/o);case"rem":return it(e/a);case"%":return it(e/o*100)}}function tC(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 it(e);const a=tC(e,t,r,o);return Pp(a,n,r,o)}const hu="pt",nC=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,rC=/^[+-]?0(?:\.0+)?$/;function _e(e){return`${be(e.value)}${e.unit}`}function pt(e){const t=e.trim();if(!t)return null;if(rC.test(t))return{value:0,unit:"px"};const n=t.match(nC);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return xs(o)?{value:it(r),unit:o}:null}function li(e,t,n){const r=e.trim();if(!r)return null;const o=pt(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:it(a),unit:t}:null}function ir(e){return e.value>=0?e:{value:0,unit:e.unit}}function Ot(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function Da(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function oC(e,t){return t?e===t||e.contains(t):!1}function zm(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 Om(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return zm(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 zm(e,t)+r}function Km(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 Tp(e,t,n){const r=document.createRange(),o=Km(e,t),a=Km(e,n);return r.setStart(o.node,o.offset),r.setEnd(a.node,a.offset),r}function Rp(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function Pc(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function ci(e,t){return t.mode!=="visual"?null:t.visualRange&&Rp(t.visualRange,e)?t.visualRange:Tp(e,t.start,t.end)}function iC(e){const t=un({mode:e.mode,visualEl:e.visualEl,htmlEl:e.htmlEl}),n=e.stored;return Pc(n,t)?n:t.visualRange?t:n??t}function aC(e,t,n){if(!n)return null;const r=e.indexOf(n);if(r!==-1)return{start:r,end:r+n.length,corpus:"pageBody"};const o=t.indexOf(n);return o!==-1?{start:o,end:o+n.length,corpus:"visualInner"}:null}function sC(e,t){if(!t)return null;const n=[e,...e.querySelectorAll("*")];for(const a of n){if(a!==e&&a.outerHTML===t){const s=document.createRange();return s.selectNode(a),s}if(a.innerHTML===t){const s=document.createRange();return s.selectNodeContents(a),s}}const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();){const s=(o.textContent??"").indexOf(t);if(s!==-1){const u=document.createRange();return u.setStart(o,s),u.setEnd(o,s+t.length),u}}return null}function lC(e,t,n){if(t.visualRange&&Rp(t.visualRange,e)&&!t.visualRange.collapsed)return t.visualRange;const r=sC(e,n);if(r&&!r.collapsed)return r;if(t.collapsed)return null;const o=ci(e,t);return o&&!o.collapsed?o:null}function cC(e,t,n){if(e.deleteContents(),!t)return;if(n){const o=e.createContextualFragment(t),a=o.lastChild;e.insertNode(o),a&&(e.setStartAfter(a),e.collapse(!0));return}const r=document.createTextNode(t);e.insertNode(r),e.setStartAfter(r),e.collapse(!0)}function uC(e,t){if(t.mode!=="visual"||t.collapsed)return"";const n=ci(e,t);if(!n||n.collapsed)return"";const r=n.cloneContents(),o=document.createElement("div");return o.appendChild(r),o.innerHTML}function un(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(oC(t,a.commonAncestorContainer)){const s=Om(t,a.startContainer,a.startOffset),u=Om(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 Jl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $m(e){if(e.snapshot.mode==="html"){const o=e.getHtml(),a=e.snapshot.start,s=e.snapshot.end,u=e.asHtml?e.content:Jl(e.content);e.setHtml(o.slice(0,a)+u+o.slice(s));const d=e.htmlEl;if(d){const f=a+u.length;d.focus(),d.setSelectionRange(f,f)}return}const t=e.visualEl;if(!t){const o=e.asHtml?e.content:Jl(e.content);e.setHtml(e.getHtml()+o);return}const n=ci(t,e.snapshot);if(!n){const o=e.asHtml?e.content:Jl(e.content);e.setHtml(e.getHtml()+o);return}if(n.deleteContents(),e.content)if(e.asHtml){const o=n.createContextualFragment(e.content),a=o.lastChild;n.insertNode(o),a&&(n.setStartAfter(a),n.collapse(!0))}else{const o=document.createTextNode(e.content);n.insertNode(o),n.setStartAfter(o),n.collapse(!0)}const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(n),e.setHtml(t.innerHTML)}const bu=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),Dp=new Set(["table","thead","tbody","tr","td","th"]),yu=new Set([...Dp,"ul","ol","li","pre","hr"]);function Le(e){return e.tagName.toLowerCase()}function xi(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function xu(e){return e instanceof HTMLElement&&(Le(e)==="ul"||Le(e)==="ol")}function Kt(e){return e instanceof HTMLElement&&Le(e)==="li"}function hn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Cu(e){const t=e.collapsed?[]:vt(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function co(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 wu(e,t,n){const r=Tp(e,t,n),o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function ar(e,t){const n=hn(e);if(!n)return!1;const r=co(e,n.startContainer,n.startOffset),o=co(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=t();return wu(e,a,s),u}function vu(e,t){if(Le(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 xt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function dC(e,t){let n=xi(t);for(;n&&n!==e;){if(yg(n,e)||kt(n)){n=n.parentElement;continue}const r=Le(n);if(bu.has(r)&&n instanceof HTMLElement)return n;if(Dp.has(r)||r==="pre")return null;n=n.parentElement}return null}function En(e){const t=hn(e);if(!t)return[];const n=new Set,r=[];for(const o of Cu(t)){const a=dC(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Ac(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Le(e);return bu.has(t)||yu.has(t)?!1:gn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function mC(e,t){let n=xi(t);for(;n&&n!==e;){if(yu.has(Le(n)))return!0;n=n.parentElement}return!1}function fC(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function pC(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&Ac(n[o-1]);)o-=1;for(;a<n.length-1&&Ac(n[a+1]);)a+=1;return n.slice(o,a+1)}function Tc(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t)))return t;return null}function gC(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&&kt(r)?Tc(e):r}return n.startContainer===t&&e!==t?Tc(e):fC(e,n.startContainer)}function hC(e,t){const n=Eu(e);if(mC(e,t.startContainer))return null;if(!Tc(n)){const s=document.createElement("p");return s.appendChild(document.createElement("br")),n.appendChild(s),s}const r=gC(n,e,t);if(!r||r instanceof HTMLElement&&kt(r)||r instanceof Element&&yu.has(Le(r))||r instanceof HTMLElement&&bu.has(Le(r))||!Ac(r))return null;const o=pC(n,r),a=document.createElement("p");n.insertBefore(a,o[0]);for(const s of o)a.appendChild(s);return a}function Er(e){const t=En(e);if(t.length>0)return t;const n=hn(e);if(!n)return[];const r=hC(e,n);return r?[r]:[]}function uo(e){const t=e.parentElement;return t&&xu(t)?t:null}function Ip(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&&bC(r,o)?t[t.length-1].push(o):t.push([o])}return t}function bC(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 yC(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Ql(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 ec(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 tc(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 xC={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 CC(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||CC(t))return null;const n=tc(t);if(n)return n;const r=Ql(t);if(r)return r.a===0?null:ec(r.r,r.g,r.b);const o=xC[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=tc(t);if(d==="#010203")return d;const f=Ql(t);return f&&ec(f.r,f.g,f.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(s.startsWith("#"))return tc(s);const u=Ql(s);return!u||u.a===0?null:ec(u.r,u.g,u.b)}function jp(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?Ue(n):null}function Ka(e,t,n){let r=yC(t);for(;r&&r!==e&&r instanceof HTMLElement;){const o=jp(r,n);if(o)return o;r=r.parentElement}return null}function $a(e,t){return e instanceof HTMLElement?jp(e,t)!==null:!1}function ku(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function Ep(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function wC(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!$a(o,n)){r=o;continue}if(or(o,r),$a(o,n)&&(ku(o,n),rr(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 Re(e,n.commonAncestorContainer)?n:null}function Ua(e,t){const n=Mp(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:vt(n).filter(d=>d.data.length>0),a=(r.length>0?r:[n.startContainer]).map(d=>Ka(e,d,t)),s=a[0]??null;return a.every(d=>d===s)?{value:s,mixed:!1}:{value:null,mixed:!0}}function ni(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;fn(r);const a=vt(r).filter(s=>s.data.length>0);for(const s of a){const u=Ka(e,s,t);if(o===null){if(u===null)continue;wC(e,s,t);continue}u!==o&&bi(s,d=>{Ep(d,t,o)})}return jr(a),!0}function Um(e,t,n){if(n.value===null){ku(e,t);return}const r=Ue(n.value);r&&Ep(e,t,r)}function vC(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function kC(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 SC(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 _p(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!n.some(a=>$a(o,a))){r=o;continue}or(o,r);for(const a of n)$a(o,a)&&ku(o,a);if(rr(o)){Mt(o);continue}r=o.isConnected?o:t}return t}function PC(e,t,n){kC(t);const r=SC(t);return _p(e,r,n)}function AC(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&Ka(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&Ka(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const Np=["auto","avoid"],Rc=["auto","avoid","page"];new Set(Np);new Set(Rc);function Lp(e){return e.trim().toLowerCase()}function Vm(e){return Lp(e)==="avoid"?"avoid":"auto"}function Va(e){const t=Lp(e);return t==="avoid"?"avoid":t==="page"||t==="always"?"page":"auto"}function Bp(e){const t=e.style.breakInside;if(t)return Vm(t);const n=e.style.pageBreakInside;return n?Vm(n):"auto"}function Fp(e){const t=e.style.breakAfter;if(t)return Va(t);const n=e.style.pageBreakAfter;return n?Va(n):"auto"}function Hp(e){const t=e.style.breakBefore;if(t)return Va(t);const n=e.style.pageBreakBefore;return n?Va(n):"auto"}function TC(e){e.style.removeProperty("break-inside"),e.style.removeProperty("page-break-inside")}function RC(e){e.style.removeProperty("break-after"),e.style.removeProperty("page-break-after")}function DC(e){e.style.removeProperty("break-before"),e.style.removeProperty("page-break-before")}function IC(e){return{breakInside:Bp(e),breakAfter:Fp(e),breakBefore:Hp(e)}}function jC(e,t){return Bp(e)===t?!1:t==="auto"?(TC(e),!0):(e.style.breakInside="avoid",e.style.pageBreakInside="avoid",!0)}function EC(e,t){return Fp(e)===t?!1:t==="auto"?(RC(e),!0):t==="avoid"?(e.style.breakAfter="avoid",e.style.pageBreakAfter="avoid",!0):(e.style.breakAfter="page",e.style.pageBreakAfter="always",!0)}function MC(e,t){return Hp(e)===t?!1:t==="auto"?(DC(e),!0):t==="avoid"?(e.style.breakBefore="avoid",e.style.pageBreakBefore="avoid",!0):(e.style.breakBefore="page",e.style.pageBreakBefore="always",!0)}function _C(e,t){return e===t}function Wm(e,t){return e===t}const at=["top","right","bottom","left"],Cs=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],Jt={top:null,right:null,bottom:null,left:null},Su={style:"none",width:null,color:null},NC=new Set(Cs),Gm={value:0,unit:"px"};function LC(){return{margin:{...Jt},padding:{...Jt},lineHeight:null,border:{...Su},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null,breakInside:"auto",breakAfter:"auto",breakBefore:"auto"}}function Mr(){const e=LC();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 In(e,t){return at.every(n=>Ot(e[n],t[n]))}function zp(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 Op(e,t){return e.style===t.style&&Ot(e.width,t.width)&&e.color===t.color}function Kp(e,t){return e===t?!0:!e||!t?!1:Ot(e.offsetX,t.offsetX)&&Ot(e.offsetY,t.offsetY)&&Ot(e.blur,t.blur)&&Ot(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function BC(e){return e.kind==="normal"?"normal":e.kind==="number"?be(e.value):_e({value:e.value,unit:e.unit})}function FC(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)?Qn(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?Qn(n):null}function Qn(e){return it(Math.min(1,Math.max(0,e)))}function Wa(e){return it(Qn(e)*100)}function $p(e){return Qn(e/100)}function Up(e){return be(Qn(e))}function HC(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:it(r)}}const n=pt(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function zC(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 OC(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 KC(e){const t=[_e(e.offsetX),_e(e.offsetY),_e(e.blur),_e(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function $C(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=zC(t,",")[0];if(!n)return null;const r=OC(n);let o=!1,a=null;const s=[];for(const u of r){if(u.toLowerCase()==="inset"){o=!0;continue}const d=pt(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]??Gm,spread:s[3]??Gm,color:a,inset:o}}function no(e,t){return pt(e.style.getPropertyValue(t))}function UC(e,t,n,r){const o=n&&r?ir(n):n,a=o?_e(o):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function Zm(e,t){return{top:no(e,`${t}-top`),right:no(e,`${t}-right`),bottom:no(e,`${t}-bottom`),left:no(e,`${t}-left`)}}function qm(e,t,n,r){let o=!1;for(const a of at)UC(e,`${t}-${a}`,n[a],r)&&(o=!0);return o}function VC(e){const t=e.trim().toLowerCase();return NC.has(t)?t:"none"}function Vp(e){const t=VC(e.style.borderStyle||e.style.borderTopStyle),n=no(e,"border-width")??no(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,o=r?Ue(r):null;return{style:t,width:n,color:o}}function WC(e,t){const n=Vp(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?ir(t.width):null,color:t.color};return Op(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=_e(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Wp(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return pt(n)}function GC(e,t){const n=t?ir(t):null,r=Wp(e);return Ot(r,n)?!1:(n?e.style.borderRadius=_e(n):e.style.removeProperty("border-radius"),!0)}function Gp(e){return $C(e.style.boxShadow)}function ZC(e,t){const n=Gp(e),r=t?{...t,blur:ir(t.blur)}:null;return Kp(n,r)?!1:(r?e.style.boxShadow=KC(r):e.style.removeProperty("box-shadow"),!0)}function Zp(e){return HC(e.style.lineHeight)}function qC(e,t){const n=Zp(e);return zp(n,t)?!1:(t?e.style.lineHeight=BC(t):e.style.removeProperty("line-height"),!0)}function qp(e){const t=e.style.backgroundColor;return t?Ue(t):null}function YC(e,t){const n=t?Ue(t):null;return qp(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Yp(e){return FC(e.style.opacity)}function XC(e,t){const n=Yp(e),r=t===null?null:Qn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=Up(r),!0)}function yo(e){const t=IC(e);return{margin:Zm(e,"margin"),padding:Zm(e,"padding"),lineHeight:Zp(e),border:Vp(e),borderRadius:Wp(e),boxShadow:Gp(e),backgroundColor:qp(e),opacity:Yp(e),breakInside:t.breakInside,breakAfter:t.breakAfter,breakBefore:t.breakBefore}}function xo(e,t){let n=!1;return!t.marginMixed&&qm(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&qm(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&qC(e,t.lineHeight)&&(n=!0),!t.borderMixed&&WC(e,t.border)&&(n=!0),!t.radiusMixed&&GC(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&ZC(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&YC(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&XC(e,t.opacity)&&(n=!0),!t.breakInsideMixed&&jC(e,t.breakInside)&&(n=!0),!t.breakAfterMixed&&EC(e,t.breakAfter)&&(n=!0),!t.breakBeforeMixed&&MC(e,t.breakBefore)&&(n=!0),n&&xt(e),n}function JC(e){const t=Mr(),n=En(e);if(n.length===0)return t;const r=n.map(yo),o=r[0];return{margin:o.margin,marginMixed:r.some(a=>!In(a.margin,o.margin)),padding:o.padding,paddingMixed:r.some(a=>!In(a.padding,o.padding)),lineHeight:o.lineHeight,lineHeightMixed:r.some(a=>!zp(a.lineHeight,o.lineHeight)),border:o.border,borderMixed:r.some(a=>!Op(a.border,o.border)),borderRadius:o.borderRadius,radiusMixed:r.some(a=>!Ot(a.borderRadius,o.borderRadius)),boxShadow:o.boxShadow,shadowMixed:r.some(a=>!Kp(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=>!_C(a.breakInside,o.breakInside)),breakAfter:o.breakAfter,breakAfterMixed:r.some(a=>!Wm(a.breakAfter,o.breakAfter)),breakBefore:o.breakBefore,breakBeforeMixed:r.some(a=>!Wm(a.breakBefore,o.breakBefore))}}function QC(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;let r=!1;for(const o of n)xo(o,t)&&(r=!0);return r})}const ui=96,ew=25.4,Pu=ui/ew,Xp=Pu*10,Jp=72,tw=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt|px|em|rem|%)$/i;function Qp(e){const t=e.trim();if(!t)return null;if(/^[+-]?0(?:\.0+)?$/.test(t))return{value:0,unit:"px"};const n=t.match(tw);if(!n)return null;const r=Number(n[1]);return Number.isFinite(r)?{value:it(r),unit:n[2].toLowerCase()}:null}function di(e,t){switch(t){case"in":return e/ui;case"cm":return e/Xp;case"mm":return e/Pu;case"pt":return e/ui*Jp;case"px":default:return e}}function mi(e,t){switch(t){case"in":return e*ui;case"cm":return e*Xp;case"mm":return e*Pu;case"pt":return e/Jp*ui;case"em":case"rem":return e*16;case"px":default:return e}}function Vn(e,t=0){if(!e)return t;const n=typeof e=="string"?Qp(e):e;return!n||!Number.isFinite(n.value)?t:mi(n.value,n.unit)}function nc(e,t="in"){const n=di(e,t);return{value:Math.round(n*1e3)/1e3,unit:t}}function Jo(e){const t=di(e,"pt");return{value:Math.round(t*1e3)/1e3,unit:"pt"}}function eg(e,t="in"){const n=di(e,t),r=t==="in"?2:t==="cm"?1:0;return`${n.toFixed(r)} ${t}`}function vr(e,t="in",n=!1,r=0){if(n)return e;const o=e-r,s=mi(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 tg(e,t,n="in"){const r=[];if(e<=0)return r;const o=n==="in",a=o?.125:.1;if(mi(a,n)<=0)return r;const u=-di(t,n),d=di(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+mi(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 A={positionPx:Math.round(b),unitValue:y,major:x,height:S};x&&y>=0&&(A.label=String(Math.abs(C))),r.push(A)}return r}function ng(e){const t=pt(e);if(t)return t;const n=Qp(e);return n&&(n.unit==="in"||n.unit==="cm"||n.unit==="mm")?Jo(mi(n.value,n.unit)):null}const Ga="data-page-at-rule";function Wn(){return{sizePreset:"auto",customWidth:null,customHeight:null,orientation:null,margin:{...Jt},marginMixed:!1}}function Au(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function rg(e){return e.body.innerHTML.replace(/\s*data-page=""/g," data-page")}function fi(e){var r;const n=Au(e).querySelector(`style[${Ga}]`);return((r=n==null?void 0:n.textContent)==null?void 0:r.trim())??null}function Ia(e,t){const n=new RegExp(`margin-${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?ng(r[1].trim()):null}function nw(e){const t=e.match(/(?:^|[\s{;])margin\s*:\s*([^;]+)/i);if(!t)return{...Jt};const n=t[1].trim().split(/\s+/).map(u=>ng(u)),[r,o=r,a=r,s=o]=n;return{top:r??null,right:o??null,bottom:a??null,left:s??null}}function rw(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=pt(d[0]),g=pt(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 ow(e){const t=Wn();if(!e)return t;const n=e.match(/@page\s*\{([^}]*)\}/is);if(!n)return t;const r=n[1],o=rw(r),a={top:Ia(r,"top"),right:Ia(r,"right"),bottom:Ia(r,"bottom"),left:Ia(r,"left")},u=at.some(d=>a[d]!==null)?a:nw(r);return{...o,margin:u,marginMixed:!1}}function ot(e){return ow(fi(e))}function zt(e,t){return fi(e)||!fi(t)?e:Za(e,ot(t))}function iw(e){const t=at.map(r=>e[r]);if(t.every(r=>r===null))return null;const n=t.map(r=>r?_e(r):"0");return n[0]===n[1]&&n[1]===n[2]&&n[2]===n[3]?`margin: ${n[0]};`:at.map(r=>e[r]?`margin-${r}: ${_e(e[r])};`:null).filter(Boolean).join(" ")}function aw(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(_e(e.customWidth),_e(e.customHeight)),e.orientation&&t.push(e.orientation),t.length===0?null:`size: ${t.join(" ")};`}function sw(e){const t=aw(e),n=iw(e.margin);return!t&&!n?null:`@page { ${[t,n].filter(Boolean).join(" ")} }`}function Xt(e){const t=Au(e);for(const n of t.querySelectorAll(`style[${Ga}]`))n.remove();return rg(t)}function lw(e,t){const n=Au(e);let r=n.querySelector(`style[${Ga}]`);return r||(r=n.createElement("style"),r.setAttribute(Ga,""),n.body.insertBefore(r,n.body.firstChild)),r.textContent=t,rg(n)}function Za(e,t){const n=sw(t);return n?lw(e,n):og(e)}function og(e){return Xt(e)}function ig(e){const t=e.map(n=>fi(n)).filter(n=>!!n);return t.length===0?"":t.join(`
140
+ `)}const Tu="data-page-sized",Dc={top:"--wysiwyg-page-margin-top",right:"--wysiwyg-page-margin-right",bottom:"--wysiwyg-page-margin-bottom",left:"--wysiwyg-page-margin-left"},cw="0.75rem",Ic=["top","right","bottom","left"],rc={A4:{width:"210mm",height:"297mm"},letter:{width:"8.5in",height:"11in"},legal:{width:"8.5in",height:"14in"}};function Co(e,t=!1){let n=null;return e.sizePreset==="A4"||e.sizePreset==="letter"||e.sizePreset==="legal"?n={...rc[e.sizePreset]}:e.sizePreset==="custom"&&e.customWidth&&e.customHeight?n={width:_e(e.customWidth),height:_e(e.customHeight)}:e.orientation?n=t?{...rc.letter}:null:n=t?{...rc.letter}:null,n?e.orientation==="landscape"?{width:n.height,height:n.width}:n:null}function ag(e){return Co(e,!1)!==null}function uw(e){const t=Co(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 at){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 dw(e.margin)}function dw(e){return{top:e.top?_e(e.top):null,right:e.right?_e(e.right):null,bottom:e.bottom?_e(e.bottom):null,left:e.left?_e(e.left):null}}const mw=["width","min-height","padding-top","padding-right","padding-bottom","padding-left"];function sg(e){for(const t of Ic)e.style.removeProperty(Dc[t])}function fw(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 pw(e,t){if(!fw(e)){sg(e);return}const n=ot(t);if(Co(n)){const o=Ci(n);for(const a of Ic){const s=o[a]??"0px";e.style.setProperty(Dc[a],s)}return}for(const o of Ic)e.style.setProperty(Dc[o],cw)}function gw(e){e.removeAttribute(Tu);for(const t of mw)e.style.removeProperty(t);sg(e)}function lg(e,t){const n=ot(e),r={...n.margin};return t.left!==void 0&&(r.left=Jo(t.left)),t.right!==void 0&&(r.right=Jo(t.right)),t.top!==void 0&&(r.top=Jo(t.top)),t.bottom!==void 0&&(r.bottom=Jo(t.bottom)),Za(e,{...n,margin:r})}function hw(e,t,n){wo(e,lg(t,n))}function wo(e,t){const n=ot(t),r=Co(n);if(!r){gw(e);return}e.setAttribute(Tu,""),e.style.width=r.width,e.style.minHeight=r.height;const o=Ci(n);for(const a of at){const s=`padding-${a}`,u=o[a];u?e.style.setProperty(s,u):e.style.removeProperty(s)}pw(e,t)}const cg="data-template-tag",ug=/\{\{/;function Ru(e){return e instanceof HTMLSpanElement&&e.hasAttribute(cg)}function dg(e){return ug.test(e)}function mg(e){return ug.test(e)}function bw(e,t){if(!dg(e))return!0;const n=(e.match(/data-template-tag/g)??[]).length,r=t.querySelectorAll(`[${cg}]`).length;if(n>0&&r<n)return!1;const o=e.match(/\{\{[^}]*\}\}/g)??[],a=t.textContent??"";return o.every(s=>a.includes(s))}const Rr="data-page",mo="data-page-bg",qa="commspliant-background";function kt(e){return e instanceof HTMLElement&&(e.id===qa||e.hasAttribute(mo))}function yw(e){return e.hasAttribute(Rr)&&e.parentElement?e.parentElement:e}function Du(e){const t=yw(e),n=new Set,r=[],o=a=>{a instanceof HTMLElement&&kt(a)&&!n.has(a)&&(n.add(a),r.push(a))};o(t.querySelector(`#${qa}`));for(const a of t.querySelectorAll(`[${mo}]`))o(a);return o(t),r}function Iu(e){return Du(e)[0]??null}function ri(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 fg(e,t){if(!e.hasAttribute(Tu))return ri(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 xw=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","div"]);function pg(e){return xw.has(e.tagName.toLowerCase())}function ws(e){const t=e.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li");return t[t.length-1]??null}function gg(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t))&&t instanceof HTMLElement&&pg(t))return t;return null}function hg(e){const t=gg(e)??ws(e);if(t)return t;const n=e.ownerDocument.createElement("p");return n.appendChild(e.ownerDocument.createElement("br")),e.appendChild(n),n}function vs(e){let t=!1;for(const n of[...e.childNodes]){if(n instanceof HTMLElement&&kt(n)||n instanceof HTMLElement&&Ru(n)||n.nodeType!==Node.TEXT_NODE)continue;const r=n.textContent??"";if(!r.trim()){n.remove(),t=!0;continue}if(mg(r))continue;(ws(e)??hg(e)).appendChild(n),t=!0}return t}function ks(e){const t=ut(e);if(!t)return!1;let n=!1;for(const r of[...e.childNodes])r!==t&&r instanceof HTMLElement&&kt(r)&&(t.insertBefore(r,t.firstChild),n=!0);return n}function pi(e){const t=ut(e);if(!t)return{changed:!1,absorbedBlocks:[]};let n=ks(e);const r=[];for(const o of[...e.childNodes])if(o!==t&&!(o instanceof HTMLElement&&kt(o))){if(o.nodeType===Node.TEXT_NODE){const a=o.textContent??"";if(!a.trim()){o.remove(),n=!0;continue}if(mg(a))continue;let s=ws(t);s||(s=document.createElement("p"),t.appendChild(s)),s.appendChild(o),n=!0;continue}if(o instanceof HTMLElement&&pg(o)&&r.push(o),o instanceof HTMLElement&&Ru(o)){t.appendChild(o),n=!0;continue}t.appendChild(o),n=!0}return vs(t)&&(n=!0),{changed:n,absorbedBlocks:r}}function Cw(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 ww="p, h1, h2, h3, h4, h5, h6, li, blockquote, pre";function bg(e,t){if(t<=0)return;const n=ut(e);if(!n)return;const r=n.querySelectorAll(ww);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)||Cw(o)}function yg(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(Rr)}function xg(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function vw(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function ut(e){return xg(e).find(n=>n.hasAttribute(Rr))??null}function kw(e){if(vw(e))return null;const t=xg(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"||kt(n)?null:n}function ju(e){const t=ut(e);if(t)return ri(t),t;const n=kw(e);if(n)return n.setAttribute(Rr,""),ri(n),n;const r=document.createElement("div");for(r.setAttribute(Rr,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),ri(r),r}function Eu(e){return ut(e)??e}function Sw(e,t,n){const{startContainer:r}=n;return r===t||t.contains(r)?!1:r===e?!0:e.contains(r)}function Pw(e,t){const{startContainer:n}=t;return n===e||n.nodeType===Node.TEXT_NODE&&n.parentElement===e}function Aw(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 jc(e){vs(e);const t=ws(e)??gg(e)??hg(e);Aw(t)}function Tw(e){const t=ut(e);e.focus(),t&&jc(t)}function fo(e){const t=ut(e);if(!t)return;vs(t);const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);if(Pw(t,r)){jc(t);return}Sw(e,t,r)&&jc(t)}const Rw=["background-image","background-size","background-position","background-repeat","opacity"];function Dw(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 Ss(e){const t=ut(e);Dw(e,t,"background-color");for(const n of Rw)e.style.removeProperty(n)}const Ya="<!-- wysiwyg-page-separator -->",Dr="data-page-surface";function Zn(e){const t=e.trim();return t?t.includes(Ya)?e.split(Ya).map(n=>n.trim()):[e]:[""]}function Et(e){return e.length===0?"":e.length===1?e[0]??"":e.join(`
141
141
  ${Ya}
142
- `)}function Un(){return"<p></p>"}function Gn(e){return e.length===0?[Un()]:e.map(t=>t.trim())}function oc(e,t){if(e.length===t.length){let a=!1;const l=[],u=[];for(let d=0;d<t.length;d+=1){const f=t[d]??"";e[d]===f?l.push(e[d]):(l.push(f),a=!0,u.push(d))}return a?{pages:l,changed:!0,changedIndices:u}:{pages:e,changed:!1,changedIndices:[]}}const n=[],r=[];for(let a=0;a<t.length;a+=1){const l=t[a]??"";a<e.length&&e[a]===l?n.push(e[a]):(n.push(l),r.push(a))}return r.length>0||e.length!==t.length||!kr(e,n)?{pages:n,changed:!0,changedIndices:r}:{pages:e,changed:!1,changedIndices:[]}}function kr(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 Ec(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 Ze(e,t){const n=e.querySelector(`[${Dr}][data-page-index="${t}"]`);return n||([...e.querySelectorAll(`[${Dr}]`)][t]??null)}function Iw(e){if(!e)return null;const t=e instanceof Element?e:e.parentElement;return(t==null?void 0:t.closest(`[${Dr}]`))??null}function Ym(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(`[${Dr}]`)].indexOf(e);if(o!==-1)return o;n=n.parentElement}return null}const jt="data-wysiwyg-img-id",Mc="data-page-bg",jw=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,_c=/background-image:\s*url\(\s*(["']?)(.+?)\1\s*\)/i;function Xm(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Jm(e){return e.body.innerHTML}function ic(e){return jw.test(e.trim())}function Qm(e){return e.includes("<img")||e.includes("IMG")||e.includes(Mc)||e.includes(jt)}function Ew(e){var r;const t=_c.exec(e);return t&&(((r=t[2])==null?void 0:r.trim())??"")||null}function ja(e,t){const r=`url("${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`;if(_c.test(e))return e.replace(_c,`background-image: ${r}`);const o=e.trim().replace(/;+$/,"");return o?`${o};background-image: ${r}`:`background-image: ${r}`}function Mw(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`img-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _w(){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(ef(C));return e.set(b,{dataUrl:C,objectUrl:k}),k}return x.objectUrl}const v=URL.createObjectURL(ef(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())||Mw();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 l(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(ic(x))return x;const v=(C==null?void 0:C.trim())||l(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(jt))==null?void 0:x.trim(),A=((v=k.getAttribute("src"))==null?void 0:v.trim())??"";if(C==="hydrate"){const P=u(A,S);if(!P)continue;k.setAttribute("src",P);continue}if(S&&a(S)){const P=o(S);P&&k.setAttribute("src",P);continue}const R=l(A);if(R){k.setAttribute(jt,R);const P=o(R);P&&k.setAttribute("src",P);continue}if(!ic(A))continue;const T=n(A);k.setAttribute(jt,T);const D=o(T);D&&k.setAttribute("src",D)}}function f(b,C){var x;for(const v of b.querySelectorAll(`[${Mc}]`)){if(!(v instanceof HTMLElement))continue;const k=(x=v.getAttribute(jt))==null?void 0:x.trim(),S=v.getAttribute("style")??"",A=Ew(S);if(C==="hydrate"){if(!A)continue;const P=u(A,k);if(!P)continue;v.setAttribute("style",ja(S,P));continue}if(!A)continue;if(k&&a(k)){const P=o(k);P&&v.setAttribute("style",ja(S,P));continue}const R=l(A);if(R){v.setAttribute(jt,R);const P=o(R);P&&v.setAttribute("style",ja(S,P));continue}if(!ic(A))continue;const T=n(A);v.setAttribute(jt,T);const D=o(T);D&&v.setAttribute("style",ja(S,D))}}function g(b){const C=b.trim();if(!C||!Qm(C))return b;const x=Xm(b);return d(x,"externalize"),f(x,"externalize"),Jm(x)}function h(b){const C=b.trim();if(!C||!Qm(C))return b;const x=Xm(b);f(x,"hydrate"),d(x,"hydrate");for(const v of x.querySelectorAll("img"))v.removeAttribute(jt);for(const v of x.querySelectorAll(`[${Mc}]`))v.removeAttribute(jt);return Jm(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 ef(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",l=atob(r),u=new Uint8Array(l.length);for(let d=0;d<l.length;d+=1)u[d]=l.charCodeAt(d);return new Blob([u],{type:a})}const Nw=.85,Lw=new Set(["image/webp","image/avif","image/gif"]);let Go=null;function Bw(){if(Go!==null)return Go;Go=!1;try{Go=document.createElement("canvas").toDataURL("image/webp").startsWith("data:image/webp")}catch{}return Go}function Fw(e){const t=e.type.trim().toLowerCase();if(t&&Lw.has(t))return!1;const n=Ow(e.name);return!(!t&&(n==="webp"||n==="avif"||n==="gif"))}function Hw(e,t=Nw){return typeof createImageBitmap!="function"?Promise.resolve(null):createImageBitmap(e).then(n=>zw(n,t)).catch(()=>null)}function zw(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 l=new FileReader;l.onload=()=>{const u=String(l.result??"");o(u.startsWith("data:image/webp")?u:null)},l.onerror=()=>o(null),l.readAsDataURL(a)},"image/webp",t)})}function Ow(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Cg=2*1024*1024,Kw="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",$w=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),Uw=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),wg=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,Vw=/^(javascript|vbscript|file|blob):/i;function Ww(e={}){return{src:"",alt:"",title:"",...e}}function pn(e){const t=e.trim();if(!t)return"empty";if(Vw.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return wg.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 Gw(e){return e.size>Cg?"tooLarge":t1(e)?null:"type"}function qw(e){const t=Gw(e);return t?Promise.reject(new Error(t)):Zw(e)}async function Zw(e){if(Fw(e)&&Bw()){const t=await Hw(e);if(t&&pn(t)===null&&Xw(t)<=Cg)return t}return Yw(e)}function Yw(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const o=String(r.result??"");if(pn(o)){n(new Error("invalid"));return}t(o)},r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsDataURL(e)})}function Xw(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 Jw(e,t,n){const r=vg(t,n);e.setAttribute("src",r.src.trim()),r.registryId?e.setAttribute(jt,r.registryId):e.removeAttribute(jt);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",Qw(e,t.css)}function Qw(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(),l=r.slice(o+1).trim();a&&l&&e.style.setProperty(a,l)}}function vg(e,t){if(!t)return e;const n=e.src.trim();if(pn(n)||!wg.test(n))return e;const r=t.register(n),o=t.getObjectUrl(r);return o?{...e,src:o,registryId:r}:e}function e1(e,t,n){const r=Ww(t),o=n?vg(r,n):r;if(o.registryId){const d=n==null?void 0:n.getDataUrl(o.registryId);if(!d||pn(d))return!1}else if(pn(o.src))return!1;const a=window.getSelection();if(!a||a.rangeCount===0)return!1;const l=a.getRangeAt(0);if(!Re(e,l.commonAncestorContainer))return!1;l.collapsed||l.deleteContents();const u=document.createElement("img");return Jw(u,o,n),l.insertNode(u),l.setStartAfter(u),l.collapse(!0),a.removeAllRanges(),a.addRange(l),!0}function Nc(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function ac(e,t){if(!Re(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 t1(e){const t=e.type.trim().toLowerCase();if(t&&$w.has(t))return!0;const n=n1(e.name);return!!(!t&&n&&Uw.has(n))}function n1(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const kg=["%","px","pt","pc","em","rem"],r1="%",o1={"%":[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]},po={"%":{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}},i1=new Set(kg),a1=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function l1(e){return i1.has(e)}function Sr(e){return`${be(e.value)}${e.unit}`}function Xa(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(a1);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 l1(o)?go(r,o):null}function tf(e,t){const n=e.trim();if(!n)return null;const r=Xa(n);if(r)return r;const o=Number(n.replace(",","."));return Number.isFinite(o)?go(o,t):null}function go(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=po[t];return{value:it(Math.min(r,Math.max(n,e))),unit:t}}function oi(e,t,n){const r=n>0?n:1;if(e==="width"){const a=go(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:go(t.value*r,t.unit)??t,height:t}}const Ha="data-hover-css",Mu=["fill","contain","cover","none","scale-down"],_u=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],s1=new Set(Mu),c1=new Set(_u),nf="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",u1="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",d1=/^-?[a-z][a-z0-9-]*$/i,m1=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,Lc=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function Sg(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...Jt},border:{...Su},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function f1(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function p1(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=oi("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=oi("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function g1(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(),l=r.slice(o+1).trim();!a||!l||d1.test(a)&&(a==="behavior"||a.endsWith("binding")||m1.test(l)||t.push(`${a}: ${l}`))}return t.join("; ")}function Zn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!Re(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&&Re(e,r))return r}return Nc(e,n.commonAncestorContainer)}function h1(e){const t=Zn(e);return t?Pg(t):null}function Pg(e){const t=yo(e),n=w1(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,o=y1(e);return Sg({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:Tg(e),objectPosition:P1(e),rotateDeg:Rg(e),hoverCss:e.getAttribute(Ha)??""})}function Ag(e,t){let n=!1;return x1(e,t)&&(n=!0),xo(e,{...Mr(),margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:Jt,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),v1(e,t.align)&&(n=!0),k1(e,t.objectFit)&&(n=!0),S1(e,t.objectPosition)&&(n=!0),T1(e,t.rotateDeg)&&(n=!0),R1(e,t.hoverCss)&&(n=!0),n}function b1(e,t){const n=Zn(e);return n?Ag(n,t):!1}function y1(e){const t=Xa(e.style.width),n=Xa(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 x1(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=C1(t);return r.width?e.style.width=Sr(r.width):e.style.removeProperty("width"),r.height?e.style.height=Sr(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 C1(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 w1(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 v1(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 Tg(e){const t=e.style.objectFit.trim().toLowerCase();return s1.has(t)?t:null}function k1(e,t){return Tg(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function S1(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 P1(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(c1.has(t),t):null}function Rg(e){const t=Lc.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?it(n):null}function A1(e){const t=e.trim();return t?Lc.test(t)&&t.replace(Lc,"").trim()==="":!0}function T1(e,t){const n=Rg(e),r=t===null||t===0?null:it(t);return n===r?!1:r===null?A1(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${be(r)}deg)`,!0)}function R1(e,t){const n=g1(t),r=e.getAttribute(Ha)??"",o=e.getAttribute("onmouseover")??"";return r===n&&(n&&o===nf||!n&&!o)?!1:n?(e.setAttribute(Ha,n),e.setAttribute("onmouseover",nf),e.setAttribute("onmouseout",u1),!0):(e.removeAttribute(Ha),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const lo={value:100,unit:"%"},D1=new Set(Mu),I1=new Set(_u),j1=new Set(["cover","contain","scale-down","none"]),rf={contain:"contain",cover:"cover",auto:"none"},of={fill:"100% 100%",contain:"contain",cover:"cover",none:"auto","scale-down":"contain"};function mn(){return{src:null,opacity:null,fit:null,position:null,width:{...lo},height:null}}function Dg(e){return e!=null&&j1.has(e)}function Ig(e){const t=e.style.opacity.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?Qn(n):null}function af(e,t){const n=Ig(e),r=t===null?null:Qn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=Up(r),!0)}function jg(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 E1(e){return`url("${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`}function lf(e,t){const n=jg(e),r=(t==null?void 0:t.trim())??"",o=r&&pn(r)===null?r:null;return n===o?!1:(o?e.style.backgroundImage=E1(o):e.style.removeProperty("background-image"),!0)}function Nu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function lc(e){return!e||e==="auto"?null:Xa(e)}function M1(e){return Dg(e.fit)&&e.fit?of[e.fit]:e.fit==="fill"?of.fill:e.width&&e.height?`${Sr(e.width)} ${Sr(e.height)}`:e.width?Sr(e.width):e.height?`auto ${Sr(e.height)}`:null}function _1(e){const t=Nu(e.style.backgroundSize);if(!t)return{fit:null,width:null,height:null};if(t==="100% 100%")return{fit:"fill",width:{...lo},height:{...lo}};if(rf[t])return{fit:rf[t],width:null,height:null};if(D1.has(t))return{fit:t,width:null,height:null};const n=t.split(" ");return n.length===1?{fit:null,width:lc(n[0]),height:null}:n.length===2?{fit:null,width:lc(n[0]),height:lc(n[1])}:{fit:null,width:null,height:null}}function N1(e,t){const n=Nu(e.style.backgroundSize),r=M1(t);return n===(r??"")?!1:(r?e.style.backgroundSize=r:e.style.removeProperty("background-size"),!0)}function L1(e){const t=e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(I1.has(t),t):null}function sf(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 Ja(e){let t=!1;return e.id!==Za&&(e.id=Za,t=!0),e.hasAttribute(mo)||(e.setAttribute(mo,""),t=!0),e.getAttribute("contenteditable")!=="false"&&(e.setAttribute("contenteditable","false"),t=!0),t}function Qa(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 Eg(e){const t=Du(e),n=t[0]??null;if(n){let o=Ja(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 Ja(r),Qa(r),e.insertBefore(r,e.firstChild),{layer:r,changed:!0}}function B1(e){const t=Du(e);if(t.length===0)return!1;for(const n of t)n.remove();return!0}function el(e){let t=!1;return Iu(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 Lu(e){if(!Iu(e))return el(e);const n=Eg(e);let r=n.changed;return Ja(n.layer)&&(r=!0),Qa(n.layer)&&(r=!0),el(e)&&(r=!0),r}function Pl(e){const t=ut(e);if(!t)return!1;let n=kl(e);return Lu(t)&&(n=!0),n}function F1(e){return e.includes(mo)||e.includes(Rr)}function H1(e){const t=new DOMParser().parseFromString(`<body>${e}</body>`,"text/html");kl(t.body);const n=ut(t.body);return n&&(Lu(n),vl(n)),t.body.innerHTML}function cf(e){return F1(e)?H1(e):e}function Mg(e){const t=_1(e);return{src:jg(e),opacity:Ig(e),fit:t.fit,position:L1(e),width:t.width,height:t.height}}function _g(e,t){var a;const n=((a=t.src)==null?void 0:a.trim())??"",r=n.length>0&&pn(n)===null;let o=!1;return r?(lf(e,n)&&(o=!0),N1(e,t)&&(o=!0),sf(e,t.position)&&(o=!0),af(e,t.opacity)&&(o=!0),e.style.backgroundRepeat!=="no-repeat"&&(e.style.backgroundRepeat="no-repeat",o=!0),o&&xt(e),o):(lf(e,null)&&(o=!0),Nu(e.style.backgroundSize)&&(e.style.removeProperty("background-size"),o=!0),sf(e,null)&&(o=!0),af(e,null)&&(o=!0),e.style.backgroundRepeat&&(e.style.removeProperty("background-repeat"),o=!0),o&&xt(e),o)}function z1(e){const t=Iu(e);return t?Mg(t):mn()}function O1(e,t){var u;const n=((u=t.src)==null?void 0:u.trim())??"";if(!(n.length>0&&pn(n)===null)){const d=B1(e),f=el(e);return(d||f)&&xt(e),d||f}const o=Eg(e),a=o.layer;let l=o.changed;return Ja(a)&&(l=!0),Qa(a)&&(l=!0),el(e)&&(l=!0),_g(a,t)&&(l=!0),Qa(a)&&(l=!0),l&&(xt(a),xt(e)),l}function K1(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function $1(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 uf(e){const t=e.trim().match(/^([\d.]+)pt$/i);return t?Number.parseFloat(t[1]):null}function U1(e,t){if(!t)return e;if(!e)return t;const n=uf(e),r=uf(t);return n!==null&&r!==null?`${Math.max(n,r)}pt`:t}function V1(e,t){const n=ot(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=Co(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 at){const l=`padding-${a}`,u=r[a],d=e.style.getPropertyValue(l).trim()||null,f=U1(d,u);f&&e.style.setProperty(l,f)}}function Bu(e){const t=K1(e);let n=!1;kl(t.body);for(const r of t.querySelectorAll(`[${Rr}]`)){if(!(r instanceof HTMLElement))continue;const o=r.querySelector(`[${mo}]`);!(o instanceof HTMLElement)||!$1(o)||(n=!0,V1(r,e),Lu(r))}return{html:t.body.innerHTML,hasBleed:n}}const df=`
142
+ `)}function Un(){return"<p></p>"}function Gn(e){return e.length===0?[Un()]:e.map(t=>t.trim())}function oc(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||!kr(e,n)?{pages:n,changed:!0,changedIndices:r}:{pages:e,changed:!1,changedIndices:[]}}function kr(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 Ec(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 qe(e,t){const n=e.querySelector(`[${Dr}][data-page-index="${t}"]`);return n||([...e.querySelectorAll(`[${Dr}]`)][t]??null)}function Iw(e){if(!e)return null;const t=e instanceof Element?e:e.parentElement;return(t==null?void 0:t.closest(`[${Dr}]`))??null}function Ym(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(`[${Dr}]`)].indexOf(e);if(o!==-1)return o;n=n.parentElement}return null}const jt="data-wysiwyg-img-id",Mc="data-page-bg",jw=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,_c=/background-image:\s*url\(\s*(["']?)(.+?)\1\s*\)/i;function Xm(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Jm(e){return e.body.innerHTML}function ic(e){return jw.test(e.trim())}function Qm(e){return e.includes("<img")||e.includes("IMG")||e.includes(Mc)||e.includes(jt)}function Ew(e){var r;const t=_c.exec(e);return t&&(((r=t[2])==null?void 0:r.trim())??"")||null}function ja(e,t){const r=`url("${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`;if(_c.test(e))return e.replace(_c,`background-image: ${r}`);const o=e.trim().replace(/;+$/,"");return o?`${o};background-image: ${r}`:`background-image: ${r}`}function Mw(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`img-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _w(){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(ef(C));return e.set(b,{dataUrl:C,objectUrl:k}),k}return x.objectUrl}const v=URL.createObjectURL(ef(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())||Mw();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(ic(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(jt))==null?void 0:x.trim(),A=((v=k.getAttribute("src"))==null?void 0:v.trim())??"";if(C==="hydrate"){const P=u(A,S);if(!P)continue;k.setAttribute("src",P);continue}if(S&&a(S)){const P=o(S);P&&k.setAttribute("src",P);continue}const R=s(A);if(R){k.setAttribute(jt,R);const P=o(R);P&&k.setAttribute("src",P);continue}if(!ic(A))continue;const T=n(A);k.setAttribute(jt,T);const D=o(T);D&&k.setAttribute("src",D)}}function f(b,C){var x;for(const v of b.querySelectorAll(`[${Mc}]`)){if(!(v instanceof HTMLElement))continue;const k=(x=v.getAttribute(jt))==null?void 0:x.trim(),S=v.getAttribute("style")??"",A=Ew(S);if(C==="hydrate"){if(!A)continue;const P=u(A,k);if(!P)continue;v.setAttribute("style",ja(S,P));continue}if(!A)continue;if(k&&a(k)){const P=o(k);P&&v.setAttribute("style",ja(S,P));continue}const R=s(A);if(R){v.setAttribute(jt,R);const P=o(R);P&&v.setAttribute("style",ja(S,P));continue}if(!ic(A))continue;const T=n(A);v.setAttribute(jt,T);const D=o(T);D&&v.setAttribute("style",ja(S,D))}}function g(b){const C=b.trim();if(!C||!Qm(C))return b;const x=Xm(b);return d(x,"externalize"),f(x,"externalize"),Jm(x)}function h(b){const C=b.trim();if(!C||!Qm(C))return b;const x=Xm(b);f(x,"hydrate"),d(x,"hydrate");for(const v of x.querySelectorAll("img"))v.removeAttribute(jt);for(const v of x.querySelectorAll(`[${Mc}]`))v.removeAttribute(jt);return Jm(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 ef(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 Nw=.85,Lw=new Set(["image/webp","image/avif","image/gif"]);let Go=null;function Bw(){if(Go!==null)return Go;Go=!1;try{Go=document.createElement("canvas").toDataURL("image/webp").startsWith("data:image/webp")}catch{}return Go}function Fw(e){const t=e.type.trim().toLowerCase();if(t&&Lw.has(t))return!1;const n=Ow(e.name);return!(!t&&(n==="webp"||n==="avif"||n==="gif"))}function Hw(e,t=Nw){return typeof createImageBitmap!="function"?Promise.resolve(null):createImageBitmap(e).then(n=>zw(n,t)).catch(()=>null)}function zw(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 Ow(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Cg=2*1024*1024,Kw="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",$w=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),Uw=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),wg=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,Vw=/^(javascript|vbscript|file|blob):/i;function Ww(e={}){return{src:"",alt:"",title:"",...e}}function pn(e){const t=e.trim();if(!t)return"empty";if(Vw.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return wg.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 Gw(e){return e.size>Cg?"tooLarge":t1(e)?null:"type"}function Zw(e){const t=Gw(e);return t?Promise.reject(new Error(t)):qw(e)}async function qw(e){if(Fw(e)&&Bw()){const t=await Hw(e);if(t&&pn(t)===null&&Xw(t)<=Cg)return t}return Yw(e)}function Yw(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const o=String(r.result??"");if(pn(o)){n(new Error("invalid"));return}t(o)},r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsDataURL(e)})}function Xw(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 Jw(e,t,n){const r=vg(t,n);e.setAttribute("src",r.src.trim()),r.registryId?e.setAttribute(jt,r.registryId):e.removeAttribute(jt);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",Qw(e,t.css)}function Qw(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 vg(e,t){if(!t)return e;const n=e.src.trim();if(pn(n)||!wg.test(n))return e;const r=t.register(n),o=t.getObjectUrl(r);return o?{...e,src:o,registryId:r}:e}function e1(e,t,n){const r=Ww(t),o=n?vg(r,n):r;if(o.registryId){const d=n==null?void 0:n.getDataUrl(o.registryId);if(!d||pn(d))return!1}else if(pn(o.src))return!1;const a=window.getSelection();if(!a||a.rangeCount===0)return!1;const s=a.getRangeAt(0);if(!Re(e,s.commonAncestorContainer))return!1;s.collapsed||s.deleteContents();const u=document.createElement("img");return Jw(u,o,n),s.insertNode(u),s.setStartAfter(u),s.collapse(!0),a.removeAllRanges(),a.addRange(s),!0}function Nc(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function ac(e,t){if(!Re(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 t1(e){const t=e.type.trim().toLowerCase();if(t&&$w.has(t))return!0;const n=n1(e.name);return!!(!t&&n&&Uw.has(n))}function n1(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const kg=["%","px","pt","pc","em","rem"],r1="%",o1={"%":[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]},po={"%":{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}},i1=new Set(kg),a1=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function s1(e){return i1.has(e)}function Sr(e){return`${be(e.value)}${e.unit}`}function Xa(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(a1);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 s1(o)?go(r,o):null}function tf(e,t){const n=e.trim();if(!n)return null;const r=Xa(n);if(r)return r;const o=Number(n.replace(",","."));return Number.isFinite(o)?go(o,t):null}function go(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=po[t];return{value:it(Math.min(r,Math.max(n,e))),unit:t}}function oi(e,t,n){const r=n>0?n:1;if(e==="width"){const a=go(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:go(t.value*r,t.unit)??t,height:t}}const Ha="data-hover-css",Mu=["fill","contain","cover","none","scale-down"],_u=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],l1=new Set(Mu),c1=new Set(_u),nf="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",u1="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",d1=/^-?[a-z][a-z0-9-]*$/i,m1=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,Lc=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function Sg(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...Jt},border:{...Su},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function f1(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function p1(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=oi("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=oi("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function g1(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||d1.test(a)&&(a==="behavior"||a.endsWith("binding")||m1.test(s)||t.push(`${a}: ${s}`))}return t.join("; ")}function qn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!Re(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&&Re(e,r))return r}return Nc(e,n.commonAncestorContainer)}function h1(e){const t=qn(e);return t?Pg(t):null}function Pg(e){const t=yo(e),n=w1(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,o=y1(e);return Sg({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:Tg(e),objectPosition:P1(e),rotateDeg:Rg(e),hoverCss:e.getAttribute(Ha)??""})}function Ag(e,t){let n=!1;return x1(e,t)&&(n=!0),xo(e,{...Mr(),margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:Jt,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),v1(e,t.align)&&(n=!0),k1(e,t.objectFit)&&(n=!0),S1(e,t.objectPosition)&&(n=!0),T1(e,t.rotateDeg)&&(n=!0),R1(e,t.hoverCss)&&(n=!0),n}function b1(e,t){const n=qn(e);return n?Ag(n,t):!1}function y1(e){const t=Xa(e.style.width),n=Xa(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 x1(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=C1(t);return r.width?e.style.width=Sr(r.width):e.style.removeProperty("width"),r.height?e.style.height=Sr(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 C1(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 w1(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 v1(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 Tg(e){const t=e.style.objectFit.trim().toLowerCase();return l1.has(t)?t:null}function k1(e,t){return Tg(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function S1(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 P1(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(c1.has(t),t):null}function Rg(e){const t=Lc.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?it(n):null}function A1(e){const t=e.trim();return t?Lc.test(t)&&t.replace(Lc,"").trim()==="":!0}function T1(e,t){const n=Rg(e),r=t===null||t===0?null:it(t);return n===r?!1:r===null?A1(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${be(r)}deg)`,!0)}function R1(e,t){const n=g1(t),r=e.getAttribute(Ha)??"",o=e.getAttribute("onmouseover")??"";return r===n&&(n&&o===nf||!n&&!o)?!1:n?(e.setAttribute(Ha,n),e.setAttribute("onmouseover",nf),e.setAttribute("onmouseout",u1),!0):(e.removeAttribute(Ha),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const so={value:100,unit:"%"},D1=new Set(Mu),I1=new Set(_u),j1=new Set(["cover","contain","scale-down","none"]),rf={contain:"contain",cover:"cover",auto:"none"},of={fill:"100% 100%",contain:"contain",cover:"cover",none:"auto","scale-down":"contain"};function mn(){return{src:null,opacity:null,fit:null,position:null,width:{...so},height:null}}function Dg(e){return e!=null&&j1.has(e)}function Ig(e){const t=e.style.opacity.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?Qn(n):null}function af(e,t){const n=Ig(e),r=t===null?null:Qn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=Up(r),!0)}function jg(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 E1(e){return`url("${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`}function sf(e,t){const n=jg(e),r=(t==null?void 0:t.trim())??"",o=r&&pn(r)===null?r:null;return n===o?!1:(o?e.style.backgroundImage=E1(o):e.style.removeProperty("background-image"),!0)}function Nu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function sc(e){return!e||e==="auto"?null:Xa(e)}function M1(e){return Dg(e.fit)&&e.fit?of[e.fit]:e.fit==="fill"?of.fill:e.width&&e.height?`${Sr(e.width)} ${Sr(e.height)}`:e.width?Sr(e.width):e.height?`auto ${Sr(e.height)}`:null}function _1(e){const t=Nu(e.style.backgroundSize);if(!t)return{fit:null,width:null,height:null};if(t==="100% 100%")return{fit:"fill",width:{...so},height:{...so}};if(rf[t])return{fit:rf[t],width:null,height:null};if(D1.has(t))return{fit:t,width:null,height:null};const n=t.split(" ");return n.length===1?{fit:null,width:sc(n[0]),height:null}:n.length===2?{fit:null,width:sc(n[0]),height:sc(n[1])}:{fit:null,width:null,height:null}}function N1(e,t){const n=Nu(e.style.backgroundSize),r=M1(t);return n===(r??"")?!1:(r?e.style.backgroundSize=r:e.style.removeProperty("background-size"),!0)}function L1(e){const t=e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(I1.has(t),t):null}function lf(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 Ja(e){let t=!1;return e.id!==qa&&(e.id=qa,t=!0),e.hasAttribute(mo)||(e.setAttribute(mo,""),t=!0),e.getAttribute("contenteditable")!=="false"&&(e.setAttribute("contenteditable","false"),t=!0),t}function Qa(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 Eg(e){const t=Du(e),n=t[0]??null;if(n){let o=Ja(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 Ja(r),Qa(r),e.insertBefore(r,e.firstChild),{layer:r,changed:!0}}function B1(e){const t=Du(e);if(t.length===0)return!1;for(const n of t)n.remove();return!0}function es(e){let t=!1;return Iu(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 Lu(e){if(!Iu(e))return es(e);const n=Eg(e);let r=n.changed;return Ja(n.layer)&&(r=!0),Qa(n.layer)&&(r=!0),es(e)&&(r=!0),r}function Ps(e){const t=ut(e);if(!t)return!1;let n=ks(e);return Lu(t)&&(n=!0),n}function F1(e){return e.includes(mo)||e.includes(Rr)}function H1(e){const t=new DOMParser().parseFromString(`<body>${e}</body>`,"text/html");ks(t.body);const n=ut(t.body);return n&&(Lu(n),vs(n)),t.body.innerHTML}function cf(e){return F1(e)?H1(e):e}function Mg(e){const t=_1(e);return{src:jg(e),opacity:Ig(e),fit:t.fit,position:L1(e),width:t.width,height:t.height}}function _g(e,t){var a;const n=((a=t.src)==null?void 0:a.trim())??"",r=n.length>0&&pn(n)===null;let o=!1;return r?(sf(e,n)&&(o=!0),N1(e,t)&&(o=!0),lf(e,t.position)&&(o=!0),af(e,t.opacity)&&(o=!0),e.style.backgroundRepeat!=="no-repeat"&&(e.style.backgroundRepeat="no-repeat",o=!0),o&&xt(e),o):(sf(e,null)&&(o=!0),Nu(e.style.backgroundSize)&&(e.style.removeProperty("background-size"),o=!0),lf(e,null)&&(o=!0),af(e,null)&&(o=!0),e.style.backgroundRepeat&&(e.style.removeProperty("background-repeat"),o=!0),o&&xt(e),o)}function z1(e){const t=Iu(e);return t?Mg(t):mn()}function O1(e,t){var u;const n=((u=t.src)==null?void 0:u.trim())??"";if(!(n.length>0&&pn(n)===null)){const d=B1(e),f=es(e);return(d||f)&&xt(e),d||f}const o=Eg(e),a=o.layer;let s=o.changed;return Ja(a)&&(s=!0),Qa(a)&&(s=!0),es(e)&&(s=!0),_g(a,t)&&(s=!0),Qa(a)&&(s=!0),s&&(xt(a),xt(e)),s}function K1(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function $1(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 uf(e){const t=e.trim().match(/^([\d.]+)pt$/i);return t?Number.parseFloat(t[1]):null}function U1(e,t){if(!t)return e;if(!e)return t;const n=uf(e),r=uf(t);return n!==null&&r!==null?`${Math.max(n,r)}pt`:t}function V1(e,t){const n=ot(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=Co(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 at){const s=`padding-${a}`,u=r[a],d=e.style.getPropertyValue(s).trim()||null,f=U1(d,u);f&&e.style.setProperty(s,f)}}function Bu(e){const t=K1(e);let n=!1;ks(t.body);for(const r of t.querySelectorAll(`[${Rr}]`)){if(!(r instanceof HTMLElement))continue;const o=r.querySelector(`[${mo}]`);!(o instanceof HTMLElement)||!$1(o)||(n=!0,V1(r,e),Lu(r))}return{html:t.body.innerHTML,hasBleed:n}}const df=`
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 Ng(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function G1(e){return Ng(e).replace(/'/g,"&#39;")}function Lg(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 q1(e,t="Document"){const n=qn(e),r=n.map(b=>Bu(b)),o=r.some(b=>b.hasBleed),a=[],l=[];for(const b of r){const C=ye(b.html);a.push(...C.hrefs),l.push(C.body)}const u=l.length<=1?l[0]??"":l.map((b,C)=>`<div data-wysiwyg-print-page="" style="${C===l.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=ig(n),f=o?"@page { margin: 0 !important; }":"",g=Bg(o),h=[d,f,g].filter(Boolean).join(`
313
+ `.trim();function Ng(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function G1(e){return Ng(e).replace(/'/g,"&#39;")}function Lg(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 Z1(e,t="Document"){const n=Zn(e),r=n.map(b=>Bu(b)),o=r.some(b=>b.hasBleed),a=[],s=[];for(const b of r){const C=ye(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=ig(n),f=o?"@page { margin: 0 !important; }":"",g=Bg(o),h=[d,f,g].filter(Boolean).join(`
314
314
  `),y=Array.from(new Set(a)).map(b=>`<link rel="stylesheet" href="${G1(b)}" />`).join(`
315
315
  `);return["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="utf-8">',`<title>${Ng(t)}</title>`,`<style>${h}</style>`,y,"</head>","<body>",u,"</body>","</html>"].filter(Boolean).join(`
316
316
  `)}function Bg(e){return e?`${df}
317
- ${W1}`:df}function Bc(e,t,n="​"){const r=Bu(t),{hrefs:o,body:a}=ye(r.html),l=e.createElement("meta");l.setAttribute("charset","utf-8");const u=e.createElement("title");u.textContent=n;const d=e.createElement("style");d.textContent=Bg(r.hasBleed);const f=o.map(g=>{const h=e.createElement("link");return h.rel="stylesheet",h.href=g,h});e.head.replaceChildren(l,u,d,...f),e.title=n,e.body.innerHTML=a}function Fu(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 Z1(e){const t=e.name.toLowerCase();return e.type==="text/html"||t.endsWith(".html")||t.endsWith(".htm")}function Ea(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 Y1(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 l=a.getAsFile();l&&t.push(l)}return t}function X1(e){return e?Y1(e).find(Z1)??null:null}const Fg={description:"HTML",accept:{"text/html":[".html",".htm"]}},J1="document.html";function Hg(){return window}function zg(e){return e instanceof DOMException&&e.name==="AbortError"}function Q1(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 ev(){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}Fu(r).then(a=>n(Lg(a)),()=>n(null))}),t.addEventListener("cancel",()=>n(null)),document.body.append(t),t.click()})}async function tv(e,t=J1){const n=Hg().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(zg(r))return;throw r}return}Q1(e,t)}async function nv(){const e=Hg().showOpenFilePicker;if(typeof e=="function")try{const[t]=await e({multiple:!1,types:[Fg]}),n=await t.getFile();return Lg(await Fu(n))}catch(t){if(zg(t))return null;throw t}return ev()}const rv=1e3;function ov(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 iv(e){const t=[...e.images];return t.length===0?Promise.resolve():Promise.all(t.map(ov)).then(()=>{})}function Og(){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 Kg(e,t,n,r){Bc(e,r);let o=!1;const a=()=>{o||(o=!0,n.remove())};t.addEventListener("afterprint",a),await iv(e),t.focus(),t.print(),window.setTimeout(a,rv)}function av(e){const t=Og();t&&Kg(t.doc,t.win,t.iframe,e)}function lv(e){const t=Og();if(!t)return;const n=e.map(Bu),r=n.some(g=>g.hasBleed),o=[],a=[];for(const g of n){const h=ye(g.html);o.push(...h.hrefs),a.push(h.body)}const l=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=ig(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}" />`),l].filter(Boolean).join("");Kg(t.doc,t.win,t.iframe,f)}function sv(e){return{save:async()=>{if(e.onSave){const t=e.isMultiPagesEnabled()?e.getAllPagesHtml():e.getHtml();await e.onSave(t);return}await tv(q1(e.getHtml()))},open:async()=>{const t=e.onOpen?await e.onOpen():await nv();if(t!==null){if(Array.isArray(t)){e.setHtml(Et(t));return}if(e.isMultiPagesEnabled()){e.setHtml(Et([t]));return}e.setHtml(t)}},print:()=>{if(e.isMultiPagesEnabled()){lv(qn(e.getHtml()));return}av(e.getHtml())}}}function cv(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 uv(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 dv(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function mv(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function fv(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 pv(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected(),isMultiPagesEnabled:()=>e.isMultiPagesEnabled(),hasSelectedPage:()=>e.hasSelectedPage(),canDeletePage:()=>e.canDeletePage(),canInsertPageBackgroundImage:()=>e.canInsertPageBackgroundImage(),canInsertParagraphBackgroundImage:()=>e.canInsertParagraphBackgroundImage()}}function gv(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 hv(e){return{isInTable:()=>e.isInTable(),canMergeCells:()=>e.canMergeCells(),canUnmergeCells:()=>e.canUnmergeCells()}}function bv(e){return{openHelp:()=>{e.openHelp()},openKeyboardShortcuts:()=>{e.openKeyboardShortcuts()},openAbout:()=>{e.openAbout()}}}const yv=[50,75,100,125,150,200],xv=.1,Cv=3;function sc(e){return!Number.isFinite(e)||e<=0?1:Math.min(Cv,Math.max(xv,e))}function wv(e,t,n,r,o){if(e==="fitWidth")return r<=0?1:sc(t/r);if(e==="fitPage"){if(r<=0||o<=0)return 1;const a=t/r,l=n/o;return sc(Math.min(a,l))}return sc(e/100)}function vv(e){let t=null;return{schedule(){t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(window.cancelAnimationFrame(t),t=null)}}}function On(e,t){return()=>{e.setPageZoom(t)}}function Kn(e,t){return()=>e.getPageZoom()===t}function kv(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:On(e,"fitWidth"),setPageZoomFitPage:On(e,"fitPage"),setPageZoom50:On(e,50),setPageZoom75:On(e,75),setPageZoom100:On(e,100),setPageZoom125:On(e,125),setPageZoom150:On(e,150),setPageZoom200:On(e,200),setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function Sv(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isPageZoomFitWidth:Kn(e,"fitWidth"),isPageZoomFitPage:Kn(e,"fitPage"),isPageZoom50:Kn(e,50),isPageZoom75:Kn(e,75),isPageZoom100:Kn(e,100),isPageZoom125:Kn(e,125),isPageZoom150:Kn(e,150),isPageZoom200:Kn(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 Pv(e){return{addComment:()=>e.addComment(),toggleCommentsVisible:()=>e.toggleCommentsVisible()}}function Av(e){return{canAddComment:()=>e.canAddComment(),areCommentsVisible:()=>e.areCommentsVisible(),isCommentsEnabled:()=>e.isCommentsEnabled()}}function Tv(e){return{...sv(e),...dv(e),...gx(e),...fv(e),...gv(e),...kv(e),...cv(e),...Pv(e),...bv(e)}}function Rv(e){return{...Sv(e),...mv(e),...pv(e),...hv(e),...uv(e),...Av(e)}}function tl(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Dv(e){const t=e.style.fontSize;if(!t)return null;const n=gu(t);return!n||!xl(n.unit)?null:{value:n.value,unit:n.unit}}function $g(e,t){let n=tl(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Dv(n);if(r)return r;n=n.parentElement}return null}function Iv(e,t){const n=tl(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function Ug(e,t){var a;let n=tl(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=tl(t))==null?void 0:a.parentElement)??e,o=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(o)&&o>0?o:16}function Vg(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function jv(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function mf(e=so){return{value:null,unit:e,mixed:!1}}function Wg(e,t=so){const n=window.getSelection();if(!n||n.rangeCount===0)return mf(t);const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer))return mf(t);const o=r.collapsed?[]:vt(r).filter(f=>f.data.length>0),a=o.length>0?o:[r.startContainer],l=a.map(f=>$g(e,f)),u=l[0];if(l.every(f=>jv(f,u))&&u)return{value:u.value,unit:u.unit,mixed:!1};if(l.every(f=>f===null)){const f=a.map(h=>Iv(h,e)),g=f[0];if(f.every(h=>Math.abs(h-g)<.05)){const h=Ug(e,a[0]),y=Vg(e);return{value:Pp(g,t,h,y),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function Ev(e,t){return{parentPx:Ug(e,t),rootPx:Vg(e)}}function Mv(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Fc(e,t,n){const r=Ar(t,n);if(!r)return!1;const o=Mv(e);if(!o||o.collapsed)return!1;const a=pu(r.value,r.unit);fn(o);const l=vt(o).filter(u=>u.data.length>0);for(const u of l){const d=$g(e,u);d&&d.value===r.value&&d.unit===r.unit||bi(u,f=>{f.style.fontSize=a})}return jr(l),!0}function _v(e,t){e.style.fontSize=pu(t.value,t.unit)}function Nv(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Lv(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=Lv(r.slice(0,o)),l=r.slice(o+1).trim();a&&(t[a]=l)}return t}function Gg(e){return Object.entries(e).filter(([t])=>t.trim()).map(([t,n])=>`${t}: ${n}`).join("; ")}function Bv(e,t){const n={...e};for(const[r,o]of Object.entries(t))o.trim()?n[r]=o:delete n[r];return n}function Fv(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 Al(e){const t=Hc(e);return Gg(t)}function Hv(e,t){let n=Nv(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=n.style.cssText.trim();if(r)return r;n=n.parentElement}return""}function qg(e){const t=hn(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:vt(t).filter(d=>d.data.length>0),a=(n.length>0?n:[t.startContainer]).map(d=>Hv(e,d)).map(d=>d.trim()),l=a[0]??"";return a.every(d=>d===l)?{value:l||null,mixed:!1}:{value:null,mixed:!0}}function Zg(e,t){const n=Hc(e.style.cssText),r=Hc(t),o=Bv(n,r),a=Gg(o);a?e.style.cssText=a:e.removeAttribute("style")}function Yg(e,t){const n=Al(t);if(!n)return!1;const r=hn(e);if(!r||r.collapsed)return!1;fn(r);const o=vt(r).filter(a=>a.data.length>0);if(o.length===0)return!1;for(const a of o)bi(a,l=>{Zg(l,n),rr(l)&&Mt(l)});return jr(o),!0}function zv(e,t){const n=Al(t);n&&Zg(e,n)}function Ov(e){return!!(e&&Al(e))}const $t=["bold","italic","underline","strikethrough"],ro={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},Kv=new Set(["underline","line-through","overline"]);function Yn(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function $v(e,t){return $t.every(n=>e[n]===t[n])}function Uv(e){return $t.some(t=>e[t]!==void 0)}function Xg(e,t){const n={...e};if(!t)return n;for(const r of $t){const o=t[r];o!==void 0&&(n[r]=o)}return n}function Vv(e,t,n){const r=e[n]??t[n],o={...e,[n]:!r};return o[n]===t[n]&&delete o[n],o}function er(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>Kv.has(n))}function ho(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 Jg(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(ro.bold.has(r))return!0;const l=n.style.fontWeight;if(!l)return null;if(l==="bold"||l==="bolder")return!0;const u=Number(l);return Number.isNaN(u)?l==="normal"||l==="lighter"?!1:null:u>=700}if(t==="italic"){if(ro.italic.has(r))return!0;const l=n.style.fontStyle;return l?l==="italic"||l==="oblique"?!0:l==="normal"?!1:null:null}if(t==="underline"){if(ro.underline.has(r))return!0;const l=n.style.textDecorationLine||n.style.textDecoration;if(!l)return null;if(l==="none")return!1;const u=er(n);return u.includes("underline")?!0:u.length>0?!1:null}if(ro.strikethrough.has(r))return!0;const o=n.style.textDecorationLine||n.style.textDecoration;if(!o)return null;if(o==="none")return!1;const a=er(n);return a.includes("line-through")?!0:a.length>0?!1:null}function nl(e,t){return Jg(e,t)===!0}function bo(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const o=Jg(r,n);if(o!==null)return o;r=r.parentElement}return!1}function Qg(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=er(e);r.includes("underline")||r.push("underline"),ho(e,r);return}const n=er(e);n.includes("line-through")||n.push("line-through"),ho(e,n)}function eh(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"){ho(e,er(e).filter(n=>n!=="underline"));return}ho(e,er(e).filter(n=>n!=="line-through"))}function Wv(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=er(e).filter(o=>o!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}ho(e,r);return}const n=er(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}ho(e,n)}function Gv(e,t){bi(e,n=>Qg(n,t))}function qv(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!nl(o,n)){r=o;continue}if(or(o,r),nl(o,n)){if(ro[n].has(o.tagName.toLowerCase())){Mt(o);continue}if(eh(o,n),rr(o)){Mt(o);continue}}r=o}}function Zv(e,t,n){const r=vt(t).filter(o=>o.data.length>0);return r.length===0?bo(e,t.startContainer,n):r.every(o=>bo(e,o,n))}function Yv(e,t,n,r){fn(t);const o=vt(t).filter(a=>a.data.length>0);for(const a of o)r?bo(e,a,n)||Gv(a,n):qv(e,a,n);jr(o)}function oo(e){const t=window.getSelection();if(!t||t.rangeCount===0)return Yn();const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return Yn();if(n.collapsed)return zc(e,n);const r=vt(n).filter(a=>a.data.length>0);if(r.length===0)return zc(e,n);const o=Yn();for(const a of $t)o[a]=bo(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const l of $t)o[l]=o[l]&&bo(e,r[a],l);return o}function zc(e,t){const n=Yn();for(const r of $t)n[r]=bo(e,t.startContainer,r);return n}function Oc(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer)||r.collapsed)return!1;const o=Zv(e,r,t);return Yv(e,r,t,!o),!0}function Xv(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 Jv(e,t,n){var a,l,u;Xv(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("");(l=t.startContainer.parentNode)==null||l.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(!gn(d)){o=d;continue}if(!n.some(g=>nl(d,g))){o=d;continue}or(d,o);for(const g of n)if(nl(d,g)){if(ro[g].has(d.tagName.toLowerCase())){Mt(d);break}if(eh(d,g),rr(d)){Mt(d);break}}o=d.isConnected?d:r}return r}function Qv(e,t,n){for(const r of $t)n[r]!==t[r]&&(n[r]?Qg(e,r):Wv(e,r))}function ek(e,t,n,r,o,a,l){var S,A;const u=window.getSelection();if(!u||u.rangeCount===0)return;const d=u.getRangeAt(0);if(!Re(e,d.commonAncestorContainer))return;const f=zc(e,d),g=Xg(f,n),h=$t.filter(R=>f[R]&&!g[R]),y=AC(e,d.startContainer,o),b=Zx(e,d.startContainer,a);let C=null;h.length>0?(C=Jv(e,d,h),y.length>0&&_p(e,C,y),b&&Sc(e,C)):y.length>0?(C=PC(e,d,y),b&&Sc(e,C)):b?C=qx(e,d):d.deleteContents();const x=document.createElement("span");Qv(x,f,g),r&&_v(x,r),o!=null&&o.color&&Um(x,"color",o.color),o!=null&&o.backgroundColor&&Um(x,"backgroundColor",o.backgroundColor),a&&Ux(x,a),l&&zv(x,l),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&&((A=C.parentNode)==null||A.removeChild(C))):d.insertNode(v);const k=document.createRange();k.selectNodeContents(v),k.collapse(!1),u.removeAllRanges(),u.addRange(k)}const rl=["p","h1","h2","h3","h4","h5","h6"],tk=new Set(rl),th=new Set([...rl,"div"]),Tl=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),nk=()=>({tag:null,mixed:!1});function nh(e){return tk.has(e)}function rk(e){return nh(e)?e:e==="div"?"p":null}function ok(e){return e instanceof Element&&Tl.has(Le(e))}function rh(e){return e instanceof HTMLElement&&!kt(e)&&th.has(Le(e))}function Kc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Le(e);return th.has(t)||Tl.has(t)?!1:gn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function ik(e,t){let n=xi(t);for(;n&&n!==e;){if(Tl.has(Le(n)))return!0;n=n.parentElement}return!1}function oh(e,t){let n=xi(t);for(;n&&n!==e;){if(yg(n,e)){n=n.parentElement;continue}if(rh(n))return n;if(Tl.has(Le(n)))return null;n=n.parentElement}return null}function ak(e,t){const n=new Set,r=[];for(const o of Cu(t)){const a=oh(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function lk(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function sk(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&Kc(n[o-1]);)o-=1;for(;a<n.length-1&&Kc(n[a+1]);)a+=1;return n.slice(o,a+1)}function $c(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t)))return t;return null}function ck(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&&kt(r)?$c(e):r}return n.startContainer===t&&e!==t?$c(e):lk(e,n.startContainer)}function uk(e,t,n){const r=Eu(e);if(ik(e,t.startContainer))return!1;if(!$c(r)){const u=document.createElement(n);return u.appendChild(document.createElement("br")),r.appendChild(u),!0}const o=ck(r,e,t);if(!o||o instanceof HTMLElement&&kt(o)||ok(o)||rh(o)||!Kc(o))return!1;const a=sk(r,o),l=document.createElement(n);r.insertBefore(l,a[0]);for(const u of a)l.appendChild(u);return!0}function dk(e){const t=hn(e);if(!t)return nk();const n=Cu(t).map(o=>{const a=oh(e,o);return a?rk(Le(a)):null}),r=n[0];return n.every(o=>o===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function mk(e,t){if(!nh(t))return!1;const n=hn(e);if(!n)return!1;const r=co(e,n.startContainer,n.startOffset),o=co(e,n.endContainer,n.endOffset),a=Math.min(r,o),l=Math.max(r,o),u=ak(e,n);let d=!1;if(u.length===0)d=uk(e,n,t);else for(const f of u)Le(f)!==t&&(vu(f,t),d=!0);return wu(e,a,l),d}function Hu(e){if(!Kt(e))return null;const t=uo(e);if(!t)return null;const n=Le(t);return n==="ul"||n==="ol"?n:null}function ih(e){const t=En(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(Hu),r=n[0];return n.every(o=>o===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function fk(e,t,n){const r=[...e.children].filter(o=>xu(o));for(const o of r)t.insertBefore(o,n)}function ah(e){const t=uo(e),n=document.createElement("p");for(const f of[...e.attributes])n.setAttribute(f.name,f.value);for(n.style.marginLeft="",xt(n);e.firstChild&&!xu(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 l=Kt(a)?a.parentNode??a:a,u=Kt(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 l.insertBefore(n,u),d&&l.insertBefore(d,n.nextSibling),fk(e,l,n.nextSibling),t.childElementCount===0&&t.remove(),n}function pk(e){if(Kt(e))return e;const t=vu(e,"li");return t.style.marginLeft="",xt(t),t}function lh(e,t){if(e.length===0)return!1;if(e.every(Kt)){const a=uo(e[0]);if(a&&e.every(l=>l.parentElement===a)&&[...a.children].every(u=>u instanceof HTMLElement&&e.includes(u)))return Le(a)===t?!1:(vu(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 l=Kt(a)?uo(a):null;o.appendChild(pk(a)),l&&l!==o&&l.childElementCount===0&&l.remove()}return!0}function sh(e){let t=!1;for(const n of[...e].reverse())Kt(n)&&(ah(n),t=!0);return t}function gk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;if(n.every(a=>Hu(a)===t))return sh(n);let o=!1;for(const a of Ip(n))lh(a,t)&&(o=!0);return o})}function hk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;if(t===null)return sh(n);if(n.every(a=>Hu(a)===t))return!1;let o=!1;for(const a of Ip(n))lh(a,t)&&(o=!0);return o})}const ch=40;function zu(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function uh(e,t){if(t<=0){e.style.marginLeft="",xt(e);return}e.style.marginLeft=`${t}px`}function bk(e){let t=e.previousElementSibling;for(;t;){if(Kt(t))return t;t=t.previousElementSibling}return null}function yk(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(Le(n)==="ul"||Le(n)==="ol"))return n}return null}function xk(e){const t=bk(e);if(!t)return!1;const n=uo(e);if(!n)return!1;const r=Le(n)==="ol"?"ol":"ul";let o=yk(t);return(!o||Le(o)!==r)&&(o=document.createElement(r),t.appendChild(o)),o.appendChild(e),!0}function Ck(e){const t=uo(e);if(!t)return!1;const n=t.parentElement;if(n&&Kt(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return ah(e),!0}function wk(e){return En(e).some(n=>Kt(n)||zu(n)>0)}function vk(e){return ar(e,()=>{const t=Er(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Kt(r)){xk(r)&&(n=!0);continue}uh(r,zu(r)+ch),n=!0}return n})}function kk(e){return ar(e,()=>{const t=En(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Kt(r)){Ck(r)&&(n=!0);continue}const o=zu(r);o<=0||(uh(r,Math.max(0,o-ch)),n=!0)}return n})}function Rl(e){return{colSpan:Math.max(1,e.colSpan||1),rowSpan:Math.max(1,e.rowSpan||1)}}function Ir(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 _t(e){const t=e.rows.length,n=Array.from({length:t},()=>[]),r=[];let o=0;for(let a=0;a<t;a+=1){const l=e.rows[a];let u=0;for(const d of Array.from(l.cells)){for(;n[a][u];)u+=1;const f=Rl(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 ol(e,t,n){var r;return((r=e.slots[t])==null?void 0:r[n])??null}function Qt(e,t){return e.unique.find(n=>n.cell===t)??null}function dh(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 mh(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 Sk(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 l=ol(e,o,a);!l||n.has(l.cell)||(n.add(l.cell),r.push(l.cell))}return r}function fh(e,t){if(t.minRow>t.maxRow||t.minCol>t.maxCol)return null;const n=ol(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 l=t.minCol;l<=t.maxCol;l+=1){const u=ol(e,a,l);if(!u||dh(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 Pk(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 l=o.minCol;l<=o.maxCol;l+=1){const u=ol(e,a,l);if(!u)return!1;if(u.cell!==t.cell&&dh(u,o))return!1}return!0}const ff=10,io=1,ao=50,Ak="1px solid #000",Tk="0.25em",Rk=new Set(["td","th"]);function ph(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=io&&t>=io&&e<=ao&&t<=ao}function wt(e,t){return Ku(e,t,n=>n instanceof HTMLTableElement)}function il(e,t){return Ku(e,t,n=>Hk(n))}function Dk(e,t){return Ku(e,t,n=>n instanceof HTMLTableRowElement)}function Ou(e){return wt(e,$u(e))}function bn(e){return il(e,$u(e))}function gh(e){return Dk(e,$u(e))}function Ik(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function wi(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return[];const r=il(e,n.startContainer),o=il(e,n.endContainer);if(!r)return[];if(!o||r===o)return[r];const a=wt(e,r);if(!a||wt(e,o)!==a)return[r];const l=_t(a),u=Qt(l,r),d=Qt(l,o);if(!u||!d)return[r];const f=mh([u,d]);if(!f)return[r];const g=Sk(l,f);return g.length>0?g:[r]}function jk(e,t){if(!ph(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(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(zk("td"));a.appendChild(d)}o.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(o),Uk(e,o);const l=o.querySelector("td, th");return l instanceof HTMLTableCellElement&&Ct(l),!0}function Uc(e,t){var h,y,b,C;const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=_t(r),a=Qt(o,n);if(!a)return!1;const l=t==="before"?a.originRow:a.originRow+a.rowSpan,u=new Set;for(const x of o.unique)if(x.originRow<l&&x.originRow+x.rowSpan>l){Ir(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(l,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(Uu(v))}if(l>=r.rows.length)(b=r.rows[r.rows.length-1].parentNode)==null||b.appendChild(d);else{const x=r.rows[l];(C=x.parentNode)==null||C.insertBefore(d,x)}const g=Kk(d,o.colCount,u,a.originCol);return Ct(g||n),!0}function pf(e,t){var f,g,h,y;const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=_t(r),a=Qt(o,n);if(!a)return!1;const l=t==="before"?a.originCol:a.originCol+a.colSpan,u=new Set;for(const b of o.unique)if(b.originCol<l&&b.originCol+b.colSpan>l){Ir(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(l,Math.max(0,o.colCount-1))])==null?void 0:g.cell)??((y=(h=o.slots[b])==null?void 0:h[Math.max(0,l-1)])==null?void 0:y.cell)??n,x=Uu(C);Vu(r,b,l,x),b===a.originRow&&(d=x)}return d&&Ct(d),!0}function Ek(e){var y,b;const t=bn(e);if(!t)return!1;const n=wt(e,t);if(!n)return!1;const r=_t(n),o=Qt(r,t);if(!o)return!1;if(r.rowCount<=1)return Vc(e,n);const a=o.originRow,l=a+1,u=[];for(const C of r.unique)C.originRow<=a&&C.originRow+C.rowSpan>a&&(C.originRow<a?Ir(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)Ir(C.cell,C.colSpan,C.rowSpan-1),Vu(n,l,C.originCol,C.cell);const d=o.originCol;n.rows[a].remove();const f=n.rows[Math.min(a,n.rows.length-1)],g=_t(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?Ct(h):f!=null&&f.cells[0]?Ct(f.cells[0]):Wk(n),!0}function Mk(e){var f,g,h;const t=bn(e);if(!t)return!1;const n=wt(e,t);if(!n)return!1;const r=_t(n),o=Qt(r,t);if(!o)return!1;if(r.colCount<=1)return Vc(e,n);const a=o.originCol,l=o.originRow;for(const y of r.unique)a<y.originCol||a>=y.originCol+y.colSpan||(y.colSpan===1?y.cell.remove():Ir(y.cell,y.colSpan-1,y.rowSpan));const u=_t(n);if(u.colCount===0||u.unique.length===0)return Vc(e,n);const d=((g=(f=u.slots[Math.min(l,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&&Ct(d),!0}function _k(e,t){const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=Ik(r),a=o.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(Ct(o[a-1]),{changed:!1});if(a<o.length-1)return Ct(o[a+1]),{changed:!1};const l=n.parentElement;if(!Uc(e,"below"))return!1;const u=l instanceof HTMLTableRowElement?l.nextElementSibling:null;return u instanceof HTMLTableRowElement&&u.cells[0]&&Ct(u.cells[0]),{changed:!0}}function Nk(e,t){return!Re(e,t)||t===e?!1:(Ct(t),!0)}function gf(e){return hh(e)!==null}function hf(e){const t=bn(e);if(!t)return!1;const n=Rl(t);return n.colSpan>1||n.rowSpan>1}function Lk(e){const t=hh(e);if(!t)return!1;const n=wt(e,t.origin.cell);return n?bh(n,t):!1}function Bk(e){const t=bn(e);if(!t)return!1;const n=wt(e,t);return n?yh(n,t):!1}function Fk(e,t,n){const r=bn(e);if(!r)return!1;const o=wt(e,r);if(!o)return!1;const a=_t(o),l=Qt(a,r);if(!l)return!1;const u=Math.min(a.colCount-l.originCol,Math.max(1,Math.floor(t))),d=Math.min(a.rowCount-l.originRow,Math.max(1,Math.floor(n)));if(u===l.colSpan&&d===l.rowSpan||!Pk(a,l,u,d))return!1;if((l.colSpan>1||l.rowSpan>1)&&yh(o,r),u===1&&d===1)return Ct(r),!0;const f=_t(o),g=fh(f,{minRow:l.originRow,maxRow:l.originRow+d-1,minCol:l.originCol,maxCol:l.originCol+u-1});return g?bh(o,g):!0}function Ku(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function Hk(e){return Rk.has(e.tagName.toLowerCase())}function $u(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n.startContainer:null}function hh(e){const t=wi(e);if(t.length<2)return null;const n=wt(e,t[0]);if(!n)return null;const r=_t(n),o=[];for(const u of t){const d=Qt(r,u);if(!d)return null;o.push(d)}const a=mh(o);if(!a)return null;const l=fh(r,a);return!l||l.cells.length<2?null:l}function bh(e,t){const n=t.origin.cell,r=_t(e),o=t.cells.map(a=>Qt(r,a)).filter(a=>a!==null).sort((a,l)=>a.originRow-l.originRow||a.originCol-l.originCol);for(const a of o)a.cell!==n&&$k(n,a.cell);Ir(n,t.colSpan,t.rowSpan);for(const a of o)a.cell!==n&&a.cell.remove();return Ct(n),!0}function yh(e,t){const n=_t(e),r=Qt(n,t);if(!r||r.colSpan===1&&r.rowSpan===1)return!1;Ir(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||Vu(e,o,a,Uu(t));return Ct(t),!0}function zk(e){const t=document.createElement(e);return t.style.border=Ak,t.style.padding=Tk,t.appendChild(document.createElement("br")),t}function Uu(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 Ok(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function Vu(e,t,n,r){const o=e.rows[t];if(!o)return;const a=_t(e);let l=0;for(const u of Array.from(o.cells)){if(u===r)continue;const d=Qt(a,u);if(!d||d.originCol>=n)break;l+=1}Ok(o,l,r)}function Kk(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 bf(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 $k(e,t){if(!(e===t||bf(t)))for(bf(e)?e.innerHTML="":e.appendChild(document.createTextNode(" "));t.firstChild;)e.appendChild(t.firstChild)}function Uk(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),Vk(n)&&n.remove())}function Vk(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||!Re(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 Ct(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Wk(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const xh=["left","center","right","justify"];function Gk(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function al(e){return Gk(e.style.textAlign)}function Wc(e,t){const n=t??"left";return al(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 yf(e){const t=e[0];return e.every(n=>n===t)?{align:t,mixed:!1}:{align:null,mixed:!0}}function Ch(e){const t=wi(e);if(t.length>0)return yf(t.map(al));const n=En(e);return n.length===0?hn(e)?{align:"left",mixed:!1}:{align:null,mixed:!1}:yf(n.map(al))}function wh(e,t){return xh.includes(t)?ar(e,()=>{const n=wi(e);if(n.length>0){let a=!1;for(const l of n)Wc(l,t)&&(a=!0);return a}const r=Er(e);if(r.length===0)return!1;let o=!1;for(const a of r)Wc(a,t)&&(o=!0);return o}):!1}function Pr(){return{...Mr(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function Ma(e){const t=JC(e),n=Ch(e),r=ih(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function vh(e,t){let n=!1;return!t.alignMixed&&t.align&&wh(e,t.align)&&(n=!0),t.listMixed||hk(e,t.list)&&(n=!0),QC(e,t)&&(n=!0),n}function qk(e,t){return vh(e,Gc(t))}function kh(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 Gc(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 _a(e){return e?Sr(e):""}function Zk(e,t){return e.src===t.src&&e.opacity===t.opacity&&e.fit===t.fit&&e.position===t.position&&_a(e.width)===_a(t.width)&&_a(e.height)===_a(t.height)}function cc(e){const t=En(e);if(t.length===0)return mn();const n=t.map(Mg),r=n[0];return n.some(o=>!Zk(o,r))?mn():r}function Yk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;let r=!1;for(const o of n)_g(o,t)&&(r=!0);return r})}function Xk(){return{size:null,unit:so,marks:Yn(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function ii(){return{font:Xk(),box:Mr(),backgroundImage:mn(),atRule:Wn()}}function qc(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 Jk(e,t){if(!t)return e;const{margin:n,padding:r,...o}=t;return{...e,...o,margin:n?qc(e.margin,n):e.margin,padding:r?qc(e.padding,r):e.padding}}function Qk(e,t){if(!t)return e;const{marks:n,...r}=t;return{...e,...r,marks:n?{...e.marks,...n}:e.marks}}function eS(e,t){const{margin:n,...r}=t.atRule??{};return{font:Qk(e.font,t.font),box:Jk(e.box,t.box),backgroundImage:t.backgroundImage?{...e.backgroundImage,...t.backgroundImage}:e.backgroundImage,atRule:t.atRule?{...e.atRule,...r,margin:n?qc(e.atRule.margin,n):e.atRule.margin}:e.atRule}}function tS(e){return e?!!(e.font||e.box||e.backgroundImage||e.atRule):!1}function xf(e,t){if(!tS(t))return e;const n=document.createElement("div");n.innerHTML=e;const r=eS(Qo(n),t);return Zc(n,r).pageHtml}function nS(e){const t=e.style.fontSize,n=t?gu(t):null,r=n&&xl(n.unit)?{value:n.value,unit:n.unit}:null,o=`${e.style.textDecorationLine} ${e.style.textDecoration}`.toLowerCase(),a=e.style.fontWeight.trim().toLowerCase(),l={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)??so,marks:l,fontFamily:d||null,fontFamilyMixed:!1,fontColor:u?Ue(u):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function rS(e,t){const n=e.style.fontSize,r=t.size===null?null:Ar(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const o=pu(r.value,r.unit);return n===o?!1:(e.style.fontSize=o,!0)}function oS(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 yi(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function iS(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 aS(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 l=a.join(" ");return(e.style.textDecorationLine||e.style.textDecoration).trim()!==l&&(l?e.style.textDecoration=l:(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),n=!0),n}function lS(e,t){let n=!1;return rS(e,t)&&(n=!0),oS(e,t)&&(n=!0),iS(e,t)&&(n=!0),aS(e,t.marks)&&(n=!0),n&&xt(e),n}function sS(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function Qo(e){const t=ut(e);if(!t)return ii();const n=yo(t);return{font:nS(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,breakInside:n.breakInside,breakInsideMixed:!1,breakAfter:n.breakAfter,breakAfterMixed:!1,breakBefore:n.breakBefore,breakBeforeMixed:!1},backgroundImage:z1(t),atRule:ot(e.innerHTML)}}function Zc(e,t){const n=hn(e),r=n?co(e,n.startContainer,n.startOffset):null,o=n?co(e,n.endContainer,n.endOffset):null,a=ut(e),l=ju(e);ri(l);const u=lS(l,t.font),d=xo(l,sS(t)),f=O1(l,t.backgroundImage);Sl(e);const g=ot(e.innerHTML),h=qa(e.innerHTML,t.atRule),y=Xt(h);y!==Xt(e.innerHTML)&&(e.innerHTML=y),wo(e,h);const b=JSON.stringify(g)!==JSON.stringify(t.atRule);r!==null&&o!==null&&wu(e,Math.min(r,o),Math.max(r,o)),Pl(e);const C=qa(e.innerHTML,t.atRule);return{changed:!a||u||d||f||b,pageHtml:C}}function cS(e,t){const n=t??e.innerHTML,r=og(n);return fi(n)?(e.innerHTML=Xt(r),Sl(e),wo(e,r),{changed:!0,pageHtml:r}):{changed:!1,pageHtml:r}}const uS=/<script\b[^>]*>[\s\S]*?<\/script>/gi,dS=/^\s*javascript\s*:/i;function mS(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 Sh(e){const t=mS(e).replace(/[\u0000-\u001F\u007F\s]+/g,"");return dS.test(t)}function fS(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!Sh(r)&&!/url\s*\(\s*["']?\s*javascript:/i.test(r)}).join("; ")}function pS(e){const t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(const n of t)for(const r of[...n.attributes]){if(Sh(r.value)){n.removeAttribute(r.name);continue}if(r.name.toLowerCase()==="style"){const o=fS(r.value);o?o!==r.value&&n.setAttribute(r.name,o):n.removeAttribute(r.name)}}}function gS(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function hS(e){return e.body.innerHTML}function Yc(e){if(!e.trim())return e;const n=e.replace(uS,"");if(!/javascript\s*:/i.test(n))return n;const r=gS(n);return pS(r.body),hS(r)}function to(e){if(!e.trim())return e;const n=qn(e);return n.length===1?Yc(e):Et(n.map(Yc))}const Wu="data-hover-html",bS="noopener noreferrer",yS="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)",xS="this._hoverBox&&this._hoverBox.remove()",CS=/^(#(?:[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 Dl(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function wS(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function gi(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&wS(n))return n;n=n.parentNode}return null}function Ph(e){return CS.test(e)}function vS(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&&Ph(r)?r:null}function Ah(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function kS(e){const t=e.getAttribute(Wu)??"",n=vS(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:Ah(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function Th(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return null;const r=gi(e,n.commonAncestorContainer);return r?kS(r):null}function SS(e){return Th(e)!==null}function PS(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Wu)}function AS(e,t){var r;if(PS(e),t.hoverMode==="html"){const o=t.hoverHtml.trim();if(!o)return;e.setAttribute(Wu,o),e.setAttribute("onmouseover",yS),e.setAttribute("onmouseout",xS);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!Ph(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function Gu(e,t){const n=Dl(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",bS)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":Ah(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),AS(e,n)}function TS(e,t){const n=new Set;for(const r of t){const o=gi(e,r);o&&!n.has(o)&&n.add(o)}for(const r of n)Mt(r)}function RS(e,t,n){fn(t);const r=vt(t).filter(u=>u.data.length>0);TS(e,r),r.length>0&&jr(r);const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);fn(a);const l=document.createElement("a");Gu(l,n);try{return a.surroundContents(l),!0}catch{const u=a.extractContents();return u.hasChildNodes()?(l.appendChild(u),a.insertNode(l),!0):!1}}function DS(e,t){const n=document.createElement("a");Gu(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 IS(e,t){const n=t.href.trim();if(!n)return!1;const r=Dl({...t,href:n}),o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!Re(e,a.commonAncestorContainer))return!1;const l=gi(e,a.startContainer),u=gi(e,a.endContainer);return l&&l===u?(Gu(l,r),!0):a.collapsed?DS(a,r):RS(e,a,r)}const jS=/^[A-Za-z][A-Za-z0-9_-]*$/,Rh="​";function Xc(e){var r;const t=Eu(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 ES(e){return new Set(Xc(e).map(t=>t.id))}function Dh(e,t){const n=e.trim();return n?jS.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function Cf(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 MS(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 _S(e,t){const n=t.trim();if(Dh(n,ES(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;const a=gi(e,o.startContainer);if(a)return MS(a,n),!0;if(o.collapsed)return Cf(o,n),!0;fn(o);const l=document.createElement("span");l.id=n;try{return o.surroundContents(l),!0}catch{return Cf(o,n),!0}}const ct="data-comment-thread",wf="wysiwyg-comment-anchor";function NS(){return`cmt_${crypto.randomUUID()}`}function LS(){return crypto.randomUUID()}const ll=20;function vf(e,t){if(!e)return null;const n=e instanceof Element?e:e.parentElement;if(!n)return null;const r=n.closest(`[${ct}]`);return r instanceof HTMLElement&&Re(t,r)?r:null}function kf(e,t,n){var y;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=Math.max(0,t),a=Math.max(t,n),l=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(!l&&o<=C&&(l=b,u=o),!d&&a<=C){d=b,f=a;break}o-=C,a-=C}if(!l||!d)return null;const h=document.createRange();return h.setStart(l,u),h.setEnd(d,f),h}function BS(e,t,n){const r=e.textContent??"",o=r.slice(Math.max(0,t-ll),t),a=r.slice(n,n+ll);return{prefix:o,suffix:a}}function FS(e,t){if(t.mode!=="visual")return null;const n=Zn(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}=BS(e,t.start,t.end);return{type:"text",text:t.text,start:t.start,end:t.end,prefix:r,suffix:o}}function Sf(e,t){if(t.mode!=="visual")return null;const n=Zn(e);if(n!=null&&n.hasAttribute(ct))return n.getAttribute(ct)??null;if(t.visualRange){const r=vf(t.visualRange.startContainer,e);if(r)return r.getAttribute(ct)??null;const o=vf(t.visualRange.endContainer,e);if(o)return o.getAttribute(ct)??null}return null}function Jc(e,t,n){if(!Re(e,n.commonAncestorContainer))return!1;fn(n);const r=document.createElement("span");r.setAttribute(ct,t);try{return n.surroundContents(r),!0}catch{const o=n.toString();if(!o)return!1;const a=document.createElement("span");return a.setAttribute(ct,t),a.textContent=o,n.deleteContents(),n.insertNode(a),!0}}function Ih(e,t){e.setAttribute(ct,t)}function HS(e,t,n){const r=Zn(e);return r?(Ih(r,t),!0):n.visualRange?Jc(e,t,n.visualRange):!1}function zS(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 OS(e,t,n){if(n.type!=="text")return!1;if(n.start!==void 0&&n.end!==void 0){const l=kf(e,n.start,n.end);if(l&&l.toString()===n.text)return Jc(e,t,l)}const r=e.textContent??"",o=n.text;if(!o)return!1;let a=0;for(;a<=r.length;){const l=r.indexOf(o,a);if(l===-1)return!1;const u=l+o.length,d=r.slice(Math.max(0,l-ll),l),f=r.slice(u,u+ll);if(n.prefix!==void 0&&d!==n.prefix){a=l+1;continue}if(n.suffix!==void 0&&f!==n.suffix){a=l+1;continue}const g=kf(e,l,u);return g?Jc(e,t,g):!1}return!1}function KS(e,t){for(const n of t)if(!e.querySelector(`[${ct}="${n.id}"]`)){if(n.anchor.type==="image"){const o=zS(e,n.anchor);o&&Ih(o,n.id);continue}OS(e,n.id,n.anchor)}}function jh(e,t){for(const n of e.querySelectorAll(`[${ct}]`))n instanceof HTMLElement&&(t?n.classList.add(wf):n.classList.remove(wf))}function Eh(e,t){if(!t)return null;const n=t instanceof Element?t:t.parentElement;if(!n)return null;const r=n.closest(`[${ct}]`);return r instanceof HTMLElement&&Re(e,r)?r:null}function Pf(e,t){const n=e.querySelector(`[${ct}="${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 l=document.createTreeWalker(n,NodeFilter.SHOW_TEXT).nextNode();l instanceof Text?(o.setStart(l,0),o.collapse(!0)):(o.selectNodeContents(n),o.collapse(!0))}return r.removeAllRanges(),r.addRange(o),!0}function $S(e,t=[]){return{id:NS(),anchor:e,messages:t,createdAt:new Date().toISOString(),resolvedAt:null,resolvedBy:null}}function US(e,t){return{id:LS(),userId:e.userId,userName:e.userName,message:t.trim(),createdAt:new Date().toISOString()}}function VS(e,t,n){return e.map(r=>r.id===t?{...r,messages:[...r.messages,n]}:r)}function WS(e,t){return e.find(n=>n.id===t)}function Mh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function GS(e){const t=Mh(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 _h(e){const t=Mh(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 qS(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 Nh(e){const t=GS(e);return t?qS(t):!1}async function ZS(e){return await Nh(e)?_h(e):!1}const YS=new Set(["strong","b","em","i","u","s","strike","del"]),XS=["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 JS(e){for(const t of XS)e.style.removeProperty(t)}function QS(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)){n=r;continue}if(or(r,n),YS.has(r.tagName.toLowerCase())){Mt(r);continue}if(JS(r),rr(r)){Mt(r);continue}n=r.isConnected?r:t}}function e0(e){const t=hn(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;fn(t);const r=vt(t).filter(o=>o.data.length>0);if(r.length===0)return!1;for(const o of r)QS(e,o);return jr(r),e.innerHTML!==n}function t0(e,t){return e.start===t.start&&e.end===t.end&&e.collapsed===t.collapsed}function n0(e){const t=oo(e),n=Wg(e),r=Sp(e),o=Ua(e,"color"),a=Ua(e,"backgroundColor"),l=qg(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:l.mixed?null:l.value,customCssMixed:l.mixed}}function r0(e,t){t.size!==null&&Fc(e,t.size,t.unit);const n=oo(e);for(const r of $t)t.marks[r]!==n[r]&&Oc(e,r);return t.fontFamilyMixed||kc(e,t.fontFamily),t.fontColorMixed||ni(e,"color",t.fontColor),t.highlightColorMixed||ni(e,"backgroundColor",t.highlightColor),!t.customCssMixed&&t.customCss&&Yg(e,t.customCss),!0}function za(){return typeof window<"u"&&"speechSynthesis"in window}function o0(e){const t=document.createElement("div");return t.innerHTML=e,(t.innerText??t.textContent??"").trim()}function Af(e,t){const n=e.text.trim();return n||o0(t)||null}function i0(e){const t=window.speechSynthesis,n=()=>{e()};return{toggle(r){if(!za())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 za()&&t.speaking},cancel(){za()&&t.speaking&&(t.cancel(),n())}}}const a0=5*1024*1024,l0="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",s0=new Set(["audio/mpeg","audio/mp3","audio/wav","audio/x-wav","audio/ogg","audio/aac","audio/webm","audio/mp4","audio/x-m4a"]),c0=new Set(["mp3","wav","ogg","aac","webm","m4a"]),u0=/^data:audio\/(?:mpeg|mp3|wav|x-wav|ogg|aac|webm|mp4|x-m4a)(?:;charset=[^;,]+)?;base64,/i,d0=/^(javascript|vbscript|file|blob):/i;function m0(e={}){return{src:"",title:"",...e}}function qu(e){const t=e.trim();if(!t)return"empty";if(d0.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return u0.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 f0(e){return e.size>a0?"tooLarge":y0(e)?null:"type"}function p0(e){const t=f0(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const o=new FileReader;o.onload=()=>{const a=String(o.result??"");if(qu(a)){r(new Error("invalid"));return}n(a)},o.onerror=()=>r(o.error??new Error("Failed to read file")),o.readAsDataURL(e)})}function g0(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%",h0(e,t.css)}function h0(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(),l=r.slice(o+1).trim();a&&l&&e.style.setProperty(a,l)}}function b0(e,t){const n=m0(t);if(qu(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=document.createElement("audio");return g0(a,n),o.insertNode(a),o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}function y0(e){const t=e.type.trim().toLowerCase();if(t&&s0.has(t))return!0;const n=x0(e.name);return!!(!t&&n&&c0.has(n))}function x0(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function Tf(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(jt);return o.body.innerHTML}function Lh(e,t,n){return Tf(e,n)===Tf(t,n)}const C0=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i;function Rf(e,t){var o,a;const n=(o=e.getAttribute(jt))==null?void 0:o.trim();if(n&&t){const l=t(n);if(l)return`embedded:${l}`}const r=((a=e.getAttribute("src"))==null?void 0:a.trim())??"";return C0.test(r)?`embedded:${r}`:r.startsWith("blob:")&&n?`registry:${n}`:r?`url:${r}`:"empty"}function Bh(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html").body}const Df=/<tr(\s[^>]*)?>([\s\S]*?)<\/tr>/gi;function w0(e){const t=[];let n;for(Df.lastIndex=0;(n=Df.exec(e))!==null;)t.push(n[2]??"");return t}function v0(e,t){const n=document.createRange();n.selectNodeContents(e);const r=n.createContextualFragment(t);e.replaceChildren(...r.childNodes)}function k0(e,t){const n=w0(t);if(n.length===0)return;let r=0;e.querySelectorAll("tr").forEach(o=>{r>=n.length||(v0(o,n[r]),r+=1)})}function S0(e){const t=[e,...e.querySelectorAll("table, tbody, thead, tfoot")];for(const n of t)for(const r of[...n.childNodes])r instanceof Element&&Ru(r)&&r.remove()}function P0(e,t){const n=Bh(t);e.replaceChildren(...n.childNodes),/<tr[\s>]/i.test(t)&&(S0(e),k0(e,t))}function A0(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 T0(e,t){e.querySelectorAll("img").forEach((n,r)=>{const o=document.createElement("span");o.setAttribute(t,String(r)),n.replaceWith(o)})}function If(e,t){const n=e.cloneNode(!0);return T0(n,t),n.innerHTML}function R0(e,t,n){const r=Bh(t),o=[...e.querySelectorAll("img")],a=[...r.querySelectorAll("img")];if(o.length===0||o.length!==a.length)return!1;const l=o.map(h=>Rf(h,n)),u=a.map(h=>Rf(h,n));if(!l.every((h,y)=>h===u[y]))return!1;const d="data-wysiwyg-img-marker",f=If(e,d),g=If(r,d);if(f!==g)return!1;for(let h=0;h<o.length;h+=1)A0(o[h],a[h]);return!0}function sl(e,t,n={}){const{resolveDataUrl:r,hydrateEmbeddedImages:o}=n;return dg(t)?e.innerHTML===t?{changed:!1}:(P0(e,t),{changed:!0}):Lh(e.innerHTML,t,o)?{changed:!1}:e.innerHTML===t?{changed:!1}:R0(e,t,r)?{changed:!0}:(e.innerHTML=t,{changed:!0})}const Fh=/^(javascript|vbscript|file|blob):/i,D0=[/(?: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 I0(e={}){return{url:"",title:"",...e}}function j0(e={}){return{src:"",title:"",...e}}function Il(e){const t=e.trim();if(!t)return null;for(const n of D0){const r=t.match(n);if(r!=null&&r[1])return r[1]}return null}function Hh(e){return`https://www.youtube.com/embed/${e}`}function zh(e){const t=e.trim();return t?Fh.test(t)?"invalid":Il(t)?null:"invalid":"empty"}function E0(e){const t=e.trim();if(!t)return"empty";if(Fh.test(t))return"invalid";if(Il(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 Oh(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(),l=r.slice(o+1).trim();a&&l&&e.style.setProperty(a,l)}}function Kh(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",Oh(e,n.css)}function M0(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%",Oh(e,t.css)}function _0(e,t){const n=I0(t);if(zh(n.url))return!1;const r=Il(n.url);if(!r)return!1;const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!Re(e,a.commonAncestorContainer))return!1;a.collapsed||a.deleteContents();const l=document.createElement("iframe");return Kh(l,Hh(r),n),a.insertNode(l),a.setStartAfter(l),a.collapse(!0),o.removeAllRanges(),o.addRange(a),!0}function N0(e,t){const n=j0(t);if(E0(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=Il(n.src);if(a){const l=document.createElement("iframe");Kh(l,Hh(a),{title:n.title,css:n.css}),o.insertNode(l),o.setStartAfter(l)}else{const l=document.createElement("video");M0(l,n),o.insertNode(l),o.setStartAfter(l)}return o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}const L0=new Set(["p","h1","h2","h3","h4","h5","h6"]),B0=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function $h(e,t){var a;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer))return!1;r.collapsed||r.deleteContents();const o=F0(e,r.startContainer);if(o){const l=H0(o,r);return(a=o.parentNode)==null||a.insertBefore(t,l),Ef(t),!0}return r.insertNode(t),z0(e,t),$0(t),Ef(t),!0}function F0(e,t){let n=xi(t);for(;n&&n!==e;){const r=Le(n);if(L0.has(r)&&n instanceof HTMLElement)return n;if(B0.has(r))return null;n=n.parentElement}return null}function H0(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),jf(e),jf(o),(a=e.parentNode)==null||a.insertBefore(o,e.nextSibling),o}function z0(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!O0(n))return;or(n,t),Mt(n)}}function O0(e){const t=Le(e);return gn(e)||t==="a"}function jf(e){K0(e)&&e.appendChild(document.createElement("br"))}function K0(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 $0(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 Ef(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 U0="1em 0",V0="1px solid #d0d0d0";function W0(){const e=document.createElement("hr");return e.style.margin=U0,e.style.border="0",e.style.borderTop=V0,e}function G0(e){return $h(e,W0())}const q0="1.5em 0",Z0="2px dashed #bbb",Y0="data-wysiwyg-page-break";function X0(){const e=document.createElement("div");return e.setAttribute(Y0,""),e.style.display="block",e.style.clear="both",e.style.breakAfter="page",e.style.pageBreakAfter="always",e.style.margin=q0,e.style.border="0",e.style.borderTop=Z0,e.style.height="0",e}function J0(e){return $h(e,X0())}const jn=16;function Mf(e){return Math.min(po.px.max,Math.max(jn,e))}function Q0(e){return e.width>0&&e.height>0?e.width/e.height:1}function eP(e,t){const n=Math.max(jn,jn*t),r=Math.min(po.px.max,po.px.max*t),o=Math.min(r,Math.max(n,e));return{width:o,height:o/t}}function tP(e,t){const n=Math.max(jn,jn/t),r=Math.min(po.px.max,po.px.max/t),o=Math.min(r,Math.max(n,e));return{width:o*t,height:o}}function nP(e,t,n){const r=Q0(t);return e==="e"?eP(t.width+n.x,r):e==="s"?tP(t.height+n.y,r):{width:Mf(t.width+n.x),height:Mf(t.height+n.y)}}function rP(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:jn,height:r>0?r:jn}}function oP(e,t,n){const r=go(Math.max(jn,t),"px"),o=go(Math.max(jn,n),"px");return!r||!o?!1:Ag(e,{...Pg(e),sizeMode:"lock",width:r,height:o})}function iP(e={}){return{border:{...Su},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function aP(e){const t=yo(e);return{border:t.border,borderCollapse:uP(e),borderSpacing:Uh(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:pt(e.style.width)}}function lP(e,t){let n=xo(e,{...Mr(),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 dP(e,t.borderCollapse)&&(n=!0),mP(e,t.borderCollapse,t.borderSpacing)&&(n=!0),fP(e,t.width)&&(n=!0),n&&xt(e),n}function sP(e){const t=Ou(e);return t?aP(t):null}function cP(e,t){const n=Ou(e);return n?lP(n,t):!1}function uP(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function dP(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function Uh(e){const t=e.style.borderSpacing.trim();return t?pt(t.split(/\s+/)[0]??""):null}function mP(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?ir(n):null,o=Uh(e);return Ot(o,r)?!1:(r?e.style.borderSpacing=_e(r):e.style.removeProperty("border-spacing"),!0)}function fP(e,t){const n=t?ir(t):null,r=pt(e.style.width);return Ot(r,n)?!1:(n?e.style.width=_e(n):e.style.removeProperty("width"),!0)}const jl=["top","middle","bottom","baseline"],pP=new Set(jl);function gP(e={}){return{backgroundColor:null,color:null,padding:{...Jt},textAlign:null,verticalAlign:null,width:null,colSpan:1,rowSpan:1,...e}}function hP(e){const t=yo(e);return{backgroundColor:t.backgroundColor,color:Vh(e),padding:t.padding,textAlign:wP(e),verticalAlign:Wh(e),width:pt(e.style.width),...Rl(e)}}function bP(e,t){let n=xo(e,{...Mr(),margin:{...Jt},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 CP(e,t.color)&&(n=!0),Wc(e,t.textAlign)&&(n=!0),vP(e,t.verticalAlign)&&(n=!0),kP(e,t.width)&&(n=!0),n&&xt(e),n}function yP(e){const t=bn(e);return t?hP(t):null}function xP(e,t){const n=wi(e);if(n.length===0)return!1;let r=!1;for(const a of n)bP(a,t)&&(r=!0);const o=bn(e);if(o){const a=Rl(o);(a.colSpan!==t.colSpan||a.rowSpan!==t.rowSpan)&&Fk(e,t.colSpan,t.rowSpan)&&(r=!0)}return r}function Vh(e){const t=e.style.color;return t?Ue(t):null}function CP(e,t){const n=t?Ue(t):null;return Vh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function wP(e){const t=al(e);return t==="left"?null:t}function Wh(e){const t=e.style.verticalAlign.trim().toLowerCase();return pP.has(t)?t:null}function vP(e,t){return Wh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function kP(e,t){const n=t?ir(t):null,r=pt(e.style.width);return Ot(r,n)?!1:(n?e.style.width=_e(n):e.style.removeProperty("width"),!0)}const SP=new Set(jl);function PP(e={}){return{backgroundColor:null,color:null,padding:{...Jt},height:null,verticalAlign:null,...e}}function AP(e){const t=e.cells[0],n=t?yo(t).padding:{...Jt};return{backgroundColor:Gh(e),color:qh(e),padding:n,height:pt(e.style.height),verticalAlign:Zh(e)}}function TP(e,t){let n=!1;IP(e,t.backgroundColor)&&(n=!0),jP(e,t.color)&&(n=!0),MP(e,t.height)&&(n=!0),EP(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))xo(r,{...Mr(),margin:{...Jt},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&&xt(e),n}function RP(e){const t=gh(e);return t?AP(t):null}function DP(e,t){const n=gh(e);return n?TP(n,t):!1}function Gh(e){const t=e.style.backgroundColor;return t?Ue(t):null}function IP(e,t){const n=t?Ue(t):null;return Gh(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function qh(e){const t=e.style.color;return t?Ue(t):null}function jP(e,t){const n=t?Ue(t):null;return qh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Zh(e){const t=e.style.verticalAlign.trim().toLowerCase();return SP.has(t)?t:null}function EP(e,t){return Zh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function MP(e,t){const n=t?ir(t):null,r=pt(e.style.height);return Ot(r,n)?!1:(n?e.style.height=_e(n):e.style.removeProperty("height"),!0)}const _P=1e3;function NP(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function LP({onAutoSave:e,getHtml:t}){const n=s.useRef(e);n.current=e;const r=s.useRef(t);r.current=t;const o=s.useRef(null),a=e!=null;s.useEffect(()=>{if(!a){o.current=null;return}o.current=r.current();const l=window.setInterval(()=>{const u=n.current;if(!u)return;const d=r.current();d!==o.current&&(o.current=d,queueMicrotask(()=>NP(u,d)))},_P);return()=>{window.clearInterval(l)}},[a])}function BP(){const[e,t]=s.useState({open:!1,tab:"general"}),[n,r]=s.useState(!1),[o,a]=s.useState({open:!1,html:""}),[l,u]=s.useState(null),[d,f]=s.useState(!1),[g,h]=s.useState(!1),[y,b]=s.useState({open:!1,tab:"general",value:Pr(),backgroundImage:mn()}),[C,x]=s.useState({open:!1,value:""}),[v,k]=s.useState({open:!1,tab:"font",paragraphTab:"spacing",value:ii()}),[S,A]=s.useState(!1),[R,T]=s.useState({open:!1}),[D,P]=s.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[j,L]=s.useState({open:!1,existingIds:[]}),[V,E]=s.useState({open:!1}),[N,K]=s.useState({open:!1}),[G,q]=s.useState({open:!1}),[ae,Z]=s.useState({open:!1,tab:"general",value:Sg(),aspectRatio:1}),[ee,le]=s.useState({open:!1}),[me,ne]=s.useState({open:!1,value:iP()}),[M,re]=s.useState({open:!1,value:gP()}),[O,ie]=s.useState({open:!1,value:PP()}),[Ee,He]=s.useState({open:!1,topicId:"getStarted"}),[$e,Ve]=s.useState(!1);return{fontDialog:e,setFontDialog:t,customizeToolbarOpen:n,setCustomizeToolbarOpen:r,documentPreview:o,setDocumentPreview:a,toolbarSettings:l,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:A,customStyleDialog:R,setCustomStyleDialog:T,linkDialog:D,setLinkDialog:P,bookmarkDialog:j,setBookmarkDialog:L,imageDialog:V,setImageDialog:E,audioDialog:N,setAudioDialog:K,youtubeDialog:G,setYoutubeDialog:q,imageProperties:ae,setImageProperties:Z,tableDialog:ee,setTableDialog:le,tableProperties:me,setTableProperties:ne,cellProperties:M,setCellProperties:re,rowProperties:O,setRowProperties:ie,helpDialog:Ee,setHelpDialog:He,aboutDialogOpen:$e,setAboutDialogOpen:Ve}}const _f={changed:!1,pages:[],joined:"",changedIndices:[]};function Nf(e){return{changed:e.changed,pages:e.pages,joined:Et(e.pages),changedIndices:e.changedIndices}}function Lf(e,t,n){return n.size===0?t:t.map((r,o)=>n.has(o)&&e[o]!==void 0&&e[o]!==r?e[o]:r)}function FP({enabled:e,pagesProp:t,defaultPages:n}){const r=e&&t!==void 0,o=s.useMemo(()=>t!==void 0?Gn(t):void 0,[t]),[a,l]=s.useState(()=>({pages:Gn(n),revision:0})),u=s.useRef(o??Gn(n)),d=s.useRef(new Set),f=s.useRef(t);s.useEffect(()=>{if(!e||!r||o===void 0||f.current===t&&kr(u.current,o))return;f.current=t;const k=Lf(u.current,o,d.current),S=oc(u.current,k);if(u.current=S.pages,!!S.changed){for(const A of S.changedIndices)d.current.add(A);l(A=>({pages:S.pages,revision:A.revision+1}))}},[e,r,o,t]);const g=s.useMemo(()=>{if(!e)return[];if(r&&o!==void 0){const k=Lf(u.current,o,d.current),S=oc(u.current,k);return u.current=S.pages,S.pages}return a.pages},[e,r,o,a.pages,a.revision]),h=s.useCallback((k,S)=>{if(!e)return _f;const A=r?u.current:a.pages,R=oc(A,k);if(!R.changed)return Nf(R);for(const T of R.changedIndices)d.current.add(T);return S!==void 0&&d.current.add(S),r?u.current=R.pages:l(T=>({pages:R.pages,revision:T.revision+1})),Nf(R)},[e,a.pages,r]),y=s.useCallback((k,S)=>h(k,S==null?void 0:S.editedIndex),[h]),b=s.useCallback((k,S,A)=>{if(!e)return _f;const R=r?u.current:a.pages,T=Ec(R,k,S);return T.changed?h(T.pages,(A==null?void 0:A.editedIndex)??k):{changed:!1,pages:R,joined:Et(R),changedIndices:[]}},[h,e,a.pages,r]),C=s.useCallback(k=>h(Gn(k)),[h]),x=s.useCallback(k=>{if(k===void 0){d.current.clear();return}for(const S of k)d.current.delete(S)},[]),v=s.useCallback(()=>Et(g),[g]);return s.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 Oa({value:e,defaultValue:t,onChange:n}){const[r,o]=s.useState(t),a=e!==void 0,l=a?e:r,u=s.useCallback(d=>{a||o(d),n==null||n(d)},[a,n]);return[l,u]}const Yh="commspliant-html-editor.darkMode";function HP(e){return typeof e=="boolean"?e:null}function Bf(){try{const e=localStorage.getItem(Yh);return e?HP(JSON.parse(e)):null}catch{return null}}function zP(e){try{localStorage.setItem(Yh,JSON.stringify(e))}catch{}}const Xh="commspliant-html-editor.pageZoom",OP=new Set(["fitWidth","fitPage"]);function KP(e){return typeof e=="string"&&OP.has(e)||typeof e=="number"&&yv.includes(e)?e:null}function $P(){try{const e=localStorage.getItem(Xh);return e?KP(JSON.parse(e)):null}catch{return null}}function UP(e){try{localStorage.setItem(Xh,JSON.stringify(e))}catch{}}const Jh="commspliant-html-editor.toolbarPosition",VP=["top","left","right","bottom"];function Qh(e){return typeof e=="string"&&VP.includes(e)?e:null}function Ff(){try{const e=localStorage.getItem(Jh);return e?Qh(JSON.parse(e)):null}catch{return null}}function WP(e){try{localStorage.setItem(Jh,JSON.stringify(e))}catch{}}function GP({enabled:e,onHtml:t}){const[n,r]=s.useState(!1),o=s.useRef(0),a=s.useRef(e),l=s.useRef(t);a.current=e,l.current=t;const u=s.useCallback(()=>{o.current=0,r(!1)},[]);s.useEffect(()=>{e||u()},[e,u]);const d=s.useCallback(y=>{!a.current||!Ea(y.dataTransfer)||(y.preventDefault(),o.current+=1,r(!0))},[]),f=s.useCallback(y=>{!a.current||!Ea(y.dataTransfer)||(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="copy"))},[]),g=s.useCallback(y=>{if(!a.current||!Ea(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=s.useCallback(y=>{if(!a.current||!Ea(y.dataTransfer))return;y.preventDefault(),u();const b=X1(y.dataTransfer);b&&Fu(b).then(C=>{a.current&&l.current(C)},()=>{})},[u]);return{dragging:n,onDragEnter:d,onDragOver:f,onDragLeave:g,onDrop:h}}const qP={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:nx,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:Yy,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:ti,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},deletePage:{id:"deletePage",command:"deletePage",icon:ti,labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:"canDeletePage"}}},eb=400,cl=100,tb=2e7;function ZP(e){let t=[],n=0,r=e,o=[],a=0,l=!1,u=!1,d=0;function f(){if(t.length>cl){const v=t.splice(0,t.length-cl);for(const k of v)n-=k.length}for(;t.length>1&&n+a>tb;){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(l){r=v,l=!1;return}if(v===r)return;const S=Date.now(),A=(k==null?void 0:k.coalesce)===!0;if(A&&u&&S-d<eb){r=v,d=S,o.length>0&&h();return}g(r),r=v,h(),d=S,u=A}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(l){r=v,l=!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:()=>{l=!0},finishApplying:()=>{l=!1}}}function Xe(e){return e.map(t=>t)}function xr(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 YP(e){let t=[],n=0,r=Xe(e),o=[],a=0,l=!1,u=!1,d=null,f=0;function g(){if(t.length>cl){const D=t.splice(0,t.length-cl);for(const P of D)n-=xr(P)}for(;t.length>1&&n+a>tb;){const D=t.shift();D&&(n-=xr(D))}}function h(D){t.push(D),n+=xr(D),g()}function y(D){o.push(D),a+=xr(D)}function b(){for(const D of o)a-=xr(D);o=[],a=0}function C(){u=!1,d=null}function x(D,P,j){if(l){const K=Xe(r);K[D]=P,r=K,l=!1;return}if(r[D]===P)return;const L=Date.now(),V=(j==null?void 0:j.coalesce)===!0,E=V&&u&&d===D&&L-f<eb,N=Xe(r);if(N[D]=P,E){r=N,f=L;return}h({type:"pageEdit",pageIndex:D,before:r[D]??""}),r=N,b(),f=L,u=V,d=D}function v(D,P){if(l){r=Xe(P),l=!1;return}kr(r,P)||(h({type:"insertPage",index:D,page:P[D]??""}),r=Xe(P),b(),C())}function k(D,P,j){if(l){r=Xe(j),l=!1;return}kr(r,j)||(h({type:"deletePage",index:D,page:P}),r=Xe(j),b(),C())}function S(D){if(l){r=Xe(D),l=!1;return}kr(r,D)||(h({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D),b(),C())}function A(D){if(l){r=Xe(D),l=!1;return}kr(r,D)||(r=Xe(D))}function R(){if(t.length===0)return null;C();const D=t.pop();switch(n-=xr(D),D.type){case"pageEdit":{const P=r[D.pageIndex]??"";y({type:"pageEdit",pageIndex:D.pageIndex,before:P}),r[D.pageIndex]=D.before;break}case"insertPage":{const P=r[D.index]??"";y({type:"insertPage",index:D.index,page:P}),r.splice(D.index,1);break}case"deletePage":{y({type:"deletePage",index:D.index,page:D.page}),r.splice(D.index,0,D.page);break}case"replaceAll":{y({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D.beforePages);break}}return g(),Xe(r)}function T(){if(o.length===0)return null;C();const D=o.pop();switch(a-=xr(D),D.type){case"pageEdit":{const P=r[D.pageIndex]??"";h({type:"pageEdit",pageIndex:D.pageIndex,before:P}),r[D.pageIndex]=D.before;break}case"insertPage":{h({type:"insertPage",index:D.index,page:D.page}),r.splice(D.index,0,D.page);break}case"deletePage":{const P=r[D.index]??"";h({type:"deletePage",index:D.index,page:P}),r.splice(D.index,1);break}case"replaceAll":{h({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D.beforePages);break}}return Xe(r)}return{getPresent:()=>r,recordPageEdit:x,recordInsertPage:v,recordDeletePage:k,recordReplaceAll:S,undo:R,redo:T,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncPages:D=>S(D),applyPresent:A,markApplying:()=>{l=!0}}}function Ht(e){return typeof e=="object"&&e!==null&&"recordPageEdit"in e&&typeof e.recordPageEdit=="function"}const XP='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',JP='[role="listbox"], [data-color-picker]';function Ye(e,{open:t,onClose:n,focusableSelector:r=XP,escapeIgnoreSelectors:o=JP}){s.useEffect(()=>{if(!t)return;const a=e.current,l=a==null?void 0:a.querySelector(r);l==null||l.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 tr(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function ul(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):tr(e,t):""}const dn="fullscreen",Qc="commspliant-html-editor.toolbarCustomization";function eu(e){const t=e.filter(n=>n!==dn);return e.includes(dn)?[...t,dn]:t}function Zu(e,t){if(!t||t.length===0)return eu(e);const n=new Set(e),r=t.filter(l=>n.has(l)),o=new Set(r),a=[...r];for(let l=0;l<e.length;l++){const u=e[l];if(o.has(u))continue;let d=0;for(let f=l-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 eu(a)}function QP(e,t){const n=new Map(e.map(l=>[l.id,l])),r=Zu(e.map(l=>l.id),t==null?void 0:t.groupOrder),o=new Set((t==null?void 0:t.hiddenItemIds)??[]),a=[];for(const l of r){const u=n.get(l);if(!u)continue;const d=u.items.filter(f=>!o.has(f));d.length!==0&&a.push({id:l,items:d})}return a}function eA(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 tA(){try{const e=localStorage.getItem(Qc);return e?eA(JSON.parse(e)):null}catch{return null}}function nA(e){try{if(!e){localStorage.removeItem(Qc);return}localStorage.setItem(Qc,JSON.stringify(e))}catch{}}function Yu(e,t){return Zu(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function rA(e,t,n,r){const o=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?o.delete(n):o.add(n),{groupOrder:Yu(e,t),hiddenItemIds:[...o]}}function nb(e,t,n,r){const o=Yu(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===dn||r===dn)return{groupOrder:o,hiddenItemIds:a};const l=o.indexOf(n),u=o.indexOf(r);if(l<0||u<0||l===u)return{groupOrder:o,hiddenItemIds:a};const d=[...o],[f]=d.splice(l,1);return d.splice(u,0,f),{groupOrder:eu(d),hiddenItemIds:a}}function Hf(e,t,n,r){const o=Yu(e,t),a=o.filter(d=>d!==dn),l=a.indexOf(n),u=l+r;return l<0||u<0||u>=a.length?{groupOrder:o,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:nb(e,t,n,a[u])}const oA="_backdrop_11w4e_1",iA="_dialog_11w4e_12",aA="_header_11w4e_31",lA="_body_11w4e_39",sA="_group_11w4e_49",cA="_groupDragging_11w4e_55",uA="_groupDropTarget_11w4e_59",dA="_groupHeader_11w4e_64",mA="_groupTitle_11w4e_72",fA="_dragHandle_11w4e_77",pA="_moveButton_11w4e_78",gA="_items_11w4e_119",hA="_item_11w4e_119",bA="_itemIcon_11w4e_135",yA="_itemTitle_11w4e_144",xA="_itemCheckbox_11w4e_151",CA="_actions_11w4e_155",wA="_action_11w4e_155",vA="_spinnerWrap_11w4e_191",kA="_spinner_11w4e_191",ze={backdrop:oA,dialog:iA,header:aA,body:lA,group:sA,groupDragging:cA,groupDropTarget:uA,groupHeader:dA,groupTitle:mA,dragHandle:fA,moveButton:pA,items:gA,item:hA,itemIcon:bA,itemTitle:yA,itemCheckbox:xA,actions:CA,action:wA,spinnerWrap:vA,spinner:kA};function SA(){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 PA({open:e,catalog:t,groups:n,settings:r,loading:o=!1,busy:a=!1,disabled:l,onChange:u,onReset:d,onClose:f}){const g=X(),h=s.useId(),y=s.useRef(null),[b,C]=s.useState(null),[x,v]=s.useState(null),k=Zu(n.map(E=>E.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),A=new Map(n.map(E=>[E.id,E])),R=k.map(E=>A.get(E)).filter(E=>!!E),T=l||a||o;if(s.useEffect(()=>{e||(C(null),v(null))},[e]),Ye(y,{open:e,onClose:f,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const D=R.map(E=>E.id).filter(E=>E!==dn),P=(E,N)=>{if(T||N===dn){E.preventDefault();return}E.dataTransfer.setData("text/plain",N),E.dataTransfer.effectAllowed="move",C(N)},j=(E,N)=>{T||N===dn||!b||b===N||(E.preventDefault(),E.dataTransfer&&(E.dataTransfer.dropEffect="move"),v(N))},L=(E,N)=>{var G;E.preventDefault();const K=((G=E.dataTransfer)==null?void 0:G.getData("text/plain"))||b;C(null),v(null),!(!K||K===N||T)&&u(nb(r,n,K,N))},V=()=>{C(null),v(null)};return i.jsx(Pe,{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:E=>E.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"})}):R.map(E=>{const N=t.groups[E.id],K=N?tr(g,N):E.id,G=E.id===dn,q=D.indexOf(E.id);return i.jsxs("section",{className:[ze.group,b===E.id?ze.groupDragging:"",x===E.id?ze.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":E.id,"aria-label":K,onDragOver:ae=>j(ae,E.id),onDrop:ae=>L(ae,E.id),onDragLeave:()=>{x===E.id&&v(null)},children:[i.jsxs("div",{className:ze.groupHeader,children:[i.jsx("button",{type:"button",className:ze.dragHandle,draggable:!T&&!G,disabled:T||G,"aria-label":g("customizeToolbarDragHandle"),onDragStart:ae=>P(ae,E.id),onDragEnd:V,children:i.jsx(SA,{})}),i.jsx("span",{className:ze.groupTitle,children:K}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:T||G||q<=0,"aria-label":g("customizeToolbarMoveUp"),onClick:()=>u(Hf(r,n,E.id,-1)),children:"↑"}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:T||G||q<0||q>=D.length-1,"aria-label":g("customizeToolbarMoveDown"),onClick:()=>u(Hf(r,n,E.id,1)),children:"↓"})]}),i.jsx("div",{className:ze.items,children:E.items.map(ae=>{const Z=t.items[ae];if(!Z)return null;const ee=Z.icon,le=tr(g,Z),me=`${h}-${E.id}-${ae}`,ne=!S.has(ae);return i.jsxs("label",{className:ze.item,htmlFor:me,children:[i.jsx("span",{className:ze.itemIcon,"aria-hidden":"true",children:ee?i.jsx(ee,{}):le.slice(0,2)}),i.jsx("span",{className:ze.itemTitle,children:le}),i.jsx("input",{id:me,className:ze.itemCheckbox,type:"checkbox",checked:ne,disabled:T,"aria-label":`${le}: ${g("customizeToolbarItemVisible")}`,onChange:M=>u(rA(r,n,ae,M.target.checked))})]},ae)})})]},E.id)})}),i.jsxs("div",{className:ze.actions,children:[i.jsx("button",{type:"button",className:ze.action,disabled:T,onClick:d,children:g("customizeToolbarDialogReset")}),i.jsx("button",{type:"button",className:ze.action,"aria-label":g("customizeToolbarDialogCloseAria"),onClick:f,children:g("customizeToolbarDialogClose")})]})]})})})}function AA(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(l=>n.includes(l.id)),a=r===void 0?e.iconGroups:e.iconGroups.map(l=>({id:l.id,items:l.items.filter(u=>r.includes(u))})).filter(l=>l.items.length>0);return{menus:o,iconGroups:a}}const TA={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:Qy,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:Ky,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:qy,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},rb=4;function RA({anchorRect:e,floatingWidth:t,floatingHeight:n,pad:r=rb,minWidth:o=0,matchAnchorWidth:a=!1}){const l=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-l-r);return a?{top:u,left:d,width:l}:{top:u,left:d}}function vo(e,t,n,{pad:r=rb,minWidth:o=0,matchAnchorWidth:a=!1,deps:l=[]}={}){const[u,d]=s.useState({top:0,left:0}),f=s.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(RA({anchorRect:y,floatingWidth:b,floatingHeight:C,pad:r,minWidth:o,matchAnchorWidth:a}))},[t,n,a,o,r]);return s.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,...l]),u}const DA="_toolbar_a9bu4_1",IA="_menuBar_a9bu4_35",jA="_menuBarDesktop_a9bu4_43",EA="_brandMark_a9bu4_49",MA="_brandMarkIcon_a9bu4_56",_A="_menuBarCompact_a9bu4_68",NA="_menuWrap_a9bu4_91",LA="_menuButton_a9bu4_97",BA="_iconButton_a9bu4_98",FA="_menuItem_a9bu4_99",HA="_hamburgerButton_a9bu4_144",zA="_iconNav_a9bu4_151",OA="_iconNavMain_a9bu4_162",KA="_iconNavEnd_a9bu4_171",$A="_iconGroup_a9bu4_187",UA="_tooltipTrigger_a9bu4_281",VA="_menu_a9bu4_35",WA="_submenuWrap_a9bu4_311",GA="_submenu_a9bu4_311",qA="_submenuTrigger_a9bu4_321",ZA="_menuOverlay_a9bu4_336",YA="_menuOverlayHeader_a9bu4_348",XA="_menuOverlayTitle_a9bu4_358",JA="_menuOverlayBody_a9bu4_364",QA="_menuSeparator_a9bu4_415",eT="_icon_a9bu4_98",tT="_tooltip_a9bu4_281",nT="_tooltipElevated_a9bu4_510",ce={toolbar:DA,menuBar:IA,menuBarDesktop:jA,brandMark:EA,brandMarkIcon:MA,menuBarCompact:_A,menuWrap:NA,menuButton:LA,iconButton:BA,menuItem:FA,hamburgerButton:HA,iconNav:zA,iconNavMain:OA,iconNavEnd:KA,iconGroup:$A,tooltipTrigger:UA,menu:VA,submenuWrap:WA,submenu:GA,submenuTrigger:qA,menuOverlay:ZA,menuOverlayHeader:YA,menuOverlayTitle:XA,menuOverlayBody:JA,menuSeparator:QA,icon:eT,tooltip:tT,tooltipElevated:nT},rT=400,zf=6,uc=4;function nr({label:e,children:t,className:n,elevated:r}){const o=s.useRef(null),a=s.useRef(null),l=s.useRef(null),u=s.useRef(!1),d=s.useRef(!1),[f,g]=s.useState(!1),[h,y]=s.useState({top:0,left:0}),b=s.useCallback(()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)},[]),C=s.useCallback(k=>{if(!(u.current||d.current)){b(),g(!1);return}if(k||d.current){b(),g(!0);return}b(),l.current=setTimeout(()=>{l.current=null,g(!0)},rT)},[b]),x=s.useCallback(()=>{const k=o.current,S=a.current;if(!k||!S)return;const A=k.getBoundingClientRect(),R=S.offsetWidth,T=S.offsetHeight;let D=A.bottom+zf;D+T>window.innerHeight-uc&&(D=A.top-zf-T);let P=A.left+A.width/2-R/2;P=Math.min(Math.max(P,uc),window.innerWidth-R-uc),y({top:D,left:P})},[]);s.useEffect(()=>()=>b(),[b]),s.useEffect(()=>{const k=o.current;if(!k)return;const S=()=>{d.current=!0,C(!0)},A=()=>{d.current=!1,C(!1)};return k.addEventListener("focusin",S),k.addEventListener("focusout",A),()=>{k.removeEventListener("focusin",S),k.removeEventListener("focusout",A)}},[C]),s.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?`${ce.tooltipTrigger} ${n}`:ce.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(Pe,{children:i.jsx("span",{ref:a,className:r?`${ce.tooltip} ${ce.tooltipElevated}`:ce.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const Of=8,Kf=["#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"],oT=8;let tu=[];const nu=new Set;function $f(){return tu}function iT(e){const t=Ue(e);t&&(tu=[t,...tu.filter(n=>n!==t)].slice(0,oT),nu.forEach(n=>n()))}function aT(e){return nu.add(e),()=>{nu.delete(e)}}function Na(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 dc({r:e,g:t,b:n}){const r=e/255,o=t/255,a=n/255,l=Math.max(r,o,a),u=Math.min(r,o,a),d=l-u;let f=0;return d!==0&&(l===r?f=(o-a)/d%6:l===o?f=(a-r)/d+2:f=(r-o)/d+4,f*=60,f<0&&(f+=360)),{h:f,s:l===0?0:d/l,v:l}}function mc({h:e,s:t,v:n}){const r=(e%360+360)%360,o=n*t,a=o*(1-Math.abs(r/60%2-1)),l=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+l)*255),g:Math.round((d+l)*255),b:Math.round((f+l)*255)}}function ob(){return typeof window<"u"&&"EyeDropper"in window}async function lT(){if(!ob())return null;const e=window.EyeDropper;try{const t=await new e().open();return Ue(t.sRGBHex)}catch{return null}}const sT="_picker_ag1yo_1",cT="_none_ag1yo_12",uT="_customToggle_ag1yo_13",dT="_eyedrop_ag1yo_14",mT="_swatch_ag1yo_48",fT="_field_ag1yo_49",pT="_grid_ag1yo_54",gT="_recents_ag1yo_55",hT="_sectionLabel_ag1yo_84",bT="_custom_ag1yo_13",yT="_sv_ag1yo_95",xT="_svThumb_ag1yo_105",CT="_hue_ag1yo_116",wT="_rgbRow_ag1yo_155",vT="_hexRow_ag1yo_156",rt={picker:sT,none:cT,customToggle:uT,eyedrop:dT,swatch:mT,field:fT,grid:pT,recents:gT,sectionLabel:hT,custom:bT,sv:yT,svThumb:xT,hue:CT,rgbRow:wT,hexRow:vT};function kT(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 Xu({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:o,menu:a=!1,fallbackCustom:l="#000000",onChange:u,onCommit:d}){const f=X(),g=s.useId(),h=a?"menuitemradio":"option",y=t?null:e,b=Na(y??l)??{r:0,g:0,b:0},[C,x]=s.useState(!1),[v,k]=s.useState(()=>dc(b)),[S,A]=s.useState(()=>({r:String(b.r),g:String(b.g),b:String(b.b)})),[R,T]=s.useState(()=>Cr(b.r,b.g,b.b)),[D,P]=s.useState(()=>[...$f()]),j=s.useRef(null),L=s.useRef(Cr(b.r,b.g,b.b));s.useEffect(()=>aT(()=>P([...$f()])),[]),s.useEffect(()=>{const M=Na(y??l);if(!M)return;const re=dc(M);k(re),A({r:String(M.r),g:String(M.g),b:String(M.b)}),T(Cr(M.r,M.g,M.b))},[y,l]);const V=(M,re,O)=>{M&&(L.current=M),O&&M&&iT(M),u(M),re&&(d==null||d(M))},E=(M,re,O)=>{const ie=Cr(M.r,M.g,M.b);k(dc(M)),A({r:String(M.r),g:String(M.g),b:String(M.b)}),T(ie),V(ie,re,O)},N=(M,re,O)=>{const ie=mc(M),Ee=Cr(ie.r,ie.g,ie.b);k(M),A({r:String(ie.r),g:String(ie.g),b:String(ie.b)}),T(Ee),V(Ee,re,O)},K=M=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(M.key))return;const O=[...M.currentTarget.querySelectorAll("button")],ie=O.findIndex($e=>$e===document.activeElement);if(ie<0)return;M.preventDefault();const Ee=M.key==="ArrowLeft"?-1:M.key==="ArrowRight"?1:M.key==="ArrowUp"?-Of:Of,He=O[Math.max(0,Math.min(O.length-1,ie+Ee))];He==null||He.focus()},G=(M,re)=>{const O=j.current;if(!O||o)return;const ie=O.getBoundingClientRect(),Ee=Math.max(0,Math.min(1,(M.clientX-ie.left)/ie.width)),He=Math.max(0,Math.min(1,1-(M.clientY-ie.top)/ie.height));N({h:v.h,s:Ee,v:He},re,re)},q=M=>{o||(M.currentTarget.setPointerCapture(M.pointerId),G(M,!1))},ae=mc({h:v.h,s:1,v:1}),Z=Cr(ae.r,ae.g,ae.b),ee=mc(v),le=Cr(ee.r,ee.g,ee.b),me=new Set(Kf),ne=D.filter(M=>!me.has(M));return i.jsxs("div",{className:rt.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[i.jsx("button",{type:"button",className:rt.none,role:h,"aria-checked":a?y===null&&!t:void 0,"aria-selected":a?void 0:y===null&&!t,disabled:o,onClick:()=>V(null,!0,!1),children:n}),i.jsx("div",{className:rt.grid,role:a?"group":"none",onKeyDown:K,children:Kf.map(M=>{const re=y===M;return i.jsx("button",{type:"button",className:rt.swatch,role:h,"aria-label":M,"aria-checked":a?re:void 0,"aria-selected":a?void 0:re,disabled:o,style:{backgroundColor:M},onMouseDown:O=>O.preventDefault(),onClick:()=>V(M,!0,!1)},M)})}),ne.length>0?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:rt.sectionLabel,children:f("colorRecent")}),i.jsx("div",{className:rt.recents,role:a?"group":"none","aria-label":f("colorRecent"),children:ne.map(M=>i.jsx("button",{type:"button",className:rt.swatch,role:h,"aria-label":M,"aria-checked":a?y===M:void 0,"aria-selected":a?void 0:y===M,disabled:o,style:{backgroundColor:M},onMouseDown:re=>re.preventDefault(),onClick:()=>V(M,!0,!1)},M))})]}):null,i.jsx("button",{type:"button",className:rt.customToggle,disabled:o,"aria-expanded":C,onClick:()=>x(M=>!M),children:f("colorCustom")}),C?i.jsxs("div",{className:rt.custom,children:[i.jsx("div",{ref:j,className:rt.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${Z})`},onPointerDown:q,onPointerMove:M=>{M.currentTarget.hasPointerCapture(M.pointerId)&&G(M,!1)},onPointerUp:M=>{G(M,!0)},children:i.jsx("span",{className:rt.svThumb,style:{left:`${v.s*100}%`,top:`${(1-v.v)*100}%`}})}),i.jsx("input",{className:rt.hue,type:"range",min:0,max:360,value:Math.round(v.h),disabled:o,"aria-label":f("colorCustom"),onChange:M=>N({...v,h:Number(M.target.value)},!1,!1),onPointerUp:()=>V(L.current,!0,!0)}),i.jsx("div",{className:rt.rgbRow,children:["r","g","b"].map(M=>i.jsxs("div",{className:rt.field,children:[i.jsx("label",{htmlFor:`${g}-${M}`,children:f(M==="r"?"colorRgbR":M==="g"?"colorRgbG":"colorRgbB")}),i.jsx("input",{id:`${g}-${M}`,inputMode:"numeric",value:S[M],disabled:o,onChange:re=>{A(O=>({...O,[M]:re.target.value}))},onBlur:()=>{const re=kT(S[M]);if(re===null){A({r:String(ee.r),g:String(ee.g),b:String(ee.b)});return}E({...ee,[M]:re},!0,!0)},onKeyDown:re=>{re.key==="Enter"&&re.currentTarget.blur()}})]},M))}),i.jsx("div",{className:rt.hexRow,children:i.jsxs("div",{className:rt.field,children:[i.jsx("label",{htmlFor:`${g}-hex`,children:f("colorHex")}),i.jsx("input",{id:`${g}-hex`,value:R,disabled:o,onChange:M=>T(M.target.value),onBlur:()=>{const M=Ue(R);if(!M){T(le);return}const re=Na(M);re&&E(re,!0,!0)},onKeyDown:M=>{M.key==="Enter"&&M.currentTarget.blur()}})]})}),ob()?i.jsx("button",{type:"button",className:rt.eyedrop,disabled:o,onClick:()=>{lT().then(M=>{if(!M)return;const re=Na(M);re&&E(re,!0,!0)})},children:f("colorPickFromScreen")}):null]}):null]})}const ST="_wrap_hfz5s_1",PT="_button_hfz5s_8",AT="_icon_hfz5s_18",TT="_bar_hfz5s_24",RT="_barEmpty_hfz5s_33",DT="_popover_hfz5s_43",wr={wrap:ST,button:PT,icon:AT,bar:TT,barEmpty:RT,popover:DT};function ib({icon:e,value:t,mixed:n,noneKey:r,labelKey:o,ariaKey:a,fallbackCustom:l,disabled:u,onChange:d}){const f=X(),g=s.useId(),h=s.useRef(null),y=s.useRef(null),b=s.useRef(null),[C,x]=s.useState(!1),v=vo(C,y,b);s.useEffect(()=>{if(!C)return;const T=P=>{var L,V;const j=P.target;(L=h.current)!=null&&L.contains(j)||(V=b.current)!=null&&V.contains(j)||x(!1)},D=P=>{var j;P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),x(!1),(j=y.current)==null||j.focus())};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",D,!0),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",D,!0)}},[C]);const k=T=>{d(T)},S=`${wr.bar}${!t||n?` ${wr.barEmpty}`:""}`,A=t&&!n?{backgroundColor:t}:void 0,R=i.jsxs("div",{className:wr.wrap,ref:h,children:[i.jsxs("button",{ref:y,type:"button",className:`${ce.iconButton} ${wr.button}`,"aria-label":f(a),"aria-expanded":C,"aria-haspopup":"listbox","aria-controls":C?g:void 0,disabled:u,onMouseDown:T=>T.preventDefault(),onClick:()=>x(T=>!T),children:[i.jsx(e,{className:`${ce.icon} ${wr.icon}`}),i.jsx("span",{className:S,style:A})]}),C?i.jsx(Pe,{children:i.jsx("div",{ref:b,id:g,className:wr.popover,style:{top:v.top,left:v.left},children:i.jsx(Xu,{value:t,mixed:n,noneLabel:f(r),ariaLabel:f(a),disabled:u,fallbackCustom:l,onChange:k,onCommit:()=>x(!1)})})}):null]});return i.jsx(nr,{label:f(o),children:R})}function IT({commands:e,queries:t,disabled:n}){return i.jsx(ib,{icon:ap,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}const jT="_wrap_1vjt0_1",ET="_wrapToolbar_1vjt0_7",MT="_field_1vjt0_12",_T="_trigger_1vjt0_20",NT="_chevron_1vjt0_50",LT="_list_1vjt0_73",BT="_listInline_1vjt0_88",FT="_option_1vjt0_96",HT="_separator_1vjt0_125",Yt={wrap:jT,wrapToolbar:ET,field:MT,trigger:_T,chevron:NT,list:LT,listInline:BT,option:FT,separator:HT};function zT({value:e,mixed:t=!1,fonts:n,disabled:r,listId:o,listRef:a,inline:l,style:u,onSelect:d}){const f=X(),g=!t&&e===null;return i.jsxs("ul",{ref:a,id:o,className:l?`${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 y=!t&&yi(e,h.family);return i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Yt.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 OT(e,t,n,r){var o;return t?"":e===null?r:((o=Mx(e,n))==null?void 0:o.name)??e}function ab({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:o,toolbar:a=!1,triggerId:l,onChange:u}){const d=X(),f=s.useId(),g=s.useRef(null),h=s.useRef(null),y=s.useRef(null),[b,C]=s.useState(!1),x=OT(e,t,n,d("fontFamilyDefault")),v=vo(b,h,y,{matchAnchorWidth:!0,deps:[n.length]});s.useEffect(()=>{if(!b)return;const S=R=>{var D,P;const T=R.target;(D=g.current)!=null&&D.contains(T)||(P=y.current)!=null&&P.contains(T)||C(!1)},A=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),C(!1))};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",A,!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:l,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:()=>C(S=>!S),children:x}),i.jsx("span",{className:Yt.chevron,"aria-hidden":"true"})]}),b?i.jsx(Pe,{children:i.jsx(zT,{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(nr,{label:o,children:k}):k}function KT({commands:e,queries:t,disabled:n}){const r=X(),o=!!(n||!t.isVisualMode());return i.jsx(ab,{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 $T="_wrap_58i0x_1",UT="_wrapToolbar_58i0x_9",VT="_field_58i0x_14",WT="_input_58i0x_22",GT="_toggle_58i0x_41",qT="_chevron_58i0x_42",ZT="_unit_58i0x_80",YT="_list_58i0x_110",XT="_option_58i0x_125",qe={wrap:$T,wrapToolbar:UT,field:VT,input:WT,toggle:GT,chevron:qT,unit:ZT,list:YT,option:XT},JT={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function lb({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:o,tooltip:a,sizeInputId:l,toolbar:u=!1}){const d=X(),f=s.useId(),g=s.useRef(null),h=s.useRef(null),y=s.useRef(null),[b,C]=s.useState(()=>e===null?"":be(e)),[x,v]=s.useState(!1),[k,S]=s.useState(!1),A=vo(k,h,y,{matchAnchorWidth:!0,minWidth:72});s.useEffect(()=>{x||C(e===null?"":be(e))},[e,x]),s.useEffect(()=>{if(!k)return;const j=V=>{var N,K;const E=V.target;(N=g.current)!=null&&N.contains(E)||(K=y.current)!=null&&K.contains(E)||S(!1)},L=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",L,!0)}},[k]);const R=j=>{const L=eC(j,t);if(!L){C(e===null?"":be(e));return}n(L.value,L.unit),C(be(L.value))},T=Yx[t],D=k?i.jsx(Pe,{children:i.jsx("ul",{ref:y,className:qe.list,role:"listbox",id:f,style:{top:A.top,left:A.left,minWidth:A.width},children:T.map(j=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:qe.option,role:"option","aria-selected":e===j,onMouseDown:L=>L.preventDefault(),onClick:()=>{n(j,t),C(be(j)),S(!1)},children:be(j)})},j))})}):null,P=i.jsxs("div",{className:`${qe.wrap}${u?` ${qe.wrapToolbar}`:""}`,ref:g,children:[i.jsxs("div",{className:qe.field,ref:h,children:[i.jsx("input",{id:l,className:qe.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:j=>C(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),R(b),S(!1),j.currentTarget.blur()),j.key==="ArrowDown"&&(j.preventDefault(),S(!0))}}),i.jsx("button",{type:"button",className:qe.toggle,tabIndex:-1,disabled:o,"aria-label":d("commandFontSizeAria"),"aria-expanded":k,"aria-controls":f,onMouseDown:j=>j.preventDefault(),onClick:()=>S(j=>!j)})]}),i.jsxs("div",{className:qe.field,children:[i.jsx("select",{className:qe.unit,value:t,disabled:o,"aria-label":d("commandFontSizeUnitAria"),onChange:j=>{r(j.target.value)},children:fu.map(j=>i.jsx("option",{value:j,children:d(JT[j])},j))}),i.jsx("span",{className:qe.chevron,"aria-hidden":"true"})]}),D]});return a?i.jsx(nr,{label:a,children:P}):P}function QT({commands:e,queries:t,disabled:n}){const r=X(),o=!!(n||!t.isVisualMode());return i.jsx(lb,{size:t.getFontSize(),unit:t.getFontSizeUnit(),disabled:o,tooltip:r("commandFontSize"),toolbar:!0,onSizeChange:(a,l)=>{e.setFontSize(a,l)},onUnitChange:a=>{e.setFontSizeUnit(a)}})}function eR({commands:e,queries:t,disabled:n}){return i.jsx(ib,{icon:lp,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function tR({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=X(),a=!!(n||!t.isVisualMode());return i.jsx(Xu,{value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneLabel:o("colorNone"),ariaLabel:o("commandHighlightColorAria"),disabled:a,menu:!0,fallbackCustom:"#ffff00",onChange:l=>e.setHighlightColor(l),onCommit:()=>r==null?void 0:r()})}const nR="_wrap_1gtdc_1",rR="_wrapToolbar_1gtdc_7",oR="_field_1gtdc_12",iR="_trigger_1gtdc_20",aR="_chevron_1gtdc_46",lR="_list_1gtdc_69",sR="_option_1gtdc_84",cR="_separator_1gtdc_113",Dn={wrap:nR,wrapToolbar:rR,field:oR,trigger:iR,chevron:aR,list:lR,option:sR,separator:cR},uR="_backdrop_1p9zk_1",dR="_dialog_1p9zk_12",mR="_dialogWide_1p9zk_31",fR="_header_1p9zk_35",pR="_tabs_1p9zk_43",gR="_tab_1p9zk_43",hR="_body_1p9zk_76",bR="_field_1p9zk_86",yR="_label_1p9zk_92",xR="_sizeRow_1p9zk_96",CR="_fileRow_1p9zk_102",wR="_fileName_1p9zk_108",vR="_previewImage_1p9zk_115",kR="_marks_1p9zk_125",SR="_mark_1p9zk_125",PR="_actions_1p9zk_140",AR="_actionsSpread_1p9zk_148",TR="_actionsEnd_1p9zk_152",RR="_headerRow_1p9zk_157",DR="_close_1p9zk_170",IR="_nameSection_1p9zk_187",jR="_nameInput_1p9zk_192",ER="_labelRow_1p9zk_209",MR="_help_1p9zk_215",_R="_textInput_1p9zk_233",NR="_fullSelect_1p9zk_245",LR="_error_1p9zk_249",BR="_emptyHint_1p9zk_254",FR="_action_1p9zk_140",HR="_textarea_1p9zk_265",zR="_actionDanger_1p9zk_279",OR="_confirmBody_1p9zk_285",KR="_nestedPanel_1p9zk_294",$R="_spinnerWrap_1p9zk_309",UR="_spinner_1p9zk_309",VR="_actionPrimary_1p9zk_344",WR="_iconButton_1p9zk_358",GR="_select_1p9zk_359",qR="_lengthInput_1p9zk_360",ZR="_lengthUnit_1p9zk_361",YR="_group_1p9zk_369",XR="_nestedGroup_1p9zk_379",JR="_subLabel_1p9zk_389",QR="_iconRow_1p9zk_393",eD="_lengthField_1p9zk_425",tD="_sideLabel_1p9zk_431",nD="_lengthRow_1p9zk_435",rD="_sideGrid_1p9zk_463",oD="_shadowGrid_1p9zk_464",p={backdrop:uR,dialog:dR,dialogWide:mR,header:fR,tabs:pR,tab:gR,body:hR,field:bR,label:yR,sizeRow:xR,fileRow:CR,fileName:wR,previewImage:vR,marks:kR,mark:SR,actions:PR,actionsSpread:AR,actionsEnd:TR,headerRow:RR,close:DR,nameSection:IR,nameInput:jR,labelRow:ER,help:MR,textInput:_R,fullSelect:NR,error:LR,emptyHint:BR,action:FR,textarea:HR,actionDanger:zR,confirmBody:OR,nestedPanel:KR,spinnerWrap:$R,spinner:UR,actionPrimary:VR,iconButton:WR,select:GR,lengthInput:qR,lengthUnit:ZR,group:YR,nestedGroup:XR,subLabel:JR,iconRow:QR,lengthField:eD,sideLabel:tD,lengthRow:nD,sideGrid:rD,shadowGrid:oD},ru={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},iD={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 Uf(){const e=X();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 sb({value:e,mixed:t=!1,disabled:n,menu:r=!1,listId:o,listRef:a,style:l,customStylesEnabled:u=!1,customStyles:d=[],customStylesLoading:f=!1,onSelect:g,onSelectCustom:h,onAddNew:y}){const b=X(),C=t?null:e,x=u,v=!!(r&&u&&y);return r?i.jsxs(i.Fragment,{children:[rl.map(k=>i.jsx("button",{type:"button",className:ce.menuItem,role:"menuitemradio","aria-checked":C===k,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(ru[k])},k)),x?i.jsx("div",{role:"separator",className:ce.menuSeparator}):null,x&&f?i.jsx(Uf,{}):null,x&&!f?d.map(k=>i.jsx("button",{type:"button",className:ce.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:ce.menuSeparator}):null,i.jsxs("button",{type:"button",className:ce.menuItem,role:"menuitem","aria-label":b("styleAddNewAria"),disabled:n,onMouseDown:k=>k.preventDefault(),onClick:()=>y==null?void 0:y(),children:[i.jsx(Gy,{className:ce.icon}),b("styleAddNew")]})]}):null]}):i.jsxs("ul",{ref:a,className:Dn.list,role:"listbox",id:o,style:l,"aria-label":b("commandParagraphStyleAria"),"aria-busy":x&&f?!0:void 0,children:[rl.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Dn.option,role:"option","aria-selected":C===k,disabled:n,style:iD[k],onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(ru[k])})},k)),x&&(f||d.length>0)?i.jsx("li",{role:"separator",className:Dn.separator}):null,x&&f?i.jsx("li",{role:"presentation",children:i.jsx(Uf,{})}):null,x&&!f?d.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Dn.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 aD({commands:e,queries:t,disabled:n}){const r=X(),o=s.useId(),a=s.useRef(null),l=s.useRef(null),u=s.useRef(null),[d,f]=s.useState(!1),g=!!(n||!t.isVisualMode()),h=t.isParagraphStyleMixed(),y=h?null:t.getParagraphStyle(),b=y?r(ru[y]):"",C=t.customParagraphStylesEnabled(),x=C?t.getCustomParagraphStyles():[],v=C&&t.isCustomParagraphStylesLoading(),k=vo(d,l,u,{matchAnchorWidth:!0,deps:[x.length,v]});s.useEffect(()=>{if(!d)return;const A=T=>{var P,j;const D=T.target;(P=a.current)!=null&&P.contains(D)||(j=u.current)!=null&&j.contains(D)||f(!1)},R=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),f(!1))};return document.addEventListener("pointerdown",A),document.addEventListener("keydown",R,!0),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("keydown",R,!0)}},[d]);const S=i.jsxs("div",{className:`${Dn.wrap} ${Dn.wrapToolbar}`,ref:a,children:[i.jsxs("div",{className:Dn.field,ref:l,children:[i.jsx("button",{type:"button",className:Dn.trigger,disabled:g,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":d,"aria-controls":d?o:void 0,onMouseDown:A=>A.preventDefault(),onClick:()=>f(A=>!A),children:b}),i.jsx("span",{className:Dn.chevron,"aria-hidden":"true"})]}),d?i.jsx(Pe,{children:i.jsx(sb,{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:A=>{e.setParagraphStyle(A),f(!1)},onSelectCustom:A=>{e.applyCustomParagraphStyle(A),f(!1)}})}):null]});return i.jsx(nr,{label:r("commandParagraphStyle"),children:S})}function lD({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=!!(n||!t.isVisualMode()),a=t.isParagraphStyleMixed(),l=a?null:t.getParagraphStyle(),u=t.customParagraphStylesEnabled(),d=u?t.getCustomParagraphStyles():[],f=u&&t.isCustomParagraphStylesLoading();return i.jsx(sb,{menu:!0,value:l,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 sD={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:lD,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:tR,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:KT,icon:Dy,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:aD,icon:Wy,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:QT,icon:jy,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:Iy,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},customCss:{id:"customCss",command:"openCustomCss",icon:Ay,labelKey:"commandCustomCss",ariaKey:"commandCustomCssAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:up,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:sp,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:IT,icon:ap,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:eR,icon:lp,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:xy,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:By,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:tx,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:ex,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:vy,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},formatBrush:{id:"formatBrush",command:"toggleFormatBrush",icon:Ey,labelKey:"commandFormatBrush",ariaKey:"commandFormatBrushAria",active:"isFormatBrushActive",enabled:"isVisualMode",toggle:!0},alignLeft:{id:"alignLeft",command:"alignLeft",icon:gl,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:pl,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:hl,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:op,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:Ly,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:$y,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:ip,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:cp,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},cD={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:Hy,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Cy,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:sp,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},pageBackgroundImage:{id:"pageBackgroundImage",command:"openPageBackgroundImage",icon:ti,labelKey:"commandPageBackgroundImage",ariaKey:"commandPageBackgroundImageAria",enabled:"canInsertPageBackgroundImage"},paragraphBackgroundImage:{id:"paragraphBackgroundImage",command:"openParagraphBackgroundImage",icon:up,labelKey:"commandParagraphBackgroundImage",ariaKey:"commandParagraphBackgroundImageAria",enabled:"canInsertParagraphBackgroundImage"},audio:{id:"audio",command:"openAudioDialog",icon:yy,labelKey:"commandAudio",ariaKey:"commandAudioAria",enabled:"isVisualMode"},youtube:{id:"youtube",command:"openYoutubeDialog",icon:ix,labelKey:"commandYoutube",ariaKey:"commandYoutubeAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:_y,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"},pageBreak:{id:"pageBreak",command:"insertPageBreak",icon:Uy,labelKey:"commandPageBreak",ariaKey:"commandPageBreakAria",enabled:"isVisualMode"},insertPageBefore:{id:"insertPageBefore",command:"insertPageBefore",icon:ti,labelKey:"commandInsertPageBefore",ariaKey:"commandInsertPageBeforeAria",enabled:"hasSelectedPage"},insertPageAfter:{id:"insertPageAfter",command:"insertPageAfter",icon:ti,labelKey:"commandInsertPageAfter",ariaKey:"commandInsertPageAfterAria",enabled:"hasSelectedPage"}}},uD={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:Bm,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:Zs,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:Zs,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:Zs,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:qs,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:qs,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:qs,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},mergeCells:{id:"mergeCells",command:"mergeCells",icon:Oy,labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:"canMergeCells"},unmergeCells:{id:"unmergeCells",command:"unmergeCells",icon:rx,labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:"canUnmergeCells"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:Bm,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:wy,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:Xy,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},dD={menus:{help:{id:"help",labelKey:"menuHelp",ariaKey:"menuHelpAria"}},groups:{},items:{editorHelp:{id:"editorHelp",command:"openHelp",icon:Gs,labelKey:"commandEditorHelp",ariaKey:"commandEditorHelpAria"},keyboardShortcuts:{id:"keyboardShortcuts",command:"openKeyboardShortcuts",icon:Gs,labelKey:"commandKeyboardShortcuts",ariaKey:"commandKeyboardShortcutsAria"},about:{id:"about",command:"openAbout",icon:Gs,labelKey:"commandAbout",ariaKey:"commandAboutAria"}}},mD=["getStarted","file","edit","insert","format","table","view","keyboard"],ou=[{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"]}],Vf=Object.fromEntries(ou.map(e=>[e.id,e]));function cb(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function fD(e,t){const n=cb(t);if(n.length===0)return 1;const r=e.title.toLowerCase(),o=e.body.toLowerCase(),a=e.keywords.toLowerCase(),l=`${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),l.includes(d)&&(u+=5);return u}function pD(e,t){return cb(t).length===0?e:e.map(r=>({entry:r,score:fD(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 gD={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:ox,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:Ny,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:Ty,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:Fy,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:Ry,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:Vy,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},ruler:{id:"ruler",command:"toggleRuler",icon:Jy,labelKey:"commandRuler",ariaKey:"commandRulerAria",active:"isRulerVisible",toggle:!0},readAloud:{id:"readAloud",command:"toggleReadAloud",icon:Zy,labelKey:"commandReadAloud",ariaKey:"commandReadAloudAria",active:"isReadingAloud",toggle:!0,enabled:"canReadAloud"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:My,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function hD(...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 bD=hD(TA,qP,cD,uD,gD,sD,dD),yD={menus:[{id:"file",items:["save","open",Se,"print"]},{id:"edit",items:["undo","redo",Se,{submenu:"page",items:["pageProperties",Se,"deletePage"]}]},{id:"view",items:["visual","html",Se,{submenu:"toolbar",items:["customizeToolbar",Se,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},Se,{submenu:"zoom",items:["pageZoomFitWidth","pageZoomFitPage",Se,"pageZoom50","pageZoom75","pageZoom100","pageZoom125","pageZoom150","pageZoom200"]},Se,"lightMode","darkMode",Se,"toggleCommentsVisible","ruler","preview","readAloud","fullscreen"]},{id:"insert",items:["pageBreak",{submenu:"insertPage",items:["insertPageBefore","insertPageAfter"]},Se,"table",Se,"image","pageBackgroundImage","paragraphBackgroundImage","audio","youtube","horizontalRule",Se,"link","bookmark",Se,"insertComment"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},Se,{submenu:"font",items:["fontProperties","customCss",Se,{submenu:"highlightColor",items:[]},Se,"bold","italic","underline","strikethrough"]},Se,"clearFormatting",Se,{submenu:"paragraph",items:["paragraphProperties",Se,"alignLeft","alignCenter","alignRight","alignJustify",Se,"indent","outdent",Se,"bulletList","numberedList"]},Se,"imageProperties"]},{id:"table",items:["table",Se,{submenu:"insertRow",items:["insertRowBefore","insertRowBelow","deleteRow"]},{submenu:"insertColumn",items:["insertColumnBefore","insertColumnAfter","deleteColumn"]},Se,"mergeCells","unmergeCells",Se,"tableProperties","rowProperties","cellProperties"]},{id:"help",items:["editorHelp","keyboardShortcuts",Se,"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"]}]},Wf={items:{addComment:{id:"addComment",command:"addComment",icon:Lm,labelKey:"commandAddComment",ariaKey:"commandAddCommentAria",enabled:"canAddComment"},insertComment:{id:"insertComment",command:"addComment",icon:Lm,labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:"canAddComment"},toggleCommentsVisible:{id:"toggleCommentsVisible",command:"toggleCommentsVisible",icon:ky,labelKey:"showComments",ariaKey:"toggleCommentsVisibleAria",toggle:!0,active:"areCommentsVisible"}}},xD=["addComment","insertComment","toggleCommentsVisible"],CD=new Set(["insert","view"]);function ub(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!xD.includes(e):!0:!1}function wD(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!CD.has(e):!0:!1}function vD(e,t){const n=t?"hideComments":"showComments",r=Wf.items.toggleCommentsVisible;return{...e,items:{...e.items,...Wf.items,toggleCommentsVisible:r&&{...r,labelKey:n}}}}function kD(e){return{...e,menus:e.menus.map(t=>{if(t.id==="insert"){const n=[...t.items],r=n.findIndex(a=>Jn(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 Gf={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 db(){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 mb(e){const t=new Set;return e.active&&t.add(Gf[e.active]??"chrome"),e.enabled&&t.add(Gf[e.enabled]??"chrome"),t.size===0&&t.add("chrome"),[...t]}const fb=s.createContext(null);function SD({value:e,children:t}){return i.jsx(fb.Provider,{value:e,children:t})}function pb(e){const t=s.useContext(fb),n=s.useMemo(()=>e.join("\0"),[e]),r=s.useMemo(()=>e,[n,e]);s.useSyncExternalStore(o=>{if(!t)return()=>{};const a=r.map(l=>t.subscribe(l,o));return()=>{for(const l of a)l()}},()=>{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 La="fullscreen";function PD(e){const t=[];let n=null;for(const r of e){const o=r.items.filter(a=>a!==La);o.length>0&&t.push({id:r.id,items:o}),r.items.includes(La)&&(n={id:La,items:[La]})}return{main:t,trailing:n}}const AD=s.memo(function({item:t,itemId:n,commands:r,queries:o,disabled:a,chromeLock:l}){const u=X(),d=s.useMemo(()=>mb(t),[t]);if(pb(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(nr,{label:t.tooltip??tr(u,t),children:i.jsx("button",{type:"button",className:ce.iconButton,"aria-label":ul(u,t),"aria-pressed":y,disabled:a||(l?ub(n,l):!1)||h,onPointerDown:b=>b.preventDefault(),onMouseDown:b=>b.preventDefault(),onClick:()=>{su(r,g)},children:i.jsx(f,{className:ce.icon})})})});function TD({groups:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a}){const l=X(),{main:u,trailing:d}=PD(e),f=g=>{const h=t.groups[g.id];return i.jsx("div",{className:ce.iconGroup,role:"group","aria-label":h?tr(l,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(AD,{itemId:y,item:b,commands:n,queries:r,disabled:o,chromeLock:a},y)})},g.id)};return i.jsxs("div",{className:ce.iconNav,role:"toolbar","aria-label":l("toolbarAria"),children:[u.length>0?i.jsx("div",{className:ce.iconNavMain,children:u.map(f)}):null,d?i.jsx("div",{className:ce.iconNavEnd,children:f(d)}):null]})}const RD=["--wysiwyg-menu-color","--wysiwyg-menu-background"],qf=["--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function DD(e,t){const n=t?qf:[...RD,...qf],r={};for(const o of n){const a=getComputedStyle(e).getPropertyValue(o).trim();if(a){r[o]=a;continue}let l=e;for(;l;){const u=l.style.getPropertyValue(o).trim();if(u){r[o]=u;break}l=l.parentElement}}return r}function ID({menus:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,compact:l,openMenuId:u,onOpenMenuIdChange:d}){const f=X(),g=yp(),[h,y]=s.useState(!1),[b,C]=s.useState({}),x=s.useRef(null),v=s.useRef(null),k=s.useRef(null),S=s.useRef(null),A=s.useCallback(()=>{y(!1),d(null)},[d]);s.useLayoutEffect(()=>{!h||!x.current||C(DD(x.current,g))},[g,h]),s.useEffect(()=>{var T;h&&((T=k.current)==null||T.focus())},[h]),s.useEffect(()=>{if(!h)return;const T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=T}},[h]),s.useEffect(()=>{if(!h)return;const T=P=>{var j;if(P.key==="Escape"){if(P.preventDefault(),P.stopPropagation(),u){d(null);return}A(),(j=v.current)==null||j.focus()}},D=P=>{var j;S.current&&!S.current.contains(P.target)&&(A(),(j=v.current)==null||j.focus())};return document.addEventListener("keydown",T,!0),document.addEventListener("pointerdown",D),()=>{document.removeEventListener("keydown",T,!0),document.removeEventListener("pointerdown",D)}},[h,u,d,A]);const R=T=>e.map(D=>{const P=t.menus[D.id];return P?i.jsx(ED,{def:P,itemIds:D.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:T,open:(T==="overlay"||!h)&&u===D.id,onOpenChange:j=>d(j?D.id:null),onItemRun:T==="overlay"?()=>{var j;A(),(j=v.current)==null||j.focus()}:void 0},`${T}-${D.id}`):null});return i.jsxs("div",{className:ce.menuBar,ref:x,children:[i.jsx(nr,{label:f("brandMarkAria"),children:i.jsx("span",{className:ce.brandMark,role:"img","aria-label":f("brandMarkAria"),children:i.jsx(Sy,{className:ce.brandMarkIcon})})}),i.jsx("div",{className:ce.menuBarCompact,hidden:l===void 0?void 0:!l,children:i.jsx(nr,{label:f("menuHamburgerAria"),children:i.jsx("button",{ref:v,type:"button",className:`${ce.menuButton} ${ce.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":h,"aria-label":f("menuHamburgerAria"),disabled:o||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>{if(h){A();return}d(null),y(!0)},children:i.jsx(zy,{className:ce.icon})})})}),i.jsx("div",{className:ce.menuBarDesktop,hidden:l===void 0?void 0:l,children:R("dropdown")}),h?i.jsx(Pe,{children:i.jsx("div",{className:ce.toolbar,"data-menu-overlay-portal":"",style:b,children:i.jsxs("div",{ref:S,className:ce.menuOverlay,role:"dialog","aria-modal":"true","aria-label":f("menuOverlayAria"),children:[i.jsxs("div",{className:ce.menuOverlayHeader,children:[i.jsx("span",{className:ce.menuOverlayTitle,children:f("menuOverlayAria")}),i.jsx("button",{ref:k,type:"button",className:ce.iconButton,"aria-label":f("menuCloseAria"),onClick:()=>{var T;A(),(T=v.current)==null||T.focus()},children:i.jsx(Qe,{className:ce.icon})})]}),i.jsx("div",{className:ce.menuOverlayBody,children:R("overlay")})]})})}):null]})}function dl(e,t){var n,r;if(Xn(e))return!1;if(Jn(e)){const o=(n=t.submenus)==null?void 0:n[e.submenu];return o?o.panel?!0:e.items.some(a=>dl(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function jD(e,t,n){if(!Xn(e[t])||!e.slice(t+1).some(a=>dl(a,n)))return!1;let o=!1;for(let a=t-1;a>=0;a--){const l=e[a];if(Xn(l)){o=!0;continue}if(dl(l,n))return!o}return!1}function ED({def:e,itemIds:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:l,variant:u,open:d,onOpenChange:f,onItemRun:g}){const h=X(),y=s.useRef(null),b=u==="overlay"?`overlay-${e.id}-menu`:`${e.id}-menu`,[C,x]=s.useState(null);s.useEffect(()=>{d||x(null)},[d]),s.useEffect(()=>{if(!d||u==="overlay")return;const k=A=>{y.current&&!y.current.contains(A.target)&&f(!1)},S=A=>{if(A.key==="Escape"){if(A.preventDefault(),A.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:ce.menuWrap,ref:y,children:[i.jsx("button",{type:"button",className:ce.menuButton,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":b,"aria-label":ul(h,e),disabled:a||(l?wD(e.id,l):!1),onClick:()=>f(!d),children:tr(h,e)}),d?i.jsx("div",{className:ce.menu,role:"menu",id:b,onMouseDown:k=>k.preventDefault(),children:i.jsx(gb,{entries:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:l,variant:u,onClose:v,openSubmenuId:C,onOpenSubmenuIdChange:x})}):null]})}function gb({entries:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:l,onClose:u,openSubmenuId:d,onOpenSubmenuIdChange:f}){return i.jsx(i.Fragment,{children:e.map((g,h)=>{if(Xn(g))return jD(e,h,t)?i.jsx("div",{role:"separator",className:ce.menuSeparator},`separator-${h}`):null;if(Jn(g))return i.jsx(_D,{entry:g,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:l,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(MD,{item:y,commands:n,queries:r,disabled:o,chromeLock:a,onClose:u},g)})})}function MD({item:e,commands:t,queries:n,disabled:r,chromeLock:o,onClose:a}){const l=X(),u=s.useMemo(()=>mb(e),[e]);if(pb(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:ce.menuItem,"aria-checked":g,disabled:r||(o?ub(e.id,o):!1)||h,onClick:()=>{a(),su(t,f)},children:[d?i.jsx(d,{className:ce.icon}):null,tr(l,e)]})}function _D({entry:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:l,onClose:u,open:d,onOpenChange:f}){var D;const g=X(),h=s.useRef(null),y=s.useRef(null),[b,C]=s.useState(null),x=(D=t.submenus)==null?void 0:D[e.submenu],v=l==="overlay"?`overlay-${e.submenu}-submenu`:`${e.submenu}-submenu`,k=x==null?void 0:x.panel,S=x!=null&&x.enabled?!r[x.enabled]():!1,A=l==="overlay";if(s.useEffect(()=>{d||C(null)},[d]),!x||!k&&!e.items.some(P=>dl(P,t)))return null;const R=P=>{(P.key==="ArrowRight"||P.key==="Enter"||P.key===" ")&&(P.preventDefault(),P.stopPropagation(),f(!0),requestAnimationFrame(()=>{var L;const j=(L=y.current)==null?void 0:L.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');j==null||j.focus()}))},T=P=>{var j;P.key==="ArrowLeft"&&(P.preventDefault(),P.stopPropagation(),f(!1),(j=h.current)==null||j.focus())};return i.jsxs("div",{className:ce.submenuWrap,onMouseEnter:A?void 0:()=>f(!0),onMouseLeave:A?void 0:()=>f(!1),children:[i.jsx("button",{ref:h,type:"button",role:"menuitem",className:`${ce.menuItem} ${ce.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":v,"aria-label":ul(g,x),disabled:o||S||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>f(A?!d:!0),onKeyDown:R,children:tr(g,x)}),d?i.jsx("div",{ref:y,className:`${ce.menu} ${ce.submenu}`,role:"menu",id:v,"aria-label":ul(g,x),onMouseDown:P=>P.preventDefault(),onKeyDown:T,children:k?i.jsx(k,{commands:n,queries:r,disabled:o||S,onMenuClose:u}):i.jsx(gb,{entries:e.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:l,onClose:u,openSubmenuId:b,onOpenSubmenuIdChange:C})}):null]})}const iu=s.memo(function({catalog:t,layout:n,commands:r,queries:o,queryRevisions:a,disabled:l,chromeLock:u,menuVisible:d=!0,toolbarVisible:f=!0,compact:g,position:h="top"}){const[y,b]=s.useState(null);if(!d&&!f)return null;const C=i.jsxs("div",{className:ce.toolbar,"data-compact":g?"":void 0,"data-toolbar-position":h,children:[d?i.jsx(ID,{menus:n.menus,catalog:t,commands:r,queries:o,disabled:l,chromeLock:u,compact:g,openMenuId:y,onOpenMenuIdChange:b}):null,f?i.jsx(TD,{groups:n.iconGroups,catalog:t,commands:r,queries:o,disabled:l,chromeLock:u}):null]});return a?i.jsx(SD,{value:a,children:C}):C});function ND(e,t){return t?e:{...e,menus:e.menus.map(n=>n.id==="insert"?{...n,items:n.items.filter(r=>!(Jn(r)&&r.submenu==="insertPage"))}:n.id==="edit"?{...n,items:n.items.map(r=>{if(!Jn(r)||r.submenu!=="page")return r;let o=r.items.filter(a=>a!=="deletePage");return o.at(-1)===Se&&(o=o.slice(0,-1)),{...r,items:o}})}:n)}}function hi(e){return ag(ot(e))}const LD=1.5,fc=384;function BD(e,t=16){return e>0?LD*t:0}function hb(e,t,n=16){const r=BD(t,n);if(!hi(e))return fc+r;const o=ot(e),a=Co(o,!1);return a?Vn(a.height,fc)+r:fc+r}function ei(e,t){const n=[0];for(let r=0;r<e;r+=1)n.push(n[r]+t(r));return n}function FD(){const e=new Map;return{get(t,n){return e.get(t)??hb(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 HD=2;function bb(e,t,n){if(n<=0)return 0;let r=0,o=n-1,a=0;for(;r<=o;){const l=r+o>>1;(t[l+1]??0)>e?(a=l,o=l-1):r=l+1}return a}function yb(e,t,n){if(n<=0)return-1;let r=0,o=n-1,a=n-1;for(;r<=o;){const l=r+o>>1;(t[l]??0)<e?(a=l,r=l+1):o=l-1}return a}function Zf(e,t,n,r,o,a,l){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=bb(e,n,r),g=yb(d,n,r);let h=Math.max(0,f-o),y=Math.min(r-1,g+o);l&&(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 zD({scrollElementRef:e,pageCount:t,getRowHeight:n,overscan:r=HD,activePageIndex:o,pinActivePage:a=!0}){const l=s.useRef(n);l.current=n;const u=s.useRef(new Map),[d,f]=s.useState(0);s.useLayoutEffect(()=>{u.current.clear()},[t]);const g=s.useCallback(S=>{const A=u.current.get(S),R=l.current(S);return A!==void 0?Math.max(A,R):R},[d]),h=s.useMemo(()=>ei(t,g),[t,g]),[y,b]=s.useState(()=>{const S=ei(t,A=>l.current(A));return Zf(0,300,S,t,r,o,a)}),C=s.useCallback(()=>{const S=e.current;if(!S||t<=0)return;const A=S.clientHeight>0?S.clientHeight:300,R=ei(t,g);b(Zf(S.scrollTop,A,R,t,r,o,a))},[o,r,t,a,g,e]);s.useLayoutEffect(()=>{C()},[C,h,o,t]),s.useLayoutEffect(()=>{const S=e.current;if(!S)return;const A=()=>C();S.addEventListener("scroll",A,{passive:!0});let R;return typeof ResizeObserver<"u"&&(R=new ResizeObserver(()=>C()),R.observe(S)),C(),()=>{S.removeEventListener("scroll",A),R==null||R.disconnect()}},[e,C]);const x=s.useCallback((S,A)=>{if(A<=0)return;const R=u.current.get(S);R!==void 0&&Math.abs(R-A)<1||(u.current.set(S,A),f(T=>T+1))},[]),v=s.useCallback(S=>{const A=e.current;if(!A||S<0||S>=t)return;const R=ei(t,g);A.scrollTop=R[S]??0,C()},[t,g,e,C]),k=s.useMemo(()=>{if(y.endIndex<y.startIndex)return[];const S=[];for(let A=y.startIndex;A<=y.endIndex;A+=1)S.push(A);return S},[y.endIndex,y.startIndex]);return{...y,visibleIndices:k,scrollToIndex:v,notifyRowMeasured:x}}function Ju(){return{firstLineIndentPx:0,leftIndentPx:0,rightIndentPx:0,mixed:!1}}function ml(e){const t=En(e);if(t.length===0)return Ju();let n=null,r=null,o=null,a=!1;for(const l of t){const u=l.style.textIndent,d=l.style.marginLeft,f=l.style.marginRight,g=u?Vn(u,0):0,h=d?Vn(d,0):0,y=f?Vn(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 OD(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 KD(e,t){return ar(e,()=>{let n=Er(e);if(n.length===0){const a=OD(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 l=_e(nc(t.firstLineIndentPx,r));a.style.textIndent!==l&&(a.style.textIndent=l,o=!0)}if(t.leftIndentPx!==void 0)if(t.leftIndentPx<=.5)a.style.marginLeft&&(a.style.removeProperty("margin-left"),o=!0);else{const l=_e(nc(t.leftIndentPx,r));a.style.marginLeft!==l&&(a.style.marginLeft=l,o=!0)}if(t.rightIndentPx!==void 0)if(t.rightIndentPx<=.5)a.style.marginRight&&(a.style.removeProperty("margin-right"),o=!0);else{const l=_e(nc(t.rightIndentPx,r));a.style.marginRight!==l&&(a.style.marginRight=l,o=!0)}xt(a)}return o})}const xb=24,ai=48;function Cb(e,t){const n=Ci(ot(t));return{pageWidthPx:e.offsetWidth,pageHeightPx:e.offsetHeight,marginsPx:{top:Vn(n.top,0),right:Vn(n.right,0),bottom:Vn(n.bottom,0),left:Vn(n.left,0)}}}function $D(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 UD(e,t,n,r,o=!0,a=1){const[l,u]=s.useState({}),[d,f]=s.useState(Ju()),g=s.useCallback(y=>l[y]??null,[l]),h=s.useCallback(()=>{const y=e.current;if(!o||!y)return;const b={};for(const x of n){const v=Ze(y,x);if(!v)continue;const k=t[x]??t[0]??"";b[x]=Cb(v,k)}u(x=>{const v={...x,...b};return $D(x,v)?x:v});const C=Ze(y,r());C&&f(ml(C))},[e,o,r,n,t]);return s.useLayoutEffect(()=>{if(!o)return;const y=requestAnimationFrame(h);return()=>cancelAnimationFrame(y)},[o,r,n,t,a,h]),s.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=Ze(y,C);x&&b.observe(x)}return()=>b.disconnect()},[e,o,n,h]),s.useLayoutEffect(()=>{if(!o)return;const y=()=>{const b=e.current;if(!b)return;const C=Ze(b,r());C&&f(ml(C))};return document.addEventListener("selectionchange",y),()=>document.removeEventListener("selectionchange",y)},[e,o,r]),{pageGeometries:l,geometryForPage:g,indentState:d,refresh:h}}const VD="_rulerRoot_j57vt_5",WD="_horizontalRulerGroup_j57vt_22",GD="_horizontalRulerTrack_j57vt_28",qD="_horizontalRulerShelf_j57vt_42",ZD="_horizontalInner_j57vt_51",YD="_dragEdgeLeft_j57vt_63",XD="_dragEdgeRight_j57vt_73",JD="_dragEdgeActive_j57vt_85",QD="_verticalRuler_j57vt_92",eI="_verticalInner_j57vt_102",tI="_dragEdgeTop_j57vt_114",nI="_dragEdgeBottom_j57vt_124",rI="_dragEdgeActiveV_j57vt_136",oI="_tickH_j57vt_143",iI="_tickV_j57vt_152",aI="_tickLabelH_j57vt_161",lI="_tickLabelV_j57vt_175",sI="_arrowIconWrapper_j57vt_192",cI="_arrowDown_j57vt_203",uI="_arrowGlyph_j57vt_211",dI="_arrowActive_j57vt_220",mI="_arrowUp_j57vt_225",fI="_rulerTooltip_j57vt_249",je={rulerRoot:VD,horizontalRulerGroup:WD,horizontalRulerTrack:GD,horizontalRulerShelf:qD,horizontalInner:ZD,dragEdgeLeft:YD,dragEdgeRight:XD,dragEdgeActive:JD,verticalRuler:QD,verticalInner:eI,dragEdgeTop:tI,dragEdgeBottom:nI,dragEdgeActiveV:rI,tickH:oI,tickV:iI,tickLabelH:aI,tickLabelV:lI,arrowIconWrapper:sI,arrowDown:cI,arrowGlyph:uI,arrowActive:dI,arrowUp:mI,rulerTooltip:fI},pc=({type:e,active:t=!1,className:n="",style:r,title:o,"aria-label":a,onPointerDown:l,"data-testid":u})=>{const d=e==="down"?je.arrowDown:je.arrowUp;return i.jsx("div",{className:`${je.arrowIconWrapper} ${d} ${t?je.arrowActive:""} ${n}`,style:r,title:o,"aria-label":a||o,onPointerDown:l,"data-testid":u,children:i.jsx("div",{className:je.arrowGlyph})})};function wb(){const[e,t]=s.useState(null),[n,r]=s.useState(null),o=s.useCallback((a,l,u)=>{l.preventDefault(),l.stopPropagation(),t(a);const d=Number.isFinite(l.clientX)?l.clientX:0,f=Number.isFinite(l.clientY)?l.clientY:0,g=l.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 pI=({geometry:e,indentState:t,unit:n="in",zoomScale:r=1,onMarginChange:o,onMarginPreview:a,onIndentChange:l})=>{const u=X(),{activeTarget:d,dragPreview:f,startPointerDrag:g}=wb(),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,A=(f==null?void 0:f.rightIndentPx)??t.rightIndentPx,R=Math.max(0,h-x-v),T=!t.mixed,D=s.useMemo(()=>tg(h,x,n),[h,x,n]),P=s.useCallback((N,K)=>{const G=Number.isFinite(K.clientX)?K.clientX:0;g(N.type,K,{updateDragState:(q,ae,Z)=>{const ee=(q-G)/C;let le=0;const me={target:N.type,marginLeft:y,marginRight:b,firstLineIndentPx:t.firstLineIndentPx,leftIndentPx:t.leftIndentPx,rightIndentPx:t.rightIndentPx,measurementPx:0,clientX:q,clientY:ae};if(N.type==="margin-left"){const ne=Math.max(0,Math.min(h-b-ai,N.startMarginPx+ee)),M=vr(ne,n,Z,0);me.marginLeft=M,le=M}else if(N.type==="margin-right"){const ne=Math.max(0,Math.min(h-y-ai,N.startMarginPx-ee)),M=vr(ne,n,Z,0);me.marginRight=M,le=M}else if(N.type==="first-line-indent"){const ne=-N.startLeftIndentPx,M=h-y-b-N.startLeftIndentPx-ai,re=Math.max(ne,Math.min(M,N.startFirstLinePx+ee)),O=vr(re,n,Z,0);me.firstLineIndentPx=O,le=O}else if(N.type==="left-indent"){const ne=Math.max(0,N.startLeftIndentPx+ee),M=vr(ne,n,Z,0);me.leftIndentPx=M,me.firstLineIndentPx=N.startFirstLinePx,le=M}else if(N.type==="right-indent"){const ne=Math.max(0,N.startRightIndentPx-ee),M=vr(ne,n,Z,0);me.rightIndentPx=M,le=M}return me.measurementPx=le,me},onPreview:q=>{N.type==="margin-left"?a==null||a({left:q.marginLeft}):N.type==="margin-right"&&(a==null||a({right:q.marginRight}))},onCommit:q=>{N.type==="margin-left"?o==null||o({left:q.marginLeft}):N.type==="margin-right"?o==null||o({right:q.marginRight}):N.type==="first-line-indent"?l==null||l({firstLineIndentPx:q.firstLineIndentPx}):N.type==="left-indent"?l==null||l({leftIndentPx:q.leftIndentPx}):N.type==="right-indent"&&(l==null||l({rightIndentPx:q.rightIndentPx}))}})},[y,b,h,n,C,t,o,a,l,g]),j=x+S,L=j+k,V=h-v-A,E=h*C;return i.jsxs("div",{className:`${je.rulerRoot} ${je.horizontalRulerGroup}`,style:{width:`${E}px`},"data-testid":"horizontal-ruler",children:[i.jsxs("div",{className:je.horizontalRulerTrack,children:[i.jsxs("div",{className:je.horizontalInner,style:{left:`${x*C}px`,width:`${R*C}px`},"data-testid":"ruler-printable-area",children:[i.jsx("div",{className:`${je.dragEdgeLeft} ${d==="margin-left"?je.dragEdgeActive:""}`,title:u("rulerMarginLeft"),"aria-label":u("rulerMarginLeft"),"data-testid":"ruler-margin-splitter-left",onPointerDown:N=>P({type:"margin-left",startMarginPx:y},N)}),i.jsx("div",{className:`${je.dragEdgeRight} ${d==="margin-right"?je.dragEdgeActive:""}`,title:u("rulerMarginRight"),"aria-label":u("rulerMarginRight"),"data-testid":"ruler-margin-splitter-right",onPointerDown:N=>P({type:"margin-right",startMarginPx:b},N)})]}),D.map((N,K)=>i.jsxs(s.Fragment,{children:[i.jsx("div",{className:je.tickH,style:{left:`${N.positionPx*C}px`,height:`${N.height}px`}}),N.label?i.jsx("span",{className:je.tickLabelH,style:{left:`${N.positionPx*C}px`},children:N.label}):null]},K)),T?i.jsxs(i.Fragment,{children:[i.jsx(pc,{type:"down",style:{left:`${L*C}px`},active:d==="first-line-indent",title:u("rulerFirstLineIndent"),"aria-label":u("rulerFirstLineIndent"),"data-testid":"ruler-first-line-indent",onPointerDown:N=>P({type:"first-line-indent",startFirstLinePx:t.firstLineIndentPx,startLeftIndentPx:t.leftIndentPx},N)}),i.jsx(pc,{type:"up",style:{left:`${j*C}px`},active:d==="left-indent",title:u("rulerLeftIndent"),"aria-label":u("rulerLeftIndent"),"data-testid":"ruler-left-indent",onPointerDown:N=>P({type:"left-indent",startLeftIndentPx:t.leftIndentPx,startFirstLinePx:t.firstLineIndentPx},N)}),i.jsx(pc,{type:"up",style:{left:`${V*C}px`},active:d==="right-indent",title:u("rulerRightIndent"),"aria-label":u("rulerRightIndent"),"data-testid":"ruler-right-indent",onPointerDown:N=>P({type:"right-indent",startRightIndentPx:t.rightIndentPx},N)})]}):null]}),i.jsx("div",{className:je.horizontalRulerShelf,"aria-hidden":!0}),f?i.jsx("div",{className:je.rulerTooltip,style:{left:f.clientX,top:f.clientY},"data-testid":"ruler-drag-tooltip",children:eg(f.measurementPx,n)}):null]})},gI=({geometry:e,unit:t="in",zoomScale:n=1,onMarginChange:r,onMarginPreview:o})=>{const a=X(),{activeTarget:l,dragPreview:u,startPointerDrag:d}=wb(),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=s.useMemo(()=>tg(f,b,t),[f,b,t]),k=s.useCallback((S,A)=>{const R=Number.isFinite(A.clientY)?A.clientY:0;d(S.type,A,{updateDragState:(T,D,P)=>{const j=(D-R)/y,L={target:S.type,marginTop:g,marginBottom:h,measurementPx:0,clientX:T,clientY:D};if(S.type==="margin-top"){const V=Math.max(0,Math.min(f-h-ai,S.startMarginPx+j)),E=vr(V,t,P,0);L.marginTop=E,L.measurementPx=E}else if(S.type==="margin-bottom"){const V=Math.max(0,Math.min(f-g-ai,S.startMarginPx-j)),E=vr(V,t,P,0);L.marginBottom=E,L.measurementPx=E}return L},onPreview:T=>{S.type==="margin-top"?o==null||o({top:T.marginTop}):S.type==="margin-bottom"&&(o==null||o({bottom:T.marginBottom}))},onCommit:T=>{S.type==="margin-top"?r==null||r({top:T.marginTop}):S.type==="margin-bottom"&&(r==null||r({bottom:T.marginBottom}))}})},[g,h,f,t,y,r,o,d]);return i.jsxs("div",{className:`${je.rulerRoot} ${je.verticalRuler}`,style:{height:`${f}px`},"data-testid":"vertical-ruler",children:[i.jsxs("div",{className:je.verticalInner,style:{top:`${b}px`,height:`${x}px`},"data-testid":"ruler-printable-area-vertical",children:[i.jsx("div",{className:`${je.dragEdgeTop} ${l==="margin-top"?je.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:`${je.dragEdgeBottom} ${l==="margin-bottom"?je.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,A)=>i.jsxs(s.Fragment,{children:[i.jsx("div",{className:je.tickV,style:{top:`${S.positionPx}px`,width:`${S.height}px`}}),S.label?i.jsx("span",{className:je.tickLabelV,style:{top:`${S.positionPx}px`},children:S.label}):null]},A)),u?i.jsx("div",{className:je.rulerTooltip,style:{left:u.clientX,top:u.clientY},"data-testid":"ruler-drag-tooltip",children:eg(u.measurementPx,t)}):null]})},hI="_root_1wqbe_1",bI="_fullscreen_1wqbe_36",yI="_exitFullscreen_1wqbe_48",xI="_exitFullscreenIcon_1wqbe_79",CI="_menuChrome_1wqbe_94",wI="_body_1wqbe_106",vI="_iconChrome_1wqbe_136",kI="_workspace_1wqbe_181",SI="_workspacePageSized_1wqbe_193",PI="_workspaceWithRuler_1wqbe_197",AI="_pageCanvasViewport_1wqbe_201",TI="_multiPageRulerLayer_1wqbe_211",RI="_multiPageContainer_1wqbe_234",DI="_pageZoomContent_1wqbe_244",II="_htmlFileDropOverlay_1wqbe_262",jI="_surface_1wqbe_276",EI="_visual_1wqbe_283",MI="_pageBlock_1wqbe_341",_I="_pageBlockFluid_1wqbe_348",NI="_pageSurfaceRulerGutter_1wqbe_357",LI="_pageSurface_1wqbe_357",BI="_htmlModeShell_1wqbe_378",FI="_html_1wqbe_262",ke={root:hI,fullscreen:bI,exitFullscreen:yI,exitFullscreenIcon:xI,menuChrome:CI,body:wI,iconChrome:vI,workspace:kI,workspacePageSized:SI,workspaceWithRuler:PI,pageCanvasViewport:AI,multiPageRulerLayer:TI,multiPageContainer:RI,pageZoomContent:DI,htmlFileDropOverlay:II,surface:jI,visual:EI,pageBlock:MI,pageBlockFluid:_I,pageSurfaceRulerGutter:NI,pageSurface:LI,htmlModeShell:BI,html:FI};function vb(e){if(e!==1)return{zoom:e,"--page-zoom":String(e)}}function kb({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,onIndentChange:u}){if(!e)return null;const d=xb;return i.jsx("div",{className:ke.multiPageRulerLayer,children:i.jsxs("div",{className:ke.pageBlock,children:[i.jsx("div",{className:ke.pageSurfaceRulerGutter,style:{width:`${d}px`,flex:`0 0 ${d}px`},"aria-hidden":!0}),i.jsx(pI,{geometry:t,indentState:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,onIndentChange:u})]})})}function Sb({showVerticalRuler:e=!1,pageSized:t=!1,geometry:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,children:u,pageBlockStyle:d,pageBlockRef:f}){const g=o>0?o:1,h=e?xb/g:0;return i.jsxs("div",{ref:f,className:`${ke.pageBlock} ${t?"":ke.pageBlockFluid}`,style:d,children:[i.jsx("div",{className:ke.pageSurfaceRulerGutter,style:{width:`${h}px`,flex:`0 0 ${h}px`},children:e?i.jsx(gI,{geometry:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l}):null}),u]})}function HI({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,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(kb,{showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,onIndentChange:u}),i.jsx("div",{className:ke.pageZoomContent,style:vb(o),children:i.jsx(Sb,{showVerticalRuler:e,pageSized:e,geometry:t,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:l,children:d})})]})}const zI=s.memo(function({index:t,pageHtml:n,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:l,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:A,onContextMenu:R,onRulerRefresh:T}){const D=s.useRef(null),P=s.useRef(null),j=s.useRef(""),L=s.useRef(!1),V=s.useRef(C);V.current=C;const E=s.useRef(v);E.current=v,s.useLayoutEffect(()=>{const K=P.current;if(!K||!E.current)return;const G=()=>{var ae;return(ae=E.current)==null?void 0:ae.call(E,t,K.offsetHeight)};if(G(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(G);return q.observe(K),()=>q.disconnect()},[t,n,o,r]);const N=s.useCallback(K=>{D.current=K,K&&(j.current=K.innerHTML)},[]);return s.useLayoutEffect(()=>()=>{x!=null&&x.current||!L.current||!V.current||V.current(t,j.current)},[t,x]),i.jsx(Sb,{pageBlockRef:P,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:l,zoomScale:u,pageBlockStyle:{marginTop:t>0?"1.5rem":"0"},onMarginChange:K=>{k==null||k(t,K)},onMarginPreview:K=>{S==null||S(t,K)},children:i.jsx("div",{ref:N,className:`${ke.surface} ${ke.visual} ${o?ke.pageSurface:""}`,[Dr]:"","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:K=>{const G=K.currentTarget;pi(G),fo(G),h(t)},onPointerDown:K=>y(t,K),onMouseUp:A,onContextMenu:R,onInput:K=>{const G=K.currentTarget;L.current=!0,j.current=G.innerHTML;const{absorbedBlocks:q}=pi(G);if(j.current=G.innerHTML,b(t,G.innerHTML),q.length>0){const ae=q.length;requestAnimationFrame(()=>bg(G,ae))}T()}})})},OI);function OI(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 KI=s.forwardRef(function({pages:t,activePageIndex:n,hasSelectedPage:r=!1,scrollRootRef:o,onActivePageIndexChange:a,onPageSelected:l,onPageChange:u,onPageFlush:d,suppressPageFlushRef:f,pendingInsertPageFocusRef:g,placeholder:h,disabled:y,rulerVisible:b=!0,rulerUnit:C="in",zoomScale:x=1,onMarginChange:v,onMarginPreview:k,onIndentChange:S,onBeforeInput:A,resolveEmbeddedImageDataUrl:R,hydrateEmbeddedImages:T,onPointerDown:D,onMouseUp:P,onContextMenu:j},L){const V=X(),E=s.useRef(null),N=s.useRef(n);N.current=n;const K=s.useRef(A);K.current=A;const G=s.useRef(u);G.current=u;const q=s.useRef(d);q.current=d;const ae=s.useRef(l);ae.current=l;const Z=s.useRef(D);Z.current=D;const ee=s.useRef(v);ee.current=v;const le=s.useRef(k);le.current=k;const me=s.useRef(null),ne=s.useRef([]),M=s.useRef(FD()),re=f,O=s.useCallback(()=>N.current,[]),ie=s.useCallback(H=>M.current.get(H,t[H]??""),[t]),{visibleIndices:Ee,topSpacerHeight:He,bottomSpacerHeight:$e,scrollToIndex:Ve,notifyRowMeasured:St}=zD({scrollElementRef:o??E,pageCount:t.length,getRowHeight:ie,activePageIndex:n,pinActivePage:r}),{geometryForPage:et,indentState:en,refresh:Q}=UD(E,t,Ee,O,!0,x),fe=r?n:0,pe=t[fe]??"",Ce=s.useCallback(H=>hi(t[H]??""),[t]),Pt=b&&hi(pe),Vt=s.useCallback(H=>{Ve(H),requestAnimationFrame(()=>{const J=E.current;if(!J)return;const ue=Ze(J,H);ue&&fo(ue)})},[Ve]),Mn=s.useCallback(H=>{if(H<0||H>=t.length)return;const J=(o==null?void 0:o.current)??E.current;if(!J)return;const ue=ei(t.length,ie),Ne=J.scrollTop,At=Ne+J.clientHeight,Cn=bb(Ne,ue,t.length),tt=yb(At,ue,t.length);H>=Cn&&H<=tt||Ve(H)},[ie,t.length,o,Ve]),Wt=s.useCallback(H=>{Mn(H),requestAnimationFrame(()=>{const J=E.current;if(!J)return;const ue=Ze(J,H);ue&&Tw(ue)})},[Mn]),De=s.useRef(Mn);De.current=Mn,s.useLayoutEffect(()=>{De.current(n)},[n,t.length]),s.useLayoutEffect(()=>{const H=g;if(!H)return;const J=H.current;J!=null&&(H.current=null,Wt(J))},[n,t.length,g,Wt]);const yn=s.useCallback(H=>{var Ne;if(N.current=H,H!==n&&a(H),(Ne=ae.current)==null||Ne.call(ae,H),!Ee.includes(H)){Vt(H);return}Q();const J=E.current;if(!J)return;const ue=Ze(J,H);ue&&requestAnimationFrame(()=>fo(ue))},[n,a,Q,Vt,Ee]);s.useImperativeHandle(L,()=>({getContainer:()=>E.current,getActivePageRoot:()=>{const H=E.current;return H?Ze(H,N.current):null},getActivePageIndex:()=>N.current,flushPageHtml:H=>{var ue;const J=E.current;return J?((ue=Ze(J,H))==null?void 0:ue.innerHTML)??null:null},ensurePageMounted:H=>{Vt(H)},focusPageAt:Wt,activatePageAt:yn}));const xn=s.useCallback((H,J,ue,Ne)=>{const At=Xt(ye(ue).body),Cn=J===document.activeElement;(Ne!=null&&Ne.forceBodySync||!Cn)&&sl(J,At,{resolveDataUrl:R,hydrateEmbeddedImages:T}),ju(J),pi(J);const tt=Pl(J);Sl(J),wo(J,ue);const Ke=ut(J);if(Ke&&fg(J,Ke),tt){const Ae=Xt(ye(ue).body);J.innerHTML!==Ae&&bw(Ae,J)&&G.current(H,J.innerHTML)}},[T,R]);s.useLayoutEffect(()=>{M.current.clear()},[t.length]),s.useLayoutEffect(()=>{const H=E.current;if(!H)return;const J=me.current,ue=J===null||J.length!==t.length;ue&&De.current(n);const Ne=new Set(ne.current),At=new Set(Ee);ue&&At.add(n);for(const tt of At){const Ke=!Ne.has(tt),Ae=t[tt]!==(J==null?void 0:J[tt]);if(!ue&&!Ke&&!Ae)continue;const We=Ze(H,tt);We&&xn(tt,We,t[tt]??"",{forceBodySync:ue})}me.current=t,ne.current=Ee,ue&&(re!=null&&re.current)&&(re.current=!1);const Cn=requestAnimationFrame(Q);return()=>cancelAnimationFrame(Cn)},[n,t,re,xn,Q,Ee]),s.useLayoutEffect(()=>{const H=E.current;if(!H)return;const J=ue=>{var Ne;(Ne=K.current)==null||Ne.call(K,ue)};return H.addEventListener("beforeinput",J),()=>H.removeEventListener("beforeinput",J)},[]);const _r=s.useCallback((H,J)=>{var ue;yn(H),(ue=Z.current)==null||ue.call(Z,J)},[yn]),Nr=s.useCallback((H,J)=>{G.current(H,J)},[]),Lr=s.useCallback((H,J)=>{var ue;(ue=q.current)==null||ue.call(q,H,J)},[]),ve=s.useCallback((H,J)=>{const ue=hb(t[H]??"",H),Ne=Math.max(J,ue);M.current.set(H,Ne),St(H,Ne)},[St,t]),tn=s.useCallback((H,J)=>{var ue;(ue=ee.current)==null||ue.call(ee,H,J)},[]),Br=s.useCallback((H,J)=>{var ue;(ue=le.current)==null||ue.call(le,H,J)},[]),lr=V("visualEditorAria"),sr=s.useMemo(()=>Ee.map(H=>i.jsx(zI,{index:H,pageHtml:t[H]??"",showVerticalRuler:Pt&&Ce(H),pageSized:Ce(H),geometry:et(H),rulerUnit:C,zoomScale:x,placeholder:h,disabled:y,visualEditorAria:lr,onActivate:yn,onPointerDown:_r,onPageChange:Nr,onPageFlush:Lr,suppressPageFlushRef:re,onMeasured:ve,onMarginChange:tn,onMarginPreview:Br,onMouseUp:P,onContextMenu:j,onRulerRefresh:Q},H)),[yn,y,et,tn,Br,Nr,Lr,_r,ve,j,P,Ce,t,h,Q,C,Pt,Ee,lr,x]);return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:Pt?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(kb,{showRulers:Pt,geometry:et(fe),indentState:en,rulerUnit:C,zoomScale:x,onMarginChange:H=>{v==null||v(fe,H)},onMarginPreview:H=>{k==null||k(fe,H)},onIndentChange:H=>{S==null||S(H)}}),i.jsx("div",{className:ke.pageZoomContent,style:vb(x),children:i.jsxs("div",{ref:E,className:ke.multiPageContainer,style:{display:"flex",flexDirection:"column",alignItems:Pt?"center":"stretch",width:"100%",minHeight:Pt?void 0:"100%",position:"relative"},children:[He>0?i.jsx("div",{"aria-hidden":!0,style:{height:He,flexShrink:0}}):null,sr,$e>0?i.jsx("div",{"aria-hidden":!0,style:{height:$e,flexShrink:0}}):null]})})]})});function $I(e,t,n){return r=>{const o=e();o&&n(o,t(),r)}}function UI(e,t,n,r){return o=>{const a=e();if(!a)return;const l=n(a,t(),o);r(l.pageHtml)}}function VI(e,t,n){return(r,o)=>{const a=e(r);a&&n(a,t(r),o)}}function WI(e,t,n,r){return(o,a)=>{const l=e(o);if(!l)return;const u=n(l,t(o),a);r(o,u.pageHtml)}}function Yf(e,t,n){return r=>{const o=e();o&&KD(o,{...r,unit:t})&&n(o)}}const GI="_field_1knrr_1",qI="_label_1knrr_8",ZI="_button_1knrr_12",YI="_swatch_1knrr_37",XI="_swatchEmpty_1knrr_44",qo={field:GI,label:qI,button:ZI,swatch:YI,swatchEmpty:XI};function Ut({label:e,noneLabel:t,value:n,mixed:r=!1,disabled:o,fallbackCustom:a,onChange:l}){const u=s.useId(),d=s.useRef(null),f=s.useRef(null),g=s.useRef(null),[h,y]=s.useState(!1),b=vo(h,f,g);s.useEffect(()=>{if(!h)return;const v=S=>{var R,T;const A=S.target;(R=d.current)!=null&&R.contains(A)||(T=g.current)!=null&&T.contains(A)||y(!1)},k=S=>{var A;S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),y(!1),(A=f.current)==null||A.focus())};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0)}},[h]);const C=`${qo.swatch}${!n||r?` ${qo.swatchEmpty}`:""}`,x=n&&!r?{backgroundColor:n}:void 0;return i.jsxs("div",{className:qo.field,ref:d,children:[i.jsx("span",{className:qo.label,children:e}),i.jsx("button",{ref:f,type:"button",className:qo.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(Pe,{children:i.jsx("div",{ref:g,id:u,className:wr.popover,style:{top:b.top,left:b.left,zIndex:1400},children:i.jsx(Xu,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:o,fallbackCustom:a,onChange:l,onCommit:()=>y(!1)})})}):null]})}const gc=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],JI={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Qu({tab:e,value:t,fonts:n,disabled:r,onTabChange:o,onChange:a}){const l=X(),u=s.useId(),d=s.useId(),f=n??Cp(),g=gc.find(h=>h.id===e)??gc[0];return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":l("fontDialogTitle"),children:gc.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:l(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:l("fontDialogFamily")}),i.jsx(ab,{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:l("fontDialogSize")}),i.jsx("div",{className:p.sizeRow,children:i.jsx(lb,{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(Ut,{label:l("commandFontColor"),noneLabel:l("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(Ut,{label:l("commandHighlightColor"),noneLabel:l("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:l("fontDialogStyle")}),$t.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]}})}}),l(JI[h].label)]},h))]})]}):null})]})}function QI({open:e,tab:t,size:n,unit:r,marks:o,fontFamily:a=null,fontFamilyMixed:l=!1,fontColor:u,fontColorMixed:d=!1,highlightColor:f,highlightColorMixed:g=!1,fonts:h,disabled:y,onTabChange:b,onApply:C,onClose:x}){const v=X(),k=s.useId(),S=s.useRef(null),[A,R]=s.useState({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:l,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g});return s.useEffect(()=>{e&&R({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:l,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g})},[e,n,r,o,a,l,u,d,f,g]),Ye(S,{open:e,onClose:x}),e?i.jsx(Pe,{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:T=>T.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:k,children:v("fontDialogTitle")}),i.jsx(Qu,{tab:t,value:A,fonts:h,disabled:y,onTabChange:b,onChange:R}),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(A),children:v("fontDialogOk")})]})]})})}):null}const ej={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Je({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:o,inputId:a,onChange:l}){const u=X(),d=s.useId(),f=a??d,g=(t==null?void 0:t.unit)??hu,[h,y]=s.useState(()=>t?be(t.value):""),[b,C]=s.useState(!1);s.useEffect(()=>{b||y(t?be(t.value):"")},[t,b]);const x=v=>{const k=v.trim();if(!k){l(null),y("");return}const S=si(k,g,r);if(!S){y(t?be(t.value):"");return}l(S),y(be(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){l({value:t.value,unit:k});return}if(h.trim()){const S=si(h,k,r);l(S)}},children:fu.map(v=>i.jsx("option",{value:v,children:u(ej[v])},v))})]})]})}function ed({shadow:e,disabled:t,onChange:n}){const r=X();return i.jsxs("div",{className:p.shadowGrid,children:[i.jsx(Je,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetX:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetY:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:o=>{n({...e,blur:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:o=>{n({...e,spread:o??{value:0,unit:"px"}})}}),i.jsx(Ut,{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 Pb=[{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}],Ab=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],tj={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},nj={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"};function Tb({legendKey:e="imagePropertiesTabAdvanced",value:t,disabled:n,onChange:r}){const o=X(),a=s.useId(),l=s.useId();return i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:o(e)}),i.jsx(rj,{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")}),Mu.map(u=>i.jsx("option",{value:u,children:o(tj[u])},u))]})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:l,children:o("imagePropertiesPosition")}),i.jsxs("select",{id:l,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")}),_u.map(u=>i.jsx("option",{value:u,children:o(nj[u])},u))]})]})]})}function rj({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),a=e===null?null:Wa(e),[l,u]=s.useState(()=>a===null?"":be(a)),[d,f]=s.useState(!1);s.useEffect(()=>{d||u(a===null?"":be(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?"":be(a));return}const C=$p(b);n(C),u(be(Wa(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:l,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(l)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}const oj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function fl({label:e,inputAria:t,value:n,disabled:r,onChange:o}){const a=X(),l=s.useId(),u=s.useId(),d=s.useRef(null),f=s.useRef(null),g=s.useRef(null),h=(n==null?void 0:n.unit)??r1,[y,b]=s.useState(()=>n?be(n.value):""),[C,x]=s.useState(!1),[v,k]=s.useState(!1),S=vo(v,f,g,{matchAnchorWidth:!0,minWidth:72});s.useEffect(()=>{C||b(n?be(n.value):"")},[n,C]),s.useEffect(()=>{if(!v)return;const P=L=>{var E,N;const V=L.target;(E=d.current)!=null&&E.contains(V)||(N=g.current)!=null&&N.contains(V)||k(!1)},j=L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),k(!1))};return document.addEventListener("pointerdown",P),document.addEventListener("keydown",j,!0),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",j,!0)}},[v]);const A=P=>{const j=P.trim();if(!j){o(null),b("");return}const L=tf(j,h);if(!L){b(n?be(n.value):"");return}o(L),b(be(L.value))},R=o1[h],T=(n==null?void 0:n.value)??null,D=v?i.jsx(Pe,{children:i.jsx("ul",{ref:g,className:qe.list,role:"listbox",id:l,style:{top:S.top,left:S.left,minWidth:S.width},children:R.map(P=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:qe.option,role:"option","aria-selected":T===P,onMouseDown:j=>j.preventDefault(),onClick:()=>{o({value:P,unit:h}),b(be(P)),k(!1)},children:be(P)})},P))})}):null;return i.jsxs("div",{className:p.lengthField,children:[i.jsx("label",{className:p.sideLabel,htmlFor:u,children:e}),i.jsxs("div",{className:`${qe.wrap} ${p.lengthRow}`,ref:d,children:[i.jsxs("div",{className:qe.field,ref:f,children:[i.jsx("input",{id:u,className:qe.input,value:y,disabled:r,"aria-label":t,"aria-autocomplete":"list","aria-expanded":v,"aria-controls":l,role:"combobox",inputMode:"decimal",onFocus:()=>x(!0),onBlur:()=>{x(!1),A(y)},onChange:P=>b(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),A(y),k(!1),P.currentTarget.blur()),P.key==="ArrowDown"&&(P.preventDefault(),k(!0))}}),i.jsx("button",{type:"button",className:qe.toggle,tabIndex:-1,disabled:r,"aria-label":t,"aria-expanded":v,"aria-controls":l,onMouseDown:P=>P.preventDefault(),onClick:()=>k(P=>!P)})]}),i.jsxs("div",{className:qe.field,children:[i.jsx("select",{className:qe.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:P=>{const j=P.target.value;if(n){o({value:n.value,unit:j});return}y.trim()&&o(tf(y,j))},children:kg.map(P=>i.jsx("option",{value:P,children:a(oj[P])},P))}),i.jsx("span",{className:qe.chevron,"aria-hidden":"true"})]}),D]})]})}const ij={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},aj={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function lj(e,t,n){return t&&n?"custom":e.startsWith("data:")?"file":e.trim()?"url":"file"}function Rb({src:e,disabled:t,customImagePicker:n,disableBuiltinSources:r=!1,onSrcChange:o,onCustomPick:a,onSourceChange:l}){const u=X(),d=s.useId(),f=s.useId(),g=s.useRef(null),h=r&&!!n,[y,b]=s.useState(()=>lj(e,r,n)),[C,x]=s.useState(()=>e.startsWith("data:")?"":e),[v,k]=s.useState(""),[S,A]=s.useState(null),[R,T]=s.useState(!1);s.useEffect(()=>{l==null||l(y)},[l,y]),s.useEffect(()=>{h&&b("custom")},[h]);const D=y==="file"&&e.startsWith("data:")?e:y==="url"?C:"",P=y==="custom"?null:pn(D),j=y==="custom"?null:y==="file"&&S?aj[S]:P&&(y==="file"||C.trim().length>0)?ij[P]:null,L=()=>{t||!n||a==null||a()},V=E=>{var K;const N=(K=E.target.files)==null?void 0:K[0];N&&(T(!0),A(null),qw(N).then(G=>{k(N.name),b("file"),o(G),T(!1)},G=>{const q=G instanceof Error?G.message:"";k(""),b("file"),A(q==="tooLarge"||q==="type"?q:"type"),T(!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:Kw,hidden:!0,disabled:t,"aria-label":u("imageDialogChooseFile"),onChange:V}),i.jsx("button",{type:"button",className:p.action,disabled:t||R,onClick:()=>{var E;return(E=g.current)==null?void 0:E.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":j!==null,"aria-describedby":j?f:void 0,onChange:E=>{const N=E.target.value;x(N),o(N.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:L,children:n.buttonCaption})]}):null,j?i.jsx("p",{id:f,className:p.error,children:u(j)}):null]})}function sj(e){return pn(e.trim())===null}function cj(e){return Dg(e)?{width:null,height:null}:e==="fill"?{width:{...lo},height:{...lo}}:{width:{...lo},height:null}}function uj({value:e,disabled:t,customImagePicker:n,disableBuiltinSources:r,onCustomImagePick:o,onChange:a}){const l=X(),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:l("pageBackgroundImagePreview")}),i.jsx("img",{className:p.previewImage,src:u,alt:l("pageBackgroundImagePreviewAlt")}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:()=>{a({...e,src:null})},children:l("pageBackgroundImageClear")})]}):null,i.jsx(Rb,{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(fl,{label:l("imagePropertiesWidth"),inputAria:l("imagePropertiesWidthAria"),value:e.width,disabled:t,onChange:f=>d("width",f)}),i.jsx(fl,{label:l("imagePropertiesHeight"),inputAria:l("imagePropertiesHeightAria"),value:e.height,disabled:t,onChange:f=>d("height",f)}),i.jsx(Tb,{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}:cj(f.fit);a({...e,opacity:f.opacity,fit:f.fit,position:f.position,...g})}})]}):null]})}const dj={left:gl,center:pl,right:hl,justify:op},mj={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},fj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},pj={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},gj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},hj={value:1,unit:"pt"},bj={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1},yj={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid"},Xf={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid",page:"paragraphDialogBreakPage"};function Zo(e){return{top:e,right:e,bottom:e,left:e}}function Jf(e){for(const t of at)if(e[t])return e[t];return null}function xj(){const e=[...Pb];for(const t of Ab)e.some(n=>n.id===t.id)||e.push(t);return e}function td({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:o="paragraphDialogTitle",backgroundImage:a,customImagePicker:l,disableBuiltinBackgroundImageSources:u,onCustomImagePick:d,onBackgroundImageChange:f,onTabChange:g,onChange:h}){const y=X(),b=r?xj().filter(P=>r.includes(P.id)):Pb,C=s.useId(),x=s.useId(),v=s.useId(),k=s.useId(),[S,A]=s.useState(()=>In(t.margin,Zo(t.margin.top))),[R,T]=s.useState(()=>In(t.padding,Zo(t.padding.top))),D=(P,j,L,V)=>{const E=t[P],N=j?Zo(V):{...E,[L]:V};h({...t,[P]:N,[`${P}Mixed`]:!1})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":y(o),children:b.map(P=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":P.id===e,disabled:!P.implemented,onClick:()=>g(P.id),children:y(P.labelKey)},P.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:xh.map(P=>{const j=dj[P],L=!t.alignMixed&&t.align===P;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":L,"aria-label":y(mj[P].aria),disabled:n,onClick:()=>{h({...t,align:P,alignMixed:!1})},children:i.jsx(j,{})},P)})})]}),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 P=!t.listMixed&&t.list==="ul"?null:"ul";h({...t,list:P,listMixed:!1})},children:i.jsx(ip,{})}),i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":y("commandNumberedListAria"),disabled:n,onClick:()=>{const P=!t.listMixed&&t.list==="ol"?null:"ol";h({...t,list:P,listMixed:!1})},children:i.jsx(cp,{})})]})]})]}):null,e==="spacing"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogSpacing")}),i.jsx(Qf,{legend:y("paragraphDialogMargin"),sides:t.margin,linked:S,disabled:n,allowNegative:!0,onLinkedChange:P=>{A(P),P&&h({...t,margin:Zo(Jf(t.margin)),marginMixed:!1})},onSideChange:(P,j)=>D("margin",S,P,j)}),i.jsx(Qf,{legend:y("paragraphDialogPadding"),sides:t.padding,linked:R,disabled:n,onLinkedChange:P=>{T(P),P&&h({...t,padding:Zo(Jf(t.padding)),paddingMixed:!1})},onSideChange:(P,j)=>D("padding",R,P,j)}),i.jsx(wj,{value:t.lineHeight,disabled:n,onChange:P=>{h({...t,lineHeight:P,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:P=>{h({...t,breakInside:P.target.value,breakInsideMixed:!1})},children:Np.map(P=>i.jsx("option",{value:P,children:y(yj[P])},P))})]}),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:P=>{h({...t,breakAfter:P.target.value,breakAfterMixed:!1})},children:Rc.map(P=>i.jsx("option",{value:P,children:y(Xf[P])},P))})]}),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:P=>{h({...t,breakBefore:P.target.value,breakBeforeMixed:!1})},children:Rc.map(P=>i.jsx("option",{value:P,children:y(Xf[P])},P))})]})]})]}):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:P=>{const j=P.target.value;h({...t,border:{style:j,width:j==="none"?null:t.border.width??hj,color:j==="none"?null:t.border.color},borderMixed:!1})},children:Cl.map(P=>i.jsx("option",{value:P,children:y(pj[P])},P))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:y("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:P=>{h({...t,border:{...t.border,width:P},borderMixed:!1})}}),i.jsx(Ut,{label:y("paragraphDialogBorderColor"),noneLabel:y("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:P=>{h({...t,border:{...t.border,color:P},borderMixed:!1})}})]}):null,i.jsx(Je,{label:y("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:P=>{h({...t,borderRadius:P,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:bj,shadowMixed:!1})}}),y("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(ed,{shadow:t.boxShadow,disabled:n,onChange:P=>{h({...t,boxShadow:P,shadowMixed:!1})}}):null]}):null,e==="background"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogTabBackground")}),i.jsx(Ut,{label:y("paragraphDialogBackgroundColor"),noneLabel:y("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:P=>{h({...t,backgroundColor:P,backgroundMixed:!1})}}),i.jsx(Cj,{value:t.opacity,disabled:n,onChange:P=>{h({...t,opacity:P,opacityMixed:!1})}})]}):null,e==="backgroundImage"&&a&&f?i.jsx(uj,{value:a,disabled:n,customImagePicker:l,disableBuiltinSources:u,onCustomImagePick:d,onChange:f}):null]})]})}function Cj({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),a=e===null?null:Wa(e),[l,u]=s.useState(()=>a===null?"":be(a)),[d,f]=s.useState(!1);s.useEffect(()=>{d||u(a===null?"":be(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?"":be(a));return}const C=$p(b);n(C),u(be(Wa(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:l,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(l)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}function Qf({legend:e,sides:t,linked:n,disabled:r,allowNegative:o=!1,onLinkedChange:a,onSideChange:l}){const u=X(),d=n?["top"]:at;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(Je,{label:n?e:u(fj[f]),value:t[f],disabled:r,allowNegative:o,onChange:g=>l(f,g)},f))})]})}function wj({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),a=vj(e),l=(e==null?void 0:e.kind)==="number"||(e==null?void 0:e.kind)==="length"?e.value:null,[u,d]=s.useState(()=>l===null?"":be(l)),f=(e==null?void 0:e.kind)==="length"?e.unit:hu;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(l===null?"":be(l));return}n({kind:"number",value:y}),d(be(y));return}const h=si(g,f,!1);if(!h){d(l===null?"":be(l));return}n({kind:"length",value:h.value,unit:h.unit}),d(be(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(be(v));return}const y=h,b=si(u||"1",y,!1),C=(b==null?void 0:b.value)??1;n({kind:"length",value:C,unit:y}),d(be(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(gj[g])},g))]})]})]})}function vj(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}function kj({open:e,tab:t,value:n,backgroundImage:r,disabled:o,customImagePicker:a,disableBuiltinBackgroundImageSources:l,onCustomImagePick:u,onTabChange:d,onApply:f,onClose:g}){const h=X(),y=s.useId(),b=s.useRef(null),[C,x]=s.useState(n),[v,k]=s.useState(r);return s.useEffect(()=>{e&&(x(n),k(r??mn()))},[e,n,r]),Ye(b,{open:e,onClose:g,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),e?i.jsx(Pe,{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(td,{tab:t,value:C,disabled:o,backgroundImage:v,customImagePicker:a,disableBuiltinBackgroundImageSources:l,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 Sj=["auto","A4","letter","legal","custom"],Pj={auto:"pageAtRuleSizeAuto",A4:"pageAtRuleSizeA4",letter:"pageAtRuleSizeLetter",legal:"pageAtRuleSizeLegal",custom:"pageAtRuleSizeCustom"},Aj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"};function ep(e){return e===null?"":be(e.value)}function Tj({value:e,disabled:t,onChange:n,onReset:r}){const o=X(),a=s.useId(),[l,u]=s.useState(!0),d=e??Wn(),f=(g,h)=>{if(l){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:Sj.map(g=>i.jsx("option",{value:g,children:o(Pj[g])},g))})]}),d.sizePreset==="custom"?i.jsxs("div",{className:p.sideGrid,children:[i.jsx(hc,{label:o("pageAtRuleWidth"),value:d.customWidth,disabled:t,onChange:g=>n({...d,customWidth:g})}),i.jsx(hc,{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:l,disabled:t,onChange:()=>u(!l)}),o("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(l?["top"]:at).map(g=>i.jsx(hc,{label:o(l?"pageAtRuleMargins":Aj[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 hc({label:e,value:t,disabled:n,onChange:r}){const o=X(),a=s.useId(),[l,u]=s.useState(()=>ep(t)),d=(t==null?void 0:t.unit)??hu;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:l,disabled:n,inputMode:"decimal",onChange:f=>u(f.target.value),onBlur:()=>{const f=l.trim();if(!f){r(null);return}const g=si(f,d,!1);if(!g){u(ep(t));return}r(g),u(be(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 Rj=Ab.map(e=>e.id);function Dj(e){return{...Pr(),...e}}function Ij(e){const{align:t,alignMixed:n,list:r,listMixed:o,...a}=e;return a}function jj({open:e,tab:t,value:n,fonts:r,disabled:o,printTabVisible:a=!1,initialParagraphTab:l="spacing",customImagePicker:u,disableBuiltinBackgroundImageSources:d,onCustomImagePick:f,onTabChange:g,onApply:h,onResetAtRule:y,onClose:b}){const C=X(),x=s.useId(),v=s.useRef(null),[k,S]=s.useState("general"),[A,R]=s.useState("spacing"),[T,D]=s.useState(n.font),[P,j]=s.useState(n.box),[L,V]=s.useState(n.backgroundImage),[E,N]=s.useState(n.atRule??Wn());if(s.useEffect(()=>{e&&(S("general"),R(l==="general"?"spacing":l),D(n.font),j(n.box),V(n.backgroundImage??mn()),N(n.atRule??Wn()),t==="print"&&!a&&g("font"))},[e,n,t,a,l,g]),Ye(v,{open:e,onClose:b,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const K=C("pageDialogTitle"),G=t==="print"&&!a?"font":t;return i.jsx(Pe,{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:K}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":K,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(Qu,{tab:k,value:T,fonts:r,disabled:o,onTabChange:S,onChange:D})}):G==="paragraph"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(td,{tab:A,value:Dj(P),disabled:o,tabs:Rj,tablistLabelKey:"pageDialogTitle",backgroundImage:L,customImagePicker:u,disableBuiltinBackgroundImageSources:d,onCustomImagePick:f,onBackgroundImageChange:V,onTabChange:q=>{q!=="general"&&R(q)},onChange:q=>j(Ij(q))})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(Tj,{value:E,disabled:o,onChange:N,onReset:()=>{N(Wn()),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:T,box:P,backgroundImage:L,atRule:a?E:n.atRule??Wn()}),children:C("fontDialogOk")})]})]})})})}function Ej({open:e,disabled:t,onClose:n,onConfirm:r}){const o=X(),a=s.useId(),l=s.useRef(null);if(s.useEffect(()=>{if(!e)return;const d=l.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(Pe,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:l,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("deletePageDialogCloseAria"),onClick:n,children:i.jsx(Qe,{})})]}),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 Mj(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function tp(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 _j(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 Nj({open:e,mode:t,styleId:n,name:r="",font:o,paragraph:a,canDelete:l=!1,busy:u,disabled:d,fonts:f,defaultOuterTab:g="font",onSave:h,onDelete:y,onClose:b}){const C=X(),x=s.useId(),v=s.useId(),k=s.useRef(null),[S,A]=s.useState(r),[R,T]=s.useState(g),[D,P]=s.useState("general"),[j,L]=s.useState("general"),[V,E]=s.useState(()=>tp(o)),[N,K]=s.useState(()=>Gc(a)),[G,q]=s.useState(!1);s.useEffect(()=>{e&&(A(r),T(g),P("general"),L("general"),E(tp(o)),K(Gc(a)),q(!1))},[e,r,o,a,g]);const ae=s.useCallback(()=>{if(G){q(!1);return}b()},[G,b]);if(Ye(k,{open:e,onClose:ae,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const Z=C(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),ee=S.trim().length>0,le=!!(d||u),me=()=>{const ne=S.trim();ne&&h({id:n??Mj(),name:ne,font:_j(V),paragraph:kh(N)})};return i.jsx(Pe,{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:ne=>ne.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(Qe,{})})]}),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:le,onClick:()=>q(!1),children:C("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:le||!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:le,onChange:ne=>A(ne.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:()=>T("font"),children:C("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":R==="paragraph",onClick:()=>T("paragraph"),children:C("customStyleDialogTabParagraph")})]}),R==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Qu,{tab:D,value:V,fonts:f,disabled:le,onTabChange:P,onChange:E})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(td,{tab:j,value:N,disabled:le,onTabChange:L,onChange:K})}),i.jsxs("div",{className:t==="edit"&&l?`${p.actions} ${p.actionsSpread}`:p.actions,children:[t==="edit"&&l?i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:le,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:le||!ee,onClick:me,children:C("fontDialogOk")})]})]})]})]})})})}function Lj({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),l=s.useId(),u=s.useId(),d=s.useRef(null),f=s.useRef(null),[g,h]=s.useState(t);if(s.useEffect(()=>{e&&h(t)},[e,t]),Ye(d,{open:e,onClose:o,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),s.useEffect(()=>{var b;e&&((b=f.current)==null||b.focus())},[e]),!e)return null;const y=()=>{n||r(g)};return i.jsx(Pe,{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":l,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:l,children:a("customCssDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("customCssDialogCloseAria"),onClick:o,children:i.jsx(Qe,{})})]}),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 Bj={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function Fj({open:e,existingIds:t,disabled:n,onApply:r,onClose:o}){const a=X(),l=s.useId(),u=s.useId(),d=s.useId(),f=s.useRef(null),[g,h]=s.useState(""),[y,b]=s.useState(!1),C=s.useMemo(()=>new Set(t),[t]),x=Dh(g,C);if(s.useEffect(()=>{e&&(h(""),b(!1))},[e]),Ye(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(Pe,{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":l,onMouseDown:A=>A.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:l,children:a("bookmarkDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("bookmarkDialogCloseAria"),onClick:o,children:i.jsx(Qe,{})})]}),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(nr,{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:A=>h(A.target.value)}),v?i.jsx("p",{id:d,className:p.error,children:a(Bj[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 Hj={empty:"audioDialogErrorEmpty",invalid:"audioDialogErrorInvalid"},zj={type:"audioDialogErrorType",tooLarge:"audioDialogErrorTooLarge"};function Oj({open:e,disabled:t,customAudioPicker:n,onApply:r,onCustomPick:o,onClose:a}){const l=X(),u=s.useId(),d=s.useId(),f=s.useId(),g=s.useId(),h=s.useRef(null),y=s.useRef(null),[b,C]=s.useState("file"),[x,v]=s.useState(""),[k,S]=s.useState(""),[A,R]=s.useState(""),[T,D]=s.useState(""),[P,j]=s.useState(null),[L,V]=s.useState(!1);if(s.useEffect(()=>{e&&(C("file"),v(""),S(""),R(""),D(""),j(null),V(!1),y.current&&(y.current.value=""))},[e]),Ye(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const E=b==="file"?k:b==="url"?x:"",N=b==="custom"?null:qu(E),K=b==="custom"?null:b==="file"&&P?zj[P]:N&&(b==="file"||x.trim().length>0)?Hj[N]:null,G=b!=="custom"&&N===null&&!(b==="file"&&P)&&!t&&!L,q=()=>{t||!n||o==null||o()},ae=()=>{G&&r({src:E.trim(),title:T.trim()})},Z=ee=>{var me;const le=(me=ee.target.files)==null?void 0:me[0];le&&(V(!0),j(null),p0(le).then(ne=>{S(ne),R(le.name),C("file"),V(!1)},ne=>{const M=ne instanceof Error?ne.message:"";S(""),R(""),C("file"),j(M==="tooLarge"||M==="type"?M:"type"),V(!1),y.current&&(y.current.value="")}))};return i.jsx(Pe,{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:ee=>ee.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:l("audioDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":l("audioDialogCloseAria"),onClick:a,children:i.jsx(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:l("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":l("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="file",disabled:t,onClick:()=>C("file"),children:l("audioDialogFile")}),i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="url",disabled:t,onClick:()=>C("url"),children:l("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:l0,hidden:!0,disabled:t,"aria-label":l("audioDialogChooseFile"),onChange:Z}),i.jsx("button",{type:"button",className:p.action,disabled:t||L,onClick:()=>{var ee;return(ee=y.current)==null?void 0:ee.click()},children:l("audioDialogChooseFile")}),A?i.jsx("span",{className:p.fileName,children:A}):null]}):null,b==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:l("audioDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:x,disabled:t,"aria-invalid":K!==null,"aria-describedby":K?g:void 0,onChange:ee=>v(ee.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:l("audioDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:T,disabled:t,onChange:ee=>D(ee.target.value)})]}):null,K?i.jsx("p",{id:g,className:p.error,children:l(K)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:l("fontDialogCancel")}),b!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!G,onClick:ae,children:l("fontDialogOk")}):null]})]})})})}function Kj({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:o,onClose:a}){const l=X(),u=s.useId(),d=s.useId(),f=s.useId(),g=s.useRef(null),[h,y]=s.useState(""),[b,C]=s.useState(""),[x,v]=s.useState(""),[k,S]=s.useState("file");if(s.useEffect(()=>{e&&(y(""),C(""),v(""),S("file"))},[e]),Ye(g,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const A=sj(h)&&!t,R=()=>{A&&r({src:h.trim(),alt:b.trim(),title:x.trim()})};return i.jsx(Pe,{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:T=>T.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:l("imageDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":l("imageDialogCloseAria"),onClick:a,children:i.jsx(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx(Rb,{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:l("imageDialogAlt")}),i.jsx("input",{id:d,className:p.textInput,value:b,disabled:t,onChange:T=>C(T.target.value)})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:l("imageDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:x,disabled:t,onChange:T=>v(T.target.value)})]})]}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:l("fontDialogCancel")}),k!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!A,onClick:R,children:l("fontDialogOk")}):null]})]})})})}const $j=[{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}],Uj={left:gl,center:pl,right:hl},Vj=["left","center","right"],Wj={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},Gj=["width","height","lock"],qj={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},Zj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Yj={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Xj={value:1,unit:"pt"},Jj={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 bc(e){return{top:e,right:e,bottom:e,left:e}}function Qj(e){for(const t of at)if(e[t])return e[t];return null}function eE({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:o,onChange:a}){const l=X(),u=s.useId(),d=s.useId(),f=s.useId(),[g,h]=s.useState(()=>In(t.margin,bc(t.margin.top))),y=t.align==="center",b=(x,v)=>{if(t.sizeMode==="lock"&&v){const k=oi(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=oi("width",t.width,n);a({...t,sizeMode:x,width:v.width,height:v.height});return}if(t.height){const v=oi("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":l("imagePropertiesDialogTitle"),children:$j.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:l(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:l("imagePropertiesSize")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":l("imagePropertiesSizeMode"),children:Gj.map(x=>i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":t.sizeMode===x,disabled:r,onClick:()=>C(x),children:l(qj[x])},x))}),i.jsx(fl,{label:l("imagePropertiesWidth"),inputAria:l("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:x=>b("width",x)}),i.jsx(fl,{label:l("imagePropertiesHeight"),inputAria:l("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:l("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":l("paragraphDialogAlignment"),children:Vj.map(x=>{const v=Uj[x];return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":t.align===x,"aria-label":l(Wj[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:l("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:bc(Qj(t.margin))})}}),l("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(g?["top"]:at).map(x=>i.jsx(Je,{label:l(g?"paragraphDialogMargin":Zj[x]),value:t.margin[x],disabled:r||y&&(x==="left"||x==="right"),allowNegative:!0,onChange:v=>{const k=g?bc(v):{...t.margin,[x]:v};a({...t,margin:k})}},x))})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:l("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:l("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??Xj,color:v==="none"?null:t.border.color}})},children:Cl.map(x=>i.jsx("option",{value:x,children:l(Yj[x])},x))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:l("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:x=>{a({...t,border:{...t.border,width:x}})}}),i.jsx(Ut,{label:l("paragraphDialogBorderColor"),noneLabel:l("colorNone"),value:t.border.color,disabled:r,onChange:x=>{a({...t,border:{...t.border,color:x}})}})]}):null,i.jsx(Je,{label:l("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:Jj})}}),l("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(ed,{shadow:t.boxShadow,disabled:r,onChange:x=>{a({...t,boxShadow:x})}}):null]})]}):null,e==="advanced"?i.jsxs(i.Fragment,{children:[i.jsx(Tb,{value:{opacity:t.opacity,fit:t.objectFit,position:t.objectPosition},disabled:r,onChange:x=>{a(p1({...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:l("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?"":be(t.rotateDeg),disabled:r,inputMode:"decimal","aria-label":l("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:l("imagePropertiesRotationUnit")})]})})]})]}):null,e==="hover"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:l("imagePropertiesTabHover")}),i.jsx("p",{className:p.emptyHint,children:l("imagePropertiesHoverHelp")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:l("imagePropertiesHoverCss")}),i.jsx("textarea",{id:f,className:p.textarea,value:t.hoverCss,disabled:r,spellCheck:!1,"aria-label":l("imagePropertiesHoverCssAria"),onChange:x=>{a({...t,hoverCss:x.target.value})}})]})]}):null]})]})}function tE({open:e,tab:t,value:n,aspectRatio:r=1,disabled:o,onTabChange:a,onApply:l,onClose:u}){const d=X(),f=s.useId(),g=s.useRef(null),[h,y]=s.useState(n);return s.useEffect(()=>{e&&y(n)},[e,n]),Ye(g,{open:e,onClose:u,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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(Qe,{})})]}),i.jsx(eE,{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:()=>l(h),children:d("fontDialogOk")})]})]})})}):null}function nE({open:e,tab:t,href:n,title:r,targetBlank:o,textDecorationNone:a,hoverMode:l,hoverColor:u,hoverHtml:d,bookmarks:f,selectedBookmarkId:g,disabled:h,onTabChange:y,onApply:b,onClose:C}){const x=X(),v=s.useId(),k=s.useId(),S=s.useId(),A=s.useId(),R=s.useId(),T=s.useRef(null),[D,P]=s.useState(n),[j,L]=s.useState(r),[V,E]=s.useState(o),[N,K]=s.useState(a),[G,q]=s.useState(l),[ae,Z]=s.useState(u),[ee,le]=s.useState(d),[me,ne]=s.useState(g);if(s.useEffect(()=>{e&&(P(n),L(r),E(o),K(a),q(l),Z(u),le(d),ne(g))},[e,n,r,o,a,l,u,d,g]),Ye(T,{open:e,onClose:C,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),!e)return null;const M=()=>Dl({title:j,targetBlank:V,textDecorationNone:N,hoverMode:G,hoverColor:ae,hoverHtml:ee}),re=()=>{const ie=D.trim();!ie||h||b({...M(),href:ie})},O=()=>{!me||h||b({...M(),href:`#${me}`})};return i.jsx(Pe,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:C,children:i.jsxs("div",{ref:T,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":v,onMouseDown:ie=>ie.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:D,disabled:h,onChange:ie=>P(ie.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:j,disabled:h,onChange:ie=>L(ie.target.value)})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:V,disabled:h,onChange:ie=>E(ie.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:A,children:x("linkDialogBookmark")}),i.jsxs("select",{id:A,className:`${p.select} ${p.fullSelect}`,value:me,disabled:h,onChange:ie=>ne(ie.target.value),children:[i.jsx("option",{value:""}),f.map(ie=>i.jsx("option",{value:ie.id,children:ie.id},ie.id))]})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:N,disabled:h,onChange:ie=>K(ie.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(Ut,{label:x("linkDialogHoverColorField"),noneLabel:x("colorNone"),value:ae,disabled:h,onChange:Z}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:R,children:x("linkDialogHoverHtmlAria")}),i.jsx("textarea",{id:R,className:p.textarea,value:ee,disabled:h,spellCheck:!1,onChange:ie=>le(ie.target.value)})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:h||!me,onClick:O,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||!D.trim(),onClick:re,children:x("fontDialogOk")})]})]})})})}const np={empty:"youtubeDialogErrorEmpty",invalid:"youtubeDialogErrorInvalid"};function rE({open:e,disabled:t,customVideoPicker:n,onApply:r,onCustomPick:o,onClose:a}){const l=X(),u=s.useId(),d=s.useId(),f=s.useId(),g=s.useId(),h=s.useRef(null),[y,b]=s.useState("url"),[C,x]=s.useState(""),[v,k]=s.useState("");if(s.useEffect(()=>{e&&(b("url"),x(""),k(""))},[e]),Ye(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const S=y==="custom"?null:zh(C),A=y==="custom"?null:S&&C.trim().length>0?np[S]:S==="empty"&&C.trim().length===0?null:S?np[S]:null,R=y!=="custom"&&S===null&&!t&&C.trim().length>0,T=()=>{t||!n||o==null||o()},D=()=>{R&&r({url:C.trim(),title:v.trim()})};return i.jsx(Pe,{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:P=>P.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:l("youtubeDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":l("youtubeDialogCloseAria"),onClick:a,children:i.jsx(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:l("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":l("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="url",disabled:t,onClick:()=>b("url"),children:l("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:l("youtubeDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:C,disabled:t,"aria-invalid":A!==null,"aria-describedby":A?g:void 0,onChange:P=>x(P.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:T,children:n.buttonCaption})]}):null]}),y!=="custom"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:l("youtubeDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:v,disabled:t,onChange:P=>k(P.target.value)})]}):null,A?i.jsx("p",{id:g,className:p.error,children:l(A)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:l("fontDialogCancel")}),y!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!R,onClick:D,children:l("fontDialogOk")}):null]})]})})})}const oE="_grid_1bpma_1",iE="_cell_1bpma_8",aE="_sizeLabel_1bpma_27",lE="_sizeFields_1bpma_33",sE="_numberInput_1bpma_37",Qr={grid:oE,cell:iE,sizeLabel:aE,sizeFields:lE,numberInput:sE},$n={rows:3,cols:3};function cE({open:e,disabled:t,onApply:n,onClose:r}){const o=X(),a=s.useId(),l=s.useId(),u=s.useId(),d=s.useRef(null),[f,g]=s.useState($n.rows),[h,y]=s.useState($n.cols),[b,C]=s.useState(String($n.rows)),[x,v]=s.useState(String($n.cols)),[k,S]=s.useState(!1);if(s.useEffect(()=>{e&&(g($n.rows),y($n.cols),C(String($n.rows)),v(String($n.cols)),S(!1))},[e]),Ye(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=ph(f,h)&&!t,T=(L,V)=>{const E=Math.min(ao,Math.max(io,L)),N=Math.min(ao,Math.max(io,V));g(E),y(N),C(String(E)),v(String(N))},D=(L,V)=>{const E=Number.parseInt(L,10);if(!Number.isFinite(E)){V==="rows"?C(String(f)):v(String(h));return}S(!0),V==="rows"?T(E,h):T(f,E)},P=(L,V)=>{const E=L.replace(/\D/g,"");if(V==="rows"?C(E):v(E),E==="")return;const N=Number.parseInt(E,10);Number.isFinite(N)&&(S(!0),V==="rows"?T(N,h):T(f,N))},j=L=>{(L.key==="e"||L.key==="E"||L.key==="+"||L.key==="-"||L.key===".")&&L.preventDefault()};return i.jsx(Pe,{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:L=>L.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(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx("div",{className:Qr.grid,role:"grid","aria-label":o("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:ff},(L,V)=>Array.from({length:ff},(E,N)=>{const K=V+1,G=N+1,q=K<=f&&G<=h;return i.jsx("button",{type:"button",className:Qr.cell,role:"gridcell","data-active":q?"true":void 0,"aria-label":`${K} × ${G}`,"aria-pressed":q&&K===f&&G===h,disabled:t,onMouseEnter:()=>{k||T(K,G)},onClick:()=>{S(!0),T(K,G)}},`${K}-${G}`)}))}),i.jsxs("p",{className:Qr.sizeLabel,children:[o("tableDialogSize"),": ",f," × ",h]}),i.jsxs("div",{className:`${p.sizeRow} ${Qr.sizeFields}`,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:l,children:o("tableDialogRows")}),i.jsx("input",{id:l,className:Qr.numberInput,type:"number",inputMode:"numeric",min:io,max:ao,step:1,value:b,disabled:t,onKeyDown:j,onChange:L=>P(L.target.value,"rows"),onBlur:()=>D(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:Qr.numberInput,type:"number",inputMode:"numeric",min:io,max:ao,step:1,value:x,disabled:t,onKeyDown:j,onChange:L=>P(L.target.value,"cols"),onBlur:()=>D(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:!R,onClick:()=>{R&&n({rows:f,cols:h})},children:o("tableDialogInsert")})]})]})})})}const uE={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},dE={value:1,unit:"pt"},mE={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 fE({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),a=s.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(Je,{label:r("tablePropertiesWidth"),value:e.width,disabled:t,onChange:l=>n({...e,width:l})}),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:l=>{const u=l.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(Je,{label:r("tablePropertiesSpacing"),value:e.borderSpacing,disabled:t,onChange:l=>n({...e,borderSpacing:l})}):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:l=>{const u=l.target.value;n({...e,border:{style:u,width:u==="none"?null:e.border.width??dE,color:u==="none"?null:e.border.color}})},children:Cl.map(l=>i.jsx("option",{value:l,children:r(uE[l])},l))})]}),e.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:l=>n({...e,border:{...e.border,width:l}})}),i.jsx(Ut,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:l=>n({...e,border:{...e.border,color:l}})})]}):null,i.jsx(Je,{label:r("paragraphDialogBorderRadius"),value:e.borderRadius,disabled:t,onChange:l=>n({...e,borderRadius:l})}),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:mE})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?i.jsx(ed,{shadow:e.boxShadow,disabled:t,onChange:l=>n({...e,boxShadow:l})}):null]})]})}function pE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),l=s.useId(),u=s.useRef(null),[d,f]=s.useState(t);return s.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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":l,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:l,children:a("tablePropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("tablePropertiesDialogCloseAria"),onClick:o,children:i.jsx(Qe,{})})]}),i.jsx(fE,{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 gE=["left","center","right"],hE={left:gl,center:pl,right:hl},bE={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},yE={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},xE={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Ba(e){return{top:e,right:e,bottom:e,left:e}}function yc(e){for(const t of at)if(e[t])return e[t];return null}function CE({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),a=s.useId(),l=s.useId(),[u,d]=s.useState(()=>In(e.padding,Ba(yc(e.padding))));return s.useEffect(()=>{d(In(e.padding,Ba(yc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx(Ut,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:f=>n({...e,backgroundColor:f})}),i.jsx(Ut,{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:Ba(yc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(u?["top"]:at).map(f=>i.jsx(Je,{label:r(u?"paragraphDialogPadding":yE[f]),value:e.padding[f],disabled:t,onChange:g=>{const h=u?Ba(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:gE.map(f=>{const g=hE[f],h=(e.textAlign??"left")===f;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":h,"aria-label":r(bE[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")}),jl.map(f=>i.jsx("option",{value:f,children:r(xE[f])},f))]})]}),i.jsx(Je,{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:l,children:r("cellPropertiesRowSpan")}),i.jsx("input",{id:l,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 wE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),l=s.useId(),u=s.useRef(null),[d,f]=s.useState(t);return s.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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":l,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:l,children:a("cellPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("cellPropertiesDialogCloseAria"),onClick:o,children:i.jsx(Qe,{})})]}),i.jsx(CE,{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 vE={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},kE={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Fa(e){return{top:e,right:e,bottom:e,left:e}}function xc(e){for(const t of at)if(e[t])return e[t];return null}function SE({value:e,disabled:t,onChange:n}){const r=X(),o=s.useId(),[a,l]=s.useState(()=>In(e.padding,Fa(xc(e.padding))));return s.useEffect(()=>{l(In(e.padding,Fa(xc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx(Ut,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:u=>n({...e,backgroundColor:u})}),i.jsx(Ut,{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;l(u),u&&n({...e,padding:Fa(xc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(a?["top"]:at).map(u=>i.jsx(Je,{label:r(a?"paragraphDialogPadding":vE[u]),value:e.padding[u],disabled:t,onChange:d=>{const f=a?Fa(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")}),jl.map(u=>i.jsx("option",{value:u,children:r(kE[u])},u))]})]}),i.jsx(Je,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:u=>n({...e,height:u})})]})}function PE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),l=s.useId(),u=s.useRef(null),[d,f]=s.useState(t);return s.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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":l,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:l,children:a("rowPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("rowPropertiesDialogCloseAria"),onClick:o,children:i.jsx(Qe,{})})]}),i.jsx(SE,{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 AE="_backdrop_9d3gw_1",TE="_dialog_9d3gw_12",RE="_headerRow_9d3gw_29",DE="_header_9d3gw_29",IE="_close_9d3gw_44",jE="_body_9d3gw_66",EE="_frame_9d3gw_75",ME="_actions_9d3gw_83",_E="_action_9d3gw_83",Rn={backdrop:AE,dialog:TE,headerRow:RE,header:DE,close:IE,body:jE,frame:EE,actions:ME,action:_E};function NE(e){const t=qn(e);if(t.length<=1)return e;const n=[],r=[];for(const a of t){const l=ye(a);n.push(...l.hrefs),r.push(l.body)}const o=r.map((a,l)=>`<div class="wysiwyg-preview-page" style="${l===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 LE({open:e,html:t,onClose:n}){const r=X(),o=s.useId(),a=s.useRef(null),l=s.useRef(null),u=s.useMemo(()=>NE(t),[t]);return Ye(a,{open:e,onClose:n,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),s.useEffect(()=>{var f;if(!e)return;const d=(f=l.current)==null?void 0:f.contentDocument;d&&Bc(d,u,r("previewDialogTitle"))},[e,u,r]),e?i.jsx(Pe,{children:i.jsx("div",{className:Rn.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:a,className:Rn.dialog,role:"dialog","aria-modal":"true","aria-labelledby":o,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:Rn.headerRow,children:[i.jsx("h2",{className:Rn.header,id:o,children:r("previewDialogTitle")}),i.jsx("button",{type:"button",className:Rn.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:i.jsx(Qe,{})})]}),i.jsx("div",{className:Rn.body,children:i.jsx("iframe",{ref:l,className:Rn.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var f;const d=(f=l.current)==null?void 0:f.contentDocument;d&&Bc(d,u,r("previewDialogTitle"))}})}),i.jsx("div",{className:Rn.actions,children:i.jsx("button",{type:"button",className:Rn.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const BE="0.0.11",FE="_backdrop_72ox3_1",HE="_dialog_72ox3_12",zE="_headerRow_72ox3_30",OE="_header_72ox3_30",KE="_close_72ox3_46",$E="_body_72ox3_68",UE="_product_72ox3_76",VE="_meta_72ox3_82",WE="_description_72ox3_87",GE="_website_72ox3_92",qE="_cta_72ox3_97",ZE="_link_72ox3_102",YE="_actions_72ox3_118",XE="_action_72ox3_118",bt={backdrop:FE,dialog:HE,headerRow:zE,header:OE,close:KE,body:$E,product:UE,meta:VE,description:WE,website:GE,cta:qE,link:ZE,actions:YE,action:XE};function JE({open:e,onClose:t}){const n=X(),r=s.useId(),o=s.useRef(null);return Ye(o,{open:e,onClose:t,escapeIgnoreSelectors:!1,focusableSelector:'a[href], button:not([disabled]):not([tabindex="-1"])'}),e?i.jsx(Pe,{children:i.jsx("div",{className:bt.backdrop,role:"presentation",onMouseDown:t,children:i.jsxs("div",{ref:o,className:bt.dialog,role:"dialog","aria-modal":"true","aria-labelledby":r,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:bt.headerRow,children:[i.jsx("h2",{id:r,className:bt.header,children:n("aboutDialogTitle")}),i.jsx("button",{type:"button",className:bt.close,onClick:t,"aria-label":n("aboutDialogCloseAria"),children:i.jsx(Qe,{})})]}),i.jsxs("div",{className:bt.body,children:[i.jsx("p",{className:bt.product,children:n("brandMarkAria")}),i.jsx("p",{className:bt.meta,children:n("aboutDialogVersion").replace("{version}",BE)}),i.jsx("p",{className:bt.description,children:n("aboutDialogDescription")}),i.jsxs("div",{className:bt.website,children:[i.jsx("p",{className:bt.cta,children:n("aboutDialogWebsiteCta")}),i.jsx("a",{className:bt.link,href:"https://commspliant.com/",target:"_blank",rel:"noopener noreferrer","aria-label":n("aboutDialogWebsiteAria"),children:n("aboutDialogWebsite")})]})]}),i.jsx("div",{className:bt.actions,children:i.jsx("button",{type:"button",className:bt.action,onClick:t,children:n("aboutDialogClose")})})]})})}):null}const QE="_backdrop_12fkg_1",eM="_dialog_12fkg_12",tM="_headerRow_12fkg_31",nM="_header_12fkg_31",rM="_close_12fkg_47",oM="_searchRow_12fkg_69",iM="_search_12fkg_69",aM="_body_12fkg_91",lM="_sidebar_12fkg_99",sM="_category_12fkg_111",cM="_topicList_12fkg_121",uM="_topicButton_12fkg_127",dM="_topicButtonActive_12fkg_147",mM="_main_12fkg_157",fM="_articleTitle_12fkg_164",pM="_articleBody_12fkg_171",gM="_noResults_12fkg_176",hM="_related_12fkg_181",bM="_relatedTitle_12fkg_187",yM="_relatedList_12fkg_194",xM="_relatedButton_12fkg_200",CM="_relatedItem_12fkg_223",Oe={backdrop:QE,dialog:eM,headerRow:tM,header:nM,close:rM,searchRow:oM,search:iM,body:aM,sidebar:lM,category:sM,topicList:cM,topicButton:uM,topicButtonActive:dM,main:mM,articleTitle:fM,articleBody:pM,noResults:gM,related:hM,relatedTitle:bM,relatedList:yM,relatedButton:xM,relatedItem:CM};function wM(e){return{getStarted:"helpCategoryGetStarted",file:"helpCategoryFile",edit:"helpCategoryEdit",insert:"helpCategoryInsert",format:"helpCategoryFormat",table:"helpCategoryTable",view:"helpCategoryView",keyboard:"helpCategoryKeyboard"}[e]}function vM({open:e,topicId:t,onTopicChange:n,onClose:r}){const o=X(),a=s.useId(),l=s.useRef(null),[u,d]=s.useState("");Ye(l,{open:e,onClose:r,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),s.useEffect(()=>{e||d("")},[e]);const f=s.useMemo(()=>ou.map(b=>({id:b.id,title:o(b.titleKey),body:o(b.bodyKey),keywords:o(b.keywordsKey)})),[o]),g=s.useMemo(()=>{const b=pD(f,u);return new Set(b.map(C=>C.id))},[u,f]),h=Vf[t],y=u.trim().length>0&&g.size===0;return e?i.jsx(Pe,{children:i.jsx("div",{className:Oe.backdrop,role:"presentation",onMouseDown:r,children:i.jsxs("div",{ref:l,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(Qe,{})})]}),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:mD.map(b=>{const C=ou.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(wM(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=Vf[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 Db(e){return{catalog:e.catalog,layout:e.layout,commands:e.commands,queries:e.queries,queryRevisions:e.queryRevisions??db(),disabled:e.disabled,chromeLock:e.chromeLock}}function kM(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 SM=s.memo(function({menuVisible:t,captureChromeSelection:n,displayCatalog:r,displayLayout:o,commands:a,queries:l,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:A,documentPreview:R,onDocumentPreviewClose:T,helpDialog:D,onHelpDialogClose:P,onHelpTopicChange:j,aboutDialogOpen:L,onAboutDialogClose:V,fontDialog:E,fontSizeState:N,markState:K,fontFamilyState:G,fontColorState:q,highlightColorState:ae,fontFaces:Z,onFontDialogTabChange:ee,onFontDialogClose:le,onApplyFontProperties:me,paragraphDialog:ne,customBackgroundImagePicker:M,disableBuiltinBackgroundImageSources:re,onParagraphCustomImagePick:O,onParagraphDialogTabChange:ie,onParagraphDialogClose:Ee,onApplyParagraphProperties:He,customCssDialog:$e,onCustomCssDialogClose:Ve,onApplyCustomCss:St,pageDialog:et,enablePageProperties:en,onPageCustomImagePick:Q,onPageDialogTabChange:fe,onPageDialogClose:pe,onApplyPageProperties:Ce,onPageDialogResetAtRule:Pt,deletePageConfirmOpen:Vt,onDeletePageConfirmClose:Mn,onDeletePageConfirm:Wt,customStyleDialog:De,canDeleteCustomParagraphStyle:yn,customStyleBusy:xn,onCustomStyleDialogClose:_r,onCustomStyleSave:Nr,onCustomStyleDelete:Lr,linkDialog:ve,onLinkDialogTabChange:tn,onLinkDialogClose:Br,onApplyLink:lr,bookmarkDialog:sr,onBookmarkDialogClose:H,onApplyBookmark:J,imageDialogOpen:ue,customImagePicker:Ne,customAudioPicker:At,customVideoPicker:Cn,onImageDialogClose:tt,onApplyImage:Ke,onImageDialogCustomPick:Ae,audioDialogOpen:We,onAudioDialogClose:nn,onApplyAudio:El,onAudioDialogCustomPick:vi,youtubeDialogOpen:Ml,onYoutubeDialogClose:lt,onApplyYoutube:ki,onYoutubeDialogCustomPick:Tt,imageProperties:rn,onImagePropertiesTabChange:_n,onImagePropertiesClose:_l,onApplyImageProperties:ko,tableDialogOpen:Nl,onTableDialogClose:Si,onApplyTable:Nn,tableProperties:on,onTablePropertiesClose:So,onApplyTableProperties:cr,cellProperties:F,onCellPropertiesClose:Nt,onApplyCellProperties:Pi,rowProperties:ur,onRowPropertiesClose:dt,onApplyRowProperties:dr}){const Ai=Db({catalog:r,layout:o,commands:a,queries:l,queryRevisions:u,disabled:d,chromeLock:f});return i.jsxs(i.Fragment,{children:[t?i.jsx("div",{className:ke.menuChrome,onPointerDownCapture:n,children:i.jsx(iu,{...Ai,menuVisible:!0,toolbarVisible:!1})}):null,h?i.jsx(PA,{open:!0,catalog:y,groups:b.iconGroups,settings:C,loading:x,busy:v,disabled:g,onChange:S,onReset:A,onClose:k}):null,R.open?i.jsx(LE,{open:!0,html:R.html,onClose:T}):null,D.open?i.jsx(vM,{open:!0,topicId:D.topicId,onTopicChange:j,onClose:P}):null,L?i.jsx(JE,{open:!0,onClose:V}):null,E.open?i.jsx(QI,{open:!0,tab:E.tab,size:N.value,unit:N.unit,marks:K,fontFamily:G.value,fontFamilyMixed:G.mixed,fontColor:q.value,fontColorMixed:q.mixed,highlightColor:ae.value,highlightColorMixed:ae.mixed,fonts:Z,disabled:g,onTabChange:ee,onApply:me,onClose:le}):null,ne.open?i.jsx(kj,{open:!0,tab:ne.tab,value:ne.value,backgroundImage:ne.backgroundImage,disabled:g,customImagePicker:M,disableBuiltinBackgroundImageSources:re,onCustomImagePick:O,onTabChange:ie,onApply:He,onClose:Ee}):null,$e.open?i.jsx(Lj,{open:!0,value:$e.value,disabled:g,onApply:St,onClose:Ve}):null,et.open?i.jsx(jj,{open:!0,tab:et.tab,initialParagraphTab:et.paragraphTab,value:et.value,fonts:Z,disabled:g,printTabVisible:en,customImagePicker:M,disableBuiltinBackgroundImageSources:re,onCustomImagePick:Q,onTabChange:fe,onApply:Ce,onResetAtRule:Pt,onClose:pe}):null,Vt?i.jsx(Ej,{open:!0,disabled:g,onClose:Mn,onConfirm:Wt}):null,De.open?i.jsx(Nj,{open:!0,mode:De.mode,styleId:De.mode==="edit"?De.style.id:void 0,name:De.mode==="edit"?De.style.name:"",font:De.mode==="edit"?De.style.font:De.font,paragraph:De.mode==="edit"?De.style.paragraph:De.paragraph,canDelete:yn,fonts:Z,busy:xn,disabled:g,onSave:Nr,onDelete:Lr,onClose:_r}):null,ve.open?i.jsx(nE,{open:!0,tab:ve.tab,href:ve.href,title:ve.title,targetBlank:ve.targetBlank,textDecorationNone:ve.textDecorationNone,hoverMode:ve.hoverMode,hoverColor:ve.hoverColor,hoverHtml:ve.hoverHtml,bookmarks:ve.bookmarks,selectedBookmarkId:ve.selectedBookmarkId,disabled:g,onTabChange:tn,onApply:lr,onClose:Br}):null,sr.open?i.jsx(Fj,{open:!0,existingIds:sr.existingIds,disabled:g,onApply:J,onClose:H}):null,ue?i.jsx(Kj,{open:!0,disabled:g,customImagePicker:Ne,onApply:Ke,onCustomPick:Ae,onClose:tt}):null,We?i.jsx(Oj,{open:!0,disabled:g,customAudioPicker:At,onApply:El,onCustomPick:vi,onClose:nn}):null,Ml?i.jsx(rE,{open:!0,disabled:g,customVideoPicker:Cn,onApply:ki,onCustomPick:Tt,onClose:lt}):null,rn.open?i.jsx(tE,{open:!0,tab:rn.tab,value:rn.value,aspectRatio:rn.aspectRatio,disabled:g,onTabChange:_n,onApply:ko,onClose:_l}):null,Nl?i.jsx(cE,{open:!0,disabled:g,onApply:Nn,onClose:Si}):null,on.open?i.jsx(pE,{open:!0,value:on.value,disabled:g,onApply:cr,onClose:So}):null,F.open?i.jsx(wE,{open:!0,value:F.value,disabled:g,onApply:Pi,onClose:Nt}):null,ur.open?i.jsx(PE,{open:!0,value:ur.value,disabled:g,onApply:dr,onClose:dt}):null]})},kM);function PM({toolbarVisible:e,toolbarPos:t,captureChromeSelection:n,toolbarShellProps:r,children:o}){return i.jsxs("div",{className:ke.body,"data-icon-dock":e?t:void 0,children:[e&&(t==="top"||t==="left")?i.jsx("div",{className:ke.iconChrome,onPointerDownCapture:n,children:i.jsx(iu,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null,o,e&&(t==="bottom"||t==="right")?i.jsx("div",{className:ke.iconChrome,onPointerDownCapture:n,children:i.jsx(iu,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null]})}const Ib=s.createContext(null);function AM({value:e,children:t}){return i.jsx(Ib.Provider,{value:e,children:t})}function TM(){const e=s.useContext(Ib);if(!e)throw new Error("useEditorShellContext must be used within EditorShellProvider");return e}function RM(e,t){const n=s.useRef([]),r=s.useRef([]);return s.useMemo(()=>{const o=n.current,a=r.current,l=[];for(let u=0;u<e.length;u+=1){const d=e[u]??"";o[u]===d&&a[u]!==void 0?l.push(a[u]):l.push(ye(d).body)}return n.current=e,r.current=l,l},[e,t,e.length])}const DM="_panel_6xdnw_1",IM="_header_6xdnw_17",jM="_title_6xdnw_26",EM="_close_6xdnw_32",MM="_messages_6xdnw_48",_M="_empty_6xdnw_57",NM="_message_6xdnw_48",LM="_messageHeader_6xdnw_69",BM="_author_6xdnw_77",FM="_time_6xdnw_81",HM="_body_6xdnw_86",zM="_reply_6xdnw_92",OM="_input_6xdnw_100",KM="_post_6xdnw_111",yt={panel:DM,header:IM,title:jM,close:EM,messages:MM,empty:_M,message:NM,messageHeader:LM,author:BM,time:FM,body:HM,reply:zM,input:OM,post:KM};function $M(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(n)}function UM({thread:e,locale:t,disabled:n,commentAuthor:r,panelRef:o,onPost:a,onClose:l}){const u=X(),[d,f]=s.useState(""),g=s.useRef(null);s.useEffect(()=>{var x;(x=g.current)==null||x.focus()},[e==null?void 0:e.id]);const h=!n&&r&&d.trim().length>0,y=s.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 au.createPortal(i.jsxs("div",{ref:o,className:yt.panel,role:"dialog","aria-label":u("commentPanelTitle"),children:[i.jsxs("div",{className:yt.header,children:[i.jsx("h2",{className:yt.title,children:u("commentPanelTitle")}),i.jsx("button",{type:"button",className:yt.close,onClick:l,"aria-label":u("commentPanelCloseAria"),children:i.jsx(Qe,{})})]}),i.jsx("div",{className:yt.messages,children:y.length===0?i.jsx("p",{className:yt.empty,children:u("commentEmpty")}):y.map(x=>i.jsxs("article",{className:yt.message,children:[i.jsxs("header",{className:yt.messageHeader,children:[i.jsx("span",{className:yt.author,children:x.userName}),i.jsx("time",{className:yt.time,dateTime:x.createdAt,children:$M(x.createdAt,t)})]}),i.jsx("p",{className:yt.body,children:x.message})]},x.id))}),i.jsxs("div",{className:yt.reply,children:[i.jsx("textarea",{ref:g,className:yt.input,value:d,onChange:x=>f(x.target.value),placeholder:b,rows:3,disabled:n||!r}),i.jsx("button",{type:"button",className:yt.post,onClick:C,disabled:!h,children:u("commentPost")})]})]}),document.body)}const VM=s.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:o},a){const l=X();return i.jsx("textarea",{ref:a,className:`${ke.surface} ${ke.html}`,value:t,onChange:u=>n(u.target.value),placeholder:r,disabled:o,"aria-label":l("htmlEditorAria"),spellCheck:!1})}),WM="_shell_yvznc_1",GM="_scrollButton_yvznc_10",qM="_tabList_yvznc_48",ZM="_tab_yvznc_48",YM="_tabActive_yvznc_86",eo={shell:WM,scrollButton:GM,tabList:qM,tab:ZM,tabActive:YM},XM=5,rp=120;function JM({pageCount:e,activeIndex:t,onSelect:n}){const r=X(),o=s.useRef(null),[a,l]=s.useState(!1),[u,d]=s.useState(!1),f=e>=XM,g=s.useCallback(()=>{const b=o.current;if(!b)return;const{scrollLeft:C,scrollWidth:x,clientWidth:v}=b;l(C>1),d(C+v<x-1)},[]);s.useEffect(()=>{g()},[e,t,g]),s.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]),s.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:eo.shell,children:[f?i.jsx("button",{type:"button",className:eo.scrollButton,"aria-label":r("htmlModePageTabsScrollLeftAria"),disabled:!a,onClick:()=>h(-rp),children:"‹"}):null,i.jsx("div",{ref:o,className:eo.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:`${eo.tab} ${C===t?eo.tabActive:""}`,"aria-selected":C===t,tabIndex:C===t?0:-1,onClick:()=>n(C),children:y(C)},C))}),f?i.jsx("button",{type:"button",className:eo.scrollButton,"aria-label":r("htmlModePageTabsScrollRightAria"),disabled:!u,onClick:()=>h(rp),children:"›"}):null]})}function QM(e,t,n=!0){const[r,o]=s.useState(null),[a,l]=s.useState(Ju()),u=s.useCallback(()=>{!n||!e||(o(Cb(e,t)),l(ml(e)))},[n,e,t]);return s.useLayoutEffect(()=>{if(!n)return;const d=requestAnimationFrame(u);return()=>cancelAnimationFrame(d)},[n,u]),s.useLayoutEffect(()=>{if(!n||!e||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>u());return d.observe(e),()=>d.disconnect()},[n,e,u]),s.useLayoutEffect(()=>{if(!n||!e)return;const d=()=>{l(ml(e))};return document.addEventListener("selectionchange",d),()=>document.removeEventListener("selectionchange",d)},[n,e]),{geometry:r,indentState:a,refresh:u}}const e_=s.forwardRef(function({html:t,pageHtml:n,onChange:r,placeholder:o,disabled:a,rulerVisible:l=!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},A){const R=X(),T=s.useRef(null),D=s.useRef(!1),[P,j]=s.useState(null),L=s.useRef(y);L.current=y;const V=n??t,E=l&&hi(V),{geometry:N,indentState:K,refresh:G}=QM(P,V,E),q=Z=>{T.current=Z,j(Z),typeof A=="function"?A(Z):A&&(A.current=Z)};s.useLayoutEffect(()=>{const Z=T.current;if(!Z)return;const ee=Xt(t),me=Z===document.activeElement&&D.current;if(D.current=!1,me||sl(Z,ee,{resolveDataUrl:C,hydrateEmbeddedImages:x}),ut(Z)||hi(V)){ju(Z),pi(Z),Pl(Z);const ne=ut(Z);ne&&fg(Z,ne)}Sl(Z),wo(Z,V)},[t,V,C,x]),s.useLayoutEffect(()=>{if(b)return b.current=()=>{D.current=!0},()=>{b.current=null}},[b]),s.useLayoutEffect(()=>{const Z=T.current;if(!Z)return;const ee=le=>{var me;(me=L.current)==null||me.call(L,le)};return Z.addEventListener("beforeinput",ee),()=>Z.removeEventListener("beforeinput",ee)},[]);const ae=i.jsx("div",{ref:q,className:`${ke.surface} ${ke.visual} ${E?ke.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 ee=Z.currentTarget;if(D.current=!0,ut(ee)){const{absorbedBlocks:le}=pi(ee);if(r(ee.innerHTML),le.length>0){const me=le.length;requestAnimationFrame(()=>bg(ee,me))}}else r(ee.innerHTML);E&&G()}});return i.jsx(HI,{showRulers:E,geometry:N,indentState:K,rulerUnit:u,zoomScale:d,onMarginChange:f,onMarginPreview:g,onIndentChange:h,children:ae})}),t_="_frame_bwkh8_1",n_="_handle_bwkh8_9",r_="_handleEast_bwkh8_29",o_="_handleSouth_bwkh8_37",i_="_handleSouthEast_bwkh8_45",li={frame:t_,handle:n_,handleEast:r_,handleSouth:o_,handleSouthEast:i_};function Yo(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const a_=[{handle:"e",className:li.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:li.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:li.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function Cc(e){return!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)?null:{x:e.clientX,y:e.clientY}}function l_({img:e,onResize:t,onResizeEnd:n}){const r=X(),o=s.useRef(null),a=s.useRef(e),l=s.useRef(t),u=s.useRef(n),d=s.useRef(null);a.current=e,l.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`)};s.useLayoutEffect(()=>{f(Yo(e));const k=()=>{e.isConnected&&f(Yo(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 A=d.current,R=a.current;if(!A||!R)return;const T=nP(A.handle,A.start,{x:k-A.originX,y:S-A.originY});l.current(T.width,T.height),R.isConnected&&f(Yo(R))},h=()=>{if(!d.current)return;d.current=null;const k=a.current;u.current(),k!=null&&k.isConnected&&f(Yo(k))};s.useLayoutEffect(()=>{const k=A=>{if(!d.current)return;const R=Cc(A);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 y=(k,S)=>{const A=Cc(S);A&&(d.current={handle:k,start:rP(a.current),originX:A.x,originY:A.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=Cc(k);S&&g(S.x,S.y)};if(!e.isConnected)return null;const v=Yo(e);return au.createPortal(i.jsx("div",{ref:o,className:li.frame,"data-image-resize-overlay":"",style:{left:v.left,top:v.top,width:v.width,height:v.height},children:a_.map(k=>i.jsx("button",{type:"button",className:`${li.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 s_(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 c_(){const e=X();return i.jsx("div",{className:ke.htmlFileDropOverlay,"aria-hidden":"true",children:e("htmlFileDropOverlay")})}function u_({propsRef:e,pageStore:t,mode:n,enableMultiPages:r,contentLocked:o,activePageIndex:a,hasSelectedPage:l,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:A,commentsVisible:R,disabled:T,locale:D,commentAuthor:P,activeThreadId:j,contextMenu:L,commentThreads:V,commands:E,htmlFileDropDragging:N,selectedImage:K}){const{htmlRef:G,pagesRef:q,documentBridgeRef:ae}=TM(),[Z,ee]=s.useState(C),[le,me]=Oa({value:g?void 0:y,defaultValue:b,onChange:r||g?void 0:k}),ne=g?Z:le,[M,re]=s.useState(()=>r&&(e.current.htmlModePageHtmlRef.current||x[0])||""),O=e.current;O.setHtmlModePageHtml=re,g?r||(G.current=Z):G.current=le,r&&(q.current=t.pages);const ie=s.useCallback(()=>r?t.getJoinedHtml():g?Z:le,[r,le,g,t,Z]);s.useLayoutEffect(()=>{const Q={pageStore:t,setHtml:me,setStorageHtml:ee,getEditorHtml:ie,replacePagesFromHistory:fe=>t.replacePages([...fe])};return ae.current=Q,()=>{ae.current===Q&&(ae.current=null)}},[ae,ie,t,me,ee]);const Ee=s.useMemo(()=>{if(r){const Q=t.pages[a]??t.pages[0]??"";return Hm(Q,S).join(`
317
+ ${W1}`:df}function Bc(e,t,n="​"){const r=Bu(t),{hrefs:o,body:a}=ye(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=Bg(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 Fu(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 q1(e){const t=e.name.toLowerCase();return e.type==="text/html"||t.endsWith(".html")||t.endsWith(".htm")}function Ea(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 Y1(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 X1(e){return e?Y1(e).find(q1)??null:null}const Fg={description:"HTML",accept:{"text/html":[".html",".htm"]}},J1="document.html";function Hg(){return window}function zg(e){return e instanceof DOMException&&e.name==="AbortError"}function Q1(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 ev(){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}Fu(r).then(a=>n(Lg(a)),()=>n(null))}),t.addEventListener("cancel",()=>n(null)),document.body.append(t),t.click()})}async function tv(e,t=J1){const n=Hg().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(zg(r))return;throw r}return}Q1(e,t)}async function nv(){const e=Hg().showOpenFilePicker;if(typeof e=="function")try{const[t]=await e({multiple:!1,types:[Fg]}),n=await t.getFile();return Lg(await Fu(n))}catch(t){if(zg(t))return null;throw t}return ev()}const rv=1e3;function ov(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 iv(e){const t=[...e.images];return t.length===0?Promise.resolve():Promise.all(t.map(ov)).then(()=>{})}function Og(){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 Kg(e,t,n,r){Bc(e,r);let o=!1;const a=()=>{o||(o=!0,n.remove())};t.addEventListener("afterprint",a),await iv(e),t.focus(),t.print(),window.setTimeout(a,rv)}function av(e){const t=Og();t&&Kg(t.doc,t.win,t.iframe,e)}function sv(e){const t=Og();if(!t)return;const n=e.map(Bu),r=n.some(g=>g.hasBleed),o=[],a=[];for(const g of n){const h=ye(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=ig(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("");Kg(t.doc,t.win,t.iframe,f)}function lv(e){return{save:async()=>{if(e.onSave){const t=e.isMultiPagesEnabled()?e.getAllPagesHtml():e.getHtml();await e.onSave(t);return}await tv(Z1(e.getHtml()))},open:async()=>{const t=e.onOpen?await e.onOpen():await nv();if(t!==null){if(Array.isArray(t)){e.setHtml(Et(t));return}if(e.isMultiPagesEnabled()){e.setHtml(Et([t]));return}e.setHtml(t)}},print:()=>{if(e.isMultiPagesEnabled()){sv(Zn(e.getHtml()));return}av(e.getHtml())}}}function cv(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 uv(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 dv(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function mv(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function fv(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 pv(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected(),isMultiPagesEnabled:()=>e.isMultiPagesEnabled(),hasSelectedPage:()=>e.hasSelectedPage(),canDeletePage:()=>e.canDeletePage(),canInsertPageBackgroundImage:()=>e.canInsertPageBackgroundImage(),canInsertParagraphBackgroundImage:()=>e.canInsertParagraphBackgroundImage()}}function gv(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 hv(e){return{isInTable:()=>e.isInTable(),canMergeCells:()=>e.canMergeCells(),canUnmergeCells:()=>e.canUnmergeCells()}}function bv(e){return{openHelp:()=>{e.openHelp()},openKeyboardShortcuts:()=>{e.openKeyboardShortcuts()},openAbout:()=>{e.openAbout()}}}const yv=[50,75,100,125,150,200],xv=.1,Cv=3;function lc(e){return!Number.isFinite(e)||e<=0?1:Math.min(Cv,Math.max(xv,e))}function wv(e,t,n,r,o){if(e==="fitWidth")return r<=0?1:lc(t/r);if(e==="fitPage"){if(r<=0||o<=0)return 1;const a=t/r,s=n/o;return lc(Math.min(a,s))}return lc(e/100)}function vv(e){let t=null;return{schedule(){t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(window.cancelAnimationFrame(t),t=null)}}}function On(e,t){return()=>{e.setPageZoom(t)}}function Kn(e,t){return()=>e.getPageZoom()===t}function kv(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:On(e,"fitWidth"),setPageZoomFitPage:On(e,"fitPage"),setPageZoom50:On(e,50),setPageZoom75:On(e,75),setPageZoom100:On(e,100),setPageZoom125:On(e,125),setPageZoom150:On(e,150),setPageZoom200:On(e,200),setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function Sv(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isPageZoomFitWidth:Kn(e,"fitWidth"),isPageZoomFitPage:Kn(e,"fitPage"),isPageZoom50:Kn(e,50),isPageZoom75:Kn(e,75),isPageZoom100:Kn(e,100),isPageZoom125:Kn(e,125),isPageZoom150:Kn(e,150),isPageZoom200:Kn(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 Pv(e){return{addComment:()=>e.addComment(),toggleCommentsVisible:()=>e.toggleCommentsVisible()}}function Av(e){return{canAddComment:()=>e.canAddComment(),areCommentsVisible:()=>e.areCommentsVisible(),isCommentsEnabled:()=>e.isCommentsEnabled()}}function Tv(e){return{...lv(e),...dv(e),...gx(e),...fv(e),...gv(e),...kv(e),...cv(e),...Pv(e),...bv(e)}}function Rv(e){return{...Sv(e),...mv(e),...pv(e),...hv(e),...uv(e),...Av(e)}}function ts(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Dv(e){const t=e.style.fontSize;if(!t)return null;const n=gu(t);return!n||!xs(n.unit)?null:{value:n.value,unit:n.unit}}function $g(e,t){let n=ts(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Dv(n);if(r)return r;n=n.parentElement}return null}function Iv(e,t){const n=ts(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function Ug(e,t){var a;let n=ts(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=ts(t))==null?void 0:a.parentElement)??e,o=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(o)&&o>0?o:16}function Vg(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function jv(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function mf(e=lo){return{value:null,unit:e,mixed:!1}}function Wg(e,t=lo){const n=window.getSelection();if(!n||n.rangeCount===0)return mf(t);const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer))return mf(t);const o=r.collapsed?[]:vt(r).filter(f=>f.data.length>0),a=o.length>0?o:[r.startContainer],s=a.map(f=>$g(e,f)),u=s[0];if(s.every(f=>jv(f,u))&&u)return{value:u.value,unit:u.unit,mixed:!1};if(s.every(f=>f===null)){const f=a.map(h=>Iv(h,e)),g=f[0];if(f.every(h=>Math.abs(h-g)<.05)){const h=Ug(e,a[0]),y=Vg(e);return{value:Pp(g,t,h,y),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function Ev(e,t){return{parentPx:Ug(e,t),rootPx:Vg(e)}}function Mv(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function Fc(e,t,n){const r=Ar(t,n);if(!r)return!1;const o=Mv(e);if(!o||o.collapsed)return!1;const a=pu(r.value,r.unit);fn(o);const s=vt(o).filter(u=>u.data.length>0);for(const u of s){const d=$g(e,u);d&&d.value===r.value&&d.unit===r.unit||bi(u,f=>{f.style.fontSize=a})}return jr(s),!0}function _v(e,t){e.style.fontSize=pu(t.value,t.unit)}function Nv(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Lv(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=Lv(r.slice(0,o)),s=r.slice(o+1).trim();a&&(t[a]=s)}return t}function Gg(e){return Object.entries(e).filter(([t])=>t.trim()).map(([t,n])=>`${t}: ${n}`).join("; ")}function Bv(e,t){const n={...e};for(const[r,o]of Object.entries(t))o.trim()?n[r]=o:delete n[r];return n}function Fv(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 As(e){const t=Hc(e);return Gg(t)}function Hv(e,t){let n=Nv(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=n.style.cssText.trim();if(r)return r;n=n.parentElement}return""}function Zg(e){const t=hn(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:vt(t).filter(d=>d.data.length>0),a=(n.length>0?n:[t.startContainer]).map(d=>Hv(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 qg(e,t){const n=Hc(e.style.cssText),r=Hc(t),o=Bv(n,r),a=Gg(o);a?e.style.cssText=a:e.removeAttribute("style")}function Yg(e,t){const n=As(t);if(!n)return!1;const r=hn(e);if(!r||r.collapsed)return!1;fn(r);const o=vt(r).filter(a=>a.data.length>0);if(o.length===0)return!1;for(const a of o)bi(a,s=>{qg(s,n),rr(s)&&Mt(s)});return jr(o),!0}function zv(e,t){const n=As(t);n&&qg(e,n)}function Ov(e){return!!(e&&As(e))}const $t=["bold","italic","underline","strikethrough"],ro={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},Kv=new Set(["underline","line-through","overline"]);function Yn(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function $v(e,t){return $t.every(n=>e[n]===t[n])}function Uv(e){return $t.some(t=>e[t]!==void 0)}function Xg(e,t){const n={...e};if(!t)return n;for(const r of $t){const o=t[r];o!==void 0&&(n[r]=o)}return n}function Vv(e,t,n){const r=e[n]??t[n],o={...e,[n]:!r};return o[n]===t[n]&&delete o[n],o}function er(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>Kv.has(n))}function ho(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 Jg(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(ro.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(ro.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(ro.underline.has(r))return!0;const s=n.style.textDecorationLine||n.style.textDecoration;if(!s)return null;if(s==="none")return!1;const u=er(n);return u.includes("underline")?!0:u.length>0?!1:null}if(ro.strikethrough.has(r))return!0;const o=n.style.textDecorationLine||n.style.textDecoration;if(!o)return null;if(o==="none")return!1;const a=er(n);return a.includes("line-through")?!0:a.length>0?!1:null}function ns(e,t){return Jg(e,t)===!0}function bo(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const o=Jg(r,n);if(o!==null)return o;r=r.parentElement}return!1}function Qg(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=er(e);r.includes("underline")||r.push("underline"),ho(e,r);return}const n=er(e);n.includes("line-through")||n.push("line-through"),ho(e,n)}function eh(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"){ho(e,er(e).filter(n=>n!=="underline"));return}ho(e,er(e).filter(n=>n!=="line-through"))}function Wv(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=er(e).filter(o=>o!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}ho(e,r);return}const n=er(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}ho(e,n)}function Gv(e,t){bi(e,n=>Qg(n,t))}function Zv(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!gn(o)||!ns(o,n)){r=o;continue}if(or(o,r),ns(o,n)){if(ro[n].has(o.tagName.toLowerCase())){Mt(o);continue}if(eh(o,n),rr(o)){Mt(o);continue}}r=o}}function qv(e,t,n){const r=vt(t).filter(o=>o.data.length>0);return r.length===0?bo(e,t.startContainer,n):r.every(o=>bo(e,o,n))}function Yv(e,t,n,r){fn(t);const o=vt(t).filter(a=>a.data.length>0);for(const a of o)r?bo(e,a,n)||Gv(a,n):Zv(e,a,n);jr(o)}function oo(e){const t=window.getSelection();if(!t||t.rangeCount===0)return Yn();const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return Yn();if(n.collapsed)return zc(e,n);const r=vt(n).filter(a=>a.data.length>0);if(r.length===0)return zc(e,n);const o=Yn();for(const a of $t)o[a]=bo(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const s of $t)o[s]=o[s]&&bo(e,r[a],s);return o}function zc(e,t){const n=Yn();for(const r of $t)n[r]=bo(e,t.startContainer,r);return n}function Oc(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer)||r.collapsed)return!1;const o=qv(e,r,t);return Yv(e,r,t,!o),!0}function Xv(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 Jv(e,t,n){var a,s,u;Xv(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(!gn(d)){o=d;continue}if(!n.some(g=>ns(d,g))){o=d;continue}or(d,o);for(const g of n)if(ns(d,g)){if(ro[g].has(d.tagName.toLowerCase())){Mt(d);break}if(eh(d,g),rr(d)){Mt(d);break}}o=d.isConnected?d:r}return r}function Qv(e,t,n){for(const r of $t)n[r]!==t[r]&&(n[r]?Qg(e,r):Wv(e,r))}function ek(e,t,n,r,o,a,s){var S,A;const u=window.getSelection();if(!u||u.rangeCount===0)return;const d=u.getRangeAt(0);if(!Re(e,d.commonAncestorContainer))return;const f=zc(e,d),g=Xg(f,n),h=$t.filter(R=>f[R]&&!g[R]),y=AC(e,d.startContainer,o),b=qx(e,d.startContainer,a);let C=null;h.length>0?(C=Jv(e,d,h),y.length>0&&_p(e,C,y),b&&Sc(e,C)):y.length>0?(C=PC(e,d,y),b&&Sc(e,C)):b?C=Zx(e,d):d.deleteContents();const x=document.createElement("span");Qv(x,f,g),r&&_v(x,r),o!=null&&o.color&&Um(x,"color",o.color),o!=null&&o.backgroundColor&&Um(x,"backgroundColor",o.backgroundColor),a&&Ux(x,a),s&&zv(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&&((A=C.parentNode)==null||A.removeChild(C))):d.insertNode(v);const k=document.createRange();k.selectNodeContents(v),k.collapse(!1),u.removeAllRanges(),u.addRange(k)}const rs=["p","h1","h2","h3","h4","h5","h6"],tk=new Set(rs),th=new Set([...rs,"div"]),Ts=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),nk=()=>({tag:null,mixed:!1});function nh(e){return tk.has(e)}function rk(e){return nh(e)?e:e==="div"?"p":null}function ok(e){return e instanceof Element&&Ts.has(Le(e))}function rh(e){return e instanceof HTMLElement&&!kt(e)&&th.has(Le(e))}function Kc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Le(e);return th.has(t)||Ts.has(t)?!1:gn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function ik(e,t){let n=xi(t);for(;n&&n!==e;){if(Ts.has(Le(n)))return!0;n=n.parentElement}return!1}function oh(e,t){let n=xi(t);for(;n&&n!==e;){if(yg(n,e)){n=n.parentElement;continue}if(rh(n))return n;if(Ts.has(Le(n)))return null;n=n.parentElement}return null}function ak(e,t){const n=new Set,r=[];for(const o of Cu(t)){const a=oh(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function sk(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function lk(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&Kc(n[o-1]);)o-=1;for(;a<n.length-1&&Kc(n[a+1]);)a+=1;return n.slice(o,a+1)}function $c(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&kt(t)))return t;return null}function ck(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&&kt(r)?$c(e):r}return n.startContainer===t&&e!==t?$c(e):sk(e,n.startContainer)}function uk(e,t,n){const r=Eu(e);if(ik(e,t.startContainer))return!1;if(!$c(r)){const u=document.createElement(n);return u.appendChild(document.createElement("br")),r.appendChild(u),!0}const o=ck(r,e,t);if(!o||o instanceof HTMLElement&&kt(o)||ok(o)||rh(o)||!Kc(o))return!1;const a=lk(r,o),s=document.createElement(n);r.insertBefore(s,a[0]);for(const u of a)s.appendChild(u);return!0}function dk(e){const t=hn(e);if(!t)return nk();const n=Cu(t).map(o=>{const a=oh(e,o);return a?rk(Le(a)):null}),r=n[0];return n.every(o=>o===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function mk(e,t){if(!nh(t))return!1;const n=hn(e);if(!n)return!1;const r=co(e,n.startContainer,n.startOffset),o=co(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=ak(e,n);let d=!1;if(u.length===0)d=uk(e,n,t);else for(const f of u)Le(f)!==t&&(vu(f,t),d=!0);return wu(e,a,s),d}function Hu(e){if(!Kt(e))return null;const t=uo(e);if(!t)return null;const n=Le(t);return n==="ul"||n==="ol"?n:null}function ih(e){const t=En(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(Hu),r=n[0];return n.every(o=>o===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function fk(e,t,n){const r=[...e.children].filter(o=>xu(o));for(const o of r)t.insertBefore(o,n)}function ah(e){const t=uo(e),n=document.createElement("p");for(const f of[...e.attributes])n.setAttribute(f.name,f.value);for(n.style.marginLeft="",xt(n);e.firstChild&&!xu(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=Kt(a)?a.parentNode??a:a,u=Kt(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),fk(e,s,n.nextSibling),t.childElementCount===0&&t.remove(),n}function pk(e){if(Kt(e))return e;const t=vu(e,"li");return t.style.marginLeft="",xt(t),t}function sh(e,t){if(e.length===0)return!1;if(e.every(Kt)){const a=uo(e[0]);if(a&&e.every(s=>s.parentElement===a)&&[...a.children].every(u=>u instanceof HTMLElement&&e.includes(u)))return Le(a)===t?!1:(vu(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=Kt(a)?uo(a):null;o.appendChild(pk(a)),s&&s!==o&&s.childElementCount===0&&s.remove()}return!0}function lh(e){let t=!1;for(const n of[...e].reverse())Kt(n)&&(ah(n),t=!0);return t}function gk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;if(n.every(a=>Hu(a)===t))return lh(n);let o=!1;for(const a of Ip(n))sh(a,t)&&(o=!0);return o})}function hk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;if(t===null)return lh(n);if(n.every(a=>Hu(a)===t))return!1;let o=!1;for(const a of Ip(n))sh(a,t)&&(o=!0);return o})}const ch=40;function zu(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function uh(e,t){if(t<=0){e.style.marginLeft="",xt(e);return}e.style.marginLeft=`${t}px`}function bk(e){let t=e.previousElementSibling;for(;t;){if(Kt(t))return t;t=t.previousElementSibling}return null}function yk(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(Le(n)==="ul"||Le(n)==="ol"))return n}return null}function xk(e){const t=bk(e);if(!t)return!1;const n=uo(e);if(!n)return!1;const r=Le(n)==="ol"?"ol":"ul";let o=yk(t);return(!o||Le(o)!==r)&&(o=document.createElement(r),t.appendChild(o)),o.appendChild(e),!0}function Ck(e){const t=uo(e);if(!t)return!1;const n=t.parentElement;if(n&&Kt(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return ah(e),!0}function wk(e){return En(e).some(n=>Kt(n)||zu(n)>0)}function vk(e){return ar(e,()=>{const t=Er(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Kt(r)){xk(r)&&(n=!0);continue}uh(r,zu(r)+ch),n=!0}return n})}function kk(e){return ar(e,()=>{const t=En(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Kt(r)){Ck(r)&&(n=!0);continue}const o=zu(r);o<=0||(uh(r,Math.max(0,o-ch)),n=!0)}return n})}function Rs(e){return{colSpan:Math.max(1,e.colSpan||1),rowSpan:Math.max(1,e.rowSpan||1)}}function Ir(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 _t(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=Rs(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 os(e,t,n){var r;return((r=e.slots[t])==null?void 0:r[n])??null}function Qt(e,t){return e.unique.find(n=>n.cell===t)??null}function dh(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 mh(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 Sk(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=os(e,o,a);!s||n.has(s.cell)||(n.add(s.cell),r.push(s.cell))}return r}function fh(e,t){if(t.minRow>t.maxRow||t.minCol>t.maxCol)return null;const n=os(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=os(e,a,s);if(!u||dh(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 Pk(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=os(e,a,s);if(!u)return!1;if(u.cell!==t.cell&&dh(u,o))return!1}return!0}const ff=10,io=1,ao=50,Ak="1px solid #000",Tk="0.25em",Rk=new Set(["td","th"]);function ph(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=io&&t>=io&&e<=ao&&t<=ao}function wt(e,t){return Ku(e,t,n=>n instanceof HTMLTableElement)}function is(e,t){return Ku(e,t,n=>Hk(n))}function Dk(e,t){return Ku(e,t,n=>n instanceof HTMLTableRowElement)}function Ou(e){return wt(e,$u(e))}function bn(e){return is(e,$u(e))}function gh(e){return Dk(e,$u(e))}function Ik(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function wi(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return[];const r=is(e,n.startContainer),o=is(e,n.endContainer);if(!r)return[];if(!o||r===o)return[r];const a=wt(e,r);if(!a||wt(e,o)!==a)return[r];const s=_t(a),u=Qt(s,r),d=Qt(s,o);if(!u||!d)return[r];const f=mh([u,d]);if(!f)return[r];const g=Sk(s,f);return g.length>0?g:[r]}function jk(e,t){if(!ph(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(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(zk("td"));a.appendChild(d)}o.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(o),Uk(e,o);const s=o.querySelector("td, th");return s instanceof HTMLTableCellElement&&Ct(s),!0}function Uc(e,t){var h,y,b,C;const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=_t(r),a=Qt(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){Ir(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(Uu(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=Kk(d,o.colCount,u,a.originCol);return Ct(g||n),!0}function pf(e,t){var f,g,h,y;const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=_t(r),a=Qt(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){Ir(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=Uu(C);Vu(r,b,s,x),b===a.originRow&&(d=x)}return d&&Ct(d),!0}function Ek(e){var y,b;const t=bn(e);if(!t)return!1;const n=wt(e,t);if(!n)return!1;const r=_t(n),o=Qt(r,t);if(!o)return!1;if(r.rowCount<=1)return Vc(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?Ir(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)Ir(C.cell,C.colSpan,C.rowSpan-1),Vu(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=_t(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?Ct(h):f!=null&&f.cells[0]?Ct(f.cells[0]):Wk(n),!0}function Mk(e){var f,g,h;const t=bn(e);if(!t)return!1;const n=wt(e,t);if(!n)return!1;const r=_t(n),o=Qt(r,t);if(!o)return!1;if(r.colCount<=1)return Vc(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():Ir(y.cell,y.colSpan-1,y.rowSpan));const u=_t(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&&Ct(d),!0}function _k(e,t){const n=bn(e);if(!n)return!1;const r=wt(e,n);if(!r)return!1;const o=Ik(r),a=o.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(Ct(o[a-1]),{changed:!1});if(a<o.length-1)return Ct(o[a+1]),{changed:!1};const s=n.parentElement;if(!Uc(e,"below"))return!1;const u=s instanceof HTMLTableRowElement?s.nextElementSibling:null;return u instanceof HTMLTableRowElement&&u.cells[0]&&Ct(u.cells[0]),{changed:!0}}function Nk(e,t){return!Re(e,t)||t===e?!1:(Ct(t),!0)}function gf(e){return hh(e)!==null}function hf(e){const t=bn(e);if(!t)return!1;const n=Rs(t);return n.colSpan>1||n.rowSpan>1}function Lk(e){const t=hh(e);if(!t)return!1;const n=wt(e,t.origin.cell);return n?bh(n,t):!1}function Bk(e){const t=bn(e);if(!t)return!1;const n=wt(e,t);return n?yh(n,t):!1}function Fk(e,t,n){const r=bn(e);if(!r)return!1;const o=wt(e,r);if(!o)return!1;const a=_t(o),s=Qt(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||!Pk(a,s,u,d))return!1;if((s.colSpan>1||s.rowSpan>1)&&yh(o,r),u===1&&d===1)return Ct(r),!0;const f=_t(o),g=fh(f,{minRow:s.originRow,maxRow:s.originRow+d-1,minCol:s.originCol,maxCol:s.originCol+u-1});return g?bh(o,g):!0}function Ku(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function Hk(e){return Rk.has(e.tagName.toLowerCase())}function $u(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n.startContainer:null}function hh(e){const t=wi(e);if(t.length<2)return null;const n=wt(e,t[0]);if(!n)return null;const r=_t(n),o=[];for(const u of t){const d=Qt(r,u);if(!d)return null;o.push(d)}const a=mh(o);if(!a)return null;const s=fh(r,a);return!s||s.cells.length<2?null:s}function bh(e,t){const n=t.origin.cell,r=_t(e),o=t.cells.map(a=>Qt(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&&$k(n,a.cell);Ir(n,t.colSpan,t.rowSpan);for(const a of o)a.cell!==n&&a.cell.remove();return Ct(n),!0}function yh(e,t){const n=_t(e),r=Qt(n,t);if(!r||r.colSpan===1&&r.rowSpan===1)return!1;Ir(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||Vu(e,o,a,Uu(t));return Ct(t),!0}function zk(e){const t=document.createElement(e);return t.style.border=Ak,t.style.padding=Tk,t.appendChild(document.createElement("br")),t}function Uu(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 Ok(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function Vu(e,t,n,r){const o=e.rows[t];if(!o)return;const a=_t(e);let s=0;for(const u of Array.from(o.cells)){if(u===r)continue;const d=Qt(a,u);if(!d||d.originCol>=n)break;s+=1}Ok(o,s,r)}function Kk(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 bf(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 $k(e,t){if(!(e===t||bf(t)))for(bf(e)?e.innerHTML="":e.appendChild(document.createTextNode(" "));t.firstChild;)e.appendChild(t.firstChild)}function Uk(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),Vk(n)&&n.remove())}function Vk(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||!Re(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 Ct(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Wk(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const xh=["left","center","right","justify"];function Gk(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function as(e){return Gk(e.style.textAlign)}function Wc(e,t){const n=t??"left";return as(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 yf(e){const t=e[0];return e.every(n=>n===t)?{align:t,mixed:!1}:{align:null,mixed:!0}}function Ch(e){const t=wi(e);if(t.length>0)return yf(t.map(as));const n=En(e);return n.length===0?hn(e)?{align:"left",mixed:!1}:{align:null,mixed:!1}:yf(n.map(as))}function wh(e,t){return xh.includes(t)?ar(e,()=>{const n=wi(e);if(n.length>0){let a=!1;for(const s of n)Wc(s,t)&&(a=!0);return a}const r=Er(e);if(r.length===0)return!1;let o=!1;for(const a of r)Wc(a,t)&&(o=!0);return o}):!1}function Pr(){return{...Mr(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function Ma(e){const t=JC(e),n=Ch(e),r=ih(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function vh(e,t){let n=!1;return!t.alignMixed&&t.align&&wh(e,t.align)&&(n=!0),t.listMixed||hk(e,t.list)&&(n=!0),QC(e,t)&&(n=!0),n}function Zk(e,t){return vh(e,Gc(t))}function kh(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 Gc(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 _a(e){return e?Sr(e):""}function qk(e,t){return e.src===t.src&&e.opacity===t.opacity&&e.fit===t.fit&&e.position===t.position&&_a(e.width)===_a(t.width)&&_a(e.height)===_a(t.height)}function cc(e){const t=En(e);if(t.length===0)return mn();const n=t.map(Mg),r=n[0];return n.some(o=>!qk(o,r))?mn():r}function Yk(e,t){return ar(e,()=>{const n=Er(e);if(n.length===0)return!1;let r=!1;for(const o of n)_g(o,t)&&(r=!0);return r})}function Xk(){return{size:null,unit:lo,marks:Yn(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function ii(){return{font:Xk(),box:Mr(),backgroundImage:mn(),atRule:Wn()}}function Zc(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 Jk(e,t){if(!t)return e;const{margin:n,padding:r,...o}=t;return{...e,...o,margin:n?Zc(e.margin,n):e.margin,padding:r?Zc(e.padding,r):e.padding}}function Qk(e,t){if(!t)return e;const{marks:n,...r}=t;return{...e,...r,marks:n?{...e.marks,...n}:e.marks}}function eS(e,t){const{margin:n,...r}=t.atRule??{};return{font:Qk(e.font,t.font),box:Jk(e.box,t.box),backgroundImage:t.backgroundImage?{...e.backgroundImage,...t.backgroundImage}:e.backgroundImage,atRule:t.atRule?{...e.atRule,...r,margin:n?Zc(e.atRule.margin,n):e.atRule.margin}:e.atRule}}function tS(e){return e?!!(e.font||e.box||e.backgroundImage||e.atRule):!1}function xf(e,t){if(!tS(t))return e;const n=document.createElement("div");n.innerHTML=e;const r=eS(Qo(n),t);return qc(n,r).pageHtml}function nS(e){const t=e.style.fontSize,n=t?gu(t):null,r=n&&xs(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)??lo,marks:s,fontFamily:d||null,fontFamilyMixed:!1,fontColor:u?Ue(u):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function rS(e,t){const n=e.style.fontSize,r=t.size===null?null:Ar(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const o=pu(r.value,r.unit);return n===o?!1:(e.style.fontSize=o,!0)}function oS(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 yi(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function iS(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 aS(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 sS(e,t){let n=!1;return rS(e,t)&&(n=!0),oS(e,t)&&(n=!0),iS(e,t)&&(n=!0),aS(e,t.marks)&&(n=!0),n&&xt(e),n}function lS(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function Qo(e){const t=ut(e);if(!t)return ii();const n=yo(t);return{font:nS(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,breakInside:n.breakInside,breakInsideMixed:!1,breakAfter:n.breakAfter,breakAfterMixed:!1,breakBefore:n.breakBefore,breakBeforeMixed:!1},backgroundImage:z1(t),atRule:ot(e.innerHTML)}}function qc(e,t){const n=hn(e),r=n?co(e,n.startContainer,n.startOffset):null,o=n?co(e,n.endContainer,n.endOffset):null,a=ut(e),s=ju(e);ri(s);const u=sS(s,t.font),d=xo(s,lS(t)),f=O1(s,t.backgroundImage);Ss(e);const g=ot(e.innerHTML),h=Za(e.innerHTML,t.atRule),y=Xt(h);y!==Xt(e.innerHTML)&&(e.innerHTML=y),wo(e,h);const b=JSON.stringify(g)!==JSON.stringify(t.atRule);r!==null&&o!==null&&wu(e,Math.min(r,o),Math.max(r,o)),Ps(e);const C=Za(e.innerHTML,t.atRule);return{changed:!a||u||d||f||b,pageHtml:C}}function cS(e,t){const n=t??e.innerHTML,r=og(n);return fi(n)?(e.innerHTML=Xt(r),Ss(e),wo(e,r),{changed:!0,pageHtml:r}):{changed:!1,pageHtml:r}}const uS=/<script\b[^>]*>[\s\S]*?<\/script>/gi,dS=/^\s*javascript\s*:/i;function mS(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 Sh(e){const t=mS(e).replace(/[\u0000-\u001F\u007F\s]+/g,"");return dS.test(t)}function fS(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!Sh(r)&&!/url\s*\(\s*["']?\s*javascript:/i.test(r)}).join("; ")}function pS(e){const t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(const n of t)for(const r of[...n.attributes]){if(Sh(r.value)){n.removeAttribute(r.name);continue}if(r.name.toLowerCase()==="style"){const o=fS(r.value);o?o!==r.value&&n.setAttribute(r.name,o):n.removeAttribute(r.name)}}}function gS(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function hS(e){return e.body.innerHTML}function Yc(e){if(!e.trim())return e;const n=e.replace(uS,"");if(!/javascript\s*:/i.test(n))return n;const r=gS(n);return pS(r.body),hS(r)}function to(e){if(!e.trim())return e;const n=Zn(e);return n.length===1?Yc(e):Et(n.map(Yc))}const Wu="data-hover-html",bS="noopener noreferrer",yS="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)",xS="this._hoverBox&&this._hoverBox.remove()",CS=/^(#(?:[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 Ds(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function wS(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function gi(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&wS(n))return n;n=n.parentNode}return null}function Ph(e){return CS.test(e)}function vS(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&&Ph(r)?r:null}function Ah(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function kS(e){const t=e.getAttribute(Wu)??"",n=vS(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:Ah(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function Th(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!Re(e,n.commonAncestorContainer))return null;const r=gi(e,n.commonAncestorContainer);return r?kS(r):null}function SS(e){return Th(e)!==null}function PS(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Wu)}function AS(e,t){var r;if(PS(e),t.hoverMode==="html"){const o=t.hoverHtml.trim();if(!o)return;e.setAttribute(Wu,o),e.setAttribute("onmouseover",yS),e.setAttribute("onmouseout",xS);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!Ph(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function Gu(e,t){const n=Ds(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",bS)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":Ah(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),AS(e,n)}function TS(e,t){const n=new Set;for(const r of t){const o=gi(e,r);o&&!n.has(o)&&n.add(o)}for(const r of n)Mt(r)}function RS(e,t,n){fn(t);const r=vt(t).filter(u=>u.data.length>0);TS(e,r),r.length>0&&jr(r);const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);fn(a);const s=document.createElement("a");Gu(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 DS(e,t){const n=document.createElement("a");Gu(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 IS(e,t){const n=t.href.trim();if(!n)return!1;const r=Ds({...t,href:n}),o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!Re(e,a.commonAncestorContainer))return!1;const s=gi(e,a.startContainer),u=gi(e,a.endContainer);return s&&s===u?(Gu(s,r),!0):a.collapsed?DS(a,r):RS(e,a,r)}const jS=/^[A-Za-z][A-Za-z0-9_-]*$/,Rh="​";function Xc(e){var r;const t=Eu(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 ES(e){return new Set(Xc(e).map(t=>t.id))}function Dh(e,t){const n=e.trim();return n?jS.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function Cf(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 MS(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 _S(e,t){const n=t.trim();if(Dh(n,ES(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;const a=gi(e,o.startContainer);if(a)return MS(a,n),!0;if(o.collapsed)return Cf(o,n),!0;fn(o);const s=document.createElement("span");s.id=n;try{return o.surroundContents(s),!0}catch{return Cf(o,n),!0}}const ct="data-comment-thread",wf="wysiwyg-comment-anchor";function NS(){return`cmt_${crypto.randomUUID()}`}function LS(){return crypto.randomUUID()}const ss=20;function vf(e,t){if(!e)return null;const n=e instanceof Element?e:e.parentElement;if(!n)return null;const r=n.closest(`[${ct}]`);return r instanceof HTMLElement&&Re(t,r)?r:null}function kf(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 BS(e,t,n){const r=e.textContent??"",o=r.slice(Math.max(0,t-ss),t),a=r.slice(n,n+ss);return{prefix:o,suffix:a}}function FS(e,t){if(t.mode!=="visual")return null;const n=qn(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}=BS(e,t.start,t.end);return{type:"text",text:t.text,start:t.start,end:t.end,prefix:r,suffix:o}}function Sf(e,t){if(t.mode!=="visual")return null;const n=qn(e);if(n!=null&&n.hasAttribute(ct))return n.getAttribute(ct)??null;if(t.visualRange){const r=vf(t.visualRange.startContainer,e);if(r)return r.getAttribute(ct)??null;const o=vf(t.visualRange.endContainer,e);if(o)return o.getAttribute(ct)??null}return null}function Jc(e,t,n){if(!Re(e,n.commonAncestorContainer))return!1;fn(n);const r=document.createElement("span");r.setAttribute(ct,t);try{return n.surroundContents(r),!0}catch{const o=n.toString();if(!o)return!1;const a=document.createElement("span");return a.setAttribute(ct,t),a.textContent=o,n.deleteContents(),n.insertNode(a),!0}}function Ih(e,t){e.setAttribute(ct,t)}function HS(e,t,n){const r=qn(e);return r?(Ih(r,t),!0):n.visualRange?Jc(e,t,n.visualRange):!1}function zS(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 OS(e,t,n){if(n.type!=="text")return!1;if(n.start!==void 0&&n.end!==void 0){const s=kf(e,n.start,n.end);if(s&&s.toString()===n.text)return Jc(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-ss),s),f=r.slice(u,u+ss);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=kf(e,s,u);return g?Jc(e,t,g):!1}return!1}function KS(e,t){for(const n of t)if(!e.querySelector(`[${ct}="${n.id}"]`)){if(n.anchor.type==="image"){const o=zS(e,n.anchor);o&&Ih(o,n.id);continue}OS(e,n.id,n.anchor)}}function jh(e,t){for(const n of e.querySelectorAll(`[${ct}]`))n instanceof HTMLElement&&(t?n.classList.add(wf):n.classList.remove(wf))}function Eh(e,t){if(!t)return null;const n=t instanceof Element?t:t.parentElement;if(!n)return null;const r=n.closest(`[${ct}]`);return r instanceof HTMLElement&&Re(e,r)?r:null}function Pf(e,t){const n=e.querySelector(`[${ct}="${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 $S(e,t=[]){return{id:NS(),anchor:e,messages:t,createdAt:new Date().toISOString(),resolvedAt:null,resolvedBy:null}}function US(e,t){return{id:LS(),userId:e.userId,userName:e.userName,message:t.trim(),createdAt:new Date().toISOString()}}function VS(e,t,n){return e.map(r=>r.id===t?{...r,messages:[...r.messages,n]}:r)}function WS(e,t){return e.find(n=>n.id===t)}function Mh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return Re(e,n.commonAncestorContainer)?n:null}function GS(e){const t=Mh(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 _h(e){const t=Mh(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 ZS(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 Nh(e){const t=GS(e);return t?ZS(t):!1}async function qS(e){return await Nh(e)?_h(e):!1}const YS=new Set(["strong","b","em","i","u","s","strike","del"]),XS=["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 JS(e){for(const t of XS)e.style.removeProperty(t)}function QS(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!gn(r)){n=r;continue}if(or(r,n),YS.has(r.tagName.toLowerCase())){Mt(r);continue}if(JS(r),rr(r)){Mt(r);continue}n=r.isConnected?r:t}}function e0(e){const t=hn(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;fn(t);const r=vt(t).filter(o=>o.data.length>0);if(r.length===0)return!1;for(const o of r)QS(e,o);return jr(r),e.innerHTML!==n}function t0(e,t){return e.start===t.start&&e.end===t.end&&e.collapsed===t.collapsed}function n0(e){const t=oo(e),n=Wg(e),r=Sp(e),o=Ua(e,"color"),a=Ua(e,"backgroundColor"),s=Zg(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 r0(e,t){t.size!==null&&Fc(e,t.size,t.unit);const n=oo(e);for(const r of $t)t.marks[r]!==n[r]&&Oc(e,r);return t.fontFamilyMixed||kc(e,t.fontFamily),t.fontColorMixed||ni(e,"color",t.fontColor),t.highlightColorMixed||ni(e,"backgroundColor",t.highlightColor),!t.customCssMixed&&t.customCss&&Yg(e,t.customCss),!0}function za(){return typeof window<"u"&&"speechSynthesis"in window}function o0(e){const t=document.createElement("div");return t.innerHTML=e,(t.innerText??t.textContent??"").trim()}function Af(e,t){const n=e.text.trim();return n||o0(t)||null}function i0(e){const t=window.speechSynthesis,n=()=>{e()};return{toggle(r){if(!za())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 za()&&t.speaking},cancel(){za()&&t.speaking&&(t.cancel(),n())}}}const a0=5*1024*1024,s0="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",l0=new Set(["audio/mpeg","audio/mp3","audio/wav","audio/x-wav","audio/ogg","audio/aac","audio/webm","audio/mp4","audio/x-m4a"]),c0=new Set(["mp3","wav","ogg","aac","webm","m4a"]),u0=/^data:audio\/(?:mpeg|mp3|wav|x-wav|ogg|aac|webm|mp4|x-m4a)(?:;charset=[^;,]+)?;base64,/i,d0=/^(javascript|vbscript|file|blob):/i;function m0(e={}){return{src:"",title:"",...e}}function Zu(e){const t=e.trim();if(!t)return"empty";if(d0.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return u0.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 f0(e){return e.size>a0?"tooLarge":y0(e)?null:"type"}function p0(e){const t=f0(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const o=new FileReader;o.onload=()=>{const a=String(o.result??"");if(Zu(a)){r(new Error("invalid"));return}n(a)},o.onerror=()=>r(o.error??new Error("Failed to read file")),o.readAsDataURL(e)})}function g0(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%",h0(e,t.css)}function h0(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 b0(e,t){const n=m0(t);if(Zu(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=document.createElement("audio");return g0(a,n),o.insertNode(a),o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}function y0(e){const t=e.type.trim().toLowerCase();if(t&&l0.has(t))return!0;const n=x0(e.name);return!!(!t&&n&&c0.has(n))}function x0(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function Tf(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(jt);return o.body.innerHTML}function Lh(e,t,n){return Tf(e,n)===Tf(t,n)}const C0=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i;function Rf(e,t){var o,a;const n=(o=e.getAttribute(jt))==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 C0.test(r)?`embedded:${r}`:r.startsWith("blob:")&&n?`registry:${n}`:r?`url:${r}`:"empty"}function Bh(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html").body}const Df=/<tr(\s[^>]*)?>([\s\S]*?)<\/tr>/gi;function w0(e){const t=[];let n;for(Df.lastIndex=0;(n=Df.exec(e))!==null;)t.push(n[2]??"");return t}function v0(e,t){const n=document.createRange();n.selectNodeContents(e);const r=n.createContextualFragment(t);e.replaceChildren(...r.childNodes)}function k0(e,t){const n=w0(t);if(n.length===0)return;let r=0;e.querySelectorAll("tr").forEach(o=>{r>=n.length||(v0(o,n[r]),r+=1)})}function S0(e){const t=[e,...e.querySelectorAll("table, tbody, thead, tfoot")];for(const n of t)for(const r of[...n.childNodes])r instanceof Element&&Ru(r)&&r.remove()}function P0(e,t){const n=Bh(t);e.replaceChildren(...n.childNodes),/<tr[\s>]/i.test(t)&&(S0(e),k0(e,t))}function A0(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 T0(e,t){e.querySelectorAll("img").forEach((n,r)=>{const o=document.createElement("span");o.setAttribute(t,String(r)),n.replaceWith(o)})}function If(e,t){const n=e.cloneNode(!0);return T0(n,t),n.innerHTML}function R0(e,t,n){const r=Bh(t),o=[...e.querySelectorAll("img")],a=[...r.querySelectorAll("img")];if(o.length===0||o.length!==a.length)return!1;const s=o.map(h=>Rf(h,n)),u=a.map(h=>Rf(h,n));if(!s.every((h,y)=>h===u[y]))return!1;const d="data-wysiwyg-img-marker",f=If(e,d),g=If(r,d);if(f!==g)return!1;for(let h=0;h<o.length;h+=1)A0(o[h],a[h]);return!0}function ls(e,t,n={}){const{resolveDataUrl:r,hydrateEmbeddedImages:o}=n;return dg(t)?e.innerHTML===t?{changed:!1}:(P0(e,t),{changed:!0}):Lh(e.innerHTML,t,o)?{changed:!1}:e.innerHTML===t?{changed:!1}:R0(e,t,r)?{changed:!0}:(e.innerHTML=t,{changed:!0})}const Fh=/^(javascript|vbscript|file|blob):/i,D0=[/(?: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 I0(e={}){return{url:"",title:"",...e}}function j0(e={}){return{src:"",title:"",...e}}function Is(e){const t=e.trim();if(!t)return null;for(const n of D0){const r=t.match(n);if(r!=null&&r[1])return r[1]}return null}function Hh(e){return`https://www.youtube.com/embed/${e}`}function zh(e){const t=e.trim();return t?Fh.test(t)?"invalid":Is(t)?null:"invalid":"empty"}function E0(e){const t=e.trim();if(!t)return"empty";if(Fh.test(t))return"invalid";if(Is(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 Oh(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 Kh(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",Oh(e,n.css)}function M0(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%",Oh(e,t.css)}function _0(e,t){const n=I0(t);if(zh(n.url))return!1;const r=Is(n.url);if(!r)return!1;const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!Re(e,a.commonAncestorContainer))return!1;a.collapsed||a.deleteContents();const s=document.createElement("iframe");return Kh(s,Hh(r),n),a.insertNode(s),a.setStartAfter(s),a.collapse(!0),o.removeAllRanges(),o.addRange(a),!0}function N0(e,t){const n=j0(t);if(E0(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!Re(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=Is(n.src);if(a){const s=document.createElement("iframe");Kh(s,Hh(a),{title:n.title,css:n.css}),o.insertNode(s),o.setStartAfter(s)}else{const s=document.createElement("video");M0(s,n),o.insertNode(s),o.setStartAfter(s)}return o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}const L0=new Set(["p","h1","h2","h3","h4","h5","h6"]),B0=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function $h(e,t){var a;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!Re(e,r.commonAncestorContainer))return!1;r.collapsed||r.deleteContents();const o=F0(e,r.startContainer);if(o){const s=H0(o,r);return(a=o.parentNode)==null||a.insertBefore(t,s),Ef(t),!0}return r.insertNode(t),z0(e,t),$0(t),Ef(t),!0}function F0(e,t){let n=xi(t);for(;n&&n!==e;){const r=Le(n);if(L0.has(r)&&n instanceof HTMLElement)return n;if(B0.has(r))return null;n=n.parentElement}return null}function H0(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),jf(e),jf(o),(a=e.parentNode)==null||a.insertBefore(o,e.nextSibling),o}function z0(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!O0(n))return;or(n,t),Mt(n)}}function O0(e){const t=Le(e);return gn(e)||t==="a"}function jf(e){K0(e)&&e.appendChild(document.createElement("br"))}function K0(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 $0(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 Ef(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 U0="1em 0",V0="1px solid #d0d0d0";function W0(){const e=document.createElement("hr");return e.style.margin=U0,e.style.border="0",e.style.borderTop=V0,e}function G0(e){return $h(e,W0())}const Z0="1.5em 0",q0="2px dashed #bbb",Y0="data-wysiwyg-page-break";function X0(){const e=document.createElement("div");return e.setAttribute(Y0,""),e.style.display="block",e.style.clear="both",e.style.breakAfter="page",e.style.pageBreakAfter="always",e.style.margin=Z0,e.style.border="0",e.style.borderTop=q0,e.style.height="0",e}function J0(e){return $h(e,X0())}const jn=16;function Mf(e){return Math.min(po.px.max,Math.max(jn,e))}function Q0(e){return e.width>0&&e.height>0?e.width/e.height:1}function eP(e,t){const n=Math.max(jn,jn*t),r=Math.min(po.px.max,po.px.max*t),o=Math.min(r,Math.max(n,e));return{width:o,height:o/t}}function tP(e,t){const n=Math.max(jn,jn/t),r=Math.min(po.px.max,po.px.max/t),o=Math.min(r,Math.max(n,e));return{width:o*t,height:o}}function nP(e,t,n){const r=Q0(t);return e==="e"?eP(t.width+n.x,r):e==="s"?tP(t.height+n.y,r):{width:Mf(t.width+n.x),height:Mf(t.height+n.y)}}function rP(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:jn,height:r>0?r:jn}}function oP(e,t,n){const r=go(Math.max(jn,t),"px"),o=go(Math.max(jn,n),"px");return!r||!o?!1:Ag(e,{...Pg(e),sizeMode:"lock",width:r,height:o})}function iP(e={}){return{border:{...Su},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function aP(e){const t=yo(e);return{border:t.border,borderCollapse:uP(e),borderSpacing:Uh(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:pt(e.style.width)}}function sP(e,t){let n=xo(e,{...Mr(),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 dP(e,t.borderCollapse)&&(n=!0),mP(e,t.borderCollapse,t.borderSpacing)&&(n=!0),fP(e,t.width)&&(n=!0),n&&xt(e),n}function lP(e){const t=Ou(e);return t?aP(t):null}function cP(e,t){const n=Ou(e);return n?sP(n,t):!1}function uP(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function dP(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function Uh(e){const t=e.style.borderSpacing.trim();return t?pt(t.split(/\s+/)[0]??""):null}function mP(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?ir(n):null,o=Uh(e);return Ot(o,r)?!1:(r?e.style.borderSpacing=_e(r):e.style.removeProperty("border-spacing"),!0)}function fP(e,t){const n=t?ir(t):null,r=pt(e.style.width);return Ot(r,n)?!1:(n?e.style.width=_e(n):e.style.removeProperty("width"),!0)}const js=["top","middle","bottom","baseline"],pP=new Set(js);function gP(e={}){return{backgroundColor:null,color:null,padding:{...Jt},textAlign:null,verticalAlign:null,width:null,colSpan:1,rowSpan:1,...e}}function hP(e){const t=yo(e);return{backgroundColor:t.backgroundColor,color:Vh(e),padding:t.padding,textAlign:wP(e),verticalAlign:Wh(e),width:pt(e.style.width),...Rs(e)}}function bP(e,t){let n=xo(e,{...Mr(),margin:{...Jt},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 CP(e,t.color)&&(n=!0),Wc(e,t.textAlign)&&(n=!0),vP(e,t.verticalAlign)&&(n=!0),kP(e,t.width)&&(n=!0),n&&xt(e),n}function yP(e){const t=bn(e);return t?hP(t):null}function xP(e,t){const n=wi(e);if(n.length===0)return!1;let r=!1;for(const a of n)bP(a,t)&&(r=!0);const o=bn(e);if(o){const a=Rs(o);(a.colSpan!==t.colSpan||a.rowSpan!==t.rowSpan)&&Fk(e,t.colSpan,t.rowSpan)&&(r=!0)}return r}function Vh(e){const t=e.style.color;return t?Ue(t):null}function CP(e,t){const n=t?Ue(t):null;return Vh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function wP(e){const t=as(e);return t==="left"?null:t}function Wh(e){const t=e.style.verticalAlign.trim().toLowerCase();return pP.has(t)?t:null}function vP(e,t){return Wh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function kP(e,t){const n=t?ir(t):null,r=pt(e.style.width);return Ot(r,n)?!1:(n?e.style.width=_e(n):e.style.removeProperty("width"),!0)}const SP=new Set(js);function PP(e={}){return{backgroundColor:null,color:null,padding:{...Jt},height:null,verticalAlign:null,...e}}function AP(e){const t=e.cells[0],n=t?yo(t).padding:{...Jt};return{backgroundColor:Gh(e),color:Zh(e),padding:n,height:pt(e.style.height),verticalAlign:qh(e)}}function TP(e,t){let n=!1;IP(e,t.backgroundColor)&&(n=!0),jP(e,t.color)&&(n=!0),MP(e,t.height)&&(n=!0),EP(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))xo(r,{...Mr(),margin:{...Jt},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&&xt(e),n}function RP(e){const t=gh(e);return t?AP(t):null}function DP(e,t){const n=gh(e);return n?TP(n,t):!1}function Gh(e){const t=e.style.backgroundColor;return t?Ue(t):null}function IP(e,t){const n=t?Ue(t):null;return Gh(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Zh(e){const t=e.style.color;return t?Ue(t):null}function jP(e,t){const n=t?Ue(t):null;return Zh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function qh(e){const t=e.style.verticalAlign.trim().toLowerCase();return SP.has(t)?t:null}function EP(e,t){return qh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function MP(e,t){const n=t?ir(t):null,r=pt(e.style.height);return Ot(r,n)?!1:(n?e.style.height=_e(n):e.style.removeProperty("height"),!0)}const _P=1e3;function NP(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function LP({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(()=>NP(u,d)))},_P);return()=>{window.clearInterval(s)}},[a])}function BP(){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:mn()}),[C,x]=l.useState({open:!1,value:""}),[v,k]=l.useState({open:!1,tab:"font",paragraphTab:"spacing",value:ii()}),[S,A]=l.useState(!1),[R,T]=l.useState({open:!1}),[D,P]=l.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[j,L]=l.useState({open:!1,existingIds:[]}),[V,E]=l.useState({open:!1}),[N,K]=l.useState({open:!1}),[G,Z]=l.useState({open:!1}),[ae,q]=l.useState({open:!1,tab:"general",value:Sg(),aspectRatio:1}),[ee,se]=l.useState({open:!1}),[me,ne]=l.useState({open:!1,value:iP()}),[M,re]=l.useState({open:!1,value:gP()}),[O,ie]=l.useState({open:!1,value:PP()}),[Ee,He]=l.useState({open:!1,topicId:"getStarted"}),[$e,Ve]=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:A,customStyleDialog:R,setCustomStyleDialog:T,linkDialog:D,setLinkDialog:P,bookmarkDialog:j,setBookmarkDialog:L,imageDialog:V,setImageDialog:E,audioDialog:N,setAudioDialog:K,youtubeDialog:G,setYoutubeDialog:Z,imageProperties:ae,setImageProperties:q,tableDialog:ee,setTableDialog:se,tableProperties:me,setTableProperties:ne,cellProperties:M,setCellProperties:re,rowProperties:O,setRowProperties:ie,helpDialog:Ee,setHelpDialog:He,aboutDialogOpen:$e,setAboutDialogOpen:Ve}}const _f={changed:!1,pages:[],joined:"",changedIndices:[]};function Nf(e){return{changed:e.changed,pages:e.pages,joined:Et(e.pages),changedIndices:e.changedIndices}}function Lf(e,t,n){return n.size===0?t:t.map((r,o)=>n.has(o)&&e[o]!==void 0&&e[o]!==r?e[o]:r)}function FP({enabled:e,pagesProp:t,defaultPages:n}){const r=e&&t!==void 0,o=l.useMemo(()=>t!==void 0?Gn(t):void 0,[t]),[a,s]=l.useState(()=>({pages:Gn(n),revision:0})),u=l.useRef(o??Gn(n)),d=l.useRef(new Set),f=l.useRef(t);l.useEffect(()=>{if(!e||!r||o===void 0||f.current===t&&kr(u.current,o))return;f.current=t;const k=Lf(u.current,o,d.current),S=oc(u.current,k);if(u.current=S.pages,!!S.changed){for(const A of S.changedIndices)d.current.add(A);s(A=>({pages:S.pages,revision:A.revision+1}))}},[e,r,o,t]);const g=l.useMemo(()=>{if(!e)return[];if(r&&o!==void 0){const k=Lf(u.current,o,d.current),S=oc(u.current,k);return u.current=S.pages,S.pages}return a.pages},[e,r,o,a.pages,a.revision]),h=l.useCallback((k,S)=>{if(!e)return _f;const A=r?u.current:a.pages,R=oc(A,k);if(!R.changed)return Nf(R);for(const T of R.changedIndices)d.current.add(T);return S!==void 0&&d.current.add(S),r?u.current=R.pages:s(T=>({pages:R.pages,revision:T.revision+1})),Nf(R)},[e,a.pages,r]),y=l.useCallback((k,S)=>h(k,S==null?void 0:S.editedIndex),[h]),b=l.useCallback((k,S,A)=>{if(!e)return _f;const R=r?u.current:a.pages,T=Ec(R,k,S);return T.changed?h(T.pages,(A==null?void 0:A.editedIndex)??k):{changed:!1,pages:R,joined:Et(R),changedIndices:[]}},[h,e,a.pages,r]),C=l.useCallback(k=>h(Gn(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(()=>Et(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 Oa({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 Yh="commspliant-html-editor.darkMode";function HP(e){return typeof e=="boolean"?e:null}function Bf(){try{const e=localStorage.getItem(Yh);return e?HP(JSON.parse(e)):null}catch{return null}}function zP(e){try{localStorage.setItem(Yh,JSON.stringify(e))}catch{}}const Xh="commspliant-html-editor.pageZoom",OP=new Set(["fitWidth","fitPage"]);function KP(e){return typeof e=="string"&&OP.has(e)||typeof e=="number"&&yv.includes(e)?e:null}function $P(){try{const e=localStorage.getItem(Xh);return e?KP(JSON.parse(e)):null}catch{return null}}function UP(e){try{localStorage.setItem(Xh,JSON.stringify(e))}catch{}}const Jh="commspliant-html-editor.toolbarPosition",VP=["top","left","right","bottom"];function Qh(e){return typeof e=="string"&&VP.includes(e)?e:null}function Ff(){try{const e=localStorage.getItem(Jh);return e?Qh(JSON.parse(e)):null}catch{return null}}function WP(e){try{localStorage.setItem(Jh,JSON.stringify(e))}catch{}}function GP({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||!Ea(y.dataTransfer)||(y.preventDefault(),o.current+=1,r(!0))},[]),f=l.useCallback(y=>{!a.current||!Ea(y.dataTransfer)||(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="copy"))},[]),g=l.useCallback(y=>{if(!a.current||!Ea(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||!Ea(y.dataTransfer))return;y.preventDefault(),u();const b=X1(y.dataTransfer);b&&Fu(b).then(C=>{a.current&&s.current(C)},()=>{})},[u]);return{dragging:n,onDragEnter:d,onDragOver:f,onDragLeave:g,onDrop:h}}const ZP={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:nx,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:Yy,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:ti,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},deletePage:{id:"deletePage",command:"deletePage",icon:ti,labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:"canDeletePage"}}},eb=400,cs=100,tb=2e7;function qP(e){let t=[],n=0,r=e,o=[],a=0,s=!1,u=!1,d=0;function f(){if(t.length>cs){const v=t.splice(0,t.length-cs);for(const k of v)n-=k.length}for(;t.length>1&&n+a>tb;){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(),A=(k==null?void 0:k.coalesce)===!0;if(A&&u&&S-d<eb){r=v,d=S,o.length>0&&h();return}g(r),r=v,h(),d=S,u=A}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 Xe(e){return e.map(t=>t)}function xr(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 YP(e){let t=[],n=0,r=Xe(e),o=[],a=0,s=!1,u=!1,d=null,f=0;function g(){if(t.length>cs){const D=t.splice(0,t.length-cs);for(const P of D)n-=xr(P)}for(;t.length>1&&n+a>tb;){const D=t.shift();D&&(n-=xr(D))}}function h(D){t.push(D),n+=xr(D),g()}function y(D){o.push(D),a+=xr(D)}function b(){for(const D of o)a-=xr(D);o=[],a=0}function C(){u=!1,d=null}function x(D,P,j){if(s){const K=Xe(r);K[D]=P,r=K,s=!1;return}if(r[D]===P)return;const L=Date.now(),V=(j==null?void 0:j.coalesce)===!0,E=V&&u&&d===D&&L-f<eb,N=Xe(r);if(N[D]=P,E){r=N,f=L;return}h({type:"pageEdit",pageIndex:D,before:r[D]??""}),r=N,b(),f=L,u=V,d=D}function v(D,P){if(s){r=Xe(P),s=!1;return}kr(r,P)||(h({type:"insertPage",index:D,page:P[D]??""}),r=Xe(P),b(),C())}function k(D,P,j){if(s){r=Xe(j),s=!1;return}kr(r,j)||(h({type:"deletePage",index:D,page:P}),r=Xe(j),b(),C())}function S(D){if(s){r=Xe(D),s=!1;return}kr(r,D)||(h({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D),b(),C())}function A(D){if(s){r=Xe(D),s=!1;return}kr(r,D)||(r=Xe(D))}function R(){if(t.length===0)return null;C();const D=t.pop();switch(n-=xr(D),D.type){case"pageEdit":{const P=r[D.pageIndex]??"";y({type:"pageEdit",pageIndex:D.pageIndex,before:P}),r[D.pageIndex]=D.before;break}case"insertPage":{const P=r[D.index]??"";y({type:"insertPage",index:D.index,page:P}),r.splice(D.index,1);break}case"deletePage":{y({type:"deletePage",index:D.index,page:D.page}),r.splice(D.index,0,D.page);break}case"replaceAll":{y({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D.beforePages);break}}return g(),Xe(r)}function T(){if(o.length===0)return null;C();const D=o.pop();switch(a-=xr(D),D.type){case"pageEdit":{const P=r[D.pageIndex]??"";h({type:"pageEdit",pageIndex:D.pageIndex,before:P}),r[D.pageIndex]=D.before;break}case"insertPage":{h({type:"insertPage",index:D.index,page:D.page}),r.splice(D.index,0,D.page);break}case"deletePage":{const P=r[D.index]??"";h({type:"deletePage",index:D.index,page:P}),r.splice(D.index,1);break}case"replaceAll":{h({type:"replaceAll",beforePages:Xe(r)}),r=Xe(D.beforePages);break}}return Xe(r)}return{getPresent:()=>r,recordPageEdit:x,recordInsertPage:v,recordDeletePage:k,recordReplaceAll:S,undo:R,redo:T,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncPages:D=>S(D),applyPresent:A,markApplying:()=>{s=!0}}}function Ht(e){return typeof e=="object"&&e!==null&&"recordPageEdit"in e&&typeof e.recordPageEdit=="function"}const XP='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',JP='[role="listbox"], [data-color-picker]';function Ye(e,{open:t,onClose:n,focusableSelector:r=XP,escapeIgnoreSelectors:o=JP}){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 tr(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function us(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):tr(e,t):""}const dn="fullscreen",Qc="commspliant-html-editor.toolbarCustomization";function eu(e){const t=e.filter(n=>n!==dn);return e.includes(dn)?[...t,dn]:t}function qu(e,t){if(!t||t.length===0)return eu(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 eu(a)}function QP(e,t){const n=new Map(e.map(s=>[s.id,s])),r=qu(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 eA(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 tA(){try{const e=localStorage.getItem(Qc);return e?eA(JSON.parse(e)):null}catch{return null}}function nA(e){try{if(!e){localStorage.removeItem(Qc);return}localStorage.setItem(Qc,JSON.stringify(e))}catch{}}function Yu(e,t){return qu(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function rA(e,t,n,r){const o=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?o.delete(n):o.add(n),{groupOrder:Yu(e,t),hiddenItemIds:[...o]}}function nb(e,t,n,r){const o=Yu(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===dn||r===dn)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:eu(d),hiddenItemIds:a}}function Hf(e,t,n,r){const o=Yu(e,t),a=o.filter(d=>d!==dn),s=a.indexOf(n),u=s+r;return s<0||u<0||u>=a.length?{groupOrder:o,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:nb(e,t,n,a[u])}const oA="_backdrop_11w4e_1",iA="_dialog_11w4e_12",aA="_header_11w4e_31",sA="_body_11w4e_39",lA="_group_11w4e_49",cA="_groupDragging_11w4e_55",uA="_groupDropTarget_11w4e_59",dA="_groupHeader_11w4e_64",mA="_groupTitle_11w4e_72",fA="_dragHandle_11w4e_77",pA="_moveButton_11w4e_78",gA="_items_11w4e_119",hA="_item_11w4e_119",bA="_itemIcon_11w4e_135",yA="_itemTitle_11w4e_144",xA="_itemCheckbox_11w4e_151",CA="_actions_11w4e_155",wA="_action_11w4e_155",vA="_spinnerWrap_11w4e_191",kA="_spinner_11w4e_191",ze={backdrop:oA,dialog:iA,header:aA,body:sA,group:lA,groupDragging:cA,groupDropTarget:uA,groupHeader:dA,groupTitle:mA,dragHandle:fA,moveButton:pA,items:gA,item:hA,itemIcon:bA,itemTitle:yA,itemCheckbox:xA,actions:CA,action:wA,spinnerWrap:vA,spinner:kA};function SA(){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 PA({open:e,catalog:t,groups:n,settings:r,loading:o=!1,busy:a=!1,disabled:s,onChange:u,onReset:d,onClose:f}){const g=X(),h=l.useId(),y=l.useRef(null),[b,C]=l.useState(null),[x,v]=l.useState(null),k=qu(n.map(E=>E.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),A=new Map(n.map(E=>[E.id,E])),R=k.map(E=>A.get(E)).filter(E=>!!E),T=s||a||o;if(l.useEffect(()=>{e||(C(null),v(null))},[e]),Ye(y,{open:e,onClose:f,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const D=R.map(E=>E.id).filter(E=>E!==dn),P=(E,N)=>{if(T||N===dn){E.preventDefault();return}E.dataTransfer.setData("text/plain",N),E.dataTransfer.effectAllowed="move",C(N)},j=(E,N)=>{T||N===dn||!b||b===N||(E.preventDefault(),E.dataTransfer&&(E.dataTransfer.dropEffect="move"),v(N))},L=(E,N)=>{var G;E.preventDefault();const K=((G=E.dataTransfer)==null?void 0:G.getData("text/plain"))||b;C(null),v(null),!(!K||K===N||T)&&u(nb(r,n,K,N))},V=()=>{C(null),v(null)};return i.jsx(Pe,{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:E=>E.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"})}):R.map(E=>{const N=t.groups[E.id],K=N?tr(g,N):E.id,G=E.id===dn,Z=D.indexOf(E.id);return i.jsxs("section",{className:[ze.group,b===E.id?ze.groupDragging:"",x===E.id?ze.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":E.id,"aria-label":K,onDragOver:ae=>j(ae,E.id),onDrop:ae=>L(ae,E.id),onDragLeave:()=>{x===E.id&&v(null)},children:[i.jsxs("div",{className:ze.groupHeader,children:[i.jsx("button",{type:"button",className:ze.dragHandle,draggable:!T&&!G,disabled:T||G,"aria-label":g("customizeToolbarDragHandle"),onDragStart:ae=>P(ae,E.id),onDragEnd:V,children:i.jsx(SA,{})}),i.jsx("span",{className:ze.groupTitle,children:K}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:T||G||Z<=0,"aria-label":g("customizeToolbarMoveUp"),onClick:()=>u(Hf(r,n,E.id,-1)),children:"↑"}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:T||G||Z<0||Z>=D.length-1,"aria-label":g("customizeToolbarMoveDown"),onClick:()=>u(Hf(r,n,E.id,1)),children:"↓"})]}),i.jsx("div",{className:ze.items,children:E.items.map(ae=>{const q=t.items[ae];if(!q)return null;const ee=q.icon,se=tr(g,q),me=`${h}-${E.id}-${ae}`,ne=!S.has(ae);return i.jsxs("label",{className:ze.item,htmlFor:me,children:[i.jsx("span",{className:ze.itemIcon,"aria-hidden":"true",children:ee?i.jsx(ee,{}):se.slice(0,2)}),i.jsx("span",{className:ze.itemTitle,children:se}),i.jsx("input",{id:me,className:ze.itemCheckbox,type:"checkbox",checked:ne,disabled:T,"aria-label":`${se}: ${g("customizeToolbarItemVisible")}`,onChange:M=>u(rA(r,n,ae,M.target.checked))})]},ae)})})]},E.id)})}),i.jsxs("div",{className:ze.actions,children:[i.jsx("button",{type:"button",className:ze.action,disabled:T,onClick:d,children:g("customizeToolbarDialogReset")}),i.jsx("button",{type:"button",className:ze.action,"aria-label":g("customizeToolbarDialogCloseAria"),onClick:f,children:g("customizeToolbarDialogClose")})]})]})})})}function AA(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 TA={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:Qy,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:Ky,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:Zy,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},rb=4;function RA({anchorRect:e,floatingWidth:t,floatingHeight:n,pad:r=rb,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 vo(e,t,n,{pad:r=rb,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(RA({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 DA="_toolbar_a9bu4_1",IA="_menuBar_a9bu4_35",jA="_menuBarDesktop_a9bu4_43",EA="_brandMark_a9bu4_49",MA="_brandMarkIcon_a9bu4_56",_A="_menuBarCompact_a9bu4_68",NA="_menuWrap_a9bu4_91",LA="_menuButton_a9bu4_97",BA="_iconButton_a9bu4_98",FA="_menuItem_a9bu4_99",HA="_hamburgerButton_a9bu4_144",zA="_iconNav_a9bu4_151",OA="_iconNavMain_a9bu4_162",KA="_iconNavEnd_a9bu4_171",$A="_iconGroup_a9bu4_187",UA="_tooltipTrigger_a9bu4_281",VA="_menu_a9bu4_35",WA="_submenuWrap_a9bu4_311",GA="_submenu_a9bu4_311",ZA="_submenuTrigger_a9bu4_321",qA="_menuOverlay_a9bu4_336",YA="_menuOverlayHeader_a9bu4_348",XA="_menuOverlayTitle_a9bu4_358",JA="_menuOverlayBody_a9bu4_364",QA="_menuSeparator_a9bu4_415",eT="_icon_a9bu4_98",tT="_tooltip_a9bu4_281",nT="_tooltipElevated_a9bu4_510",ce={toolbar:DA,menuBar:IA,menuBarDesktop:jA,brandMark:EA,brandMarkIcon:MA,menuBarCompact:_A,menuWrap:NA,menuButton:LA,iconButton:BA,menuItem:FA,hamburgerButton:HA,iconNav:zA,iconNavMain:OA,iconNavEnd:KA,iconGroup:$A,tooltipTrigger:UA,menu:VA,submenuWrap:WA,submenu:GA,submenuTrigger:ZA,menuOverlay:qA,menuOverlayHeader:YA,menuOverlayTitle:XA,menuOverlayBody:JA,menuSeparator:QA,icon:eT,tooltip:tT,tooltipElevated:nT},rT=400,zf=6,uc=4;function nr({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)},rT)},[b]),x=l.useCallback(()=>{const k=o.current,S=a.current;if(!k||!S)return;const A=k.getBoundingClientRect(),R=S.offsetWidth,T=S.offsetHeight;let D=A.bottom+zf;D+T>window.innerHeight-uc&&(D=A.top-zf-T);let P=A.left+A.width/2-R/2;P=Math.min(Math.max(P,uc),window.innerWidth-R-uc),y({top:D,left:P})},[]);l.useEffect(()=>()=>b(),[b]),l.useEffect(()=>{const k=o.current;if(!k)return;const S=()=>{d.current=!0,C(!0)},A=()=>{d.current=!1,C(!1)};return k.addEventListener("focusin",S),k.addEventListener("focusout",A),()=>{k.removeEventListener("focusin",S),k.removeEventListener("focusout",A)}},[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?`${ce.tooltipTrigger} ${n}`:ce.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(Pe,{children:i.jsx("span",{ref:a,className:r?`${ce.tooltip} ${ce.tooltipElevated}`:ce.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const Of=8,Kf=["#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"],oT=8;let tu=[];const nu=new Set;function $f(){return tu}function iT(e){const t=Ue(e);t&&(tu=[t,...tu.filter(n=>n!==t)].slice(0,oT),nu.forEach(n=>n()))}function aT(e){return nu.add(e),()=>{nu.delete(e)}}function Na(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 dc({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 mc({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 ob(){return typeof window<"u"&&"EyeDropper"in window}async function sT(){if(!ob())return null;const e=window.EyeDropper;try{const t=await new e().open();return Ue(t.sRGBHex)}catch{return null}}const lT="_picker_ag1yo_1",cT="_none_ag1yo_12",uT="_customToggle_ag1yo_13",dT="_eyedrop_ag1yo_14",mT="_swatch_ag1yo_48",fT="_field_ag1yo_49",pT="_grid_ag1yo_54",gT="_recents_ag1yo_55",hT="_sectionLabel_ag1yo_84",bT="_custom_ag1yo_13",yT="_sv_ag1yo_95",xT="_svThumb_ag1yo_105",CT="_hue_ag1yo_116",wT="_rgbRow_ag1yo_155",vT="_hexRow_ag1yo_156",rt={picker:lT,none:cT,customToggle:uT,eyedrop:dT,swatch:mT,field:fT,grid:pT,recents:gT,sectionLabel:hT,custom:bT,sv:yT,svThumb:xT,hue:CT,rgbRow:wT,hexRow:vT};function kT(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 Xu({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:o,menu:a=!1,fallbackCustom:s="#000000",onChange:u,onCommit:d}){const f=X(),g=l.useId(),h=a?"menuitemradio":"option",y=t?null:e,b=Na(y??s)??{r:0,g:0,b:0},[C,x]=l.useState(!1),[v,k]=l.useState(()=>dc(b)),[S,A]=l.useState(()=>({r:String(b.r),g:String(b.g),b:String(b.b)})),[R,T]=l.useState(()=>Cr(b.r,b.g,b.b)),[D,P]=l.useState(()=>[...$f()]),j=l.useRef(null),L=l.useRef(Cr(b.r,b.g,b.b));l.useEffect(()=>aT(()=>P([...$f()])),[]),l.useEffect(()=>{const M=Na(y??s);if(!M)return;const re=dc(M);k(re),A({r:String(M.r),g:String(M.g),b:String(M.b)}),T(Cr(M.r,M.g,M.b))},[y,s]);const V=(M,re,O)=>{M&&(L.current=M),O&&M&&iT(M),u(M),re&&(d==null||d(M))},E=(M,re,O)=>{const ie=Cr(M.r,M.g,M.b);k(dc(M)),A({r:String(M.r),g:String(M.g),b:String(M.b)}),T(ie),V(ie,re,O)},N=(M,re,O)=>{const ie=mc(M),Ee=Cr(ie.r,ie.g,ie.b);k(M),A({r:String(ie.r),g:String(ie.g),b:String(ie.b)}),T(Ee),V(Ee,re,O)},K=M=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(M.key))return;const O=[...M.currentTarget.querySelectorAll("button")],ie=O.findIndex($e=>$e===document.activeElement);if(ie<0)return;M.preventDefault();const Ee=M.key==="ArrowLeft"?-1:M.key==="ArrowRight"?1:M.key==="ArrowUp"?-Of:Of,He=O[Math.max(0,Math.min(O.length-1,ie+Ee))];He==null||He.focus()},G=(M,re)=>{const O=j.current;if(!O||o)return;const ie=O.getBoundingClientRect(),Ee=Math.max(0,Math.min(1,(M.clientX-ie.left)/ie.width)),He=Math.max(0,Math.min(1,1-(M.clientY-ie.top)/ie.height));N({h:v.h,s:Ee,v:He},re,re)},Z=M=>{o||(M.currentTarget.setPointerCapture(M.pointerId),G(M,!1))},ae=mc({h:v.h,s:1,v:1}),q=Cr(ae.r,ae.g,ae.b),ee=mc(v),se=Cr(ee.r,ee.g,ee.b),me=new Set(Kf),ne=D.filter(M=>!me.has(M));return i.jsxs("div",{className:rt.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[i.jsx("button",{type:"button",className:rt.none,role:h,"aria-checked":a?y===null&&!t:void 0,"aria-selected":a?void 0:y===null&&!t,disabled:o,onClick:()=>V(null,!0,!1),children:n}),i.jsx("div",{className:rt.grid,role:a?"group":"none",onKeyDown:K,children:Kf.map(M=>{const re=y===M;return i.jsx("button",{type:"button",className:rt.swatch,role:h,"aria-label":M,"aria-checked":a?re:void 0,"aria-selected":a?void 0:re,disabled:o,style:{backgroundColor:M},onMouseDown:O=>O.preventDefault(),onClick:()=>V(M,!0,!1)},M)})}),ne.length>0?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:rt.sectionLabel,children:f("colorRecent")}),i.jsx("div",{className:rt.recents,role:a?"group":"none","aria-label":f("colorRecent"),children:ne.map(M=>i.jsx("button",{type:"button",className:rt.swatch,role:h,"aria-label":M,"aria-checked":a?y===M:void 0,"aria-selected":a?void 0:y===M,disabled:o,style:{backgroundColor:M},onMouseDown:re=>re.preventDefault(),onClick:()=>V(M,!0,!1)},M))})]}):null,i.jsx("button",{type:"button",className:rt.customToggle,disabled:o,"aria-expanded":C,onClick:()=>x(M=>!M),children:f("colorCustom")}),C?i.jsxs("div",{className:rt.custom,children:[i.jsx("div",{ref:j,className:rt.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${q})`},onPointerDown:Z,onPointerMove:M=>{M.currentTarget.hasPointerCapture(M.pointerId)&&G(M,!1)},onPointerUp:M=>{G(M,!0)},children:i.jsx("span",{className:rt.svThumb,style:{left:`${v.s*100}%`,top:`${(1-v.v)*100}%`}})}),i.jsx("input",{className:rt.hue,type:"range",min:0,max:360,value:Math.round(v.h),disabled:o,"aria-label":f("colorCustom"),onChange:M=>N({...v,h:Number(M.target.value)},!1,!1),onPointerUp:()=>V(L.current,!0,!0)}),i.jsx("div",{className:rt.rgbRow,children:["r","g","b"].map(M=>i.jsxs("div",{className:rt.field,children:[i.jsx("label",{htmlFor:`${g}-${M}`,children:f(M==="r"?"colorRgbR":M==="g"?"colorRgbG":"colorRgbB")}),i.jsx("input",{id:`${g}-${M}`,inputMode:"numeric",value:S[M],disabled:o,onChange:re=>{A(O=>({...O,[M]:re.target.value}))},onBlur:()=>{const re=kT(S[M]);if(re===null){A({r:String(ee.r),g:String(ee.g),b:String(ee.b)});return}E({...ee,[M]:re},!0,!0)},onKeyDown:re=>{re.key==="Enter"&&re.currentTarget.blur()}})]},M))}),i.jsx("div",{className:rt.hexRow,children:i.jsxs("div",{className:rt.field,children:[i.jsx("label",{htmlFor:`${g}-hex`,children:f("colorHex")}),i.jsx("input",{id:`${g}-hex`,value:R,disabled:o,onChange:M=>T(M.target.value),onBlur:()=>{const M=Ue(R);if(!M){T(se);return}const re=Na(M);re&&E(re,!0,!0)},onKeyDown:M=>{M.key==="Enter"&&M.currentTarget.blur()}})]})}),ob()?i.jsx("button",{type:"button",className:rt.eyedrop,disabled:o,onClick:()=>{sT().then(M=>{if(!M)return;const re=Na(M);re&&E(re,!0,!0)})},children:f("colorPickFromScreen")}):null]}):null]})}const ST="_wrap_hfz5s_1",PT="_button_hfz5s_8",AT="_icon_hfz5s_18",TT="_bar_hfz5s_24",RT="_barEmpty_hfz5s_33",DT="_popover_hfz5s_43",wr={wrap:ST,button:PT,icon:AT,bar:TT,barEmpty:RT,popover:DT};function ib({icon:e,value:t,mixed:n,noneKey:r,labelKey:o,ariaKey:a,fallbackCustom:s,disabled:u,onChange:d}){const f=X(),g=l.useId(),h=l.useRef(null),y=l.useRef(null),b=l.useRef(null),[C,x]=l.useState(!1),v=vo(C,y,b);l.useEffect(()=>{if(!C)return;const T=P=>{var L,V;const j=P.target;(L=h.current)!=null&&L.contains(j)||(V=b.current)!=null&&V.contains(j)||x(!1)},D=P=>{var j;P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),x(!1),(j=y.current)==null||j.focus())};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",D,!0),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",D,!0)}},[C]);const k=T=>{d(T)},S=`${wr.bar}${!t||n?` ${wr.barEmpty}`:""}`,A=t&&!n?{backgroundColor:t}:void 0,R=i.jsxs("div",{className:wr.wrap,ref:h,children:[i.jsxs("button",{ref:y,type:"button",className:`${ce.iconButton} ${wr.button}`,"aria-label":f(a),"aria-expanded":C,"aria-haspopup":"listbox","aria-controls":C?g:void 0,disabled:u,onMouseDown:T=>T.preventDefault(),onClick:()=>x(T=>!T),children:[i.jsx(e,{className:`${ce.icon} ${wr.icon}`}),i.jsx("span",{className:S,style:A})]}),C?i.jsx(Pe,{children:i.jsx("div",{ref:b,id:g,className:wr.popover,style:{top:v.top,left:v.left},children:i.jsx(Xu,{value:t,mixed:n,noneLabel:f(r),ariaLabel:f(a),disabled:u,fallbackCustom:s,onChange:k,onCommit:()=>x(!1)})})}):null]});return i.jsx(nr,{label:f(o),children:R})}function IT({commands:e,queries:t,disabled:n}){return i.jsx(ib,{icon:ap,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}const jT="_wrap_1vjt0_1",ET="_wrapToolbar_1vjt0_7",MT="_field_1vjt0_12",_T="_trigger_1vjt0_20",NT="_chevron_1vjt0_50",LT="_list_1vjt0_73",BT="_listInline_1vjt0_88",FT="_option_1vjt0_96",HT="_separator_1vjt0_125",Yt={wrap:jT,wrapToolbar:ET,field:MT,trigger:_T,chevron:NT,list:LT,listInline:BT,option:FT,separator:HT};function zT({value:e,mixed:t=!1,fonts:n,disabled:r,listId:o,listRef:a,inline:s,style:u,onSelect:d}){const f=X(),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 y=!t&&yi(e,h.family);return i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Yt.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 OT(e,t,n,r){var o;return t?"":e===null?r:((o=Mx(e,n))==null?void 0:o.name)??e}function ab({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:o,toolbar:a=!1,triggerId:s,onChange:u}){const d=X(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(!1),x=OT(e,t,n,d("fontFamilyDefault")),v=vo(b,h,y,{matchAnchorWidth:!0,deps:[n.length]});l.useEffect(()=>{if(!b)return;const S=R=>{var D,P;const T=R.target;(D=g.current)!=null&&D.contains(T)||(P=y.current)!=null&&P.contains(T)||C(!1)},A=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),C(!1))};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",A,!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:()=>C(S=>!S),children:x}),i.jsx("span",{className:Yt.chevron,"aria-hidden":"true"})]}),b?i.jsx(Pe,{children:i.jsx(zT,{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(nr,{label:o,children:k}):k}function KT({commands:e,queries:t,disabled:n}){const r=X(),o=!!(n||!t.isVisualMode());return i.jsx(ab,{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 $T="_wrap_58i0x_1",UT="_wrapToolbar_58i0x_9",VT="_field_58i0x_14",WT="_input_58i0x_22",GT="_toggle_58i0x_41",ZT="_chevron_58i0x_42",qT="_unit_58i0x_80",YT="_list_58i0x_110",XT="_option_58i0x_125",Ze={wrap:$T,wrapToolbar:UT,field:VT,input:WT,toggle:GT,chevron:ZT,unit:qT,list:YT,option:XT},JT={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function sb({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:o,tooltip:a,sizeInputId:s,toolbar:u=!1}){const d=X(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(()=>e===null?"":be(e)),[x,v]=l.useState(!1),[k,S]=l.useState(!1),A=vo(k,h,y,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{x||C(e===null?"":be(e))},[e,x]),l.useEffect(()=>{if(!k)return;const j=V=>{var N,K;const E=V.target;(N=g.current)!=null&&N.contains(E)||(K=y.current)!=null&&K.contains(E)||S(!1)},L=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",L,!0)}},[k]);const R=j=>{const L=eC(j,t);if(!L){C(e===null?"":be(e));return}n(L.value,L.unit),C(be(L.value))},T=Yx[t],D=k?i.jsx(Pe,{children:i.jsx("ul",{ref:y,className:Ze.list,role:"listbox",id:f,style:{top:A.top,left:A.left,minWidth:A.width},children:T.map(j=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":e===j,onMouseDown:L=>L.preventDefault(),onClick:()=>{n(j,t),C(be(j)),S(!1)},children:be(j)})},j))})}):null,P=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:j=>C(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),R(b),S(!1),j.currentTarget.blur()),j.key==="ArrowDown"&&(j.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:j=>j.preventDefault(),onClick:()=>S(j=>!j)})]}),i.jsxs("div",{className:Ze.field,children:[i.jsx("select",{className:Ze.unit,value:t,disabled:o,"aria-label":d("commandFontSizeUnitAria"),onChange:j=>{r(j.target.value)},children:fu.map(j=>i.jsx("option",{value:j,children:d(JT[j])},j))}),i.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),D]});return a?i.jsx(nr,{label:a,children:P}):P}function QT({commands:e,queries:t,disabled:n}){const r=X(),o=!!(n||!t.isVisualMode());return i.jsx(sb,{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 eR({commands:e,queries:t,disabled:n}){return i.jsx(ib,{icon:sp,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function tR({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=X(),a=!!(n||!t.isVisualMode());return i.jsx(Xu,{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 nR="_wrap_1gtdc_1",rR="_wrapToolbar_1gtdc_7",oR="_field_1gtdc_12",iR="_trigger_1gtdc_20",aR="_chevron_1gtdc_46",sR="_list_1gtdc_69",lR="_option_1gtdc_84",cR="_separator_1gtdc_113",Dn={wrap:nR,wrapToolbar:rR,field:oR,trigger:iR,chevron:aR,list:sR,option:lR,separator:cR},uR="_backdrop_1p9zk_1",dR="_dialog_1p9zk_12",mR="_dialogWide_1p9zk_31",fR="_header_1p9zk_35",pR="_tabs_1p9zk_43",gR="_tab_1p9zk_43",hR="_body_1p9zk_76",bR="_field_1p9zk_86",yR="_label_1p9zk_92",xR="_sizeRow_1p9zk_96",CR="_fileRow_1p9zk_102",wR="_fileName_1p9zk_108",vR="_previewImage_1p9zk_115",kR="_marks_1p9zk_125",SR="_mark_1p9zk_125",PR="_actions_1p9zk_140",AR="_actionsSpread_1p9zk_148",TR="_actionsEnd_1p9zk_152",RR="_headerRow_1p9zk_157",DR="_close_1p9zk_170",IR="_nameSection_1p9zk_187",jR="_nameInput_1p9zk_192",ER="_labelRow_1p9zk_209",MR="_help_1p9zk_215",_R="_textInput_1p9zk_233",NR="_fullSelect_1p9zk_245",LR="_error_1p9zk_249",BR="_emptyHint_1p9zk_254",FR="_action_1p9zk_140",HR="_textarea_1p9zk_265",zR="_actionDanger_1p9zk_279",OR="_confirmBody_1p9zk_285",KR="_nestedPanel_1p9zk_294",$R="_spinnerWrap_1p9zk_309",UR="_spinner_1p9zk_309",VR="_actionPrimary_1p9zk_344",WR="_iconButton_1p9zk_358",GR="_select_1p9zk_359",ZR="_lengthInput_1p9zk_360",qR="_lengthUnit_1p9zk_361",YR="_group_1p9zk_369",XR="_nestedGroup_1p9zk_379",JR="_subLabel_1p9zk_389",QR="_iconRow_1p9zk_393",eD="_lengthField_1p9zk_425",tD="_sideLabel_1p9zk_431",nD="_lengthRow_1p9zk_435",rD="_sideGrid_1p9zk_463",oD="_shadowGrid_1p9zk_464",p={backdrop:uR,dialog:dR,dialogWide:mR,header:fR,tabs:pR,tab:gR,body:hR,field:bR,label:yR,sizeRow:xR,fileRow:CR,fileName:wR,previewImage:vR,marks:kR,mark:SR,actions:PR,actionsSpread:AR,actionsEnd:TR,headerRow:RR,close:DR,nameSection:IR,nameInput:jR,labelRow:ER,help:MR,textInput:_R,fullSelect:NR,error:LR,emptyHint:BR,action:FR,textarea:HR,actionDanger:zR,confirmBody:OR,nestedPanel:KR,spinnerWrap:$R,spinner:UR,actionPrimary:VR,iconButton:WR,select:GR,lengthInput:ZR,lengthUnit:qR,group:YR,nestedGroup:XR,subLabel:JR,iconRow:QR,lengthField:eD,sideLabel:tD,lengthRow:nD,sideGrid:rD,shadowGrid:oD},ru={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},iD={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 Uf(){const e=X();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 lb({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=X(),C=t?null:e,x=u,v=!!(r&&u&&y);return r?i.jsxs(i.Fragment,{children:[rs.map(k=>i.jsx("button",{type:"button",className:ce.menuItem,role:"menuitemradio","aria-checked":C===k,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(ru[k])},k)),x?i.jsx("div",{role:"separator",className:ce.menuSeparator}):null,x&&f?i.jsx(Uf,{}):null,x&&!f?d.map(k=>i.jsx("button",{type:"button",className:ce.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:ce.menuSeparator}):null,i.jsxs("button",{type:"button",className:ce.menuItem,role:"menuitem","aria-label":b("styleAddNewAria"),disabled:n,onMouseDown:k=>k.preventDefault(),onClick:()=>y==null?void 0:y(),children:[i.jsx(Gy,{className:ce.icon}),b("styleAddNew")]})]}):null]}):i.jsxs("ul",{ref:a,className:Dn.list,role:"listbox",id:o,style:s,"aria-label":b("commandParagraphStyleAria"),"aria-busy":x&&f?!0:void 0,children:[rs.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Dn.option,role:"option","aria-selected":C===k,disabled:n,style:iD[k],onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(ru[k])})},k)),x&&(f||d.length>0)?i.jsx("li",{role:"separator",className:Dn.separator}):null,x&&f?i.jsx("li",{role:"presentation",children:i.jsx(Uf,{})}):null,x&&!f?d.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Dn.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 aD({commands:e,queries:t,disabled:n}){const r=X(),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(ru[y]):"",C=t.customParagraphStylesEnabled(),x=C?t.getCustomParagraphStyles():[],v=C&&t.isCustomParagraphStylesLoading(),k=vo(d,s,u,{matchAnchorWidth:!0,deps:[x.length,v]});l.useEffect(()=>{if(!d)return;const A=T=>{var P,j;const D=T.target;(P=a.current)!=null&&P.contains(D)||(j=u.current)!=null&&j.contains(D)||f(!1)},R=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),f(!1))};return document.addEventListener("pointerdown",A),document.addEventListener("keydown",R,!0),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("keydown",R,!0)}},[d]);const S=i.jsxs("div",{className:`${Dn.wrap} ${Dn.wrapToolbar}`,ref:a,children:[i.jsxs("div",{className:Dn.field,ref:s,children:[i.jsx("button",{type:"button",className:Dn.trigger,disabled:g,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":d,"aria-controls":d?o:void 0,onMouseDown:A=>A.preventDefault(),onClick:()=>f(A=>!A),children:b}),i.jsx("span",{className:Dn.chevron,"aria-hidden":"true"})]}),d?i.jsx(Pe,{children:i.jsx(lb,{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:A=>{e.setParagraphStyle(A),f(!1)},onSelectCustom:A=>{e.applyCustomParagraphStyle(A),f(!1)}})}):null]});return i.jsx(nr,{label:r("commandParagraphStyle"),children:S})}function sD({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(lb,{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 lD={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:sD,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:tR,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:KT,icon:Dy,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:aD,icon:Wy,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:QT,icon:jy,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:Iy,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},customCss:{id:"customCss",command:"openCustomCss",icon:Ay,labelKey:"commandCustomCss",ariaKey:"commandCustomCssAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:up,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:lp,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:IT,icon:ap,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:eR,icon:sp,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:xy,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:By,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:tx,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:ex,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:vy,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},formatBrush:{id:"formatBrush",command:"toggleFormatBrush",icon:Ey,labelKey:"commandFormatBrush",ariaKey:"commandFormatBrushAria",active:"isFormatBrushActive",enabled:"isVisualMode",toggle:!0},alignLeft:{id:"alignLeft",command:"alignLeft",icon:gs,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:ps,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:hs,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:op,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:Ly,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:$y,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:ip,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:cp,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},cD={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:Hy,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Cy,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:lp,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},pageBackgroundImage:{id:"pageBackgroundImage",command:"openPageBackgroundImage",icon:ti,labelKey:"commandPageBackgroundImage",ariaKey:"commandPageBackgroundImageAria",enabled:"canInsertPageBackgroundImage"},paragraphBackgroundImage:{id:"paragraphBackgroundImage",command:"openParagraphBackgroundImage",icon:up,labelKey:"commandParagraphBackgroundImage",ariaKey:"commandParagraphBackgroundImageAria",enabled:"canInsertParagraphBackgroundImage"},audio:{id:"audio",command:"openAudioDialog",icon:yy,labelKey:"commandAudio",ariaKey:"commandAudioAria",enabled:"isVisualMode"},youtube:{id:"youtube",command:"openYoutubeDialog",icon:ix,labelKey:"commandYoutube",ariaKey:"commandYoutubeAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:_y,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"},pageBreak:{id:"pageBreak",command:"insertPageBreak",icon:Uy,labelKey:"commandPageBreak",ariaKey:"commandPageBreakAria",enabled:"isVisualMode"},insertPageBefore:{id:"insertPageBefore",command:"insertPageBefore",icon:ti,labelKey:"commandInsertPageBefore",ariaKey:"commandInsertPageBeforeAria",enabled:"hasSelectedPage"},insertPageAfter:{id:"insertPageAfter",command:"insertPageAfter",icon:ti,labelKey:"commandInsertPageAfter",ariaKey:"commandInsertPageAfterAria",enabled:"hasSelectedPage"}}},uD={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:Bm,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:ql,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:ql,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:ql,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:Zl,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:Zl,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:Zl,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},mergeCells:{id:"mergeCells",command:"mergeCells",icon:Oy,labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:"canMergeCells"},unmergeCells:{id:"unmergeCells",command:"unmergeCells",icon:rx,labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:"canUnmergeCells"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:Bm,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:wy,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:Xy,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},dD={menus:{help:{id:"help",labelKey:"menuHelp",ariaKey:"menuHelpAria"}},groups:{},items:{editorHelp:{id:"editorHelp",command:"openHelp",icon:Gl,labelKey:"commandEditorHelp",ariaKey:"commandEditorHelpAria"},keyboardShortcuts:{id:"keyboardShortcuts",command:"openKeyboardShortcuts",icon:Gl,labelKey:"commandKeyboardShortcuts",ariaKey:"commandKeyboardShortcutsAria"},about:{id:"about",command:"openAbout",icon:Gl,labelKey:"commandAbout",ariaKey:"commandAboutAria"}}},mD=["getStarted","file","edit","insert","format","table","view","keyboard"],ou=[{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"]}],Vf=Object.fromEntries(ou.map(e=>[e.id,e]));function cb(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function fD(e,t){const n=cb(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 pD(e,t){return cb(t).length===0?e:e.map(r=>({entry:r,score:fD(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 gD={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:ox,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:Ny,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:Ty,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:Fy,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:Ry,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:Vy,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},ruler:{id:"ruler",command:"toggleRuler",icon:Jy,labelKey:"commandRuler",ariaKey:"commandRulerAria",active:"isRulerVisible",toggle:!0},readAloud:{id:"readAloud",command:"toggleReadAloud",icon:qy,labelKey:"commandReadAloud",ariaKey:"commandReadAloudAria",active:"isReadingAloud",toggle:!0,enabled:"canReadAloud"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:My,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function hD(...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 bD=hD(TA,ZP,cD,uD,gD,lD,dD),yD={menus:[{id:"file",items:["save","open",Se,"print"]},{id:"edit",items:["undo","redo",Se,{submenu:"page",items:["pageProperties",Se,"deletePage"]}]},{id:"view",items:["visual","html",Se,{submenu:"toolbar",items:["customizeToolbar",Se,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},Se,{submenu:"zoom",items:["pageZoomFitWidth","pageZoomFitPage",Se,"pageZoom50","pageZoom75","pageZoom100","pageZoom125","pageZoom150","pageZoom200"]},Se,"lightMode","darkMode",Se,"toggleCommentsVisible","ruler","preview","readAloud","fullscreen"]},{id:"insert",items:["pageBreak",{submenu:"insertPage",items:["insertPageBefore","insertPageAfter"]},Se,"table",Se,"image","pageBackgroundImage","paragraphBackgroundImage","audio","youtube","horizontalRule",Se,"link","bookmark",Se,"insertComment"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},Se,{submenu:"font",items:["fontProperties","customCss",Se,{submenu:"highlightColor",items:[]},Se,"bold","italic","underline","strikethrough"]},Se,"clearFormatting",Se,{submenu:"paragraph",items:["paragraphProperties",Se,"alignLeft","alignCenter","alignRight","alignJustify",Se,"indent","outdent",Se,"bulletList","numberedList"]},Se,"imageProperties"]},{id:"table",items:["table",Se,{submenu:"insertRow",items:["insertRowBefore","insertRowBelow","deleteRow"]},{submenu:"insertColumn",items:["insertColumnBefore","insertColumnAfter","deleteColumn"]},Se,"mergeCells","unmergeCells",Se,"tableProperties","rowProperties","cellProperties"]},{id:"help",items:["editorHelp","keyboardShortcuts",Se,"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"]}]},Wf={items:{addComment:{id:"addComment",command:"addComment",icon:Lm,labelKey:"commandAddComment",ariaKey:"commandAddCommentAria",enabled:"canAddComment"},insertComment:{id:"insertComment",command:"addComment",icon:Lm,labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:"canAddComment"},toggleCommentsVisible:{id:"toggleCommentsVisible",command:"toggleCommentsVisible",icon:ky,labelKey:"showComments",ariaKey:"toggleCommentsVisibleAria",toggle:!0,active:"areCommentsVisible"}}},xD=["addComment","insertComment","toggleCommentsVisible"],CD=new Set(["insert","view"]);function ub(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!xD.includes(e):!0:!1}function wD(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!CD.has(e):!0:!1}function vD(e,t){const n=t?"hideComments":"showComments",r=Wf.items.toggleCommentsVisible;return{...e,items:{...e.items,...Wf.items,toggleCommentsVisible:r&&{...r,labelKey:n}}}}function kD(e){return{...e,menus:e.menus.map(t=>{if(t.id==="insert"){const n=[...t.items],r=n.findIndex(a=>Jn(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 Gf={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 db(){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 mb(e){const t=new Set;return e.active&&t.add(Gf[e.active]??"chrome"),e.enabled&&t.add(Gf[e.enabled]??"chrome"),t.size===0&&t.add("chrome"),[...t]}const fb=l.createContext(null);function SD({value:e,children:t}){return i.jsx(fb.Provider,{value:e,children:t})}function pb(e){const t=l.useContext(fb),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 La="fullscreen";function PD(e){const t=[];let n=null;for(const r of e){const o=r.items.filter(a=>a!==La);o.length>0&&t.push({id:r.id,items:o}),r.items.includes(La)&&(n={id:La,items:[La]})}return{main:t,trailing:n}}const AD=l.memo(function({item:t,itemId:n,commands:r,queries:o,disabled:a,chromeLock:s}){const u=X(),d=l.useMemo(()=>mb(t),[t]);if(pb(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(nr,{label:t.tooltip??tr(u,t),children:i.jsx("button",{type:"button",className:ce.iconButton,"aria-label":us(u,t),"aria-pressed":y,disabled:a||(s?ub(n,s):!1)||h,onPointerDown:b=>b.preventDefault(),onMouseDown:b=>b.preventDefault(),onClick:()=>{lu(r,g)},children:i.jsx(f,{className:ce.icon})})})});function TD({groups:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a}){const s=X(),{main:u,trailing:d}=PD(e),f=g=>{const h=t.groups[g.id];return i.jsx("div",{className:ce.iconGroup,role:"group","aria-label":h?tr(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(AD,{itemId:y,item:b,commands:n,queries:r,disabled:o,chromeLock:a},y)})},g.id)};return i.jsxs("div",{className:ce.iconNav,role:"toolbar","aria-label":s("toolbarAria"),children:[u.length>0?i.jsx("div",{className:ce.iconNavMain,children:u.map(f)}):null,d?i.jsx("div",{className:ce.iconNavEnd,children:f(d)}):null]})}const RD=["--wysiwyg-menu-color","--wysiwyg-menu-background"],Zf=["--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function DD(e,t){const n=t?Zf:[...RD,...Zf],r={};for(const o of n){const a=getComputedStyle(e).getPropertyValue(o).trim();if(a){r[o]=a;continue}let s=e;for(;s;){const u=s.style.getPropertyValue(o).trim();if(u){r[o]=u;break}s=s.parentElement}}return r}function ID({menus:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,compact:s,openMenuId:u,onOpenMenuIdChange:d}){const f=X(),g=yp(),[h,y]=l.useState(!1),[b,C]=l.useState({}),x=l.useRef(null),v=l.useRef(null),k=l.useRef(null),S=l.useRef(null),A=l.useCallback(()=>{y(!1),d(null)},[d]);l.useLayoutEffect(()=>{!h||!x.current||C(DD(x.current,g))},[g,h]),l.useEffect(()=>{var T;h&&((T=k.current)==null||T.focus())},[h]),l.useEffect(()=>{if(!h)return;const T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=T}},[h]),l.useEffect(()=>{if(!h)return;const T=P=>{var j;if(P.key==="Escape"){if(P.preventDefault(),P.stopPropagation(),u){d(null);return}A(),(j=v.current)==null||j.focus()}},D=P=>{var j;S.current&&!S.current.contains(P.target)&&(A(),(j=v.current)==null||j.focus())};return document.addEventListener("keydown",T,!0),document.addEventListener("pointerdown",D),()=>{document.removeEventListener("keydown",T,!0),document.removeEventListener("pointerdown",D)}},[h,u,d,A]);const R=T=>e.map(D=>{const P=t.menus[D.id];return P?i.jsx(ED,{def:P,itemIds:D.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:T,open:(T==="overlay"||!h)&&u===D.id,onOpenChange:j=>d(j?D.id:null),onItemRun:T==="overlay"?()=>{var j;A(),(j=v.current)==null||j.focus()}:void 0},`${T}-${D.id}`):null});return i.jsxs("div",{className:ce.menuBar,ref:x,children:[i.jsx(nr,{label:f("brandMarkAria"),children:i.jsx("span",{className:ce.brandMark,role:"img","aria-label":f("brandMarkAria"),children:i.jsx(Sy,{className:ce.brandMarkIcon})})}),i.jsx("div",{className:ce.menuBarCompact,hidden:s===void 0?void 0:!s,children:i.jsx(nr,{label:f("menuHamburgerAria"),children:i.jsx("button",{ref:v,type:"button",className:`${ce.menuButton} ${ce.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":h,"aria-label":f("menuHamburgerAria"),disabled:o||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>{if(h){A();return}d(null),y(!0)},children:i.jsx(zy,{className:ce.icon})})})}),i.jsx("div",{className:ce.menuBarDesktop,hidden:s===void 0?void 0:s,children:R("dropdown")}),h?i.jsx(Pe,{children:i.jsx("div",{className:ce.toolbar,"data-menu-overlay-portal":"",style:b,children:i.jsxs("div",{ref:S,className:ce.menuOverlay,role:"dialog","aria-modal":"true","aria-label":f("menuOverlayAria"),children:[i.jsxs("div",{className:ce.menuOverlayHeader,children:[i.jsx("span",{className:ce.menuOverlayTitle,children:f("menuOverlayAria")}),i.jsx("button",{ref:k,type:"button",className:ce.iconButton,"aria-label":f("menuCloseAria"),onClick:()=>{var T;A(),(T=v.current)==null||T.focus()},children:i.jsx(Qe,{className:ce.icon})})]}),i.jsx("div",{className:ce.menuOverlayBody,children:R("overlay")})]})})}):null]})}function ds(e,t){var n,r;if(Xn(e))return!1;if(Jn(e)){const o=(n=t.submenus)==null?void 0:n[e.submenu];return o?o.panel?!0:e.items.some(a=>ds(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function jD(e,t,n){if(!Xn(e[t])||!e.slice(t+1).some(a=>ds(a,n)))return!1;let o=!1;for(let a=t-1;a>=0;a--){const s=e[a];if(Xn(s)){o=!0;continue}if(ds(s,n))return!o}return!1}function ED({def:e,itemIds:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,open:d,onOpenChange:f,onItemRun:g}){const h=X(),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=A=>{y.current&&!y.current.contains(A.target)&&f(!1)},S=A=>{if(A.key==="Escape"){if(A.preventDefault(),A.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:ce.menuWrap,ref:y,children:[i.jsx("button",{type:"button",className:ce.menuButton,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":b,"aria-label":us(h,e),disabled:a||(s?wD(e.id,s):!1),onClick:()=>f(!d),children:tr(h,e)}),d?i.jsx("div",{className:ce.menu,role:"menu",id:b,onMouseDown:k=>k.preventDefault(),children:i.jsx(gb,{entries:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,onClose:v,openSubmenuId:C,onOpenSubmenuIdChange:x})}):null]})}function gb({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(Xn(g))return jD(e,h,t)?i.jsx("div",{role:"separator",className:ce.menuSeparator},`separator-${h}`):null;if(Jn(g))return i.jsx(_D,{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(MD,{item:y,commands:n,queries:r,disabled:o,chromeLock:a,onClose:u},g)})})}function MD({item:e,commands:t,queries:n,disabled:r,chromeLock:o,onClose:a}){const s=X(),u=l.useMemo(()=>mb(e),[e]);if(pb(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:ce.menuItem,"aria-checked":g,disabled:r||(o?ub(e.id,o):!1)||h,onClick:()=>{a(),lu(t,f)},children:[d?i.jsx(d,{className:ce.icon}):null,tr(s,e)]})}function _D({entry:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,open:d,onOpenChange:f}){var D;const g=X(),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(null),x=(D=t.submenus)==null?void 0:D[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,A=s==="overlay";if(l.useEffect(()=>{d||C(null)},[d]),!x||!k&&!e.items.some(P=>ds(P,t)))return null;const R=P=>{(P.key==="ArrowRight"||P.key==="Enter"||P.key===" ")&&(P.preventDefault(),P.stopPropagation(),f(!0),requestAnimationFrame(()=>{var L;const j=(L=y.current)==null?void 0:L.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');j==null||j.focus()}))},T=P=>{var j;P.key==="ArrowLeft"&&(P.preventDefault(),P.stopPropagation(),f(!1),(j=h.current)==null||j.focus())};return i.jsxs("div",{className:ce.submenuWrap,onMouseEnter:A?void 0:()=>f(!0),onMouseLeave:A?void 0:()=>f(!1),children:[i.jsx("button",{ref:h,type:"button",role:"menuitem",className:`${ce.menuItem} ${ce.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":v,"aria-label":us(g,x),disabled:o||S||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>f(A?!d:!0),onKeyDown:R,children:tr(g,x)}),d?i.jsx("div",{ref:y,className:`${ce.menu} ${ce.submenu}`,role:"menu",id:v,"aria-label":us(g,x),onMouseDown:P=>P.preventDefault(),onKeyDown:T,children:k?i.jsx(k,{commands:n,queries:r,disabled:o||S,onMenuClose:u}):i.jsx(gb,{entries:e.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,openSubmenuId:b,onOpenSubmenuIdChange:C})}):null]})}const iu=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:ce.toolbar,"data-compact":g?"":void 0,"data-toolbar-position":h,children:[d?i.jsx(ID,{menus:n.menus,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u,compact:g,openMenuId:y,onOpenMenuIdChange:b}):null,f?i.jsx(TD,{groups:n.iconGroups,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u}):null]});return a?i.jsx(SD,{value:a,children:C}):C});function ND(e,t){return t?e:{...e,menus:e.menus.map(n=>n.id==="insert"?{...n,items:n.items.filter(r=>!(Jn(r)&&r.submenu==="insertPage"))}:n.id==="edit"?{...n,items:n.items.map(r=>{if(!Jn(r)||r.submenu!=="page")return r;let o=r.items.filter(a=>a!=="deletePage");return o.at(-1)===Se&&(o=o.slice(0,-1)),{...r,items:o}})}:n)}}function hi(e){return ag(ot(e))}const LD=1.5,fc=384;function BD(e,t=16){return e>0?LD*t:0}function hb(e,t,n=16){const r=BD(t,n);if(!hi(e))return fc+r;const o=ot(e),a=Co(o,!1);return a?Vn(a.height,fc)+r:fc+r}function ei(e,t){const n=[0];for(let r=0;r<e;r+=1)n.push(n[r]+t(r));return n}function FD(){const e=new Map;return{get(t,n){return e.get(t)??hb(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 HD=2;function bb(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 yb(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 qf(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=bb(e,n,r),g=yb(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 zD({scrollElementRef:e,pageCount:t,getRowHeight:n,overscan:r=HD,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 A=u.current.get(S),R=s.current(S);return A!==void 0?Math.max(A,R):R},[d]),h=l.useMemo(()=>ei(t,g),[t,g]),[y,b]=l.useState(()=>{const S=ei(t,A=>s.current(A));return qf(0,300,S,t,r,o,a)}),C=l.useCallback(()=>{const S=e.current;if(!S||t<=0)return;const A=S.clientHeight>0?S.clientHeight:300,R=ei(t,g);b(qf(S.scrollTop,A,R,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 A=()=>C();S.addEventListener("scroll",A,{passive:!0});let R;return typeof ResizeObserver<"u"&&(R=new ResizeObserver(()=>C()),R.observe(S)),C(),()=>{S.removeEventListener("scroll",A),R==null||R.disconnect()}},[e,C]);const x=l.useCallback((S,A)=>{if(A<=0)return;const R=u.current.get(S);R!==void 0&&Math.abs(R-A)<1||(u.current.set(S,A),f(T=>T+1))},[]),v=l.useCallback(S=>{const A=e.current;if(!A||S<0||S>=t)return;const R=ei(t,g);A.scrollTop=R[S]??0,C()},[t,g,e,C]),k=l.useMemo(()=>{if(y.endIndex<y.startIndex)return[];const S=[];for(let A=y.startIndex;A<=y.endIndex;A+=1)S.push(A);return S},[y.endIndex,y.startIndex]);return{...y,visibleIndices:k,scrollToIndex:v,notifyRowMeasured:x}}function Ju(){return{firstLineIndentPx:0,leftIndentPx:0,rightIndentPx:0,mixed:!1}}function ms(e){const t=En(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?Vn(u,0):0,h=d?Vn(d,0):0,y=f?Vn(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 OD(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 KD(e,t){return ar(e,()=>{let n=Er(e);if(n.length===0){const a=OD(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=_e(nc(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=_e(nc(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=_e(nc(t.rightIndentPx,r));a.style.marginRight!==s&&(a.style.marginRight=s,o=!0)}xt(a)}return o})}const xb=24,ai=48;function Cb(e,t){const n=Ci(ot(t));return{pageWidthPx:e.offsetWidth,pageHeightPx:e.offsetHeight,marginsPx:{top:Vn(n.top,0),right:Vn(n.right,0),bottom:Vn(n.bottom,0),left:Vn(n.left,0)}}}function $D(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 UD(e,t,n,r,o=!0,a=1){const[s,u]=l.useState({}),[d,f]=l.useState(Ju()),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=qe(y,x);if(!v)continue;const k=t[x]??t[0]??"";b[x]=Cb(v,k)}u(x=>{const v={...x,...b};return $D(x,v)?x:v});const C=qe(y,r());C&&f(ms(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=qe(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=qe(b,r());C&&f(ms(C))};return document.addEventListener("selectionchange",y),()=>document.removeEventListener("selectionchange",y)},[e,o,r]),{pageGeometries:s,geometryForPage:g,indentState:d,refresh:h}}const VD="_rulerRoot_j57vt_5",WD="_horizontalRulerGroup_j57vt_22",GD="_horizontalRulerTrack_j57vt_28",ZD="_horizontalRulerShelf_j57vt_42",qD="_horizontalInner_j57vt_51",YD="_dragEdgeLeft_j57vt_63",XD="_dragEdgeRight_j57vt_73",JD="_dragEdgeActive_j57vt_85",QD="_verticalRuler_j57vt_92",eI="_verticalInner_j57vt_102",tI="_dragEdgeTop_j57vt_114",nI="_dragEdgeBottom_j57vt_124",rI="_dragEdgeActiveV_j57vt_136",oI="_tickH_j57vt_143",iI="_tickV_j57vt_152",aI="_tickLabelH_j57vt_161",sI="_tickLabelV_j57vt_175",lI="_arrowIconWrapper_j57vt_192",cI="_arrowDown_j57vt_203",uI="_arrowGlyph_j57vt_211",dI="_arrowActive_j57vt_220",mI="_arrowUp_j57vt_225",fI="_rulerTooltip_j57vt_249",je={rulerRoot:VD,horizontalRulerGroup:WD,horizontalRulerTrack:GD,horizontalRulerShelf:ZD,horizontalInner:qD,dragEdgeLeft:YD,dragEdgeRight:XD,dragEdgeActive:JD,verticalRuler:QD,verticalInner:eI,dragEdgeTop:tI,dragEdgeBottom:nI,dragEdgeActiveV:rI,tickH:oI,tickV:iI,tickLabelH:aI,tickLabelV:sI,arrowIconWrapper:lI,arrowDown:cI,arrowGlyph:uI,arrowActive:dI,arrowUp:mI,rulerTooltip:fI},pc=({type:e,active:t=!1,className:n="",style:r,title:o,"aria-label":a,onPointerDown:s,"data-testid":u})=>{const d=e==="down"?je.arrowDown:je.arrowUp;return i.jsx("div",{className:`${je.arrowIconWrapper} ${d} ${t?je.arrowActive:""} ${n}`,style:r,title:o,"aria-label":a||o,onPointerDown:s,"data-testid":u,children:i.jsx("div",{className:je.arrowGlyph})})};function wb(){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 pI=({geometry:e,indentState:t,unit:n="in",zoomScale:r=1,onMarginChange:o,onMarginPreview:a,onIndentChange:s})=>{const u=X(),{activeTarget:d,dragPreview:f,startPointerDrag:g}=wb(),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,A=(f==null?void 0:f.rightIndentPx)??t.rightIndentPx,R=Math.max(0,h-x-v),T=!t.mixed,D=l.useMemo(()=>tg(h,x,n),[h,x,n]),P=l.useCallback((N,K)=>{const G=Number.isFinite(K.clientX)?K.clientX:0;g(N.type,K,{updateDragState:(Z,ae,q)=>{const ee=(Z-G)/C;let se=0;const me={target:N.type,marginLeft:y,marginRight:b,firstLineIndentPx:t.firstLineIndentPx,leftIndentPx:t.leftIndentPx,rightIndentPx:t.rightIndentPx,measurementPx:0,clientX:Z,clientY:ae};if(N.type==="margin-left"){const ne=Math.max(0,Math.min(h-b-ai,N.startMarginPx+ee)),M=vr(ne,n,q,0);me.marginLeft=M,se=M}else if(N.type==="margin-right"){const ne=Math.max(0,Math.min(h-y-ai,N.startMarginPx-ee)),M=vr(ne,n,q,0);me.marginRight=M,se=M}else if(N.type==="first-line-indent"){const ne=-N.startLeftIndentPx,M=h-y-b-N.startLeftIndentPx-ai,re=Math.max(ne,Math.min(M,N.startFirstLinePx+ee)),O=vr(re,n,q,0);me.firstLineIndentPx=O,se=O}else if(N.type==="left-indent"){const ne=Math.max(0,N.startLeftIndentPx+ee),M=vr(ne,n,q,0);me.leftIndentPx=M,me.firstLineIndentPx=N.startFirstLinePx,se=M}else if(N.type==="right-indent"){const ne=Math.max(0,N.startRightIndentPx-ee),M=vr(ne,n,q,0);me.rightIndentPx=M,se=M}return me.measurementPx=se,me},onPreview:Z=>{N.type==="margin-left"?a==null||a({left:Z.marginLeft}):N.type==="margin-right"&&(a==null||a({right:Z.marginRight}))},onCommit:Z=>{N.type==="margin-left"?o==null||o({left:Z.marginLeft}):N.type==="margin-right"?o==null||o({right:Z.marginRight}):N.type==="first-line-indent"?s==null||s({firstLineIndentPx:Z.firstLineIndentPx}):N.type==="left-indent"?s==null||s({leftIndentPx:Z.leftIndentPx}):N.type==="right-indent"&&(s==null||s({rightIndentPx:Z.rightIndentPx}))}})},[y,b,h,n,C,t,o,a,s,g]),j=x+S,L=j+k,V=h-v-A,E=h*C;return i.jsxs("div",{className:`${je.rulerRoot} ${je.horizontalRulerGroup}`,style:{width:`${E}px`},"data-testid":"horizontal-ruler",children:[i.jsxs("div",{className:je.horizontalRulerTrack,children:[i.jsxs("div",{className:je.horizontalInner,style:{left:`${x*C}px`,width:`${R*C}px`},"data-testid":"ruler-printable-area",children:[i.jsx("div",{className:`${je.dragEdgeLeft} ${d==="margin-left"?je.dragEdgeActive:""}`,title:u("rulerMarginLeft"),"aria-label":u("rulerMarginLeft"),"data-testid":"ruler-margin-splitter-left",onPointerDown:N=>P({type:"margin-left",startMarginPx:y},N)}),i.jsx("div",{className:`${je.dragEdgeRight} ${d==="margin-right"?je.dragEdgeActive:""}`,title:u("rulerMarginRight"),"aria-label":u("rulerMarginRight"),"data-testid":"ruler-margin-splitter-right",onPointerDown:N=>P({type:"margin-right",startMarginPx:b},N)})]}),D.map((N,K)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:je.tickH,style:{left:`${N.positionPx*C}px`,height:`${N.height}px`}}),N.label?i.jsx("span",{className:je.tickLabelH,style:{left:`${N.positionPx*C}px`},children:N.label}):null]},K)),T?i.jsxs(i.Fragment,{children:[i.jsx(pc,{type:"down",style:{left:`${L*C}px`},active:d==="first-line-indent",title:u("rulerFirstLineIndent"),"aria-label":u("rulerFirstLineIndent"),"data-testid":"ruler-first-line-indent",onPointerDown:N=>P({type:"first-line-indent",startFirstLinePx:t.firstLineIndentPx,startLeftIndentPx:t.leftIndentPx},N)}),i.jsx(pc,{type:"up",style:{left:`${j*C}px`},active:d==="left-indent",title:u("rulerLeftIndent"),"aria-label":u("rulerLeftIndent"),"data-testid":"ruler-left-indent",onPointerDown:N=>P({type:"left-indent",startLeftIndentPx:t.leftIndentPx,startFirstLinePx:t.firstLineIndentPx},N)}),i.jsx(pc,{type:"up",style:{left:`${V*C}px`},active:d==="right-indent",title:u("rulerRightIndent"),"aria-label":u("rulerRightIndent"),"data-testid":"ruler-right-indent",onPointerDown:N=>P({type:"right-indent",startRightIndentPx:t.rightIndentPx},N)})]}):null]}),i.jsx("div",{className:je.horizontalRulerShelf,"aria-hidden":!0}),f?i.jsx("div",{className:je.rulerTooltip,style:{left:f.clientX,top:f.clientY},"data-testid":"ruler-drag-tooltip",children:eg(f.measurementPx,n)}):null]})},gI=({geometry:e,unit:t="in",zoomScale:n=1,onMarginChange:r,onMarginPreview:o})=>{const a=X(),{activeTarget:s,dragPreview:u,startPointerDrag:d}=wb(),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(()=>tg(f,b,t),[f,b,t]),k=l.useCallback((S,A)=>{const R=Number.isFinite(A.clientY)?A.clientY:0;d(S.type,A,{updateDragState:(T,D,P)=>{const j=(D-R)/y,L={target:S.type,marginTop:g,marginBottom:h,measurementPx:0,clientX:T,clientY:D};if(S.type==="margin-top"){const V=Math.max(0,Math.min(f-h-ai,S.startMarginPx+j)),E=vr(V,t,P,0);L.marginTop=E,L.measurementPx=E}else if(S.type==="margin-bottom"){const V=Math.max(0,Math.min(f-g-ai,S.startMarginPx-j)),E=vr(V,t,P,0);L.marginBottom=E,L.measurementPx=E}return L},onPreview:T=>{S.type==="margin-top"?o==null||o({top:T.marginTop}):S.type==="margin-bottom"&&(o==null||o({bottom:T.marginBottom}))},onCommit:T=>{S.type==="margin-top"?r==null||r({top:T.marginTop}):S.type==="margin-bottom"&&(r==null||r({bottom:T.marginBottom}))}})},[g,h,f,t,y,r,o,d]);return i.jsxs("div",{className:`${je.rulerRoot} ${je.verticalRuler}`,style:{height:`${f}px`},"data-testid":"vertical-ruler",children:[i.jsxs("div",{className:je.verticalInner,style:{top:`${b}px`,height:`${x}px`},"data-testid":"ruler-printable-area-vertical",children:[i.jsx("div",{className:`${je.dragEdgeTop} ${s==="margin-top"?je.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:`${je.dragEdgeBottom} ${s==="margin-bottom"?je.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,A)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:je.tickV,style:{top:`${S.positionPx}px`,width:`${S.height}px`}}),S.label?i.jsx("span",{className:je.tickLabelV,style:{top:`${S.positionPx}px`},children:S.label}):null]},A)),u?i.jsx("div",{className:je.rulerTooltip,style:{left:u.clientX,top:u.clientY},"data-testid":"ruler-drag-tooltip",children:eg(u.measurementPx,t)}):null]})},hI="_root_njanr_1",bI="_fullscreen_njanr_36",yI="_exitFullscreen_njanr_48",xI="_exitFullscreenIcon_njanr_79",CI="_menuChrome_njanr_94",wI="_body_njanr_106",vI="_iconChrome_njanr_136",kI="_workspace_njanr_181",SI="_workspacePageSized_njanr_193",PI="_workspaceWithRuler_njanr_197",AI="_pageCanvasViewport_njanr_201",TI="_multiPageRulerLayer_njanr_211",RI="_multiPageContainer_njanr_234",DI="_pageZoomContent_njanr_244",II="_htmlFileDropOverlay_njanr_262",jI="_surface_njanr_276",EI="_visual_njanr_283",MI="_pageBlock_njanr_341",_I="_pageBlockFluid_njanr_348",NI="_pageSurfaceRulerGutter_njanr_357",LI="_pageSurface_njanr_357",BI="_htmlModeShell_njanr_378",FI="_html_njanr_262",ke={root:hI,fullscreen:bI,exitFullscreen:yI,exitFullscreenIcon:xI,menuChrome:CI,body:wI,iconChrome:vI,workspace:kI,workspacePageSized:SI,workspaceWithRuler:PI,pageCanvasViewport:AI,multiPageRulerLayer:TI,multiPageContainer:RI,pageZoomContent:DI,htmlFileDropOverlay:II,surface:jI,visual:EI,pageBlock:MI,pageBlockFluid:_I,pageSurfaceRulerGutter:NI,pageSurface:LI,htmlModeShell:BI,html:FI};function vb(e){if(e!==1)return{zoom:e,"--page-zoom":String(e)}}function kb({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}){if(!e)return null;const d=xb;return i.jsx("div",{className:ke.multiPageRulerLayer,children:i.jsxs("div",{className:ke.pageBlock,children:[i.jsx("div",{className:ke.pageSurfaceRulerGutter,style:{width:`${d}px`,flex:`0 0 ${d}px`},"aria-hidden":!0}),i.jsx(pI,{geometry:t,indentState:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u})]})})}function Sb({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?xb/g:0;return i.jsxs("div",{ref:f,className:`${ke.pageBlock} ${t?"":ke.pageBlockFluid}`,style:d,children:[i.jsx("div",{className:ke.pageSurfaceRulerGutter,style:{width:`${h}px`,flex:`0 0 ${h}px`},children:e?i.jsx(gI,{geometry:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s}):null}),u]})}function HI({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(kb,{showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}),i.jsx("div",{className:ke.pageZoomContent,style:vb(o),children:i.jsx(Sb,{showVerticalRuler:e,pageSized:e,geometry:t,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,children:d})})]})}const zI=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:A,onContextMenu:R,onRulerRefresh:T}){const D=l.useRef(null),P=l.useRef(null),j=l.useRef(""),L=l.useRef(!1),V=l.useRef(C);V.current=C;const E=l.useRef(v);E.current=v,l.useLayoutEffect(()=>{const K=P.current;if(!K||!E.current)return;const G=()=>{var ae;return(ae=E.current)==null?void 0:ae.call(E,t,K.offsetHeight)};if(G(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(G);return Z.observe(K),()=>Z.disconnect()},[t,n,o,r]);const N=l.useCallback(K=>{D.current=K,K&&(j.current=K.innerHTML)},[]);return l.useLayoutEffect(()=>()=>{x!=null&&x.current||!L.current||!V.current||V.current(t,j.current)},[t,x]),i.jsx(Sb,{pageBlockRef:P,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:s,zoomScale:u,pageBlockStyle:{marginTop:t>0?"1.5rem":"0"},onMarginChange:K=>{k==null||k(t,K)},onMarginPreview:K=>{S==null||S(t,K)},children:i.jsx("div",{ref:N,className:`${ke.surface} ${ke.visual} ${o?ke.pageSurface:""}`,[Dr]:"","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:K=>{const G=K.currentTarget;pi(G),fo(G),h(t)},onPointerDown:K=>y(t,K),onMouseUp:A,onContextMenu:R,onInput:K=>{const G=K.currentTarget;L.current=!0,j.current=G.innerHTML;const{absorbedBlocks:Z}=pi(G);if(j.current=G.innerHTML,b(t,G.innerHTML),Z.length>0){const ae=Z.length;requestAnimationFrame(()=>bg(G,ae))}T()}})})},OI);function OI(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 KI=l.forwardRef(function({pages:t,activePageIndex:n,hasSelectedPage:r=!1,scrollRootRef:o,onActivePageIndexChange:a,onPageSelected:s,onPageChange:u,onPageFlush:d,suppressPageFlushRef:f,pendingInsertPageFocusRef:g,placeholder:h,disabled:y,rulerVisible:b=!0,rulerUnit:C="in",zoomScale:x=1,onMarginChange:v,onMarginPreview:k,onIndentChange:S,onBeforeInput:A,resolveEmbeddedImageDataUrl:R,hydrateEmbeddedImages:T,onPointerDown:D,onMouseUp:P,onContextMenu:j},L){const V=X(),E=l.useRef(null),N=l.useRef(n);N.current=n;const K=l.useRef(A);K.current=A;const G=l.useRef(u);G.current=u;const Z=l.useRef(d);Z.current=d;const ae=l.useRef(s);ae.current=s;const q=l.useRef(D);q.current=D;const ee=l.useRef(v);ee.current=v;const se=l.useRef(k);se.current=k;const me=l.useRef(null),ne=l.useRef([]),M=l.useRef(FD()),re=f,O=l.useCallback(()=>N.current,[]),ie=l.useCallback(H=>M.current.get(H,t[H]??""),[t]),{visibleIndices:Ee,topSpacerHeight:He,bottomSpacerHeight:$e,scrollToIndex:Ve,notifyRowMeasured:St}=zD({scrollElementRef:o??E,pageCount:t.length,getRowHeight:ie,activePageIndex:n,pinActivePage:r}),{geometryForPage:et,indentState:en,refresh:Q}=UD(E,t,Ee,O,!0,x),fe=r?n:0,pe=t[fe]??"",Ce=l.useCallback(H=>hi(t[H]??""),[t]),Pt=b&&hi(pe),Vt=l.useCallback(H=>{Ve(H),requestAnimationFrame(()=>{const J=E.current;if(!J)return;const ue=qe(J,H);ue&&fo(ue)})},[Ve]),Mn=l.useCallback(H=>{if(H<0||H>=t.length)return;const J=(o==null?void 0:o.current)??E.current;if(!J)return;const ue=ei(t.length,ie),Ne=J.scrollTop,At=Ne+J.clientHeight,Cn=bb(Ne,ue,t.length),tt=yb(At,ue,t.length);H>=Cn&&H<=tt||Ve(H)},[ie,t.length,o,Ve]),Wt=l.useCallback(H=>{Mn(H),requestAnimationFrame(()=>{const J=E.current;if(!J)return;const ue=qe(J,H);ue&&Tw(ue)})},[Mn]),De=l.useRef(Mn);De.current=Mn,l.useLayoutEffect(()=>{De.current(n)},[n,t.length]),l.useLayoutEffect(()=>{const H=g;if(!H)return;const J=H.current;J!=null&&(H.current=null,Wt(J))},[n,t.length,g,Wt]);const yn=l.useCallback(H=>{var Ne;if(N.current=H,H!==n&&a(H),(Ne=ae.current)==null||Ne.call(ae,H),!Ee.includes(H)){Vt(H);return}Q();const J=E.current;if(!J)return;const ue=qe(J,H);ue&&requestAnimationFrame(()=>fo(ue))},[n,a,Q,Vt,Ee]);l.useImperativeHandle(L,()=>({getContainer:()=>E.current,getActivePageRoot:()=>{const H=E.current;return H?qe(H,N.current):null},getActivePageIndex:()=>N.current,flushPageHtml:H=>{var ue;const J=E.current;return J?((ue=qe(J,H))==null?void 0:ue.innerHTML)??null:null},ensurePageMounted:H=>{Vt(H)},focusPageAt:Wt,activatePageAt:yn}));const xn=l.useCallback((H,J,ue,Ne)=>{const At=Xt(ye(ue).body),Cn=J===document.activeElement;(Ne!=null&&Ne.forceBodySync||!Cn)&&ls(J,At,{resolveDataUrl:R,hydrateEmbeddedImages:T}),ju(J),pi(J);const tt=Ps(J);Ss(J),wo(J,ue);const Ke=ut(J);if(Ke&&fg(J,Ke),tt){const Ae=Xt(ye(ue).body);J.innerHTML!==Ae&&bw(Ae,J)&&G.current(H,J.innerHTML)}},[T,R]);l.useLayoutEffect(()=>{M.current.clear()},[t.length]),l.useLayoutEffect(()=>{const H=E.current;if(!H)return;const J=me.current,ue=J===null||J.length!==t.length;ue&&De.current(n);const Ne=new Set(ne.current),At=new Set(Ee);ue&&At.add(n);for(const tt of At){const Ke=!Ne.has(tt),Ae=t[tt]!==(J==null?void 0:J[tt]);if(!ue&&!Ke&&!Ae)continue;const We=qe(H,tt);We&&xn(tt,We,t[tt]??"",{forceBodySync:ue})}me.current=t,ne.current=Ee,ue&&(re!=null&&re.current)&&(re.current=!1);const Cn=requestAnimationFrame(Q);return()=>cancelAnimationFrame(Cn)},[n,t,re,xn,Q,Ee]),l.useLayoutEffect(()=>{const H=E.current;if(!H)return;const J=ue=>{var Ne;(Ne=K.current)==null||Ne.call(K,ue)};return H.addEventListener("beforeinput",J),()=>H.removeEventListener("beforeinput",J)},[]);const _r=l.useCallback((H,J)=>{var ue;yn(H),(ue=q.current)==null||ue.call(q,J)},[yn]),Nr=l.useCallback((H,J)=>{G.current(H,J)},[]),Lr=l.useCallback((H,J)=>{var ue;(ue=Z.current)==null||ue.call(Z,H,J)},[]),ve=l.useCallback((H,J)=>{const ue=hb(t[H]??"",H),Ne=Math.max(J,ue);M.current.set(H,Ne),St(H,Ne)},[St,t]),tn=l.useCallback((H,J)=>{var ue;(ue=ee.current)==null||ue.call(ee,H,J)},[]),Br=l.useCallback((H,J)=>{var ue;(ue=se.current)==null||ue.call(se,H,J)},[]),sr=V("visualEditorAria"),lr=l.useMemo(()=>Ee.map(H=>i.jsx(zI,{index:H,pageHtml:t[H]??"",showVerticalRuler:Pt&&Ce(H),pageSized:Ce(H),geometry:et(H),rulerUnit:C,zoomScale:x,placeholder:h,disabled:y,visualEditorAria:sr,onActivate:yn,onPointerDown:_r,onPageChange:Nr,onPageFlush:Lr,suppressPageFlushRef:re,onMeasured:ve,onMarginChange:tn,onMarginPreview:Br,onMouseUp:P,onContextMenu:j,onRulerRefresh:Q},H)),[yn,y,et,tn,Br,Nr,Lr,_r,ve,j,P,Ce,t,h,Q,C,Pt,Ee,sr,x]);return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:Pt?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(kb,{showRulers:Pt,geometry:et(fe),indentState:en,rulerUnit:C,zoomScale:x,onMarginChange:H=>{v==null||v(fe,H)},onMarginPreview:H=>{k==null||k(fe,H)},onIndentChange:H=>{S==null||S(H)}}),i.jsx("div",{className:ke.pageZoomContent,style:vb(x),children:i.jsxs("div",{ref:E,className:ke.multiPageContainer,style:{display:"flex",flexDirection:"column",alignItems:Pt?"center":"stretch",width:"100%",minHeight:Pt?void 0:"100%",position:"relative"},children:[He>0?i.jsx("div",{"aria-hidden":!0,style:{height:He,flexShrink:0}}):null,lr,$e>0?i.jsx("div",{"aria-hidden":!0,style:{height:$e,flexShrink:0}}):null]})})]})});function $I(e,t,n){return r=>{const o=e();o&&n(o,t(),r)}}function UI(e,t,n,r){return o=>{const a=e();if(!a)return;const s=n(a,t(),o);r(s.pageHtml)}}function VI(e,t,n){return(r,o)=>{const a=e(r);a&&n(a,t(r),o)}}function WI(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 Yf(e,t,n){return r=>{const o=e();o&&KD(o,{...r,unit:t})&&n(o)}}const GI="_field_1knrr_1",ZI="_label_1knrr_8",qI="_button_1knrr_12",YI="_swatch_1knrr_37",XI="_swatchEmpty_1knrr_44",Zo={field:GI,label:ZI,button:qI,swatch:YI,swatchEmpty:XI};function Ut({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=vo(h,f,g);l.useEffect(()=>{if(!h)return;const v=S=>{var R,T;const A=S.target;(R=d.current)!=null&&R.contains(A)||(T=g.current)!=null&&T.contains(A)||y(!1)},k=S=>{var A;S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),y(!1),(A=f.current)==null||A.focus())};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0)}},[h]);const C=`${Zo.swatch}${!n||r?` ${Zo.swatchEmpty}`:""}`,x=n&&!r?{backgroundColor:n}:void 0;return i.jsxs("div",{className:Zo.field,ref:d,children:[i.jsx("span",{className:Zo.label,children:e}),i.jsx("button",{ref:f,type:"button",className:Zo.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(Pe,{children:i.jsx("div",{ref:g,id:u,className:wr.popover,style:{top:b.top,left:b.left,zIndex:1400},children:i.jsx(Xu,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:o,fallbackCustom:a,onChange:s,onCommit:()=>y(!1)})})}):null]})}const gc=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],JI={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Qu({tab:e,value:t,fonts:n,disabled:r,onTabChange:o,onChange:a}){const s=X(),u=l.useId(),d=l.useId(),f=n??Cp(),g=gc.find(h=>h.id===e)??gc[0];return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":s("fontDialogTitle"),children:gc.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(ab,{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(sb,{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(Ut,{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(Ut,{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")}),$t.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(JI[h].label)]},h))]})]}):null})]})}function QI({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=X(),k=l.useId(),S=l.useRef(null),[A,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]),Ye(S,{open:e,onClose:x}),e?i.jsx(Pe,{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:T=>T.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:k,children:v("fontDialogTitle")}),i.jsx(Qu,{tab:t,value:A,fonts:h,disabled:y,onTabChange:b,onChange:R}),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(A),children:v("fontDialogOk")})]})]})})}):null}const ej={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Je({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:o,inputId:a,onChange:s}){const u=X(),d=l.useId(),f=a??d,g=(t==null?void 0:t.unit)??hu,[h,y]=l.useState(()=>t?be(t.value):""),[b,C]=l.useState(!1);l.useEffect(()=>{b||y(t?be(t.value):"")},[t,b]);const x=v=>{const k=v.trim();if(!k){s(null),y("");return}const S=li(k,g,r);if(!S){y(t?be(t.value):"");return}s(S),y(be(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=li(h,k,r);s(S)}},children:fu.map(v=>i.jsx("option",{value:v,children:u(ej[v])},v))})]})]})}function ed({shadow:e,disabled:t,onChange:n}){const r=X();return i.jsxs("div",{className:p.shadowGrid,children:[i.jsx(Je,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetX:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetY:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:o=>{n({...e,blur:o??{value:0,unit:"px"}})}}),i.jsx(Je,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:o=>{n({...e,spread:o??{value:0,unit:"px"}})}}),i.jsx(Ut,{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 Pb=[{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}],Ab=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],tj={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},nj={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"};function Tb({legendKey:e="imagePropertiesTabAdvanced",value:t,disabled:n,onChange:r}){const o=X(),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(rj,{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")}),Mu.map(u=>i.jsx("option",{value:u,children:o(tj[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")}),_u.map(u=>i.jsx("option",{value:u,children:o(nj[u])},u))]})]})]})}function rj({value:e,disabled:t,onChange:n}){const r=X(),o=l.useId(),a=e===null?null:Wa(e),[s,u]=l.useState(()=>a===null?"":be(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":be(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?"":be(a));return}const C=$p(b);n(C),u(be(Wa(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 oj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function fs({label:e,inputAria:t,value:n,disabled:r,onChange:o}){const a=X(),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)??r1,[y,b]=l.useState(()=>n?be(n.value):""),[C,x]=l.useState(!1),[v,k]=l.useState(!1),S=vo(v,f,g,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{C||b(n?be(n.value):"")},[n,C]),l.useEffect(()=>{if(!v)return;const P=L=>{var E,N;const V=L.target;(E=d.current)!=null&&E.contains(V)||(N=g.current)!=null&&N.contains(V)||k(!1)},j=L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),k(!1))};return document.addEventListener("pointerdown",P),document.addEventListener("keydown",j,!0),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",j,!0)}},[v]);const A=P=>{const j=P.trim();if(!j){o(null),b("");return}const L=tf(j,h);if(!L){b(n?be(n.value):"");return}o(L),b(be(L.value))},R=o1[h],T=(n==null?void 0:n.value)??null,D=v?i.jsx(Pe,{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(P=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":T===P,onMouseDown:j=>j.preventDefault(),onClick:()=>{o({value:P,unit:h}),b(be(P)),k(!1)},children:be(P)})},P))})}):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: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),A(y)},onChange:P=>b(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),A(y),k(!1),P.currentTarget.blur()),P.key==="ArrowDown"&&(P.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:P=>P.preventDefault(),onClick:()=>k(P=>!P)})]}),i.jsxs("div",{className:Ze.field,children:[i.jsx("select",{className:Ze.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:P=>{const j=P.target.value;if(n){o({value:n.value,unit:j});return}y.trim()&&o(tf(y,j))},children:kg.map(P=>i.jsx("option",{value:P,children:a(oj[P])},P))}),i.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),D]})]})}const ij={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},aj={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function sj(e,t,n){return t&&n?"custom":e.startsWith("data:")?"file":e.trim()?"url":"file"}function Rb({src:e,disabled:t,customImagePicker:n,disableBuiltinSources:r=!1,onSrcChange:o,onCustomPick:a,onSourceChange:s}){const u=X(),d=l.useId(),f=l.useId(),g=l.useRef(null),h=r&&!!n,[y,b]=l.useState(()=>sj(e,r,n)),[C,x]=l.useState(()=>e.startsWith("data:")?"":e),[v,k]=l.useState(""),[S,A]=l.useState(null),[R,T]=l.useState(!1);l.useEffect(()=>{s==null||s(y)},[s,y]),l.useEffect(()=>{h&&b("custom")},[h]);const D=y==="file"&&e.startsWith("data:")?e:y==="url"?C:"",P=y==="custom"?null:pn(D),j=y==="custom"?null:y==="file"&&S?aj[S]:P&&(y==="file"||C.trim().length>0)?ij[P]:null,L=()=>{t||!n||a==null||a()},V=E=>{var K;const N=(K=E.target.files)==null?void 0:K[0];N&&(T(!0),A(null),Zw(N).then(G=>{k(N.name),b("file"),o(G),T(!1)},G=>{const Z=G instanceof Error?G.message:"";k(""),b("file"),A(Z==="tooLarge"||Z==="type"?Z:"type"),T(!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:Kw,hidden:!0,disabled:t,"aria-label":u("imageDialogChooseFile"),onChange:V}),i.jsx("button",{type:"button",className:p.action,disabled:t||R,onClick:()=>{var E;return(E=g.current)==null?void 0:E.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":j!==null,"aria-describedby":j?f:void 0,onChange:E=>{const N=E.target.value;x(N),o(N.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:L,children:n.buttonCaption})]}):null,j?i.jsx("p",{id:f,className:p.error,children:u(j)}):null]})}function lj(e){return pn(e.trim())===null}function cj(e){return Dg(e)?{width:null,height:null}:e==="fill"?{width:{...so},height:{...so}}:{width:{...so},height:null}}function uj({value:e,disabled:t,customImagePicker:n,disableBuiltinSources:r,onCustomImagePick:o,onChange:a}){const s=X(),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(Rb,{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(fs,{label:s("imagePropertiesWidth"),inputAria:s("imagePropertiesWidthAria"),value:e.width,disabled:t,onChange:f=>d("width",f)}),i.jsx(fs,{label:s("imagePropertiesHeight"),inputAria:s("imagePropertiesHeightAria"),value:e.height,disabled:t,onChange:f=>d("height",f)}),i.jsx(Tb,{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}:cj(f.fit);a({...e,opacity:f.opacity,fit:f.fit,position:f.position,...g})}})]}):null]})}const dj={left:gs,center:ps,right:hs,justify:op},mj={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},fj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},pj={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},gj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},hj={value:1,unit:"pt"},bj={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1},yj={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid"},Xf={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid",page:"paragraphDialogBreakPage"};function qo(e){return{top:e,right:e,bottom:e,left:e}}function Jf(e){for(const t of at)if(e[t])return e[t];return null}function xj(){const e=[...Pb];for(const t of Ab)e.some(n=>n.id===t.id)||e.push(t);return e}function td({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:o="paragraphDialogTitle",backgroundImage:a,customImagePicker:s,disableBuiltinBackgroundImageSources:u,onCustomImagePick:d,onBackgroundImageChange:f,onTabChange:g,onChange:h}){const y=X(),b=r?xj().filter(P=>r.includes(P.id)):Pb,C=l.useId(),x=l.useId(),v=l.useId(),k=l.useId(),[S,A]=l.useState(()=>In(t.margin,qo(t.margin.top))),[R,T]=l.useState(()=>In(t.padding,qo(t.padding.top))),D=(P,j,L,V)=>{const E=t[P],N=j?qo(V):{...E,[L]:V};h({...t,[P]:N,[`${P}Mixed`]:!1})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":y(o),children:b.map(P=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":P.id===e,disabled:!P.implemented,onClick:()=>g(P.id),children:y(P.labelKey)},P.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:xh.map(P=>{const j=dj[P],L=!t.alignMixed&&t.align===P;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":L,"aria-label":y(mj[P].aria),disabled:n,onClick:()=>{h({...t,align:P,alignMixed:!1})},children:i.jsx(j,{})},P)})})]}),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 P=!t.listMixed&&t.list==="ul"?null:"ul";h({...t,list:P,listMixed:!1})},children:i.jsx(ip,{})}),i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":y("commandNumberedListAria"),disabled:n,onClick:()=>{const P=!t.listMixed&&t.list==="ol"?null:"ol";h({...t,list:P,listMixed:!1})},children:i.jsx(cp,{})})]})]})]}):null,e==="spacing"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogSpacing")}),i.jsx(Qf,{legend:y("paragraphDialogMargin"),sides:t.margin,linked:S,disabled:n,allowNegative:!0,onLinkedChange:P=>{A(P),P&&h({...t,margin:qo(Jf(t.margin)),marginMixed:!1})},onSideChange:(P,j)=>D("margin",S,P,j)}),i.jsx(Qf,{legend:y("paragraphDialogPadding"),sides:t.padding,linked:R,disabled:n,onLinkedChange:P=>{T(P),P&&h({...t,padding:qo(Jf(t.padding)),paddingMixed:!1})},onSideChange:(P,j)=>D("padding",R,P,j)}),i.jsx(wj,{value:t.lineHeight,disabled:n,onChange:P=>{h({...t,lineHeight:P,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:P=>{h({...t,breakInside:P.target.value,breakInsideMixed:!1})},children:Np.map(P=>i.jsx("option",{value:P,children:y(yj[P])},P))})]}),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:P=>{h({...t,breakAfter:P.target.value,breakAfterMixed:!1})},children:Rc.map(P=>i.jsx("option",{value:P,children:y(Xf[P])},P))})]}),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:P=>{h({...t,breakBefore:P.target.value,breakBeforeMixed:!1})},children:Rc.map(P=>i.jsx("option",{value:P,children:y(Xf[P])},P))})]})]})]}):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:P=>{const j=P.target.value;h({...t,border:{style:j,width:j==="none"?null:t.border.width??hj,color:j==="none"?null:t.border.color},borderMixed:!1})},children:Cs.map(P=>i.jsx("option",{value:P,children:y(pj[P])},P))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:y("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:P=>{h({...t,border:{...t.border,width:P},borderMixed:!1})}}),i.jsx(Ut,{label:y("paragraphDialogBorderColor"),noneLabel:y("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:P=>{h({...t,border:{...t.border,color:P},borderMixed:!1})}})]}):null,i.jsx(Je,{label:y("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:P=>{h({...t,borderRadius:P,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:bj,shadowMixed:!1})}}),y("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(ed,{shadow:t.boxShadow,disabled:n,onChange:P=>{h({...t,boxShadow:P,shadowMixed:!1})}}):null]}):null,e==="background"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogTabBackground")}),i.jsx(Ut,{label:y("paragraphDialogBackgroundColor"),noneLabel:y("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:P=>{h({...t,backgroundColor:P,backgroundMixed:!1})}}),i.jsx(Cj,{value:t.opacity,disabled:n,onChange:P=>{h({...t,opacity:P,opacityMixed:!1})}})]}):null,e==="backgroundImage"&&a&&f?i.jsx(uj,{value:a,disabled:n,customImagePicker:s,disableBuiltinSources:u,onCustomImagePick:d,onChange:f}):null]})]})}function Cj({value:e,disabled:t,onChange:n}){const r=X(),o=l.useId(),a=e===null?null:Wa(e),[s,u]=l.useState(()=>a===null?"":be(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":be(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?"":be(a));return}const C=$p(b);n(C),u(be(Wa(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 Qf({legend:e,sides:t,linked:n,disabled:r,allowNegative:o=!1,onLinkedChange:a,onSideChange:s}){const u=X(),d=n?["top"]:at;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(Je,{label:n?e:u(fj[f]),value:t[f],disabled:r,allowNegative:o,onChange:g=>s(f,g)},f))})]})}function wj({value:e,disabled:t,onChange:n}){const r=X(),o=l.useId(),a=vj(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?"":be(s)),f=(e==null?void 0:e.kind)==="length"?e.unit:hu;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?"":be(s));return}n({kind:"number",value:y}),d(be(y));return}const h=li(g,f,!1);if(!h){d(s===null?"":be(s));return}n({kind:"length",value:h.value,unit:h.unit}),d(be(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(be(v));return}const y=h,b=li(u||"1",y,!1),C=(b==null?void 0:b.value)??1;n({kind:"length",value:C,unit:y}),d(be(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(gj[g])},g))]})]})]})}function vj(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}function kj({open:e,tab:t,value:n,backgroundImage:r,disabled:o,customImagePicker:a,disableBuiltinBackgroundImageSources:s,onCustomImagePick:u,onTabChange:d,onApply:f,onClose:g}){const h=X(),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??mn()))},[e,n,r]),Ye(b,{open:e,onClose:g,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),e?i.jsx(Pe,{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(td,{tab:t,value:C,disabled:o,backgroundImage:v,customImagePicker:a,disableBuiltinBackgroundImageSources: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 Sj=["auto","A4","letter","legal","custom"],Pj={auto:"pageAtRuleSizeAuto",A4:"pageAtRuleSizeA4",letter:"pageAtRuleSizeLetter",legal:"pageAtRuleSizeLegal",custom:"pageAtRuleSizeCustom"},Aj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"};function ep(e){return e===null?"":be(e.value)}function Tj({value:e,disabled:t,onChange:n,onReset:r}){const o=X(),a=l.useId(),[s,u]=l.useState(!0),d=e??Wn(),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:Sj.map(g=>i.jsx("option",{value:g,children:o(Pj[g])},g))})]}),d.sizePreset==="custom"?i.jsxs("div",{className:p.sideGrid,children:[i.jsx(hc,{label:o("pageAtRuleWidth"),value:d.customWidth,disabled:t,onChange:g=>n({...d,customWidth:g})}),i.jsx(hc,{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"]:at).map(g=>i.jsx(hc,{label:o(s?"pageAtRuleMargins":Aj[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 hc({label:e,value:t,disabled:n,onChange:r}){const o=X(),a=l.useId(),[s,u]=l.useState(()=>ep(t)),d=(t==null?void 0:t.unit)??hu;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=li(f,d,!1);if(!g){u(ep(t));return}r(g),u(be(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 Rj=Ab.map(e=>e.id);function Dj(e){return{...Pr(),...e}}function Ij(e){const{align:t,alignMixed:n,list:r,listMixed:o,...a}=e;return a}function jj({open:e,tab:t,value:n,fonts:r,disabled:o,printTabVisible:a=!1,initialParagraphTab:s="spacing",customImagePicker:u,disableBuiltinBackgroundImageSources:d,onCustomImagePick:f,onTabChange:g,onApply:h,onResetAtRule:y,onClose:b}){const C=X(),x=l.useId(),v=l.useRef(null),[k,S]=l.useState("general"),[A,R]=l.useState("spacing"),[T,D]=l.useState(n.font),[P,j]=l.useState(n.box),[L,V]=l.useState(n.backgroundImage),[E,N]=l.useState(n.atRule??Wn());if(l.useEffect(()=>{e&&(S("general"),R(s==="general"?"spacing":s),D(n.font),j(n.box),V(n.backgroundImage??mn()),N(n.atRule??Wn()),t==="print"&&!a&&g("font"))},[e,n,t,a,s,g]),Ye(v,{open:e,onClose:b,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const K=C("pageDialogTitle"),G=t==="print"&&!a?"font":t;return i.jsx(Pe,{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:Z=>Z.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:x,children:K}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":K,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(Qu,{tab:k,value:T,fonts:r,disabled:o,onTabChange:S,onChange:D})}):G==="paragraph"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(td,{tab:A,value:Dj(P),disabled:o,tabs:Rj,tablistLabelKey:"pageDialogTitle",backgroundImage:L,customImagePicker:u,disableBuiltinBackgroundImageSources:d,onCustomImagePick:f,onBackgroundImageChange:V,onTabChange:Z=>{Z!=="general"&&R(Z)},onChange:Z=>j(Ij(Z))})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(Tj,{value:E,disabled:o,onChange:N,onReset:()=>{N(Wn()),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:T,box:P,backgroundImage:L,atRule:a?E:n.atRule??Wn()}),children:C("fontDialogOk")})]})]})})})}function Ej({open:e,disabled:t,onClose:n,onConfirm:r}){const o=X(),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(Pe,{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("deletePageDialogCloseAria"),onClick:n,children:i.jsx(Qe,{})})]}),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 Mj(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function tp(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 _j(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 Nj({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=X(),x=l.useId(),v=l.useId(),k=l.useRef(null),[S,A]=l.useState(r),[R,T]=l.useState(g),[D,P]=l.useState("general"),[j,L]=l.useState("general"),[V,E]=l.useState(()=>tp(o)),[N,K]=l.useState(()=>Gc(a)),[G,Z]=l.useState(!1);l.useEffect(()=>{e&&(A(r),T(g),P("general"),L("general"),E(tp(o)),K(Gc(a)),Z(!1))},[e,r,o,a,g]);const ae=l.useCallback(()=>{if(G){Z(!1);return}b()},[G,b]);if(Ye(k,{open:e,onClose:ae,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const q=C(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),ee=S.trim().length>0,se=!!(d||u),me=()=>{const ne=S.trim();ne&&h({id:n??Mj(),name:ne,font:_j(V),paragraph:kh(N)})};return i.jsx(Pe,{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:ne=>ne.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:x,children:q}),i.jsx("button",{type:"button",className:p.close,"aria-label":C("customStyleDialogCloseAria"),onClick:b,children:i.jsx(Qe,{})})]}),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:se,onClick:()=>Z(!1),children:C("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:se||!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:se,onChange:ne=>A(ne.target.value)})]})}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":q,children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":R==="font",onClick:()=>T("font"),children:C("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":R==="paragraph",onClick:()=>T("paragraph"),children:C("customStyleDialogTabParagraph")})]}),R==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Qu,{tab:D,value:V,fonts:f,disabled:se,onTabChange:P,onChange:E})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(td,{tab:j,value:N,disabled:se,onTabChange:L,onChange:K})}),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:se,onClick:()=>Z(!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:se||!ee,onClick:me,children:C("fontDialogOk")})]})]})]})]})})})}function Lj({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),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]),Ye(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(Pe,{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(Qe,{})})]}),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 Bj={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function Fj({open:e,existingIds:t,disabled:n,onApply:r,onClose:o}){const a=X(),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=Dh(g,C);if(l.useEffect(()=>{e&&(h(""),b(!1))},[e]),Ye(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(Pe,{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:A=>A.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(Qe,{})})]}),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(nr,{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:A=>h(A.target.value)}),v?i.jsx("p",{id:d,className:p.error,children:a(Bj[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 Hj={empty:"audioDialogErrorEmpty",invalid:"audioDialogErrorInvalid"},zj={type:"audioDialogErrorType",tooLarge:"audioDialogErrorTooLarge"};function Oj({open:e,disabled:t,customAudioPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=X(),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(""),[A,R]=l.useState(""),[T,D]=l.useState(""),[P,j]=l.useState(null),[L,V]=l.useState(!1);if(l.useEffect(()=>{e&&(C("file"),v(""),S(""),R(""),D(""),j(null),V(!1),y.current&&(y.current.value=""))},[e]),Ye(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const E=b==="file"?k:b==="url"?x:"",N=b==="custom"?null:Zu(E),K=b==="custom"?null:b==="file"&&P?zj[P]:N&&(b==="file"||x.trim().length>0)?Hj[N]:null,G=b!=="custom"&&N===null&&!(b==="file"&&P)&&!t&&!L,Z=()=>{t||!n||o==null||o()},ae=()=>{G&&r({src:E.trim(),title:T.trim()})},q=ee=>{var me;const se=(me=ee.target.files)==null?void 0:me[0];se&&(V(!0),j(null),p0(se).then(ne=>{S(ne),R(se.name),C("file"),V(!1)},ne=>{const M=ne instanceof Error?ne.message:"";S(""),R(""),C("file"),j(M==="tooLarge"||M==="type"?M:"type"),V(!1),y.current&&(y.current.value="")}))};return i.jsx(Pe,{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:ee=>ee.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(Qe,{})})]}),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:s0,hidden:!0,disabled:t,"aria-label":s("audioDialogChooseFile"),onChange:q}),i.jsx("button",{type:"button",className:p.action,disabled:t||L,onClick:()=>{var ee;return(ee=y.current)==null?void 0:ee.click()},children:s("audioDialogChooseFile")}),A?i.jsx("span",{className:p.fileName,children:A}):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":K!==null,"aria-describedby":K?g:void 0,onChange:ee=>v(ee.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:Z,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:T,disabled:t,onChange:ee=>D(ee.target.value)})]}):null,K?i.jsx("p",{id:g,className:p.error,children:s(K)}):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:ae,children:s("fontDialogOk")}):null]})]})})})}function Kj({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=X(),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]),Ye(g,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const A=lj(h)&&!t,R=()=>{A&&r({src:h.trim(),alt:b.trim(),title:x.trim()})};return i.jsx(Pe,{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:T=>T.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(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx(Rb,{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:T=>C(T.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:T=>v(T.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:!A,onClick:R,children:s("fontDialogOk")}):null]})]})})})}const $j=[{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}],Uj={left:gs,center:ps,right:hs},Vj=["left","center","right"],Wj={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},Gj=["width","height","lock"],Zj={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},qj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Yj={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Xj={value:1,unit:"pt"},Jj={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 bc(e){return{top:e,right:e,bottom:e,left:e}}function Qj(e){for(const t of at)if(e[t])return e[t];return null}function eE({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:o,onChange:a}){const s=X(),u=l.useId(),d=l.useId(),f=l.useId(),[g,h]=l.useState(()=>In(t.margin,bc(t.margin.top))),y=t.align==="center",b=(x,v)=>{if(t.sizeMode==="lock"&&v){const k=oi(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=oi("width",t.width,n);a({...t,sizeMode:x,width:v.width,height:v.height});return}if(t.height){const v=oi("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:$j.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:Gj.map(x=>i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":t.sizeMode===x,disabled:r,onClick:()=>C(x),children:s(Zj[x])},x))}),i.jsx(fs,{label:s("imagePropertiesWidth"),inputAria:s("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:x=>b("width",x)}),i.jsx(fs,{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:Vj.map(x=>{const v=Uj[x];return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":t.align===x,"aria-label":s(Wj[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:bc(Qj(t.margin))})}}),s("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(g?["top"]:at).map(x=>i.jsx(Je,{label:s(g?"paragraphDialogMargin":qj[x]),value:t.margin[x],disabled:r||y&&(x==="left"||x==="right"),allowNegative:!0,onChange:v=>{const k=g?bc(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??Xj,color:v==="none"?null:t.border.color}})},children:Cs.map(x=>i.jsx("option",{value:x,children:s(Yj[x])},x))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:s("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:x=>{a({...t,border:{...t.border,width:x}})}}),i.jsx(Ut,{label:s("paragraphDialogBorderColor"),noneLabel:s("colorNone"),value:t.border.color,disabled:r,onChange:x=>{a({...t,border:{...t.border,color:x}})}})]}):null,i.jsx(Je,{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:Jj})}}),s("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(ed,{shadow:t.boxShadow,disabled:r,onChange:x=>{a({...t,boxShadow:x})}}):null]})]}):null,e==="advanced"?i.jsxs(i.Fragment,{children:[i.jsx(Tb,{value:{opacity:t.opacity,fit:t.objectFit,position:t.objectPosition},disabled:r,onChange:x=>{a(p1({...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?"":be(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 tE({open:e,tab:t,value:n,aspectRatio:r=1,disabled:o,onTabChange:a,onApply:s,onClose:u}){const d=X(),f=l.useId(),g=l.useRef(null),[h,y]=l.useState(n);return l.useEffect(()=>{e&&y(n)},[e,n]),Ye(g,{open:e,onClose:u,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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(Qe,{})})]}),i.jsx(eE,{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 nE({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=X(),v=l.useId(),k=l.useId(),S=l.useId(),A=l.useId(),R=l.useId(),T=l.useRef(null),[D,P]=l.useState(n),[j,L]=l.useState(r),[V,E]=l.useState(o),[N,K]=l.useState(a),[G,Z]=l.useState(s),[ae,q]=l.useState(u),[ee,se]=l.useState(d),[me,ne]=l.useState(g);if(l.useEffect(()=>{e&&(P(n),L(r),E(o),K(a),Z(s),q(u),se(d),ne(g))},[e,n,r,o,a,s,u,d,g]),Ye(T,{open:e,onClose:C,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),!e)return null;const M=()=>Ds({title:j,targetBlank:V,textDecorationNone:N,hoverMode:G,hoverColor:ae,hoverHtml:ee}),re=()=>{const ie=D.trim();!ie||h||b({...M(),href:ie})},O=()=>{!me||h||b({...M(),href:`#${me}`})};return i.jsx(Pe,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:C,children:i.jsxs("div",{ref:T,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":v,onMouseDown:ie=>ie.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:D,disabled:h,onChange:ie=>P(ie.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:j,disabled:h,onChange:ie=>L(ie.target.value)})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:V,disabled:h,onChange:ie=>E(ie.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:A,children:x("linkDialogBookmark")}),i.jsxs("select",{id:A,className:`${p.select} ${p.fullSelect}`,value:me,disabled:h,onChange:ie=>ne(ie.target.value),children:[i.jsx("option",{value:""}),f.map(ie=>i.jsx("option",{value:ie.id,children:ie.id},ie.id))]})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:N,disabled:h,onChange:ie=>K(ie.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:()=>Z("color"),children:x("linkDialogHoverColor")}),i.jsx("button",{type:"button",className:p.action,"aria-pressed":G==="html",disabled:h,onClick:()=>Z("html"),children:x("linkDialogHoverHtml")})]}),G==="color"?i.jsx(Ut,{label:x("linkDialogHoverColorField"),noneLabel:x("colorNone"),value:ae,disabled:h,onChange:q}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:R,children:x("linkDialogHoverHtmlAria")}),i.jsx("textarea",{id:R,className:p.textarea,value:ee,disabled:h,spellCheck:!1,onChange:ie=>se(ie.target.value)})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:h||!me,onClick:O,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||!D.trim(),onClick:re,children:x("fontDialogOk")})]})]})})})}const np={empty:"youtubeDialogErrorEmpty",invalid:"youtubeDialogErrorInvalid"};function rE({open:e,disabled:t,customVideoPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=X(),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]),Ye(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const S=y==="custom"?null:zh(C),A=y==="custom"?null:S&&C.trim().length>0?np[S]:S==="empty"&&C.trim().length===0?null:S?np[S]:null,R=y!=="custom"&&S===null&&!t&&C.trim().length>0,T=()=>{t||!n||o==null||o()},D=()=>{R&&r({url:C.trim(),title:v.trim()})};return i.jsx(Pe,{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:P=>P.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(Qe,{})})]}),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":A!==null,"aria-describedby":A?g:void 0,onChange:P=>x(P.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:T,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:P=>k(P.target.value)})]}):null,A?i.jsx("p",{id:g,className:p.error,children:s(A)}):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:!R,onClick:D,children:s("fontDialogOk")}):null]})]})})})}const oE="_grid_1bpma_1",iE="_cell_1bpma_8",aE="_sizeLabel_1bpma_27",sE="_sizeFields_1bpma_33",lE="_numberInput_1bpma_37",Qr={grid:oE,cell:iE,sizeLabel:aE,sizeFields:sE,numberInput:lE},$n={rows:3,cols:3};function cE({open:e,disabled:t,onApply:n,onClose:r}){const o=X(),a=l.useId(),s=l.useId(),u=l.useId(),d=l.useRef(null),[f,g]=l.useState($n.rows),[h,y]=l.useState($n.cols),[b,C]=l.useState(String($n.rows)),[x,v]=l.useState(String($n.cols)),[k,S]=l.useState(!1);if(l.useEffect(()=>{e&&(g($n.rows),y($n.cols),C(String($n.rows)),v(String($n.cols)),S(!1))},[e]),Ye(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=ph(f,h)&&!t,T=(L,V)=>{const E=Math.min(ao,Math.max(io,L)),N=Math.min(ao,Math.max(io,V));g(E),y(N),C(String(E)),v(String(N))},D=(L,V)=>{const E=Number.parseInt(L,10);if(!Number.isFinite(E)){V==="rows"?C(String(f)):v(String(h));return}S(!0),V==="rows"?T(E,h):T(f,E)},P=(L,V)=>{const E=L.replace(/\D/g,"");if(V==="rows"?C(E):v(E),E==="")return;const N=Number.parseInt(E,10);Number.isFinite(N)&&(S(!0),V==="rows"?T(N,h):T(f,N))},j=L=>{(L.key==="e"||L.key==="E"||L.key==="+"||L.key==="-"||L.key===".")&&L.preventDefault()};return i.jsx(Pe,{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:L=>L.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(Qe,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx("div",{className:Qr.grid,role:"grid","aria-label":o("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:ff},(L,V)=>Array.from({length:ff},(E,N)=>{const K=V+1,G=N+1,Z=K<=f&&G<=h;return i.jsx("button",{type:"button",className:Qr.cell,role:"gridcell","data-active":Z?"true":void 0,"aria-label":`${K} × ${G}`,"aria-pressed":Z&&K===f&&G===h,disabled:t,onMouseEnter:()=>{k||T(K,G)},onClick:()=>{S(!0),T(K,G)}},`${K}-${G}`)}))}),i.jsxs("p",{className:Qr.sizeLabel,children:[o("tableDialogSize"),": ",f," × ",h]}),i.jsxs("div",{className:`${p.sizeRow} ${Qr.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:Qr.numberInput,type:"number",inputMode:"numeric",min:io,max:ao,step:1,value:b,disabled:t,onKeyDown:j,onChange:L=>P(L.target.value,"rows"),onBlur:()=>D(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:Qr.numberInput,type:"number",inputMode:"numeric",min:io,max:ao,step:1,value:x,disabled:t,onKeyDown:j,onChange:L=>P(L.target.value,"cols"),onBlur:()=>D(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:!R,onClick:()=>{R&&n({rows:f,cols:h})},children:o("tableDialogInsert")})]})]})})})}const uE={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},dE={value:1,unit:"pt"},mE={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 fE({value:e,disabled:t,onChange:n}){const r=X(),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(Je,{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(Je,{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??dE,color:u==="none"?null:e.border.color}})},children:Cs.map(s=>i.jsx("option",{value:s,children:r(uE[s])},s))})]}),e.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Je,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:s=>n({...e,border:{...e.border,width:s}})}),i.jsx(Ut,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:s=>n({...e,border:{...e.border,color:s}})})]}):null,i.jsx(Je,{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:mE})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?i.jsx(ed,{shadow:e.boxShadow,disabled:t,onChange:s=>n({...e,boxShadow:s})}):null]})]})}function pE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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(Qe,{})})]}),i.jsx(fE,{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 gE=["left","center","right"],hE={left:gs,center:ps,right:hs},bE={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},yE={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},xE={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Ba(e){return{top:e,right:e,bottom:e,left:e}}function yc(e){for(const t of at)if(e[t])return e[t];return null}function CE({value:e,disabled:t,onChange:n}){const r=X(),o=l.useId(),a=l.useId(),s=l.useId(),[u,d]=l.useState(()=>In(e.padding,Ba(yc(e.padding))));return l.useEffect(()=>{d(In(e.padding,Ba(yc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx(Ut,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:f=>n({...e,backgroundColor:f})}),i.jsx(Ut,{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:Ba(yc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(u?["top"]:at).map(f=>i.jsx(Je,{label:r(u?"paragraphDialogPadding":yE[f]),value:e.padding[f],disabled:t,onChange:g=>{const h=u?Ba(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:gE.map(f=>{const g=hE[f],h=(e.textAlign??"left")===f;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":h,"aria-label":r(bE[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")}),js.map(f=>i.jsx("option",{value:f,children:r(xE[f])},f))]})]}),i.jsx(Je,{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 wE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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(Qe,{})})]}),i.jsx(CE,{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 vE={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},kE={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Fa(e){return{top:e,right:e,bottom:e,left:e}}function xc(e){for(const t of at)if(e[t])return e[t];return null}function SE({value:e,disabled:t,onChange:n}){const r=X(),o=l.useId(),[a,s]=l.useState(()=>In(e.padding,Fa(xc(e.padding))));return l.useEffect(()=>{s(In(e.padding,Fa(xc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx(Ut,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:u=>n({...e,backgroundColor:u})}),i.jsx(Ut,{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:Fa(xc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(a?["top"]:at).map(u=>i.jsx(Je,{label:r(a?"paragraphDialogPadding":vE[u]),value:e.padding[u],disabled:t,onChange:d=>{const f=a?Fa(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")}),js.map(u=>i.jsx("option",{value:u,children:r(kE[u])},u))]})]}),i.jsx(Je,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:u=>n({...e,height:u})})]})}function PE({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=X(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ye(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(Pe,{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(Qe,{})})]}),i.jsx(SE,{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 AE="_backdrop_9d3gw_1",TE="_dialog_9d3gw_12",RE="_headerRow_9d3gw_29",DE="_header_9d3gw_29",IE="_close_9d3gw_44",jE="_body_9d3gw_66",EE="_frame_9d3gw_75",ME="_actions_9d3gw_83",_E="_action_9d3gw_83",Rn={backdrop:AE,dialog:TE,headerRow:RE,header:DE,close:IE,body:jE,frame:EE,actions:ME,action:_E};function NE(e){const t=Zn(e);if(t.length<=1)return e;const n=[],r=[];for(const a of t){const s=ye(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 LE({open:e,html:t,onClose:n}){const r=X(),o=l.useId(),a=l.useRef(null),s=l.useRef(null),u=l.useMemo(()=>NE(t),[t]);return Ye(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&&Bc(d,u,r("previewDialogTitle"))},[e,u,r]),e?i.jsx(Pe,{children:i.jsx("div",{className:Rn.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:a,className:Rn.dialog,role:"dialog","aria-modal":"true","aria-labelledby":o,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:Rn.headerRow,children:[i.jsx("h2",{className:Rn.header,id:o,children:r("previewDialogTitle")}),i.jsx("button",{type:"button",className:Rn.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:i.jsx(Qe,{})})]}),i.jsx("div",{className:Rn.body,children:i.jsx("iframe",{ref:s,className:Rn.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var f;const d=(f=s.current)==null?void 0:f.contentDocument;d&&Bc(d,u,r("previewDialogTitle"))}})}),i.jsx("div",{className:Rn.actions,children:i.jsx("button",{type:"button",className:Rn.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const BE="0.0.11",FE="_backdrop_72ox3_1",HE="_dialog_72ox3_12",zE="_headerRow_72ox3_30",OE="_header_72ox3_30",KE="_close_72ox3_46",$E="_body_72ox3_68",UE="_product_72ox3_76",VE="_meta_72ox3_82",WE="_description_72ox3_87",GE="_website_72ox3_92",ZE="_cta_72ox3_97",qE="_link_72ox3_102",YE="_actions_72ox3_118",XE="_action_72ox3_118",bt={backdrop:FE,dialog:HE,headerRow:zE,header:OE,close:KE,body:$E,product:UE,meta:VE,description:WE,website:GE,cta:ZE,link:qE,actions:YE,action:XE};function JE({open:e,onClose:t}){const n=X(),r=l.useId(),o=l.useRef(null);return Ye(o,{open:e,onClose:t,escapeIgnoreSelectors:!1,focusableSelector:'a[href], button:not([disabled]):not([tabindex="-1"])'}),e?i.jsx(Pe,{children:i.jsx("div",{className:bt.backdrop,role:"presentation",onMouseDown:t,children:i.jsxs("div",{ref:o,className:bt.dialog,role:"dialog","aria-modal":"true","aria-labelledby":r,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:bt.headerRow,children:[i.jsx("h2",{id:r,className:bt.header,children:n("aboutDialogTitle")}),i.jsx("button",{type:"button",className:bt.close,onClick:t,"aria-label":n("aboutDialogCloseAria"),children:i.jsx(Qe,{})})]}),i.jsxs("div",{className:bt.body,children:[i.jsx("p",{className:bt.product,children:n("brandMarkAria")}),i.jsx("p",{className:bt.meta,children:n("aboutDialogVersion").replace("{version}",BE)}),i.jsx("p",{className:bt.description,children:n("aboutDialogDescription")}),i.jsxs("div",{className:bt.website,children:[i.jsx("p",{className:bt.cta,children:n("aboutDialogWebsiteCta")}),i.jsx("a",{className:bt.link,href:"https://commspliant.com/",target:"_blank",rel:"noopener noreferrer","aria-label":n("aboutDialogWebsiteAria"),children:n("aboutDialogWebsite")})]})]}),i.jsx("div",{className:bt.actions,children:i.jsx("button",{type:"button",className:bt.action,onClick:t,children:n("aboutDialogClose")})})]})})}):null}const QE="_backdrop_12fkg_1",eM="_dialog_12fkg_12",tM="_headerRow_12fkg_31",nM="_header_12fkg_31",rM="_close_12fkg_47",oM="_searchRow_12fkg_69",iM="_search_12fkg_69",aM="_body_12fkg_91",sM="_sidebar_12fkg_99",lM="_category_12fkg_111",cM="_topicList_12fkg_121",uM="_topicButton_12fkg_127",dM="_topicButtonActive_12fkg_147",mM="_main_12fkg_157",fM="_articleTitle_12fkg_164",pM="_articleBody_12fkg_171",gM="_noResults_12fkg_176",hM="_related_12fkg_181",bM="_relatedTitle_12fkg_187",yM="_relatedList_12fkg_194",xM="_relatedButton_12fkg_200",CM="_relatedItem_12fkg_223",Oe={backdrop:QE,dialog:eM,headerRow:tM,header:nM,close:rM,searchRow:oM,search:iM,body:aM,sidebar:sM,category:lM,topicList:cM,topicButton:uM,topicButtonActive:dM,main:mM,articleTitle:fM,articleBody:pM,noResults:gM,related:hM,relatedTitle:bM,relatedList:yM,relatedButton:xM,relatedItem:CM};function wM(e){return{getStarted:"helpCategoryGetStarted",file:"helpCategoryFile",edit:"helpCategoryEdit",insert:"helpCategoryInsert",format:"helpCategoryFormat",table:"helpCategoryTable",view:"helpCategoryView",keyboard:"helpCategoryKeyboard"}[e]}function vM({open:e,topicId:t,onTopicChange:n,onClose:r}){const o=X(),a=l.useId(),s=l.useRef(null),[u,d]=l.useState("");Ye(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(()=>ou.map(b=>({id:b.id,title:o(b.titleKey),body:o(b.bodyKey),keywords:o(b.keywordsKey)})),[o]),g=l.useMemo(()=>{const b=pD(f,u);return new Set(b.map(C=>C.id))},[u,f]),h=Vf[t],y=u.trim().length>0&&g.size===0;return e?i.jsx(Pe,{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(Qe,{})})]}),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:mD.map(b=>{const C=ou.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(wM(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=Vf[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 Db(e){return{catalog:e.catalog,layout:e.layout,commands:e.commands,queries:e.queries,queryRevisions:e.queryRevisions??db(),disabled:e.disabled,chromeLock:e.chromeLock}}function kM(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 SM=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:A,documentPreview:R,onDocumentPreviewClose:T,helpDialog:D,onHelpDialogClose:P,onHelpTopicChange:j,aboutDialogOpen:L,onAboutDialogClose:V,fontDialog:E,fontSizeState:N,markState:K,fontFamilyState:G,fontColorState:Z,highlightColorState:ae,fontFaces:q,onFontDialogTabChange:ee,onFontDialogClose:se,onApplyFontProperties:me,paragraphDialog:ne,customBackgroundImagePicker:M,disableBuiltinBackgroundImageSources:re,onParagraphCustomImagePick:O,onParagraphDialogTabChange:ie,onParagraphDialogClose:Ee,onApplyParagraphProperties:He,customCssDialog:$e,onCustomCssDialogClose:Ve,onApplyCustomCss:St,pageDialog:et,enablePageProperties:en,onPageCustomImagePick:Q,onPageDialogTabChange:fe,onPageDialogClose:pe,onApplyPageProperties:Ce,onPageDialogResetAtRule:Pt,deletePageConfirmOpen:Vt,onDeletePageConfirmClose:Mn,onDeletePageConfirm:Wt,customStyleDialog:De,canDeleteCustomParagraphStyle:yn,customStyleBusy:xn,onCustomStyleDialogClose:_r,onCustomStyleSave:Nr,onCustomStyleDelete:Lr,linkDialog:ve,onLinkDialogTabChange:tn,onLinkDialogClose:Br,onApplyLink:sr,bookmarkDialog:lr,onBookmarkDialogClose:H,onApplyBookmark:J,imageDialogOpen:ue,customImagePicker:Ne,customAudioPicker:At,customVideoPicker:Cn,onImageDialogClose:tt,onApplyImage:Ke,onImageDialogCustomPick:Ae,audioDialogOpen:We,onAudioDialogClose:nn,onApplyAudio:Es,onAudioDialogCustomPick:vi,youtubeDialogOpen:Ms,onYoutubeDialogClose:st,onApplyYoutube:ki,onYoutubeDialogCustomPick:Tt,imageProperties:rn,onImagePropertiesTabChange:_n,onImagePropertiesClose:_s,onApplyImageProperties:ko,tableDialogOpen:Ns,onTableDialogClose:Si,onApplyTable:Nn,tableProperties:on,onTablePropertiesClose:So,onApplyTableProperties:cr,cellProperties:F,onCellPropertiesClose:Nt,onApplyCellProperties:Pi,rowProperties:ur,onRowPropertiesClose:dt,onApplyRowProperties:dr}){const Ai=Db({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:ke.menuChrome,onPointerDownCapture:n,children:i.jsx(iu,{...Ai,menuVisible:!0,toolbarVisible:!1})}):null,h?i.jsx(PA,{open:!0,catalog:y,groups:b.iconGroups,settings:C,loading:x,busy:v,disabled:g,onChange:S,onReset:A,onClose:k}):null,R.open?i.jsx(LE,{open:!0,html:R.html,onClose:T}):null,D.open?i.jsx(vM,{open:!0,topicId:D.topicId,onTopicChange:j,onClose:P}):null,L?i.jsx(JE,{open:!0,onClose:V}):null,E.open?i.jsx(QI,{open:!0,tab:E.tab,size:N.value,unit:N.unit,marks:K,fontFamily:G.value,fontFamilyMixed:G.mixed,fontColor:Z.value,fontColorMixed:Z.mixed,highlightColor:ae.value,highlightColorMixed:ae.mixed,fonts:q,disabled:g,onTabChange:ee,onApply:me,onClose:se}):null,ne.open?i.jsx(kj,{open:!0,tab:ne.tab,value:ne.value,backgroundImage:ne.backgroundImage,disabled:g,customImagePicker:M,disableBuiltinBackgroundImageSources:re,onCustomImagePick:O,onTabChange:ie,onApply:He,onClose:Ee}):null,$e.open?i.jsx(Lj,{open:!0,value:$e.value,disabled:g,onApply:St,onClose:Ve}):null,et.open?i.jsx(jj,{open:!0,tab:et.tab,initialParagraphTab:et.paragraphTab,value:et.value,fonts:q,disabled:g,printTabVisible:en,customImagePicker:M,disableBuiltinBackgroundImageSources:re,onCustomImagePick:Q,onTabChange:fe,onApply:Ce,onResetAtRule:Pt,onClose:pe}):null,Vt?i.jsx(Ej,{open:!0,disabled:g,onClose:Mn,onConfirm:Wt}):null,De.open?i.jsx(Nj,{open:!0,mode:De.mode,styleId:De.mode==="edit"?De.style.id:void 0,name:De.mode==="edit"?De.style.name:"",font:De.mode==="edit"?De.style.font:De.font,paragraph:De.mode==="edit"?De.style.paragraph:De.paragraph,canDelete:yn,fonts:q,busy:xn,disabled:g,onSave:Nr,onDelete:Lr,onClose:_r}):null,ve.open?i.jsx(nE,{open:!0,tab:ve.tab,href:ve.href,title:ve.title,targetBlank:ve.targetBlank,textDecorationNone:ve.textDecorationNone,hoverMode:ve.hoverMode,hoverColor:ve.hoverColor,hoverHtml:ve.hoverHtml,bookmarks:ve.bookmarks,selectedBookmarkId:ve.selectedBookmarkId,disabled:g,onTabChange:tn,onApply:sr,onClose:Br}):null,lr.open?i.jsx(Fj,{open:!0,existingIds:lr.existingIds,disabled:g,onApply:J,onClose:H}):null,ue?i.jsx(Kj,{open:!0,disabled:g,customImagePicker:Ne,onApply:Ke,onCustomPick:Ae,onClose:tt}):null,We?i.jsx(Oj,{open:!0,disabled:g,customAudioPicker:At,onApply:Es,onCustomPick:vi,onClose:nn}):null,Ms?i.jsx(rE,{open:!0,disabled:g,customVideoPicker:Cn,onApply:ki,onCustomPick:Tt,onClose:st}):null,rn.open?i.jsx(tE,{open:!0,tab:rn.tab,value:rn.value,aspectRatio:rn.aspectRatio,disabled:g,onTabChange:_n,onApply:ko,onClose:_s}):null,Ns?i.jsx(cE,{open:!0,disabled:g,onApply:Nn,onClose:Si}):null,on.open?i.jsx(pE,{open:!0,value:on.value,disabled:g,onApply:cr,onClose:So}):null,F.open?i.jsx(wE,{open:!0,value:F.value,disabled:g,onApply:Pi,onClose:Nt}):null,ur.open?i.jsx(PE,{open:!0,value:ur.value,disabled:g,onApply:dr,onClose:dt}):null]})},kM);function PM({toolbarVisible:e,toolbarPos:t,captureChromeSelection:n,toolbarShellProps:r,children:o}){return i.jsxs("div",{className:ke.body,"data-icon-dock":e?t:void 0,children:[e&&(t==="top"||t==="left")?i.jsx("div",{className:ke.iconChrome,onPointerDownCapture:n,children:i.jsx(iu,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null,o,e&&(t==="bottom"||t==="right")?i.jsx("div",{className:ke.iconChrome,onPointerDownCapture:n,children:i.jsx(iu,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null]})}const Ib=l.createContext(null);function AM({value:e,children:t}){return i.jsx(Ib.Provider,{value:e,children:t})}function TM(){const e=l.useContext(Ib);if(!e)throw new Error("useEditorShellContext must be used within EditorShellProvider");return e}function RM(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(ye(d).body)}return n.current=e,r.current=s,s},[e,t,e.length])}const DM="_panel_6xdnw_1",IM="_header_6xdnw_17",jM="_title_6xdnw_26",EM="_close_6xdnw_32",MM="_messages_6xdnw_48",_M="_empty_6xdnw_57",NM="_message_6xdnw_48",LM="_messageHeader_6xdnw_69",BM="_author_6xdnw_77",FM="_time_6xdnw_81",HM="_body_6xdnw_86",zM="_reply_6xdnw_92",OM="_input_6xdnw_100",KM="_post_6xdnw_111",yt={panel:DM,header:IM,title:jM,close:EM,messages:MM,empty:_M,message:NM,messageHeader:LM,author:BM,time:FM,body:HM,reply:zM,input:OM,post:KM};function $M(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(n)}function UM({thread:e,locale:t,disabled:n,commentAuthor:r,panelRef:o,onPost:a,onClose:s}){const u=X(),[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 au.createPortal(i.jsxs("div",{ref:o,className:yt.panel,role:"dialog","aria-label":u("commentPanelTitle"),children:[i.jsxs("div",{className:yt.header,children:[i.jsx("h2",{className:yt.title,children:u("commentPanelTitle")}),i.jsx("button",{type:"button",className:yt.close,onClick:s,"aria-label":u("commentPanelCloseAria"),children:i.jsx(Qe,{})})]}),i.jsx("div",{className:yt.messages,children:y.length===0?i.jsx("p",{className:yt.empty,children:u("commentEmpty")}):y.map(x=>i.jsxs("article",{className:yt.message,children:[i.jsxs("header",{className:yt.messageHeader,children:[i.jsx("span",{className:yt.author,children:x.userName}),i.jsx("time",{className:yt.time,dateTime:x.createdAt,children:$M(x.createdAt,t)})]}),i.jsx("p",{className:yt.body,children:x.message})]},x.id))}),i.jsxs("div",{className:yt.reply,children:[i.jsx("textarea",{ref:g,className:yt.input,value:d,onChange:x=>f(x.target.value),placeholder:b,rows:3,disabled:n||!r}),i.jsx("button",{type:"button",className:yt.post,onClick:C,disabled:!h,children:u("commentPost")})]})]}),document.body)}const VM=l.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:o},a){const s=X();return i.jsx("textarea",{ref:a,className:`${ke.surface} ${ke.html}`,value:t,onChange:u=>n(u.target.value),placeholder:r,disabled:o,"aria-label":s("htmlEditorAria"),spellCheck:!1})}),WM="_shell_yvznc_1",GM="_scrollButton_yvznc_10",ZM="_tabList_yvznc_48",qM="_tab_yvznc_48",YM="_tabActive_yvznc_86",eo={shell:WM,scrollButton:GM,tabList:ZM,tab:qM,tabActive:YM},XM=5,rp=120;function JM({pageCount:e,activeIndex:t,onSelect:n}){const r=X(),o=l.useRef(null),[a,s]=l.useState(!1),[u,d]=l.useState(!1),f=e>=XM,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:eo.shell,children:[f?i.jsx("button",{type:"button",className:eo.scrollButton,"aria-label":r("htmlModePageTabsScrollLeftAria"),disabled:!a,onClick:()=>h(-rp),children:"‹"}):null,i.jsx("div",{ref:o,className:eo.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:`${eo.tab} ${C===t?eo.tabActive:""}`,"aria-selected":C===t,tabIndex:C===t?0:-1,onClick:()=>n(C),children:y(C)},C))}),f?i.jsx("button",{type:"button",className:eo.scrollButton,"aria-label":r("htmlModePageTabsScrollRightAria"),disabled:!u,onClick:()=>h(rp),children:"›"}):null]})}function QM(e,t,n=!0){const[r,o]=l.useState(null),[a,s]=l.useState(Ju()),u=l.useCallback(()=>{!n||!e||(o(Cb(e,t)),s(ms(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(ms(e))};return document.addEventListener("selectionchange",d),()=>document.removeEventListener("selectionchange",d)},[n,e]),{geometry:r,indentState:a,refresh:u}}const e_=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},A){const R=X(),T=l.useRef(null),D=l.useRef(!1),[P,j]=l.useState(null),L=l.useRef(y);L.current=y;const V=n??t,E=s&&hi(V),{geometry:N,indentState:K,refresh:G}=QM(P,V,E),Z=q=>{T.current=q,j(q),typeof A=="function"?A(q):A&&(A.current=q)};l.useLayoutEffect(()=>{const q=T.current;if(!q)return;const ee=Xt(t),me=q===document.activeElement&&D.current;if(D.current=!1,me||ls(q,ee,{resolveDataUrl:C,hydrateEmbeddedImages:x}),ut(q)||hi(V)){ju(q),pi(q),Ps(q);const ne=ut(q);ne&&fg(q,ne)}Ss(q),wo(q,V)},[t,V,C,x]),l.useLayoutEffect(()=>{if(b)return b.current=()=>{D.current=!0},()=>{b.current=null}},[b]),l.useLayoutEffect(()=>{const q=T.current;if(!q)return;const ee=se=>{var me;(me=L.current)==null||me.call(L,se)};return q.addEventListener("beforeinput",ee),()=>q.removeEventListener("beforeinput",ee)},[]);const ae=i.jsx("div",{ref:Z,className:`${ke.surface} ${ke.visual} ${E?ke.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:q=>{const ee=q.currentTarget;if(D.current=!0,ut(ee)){const{absorbedBlocks:se}=pi(ee);if(r(ee.innerHTML),se.length>0){const me=se.length;requestAnimationFrame(()=>bg(ee,me))}}else r(ee.innerHTML);E&&G()}});return i.jsx(HI,{showRulers:E,geometry:N,indentState:K,rulerUnit:u,zoomScale:d,onMarginChange:f,onMarginPreview:g,onIndentChange:h,children:ae})}),t_="_frame_bwkh8_1",n_="_handle_bwkh8_9",r_="_handleEast_bwkh8_29",o_="_handleSouth_bwkh8_37",i_="_handleSouthEast_bwkh8_45",si={frame:t_,handle:n_,handleEast:r_,handleSouth:o_,handleSouthEast:i_};function Yo(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const a_=[{handle:"e",className:si.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:si.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:si.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function Cc(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=X(),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(Yo(e));const k=()=>{e.isConnected&&f(Yo(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 A=d.current,R=a.current;if(!A||!R)return;const T=nP(A.handle,A.start,{x:k-A.originX,y:S-A.originY});s.current(T.width,T.height),R.isConnected&&f(Yo(R))},h=()=>{if(!d.current)return;d.current=null;const k=a.current;u.current(),k!=null&&k.isConnected&&f(Yo(k))};l.useLayoutEffect(()=>{const k=A=>{if(!d.current)return;const R=Cc(A);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 y=(k,S)=>{const A=Cc(S);A&&(d.current={handle:k,start:rP(a.current),originX:A.x,originY:A.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=Cc(k);S&&g(S.x,S.y)};if(!e.isConnected)return null;const v=Yo(e);return au.createPortal(i.jsx("div",{ref:o,className:si.frame,"data-image-resize-overlay":"",style:{left:v.left,top:v.top,width:v.width,height:v.height},children:a_.map(k=>i.jsx("button",{type:"button",className:`${si.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 l_(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 c_(){const e=X();return i.jsx("div",{className:ke.htmlFileDropOverlay,"aria-hidden":"true",children:e("htmlFileDropOverlay")})}function u_({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:A,commentsVisible:R,disabled:T,locale:D,commentAuthor:P,activeThreadId:j,contextMenu:L,commentThreads:V,commands:E,htmlFileDropDragging:N,selectedImage:K}){const{htmlRef:G,pagesRef:Z,documentBridgeRef:ae}=TM(),[q,ee]=l.useState(C),[se,me]=Oa({value:g?void 0:y,defaultValue:b,onChange:r||g?void 0:k}),ne=g?q:se,[M,re]=l.useState(()=>r&&(e.current.htmlModePageHtmlRef.current||x[0])||""),O=e.current;O.setHtmlModePageHtml=re,g?r||(G.current=q):G.current=se,r&&(Z.current=t.pages);const ie=l.useCallback(()=>r?t.getJoinedHtml():g?q:se,[r,se,g,t,q]);l.useLayoutEffect(()=>{const Q={pageStore:t,setHtml:me,setStorageHtml:ee,getEditorHtml:ie,replacePagesFromHistory:fe=>t.replacePages([...fe])};return ae.current=Q,()=>{ae.current===Q&&(ae.current=null)}},[ae,ie,t,me,ee]);const Ee=l.useMemo(()=>{if(r){const Q=t.pages[a]??t.pages[0]??"";return Hm(Q,S).join(`
319
319
  `)}return Hm(ne,S).join(`
320
- `)},[r,t.pages,t.revision,a,ne,S]),He=RM(r?t.pages:[],r?t.revision:0);s.useLayoutEffect(()=>{var fe;if(!r)return;const Q=(fe=e.current.multiPageVisualRef.current)==null?void 0:fe.getActivePageRoot();Q instanceof HTMLDivElement&&(e.current.visualRootRef.current=Q)},[r,a,He.length,e]);const $e=s.useMemo(()=>r?He[l?a:0]??"":ye(ne).body,[r,He,a,l,ne]),Ve=s.useMemo(()=>ag(ot($e)),[$e]);O.activePageHtmlRef.current=$e,O.pageCanvasSizedRef.current=Ve,s.useEffect(()=>{const fe=(Ee?Ee.split(`
321
- `):[]).map(pe=>{const Ce=document.createElement("link");return Ce.rel="stylesheet",Ce.href=pe,Ce.setAttribute(bl,""),document.head.append(Ce),Ce});return()=>{for(const pe of fe)pe.remove()}},[Ee]),s.useEffect(()=>{(!A||n!=="visual"||!R)&&e.current.setActiveThreadId(null)},[A,n,R,e]),s.useEffect(()=>{if(!j)return;const Q=fe=>{var Vt;const pe=e.current,Ce=fe.target;if((Vt=pe.commentPanelRef.current)!=null&&Vt.contains(Ce))return;const Pt=pe.visualRootRef.current;Pt&&Eh(Pt,Ce)||pe.setActiveThreadId(null)};return document.addEventListener("pointerdown",Q),()=>document.removeEventListener("pointerdown",Q)},[j,e]),s.useEffect(()=>{if(!r||n!=="html")return;const Q=t.pages[a]??t.pages[0]??"";O.htmlModePageHtmlRef.current=Q,re(Q)},[r,n,t.pages,t.revision,a,O]),s.useEffect(()=>{if(!A||n!=="visual")return;const Q=e.current.visualRootRef.current;Q&&(KS(Q,V),jh(Q,R))},[A,n,V,R,ne,e]);const St=n==="visual"&&d&&Ve,et=s.useMemo(()=>j?WS(V,j):null,[j,V]),en=n==="visual"?r?i.jsx(KI,{ref:O.multiPageVisualRef,pages:He,activePageIndex:a,hasSelectedPage:l,scrollRootRef:O.workspaceRef,suppressPageFlushRef:O.suppressPageFlushRef,pendingInsertPageFocusRef:O.pendingInsertPageFocusRef,onActivePageIndexChange:Q=>{var Ce;O.activePageIndexRef.current=Q,O.setActivePageIndex(Q);const fe=(Ce=O.multiPageVisualRef.current)==null?void 0:Ce.getContainer(),pe=fe?Ze(fe,Q):null;pe instanceof HTMLDivElement&&(O.visualRootRef.current=pe)},onPageSelected:()=>{O.setHasSelectedPage(!0)},onPageChange:(Q,fe)=>{const pe=q.current[Q]??"";O.recordPageVisualHtml(Q,zt(fe,ye(pe).body),!0)},onPageFlush:(Q,fe)=>{const pe=q.current[Q]??"";O.recordPageVisualHtml(Q,zt(fe,ye(pe).body),!1)},onBeforeInput:O.handleVisualBeforeInput,onPointerDown:Q=>{if(Q.currentTarget instanceof HTMLDivElement&&(O.visualRootRef.current=Q.currentTarget),O.handleVisualPointerDown(Q),Q.currentTarget instanceof HTMLDivElement){const fe=Q.currentTarget;requestAnimationFrame(()=>fo(fe))}},onMouseUp:O.handleVisualMouseUp,onContextMenu:O.handleVisualContextMenu,placeholder:h,disabled:o,rulerVisible:d,rulerUnit:f,zoomScale:u,onMarginPreview:O.multiPageRulerMarginPreview,onMarginChange:O.multiPageRulerMarginChange,onIndentChange:O.multiPageRulerIndentChange,resolveEmbeddedImageDataUrl:g?O.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?O.hydrateExportHtml:void 0}):i.jsx(e_,{ref:O.visualRootRef,html:ye(ne).body,pageHtml:ne,rulerVisible:d,rulerUnit:f,zoomScale:u,propSyncGuardRef:O.visualPropSyncGuardRef,resolveEmbeddedImageDataUrl:g?O.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?O.hydrateExportHtml:void 0,onMarginPreview:O.singlePageRulerMarginPreview,onMarginChange:O.singlePageRulerMarginChange,onIndentChange:O.singlePageRulerIndentChange,onChange:Q=>O.recordVisualInputHtml(Q,!0),onBeforeInput:O.handleVisualBeforeInput,onPointerDown:Q=>{if(O.handleVisualPointerDown(Q),Q.currentTarget instanceof HTMLDivElement){const fe=Q.currentTarget;requestAnimationFrame(()=>fo(fe))}},onMouseUp:O.handleVisualMouseUp,onContextMenu:O.handleVisualContextMenu,placeholder:h,disabled:o}):i.jsxs("div",{className:ke.htmlModeShell,children:[r&&t.pages.length>1?i.jsx(JM,{pageCount:t.pages.length,activeIndex:a,onSelect:O.handleHtmlPageTabSelect}):null,i.jsx(VM,{ref:O.htmlAreaRef,html:r?M:ne,onChange:Q=>{O.htmlModePageHtmlRef.current=Q,re(Q),O.handleHtmlSurfaceChange(Q)},placeholder:h,disabled:o})]});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{ref:O.workspaceRef,className:`${ke.workspace} ${Ve?ke.workspacePageSized:""} ${St?ke.workspaceWithRuler:""}`,onDragEnter:O.htmlFileDrop.onDragEnter,onDragOver:O.htmlFileDrop.onDragOver,onDragLeave:O.htmlFileDrop.onDragLeave,onDrop:O.htmlFileDrop.onDrop,children:[n==="visual"?i.jsx("div",{className:ke.pageCanvasViewport,"data-page-canvas-sized":Ve?"":void 0,children:en}):en,O.htmlFileDrop.dragging?i.jsx(c_,{}):null]}),n==="visual"&&!o&&(K!=null&&K.isConnected)?i.jsx(l_,{img:K,onResize:O.handleImageResize,onResizeEnd:O.handleImageResizeEnd}):null,A&&R&&et?i.jsx(UM,{panelRef:O.commentPanelRef,thread:et,locale:D,disabled:T,commentAuthor:P,onPost:O.postCommentMessage,onClose:()=>O.setActiveThreadId(null)}):null,i.jsx(Tx,{open:L.open,x:L.x,y:L.y,kind:L.kind,inTable:L.inTable,canMergeCells:L.canMergeCells,canUnmergeCells:L.canUnmergeCells,canDeletePage:L.canDeletePage,canAddComment:L.canAddComment,commands:E,onClose:()=>O.setContextMenu(Q=>({...Q,open:!1}))})]})}const d_=s.memo(u_,s_),m_=.005;function f_({value:e,defaultValue:t="",onChange:n,onAutoSave:r,onSave:o,onOpen:a,mode:l,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:A,menuFontSize:R,menuFontFamily:T,border:D,menuVisible:P=!0,toolbarVisible:j=!0,allowedChrome:L,customActions:V,customFonts:E,transformHtml:N,sanitizeHtml:K=!0,loadCustomParagraphStyles:G,onSaveCustomParagraphStyle:q,onDeleteCustomParagraphStyle:ae,customImagePicker:Z,disableBuiltinImageInsert:ee,customBackgroundImagePicker:le,disableBuiltinBackgroundImageInsert:me,disableBuiltinBackgroundImageSources:ne,customAudioPicker:M,disableBuiltinAudioInsert:re,customVideoPicker:O,disableBuiltinVideoInsert:ie,disableHtmlFileDrop:Ee=!1,toolbarCustomization:He,darkMode:$e=!1,darkModePersistence:Ve,toolbarPosition:St="top",toolbarPositionPersistence:et,enablePageProperties:en=!1,defaultPageProperties:Q,optimizeEmbeddedImages:fe=!1,enableMultiPages:pe=!1,pages:Ce,defaultPages:Pt,onPagesChange:Vt,defaultRulerVisible:Mn=!0,rulerUnit:Wt="in",enableComments:De=!1,defaultCommentsVisible:yn=!0,commentAuthor:xn,comments:_r,defaultComments:Nr=[],onCommentsChange:Lr}){var jm;const ve=!!(b||C),tn=!!b,Br=pe?Ce!==void 0:e!==void 0,lr=Gn(Pt??(t.trim()?[t]:[Un()])),sr=!Br&&Q?lr.map(c=>xf(c,Q)):lr,H=s.useRef(null);fe&&H.current===null&&(H.current=_w());const J=s.useRef(null);J.current===null&&(J.current=fe&&H.current?sr.map(c=>H.current.externalizeHtml(c)):[...sr]);const ue=pe?Et(J.current):J.current[0]??"",Ne=K?to(ue):ue,At=pe&&Ce!==void 0?Et(Gn(Ce)):e,Cn=s.useMemo(()=>{if(At!==void 0)return K?to(At):At},[At,K]),tt=s.useRef(n);tt.current=n;const Ke=s.useRef(fe);Ke.current=fe;const Ae=s.useCallback(c=>!Ke.current||!H.current?c:H.current.externalizeHtml(c),[]),We=s.useCallback(c=>!Ke.current||!H.current?c:H.current.hydrateHtml(c),[]),nn=s.useCallback(c=>c.map(m=>We(m)),[We]),El=s.useCallback(c=>{var m;return((m=H.current)==null?void 0:m.getDataUrl(c))??null},[]),vi=s.useCallback(c=>{var m;(m=tt.current)==null||m.call(tt,We(c))},[We]),[Ml]=s.useState(()=>{if(fe&&e!==void 0&&!pe){const c=K?to(e):e;return H.current?H.current.externalizeHtml(c):c}return Ne}),[lt,ki]=Oa({value:l,defaultValue:u,onChange:d}),[Tt,rn]=Oa({value:f,defaultValue:g,onChange:h}),[_n,_l]=s.useState(yn),[ko,Nl]=s.useState(Mn),Si=s.useRef(ko);Si.current=ko;const[Nn,on]=s.useState(null),[So,cr]=Oa({value:_r,defaultValue:Nr,onChange:Lr}),F=s.useRef(null),Nt=s.useRef(null),Pi=s.useRef(null),ur=s.useRef(null),dt=s.useRef(null),dr=s.useRef(!1),Ai=s.useRef(null),gt=s.useRef(null),xe=s.useRef(pe);xe.current=pe;const Ll=s.useRef(Q);Ll.current=Q;const Ln=s.useRef(De);Ln.current=De;const nd=s.useRef(C);nd.current=C;const rd=s.useRef(ve);rd.current=ve;const Ti=s.useRef(_n);Ti.current=_n;const Ri=s.useRef(So);Ri.current=So;const Di=s.useRef(Vt);Di.current=Vt;const Ii=s.useRef(null),ji=s.useRef(!1),Fr=s.useCallback(()=>{var m;ji.current=!1;const c=Ii.current;Ii.current=null,c&&((m=Di.current)==null||m.call(Di,c.pages,c.activePageIndex))},[]),Hr=s.useCallback((c,m)=>{Ii.current={pages:[...c],activePageIndex:m},!ji.current&&(ji.current=!0,queueMicrotask(Fr))},[Fr]),Bl=s.useRef(Ce);Bl.current=Ce;const od=s.useMemo(()=>!fe||Ce===void 0?Ce:Gn(Ce).map(c=>{var w;const m=K?to(c):c;return((w=H.current)==null?void 0:w.externalizeHtml(m))??m}),[fe,Ce,K]),mt=FP({enabled:pe,pagesProp:od,defaultPages:J.current??[Un()]}),zr=s.useRef(null),id=s.useRef(null),[Or,Po]=s.useState(0),Te=s.useRef(Or);Te.current=Or;const wn=s.useRef(pe?((jm=J.current)==null?void 0:jm[0])??"":""),Kr=s.useRef(!1),[Ao,mr]=s.useState(!1),Gt=s.useRef(Ao);Gt.current=Ao;const[ad,jb]=s.useState(0),ld=s.useRef(!1),sd=s.useRef(!1),Rt=s.useMemo(()=>db(),[]),Fl=s.useRef(null);Fl.current===null&&(Fl.current=pe?YP(J.current??[Un()]):ZP(Ae(Ne)));const oe=Fl.current,an=s.useCallback(()=>{const c=oe.canUndo(),m=oe.canRedo();c===ld.current&&m===sd.current||(ld.current=c,sd.current=m,jb(w=>w+1))},[oe]),se=s.useRef(Ne),Me=s.useRef(J.current??[Un()]);pe&&(Me.current=mt.pages);const cd=s.useRef(""),ud=s.useRef(!1),Lt=s.useRef(!0),$r=s.useRef(""),vn=s.useRef(null),B=s.useRef(lt);B.current=lt;const dd=s.useRef(Tt);dd.current=Tt;const Ge=s.useRef(null),[,Eb]=s.useState(0),To=s.useRef(null);To.current===null&&(To.current=i0(()=>{Eb(c=>c+1)}));const Ei=s.useRef(N);Ei.current=N;const md=s.useRef(K);md.current=K;const Bt=s.useRef({}),Dt=s.useRef(null),Ft=s.useRef(null),qt=s.useRef(null),Zt=s.useRef(null),Bn=s.useRef(null),It=s.useRef(null),[Ro,Hl]=s.useState(Yn),zl=s.useRef(Ro);zl.current=Ro;const kn=s.useRef(so),[Do,Mi]=s.useState({value:null,unit:so,mixed:!1}),Fn=s.useRef(Do);Fn.current=Do;const[Io,Ol]=s.useState({value:null,mixed:!1}),jo=s.useRef(Io);jo.current=Io;const[Eo,Kl]=s.useState({value:null,mixed:!1}),Mo=s.useRef(Eo);Mo.current=Eo;const[_o,$l]=s.useState({value:null,mixed:!1}),No=s.useRef(_o);No.current=_o;const[_i,Ul]=s.useState({tag:null,mixed:!1}),Vl=s.useRef(_i);Vl.current=_i;const[fd,Wl]=s.useState({align:"left",mixed:!1}),Gl=s.useRef(fd);Gl.current=fd;const[pd,ql]=s.useState({type:null,mixed:!1}),Lo=s.useRef(pd);Lo.current=pd;const[gd,Zl]=s.useState(!1),hd=s.useRef(gd);hd.current=gd;const[Ni,Yl]=s.useState(!1),Xl=s.useRef(Ni);Xl.current=Ni;const[Li,bd]=s.useState(!1),Bi=s.useRef(Li);Bi.current=Li;const Fi=s.useRef(null),Hi=s.useRef(null),[yd,xd]=s.useState(!1),Cd=s.useRef(yd);Cd.current=yd;const{fontDialog:zi,setFontDialog:Oi,customizeToolbarOpen:Jl,setCustomizeToolbarOpen:wd,documentPreview:Ki,setDocumentPreview:vd,toolbarSettings:Ql,setToolbarSettings:$i,toolbarSettingsLoading:Mb,setToolbarSettingsLoading:es,toolbarSettingsBusy:_b,setToolbarSettingsBusy:ts,paragraphDialog:Bo,setParagraphDialog:Ur,customCssDialog:ns,setCustomCssDialog:rs,pageDialog:Fo,setPageDialog:fr,deletePageConfirmOpen:os,setDeletePageConfirmOpen:is,customStyleDialog:Nb,setCustomStyleDialog:Ho,linkDialog:as,setLinkDialog:Ui,bookmarkDialog:kd,setBookmarkDialog:ls,imageDialog:Lb,setImageDialog:Vi,audioDialog:Bb,setAudioDialog:Wi,youtubeDialog:Fb,setYoutubeDialog:zo,imageProperties:Hb,setImageProperties:Gi,tableDialog:ss,setTableDialog:cs,tableProperties:us,setTableProperties:ds,cellProperties:ms,setCellProperties:fs,rowProperties:ps,setRowProperties:gs,helpDialog:hs,setHelpDialog:Oo,aboutDialogOpen:bs,setAboutDialogOpen:Sd}=BP(),[Hn,qi]=s.useState(()=>Ve?$e:Bf()??$e),[Vr,Zi]=s.useState(()=>et?St:Ff()??St),[Ko,zb]=s.useState(()=>$P()??"fitWidth"),[ys,Ob]=s.useState(1),[Yi,Pd]=s.useState([]),[Xi,xs]=s.useState(!1),[Kb,Ji]=s.useState(!1),[$b,Cs]=s.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1,canMergeCells:!1,canUnmergeCells:!1,canDeletePage:!1,canAddComment:!1}),[ft,Wr]=s.useState(null),ws=s.useRef(ft);ws.current=ft;const[Qi,Ad]=s.useState(!1),Td=s.useRef(Qi);Td.current=Qi;const[ea,Rd]=s.useState(!1),Dd=s.useRef(ea);Dd.current=ea;const[ta,Id]=s.useState(!1),jd=s.useRef(ta);jd.current=ta;const Ed=s.useRef(void 0),na=s.useRef(Yi);na.current=Yi;const Md=s.useRef(Xi);Md.current=Xi;const ra=!!(G&&q),vs=s.useRef(ra);vs.current=ra;const _d=s.useRef(G);_d.current=G;const Nd=s.useRef(q);Nd.current=q;const Ld=s.useRef(ae);Ld.current=ae;const Bd=s.useRef(o);Bd.current=o;const Fd=s.useRef(a);Fd.current=a;const Hd=s.useRef(Z);Hd.current=Z;const Sn=le??Z,zd=me??ee??!1,ks=ne??ee??!1,Ss=s.useRef(Sn);Ss.current=Sn;const Ps=s.useRef(zd);Ps.current=zd;const Ub=s.useRef(ks);Ub.current=ks;const Od=s.useRef(M);Od.current=M;const Kd=s.useRef(O);Kd.current=O;const $d=s.useRef(He);$d.current=He;const Ud=s.useRef(Ve);Ud.current=Ve;const Vd=s.useRef(et);Vd.current=et;const Wd=s.useRef(Hn);Wd.current=Hn;const Gd=s.useRef(Vr);Gd.current=Vr;const oa=s.useRef(Ko);oa.current=Ko;const ia=s.useRef(ys);ia.current=ys;const qd=s.useRef(ee);qd.current=ee;const Zd=s.useRef(re);Zd.current=re;const Yd=s.useRef(ie);Yd.current=ie;const As=s.useRef(0),$o=s.useRef(0),Xd=s.useRef(0),aa=s.useRef(0),Jd=s.useRef(0),la=s.useRef(0),Qd=s.useRef(0),Gr=s.useMemo(()=>Cp(E),[E]),qr=s.useRef(Gr);qr.current=Gr;const sa=s.useCallback(()=>{var c;if(xe.current){const m=(c=dt.current)==null?void 0:c.getActivePageRoot();if(m instanceof HTMLElement)return m}return F.current},[]),ln=s.useCallback(()=>{var w;const c=F.current;if(c!=null&&c.hasAttribute(Dr)){const I=Ym(c);if(I!==null)return I}const m=(w=dt.current)==null?void 0:w.getActivePageIndex();return typeof m=="number"?m:Te.current},[]),Uo=s.useCallback(()=>{if(xe.current){const c=dt.current;if(!c)return null;const m=ln();if(m===null)return null;c.ensurePageMounted(m);const w=c.getContainer(),I=w?Ze(w,m):null;return I instanceof HTMLDivElement?(F.current=I,I):null}return F.current},[ln]),Zr=s.useCallback(()=>{if(!xe.current)return se.current;const c=ln()??Te.current;return Me.current[c]??""},[ln]);s.useLayoutEffect(()=>{var m;if(!pe)return;const c=(m=dt.current)==null?void 0:m.getActivePageRoot();c instanceof HTMLDivElement&&(F.current=c)},[pe,Or]);const ca=s.useRef(()=>{}),Ts=s.useRef(!1),Vb=s.useCallback(()=>{if(Ts.current||B.current!=="visual")return;const c=ur.current;if(c){Ts.current=!0;try{const m=getComputedStyle(c),w=parseFloat(m.paddingLeft)+parseFloat(m.paddingRight),I=parseFloat(m.paddingTop)+parseFloat(m.paddingBottom),_=Math.max(0,c.clientWidth-w),$=Math.max(0,c.clientHeight-I);let Y=0,te=0;if(ud.current){const he=uw(ot(cd.current));he&&(Y=he.width,te=he.height)}else{const he=sa(),Be=ia.current>0?ia.current:1;Y=((he==null?void 0:he.offsetWidth)??0)/Be,te=((he==null?void 0:he.offsetHeight)??0)/Be}Y<=0&&(Y=_),te<=0&&(te=$);const ge=wv(oa.current,_,$,Y,te);Math.abs(ge-ia.current)>=m_&&Ob(ge)}finally{Ts.current=!1}}},[sa]);ca.current=Vb,s.useLayoutEffect(()=>{if(lt!=="visual")return;const c=sa();!c||c!==document.activeElement||fo(c)},[lt,Or,sa]);const ua=s.useCallback(async()=>{const c=_d.current;if(!c)return;const m=++As.current;xs(!0);try{const w=await c();if(m!==As.current)return;Pd(w)}catch{}finally{m===As.current&&xs(!1)}},[]);s.useEffect(()=>{if(!G||!q){Pd([]),xs(!1);return}ua()},[G,q,ua]);const em=s.useCallback(async c=>{$i(c);const m=$d.current;if(m!=null&&m.load&&m.save){const w=++Xd.current;ts(!0);try{await m.save(c)}catch{}finally{w===Xd.current&&ts(!1)}return}nA(c)},[]);s.useEffect(()=>{const c=He;if(!(c!=null&&c.load)||!c.save){$i(tA()),es(!1),ts(!1);return}const m=++$o.current;return es(!0),(async()=>{try{const w=await c.load();if(m!==$o.current)return;$i(w)}catch{if(m!==$o.current)return;$i(null)}finally{m===$o.current&&es(!1)}})(),()=>{$o.current+=1}},[He]);const tm=s.useCallback(async c=>{qi(c);const m=Ud.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}zP(c)},[]),nm=s.useCallback(c=>{oa.current=c,zb(c),UP(c);const m=ur.current;m&&(m.scrollTop=0,m.scrollLeft=0),ca.current()},[]);s.useEffect(()=>{const c=Ve;if(!(c!=null&&c.load)||!c.save){qi(Bf()??$e);return}const m=++aa.current;return(async()=>{try{const w=await c.load();if(m!==aa.current)return;qi(typeof w=="boolean"?w:$e)}catch{if(m!==aa.current)return;qi($e)}})(),()=>{aa.current+=1}},[Ve,$e]),s.useLayoutEffect(()=>{if(ca.current(),lt!=="visual")return;const c=ur.current;if(!c||typeof ResizeObserver>"u")return;const m=vv(()=>{ca.current()}),w=new ResizeObserver(()=>{m.schedule()});return w.observe(c),()=>{w.disconnect(),m.cancel()}},[lt,Or,Ko,pe]);const rm=s.useCallback(async c=>{Zi(c);const m=Vd.current;if(m!=null&&m.load&&m.save){const w=++Qd.current;try{await m.save(c)}catch{}finally{if(w!==Qd.current)return}return}WP(c)},[]);s.useEffect(()=>{const c=et;if(!(c!=null&&c.load)||!c.save){Zi(Ff()??St);return}const m=++la.current;return(async()=>{try{const w=await c.load();if(m!==la.current)return;Zi(Qh(w)??St)}catch{if(m!==la.current)return;Zi(St)}})(),()=>{la.current+=1}},[et,St]);const Yr=s.useCallback((c,m)=>{var te,ge;const w=md.current?to(c):c,I=((te=Ei.current)==null?void 0:te.call(Ei,w))??w,_=Lh(se.current,I,We);m!=null&&m.fullReplace&&!_&&Ke.current&&((ge=H.current)==null||ge.clear());const $=Ae(I);if(_)return se.current=$,{stored:$,stateUpdated:!1};$!==se.current&&(Lt.current=!0);const Y=zr.current;if(xe.current){const he=mt;if(!he)return se.current=$,{stored:$,stateUpdated:!1};const Be=he.replacePages(qn($));return se.current=Be.joined,Me.current=Be.pages,B.current==="html"&&!Ke.current&&(Y==null||Y.setHtml($)),Hr(nn(Be.pages),Te.current),{stored:$,stateUpdated:!0}}return Ke.current?(se.current=$,Y==null||Y.setStorageHtml($),vi($),{stored:$,stateUpdated:!0}):(se.current=$,Y==null||Y.setHtml($),{stored:$,stateUpdated:!0})},[Ae,We,nn,vi,Hr]),sn=s.useCallback((c,m,w,I)=>{var te;const _=c.map(ge=>Ae(ge)),$=mt;if(!$)return Et(_);const Y=$.setPages(_,{editedIndex:w});if(!Y.changed)return Y.joined;if(Me.current=Y.pages,Lt.current=!0,se.current=Y.joined,Bl.current===void 0&&B.current==="html"&&!Ke.current&&((te=zr.current)==null||te.setHtml(Y.joined)),Hr(nn(Y.pages),Te.current),!(I!=null&&I.skipHistory)&&Ht(oe)){const{changedIndices:ge,pages:he}=Y;if(ge.length===1){const Be=w??ge[0];oe.recordPageEdit(Be,he[Be]??"",{coalesce:m})}else ge.length>1?oe.recordReplaceAll(he):w!==void 0?oe.recordPageEdit(w,he[w]??"",{coalesce:m}):oe.recordReplaceAll(he)}return an(),Y.joined},[an,Ae,nn,oe,mt,Hr]),zn=s.useCallback(c=>{var $,Y;if(B.current!=="visual")return;const m=Ke.current?te=>{var ge;return((ge=H.current)==null?void 0:ge.getDataUrl(te))??null}:void 0,w=Ke.current?We:void 0;if(($=Nt.current)==null||$.call(Nt),xe.current){const te=(Y=dt.current)==null?void 0:Y.getContainer();if(!te)return;const ge=qn(c);for(let he=0;he<ge.length;he+=1){const Be=Ze(te,he);if(!Be)continue;const Fe=Xt(ye(ge[he]??"").body);sl(Be,Fe,{resolveDataUrl:m,hydrateEmbeddedImages:w})}return}const I=F.current;if(!I)return;const _=Xt(ye(c).body);sl(I,_,{resolveDataUrl:m,hydrateEmbeddedImages:w})},[We]),st=s.useCallback((c,m)=>{const{stored:w,stateUpdated:I}=Yr(c,{fullReplace:!m});return!m&&I&&zn(w),Ht(oe)?oe.recordReplaceAll(qn(w)):oe.record(w,{coalesce:m}),an(),w},[an,Yr,oe,zn]),Wb=s.useCallback(c=>{if(xe.current){const m=Te.current,I=Me.current.slice();I[m]=c,sn(I,!1,m);return}st(c,!1)},[sn,st]),om=GP({enabled:!ve&&!Ee,onHtml:Wb}),we=s.useCallback((c,m)=>{var w;return(w=Nt.current)==null||w.call(Nt),st(Ta(c,Ra(c,se.current,qr.current,{liveRoot:F.current??void 0})),m)},[st]),Gb=s.useCallback((c,m)=>we(zt(c,se.current),m),[we]),da=s.useCallback((c,m,w)=>{hw(c,m,w)},[]),ma=s.useCallback((c,m,w)=>{const I={...Qo(c),atRule:ot(sg(m,w))};return Zc(c,I)},[]),pr=s.useCallback((c,m,w)=>Ta(c,Ra(c,m,qr.current,{liveRoot:w})),[]),ht=s.useCallback(c=>{const m=dt.current,w=m==null?void 0:m.getContainer(),I=mt.pages.length>0?mt.pages:Me.current;if(!w||!m)return[...I];const _=mt;if(!_)return[...I];const $=_.dirtyPagesRef.current,Y=(c==null?void 0:c.allPages)===!0,te=Te.current;let ge=!1;const he=I.map((Fe,nt)=>{if(!(Y||$.has(nt)||nt===te))return Fe;const Tn=Ze(w,nt);let Jr=null;if(Tn?(Pl(Tn),Jr=Tn.innerHTML):Jr=m.flushPageHtml(nt),Jr===null){const Mm=Xt(ye(Fe).body),_m=cf(Mm);if(_m===Mm)return Fe;const Nm=pr(zt(_m,ye(Fe).body),Fe);return Nm!==Fe&&(ge=!0),Nm}const by=zt(Jr,ye(Fe).body),Em=pr(by,Fe,Tn??void 0);return Em!==Fe&&(ge=!0),Em});if(ge){const Fe=Ke.current?he.map(yr=>Ae(yr)):he,nt=_.setPages(Fe);se.current=nt.joined}_.markPagesClean();const Be=ge?_.pages:I;return Ke.current?Be.map(Fe=>Ae(Fe)):[...Be]},[Ae,mt,pr]),gr=s.useCallback((c,m,w)=>{const I=pr(m,Me.current[c]??""),_=Ec(Me.current,c,I);_.changed&&sn(_.pages,w,c)},[sn,pr]),hr=s.useCallback((c,m,w)=>{const I=Me.current[c]??"",_=ye(m).body,$=cf(_),Y=$===_?m:pr(zt($,ye(I).body),I),te=Ec(Me.current,c,Y);te.changed&&sn(te.pages,w,c)},[sn,pr]),Vo=s.useCallback((c,m)=>{const w=ye(c).body;xe.current?gr(Te.current,w,m):we(w,m)},[gr,we]),de=s.useCallback((c,m,w)=>{var Y;const I=w?ye(w).body:c.innerHTML,_=te=>w?I:zt(I,ye(te).body);if(!xe.current){we(_(se.current),m);return}const $=(Y=dt.current)==null?void 0:Y.getContainer();if(!$){we(_(se.current),m);return}for(let te=0;te<Me.current.length;te+=1)if(Ze($,te)===c){gr(te,_(Me.current[te]??""),m);return}we(_(se.current),m)},[gr,we]),im=s.useCallback((c,m)=>{nd.current||de(c,m)},[de]),qb=s.useMemo(()=>$I(()=>F.current,()=>se.current,da),[da]),Zb=s.useMemo(()=>UI(()=>F.current,()=>se.current,ma,c=>we(ye(c).body,!1)),[ma,we]),Yb=s.useMemo(()=>Yf(()=>F.current,Wt??"in",c=>de(c,!1)),[Wt,de]),Xb=s.useMemo(()=>VI(c=>{var w;const m=(w=dt.current)==null?void 0:w.getContainer();return m?Ze(m,c):null},c=>Me.current[c]??"",da),[da]),Jb=s.useMemo(()=>WI(c=>{var w;const m=(w=dt.current)==null?void 0:w.getContainer();return m?Ze(m,c):null},c=>Me.current[c]??"",ma,(c,m)=>gr(c,ye(m).body,!1)),[ma,gr]),Qb=s.useMemo(()=>Yf(()=>{var m;const c=(m=dt.current)==null?void 0:m.getContainer();return c?Ze(c,Te.current):null},Wt??"in",c=>de(c,!1)),[Wt,de]),fa=s.useCallback(()=>{const c=xe.current?ht():[se.current];return c[Te.current]??c[0]??""},[ht]),br=s.useCallback(()=>{if(!xe.current)return[se.current];if(B.current==="html"){const c=Me.current.slice();return c[Te.current]=wn.current,c}return ht({allPages:!0})},[ht]),pa=s.useCallback(c=>{if(!xe.current||B.current!=="visual"||!Gt.current)return;dr.current=!0;const m=ht(),w=Math.max(0,Math.min(c,m.length)),I=[...m],_=Ll.current?xf(Un(),Ll.current):Un();I.splice(w,0,_);const $=I.map(Y=>Ae(Y));sn(I,!1,void 0,{skipHistory:!0}),Ht(oe)&&oe.recordInsertPage(w,$),Te.current=w,Po(w),mr(!0),Ai.current=w},[ht,sn,oe,Ae]),am=s.useCallback(()=>{const c=ln();c===null||!Gt.current||pa(c)},[pa,ln]),lm=s.useCallback(()=>{const c=ln();c===null||!Gt.current||pa(c+1)},[pa,ln]),sm=s.useCallback(()=>{if(!xe.current||B.current!=="visual"||!Gt.current)return;dr.current=!0;const c=ht();if(c.length<=1){dr.current=!1;return}const m=ln();if(m===null){dr.current=!1;return}const w=c[m]??"",I=c.filter((te,ge)=>ge!==m),_=Ae(w),$=I.map(te=>Ae(te));sn(I,!1,void 0,{skipHistory:!0}),Ht(oe)&&oe.recordDeletePage(m,_,$);const Y=Math.min(m,I.length-1);Te.current=Y,Po(Y),mr(!0)},[ht,sn,oe,ln,Ae]);s.useEffect(()=>{pe||mr(!1)},[pe]),s.useEffect(()=>()=>{Ii.current&&(ji.current=!1,Fr())},[Fr]);const ga=s.useCallback(c=>{var I,_;const m=mt.replacePages([...c]);se.current=m.joined,Me.current=m.pages,Lt.current=!0,Hr(nn(m.pages),Te.current);const w=Math.max(0,Math.min(Te.current,m.pages.length-1));w!==Te.current&&(Te.current=w,Po(w)),Bl.current===void 0&&B.current==="html"&&!Ke.current&&((I=zr.current)==null||I.setHtml(m.joined)),(_=Nt.current)==null||_.call(Nt),zn(m.joined),Ht(oe)&&oe.applyPresent(m.pages)},[nn,oe,mt,Hr,zn]),ha=s.useCallback(()=>{if(B.current!=="visual"||ve){Wr(null);return}const c=F.current;if(!c)return;const m=Zn(c);Wr(w=>m||(w&&w.isConnected&&c.contains(w)?w:null))},[ve]),ba=s.useCallback(()=>{if(Ht(oe)){const m=oe.undo();if(m===null)return;oe.markApplying(),ga(m),an();return}const c=oe.undo();c!==null&&(oe.markApplying(),Yr(c,{fullReplace:!0}),zn(c),oe.finishApplying(),ha(),an())},[ga,an,Yr,oe,ha,zn]),ya=s.useCallback(()=>{if(Ht(oe)){const m=oe.redo();if(m===null)return;oe.markApplying(),ga(m),an();return}const c=oe.redo();c!==null&&(oe.markApplying(),Yr(c,{fullReplace:!0}),zn(c),oe.finishApplying(),ha(),an())},[ga,an,Yr,oe,ha,zn]);s.useEffect(()=>{if(pe){Ht(oe)&&(Ce!==void 0&&!fe?oe.syncPages(Me.current):oe.applyPresent(Me.current));return}Ht(oe)||oe.syncExternal(se.current)},[pe,fe,oe,Ce]);const z=s.useCallback(()=>{Ge.current=un({mode:B.current,visualEl:F.current,htmlEl:gt.current})},[]),cn=s.useCallback(c=>{if(!c||B.current!=="visual"){Ad(!1),Rd(!1),Id(!1);return}Ad(Ou(c)!==null),Rd(gf(c)),Id(hf(c))},[]),xa=s.useCallback(()=>{const c=un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),m=Ge.current;Pc(m,c)||(Ge.current=c)},[]),Rs=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Mi({value:null,unit:kn.current,mixed:!1});return}const m=Wg(c,kn.current);Dt.current&&(m.value=Dt.current.value,m.unit=Dt.current.unit,m.mixed=!1),kn.current=m.unit,Mi(w=>w.value===m.value&&w.unit===m.unit&&w.mixed===m.mixed?w:m)},[]),Ds=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Ol({value:null,mixed:!1});return}const m=Sp(c);Ft.current&&(m.value=Ft.current.value,m.mixed=!1),Ol(w=>w.value===m.value&&w.mixed===m.mixed?w:m)},[]),Is=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Kl({value:null,mixed:!1}),$l({value:null,mixed:!1});return}const m=Ua(c,"color");qt.current&&(m.value=qt.current.value,m.mixed=!1);const w=Ua(c,"backgroundColor");Zt.current&&(w.value=Zt.current.value,w.mixed=!1),Kl(I=>I.value===m.value&&I.mixed===m.mixed?I:m),$l(I=>I.value===w.value&&I.mixed===w.mixed?I:w)},[]),js=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Ul({tag:null,mixed:!1});return}const m=dk(c);Ul(w=>w.tag===m.tag&&w.mixed===m.mixed?w:m)},[]),Es=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Wl({align:null,mixed:!1}),ql({type:null,mixed:!1}),Zl(!1),xd(!1);return}const m=Ch(c);Wl($=>$.align===m.align&&$.mixed===m.mixed?$:m);const w=ih(c);ql($=>$.type===w.type&&$.mixed===w.mixed?$:w);const I=wk(c);Zl($=>$===I?$:I);const _=SS(c);xd($=>$===_?$:_)},[]),U=s.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Hl(Yn()),Yl(!1),Rs(),Ds(),Is(),js(),Es();return}const m=Ge.current,w=!!(m&&!m.collapsed);Yl(_=>_===w?_:w);const I=Xg(oo(c),Bt.current);Hl(_=>$v(_,I)?_:I),Rs(),Ds(),Is(),js(),Es()},[Rs,Ds,Is,js,Es]),cm=s.useCallback(()=>{const c=Ge.current,m=It.current;!m||!c||c.collapsed&&c.start===m.start&&c.end===m.end||(Bt.current={},Dt.current=null,Ft.current=null,qt.current=null,Zt.current=null,Bn.current=null,It.current=null)},[]);s.useEffect(()=>{if(lt==="visual"){U();return}Bt.current={},Dt.current=null,Ft.current=null,qt.current=null,Zt.current=null,Bn.current=null,It.current=null,Hl(Yn()),Mi({value:null,unit:kn.current,mixed:!1}),Ol({value:null,mixed:!1}),Kl({value:null,mixed:!1}),$l({value:null,mixed:!1}),Ul({tag:null,mixed:!1}),Wl({align:null,mixed:!1}),ql({type:null,mixed:!1}),Zl(!1),Yl(!1)},[lt,U]);const Wo=s.useCallback((c,m,w)=>{$m({snapshot:c,visualEl:F.current,htmlEl:gt.current,getHtml:()=>B.current==="visual"&&F.current?F.current.innerHTML:se.current,setHtml:I=>{if(B.current==="visual"){const _=xe.current?Me.current[Te.current]??"":se.current;Vo(zt(ye(I).body,ye(_).body),!1);return}st(I,!1)},content:m,asHtml:w})},[st,Vo]),ey=s.useCallback(c=>{if(!xe.current||c===Te.current)return;Kr.current&&hr(Te.current,wn.current,!0),Kr.current=!1,Te.current=c,Po(c);const m=Me.current[c]??"";wn.current=m},[hr]),ty=s.useCallback(c=>{if(Kr.current=!0,xe.current){if(Ke.current){const m=Ae(c);wn.current=m,hr(Te.current,m,!0)}else wn.current=c,hr(Te.current,c,!0);return}st(c,!0)},[Ae,st,hr]),um=s.useCallback(c=>{var m;if(B.current==="visual"&&c==="html"){if(xe.current){const w=ht({allPages:!0}),I=Te.current,_=w[I]??w[0]??"";wn.current=_,Kr.current=!1,se.current=Et(w),Fr()}else if(F.current){const w=zt(F.current.innerHTML,ye(se.current).body),I=Ta(w,Ra(w,se.current,qr.current,{liveRoot:F.current??void 0}));if(Ke.current){const _=Ae(I),$=se.current;(m=zr.current)==null||m.setStorageHtml(_),se.current=_,_!==$&&(Lt.current=!0,Ht(oe)||oe.record(_,{coalesce:!0}))}else I!==se.current&&st(I,!0)}}B.current==="html"&&c==="visual"&&xe.current&&(Kr.current&&hr(Te.current,wn.current,!0),Kr.current=!1),ki(c),c!=="visual"&&mr(!1)},[Ae,Fr,oe,st,hr,ki,ht]);s.useEffect(()=>{if(!Tt)return;const c=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=c}},[Tt]),s.useEffect(()=>{if(!Tt)return;const c=m=>{m.key==="Escape"&&(m.defaultPrevented||zi.open||ns.open||Bo.open||Fo.open||os||ss.open||us.open||ms.open||ps.open||Jl||Ki.open||hs.open||bs||(m.preventDefault(),rn(!1)))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[Tt,rn,zi.open,ns.open,Bo.open,Fo.open,os,ss.open,us.open,ms.open,ps.open,Jl,Ki.open,hs.open,bs]),s.useEffect(()=>{const c=()=>{if(B.current!=="visual"||!F.current)return;const m=window.getSelection();if(!m||m.rangeCount===0)return;const w=m.anchorNode;!w||!F.current.contains(w)&&F.current!==w||vn.current===null&&(vn.current=window.requestAnimationFrame(()=>{var _;vn.current=null;const I=F.current;if(!(!I||B.current!=="visual")&&(z(),cm(),U(),Wr(Zn(I)),cn(I),Ln.current&&Ti.current&&!((_=Pi.current)!=null&&_.contains(document.activeElement)))){const $=Ge.current;$&&on(Sf(I,$))}}))};return document.addEventListener("selectionchange",c),()=>{document.removeEventListener("selectionchange",c),vn.current!==null&&(window.cancelAnimationFrame(vn.current),vn.current=null)}},[z,cm,U,cn]),s.useEffect(()=>{if(lt!=="html")return;const c=gt.current;if(!c)return;const m=()=>z();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)}},[lt,z]);const W=s.useCallback(c=>{const m=un({mode:"visual",visualEl:c,htmlEl:gt.current}),w=Ge.current,I=Pc(w,m)?w:m.visualRange?m:w??m;Ge.current=I,c.focus();const _=ci(c,I);if(_){const $=window.getSelection();try{$==null||$.removeAllRanges(),$==null||$.addRange(_),Ge.current={...I,visualRange:_}}catch{}}return Ge.current??I},[]),Pn=s.useCallback(()=>{Fi.current=null,Hi.current=null,bd(!1)},[]),dm=s.useCallback(()=>{if(!Bi.current||!Fi.current||!Hi.current||B.current!=="visual")return;const c=F.current;if(!c)return;z();const m=Ge.current;!m||m.collapsed||t0(m,Hi.current)||(W(c),r0(c,Fi.current),de(c,!1),z(),U(),Pn())},[z,W,we,U,Pn]),mm=s.useCallback(()=>{if(B.current!=="visual"){Pn();return}if(Bi.current){Pn();return}const c=F.current;if(!c){Pn();return}const m=W(c);if(m.collapsed){Pn();return}Fi.current=n0(c),Hi.current={...m},bd(!0),z()},[Pn,W,z]),ny=s.useCallback(()=>{dm()},[dm]);s.useEffect(()=>{(lt!=="visual"||ve)&&Pn()},[lt,ve,Pn]);const Ms=s.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=m??kn.current,_=Ar(c,I);if(!_)return;kn.current=_.unit;const $=W(w);if($.collapsed){Dt.current=_,It.current={start:$.start,end:$.end},U();return}Dt.current=null,Fc(w,_.value,_.unit)&&(de(w,!1),z(),U())},[W,we,z,U]),fm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(w.collapsed){Ft.current={value:c},It.current={start:w.start,end:w.end},U();return}Ft.current=null,kc(m,c)&&(de(m,!1),z(),U())},[W,we,z,U]),_s=s.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=W(w),_=c==="color"?qt:Zt;if(I.collapsed){_.current={value:m},It.current={start:I.start,end:I.end},U();return}_.current=null,ni(w,c,m)&&(de(w,!1),z(),U())},[W,we,z,U]),Ns=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(Oi({open:!1,tab:"general"}),w.collapsed){if(c.size!==null){const Y=Ar(c.size,c.unit);Y&&(Dt.current=Y,kn.current=Y.unit)}const _=oo(m),$={};for(const Y of $t)c.marks[Y]!==_[Y]&&($[Y]=c.marks[Y]);Bt.current=$,c.fontColorMixed||(qt.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},U();return}if(Bt.current={},Dt.current=null,Ft.current=null,qt.current=null,Zt.current=null,It.current=null,c.size!==null){const _=Ar(c.size,c.unit);_&&(kn.current=_.unit,Fc(m,_.value,_.unit))}const I=oo(m);for(const _ of $t)c.marks[_]!==I[_]&&Oc(m,_);c.fontFamilyMixed||kc(m,c.fontFamily),c.fontColorMixed||ni(m,"color",c.fontColor),c.highlightColorMixed||ni(m,"backgroundColor",c.highlightColor),de(m,!1),z(),U()},[W,we,z,U]),Ls=s.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;W(w),Ur(_=>({..._,open:!1}));let I=vh(w,c);if(m&&Yk(w,m)&&(I=!0),!I){z(),U();return}de(w,!1),z(),U()},[W,we,z,U]),pm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(rs(I=>({...I,open:!1})),!Al(c)){z(),U();return}if(w.collapsed){Bn.current=c,It.current={start:w.start,end:w.end},U();return}if(Bn.current=null,!Yg(m,c)){z(),U();return}de(m,!1),z(),U()},[W,we,z,U]),Bs=s.useCallback(c=>{if(B.current!=="visual")return;const m=Uo();if(!m)return;W(m),fr($=>({...$,open:!1}));const w=Zr(),I=JSON.stringify(c.atRule)!==JSON.stringify(ot(ye(w).body)),_=Zc(m,c);if(I&&wo(m,_.pageHtml),!_.changed&&!I){z(),U();return}de(m,!1,_.pageHtml),z(),U()},[W,de,z,U,Uo,Zr]),gm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Ui(w=>({...w,open:!1})),!IS(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),hm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),ls(w=>({...w,open:!1})),!_S(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),Ca=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Vi({open:!1}),!e1(m,c,H.current)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),wa=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Wi({open:!1}),!b0(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),bm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),zo({open:!1}),!_0(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),ym=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),cs({open:!1}),!jk(m,c)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),xm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),ds(w=>({...w,open:!1})),!cP(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),Cm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),fs(w=>({...w,open:!1})),!xP(m,c)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),wm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),gs(w=>({...w,open:!1})),!DP(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),An=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),!c(m)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),Fs=s.useCallback(c=>{Ca({src:c.src,alt:c.alt??"",title:c.title??"",css:c.css})},[Ca]),Hs=s.useCallback(c=>{wa({src:c.src,title:c.title??"",css:c.css})},[wa]),zs=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),zo({open:!1}),!N0(m,{src:c.src,title:c.title??"",css:c.css})){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),vm=s.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Gi(w=>({...w,open:!1})),!b1(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),ry=s.useCallback((c,m)=>{ft!=null&&ft.isConnected&&oP(ft,c,m)},[ft]),oy=s.useCallback(()=>{const c=F.current;!c||!(ft!=null&&ft.isConnected)||(de(c,!1),ac(c,ft),z(),U())},[ft,we,z,U]),va=s.useCallback(()=>{if(B.current!=="visual"||!F.current)return se.current;const c=zt(F.current.innerHTML,ye(se.current).body);return Ta(c,Ra(c,se.current,qr.current,{liveRoot:F.current}))},[]),ka=s.useCallback(()=>{if(xe.current){const c=Et(br());return se.current=c,We(c)}if(Lt.current){const c=B.current==="visual"?va():se.current;c!==se.current&&(se.current=c)}return We(se.current)},[br,We,va]),iy=s.useRef(-1),km=s.useCallback(()=>{if(!Lt.current&&$r.current)return $r.current;const c=Lt.current&&B.current==="visual"?va():se.current;return c!==se.current&&(se.current=c),$r.current=c,Lt.current=!1,c},[va]),Sm=s.useCallback(()=>{if(!Lt.current&&$r.current)return $r.current;const c=ht(),m=JSON.stringify(c);return $r.current=m,iy.current=mt.revision,Lt.current=!1,m},[ht,mt.revision]),ay=s.useCallback(()=>xe.current?Sm():km(),[Sm,km]);LP({onAutoSave:r?async c=>{Lt.current=!1;const m=xe.current?nn(JSON.parse(c)):We(c);return r(m)}:void 0,getHtml:ay}),s.useEffect(()=>()=>{var c;(c=H.current)==null||c.clear()},[]),s.useEffect(()=>{var m;if(!fe||e===void 0||pe)return;const c=Ae(e);(m=zr.current)==null||m.setStorageHtml(c),se.current=c,Ht(oe)||oe.syncExternal(c)},[pe,Ae,oe,fe,e]),s.useEffect(()=>{if(!fe||!pe||Ce===void 0||Lt.current)return;const c=Gn(Ce).map(w=>Ae(w));if(kr(c,Me.current))return;const m=mt.replacePages(c);if(se.current=m.joined,Me.current=m.pages,Ht(oe)&&oe.syncPages(m.pages),B.current==="html"){const w=m.pages[Te.current]??"";wn.current=w}},[pe,Ae,oe,fe,mt,Ce]),s.useEffect(()=>()=>{var c;(c=To.current)==null||c.cancel()},[]);const Ie=s.useMemo(()=>({getHtml:ka,setHtml:c=>{st(c,!1)},getMode:()=>B.current,setMode:um,getFullscreen:()=>dd.current,setFullscreen:rn,getDarkMode:()=>Wd.current,setDarkMode:c=>{tm(c)},getPageZoom:()=>oa.current,setPageZoom:nm,getToolbarPosition:()=>Gd.current,setToolbarPosition:c=>{rm(c)},openCustomizeToolbar:()=>{wd(!0)},openDocumentPreview:()=>{vd({open:!0,html:We(Et(br()))})},openHelp:()=>{Oo({open:!0,topicId:"getStarted"})},openKeyboardShortcuts:()=>{Oo({open:!0,topicId:"keyboardShortcuts"})},openAbout:()=>{Sd(!0)},toggleReadAloud:()=>{const c=To.current;if(!c)return;const m=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),w=Af(Da(m),ka());w&&c.toggle(w)},toggleRuler:()=>{Nl(c=>!c)},isReadingAloud:()=>{var c;return((c=To.current)==null?void 0:c.isSpeaking())??!1},isRulerVisible:()=>Si.current,canReadAloud:()=>{if(!za())return!1;const c=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});return Af(Da(c),ka())!==null},undo:ba,redo:ya,canUndo:()=>oe.canUndo(),canRedo:()=>oe.canRedo(),getSelection:()=>{const c=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});return Da(c)},insertText:c=>{const m=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});Wo(m,c,!1)},insertHtml:(c,m)=>{const w=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),I=m===void 0;Wo(w,I?c:m,I)},toggleFontMark:c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(w.collapsed){const I=oo(m);Bt.current=Vv(Bt.current,I,c),It.current={start:w.start,end:w.end},U();return}Bt.current={},It.current=null,Oc(m,c)&&(de(m,!1),z(),U())},clearFormatting:()=>{if(B.current!=="visual")return;const c=F.current;!c||W(c).collapsed||(Bt.current={},Dt.current=null,Ft.current=null,qt.current=null,Zt.current=null,Bn.current=null,It.current=null,e0(c)&&(de(c,!1),z(),U()))},toggleFormatBrush:mm,isFormatBrushActive:()=>Bi.current,isFontMarkActive:c=>zl.current[c],hasTextSelection:()=>B.current==="visual"&&Xl.current,setFontSize:(c,m)=>{Ms(c,m)},setFontSizeUnit:c=>{var Y;const m=F.current,w=Fn.current;if(B.current!=="visual"||!m||w.value===null||w.mixed){kn.current=c,Mi(te=>({...te,unit:c}));return}const I=W(m),_=Ev(m,((Y=I.visualRange)==null?void 0:Y.startContainer)??m),$=Ap(w.value,w.unit,c,_.parentPx,_.rootPx);Ms($,c)},getFontSize:()=>Fn.current.value,getFontSizeUnit:()=>Fn.current.unit,isFontSizeMixed:()=>Fn.current.mixed,setFontFamily:c=>{fm(c)},getFontFamily:()=>jo.current.value,isFontFamilyMixed:()=>jo.current.mixed,getFontFaces:()=>qr.current,setFontColor:c=>{_s("color",c)},setHighlightColor:c=>{_s("backgroundColor",c)},getFontColor:()=>Mo.current.value,isFontColorMixed:()=>Mo.current.mixed,getHighlightColor:()=>No.current.value,isHighlightColorMixed:()=>No.current.mixed,setParagraphStyle:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),mk(m,c)&&(de(m,!1),z(),U()))},getParagraphStyle:()=>Vl.current.tag,isParagraphStyleMixed:()=>Vl.current.mixed,setTextAlign:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),wh(m,c)&&(de(m,!1),z(),U()))},getTextAlign:()=>Gl.current.align,isTextAlignMixed:()=>Gl.current.mixed,indent:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),vk(c)&&(de(c,!1),z(),U()))},outdent:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),kk(c)&&(de(c,!1),z(),U()))},canOutdent:()=>B.current==="visual"&&hd.current,toggleList:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),gk(m,c)&&(de(m,!1),z(),U()))},isBulletList:()=>Lo.current.type==="ul"&&!Lo.current.mixed,isNumberedList:()=>Lo.current.type==="ol"&&!Lo.current.mixed,openFontProperties:c=>{B.current==="visual"&&Oi({open:!0,tab:c??"general"})},applyFontProperties:c=>{Ns(c)},openCustomCss:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=c?qg(c):{value:null,mixed:!1},w=m.mixed||!m.value?"":Fv(m.value);rs({open:!0,value:w})},applyCustomCss:c=>{pm(c)},openParagraphProperties:c=>{if(B.current!=="visual")return;const m=F.current;m&&W(m),Ur({open:!0,tab:c??"general",value:m?Ma(m):Pr(),backgroundImage:m?cc(m):mn()})},applyParagraphProperties:(c,m)=>{Ls(c,m)},openPageProperties:(c,m)=>{if(B.current!=="visual")return;const w=Uo();w&&W(w);const I=Zr(),_=w?Qo(w):ii();fr({open:!0,tab:c==="print"&&!en?"font":c??"font",paragraphTab:m??"spacing",value:{..._,atRule:ot(ye(I).body)}})},applyPageProperties:c=>{Bs(c)},openPageBackgroundImage:()=>{if(B.current!=="visual")return;const c=Uo();c&&W(c);const m=Ss.current;if(Ps.current&&m){m.onPick(_=>{const $=Zr(),Y=c?Qo(c):ii();Bs({...Y,backgroundImage:{...Y.backgroundImage,src:_.src},atRule:ot(ye($).body)})});return}const w=Zr(),I=c?Qo(c):ii();fr({open:!0,tab:"paragraph",paragraphTab:"backgroundImage",value:{...I,atRule:ot(ye(w).body)}})},openParagraphBackgroundImage:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Ss.current;if(Ps.current&&m){m.onPick(w=>{const I=c?Ma(c):Pr(),_=c?cc(c):mn();Ls(I,{..._,src:w.src})});return}Ur({open:!0,tab:"backgroundImage",value:c?Ma(c):Pr(),backgroundImage:c?cc(c):mn()})},openCustomParagraphStyleDialog:c=>{if(B.current!=="visual"||!vs.current)return;if(c){const w=na.current.find(I=>I.id===c);if(!w)return;Ho({open:!0,mode:"edit",style:w});return}const m=F.current;m&&W(m),Ho({open:!0,mode:"create",font:{size:Fn.current.mixed?null:Fn.current.value,unit:Fn.current.unit,marks:{...zl.current},fontFamily:jo.current.mixed?null:jo.current.value,fontColor:Mo.current.mixed?null:Mo.current.value,highlightColor:No.current.mixed?null:No.current.value},paragraph:kh(m?Ma(m):Pr())})},applyCustomParagraphStyle:c=>{const m=na.current.find(I=>I.id===c);if(!m||(Ns({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=F.current;!w||B.current!=="visual"||(W(w),qk(w,m.paragraph)&&(de(w,!1),z(),U()))},customParagraphStylesEnabled:()=>vs.current,getCustomParagraphStyles:()=>na.current,isCustomParagraphStylesLoading:()=>Md.current,openLinkDialog:c=>{if(B.current!=="visual")return;const m=F.current;m&&W(m);const w=m?Th(m):Dl(),I=m?Xc(m):[],_=(w==null?void 0:w.href)??"",$=_.startsWith("#")?_.slice(1):"",Y=I.some(te=>te.id===$)?$:"";Ui({open:!0,tab:c??"link",href:_,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:I,selectedBookmarkId:Y})},applyLink:c=>{gm(c)},openBookmarkDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c),ls({open:!0,existingIds:c?Xc(c).map(m=>m.id):[]})},applyBookmark:c=>{hm(c)},openImageDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Hd.current;if(qd.current&&m){m.onPick(Fs);return}Vi({open:!0})},applyImage:c=>{Ca(c)},openAudioDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Od.current;if(Zd.current&&m){m.onPick(Hs);return}Wi({open:!0})},applyAudio:c=>{wa(c)},openYoutubeDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Kd.current;if(Yd.current&&m){m.onPick(zs);return}zo({open:!0})},applyYoutube:c=>{bm(c)},openImageProperties:c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;W(m);const w=Zn(m),I=h1(m);!w||!I||Gi({open:!0,tab:c??"general",value:I,aspectRatio:f1(w)})},applyImageProperties:c=>{vm(c)},insertHorizontalRule:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),G0(c)&&(de(c,!1),z(),U()))},insertPageBreak:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),J0(c)&&(de(c,!1),z(),U()))},insertPageBefore:()=>{am()},insertPageAfter:()=>{lm()},deletePage:()=>{!xe.current||B.current!=="visual"||Gt.current&&(br().length<=1||is(!0))},isMultiPagesEnabled:()=>xe.current,hasSelectedPage:()=>xe.current&&B.current==="visual"&&Gt.current,canDeletePage:()=>xe.current&&B.current==="visual"&&Gt.current&&br().length>1,canInsertPageBackgroundImage:()=>!(B.current!=="visual"||xe.current&&!Gt.current),canInsertParagraphBackgroundImage:()=>{if(B.current!=="visual")return!1;const c=F.current;return c?En(c).length>0:!1},getActivePageHtml:()=>fa(),getAllPagesHtml:()=>nn(br()),openTableDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c),cs({open:!0})},applyTable:c=>{ym(c)},openTableProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=sP(c);m&&ds({open:!0,value:m})},applyTableProperties:c=>{xm(c)},openCellProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=yP(c);m&&fs({open:!0,value:m})},applyCellProperties:c=>{Cm(c)},openRowProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=RP(c);m&&gs({open:!0,value:m})},applyRowProperties:c=>{wm(c)},insertRowBelow:()=>{An(c=>Uc(c,"below"))},insertRowBefore:()=>{An(c=>Uc(c,"before"))},deleteRow:()=>{An(c=>Ek(c))},insertColumnAfter:()=>{An(c=>pf(c,"after"))},insertColumnBefore:()=>{An(c=>pf(c,"before"))},deleteColumn:()=>{An(c=>Mk(c))},mergeCells:()=>{An(c=>Lk(c))},unmergeCells:()=>{An(c=>Bk(c))},cut:async()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),await ZS(c)&&(de(c,!1),z(),U()))},copy:async()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),await Nh(c))},deleteSelection:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),_h(c)&&(de(c,!1),z(),U()))},addComment:()=>{if(!Ln.current||b||B.current!=="visual")return;const c=F.current;if(!c)return;const m=W(c),w=Sf(c,m);if(w){on(w);return}const I=FS(c,m);if(!I)return;const _=$S(I);HS(c,_.id,m)&&(Pf(c,_.id),z(),im(c,!1),cr([...Ri.current,_]),on(_.id))},toggleCommentsVisible:()=>{_l(c=>{const m=!c,w=F.current;return w&&jh(w,m),m})},areCommentsVisible:()=>Ti.current,canAddComment:()=>!Ln.current||b||B.current!=="visual"?!1:Xl.current||ws.current!==null,isCommentsEnabled:()=>Ln.current,getCommentThreads:()=>Ri.current,setCommentThreads:c=>cr(c),openCommentThread:c=>{const m=F.current;!m||B.current!=="visual"||Pf(m,c)&&(z(),on(c))},isContentLocked:()=>rd.current,isLink:()=>Cd.current,isImageSelected:()=>B.current==="visual"&&ws.current!==null,isInTable:()=>B.current==="visual"&&Td.current,canMergeCells:()=>B.current==="visual"&&Dd.current,canUnmergeCells:()=>B.current==="visual"&&jd.current,...o!=null?{onSave:c=>Bd.current(c)}:{},...a!=null?{onOpen:()=>Fd.current()}:{}}),[st,we,de,im,um,rn,tm,nm,rm,Wo,ba,ya,z,U,W,Ms,fm,_s,Ns,pm,Ls,Bs,gm,hm,Ca,wa,bm,vm,ym,xm,Cm,wm,An,Fs,Hs,zs,ka,fa,br,am,lm,sm,mm,o,a,b,cr,en]),Os=s.useCallback((c,m,w,I)=>{const{activePageIndexAtCapture:_,pageHtmlAtCapture:$,selectedHtmlAtCapture:Y}=I;if(c.mode==="visual"){let te=F.current;if(xe.current){const ge=dt.current;ge==null||ge.ensurePageMounted(_);const he=ge==null?void 0:ge.getContainer();te=he?Ze(he,_):te}if(te){F.current=te;const ge=sC(te,c,Y);if(ge&&!ge.collapsed){cC(ge,m,w);const Fe=xe.current?$??Me.current[_]??"":se.current;Vo(zt(ye(te.innerHTML).body,ye(Fe).body),!1);return}te.focus({preventScroll:!0});const he=ci(te,c),Be=he!==null?{...c,visualRange:he.cloneRange()}:c;$m({snapshot:Be,visualEl:te,htmlEl:gt.current,getHtml:()=>B.current==="visual"&&te?te.innerHTML:se.current,setHtml:Fe=>{if(B.current==="visual"){const nt=xe.current?Me.current[_]??"":se.current;Vo(zt(ye(Fe).body,ye(nt).body),!1);return}st(Fe,!1)},content:m,asHtml:w});return}}Wo(c,m,w)},[Wo,Vo,st]),Pm=s.useCallback(()=>{vn.current!==null&&(window.cancelAnimationFrame(vn.current),vn.current=null,z()),xa()},[z,xa]),Am=s.useCallback(()=>{var Be,Fe;const c=iC({stored:Ge.current,mode:B.current,visualEl:F.current,htmlEl:gt.current}),m={...c,visualRange:((Be=c.visualRange)==null?void 0:Be.cloneRange())??null};Ge.current=m;const w=xe.current?Te.current:0,I=c.mode==="visual"&&xe.current?fa():null,_=((Fe=F.current)==null?void 0:Fe.innerHTML)??"",$=I?Xt(ye(I).body):_,Y=(()=>{if(c.mode==="html"){const yr=Ie.getHtml(),Tn=Math.min(c.start,c.end),Jr=Math.max(c.start,c.end);return yr.slice(Tn,Jr)}const nt=F.current;return nt&&uC(nt,m)||c.text})(),te=c.mode==="visual"&&xe.current&&!c.collapsed&&Y?aC($,_,Y):null,ge=te&&xe.current?{pageIndex:w,start:te.start,end:te.end,pageBodyAtCapture:$}:null,he={activePageIndexAtCapture:w,pageHtmlAtCapture:I,selectedHtmlAtCapture:Y};return{mode:m.mode,selection:Da(m),getHtml:Ie.getHtml,getSelectedHtml:()=>Y,getPinnedPageBodySelection:()=>ge,setHtml:nt=>{st(nt,!1)},insertText:nt=>Os(m,nt,!1,he),insertHtml:(nt,yr)=>{const Tn=yr===void 0;Os(m,Tn?nt:yr,Tn,he)}}},[Os,Ie.getHtml,fa,st]),{catalog:Sa,layout:Tm}=s.useMemo(()=>fx(V,bD,yD),[V]),Pa=s.useMemo(()=>AA(Tm,L),[Tm,L]),Rm=s.useMemo(()=>({...Pa,iconGroups:QP(Pa.iconGroups,Ql)}),[Pa,Ql]),Dm=pe&&lt==="visual",Ks=s.useMemo(()=>ND(Rm,Dm),[Rm,Dm]),$s=s.useMemo(()=>De?vD(Sa,_n):Sa,[Sa,De,_n]),Us=s.useMemo(()=>De?kD(Ks):Ks,[Ks,De]),Vs=s.useMemo(()=>({disabled:tn,readOnly:C,enableComments:De}),[tn,C,De]),ly=s.useCallback(c=>{if(!Nn||!xn||b)return;const m=US(xn,c);cr(VS(Ri.current,Nn,m))},[Nn,xn,b,cr]),Xr=s.useMemo(()=>({...Tv(Ie),...px(V,Am,Pm)}),[Ie,V,Am,Pm]),Ws=s.useMemo(()=>Rv(Ie),[Ie,Ro,Do,Io,Eo,_o,_i,Yi,Xi,ra,Gr,ft,Qi,ea,ta,Ni,Li,Hn,Vr,Ko,Ao,ad,Tt]);s.useLayoutEffect(()=>{Rt.bump("history")},[ad,Rt]),s.useLayoutEffect(()=>{Rt.bump("marks")},[Ro,Do,Io,Eo,_o,_i,Li,Rt]),s.useLayoutEffect(()=>{Rt.bump("table")},[Qi,ea,ta,Rt]),s.useLayoutEffect(()=>{Rt.bump("selection")},[Ni,ft,Rt]),s.useLayoutEffect(()=>{Rt.bump("chrome")},[Hn,Vr,Ko,Ao,Tt,Yi,Xi,ra,Gr,Rt]);const sy=s.useCallback(c=>{if(ve||c.inputType!=="insertText"&&c.inputType!=="insertReplacementText"||!c.data||!Uv(Bt.current)&&!Dt.current&&!Vx(Ft.current)&&!vC({color:qt.current,backgroundColor:Zt.current})&&!Ov(Bn.current))return;const m=F.current;m&&(c.preventDefault(),ek(m,c.data,Bt.current,Dt.current,{color:qt.current,backgroundColor:Zt.current},Ft.current,Bn.current),Bt.current={},Dt.current=null,Ft.current=null,qt.current=null,Zt.current=null,Bn.current=null,It.current=null,de(m,!0),z(),U())},[ve,we,z,U]),cy=s.useCallback(c=>{var ge;if(ve||!Dx(c,Ed.current))return;c.preventDefault(),c.stopPropagation();let m=F.current;if(xe.current){const he=c.currentTarget instanceof HTMLElement&&c.currentTarget.hasAttribute(Dr)?c.currentTarget:Iw(c.target);if(he instanceof HTMLElement){const Be=Ym(he);Be!==null&&((ge=dt.current)==null||ge.activatePageAt(Be),F.current=he,m=he,Gt.current=!0,mr(!0))}}else c.currentTarget instanceof HTMLDivElement&&(F.current=c.currentTarget,m=c.currentTarget);if(!m)return;W(m);const w=Nc(m,c.target),I=il(m,c.target);I&&!wi(m).includes(I)&&Nk(m,I);const _={inTable:wt(m,c.target)!==null,canMergeCells:gf(m),canUnmergeCells:hf(m)},$={canDeletePage:xe.current&&Gt.current&&ht().length>1},Y={canAddComment:Ln.current&&!b};if(w){ac(m,w),z(),Wr(w),Cs({open:!0,x:c.clientX,y:c.clientY,kind:"image",..._,...$,...Y,inTable:wt(m,w)!==null});return}const te=un({mode:"visual",visualEl:m,htmlEl:gt.current});Ge.current=te,Cs({open:!0,x:c.clientX,y:c.clientY,kind:te.collapsed?"caret":"text",..._,...$,canAddComment:Y.canAddComment&&!te.collapsed})},[ve,z,W,ht,b,mr]),uy=s.useCallback(c=>{if(Ed.current=c.pointerType,b)return;const m=F.current;if(!m)return;if(Ln.current&&Ti.current){const I=Eh(m,c.target);if(I){const _=I.getAttribute("data-comment-thread");_&&on(_);return}}if(ve&&!Ln.current)return;const w=Nc(m,c.target);if(!w){Wr(null);return}c.preventDefault(),ac(m,w),z(),Wr(w)},[b,ve,z]),Im=s.useCallback(c=>{if(ve)return;if(c.key==="Tab"&&!c.ctrlKey&&!c.metaKey&&!c.altKey){if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=c.target;if(!(I instanceof Node)||!w.contains(I))return;W(w);const _=_k(w,c.shiftKey);if(!_)return;c.preventDefault(),typeof _=="object"&&_.changed&&de(w,!1),z(),U(),cn(w);return}if(!(c.ctrlKey||c.metaKey))return;if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),Ie.insertPageBreak();return}const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),ba();return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),ya();return}if(m==="b"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("bold");return}if(m==="i"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("italic");return}if(m==="u"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("underline");return}if(m==="x"&&c.shiftKey){c.preventDefault(),Ie.toggleFontMark("strikethrough");return}m==="p"&&!c.shiftKey&&(c.preventDefault(),Xr.print())},[ve,ba,ya,Ie,Xr,W,we,z,U,cn]),dy=s.useCallback(c=>{if(c.key==="F1"){c.preventDefault(),Oo({open:!0,topicId:"getStarted"});return}if(c.key==="Escape"&&Nn){c.preventDefault(),on(null);return}Im(c)},[Nn,Im]),my=[ke.root,wc(Hn).className,Tt?ke.fullscreen:"",x].filter(Boolean).join(" "),fy=p_({dark:Hn,toolbarBackground:k,menuColor:S,menuBackground:A,menuFontSize:R,menuFontFamily:T,border:D}),py=wc(Hn)["data-wysiwyg-theme"];id.current={multiPageVisualRef:dt,workspaceRef:ur,suppressPageFlushRef:dr,pendingInsertPageFocusRef:Ai,visualRootRef:F,visualPropSyncGuardRef:Nt,htmlAreaRef:gt,commentPanelRef:Pi,activePageIndexRef:Te,htmlModePageHtmlRef:wn,setHtmlModePageHtml:()=>{},activePageHtmlRef:cd,pageCanvasSizedRef:ud,setActivePageIndex:Po,setHasSelectedPage:mr,setActiveThreadId:on,setContextMenu:Cs,recordVisualInputHtml:Gb,recordPageVisualHtml:gr,handleVisualBeforeInput:sy,handleVisualPointerDown:uy,handleVisualMouseUp:ny,handleVisualContextMenu:cy,handleHtmlPageTabSelect:ey,handleHtmlSurfaceChange:ty,handleImageResize:ry,handleImageResizeEnd:oy,multiPageRulerMarginPreview:Xb,multiPageRulerMarginChange:Jb,multiPageRulerIndentChange:Qb,singlePageRulerMarginPreview:qb,singlePageRulerMarginChange:Zb,singlePageRulerIndentChange:Yb,resolveEmbeddedImageDataUrl:fe?El:void 0,hydrateExportHtml:We,postCommentMessage:ly,htmlFileDrop:om};const gy=s.useMemo(()=>Db({catalog:$s,layout:Us,commands:Xr,queries:Ws,queryRevisions:Rt,disabled:tn,chromeLock:Vs}),[tn,Vs,Xr,$s,Us,Ws,Rt]),hy=s.useMemo(()=>({documentBridgeRef:zr,htmlRef:se,pagesRef:Me}),[]);return i.jsx(wx,{locale:v,children:i.jsx(yx,{dark:Hn,children:i.jsx(AM,{value:hy,children:i.jsxs("div",{className:my,style:fy,"data-fullscreen":Tt?"":void 0,"data-wysiwyg-theme":py,"data-toolbar-position":Vr,"data-comments-visible":De&&_n?"":void 0,onKeyDown:dy,children:[i.jsx(SM,{menuVisible:P,captureChromeSelection:xa,displayCatalog:$s,displayLayout:Us,commands:Xr,queries:Ws,queryRevisions:Rt,chromeDisabled:tn,chromeLock:Vs,contentLocked:ve,customizeToolbarOpen:Jl,baseCatalog:Sa,allowedLayout:Pa,toolbarSettings:Ql,toolbarSettingsLoading:Mb,toolbarSettingsBusy:_b,onCustomizeToolbarClose:()=>wd(!1),onToolbarSettingsChange:c=>{em(c)},onToolbarSettingsReset:()=>{em(null)},documentPreview:Ki,onDocumentPreviewClose:()=>vd({open:!1,html:Ki.html}),helpDialog:hs,onHelpDialogClose:()=>Oo(c=>({...c,open:!1})),onHelpTopicChange:c=>Oo(m=>({...m,open:!0,topicId:c})),aboutDialogOpen:bs,onAboutDialogClose:()=>Sd(!1),fontDialog:zi,fontSizeState:Do,markState:Ro,fontFamilyState:Io,fontColorState:Eo,highlightColorState:_o,fontFaces:Gr,onFontDialogTabChange:c=>Oi({open:!0,tab:c}),onFontDialogClose:()=>Oi({open:!1,tab:zi.tab}),onApplyFontProperties:c=>Ie.applyFontProperties(c),paragraphDialog:Bo,customBackgroundImagePicker:Sn,disableBuiltinBackgroundImageSources:ks,onParagraphCustomImagePick:()=>{Sn==null||Sn.onPick(c=>{Ur(m=>({...m,tab:"backgroundImage",backgroundImage:{...m.backgroundImage,src:c.src}}))})},onParagraphDialogTabChange:c=>Ur({...Bo,open:!0,tab:c}),onParagraphDialogClose:()=>Ur({...Bo,open:!1}),onApplyParagraphProperties:({value:c,backgroundImage:m})=>Ie.applyParagraphProperties(c,m),customCssDialog:ns,onCustomCssDialogClose:()=>rs(c=>({...c,open:!1})),onApplyCustomCss:c=>Ie.applyCustomCss(c),pageDialog:Fo,enablePageProperties:en,onPageCustomImagePick:()=>{Sn==null||Sn.onPick(c=>{fr(m=>({...m,tab:"paragraph",paragraphTab:"backgroundImage",value:{...m.value,backgroundImage:{...m.value.backgroundImage,src:c.src}}}))})},onPageDialogTabChange:c=>fr({...Fo,open:!0,tab:c}),onPageDialogClose:()=>fr({...Fo,open:!1}),onApplyPageProperties:c=>Ie.applyPageProperties(c),onPageDialogResetAtRule:()=>{const c=Uo();if(!c||B.current!=="visual")return;const m=xe.current?Zr():ye(se.current).body,w=cS(c,m);w.changed&&(de(c,!1,w.pageHtml),fr(I=>({...I,value:{...I.value,atRule:Wn()}})))},deletePageConfirmOpen:os,onDeletePageConfirmClose:()=>is(!1),onDeletePageConfirm:()=>{sm(),is(!1)},customStyleDialog:Nb,canDeleteCustomParagraphStyle:!!ae,customStyleBusy:Kb,onCustomStyleDialogClose:()=>Ho({open:!1}),onCustomStyleSave:async c=>{const m=Nd.current;if(m){Ji(!0);try{await m(c),Ho({open:!1}),await ua()}finally{Ji(!1)}}},onCustomStyleDelete:async c=>{const m=Ld.current;if(m){Ji(!0);try{await m(c),Ho({open:!1}),await ua()}finally{Ji(!1)}}},linkDialog:as,onLinkDialogTabChange:c=>Ui({...as,open:!0,tab:c}),onLinkDialogClose:()=>Ui({...as,open:!1}),onApplyLink:c=>Ie.applyLink(c),bookmarkDialog:kd,onBookmarkDialogClose:()=>ls({...kd,open:!1}),onApplyBookmark:c=>Ie.applyBookmark(c),imageDialogOpen:Lb.open,customImagePicker:Z,customAudioPicker:M,customVideoPicker:O,onImageDialogClose:()=>Vi({open:!1}),onApplyImage:c=>Ie.applyImage(c),onImageDialogCustomPick:()=>{Vi({open:!1}),Z==null||Z.onPick(Fs)},audioDialogOpen:Bb.open,onAudioDialogClose:()=>Wi({open:!1}),onApplyAudio:c=>Ie.applyAudio(c),onAudioDialogCustomPick:()=>{Wi({open:!1}),M==null||M.onPick(Hs)},youtubeDialogOpen:Fb.open,onYoutubeDialogClose:()=>zo({open:!1}),onApplyYoutube:c=>Ie.applyYoutube(c),onYoutubeDialogCustomPick:()=>{zo({open:!1}),O==null||O.onPick(zs)},imageProperties:Hb,onImagePropertiesTabChange:c=>Gi(m=>({...m,tab:c})),onImagePropertiesClose:()=>Gi(c=>({...c,open:!1})),onApplyImageProperties:c=>Ie.applyImageProperties(c),tableDialogOpen:ss.open,onTableDialogClose:()=>cs({open:!1}),onApplyTable:c=>Ie.applyTable(c),tableProperties:us,onTablePropertiesClose:()=>ds(c=>({...c,open:!1})),onApplyTableProperties:c=>Ie.applyTableProperties(c),cellProperties:ms,onCellPropertiesClose:()=>fs(c=>({...c,open:!1})),onApplyCellProperties:c=>Ie.applyCellProperties(c),rowProperties:ps,onRowPropertiesClose:()=>gs(c=>({...c,open:!1})),onApplyRowProperties:c=>Ie.applyRowProperties(c)}),i.jsx(PM,{toolbarVisible:j,toolbarPos:Vr,captureChromeSelection:xa,toolbarShellProps:gy,children:i.jsx(d_,{propsRef:id,pageStore:mt,mode:lt,enableMultiPages:pe,contentLocked:ve,activePageIndex:Or,hasSelectedPage:Ao,pageZoomScale:ys,rulerVisible:ko,rulerUnit:Wt,optimizeEmbeddedImages:fe,placeholder:y,value:e,pagesProp:Ce,controlledHtml:Cn,initialHtml:Ne,initialStorageHtml:Ml,defaultPages:J.current??[Un()],ingestedPagesProp:od,onChange:n,fontFaces:Gr,enableComments:De,commentsVisible:_n,disabled:b,locale:v,commentAuthor:xn,activeThreadId:Nn,contextMenu:$b,commentThreads:So,commands:Xr,htmlFileDropDragging:om.dragging,selectedImage:ft})}),Tt?i.jsx(g_,{onClick:()=>rn(!1)}):null]})})})})}function p_({dark:e,toolbarBackground:t,menuColor:n,menuBackground:r,menuFontSize:o,menuFontFamily:a,border:l}){const u={};return e||(t&&(u["--wysiwyg-toolbar-background"]=t),n&&(u["--wysiwyg-menu-color"]=n),r&&(u["--wysiwyg-menu-background"]=r)),o&&(u["--wysiwyg-menu-font-size"]=o),a&&(u["--wysiwyg-menu-font-family"]=a),l==="none"?(u["--wysiwyg-border-width"]="0",u["--wysiwyg-border-radius"]="0",u["--wysiwyg-border-shadow"]="none"):l&&(l.width&&(u["--wysiwyg-border-width"]=l.width),l.color&&(u["--wysiwyg-border-color"]=l.color),l.radius&&(u["--wysiwyg-border-radius"]=l.radius),l.shadow&&(u["--wysiwyg-border-shadow"]=l.shadow)),Object.keys(u).length?u:void 0}function g_({onClick:e}){const t=X();return i.jsx("button",{type:"button",className:ke.exitFullscreen,"aria-label":t("exitFullscreenAria"),onClick:e,children:i.jsx(Qe,{className:ke.exitFullscreenIcon})})}function h_(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)===ct?!0:t.length===2&&t.some(r=>r.name===ct)&&t.some(r=>r.name==="class"&&r.value.includes("wysiwyg-comment-anchor"))?!e.hasAttribute("style"):!1}function b_(e){for(const t of[...e.querySelectorAll(`[${ct}]`)])t.removeAttribute(ct),t instanceof HTMLElement&&t.classList.remove("wysiwyg-comment-anchor");for(const t of[...e.querySelectorAll("span")]){if(!h_(t))continue;const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);n.removeChild(t)}}}function y_(e){const t=e.trim();if(!t)return e;const n=new DOMParser().parseFromString(t,"text/html");return b_(n.body),n.body.innerHTML}exports.Editor=f_;exports.PAGE_SEPARATOR=Ya;exports.joinPagesToHtml=Et;exports.sanitizeDocumentHtml=to;exports.sanitizePageHtml=Yc;exports.splitPagesFromHtml=qn;exports.stripCommentAnchors=y_;
320
+ `)},[r,t.pages,t.revision,a,ne,S]),He=RM(r?t.pages:[],r?t.revision:0);l.useLayoutEffect(()=>{var fe;if(!r)return;const Q=(fe=e.current.multiPageVisualRef.current)==null?void 0:fe.getActivePageRoot();Q instanceof HTMLDivElement&&(e.current.visualRootRef.current=Q)},[r,a,He.length,e]);const $e=l.useMemo(()=>r?He[s?a:0]??"":ye(ne).body,[r,He,a,s,ne]),Ve=l.useMemo(()=>ag(ot($e)),[$e]);O.activePageHtmlRef.current=$e,O.pageCanvasSizedRef.current=Ve,l.useEffect(()=>{const fe=(Ee?Ee.split(`
321
+ `):[]).map(pe=>{const Ce=document.createElement("link");return Ce.rel="stylesheet",Ce.href=pe,Ce.setAttribute(bs,""),document.head.append(Ce),Ce});return()=>{for(const pe of fe)pe.remove()}},[Ee]),l.useEffect(()=>{(!A||n!=="visual"||!R)&&e.current.setActiveThreadId(null)},[A,n,R,e]),l.useEffect(()=>{if(!j)return;const Q=fe=>{var Vt;const pe=e.current,Ce=fe.target;if((Vt=pe.commentPanelRef.current)!=null&&Vt.contains(Ce))return;const Pt=pe.visualRootRef.current;Pt&&Eh(Pt,Ce)||pe.setActiveThreadId(null)};return document.addEventListener("pointerdown",Q),()=>document.removeEventListener("pointerdown",Q)},[j,e]),l.useEffect(()=>{if(!r||n!=="html")return;const Q=t.pages[a]??t.pages[0]??"";O.htmlModePageHtmlRef.current=Q,re(Q)},[r,n,t.pages,t.revision,a,O]),l.useEffect(()=>{if(!A||n!=="visual")return;const Q=e.current.visualRootRef.current;Q&&(KS(Q,V),jh(Q,R))},[A,n,V,R,ne,e]);const St=n==="visual"&&d&&Ve,et=l.useMemo(()=>j?WS(V,j):null,[j,V]),en=n==="visual"?r?i.jsx(KI,{ref:O.multiPageVisualRef,pages:He,activePageIndex:a,hasSelectedPage:s,scrollRootRef:O.workspaceRef,suppressPageFlushRef:O.suppressPageFlushRef,pendingInsertPageFocusRef:O.pendingInsertPageFocusRef,onActivePageIndexChange:Q=>{var Ce;O.activePageIndexRef.current=Q,O.setActivePageIndex(Q);const fe=(Ce=O.multiPageVisualRef.current)==null?void 0:Ce.getContainer(),pe=fe?qe(fe,Q):null;pe instanceof HTMLDivElement&&(O.visualRootRef.current=pe)},onPageSelected:()=>{O.setHasSelectedPage(!0)},onPageChange:(Q,fe)=>{const pe=Z.current[Q]??"";O.recordPageVisualHtml(Q,zt(fe,ye(pe).body),!0)},onPageFlush:(Q,fe)=>{const pe=Z.current[Q]??"";O.recordPageVisualHtml(Q,zt(fe,ye(pe).body),!1)},onBeforeInput:O.handleVisualBeforeInput,onPointerDown:Q=>{if(Q.currentTarget instanceof HTMLDivElement&&(O.visualRootRef.current=Q.currentTarget),O.handleVisualPointerDown(Q),Q.currentTarget instanceof HTMLDivElement){const fe=Q.currentTarget;requestAnimationFrame(()=>fo(fe))}},onMouseUp:O.handleVisualMouseUp,onContextMenu:O.handleVisualContextMenu,placeholder:h,disabled:o,rulerVisible:d,rulerUnit:f,zoomScale:u,onMarginPreview:O.multiPageRulerMarginPreview,onMarginChange:O.multiPageRulerMarginChange,onIndentChange:O.multiPageRulerIndentChange,resolveEmbeddedImageDataUrl:g?O.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?O.hydrateExportHtml:void 0}):i.jsx(e_,{ref:O.visualRootRef,html:ye(ne).body,pageHtml:ne,rulerVisible:d,rulerUnit:f,zoomScale:u,propSyncGuardRef:O.visualPropSyncGuardRef,resolveEmbeddedImageDataUrl:g?O.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?O.hydrateExportHtml:void 0,onMarginPreview:O.singlePageRulerMarginPreview,onMarginChange:O.singlePageRulerMarginChange,onIndentChange:O.singlePageRulerIndentChange,onChange:Q=>O.recordVisualInputHtml(Q,!0),onBeforeInput:O.handleVisualBeforeInput,onPointerDown:Q=>{if(O.handleVisualPointerDown(Q),Q.currentTarget instanceof HTMLDivElement){const fe=Q.currentTarget;requestAnimationFrame(()=>fo(fe))}},onMouseUp:O.handleVisualMouseUp,onContextMenu:O.handleVisualContextMenu,placeholder:h,disabled:o}):i.jsxs("div",{className:ke.htmlModeShell,children:[r&&t.pages.length>1?i.jsx(JM,{pageCount:t.pages.length,activeIndex:a,onSelect:O.handleHtmlPageTabSelect}):null,i.jsx(VM,{ref:O.htmlAreaRef,html:r?M:ne,onChange:Q=>{O.htmlModePageHtmlRef.current=Q,re(Q),O.handleHtmlSurfaceChange(Q)},placeholder:h,disabled:o})]});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{ref:O.workspaceRef,className:`${ke.workspace} ${Ve?ke.workspacePageSized:""} ${St?ke.workspaceWithRuler:""}`,onDragEnter:O.htmlFileDrop.onDragEnter,onDragOver:O.htmlFileDrop.onDragOver,onDragLeave:O.htmlFileDrop.onDragLeave,onDrop:O.htmlFileDrop.onDrop,children:[n==="visual"?i.jsx("div",{className:ke.pageCanvasViewport,"data-page-canvas-sized":Ve?"":void 0,children:en}):en,O.htmlFileDrop.dragging?i.jsx(c_,{}):null]}),n==="visual"&&!o&&(K!=null&&K.isConnected)?i.jsx(s_,{img:K,onResize:O.handleImageResize,onResizeEnd:O.handleImageResizeEnd}):null,A&&R&&et?i.jsx(UM,{panelRef:O.commentPanelRef,thread:et,locale:D,disabled:T,commentAuthor:P,onPost:O.postCommentMessage,onClose:()=>O.setActiveThreadId(null)}):null,i.jsx(Tx,{open:L.open,x:L.x,y:L.y,kind:L.kind,inTable:L.inTable,canMergeCells:L.canMergeCells,canUnmergeCells:L.canUnmergeCells,canDeletePage:L.canDeletePage,canAddComment:L.canAddComment,commands:E,onClose:()=>O.setContextMenu(Q=>({...Q,open:!1}))})]})}const d_=l.memo(u_,l_),m_=.005;function f_({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:A,menuFontSize:R,menuFontFamily:T,border:D,menuVisible:P=!0,toolbarVisible:j=!0,allowedChrome:L,customActions:V,customFonts:E,transformHtml:N,sanitizeHtml:K=!0,loadCustomParagraphStyles:G,onSaveCustomParagraphStyle:Z,onDeleteCustomParagraphStyle:ae,customImagePicker:q,disableBuiltinImageInsert:ee,customBackgroundImagePicker:se,disableBuiltinBackgroundImageInsert:me,disableBuiltinBackgroundImageSources:ne,customAudioPicker:M,disableBuiltinAudioInsert:re,customVideoPicker:O,disableBuiltinVideoInsert:ie,disableHtmlFileDrop:Ee=!1,toolbarCustomization:He,darkMode:$e=!1,darkModePersistence:Ve,toolbarPosition:St="top",toolbarPositionPersistence:et,enablePageProperties:en=!1,defaultPageProperties:Q,optimizeEmbeddedImages:fe=!1,enableMultiPages:pe=!1,pages:Ce,defaultPages:Pt,onPagesChange:Vt,defaultRulerVisible:Mn=!0,rulerUnit:Wt="in",enableComments:De=!1,defaultCommentsVisible:yn=!0,commentAuthor:xn,comments:_r,defaultComments:Nr=[],onCommentsChange:Lr}){var jm;const ve=!!(b||C),tn=!!b,Br=pe?Ce!==void 0:e!==void 0,sr=Gn(Pt??(t.trim()?[t]:[Un()])),lr=!Br&&Q?sr.map(c=>xf(c,Q)):sr,H=l.useRef(null);fe&&H.current===null&&(H.current=_w());const J=l.useRef(null);J.current===null&&(J.current=fe&&H.current?lr.map(c=>H.current.externalizeHtml(c)):[...lr]);const ue=pe?Et(J.current):J.current[0]??"",Ne=K?to(ue):ue,At=pe&&Ce!==void 0?Et(Gn(Ce)):e,Cn=l.useMemo(()=>{if(At!==void 0)return K?to(At):At},[At,K]),tt=l.useRef(n);tt.current=n;const Ke=l.useRef(fe);Ke.current=fe;const Ae=l.useCallback(c=>!Ke.current||!H.current?c:H.current.externalizeHtml(c),[]),We=l.useCallback(c=>!Ke.current||!H.current?c:H.current.hydrateHtml(c),[]),nn=l.useCallback(c=>c.map(m=>We(m)),[We]),Es=l.useCallback(c=>{var m;return((m=H.current)==null?void 0:m.getDataUrl(c))??null},[]),vi=l.useCallback(c=>{var m;(m=tt.current)==null||m.call(tt,We(c))},[We]),[Ms]=l.useState(()=>{if(fe&&e!==void 0&&!pe){const c=K?to(e):e;return H.current?H.current.externalizeHtml(c):c}return Ne}),[st,ki]=Oa({value:s,defaultValue:u,onChange:d}),[Tt,rn]=Oa({value:f,defaultValue:g,onChange:h}),[_n,_s]=l.useState(yn),[ko,Ns]=l.useState(Mn),Si=l.useRef(ko);Si.current=ko;const[Nn,on]=l.useState(null),[So,cr]=Oa({value:_r,defaultValue:Nr,onChange:Lr}),F=l.useRef(null),Nt=l.useRef(null),Pi=l.useRef(null),ur=l.useRef(null),dt=l.useRef(null),dr=l.useRef(!1),Ai=l.useRef(null),gt=l.useRef(null),xe=l.useRef(pe);xe.current=pe;const Ls=l.useRef(Q);Ls.current=Q;const Ln=l.useRef(De);Ln.current=De;const nd=l.useRef(C);nd.current=C;const rd=l.useRef(ve);rd.current=ve;const Ti=l.useRef(_n);Ti.current=_n;const Ri=l.useRef(So);Ri.current=So;const Di=l.useRef(Vt);Di.current=Vt;const Ii=l.useRef(null),ji=l.useRef(!1),Fr=l.useCallback(()=>{var m;ji.current=!1;const c=Ii.current;Ii.current=null,c&&((m=Di.current)==null||m.call(Di,c.pages,c.activePageIndex))},[]),Hr=l.useCallback((c,m)=>{Ii.current={pages:[...c],activePageIndex:m},!ji.current&&(ji.current=!0,queueMicrotask(Fr))},[Fr]),Bs=l.useRef(Ce);Bs.current=Ce;const od=l.useMemo(()=>!fe||Ce===void 0?Ce:Gn(Ce).map(c=>{var w;const m=K?to(c):c;return((w=H.current)==null?void 0:w.externalizeHtml(m))??m}),[fe,Ce,K]),mt=FP({enabled:pe,pagesProp:od,defaultPages:J.current??[Un()]}),zr=l.useRef(null),id=l.useRef(null),[Or,Po]=l.useState(0),Te=l.useRef(Or);Te.current=Or;const wn=l.useRef(pe?((jm=J.current)==null?void 0:jm[0])??"":""),Kr=l.useRef(!1),[Ao,mr]=l.useState(!1),Gt=l.useRef(Ao);Gt.current=Ao;const[ad,jb]=l.useState(0),sd=l.useRef(!1),ld=l.useRef(!1),Rt=l.useMemo(()=>db(),[]),Fs=l.useRef(null);Fs.current===null&&(Fs.current=pe?YP(J.current??[Un()]):qP(Ae(Ne)));const oe=Fs.current,an=l.useCallback(()=>{const c=oe.canUndo(),m=oe.canRedo();c===sd.current&&m===ld.current||(sd.current=c,ld.current=m,jb(w=>w+1))},[oe]),le=l.useRef(Ne),Me=l.useRef(J.current??[Un()]);pe&&(Me.current=mt.pages);const cd=l.useRef(""),ud=l.useRef(!1),Lt=l.useRef(!0),$r=l.useRef(""),vn=l.useRef(null),B=l.useRef(st);B.current=st;const dd=l.useRef(Tt);dd.current=Tt;const Ge=l.useRef(null),[,Eb]=l.useState(0),To=l.useRef(null);To.current===null&&(To.current=i0(()=>{Eb(c=>c+1)}));const Ei=l.useRef(N);Ei.current=N;const md=l.useRef(K);md.current=K;const Bt=l.useRef({}),Dt=l.useRef(null),Ft=l.useRef(null),Zt=l.useRef(null),qt=l.useRef(null),Bn=l.useRef(null),It=l.useRef(null),[Ro,Hs]=l.useState(Yn),zs=l.useRef(Ro);zs.current=Ro;const kn=l.useRef(lo),[Do,Mi]=l.useState({value:null,unit:lo,mixed:!1}),Fn=l.useRef(Do);Fn.current=Do;const[Io,Os]=l.useState({value:null,mixed:!1}),jo=l.useRef(Io);jo.current=Io;const[Eo,Ks]=l.useState({value:null,mixed:!1}),Mo=l.useRef(Eo);Mo.current=Eo;const[_o,$s]=l.useState({value:null,mixed:!1}),No=l.useRef(_o);No.current=_o;const[_i,Us]=l.useState({tag:null,mixed:!1}),Vs=l.useRef(_i);Vs.current=_i;const[fd,Ws]=l.useState({align:"left",mixed:!1}),Gs=l.useRef(fd);Gs.current=fd;const[pd,Zs]=l.useState({type:null,mixed:!1}),Lo=l.useRef(pd);Lo.current=pd;const[gd,qs]=l.useState(!1),hd=l.useRef(gd);hd.current=gd;const[Ni,Ys]=l.useState(!1),Xs=l.useRef(Ni);Xs.current=Ni;const[Li,bd]=l.useState(!1),Bi=l.useRef(Li);Bi.current=Li;const Fi=l.useRef(null),Hi=l.useRef(null),[yd,xd]=l.useState(!1),Cd=l.useRef(yd);Cd.current=yd;const{fontDialog:zi,setFontDialog:Oi,customizeToolbarOpen:Js,setCustomizeToolbarOpen:wd,documentPreview:Ki,setDocumentPreview:vd,toolbarSettings:Qs,setToolbarSettings:$i,toolbarSettingsLoading:Mb,setToolbarSettingsLoading:el,toolbarSettingsBusy:_b,setToolbarSettingsBusy:tl,paragraphDialog:Bo,setParagraphDialog:Ur,customCssDialog:nl,setCustomCssDialog:rl,pageDialog:Fo,setPageDialog:fr,deletePageConfirmOpen:ol,setDeletePageConfirmOpen:il,customStyleDialog:Nb,setCustomStyleDialog:Ho,linkDialog:al,setLinkDialog:Ui,bookmarkDialog:kd,setBookmarkDialog:sl,imageDialog:Lb,setImageDialog:Vi,audioDialog:Bb,setAudioDialog:Wi,youtubeDialog:Fb,setYoutubeDialog:zo,imageProperties:Hb,setImageProperties:Gi,tableDialog:ll,setTableDialog:cl,tableProperties:ul,setTableProperties:dl,cellProperties:ml,setCellProperties:fl,rowProperties:pl,setRowProperties:gl,helpDialog:hl,setHelpDialog:Oo,aboutDialogOpen:bl,setAboutDialogOpen:Sd}=BP(),[Hn,Zi]=l.useState(()=>Ve?$e:Bf()??$e),[Vr,qi]=l.useState(()=>et?St:Ff()??St),[Ko,zb]=l.useState(()=>$P()??"fitWidth"),[yl,Ob]=l.useState(1),[Yi,Pd]=l.useState([]),[Xi,xl]=l.useState(!1),[Kb,Ji]=l.useState(!1),[$b,Cl]=l.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1,canMergeCells:!1,canUnmergeCells:!1,canDeletePage:!1,canAddComment:!1}),[ft,Wr]=l.useState(null),wl=l.useRef(ft);wl.current=ft;const[Qi,Ad]=l.useState(!1),Td=l.useRef(Qi);Td.current=Qi;const[ea,Rd]=l.useState(!1),Dd=l.useRef(ea);Dd.current=ea;const[ta,Id]=l.useState(!1),jd=l.useRef(ta);jd.current=ta;const Ed=l.useRef(void 0),na=l.useRef(Yi);na.current=Yi;const Md=l.useRef(Xi);Md.current=Xi;const ra=!!(G&&Z),vl=l.useRef(ra);vl.current=ra;const _d=l.useRef(G);_d.current=G;const Nd=l.useRef(Z);Nd.current=Z;const Ld=l.useRef(ae);Ld.current=ae;const Bd=l.useRef(o);Bd.current=o;const Fd=l.useRef(a);Fd.current=a;const Hd=l.useRef(q);Hd.current=q;const Sn=se??q,zd=me??ee??!1,kl=ne??ee??!1,Sl=l.useRef(Sn);Sl.current=Sn;const Pl=l.useRef(zd);Pl.current=zd;const Ub=l.useRef(kl);Ub.current=kl;const Od=l.useRef(M);Od.current=M;const Kd=l.useRef(O);Kd.current=O;const $d=l.useRef(He);$d.current=He;const Ud=l.useRef(Ve);Ud.current=Ve;const Vd=l.useRef(et);Vd.current=et;const Wd=l.useRef(Hn);Wd.current=Hn;const Gd=l.useRef(Vr);Gd.current=Vr;const oa=l.useRef(Ko);oa.current=Ko;const ia=l.useRef(yl);ia.current=yl;const Zd=l.useRef(ee);Zd.current=ee;const qd=l.useRef(re);qd.current=re;const Yd=l.useRef(ie);Yd.current=ie;const Al=l.useRef(0),$o=l.useRef(0),Xd=l.useRef(0),aa=l.useRef(0),Jd=l.useRef(0),sa=l.useRef(0),Qd=l.useRef(0),Gr=l.useMemo(()=>Cp(E),[E]),Zr=l.useRef(Gr);Zr.current=Gr;const la=l.useCallback(()=>{var c;if(xe.current){const m=(c=dt.current)==null?void 0:c.getActivePageRoot();if(m instanceof HTMLElement)return m}return F.current},[]),sn=l.useCallback(()=>{var w;const c=F.current;if(c!=null&&c.hasAttribute(Dr)){const I=Ym(c);if(I!==null)return I}const m=(w=dt.current)==null?void 0:w.getActivePageIndex();return typeof m=="number"?m:Te.current},[]),Uo=l.useCallback(()=>{if(xe.current){const c=dt.current;if(!c)return null;const m=sn();if(m===null)return null;c.ensurePageMounted(m);const w=c.getContainer(),I=w?qe(w,m):null;return I instanceof HTMLDivElement?(F.current=I,I):null}return F.current},[sn]),qr=l.useCallback(()=>{if(!xe.current)return le.current;const c=sn()??Te.current;return Me.current[c]??""},[sn]);l.useLayoutEffect(()=>{var m;if(!pe)return;const c=(m=dt.current)==null?void 0:m.getActivePageRoot();c instanceof HTMLDivElement&&(F.current=c)},[pe,Or]);const ca=l.useRef(()=>{}),Tl=l.useRef(!1),Vb=l.useCallback(()=>{if(Tl.current||B.current!=="visual")return;const c=ur.current;if(c){Tl.current=!0;try{const m=getComputedStyle(c),w=parseFloat(m.paddingLeft)+parseFloat(m.paddingRight),I=parseFloat(m.paddingTop)+parseFloat(m.paddingBottom),_=Math.max(0,c.clientWidth-w),$=Math.max(0,c.clientHeight-I);let Y=0,te=0;if(ud.current){const he=uw(ot(cd.current));he&&(Y=he.width,te=he.height)}else{const he=la(),Be=ia.current>0?ia.current:1;Y=((he==null?void 0:he.offsetWidth)??0)/Be,te=((he==null?void 0:he.offsetHeight)??0)/Be}Y<=0&&(Y=_),te<=0&&(te=$);const ge=wv(oa.current,_,$,Y,te);Math.abs(ge-ia.current)>=m_&&Ob(ge)}finally{Tl.current=!1}}},[la]);ca.current=Vb,l.useLayoutEffect(()=>{if(st!=="visual")return;const c=la();!c||c!==document.activeElement||fo(c)},[st,Or,la]);const ua=l.useCallback(async()=>{const c=_d.current;if(!c)return;const m=++Al.current;xl(!0);try{const w=await c();if(m!==Al.current)return;Pd(w)}catch{}finally{m===Al.current&&xl(!1)}},[]);l.useEffect(()=>{if(!G||!Z){Pd([]),xl(!1);return}ua()},[G,Z,ua]);const em=l.useCallback(async c=>{$i(c);const m=$d.current;if(m!=null&&m.load&&m.save){const w=++Xd.current;tl(!0);try{await m.save(c)}catch{}finally{w===Xd.current&&tl(!1)}return}nA(c)},[]);l.useEffect(()=>{const c=He;if(!(c!=null&&c.load)||!c.save){$i(tA()),el(!1),tl(!1);return}const m=++$o.current;return el(!0),(async()=>{try{const w=await c.load();if(m!==$o.current)return;$i(w)}catch{if(m!==$o.current)return;$i(null)}finally{m===$o.current&&el(!1)}})(),()=>{$o.current+=1}},[He]);const tm=l.useCallback(async c=>{Zi(c);const m=Ud.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}zP(c)},[]),nm=l.useCallback(c=>{oa.current=c,zb(c),UP(c);const m=ur.current;m&&(m.scrollTop=0,m.scrollLeft=0),ca.current()},[]);l.useEffect(()=>{const c=Ve;if(!(c!=null&&c.load)||!c.save){Zi(Bf()??$e);return}const m=++aa.current;return(async()=>{try{const w=await c.load();if(m!==aa.current)return;Zi(typeof w=="boolean"?w:$e)}catch{if(m!==aa.current)return;Zi($e)}})(),()=>{aa.current+=1}},[Ve,$e]),l.useLayoutEffect(()=>{if(ca.current(),st!=="visual")return;const c=ur.current;if(!c||typeof ResizeObserver>"u")return;const m=vv(()=>{ca.current()}),w=new ResizeObserver(()=>{m.schedule()});return w.observe(c),()=>{w.disconnect(),m.cancel()}},[st,Or,Ko,pe]);const rm=l.useCallback(async c=>{qi(c);const m=Vd.current;if(m!=null&&m.load&&m.save){const w=++Qd.current;try{await m.save(c)}catch{}finally{if(w!==Qd.current)return}return}WP(c)},[]);l.useEffect(()=>{const c=et;if(!(c!=null&&c.load)||!c.save){qi(Ff()??St);return}const m=++sa.current;return(async()=>{try{const w=await c.load();if(m!==sa.current)return;qi(Qh(w)??St)}catch{if(m!==sa.current)return;qi(St)}})(),()=>{sa.current+=1}},[et,St]);const Yr=l.useCallback((c,m)=>{var te,ge;const w=md.current?to(c):c,I=((te=Ei.current)==null?void 0:te.call(Ei,w))??w,_=Lh(le.current,I,We);m!=null&&m.fullReplace&&!_&&Ke.current&&((ge=H.current)==null||ge.clear());const $=Ae(I);if(_)return le.current=$,{stored:$,stateUpdated:!1};$!==le.current&&(Lt.current=!0);const Y=zr.current;if(xe.current){const he=mt;if(!he)return le.current=$,{stored:$,stateUpdated:!1};const Be=he.replacePages(Zn($));return le.current=Be.joined,Me.current=Be.pages,B.current==="html"&&!Ke.current&&(Y==null||Y.setHtml($)),Hr(nn(Be.pages),Te.current),{stored:$,stateUpdated:!0}}return Ke.current?(le.current=$,Y==null||Y.setStorageHtml($),vi($),{stored:$,stateUpdated:!0}):(le.current=$,Y==null||Y.setHtml($),{stored:$,stateUpdated:!0})},[Ae,We,nn,vi,Hr]),ln=l.useCallback((c,m,w,I)=>{var te;const _=c.map(ge=>Ae(ge)),$=mt;if(!$)return Et(_);const Y=$.setPages(_,{editedIndex:w});if(!Y.changed)return Y.joined;if(Me.current=Y.pages,Lt.current=!0,le.current=Y.joined,Bs.current===void 0&&B.current==="html"&&!Ke.current&&((te=zr.current)==null||te.setHtml(Y.joined)),Hr(nn(Y.pages),Te.current),!(I!=null&&I.skipHistory)&&Ht(oe)){const{changedIndices:ge,pages:he}=Y;if(ge.length===1){const Be=w??ge[0];oe.recordPageEdit(Be,he[Be]??"",{coalesce:m})}else ge.length>1?oe.recordReplaceAll(he):w!==void 0?oe.recordPageEdit(w,he[w]??"",{coalesce:m}):oe.recordReplaceAll(he)}return an(),Y.joined},[an,Ae,nn,oe,mt,Hr]),zn=l.useCallback(c=>{var $,Y;if(B.current!=="visual")return;const m=Ke.current?te=>{var ge;return((ge=H.current)==null?void 0:ge.getDataUrl(te))??null}:void 0,w=Ke.current?We:void 0;if(($=Nt.current)==null||$.call(Nt),xe.current){const te=(Y=dt.current)==null?void 0:Y.getContainer();if(!te)return;const ge=Zn(c);for(let he=0;he<ge.length;he+=1){const Be=qe(te,he);if(!Be)continue;const Fe=Xt(ye(ge[he]??"").body);ls(Be,Fe,{resolveDataUrl:m,hydrateEmbeddedImages:w})}return}const I=F.current;if(!I)return;const _=Xt(ye(c).body);ls(I,_,{resolveDataUrl:m,hydrateEmbeddedImages:w})},[We]),lt=l.useCallback((c,m)=>{const{stored:w,stateUpdated:I}=Yr(c,{fullReplace:!m});return!m&&I&&zn(w),Ht(oe)?oe.recordReplaceAll(Zn(w)):oe.record(w,{coalesce:m}),an(),w},[an,Yr,oe,zn]),Wb=l.useCallback(c=>{if(xe.current){const m=Te.current,I=Me.current.slice();I[m]=c,ln(I,!1,m);return}lt(c,!1)},[ln,lt]),om=GP({enabled:!ve&&!Ee,onHtml:Wb}),we=l.useCallback((c,m)=>{var w;return(w=Nt.current)==null||w.call(Nt),lt(Ta(c,Ra(c,le.current,Zr.current,{liveRoot:F.current??void 0})),m)},[lt]),Gb=l.useCallback((c,m)=>we(zt(c,le.current),m),[we]),da=l.useCallback((c,m,w)=>{hw(c,m,w)},[]),ma=l.useCallback((c,m,w)=>{const I={...Qo(c),atRule:ot(lg(m,w))};return qc(c,I)},[]),pr=l.useCallback((c,m,w)=>Ta(c,Ra(c,m,Zr.current,{liveRoot:w})),[]),ht=l.useCallback(c=>{const m=dt.current,w=m==null?void 0:m.getContainer(),I=mt.pages.length>0?mt.pages:Me.current;if(!w||!m)return[...I];const _=mt;if(!_)return[...I];const $=_.dirtyPagesRef.current,Y=(c==null?void 0:c.allPages)===!0,te=Te.current;let ge=!1;const he=I.map((Fe,nt)=>{if(!(Y||$.has(nt)||nt===te))return Fe;const Tn=qe(w,nt);let Jr=null;if(Tn?(Ps(Tn),Jr=Tn.innerHTML):Jr=m.flushPageHtml(nt),Jr===null){const Mm=Xt(ye(Fe).body),_m=cf(Mm);if(_m===Mm)return Fe;const Nm=pr(zt(_m,ye(Fe).body),Fe);return Nm!==Fe&&(ge=!0),Nm}const by=zt(Jr,ye(Fe).body),Em=pr(by,Fe,Tn??void 0);return Em!==Fe&&(ge=!0),Em});if(ge){const Fe=Ke.current?he.map(yr=>Ae(yr)):he,nt=_.setPages(Fe);le.current=nt.joined}_.markPagesClean();const Be=ge?_.pages:I;return Ke.current?Be.map(Fe=>Ae(Fe)):[...Be]},[Ae,mt,pr]),gr=l.useCallback((c,m,w)=>{const I=pr(m,Me.current[c]??""),_=Ec(Me.current,c,I);_.changed&&ln(_.pages,w,c)},[ln,pr]),hr=l.useCallback((c,m,w)=>{const I=Me.current[c]??"",_=ye(m).body,$=cf(_),Y=$===_?m:pr(zt($,ye(I).body),I),te=Ec(Me.current,c,Y);te.changed&&ln(te.pages,w,c)},[ln,pr]),Vo=l.useCallback((c,m)=>{const w=ye(c).body;xe.current?gr(Te.current,w,m):we(w,m)},[gr,we]),de=l.useCallback((c,m,w)=>{var Y;const I=w?ye(w).body:c.innerHTML,_=te=>w?I:zt(I,ye(te).body);if(!xe.current){we(_(le.current),m);return}const $=(Y=dt.current)==null?void 0:Y.getContainer();if(!$){we(_(le.current),m);return}for(let te=0;te<Me.current.length;te+=1)if(qe($,te)===c){gr(te,_(Me.current[te]??""),m);return}we(_(le.current),m)},[gr,we]),im=l.useCallback((c,m)=>{nd.current||de(c,m)},[de]),Zb=l.useMemo(()=>$I(()=>F.current,()=>le.current,da),[da]),qb=l.useMemo(()=>UI(()=>F.current,()=>le.current,ma,c=>we(ye(c).body,!1)),[ma,we]),Yb=l.useMemo(()=>Yf(()=>F.current,Wt??"in",c=>de(c,!1)),[Wt,de]),Xb=l.useMemo(()=>VI(c=>{var w;const m=(w=dt.current)==null?void 0:w.getContainer();return m?qe(m,c):null},c=>Me.current[c]??"",da),[da]),Jb=l.useMemo(()=>WI(c=>{var w;const m=(w=dt.current)==null?void 0:w.getContainer();return m?qe(m,c):null},c=>Me.current[c]??"",ma,(c,m)=>gr(c,ye(m).body,!1)),[ma,gr]),Qb=l.useMemo(()=>Yf(()=>{var m;const c=(m=dt.current)==null?void 0:m.getContainer();return c?qe(c,Te.current):null},Wt??"in",c=>de(c,!1)),[Wt,de]),fa=l.useCallback(()=>{const c=xe.current?ht():[le.current];return c[Te.current]??c[0]??""},[ht]),br=l.useCallback(()=>{if(!xe.current)return[le.current];if(B.current==="html"){const c=Me.current.slice();return c[Te.current]=wn.current,c}return ht({allPages:!0})},[ht]),pa=l.useCallback(c=>{if(!xe.current||B.current!=="visual"||!Gt.current)return;dr.current=!0;const m=ht(),w=Math.max(0,Math.min(c,m.length)),I=[...m],_=Ls.current?xf(Un(),Ls.current):Un();I.splice(w,0,_);const $=I.map(Y=>Ae(Y));ln(I,!1,void 0,{skipHistory:!0}),Ht(oe)&&oe.recordInsertPage(w,$),Te.current=w,Po(w),mr(!0),Ai.current=w},[ht,ln,oe,Ae]),am=l.useCallback(()=>{const c=sn();c===null||!Gt.current||pa(c)},[pa,sn]),sm=l.useCallback(()=>{const c=sn();c===null||!Gt.current||pa(c+1)},[pa,sn]),lm=l.useCallback(()=>{if(!xe.current||B.current!=="visual"||!Gt.current)return;dr.current=!0;const c=ht();if(c.length<=1){dr.current=!1;return}const m=sn();if(m===null){dr.current=!1;return}const w=c[m]??"",I=c.filter((te,ge)=>ge!==m),_=Ae(w),$=I.map(te=>Ae(te));ln(I,!1,void 0,{skipHistory:!0}),Ht(oe)&&oe.recordDeletePage(m,_,$);const Y=Math.min(m,I.length-1);Te.current=Y,Po(Y),mr(!0)},[ht,ln,oe,sn,Ae]);l.useEffect(()=>{pe||mr(!1)},[pe]),l.useEffect(()=>()=>{Ii.current&&(ji.current=!1,Fr())},[Fr]);const ga=l.useCallback(c=>{var I,_;const m=mt.replacePages([...c]);le.current=m.joined,Me.current=m.pages,Lt.current=!0,Hr(nn(m.pages),Te.current);const w=Math.max(0,Math.min(Te.current,m.pages.length-1));w!==Te.current&&(Te.current=w,Po(w)),Bs.current===void 0&&B.current==="html"&&!Ke.current&&((I=zr.current)==null||I.setHtml(m.joined)),(_=Nt.current)==null||_.call(Nt),zn(m.joined),Ht(oe)&&oe.applyPresent(m.pages)},[nn,oe,mt,Hr,zn]),ha=l.useCallback(()=>{if(B.current!=="visual"||ve){Wr(null);return}const c=F.current;if(!c)return;const m=qn(c);Wr(w=>m||(w&&w.isConnected&&c.contains(w)?w:null))},[ve]),ba=l.useCallback(()=>{if(Ht(oe)){const m=oe.undo();if(m===null)return;oe.markApplying(),ga(m),an();return}const c=oe.undo();c!==null&&(oe.markApplying(),Yr(c,{fullReplace:!0}),zn(c),oe.finishApplying(),ha(),an())},[ga,an,Yr,oe,ha,zn]),ya=l.useCallback(()=>{if(Ht(oe)){const m=oe.redo();if(m===null)return;oe.markApplying(),ga(m),an();return}const c=oe.redo();c!==null&&(oe.markApplying(),Yr(c,{fullReplace:!0}),zn(c),oe.finishApplying(),ha(),an())},[ga,an,Yr,oe,ha,zn]);l.useEffect(()=>{if(pe){Ht(oe)&&(Ce!==void 0&&!fe?oe.syncPages(Me.current):oe.applyPresent(Me.current));return}Ht(oe)||oe.syncExternal(le.current)},[pe,fe,oe,Ce]);const z=l.useCallback(()=>{Ge.current=un({mode:B.current,visualEl:F.current,htmlEl:gt.current})},[]),cn=l.useCallback(c=>{if(!c||B.current!=="visual"){Ad(!1),Rd(!1),Id(!1);return}Ad(Ou(c)!==null),Rd(gf(c)),Id(hf(c))},[]),xa=l.useCallback(()=>{const c=un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),m=Ge.current;Pc(m,c)||(Ge.current=c)},[]),Rl=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Mi({value:null,unit:kn.current,mixed:!1});return}const m=Wg(c,kn.current);Dt.current&&(m.value=Dt.current.value,m.unit=Dt.current.unit,m.mixed=!1),kn.current=m.unit,Mi(w=>w.value===m.value&&w.unit===m.unit&&w.mixed===m.mixed?w:m)},[]),Dl=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Os({value:null,mixed:!1});return}const m=Sp(c);Ft.current&&(m.value=Ft.current.value,m.mixed=!1),Os(w=>w.value===m.value&&w.mixed===m.mixed?w:m)},[]),Il=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Ks({value:null,mixed:!1}),$s({value:null,mixed:!1});return}const m=Ua(c,"color");Zt.current&&(m.value=Zt.current.value,m.mixed=!1);const w=Ua(c,"backgroundColor");qt.current&&(w.value=qt.current.value,w.mixed=!1),Ks(I=>I.value===m.value&&I.mixed===m.mixed?I:m),$s(I=>I.value===w.value&&I.mixed===w.mixed?I:w)},[]),jl=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Us({tag:null,mixed:!1});return}const m=dk(c);Us(w=>w.tag===m.tag&&w.mixed===m.mixed?w:m)},[]),El=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Ws({align:null,mixed:!1}),Zs({type:null,mixed:!1}),qs(!1),xd(!1);return}const m=Ch(c);Ws($=>$.align===m.align&&$.mixed===m.mixed?$:m);const w=ih(c);Zs($=>$.type===w.type&&$.mixed===w.mixed?$:w);const I=wk(c);qs($=>$===I?$:I);const _=SS(c);xd($=>$===_?$:_)},[]),U=l.useCallback(()=>{const c=F.current;if(B.current!=="visual"||!c){Hs(Yn()),Ys(!1),Rl(),Dl(),Il(),jl(),El();return}const m=Ge.current,w=!!(m&&!m.collapsed);Ys(_=>_===w?_:w);const I=Xg(oo(c),Bt.current);Hs(_=>$v(_,I)?_:I),Rl(),Dl(),Il(),jl(),El()},[Rl,Dl,Il,jl,El]),cm=l.useCallback(()=>{const c=Ge.current,m=It.current;!m||!c||c.collapsed&&c.start===m.start&&c.end===m.end||(Bt.current={},Dt.current=null,Ft.current=null,Zt.current=null,qt.current=null,Bn.current=null,It.current=null)},[]);l.useEffect(()=>{if(st==="visual"){U();return}Bt.current={},Dt.current=null,Ft.current=null,Zt.current=null,qt.current=null,Bn.current=null,It.current=null,Hs(Yn()),Mi({value:null,unit:kn.current,mixed:!1}),Os({value:null,mixed:!1}),Ks({value:null,mixed:!1}),$s({value:null,mixed:!1}),Us({tag:null,mixed:!1}),Ws({align:null,mixed:!1}),Zs({type:null,mixed:!1}),qs(!1),Ys(!1)},[st,U]);const Wo=l.useCallback((c,m,w)=>{$m({snapshot:c,visualEl:F.current,htmlEl:gt.current,getHtml:()=>B.current==="visual"&&F.current?F.current.innerHTML:le.current,setHtml:I=>{if(B.current==="visual"){const _=xe.current?Me.current[Te.current]??"":le.current;Vo(zt(ye(I).body,ye(_).body),!1);return}lt(I,!1)},content:m,asHtml:w})},[lt,Vo]),ey=l.useCallback(c=>{if(!xe.current||c===Te.current)return;Kr.current&&hr(Te.current,wn.current,!0),Kr.current=!1,Te.current=c,Po(c);const m=Me.current[c]??"";wn.current=m},[hr]),ty=l.useCallback(c=>{if(Kr.current=!0,xe.current){if(Ke.current){const m=Ae(c);wn.current=m,hr(Te.current,m,!0)}else wn.current=c,hr(Te.current,c,!0);return}lt(c,!0)},[Ae,lt,hr]),um=l.useCallback(c=>{var m;if(B.current==="visual"&&c==="html"){if(xe.current){const w=ht({allPages:!0}),I=Te.current,_=w[I]??w[0]??"";wn.current=_,Kr.current=!1,le.current=Et(w),Fr()}else if(F.current){const w=zt(F.current.innerHTML,ye(le.current).body),I=Ta(w,Ra(w,le.current,Zr.current,{liveRoot:F.current??void 0}));if(Ke.current){const _=Ae(I),$=le.current;(m=zr.current)==null||m.setStorageHtml(_),le.current=_,_!==$&&(Lt.current=!0,Ht(oe)||oe.record(_,{coalesce:!0}))}else I!==le.current&&lt(I,!0)}}B.current==="html"&&c==="visual"&&xe.current&&(Kr.current&&hr(Te.current,wn.current,!0),Kr.current=!1),ki(c),c!=="visual"&&mr(!1)},[Ae,Fr,oe,lt,hr,ki,ht]);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||zi.open||nl.open||Bo.open||Fo.open||ol||ll.open||ul.open||ml.open||pl.open||Js||Ki.open||hl.open||bl||(m.preventDefault(),rn(!1)))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[Tt,rn,zi.open,nl.open,Bo.open,Fo.open,ol,ll.open,ul.open,ml.open,pl.open,Js,Ki.open,hl.open,bl]),l.useEffect(()=>{const c=()=>{if(B.current!=="visual"||!F.current)return;const m=window.getSelection();if(!m||m.rangeCount===0)return;const w=m.anchorNode;!w||!F.current.contains(w)&&F.current!==w||vn.current===null&&(vn.current=window.requestAnimationFrame(()=>{var _;vn.current=null;const I=F.current;if(!(!I||B.current!=="visual")&&(z(),cm(),U(),Wr(qn(I)),cn(I),Ln.current&&Ti.current&&!((_=Pi.current)!=null&&_.contains(document.activeElement)))){const $=Ge.current;$&&on(Sf(I,$))}}))};return document.addEventListener("selectionchange",c),()=>{document.removeEventListener("selectionchange",c),vn.current!==null&&(window.cancelAnimationFrame(vn.current),vn.current=null)}},[z,cm,U,cn]),l.useEffect(()=>{if(st!=="html")return;const c=gt.current;if(!c)return;const m=()=>z();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)}},[st,z]);const W=l.useCallback(c=>{const m=un({mode:"visual",visualEl:c,htmlEl:gt.current}),w=Ge.current,I=Pc(w,m)?w:m.visualRange?m:w??m;Ge.current=I,c.focus();const _=ci(c,I);if(_){const $=window.getSelection();try{$==null||$.removeAllRanges(),$==null||$.addRange(_),Ge.current={...I,visualRange:_}}catch{}}return Ge.current??I},[]),Pn=l.useCallback(()=>{Fi.current=null,Hi.current=null,bd(!1)},[]),dm=l.useCallback(()=>{if(!Bi.current||!Fi.current||!Hi.current||B.current!=="visual")return;const c=F.current;if(!c)return;z();const m=Ge.current;!m||m.collapsed||t0(m,Hi.current)||(W(c),r0(c,Fi.current),de(c,!1),z(),U(),Pn())},[z,W,we,U,Pn]),mm=l.useCallback(()=>{if(B.current!=="visual"){Pn();return}if(Bi.current){Pn();return}const c=F.current;if(!c){Pn();return}const m=W(c);if(m.collapsed){Pn();return}Fi.current=n0(c),Hi.current={...m},bd(!0),z()},[Pn,W,z]),ny=l.useCallback(()=>{dm()},[dm]);l.useEffect(()=>{(st!=="visual"||ve)&&Pn()},[st,ve,Pn]);const Ml=l.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=m??kn.current,_=Ar(c,I);if(!_)return;kn.current=_.unit;const $=W(w);if($.collapsed){Dt.current=_,It.current={start:$.start,end:$.end},U();return}Dt.current=null,Fc(w,_.value,_.unit)&&(de(w,!1),z(),U())},[W,we,z,U]),fm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(w.collapsed){Ft.current={value:c},It.current={start:w.start,end:w.end},U();return}Ft.current=null,kc(m,c)&&(de(m,!1),z(),U())},[W,we,z,U]),_l=l.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=W(w),_=c==="color"?Zt:qt;if(I.collapsed){_.current={value:m},It.current={start:I.start,end:I.end},U();return}_.current=null,ni(w,c,m)&&(de(w,!1),z(),U())},[W,we,z,U]),Nl=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(Oi({open:!1,tab:"general"}),w.collapsed){if(c.size!==null){const Y=Ar(c.size,c.unit);Y&&(Dt.current=Y,kn.current=Y.unit)}const _=oo(m),$={};for(const Y of $t)c.marks[Y]!==_[Y]&&($[Y]=c.marks[Y]);Bt.current=$,c.fontColorMixed||(Zt.current={value:c.fontColor}),c.highlightColorMixed||(qt.current={value:c.highlightColor}),c.fontFamilyMixed||(Ft.current={value:c.fontFamily}),It.current={start:w.start,end:w.end},U();return}if(Bt.current={},Dt.current=null,Ft.current=null,Zt.current=null,qt.current=null,It.current=null,c.size!==null){const _=Ar(c.size,c.unit);_&&(kn.current=_.unit,Fc(m,_.value,_.unit))}const I=oo(m);for(const _ of $t)c.marks[_]!==I[_]&&Oc(m,_);c.fontFamilyMixed||kc(m,c.fontFamily),c.fontColorMixed||ni(m,"color",c.fontColor),c.highlightColorMixed||ni(m,"backgroundColor",c.highlightColor),de(m,!1),z(),U()},[W,we,z,U]),Ll=l.useCallback((c,m)=>{if(B.current!=="visual")return;const w=F.current;if(!w)return;W(w),Ur(_=>({..._,open:!1}));let I=vh(w,c);if(m&&Yk(w,m)&&(I=!0),!I){z(),U();return}de(w,!1),z(),U()},[W,we,z,U]),pm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(rl(I=>({...I,open:!1})),!As(c)){z(),U();return}if(w.collapsed){Bn.current=c,It.current={start:w.start,end:w.end},U();return}if(Bn.current=null,!Yg(m,c)){z(),U();return}de(m,!1),z(),U()},[W,we,z,U]),Bl=l.useCallback(c=>{if(B.current!=="visual")return;const m=Uo();if(!m)return;W(m),fr($=>({...$,open:!1}));const w=qr(),I=JSON.stringify(c.atRule)!==JSON.stringify(ot(ye(w).body)),_=qc(m,c);if(I&&wo(m,_.pageHtml),!_.changed&&!I){z(),U();return}de(m,!1,_.pageHtml),z(),U()},[W,de,z,U,Uo,qr]),gm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Ui(w=>({...w,open:!1})),!IS(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),hm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),sl(w=>({...w,open:!1})),!_S(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),Ca=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Vi({open:!1}),!e1(m,c,H.current)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),wa=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Wi({open:!1}),!b0(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),bm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),zo({open:!1}),!_0(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),ym=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),cl({open:!1}),!jk(m,c)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),xm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),dl(w=>({...w,open:!1})),!cP(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),Cm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),fl(w=>({...w,open:!1})),!xP(m,c)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),wm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),gl(w=>({...w,open:!1})),!DP(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),An=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),!c(m)){z(),U();return}de(m,!1),z(),U(),cn(m)}},[W,we,z,U,cn]),Fl=l.useCallback(c=>{Ca({src:c.src,alt:c.alt??"",title:c.title??"",css:c.css})},[Ca]),Hl=l.useCallback(c=>{wa({src:c.src,title:c.title??"",css:c.css})},[wa]),zl=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),zo({open:!1}),!N0(m,{src:c.src,title:c.title??"",css:c.css})){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),vm=l.useCallback(c=>{if(B.current!=="visual")return;const m=F.current;if(m){if(W(m),Gi(w=>({...w,open:!1})),!b1(m,c)){z(),U();return}de(m,!1),z(),U()}},[W,we,z,U]),ry=l.useCallback((c,m)=>{ft!=null&&ft.isConnected&&oP(ft,c,m)},[ft]),oy=l.useCallback(()=>{const c=F.current;!c||!(ft!=null&&ft.isConnected)||(de(c,!1),ac(c,ft),z(),U())},[ft,we,z,U]),va=l.useCallback(()=>{if(B.current!=="visual"||!F.current)return le.current;const c=zt(F.current.innerHTML,ye(le.current).body);return Ta(c,Ra(c,le.current,Zr.current,{liveRoot:F.current}))},[]),ka=l.useCallback(()=>{if(xe.current){const c=Et(br());return le.current=c,We(c)}if(Lt.current){const c=B.current==="visual"?va():le.current;c!==le.current&&(le.current=c)}return We(le.current)},[br,We,va]),iy=l.useRef(-1),km=l.useCallback(()=>{if(!Lt.current&&$r.current)return $r.current;const c=Lt.current&&B.current==="visual"?va():le.current;return c!==le.current&&(le.current=c),$r.current=c,Lt.current=!1,c},[va]),Sm=l.useCallback(()=>{if(!Lt.current&&$r.current)return $r.current;const c=ht(),m=JSON.stringify(c);return $r.current=m,iy.current=mt.revision,Lt.current=!1,m},[ht,mt.revision]),ay=l.useCallback(()=>xe.current?Sm():km(),[Sm,km]);LP({onAutoSave:r?async c=>{Lt.current=!1;const m=xe.current?nn(JSON.parse(c)):We(c);return r(m)}:void 0,getHtml:ay}),l.useEffect(()=>()=>{var c;(c=H.current)==null||c.clear()},[]),l.useEffect(()=>{var m;if(!fe||e===void 0||pe)return;const c=Ae(e);(m=zr.current)==null||m.setStorageHtml(c),le.current=c,Ht(oe)||oe.syncExternal(c)},[pe,Ae,oe,fe,e]),l.useEffect(()=>{if(!fe||!pe||Ce===void 0||Lt.current)return;const c=Gn(Ce).map(w=>Ae(w));if(kr(c,Me.current))return;const m=mt.replacePages(c);if(le.current=m.joined,Me.current=m.pages,Ht(oe)&&oe.syncPages(m.pages),B.current==="html"){const w=m.pages[Te.current]??"";wn.current=w}},[pe,Ae,oe,fe,mt,Ce]),l.useEffect(()=>()=>{var c;(c=To.current)==null||c.cancel()},[]);const Ie=l.useMemo(()=>({getHtml:ka,setHtml:c=>{lt(c,!1)},getMode:()=>B.current,setMode:um,getFullscreen:()=>dd.current,setFullscreen:rn,getDarkMode:()=>Wd.current,setDarkMode:c=>{tm(c)},getPageZoom:()=>oa.current,setPageZoom:nm,getToolbarPosition:()=>Gd.current,setToolbarPosition:c=>{rm(c)},openCustomizeToolbar:()=>{wd(!0)},openDocumentPreview:()=>{vd({open:!0,html:We(Et(br()))})},openHelp:()=>{Oo({open:!0,topicId:"getStarted"})},openKeyboardShortcuts:()=>{Oo({open:!0,topicId:"keyboardShortcuts"})},openAbout:()=>{Sd(!0)},toggleReadAloud:()=>{const c=To.current;if(!c)return;const m=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),w=Af(Da(m),ka());w&&c.toggle(w)},toggleRuler:()=>{Ns(c=>!c)},isReadingAloud:()=>{var c;return((c=To.current)==null?void 0:c.isSpeaking())??!1},isRulerVisible:()=>Si.current,canReadAloud:()=>{if(!za())return!1;const c=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});return Af(Da(c),ka())!==null},undo:ba,redo:ya,canUndo:()=>oe.canUndo(),canRedo:()=>oe.canRedo(),getSelection:()=>{const c=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});return Da(c)},insertText:c=>{const m=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current});Wo(m,c,!1)},insertHtml:(c,m)=>{const w=Ge.current??un({mode:B.current,visualEl:F.current,htmlEl:gt.current}),I=m===void 0;Wo(w,I?c:m,I)},toggleFontMark:c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;const w=W(m);if(w.collapsed){const I=oo(m);Bt.current=Vv(Bt.current,I,c),It.current={start:w.start,end:w.end},U();return}Bt.current={},It.current=null,Oc(m,c)&&(de(m,!1),z(),U())},clearFormatting:()=>{if(B.current!=="visual")return;const c=F.current;!c||W(c).collapsed||(Bt.current={},Dt.current=null,Ft.current=null,Zt.current=null,qt.current=null,Bn.current=null,It.current=null,e0(c)&&(de(c,!1),z(),U()))},toggleFormatBrush:mm,isFormatBrushActive:()=>Bi.current,isFontMarkActive:c=>zs.current[c],hasTextSelection:()=>B.current==="visual"&&Xs.current,setFontSize:(c,m)=>{Ml(c,m)},setFontSizeUnit:c=>{var Y;const m=F.current,w=Fn.current;if(B.current!=="visual"||!m||w.value===null||w.mixed){kn.current=c,Mi(te=>({...te,unit:c}));return}const I=W(m),_=Ev(m,((Y=I.visualRange)==null?void 0:Y.startContainer)??m),$=Ap(w.value,w.unit,c,_.parentPx,_.rootPx);Ml($,c)},getFontSize:()=>Fn.current.value,getFontSizeUnit:()=>Fn.current.unit,isFontSizeMixed:()=>Fn.current.mixed,setFontFamily:c=>{fm(c)},getFontFamily:()=>jo.current.value,isFontFamilyMixed:()=>jo.current.mixed,getFontFaces:()=>Zr.current,setFontColor:c=>{_l("color",c)},setHighlightColor:c=>{_l("backgroundColor",c)},getFontColor:()=>Mo.current.value,isFontColorMixed:()=>Mo.current.mixed,getHighlightColor:()=>No.current.value,isHighlightColorMixed:()=>No.current.mixed,setParagraphStyle:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),mk(m,c)&&(de(m,!1),z(),U()))},getParagraphStyle:()=>Vs.current.tag,isParagraphStyleMixed:()=>Vs.current.mixed,setTextAlign:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),wh(m,c)&&(de(m,!1),z(),U()))},getTextAlign:()=>Gs.current.align,isTextAlignMixed:()=>Gs.current.mixed,indent:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),vk(c)&&(de(c,!1),z(),U()))},outdent:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),kk(c)&&(de(c,!1),z(),U()))},canOutdent:()=>B.current==="visual"&&hd.current,toggleList:c=>{if(B.current!=="visual")return;const m=F.current;m&&(W(m),gk(m,c)&&(de(m,!1),z(),U()))},isBulletList:()=>Lo.current.type==="ul"&&!Lo.current.mixed,isNumberedList:()=>Lo.current.type==="ol"&&!Lo.current.mixed,openFontProperties:c=>{B.current==="visual"&&Oi({open:!0,tab:c??"general"})},applyFontProperties:c=>{Nl(c)},openCustomCss:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=c?Zg(c):{value:null,mixed:!1},w=m.mixed||!m.value?"":Fv(m.value);rl({open:!0,value:w})},applyCustomCss:c=>{pm(c)},openParagraphProperties:c=>{if(B.current!=="visual")return;const m=F.current;m&&W(m),Ur({open:!0,tab:c??"general",value:m?Ma(m):Pr(),backgroundImage:m?cc(m):mn()})},applyParagraphProperties:(c,m)=>{Ll(c,m)},openPageProperties:(c,m)=>{if(B.current!=="visual")return;const w=Uo();w&&W(w);const I=qr(),_=w?Qo(w):ii();fr({open:!0,tab:c==="print"&&!en?"font":c??"font",paragraphTab:m??"spacing",value:{..._,atRule:ot(ye(I).body)}})},applyPageProperties:c=>{Bl(c)},openPageBackgroundImage:()=>{if(B.current!=="visual")return;const c=Uo();c&&W(c);const m=Sl.current;if(Pl.current&&m){m.onPick(_=>{const $=qr(),Y=c?Qo(c):ii();Bl({...Y,backgroundImage:{...Y.backgroundImage,src:_.src},atRule:ot(ye($).body)})});return}const w=qr(),I=c?Qo(c):ii();fr({open:!0,tab:"paragraph",paragraphTab:"backgroundImage",value:{...I,atRule:ot(ye(w).body)}})},openParagraphBackgroundImage:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Sl.current;if(Pl.current&&m){m.onPick(w=>{const I=c?Ma(c):Pr(),_=c?cc(c):mn();Ll(I,{..._,src:w.src})});return}Ur({open:!0,tab:"backgroundImage",value:c?Ma(c):Pr(),backgroundImage:c?cc(c):mn()})},openCustomParagraphStyleDialog:c=>{if(B.current!=="visual"||!vl.current)return;if(c){const w=na.current.find(I=>I.id===c);if(!w)return;Ho({open:!0,mode:"edit",style:w});return}const m=F.current;m&&W(m),Ho({open:!0,mode:"create",font:{size:Fn.current.mixed?null:Fn.current.value,unit:Fn.current.unit,marks:{...zs.current},fontFamily:jo.current.mixed?null:jo.current.value,fontColor:Mo.current.mixed?null:Mo.current.value,highlightColor:No.current.mixed?null:No.current.value},paragraph:kh(m?Ma(m):Pr())})},applyCustomParagraphStyle:c=>{const m=na.current.find(I=>I.id===c);if(!m||(Nl({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=F.current;!w||B.current!=="visual"||(W(w),Zk(w,m.paragraph)&&(de(w,!1),z(),U()))},customParagraphStylesEnabled:()=>vl.current,getCustomParagraphStyles:()=>na.current,isCustomParagraphStylesLoading:()=>Md.current,openLinkDialog:c=>{if(B.current!=="visual")return;const m=F.current;m&&W(m);const w=m?Th(m):Ds(),I=m?Xc(m):[],_=(w==null?void 0:w.href)??"",$=_.startsWith("#")?_.slice(1):"",Y=I.some(te=>te.id===$)?$:"";Ui({open:!0,tab:c??"link",href:_,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:I,selectedBookmarkId:Y})},applyLink:c=>{gm(c)},openBookmarkDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c),sl({open:!0,existingIds:c?Xc(c).map(m=>m.id):[]})},applyBookmark:c=>{hm(c)},openImageDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Hd.current;if(Zd.current&&m){m.onPick(Fl);return}Vi({open:!0})},applyImage:c=>{Ca(c)},openAudioDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Od.current;if(qd.current&&m){m.onPick(Hl);return}Wi({open:!0})},applyAudio:c=>{wa(c)},openYoutubeDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c);const m=Kd.current;if(Yd.current&&m){m.onPick(zl);return}zo({open:!0})},applyYoutube:c=>{bm(c)},openImageProperties:c=>{if(B.current!=="visual")return;const m=F.current;if(!m)return;W(m);const w=qn(m),I=h1(m);!w||!I||Gi({open:!0,tab:c??"general",value:I,aspectRatio:f1(w)})},applyImageProperties:c=>{vm(c)},insertHorizontalRule:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),G0(c)&&(de(c,!1),z(),U()))},insertPageBreak:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),J0(c)&&(de(c,!1),z(),U()))},insertPageBefore:()=>{am()},insertPageAfter:()=>{sm()},deletePage:()=>{!xe.current||B.current!=="visual"||Gt.current&&(br().length<=1||il(!0))},isMultiPagesEnabled:()=>xe.current,hasSelectedPage:()=>xe.current&&B.current==="visual"&&Gt.current,canDeletePage:()=>xe.current&&B.current==="visual"&&Gt.current&&br().length>1,canInsertPageBackgroundImage:()=>!(B.current!=="visual"||xe.current&&!Gt.current),canInsertParagraphBackgroundImage:()=>{if(B.current!=="visual")return!1;const c=F.current;return c?En(c).length>0:!1},getActivePageHtml:()=>fa(),getAllPagesHtml:()=>nn(br()),openTableDialog:()=>{if(B.current!=="visual")return;const c=F.current;c&&W(c),cl({open:!0})},applyTable:c=>{ym(c)},openTableProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=lP(c);m&&dl({open:!0,value:m})},applyTableProperties:c=>{xm(c)},openCellProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=yP(c);m&&fl({open:!0,value:m})},applyCellProperties:c=>{Cm(c)},openRowProperties:()=>{if(B.current!=="visual")return;const c=F.current;if(!c)return;W(c);const m=RP(c);m&&gl({open:!0,value:m})},applyRowProperties:c=>{wm(c)},insertRowBelow:()=>{An(c=>Uc(c,"below"))},insertRowBefore:()=>{An(c=>Uc(c,"before"))},deleteRow:()=>{An(c=>Ek(c))},insertColumnAfter:()=>{An(c=>pf(c,"after"))},insertColumnBefore:()=>{An(c=>pf(c,"before"))},deleteColumn:()=>{An(c=>Mk(c))},mergeCells:()=>{An(c=>Lk(c))},unmergeCells:()=>{An(c=>Bk(c))},cut:async()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),await qS(c)&&(de(c,!1),z(),U()))},copy:async()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),await Nh(c))},deleteSelection:()=>{if(B.current!=="visual")return;const c=F.current;c&&(W(c),_h(c)&&(de(c,!1),z(),U()))},addComment:()=>{if(!Ln.current||b||B.current!=="visual")return;const c=F.current;if(!c)return;const m=W(c),w=Sf(c,m);if(w){on(w);return}const I=FS(c,m);if(!I)return;const _=$S(I);HS(c,_.id,m)&&(Pf(c,_.id),z(),im(c,!1),cr([...Ri.current,_]),on(_.id))},toggleCommentsVisible:()=>{_s(c=>{const m=!c,w=F.current;return w&&jh(w,m),m})},areCommentsVisible:()=>Ti.current,canAddComment:()=>!Ln.current||b||B.current!=="visual"?!1:Xs.current||wl.current!==null,isCommentsEnabled:()=>Ln.current,getCommentThreads:()=>Ri.current,setCommentThreads:c=>cr(c),openCommentThread:c=>{const m=F.current;!m||B.current!=="visual"||Pf(m,c)&&(z(),on(c))},isContentLocked:()=>rd.current,isLink:()=>Cd.current,isImageSelected:()=>B.current==="visual"&&wl.current!==null,isInTable:()=>B.current==="visual"&&Td.current,canMergeCells:()=>B.current==="visual"&&Dd.current,canUnmergeCells:()=>B.current==="visual"&&jd.current,...o!=null?{onSave:c=>Bd.current(c)}:{},...a!=null?{onOpen:()=>Fd.current()}:{}}),[lt,we,de,im,um,rn,tm,nm,rm,Wo,ba,ya,z,U,W,Ml,fm,_l,Nl,pm,Ll,Bl,gm,hm,Ca,wa,bm,vm,ym,xm,Cm,wm,An,Fl,Hl,zl,ka,fa,br,am,sm,lm,mm,o,a,b,cr,en]),Ol=l.useCallback((c,m,w,I)=>{const{activePageIndexAtCapture:_,pageHtmlAtCapture:$,selectedHtmlAtCapture:Y}=I;if(c.mode==="visual"){let te=F.current;if(xe.current){const ge=dt.current;ge==null||ge.ensurePageMounted(_);const he=ge==null?void 0:ge.getContainer();te=he?qe(he,_):te}if(te){F.current=te;const ge=lC(te,c,Y);if(ge&&!ge.collapsed){cC(ge,m,w);const Fe=xe.current?$??Me.current[_]??"":le.current;Vo(zt(ye(te.innerHTML).body,ye(Fe).body),!1);return}te.focus({preventScroll:!0});const he=ci(te,c),Be=he!==null?{...c,visualRange:he.cloneRange()}:c;$m({snapshot:Be,visualEl:te,htmlEl:gt.current,getHtml:()=>B.current==="visual"&&te?te.innerHTML:le.current,setHtml:Fe=>{if(B.current==="visual"){const nt=xe.current?Me.current[_]??"":le.current;Vo(zt(ye(Fe).body,ye(nt).body),!1);return}lt(Fe,!1)},content:m,asHtml:w});return}}Wo(c,m,w)},[Wo,Vo,lt]),Pm=l.useCallback(()=>{vn.current!==null&&(window.cancelAnimationFrame(vn.current),vn.current=null,z()),xa()},[z,xa]),Am=l.useCallback(()=>{var Be,Fe;const c=iC({stored:Ge.current,mode:B.current,visualEl:F.current,htmlEl:gt.current}),m={...c,visualRange:((Be=c.visualRange)==null?void 0:Be.cloneRange())??null};Ge.current=m;const w=xe.current?Te.current:0,I=c.mode==="visual"&&xe.current?fa():null,_=((Fe=F.current)==null?void 0:Fe.innerHTML)??"",$=I?Xt(ye(I).body):_,Y=(()=>{if(c.mode==="html"){const yr=Ie.getHtml(),Tn=Math.min(c.start,c.end),Jr=Math.max(c.start,c.end);return yr.slice(Tn,Jr)}const nt=F.current;return nt&&uC(nt,m)||c.text})(),te=c.mode==="visual"&&xe.current&&!c.collapsed&&Y?aC($,_,Y):null,ge=te&&xe.current?{pageIndex:w,start:te.start,end:te.end,pageBodyAtCapture:$}:null,he={activePageIndexAtCapture:w,pageHtmlAtCapture:I,selectedHtmlAtCapture:Y};return{mode:m.mode,selection:Da(m),getHtml:Ie.getHtml,getSelectedHtml:()=>Y,getPinnedPageBodySelection:()=>ge,setHtml:nt=>{lt(nt,!1)},insertText:nt=>Ol(m,nt,!1,he),insertHtml:(nt,yr)=>{const Tn=yr===void 0;Ol(m,Tn?nt:yr,Tn,he)}}},[Ol,Ie.getHtml,fa,lt]),{catalog:Sa,layout:Tm}=l.useMemo(()=>fx(V,bD,yD),[V]),Pa=l.useMemo(()=>AA(Tm,L),[Tm,L]),Rm=l.useMemo(()=>({...Pa,iconGroups:QP(Pa.iconGroups,Qs)}),[Pa,Qs]),Dm=pe&&st==="visual",Kl=l.useMemo(()=>ND(Rm,Dm),[Rm,Dm]),$l=l.useMemo(()=>De?vD(Sa,_n):Sa,[Sa,De,_n]),Ul=l.useMemo(()=>De?kD(Kl):Kl,[Kl,De]),Vl=l.useMemo(()=>({disabled:tn,readOnly:C,enableComments:De}),[tn,C,De]),sy=l.useCallback(c=>{if(!Nn||!xn||b)return;const m=US(xn,c);cr(VS(Ri.current,Nn,m))},[Nn,xn,b,cr]),Xr=l.useMemo(()=>({...Tv(Ie),...px(V,Am,Pm)}),[Ie,V,Am,Pm]),Wl=l.useMemo(()=>Rv(Ie),[Ie,Ro,Do,Io,Eo,_o,_i,Yi,Xi,ra,Gr,ft,Qi,ea,ta,Ni,Li,Hn,Vr,Ko,Ao,ad,Tt]);l.useLayoutEffect(()=>{Rt.bump("history")},[ad,Rt]),l.useLayoutEffect(()=>{Rt.bump("marks")},[Ro,Do,Io,Eo,_o,_i,Li,Rt]),l.useLayoutEffect(()=>{Rt.bump("table")},[Qi,ea,ta,Rt]),l.useLayoutEffect(()=>{Rt.bump("selection")},[Ni,ft,Rt]),l.useLayoutEffect(()=>{Rt.bump("chrome")},[Hn,Vr,Ko,Ao,Tt,Yi,Xi,ra,Gr,Rt]);const ly=l.useCallback(c=>{if(ve||c.inputType!=="insertText"&&c.inputType!=="insertReplacementText"||!c.data||!Uv(Bt.current)&&!Dt.current&&!Vx(Ft.current)&&!vC({color:Zt.current,backgroundColor:qt.current})&&!Ov(Bn.current))return;const m=F.current;m&&(c.preventDefault(),ek(m,c.data,Bt.current,Dt.current,{color:Zt.current,backgroundColor:qt.current},Ft.current,Bn.current),Bt.current={},Dt.current=null,Ft.current=null,Zt.current=null,qt.current=null,Bn.current=null,It.current=null,de(m,!0),z(),U())},[ve,we,z,U]),cy=l.useCallback(c=>{var ge;if(ve||!Dx(c,Ed.current))return;c.preventDefault(),c.stopPropagation();let m=F.current;if(xe.current){const he=c.currentTarget instanceof HTMLElement&&c.currentTarget.hasAttribute(Dr)?c.currentTarget:Iw(c.target);if(he instanceof HTMLElement){const Be=Ym(he);Be!==null&&((ge=dt.current)==null||ge.activatePageAt(Be),F.current=he,m=he,Gt.current=!0,mr(!0))}}else c.currentTarget instanceof HTMLDivElement&&(F.current=c.currentTarget,m=c.currentTarget);if(!m)return;W(m);const w=Nc(m,c.target),I=is(m,c.target);I&&!wi(m).includes(I)&&Nk(m,I);const _={inTable:wt(m,c.target)!==null,canMergeCells:gf(m),canUnmergeCells:hf(m)},$={canDeletePage:xe.current&&Gt.current&&ht().length>1},Y={canAddComment:Ln.current&&!b};if(w){ac(m,w),z(),Wr(w),Cl({open:!0,x:c.clientX,y:c.clientY,kind:"image",..._,...$,...Y,inTable:wt(m,w)!==null});return}const te=un({mode:"visual",visualEl:m,htmlEl:gt.current});Ge.current=te,Cl({open:!0,x:c.clientX,y:c.clientY,kind:te.collapsed?"caret":"text",..._,...$,canAddComment:Y.canAddComment&&!te.collapsed})},[ve,z,W,ht,b,mr]),uy=l.useCallback(c=>{if(Ed.current=c.pointerType,b)return;const m=F.current;if(!m)return;if(Ln.current&&Ti.current){const I=Eh(m,c.target);if(I){const _=I.getAttribute("data-comment-thread");_&&on(_);return}}if(ve&&!Ln.current)return;const w=Nc(m,c.target);if(!w){Wr(null);return}c.preventDefault(),ac(m,w),z(),Wr(w)},[b,ve,z]),Im=l.useCallback(c=>{if(ve)return;if(c.key==="Tab"&&!c.ctrlKey&&!c.metaKey&&!c.altKey){if(B.current!=="visual")return;const w=F.current;if(!w)return;const I=c.target;if(!(I instanceof Node)||!w.contains(I))return;W(w);const _=_k(w,c.shiftKey);if(!_)return;c.preventDefault(),typeof _=="object"&&_.changed&&de(w,!1),z(),U(),cn(w);return}if(!(c.ctrlKey||c.metaKey))return;if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),Ie.insertPageBreak();return}const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),ba();return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),ya();return}if(m==="b"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("bold");return}if(m==="i"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("italic");return}if(m==="u"&&!c.shiftKey){c.preventDefault(),Ie.toggleFontMark("underline");return}if(m==="x"&&c.shiftKey){c.preventDefault(),Ie.toggleFontMark("strikethrough");return}m==="p"&&!c.shiftKey&&(c.preventDefault(),Xr.print())},[ve,ba,ya,Ie,Xr,W,we,z,U,cn]),dy=l.useCallback(c=>{if(c.key==="F1"){c.preventDefault(),Oo({open:!0,topicId:"getStarted"});return}if(c.key==="Escape"&&Nn){c.preventDefault(),on(null);return}Im(c)},[Nn,Im]),my=[ke.root,wc(Hn).className,Tt?ke.fullscreen:"",x].filter(Boolean).join(" "),fy=p_({dark:Hn,toolbarBackground:k,workspaceBackground,menuColor:S,menuBackground:A,menuFontSize:R,menuFontFamily:T,border:D}),py=wc(Hn)["data-wysiwyg-theme"];id.current={multiPageVisualRef:dt,workspaceRef:ur,suppressPageFlushRef:dr,pendingInsertPageFocusRef:Ai,visualRootRef:F,visualPropSyncGuardRef:Nt,htmlAreaRef:gt,commentPanelRef:Pi,activePageIndexRef:Te,htmlModePageHtmlRef:wn,setHtmlModePageHtml:()=>{},activePageHtmlRef:cd,pageCanvasSizedRef:ud,setActivePageIndex:Po,setHasSelectedPage:mr,setActiveThreadId:on,setContextMenu:Cl,recordVisualInputHtml:Gb,recordPageVisualHtml:gr,handleVisualBeforeInput:ly,handleVisualPointerDown:uy,handleVisualMouseUp:ny,handleVisualContextMenu:cy,handleHtmlPageTabSelect:ey,handleHtmlSurfaceChange:ty,handleImageResize:ry,handleImageResizeEnd:oy,multiPageRulerMarginPreview:Xb,multiPageRulerMarginChange:Jb,multiPageRulerIndentChange:Qb,singlePageRulerMarginPreview:Zb,singlePageRulerMarginChange:qb,singlePageRulerIndentChange:Yb,resolveEmbeddedImageDataUrl:fe?Es:void 0,hydrateExportHtml:We,postCommentMessage:sy,htmlFileDrop:om};const gy=l.useMemo(()=>Db({catalog:$l,layout:Ul,commands:Xr,queries:Wl,queryRevisions:Rt,disabled:tn,chromeLock:Vl}),[tn,Vl,Xr,$l,Ul,Wl,Rt]),hy=l.useMemo(()=>({documentBridgeRef:zr,htmlRef:le,pagesRef:Me}),[]);return i.jsx(wx,{locale:v,children:i.jsx(yx,{dark:Hn,children:i.jsx(AM,{value:hy,children:i.jsxs("div",{className:my,style:fy,"data-fullscreen":Tt?"":void 0,"data-wysiwyg-theme":py,"data-toolbar-position":Vr,"data-comments-visible":De&&_n?"":void 0,onKeyDown:dy,children:[i.jsx(SM,{menuVisible:P,captureChromeSelection:xa,displayCatalog:$l,displayLayout:Ul,commands:Xr,queries:Wl,queryRevisions:Rt,chromeDisabled:tn,chromeLock:Vl,contentLocked:ve,customizeToolbarOpen:Js,baseCatalog:Sa,allowedLayout:Pa,toolbarSettings:Qs,toolbarSettingsLoading:Mb,toolbarSettingsBusy:_b,onCustomizeToolbarClose:()=>wd(!1),onToolbarSettingsChange:c=>{em(c)},onToolbarSettingsReset:()=>{em(null)},documentPreview:Ki,onDocumentPreviewClose:()=>vd({open:!1,html:Ki.html}),helpDialog:hl,onHelpDialogClose:()=>Oo(c=>({...c,open:!1})),onHelpTopicChange:c=>Oo(m=>({...m,open:!0,topicId:c})),aboutDialogOpen:bl,onAboutDialogClose:()=>Sd(!1),fontDialog:zi,fontSizeState:Do,markState:Ro,fontFamilyState:Io,fontColorState:Eo,highlightColorState:_o,fontFaces:Gr,onFontDialogTabChange:c=>Oi({open:!0,tab:c}),onFontDialogClose:()=>Oi({open:!1,tab:zi.tab}),onApplyFontProperties:c=>Ie.applyFontProperties(c),paragraphDialog:Bo,customBackgroundImagePicker:Sn,disableBuiltinBackgroundImageSources:kl,onParagraphCustomImagePick:()=>{Sn==null||Sn.onPick(c=>{Ur(m=>({...m,tab:"backgroundImage",backgroundImage:{...m.backgroundImage,src:c.src}}))})},onParagraphDialogTabChange:c=>Ur({...Bo,open:!0,tab:c}),onParagraphDialogClose:()=>Ur({...Bo,open:!1}),onApplyParagraphProperties:({value:c,backgroundImage:m})=>Ie.applyParagraphProperties(c,m),customCssDialog:nl,onCustomCssDialogClose:()=>rl(c=>({...c,open:!1})),onApplyCustomCss:c=>Ie.applyCustomCss(c),pageDialog:Fo,enablePageProperties:en,onPageCustomImagePick:()=>{Sn==null||Sn.onPick(c=>{fr(m=>({...m,tab:"paragraph",paragraphTab:"backgroundImage",value:{...m.value,backgroundImage:{...m.value.backgroundImage,src:c.src}}}))})},onPageDialogTabChange:c=>fr({...Fo,open:!0,tab:c}),onPageDialogClose:()=>fr({...Fo,open:!1}),onApplyPageProperties:c=>Ie.applyPageProperties(c),onPageDialogResetAtRule:()=>{const c=Uo();if(!c||B.current!=="visual")return;const m=xe.current?qr():ye(le.current).body,w=cS(c,m);w.changed&&(de(c,!1,w.pageHtml),fr(I=>({...I,value:{...I.value,atRule:Wn()}})))},deletePageConfirmOpen:ol,onDeletePageConfirmClose:()=>il(!1),onDeletePageConfirm:()=>{lm(),il(!1)},customStyleDialog:Nb,canDeleteCustomParagraphStyle:!!ae,customStyleBusy:Kb,onCustomStyleDialogClose:()=>Ho({open:!1}),onCustomStyleSave:async c=>{const m=Nd.current;if(m){Ji(!0);try{await m(c),Ho({open:!1}),await ua()}finally{Ji(!1)}}},onCustomStyleDelete:async c=>{const m=Ld.current;if(m){Ji(!0);try{await m(c),Ho({open:!1}),await ua()}finally{Ji(!1)}}},linkDialog:al,onLinkDialogTabChange:c=>Ui({...al,open:!0,tab:c}),onLinkDialogClose:()=>Ui({...al,open:!1}),onApplyLink:c=>Ie.applyLink(c),bookmarkDialog:kd,onBookmarkDialogClose:()=>sl({...kd,open:!1}),onApplyBookmark:c=>Ie.applyBookmark(c),imageDialogOpen:Lb.open,customImagePicker:q,customAudioPicker:M,customVideoPicker:O,onImageDialogClose:()=>Vi({open:!1}),onApplyImage:c=>Ie.applyImage(c),onImageDialogCustomPick:()=>{Vi({open:!1}),q==null||q.onPick(Fl)},audioDialogOpen:Bb.open,onAudioDialogClose:()=>Wi({open:!1}),onApplyAudio:c=>Ie.applyAudio(c),onAudioDialogCustomPick:()=>{Wi({open:!1}),M==null||M.onPick(Hl)},youtubeDialogOpen:Fb.open,onYoutubeDialogClose:()=>zo({open:!1}),onApplyYoutube:c=>Ie.applyYoutube(c),onYoutubeDialogCustomPick:()=>{zo({open:!1}),O==null||O.onPick(zl)},imageProperties:Hb,onImagePropertiesTabChange:c=>Gi(m=>({...m,tab:c})),onImagePropertiesClose:()=>Gi(c=>({...c,open:!1})),onApplyImageProperties:c=>Ie.applyImageProperties(c),tableDialogOpen:ll.open,onTableDialogClose:()=>cl({open:!1}),onApplyTable:c=>Ie.applyTable(c),tableProperties:ul,onTablePropertiesClose:()=>dl(c=>({...c,open:!1})),onApplyTableProperties:c=>Ie.applyTableProperties(c),cellProperties:ml,onCellPropertiesClose:()=>fl(c=>({...c,open:!1})),onApplyCellProperties:c=>Ie.applyCellProperties(c),rowProperties:pl,onRowPropertiesClose:()=>gl(c=>({...c,open:!1})),onApplyRowProperties:c=>Ie.applyRowProperties(c)}),i.jsx(PM,{toolbarVisible:j,toolbarPos:Vr,captureChromeSelection:xa,toolbarShellProps:gy,children:i.jsx(d_,{propsRef:id,pageStore:mt,mode:st,enableMultiPages:pe,contentLocked:ve,activePageIndex:Or,hasSelectedPage:Ao,pageZoomScale:yl,rulerVisible:ko,rulerUnit:Wt,optimizeEmbeddedImages:fe,placeholder:y,value:e,pagesProp:Ce,controlledHtml:Cn,initialHtml:Ne,initialStorageHtml:Ms,defaultPages:J.current??[Un()],ingestedPagesProp:od,onChange:n,fontFaces:Gr,enableComments:De,commentsVisible:_n,disabled:b,locale:v,commentAuthor:xn,activeThreadId:Nn,contextMenu:$b,commentThreads:So,commands:Xr,htmlFileDropDragging:om.dragging,selectedImage:ft})}),Tt?i.jsx(g_,{onClick:()=>rn(!1)}):null]})})})})}function p_({dark:e,toolbarBackground:t,workspaceBackground:n,menuColor:r,menuBackground:o,menuFontSize:a,menuFontFamily:s,border:u}){const d={};return n&&(d["--wysiwyg-workspace-background"]=n),e||(t&&(d["--wysiwyg-toolbar-background"]=t),r&&(d["--wysiwyg-menu-color"]=r),o&&(d["--wysiwyg-menu-background"]=o)),a&&(d["--wysiwyg-menu-font-size"]=a),s&&(d["--wysiwyg-menu-font-family"]=s),u==="none"?(d["--wysiwyg-border-width"]="0",d["--wysiwyg-border-radius"]="0",d["--wysiwyg-border-shadow"]="none"):u&&(u.width&&(d["--wysiwyg-border-width"]=u.width),u.color&&(d["--wysiwyg-border-color"]=u.color),u.radius&&(d["--wysiwyg-border-radius"]=u.radius),u.shadow&&(d["--wysiwyg-border-shadow"]=u.shadow)),Object.keys(d).length?d:void 0}function g_({onClick:e}){const t=X();return i.jsx("button",{type:"button",className:ke.exitFullscreen,"aria-label":t("exitFullscreenAria"),onClick:e,children:i.jsx(Qe,{className:ke.exitFullscreenIcon})})}function h_(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)===ct?!0:t.length===2&&t.some(r=>r.name===ct)&&t.some(r=>r.name==="class"&&r.value.includes("wysiwyg-comment-anchor"))?!e.hasAttribute("style"):!1}function b_(e){for(const t of[...e.querySelectorAll(`[${ct}]`)])t.removeAttribute(ct),t instanceof HTMLElement&&t.classList.remove("wysiwyg-comment-anchor");for(const t of[...e.querySelectorAll("span")]){if(!h_(t))continue;const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);n.removeChild(t)}}}function y_(e){const t=e.trim();if(!t)return e;const n=new DOMParser().parseFromString(t,"text/html");return b_(n.body),n.body.innerHTML}exports.Editor=f_;exports.PAGE_SEPARATOR=Ya;exports.joinPagesToHtml=Et;exports.sanitizeDocumentHtml=to;exports.sanitizePageHtml=Yc;exports.splitPagesFromHtml=Zn;exports.stripCommentAnchors=y_;