commspliant-html-editor 0.0.2 → 0.0.3
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/commspliant-html-editor.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,6 @@ img {
|
|
|
87
87
|
height: auto;
|
|
88
88
|
vertical-align: middle;
|
|
89
89
|
}
|
|
90
|
-
`.trim();function Zo(e,t,n=""){const{hrefs:r,body:i}=vn(t),a=e.createElement("meta");a.setAttribute("charset","utf-8");const l=e.createElement("title");l.textContent=n;const c=e.createElement("style");c.textContent=jd;const m=r.map(p=>{const b=e.createElement("link");return b.rel="stylesheet",b.href=p,b});e.head.replaceChildren(a,l,c,...m),e.title=n,e.body.innerHTML=i}const Ed=1e3;function Td(e){const t=document.createElement("iframe");t.setAttribute("aria-hidden","true"),t.setAttribute("data-wysiwyg-print",""),t.style.position="fixed",t.style.right="0",t.style.bottom="0",t.style.width="0",t.style.height="0",t.style.border="0",document.body.append(t);const n=t.contentDocument,r=t.contentWindow;if(!n||!r){t.remove();return}Zo(n,e);let i=!1;const a=()=>{i||(i=!0,t.remove())};r.addEventListener("afterprint",a),r.focus(),r.print(),window.setTimeout(a,Ed)}function Nd(e){return{save:async()=>{await ld(e.getHtml())},open:async()=>{const t=await sd();t!==null&&e.setHtml(t)},print:()=>{Td(e.getHtml())}}}function Ld(e){return{toggleBold:()=>{e.toggleFontMark("bold")},toggleItalic:()=>{e.toggleFontMark("italic")},toggleUnderline:()=>{e.toggleFontMark("underline")},toggleStrikethrough:()=>{e.toggleFontMark("strikethrough")},clearFormatting:()=>{e.clearFormatting()},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)}}}function Md(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(),customParagraphStylesEnabled:()=>e.customParagraphStylesEnabled(),getCustomParagraphStyles:()=>e.getCustomParagraphStyles(),isCustomParagraphStylesLoading:()=>e.isCustomParagraphStylesLoading()}}function Rd(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function _d(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function Id(e){return{openLinkDialog:t=>{e.openLinkDialog(t)},applyLink:t=>{e.applyLink(t)},openBookmarkDialog:()=>{e.openBookmarkDialog()},applyBookmark:t=>{e.applyBookmark(t)},openImageDialog:()=>{e.openImageDialog()},applyImage:t=>{e.applyImage(t)},openImageProperties:t=>{e.openImageProperties(t)},applyImageProperties:t=>{e.applyImageProperties(t)},insertHorizontalRule:()=>{e.insertHorizontalRule()}}}function Fd(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected()}}function Bd(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()}}}function Hd(e){return{isInTable:()=>e.isInTable()}}function zd(e){return{setVisualMode:()=>{e.setMode("visual")},setHtmlMode:()=>{e.setMode("html")},toggleFullscreen:()=>{e.setFullscreen(!e.getFullscreen())},openCustomizeToolbar:()=>{e.openCustomizeToolbar()},openDocumentPreview:()=>{e.openDocumentPreview()},setLightMode:()=>{e.setDarkMode(!1)},setDarkMode:()=>{e.setDarkMode(!0)},setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function Od(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isToolbarPositionTop:()=>e.getToolbarPosition()==="top",isToolbarPositionLeft:()=>e.getToolbarPosition()==="left",isToolbarPositionRight:()=>e.getToolbarPosition()==="right",isToolbarPositionBottom:()=>e.getToolbarPosition()==="bottom"}}function Kd(e){return{...Nd(e),...Rd(e),...zu(e),...Id(e),...Bd(e),...zd(e),...Ld(e)}}function $d(e){return{...Od(e),..._d(e),...Fd(e),...Hd(e),...Md(e)}}const Ci=["pt","px","em","rem","%"],Ct="pt",Ud={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]},Wd={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},Gd=new Set(Ci),Vd=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function Tr(e){return Gd.has(e)}function ve(e){return Math.round(e*100)/100}function J(e){const t=ve(e);return Number.isInteger(t),String(t)}function ki(e,t){return`${J(e)}${t}`}function Di(e){const t=e.trim();if(!t)return null;const n=t.match(Vd);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return{value:r,unit:i}}function qd(e,t){const n=e.trim();if(!n)return null;const r=Di(n);if(r)return Tr(r.unit)?kt(r.value,r.unit):null;const i=Number(n.replace(",","."));return Number.isFinite(i)?kt(i,t):null}function kt(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Wd[t];return{value:ve(Math.min(r,Math.max(n,e))),unit:t}}function ds(e,t,n,r){const i=n>0?n:16,a=r>0?r:16;switch(t){case"px":return ve(e);case"pt":return ve(e*.75);case"em":return ve(e/i);case"rem":return ve(e/a);case"%":return ve(e/i*100)}}function Xd(e,t,n,r){const i=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*i;case"rem":return e*a;case"%":return e/100*i}}function ms(e,t,n,r,i){if(t===n)return ve(e);const a=Xd(e,t,r,i);return ds(a,n,r,i)}function gr(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Yd(e){const t=e.style.fontSize;if(!t)return null;const n=Di(t);return!n||!Tr(n.unit)?null:{value:n.value,unit:n.unit}}function fs(e,t){let n=gr(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Yd(n);if(r)return r;n=n.parentElement}return null}function Jd(e,t){const n=gr(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function ps(e,t){var a;let n=gr(t);for(;n&&n!==e;){if(n.style.fontSize){const c=n.parentElement??e,m=parseFloat(getComputedStyle(c).fontSize);return Number.isFinite(m)&&m>0?m:16}n=n.parentElement}const r=((a=gr(t))==null?void 0:a.parentElement)??e,i=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(i)&&i>0?i:16}function hs(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function Zd(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function Ga(e=Ct){return{value:null,unit:e,mixed:!1}}function Qd(e,t=Ct){const n=window.getSelection();if(!n||n.rangeCount===0)return Ga(t);const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer))return Ga(t);const i=r.collapsed?[]:Be(r).filter(p=>p.data.length>0),a=i.length>0?i:[r.startContainer],l=a.map(p=>fs(e,p)),c=l[0];if(l.every(p=>Zd(p,c))&&c)return{value:c.value,unit:c.unit,mixed:!1};if(l.every(p=>p===null)){const p=a.map(h=>Jd(h,e)),b=p[0];if(p.every(h=>Math.abs(h-b)<.05)){const h=ps(e,a[0]),w=hs(e);return{value:ds(b,t,h,w),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function em(e,t){return{parentPx:ps(e,t),rootPx:hs(e)}}function tm(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function Va(e,t,n){const r=kt(t,n);if(!r)return!1;const i=tm(e);if(!i||i.collapsed)return!1;const a=ki(r.value,r.unit);ut(i);const l=Be(i).filter(c=>c.data.length>0);for(const c of l){const m=fs(e,c);m&&m.value===r.value&&m.unit===r.unit||Ar(c,p=>{p.style.fontSize=a})}return Ut(l),!0}function nm(e,t){e.style.fontSize=ki(t.value,t.unit)}function rm(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Ro(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]),i=Number(t[3]),a=t[4]===void 0?1:Number(t[4]);return[n,r,i,a].every(l=>Number.isFinite(l))?{r:n,g:r,b:i,a}:null}function _o(e,t,n){const r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Io(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 om={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 im(e){const t=e.trim().toLowerCase();return t===""||t==="transparent"||t==="inherit"||t==="initial"||t==="unset"||t==="currentcolor"||t==="currentColor"}function me(e){const t=e.trim();if(!t||im(t))return null;const n=Io(t);if(n)return n;const r=Ro(t);if(r)return r.a===0?null:_o(r.r,r.g,r.b);const i=om[t.toLowerCase()];if(i)return i;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 m=Io(t);if(m==="#010203")return m;const p=Ro(t);return p&&_o(p.r,p.g,p.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(l.startsWith("#"))return Io(l);const c=Ro(l);return!c||c.a===0?null:_o(c.r,c.g,c.b)}function gs(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?me(n):null}function br(e,t,n){let r=rm(t);for(;r&&r!==e&&r instanceof HTMLElement;){const i=gs(r,n);if(i)return i;r=r.parentElement}return null}function yr(e,t){return e instanceof HTMLElement?gs(e,t)!==null:!1}function Pi(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function bs(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function am(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!yr(i,n)){r=i;continue}if(pt(i,r),yr(i,n)&&(Pi(i,n),Dt(i))){_e(i);continue}r=i}}function ys(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function qa(e,t){const n=ys(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:Be(n).filter(m=>m.data.length>0),a=(r.length>0?r:[n.startContainer]).map(m=>br(e,m,t)),l=a[0]??null;return a.every(m=>m===l)?{value:l,mixed:!1}:{value:null,mixed:!0}}function Fo(e,t,n){const r=ys(e);if(!r||r.collapsed)return!1;const i=n===null?null:me(n);if(n!==null&&i===null)return!1;ut(r);const a=Be(r).filter(l=>l.data.length>0);for(const l of a){const c=br(e,l,t);if(i===null){if(c===null)continue;am(e,l,t);continue}c!==i&&Ar(l,m=>{bs(m,t,i)})}return Ut(a),!0}function Xa(e,t,n){if(n.value===null){Pi(e,t);return}const r=me(n.value);r&&bs(e,t,r)}function lm(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function sm(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 i=r.splitText(n);e.setStart(i,0),e.collapse(!0)}function cm(e){var r,i,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(i=e.startContainer.parentNode)==null||i.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 xs(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!n.some(a=>yr(i,a))){r=i;continue}pt(i,r);for(const a of n)yr(i,a)&&Pi(i,a);if(Dt(i)){_e(i);continue}r=i.isConnected?i:t}return t}function um(e,t,n){sm(t);const r=cm(t);return xs(e,r,n)}function dm(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&br(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&br(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const Ue=["bold","italic","underline","strikethrough"],Mt={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},mm=new Set(["underline","line-through","overline"]);function Qe(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function fm(e,t){return Ue.every(n=>e[n]===t[n])}function pm(e){return Ue.some(t=>e[t]!==void 0)}function ws(e,t){const n={...e};if(!t)return n;for(const r of Ue){const i=t[r];i!==void 0&&(n[r]=i)}return n}function hm(e,t,n){const r=e[n]??t[n],i={...e,[n]:!r};return i[n]===t[n]&&delete i[n],i}function dt(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>mm.has(n))}function Ft(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 vs(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(Mt.bold.has(r))return!0;const l=n.style.fontWeight;if(!l)return null;if(l==="bold"||l==="bolder")return!0;const c=Number(l);return Number.isNaN(c)?l==="normal"||l==="lighter"?!1:null:c>=700}if(t==="italic"){if(Mt.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(Mt.underline.has(r))return!0;const l=n.style.textDecorationLine||n.style.textDecoration;if(!l)return null;if(l==="none")return!1;const c=dt(n);return c.includes("underline")?!0:c.length>0?!1:null}if(Mt.strikethrough.has(r))return!0;const i=n.style.textDecorationLine||n.style.textDecoration;if(!i)return null;if(i==="none")return!1;const a=dt(n);return a.includes("line-through")?!0:a.length>0?!1:null}function xr(e,t){return vs(e,t)===!0}function Bt(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const i=vs(r,n);if(i!==null)return i;r=r.parentElement}return!1}function Ss(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=dt(e);r.includes("underline")||r.push("underline"),Ft(e,r);return}const n=dt(e);n.includes("line-through")||n.push("line-through"),Ft(e,n)}function Cs(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"){Ft(e,dt(e).filter(n=>n!=="underline"));return}Ft(e,dt(e).filter(n=>n!=="line-through"))}function gm(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=dt(e).filter(i=>i!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}Ft(e,r);return}const n=dt(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}Ft(e,n)}function bm(e,t){Ar(e,n=>Ss(n,t))}function ym(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!xr(i,n)){r=i;continue}if(pt(i,r),xr(i,n)){if(Mt[n].has(i.tagName.toLowerCase())){_e(i);continue}if(Cs(i,n),Dt(i)){_e(i);continue}}r=i}}function xm(e,t,n){const r=Be(t).filter(i=>i.data.length>0);return r.length===0?Bt(e,t.startContainer,n):r.every(i=>Bt(e,i,n))}function wm(e,t,n,r){ut(t);const i=Be(t).filter(a=>a.data.length>0);for(const a of i)r?Bt(e,a,n)||bm(a,n):ym(e,a,n);Ut(i)}function or(e){const t=window.getSelection();if(!t||t.rangeCount===0)return Qe();const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return Qe();if(n.collapsed)return Qo(e,n);const r=Be(n).filter(a=>a.data.length>0);if(r.length===0)return Qo(e,n);const i=Qe();for(const a of Ue)i[a]=Bt(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const l of Ue)i[l]=i[l]&&Bt(e,r[a],l);return i}function Qo(e,t){const n=Qe();for(const r of Ue)n[r]=Bt(e,t.startContainer,r);return n}function Ya(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer)||r.collapsed)return!1;const i=xm(e,r,t);return wm(e,r,t,!i),!0}function vm(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 i=r.splitText(n);e.setStart(i,0),e.collapse(!0)}function Sm(e,t,n){var a,l,c;vm(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 m=document.createTextNode("");(a=t.startContainer.parentNode)==null||a.insertBefore(m,t.startContainer.nextSibling),r=m}else if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0){const m=document.createTextNode("");(l=t.startContainer.parentNode)==null||l.insertBefore(m,t.startContainer),r=m}else{const m=document.createTextNode("");r&&r!==t.startContainer?(c=r.parentNode)==null||c.insertBefore(m,r):t.startContainer.appendChild(m),r=m}let i=r;for(;i.parentElement&&i.parentElement!==e;){const m=i.parentElement;if(!qe(m)){i=m;continue}if(!n.some(b=>xr(m,b))){i=m;continue}pt(m,i);for(const b of n)if(xr(m,b)){if(Mt[b].has(m.tagName.toLowerCase())){_e(m);break}if(Cs(m,b),Dt(m)){_e(m);break}}i=m.isConnected?m:r}return r}function Cm(e,t,n){for(const r of Ue)n[r]!==t[r]&&(n[r]?Ss(e,r):gm(e,r))}function km(e,t,n,r,i,a){var g,S;const l=window.getSelection();if(!l||l.rangeCount===0)return;const c=l.getRangeAt(0);if(!se(e,c.commonAncestorContainer))return;const m=Qo(e,c),p=ws(m,n),b=Ue.filter(A=>m[A]&&!p[A]),h=dm(e,c.startContainer,i),w=Ad(e,c.startContainer,a);let y=null;b.length>0?(y=Sm(e,c,b),h.length>0&&xs(e,y,h),w&&Jo(e,y)):h.length>0?(y=um(e,c,h),w&&Jo(e,y)):w?y=Pd(e,c):c.deleteContents();const v=document.createElement("span");Cm(v,m,p),r&&nm(v,r),i!=null&&i.color&&Xa(v,"color",i.color),i!=null&&i.backgroundColor&&Xa(v,"backgroundColor",i.backgroundColor),a&&Sd(v,a),v.textContent=t;const x=v.style.cssText.trim()?v:document.createTextNode(t);y?((g=y.parentNode)==null||g.insertBefore(x,y),y.nodeType===Node.TEXT_NODE&&!y.data&&((S=y.parentNode)==null||S.removeChild(y))):c.insertNode(x);const k=document.createRange();k.selectNodeContents(x),k.collapse(!1),l.removeAllRanges(),l.addRange(k)}const wr="data-page";function ks(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(wr)}function Ds(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function Dm(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function Dn(e){return Ds(e).find(n=>n.hasAttribute(wr))??null}function Pm(e){if(Dm(e))return null;const t=Ds(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"?null:n}function Am(e){const t=Dn(e);if(t)return t;const n=Pm(e);if(n)return n.setAttribute(wr,""),n;const r=document.createElement("div");for(r.setAttribute(wr,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),r}function Ai(e){return Dn(e)??e}function Ps(e){const t=Dn(e),n=(t==null?void 0:t.style.backgroundColor.trim())??"";n?e.style.backgroundColor=n:e.style.removeProperty("background-color")}function Ja(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function jm(e,t){return t?e===t||e.contains(t):!1}function Za(e,t){var a;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,i;for(;i=n.nextNode();){if(i===t||t.contains(i)||t.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING)return r;r+=((a=i.textContent)==null?void 0:a.length)??0}return r}function Qa(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return Za(e,t)+n;let r=0;const i=t.childNodes;for(let l=0;l<n&&l<i.length;l+=1)r+=((a=i[l].textContent)==null?void 0:a.length)??0;return Za(e,t)+r}function el(e,t){var l,c;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=Math.max(0,t),i,a=null;for(;i=n.nextNode();){a=i;const m=((l=i.textContent)==null?void 0:l.length)??0;if(r<=m)return{node:i,offset:r};r-=m}return a?{node:a,offset:((c=a.textContent)==null?void 0:c.length)??0}:{node:e,offset:e.childNodes.length}}function ji(e,t,n){const r=document.createRange(),i=el(e,t),a=el(e,n);return r.setStart(i.node,i.offset),r.setEnd(a.node,a.offset),r}function As(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function tl(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function Em(e,t){return t.mode!=="visual"?null:t.visualRange&&As(t.visualRange,e)?t.visualRange:ji(e,t.start,t.end)}function lt(e){var n;if(e.mode==="html"&&e.htmlEl){const r=e.htmlEl.selectionStart,i=e.htmlEl.selectionEnd;return{mode:"html",text:e.htmlEl.value.slice(r,i),collapsed:r===i,start:r,end:i,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(jm(t,a.commonAncestorContainer)){const l=Qa(t,a.startContainer,a.startOffset),c=Qa(t,a.endContainer,a.endOffset);return{mode:"visual",text:a.toString(),collapsed:a.collapsed,start:Math.min(l,c),end:Math.max(l,c),visualRange:a.cloneRange()}}}const i=((n=t.textContent)==null?void 0:n.length)??0;return{mode:"visual",text:"",collapsed:!0,start:i,end:i,visualRange:null}}return{mode:e.mode,text:"",collapsed:!0,start:0,end:0,visualRange:null}}function nl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Tm(e){if(e.snapshot.mode==="html"){const a=e.getHtml(),l=e.snapshot.start,c=e.snapshot.end,m=e.asHtml?e.content:nl(e.content);e.setHtml(a.slice(0,l)+m+a.slice(c));const p=e.htmlEl;if(p){const b=l+m.length;p.focus(),p.setSelectionRange(b,b)}return}const t=e.visualEl;if(!t){const a=e.asHtml?e.content:nl(e.content);e.setHtml(e.getHtml()+a);return}const r=(e.snapshot.visualRange&&As(e.snapshot.visualRange,t)?e.snapshot.visualRange:null)??ji(t,e.snapshot.start,e.snapshot.end);if(r.deleteContents(),e.content)if(e.asHtml){const a=r.createContextualFragment(e.content),l=a.lastChild;r.insertNode(a),l&&(r.setStartAfter(l),r.collapse(!0))}else{const a=document.createTextNode(e.content);r.insertNode(a),r.setStartAfter(a),r.collapse(!0)}const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r),e.setHtml(t.innerHTML)}const Ei=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),js=new Set(["table","thead","tbody","tr","td","th"]),Ti=new Set([...js,"ul","ol","li","pre","hr"]);function oe(e){return e.tagName.toLowerCase()}function Pn(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Ni(e){return e instanceof HTMLElement&&(oe(e)==="ul"||oe(e)==="ol")}function Ie(e){return e instanceof HTMLElement&&oe(e)==="li"}function ht(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function Li(e){const t=e.collapsed?[]:Be(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function Ht(e,t,n){var m,p,b;if(t.nodeType===Node.TEXT_NODE){const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let w=0,y;for(;y=h.nextNode();){if(y===t)return w+n;w+=((m=y.textContent)==null?void 0:m.length)??0}return w}let r=0;const i=t.childNodes;for(let h=0;h<n&&h<i.length;h+=1)r+=((p=i[h].textContent)==null?void 0:p.length)??0;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=0,c;for(;c=a.nextNode();){if(t.contains(c)||t.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)return l+r;l+=((b=c.textContent)==null?void 0:b.length)??0}return l+r}function Mi(e,t,n){const r=ji(e,t,n),i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r)}function Wt(e,t){const n=ht(e);if(!n)return!1;const r=Ht(e,n.startContainer,n.startOffset),i=Ht(e,n.endContainer,n.endOffset),a=Math.min(r,i),l=Math.max(r,i),c=t();return Mi(e,a,l),c}function Ri(e,t){if(oe(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 gt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function Nm(e,t){let n=Pn(t);for(;n&&n!==e;){if(ks(n,e)){n=n.parentElement;continue}const r=oe(n);if(Ei.has(r)&&n instanceof HTMLElement)return n;if(js.has(r)||r==="pre")return null;n=n.parentElement}return null}function Gt(e){const t=ht(e);if(!t)return[];const n=new Set,r=[];for(const i of Li(t)){const a=Nm(e,i);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function ei(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=oe(e);return Ei.has(t)||Ti.has(t)?!1:qe(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Lm(e,t){let n=Pn(t);for(;n&&n!==e;){if(Ti.has(oe(n)))return!0;n=n.parentElement}return!1}function Mm(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Rm(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let i=r,a=r;for(;i>0&&ei(n[i-1]);)i-=1;for(;a<n.length-1&&ei(n[a+1]);)a+=1;return n.slice(i,a+1)}function _m(e,t,n){return n.startContainer===e?e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild:n.startContainer===t&&e!==t?e.firstChild:Mm(e,n.startContainer)}function Im(e,t){const n=Ai(e);if(Lm(e,t.startContainer))return null;if(!n.firstChild){const l=document.createElement("p");return l.appendChild(document.createElement("br")),n.appendChild(l),l}const r=_m(n,e,t);if(!r||r instanceof Element&&Ti.has(oe(r))||r instanceof HTMLElement&&Ei.has(oe(r))||!ei(r))return null;const i=Rm(n,r),a=document.createElement("p");n.insertBefore(a,i[0]);for(const l of i)a.appendChild(l);return a}function An(e){const t=Gt(e);if(t.length>0)return t;const n=ht(e);if(!n)return[];const r=Im(e,n);return r?[r]:[]}function zt(e){const t=e.parentElement;return t&&Ni(t)?t:null}function Es(e){if(e.length===0)return[];const t=[[e[0]]];for(let n=1;n<e.length;n+=1){const r=e[n-1],i=e[n];r.parentNode===i.parentNode&&Fm(r,i)?t[t.length-1].push(i):t.push([i])}return t}function Fm(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}const vr=["p","h1","h2","h3","h4","h5","h6"],Bm=new Set(vr),Ts=new Set([...vr,"div"]),Nr=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),Hm=()=>({tag:null,mixed:!1});function Ns(e){return Bm.has(e)}function zm(e){return Ns(e)?e:e==="div"?"p":null}function Om(e){return e instanceof Element&&Nr.has(oe(e))}function Ls(e){return e instanceof HTMLElement&&Ts.has(oe(e))}function ti(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=oe(e);return Ts.has(t)||Nr.has(t)?!1:qe(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Km(e,t){let n=Pn(t);for(;n&&n!==e;){if(Nr.has(oe(n)))return!0;n=n.parentElement}return!1}function Ms(e,t){let n=Pn(t);for(;n&&n!==e;){if(ks(n,e)){n=n.parentElement;continue}if(Ls(n))return n;if(Nr.has(oe(n)))return null;n=n.parentElement}return null}function $m(e,t){const n=new Set,r=[];for(const i of Li(t)){const a=Ms(e,i);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Um(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Wm(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let i=r,a=r;for(;i>0&&ti(n[i-1]);)i-=1;for(;a<n.length-1&&ti(n[a+1]);)a+=1;return n.slice(i,a+1)}function Gm(e,t,n){return n.startContainer===e?e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild:n.startContainer===t&&e!==t?e.firstChild:Um(e,n.startContainer)}function Vm(e,t,n){const r=Ai(e);if(Km(e,t.startContainer))return!1;if(!r.firstChild){const c=document.createElement(n);return c.appendChild(document.createElement("br")),r.appendChild(c),!0}const i=Gm(r,e,t);if(!i||Om(i)||Ls(i)||!ti(i))return!1;const a=Wm(r,i),l=document.createElement(n);r.insertBefore(l,a[0]);for(const c of a)l.appendChild(c);return!0}function qm(e){const t=ht(e);if(!t)return Hm();const n=Li(t).map(i=>{const a=Ms(e,i);return a?zm(oe(a)):null}),r=n[0];return n.every(i=>i===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function Xm(e,t){if(!Ns(t))return!1;const n=ht(e);if(!n)return!1;const r=Ht(e,n.startContainer,n.startOffset),i=Ht(e,n.endContainer,n.endOffset),a=Math.min(r,i),l=Math.max(r,i),c=$m(e,n);let m=!1;if(c.length===0)m=Vm(e,n,t);else for(const p of c)oe(p)!==t&&(Ri(p,t),m=!0);return Mi(e,a,l),m}function _i(e){if(!Ie(e))return null;const t=zt(e);if(!t)return null;const n=oe(t);return n==="ul"||n==="ol"?n:null}function Rs(e){const t=Gt(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(_i),r=n[0];return n.every(i=>i===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function Ym(e,t,n){const r=[...e.children].filter(i=>Ni(i));for(const i of r)t.insertBefore(i,n)}function _s(e){const t=zt(e),n=document.createElement("p");for(const p of[...e.attributes])n.setAttribute(p.name,p.value);for(n.style.marginLeft="",gt(n);e.firstChild&&!Ni(e.firstChild);)n.appendChild(e.firstChild);const r=[];let i=e.nextElementSibling;for(;i;)r.push(i),i=i.nextElementSibling;const a=(t==null?void 0:t.parentNode)??e.parentNode;if(!t||!a)return e.replaceWith(n),n;const l=Ie(a)?a.parentNode??a:a,c=Ie(a)?a.nextSibling:t.nextSibling;e.remove();let m=null;if(r.length>0){m=document.createElement(t.tagName);for(const p of r)m.appendChild(p)}return l.insertBefore(n,c),m&&l.insertBefore(m,n.nextSibling),Ym(e,l,n.nextSibling),t.childElementCount===0&&t.remove(),n}function Jm(e){if(Ie(e))return e;const t=Ri(e,"li");return t.style.marginLeft="",gt(t),t}function Is(e,t){if(e.length===0)return!1;if(e.every(Ie)){const a=zt(e[0]);if(a&&e.every(l=>l.parentElement===a)&&[...a.children].every(c=>c instanceof HTMLElement&&e.includes(c)))return oe(a)===t?!1:(Ri(a,t),!0)}const n=e[0],r=n.parentNode;if(!r)return!1;const i=document.createElement(t);r.insertBefore(i,n);for(const a of e){const l=Ie(a)?zt(a):null;i.appendChild(Jm(a)),l&&l!==i&&l.childElementCount===0&&l.remove()}return!0}function Fs(e){let t=!1;for(const n of[...e].reverse())Ie(n)&&(_s(n),t=!0);return t}function Zm(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;if(n.every(a=>_i(a)===t))return Fs(n);let i=!1;for(const a of Es(n))Is(a,t)&&(i=!0);return i})}function Qm(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;if(t===null)return Fs(n);if(n.every(a=>_i(a)===t))return!1;let i=!1;for(const a of Es(n))Is(a,t)&&(i=!0);return i})}const Bs=40;function Ii(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function Hs(e,t){if(t<=0){e.style.marginLeft="",gt(e);return}e.style.marginLeft=`${t}px`}function ef(e){let t=e.previousElementSibling;for(;t;){if(Ie(t))return t;t=t.previousElementSibling}return null}function tf(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(oe(n)==="ul"||oe(n)==="ol"))return n}return null}function nf(e){const t=ef(e);if(!t)return!1;const n=zt(e);if(!n)return!1;const r=oe(n)==="ol"?"ol":"ul";let i=tf(t);return(!i||oe(i)!==r)&&(i=document.createElement(r),t.appendChild(i)),i.appendChild(e),!0}function rf(e){const t=zt(e);if(!t)return!1;const n=t.parentElement;if(n&&Ie(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return _s(e),!0}function of(e){return Gt(e).some(n=>Ie(n)||Ii(n)>0)}function af(e){return Wt(e,()=>{const t=An(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Ie(r)){nf(r)&&(n=!0);continue}Hs(r,Ii(r)+Bs),n=!0}return n})}function lf(e){return Wt(e,()=>{const t=Gt(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Ie(r)){rf(r)&&(n=!0);continue}const i=Ii(r);i<=0||(Hs(r,Math.max(0,i-Bs)),n=!0)}return n})}const zs="pt",sf=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,cf=/^[+-]?0(?:\.0+)?$/;function Me(e){return`${J(e.value)}${e.unit}`}function He(e){const t=e.trim();if(!t)return null;if(cf.test(t))return{value:0,unit:"px"};const n=t.match(sf);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return Tr(i)?{value:ve(r),unit:i}:null}function Sr(e,t,n){const r=e.trim();if(!r)return null;const i=He(r);if(i)return!n&&i.value<0?{...i,value:0}:i;const a=Number(r.replace(",","."));return Number.isFinite(a)?!n&&a<0?{value:0,unit:t}:{value:ve(a),unit:t}:null}function bt(e){return e.value>=0?e:{value:0,unit:e.unit}}function Re(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}const Xe=["top","right","bottom","left"],Lr=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],tt={top:null,right:null,bottom:null,left:null},Fi={style:"none",width:null,color:null},uf=new Set(Lr),rl={value:0,unit:"px"};function df(){return{margin:{...tt},padding:{...tt},lineHeight:null,border:{...Fi},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null}}function Bi(){const e=df();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}}function nt(e,t){return Xe.every(n=>Re(e[n],t[n]))}function Os(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 Ks(e,t){return e.style===t.style&&Re(e.width,t.width)&&e.color===t.color}function $s(e,t){return e===t?!0:!e||!t?!1:Re(e.offsetX,t.offsetX)&&Re(e.offsetY,t.offsetY)&&Re(e.blur,t.blur)&&Re(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function mf(e){return e.kind==="normal"?"normal":e.kind==="number"?J(e.value):Me({value:e.value,unit:e.unit})}function ff(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)?Ot(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?Ot(n):null}function Ot(e){return ve(Math.min(1,Math.max(0,e)))}function Cr(e){return ve(Ot(e)*100)}function Us(e){return Ot(e/100)}function pf(e){return J(Ot(e))}function hf(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:ve(r)}}const n=He(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function gf(e,t){const n=[];let r="",i=0;for(const a of e){if(a==="("){i+=1,r+=a;continue}if(a===")"){i=Math.max(0,i-1),r+=a;continue}if(a===t&&i===0){r.trim()&&n.push(r.trim()),r="";continue}r+=a}return r.trim()&&n.push(r.trim()),n}function bf(e){const t=[];let n="",r=0;for(const i of e){if(i==="("){r+=1,n+=i;continue}if(i===")"){r=Math.max(0,r-1),n+=i;continue}if(/\s/.test(i)&&r===0){n&&t.push(n),n="";continue}n+=i}return n&&t.push(n),t}function yf(e){const t=[Me(e.offsetX),Me(e.offsetY),Me(e.blur),Me(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function xf(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=gf(t,",")[0];if(!n)return null;const r=bf(n);let i=!1,a=null;const l=[];for(const c of r){if(c.toLowerCase()==="inset"){i=!0;continue}const m=He(c);if(m){l.push(m);continue}const p=me(c);if(p){a=p;continue}return null}return l.length<2||l.length>4?null:{offsetX:l[0],offsetY:l[1],blur:l[2]??rl,spread:l[3]??rl,color:a,inset:i}}function Rt(e,t){return He(e.style.getPropertyValue(t))}function wf(e,t,n,r){const i=n&&r?bt(n):n,a=i?Me(i):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function ol(e,t){return{top:Rt(e,`${t}-top`),right:Rt(e,`${t}-right`),bottom:Rt(e,`${t}-bottom`),left:Rt(e,`${t}-left`)}}function il(e,t,n,r){let i=!1;for(const a of Xe)wf(e,`${t}-${a}`,n[a],r)&&(i=!0);return i}function vf(e){const t=e.trim().toLowerCase();return uf.has(t)?t:"none"}function Ws(e){const t=vf(e.style.borderStyle||e.style.borderTopStyle),n=Rt(e,"border-width")??Rt(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,i=r?me(r):null;return{style:t,width:n,color:i}}function Sf(e,t){const n=Ws(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?bt(t.width):null,color:t.color};return Ks(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=Me(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Gs(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return He(n)}function Cf(e,t){const n=t?bt(t):null,r=Gs(e);return Re(r,n)?!1:(n?e.style.borderRadius=Me(n):e.style.removeProperty("border-radius"),!0)}function Vs(e){return xf(e.style.boxShadow)}function kf(e,t){const n=Vs(e),r=t?{...t,blur:bt(t.blur)}:null;return $s(n,r)?!1:(r?e.style.boxShadow=yf(r):e.style.removeProperty("box-shadow"),!0)}function qs(e){return hf(e.style.lineHeight)}function Df(e,t){const n=qs(e);return Os(n,t)?!1:(t?e.style.lineHeight=mf(t):e.style.removeProperty("line-height"),!0)}function Xs(e){const t=e.style.backgroundColor;return t?me(t):null}function Pf(e,t){const n=t?me(t):null;return Xs(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Ys(e){return ff(e.style.opacity)}function Af(e,t){const n=Ys(e),r=t===null?null:Ot(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=pf(r),!0)}function Vt(e){return{margin:ol(e,"margin"),padding:ol(e,"padding"),lineHeight:qs(e),border:Ws(e),borderRadius:Gs(e),boxShadow:Vs(e),backgroundColor:Xs(e),opacity:Ys(e)}}function qt(e,t){let n=!1;return!t.marginMixed&&il(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&il(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&Df(e,t.lineHeight)&&(n=!0),!t.borderMixed&&Sf(e,t.border)&&(n=!0),!t.radiusMixed&&Cf(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&kf(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&Pf(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&Af(e,t.opacity)&&(n=!0),n&>(e),n}function jf(e){const t=Bi(),n=Gt(e);if(n.length===0)return t;const r=n.map(Vt),i=r[0];return{margin:i.margin,marginMixed:r.some(a=>!nt(a.margin,i.margin)),padding:i.padding,paddingMixed:r.some(a=>!nt(a.padding,i.padding)),lineHeight:i.lineHeight,lineHeightMixed:r.some(a=>!Os(a.lineHeight,i.lineHeight)),border:i.border,borderMixed:r.some(a=>!Ks(a.border,i.border)),borderRadius:i.borderRadius,radiusMixed:r.some(a=>!Re(a.borderRadius,i.borderRadius)),boxShadow:i.boxShadow,shadowMixed:r.some(a=>!$s(a.boxShadow,i.boxShadow)),backgroundColor:i.backgroundColor,backgroundMixed:r.some(a=>a.backgroundColor!==i.backgroundColor),opacity:i.opacity,opacityMixed:r.some(a=>a.opacity!==i.opacity)}}function Ef(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;let r=!1;for(const i of n)qt(i,t)&&(r=!0);return r})}const Js=["left","center","right","justify"];function Tf(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function Nf(e){return Tf(e.style.textAlign)}function Zs(e){const t=Gt(e);if(t.length===0)return ht(e)?{align:"left",mixed:!1}:{align:null,mixed:!1};const n=t.map(Nf),r=n[0];return n.every(i=>i===r)?{align:r,mixed:!1}:{align:null,mixed:!0}}function Qs(e,t){return Js.includes(t)?Wt(e,()=>{const n=An(e);if(n.length===0)return!1;let r=!1;for(const i of n)i.style.textAlign!==t&&(i.style.textAlign=t,r=!0);return r}):!1}function hn(){return{...Bi(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function al(e){const t=jf(e),n=Zs(e),r=Rs(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function ec(e,t){let n=!1;return!t.alignMixed&&t.align&&Qs(e,t.align)&&(n=!0),t.listMixed||Qm(e,t.list)&&(n=!0),Ef(e,t)&&(n=!0),n}function Lf(e,t){return ec(e,ni(t))}function tc(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}}function ni(e){const t=hn();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}:{...t,alignMixed:!0,listMixed:!0,marginMixed:!0,paddingMixed:!0,lineHeightMixed:!0,borderMixed:!0,radiusMixed:!0,shadowMixed:!0,backgroundMixed:!0,opacityMixed:!0}}function Mf(){return{size:null,unit:Ct,marks:Qe(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function ri(){return{font:Mf(),box:Bi()}}function Rf(e){const t=e.style.fontSize,n=t?Di(t):null,r=n&&Tr(n.unit)?{value:n.value,unit:n.unit}:null,i=`${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(i),strikethrough:/\bline-through\b/.test(i)},c=e.style.color,m=e.style.fontFamily.trim();return{size:(r==null?void 0:r.value)??null,unit:(r==null?void 0:r.unit)??Ct,marks:l,fontFamily:m||null,fontFamilyMixed:!1,fontColor:c?me(c):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function _f(e,t){const n=e.style.fontSize,r=t.size===null?null:kt(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const i=ki(r.value,r.unit);return n===i?!1:(e.style.fontSize=i,!0)}function If(e,t){var i;if(t.fontFamilyMixed)return!1;const n=(i=t.fontFamily)!=null&&i.trim()?t.fontFamily.trim():null,r=e.style.fontFamily.trim()||null;return kn(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function Ff(e,t){if(t.fontColorMixed)return!1;const n=t.fontColor?me(t.fontColor):null;return(e.style.color?me(e.style.color):null)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Bf(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 i=t.italic?"italic":"";e.style.fontStyle!==i&&(i?e.style.fontStyle=i: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 Hf(e,t){let n=!1;return _f(e,t)&&(n=!0),If(e,t)&&(n=!0),Ff(e,t)&&(n=!0),Bf(e,t.marks)&&(n=!0),n&>(e),n}function zf(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function Of(e){const t=Dn(e);if(!t)return ri();const n=Vt(t);return{font:Rf(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}}}function Kf(e,t){const n=ht(e),r=n?Ht(e,n.startContainer,n.startOffset):null,i=n?Ht(e,n.endContainer,n.endOffset):null,a=Dn(e),l=Am(e),c=Hf(l,t.font),m=qt(l,zf(t));return Ps(e),r!==null&&i!==null&&Mi(e,Math.min(r,i),Math.max(r,i)),!a||c||m}const Hi="data-hover-html",$f="noopener noreferrer",Uf="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)",Wf="this._hoverBox&&this._hoverBox.remove()",Gf=/^(#(?:[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 Mr(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function Vf(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function Sn(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&Vf(n))return n;n=n.parentNode}return null}function nc(e){return Gf.test(e)}function qf(e){var i;const t=e.getAttribute("onmouseover")??"",n=/this\.style\.color\s*=\s*'([^']+)'/.exec(t),r=((i=n==null?void 0:n[1])==null?void 0:i.trim())??"";return r&&nc(r)?r:null}function rc(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function Xf(e){const t=e.getAttribute(Hi)??"",n=qf(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:rc(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function oc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return null;const r=Sn(e,n.commonAncestorContainer);return r?Xf(r):null}function Yf(e){return oc(e)!==null}function Jf(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Hi)}function Zf(e,t){var r;if(Jf(e),t.hoverMode==="html"){const i=t.hoverHtml.trim();if(!i)return;e.setAttribute(Hi,i),e.setAttribute("onmouseover",Uf),e.setAttribute("onmouseout",Wf);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!nc(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function zi(e,t){const n=Mr(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",$f)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":rc(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),Zf(e,n)}function Qf(e,t){const n=new Set;for(const r of t){const i=Sn(e,r);i&&!n.has(i)&&n.add(i)}for(const r of n)_e(r)}function ep(e,t,n){ut(t);const r=Be(t).filter(c=>c.data.length>0);Qf(e,r),r.length>0&&Ut(r);const i=window.getSelection();if(!i||i.rangeCount===0)return!1;const a=i.getRangeAt(0);ut(a);const l=document.createElement("a");zi(l,n);try{return a.surroundContents(l),!0}catch{const c=a.extractContents();return c.hasChildNodes()?(l.appendChild(c),a.insertNode(l),!0):!1}}function tp(e,t){const n=document.createElement("a");zi(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 np(e,t){const n=t.href.trim();if(!n)return!1;const r=Mr({...t,href:n}),i=window.getSelection();if(!i||i.rangeCount===0)return!1;const a=i.getRangeAt(0);if(!se(e,a.commonAncestorContainer))return!1;const l=Sn(e,a.startContainer),c=Sn(e,a.endContainer);return l&&l===c?(zi(l,r),!0):a.collapsed?tp(a,r):ep(e,a,r)}const rp=/^[A-Za-z][A-Za-z0-9_-]*$/,ic="";function oi(e){var r;const t=Ai(e),n=new Set;for(const i of t.querySelectorAll("[id]")){if(i===t)continue;const a=i.id.trim();a&&n.add(a)}for(const i of t.querySelectorAll("a[name]")){const a=(r=i.getAttribute("name"))==null?void 0:r.trim();a&&n.add(a)}return[...n].sort((i,a)=>i.localeCompare(a)).map(i=>({id:i}))}function op(e){return new Set(oi(e).map(t=>t.id))}function ac(e,t){const n=e.trim();return n?rp.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function ll(e,t){const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(ic)),e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(e)}function ip(e,t){var r;const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(ic)),(r=e.parentNode)==null||r.insertBefore(n,e)}function ap(e,t){const n=t.trim();if(ac(n,op(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const i=r.getRangeAt(0);if(!se(e,i.commonAncestorContainer))return!1;const a=Sn(e,i.startContainer);if(a)return ip(a,n),!0;if(i.collapsed)return ll(i,n),!0;ut(i);const l=document.createElement("span");l.id=n;try{return i.surroundContents(l),!0}catch{return ll(i,n),!0}}function lc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function lp(e){const t=lc(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 i=t.toString();if(!i){const a=n.querySelector("img");i=(a==null?void 0:a.getAttribute("alt"))??(a==null?void 0:a.getAttribute("src"))??""}return{html:r,text:i}}function sc(e){const t=lc(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 sp(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 cc(e){const t=lp(e);return t?sp(t):!1}async function cp(e){return await cc(e)?sc(e):!1}const up=new Set(["strong","b","em","i","u","s","strike","del"]),dp=["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 mp(e){for(const t of dp)e.style.removeProperty(t)}function fp(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!qe(r)){n=r;continue}if(pt(r,n),up.has(r.tagName.toLowerCase())){_e(r);continue}if(mp(r),Dt(r)){_e(r);continue}n=r.isConnected?r:t}}function pp(e){const t=ht(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;ut(t);const r=Be(t).filter(i=>i.data.length>0);if(r.length===0)return!1;for(const i of r)fp(e,i);return Ut(r),e.innerHTML!==n}const hp=2*1024*1024,gp="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",bp=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),yp=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),xp=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,wp=/^(javascript|vbscript|file|blob):/i;function vp(e={}){return{src:"",alt:"",title:"",...e}}function Oi(e){const t=e.trim();if(!t)return"empty";if(wp.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return xp.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 Sp(e){return e.size>hp?"tooLarge":Ap(e)?null:"type"}function Cp(e){const t=Sp(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const i=new FileReader;i.onload=()=>{const a=String(i.result??"");if(Oi(a)){r(new Error("invalid"));return}n(a)},i.onerror=()=>r(i.error??new Error("Failed to read file")),i.readAsDataURL(e)})}function kp(e,t){e.setAttribute("src",t.src.trim());const n=t.alt.trim(),r=t.title.trim();n?e.setAttribute("alt",n):e.removeAttribute("alt"),r?e.setAttribute("title",r):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.height="auto",Dp(e,t.css)}function Dp(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const i=r.indexOf(":");if(i<=0)continue;const a=r.slice(0,i).trim(),l=r.slice(i+1).trim();a&&l&&e.style.setProperty(a,l)}}function Pp(e,t){const n=vp(t);if(Oi(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const i=r.getRangeAt(0);if(!se(e,i.commonAncestorContainer))return!1;i.collapsed||i.deleteContents();const a=document.createElement("img");return kp(a,n),i.insertNode(a),i.setStartAfter(a),i.collapse(!0),r.removeAllRanges(),r.addRange(i),!0}function ii(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function Bo(e,t){if(!se(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 Ap(e){const t=e.type.trim().toLowerCase();if(t&&bp.has(t))return!0;const n=jp(e.name);return!!(!t&&n&&yp.has(n))}function jp(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Ep="1em 0",Tp="1px solid #d0d0d0",Np=new Set(["p","h1","h2","h3","h4","h5","h6"]),Lp=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function Mp(e){var a;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return!1;n.collapsed||n.deleteContents();const r=Rp(),i=_p(e,n.startContainer);if(i){const l=Ip(i,n);return(a=i.parentNode)==null||a.insertBefore(r,l),cl(r),!0}return n.insertNode(r),Fp(e,r),zp(r),cl(r),!0}function Rp(){const e=document.createElement("hr");return e.style.margin=Ep,e.style.border="0",e.style.borderTop=Tp,e}function _p(e,t){let n=Pn(t);for(;n&&n!==e;){const r=oe(n);if(Np.has(r)&&n instanceof HTMLElement)return n;if(Lp.has(r))return null;n=n.parentElement}return null}function Ip(e,t){var a;const n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(e,e.childNodes.length);const r=n.extractContents(),i=e.cloneNode(!1);return i.appendChild(r),sl(e),sl(i),(a=e.parentNode)==null||a.insertBefore(i,e.nextSibling),i}function Fp(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!Bp(n))return;pt(n,t),_e(n)}}function Bp(e){const t=oe(e);return qe(e)||t==="a"}function sl(e){Hp(e)&&e.appendChild(document.createElement("br"))}function Hp(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 zp(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 cl(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 uc=["%","px","pt","pc","em","rem"],Op="%",Kp={"%":[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]},Kt={"%":{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}},$p=new Set(uc),Up=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function Wp(e){return $p.has(e)}function ul(e){return`${J(e.value)}${e.unit}`}function ai(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(Up);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r)||r<=0)return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return Wp(i)?$t(r,i):null}function dl(e,t){const n=e.trim();if(!n)return null;const r=ai(n);if(r)return r;const i=Number(n.replace(",","."));return Number.isFinite(i)?$t(i,t):null}function $t(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Kt[t];return{value:ve(Math.min(r,Math.max(n,e))),unit:t}}function gn(e,t,n){const r=n>0?n:1;if(e==="width"){const a=$t(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:$t(t.value*r,t.unit)??t,height:t}}const hr="data-hover-css",dc=["fill","contain","cover","none","scale-down"],mc=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],Gp=new Set(dc),Vp=new Set(mc),ml="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",qp="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",Xp=/^-?[a-z][a-z0-9-]*$/i,Yp=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,li=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function fc(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...tt},border:{...Fi},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function Jp(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function Zp(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=gn("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=gn("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function Qp(e){const t=[];for(const n of e.split(";")){const r=n.trim();if(!r)continue;const i=r.indexOf(":");if(i<=0)continue;const a=r.slice(0,i).trim().toLowerCase(),l=r.slice(i+1).trim();!a||!l||Xp.test(a)&&(a==="behavior"||a.endsWith("binding")||Yp.test(l)||t.push(`${a}: ${l}`))}return t.join("; ")}function bn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!se(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&&se(e,r))return r}return ii(e,n.commonAncestorContainer)}function eh(e){const t=bn(e);return t?pc(t):null}function pc(e){const t=Vt(e),n=ih(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,i=nh(e);return fc({sizeMode:i.sizeMode,width:i.width,height:i.height,align:n,margin:r,border:t.border,borderRadius:t.borderRadius,boxShadow:t.boxShadow,opacity:t.opacity,objectFit:gc(e),objectPosition:ch(e),rotateDeg:bc(e),hoverCss:e.getAttribute(hr)??""})}function hc(e,t){let n=!1;return rh(e,t)&&(n=!0),qt(e,{margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:tt,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),ah(e,t.align)&&(n=!0),lh(e,t.objectFit)&&(n=!0),sh(e,t.objectPosition)&&(n=!0),dh(e,t.rotateDeg)&&(n=!0),mh(e,t.hoverCss)&&(n=!0),n}function th(e,t){const n=bn(e);return n?hc(n,t):!1}function nh(e){const t=ai(e.style.width),n=ai(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 rh(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=oh(t);return r.width?e.style.width=ul(r.width):e.style.removeProperty("width"),r.height?e.style.height=ul(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 oh(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 ih(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(),i=e.style.marginRight.trim().toLowerCase();return n==="block"&&r==="auto"&&i==="auto"?"center":null}function ah(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 gc(e){const t=e.style.objectFit.trim().toLowerCase();return Gp.has(t)?t:null}function lh(e,t){return gc(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function sh(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 ch(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(Vp.has(t),t):null}function bc(e){const t=li.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?ve(n):null}function uh(e){const t=e.trim();return t?li.test(t)&&t.replace(li,"").trim()==="":!0}function dh(e,t){const n=bc(e),r=t===null||t===0?null:ve(t);return n===r?!1:r===null?uh(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${J(r)}deg)`,!0)}function mh(e,t){const n=Qp(t),r=e.getAttribute(hr)??"",i=e.getAttribute("onmouseover")??"";return r===n&&(n&&i===ml||!n&&!i)?!1:n?(e.setAttribute(hr,n),e.setAttribute("onmouseover",ml),e.setAttribute("onmouseout",qp),!0):(e.removeAttribute(hr),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const rt=16;function fl(e){return Math.min(Kt.px.max,Math.max(rt,e))}function fh(e){return e.width>0&&e.height>0?e.width/e.height:1}function ph(e,t){const n=Math.max(rt,rt*t),r=Math.min(Kt.px.max,Kt.px.max*t),i=Math.min(r,Math.max(n,e));return{width:i,height:i/t}}function hh(e,t){const n=Math.max(rt,rt/t),r=Math.min(Kt.px.max,Kt.px.max/t),i=Math.min(r,Math.max(n,e));return{width:i*t,height:i}}function gh(e,t,n){const r=fh(t);return e==="e"?ph(t.width+n.x,r):e==="s"?hh(t.height+n.y,r):{width:fl(t.width+n.x),height:fl(t.height+n.y)}}function bh(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:rt,height:r>0?r:rt}}function yh(e,t,n){const r=$t(Math.max(rt,t),"px"),i=$t(Math.max(rt,n),"px");return!r||!i?!1:hc(e,{...pc(e),sizeMode:"lock",width:r,height:i})}const pl=10,_t=1,It=50,xh="1px solid #000",wh="0.25em",vh=new Set(["td","th"]);function yc(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=_t&&t>=_t&&e<=It&&t<=It}function Ve(e,t){return Ki(e,t,n=>n instanceof HTMLTableElement)}function kr(e,t){return Ki(e,t,n=>Th(n))}function Sh(e,t){return Ki(e,t,n=>n instanceof HTMLTableRowElement)}function yn(e){return Ve(e,$i(e))}function Xt(e){return kr(e,$i(e))}function xc(e){return Sh(e,$i(e))}function Ch(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function kh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return[];const r=kr(e,n.startContainer),i=kr(e,n.endContainer);if(!r)return[];if(!i||r===i)return[r];const a=Ve(e,r);if(!a||Ve(e,i)!==a)return[r];const l=gl(r),c=gl(i);if(!l||!c)return[r];const m=Math.min(l.row,c.row),p=Math.max(l.row,c.row),b=Math.min(l.col,c.col),h=Math.max(l.col,c.col),w=[];for(const y of Array.from(a.rows))if(!(y.rowIndex<m||y.rowIndex>p))for(const v of Array.from(y.cells))v.cellIndex>=b&&v.cellIndex<=h&&w.push(v);return w.length>0?w:[r]}function Dh(e,t){if(!yc(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer))return!1;const i=document.createElement("table");i.style.borderCollapse="collapse",i.style.width="100%";const a=document.createElement("tbody");for(let c=0;c<t.rows;c+=1){const m=document.createElement("tr");for(let p=0;p<t.cols;p+=1)m.appendChild(Ui("td"));a.appendChild(m)}i.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(i),Lh(e,i);const l=i.querySelector("td, th");return l instanceof HTMLTableCellElement&&et(l),!0}function si(e,t){var m;const n=Xt(e);if(!n)return!1;const r=n.parentElement;if(!(r instanceof HTMLTableRowElement)||!Ve(e,n))return!1;const a=document.createElement("tr"),l=Math.max(1,r.cells.length);for(let p=0;p<l;p+=1){const b=r.cells[p];a.appendChild(Ui((b==null?void 0:b.tagName)==="TH"?"th":"td"))}t==="before"?(m=r.parentNode)==null||m.insertBefore(a,r):r.insertAdjacentElement("afterend",a);const c=a.cells[Math.min(n.cellIndex,a.cells.length-1)];return c&&et(c),!0}function hl(e,t){const n=Xt(e);if(!n)return!1;const r=Ve(e,n);if(!r)return!1;const i=n.cellIndex,a=t==="before"?i:i+1;let l=null;for(const c of Array.from(r.rows)){const m=c.cells[Math.min(i,c.cells.length-1)]??null,p=Ui((m==null?void 0:m.tagName)==="TH"?"th":"td");Nh(c,a,p),c===n.parentElement&&(l=p)}return l&&et(l),!0}function Ph(e){const t=Xt(e);if(!t)return!1;const n=t.parentElement;if(!(n instanceof HTMLTableRowElement))return!1;const r=Ve(e,t);if(!r)return!1;const i=t.cellIndex,a=n.rowIndex;if(r.rows.length<=1)return wc(e,r);const l=n.parentNode;n.remove();const c=r.rows[Math.min(a,r.rows.length-1)],m=c==null?void 0:c.cells[Math.min(i,c.cells.length-1)];return m?et(m):l&&Rh(r),!0}function Ah(e){const t=Xt(e);if(!t)return!1;const n=Ve(e,t);if(!n)return!1;const r=t.cellIndex,i=t.parentElement;if(Math.max(0,...Array.from(n.rows,p=>p.cells.length))<=1)return wc(e,n);const l=i instanceof HTMLTableRowElement?i.rowIndex:0;for(const p of Array.from(n.rows)){const b=p.cells[r];b&&b.remove()}const c=n.rows[Math.min(l,n.rows.length-1)],m=c==null?void 0:c.cells[Math.min(r,c.cells.length-1)];return m&&et(m),!0}function jh(e,t){const n=Xt(e);if(!n)return!1;const r=Ve(e,n);if(!r)return!1;const i=Ch(r),a=i.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(et(i[a-1]),{changed:!1});if(a<i.length-1)return et(i[a+1]),{changed:!1};const l=n.parentElement;if(!si(e,"below"))return!1;const c=l instanceof HTMLTableRowElement?l.nextElementSibling:null;return c instanceof HTMLTableRowElement&&c.cells[0]&&et(c.cells[0]),{changed:!0}}function Eh(e,t){return!se(e,t)||t===e?!1:(et(t),!0)}function Ki(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function Th(e){return vh.has(e.tagName.toLowerCase())}function $i(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n.startContainer:null}function gl(e){const t=e.parentElement;return t instanceof HTMLTableRowElement?{row:t.rowIndex,col:e.cellIndex}:null}function Ui(e){const t=document.createElement(e);return t.style.border=xh,t.style.padding=wh,t.appendChild(document.createElement("br")),t}function Nh(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function Lh(e,t){var i;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))&&((i=n.parentNode)==null||i.insertBefore(t,n.nextSibling),Mh(n)&&n.remove())}function Mh(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 wc(e,t){if(!t.parentNode||!se(e,t))return!1;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),t.remove();const i=window.getSelection();return i&&(i.removeAllRanges(),i.addRange(r)),!0}function et(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Rh(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function _h(e={}){return{border:{...Fi},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function Ih(e){const t=Vt(e);return{border:t.border,borderCollapse:zh(e),borderSpacing:vc(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:He(e.style.width)}}function Fh(e,t){let n=qt(e,{margin:{top:null,right:null,bottom:null,left:null},marginMixed:!0,padding:{top:null,right:null,bottom:null,left:null},paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0});return Oh(e,t.borderCollapse)&&(n=!0),Kh(e,t.borderCollapse,t.borderSpacing)&&(n=!0),$h(e,t.width)&&(n=!0),n&>(e),n}function Bh(e){const t=yn(e);return t?Ih(t):null}function Hh(e,t){const n=yn(e);return n?Fh(n,t):!1}function zh(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function Oh(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function vc(e){const t=e.style.borderSpacing.trim();return t?He(t.split(/\s+/)[0]??""):null}function Kh(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?bt(n):null,i=vc(e);return Re(i,r)?!1:(r?e.style.borderSpacing=Me(r):e.style.removeProperty("border-spacing"),!0)}function $h(e,t){const n=t?bt(t):null,r=He(e.style.width);return Re(r,n)?!1:(n?e.style.width=Me(n):e.style.removeProperty("width"),!0)}const Rr=["top","middle","bottom","baseline"],Uh=new Set(Rr);function Wh(e={}){return{backgroundColor:null,color:null,padding:{...tt},verticalAlign:null,width:null,...e}}function Gh(e){const t=Vt(e);return{backgroundColor:t.backgroundColor,color:Sc(e),padding:t.padding,verticalAlign:Cc(e),width:He(e.style.width)}}function Vh(e,t){let n=qt(e,{margin:{...tt},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 Yh(e,t.color)&&(n=!0),Jh(e,t.verticalAlign)&&(n=!0),Zh(e,t.width)&&(n=!0),n&>(e),n}function qh(e){const t=Xt(e);return t?Gh(t):null}function Xh(e,t){const n=kh(e);if(n.length===0)return!1;let r=!1;for(const i of n)Vh(i,t)&&(r=!0);return r}function Sc(e){const t=e.style.color;return t?me(t):null}function Yh(e,t){const n=t?me(t):null;return Sc(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Cc(e){const t=e.style.verticalAlign.trim().toLowerCase();return Uh.has(t)?t:null}function Jh(e,t){return Cc(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function Zh(e,t){const n=t?bt(t):null,r=He(e.style.width);return Re(r,n)?!1:(n?e.style.width=Me(n):e.style.removeProperty("width"),!0)}const Qh=new Set(Rr);function eg(e={}){return{backgroundColor:null,color:null,padding:{...tt},height:null,verticalAlign:null,...e}}function tg(e){const t=e.cells[0],n=t?Vt(t).padding:{...tt};return{backgroundColor:kc(e),color:Dc(e),padding:n,height:He(e.style.height),verticalAlign:Pc(e)}}function ng(e,t){let n=!1;ig(e,t.backgroundColor)&&(n=!0),ag(e,t.color)&&(n=!0),sg(e,t.height)&&(n=!0),lg(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))qt(r,{margin:{...tt},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&>(e),n}function rg(e){const t=xc(e);return t?tg(t):null}function og(e,t){const n=xc(e);return n?ng(n,t):!1}function kc(e){const t=e.style.backgroundColor;return t?me(t):null}function ig(e,t){const n=t?me(t):null;return kc(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Dc(e){const t=e.style.color;return t?me(t):null}function ag(e,t){const n=t?me(t):null;return Dc(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Pc(e){const t=e.style.verticalAlign.trim().toLowerCase();return Qh.has(t)?t:null}function lg(e,t){return Pc(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function sg(e,t){const n=t?bt(t):null,r=He(e.style.height);return Re(r,n)?!1:(n?e.style.height=Me(n):e.style.removeProperty("height"),!0)}const cg=1e3;function ug(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function dg({onAutoSave:e,getHtml:t}){const n=s.useRef(e);n.current=e;const r=s.useRef(t);r.current=t;const i=s.useRef(null),a=e!=null;s.useEffect(()=>{if(!a){i.current=null;return}i.current=r.current();const l=window.setInterval(()=>{const c=n.current;if(!c)return;const m=r.current();m!==i.current&&(i.current=m,queueMicrotask(()=>ug(c,m)))},cg);return()=>{window.clearInterval(l)}},[a])}function Ho({value:e,defaultValue:t,onChange:n}){const[r,i]=s.useState(t),a=e!==void 0,l=a?e:r,c=s.useCallback(m=>{a||i(m),n==null||n(m)},[a,n]);return[l,c]}const bl=8,yl=["#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"],mg=8;let ci=[];const ui=new Set;function xl(){return ci}function fg(e){const t=me(e);t&&(ci=[t,...ci.filter(n=>n!==t)].slice(0,mg),ui.forEach(n=>n()))}function pg(e){return ui.add(e),()=>{ui.delete(e)}}function ir(e){const t=me(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 vt(e,t,n){const r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function zo({r:e,g:t,b:n}){const r=e/255,i=t/255,a=n/255,l=Math.max(r,i,a),c=Math.min(r,i,a),m=l-c;let p=0;return m!==0&&(l===r?p=(i-a)/m%6:l===i?p=(a-r)/m+2:p=(r-i)/m+4,p*=60,p<0&&(p+=360)),{h:p,s:l===0?0:m/l,v:l}}function Oo({h:e,s:t,v:n}){const r=(e%360+360)%360,i=n*t,a=i*(1-Math.abs(r/60%2-1)),l=n-i;let c=0,m=0,p=0;return r<60?(c=i,m=a):r<120?(c=a,m=i):r<180?(m=i,p=a):r<240?(m=a,p=i):r<300?(c=a,p=i):(c=i,p=a),{r:Math.round((c+l)*255),g:Math.round((m+l)*255),b:Math.round((p+l)*255)}}function Ac(){return typeof window<"u"&&"EyeDropper"in window}async function hg(){if(!Ac())return null;const e=window.EyeDropper;try{const t=await new e().open();return me(t.sRGBHex)}catch{return null}}const gg="_picker_ag1yo_1",bg="_none_ag1yo_12",yg="_customToggle_ag1yo_13",xg="_eyedrop_ag1yo_14",wg="_swatch_ag1yo_48",vg="_field_ag1yo_49",Sg="_grid_ag1yo_54",Cg="_recents_ag1yo_55",kg="_sectionLabel_ag1yo_84",Dg="_custom_ag1yo_13",Pg="_sv_ag1yo_95",Ag="_svThumb_ag1yo_105",jg="_hue_ag1yo_116",Eg="_rgbRow_ag1yo_155",Tg="_hexRow_ag1yo_156",xe={picker:gg,none:bg,customToggle:yg,eyedrop:xg,swatch:wg,field:vg,grid:Sg,recents:Cg,sectionLabel:kg,custom:Dg,sv:Pg,svThumb:Ag,hue:jg,rgbRow:Eg,hexRow:Tg};function Ng(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 Wi({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:i,menu:a=!1,fallbackCustom:l="#000000",onChange:c,onCommit:m}){const p=V(),b=s.useId(),h=a?"menuitemradio":"option",w=t?null:e,y=ir(w??l)??{r:0,g:0,b:0},[v,x]=s.useState(!1),[k,g]=s.useState(()=>zo(y)),[S,A]=s.useState(()=>({r:String(y.r),g:String(y.g),b:String(y.b)})),[N,E]=s.useState(()=>vt(y.r,y.g,y.b)),[L,M]=s.useState(()=>[...xl()]),I=s.useRef(null),j=s.useRef(vt(y.r,y.g,y.b));s.useEffect(()=>pg(()=>M([...xl()])),[]),s.useEffect(()=>{const D=ir(w??l);if(!D)return;const $=zo(D);g($),A({r:String(D.r),g:String(D.g),b:String(D.b)}),E(vt(D.r,D.g,D.b))},[w,l]);const T=(D,$,Y)=>{D&&(j.current=D),Y&&D&&fg(D),c(D),$&&(m==null||m(D))},P=(D,$,Y)=>{const B=vt(D.r,D.g,D.b);g(zo(D)),A({r:String(D.r),g:String(D.g),b:String(D.b)}),E(B),T(B,$,Y)},R=(D,$,Y)=>{const B=Oo(D),fe=vt(B.r,B.g,B.b);g(D),A({r:String(B.r),g:String(B.g),b:String(B.b)}),E(fe),T(fe,$,Y)},W=D=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(D.key))return;const Y=[...D.currentTarget.querySelectorAll("button")],B=Y.findIndex(we=>we===document.activeElement);if(B<0)return;D.preventDefault();const fe=D.key==="ArrowLeft"?-1:D.key==="ArrowRight"?1:D.key==="ArrowUp"?-bl:bl,ue=Y[Math.max(0,Math.min(Y.length-1,B+fe))];ue==null||ue.focus()},O=(D,$)=>{const Y=I.current;if(!Y||i)return;const B=Y.getBoundingClientRect(),fe=Math.max(0,Math.min(1,(D.clientX-B.left)/B.width)),ue=Math.max(0,Math.min(1,1-(D.clientY-B.top)/B.height));R({h:k.h,s:fe,v:ue},$,$)},Z=D=>{i||(D.currentTarget.setPointerCapture(D.pointerId),O(D,!1))},te=Oo({h:k.h,s:1,v:1}),ce=vt(te.r,te.g,te.b),re=Oo(k),he=vt(re.r,re.g,re.b),ne=new Set(yl),Q=L.filter(D=>!ne.has(D));return o.jsxs("div",{className:xe.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[o.jsx("button",{type:"button",className:xe.none,role:h,"aria-checked":a?w===null&&!t:void 0,"aria-selected":a?void 0:w===null&&!t,disabled:i,onClick:()=>T(null,!0,!1),children:n}),o.jsx("div",{className:xe.grid,role:a?"group":"none",onKeyDown:W,children:yl.map(D=>{const $=w===D;return o.jsx("button",{type:"button",className:xe.swatch,role:h,"aria-label":D,"aria-checked":a?$:void 0,"aria-selected":a?void 0:$,disabled:i,style:{backgroundColor:D},onMouseDown:Y=>Y.preventDefault(),onClick:()=>T(D,!0,!1)},D)})}),Q.length>0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:xe.sectionLabel,children:p("colorRecent")}),o.jsx("div",{className:xe.recents,role:a?"group":"none","aria-label":p("colorRecent"),children:Q.map(D=>o.jsx("button",{type:"button",className:xe.swatch,role:h,"aria-label":D,"aria-checked":a?w===D:void 0,"aria-selected":a?void 0:w===D,disabled:i,style:{backgroundColor:D},onMouseDown:$=>$.preventDefault(),onClick:()=>T(D,!0,!1)},D))})]}):null,o.jsx("button",{type:"button",className:xe.customToggle,disabled:i,"aria-expanded":v,onClick:()=>x(D=>!D),children:p("colorCustom")}),v?o.jsxs("div",{className:xe.custom,children:[o.jsx("div",{ref:I,className:xe.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${ce})`},onPointerDown:Z,onPointerMove:D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&O(D,!1)},onPointerUp:D=>{O(D,!0)},children:o.jsx("span",{className:xe.svThumb,style:{left:`${k.s*100}%`,top:`${(1-k.v)*100}%`}})}),o.jsx("input",{className:xe.hue,type:"range",min:0,max:360,value:Math.round(k.h),disabled:i,"aria-label":p("colorCustom"),onChange:D=>R({...k,h:Number(D.target.value)},!1,!1),onPointerUp:()=>T(j.current,!0,!0)}),o.jsx("div",{className:xe.rgbRow,children:["r","g","b"].map(D=>o.jsxs("div",{className:xe.field,children:[o.jsx("label",{htmlFor:`${b}-${D}`,children:p(D==="r"?"colorRgbR":D==="g"?"colorRgbG":"colorRgbB")}),o.jsx("input",{id:`${b}-${D}`,inputMode:"numeric",value:S[D],disabled:i,onChange:$=>{A(Y=>({...Y,[D]:$.target.value}))},onBlur:()=>{const $=Ng(S[D]);if($===null){A({r:String(re.r),g:String(re.g),b:String(re.b)});return}P({...re,[D]:$},!0,!0)},onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}})]},D))}),o.jsx("div",{className:xe.hexRow,children:o.jsxs("div",{className:xe.field,children:[o.jsx("label",{htmlFor:`${b}-hex`,children:p("colorHex")}),o.jsx("input",{id:`${b}-hex`,value:N,disabled:i,onChange:D=>E(D.target.value),onBlur:()=>{const D=me(N);if(!D){E(he);return}const $=ir(D);$&&P($,!0,!0)},onKeyDown:D=>{D.key==="Enter"&&D.currentTarget.blur()}})]})}),Ac()?o.jsx("button",{type:"button",className:xe.eyedrop,disabled:i,onClick:()=>{hg().then(D=>{if(!D)return;const $=ir(D);$&&P($,!0,!0)})},children:p("colorPickFromScreen")}):null]}):null]})}const Lg="_wrap_xzhkl_1",Mg="_button_xzhkl_8",Rg="_icon_xzhkl_18",_g="_bar_xzhkl_24",Ig="_barEmpty_xzhkl_33",Fg="_popover_xzhkl_43",St={wrap:Lg,button:Mg,icon:Rg,bar:_g,barEmpty:Ig,popover:Fg},Bg="_field_1knrr_1",Hg="_label_1knrr_8",zg="_button_1knrr_12",Og="_swatch_1knrr_37",Kg="_swatchEmpty_1knrr_44",mn={field:Bg,label:Hg,button:zg,swatch:Og,swatchEmpty:Kg},ar=4;function Fe({label:e,noneLabel:t,value:n,mixed:r=!1,disabled:i,fallbackCustom:a,onChange:l}){const c=s.useId(),m=s.useRef(null),p=s.useRef(null),b=s.useRef(null),[h,w]=s.useState(!1),[y,v]=s.useState({top:0,left:0}),x=s.useCallback(()=>{const S=p.current,A=b.current;if(!S)return;const N=S.getBoundingClientRect(),E=(A==null?void 0:A.offsetHeight)??0,L=(A==null?void 0:A.offsetWidth)??240;let M=N.bottom;M+E>window.innerHeight-ar&&(M=Math.max(ar,N.top-E));const I=Math.min(Math.max(N.left,ar),window.innerWidth-L-ar);v({top:M,left:I})},[]);s.useLayoutEffect(()=>{if(!h)return;x();const S=()=>x();return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[h,x]),s.useEffect(()=>{if(!h)return;const S=N=>{var L,M;const E=N.target;(L=m.current)!=null&&L.contains(E)||(M=b.current)!=null&&M.contains(E)||w(!1)},A=N=>{var E;N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),w(!1),(E=p.current)==null||E.focus())};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",A,!0)}},[h]);const k=`${mn.swatch}${!n||r?` ${mn.swatchEmpty}`:""}`,g=n&&!r?{backgroundColor:n}:void 0;return o.jsxs("div",{className:mn.field,ref:m,children:[o.jsx("span",{className:mn.label,children:e}),o.jsx("button",{ref:p,type:"button",className:mn.button,"aria-label":e,"aria-haspopup":"listbox","aria-expanded":h,"aria-controls":h?c:void 0,disabled:i,onClick:()=>w(S=>!S),children:o.jsx("span",{className:k,style:g})}),h?o.jsx(ie,{children:o.jsx("div",{ref:b,id:c,className:St.popover,style:{top:y.top,left:y.left,zIndex:1400},children:o.jsx(Wi,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:i,fallbackCustom:a,onChange:l,onCommit:()=>w(!1)})})}):null]})}const Ko=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],$g="_toolbar_2uk4l_1",Ug="_menuBar_2uk4l_35",Wg="_menuBarDesktop_2uk4l_43",Gg="_brandMark_2uk4l_49",Vg="_brandMarkIcon_2uk4l_56",qg="_menuBarCompact_2uk4l_68",Xg="_menuWrap_2uk4l_91",Yg="_menuButton_2uk4l_97",Jg="_iconButton_2uk4l_98",Zg="_menuItem_2uk4l_99",Qg="_hamburgerButton_2uk4l_142",eb="_iconNav_2uk4l_149",tb="_iconNavMain_2uk4l_160",nb="_iconNavEnd_2uk4l_169",rb="_iconGroup_2uk4l_185",ob="_tooltipTrigger_2uk4l_276",ib="_menu_2uk4l_35",ab="_submenuWrap_2uk4l_304",lb="_submenu_2uk4l_304",sb="_submenuTrigger_2uk4l_314",cb="_menuOverlay_2uk4l_329",ub="_menuOverlayHeader_2uk4l_341",db="_menuOverlayTitle_2uk4l_351",mb="_menuOverlayBody_2uk4l_357",fb="_menuSeparator_2uk4l_408",pb="_icon_2uk4l_98",hb="_tooltip_2uk4l_276",gb="_tooltipElevated_2uk4l_493",X={toolbar:$g,menuBar:Ug,menuBarDesktop:Wg,brandMark:Gg,brandMarkIcon:Vg,menuBarCompact:qg,menuWrap:Xg,menuButton:Yg,iconButton:Jg,menuItem:Zg,hamburgerButton:Qg,iconNav:eb,iconNavMain:tb,iconNavEnd:nb,iconGroup:rb,tooltipTrigger:ob,menu:ib,submenuWrap:ab,submenu:lb,submenuTrigger:sb,menuOverlay:cb,menuOverlayHeader:ub,menuOverlayTitle:db,menuOverlayBody:mb,menuSeparator:fb,icon:pb,tooltip:hb,tooltipElevated:gb},bb=400,wl=6,$o=4;function mt({label:e,children:t,className:n,elevated:r}){const i=s.useRef(null),a=s.useRef(null),l=s.useRef(null),c=s.useRef(!1),m=s.useRef(!1),[p,b]=s.useState(!1),[h,w]=s.useState({top:0,left:0}),y=s.useCallback(()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)},[]),v=s.useCallback(g=>{if(!(c.current||m.current)){y(),b(!1);return}if(g||m.current){y(),b(!0);return}y(),l.current=setTimeout(()=>{l.current=null,b(!0)},bb)},[y]),x=s.useCallback(()=>{const g=i.current,S=a.current;if(!g||!S)return;const A=g.getBoundingClientRect(),N=S.offsetWidth,E=S.offsetHeight;let L=A.bottom+wl;L+E>window.innerHeight-$o&&(L=A.top-wl-E);let M=A.left+A.width/2-N/2;M=Math.min(Math.max(M,$o),window.innerWidth-N-$o),w({top:L,left:M})},[]);s.useEffect(()=>()=>y(),[y]),s.useEffect(()=>{const g=i.current;if(!g)return;const S=()=>{m.current=!0,v(!0)},A=()=>{m.current=!1,v(!1)};return g.addEventListener("focusin",S),g.addEventListener("focusout",A),()=>{g.removeEventListener("focusin",S),g.removeEventListener("focusout",A)}},[v]),s.useLayoutEffect(()=>{if(!p)return;x();const g=()=>x();return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[p,e,x]);const k=n?`${X.tooltipTrigger} ${n}`:X.tooltipTrigger;return o.jsxs(o.Fragment,{children:[o.jsx("span",{ref:i,className:k,"data-tooltip-trigger":"",onMouseEnter:()=>{c.current=!0,v(!1)},onMouseLeave:()=>{c.current=!1,v(!1)},children:t}),p?o.jsx(ie,{children:o.jsx("span",{ref:a,className:r?`${X.tooltip} ${X.tooltipElevated}`:X.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const yb="_wrap_1097y_1",xb="_wrapToolbar_1097y_7",wb="_field_1097y_12",vb="_trigger_1097y_20",Sb="_chevron_1097y_50",Cb="_list_1097y_73",kb="_listInline_1097y_88",Db="_option_1097y_96",Pb="_separator_1097y_125",$e={wrap:yb,wrapToolbar:xb,field:wb,trigger:vb,chevron:Sb,list:Cb,listInline:kb,option:Db,separator:Pb};function Ab({value:e,mixed:t=!1,fonts:n,disabled:r,listId:i,listRef:a,inline:l,style:c,onSelect:m}){const p=V(),b=!t&&e===null;return o.jsxs("ul",{ref:a,id:i,className:l?`${$e.list} ${$e.listInline}`:$e.list,role:"listbox","aria-label":p("commandFontFamilyAria"),style:c,children:[o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:$e.option,role:"option","aria-checked":b,disabled:r,onMouseDown:h=>h.preventDefault(),onClick:()=>m(null),children:p("fontFamilyDefault")})}),o.jsx("li",{className:$e.separator,role:"separator"}),n.map(h=>{const w=!t&&kn(e,h.family);return o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:$e.option,role:"option","aria-checked":w,disabled:r,style:{fontFamily:h.family},onMouseDown:y=>y.preventDefault(),onClick:()=>m(h.family),children:h.name})},h.family)})]})}function jb(e,t,n,r){var i;return t?"":e===null?r:((i=md(e,n))==null?void 0:i.name)??e}const lr=4;function jc({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:i,toolbar:a=!1,triggerId:l,onChange:c}){const m=V(),p=s.useId(),b=s.useRef(null),h=s.useRef(null),w=s.useRef(null),[y,v]=s.useState(!1),[x,k]=s.useState({top:0,left:0,width:0}),g=jb(e,t,n,m("fontFamilyDefault")),S=s.useCallback(()=>{const N=h.current,E=w.current;if(!N)return;const L=N.getBoundingClientRect(),M=(E==null?void 0:E.offsetHeight)??0,I=Math.max(L.width,(E==null?void 0:E.offsetWidth)??0);let j=L.bottom;j+M>window.innerHeight-lr&&(j=Math.max(lr,L.top-M));const T=Math.min(Math.max(L.left,lr),window.innerWidth-I-lr);k({top:j,left:T,width:I})},[]);s.useLayoutEffect(()=>{if(!y)return;S();const N=()=>S();return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[y,S,n.length]),s.useEffect(()=>{if(!y)return;const N=L=>{var I,j;const M=L.target;(I=b.current)!=null&&I.contains(M)||(j=w.current)!=null&&j.contains(M)||v(!1)},E=L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),v(!1))};return document.addEventListener("pointerdown",N),document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",E,!0)}},[y]);const A=o.jsxs("div",{className:`${$e.wrap}${a?` ${$e.wrapToolbar}`:""}`,ref:b,children:[o.jsxs("div",{className:$e.field,ref:h,children:[o.jsx("button",{type:"button",id:l,className:$e.trigger,disabled:r,"aria-label":a?m("commandFontFamilyAria"):void 0,"aria-haspopup":"listbox","aria-expanded":y,"aria-controls":y?p:void 0,style:e&&!t?{fontFamily:e}:void 0,onMouseDown:N=>N.preventDefault(),onClick:()=>v(N=>!N),children:g}),o.jsx("span",{className:$e.chevron,"aria-hidden":"true"})]}),y?o.jsx(ie,{children:o.jsx(Ab,{listRef:w,listId:p,value:t?null:e,mixed:t,fonts:n,disabled:r,style:{top:x.top,left:x.left,minWidth:x.width},onSelect:N=>{c(N),v(!1)}})}):null]});return i?o.jsx(mt,{label:i,children:A}):A}function Eb({commands:e,queries:t,disabled:n}){const r=V(),i=!!(n||!t.isVisualMode());return o.jsx(jc,{family:t.isFontFamilyMixed()?null:t.getFontFamily(),mixed:t.isFontFamilyMixed(),fonts:t.getFontFaces(),disabled:i,tooltip:r("commandFontFamily"),toolbar:!0,onChange:a=>{e.setFontFamily(a)}})}const Tb="_wrap_192bz_1",Nb="_wrapToolbar_192bz_9",Lb="_field_192bz_14",Mb="_input_192bz_22",Rb="_toggle_192bz_41",_b="_chevron_192bz_42",Ib="_unit_192bz_80",Fb="_list_192bz_110",Bb="_option_192bz_125",pe={wrap:Tb,wrapToolbar:Nb,field:Lb,input:Mb,toggle:Rb,chevron:_b,unit:Ib,list:Fb,option:Bb},sr=4,Hb={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Ec({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:i,tooltip:a,sizeInputId:l,toolbar:c=!1}){const m=V(),p=s.useId(),b=s.useRef(null),h=s.useRef(null),w=s.useRef(null),[y,v]=s.useState(()=>e===null?"":J(e)),[x,k]=s.useState(!1),[g,S]=s.useState(!1),[A,N]=s.useState({top:0,left:0,width:0});s.useEffect(()=>{x||v(e===null?"":J(e))},[e,x]);const E=s.useCallback(()=>{const T=h.current,P=w.current;if(!T)return;const R=T.getBoundingClientRect(),W=(P==null?void 0:P.offsetHeight)??0;let O=R.bottom;O+W>window.innerHeight-sr&&(O=Math.max(sr,R.top-W));const Z=Math.min(Math.max(R.left,sr),window.innerWidth-Math.max(R.width,72)-sr);N({top:O,left:Z,width:R.width})},[]);s.useLayoutEffect(()=>{if(!g)return;E();const T=()=>E();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[g,E]),s.useEffect(()=>{if(!g)return;const T=R=>{var O,Z;const W=R.target;(O=b.current)!=null&&O.contains(W)||(Z=w.current)!=null&&Z.contains(W)||S(!1)},P=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",P,!0)}},[g]);const L=T=>{const P=qd(T,t);if(!P){v(e===null?"":J(e));return}n(P.value,P.unit),v(J(P.value))},M=Ud[t],I=g?o.jsx(ie,{children:o.jsx("ul",{ref:w,className:pe.list,role:"listbox",id:p,style:{top:A.top,left:A.left,minWidth:A.width},children:M.map(T=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:pe.option,role:"option","aria-selected":e===T,onMouseDown:P=>P.preventDefault(),onClick:()=>{n(T,t),v(J(T)),S(!1)},children:J(T)})},T))})}):null,j=o.jsxs("div",{className:`${pe.wrap}${c?` ${pe.wrapToolbar}`:""}`,ref:b,children:[o.jsxs("div",{className:pe.field,ref:h,children:[o.jsx("input",{id:l,className:pe.input,value:y,disabled:i,"aria-label":m("commandFontSizeAria"),"aria-autocomplete":"list","aria-expanded":g,"aria-controls":p,role:"combobox",inputMode:"decimal",onFocus:()=>k(!0),onBlur:()=>{k(!1),L(y)},onChange:T=>v(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),L(y),S(!1),T.currentTarget.blur()),T.key==="ArrowDown"&&(T.preventDefault(),S(!0))}}),o.jsx("button",{type:"button",className:pe.toggle,tabIndex:-1,disabled:i,"aria-label":m("commandFontSizeAria"),"aria-expanded":g,"aria-controls":p,onMouseDown:T=>T.preventDefault(),onClick:()=>S(T=>!T)})]}),o.jsxs("div",{className:pe.field,children:[o.jsx("select",{className:pe.unit,value:t,disabled:i,"aria-label":m("commandFontSizeUnitAria"),onChange:T=>{r(T.target.value)},children:Ci.map(T=>o.jsx("option",{value:T,children:m(Hb[T])},T))}),o.jsx("span",{className:pe.chevron,"aria-hidden":"true"})]}),I]});return a?o.jsx(mt,{label:a,children:j}):j}const zb="_backdrop_mi7ap_1",Ob="_dialog_mi7ap_12",Kb="_dialogWide_mi7ap_28",$b="_header_mi7ap_32",Ub="_tabs_mi7ap_39",Wb="_tab_mi7ap_39",Gb="_body_mi7ap_71",Vb="_field_mi7ap_79",qb="_label_mi7ap_85",Xb="_sizeRow_mi7ap_89",Yb="_fileRow_mi7ap_95",Jb="_fileName_mi7ap_101",Zb="_marks_mi7ap_108",Qb="_mark_mi7ap_108",ey="_actions_mi7ap_123",ty="_actionsSpread_mi7ap_130",ny="_actionsEnd_mi7ap_134",ry="_headerRow_mi7ap_139",oy="_close_mi7ap_151",iy="_nameSection_mi7ap_168",ay="_nameInput_mi7ap_172",ly="_labelRow_mi7ap_189",sy="_help_mi7ap_195",cy="_textInput_mi7ap_213",uy="_fullSelect_mi7ap_225",dy="_error_mi7ap_229",my="_emptyHint_mi7ap_234",fy="_action_mi7ap_123",py="_textarea_mi7ap_245",hy="_actionDanger_mi7ap_259",gy="_confirmBody_mi7ap_265",by="_nestedPanel_mi7ap_273",yy="_spinnerWrap_mi7ap_284",xy="_spinner_mi7ap_284",wy="_actionPrimary_mi7ap_319",vy="_iconButton_mi7ap_333",Sy="_select_mi7ap_334",Cy="_lengthInput_mi7ap_335",ky="_lengthUnit_mi7ap_336",Dy="_group_mi7ap_344",Py="_nestedGroup_mi7ap_354",Ay="_subLabel_mi7ap_364",jy="_iconRow_mi7ap_368",Ey="_lengthField_mi7ap_400",Ty="_sideLabel_mi7ap_406",Ny="_lengthRow_mi7ap_410",Ly="_sideGrid_mi7ap_438",My="_shadowGrid_mi7ap_439",d={backdrop:zb,dialog:Ob,dialogWide:Kb,header:$b,tabs:Ub,tab:Wb,body:Gb,field:Vb,label:qb,sizeRow:Xb,fileRow:Yb,fileName:Jb,marks:Zb,mark:Qb,actions:ey,actionsSpread:ty,actionsEnd:ny,headerRow:ry,close:oy,nameSection:iy,nameInput:ay,labelRow:ly,help:sy,textInput:cy,fullSelect:uy,error:dy,emptyHint:my,action:fy,textarea:py,actionDanger:hy,confirmBody:gy,nestedPanel:by,spinnerWrap:yy,spinner:xy,actionPrimary:wy,iconButton:vy,select:Sy,lengthInput:Cy,lengthUnit:ky,group:Dy,nestedGroup:Py,subLabel:Ay,iconRow:jy,lengthField:Ey,sideLabel:Ty,lengthRow:Ny,sideGrid:Ly,shadowGrid:My},Ry={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Gi({tab:e,value:t,fonts:n,disabled:r,onTabChange:i,onChange:a}){const l=V(),c=s.useId(),m=s.useId(),p=n??ss(),b=Ko.find(h=>h.id===e)??Ko[0];return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":l("fontDialogTitle"),children:Ko.map(h=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":h.id===e,disabled:!h.implemented,onClick:()=>i(h.id),children:l(h.labelKey)},h.id))}),o.jsx("div",{className:d.body,role:"tabpanel",children:b.implemented?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("fontDialogFamily")}),o.jsx(jc,{family:t.fontFamilyMixed?null:t.fontFamily,mixed:t.fontFamilyMixed,fonts:p,disabled:r,triggerId:m,onChange:h=>{a({...t,fontFamily:h,fontFamilyMixed:!1})}})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:l("fontDialogSize")}),o.jsx("div",{className:d.sizeRow,children:o.jsx(Ec,{size:t.size,unit:t.unit,sizeInputId:c,disabled:r,onSizeChange:(h,w)=>{a({...t,size:h,unit:w})},onUnitChange:h=>{const w=t.size!==null?ms(t.size,t.unit,h,16,16):t.size;a({...t,size:w,unit:h})}})})]}),o.jsx("div",{className:d.field,children:o.jsx(Fe,{label:l("commandFontColor"),noneLabel:l("colorAutomatic"),value:t.fontColor,mixed:t.fontColorMixed,disabled:r,onChange:h=>{a({...t,fontColor:h,fontColorMixed:!1})}})}),o.jsx("div",{className:d.field,children:o.jsx(Fe,{label:l("commandHighlightColor"),noneLabel:l("colorNone"),value:t.highlightColor,mixed:t.highlightColorMixed,disabled:r,fallbackCustom:"#ffff00",onChange:h=>{a({...t,highlightColor:h,highlightColorMixed:!1})}})}),o.jsxs("fieldset",{className:d.marks,children:[o.jsx("legend",{className:d.label,children:l("fontDialogStyle")}),Ue.map(h=>o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.marks[h],disabled:r,onChange:()=>{a({...t,marks:{...t.marks,[h]:!t.marks[h]}})}}),l(Ry[h].label)]},h))]})]}):null})]})}const vl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function _y({open:e,tab:t,size:n,unit:r,marks:i,fontFamily:a=null,fontFamilyMixed:l=!1,fontColor:c,fontColorMixed:m=!1,highlightColor:p,highlightColorMixed:b=!1,fonts:h,disabled:w,onTabChange:y,onApply:v,onClose:x}){const k=V(),g=s.useId(),S=s.useRef(null),[A,N]=s.useState({size:n,unit:r,marks:i,fontFamily:a,fontFamilyMixed:l,fontColor:c,highlightColor:p,fontColorMixed:m,highlightColorMixed:b});return s.useEffect(()=>{e&&N({size:n,unit:r,marks:i,fontFamily:a,fontFamilyMixed:l,fontColor:c,highlightColor:p,fontColorMixed:m,highlightColorMixed:b})},[e,n,r,i,a,l,c,m,p,b]),s.useEffect(()=>{if(!e)return;const E=S.current,L=E==null?void 0:E.querySelector(vl);L==null||L.focus();const M=I=>{if(I.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;I.preventDefault(),I.stopPropagation(),x();return}if(I.key!=="Tab"||!E)return;const j=[...E.querySelectorAll(vl)];if(j.length===0)return;const T=j[0],P=j[j.length-1];I.shiftKey&&document.activeElement===T?(I.preventDefault(),P.focus()):!I.shiftKey&&document.activeElement===P&&(I.preventDefault(),T.focus())};return document.addEventListener("keydown",M,!0),()=>document.removeEventListener("keydown",M,!0)},[e,x]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:x,children:o.jsxs("div",{ref:S,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":g,onMouseDown:E=>E.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:g,children:k("fontDialogTitle")}),o.jsx(Gi,{tab:t,value:A,fonts:h,disabled:w,onTabChange:y,onChange:N}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:x,children:k("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:w,onClick:()=>v(A),children:k("fontDialogOk")})]})]})})}):null}const Iy={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function ge({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:i,inputId:a,onChange:l}){const c=V(),m=s.useId(),p=a??m,b=(t==null?void 0:t.unit)??zs,[h,w]=s.useState(()=>t?J(t.value):""),[y,v]=s.useState(!1);s.useEffect(()=>{y||w(t?J(t.value):"")},[t,y]);const x=k=>{const g=k.trim();if(!g){l(null),w("");return}const S=Sr(g,b,r);if(!S){w(t?J(t.value):"");return}l(S),w(J(S.value))};return o.jsxs("div",{className:d.lengthField,children:[o.jsx("label",{className:d.sideLabel,htmlFor:p,children:e}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:p,className:d.lengthInput,value:h,disabled:n,inputMode:"decimal",onFocus:()=>v(!0),onBlur:()=>{v(!1),x(h)},onChange:k=>w(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),x(h),k.currentTarget.blur())}}),o.jsx("select",{className:d.lengthUnit,value:b,disabled:n,"aria-label":i??c("paragraphDialogLengthUnitAria"),onChange:k=>{const g=k.target.value;if(t){l({value:t.value,unit:g});return}if(h.trim()){const S=Sr(h,g,r);l(S)}},children:Ci.map(k=>o.jsx("option",{value:k,children:c(Iy[k])},k))})]})]})}function Vi({shadow:e,disabled:t,onChange:n}){const r=V();return o.jsxs("div",{className:d.shadowGrid,children:[o.jsx(ge,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:i=>{n({...e,offsetX:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:i=>{n({...e,offsetY:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:i=>{n({...e,blur:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:i=>{n({...e,spread:i??{value:0,unit:"px"}})}}),o.jsx(Fe,{label:r("paragraphDialogShadowColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:i=>{n({...e,color:i})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:e.inset,disabled:t,onChange:()=>{n({...e,inset:!e.inset})}}),r("paragraphDialogShadowInset")]})]})}const Sl=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0}],Fy={left:hi,center:pi,right:gi,justify:Wl},By={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},Hy={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},zy={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Oy={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},Ky={value:1,unit:"pt"},$y={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 fn(e){return{top:e,right:e,bottom:e,left:e}}function Cl(e){for(const t of Xe)if(e[t])return e[t];return null}function qi({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:i="paragraphDialogTitle",onTabChange:a,onChange:l}){const c=V(),m=r?Sl.filter(x=>r.includes(x.id)):Sl,p=s.useId(),[b,h]=s.useState(()=>nt(t.margin,fn(t.margin.top))),[w,y]=s.useState(()=>nt(t.padding,fn(t.padding.top))),v=(x,k,g,S)=>{const A=t[x],N=k?fn(S):{...A,[g]:S};l({...t,[x]:N,[`${x}Mixed`]:!1})};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":c(i),children:m.map(x=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":x.id===e,disabled:!x.implemented,onClick:()=>a(x.id),children:c(x.labelKey)},x.id))}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[e==="general"?o.jsxs(o.Fragment,{children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogAlignment")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":c("paragraphDialogAlignment"),children:Js.map(x=>{const k=Fy[x],g=!t.alignMixed&&t.align===x;return o.jsx("button",{type:"button",className:d.iconButton,role:"radio","aria-checked":g,"aria-label":c(By[x].aria),disabled:n,onClick:()=>{l({...t,align:x,alignMixed:!1})},children:o.jsx(k,{})},x)})})]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogLists")}),o.jsxs("div",{className:d.iconRow,children:[o.jsx("button",{type:"button",className:d.iconButton,"aria-pressed":!t.listMixed&&t.list==="ul","aria-label":c("commandBulletListAria"),disabled:n,onClick:()=>{const x=!t.listMixed&&t.list==="ul"?null:"ul";l({...t,list:x,listMixed:!1})},children:o.jsx(Gl,{})}),o.jsx("button",{type:"button",className:d.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":c("commandNumberedListAria"),disabled:n,onClick:()=>{const x=!t.listMixed&&t.list==="ol"?null:"ol";l({...t,list:x,listMixed:!1})},children:o.jsx(Yl,{})})]})]})]}):null,e==="spacing"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogSpacing")}),o.jsx(kl,{legend:c("paragraphDialogMargin"),sides:t.margin,linked:b,disabled:n,allowNegative:!0,onLinkedChange:x=>{h(x),x&&l({...t,margin:fn(Cl(t.margin)),marginMixed:!1})},onSideChange:(x,k)=>v("margin",b,x,k)}),o.jsx(kl,{legend:c("paragraphDialogPadding"),sides:t.padding,linked:w,disabled:n,onLinkedChange:x=>{y(x),x&&l({...t,padding:fn(Cl(t.padding)),paddingMixed:!1})},onSideChange:(x,k)=>v("padding",w,x,k)}),o.jsx(Wy,{value:t.lineHeight,disabled:n,onChange:x=>{l({...t,lineHeight:x,lineHeightMixed:!1})}})]}):null,e==="border"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:c("paragraphDialogBorderStyle")}),o.jsx("select",{id:p,className:d.select,value:t.border.style,disabled:n,onChange:x=>{const k=x.target.value;l({...t,border:{style:k,width:k==="none"?null:t.border.width??Ky,color:k==="none"?null:t.border.color},borderMixed:!1})},children:Lr.map(x=>o.jsx("option",{value:x,children:c(zy[x])},x))})]}),t.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:c("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:x=>{l({...t,border:{...t.border,width:x},borderMixed:!1})}}),o.jsx(Fe,{label:c("paragraphDialogBorderColor"),noneLabel:c("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:x=>{l({...t,border:{...t.border,color:x},borderMixed:!1})}})]}):null,o.jsx(ge,{label:c("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:x=>{l({...t,borderRadius:x,radiusMixed:!1})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:n,onChange:()=>{l({...t,boxShadow:t.boxShadow?null:$y,shadowMixed:!1})}}),c("paragraphDialogBoxShadow")]}),t.boxShadow?o.jsx(Vi,{shadow:t.boxShadow,disabled:n,onChange:x=>{l({...t,boxShadow:x,shadowMixed:!1})}}):null]}):null,e==="background"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogTabBackground")}),o.jsx(Fe,{label:c("paragraphDialogBackgroundColor"),noneLabel:c("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:x=>{l({...t,backgroundColor:x,backgroundMixed:!1})}}),o.jsx(Uy,{value:t.opacity,disabled:n,onChange:x=>{l({...t,opacity:x,opacityMixed:!1})}})]}):null]})]})}function Uy({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=e===null?null:Cr(e),[l,c]=s.useState(()=>a===null?"":J(a)),[m,p]=s.useState(!1);s.useEffect(()=>{m||c(a===null?"":J(a))},[a,m]);const b=h=>{const w=h.trim();if(!w){n(null),c("");return}const y=Number(w.replace(",","."));if(!Number.isFinite(y)){c(a===null?"":J(a));return}const v=Us(y);n(v),c(J(Cr(v)))};return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogOpacity")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:l,disabled:t,inputMode:"decimal",onFocus:()=>p(!0),onChange:h=>c(h.target.value),onBlur:()=>{p(!1),b(l)}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}function kl({legend:e,sides:t,linked:n,disabled:r,allowNegative:i=!1,onLinkedChange:a,onSideChange:l}){const c=V(),m=n?["top"]:Xe;return o.jsxs("fieldset",{className:d.nestedGroup,children:[o.jsx("legend",{className:d.subLabel,children:e}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:()=>a(!n)}),c("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:m.map(p=>o.jsx(ge,{label:n?e:c(Hy[p]),value:t[p],disabled:r,allowNegative:i,onChange:b=>l(p,b)},p))})]})}function Wy({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=Gy(e),l=(e==null?void 0:e.kind)==="number"||(e==null?void 0:e.kind)==="length"?e.value:null,[c,m]=s.useState(()=>l===null?"":J(l)),p=(e==null?void 0:e.kind)==="length"?e.unit:zs;return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogLineHeight")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:a==="normal"?"":c,disabled:t||a==="normal",inputMode:"decimal",onChange:b=>m(b.target.value),onBlur:()=>{const b=c.trim();if(!b){n(null);return}if(a==="number"||a==="empty"){const w=Number(b.replace(",","."));if(!Number.isFinite(w)||w<0){m(l===null?"":J(l));return}n({kind:"number",value:w}),m(J(w));return}const h=Sr(b,p,!1);if(!h){m(l===null?"":J(l));return}n({kind:"length",value:h.value,unit:h.unit}),m(J(h.value))}}),o.jsxs("select",{className:d.lengthUnit,value:a==="length"?p:a,disabled:t,"aria-label":r("paragraphDialogLengthUnitAria"),onChange:b=>{const h=b.target.value;if(h==="empty"){n(null),m("");return}if(h==="normal"){n({kind:"normal"}),m("");return}if(h==="number"){const x=Number((c||"1.5").replace(",",".")),k=Number.isFinite(x)&&x>=0?x:1.5;n({kind:"number",value:k}),m(J(k));return}const w=h,y=Sr(c||"1",w,!1),v=(y==null?void 0:y.value)??1;n({kind:"length",value:v,unit:w}),m(J(v))},children:[o.jsx("option",{value:"empty"}),o.jsx("option",{value:"normal",children:r("paragraphDialogLineHeightNormal")}),o.jsx("option",{value:"number",children:r("paragraphDialogLineHeightUnitless")}),["pt","px","em","rem","%"].map(b=>o.jsx("option",{value:b,children:r(Oy[b])},b))]})]})]})}function Gy(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}const Dl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function Vy({open:e,tab:t,value:n,disabled:r,onTabChange:i,onApply:a,onClose:l}){const c=V(),m=s.useId(),p=s.useRef(null),[b,h]=s.useState(n);return s.useEffect(()=>{e&&h(n)},[e,n]),s.useEffect(()=>{if(!e)return;const w=p.current,y=w==null?void 0:w.querySelector(Dl);y==null||y.focus();const v=x=>{if(x.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;x.preventDefault(),x.stopPropagation(),l();return}if(x.key!=="Tab"||!w)return;const k=[...w.querySelectorAll(Dl)];if(k.length===0)return;const g=k[0],S=k[k.length-1];x.shiftKey&&document.activeElement===g?(x.preventDefault(),S.focus()):!x.shiftKey&&document.activeElement===S&&(x.preventDefault(),g.focus())};return document.addEventListener("keydown",v,!0),()=>document.removeEventListener("keydown",v,!0)},[e,l]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:l,children:o.jsxs("div",{ref:p,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":m,onMouseDown:w=>w.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:m,children:c("paragraphDialogTitle")}),o.jsx(qi,{tab:t,value:b,disabled:r,onTabChange:i,onChange:h}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:l,children:c("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:r,onClick:()=>a(b),children:c("fontDialogOk")})]})]})})}):null}const qy=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0}],Pl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])',Xy=qy.map(e=>e.id);function Yy(e){return{...hn(),...e}}function Jy(e){const{align:t,alignMixed:n,list:r,listMixed:i,...a}=e;return a}function Zy({open:e,tab:t,value:n,fonts:r,disabled:i,onTabChange:a,onApply:l,onClose:c}){const m=V(),p=s.useId(),b=s.useRef(null),[h,w]=s.useState("general"),[y,v]=s.useState("spacing"),[x,k]=s.useState(n.font),[g,S]=s.useState(n.box);if(s.useEffect(()=>{e&&(w("general"),v("spacing"),k(n.font),S(n.box))},[e,n]),s.useEffect(()=>{if(!e)return;const N=b.current,E=N==null?void 0:N.querySelector(Pl);E==null||E.focus();const L=M=>{if(M.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;M.preventDefault(),M.stopPropagation(),c();return}if(M.key!=="Tab"||!N)return;const I=[...N.querySelectorAll(Pl)];if(I.length===0)return;const j=I[0],T=I[I.length-1];M.shiftKey&&document.activeElement===j?(M.preventDefault(),T.focus()):!M.shiftKey&&document.activeElement===T&&(M.preventDefault(),j.focus())};return document.addEventListener("keydown",L,!0),()=>document.removeEventListener("keydown",L,!0)},[e,c]),!e)return null;const A=m("pageDialogTitle");return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:c,children:o.jsxs("div",{ref:b,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":p,onMouseDown:N=>N.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:p,children:A}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":A,children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="font",onClick:()=>a("font"),children:m("customStyleDialogTabFont")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="paragraph",onClick:()=>a("paragraph"),children:m("customStyleDialogTabParagraph")})]}),t==="font"?o.jsx("div",{className:d.nestedPanel,children:o.jsx(Gi,{tab:h,value:x,fonts:r,disabled:i,onTabChange:w,onChange:k})}):o.jsx("div",{className:d.nestedPanel,children:o.jsx(qi,{tab:y,value:Yy(g),disabled:i,tabs:Xy,tablistLabelKey:"pageDialogTitle",onTabChange:N=>{N!=="general"&&v(N)},onChange:N=>S(Jy(N))})}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:c,children:m("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:i,onClick:()=>l({font:x,box:g}),children:m("fontDialogOk")})]})]})})})}const Al='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function Qy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function jl(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 ex(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 tx({open:e,mode:t,styleId:n,name:r="",font:i,paragraph:a,canDelete:l=!1,busy:c,disabled:m,fonts:p,defaultOuterTab:b="font",onSave:h,onDelete:w,onClose:y}){const v=V(),x=s.useId(),k=s.useId(),g=s.useRef(null),[S,A]=s.useState(r),[N,E]=s.useState(b),[L,M]=s.useState("general"),[I,j]=s.useState("general"),[T,P]=s.useState(()=>jl(i)),[R,W]=s.useState(()=>ni(a)),[O,Z]=s.useState(!1);if(s.useEffect(()=>{e&&(A(r),E(b),M("general"),j("general"),P(jl(i)),W(ni(a)),Z(!1))},[e,r,i,a,b]),s.useEffect(()=>{if(!e)return;const ne=g.current,Q=ne==null?void 0:ne.querySelector(Al);Q==null||Q.focus();const D=$=>{if($.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;if($.preventDefault(),$.stopPropagation(),O){Z(!1);return}y();return}if($.key!=="Tab"||!ne)return;const Y=[...ne.querySelectorAll(Al)];if(Y.length===0)return;const B=Y[0],fe=Y[Y.length-1];$.shiftKey&&document.activeElement===B?($.preventDefault(),fe.focus()):!$.shiftKey&&document.activeElement===fe&&($.preventDefault(),B.focus())};return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[e,y,O]),!e)return null;const te=v(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),ce=S.trim().length>0,re=!!(m||c),he=()=>{const ne=S.trim();ne&&h({id:n??Qy(),name:ne,font:ex(T),paragraph:tc(R)})};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:y,children:o.jsxs("div",{ref:g,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":x,"aria-busy":c||void 0,onMouseDown:ne=>ne.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:x,children:te}),o.jsx("button",{type:"button",className:d.close,"aria-label":v("customStyleDialogCloseAria"),onClick:y,children:o.jsx(We,{})})]}),O?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.confirmBody,children:v("customStyleDialogDeleteConfirm")}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,disabled:re,onClick:()=>Z(!1),children:v("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionDanger}`,disabled:re||!n,onClick:()=>{n&&(w==null||w(n))},children:v("customStyleDialogDelete")})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.nameSection,children:o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:k,children:v("customStyleDialogName")}),o.jsx("input",{id:k,className:d.nameInput,value:S,disabled:re,onChange:ne=>A(ne.target.value)})]})}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":te,children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":N==="font",onClick:()=>E("font"),children:v("customStyleDialogTabFont")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":N==="paragraph",onClick:()=>E("paragraph"),children:v("customStyleDialogTabParagraph")})]}),N==="font"?o.jsx("div",{className:d.nestedPanel,children:o.jsx(Gi,{tab:L,value:T,fonts:p,disabled:re,onTabChange:M,onChange:P})}):o.jsx("div",{className:d.nestedPanel,children:o.jsx(qi,{tab:I,value:R,disabled:re,onTabChange:j,onChange:W})}),o.jsxs("div",{className:t==="edit"&&l?`${d.actions} ${d.actionsSpread}`:d.actions,children:[t==="edit"&&l?o.jsx("button",{type:"button",className:`${d.action} ${d.actionDanger}`,disabled:re,onClick:()=>Z(!0),children:v("customStyleDialogDelete")}):null,o.jsxs("div",{className:d.actionsEnd,children:[o.jsx("button",{type:"button",className:d.action,onClick:y,children:v("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:re||!ce,onClick:he,children:v("fontDialogOk")})]})]})]})]})})})}const El='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])',nx={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function rx({open:e,existingIds:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useId(),m=s.useId(),p=s.useRef(null),[b,h]=s.useState(""),[w,y]=s.useState(!1),v=s.useMemo(()=>new Set(t),[t]),x=ac(b,v);if(s.useEffect(()=>{e&&(h(""),y(!1))},[e]),s.useEffect(()=>{if(!e)return;const A=p.current,N=A==null?void 0:A.querySelector(El);N==null||N.focus();const E=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),i();return}if(L.key!=="Tab"||!A)return;const M=[...A.querySelectorAll(El)];if(M.length===0)return;const I=M[0],j=M[M.length-1];L.shiftKey&&document.activeElement===I?(L.preventDefault(),j.focus()):!L.shiftKey&&document.activeElement===j&&(L.preventDefault(),I.focus())};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[e,i]),!e)return null;const k=w||b.trim().length>0?x:null,g=x===null&&!n,S=()=>{y(!0),!(x||n)&&r(b.trim())};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:p,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:A=>A.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("bookmarkDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("bookmarkDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx("div",{className:d.body,children:o.jsxs("div",{className:d.field,children:[o.jsxs("div",{className:d.labelRow,children:[o.jsx("label",{className:d.label,htmlFor:c,children:a("bookmarkDialogName")}),o.jsx(mt,{label:a("bookmarkDialogHelp"),elevated:!0,children:o.jsx("button",{type:"button",className:d.help,"aria-label":a("bookmarkDialogHelpAria"),children:"?"})})]}),o.jsx("input",{id:c,className:d.textInput,value:b,disabled:n,"aria-invalid":k!==null,"aria-describedby":k?m:void 0,onChange:A=>h(A.target.value)}),k?o.jsx("p",{id:m,className:d.error,children:a(nx[k])}):null]})}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!g,onClick:S,children:a("fontDialogOk")})]})]})})})}const Tl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',ox={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},ix={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function ax({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:i,onClose:a}){const l=V(),c=s.useId(),m=s.useId(),p=s.useId(),b=s.useId(),h=s.useId(),w=s.useRef(null),y=s.useRef(null),[v,x]=s.useState("file"),[k,g]=s.useState(""),[S,A]=s.useState(""),[N,E]=s.useState(""),[L,M]=s.useState(""),[I,j]=s.useState(""),[T,P]=s.useState(null),[R,W]=s.useState(!1);if(s.useEffect(()=>{e&&(x("file"),g(""),A(""),E(""),M(""),j(""),P(null),W(!1),y.current&&(y.current.value=""))},[e]),s.useEffect(()=>{if(!e)return;const Q=w.current,D=Q==null?void 0:Q.querySelector(Tl);D==null||D.focus();const $=Y=>{if(Y.key==="Escape"){Y.preventDefault(),Y.stopPropagation(),a();return}if(Y.key!=="Tab"||!Q)return;const B=[...Q.querySelectorAll(Tl)];if(B.length===0)return;const fe=B[0],ue=B[B.length-1];Y.shiftKey&&document.activeElement===fe?(Y.preventDefault(),ue.focus()):!Y.shiftKey&&document.activeElement===ue&&(Y.preventDefault(),fe.focus())};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[e,a]),!e)return null;const O=v==="file"?S:v==="url"?k:"",Z=v==="custom"?null:Oi(O),te=v==="custom"?null:v==="file"&&T?ix[T]:Z&&(v==="file"||k.trim().length>0)?ox[Z]:null,ce=v!=="custom"&&Z===null&&!(v==="file"&&T)&&!t&&!R,re=()=>{t||!n||i==null||i()},he=()=>{ce&&r({src:O.trim(),alt:L.trim(),title:I.trim()})},ne=Q=>{var $;const D=($=Q.target.files)==null?void 0:$[0];D&&(W(!0),P(null),Cp(D).then(Y=>{A(Y),E(D.name),x("file"),W(!1)},Y=>{const B=Y instanceof Error?Y.message:"";A(""),E(""),x("file"),P(B==="tooLarge"||B==="type"?B:"type"),W(!1),y.current&&(y.current.value="")}))};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:a,children:o.jsxs("div",{ref:w,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":c,onMouseDown:Q=>Q.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:c,children:l("imageDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":l("imageDialogCloseAria"),onClick:a,children:o.jsx(We,{})})]}),o.jsxs("div",{className:d.body,children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.subLabel,children:l("imageDialogSource")}),o.jsxs("div",{className:d.sizeRow,role:"radiogroup","aria-label":l("imageDialogSource"),children:[o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="file",disabled:t,onClick:()=>x("file"),children:l("imageDialogFile")}),o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="url",disabled:t,onClick:()=>x("url"),children:l("imageDialogUrl")}),n?o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="custom",disabled:t,onClick:()=>x("custom"),children:n.text}):null]}),v==="file"?o.jsxs("div",{className:d.fileRow,children:[o.jsx("input",{ref:y,type:"file",accept:gp,hidden:!0,disabled:t,"aria-label":l("imageDialogChooseFile"),onChange:ne}),o.jsx("button",{type:"button",className:d.action,disabled:t||R,onClick:()=>{var Q;return(Q=y.current)==null?void 0:Q.click()},children:l("imageDialogChooseFile")}),N?o.jsx("span",{className:d.fileName,children:N}):null]}):null,v==="url"?o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("imageDialogUrl")}),o.jsx("input",{id:m,className:d.textInput,value:k,disabled:t,"aria-invalid":te!==null,"aria-describedby":te?h:void 0,onChange:Q=>g(Q.target.value)})]}):null,v==="custom"&&n?o.jsxs("div",{className:d.field,children:[o.jsx("p",{className:d.emptyHint,children:n.description}),o.jsx("button",{type:"button",className:d.action,disabled:t,onClick:re,children:n.buttonCaption})]}):null]}),v!=="custom"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:l("imageDialogAlt")}),o.jsx("input",{id:p,className:d.textInput,value:L,disabled:t,onChange:Q=>M(Q.target.value)})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:b,children:l("imageDialogTitleField")}),o.jsx("input",{id:b,className:d.textInput,value:I,disabled:t,onChange:Q=>j(Q.target.value)})]})]}):null,te?o.jsx("p",{id:h,className:d.error,children:l(te)}):null]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:a,children:l("fontDialogCancel")}),v!=="custom"?o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!ce,onClick:he,children:l("fontDialogOk")}):null]})]})})})}const cr=4,lx={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function Nl({label:e,inputAria:t,value:n,disabled:r,onChange:i}){const a=V(),l=s.useId(),c=s.useId(),m=s.useRef(null),p=s.useRef(null),b=s.useRef(null),h=(n==null?void 0:n.unit)??Op,[w,y]=s.useState(()=>n?J(n.value):""),[v,x]=s.useState(!1),[k,g]=s.useState(!1),[S,A]=s.useState({top:0,left:0,width:0});s.useEffect(()=>{v||y(n?J(n.value):"")},[n,v]);const N=s.useCallback(()=>{const j=p.current,T=b.current;if(!j)return;const P=j.getBoundingClientRect(),R=(T==null?void 0:T.offsetHeight)??0;let W=P.bottom;W+R>window.innerHeight-cr&&(W=Math.max(cr,P.top-R));const O=Math.min(Math.max(P.left,cr),window.innerWidth-Math.max(P.width,72)-cr);A({top:W,left:O,width:P.width})},[]);s.useLayoutEffect(()=>{if(!k)return;N();const j=()=>N();return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[k,N]),s.useEffect(()=>{if(!k)return;const j=P=>{var W,O;const R=P.target;(W=m.current)!=null&&W.contains(R)||(O=b.current)!=null&&O.contains(R)||g(!1)},T=P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),g(!1))};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",T,!0),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",T,!0)}},[k]);const E=j=>{const T=j.trim();if(!T){i(null),y("");return}const P=dl(T,h);if(!P){y(n?J(n.value):"");return}i(P),y(J(P.value))},L=Kp[h],M=(n==null?void 0:n.value)??null,I=k?o.jsx(ie,{children:o.jsx("ul",{ref:b,className:pe.list,role:"listbox",id:l,style:{top:S.top,left:S.left,minWidth:S.width},children:L.map(j=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:pe.option,role:"option","aria-selected":M===j,onMouseDown:T=>T.preventDefault(),onClick:()=>{i({value:j,unit:h}),y(J(j)),g(!1)},children:J(j)})},j))})}):null;return o.jsxs("div",{className:d.lengthField,children:[o.jsx("label",{className:d.sideLabel,htmlFor:c,children:e}),o.jsxs("div",{className:`${pe.wrap} ${d.lengthRow}`,ref:m,children:[o.jsxs("div",{className:pe.field,ref:p,children:[o.jsx("input",{id:c,className:pe.input,value:w,disabled:r,"aria-label":t,"aria-autocomplete":"list","aria-expanded":k,"aria-controls":l,role:"combobox",inputMode:"decimal",onFocus:()=>x(!0),onBlur:()=>{x(!1),E(w)},onChange:j=>y(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),E(w),g(!1),j.currentTarget.blur()),j.key==="ArrowDown"&&(j.preventDefault(),g(!0))}}),o.jsx("button",{type:"button",className:pe.toggle,tabIndex:-1,disabled:r,"aria-label":t,"aria-expanded":k,"aria-controls":l,onMouseDown:j=>j.preventDefault(),onClick:()=>g(j=>!j)})]}),o.jsxs("div",{className:pe.field,children:[o.jsx("select",{className:pe.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:j=>{const T=j.target.value;if(n){i({value:n.value,unit:T});return}w.trim()&&i(dl(w,T))},children:uc.map(j=>o.jsx("option",{value:j,children:a(lx[j])},j))}),o.jsx("span",{className:pe.chevron,"aria-hidden":"true"})]}),I]})]})}const sx=[{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}],cx={left:hi,center:pi,right:gi},ux=["left","center","right"],dx={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},mx=["width","height","lock"],fx={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},px={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},hx={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},gx={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},bx={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"},yx={value:1,unit:"pt"},xx={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 Uo(e){return{top:e,right:e,bottom:e,left:e}}function wx(e){for(const t of Xe)if(e[t])return e[t];return null}function vx({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:i,onChange:a}){const l=V(),c=s.useId(),m=s.useId(),p=s.useId(),b=s.useId(),h=s.useId(),[w,y]=s.useState(()=>nt(t.margin,Uo(t.margin.top))),v=t.align==="center",x=(g,S)=>{if(t.sizeMode==="lock"&&S){const A=gn(g,S,n);a({...t,width:A.width,height:A.height});return}a({...t,[g]:S})},k=g=>{if(g==="width"){a({...t,sizeMode:g,height:null});return}if(g==="height"){a({...t,sizeMode:g,width:null});return}if(t.width){const S=gn("width",t.width,n);a({...t,sizeMode:g,width:S.width,height:S.height});return}if(t.height){const S=gn("height",t.height,n);a({...t,sizeMode:g,width:S.width,height:S.height});return}a({...t,sizeMode:g})};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":l("imagePropertiesDialogTitle"),children:sx.map(g=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":g.id===e,disabled:!g.implemented,onClick:()=>i(g.id),children:l(g.labelKey)},g.id))}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[e==="general"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesSize")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":l("imagePropertiesSizeMode"),children:mx.map(g=>o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":t.sizeMode===g,disabled:r,onClick:()=>k(g),children:l(fx[g])},g))}),o.jsx(Nl,{label:l("imagePropertiesWidth"),inputAria:l("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:g=>x("width",g)}),o.jsx(Nl,{label:l("imagePropertiesHeight"),inputAria:l("imagePropertiesHeightAria"),value:t.height,disabled:r||t.sizeMode==="width",onChange:g=>x("height",g)})]}):null,e==="alignment"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogAlignment")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":l("paragraphDialogAlignment"),children:ux.map(g=>{const S=cx[g];return o.jsx("button",{type:"button",className:d.iconButton,role:"radio","aria-checked":t.align===g,"aria-label":l(dx[g]),disabled:r,onClick:()=>{a({...t,align:t.align===g?null:g})},children:o.jsx(S,{})},g)})})]}):null,e==="border"?o.jsxs(o.Fragment,{children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogMargin")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:w,disabled:r||v,onChange:()=>{const g=!w;y(g),g&&a({...t,margin:Uo(wx(t.margin))})}}),l("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(w?["top"]:Xe).map(g=>o.jsx(ge,{label:l(w?"paragraphDialogMargin":px[g]),value:t.margin[g],disabled:r||v&&(g==="left"||g==="right"),allowNegative:!0,onChange:S=>{const A=w?Uo(S):{...t.margin,[g]:S};a({...t,margin:A})}},g))})]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:l("paragraphDialogBorderStyle")}),o.jsx("select",{id:c,className:d.select,value:t.border.style,disabled:r,onChange:g=>{const S=g.target.value;a({...t,border:{style:S,width:S==="none"?null:t.border.width??yx,color:S==="none"?null:t.border.color}})},children:Lr.map(g=>o.jsx("option",{value:g,children:l(hx[g])},g))})]}),t.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:l("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:g=>{a({...t,border:{...t.border,width:g}})}}),o.jsx(Fe,{label:l("paragraphDialogBorderColor"),noneLabel:l("colorNone"),value:t.border.color,disabled:r,onChange:g=>{a({...t,border:{...t.border,color:g}})}})]}):null,o.jsx(ge,{label:l("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:r,onChange:g=>{a({...t,borderRadius:g})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:r,onChange:()=>{a({...t,boxShadow:t.boxShadow?null:xx})}}),l("paragraphDialogBoxShadow")]}),t.boxShadow?o.jsx(Vi,{shadow:t.boxShadow,disabled:r,onChange:g=>{a({...t,boxShadow:g})}}):null]})]}):null,e==="advanced"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesTabAdvanced")}),o.jsx(Sx,{value:t.opacity,disabled:r,onChange:g=>{a({...t,opacity:g})}}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("imagePropertiesFit")}),o.jsxs("select",{id:m,className:d.select,value:t.objectFit??"",disabled:r,onChange:g=>{const S=g.target.value;a(Zp({...t,objectFit:S||null},n))},children:[o.jsx("option",{value:"",children:l("imagePropertiesFitDefault")}),dc.map(g=>o.jsx("option",{value:g,children:l(gx[g])},g))]})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:l("imagePropertiesPosition")}),o.jsxs("select",{id:p,className:d.select,value:t.objectPosition??"",disabled:r,onChange:g=>{const S=g.target.value||null;a({...t,objectPosition:S})},children:[o.jsx("option",{value:"",children:l("imagePropertiesPositionDefault")}),mc.map(g=>o.jsx("option",{value:g,children:l(bx[g])},g))]})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:b,children:l("imagePropertiesRotation")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:b,className:d.lengthInput,value:t.rotateDeg===null?"":J(t.rotateDeg),disabled:r,inputMode:"decimal",onChange:g=>{const S=g.target.value.trim();if(!S){a({...t,rotateDeg:null});return}const A=Number(S.replace(",","."));Number.isFinite(A)&&a({...t,rotateDeg:A})}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:l("imagePropertiesRotationUnit")})]})]})]}):null,e==="hover"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesTabHover")}),o.jsx("p",{className:d.emptyHint,children:l("imagePropertiesHoverHelp")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:h,children:l("imagePropertiesHoverCss")}),o.jsx("textarea",{id:h,className:d.textarea,value:t.hoverCss,disabled:r,spellCheck:!1,"aria-label":l("imagePropertiesHoverCssAria"),onChange:g=>{a({...t,hoverCss:g.target.value})}})]})]}):null]})]})}function Sx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=e===null?null:Cr(e),[l,c]=s.useState(()=>a===null?"":J(a)),[m,p]=s.useState(!1);s.useEffect(()=>{m||c(a===null?"":J(a))},[a,m]);const b=h=>{const w=h.trim();if(!w){n(null),c("");return}const y=Number(w.replace(",","."));if(!Number.isFinite(y)){c(a===null?"":J(a));return}const v=Us(y);n(v),c(J(Cr(v)))};return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogOpacity")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:l,disabled:t,inputMode:"decimal",onFocus:()=>p(!0),onChange:h=>c(h.target.value),onBlur:()=>{p(!1),b(l)}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}const Ll='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Cx({open:e,tab:t,value:n,aspectRatio:r=1,disabled:i,onTabChange:a,onApply:l,onClose:c}){const m=V(),p=s.useId(),b=s.useRef(null),[h,w]=s.useState(n);return s.useEffect(()=>{e&&w(n)},[e,n]),s.useEffect(()=>{if(!e)return;const y=b.current,v=y==null?void 0:y.querySelector(Ll);v==null||v.focus();const x=k=>{if(k.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;k.preventDefault(),k.stopPropagation(),c();return}if(k.key!=="Tab"||!y)return;const g=[...y.querySelectorAll(Ll)];if(g.length===0)return;const S=g[0],A=g[g.length-1];k.shiftKey&&document.activeElement===S?(k.preventDefault(),A.focus()):!k.shiftKey&&document.activeElement===A&&(k.preventDefault(),S.focus())};return document.addEventListener("keydown",x,!0),()=>document.removeEventListener("keydown",x,!0)},[e,c]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:c,children:o.jsxs("div",{ref:b,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":p,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:p,children:m("imagePropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":m("imagePropertiesDialogCloseAria"),onClick:c,children:o.jsx(We,{})})]}),o.jsx(vx,{tab:t,value:h,aspectRatio:r,disabled:i,onTabChange:a,onChange:w}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:c,children:m("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:i,onClick:()=>l(h),children:m("fontDialogOk")})]})]})})}):null}const kx="_frame_bwkh8_1",Dx="_handle_bwkh8_9",Px="_handleEast_bwkh8_29",Ax="_handleSouth_bwkh8_37",jx="_handleSouthEast_bwkh8_45",xn={frame:kx,handle:Dx,handleEast:Px,handleSouth:Ax,handleSouthEast:jx};function pn(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const Ex=[{handle:"e",className:xn.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:xn.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:xn.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function Wo(e){return!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)?null:{x:e.clientX,y:e.clientY}}function Tx({img:e,onResize:t,onResizeEnd:n}){const r=V(),i=s.useRef(null),a=s.useRef(e),l=s.useRef(t),c=s.useRef(n),m=s.useRef(null);a.current=e,l.current=t,c.current=n;const p=g=>{const S=i.current;S&&(S.style.left=`${g.left}px`,S.style.top=`${g.top}px`,S.style.width=`${g.width}px`,S.style.height=`${g.height}px`)};s.useLayoutEffect(()=>{p(pn(e));const g=()=>{e.isConnected&&p(pn(e))};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[e]);const b=(g,S)=>{const A=m.current,N=a.current;if(!A||!N)return;const E=gh(A.handle,A.start,{x:g-A.originX,y:S-A.originY});l.current(E.width,E.height),N.isConnected&&p(pn(N))},h=()=>{if(!m.current)return;m.current=null;const g=a.current;c.current(),g!=null&&g.isConnected&&p(pn(g))};s.useLayoutEffect(()=>{const g=A=>{if(!m.current)return;const N=Wo(A);N&&b(N.x,N.y)},S=()=>{h()};return document.addEventListener("pointermove",g),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),document.addEventListener("mousemove",g),document.addEventListener("mouseup",S),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",S),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",S)}},[]);const w=(g,S)=>{const A=Wo(S);A&&(m.current={handle:g,start:bh(a.current),originX:A.x,originY:A.y})},y=g=>S=>{S.preventDefault(),S.stopPropagation(),w(g,S);try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}},v=g=>S=>{S.preventDefault(),S.stopPropagation(),w(g,S)},x=g=>{const S=Wo(g);S&&b(S.x,S.y)};if(!e.isConnected)return null;const k=pn(e);return Ul.createPortal(o.jsx("div",{ref:i,className:xn.frame,"data-image-resize-overlay":"",style:{left:k.left,top:k.top,width:k.width,height:k.height},children:Ex.map(g=>o.jsx("button",{type:"button",className:`${xn.handle} ${g.className}`,style:{cursor:g.cursor},"aria-label":r(g.ariaKey),"data-resize-handle":g.handle,onPointerDown:y(g.handle),onPointerMove:x,onPointerUp:h,onPointerCancel:h,onMouseDown:v(g.handle),onMouseMove:x,onMouseUp:h},g.handle))}),document.body)}const Ml='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Nx({open:e,tab:t,href:n,title:r,targetBlank:i,textDecorationNone:a,hoverMode:l,hoverColor:c,hoverHtml:m,bookmarks:p,selectedBookmarkId:b,disabled:h,onTabChange:w,onApply:y,onClose:v}){const x=V(),k=s.useId(),g=s.useId(),S=s.useId(),A=s.useId(),N=s.useId(),E=s.useRef(null),[L,M]=s.useState(n),[I,j]=s.useState(r),[T,P]=s.useState(i),[R,W]=s.useState(a),[O,Z]=s.useState(l),[te,ce]=s.useState(c),[re,he]=s.useState(m),[ne,Q]=s.useState(b);if(s.useEffect(()=>{e&&(M(n),j(r),P(i),W(a),Z(l),ce(c),he(m),Q(b))},[e,n,r,i,a,l,c,m,b]),s.useEffect(()=>{if(!e)return;const B=E.current,fe=B==null?void 0:B.querySelector(Ml);fe==null||fe.focus();const ue=we=>{if(we.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;we.preventDefault(),we.stopPropagation(),v();return}if(we.key!=="Tab"||!B)return;const _=[...B.querySelectorAll(Ml)];if(_.length===0)return;const Ce=_[0],Pt=_[_.length-1];we.shiftKey&&document.activeElement===Ce?(we.preventDefault(),Pt.focus()):!we.shiftKey&&document.activeElement===Pt&&(we.preventDefault(),Ce.focus())};return document.addEventListener("keydown",ue,!0),()=>document.removeEventListener("keydown",ue,!0)},[e,v,t,O]),!e)return null;const D=()=>Mr({title:I,targetBlank:T,textDecorationNone:R,hoverMode:O,hoverColor:te,hoverHtml:re}),$=()=>{const B=L.trim();!B||h||y({...D(),href:B})},Y=()=>{!ne||h||y({...D(),href:`#${ne}`})};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:v,children:o.jsxs("div",{ref:E,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":k,onMouseDown:B=>B.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:k,children:x("linkDialogTitle")}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":x("linkDialogTitle"),children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="link",onClick:()=>w("link"),children:x("linkDialogTabLink")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="bookmark",onClick:()=>w("bookmark"),children:x("linkDialogTabBookmark")})]}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[t==="link"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:g,children:x("linkDialogHref")}),o.jsx("input",{id:g,className:d.textInput,value:L,disabled:h,onChange:B=>M(B.target.value)})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:S,children:x("linkDialogHoverTitle")}),o.jsx("input",{id:S,className:d.textInput,value:I,disabled:h,onChange:B=>j(B.target.value)})]}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:T,disabled:h,onChange:B=>P(B.target.checked)}),x("linkDialogTargetBlank")]})]}):p.length===0?o.jsx("p",{className:d.emptyHint,children:x("linkDialogBookmarkEmpty")}):o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:A,children:x("linkDialogBookmark")}),o.jsxs("select",{id:A,className:`${d.select} ${d.fullSelect}`,value:ne,disabled:h,onChange:B=>Q(B.target.value),children:[o.jsx("option",{value:""}),p.map(B=>o.jsx("option",{value:B.id,children:B.id},B.id))]})]}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:R,disabled:h,onChange:B=>W(B.target.checked)}),x("linkDialogTextDecorationNone")]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.subLabel,children:x("linkDialogHover")}),o.jsxs("div",{className:d.sizeRow,role:"group","aria-label":x("linkDialogHover"),children:[o.jsx("button",{type:"button",className:d.action,"aria-pressed":O==="color",disabled:h,onClick:()=>Z("color"),children:x("linkDialogHoverColor")}),o.jsx("button",{type:"button",className:d.action,"aria-pressed":O==="html",disabled:h,onClick:()=>Z("html"),children:x("linkDialogHoverHtml")})]}),O==="color"?o.jsx(Fe,{label:x("linkDialogHoverColorField"),noneLabel:x("colorNone"),value:te,disabled:h,onChange:ce}):o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:N,children:x("linkDialogHoverHtmlAria")}),o.jsx("textarea",{id:N,className:d.textarea,value:re,disabled:h,spellCheck:!1,onChange:B=>he(B.target.value)})]})]})]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,disabled:h||!ne,onClick:Y,children:x("linkDialogSelect")}),o.jsx("button",{type:"button",className:d.action,onClick:v,children:x("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:h||!L.trim(),onClick:$,children:x("fontDialogOk")})]})]})})})}const Lx="_grid_1bpma_1",Mx="_cell_1bpma_8",Rx="_sizeLabel_1bpma_27",_x="_sizeFields_1bpma_33",Ix="_numberInput_1bpma_37",Lt={grid:Lx,cell:Mx,sizeLabel:Rx,sizeFields:_x,numberInput:Ix},Rl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled])',st={rows:3,cols:3};function Fx({open:e,disabled:t,onApply:n,onClose:r}){const i=V(),a=s.useId(),l=s.useId(),c=s.useId(),m=s.useRef(null),[p,b]=s.useState(st.rows),[h,w]=s.useState(st.cols),[y,v]=s.useState(String(st.rows)),[x,k]=s.useState(String(st.cols)),[g,S]=s.useState(!1);if(s.useEffect(()=>{e&&(b(st.rows),w(st.cols),v(String(st.rows)),k(String(st.cols)),S(!1))},[e]),s.useEffect(()=>{if(!e)return;const j=m.current,T=j==null?void 0:j.querySelector(Rl);T==null||T.focus();const P=R=>{if(R.key==="Escape"){R.preventDefault(),R.stopPropagation(),r();return}if(R.key!=="Tab"||!j)return;const W=[...j.querySelectorAll(Rl)];if(W.length===0)return;const O=W[0],Z=W[W.length-1];R.shiftKey&&document.activeElement===O?(R.preventDefault(),Z.focus()):!R.shiftKey&&document.activeElement===Z&&(R.preventDefault(),O.focus())};return document.addEventListener("keydown",P,!0),()=>document.removeEventListener("keydown",P,!0)},[e,r]),!e)return null;const N=yc(p,h)&&!t,E=(j,T)=>{const P=Math.min(It,Math.max(_t,j)),R=Math.min(It,Math.max(_t,T));b(P),w(R),v(String(P)),k(String(R))},L=(j,T)=>{const P=Number.parseInt(j,10);if(!Number.isFinite(P)){T==="rows"?v(String(p)):k(String(h));return}S(!0),T==="rows"?E(P,h):E(p,P)},M=(j,T)=>{const P=j.replace(/\D/g,"");if(T==="rows"?v(P):k(P),P==="")return;const R=Number.parseInt(P,10);Number.isFinite(R)&&(S(!0),T==="rows"?E(R,h):E(p,R))},I=j=>{(j.key==="e"||j.key==="E"||j.key==="+"||j.key==="-"||j.key===".")&&j.preventDefault()};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:r,children:o.jsxs("div",{ref:m,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:j=>j.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:a,children:i("tableDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":i("tableDialogCloseAria"),onClick:r,children:o.jsx(We,{})})]}),o.jsxs("div",{className:d.body,children:[o.jsx("div",{className:Lt.grid,role:"grid","aria-label":i("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:pl},(j,T)=>Array.from({length:pl},(P,R)=>{const W=T+1,O=R+1,Z=W<=p&&O<=h;return o.jsx("button",{type:"button",className:Lt.cell,role:"gridcell","data-active":Z?"true":void 0,"aria-label":`${W} × ${O}`,"aria-pressed":Z&&W===p&&O===h,disabled:t,onMouseEnter:()=>{g||E(W,O)},onClick:()=>{S(!0),E(W,O)}},`${W}-${O}`)}))}),o.jsxs("p",{className:Lt.sizeLabel,children:[i("tableDialogSize"),": ",p," × ",h]}),o.jsxs("div",{className:`${d.sizeRow} ${Lt.sizeFields}`,children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:l,children:i("tableDialogRows")}),o.jsx("input",{id:l,className:Lt.numberInput,type:"number",inputMode:"numeric",min:_t,max:It,step:1,value:y,disabled:t,onKeyDown:I,onChange:j=>M(j.target.value,"rows"),onBlur:()=>L(y,"rows")})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:i("tableDialogColumns")}),o.jsx("input",{id:c,className:Lt.numberInput,type:"number",inputMode:"numeric",min:_t,max:It,step:1,value:x,disabled:t,onKeyDown:I,onChange:j=>M(j.target.value,"cols"),onBlur:()=>L(x,"cols")})]})]})]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:r,children:i("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!N,onClick:()=>{N&&n({rows:p,cols:h})},children:i("tableDialogInsert")})]})]})})})}const Bx={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Hx={value:1,unit:"pt"},zx={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 Ox({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=s.useId();return o.jsxs("div",{className:d.body,children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("tablePropertiesWidth")}),o.jsx(ge,{label:r("tablePropertiesWidth"),value:e.width,disabled:t,onChange:l=>n({...e,width:l})}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("tablePropertiesCollapse")}),o.jsxs("select",{id:i,className:d.select,value:e.borderCollapse,disabled:t,onChange:l=>{const c=l.target.value==="separate"?"separate":"collapse";n({...e,borderCollapse:c,borderSpacing:c==="separate"?e.borderSpacing:null})},children:[o.jsx("option",{value:"collapse",children:r("tablePropertiesCollapseCollapse")}),o.jsx("option",{value:"separate",children:r("tablePropertiesCollapseSeparate")})]})]}),e.borderCollapse==="separate"?o.jsx(ge,{label:r("tablePropertiesSpacing"),value:e.borderSpacing,disabled:t,onChange:l=>n({...e,borderSpacing:l})}):null]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:a,children:r("paragraphDialogBorderStyle")}),o.jsx("select",{id:a,className:d.select,value:e.border.style,disabled:t,onChange:l=>{const c=l.target.value;n({...e,border:{style:c,width:c==="none"?null:e.border.width??Hx,color:c==="none"?null:e.border.color}})},children:Lr.map(l=>o.jsx("option",{value:l,children:r(Bx[l])},l))})]}),e.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:l=>n({...e,border:{...e.border,width:l}})}),o.jsx(Fe,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:l=>n({...e,border:{...e.border,color:l}})})]}):null,o.jsx(ge,{label:r("paragraphDialogBorderRadius"),value:e.borderRadius,disabled:t,onChange:l=>n({...e,borderRadius:l})}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:e.boxShadow!==null,disabled:t,onChange:()=>{n({...e,boxShadow:e.boxShadow?null:zx})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?o.jsx(Vi,{shadow:e.boxShadow,disabled:t,onChange:l=>n({...e,boxShadow:l})}):null]})]})}const _l='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Kx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(_l);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(_l)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("tablePropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("tablePropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Ox,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const $x={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Ux={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function ur(e){return{top:e,right:e,bottom:e,left:e}}function Go(e){for(const t of Xe)if(e[t])return e[t];return null}function Wx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),[a,l]=s.useState(()=>nt(e.padding,ur(Go(e.padding))));return s.useEffect(()=>{l(nt(e.padding,ur(Go(e.padding))))},[e.padding]),o.jsxs("div",{className:d.body,children:[o.jsx(Fe,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:c=>n({...e,backgroundColor:c})}),o.jsx(Fe,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:c=>n({...e,color:c})}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogPadding")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const c=!a;l(c),c&&n({...e,padding:ur(Go(e.padding))})}}),r("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(a?["top"]:Xe).map(c=>o.jsx(ge,{label:r(a?"paragraphDialogPadding":$x[c]),value:e.padding[c],disabled:t,onChange:m=>{const p=a?ur(m):{...e.padding,[c]:m};n({...e,padding:p})}},c))})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("cellPropertiesVerticalAlign")}),o.jsxs("select",{id:i,className:d.select,value:e.verticalAlign??"",disabled:t,onChange:c=>{const m=c.target.value;n({...e,verticalAlign:m||null})},children:[o.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),Rr.map(c=>o.jsx("option",{value:c,children:r(Ux[c])},c))]})]}),o.jsx(ge,{label:r("cellPropertiesWidth"),value:e.width,disabled:t,onChange:c=>n({...e,width:c})})]})}const Il='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Gx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(Il);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(Il)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("cellPropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("cellPropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Wx,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const Vx={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},qx={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function dr(e){return{top:e,right:e,bottom:e,left:e}}function Vo(e){for(const t of Xe)if(e[t])return e[t];return null}function Xx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),[a,l]=s.useState(()=>nt(e.padding,dr(Vo(e.padding))));return s.useEffect(()=>{l(nt(e.padding,dr(Vo(e.padding))))},[e.padding]),o.jsxs("div",{className:d.body,children:[o.jsx(Fe,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:c=>n({...e,backgroundColor:c})}),o.jsx(Fe,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:c=>n({...e,color:c})}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogPadding")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const c=!a;l(c),c&&n({...e,padding:dr(Vo(e.padding))})}}),r("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(a?["top"]:Xe).map(c=>o.jsx(ge,{label:r(a?"paragraphDialogPadding":Vx[c]),value:e.padding[c],disabled:t,onChange:m=>{const p=a?dr(m):{...e.padding,[c]:m};n({...e,padding:p})}},c))})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("cellPropertiesVerticalAlign")}),o.jsxs("select",{id:i,className:d.select,value:e.verticalAlign??"",disabled:t,onChange:c=>{const m=c.target.value;n({...e,verticalAlign:m||null})},children:[o.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),Rr.map(c=>o.jsx("option",{value:c,children:r(qx[c])},c))]})]}),o.jsx(ge,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:c=>n({...e,height:c})})]})}const Fl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Yx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(Fl);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(Fl)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("rowPropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("rowPropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Xx,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const Jx="_backdrop_9d3gw_1",Zx="_dialog_9d3gw_12",Qx="_headerRow_9d3gw_29",e1="_header_9d3gw_29",t1="_close_9d3gw_44",n1="_body_9d3gw_66",r1="_frame_9d3gw_75",o1="_actions_9d3gw_83",i1="_action_9d3gw_83",Je={backdrop:Jx,dialog:Zx,headerRow:Qx,header:e1,close:t1,body:n1,frame:r1,actions:o1,action:i1},Bl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function a1({open:e,html:t,onClose:n}){const r=V(),i=s.useId(),a=s.useRef(null),l=s.useRef(null);return s.useEffect(()=>{if(!e)return;const c=a.current,m=c==null?void 0:c.querySelector(Bl);m==null||m.focus();const p=b=>{if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),n();return}if(b.key!=="Tab"||!c)return;const h=[...c.querySelectorAll(Bl)];if(h.length===0)return;const w=h[0],y=h[h.length-1];b.shiftKey&&document.activeElement===w?(b.preventDefault(),y.focus()):!b.shiftKey&&document.activeElement===y&&(b.preventDefault(),w.focus())};return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,n]),s.useEffect(()=>{var m;if(!e)return;const c=(m=l.current)==null?void 0:m.contentDocument;c&&Zo(c,t,r("previewDialogTitle"))},[e,t,r]),e?o.jsx(ie,{children:o.jsx("div",{className:Je.backdrop,role:"presentation",onMouseDown:n,children:o.jsxs("div",{ref:a,className:Je.dialog,role:"dialog","aria-modal":"true","aria-labelledby":i,onMouseDown:c=>c.stopPropagation(),children:[o.jsxs("div",{className:Je.headerRow,children:[o.jsx("h2",{className:Je.header,id:i,children:r("previewDialogTitle")}),o.jsx("button",{type:"button",className:Je.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:o.jsx(We,{})})]}),o.jsx("div",{className:Je.body,children:o.jsx("iframe",{ref:l,className:Je.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var m;const c=(m=l.current)==null?void 0:m.contentDocument;c&&Zo(c,t,r("previewDialogTitle"))}})}),o.jsx("div",{className:Je.actions,children:o.jsx("button",{type:"button",className:Je.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const Tc="commspliant-html-editor.darkMode";function l1(e){return typeof e=="boolean"?e:null}function Hl(){try{const e=localStorage.getItem(Tc);return e?l1(JSON.parse(e)):null}catch{return null}}function s1(e){try{localStorage.setItem(Tc,JSON.stringify(e))}catch{}}const Nc="commspliant-html-editor.toolbarPosition",c1=["top","left","right","bottom"];function Lc(e){return typeof e=="string"&&c1.includes(e)?e:null}function zl(){try{const e=localStorage.getItem(Nc);return e?Lc(JSON.parse(e)):null}catch{return null}}function u1(e){try{localStorage.setItem(Nc,JSON.stringify(e))}catch{}}function d1({enabled:e,onHtml:t}){const[n,r]=s.useState(!1),i=s.useRef(0),a=s.useRef(e),l=s.useRef(t);a.current=e,l.current=t;const c=s.useCallback(()=>{i.current=0,r(!1)},[]);s.useEffect(()=>{e||c()},[e,c]);const m=s.useCallback(w=>{!a.current||!rr(w.dataTransfer)||(w.preventDefault(),i.current+=1,r(!0))},[]),p=s.useCallback(w=>{!a.current||!rr(w.dataTransfer)||(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy"))},[]),b=s.useCallback(w=>{if(!a.current||!rr(w.dataTransfer))return;const y=w.relatedTarget;y instanceof Node&&w.currentTarget.contains(y)||(i.current=Math.max(0,i.current-1),i.current===0&&r(!1))},[]),h=s.useCallback(w=>{if(!a.current||!rr(w.dataTransfer))return;w.preventDefault(),c();const y=rd(w.dataTransfer);y&&wi(y).then(v=>{a.current&&l.current(v)},()=>{})},[c]);return{dragging:n,onDragEnter:m,onDragOver:p,onDragLeave:b,onDrop:h}}const m1={menus:{edit:{id:"edit",labelKey:"menuEdit",ariaKey:"menuEditAria"}},groups:{edit:{id:"edit",labelKey:"toolbarGroupEdit"}},items:{undo:{id:"undo",command:"undo",icon:Eu,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:ku,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"}}},f1=400;function p1(e){let t=[],n=e,r=[],i=!1,a=!1,l=0;function c(h,w){if(i){n=h,i=!1;return}if(h===n)return;const y=Date.now(),v=(w==null?void 0:w.coalesce)===!0;if(v&&a&&y-l<f1){n=h,l=y;return}t.push(n),n=h,r=[],l=y,a=v}function m(){return t.length===0?null:(a=!1,r.push(n),n=t.pop(),n)}function p(){return r.length===0?null:(a=!1,t.push(n),n=r.pop(),n)}function b(h){if(i){n=h,i=!1;return}h!==n&&(t.push(n),n=h,r=[],a=!1)}return{record:c,undo:m,redo:p,canUndo:()=>t.length>0,canRedo:()=>r.length>0,syncExternal:b,markApplying:()=>{i=!0}}}function ft(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function Dr(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):ft(e,t):""}const Ge="fullscreen",di="commspliant-html-editor.toolbarCustomization";function mi(e){const t=e.filter(n=>n!==Ge);return e.includes(Ge)?[...t,Ge]:t}function Xi(e,t){if(!t||t.length===0)return mi(e);const n=new Set(e),r=t.filter(l=>n.has(l)),i=new Set(r),a=[...r];for(let l=0;l<e.length;l++){const c=e[l];if(i.has(c))continue;let m=0;for(let p=l-1;p>=0;p--){const b=e[p],h=a.indexOf(b);if(h>=0){m=h+1;break}}a.splice(m,0,c),i.add(c)}return mi(a)}function h1(e,t){const n=new Map(e.map(l=>[l.id,l])),r=Xi(e.map(l=>l.id),t==null?void 0:t.groupOrder),i=new Set((t==null?void 0:t.hiddenItemIds)??[]),a=[];for(const l of r){const c=n.get(l);if(!c)continue;const m=c.items.filter(p=>!i.has(p));m.length!==0&&a.push({id:l,items:m})}return a}function g1(e){if(e==null||typeof e!="object")return null;const t=e,n=Array.isArray(t.groupOrder)?t.groupOrder.filter(i=>typeof i=="string"):[],r=Array.isArray(t.hiddenItemIds)?[...new Set(t.hiddenItemIds.filter(i=>typeof i=="string"))]:[];return n.length===0&&r.length===0?null:{groupOrder:n,hiddenItemIds:r}}function b1(){try{const e=localStorage.getItem(di);return e?g1(JSON.parse(e)):null}catch{return null}}function y1(e){try{if(!e){localStorage.removeItem(di);return}localStorage.setItem(di,JSON.stringify(e))}catch{}}function Yi(e,t){return Xi(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function x1(e,t,n,r){const i=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?i.delete(n):i.add(n),{groupOrder:Yi(e,t),hiddenItemIds:[...i]}}function Mc(e,t,n,r){const i=Yi(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===Ge||r===Ge)return{groupOrder:i,hiddenItemIds:a};const l=i.indexOf(n),c=i.indexOf(r);if(l<0||c<0||l===c)return{groupOrder:i,hiddenItemIds:a};const m=[...i],[p]=m.splice(l,1);return m.splice(c,0,p),{groupOrder:mi(m),hiddenItemIds:a}}function Ol(e,t,n,r){const i=Yi(e,t),a=i.filter(m=>m!==Ge),l=a.indexOf(n),c=l+r;return l<0||c<0||c>=a.length?{groupOrder:i,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:Mc(e,t,n,a[c])}const w1="_backdrop_1dasl_1",v1="_dialog_1dasl_12",S1="_header_1dasl_28",C1="_body_1dasl_35",k1="_group_1dasl_43",D1="_groupDragging_1dasl_49",P1="_groupDropTarget_1dasl_53",A1="_groupHeader_1dasl_58",j1="_groupTitle_1dasl_66",E1="_dragHandle_1dasl_71",T1="_moveButton_1dasl_72",N1="_items_1dasl_113",L1="_item_1dasl_113",M1="_itemIcon_1dasl_129",R1="_itemTitle_1dasl_138",_1="_itemCheckbox_1dasl_145",I1="_actions_1dasl_149",F1="_action_1dasl_149",B1="_spinnerWrap_1dasl_184",H1="_spinner_1dasl_184",le={backdrop:w1,dialog:v1,header:S1,body:C1,group:k1,groupDragging:D1,groupDropTarget:P1,groupHeader:A1,groupTitle:j1,dragHandle:E1,moveButton:T1,items:N1,item:L1,itemIcon:M1,itemTitle:R1,itemCheckbox:_1,actions:I1,action:F1,spinnerWrap:B1,spinner:H1},Kl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function z1(){return o.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",fill:"currentColor",children:[o.jsx("circle",{cx:"5",cy:"4",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"4",r:"1.2"}),o.jsx("circle",{cx:"5",cy:"8",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"8",r:"1.2"}),o.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"12",r:"1.2"})]})}function O1({open:e,catalog:t,groups:n,settings:r,loading:i=!1,busy:a=!1,disabled:l,onChange:c,onReset:m,onClose:p}){const b=V(),h=s.useId(),w=s.useRef(null),[y,v]=s.useState(null),[x,k]=s.useState(null),g=Xi(n.map(P=>P.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),A=new Map(n.map(P=>[P.id,P])),N=g.map(P=>A.get(P)).filter(P=>!!P),E=l||a||i;if(s.useEffect(()=>{e||(v(null),k(null))},[e]),s.useEffect(()=>{if(!e)return;const P=w.current,R=P==null?void 0:P.querySelector(Kl);R==null||R.focus();const W=O=>{if(O.key==="Escape"){O.preventDefault(),O.stopPropagation(),p();return}if(O.key!=="Tab"||!P)return;const Z=[...P.querySelectorAll(Kl)];if(Z.length===0)return;const te=Z[0],ce=Z[Z.length-1];O.shiftKey&&document.activeElement===te?(O.preventDefault(),ce.focus()):!O.shiftKey&&document.activeElement===ce&&(O.preventDefault(),te.focus())};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[e,p]),!e)return null;const L=N.map(P=>P.id).filter(P=>P!==Ge),M=(P,R)=>{if(E||R===Ge){P.preventDefault();return}P.dataTransfer.setData("text/plain",R),P.dataTransfer.effectAllowed="move",v(R)},I=(P,R)=>{E||R===Ge||!y||y===R||(P.preventDefault(),P.dataTransfer&&(P.dataTransfer.dropEffect="move"),k(R))},j=(P,R)=>{var O;P.preventDefault();const W=((O=P.dataTransfer)==null?void 0:O.getData("text/plain"))||y;v(null),k(null),!(!W||W===R||E)&&c(Mc(r,n,W,R))},T=()=>{v(null),k(null)};return o.jsx(ie,{children:o.jsx("div",{className:le.backdrop,role:"presentation",onMouseDown:p,children:o.jsxs("div",{ref:w,className:le.dialog,role:"dialog","aria-modal":"true","aria-labelledby":h,"aria-busy":i||a?!0:void 0,onMouseDown:P=>P.stopPropagation(),children:[o.jsx("h2",{className:le.header,id:h,children:b("customizeToolbarDialogTitle")}),o.jsx("div",{className:le.body,children:i?o.jsx("div",{className:le.spinnerWrap,role:"status","aria-live":"polite","aria-label":b("customizeToolbarDialogLoading"),children:o.jsx("span",{className:le.spinner,"aria-hidden":"true"})}):N.map(P=>{const R=t.groups[P.id],W=R?ft(b,R):P.id,O=P.id===Ge,Z=L.indexOf(P.id);return o.jsxs("section",{className:[le.group,y===P.id?le.groupDragging:"",x===P.id?le.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":P.id,"aria-label":W,onDragOver:te=>I(te,P.id),onDrop:te=>j(te,P.id),onDragLeave:()=>{x===P.id&&k(null)},children:[o.jsxs("div",{className:le.groupHeader,children:[o.jsx("button",{type:"button",className:le.dragHandle,draggable:!E&&!O,disabled:E||O,"aria-label":b("customizeToolbarDragHandle"),onDragStart:te=>M(te,P.id),onDragEnd:T,children:o.jsx(z1,{})}),o.jsx("span",{className:le.groupTitle,children:W}),o.jsx("button",{type:"button",className:le.moveButton,disabled:E||O||Z<=0,"aria-label":b("customizeToolbarMoveUp"),onClick:()=>c(Ol(r,n,P.id,-1)),children:"↑"}),o.jsx("button",{type:"button",className:le.moveButton,disabled:E||O||Z<0||Z>=L.length-1,"aria-label":b("customizeToolbarMoveDown"),onClick:()=>c(Ol(r,n,P.id,1)),children:"↓"})]}),o.jsx("div",{className:le.items,children:P.items.map(te=>{const ce=t.items[te];if(!ce)return null;const re=ce.icon,he=ft(b,ce),ne=`${h}-${P.id}-${te}`,Q=!S.has(te);return o.jsxs("label",{className:le.item,htmlFor:ne,children:[o.jsx("span",{className:le.itemIcon,"aria-hidden":"true",children:re?o.jsx(re,{}):he.slice(0,2)}),o.jsx("span",{className:le.itemTitle,children:he}),o.jsx("input",{id:ne,className:le.itemCheckbox,type:"checkbox",checked:Q,disabled:E,"aria-label":`${he}: ${b("customizeToolbarItemVisible")}`,onChange:D=>c(x1(r,n,te,D.target.checked))})]},te)})})]},P.id)})}),o.jsxs("div",{className:le.actions,children:[o.jsx("button",{type:"button",className:le.action,disabled:E,onClick:m,children:b("customizeToolbarDialogReset")}),o.jsx("button",{type:"button",className:le.action,"aria-label":b("customizeToolbarDialogCloseAria"),onClick:p,children:b("customizeToolbarDialogClose")})]})]})})})}function K1(e,t){if(!t)return e;const n=t.menus,r=t.toolbar;if(n===void 0&&r===void 0)return e;const i=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(c=>r.includes(c))})).filter(l=>l.items.length>0);return{menus:i,iconGroups:a}}const $1={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:Pu,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:gu,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:Cu,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},mr=4;function Rc({icon:e,value:t,mixed:n,noneKey:r,labelKey:i,ariaKey:a,fallbackCustom:l,disabled:c,onChange:m}){const p=V(),b=s.useId(),h=s.useRef(null),w=s.useRef(null),y=s.useRef(null),[v,x]=s.useState(!1),[k,g]=s.useState({top:0,left:0}),S=s.useCallback(()=>{const M=w.current,I=y.current;if(!M)return;const j=M.getBoundingClientRect(),T=(I==null?void 0:I.offsetHeight)??0,P=(I==null?void 0:I.offsetWidth)??200;let R=j.bottom;R+T>window.innerHeight-mr&&(R=Math.max(mr,j.top-T));const W=Math.min(Math.max(j.left,mr),window.innerWidth-P-mr);g({top:R,left:W})},[]);s.useLayoutEffect(()=>{if(!v)return;S();const M=()=>S();return window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),()=>{window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[v,S]),s.useEffect(()=>{if(!v)return;const M=j=>{var P,R;const T=j.target;(P=h.current)!=null&&P.contains(T)||(R=y.current)!=null&&R.contains(T)||x(!1)},I=j=>{var T;j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),x(!1),(T=w.current)==null||T.focus())};return document.addEventListener("pointerdown",M),document.addEventListener("keydown",I,!0),()=>{document.removeEventListener("pointerdown",M),document.removeEventListener("keydown",I,!0)}},[v]);const A=M=>{m(M)},N=`${St.bar}${!t||n?` ${St.barEmpty}`:""}`,E=t&&!n?{backgroundColor:t}:void 0,L=o.jsxs("div",{className:St.wrap,ref:h,children:[o.jsxs("button",{ref:w,type:"button",className:`${X.iconButton} ${St.button}`,"aria-label":p(a),"aria-expanded":v,"aria-haspopup":"listbox","aria-controls":v?b:void 0,disabled:c,onMouseDown:M=>M.preventDefault(),onClick:()=>x(M=>!M),children:[o.jsx(e,{className:`${X.icon} ${St.icon}`}),o.jsx("span",{className:N,style:E})]}),v?o.jsx(ie,{children:o.jsx("div",{ref:y,id:b,className:St.popover,style:{top:k.top,left:k.left},children:o.jsx(Wi,{value:t,mixed:n,noneLabel:p(r),ariaLabel:p(a),disabled:c,fallbackCustom:l,onChange:A,onCommit:()=>x(!1)})})}):null]});return o.jsx(mt,{label:p(i),children:L})}function U1({commands:e,queries:t,disabled:n}){return o.jsx(Rc,{icon:Vl,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}function W1({commands:e,queries:t,disabled:n}){const r=V(),i=!!(n||!t.isVisualMode());return o.jsx(Ec,{size:t.getFontSize(),unit:t.getFontSizeUnit(),disabled:i,tooltip:r("commandFontSize"),toolbar:!0,onSizeChange:(a,l)=>{e.setFontSize(a,l)},onUnitChange:a=>{e.setFontSizeUnit(a)}})}function G1({commands:e,queries:t,disabled:n}){return o.jsx(Rc,{icon:ql,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function V1({commands:e,queries:t,disabled:n,onMenuClose:r}){const i=V(),a=!!(n||!t.isVisualMode());return o.jsx(Wi,{value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneLabel:i("colorNone"),ariaLabel:i("commandHighlightColorAria"),disabled:a,menu:!0,fallbackCustom:"#ffff00",onChange:l=>e.setHighlightColor(l),onCommit:()=>r==null?void 0:r()})}const q1="_wrap_2cawp_1",X1="_wrapToolbar_2cawp_7",Y1="_field_2cawp_12",J1="_trigger_2cawp_20",Z1="_chevron_2cawp_46",Q1="_list_2cawp_69",ew="_option_2cawp_84",tw="_separator_2cawp_113",Ze={wrap:q1,wrapToolbar:X1,field:Y1,trigger:J1,chevron:Z1,list:Q1,option:ew,separator:tw},fi={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},nw={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 $l(){const e=V();return o.jsx("div",{className:d.spinnerWrap,role:"status","aria-live":"polite","aria-label":e("customStyleLoading"),children:o.jsx("span",{className:d.spinner,"aria-hidden":"true"})})}function _c({value:e,mixed:t=!1,disabled:n,menu:r=!1,listId:i,listRef:a,style:l,customStylesEnabled:c=!1,customStyles:m=[],customStylesLoading:p=!1,onSelect:b,onSelectCustom:h,onAddNew:w}){const y=V(),v=t?null:e,x=c,k=!!(r&&c&&w);return r?o.jsxs(o.Fragment,{children:[vr.map(g=>o.jsx("button",{type:"button",className:X.menuItem,role:"menuitemradio","aria-checked":v===g,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>b(g),children:y(fi[g])},g)),x?o.jsx("div",{role:"separator",className:X.menuSeparator}):null,x&&p?o.jsx($l,{}):null,x&&!p?m.map(g=>o.jsx("button",{type:"button",className:X.menuItem,role:"menuitem",disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(g.id),children:g.name},g.id)):null,k?o.jsxs(o.Fragment,{children:[x&&(p||m.length>0)?o.jsx("div",{role:"separator",className:X.menuSeparator}):null,o.jsxs("button",{type:"button",className:X.menuItem,role:"menuitem","aria-label":y("styleAddNewAria"),disabled:n,onMouseDown:g=>g.preventDefault(),onClick:()=>w==null?void 0:w(),children:[o.jsx(Su,{className:X.icon}),y("styleAddNew")]})]}):null]}):o.jsxs("ul",{ref:a,className:Ze.list,role:"listbox",id:i,style:l,"aria-label":y("commandParagraphStyleAria"),"aria-busy":x&&p?!0:void 0,children:[vr.map(g=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":v===g,disabled:n,style:nw[g],onMouseDown:S=>S.preventDefault(),onClick:()=>b(g),children:y(fi[g])})},g)),x&&(p||m.length>0)?o.jsx("li",{role:"separator",className:Ze.separator}):null,x&&p?o.jsx("li",{role:"presentation",children:o.jsx($l,{})}):null,x&&!p?m.map(g=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":!1,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(g.id),children:g.name})},g.id)):null]})}const fr=4;function rw({commands:e,queries:t,disabled:n}){const r=V(),i=s.useId(),a=s.useRef(null),l=s.useRef(null),c=s.useRef(null),[m,p]=s.useState(!1),[b,h]=s.useState({top:0,left:0,width:0}),w=!!(n||!t.isVisualMode()),y=t.isParagraphStyleMixed(),v=y?null:t.getParagraphStyle(),x=v?r(fi[v]):"",k=t.customParagraphStylesEnabled(),g=k?t.getCustomParagraphStyles():[],S=k&&t.isCustomParagraphStylesLoading(),A=s.useCallback(()=>{const E=l.current,L=c.current;if(!E)return;const M=E.getBoundingClientRect(),I=(L==null?void 0:L.offsetHeight)??0,j=Math.max(M.width,(L==null?void 0:L.offsetWidth)??0);let T=M.bottom;T+I>window.innerHeight-fr&&(T=Math.max(fr,M.top-I));const P=Math.min(Math.max(M.left,fr),window.innerWidth-j-fr);h({top:T,left:P,width:j})},[]);s.useLayoutEffect(()=>{if(!m)return;A();const E=()=>A();return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[m,A,g.length,S]),s.useEffect(()=>{if(!m)return;const E=M=>{var j,T;const I=M.target;(j=a.current)!=null&&j.contains(I)||(T=c.current)!=null&&T.contains(I)||p(!1)},L=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),p(!1))};return document.addEventListener("pointerdown",E),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",E),document.removeEventListener("keydown",L,!0)}},[m]);const N=o.jsxs("div",{className:`${Ze.wrap} ${Ze.wrapToolbar}`,ref:a,children:[o.jsxs("div",{className:Ze.field,ref:l,children:[o.jsx("button",{type:"button",className:Ze.trigger,disabled:w,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":m,"aria-controls":m?i:void 0,onMouseDown:E=>E.preventDefault(),onClick:()=>p(E=>!E),children:x}),o.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),m?o.jsx(ie,{children:o.jsx(_c,{listRef:c,listId:i,value:v,mixed:y,disabled:w,customStylesEnabled:k,customStyles:g,customStylesLoading:S,style:{top:b.top,left:b.left,minWidth:b.width},onSelect:E=>{e.setParagraphStyle(E),p(!1)},onSelectCustom:E=>{e.applyCustomParagraphStyle(E),p(!1)}})}):null]});return o.jsx(mt,{label:r("commandParagraphStyle"),children:N})}function ow({commands:e,queries:t,disabled:n,onMenuClose:r}){const i=!!(n||!t.isVisualMode()),a=t.isParagraphStyleMixed(),l=a?null:t.getParagraphStyle(),c=t.customParagraphStylesEnabled(),m=c?t.getCustomParagraphStyles():[],p=c&&t.isCustomParagraphStylesLoading();return o.jsx(_c,{menu:!0,value:l,mixed:a,disabled:i,customStylesEnabled:c,customStyles:m,customStylesLoading:p,onSelect:b=>{e.setParagraphStyle(b),r==null||r()},onSelectCustom:b=>{e.openCustomParagraphStyleDialog(b),r==null||r()},onAddNew:()=>{e.openCustomParagraphStyleDialog(),r==null||r()}})}const iw={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:ow,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:V1,enabled:"isVisualMode"},paragraph:{id:"paragraph",labelKey:"menuParagraph",ariaKey:"menuParagraphAria"},page:{id:"page",labelKey:"menuPage",ariaKey:"menuPageAria"}},groups:{font:{id:"font",labelKey:"toolbarGroupFont"},align:{id:"align",labelKey:"toolbarGroupAlign"},paragraph:{id:"paragraph",labelKey:"toolbarGroupParagraph"}},items:{fontFamily:{id:"fontFamily",widget:Eb,icon:iu,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:rw,icon:vu,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:W1,icon:lu,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:au,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:xu,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:yu,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:Xl,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:U1,icon:Vl,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:G1,icon:ql,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:Jc,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:mu,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:ju,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:Au,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:eu,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},alignLeft:{id:"alignLeft",command:"alignLeft",icon:hi,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:pi,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:gi,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:Wl,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:du,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:bu,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:Gl,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:Yl,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},aw={menus:{insert:{id:"insert",labelKey:"menuInsert",ariaKey:"menuInsertAria"}},groups:{insert:{id:"insert",labelKey:"toolbarGroupInsert"}},items:{link:{id:"link",command:"openLinkDialog",icon:pu,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Zc,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:Xl,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:cu,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"}}},lw={menus:{},submenus:{insertRow:{id:"insertRow",labelKey:"menuInsertRow",ariaKey:"menuInsertRowAria",enabled:"isInTable"},insertColumn:{id:"insertColumn",labelKey:"menuInsertColumn",ariaKey:"menuInsertColumnAria",enabled:"isInTable"}},groups:{},items:{table:{id:"table",command:"openTableDialog",icon:$a,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:To,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:To,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:To,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:Eo,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:Eo,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:Eo,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:$a,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:Qc,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:Du,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},sw={menus:{view:{id:"view",labelKey:"menuView",ariaKey:"menuViewAria"}},submenus:{toolbar:{id:"toolbar",labelKey:"menuToolbar",ariaKey:"menuToolbarAria"},toolbarPosition:{id:"toolbarPosition",labelKey:"menuToolbarPosition",ariaKey:"menuToolbarPositionAria"}},groups:{view:{id:"view",labelKey:"toolbarGroupView"},fullscreen:{id:"fullscreen",labelKey:"toolbarGroupFullscreen"}},items:{visual:{id:"visual",command:"setVisualMode",icon:Tu,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:uu,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:ru,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:fu,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:ou,labelKey:"modeDark",ariaKey:"modeDarkAria",active:"isDarkMode"},preview:{id:"preview",command:"openDocumentPreview",icon:wu,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:su,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function cw(...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 uw=cw($1,m1,aw,lw,sw,iw),dw={menus:[{id:"file",items:["save","open",de,"print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark",de,"image","table","horizontalRule",de,{submenu:"insertRow",items:["insertRowBelow","insertRowBefore","deleteRow"]},{submenu:"insertColumn",items:["insertColumnAfter","insertColumnBefore","deleteColumn"]}]},{id:"view",items:["visual","html",de,{submenu:"toolbar",items:["customizeToolbar",de,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},de,"lightMode","darkMode",de,"preview","fullscreen"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},de,{submenu:"font",items:["fontProperties",de,{submenu:"highlightColor",items:[]},de,"bold","italic","underline","strikethrough"]},de,"clearFormatting",de,{submenu:"paragraph",items:["paragraphProperties",de,"alignLeft","alignCenter","alignRight","alignJustify",de,"indent","outdent",de,"bulletList","numberedList"]},de,{submenu:"page",items:["pageProperties"]},de,"imageProperties",de,"tableProperties","cellProperties","rowProperties"]}],iconGroups:[{id:"file",items:["save","open"]},{id:"print",items:["print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark","image","table","horizontalRule"]},{id:"font",items:["fontFamily","paragraphStyle","fontSize","fontColor","highlightColor","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"]},{id:"fullscreen",items:["fullscreen"]}]},pr="fullscreen";function mw(e){const t=[];let n=null;for(const r of e){const i=r.items.filter(a=>a!==pr);i.length>0&&t.push({id:r.id,items:i}),r.items.includes(pr)&&(n={id:pr,items:[pr]})}return{main:t,trailing:n}}function fw({groups:e,catalog:t,commands:n,queries:r,disabled:i}){const a=V(),{main:l,trailing:c}=mw(e),m=p=>{const b=t.groups[p.id];return o.jsx("div",{className:X.iconGroup,role:"group","aria-label":b?ft(a,b):void 0,"data-toolbar-group":p.id,children:p.items.map(h=>{const w=t.items[h];if(!w)return null;const y=w.enabled?!r[w.enabled]():!1;if(w.widget){const g=w.widget;return o.jsx(g,{commands:n,queries:r,disabled:i||y},h)}if(!w.icon||!w.command)return null;const v=w.icon,x=w.command,k=w.active?r[w.active]():void 0;return o.jsx(mt,{label:w.tooltip??ft(a,w),children:o.jsx("button",{type:"button",className:X.iconButton,"aria-label":Dr(a,w),"aria-pressed":k,disabled:i||y,onPointerDown:g=>g.preventDefault(),onMouseDown:g=>g.preventDefault(),onClick:()=>{yi(n,x)},children:o.jsx(v,{className:X.icon})})},h)})},p.id)};return o.jsxs("div",{className:X.iconNav,role:"toolbar","aria-label":a("toolbarAria"),children:[l.length>0?o.jsx("div",{className:X.iconNavMain,children:l.map(m)}):null,c?o.jsx("div",{className:X.iconNavEnd,children:m(c)}):null]})}const pw=["--wysiwyg-menu-color","--wysiwyg-menu-background","--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function hw(e){const t={};for(const n of pw){const r=getComputedStyle(e).getPropertyValue(n).trim();if(r){t[n]=r;continue}let i=e;for(;i;){const a=i.style.getPropertyValue(n).trim();if(a){t[n]=a;break}i=i.parentElement}}return t}function gw({menus:e,catalog:t,commands:n,queries:r,disabled:i,compact:a,openMenuId:l,onOpenMenuIdChange:c}){const m=V(),[p,b]=s.useState(!1),[h,w]=s.useState({}),y=s.useRef(null),v=s.useRef(null),x=s.useRef(null),k=s.useRef(null),g=s.useCallback(()=>{b(!1),c(null)},[c]);s.useLayoutEffect(()=>{!p||!y.current||w(hw(y.current))},[p]),s.useEffect(()=>{var A;p&&((A=x.current)==null||A.focus())},[p]),s.useEffect(()=>{if(!p)return;const A=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=A}},[p]),s.useEffect(()=>{if(!p)return;const A=E=>{var L;if(E.key==="Escape"){if(E.preventDefault(),E.stopPropagation(),l){c(null);return}g(),(L=v.current)==null||L.focus()}},N=E=>{var L;k.current&&!k.current.contains(E.target)&&(g(),(L=v.current)==null||L.focus())};return document.addEventListener("keydown",A,!0),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",A,!0),document.removeEventListener("pointerdown",N)}},[p,l,c,g]);const S=A=>e.map(N=>{const E=t.menus[N.id];return E?o.jsx(yw,{def:E,itemIds:N.items,catalog:t,commands:n,queries:r,disabled:i,variant:A,open:(A==="overlay"||!p)&&l===N.id,onOpenChange:L=>c(L?N.id:null),onItemRun:A==="overlay"?()=>{var L;g(),(L=v.current)==null||L.focus()}:void 0},`${A}-${N.id}`):null});return o.jsxs("div",{className:X.menuBar,ref:y,children:[o.jsx(mt,{label:m("brandMarkAria"),children:o.jsx("span",{className:X.brandMark,role:"img","aria-label":m("brandMarkAria"),children:o.jsx(tu,{className:X.brandMarkIcon})})}),o.jsx("div",{className:X.menuBarCompact,hidden:a===void 0?void 0:!a,children:o.jsx(mt,{label:m("menuHamburgerAria"),children:o.jsx("button",{ref:v,type:"button",className:`${X.menuButton} ${X.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":p,"aria-label":m("menuHamburgerAria"),disabled:i,onClick:()=>{if(p){g();return}c(null),b(!0)},children:o.jsx(hu,{className:X.icon})})})}),o.jsx("div",{className:X.menuBarDesktop,hidden:a===void 0?void 0:a,children:S("dropdown")}),p?o.jsx(ie,{children:o.jsx("div",{className:X.toolbar,"data-menu-overlay-portal":"",style:h,children:o.jsxs("div",{ref:k,className:X.menuOverlay,role:"dialog","aria-modal":"true","aria-label":m("menuOverlayAria"),children:[o.jsxs("div",{className:X.menuOverlayHeader,children:[o.jsx("span",{className:X.menuOverlayTitle,children:m("menuOverlayAria")}),o.jsx("button",{ref:x,type:"button",className:X.iconButton,"aria-label":m("menuCloseAria"),onClick:()=>{var A;g(),(A=v.current)==null||A.focus()},children:o.jsx(We,{className:X.icon})})]}),o.jsx("div",{className:X.menuOverlayBody,children:S("overlay")})]})})}):null]})}function Pr(e,t){var n,r;if(ct(e))return!1;if(Cn(e)){const i=(n=t.submenus)==null?void 0:n[e.submenu];return i?i.panel?!0:e.items.some(a=>Pr(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function bw(e,t,n){if(!ct(e[t])||!e.slice(t+1).some(a=>Pr(a,n)))return!1;let i=!1;for(let a=t-1;a>=0;a--){const l=e[a];if(ct(l)){i=!0;continue}if(Pr(l,n))return!i}return!1}function yw({def:e,itemIds:t,catalog:n,commands:r,queries:i,disabled:a,variant:l,open:c,onOpenChange:m,onItemRun:p}){const b=V(),h=s.useRef(null),w=l==="overlay"?`overlay-${e.id}-menu`:`${e.id}-menu`,[y,v]=s.useState(null);s.useEffect(()=>{c||v(null)},[c]),s.useEffect(()=>{if(!c||l==="overlay")return;const k=S=>{h.current&&!h.current.contains(S.target)&&m(!1)},g=S=>{if(S.key==="Escape"){if(S.preventDefault(),S.stopPropagation(),y){v(null);return}m(!1)}};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",g,!0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",g,!0)}},[c,y,m,l]);const x=()=>{m(!1),p==null||p()};return o.jsxs("div",{className:X.menuWrap,ref:h,children:[o.jsx("button",{type:"button",className:X.menuButton,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":w,"aria-label":Dr(b,e),disabled:a,onClick:()=>m(!c),children:ft(b,e)}),c?o.jsx("div",{className:X.menu,role:"menu",id:w,children:o.jsx(Ic,{entries:t,catalog:n,commands:r,queries:i,disabled:a,variant:l,onClose:x,openSubmenuId:y,onOpenSubmenuIdChange:v})}):null]})}function Ic({entries:e,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,openSubmenuId:c,onOpenSubmenuIdChange:m}){return o.jsx(o.Fragment,{children:e.map((p,b)=>{if(ct(p))return bw(e,b,t)?o.jsx("div",{role:"separator",className:X.menuSeparator},`separator-${b}`):null;if(Cn(p))return o.jsx(ww,{entry:p,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,open:c===p.submenu,onOpenChange:w=>m==null?void 0:m(w?p.submenu:null)},`submenu-${p.submenu}-${b}`);const h=t.items[p];return!h||!h.command?null:o.jsx(xw,{item:h,commands:n,queries:r,disabled:i,onClose:l},p)})})}function xw({item:e,commands:t,queries:n,disabled:r,onClose:i}){const a=V();if(!e.command)return null;const l=e.icon,c=e.command,m=e.active?n[e.active]():void 0,p=e.enabled?!n[e.enabled]():!1,b=e.toggle?"menuitemcheckbox":e.active?"menuitemradio":"menuitem";return o.jsxs("button",{type:"button",role:b,className:X.menuItem,"aria-checked":m,disabled:r||p,onClick:()=>{i(),yi(t,c)},children:[l?o.jsx(l,{className:X.icon}):null,ft(a,e)]})}function ww({entry:e,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,open:c,onOpenChange:m}){var E;const p=V(),b=s.useRef(null),h=s.useRef(null),[w,y]=s.useState(null),v=(E=t.submenus)==null?void 0:E[e.submenu],x=a==="overlay"?`overlay-${e.submenu}-submenu`:`${e.submenu}-submenu`,k=v==null?void 0:v.panel,g=v!=null&&v.enabled?!r[v.enabled]():!1,S=a==="overlay";if(s.useEffect(()=>{c||y(null)},[c]),!v||!k&&!e.items.some(L=>Pr(L,t)))return null;const A=L=>{(L.key==="ArrowRight"||L.key==="Enter"||L.key===" ")&&(L.preventDefault(),L.stopPropagation(),m(!0),requestAnimationFrame(()=>{var I;const M=(I=h.current)==null?void 0:I.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');M==null||M.focus()}))},N=L=>{var M;L.key==="ArrowLeft"&&(L.preventDefault(),L.stopPropagation(),m(!1),(M=b.current)==null||M.focus())};return o.jsxs("div",{className:X.submenuWrap,onMouseEnter:S?void 0:()=>m(!0),onMouseLeave:S?void 0:()=>m(!1),children:[o.jsx("button",{ref:b,type:"button",role:"menuitem",className:`${X.menuItem} ${X.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":x,"aria-label":Dr(p,v),disabled:i||g,onClick:()=>m(S?!c:!0),onKeyDown:A,children:ft(p,v)}),c?o.jsx("div",{ref:h,className:`${X.menu} ${X.submenu}`,role:"menu",id:x,"aria-label":Dr(p,v),onKeyDown:N,children:k?o.jsx(k,{commands:n,queries:r,disabled:i||g,onMenuClose:l}):o.jsx(Ic,{entries:e.items,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,openSubmenuId:w,onOpenSubmenuIdChange:y})}):null]})}function qo({catalog:e,layout:t,commands:n,queries:r,disabled:i,menuVisible:a=!0,toolbarVisible:l=!0,compact:c,position:m="top"}){const[p,b]=s.useState(null);return!a&&!l?null:o.jsxs("div",{className:X.toolbar,"data-compact":c?"":void 0,"data-toolbar-position":m,children:[a?o.jsx(gw,{menus:t.menus,catalog:e,commands:n,queries:r,disabled:i,compact:c,openMenuId:p,onOpenMenuIdChange:b}):null,l?o.jsx(fw,{groups:t.iconGroups,catalog:e,commands:n,queries:r,disabled:i}):null]})}const vw="_root_1621j_1",Sw="_fullscreen_1621j_36",Cw="_exitFullscreen_1621j_48",kw="_exitFullscreenIcon_1621j_79",Dw="_menuChrome_1621j_94",Pw="_body_1621j_104",Aw="_iconChrome_1621j_134",jw="_workspace_1621j_178",Ew="_htmlFileDropOverlay_1621j_190",Tw="_surface_1621j_204",Nw="_visual_1621j_211",Lw="_html_1621j_190",De={root:vw,fullscreen:Sw,exitFullscreen:Cw,exitFullscreenIcon:kw,menuChrome:Dw,body:Pw,iconChrome:Aw,workspace:jw,htmlFileDropOverlay:Ew,surface:Tw,visual:Nw,html:Lw},Mw=s.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:i},a){const l=V();return o.jsx("textarea",{ref:a,className:`${De.surface} ${De.html}`,value:t,onChange:c=>n(c.target.value),placeholder:r,disabled:i,"aria-label":l("htmlEditorAria"),spellCheck:!1})}),Rw=s.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:i,onBeforeInput:a,onPointerDown:l,onContextMenu:c},m){const p=V(),b=s.useRef(null),h=s.useRef(a);h.current=a;const w=y=>{b.current=y,typeof m=="function"?m(y):m&&(m.current=y)};return s.useLayoutEffect(()=>{const y=b.current;y&&(y.innerHTML!==t&&(y.innerHTML=t),Ps(y))},[t]),s.useLayoutEffect(()=>{const y=b.current;if(!y)return;const v=x=>{var k;(k=h.current)==null||k.call(h,x)};return y.addEventListener("beforeinput",v),()=>y.removeEventListener("beforeinput",v)},[]),o.jsx("div",{ref:w,className:`${De.surface} ${De.visual}`,contentEditable:!i,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":p("visualEditorAria"),"aria-disabled":i||void 0,"data-placeholder":r,onPointerDown:l,onContextMenu:c,onInput:y=>{n(y.currentTarget.innerHTML)}})});function _w({value:e,defaultValue:t="",onChange:n,onAutoSave:r,mode:i,defaultMode:a="visual",onModeChange:l,fullscreen:c,defaultFullscreen:m=!1,onFullscreenChange:p,placeholder:b,disabled:h,readOnly:w=!1,className:y,locale:v="en",toolbarBackground:x,menuColor:k,menuBackground:g,menuFontSize:S,menuFontFamily:A,border:N,menuVisible:E=!0,toolbarVisible:L=!0,allowedChrome:M,customActions:I,customFonts:j,transformHtml:T,loadCustomParagraphStyles:P,onSaveCustomParagraphStyle:R,onDeleteCustomParagraphStyle:W,customImagePicker:O,disableBuiltinImageInsert:Z,disableHtmlFileDrop:te=!1,toolbarCustomization:ce,darkMode:re=!1,darkModePersistence:he,toolbarPosition:ne="top",toolbarPositionPersistence:Q}){const D=!!(h||w),[$,Y]=Ho({value:e,defaultValue:t,onChange:n}),[B,fe]=Ho({value:i,defaultValue:a,onChange:l}),[ue,we]=Ho({value:c,defaultValue:m,onChange:p}),_=s.useRef(null),Ce=s.useRef(null),Pt=s.useRef(null);Pt.current===null&&(Pt.current=p1($));const Ee=Pt.current,ot=s.useRef($);ot.current=$;const z=s.useRef(B);z.current=B;const Ji=s.useRef(ue);Ji.current=ue;const ke=s.useRef(null),jn=s.useRef(T);jn.current=T;const Te=s.useRef({}),Pe=s.useRef(null),Ne=s.useRef(null),ze=s.useRef(null),Oe=s.useRef(null),Le=s.useRef(null),[En,_r]=s.useState(Qe),Ir=s.useRef(En);Ir.current=En;const Ye=s.useRef(Ct),[Yt,Tn]=s.useState({value:null,unit:Ct,mixed:!1}),it=s.useRef(Yt);it.current=Yt;const[Jt,Fr]=s.useState({value:null,mixed:!1}),Zt=s.useRef(Jt);Zt.current=Jt;const[Qt,Br]=s.useState({value:null,mixed:!1}),en=s.useRef(Qt);en.current=Qt;const[tn,Hr]=s.useState({value:null,mixed:!1}),nn=s.useRef(tn);nn.current=tn;const[zr,Or]=s.useState({tag:null,mixed:!1}),Kr=s.useRef(zr);Kr.current=zr;const[Zi,$r]=s.useState({align:"left",mixed:!1}),Ur=s.useRef(Zi);Ur.current=Zi;const[Qi,Wr]=s.useState({type:null,mixed:!1}),rn=s.useRef(Qi);rn.current=Qi;const[ea,Gr]=s.useState(!1),ta=s.useRef(ea);ta.current=ea;const[Vr,qr]=s.useState(!1),na=s.useRef(Vr);na.current=Vr;const[ra,oa]=s.useState(!1),ia=s.useRef(ra);ia.current=ra;const[on,Nn]=s.useState({open:!1,tab:"general"}),[Xr,aa]=s.useState(!1),[an,la]=s.useState({open:!1,html:""}),[Yr,Ln]=s.useState(null),[Fc,Jr]=s.useState(!1),[Bc,Zr]=s.useState(!1),[At,Mn]=s.useState(()=>he?re:Hl()??re),[Ke,Rn]=s.useState(()=>Q?ne:zl()??ne),[yt,_n]=s.useState({open:!1,tab:"general",value:hn()}),[xt,In]=s.useState({open:!1,tab:"font",value:ri()}),[Qr,sa]=s.useState([]),[eo,to]=s.useState(!1),[Hc,Fn]=s.useState(!1),[be,ln]=s.useState({open:!1}),[Ae,Bn]=s.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[no,ro]=s.useState({open:!1,existingIds:[]}),[zc,Hn]=s.useState({open:!1}),[zn,On]=s.useState({open:!1,tab:"general",value:fc(),aspectRatio:1}),[oo,io]=s.useState({open:!1}),[Kn,ao]=s.useState({open:!1,value:_h()}),[$n,lo]=s.useState({open:!1,value:Wh()}),[Un,so]=s.useState({open:!1,value:eg()}),[sn,co]=s.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1}),[ye,jt]=s.useState(null),ca=s.useRef(ye);ca.current=ye;const[uo,Wn]=s.useState(!1),ua=s.useRef(uo);ua.current=uo;const da=s.useRef(void 0),Gn=s.useRef(Qr);Gn.current=Qr;const ma=s.useRef(eo);ma.current=eo;const mo=!!(P&&R),fo=s.useRef(mo);fo.current=mo;const fa=s.useRef(P);fa.current=P;const pa=s.useRef(R);pa.current=R;const ha=s.useRef(W);ha.current=W;const ga=s.useRef(O);ga.current=O;const ba=s.useRef(ce);ba.current=ce;const ya=s.useRef(he);ya.current=he;const xa=s.useRef(Q);xa.current=Q;const wa=s.useRef(At);wa.current=At;const va=s.useRef(Ke);va.current=Ke;const Sa=s.useRef(Z);Sa.current=Z;const po=s.useRef(0),cn=s.useRef(0),Ca=s.useRef(0),Vn=s.useRef(0),ka=s.useRef(0),qn=s.useRef(0),Da=s.useRef(0),at=s.useMemo(()=>ss(j),[j]),un=s.useRef(at);un.current=at;const ho=s.useMemo(()=>yd($,at).join(`
|
|
90
|
+
`.trim();function Zo(e,t,n=""){const{hrefs:r,body:i}=vn(t),a=e.createElement("meta");a.setAttribute("charset","utf-8");const l=e.createElement("title");l.textContent=n;const c=e.createElement("style");c.textContent=jd;const m=r.map(p=>{const b=e.createElement("link");return b.rel="stylesheet",b.href=p,b});e.head.replaceChildren(a,l,c,...m),e.title=n,e.body.innerHTML=i}const Ed=1e3;function Td(e){const t=document.createElement("iframe");t.setAttribute("aria-hidden","true"),t.setAttribute("data-wysiwyg-print",""),t.style.position="fixed",t.style.right="0",t.style.bottom="0",t.style.width="0",t.style.height="0",t.style.border="0",document.body.append(t);const n=t.contentDocument,r=t.contentWindow;if(!n||!r){t.remove();return}Zo(n,e);let i=!1;const a=()=>{i||(i=!0,t.remove())};r.addEventListener("afterprint",a),r.focus(),r.print(),window.setTimeout(a,Ed)}function Nd(e){return{save:async()=>{await ld(e.getHtml())},open:async()=>{const t=await sd();t!==null&&e.setHtml(t)},print:()=>{Td(e.getHtml())}}}function Ld(e){return{toggleBold:()=>{e.toggleFontMark("bold")},toggleItalic:()=>{e.toggleFontMark("italic")},toggleUnderline:()=>{e.toggleFontMark("underline")},toggleStrikethrough:()=>{e.toggleFontMark("strikethrough")},clearFormatting:()=>{e.clearFormatting()},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)}}}function Md(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(),customParagraphStylesEnabled:()=>e.customParagraphStylesEnabled(),getCustomParagraphStyles:()=>e.getCustomParagraphStyles(),isCustomParagraphStylesLoading:()=>e.isCustomParagraphStylesLoading()}}function Rd(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function _d(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function Id(e){return{openLinkDialog:t=>{e.openLinkDialog(t)},applyLink:t=>{e.applyLink(t)},openBookmarkDialog:()=>{e.openBookmarkDialog()},applyBookmark:t=>{e.applyBookmark(t)},openImageDialog:()=>{e.openImageDialog()},applyImage:t=>{e.applyImage(t)},openImageProperties:t=>{e.openImageProperties(t)},applyImageProperties:t=>{e.applyImageProperties(t)},insertHorizontalRule:()=>{e.insertHorizontalRule()}}}function Fd(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected()}}function Bd(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()}}}function Hd(e){return{isInTable:()=>e.isInTable()}}function zd(e){return{setVisualMode:()=>{e.setMode("visual")},setHtmlMode:()=>{e.setMode("html")},toggleFullscreen:()=>{e.setFullscreen(!e.getFullscreen())},openCustomizeToolbar:()=>{e.openCustomizeToolbar()},openDocumentPreview:()=>{e.openDocumentPreview()},setLightMode:()=>{e.setDarkMode(!1)},setDarkMode:()=>{e.setDarkMode(!0)},setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function Od(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isToolbarPositionTop:()=>e.getToolbarPosition()==="top",isToolbarPositionLeft:()=>e.getToolbarPosition()==="left",isToolbarPositionRight:()=>e.getToolbarPosition()==="right",isToolbarPositionBottom:()=>e.getToolbarPosition()==="bottom"}}function Kd(e){return{...Nd(e),...Rd(e),...zu(e),...Id(e),...Bd(e),...zd(e),...Ld(e)}}function $d(e){return{...Od(e),..._d(e),...Fd(e),...Hd(e),...Md(e)}}const Ci=["pt","px","em","rem","%"],Ct="pt",Ud={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]},Wd={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},Gd=new Set(Ci),Vd=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function Tr(e){return Gd.has(e)}function ve(e){return Math.round(e*100)/100}function J(e){const t=ve(e);return Number.isInteger(t),String(t)}function ki(e,t){return`${J(e)}${t}`}function Di(e){const t=e.trim();if(!t)return null;const n=t.match(Vd);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return{value:r,unit:i}}function qd(e,t){const n=e.trim();if(!n)return null;const r=Di(n);if(r)return Tr(r.unit)?kt(r.value,r.unit):null;const i=Number(n.replace(",","."));return Number.isFinite(i)?kt(i,t):null}function kt(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Wd[t];return{value:ve(Math.min(r,Math.max(n,e))),unit:t}}function ds(e,t,n,r){const i=n>0?n:16,a=r>0?r:16;switch(t){case"px":return ve(e);case"pt":return ve(e*.75);case"em":return ve(e/i);case"rem":return ve(e/a);case"%":return ve(e/i*100)}}function Xd(e,t,n,r){const i=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*i;case"rem":return e*a;case"%":return e/100*i}}function ms(e,t,n,r,i){if(t===n)return ve(e);const a=Xd(e,t,r,i);return ds(a,n,r,i)}function gr(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Yd(e){const t=e.style.fontSize;if(!t)return null;const n=Di(t);return!n||!Tr(n.unit)?null:{value:n.value,unit:n.unit}}function fs(e,t){let n=gr(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Yd(n);if(r)return r;n=n.parentElement}return null}function Jd(e,t){const n=gr(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function ps(e,t){var a;let n=gr(t);for(;n&&n!==e;){if(n.style.fontSize){const c=n.parentElement??e,m=parseFloat(getComputedStyle(c).fontSize);return Number.isFinite(m)&&m>0?m:16}n=n.parentElement}const r=((a=gr(t))==null?void 0:a.parentElement)??e,i=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(i)&&i>0?i:16}function hs(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function Zd(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function Ga(e=Ct){return{value:null,unit:e,mixed:!1}}function Qd(e,t=Ct){const n=window.getSelection();if(!n||n.rangeCount===0)return Ga(t);const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer))return Ga(t);const i=r.collapsed?[]:Be(r).filter(p=>p.data.length>0),a=i.length>0?i:[r.startContainer],l=a.map(p=>fs(e,p)),c=l[0];if(l.every(p=>Zd(p,c))&&c)return{value:c.value,unit:c.unit,mixed:!1};if(l.every(p=>p===null)){const p=a.map(h=>Jd(h,e)),b=p[0];if(p.every(h=>Math.abs(h-b)<.05)){const h=ps(e,a[0]),w=hs(e);return{value:ds(b,t,h,w),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function em(e,t){return{parentPx:ps(e,t),rootPx:hs(e)}}function tm(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function Va(e,t,n){const r=kt(t,n);if(!r)return!1;const i=tm(e);if(!i||i.collapsed)return!1;const a=ki(r.value,r.unit);ut(i);const l=Be(i).filter(c=>c.data.length>0);for(const c of l){const m=fs(e,c);m&&m.value===r.value&&m.unit===r.unit||Ar(c,p=>{p.style.fontSize=a})}return Ut(l),!0}function nm(e,t){e.style.fontSize=ki(t.value,t.unit)}function rm(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Ro(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]),i=Number(t[3]),a=t[4]===void 0?1:Number(t[4]);return[n,r,i,a].every(l=>Number.isFinite(l))?{r:n,g:r,b:i,a}:null}function _o(e,t,n){const r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Io(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 om={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 im(e){const t=e.trim().toLowerCase();return t===""||t==="transparent"||t==="inherit"||t==="initial"||t==="unset"||t==="currentcolor"||t==="currentColor"}function me(e){const t=e.trim();if(!t||im(t))return null;const n=Io(t);if(n)return n;const r=Ro(t);if(r)return r.a===0?null:_o(r.r,r.g,r.b);const i=om[t.toLowerCase()];if(i)return i;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 m=Io(t);if(m==="#010203")return m;const p=Ro(t);return p&&_o(p.r,p.g,p.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(l.startsWith("#"))return Io(l);const c=Ro(l);return!c||c.a===0?null:_o(c.r,c.g,c.b)}function gs(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?me(n):null}function br(e,t,n){let r=rm(t);for(;r&&r!==e&&r instanceof HTMLElement;){const i=gs(r,n);if(i)return i;r=r.parentElement}return null}function yr(e,t){return e instanceof HTMLElement?gs(e,t)!==null:!1}function Pi(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function bs(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function am(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!yr(i,n)){r=i;continue}if(pt(i,r),yr(i,n)&&(Pi(i,n),Dt(i))){_e(i);continue}r=i}}function ys(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function qa(e,t){const n=ys(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:Be(n).filter(m=>m.data.length>0),a=(r.length>0?r:[n.startContainer]).map(m=>br(e,m,t)),l=a[0]??null;return a.every(m=>m===l)?{value:l,mixed:!1}:{value:null,mixed:!0}}function Fo(e,t,n){const r=ys(e);if(!r||r.collapsed)return!1;const i=n===null?null:me(n);if(n!==null&&i===null)return!1;ut(r);const a=Be(r).filter(l=>l.data.length>0);for(const l of a){const c=br(e,l,t);if(i===null){if(c===null)continue;am(e,l,t);continue}c!==i&&Ar(l,m=>{bs(m,t,i)})}return Ut(a),!0}function Xa(e,t,n){if(n.value===null){Pi(e,t);return}const r=me(n.value);r&&bs(e,t,r)}function lm(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function sm(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 i=r.splitText(n);e.setStart(i,0),e.collapse(!0)}function cm(e){var r,i,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(i=e.startContainer.parentNode)==null||i.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 xs(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!n.some(a=>yr(i,a))){r=i;continue}pt(i,r);for(const a of n)yr(i,a)&&Pi(i,a);if(Dt(i)){_e(i);continue}r=i.isConnected?i:t}return t}function um(e,t,n){sm(t);const r=cm(t);return xs(e,r,n)}function dm(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&br(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&br(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const Ue=["bold","italic","underline","strikethrough"],Mt={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},mm=new Set(["underline","line-through","overline"]);function Qe(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function fm(e,t){return Ue.every(n=>e[n]===t[n])}function pm(e){return Ue.some(t=>e[t]!==void 0)}function ws(e,t){const n={...e};if(!t)return n;for(const r of Ue){const i=t[r];i!==void 0&&(n[r]=i)}return n}function hm(e,t,n){const r=e[n]??t[n],i={...e,[n]:!r};return i[n]===t[n]&&delete i[n],i}function dt(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>mm.has(n))}function Ft(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 vs(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(Mt.bold.has(r))return!0;const l=n.style.fontWeight;if(!l)return null;if(l==="bold"||l==="bolder")return!0;const c=Number(l);return Number.isNaN(c)?l==="normal"||l==="lighter"?!1:null:c>=700}if(t==="italic"){if(Mt.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(Mt.underline.has(r))return!0;const l=n.style.textDecorationLine||n.style.textDecoration;if(!l)return null;if(l==="none")return!1;const c=dt(n);return c.includes("underline")?!0:c.length>0?!1:null}if(Mt.strikethrough.has(r))return!0;const i=n.style.textDecorationLine||n.style.textDecoration;if(!i)return null;if(i==="none")return!1;const a=dt(n);return a.includes("line-through")?!0:a.length>0?!1:null}function xr(e,t){return vs(e,t)===!0}function Bt(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const i=vs(r,n);if(i!==null)return i;r=r.parentElement}return!1}function Ss(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=dt(e);r.includes("underline")||r.push("underline"),Ft(e,r);return}const n=dt(e);n.includes("line-through")||n.push("line-through"),Ft(e,n)}function Cs(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"){Ft(e,dt(e).filter(n=>n!=="underline"));return}Ft(e,dt(e).filter(n=>n!=="line-through"))}function gm(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=dt(e).filter(i=>i!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}Ft(e,r);return}const n=dt(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}Ft(e,n)}function bm(e,t){Ar(e,n=>Ss(n,t))}function ym(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const i=r.parentElement;if(!qe(i)||!xr(i,n)){r=i;continue}if(pt(i,r),xr(i,n)){if(Mt[n].has(i.tagName.toLowerCase())){_e(i);continue}if(Cs(i,n),Dt(i)){_e(i);continue}}r=i}}function xm(e,t,n){const r=Be(t).filter(i=>i.data.length>0);return r.length===0?Bt(e,t.startContainer,n):r.every(i=>Bt(e,i,n))}function wm(e,t,n,r){ut(t);const i=Be(t).filter(a=>a.data.length>0);for(const a of i)r?Bt(e,a,n)||bm(a,n):ym(e,a,n);Ut(i)}function or(e){const t=window.getSelection();if(!t||t.rangeCount===0)return Qe();const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return Qe();if(n.collapsed)return Qo(e,n);const r=Be(n).filter(a=>a.data.length>0);if(r.length===0)return Qo(e,n);const i=Qe();for(const a of Ue)i[a]=Bt(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const l of Ue)i[l]=i[l]&&Bt(e,r[a],l);return i}function Qo(e,t){const n=Qe();for(const r of Ue)n[r]=Bt(e,t.startContainer,r);return n}function Ya(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer)||r.collapsed)return!1;const i=xm(e,r,t);return wm(e,r,t,!i),!0}function vm(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 i=r.splitText(n);e.setStart(i,0),e.collapse(!0)}function Sm(e,t,n){var a,l,c;vm(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 m=document.createTextNode("");(a=t.startContainer.parentNode)==null||a.insertBefore(m,t.startContainer.nextSibling),r=m}else if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0){const m=document.createTextNode("");(l=t.startContainer.parentNode)==null||l.insertBefore(m,t.startContainer),r=m}else{const m=document.createTextNode("");r&&r!==t.startContainer?(c=r.parentNode)==null||c.insertBefore(m,r):t.startContainer.appendChild(m),r=m}let i=r;for(;i.parentElement&&i.parentElement!==e;){const m=i.parentElement;if(!qe(m)){i=m;continue}if(!n.some(b=>xr(m,b))){i=m;continue}pt(m,i);for(const b of n)if(xr(m,b)){if(Mt[b].has(m.tagName.toLowerCase())){_e(m);break}if(Cs(m,b),Dt(m)){_e(m);break}}i=m.isConnected?m:r}return r}function Cm(e,t,n){for(const r of Ue)n[r]!==t[r]&&(n[r]?Ss(e,r):gm(e,r))}function km(e,t,n,r,i,a){var g,S;const l=window.getSelection();if(!l||l.rangeCount===0)return;const c=l.getRangeAt(0);if(!se(e,c.commonAncestorContainer))return;const m=Qo(e,c),p=ws(m,n),b=Ue.filter(A=>m[A]&&!p[A]),h=dm(e,c.startContainer,i),w=Ad(e,c.startContainer,a);let y=null;b.length>0?(y=Sm(e,c,b),h.length>0&&xs(e,y,h),w&&Jo(e,y)):h.length>0?(y=um(e,c,h),w&&Jo(e,y)):w?y=Pd(e,c):c.deleteContents();const v=document.createElement("span");Cm(v,m,p),r&&nm(v,r),i!=null&&i.color&&Xa(v,"color",i.color),i!=null&&i.backgroundColor&&Xa(v,"backgroundColor",i.backgroundColor),a&&Sd(v,a),v.textContent=t;const x=v.style.cssText.trim()?v:document.createTextNode(t);y?((g=y.parentNode)==null||g.insertBefore(x,y),y.nodeType===Node.TEXT_NODE&&!y.data&&((S=y.parentNode)==null||S.removeChild(y))):c.insertNode(x);const k=document.createRange();k.selectNodeContents(x),k.collapse(!1),l.removeAllRanges(),l.addRange(k)}const wr="data-page";function ks(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(wr)}function Ds(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function Dm(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function Dn(e){return Ds(e).find(n=>n.hasAttribute(wr))??null}function Pm(e){if(Dm(e))return null;const t=Ds(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"?null:n}function Am(e){const t=Dn(e);if(t)return t;const n=Pm(e);if(n)return n.setAttribute(wr,""),n;const r=document.createElement("div");for(r.setAttribute(wr,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),r}function Ai(e){return Dn(e)??e}function Ps(e){const t=Dn(e),n=(t==null?void 0:t.style.backgroundColor.trim())??"";n?e.style.backgroundColor=n:e.style.removeProperty("background-color")}function Ja(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function jm(e,t){return t?e===t||e.contains(t):!1}function Za(e,t){var a;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,i;for(;i=n.nextNode();){if(i===t||t.contains(i)||t.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING)return r;r+=((a=i.textContent)==null?void 0:a.length)??0}return r}function Qa(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return Za(e,t)+n;let r=0;const i=t.childNodes;for(let l=0;l<n&&l<i.length;l+=1)r+=((a=i[l].textContent)==null?void 0:a.length)??0;return Za(e,t)+r}function el(e,t){var l,c;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=Math.max(0,t),i,a=null;for(;i=n.nextNode();){a=i;const m=((l=i.textContent)==null?void 0:l.length)??0;if(r<=m)return{node:i,offset:r};r-=m}return a?{node:a,offset:((c=a.textContent)==null?void 0:c.length)??0}:{node:e,offset:e.childNodes.length}}function ji(e,t,n){const r=document.createRange(),i=el(e,t),a=el(e,n);return r.setStart(i.node,i.offset),r.setEnd(a.node,a.offset),r}function As(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function tl(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function Em(e,t){return t.mode!=="visual"?null:t.visualRange&&As(t.visualRange,e)?t.visualRange:ji(e,t.start,t.end)}function lt(e){var n;if(e.mode==="html"&&e.htmlEl){const r=e.htmlEl.selectionStart,i=e.htmlEl.selectionEnd;return{mode:"html",text:e.htmlEl.value.slice(r,i),collapsed:r===i,start:r,end:i,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(jm(t,a.commonAncestorContainer)){const l=Qa(t,a.startContainer,a.startOffset),c=Qa(t,a.endContainer,a.endOffset);return{mode:"visual",text:a.toString(),collapsed:a.collapsed,start:Math.min(l,c),end:Math.max(l,c),visualRange:a.cloneRange()}}}const i=((n=t.textContent)==null?void 0:n.length)??0;return{mode:"visual",text:"",collapsed:!0,start:i,end:i,visualRange:null}}return{mode:e.mode,text:"",collapsed:!0,start:0,end:0,visualRange:null}}function nl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Tm(e){if(e.snapshot.mode==="html"){const a=e.getHtml(),l=e.snapshot.start,c=e.snapshot.end,m=e.asHtml?e.content:nl(e.content);e.setHtml(a.slice(0,l)+m+a.slice(c));const p=e.htmlEl;if(p){const b=l+m.length;p.focus(),p.setSelectionRange(b,b)}return}const t=e.visualEl;if(!t){const a=e.asHtml?e.content:nl(e.content);e.setHtml(e.getHtml()+a);return}const r=(e.snapshot.visualRange&&As(e.snapshot.visualRange,t)?e.snapshot.visualRange:null)??ji(t,e.snapshot.start,e.snapshot.end);if(r.deleteContents(),e.content)if(e.asHtml){const a=r.createContextualFragment(e.content),l=a.lastChild;r.insertNode(a),l&&(r.setStartAfter(l),r.collapse(!0))}else{const a=document.createTextNode(e.content);r.insertNode(a),r.setStartAfter(a),r.collapse(!0)}const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r),e.setHtml(t.innerHTML)}const Ei=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),js=new Set(["table","thead","tbody","tr","td","th"]),Ti=new Set([...js,"ul","ol","li","pre","hr"]);function oe(e){return e.tagName.toLowerCase()}function Pn(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Ni(e){return e instanceof HTMLElement&&(oe(e)==="ul"||oe(e)==="ol")}function Ie(e){return e instanceof HTMLElement&&oe(e)==="li"}function ht(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function Li(e){const t=e.collapsed?[]:Be(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function Ht(e,t,n){var m,p,b;if(t.nodeType===Node.TEXT_NODE){const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let w=0,y;for(;y=h.nextNode();){if(y===t)return w+n;w+=((m=y.textContent)==null?void 0:m.length)??0}return w}let r=0;const i=t.childNodes;for(let h=0;h<n&&h<i.length;h+=1)r+=((p=i[h].textContent)==null?void 0:p.length)??0;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=0,c;for(;c=a.nextNode();){if(t.contains(c)||t.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)return l+r;l+=((b=c.textContent)==null?void 0:b.length)??0}return l+r}function Mi(e,t,n){const r=ji(e,t,n),i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r)}function Wt(e,t){const n=ht(e);if(!n)return!1;const r=Ht(e,n.startContainer,n.startOffset),i=Ht(e,n.endContainer,n.endOffset),a=Math.min(r,i),l=Math.max(r,i),c=t();return Mi(e,a,l),c}function Ri(e,t){if(oe(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 gt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function Nm(e,t){let n=Pn(t);for(;n&&n!==e;){if(ks(n,e)){n=n.parentElement;continue}const r=oe(n);if(Ei.has(r)&&n instanceof HTMLElement)return n;if(js.has(r)||r==="pre")return null;n=n.parentElement}return null}function Gt(e){const t=ht(e);if(!t)return[];const n=new Set,r=[];for(const i of Li(t)){const a=Nm(e,i);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function ei(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=oe(e);return Ei.has(t)||Ti.has(t)?!1:qe(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Lm(e,t){let n=Pn(t);for(;n&&n!==e;){if(Ti.has(oe(n)))return!0;n=n.parentElement}return!1}function Mm(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Rm(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let i=r,a=r;for(;i>0&&ei(n[i-1]);)i-=1;for(;a<n.length-1&&ei(n[a+1]);)a+=1;return n.slice(i,a+1)}function _m(e,t,n){return n.startContainer===e?e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild:n.startContainer===t&&e!==t?e.firstChild:Mm(e,n.startContainer)}function Im(e,t){const n=Ai(e);if(Lm(e,t.startContainer))return null;if(!n.firstChild){const l=document.createElement("p");return l.appendChild(document.createElement("br")),n.appendChild(l),l}const r=_m(n,e,t);if(!r||r instanceof Element&&Ti.has(oe(r))||r instanceof HTMLElement&&Ei.has(oe(r))||!ei(r))return null;const i=Rm(n,r),a=document.createElement("p");n.insertBefore(a,i[0]);for(const l of i)a.appendChild(l);return a}function An(e){const t=Gt(e);if(t.length>0)return t;const n=ht(e);if(!n)return[];const r=Im(e,n);return r?[r]:[]}function zt(e){const t=e.parentElement;return t&&Ni(t)?t:null}function Es(e){if(e.length===0)return[];const t=[[e[0]]];for(let n=1;n<e.length;n+=1){const r=e[n-1],i=e[n];r.parentNode===i.parentNode&&Fm(r,i)?t[t.length-1].push(i):t.push([i])}return t}function Fm(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}const vr=["p","h1","h2","h3","h4","h5","h6"],Bm=new Set(vr),Ts=new Set([...vr,"div"]),Nr=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),Hm=()=>({tag:null,mixed:!1});function Ns(e){return Bm.has(e)}function zm(e){return Ns(e)?e:e==="div"?"p":null}function Om(e){return e instanceof Element&&Nr.has(oe(e))}function Ls(e){return e instanceof HTMLElement&&Ts.has(oe(e))}function ti(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=oe(e);return Ts.has(t)||Nr.has(t)?!1:qe(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Km(e,t){let n=Pn(t);for(;n&&n!==e;){if(Nr.has(oe(n)))return!0;n=n.parentElement}return!1}function Ms(e,t){let n=Pn(t);for(;n&&n!==e;){if(ks(n,e)){n=n.parentElement;continue}if(Ls(n))return n;if(Nr.has(oe(n)))return null;n=n.parentElement}return null}function $m(e,t){const n=new Set,r=[];for(const i of Li(t)){const a=Ms(e,i);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Um(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Wm(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let i=r,a=r;for(;i>0&&ti(n[i-1]);)i-=1;for(;a<n.length-1&&ti(n[a+1]);)a+=1;return n.slice(i,a+1)}function Gm(e,t,n){return n.startContainer===e?e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild:n.startContainer===t&&e!==t?e.firstChild:Um(e,n.startContainer)}function Vm(e,t,n){const r=Ai(e);if(Km(e,t.startContainer))return!1;if(!r.firstChild){const c=document.createElement(n);return c.appendChild(document.createElement("br")),r.appendChild(c),!0}const i=Gm(r,e,t);if(!i||Om(i)||Ls(i)||!ti(i))return!1;const a=Wm(r,i),l=document.createElement(n);r.insertBefore(l,a[0]);for(const c of a)l.appendChild(c);return!0}function qm(e){const t=ht(e);if(!t)return Hm();const n=Li(t).map(i=>{const a=Ms(e,i);return a?zm(oe(a)):null}),r=n[0];return n.every(i=>i===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function Xm(e,t){if(!Ns(t))return!1;const n=ht(e);if(!n)return!1;const r=Ht(e,n.startContainer,n.startOffset),i=Ht(e,n.endContainer,n.endOffset),a=Math.min(r,i),l=Math.max(r,i),c=$m(e,n);let m=!1;if(c.length===0)m=Vm(e,n,t);else for(const p of c)oe(p)!==t&&(Ri(p,t),m=!0);return Mi(e,a,l),m}function _i(e){if(!Ie(e))return null;const t=zt(e);if(!t)return null;const n=oe(t);return n==="ul"||n==="ol"?n:null}function Rs(e){const t=Gt(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(_i),r=n[0];return n.every(i=>i===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function Ym(e,t,n){const r=[...e.children].filter(i=>Ni(i));for(const i of r)t.insertBefore(i,n)}function _s(e){const t=zt(e),n=document.createElement("p");for(const p of[...e.attributes])n.setAttribute(p.name,p.value);for(n.style.marginLeft="",gt(n);e.firstChild&&!Ni(e.firstChild);)n.appendChild(e.firstChild);const r=[];let i=e.nextElementSibling;for(;i;)r.push(i),i=i.nextElementSibling;const a=(t==null?void 0:t.parentNode)??e.parentNode;if(!t||!a)return e.replaceWith(n),n;const l=Ie(a)?a.parentNode??a:a,c=Ie(a)?a.nextSibling:t.nextSibling;e.remove();let m=null;if(r.length>0){m=document.createElement(t.tagName);for(const p of r)m.appendChild(p)}return l.insertBefore(n,c),m&&l.insertBefore(m,n.nextSibling),Ym(e,l,n.nextSibling),t.childElementCount===0&&t.remove(),n}function Jm(e){if(Ie(e))return e;const t=Ri(e,"li");return t.style.marginLeft="",gt(t),t}function Is(e,t){if(e.length===0)return!1;if(e.every(Ie)){const a=zt(e[0]);if(a&&e.every(l=>l.parentElement===a)&&[...a.children].every(c=>c instanceof HTMLElement&&e.includes(c)))return oe(a)===t?!1:(Ri(a,t),!0)}const n=e[0],r=n.parentNode;if(!r)return!1;const i=document.createElement(t);r.insertBefore(i,n);for(const a of e){const l=Ie(a)?zt(a):null;i.appendChild(Jm(a)),l&&l!==i&&l.childElementCount===0&&l.remove()}return!0}function Fs(e){let t=!1;for(const n of[...e].reverse())Ie(n)&&(_s(n),t=!0);return t}function Zm(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;if(n.every(a=>_i(a)===t))return Fs(n);let i=!1;for(const a of Es(n))Is(a,t)&&(i=!0);return i})}function Qm(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;if(t===null)return Fs(n);if(n.every(a=>_i(a)===t))return!1;let i=!1;for(const a of Es(n))Is(a,t)&&(i=!0);return i})}const Bs=40;function Ii(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function Hs(e,t){if(t<=0){e.style.marginLeft="",gt(e);return}e.style.marginLeft=`${t}px`}function ef(e){let t=e.previousElementSibling;for(;t;){if(Ie(t))return t;t=t.previousElementSibling}return null}function tf(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(oe(n)==="ul"||oe(n)==="ol"))return n}return null}function nf(e){const t=ef(e);if(!t)return!1;const n=zt(e);if(!n)return!1;const r=oe(n)==="ol"?"ol":"ul";let i=tf(t);return(!i||oe(i)!==r)&&(i=document.createElement(r),t.appendChild(i)),i.appendChild(e),!0}function rf(e){const t=zt(e);if(!t)return!1;const n=t.parentElement;if(n&&Ie(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return _s(e),!0}function of(e){return Gt(e).some(n=>Ie(n)||Ii(n)>0)}function af(e){return Wt(e,()=>{const t=An(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Ie(r)){nf(r)&&(n=!0);continue}Hs(r,Ii(r)+Bs),n=!0}return n})}function lf(e){return Wt(e,()=>{const t=Gt(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Ie(r)){rf(r)&&(n=!0);continue}const i=Ii(r);i<=0||(Hs(r,Math.max(0,i-Bs)),n=!0)}return n})}const zs="pt",sf=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,cf=/^[+-]?0(?:\.0+)?$/;function Me(e){return`${J(e.value)}${e.unit}`}function He(e){const t=e.trim();if(!t)return null;if(cf.test(t))return{value:0,unit:"px"};const n=t.match(sf);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return Tr(i)?{value:ve(r),unit:i}:null}function Sr(e,t,n){const r=e.trim();if(!r)return null;const i=He(r);if(i)return!n&&i.value<0?{...i,value:0}:i;const a=Number(r.replace(",","."));return Number.isFinite(a)?!n&&a<0?{value:0,unit:t}:{value:ve(a),unit:t}:null}function bt(e){return e.value>=0?e:{value:0,unit:e.unit}}function Re(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}const Xe=["top","right","bottom","left"],Lr=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],tt={top:null,right:null,bottom:null,left:null},Fi={style:"none",width:null,color:null},uf=new Set(Lr),rl={value:0,unit:"px"};function df(){return{margin:{...tt},padding:{...tt},lineHeight:null,border:{...Fi},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null}}function Bi(){const e=df();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}}function nt(e,t){return Xe.every(n=>Re(e[n],t[n]))}function Os(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 Ks(e,t){return e.style===t.style&&Re(e.width,t.width)&&e.color===t.color}function $s(e,t){return e===t?!0:!e||!t?!1:Re(e.offsetX,t.offsetX)&&Re(e.offsetY,t.offsetY)&&Re(e.blur,t.blur)&&Re(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function mf(e){return e.kind==="normal"?"normal":e.kind==="number"?J(e.value):Me({value:e.value,unit:e.unit})}function ff(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)?Ot(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?Ot(n):null}function Ot(e){return ve(Math.min(1,Math.max(0,e)))}function Cr(e){return ve(Ot(e)*100)}function Us(e){return Ot(e/100)}function pf(e){return J(Ot(e))}function hf(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:ve(r)}}const n=He(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function gf(e,t){const n=[];let r="",i=0;for(const a of e){if(a==="("){i+=1,r+=a;continue}if(a===")"){i=Math.max(0,i-1),r+=a;continue}if(a===t&&i===0){r.trim()&&n.push(r.trim()),r="";continue}r+=a}return r.trim()&&n.push(r.trim()),n}function bf(e){const t=[];let n="",r=0;for(const i of e){if(i==="("){r+=1,n+=i;continue}if(i===")"){r=Math.max(0,r-1),n+=i;continue}if(/\s/.test(i)&&r===0){n&&t.push(n),n="";continue}n+=i}return n&&t.push(n),t}function yf(e){const t=[Me(e.offsetX),Me(e.offsetY),Me(e.blur),Me(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function xf(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=gf(t,",")[0];if(!n)return null;const r=bf(n);let i=!1,a=null;const l=[];for(const c of r){if(c.toLowerCase()==="inset"){i=!0;continue}const m=He(c);if(m){l.push(m);continue}const p=me(c);if(p){a=p;continue}return null}return l.length<2||l.length>4?null:{offsetX:l[0],offsetY:l[1],blur:l[2]??rl,spread:l[3]??rl,color:a,inset:i}}function Rt(e,t){return He(e.style.getPropertyValue(t))}function wf(e,t,n,r){const i=n&&r?bt(n):n,a=i?Me(i):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function ol(e,t){return{top:Rt(e,`${t}-top`),right:Rt(e,`${t}-right`),bottom:Rt(e,`${t}-bottom`),left:Rt(e,`${t}-left`)}}function il(e,t,n,r){let i=!1;for(const a of Xe)wf(e,`${t}-${a}`,n[a],r)&&(i=!0);return i}function vf(e){const t=e.trim().toLowerCase();return uf.has(t)?t:"none"}function Ws(e){const t=vf(e.style.borderStyle||e.style.borderTopStyle),n=Rt(e,"border-width")??Rt(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,i=r?me(r):null;return{style:t,width:n,color:i}}function Sf(e,t){const n=Ws(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?bt(t.width):null,color:t.color};return Ks(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=Me(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Gs(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return He(n)}function Cf(e,t){const n=t?bt(t):null,r=Gs(e);return Re(r,n)?!1:(n?e.style.borderRadius=Me(n):e.style.removeProperty("border-radius"),!0)}function Vs(e){return xf(e.style.boxShadow)}function kf(e,t){const n=Vs(e),r=t?{...t,blur:bt(t.blur)}:null;return $s(n,r)?!1:(r?e.style.boxShadow=yf(r):e.style.removeProperty("box-shadow"),!0)}function qs(e){return hf(e.style.lineHeight)}function Df(e,t){const n=qs(e);return Os(n,t)?!1:(t?e.style.lineHeight=mf(t):e.style.removeProperty("line-height"),!0)}function Xs(e){const t=e.style.backgroundColor;return t?me(t):null}function Pf(e,t){const n=t?me(t):null;return Xs(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Ys(e){return ff(e.style.opacity)}function Af(e,t){const n=Ys(e),r=t===null?null:Ot(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=pf(r),!0)}function Vt(e){return{margin:ol(e,"margin"),padding:ol(e,"padding"),lineHeight:qs(e),border:Ws(e),borderRadius:Gs(e),boxShadow:Vs(e),backgroundColor:Xs(e),opacity:Ys(e)}}function qt(e,t){let n=!1;return!t.marginMixed&&il(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&il(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&Df(e,t.lineHeight)&&(n=!0),!t.borderMixed&&Sf(e,t.border)&&(n=!0),!t.radiusMixed&&Cf(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&kf(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&Pf(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&Af(e,t.opacity)&&(n=!0),n&>(e),n}function jf(e){const t=Bi(),n=Gt(e);if(n.length===0)return t;const r=n.map(Vt),i=r[0];return{margin:i.margin,marginMixed:r.some(a=>!nt(a.margin,i.margin)),padding:i.padding,paddingMixed:r.some(a=>!nt(a.padding,i.padding)),lineHeight:i.lineHeight,lineHeightMixed:r.some(a=>!Os(a.lineHeight,i.lineHeight)),border:i.border,borderMixed:r.some(a=>!Ks(a.border,i.border)),borderRadius:i.borderRadius,radiusMixed:r.some(a=>!Re(a.borderRadius,i.borderRadius)),boxShadow:i.boxShadow,shadowMixed:r.some(a=>!$s(a.boxShadow,i.boxShadow)),backgroundColor:i.backgroundColor,backgroundMixed:r.some(a=>a.backgroundColor!==i.backgroundColor),opacity:i.opacity,opacityMixed:r.some(a=>a.opacity!==i.opacity)}}function Ef(e,t){return Wt(e,()=>{const n=An(e);if(n.length===0)return!1;let r=!1;for(const i of n)qt(i,t)&&(r=!0);return r})}const Js=["left","center","right","justify"];function Tf(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function Nf(e){return Tf(e.style.textAlign)}function Zs(e){const t=Gt(e);if(t.length===0)return ht(e)?{align:"left",mixed:!1}:{align:null,mixed:!1};const n=t.map(Nf),r=n[0];return n.every(i=>i===r)?{align:r,mixed:!1}:{align:null,mixed:!0}}function Qs(e,t){return Js.includes(t)?Wt(e,()=>{const n=An(e);if(n.length===0)return!1;let r=!1;for(const i of n)i.style.textAlign!==t&&(i.style.textAlign=t,r=!0);return r}):!1}function hn(){return{...Bi(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function al(e){const t=jf(e),n=Zs(e),r=Rs(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function ec(e,t){let n=!1;return!t.alignMixed&&t.align&&Qs(e,t.align)&&(n=!0),t.listMixed||Qm(e,t.list)&&(n=!0),Ef(e,t)&&(n=!0),n}function Lf(e,t){return ec(e,ni(t))}function tc(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}}function ni(e){const t=hn();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}:{...t,alignMixed:!0,listMixed:!0,marginMixed:!0,paddingMixed:!0,lineHeightMixed:!0,borderMixed:!0,radiusMixed:!0,shadowMixed:!0,backgroundMixed:!0,opacityMixed:!0}}function Mf(){return{size:null,unit:Ct,marks:Qe(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function ri(){return{font:Mf(),box:Bi()}}function Rf(e){const t=e.style.fontSize,n=t?Di(t):null,r=n&&Tr(n.unit)?{value:n.value,unit:n.unit}:null,i=`${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(i),strikethrough:/\bline-through\b/.test(i)},c=e.style.color,m=e.style.fontFamily.trim();return{size:(r==null?void 0:r.value)??null,unit:(r==null?void 0:r.unit)??Ct,marks:l,fontFamily:m||null,fontFamilyMixed:!1,fontColor:c?me(c):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function _f(e,t){const n=e.style.fontSize,r=t.size===null?null:kt(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const i=ki(r.value,r.unit);return n===i?!1:(e.style.fontSize=i,!0)}function If(e,t){var i;if(t.fontFamilyMixed)return!1;const n=(i=t.fontFamily)!=null&&i.trim()?t.fontFamily.trim():null,r=e.style.fontFamily.trim()||null;return kn(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function Ff(e,t){if(t.fontColorMixed)return!1;const n=t.fontColor?me(t.fontColor):null;return(e.style.color?me(e.style.color):null)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Bf(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 i=t.italic?"italic":"";e.style.fontStyle!==i&&(i?e.style.fontStyle=i: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 Hf(e,t){let n=!1;return _f(e,t)&&(n=!0),If(e,t)&&(n=!0),Ff(e,t)&&(n=!0),Bf(e,t.marks)&&(n=!0),n&>(e),n}function zf(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function Of(e){const t=Dn(e);if(!t)return ri();const n=Vt(t);return{font:Rf(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}}}function Kf(e,t){const n=ht(e),r=n?Ht(e,n.startContainer,n.startOffset):null,i=n?Ht(e,n.endContainer,n.endOffset):null,a=Dn(e),l=Am(e),c=Hf(l,t.font),m=qt(l,zf(t));return Ps(e),r!==null&&i!==null&&Mi(e,Math.min(r,i),Math.max(r,i)),!a||c||m}const Hi="data-hover-html",$f="noopener noreferrer",Uf="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)",Wf="this._hoverBox&&this._hoverBox.remove()",Gf=/^(#(?:[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 Mr(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function Vf(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function Sn(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&Vf(n))return n;n=n.parentNode}return null}function nc(e){return Gf.test(e)}function qf(e){var i;const t=e.getAttribute("onmouseover")??"",n=/this\.style\.color\s*=\s*'([^']+)'/.exec(t),r=((i=n==null?void 0:n[1])==null?void 0:i.trim())??"";return r&&nc(r)?r:null}function rc(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function Xf(e){const t=e.getAttribute(Hi)??"",n=qf(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:rc(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function oc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return null;const r=Sn(e,n.commonAncestorContainer);return r?Xf(r):null}function Yf(e){return oc(e)!==null}function Jf(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Hi)}function Zf(e,t){var r;if(Jf(e),t.hoverMode==="html"){const i=t.hoverHtml.trim();if(!i)return;e.setAttribute(Hi,i),e.setAttribute("onmouseover",Uf),e.setAttribute("onmouseout",Wf);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!nc(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function zi(e,t){const n=Mr(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",$f)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":rc(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),Zf(e,n)}function Qf(e,t){const n=new Set;for(const r of t){const i=Sn(e,r);i&&!n.has(i)&&n.add(i)}for(const r of n)_e(r)}function ep(e,t,n){ut(t);const r=Be(t).filter(c=>c.data.length>0);Qf(e,r),r.length>0&&Ut(r);const i=window.getSelection();if(!i||i.rangeCount===0)return!1;const a=i.getRangeAt(0);ut(a);const l=document.createElement("a");zi(l,n);try{return a.surroundContents(l),!0}catch{const c=a.extractContents();return c.hasChildNodes()?(l.appendChild(c),a.insertNode(l),!0):!1}}function tp(e,t){const n=document.createElement("a");zi(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 np(e,t){const n=t.href.trim();if(!n)return!1;const r=Mr({...t,href:n}),i=window.getSelection();if(!i||i.rangeCount===0)return!1;const a=i.getRangeAt(0);if(!se(e,a.commonAncestorContainer))return!1;const l=Sn(e,a.startContainer),c=Sn(e,a.endContainer);return l&&l===c?(zi(l,r),!0):a.collapsed?tp(a,r):ep(e,a,r)}const rp=/^[A-Za-z][A-Za-z0-9_-]*$/,ic="";function oi(e){var r;const t=Ai(e),n=new Set;for(const i of t.querySelectorAll("[id]")){if(i===t)continue;const a=i.id.trim();a&&n.add(a)}for(const i of t.querySelectorAll("a[name]")){const a=(r=i.getAttribute("name"))==null?void 0:r.trim();a&&n.add(a)}return[...n].sort((i,a)=>i.localeCompare(a)).map(i=>({id:i}))}function op(e){return new Set(oi(e).map(t=>t.id))}function ac(e,t){const n=e.trim();return n?rp.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function ll(e,t){const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(ic)),e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(e)}function ip(e,t){var r;const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(ic)),(r=e.parentNode)==null||r.insertBefore(n,e)}function ap(e,t){const n=t.trim();if(ac(n,op(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const i=r.getRangeAt(0);if(!se(e,i.commonAncestorContainer))return!1;const a=Sn(e,i.startContainer);if(a)return ip(a,n),!0;if(i.collapsed)return ll(i,n),!0;ut(i);const l=document.createElement("span");l.id=n;try{return i.surroundContents(l),!0}catch{return ll(i,n),!0}}function lc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n:null}function lp(e){const t=lc(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 i=t.toString();if(!i){const a=n.querySelector("img");i=(a==null?void 0:a.getAttribute("alt"))??(a==null?void 0:a.getAttribute("src"))??""}return{html:r,text:i}}function sc(e){const t=lc(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 sp(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 cc(e){const t=lp(e);return t?sp(t):!1}async function cp(e){return await cc(e)?sc(e):!1}const up=new Set(["strong","b","em","i","u","s","strike","del"]),dp=["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 mp(e){for(const t of dp)e.style.removeProperty(t)}function fp(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!qe(r)){n=r;continue}if(pt(r,n),up.has(r.tagName.toLowerCase())){_e(r);continue}if(mp(r),Dt(r)){_e(r);continue}n=r.isConnected?r:t}}function pp(e){const t=ht(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;ut(t);const r=Be(t).filter(i=>i.data.length>0);if(r.length===0)return!1;for(const i of r)fp(e,i);return Ut(r),e.innerHTML!==n}const hp=2*1024*1024,gp="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",bp=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),yp=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),xp=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,wp=/^(javascript|vbscript|file|blob):/i;function vp(e={}){return{src:"",alt:"",title:"",...e}}function Oi(e){const t=e.trim();if(!t)return"empty";if(wp.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return xp.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 Sp(e){return e.size>hp?"tooLarge":Ap(e)?null:"type"}function Cp(e){const t=Sp(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const i=new FileReader;i.onload=()=>{const a=String(i.result??"");if(Oi(a)){r(new Error("invalid"));return}n(a)},i.onerror=()=>r(i.error??new Error("Failed to read file")),i.readAsDataURL(e)})}function kp(e,t){e.setAttribute("src",t.src.trim());const n=t.alt.trim(),r=t.title.trim();n?e.setAttribute("alt",n):e.removeAttribute("alt"),r?e.setAttribute("title",r):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.height="auto",Dp(e,t.css)}function Dp(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const i=r.indexOf(":");if(i<=0)continue;const a=r.slice(0,i).trim(),l=r.slice(i+1).trim();a&&l&&e.style.setProperty(a,l)}}function Pp(e,t){const n=vp(t);if(Oi(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const i=r.getRangeAt(0);if(!se(e,i.commonAncestorContainer))return!1;i.collapsed||i.deleteContents();const a=document.createElement("img");return kp(a,n),i.insertNode(a),i.setStartAfter(a),i.collapse(!0),r.removeAllRanges(),r.addRange(i),!0}function ii(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function Bo(e,t){if(!se(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 Ap(e){const t=e.type.trim().toLowerCase();if(t&&bp.has(t))return!0;const n=jp(e.name);return!!(!t&&n&&yp.has(n))}function jp(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Ep="1em 0",Tp="1px solid #d0d0d0",Np=new Set(["p","h1","h2","h3","h4","h5","h6"]),Lp=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function Mp(e){var a;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return!1;n.collapsed||n.deleteContents();const r=Rp(),i=_p(e,n.startContainer);if(i){const l=Ip(i,n);return(a=i.parentNode)==null||a.insertBefore(r,l),cl(r),!0}return n.insertNode(r),Fp(e,r),zp(r),cl(r),!0}function Rp(){const e=document.createElement("hr");return e.style.margin=Ep,e.style.border="0",e.style.borderTop=Tp,e}function _p(e,t){let n=Pn(t);for(;n&&n!==e;){const r=oe(n);if(Np.has(r)&&n instanceof HTMLElement)return n;if(Lp.has(r))return null;n=n.parentElement}return null}function Ip(e,t){var a;const n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(e,e.childNodes.length);const r=n.extractContents(),i=e.cloneNode(!1);return i.appendChild(r),sl(e),sl(i),(a=e.parentNode)==null||a.insertBefore(i,e.nextSibling),i}function Fp(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!Bp(n))return;pt(n,t),_e(n)}}function Bp(e){const t=oe(e);return qe(e)||t==="a"}function sl(e){Hp(e)&&e.appendChild(document.createElement("br"))}function Hp(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 zp(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 cl(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 uc=["%","px","pt","pc","em","rem"],Op="%",Kp={"%":[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]},Kt={"%":{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}},$p=new Set(uc),Up=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function Wp(e){return $p.has(e)}function ul(e){return`${J(e.value)}${e.unit}`}function ai(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(Up);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r)||r<=0)return null;const i=n[2]==="%"?"%":n[2].toLowerCase();return Wp(i)?$t(r,i):null}function dl(e,t){const n=e.trim();if(!n)return null;const r=ai(n);if(r)return r;const i=Number(n.replace(",","."));return Number.isFinite(i)?$t(i,t):null}function $t(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=Kt[t];return{value:ve(Math.min(r,Math.max(n,e))),unit:t}}function gn(e,t,n){const r=n>0?n:1;if(e==="width"){const a=$t(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:$t(t.value*r,t.unit)??t,height:t}}const hr="data-hover-css",dc=["fill","contain","cover","none","scale-down"],mc=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],Gp=new Set(dc),Vp=new Set(mc),ml="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",qp="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",Xp=/^-?[a-z][a-z0-9-]*$/i,Yp=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,li=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function fc(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...tt},border:{...Fi},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function Jp(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function Zp(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=gn("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=gn("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function Qp(e){const t=[];for(const n of e.split(";")){const r=n.trim();if(!r)continue;const i=r.indexOf(":");if(i<=0)continue;const a=r.slice(0,i).trim().toLowerCase(),l=r.slice(i+1).trim();!a||!l||Xp.test(a)&&(a==="behavior"||a.endsWith("binding")||Yp.test(l)||t.push(`${a}: ${l}`))}return t.join("; ")}function bn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!se(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&&se(e,r))return r}return ii(e,n.commonAncestorContainer)}function eh(e){const t=bn(e);return t?pc(t):null}function pc(e){const t=Vt(e),n=ih(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,i=nh(e);return fc({sizeMode:i.sizeMode,width:i.width,height:i.height,align:n,margin:r,border:t.border,borderRadius:t.borderRadius,boxShadow:t.boxShadow,opacity:t.opacity,objectFit:gc(e),objectPosition:ch(e),rotateDeg:bc(e),hoverCss:e.getAttribute(hr)??""})}function hc(e,t){let n=!1;return rh(e,t)&&(n=!0),qt(e,{margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:tt,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),ah(e,t.align)&&(n=!0),lh(e,t.objectFit)&&(n=!0),sh(e,t.objectPosition)&&(n=!0),dh(e,t.rotateDeg)&&(n=!0),mh(e,t.hoverCss)&&(n=!0),n}function th(e,t){const n=bn(e);return n?hc(n,t):!1}function nh(e){const t=ai(e.style.width),n=ai(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 rh(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=oh(t);return r.width?e.style.width=ul(r.width):e.style.removeProperty("width"),r.height?e.style.height=ul(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 oh(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 ih(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(),i=e.style.marginRight.trim().toLowerCase();return n==="block"&&r==="auto"&&i==="auto"?"center":null}function ah(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 gc(e){const t=e.style.objectFit.trim().toLowerCase();return Gp.has(t)?t:null}function lh(e,t){return gc(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function sh(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 ch(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(Vp.has(t),t):null}function bc(e){const t=li.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?ve(n):null}function uh(e){const t=e.trim();return t?li.test(t)&&t.replace(li,"").trim()==="":!0}function dh(e,t){const n=bc(e),r=t===null||t===0?null:ve(t);return n===r?!1:r===null?uh(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${J(r)}deg)`,!0)}function mh(e,t){const n=Qp(t),r=e.getAttribute(hr)??"",i=e.getAttribute("onmouseover")??"";return r===n&&(n&&i===ml||!n&&!i)?!1:n?(e.setAttribute(hr,n),e.setAttribute("onmouseover",ml),e.setAttribute("onmouseout",qp),!0):(e.removeAttribute(hr),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const rt=16;function fl(e){return Math.min(Kt.px.max,Math.max(rt,e))}function fh(e){return e.width>0&&e.height>0?e.width/e.height:1}function ph(e,t){const n=Math.max(rt,rt*t),r=Math.min(Kt.px.max,Kt.px.max*t),i=Math.min(r,Math.max(n,e));return{width:i,height:i/t}}function hh(e,t){const n=Math.max(rt,rt/t),r=Math.min(Kt.px.max,Kt.px.max/t),i=Math.min(r,Math.max(n,e));return{width:i*t,height:i}}function gh(e,t,n){const r=fh(t);return e==="e"?ph(t.width+n.x,r):e==="s"?hh(t.height+n.y,r):{width:fl(t.width+n.x),height:fl(t.height+n.y)}}function bh(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:rt,height:r>0?r:rt}}function yh(e,t,n){const r=$t(Math.max(rt,t),"px"),i=$t(Math.max(rt,n),"px");return!r||!i?!1:hc(e,{...pc(e),sizeMode:"lock",width:r,height:i})}const pl=10,_t=1,It=50,xh="1px solid #000",wh="0.25em",vh=new Set(["td","th"]);function yc(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=_t&&t>=_t&&e<=It&&t<=It}function Ve(e,t){return Ki(e,t,n=>n instanceof HTMLTableElement)}function kr(e,t){return Ki(e,t,n=>Th(n))}function Sh(e,t){return Ki(e,t,n=>n instanceof HTMLTableRowElement)}function yn(e){return Ve(e,$i(e))}function Xt(e){return kr(e,$i(e))}function xc(e){return Sh(e,$i(e))}function Ch(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function kh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!se(e,n.commonAncestorContainer))return[];const r=kr(e,n.startContainer),i=kr(e,n.endContainer);if(!r)return[];if(!i||r===i)return[r];const a=Ve(e,r);if(!a||Ve(e,i)!==a)return[r];const l=gl(r),c=gl(i);if(!l||!c)return[r];const m=Math.min(l.row,c.row),p=Math.max(l.row,c.row),b=Math.min(l.col,c.col),h=Math.max(l.col,c.col),w=[];for(const y of Array.from(a.rows))if(!(y.rowIndex<m||y.rowIndex>p))for(const v of Array.from(y.cells))v.cellIndex>=b&&v.cellIndex<=h&&w.push(v);return w.length>0?w:[r]}function Dh(e,t){if(!yc(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!se(e,r.commonAncestorContainer))return!1;const i=document.createElement("table");i.style.borderCollapse="collapse",i.style.width="100%";const a=document.createElement("tbody");for(let c=0;c<t.rows;c+=1){const m=document.createElement("tr");for(let p=0;p<t.cols;p+=1)m.appendChild(Ui("td"));a.appendChild(m)}i.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(i),Lh(e,i);const l=i.querySelector("td, th");return l instanceof HTMLTableCellElement&&et(l),!0}function si(e,t){var m;const n=Xt(e);if(!n)return!1;const r=n.parentElement;if(!(r instanceof HTMLTableRowElement)||!Ve(e,n))return!1;const a=document.createElement("tr"),l=Math.max(1,r.cells.length);for(let p=0;p<l;p+=1){const b=r.cells[p];a.appendChild(Ui((b==null?void 0:b.tagName)==="TH"?"th":"td"))}t==="before"?(m=r.parentNode)==null||m.insertBefore(a,r):r.insertAdjacentElement("afterend",a);const c=a.cells[Math.min(n.cellIndex,a.cells.length-1)];return c&&et(c),!0}function hl(e,t){const n=Xt(e);if(!n)return!1;const r=Ve(e,n);if(!r)return!1;const i=n.cellIndex,a=t==="before"?i:i+1;let l=null;for(const c of Array.from(r.rows)){const m=c.cells[Math.min(i,c.cells.length-1)]??null,p=Ui((m==null?void 0:m.tagName)==="TH"?"th":"td");Nh(c,a,p),c===n.parentElement&&(l=p)}return l&&et(l),!0}function Ph(e){const t=Xt(e);if(!t)return!1;const n=t.parentElement;if(!(n instanceof HTMLTableRowElement))return!1;const r=Ve(e,t);if(!r)return!1;const i=t.cellIndex,a=n.rowIndex;if(r.rows.length<=1)return wc(e,r);const l=n.parentNode;n.remove();const c=r.rows[Math.min(a,r.rows.length-1)],m=c==null?void 0:c.cells[Math.min(i,c.cells.length-1)];return m?et(m):l&&Rh(r),!0}function Ah(e){const t=Xt(e);if(!t)return!1;const n=Ve(e,t);if(!n)return!1;const r=t.cellIndex,i=t.parentElement;if(Math.max(0,...Array.from(n.rows,p=>p.cells.length))<=1)return wc(e,n);const l=i instanceof HTMLTableRowElement?i.rowIndex:0;for(const p of Array.from(n.rows)){const b=p.cells[r];b&&b.remove()}const c=n.rows[Math.min(l,n.rows.length-1)],m=c==null?void 0:c.cells[Math.min(r,c.cells.length-1)];return m&&et(m),!0}function jh(e,t){const n=Xt(e);if(!n)return!1;const r=Ve(e,n);if(!r)return!1;const i=Ch(r),a=i.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(et(i[a-1]),{changed:!1});if(a<i.length-1)return et(i[a+1]),{changed:!1};const l=n.parentElement;if(!si(e,"below"))return!1;const c=l instanceof HTMLTableRowElement?l.nextElementSibling:null;return c instanceof HTMLTableRowElement&&c.cells[0]&&et(c.cells[0]),{changed:!0}}function Eh(e,t){return!se(e,t)||t===e?!1:(et(t),!0)}function Ki(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function Th(e){return vh.has(e.tagName.toLowerCase())}function $i(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return se(e,n.commonAncestorContainer)?n.startContainer:null}function gl(e){const t=e.parentElement;return t instanceof HTMLTableRowElement?{row:t.rowIndex,col:e.cellIndex}:null}function Ui(e){const t=document.createElement(e);return t.style.border=xh,t.style.padding=wh,t.appendChild(document.createElement("br")),t}function Nh(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function Lh(e,t){var i;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))&&((i=n.parentNode)==null||i.insertBefore(t,n.nextSibling),Mh(n)&&n.remove())}function Mh(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 wc(e,t){if(!t.parentNode||!se(e,t))return!1;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),t.remove();const i=window.getSelection();return i&&(i.removeAllRanges(),i.addRange(r)),!0}function et(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Rh(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function _h(e={}){return{border:{...Fi},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function Ih(e){const t=Vt(e);return{border:t.border,borderCollapse:zh(e),borderSpacing:vc(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:He(e.style.width)}}function Fh(e,t){let n=qt(e,{margin:{top:null,right:null,bottom:null,left:null},marginMixed:!0,padding:{top:null,right:null,bottom:null,left:null},paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0});return Oh(e,t.borderCollapse)&&(n=!0),Kh(e,t.borderCollapse,t.borderSpacing)&&(n=!0),$h(e,t.width)&&(n=!0),n&>(e),n}function Bh(e){const t=yn(e);return t?Ih(t):null}function Hh(e,t){const n=yn(e);return n?Fh(n,t):!1}function zh(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function Oh(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function vc(e){const t=e.style.borderSpacing.trim();return t?He(t.split(/\s+/)[0]??""):null}function Kh(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?bt(n):null,i=vc(e);return Re(i,r)?!1:(r?e.style.borderSpacing=Me(r):e.style.removeProperty("border-spacing"),!0)}function $h(e,t){const n=t?bt(t):null,r=He(e.style.width);return Re(r,n)?!1:(n?e.style.width=Me(n):e.style.removeProperty("width"),!0)}const Rr=["top","middle","bottom","baseline"],Uh=new Set(Rr);function Wh(e={}){return{backgroundColor:null,color:null,padding:{...tt},verticalAlign:null,width:null,...e}}function Gh(e){const t=Vt(e);return{backgroundColor:t.backgroundColor,color:Sc(e),padding:t.padding,verticalAlign:Cc(e),width:He(e.style.width)}}function Vh(e,t){let n=qt(e,{margin:{...tt},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 Yh(e,t.color)&&(n=!0),Jh(e,t.verticalAlign)&&(n=!0),Zh(e,t.width)&&(n=!0),n&>(e),n}function qh(e){const t=Xt(e);return t?Gh(t):null}function Xh(e,t){const n=kh(e);if(n.length===0)return!1;let r=!1;for(const i of n)Vh(i,t)&&(r=!0);return r}function Sc(e){const t=e.style.color;return t?me(t):null}function Yh(e,t){const n=t?me(t):null;return Sc(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Cc(e){const t=e.style.verticalAlign.trim().toLowerCase();return Uh.has(t)?t:null}function Jh(e,t){return Cc(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function Zh(e,t){const n=t?bt(t):null,r=He(e.style.width);return Re(r,n)?!1:(n?e.style.width=Me(n):e.style.removeProperty("width"),!0)}const Qh=new Set(Rr);function eg(e={}){return{backgroundColor:null,color:null,padding:{...tt},height:null,verticalAlign:null,...e}}function tg(e){const t=e.cells[0],n=t?Vt(t).padding:{...tt};return{backgroundColor:kc(e),color:Dc(e),padding:n,height:He(e.style.height),verticalAlign:Pc(e)}}function ng(e,t){let n=!1;ig(e,t.backgroundColor)&&(n=!0),ag(e,t.color)&&(n=!0),sg(e,t.height)&&(n=!0),lg(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))qt(r,{margin:{...tt},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&>(e),n}function rg(e){const t=xc(e);return t?tg(t):null}function og(e,t){const n=xc(e);return n?ng(n,t):!1}function kc(e){const t=e.style.backgroundColor;return t?me(t):null}function ig(e,t){const n=t?me(t):null;return kc(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Dc(e){const t=e.style.color;return t?me(t):null}function ag(e,t){const n=t?me(t):null;return Dc(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Pc(e){const t=e.style.verticalAlign.trim().toLowerCase();return Qh.has(t)?t:null}function lg(e,t){return Pc(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function sg(e,t){const n=t?bt(t):null,r=He(e.style.height);return Re(r,n)?!1:(n?e.style.height=Me(n):e.style.removeProperty("height"),!0)}const cg=1e3;function ug(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function dg({onAutoSave:e,getHtml:t}){const n=s.useRef(e);n.current=e;const r=s.useRef(t);r.current=t;const i=s.useRef(null),a=e!=null;s.useEffect(()=>{if(!a){i.current=null;return}i.current=r.current();const l=window.setInterval(()=>{const c=n.current;if(!c)return;const m=r.current();m!==i.current&&(i.current=m,queueMicrotask(()=>ug(c,m)))},cg);return()=>{window.clearInterval(l)}},[a])}function Ho({value:e,defaultValue:t,onChange:n}){const[r,i]=s.useState(t),a=e!==void 0,l=a?e:r,c=s.useCallback(m=>{a||i(m),n==null||n(m)},[a,n]);return[l,c]}const bl=8,yl=["#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"],mg=8;let ci=[];const ui=new Set;function xl(){return ci}function fg(e){const t=me(e);t&&(ci=[t,...ci.filter(n=>n!==t)].slice(0,mg),ui.forEach(n=>n()))}function pg(e){return ui.add(e),()=>{ui.delete(e)}}function ir(e){const t=me(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 vt(e,t,n){const r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function zo({r:e,g:t,b:n}){const r=e/255,i=t/255,a=n/255,l=Math.max(r,i,a),c=Math.min(r,i,a),m=l-c;let p=0;return m!==0&&(l===r?p=(i-a)/m%6:l===i?p=(a-r)/m+2:p=(r-i)/m+4,p*=60,p<0&&(p+=360)),{h:p,s:l===0?0:m/l,v:l}}function Oo({h:e,s:t,v:n}){const r=(e%360+360)%360,i=n*t,a=i*(1-Math.abs(r/60%2-1)),l=n-i;let c=0,m=0,p=0;return r<60?(c=i,m=a):r<120?(c=a,m=i):r<180?(m=i,p=a):r<240?(m=a,p=i):r<300?(c=a,p=i):(c=i,p=a),{r:Math.round((c+l)*255),g:Math.round((m+l)*255),b:Math.round((p+l)*255)}}function Ac(){return typeof window<"u"&&"EyeDropper"in window}async function hg(){if(!Ac())return null;const e=window.EyeDropper;try{const t=await new e().open();return me(t.sRGBHex)}catch{return null}}const gg="_picker_ag1yo_1",bg="_none_ag1yo_12",yg="_customToggle_ag1yo_13",xg="_eyedrop_ag1yo_14",wg="_swatch_ag1yo_48",vg="_field_ag1yo_49",Sg="_grid_ag1yo_54",Cg="_recents_ag1yo_55",kg="_sectionLabel_ag1yo_84",Dg="_custom_ag1yo_13",Pg="_sv_ag1yo_95",Ag="_svThumb_ag1yo_105",jg="_hue_ag1yo_116",Eg="_rgbRow_ag1yo_155",Tg="_hexRow_ag1yo_156",xe={picker:gg,none:bg,customToggle:yg,eyedrop:xg,swatch:wg,field:vg,grid:Sg,recents:Cg,sectionLabel:kg,custom:Dg,sv:Pg,svThumb:Ag,hue:jg,rgbRow:Eg,hexRow:Tg};function Ng(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 Wi({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:i,menu:a=!1,fallbackCustom:l="#000000",onChange:c,onCommit:m}){const p=V(),b=s.useId(),h=a?"menuitemradio":"option",w=t?null:e,y=ir(w??l)??{r:0,g:0,b:0},[v,x]=s.useState(!1),[k,g]=s.useState(()=>zo(y)),[S,A]=s.useState(()=>({r:String(y.r),g:String(y.g),b:String(y.b)})),[N,E]=s.useState(()=>vt(y.r,y.g,y.b)),[L,M]=s.useState(()=>[...xl()]),I=s.useRef(null),j=s.useRef(vt(y.r,y.g,y.b));s.useEffect(()=>pg(()=>M([...xl()])),[]),s.useEffect(()=>{const D=ir(w??l);if(!D)return;const $=zo(D);g($),A({r:String(D.r),g:String(D.g),b:String(D.b)}),E(vt(D.r,D.g,D.b))},[w,l]);const T=(D,$,Y)=>{D&&(j.current=D),Y&&D&&fg(D),c(D),$&&(m==null||m(D))},P=(D,$,Y)=>{const B=vt(D.r,D.g,D.b);g(zo(D)),A({r:String(D.r),g:String(D.g),b:String(D.b)}),E(B),T(B,$,Y)},R=(D,$,Y)=>{const B=Oo(D),fe=vt(B.r,B.g,B.b);g(D),A({r:String(B.r),g:String(B.g),b:String(B.b)}),E(fe),T(fe,$,Y)},W=D=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(D.key))return;const Y=[...D.currentTarget.querySelectorAll("button")],B=Y.findIndex(we=>we===document.activeElement);if(B<0)return;D.preventDefault();const fe=D.key==="ArrowLeft"?-1:D.key==="ArrowRight"?1:D.key==="ArrowUp"?-bl:bl,ue=Y[Math.max(0,Math.min(Y.length-1,B+fe))];ue==null||ue.focus()},O=(D,$)=>{const Y=I.current;if(!Y||i)return;const B=Y.getBoundingClientRect(),fe=Math.max(0,Math.min(1,(D.clientX-B.left)/B.width)),ue=Math.max(0,Math.min(1,1-(D.clientY-B.top)/B.height));R({h:k.h,s:fe,v:ue},$,$)},Z=D=>{i||(D.currentTarget.setPointerCapture(D.pointerId),O(D,!1))},te=Oo({h:k.h,s:1,v:1}),ce=vt(te.r,te.g,te.b),re=Oo(k),he=vt(re.r,re.g,re.b),ne=new Set(yl),Q=L.filter(D=>!ne.has(D));return o.jsxs("div",{className:xe.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[o.jsx("button",{type:"button",className:xe.none,role:h,"aria-checked":a?w===null&&!t:void 0,"aria-selected":a?void 0:w===null&&!t,disabled:i,onClick:()=>T(null,!0,!1),children:n}),o.jsx("div",{className:xe.grid,role:a?"group":"none",onKeyDown:W,children:yl.map(D=>{const $=w===D;return o.jsx("button",{type:"button",className:xe.swatch,role:h,"aria-label":D,"aria-checked":a?$:void 0,"aria-selected":a?void 0:$,disabled:i,style:{backgroundColor:D},onMouseDown:Y=>Y.preventDefault(),onClick:()=>T(D,!0,!1)},D)})}),Q.length>0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:xe.sectionLabel,children:p("colorRecent")}),o.jsx("div",{className:xe.recents,role:a?"group":"none","aria-label":p("colorRecent"),children:Q.map(D=>o.jsx("button",{type:"button",className:xe.swatch,role:h,"aria-label":D,"aria-checked":a?w===D:void 0,"aria-selected":a?void 0:w===D,disabled:i,style:{backgroundColor:D},onMouseDown:$=>$.preventDefault(),onClick:()=>T(D,!0,!1)},D))})]}):null,o.jsx("button",{type:"button",className:xe.customToggle,disabled:i,"aria-expanded":v,onClick:()=>x(D=>!D),children:p("colorCustom")}),v?o.jsxs("div",{className:xe.custom,children:[o.jsx("div",{ref:I,className:xe.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${ce})`},onPointerDown:Z,onPointerMove:D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&O(D,!1)},onPointerUp:D=>{O(D,!0)},children:o.jsx("span",{className:xe.svThumb,style:{left:`${k.s*100}%`,top:`${(1-k.v)*100}%`}})}),o.jsx("input",{className:xe.hue,type:"range",min:0,max:360,value:Math.round(k.h),disabled:i,"aria-label":p("colorCustom"),onChange:D=>R({...k,h:Number(D.target.value)},!1,!1),onPointerUp:()=>T(j.current,!0,!0)}),o.jsx("div",{className:xe.rgbRow,children:["r","g","b"].map(D=>o.jsxs("div",{className:xe.field,children:[o.jsx("label",{htmlFor:`${b}-${D}`,children:p(D==="r"?"colorRgbR":D==="g"?"colorRgbG":"colorRgbB")}),o.jsx("input",{id:`${b}-${D}`,inputMode:"numeric",value:S[D],disabled:i,onChange:$=>{A(Y=>({...Y,[D]:$.target.value}))},onBlur:()=>{const $=Ng(S[D]);if($===null){A({r:String(re.r),g:String(re.g),b:String(re.b)});return}P({...re,[D]:$},!0,!0)},onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}})]},D))}),o.jsx("div",{className:xe.hexRow,children:o.jsxs("div",{className:xe.field,children:[o.jsx("label",{htmlFor:`${b}-hex`,children:p("colorHex")}),o.jsx("input",{id:`${b}-hex`,value:N,disabled:i,onChange:D=>E(D.target.value),onBlur:()=>{const D=me(N);if(!D){E(he);return}const $=ir(D);$&&P($,!0,!0)},onKeyDown:D=>{D.key==="Enter"&&D.currentTarget.blur()}})]})}),Ac()?o.jsx("button",{type:"button",className:xe.eyedrop,disabled:i,onClick:()=>{hg().then(D=>{if(!D)return;const $=ir(D);$&&P($,!0,!0)})},children:p("colorPickFromScreen")}):null]}):null]})}const Lg="_wrap_xzhkl_1",Mg="_button_xzhkl_8",Rg="_icon_xzhkl_18",_g="_bar_xzhkl_24",Ig="_barEmpty_xzhkl_33",Fg="_popover_xzhkl_43",St={wrap:Lg,button:Mg,icon:Rg,bar:_g,barEmpty:Ig,popover:Fg},Bg="_field_1knrr_1",Hg="_label_1knrr_8",zg="_button_1knrr_12",Og="_swatch_1knrr_37",Kg="_swatchEmpty_1knrr_44",mn={field:Bg,label:Hg,button:zg,swatch:Og,swatchEmpty:Kg},ar=4;function Fe({label:e,noneLabel:t,value:n,mixed:r=!1,disabled:i,fallbackCustom:a,onChange:l}){const c=s.useId(),m=s.useRef(null),p=s.useRef(null),b=s.useRef(null),[h,w]=s.useState(!1),[y,v]=s.useState({top:0,left:0}),x=s.useCallback(()=>{const S=p.current,A=b.current;if(!S)return;const N=S.getBoundingClientRect(),E=(A==null?void 0:A.offsetHeight)??0,L=(A==null?void 0:A.offsetWidth)??240;let M=N.bottom;M+E>window.innerHeight-ar&&(M=Math.max(ar,N.top-E));const I=Math.min(Math.max(N.left,ar),window.innerWidth-L-ar);v({top:M,left:I})},[]);s.useLayoutEffect(()=>{if(!h)return;x();const S=()=>x();return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[h,x]),s.useEffect(()=>{if(!h)return;const S=N=>{var L,M;const E=N.target;(L=m.current)!=null&&L.contains(E)||(M=b.current)!=null&&M.contains(E)||w(!1)},A=N=>{var E;N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),w(!1),(E=p.current)==null||E.focus())};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",A,!0)}},[h]);const k=`${mn.swatch}${!n||r?` ${mn.swatchEmpty}`:""}`,g=n&&!r?{backgroundColor:n}:void 0;return o.jsxs("div",{className:mn.field,ref:m,children:[o.jsx("span",{className:mn.label,children:e}),o.jsx("button",{ref:p,type:"button",className:mn.button,"aria-label":e,"aria-haspopup":"listbox","aria-expanded":h,"aria-controls":h?c:void 0,disabled:i,onClick:()=>w(S=>!S),children:o.jsx("span",{className:k,style:g})}),h?o.jsx(ie,{children:o.jsx("div",{ref:b,id:c,className:St.popover,style:{top:y.top,left:y.left,zIndex:1400},children:o.jsx(Wi,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:i,fallbackCustom:a,onChange:l,onCommit:()=>w(!1)})})}):null]})}const Ko=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],$g="_toolbar_2uk4l_1",Ug="_menuBar_2uk4l_35",Wg="_menuBarDesktop_2uk4l_43",Gg="_brandMark_2uk4l_49",Vg="_brandMarkIcon_2uk4l_56",qg="_menuBarCompact_2uk4l_68",Xg="_menuWrap_2uk4l_91",Yg="_menuButton_2uk4l_97",Jg="_iconButton_2uk4l_98",Zg="_menuItem_2uk4l_99",Qg="_hamburgerButton_2uk4l_142",eb="_iconNav_2uk4l_149",tb="_iconNavMain_2uk4l_160",nb="_iconNavEnd_2uk4l_169",rb="_iconGroup_2uk4l_185",ob="_tooltipTrigger_2uk4l_276",ib="_menu_2uk4l_35",ab="_submenuWrap_2uk4l_304",lb="_submenu_2uk4l_304",sb="_submenuTrigger_2uk4l_314",cb="_menuOverlay_2uk4l_329",ub="_menuOverlayHeader_2uk4l_341",db="_menuOverlayTitle_2uk4l_351",mb="_menuOverlayBody_2uk4l_357",fb="_menuSeparator_2uk4l_408",pb="_icon_2uk4l_98",hb="_tooltip_2uk4l_276",gb="_tooltipElevated_2uk4l_493",X={toolbar:$g,menuBar:Ug,menuBarDesktop:Wg,brandMark:Gg,brandMarkIcon:Vg,menuBarCompact:qg,menuWrap:Xg,menuButton:Yg,iconButton:Jg,menuItem:Zg,hamburgerButton:Qg,iconNav:eb,iconNavMain:tb,iconNavEnd:nb,iconGroup:rb,tooltipTrigger:ob,menu:ib,submenuWrap:ab,submenu:lb,submenuTrigger:sb,menuOverlay:cb,menuOverlayHeader:ub,menuOverlayTitle:db,menuOverlayBody:mb,menuSeparator:fb,icon:pb,tooltip:hb,tooltipElevated:gb},bb=400,wl=6,$o=4;function mt({label:e,children:t,className:n,elevated:r}){const i=s.useRef(null),a=s.useRef(null),l=s.useRef(null),c=s.useRef(!1),m=s.useRef(!1),[p,b]=s.useState(!1),[h,w]=s.useState({top:0,left:0}),y=s.useCallback(()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)},[]),v=s.useCallback(g=>{if(!(c.current||m.current)){y(),b(!1);return}if(g||m.current){y(),b(!0);return}y(),l.current=setTimeout(()=>{l.current=null,b(!0)},bb)},[y]),x=s.useCallback(()=>{const g=i.current,S=a.current;if(!g||!S)return;const A=g.getBoundingClientRect(),N=S.offsetWidth,E=S.offsetHeight;let L=A.bottom+wl;L+E>window.innerHeight-$o&&(L=A.top-wl-E);let M=A.left+A.width/2-N/2;M=Math.min(Math.max(M,$o),window.innerWidth-N-$o),w({top:L,left:M})},[]);s.useEffect(()=>()=>y(),[y]),s.useEffect(()=>{const g=i.current;if(!g)return;const S=()=>{m.current=!0,v(!0)},A=()=>{m.current=!1,v(!1)};return g.addEventListener("focusin",S),g.addEventListener("focusout",A),()=>{g.removeEventListener("focusin",S),g.removeEventListener("focusout",A)}},[v]),s.useLayoutEffect(()=>{if(!p)return;x();const g=()=>x();return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[p,e,x]);const k=n?`${X.tooltipTrigger} ${n}`:X.tooltipTrigger;return o.jsxs(o.Fragment,{children:[o.jsx("span",{ref:i,className:k,"data-tooltip-trigger":"",onMouseEnter:()=>{c.current=!0,v(!1)},onMouseLeave:()=>{c.current=!1,v(!1)},children:t}),p?o.jsx(ie,{children:o.jsx("span",{ref:a,className:r?`${X.tooltip} ${X.tooltipElevated}`:X.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const yb="_wrap_1097y_1",xb="_wrapToolbar_1097y_7",wb="_field_1097y_12",vb="_trigger_1097y_20",Sb="_chevron_1097y_50",Cb="_list_1097y_73",kb="_listInline_1097y_88",Db="_option_1097y_96",Pb="_separator_1097y_125",$e={wrap:yb,wrapToolbar:xb,field:wb,trigger:vb,chevron:Sb,list:Cb,listInline:kb,option:Db,separator:Pb};function Ab({value:e,mixed:t=!1,fonts:n,disabled:r,listId:i,listRef:a,inline:l,style:c,onSelect:m}){const p=V(),b=!t&&e===null;return o.jsxs("ul",{ref:a,id:i,className:l?`${$e.list} ${$e.listInline}`:$e.list,role:"listbox","aria-label":p("commandFontFamilyAria"),style:c,children:[o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:$e.option,role:"option","aria-checked":b,disabled:r,onMouseDown:h=>h.preventDefault(),onClick:()=>m(null),children:p("fontFamilyDefault")})}),o.jsx("li",{className:$e.separator,role:"separator"}),n.map(h=>{const w=!t&&kn(e,h.family);return o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:$e.option,role:"option","aria-checked":w,disabled:r,style:{fontFamily:h.family},onMouseDown:y=>y.preventDefault(),onClick:()=>m(h.family),children:h.name})},h.family)})]})}function jb(e,t,n,r){var i;return t?"":e===null?r:((i=md(e,n))==null?void 0:i.name)??e}const lr=4;function jc({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:i,toolbar:a=!1,triggerId:l,onChange:c}){const m=V(),p=s.useId(),b=s.useRef(null),h=s.useRef(null),w=s.useRef(null),[y,v]=s.useState(!1),[x,k]=s.useState({top:0,left:0,width:0}),g=jb(e,t,n,m("fontFamilyDefault")),S=s.useCallback(()=>{const N=h.current,E=w.current;if(!N)return;const L=N.getBoundingClientRect(),M=(E==null?void 0:E.offsetHeight)??0,I=Math.max(L.width,(E==null?void 0:E.offsetWidth)??0);let j=L.bottom;j+M>window.innerHeight-lr&&(j=Math.max(lr,L.top-M));const T=Math.min(Math.max(L.left,lr),window.innerWidth-I-lr);k({top:j,left:T,width:I})},[]);s.useLayoutEffect(()=>{if(!y)return;S();const N=()=>S();return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[y,S,n.length]),s.useEffect(()=>{if(!y)return;const N=L=>{var I,j;const M=L.target;(I=b.current)!=null&&I.contains(M)||(j=w.current)!=null&&j.contains(M)||v(!1)},E=L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),v(!1))};return document.addEventListener("pointerdown",N),document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",E,!0)}},[y]);const A=o.jsxs("div",{className:`${$e.wrap}${a?` ${$e.wrapToolbar}`:""}`,ref:b,children:[o.jsxs("div",{className:$e.field,ref:h,children:[o.jsx("button",{type:"button",id:l,className:$e.trigger,disabled:r,"aria-label":a?m("commandFontFamilyAria"):void 0,"aria-haspopup":"listbox","aria-expanded":y,"aria-controls":y?p:void 0,style:e&&!t?{fontFamily:e}:void 0,onMouseDown:N=>N.preventDefault(),onClick:()=>v(N=>!N),children:g}),o.jsx("span",{className:$e.chevron,"aria-hidden":"true"})]}),y?o.jsx(ie,{children:o.jsx(Ab,{listRef:w,listId:p,value:t?null:e,mixed:t,fonts:n,disabled:r,style:{top:x.top,left:x.left,minWidth:x.width},onSelect:N=>{c(N),v(!1)}})}):null]});return i?o.jsx(mt,{label:i,children:A}):A}function Eb({commands:e,queries:t,disabled:n}){const r=V(),i=!!(n||!t.isVisualMode());return o.jsx(jc,{family:t.isFontFamilyMixed()?null:t.getFontFamily(),mixed:t.isFontFamilyMixed(),fonts:t.getFontFaces(),disabled:i,tooltip:r("commandFontFamily"),toolbar:!0,onChange:a=>{e.setFontFamily(a)}})}const Tb="_wrap_192bz_1",Nb="_wrapToolbar_192bz_9",Lb="_field_192bz_14",Mb="_input_192bz_22",Rb="_toggle_192bz_41",_b="_chevron_192bz_42",Ib="_unit_192bz_80",Fb="_list_192bz_110",Bb="_option_192bz_125",pe={wrap:Tb,wrapToolbar:Nb,field:Lb,input:Mb,toggle:Rb,chevron:_b,unit:Ib,list:Fb,option:Bb},sr=4,Hb={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Ec({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:i,tooltip:a,sizeInputId:l,toolbar:c=!1}){const m=V(),p=s.useId(),b=s.useRef(null),h=s.useRef(null),w=s.useRef(null),[y,v]=s.useState(()=>e===null?"":J(e)),[x,k]=s.useState(!1),[g,S]=s.useState(!1),[A,N]=s.useState({top:0,left:0,width:0});s.useEffect(()=>{x||v(e===null?"":J(e))},[e,x]);const E=s.useCallback(()=>{const T=h.current,P=w.current;if(!T)return;const R=T.getBoundingClientRect(),W=(P==null?void 0:P.offsetHeight)??0;let O=R.bottom;O+W>window.innerHeight-sr&&(O=Math.max(sr,R.top-W));const Z=Math.min(Math.max(R.left,sr),window.innerWidth-Math.max(R.width,72)-sr);N({top:O,left:Z,width:R.width})},[]);s.useLayoutEffect(()=>{if(!g)return;E();const T=()=>E();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[g,E]),s.useEffect(()=>{if(!g)return;const T=R=>{var O,Z;const W=R.target;(O=b.current)!=null&&O.contains(W)||(Z=w.current)!=null&&Z.contains(W)||S(!1)},P=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",P,!0)}},[g]);const L=T=>{const P=qd(T,t);if(!P){v(e===null?"":J(e));return}n(P.value,P.unit),v(J(P.value))},M=Ud[t],I=g?o.jsx(ie,{children:o.jsx("ul",{ref:w,className:pe.list,role:"listbox",id:p,style:{top:A.top,left:A.left,minWidth:A.width},children:M.map(T=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:pe.option,role:"option","aria-selected":e===T,onMouseDown:P=>P.preventDefault(),onClick:()=>{n(T,t),v(J(T)),S(!1)},children:J(T)})},T))})}):null,j=o.jsxs("div",{className:`${pe.wrap}${c?` ${pe.wrapToolbar}`:""}`,ref:b,children:[o.jsxs("div",{className:pe.field,ref:h,children:[o.jsx("input",{id:l,className:pe.input,value:y,disabled:i,"aria-label":m("commandFontSizeAria"),"aria-autocomplete":"list","aria-expanded":g,"aria-controls":p,role:"combobox",inputMode:"decimal",onFocus:()=>k(!0),onBlur:()=>{k(!1),L(y)},onChange:T=>v(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),L(y),S(!1),T.currentTarget.blur()),T.key==="ArrowDown"&&(T.preventDefault(),S(!0))}}),o.jsx("button",{type:"button",className:pe.toggle,tabIndex:-1,disabled:i,"aria-label":m("commandFontSizeAria"),"aria-expanded":g,"aria-controls":p,onMouseDown:T=>T.preventDefault(),onClick:()=>S(T=>!T)})]}),o.jsxs("div",{className:pe.field,children:[o.jsx("select",{className:pe.unit,value:t,disabled:i,"aria-label":m("commandFontSizeUnitAria"),onChange:T=>{r(T.target.value)},children:Ci.map(T=>o.jsx("option",{value:T,children:m(Hb[T])},T))}),o.jsx("span",{className:pe.chevron,"aria-hidden":"true"})]}),I]});return a?o.jsx(mt,{label:a,children:j}):j}const zb="_backdrop_mi7ap_1",Ob="_dialog_mi7ap_12",Kb="_dialogWide_mi7ap_28",$b="_header_mi7ap_32",Ub="_tabs_mi7ap_39",Wb="_tab_mi7ap_39",Gb="_body_mi7ap_71",Vb="_field_mi7ap_79",qb="_label_mi7ap_85",Xb="_sizeRow_mi7ap_89",Yb="_fileRow_mi7ap_95",Jb="_fileName_mi7ap_101",Zb="_marks_mi7ap_108",Qb="_mark_mi7ap_108",ey="_actions_mi7ap_123",ty="_actionsSpread_mi7ap_130",ny="_actionsEnd_mi7ap_134",ry="_headerRow_mi7ap_139",oy="_close_mi7ap_151",iy="_nameSection_mi7ap_168",ay="_nameInput_mi7ap_172",ly="_labelRow_mi7ap_189",sy="_help_mi7ap_195",cy="_textInput_mi7ap_213",uy="_fullSelect_mi7ap_225",dy="_error_mi7ap_229",my="_emptyHint_mi7ap_234",fy="_action_mi7ap_123",py="_textarea_mi7ap_245",hy="_actionDanger_mi7ap_259",gy="_confirmBody_mi7ap_265",by="_nestedPanel_mi7ap_273",yy="_spinnerWrap_mi7ap_284",xy="_spinner_mi7ap_284",wy="_actionPrimary_mi7ap_319",vy="_iconButton_mi7ap_333",Sy="_select_mi7ap_334",Cy="_lengthInput_mi7ap_335",ky="_lengthUnit_mi7ap_336",Dy="_group_mi7ap_344",Py="_nestedGroup_mi7ap_354",Ay="_subLabel_mi7ap_364",jy="_iconRow_mi7ap_368",Ey="_lengthField_mi7ap_400",Ty="_sideLabel_mi7ap_406",Ny="_lengthRow_mi7ap_410",Ly="_sideGrid_mi7ap_438",My="_shadowGrid_mi7ap_439",d={backdrop:zb,dialog:Ob,dialogWide:Kb,header:$b,tabs:Ub,tab:Wb,body:Gb,field:Vb,label:qb,sizeRow:Xb,fileRow:Yb,fileName:Jb,marks:Zb,mark:Qb,actions:ey,actionsSpread:ty,actionsEnd:ny,headerRow:ry,close:oy,nameSection:iy,nameInput:ay,labelRow:ly,help:sy,textInput:cy,fullSelect:uy,error:dy,emptyHint:my,action:fy,textarea:py,actionDanger:hy,confirmBody:gy,nestedPanel:by,spinnerWrap:yy,spinner:xy,actionPrimary:wy,iconButton:vy,select:Sy,lengthInput:Cy,lengthUnit:ky,group:Dy,nestedGroup:Py,subLabel:Ay,iconRow:jy,lengthField:Ey,sideLabel:Ty,lengthRow:Ny,sideGrid:Ly,shadowGrid:My},Ry={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Gi({tab:e,value:t,fonts:n,disabled:r,onTabChange:i,onChange:a}){const l=V(),c=s.useId(),m=s.useId(),p=n??ss(),b=Ko.find(h=>h.id===e)??Ko[0];return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":l("fontDialogTitle"),children:Ko.map(h=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":h.id===e,disabled:!h.implemented,onClick:()=>i(h.id),children:l(h.labelKey)},h.id))}),o.jsx("div",{className:d.body,role:"tabpanel",children:b.implemented?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("fontDialogFamily")}),o.jsx(jc,{family:t.fontFamilyMixed?null:t.fontFamily,mixed:t.fontFamilyMixed,fonts:p,disabled:r,triggerId:m,onChange:h=>{a({...t,fontFamily:h,fontFamilyMixed:!1})}})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:l("fontDialogSize")}),o.jsx("div",{className:d.sizeRow,children:o.jsx(Ec,{size:t.size,unit:t.unit,sizeInputId:c,disabled:r,onSizeChange:(h,w)=>{a({...t,size:h,unit:w})},onUnitChange:h=>{const w=t.size!==null?ms(t.size,t.unit,h,16,16):t.size;a({...t,size:w,unit:h})}})})]}),o.jsx("div",{className:d.field,children:o.jsx(Fe,{label:l("commandFontColor"),noneLabel:l("colorAutomatic"),value:t.fontColor,mixed:t.fontColorMixed,disabled:r,onChange:h=>{a({...t,fontColor:h,fontColorMixed:!1})}})}),o.jsx("div",{className:d.field,children:o.jsx(Fe,{label:l("commandHighlightColor"),noneLabel:l("colorNone"),value:t.highlightColor,mixed:t.highlightColorMixed,disabled:r,fallbackCustom:"#ffff00",onChange:h=>{a({...t,highlightColor:h,highlightColorMixed:!1})}})}),o.jsxs("fieldset",{className:d.marks,children:[o.jsx("legend",{className:d.label,children:l("fontDialogStyle")}),Ue.map(h=>o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.marks[h],disabled:r,onChange:()=>{a({...t,marks:{...t.marks,[h]:!t.marks[h]}})}}),l(Ry[h].label)]},h))]})]}):null})]})}const vl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function _y({open:e,tab:t,size:n,unit:r,marks:i,fontFamily:a=null,fontFamilyMixed:l=!1,fontColor:c,fontColorMixed:m=!1,highlightColor:p,highlightColorMixed:b=!1,fonts:h,disabled:w,onTabChange:y,onApply:v,onClose:x}){const k=V(),g=s.useId(),S=s.useRef(null),[A,N]=s.useState({size:n,unit:r,marks:i,fontFamily:a,fontFamilyMixed:l,fontColor:c,highlightColor:p,fontColorMixed:m,highlightColorMixed:b});return s.useEffect(()=>{e&&N({size:n,unit:r,marks:i,fontFamily:a,fontFamilyMixed:l,fontColor:c,highlightColor:p,fontColorMixed:m,highlightColorMixed:b})},[e,n,r,i,a,l,c,m,p,b]),s.useEffect(()=>{if(!e)return;const E=S.current,L=E==null?void 0:E.querySelector(vl);L==null||L.focus();const M=I=>{if(I.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;I.preventDefault(),I.stopPropagation(),x();return}if(I.key!=="Tab"||!E)return;const j=[...E.querySelectorAll(vl)];if(j.length===0)return;const T=j[0],P=j[j.length-1];I.shiftKey&&document.activeElement===T?(I.preventDefault(),P.focus()):!I.shiftKey&&document.activeElement===P&&(I.preventDefault(),T.focus())};return document.addEventListener("keydown",M,!0),()=>document.removeEventListener("keydown",M,!0)},[e,x]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:x,children:o.jsxs("div",{ref:S,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":g,onMouseDown:E=>E.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:g,children:k("fontDialogTitle")}),o.jsx(Gi,{tab:t,value:A,fonts:h,disabled:w,onTabChange:y,onChange:N}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:x,children:k("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:w,onClick:()=>v(A),children:k("fontDialogOk")})]})]})})}):null}const Iy={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function ge({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:i,inputId:a,onChange:l}){const c=V(),m=s.useId(),p=a??m,b=(t==null?void 0:t.unit)??zs,[h,w]=s.useState(()=>t?J(t.value):""),[y,v]=s.useState(!1);s.useEffect(()=>{y||w(t?J(t.value):"")},[t,y]);const x=k=>{const g=k.trim();if(!g){l(null),w("");return}const S=Sr(g,b,r);if(!S){w(t?J(t.value):"");return}l(S),w(J(S.value))};return o.jsxs("div",{className:d.lengthField,children:[o.jsx("label",{className:d.sideLabel,htmlFor:p,children:e}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:p,className:d.lengthInput,value:h,disabled:n,inputMode:"decimal",onFocus:()=>v(!0),onBlur:()=>{v(!1),x(h)},onChange:k=>w(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),x(h),k.currentTarget.blur())}}),o.jsx("select",{className:d.lengthUnit,value:b,disabled:n,"aria-label":i??c("paragraphDialogLengthUnitAria"),onChange:k=>{const g=k.target.value;if(t){l({value:t.value,unit:g});return}if(h.trim()){const S=Sr(h,g,r);l(S)}},children:Ci.map(k=>o.jsx("option",{value:k,children:c(Iy[k])},k))})]})]})}function Vi({shadow:e,disabled:t,onChange:n}){const r=V();return o.jsxs("div",{className:d.shadowGrid,children:[o.jsx(ge,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:i=>{n({...e,offsetX:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:i=>{n({...e,offsetY:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:i=>{n({...e,blur:i??{value:0,unit:"px"}})}}),o.jsx(ge,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:i=>{n({...e,spread:i??{value:0,unit:"px"}})}}),o.jsx(Fe,{label:r("paragraphDialogShadowColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:i=>{n({...e,color:i})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:e.inset,disabled:t,onChange:()=>{n({...e,inset:!e.inset})}}),r("paragraphDialogShadowInset")]})]})}const Sl=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0}],Fy={left:hi,center:pi,right:gi,justify:Wl},By={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},Hy={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},zy={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Oy={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},Ky={value:1,unit:"pt"},$y={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 fn(e){return{top:e,right:e,bottom:e,left:e}}function Cl(e){for(const t of Xe)if(e[t])return e[t];return null}function qi({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:i="paragraphDialogTitle",onTabChange:a,onChange:l}){const c=V(),m=r?Sl.filter(x=>r.includes(x.id)):Sl,p=s.useId(),[b,h]=s.useState(()=>nt(t.margin,fn(t.margin.top))),[w,y]=s.useState(()=>nt(t.padding,fn(t.padding.top))),v=(x,k,g,S)=>{const A=t[x],N=k?fn(S):{...A,[g]:S};l({...t,[x]:N,[`${x}Mixed`]:!1})};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":c(i),children:m.map(x=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":x.id===e,disabled:!x.implemented,onClick:()=>a(x.id),children:c(x.labelKey)},x.id))}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[e==="general"?o.jsxs(o.Fragment,{children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogAlignment")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":c("paragraphDialogAlignment"),children:Js.map(x=>{const k=Fy[x],g=!t.alignMixed&&t.align===x;return o.jsx("button",{type:"button",className:d.iconButton,role:"radio","aria-checked":g,"aria-label":c(By[x].aria),disabled:n,onClick:()=>{l({...t,align:x,alignMixed:!1})},children:o.jsx(k,{})},x)})})]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogLists")}),o.jsxs("div",{className:d.iconRow,children:[o.jsx("button",{type:"button",className:d.iconButton,"aria-pressed":!t.listMixed&&t.list==="ul","aria-label":c("commandBulletListAria"),disabled:n,onClick:()=>{const x=!t.listMixed&&t.list==="ul"?null:"ul";l({...t,list:x,listMixed:!1})},children:o.jsx(Gl,{})}),o.jsx("button",{type:"button",className:d.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":c("commandNumberedListAria"),disabled:n,onClick:()=>{const x=!t.listMixed&&t.list==="ol"?null:"ol";l({...t,list:x,listMixed:!1})},children:o.jsx(Yl,{})})]})]})]}):null,e==="spacing"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogSpacing")}),o.jsx(kl,{legend:c("paragraphDialogMargin"),sides:t.margin,linked:b,disabled:n,allowNegative:!0,onLinkedChange:x=>{h(x),x&&l({...t,margin:fn(Cl(t.margin)),marginMixed:!1})},onSideChange:(x,k)=>v("margin",b,x,k)}),o.jsx(kl,{legend:c("paragraphDialogPadding"),sides:t.padding,linked:w,disabled:n,onLinkedChange:x=>{y(x),x&&l({...t,padding:fn(Cl(t.padding)),paddingMixed:!1})},onSideChange:(x,k)=>v("padding",w,x,k)}),o.jsx(Wy,{value:t.lineHeight,disabled:n,onChange:x=>{l({...t,lineHeight:x,lineHeightMixed:!1})}})]}):null,e==="border"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:c("paragraphDialogBorderStyle")}),o.jsx("select",{id:p,className:d.select,value:t.border.style,disabled:n,onChange:x=>{const k=x.target.value;l({...t,border:{style:k,width:k==="none"?null:t.border.width??Ky,color:k==="none"?null:t.border.color},borderMixed:!1})},children:Lr.map(x=>o.jsx("option",{value:x,children:c(zy[x])},x))})]}),t.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:c("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:x=>{l({...t,border:{...t.border,width:x},borderMixed:!1})}}),o.jsx(Fe,{label:c("paragraphDialogBorderColor"),noneLabel:c("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:x=>{l({...t,border:{...t.border,color:x},borderMixed:!1})}})]}):null,o.jsx(ge,{label:c("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:x=>{l({...t,borderRadius:x,radiusMixed:!1})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:n,onChange:()=>{l({...t,boxShadow:t.boxShadow?null:$y,shadowMixed:!1})}}),c("paragraphDialogBoxShadow")]}),t.boxShadow?o.jsx(Vi,{shadow:t.boxShadow,disabled:n,onChange:x=>{l({...t,boxShadow:x,shadowMixed:!1})}}):null]}):null,e==="background"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:c("paragraphDialogTabBackground")}),o.jsx(Fe,{label:c("paragraphDialogBackgroundColor"),noneLabel:c("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:x=>{l({...t,backgroundColor:x,backgroundMixed:!1})}}),o.jsx(Uy,{value:t.opacity,disabled:n,onChange:x=>{l({...t,opacity:x,opacityMixed:!1})}})]}):null]})]})}function Uy({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=e===null?null:Cr(e),[l,c]=s.useState(()=>a===null?"":J(a)),[m,p]=s.useState(!1);s.useEffect(()=>{m||c(a===null?"":J(a))},[a,m]);const b=h=>{const w=h.trim();if(!w){n(null),c("");return}const y=Number(w.replace(",","."));if(!Number.isFinite(y)){c(a===null?"":J(a));return}const v=Us(y);n(v),c(J(Cr(v)))};return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogOpacity")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:l,disabled:t,inputMode:"decimal",onFocus:()=>p(!0),onChange:h=>c(h.target.value),onBlur:()=>{p(!1),b(l)}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}function kl({legend:e,sides:t,linked:n,disabled:r,allowNegative:i=!1,onLinkedChange:a,onSideChange:l}){const c=V(),m=n?["top"]:Xe;return o.jsxs("fieldset",{className:d.nestedGroup,children:[o.jsx("legend",{className:d.subLabel,children:e}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:()=>a(!n)}),c("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:m.map(p=>o.jsx(ge,{label:n?e:c(Hy[p]),value:t[p],disabled:r,allowNegative:i,onChange:b=>l(p,b)},p))})]})}function Wy({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=Gy(e),l=(e==null?void 0:e.kind)==="number"||(e==null?void 0:e.kind)==="length"?e.value:null,[c,m]=s.useState(()=>l===null?"":J(l)),p=(e==null?void 0:e.kind)==="length"?e.unit:zs;return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogLineHeight")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:a==="normal"?"":c,disabled:t||a==="normal",inputMode:"decimal",onChange:b=>m(b.target.value),onBlur:()=>{const b=c.trim();if(!b){n(null);return}if(a==="number"||a==="empty"){const w=Number(b.replace(",","."));if(!Number.isFinite(w)||w<0){m(l===null?"":J(l));return}n({kind:"number",value:w}),m(J(w));return}const h=Sr(b,p,!1);if(!h){m(l===null?"":J(l));return}n({kind:"length",value:h.value,unit:h.unit}),m(J(h.value))}}),o.jsxs("select",{className:d.lengthUnit,value:a==="length"?p:a,disabled:t,"aria-label":r("paragraphDialogLengthUnitAria"),onChange:b=>{const h=b.target.value;if(h==="empty"){n(null),m("");return}if(h==="normal"){n({kind:"normal"}),m("");return}if(h==="number"){const x=Number((c||"1.5").replace(",",".")),k=Number.isFinite(x)&&x>=0?x:1.5;n({kind:"number",value:k}),m(J(k));return}const w=h,y=Sr(c||"1",w,!1),v=(y==null?void 0:y.value)??1;n({kind:"length",value:v,unit:w}),m(J(v))},children:[o.jsx("option",{value:"empty"}),o.jsx("option",{value:"normal",children:r("paragraphDialogLineHeightNormal")}),o.jsx("option",{value:"number",children:r("paragraphDialogLineHeightUnitless")}),["pt","px","em","rem","%"].map(b=>o.jsx("option",{value:b,children:r(Oy[b])},b))]})]})]})}function Gy(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}const Dl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function Vy({open:e,tab:t,value:n,disabled:r,onTabChange:i,onApply:a,onClose:l}){const c=V(),m=s.useId(),p=s.useRef(null),[b,h]=s.useState(n);return s.useEffect(()=>{e&&h(n)},[e,n]),s.useEffect(()=>{if(!e)return;const w=p.current,y=w==null?void 0:w.querySelector(Dl);y==null||y.focus();const v=x=>{if(x.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;x.preventDefault(),x.stopPropagation(),l();return}if(x.key!=="Tab"||!w)return;const k=[...w.querySelectorAll(Dl)];if(k.length===0)return;const g=k[0],S=k[k.length-1];x.shiftKey&&document.activeElement===g?(x.preventDefault(),S.focus()):!x.shiftKey&&document.activeElement===S&&(x.preventDefault(),g.focus())};return document.addEventListener("keydown",v,!0),()=>document.removeEventListener("keydown",v,!0)},[e,l]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:l,children:o.jsxs("div",{ref:p,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":m,onMouseDown:w=>w.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:m,children:c("paragraphDialogTitle")}),o.jsx(qi,{tab:t,value:b,disabled:r,onTabChange:i,onChange:h}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:l,children:c("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:r,onClick:()=>a(b),children:c("fontDialogOk")})]})]})})}):null}const qy=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0}],Pl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])',Xy=qy.map(e=>e.id);function Yy(e){return{...hn(),...e}}function Jy(e){const{align:t,alignMixed:n,list:r,listMixed:i,...a}=e;return a}function Zy({open:e,tab:t,value:n,fonts:r,disabled:i,onTabChange:a,onApply:l,onClose:c}){const m=V(),p=s.useId(),b=s.useRef(null),[h,w]=s.useState("general"),[y,v]=s.useState("spacing"),[x,k]=s.useState(n.font),[g,S]=s.useState(n.box);if(s.useEffect(()=>{e&&(w("general"),v("spacing"),k(n.font),S(n.box))},[e,n]),s.useEffect(()=>{if(!e)return;const N=b.current,E=N==null?void 0:N.querySelector(Pl);E==null||E.focus();const L=M=>{if(M.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;M.preventDefault(),M.stopPropagation(),c();return}if(M.key!=="Tab"||!N)return;const I=[...N.querySelectorAll(Pl)];if(I.length===0)return;const j=I[0],T=I[I.length-1];M.shiftKey&&document.activeElement===j?(M.preventDefault(),T.focus()):!M.shiftKey&&document.activeElement===T&&(M.preventDefault(),j.focus())};return document.addEventListener("keydown",L,!0),()=>document.removeEventListener("keydown",L,!0)},[e,c]),!e)return null;const A=m("pageDialogTitle");return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:c,children:o.jsxs("div",{ref:b,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":p,onMouseDown:N=>N.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:p,children:A}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":A,children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="font",onClick:()=>a("font"),children:m("customStyleDialogTabFont")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="paragraph",onClick:()=>a("paragraph"),children:m("customStyleDialogTabParagraph")})]}),t==="font"?o.jsx("div",{className:d.nestedPanel,children:o.jsx(Gi,{tab:h,value:x,fonts:r,disabled:i,onTabChange:w,onChange:k})}):o.jsx("div",{className:d.nestedPanel,children:o.jsx(qi,{tab:y,value:Yy(g),disabled:i,tabs:Xy,tablistLabelKey:"pageDialogTitle",onTabChange:N=>{N!=="general"&&v(N)},onChange:N=>S(Jy(N))})}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:c,children:m("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:i,onClick:()=>l({font:x,box:g}),children:m("fontDialogOk")})]})]})})})}const Al='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function Qy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function jl(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 ex(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 tx({open:e,mode:t,styleId:n,name:r="",font:i,paragraph:a,canDelete:l=!1,busy:c,disabled:m,fonts:p,defaultOuterTab:b="font",onSave:h,onDelete:w,onClose:y}){const v=V(),x=s.useId(),k=s.useId(),g=s.useRef(null),[S,A]=s.useState(r),[N,E]=s.useState(b),[L,M]=s.useState("general"),[I,j]=s.useState("general"),[T,P]=s.useState(()=>jl(i)),[R,W]=s.useState(()=>ni(a)),[O,Z]=s.useState(!1);if(s.useEffect(()=>{e&&(A(r),E(b),M("general"),j("general"),P(jl(i)),W(ni(a)),Z(!1))},[e,r,i,a,b]),s.useEffect(()=>{if(!e)return;const ne=g.current,Q=ne==null?void 0:ne.querySelector(Al);Q==null||Q.focus();const D=$=>{if($.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;if($.preventDefault(),$.stopPropagation(),O){Z(!1);return}y();return}if($.key!=="Tab"||!ne)return;const Y=[...ne.querySelectorAll(Al)];if(Y.length===0)return;const B=Y[0],fe=Y[Y.length-1];$.shiftKey&&document.activeElement===B?($.preventDefault(),fe.focus()):!$.shiftKey&&document.activeElement===fe&&($.preventDefault(),B.focus())};return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[e,y,O]),!e)return null;const te=v(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),ce=S.trim().length>0,re=!!(m||c),he=()=>{const ne=S.trim();ne&&h({id:n??Qy(),name:ne,font:ex(T),paragraph:tc(R)})};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:y,children:o.jsxs("div",{ref:g,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":x,"aria-busy":c||void 0,onMouseDown:ne=>ne.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:x,children:te}),o.jsx("button",{type:"button",className:d.close,"aria-label":v("customStyleDialogCloseAria"),onClick:y,children:o.jsx(We,{})})]}),O?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.confirmBody,children:v("customStyleDialogDeleteConfirm")}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,disabled:re,onClick:()=>Z(!1),children:v("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionDanger}`,disabled:re||!n,onClick:()=>{n&&(w==null||w(n))},children:v("customStyleDialogDelete")})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.nameSection,children:o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:k,children:v("customStyleDialogName")}),o.jsx("input",{id:k,className:d.nameInput,value:S,disabled:re,onChange:ne=>A(ne.target.value)})]})}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":te,children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":N==="font",onClick:()=>E("font"),children:v("customStyleDialogTabFont")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":N==="paragraph",onClick:()=>E("paragraph"),children:v("customStyleDialogTabParagraph")})]}),N==="font"?o.jsx("div",{className:d.nestedPanel,children:o.jsx(Gi,{tab:L,value:T,fonts:p,disabled:re,onTabChange:M,onChange:P})}):o.jsx("div",{className:d.nestedPanel,children:o.jsx(qi,{tab:I,value:R,disabled:re,onTabChange:j,onChange:W})}),o.jsxs("div",{className:t==="edit"&&l?`${d.actions} ${d.actionsSpread}`:d.actions,children:[t==="edit"&&l?o.jsx("button",{type:"button",className:`${d.action} ${d.actionDanger}`,disabled:re,onClick:()=>Z(!0),children:v("customStyleDialogDelete")}):null,o.jsxs("div",{className:d.actionsEnd,children:[o.jsx("button",{type:"button",className:d.action,onClick:y,children:v("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:re||!ce,onClick:he,children:v("fontDialogOk")})]})]})]})]})})})}const El='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])',nx={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function rx({open:e,existingIds:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useId(),m=s.useId(),p=s.useRef(null),[b,h]=s.useState(""),[w,y]=s.useState(!1),v=s.useMemo(()=>new Set(t),[t]),x=ac(b,v);if(s.useEffect(()=>{e&&(h(""),y(!1))},[e]),s.useEffect(()=>{if(!e)return;const A=p.current,N=A==null?void 0:A.querySelector(El);N==null||N.focus();const E=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),i();return}if(L.key!=="Tab"||!A)return;const M=[...A.querySelectorAll(El)];if(M.length===0)return;const I=M[0],j=M[M.length-1];L.shiftKey&&document.activeElement===I?(L.preventDefault(),j.focus()):!L.shiftKey&&document.activeElement===j&&(L.preventDefault(),I.focus())};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[e,i]),!e)return null;const k=w||b.trim().length>0?x:null,g=x===null&&!n,S=()=>{y(!0),!(x||n)&&r(b.trim())};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:p,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:A=>A.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("bookmarkDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("bookmarkDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx("div",{className:d.body,children:o.jsxs("div",{className:d.field,children:[o.jsxs("div",{className:d.labelRow,children:[o.jsx("label",{className:d.label,htmlFor:c,children:a("bookmarkDialogName")}),o.jsx(mt,{label:a("bookmarkDialogHelp"),elevated:!0,children:o.jsx("button",{type:"button",className:d.help,"aria-label":a("bookmarkDialogHelpAria"),children:"?"})})]}),o.jsx("input",{id:c,className:d.textInput,value:b,disabled:n,"aria-invalid":k!==null,"aria-describedby":k?m:void 0,onChange:A=>h(A.target.value)}),k?o.jsx("p",{id:m,className:d.error,children:a(nx[k])}):null]})}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!g,onClick:S,children:a("fontDialogOk")})]})]})})})}const Tl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',ox={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},ix={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function ax({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:i,onClose:a}){const l=V(),c=s.useId(),m=s.useId(),p=s.useId(),b=s.useId(),h=s.useId(),w=s.useRef(null),y=s.useRef(null),[v,x]=s.useState("file"),[k,g]=s.useState(""),[S,A]=s.useState(""),[N,E]=s.useState(""),[L,M]=s.useState(""),[I,j]=s.useState(""),[T,P]=s.useState(null),[R,W]=s.useState(!1);if(s.useEffect(()=>{e&&(x("file"),g(""),A(""),E(""),M(""),j(""),P(null),W(!1),y.current&&(y.current.value=""))},[e]),s.useEffect(()=>{if(!e)return;const Q=w.current,D=Q==null?void 0:Q.querySelector(Tl);D==null||D.focus();const $=Y=>{if(Y.key==="Escape"){Y.preventDefault(),Y.stopPropagation(),a();return}if(Y.key!=="Tab"||!Q)return;const B=[...Q.querySelectorAll(Tl)];if(B.length===0)return;const fe=B[0],ue=B[B.length-1];Y.shiftKey&&document.activeElement===fe?(Y.preventDefault(),ue.focus()):!Y.shiftKey&&document.activeElement===ue&&(Y.preventDefault(),fe.focus())};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[e,a]),!e)return null;const O=v==="file"?S:v==="url"?k:"",Z=v==="custom"?null:Oi(O),te=v==="custom"?null:v==="file"&&T?ix[T]:Z&&(v==="file"||k.trim().length>0)?ox[Z]:null,ce=v!=="custom"&&Z===null&&!(v==="file"&&T)&&!t&&!R,re=()=>{t||!n||i==null||i()},he=()=>{ce&&r({src:O.trim(),alt:L.trim(),title:I.trim()})},ne=Q=>{var $;const D=($=Q.target.files)==null?void 0:$[0];D&&(W(!0),P(null),Cp(D).then(Y=>{A(Y),E(D.name),x("file"),W(!1)},Y=>{const B=Y instanceof Error?Y.message:"";A(""),E(""),x("file"),P(B==="tooLarge"||B==="type"?B:"type"),W(!1),y.current&&(y.current.value="")}))};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:a,children:o.jsxs("div",{ref:w,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":c,onMouseDown:Q=>Q.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:c,children:l("imageDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":l("imageDialogCloseAria"),onClick:a,children:o.jsx(We,{})})]}),o.jsxs("div",{className:d.body,children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.subLabel,children:l("imageDialogSource")}),o.jsxs("div",{className:d.sizeRow,role:"radiogroup","aria-label":l("imageDialogSource"),children:[o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="file",disabled:t,onClick:()=>x("file"),children:l("imageDialogFile")}),o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="url",disabled:t,onClick:()=>x("url"),children:l("imageDialogUrl")}),n?o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":v==="custom",disabled:t,onClick:()=>x("custom"),children:n.text}):null]}),v==="file"?o.jsxs("div",{className:d.fileRow,children:[o.jsx("input",{ref:y,type:"file",accept:gp,hidden:!0,disabled:t,"aria-label":l("imageDialogChooseFile"),onChange:ne}),o.jsx("button",{type:"button",className:d.action,disabled:t||R,onClick:()=>{var Q;return(Q=y.current)==null?void 0:Q.click()},children:l("imageDialogChooseFile")}),N?o.jsx("span",{className:d.fileName,children:N}):null]}):null,v==="url"?o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("imageDialogUrl")}),o.jsx("input",{id:m,className:d.textInput,value:k,disabled:t,"aria-invalid":te!==null,"aria-describedby":te?h:void 0,onChange:Q=>g(Q.target.value)})]}):null,v==="custom"&&n?o.jsxs("div",{className:d.field,children:[o.jsx("p",{className:d.emptyHint,children:n.description}),o.jsx("button",{type:"button",className:d.action,disabled:t,onClick:re,children:n.buttonCaption})]}):null]}),v!=="custom"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:l("imageDialogAlt")}),o.jsx("input",{id:p,className:d.textInput,value:L,disabled:t,onChange:Q=>M(Q.target.value)})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:b,children:l("imageDialogTitleField")}),o.jsx("input",{id:b,className:d.textInput,value:I,disabled:t,onChange:Q=>j(Q.target.value)})]})]}):null,te?o.jsx("p",{id:h,className:d.error,children:l(te)}):null]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:a,children:l("fontDialogCancel")}),v!=="custom"?o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!ce,onClick:he,children:l("fontDialogOk")}):null]})]})})})}const cr=4,lx={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function Nl({label:e,inputAria:t,value:n,disabled:r,onChange:i}){const a=V(),l=s.useId(),c=s.useId(),m=s.useRef(null),p=s.useRef(null),b=s.useRef(null),h=(n==null?void 0:n.unit)??Op,[w,y]=s.useState(()=>n?J(n.value):""),[v,x]=s.useState(!1),[k,g]=s.useState(!1),[S,A]=s.useState({top:0,left:0,width:0});s.useEffect(()=>{v||y(n?J(n.value):"")},[n,v]);const N=s.useCallback(()=>{const j=p.current,T=b.current;if(!j)return;const P=j.getBoundingClientRect(),R=(T==null?void 0:T.offsetHeight)??0;let W=P.bottom;W+R>window.innerHeight-cr&&(W=Math.max(cr,P.top-R));const O=Math.min(Math.max(P.left,cr),window.innerWidth-Math.max(P.width,72)-cr);A({top:W,left:O,width:P.width})},[]);s.useLayoutEffect(()=>{if(!k)return;N();const j=()=>N();return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[k,N]),s.useEffect(()=>{if(!k)return;const j=P=>{var W,O;const R=P.target;(W=m.current)!=null&&W.contains(R)||(O=b.current)!=null&&O.contains(R)||g(!1)},T=P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),g(!1))};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",T,!0),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",T,!0)}},[k]);const E=j=>{const T=j.trim();if(!T){i(null),y("");return}const P=dl(T,h);if(!P){y(n?J(n.value):"");return}i(P),y(J(P.value))},L=Kp[h],M=(n==null?void 0:n.value)??null,I=k?o.jsx(ie,{children:o.jsx("ul",{ref:b,className:pe.list,role:"listbox",id:l,style:{top:S.top,left:S.left,minWidth:S.width},children:L.map(j=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:pe.option,role:"option","aria-selected":M===j,onMouseDown:T=>T.preventDefault(),onClick:()=>{i({value:j,unit:h}),y(J(j)),g(!1)},children:J(j)})},j))})}):null;return o.jsxs("div",{className:d.lengthField,children:[o.jsx("label",{className:d.sideLabel,htmlFor:c,children:e}),o.jsxs("div",{className:`${pe.wrap} ${d.lengthRow}`,ref:m,children:[o.jsxs("div",{className:pe.field,ref:p,children:[o.jsx("input",{id:c,className:pe.input,value:w,disabled:r,"aria-label":t,"aria-autocomplete":"list","aria-expanded":k,"aria-controls":l,role:"combobox",inputMode:"decimal",onFocus:()=>x(!0),onBlur:()=>{x(!1),E(w)},onChange:j=>y(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),E(w),g(!1),j.currentTarget.blur()),j.key==="ArrowDown"&&(j.preventDefault(),g(!0))}}),o.jsx("button",{type:"button",className:pe.toggle,tabIndex:-1,disabled:r,"aria-label":t,"aria-expanded":k,"aria-controls":l,onMouseDown:j=>j.preventDefault(),onClick:()=>g(j=>!j)})]}),o.jsxs("div",{className:pe.field,children:[o.jsx("select",{className:pe.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:j=>{const T=j.target.value;if(n){i({value:n.value,unit:T});return}w.trim()&&i(dl(w,T))},children:uc.map(j=>o.jsx("option",{value:j,children:a(lx[j])},j))}),o.jsx("span",{className:pe.chevron,"aria-hidden":"true"})]}),I]})]})}const sx=[{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}],cx={left:hi,center:pi,right:gi},ux=["left","center","right"],dx={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},mx=["width","height","lock"],fx={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},px={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},hx={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},gx={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},bx={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"},yx={value:1,unit:"pt"},xx={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 Uo(e){return{top:e,right:e,bottom:e,left:e}}function wx(e){for(const t of Xe)if(e[t])return e[t];return null}function vx({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:i,onChange:a}){const l=V(),c=s.useId(),m=s.useId(),p=s.useId(),b=s.useId(),h=s.useId(),[w,y]=s.useState(()=>nt(t.margin,Uo(t.margin.top))),v=t.align==="center",x=(g,S)=>{if(t.sizeMode==="lock"&&S){const A=gn(g,S,n);a({...t,width:A.width,height:A.height});return}a({...t,[g]:S})},k=g=>{if(g==="width"){a({...t,sizeMode:g,height:null});return}if(g==="height"){a({...t,sizeMode:g,width:null});return}if(t.width){const S=gn("width",t.width,n);a({...t,sizeMode:g,width:S.width,height:S.height});return}if(t.height){const S=gn("height",t.height,n);a({...t,sizeMode:g,width:S.width,height:S.height});return}a({...t,sizeMode:g})};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:d.tabs,role:"tablist","aria-label":l("imagePropertiesDialogTitle"),children:sx.map(g=>o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":g.id===e,disabled:!g.implemented,onClick:()=>i(g.id),children:l(g.labelKey)},g.id))}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[e==="general"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesSize")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":l("imagePropertiesSizeMode"),children:mx.map(g=>o.jsx("button",{type:"button",className:d.action,role:"radio","aria-checked":t.sizeMode===g,disabled:r,onClick:()=>k(g),children:l(fx[g])},g))}),o.jsx(Nl,{label:l("imagePropertiesWidth"),inputAria:l("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:g=>x("width",g)}),o.jsx(Nl,{label:l("imagePropertiesHeight"),inputAria:l("imagePropertiesHeightAria"),value:t.height,disabled:r||t.sizeMode==="width",onChange:g=>x("height",g)})]}):null,e==="alignment"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogAlignment")}),o.jsx("div",{className:d.iconRow,role:"radiogroup","aria-label":l("paragraphDialogAlignment"),children:ux.map(g=>{const S=cx[g];return o.jsx("button",{type:"button",className:d.iconButton,role:"radio","aria-checked":t.align===g,"aria-label":l(dx[g]),disabled:r,onClick:()=>{a({...t,align:t.align===g?null:g})},children:o.jsx(S,{})},g)})})]}):null,e==="border"?o.jsxs(o.Fragment,{children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogMargin")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:w,disabled:r||v,onChange:()=>{const g=!w;y(g),g&&a({...t,margin:Uo(wx(t.margin))})}}),l("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(w?["top"]:Xe).map(g=>o.jsx(ge,{label:l(w?"paragraphDialogMargin":px[g]),value:t.margin[g],disabled:r||v&&(g==="left"||g==="right"),allowNegative:!0,onChange:S=>{const A=w?Uo(S):{...t.margin,[g]:S};a({...t,margin:A})}},g))})]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:l("paragraphDialogBorderStyle")}),o.jsx("select",{id:c,className:d.select,value:t.border.style,disabled:r,onChange:g=>{const S=g.target.value;a({...t,border:{style:S,width:S==="none"?null:t.border.width??yx,color:S==="none"?null:t.border.color}})},children:Lr.map(g=>o.jsx("option",{value:g,children:l(hx[g])},g))})]}),t.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:l("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:g=>{a({...t,border:{...t.border,width:g}})}}),o.jsx(Fe,{label:l("paragraphDialogBorderColor"),noneLabel:l("colorNone"),value:t.border.color,disabled:r,onChange:g=>{a({...t,border:{...t.border,color:g}})}})]}):null,o.jsx(ge,{label:l("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:r,onChange:g=>{a({...t,borderRadius:g})}}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:r,onChange:()=>{a({...t,boxShadow:t.boxShadow?null:xx})}}),l("paragraphDialogBoxShadow")]}),t.boxShadow?o.jsx(Vi,{shadow:t.boxShadow,disabled:r,onChange:g=>{a({...t,boxShadow:g})}}):null]})]}):null,e==="advanced"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesTabAdvanced")}),o.jsx(Sx,{value:t.opacity,disabled:r,onChange:g=>{a({...t,opacity:g})}}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:m,children:l("imagePropertiesFit")}),o.jsxs("select",{id:m,className:d.select,value:t.objectFit??"",disabled:r,onChange:g=>{const S=g.target.value;a(Zp({...t,objectFit:S||null},n))},children:[o.jsx("option",{value:"",children:l("imagePropertiesFitDefault")}),dc.map(g=>o.jsx("option",{value:g,children:l(gx[g])},g))]})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:p,children:l("imagePropertiesPosition")}),o.jsxs("select",{id:p,className:d.select,value:t.objectPosition??"",disabled:r,onChange:g=>{const S=g.target.value||null;a({...t,objectPosition:S})},children:[o.jsx("option",{value:"",children:l("imagePropertiesPositionDefault")}),mc.map(g=>o.jsx("option",{value:g,children:l(bx[g])},g))]})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:b,children:l("imagePropertiesRotation")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:b,className:d.lengthInput,value:t.rotateDeg===null?"":J(t.rotateDeg),disabled:r,inputMode:"decimal",onChange:g=>{const S=g.target.value.trim();if(!S){a({...t,rotateDeg:null});return}const A=Number(S.replace(",","."));Number.isFinite(A)&&a({...t,rotateDeg:A})}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:l("imagePropertiesRotationUnit")})]})]})]}):null,e==="hover"?o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:l("imagePropertiesTabHover")}),o.jsx("p",{className:d.emptyHint,children:l("imagePropertiesHoverHelp")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:h,children:l("imagePropertiesHoverCss")}),o.jsx("textarea",{id:h,className:d.textarea,value:t.hoverCss,disabled:r,spellCheck:!1,"aria-label":l("imagePropertiesHoverCssAria"),onChange:g=>{a({...t,hoverCss:g.target.value})}})]})]}):null]})]})}function Sx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=e===null?null:Cr(e),[l,c]=s.useState(()=>a===null?"":J(a)),[m,p]=s.useState(!1);s.useEffect(()=>{m||c(a===null?"":J(a))},[a,m]);const b=h=>{const w=h.trim();if(!w){n(null),c("");return}const y=Number(w.replace(",","."));if(!Number.isFinite(y)){c(a===null?"":J(a));return}const v=Us(y);n(v),c(J(Cr(v)))};return o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("paragraphDialogOpacity")}),o.jsxs("div",{className:d.lengthRow,children:[o.jsx("input",{id:i,className:d.lengthInput,value:l,disabled:t,inputMode:"decimal",onFocus:()=>p(!0),onChange:h=>c(h.target.value),onBlur:()=>{p(!1),b(l)}}),o.jsx("span",{className:d.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}const Ll='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Cx({open:e,tab:t,value:n,aspectRatio:r=1,disabled:i,onTabChange:a,onApply:l,onClose:c}){const m=V(),p=s.useId(),b=s.useRef(null),[h,w]=s.useState(n);return s.useEffect(()=>{e&&w(n)},[e,n]),s.useEffect(()=>{if(!e)return;const y=b.current,v=y==null?void 0:y.querySelector(Ll);v==null||v.focus();const x=k=>{if(k.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;k.preventDefault(),k.stopPropagation(),c();return}if(k.key!=="Tab"||!y)return;const g=[...y.querySelectorAll(Ll)];if(g.length===0)return;const S=g[0],A=g[g.length-1];k.shiftKey&&document.activeElement===S?(k.preventDefault(),A.focus()):!k.shiftKey&&document.activeElement===A&&(k.preventDefault(),S.focus())};return document.addEventListener("keydown",x,!0),()=>document.removeEventListener("keydown",x,!0)},[e,c]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:c,children:o.jsxs("div",{ref:b,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":p,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:p,children:m("imagePropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":m("imagePropertiesDialogCloseAria"),onClick:c,children:o.jsx(We,{})})]}),o.jsx(vx,{tab:t,value:h,aspectRatio:r,disabled:i,onTabChange:a,onChange:w}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:c,children:m("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:i,onClick:()=>l(h),children:m("fontDialogOk")})]})]})})}):null}const kx="_frame_bwkh8_1",Dx="_handle_bwkh8_9",Px="_handleEast_bwkh8_29",Ax="_handleSouth_bwkh8_37",jx="_handleSouthEast_bwkh8_45",xn={frame:kx,handle:Dx,handleEast:Px,handleSouth:Ax,handleSouthEast:jx};function pn(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const Ex=[{handle:"e",className:xn.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:xn.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:xn.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function Wo(e){return!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)?null:{x:e.clientX,y:e.clientY}}function Tx({img:e,onResize:t,onResizeEnd:n}){const r=V(),i=s.useRef(null),a=s.useRef(e),l=s.useRef(t),c=s.useRef(n),m=s.useRef(null);a.current=e,l.current=t,c.current=n;const p=g=>{const S=i.current;S&&(S.style.left=`${g.left}px`,S.style.top=`${g.top}px`,S.style.width=`${g.width}px`,S.style.height=`${g.height}px`)};s.useLayoutEffect(()=>{p(pn(e));const g=()=>{e.isConnected&&p(pn(e))};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[e]);const b=(g,S)=>{const A=m.current,N=a.current;if(!A||!N)return;const E=gh(A.handle,A.start,{x:g-A.originX,y:S-A.originY});l.current(E.width,E.height),N.isConnected&&p(pn(N))},h=()=>{if(!m.current)return;m.current=null;const g=a.current;c.current(),g!=null&&g.isConnected&&p(pn(g))};s.useLayoutEffect(()=>{const g=A=>{if(!m.current)return;const N=Wo(A);N&&b(N.x,N.y)},S=()=>{h()};return document.addEventListener("pointermove",g),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),document.addEventListener("mousemove",g),document.addEventListener("mouseup",S),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",S),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",S)}},[]);const w=(g,S)=>{const A=Wo(S);A&&(m.current={handle:g,start:bh(a.current),originX:A.x,originY:A.y})},y=g=>S=>{S.preventDefault(),S.stopPropagation(),w(g,S);try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}},v=g=>S=>{S.preventDefault(),S.stopPropagation(),w(g,S)},x=g=>{const S=Wo(g);S&&b(S.x,S.y)};if(!e.isConnected)return null;const k=pn(e);return Ul.createPortal(o.jsx("div",{ref:i,className:xn.frame,"data-image-resize-overlay":"",style:{left:k.left,top:k.top,width:k.width,height:k.height},children:Ex.map(g=>o.jsx("button",{type:"button",className:`${xn.handle} ${g.className}`,style:{cursor:g.cursor},"aria-label":r(g.ariaKey),"data-resize-handle":g.handle,onPointerDown:y(g.handle),onPointerMove:x,onPointerUp:h,onPointerCancel:h,onMouseDown:v(g.handle),onMouseMove:x,onMouseUp:h},g.handle))}),document.body)}const Ml='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Nx({open:e,tab:t,href:n,title:r,targetBlank:i,textDecorationNone:a,hoverMode:l,hoverColor:c,hoverHtml:m,bookmarks:p,selectedBookmarkId:b,disabled:h,onTabChange:w,onApply:y,onClose:v}){const x=V(),k=s.useId(),g=s.useId(),S=s.useId(),A=s.useId(),N=s.useId(),E=s.useRef(null),[L,M]=s.useState(n),[I,j]=s.useState(r),[T,P]=s.useState(i),[R,W]=s.useState(a),[O,Z]=s.useState(l),[te,ce]=s.useState(c),[re,he]=s.useState(m),[ne,Q]=s.useState(b);if(s.useEffect(()=>{e&&(M(n),j(r),P(i),W(a),Z(l),ce(c),he(m),Q(b))},[e,n,r,i,a,l,c,m,b]),s.useEffect(()=>{if(!e)return;const B=E.current,fe=B==null?void 0:B.querySelector(Ml);fe==null||fe.focus();const ue=we=>{if(we.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;we.preventDefault(),we.stopPropagation(),v();return}if(we.key!=="Tab"||!B)return;const _=[...B.querySelectorAll(Ml)];if(_.length===0)return;const Ce=_[0],Pt=_[_.length-1];we.shiftKey&&document.activeElement===Ce?(we.preventDefault(),Pt.focus()):!we.shiftKey&&document.activeElement===Pt&&(we.preventDefault(),Ce.focus())};return document.addEventListener("keydown",ue,!0),()=>document.removeEventListener("keydown",ue,!0)},[e,v,t,O]),!e)return null;const D=()=>Mr({title:I,targetBlank:T,textDecorationNone:R,hoverMode:O,hoverColor:te,hoverHtml:re}),$=()=>{const B=L.trim();!B||h||y({...D(),href:B})},Y=()=>{!ne||h||y({...D(),href:`#${ne}`})};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:v,children:o.jsxs("div",{ref:E,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":k,onMouseDown:B=>B.stopPropagation(),children:[o.jsx("h2",{className:d.header,id:k,children:x("linkDialogTitle")}),o.jsxs("div",{className:d.tabs,role:"tablist","aria-label":x("linkDialogTitle"),children:[o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="link",onClick:()=>w("link"),children:x("linkDialogTabLink")}),o.jsx("button",{type:"button",className:d.tab,role:"tab","aria-selected":t==="bookmark",onClick:()=>w("bookmark"),children:x("linkDialogTabBookmark")})]}),o.jsxs("div",{className:d.body,role:"tabpanel",children:[t==="link"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:g,children:x("linkDialogHref")}),o.jsx("input",{id:g,className:d.textInput,value:L,disabled:h,onChange:B=>M(B.target.value)})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:S,children:x("linkDialogHoverTitle")}),o.jsx("input",{id:S,className:d.textInput,value:I,disabled:h,onChange:B=>j(B.target.value)})]}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:T,disabled:h,onChange:B=>P(B.target.checked)}),x("linkDialogTargetBlank")]})]}):p.length===0?o.jsx("p",{className:d.emptyHint,children:x("linkDialogBookmarkEmpty")}):o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:A,children:x("linkDialogBookmark")}),o.jsxs("select",{id:A,className:`${d.select} ${d.fullSelect}`,value:ne,disabled:h,onChange:B=>Q(B.target.value),children:[o.jsx("option",{value:""}),p.map(B=>o.jsx("option",{value:B.id,children:B.id},B.id))]})]}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:R,disabled:h,onChange:B=>W(B.target.checked)}),x("linkDialogTextDecorationNone")]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.subLabel,children:x("linkDialogHover")}),o.jsxs("div",{className:d.sizeRow,role:"group","aria-label":x("linkDialogHover"),children:[o.jsx("button",{type:"button",className:d.action,"aria-pressed":O==="color",disabled:h,onClick:()=>Z("color"),children:x("linkDialogHoverColor")}),o.jsx("button",{type:"button",className:d.action,"aria-pressed":O==="html",disabled:h,onClick:()=>Z("html"),children:x("linkDialogHoverHtml")})]}),O==="color"?o.jsx(Fe,{label:x("linkDialogHoverColorField"),noneLabel:x("colorNone"),value:te,disabled:h,onChange:ce}):o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:N,children:x("linkDialogHoverHtmlAria")}),o.jsx("textarea",{id:N,className:d.textarea,value:re,disabled:h,spellCheck:!1,onChange:B=>he(B.target.value)})]})]})]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,disabled:h||!ne,onClick:Y,children:x("linkDialogSelect")}),o.jsx("button",{type:"button",className:d.action,onClick:v,children:x("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:h||!L.trim(),onClick:$,children:x("fontDialogOk")})]})]})})})}const Lx="_grid_1bpma_1",Mx="_cell_1bpma_8",Rx="_sizeLabel_1bpma_27",_x="_sizeFields_1bpma_33",Ix="_numberInput_1bpma_37",Lt={grid:Lx,cell:Mx,sizeLabel:Rx,sizeFields:_x,numberInput:Ix},Rl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled])',st={rows:3,cols:3};function Fx({open:e,disabled:t,onApply:n,onClose:r}){const i=V(),a=s.useId(),l=s.useId(),c=s.useId(),m=s.useRef(null),[p,b]=s.useState(st.rows),[h,w]=s.useState(st.cols),[y,v]=s.useState(String(st.rows)),[x,k]=s.useState(String(st.cols)),[g,S]=s.useState(!1);if(s.useEffect(()=>{e&&(b(st.rows),w(st.cols),v(String(st.rows)),k(String(st.cols)),S(!1))},[e]),s.useEffect(()=>{if(!e)return;const j=m.current,T=j==null?void 0:j.querySelector(Rl);T==null||T.focus();const P=R=>{if(R.key==="Escape"){R.preventDefault(),R.stopPropagation(),r();return}if(R.key!=="Tab"||!j)return;const W=[...j.querySelectorAll(Rl)];if(W.length===0)return;const O=W[0],Z=W[W.length-1];R.shiftKey&&document.activeElement===O?(R.preventDefault(),Z.focus()):!R.shiftKey&&document.activeElement===Z&&(R.preventDefault(),O.focus())};return document.addEventListener("keydown",P,!0),()=>document.removeEventListener("keydown",P,!0)},[e,r]),!e)return null;const N=yc(p,h)&&!t,E=(j,T)=>{const P=Math.min(It,Math.max(_t,j)),R=Math.min(It,Math.max(_t,T));b(P),w(R),v(String(P)),k(String(R))},L=(j,T)=>{const P=Number.parseInt(j,10);if(!Number.isFinite(P)){T==="rows"?v(String(p)):k(String(h));return}S(!0),T==="rows"?E(P,h):E(p,P)},M=(j,T)=>{const P=j.replace(/\D/g,"");if(T==="rows"?v(P):k(P),P==="")return;const R=Number.parseInt(P,10);Number.isFinite(R)&&(S(!0),T==="rows"?E(R,h):E(p,R))},I=j=>{(j.key==="e"||j.key==="E"||j.key==="+"||j.key==="-"||j.key===".")&&j.preventDefault()};return o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:r,children:o.jsxs("div",{ref:m,className:d.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:j=>j.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:a,children:i("tableDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":i("tableDialogCloseAria"),onClick:r,children:o.jsx(We,{})})]}),o.jsxs("div",{className:d.body,children:[o.jsx("div",{className:Lt.grid,role:"grid","aria-label":i("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:pl},(j,T)=>Array.from({length:pl},(P,R)=>{const W=T+1,O=R+1,Z=W<=p&&O<=h;return o.jsx("button",{type:"button",className:Lt.cell,role:"gridcell","data-active":Z?"true":void 0,"aria-label":`${W} × ${O}`,"aria-pressed":Z&&W===p&&O===h,disabled:t,onMouseEnter:()=>{g||E(W,O)},onClick:()=>{S(!0),E(W,O)}},`${W}-${O}`)}))}),o.jsxs("p",{className:Lt.sizeLabel,children:[i("tableDialogSize"),": ",p," × ",h]}),o.jsxs("div",{className:`${d.sizeRow} ${Lt.sizeFields}`,children:[o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:l,children:i("tableDialogRows")}),o.jsx("input",{id:l,className:Lt.numberInput,type:"number",inputMode:"numeric",min:_t,max:It,step:1,value:y,disabled:t,onKeyDown:I,onChange:j=>M(j.target.value,"rows"),onBlur:()=>L(y,"rows")})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:c,children:i("tableDialogColumns")}),o.jsx("input",{id:c,className:Lt.numberInput,type:"number",inputMode:"numeric",min:_t,max:It,step:1,value:x,disabled:t,onKeyDown:I,onChange:j=>M(j.target.value,"cols"),onBlur:()=>L(x,"cols")})]})]})]}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:r,children:i("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:!N,onClick:()=>{N&&n({rows:p,cols:h})},children:i("tableDialogInsert")})]})]})})})}const Bx={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Hx={value:1,unit:"pt"},zx={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 Ox({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),a=s.useId();return o.jsxs("div",{className:d.body,children:[o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("tablePropertiesWidth")}),o.jsx(ge,{label:r("tablePropertiesWidth"),value:e.width,disabled:t,onChange:l=>n({...e,width:l})}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("tablePropertiesCollapse")}),o.jsxs("select",{id:i,className:d.select,value:e.borderCollapse,disabled:t,onChange:l=>{const c=l.target.value==="separate"?"separate":"collapse";n({...e,borderCollapse:c,borderSpacing:c==="separate"?e.borderSpacing:null})},children:[o.jsx("option",{value:"collapse",children:r("tablePropertiesCollapseCollapse")}),o.jsx("option",{value:"separate",children:r("tablePropertiesCollapseSeparate")})]})]}),e.borderCollapse==="separate"?o.jsx(ge,{label:r("tablePropertiesSpacing"),value:e.borderSpacing,disabled:t,onChange:l=>n({...e,borderSpacing:l})}):null]}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogBorder")}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:a,children:r("paragraphDialogBorderStyle")}),o.jsx("select",{id:a,className:d.select,value:e.border.style,disabled:t,onChange:l=>{const c=l.target.value;n({...e,border:{style:c,width:c==="none"?null:e.border.width??Hx,color:c==="none"?null:e.border.color}})},children:Lr.map(l=>o.jsx("option",{value:l,children:r(Bx[l])},l))})]}),e.border.style!=="none"?o.jsxs(o.Fragment,{children:[o.jsx(ge,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:l=>n({...e,border:{...e.border,width:l}})}),o.jsx(Fe,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:l=>n({...e,border:{...e.border,color:l}})})]}):null,o.jsx(ge,{label:r("paragraphDialogBorderRadius"),value:e.borderRadius,disabled:t,onChange:l=>n({...e,borderRadius:l})}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:e.boxShadow!==null,disabled:t,onChange:()=>{n({...e,boxShadow:e.boxShadow?null:zx})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?o.jsx(Vi,{shadow:e.boxShadow,disabled:t,onChange:l=>n({...e,boxShadow:l})}):null]})]})}const _l='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Kx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(_l);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(_l)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("tablePropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("tablePropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Ox,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const $x={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Ux={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function ur(e){return{top:e,right:e,bottom:e,left:e}}function Go(e){for(const t of Xe)if(e[t])return e[t];return null}function Wx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),[a,l]=s.useState(()=>nt(e.padding,ur(Go(e.padding))));return s.useEffect(()=>{l(nt(e.padding,ur(Go(e.padding))))},[e.padding]),o.jsxs("div",{className:d.body,children:[o.jsx(Fe,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:c=>n({...e,backgroundColor:c})}),o.jsx(Fe,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:c=>n({...e,color:c})}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogPadding")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const c=!a;l(c),c&&n({...e,padding:ur(Go(e.padding))})}}),r("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(a?["top"]:Xe).map(c=>o.jsx(ge,{label:r(a?"paragraphDialogPadding":$x[c]),value:e.padding[c],disabled:t,onChange:m=>{const p=a?ur(m):{...e.padding,[c]:m};n({...e,padding:p})}},c))})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("cellPropertiesVerticalAlign")}),o.jsxs("select",{id:i,className:d.select,value:e.verticalAlign??"",disabled:t,onChange:c=>{const m=c.target.value;n({...e,verticalAlign:m||null})},children:[o.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),Rr.map(c=>o.jsx("option",{value:c,children:r(Ux[c])},c))]})]}),o.jsx(ge,{label:r("cellPropertiesWidth"),value:e.width,disabled:t,onChange:c=>n({...e,width:c})})]})}const Il='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Gx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(Il);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(Il)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("cellPropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("cellPropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Wx,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const Vx={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},qx={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function dr(e){return{top:e,right:e,bottom:e,left:e}}function Vo(e){for(const t of Xe)if(e[t])return e[t];return null}function Xx({value:e,disabled:t,onChange:n}){const r=V(),i=s.useId(),[a,l]=s.useState(()=>nt(e.padding,dr(Vo(e.padding))));return s.useEffect(()=>{l(nt(e.padding,dr(Vo(e.padding))))},[e.padding]),o.jsxs("div",{className:d.body,children:[o.jsx(Fe,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:c=>n({...e,backgroundColor:c})}),o.jsx(Fe,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:c=>n({...e,color:c})}),o.jsxs("fieldset",{className:d.group,children:[o.jsx("legend",{className:d.label,children:r("paragraphDialogPadding")}),o.jsxs("label",{className:d.mark,children:[o.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const c=!a;l(c),c&&n({...e,padding:dr(Vo(e.padding))})}}),r("paragraphDialogLinkSides")]}),o.jsx("div",{className:d.sideGrid,children:(a?["top"]:Xe).map(c=>o.jsx(ge,{label:r(a?"paragraphDialogPadding":Vx[c]),value:e.padding[c],disabled:t,onChange:m=>{const p=a?dr(m):{...e.padding,[c]:m};n({...e,padding:p})}},c))})]}),o.jsxs("div",{className:d.field,children:[o.jsx("label",{className:d.label,htmlFor:i,children:r("cellPropertiesVerticalAlign")}),o.jsxs("select",{id:i,className:d.select,value:e.verticalAlign??"",disabled:t,onChange:c=>{const m=c.target.value;n({...e,verticalAlign:m||null})},children:[o.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),Rr.map(c=>o.jsx("option",{value:c,children:r(qx[c])},c))]})]}),o.jsx(ge,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:c=>n({...e,height:c})})]})}const Fl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])';function Yx({open:e,value:t,disabled:n,onApply:r,onClose:i}){const a=V(),l=s.useId(),c=s.useRef(null),[m,p]=s.useState(t);return s.useEffect(()=>{e&&p(t)},[e,t]),s.useEffect(()=>{if(!e)return;const b=c.current,h=b==null?void 0:b.querySelector(Fl);h==null||h.focus();const w=y=>{if(y.key==="Escape"){if(document.querySelector('[role="listbox"], [data-color-picker]'))return;y.preventDefault(),y.stopPropagation(),i();return}if(y.key!=="Tab"||!b)return;const v=[...b.querySelectorAll(Fl)];if(v.length===0)return;const x=v[0],k=v[v.length-1];y.shiftKey&&document.activeElement===x?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),x.focus())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[e,i]),e?o.jsx(ie,{children:o.jsx("div",{className:d.backdrop,role:"presentation",onMouseDown:i,children:o.jsxs("div",{ref:c,className:`${d.dialog} ${d.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":l,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:d.headerRow,children:[o.jsx("h2",{className:d.header,id:l,children:a("rowPropertiesDialogTitle")}),o.jsx("button",{type:"button",className:d.close,"aria-label":a("rowPropertiesDialogCloseAria"),onClick:i,children:o.jsx(We,{})})]}),o.jsx(Xx,{value:m,disabled:n,onChange:p}),o.jsxs("div",{className:d.actions,children:[o.jsx("button",{type:"button",className:d.action,onClick:i,children:a("fontDialogCancel")}),o.jsx("button",{type:"button",className:`${d.action} ${d.actionPrimary}`,disabled:n,onClick:()=>r(m),children:a("fontDialogOk")})]})]})})}):null}const Jx="_backdrop_9d3gw_1",Zx="_dialog_9d3gw_12",Qx="_headerRow_9d3gw_29",e1="_header_9d3gw_29",t1="_close_9d3gw_44",n1="_body_9d3gw_66",r1="_frame_9d3gw_75",o1="_actions_9d3gw_83",i1="_action_9d3gw_83",Je={backdrop:Jx,dialog:Zx,headerRow:Qx,header:e1,close:t1,body:n1,frame:r1,actions:o1,action:i1},Bl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function a1({open:e,html:t,onClose:n}){const r=V(),i=s.useId(),a=s.useRef(null),l=s.useRef(null);return s.useEffect(()=>{if(!e)return;const c=a.current,m=c==null?void 0:c.querySelector(Bl);m==null||m.focus();const p=b=>{if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),n();return}if(b.key!=="Tab"||!c)return;const h=[...c.querySelectorAll(Bl)];if(h.length===0)return;const w=h[0],y=h[h.length-1];b.shiftKey&&document.activeElement===w?(b.preventDefault(),y.focus()):!b.shiftKey&&document.activeElement===y&&(b.preventDefault(),w.focus())};return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,n]),s.useEffect(()=>{var m;if(!e)return;const c=(m=l.current)==null?void 0:m.contentDocument;c&&Zo(c,t,r("previewDialogTitle"))},[e,t,r]),e?o.jsx(ie,{children:o.jsx("div",{className:Je.backdrop,role:"presentation",onMouseDown:n,children:o.jsxs("div",{ref:a,className:Je.dialog,role:"dialog","aria-modal":"true","aria-labelledby":i,onMouseDown:c=>c.stopPropagation(),children:[o.jsxs("div",{className:Je.headerRow,children:[o.jsx("h2",{className:Je.header,id:i,children:r("previewDialogTitle")}),o.jsx("button",{type:"button",className:Je.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:o.jsx(We,{})})]}),o.jsx("div",{className:Je.body,children:o.jsx("iframe",{ref:l,className:Je.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var m;const c=(m=l.current)==null?void 0:m.contentDocument;c&&Zo(c,t,r("previewDialogTitle"))}})}),o.jsx("div",{className:Je.actions,children:o.jsx("button",{type:"button",className:Je.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const Tc="commspliant-html-editor.darkMode";function l1(e){return typeof e=="boolean"?e:null}function Hl(){try{const e=localStorage.getItem(Tc);return e?l1(JSON.parse(e)):null}catch{return null}}function s1(e){try{localStorage.setItem(Tc,JSON.stringify(e))}catch{}}const Nc="commspliant-html-editor.toolbarPosition",c1=["top","left","right","bottom"];function Lc(e){return typeof e=="string"&&c1.includes(e)?e:null}function zl(){try{const e=localStorage.getItem(Nc);return e?Lc(JSON.parse(e)):null}catch{return null}}function u1(e){try{localStorage.setItem(Nc,JSON.stringify(e))}catch{}}function d1({enabled:e,onHtml:t}){const[n,r]=s.useState(!1),i=s.useRef(0),a=s.useRef(e),l=s.useRef(t);a.current=e,l.current=t;const c=s.useCallback(()=>{i.current=0,r(!1)},[]);s.useEffect(()=>{e||c()},[e,c]);const m=s.useCallback(w=>{!a.current||!rr(w.dataTransfer)||(w.preventDefault(),i.current+=1,r(!0))},[]),p=s.useCallback(w=>{!a.current||!rr(w.dataTransfer)||(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy"))},[]),b=s.useCallback(w=>{if(!a.current||!rr(w.dataTransfer))return;const y=w.relatedTarget;y instanceof Node&&w.currentTarget.contains(y)||(i.current=Math.max(0,i.current-1),i.current===0&&r(!1))},[]),h=s.useCallback(w=>{if(!a.current||!rr(w.dataTransfer))return;w.preventDefault(),c();const y=rd(w.dataTransfer);y&&wi(y).then(v=>{a.current&&l.current(v)},()=>{})},[c]);return{dragging:n,onDragEnter:m,onDragOver:p,onDragLeave:b,onDrop:h}}const m1={menus:{edit:{id:"edit",labelKey:"menuEdit",ariaKey:"menuEditAria"}},groups:{edit:{id:"edit",labelKey:"toolbarGroupEdit"}},items:{undo:{id:"undo",command:"undo",icon:Eu,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:ku,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"}}},f1=400;function p1(e){let t=[],n=e,r=[],i=!1,a=!1,l=0;function c(h,w){if(i){n=h,i=!1;return}if(h===n)return;const y=Date.now(),v=(w==null?void 0:w.coalesce)===!0;if(v&&a&&y-l<f1){n=h,l=y;return}t.push(n),n=h,r=[],l=y,a=v}function m(){return t.length===0?null:(a=!1,r.push(n),n=t.pop(),n)}function p(){return r.length===0?null:(a=!1,t.push(n),n=r.pop(),n)}function b(h){if(i){n=h,i=!1;return}h!==n&&(t.push(n),n=h,r=[],a=!1)}return{record:c,undo:m,redo:p,canUndo:()=>t.length>0,canRedo:()=>r.length>0,syncExternal:b,markApplying:()=>{i=!0}}}function ft(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function Dr(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):ft(e,t):""}const Ge="fullscreen",di="commspliant-html-editor.toolbarCustomization";function mi(e){const t=e.filter(n=>n!==Ge);return e.includes(Ge)?[...t,Ge]:t}function Xi(e,t){if(!t||t.length===0)return mi(e);const n=new Set(e),r=t.filter(l=>n.has(l)),i=new Set(r),a=[...r];for(let l=0;l<e.length;l++){const c=e[l];if(i.has(c))continue;let m=0;for(let p=l-1;p>=0;p--){const b=e[p],h=a.indexOf(b);if(h>=0){m=h+1;break}}a.splice(m,0,c),i.add(c)}return mi(a)}function h1(e,t){const n=new Map(e.map(l=>[l.id,l])),r=Xi(e.map(l=>l.id),t==null?void 0:t.groupOrder),i=new Set((t==null?void 0:t.hiddenItemIds)??[]),a=[];for(const l of r){const c=n.get(l);if(!c)continue;const m=c.items.filter(p=>!i.has(p));m.length!==0&&a.push({id:l,items:m})}return a}function g1(e){if(e==null||typeof e!="object")return null;const t=e,n=Array.isArray(t.groupOrder)?t.groupOrder.filter(i=>typeof i=="string"):[],r=Array.isArray(t.hiddenItemIds)?[...new Set(t.hiddenItemIds.filter(i=>typeof i=="string"))]:[];return n.length===0&&r.length===0?null:{groupOrder:n,hiddenItemIds:r}}function b1(){try{const e=localStorage.getItem(di);return e?g1(JSON.parse(e)):null}catch{return null}}function y1(e){try{if(!e){localStorage.removeItem(di);return}localStorage.setItem(di,JSON.stringify(e))}catch{}}function Yi(e,t){return Xi(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function x1(e,t,n,r){const i=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?i.delete(n):i.add(n),{groupOrder:Yi(e,t),hiddenItemIds:[...i]}}function Mc(e,t,n,r){const i=Yi(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===Ge||r===Ge)return{groupOrder:i,hiddenItemIds:a};const l=i.indexOf(n),c=i.indexOf(r);if(l<0||c<0||l===c)return{groupOrder:i,hiddenItemIds:a};const m=[...i],[p]=m.splice(l,1);return m.splice(c,0,p),{groupOrder:mi(m),hiddenItemIds:a}}function Ol(e,t,n,r){const i=Yi(e,t),a=i.filter(m=>m!==Ge),l=a.indexOf(n),c=l+r;return l<0||c<0||c>=a.length?{groupOrder:i,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:Mc(e,t,n,a[c])}const w1="_backdrop_1dasl_1",v1="_dialog_1dasl_12",S1="_header_1dasl_28",C1="_body_1dasl_35",k1="_group_1dasl_43",D1="_groupDragging_1dasl_49",P1="_groupDropTarget_1dasl_53",A1="_groupHeader_1dasl_58",j1="_groupTitle_1dasl_66",E1="_dragHandle_1dasl_71",T1="_moveButton_1dasl_72",N1="_items_1dasl_113",L1="_item_1dasl_113",M1="_itemIcon_1dasl_129",R1="_itemTitle_1dasl_138",_1="_itemCheckbox_1dasl_145",I1="_actions_1dasl_149",F1="_action_1dasl_149",B1="_spinnerWrap_1dasl_184",H1="_spinner_1dasl_184",le={backdrop:w1,dialog:v1,header:S1,body:C1,group:k1,groupDragging:D1,groupDropTarget:P1,groupHeader:A1,groupTitle:j1,dragHandle:E1,moveButton:T1,items:N1,item:L1,itemIcon:M1,itemTitle:R1,itemCheckbox:_1,actions:I1,action:F1,spinnerWrap:B1,spinner:H1},Kl='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])';function z1(){return o.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",fill:"currentColor",children:[o.jsx("circle",{cx:"5",cy:"4",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"4",r:"1.2"}),o.jsx("circle",{cx:"5",cy:"8",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"8",r:"1.2"}),o.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),o.jsx("circle",{cx:"11",cy:"12",r:"1.2"})]})}function O1({open:e,catalog:t,groups:n,settings:r,loading:i=!1,busy:a=!1,disabled:l,onChange:c,onReset:m,onClose:p}){const b=V(),h=s.useId(),w=s.useRef(null),[y,v]=s.useState(null),[x,k]=s.useState(null),g=Xi(n.map(P=>P.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),A=new Map(n.map(P=>[P.id,P])),N=g.map(P=>A.get(P)).filter(P=>!!P),E=l||a||i;if(s.useEffect(()=>{e||(v(null),k(null))},[e]),s.useEffect(()=>{if(!e)return;const P=w.current,R=P==null?void 0:P.querySelector(Kl);R==null||R.focus();const W=O=>{if(O.key==="Escape"){O.preventDefault(),O.stopPropagation(),p();return}if(O.key!=="Tab"||!P)return;const Z=[...P.querySelectorAll(Kl)];if(Z.length===0)return;const te=Z[0],ce=Z[Z.length-1];O.shiftKey&&document.activeElement===te?(O.preventDefault(),ce.focus()):!O.shiftKey&&document.activeElement===ce&&(O.preventDefault(),te.focus())};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[e,p]),!e)return null;const L=N.map(P=>P.id).filter(P=>P!==Ge),M=(P,R)=>{if(E||R===Ge){P.preventDefault();return}P.dataTransfer.setData("text/plain",R),P.dataTransfer.effectAllowed="move",v(R)},I=(P,R)=>{E||R===Ge||!y||y===R||(P.preventDefault(),P.dataTransfer&&(P.dataTransfer.dropEffect="move"),k(R))},j=(P,R)=>{var O;P.preventDefault();const W=((O=P.dataTransfer)==null?void 0:O.getData("text/plain"))||y;v(null),k(null),!(!W||W===R||E)&&c(Mc(r,n,W,R))},T=()=>{v(null),k(null)};return o.jsx(ie,{children:o.jsx("div",{className:le.backdrop,role:"presentation",onMouseDown:p,children:o.jsxs("div",{ref:w,className:le.dialog,role:"dialog","aria-modal":"true","aria-labelledby":h,"aria-busy":i||a?!0:void 0,onMouseDown:P=>P.stopPropagation(),children:[o.jsx("h2",{className:le.header,id:h,children:b("customizeToolbarDialogTitle")}),o.jsx("div",{className:le.body,children:i?o.jsx("div",{className:le.spinnerWrap,role:"status","aria-live":"polite","aria-label":b("customizeToolbarDialogLoading"),children:o.jsx("span",{className:le.spinner,"aria-hidden":"true"})}):N.map(P=>{const R=t.groups[P.id],W=R?ft(b,R):P.id,O=P.id===Ge,Z=L.indexOf(P.id);return o.jsxs("section",{className:[le.group,y===P.id?le.groupDragging:"",x===P.id?le.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":P.id,"aria-label":W,onDragOver:te=>I(te,P.id),onDrop:te=>j(te,P.id),onDragLeave:()=>{x===P.id&&k(null)},children:[o.jsxs("div",{className:le.groupHeader,children:[o.jsx("button",{type:"button",className:le.dragHandle,draggable:!E&&!O,disabled:E||O,"aria-label":b("customizeToolbarDragHandle"),onDragStart:te=>M(te,P.id),onDragEnd:T,children:o.jsx(z1,{})}),o.jsx("span",{className:le.groupTitle,children:W}),o.jsx("button",{type:"button",className:le.moveButton,disabled:E||O||Z<=0,"aria-label":b("customizeToolbarMoveUp"),onClick:()=>c(Ol(r,n,P.id,-1)),children:"↑"}),o.jsx("button",{type:"button",className:le.moveButton,disabled:E||O||Z<0||Z>=L.length-1,"aria-label":b("customizeToolbarMoveDown"),onClick:()=>c(Ol(r,n,P.id,1)),children:"↓"})]}),o.jsx("div",{className:le.items,children:P.items.map(te=>{const ce=t.items[te];if(!ce)return null;const re=ce.icon,he=ft(b,ce),ne=`${h}-${P.id}-${te}`,Q=!S.has(te);return o.jsxs("label",{className:le.item,htmlFor:ne,children:[o.jsx("span",{className:le.itemIcon,"aria-hidden":"true",children:re?o.jsx(re,{}):he.slice(0,2)}),o.jsx("span",{className:le.itemTitle,children:he}),o.jsx("input",{id:ne,className:le.itemCheckbox,type:"checkbox",checked:Q,disabled:E,"aria-label":`${he}: ${b("customizeToolbarItemVisible")}`,onChange:D=>c(x1(r,n,te,D.target.checked))})]},te)})})]},P.id)})}),o.jsxs("div",{className:le.actions,children:[o.jsx("button",{type:"button",className:le.action,disabled:E,onClick:m,children:b("customizeToolbarDialogReset")}),o.jsx("button",{type:"button",className:le.action,"aria-label":b("customizeToolbarDialogCloseAria"),onClick:p,children:b("customizeToolbarDialogClose")})]})]})})})}function K1(e,t){if(!t)return e;const n=t.menus,r=t.toolbar;if(n===void 0&&r===void 0)return e;const i=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(c=>r.includes(c))})).filter(l=>l.items.length>0);return{menus:i,iconGroups:a}}const $1={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:Pu,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:gu,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:Cu,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},mr=4;function Rc({icon:e,value:t,mixed:n,noneKey:r,labelKey:i,ariaKey:a,fallbackCustom:l,disabled:c,onChange:m}){const p=V(),b=s.useId(),h=s.useRef(null),w=s.useRef(null),y=s.useRef(null),[v,x]=s.useState(!1),[k,g]=s.useState({top:0,left:0}),S=s.useCallback(()=>{const M=w.current,I=y.current;if(!M)return;const j=M.getBoundingClientRect(),T=(I==null?void 0:I.offsetHeight)??0,P=(I==null?void 0:I.offsetWidth)??200;let R=j.bottom;R+T>window.innerHeight-mr&&(R=Math.max(mr,j.top-T));const W=Math.min(Math.max(j.left,mr),window.innerWidth-P-mr);g({top:R,left:W})},[]);s.useLayoutEffect(()=>{if(!v)return;S();const M=()=>S();return window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),()=>{window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[v,S]),s.useEffect(()=>{if(!v)return;const M=j=>{var P,R;const T=j.target;(P=h.current)!=null&&P.contains(T)||(R=y.current)!=null&&R.contains(T)||x(!1)},I=j=>{var T;j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),x(!1),(T=w.current)==null||T.focus())};return document.addEventListener("pointerdown",M),document.addEventListener("keydown",I,!0),()=>{document.removeEventListener("pointerdown",M),document.removeEventListener("keydown",I,!0)}},[v]);const A=M=>{m(M)},N=`${St.bar}${!t||n?` ${St.barEmpty}`:""}`,E=t&&!n?{backgroundColor:t}:void 0,L=o.jsxs("div",{className:St.wrap,ref:h,children:[o.jsxs("button",{ref:w,type:"button",className:`${X.iconButton} ${St.button}`,"aria-label":p(a),"aria-expanded":v,"aria-haspopup":"listbox","aria-controls":v?b:void 0,disabled:c,onMouseDown:M=>M.preventDefault(),onClick:()=>x(M=>!M),children:[o.jsx(e,{className:`${X.icon} ${St.icon}`}),o.jsx("span",{className:N,style:E})]}),v?o.jsx(ie,{children:o.jsx("div",{ref:y,id:b,className:St.popover,style:{top:k.top,left:k.left},children:o.jsx(Wi,{value:t,mixed:n,noneLabel:p(r),ariaLabel:p(a),disabled:c,fallbackCustom:l,onChange:A,onCommit:()=>x(!1)})})}):null]});return o.jsx(mt,{label:p(i),children:L})}function U1({commands:e,queries:t,disabled:n}){return o.jsx(Rc,{icon:Vl,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}function W1({commands:e,queries:t,disabled:n}){const r=V(),i=!!(n||!t.isVisualMode());return o.jsx(Ec,{size:t.getFontSize(),unit:t.getFontSizeUnit(),disabled:i,tooltip:r("commandFontSize"),toolbar:!0,onSizeChange:(a,l)=>{e.setFontSize(a,l)},onUnitChange:a=>{e.setFontSizeUnit(a)}})}function G1({commands:e,queries:t,disabled:n}){return o.jsx(Rc,{icon:ql,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function V1({commands:e,queries:t,disabled:n,onMenuClose:r}){const i=V(),a=!!(n||!t.isVisualMode());return o.jsx(Wi,{value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneLabel:i("colorNone"),ariaLabel:i("commandHighlightColorAria"),disabled:a,menu:!0,fallbackCustom:"#ffff00",onChange:l=>e.setHighlightColor(l),onCommit:()=>r==null?void 0:r()})}const q1="_wrap_2cawp_1",X1="_wrapToolbar_2cawp_7",Y1="_field_2cawp_12",J1="_trigger_2cawp_20",Z1="_chevron_2cawp_46",Q1="_list_2cawp_69",ew="_option_2cawp_84",tw="_separator_2cawp_113",Ze={wrap:q1,wrapToolbar:X1,field:Y1,trigger:J1,chevron:Z1,list:Q1,option:ew,separator:tw},fi={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},nw={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 $l(){const e=V();return o.jsx("div",{className:d.spinnerWrap,role:"status","aria-live":"polite","aria-label":e("customStyleLoading"),children:o.jsx("span",{className:d.spinner,"aria-hidden":"true"})})}function _c({value:e,mixed:t=!1,disabled:n,menu:r=!1,listId:i,listRef:a,style:l,customStylesEnabled:c=!1,customStyles:m=[],customStylesLoading:p=!1,onSelect:b,onSelectCustom:h,onAddNew:w}){const y=V(),v=t?null:e,x=c,k=!!(r&&c&&w);return r?o.jsxs(o.Fragment,{children:[vr.map(g=>o.jsx("button",{type:"button",className:X.menuItem,role:"menuitemradio","aria-checked":v===g,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>b(g),children:y(fi[g])},g)),x?o.jsx("div",{role:"separator",className:X.menuSeparator}):null,x&&p?o.jsx($l,{}):null,x&&!p?m.map(g=>o.jsx("button",{type:"button",className:X.menuItem,role:"menuitem",disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(g.id),children:g.name},g.id)):null,k?o.jsxs(o.Fragment,{children:[x&&(p||m.length>0)?o.jsx("div",{role:"separator",className:X.menuSeparator}):null,o.jsxs("button",{type:"button",className:X.menuItem,role:"menuitem","aria-label":y("styleAddNewAria"),disabled:n,onMouseDown:g=>g.preventDefault(),onClick:()=>w==null?void 0:w(),children:[o.jsx(Su,{className:X.icon}),y("styleAddNew")]})]}):null]}):o.jsxs("ul",{ref:a,className:Ze.list,role:"listbox",id:i,style:l,"aria-label":y("commandParagraphStyleAria"),"aria-busy":x&&p?!0:void 0,children:[vr.map(g=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":v===g,disabled:n,style:nw[g],onMouseDown:S=>S.preventDefault(),onClick:()=>b(g),children:y(fi[g])})},g)),x&&(p||m.length>0)?o.jsx("li",{role:"separator",className:Ze.separator}):null,x&&p?o.jsx("li",{role:"presentation",children:o.jsx($l,{})}):null,x&&!p?m.map(g=>o.jsx("li",{role:"presentation",children:o.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":!1,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(g.id),children:g.name})},g.id)):null]})}const fr=4;function rw({commands:e,queries:t,disabled:n}){const r=V(),i=s.useId(),a=s.useRef(null),l=s.useRef(null),c=s.useRef(null),[m,p]=s.useState(!1),[b,h]=s.useState({top:0,left:0,width:0}),w=!!(n||!t.isVisualMode()),y=t.isParagraphStyleMixed(),v=y?null:t.getParagraphStyle(),x=v?r(fi[v]):"",k=t.customParagraphStylesEnabled(),g=k?t.getCustomParagraphStyles():[],S=k&&t.isCustomParagraphStylesLoading(),A=s.useCallback(()=>{const E=l.current,L=c.current;if(!E)return;const M=E.getBoundingClientRect(),I=(L==null?void 0:L.offsetHeight)??0,j=Math.max(M.width,(L==null?void 0:L.offsetWidth)??0);let T=M.bottom;T+I>window.innerHeight-fr&&(T=Math.max(fr,M.top-I));const P=Math.min(Math.max(M.left,fr),window.innerWidth-j-fr);h({top:T,left:P,width:j})},[]);s.useLayoutEffect(()=>{if(!m)return;A();const E=()=>A();return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[m,A,g.length,S]),s.useEffect(()=>{if(!m)return;const E=M=>{var j,T;const I=M.target;(j=a.current)!=null&&j.contains(I)||(T=c.current)!=null&&T.contains(I)||p(!1)},L=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),p(!1))};return document.addEventListener("pointerdown",E),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",E),document.removeEventListener("keydown",L,!0)}},[m]);const N=o.jsxs("div",{className:`${Ze.wrap} ${Ze.wrapToolbar}`,ref:a,children:[o.jsxs("div",{className:Ze.field,ref:l,children:[o.jsx("button",{type:"button",className:Ze.trigger,disabled:w,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":m,"aria-controls":m?i:void 0,onMouseDown:E=>E.preventDefault(),onClick:()=>p(E=>!E),children:x}),o.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),m?o.jsx(ie,{children:o.jsx(_c,{listRef:c,listId:i,value:v,mixed:y,disabled:w,customStylesEnabled:k,customStyles:g,customStylesLoading:S,style:{top:b.top,left:b.left,minWidth:b.width},onSelect:E=>{e.setParagraphStyle(E),p(!1)},onSelectCustom:E=>{e.applyCustomParagraphStyle(E),p(!1)}})}):null]});return o.jsx(mt,{label:r("commandParagraphStyle"),children:N})}function ow({commands:e,queries:t,disabled:n,onMenuClose:r}){const i=!!(n||!t.isVisualMode()),a=t.isParagraphStyleMixed(),l=a?null:t.getParagraphStyle(),c=t.customParagraphStylesEnabled(),m=c?t.getCustomParagraphStyles():[],p=c&&t.isCustomParagraphStylesLoading();return o.jsx(_c,{menu:!0,value:l,mixed:a,disabled:i,customStylesEnabled:c,customStyles:m,customStylesLoading:p,onSelect:b=>{e.setParagraphStyle(b),r==null||r()},onSelectCustom:b=>{e.openCustomParagraphStyleDialog(b),r==null||r()},onAddNew:()=>{e.openCustomParagraphStyleDialog(),r==null||r()}})}const iw={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:ow,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:V1,enabled:"isVisualMode"},paragraph:{id:"paragraph",labelKey:"menuParagraph",ariaKey:"menuParagraphAria"},page:{id:"page",labelKey:"menuPage",ariaKey:"menuPageAria"}},groups:{font:{id:"font",labelKey:"toolbarGroupFont"},align:{id:"align",labelKey:"toolbarGroupAlign"},paragraph:{id:"paragraph",labelKey:"toolbarGroupParagraph"}},items:{fontFamily:{id:"fontFamily",widget:Eb,icon:iu,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:rw,icon:vu,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:W1,icon:lu,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:au,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:xu,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:yu,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:Xl,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:U1,icon:Vl,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:G1,icon:ql,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:Jc,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:mu,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:ju,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:Au,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:eu,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},alignLeft:{id:"alignLeft",command:"alignLeft",icon:hi,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:pi,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:gi,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:Wl,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:du,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:bu,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:Gl,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:Yl,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},aw={menus:{insert:{id:"insert",labelKey:"menuInsert",ariaKey:"menuInsertAria"}},groups:{insert:{id:"insert",labelKey:"toolbarGroupInsert"}},items:{link:{id:"link",command:"openLinkDialog",icon:pu,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Zc,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:Xl,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:cu,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"}}},lw={menus:{},submenus:{insertRow:{id:"insertRow",labelKey:"menuInsertRow",ariaKey:"menuInsertRowAria",enabled:"isInTable"},insertColumn:{id:"insertColumn",labelKey:"menuInsertColumn",ariaKey:"menuInsertColumnAria",enabled:"isInTable"}},groups:{},items:{table:{id:"table",command:"openTableDialog",icon:$a,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:To,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:To,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:To,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:Eo,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:Eo,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:Eo,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:$a,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:Qc,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:Du,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},sw={menus:{view:{id:"view",labelKey:"menuView",ariaKey:"menuViewAria"}},submenus:{toolbar:{id:"toolbar",labelKey:"menuToolbar",ariaKey:"menuToolbarAria"},toolbarPosition:{id:"toolbarPosition",labelKey:"menuToolbarPosition",ariaKey:"menuToolbarPositionAria"}},groups:{view:{id:"view",labelKey:"toolbarGroupView"},fullscreen:{id:"fullscreen",labelKey:"toolbarGroupFullscreen"}},items:{visual:{id:"visual",command:"setVisualMode",icon:Tu,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:uu,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:ru,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:fu,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:ou,labelKey:"modeDark",ariaKey:"modeDarkAria",active:"isDarkMode"},preview:{id:"preview",command:"openDocumentPreview",icon:wu,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:su,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function cw(...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 uw=cw($1,m1,aw,lw,sw,iw),dw={menus:[{id:"file",items:["save","open",de,"print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark",de,"image","table","horizontalRule",de,{submenu:"insertRow",items:["insertRowBelow","insertRowBefore","deleteRow"]},{submenu:"insertColumn",items:["insertColumnAfter","insertColumnBefore","deleteColumn"]}]},{id:"view",items:["visual","html",de,{submenu:"toolbar",items:["customizeToolbar",de,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},de,"lightMode","darkMode",de,"preview","fullscreen"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},de,{submenu:"font",items:["fontProperties",de,{submenu:"highlightColor",items:[]},de,"bold","italic","underline","strikethrough"]},de,"clearFormatting",de,{submenu:"paragraph",items:["paragraphProperties",de,"alignLeft","alignCenter","alignRight","alignJustify",de,"indent","outdent",de,"bulletList","numberedList"]},de,{submenu:"page",items:["pageProperties"]},de,"imageProperties",de,"tableProperties","cellProperties","rowProperties"]}],iconGroups:[{id:"file",items:["save","open"]},{id:"print",items:["print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark","image","table","horizontalRule"]},{id:"font",items:["fontFamily","paragraphStyle","fontSize","fontColor","highlightColor","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"]},{id:"fullscreen",items:["fullscreen"]}]},pr="fullscreen";function mw(e){const t=[];let n=null;for(const r of e){const i=r.items.filter(a=>a!==pr);i.length>0&&t.push({id:r.id,items:i}),r.items.includes(pr)&&(n={id:pr,items:[pr]})}return{main:t,trailing:n}}function fw({groups:e,catalog:t,commands:n,queries:r,disabled:i}){const a=V(),{main:l,trailing:c}=mw(e),m=p=>{const b=t.groups[p.id];return o.jsx("div",{className:X.iconGroup,role:"group","aria-label":b?ft(a,b):void 0,"data-toolbar-group":p.id,children:p.items.map(h=>{const w=t.items[h];if(!w)return null;const y=w.enabled?!r[w.enabled]():!1;if(w.widget){const g=w.widget;return o.jsx(g,{commands:n,queries:r,disabled:i||y},h)}if(!w.icon||!w.command)return null;const v=w.icon,x=w.command,k=w.active?r[w.active]():void 0;return o.jsx(mt,{label:w.tooltip??ft(a,w),children:o.jsx("button",{type:"button",className:X.iconButton,"aria-label":Dr(a,w),"aria-pressed":k,disabled:i||y,onPointerDown:g=>g.preventDefault(),onMouseDown:g=>g.preventDefault(),onClick:()=>{yi(n,x)},children:o.jsx(v,{className:X.icon})})},h)})},p.id)};return o.jsxs("div",{className:X.iconNav,role:"toolbar","aria-label":a("toolbarAria"),children:[l.length>0?o.jsx("div",{className:X.iconNavMain,children:l.map(m)}):null,c?o.jsx("div",{className:X.iconNavEnd,children:m(c)}):null]})}const pw=["--wysiwyg-menu-color","--wysiwyg-menu-background","--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function hw(e){const t={};for(const n of pw){const r=getComputedStyle(e).getPropertyValue(n).trim();if(r){t[n]=r;continue}let i=e;for(;i;){const a=i.style.getPropertyValue(n).trim();if(a){t[n]=a;break}i=i.parentElement}}return t}function gw({menus:e,catalog:t,commands:n,queries:r,disabled:i,compact:a,openMenuId:l,onOpenMenuIdChange:c}){const m=V(),[p,b]=s.useState(!1),[h,w]=s.useState({}),y=s.useRef(null),v=s.useRef(null),x=s.useRef(null),k=s.useRef(null),g=s.useCallback(()=>{b(!1),c(null)},[c]);s.useLayoutEffect(()=>{!p||!y.current||w(hw(y.current))},[p]),s.useEffect(()=>{var A;p&&((A=x.current)==null||A.focus())},[p]),s.useEffect(()=>{if(!p)return;const A=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=A}},[p]),s.useEffect(()=>{if(!p)return;const A=E=>{var L;if(E.key==="Escape"){if(E.preventDefault(),E.stopPropagation(),l){c(null);return}g(),(L=v.current)==null||L.focus()}},N=E=>{var L;k.current&&!k.current.contains(E.target)&&(g(),(L=v.current)==null||L.focus())};return document.addEventListener("keydown",A,!0),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",A,!0),document.removeEventListener("pointerdown",N)}},[p,l,c,g]);const S=A=>e.map(N=>{const E=t.menus[N.id];return E?o.jsx(yw,{def:E,itemIds:N.items,catalog:t,commands:n,queries:r,disabled:i,variant:A,open:(A==="overlay"||!p)&&l===N.id,onOpenChange:L=>c(L?N.id:null),onItemRun:A==="overlay"?()=>{var L;g(),(L=v.current)==null||L.focus()}:void 0},`${A}-${N.id}`):null});return o.jsxs("div",{className:X.menuBar,ref:y,children:[o.jsx(mt,{label:m("brandMarkAria"),children:o.jsx("span",{className:X.brandMark,role:"img","aria-label":m("brandMarkAria"),children:o.jsx(tu,{className:X.brandMarkIcon})})}),o.jsx("div",{className:X.menuBarCompact,hidden:a===void 0?void 0:!a,children:o.jsx(mt,{label:m("menuHamburgerAria"),children:o.jsx("button",{ref:v,type:"button",className:`${X.menuButton} ${X.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":p,"aria-label":m("menuHamburgerAria"),disabled:i,onClick:()=>{if(p){g();return}c(null),b(!0)},children:o.jsx(hu,{className:X.icon})})})}),o.jsx("div",{className:X.menuBarDesktop,hidden:a===void 0?void 0:a,children:S("dropdown")}),p?o.jsx(ie,{children:o.jsx("div",{className:X.toolbar,"data-menu-overlay-portal":"",style:h,children:o.jsxs("div",{ref:k,className:X.menuOverlay,role:"dialog","aria-modal":"true","aria-label":m("menuOverlayAria"),children:[o.jsxs("div",{className:X.menuOverlayHeader,children:[o.jsx("span",{className:X.menuOverlayTitle,children:m("menuOverlayAria")}),o.jsx("button",{ref:x,type:"button",className:X.iconButton,"aria-label":m("menuCloseAria"),onClick:()=>{var A;g(),(A=v.current)==null||A.focus()},children:o.jsx(We,{className:X.icon})})]}),o.jsx("div",{className:X.menuOverlayBody,children:S("overlay")})]})})}):null]})}function Pr(e,t){var n,r;if(ct(e))return!1;if(Cn(e)){const i=(n=t.submenus)==null?void 0:n[e.submenu];return i?i.panel?!0:e.items.some(a=>Pr(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function bw(e,t,n){if(!ct(e[t])||!e.slice(t+1).some(a=>Pr(a,n)))return!1;let i=!1;for(let a=t-1;a>=0;a--){const l=e[a];if(ct(l)){i=!0;continue}if(Pr(l,n))return!i}return!1}function yw({def:e,itemIds:t,catalog:n,commands:r,queries:i,disabled:a,variant:l,open:c,onOpenChange:m,onItemRun:p}){const b=V(),h=s.useRef(null),w=l==="overlay"?`overlay-${e.id}-menu`:`${e.id}-menu`,[y,v]=s.useState(null);s.useEffect(()=>{c||v(null)},[c]),s.useEffect(()=>{if(!c||l==="overlay")return;const k=S=>{h.current&&!h.current.contains(S.target)&&m(!1)},g=S=>{if(S.key==="Escape"){if(S.preventDefault(),S.stopPropagation(),y){v(null);return}m(!1)}};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",g,!0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",g,!0)}},[c,y,m,l]);const x=()=>{m(!1),p==null||p()};return o.jsxs("div",{className:X.menuWrap,ref:h,children:[o.jsx("button",{type:"button",className:X.menuButton,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":w,"aria-label":Dr(b,e),disabled:a,onClick:()=>m(!c),children:ft(b,e)}),c?o.jsx("div",{className:X.menu,role:"menu",id:w,children:o.jsx(Ic,{entries:t,catalog:n,commands:r,queries:i,disabled:a,variant:l,onClose:x,openSubmenuId:y,onOpenSubmenuIdChange:v})}):null]})}function Ic({entries:e,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,openSubmenuId:c,onOpenSubmenuIdChange:m}){return o.jsx(o.Fragment,{children:e.map((p,b)=>{if(ct(p))return bw(e,b,t)?o.jsx("div",{role:"separator",className:X.menuSeparator},`separator-${b}`):null;if(Cn(p))return o.jsx(ww,{entry:p,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,open:c===p.submenu,onOpenChange:w=>m==null?void 0:m(w?p.submenu:null)},`submenu-${p.submenu}-${b}`);const h=t.items[p];return!h||!h.command?null:o.jsx(xw,{item:h,commands:n,queries:r,disabled:i,onClose:l},p)})})}function xw({item:e,commands:t,queries:n,disabled:r,onClose:i}){const a=V();if(!e.command)return null;const l=e.icon,c=e.command,m=e.active?n[e.active]():void 0,p=e.enabled?!n[e.enabled]():!1,b=e.toggle?"menuitemcheckbox":e.active?"menuitemradio":"menuitem";return o.jsxs("button",{type:"button",role:b,className:X.menuItem,"aria-checked":m,disabled:r||p,onClick:()=>{i(),yi(t,c)},children:[l?o.jsx(l,{className:X.icon}):null,ft(a,e)]})}function ww({entry:e,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,open:c,onOpenChange:m}){var E;const p=V(),b=s.useRef(null),h=s.useRef(null),[w,y]=s.useState(null),v=(E=t.submenus)==null?void 0:E[e.submenu],x=a==="overlay"?`overlay-${e.submenu}-submenu`:`${e.submenu}-submenu`,k=v==null?void 0:v.panel,g=v!=null&&v.enabled?!r[v.enabled]():!1,S=a==="overlay";if(s.useEffect(()=>{c||y(null)},[c]),!v||!k&&!e.items.some(L=>Pr(L,t)))return null;const A=L=>{(L.key==="ArrowRight"||L.key==="Enter"||L.key===" ")&&(L.preventDefault(),L.stopPropagation(),m(!0),requestAnimationFrame(()=>{var I;const M=(I=h.current)==null?void 0:I.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');M==null||M.focus()}))},N=L=>{var M;L.key==="ArrowLeft"&&(L.preventDefault(),L.stopPropagation(),m(!1),(M=b.current)==null||M.focus())};return o.jsxs("div",{className:X.submenuWrap,onMouseEnter:S?void 0:()=>m(!0),onMouseLeave:S?void 0:()=>m(!1),children:[o.jsx("button",{ref:b,type:"button",role:"menuitem",className:`${X.menuItem} ${X.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":x,"aria-label":Dr(p,v),disabled:i||g,onClick:()=>m(S?!c:!0),onKeyDown:A,children:ft(p,v)}),c?o.jsx("div",{ref:h,className:`${X.menu} ${X.submenu}`,role:"menu",id:x,"aria-label":Dr(p,v),onKeyDown:N,children:k?o.jsx(k,{commands:n,queries:r,disabled:i||g,onMenuClose:l}):o.jsx(Ic,{entries:e.items,catalog:t,commands:n,queries:r,disabled:i,variant:a,onClose:l,openSubmenuId:w,onOpenSubmenuIdChange:y})}):null]})}function qo({catalog:e,layout:t,commands:n,queries:r,disabled:i,menuVisible:a=!0,toolbarVisible:l=!0,compact:c,position:m="top"}){const[p,b]=s.useState(null);return!a&&!l?null:o.jsxs("div",{className:X.toolbar,"data-compact":c?"":void 0,"data-toolbar-position":m,children:[a?o.jsx(gw,{menus:t.menus,catalog:e,commands:n,queries:r,disabled:i,compact:c,openMenuId:p,onOpenMenuIdChange:b}):null,l?o.jsx(fw,{groups:t.iconGroups,catalog:e,commands:n,queries:r,disabled:i}):null]})}const vw="_root_1j9y7_1",Sw="_fullscreen_1j9y7_36",Cw="_exitFullscreen_1j9y7_48",kw="_exitFullscreenIcon_1j9y7_79",Dw="_menuChrome_1j9y7_94",Pw="_body_1j9y7_105",Aw="_iconChrome_1j9y7_135",jw="_workspace_1j9y7_179",Ew="_htmlFileDropOverlay_1j9y7_191",Tw="_surface_1j9y7_205",Nw="_visual_1j9y7_212",Lw="_html_1j9y7_191",De={root:vw,fullscreen:Sw,exitFullscreen:Cw,exitFullscreenIcon:kw,menuChrome:Dw,body:Pw,iconChrome:Aw,workspace:jw,htmlFileDropOverlay:Ew,surface:Tw,visual:Nw,html:Lw},Mw=s.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:i},a){const l=V();return o.jsx("textarea",{ref:a,className:`${De.surface} ${De.html}`,value:t,onChange:c=>n(c.target.value),placeholder:r,disabled:i,"aria-label":l("htmlEditorAria"),spellCheck:!1})}),Rw=s.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:i,onBeforeInput:a,onPointerDown:l,onContextMenu:c},m){const p=V(),b=s.useRef(null),h=s.useRef(a);h.current=a;const w=y=>{b.current=y,typeof m=="function"?m(y):m&&(m.current=y)};return s.useLayoutEffect(()=>{const y=b.current;y&&(y.innerHTML!==t&&(y.innerHTML=t),Ps(y))},[t]),s.useLayoutEffect(()=>{const y=b.current;if(!y)return;const v=x=>{var k;(k=h.current)==null||k.call(h,x)};return y.addEventListener("beforeinput",v),()=>y.removeEventListener("beforeinput",v)},[]),o.jsx("div",{ref:w,className:`${De.surface} ${De.visual}`,contentEditable:!i,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":p("visualEditorAria"),"aria-disabled":i||void 0,"data-placeholder":r,onPointerDown:l,onContextMenu:c,onInput:y=>{n(y.currentTarget.innerHTML)}})});function _w({value:e,defaultValue:t="",onChange:n,onAutoSave:r,mode:i,defaultMode:a="visual",onModeChange:l,fullscreen:c,defaultFullscreen:m=!1,onFullscreenChange:p,placeholder:b,disabled:h,readOnly:w=!1,className:y,locale:v="en",toolbarBackground:x,menuColor:k,menuBackground:g,menuFontSize:S,menuFontFamily:A,border:N,menuVisible:E=!0,toolbarVisible:L=!0,allowedChrome:M,customActions:I,customFonts:j,transformHtml:T,loadCustomParagraphStyles:P,onSaveCustomParagraphStyle:R,onDeleteCustomParagraphStyle:W,customImagePicker:O,disableBuiltinImageInsert:Z,disableHtmlFileDrop:te=!1,toolbarCustomization:ce,darkMode:re=!1,darkModePersistence:he,toolbarPosition:ne="top",toolbarPositionPersistence:Q}){const D=!!(h||w),[$,Y]=Ho({value:e,defaultValue:t,onChange:n}),[B,fe]=Ho({value:i,defaultValue:a,onChange:l}),[ue,we]=Ho({value:c,defaultValue:m,onChange:p}),_=s.useRef(null),Ce=s.useRef(null),Pt=s.useRef(null);Pt.current===null&&(Pt.current=p1($));const Ee=Pt.current,ot=s.useRef($);ot.current=$;const z=s.useRef(B);z.current=B;const Ji=s.useRef(ue);Ji.current=ue;const ke=s.useRef(null),jn=s.useRef(T);jn.current=T;const Te=s.useRef({}),Pe=s.useRef(null),Ne=s.useRef(null),ze=s.useRef(null),Oe=s.useRef(null),Le=s.useRef(null),[En,_r]=s.useState(Qe),Ir=s.useRef(En);Ir.current=En;const Ye=s.useRef(Ct),[Yt,Tn]=s.useState({value:null,unit:Ct,mixed:!1}),it=s.useRef(Yt);it.current=Yt;const[Jt,Fr]=s.useState({value:null,mixed:!1}),Zt=s.useRef(Jt);Zt.current=Jt;const[Qt,Br]=s.useState({value:null,mixed:!1}),en=s.useRef(Qt);en.current=Qt;const[tn,Hr]=s.useState({value:null,mixed:!1}),nn=s.useRef(tn);nn.current=tn;const[zr,Or]=s.useState({tag:null,mixed:!1}),Kr=s.useRef(zr);Kr.current=zr;const[Zi,$r]=s.useState({align:"left",mixed:!1}),Ur=s.useRef(Zi);Ur.current=Zi;const[Qi,Wr]=s.useState({type:null,mixed:!1}),rn=s.useRef(Qi);rn.current=Qi;const[ea,Gr]=s.useState(!1),ta=s.useRef(ea);ta.current=ea;const[Vr,qr]=s.useState(!1),na=s.useRef(Vr);na.current=Vr;const[ra,oa]=s.useState(!1),ia=s.useRef(ra);ia.current=ra;const[on,Nn]=s.useState({open:!1,tab:"general"}),[Xr,aa]=s.useState(!1),[an,la]=s.useState({open:!1,html:""}),[Yr,Ln]=s.useState(null),[Fc,Jr]=s.useState(!1),[Bc,Zr]=s.useState(!1),[At,Mn]=s.useState(()=>he?re:Hl()??re),[Ke,Rn]=s.useState(()=>Q?ne:zl()??ne),[yt,_n]=s.useState({open:!1,tab:"general",value:hn()}),[xt,In]=s.useState({open:!1,tab:"font",value:ri()}),[Qr,sa]=s.useState([]),[eo,to]=s.useState(!1),[Hc,Fn]=s.useState(!1),[be,ln]=s.useState({open:!1}),[Ae,Bn]=s.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[no,ro]=s.useState({open:!1,existingIds:[]}),[zc,Hn]=s.useState({open:!1}),[zn,On]=s.useState({open:!1,tab:"general",value:fc(),aspectRatio:1}),[oo,io]=s.useState({open:!1}),[Kn,ao]=s.useState({open:!1,value:_h()}),[$n,lo]=s.useState({open:!1,value:Wh()}),[Un,so]=s.useState({open:!1,value:eg()}),[sn,co]=s.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1}),[ye,jt]=s.useState(null),ca=s.useRef(ye);ca.current=ye;const[uo,Wn]=s.useState(!1),ua=s.useRef(uo);ua.current=uo;const da=s.useRef(void 0),Gn=s.useRef(Qr);Gn.current=Qr;const ma=s.useRef(eo);ma.current=eo;const mo=!!(P&&R),fo=s.useRef(mo);fo.current=mo;const fa=s.useRef(P);fa.current=P;const pa=s.useRef(R);pa.current=R;const ha=s.useRef(W);ha.current=W;const ga=s.useRef(O);ga.current=O;const ba=s.useRef(ce);ba.current=ce;const ya=s.useRef(he);ya.current=he;const xa=s.useRef(Q);xa.current=Q;const wa=s.useRef(At);wa.current=At;const va=s.useRef(Ke);va.current=Ke;const Sa=s.useRef(Z);Sa.current=Z;const po=s.useRef(0),cn=s.useRef(0),Ca=s.useRef(0),Vn=s.useRef(0),ka=s.useRef(0),qn=s.useRef(0),Da=s.useRef(0),at=s.useMemo(()=>ss(j),[j]),un=s.useRef(at);un.current=at;const ho=s.useMemo(()=>yd($,at).join(`
|
|
91
91
|
`),[$,at]);s.useEffect(()=>{const f=(ho?ho.split(`
|
|
92
92
|
`):[]).map(C=>{const K=document.createElement("link");return K.rel="stylesheet",K.href=C,K.setAttribute(jr,""),document.head.append(K),K});return()=>{for(const C of f)C.remove()}},[ho]);const Xn=s.useCallback(async()=>{const u=fa.current;if(!u)return;const f=++po.current;to(!0);try{const C=await u();if(f!==po.current)return;sa(C)}catch{}finally{f===po.current&&to(!1)}},[]);s.useEffect(()=>{if(!P||!R){sa([]),to(!1);return}Xn()},[P,R,Xn]);const Pa=s.useCallback(async u=>{Ln(u);const f=ba.current;if(f!=null&&f.load&&f.save){const C=++Ca.current;Zr(!0);try{await f.save(u)}catch{}finally{C===Ca.current&&Zr(!1)}return}y1(u)},[]);s.useEffect(()=>{const u=ce;if(!(u!=null&&u.load)||!u.save){Ln(b1()),Jr(!1),Zr(!1);return}const f=++cn.current;return Jr(!0),(async()=>{try{const C=await u.load();if(f!==cn.current)return;Ln(C)}catch{if(f!==cn.current)return;Ln(null)}finally{f===cn.current&&Jr(!1)}})(),()=>{cn.current+=1}},[ce]);const Aa=s.useCallback(async u=>{Mn(u);const f=ya.current;if(f!=null&&f.load&&f.save){const C=++ka.current;try{await f.save(u)}catch{}finally{if(C!==ka.current)return}return}s1(u)},[]);s.useEffect(()=>{const u=he;if(!(u!=null&&u.load)||!u.save){Mn(Hl()??re);return}const f=++Vn.current;return(async()=>{try{const C=await u.load();if(f!==Vn.current)return;Mn(typeof C=="boolean"?C:re)}catch{if(f!==Vn.current)return;Mn(re)}})(),()=>{Vn.current+=1}},[he,re]);const ja=s.useCallback(async u=>{Rn(u);const f=xa.current;if(f!=null&&f.load&&f.save){const C=++Da.current;try{await f.save(u)}catch{}finally{if(C!==Da.current)return}return}u1(u)},[]);s.useEffect(()=>{const u=Q;if(!(u!=null&&u.load)||!u.save){Rn(zl()??ne);return}const f=++qn.current;return(async()=>{try{const C=await u.load();if(f!==qn.current)return;Rn(Lc(C)??ne)}catch{if(f!==qn.current)return;Rn(ne)}})(),()=>{qn.current+=1}},[Q,ne]);const Et=s.useCallback(u=>{var C;const f=((C=jn.current)==null?void 0:C.call(jn,u))??u;return Y(f),f},[Y]),Se=s.useCallback((u,f)=>{const C=Et(u);return Ee.record(C,{coalesce:f}),C},[Et,Ee]),Oc=s.useCallback(u=>{Se(u,!1)},[Se]),dn=d1({enabled:!D&&!te,onHtml:Oc}),G=s.useCallback((u,f)=>Se(Lo(u,Mo(u,ot.current,un.current)),f),[Se]),Yn=s.useCallback(()=>{const u=Ee.undo();u!==null&&(Ee.markApplying(),Et(u))},[Et,Ee]),Jn=s.useCallback(()=>{const u=Ee.redo();u!==null&&(Ee.markApplying(),Et(u))},[Et,Ee]);s.useEffect(()=>{Ee.syncExternal($)},[$,Ee]);const H=s.useCallback(()=>{ke.current=lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current})},[]),go=s.useCallback(()=>{const u=lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current}),f=ke.current;tl(f,u)||(ke.current=u)},[]),bo=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){Tn({value:null,unit:Ye.current,mixed:!1});return}const f=Qd(u,Ye.current);Pe.current&&(f.value=Pe.current.value,f.unit=Pe.current.unit,f.mixed=!1),Ye.current=f.unit,Tn(C=>C.value===f.value&&C.unit===f.unit&&C.mixed===f.mixed?C:f)},[]),yo=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){Fr({value:null,mixed:!1});return}const f=vd(u);Ne.current&&(f.value=Ne.current.value,f.mixed=!1),Fr(C=>C.value===f.value&&C.mixed===f.mixed?C:f)},[]),xo=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){Br({value:null,mixed:!1}),Hr({value:null,mixed:!1});return}const f=qa(u,"color");ze.current&&(f.value=ze.current.value,f.mixed=!1);const C=qa(u,"backgroundColor");Oe.current&&(C.value=Oe.current.value,C.mixed=!1),Br(K=>K.value===f.value&&K.mixed===f.mixed?K:f),Hr(K=>K.value===C.value&&K.mixed===C.mixed?K:C)},[]),wo=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){Or({tag:null,mixed:!1});return}const f=qm(u);Or(C=>C.tag===f.tag&&C.mixed===f.mixed?C:f)},[]),vo=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){$r({align:null,mixed:!1}),Wr({type:null,mixed:!1}),Gr(!1),oa(!1);return}const f=Zs(u);$r(ee=>ee.align===f.align&&ee.mixed===f.mixed?ee:f);const C=Rs(u);Wr(ee=>ee.type===C.type&&ee.mixed===C.mixed?ee:C);const K=of(u);Gr(ee=>ee===K?ee:K);const q=Yf(u);oa(ee=>ee===q?ee:q)},[]),F=s.useCallback(()=>{const u=_.current;if(z.current!=="visual"||!u){_r(Qe()),qr(!1),bo(),yo(),xo(),wo(),vo();return}const f=ke.current,C=!!(f&&!f.collapsed);qr(q=>q===C?q:C);const K=ws(or(u),Te.current);_r(q=>fm(q,K)?q:K),bo(),yo(),xo(),wo(),vo()},[bo,yo,xo,wo,vo]),Ea=s.useCallback(()=>{const u=ke.current,f=Le.current;!f||!u||u.collapsed&&u.start===f.start&&u.end===f.end||(Te.current={},Pe.current=null,Ne.current=null,ze.current=null,Oe.current=null,Le.current=null)},[]);s.useEffect(()=>{if(B==="visual"){F();return}Te.current={},Pe.current=null,Ne.current=null,ze.current=null,Oe.current=null,Le.current=null,_r(Qe()),Tn({value:null,unit:Ye.current,mixed:!1}),Fr({value:null,mixed:!1}),Br({value:null,mixed:!1}),Hr({value:null,mixed:!1}),Or({tag:null,mixed:!1}),$r({align:null,mixed:!1}),Wr({type:null,mixed:!1}),Gr(!1),qr(!1)},[B,$,F]);const Tt=s.useCallback((u,f,C)=>{Tm({snapshot:u,visualEl:_.current,htmlEl:Ce.current,getHtml:()=>z.current==="visual"&&_.current?_.current.innerHTML:ot.current,setHtml:K=>{if(z.current==="visual"){G(vn(K).body,!1);return}Se(K,!1)},content:f,asHtml:C})},[Se,G]),Ta=s.useCallback(u=>{if(z.current==="visual"&&u==="html"&&_.current){const f=_.current.innerHTML,C=Lo(f,Mo(f,ot.current,un.current));C!==ot.current&&Se(C,!0)}fe(u)},[Se,fe]);s.useEffect(()=>{if(!ue)return;const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=u}},[ue]),s.useEffect(()=>{if(!ue)return;const u=f=>{f.key==="Escape"&&(f.defaultPrevented||on.open||yt.open||xt.open||oo.open||Kn.open||$n.open||Un.open||Xr||an.open||(f.preventDefault(),we(!1)))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[ue,we,on.open,yt.open,xt.open,oo.open,Kn.open,$n.open,Un.open,Xr,an.open]),s.useEffect(()=>{const u=()=>{if(z.current!=="visual"||!_.current)return;const f=window.getSelection();if(!f||f.rangeCount===0)return;const C=f.anchorNode;!C||!_.current.contains(C)&&_.current!==C||(H(),Ea(),F(),jt(bn(_.current)),Wn(yn(_.current)!==null))};return document.addEventListener("selectionchange",u),()=>document.removeEventListener("selectionchange",u)},[H,Ea,F]),s.useEffect(()=>{if(B!=="html")return;const u=Ce.current;if(!u)return;const f=()=>H();return u.addEventListener("select",f),u.addEventListener("keyup",f),u.addEventListener("mouseup",f),()=>{u.removeEventListener("select",f),u.removeEventListener("keyup",f),u.removeEventListener("mouseup",f)}},[B,H]),s.useLayoutEffect(()=>{if(B!=="visual"||D){jt(null);return}const u=_.current;if(!u)return;const f=bn(u);jt(C=>f||(C&&C.isConnected&&u.contains(C)?C:null))},[$,B,D]);const U=s.useCallback(u=>{const f=lt({mode:"visual",visualEl:u,htmlEl:Ce.current}),C=ke.current,K=tl(C,f)?C:f.visualRange?f:C??f;ke.current=K,u.focus();const q=Em(u,K);if(q){const ee=window.getSelection();try{ee==null||ee.removeAllRanges(),ee==null||ee.addRange(q),ke.current={...K,visualRange:q}}catch{}}return ke.current??K},[]),So=s.useCallback((u,f)=>{if(z.current!=="visual")return;const C=_.current;if(!C)return;const K=f??Ye.current,q=kt(u,K);if(!q)return;Ye.current=q.unit;const ee=U(C);if(ee.collapsed){Pe.current=q,Le.current={start:ee.start,end:ee.end},F();return}Pe.current=null,Va(C,q.value,q.unit)&&(G(C.innerHTML,!1),H(),F())},[U,G,H,F]),Na=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(!f)return;const C=U(f);if(C.collapsed){Ne.current={value:u},Le.current={start:C.start,end:C.end},F();return}Ne.current=null,Wa(f,u)&&(G(f.innerHTML,!1),H(),F())},[U,G,H,F]),Co=s.useCallback((u,f)=>{if(z.current!=="visual")return;const C=_.current;if(!C)return;const K=U(C),q=u==="color"?ze:Oe;if(K.collapsed){q.current={value:f},Le.current={start:K.start,end:K.end},F();return}q.current=null,Fo(C,u,f)&&(G(C.innerHTML,!1),H(),F())},[U,G,H,F]),ko=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(!f)return;const C=U(f);if(Nn({open:!1,tab:"general"}),C.collapsed){if(u.size!==null){const je=kt(u.size,u.unit);je&&(Pe.current=je,Ye.current=je.unit)}const q=or(f),ee={};for(const je of Ue)u.marks[je]!==q[je]&&(ee[je]=u.marks[je]);Te.current=ee,u.fontColorMixed||(ze.current={value:u.fontColor}),u.highlightColorMixed||(Oe.current={value:u.highlightColor}),u.fontFamilyMixed||(Ne.current={value:u.fontFamily}),Le.current={start:C.start,end:C.end},F();return}if(Te.current={},Pe.current=null,Ne.current=null,ze.current=null,Oe.current=null,Le.current=null,u.size!==null){const q=kt(u.size,u.unit);q&&(Ye.current=q.unit,Va(f,q.value,q.unit))}const K=or(f);for(const q of Ue)u.marks[q]!==K[q]&&Ya(f,q);u.fontFamilyMixed||Wa(f,u.fontFamily),u.fontColorMixed||Fo(f,"color",u.fontColor),u.highlightColorMixed||Fo(f,"backgroundColor",u.highlightColor),G(f.innerHTML,!1),H(),F()},[U,G,H,F]),La=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),_n(C=>({...C,open:!1})),!ec(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Ma=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),In(C=>({...C,open:!1})),!Kf(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Ra=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),Bn(C=>({...C,open:!1})),!np(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),_a=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),ro(C=>({...C,open:!1})),!ap(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Zn=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),Hn({open:!1}),!Pp(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Ia=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),io({open:!1}),!Dh(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F(),Wn(!0)}},[U,G,H,F]),Fa=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),ao(C=>({...C,open:!1})),!Hh(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Ba=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),lo(C=>({...C,open:!1})),!Xh(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Ha=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),so(C=>({...C,open:!1})),!og(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),wt=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),!u(f)){H(),F();return}G(f.innerHTML,!1),H(),F(),Wn(yn(f)!==null)}},[U,G,H,F]),Do=s.useCallback(u=>{Zn({src:u.src,alt:u.alt??"",title:u.title??"",css:u.css})},[Zn]),za=s.useCallback(u=>{if(z.current!=="visual")return;const f=_.current;if(f){if(U(f),On(C=>({...C,open:!1})),!th(f,u)){H(),F();return}G(f.innerHTML,!1),H(),F()}},[U,G,H,F]),Kc=s.useCallback((u,f)=>{ye!=null&&ye.isConnected&&yh(ye,u,f)},[ye]),$c=s.useCallback(()=>{const u=_.current;!u||!(ye!=null&&ye.isConnected)||(G(u.innerHTML,!1),Bo(u,ye),H(),F())},[ye,G,H,F]),Qn=s.useCallback(()=>{if(z.current==="visual"&&_.current){const u=_.current.innerHTML,f=Lo(u,Mo(u,ot.current,un.current));if(f!==ot.current)return Se(f,!0)}return ot.current},[Se]);dg({onAutoSave:r,getHtml:Qn});const ae=s.useMemo(()=>({getHtml:Qn,setHtml:u=>{Se(u,!1)},getMode:()=>z.current,setMode:Ta,getFullscreen:()=>Ji.current,setFullscreen:we,getDarkMode:()=>wa.current,setDarkMode:u=>{Aa(u)},getToolbarPosition:()=>va.current,setToolbarPosition:u=>{ja(u)},openCustomizeToolbar:()=>{aa(!0)},openDocumentPreview:()=>{la({open:!0,html:Qn()})},undo:Yn,redo:Jn,canUndo:()=>Ee.canUndo(),canRedo:()=>Ee.canRedo(),getSelection:()=>{const u=ke.current??lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current});return Ja(u)},insertText:u=>{const f=ke.current??lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current});Tt(f,u,!1)},insertHtml:(u,f)=>{const C=ke.current??lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current}),K=f===void 0;Tt(C,K?u:f,K)},toggleFontMark:u=>{if(z.current!=="visual")return;const f=_.current;if(!f)return;const C=U(f);if(C.collapsed){const K=or(f);Te.current=hm(Te.current,K,u),Le.current={start:C.start,end:C.end},F();return}Te.current={},Le.current=null,Ya(f,u)&&(G(f.innerHTML,!1),H(),F())},clearFormatting:()=>{if(z.current!=="visual")return;const u=_.current;!u||U(u).collapsed||(Te.current={},Pe.current=null,Ne.current=null,ze.current=null,Oe.current=null,Le.current=null,pp(u)&&(G(u.innerHTML,!1),H(),F()))},isFontMarkActive:u=>Ir.current[u],hasTextSelection:()=>z.current==="visual"&&na.current,setFontSize:(u,f)=>{So(u,f)},setFontSizeUnit:u=>{var je;const f=_.current,C=it.current;if(z.current!=="visual"||!f||C.value===null||C.mixed){Ye.current=u,Tn(jo=>({...jo,unit:u}));return}const K=U(f),q=em(f,((je=K.visualRange)==null?void 0:je.startContainer)??f),ee=ms(C.value,C.unit,u,q.parentPx,q.rootPx);So(ee,u)},getFontSize:()=>it.current.value,getFontSizeUnit:()=>it.current.unit,isFontSizeMixed:()=>it.current.mixed,setFontFamily:u=>{Na(u)},getFontFamily:()=>Zt.current.value,isFontFamilyMixed:()=>Zt.current.mixed,getFontFaces:()=>un.current,setFontColor:u=>{Co("color",u)},setHighlightColor:u=>{Co("backgroundColor",u)},getFontColor:()=>en.current.value,isFontColorMixed:()=>en.current.mixed,getHighlightColor:()=>nn.current.value,isHighlightColorMixed:()=>nn.current.mixed,setParagraphStyle:u=>{if(z.current!=="visual")return;const f=_.current;f&&(U(f),Xm(f,u)&&(G(f.innerHTML,!1),H(),F()))},getParagraphStyle:()=>Kr.current.tag,isParagraphStyleMixed:()=>Kr.current.mixed,setTextAlign:u=>{if(z.current!=="visual")return;const f=_.current;f&&(U(f),Qs(f,u)&&(G(f.innerHTML,!1),H(),F()))},getTextAlign:()=>Ur.current.align,isTextAlignMixed:()=>Ur.current.mixed,indent:()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),af(u)&&(G(u.innerHTML,!1),H(),F()))},outdent:()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),lf(u)&&(G(u.innerHTML,!1),H(),F()))},canOutdent:()=>z.current==="visual"&&ta.current,toggleList:u=>{if(z.current!=="visual")return;const f=_.current;f&&(U(f),Zm(f,u)&&(G(f.innerHTML,!1),H(),F()))},isBulletList:()=>rn.current.type==="ul"&&!rn.current.mixed,isNumberedList:()=>rn.current.type==="ol"&&!rn.current.mixed,openFontProperties:u=>{z.current==="visual"&&Nn({open:!0,tab:u??"general"})},applyFontProperties:u=>{ko(u)},openParagraphProperties:u=>{if(z.current!=="visual")return;const f=_.current;f&&U(f),_n({open:!0,tab:u??"general",value:f?al(f):hn()})},applyParagraphProperties:u=>{La(u)},openPageProperties:u=>{if(z.current!=="visual")return;const f=_.current;f&&U(f),In({open:!0,tab:u??"font",value:f?Of(f):ri()})},applyPageProperties:u=>{Ma(u)},openCustomParagraphStyleDialog:u=>{if(z.current!=="visual"||!fo.current)return;if(u){const C=Gn.current.find(K=>K.id===u);if(!C)return;ln({open:!0,mode:"edit",style:C});return}const f=_.current;f&&U(f),ln({open:!0,mode:"create",font:{size:it.current.mixed?null:it.current.value,unit:it.current.unit,marks:{...Ir.current},fontFamily:Zt.current.mixed?null:Zt.current.value,fontColor:en.current.mixed?null:en.current.value,highlightColor:nn.current.mixed?null:nn.current.value},paragraph:tc(f?al(f):hn())})},applyCustomParagraphStyle:u=>{const f=Gn.current.find(K=>K.id===u);if(!f||(ko({size:f.font.size,unit:f.font.unit,marks:f.font.marks,fontFamily:f.font.fontFamily??null,fontFamilyMixed:!1,fontColor:f.font.fontColor,highlightColor:f.font.highlightColor,fontColorMixed:!1,highlightColorMixed:!1}),!f.paragraph))return;const C=_.current;!C||z.current!=="visual"||(U(C),Lf(C,f.paragraph)&&(G(C.innerHTML,!1),H(),F()))},customParagraphStylesEnabled:()=>fo.current,getCustomParagraphStyles:()=>Gn.current,isCustomParagraphStylesLoading:()=>ma.current,openLinkDialog:u=>{if(z.current!=="visual")return;const f=_.current;f&&U(f);const C=f?oc(f):Mr(),K=f?oi(f):[],q=(C==null?void 0:C.href)??"",ee=q.startsWith("#")?q.slice(1):"",je=K.some(jo=>jo.id===ee)?ee:"";Bn({open:!0,tab:u??"link",href:q,title:(C==null?void 0:C.title)??"",targetBlank:(C==null?void 0:C.targetBlank)??!1,textDecorationNone:(C==null?void 0:C.textDecorationNone)??!1,hoverMode:(C==null?void 0:C.hoverMode)??"color",hoverColor:(C==null?void 0:C.hoverColor)??null,hoverHtml:(C==null?void 0:C.hoverHtml)??"",bookmarks:K,selectedBookmarkId:je})},applyLink:u=>{Ra(u)},openBookmarkDialog:()=>{if(z.current!=="visual")return;const u=_.current;u&&U(u),ro({open:!0,existingIds:u?oi(u).map(f=>f.id):[]})},applyBookmark:u=>{_a(u)},openImageDialog:()=>{if(z.current!=="visual")return;const u=_.current;u&&U(u);const f=ga.current;if(Sa.current&&f){f.onPick(Do);return}Hn({open:!0})},applyImage:u=>{Zn(u)},openImageProperties:u=>{if(z.current!=="visual")return;const f=_.current;if(!f)return;U(f);const C=bn(f),K=eh(f);!C||!K||On({open:!0,tab:u??"general",value:K,aspectRatio:Jp(C)})},applyImageProperties:u=>{za(u)},insertHorizontalRule:()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),Mp(u)&&(G(u.innerHTML,!1),H(),F()))},openTableDialog:()=>{if(z.current!=="visual")return;const u=_.current;u&&U(u),io({open:!0})},applyTable:u=>{Ia(u)},openTableProperties:()=>{if(z.current!=="visual")return;const u=_.current;if(!u)return;U(u);const f=Bh(u);f&&ao({open:!0,value:f})},applyTableProperties:u=>{Fa(u)},openCellProperties:()=>{if(z.current!=="visual")return;const u=_.current;if(!u)return;U(u);const f=qh(u);f&&lo({open:!0,value:f})},applyCellProperties:u=>{Ba(u)},openRowProperties:()=>{if(z.current!=="visual")return;const u=_.current;if(!u)return;U(u);const f=rg(u);f&&so({open:!0,value:f})},applyRowProperties:u=>{Ha(u)},insertRowBelow:()=>{wt(u=>si(u,"below"))},insertRowBefore:()=>{wt(u=>si(u,"before"))},deleteRow:()=>{wt(u=>Ph(u))},insertColumnAfter:()=>{wt(u=>hl(u,"after"))},insertColumnBefore:()=>{wt(u=>hl(u,"before"))},deleteColumn:()=>{wt(u=>Ah(u))},cut:async()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),await cp(u)&&(G(u.innerHTML,!1),H(),F()))},copy:async()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),await cc(u))},deleteSelection:()=>{if(z.current!=="visual")return;const u=_.current;u&&(U(u),sc(u)&&(G(u.innerHTML,!1),H(),F()))},isLink:()=>ia.current,isImageSelected:()=>z.current==="visual"&&ca.current!==null,isInTable:()=>z.current==="visual"&&ua.current}),[Se,G,Ta,we,Aa,ja,Tt,Yn,Jn,H,F,U,So,Na,Co,ko,La,Ma,Ra,_a,Zn,za,Ia,Fa,Ba,Ha,wt,Do,Qn]),Oa=s.useCallback(()=>{const u=ke.current??lt({mode:z.current,visualEl:_.current,htmlEl:Ce.current});return{mode:u.mode,selection:Ja(u),getHtml:ae.getHtml,setHtml:f=>{Se(f,!1)},insertText:f=>Tt(u,f,!1),insertHtml:(f,C)=>{const K=C===void 0;Tt(u,K?f:C,K)}}},[Tt,ae.getHtml,Se]),{catalog:er,layout:Ka}=s.useMemo(()=>Bu(I,uw,dw),[I]),tr=s.useMemo(()=>K1(Ka,M),[Ka,M]),Po=s.useMemo(()=>({...tr,iconGroups:h1(tr.iconGroups,Yr)}),[tr,Yr]),Nt=s.useMemo(()=>({...Kd(ae),...Hu(I,Oa)}),[ae,I,Oa]),Ao=s.useMemo(()=>$d(ae),[ae,En,Yt,Jt,Qt,tn,zr,Qr,eo,mo,at,ye,uo,Vr,At,Ke]),Uc=s.useCallback(u=>{if(D||u.inputType!=="insertText"&&u.inputType!=="insertReplacementText"||!u.data||!pm(Te.current)&&!Pe.current&&!Cd(Ne.current)&&!lm({color:ze.current,backgroundColor:Oe.current}))return;const f=_.current;f&&(u.preventDefault(),km(f,u.data,Te.current,Pe.current,{color:ze.current,backgroundColor:Oe.current},Ne.current),Te.current={},Pe.current=null,Ne.current=null,ze.current=null,Oe.current=null,Le.current=null,G(f.innerHTML,!0),H(),F())},[D,G,H,F]),Wc=s.useCallback(u=>{if(D||!ed(u,da.current))return;u.preventDefault(),u.stopPropagation();const f=_.current;if(!f)return;const C=ii(f,u.target),K=kr(f,u.target);if(K&&Eh(f,K),C){Bo(f,C),H(),jt(C),co({open:!0,x:u.clientX,y:u.clientY,kind:"image",inTable:Ve(f,C)!==null});return}const q=lt({mode:"visual",visualEl:f,htmlEl:Ce.current});ke.current=q,co({open:!0,x:u.clientX,y:u.clientY,kind:q.collapsed?"caret":"text",inTable:Ve(f,u.target)!==null})},[D,H]),Gc=s.useCallback(u=>{if(da.current=u.pointerType,D)return;const f=_.current;if(!f)return;const C=ii(f,u.target);if(!C){jt(null);return}u.preventDefault(),Bo(f,C),H(),jt(C)},[D,H]),Vc=s.useCallback(u=>{if(D)return;if(u.key==="Tab"&&!u.ctrlKey&&!u.metaKey&&!u.altKey){if(z.current!=="visual")return;const C=_.current;if(!C)return;const K=u.target;if(!(K instanceof Node)||!C.contains(K))return;U(C);const q=jh(C,u.shiftKey);if(!q)return;u.preventDefault(),typeof q=="object"&&q.changed&&G(C.innerHTML,!1),H(),F(),Wn(yn(C)!==null);return}if(!(u.ctrlKey||u.metaKey))return;const f=u.key.toLowerCase();if(f==="z"&&!u.shiftKey){u.preventDefault(),Yn();return}if(f==="z"&&u.shiftKey||f==="y"){u.preventDefault(),Jn();return}if(f==="b"&&!u.shiftKey){u.preventDefault(),ae.toggleFontMark("bold");return}if(f==="i"&&!u.shiftKey){u.preventDefault(),ae.toggleFontMark("italic");return}if(f==="u"&&!u.shiftKey){u.preventDefault(),ae.toggleFontMark("underline");return}if(f==="x"&&u.shiftKey){u.preventDefault(),ae.toggleFontMark("strikethrough");return}f==="p"&&!u.shiftKey&&(u.preventDefault(),Nt.print())},[D,Yn,Jn,ae,Nt,U,G,H,F]),qc=[De.root,Xo(At).className,ue?De.fullscreen:"",y].filter(Boolean).join(" "),Xc=Iw({toolbarBackground:x,menuColor:k,menuBackground:g,menuFontSize:S,menuFontFamily:A,border:N}),Yc=Xo(At)["data-wysiwyg-theme"];return o.jsx(Vu,{locale:v,children:o.jsx($u,{dark:At,children:o.jsxs("div",{className:qc,style:Xc,"data-fullscreen":ue?"":void 0,"data-wysiwyg-theme":Yc,"data-toolbar-position":Ke,onKeyDown:Vc,children:[E?o.jsx("div",{className:De.menuChrome,onPointerDownCapture:go,children:o.jsx(qo,{catalog:er,layout:Po,commands:Nt,queries:Ao,disabled:D,menuVisible:!0,toolbarVisible:!1})}):null,o.jsxs("div",{className:De.body,"data-icon-dock":L?Ke:void 0,children:[L&&(Ke==="top"||Ke==="left")?o.jsx("div",{className:De.iconChrome,onPointerDownCapture:go,children:o.jsx(qo,{catalog:er,layout:Po,commands:Nt,queries:Ao,disabled:D,menuVisible:!1,toolbarVisible:!0,position:Ke})}):null,o.jsxs("div",{className:De.workspace,onDragEnter:dn.onDragEnter,onDragOver:dn.onDragOver,onDragLeave:dn.onDragLeave,onDrop:dn.onDrop,children:[B==="visual"?o.jsx(Rw,{ref:_,html:vn($).body,onChange:u=>G(u,!0),onBeforeInput:Uc,onPointerDown:Gc,onContextMenu:Wc,placeholder:b,disabled:D}):o.jsx(Mw,{ref:Ce,html:$,onChange:u=>Se(u,!0),placeholder:b,disabled:D}),dn.dragging?o.jsx(Bw,{}):null]}),L&&(Ke==="bottom"||Ke==="right")?o.jsx("div",{className:De.iconChrome,onPointerDownCapture:go,children:o.jsx(qo,{catalog:er,layout:Po,commands:Nt,queries:Ao,disabled:D,menuVisible:!1,toolbarVisible:!0,position:Ke})}):null]}),ue?o.jsx(Fw,{onClick:()=>we(!1)}):null,o.jsx(O1,{open:Xr,catalog:er,groups:tr.iconGroups,settings:Yr,loading:Fc,busy:Bc,disabled:D,onChange:u=>{Pa(u)},onReset:()=>{Pa(null)},onClose:()=>aa(!1)}),o.jsx(a1,{open:an.open,html:an.html,onClose:()=>la({open:!1,html:an.html})}),o.jsx(_y,{open:on.open,tab:on.tab,size:Yt.value,unit:Yt.unit,marks:En,fontFamily:Jt.value,fontFamilyMixed:Jt.mixed,fontColor:Qt.value,fontColorMixed:Qt.mixed,highlightColor:tn.value,highlightColorMixed:tn.mixed,fonts:at,disabled:D,onTabChange:u=>Nn({open:!0,tab:u}),onApply:u=>ae.applyFontProperties(u),onClose:()=>Nn({open:!1,tab:on.tab})}),o.jsx(Vy,{open:yt.open,tab:yt.tab,value:yt.value,disabled:D,onTabChange:u=>_n({...yt,open:!0,tab:u}),onApply:u=>ae.applyParagraphProperties(u),onClose:()=>_n({...yt,open:!1})}),o.jsx(Zy,{open:xt.open,tab:xt.tab,value:xt.value,fonts:at,disabled:D,onTabChange:u=>In({...xt,open:!0,tab:u}),onApply:u=>ae.applyPageProperties(u),onClose:()=>In({...xt,open:!1})}),o.jsx(tx,{open:be.open,mode:be.open?be.mode:"create",styleId:be.open&&be.mode==="edit"?be.style.id:void 0,name:be.open&&be.mode==="edit"?be.style.name:"",font:be.open?be.mode==="edit"?be.style.font:be.font:{size:null,unit:Ct,marks:Qe(),fontFamily:null,fontColor:null,highlightColor:null},paragraph:be.open?be.mode==="edit"?be.style.paragraph:be.paragraph:void 0,canDelete:!!W,fonts:at,busy:Hc,disabled:D,onSave:async u=>{const f=pa.current;if(f){Fn(!0);try{await f(u),ln({open:!1}),await Xn()}finally{Fn(!1)}}},onDelete:async u=>{const f=ha.current;if(f){Fn(!0);try{await f(u),ln({open:!1}),await Xn()}finally{Fn(!1)}}},onClose:()=>ln({open:!1})}),o.jsx(Nx,{open:Ae.open,tab:Ae.tab,href:Ae.href,title:Ae.title,targetBlank:Ae.targetBlank,textDecorationNone:Ae.textDecorationNone,hoverMode:Ae.hoverMode,hoverColor:Ae.hoverColor,hoverHtml:Ae.hoverHtml,bookmarks:Ae.bookmarks,selectedBookmarkId:Ae.selectedBookmarkId,disabled:D,onTabChange:u=>Bn({...Ae,open:!0,tab:u}),onApply:u=>ae.applyLink(u),onClose:()=>Bn({...Ae,open:!1})}),o.jsx(rx,{open:no.open,existingIds:no.existingIds,disabled:D,onApply:u=>ae.applyBookmark(u),onClose:()=>ro({...no,open:!1})}),o.jsx(ax,{open:zc.open,disabled:D,customImagePicker:O,onApply:u=>ae.applyImage(u),onCustomPick:()=>{Hn({open:!1}),O==null||O.onPick(Do)},onClose:()=>Hn({open:!1})}),o.jsx(Cx,{open:zn.open,tab:zn.tab,value:zn.value,aspectRatio:zn.aspectRatio,disabled:D,onTabChange:u=>On(f=>({...f,tab:u})),onApply:u=>ae.applyImageProperties(u),onClose:()=>On(u=>({...u,open:!1}))}),o.jsx(Fx,{open:oo.open,disabled:D,onApply:u=>ae.applyTable(u),onClose:()=>io({open:!1})}),o.jsx(Kx,{open:Kn.open,value:Kn.value,disabled:D,onApply:u=>ae.applyTableProperties(u),onClose:()=>ao(u=>({...u,open:!1}))}),o.jsx(Gx,{open:$n.open,value:$n.value,disabled:D,onApply:u=>ae.applyCellProperties(u),onClose:()=>lo(u=>({...u,open:!1}))}),o.jsx(Yx,{open:Un.open,value:Un.value,disabled:D,onApply:u=>ae.applyRowProperties(u),onClose:()=>so(u=>({...u,open:!1}))}),B==="visual"&&!D&&(ye!=null&&ye.isConnected)?o.jsx(Tx,{img:ye,onResize:Kc,onResizeEnd:$c}):null,o.jsx(Zu,{open:sn.open,x:sn.x,y:sn.y,kind:sn.kind,inTable:sn.inTable,commands:Nt,onClose:()=>co(u=>({...u,open:!1}))})]})})})}function Iw({toolbarBackground:e,menuColor:t,menuBackground:n,menuFontSize:r,menuFontFamily:i,border:a}){const l={};return e&&(l["--wysiwyg-toolbar-background"]=e),t&&(l["--wysiwyg-menu-color"]=t),n&&(l["--wysiwyg-menu-background"]=n),r&&(l["--wysiwyg-menu-font-size"]=r),i&&(l["--wysiwyg-menu-font-family"]=i),a==="none"?(l["--wysiwyg-border-width"]="0",l["--wysiwyg-border-radius"]="0",l["--wysiwyg-border-shadow"]="none"):a&&(a.width&&(l["--wysiwyg-border-width"]=a.width),a.color&&(l["--wysiwyg-border-color"]=a.color),a.radius&&(l["--wysiwyg-border-radius"]=a.radius),a.shadow&&(l["--wysiwyg-border-shadow"]=a.shadow)),Object.keys(l).length?l:void 0}function Fw({onClick:e}){const t=V();return o.jsx("button",{type:"button",className:De.exitFullscreen,"aria-label":t("exitFullscreenAria"),onClick:e,children:o.jsx(We,{className:De.exitFullscreenIcon})})}function Bw(){const e=V();return o.jsx("div",{className:De.htmlFileDropOverlay,"aria-hidden":"true",children:e("htmlFileDropOverlay")})}exports.Editor=_w;
|