superdoc 2.4.0-next.32 → 2.4.0-next.34

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.
@@ -99,10 +99,10 @@ js: import "konva/skia-backend";
99
99
  `,y_=()=>{if(typeof document>"u")throw new Error(sD)},Xi=class rI{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new rI(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),o=this.m[0]*n+this.m[2]*r,i=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=o,this.m[1]=i,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,o=this.m[1]+this.m[3]*n,i=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=i,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],o=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,o=-this.m[2]*t,i=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],o=this.m[3],i=this.m[4],s=this.m[5],a=t*o-n*r,l={x:i,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const c=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/c):-Math.acos(t/c),l.scaleX=c,l.scaleY=a/c,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const c=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/c):-Math.acos(r/c)),l.scaleX=a/c,l.scaleY=c,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=Ee._getRotation(l.rotation),l}},aD="[object Array]",lD="[object Number]",cD="[object String]",uD="[object Boolean]",dD=Math.PI/180,fD=180/Math.PI,df="#",hD="",pD="0",mD="Konva warning: ",b_="Konva error: ",gD="rgb(",b0={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},vD=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Np=[],ff=null,yD=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)},Ee={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===aD},_isNumber(e){return Object.prototype.toString.call(e)===lD&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===cD},_isBoolean(e){return Object.prototype.toString.call(e)===uD},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){Np.push(e),Np.length===1&&yD(function(){const t=Np;Np=[],t.forEach(function(n){n()})})},createCanvasElement(){y_();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return y_(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=Ee.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(df,hD);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=pD+e;return df+e},isCanvasFarblingActive(){if(ff!==null)return ff;if(typeof document>"u")return ff=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let o=0;o<100;o++)if(n[o*4]!==40||n[o*4+1]!==40||n[o*4+2]!==40||n[o*4+3]!==255){r=!0;break}return ff=r,this.releaseCanvas(e),ff},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),df+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return df+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in b0?(t=b0[e],{r:t[0],g:t[1],b:t[2]}):e[0]===df?this._hexToRgb(e.substring(1)):e.substr(0,4)===gD?(t=vD.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",Ee._namedColorToRBA(e)||Ee._hex3ColorToRGBA(e)||Ee._hex4ColorToRGBA(e)||Ee._hex6ColorToRGBA(e)||Ee._hex8ColorToRGBA(e)||Ee._rgbColorToRGBA(e)||Ee._rgbaColorToRGBA(e)||Ee._hslColorToRGBA(e)},_namedColorToRBA(e){const t=b0[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,o=Number(n[1])/100,i=Number(n[2])/100;let s,a,l;if(o===0)return l=i*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};i<.5?s=i*(1+o):s=i+o-i*o;const c=2*i-s,u=[0,0,0];for(let f=0;f<3;f++)a=r+1/3*-(f-1),a<0&&a++,a>1&&a--,6*a<1?l=c+(s-c)*6*a:2*a<1?l=s:3*a<2?l=c+(s-c)*(2/3-a)*6:l=c,u[f]=l*255;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*dD},radToDeg(e){return e*fD},_degToRad(e){return Ee.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Ee.degToRad(e)},_radToDeg(e){return Ee.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Ee.radToDeg(e)},_getRotation(e){return _t.angleDeg?Ee.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(b_+e)},error(e){console.error(b_+e)},warn(e){_t.showWarnings&&console.warn(mD+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,o,i){let s,a,l;const c=(e-n)*(e-n)+(t-r)*(t-r);if(c==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const u=((o-e)*(n-e)+(i-t)*(r-t))/c;u<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):u>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+u*(n-e),a=t+u*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=Ee.cloneObject(e);let o=Number.MAX_VALUE;return t.forEach(function(i,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=Ee._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),c=l[0],u=l[1],f=l[2];f<o&&(r.x=c,r.y=u,o=f)}),r},_prepareArrayForTween(e,t,n){const r=[],o=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)o.push({x:t[s],y:t[s+1]});const i=[];return o.forEach(function(s){const a=Ee._getProjectionToLine(s,r,n);i.push(a.x),i.push(a.y)}),i},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||Ee._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(Ee._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){_t.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let o=t<0?t:0,i=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,c=0;typeof r=="number"?s=a=l=c=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),c=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(o+s,i),e.lineTo(o+t-a,i),e.arc(o+t-a,i+a,a,Math.PI*3/2,0,!1),e.lineTo(o+t,i+n-c),e.arc(o+t-c,i+n-c,c,0,Math.PI/2,!1),e.lineTo(o+l,i+n),e.arc(o+l,i+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(o,i+s),e.arc(o+s,i+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,o){r=Math.abs(r);for(let i=0;i<n;i++){const s=t[(i-1+n)%n],a=t[i],l=t[(i+1)%n],c={x:a.x-s.x,y:a.y-s.y},u={x:l.x-a.x,y:l.y-a.y},f=Math.hypot(c.x,c.y),h=Math.hypot(u.x,u.y);let g;typeof o=="number"?g=o:g=i<o.length?o[i]:0,g=r*Math.cos(Math.PI/n)*Math.min(1,g/r*2);const m={x:c.x/f,y:c.y/f},v={x:u.x/h,y:u.y/h},k={x:a.x-m.x*g,y:a.y-m.y*g},C={x:a.x+v.x*g,y:a.y+v.y*g};i===0?e.moveTo(k.x,k.y):e.lineTo(k.x,k.y),e.arcTo(a.x,a.y,C.x,C.y,g)}}};function bD(e){const t=[],n=e.length,r=Ee;for(let o=0;o<n;o++){let i=e[o];r._isNumber(i)?i=Math.round(i*1e3)/1e3:r._isString(i)||(i=i+""),t.push(i)}return t}var w_=",",wD="(",CD=")",kD="([",SD="])",_D=";",AD="()",ID="=",C_=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],xD=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],ED=100,Bp=null;function k_(){if(Bp!==null)return Bp;try{const e=Ee.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(Bp=!1,!1)}catch{return Bp=!1,!1}}var zp=class{constructor(e){this.canvas=e,_t.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,o="",i,s,a,l;for(i=0;i<r;i++)s=n[i],a=s.method,a?(l=s.args,o+=a,e?o+=AD:Ee._isArray(l[0])?o+=kD+l.join(w_)+SD:(t&&(l=l.map(c=>typeof c=="number"?Math.floor(c):c)),o+=wD+l.join(w_)+CD)):(o+=s.property,e||(o+=ID+s.val)),o+=_D;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ED&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,o,i){this._context.arc(e,t,n,r,o,i)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,i){this._context.bezierCurveTo(e,t,n,r,o,i)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,o,i){return this._context.createRadialGradient(e,t,n,r,o,i)}drawImage(e,t,n,r,o,i,s,a,l){const c=arguments,u=this._context;c.length===3?u.drawImage(e,t,n):c.length===5?u.drawImage(e,t,n,r,o):c.length===9&&u.drawImage(e,t,n,r,o,i,s,a,l)}ellipse(e,t,n,r,o,i,s,a){this._context.ellipse(e,t,n,r,o,i,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,o){this._context.roundRect(e,t,n,r,o)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,o,i){this._context.setTransform(e,t,n,r,o,i)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,o,i){this._context.transform(e,t,n,r,o,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=C_.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=bD(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:o}),l}};for(r=0;r<t;r++)i(C_[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};xD.forEach(function(e){Object.defineProperty(zp.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var TD=class extends zp{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const i=e.getFillRadialGradientColorStops();if(i&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):i&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let i=0;i<r.length;i+=2)o.addColorStop(r[i],r[i+1]);this.setAttr("strokeStyle",o)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=a.x*l,u=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(c),Math.abs(u))),this.setAttr("shadowOffsetX",s.x*c),this.setAttr("shadowOffsetY",s.y*u)}},RD=class extends zp{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const o=this.getCanvas().getPixelRatio();this.setTransform(o,0,0,o,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},Vp;function LD(){if(Vp)return Vp;const e=Ee.createCanvasElement(),t=e.getContext("2d");return Vp=(function(){return(_t._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),Ee.releaseCanvas(e),Vp}var w0=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const t=(e||{}).pixelRatio||_t.pixelRatio||LD();this.pixelRatio=t,this._canvas=Ee.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return Ee.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},ol=class extends w0{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new TD(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},C0=class extends w0{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new RD(this),this.setSize(e.width,e.height)}},Dn={get isDragging(){let e=!1;return Dn._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Dn._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Dn._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=Ee._getFirstPointerId(e));const s=i._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=o.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,n),t.push(o)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Dn._dragElements.forEach(n=>{const{node:r}=n,o=r.getStage();if(e&&o.setPointersPositions(e),!o._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Dn.justDragged=!0,_t._mouseListenClick=!1,_t._touchListenClick=!1,_t._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof _t.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Dn._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Dn._dragElements.delete(n)})}};_t.isBrowser&&(window.addEventListener("mouseup",Dn._endDragBefore,!0),window.addEventListener("touchend",Dn._endDragBefore,!0),window.addEventListener("touchcancel",Dn._endDragBefore,!0),window.addEventListener("mousemove",Dn._drag),window.addEventListener("touchmove",Dn._drag),window.addEventListener("mouseup",Dn._endDragAfter,!1),window.addEventListener("touchend",Dn._endDragAfter,!1),window.addEventListener("touchcancel",Dn._endDragAfter,!1));function il(e){return Ee._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||Ee._isBoolean(e)?e:Object.prototype.toString.call(e)}function S_(e){return e>255?255:e<0?0:Math.round(e)}function wt(){if(_t.isUnminified)return function(e,t){return Ee._isNumber(e)||Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function jp(e){if(_t.isUnminified)return function(t,n){let r=Ee._isNumber(t),o=Ee._isArray(t)&&t.length==e;return!r&&!o&&Ee.warn(il(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function k0(){if(_t.isUnminified)return function(e,t){return Ee._isNumber(e)||e==="auto"||Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Yl(){if(_t.isUnminified)return function(e,t){return Ee._isString(e)||Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function __(){if(_t.isUnminified)return function(e,t){const n=Ee._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function MD(){if(_t.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(Ee._isArray(e)?e.forEach(function(r){Ee._isNumber(r)||Ee.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Zi(){if(_t.isUnminified)return function(e,t){return e===!0||e===!1||Ee.warn(il(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function PD(e){if(_t.isUnminified)return function(t,n){return t==null||Ee.isObject(t)||Ee.warn(il(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var hf="get",pf="set",ce={addGetterSetter(e,t,n,r,o){ce.addGetter(e,t,n),ce.addSetter(e,t,r,o),ce.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=hf+Ee._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const o=this.attrs[t];return o===void 0?n:o}},addSetter(e,t,n,r){const o=pf+Ee._capitalize(t);e.prototype[o]||ce.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=pf+Ee._capitalize(t);e.prototype[o]=function(i){return n&&i!==void 0&&i!==null&&(i=n.call(this,i,t)),this._setAttr(t,i),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,o){const i=n.length,s=Ee._capitalize,a=hf+s(t),l=pf+s(t);e.prototype[a]=function(){const u={};for(let f=0;f<i;f++){const h=n[f];u[h]=this.getAttr(t+s(h))}return u};const c=PD(n);e.prototype[l]=function(u){const f=this.attrs[t];r&&(u=r.call(this,u,t)),c&&c.call(this,u,t);for(const h in u)u.hasOwnProperty(h)&&this._setAttr(t+s(h),u[h]);return u||n.forEach(h=>{this._setAttr(t+s(h),void 0)}),this._fireChangeEvent(t,f,u),o&&o.call(this),this},ce.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=Ee._capitalize(t),r=pf+n,o=hf+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){Ee.error("Adding deprecated "+t);const o=hf+Ee._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Ee.error(i);const s=this.attrs[t];return s===void 0?n:s},ce.addSetter(e,t,r,function(){Ee.error(i)}),ce.addOverloadedGetterSetter(e,t)},backCompat(e,t){Ee.each(t,function(n,r){const o=e.prototype[r],i=hf+Ee._capitalize(n),s=pf+Ee._capitalize(n);function a(){o.apply(this,arguments),Ee.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[i]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function DD(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,o]=n;switch(r){case"blur":{const i=parseFloat(o.replace("px",""));return function(s){this.blurRadius(i*.5);const a=_t.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const i=o.includes("%")?parseFloat(o)/100:parseFloat(o);return function(s){this.brightness(i);const a=_t.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const i=parseFloat(o);return function(s){const a=100*(Math.sqrt(i)-1);this.contrast(a);const l=_t.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=_t.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=_t.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=_t.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:Ee.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}var Up="absoluteOpacity",A_="allEventListeners",_a="absoluteTransform",I_="absoluteScale",Xl="canvas",OD="Change",FD="children",ND="konva",S0="listening",BD="mouseenter",zD="mouseleave",VD="pointerenter",jD="pointerleave",UD="touchenter",HD="touchleave",x_="set",E_="Shape",Hp=" ",T_="stage",sl="transform",$D="Stage",_0="visible",GD=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Hp),WD=1,At=class Qf{constructor(t){this._id=WD++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===sl||t===_a)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===sl||t===_a)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const o=n.map(i=>i+"Change.konva").join(Hp);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(Xl)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===_a&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Xl)){const{scene:t,filter:n,hit:r}=this._cache.get(Xl);Ee.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(Xl)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let o=Math.ceil(n.width||r.width),i=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,c=n.offset||0,u=n.drawBorder||!1,f=n.hitCanvasPixelRatio||1;if(!o||!i){Ee.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const h=Math.abs(Math.round(r.x)-a)>.5?1:0,g=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=c*2+h,i+=c*2+g,a-=c,l-=c;const m=new ol({pixelRatio:s,width:o,height:i}),v=new ol({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),k=new C0({pixelRatio:f,width:o,height:i}),C=m.getContext(),_=k.getContext(),y=new ol({width:m.width/m.pixelRatio+Math.abs(a),height:m.height/m.pixelRatio+Math.abs(l),pixelRatio:m.pixelRatio}),w=y.getContext();return k.isCache=!0,m.isCache=!0,this._cache.delete(Xl),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(m.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),C.save(),_.save(),w.save(),C.translate(-a,-l),_.translate(-a,-l),w.translate(-a,-l),y.x=a,y.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(Up),this._clearSelfAndDescendantCache(I_),this.drawScene(m,this,y),this.drawHit(k,this),this._isUnderCache=!1,C.restore(),_.restore(),u&&(C.save(),C.beginPath(),C.rect(0,0,o,i),C.closePath(),C.setAttr("strokeStyle","red"),C.setAttr("lineWidth",5),C.stroke(),C.restore()),Ee.releaseCanvas(y._canvas),this._cache.set(Xl,{scene:m,filter:v,hit:k,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Xl)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let o=1/0,i=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(c){const u=l.point(c);o===void 0&&(o=s=u.x,i=a=u.y),o=Math.min(o,u.x),i=Math.min(i,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}),{x:o,y:i,width:s-o,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),o=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/o,r.height/o),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,o=n.filter,i=o.getContext(),s,a,l,c;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let u=!0;for(let h=0;h<t.length;h++)if(typeof t[h]=="string"&&k_(),typeof t[h]!="string"||!k_()){u=!1;break}const f=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),u){const h=t.join(" ");return i.save(),i.setAttr("filter",h),i.drawImage(r._canvas,0,0,r.getWidth()/f,r.getHeight()/f),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/f,r.getHeight()/f),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)c=t[l],typeof c=="string"&&(c=DD(c)),c.call(this,a),i.putImageData(a,0,0)}catch(h){Ee.error("Unable to apply filter. "+h.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(A_),t.length===3)return this._delegate.apply(this,t);const o=n.split(Hp);for(let i=0;i<o.length;i++){const s=o[i].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(Hp),o=r.length,i,s,a,l,c,u;if(this._cache&&this._cache.delete(A_),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),c=l[0],u=l[1],c)this.eventListeners[c]&&this._off(c,u,n);else for(s in this.eventListeners)this._off(s,u,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const o=this;return this.on(t,function(i){const s=i.target.findAncestors(n,!0,o);for(let a=0;a<s.length;a++)i=Ee.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Dn._dragElements.delete(this._id),Dn._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Dn._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(_a),this._clearSelfAndDescendantCache(Up),this._clearSelfAndDescendantCache(I_),this._clearSelfAndDescendantCache(T_),this._clearSelfAndDescendantCache(_0),this._clearSelfAndDescendantCache(S0)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+Ee._capitalize(t);return Ee._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==FD&&(r=x_+Ee._capitalize(n),Ee._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(S0,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(_0,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let o=!1;Dn._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!_t.hitOnDragEnabled&&(o||_t.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,o,i,s,a;function l(u){for(o=[],i=u.length,s=0;s<i;s++)a=u[s],r++,a.nodeType!==E_&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const c=this.getStage();return n.nodeType!==$D&&c&&l(c.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(sl),this._clearSelfAndDescendantCache(_a)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const o=this.getAbsoluteTransform(t).getMatrix(),i=new Xi,s=this.offset();return i.m=o.slice(),i.translate(s.x,s.y),i.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...o}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(sl);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(o),this.setPosition({x:t.x,y:t.y}),this._clearCache(sl),this._clearSelfAndDescendantCache(_a),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,o=this.x(),i=this.y();return n!==void 0&&(o+=n),r!==void 0&&(i+=r),this.setPosition({x:o,y:i}),this}_eachAncestorReverse(t,n){let r=[],o=this.getParent(),i,s;if(!(n&&n._id===this._id)){for(r.unshift(this);o&&(!n||o._id!==n._id);)r.unshift(o),o=o.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Ee.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Ee.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Ee.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Ee.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return Ee.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Ee.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Up,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,o,i,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=Ee.isObject(r)&&!Ee._isPlainObject(r)&&!Ee._isArray(r),!s&&(o=typeof this[n]=="function"&&this[n],delete t[n],i=o?o.call(this):null,t[n]=r,i!==r&&(a.attrs[n]=r));return Ee._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const o=[];n&&this._isMatch(t)&&o.push(this);let i=this.parent;for(;i;){if(i===r)return o;i._isMatch(t)&&o.push(i),i=i.parent}return o}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,o,i;for(o=0;o<r;o++)if(i=n[o],Ee.isValidSelector(i)||(Ee.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Ee.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Ee.warn("Konva is awesome, right?")),i.charAt(0)==="#"){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)==="."){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(T_,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(_a,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new Xi,this._eachAncestorReverse(function(r){const o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(_a)||new Xi,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const o=this.attrs.x||0,i=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(o-s,i-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(sl,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(sl)||new Xi;r.reset();const o=this.x(),i=this.y(),s=_t.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,c=this.attrs.skewX||0,u=this.attrs.skewY||0,f=this.attrs.offsetX||0,h=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(c!==0||u!==0)&&r.skew(c,u),(a!==1||l!==1)&&r.scale(a,l),(f!==0||h!==0)&&r.translate(-1*f,-1*h),r.dirty=!1,r}clone(t){let n=Ee.cloneObject(this.attrs),r,o,i,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(o=this.eventListeners[r],i=o.length,s=0;s<i;s++)a=o[s],a.name.indexOf(ND)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),o=t.x!==void 0?t.x:Math.floor(n.x),i=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new ol({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),c=new ol({width:a.width/a.pixelRatio+Math.abs(o),height:a.height/a.pixelRatio+Math.abs(i),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(o||i)&&l.translate(-1*o,-1*i),this.drawScene(a,void 0,c),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,o=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(o),o}toImage(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,Ee._urlToImage(this.toDataURL(t),function(i){n(i),o?.(i)})}catch(o){r(o)}})}toBlob(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,this.toCanvas(t).toBlob(i=>{n(i),o?.(i)},t?.mimeType,t?.quality)}catch(o){r(o)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():_t.dragDistance}_off(t,n,r){let o=this.eventListeners[t],i,s,a;for(i=0;i<o.length;i++)if(s=o[i].name,a=o[i].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(o.splice(i,1),o.length===0){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,n,r){this._fire(t+OD,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[x_+Ee._capitalize(t)];return Ee._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(_t.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!Ee.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let o;r!==void 0&&(o=this.attrs[t],o||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,o,r))}_fireAndBubble(t,n,r){n&&this.nodeType===E_&&(n.target=this);const o=[BD,zD,VD,jD,UD,HD];if(!(o.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const i=o.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!i&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:o}=this,i=Qf.protoListenerMap.get(o)||{};let s=i?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}i[t]=s,Qf.protoListenerMap.set(o,i)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const i=r.slice();for(let s=0;s<i.length;s++)i[s].handler.call(this,n)}const o=this.eventListeners[t];if(o){const i=o.slice(),s=i.length;for(let l=0;l<i.length;l++)i[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),o=this.getAbsolutePosition();if(!r)return;const i=r._getPointerById(n)||r._changedPointerPositions[0]||o;Dn._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-o.x,y:i.y-o.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Dn._dragElements.has(this._id)||this._createDragElement(t);const r=Dn._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let o={x:r.x-n.offset.x,y:r.y-n.offset.y};const i=this.dragBoundFunc();if(i!==void 0){const s=i.call(this,o,t);s?o=s:Ee.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==o.x||this._lastPos.y!==o.y)&&(this.setAbsolutePosition(o),this._requestDraw()),this._lastPos=o}stopDrag(t){const n=Dn._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Dn._endDragBefore(t),Dn._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Dn._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||_t.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Dn._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Dn._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Dn._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return Ee.haveIntersection(r,this.getClientRect())}static create(t,n){return Ee._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=Qf.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),_t[r]||(Ee.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=_t[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(Qf._createNode(o[a]));return i}};At.protoListenerMap=new Map,At.prototype.nodeType="Node",At.prototype._attrsAffectingSize=[],At.prototype.eventListeners={},At.prototype.on(GD,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(sl),this._clearSelfAndDescendantCache(_a)}),At.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(_0)}),At.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(S0)}),At.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(Up)});var tr=ce.addGetterSetter;tr(At,"zIndex"),tr(At,"absolutePosition"),tr(At,"position"),tr(At,"x",0,wt()),tr(At,"y",0,wt()),tr(At,"globalCompositeOperation","source-over",Yl()),tr(At,"opacity",1,wt()),tr(At,"name","",Yl()),tr(At,"id","",Yl()),tr(At,"rotation",0,wt()),ce.addComponentsGetterSetter(At,"scale",["x","y"]),tr(At,"scaleX",1,wt()),tr(At,"scaleY",1,wt()),ce.addComponentsGetterSetter(At,"skew",["x","y"]),tr(At,"skewX",0,wt()),tr(At,"skewY",0,wt()),ce.addComponentsGetterSetter(At,"offset",["x","y"]),tr(At,"offsetX",0,wt()),tr(At,"offsetY",0,wt()),tr(At,"dragDistance",void 0,wt()),tr(At,"width",0,wt()),tr(At,"height",0,wt()),tr(At,"listening",!0,Zi()),tr(At,"preventDefault",!0,Zi()),tr(At,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),tr(At,"visible",!0,Zi()),tr(At,"transformsEnabled","all",Yl()),tr(At,"size"),tr(At,"dragBoundFunc"),tr(At,"draggable",!1,Zi()),ce.backCompat(At,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Ci=class extends At{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&n.push(r),!!(o&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=At.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=At.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas(),i=o&&o.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=o&&o.isCache;if(!this.isVisible()&&!l)return this;if(a){i.save();const c=this.getAbsoluteTransform(t).getMatrix();i.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",o,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),i=this._getCanvasCache();if(i&&i.hit){o.save();const s=this.getAbsoluteTransform(t).getMatrix();o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var o;const i=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),c=typeof s=="number"&&typeof a=="number"||l,u=n===this;if(c){i.save();const h=this.getAbsoluteTransform(n);let g=h.getMatrix();i.transform(g[0],g[1],g[2],g[3],g[4],g[5]),i.beginPath();let m;if(l)m=l.call(this,i,this);else{const v=this.clipX(),k=this.clipY();i.rect(v||0,k||0,s,a)}i.clip.apply(i,m),g=h.copy().invert().getMatrix(),i.transform(g[0],g[1],g[2],g[3],g[4],g[5])}const f=!u&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";f&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(h){h[e](t,n,r)}),f&&i.restore(),c&&i.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let o,i,s,a,l={x:1/0,y:1/0,width:0,height:0};const c=this;(t=this.children)===null||t===void 0||t.forEach(function(h){if(!h.visible())return;const g=h.getClientRect({relativeTo:c,skipShadow:e.skipShadow,skipStroke:e.skipStroke});g.width===0&&g.height===0||(o===void 0?(o=g.x,i=g.y,s=g.x+g.width,a=g.y+g.height):(o=Math.min(o,g.x),i=Math.min(i,g.y),s=Math.max(s,g.x+g.width),a=Math.max(a,g.y+g.height)))});const u=this.find("Shape");let f=!1;for(let h=0;h<u.length;h++)if(u[h]._isVisible(this)){f=!0;break}return f&&o!==void 0?l={x:o,y:i,width:s-o,height:a-i}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};ce.addComponentsGetterSetter(Ci,"clip",["x","y","width","height"]),ce.addGetterSetter(Ci,"clipX",void 0,wt()),ce.addGetterSetter(Ci,"clipY",void 0,wt()),ce.addGetterSetter(Ci,"clipWidth",void 0,wt()),ce.addGetterSetter(Ci,"clipHeight",void 0,wt()),ce.addGetterSetter(Ci,"clipFunc");var mf=new Map,R_=_t._global.PointerEvent!==void 0;function A0(e){return mf.get(e)}function I0(e){return{evt:e,pointerId:e.pointerId}}function L_(e,t){return mf.get(e)===t}function M_(e,t){gf(e),t.getStage()&&(mf.set(e,t),R_&&t._fire("gotpointercapture",I0(new PointerEvent("gotpointercapture"))))}function gf(e,t){const n=mf.get(e);if(!n)return;const r=n.getStage();r&&r.content,mf.delete(e),R_&&n._fire("lostpointercapture",I0(new PointerEvent("lostpointercapture")))}var KD="Stage",qD="string",P_="px",YD="mouseout",D_="mouseleave",O_="mouseover",F_="mouseenter",N_="mousemove",B_="mousedown",z_="mouseup",vf="pointermove",yf="pointerdown",uu="pointerup",bf="pointercancel",XD="lostpointercapture",$p="pointerout",wf="pointerleave",Gp="pointerover",Wp="pointerenter",x0="contextmenu",V_="touchstart",j_="touchend",U_="touchmove",H_="touchcancel",E0="wheel",ZD=5,QD=[[F_,"_pointerenter"],[B_,"_pointerdown"],[N_,"_pointermove"],[z_,"_pointerup"],[D_,"_pointerleave"],[V_,"_pointerdown"],[U_,"_pointermove"],[j_,"_pointerup"],[H_,"_pointercancel"],[O_,"_pointerover"],[E0,"_wheel"],[x0,"_contextmenu"],[yf,"_pointerdown"],[vf,"_pointermove"],[uu,"_pointerup"],[bf,"_pointercancel"],[wf,"_pointerleave"],[XD,"_lostpointercapture"]],T0={mouse:{[$p]:YD,[wf]:D_,[Gp]:O_,[Wp]:F_,[vf]:N_,[yf]:B_,[uu]:z_,[bf]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[$p]:"touchout",[wf]:"touchleave",[Gp]:"touchover",[Wp]:"touchenter",[vf]:U_,[yf]:V_,[uu]:j_,[bf]:H_,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[$p]:$p,[wf]:wf,[Gp]:Gp,[Wp]:Wp,[vf]:vf,[yf]:yf,[uu]:uu,[bf]:bf,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Cf=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",du=e=>{const t=Cf(e);if(t==="pointer")return _t.pointerEventsEnabled&&T0.pointer;if(t==="touch")return T0.touch;if(t==="mouse")return T0.mouse};function $_(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&Ee.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var JD="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);",kf=[],Kp=class extends Ci{constructor(e){super($_(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),kf.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{$_(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||Ee.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===qD){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Ci.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&Ee._isInDocument(e)&&this.container().removeChild(e);const t=kf.indexOf(this);return t>-1&&kf.splice(t,1),Ee.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Ee.warn(JD),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new ol({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(!o.isVisible())return;const i=o._toKonvaCanvas(e);n.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const o=t[r].getIntersection(e);if(o)return o}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+P_,this.content.style.height=t+P_),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>ZD&&Ee.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),_t.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return L_(e,this)}setPointerCapture(e){M_(e,this)}releaseCapture(e){gf(e,this)}getLayers(){return this.children}_bindContentEvents(){_t.isBrowser&&QD.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=du(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=du(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=du(e.type),n=Cf(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(_t.isDragging()||_t.isTransforming())||_t.hitOnDragEnabled;r&&o?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):o&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=du(e.type),n=Cf(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Dn.justDragged=!1,_t["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}_t.capturePointerEventsEnabled&&i.setPointerCapture(o.id),this[n+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const s=e.type.indexOf("touch")>=0;i.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=du(e.type),n=Cf(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(_t.isDragging()&&Dn.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(_t.isDragging()||_t.isTransforming())||_t.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=A0(a.id)||this.getIntersection(a),c=a.id,u={evt:e,pointerId:c},f=s!==l;if(f&&s&&(s._fireAndBubble(t.pointerout,{...u},l),s._fireAndBubble(t.pointerleave,{...u},l)),l){if(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!0,f&&(l._fireAndBubble(t.pointerover,{...u},s),l._fireAndBubble(t.pointerenter,{...u},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...u})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=du(e.type),n=Cf(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],i={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=A0(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const c=a.id,u={evt:e,pointerId:c};let f=!1;_t["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this[n+"DblTimeout"])):Dn.justDragged||(_t["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){_t["_"+n+"InDblClickWindow"]=!1},_t.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...u}),_t["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...u}),f&&o&&o===l&&l._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),_t["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:c}),f&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:c}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),_t["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(x0,{evt:e}):this._fire(x0,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(E0,{evt:e}):this._fire(E0,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=A0(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(uu,I0(e)),gf(e.pointerId)}_lostpointercapture(e){gf(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:Ee._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:Ee._getFirstPointerId(e)}])}_setPointerPosition(e){Ee.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new ol({width:this.width(),height:this.height()}),this.bufferHitCanvas=new C0({pixelRatio:1,width:this.width(),height:this.height()}),!_t.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return Ee.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};Kp.prototype.nodeType=KD,wr(Kp),ce.addGetterSetter(Kp,"container"),_t.isBrowser&&document.addEventListener("visibilitychange",()=>{kf.forEach(e=>{e.batchDraw()})});var G_="hasShadow",W_="shadowRGBA",K_="patternImage",q_="linearGradient",Y_="radialGradient",qp;function R0(){return qp||(qp=Ee.createCanvasElement().getContext("2d"),qp)}var Sf={};function eO(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function tO(e){e.stroke()}function nO(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function rO(e){e.stroke()}function oO(){this._clearCache(G_)}function iO(){this._clearCache(W_)}function sO(){this._clearCache(K_)}function aO(){this._clearCache(q_)}function lO(){this._clearCache(Y_)}var pt=class extends At{constructor(e){super(e);let t,n=0;for(;t=Ee.getHitColor(),!(t&&!(t in Sf));)if(n++,n>=1e4){Ee.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=Ee.getRandomColor();break}this.colorKey=t,Sf[t]=this}getContext(){return Ee.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Ee.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(G_,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(K_,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=R0().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Xi;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(_t.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(q_,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=R0(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}_getRadialGradient(){return this._getCache(Y_,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=R0(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}getShadowRGBA(){return this._getCache(W_,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=Ee.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return At.prototype.destroy.call(this),delete Sf[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),o=this.getAbsoluteOpacity()!==1;if(n&&r&&o)return!0;const i=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&i&&s)}setStrokeHitEnabled(e){Ee.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,o=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=i.width+s,l=i.height+s,c=!e.skipShadow&&this.hasShadow(),u=c?this.shadowOffsetX():0,f=c?this.shadowOffsetY():0,h=a+Math.abs(u),g=l+Math.abs(f),m=c&&this.shadowBlur()||0,v={width:h+m*2,height:g+m*2,x:-(s/2+m)+Math.min(u,0)+i.x,y:-(s/2+m)+Math.min(f,0)+i.y};return r?v:this._transformedRect(v,o)}drawScene(e,t,n){const r=this.getLayer(),o=(e||r.getCanvas()).getContext(),i=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const c=t===this;if(!this.isVisible()&&!c)return this;if(i){o.save();const u=this.getAbsoluteTransform(t).getMatrix();return o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),this._useBufferCanvas()){l=this.getStage();const u=n||l.bufferCanvas,f=u.getContext();n?(f.save(),f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,u.width,u.height),f.restore()):f.clear(),f.save(),f._applyLineJoin(this),f._applyMiterLimit(this);const h=this.getAbsoluteTransform(t).getMatrix();f.transform(h[0],h[1],h[2],h[3],h[4],h[5]),s.call(this,f,this),f.restore();const g=u.pixelRatio;a&&o._applyShadow(this),c||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(u._canvas,u.x||0,u.y||0,u.width/g,u.height/g)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!c){const u=this.getAbsoluteTransform(t).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}a&&o._applyShadow(this),s.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),o=e||r.hitCanvas,i=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||Ee.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){i.save();const c=this.getAbsoluteTransform(t).getMatrix();return i.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const c=this.getAbsoluteTransform(t).getMatrix();i.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return s.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),i=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,i,s);try{const a=o.getImageData(0,0,i,s),l=a.data,c=l.length,u=Ee._hexToRgb(this.colorKey);for(let f=0;f<c;f+=4)l[f+3]>e?(l[f]=u.r,l[f+1]=u.g,l[f+2]=u.b,l[f+3]=255):l[f+3]=0;o.putImageData(a,0,0)}catch(a){Ee.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return L_(e,this)}setPointerCapture(e){M_(e,this)}releaseCapture(e){gf(e,this)}};pt.prototype._fillFunc=eO,pt.prototype._strokeFunc=tO,pt.prototype._fillFuncHit=nO,pt.prototype._strokeFuncHit=rO,pt.prototype._centroid=!1,pt.prototype.nodeType="Shape",wr(pt),pt.prototype.eventListeners={},pt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",oO),pt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",iO),pt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",sO),pt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",aO),pt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",lO),ce.addGetterSetter(pt,"stroke",void 0,__()),ce.addGetterSetter(pt,"strokeWidth",2,wt()),ce.addGetterSetter(pt,"fillAfterStrokeEnabled",!1),ce.addGetterSetter(pt,"hitStrokeWidth","auto",k0()),ce.addGetterSetter(pt,"strokeHitEnabled",!0,Zi()),ce.addGetterSetter(pt,"perfectDrawEnabled",!0,Zi()),ce.addGetterSetter(pt,"shadowForStrokeEnabled",!0,Zi()),ce.addGetterSetter(pt,"lineJoin"),ce.addGetterSetter(pt,"lineCap"),ce.addGetterSetter(pt,"miterLimit"),ce.addGetterSetter(pt,"sceneFunc"),ce.addGetterSetter(pt,"hitFunc"),ce.addGetterSetter(pt,"dash"),ce.addGetterSetter(pt,"dashOffset",0,wt()),ce.addGetterSetter(pt,"shadowColor",void 0,Yl()),ce.addGetterSetter(pt,"shadowBlur",0,wt()),ce.addGetterSetter(pt,"shadowOpacity",1,wt()),ce.addComponentsGetterSetter(pt,"shadowOffset",["x","y"]),ce.addGetterSetter(pt,"shadowOffsetX",0,wt()),ce.addGetterSetter(pt,"shadowOffsetY",0,wt()),ce.addGetterSetter(pt,"fillPatternImage"),ce.addGetterSetter(pt,"fill",void 0,__()),ce.addGetterSetter(pt,"fillPatternX",0,wt()),ce.addGetterSetter(pt,"fillPatternY",0,wt()),ce.addGetterSetter(pt,"fillLinearGradientColorStops"),ce.addGetterSetter(pt,"strokeLinearGradientColorStops"),ce.addGetterSetter(pt,"fillRadialGradientStartRadius",0),ce.addGetterSetter(pt,"fillRadialGradientEndRadius",0),ce.addGetterSetter(pt,"fillRadialGradientColorStops"),ce.addGetterSetter(pt,"fillPatternRepeat","repeat"),ce.addGetterSetter(pt,"fillEnabled",!0),ce.addGetterSetter(pt,"strokeEnabled",!0),ce.addGetterSetter(pt,"shadowEnabled",!0),ce.addGetterSetter(pt,"dashEnabled",!0),ce.addGetterSetter(pt,"strokeScaleEnabled",!0),ce.addGetterSetter(pt,"fillPriority","color"),ce.addComponentsGetterSetter(pt,"fillPatternOffset",["x","y"]),ce.addGetterSetter(pt,"fillPatternOffsetX",0,wt()),ce.addGetterSetter(pt,"fillPatternOffsetY",0,wt()),ce.addComponentsGetterSetter(pt,"fillPatternScale",["x","y"]),ce.addGetterSetter(pt,"fillPatternScaleX",1,wt()),ce.addGetterSetter(pt,"fillPatternScaleY",1,wt()),ce.addComponentsGetterSetter(pt,"fillLinearGradientStartPoint",["x","y"]),ce.addComponentsGetterSetter(pt,"strokeLinearGradientStartPoint",["x","y"]),ce.addGetterSetter(pt,"fillLinearGradientStartPointX",0),ce.addGetterSetter(pt,"strokeLinearGradientStartPointX",0),ce.addGetterSetter(pt,"fillLinearGradientStartPointY",0),ce.addGetterSetter(pt,"strokeLinearGradientStartPointY",0),ce.addComponentsGetterSetter(pt,"fillLinearGradientEndPoint",["x","y"]),ce.addComponentsGetterSetter(pt,"strokeLinearGradientEndPoint",["x","y"]),ce.addGetterSetter(pt,"fillLinearGradientEndPointX",0),ce.addGetterSetter(pt,"strokeLinearGradientEndPointX",0),ce.addGetterSetter(pt,"fillLinearGradientEndPointY",0),ce.addGetterSetter(pt,"strokeLinearGradientEndPointY",0),ce.addComponentsGetterSetter(pt,"fillRadialGradientStartPoint",["x","y"]),ce.addGetterSetter(pt,"fillRadialGradientStartPointX",0),ce.addGetterSetter(pt,"fillRadialGradientStartPointY",0),ce.addComponentsGetterSetter(pt,"fillRadialGradientEndPoint",["x","y"]),ce.addGetterSetter(pt,"fillRadialGradientEndPointX",0),ce.addGetterSetter(pt,"fillRadialGradientEndPointY",0),ce.addGetterSetter(pt,"fillPatternRotation",0),ce.addGetterSetter(pt,"fillRule",void 0,Yl()),ce.backCompat(pt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var cO="beforeDraw",uO="draw",X_=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],dO=X_.length,Zl=class extends Ci{constructor(e){super(e),this.canvas=new ol,this.hitCanvas=new C0({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){At.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!At.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(At.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(At.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return At.prototype.remove.call(this),e&&e.parentNode&&Ee._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ee.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),At.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Ee.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Ee.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Ee.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<dO;r++){const o=X_[r],i=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),s=i.shape;if(s)return s;if(n=!!i.antialiased,!i.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const o=Ee.getHitColorKey(n[0],n[1],n[2]),i=Sf[o];return i?{shape:i}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas();return this._fire(cO,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),Ci.prototype.drawScene.call(this,o,t,n),this._fire(uO,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Ci.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Ee.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Ee.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return Ee.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Zl.prototype.nodeType="Layer",wr(Zl),ce.addGetterSetter(Zl,"imageSmoothingEnabled",!0),ce.addGetterSetter(Zl,"clearBeforeDraw",!0),ce.addGetterSetter(Zl,"hitGraphEnabled",!0,Zi());var L0=class extends Zl{constructor(e){super(e),this.listening(!1),Ee.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};L0.prototype.nodeType="FastLayer",wr(L0);var fu=class extends Ci{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ee.throw("You may only add groups and shapes to groups.")}};fu.prototype.nodeType="Group",wr(fu);var M0=(function(){return ql.performance&&ql.performance.now?function(){return ql.performance.now()}:function(){return new Date().getTime()}})(),hu=class Qu{constructor(t,n){this.id=Qu.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:M0(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let o=0;o<r;o++)if(n[o]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Qu.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=M0(),Qu._addAnimation(this),this}stop(){return Qu._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,o=r.length;for(let i=0;i<o;i++)if(r[i].id===n){this.animations.splice(i,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const o=n[r],i=o.layers,s=o.func;o._updateFrameObject(M0());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let c=0;c<a;c++){const u=i[c];u._id!==void 0&&(t[u._id]=u)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Qu;t.animations.length?(t._runFrames(),Ee.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ee.requestAnimFrame(this._animationLoop))}};hu.animations=[],hu.animIdCounter=0,hu.animRunning=!1;var fO={node:1,duration:1,easing:1,onFinish:1,yoyo:1},hO=1,Z_=2,Q_=3,J_=["fill","stroke","shadowColor"],pO=0,mO=class{constructor(e,t,n,r,o,i,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=o-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=Z_,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=Q_,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===Z_?this.setTime(e):this.state===Q_&&this.setTime(this.duration-e)}pause(){this.state=hO,this.fire("onPause")}getTimer(){return new Date().getTime()}},Yp=class Pr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||_f.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=pO++;const c=r.getLayer()||(r instanceof _t.Stage?r.getLayers():null);c||Ee.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new hu(function(){n.tween.onEnterFrame()},c),this.tween=new mO(l,function(u){n._tweenFunc(u)},i,0,1,a*1e3,s),this._addListeners(),Pr.attrs[o]||(Pr.attrs[o]={}),Pr.attrs[o][this._id]||(Pr.attrs[o][this._id]={}),Pr.tweens[o]||(Pr.tweens[o]={});for(l in t)fO[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,o=r._id;let i,s,a,l,c;const u=Pr.tweens[o][t];u&&delete Pr.attrs[o][u][t];let f=r.getAttr(t);if(Ee._isArray(n))if(i=[],s=Math.max(n.length,f.length),t==="points"&&n.length!==f.length&&(n.length>f.length?(l=f,f=Ee._prepareArrayForTween(f,n,r.closed())):(a=n,n=Ee._prepareArrayForTween(n,f,r.closed()))),t.indexOf("fill")===0)for(let h=0;h<s;h++)if(h%2===0)i.push(n[h]-f[h]);else{const g=Ee.colorToRGBA(f[h]);c=Ee.colorToRGBA(n[h]),f[h]=g,i.push({r:c.r-g.r,g:c.g-g.g,b:c.b-g.b,a:c.a-g.a})}else for(let h=0;h<s;h++)i.push(n[h]-f[h]);else J_.indexOf(t)!==-1?(f=Ee.colorToRGBA(f),c=Ee.colorToRGBA(n),i={r:c.r-f.r,g:c.g-f.g,b:c.b-f.b,a:c.a-f.a}):i=n-f;Pr.attrs[o][this._id][t]={start:f,diff:i,end:n,trueEnd:a,trueStart:l},Pr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=Pr.attrs[n._id][this._id];let o,i,s,a,l,c,u,f;for(o in r){if(i=r[o],s=i.start,a=i.diff,f=i.end,Ee._isArray(s))if(l=[],u=Math.max(s.length,f.length),o.indexOf("fill")===0)for(c=0;c<u;c++)c%2===0?l.push((s[c]||0)+a[c]*t):l.push("rgba("+Math.round(s[c].r+a[c].r*t)+","+Math.round(s[c].g+a[c].g*t)+","+Math.round(s[c].b+a[c].b*t)+","+(s[c].a+a[c].a*t)+")");else for(c=0;c<u;c++)l.push((s[c]||0)+a[c]*t);else J_.indexOf(o)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(o,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=Pr.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=Pr.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=Pr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete Pr.tweens[t][o];delete Pr.attrs[t][n],Pr.tweens[t]&&(Object.keys(Pr.tweens[t]).length===0&&delete Pr.tweens[t],Object.keys(Pr.attrs[t]).length===0&&delete Pr.attrs[t])}};Yp.attrs={},Yp.tweens={},At.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Yp(e).play()};var _f={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let o=1.70158;return(e/=r/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+t:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+t},ElasticEaseIn(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t)},ElasticEaseOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),o*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/i)+n+t)},ElasticEaseInOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r/2)===2?t+n:(i||(i=r*(.3*1.5)),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),e<1?-.5*(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-_f.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?_f.BounceEaseIn(e*2,0,n,r)*.5+t:_f.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},e4=Ee._assign(_t,{Util:Ee,Transform:Xi,Node:At,Container:Ci,Stage:Kp,stages:kf,Layer:Zl,FastLayer:L0,Group:fu,DD:Dn,Shape:pt,shapes:Sf,Animation:hu,Tween:Yp,Easings:_f,Context:zp,Canvas:w0}),Aa=class extends pt{_sceneFunc(e){const t=_t.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=_t.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),i=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=o*(o>0?e:t),c=i*t,u=s*(s>0?e:t),f=a*(a>0?t:e);return{x:l,y:n?-1*f:u,width:c-l,height:f-u}}};Aa.prototype._centroid=!0,Aa.prototype.className="Arc",Aa.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],wr(Aa),ce.addGetterSetter(Aa,"innerRadius",0,wt()),ce.addGetterSetter(Aa,"outerRadius",0,wt()),ce.addGetterSetter(Aa,"angle",0,wt()),ce.addGetterSetter(Aa,"clockwise",!1,Zi());function P0(e,t,n,r,o,i,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2)),c=s*a/(a+l),u=s*l/(a+l);return[n-c*(o-e),r-c*(i-t),n+u*(o-e),r+u*(i-t)]}function t4(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=P0(e[o-2],e[o-1],e[o],e[o+1],e[o+2],e[o+3],t);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(e[o]),r.push(e[o+1]),r.push(i[2]),r.push(i[3]))}return r}function gO(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const o=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(o!==0){const i=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=i*i-4*o*s;if(a>=0){const l=Math.sqrt(a);n.push((-i+l)/(2*o)),n.push((-i-l)/(2*o))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(o=>{const i=1-r;return i*i*i*o[0]+3*i*i*r*o[1]+3*i*r*r*o[2]+r*r*r*o[3]}))}var Ia=class extends pt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),o=this.closed(),i=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=o?0:4,o||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);o||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(i)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():t4(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=P0(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=P0(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=t4(e,n);return[r[2],r[3]].concat(i).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...gO(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],o=e[1],i,s;for(let a=0;a<e.length/2;a++)i=e[a*2],s=e[a*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);return{x:t,y:r,width:n-t,height:o-r}}};Ia.prototype.className="Line",Ia.prototype._attrsAffectingSize=["points","bezier","tension"],wr(Ia),ce.addGetterSetter(Ia,"closed",!1),ce.addGetterSetter(Ia,"bezier",!1),ce.addGetterSetter(Ia,"tension",0,wt()),ce.addGetterSetter(Ia,"points",[],MD());var vO=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],yO=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],bO=[[1],[1,1],[1,2,1],[1,3,3,1]],n4=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*vO[20][a]+s,r+=yO[20][a]*wO(e,t,o);return s*r},r4=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],o=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+o*o),l=4*(r*i+o*s),c=i*i+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const u=l/(2*a),f=c/a,h=n+u,g=f-u*u,m=h*h+g>0?Math.sqrt(h*h+g):0,v=u*u+g>0?Math.sqrt(u*u+g):0,k=u+Math.sqrt(u*u+g)!==0?g*Math.log(Math.abs((h+m)/(u+v))):0;return Math.sqrt(a)/2*(h*m-u*v+k)};function wO(e,t,n){const r=D0(1,n,e),o=D0(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var D0=(e,t,n)=>{const r=n.length-1;let o,i;if(r===0)return 0;if(e===0){i=0;for(let s=0;s<=r;s++)i+=bO[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return i}else{o=new Array(r);for(let s=0;s<r;s++)o[s]=r*(n[s+1]-n[s]);return D0(e-1,t,o)}},o4=(e,t,n)=>{let r=1,o=e/t,i=(e-n(o))/t,s=0;for(;r>.001;){const a=n(o+i),l=Math.abs(e-a)/t;if(l<r)r=l,o+=i;else{const c=n(o-i),u=Math.abs(e-c)/t;u<r?(r=u,o-=i):i/=2}if(s++,s>500)break}return o},Pi=class mi extends pt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=mi.parsePathData(this.data()),this.pathLength=mi.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let o=0;o<n.length;o++){const i=n[o].command,s=n[o].points;switch(i){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],c=s[2],u=s[3],f=s[4],h=s[5],g=s[6],m=s[7],v=c>u?c:u,k=c>u?1:c/u,C=c>u?u/c:1;t.translate(a,l),t.rotate(g),t.scale(k,C),t.arc(0,0,v,f,f+h,1-m),t.scale(1/k,1/C),t.rotate(-g),t.translate(-a,-l);break;case"z":r=!0,t.closePath()}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const c=l.points[4],u=l.points[5],f=l.points[4]+u;let h=Math.PI/180;if(Math.abs(c-f)<h&&(h=Math.abs(c-f)),u<0)for(let g=c-h;g>f;g-=h){const m=mi.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],g,0);t.push(m.x,m.y)}else for(let g=c+h;g<f;g+=h){const m=mi.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],g,0);t.push(m.x,m.y)}}else if(l.command==="C")for(let c=0;c<=1;c+=.01){const u=mi.getPointOnCubicBezier(c,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(u.x,u.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],o=t[1],i=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(o=Math.min(o,a),i=Math.max(i,a));return{x:n,y:o,width:r-n,height:i-o}}getLength(){return this.pathLength}getPointAtLength(t){return mi.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,o){return Math.sqrt((r-t)*(r-t)+(o-n)*(o-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,o=0,i=n.length;if(!i)return null;for(;o<i&&t>n[o].pathLength;)t-=n[o].pathLength,++o;if(o===i)return r=n[o-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[o].command==="M"?(r=n[o].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[o].start.x,y:n[o].start.y};const s=n[o],a=s.points;switch(s.command){case"L":return mi.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return mi.getPointOnCubicBezier(o4(t,mi.getPathLength(n),v=>n4([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return mi.getPointOnQuadraticBezier(o4(t,mi.getPathLength(n),v=>r4([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],c=a[1],u=a[2],f=a[3],h=a[5],g=a[6];let m=a[4];return m+=h*t/s.pathLength,mi.getPointOnEllipticalArc(l,c,u,f,m,g)}return null}static getPointOnLine(t,n,r,o,i,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,o,i);if(l<1e-10)return{x:n,y:r};if(o===n)return{x:s,y:a+(i>r?t:-t)};const c=(i-r)/(o-n),u=Math.sqrt(t*t/(1+c*c))*(o<n?-1:1),f=c*u;if(Math.abs(a-r-c*(s-n))<1e-10)return{x:s+u,y:a+f};const h=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),g=n+h*(o-n),m=r+h*(i-r),v=this.getLineLength(s,a,g,m),k=Math.sqrt(t*t-v*v),C=Math.sqrt(k*k/(1+c*c))*(o<n?-1:1),_=c*C;return{x:g+C,y:m+_}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,c){function u(m){return m*m*m}function f(m){return 3*m*m*(1-m)}function h(m){return 3*m*(1-m)*(1-m)}function g(m){return(1-m)*(1-m)*(1-m)}return{x:l*u(t)+s*f(t)+o*h(t)+n*g(t),y:c*u(t)+a*f(t)+i*h(t)+r*g(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(f){return f*f}function c(f){return 2*f*(1-f)}function u(f){return(1-f)*(1-f)}return{x:s*l(t)+o*c(t)+n*u(t),y:a*l(t)+i*c(t)+r*u(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),c={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(c.x*a-c.y*l),y:n+(c.x*l+c.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let f=0;f<r.length;f++)n=n.replace(new RegExp(r[f],"g"),"|"+r[f]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let u;for(let f=1;f<o.length;f++){let h=o[f],g=h.charAt(0);for(h=h.slice(1),s.length=0;u=c.exec(h);)s.push(u[0]);let m=[],v=g==="A"||g==="a"?0:-1;for(let k=0,C=s.length;k<C;k++){const _=s[k];if(_==="00"){m.push(0,0),v>=0&&(v+=2,v>=7&&(v-=7));continue}if(v>=0){if(v===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(_)){m.push(parseInt(_[0],10)),m.push(parseInt(_[1],10)),m.push(parseFloat(_.slice(2))),v+=3,v>=7&&(v-=7);continue}if(_==="11"||_==="10"||_==="01"){m.push(parseInt(_[0],10)),m.push(parseInt(_[1],10)),v+=2,v>=7&&(v-=7);continue}if(_==="0"||_==="1"){m.push(parseInt(_,10)),v+=1,v>=7&&(v-=7);continue}}else if(v===4){if(/^[01]\d+(?:\.\d+)?$/.test(_)){m.push(parseInt(_[0],10)),m.push(parseFloat(_.slice(1))),v+=2,v>=7&&(v-=7);continue}if(_==="0"||_==="1"){m.push(parseInt(_,10)),v+=1,v>=7&&(v-=7);continue}}const y=parseFloat(_);isNaN(y)?m.push(0):m.push(y),v+=1,v>=7&&(v-=7)}else{const y=parseFloat(_);isNaN(y)?m.push(0):m.push(y)}}for(;m.length>0&&!isNaN(m[0]);){let k="",C=[];const _=a,y=l;let w,T,L,F,H,M,B,q,P,N;switch(g){case"l":a+=m.shift(),l+=m.shift(),k="L",C.push(a,l);break;case"L":a=m.shift(),l=m.shift(),C.push(a,l);break;case"m":const E=m.shift(),j=m.shift();if(a+=E,l+=j,k="M",i.length>2&&i[i.length-1].command==="z"){for(let Q=i.length-2;Q>=0;Q--)if(i[Q].command==="M"){a=i[Q].points[0]+E,l=i[Q].points[1]+j;break}}C.push(a,l),g="l";break;case"M":a=m.shift(),l=m.shift(),k="M",C.push(a,l),g="L";break;case"h":a+=m.shift(),k="L",C.push(a,l);break;case"H":a=m.shift(),k="L",C.push(a,l);break;case"v":l+=m.shift(),k="L",C.push(a,l);break;case"V":l=m.shift(),k="L",C.push(a,l);break;case"C":C.push(m.shift(),m.shift(),m.shift(),m.shift()),a=m.shift(),l=m.shift(),C.push(a,l);break;case"c":C.push(a+m.shift(),l+m.shift(),a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),k="C",C.push(a,l);break;case"S":T=a,L=l,w=i[i.length-1],w.command==="C"&&(T=a+(a-w.points[2]),L=l+(l-w.points[3])),C.push(T,L,m.shift(),m.shift()),a=m.shift(),l=m.shift(),k="C",C.push(a,l);break;case"s":T=a,L=l,w=i[i.length-1],w.command==="C"&&(T=a+(a-w.points[2]),L=l+(l-w.points[3])),C.push(T,L,a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),k="C",C.push(a,l);break;case"Q":C.push(m.shift(),m.shift()),a=m.shift(),l=m.shift(),C.push(a,l);break;case"q":C.push(a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),k="Q",C.push(a,l);break;case"T":T=a,L=l,w=i[i.length-1],w.command==="Q"&&(T=a+(a-w.points[0]),L=l+(l-w.points[1])),a=m.shift(),l=m.shift(),k="Q",C.push(T,L,a,l);break;case"t":T=a,L=l,w=i[i.length-1],w.command==="Q"&&(T=a+(a-w.points[0]),L=l+(l-w.points[1])),a+=m.shift(),l+=m.shift(),k="Q",C.push(T,L,a,l);break;case"A":F=m.shift(),H=m.shift(),M=m.shift(),B=m.shift(),q=m.shift(),P=a,N=l,a=m.shift(),l=m.shift(),k="A",C=this.convertEndpointToCenterParameterization(P,N,a,l,B,q,F,H,M);break;case"a":F=m.shift(),H=m.shift(),M=m.shift(),B=m.shift(),q=m.shift(),P=a,N=l,a+=m.shift(),l+=m.shift(),k="A",C=this.convertEndpointToCenterParameterization(P,N,a,l,B,q,F,H,M)}i.push({command:k||g,points:C,start:{x:_,y},pathLength:this.calcLength(_,y,k||g,C)})}(g==="z"||g==="Z")&&i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,o){let i,s,a,l;const c=mi;switch(r){case"L":return c.getLineLength(t,n,o[0],o[1]);case"C":return n4([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return r4([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const u=o[4],f=o[5],h=o[4]+f;let g=Math.PI/180;if(Math.abs(u-h)<g&&(g=Math.abs(u-h)),s=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],u,0),f<0)for(l=u-g;l>h;l-=g)a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=u+g;l<h;l+=g)a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],h,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,c){const u=c*(Math.PI/180),f=Math.cos(u)*(t-r)/2+Math.sin(u)*(n-o)/2,h=-1*Math.sin(u)*(t-r)/2+Math.cos(u)*(n-o)/2,g=f*f/(a*a)+h*h/(l*l);g>1&&(a*=Math.sqrt(g),l*=Math.sqrt(g));let m=Math.sqrt((a*a*(l*l)-a*a*(h*h)-l*l*(f*f))/(a*a*(h*h)+l*l*(f*f)));i===s&&(m*=-1),isNaN(m)&&(m=0);const v=m*a*h/l,k=m*-l*f/a,C=(t+r)/2+Math.cos(u)*v-Math.sin(u)*k,_=(n+o)/2+Math.sin(u)*v+Math.cos(u)*k,y=function(B){return Math.sqrt(B[0]*B[0]+B[1]*B[1])},w=function(B,q){return(B[0]*q[0]+B[1]*q[1])/(y(B)*y(q))},T=function(B,q){return(B[0]*q[1]<B[1]*q[0]?-1:1)*Math.acos(w(B,q))},L=T([1,0],[(f-v)/a,(h-k)/l]),F=[(f-v)/a,(h-k)/l],H=[(-1*f-v)/a,(-1*h-k)/l];let M=T(F,H);return w(F,H)<=-1&&(M=Math.PI),w(F,H)>=1&&(M=0),s===0&&M>0&&(M=M-2*Math.PI),s===1&&M<0&&(M=M+2*Math.PI),[C,_,a,l,L,M,u,s]}};Pi.prototype.className="Path",Pi.prototype._attrsAffectingSize=["data"],wr(Pi),ce.addGetterSetter(Pi,"data");var Ql=class extends Ia{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());const i=this.pointerLength(),s=n.length;let a,l;if(o){const f=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],h=Pi.calcLength(r[r.length-4],r[r.length-3],"C",f),g=Pi.getPointOnQuadraticBezier(Math.min(1,1-i/h),f[0],f[1],f[2],f[3],f[4],f[5]);a=n[s-2]-g.x,l=n[s-1]-g.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const c=(Math.atan2(l,a)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(c),e.moveTo(0,0),e.lineTo(-i,u/2),e.lineTo(-i,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-i,u/2),e.lineTo(-i,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};Ql.prototype.className="Arrow",wr(Ql),ce.addGetterSetter(Ql,"pointerLength",10,wt()),ce.addGetterSetter(Ql,"pointerWidth",10,wt()),ce.addGetterSetter(Ql,"pointerAtBeginning",!1),ce.addGetterSetter(Ql,"pointerAtEnding",!0);var pu=class extends pt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};pu.prototype._centroid=!0,pu.prototype.className="Circle",pu.prototype._attrsAffectingSize=["radius"],wr(pu),ce.addGetterSetter(pu,"radius",0,wt());var al=class extends pt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};al.prototype.className="Ellipse",al.prototype._centroid=!0,al.prototype._attrsAffectingSize=["radiusX","radiusY"],wr(al),ce.addComponentsGetterSetter(al,"radius",["x","y"]),ce.addGetterSetter(al,"radiusX",0,wt()),ce.addGetterSetter(al,"radiusY",0,wt());var Qi=class oI extends pt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),o=this.cornerRadius(),i=this.attrs.image;let s;if(i){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[i,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[i,0,0,n,r]}(this.hasFill()||this.hasStroke()||o)&&(t.beginPath(),o?Ee.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),i&&(o&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),o=this.cornerRadius();t.beginPath(),o?Ee.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const o=Ee.createImageElement();o.onload=function(){n(new oI({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};Qi.prototype.className="Image",Qi.prototype._attrsAffectingSize=["image"],wr(Qi),ce.addGetterSetter(Qi,"cornerRadius",0,jp(4)),ce.addGetterSetter(Qi,"image"),ce.addComponentsGetterSetter(Qi,"crop",["x","y","width","height"]),ce.addGetterSetter(Qi,"cropX",0,wt()),ce.addGetterSetter(Qi,"cropY",0,wt()),ce.addGetterSetter(Qi,"cropWidth",0,wt()),ce.addGetterSetter(Qi,"cropHeight",0,wt());var i4=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CO="Change.konva",kO="none",O0="up",F0="right",N0="down",B0="left",SO=i4.length,z0=class extends fu{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<SO;n++)e.on(i4[n]+CO,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,o,i,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),i=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,o){case O0:s=n/2,a=-1*l;break;case F0:s=n+i,a=r/2;break;case N0:s=n/2,a=r+l;break;case B0:s=-1*i,a=r/2}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};z0.prototype.className="Label",wr(z0);var Jl=class extends pt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),i=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,c=0,u=0;typeof s=="number"?a=l=c=u=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),u=Math.min(s[2]||0,t/2,n/2),c=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===O0&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+o)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===F0&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===N0&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),r===B0&&(e.lineTo(0,(n+i)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-i)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),i=this.width(),s=this.height();return o===O0?(t-=r,s+=r):o===N0?s+=r:o===B0?(e-=n*1.5,i+=n):o===F0&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};Jl.prototype.className="Tag",wr(Jl),ce.addGetterSetter(Jl,"pointerDirection",kO),ce.addGetterSetter(Jl,"pointerWidth",0,wt()),ce.addGetterSetter(Jl,"pointerHeight",0,wt()),ce.addGetterSetter(Jl,"cornerRadius",0,jp(4));var Af=class extends pt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?Ee.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Af.prototype.className="Rect",wr(Af),ce.addGetterSetter(Af,"cornerRadius",0,jp(4));var ll=class extends pt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)Ee.drawRoundedPolygonPath(e,t,r,n,o);else{e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,o=e[0].y;return e.forEach(i=>{t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y)}),{x:t,y:r,width:n-t,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};ll.prototype.className="RegularPolygon",ll.prototype._centroid=!0,ll.prototype._attrsAffectingSize=["radius"],wr(ll),ce.addGetterSetter(ll,"radius",0,wt()),ce.addGetterSetter(ll,"sides",0,wt()),ce.addGetterSetter(ll,"cornerRadius",0,jp(4));var s4=Math.PI*2,ec=class extends pt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,s4,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),s4,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};ec.prototype.className="Ring",ec.prototype._centroid=!0,ec.prototype._attrsAffectingSize=["innerRadius","outerRadius"],wr(ec),ce.addGetterSetter(ec,"innerRadius",0,wt()),ce.addGetterSetter(ec,"outerRadius",0,wt());var Ms=class extends pt{constructor(e){super(e),this._updated=!0,this.anim=new hu(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+0],a=o[r+1],l=o[r+2],c=o[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,c),e.closePath(),e.fillStrokeShape(this)),u)if(i){const f=i[t],h=n*2;e.drawImage(u,s,a,l,c,f[h+0],f[h+1],l,c)}else e.drawImage(u,s,a,l,c,0,0,l,c)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+2],a=o[r+3];if(e.beginPath(),i){const l=i[t],c=n*2;e.rect(l[c+0],l[c+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};Ms.prototype.className="Sprite",wr(Ms),ce.addGetterSetter(Ms,"animation"),ce.addGetterSetter(Ms,"animations"),ce.addGetterSetter(Ms,"frameOffsets"),ce.addGetterSetter(Ms,"image"),ce.addGetterSetter(Ms,"frameIndex",0,wt()),ce.addGetterSetter(Ms,"frameRate",17,wt()),ce.backCompat(Ms,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var cl=class extends pt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let o=1;o<r*2;o++){const i=o%2===0?n:t,s=i*Math.sin(o*Math.PI/r),a=-1*i*Math.cos(o*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};cl.prototype.className="Star",cl.prototype._centroid=!0,cl.prototype._attrsAffectingSize=["innerRadius","outerRadius"],wr(cl),ce.addGetterSetter(cl,"numPoints",5,wt()),ce.addGetterSetter(cl,"innerRadius",0,wt()),ce.addGetterSetter(cl,"outerRadius",0,wt());function ul(e){return[...e].reduce((t,n,r,o)=>{if(/\p{Emoji}/u.test(n)){const i=o[r+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(n+i),o[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(o[r+1]||""))?t.push(n+o[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var mu="auto",_O="center",a4="inherit",If="justify",AO="Change.konva",l4="2d",c4="-",u4="left",IO="text",xO="Text",EO="top",TO="bottom",d4="middle",f4="normal",RO="px ",Xp=" ",LO="right",h4="rtl",MO="word",PO="char",p4="none",V0="…",m4=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],DO=m4.length,xf=null;function OO(){if(xf!==null)return xf;xf=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(l4);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){xf=!0;break}}}catch{}return xf}function FO(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var Zp;function j0(){return Zp||(Zp=Ee.createCanvasElement().getContext(l4),Zp)}function NO(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function BO(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function zO(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var ar=class extends pt{constructor(e){super(zO(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<DO;t++)this.on(m4[t]+AO,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,o=r.length;if(!this.text())return;let i=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),c=this.direction(),u=0,f=this.align(),h=this.getWidth(),g=this.letterSpacing(),m=this.charRenderFunc(),v=this.fill(),k=this.textDecoration(),C=this.underlineOffset(),_=k.indexOf("underline")!==-1,y=k.indexOf("line-through")!==-1,w;c=c===a4?e.direction:c;let T=a/2,L=d4;if(!_t.legacyTextRendering){const F=this.measureSize("M");L="alphabetic",T=(((t=F.fontBoundingBoxAscent)!==null&&t!==void 0?t:F.actualBoundingBoxAscent)-((n=F.fontBoundingBoxDescent)!==null&&n!==void 0?n:F.actualBoundingBoxDescent))/2+a/2}for(c===h4&&e.setAttr("direction",c),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",L),e.setAttr("textAlign",u4),l===d4?u=(this.getHeight()-o*a-i*2)/2:l===TO&&(u=this.getHeight()-o*a-i*2),e.translate(i,u+i),w=0;w<o;w++){let F=0,H=0;const M=r[w],B=M.text,q=M.width,P=M.lastInParagraph;if(e.save(),f===LO?F+=h-q-i*2:f===_O&&(F+=(h-q-i*2)/2),_){e.save(),e.beginPath();const E=C??(_t.legacyTextRendering?Math.round(s/2):Math.round(s/4)),j=F,Q=T+H+E;e.moveTo(j,Q);const Y=f===If&&!P?h-i*2:q;e.lineTo(j+Math.round(Y),Q),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}const N=F;if(c!==h4&&(g!==0||f===If||m)){const E=B.split(" ").length-1,j=ul(B);for(let Q=0;Q<j.length;Q++){const Y=j[Q];if(Y===" "&&!P&&f===If&&(F+=(h-i*2-q)/E),this._partialTextX=F,this._partialTextY=T+H,this._partialText=Y,m){e.save();const se=r.slice(0,w).reduce((he,Ve)=>he+ul(Ve.text).length,0);m({char:Y,index:Q+se,x:F,y:T+H,lineIndex:w,column:Q,isLastInLine:P,width:this.measureSize(Y).width,context:e})}e.fillStrokeShape(this),m&&e.restore(),F+=this.measureSize(Y).width+g}}else g!==0&&e.setAttr("letterSpacing",`${g}px`),this._partialTextX=F,this._partialTextY=T+H,this._partialText=B,e.fillStrokeShape(this);if(y){e.save(),e.beginPath();const E=_t.legacyTextRendering?0:-Math.round(s/4),j=N;e.moveTo(j,T+H+E);const Q=f===If&&!P?h-i*2:q;e.lineTo(j+Math.round(Q),T+H+E),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}e.restore(),o>1&&(T+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=Ee._isString(e)?e:e==null?"":e+"";return this._setAttr(IO,t),this}getWidth(){return this.attrs.width===mu||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===mu||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Ee.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,o,i,s,a,l,c,u,f;let h=j0(),g=this.fontSize(),m;h.save(),h.font=this._getContextFont(),m=h.measureText(e),h.restore();const v=g/100;return{actualBoundingBoxAscent:(t=m.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*v,actualBoundingBoxDescent:(n=m.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=m.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*v,actualBoundingBoxRight:(o=m.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*v,alphabeticBaseline:(i=m.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=m.emHeightAscent)!==null&&s!==void 0?s:100*v,emHeightDescent:(a=m.emHeightDescent)!==null&&a!==void 0?a:-20*v,fontBoundingBoxAscent:(l=m.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*v,fontBoundingBoxDescent:(c=m.fontBoundingBoxDescent)!==null&&c!==void 0?c:21*v,hangingBaseline:(u=m.hangingBaseline)!==null&&u!==void 0?u:72.80000305175781*v,ideographicBaseline:(f=m.ideographicBaseline)!==null&&f!==void 0?f:-21*v,width:m.width,height:g}}_getContextFont(){return this.fontStyle()+Xp+this.fontVariant()+Xp+(this.fontSize()+RO)+FO(this.fontFamily())}_addTextLine(e){this.align()===If&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return j0().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
100
100
  `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==mu&&o!==void 0,a=i!==mu&&i!==void 0,l=this.padding(),c=o-l*2,u=i-l*2,f=0,h=this.wrap(),g=h!==PO&&h!==p4,m=this.ellipsis();this.textArr=[],j0().font=this._getContextFont();const v=m?this._getTextWidth(V0):0;for(let k=0,C=e.length;k<C;++k){let _=e[k],y=this._getTextWidth(_);if(s&&y>c)for(;_.length>0;){let w=0,T=ul(_).length,L="",F=0;for(;w<T;){const H=w+T>>>1,M=ul(_).slice(0,H+1).join(""),B=this._getTextWidth(M);(m&&a&&f+r>u?B+v:B)<=c?(w=H+1,L=M,F=B):T=H}if(L){if(g){const H=ul(_),M=ul(L),B=H[M.length],q=B===Xp||B===c4;let P;if(q&&F<=c)P=M.length;else{const N=M.lastIndexOf(Xp),E=M.lastIndexOf(c4);P=Math.max(N,E)+1}P>0&&(w=P,L=H.slice(0,w).join(""),F=this._getTextWidth(L))}if(L=L.trimRight(),this._addTextLine(L),n=Math.max(n,F),f+=r,this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(_=ul(_).slice(w).join("").trimLeft(),_.length>0&&(y=this._getTextWidth(_),y<=c)){this._addTextLine(_),f+=r,n=Math.max(n,y);break}}else break}else this._addTextLine(_),f+=r,n=Math.max(n,y),this._shouldHandleEllipsis(f)&&k<C-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&f+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==mu&&r!==void 0,i=r-this.padding()*2;return this.wrap()===p4||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==mu&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+V0)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+V0))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&OO()?!0:super._useBufferCanvas()}};ar.prototype._fillFunc=NO,ar.prototype._strokeFunc=BO,ar.prototype.className=xO,ar.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],wr(ar),ce.overWriteSetter(ar,"width",k0()),ce.overWriteSetter(ar,"height",k0()),ce.addGetterSetter(ar,"direction",a4),ce.addGetterSetter(ar,"fontFamily","Arial"),ce.addGetterSetter(ar,"fontSize",12,wt()),ce.addGetterSetter(ar,"fontStyle",f4),ce.addGetterSetter(ar,"fontVariant",f4),ce.addGetterSetter(ar,"padding",0,wt()),ce.addGetterSetter(ar,"align",u4),ce.addGetterSetter(ar,"verticalAlign",EO),ce.addGetterSetter(ar,"lineHeight",1,wt()),ce.addGetterSetter(ar,"wrap",MO),ce.addGetterSetter(ar,"ellipsis",!1,Zi()),ce.addGetterSetter(ar,"letterSpacing",0,wt()),ce.addGetterSetter(ar,"text","",Yl()),ce.addGetterSetter(ar,"textDecoration",""),ce.addGetterSetter(ar,"underlineOffset",void 0,wt()),ce.addGetterSetter(ar,"charRenderFunc",void 0);var VO="",g4="normal";function v4(e){e.fillText(this.partialText,0,0)}function y4(e){e.strokeText(this.partialText,0,0)}var Yr=class extends pt{constructor(e){super(e),this.dummyCanvas=Ee.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Pi.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Pi.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Pi.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Ee.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return ar.prototype.setText.call(this,e)}_getContextFont(){return ar.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=ul(this.text()),t=[];let n=0;for(let h=0;h<e.length;h++)t.push({char:e[h],width:this._getTextSize(e[h]).width}),n+=t[h].width;const{width:r,height:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let u=0;s==="center"&&(u=Math.max(0,this.pathLength/2-c/2)),s==="right"&&(u=Math.max(0,this.pathLength-c));let f=u;for(let h=0;h<t.length;h++){const g=this._getPointAtLength(f);if(!g)return;const m=t[h].char;let v=t[h].width+i;if(m===" "&&s==="justify"){const L=this.text().split(" ").length-1;v+=(this.pathLength-c)/L}const k=f+v,C=this._getPointAtLength(k>this.pathLength&&k-this.pathLength<=l?this.pathLength:k);if(!C)return;const _=Pi.getLineLength(g.x,g.y,C.x,C.y);let y=0;if(a)try{y=a(t[h-1].char,m)*this.fontSize()}catch{y=0}g.x+=y,C.x+=y,this.textWidth+=y;const w=Pi.getPointOnLine(y+_/2,g.x,g.y,C.x,C.y),T=Math.atan2(C.y-g.y,C.x-g.x);this.glyphInfo.push({transposeX:w.x,transposeY:w.y,text:e[h],rotation:T,p0:g,p1:C,width:_}),f+=v}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return Ee.releaseCanvas(this.dummyCanvas),super.destroy()}};Yr.prototype._fillFunc=v4,Yr.prototype._strokeFunc=y4,Yr.prototype._fillFuncHit=v4,Yr.prototype._strokeFuncHit=y4,Yr.prototype.className="TextPath",Yr.prototype._attrsAffectingSize=["text","fontSize","data"],wr(Yr),ce.addGetterSetter(Yr,"data"),ce.addGetterSetter(Yr,"fontFamily","Arial"),ce.addGetterSetter(Yr,"fontSize",12,wt()),ce.addGetterSetter(Yr,"fontStyle",g4),ce.addGetterSetter(Yr,"align","left"),ce.addGetterSetter(Yr,"letterSpacing",0,wt()),ce.addGetterSetter(Yr,"textBaseline","middle"),ce.addGetterSetter(Yr,"fontVariant",g4),ce.addGetterSetter(Yr,"text",VO),ce.addGetterSetter(Yr,"textDecoration",""),ce.addGetterSetter(Yr,"kerningFunc",void 0);var b4="tr-konva",jO=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${b4}`).join(" "),w4="nodesRect",UO=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],HO={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},$O="ontouchstart"in _t._global;function GO(e,t,n){if(e==="rotater")return n;t+=Ee.degToRad(HO[e]||0);const r=(Ee.radToDeg(t)%360+360)%360;return Ee._inRange(r,337.5,360)||Ee._inRange(r,0,22.5)?"ns-resize":Ee._inRange(r,22.5,67.5)?"nesw-resize":Ee._inRange(r,67.5,112.5)?"ew-resize":Ee._inRange(r,112.5,157.5)?"nwse-resize":Ee._inRange(r,157.5,202.5)?"ns-resize":Ee._inRange(r,202.5,247.5)?"nesw-resize":Ee._inRange(r,247.5,292.5)?"ew-resize":Ee._inRange(r,292.5,337.5)?"nwse-resize":(Ee.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var Qp=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function WO(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function C4(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:o}}function KO(e,t){return C4(e,t,WO(e))}function qO(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=_t.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var U0=0,xn=class extends fu{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(jO,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Ee.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return b4+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter(n=>n.isAncestorOf(this)?(Ee.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(n=>{const r=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(n._attrsAffectingSize.length){const o=n._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");n.on(o,r)}n.on(UO.map(o=>o+`.${this._getEventNamespace()}`).join(" "),r),n.on(`absoluteTransformChange.${this._getEventNamespace()}`,r),this._proxyDrag(n)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(w4),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(w4,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(_t.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return C4({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-_t.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),c=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],u=a.getAbsoluteTransform();c.forEach(function(f){const h=u.point(f);e.push(h)})});const t=new Xi;t.rotate(-_t.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:_t.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Qp.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new Af({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:$O?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=GO(e,_t.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new pt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=Ee.degToRad(a),u=Math.sin(c),f=-Math.cos(c),h=i/2,g=s/2;let m=1/0;f<0?m=Math.min(m,-g/f):f>0&&(m=Math.min(m,(s-g)/f)),u<0?m=Math.min(m,-h/u):u>0&&(m=Math.min(m,(i-h)/u));const v=h+u*m,k=g+f*m,C=Ee._sign(s),_=v+u*l*C,y=k+f*l*C;t.moveTo(v,k),t.lineTo(_,y)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},U0++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const c=o.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const C=this._getNodeRect();t=o.x()-C.width/2,n=-o.y()+C.height/2;const _=_t.getAngle(this.rotateAnchorAngle());let y=Math.atan2(-n,t)+Math.PI/2-_;C.height<0&&(y-=Math.PI);const w=_t.getAngle(this.rotation())+y,T=_t.getAngle(this.rotationSnapTolerance()),L=KO(C,qO(this.rotationSnaps(),w,T)-C.rotation);this._fitNodesInto(L,e);return}const u=this.shiftBehavior();let f;u==="inverted"?f=this.keepRatio()&&!e.shiftKey:u==="none"?f=this.keepRatio():f=this.keepRatio()||e.shiftKey;let h=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(f){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(C.x-o.x(),2)+Math.pow(C.y-o.y(),2));const _=this.findOne(".top-left").x()>C.x?-1:1,y=this.findOne(".top-left").y()>C.y?-1:1;t=r*this.cos*_,n=r*this.sin*y,this.findOne(".top-left").x(C.x-t),this.findOne(".top-left").y(C.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(f){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-C.x,2)+Math.pow(C.y-o.y(),2));const _=this.findOne(".top-right").x()<C.x?-1:1,y=this.findOne(".top-right").y()>C.y?-1:1;t=r*this.cos*_,n=r*this.sin*y,this.findOne(".top-right").x(C.x+t),this.findOne(".top-right").y(C.y-n)}var g=o.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(f){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(C.x-o.x(),2)+Math.pow(o.y()-C.y,2));const _=C.x<o.x()?-1:1,y=o.y()<C.y?-1:1;t=r*this.cos*_,n=r*this.sin*y,o.x(C.x-t),o.y(C.y+n)}g=o.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(f){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-C.x,2)+Math.pow(o.y()-C.y,2));const _=this.findOne(".bottom-right").x()<C.x?-1:1,y=this.findOne(".bottom-right").y()<C.y?-1:1;t=r*this.cos*_,n=r*this.sin*y,this.findOne(".bottom-right").x(C.x+t),this.findOne(".bottom-right").y(C.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(h=this.centeredScaling()||e.altKey,h){const C=this.findOne(".top-left"),_=this.findOne(".bottom-right"),y=C.x(),w=C.y(),T=this.getWidth()-_.x(),L=this.getHeight()-_.y();_.move({x:-y,y:-w}),C.move({x:T,y:L})}const m=this.findOne(".top-left").getAbsolutePosition();t=m.x,n=m.y;const v=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),k=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:v,height:k,rotation:_t.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();U0--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(Ee._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Ee._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new Xi;if(o.rotate(_t.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const f=o.point({x:-this.padding()*2,y:0});e.x+=f.x,e.y+=f.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const f=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const f=o.point({x:0,y:-this.padding()*2});e.x+=f.x,e.y+=f.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const f=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const f=this.boundBoxFunc()(n,e);f?e=f:Ee.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new Xi;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new Xi,l=e.width/i,c=e.height/i;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(c))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,c));const u=a.multiply(s.invert());this._nodes.forEach(f=>{var h;if(!f.getStage())return;const g=f.getParent().getAbsoluteTransform(),m=f.getTransform().copy();m.translate(f.offsetX(),f.offsetY());const v=new Xi;v.multiply(g.copy().invert()).multiply(u).multiply(g).multiply(m);const k=v.decompose();f.setAttrs(k),(h=f.getLayer())===null||h===void 0||h.batchDraw()}),this.rotation(Ee._getRotation(e.rotation)),this._nodes.forEach(f=>{this._fire("transform",{evt:t,target:f}),f._fire("transform",{evt:t,target:f})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(Ee._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(T=>{T.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),f=Ee.degToRad(c),h=Math.sin(f),g=-Math.cos(f),m=n/2,v=r/2;let k=1/0;g<0?k=Math.min(k,-v/g):g>0&&(k=Math.min(k,(r-v)/g)),h<0?k=Math.min(k,-m/h):h>0&&(k=Math.min(k,(n-m)/h));const C=m+h*k,_=v+g*k,y=Ee._sign(r);this._batchChangeChild(".rotater",{x:C+h*u*y,y:_+g*u*y-s*g,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(T=>T.draggable()),x:0,y:0});const w=this.anchorStyleFunc();w&&l.forEach(T=>{w(T)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),fu.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(Ee.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return At.prototype.toObject.call(this)}clone(e){return At.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};xn.isTransforming=()=>U0>0;function YO(e){return e instanceof Array||Ee.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){Qp.indexOf(t)===-1&&Ee.warn("Unknown anchor name: "+t+". Available names are: "+Qp.join(", "))}),e||[]}xn.prototype.className="Transformer",wr(xn),ce.addGetterSetter(xn,"enabledAnchors",Qp,YO),ce.addGetterSetter(xn,"flipEnabled",!0,Zi()),ce.addGetterSetter(xn,"resizeEnabled",!0),ce.addGetterSetter(xn,"anchorSize",10,wt()),ce.addGetterSetter(xn,"rotateEnabled",!0),ce.addGetterSetter(xn,"rotateLineVisible",!0),ce.addGetterSetter(xn,"rotationSnaps",[]),ce.addGetterSetter(xn,"rotateAnchorOffset",50,wt()),ce.addGetterSetter(xn,"rotateAnchorAngle",0,wt()),ce.addGetterSetter(xn,"rotateAnchorCursor","crosshair"),ce.addGetterSetter(xn,"rotationSnapTolerance",5,wt()),ce.addGetterSetter(xn,"borderEnabled",!0),ce.addGetterSetter(xn,"anchorStroke","rgb(0, 161, 255)"),ce.addGetterSetter(xn,"anchorStrokeWidth",1,wt()),ce.addGetterSetter(xn,"anchorFill","white"),ce.addGetterSetter(xn,"anchorCornerRadius",0,wt()),ce.addGetterSetter(xn,"borderStroke","rgb(0, 161, 255)"),ce.addGetterSetter(xn,"borderStrokeWidth",1,wt()),ce.addGetterSetter(xn,"borderDash"),ce.addGetterSetter(xn,"keepRatio",!0),ce.addGetterSetter(xn,"shiftBehavior","default"),ce.addGetterSetter(xn,"centeredScaling",!1),ce.addGetterSetter(xn,"ignoreStroke",!1),ce.addGetterSetter(xn,"padding",0,wt()),ce.addGetterSetter(xn,"nodes"),ce.addGetterSetter(xn,"node"),ce.addGetterSetter(xn,"boundBoxFunc"),ce.addGetterSetter(xn,"anchorDragBoundFunc"),ce.addGetterSetter(xn,"anchorStyleFunc"),ce.addGetterSetter(xn,"shouldOverdrawWholeArea",!1),ce.addGetterSetter(xn,"useSingleNodeRotation",!0),ce.backCompat(xn,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var xa=class extends pt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,_t.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};xa.prototype.className="Wedge",xa.prototype._centroid=!0,xa.prototype._attrsAffectingSize=["radius"],wr(xa),ce.addGetterSetter(xa,"radius",0,wt()),ce.addGetterSetter(xa,"angle",0,wt()),ce.addGetterSetter(xa,"clockwise",!1),ce.backCompat(xa,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function k4(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var XO=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],ZO=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function QO(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,c,u,f,h,g,m,v,k,C,_,y,w,T,L,F,H;const M=t+t+1,B=r-1,q=o-1,P=t+1,N=P*(P+1)/2,E=new k4,j=XO[t],Q=ZO[t];let Y=null,se=E,he=null,Ve=null;for(let pe=1;pe<M;pe++)se=se.next=new k4,pe===P&&(Y=se);se.next=E,a=s=0;for(let pe=0;pe<o;pe++){k=C=_=y=l=c=u=f=0,h=P*(w=n[s]),g=P*(T=n[s+1]),m=P*(L=n[s+2]),v=P*(F=n[s+3]),l+=N*w,c+=N*T,u+=N*L,f+=N*F,se=E;for(let ye=0;ye<P;ye++)se.r=w,se.g=T,se.b=L,se.a=F,se=se.next;for(let ye=1;ye<P;ye++)i=s+((B<ye?B:ye)<<2),l+=(se.r=w=n[i])*(H=P-ye),c+=(se.g=T=n[i+1])*H,u+=(se.b=L=n[i+2])*H,f+=(se.a=F=n[i+3])*H,k+=w,C+=T,_+=L,y+=F,se=se.next;he=E,Ve=Y;for(let ye=0;ye<r;ye++)n[s+3]=F=f*j>>Q,F!==0?(F=255/F,n[s]=(l*j>>Q)*F,n[s+1]=(c*j>>Q)*F,n[s+2]=(u*j>>Q)*F):n[s]=n[s+1]=n[s+2]=0,l-=h,c-=g,u-=m,f-=v,h-=he.r,g-=he.g,m-=he.b,v-=he.a,i=a+((i=ye+t+1)<B?i:B)<<2,k+=he.r=n[i],C+=he.g=n[i+1],_+=he.b=n[i+2],y+=he.a=n[i+3],l+=k,c+=C,u+=_,f+=y,he=he.next,h+=w=Ve.r,g+=T=Ve.g,m+=L=Ve.b,v+=F=Ve.a,k-=w,C-=T,_-=L,y-=F,Ve=Ve.next,s+=4;a+=r}for(let pe=0;pe<r;pe++){C=_=y=k=c=u=f=l=0,s=pe<<2,h=P*(w=n[s]),g=P*(T=n[s+1]),m=P*(L=n[s+2]),v=P*(F=n[s+3]),l+=N*w,c+=N*T,u+=N*L,f+=N*F,se=E;for(let me=0;me<P;me++)se.r=w,se.g=T,se.b=L,se.a=F,se=se.next;let ye=r;for(let me=1;me<=t;me++)s=ye+pe<<2,l+=(se.r=w=n[s])*(H=P-me),c+=(se.g=T=n[s+1])*H,u+=(se.b=L=n[s+2])*H,f+=(se.a=F=n[s+3])*H,k+=w,C+=T,_+=L,y+=F,se=se.next,me<q&&(ye+=r);s=pe,he=E,Ve=Y;for(let me=0;me<o;me++)i=s<<2,n[i+3]=F=f*j>>Q,F>0?(F=255/F,n[i]=(l*j>>Q)*F,n[i+1]=(c*j>>Q)*F,n[i+2]=(u*j>>Q)*F):n[i]=n[i+1]=n[i+2]=0,l-=h,c-=g,u-=m,f-=v,h-=he.r,g-=he.g,m-=he.b,v-=he.a,i=pe+((i=me+P)<q?i:q)*r<<2,l+=k+=he.r=n[i],c+=C+=he.g=n[i+1],u+=_+=he.b=n[i+2],f+=y+=he.a=n[i+3],he=he.next,h+=w=Ve.r,g+=T=Ve.g,m+=L=Ve.b,v+=F=Ve.a,k-=w,C-=T,_-=L,y-=F,Ve=Ve.next,s+=r}}var JO=function(t){const n=Math.round(this.blurRadius());n>0&&QO(t,n)};ce.addGetterSetter(At,"blurRadius",0,wt(),ce.afterSetFilter);var eF=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};ce.addGetterSetter(At,"brightness",0,wt(),ce.afterSetFilter);var tF=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},nF=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};ce.addGetterSetter(At,"contrast",0,wt(),ce.afterSetFilter);var rF=function(e){var t,n,r,o,i,s,a,l,c;const u=e.data,f=e.width,h=e.height,g=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),m=Math.min(1,Math.max(0,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),v=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,k=!!((c=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&c!==void 0&&c),C=g*10,_=m*255,y=v*Math.PI/180,w=Math.cos(y),T=Math.sin(y),L=128/1020*C,F=new Uint8ClampedArray(u),H=new Float32Array(f*h);for(let N=0,E=0;E<u.length;E+=4,N++)H[N]=.2126*F[E]+.7152*F[E+1]+.0722*F[E+2];const M=[-1,0,1,-2,0,2,-1,0,1],B=[-1,-2,-1,0,0,0,1,2,1],q=[-f-1,-f,-f+1,-1,0,1,f-1,f,f+1],P=N=>N<0?0:N>255?255:N;for(let N=1;N<h-1;N++)for(let E=1;E<f-1;E++){const j=N*f+E;let Q=0,Y=0;Q+=H[j+q[0]]*M[0],Y+=H[j+q[0]]*B[0],Q+=H[j+q[1]]*M[1],Y+=H[j+q[1]]*B[1],Q+=H[j+q[2]]*M[2],Y+=H[j+q[2]]*B[2],Q+=H[j+q[3]]*M[3],Y+=H[j+q[3]]*B[3],Q+=H[j+q[5]]*M[5],Y+=H[j+q[5]]*B[5],Q+=H[j+q[6]]*M[6],Y+=H[j+q[6]]*B[6],Q+=H[j+q[7]]*M[7],Y+=H[j+q[7]]*B[7],Q+=H[j+q[8]]*M[8],Y+=H[j+q[8]]*B[8];const se=P(_+(w*Q+T*Y)*L),he=j*4;if(k){const Ve=se-_;u[he]=P(F[he]+Ve),u[he+1]=P(F[he+1]+Ve),u[he+2]=P(F[he+2]+Ve),u[he+3]=F[he+3]}else u[he]=u[he+1]=u[he+2]=se,u[he+3]=F[he+3]}for(let N=0;N<f;N++){let E=N*4,j=((h-1)*f+N)*4;u[E]=F[E],u[E+1]=F[E+1],u[E+2]=F[E+2],u[E+3]=F[E+3],u[j]=F[j],u[j+1]=F[j+1],u[j+2]=F[j+2],u[j+3]=F[j+3]}for(let N=1;N<h-1;N++){let E=N*f*4,j=(N*f+(f-1))*4;u[E]=F[E],u[E+1]=F[E+1],u[E+2]=F[E+2],u[E+3]=F[E+3],u[j]=F[j],u[j+1]=F[j+1],u[j+2]=F[j+2],u[j+3]=F[j+3]}return e};ce.addGetterSetter(At,"embossStrength",.5,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"embossWhiteLevel",.5,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"embossDirection","top-left",void 0,ce.afterSetFilter),ce.addGetterSetter(At,"embossBlend",!1,void 0,ce.afterSetFilter);function H0(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}var oF=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,c=t[2],u=c,f;const h=this.enhance();if(h===0)return;for(let y=0;y<n;y+=4)i=t[y+0],i<r?r=i:i>o&&(o=i),l=t[y+1],l<s?s=l:l>a&&(a=l),f=t[y+2],f<c?c=f:f>u&&(u=f);o===r&&(o=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let g,m,v,k,C,_;if(h>0)g=o+h*(255-o),m=r-h*(r-0),v=a+h*(255-a),k=s-h*(s-0),C=u+h*(255-u),_=c-h*(c-0);else{const y=(o+r)*.5;g=o+h*(o-y),m=r+h*(r-y);const w=(a+s)*.5;v=a+h*(a-w),k=s+h*(s-w);const T=(u+c)*.5;C=u+h*(u-T),_=c+h*(c-T)}for(let y=0;y<n;y+=4)t[y+0]=H0(t[y+0],r,o,m,g),t[y+1]=H0(t[y+1],s,a,k,v),t[y+2]=H0(t[y+2],c,u,_,C)};ce.addGetterSetter(At,"enhance",0,wt(),ce.afterSetFilter);var iF=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};ce.addGetterSetter(At,"hue",0,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"saturation",0,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"luminance",0,wt(),ce.afterSetFilter);var sF=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*Math.PI/180),c=.299*r+.701*a+.167*l,u=.587*r-.587*a+.33*l,f=.114*r-.114*a-.497*l,h=.299*r-.299*a-.328*l,g=.587*r+.413*a+.035*l,m=.114*r-.114*a+.293*l,v=.299*r-.3*a+1.25*l,k=.587*r-.586*a-1.05*l,C=.114*r+.886*a-.2*l;let _,y,w,T;for(let L=0;L<n;L+=4)_=t[L+0],y=t[L+1],w=t[L+2],T=t[L+3],t[L+0]=c*_+u*y+f*w+s,t[L+1]=h*_+g*y+m*w+s,t[L+2]=v*_+k*y+C*w+s,t[L+3]=T},aF=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*Math.PI/180),l=.299*r+.701*s+.167*a,c=.587*r-.587*s+.33*a,u=.114*r-.114*s-.497*a,f=.299*r-.299*s-.328*a,h=.587*r+.413*s+.035*a,g=.114*r-.114*s+.293*a,m=.299*r-.3*s+1.25*a,v=.587*r-.586*s-1.05*a,k=.114*r+.886*s-.2*a;for(let C=0;C<n;C+=4){const _=t[C+0],y=t[C+1],w=t[C+2],T=t[C+3];t[C+0]=l*_+c*y+u*w,t[C+1]=f*_+h*y+g*w,t[C+2]=m*_+v*y+k*w,t[C+3]=T}};ce.addGetterSetter(At,"hue",0,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"saturation",0,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"value",0,wt(),ce.afterSetFilter);var lF=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]},cF=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,f=s-l;const h=Math.sqrt(u*u+f*f);c=h>c?h:c;const g=s,m=i,v=360/m*Math.PI/180;for(let k=0;k<m;k+=1){const C=Math.sin(k*v),_=Math.cos(k*v);for(let y=0;y<g;y+=1){u=Math.floor(a+c*y/g*_),f=Math.floor(l+c*y/g*C);let w=(f*i+u)*4;const T=r[w+0],L=r[w+1],F=r[w+2],H=r[w+3];w=(k+y*i)*4,o[w+0]=T,o[w+1]=L,o[w+2]=F,o[w+3]=H}}},uF=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,f=s-l;const h=Math.sqrt(u*u+f*f);c=h>c?h:c;const g=s,m=i,v=n.polarRotation||0;let k,C;for(u=0;u<i;u+=1)for(f=0;f<s;f+=1){const _=u-a,y=f-l,w=Math.sqrt(_*_+y*y)*g/c;let T=(Math.atan2(y,_)*180/Math.PI+360+v)%360;T=T*m/360,k=Math.floor(T),C=Math.floor(w);let L=(C*i+k)*4;const F=r[L+0],H=r[L+1],M=r[L+2],B=r[L+3];L=(f*i+u)*4,o[L+0]=F,o[L+1]=H,o[L+2]=M,o[L+3]=B}},dF=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,c,u,f,h,g=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),v=Math.floor(t*(m%360)/360);if(g<1)return;const k=Ee.createCanvasElement();k.width=t,k.height=n;const C=k.getContext("2d").getImageData(0,0,t,n);Ee.releaseCanvas(k),cF(e,C,{polarCenterX:t/2,polarCenterY:n/2});let _=t/Math.pow(2,g);for(;_<=8;)_=_*2,g-=1;_=Math.ceil(_);let y=_,w=0,T=y,L=1;for(v+_>t&&(w=y,T=0,L=-1),o=0;o<n;o+=1)for(r=w;r!==T;r+=L)i=Math.round(r+v)%t,f=(t*o+i)*4,a=C.data[f+0],l=C.data[f+1],c=C.data[f+2],u=C.data[f+3],h=(t*o+r)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=c,C.data[h+3]=u;for(o=0;o<n;o+=1)for(y=Math.floor(_),s=0;s<g;s+=1){for(r=0;r<y+1;r+=1)f=(t*o+r)*4,a=C.data[f+0],l=C.data[f+1],c=C.data[f+2],u=C.data[f+3],h=(t*o+y*2-r-1)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=c,C.data[h+3]=u;y*=2}uF(C,e,{polarRotation:0})};ce.addGetterSetter(At,"kaleidoscopePower",2,wt(),ce.afterSetFilter),ce.addGetterSetter(At,"kaleidoscopeAngle",0,wt(),ce.afterSetFilter);function Jp(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function Ef(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function fF(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function hF(e,t){const n=Jp(e,0,0),r=Jp(e,e.width-1,0),o=Jp(e,0,e.height-1),i=Jp(e,e.width-1,e.height-1),s=t||10;if(Ef(n,r)<s&&Ef(r,i)<s&&Ef(i,o)<s&&Ef(o,n)<s){const a=fF([r,n,i,o]),l=[];for(let c=0;c<e.width*e.height;c++){const u=Ef(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]]);l[c]=u<s?0:255}return l}}function pF(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function mF(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let f=0;f<o;f++)for(let h=0;h<o;h++){const g=a+f-i,m=l+h-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,k=r[f*o+h];u+=e[v]*k}}s[c]=u===2040?255:0}return s}function gF(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let f=0;f<o;f++)for(let h=0;h<o;h++){const g=a+f-i,m=l+h-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,k=r[f*o+h];u+=e[v]*k}}s[c]=u>=1020?255:0}return s}function vF(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let f=0;f<o;f++)for(let h=0;h<o;h++){const g=a+f-i,m=l+h-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,k=r[f*o+h];u+=e[v]*k}}s[c]=u}return s}var yF=function(e){let t=hF(e,this.threshold());return t&&(t=mF(t,e.width,e.height),t=gF(t,e.width,e.height),t=vF(t,e.width,e.height),pF(e,t)),e};ce.addGetterSetter(At,"threshold",0,wt(),ce.afterSetFilter);var bF=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};ce.addGetterSetter(At,"noise",.2,wt(),ce.afterSetFilter);var wF=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){Ee.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;l+=1){let c=0,u=0,f=0,h=0;const g=a*t,m=g+t,v=l*t,k=v+t;let C=0;for(let _=g;_<m;_+=1)if(!(_>=n))for(let y=v;y<k;y+=1){if(y>=r)continue;const w=(n*y+_)*4;c+=s[w+0],u+=s[w+1],f+=s[w+2],h+=s[w+3],C+=1}c=c/C,u=u/C,f=f/C,h=h/C;for(let _=g;_<m;_+=1)if(!(_>=n))for(let y=v;y<k;y+=1){if(y>=r)continue;const w=(n*y+_)*4;s[w+0]=c,s[w+1]=u,s[w+2]=f,s[w+3]=h}}};ce.addGetterSetter(At,"pixelSize",8,wt(),ce.afterSetFilter);var CF=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};ce.addGetterSetter(At,"levels",.5,wt(),ce.afterSetFilter);var kF=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*o,t[s+2]=a*i,t[s+3]=t[s+3]}};ce.addGetterSetter(At,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(At,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(At,"blue",0,S_,ce.afterSetFilter);var SF=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};ce.addGetterSetter(At,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(At,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(At,"blue",0,S_,ce.afterSetFilter),ce.addGetterSetter(At,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var _F=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},AF=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},IF=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};ce.addGetterSetter(At,"threshold",.5,wt(),ce.afterSetFilter);var xF=e4.Util._assign(e4,{Arc:Aa,Arrow:Ql,Circle:pu,Ellipse:al,Image:Qi,Label:z0,Tag:Jl,Line:Ia,Path:Pi,Rect:Af,RegularPolygon:ll,Ring:ec,Sprite:Ms,Star:cl,Text:ar,TextPath:Yr,Transformer:xn,Wedge:xa,Filters:{Blur:JO,Brightness:tF,Brighten:eF,Contrast:nF,Emboss:rF,Enhance:oF,Grayscale:iF,HSL:sF,HSV:aF,Invert:lF,Kaleidoscope:dF,Mask:yF,Noise:bF,Pixelate:wF,Posterize:CF,RGB:kF,RGBA:SF,Sepia:_F,Solarize:AF,Threshold:IF}}),EF=xF;Rt();var TF=["dialog","floating"],S4=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function RF(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!TF.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!S4.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${S4.join(", ")}, got "${e.floating.placement}".`)}var LF=class{activeDialog=zr(null);activeFloating=zr(null);#e=!1;#n=1;#t;constructor({getModuleConfig:e}){this.#t=e}open(e){if(this.#e)return this.#f(e);RF(e);const t=this.#d(e),{component:n,props:r,render:o}=this.#h(t);let i,s=!1;const a=new Promise(g=>{i=m=>s?!1:(s=!0,g(m),!0)});let l;const c=g=>{i({status:"submitted",data:g})&&this.#i(l)},u=g=>{i({status:"closed",reason:g})&&this.#i(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:c,close:u,settle:g=>i(g),get settled(){return s}};const f=t.mode==="dialog"?"activeDialog":"activeFloating",h=this[f].value;return h&&!h.settled&&h.settle({status:"replaced",replacedBy:t.id}),this[f].value=l,{id:t.id,mode:t.mode,close:g=>this.#r(l,g),result:a}}close(e,t){if(e!=null){const o=this.#s(e);o&&this.#r(o,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#r(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#r(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#r(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#i(e))}#i(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#s(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#d(e){const t=e.id??`surface-${this.#n++}`,n=this.#t()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:o,floating:i}}#h(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#t()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via surfaces.resolver, or use a direct-render request.`)}#f(e){return{id:e?.id??`surface-${this.#n++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},MF="https://docs.superdoc.dev/guides/migration/document-api",_4=new Set;function PF(e,t){_4.has(e)||(_4.add(e),console.warn(t))}var DF={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},A4=Symbol.for("superdoc:rawEditor"),I4=new WeakMap;function x4(e){return!e||e[A4]?e:new Proxy(e,{get(t,n){if(n===A4)return t;const r=DF[n];r&&PF(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${MF}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=I4.get(t);return i||(i=new Map,I4.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var E4=["review","original","final","off"],OF=["paired","independent"],T4=Symbol.for("@superdoc/trackChanges:normalized"),R4=new Set;function L4(e,t){R4.has(e)||(R4.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function M4(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function FF(e,t,n){return typeof e=="string"&&E4.includes(e)?e:typeof t=="string"&&E4.includes(t)?t:n}function NF(e){return typeof e=="string"&&OF.includes(e)?e:null}function tc(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function BF(e){const t=e[T4]===!0;tc(e.modules)||(e.modules={});const n=tc(e.modules.trackChanges),r=tc(e.trackChanges),o=tc(e.layoutEngineOptions?.trackedChanges);t||(r&&L4("config.trackChanges","config.modules.trackChanges"),o&&L4("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=M4(n?.visible,r?.visible,!1),s=M4(n?.enabled,o?.enabled,!0),a=NF(n?.replacements)??"paired",l=tc(n?.authorColors)?n.authorColors:void 0,c=tc(n?.semanticColors)?n.semanticColors:void 0,u=e.documentMode==="viewing"?i?"review":"original":"review",f=FF(n?.mode,o?.mode,u),h={visible:i,mode:f,enabled:s,replacements:a};return l&&(h.authorColors=l),c&&(h.semanticColors=c),e.modules.trackChanges=h,e.trackChanges={visible:i},tc(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:f,enabled:s},Object.defineProperty(e,T4,{value:!0,writable:!0,configurable:!0,enumerable:!1}),h}var $0=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function zF(e){return!e||typeof e!="object"?{...$0}:{...$0,...e}}var P4=Object.freeze({toolbar:!0,comments:!0,contextMenu:!0,search:!1,linkPopover:!1,ruler:!1,contentControls:!0}),VF=Object.freeze(["left","center","right"]),AH=Object.freeze(Object.keys(P4)),gu=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function D4(e,t){const n=e?.[t];return n===!1?!1:n===void 0?P4[t]:!0}function jF(e,t){const n=e?.[t];return gu(n)?n:{}}var O4=Object.freeze(["readOnly","allowResolve","permissionResolver"]);function UF(e){if(!O4.some(n=>n in e))return e;const t={...e};for(const n of O4)delete t[n];return t}function F4(e={}){const t=e.ui,n=t===!1,r=gu(t)?t:void 0,o=B=>!n&&D4(r,B),i=B=>n?!1:r?.[B]===void 0?void 0:D4(r,B),s=B=>n?{}:jF(r,B),a=n||i("ruler")===!1,l=n||i("linkPopover")===!1,c=l?void 0:d0(s("linkPopover").popoverResolver,e.modules?.links?.popoverResolver),u=i("contentControls")??(!n&&e.modules?.contentControls?.chrome!=="none"),f=e.modules?.contentControls?.chrome==="none"?void 0:e.modules?.contentControls?.chrome,h=s("toolbar"),g=e.modules?.toolbar,m=gu(g)?g:{},v=e.modules?.contextMenu??e.modules?.slashMenu,k=gu(v)?v:{},C=e.modules?.surfaces?.findReplace,_=gu(C)?C:{},y=[h.groups,m.groups],w=y.find(gu),T=y.find(Array.isArray),L=d0(T,m.toolbarGroups,e.toolbarGroups),F=Array.isArray(L)?L:null,H=(B,q)=>Object.prototype.hasOwnProperty.call(B,q),M=w&&F?Object.fromEntries([...F.filter(B=>H(w,B)),...Object.keys(w).filter(B=>!VF.includes(B))].map(B=>[B,w[B]])):w;return{enabled:!n,toolbar:{enabled:o("toolbar"),container:n?null:d0(h.container,m.selector,e.toolbar)??null,options:n?{}:{...Ls(m,h),groups:M,toolbarGroups:L,icons:Ls(e.toolbarIcons,m.icons,h.icons),texts:Ls(e.toolbarTexts,m.texts,h.texts)}},comments:{enabled:i("comments")??(!n&&e.modules?.comments!==!1),options:n?{}:Pk(UF(s("comments")))},contextMenu:{enabled:i("contextMenu")??(!n&&e.disableContextMenu!==!0),suppressed:n||i("contextMenu")===!1,options:n?{}:Ls(k,s("contextMenu"))},search:{enabled:i("search")??(!n&&!!e.modules?.surfaces?.findReplace),options:n?{}:Ls(_,s("search"))},linkPopover:{enabled:typeof c=="function",suppressed:l,options:Ls(s("linkPopover"),{popoverResolver:c})},ruler:{enabled:i("ruler")??(!n&&!!e.rulers),suppressed:a,container:a?null:s("ruler").container??e.rulerContainer??null},contentControls:{enabled:u,options:u?Ls({chrome:f},s("contentControls")):{chrome:"none"}}}}var G0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function N4(e={}){const t=G0(e.interaction)?e.interaction:{},n=G0(t.comments)?t.comments:{},r=G0(e.modules?.comments)?e.modules.comments:{};return{comments:{readOnly:(n.readOnly??r.readOnly??!1)===!0,allowResolve:(n.allowResolve??r.allowResolve??!0)!==!1}}}var B4=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function z4(e={}){const t=B4(e.surfaces)?e.surfaces:{},n=B4(e.modules?.surfaces)?e.modules.surfaces:{},r=t.resolver===void 0?n.resolver:t.resolver;return{resolver:typeof r=="function"?r:null,dialog:Ls(n.dialog,t.dialog),floating:Ls(n.floating,t.floating)}}var HF=class{#e=new Map;#n=new Map;#t=null;#r=new Set;register(e){if(this.#e.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#n.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#e.set(e.id,e),t&&this.#n.set(t,e.id)}unregister(e){const t=this.#e.get(e);return t?(this.#e.delete(e),t.root&&this.#n.delete(t.root),this.#t===e&&(this.#t=null,this.#i({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#e.get(e)??null}getAll(){return Array.from(this.#e.values())}getAllByDocumentId(e){const t=[];for(const n of this.#e.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#t===null?null:this.#e.get(this.#t)}getActiveId(){return this.#t}setActive(e,t){if(e!==null&&!this.#e.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#t)return;const n=this.#t;this.#t=e;let r=null;e!==null&&(r=this.#e.get(e).getLegacyEditorProjection?.()??null),this.#i({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${Pp}]`);if(!n)return null;const r=n.getAttribute(Pp),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#r.add(e),()=>{this.#r.delete(e)}}clear(){this.#e.clear(),this.#n.clear(),this.#t=null,this.#r.clear()}#i(e){for(const t of Array.from(this.#r))try{t(e)}catch{}}},ct={notReady:"not-ready",documentApiUnavailable:"document-api-unavailable",documentReadonly:"document-readonly",selectionRequired:"selection-required",rangeSelectionRequired:"range-selection-required",contextUnavailable:"context-unavailable",geometryUnavailable:"geometry-unavailable",targetUnresolved:"target-unresolved",targetNotVisible:"target-not-visible",commandUnsupported:"command-unsupported",commandDeferred:"command-deferred",tableContextUnavailable:"table-context-unavailable",operationUnavailable:"operation-unavailable",bulkDecisionsDisabled:"bulk-decisions-disabled",hostCapabilityUnavailable:"host-capability-unavailable",historyEmpty:"history-empty",searchUnavailable:"search-unavailable",searchInvalidPattern:"search-invalid-pattern",replaceUnsupported:"replace-unsupported",contentControlLocked:"content-control-locked"},V4={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontFamily:"font-family",fontSize:"font-size",setFontFamily:"setFontFamily",setFontSize:"setFontSize",undo:"undo",redo:"redo",acceptChange:"acceptChange",rejectChange:"rejectChange",acceptAllChanges:"acceptAllChanges",rejectAllChanges:"rejectAllChanges",bulletList:"bullet-list",numberedList:"numbered-list"};function j4(e){const t=n=>typeof n=="string"?n.replace(/\s*pt$/i,"").trim():n;if(typeof e=="string")return t(e);if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return e}function $F(e){const t=(n,r)=>!r&&n>0&&n<=5?n*100:n;if(typeof e=="string"){const n=e.includes("%"),r=Number.parseFloat(e.replace("%","").trim());return Number.isFinite(r)?t(r,n):e}return typeof e=="number"&&Number.isFinite(e)?t(e,!1):e}function GF(e){const t=e&&typeof e=="object"&&"value"in e?e.value:e;if(t==="in"||t==="cm")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="in"||n==="inch"||n==="inches")return"in";if(n==="cm"||n==="centimeter"||n==="centimeters"||n==="centimetre"||n==="centimetres")return"cm"}return t}function U4(e){const t=n=>{if(n===null)return null;if(typeof n!="string")return n;const r=n.trim();return r===""?n:/^#[0-9a-fA-F]{6}$/.test(r)?r:/^[0-9a-fA-F]{6}$/.test(r)?`#${r}`:r};if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return t(e)}function W0(e,t){if(e&&typeof e=="object"){const n=e;for(const r of t)if(r in n)return n[r]}return e}function WF(e){const t=W0(e,["alignment","value"]);if(typeof t!="string")return t;const n=t.trim().toLowerCase();return n==="justified"||n==="both"?"justify":n}function KF(e){const t=W0(e,["line","lineHeight","value"]),n=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t.trim()):NaN;return!Number.isFinite(n)||n<=0?t:n<=10?Math.round(n*240):Math.round(n)}function qF(e){if(e&&typeof e=="object"&&"role"in e)return e;const t=W0(e,["styleId","value","style"]);return typeof t=="string"?t.trim():t}function YF(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.mode;if(typeof t=="string")return t}return e}var XF=ct.commandUnsupported,Ps=ct.tableContextUnavailable,H4=[{id:"bold",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.bold",activeMark:"bold",inline:{key:"bold",kind:"toggle"}},{id:"italic",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.italic",activeMark:"italic",inline:{key:"italic",kind:"toggle"}},{id:"underline",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.underline",activeMark:"underline",inline:{key:"underline",kind:"toggle"}},{id:"strikethrough",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.strikethrough",activeMark:"strikethrough",inline:{key:"strike",kind:"toggle"}},{id:"font-family",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliases:["setFontFamily"],inline:{key:"fontFamily",kind:"value-string"}},{id:"font-size",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliases:["setFontSize"],normalizePayload:j4,inline:{key:"fontSize",kind:"value-number"}},{id:"setFontFamily",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliasOf:"font-family",inline:{key:"fontFamily",kind:"value-string"}},{id:"setFontSize",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliasOf:"font-size",normalizePayload:j4,inline:{key:"fontSize",kind:"value-number"}},{id:"undo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.undo"},{id:"redo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.redo"},{id:"acceptChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliases:["track-changes-accept-selection"]},{id:"rejectChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliases:["track-changes-reject-selection"]},{id:"acceptAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"all"}},{id:"rejectAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"all"}},{id:"track-changes-accept-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliasOf:"acceptChange"},{id:"track-changes-reject-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliasOf:"rejectChange"},{id:"zoom",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoom",valueFrom:"zoom",normalizePayload:$F},{id:"zoom-fit-width",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoomMode",fixedArg:"fit-width",valueFrom:"zoom"},{id:"document-mode",family:"document",disposition:"routed",mutates:!1,instanceRoute:"setDocumentMode",valueFrom:"documentMode",normalizePayload:YF},{id:"measurement-unit",family:"measurement",disposition:"routed",mutates:!1,instanceRoute:"setMeasurementUnit",valueFrom:"measurementUnit",normalizePayload:GF},{id:"text-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.color",inline:{key:"color",kind:"value-string"},normalizePayload:U4},{id:"highlight-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.highlight",inline:{key:"highlight",kind:"value-string"},normalizePayload:U4},{id:"link",family:"links",disposition:"routed",mutates:!0,docRoute:"hyperlinks.wrap",activeMark:"link",link:{kind:"link"}},{id:"text-align",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setAlignment",blockParagraph:{kind:"alignment"},normalizePayload:WF},{id:"line-height",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setSpacing",blockParagraph:{kind:"spacing-line"},normalizePayload:KF},{id:"linked-style",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"styles.paragraph.setStyle",blockParagraph:{kind:"style"},normalizePayload:qF},{id:"bullet-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"bullet"}},{id:"numbered-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"ordered"}},{id:"indent-increase",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.indent",list:{mode:"indent"}},{id:"indent-decrease",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.outdent",list:{mode:"outdent"}},{id:"direction-ltr",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"ltr"}},{id:"direction-rtl",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"rtl"}},{id:"clear-formatting",family:"formatting",disposition:"routed",mutates:!0,docRoute:"format.apply",inline:{key:"*",kind:"clear"}},{id:"image",family:"media",disposition:"routed",mutates:!0,docRoute:"create.image",create:{kind:"image"}},{id:"table-of-contents-insert",family:"TOC",disposition:"routed",mutates:!0,docRoute:"create.tableOfContents",create:{kind:"toc"}},{id:"table-insert",family:"tables",disposition:"routed",mutates:!0,docRoute:"create.table",create:{kind:"table"}},{id:"table-add-row-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-before",op:"insertRow"},reason:Ps},{id:"table-add-row-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-after",op:"insertRow"},reason:Ps},{id:"table-delete-row",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteRow",table:{action:"delete-row",op:"deleteRow"},reason:Ps},{id:"table-add-column-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-before",op:"insertColumn"},reason:Ps},{id:"table-add-column-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-after",op:"insertColumn"},reason:Ps},{id:"table-delete-column",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteColumn",table:{action:"delete-column",op:"deleteColumn"},reason:Ps},{id:"table-delete",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.delete",table:{action:"delete-table",op:"delete"},reason:Ps},{id:"table-merge-cells",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.mergeCells",table:{action:"merge-cells",op:"mergeCells"},reason:Ps},{id:"table-split-cell",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.splitCell",table:{action:"split-cell",op:"splitCell",requiresCell:!0},reason:Ps},{id:"table-remove-borders",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.setBorders",table:{action:"remove-borders",op:"setBorders"},reason:Ps},{id:"ruler",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleRuler",valueFrom:"ruler"},{id:"formatting-marks",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleFormattingMarks",valueFrom:"formattingMarks"},{id:"copy-format",family:"formatting",disposition:"routed",mutates:!1},{id:"table-fix",family:"tables",disposition:"unsupported",mutates:!0,reason:XF}],ZF=new Map(H4.map(e=>[e.id,e])),QF=H4.map(e=>e.id);function vu(e){return ZF.get(e)??null}var JF=["table-add-row-before","table-add-row-after","table-delete-row","table-add-column-before","table-add-column-after","table-delete-column","table-delete","table-merge-cells","table-split-cell","table-remove-borders"],$4=[{name:"bold",commandId:"bold",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"italic",commandId:"italic",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"underline",commandId:"underline",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"strike",commandId:"strikethrough",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"clearFormatting",commandId:"clear-formatting",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"copyFormat",commandId:"copy-format",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontFamily",commandId:"font-family",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontSize",commandId:"font-size",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"color",commandId:"text-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"highlight",commandId:"highlight-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"textAlign",commandId:"text-align",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"list",commandId:"bullet-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"numberedlist",commandId:"numbered-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentleft",commandId:"indent-decrease",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentright",commandId:"indent-increase",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"lineHeight",commandId:"line-height",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"linkedStyles",commandId:"linked-style",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"link",commandId:"link",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"image",commandId:"image",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"table",commandId:"table-insert",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"tableActions",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",memberCommandIds:JF,note:"table editing dropdown is shell chrome; its member commands are controller-routed through the shared table-context facade (ui.tables / host.getTableContext()) and fail closed with table-context-unavailable when the caret is not in a table"},{name:"undo",commandId:"undo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"redo",commandId:"redo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"search",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"right",note:"built-in search button; opens the shared find/replace surface (the same one Cmd/Ctrl+F opens) by emitting a `search:open` event on the SuperDoc instance, which the shell handles. The surface reads/drives the controller search surface (ui.search), backed by the single V2 host search session (host.search) which owns query, navigation, reveal, and replace. Find/navigation are always available when the host exposes search; replace/replaceAll mutate through the host session and fail closed (document-readonly) in viewing/read-only mode. If a runtime cannot expose search, the surface fails closed with search-unavailable"},{name:"zoom",commandId:"zoom",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"measurementUnit",commandId:"measurement-unit",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"ruler",commandId:null,instanceMethod:"toggleRuler",disposition:"host-routed",group:"right",note:"built-in shell toggles ruler visibility through the public SuperDoc.toggleRuler() instance method; the controller also routes the ruler command through it so custom UIs drive the same chrome (active state from config.rulers)"},{name:"formattingMarks",commandId:null,instanceMethod:"toggleFormattingMarks",disposition:"host-routed",group:"right",note:"built-in shell toggles nonprinting marks through the public SuperDoc.toggleFormattingMarks()/setShowFormattingMarks() instance methods (not a controller command)"},{name:"documentMode",commandId:"document-mode",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"acceptTrackedChangeBySelection",commandId:"track-changes-accept-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"rejectTrackedChangeOnSelection",commandId:"track-changes-reject-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"customButtons",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",note:"consumer-defined buttons the rendered shell owns; their execution context surface is phase 2"}],G4=new Map($4.map(e=>[e.name,e])),IH=$4.map(e=>e.name);function K0(e){return G4.get(e)??null}function eN(e){const t=G4.get(e);return t?.disposition==="controller-routed"?t.commandId:null}var tN=".png,.jpg,.jpeg,image/png,image/jpeg",W4=new Set(["image/png","image/jpeg","image/jpg"]),nN=/\.(png|jpe?g)$/i;function rN(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?W4.has(t):nN.test(String(e.name??""))}function K4(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(oN(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function oN(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(W4.has(r))return e;const o=String(t?.name??""),i=/\.jpe?g$/i.test(o)?"image/jpeg":/\.png$/i.test(o)?"image/png":null;return i?`data:${i};base64,${e.slice(n[0].length)}`:e}async function iN(e,t){if(typeof t=="function"){const n=await t(e);if(typeof n!="string"||n.trim()==="")throw new Error("handleImageUpload returned an empty result");return n.startsWith("data:")?n:sN(n,e)}return K4(e)}async function sN(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`image fetch failed: ${n.status}`);const r=await n.blob(),o=(/\.(?:png|jpe?g)(?:$|[?#])/i.test(e)?e.split(/[?#]/)[0]:"")||t?.name||"";return K4(o?Object.assign(r,{name:o}):r)}function aN({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=tN,r.hidden=!0,r.tabIndex=-1,r.setAttribute("data-superdoc-image-picker","true"),r.setAttribute("aria-hidden","true"),r.addEventListener("change",()=>{const o=r.files&&r.files[0];if(r.value="",!!o){if(!rN(o)){n?.(new Error(`unsupported image type: ${o.type||o.name}`));return}try{const i=t?.(o);i&&typeof i.then=="function"&&i.catch(s=>n?.(s))}catch(i){n?.(i)}}}),e.body?.appendChild(r),{input:r,open(){r.click()},destroy(){r.remove()}}}var lN=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},cN=(e,t,n)=>{let r,o,i,s=0;n||(n={});const a=()=>{s=n.leading===!1?0:Date.now(),r=null,i=e(...o),r||(o=null)},l=(...c)=>{const u=Date.now();!s&&n.leading===!1&&(s=u);const f=t-(u-s);return o=c,f<=0||f>t?(r&&(clearTimeout(r),r=null),s=u,i=e(...c),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,f)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};Rt(),pn();var uN={class:"sd-toolbar-icon"},dN=["innerHTML"],fN={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ke(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ke(()=>["color","highlight"].includes(t.name));return(o,i)=>(ge(),xe("div",uN,[Fe("div",{class:rn(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,dN),r.value?(ge(),xe("div",{key:0,class:"color-bar",style:vn(n.value)},null,4)):gt("",!0)]))}},q4=fn(fN,[["__scopeId","data-v-d7d79424"]]);Rt(),pn();var hN=["role","aria-label"],pN=["data-item"],mN=["data-item"],gN={key:1,class:"sd-button-label"},vN=["data-item","aria-label"],yN=["innerHTML"],bN={key:2},wN=["onKeydown","id"],CN=["placeholder","onKeydown","id","data-item"],kN=["data-item","innerHTML"],SN={"aria-live":"polite",class:"sd-visually-hidden"},_N={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,{proxy:r}=dr(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:c,iconColor:u,hasCaret:f,splitButton:h,disabled:g,expand:m,inlineTextInputVisible:v,hasInlineTextInput:k,minWidth:C,style:_,attributes:y}=o.toolbarItem,w=ke(()=>!!h?.value&&!!f?.value),T=ke(()=>i?.value??""),L=te(""),F=te(null),{isHighContrastMode:H}=qi();Nt(()=>l?.value,_e=>{document.activeElement!==F.value&&(L.value=_e==null?"":String(_e))},{immediate:!0});const M=()=>{k&&xt(()=>{F.value?.focus(),F.value?.select()}),n("buttonClick")},B=_e=>{g?.value||(_e?.stopPropagation(),n("mainClick"))},q=()=>{w.value||M()},P=_e=>{if(w.value){B(_e);return}M()},N=_e=>{o.allowEnterPropagation||_e.stopPropagation(),P(_e)},E=_e=>{const oe=o.toolbarItem?.nestedOptions?.value??[],Re=_e.trim();if(!Re)return"";const je=oe.find(et=>typeof et?.label=="string"&&et.label.toLowerCase()===Re.toLowerCase());return je?.label?je.label:oe.find(et=>typeof et?.label=="string"&&et.label.toLowerCase().startsWith(Re.toLowerCase()))?.label??Re},j=()=>{const _e=String(L.value??"").trim();let oe=_e;if(T.value==="fontSize"){const Re=Number.parseFloat(_e);oe=_e.match(/^\d+(\.5)?$/)?_e:Number.isFinite(Re)?Math.floor(Re).toString():""}else T.value==="fontFamily"&&(oe=E(_e));return oe?(n("textSubmit",oe),L.value=oe,!0):!1},Q=_e=>{const oe=_e?.currentTarget;oe instanceof HTMLInputElement&&(oe.focus({preventScroll:!0}),oe.select())},Y=_e=>{requestAnimationFrame(()=>{const oe=document.getElementById(`inlineTextInput-${_e}`);oe instanceof HTMLInputElement&&(oe.focus({preventScroll:!0}),oe.select())})},se=()=>{const _e=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return _e instanceof HTMLElement?(_e.focus({preventScroll:!0}),!0):!1},he=()=>{const _e=r?.$toolbar?.pendingSelectionCapture,oe=()=>{_e&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(_e)};if(se()){oe();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),oe())},Ve=()=>{j()&&he()},pe=_e=>{if(j(),_e.shiftKey){T.value==="fontSize"&&(_e.preventDefault(),xt(()=>Y("fontFamily")));return}if(_e.preventDefault(),T.value==="fontFamily"){xt(()=>Y("fontSize"));return}T.value==="fontSize"&&xt(he)},ye=ke(()=>_.value?_.value:{minWidth:o.minWidth}),me=ke(()=>m?.value?sr.dropdownCaretUp:sr.dropdownCaretDown);return(_e,oe)=>(ge(),xe("div",{class:rn(["sd-toolbar-item",Xe(y).className]),style:vn(ye.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Xe(y).ariaLabel,"data-sd-part":"toolbar-item",onClick:q,onKeydown:oe[9]||(oe[9]=ei(Re=>N(Re),["enter"])),tabindex:"0"},[Fe("div",{class:rn(["sd-toolbar-button",{"sd-active":Xe(s),"sd-disabled":Xe(g),narrow:e.isNarrow,wide:e.isWide,split:w.value,"has-inline-text-input":Xe(k),"high-contrast":Xe(H)}]),"data-item":`btn-${Xe(i)||""}`},[w.value?(ge(),xe("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${Xe(i)||""}-main`,onClick:oe[0]||(oe[0]=Re=>B(Re))},[Xe(a)?(ge(),sn(q4,{key:0,color:Xe(u),class:"sd-toolbar-icon",icon:Xe(a),name:Xe(i)},null,8,["color","icon","name"])):gt("",!0),Xe(l)&&!Xe(c)&&!Xe(v)?(ge(),xe("div",gN,jt(Xe(l)),1)):gt("",!0)],8,mN)):gt("",!0),w.value?(ge(),xe("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${Xe(i)||""}-caret`,"aria-label":`${Xe(y).ariaLabel} options`,role:"button"},[Fe("div",{class:"sd-dropdown-caret",innerHTML:me.value,style:vn({opacity:Xe(g)?.6:1})},null,12,yN)],8,vN)):(ge(),xe(Gt,{key:2},[Xe(a)?(ge(),sn(q4,{key:0,color:Xe(u),class:"sd-toolbar-icon",icon:Xe(a),name:Xe(i)},null,8,["color","icon","name"])):gt("",!0),Xe(l)&&!Xe(c)&&(!Xe(v)||T.value==="fontFamily")?(ge(),xe("div",{key:1,class:rn(["sd-button-label",{"sd-visually-hidden":Xe(v)&&T.value==="fontFamily"}])},jt(Xe(l)),3)):gt("",!0),Xe(v)?(ge(),xe("span",bN,[Xe(i)==="fontSize"?sa((ge(),xe("input",{key:0,"onUpdate:modelValue":oe[1]||(oe[1]=Re=>L.value=Re),onKeydown:[ei(en(Ve,["stop","prevent"]),["enter"]),oe[2]||(oe[2]=ei(Re=>pe(Re),["tab"]))],onClick:oe[3]||(oe[3]=en(Re=>Q(Re),["stop"])),onFocus:oe[4]||(oe[4]=Re=>Q(Re)),type:"text",class:rn(["button-text-input button-text-input--font-size",{"high-contrast":Xe(H)}]),id:"inlineTextInput-"+Xe(i),autocomplete:"off",ref_key:"inlineInput",ref:F},null,42,wN)),[[Li,L.value]]):sa((ge(),xe("input",{key:1,"onUpdate:modelValue":oe[5]||(oe[5]=Re=>L.value=Re),placeholder:Xe(l),onKeydown:[ei(en(Ve,["stop","prevent"]),["enter"]),oe[6]||(oe[6]=ei(Re=>pe(Re),["tab"]))],onClick:oe[7]||(oe[7]=en(Re=>Q(Re),["stop"])),onFocus:oe[8]||(oe[8]=Re=>Q(Re)),type:"text",class:rn(["button-text-input",{"button-text-input--font-family":T.value==="fontFamily","high-contrast":Xe(H)}]),id:"inlineTextInput-"+Xe(i),"data-item":T.value==="fontFamily"?`btn-${Xe(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:F},null,42,CN)),[[Li,L.value]])])):gt("",!0),Xe(f)?(ge(),xe("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${Xe(i)||""}-toggle`,innerHTML:me.value,style:vn({opacity:Xe(g)?.6:1})},null,12,kN)):gt("",!0)],64)),Fe("div",SN,jt(`${Xe(y).ariaLabel} ${Xe(s)?"selected":"unset"}`),1)],10,pN)],46,hN))}},q0=fn(_N,[["__scopeId","data-v-dbdea151"]]);Rt(),pn();var AN={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},IN={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=qi(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(ge(),xe("div",AN,[Fe("div",{class:"separator-inner",style:vn({backgroundColor:r()})},null,4)]))}},xN=fn(IN,[["__scopeId","data-v-cb82253a"]]);Rt(),pn();var EN={class:"overflow-menu"},TN={class:"overflow-menu-trigger"},RN={key:0,class:"overflow-menu_items",role:"group"},LN={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=dr(),r=t,o=e,i=ke(()=>o.toolbarItem.expand.value),s=te(!1),a=ke(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},c=({item:f,argument:h})=>{n.$toolbar.emitCommand({item:f,argument:h})},u=f=>{f.key==="Escape"&&i.value&&!s.value&&(f.preventDefault(),r("close"))};return Pn(()=>{document.addEventListener("keydown",u,!0)}),ir(()=>{document.removeEventListener("keydown",u,!0)}),(f,h)=>(ge(),xe("div",EN,[Fe("div",TN,[Kt(q0,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(ge(),xe("div",RN,[Kt(rm,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:c,onDropdownUpdateShow:h[0]||(h[0]=g=>s.value=g)},null,8,["toolbar-items"])])):gt("",!0)]))}},MN=fn(LN,[["__scopeId","data-v-504ecd05"]]);Rt(),pn();var PN={class:"toolbar-dropdown"},DN=["onClick"],ON={key:0,class:"toolbar-dropdown-option__icon"},FN={class:"toolbar-dropdown-option__label"},em='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',NN={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null}},emits:["update:show","select"],setup(e,{emit:t}){const n=e,r=t,o=te(null),i=te(null),s=te({top:"0px",left:"0px",maxHeight:"none"}),a=te([]),l=te(-1),c=ke(()=>!!n.show),u=ke(()=>n.options.some(oe=>oe?.type==="render")),f=ke(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),h=ke(()=>{const{class:oe,style:Re,...je}=f.value;return je}),g=ke(()=>["toolbar-dropdown-menu",f.value.class,{"toolbar-dropdown-menu--render-only":n.options.length>0&&n.options.every(oe=>oe&&oe.type==="render")}]),m=ke(()=>{const oe=f.value.style||{};return{...n.contentStyle,...oe}}),v=ke(()=>({...m.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),k=oe=>{r("update:show",oe)},C=()=>{c.value&&k(!1)},_=()=>{if(!o.value)return;const oe=o.value.getBoundingClientRect(),Re=i.value,je=Re?.offsetWidth??0,et=Re?.scrollHeight??Re?.offsetHeight??0,St=window.innerWidth||document.documentElement.clientWidth||0,Te=window.innerHeight||document.documentElement.clientHeight||0,He=8,Ye=4,ee=oe.bottom+Ye,S=oe.top-Ye,ne=Math.max(0,Te-ee-He),O=Math.max(0,S-He),U=ne<et&&O>ne,$=U?O:ne,z=U?Math.max(He,S-(et?Math.min(et,$):$)):ee;let J=oe.left;n.placement==="bottom-end"&&(J=oe.right-je);const Z=Math.max(He,St-je-He);J=Math.min(Math.max(He,J),Z),s.value={top:`${z}px`,left:`${J}px`,maxHeight:`${$}px`}},y=()=>{n.disabled||k(!c.value)},w=oe=>typeof n.nodeProps!="function"?{}:n.nodeProps(oe)||{},T=oe=>{oe?.disabled||oe?.type!=="render"&&(r("select",oe?.key,oe),C())},L=oe=>oe?.type==="render",F=oe=>!oe?.disabled&&oe?.type!=="render",H=oe=>typeof oe?.icon=="function"||!!oe?.icon,M=oe=>typeof oe?.icon=="function"?oe.icon(oe):oe?.icon||null,B=oe=>oe?typeof oe=="string"?oe.split(/\s+/).includes("sd-selected"):Array.isArray(oe)?oe.some(B):typeof oe=="object"?!!oe["sd-selected"]:!1:!1,q=oe=>B(oe?.props?.class)||B(oe?.class),P=()=>n.options.map((oe,Re)=>F(oe)?Re:-1).filter(oe=>oe>=0),N=()=>{const oe=n.options.findIndex(Re=>F(Re)&&q(Re));return oe>=0?oe:P()[0]??-1},E=(oe,Re)=>{if(!oe){delete a.value[Re];return}a.value[Re]=oe},j=()=>{a.value.forEach((Re,je)=>{Re&&Re.setAttribute("tabindex",je===l.value?"0":"-1")});const oe=a.value[l.value];oe&&typeof oe.focus=="function"&&(oe.focus(),oe.scrollIntoView?.({block:"nearest",inline:"nearest"}))},Q=oe=>{const Re=P();if(!Re.length){l.value=-1;return}const je=Re.indexOf(l.value);if(je<0){l.value=oe>0?Re[0]:Re[Re.length-1];return}const et=(je+oe+Re.length)%Re.length;l.value=Re[et]},Y=()=>{let oe=n.options[l.value];if(!F(oe)){const Re=P()[0];oe=Re===void 0?null:n.options[Re]}oe&&T(oe)},se=Dl({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(oe){return()=>typeof oe.option.render!="function"?null:oe.option.render()}}),he=Dl({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(oe){return()=>M(oe.option)}}),Ve=oe=>{if(!c.value)return;const Re=oe.target;if(!(Re instanceof Element))return;const je=o.value?.contains(Re),et=i.value?.contains(Re);je||et||C()},pe=te(null),ye=()=>{const oe=o.value,Re=document.activeElement;if(oe&&Re instanceof HTMLElement&&oe.contains(Re)){pe.value=Re;return}pe.value=oe?.matches?.(em)?oe:oe?.querySelector(em)},me=()=>{const oe=pe.value;if(oe instanceof HTMLElement&&document.contains(oe)){oe.focus();return}const Re=o.value;if(!Re)return;const je=Re.matches?.(em)?Re:Re.querySelector(em);if(je instanceof HTMLElement){je.focus();return}Re.setAttribute("tabindex","-1"),Re.focus()},_e=oe=>{if(!c.value)return;const{key:Re}=oe;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(Re)){if(Re==="Escape"){oe.preventDefault(),C(),xt(()=>{requestAnimationFrame(me)});return}if(!u.value){if(oe.preventDefault(),Re==="ArrowDown"){Q(1),j();return}if(Re==="ArrowUp"){Q(-1),j();return}Re==="Enter"&&Y()}}};return Nt(c,async oe=>{if(!oe){l.value=-1,a.value=[];return}ye(),await xt(),_(),!u.value&&(l.value=N(),await xt(),j())},{immediate:!0}),Nt(c,oe=>{oe?(document.addEventListener("pointerdown",Ve,!0),document.addEventListener("keydown",_e,!0),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0)):(document.removeEventListener("pointerdown",Ve,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0))},{immediate:!0}),ir(()=>{document.removeEventListener("pointerdown",Ve,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}),(oe,Re)=>(ge(),xe("div",PN,[Fe("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:y},[kd(oe.$slots,"trigger",{},void 0,!0)],512),(ge(),sn($a,{to:"body"},[Kt(Uh,{name:"fade-in-scale-up-transition"},{default:Mo(()=>[c.value?(ge(),xe("div",bs({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:g.value,style:v.value},h.value),[(ge(!0),xe(Gt,null,ur(e.options,(je,et)=>(ge(),xe("div",bs({key:je.key,ref_for:!0,ref:St=>E(St,et),class:["toolbar-dropdown-option",[je.class,je.props?.class,{"sd-disabled":je.disabled,"sd-render":L(je)}]],tabindex:"-1",onClick:St=>T(je)},{ref_for:!0},{...je.props,...w(je)}),[L(je)?(ge(),sn(Xe(se),{key:0,option:je},null,8,["option"])):(ge(),xe(Gt,{key:1},[H(je)?(ge(),xe("span",ON,[Kt(Xe(he),{option:je},null,8,["option"])])):gt("",!0),Fe("span",FN,jt(je.label),1)],64))],16,DN))),128))],16)):gt("",!0)]),_:1})]))]))}},BN=fn(NN,[["__scopeId","data-v-fef410f7"]]),Y4=e=>String(e??"").trim().toLowerCase(),tm=(e,t)=>{const n=Y4(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(Y4(t[r]).startsWith(n))return r;return-1},zN=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=tm(r,t),i=o>=0?String(t[o]??""):"";return n&&o>=0&&i.length>r.length?{matchIndex:o,display:i,selectionStart:r.length,selectionEnd:i.length}:{matchIndex:o,display:r,selectionStart:r.length,selectionEnd:r.length}},VN=e=>{let t=String(e??"").trim();for(;t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"));)t=t.slice(1,-1).trim();return t},jN=e=>e<=31||e===127,UN=e=>e===32||e===160||e===65279,HN=e=>Array.from(String(e)).filter(t=>!jN(t.charCodeAt(0))).join(""),$N=e=>{let t="",n=!1;for(const r of String(e)){if(UN(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t},GN=e=>{const t=String(e??"").split(",")[0]??"",n=HN(t);return $N(VN(n)).trim()},WN=1,KN=1638,qN=e=>{const t=String(e??"").replace(/[^0-9.-]/g,""),n=Number.parseFloat(t);if(!Number.isFinite(n))return"";const r=Math.round(n*2)/2;return r<WN?"":String(Math.min(r,KN))};Rt(),pn();var YN=["data-item"],XN=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],ZN=["data-item","aria-label","disabled"],QN=["innerHTML"],JN=["id","aria-label"],eB=["id","aria-selected","aria-label","onMousedown","onMouseenter"],tB={class:"toolbar-dropdown-option__label"},nB={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},rB={__name:"ToolbarComboBox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},showPreview:{type:Boolean,default:!1},normalizeValue:{type:Function,default:e=>String(e??"").trim()}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t,{isHighContrastMode:o}=qi(),i=te(null),s=te(null),a=te(null),l=te([]),c=te(!1),u=te(!1),f=te(-1),h=te(""),g=te(""),m=te(!1),v=te({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),k=ke(()=>n.item.nestedOptions?.value??[]),C=ke(()=>k.value.map(Z=>String(Z?.label??""))),_=ke(()=>String(n.item.label?.value??"")),y=ke(()=>!!n.item.disabled?.value),w=ke(()=>String(n.item.name?.value??"")),T=ke(()=>n.item.attributes?.value?.ariaLabel??"Font family"),L=ke(()=>c.value?g.value:_.value),F=ke(()=>`sd-${w.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),H=Z=>`${F.value}-option-${Z}`,M=ke(()=>u.value&&f.value>=0?H(f.value):void 0),B=ke(()=>u.value?sr.dropdownCaretUp:sr.dropdownCaretDown),q=Z=>{const G=String(Z??"").trim().toLowerCase();return k.value.find(be=>String(be?.label??"").trim().toLowerCase()===G)?.props?.style?.fontFamily||Z||n.uiFontFamily},P=ke(()=>n.showPreview?{fontFamily:q(c.value?g.value:_.value)}:{fontFamily:n.uiFontFamily}),N=()=>{const Z=n.item.selectedValue?.value;if(Z){const G=k.value.findIndex(be=>be?.key===Z);if(G>=0)return G}return C.value.findIndex(G=>G.toLowerCase()===_.value.toLowerCase())},E=(Z,G)=>{const be=i.value;if(!(!be||typeof be.setSelectionRange!="function"))try{be.setSelectionRange(Z,G)}catch{}},j=()=>{l.value[f.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},Q=()=>{l.value[f.value]?.focus?.()},Y=()=>{const Z=s.value;if(!Z)return;const G=Z.getBoundingClientRect(),be=a.value,ve=be?.scrollHeight??be?.offsetHeight??0,Ce=window.innerHeight||document.documentElement.clientHeight||0,De=window.innerWidth||document.documentElement.clientWidth||0,Ze=8,ot=4,yt=G.bottom+ot,tn=G.top-ot,Ue=Math.max(0,Ce-yt-Ze),Ot=Math.max(0,tn-Ze),Bt=Ue<ve&&Ot>Ue,an=Bt?Ot:Ue,nr=Bt?Math.max(Ze,tn-(ve?Math.min(ve,an):an)):yt,qt=Math.min(Math.max(Ze,G.left),Math.max(Ze,De-G.width-Ze));v.value={top:`${nr}px`,left:`${qt}px`,minWidth:`${G.width}px`,maxHeight:`${an}px`}},se=ke(()=>({position:"fixed",top:v.value.top,left:v.value.left,minWidth:v.value.minWidth,maxHeight:v.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),he=Z=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=Z)},Ve=(Z,{focusInput:G=!1,focusOption:be=!1}={})=>{if(y.value||!k.value.length){he(!1);return}u.value=!0,he(!0),f.value=Z??-1,G&&(c.value=!0,g.value=_.value,i.value?.focus()),xt(()=>{Y(),j(),be&&Q()})},pe=({syncItem:Z=!0}={})=>{u.value=!1,f.value=-1,Z&&he(!1)},ye=()=>{pe(),c.value=!1,h.value="",g.value=_.value},me=()=>{y.value||(u.value||r("item-clicked"),c.value=!0,h.value="",g.value=_.value,xt(()=>E(0,g.value.length)))},_e=Z=>{if(y.value)return;const G=document.activeElement===i.value;if(r("item-clicked"),c.value=!0,G||(h.value="",g.value=_.value,Z.preventDefault(),i.value?.focus({preventScroll:!0}),E(0,_.value.length)),!u.value){const be=N();Ve(be>=0?be:0)}},oe=Z=>{const G=Z.relatedTarget;G instanceof Node&&s.value?.contains(G)||G instanceof Node&&a.value?.contains(G)||ye()},Re=Z=>{if(m.value)return;const G=Z.target,be=G.value,ve=typeof G.selectionStart=="number"?G.selectionStart:be.length,Ce=typeof G.selectionEnd=="number"?G.selectionEnd:ve,De=typeof Z.inputType=="string"&&Z.inputType.startsWith("delete"),Ze=ve===be.length&&Ce===be.length;h.value=be;const ot=zN(be,C.value,{autocomplete:!De&&Ze});g.value=ot.display,G.value=ot.display,ot.display===be&&!Ze?E(ve,Ce):E(ot.selectionStart,ot.selectionEnd),u.value&&(f.value=ot.matchIndex,xt(j))},je=Z=>{m.value=!1,Re(Z)},et=Z=>{if(!k.value.length)return;const G=k.value.length,be=f.value<0?Z>0?-1:0:f.value;f.value=(be+Z+G)%G,xt(j)},St=(Z,G)=>{r("item-clicked"),r("command",{item:n.item,argument:Z,option:G}),G&&(n.item.selectedValue.value=G.key)},Te=Z=>{Z&&(St(Z.label,Z),c.value=!1,h.value="",g.value=Z.label,pe())},He=()=>{if(u.value&&f.value>=0)return Te(k.value[f.value]),!0;const Z=tm(h.value,C.value);if(Z>=0)return Te(k.value[Z]),!0;const G=n.normalizeValue(h.value);return G?(St(G,null),c.value=!1,h.value="",g.value=G,pe(),!0):!1},Ye=Z=>{if(!(Z.isComposing||m.value||Z.keyCode===229)&&!(Z.ctrlKey||Z.metaKey||Z.altKey))switch(Z.key){case"ArrowDown":if(Z.preventDefault(),u.value)Q();else{const G=tm(h.value,C.value),be=G>=0?G:N();Ve(be>=0?be:0,{focusOption:!0})}break;case"ArrowUp":if(Z.preventDefault(),u.value)Q();else{const G=tm(h.value,C.value),be=G>=0?G:N();Ve(be>=0?be:k.value.length-1,{focusOption:!0})}break;case"Enter":Z.preventDefault(),He()&&r("editor-handoff"),i.value?.blur();break;case"Tab":Z.preventDefault(),He(),pe(),i.value?.blur(),r("tab-out",Z);break;case"Escape":Z.preventDefault(),ye(),xt(()=>i.value?.focus())}},ee=Z=>{if(Z.preventDefault(),!y.value)if(r("item-clicked"),u.value)pe(),i.value?.focus();else{const G=N();Ve(G>=0?G:0,{focusOption:!0})}},S=(Z,G)=>{Z.preventDefault(),Te(G),r("editor-handoff"),i.value?.blur()},ne=Z=>{f.value=Z},O=Z=>{if(!(Z.ctrlKey||Z.metaKey||Z.altKey))switch(Z.key){case"ArrowDown":Z.preventDefault(),et(1),Q();break;case"ArrowUp":Z.preventDefault(),et(-1),Q();break;case"Enter":Z.preventDefault(),f.value>=0&&(Te(k.value[f.value]),r("editor-handoff"));break;case"Escape":Z.preventDefault(),ye(),xt(()=>i.value?.focus());break;case"Tab":Z.preventDefault(),f.value>=0?Te(k.value[f.value]):pe(),r("tab-out",{shiftKey:Z.shiftKey,target:i.value})}},U=Z=>{if(!u.value)return;const G=Z.target;G instanceof Element&&(s.value?.contains(G)||a.value?.contains(G)||ye())};Nt(u,Z=>{Z?(document.addEventListener("pointerdown",U,!0),window.addEventListener("resize",Y),window.addEventListener("scroll",Y,!0)):(document.removeEventListener("pointerdown",U,!0),window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0),l.value=[])},{immediate:!0}),ir(()=>{document.removeEventListener("pointerdown",U,!0),window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0)});const $=(Z,G)=>{if(!Z){delete l.value[G];return}l.value[G]=Z},z=Z=>Z===f.value,J=Z=>Z?.key&&Z.key===n.item.selectedValue?.value;return Nt(_,Z=>{c.value||(g.value=Z)}),Nt(()=>!!n.item.expand?.value,Z=>{if(Z&&!u.value){const G=N();Ve(G>=0?G:0,{focusInput:!0});return}!Z&&u.value&&pe({syncItem:!1})}),(Z,G)=>(ge(),xe("div",{ref_key:"rootRef",ref:s,class:rn(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":y.value,"high-contrast":Xe(o)}]),style:vn(n.item.style?.value),"data-item":`btn-${w.value}`},[Fe("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:_e},[Fe("input",{ref_key:"inputRef",ref:i,id:`inlineTextInput-${w.value}`,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:L.value,style:vn(P.value),disabled:y.value,"aria-label":T.value,"aria-expanded":u.value?"true":"false","aria-controls":F.value,"aria-activedescendant":M.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${w.value}-input`,onFocus:me,onBlur:oe,onInput:Re,onKeydown:Ye,onCompositionstart:G[0]||(G[0]=be=>m.value=!0),onCompositionend:je},null,44,XN)],32),Fe("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":`btn-${w.value}-toggle`,tabindex:"-1","aria-label":`${T.value} options`,disabled:y.value,onMousedown:ee},[Fe("span",{class:"sd-dropdown-caret",innerHTML:B.value},null,8,QN)],40,ZN),(ge(),sn($a,{to:"body"},[u.value?(ge(),xe("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:F.value,"aria-label":T.value,class:rn(["sd-font-combobox__listbox",{"high-contrast":Xe(o)}]),style:vn(se.value)},[(ge(!0),xe(Gt,null,ur(k.value,(be,ve)=>(ge(),xe("div",bs({key:be.key,ref_for:!0,ref:Ce=>$(Ce,ve),id:H(ve),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":z(ve),"sd-selected":J(be)}],"aria-selected":J(be)?"true":"false","aria-label":`${T.value} - ${be.label}`},{ref_for:!0},be.props,{onMousedown:Ce=>S(Ce,be),onMouseenter:Ce=>ne(ve),onKeydown:O}),[Fe("span",tB,jt(be.label),1)],16,eB))),128))],14,JN)):gt("",!0)])),Fe("span",nB,jt(_.value),1)],14,YN))}},X4=fn(rB,[["__scopeId","data-v-99070b63"]]);Rt();var oB={__name:"FontFamilyCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),sn(X4,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":Xe(GN),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}};Rt();var iB={__name:"FontSizeCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),sn(X4,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":Xe(qN),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}};Rt(),pn();var sB=2500,aB=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=K1(),r=te(!1),o=te(null),i=te(null),s=te({top:"0px",left:"0px"});let a=null,l=null,c=null;const u=ke(()=>["sd-tooltip-content",n.class]),f=ke(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),h=()=>{a&&(window.clearTimeout(a),a=null)},g=()=>{l&&(window.clearTimeout(l),l=null)},m=()=>{c&&(window.clearTimeout(c),c=null)},v=()=>{m(),c=window.setTimeout(()=>{c=null,_()},sB)},k=()=>{if(!o.value||!i.value)return;const B=o.value.getBoundingClientRect(),q=i.value.offsetWidth,P=i.value.offsetHeight,N=window.innerWidth||document.documentElement.clientWidth||0,E=8;let j=B.left+B.width/2-q/2;j=Math.max(E,Math.min(j,N-q-E)),s.value={top:`${B.top-P-10}px`,left:`${j}px`}},C=async()=>{t.disabled||(h(),g(),!r.value&&(r.value=!0,v(),await xt(),k()))},_=()=>{g(),h(),m(),r.value&&(r.value=!1)},y=()=>{if(h(),g(),!r.value){if(t.delay===0){C();return}l=window.setTimeout(()=>{l=null,C()},t.delay)}},w=()=>{if(g(),h(),!!r.value){if(t.duration===0){_();return}a=window.setTimeout(()=>{a=null,_()},t.duration)}},T=()=>{t.trigger==="hover"&&y()},L=()=>{t.trigger==="hover"&&w()},F=()=>{g(),h()},H=()=>{w()},M=B=>{B.key==="Escape"&&_()};return Nt(()=>t.disabled,B=>{B&&_()}),Nt(r,B=>{B?(window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),document.addEventListener("keydown",M,!0)):(window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),document.removeEventListener("keydown",M,!0))}),ir(()=>{g(),h(),m(),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),document.removeEventListener("keydown",M,!0)}),(B,q)=>(ge(),xe(Gt,null,[Fe("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:T,onMouseleave:L,onFocusin:T,onFocusout:L},[kd(B.$slots,"trigger",{},void 0,!0)],544),(ge(),sn($a,{to:"body"},[Kt(Uh,{name:"fade-in-scale-up-transition"},{default:Mo(()=>[r.value&&!e.disabled?(ge(),xe("div",{key:0,ref_key:"contentRef",ref:i,class:rn(u.value),style:vn(f.value),onMouseenter:F,onMouseleave:H},[q[0]||(q[0]=Fe("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),kd(B.$slots,"default",{},void 0,!0)],38)):gt("",!0)]),_:3})]))],64))}}),nm=fn(aB,[["__scopeId","data-v-2a872eae"]]),yu=(e,t=null)=>{if(typeof t?.focus=="function"){t.focus();return}const n=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof n=="function"){n.call(e?.superdoc??e?.activeEditor,{preventScroll:!0});return}const r=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');r instanceof HTMLElement&&r.focus({preventScroll:!0})};Rt(),pn();var lB=["onKeydown","tabindex","data-item-id"],cB={key:0},uB={key:0},dB={key:0},fB={key:0},hB={key:0},pB={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=dr(),o=te([]),i=te(null),s=e,a=te(null),{isHighContrastMode:l}=qi(),c=window.matchMedia("(max-width: 768px)").matches,u=ke(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:c?0:1,justifyContent:"center"}),f=Te=>Te.type==="button",h=Te=>Te.type==="dropdown",g=Te=>Te.type==="dropdown"&&Te.name?.value==="fontFamily",m=Te=>Te.type==="dropdown"&&Te.name?.value==="fontSize",v=Te=>Te.type==="separator",k=Te=>Te.type==="overflow",C=Te=>!!Te.nestedOptions?.value?.length,_=Te=>{if(!Te)return!1;const He=Te.expand;return typeof He=="object"&&He!==null&&"value"in He?!!He.value:!!He},y=(Te,He)=>{Te?.expand&&(Te.expand.value=He)},w=(Te,He=void 0)=>{if(Te.disabled.value)return;if(k(Te)){const ee=!_(Te);ee&&F(),y(Te,ee),a.value=ee?Te:null,n("item-clicked");return}if(h(Te))return;a.value&&h(a.value)&&_(a.value)&&F(),n("item-clicked");const Ye=He!==void 0?He:Te.argument?.value;n("command",Ye===void 0?{item:Te}:{item:Te,argument:Ye})},T=(Te,He)=>{Te.disabled.value||(a.value=null,n("command",{item:Te,argument:He}))},L=Te=>{if(Te.disabled.value)return;F();const He=Te.splitButtonCommand,Ye=Te.command,ee=He||Ye;if(!ee)return;const S={...Te,command:ee};n("item-clicked"),n("command",{item:S})},F=()=>{const Te=r?.$toolbar?.toolbarItems||[],He=r?.$toolbar?.overflowItems||[],Ye=[...Te,...He];(Ye.length?Ye:s.toolbarItems).forEach(ee=>{const S=k(ee)&&!s.fromOverflow;(h(ee)||S)&&y(ee,!1)}),a.value=null},H=(Te,He)=>{F();const Ye=Te.dropdownValueKey.value?He[Te.dropdownValueKey.value]:He.label;n("command",{item:Te,argument:Ye,option:He}),Te.selectedValue.value=He.key,Te.restoreEditorFocus&&yu(r?.$toolbar)},M=Te=>{n("command",Te)},B=()=>{F(),n("item-clicked")},q=()=>{const Te=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Te instanceof HTMLElement?(Te.focus({preventScroll:!0}),!0):!1},P=()=>{const Te=r?.$toolbar?.pendingSelectionCapture,He=()=>{Te&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Te)};if(q()){He();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),He())},N=Te=>!(Te instanceof HTMLElement)||Te.classList.contains("sd-disabled")?null:Te.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||Te.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),E=(Te,He)=>{const Ye=Te?.target?.closest?.(".sd-toolbar-item-ctn");if(!(Ye instanceof HTMLElement))return!1;let ee=He>0?Ye.nextElementSibling:Ye.previousElementSibling;for(;ee;){const S=N(ee);if(S instanceof HTMLElement)return Ye.setAttribute("tabindex","-1"),ee.setAttribute("tabindex","0"),S.focus(),!0;ee=He>0?ee.nextElementSibling:ee.previousElementSibling}return!1},j=Te=>{F();const He=Te?.shiftKey?-1:1;E(Te,He)||P()},Q=Te=>{if(F(),Te?.shiftKey){E(Te,-1)||P();return}P()},Y=()=>{P()},se=Te=>Te.nestedOptions?.value?.length?Te.nestedOptions.value.map(He=>{const Ye=He?.type!=="render"&&Te.selectedValue.value===He.key;return{...He,props:{...He.props,class:Ye?"sd-selected":""}}}):[],he=(Te,He)=>({role:"menuitem",ariaLabel:`${He.attributes.value.ariaLabel} - ${Te.label}`}),Ve=Te=>{const He=Te.target,Ye=Te.target.closest(".sd-toolbar-item-ctn").nextElementSibling;Ye&&(He.setAttribute("tabindex","-1"),Ye.setAttribute("tabindex","0"),Ye.focus())},pe=Te=>{const He=Te.target,Ye=Te.target.closest(".sd-toolbar-item-ctn").previousElementSibling;Ye&&(He.setAttribute("tabindex","-1"),Ye.setAttribute("tabindex","0"),Ye.focus())},ye=Te=>{const He=Te.target.closest(".button-group").nextElementSibling;if(He)He.setAttribute("tabindex","0"),He.focus();else{const Ye=document.querySelector(".ProseMirror");Ye&&Ye.focus()}},me=Te=>{const He=Te.target.closest(".button-group").previousElementSibling;He&&(He.setAttribute("tabindex","0"),He.focus())},_e=Te=>{if(!Te.disabled.value){if(h(Te)){je(!_(Te),Te);return}w(Te)}},oe=(Te,He)=>{const Ye=Te.target.nodeName==="INPUT"||Te.target.nodeName==="TEXTAREA",ee=He.name.value==="fontSize"||He.name.value==="fontFamily";if(!(Ye&&ee)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(Te.key))switch(Te.preventDefault(),Te.key){case"Enter":case" ":case"Spacebar":_e(He);break;case"Escape":F();break;case"ArrowRight":F(),Ve(Te);break;case"ArrowLeft":F(),pe(Te);break;case"Tab":Te.shiftKey?me(Te):ye(Te)}},Re=Te=>{const He=o.value.find(Ye=>!Ye.classList.contains("sd-disabled"));He&&(He.setAttribute("tabindex","0"),He.focus())},je=(Te,He)=>{if(n("item-clicked"),!Te){F(),n("dropdown-update-show",!1);return}F(),a.value=He,y(He,!0),n("dropdown-update-show",!0)},et=Te=>{if(!a.value)return;const He=Te.target;He instanceof Element&&(He.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(He)||F())};return Nt(()=>_(a.value),Te=>{Te?document.addEventListener("pointerdown",et,!0):document.removeEventListener("pointerdown",et,!0)},{immediate:!0}),ir(()=>{document.removeEventListener("pointerdown",et,!0)}),(Te,He)=>(ge(),xe("div",{style:vn(u.value),class:"button-group",role:"group",onFocus:Re,ref_key:"buttonGroupRef",ref:i},[(ge(!0),xe(Gt,null,ur(e.toolbarItems,(Ye,ee)=>(ge(),xe("div",{key:Ye.id.value,class:rn([{narrow:Ye.isNarrow.value,wide:Ye.isWide.value,"sd-disabled":Ye.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:S=>oe(S,Ye),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:ee===0?0:-1,"data-item-id":Ye.id.value},[v(Ye)?(ge(),sn(xN,{key:0,style:{width:"20px"}})):gt("",!0),g(Ye)&&C(Ye)?(ge(),sn(nm,{key:1,trigger:"hover",disabled:!Ye.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Mo(()=>[Kt(oB,{item:Ye,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:M,onItemClicked:B,onTabOut:He[0]||(He[0]=S=>j(S)),onEditorHandoff:Y},null,8,["item","ui-font-family"])]),default:Mo(()=>[Fe("div",null,[$i(jt(Ye.tooltip)+" ",1),Ye.disabled.value?(ge(),xe("span",cB,"(disabled)")):gt("",!0)])]),_:2},1032,["disabled","content-style"])):m(Ye)&&C(Ye)?(ge(),sn(nm,{key:2,trigger:"hover",disabled:!Ye.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Mo(()=>[Kt(iB,{item:Ye,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:M,onItemClicked:B,onTabOut:He[1]||(He[1]=S=>Q(S)),onEditorHandoff:Y},null,8,["item","ui-font-family"])]),default:Mo(()=>[Fe("div",null,[$i(jt(Ye.tooltip)+" ",1),Ye.disabled.value?(ge(),xe("span",uB,"(disabled)")):gt("",!0)])]),_:2},1032,["disabled","content-style"])):h(Ye)&&Ye.nestedOptions?.value?.length?(ge(),sn(BN,{key:3,options:se(Ye),disabled:Ye.disabled.value,show:_(Ye),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(S,ne)=>H(Ye,ne),"onUpdate:show":S=>je(S,Ye),style:vn(Ye.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Xe(l)}]}),"node-props":S=>he(S,Ye)},{trigger:Mo(()=>[Kt(nm,{trigger:"hover",disabled:!Ye.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Mo(()=>[Kt(q0,{"toolbar-item":Ye,disabled:Ye.disabled.value,"allow-enter-propagation":!0,onTextSubmit:S=>T(Ye,S),onMainClick:S=>L(Ye)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:Mo(()=>[Fe("div",null,[$i(jt(Ye.tooltip)+" ",1),Ye.disabled.value?(ge(),xe("span",dB,"(disabled)")):gt("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):f(Ye)?(ge(),sn(nm,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:Mo(()=>[Kt(q0,{"toolbar-item":Ye,"is-overflow-item":e.fromOverflow,onTextSubmit:S=>T(Ye,S),onButtonClick:S=>w(Ye)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Mo(()=>[Ye.tooltip?(ge(),xe("div",fB,[$i(jt(Ye.tooltip)+" ",1),Ye.disabled.value?(ge(),xe("span",hB,"(disabled)")):gt("",!0)])):gt("",!0)]),_:2},1032,["content-style"])):gt("",!0),k(Ye)&&e.overflowItems.length?(ge(),sn(MN,{key:5,"toolbar-item":Ye,onButtonClick:S=>w(Ye),"overflow-items":e.overflowItems,onClose:F},null,8,["toolbar-item","onButtonClick","overflow-items"])):gt("",!0)],42,lB))),128))],36))}},rm=fn(pB,[["__scopeId","data-v-2bc00f65"]]),mB=[["Arial","sans-serif"],["Arial Black","sans-serif"],["Arial Narrow","sans-serif"],["Baskerville Old Face","serif"],["Bookman Old Style","serif"],["Brush Script MT","cursive"],["Calibri","sans-serif"],["Century","serif"],["Century Gothic","sans-serif"],["Comic Sans MS","sans-serif"],["Cooper Black","serif"],["Courier New","monospace"],["Garamond","serif"],["Georgia","serif"],["Gill Sans MT Condensed","sans-serif"],["Helvetica","sans-serif"],["Lucida Console","monospace"],["Segoe UI","sans-serif"],["Tahoma","sans-serif"],["Times New Roman","serif"],["Trebuchet MS","sans-serif"],["Verdana","sans-serif"]],gB=mB.map(([e,t])=>({label:e,key:e,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function vB(e){if(e?.length)return e.map(t=>({label:t.label,key:t.value,props:{style:{fontFamily:t.previewFamily||t.label},"data-item":"btn-fontFamily-option"}}))}var yB=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],Tf={sm:768,md:1024,lg:1280,xl:1410},Y0={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",measurementUnit:"measurement-unit",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",tableOfContents:"table-of-contents-insert",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},Z4={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},Q4=Object.values(Z4),xH=[...new Set([...Object.values(Y0),...Q4])],bB=new Set(["link"]),EH=new Set(Object.keys(Y0).filter(e=>!bB.has(e)));Rt(),pn();var wB="Arial, Helvetica, sans-serif",CB={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=dr();let r=te(1);const o=te(0),i=te(!1);let s=null,a=null;const l=ke(()=>{const H=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof H=="string"&&H.trim()?H.trim():wB}),c=n.$toolbar.config?.toolbarGroups?.includes("left"),u=n.$toolbar.config?.toolbarGroups?.includes("right"),f=n.$toolbar.config?.toolbarButtonsExclude||[],h=H=>(o.value,n.$toolbar.getToolbarItemByGroup(H).filter(M=>!f.includes(M.name.value))),g=()=>{i.value=n.$toolbar.getAvailableWidth()<=Tf.lg},v=cN(async()=>{await n.$toolbar.onToolbarResize(),g(),r.value+=1},300),k=()=>{r.value+=1},C=()=>{o.value+=1};function _(){window.removeEventListener("resize",v),n.$toolbar.off?.("toolbar-items-changed",k),n.$toolbar.off?.("toolbar-state-change",C),s?.disconnect(),s=null}function y(){_(),window.addEventListener("resize",v),n.$toolbar.on?.("toolbar-items-changed",k),n.$toolbar.on?.("toolbar-state-change",C),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(s=new ResizeObserver(()=>{v()}),s.observe(n.$toolbar.toolbarContainer)),g()}Pn(y),Ig(y),xg(_),ir(_);const w=()=>{if(!n.$toolbar.activeEditor){a=null,n.$toolbar.pendingSelectionCapture=null;return}a=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=a},T=({item:H,argument:M,option:B})=>{L(),n.$toolbar.emitCommand({item:H,argument:M,option:B})},L=()=>{const H=n.$toolbar.activeEditor;if(!H)return;const M=n.$toolbar.pendingSelectionCapture??a;if(M&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(M);return}H.commands?.restoreSelection?.()},F=H=>{w(),!H.target.closest('input, textarea, [contenteditable="true"]')&&H.preventDefault()};return(H,M)=>(ge(),xe("div",{class:"superdoc-toolbar",key:Xe(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:F},[Xe(c)?(ge(),sn(rm,{key:0,tabindex:"0","toolbar-items":h("left"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"left",onCommand:T,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):gt("",!0),Kt(rm,{tabindex:"0","toolbar-items":h("center"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"center",onCommand:T},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Xe(u)?(ge(),sn(rm,{key:1,tabindex:"0","toolbar-items":h("right"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"right",onCommand:T,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):gt("",!0)],32))}},kB=fn(CB,[["__scopeId","data-v-55b5af7a"]]),SB=e=>{if(!e)return e;const t=e.props?.style?.fontFamily??e.label??e.key;return{...e,props:{...e.props,style:{...e.props?.style,fontFamily:t},"data-item":e.props?.["data-item"]??"btn-fontFamily-option"}}};Rt();var _n=e=>{if(!["button","options","separator","dropdown","overflow"].includes(e.type))throw new Error("Invalid toolbar item type - "+e.type);if(e.type==="button"&&!e.defaultLabel&&!e.icon)throw new Error(`Toolbar button item needs either "icon" or "defaultLabel" - ${e.name}. "label" is the live label and is not a substitute for "defaultLabel".`);if(!e.name)throw new Error("Invalid toolbar item name - "+e.name);const t=te(ps()),n=e.type,r=te(e.name),o=e.command,i=e.noArgumentCommand,s=te(e.icon),a=te(e.group||"center"),l=te(e.allowWithoutEditor),c=te(e.attributes||{}),u=e.disabled||!1,f=te(e.disabled),h=te(!1),g=te(!1),m=te(e.style),v=te(e.isNarrow),k=te(e.isWide),C=te(e.minWidth),_=te(e.suppressActiveHighlight||!1),y=te(e.argument),w=te(null),T=te(null),L=te(e.iconColor),F=te(e.hasCaret),H=te(!!e.splitButton),M=e.splitButtonCommand,B=!!e.restoreEditorFocus,q=te(e.dropdownStyles),P=te(e.tooltip),N=te(e.tooltipVisible),E=te(e.tooltipTimeout),j=te(e.defaultLabel),Q=te(e.label),Y=te(e.hideLabel),se=te(e.inlineTextInputVisible),he=te(e.hasInlineTextInput),Ve=te(e.markName),pe=te(e.labelAttr),ye=te(e.selectedValue),me=te(e.dropdownValueKey),_e=te(e.inputRef||null),oe=te([]);if(e.options){if(!Array.isArray(e.options))throw new Error("Invalid toolbar item options - "+e.options);let S=0;for(let ne=0;ne<e.options.length;ne+=1){const O=e.options[ne];(!O||typeof O!="object")&&(S+=1)}if(S)throw new Error(`Toolbar item options must all be objects - ${e.name}. ${S} row(s) are not, so this item is skipped.`);oe.value?.push(...e.options)}const Re=(S={},...ne)=>{Te(S,...ne),!_.value&&(h.value=!0)},je=()=>{He(),h.value=!1},et=S=>{f.value=S},St=()=>{f.value=u},Te=e.onActivate||(()=>null),He=e.onDeactivate||(()=>null),Ye=()=>{const S={};return Object.keys(ee).forEach(ne=>{ee[ne].value!==void 0&&(S[ne]=ee[ne].value)}),S},ee={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:P,group:a,attributes:c,disabled:f,active:h,expand:g,nestedOptions:oe,style:m,isNarrow:v,isWide:k,minWidth:C,argument:y,parentItem:T,iconColor:L,hasCaret:F,splitButton:H,splitButtonCommand:M,dropdownStyles:q,tooltipVisible:N,tooltipTimeout:E,defaultLabel:j,label:Q,hideLabel:Y,inlineTextInputVisible:se,hasInlineTextInput:he,restoreEditorFocus:B,markName:Ve,labelAttr:pe,childItem:w,allowWithoutEditor:l,dropdownValueKey:me,selectedValue:ye,inputRef:_e};return{...ee,unref:Ye,activate:Re,deactivate:je,setDisabled:et,resetDisabled:St,onActivate:Te,onDeactivate:He}};Rt(),pn();var _B=["onClick","innerHTML","aria-label","onKeydown"],AB={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=qi(),r=t,o=te([]),i=[{key:"left",ariaLabel:"Align left",icon:sr.alignLeft},{key:"center",ariaLabel:"Align center",icon:sr.alignCenter},{key:"right",ariaLabel:"Align right",icon:sr.alignRight},{key:"justify",ariaLabel:"Justify",icon:sr.alignJustify}],s=u=>{r("select",u)},a=u=>{if(u===o.value.length-1)return;const f=o.value[u+1];f&&(f.setAttribute("tabindex","0"),f.focus())},l=u=>{if(u===0)return;const f=o.value[u-1];f&&(f.setAttribute("tabindex","0"),f.focus())},c=(u,f)=>{switch(u.key){case"ArrowLeft":l(f);break;case"ArrowRight":a(f);break;case"Enter":s(i[f].key)}};return Pn(()=>{const u=o.value[0];u&&(u.setAttribute("tabindex","0"),u.focus())}),(u,f)=>(ge(),xe("div",{class:rn(["alignment-buttons",{"high-contrast":Xe(n)}])},[(ge(),xe(Gt,null,ur(i,(h,g)=>Fe("div",{key:h.key,class:"sd-button-icon",onClick:m=>s(h.key),innerHTML:h.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":h.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:o,onKeydown:en(m=>c(m,g),["prevent"])},null,40,_B)),64))],2))}},IB=fn(AB,[["__scopeId","data-v-13e5f7a4"]]);Rt(),pn();var xB=["onClick","innerHTML","aria-label","onKeydown"],EB={__name:"StyleButtonsList",props:{buttons:{type:Array,required:!0},selectedStyle:{type:String,default:null},iconSize:{type:Number,default:25}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=qi(),r=t,o=e,i=te([]),s=ke(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=f=>{r("select",f)},l=f=>{if(f===i.value.length-1)return;const h=i.value[f+1];h&&(h.setAttribute("tabindex","0"),h.focus())},c=f=>{if(f===0)return;const h=i.value[f-1];h&&(h.setAttribute("tabindex","0"),h.focus())},u=(f,h)=>{switch(f.key){case"ArrowLeft":c(h);break;case"ArrowRight":l(h);break;case"Enter":a(o.buttons[h].key)}};return Pn(()=>{const f=i.value[0];f&&(f.setAttribute("tabindex","0"),f.focus())}),(f,h)=>(ge(),xe("div",{class:rn(["style-buttons-list",{"high-contrast":Xe(n)}])},[(ge(!0),xe(Gt,null,ur(o.buttons,(g,m)=>(ge(),xe("div",{key:g.key,class:rn(["sd-button-icon",{"sd-selected":o.selectedStyle===g.key}]),style:vn(s.value),onClick:v=>a(g.key),innerHTML:g.icon,role:"menuitem","aria-label":g.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:en(v=>u(v,m),["prevent"])},null,46,xB))),128))],2))}},J4=fn(EB,[["__scopeId","data-v-44f37ff6"]]),TB=[{key:"disc",icon:sr.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:sr.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:sr.bulletListSquare,ariaLabel:"Opaque square"}],RB=[{key:"decimal",icon:sr.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:sr.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:sr.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:sr.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:sr.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:sr.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:sr.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:sr.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];Rt(),pn();var LB=["onClick","onKeydown"],MB={class:"document-mode-column icon-column"},PB=["innerHTML"],DB={class:"document-mode-column text-column"},OB={class:"document-mode-type"},FB={class:"document-mode-description"},NB={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=te([]),{isHighContrastMode:o}=qi(),i=e,s=u=>{n("select",u)},a=u=>{if(u===r.value.length-1)return;const f=r.value[u+1];f&&(f.setAttribute("tabindex","0"),f.focus())},l=u=>{if(u===0)return;const f=r.value[u-1];f&&(f.setAttribute("tabindex","0"),f.focus())},c=(u,f)=>{switch(u.key){case"ArrowDown":a(f);break;case"ArrowUp":l(f);break;case"Enter":s(i.options[f])}};return Pn(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(u,f)=>(ge(),xe("div",{class:rn(["document-mode",{"high-contrast":Xe(o)}])},[(ge(!0),xe(Gt,null,ur(e.options,(h,g)=>(ge(),xe("div",{class:rn(["sd-option-item",{"sd-disabled":h.disabled}]),onClick:m=>s(h),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:en(m=>c(m,g),["prevent"])},[Fe("div",MB,[Fe("div",{class:"icon-column__icon",innerHTML:h.icon},null,8,PB)]),Fe("div",DB,[Fe("div",OB,jt(h.label),1),Fe("div",FB,jt(h.description),1)])],42,LB))),256))],2))}},BB=fn(NB,[["__scopeId","data-v-bee14d7a"]]);Rt(),pn();var zB={class:"linked-style-buttons","data-editor-ui-surface":""},VB=["onClick","onKeydown","aria-label"],jB={__name:"LinkedStyle",props:{styles:{type:Array,default:()=>[]},selectedOption:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const n=t,r=te([]),o=e,i=f=>{n("select",f)},s=f=>{if(f===r.value.length-1)return;const h=r.value[f+1];h.setAttribute("tabindex","0"),h.focus()},a=f=>{if(f===0)return;const h=r.value[f-1];h.setAttribute("tabindex","0"),h.focus()},l=(f,h,g)=>{switch(f.key){case"ArrowDown":s(h);break;case"ArrowUp":a(h);break;case"Enter":f.preventDefault(),i(g)}},c=f=>f?.name??f?.id??"",u=f=>{const h=f?.preview?.css;return h&&typeof h=="object"?h:void 0};return Pn(()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())}),(f,h)=>(ge(),xe("div",zB,[(ge(!0),xe(Gt,null,ur(o.styles,(g,m)=>(ge(),xe("div",{key:g.id??m,class:rn(["style-item",{selected:e.selectedOption===g.id}]),onClick:v=>i(g),onKeydown:v=>l(v,m,g),"aria-label":`Linked style - ${g.id??c(g)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[Fe("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:vn(u(g))},jt(c(g)),5)],42,VB))),128))]))}},UB=fn(jB,[["__scopeId","data-v-43b5dcca"]]);Rt(),pn();var HB=["placeholder"],$B={class:"sd-ai-writer__footer"},GB={key:0,class:"sd-ai-writer__error",role:"alert"},WB=["disabled"],KB="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",qB="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",YB={__name:"AIWriter",props:{selectedText:{type:String,default:""},target:{type:Object,default:null},doc:{type:Object,default:null},apiKey:{type:String,default:""},endpoint:{type:String,default:""},restoreSelection:{type:Function,default:null},handleClose:{type:Function,required:!0}},setup(e){const t=e,n=te(""),r=te(!1),o=te(""),i=te(null),s=ke(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=ke(()=>n.value.trim().length>0&&!r.value);Pn(()=>{xt(()=>{i.value?.focus()})});function l(m){if(typeof m=="string")return m;if(!m||typeof m!="object")return"";const v=m.custom_prompt;if(Array.isArray(v)){const k=v[0];if(k&&typeof k.value=="string")return k.value}return v&&typeof v=="object"&&typeof v.value=="string"?v.value:typeof m.value=="string"?m.value:typeof m.text=="string"?m.text:""}async function c(m){const v={"Content-Type":"application/json"};t.apiKey&&(v["x-api-key"]=t.apiKey);const k=t.selectedText.trim(),C=k?`Rewrite the following text: "${k}" using these instructions: ${m}`:`Generate text based on the following prompt: ${m}`,_=await fetch(t.endpoint||KB,{method:"POST",headers:v,body:JSON.stringify({stream:!1,context:qB,insights:[{type:"custom_prompt",name:k?"text_rewrite":"text_generation",message:C,format:[{value:""}]}]})});if(!_.ok){const w=await _.text().catch(()=>"");throw new Error(w||`AI request failed with ${_.status}`)}const y=l((_.headers.get("content-type")||"").includes("application/json")?await _.json():await _.text()).trim();if(!y)throw new Error("AI returned no text.");return y}function u(m){return!m||typeof m!="object"?!0:!(m.success===!1||m.ok===!1)}function f(m){const v=t.doc;if(!v)throw new Error("Document API is unavailable.");t.restoreSelection?.();let k=null,C=!1;if(t.selectedText&&t.target&&typeof v.replace=="function"?(k=v.replace({target:t.target,text:m}),C=!0):t.target&&typeof v.insert=="function"?(k=v.insert({target:t.target,value:m,type:"text"}),C=!0):typeof v.insert=="function"&&(k=v.insert({value:m,type:"text"}),C=!0),!C)throw new Error("Document text insertion is unavailable.");if(!u(k))throw new Error("Unable to insert generated text.")}async function h(){if(a.value){o.value="",r.value=!0;try{f(await c(n.value.trim())),t.handleClose()}catch(m){o.value=m instanceof Error?m.message:String(m)}finally{r.value=!1}}}function g(m){m.key!=="Enter"||m.shiftKey||(m.preventDefault(),h())}return(m,v)=>(ge(),xe("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:en(h,["prevent"])},[sa(Fe("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":v[0]||(v[0]=k=>n.value=k),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:g},null,40,HB),[[Li,n.value]]),Fe("div",$B,[o.value?(ge(),xe("p",GB,jt(o.value),1)):gt("",!0),Fe("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},jt(r.value?"Generating":"Generate"),9,WB)])],32))}},XB=fn(YB,[["__scopeId","data-v-67f6c6f7"]]);Rt(),pn();var ZB=["aria-label","onClick","onKeydown"],QB=["innerHTML"],JB=["innerHTML"],om=7,ez={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,o=ke(()=>m=>r.activeColor.value?r.activeColor.value.toUpperCase()===m.value:!1),i=(m,v)=>v===5||["#FFFFFF","#FAFF09"].includes(m)?{color:"#000"}:{color:"#FFF"},s=m=>{n("select",m.value)},a=te([]),l=te([]);Pn(()=>{if(!r.icons.every(v=>Array.isArray(v)))throw new Error("icon props must be 2d array");const m=l.value[0];m&&(m.setAttribute("tabindex","0"),m.focus({preventScroll:!0}))});const c=(m,v)=>{const k=om*m+v+1,C=l.value[k];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},u=(m,v)=>{const k=om*m+v-1,C=l.value[k];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},f=(m,v)=>{const k=v+om*(m+1),C=l.value[k];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},h=(m,v)=>{const k=v+om*(m-1),C=l.value[k];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},g=(m,v,k,C)=>{switch(m.key){case"ArrowRight":c(v,k);break;case"ArrowLeft":u(v,k);break;case"ArrowDown":f(v,k);break;case"ArrowUp":h(v,k);break;case"Enter":s(C);break;case"Escape":n("clickoutside")}};return(m,v)=>(ge(!0),xe(Gt,null,ur(e.icons,(k,C)=>(ge(),xe("div",{class:"sd-option-row",key:C,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(ge(!0),xe(Gt,null,ur(k,(_,y)=>(ge(),xe("div",{class:"sd-option",key:y,"aria-label":_.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:en(w=>s(_),["stop","prevent"]),onKeydown:en(w=>g(w,C,y,_),["prevent"])},[Fe("div",{class:"sd-option__icon",innerHTML:_.icon,style:vn(_.style)},null,12,QB),o.value(_)?(ge(),xe("div",{key:0,class:"sd-option__check",innerHTML:Xe(sr).colorOptionCheck,style:vn(i(_.value,y))},null,12,JB)):gt("",!0)],40,ZB))),128))]))),128))}},eA=fn(ez,[["__scopeId","data-v-05eb02fc"]]),tz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
101
101
  `;Rt(),pn();var nz={class:"options-grid-wrap"},rz=["innerHTML"],oz={class:"option-grid-ctn"},iz={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=o=>{n("select",o)};return(o,i)=>(ge(),xe("div",nz,[e.hasNoneIcon?(ge(),xe("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[Fe("span",{innerHTML:Xe(tz),class:"none-icon"},null,8,rz),i[1]||(i[1]=$i(" None ",-1))])):gt("",!0),Fe("div",oz,[Kt(eA,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(ge(),xe(Gt,{key:0},[i[2]||(i[2]=Fe("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),Kt(eA,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):gt("",!0)])]))}},sz=fn(iz,[["__scopeId","data-v-52b0283a"]]);Rt();var az=e=>{e.expand.value=!1},Ut=(e,t=null)=>({label:t,icon:sr.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),X0=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),az(t),yu(e)};return Vr("div",{},[Vr(sz,{icons:lz,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},lz=[[Ut("#111111","black"),Ut("#333333","dark gray"),Ut("#5C5C5C","medium gray"),Ut("#858585","light gray"),Ut("#ADADAD","very light gray"),Ut("#D6D6D6","transparent gray"),Ut("#FFFFFF","white")],[Ut("#860028","dark red"),Ut("#D2003F","red"),Ut("#DB3365","coral red"),Ut("#E4668C","light red"),Ut("#ED99B2","pale pink"),Ut("#F6CCD9","transparent pink"),Ut("#FF004D","bright pink")],[Ut("#83015E","dark purple"),Ut("#CD0194","purple"),Ut("#D734A9","orchid"),Ut("#E167BF","light purple"),Ut("#EB99D4","lavender"),Ut("#F5CCEA","transparent pink"),Ut("#FF00A8","neon pink")],[Ut("#8E220A","maroon"),Ut("#DD340F","red-orange"),Ut("#E45C3F","burnt orange"),Ut("#EB856F","peach"),Ut("#F1AE9F","pale peach"),Ut("#F8D6CF","transparent peach"),Ut("#FF7A00","orange")],[Ut("#947D02","olive"),Ut("#E7C302","mustard yellow"),Ut("#ECCF35","yellow"),Ut("#F1DB67","light yellow"),Ut("#F5E79A","very pale yellow"),Ut("#FAF3CC","transparent yellow"),Ut("#FAFF09","neon yellow")],[Ut("#055432","forest green"),Ut("#07834F","green"),Ut("#399C72","medium green"),Ut("#6AB595","light green"),Ut("#9CCDB9","mint"),Ut("#CDE6DC","transparent mint"),Ut("#05F38F","bright teal")],[Ut("#063E7E","navy blue"),Ut("#0A60C5","blue"),Ut("#3B80D1","sky blue"),Ut("#6CA0DC","cornflower blue"),Ut("#9DBFE8","light blue"),Ut("#CEDFF3","very light blue"),Ut("#21c8ce","cyan")],[Ut("#3E027A","deep purple"),Ut("#6103BF","indigo"),Ut("#8136CC","violet"),Ut("#A068D9","lavender pink"),Ut("#C09AE6","light lilac"),Ut("#DFCDF2","transparent lilac"),Ut("#A91DFF","neon purple")]];Rt(),pn();var cz=["data-cols","data-rows","onKeydown","onClick"],uz=["aria-valuetext"],im=5,dz={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=te(0),o=te(0),{isHighContrastMode:i}=qi(),s=te([]),a=f=>{let h=f.target;if(h.dataset.grid)return;let g=[...h.parentElement.querySelectorAll("[data-item]")],m=parseInt(h.dataset.cols,10),v=parseInt(h.dataset.rows,10);l(g,m,v)},l=(f,h,g)=>{o.value=h,r.value=g;for(let m=0;m<f.length;m++){let v=f[m],k=parseInt(v.dataset.cols,10),C=parseInt(v.dataset.rows,10);k<=h&&C<=g?v.classList.add("sd-selected"):v.classList.remove("sd-selected")}},c=({cols:f,rows:h})=>{n("select",{cols:f,rows:h})},u=(f,h,g)=>{let m=h-1,v=g-1;switch(f.key){case"ArrowRight":{if(m>=4)return;const k=v*im;s.value[k+m+1].setAttribute("tabindex","0"),s.value[k+m+1].focus(),l(s.value,h+1,g);break}case"ArrowLeft":{if(m<=0)return;const k=v*im;s.value[k+m-1].setAttribute("tabindex","0"),s.value[k+m-1].focus(),l(s.value,h-1,g);break}case"ArrowDown":{if(v>=4)return;const k=(v+1)*im;s.value[k+m].setAttribute("tabindex","0"),s.value[k+m].focus(),l(s.value,h,g+1);break}case"ArrowUp":{if(v<=0)return;const k=(v-1)*im;s.value[k+m].setAttribute("tabindex","0"),s.value[k+m].focus(),l(s.value,h,g-1);break}case"Enter":c({cols:h,rows:g})}};return Pn(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(f,h)=>(ge(),xe("div",{class:rn(["toolbar-table-grid-wrapper",{"high-contrast":Xe(i)}])},[Fe("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(ge(),xe(Gt,null,ur(5,g=>(ge(),xe(Gt,{key:g},[(ge(),xe(Gt,null,ur(5,m=>Fe("div",{class:"toolbar-table-grid__item",key:`${g}_${m}`,"data-cols":m,"data-rows":g,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:en(v=>u(v,m,g),["prevent"]),onClick:en(v=>c({cols:m,rows:g}),["stop","prevent"])},null,40,cz)),64))],64))),64))],32),Fe("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},jt(r.value)+" x "+jt(o.value),9,uz)],2))}},fz=fn(dz,[["__scopeId","data-v-b87d6ca2"]]);Rt(),pn();var hz={class:"toolbar-table-actions"},pz=["onClick","data-item","ariaLabel"],mz={class:"toolbar-table-actions__icon"},gz=["innerHTML"],vz={class:"toolbar-table-actions__label"},yz={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=o=>{n("select",{command:o.command})};return(o,i)=>(ge(),xe("div",hz,[(ge(!0),xe(Gt,null,ur(e.options,s=>(ge(),xe("div",{class:rn(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[Fe("div",mz,[Fe("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,gz)]),Fe("div",vz,jt(s.label),1)],10,pz))),256))]))}},bz=fn(yz,[["__scopeId","data-v-0cdad084"]]),wz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
102
- `;Rt();var Ds=e=>{e.expand.value=!1};function Z0(e,t){const n={...e??{}};return t?n.href=t:delete n.href,n}function tA(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Cz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function nA(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function kz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Sz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}var _z=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=_n({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??gB).map(SB),u=_n({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:c,onActivate:({fontFamily:Qe}={},It=!1)=>{if(It){u.label.value="",u.selectedValue.value="";return}if(!Qe)return;Qe=Qe.split(",")[0],u.label.value=Qe;const Ht=c.find(nn=>nn.label===u.defaultLabel.value),wn=c.find(nn=>nn.label===Qe);wn?u.selectedValue.value=wn.key:Ht?u.selectedValue.value=Ht.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const Qe=c.find(It=>It.label===u.defaultLabel.value);Qe?u.selectedValue.value=Qe.key:u.selectedValue.value=""}}),f=_n({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(f)}]});function h(Qe){const It=nA(e),Ht=It?.selectionTarget??tA(It?.target),wn=It?.empty?"":Cz(It),nn=Sz(e),un=()=>Ds(Qe),Wn=()=>{const Xn=e.pendingSelectionCapture;Xn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Xn)};return Vr("div",{},[Vr(XB,{handleClose:un,selectedText:wn,target:Ht,doc:e.superdoc?.activeEditor?.doc??null,apiKey:nn?.apiKey||e.config?.aiApiKey||"",endpoint:nn?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Wn})])}const g=yB,m=_n({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:g,onActivate:({fontSize:Qe},It=!1)=>{if(It){m.label.value="",m.selectedValue.value="";return}const Ht=g.find(Wn=>Wn.label===String(m.defaultLabel.value));if(!Qe){m.label.value=m.defaultLabel.value,Ht?m.selectedValue.value=Ht.key:m.selectedValue.value="";return}let wn=lN(Qe,12);wn<8&&(wn=8),wn>96&&(wn=96);let nn=String(wn);const un=g.find(Wn=>Wn.label===nn||Wn.key===nn);un?m.selectedValue.value=un.key:m.selectedValue.value="",m.label.value=nn},onDeactivate:()=>{m.label.value=m.defaultLabel.value;const Qe=g.find(It=>It.label===String(m.defaultLabel.value));Qe?m.selectedValue.value=Qe.key:m.selectedValue.value=""}}),v=_n({type:"separator",name:"separator",isNarrow:!0}),k=_n({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=_n({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),_=_n({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=_n({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>X0(e,y,[],!0)}],onActivate:({color:Qe})=>{y.iconColor.value=Qe||""},onDeactivate:()=>y.iconColor.value=""}),w=_n({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>X0(e,w)}],onActivate:({color:Qe})=>{w.iconColor.value=Qe},onDeactivate:()=>w.iconColor.value="#000"}),T=_n({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),L=_n({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>F(L)}],onActivate:({href:Qe})=>{L.attributes.value=Z0(L.attributes.value,Qe)},onDeactivate:()=>{L.attributes.value=Z0(L.attributes.value,null),L.expand.value=!1}});function F(Qe){const It=nA(e),Ht=It?.selectionTarget??tA(It?.target),wn=()=>{const nn=e.pendingSelectionCapture;nn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(nn)};return Vr("div",{},[Vr(IS,{ui:e.ui,linkItem:Qe,textTarget:Ht,restoreSelection:wn,closePopover:()=>{Ds(Qe),yu(e)},goToAnchor:()=>{Ds(Qe);const nn=Qe.attributes.value?.href;if(!nn)return;const un=nn.slice(1),Wn=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${un}']`);Wn&&lf(Wn)}})])}const H=_n({type:"options",name:"linkInput",command:"toggleLink",active:!1});L.childItem=H,H.parentItem=L;const M=_n({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),B=_n({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),q=_n({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>P(q)}]});function P(Qe){return Vr("div",{},[Vr(fz,{onSelect:Ht=>{e.emitCommand({item:Qe,argument:Ht}),Ds(Qe),yu(e)}})])}const N=_n({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>j(N)}]}),E=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function j(Qe){return Vr(bz,{options:E,onSelect:It=>{Ds(Qe);const{command:Ht}=It;e.emitCommand({item:Qe,argument:{command:Ht}})}})}const Q=_n({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Vr("div",{},[Vr(IB,{onSelect:It=>{Ds(Q);const Ht={...Q,command:"setTextAlign"};Ht.command="setTextAlign",e.emitCommand({item:Ht,argument:It}),Y(Q,It),yu(e)}})]),key:"alignment"}],onActivate:({textAlign:Qe})=>{Y(Q,Qe)},onDeactivate:()=>{Y(Q,"left")}}),Y=(Qe,It)=>{let Ht=It==="both"?"justify":It,wn={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},nn=wn[Ht]??wn.left;Qe.icon.value=nn},se=_n({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Qe=It=>{Ds(se);const Ht={...se,command:"toggleBulletListStyle"};e.emitCommand({item:Ht,argument:It})};return Vr(J4,{buttons:TB,iconSize:25,selectedStyle:se.selectedValue.value,onSelect:Qe})}}]}),he=_n({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Qe=It=>{Ds(he);const Ht={...he,command:"toggleOrderedListStyle"};e.emitCommand({item:Ht,argument:It})};return Vr(J4,{buttons:RB,iconSize:30,selectedStyle:he.selectedValue.value,onSelect:Qe})}}]}),Ve=_n({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),pe=_n({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ye=_n({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),me=_n({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Qe})=>{Qe&&(me.label.value=Qe)}}),_e=_n({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Qe})=>{Qe&&(_e.label.value=Qe)}}),oe=_n({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Re=_n({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),je=_n({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),et=_n({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),St=_n({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Te=_n({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),He=(Qe,It)=>Qe==="editor"?It:Qe==="suggester"?It.filter(Ht=>Ht.value==="suggesting"):It.filter(Ht=>Ht.value==="viewing"),Ye=Qe=>Qe==="editor"?"Editing":Qe==="suggester"?"Suggesting":"Viewing",ee=_n({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Ye(s),label:Ye(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ne(ee)}]}),S=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ne(Qe){const It=He(s,S);return Vr(BB,{options:It,onSelect:Ht=>{const wn=e.superdoc?.activeEditor??e.activeEditor;Ds(Qe);const{label:nn,icon:un,value:Wn}=Ht;ee.label.value=nn,ee.icon.value=un,e.emitCommand({item:ee,argument:Wn}),yu(e,wn)}})}const O=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),U=["search","ruler","undo","overflow","documentMode"],$=_n({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),z=_n({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),J=_n({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Qe=Ht=>{Ds(J);const wn=typeof Ht=="string"?Ht:Ht?.id??null;if(!wn)return;const nn={...J,command:"setLinkedStyle"};e.emitCommand({item:nn,argument:wn})},It=e.getActiveLinkedStyleId?.()??null;return Vr("div",{},[Vr(UB,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Qe,selectedOption:It})])}}],onActivate:({styleId:Qe,styleName:It})=>{const Ht=It||Qe;J.label.value=Qe&&Qe!=="Normal"?String(Ht):n.formatText,J.disabled.value=!1},onDeactivate:()=>{J.disabled.value=!0,J.label.value=n.formatText}}),Z=(Qe,It)=>{if(It.value==Qe)return Vr("div",{innerHTML:wz,class:"dropdown-select-icon"})},G=_n({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,restoreEditorFocus:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Qe=>({label:Qe.toFixed(2),key:Qe,icon:()=>Z(Qe,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),be=20,ve=32,Ce=U.reduce((Qe,It)=>Qe+(O.get(It)||O.get("default")),0),De=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Ze=["zoom","fontFamily","fontSize","redo"],ot=i<=Tf.lg,yt=e.config?.showFormattingMarksButton===!0,tn=e.config?.showTableOfContentsButton===!0;ot&&(ee.attributes.value={...ee.attributes.value,className:`${ee.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),ot&&(J.attributes.value={...J.attributes.value,className:`${J.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let Ue=[oe,Re,je,et,T,me,u,v,m,v,l,k,C,_,w,y,v,L,M,...tn?[B]:[],q,N,v,Q,se,he,Ve,pe,G,v,J,v,$,_e,...yt?[z]:[],Te,St,...kz(e)?[f]:[],ye,ee];if(i<=Tf.md&&o&&(Ue=Ue.filter(Qe=>Qe.type!=="separator")),e.config.mode!=="docx"){const Qe=Ue.findIndex(Ht=>Ht.name.value==="linkedStyles");Ue.splice(Qe-1,2);const It=["ruler","zoom","undo","redo"];Ue=Ue.filter(Ht=>!It.includes(Ht.name.value))}const Ot=[];a||(s==="viewer"&&Ot.push(je,et),Ue=Ue.filter(Qe=>!Ot.includes(Qe)));const Bt=Qe=>U.includes(Qe.name.value),an=[],nr=[];let qt=ve+Ce;return Ue.forEach(Qe=>{const It=O.get(Qe.name.value)||O.get("default");if(i<Tf.xl+be&&De.includes(Qe.name.value)&&o){if(an.push(Qe),Qe.name.value==="linkedStyles"){const Ht=Ue.findIndex(wn=>wn.name.value==="linkedStyles");Ue.splice(Ht+1,1)}return}if(i<Tf.sm&&Ze.includes(Qe.name.value)&&o){an.push(Qe);return}if(Bt(Qe)){nr.push(Qe),qt+=It;return}qt<i||!o?(nr.push(Qe),qt+=It):an.push(Qe)}),{defaultItems:nr,overflowItems:an.filter(Qe=>Qe.type!=="separator")}},rA={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},Az=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Rt();function oA(e){return eN(e)??Y0[e]??null}function sm(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Iz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),xz=new Set(["list","numberedlist"]);function Ez(e,t){if(e==="fontFamily"||e==="fontSize"||xz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Iz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function iA(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Tz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var Rz=class extends $m.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...sr},texts:{...rA},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#e=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...sr,...e.icons},this.config.texts={...rA,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._reportedInvalidCustomItems=new Set,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=Az(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#t(),this.#d(),this.#f(),this.#i(),this._lastFontOptionsSignature=this.#o(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Ul(kB),this.app.directive("click-outside",Kv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#t(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#a():this.#S()}))}#r(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#S();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#s(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#d(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#h(e){if(e)return e;const t=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return vB(t)}#f(){const e=this.getAvailableWidth(),t=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,{defaultItems:n,overflowItems:r}=_z({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#h(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),o=this.config.customButtons||[],i=new Set([...n,...r].map(c=>c.name?.value).filter(Boolean)),s=o.map((c,u)=>{try{if(c?.name&&i.has(c.name))throw new Error(`Toolbar item name "${c.name}" is already taken by another item, so this entry is skipped.`);const f=this.#c(c);return i.add(f.name?.value),f}catch(f){const h=`${c?.name??`<unnamed@${u}>`}::${f?.message??String(f)}`;return this._reportedInvalidCustomItems.has(h)||(this._reportedInvalidCustomItems.add(h),this.#b(f,c?.name??null)),null}}).filter(Boolean);s.length&&n.push(...s);let a=[...n.map(c=>c.name.value),...r.map(c=>c.name.value)];if(t){const c=Object.values(this.config.groups).flatMap(h=>h),u=new Set(Object.keys(this.config.groups)),f=s.filter(h=>u.has(h.group?.value||"center")).map(h=>h.name.value);a=[...new Set([...c,...f])]}const l=n.filter(c=>a.includes(c.name.value)).filter(c=>!this.config.excludeItems.includes(c.name.value));if(t)for(const[c,u]of Object.entries(this.config.groups))for(const f of l)u.includes(f.name.value)&&(f.group.value=c);this.toolbarItems=l,this.overflowItems=r.filter(c=>a.includes(c.name.value))}#c(e){const t=_n({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#f(),this.emit("toolbar-items-changed")}#o(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#l().find(t=>t.name.value===e)}#l(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#f(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#u(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#y(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#w(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>X0(this,e,[],!0)};e.nestedOptions.value=[t]}#k(e){return!!e?.active&&e?.value==null}#I(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=Q4.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(K0(t)?.disposition==="host-routed")return e.setDisabled(!this.#u(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=oA(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Ez(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#y()},link:()=>{e.active.value=!!r?.active,e.attributes.value=Z0(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#I(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#k(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#y(),this.#w();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#M(),this.#l().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#l().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#M(){this.#l().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#P(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#D(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#b(i,n)};if(n==="image"&&t==null)return this.#E();if(n==="tableActions"){const i=Z4[t?.command];return i?sm(this.ui,i,void 0,r):!1}if(K0(n)?.disposition==="unsupported")return!0;const o=oA(n);return o?sm(this.ui,o,t,r):!1}#E(){return this.snapshot?.commands?.image?.disabled||(this.#e||(this.#e=aN({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await iN(e,this.superdoc?.config?.handleImageUpload);sm(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#b(n,"image")})},onError:e=>this.#b(e,"image")})),this.#e.open()),!0}#a(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{iA(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!iA(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Tz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#S(){this.#n&&(this.#n(),this.#n=null)}#b(e,t){const n={error:e instanceof Error?e:new Error(String(e)),originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null},r={...n};this.emit("exception",n),this.superdoc?.emit?.("exception",r)}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(K0(r)?.disposition==="host-routed"){this.#P(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!sm(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#b(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#D(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#b(s,r)}}}destroy(){this.#S(),this.#e?.destroy(),this.#e=null,this.#s(),this.#r(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Lz(e){return new Rz(e)}function Mz(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Pz(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=am(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=Oz(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=Dz(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=Fz(e.border);return i&&(t.border=i),t}function am(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function Dz(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function Oz(e){if(!e)return;const t={},n=am(e.fill);n!=null&&(t.fill=n);const r=am(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function Fz(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=am(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function nc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}var Nz=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]),Bz=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:Nz.has(e.editableCommandKind);function sA(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function zz(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of sA(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function aA(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=e;for(;i;){const s=i,a=zz(s),l=a.length>0?s.getAttribute("data-story-key"):null;for(const m of a){const v=`trackedChange:${m}`;if(!r.has(v)){r.add(v);const k={type:"trackedChange",id:m};l&&(k.storyKey=l),n.push(k),o.push(k)}}const c=s.getAttribute("data-layout-story");if(c&&o.length>0){for(const m of o)m.story=c;o=[]}const u=s.getAttribute("data-citation-id");if(u){const m=`citation:${u}`;r.has(m)||(r.add(m),n.push({type:"citation",id:u}))}const f=s.getAttribute("data-comment-ids");if(f)for(const m of sA(f)){const v=`comment:${m}`;r.has(v)||(r.add(v),n.push({type:"comment",id:m}))}const h=s.getAttribute("data-sdt-type"),g=s.getAttribute("data-sdt-id");if(g&&h==="structuredContent"){const m=`contentControl:${g}`;if(!r.has(m)){r.add(m);const v=s.getAttribute("data-sdt-scope"),k=s.getAttribute("data-sdt-tag"),C={type:"contentControl",id:g};(v==="block"||v==="inline")&&(C.scope=v),k&&(C.tag=k),n.push(C)}}if(t&&i===t)break;i=i.parentElement}return n}var ao=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),dl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),bu=()=>({oneOf:[{type:"number"},{type:"null"}]}),wu=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),Vz={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},jz={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},Uz=()=>({oneOf:[{type:"boolean"},{type:"null"},Vz]}),Hz=()=>({oneOf:[{type:"array",items:jz,minItems:1},{type:"null"}]});function lm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function $z(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var Q0=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:lm(n),schema:ao()}),rc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:lm("textStyle",o??e),schema:r}),jn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:$z(o??e),schema:r}),cm=[Q0("bold","w:b","bold"),Q0("italic","w:i","italic"),Q0("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:lm("underline"),schema:Uz()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:lm("highlight"),schema:dl()},rc("color","string","w:color",dl()),rc("fontSize","number","w:sz",bu()),rc("fontFamily","string","w:rFonts",dl()),rc("letterSpacing","number","w:spacing",bu()),rc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),rc("position","number","w:position",bu()),jn("dstrike","boolean","w:dstrike",ao()),jn("smallCaps","boolean","w:smallCaps",ao()),rc("caps","boolean","w:caps",ao(),"textTransform"),jn("shading","object","w:shd",wu({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("border","object","w:bdr",wu({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),jn("outline","boolean","w:outline",ao()),jn("shadow","boolean","w:shadow",ao()),jn("emboss","boolean","w:emboss",ao()),jn("imprint","boolean","w:imprint",ao()),jn("charScale","number","w:w",bu(),"w"),jn("kerning","number","w:kern",bu(),"kern"),jn("vanish","boolean","w:vanish",ao()),jn("webHidden","boolean","w:webHidden",ao()),jn("specVanish","boolean","w:specVanish",ao()),jn("rtl","boolean","w:rtl",ao()),jn("cs","boolean","w:cs",ao()),jn("bCs","boolean","w:bCs",ao(),"boldCs"),jn("iCs","boolean","w:iCs",ao(),"italicCs"),jn("eastAsianLayout","object","w:eastAsianLayout",wu({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),jn("em","string","w:em",dl()),jn("fitText","object","w:fitText",wu({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("snapToGrid","boolean","w:snapToGrid",ao()),jn("lang","object","w:lang",wu({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("oMath","boolean","w:oMath",ao()),jn("rStyle","string","w:rStyle",dl(),"styleId"),jn("rFonts","object","w:rFonts",wu({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),jn("fontSizeCs","number","w:szCs",bu()),jn("ligatures","string","w14:ligatures",dl()),jn("numForm","string","w14:numForm",dl()),jn("numSpacing","string","w14:numSpacing",dl()),jn("stylisticSets","array","w14:stylisticSets",Hz()),jn("contextualAlternates","boolean","w14:cntxtAlts",ao())],TH=new Set(cm.map(e=>e.key)),Gz=Object.fromEntries(cm.map(e=>[e.key,e])),RH={mark:cm.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:cm.filter(e=>e.storage==="runAttribute").map(e=>e.key)},J0=new WeakMap;function Wz(e){let t=J0.get(e);return t||(t={refCount:0,generation:0,abortController:new AbortController,inFlight:null,activeMutationTokens:new Set},J0.set(e,t)),t.refCount+=1,t}function Kz(e,t){t.refCount=Math.max(0,t.refCount-1),!(t.refCount>0)&&(t.abortController.abort("ui-controller-destroyed"),t.inFlight=null,t.activeMutationTokens.clear(),J0.delete(e))}var qz=new Set(Object.values(ct));function e2(e,t){return typeof e=="string"&&qz.has(e)?e:t}function lA(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:ct.notReady}:{ok:!1,reason:e2(t,ct.targetUnresolved)}}return{ok:!0}}var Yz=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],Xz={[V4.bulletList]:"bullet",[V4.numberedList]:"ordered"};function cA(e){return Xz[e]??null}var Zz={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function Qz(e){const t=Zz[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var Jz={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""},eV=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: shared all-story tracked-changes catalog; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: current-token validation over the shared all-story catalog; consumers fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}],tV=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function nV(e){return eV.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var uA={ready:0,stale:1,pending:2};function fl(...e){let t="ready";for(const n of e)uA[n]>uA[t]&&(t=n);return t}function Pt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function xr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function vr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function Yn(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Rf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Lf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function t2(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function dA(e,t){if(!e||typeof e!="object")return null;const n=Lf(e),r=e,o=r.navigationTarget&&typeof r.navigationTarget=="object"?r.navigationTarget:null;if(o?.kind==="block"&&typeof o.blockId=="string"&&o.blockId.length>0){const i={kind:"text",blockId:o.blockId,range:{start:0,end:0},...o.story&&typeof o.story=="object"?{story:o.story}:{},...r.address&&typeof r.address=="object"?{address:r.address}:{}};if(t?.preferStableBlock||!t2(n))return i}return n}function Cr(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function Mf(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Lf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ji(e,t,n){return lo(e)!==t?!1:n?Cr(Mf(e))===Cr(n):!0}function um(e){const t=Mf(e);if(!(!t||Cr(t)===Cr(null)))return t}function rV(e){if(typeof e!="string"||e.length===0)return;const t=C6(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;default:return}}function oV(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function n2(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function dm(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function iV(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function lo(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function sV(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}var fA=new WeakMap;function hA(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const f of a.wordIdOther)n(f);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const c=s.replacement;if(c&&typeof c=="object")for(const f of[c.inserted,c.deleted])f&&typeof f=="object"&&(n(f.id),n(f.wordId));const u=s.move;if(u&&typeof u=="object")for(const f of[u.source,u.destination])f&&typeof f=="object"&&(n(f.id),n(f.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function Os(e){const t=fA.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=lo(i);if(s){n.add(s);for(const a of hA(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return fA.set(e,o),o}var pA=new WeakMap,mA=new WeakMap;function oc(e,t){const n=Cr(t);let r=pA.get(e);r||(r=new Map,pA.set(e,r));const o=r.get(n);if(o)return o;const i=Os(e.filter(s=>Cr(Mf(s))===n));return r.set(n,i),i}function aV(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function lV(e,t){const n=t.filter(o=>e.some(i=>lo(i)===o&&Mf(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>lo(s)===o);if(i)for(const s of hA(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function cV(e){const t=mA.get(e);if(t)return t;const n=e.filter(o=>Mf(o)!=null),r=n.length===e.length?e:n;return mA.set(e,r),r}function uV(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=c=>{for(const u of t){const f=c.toPublicId(u);if(f)return f}return null},a=es(r),l=Cr(a)===Cr(null);if(i){const c=l?cV(i):i,u=s(oc(c,a));if(u)return u;const f=n?.find(h=>c.some(g=>Ji(g,h,a)));return f||(l?s(Os(o)):aV(a)?lV(i,t):null)}return l?s(Os(o))??t[0]??null:null}function dV(e,t){const n=e.find(r=>lo(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??lo(n)??t:null}function fV(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,c=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:c??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Nr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var hV=64;function ic(e){return e.length<=hV}function es(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function bo(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function Ea(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function gA(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var vA=720;function Fs(e){return Math.round(e*20)}function Cu(e){return typeof e=="number"&&Number.isFinite(e)}function pV(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=Cu(i.left)?Fs(i.left):Cu(i.start)?Fs(i.start):void 0,a=Cu(i.right)?Fs(i.right):Cu(i.end)?Fs(i.end):void 0,l=Cu(i.firstLine)?Fs(i.firstLine):void 0,c=Cu(i.hanging)?Fs(i.hanging):void 0;return s==null&&a==null&&l==null&&c==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...c!=null?{hanging:c}:{}}}function r2(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function mV(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function Pf(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function hl(e){return Pf(e.target)??Pf(e.selectionTarget)}var yA=["fontFamily","fontSize","color","highlight"],gV={undo:"history.undo",redo:"history.redo"},Df=["bold","italic","underline","strikethrough"];function o2(e){return yA.includes(e)}function ku(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,c,u)=>{typeof l!="string"||typeof c!="number"||typeof u!="number"||r.push({blockId:l,start:Math.min(c,u),end:Math.max(c,u)})};for(const l of n){const c=l?.range;o(l?.blockId,c?.start,c?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function ts(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function vV(e){const t=ts(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function Ta(e){const t=ku(e);return t.length===0?null:[vV(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function bA(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:nc({selectionTarget:t})}function yV(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function bV(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function wV(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function CV(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function wA(e,t){const n=ku(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>CV(n,wV(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function kV(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function i2(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function SV(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function _V(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function CA(e,t){if(!e)return{};const n=new Map;for(const i of ku(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of yA){const s=new Map;let a=!1,l=!1;for(const c of r){const u=typeof c?.blockId=="string"?c.blockId:null;if(!u)continue;const f=n.get(u);if(!f?.length)continue;const h=Array.isArray(c?.runs)?c.runs:[];for(const g of h){const m=g?.range,v=typeof m?.start=="number"?m.start:null,k=typeof m?.end=="number"?m.end:null;if(v==null||k==null||!f.some(y=>bV(y,{start:v,end:k})))continue;a=!0;const C=kV(g?.styles,i);if(C===void 0){l=!0;continue}const _=_V(i,C);if(s.has(_)||s.set(_,C),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function s2(e,t){const n=Nr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:bo(n)}:{kind:"documentEnd"}}function on(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function Of(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function fm(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function Ns(e){if(xr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function hm(e){return!!e&&typeof e=="object"&&e.success===!0}function wo(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function Ff(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function a2(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const c of l.blocks)n(c);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function sc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function pm(e){return e.trackedChange?.kind==="delete"?0:typeof e.text=="string"?e.text.length:0}function ki(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!wo(i)&&n===null&&(n=i),hm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function AV(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function IV(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function mm(e){return vu(e)?.trackDecision??null}function xV(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function pl(e){return{found:!1,success:!1,rects:[],reason:e}}function EV(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function TV(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function kA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(TV))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function RV(e){return e.selectionTarget?e.selectionTarget:kA(e.target)}function Su(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=kA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function l2(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var c2={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},LV=Object.fromEntries(Object.entries(c2).filter(([e])=>Gz[e]?.tracked===!0));function MV(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...c2}};default:return null}}function PV(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function DV(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function OV(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,c=!1,u=Promise.resolve(),f=null,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},g=0;const m=new Set;let v={},k="",C=null;const _=()=>{const d=t?.activeEditor;return d&&typeof d=="object"?d:null},y=()=>{const d=_()?.doc;return d&&typeof d=="object"?d:null},w=()=>{const d=_()?.v2TrackedChanges;return d&&typeof d=="object"?d:null},T=()=>{const d=_();if(d?.editorVersion!==2)return null;const p=d.reviewWindow;return p&&typeof p=="object"?p:null},L=()=>{const d=T();return!d||typeof d.getSnapshot!="function"?null:Pt(()=>d.getSnapshot(),null)},F=()=>typeof T()?.getSnapshot=="function",H=d=>{const p=d?.status;return p==="ready"||p==="stale"?p:"pending"},M=()=>{const d=_()?.host;return d&&typeof d=="object"?d:null},B=d=>{if(d.storyType!=="headerFooterPart"||typeof d.refId!="string")return null;const p=_(),b=M(),I=p?.pageLayout??b?.pageLayout;if(!I||typeof I!="object")return null;const x=I.getActiveRulerContext,V=b?.resolveHeaderFooterEditTarget;if(typeof x!="function"||typeof V!="function")return null;const W=Pt(()=>x.call(I),null);if(!W||typeof W.pageIndex!="number")return null;for(const re of["header","footer"]){const fe=Pt(()=>V.call(b,{pageIndex:W.pageIndex,kind:re}),null);if(!(fe?.status!=="ready"||fe.refId!==d.refId||typeof fe.sectionId!="string"||!["default","first","even"].includes(String(fe.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:fe.sectionId},headerFooterKind:re,variant:fe.slotVariant}}return null},q=()=>{const d=M(),p=d?.getPendingInlineFormat;if(typeof p!="function")return null;const b=Pt(()=>p.call(d),null);return b&&typeof b=="object"?b:null},P=d=>{const p=l2(d);if(!p)return null;const b=q();if(!b||!(p in b))return null;const I=b[p];return d.inline?.kind==="toggle"?I===!0:I!=null&&I!==""},N=d=>{const p=l2(d);if(!p)return;const b=q();if(!b||!(p in b))return;const I=b[p];if(typeof I=="string"&&I!=="")return I;if(typeof I=="number"&&Number.isFinite(I))return String(I)},E=(d,p)=>{const b=M(),I=b?.setPendingInlineFormat;typeof I=="function"&&Pt(()=>I.call(b,d,p),void 0)},j=d=>{const p=M(),b=p?.clearPendingInlineFormat;typeof b=="function"&&Pt(()=>b.call(p,d),void 0)},Q=new Set(["bold","italic","underline","strikethrough"]),Y=d=>{const p=q();if(!p)return;const b=Array.isArray(d.activeMarks)?d.activeMarks:[];let I=null;for(const x of Object.keys(p)){const V=p[x];let W;if(Q.has(x))W=b.includes(x)===(V===!0);else if(o2(x)){if(V==null)continue;I||(I=Vi(d)),W=I[x]===V}else W=!1;W&&j(x)}},se=()=>{const d=_()?.editCommands;return d&&typeof d=="object"?d:null},he=d=>{const p=se();if(!p||typeof p.getSnapshot!="function")return null;const b=Pt(()=>p.getSnapshot(),null)?.commands?.[d];return b&&typeof b=="object"?b:null},Ve=()=>he("lists.apply"),pe=d=>{const p=d?.value?.seed;return p==="bullet"||p==="ordered"?p:null},ye=d=>{const p=gV[d];return p?he(p):null},me=()=>{const d=M();if(!d||typeof d.getTableContext!="function")return null;const p=Pt(()=>d.getTableContext(),null);return p&&typeof p=="object"?p:null},_e=()=>{const d=me();if(!d||d.inTable!==!0)return null;const p=d.table,b=typeof p?.nodeId=="string"&&p.nodeId.length>0?p.nodeId:null;if(!b)return null;const I=d.row,x=d.column,V=d.cell,W=typeof I?.index=="number"&&Number.isInteger(I.index)?I.index:null,re=typeof x?.index=="number"&&Number.isInteger(x.index)?x.index:null;if(W==null||re==null)return null;const fe=typeof V?.nodeId=="string"&&V.nodeId.length>0?V.nodeId:null,Me=d.cellRange;return{tableNodeId:b,rowIndex:W,columnIndex:re,cellNodeId:fe,mergeRange:PV(Me)}},oe=new Map;let Re=null,je=null,et=0,St=0,Te=0;const He=new Set,Ye=(d,p)=>d===p?!0:!d||!p?!1:d.id===p.id&&d.paintedEntityId===p.paintedEntityId&&Cr(d.story)===Cr(p.story),ee=d=>Array.from(He).some(p=>Ye(p,d)),S=d=>{const p=M();if(typeof p?.getHandles!="function")return;const b=Pt(()=>p.getHandles(),null),I=b?.review;if(I){if(d){if(typeof I.setActiveReviewTarget!="function")return;const x=b?.layout;Pt(()=>I.setActiveReviewTarget({entityType:"trackedChange",entityId:d.id,...d.paintedEntityId?{paintedEntityId:d.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof x?.generation=="number"?x.generation:0,story:d.story??{kind:"story",storyType:"body"}}),null);return}typeof I.getActiveReviewTarget!="function"||typeof I.clearActiveReviewTarget!="function"||Pt(()=>I.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Pt(()=>I.clearActiveReviewTarget(),void 0)}},ne=(d,p)=>{je=d,et+=1,Te+=1,p?.invalidateQueuedNavigation!==!1&&(St+=1)},O=new Set;let U=!1,$=null;const z=new Map,J=new Set;let Z=null,G=null,be=!1,ve=null,Ce=0,De=null,Ze=null,ot=null;const yt=()=>{if(be||U)return;be=!0;const d=()=>{be=!1,U||bt()};typeof queueMicrotask=="function"?queueMicrotask(d):Promise.resolve().then(d)},tn=250,Ue=5e3,Ot=d=>{U||ve&&Ce<=d||(ve&&clearTimeout(ve),Ce=d,ve=setTimeout(()=>{ve=null,Ce=0,U||bt()},Math.max(0,d-Date.now())))},Bt=new WeakMap;let an=0;const nr=d=>{if(!d)return"none";let p=Bt.get(d);return p==null&&(p=an+=1,Bt.set(d,p)),`e${p}`};let qt=0;const Qe=e.superdoc,It=Wz(Qe),Ht=()=>{It.abortController.abort("review-mutation-started"),It.inFlight=null},wn=()=>{It.generation+=1,It.abortController=new AbortController,It.inFlight=null},nn=d=>{const p=It.activeMutationTokens;if(typeof d!="string"||d.length===0||p.has(d))return;const b=p.size===0;p.add(d),b&&Ht()},un=d=>{const p=It.activeMutationTokens;typeof d!="string"||!p.delete(d)||p.size===0&&wn()},Wn=d=>{const p=w(),b=p?.listTrackedChanges;if(typeof b!="function")return _()?.editorVersion===2?Promise.reject(new Error("v2-tracked-changes-bridge-pending")):d();if(It.activeMutationTokens.size>0)return Promise.reject(new Error("ui-review-catalog-superseded"));const I=It.generation,x=It.inFlight;if(x?.generation===I)return x.promise;const V=It.abortController.signal,W=Me=>{if(V.aborted||I!==It.generation||Me?.reason==="review-hydration-superseded")throw new Error("ui-review-catalog-superseded");return Me},re=b.call(p,{blocking:!1,signal:V});if(!xr(re))return W(re);const fe=Promise.resolve(re).then(W);return It.inFlight={generation:I,promise:fe},fe.then(()=>{It.inFlight?.promise===fe&&(It.inFlight=null)},()=>{It.inFlight?.promise===fe&&(It.inFlight=null)}),fe};let Xn=null,Er=new Set,Kn=null,Cn=0,lr=null;const ln=()=>`${nr(_())}|m${qt}`,Co=()=>{Xn=null,Er=new Set},Ie=d=>{for(const p of["trackChanges","trackChanges:all"]){const b=z.get(p);if(!b?.hasSettled||!Array.isArray(b.value))continue;const I=b.value.filter(x=>{const V=lo(x);return!V||!d.has(V)});I.length!==b.value.length&&z.set(p,{...b,value:I})}},Be=d=>{const p=()=>{if(!U)for(const V of[...O])V(qe)},b=Ff(d)?d:null,I=_()?.documentMutationReadiness,x=()=>{const V=globalThis.requestAnimationFrame;return typeof V!="function"?Promise.resolve():new Promise(W=>{let re=!1;const fe=()=>{re||(re=!0,clearTimeout(Me),W())},Me=setTimeout(fe,250);V(()=>V(()=>setTimeout(fe,0)))})};if(b?.success===!0&&typeof b.txId=="string"&&b.txId.length>0&&typeof I?.whenPainted=="function")try{Promise.resolve(I.whenPainted.call(I,b)).then(x,()=>{}).then(p,p);return}catch{}p()},tt=(d,p)=>{const b=qe.trackChanges,I=b.items.filter(W=>{const re=lo(W);return!re||!d.has(re)});if(I.length===b.items.length)return;je&&d.has(je.id)&&ne(null);const x=new Set;for(const W of I){const re=fm(W),fe=W,Me=re.author??re.authorEmail??fe.author??fe.authorEmail;typeof Me=="string"&&x.add(Me)}const V=b.items.length-I.length;qe={...qe,trackChanges:{...b,items:I,total:Math.max(I.length,b.total-V),activeId:b.activeId&&d.has(b.activeId)?null:b.activeId,authors:[...x]}},Be(p)},ft=d=>{const p=qe.trackChanges,b=p.items.length>0||p.total!==0||p.activeId!==null||p.authors.length>0;Kn=ln(),je!==null&&ne(null),qe={...qe,trackChanges:{...p,items:[],total:0,activeId:null,authors:[]}},b&&Be(d)},Lt=(d,p)=>{if(d.size===0)return;const b=ln(),I=Xn===b?Er:new Set,x=new Set([...d].filter(V=>!I.has(V)));x.size!==0&&(Xn=b,Er=new Set([...I,...x]),Ie(Er),tt(x,p))},Dt=d=>Xn===d&&Er.size>0?Er:null,bn=d=>{const p=ln(),b=Dt(p),I=d.map(Of).filter(x=>{if(x==null)return!1;const V=lo(x);return V!=null&&!b?.has(V)});for(const x of["trackChanges","trackChanges:all"])z.set(x,{token:p,value:[...I],hasSettled:!0,inflightToken:null})},Wt=()=>`${ln()}|m${Qn()}|s${Cn}`,Zn=d=>JSON.stringify({t:d.target??null,s:d.selectionTarget??null}),ko=["contentControls:inRange:","query:","effInline:"],ri=120,oi=180,Qt=()=>{const d=M(),p=d?.getDocumentLoadingSnapshot;if(typeof p!="function")return"unknown";const b=Pt(()=>p.call(d),null)?.sourceStage;return b==="opening"||b==="bootstrap-ready"||b==="source-loading"?"loading":b==="source-complete"||b==="source-failed"||b==="source-cancelled"?"complete":"unknown"},cn=new Map,Rn=new Map,Tr=new Map;let Yt=null,Tn=0,Ur=0;const co=d=>{const p=ln();cn.get(d)!==p&&(cn.set(d,p),yt())},Bs=()=>{const d=z.get("comments");return d?.hasSettled?Array.isArray(d.value)&&d.value.length>0:d?.inflightToken!=null},ac=(d,p)=>cn.get(d)===p,zs=()=>{const d=ln();let p=!1;for(const[b,I]of Rn){if(I!==d){Rn.delete(b);continue}if(Tr.get(b)===d)continue;const x=z.get(b);!x?.hasSettled||x.token!==d||x.inflightToken!=null||(z.set(b,{...x,token:null,inflightToken:null}),Tr.set(b,d),p=!0)}p&&yt()},Si=d=>{d==="comments"?Tn+=1:Ur+=1,co(d);let p=!1;return()=>{p||(p=!0,d==="comments"?Tn=Math.max(0,Tn-1):Ur=Math.max(0,Ur-1),(d==="comments"?Tn:Ur)===0&&cn.get(d)===ln()&&cn.delete(d),yt())}},ii=d=>{co("contentControls")},we=()=>{const d=z.get("trackChanges");d?.hasSettled||d?.inflightToken!=null||co("trackChanges")},ze=()=>{const d=z.get("comments");d?.hasSettled||d?.inflightToken!=null||co("comments")},kt=6500,lt=250;let Ln=0,On=0,kr=!1,Hr=null;const jo=()=>{if(U||Hr)return;const d=()=>{if(Hr=null,U)return;const p=Date.now()-Ln;if(Xr()||p<kt){Hr=setTimeout(d,lt);return}kr=!1,bt()};Hr=setTimeout(d,0)};let Uo=null,yr=null;const Di=()=>{const d=M();if(!d||Uo===d)return;yr&&(yr(),yr=null),Uo=d;const p=d.subscribeDocumentLoading;if(typeof p!="function"){Uo=null,So(kt);return}try{const b=V=>{const W=V?.sourceStage;(W==="source-complete"||W==="source-failed"||W==="source-cancelled")&&(Yt=ln(),zs(),Ln=Math.max(Ln,Date.now()),jo())},I=p.call(d,b);typeof I=="function"&&(yr=I);const x=d.getDocumentLoadingSnapshot;typeof x=="function"&&b(Pt(()=>x.call(d),null))}catch{Uo=null,So(kt)}},Br=()=>{const d=_()?.host,p=d?.getForegroundMutationState;if(typeof p!="function")return null;const b=Pt(()=>p.call(d),null);return{active:typeof b?.active=="number"?b.active:0,pending:typeof b?.pending=="number"?b.pending:0}},Xr=()=>{const d=Br();return!!(d&&(d.active>0||d.pending>0))},So=(d=ri)=>{U||De||(De=setTimeout(()=>{if(De=null,U)return;if(Ze&&Xr()){So(),bt();return}const p=Ze;Ze=null,p===Wt()&&Vs("selection",p,La,Ni),bt()},d))},_o=(d,p)=>{if(!Br())return!1;const b=`${d}\0${p}`;return J.has(b)?!1:(J.add(b),So(oi),!0)},rs=d=>{if(Z==null||d===Z)return G?.timer&&clearTimeout(G.timer),G=null,Z=d,!1;if(G?.key===d)return G.ready?(G=null,Z=d,!1):!0;G?.timer&&clearTimeout(G.timer);const p={key:d,ready:!1,timer:null};return p.timer=setTimeout(()=>{U||G!==p||(p.timer=null,p.ready=!0,bt())},oi),G=p,!0},_i=d=>Bz(d),si=()=>{ai(),bt()};let os=null,Oi=!1,Fi=0;const ml=()=>{os=null,Oi=!1,Fi+=1},gl=()=>{const d=_(),p=d?.documentMutationReadiness;if(!d||typeof p?.whenPainted!="function"||(os={editor:d,readiness:p,afterEpoch:typeof p.getRenderEpoch=="function"?Pt(()=>p.getRenderEpoch.call(p),null):null},Oi))return;Oi=!0;const b=Fi;(async()=>{for(;!U&&b===Fi;){const x=os;if(os=null,!x){Oi=!1;return}let V=!1;try{await x.readiness.whenPainted.call(x.readiness,typeof x.afterEpoch=="number"?{afterEpoch:x.afterEpoch}:void 0),V=!0}catch{}if(U||b!==Fi)return;if(_()!==x.editor){ml();return}V&&si()}})()},vl=()=>{ot&&clearTimeout(ot),ot=setTimeout(()=>{ot=null,U||si()},500)},Vs=(d,p,b,I)=>{let x;try{x=b()}catch{x=void 0}if(!xr(x)){const re={token:p,value:I(x),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return z.set(d,re),re}const V=z.get(d),W=V?.failedToken===p;return z.set(d,{token:V?.token??null,value:V?.value??null,hasSettled:V?.hasSettled??!1,inflightToken:p,failedToken:W?p:null,failureCount:W?V.failureCount??0:0,retryAtMs:0}),Promise.resolve(x).then(re=>{const fe=z.get(d);!fe||fe.inflightToken!==p||(z.set(d,{token:p,value:I(re),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0}),yt())},()=>{const re=z.get(d);if(!re||re.inflightToken!==p)return;const fe=re.failedToken===p?(re.failureCount??0)+1:1,Me=Math.min(Ue,tn*2**Math.min(fe-1,8)),$e=Date.now()+Me;z.set(d,{...re,inflightToken:null,failedToken:p,failureCount:fe,retryAtMs:$e}),Ot($e)}),null},uo=(d,p,b,I)=>{const x=z.get(d);if(x&&x.token===p&&x.hasSettled)return{value:x.value,status:"ready"};if(nV(d)&&!ac(d,p)){if(Qt()==="loading")return kr=!0,Di(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(kr)return jo(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(Date.now()-On<kt)return kr=!0,jo(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"}}if(Xr())return So(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(x?.failedToken===p&&x.inflightToken==null&&(x.retryAtMs??0)>Date.now())return Ot(x.retryAtMs),x.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(!x&&d.startsWith("effInline:")&&rs(d))return{value:null,status:"pending"};if(!x&&_o(d,p))return{value:null,status:"pending"};if(!x||x.inflightToken!==p){const W=Vs(d,p,b,I);if(W)return{value:W.value,status:"ready"}}const V=z.get(d);return V?.hasSettled?{value:V.value,status:"stale"}:{value:null,status:"pending"}},js=d=>{for(const p of z.keys())d(p)&&z.delete(p)},Nf=d=>{const p=Zn(d),b=bA(d);return new Set([`contentControls:inRange:${p}`,`query:${p}`,...b?[`effInline:${b}`]:[]])},yl=d=>{const p=Nf(d);js(b=>ko.some(I=>b.startsWith(I))&&!p.has(b));for(const b of J){const I=b.split("\0",1)[0];ko.some(x=>I.startsWith(x))&&!p.has(I)&&J.delete(b)}},_u=()=>{const d=_();d!==lr&&(ml(),lr=d,z.clear(),ve&&clearTimeout(ve),ve=null,Ce=0,G?.timer&&clearTimeout(G.timer),G=null,Z=null,C=null,o=null,Ze=null,J.clear(),cn.clear(),Rn.clear(),Tr.clear(),Yt=null,kr=!1,yr&&yr(),yr=null,Uo=null,Co(),Kn=null)},ai=()=>{qt+=1,Rn.clear(),Tr.clear(),Yt=null,Co()},Us=()=>{const d=Kn===ln();ai(),d&&(bn([]),Kn=ln()),bt()},Au=d=>{if(typeof d!="string"||d.length===0)return Yn("insertText requires a non-empty string.","INVALID_INPUT");if(Qn()==="viewing")return Yn("The document is read-only.","DOCUMENT_READONLY");const p=y(),b=p?.insert;if(!p||typeof b!="function")return Yn("insert is unavailable.");const I=p.selection?.current;if(typeof I!="function")return Yn("selection.current is unavailable.");const x=W=>{const re=W&&typeof W=="object"?W:null,fe=re?.selectionTarget??re?.target??null;return!fe||typeof fe!="object"?Yn("insertText requires a live selection target.","PRECONDITION_FAILED"):Pt(()=>xl(b.call(p,{type:"text",value:d,target:fe}),Yn("insert failed.")),Yn("insert failed."))};let V;try{V=I.call(p.selection)}catch{return Yn("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return xr(V)?Promise.resolve(V).then(x,()=>Yn("insertText could not resolve the live selection.","PRECONDITION_FAILED")):x(V)},lc=(d,p)=>({payload:d,state:qe,editor:_(),superdoc:t,context:p,ui:$,execute:(b,I)=>bc(b,I),executeAsync:(b,I)=>xm(b,I),doc:y(),selection:qe.selection,documentMode:Qn(),insertText:Au}),cc=d=>d==="editing"||d==="suggesting"||d==="viewing"?d:null,Qn=()=>{const d=_(),p=t&&typeof t=="object"?t:null,b=cc(p?.config?.documentMode),I=Pt(typeof p?.getActiveRuntime=="function"?()=>{const W=p.getActiveRuntime();return typeof W?.getSnapshot=="function"?W.getSnapshot():null}:void 0,null),x=cc(I?.documentMode),V=cc(d?.options?.documentMode);return b&&x&&b!==x?b:x??b??V},uc=()=>{const d=t&&typeof t=="object"?t:null,p=d?.interactionConfig?.comments;if(p&&typeof p.readOnly=="boolean")return p.readOnly===!0;const b=d?.config?.modules?.comments;return!!b&&typeof b=="object"&&b.readOnly===!0},Bf=()=>{const d=t&&typeof t=="object"?t:null,p=d?.interactionConfig?.comments;if(p&&typeof p.allowResolve=="boolean")return p.allowResolve===!1;const b=d?.config?.modules?.comments;return!!b&&typeof b=="object"&&b.allowResolve===!1},Ao=()=>Qn()==="viewing"||uc(),Ni=d=>d&&typeof d=="object"?d:null,Hs=(d,p)=>{if(!d)return{...Jz,status:p};const b=d.target??null,I=typeof d.text=="string"?d.text:"";return{status:p,empty:d.empty===!0,target:b,selectionTarget:d.selectionTarget??null,activeMarks:Array.isArray(d.activeMarks)?d.activeMarks:[],activeCommentIds:Array.isArray(d.activeCommentIds)?d.activeCommentIds:[],activeChangeIds:Array.isArray(d.activeChangeIds)?d.activeChangeIds:[],quotedText:I}},Ra=()=>{const d=y()?.selection;return uo("selection",Wt(),()=>d?.current?d.current({includeText:!0}):void 0,Ni)},bl=()=>{const{value:d,status:p}=Ra();return Hs(d,p)},La=()=>{const d=y()?.selection;return d?.current?d.current({includeText:!0}):void 0},Iu=d=>{if(d.empty!==!0)return!1;const p=d.selectionTarget,b=p?.start,I=p?.end;return b?.kind==="text"&&I?.kind==="text"&&typeof b.blockId=="string"&&b.blockId===I.blockId&&typeof b.offset=="number"&&b.offset===I.offset},dc=d=>{const p=M(),b=p?.readLiveSelectionSyncSnapshot;if(typeof b!="function")return;const I=Ni(Pt(()=>b.call(p),null));if(!I||!Iu(I))return;const x=Wt(),V=Br(),W=!!(V&&(V.active>0||V.pending>0));if(W)Ze=x,So();else if(Ze=null,Vs("selection",x,La,Ni))return;const re=z.get("selection"),fe=Array.isArray(I.activeMarks)&&I.activeMarks.length>0?I.activeMarks:Array.isArray(qe.selection.activeMarks)?qe.selection.activeMarks:[],Me=Array.isArray(I.activeCommentIds)?I.activeCommentIds:[],$e=sV(d),We=hl(qe.selection),Je=Pf(I.selectionTarget)??Pf(I.target),nt=We?.range,Ge=Je?.range,rt=!!(V&&V.active>0&&We&&Je&&We.blockId===Je.blockId&&Cr(We.story)===Cr(Je.story)&&typeof nt?.start=="number"&&typeof Ge?.start=="number"&&Math.abs(Ge.start-nt.start)<=2),ht=$e!=null||rt?qe.selection.activeChangeIds.filter(it=>$e==null||Os(qe.trackChanges.items).aliasesFor(it).includes($e)):[],dt=Array.isArray(I.activeChangeIds)&&I.activeChangeIds.length>0?I.activeChangeIds:ht;z.set("selection",{token:x,value:{...I,activeMarks:fe,activeCommentIds:Me,activeChangeIds:dt},hasSettled:!0,inflightToken:W?null:re?.inflightToken??null})},$s=async(d=0)=>{const p=y()?.selection,b=p?.current,I=Wt();if(typeof b!="function")return z.set("selection",{token:I,value:null,hasSettled:!0,inflightToken:null}),bt(),qe.selection;let x;try{x=b.call(p,{includeText:!0}),xr(x)&&(x=await Promise.resolve(x))}catch{x=null}return U?Hs(null,"pending"):Wt()!==I?d<1?$s(d+1):qe.selection:(z.set("selection",{token:I,value:Ni(x),hasSettled:!0,inflightToken:null}),bt(),qe.selection)},is=()=>{const d=y()?.comments;return uo("comments",ln(),()=>d?.list?d.list():void 0,p=>p&&Array.isArray(p.items)?p.items:[])},Ma=(d="trackChanges")=>{const p=ln(),b=y()?.trackChanges,I=w(),x=typeof I?.listTrackedChanges=="function"?I.listTrackedChanges:null,V=uo(d,p,()=>x?Wn(()=>b?.list?.({in:"all"})):b?.list?b.list({in:"all"}):void 0,W=>{const re=W&&typeof W=="object"?W:null;if(re?.complete===!1||re?.sourceCoverageComplete===!1){if(Rn.set(d,p),Di(),Yt===p||Qt()==="complete"){const fe=()=>{U||zs()};typeof queueMicrotask=="function"?queueMicrotask(fe):Promise.resolve().then(fe)}}else Rn.get(d)===p&&Rn.delete(d);return re&&Array.isArray(re.items)?re.items:[]});return Rn.get(d)===p&&V.status==="ready"?{...V,status:"stale"}:V},xu=d=>{const p=L(),b=F(),I=b?null:is(),x=b&&Array.isArray(p?.commentItems)?p.commentItems:null,V=b?x:I.value,W=b?H(p):I.status,re=V??[],fe=d.activeCommentIds,Me=z.get("comments"),$e=Me?.token===ln()&&Me.hasSettled&&Array.isArray(Me.value)?Me.value:null,We=Tn>0?$e:re;Re&&We&&!We.some(nt=>lo(nt)===Re)&&(Re=null);const Je=Re??fe[0]??null;return{status:fl(W,d.status),listStatus:W,items:re,total:re.length,activeIds:fe,activeId:Je}},Eu=new WeakMap,Gs=d=>{const p=Eu.get(d);if(p)return p;const b=d.map(Of).filter(I=>I!=null);return Eu.set(d,b),b},Pa=new WeakMap,Da=(d,p)=>{const b=Pa.get(d);if(b?.suppressedIds===p)return b.value;const I=p?d.filter(x=>{const V=lo(x);return!V||!p.has(V)}):d;return Pa.set(d,{suppressedIds:p,value:I}),I},wl=new WeakMap,Rr=d=>{const p=wl.get(d);if(p)return p;const b=new Set;for(const x of d){const V=fm(x),W=x,re=V.author??V.authorEmail??W.author??W.authorEmail;typeof re=="string"&&b.add(re)}const I=[...b];return wl.set(d,I),I},Bi=()=>{const d=ln();if(F()){const I=z.get("trackChanges"),x=I?.token===d&&I.hasSettled&&Array.isArray(I.value)?I.value:L()?.trackedChangeItems;return Array.isArray(x)?Gs(x):null}const{value:p,status:b}=Ma("trackChanges:all");return b==="ready"?Gs(p??[]):null},Cl=d=>{const p=ln(),b=Dt(p),I=L(),x=F(),V=x?null:Ma(),W=x&&Array.isArray(I?.trackedChangeItems)?I.trackedChangeItems:null,re=x?W:V.value,fe=x?H(I):V.status,Me=Da(Gs(re??[]),b),$e=Bi(),We=je;if(We&&!He.has(We)){const Vt=z.get("trackChanges"),Hn=Vt?.token===p&&Vt.hasSettled&&Array.isArray(Vt.value)?Da(Gs(Vt.value),b):null,$n=Ur>0?Hn:We.story?$e:Me;$n&&!$n.some(Gr=>Ji(Gr,We.id,We.story))&&ne(null)}const Je=$e??Me,nt=oc(Je,es(d)),Ge=Kn===p?[]:b?d.activeChangeIds.filter(Vt=>!b.has(Vt)):d.activeChangeIds,rt=Ge.map(Vt=>nt.toPublicId(Vt)??Vt),ht=je?.story?oc(Je,je.story):Os(Je),dt=je?ht.toPublicId(je.id)??je.id:null,it=uV({selectionIds:Ge,publicIds:rt,selection:d,bodyItems:Me,allStoryItems:$e}),zt=dt??it;return{status:fl(fe,d.status),items:Me,total:Me.length,activeId:zt,authors:Rr(Me)}},fc=(d,p)=>{if(!F())return p;co("comments");const b=is(),I=b.value??p.items;return{status:fl(b.status,d.status),listStatus:b.status,items:I,total:I.length,activeIds:d.activeCommentIds,activeId:Re??d.activeCommentIds[0]??null}},Tu=(d,p)=>{if(!F())return p;co("trackChanges");const b=Ma(),I=Dt(ln()),x=Da(Gs(b.value??p.items),I),V=je?.story?oc(x,je.story):Os(x),W=je?V.toPublicId(je.id)??je.id:p.activeId;return{status:fl(b.status,d.status),items:x,total:x.length,activeId:W,authors:Rr(x)}},zi=d=>{const p=y()?.contentControls,{value:b,status:I}=uo("contentControls",ln(),()=>p?.list?p.list():void 0,re=>re&&Array.isArray(re.items)?re.items:[]),x=b??[],{ids:V,status:W}=Ru(p,d);return{status:fl(I,W,d.status),items:x,total:x.length,activeId:V[0]??null,activeIds:V}},ss=(d,p)=>{if(!d||typeof d.listInRange!="function")return{lockModesById:new Map,status:"ready"};const b=fV(p);if(!b)return{lockModesById:new Map,status:"ready"};const{value:I,status:x}=uo(`contentControls:inRange:${Zn(p)}`,ln(),()=>d.listInRange(b),re=>re&&Array.isArray(re.items)?re.items:[]),V=I??[],W=new Map;for(const re of V)typeof re?.id=="string"&&W.set(re.id,typeof re.lockMode=="string"?re.lockMode:"unlocked");return{lockModesById:W,status:x}},Ru=(d,p)=>{const{lockModesById:b,status:I}=ss(d,p);return{ids:[...b.keys()],status:I}},zf=()=>{const d=t?.fonts;return{options:VV(BV(Pt(d?.getDocumentFontOptions?()=>d.getDocumentFontOptions():void 0,[])),zV(Pt(d?.getFontFamilyOptions?()=>d.getFontFamilyOptions():void 0,[]))),sizeOptions:jV}},hc=()=>{const d=Pt(t?.getZoomState?()=>t.getZoomState():void 0,null),p=typeof d?.value=="number"?d.value:100,b=d?.mode;return{mode:b==="manual"||b==="fit-width"?b:b==="fixed"?"manual":null,value:p,min:typeof d?.min=="number"?d.min:10,max:typeof d?.max=="number"?d.max:100}},Lu=()=>Pt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",Mu=()=>{const d=_();return{ready:d!=null,mode:Qn(),dirty:d?!!d.isDirty:!1}},pc=d=>{const p=d.quotedText;if(typeof p!="string"||p.length===0)return null;const b=ku(d);if(b.length===0||!ic(b.map(V=>V.blockId)))return null;const I=d.target,x=b.length===1?bo(b[0].blockId,I?.story):void 0;return{select:{type:"text",pattern:p,mode:"contains",caseSensitive:!0},...x?{within:x}:{},require:"any"}},Pu=d=>{const p=y()?.query;if(typeof p?.match!="function")return null;const b=pc(d);if(!b)return null;const{value:I}=uo(`query:${Zn(d)}`,ln(),()=>p.match(b),x=>x&&typeof x=="object"?x:null);return wA(I,d)},Vf=d=>{const p=M(),b=new Set(Nr(d));if(b.size===0)return{};const I=p?.readMountedProjectionBlocksByIds,x=p?.readMountedProjectionBlocks;if(typeof I!="function"&&typeof x!="function")return{};const V=Pt(()=>{if(typeof I!="function")return x.call(p);const rt=ts(d);return rt?I.call(p,[...b],rt):I.call(p,[...b])},null);if(!Array.isArray(V))return{};const W=a2(V),re=rt=>{const ht={},dt=i2(rt.fontFamily);dt&&(ht.fontFamily=dt);const it=SV(rt.fontSize);return it&&(ht.fontSize=it),typeof rt.color=="string"&&rt.color.trim()!==""&&(ht.color=rt.color.trim().toUpperCase()),typeof rt.highlight=="string"&&rt.highlight.trim()!==""&&(ht.highlight=rt.highlight.trim().toUpperCase()),ht},fe=hl(d),Me=fe&&typeof fe.range?.start=="number"?fe.range.start:null;if(fe&&Me!==null&&b.has(fe.blockId)){const rt=W.find(dt=>sc(dt,fe.blockId)),ht=rt&&Array.isArray(rt.runs)?rt.runs:null;if(ht&&ht.length>0&&ht.every(dt=>dt?.kind==="text"||dt?.kind==="tab")){let dt=0,it=null;for(const zt of ht){const Vt=pm(zt);if(Me>=dt&&Me<dt+Vt){it=zt;break}dt+=Vt}if(!it){for(let zt=ht.length-1;zt>=0&&!it;zt-=1)ht[zt]?.kind==="text"&&(it=ht[zt]);it??=ht[ht.length-1]??null}return it?re(it):{}}}const $e=ku(d);if($e.length>0){const rt=new Set,ht=new Set;let dt=!1,it=!0;for(const zt of $e){const Vt=W.find(Gr=>sc(Gr,zt.blockId));if(!Vt)return{};const Hn=Array.isArray(Vt.runs)?Vt.runs:[];if(Hn.length===0)continue;if(!Hn.every(Gr=>Gr?.kind==="text"||Gr?.kind==="tab")){it=!1;break}let $n=0;for(const Gr of Hn){const Wr=pm(Gr),Sr=$n,Mr=$n+Wr;if(Sr<zt.end&&Mr>zt.start){dt=!0;const Yo=re(Gr);Yo.fontFamily&&rt.add(Yo.fontFamily),Yo.fontSize&&ht.add(Yo.fontSize)}$n=Mr}}if(it&&dt){const zt={};return rt.size===1&&(zt.fontFamily=[...rt][0]),ht.size===1&&(zt.fontSize=[...ht][0]),zt}}const We=new Set,Je=new Set;let nt=!1;for(const rt of W){if(![...b].some(dt=>sc(rt,dt)))continue;const ht=Array.isArray(rt.runs)?rt.runs:[];for(const dt of ht){if(dt?.kind!=="text")continue;nt=!0;const it=re(dt);it.fontFamily&&We.add(it.fontFamily),it.fontSize&&Je.add(it.fontSize)}}if(!nt)return{};const Ge={};return We.size===1&&(Ge.fontFamily=[...We][0]),Je.size===1&&(Ge.fontSize=[...Je][0]),Ge},Du=d=>{const p=M(),b=new Set(Nr(d));if(b.size===0)return{};const I=p?.readMountedProjectionBlocksByIds,x=p?.readMountedProjectionBlocks;if(typeof I!="function"&&typeof x!="function")return{};const V=Pt(()=>{if(typeof I!="function")return x.call(p);const Ge=ts(d);return Ge?I.call(p,[...b],Ge):I.call(p,[...b])},null);if(!Array.isArray(V))return{};const W=a2(V),re=Ge=>({bold:Ge.bold===!0,italic:Ge.italic===!0,underline:Ge.underline!=null,strikethrough:Ge.strike===!0}),fe=Ge=>{const rt={};for(const ht of Df){const dt=Ge[ht];dt.size===1&&(rt[ht]=[...dt][0])}return rt},Me=hl(d),$e=Me&&typeof Me.range?.start=="number"?Me.range.start:null;if(Me&&$e!==null&&b.has(Me.blockId)){const Ge=W.find(ht=>sc(ht,Me.blockId)),rt=Ge&&Array.isArray(Ge.runs)?Ge.runs:null;if(rt&&rt.length>0&&rt.every(ht=>ht?.kind==="text"||ht?.kind==="tab")){let ht=0,dt=null;for(const it of rt){const zt=pm(it);if($e>=ht&&$e<ht+zt){dt=it;break}ht+=zt}if(!dt){for(let it=rt.length-1;it>=0&&!dt;it-=1)rt[it]?.kind==="text"&&(dt=rt[it]);dt??=rt[rt.length-1]??null}return dt?re(dt):{}}}const We=ku(d);if(We.length>0){const Ge={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let rt=!1,ht=!0;for(const dt of We){const it=W.find(Hn=>sc(Hn,dt.blockId));if(!it)return{};const zt=Array.isArray(it.runs)?it.runs:[];if(zt.length===0)continue;if(!zt.every(Hn=>Hn?.kind==="text"||Hn?.kind==="tab")){ht=!1;break}let Vt=0;for(const Hn of zt){const $n=pm(Hn),Gr=Vt,Wr=Vt+$n;if(Gr<dt.end&&Wr>dt.start){rt=!0;const Sr=re(Hn);for(const Mr of Df)Ge[Mr].add(Sr[Mr])}Vt=Wr}}if(ht&&rt)return fe(Ge)}const Je={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let nt=!1;for(const Ge of W){if(![...b].some(ht=>sc(Ge,ht)))continue;const rt=Array.isArray(Ge.runs)?Ge.runs:[];for(const ht of rt){if(ht?.kind!=="text")continue;nt=!0;const dt=re(ht);for(const it of Df)Je[it].add(dt[it])}}return nt?fe(Je):{}},mc=(d,p)=>{if(p.fontFamily!==void 0&&p.fontSize!==void 0&&p.color!==void 0&&p.highlight!==void 0)return{values:p,effectiveUniformityStatus:"ready"};const b=Vf(d),I={...b.fontFamily!==void 0?{fontFamily:b.fontFamily}:{},...b.fontSize!==void 0?{fontSize:b.fontSize}:{},...b.color!==void 0?{color:b.color}:{},...b.highlight!==void 0?{highlight:b.highlight}:{},...p};if(!d.empty&&(I.fontFamily===void 0||I.fontSize===void 0)){const x=Uf(d);return x.values&&(I.fontFamily===void 0&&x.values.fontFamily!==void 0&&(I.fontFamily=x.values.fontFamily),I.fontSize===void 0&&x.values.fontSize!==void 0&&(I.fontSize=x.values.fontSize)),{values:I,effectiveUniformityStatus:x.status}}return{values:I,effectiveUniformityStatus:"ready"}},jf=["fontFamily","fontSize","bold","italic","underline","strikethrough"],gc=d=>{const p=d.selectionTarget;if(!p)return{value:null,status:"ready"};const b=vr(y(),"format.readEffectiveInlineUniformity");if(!b)return{value:null,status:"ready"};const I=bA(d)??Zn(d);return uo(`effInline:${I}`,ln(),()=>b({target:p,offsetSpace:"selection",keys:jf}),x=>x&&typeof x=="object"?x:null)},Uf=d=>{const{value:p,status:b}=gc(d);if(!p||p.success!==!0)return{values:null,status:b};const I=p.values,x=V=>{const W=I?.[V];if(!(!W||W.state!=="uniform"||typeof W.value!="string"))return V==="fontFamily"?i2(W.value):W.value};return{values:{fontFamily:x("fontFamily"),fontSize:x("fontSize")},status:b}},li=d=>{const{value:p,status:b}=gc(d);if(!p||p.success!==!0)return{values:null,status:b};const I=p.values,x={};for(const V of Df){const W=I?.[V];W?.state==="uniform"&&(W.value==="true"||W.value==="false")&&(x[V]=W.value==="true")}return{values:x,status:b}},vc=(d,p)=>{const b=d.activeMark;if(!b||!Df.includes(b))return null;const I=b,x=Du(p)[I];if(x!==void 0)return x;const{values:V}=li(p),W=V?.[I];return W!==void 0?W:null},kl=async d=>{const p=d.selectionTarget;if(!p)return null;const b=vr(y(),"format.readEffectiveInlineUniformity");if(!b)return null;try{const I=await Promise.resolve(b({target:p,offsetSpace:"selection"}));return I&&typeof I=="object"&&I.success===!0?I:null}catch{return null}},Hf=(d,p,b)=>{const I=b.values;for(const x of["fontFamily","fontSize"]){if(p[x]!==void 0)continue;const V=I?.[x];V?.state==="uniform"&&typeof V.value=="string"?d[x]=x==="fontFamily"?i2(V.value):V.value:delete d[x]}},Ou=d=>mc(d,CA(Pu(d),d)),Vi=d=>Ou(d).values,$f=async d=>{const p=y()?.query,b=pc(d);if(typeof p?.match!="function"||!b)return Vi(d);try{const I=await Promise.resolve(p.match(b)),x=CA(wA(I&&typeof I=="object"?I:null,d),d),V=mc(d,x);if(V.effectiveUniformityStatus!=="ready"&&(x.fontFamily===void 0||x.fontSize===void 0)){const W=await kl(d);W&&Hf(V.values,x,W)}return V.values}catch{return Vi(d)}},Sl=async d=>{const p=y();if(p)return typeof p.getNode=="function"?await Promise.resolve(p.getNode(d)):await Promise.resolve(p.getNodeById?.({nodeId:d.nodeId,nodeType:d.nodeType}))},Fu=d=>{const p=y()?.query;if(typeof p?.match!="function")return"ready";const b=pc(d);if(!b)return"ready";const{status:I}=uo(`query:${Zn(d)}`,ln(),()=>p.match(b),x=>x&&typeof x=="object"?x:null);return I},Nu=d=>{const p=Ou(d),b=p.values;if(d.empty)return p;const I=Ta(d);return I?d.status==="ready"&&Fu(d)==="ready"&&p.effectiveUniformityStatus==="ready"?(C={key:I,values:b},p):C&&C.key===I?{...p,values:{...C.values,...b}}:p:p},Bu=d=>{const p=y(),b=Nu(d),I=b.values;d.status==="ready"&&!d.empty&&Fu(d)==="ready"&&b.effectiveUniformityStatus==="ready"&&(v=I,k=`${nc(d)}:${ln()}`);const x=p?.contentControls,{lockModesById:V}=ss(x,d),W={};for(const re of kn())W[re]=Uu(re,p,d,I,V);return W},ji=d=>d?ct.operationUnavailable:_()?ct.documentApiUnavailable:ct.notReady,Ws=d=>d==="contentLocked"||d==="sdtContentLocked",ci=d=>{for(const p of d.values())if(Ws(p))return ct.contentControlLocked},zu=(d,p,b,I,x)=>{if(!p)return d.scope==="all"?ct.bulkDecisionsDisabled:ji(x);if(b)return ct.documentReadonly;if(d.scope!=="all"&&I.activeChangeIds.length===0)return ct.selectionRequired},Vu=d=>{const p=M(),b=Pt(typeof p?.getCapabilities=="function"?()=>p.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(b))return b.find(I=>I?.command===d||I?.id===d)??null;if(b&&typeof b=="object"){const I=b[d];return I&&typeof I=="object"?I:null}return null},ju=(d,p)=>{if(d.scope!=="all"||typeof p?.[`${d.kind}All`]=="function")return;const b=Vu(`trackedChanges.${d.kind}All`);if(!(b&&(b.status==="supported"||b.enabled===!0)))return ct.bulkDecisionsDisabled},Uu=(d,p,b,I,x=new Map)=>{if(oe.has(d))return on({supported:!0,enabled:!0,...Pt(oe.get(d).getState?()=>oe.get(d).getState(lc(void 0)):void 0,{})},"custom");const V=Qn()==="viewing",W=cA(d);if(W&&typeof se()?.lists?.apply=="function"){const nt=Ve(),Ge=typeof nt?.shippedStatus=="string"?nt.shippedStatus:null,rt=Ge!=="not-shipped"&&Ge!=="disabled";return on({enabled:rt&&(typeof nt?.enabled=="boolean"?nt.enabled:!0),active:(rt?pe(nt):null)===W,supported:rt,value:nt?.value},"builtin")}const re=mm(d);if(re){const nt=p?.trackChanges,Ge=typeof nt?.decide=="function"||typeof nt?.[re.kind]=="function",rt=typeof nt?.decide=="function"||typeof nt?.[`${re.kind}All`]=="function",ht=re.scope==="all"?rt:Ge,dt=ju(re,nt)??zu(re,ht,Ao(),b,p);return on({enabled:dt==null,active:!1,supported:ht,reason:dt},"builtin")}if(d==="copy-format")return Qn()==="viewing"?on({supported:!0,enabled:!1,active:!1},"builtin"):_()?on({supported:!0,enabled:!0,active:h.mode!=="idle"},"builtin"):on({supported:!0,enabled:!1,active:!1,reason:ct.notReady},"builtin");const fe=vu(d);if(!fe)return on({enabled:!1,active:!1,supported:!1,reason:ct.commandUnsupported},"unsupported");if(fe.disposition!=="routed")return on({enabled:!1,active:!1,supported:!1,reason:fe.reason??ct.commandUnsupported},fe.disposition==="unsupported"?"unsupported":"builtin");if(fe.instanceRoute)return ut(fe);if(fe.table)return Ct(fe,p,V);if(fe.inline?.kind==="clear"){if(fe.mutates&&V)return on({enabled:!1,active:!1,supported:!0,reason:ct.documentReadonly},"builtin");const nt=ci(x);if(nt)return on({enabled:!1,active:!1,supported:!0,reason:nt},"builtin");const Ge=Nr(b).length>0||Su(b)!=null;return on({enabled:Ge,active:!1,supported:!0,reason:Ge?void 0:ct.selectionRequired},"builtin")}const Me=fe.docRoute;if(!Me)return on({enabled:!1,active:!1,supported:!1,reason:ct.commandUnsupported},"unsupported");if(vr(p,Me)==null)return on({enabled:!1,active:!1,supported:!1,reason:ji(p)},"builtin");const $e=ye(d);if($e){const nt=$e.shippedStatus,Ge=nt!=="not-shipped"&&nt!=="disabled",rt=typeof $e.enabled=="boolean"?$e.enabled:!0,ht=d==="undo"||d==="redo",dt=ht&&$e.historyResolved===!1,it=ht&&Ge&&rt===!1&&$e.reason===null&&!dt,zt=$e.reason===void 0?void 0:it?ct.historyEmpty:dt?ct.notReady:e2($e.reason,ct.commandUnsupported);return fe.mutates&&V?on({enabled:!1,active:!1,supported:Ge,reason:ct.documentReadonly},"builtin"):on({enabled:Ge&&rt,active:!1,supported:Ge,reason:zt},"builtin")}const We=Ks(fe,p,b),Je=Wf(fe,p,b,I);if(fe.list?.mode==="indent"||fe.list?.mode==="outdent")return Oe(fe,p,V,b,We,Je);if(fe.list?.mode==="toggle-seed")return Pe(fe,p,V,b,We,Je);if(fe.mutates&&V)return on({enabled:!1,active:We,supported:!0,value:Je,reason:ct.documentReadonly},"builtin");if(fe.inline&&!Su(b)){const nt=ci(x);return on(nt?{enabled:!1,active:We,supported:!0,value:Je,reason:nt}:Nr(b).length>0&&typeof M()?.setPendingInlineFormat=="function"?{enabled:!0,active:We,supported:!0,value:Je}:{enabled:!1,active:We,supported:!0,value:Je,reason:ct.rangeSelectionRequired},"builtin")}if((fe.blockParagraph||fe.list)&&Nr(b).length===0)return on({enabled:!1,active:We,supported:!0,value:Je,reason:ct.selectionRequired},"builtin");if(fe.link&&!We&&r2(b).length===0&&!hl(b))return on({enabled:!1,active:We,supported:!0,reason:ct.rangeSelectionRequired},"builtin");if(fe.inline){const nt=ci(x);if(nt)return on({enabled:!1,active:We,supported:!0,value:Je,reason:nt},"builtin")}return on({enabled:!0,active:We,supported:!0,value:Je},"builtin")};function Gf(d,p){const b=d.address?.anchor,I=b?.start,x=b?.end,V=typeof I?.blockId=="string"?I.blockId:null,W=typeof x?.blockId=="string"?x.blockId:null;if(!V||!W)return!1;const re=typeof I?.offset=="number"?I.offset:null,fe=typeof x?.offset=="number"?x.offset:null;if(re==null||fe==null)return!1;const Me=p.target,$e=Me&&Array.isArray(Me.segments)?Me.segments:[];for(const We of $e){const Je=typeof We?.blockId=="string"?We.blockId:null;if(!Je)continue;const nt=We.range,Ge=typeof nt?.start=="number"?nt.start:null,rt=typeof nt?.end=="number"?nt.end:null;if(!(Ge==null||rt==null)){if(V!==W){if(Je===V&&rt>re||Je===W&&Ge<fe)return!0;continue}if(Je===V){if(Ge===rt){if(Ge>=re&&Ge<=fe)return!0;continue}if(Math.max(Ge,re)<Math.min(rt,fe))return!0}}}return!1}const as=(d,p)=>{const b=d?.hyperlinks;if(!b||typeof b.list!="function")return null;const I=Nr(p);if(!ic(I))return null;for(const x of I){const V={kind:"block",nodeType:"paragraph",nodeId:x},{value:W}=uo(`hyperlinks:${x}`,ln(),()=>b.list({within:V}),fe=>fe&&typeof fe=="object"?fe:null),re=(W&&Array.isArray(W.items)?W.items:[]).find(fe=>Gf(fe,p));if(re)return re}return null},Ks=(d,p,b)=>{if(d.link)return as(p,b)!=null;if(d.list?.mode==="toggle-seed"&&d.list.seed)return Al(p,b)===d.list.seed;const I=P(d);if(I!==null)return I;const x=r.get(d.id),V=Ta(b);if(V&&x?.selectionSignature===V)return x.active;const W=vc(d,b);return W!==null?W:UV(d,b)},Wf=(d,p,b,I)=>{if(d.inline&&o2(d.inline.key)){const x=N(d);if(x!==void 0)return x;const V=I[d.inline.key];if(V!==void 0)return V;const W=Ta(b),re=W?n.get(d.inline.key):void 0;if(W&&re?.selectionSignature===W)return re.value}if(d.id==="linked-style"){const{style:x}=Zr(b,mn().cache);return!x.styleId||x.mixed?void 0:{styleId:x.styleId,styleName:x.styleName}}if(d.id==="text-align")return ae(p,b);if(d.id==="link")return Ke(p,b)??void 0},ls=(d,p,b)=>{const I=d?.lists;if(!I)return{value:null,status:"ready"};const x=b.storyType==="body",V=typeof I.getStateInStory=="function"?()=>I.getStateInStory({target:Ea(p),story:b}):x&&typeof I.getState=="function"?()=>I.getState({target:Ea(p)}):null;if(!V)return{value:null,status:"ready"};const{value:W,status:re}=uo(`lists:${Cr(b)}:${p}`,ln(),V,fe=>fe&&typeof fe=="object"?fe:null);return{value:W?.success===!0?W:null,status:re}},fo=(d,p,b)=>ls(d,p,b).value,qs=(d,p,b)=>{const I=fo(d,p,b);return!I||I.isListItem!==!0?null:I.seed==="bullet"||I.seed==="ordered"?I.seed:null},_l=(d,p,b)=>{const I=ls(d,p,b),x=I.value;return{value:x&&typeof x.isListItem=="boolean"?x.isListItem:null,status:I.status}},Al=(d,p)=>{const b=Nr(p);if(b.length===0||!ic(b))return null;const I=es(p),x=qs(d,b[0],I);if(x!=="bullet"&&x!=="ordered")return null;for(const V of b.slice(1))if(qs(d,V,I)!==x)return null;return x},yc=(d,p,b)=>{if(!d)return{value:null,status:"ready",refreshing:!1};const I=Cr(b),x=I==="story:body";if(x&&typeof d.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!x&&typeof d.getNode!="function")return{value:null,status:"ready",refreshing:!1};const V=`node:${I}:${p}`,W=ln(),re=uo(V,W,()=>x?d.getNodeById({nodeId:p,nodeType:"paragraph"}):d.getNode(bo(p,b)),Me=>Me&&typeof Me=="object"?Me:null),fe=z.get(V);return{...re,refreshing:re.status==="stale"&&fe?.inflightToken===W&&fe.failedToken!==W}},Ys=d=>d==="left"||d==="center"||d==="right"||d==="justify"?d:void 0,Hu=d=>d==="start"||d==="end"||d==="distributed"||d==="numTab"||d==="lowKashida"||d==="mediumKashida"||d==="highKashida"||d==="thaiDistribute",A=(d,p)=>{const b=M(),I=b?.readMountedProjectionBlocksByIds;if(typeof I!="function")return null;const x=ts(d),V=Pt(()=>x?I.call(b,[...p],x):I.call(b,[...p]),null);if(!Array.isArray(V))return new Map;const W=a2(V),re=new Map;for(const fe of p){const Me=W.find(nt=>sc(nt,fe));if(!Me)continue;const $e=Me.attrs,We=Ys($e?.alignment),Je=o9($e);re.set(fe,We??(Je==="rtl"?"right":"left"))}return re},R=(d,p,b,I)=>{const{value:x,status:V,refreshing:W}=yc(d,p,b),re=I?.get(p);if(V==="pending")return re?{status:"uniform",value:re}:{status:"pending"};if(V==="stale"&&!W)return{status:"pending"};if(V==="stale"&&re)return{status:"uniform",value:re};if(V==="stale"&&I&&!re)return{status:"unavailable"};if(!x)return{status:"unavailable"};const fe=x.node;if(!fe)return{status:"unavailable"};const Me=fe.kind;if(Me!=="paragraph"&&Me!=="heading")return{status:"unavailable"};const $e=fe[Me];if(!$e||typeof $e!="object")return{status:"unavailable"};const We=$e.props?.alignment;if(We==null)return re?{status:"uniform",value:re}:{status:"unavailable"};const Je=Ys(We);return Je?{status:"uniform",value:Je}:Hu(We)&&re?{status:"uniform",value:re}:{status:"unavailable"}},X=(d,p)=>{const b=Nr(p);if(b.length===0||!ic(b))return{status:"unavailable"};const I=es(p),x=A(p,b),V=R(d,b[0],I,x);if(V.status!=="uniform")return V;for(const W of b.slice(1)){const re=R(d,W,I,x);if(re.status!=="uniform")return re;if(re.value!==V.value)return{status:"mixed"}}return V},ie=d=>{const p=Nr(d);return p.length===0?null:`${Cr(es(d))}:${p.join(",")}`},ae=(d,p)=>{const b=X(d,p),I=b.status==="uniform"?b.value:void 0,x=o;if(!x)return I;const V=ie(p);return V&&V!==x.selectionSignature?(o=null,I):!V||!x.settled?x.value:b.status!=="pending"?(o=null,I):x.value},le=(d,p)=>{const b=Ys(p),I=ie(d),x=Nr(d);if(!b||!I||x.length===0)return null;const V=++i;return o={selectionSignature:I,value:b,generation:V,settled:!1,canReconcile:ic(x)},bt(),V},de=(d,p)=>{if(d==null)return;const b=o;if(!(!b||b.generation!==d)){if(!wo(p)){o=null;return}if(!b.canReconcile){o=null;return}b.settled=!0}},ue=async(d,p,b)=>{const I=d?.lists;if(!I)return null;try{const x=b.storyType==="body",V=typeof I.getStateInStory=="function"?await I.getStateInStory({target:Ea(p),story:b}):x&&typeof I.getState=="function"?await I.getState({target:Ea(p)}):null,W=V&&typeof V=="object"?V:null;return!W||W.success!==!0||typeof W.isListItem!="boolean"?null:W.isListItem}catch{return null}},Ae=(d,p,b)=>{const I={resolved:!1,seed:null},x=d?.lists;if(!x)return I;const V=b.storyType==="body",W=typeof x.getStateInStory=="function"?()=>x.getStateInStory({target:Ea(p),story:b}):V&&typeof x.getState=="function"?()=>x.getState({target:Ea(p)}):null;if(!W)return I;const re=fe=>{const Me=fe&&typeof fe=="object"?fe:null;return!Me||Me.success!==!0||typeof Me.isListItem!="boolean"?I:{resolved:!0,seed:Me.isListItem===!0&&(Me.seed==="bullet"||Me.seed==="ordered")?Me.seed:null}};try{const fe=W();return xr(fe)?Promise.resolve(fe).then(re,()=>I):re(fe)}catch{return I}},Le=async(d,p,b)=>{if(!d)return null;try{const I=!b||b.storyType==="body",x=b&&typeof d.getNode=="function"?await d.getNode(bo(p,b)):I&&typeof d.getNodeById=="function"?await d.getNodeById({nodeId:p,nodeType:"paragraph"}):null;return pV(x&&typeof x=="object"?x:null)}catch{return null}},Oe=(d,p,b,I,x,V)=>{if(d.mutates&&b)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.documentReadonly},"builtin");const W=Nr(I);if(W.length===0)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.selectionRequired},"builtin");const re=d.docRoute?vr(p,d.docRoute):null,fe=vr(p,"format.paragraph.setIndentation"),Me=vr(p,"format.paragraph.clearIndentation"),$e=d.list?.mode,We=$e==="indent"?fe!=null:fe!=null||Me!=null,Je=es(I);let nt=null;if(Je.storyType!=="body"){nt=[];for(const Ge of W){const{value:rt,status:ht}=_l(p,Ge,Je);if(rt===null)return ht!=="ready"&&(re!=null||We)?on({enabled:!0,active:x,supported:!0,value:V},"builtin"):on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin");nt.push(rt)}}if(nt?.some(Ge=>Ge===!0)){const Ge=$e==="indent"?"lists.indentRange":"lists.outdentRange",rt=Qn()!=="suggesting"&&nt.every(dt=>dt===!0)&&vr(p,Ge)!=null,ht=$e==="outdent"&&vr(p,"lists.outdentInStory")!=null;if(!rt&&!ht)return on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")}for(const[Ge,rt]of W.entries()){const ht=nt?{value:nt[Ge]??null,status:"ready"}:_l(p,rt,Je),dt=ht.value;if(dt===!0){if(re!=null)return on({enabled:!0,active:x,supported:!0,value:V},"builtin");continue}if(dt===!1&&We){if(Je.storyType!=="body"&&typeof p?.getNode!="function")continue;return on({enabled:!0,active:x,supported:!0,value:V},"builtin")}if(dt===null)return ht.status!=="ready"&&(re!=null||We)?on({enabled:!0,active:x,supported:!0,value:V},"builtin"):on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")}return on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")},Pe=(d,p,b,I,x,V)=>{if(d.mutates&&b)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.documentReadonly},"builtin");const W=Nr(I);if(W.length===0)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.selectionRequired},"builtin");const re=es(I),fe=p?.lists;if(!(typeof fe?.getStateInStory=="function"||re.storyType==="body"&&typeof fe?.getState=="function"))return on({enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");if(!ic(W))return on(re.storyType==="body"&&vr(p,"lists.remove")!=null?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const Me=W.map(nt=>ls(p,nt,re));if(Me.some(({status:nt})=>nt!=="ready"))return on({enabled:!0,active:x,supported:!0,value:V},"builtin");if(Me.some(({value:nt})=>nt===null))return on({enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const $e=d.list?.seed,We=Me.every(({value:nt})=>nt?.isListItem===!0&&nt.seed===$e);if(re.storyType==="body")return on(!We||vr(p,"lists.remove")!=null?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const Je=vr(p,"lists.removeInStory");return on(We&&Je?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin")},Ke=(d,p)=>{const b=as(d,p)?.properties?.href;return typeof b=="string"?b:null},ut=d=>{if(!_())return on({enabled:!1,active:!1,supported:!1,reason:ct.notReady},"builtin");const p=d.instanceRoute;return typeof t?.[p]!="function"?on({enabled:!1,active:!1,supported:!1,reason:ct.operationUnavailable},"builtin"):on({enabled:!0,active:at(d),supported:!0,value:vt(d)},"builtin")},at=d=>{const p=t?.config??void 0;return d.valueFrom==="ruler"?!!p?.rulers:d.valueFrom==="formattingMarks"?!!p?.layoutEngineOptions?.showFormattingMarks:!1},Ct=(d,p,b)=>{if(b)return on({enabled:!1,active:!1,supported:!0,reason:ct.documentReadonly},"builtin");const I=_e();return I!=null&&(!d.table.requiresCell||I.cellNodeId!=null)?(d.docRoute?vr(p,d.docRoute):null)==null?on({enabled:!1,active:!1,supported:!1,reason:ji(p)},"builtin"):on({enabled:!0,active:!1,supported:!0},"builtin"):on({enabled:!1,active:!1,supported:!0,reason:ct.tableContextUnavailable},"builtin")},vt=d=>{if(d.valueFrom==="zoom")return hc().value;if(d.valueFrom==="documentMode")return Qn();if(d.valueFrom==="measurementUnit")return Lu();if(d.valueFrom==="ruler"||d.valueFrom==="formattingMarks")return at(d)},Xt=(d,p)=>d.id==="zoom"?typeof p=="number"&&Number.isFinite(p)&&p>0:d.id==="document-mode"?p==="editing"||p==="suggesting"||p==="viewing":d.id==="measurement-unit"?p==="in"||p==="cm":!0,kn=()=>[...new Set([...QF,...oe.keys()])],Lr="Normal",Jt={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},An=d=>{const p=y()?.styles;return!p||typeof p.getCatalog!="function"?{value:null,status:"ready"}:uo(`styles:catalog:${JSON.stringify(d??{})}`,ln(),()=>p.getCatalog(d),b=>b&&typeof b=="object"?b:null)},mn=()=>{const d=An({includePreview:!0});if(!d.value)return{cache:null,status:d.status};const p=An({view:"quickGallery",includePreview:!0}),b=p.value?p.value.items:d.value.styles.filter(x=>x.visibility.quickGallery),I=new Map;for(const x of d.value.styles)I.set(x.id,x);return{cache:{full:d.value,quickGallery:b,byId:I},status:fl(d.status,p.status)}},pr=(d,p,b)=>{const{value:I,status:x}=yc(d,p,b);if(!I)return{ok:!1,styleRef:null,status:x};const V=I.node;if(!V||typeof V!="object")return{ok:!1,styleRef:null,status:x};const W=V.kind,re=typeof W=="string"?V[W]:void 0,fe=re&&typeof re=="object"?re.styleRef:void 0;return{ok:!0,styleRef:typeof fe=="string"&&fe.length>0?fe:null,status:x}},Zr=(d,p)=>{const b=[],I=y();if(!I)return b.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};const x=Nr(d);if(x.length===0)return b.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};if(!ic(x))return b.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};const V=p?.full.defaults.paragraphStyleId??(p?Lr:null),W=new Set;let re=0,fe=0,Me=0,$e="ready";const We=es(d);for(const Ge of x){const rt=pr(I,Ge,We);if($e=fl($e,rt.status),!rt.ok){fe+=1;continue}if(!rt.styleRef&&!V){Me+=1;continue}const ht=rt.styleRef??V;if(!ht){Me+=1;continue}re+=1,W.add(ht)}if(re===0){const Ge=Me>0&&fe===0;return b.push({severity:"warning",code:Ge?"active-style-default-unavailable":"active-style-read-failed",message:Ge?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:$e}}const Je=fe+Me;if(Je>0)return b.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${re} of ${re+Je} selected blocks; ${Je} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:$e};if(W.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:b},status:$e};const nt=[...W][0];return{style:{styleId:nt,styleName:p?.byId.get(nt)?.name??null,mixed:!1,diagnostics:b},status:$e}},Qr=d=>{if(!_())return Jt;const{cache:p,status:b}=mn(),{style:I,status:x}=Zr(d,p);let V;return p?V=I.diagnostics.length===0?p.full.diagnostics:[...p.full.diagnostics,...I.diagnostics]:V=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},...I.diagnostics],{ready:!0,status:fl(b,x,d.status),catalogRevision:p?.full.revision??null,quickGallery:p?.quickGallery??[],activeParagraphStyleId:I.styleId,activeParagraphStyleName:I.styleName,mixedSelection:I.mixed,sourceStatus:p?.full.sourceStatus??null,diagnostics:V}},Ai=()=>{const d=Qn(),p=bl();p.status==="ready"&&yl(p),Y(p);const b=Ta(p);for(const[I,x]of r)(!b||x.selectionSignature!==b||x.settled&&p.status==="ready")&&r.delete(I);return{ready:_()!=null,documentMode:d,document:Mu(),selection:p,toolbar:{context:d,commands:Bu(p),copyFormatActive:h.mode!=="idle"},comments:xu(p),trackChanges:Cl(p),contentControls:zi(p),zoom:hc(),fonts:zf(),styles:Qr(p)}},ui=d=>{const p=Ta(d);p&&a&&p!==a&&(n.clear(),r.clear()),p&&(a=p)};let st=null,dn=null,Jr=null,Ho=null,ho=null,$o=null,cs=!1;const us=()=>{if(U||cs)return;cs=!0;const d=()=>{cs&&(cs=!1,!U&&bt())};typeof queueMicrotask=="function"?queueMicrotask(d):Promise.resolve().then(d)},Il=()=>{const d=se();if(d!==Jr&&(Ho&&(Ho(),Ho=null),Jr=d,!(!d||typeof d.subscribe!="function")))try{const p=d.subscribe(()=>us());typeof p=="function"&&(Ho=p)}catch{Jr=null}},ds=()=>{const d=T();if(d!==ho&&($o&&($o(),$o=null),ho=d,!(!d||typeof d.subscribe!="function")))try{const p=d.subscribe(()=>bt());typeof p=="function"&&($o=p)}catch{ho=null}};let Fo=null,di=null,fs=null,fi=null,Xs=null,D=null;const K=()=>{const d=_()?.host,p=Pt(d?.getHandles?()=>d.getHandles():void 0,null)?.editing?.selection;return p&&typeof p.subscribe=="function"?p:null},Se=()=>{const d=K();if(d!==st&&(dn&&(dn(),dn=null),st=d,!!d))try{const p=d.subscribe(b=>{Cn+=1,dc(b),bt()});typeof p=="function"&&(dn=p)}catch{st=null}},Ne=()=>{const d=_()?.host,p=Pt(d?.getHandles?()=>d.getHandles():void 0,null)?.review;return p&&typeof p.subscribe=="function"?p:null},mt=d=>d?typeof d.getActiveReviewTarget=="function"?Pt(()=>d.getActiveReviewTarget(),null):typeof d.getSnapshot=="function"?Pt(()=>d.getSnapshot(),null)?.activeReviewTarget??null:null:null;let $t=0;const Sn=(d,p)=>{const b=(p&&typeof p=="object"?p:null)?.lastInteractionRejection;if($t>0&&d==null&&b&&typeof b=="object"&&b.code==="review-target-invalidated"&&b.detail==="not-painted")return!1;const I=d&&typeof d=="object"?d:null;let x=null;if(I?.entityType==="trackedChange"&&typeof I.entityId=="string"&&I.entityId.length>0){const V=I.entityId,W=I.story&&typeof I.story=="object"?I.story:void 0,re=Bi(),fe=(re?W?oc(re,W).toPublicId(V):Os(re).toPublicId(V):null)??V,Me=W&&Cr(W)!==Cr(null)?W:void 0;x={id:fe,...Me?{story:Me}:{},...typeof I.paintedEntityId=="string"&&I.paintedEntityId.length>0?{paintedEntityId:I.paintedEntityId}:fe!==V?{paintedEntityId:V}:{}}}return d==null&&x==null&&je!=null&&ee(je)||Ye(je,x)?!1:(ne(x),!0)},En=()=>{const d=Ne();if(d===Fo)return;if(di&&(di(),di=null),Fo=d,!d){Sn(null);return}let p=!0;try{const b=d.subscribe(I=>{const x=I&&typeof I=="object"?I:null,V=x&&Object.prototype.hasOwnProperty.call(x,"activeReviewTarget")?x.activeReviewTarget:mt(d);!Sn(V,I)||p||bt()});typeof b=="function"&&(di=b),Sn(mt(d))}catch{Fo=null}finally{p=!1}},Mn=()=>{if(st||Qn()!=="viewing")return null;const d=_()?.mount?.container,p=(d&&typeof d=="object"&&"ownerDocument"in d?d.ownerDocument??null:null)??globalThis.document??null;return p&&typeof p.addEventListener=="function"?p:null},Fn=()=>{const d=Mn();if(d===Xs||(D&&(D(),D=null),Xs=d,!d))return;const p=()=>{Cn+=1,bt()};d.addEventListener("selectionchange",p),d.addEventListener("pointerup",p,!0),d.addEventListener("mouseup",p,!0),D=()=>{d.removeEventListener("selectionchange",p),d.removeEventListener("pointerup",p,!0),d.removeEventListener("mouseup",p,!0)}};_u(),Sn(mt(Ne()));let qe=Ai();a=Ta(qe.selection);const Tt=()=>{const d=_()?.host?.events,p=d&&typeof d.subscribe=="function"?d:null;if(p!==fs&&(fi&&(fi(),fi=null),fs=p,!!p))try{const b=p.subscribe(I=>{const x=I?.type;if(x==="review-mutation:started"){nn(I.reviewMutation?.token);return}if(x==="review-mutation:aborted"){un(I.reviewMutation?.token),yt();return}if(x==="mutation:rejected"&&I.reviewMutation&&(un(I.reviewMutation.token),yt()),x==="mutation:committed"&&I.reviewMutation&&un(I.reviewMutation.token),x==="source:complete"||x==="source:signals-complete"){Yt=ln(),zs();return}if((x==="mutation:committed"||x==="collaboration:remote-changed")&&(Ln=Date.now()),x==="mutation:committed"||x==="save:completed"||x==="collaboration:remote-changed"){const V=x==="mutation:committed"?Bk(I):null;if(V?.allResolved){bn([]),ft(I.receipt);return}V?.removedIds.size&&Lt(new Set(V.removedIds),I.receipt);const W=x==="mutation:committed"&&_i(I)||x==="collaboration:remote-changed"&&Array.isArray(I.changedStoryIds)&&I.changedStoryIds.length>0;if(W&&(On=Date.now()),x==="mutation:committed"&&W){vl();return}if(V?.removedIds.size&&V.upsertIds.size===0)return;(x==="collaboration:remote-changed"||x==="mutation:committed"&&!W)&&gl();const re=x==="collaboration:remote-changed"&&Array.isArray(I.changedPartUris)&&I.changedPartUris.some(Me=>typeof Me=="string"&&tV.has(Me)),fe=x==="collaboration:remote-changed"&&Array.isArray(I.changedStoryIds)&&I.changedStoryIds.length>0&&Bs();re&&!W&&(kr=!0),ai(),re&&!W?co("comments"):fe&&(kr=!0,jo()),bt()}});typeof b=="function"&&(fi=b)}catch{fs=null}},bt=()=>{if(U)return;cs=!1,_u(),Se(),Il(),ds(),En(),Fn(),Tt();const d=Ai();ui(d.selection),qe=d;for(const p of[...O])p(qe)},rr=[],Nn=[],Un=d=>{for(const p of d)try{p()}catch{}},No=()=>Un(rr),Go=()=>Un(Nn),Zs=[];((d,p)=>{if(!(!d||typeof d.on!="function"))for(const b of p){const I=b==="active-editor-change"?()=>{No(),Go(),bt()}:b==="document-replaced"?x=>{const V=x&&typeof x=="object"?x:null,W=V?.editor,re=V?.host,fe=!!W&&W===_(),Me=!!re&&re===M();!fe&&!Me||(Go(),z.clear(),ai(),bt())}:()=>bt();try{d.on(b,I),Zs.push(()=>{try{typeof d.off=="function"&&d.off(b,I)}catch{}})}catch{}}})(t,Yz),Se(),Il(),ds(),En(),Fn(),Tt();const Wo=(d,p=Mz)=>({get:()=>d(qe),subscribe:b=>{let I=d(qe);const x=V=>{const W=d(V);p(I,W)||(I=W,b(W))};return O.add(x),()=>O.delete(x)}}),Ko=d=>Wo(d),qo=d=>{const p=b=>{const I=V=>{try{b(V)}catch{}},x=d.subscribe(I);return I(d.get()),x};return{get:()=>d.get(),getSnapshot:()=>d.get(),observe:p,subscribe:b=>p(I=>b({snapshot:I}))}},Gu=(d,p,b)=>{const I=qo(d),x=qo(p),V=W=>{const re=Si(b);bt();const fe=x.observe(W);return()=>{fe(),re()}};return{get:I.get,getSnapshot:I.getSnapshot,observe:V,subscribe:W=>V(re=>W({snapshot:re}))}};function d2(d){return d&&typeof d=="object"&&typeof d.id=="string"?String(d.id):null}function Wu(d){const p=ts(d);return p&&Cr(p)!==Cr(null)?p:void 0}function qn(d,p){return{kind:"id",id:d,...p?{story:p}:{}}}function f2(d){if(d.empty)return null;const p=d.selectionTarget,b=p?.start,I=p?.end;if(p?.kind!=="selection"||b?.kind!=="text"||I?.kind!=="text"||typeof b.blockId!="string"||b.blockId!==I.blockId||!Number.isInteger(b.offset)||!Number.isInteger(I.offset)||b.offset<0||I.offset<0||b.offset===I.offset)return null;const x=Math.min(b.offset,I.offset),V=Math.max(b.offset,I.offset),W=ts(d);return{kind:"range",coordinateSpace:p.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...W?{story:W}:{},segments:[{blockId:b.blockId,range:{start:x,end:V}}]}}}function ym(d,p){if(Cr(p)!==Cr(null))return;const b=y()?.trackChanges,I=b?.list;if(typeof I!="function")return;const x=Pt(()=>I.call(b),null);if(xr(x)||!x||typeof x!="object")return;const V=x.items;if(Array.isArray(V))return V.map(Of).find(W=>W!=null&&Ji(W,d,p))}function bm(d,p){const b=wm(d.quotedText);if(!b)return!1;const I=fm(p);return[I.insertedText,I.deletedText,I.excerpt].some(x=>wm(x)===b)}function wm(d){return typeof d=="string"?d.replace(/\s+/g," ").trim():""}function Cm(){const d=qe.selection.activeChangeIds[0];if(!d)return"unavailable";const p=ts(qe.selection),b=(qe.trackChanges.status==="ready"?qe.trackChanges.items.find(W=>Ji(W,d,p)):void 0)??ym(d,p)??Bi()?.find(W=>Ji(W,d,p));if(!b)return"unavailable";const I=fm(b),x=I.type,V=I.grouping;return bm(qe.selection,b)?"id":x==="replacement"&&V==="replacement-pair"||(x==="insertion"||x==="deletion"||x==="insert"||x==="delete")&&V==="standalone"?"range":"id"}function km(d,p,b,I){const x=()=>b2(d,qn(b,I),b,I);try{const V=b2(d,p,null);if(xr(V))return xo(Promise.resolve(V).then(re=>wo(Ns(re))?re:x()));const W=Ns(V);return xo(wo(W)?V:x())}catch{return!1}}function Sm(d,p){if(d.scope==="all")return{target:{kind:"all"},changeId:null};if(typeof p=="string"&&p.length>0)return{target:{kind:"id",id:p},changeId:p};if(p&&typeof p=="object"){const x=p;if(x.target&&typeof x.target=="object"){const W=x.target;return{target:W,changeId:d2(W),story:W.story}}const V=typeof x.changeId=="string"?x.changeId:x.id;if(typeof V=="string"&&V.length>0)return{target:qn(V,x.story),changeId:V,story:x.story}}const b=qe.selection.activeChangeIds[0],I=Wu(qe.selection);return b?{target:qn(b,I),changeId:b,story:I}:null}function h2(d,p){if(d.scope==="id"&&p==null){if(qe.selection.activeChangeIds.length>1)return Yf(d.kind,{kind:"ids",ids:qe.selection.activeChangeIds},null);if(qe.selection.activeChangeIds.length===1&&!qe.selection.empty&&qe.selection.selectionTarget){const I=Cm();if(I==="unavailable")return!1;if(I==="range"){const x=f2(qe.selection),V=Wu(qe.selection);return x?km(d.kind,x,qe.selection.activeChangeIds[0],V):!1}if(I==="id"){const x=qe.selection.activeChangeIds[0],V=ts(qe.selection),W=V&&Cr(V)!==Cr(null)?V:void 0;return y2(d.kind,W?{id:x,story:W}:x)}}}const b=Sm(d,p);return b?Yf(d.kind,b.target,b.changeId,b.story):!1}function _m(d,p){const b=se()?.lists,I=b?.apply;if(typeof I!="function")return!1;const{behavior:x,preset:V,continuity:W}=typeof p=="string"?Qz(p):p&&typeof p=="object"?p:{},re={kind:d,behavior:x??"toggle"};V!==void 0&&(re.preset=V),W!==void 0&&(re.continuity=W);try{return xo(I.call(b,re))}catch{return!1}}let hi=Promise.resolve(!1),Io=null,Ku=Promise.resolve(!1);const Et=async d=>{if(!hm(d))return d;const p=_()?.documentMutationReadiness,b=p?.whenPainted;if(typeof b!="function")return d;const I=typeof d.txId=="string"?d.txId:void 0;try{await b.call(p,I?{txId:I}:void 0)}catch{}return d},Mt=d=>{if(xr(d)){const b=Promise.resolve(d);return{immediate:!0,committed:b.then(I=>Ns(I),()=>!1),settled:b.then(I=>Et(Ns(I)),()=>!1)}}const p=Ns(d);return{immediate:p,committed:Promise.resolve(p),settled:Et(p)}},gn=()=>{const d=s.shift();if(!d){c=!1,f?.(),f=null;return}try{d.resolve(U?!1:d.mutate())}catch{d.resolve(!1)}},br=()=>{let d=!1;return()=>{d||(d=!0,gn())}},$r=(d,p)=>{if(!c){c=!0,u=new Promise(V=>{f=V});try{return{result:p(),release:br()}}catch(V){throw c=!1,f?.(),f=null,V}}const b=s.find(V=>V.key===d);if(b)return b.mutate=p,{result:b.result,release:()=>{}};let I;const x=new Promise(V=>{I=V});return s.push({key:d,mutate:p,result:x,resolve:I}),{result:x,release:br()}},po=new Set(["create.tableOfContents"]),Ii=d=>Yn(`Tracked authoring is not supported for ${d}.`),Ui=d=>{if(Qn()==="suggesting")return po.has(d)?Ii(d):{changeMode:"tracked"}},qu=()=>Qn()==="suggesting"?LV:c2,mo=(d,p,b)=>{const I=Ui(d);return I&&I.success===!1?I:I?p(b,I):p(b)},hj=(d,p,b,I)=>{const x=d.inline;if(!x)return;const V=Ns(I);if(V===!1||typeof V=="object"&&V&&V.success===!1)return;if(x.kind==="clear"){n.clear();return}if(x.kind==="toggle"||!o2(x.key))return;const W=Ta(p);if(!W)return;const re=yV(x.key,b.value);if(re==null){n.delete(x.key);return}n.set(x.key,{selectionSignature:W,value:re})},pj=(d,p,b,I)=>!d.inline||d.inline.kind==="toggle"?I:xr(I)?Promise.resolve(I).then(x=>(hj(d,p,b,x),x)):I,mj=(d,p,b,I)=>{if(d.inline?.kind!=="toggle"||!wo(Ns(I))||typeof b.value!="boolean"&&b.value!==null)return null;const x=Ta(p);if(!x)return null;const V=++l;return r.set(d.id,{selectionSignature:x,active:b.value===!0,generation:V,settled:!1}),bt(),V},gj=(d,p,b)=>{if(p==null)return;const I=r.get(d.id);if(!(!I||I.generation!==p)){if(!wo(b)){r.delete(d.id);return}I.settled=!0}},Am=(d,p)=>d.then(b=>(p?.(b),Us(),b),()=>(p?.(!1),Us(),!1)),xo=(d,p)=>{const b=Io;if(Io=null,b)return hi=Am(b,p),Ns(d);if(xr(d))return hi=Am(Mt(d).settled,p),!0;const I=Ns(d);return hm(I)&&typeof _()?.documentMutationReadiness?.whenPainted=="function"?(hi=Am(Et(I),p),I):(p?.(I),hi=Promise.resolve(I),Us(),I)},vj=(d,p)=>!d||typeof d!="object"?p:d,xl=(d,p=Yn("Document API operation failed."))=>{if(xr(d))return Promise.resolve(d).then(I=>xl(I,p),()=>p);const b=vj(d,p);return ai(),hm(b)&&typeof _()?.documentMutationReadiness?.whenPainted=="function"?(Am(Et(b)),bt(),b):(bt(),b)},yj=(d,p,b,I)=>{const x=[],V=[];for(const W of b){const re=I(W);if(re)try{const fe=Mt(mo(d,p,re));x.push(fe.immediate),V.push(fe.settled)}catch{x.push(!1),V.push(Promise.resolve(!1))}}return Io=V.length?Promise.all(V).then(W=>ki(W)):null,ki(x)},bj=(d,p,b,I)=>{const x=[],V=[];for(const W of b){const re=I(W);if(re)try{const fe=Mt(mo(d,p,re));x.push(fe.immediate),V.push(fe.settled)}catch{x.push(!1),V.push(Promise.resolve(!1))}}return Io=V.length?Promise.all(V).then(W=>ki(W)):null,ki(x)},p2=(d,p,b,I=qe.selection)=>{const x=Ui(d);return x&&x.success===!1?x:I.selectionTarget?p(b,{...x??{},offsetSpace:"selection"}):x?p(b,x):p(b)},wj=(d,p,b,I)=>{const x=bo(p,I);switch(d.kind){case"alignment":{const V=b;return V!=="left"&&V!=="center"&&V!=="right"&&V!=="justify"?null:{target:x,alignment:V}}case"spacing-line":{const V=typeof b=="number"?b:Number(b);return!Number.isFinite(V)||V<=0?null:{target:x,line:V,lineRule:"auto"}}case"style":if(b&&typeof b=="object"){const V=b.role;if(V&&typeof V=="object")return{target:x,role:V}}return typeof b!="string"||b.trim()===""?null:{target:x,styleId:b};case"direction":{const V=d.fixedValue;return V!=="ltr"&&V!=="rtl"?null:{target:x,direction:V}}default:return null}},Cj=(d,p)=>{const b=d.inline,I=l2(d),x=M();if(!b||typeof x?.setPendingInlineFormat!="function")return!1;if(b.kind==="clear")return j(),!0;if(!I)return!1;let V;if(b.kind==="toggle")V=!Ks(d,y(),qe.selection);else{const W=p&&typeof p=="object"&&"value"in p?p.value:p;if(b.kind==="value-number"){const re=typeof W=="number"?W:Number(W);V=Number.isFinite(re)&&re>0?re:null}else V=typeof W=="string"&&W.trim()!==""?W:null;if(V===null)return E(I,null),!0}return E(I,V),!0},kj=()=>{const d=y(),{lockModesById:p}=ss(d?.contentControls,qe.selection);if(ci(p))return!1;const b=[],I=[],x=nt=>{const Ge=Mt(nt);b.push(Ge.immediate),I.push(Ge.settled)},V=(nt,Ge,rt)=>{try{x(rt?nt(Ge,rt):nt(Ge))}catch{b.push(!1),I.push(Promise.resolve(!1))}},W=mn().cache?.full.defaults.paragraphStyleId??Lr,re=Su(qe.selection);if(re){const nt=vr(d,"format.apply");if(nt)try{x(p2("format.apply",nt,{target:re,inline:{...qu()}}))}catch{b.push(!1),I.push(Promise.resolve(!1))}}const fe=vr(d,"format.paragraph.resetDirectFormatting"),Me=vr(d,"styles.paragraph.setStyleRef"),$e=ts(qe.selection),We=!$e||$e.storyType==="body",Je=vr(d,We?"lists.remove":"lists.removeInStory");for(const nt of Nr(qe.selection)){const Ge=bo(nt,$e);if(fe&&V(fe,{target:Ge}),Je)try{const rt=Ea(nt),ht=Mt(Je(We?{target:rt}:{target:rt,story:$e}));I.push(ht.settled.then(dt=>wo(dt)?dt:!0))}catch{}Me&&V(Me,{target:Ge,styleId:W})}if(!re&&Qn()!=="suggesting"){const nt=vr(d,"format.paragraph.setMarkRunProps");if(nt)for(const Ge of Nr(qe.selection))V(nt,{target:bo(Ge,$e),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return Io=I.length?Promise.all(I).then(nt=>ki(nt)):null,ki(b.length?b:[!1])},Sj=(d,p,b)=>{const I=Nr(qe.selection);if(I.length===0)return!1;const x=ts(qe.selection);return yj(d.docRoute,p,I,V=>wj(d.blockParagraph,V,b,x))},_j=(d,p,b)=>{const I=y(),x=vr(I,"format.paragraph.setIndentation"),V=vr(I,"format.paragraph.clearIndentation"),W=d.list?.mode,re=es(qe.selection),fe=ts(qe.selection),Me=async $e=>{const We=await ue(I,$e,re);if(We===!0)return{kind:"list",routeToCall:d.docRoute,opToCall:p,input:{target:gA($e)}};if(We===null||fe&&fe.storyType!=="body"&&typeof I?.getNode!="function")return null;const Je=await Le(I,$e,fe),nt={};if(Je?.right!=null&&(nt.right=Je.right),Je?.firstLine!=null&&(nt.firstLine=Je.firstLine),Je?.hanging!=null&&(nt.hanging=Je.hanging),W==="indent")return x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),left:Math.max(0,Je?.left??0)+vA,...nt}}:null;const Ge=Math.max(0,(Je?.left??0)-vA);return Ge>0&&(nt.left=Ge),Object.keys(nt).length===0?V?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:V,input:{target:bo($e,fe)}}:x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),left:0}}:null:x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),...nt}}:null};return Io=(async()=>{const $e=await Promise.all(b.map(Ge=>Me(Ge).catch(()=>null)));if($e.length===b.length&&$e.every(Ge=>Ge?.kind==="list")&&Qn()!=="suggesting"){const Ge=W==="indent"?"lists.indentRange":"lists.outdentRange",rt=vr(I,Ge);if(rt)try{return await Mt(mo(Ge,rt,{paraIds:b,story:re})).settled}catch{return!1}}const We=re.storyType!=="body"&&$e.some(Ge=>Ge?.kind==="list"),Je=We&&W==="outdent"?vr(I,"lists.outdentInStory"):null;if(We&&!Je)return!1;const nt=$e.map(Ge=>{if(!Ge)return Promise.resolve(!1);try{return Ge.kind==="list"&&Je?Mt(mo("lists.outdentInStory",Je,{target:Ge.input.target,story:re})).settled:Mt(mo(Ge.routeToCall,Ge.opToCall,Ge.input)).settled}catch{return Promise.resolve(!1)}});return ki(await Promise.all(nt))})(),!0},Aj=(d,p)=>{const b=d.list,I=y(),x=Nr(qe.selection);if(x.length===0)return!1;const V=es(qe.selection),W=V.storyType==="body";if(b.mode==="indent"||b.mode==="outdent")return _j(d,p,x);const re=b.seed,fe=We=>{if(We.some(dt=>!dt.resolved))return{immediate:!1,settled:null};const Je=We.every(dt=>dt.seed===re);if(!Je&&!W)return{immediate:!1,settled:null};const nt=Je?W?"lists.remove":"lists.removeInStory":d.docRoute,Ge=Je?vr(I,nt):p;if(!Ge)return{immediate:!1,settled:null};const rt=[],ht=[];return x.forEach((dt,it)=>{if(!Je&&We[it]?.seed===re)return;const zt=Je?{target:Ea(dt),...W?{}:{story:V}}:{target:Ea(dt),seed:re};try{const Vt=Mt(mo(nt,Ge,zt));rt.push(Vt.immediate),ht.push(Vt.settled)}catch{rt.push(!1),ht.push(Promise.resolve(!1))}}),{immediate:ki(rt),settled:ht.length?Promise.all(ht).then(dt=>ki(dt)):null}},Me=x.map(We=>Ae(I,We,V));if(Me.some(xr))return Io=Promise.all(Me).then(async We=>{const Je=fe(We);return Je.settled?await Je.settled:Je.immediate}),!0;const $e=fe(Me);return Io=$e.settled,$e.immediate};function Kf(d){return d&&typeof d=="object"?d:{}}function Ij(d){if(typeof d=="string")return d;const p=Kf(d);if(Object.prototype.hasOwnProperty.call(p,"href"))return p.href;if(Object.prototype.hasOwnProperty.call(p,"value"))return p.value}function xj(d,p){const b=Kf(d).text;return typeof b=="string"&&b.trim()!==""?b:p}function TA(d){const p=Kf(d),b=p.capture&&typeof p.capture=="object"?p.capture:null;return p.target??b?.target??b?.selectionTarget??p.selectionTarget??p.textTarget??null}const Ej=d=>{const p=y(),b=p?.hyperlinks;if(!b)return!1;const I=Kf(d),x=Ij(d),V=TA(d),W=typeof I.text=="string"?I.text:void 0,re=typeof I.currentText=="string"?I.currentText:void 0,fe=Ff(I.hyperlinkTarget)?I.hyperlinkTarget:null,Me=Ff(I.textTarget)?I.textTarget:null,$e=as(p,qe.selection),We=typeof fe?.storyId=="string"&&typeof fe?.hyperlinkNodeId=="string";if(We&&x===null){const Je=b.remove;if(typeof Je!="function")return!1;try{return mo("hyperlinks.remove",Je,{storyId:fe.storyId,hyperlinkNodeId:fe.hyperlinkNodeId,keepText:!0})}catch{return!1}}if($e&&x===null){const Je=b.remove;if(typeof Je!="function")return!1;try{return mo("hyperlinks.remove",Je,{target:$e.address,mode:"unwrap"})}catch{return!1}}if(($e||fe)&&typeof x=="string"&&x.trim()!==""){const Je=b.patch,nt=b.updateTarget;if(!(!We&&$e&&typeof Je=="function")&&!(We&&typeof nt=="function"))return!1;const Ge=typeof W=="string"&&W!==(We?re:$e?.text??re),rt=p?.text?.replace,ht=Ge?We?Me:AV($e?.address):null,dt=Ge&&!!ht&&typeof rt=="function";if(Ge&&!dt)return!1;const it=[],zt=[];let Vt=null,Hn=null,$n=null,Gr=!1;try{if(We){if(typeof nt!="function")return!1;const Wr=mo("hyperlinks.updateTarget",nt,{storyId:fe.storyId,hyperlinkNodeId:fe.hyperlinkNodeId,newTarget:IV(x)});Gr=xr(Wr);const Sr=Mt(Wr);if(!wo(Sr.immediate))return!1;it.push(Sr.immediate),zt.push(Sr.settled),Vt=Sr.immediate,Hn=Sr.committed,$n=Sr.settled}else if($e){if(typeof Je!="function")return!1;const Wr=mo("hyperlinks.patch",Je,{target:$e.address,patch:{href:x}});Gr=xr(Wr);const Sr=Mt(Wr);if(!wo(Sr.immediate))return!1;it.push(Sr.immediate),zt.push(Sr.settled),Vt=Sr.immediate,Hn=Sr.committed,$n=Sr.settled}}catch{return!1}if(dt){const Wr=(Mr,Yo)=>wo(Yo)?ki([Mr,Yo]):wo(Mr)?Rf(Mr,Yo):Yo,Sr=Mr=>{if(!wo(Mr))return Mr;try{const Yo=Mt(mo("text.replace",rt,{target:ht,text:W}));return wo(Yo.immediate)?Promise.all([$n??Promise.resolve(Mr),Yo.settled]).then(([_2,fU])=>Wr(_2,fU)):Rf(Mr,Yo.immediate)}catch{return Rf(Mr,!1)}};if(Gr)return Io=(Hn??Promise.resolve(Vt??!1)).then(Sr),ki(it);try{const Mr=Mt(mo("text.replace",rt,{target:ht,text:W}));if(!wo(Mr.immediate))return Vt?Rf(Vt,Mr.immediate):Mr.immediate;it.push(Mr.immediate),zt.push(Mr.settled),Io=Promise.all([$n??Promise.resolve(Vt??!1),Mr.settled]).then(([Yo,_2])=>Wr(Yo,_2))}catch{return Vt?Rf(Vt,!1):!1}}return!dt&&zt.length>0&&(Io=Promise.all(zt).then(Wr=>ki(Wr))),ki(it)}if(typeof x=="string"&&x.trim()!==""){const Je=x.trim(),nt=b.wrap,Ge=mV(V),rt=Ge.length>0?Ge:r2(qe.selection);if(rt.length>0){if(typeof nt!="function")return!1;try{return bj("hyperlinks.wrap",nt,rt,zt=>({target:zt,link:{destination:{href:Je}}}))}catch{return!1}}const ht=b.insert,dt=xj(d,Je);if(typeof ht!="function"||dt.trim()==="")return!1;const it=Pf(V)??hl(qe.selection);if(!it)return!1;try{return mo("hyperlinks.insert",ht,{target:it,text:dt,link:{destination:{href:Je}}})}catch{return!1}}return!1},Tj=(d,p,b)=>{const I=d.create.kind,x=b&&typeof b=="object"?b:{};if(I==="table"){const W=Number(x.rows??x.rowCount),re=Number(x.columns??x.cols??x.colCount);if(!Number.isInteger(W)||W<1||!Number.isInteger(re)||re<1)return!1;const fe=hl(qe.selection),Me=fe&&typeof fe.blockId=="string"?{kind:"inParagraph",target:bo(fe.blockId),offset:fe.range?.start??0}:s2(qe.selection,"nodeId");try{return mo(d.docRoute,p,{rows:W,columns:re,at:Me})}catch{return!1}}if(I==="image"){const W=x.src??x.value;if(typeof W!="string"||W.trim()==="")return!1;const re=hl(qe.selection),fe=es(qe.selection),Me=fe.storyType==="body"?null:fe;let $e;re&&typeof re.blockId=="string"?$e={kind:"inParagraph",target:bo(re.blockId,Me),offset:re.range?.start??0}:($e=s2(qe.selection,"target"),Me&&$e.kind==="after"&&($e={...$e,target:{...$e.target,story:Me}}));const We={src:W,at:$e};Me&&(We.in=$e.kind==="inParagraph"?B(Me)??Me:Me),typeof x.alt=="string"&&(We.alt=x.alt),typeof x.title=="string"&&(We.title=x.title),x.size&&typeof x.size=="object"&&(We.size=x.size);try{return mo(d.docRoute,p,We)}catch{return!1}}const V={at:s2(qe.selection,"target")};typeof x.instruction=="string"&&(V.instruction=x.instruction),x.config&&typeof x.config=="object"&&(V.config=x.config);try{return mo(d.docRoute,p,V)}catch{return!1}},Rj=(d,p)=>{const b=d.table,I=_e();if(!I||b.requiresCell&&!I.cellNodeId)return!1;const x=DV(b.action,I);if(!x)return!1;try{if(b.action==="insert-row-before"||b.action==="insert-row-after"){const V=M(),W=(typeof V?.getHandles=="function"?V.getHandles():null)?.editing?.tables;if(typeof W?.insertRow!="function")return!1;const re=Ui(d.docRoute);return re&&re.success===!1?re:re?W.insertRow(x,re):W.insertRow(x)}return mo(d.docRoute,p,x)}catch{return!1}},Lj=d=>!d||d.disposition!=="routed"?!1:!!(d.inline||d.blockParagraph||d.list||d.link||d.create),Mj=d=>{const p=Kf(d);return!!(TA(d)||Ff(p.hyperlinkTarget)||Ff(p.textTarget))},Pj=(d,p,b)=>qe.selection.status!=="ready"?!1:mm(d)?.scope==="id"||!p||p.disposition!=="routed"?!0:p.inline?.kind==="clear"?Nr(qe.selection).length>0||Su(qe.selection)!=null:p.inline?Su(qe.selection)!=null||Nr(qe.selection).length>0:p.blockParagraph||p.list?Nr(qe.selection).length>0:p.link?Mj(b)||r2(qe.selection).length>0||hl(qe.selection)!=null||Ks(p,y(),qe.selection):!0,Dj=(d,p)=>{const b=mm(d),I=vu(d);return b?.scope!=="id"&&!Lj(I)?!1:!Pj(d,I,p)},Oj=(d,p)=>Dj(d,p)?$s().then(()=>{}):null,bc=(d,p,b)=>{if(Io=null,hi=Promise.resolve(!1),U)return!1;const I=oe.get(d);if(I)try{const We=I.execute(lc(p,b));return xo(We)}catch{return!1}const x=cA(d);if(x&&typeof se()?.lists?.apply=="function")return _m(x,p);const V=mm(d);if(V)return h2(V,p);if(d==="copy-format")return xo(Fj());const W=vu(d);if(!W||W.disposition!=="routed")return!1;const re=W.normalizePayload?W.normalizePayload(p):p;if(W.instanceRoute){if(!_()||!Xt(W,re))return!1;const We=t?.[W.instanceRoute];if(typeof We!="function")return!1;try{const Je=W.fixedArg!==void 0?W.fixedArg:re,nt=We.call(t,Je);return xo(nt)}catch{return!1}}if(W.inline?.kind==="clear")return W.mutates&&Qn()==="viewing"?!1:xo(kj());const fe=W.docRoute;if(!fe||W.mutates&&Qn()==="viewing")return!1;const Me=y(),$e=vr(Me,fe);if(!$e)return!1;if(W.inline){const{lockModesById:We}=ss(Me?.contentControls,qe.selection);if(ci(We))return!1;const Je=Su(qe.selection);if(!Je)return qe.selection.empty===!1?xo(!1):xo(Cj(W,re));const nt=Ks(W,Me,qe.selection),Ge=MV(W.inline,Je,re,nt);if(!Ge)return!1;let rt=null;try{const ht=_(),dt=Qn(),it=()=>_()!==ht||y()!==Me||Qn()!==dt?!1:p2(fe,$e,Ge),zt=Ta(qe.selection)??nc(qe.selection),Vt=W.inline.kind==="toggle"?$r(`${W.id}:${zt}`,it):null;rt=Vt?.release??null;const Hn=Vt?Vt.result:it(),$n=mj(W,qe.selection,Ge,Hn),Gr=pj(W,qe.selection,Ge,Hn),Wr=xo(Gr,Sr=>{gj(W,$n,Sr),rt?.(),rt=null});return W.inline.kind==="toggle"&&(Ku=hi),Wr}catch{return rt?.(),!1}}if(W.blockParagraph){const We=Sj(W,$e,re),Je=W.blockParagraph.kind==="alignment"&&wo(We)?le(qe.selection,re):null;return xo(We,nt=>{de(Je,nt)})}if(W.list){const We=Aj(W,$e);return xo(We)}if(W.link){const We=Ej(re);return xo(We)}if(W.create){const We=Tj(W,$e,re);return xo(We)}if(W.table){const We=Rj(W,$e);return xo(We)}try{return xo(W.mutates?mo(fe,$e,re):$e(re))}catch{return!1}},Im=()=>{g+=1,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:h.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const d of m)d("idle");bt()},Fj=async()=>{const d=["bold","italic","underline","strikethrough"].filter($e=>qe.toolbar.commands[$e]?.active===!0),p=await Ku;await u;const b=wo(p)?d:[],I=500,x=Date.now();if(h.mode!=="idle"){if(h.mode==="armed"&&x-h.lastClickAt<I){h={...h,mode:"persistent",lastClickAt:x};for(const $e of m)$e("persistent");return bt(),!0}return Im(),!1}const V=x-h.lastClickAt<I,W=++g;h={...h,lastClickAt:x};const re=await $s(),fe=`${nc(re)}:${ln()}`,Me=await Nj(null,re,fe&&fe===k?v:void 0,b);if(W!==g)return!0;h={...h,mode:V?"persistent":"armed",snapshot:Me,sourceSelectionKey:nc(re),lastClickAt:x};for(const $e of m)$e(h.mode);return bt(),!0},Nj=async(d,p,b,I=[])=>{const x=p?.target??d?.target;if(!x||x.kind!=="text")return null;const V=Array.isArray(x.segments)?x.segments:[];if(V.length===0)return null;const W=y();if(!W)return null;const re=x.story;let fe=null;for(const Ge of V){const rt=(await Sl(bo(Ge.blockId,re)))?.node??null;if(!rt)continue;const ht=m2(rt),dt=Array.isArray(ht?.inlines)?ht.inlines:[],it=Bj(dt,Ge.range);fe?fe=RA(fe,it):fe=it}const Me=fe?Pz(fe):{},$e={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},We=new Set([...p?.activeMarks??(Array.isArray(d?.activeMarks)?d.activeMarks:[]),...I]);for(const[Ge,rt]of Object.entries($e))We.has(Ge)&&(Me[rt]=!0);const Je=b??await $f(p??Hs(d,"ready"));if(Je.fontFamily&&(Me.fontFamily=Je.fontFamily),Je.color&&(Me.color=Je.color),Je.highlight&&(Me.highlight=Je.highlight),Je.fontSize){const Ge=Number.parseFloat(Je.fontSize);Number.isNaN(Ge)||(Me.fontSize=Ge)}let nt=null;if(V.length===1){const Ge=V[0],rt=(await Sl(bo(Ge.blockId,re)))?.node??null;rt&&m2(rt)&&(nt=await zj(rt,Ge.blockId,W,re))}return{story:re??null,inline:Me,paragraph:nt}},m2=d=>d?d.kind==="paragraph"?d.paragraph??null:d.kind==="heading"?d.heading??null:null:null,Bj=(d,p)=>{const b=W=>{const re=W.run;return typeof re?.text=="string"?re.text:""},I=W=>W.run?.props;if(p.start===p.end){let W=0;for(const re of d){const fe=b(re),Me=W,$e=W+fe.length;if(W=$e,p.start>=Me&&p.start<=$e){const We=I(re);return We?{...We}:{}}}return{}}let x=0;const V=[];for(const W of d){const re=b(W),fe=x,Me=x+re.length;if(x=Me,Me<=p.start||fe>=p.end)continue;const $e=I(W);$e&&V.push($e)}return V.length===0?{}:V.length===1?{...V[0]}:RA(V[0],...V.slice(1))},RA=(d,...p)=>{const b={...d};for(const I of p)for(const x of Object.keys(b)){if(!(x in I)){delete b[x];continue}const V=b[x],W=I[x];(typeof V!=typeof W||JSON.stringify(V)!==JSON.stringify(W))&&delete b[x]}return b},zj=async(d,p,b,I)=>{const x=m2(d),V=x.props??{},W=x.styleRef??null,re=V.alignment??null,fe=V.spacing??null,Me=V.indent??null,$e=Me?{...Me.left!=null?{left:Me.left}:{},...Me.right!=null?{right:Me.right}:{},...Me.firstLine!=null?{firstLine:Me.firstLine}:{},...Me.hanging!=null?{hanging:Me.hanging}:{}}:null,We=V.markRunProps??null,Je=V.numbering?.numId,nt=typeof Je=="string"?parseInt(Je,10):typeof Je=="number"?Je:NaN,Ge=V.numbering?.level,rt=isNaN(nt)?null:{numId:nt,...Ge!=null?{level:Ge}:{}};let ht=null;if(rt&&typeof b.lists?.getState=="function")try{const dt=await b.lists.getState({target:bo(p,I)});dt&&typeof b.lists?.getStyle=="function"&&(ht=await b.lists.getStyle(dt)??null)}catch{}return{styleId:W,alignment:re,spacing:fe,indentation:$e,markRunProps:We,numbering:rt,listStyle:ht}},LA=async()=>{if(h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;const d=y()?.selection,p=async()=>{const W=typeof d?.current=="function"?await Promise.resolve(d.current({includeText:!0})):Ra().value;return Ni(W)},b=()=>new Promise(W=>setTimeout(W,16)),I=8;let x=null,V="";for(let W=0;W<I;W+=1){if(W>0&&await b(),h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;if(x=await p(),!(!x||x.empty)&&(V=nc(x),V!==h.sourceSelectionKey))break}if(x&&!x.empty&&V!==h.sourceSelectionKey){await MA(x);return}if(h.snapshot?.paragraph){const W=await p();if(!W||nc(W)===h.sourceSelectionKey)return;await MA(W)}},MA=async d=>{const p=h.snapshot;if(!p){h.mode==="armed"&&Im();return}const b=y();if(!b)return;const I=Hs(d,"ready"),{lockModesById:x}=ss(b.contentControls,I);if(ci(x)){bt();return}const V=d.target,W=d.selectionTarget;if(d.empty!==!0&&Object.keys(p.inline).length>0){const re=vr(b,"format.apply");if(re&&W)try{if(!wo(Ns(await Promise.resolve(p2("format.apply",re,{target:W,inline:p.inline},d))))){bt();return}}catch{bt();return}}if(p.paragraph){const re=Array.isArray(V?.segments)?V.segments:[],fe=V?.story;for(const Me of re){const $e=bo(Me.blockId,fe),We=await Sl($e),Je=We?.node??null,nt=We?.address??null;if(!Je)continue;const Ge={kind:"block",nodeType:nt?.nodeType??Je.kind??"paragraph",nodeId:Me.blockId,...fe&&typeof fe=="object"?{story:fe}:{}},{styleId:rt,alignment:ht,spacing:dt,indentation:it,markRunProps:zt,numbering:Vt,listStyle:Hn}=p.paragraph;if(rt&&await b.styles?.paragraph?.setStyle?.({target:Ge,styleId:rt}),ht&&await b.format?.paragraph?.setAlignment?.({target:Ge,alignment:ht}),dt){const $n=dt,Gr=$n.lineRule??"auto",Wr=new Set(["auto","exact","atLeast"]).has(Gr)?Gr:"auto",Sr={...$n.before!=null?{before:Math.round($n.before*20)}:{},...$n.after!=null?{after:Math.round($n.after*20)}:{},...$n.line!=null?{line:Math.round(Wr==="auto"?$n.line*240:$n.line*20),lineRule:Wr}:{}};await b.format?.paragraph?.setSpacing?.({target:Ge,...Sr})}if(it){const $n={...it.left!=null?{left:Fs(it.left)}:{},...it.right!=null?{right:Fs(it.right)}:{},...it.firstLine!=null?{firstLine:Fs(it.firstLine)}:{},...it.hanging!=null?{hanging:Fs(it.hanging)}:{}};await b.format?.paragraph?.setIndentation?.({target:Ge,...$n})}zt&&await b.format?.paragraph?.setMarkRunProps?.({target:Ge,markRunProps:zt}),Vt&&await b.format?.paragraph?.setNumbering?.({target:Ge,...Vt}),Hn&&((await Sl($e))?.address?.nodeType==="listItem"?await b.lists?.applyStyle?.({target:gA(Me.blockId,fe),style:Hn}):Vt&&await b.format?.paragraph?.setNumbering?.({target:Ge,...Vt}))}}h.mode==="armed"&&Im(),bt()},xm=(d,p,b)=>{const I=Oj(d,p),x=I?I.then(()=>(bc(d,p,b),hi)):(bc(d,p,b),hi);return vu(d)?.inline?.kind==="toggle"&&(Ku=x),x},PA=d=>({id:d,getState:()=>qe.toolbar.commands[d]??Uu(d,y(),qe.selection,Vi(qe.selection)),observe:p=>Wo(b=>b.toolbar.commands[d]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:ct.commandUnsupported}).subscribe(p),execute:p=>bc(d,p),executeAsync:p=>xm(d,p)}),Vj=d=>{oe.set(d.id,d),bt();const p=()=>{oe.delete(d.id),bt()};return Object.assign(p,{handle:PA(d.id),unregister:p})},Em=Ko(d=>d.selection),Tm=qo(Em),DA=()=>{const d=M();if(typeof d?.getHandles!="function")return{reason:ct.hostCapabilityUnavailable};let p=null;try{p=d.getHandles()}catch(I){const x=I?.reason;return{reason:x==="host-not-ready"||x==="host-disposed"||x==="editing-mount-required"?ct.notReady:ct.hostCapabilityUnavailable}}const b=p?.editing?.selectionTargets;return typeof b?.apply!="function"?{reason:ct.hostCapabilityUnavailable}:{helper:b}},jj=d=>{const p=M();if(typeof p?.getHandles=="function")try{const b=p.getHandles()?.editing?.contentControls;typeof b?.activate=="function"&&b.activate({id:d})}catch{}},OA={get:Tm.get,getSnapshot:Tm.getSnapshot,subscribe:Tm.subscribe,observe:Tm.observe,current:()=>Ra().value,capture:()=>{const d=Em.get();return d.empty||!d.target&&!d.selectionTarget?null:{...d,capturedAt:Date.now()}},restore:d=>{const p=x=>(bt(),{...x,success:x.ok});if(!d||typeof d!="object")return p({ok:!1,reason:ct.targetUnresolved});if(!_())return p({ok:!1,reason:ct.notReady});const b=RV(d);if(!b)return p({ok:!1,reason:ct.targetUnresolved});const I=DA();if(!("helper"in I))return p({ok:!1,reason:I.reason});try{return p(lA(I.helper.apply(b)))}catch{return p({ok:!1,reason:ct.hostCapabilityUnavailable})}},apply:d=>{if(!_())return{ok:!1,reason:ct.notReady};const p=DA();if(!("helper"in p))return{ok:!1,reason:p.reason};try{const b=p.helper.apply(d);return bt(),lA(b)}catch{return{ok:!1,reason:ct.hostCapabilityUnavailable}}},getAnchorRect:d=>{const p=M();if(typeof p?.getSelectionAnchorRect=="function"){const b=Pt(()=>p.getSelectionAnchorRect(d),null);return b&&typeof b=="object"&&(Number(b.width)>0||Number(b.height)>0)?b:null}return null},getRects:d=>{const p=Em.get(),b=p.selectionTarget??p.target;if(p.empty||!b)return[];const I=Bm.getRect({target:b,relativeTo:d?.relativeTo});return I.found?I.rects:[]}},Uj={get ids(){return kn()},has:d=>vu(d)!=null||oe.has(d),get:d=>PA(d),execute:bc,executeAsync:xm,register:Vj,getContextMenuItems:d=>{const p=[];for(const b of oe.values()){const I=b.contextMenu;I&&Pt(I.when?()=>I.when(d):void 0,!0)&&p.push({id:b.id,label:I.label,group:I.group,order:I.order,invoke:()=>bc(b.id,void 0,d)})}return p.sort((b,I)=>(b.order??0)-(I.order??0)||b.label.localeCompare(I.label))}},g2=qo(Ko(d=>d.toolbar)),Hj={get:g2.get,getSnapshot:()=>qe.toolbar,subscribe:g2.subscribe,observe:g2.observe,execute:bc,executeAsync:xm},wc=async(d,p)=>{if(!_())return{success:!1,ok:!1,reason:ct.notReady};if(!d)return{success:!1,ok:!1,reason:ct.targetUnresolved};const b=M(),I=b?.scrollTargetIntoView;if(typeof I!="function")return{success:!1,ok:!1,reason:ct.hostCapabilityUnavailable};try{const x={target:d,block:p?.block??"center",behavior:p?.behavior??"smooth"},V=await Promise.resolve(p?.shouldContinue?I.call(b,x,p.shouldContinue):I.call(b,x));return V&&typeof V=="object"&&V.success===!1?{success:!1,ok:!1,reason:e2(V.reason,ct.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:ct.hostCapabilityUnavailable}}},Rm=async(d,p,b,I)=>{const x=d==="trackChanges"?I?.story:void 0,V=dt=>{if(!x||!dt||typeof dt!="object")return dt;const it=dt,zt=it.address&&typeof it.address=="object"?it.address:null;return it.story||zt?.story?dt:{...it,story:x}},W=d==="trackChanges"?dA:Lf,re=b.find(dt=>Ji(dt,p,x)),fe=re&&typeof re=="object"?re:null,Me=d==="trackChanges"&&fe?.type==="move"&&(fe.subtype==="move-to"||fe.subtype==="move-from")?fe.subtype:null,$e=Me&&typeof fe?.trackedChangeCanonicalId=="string"?fe.trackedChangeCanonicalId:p,We=dt=>{if(!Me)return d==="trackChanges"?dA(dt,{preferStableBlock:!0}):W(dt);const it=Lf(dt);if(it?.kind!=="move")return null;const zt=Me==="move-to"?it.destination:it.source;return t2(zt)?zt:null},Je=W(re),nt=d!=="trackChanges"||!Me&&t2(Lf(re));if(Je&&nt)return V(Je);const Ge=y()?.[d],rt=d==="comments"?{commentId:p}:{id:$e,...x?{story:x}:{}},ht=Ge?.get;if(typeof ht!="function")return V(Je);try{return V(We(await Promise.resolve(ht.call(Ge,rt)))??Je)}catch{return V(Je)}};function FA(d,p){if(Ao())return Yn("Comments are read-only.","DOCUMENT_READONLY");if(Bf())return Yn("Resolving comments is disabled.","DOCUMENT_READONLY");const b=y()?.comments,I=b?.patch;if(typeof I!="function")return Yn("comments.patch is unavailable.");const x=Yn("comments.patch failed.");return Pt(()=>xl(I.call(b,{commentId:d,status:p}),x),x)}const qf=()=>Ao()?Yn("Comments are read-only.","DOCUMENT_READONLY"):null,$j=(d,p)=>{const b=p&&typeof p=="object"?p:null;let I=Array.from(d);b?.includeResolved===!1&&(I=I.filter(fe=>fe.status!=="resolved"));const x=Number(b?.offset),V=Number.isInteger(x)&&x>0?x:0,W=Number(b?.limit),re=Number.isInteger(W)&&W>=0?V+W:void 0;return I.slice(V,re)},Yu=Ko(d=>d.comments),Lm=Gu(Yu,Wo(d=>fc(d.selection,d.comments)),"comments"),Gj={get:Lm.get,getSnapshot:Lm.getSnapshot,subscribe:Lm.subscribe,observe:Lm.observe,list:d=>{ze();const p=is();return $j(p.value??Yu.get().items,d)},getById:d=>{const p=Yu.get().items.find(x=>lo(x)===d)??null;if(p)return p;const b=y()?.comments,I=Pt(b?.get?()=>b.get({commentId:d}):void 0,null);return xr(I)?null:I},createFromCapture:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.create;if(typeof x!="function")return Yn("comments.create is unavailable.");const V=Yn("comments.create failed.");return Pt(()=>{const W=d&&typeof d=="object"?d.target??d.selectionTarget:null;return W==null?Yn("A range selection is required to comment.","NO_SELECTION"):xl(x.call(I,{target:W,text:p.text}),V)},V)},createFromSelection:d=>{const p=qf();if(p)return p;const b=y()?.comments,I=b?.create;if(typeof I!="function")return Yn("comments.create is unavailable.");const x=Em.get(),V=x.target??x.selectionTarget;if(x.empty||!V)return Yn("A range selection is required to comment.","NO_SELECTION");const W=Yn("comments.create failed.");return Pt(()=>xl(I.call(b,{target:V,text:d.text}),W),W)},reply:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.reply??I?.create;if(typeof x!="function")return Yn("comments.reply is unavailable.");const V=Yn("comments.reply failed.");return Pt(()=>xl(x===I?.reply?x.call(I,{parentCommentId:d,text:p.text}):x.call(I,{parentCommentId:d,text:p.text}),V),V)},edit:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.patch;if(typeof x!="function")return Yn("comments.patch is unavailable.");const V=Yn("comments.patch failed.");return Pt(()=>xl(x.call(I,{commentId:d,text:p.text}),V),V)},resolve:d=>FA(d,"resolved"),reopen:d=>FA(d,"active"),delete:d=>{const p=qf();if(p)return p;const b=y()?.comments,I=b?.delete??b?.remove;if(typeof I!="function")return Yn("comments.delete is unavailable.");const x=Yn("comments.delete failed.");return Pt(()=>xl(I.call(b,{commentId:d}),x),x)},setActive:d=>{if(d==null)return Re=null,bt(),!0;if(!_())return!1;const p=Yu.get(),b=z.get("comments"),I=b?.token===ln()&&b.hasSettled&&Array.isArray(b.value)?b.value:null,x=I??p.items;if(!I&&p.listStatus!=="ready")return!1;const V=dV(x,d);return!V||!x.some(W=>lo(W)===V)?!1:(Re=V,bt(),!0)},scrollTo:async d=>{if(!y())return{success:!1,ok:!1,reason:_()?ct.documentApiUnavailable:ct.notReady};const p=await Rm("comments",d,Yu.get().items);return p?wc(p):{success:!1,ok:!1,reason:ct.targetUnresolved}}},Oa=Ko(d=>d.trackChanges),v2=(d,p)=>{we();const b=(Ma().value??Oa.get().items).map(Of).filter(We=>We!=null&&lo(We)!==null);if(b.length===0)return null;const I=qe.trackChanges.activeId,x=je?.id===I?je.story:void 0,V=b.filter(We=>um(We)==null),W=x||V.length===0?b:V;let re=I?W.findIndex(We=>Ji(We,I,x)):-1;re===-1&&I&&x&&(re=W.findIndex(We=>Ji(We,I)));const fe=W[re===-1?d>0?0:W.length-1:(re+d+W.length)%W.length],Me=lo(fe),$e=um(fe);return ne($e?{id:Me,story:$e}:{id:Me},p),bt(),Me},NA=async d=>{const p=w(),b=p?.listTrackedChanges;if(typeof b=="function")try{await Promise.resolve(b.call(p,{mode:"visible-window",targetIds:[d],refreshReason:"ui-track-change-reveal-restamp",blocking:!0}))}catch{}};let BA=Promise.resolve();const Wj=d=>{const p=St;return BA.catch(()=>{}).then(()=>Kj(d,p))},Kj=async(d,p)=>{if(St!==p)return{success:!1};const b=je,I=v2(d,{invalidateQueuedNavigation:!1});if(I==null)return{success:!1};const x=je,V=et,W=()=>St===p&&je===x&&et===V,re=()=>{W()&&(ne(b,{invalidateQueuedNavigation:!1}),bt())};x&&He.add(x);try{const fe=await Rm("trackChanges",I,Oa.get().items,x?.story?{story:x.story}:void 0);if(!W())return{success:!1};if(!fe)return re(),{success:!1};$t+=1;try{const Me=await wc(fe,{behavior:"auto",shouldContinue:W});if(!W())return{success:!1};if(!Me.ok&&Me.reason!==ct.targetNotVisible)re(),S(b);else{if(Me.ok&&await NA(I),!W())return{success:!1};S(x)}return{success:Me.ok}}finally{$t=Math.max(0,$t-1),$t===0&&(W()?Fo&&Sn(mt(Fo)):S(je))}}finally{x&&He.delete(x)}},zA=d=>{const p=Wj(d);return BA=p.then(()=>{},()=>{}),p},Mm=Gu(Oa,Wo(d=>Tu(d.selection,d.trackChanges)),"trackChanges"),qj={get:Mm.get,getSnapshot:Mm.getSnapshot,subscribe:Mm.subscribe,observe:Mm.observe,list:()=>{we();const d=Ma().value??Oa.get().items,p=Dt(ln());return d.map(Of).filter(b=>b!=null).filter(b=>{const I=lo(b);return!I||!p?.has(I)})},accept:d=>y2("accept",d),reject:d=>y2("reject",d),acceptAll:()=>Yf("accept",{kind:"all"},null),rejectAll:()=>Yf("reject",{kind:"all"},null),next:()=>v2(1),previous:()=>v2(-1),navigateNext:()=>zA(1),navigatePrevious:()=>zA(-1),getAt:d=>{if(!d||typeof d!="object"||typeof d.x!="number"||typeof d.y!="number")return null;const p=C2(d);if(p.length===0)return null;const b=Oa.get().items;let I;for(const x of p){if(x.type!=="trackedChange")continue;let V;if(x.story){if(I===void 0&&(I=Bi()),!I)continue;V=I}else V=b;const W=V.find(re=>Ji(re,x.id,x.story));if(W)return x.story?{id:W.id,item:W,story:x.story}:{id:W.id,item:W}}return null},setActive:d=>{if(d==null)return ne(null),S(null),bt(),!0;if(!_())return!1;const p=typeof d=="string"?{id:d}:{id:d.id,story:d.story};if(typeof p.id!="string"||p.id.length===0)return!1;const b=p.id;if(p.story){const I=Bi();if(!I)return!1;const x=oc(I,p.story).toPublicId(p.id)??p.id;if(!I.some(V=>Ji(V,x,p.story)))return!1;p.id=x}else{const I=Bi()??Oa.get().items,x=Os(I).toPublicId(p.id)??p.id,V=I.find(W=>lo(W)===x);if(!V)return!1;p.id=x,p.story=um(V)}return b!==p.id&&(p.paintedEntityId=b),ne(p),S(p),bt(),!0},scrollTo:async d=>{if(!y())return{success:!1,ok:!1,reason:_()?ct.documentApiUnavailable:ct.notReady};St+=1,Te+=1;const p=Te,b=Oa.get().items,I=Os(b).toPublicId(d)??d,x=um(b.find(re=>lo(re)===I)),V=je,W={id:I,...x?{story:x}:{},...I!==d?{paintedEntityId:d}:{}};He.add(W);try{const re=await Rm("trackChanges",I,b,x?{story:x}:void 0);if(Te!==p)return{success:!1,ok:!1};if(!re)return{success:!1,ok:!1,reason:ct.targetUnresolved};ne(W);const fe=Te,Me=je,$e=et,We=()=>Te===fe&&je===Me&&et===$e,Je=()=>{We()&&(ne(V,{invalidateQueuedNavigation:!1}),bt())};bt(),$t+=1;try{const nt=await wc(re,{behavior:"auto",shouldContinue:We});if(!We())return{success:!1,ok:!1};if(!nt.ok&&nt.reason!==ct.targetNotVisible)Je(),S(V);else{if(nt.ok&&await NA(I),!We())return{success:!1,ok:!1};S(W)}return nt}finally{$t=Math.max(0,$t-1),$t===0&&(We()?Fo&&Sn(mt(Fo)):S(je))}}finally{He.delete(W)}}},y2=(d,p)=>{const{id:b,story:I}=typeof p=="string"?{id:p,story:void 0}:p,x={kind:"id",id:b,...I?{story:I}:{}};return Yf(d,x,b,I)},Yf=(d,p,b,I)=>{try{return xo(b2(d,p,b,I))}catch{return!1}},b2=(d,p,b,I)=>{if(Ao())return!1;const x=y()?.trackChanges,V=p.kind==="all"||p.scope==="all",W=p.kind==="range",re=p.kind==="ids";if(ju({kind:d,scope:V?"all":"id"},x))return!1;const fe=V?`${d}All`:d,Me=!W&&!re&&!I&&x&&typeof x[fe]=="function"?x[fe]:null,$e=x&&typeof x.decide=="function"?x.decide:null;return!Me&&!$e?!1:Me?Me.call(x,b??{}):$e.call(x,{decision:d,target:p})},w2=Ko(d=>d.contentControls),Xf=d=>w2.get().items.find(p=>p?.id===d)??null,Pm=qo(w2),Yj=(d=>{if(d===void 0)return Pm.get();const p=dm(d);return p?Xf(p):null}),Xj={get:(d=>(d!==void 0&&ii("api"),Yj(d))),getSnapshot:Pm.getSnapshot,subscribe:Pm.subscribe,observe:Pm.observe,list:()=>(ii("api"),w2.get().items),getById:d=>(ii("api"),Xf(d)),getRect:d=>{const p=dm(d);if(!p)return pl("unresolved");ii("panel");const b=Xf(p);if(!b)return pl("unresolved");const I=n2(b);return I?Bm.getRect({target:I}):pl("unavailable")},scrollIntoView:async d=>{const p=dm(d);if(!p)return{success:!1};ii("panel");const b=Xf(p);if(!b)return{success:!1};const I=n2(b);return I?{success:(await wc(I,{block:d.block,behavior:d.behavior})).ok}:{success:!1}},focus:async d=>{const p=dm(d);if(!p)return{success:!1,reason:"invalid-id"};if(!_())return{success:!1,reason:"not-ready"};ii("panel");const b=Xf(p);if(!b)return{success:!1,reason:"not-found"};const I=n2(b);if(!I)return{success:!1,reason:"not-reachable"};if(!(await wc(I,{block:d.block,behavior:d.behavior})).ok)return{success:!1,reason:"not-reachable"};const x=iV(I);if(!x)return{success:!1,reason:"not-reachable"};const V=OA.apply(x);return!V.ok&&V.reason!==ct.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:(jj(p),{success:!0})}},Dm=qo(Ko(d=>d.fonts)),Zj={get:Dm.get,getSnapshot:Dm.getSnapshot,subscribe:Dm.subscribe,observe:Dm.observe,getFamilyOptions:()=>qe.fonts.options,getSizeOptions:()=>qe.fonts.sizeOptions},Om=qo(Ko(d=>d.zoom)),Qj={get:Om.get,getSnapshot:Om.getSnapshot,subscribe:Om.subscribe,observe:Om.observe,set:d=>{if(typeof t?.setZoom=="function")try{t.setZoom(d),bt()}catch{}},setMode:d=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(d),bt()}catch{}}},Fm=qo(Ko(d=>d.document)),Jj={get:Fm.get,getSnapshot:Fm.getSnapshot,subscribe:Fm.subscribe,observe:Fm.observe,setMode:d=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(d),bt()}catch{}},export:d=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(d))}catch{return}},getText:()=>{const d=y(),p=Pt(d?.getText?()=>d.getText({}):void 0,null);return typeof p=="string"?p:p&&typeof p=="object"&&typeof p.text=="string"?p.text:null},replaceFile:d=>{const p=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof p=="function")try{return Promise.resolve(p.call(t,d))}catch{return}}},VA=()=>{if(typeof HTMLElement>"u")return null;const d=_()?.mount?.container;if(d instanceof HTMLElement)return d;const p=t?.element;return p instanceof HTMLElement?p:null},eU=(d,p)=>{if(typeof d!="number"||typeof p!="number"||!Number.isFinite(d)||!Number.isFinite(p))return[];const b=globalThis.document;if(!b||typeof b.elementFromPoint!="function")return[];const I=VA();if(!I)return[];const x=b.elementFromPoint(d,p);if(!x||!I.contains(x))return[];const V=[x],W=it=>{it&&I.contains(it)&&!V.includes(it)&&V.push(it)},re=b.elementsFromPoint;if(typeof re=="function"){let it=[];try{it=re.call(b,d,p)??[]}catch{it=[]}for(const zt of it)W(zt)}const fe=[],Me=it=>{it&&I.contains(it)&&!fe.includes(it)&&!V.includes(it)&&fe.push(it)},$e=it=>{const zt=it.getBoundingClientRect;if(typeof zt!="function")return!1;let Vt;try{Vt=zt.call(it)}catch{return!1}return Vt!=null&&d>=Vt.left&&d<=Vt.right&&p>=Vt.top&&p<=Vt.bottom};for(const it of V){const zt=it.querySelectorAll;if(typeof zt!="function")continue;let Vt;try{Vt=zt.call(it,"[data-track-change-marker]")}catch{continue}for(let Hn=0;Hn<Vt.length;Hn+=1)$e(Vt[Hn])&&Me(Vt[Hn])}fe.reverse();const We=[...fe,...V],Je=aA(We[0],I);for(let it=1;it<We.length;it+=1)for(const zt of aA(We[it],I))Je.push(zt);if(Je.length===0)return Je;const nt=Oa.get().items,Ge=Os(nt);let rt;const ht=new Set,dt=[];for(const it of Je){if(it.type!=="trackedChange"){const $n=`${it.type}:${it.id}`;if(ht.has($n))continue;ht.add($n),dt.push(it);continue}const zt=oV(it.storyKey)??rV(it.story);let Vt;if(zt){if(rt===void 0&&(rt=Bi()),!rt||(Vt=oc(rt,zt).toPublicId(it.id),!Vt||!rt.some($n=>Ji($n,Vt,zt))))continue}else if(Vt=Ge.toPublicId(it.id),!Vt)continue;const Hn=`trackedChange:${Vt}`;ht.has(Hn)||(ht.add(Hn),dt.push(zt?{type:"trackedChange",id:Vt,story:zt}:{type:"trackedChange",id:Vt}))}return dt};function C2(d,p){return typeof d=="object"?eU(d?.x,d?.y):null}const Xu=new Set;let k2=!1;const jA=d=>{const p=M();if(typeof p?.observeGeometry!="function")return;let b=!1;const I=Pt(()=>{const x=p.observeGeometry(()=>d.schedule());return b=!0,x},null);d.detach=typeof I=="function"?I:null,d.boundHost=b?p:null},Nm=d=>{if(d.detach){try{d.detach()}catch{}d.detach=null}d.boundHost=null},UA=()=>{if(k2=!1,!(U||M()))for(const d of Xu)Nm(d)},tU=()=>{if(!k2){if(k2=!0,typeof queueMicrotask=="function"){queueMicrotask(UA);return}Promise.resolve().then(UA)}},nU=()=>{const d=M();if(!d){tU();return}for(const p of Xu)p.boundHost&&p.boundHost===d||(Nm(p),jA(p),p.schedule())};rr.push(nU);const Bm={getRect:d=>{const p=M(),b=p?.getTargetRects;if(typeof b=="function"){const I=Pt(()=>b.call(p,{target:d.target}),null);return I&&typeof I=="object"?I.success===!0&&Array.isArray(I.rects)?EV(xV(I.rects.filter(x=>x!=null&&typeof x=="object")),d.relativeTo):pl(typeof I.reason=="string"?I.reason:"unresolved"):pl("unresolved")}return pl("unavailable")},observe:d=>{const p=[];let b=0;const I=typeof requestAnimationFrame=="function",x=()=>{if(!I){d();return}b||(b=requestAnimationFrame(()=>{b=0,d()}))},V=Wo(re=>({ready:re.ready,selection:re.selection,zoom:re.zoom}));p.push(V.subscribe(()=>x()));const W={schedule:x,detach:null,boundHost:null};return jA(W),Xu.add(W),()=>{Xu.delete(W),Nm(W),b&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(b);for(const re of p.splice(0))try{re()}catch{}}},getHost:()=>VA(),entityAt:C2,contextAt:d=>{const p=!!d&&typeof d.x=="number"&&typeof d.y=="number",b=p?d.x:0,I=p?d.y:0;return{point:{x:b,y:I},entities:p?C2({x:b,y:I}):[],selection:qe.selection,position:null,insideSelection:!1}},scrollIntoView:async d=>{const p=d?.target;if(!p)return{success:!1};let b=null;if(p.kind==="entity"){const I=p.entityType==="comment"?"comments":"trackChanges",x=I==="comments"?Yu.get().items:Oa.get().items,V=p.entityType==="trackedChange"&&p.story?{story:p.story}:void 0;b=await Rm(I,p.entityId,x,V)}else{const I=p,x=p,V=Array.isArray(I.segments)&&I.segments.length>0?I.segments:x.blockId&&x.range?[{blockId:x.blockId,range:x.range}]:null;if(V){const W=p.story;b={kind:"text",segments:V,...W?{story:W}:{}}}}return b?{success:(await wc(b,{block:d.block??"center",behavior:d.behavior??"smooth"})).ok}:{success:!1}}},HA=d=>{const p=(d&&typeof d=="object"?d:null)?.target;return p&&typeof p=="object"?p:null},$A=d=>`metadata:resolve:${d}`,rU=d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return null;const{value:b}=uo($A(d),ln(),()=>p.resolve({id:d}),HA);return b},oU=async d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return null;try{const b=ln(),I=await Promise.resolve(p.resolve({id:d}));if(b!==ln())return null;const x=HA(I);return z.set($A(d),{token:b,value:x,hasSettled:!0,inflightToken:null}),x}catch{return null}},iU={getRect:d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return pl("unavailable");const b=rU(d.id);return b?Bm.getRect({target:b}):pl("unresolved")},scrollIntoView:async d=>{const p=await oU(d.id);return p?{success:(await wc(p,{block:d.block,behavior:d.behavior})).ok}:{success:!1}}},sU={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},aU={getContext:()=>{const d=_e();if(!d)return{...sU};const p=me()?.table;return{inTable:!0,tableNodeId:d.tableNodeId,rowIndex:d.rowIndex,columnIndex:d.columnIndex,cellNodeId:d.cellNodeId,rows:typeof p?.rows=="number"?p.rows:null,columns:typeof p?.columns=="number"?p.columns:null}},isInTable:()=>_e()!=null},zm={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeDeletedText:!1,regex:!1,canReplace:!1,reason:ct.searchUnavailable};let Bn={...zm};const Vm=new Set,Fa=()=>{const d=M()?.search;return d&&typeof d=="object"?d:null},Qs=()=>{const d=se()?.search;return d&&typeof d=="object"?d:null},Zf=()=>{const d=Fa();if(d&&typeof d.setSession=="function")return!0;const p=Qs();return!!p&&typeof p.query=="function"&&typeof p.getState=="function"},hs=()=>{for(const d of[...Vm])try{d(Bn)}catch{}},pi=d=>(Bn={...Bn,...d},hs(),Bn);let eo=0,Cc=null;const GA=()=>{const d=Cc;Cc=null,d&&Pt(()=>(d(),null),null)},lU=()=>{eo+=1,GA();const d=Zf();Bn={...zm,available:d,reason:d?void 0:ct.searchUnavailable},hs()};Nn.push(lU);const cU=d=>{if(!d)return!1;const p=d.queryError;if(p&&typeof p=="object"&&p.code==="invalid-pattern")return!0;const b=d.rejection;return d.status==="rejected"&&!!b&&typeof b=="object"&&b.code==="invalid-pattern"},S2=(d,p=!1)=>{const b=d&&typeof d=="object"?d:null;if(!b)return null;const I=Array.isArray(b.matches)?b.matches:[],x=typeof b.total=="number"&&Number.isFinite(b.total)?b.total:I.length,V=typeof b.activeMatchIndex=="number"?b.activeMatchIndex:typeof b.activeIndex=="number"?b.activeIndex:-1;return{...typeof b.query=="string"?{query:b.query}:{},total:x,activeIndex:V,canReplace:b.canReplace===!0||p,...b.includeDeletedText===!0?{includeDeletedText:!0}:{},...b.regex===!0?{regex:!0}:{},...cU(b)?{invalidPattern:!0}:{}}},Eo=()=>{const d=he("find.replace"),p=he("find.replaceAll");return d?.enabled===!0||p?.enabled===!0},To=(d,p=!1)=>{const b=S2(d,p);if(!b){pi({total:0,activeIndex:-1,canReplace:!1,reason:void 0});return}pi({...b.query!==void 0?{query:b.query}:{},total:b.total,activeIndex:b.activeIndex,canReplace:b.canReplace,...b.includeDeletedText!==void 0?{includeDeletedText:b.includeDeletedText}:{},...b.regex!==void 0?{regex:b.regex}:{},reason:b.invalidPattern?ct.searchInvalidPattern:void 0})},Na=()=>{const d=Fa();if(d&&typeof d.getState!="function")return Bn={...Bn,available:Zf(),reason:Zf()?void 0:ct.searchUnavailable},Bn;if(!d){const b=Qs();if(b&&typeof b.getState=="function"){const I=S2(Pt(()=>b.getState(),null),Eo());if(I)return Bn={...Bn,...I.query!==void 0?{query:I.query}:{},total:I.total,activeIndex:I.activeIndex,canReplace:I.canReplace,available:!0,reason:I.invalidPattern?ct.searchInvalidPattern:void 0,open:Bn.open||!!I.query},Bn}return Bn={...zm,query:Bn.query,caseSensitive:Bn.caseSensitive,includeDeletedText:Bn.includeDeletedText},Bn}const p=S2(Pt(()=>d.getState(),null));return p&&(Bn={...Bn,...p.query!==void 0?{query:p.query}:{},total:p.total,activeIndex:p.activeIndex,canReplace:p.canReplace,...p.includeDeletedText!==void 0?{includeDeletedText:p.includeDeletedText}:{},...p.regex!==void 0?{regex:p.regex}:{},available:!0,reason:p.invalidPattern?ct.searchInvalidPattern:void 0,open:Bn.open||!!p.query}),Bn},Zu=d=>{const p=d&&typeof d=="object"?d:null;if(p?.status==="committed")return{ok:!0};if(p?.status==="rejected"&&p.reason==="read-only")return{ok:!1,reason:ct.documentReadonly};const b=p?.rejection;return p?.status==="rejected"&&b&&typeof b=="object"&&b.code==="read-only-document"?{ok:!1,reason:ct.documentReadonly}:{ok:!1,reason:ct.operationUnavailable}},jm=qo({get:()=>Na(),subscribe:d=>(Vm.add(d),()=>Vm.delete(d))}),uU={get:jm.get,getSnapshot:jm.getSnapshot,subscribe:jm.subscribe,observe:jm.observe,open:()=>Zf()?(pi({available:!0,open:!0,reason:void 0}),{ok:!0}):(pi({available:!1,open:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}),close:()=>{if(eo+=1,Cc)GA();else{const d=Fa();if(d&&typeof d.clear=="function")Pt(()=>d.clear(),null);else{const p=Qs();p&&typeof p.query=="function"&&Pt(()=>p.query({query:""}),null)}}Bn={...zm,available:Zf(),reason:void 0},Bn.available||(Bn.reason=ct.searchUnavailable),hs()},search:(d,p)=>{const b=Fa(),I=!!p?.caseSensitive,x=p?.includeDeletedText===!0,V=p?.regex===!0,W=++eo;if(!b||typeof b.setSession!="function"){const fe=Qs();if(fe&&typeof fe.query=="function"&&typeof fe.getState=="function"){pi({query:d,caseSensitive:I,includeDeletedText:x,regex:V,available:!0,open:!0,reason:void 0}),Cc=()=>{fe.query({query:""})};const Me=Pt(()=>fe.query({query:d,caseSensitive:I,includeDeletedText:x,regex:V}),null);return xr(Me)?Promise.resolve(Me).then($e=>{W===eo&&To($e,Eo())},()=>{W===eo&&pi({available:!1,reason:ct.searchUnavailable})}):To(Me,Eo()),To(Pt(()=>fe.getState(),null),Eo()),Bn}return pi({query:d,total:0,activeIndex:-1,available:!1,caseSensitive:I,includeDeletedText:x,regex:V,reason:ct.searchUnavailable})}pi({query:d,caseSensitive:I,includeDeletedText:x,regex:V,available:!0,open:!0,reason:void 0}),Cc=()=>{typeof b.clear=="function"&&b.clear()};const re=Pt(()=>b.setSession(d,{caseSensitive:I,includeDeletedText:x,...V?{regex:!0}:{},highlight:!0}),null);if(To(re),d.length>0&&Bn.total===0&&Bn.reason!==ct.searchInvalidPattern){const fe=Qs();if(fe&&typeof fe.query=="function"&&typeof fe.getState=="function"){const Me=Cc;Cc=()=>{Me?.(),fe.query({query:""})};const $e=Pt(()=>fe.query({query:d,caseSensitive:I,includeDeletedText:x,regex:V}),null);xr($e)?Promise.resolve($e).then(We=>{W===eo&&To(We,Eo())},()=>{W===eo&&pi({available:!1,reason:ct.searchUnavailable})}):To($e,Eo()),To(Pt(()=>fe.getState(),null),Eo())}}return Bn},next:()=>{const d=Fa();if(!d||typeof d.next!="function"){const p=Qs();if(!p||typeof p.next!="function"||typeof p.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(Bn.total===0)return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.next(),null);if(xr(b)){const I=eo;Promise.resolve(b).then(x=>{I===eo&&To(x,Eo())}).catch(()=>{I===eo&&pi({available:!1,reason:ct.searchUnavailable})})}else To(b,Eo());return To(Pt(()=>p.getState(),null),Eo()),{ok:!0}}return Bn.total===0?{ok:!1,reason:ct.operationUnavailable}:(To(Pt(()=>d.next(),null)),{ok:!0})},previous:()=>{const d=Fa();if(!d||typeof d.previous!="function"){const p=Qs();if(!p||typeof p.previous!="function"||typeof p.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(Bn.total===0)return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.previous(),null);if(xr(b)){const I=eo;Promise.resolve(b).then(x=>{I===eo&&To(x,Eo())}).catch(()=>{I===eo&&pi({available:!1,reason:ct.searchUnavailable})})}else To(b,Eo());return To(Pt(()=>p.getState(),null),Eo()),{ok:!0}}return Bn.total===0?{ok:!1,reason:ct.operationUnavailable}:(To(Pt(()=>d.previous(),null)),{ok:!0})},clear:()=>{eo+=1;const d=Fa();if(d&&typeof d.clear=="function"&&Pt(()=>d.clear(),null),!d||typeof d.clear!="function"){const p=Qs();p&&typeof p.query=="function"&&Pt(()=>p.query({query:""}),null)}pi({query:"",total:0,activeIndex:-1,canReplace:!1})},replace:d=>{const p=Fa();if(!p){const I=Qs();if(!I||typeof I.replace!="function"||typeof I.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(!Eo())return{ok:!1,reason:ct.operationUnavailable};const x=Pt(()=>I.replace({replacement:typeof d=="string"?d:""}),null);if(xr(x)){const V=eo;Na(),hs();const W=()=>V===eo;return Promise.resolve(x).then(re=>(W()&&(To(re,Eo()),Na(),hs()),Zu(re)),()=>(W()&&pi({available:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}))}return Na(),hs(),Zu(x)}if(typeof p.replaceCurrent!="function")return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.replaceCurrent(typeof d=="string"?d:""),null);return Na(),hs(),Zu(b)},replaceAll:d=>{const p=Fa();if(!p){const I=Qs();if(!I||typeof I.replaceAll!="function"||typeof I.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(!Eo())return{ok:!1,reason:ct.operationUnavailable};const x=Pt(()=>I.replaceAll({replacement:typeof d=="string"?d:""}),null);if(xr(x)){const V=eo;Na(),hs();const W=()=>V===eo;return Promise.resolve(x).then(re=>(W()&&(To(re,Eo()),Na(),hs()),Zu(re)),()=>(W()&&pi({available:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}))}return Na(),hs(),Zu(x)}if(typeof p.replaceAll!="function")return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.replaceAll(typeof d=="string"?d:""),null);return Na(),hs(),Zu(b)}},WA=Ko(d=>d.styles),Um=qo(WA),dU={get:Um.get,getSnapshot:Um.getSnapshot,subscribe:Um.subscribe,observe:Um.observe,getCatalog:d=>An(d).value,getQuickGallery:()=>WA.get().quickGallery,getActiveParagraphStyle:()=>Zr(qe.selection,mn().cache).style},KA={select:Wo,get state(){return qe},selection:OA,commands:Uj,toolbar:Hj,comments:Gj,trackChanges:qj,contentControls:Xj,fonts:Zj,zoom:Qj,document:Jj,viewport:Bm,metadata:iU,tables:aU,search:uU,styles:dU,formatPainter:{setPointerSelecting(d){U||(h={...h,pointerSelecting:d})},notifyPointerUp(){U||(h={...h,pointerSelecting:!1},LA())},setKeyboardSelecting(d){U||(h={...h,keyboardSelecting:d})},notifyKeyUp(){U||(h={...h,keyboardSelecting:!1},LA())},cancel(){U||Im()},onModeChange(d){return U?()=>{}:(m.add(d),()=>m.delete(d))}},createScope:()=>{const d=[];return{select:(p,b)=>{const I=Wo(p,b);return{get:I.get,subscribe:x=>{const V=I.subscribe(x);return d.push(V),V}}},dispose:()=>{for(const p of d.splice(0))p()}}},destroy:()=>{if(!U){U=!0,Kz(Qe,It),De&&(clearTimeout(De),De=null),ve&&(clearTimeout(ve),ve=null,Ce=0),G?.timer&&(clearTimeout(G.timer),G.timer=null),G=null,ot&&(clearTimeout(ot),ot=null),Hr&&(clearTimeout(Hr),Hr=null),yr&&yr(),yr=null,Uo=null,Tn=0,Ur=0,cn.clear(),Rn.clear(),Tr.clear(),Yt=null,J.clear();for(const d of Zs.splice(0))d();dn&&dn(),dn=null,st=null,Ho&&Ho(),Ho=null,Jr=null,$o&&$o(),$o=null,ho=null,di&&di(),di=null,Fo=null,fi&&fi(),fi=null,fs=null,D&&D(),D=null,Xs=null;for(const d of Xu)Nm(d);Xu.clear(),O.clear(),Vm.clear(),g+=1,m.clear(),eo+=1,oe.clear()}}};return $=KA,KA}var FV=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function NV(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function BV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?NV(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function zV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function VV(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:FV;for(const s of i)o(s);return n}var jV=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function UV(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}Rt();var HV=['[data-sdt-type="structuredContent"][data-sdt-id]','[data-sdt-type="structuredContent"][data-sdt-container-id]','[data-sdt-container-type="structuredContent"][data-sdt-container-id]'].join(", "),$V=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function GV(e,t){const n=new f6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function u2(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function SA(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function WV(e,t){if(!e)return()=>{};if(u2(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{SA(e),s()},l=c=>{c!==!1&&(c===!0||u2(e))&&(SA(e),s())};return n("synced",a),n("sync",l),u2(e)&&s(),i}function KV(e,t){const n=e.composedPath();if(!n.includes(t))return null;const r=n.find(a=>a instanceof HTMLElement&&a.matches(HV));if(!r)return null;const o=n.some(a=>a instanceof HTMLElement&&a.classList.contains(Zh.BLOCK_SDT_LABEL)),i=r.getAttribute("data-sdt-container-id")?.trim()||null,s=r.getAttribute("data-sdt-id")?.trim()||null;return o?i??s:s??i}function qV(e){if(!e||typeof e!="object")return[];const t=e.items;return Array.isArray(t)?t:[]}function YV(e){if(!e||typeof e.id!="string"||e.kind!=="inline"&&e.kind!=="block"||typeof e.controlType!="string")return null;const t=e.properties?.tag,n=e.properties?.alias;return{id:e.id,controlType:e.controlType,scope:e.kind,...typeof t=="string"&&t?{tag:t}:{},...typeof n=="string"&&n?{alias:n}:{}}}function ni(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function XV(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function _A(e){return typeof e=="string"&&e.length>0?e:null}function AA(e){return e?ni(e)?_A(e.documentId??e.options?.documentId??null):_A(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function ZV(e){if(!e||ni(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function ns(e){if(!e)return null;if(ni(e))return e.fonts??null;const t=ZV(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var gm=class extends $m.default{static{this.allowedTypes=[Fr,Hl,Kh]}#e;#n;#t;#r;#i;#s;#d;#h;#f;#c;#p;get uiConfig(){return this.#p}#o;get interactionConfig(){return this.#o}#l;get surfacesConfig(){return this.#l}#g;#u;#y;#w;constructor(e){if(super(),this.#e=!1,this.#n=!1,this.#t=null,this.#r=null,this.#i=null,this.#s=null,this.#d=null,this.#h=null,this.#f=n=>{this.#k(n)},this.#c=null,this.#p=F4({}),this.#o=N4({}),this.#l=z4({}),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.#u=new HF,this.#y=null,this.#w=!1,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...$0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},this.#Z=new WeakSet,this.#Q=null,this.#j=null,this.#L=null,!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#g=new LF({getModuleConfig:()=>this.#l}),this.#h=t,t.addEventListener("click",this.#f,!0),this.#I(e,t)}async#k(e){const t=this.#h;if(!t)return;const n=KV(e,t),r=this.activeEditor?.doc?.contentControls?.list;if(!(!n||typeof r!="function"))try{const o=await r();if(this.#e)return;const i=YV(qV(o).find(s=>s.id===n));i&&this.emit("content-control:click",{target:i,source:"pointer"})}catch{return}}async#I(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),BF(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#ye(),this.config.user=zF(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=Pk(this.config.modules.comments),this.#p=F4(this.config),this.#o=N4(this.config),this.#l=z4(this.config),this.config.disableContextMenu=!this.#p.contextMenu.enabled,this.config.rulers=this.#p.ruler.enabled,this.#p.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#p.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&Object.assign(i,this.#o.comments)}if(this.config.colors=w6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.4.0-next.32",this.#C("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||ps(),this.colors=this.config.colors??[],this.#D(),await fT(),this.#e)return;if(await this.#b(this.config.modules),this.#e){this.#ue();return}this.config.cspNonce&&this.#P(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#y||(this.#y=this.#u.subscribe(i=>{this.#we(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#d=o,this.#S(),this.#M(),this.#Ce(),this.#x()}#x(){if(this.#E(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#d)}#M(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new rD({Renderer:EF,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#m("requiredNumberOfEditors").documents.filter(e=>e.type===Fr).length}get ui(){return this.#c||(this.#c=OV({superdoc:this}),this.#e&&this.#c.destroy()),this.#c}get state(){return{documents:this.#m("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#P(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#D(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}else if(n)this.config.documents=[{id:ps(),type:Fr,url:this.config.document,name:"document.docx"}];else if(r){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}else if(o){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=Gd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||ps()}}))}#E(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=GP({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#g),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&Z8(this),this.#ce()}#a(e,t){t&&this.on(e,t)}#S(){this.#a("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#a("editorCreate",this.config.onEditorCreate),this.#a("editorDestroy",this.config.onEditorDestroy),this.#a("source:complete",this.config.onSourceComplete),this.#a("source:signals-complete",this.config.onSourceSignalsComplete),this.#a("ready",this.config.onReady),this.#a("comments-update",this.config.onCommentsUpdate),this.#a("content-control:active-change",this.config.onContentControlActiveChange),this.#a("content-control:click",this.config.onContentControlClick),this.#a("awareness-update",this.config.onAwarenessUpdate),this.#a("locked",this.config.onLocked),this.#a("pdf:document-ready",this.config.onPdfDocumentReady),this.#a("sidebar-toggle",this.config.onSidebarToggle),this.#a("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#$(e?.editor??null)),this.#a("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#a("exception",this.config.onException),this.#a("list-definitions-change",this.config.onListDefinitionsChange),this.#a("pagination-update",this.config.onPaginationUpdate),this.#a("fonts-resolved",this.config.onFontsResolved),this.#a("fonts-changed",this.config.onFontsChanged),this.#a("zoomChange",this.config.onZoomChange),this.#a("viewport-change",this.config.onViewportChange)}async#b({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:ps(),type:Fr,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#ee(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=qr(e),this.provider=qr(t),this.#_();const n=this.config;this._cleanupAwareness=W8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#H(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#A(){if(this.#r){try{this.#r()}catch{}this.#r=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#$(e){this.#A(),ni(e)&&(this.#O(e),this.#T(e))}#O(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=JP(()=>this.user),r=o=>{if(this.#e)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#r=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#T(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#e||this.#v(!!r.isLocked,this.#F(r.lockedBy??null))};try{if(this.#s&&typeof t.setLocked=="function"){const o=this.#s;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#s=null}const r=t.getSnapshot?.();r&&n(r),this.#i=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#F(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#G(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#v(e,t){this.isLocked===e&&this.#G(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#C("🦋 [superdoc] Locking superdoc:",e,t,`
102
+ `;Rt();var Ds=e=>{e.expand.value=!1};function Z0(e,t){const n={...e??{}};return t?n.href=t:delete n.href,n}function tA(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Cz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function nA(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function kz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Sz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}var _z=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=_n({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??gB).map(SB),u=_n({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:c,onActivate:({fontFamily:Qe}={},It=!1)=>{if(It){u.label.value="",u.selectedValue.value="";return}if(!Qe)return;Qe=Qe.split(",")[0],u.label.value=Qe;const Ht=c.find(nn=>nn.label===u.defaultLabel.value),wn=c.find(nn=>nn.label===Qe);wn?u.selectedValue.value=wn.key:Ht?u.selectedValue.value=Ht.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const Qe=c.find(It=>It.label===u.defaultLabel.value);Qe?u.selectedValue.value=Qe.key:u.selectedValue.value=""}}),f=_n({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(f)}]});function h(Qe){const It=nA(e),Ht=It?.selectionTarget??tA(It?.target),wn=It?.empty?"":Cz(It),nn=Sz(e),un=()=>Ds(Qe),Wn=()=>{const Xn=e.pendingSelectionCapture;Xn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Xn)};return Vr("div",{},[Vr(XB,{handleClose:un,selectedText:wn,target:Ht,doc:e.superdoc?.activeEditor?.doc??null,apiKey:nn?.apiKey||e.config?.aiApiKey||"",endpoint:nn?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Wn})])}const g=yB,m=_n({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:g,onActivate:({fontSize:Qe},It=!1)=>{if(It){m.label.value="",m.selectedValue.value="";return}const Ht=g.find(Wn=>Wn.label===String(m.defaultLabel.value));if(!Qe){m.label.value=m.defaultLabel.value,Ht?m.selectedValue.value=Ht.key:m.selectedValue.value="";return}let wn=lN(Qe,12);wn<8&&(wn=8),wn>96&&(wn=96);let nn=String(wn);const un=g.find(Wn=>Wn.label===nn||Wn.key===nn);un?m.selectedValue.value=un.key:m.selectedValue.value="",m.label.value=nn},onDeactivate:()=>{m.label.value=m.defaultLabel.value;const Qe=g.find(It=>It.label===String(m.defaultLabel.value));Qe?m.selectedValue.value=Qe.key:m.selectedValue.value=""}}),v=_n({type:"separator",name:"separator",isNarrow:!0}),k=_n({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=_n({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),_=_n({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=_n({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>X0(e,y,[],!0)}],onActivate:({color:Qe})=>{y.iconColor.value=Qe||""},onDeactivate:()=>y.iconColor.value=""}),w=_n({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>X0(e,w)}],onActivate:({color:Qe})=>{w.iconColor.value=Qe},onDeactivate:()=>w.iconColor.value="#000"}),T=_n({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),L=_n({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>F(L)}],onActivate:({href:Qe})=>{L.attributes.value=Z0(L.attributes.value,Qe)},onDeactivate:()=>{L.attributes.value=Z0(L.attributes.value,null),L.expand.value=!1}});function F(Qe){const It=nA(e),Ht=It?.selectionTarget??tA(It?.target),wn=()=>{const nn=e.pendingSelectionCapture;nn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(nn)};return Vr("div",{},[Vr(IS,{ui:e.ui,linkItem:Qe,textTarget:Ht,restoreSelection:wn,closePopover:()=>{Ds(Qe),yu(e)},goToAnchor:()=>{Ds(Qe);const nn=Qe.attributes.value?.href;if(!nn)return;const un=nn.slice(1),Wn=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${un}']`);Wn&&lf(Wn)}})])}const H=_n({type:"options",name:"linkInput",command:"toggleLink",active:!1});L.childItem=H,H.parentItem=L;const M=_n({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),B=_n({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),q=_n({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>P(q)}]});function P(Qe){return Vr("div",{},[Vr(fz,{onSelect:Ht=>{e.emitCommand({item:Qe,argument:Ht}),Ds(Qe),yu(e)}})])}const N=_n({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>j(N)}]}),E=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function j(Qe){return Vr(bz,{options:E,onSelect:It=>{Ds(Qe);const{command:Ht}=It;e.emitCommand({item:Qe,argument:{command:Ht}})}})}const Q=_n({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Vr("div",{},[Vr(IB,{onSelect:It=>{Ds(Q);const Ht={...Q,command:"setTextAlign"};Ht.command="setTextAlign",e.emitCommand({item:Ht,argument:It}),Y(Q,It),yu(e)}})]),key:"alignment"}],onActivate:({textAlign:Qe})=>{Y(Q,Qe)},onDeactivate:()=>{Y(Q,"left")}}),Y=(Qe,It)=>{let Ht=It==="both"?"justify":It,wn={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},nn=wn[Ht]??wn.left;Qe.icon.value=nn},se=_n({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Qe=It=>{Ds(se);const Ht={...se,command:"toggleBulletListStyle"};e.emitCommand({item:Ht,argument:It})};return Vr(J4,{buttons:TB,iconSize:25,selectedStyle:se.selectedValue.value,onSelect:Qe})}}]}),he=_n({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Qe=It=>{Ds(he);const Ht={...he,command:"toggleOrderedListStyle"};e.emitCommand({item:Ht,argument:It})};return Vr(J4,{buttons:RB,iconSize:30,selectedStyle:he.selectedValue.value,onSelect:Qe})}}]}),Ve=_n({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),pe=_n({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ye=_n({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),me=_n({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Qe})=>{Qe&&(me.label.value=Qe)}}),_e=_n({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Qe})=>{Qe&&(_e.label.value=Qe)}}),oe=_n({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Re=_n({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),je=_n({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),et=_n({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),St=_n({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Te=_n({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),He=(Qe,It)=>Qe==="editor"?It:Qe==="suggester"?It.filter(Ht=>Ht.value==="suggesting"):It.filter(Ht=>Ht.value==="viewing"),Ye=Qe=>Qe==="editor"?"Editing":Qe==="suggester"?"Suggesting":"Viewing",ee=_n({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Ye(s),label:Ye(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ne(ee)}]}),S=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ne(Qe){const It=He(s,S);return Vr(BB,{options:It,onSelect:Ht=>{const wn=e.superdoc?.activeEditor??e.activeEditor;Ds(Qe);const{label:nn,icon:un,value:Wn}=Ht;ee.label.value=nn,ee.icon.value=un,e.emitCommand({item:ee,argument:Wn}),yu(e,wn)}})}const O=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),U=["search","ruler","undo","overflow","documentMode"],$=_n({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),z=_n({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),J=_n({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Qe=Ht=>{Ds(J);const wn=typeof Ht=="string"?Ht:Ht?.id??null;if(!wn)return;const nn={...J,command:"setLinkedStyle"};e.emitCommand({item:nn,argument:wn})},It=e.getActiveLinkedStyleId?.()??null;return Vr("div",{},[Vr(UB,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Qe,selectedOption:It})])}}],onActivate:({styleId:Qe,styleName:It})=>{const Ht=It||Qe;J.label.value=Qe&&Qe!=="Normal"?String(Ht):n.formatText,J.disabled.value=!1},onDeactivate:()=>{J.disabled.value=!0,J.label.value=n.formatText}}),Z=(Qe,It)=>{if(It.value==Qe)return Vr("div",{innerHTML:wz,class:"dropdown-select-icon"})},G=_n({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,restoreEditorFocus:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Qe=>({label:Qe.toFixed(2),key:Qe,icon:()=>Z(Qe,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),be=20,ve=32,Ce=U.reduce((Qe,It)=>Qe+(O.get(It)||O.get("default")),0),De=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Ze=["zoom","fontFamily","fontSize","redo"],ot=i<=Tf.lg,yt=e.config?.showFormattingMarksButton===!0,tn=e.config?.showTableOfContentsButton===!0;ot&&(ee.attributes.value={...ee.attributes.value,className:`${ee.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),ot&&(J.attributes.value={...J.attributes.value,className:`${J.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let Ue=[oe,Re,je,et,T,me,u,v,m,v,l,k,C,_,w,y,v,L,M,...tn?[B]:[],q,N,v,Q,se,he,Ve,pe,G,v,J,v,$,_e,...yt?[z]:[],Te,St,...kz(e)?[f]:[],ye,ee];if(i<=Tf.md&&o&&(Ue=Ue.filter(Qe=>Qe.type!=="separator")),e.config.mode!=="docx"){const Qe=Ue.findIndex(Ht=>Ht.name.value==="linkedStyles");Ue.splice(Qe-1,2);const It=["ruler","zoom","undo","redo"];Ue=Ue.filter(Ht=>!It.includes(Ht.name.value))}const Ot=[];a||(s==="viewer"&&Ot.push(je,et),Ue=Ue.filter(Qe=>!Ot.includes(Qe)));const Bt=Qe=>U.includes(Qe.name.value),an=[],nr=[];let qt=ve+Ce;return Ue.forEach(Qe=>{const It=O.get(Qe.name.value)||O.get("default");if(i<Tf.xl+be&&De.includes(Qe.name.value)&&o){if(an.push(Qe),Qe.name.value==="linkedStyles"){const Ht=Ue.findIndex(wn=>wn.name.value==="linkedStyles");Ue.splice(Ht+1,1)}return}if(i<Tf.sm&&Ze.includes(Qe.name.value)&&o){an.push(Qe);return}if(Bt(Qe)){nr.push(Qe),qt+=It;return}qt<i||!o?(nr.push(Qe),qt+=It):an.push(Qe)}),{defaultItems:nr,overflowItems:an.filter(Qe=>Qe.type!=="separator")}},rA={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},Az=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Rt();function oA(e){return eN(e)??Y0[e]??null}function sm(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Iz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),xz=new Set(["list","numberedlist"]);function Ez(e,t){if(e==="fontFamily"||e==="fontSize"||xz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Iz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function iA(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Tz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var Rz=class extends $m.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...sr},texts:{...rA},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#e=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...sr,...e.icons},this.config.texts={...rA,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._reportedInvalidCustomItems=new Set,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=Az(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#t(),this.#d(),this.#f(),this.#i(),this._lastFontOptionsSignature=this.#o(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Ul(kB),this.app.directive("click-outside",Kv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#t(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#a():this.#S()}))}#r(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#S();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#s(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#d(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#h(e){if(e)return e;const t=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return vB(t)}#f(){const e=this.getAvailableWidth(),t=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,{defaultItems:n,overflowItems:r}=_z({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#h(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),o=this.config.customButtons||[],i=new Set([...n,...r].map(c=>c.name?.value).filter(Boolean)),s=o.map((c,u)=>{try{if(c?.name&&i.has(c.name))throw new Error(`Toolbar item name "${c.name}" is already taken by another item, so this entry is skipped.`);const f=this.#c(c);return i.add(f.name?.value),f}catch(f){const h=`${c?.name??`<unnamed@${u}>`}::${f?.message??String(f)}`;return this._reportedInvalidCustomItems.has(h)||(this._reportedInvalidCustomItems.add(h),this.#b(f,c?.name??null)),null}}).filter(Boolean);s.length&&n.push(...s);let a=[...n.map(c=>c.name.value),...r.map(c=>c.name.value)];if(t){const c=Object.values(this.config.groups).flatMap(h=>h),u=new Set(Object.keys(this.config.groups)),f=s.filter(h=>u.has(h.group?.value||"center")).map(h=>h.name.value);a=[...new Set([...c,...f])]}const l=n.filter(c=>a.includes(c.name.value)).filter(c=>!this.config.excludeItems.includes(c.name.value));if(t)for(const[c,u]of Object.entries(this.config.groups))for(const f of l)u.includes(f.name.value)&&(f.group.value=c);this.toolbarItems=l,this.overflowItems=r.filter(c=>a.includes(c.name.value))}#c(e){const t=_n({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#f(),this.emit("toolbar-items-changed")}#o(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#l().find(t=>t.name.value===e)}#l(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#f(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#u(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#y(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#w(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>X0(this,e,[],!0)};e.nestedOptions.value=[t]}#k(e){return!!e?.active&&e?.value==null}#I(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=Q4.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(K0(t)?.disposition==="host-routed")return e.setDisabled(!this.#u(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=oA(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Ez(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#y()},link:()=>{e.active.value=!!r?.active,e.attributes.value=Z0(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#I(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#k(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#y(),this.#w();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#M(),this.#l().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#l().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#M(){this.#l().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#P(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#D(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#b(i,n)};if(n==="image"&&t==null)return this.#E();if(n==="tableActions"){const i=Z4[t?.command];return i?sm(this.ui,i,void 0,r):!1}if(K0(n)?.disposition==="unsupported")return!0;const o=oA(n);return o?sm(this.ui,o,t,r):!1}#E(){return this.snapshot?.commands?.image?.disabled||(this.#e||(this.#e=aN({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await iN(e,this.superdoc?.config?.handleImageUpload);sm(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#b(n,"image")})},onError:e=>this.#b(e,"image")})),this.#e.open()),!0}#a(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{iA(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!iA(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Tz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#S(){this.#n&&(this.#n(),this.#n=null)}#b(e,t){const n={error:e instanceof Error?e:new Error(String(e)),originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null},r={...n};this.emit("exception",n),this.superdoc?.emit?.("exception",r)}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(K0(r)?.disposition==="host-routed"){this.#P(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!sm(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#b(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#D(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#b(s,r)}}}destroy(){this.#S(),this.#e?.destroy(),this.#e=null,this.#s(),this.#r(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Lz(e){return new Rz(e)}function Mz(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Pz(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=am(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=Oz(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=Dz(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=Fz(e.border);return i&&(t.border=i),t}function am(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function Dz(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function Oz(e){if(!e)return;const t={},n=am(e.fill);n!=null&&(t.fill=n);const r=am(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function Fz(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=am(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function nc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}var Nz=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]),Bz=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:Nz.has(e.editableCommandKind);function sA(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function zz(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of sA(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function aA(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=e;for(;i;){const s=i,a=zz(s),l=a.length>0?s.getAttribute("data-story-key"):null;for(const m of a){const v=`trackedChange:${m}`;if(!r.has(v)){r.add(v);const k={type:"trackedChange",id:m};l&&(k.storyKey=l),n.push(k),o.push(k)}}const c=s.getAttribute("data-layout-story");if(c&&o.length>0){for(const m of o)m.story=c;o=[]}const u=s.getAttribute("data-citation-id");if(u){const m=`citation:${u}`;r.has(m)||(r.add(m),n.push({type:"citation",id:u}))}const f=s.getAttribute("data-comment-ids");if(f)for(const m of sA(f)){const v=`comment:${m}`;r.has(v)||(r.add(v),n.push({type:"comment",id:m}))}const h=s.getAttribute("data-sdt-type"),g=s.getAttribute("data-sdt-id");if(g&&h==="structuredContent"){const m=`contentControl:${g}`;if(!r.has(m)){r.add(m);const v=s.getAttribute("data-sdt-scope"),k=s.getAttribute("data-sdt-tag"),C={type:"contentControl",id:g};(v==="block"||v==="inline")&&(C.scope=v),k&&(C.tag=k),n.push(C)}}if(t&&i===t)break;i=i.parentElement}return n}var ao=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),dl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),bu=()=>({oneOf:[{type:"number"},{type:"null"}]}),wu=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),Vz={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},jz={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},Uz=()=>({oneOf:[{type:"boolean"},{type:"null"},Vz]}),Hz=()=>({oneOf:[{type:"array",items:jz,minItems:1},{type:"null"}]});function lm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function $z(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var Q0=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:lm(n),schema:ao()}),rc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:lm("textStyle",o??e),schema:r}),jn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:$z(o??e),schema:r}),cm=[Q0("bold","w:b","bold"),Q0("italic","w:i","italic"),Q0("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:lm("underline"),schema:Uz()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:lm("highlight"),schema:dl()},rc("color","string","w:color",dl()),rc("fontSize","number","w:sz",bu()),rc("fontFamily","string","w:rFonts",dl()),rc("letterSpacing","number","w:spacing",bu()),rc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),rc("position","number","w:position",bu()),jn("dstrike","boolean","w:dstrike",ao()),jn("smallCaps","boolean","w:smallCaps",ao()),rc("caps","boolean","w:caps",ao(),"textTransform"),jn("shading","object","w:shd",wu({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("border","object","w:bdr",wu({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),jn("outline","boolean","w:outline",ao()),jn("shadow","boolean","w:shadow",ao()),jn("emboss","boolean","w:emboss",ao()),jn("imprint","boolean","w:imprint",ao()),jn("charScale","number","w:w",bu(),"w"),jn("kerning","number","w:kern",bu(),"kern"),jn("vanish","boolean","w:vanish",ao()),jn("webHidden","boolean","w:webHidden",ao()),jn("specVanish","boolean","w:specVanish",ao()),jn("rtl","boolean","w:rtl",ao()),jn("cs","boolean","w:cs",ao()),jn("bCs","boolean","w:bCs",ao(),"boldCs"),jn("iCs","boolean","w:iCs",ao(),"italicCs"),jn("eastAsianLayout","object","w:eastAsianLayout",wu({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),jn("em","string","w:em",dl()),jn("fitText","object","w:fitText",wu({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("snapToGrid","boolean","w:snapToGrid",ao()),jn("lang","object","w:lang",wu({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),jn("oMath","boolean","w:oMath",ao()),jn("rStyle","string","w:rStyle",dl(),"styleId"),jn("rFonts","object","w:rFonts",wu({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),jn("fontSizeCs","number","w:szCs",bu()),jn("ligatures","string","w14:ligatures",dl()),jn("numForm","string","w14:numForm",dl()),jn("numSpacing","string","w14:numSpacing",dl()),jn("stylisticSets","array","w14:stylisticSets",Hz()),jn("contextualAlternates","boolean","w14:cntxtAlts",ao())],TH=new Set(cm.map(e=>e.key)),Gz=Object.fromEntries(cm.map(e=>[e.key,e])),RH={mark:cm.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:cm.filter(e=>e.storage==="runAttribute").map(e=>e.key)},J0=new WeakMap;function Wz(e){let t=J0.get(e);return t||(t={refCount:0,generation:0,abortController:new AbortController,inFlight:null,activeMutationTokens:new Set},J0.set(e,t)),t.refCount+=1,t}function Kz(e,t){t.refCount=Math.max(0,t.refCount-1),!(t.refCount>0)&&(t.abortController.abort("ui-controller-destroyed"),t.inFlight=null,t.activeMutationTokens.clear(),J0.delete(e))}var qz=new Set(Object.values(ct));function e2(e,t){return typeof e=="string"&&qz.has(e)?e:t}function lA(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:ct.notReady}:{ok:!1,reason:e2(t,ct.targetUnresolved)}}return{ok:!0}}var Yz=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],Xz={[V4.bulletList]:"bullet",[V4.numberedList]:"ordered"};function cA(e){return Xz[e]??null}var Zz={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function Qz(e){const t=Zz[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var Jz={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""},eV=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: shared all-story tracked-changes catalog; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: current-token validation over the shared all-story catalog; consumers fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}],tV=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function nV(e){return eV.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var uA={ready:0,stale:1,pending:2};function fl(...e){let t="ready";for(const n of e)uA[n]>uA[t]&&(t=n);return t}function Pt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function xr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function vr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function Yn(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Rf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Lf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function t2(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function dA(e,t){if(!e||typeof e!="object")return null;const n=Lf(e),r=e,o=r.navigationTarget&&typeof r.navigationTarget=="object"?r.navigationTarget:null;if(o?.kind==="block"&&typeof o.blockId=="string"&&o.blockId.length>0){const i={kind:"text",blockId:o.blockId,range:{start:0,end:0},...o.story&&typeof o.story=="object"?{story:o.story}:{},...r.address&&typeof r.address=="object"?{address:r.address}:{}};if(t?.preferStableBlock||!t2(n))return i}return n}function Cr(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function Mf(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Lf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ji(e,t,n){return lo(e)!==t?!1:n?Cr(Mf(e))===Cr(n):!0}function um(e){const t=Mf(e);if(!(!t||Cr(t)===Cr(null)))return t}function rV(e){if(typeof e!="string"||e.length===0)return;const t=C6(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;default:return}}function oV(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function n2(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function dm(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function iV(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function lo(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function sV(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}var fA=new WeakMap;function hA(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const f of a.wordIdOther)n(f);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const c=s.replacement;if(c&&typeof c=="object")for(const f of[c.inserted,c.deleted])f&&typeof f=="object"&&(n(f.id),n(f.wordId));const u=s.move;if(u&&typeof u=="object")for(const f of[u.source,u.destination])f&&typeof f=="object"&&(n(f.id),n(f.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function Os(e){const t=fA.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=lo(i);if(s){n.add(s);for(const a of hA(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return fA.set(e,o),o}var pA=new WeakMap,mA=new WeakMap;function oc(e,t){const n=Cr(t);let r=pA.get(e);r||(r=new Map,pA.set(e,r));const o=r.get(n);if(o)return o;const i=Os(e.filter(s=>Cr(Mf(s))===n));return r.set(n,i),i}function aV(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function lV(e,t){const n=t.filter(o=>e.some(i=>lo(i)===o&&Mf(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>lo(s)===o);if(i)for(const s of hA(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function cV(e){const t=mA.get(e);if(t)return t;const n=e.filter(o=>Mf(o)!=null),r=n.length===e.length?e:n;return mA.set(e,r),r}function uV(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=c=>{for(const u of t){const f=c.toPublicId(u);if(f)return f}return null},a=es(r),l=Cr(a)===Cr(null);if(i){const c=l?cV(i):i,u=s(oc(c,a));if(u)return u;const f=n?.find(h=>c.some(g=>Ji(g,h,a)));return f||(l?s(Os(o)):aV(a)?lV(i,t):null)}return l?s(Os(o))??t[0]??null:null}function dV(e,t){const n=e.find(r=>lo(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??lo(n)??t:null}function fV(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,c=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:c??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Nr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var hV=64;function ic(e){return e.length<=hV}function es(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function bo(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function Ea(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function gA(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var vA=720;function Fs(e){return Math.round(e*20)}function Cu(e){return typeof e=="number"&&Number.isFinite(e)}function pV(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=Cu(i.left)?Fs(i.left):Cu(i.start)?Fs(i.start):void 0,a=Cu(i.right)?Fs(i.right):Cu(i.end)?Fs(i.end):void 0,l=Cu(i.firstLine)?Fs(i.firstLine):void 0,c=Cu(i.hanging)?Fs(i.hanging):void 0;return s==null&&a==null&&l==null&&c==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...c!=null?{hanging:c}:{}}}function r2(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function mV(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function Pf(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function hl(e){return Pf(e.target)??Pf(e.selectionTarget)}var yA=["fontFamily","fontSize","color","highlight"],gV={undo:"history.undo",redo:"history.redo"},Df=["bold","italic","underline","strikethrough"];function o2(e){return yA.includes(e)}function ku(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,c,u)=>{typeof l!="string"||typeof c!="number"||typeof u!="number"||r.push({blockId:l,start:Math.min(c,u),end:Math.max(c,u)})};for(const l of n){const c=l?.range;o(l?.blockId,c?.start,c?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function ts(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function vV(e){const t=ts(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function Ta(e){const t=ku(e);return t.length===0?null:[vV(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function bA(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:nc({selectionTarget:t})}function yV(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function bV(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function wV(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function CV(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function wA(e,t){const n=ku(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>CV(n,wV(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function kV(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function i2(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function SV(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function _V(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function CA(e,t){if(!e)return{};const n=new Map;for(const i of ku(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of yA){const s=new Map;let a=!1,l=!1;for(const c of r){const u=typeof c?.blockId=="string"?c.blockId:null;if(!u)continue;const f=n.get(u);if(!f?.length)continue;const h=Array.isArray(c?.runs)?c.runs:[];for(const g of h){const m=g?.range,v=typeof m?.start=="number"?m.start:null,k=typeof m?.end=="number"?m.end:null;if(v==null||k==null||!f.some(y=>bV(y,{start:v,end:k})))continue;a=!0;const C=kV(g?.styles,i);if(C===void 0){l=!0;continue}const _=_V(i,C);if(s.has(_)||s.set(_,C),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function s2(e,t){const n=Nr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:bo(n)}:{kind:"documentEnd"}}function on(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function Of(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function fm(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function Ns(e){if(xr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function hm(e){return!!e&&typeof e=="object"&&e.success===!0}function wo(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function Ff(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function a2(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const c of l.blocks)n(c);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function sc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function pm(e){return e.trackedChange?.kind==="delete"?0:typeof e.text=="string"?e.text.length:0}function ki(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!wo(i)&&n===null&&(n=i),hm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function AV(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function IV(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function mm(e){return vu(e)?.trackDecision??null}function xV(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function pl(e){return{found:!1,success:!1,rects:[],reason:e}}function EV(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function TV(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function kA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(TV))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function RV(e){return e.selectionTarget?e.selectionTarget:kA(e.target)}function Su(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=kA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function l2(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var c2={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},LV=Object.fromEntries(Object.entries(c2).filter(([e])=>Gz[e]?.tracked===!0));function MV(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...c2}};default:return null}}function PV(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function DV(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function OV(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,c=!1,u=Promise.resolve(),f=null,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},g=0;const m=new Set;let v={},k="",C=null;const _=()=>{const d=t?.activeEditor;return d&&typeof d=="object"?d:null},y=()=>{const d=_()?.doc;return d&&typeof d=="object"?d:null},w=()=>{const d=_()?.v2TrackedChanges;return d&&typeof d=="object"?d:null},T=()=>{const d=_();if(d?.editorVersion!==2)return null;const p=d.reviewWindow;return p&&typeof p=="object"?p:null},L=()=>{const d=T();return!d||typeof d.getSnapshot!="function"?null:Pt(()=>d.getSnapshot(),null)},F=()=>typeof T()?.getSnapshot=="function",H=d=>{const p=d?.status;return p==="ready"||p==="stale"?p:"pending"},M=()=>{const d=_()?.host;return d&&typeof d=="object"?d:null},B=d=>{if(d.storyType!=="headerFooterPart"||typeof d.refId!="string")return null;const p=_(),b=M(),I=p?.pageLayout??b?.pageLayout;if(!I||typeof I!="object")return null;const x=I.getActiveRulerContext,V=b?.resolveHeaderFooterEditTarget;if(typeof x!="function"||typeof V!="function")return null;const W=Pt(()=>x.call(I),null);if(!W||typeof W.pageIndex!="number")return null;for(const re of["header","footer"]){const fe=Pt(()=>V.call(b,{pageIndex:W.pageIndex,kind:re}),null);if(!(fe?.status!=="ready"||fe.refId!==d.refId||typeof fe.sectionId!="string"||!["default","first","even"].includes(String(fe.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:fe.sectionId},headerFooterKind:re,variant:fe.slotVariant}}return null},q=()=>{const d=M(),p=d?.getPendingInlineFormat;if(typeof p!="function")return null;const b=Pt(()=>p.call(d),null);return b&&typeof b=="object"?b:null},P=d=>{const p=l2(d);if(!p)return null;const b=q();if(!b||!(p in b))return null;const I=b[p];return d.inline?.kind==="toggle"?I===!0:I!=null&&I!==""},N=d=>{const p=l2(d);if(!p)return;const b=q();if(!b||!(p in b))return;const I=b[p];if(typeof I=="string"&&I!=="")return I;if(typeof I=="number"&&Number.isFinite(I))return String(I)},E=(d,p)=>{const b=M(),I=b?.setPendingInlineFormat;typeof I=="function"&&Pt(()=>I.call(b,d,p),void 0)},j=d=>{const p=M(),b=p?.clearPendingInlineFormat;typeof b=="function"&&Pt(()=>b.call(p,d),void 0)},Q=new Set(["bold","italic","underline","strikethrough"]),Y=d=>{const p=q();if(!p)return;const b=Array.isArray(d.activeMarks)?d.activeMarks:[];let I=null;for(const x of Object.keys(p)){const V=p[x];let W;if(Q.has(x))W=b.includes(x)===(V===!0);else if(o2(x)){if(V==null)continue;I||(I=Vi(d)),W=I[x]===V}else W=!1;W&&j(x)}},se=()=>{const d=_()?.editCommands;return d&&typeof d=="object"?d:null},he=d=>{const p=se();if(!p||typeof p.getSnapshot!="function")return null;const b=Pt(()=>p.getSnapshot(),null)?.commands?.[d];return b&&typeof b=="object"?b:null},Ve=()=>he("lists.apply"),pe=d=>{const p=d?.value?.seed;return p==="bullet"||p==="ordered"?p:null},ye=d=>{const p=gV[d];return p?he(p):null},me=()=>{const d=M();if(!d||typeof d.getTableContext!="function")return null;const p=Pt(()=>d.getTableContext(),null);return p&&typeof p=="object"?p:null},_e=()=>{const d=me();if(!d||d.inTable!==!0)return null;const p=d.table,b=typeof p?.nodeId=="string"&&p.nodeId.length>0?p.nodeId:null;if(!b)return null;const I=d.row,x=d.column,V=d.cell,W=typeof I?.index=="number"&&Number.isInteger(I.index)?I.index:null,re=typeof x?.index=="number"&&Number.isInteger(x.index)?x.index:null;if(W==null||re==null)return null;const fe=typeof V?.nodeId=="string"&&V.nodeId.length>0?V.nodeId:null,Me=d.cellRange;return{tableNodeId:b,rowIndex:W,columnIndex:re,cellNodeId:fe,mergeRange:PV(Me)}},oe=new Map;let Re=null,je=null,et=0,St=0,Te=0;const He=new Set,Ye=(d,p)=>d===p?!0:!d||!p?!1:d.id===p.id&&d.paintedEntityId===p.paintedEntityId&&Cr(d.story)===Cr(p.story),ee=d=>Array.from(He).some(p=>Ye(p,d)),S=d=>{const p=M();if(typeof p?.getHandles!="function")return;const b=Pt(()=>p.getHandles(),null),I=b?.review;if(I){if(d){if(typeof I.setActiveReviewTarget!="function")return;const x=b?.layout;Pt(()=>I.setActiveReviewTarget({entityType:"trackedChange",entityId:d.id,...d.paintedEntityId?{paintedEntityId:d.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof x?.generation=="number"?x.generation:0,story:d.story??{kind:"story",storyType:"body"}}),null);return}typeof I.getActiveReviewTarget!="function"||typeof I.clearActiveReviewTarget!="function"||Pt(()=>I.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Pt(()=>I.clearActiveReviewTarget(),void 0)}},ne=(d,p)=>{je=d,et+=1,Te+=1,p?.invalidateQueuedNavigation!==!1&&(St+=1)},O=new Set;let U=!1,$=null;const z=new Map,J=new Set;let Z=null,G=null,be=!1,ve=null,Ce=0,De=null,Ze=null,ot=null;const yt=()=>{if(be||U)return;be=!0;const d=()=>{be=!1,U||bt()};typeof queueMicrotask=="function"?queueMicrotask(d):Promise.resolve().then(d)},tn=250,Ue=5e3,Ot=d=>{U||ve&&Ce<=d||(ve&&clearTimeout(ve),Ce=d,ve=setTimeout(()=>{ve=null,Ce=0,U||bt()},Math.max(0,d-Date.now())))},Bt=new WeakMap;let an=0;const nr=d=>{if(!d)return"none";let p=Bt.get(d);return p==null&&(p=an+=1,Bt.set(d,p)),`e${p}`};let qt=0;const Qe=e.superdoc,It=Wz(Qe),Ht=()=>{It.abortController.abort("review-mutation-started"),It.inFlight=null},wn=()=>{It.generation+=1,It.abortController=new AbortController,It.inFlight=null},nn=d=>{const p=It.activeMutationTokens;if(typeof d!="string"||d.length===0||p.has(d))return;const b=p.size===0;p.add(d),b&&Ht()},un=d=>{const p=It.activeMutationTokens;typeof d!="string"||!p.delete(d)||p.size===0&&wn()},Wn=d=>{const p=w(),b=p?.listTrackedChanges;if(typeof b!="function")return _()?.editorVersion===2?Promise.reject(new Error("v2-tracked-changes-bridge-pending")):d();if(It.activeMutationTokens.size>0)return Promise.reject(new Error("ui-review-catalog-superseded"));const I=It.generation,x=It.inFlight;if(x?.generation===I)return x.promise;const V=It.abortController.signal,W=Me=>{if(V.aborted||I!==It.generation||Me?.reason==="review-hydration-superseded")throw new Error("ui-review-catalog-superseded");return Me},re=b.call(p,{blocking:!1,signal:V});if(!xr(re))return W(re);const fe=Promise.resolve(re).then(W);return It.inFlight={generation:I,promise:fe},fe.then(()=>{It.inFlight?.promise===fe&&(It.inFlight=null)},()=>{It.inFlight?.promise===fe&&(It.inFlight=null)}),fe};let Xn=null,Er=new Set,Kn=null,Cn=0,lr=null;const ln=()=>`${nr(_())}|m${qt}`,Co=()=>{Xn=null,Er=new Set},Ie=d=>{for(const p of["trackChanges","trackChanges:all"]){const b=z.get(p);if(!b?.hasSettled||!Array.isArray(b.value))continue;const I=b.value.filter(x=>{const V=lo(x);return!V||!d.has(V)});I.length!==b.value.length&&z.set(p,{...b,value:I})}},Be=d=>{const p=()=>{if(!U)for(const V of[...O])V(qe)},b=Ff(d)?d:null,I=_()?.documentMutationReadiness,x=()=>{const V=globalThis.requestAnimationFrame;return typeof V!="function"?Promise.resolve():new Promise(W=>{let re=!1;const fe=()=>{re||(re=!0,clearTimeout(Me),W())},Me=setTimeout(fe,250);V(()=>V(()=>setTimeout(fe,0)))})};if(b?.success===!0&&typeof b.txId=="string"&&b.txId.length>0&&typeof I?.whenPainted=="function")try{Promise.resolve(I.whenPainted.call(I,b)).then(x,()=>{}).then(p,p);return}catch{}p()},tt=(d,p)=>{const b=qe.trackChanges,I=b.items.filter(W=>{const re=lo(W);return!re||!d.has(re)});if(I.length===b.items.length)return;je&&d.has(je.id)&&ne(null);const x=new Set;for(const W of I){const re=fm(W),fe=W,Me=re.author??re.authorEmail??fe.author??fe.authorEmail;typeof Me=="string"&&x.add(Me)}const V=b.items.length-I.length;qe={...qe,trackChanges:{...b,items:I,total:Math.max(I.length,b.total-V),activeId:b.activeId&&d.has(b.activeId)?null:b.activeId,authors:[...x]}},Be(p)},ft=d=>{const p=qe.trackChanges,b=p.items.length>0||p.total!==0||p.activeId!==null||p.authors.length>0;Kn=ln(),je!==null&&ne(null),qe={...qe,trackChanges:{...p,items:[],total:0,activeId:null,authors:[]}},b&&Be(d)},Lt=(d,p)=>{if(d.size===0)return;const b=ln(),I=Xn===b?Er:new Set,x=new Set([...d].filter(V=>!I.has(V)));x.size!==0&&(Xn=b,Er=new Set([...I,...x]),Ie(Er),tt(x,p))},Dt=d=>Xn===d&&Er.size>0?Er:null,bn=d=>{const p=ln(),b=Dt(p),I=d.map(Of).filter(x=>{if(x==null)return!1;const V=lo(x);return V!=null&&!b?.has(V)});for(const x of["trackChanges","trackChanges:all"])z.set(x,{token:p,value:[...I],hasSettled:!0,inflightToken:null})},Wt=()=>`${ln()}|m${Qn()}|s${Cn}`,Zn=d=>JSON.stringify({t:d.target??null,s:d.selectionTarget??null}),ko=["contentControls:inRange:","query:","effInline:"],ri=120,oi=180,Qt=()=>{const d=M(),p=d?.getDocumentLoadingSnapshot;if(typeof p!="function")return"unknown";const b=Pt(()=>p.call(d),null)?.sourceStage;return b==="opening"||b==="bootstrap-ready"||b==="source-loading"?"loading":b==="source-complete"||b==="source-failed"||b==="source-cancelled"?"complete":"unknown"},cn=new Map,Rn=new Map,Tr=new Map;let Yt=null,Tn=0,Ur=0;const co=d=>{const p=ln();cn.get(d)!==p&&(cn.set(d,p),yt())},Bs=()=>{const d=z.get("comments");return d?.hasSettled?Array.isArray(d.value)&&d.value.length>0:d?.inflightToken!=null},ac=(d,p)=>cn.get(d)===p,zs=()=>{const d=ln();let p=!1;for(const[b,I]of Rn){if(I!==d){Rn.delete(b);continue}if(Tr.get(b)===d)continue;const x=z.get(b);!x?.hasSettled||x.token!==d||x.inflightToken!=null||(z.set(b,{...x,token:null,inflightToken:null}),Tr.set(b,d),p=!0)}p&&yt()},Si=d=>{d==="comments"?Tn+=1:Ur+=1,co(d);let p=!1;return()=>{p||(p=!0,d==="comments"?Tn=Math.max(0,Tn-1):Ur=Math.max(0,Ur-1),(d==="comments"?Tn:Ur)===0&&cn.get(d)===ln()&&cn.delete(d),yt())}},ii=d=>{co("contentControls")},we=()=>{const d=z.get("trackChanges");d?.hasSettled||d?.inflightToken!=null||co("trackChanges")},ze=()=>{const d=z.get("comments");d?.hasSettled||d?.inflightToken!=null||co("comments")},kt=6500,lt=250;let Ln=0,On=0,kr=!1,Hr=null;const jo=()=>{if(U||Hr)return;const d=()=>{if(Hr=null,U)return;const p=Date.now()-Ln;if(Xr()||p<kt){Hr=setTimeout(d,lt);return}kr=!1,bt()};Hr=setTimeout(d,0)};let Uo=null,yr=null;const Di=()=>{const d=M();if(!d||Uo===d)return;yr&&(yr(),yr=null),Uo=d;const p=d.subscribeDocumentLoading;if(typeof p!="function"){Uo=null,So(kt);return}try{const b=V=>{const W=V?.sourceStage;(W==="source-complete"||W==="source-failed"||W==="source-cancelled")&&(Yt=ln(),zs(),Ln=Math.max(Ln,Date.now()),jo())},I=p.call(d,b);typeof I=="function"&&(yr=I);const x=d.getDocumentLoadingSnapshot;typeof x=="function"&&b(Pt(()=>x.call(d),null))}catch{Uo=null,So(kt)}},Br=()=>{const d=_()?.host,p=d?.getForegroundMutationState;if(typeof p!="function")return null;const b=Pt(()=>p.call(d),null);return{active:typeof b?.active=="number"?b.active:0,pending:typeof b?.pending=="number"?b.pending:0}},Xr=()=>{const d=Br();return!!(d&&(d.active>0||d.pending>0))},So=(d=ri)=>{U||De||(De=setTimeout(()=>{if(De=null,U)return;if(Ze&&Xr()){So(),bt();return}const p=Ze;Ze=null,p===Wt()&&Vs("selection",p,La,Ni),bt()},d))},_o=(d,p)=>{if(!Br())return!1;const b=`${d}\0${p}`;return J.has(b)?!1:(J.add(b),So(oi),!0)},rs=d=>{if(Z==null||d===Z)return G?.timer&&clearTimeout(G.timer),G=null,Z=d,!1;if(G?.key===d)return G.ready?(G=null,Z=d,!1):!0;G?.timer&&clearTimeout(G.timer);const p={key:d,ready:!1,timer:null};return p.timer=setTimeout(()=>{U||G!==p||(p.timer=null,p.ready=!0,bt())},oi),G=p,!0},_i=d=>Bz(d),si=()=>{ai(),bt()};let os=null,Oi=!1,Fi=0;const ml=()=>{os=null,Oi=!1,Fi+=1},gl=()=>{const d=_(),p=d?.documentMutationReadiness;if(!d||typeof p?.whenPainted!="function"||(os={editor:d,readiness:p,afterEpoch:typeof p.getRenderEpoch=="function"?Pt(()=>p.getRenderEpoch.call(p),null):null},Oi))return;Oi=!0;const b=Fi;(async()=>{for(;!U&&b===Fi;){const x=os;if(os=null,!x){Oi=!1;return}let V=!1;try{await x.readiness.whenPainted.call(x.readiness,typeof x.afterEpoch=="number"?{afterEpoch:x.afterEpoch}:void 0),V=!0}catch{}if(U||b!==Fi)return;if(_()!==x.editor){ml();return}V&&si()}})()},vl=()=>{ot&&clearTimeout(ot),ot=setTimeout(()=>{ot=null,U||si()},500)},Vs=(d,p,b,I)=>{let x;try{x=b()}catch{x=void 0}if(!xr(x)){const re={token:p,value:I(x),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return z.set(d,re),re}const V=z.get(d),W=V?.failedToken===p;return z.set(d,{token:V?.token??null,value:V?.value??null,hasSettled:V?.hasSettled??!1,inflightToken:p,failedToken:W?p:null,failureCount:W?V.failureCount??0:0,retryAtMs:0}),Promise.resolve(x).then(re=>{const fe=z.get(d);!fe||fe.inflightToken!==p||(z.set(d,{token:p,value:I(re),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0}),yt())},()=>{const re=z.get(d);if(!re||re.inflightToken!==p)return;const fe=re.failedToken===p?(re.failureCount??0)+1:1,Me=Math.min(Ue,tn*2**Math.min(fe-1,8)),$e=Date.now()+Me;z.set(d,{...re,inflightToken:null,failedToken:p,failureCount:fe,retryAtMs:$e}),Ot($e)}),null},uo=(d,p,b,I)=>{const x=z.get(d);if(x&&x.token===p&&x.hasSettled)return{value:x.value,status:"ready"};if(nV(d)&&!ac(d,p)){if(Qt()==="loading")return kr=!0,Di(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(kr)return jo(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(Date.now()-On<kt)return kr=!0,jo(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"}}if(Xr())return So(),x?.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(x?.failedToken===p&&x.inflightToken==null&&(x.retryAtMs??0)>Date.now())return Ot(x.retryAtMs),x.hasSettled?{value:x.value,status:"stale"}:{value:null,status:"pending"};if(!x&&d.startsWith("effInline:")&&rs(d))return{value:null,status:"pending"};if(!x&&_o(d,p))return{value:null,status:"pending"};if(!x||x.inflightToken!==p){const W=Vs(d,p,b,I);if(W)return{value:W.value,status:"ready"}}const V=z.get(d);return V?.hasSettled?{value:V.value,status:"stale"}:{value:null,status:"pending"}},js=d=>{for(const p of z.keys())d(p)&&z.delete(p)},Nf=d=>{const p=Zn(d),b=bA(d);return new Set([`contentControls:inRange:${p}`,`query:${p}`,...b?[`effInline:${b}`]:[]])},yl=d=>{const p=Nf(d);js(b=>ko.some(I=>b.startsWith(I))&&!p.has(b));for(const b of J){const I=b.split("\0",1)[0];ko.some(x=>I.startsWith(x))&&!p.has(I)&&J.delete(b)}},_u=()=>{const d=_();d!==lr&&(ml(),lr=d,z.clear(),ve&&clearTimeout(ve),ve=null,Ce=0,G?.timer&&clearTimeout(G.timer),G=null,Z=null,C=null,o=null,Ze=null,J.clear(),cn.clear(),Rn.clear(),Tr.clear(),Yt=null,kr=!1,yr&&yr(),yr=null,Uo=null,Co(),Kn=null)},ai=()=>{qt+=1,Rn.clear(),Tr.clear(),Yt=null,Co()},Us=()=>{const d=Kn===ln();ai(),d&&(bn([]),Kn=ln()),bt()},Au=d=>{if(typeof d!="string"||d.length===0)return Yn("insertText requires a non-empty string.","INVALID_INPUT");if(Qn()==="viewing")return Yn("The document is read-only.","DOCUMENT_READONLY");const p=y(),b=p?.insert;if(!p||typeof b!="function")return Yn("insert is unavailable.");const I=p.selection?.current;if(typeof I!="function")return Yn("selection.current is unavailable.");const x=W=>{const re=W&&typeof W=="object"?W:null,fe=re?.selectionTarget??re?.target??null;return!fe||typeof fe!="object"?Yn("insertText requires a live selection target.","PRECONDITION_FAILED"):Pt(()=>xl(b.call(p,{type:"text",value:d,target:fe}),Yn("insert failed.")),Yn("insert failed."))};let V;try{V=I.call(p.selection)}catch{return Yn("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return xr(V)?Promise.resolve(V).then(x,()=>Yn("insertText could not resolve the live selection.","PRECONDITION_FAILED")):x(V)},lc=(d,p)=>({payload:d,state:qe,editor:_(),superdoc:t,context:p,ui:$,execute:(b,I)=>bc(b,I),executeAsync:(b,I)=>xm(b,I),doc:y(),selection:qe.selection,documentMode:Qn(),insertText:Au}),cc=d=>d==="editing"||d==="suggesting"||d==="viewing"?d:null,Qn=()=>{const d=_(),p=t&&typeof t=="object"?t:null,b=cc(p?.config?.documentMode),I=Pt(typeof p?.getActiveRuntime=="function"?()=>{const W=p.getActiveRuntime();return typeof W?.getSnapshot=="function"?W.getSnapshot():null}:void 0,null),x=cc(I?.documentMode),V=cc(d?.options?.documentMode);return b&&x&&b!==x?b:x??b??V},uc=()=>{const d=t&&typeof t=="object"?t:null,p=d?.interactionConfig?.comments;if(p&&typeof p.readOnly=="boolean")return p.readOnly===!0;const b=d?.config?.modules?.comments;return!!b&&typeof b=="object"&&b.readOnly===!0},Bf=()=>{const d=t&&typeof t=="object"?t:null,p=d?.interactionConfig?.comments;if(p&&typeof p.allowResolve=="boolean")return p.allowResolve===!1;const b=d?.config?.modules?.comments;return!!b&&typeof b=="object"&&b.allowResolve===!1},Ao=()=>Qn()==="viewing"||uc(),Ni=d=>d&&typeof d=="object"?d:null,Hs=(d,p)=>{if(!d)return{...Jz,status:p};const b=d.target??null,I=typeof d.text=="string"?d.text:"";return{status:p,empty:d.empty===!0,target:b,selectionTarget:d.selectionTarget??null,activeMarks:Array.isArray(d.activeMarks)?d.activeMarks:[],activeCommentIds:Array.isArray(d.activeCommentIds)?d.activeCommentIds:[],activeChangeIds:Array.isArray(d.activeChangeIds)?d.activeChangeIds:[],quotedText:I}},Ra=()=>{const d=y()?.selection;return uo("selection",Wt(),()=>d?.current?d.current({includeText:!0}):void 0,Ni)},bl=()=>{const{value:d,status:p}=Ra();return Hs(d,p)},La=()=>{const d=y()?.selection;return d?.current?d.current({includeText:!0}):void 0},Iu=d=>{if(d.empty!==!0)return!1;const p=d.selectionTarget,b=p?.start,I=p?.end;return b?.kind==="text"&&I?.kind==="text"&&typeof b.blockId=="string"&&b.blockId===I.blockId&&typeof b.offset=="number"&&b.offset===I.offset},dc=d=>{const p=M(),b=p?.readLiveSelectionSyncSnapshot;if(typeof b!="function")return;const I=Ni(Pt(()=>b.call(p),null));if(!I||!Iu(I))return;const x=Wt(),V=Br(),W=!!(V&&(V.active>0||V.pending>0));if(W)Ze=x,So();else if(Ze=null,Vs("selection",x,La,Ni))return;const re=z.get("selection"),fe=Array.isArray(I.activeMarks)&&I.activeMarks.length>0?I.activeMarks:Array.isArray(qe.selection.activeMarks)?qe.selection.activeMarks:[],Me=Array.isArray(I.activeCommentIds)?I.activeCommentIds:[],$e=sV(d),We=hl(qe.selection),Je=Pf(I.selectionTarget)??Pf(I.target),nt=We?.range,Ge=Je?.range,rt=!!(V&&V.active>0&&We&&Je&&We.blockId===Je.blockId&&Cr(We.story)===Cr(Je.story)&&typeof nt?.start=="number"&&typeof Ge?.start=="number"&&Math.abs(Ge.start-nt.start)<=2),ht=$e!=null||rt?qe.selection.activeChangeIds.filter(it=>$e==null||Os(qe.trackChanges.items).aliasesFor(it).includes($e)):[],dt=Array.isArray(I.activeChangeIds)&&I.activeChangeIds.length>0?I.activeChangeIds:ht;z.set("selection",{token:x,value:{...I,activeMarks:fe,activeCommentIds:Me,activeChangeIds:dt},hasSettled:!0,inflightToken:W?null:re?.inflightToken??null})},$s=async(d=0)=>{const p=y()?.selection,b=p?.current,I=Wt();if(typeof b!="function")return z.set("selection",{token:I,value:null,hasSettled:!0,inflightToken:null}),bt(),qe.selection;let x;try{x=b.call(p,{includeText:!0}),xr(x)&&(x=await Promise.resolve(x))}catch{x=null}return U?Hs(null,"pending"):Wt()!==I?d<1?$s(d+1):qe.selection:(z.set("selection",{token:I,value:Ni(x),hasSettled:!0,inflightToken:null}),bt(),qe.selection)},is=()=>{const d=y()?.comments;return uo("comments",ln(),()=>d?.list?d.list():void 0,p=>p&&Array.isArray(p.items)?p.items:[])},Ma=(d="trackChanges")=>{const p=ln(),b=y()?.trackChanges,I=w(),x=typeof I?.listTrackedChanges=="function"?I.listTrackedChanges:null,V=uo(d,p,()=>x?Wn(()=>b?.list?.({in:"all"})):b?.list?b.list({in:"all"}):void 0,W=>{const re=W&&typeof W=="object"?W:null;if(re?.complete===!1||re?.sourceCoverageComplete===!1){if(Rn.set(d,p),Di(),Yt===p||Qt()==="complete"){const fe=()=>{U||zs()};typeof queueMicrotask=="function"?queueMicrotask(fe):Promise.resolve().then(fe)}}else Rn.get(d)===p&&Rn.delete(d);return re&&Array.isArray(re.items)?re.items:[]});return Rn.get(d)===p&&V.status==="ready"?{...V,status:"stale"}:V},xu=d=>{const p=L(),b=F(),I=b?null:is(),x=b&&Array.isArray(p?.commentItems)?p.commentItems:null,V=b?x:I.value,W=b?H(p):I.status,re=V??[],fe=d.activeCommentIds,Me=z.get("comments"),$e=Me?.token===ln()&&Me.hasSettled&&Array.isArray(Me.value)?Me.value:null,We=Tn>0?$e:re;Re&&We&&!We.some(nt=>lo(nt)===Re)&&(Re=null);const Je=Re??fe[0]??null;return{status:fl(W,d.status),listStatus:W,items:re,total:re.length,activeIds:fe,activeId:Je}},Eu=new WeakMap,Gs=d=>{const p=Eu.get(d);if(p)return p;const b=d.map(Of).filter(I=>I!=null);return Eu.set(d,b),b},Pa=new WeakMap,Da=(d,p)=>{const b=Pa.get(d);if(b?.suppressedIds===p)return b.value;const I=p?d.filter(x=>{const V=lo(x);return!V||!p.has(V)}):d;return Pa.set(d,{suppressedIds:p,value:I}),I},wl=new WeakMap,Rr=d=>{const p=wl.get(d);if(p)return p;const b=new Set;for(const x of d){const V=fm(x),W=x,re=V.author??V.authorEmail??W.author??W.authorEmail;typeof re=="string"&&b.add(re)}const I=[...b];return wl.set(d,I),I},Bi=()=>{const d=ln();if(F()){const I=z.get("trackChanges"),x=I?.token===d&&I.hasSettled&&Array.isArray(I.value)?I.value:L()?.trackedChangeItems;return Array.isArray(x)?Gs(x):null}const{value:p,status:b}=Ma("trackChanges:all");return b==="ready"?Gs(p??[]):null},Cl=d=>{const p=ln(),b=Dt(p),I=L(),x=F(),V=x?null:Ma(),W=x&&Array.isArray(I?.trackedChangeItems)?I.trackedChangeItems:null,re=x?W:V.value,fe=x?H(I):V.status,Me=Da(Gs(re??[]),b),$e=Bi(),We=je;if(We&&!He.has(We)){const Vt=z.get("trackChanges"),Hn=Vt?.token===p&&Vt.hasSettled&&Array.isArray(Vt.value)?Da(Gs(Vt.value),b):null,$n=Ur>0?Hn:We.story?$e:Me;$n&&!$n.some(Gr=>Ji(Gr,We.id,We.story))&&ne(null)}const Je=$e??Me,nt=oc(Je,es(d)),Ge=Kn===p?[]:b?d.activeChangeIds.filter(Vt=>!b.has(Vt)):d.activeChangeIds,rt=Ge.map(Vt=>nt.toPublicId(Vt)??Vt),ht=je?.story?oc(Je,je.story):Os(Je),dt=je?ht.toPublicId(je.id)??je.id:null,it=uV({selectionIds:Ge,publicIds:rt,selection:d,bodyItems:Me,allStoryItems:$e}),zt=dt??it;return{status:fl(fe,d.status),items:Me,total:Me.length,activeId:zt,authors:Rr(Me)}},fc=(d,p)=>{if(!F())return p;co("comments");const b=is(),I=b.value??p.items;return{status:fl(b.status,d.status),listStatus:b.status,items:I,total:I.length,activeIds:d.activeCommentIds,activeId:Re??d.activeCommentIds[0]??null}},Tu=(d,p)=>{if(!F())return p;co("trackChanges");const b=Ma(),I=Dt(ln()),x=Da(Gs(b.value??p.items),I),V=je?.story?oc(x,je.story):Os(x),W=je?V.toPublicId(je.id)??je.id:p.activeId;return{status:fl(b.status,d.status),items:x,total:x.length,activeId:W,authors:Rr(x)}},zi=d=>{const p=y()?.contentControls,{value:b,status:I}=uo("contentControls",ln(),()=>p?.list?p.list():void 0,re=>re&&Array.isArray(re.items)?re.items:[]),x=b??[],{ids:V,status:W}=Ru(p,d);return{status:fl(I,W,d.status),items:x,total:x.length,activeId:V[0]??null,activeIds:V}},ss=(d,p)=>{if(!d||typeof d.listInRange!="function")return{lockModesById:new Map,status:"ready"};const b=fV(p);if(!b)return{lockModesById:new Map,status:"ready"};const{value:I,status:x}=uo(`contentControls:inRange:${Zn(p)}`,ln(),()=>d.listInRange(b),re=>re&&Array.isArray(re.items)?re.items:[]),V=I??[],W=new Map;for(const re of V)typeof re?.id=="string"&&W.set(re.id,typeof re.lockMode=="string"?re.lockMode:"unlocked");return{lockModesById:W,status:x}},Ru=(d,p)=>{const{lockModesById:b,status:I}=ss(d,p);return{ids:[...b.keys()],status:I}},zf=()=>{const d=t?.fonts;return{options:VV(BV(Pt(d?.getDocumentFontOptions?()=>d.getDocumentFontOptions():void 0,[])),zV(Pt(d?.getFontFamilyOptions?()=>d.getFontFamilyOptions():void 0,[]))),sizeOptions:jV}},hc=()=>{const d=Pt(t?.getZoomState?()=>t.getZoomState():void 0,null),p=typeof d?.value=="number"?d.value:100,b=d?.mode;return{mode:b==="manual"||b==="fit-width"?b:b==="fixed"?"manual":null,value:p,min:typeof d?.min=="number"?d.min:10,max:typeof d?.max=="number"?d.max:100}},Lu=()=>Pt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",Mu=()=>{const d=_();return{ready:d!=null,mode:Qn(),dirty:d?!!d.isDirty:!1}},pc=d=>{const p=d.quotedText;if(typeof p!="string"||p.length===0)return null;const b=ku(d);if(b.length===0||!ic(b.map(V=>V.blockId)))return null;const I=d.target,x=b.length===1?bo(b[0].blockId,I?.story):void 0;return{select:{type:"text",pattern:p,mode:"contains",caseSensitive:!0},...x?{within:x}:{},require:"any"}},Pu=d=>{const p=y()?.query;if(typeof p?.match!="function")return null;const b=pc(d);if(!b)return null;const{value:I}=uo(`query:${Zn(d)}`,ln(),()=>p.match(b),x=>x&&typeof x=="object"?x:null);return wA(I,d)},Vf=d=>{const p=M(),b=new Set(Nr(d));if(b.size===0)return{};const I=p?.readMountedProjectionBlocksByIds,x=p?.readMountedProjectionBlocks;if(typeof I!="function"&&typeof x!="function")return{};const V=Pt(()=>{if(typeof I!="function")return x.call(p);const rt=ts(d);return rt?I.call(p,[...b],rt):I.call(p,[...b])},null);if(!Array.isArray(V))return{};const W=a2(V),re=rt=>{const ht={},dt=i2(rt.fontFamily);dt&&(ht.fontFamily=dt);const it=SV(rt.fontSize);return it&&(ht.fontSize=it),typeof rt.color=="string"&&rt.color.trim()!==""&&(ht.color=rt.color.trim().toUpperCase()),typeof rt.highlight=="string"&&rt.highlight.trim()!==""&&(ht.highlight=rt.highlight.trim().toUpperCase()),ht},fe=hl(d),Me=fe&&typeof fe.range?.start=="number"?fe.range.start:null;if(fe&&Me!==null&&b.has(fe.blockId)){const rt=W.find(dt=>sc(dt,fe.blockId)),ht=rt&&Array.isArray(rt.runs)?rt.runs:null;if(ht&&ht.length>0&&ht.every(dt=>dt?.kind==="text"||dt?.kind==="tab")){let dt=0,it=null;for(const zt of ht){const Vt=pm(zt);if(Me>=dt&&Me<dt+Vt){it=zt;break}dt+=Vt}if(!it){for(let zt=ht.length-1;zt>=0&&!it;zt-=1)ht[zt]?.kind==="text"&&(it=ht[zt]);it??=ht[ht.length-1]??null}return it?re(it):{}}}const $e=ku(d);if($e.length>0){const rt=new Set,ht=new Set;let dt=!1,it=!0;for(const zt of $e){const Vt=W.find(Gr=>sc(Gr,zt.blockId));if(!Vt)return{};const Hn=Array.isArray(Vt.runs)?Vt.runs:[];if(Hn.length===0)continue;if(!Hn.every(Gr=>Gr?.kind==="text"||Gr?.kind==="tab")){it=!1;break}let $n=0;for(const Gr of Hn){const Wr=pm(Gr),Sr=$n,Mr=$n+Wr;if(Sr<zt.end&&Mr>zt.start){dt=!0;const Yo=re(Gr);Yo.fontFamily&&rt.add(Yo.fontFamily),Yo.fontSize&&ht.add(Yo.fontSize)}$n=Mr}}if(it&&dt){const zt={};return rt.size===1&&(zt.fontFamily=[...rt][0]),ht.size===1&&(zt.fontSize=[...ht][0]),zt}}const We=new Set,Je=new Set;let nt=!1;for(const rt of W){if(![...b].some(dt=>sc(rt,dt)))continue;const ht=Array.isArray(rt.runs)?rt.runs:[];for(const dt of ht){if(dt?.kind!=="text")continue;nt=!0;const it=re(dt);it.fontFamily&&We.add(it.fontFamily),it.fontSize&&Je.add(it.fontSize)}}if(!nt)return{};const Ge={};return We.size===1&&(Ge.fontFamily=[...We][0]),Je.size===1&&(Ge.fontSize=[...Je][0]),Ge},Du=d=>{const p=M(),b=new Set(Nr(d));if(b.size===0)return{};const I=p?.readMountedProjectionBlocksByIds,x=p?.readMountedProjectionBlocks;if(typeof I!="function"&&typeof x!="function")return{};const V=Pt(()=>{if(typeof I!="function")return x.call(p);const Ge=ts(d);return Ge?I.call(p,[...b],Ge):I.call(p,[...b])},null);if(!Array.isArray(V))return{};const W=a2(V),re=Ge=>({bold:Ge.bold===!0,italic:Ge.italic===!0,underline:Ge.underline!=null,strikethrough:Ge.strike===!0}),fe=Ge=>{const rt={};for(const ht of Df){const dt=Ge[ht];dt.size===1&&(rt[ht]=[...dt][0])}return rt},Me=hl(d),$e=Me&&typeof Me.range?.start=="number"?Me.range.start:null;if(Me&&$e!==null&&b.has(Me.blockId)){const Ge=W.find(ht=>sc(ht,Me.blockId)),rt=Ge&&Array.isArray(Ge.runs)?Ge.runs:null;if(rt&&rt.length>0&&rt.every(ht=>ht?.kind==="text"||ht?.kind==="tab")){let ht=0,dt=null;for(const it of rt){const zt=pm(it);if($e>=ht&&$e<ht+zt){dt=it;break}ht+=zt}if(!dt){for(let it=rt.length-1;it>=0&&!dt;it-=1)rt[it]?.kind==="text"&&(dt=rt[it]);dt??=rt[rt.length-1]??null}return dt?re(dt):{}}}const We=ku(d);if(We.length>0){const Ge={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let rt=!1,ht=!0;for(const dt of We){const it=W.find(Hn=>sc(Hn,dt.blockId));if(!it)return{};const zt=Array.isArray(it.runs)?it.runs:[];if(zt.length===0)continue;if(!zt.every(Hn=>Hn?.kind==="text"||Hn?.kind==="tab")){ht=!1;break}let Vt=0;for(const Hn of zt){const $n=pm(Hn),Gr=Vt,Wr=Vt+$n;if(Gr<dt.end&&Wr>dt.start){rt=!0;const Sr=re(Hn);for(const Mr of Df)Ge[Mr].add(Sr[Mr])}Vt=Wr}}if(ht&&rt)return fe(Ge)}const Je={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let nt=!1;for(const Ge of W){if(![...b].some(ht=>sc(Ge,ht)))continue;const rt=Array.isArray(Ge.runs)?Ge.runs:[];for(const ht of rt){if(ht?.kind!=="text")continue;nt=!0;const dt=re(ht);for(const it of Df)Je[it].add(dt[it])}}return nt?fe(Je):{}},mc=(d,p)=>{if(p.fontFamily!==void 0&&p.fontSize!==void 0&&p.color!==void 0&&p.highlight!==void 0)return{values:p,effectiveUniformityStatus:"ready"};const b=Vf(d),I={...b.fontFamily!==void 0?{fontFamily:b.fontFamily}:{},...b.fontSize!==void 0?{fontSize:b.fontSize}:{},...b.color!==void 0?{color:b.color}:{},...b.highlight!==void 0?{highlight:b.highlight}:{},...p};if(!d.empty&&(I.fontFamily===void 0||I.fontSize===void 0)){const x=Uf(d);return x.values&&(I.fontFamily===void 0&&x.values.fontFamily!==void 0&&(I.fontFamily=x.values.fontFamily),I.fontSize===void 0&&x.values.fontSize!==void 0&&(I.fontSize=x.values.fontSize)),{values:I,effectiveUniformityStatus:x.status}}return{values:I,effectiveUniformityStatus:"ready"}},jf=["fontFamily","fontSize","bold","italic","underline","strikethrough"],gc=d=>{const p=d.selectionTarget;if(!p)return{value:null,status:"ready"};const b=vr(y(),"format.readEffectiveInlineUniformity");if(!b)return{value:null,status:"ready"};const I=bA(d)??Zn(d);return uo(`effInline:${I}`,ln(),()=>b({target:p,offsetSpace:"selection",keys:jf}),x=>x&&typeof x=="object"?x:null)},Uf=d=>{const{value:p,status:b}=gc(d);if(!p||p.success!==!0)return{values:null,status:b};const I=p.values,x=V=>{const W=I?.[V];if(!(!W||W.state!=="uniform"||typeof W.value!="string"))return V==="fontFamily"?i2(W.value):W.value};return{values:{fontFamily:x("fontFamily"),fontSize:x("fontSize")},status:b}},li=d=>{const{value:p,status:b}=gc(d);if(!p||p.success!==!0)return{values:null,status:b};const I=p.values,x={};for(const V of Df){const W=I?.[V];W?.state==="uniform"&&(W.value==="true"||W.value==="false")&&(x[V]=W.value==="true")}return{values:x,status:b}},vc=(d,p)=>{const b=d.activeMark;if(!b||!Df.includes(b))return null;const I=b,x=Du(p)[I];if(x!==void 0)return x;const{values:V}=li(p),W=V?.[I];return W!==void 0?W:null},kl=async d=>{const p=d.selectionTarget;if(!p)return null;const b=vr(y(),"format.readEffectiveInlineUniformity");if(!b)return null;try{const I=await Promise.resolve(b({target:p,offsetSpace:"selection"}));return I&&typeof I=="object"&&I.success===!0?I:null}catch{return null}},Hf=(d,p,b)=>{const I=b.values;for(const x of["fontFamily","fontSize"]){if(p[x]!==void 0)continue;const V=I?.[x];V?.state==="uniform"&&typeof V.value=="string"?d[x]=x==="fontFamily"?i2(V.value):V.value:delete d[x]}},Ou=d=>mc(d,CA(Pu(d),d)),Vi=d=>Ou(d).values,$f=async d=>{const p=y()?.query,b=pc(d);if(typeof p?.match!="function"||!b)return Vi(d);try{const I=await Promise.resolve(p.match(b)),x=CA(wA(I&&typeof I=="object"?I:null,d),d),V=mc(d,x);if(V.effectiveUniformityStatus!=="ready"&&(x.fontFamily===void 0||x.fontSize===void 0)){const W=await kl(d);W&&Hf(V.values,x,W)}return V.values}catch{return Vi(d)}},Sl=async d=>{const p=y();if(p)return typeof p.getNode=="function"?await Promise.resolve(p.getNode(d)):await Promise.resolve(p.getNodeById?.({nodeId:d.nodeId,nodeType:d.nodeType}))},Fu=d=>{const p=y()?.query;if(typeof p?.match!="function")return"ready";const b=pc(d);if(!b)return"ready";const{status:I}=uo(`query:${Zn(d)}`,ln(),()=>p.match(b),x=>x&&typeof x=="object"?x:null);return I},Nu=d=>{const p=Ou(d),b=p.values;if(d.empty)return p;const I=Ta(d);return I?d.status==="ready"&&Fu(d)==="ready"&&p.effectiveUniformityStatus==="ready"?(C={key:I,values:b},p):C&&C.key===I?{...p,values:{...C.values,...b}}:p:p},Bu=d=>{const p=y(),b=Nu(d),I=b.values;d.status==="ready"&&!d.empty&&Fu(d)==="ready"&&b.effectiveUniformityStatus==="ready"&&(v=I,k=`${nc(d)}:${ln()}`);const x=p?.contentControls,{lockModesById:V}=ss(x,d),W={};for(const re of kn())W[re]=Uu(re,p,d,I,V);return W},ji=d=>d?ct.operationUnavailable:_()?ct.documentApiUnavailable:ct.notReady,Ws=d=>d==="contentLocked"||d==="sdtContentLocked",ci=d=>{for(const p of d.values())if(Ws(p))return ct.contentControlLocked},zu=(d,p,b,I,x)=>{if(!p)return d.scope==="all"?ct.bulkDecisionsDisabled:ji(x);if(b)return ct.documentReadonly;if(d.scope!=="all"&&I.activeChangeIds.length===0)return ct.selectionRequired},Vu=d=>{const p=M(),b=Pt(typeof p?.getCapabilities=="function"?()=>p.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(b))return b.find(I=>I?.command===d||I?.id===d)??null;if(b&&typeof b=="object"){const I=b[d];return I&&typeof I=="object"?I:null}return null},ju=(d,p)=>{if(d.scope!=="all"||typeof p?.[`${d.kind}All`]=="function")return;const b=Vu(`trackedChanges.${d.kind}All`);if(!(b&&(b.status==="supported"||b.enabled===!0)))return ct.bulkDecisionsDisabled},Uu=(d,p,b,I,x=new Map)=>{if(oe.has(d))return on({supported:!0,enabled:!0,...Pt(oe.get(d).getState?()=>oe.get(d).getState(lc(void 0)):void 0,{})},"custom");const V=Qn()==="viewing",W=cA(d);if(W&&typeof se()?.lists?.apply=="function"){const nt=Ve(),Ge=typeof nt?.shippedStatus=="string"?nt.shippedStatus:null,rt=Ge!=="not-shipped"&&Ge!=="disabled";return on({enabled:rt&&(typeof nt?.enabled=="boolean"?nt.enabled:!0),active:(rt?pe(nt):null)===W,supported:rt,value:nt?.value},"builtin")}const re=mm(d);if(re){const nt=p?.trackChanges,Ge=typeof nt?.decide=="function"||typeof nt?.[re.kind]=="function",rt=typeof nt?.decide=="function"||typeof nt?.[`${re.kind}All`]=="function",ht=re.scope==="all"?rt:Ge,dt=ju(re,nt)??zu(re,ht,Ao(),b,p);return on({enabled:dt==null,active:!1,supported:ht,reason:dt},"builtin")}if(d==="copy-format")return Qn()==="viewing"?on({supported:!0,enabled:!1,active:!1},"builtin"):_()?on({supported:!0,enabled:!0,active:h.mode!=="idle"},"builtin"):on({supported:!0,enabled:!1,active:!1,reason:ct.notReady},"builtin");const fe=vu(d);if(!fe)return on({enabled:!1,active:!1,supported:!1,reason:ct.commandUnsupported},"unsupported");if(fe.disposition!=="routed")return on({enabled:!1,active:!1,supported:!1,reason:fe.reason??ct.commandUnsupported},fe.disposition==="unsupported"?"unsupported":"builtin");if(fe.instanceRoute)return ut(fe);if(fe.table)return Ct(fe,p,V);if(fe.inline?.kind==="clear"){if(fe.mutates&&V)return on({enabled:!1,active:!1,supported:!0,reason:ct.documentReadonly},"builtin");const nt=ci(x);if(nt)return on({enabled:!1,active:!1,supported:!0,reason:nt},"builtin");const Ge=Nr(b).length>0||Su(b)!=null;return on({enabled:Ge,active:!1,supported:!0,reason:Ge?void 0:ct.selectionRequired},"builtin")}const Me=fe.docRoute;if(!Me)return on({enabled:!1,active:!1,supported:!1,reason:ct.commandUnsupported},"unsupported");if(vr(p,Me)==null)return on({enabled:!1,active:!1,supported:!1,reason:ji(p)},"builtin");const $e=ye(d);if($e){const nt=$e.shippedStatus,Ge=nt!=="not-shipped"&&nt!=="disabled",rt=typeof $e.enabled=="boolean"?$e.enabled:!0,ht=d==="undo"||d==="redo",dt=ht&&$e.historyResolved===!1,it=ht&&Ge&&rt===!1&&$e.reason===null&&!dt,zt=$e.reason===void 0?void 0:it?ct.historyEmpty:dt?ct.notReady:e2($e.reason,ct.commandUnsupported);return fe.mutates&&V?on({enabled:!1,active:!1,supported:Ge,reason:ct.documentReadonly},"builtin"):on({enabled:Ge&&rt,active:!1,supported:Ge,reason:zt},"builtin")}const We=Ks(fe,p,b),Je=Wf(fe,p,b,I);if(fe.list?.mode==="indent"||fe.list?.mode==="outdent")return Oe(fe,p,V,b,We,Je);if(fe.list?.mode==="toggle-seed")return Pe(fe,p,V,b,We,Je);if(fe.mutates&&V)return on({enabled:!1,active:We,supported:!0,value:Je,reason:ct.documentReadonly},"builtin");if(fe.inline&&!Su(b)){const nt=ci(x);return on(nt?{enabled:!1,active:We,supported:!0,value:Je,reason:nt}:Nr(b).length>0&&typeof M()?.setPendingInlineFormat=="function"?{enabled:!0,active:We,supported:!0,value:Je}:{enabled:!1,active:We,supported:!0,value:Je,reason:ct.rangeSelectionRequired},"builtin")}if((fe.blockParagraph||fe.list)&&Nr(b).length===0)return on({enabled:!1,active:We,supported:!0,value:Je,reason:ct.selectionRequired},"builtin");if(fe.link&&!We&&r2(b).length===0&&!hl(b))return on({enabled:!1,active:We,supported:!0,reason:ct.rangeSelectionRequired},"builtin");if(fe.inline){const nt=ci(x);if(nt)return on({enabled:!1,active:We,supported:!0,value:Je,reason:nt},"builtin")}return on({enabled:!0,active:We,supported:!0,value:Je},"builtin")};function Gf(d,p){const b=d.address?.anchor,I=b?.start,x=b?.end,V=typeof I?.blockId=="string"?I.blockId:null,W=typeof x?.blockId=="string"?x.blockId:null;if(!V||!W)return!1;const re=typeof I?.offset=="number"?I.offset:null,fe=typeof x?.offset=="number"?x.offset:null;if(re==null||fe==null)return!1;const Me=p.target,$e=Me&&Array.isArray(Me.segments)?Me.segments:[];for(const We of $e){const Je=typeof We?.blockId=="string"?We.blockId:null;if(!Je)continue;const nt=We.range,Ge=typeof nt?.start=="number"?nt.start:null,rt=typeof nt?.end=="number"?nt.end:null;if(!(Ge==null||rt==null)){if(V!==W){if(Je===V&&rt>re||Je===W&&Ge<fe)return!0;continue}if(Je===V){if(Ge===rt){if(Ge>=re&&Ge<=fe)return!0;continue}if(Math.max(Ge,re)<Math.min(rt,fe))return!0}}}return!1}const as=(d,p)=>{const b=d?.hyperlinks;if(!b||typeof b.list!="function")return null;const I=Nr(p);if(!ic(I))return null;for(const x of I){const V={kind:"block",nodeType:"paragraph",nodeId:x},{value:W}=uo(`hyperlinks:${x}`,ln(),()=>b.list({within:V}),fe=>fe&&typeof fe=="object"?fe:null),re=(W&&Array.isArray(W.items)?W.items:[]).find(fe=>Gf(fe,p));if(re)return re}return null},Ks=(d,p,b)=>{if(d.link)return as(p,b)!=null;if(d.list?.mode==="toggle-seed"&&d.list.seed)return Al(p,b)===d.list.seed;const I=P(d);if(I!==null)return I;const x=r.get(d.id),V=Ta(b);if(V&&x?.selectionSignature===V)return x.active;const W=vc(d,b);return W!==null?W:UV(d,b)},Wf=(d,p,b,I)=>{if(d.inline&&o2(d.inline.key)){const x=N(d);if(x!==void 0)return x;const V=I[d.inline.key];if(V!==void 0)return V;const W=Ta(b),re=W?n.get(d.inline.key):void 0;if(W&&re?.selectionSignature===W)return re.value}if(d.id==="linked-style"){const{style:x}=Zr(b,mn().cache);return!x.styleId||x.mixed?void 0:{styleId:x.styleId,styleName:x.styleName}}if(d.id==="text-align")return ae(p,b);if(d.id==="link")return Ke(p,b)??void 0},ls=(d,p,b)=>{const I=d?.lists;if(!I)return{value:null,status:"ready"};const x=b.storyType==="body",V=typeof I.getStateInStory=="function"?()=>I.getStateInStory({target:Ea(p),story:b}):x&&typeof I.getState=="function"?()=>I.getState({target:Ea(p)}):null;if(!V)return{value:null,status:"ready"};const{value:W,status:re}=uo(`lists:${Cr(b)}:${p}`,ln(),V,fe=>fe&&typeof fe=="object"?fe:null);return{value:W?.success===!0?W:null,status:re}},fo=(d,p,b)=>ls(d,p,b).value,qs=(d,p,b)=>{const I=fo(d,p,b);return!I||I.isListItem!==!0?null:I.seed==="bullet"||I.seed==="ordered"?I.seed:null},_l=(d,p,b)=>{const I=ls(d,p,b),x=I.value;return{value:x&&typeof x.isListItem=="boolean"?x.isListItem:null,status:I.status}},Al=(d,p)=>{const b=Nr(p);if(b.length===0||!ic(b))return null;const I=es(p),x=qs(d,b[0],I);if(x!=="bullet"&&x!=="ordered")return null;for(const V of b.slice(1))if(qs(d,V,I)!==x)return null;return x},yc=(d,p,b)=>{if(!d)return{value:null,status:"ready",refreshing:!1};const I=Cr(b),x=I==="story:body";if(x&&typeof d.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!x&&typeof d.getNode!="function")return{value:null,status:"ready",refreshing:!1};const V=`node:${I}:${p}`,W=ln(),re=uo(V,W,()=>x?d.getNodeById({nodeId:p,nodeType:"paragraph"}):d.getNode(bo(p,b)),Me=>Me&&typeof Me=="object"?Me:null),fe=z.get(V);return{...re,refreshing:re.status==="stale"&&fe?.inflightToken===W&&fe.failedToken!==W}},Ys=d=>d==="left"||d==="center"||d==="right"||d==="justify"?d:void 0,Hu=d=>d==="start"||d==="end"||d==="distributed"||d==="numTab"||d==="lowKashida"||d==="mediumKashida"||d==="highKashida"||d==="thaiDistribute",A=(d,p)=>{const b=M(),I=b?.readMountedProjectionBlocksByIds;if(typeof I!="function")return null;const x=ts(d),V=Pt(()=>x?I.call(b,[...p],x):I.call(b,[...p]),null);if(!Array.isArray(V))return new Map;const W=a2(V),re=new Map;for(const fe of p){const Me=W.find(nt=>sc(nt,fe));if(!Me)continue;const $e=Me.attrs,We=Ys($e?.alignment),Je=o9($e);re.set(fe,We??(Je==="rtl"?"right":"left"))}return re},R=(d,p,b,I)=>{const{value:x,status:V,refreshing:W}=yc(d,p,b),re=I?.get(p);if(V==="pending")return re?{status:"uniform",value:re}:{status:"pending"};if(V==="stale"&&!W)return{status:"pending"};if(V==="stale"&&re)return{status:"uniform",value:re};if(V==="stale"&&I&&!re)return{status:"unavailable"};if(!x)return{status:"unavailable"};const fe=x.node;if(!fe)return{status:"unavailable"};const Me=fe.kind;if(Me!=="paragraph"&&Me!=="heading")return{status:"unavailable"};const $e=fe[Me];if(!$e||typeof $e!="object")return{status:"unavailable"};const We=$e.props?.alignment;if(We==null)return re?{status:"uniform",value:re}:{status:"unavailable"};const Je=Ys(We);return Je?{status:"uniform",value:Je}:Hu(We)&&re?{status:"uniform",value:re}:{status:"unavailable"}},X=(d,p)=>{const b=Nr(p);if(b.length===0||!ic(b))return{status:"unavailable"};const I=es(p),x=A(p,b),V=R(d,b[0],I,x);if(V.status!=="uniform")return V;for(const W of b.slice(1)){const re=R(d,W,I,x);if(re.status!=="uniform")return re;if(re.value!==V.value)return{status:"mixed"}}return V},ie=d=>{const p=Nr(d);return p.length===0?null:`${Cr(es(d))}:${p.join(",")}`},ae=(d,p)=>{const b=X(d,p),I=b.status==="uniform"?b.value:void 0,x=o;if(!x)return I;const V=ie(p);return V&&V!==x.selectionSignature?(o=null,I):!V||!x.settled?x.value:b.status!=="pending"?(o=null,I):x.value},le=(d,p)=>{const b=Ys(p),I=ie(d),x=Nr(d);if(!b||!I||x.length===0)return null;const V=++i;return o={selectionSignature:I,value:b,generation:V,settled:!1,canReconcile:ic(x)},bt(),V},de=(d,p)=>{if(d==null)return;const b=o;if(!(!b||b.generation!==d)){if(!wo(p)){o=null;return}if(!b.canReconcile){o=null;return}b.settled=!0}},ue=async(d,p,b)=>{const I=d?.lists;if(!I)return null;try{const x=b.storyType==="body",V=typeof I.getStateInStory=="function"?await I.getStateInStory({target:Ea(p),story:b}):x&&typeof I.getState=="function"?await I.getState({target:Ea(p)}):null,W=V&&typeof V=="object"?V:null;return!W||W.success!==!0||typeof W.isListItem!="boolean"?null:W.isListItem}catch{return null}},Ae=(d,p,b)=>{const I={resolved:!1,seed:null},x=d?.lists;if(!x)return I;const V=b.storyType==="body",W=typeof x.getStateInStory=="function"?()=>x.getStateInStory({target:Ea(p),story:b}):V&&typeof x.getState=="function"?()=>x.getState({target:Ea(p)}):null;if(!W)return I;const re=fe=>{const Me=fe&&typeof fe=="object"?fe:null;return!Me||Me.success!==!0||typeof Me.isListItem!="boolean"?I:{resolved:!0,seed:Me.isListItem===!0&&(Me.seed==="bullet"||Me.seed==="ordered")?Me.seed:null}};try{const fe=W();return xr(fe)?Promise.resolve(fe).then(re,()=>I):re(fe)}catch{return I}},Le=async(d,p,b)=>{if(!d)return null;try{const I=!b||b.storyType==="body",x=b&&typeof d.getNode=="function"?await d.getNode(bo(p,b)):I&&typeof d.getNodeById=="function"?await d.getNodeById({nodeId:p,nodeType:"paragraph"}):null;return pV(x&&typeof x=="object"?x:null)}catch{return null}},Oe=(d,p,b,I,x,V)=>{if(d.mutates&&b)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.documentReadonly},"builtin");const W=Nr(I);if(W.length===0)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.selectionRequired},"builtin");const re=d.docRoute?vr(p,d.docRoute):null,fe=vr(p,"format.paragraph.setIndentation"),Me=vr(p,"format.paragraph.clearIndentation"),$e=d.list?.mode,We=$e==="indent"?fe!=null:fe!=null||Me!=null,Je=es(I);let nt=null;if(Je.storyType!=="body"){nt=[];for(const Ge of W){const{value:rt,status:ht}=_l(p,Ge,Je);if(rt===null)return ht!=="ready"&&(re!=null||We)?on({enabled:!0,active:x,supported:!0,value:V},"builtin"):on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin");nt.push(rt)}}if(nt?.some(Ge=>Ge===!0)){const Ge=$e==="indent"?"lists.indentRange":"lists.outdentRange",rt=Qn()!=="suggesting"&&nt.every(dt=>dt===!0)&&vr(p,Ge)!=null,ht=$e==="outdent"&&vr(p,"lists.outdentInStory")!=null;if(!rt&&!ht)return on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")}for(const[Ge,rt]of W.entries()){const ht=nt?{value:nt[Ge]??null,status:"ready"}:_l(p,rt,Je),dt=ht.value;if(dt===!0){if(re!=null)return on({enabled:!0,active:x,supported:!0,value:V},"builtin");continue}if(dt===!1&&We){if(Je.storyType!=="body"&&typeof p?.getNode!="function")continue;return on({enabled:!0,active:x,supported:!0,value:V},"builtin")}if(dt===null)return ht.status!=="ready"&&(re!=null||We)?on({enabled:!0,active:x,supported:!0,value:V},"builtin"):on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")}return on({enabled:!1,active:x,supported:!1,value:V,reason:ji(p)},"builtin")},Pe=(d,p,b,I,x,V)=>{if(d.mutates&&b)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.documentReadonly},"builtin");const W=Nr(I);if(W.length===0)return on({enabled:!1,active:x,supported:!0,value:V,reason:ct.selectionRequired},"builtin");const re=es(I),fe=p?.lists;if(!(typeof fe?.getStateInStory=="function"||re.storyType==="body"&&typeof fe?.getState=="function"))return on({enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");if(!ic(W))return on(re.storyType==="body"&&vr(p,"lists.remove")!=null?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const Me=W.map(nt=>ls(p,nt,re));if(Me.some(({status:nt})=>nt!=="ready"))return on({enabled:!0,active:x,supported:!0,value:V},"builtin");if(Me.some(({value:nt})=>nt===null))return on({enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const $e=d.list?.seed,We=Me.every(({value:nt})=>nt?.isListItem===!0&&nt.seed===$e);if(re.storyType==="body")return on(!We||vr(p,"lists.remove")!=null?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin");const Je=vr(p,"lists.removeInStory");return on(We&&Je?{enabled:!0,active:x,supported:!0,value:V}:{enabled:!1,active:x,supported:!1,value:V,reason:ct.operationUnavailable},"builtin")},Ke=(d,p)=>{const b=as(d,p)?.properties?.href;return typeof b=="string"?b:null},ut=d=>{if(!_())return on({enabled:!1,active:!1,supported:!1,reason:ct.notReady},"builtin");const p=d.instanceRoute;return typeof t?.[p]!="function"?on({enabled:!1,active:!1,supported:!1,reason:ct.operationUnavailable},"builtin"):on({enabled:!0,active:at(d),supported:!0,value:vt(d)},"builtin")},at=d=>{const p=t?.config??void 0;return d.valueFrom==="ruler"?!!p?.rulers:d.valueFrom==="formattingMarks"?!!p?.layoutEngineOptions?.showFormattingMarks:!1},Ct=(d,p,b)=>{if(b)return on({enabled:!1,active:!1,supported:!0,reason:ct.documentReadonly},"builtin");const I=_e();return I!=null&&(!d.table.requiresCell||I.cellNodeId!=null)?(d.docRoute?vr(p,d.docRoute):null)==null?on({enabled:!1,active:!1,supported:!1,reason:ji(p)},"builtin"):on({enabled:!0,active:!1,supported:!0},"builtin"):on({enabled:!1,active:!1,supported:!0,reason:ct.tableContextUnavailable},"builtin")},vt=d=>{if(d.valueFrom==="zoom")return hc().value;if(d.valueFrom==="documentMode")return Qn();if(d.valueFrom==="measurementUnit")return Lu();if(d.valueFrom==="ruler"||d.valueFrom==="formattingMarks")return at(d)},Xt=(d,p)=>d.id==="zoom"?typeof p=="number"&&Number.isFinite(p)&&p>0:d.id==="document-mode"?p==="editing"||p==="suggesting"||p==="viewing":d.id==="measurement-unit"?p==="in"||p==="cm":!0,kn=()=>[...new Set([...QF,...oe.keys()])],Lr="Normal",Jt={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},An=d=>{const p=y()?.styles;return!p||typeof p.getCatalog!="function"?{value:null,status:"ready"}:uo(`styles:catalog:${JSON.stringify(d??{})}`,ln(),()=>p.getCatalog(d),b=>b&&typeof b=="object"?b:null)},mn=()=>{const d=An({includePreview:!0});if(!d.value)return{cache:null,status:d.status};const p=An({view:"quickGallery",includePreview:!0}),b=p.value?p.value.items:d.value.styles.filter(x=>x.visibility.quickGallery),I=new Map;for(const x of d.value.styles)I.set(x.id,x);return{cache:{full:d.value,quickGallery:b,byId:I},status:fl(d.status,p.status)}},pr=(d,p,b)=>{const{value:I,status:x}=yc(d,p,b);if(!I)return{ok:!1,styleRef:null,status:x};const V=I.node;if(!V||typeof V!="object")return{ok:!1,styleRef:null,status:x};const W=V.kind,re=typeof W=="string"?V[W]:void 0,fe=re&&typeof re=="object"?re.styleRef:void 0;return{ok:!0,styleRef:typeof fe=="string"&&fe.length>0?fe:null,status:x}},Zr=(d,p)=>{const b=[],I=y();if(!I)return b.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};const x=Nr(d);if(x.length===0)return b.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};if(!ic(x))return b.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:"ready"};const V=p?.full.defaults.paragraphStyleId??(p?Lr:null),W=new Set;let re=0,fe=0,Me=0,$e="ready";const We=es(d);for(const Ge of x){const rt=pr(I,Ge,We);if($e=fl($e,rt.status),!rt.ok){fe+=1;continue}if(!rt.styleRef&&!V){Me+=1;continue}const ht=rt.styleRef??V;if(!ht){Me+=1;continue}re+=1,W.add(ht)}if(re===0){const Ge=Me>0&&fe===0;return b.push({severity:"warning",code:Ge?"active-style-default-unavailable":"active-style-read-failed",message:Ge?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:$e}}const Je=fe+Me;if(Je>0)return b.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${re} of ${re+Je} selected blocks; ${Je} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:b},status:$e};if(W.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:b},status:$e};const nt=[...W][0];return{style:{styleId:nt,styleName:p?.byId.get(nt)?.name??null,mixed:!1,diagnostics:b},status:$e}},Qr=d=>{if(!_())return Jt;const{cache:p,status:b}=mn(),{style:I,status:x}=Zr(d,p);let V;return p?V=I.diagnostics.length===0?p.full.diagnostics:[...p.full.diagnostics,...I.diagnostics]:V=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},...I.diagnostics],{ready:!0,status:fl(b,x,d.status),catalogRevision:p?.full.revision??null,quickGallery:p?.quickGallery??[],activeParagraphStyleId:I.styleId,activeParagraphStyleName:I.styleName,mixedSelection:I.mixed,sourceStatus:p?.full.sourceStatus??null,diagnostics:V}},Ai=()=>{const d=Qn(),p=bl();p.status==="ready"&&yl(p),Y(p);const b=Ta(p);for(const[I,x]of r)(!b||x.selectionSignature!==b||x.settled&&p.status==="ready")&&r.delete(I);return{ready:_()!=null,documentMode:d,document:Mu(),selection:p,toolbar:{context:d,commands:Bu(p),copyFormatActive:h.mode!=="idle"},comments:xu(p),trackChanges:Cl(p),contentControls:zi(p),zoom:hc(),fonts:zf(),styles:Qr(p)}},ui=d=>{const p=Ta(d);p&&a&&p!==a&&(n.clear(),r.clear()),p&&(a=p)};let st=null,dn=null,Jr=null,Ho=null,ho=null,$o=null,cs=!1;const us=()=>{if(U||cs)return;cs=!0;const d=()=>{cs&&(cs=!1,!U&&bt())};typeof queueMicrotask=="function"?queueMicrotask(d):Promise.resolve().then(d)},Il=()=>{const d=se();if(d!==Jr&&(Ho&&(Ho(),Ho=null),Jr=d,!(!d||typeof d.subscribe!="function")))try{const p=d.subscribe(()=>us());typeof p=="function"&&(Ho=p)}catch{Jr=null}},ds=()=>{const d=T();if(d!==ho&&($o&&($o(),$o=null),ho=d,!(!d||typeof d.subscribe!="function")))try{const p=d.subscribe(()=>bt());typeof p=="function"&&($o=p)}catch{ho=null}};let Fo=null,di=null,fs=null,fi=null,Xs=null,D=null;const K=()=>{const d=_()?.host,p=Pt(d?.getHandles?()=>d.getHandles():void 0,null)?.editing?.selection;return p&&typeof p.subscribe=="function"?p:null},Se=()=>{const d=K();if(d!==st&&(dn&&(dn(),dn=null),st=d,!!d))try{const p=d.subscribe(b=>{Cn+=1,dc(b),bt()});typeof p=="function"&&(dn=p)}catch{st=null}},Ne=()=>{const d=_()?.host,p=Pt(d?.getHandles?()=>d.getHandles():void 0,null)?.review;return p&&typeof p.subscribe=="function"?p:null},mt=d=>d?typeof d.getActiveReviewTarget=="function"?Pt(()=>d.getActiveReviewTarget(),null):typeof d.getSnapshot=="function"?Pt(()=>d.getSnapshot(),null)?.activeReviewTarget??null:null:null;let $t=0;const Sn=(d,p)=>{const b=(p&&typeof p=="object"?p:null)?.lastInteractionRejection;if($t>0&&d==null&&b&&typeof b=="object"&&b.code==="review-target-invalidated"&&b.detail==="not-painted")return!1;const I=d&&typeof d=="object"?d:null;let x=null;if(I?.entityType==="trackedChange"&&typeof I.entityId=="string"&&I.entityId.length>0){const V=I.entityId,W=I.story&&typeof I.story=="object"?I.story:void 0,re=Bi(),fe=(re?W?oc(re,W).toPublicId(V):Os(re).toPublicId(V):null)??V,Me=W&&Cr(W)!==Cr(null)?W:void 0;x={id:fe,...Me?{story:Me}:{},...typeof I.paintedEntityId=="string"&&I.paintedEntityId.length>0?{paintedEntityId:I.paintedEntityId}:fe!==V?{paintedEntityId:V}:{}}}return d==null&&x==null&&je!=null&&ee(je)||Ye(je,x)?!1:(ne(x),!0)},En=()=>{const d=Ne();if(d===Fo)return;if(di&&(di(),di=null),Fo=d,!d){Sn(null);return}let p=!0;try{const b=d.subscribe(I=>{const x=I&&typeof I=="object"?I:null,V=x&&Object.prototype.hasOwnProperty.call(x,"activeReviewTarget")?x.activeReviewTarget:mt(d);!Sn(V,I)||p||bt()});typeof b=="function"&&(di=b),Sn(mt(d))}catch{Fo=null}finally{p=!1}},Mn=()=>{if(st||Qn()!=="viewing")return null;const d=_()?.mount?.container,p=(d&&typeof d=="object"&&"ownerDocument"in d?d.ownerDocument??null:null)??globalThis.document??null;return p&&typeof p.addEventListener=="function"?p:null},Fn=()=>{const d=Mn();if(d===Xs||(D&&(D(),D=null),Xs=d,!d))return;const p=()=>{Cn+=1,bt()};d.addEventListener("selectionchange",p),d.addEventListener("pointerup",p,!0),d.addEventListener("mouseup",p,!0),D=()=>{d.removeEventListener("selectionchange",p),d.removeEventListener("pointerup",p,!0),d.removeEventListener("mouseup",p,!0)}};_u(),Sn(mt(Ne()));let qe=Ai();a=Ta(qe.selection);const Tt=()=>{const d=_()?.host?.events,p=d&&typeof d.subscribe=="function"?d:null;if(p!==fs&&(fi&&(fi(),fi=null),fs=p,!!p))try{const b=p.subscribe(I=>{const x=I?.type;if(x==="review-mutation:started"){nn(I.reviewMutation?.token);return}if(x==="review-mutation:aborted"){un(I.reviewMutation?.token),yt();return}if(x==="mutation:rejected"&&I.reviewMutation&&(un(I.reviewMutation.token),yt()),x==="mutation:committed"&&I.reviewMutation&&un(I.reviewMutation.token),x==="source:complete"||x==="source:signals-complete"){Yt=ln(),zs();return}if((x==="mutation:committed"||x==="collaboration:remote-changed")&&(Ln=Date.now()),x==="mutation:committed"||x==="save:completed"||x==="collaboration:remote-changed"){const V=x==="mutation:committed"?Bk(I):null;if(V?.allResolved){bn([]),ft(I.receipt);return}V?.removedIds.size&&Lt(new Set(V.removedIds),I.receipt);const W=x==="mutation:committed"&&_i(I)||x==="collaboration:remote-changed"&&Array.isArray(I.changedStoryIds)&&I.changedStoryIds.length>0;if(W&&(On=Date.now()),x==="mutation:committed"&&W){vl();return}if(V?.removedIds.size&&V.upsertIds.size===0)return;(x==="collaboration:remote-changed"||x==="mutation:committed"&&!W)&&gl();const re=x==="collaboration:remote-changed"&&Array.isArray(I.changedPartUris)&&I.changedPartUris.some(Me=>typeof Me=="string"&&tV.has(Me)),fe=x==="collaboration:remote-changed"&&Array.isArray(I.changedStoryIds)&&I.changedStoryIds.length>0&&Bs();re&&!W&&(kr=!0),ai(),re&&!W?co("comments"):fe&&(kr=!0,jo()),bt()}});typeof b=="function"&&(fi=b)}catch{fs=null}},bt=()=>{if(U)return;cs=!1,_u(),Se(),Il(),ds(),En(),Fn(),Tt();const d=Ai();ui(d.selection),qe=d;for(const p of[...O])p(qe)},rr=[],Nn=[],Un=d=>{for(const p of d)try{p()}catch{}},No=()=>Un(rr),Go=()=>Un(Nn),Zs=[];((d,p)=>{if(!(!d||typeof d.on!="function"))for(const b of p){const I=b==="active-editor-change"?()=>{No(),Go(),bt()}:b==="document-replaced"?x=>{const V=x&&typeof x=="object"?x:null,W=V?.editor,re=V?.host,fe=!!W&&W===_(),Me=!!re&&re===M();!fe&&!Me||(Go(),z.clear(),ai(),bt())}:()=>bt();try{d.on(b,I),Zs.push(()=>{try{typeof d.off=="function"&&d.off(b,I)}catch{}})}catch{}}})(t,Yz),Se(),Il(),ds(),En(),Fn(),Tt();const Wo=(d,p=Mz)=>({get:()=>d(qe),subscribe:b=>{let I=d(qe);const x=V=>{const W=d(V);p(I,W)||(I=W,b(W))};return O.add(x),()=>O.delete(x)}}),Ko=d=>Wo(d),qo=d=>{const p=b=>{const I=V=>{try{b(V)}catch{}},x=d.subscribe(I);return I(d.get()),x};return{get:()=>d.get(),getSnapshot:()=>d.get(),observe:p,subscribe:b=>p(I=>b({snapshot:I}))}},Gu=(d,p,b)=>{const I=qo(d),x=qo(p),V=W=>{const re=Si(b);bt();const fe=x.observe(W);return()=>{fe(),re()}};return{get:I.get,getSnapshot:I.getSnapshot,observe:V,subscribe:W=>V(re=>W({snapshot:re}))}};function d2(d){return d&&typeof d=="object"&&typeof d.id=="string"?String(d.id):null}function Wu(d){const p=ts(d);return p&&Cr(p)!==Cr(null)?p:void 0}function qn(d,p){return{kind:"id",id:d,...p?{story:p}:{}}}function f2(d){if(d.empty)return null;const p=d.selectionTarget,b=p?.start,I=p?.end;if(p?.kind!=="selection"||b?.kind!=="text"||I?.kind!=="text"||typeof b.blockId!="string"||b.blockId!==I.blockId||!Number.isInteger(b.offset)||!Number.isInteger(I.offset)||b.offset<0||I.offset<0||b.offset===I.offset)return null;const x=Math.min(b.offset,I.offset),V=Math.max(b.offset,I.offset),W=ts(d);return{kind:"range",coordinateSpace:p.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...W?{story:W}:{},segments:[{blockId:b.blockId,range:{start:x,end:V}}]}}}function ym(d,p){if(Cr(p)!==Cr(null))return;const b=y()?.trackChanges,I=b?.list;if(typeof I!="function")return;const x=Pt(()=>I.call(b),null);if(xr(x)||!x||typeof x!="object")return;const V=x.items;if(Array.isArray(V))return V.map(Of).find(W=>W!=null&&Ji(W,d,p))}function bm(d,p){const b=wm(d.quotedText);if(!b)return!1;const I=fm(p);return[I.insertedText,I.deletedText,I.excerpt].some(x=>wm(x)===b)}function wm(d){return typeof d=="string"?d.replace(/\s+/g," ").trim():""}function Cm(){const d=qe.selection.activeChangeIds[0];if(!d)return"unavailable";const p=ts(qe.selection),b=(qe.trackChanges.status==="ready"?qe.trackChanges.items.find(W=>Ji(W,d,p)):void 0)??ym(d,p)??Bi()?.find(W=>Ji(W,d,p));if(!b)return"unavailable";const I=fm(b),x=I.type,V=I.grouping;return bm(qe.selection,b)?"id":x==="replacement"&&V==="replacement-pair"||(x==="insertion"||x==="deletion"||x==="insert"||x==="delete")&&V==="standalone"?"range":"id"}function km(d,p,b,I){const x=()=>b2(d,qn(b,I),b,I);try{const V=b2(d,p,null);if(xr(V))return xo(Promise.resolve(V).then(re=>wo(Ns(re))?re:x()));const W=Ns(V);return xo(wo(W)?V:x())}catch{return!1}}function Sm(d,p){if(d.scope==="all")return{target:{kind:"all"},changeId:null};if(typeof p=="string"&&p.length>0)return{target:{kind:"id",id:p},changeId:p};if(p&&typeof p=="object"){const x=p;if(x.target&&typeof x.target=="object"){const W=x.target;return{target:W,changeId:d2(W),story:W.story}}const V=typeof x.changeId=="string"?x.changeId:x.id;if(typeof V=="string"&&V.length>0)return{target:qn(V,x.story),changeId:V,story:x.story}}const b=qe.selection.activeChangeIds[0],I=Wu(qe.selection);return b?{target:qn(b,I),changeId:b,story:I}:null}function h2(d,p){if(d.scope==="id"&&p==null){if(qe.selection.activeChangeIds.length>1)return Yf(d.kind,{kind:"ids",ids:qe.selection.activeChangeIds},null);if(qe.selection.activeChangeIds.length===1&&!qe.selection.empty&&qe.selection.selectionTarget){const I=Cm();if(I==="unavailable")return!1;if(I==="range"){const x=f2(qe.selection),V=Wu(qe.selection);return x?km(d.kind,x,qe.selection.activeChangeIds[0],V):!1}if(I==="id"){const x=qe.selection.activeChangeIds[0],V=ts(qe.selection),W=V&&Cr(V)!==Cr(null)?V:void 0;return y2(d.kind,W?{id:x,story:W}:x)}}}const b=Sm(d,p);return b?Yf(d.kind,b.target,b.changeId,b.story):!1}function _m(d,p){const b=se()?.lists,I=b?.apply;if(typeof I!="function")return!1;const{behavior:x,preset:V,continuity:W}=typeof p=="string"?Qz(p):p&&typeof p=="object"?p:{},re={kind:d,behavior:x??"toggle"};V!==void 0&&(re.preset=V),W!==void 0&&(re.continuity=W);try{return xo(I.call(b,re))}catch{return!1}}let hi=Promise.resolve(!1),Io=null,Ku=Promise.resolve(!1);const Et=async d=>{if(!hm(d))return d;const p=_()?.documentMutationReadiness,b=p?.whenPainted;if(typeof b!="function")return d;const I=typeof d.txId=="string"?d.txId:void 0;try{await b.call(p,I?{txId:I}:void 0)}catch{}return d},Mt=d=>{if(xr(d)){const b=Promise.resolve(d);return{immediate:!0,committed:b.then(I=>Ns(I),()=>!1),settled:b.then(I=>Et(Ns(I)),()=>!1)}}const p=Ns(d);return{immediate:p,committed:Promise.resolve(p),settled:Et(p)}},gn=()=>{const d=s.shift();if(!d){c=!1,f?.(),f=null;return}try{d.resolve(U?!1:d.mutate())}catch{d.resolve(!1)}},br=()=>{let d=!1;return()=>{d||(d=!0,gn())}},$r=(d,p)=>{if(!c){c=!0,u=new Promise(V=>{f=V});try{return{result:p(),release:br()}}catch(V){throw c=!1,f?.(),f=null,V}}const b=s.find(V=>V.key===d);if(b)return b.mutate=p,{result:b.result,release:()=>{}};let I;const x=new Promise(V=>{I=V});return s.push({key:d,mutate:p,result:x,resolve:I}),{result:x,release:br()}},po=new Set(["create.tableOfContents"]),Ii=d=>Yn(`Tracked authoring is not supported for ${d}.`),Ui=d=>{if(Qn()==="suggesting")return po.has(d)?Ii(d):{changeMode:"tracked"}},qu=()=>Qn()==="suggesting"?LV:c2,mo=(d,p,b)=>{const I=Ui(d);return I&&I.success===!1?I:I?p(b,I):p(b)},hj=(d,p,b,I)=>{const x=d.inline;if(!x)return;const V=Ns(I);if(V===!1||typeof V=="object"&&V&&V.success===!1)return;if(x.kind==="clear"){n.clear();return}if(x.kind==="toggle"||!o2(x.key))return;const W=Ta(p);if(!W)return;const re=yV(x.key,b.value);if(re==null){n.delete(x.key);return}n.set(x.key,{selectionSignature:W,value:re})},pj=(d,p,b,I)=>!d.inline||d.inline.kind==="toggle"?I:xr(I)?Promise.resolve(I).then(x=>(hj(d,p,b,x),x)):I,mj=(d,p,b,I)=>{if(d.inline?.kind!=="toggle"||!wo(Ns(I))||typeof b.value!="boolean"&&b.value!==null)return null;const x=Ta(p);if(!x)return null;const V=++l;return r.set(d.id,{selectionSignature:x,active:b.value===!0,generation:V,settled:!1}),bt(),V},gj=(d,p,b)=>{if(p==null)return;const I=r.get(d.id);if(!(!I||I.generation!==p)){if(!wo(b)){r.delete(d.id);return}I.settled=!0}},Am=(d,p)=>d.then(b=>(p?.(b),Us(),b),()=>(p?.(!1),Us(),!1)),xo=(d,p)=>{const b=Io;if(Io=null,b)return hi=Am(b,p),Ns(d);if(xr(d))return hi=Am(Mt(d).settled,p),!0;const I=Ns(d);return hm(I)&&typeof _()?.documentMutationReadiness?.whenPainted=="function"?(hi=Am(Et(I),p),I):(p?.(I),hi=Promise.resolve(I),Us(),I)},vj=(d,p)=>!d||typeof d!="object"?p:d,xl=(d,p=Yn("Document API operation failed."))=>{if(xr(d))return Promise.resolve(d).then(I=>xl(I,p),()=>p);const b=vj(d,p);return ai(),hm(b)&&typeof _()?.documentMutationReadiness?.whenPainted=="function"?(Am(Et(b)),bt(),b):(bt(),b)},yj=(d,p,b,I)=>{const x=[],V=[];for(const W of b){const re=I(W);if(re)try{const fe=Mt(mo(d,p,re));x.push(fe.immediate),V.push(fe.settled)}catch{x.push(!1),V.push(Promise.resolve(!1))}}return Io=V.length?Promise.all(V).then(W=>ki(W)):null,ki(x)},bj=(d,p,b,I)=>{const x=[],V=[];for(const W of b){const re=I(W);if(re)try{const fe=Mt(mo(d,p,re));x.push(fe.immediate),V.push(fe.settled)}catch{x.push(!1),V.push(Promise.resolve(!1))}}return Io=V.length?Promise.all(V).then(W=>ki(W)):null,ki(x)},p2=(d,p,b,I=qe.selection)=>{const x=Ui(d);return x&&x.success===!1?x:I.selectionTarget?p(b,{...x??{},offsetSpace:"selection"}):x?p(b,x):p(b)},wj=(d,p,b,I)=>{const x=bo(p,I);switch(d.kind){case"alignment":{const V=b;return V!=="left"&&V!=="center"&&V!=="right"&&V!=="justify"?null:{target:x,alignment:V}}case"spacing-line":{const V=typeof b=="number"?b:Number(b);return!Number.isFinite(V)||V<=0?null:{target:x,line:V,lineRule:"auto"}}case"style":if(b&&typeof b=="object"){const V=b.role;if(V&&typeof V=="object")return{target:x,role:V}}return typeof b!="string"||b.trim()===""?null:{target:x,styleId:b};case"direction":{const V=d.fixedValue;return V!=="ltr"&&V!=="rtl"?null:{target:x,direction:V}}default:return null}},Cj=(d,p)=>{const b=d.inline,I=l2(d),x=M();if(!b||typeof x?.setPendingInlineFormat!="function")return!1;if(b.kind==="clear")return j(),!0;if(!I)return!1;let V;if(b.kind==="toggle")V=!Ks(d,y(),qe.selection);else{const W=p&&typeof p=="object"&&"value"in p?p.value:p;if(b.kind==="value-number"){const re=typeof W=="number"?W:Number(W);V=Number.isFinite(re)&&re>0?re:null}else V=typeof W=="string"&&W.trim()!==""?W:null;if(V===null)return E(I,null),!0}return E(I,V),!0},kj=()=>{const d=y(),{lockModesById:p}=ss(d?.contentControls,qe.selection);if(ci(p))return!1;const b=[],I=[],x=nt=>{const Ge=Mt(nt);b.push(Ge.immediate),I.push(Ge.settled)},V=(nt,Ge,rt)=>{try{x(rt?nt(Ge,rt):nt(Ge))}catch{b.push(!1),I.push(Promise.resolve(!1))}},W=mn().cache?.full.defaults.paragraphStyleId??Lr,re=Su(qe.selection);if(re){const nt=vr(d,"format.apply");if(nt)try{x(p2("format.apply",nt,{target:re,inline:{...qu()}}))}catch{b.push(!1),I.push(Promise.resolve(!1))}}const fe=vr(d,"format.paragraph.resetDirectFormatting"),Me=vr(d,"styles.paragraph.setStyleRef"),$e=ts(qe.selection),We=!$e||$e.storyType==="body",Je=vr(d,We?"lists.remove":"lists.removeInStory");for(const nt of Nr(qe.selection)){const Ge=bo(nt,$e);if(fe&&V(fe,{target:Ge}),Je)try{const rt=Ea(nt),ht=Mt(Je(We?{target:rt}:{target:rt,story:$e}));I.push(ht.settled.then(dt=>wo(dt)?dt:!0))}catch{}Me&&V(Me,{target:Ge,styleId:W})}if(!re&&Qn()!=="suggesting"){const nt=vr(d,"format.paragraph.setMarkRunProps");if(nt)for(const Ge of Nr(qe.selection))V(nt,{target:bo(Ge,$e),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return Io=I.length?Promise.all(I).then(nt=>ki(nt)):null,ki(b.length?b:[!1])},Sj=(d,p,b)=>{const I=Nr(qe.selection);if(I.length===0)return!1;const x=ts(qe.selection);return yj(d.docRoute,p,I,V=>wj(d.blockParagraph,V,b,x))},_j=(d,p,b)=>{const I=y(),x=vr(I,"format.paragraph.setIndentation"),V=vr(I,"format.paragraph.clearIndentation"),W=d.list?.mode,re=es(qe.selection),fe=ts(qe.selection),Me=async $e=>{const We=await ue(I,$e,re);if(We===!0)return{kind:"list",routeToCall:d.docRoute,opToCall:p,input:{target:gA($e)}};if(We===null||fe&&fe.storyType!=="body"&&typeof I?.getNode!="function")return null;const Je=await Le(I,$e,fe),nt={};if(Je?.right!=null&&(nt.right=Je.right),Je?.firstLine!=null&&(nt.firstLine=Je.firstLine),Je?.hanging!=null&&(nt.hanging=Je.hanging),W==="indent")return x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),left:Math.max(0,Je?.left??0)+vA,...nt}}:null;const Ge=Math.max(0,(Je?.left??0)-vA);return Ge>0&&(nt.left=Ge),Object.keys(nt).length===0?V?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:V,input:{target:bo($e,fe)}}:x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),left:0}}:null:x?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:x,input:{target:bo($e,fe),...nt}}:null};return Io=(async()=>{const $e=await Promise.all(b.map(Ge=>Me(Ge).catch(()=>null)));if($e.length===b.length&&$e.every(Ge=>Ge?.kind==="list")&&Qn()!=="suggesting"){const Ge=W==="indent"?"lists.indentRange":"lists.outdentRange",rt=vr(I,Ge);if(rt)try{return await Mt(mo(Ge,rt,{paraIds:b,story:re})).settled}catch{return!1}}const We=re.storyType!=="body"&&$e.some(Ge=>Ge?.kind==="list"),Je=We&&W==="outdent"?vr(I,"lists.outdentInStory"):null;if(We&&!Je)return!1;const nt=$e.map(Ge=>{if(!Ge)return Promise.resolve(!1);try{return Ge.kind==="list"&&Je?Mt(mo("lists.outdentInStory",Je,{target:Ge.input.target,story:re})).settled:Mt(mo(Ge.routeToCall,Ge.opToCall,Ge.input)).settled}catch{return Promise.resolve(!1)}});return ki(await Promise.all(nt))})(),!0},Aj=(d,p)=>{const b=d.list,I=y(),x=Nr(qe.selection);if(x.length===0)return!1;const V=es(qe.selection),W=V.storyType==="body";if(b.mode==="indent"||b.mode==="outdent")return _j(d,p,x);const re=b.seed,fe=We=>{if(We.some(dt=>!dt.resolved))return{immediate:!1,settled:null};const Je=We.every(dt=>dt.seed===re);if(!Je&&!W)return{immediate:!1,settled:null};const nt=Je?W?"lists.remove":"lists.removeInStory":d.docRoute,Ge=Je?vr(I,nt):p;if(!Ge)return{immediate:!1,settled:null};const rt=[],ht=[];return x.forEach((dt,it)=>{if(!Je&&We[it]?.seed===re)return;const zt=Je?{target:Ea(dt),...W?{}:{story:V}}:{target:Ea(dt),seed:re};try{const Vt=Mt(mo(nt,Ge,zt));rt.push(Vt.immediate),ht.push(Vt.settled)}catch{rt.push(!1),ht.push(Promise.resolve(!1))}}),{immediate:ki(rt),settled:ht.length?Promise.all(ht).then(dt=>ki(dt)):null}},Me=x.map(We=>Ae(I,We,V));if(Me.some(xr))return Io=Promise.all(Me).then(async We=>{const Je=fe(We);return Je.settled?await Je.settled:Je.immediate}),!0;const $e=fe(Me);return Io=$e.settled,$e.immediate};function Kf(d){return d&&typeof d=="object"?d:{}}function Ij(d){if(typeof d=="string")return d;const p=Kf(d);if(Object.prototype.hasOwnProperty.call(p,"href"))return p.href;if(Object.prototype.hasOwnProperty.call(p,"value"))return p.value}function xj(d,p){const b=Kf(d).text;return typeof b=="string"&&b.trim()!==""?b:p}function TA(d){const p=Kf(d),b=p.capture&&typeof p.capture=="object"?p.capture:null;return p.target??b?.target??b?.selectionTarget??p.selectionTarget??p.textTarget??null}const Ej=d=>{const p=y(),b=p?.hyperlinks;if(!b)return!1;const I=Kf(d),x=Ij(d),V=TA(d),W=typeof I.text=="string"?I.text:void 0,re=typeof I.currentText=="string"?I.currentText:void 0,fe=Ff(I.hyperlinkTarget)?I.hyperlinkTarget:null,Me=Ff(I.textTarget)?I.textTarget:null,$e=as(p,qe.selection),We=typeof fe?.storyId=="string"&&typeof fe?.hyperlinkNodeId=="string";if(We&&x===null){const Je=b.remove;if(typeof Je!="function")return!1;try{return mo("hyperlinks.remove",Je,{storyId:fe.storyId,hyperlinkNodeId:fe.hyperlinkNodeId,keepText:!0})}catch{return!1}}if($e&&x===null){const Je=b.remove;if(typeof Je!="function")return!1;try{return mo("hyperlinks.remove",Je,{target:$e.address,mode:"unwrap"})}catch{return!1}}if(($e||fe)&&typeof x=="string"&&x.trim()!==""){const Je=b.patch,nt=b.updateTarget;if(!(!We&&$e&&typeof Je=="function")&&!(We&&typeof nt=="function"))return!1;const Ge=typeof W=="string"&&W!==(We?re:$e?.text??re),rt=p?.text?.replace,ht=Ge?We?Me:AV($e?.address):null,dt=Ge&&!!ht&&typeof rt=="function";if(Ge&&!dt)return!1;const it=[],zt=[];let Vt=null,Hn=null,$n=null,Gr=!1;try{if(We){if(typeof nt!="function")return!1;const Wr=mo("hyperlinks.updateTarget",nt,{storyId:fe.storyId,hyperlinkNodeId:fe.hyperlinkNodeId,newTarget:IV(x)});Gr=xr(Wr);const Sr=Mt(Wr);if(!wo(Sr.immediate))return!1;it.push(Sr.immediate),zt.push(Sr.settled),Vt=Sr.immediate,Hn=Sr.committed,$n=Sr.settled}else if($e){if(typeof Je!="function")return!1;const Wr=mo("hyperlinks.patch",Je,{target:$e.address,patch:{href:x}});Gr=xr(Wr);const Sr=Mt(Wr);if(!wo(Sr.immediate))return!1;it.push(Sr.immediate),zt.push(Sr.settled),Vt=Sr.immediate,Hn=Sr.committed,$n=Sr.settled}}catch{return!1}if(dt){const Wr=(Mr,Yo)=>wo(Yo)?ki([Mr,Yo]):wo(Mr)?Rf(Mr,Yo):Yo,Sr=Mr=>{if(!wo(Mr))return Mr;try{const Yo=Mt(mo("text.replace",rt,{target:ht,text:W}));return wo(Yo.immediate)?Promise.all([$n??Promise.resolve(Mr),Yo.settled]).then(([_2,fU])=>Wr(_2,fU)):Rf(Mr,Yo.immediate)}catch{return Rf(Mr,!1)}};if(Gr)return Io=(Hn??Promise.resolve(Vt??!1)).then(Sr),ki(it);try{const Mr=Mt(mo("text.replace",rt,{target:ht,text:W}));if(!wo(Mr.immediate))return Vt?Rf(Vt,Mr.immediate):Mr.immediate;it.push(Mr.immediate),zt.push(Mr.settled),Io=Promise.all([$n??Promise.resolve(Vt??!1),Mr.settled]).then(([Yo,_2])=>Wr(Yo,_2))}catch{return Vt?Rf(Vt,!1):!1}}return!dt&&zt.length>0&&(Io=Promise.all(zt).then(Wr=>ki(Wr))),ki(it)}if(typeof x=="string"&&x.trim()!==""){const Je=x.trim(),nt=b.wrap,Ge=mV(V),rt=Ge.length>0?Ge:r2(qe.selection);if(rt.length>0){if(typeof nt!="function")return!1;try{return bj("hyperlinks.wrap",nt,rt,zt=>({target:zt,link:{destination:{href:Je}}}))}catch{return!1}}const ht=b.insert,dt=xj(d,Je);if(typeof ht!="function"||dt.trim()==="")return!1;const it=Pf(V)??hl(qe.selection);if(!it)return!1;try{return mo("hyperlinks.insert",ht,{target:it,text:dt,link:{destination:{href:Je}}})}catch{return!1}}return!1},Tj=(d,p,b)=>{const I=d.create.kind,x=b&&typeof b=="object"?b:{};if(I==="table"){const W=Number(x.rows??x.rowCount),re=Number(x.columns??x.cols??x.colCount);if(!Number.isInteger(W)||W<1||!Number.isInteger(re)||re<1)return!1;const fe=hl(qe.selection),Me=fe&&typeof fe.blockId=="string"?{kind:"inParagraph",target:bo(fe.blockId),offset:fe.range?.start??0}:s2(qe.selection,"nodeId");try{return mo(d.docRoute,p,{rows:W,columns:re,at:Me})}catch{return!1}}if(I==="image"){const W=x.src??x.value;if(typeof W!="string"||W.trim()==="")return!1;const re=hl(qe.selection),fe=es(qe.selection),Me=fe.storyType==="body"?null:fe;let $e;re&&typeof re.blockId=="string"?$e={kind:"inParagraph",target:bo(re.blockId,Me),offset:re.range?.start??0}:($e=s2(qe.selection,"target"),Me&&$e.kind==="after"&&($e={...$e,target:{...$e.target,story:Me}}));const We={src:W,at:$e};Me&&(We.in=$e.kind==="inParagraph"?B(Me)??Me:Me),typeof x.alt=="string"&&(We.alt=x.alt),typeof x.title=="string"&&(We.title=x.title),x.size&&typeof x.size=="object"&&(We.size=x.size);try{return mo(d.docRoute,p,We)}catch{return!1}}const V={at:s2(qe.selection,"target")};typeof x.instruction=="string"&&(V.instruction=x.instruction),x.config&&typeof x.config=="object"&&(V.config=x.config);try{return mo(d.docRoute,p,V)}catch{return!1}},Rj=(d,p)=>{const b=d.table,I=_e();if(!I||b.requiresCell&&!I.cellNodeId)return!1;const x=DV(b.action,I);if(!x)return!1;try{if(b.action==="insert-row-before"||b.action==="insert-row-after"){const V=M(),W=(typeof V?.getHandles=="function"?V.getHandles():null)?.editing?.tables;if(typeof W?.insertRow!="function")return!1;const re=Ui(d.docRoute);return re&&re.success===!1?re:re?W.insertRow(x,re):W.insertRow(x)}return mo(d.docRoute,p,x)}catch{return!1}},Lj=d=>!d||d.disposition!=="routed"?!1:!!(d.inline||d.blockParagraph||d.list||d.link||d.create),Mj=d=>{const p=Kf(d);return!!(TA(d)||Ff(p.hyperlinkTarget)||Ff(p.textTarget))},Pj=(d,p,b)=>qe.selection.status!=="ready"?!1:mm(d)?.scope==="id"||!p||p.disposition!=="routed"?!0:p.inline?.kind==="clear"?Nr(qe.selection).length>0||Su(qe.selection)!=null:p.inline?Su(qe.selection)!=null||Nr(qe.selection).length>0:p.blockParagraph||p.list?Nr(qe.selection).length>0:p.link?Mj(b)||r2(qe.selection).length>0||hl(qe.selection)!=null||Ks(p,y(),qe.selection):!0,Dj=(d,p)=>{const b=mm(d),I=vu(d);return b?.scope!=="id"&&!Lj(I)?!1:!Pj(d,I,p)},Oj=(d,p)=>Dj(d,p)?$s().then(()=>{}):null,bc=(d,p,b)=>{if(Io=null,hi=Promise.resolve(!1),U)return!1;const I=oe.get(d);if(I)try{const We=I.execute(lc(p,b));return xo(We)}catch{return!1}const x=cA(d);if(x&&typeof se()?.lists?.apply=="function")return _m(x,p);const V=mm(d);if(V)return h2(V,p);if(d==="copy-format")return xo(Fj());const W=vu(d);if(!W||W.disposition!=="routed")return!1;const re=W.normalizePayload?W.normalizePayload(p):p;if(W.instanceRoute){if(!_()||!Xt(W,re))return!1;const We=t?.[W.instanceRoute];if(typeof We!="function")return!1;try{const Je=W.fixedArg!==void 0?W.fixedArg:re,nt=We.call(t,Je);return xo(nt)}catch{return!1}}if(W.inline?.kind==="clear")return W.mutates&&Qn()==="viewing"?!1:xo(kj());const fe=W.docRoute;if(!fe||W.mutates&&Qn()==="viewing")return!1;const Me=y(),$e=vr(Me,fe);if(!$e)return!1;if(W.inline){const{lockModesById:We}=ss(Me?.contentControls,qe.selection);if(ci(We))return!1;const Je=Su(qe.selection);if(!Je)return qe.selection.empty===!1?xo(!1):xo(Cj(W,re));const nt=Ks(W,Me,qe.selection),Ge=MV(W.inline,Je,re,nt);if(!Ge)return!1;let rt=null;try{const ht=_(),dt=Qn(),it=()=>_()!==ht||y()!==Me||Qn()!==dt?!1:p2(fe,$e,Ge),zt=Ta(qe.selection)??nc(qe.selection),Vt=W.inline.kind==="toggle"?$r(`${W.id}:${zt}`,it):null;rt=Vt?.release??null;const Hn=Vt?Vt.result:it(),$n=mj(W,qe.selection,Ge,Hn),Gr=pj(W,qe.selection,Ge,Hn),Wr=xo(Gr,Sr=>{gj(W,$n,Sr),rt?.(),rt=null});return W.inline.kind==="toggle"&&(Ku=hi),Wr}catch{return rt?.(),!1}}if(W.blockParagraph){const We=Sj(W,$e,re),Je=W.blockParagraph.kind==="alignment"&&wo(We)?le(qe.selection,re):null;return xo(We,nt=>{de(Je,nt)})}if(W.list){const We=Aj(W,$e);return xo(We)}if(W.link){const We=Ej(re);return xo(We)}if(W.create){const We=Tj(W,$e,re);return xo(We)}if(W.table){const We=Rj(W,$e);return xo(We)}try{return xo(W.mutates?mo(fe,$e,re):$e(re))}catch{return!1}},Im=()=>{g+=1,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:h.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const d of m)d("idle");bt()},Fj=async()=>{const d=["bold","italic","underline","strikethrough"].filter($e=>qe.toolbar.commands[$e]?.active===!0),p=await Ku;await u;const b=wo(p)?d:[],I=500,x=Date.now();if(h.mode!=="idle"){if(h.mode==="armed"&&x-h.lastClickAt<I){h={...h,mode:"persistent",lastClickAt:x};for(const $e of m)$e("persistent");return bt(),!0}return Im(),!1}const V=x-h.lastClickAt<I,W=++g;h={...h,lastClickAt:x};const re=await $s(),fe=`${nc(re)}:${ln()}`,Me=await Nj(null,re,fe&&fe===k?v:void 0,b);if(W!==g)return!0;h={...h,mode:V?"persistent":"armed",snapshot:Me,sourceSelectionKey:nc(re),lastClickAt:x};for(const $e of m)$e(h.mode);return bt(),!0},Nj=async(d,p,b,I=[])=>{const x=p?.target??d?.target;if(!x||x.kind!=="text")return null;const V=Array.isArray(x.segments)?x.segments:[];if(V.length===0)return null;const W=y();if(!W)return null;const re=x.story;let fe=null;for(const Ge of V){const rt=(await Sl(bo(Ge.blockId,re)))?.node??null;if(!rt)continue;const ht=m2(rt),dt=Array.isArray(ht?.inlines)?ht.inlines:[],it=Bj(dt,Ge.range);fe?fe=RA(fe,it):fe=it}const Me=fe?Pz(fe):{},$e={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},We=new Set([...p?.activeMarks??(Array.isArray(d?.activeMarks)?d.activeMarks:[]),...I]);for(const[Ge,rt]of Object.entries($e))We.has(Ge)&&(Me[rt]=!0);const Je=b??await $f(p??Hs(d,"ready"));if(Je.fontFamily&&(Me.fontFamily=Je.fontFamily),Je.color&&(Me.color=Je.color),Je.highlight&&(Me.highlight=Je.highlight),Je.fontSize){const Ge=Number.parseFloat(Je.fontSize);Number.isNaN(Ge)||(Me.fontSize=Ge)}let nt=null;if(V.length===1){const Ge=V[0],rt=(await Sl(bo(Ge.blockId,re)))?.node??null;rt&&m2(rt)&&(nt=await zj(rt,Ge.blockId,W,re))}return{story:re??null,inline:Me,paragraph:nt}},m2=d=>d?d.kind==="paragraph"?d.paragraph??null:d.kind==="heading"?d.heading??null:null:null,Bj=(d,p)=>{const b=W=>{const re=W.run;return typeof re?.text=="string"?re.text:""},I=W=>W.run?.props;if(p.start===p.end){let W=0;for(const re of d){const fe=b(re),Me=W,$e=W+fe.length;if(W=$e,p.start>=Me&&p.start<=$e){const We=I(re);return We?{...We}:{}}}return{}}let x=0;const V=[];for(const W of d){const re=b(W),fe=x,Me=x+re.length;if(x=Me,Me<=p.start||fe>=p.end)continue;const $e=I(W);$e&&V.push($e)}return V.length===0?{}:V.length===1?{...V[0]}:RA(V[0],...V.slice(1))},RA=(d,...p)=>{const b={...d};for(const I of p)for(const x of Object.keys(b)){if(!(x in I)){delete b[x];continue}const V=b[x],W=I[x];(typeof V!=typeof W||JSON.stringify(V)!==JSON.stringify(W))&&delete b[x]}return b},zj=async(d,p,b,I)=>{const x=m2(d),V=x.props??{},W=x.styleRef??null,re=V.alignment??null,fe=V.spacing??null,Me=V.indent??null,$e=Me?{...Me.left!=null?{left:Me.left}:{},...Me.right!=null?{right:Me.right}:{},...Me.firstLine!=null?{firstLine:Me.firstLine}:{},...Me.hanging!=null?{hanging:Me.hanging}:{}}:null,We=V.markRunProps??null,Je=V.numbering?.numId,nt=typeof Je=="string"?parseInt(Je,10):typeof Je=="number"?Je:NaN,Ge=V.numbering?.level,rt=isNaN(nt)?null:{numId:nt,...Ge!=null?{level:Ge}:{}};let ht=null;if(rt&&typeof b.lists?.getState=="function")try{const dt=await b.lists.getState({target:bo(p,I)});dt&&typeof b.lists?.getStyle=="function"&&(ht=await b.lists.getStyle(dt)??null)}catch{}return{styleId:W,alignment:re,spacing:fe,indentation:$e,markRunProps:We,numbering:rt,listStyle:ht}},LA=async()=>{if(h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;const d=y()?.selection,p=async()=>{const W=typeof d?.current=="function"?await Promise.resolve(d.current({includeText:!0})):Ra().value;return Ni(W)},b=()=>new Promise(W=>setTimeout(W,16)),I=8;let x=null,V="";for(let W=0;W<I;W+=1){if(W>0&&await b(),h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;if(x=await p(),!(!x||x.empty)&&(V=nc(x),V!==h.sourceSelectionKey))break}if(x&&!x.empty&&V!==h.sourceSelectionKey){await MA(x);return}if(h.snapshot?.paragraph){const W=await p();if(!W||nc(W)===h.sourceSelectionKey)return;await MA(W)}},MA=async d=>{const p=h.snapshot;if(!p){h.mode==="armed"&&Im();return}const b=y();if(!b)return;const I=Hs(d,"ready"),{lockModesById:x}=ss(b.contentControls,I);if(ci(x)){bt();return}const V=d.target,W=d.selectionTarget;if(d.empty!==!0&&Object.keys(p.inline).length>0){const re=vr(b,"format.apply");if(re&&W)try{if(!wo(Ns(await Promise.resolve(p2("format.apply",re,{target:W,inline:p.inline},d))))){bt();return}}catch{bt();return}}if(p.paragraph){const re=Array.isArray(V?.segments)?V.segments:[],fe=V?.story;for(const Me of re){const $e=bo(Me.blockId,fe),We=await Sl($e),Je=We?.node??null,nt=We?.address??null;if(!Je)continue;const Ge={kind:"block",nodeType:nt?.nodeType??Je.kind??"paragraph",nodeId:Me.blockId,...fe&&typeof fe=="object"?{story:fe}:{}},{styleId:rt,alignment:ht,spacing:dt,indentation:it,markRunProps:zt,numbering:Vt,listStyle:Hn}=p.paragraph;if(rt&&await b.styles?.paragraph?.setStyle?.({target:Ge,styleId:rt}),ht&&await b.format?.paragraph?.setAlignment?.({target:Ge,alignment:ht}),dt){const $n=dt,Gr=$n.lineRule??"auto",Wr=new Set(["auto","exact","atLeast"]).has(Gr)?Gr:"auto",Sr={...$n.before!=null?{before:Math.round($n.before*20)}:{},...$n.after!=null?{after:Math.round($n.after*20)}:{},...$n.line!=null?{line:Math.round(Wr==="auto"?$n.line*240:$n.line*20),lineRule:Wr}:{}};await b.format?.paragraph?.setSpacing?.({target:Ge,...Sr})}if(it){const $n={...it.left!=null?{left:Fs(it.left)}:{},...it.right!=null?{right:Fs(it.right)}:{},...it.firstLine!=null?{firstLine:Fs(it.firstLine)}:{},...it.hanging!=null?{hanging:Fs(it.hanging)}:{}};await b.format?.paragraph?.setIndentation?.({target:Ge,...$n})}zt&&await b.format?.paragraph?.setMarkRunProps?.({target:Ge,markRunProps:zt}),Vt&&await b.format?.paragraph?.setNumbering?.({target:Ge,...Vt}),Hn&&((await Sl($e))?.address?.nodeType==="listItem"?await b.lists?.applyStyle?.({target:gA(Me.blockId,fe),style:Hn}):Vt&&await b.format?.paragraph?.setNumbering?.({target:Ge,...Vt}))}}h.mode==="armed"&&Im(),bt()},xm=(d,p,b)=>{const I=Oj(d,p),x=I?I.then(()=>(bc(d,p,b),hi)):(bc(d,p,b),hi);return vu(d)?.inline?.kind==="toggle"&&(Ku=x),x},PA=d=>({id:d,getState:()=>qe.toolbar.commands[d]??Uu(d,y(),qe.selection,Vi(qe.selection)),observe:p=>Wo(b=>b.toolbar.commands[d]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:ct.commandUnsupported}).subscribe(p),execute:p=>bc(d,p),executeAsync:p=>xm(d,p)}),Vj=d=>{oe.set(d.id,d),bt();const p=()=>{oe.delete(d.id),bt()};return Object.assign(p,{handle:PA(d.id),unregister:p})},Em=Ko(d=>d.selection),Tm=qo(Em),DA=()=>{const d=M();if(typeof d?.getHandles!="function")return{reason:ct.hostCapabilityUnavailable};let p=null;try{p=d.getHandles()}catch(I){const x=I?.reason;return{reason:x==="host-not-ready"||x==="host-disposed"||x==="editing-mount-required"?ct.notReady:ct.hostCapabilityUnavailable}}const b=p?.editing?.selectionTargets;return typeof b?.apply!="function"?{reason:ct.hostCapabilityUnavailable}:{helper:b}},jj=d=>{const p=M();if(typeof p?.getHandles=="function")try{const b=p.getHandles()?.editing?.contentControls;typeof b?.activate=="function"&&b.activate({id:d})}catch{}},OA={get:Tm.get,getSnapshot:Tm.getSnapshot,subscribe:Tm.subscribe,observe:Tm.observe,current:()=>Ra().value,capture:()=>{const d=Em.get();return d.empty||!d.target&&!d.selectionTarget?null:{...d,capturedAt:Date.now()}},restore:d=>{const p=x=>(bt(),{...x,success:x.ok});if(!d||typeof d!="object")return p({ok:!1,reason:ct.targetUnresolved});if(!_())return p({ok:!1,reason:ct.notReady});const b=RV(d);if(!b)return p({ok:!1,reason:ct.targetUnresolved});const I=DA();if(!("helper"in I))return p({ok:!1,reason:I.reason});try{return p(lA(I.helper.apply(b)))}catch{return p({ok:!1,reason:ct.hostCapabilityUnavailable})}},apply:d=>{if(!_())return{ok:!1,reason:ct.notReady};const p=DA();if(!("helper"in p))return{ok:!1,reason:p.reason};try{const b=p.helper.apply(d);return bt(),lA(b)}catch{return{ok:!1,reason:ct.hostCapabilityUnavailable}}},getAnchorRect:d=>{const p=M();if(typeof p?.getSelectionAnchorRect=="function"){const b=Pt(()=>p.getSelectionAnchorRect(d),null);return b&&typeof b=="object"&&(Number(b.width)>0||Number(b.height)>0)?b:null}return null},getRects:d=>{const p=Em.get(),b=p.selectionTarget??p.target;if(p.empty||!b)return[];const I=Bm.getRect({target:b,relativeTo:d?.relativeTo});return I.found?I.rects:[]}},Uj={get ids(){return kn()},has:d=>vu(d)!=null||oe.has(d),get:d=>PA(d),execute:bc,executeAsync:xm,register:Vj,getContextMenuItems:d=>{const p=[];for(const b of oe.values()){const I=b.contextMenu;I&&Pt(I.when?()=>I.when(d):void 0,!0)&&p.push({id:b.id,label:I.label,group:I.group,order:I.order,invoke:()=>bc(b.id,void 0,d)})}return p.sort((b,I)=>(b.order??0)-(I.order??0)||b.label.localeCompare(I.label))}},g2=qo(Ko(d=>d.toolbar)),Hj={get:g2.get,getSnapshot:()=>qe.toolbar,subscribe:g2.subscribe,observe:g2.observe,execute:bc,executeAsync:xm},wc=async(d,p)=>{if(!_())return{success:!1,ok:!1,reason:ct.notReady};if(!d)return{success:!1,ok:!1,reason:ct.targetUnresolved};const b=M(),I=b?.scrollTargetIntoView;if(typeof I!="function")return{success:!1,ok:!1,reason:ct.hostCapabilityUnavailable};try{const x={target:d,block:p?.block??"center",behavior:p?.behavior??"smooth"},V=await Promise.resolve(p?.shouldContinue?I.call(b,x,p.shouldContinue):I.call(b,x));return V&&typeof V=="object"&&V.success===!1?{success:!1,ok:!1,reason:e2(V.reason,ct.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:ct.hostCapabilityUnavailable}}},Rm=async(d,p,b,I)=>{const x=d==="trackChanges"?I?.story:void 0,V=dt=>{if(!x||!dt||typeof dt!="object")return dt;const it=dt,zt=it.address&&typeof it.address=="object"?it.address:null;return it.story||zt?.story?dt:{...it,story:x}},W=d==="trackChanges"?dA:Lf,re=b.find(dt=>Ji(dt,p,x)),fe=re&&typeof re=="object"?re:null,Me=d==="trackChanges"&&fe?.type==="move"&&(fe.subtype==="move-to"||fe.subtype==="move-from")?fe.subtype:null,$e=Me&&typeof fe?.trackedChangeCanonicalId=="string"?fe.trackedChangeCanonicalId:p,We=dt=>{if(!Me)return d==="trackChanges"?dA(dt,{preferStableBlock:!0}):W(dt);const it=Lf(dt);if(it?.kind!=="move")return null;const zt=Me==="move-to"?it.destination:it.source;return t2(zt)?zt:null},Je=W(re),nt=d!=="trackChanges"||!Me&&t2(Lf(re));if(Je&&nt)return V(Je);const Ge=y()?.[d],rt=d==="comments"?{commentId:p}:{id:$e,...x?{story:x}:{}},ht=Ge?.get;if(typeof ht!="function")return V(Je);try{return V(We(await Promise.resolve(ht.call(Ge,rt)))??Je)}catch{return V(Je)}};function FA(d,p){if(Ao())return Yn("Comments are read-only.","DOCUMENT_READONLY");if(Bf())return Yn("Resolving comments is disabled.","DOCUMENT_READONLY");const b=y()?.comments,I=b?.patch;if(typeof I!="function")return Yn("comments.patch is unavailable.");const x=Yn("comments.patch failed.");return Pt(()=>xl(I.call(b,{commentId:d,status:p}),x),x)}const qf=()=>Ao()?Yn("Comments are read-only.","DOCUMENT_READONLY"):null,$j=(d,p)=>{const b=p&&typeof p=="object"?p:null;let I=Array.from(d);b?.includeResolved===!1&&(I=I.filter(fe=>fe.status!=="resolved"));const x=Number(b?.offset),V=Number.isInteger(x)&&x>0?x:0,W=Number(b?.limit),re=Number.isInteger(W)&&W>=0?V+W:void 0;return I.slice(V,re)},Yu=Ko(d=>d.comments),Lm=Gu(Yu,Wo(d=>fc(d.selection,d.comments)),"comments"),Gj={get:Lm.get,getSnapshot:Lm.getSnapshot,subscribe:Lm.subscribe,observe:Lm.observe,list:d=>{ze();const p=is();return $j(p.value??Yu.get().items,d)},getById:d=>{const p=Yu.get().items.find(x=>lo(x)===d)??null;if(p)return p;const b=y()?.comments,I=Pt(b?.get?()=>b.get({commentId:d}):void 0,null);return xr(I)?null:I},createFromCapture:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.create;if(typeof x!="function")return Yn("comments.create is unavailable.");const V=Yn("comments.create failed.");return Pt(()=>{const W=d&&typeof d=="object"?d.target??d.selectionTarget:null;return W==null?Yn("A range selection is required to comment.","NO_SELECTION"):xl(x.call(I,{target:W,text:p.text}),V)},V)},createFromSelection:d=>{const p=qf();if(p)return p;const b=y()?.comments,I=b?.create;if(typeof I!="function")return Yn("comments.create is unavailable.");const x=Em.get(),V=x.target??x.selectionTarget;if(x.empty||!V)return Yn("A range selection is required to comment.","NO_SELECTION");const W=Yn("comments.create failed.");return Pt(()=>xl(I.call(b,{target:V,text:d.text}),W),W)},reply:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.reply??I?.create;if(typeof x!="function")return Yn("comments.reply is unavailable.");const V=Yn("comments.reply failed.");return Pt(()=>xl(x===I?.reply?x.call(I,{parentCommentId:d,text:p.text}):x.call(I,{parentCommentId:d,text:p.text}),V),V)},edit:(d,p)=>{const b=qf();if(b)return b;const I=y()?.comments,x=I?.patch;if(typeof x!="function")return Yn("comments.patch is unavailable.");const V=Yn("comments.patch failed.");return Pt(()=>xl(x.call(I,{commentId:d,text:p.text}),V),V)},resolve:d=>FA(d,"resolved"),reopen:d=>FA(d,"active"),delete:d=>{const p=qf();if(p)return p;const b=y()?.comments,I=b?.delete??b?.remove;if(typeof I!="function")return Yn("comments.delete is unavailable.");const x=Yn("comments.delete failed.");return Pt(()=>xl(I.call(b,{commentId:d}),x),x)},setActive:d=>{if(d==null)return Re=null,bt(),!0;if(!_())return!1;const p=Yu.get(),b=z.get("comments"),I=b?.token===ln()&&b.hasSettled&&Array.isArray(b.value)?b.value:null,x=I??p.items;if(!I&&p.listStatus!=="ready")return!1;const V=dV(x,d);return!V||!x.some(W=>lo(W)===V)?!1:(Re=V,bt(),!0)},scrollTo:async d=>{if(!y())return{success:!1,ok:!1,reason:_()?ct.documentApiUnavailable:ct.notReady};const p=await Rm("comments",d,Yu.get().items);return p?wc(p):{success:!1,ok:!1,reason:ct.targetUnresolved}}},Oa=Ko(d=>d.trackChanges),v2=(d,p)=>{we();const b=(Ma().value??Oa.get().items).map(Of).filter(We=>We!=null&&lo(We)!==null);if(b.length===0)return null;const I=qe.trackChanges.activeId,x=je?.id===I?je.story:void 0,V=b.filter(We=>um(We)==null),W=x||V.length===0?b:V;let re=I?W.findIndex(We=>Ji(We,I,x)):-1;re===-1&&I&&x&&(re=W.findIndex(We=>Ji(We,I)));const fe=W[re===-1?d>0?0:W.length-1:(re+d+W.length)%W.length],Me=lo(fe),$e=um(fe);return ne($e?{id:Me,story:$e}:{id:Me},p),bt(),Me},NA=async d=>{const p=w(),b=p?.listTrackedChanges;if(typeof b=="function")try{await Promise.resolve(b.call(p,{mode:"visible-window",targetIds:[d],refreshReason:"ui-track-change-reveal-restamp",blocking:!0}))}catch{}};let BA=Promise.resolve();const Wj=d=>{const p=St;return BA.catch(()=>{}).then(()=>Kj(d,p))},Kj=async(d,p)=>{if(St!==p)return{success:!1};const b=je,I=v2(d,{invalidateQueuedNavigation:!1});if(I==null)return{success:!1};const x=je,V=et,W=()=>St===p&&je===x&&et===V,re=()=>{W()&&(ne(b,{invalidateQueuedNavigation:!1}),bt())};x&&He.add(x);try{const fe=await Rm("trackChanges",I,Oa.get().items,x?.story?{story:x.story}:void 0);if(!W())return{success:!1};if(!fe)return re(),{success:!1};$t+=1;try{const Me=await wc(fe,{behavior:"auto",shouldContinue:W});if(!W())return{success:!1};if(!Me.ok&&Me.reason!==ct.targetNotVisible)re(),S(b);else{if(Me.ok&&await NA(I),!W())return{success:!1};S(x)}return{success:Me.ok}}finally{$t=Math.max(0,$t-1),$t===0&&(W()?Fo&&Sn(mt(Fo)):S(je))}}finally{x&&He.delete(x)}},zA=d=>{const p=Wj(d);return BA=p.then(()=>{},()=>{}),p},Mm=Gu(Oa,Wo(d=>Tu(d.selection,d.trackChanges)),"trackChanges"),qj={get:Mm.get,getSnapshot:Mm.getSnapshot,subscribe:Mm.subscribe,observe:Mm.observe,list:()=>{we();const d=Ma().value??Oa.get().items,p=Dt(ln());return d.map(Of).filter(b=>b!=null).filter(b=>{const I=lo(b);return!I||!p?.has(I)})},accept:d=>y2("accept",d),reject:d=>y2("reject",d),acceptAll:()=>Yf("accept",{kind:"all"},null),rejectAll:()=>Yf("reject",{kind:"all"},null),next:()=>v2(1),previous:()=>v2(-1),navigateNext:()=>zA(1),navigatePrevious:()=>zA(-1),getAt:d=>{if(!d||typeof d!="object"||typeof d.x!="number"||typeof d.y!="number")return null;const p=C2(d);if(p.length===0)return null;const b=Oa.get().items;let I;for(const x of p){if(x.type!=="trackedChange")continue;let V;if(x.story){if(I===void 0&&(I=Bi()),!I)continue;V=I}else V=b;const W=V.find(re=>Ji(re,x.id,x.story));if(W)return x.story?{id:W.id,item:W,story:x.story}:{id:W.id,item:W}}return null},setActive:d=>{if(d==null)return ne(null),S(null),bt(),!0;if(!_())return!1;const p=typeof d=="string"?{id:d}:{id:d.id,story:d.story};if(typeof p.id!="string"||p.id.length===0)return!1;const b=p.id;if(p.story){const I=Bi();if(!I)return!1;const x=oc(I,p.story).toPublicId(p.id)??p.id;if(!I.some(V=>Ji(V,x,p.story)))return!1;p.id=x}else{const I=Bi()??Oa.get().items,x=Os(I).toPublicId(p.id)??p.id,V=I.find(W=>lo(W)===x);if(!V)return!1;p.id=x,p.story=um(V)}return b!==p.id&&(p.paintedEntityId=b),ne(p),S(p),bt(),!0},scrollTo:async d=>{if(!y())return{success:!1,ok:!1,reason:_()?ct.documentApiUnavailable:ct.notReady};St+=1,Te+=1;const p=Te,b=Oa.get().items,I=Os(b).toPublicId(d)??d,x=um(b.find(re=>lo(re)===I)),V=je,W={id:I,...x?{story:x}:{},...I!==d?{paintedEntityId:d}:{}};He.add(W);try{const re=await Rm("trackChanges",I,b,x?{story:x}:void 0);if(Te!==p)return{success:!1,ok:!1};if(!re)return{success:!1,ok:!1,reason:ct.targetUnresolved};ne(W);const fe=Te,Me=je,$e=et,We=()=>Te===fe&&je===Me&&et===$e,Je=()=>{We()&&(ne(V,{invalidateQueuedNavigation:!1}),bt())};bt(),$t+=1;try{const nt=await wc(re,{behavior:"auto",shouldContinue:We});if(!We())return{success:!1,ok:!1};if(!nt.ok&&nt.reason!==ct.targetNotVisible)Je(),S(V);else{if(nt.ok&&await NA(I),!We())return{success:!1,ok:!1};S(W)}return nt}finally{$t=Math.max(0,$t-1),$t===0&&(We()?Fo&&Sn(mt(Fo)):S(je))}}finally{He.delete(W)}}},y2=(d,p)=>{const{id:b,story:I}=typeof p=="string"?{id:p,story:void 0}:p,x={kind:"id",id:b,...I?{story:I}:{}};return Yf(d,x,b,I)},Yf=(d,p,b,I)=>{try{return xo(b2(d,p,b,I))}catch{return!1}},b2=(d,p,b,I)=>{if(Ao())return!1;const x=y()?.trackChanges,V=p.kind==="all"||p.scope==="all",W=p.kind==="range",re=p.kind==="ids";if(ju({kind:d,scope:V?"all":"id"},x))return!1;const fe=V?`${d}All`:d,Me=!W&&!re&&!I&&x&&typeof x[fe]=="function"?x[fe]:null,$e=x&&typeof x.decide=="function"?x.decide:null;return!Me&&!$e?!1:Me?Me.call(x,b??{}):$e.call(x,{decision:d,target:p})},w2=Ko(d=>d.contentControls),Xf=d=>w2.get().items.find(p=>p?.id===d)??null,Pm=qo(w2),Yj=(d=>{if(d===void 0)return Pm.get();const p=dm(d);return p?Xf(p):null}),Xj={get:(d=>(d!==void 0&&ii("api"),Yj(d))),getSnapshot:Pm.getSnapshot,subscribe:Pm.subscribe,observe:Pm.observe,list:()=>(ii("api"),w2.get().items),getById:d=>(ii("api"),Xf(d)),getRect:d=>{const p=dm(d);if(!p)return pl("unresolved");ii("panel");const b=Xf(p);if(!b)return pl("unresolved");const I=n2(b);return I?Bm.getRect({target:I}):pl("unavailable")},scrollIntoView:async d=>{const p=dm(d);if(!p)return{success:!1};ii("panel");const b=Xf(p);if(!b)return{success:!1};const I=n2(b);return I?{success:(await wc(I,{block:d.block,behavior:d.behavior})).ok}:{success:!1}},focus:async d=>{const p=dm(d);if(!p)return{success:!1,reason:"invalid-id"};if(!_())return{success:!1,reason:"not-ready"};ii("panel");const b=Xf(p);if(!b)return{success:!1,reason:"not-found"};const I=n2(b);if(!I)return{success:!1,reason:"not-reachable"};if(!(await wc(I,{block:d.block,behavior:d.behavior})).ok)return{success:!1,reason:"not-reachable"};const x=iV(I);if(!x)return{success:!1,reason:"not-reachable"};const V=OA.apply(x);return!V.ok&&V.reason!==ct.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:(jj(p),{success:!0})}},Dm=qo(Ko(d=>d.fonts)),Zj={get:Dm.get,getSnapshot:Dm.getSnapshot,subscribe:Dm.subscribe,observe:Dm.observe,getFamilyOptions:()=>qe.fonts.options,getSizeOptions:()=>qe.fonts.sizeOptions},Om=qo(Ko(d=>d.zoom)),Qj={get:Om.get,getSnapshot:Om.getSnapshot,subscribe:Om.subscribe,observe:Om.observe,set:d=>{if(typeof t?.setZoom=="function")try{t.setZoom(d),bt()}catch{}},setMode:d=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(d),bt()}catch{}}},Fm=qo(Ko(d=>d.document)),Jj={get:Fm.get,getSnapshot:Fm.getSnapshot,subscribe:Fm.subscribe,observe:Fm.observe,setMode:d=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(d),bt()}catch{}},export:d=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(d))}catch{return}},getText:()=>{const d=y(),p=Pt(d?.getText?()=>d.getText({}):void 0,null);return typeof p=="string"?p:p&&typeof p=="object"&&typeof p.text=="string"?p.text:null},replaceFile:d=>{const p=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof p=="function")try{return Promise.resolve(p.call(t,d))}catch{return}}},VA=()=>{if(typeof HTMLElement>"u")return null;const d=_()?.mount?.container;if(d instanceof HTMLElement)return d;const p=t?.element;return p instanceof HTMLElement?p:null},eU=(d,p)=>{if(typeof d!="number"||typeof p!="number"||!Number.isFinite(d)||!Number.isFinite(p))return[];const b=globalThis.document;if(!b||typeof b.elementFromPoint!="function")return[];const I=VA();if(!I)return[];const x=b.elementFromPoint(d,p);if(!x||!I.contains(x))return[];const V=[x],W=it=>{it&&I.contains(it)&&!V.includes(it)&&V.push(it)},re=b.elementsFromPoint;if(typeof re=="function"){let it=[];try{it=re.call(b,d,p)??[]}catch{it=[]}for(const zt of it)W(zt)}const fe=[],Me=it=>{it&&I.contains(it)&&!fe.includes(it)&&!V.includes(it)&&fe.push(it)},$e=it=>{const zt=it.getBoundingClientRect;if(typeof zt!="function")return!1;let Vt;try{Vt=zt.call(it)}catch{return!1}return Vt!=null&&d>=Vt.left&&d<=Vt.right&&p>=Vt.top&&p<=Vt.bottom};for(const it of V){const zt=it.querySelectorAll;if(typeof zt!="function")continue;let Vt;try{Vt=zt.call(it,"[data-track-change-marker]")}catch{continue}for(let Hn=0;Hn<Vt.length;Hn+=1)$e(Vt[Hn])&&Me(Vt[Hn])}fe.reverse();const We=[...fe,...V],Je=aA(We[0],I);for(let it=1;it<We.length;it+=1)for(const zt of aA(We[it],I))Je.push(zt);if(Je.length===0)return Je;const nt=Oa.get().items,Ge=Os(nt);let rt;const ht=new Set,dt=[];for(const it of Je){if(it.type!=="trackedChange"){const $n=`${it.type}:${it.id}`;if(ht.has($n))continue;ht.add($n),dt.push(it);continue}const zt=oV(it.storyKey)??rV(it.story);let Vt;if(zt){if(rt===void 0&&(rt=Bi()),!rt||(Vt=oc(rt,zt).toPublicId(it.id),!Vt||!rt.some($n=>Ji($n,Vt,zt))))continue}else if(Vt=Ge.toPublicId(it.id),!Vt)continue;const Hn=`trackedChange:${Vt}`;ht.has(Hn)||(ht.add(Hn),dt.push(zt?{type:"trackedChange",id:Vt,story:zt}:{type:"trackedChange",id:Vt}))}return dt};function C2(d,p){return typeof d=="object"?eU(d?.x,d?.y):null}const Xu=new Set;let k2=!1;const jA=d=>{const p=M();if(typeof p?.observeGeometry!="function")return;let b=!1;const I=Pt(()=>{const x=p.observeGeometry(()=>d.schedule());return b=!0,x},null);d.detach=typeof I=="function"?I:null,d.boundHost=b?p:null},Nm=d=>{if(d.detach){try{d.detach()}catch{}d.detach=null}d.boundHost=null},UA=()=>{if(k2=!1,!(U||M()))for(const d of Xu)Nm(d)},tU=()=>{if(!k2){if(k2=!0,typeof queueMicrotask=="function"){queueMicrotask(UA);return}Promise.resolve().then(UA)}},nU=()=>{const d=M();if(!d){tU();return}for(const p of Xu)p.boundHost&&p.boundHost===d||(Nm(p),jA(p),p.schedule())};rr.push(nU);const Bm={getRect:d=>{const p=M(),b=p?.getTargetRects;if(typeof b=="function"){const I=Pt(()=>b.call(p,{target:d.target}),null);return I&&typeof I=="object"?I.success===!0&&Array.isArray(I.rects)?EV(xV(I.rects.filter(x=>x!=null&&typeof x=="object")),d.relativeTo):pl(typeof I.reason=="string"?I.reason:"unresolved"):pl("unresolved")}return pl("unavailable")},observe:d=>{const p=[];let b=0;const I=typeof requestAnimationFrame=="function",x=()=>{if(!I){d();return}b||(b=requestAnimationFrame(()=>{b=0,d()}))},V=Wo(re=>({ready:re.ready,selection:re.selection,zoom:re.zoom}));p.push(V.subscribe(()=>x()));const W={schedule:x,detach:null,boundHost:null};return jA(W),Xu.add(W),()=>{Xu.delete(W),Nm(W),b&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(b);for(const re of p.splice(0))try{re()}catch{}}},getHost:()=>VA(),entityAt:C2,contextAt:d=>{const p=!!d&&typeof d.x=="number"&&typeof d.y=="number",b=p?d.x:0,I=p?d.y:0;return{point:{x:b,y:I},entities:p?C2({x:b,y:I}):[],selection:qe.selection,position:null,insideSelection:!1}},scrollIntoView:async d=>{const p=d?.target;if(!p)return{success:!1};let b=null;if(p.kind==="entity"){const I=p.entityType==="comment"?"comments":"trackChanges",x=I==="comments"?Yu.get().items:Oa.get().items,V=p.entityType==="trackedChange"&&p.story?{story:p.story}:void 0;b=await Rm(I,p.entityId,x,V)}else{const I=p,x=p,V=Array.isArray(I.segments)&&I.segments.length>0?I.segments:x.blockId&&x.range?[{blockId:x.blockId,range:x.range}]:null;if(V){const W=p.story;b={kind:"text",segments:V,...W?{story:W}:{}}}}return b?{success:(await wc(b,{block:d.block??"center",behavior:d.behavior??"smooth"})).ok}:{success:!1}}},HA=d=>{const p=(d&&typeof d=="object"?d:null)?.target;return p&&typeof p=="object"?p:null},$A=d=>`metadata:resolve:${d}`,rU=d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return null;const{value:b}=uo($A(d),ln(),()=>p.resolve({id:d}),HA);return b},oU=async d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return null;try{const b=ln(),I=await Promise.resolve(p.resolve({id:d}));if(b!==ln())return null;const x=HA(I);return z.set($A(d),{token:b,value:x,hasSettled:!0,inflightToken:null}),x}catch{return null}},iU={getRect:d=>{const p=y()?.metadata;if(!p||typeof p.resolve!="function")return pl("unavailable");const b=rU(d.id);return b?Bm.getRect({target:b}):pl("unresolved")},scrollIntoView:async d=>{const p=await oU(d.id);return p?{success:(await wc(p,{block:d.block,behavior:d.behavior})).ok}:{success:!1}}},sU={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},aU={getContext:()=>{const d=_e();if(!d)return{...sU};const p=me()?.table;return{inTable:!0,tableNodeId:d.tableNodeId,rowIndex:d.rowIndex,columnIndex:d.columnIndex,cellNodeId:d.cellNodeId,rows:typeof p?.rows=="number"?p.rows:null,columns:typeof p?.columns=="number"?p.columns:null}},isInTable:()=>_e()!=null},zm={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeDeletedText:!1,regex:!1,canReplace:!1,reason:ct.searchUnavailable};let Bn={...zm};const Vm=new Set,Fa=()=>{const d=M()?.search;return d&&typeof d=="object"?d:null},Qs=()=>{const d=se()?.search;return d&&typeof d=="object"?d:null},Zf=()=>{const d=Fa();if(d&&typeof d.setSession=="function")return!0;const p=Qs();return!!p&&typeof p.query=="function"&&typeof p.getState=="function"},hs=()=>{for(const d of[...Vm])try{d(Bn)}catch{}},pi=d=>(Bn={...Bn,...d},hs(),Bn);let eo=0,Cc=null;const GA=()=>{const d=Cc;Cc=null,d&&Pt(()=>(d(),null),null)},lU=()=>{eo+=1,GA();const d=Zf();Bn={...zm,available:d,reason:d?void 0:ct.searchUnavailable},hs()};Nn.push(lU);const cU=d=>{if(!d)return!1;const p=d.queryError;if(p&&typeof p=="object"&&p.code==="invalid-pattern")return!0;const b=d.rejection;return d.status==="rejected"&&!!b&&typeof b=="object"&&b.code==="invalid-pattern"},S2=(d,p=!1)=>{const b=d&&typeof d=="object"?d:null;if(!b)return null;const I=Array.isArray(b.matches)?b.matches:[],x=typeof b.total=="number"&&Number.isFinite(b.total)?b.total:I.length,V=typeof b.activeMatchIndex=="number"?b.activeMatchIndex:typeof b.activeIndex=="number"?b.activeIndex:-1;return{...typeof b.query=="string"?{query:b.query}:{},total:x,activeIndex:V,canReplace:b.canReplace===!0||p,...b.includeDeletedText===!0?{includeDeletedText:!0}:{},...b.regex===!0?{regex:!0}:{},...cU(b)?{invalidPattern:!0}:{}}},Eo=()=>{const d=he("find.replace"),p=he("find.replaceAll");return d?.enabled===!0||p?.enabled===!0},To=(d,p=!1)=>{const b=S2(d,p);if(!b){pi({total:0,activeIndex:-1,canReplace:!1,reason:void 0});return}pi({...b.query!==void 0?{query:b.query}:{},total:b.total,activeIndex:b.activeIndex,canReplace:b.canReplace,...b.includeDeletedText!==void 0?{includeDeletedText:b.includeDeletedText}:{},...b.regex!==void 0?{regex:b.regex}:{},reason:b.invalidPattern?ct.searchInvalidPattern:void 0})},Na=()=>{const d=Fa();if(d&&typeof d.getState!="function")return Bn={...Bn,available:Zf(),reason:Zf()?void 0:ct.searchUnavailable},Bn;if(!d){const b=Qs();if(b&&typeof b.getState=="function"){const I=S2(Pt(()=>b.getState(),null),Eo());if(I)return Bn={...Bn,...I.query!==void 0?{query:I.query}:{},total:I.total,activeIndex:I.activeIndex,canReplace:I.canReplace,available:!0,reason:I.invalidPattern?ct.searchInvalidPattern:void 0,open:Bn.open||!!I.query},Bn}return Bn={...zm,query:Bn.query,caseSensitive:Bn.caseSensitive,includeDeletedText:Bn.includeDeletedText},Bn}const p=S2(Pt(()=>d.getState(),null));return p&&(Bn={...Bn,...p.query!==void 0?{query:p.query}:{},total:p.total,activeIndex:p.activeIndex,canReplace:p.canReplace,...p.includeDeletedText!==void 0?{includeDeletedText:p.includeDeletedText}:{},...p.regex!==void 0?{regex:p.regex}:{},available:!0,reason:p.invalidPattern?ct.searchInvalidPattern:void 0,open:Bn.open||!!p.query}),Bn},Zu=d=>{const p=d&&typeof d=="object"?d:null;if(p?.status==="committed")return{ok:!0};if(p?.status==="rejected"&&p.reason==="read-only")return{ok:!1,reason:ct.documentReadonly};const b=p?.rejection;return p?.status==="rejected"&&b&&typeof b=="object"&&b.code==="read-only-document"?{ok:!1,reason:ct.documentReadonly}:{ok:!1,reason:ct.operationUnavailable}},jm=qo({get:()=>Na(),subscribe:d=>(Vm.add(d),()=>Vm.delete(d))}),uU={get:jm.get,getSnapshot:jm.getSnapshot,subscribe:jm.subscribe,observe:jm.observe,open:()=>Zf()?(pi({available:!0,open:!0,reason:void 0}),{ok:!0}):(pi({available:!1,open:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}),close:()=>{if(eo+=1,Cc)GA();else{const d=Fa();if(d&&typeof d.clear=="function")Pt(()=>d.clear(),null);else{const p=Qs();p&&typeof p.query=="function"&&Pt(()=>p.query({query:""}),null)}}Bn={...zm,available:Zf(),reason:void 0},Bn.available||(Bn.reason=ct.searchUnavailable),hs()},search:(d,p)=>{const b=Fa(),I=!!p?.caseSensitive,x=p?.includeDeletedText===!0,V=p?.regex===!0,W=++eo;if(!b||typeof b.setSession!="function"){const fe=Qs();if(fe&&typeof fe.query=="function"&&typeof fe.getState=="function"){pi({query:d,caseSensitive:I,includeDeletedText:x,regex:V,available:!0,open:!0,reason:void 0}),Cc=()=>{fe.query({query:""})};const Me=Pt(()=>fe.query({query:d,caseSensitive:I,includeDeletedText:x,regex:V}),null);return xr(Me)?Promise.resolve(Me).then($e=>{W===eo&&To($e,Eo())},()=>{W===eo&&pi({available:!1,reason:ct.searchUnavailable})}):To(Me,Eo()),To(Pt(()=>fe.getState(),null),Eo()),Bn}return pi({query:d,total:0,activeIndex:-1,available:!1,caseSensitive:I,includeDeletedText:x,regex:V,reason:ct.searchUnavailable})}pi({query:d,caseSensitive:I,includeDeletedText:x,regex:V,available:!0,open:!0,reason:void 0}),Cc=()=>{typeof b.clear=="function"&&b.clear()};const re=Pt(()=>b.setSession(d,{caseSensitive:I,includeDeletedText:x,...V?{regex:!0}:{},highlight:!0}),null);if(To(re),d.length>0&&Bn.total===0&&Bn.reason!==ct.searchInvalidPattern){const fe=Qs();if(fe&&typeof fe.query=="function"&&typeof fe.getState=="function"){const Me=Cc;Cc=()=>{Me?.(),fe.query({query:""})};const $e=Pt(()=>fe.query({query:d,caseSensitive:I,includeDeletedText:x,regex:V}),null);xr($e)?Promise.resolve($e).then(We=>{W===eo&&To(We,Eo())},()=>{W===eo&&pi({available:!1,reason:ct.searchUnavailable})}):To($e,Eo()),To(Pt(()=>fe.getState(),null),Eo())}}return Bn},next:()=>{const d=Fa();if(!d||typeof d.next!="function"){const p=Qs();if(!p||typeof p.next!="function"||typeof p.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(Bn.total===0)return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.next(),null);if(xr(b)){const I=eo;Promise.resolve(b).then(x=>{I===eo&&To(x,Eo())}).catch(()=>{I===eo&&pi({available:!1,reason:ct.searchUnavailable})})}else To(b,Eo());return To(Pt(()=>p.getState(),null),Eo()),{ok:!0}}return Bn.total===0?{ok:!1,reason:ct.operationUnavailable}:(To(Pt(()=>d.next(),null)),{ok:!0})},previous:()=>{const d=Fa();if(!d||typeof d.previous!="function"){const p=Qs();if(!p||typeof p.previous!="function"||typeof p.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(Bn.total===0)return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.previous(),null);if(xr(b)){const I=eo;Promise.resolve(b).then(x=>{I===eo&&To(x,Eo())}).catch(()=>{I===eo&&pi({available:!1,reason:ct.searchUnavailable})})}else To(b,Eo());return To(Pt(()=>p.getState(),null),Eo()),{ok:!0}}return Bn.total===0?{ok:!1,reason:ct.operationUnavailable}:(To(Pt(()=>d.previous(),null)),{ok:!0})},clear:()=>{eo+=1;const d=Fa();if(d&&typeof d.clear=="function"&&Pt(()=>d.clear(),null),!d||typeof d.clear!="function"){const p=Qs();p&&typeof p.query=="function"&&Pt(()=>p.query({query:""}),null)}pi({query:"",total:0,activeIndex:-1,canReplace:!1})},replace:d=>{const p=Fa();if(!p){const I=Qs();if(!I||typeof I.replace!="function"||typeof I.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(!Eo())return{ok:!1,reason:ct.operationUnavailable};const x=Pt(()=>I.replace({replacement:typeof d=="string"?d:""}),null);if(xr(x)){const V=eo;Na(),hs();const W=()=>V===eo;return Promise.resolve(x).then(re=>(W()&&(To(re,Eo()),Na(),hs()),Zu(re)),()=>(W()&&pi({available:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}))}return Na(),hs(),Zu(x)}if(typeof p.replaceCurrent!="function")return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.replaceCurrent(typeof d=="string"?d:""),null);return Na(),hs(),Zu(b)},replaceAll:d=>{const p=Fa();if(!p){const I=Qs();if(!I||typeof I.replaceAll!="function"||typeof I.getState!="function")return{ok:!1,reason:ct.searchUnavailable};if(!Eo())return{ok:!1,reason:ct.operationUnavailable};const x=Pt(()=>I.replaceAll({replacement:typeof d=="string"?d:""}),null);if(xr(x)){const V=eo;Na(),hs();const W=()=>V===eo;return Promise.resolve(x).then(re=>(W()&&(To(re,Eo()),Na(),hs()),Zu(re)),()=>(W()&&pi({available:!1,reason:ct.searchUnavailable}),{ok:!1,reason:ct.searchUnavailable}))}return Na(),hs(),Zu(x)}if(typeof p.replaceAll!="function")return{ok:!1,reason:ct.operationUnavailable};const b=Pt(()=>p.replaceAll(typeof d=="string"?d:""),null);return Na(),hs(),Zu(b)}},WA=Ko(d=>d.styles),Um=qo(WA),dU={get:Um.get,getSnapshot:Um.getSnapshot,subscribe:Um.subscribe,observe:Um.observe,getCatalog:d=>An(d).value,getQuickGallery:()=>WA.get().quickGallery,getActiveParagraphStyle:()=>Zr(qe.selection,mn().cache).style},KA={select:Wo,get state(){return qe},selection:OA,commands:Uj,toolbar:Hj,comments:Gj,trackChanges:qj,contentControls:Xj,fonts:Zj,zoom:Qj,document:Jj,viewport:Bm,metadata:iU,tables:aU,search:uU,styles:dU,formatPainter:{setPointerSelecting(d){U||(h={...h,pointerSelecting:d})},notifyPointerUp(){U||(h={...h,pointerSelecting:!1},LA())},setKeyboardSelecting(d){U||(h={...h,keyboardSelecting:d})},notifyKeyUp(){U||(h={...h,keyboardSelecting:!1},LA())},cancel(){U||Im()},onModeChange(d){return U?()=>{}:(m.add(d),()=>m.delete(d))}},createScope:()=>{const d=[];return{select:(p,b)=>{const I=Wo(p,b);return{get:I.get,subscribe:x=>{const V=I.subscribe(x);return d.push(V),V}}},dispose:()=>{for(const p of d.splice(0))p()}}},destroy:()=>{if(!U){U=!0,Kz(Qe,It),De&&(clearTimeout(De),De=null),ve&&(clearTimeout(ve),ve=null,Ce=0),G?.timer&&(clearTimeout(G.timer),G.timer=null),G=null,ot&&(clearTimeout(ot),ot=null),Hr&&(clearTimeout(Hr),Hr=null),yr&&yr(),yr=null,Uo=null,Tn=0,Ur=0,cn.clear(),Rn.clear(),Tr.clear(),Yt=null,J.clear();for(const d of Zs.splice(0))d();dn&&dn(),dn=null,st=null,Ho&&Ho(),Ho=null,Jr=null,$o&&$o(),$o=null,ho=null,di&&di(),di=null,Fo=null,fi&&fi(),fi=null,fs=null,D&&D(),D=null,Xs=null;for(const d of Xu)Nm(d);Xu.clear(),O.clear(),Vm.clear(),g+=1,m.clear(),eo+=1,oe.clear()}}};return $=KA,KA}var FV=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function NV(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function BV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?NV(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function zV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function VV(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:FV;for(const s of i)o(s);return n}var jV=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function UV(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}Rt();var HV=['[data-sdt-type="structuredContent"][data-sdt-id]','[data-sdt-type="structuredContent"][data-sdt-container-id]','[data-sdt-container-type="structuredContent"][data-sdt-container-id]'].join(", "),$V=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function GV(e,t){const n=new f6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function u2(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function SA(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function WV(e,t){if(!e)return()=>{};if(u2(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{SA(e),s()},l=c=>{c!==!1&&(c===!0||u2(e))&&(SA(e),s())};return n("synced",a),n("sync",l),u2(e)&&s(),i}function KV(e,t){const n=e.composedPath();if(!n.includes(t))return null;const r=n.find(a=>a instanceof HTMLElement&&a.matches(HV));if(!r)return null;const o=n.some(a=>a instanceof HTMLElement&&a.classList.contains(Zh.BLOCK_SDT_LABEL)),i=r.getAttribute("data-sdt-container-id")?.trim()||null,s=r.getAttribute("data-sdt-id")?.trim()||null;return o?i??s:s??i}function qV(e){if(!e||typeof e!="object")return[];const t=e.items;return Array.isArray(t)?t:[]}function YV(e){if(!e||typeof e.id!="string"||e.kind!=="inline"&&e.kind!=="block"||typeof e.controlType!="string")return null;const t=e.properties?.tag,n=e.properties?.alias;return{id:e.id,controlType:e.controlType,scope:e.kind,...typeof t=="string"&&t?{tag:t}:{},...typeof n=="string"&&n?{alias:n}:{}}}function ni(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function XV(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function _A(e){return typeof e=="string"&&e.length>0?e:null}function AA(e){return e?ni(e)?_A(e.documentId??e.options?.documentId??null):_A(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function ZV(e){if(!e||ni(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function ns(e){if(!e)return null;if(ni(e))return e.fonts??null;const t=ZV(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var gm=class extends $m.default{static{this.allowedTypes=[Fr,Hl,Kh]}#e;#n;#t;#r;#i;#s;#d;#h;#f;#c;#p;get uiConfig(){return this.#p}#o;get interactionConfig(){return this.#o}#l;get surfacesConfig(){return this.#l}#g;#u;#y;#w;constructor(e){if(super(),this.#e=!1,this.#n=!1,this.#t=null,this.#r=null,this.#i=null,this.#s=null,this.#d=null,this.#h=null,this.#f=n=>{this.#k(n)},this.#c=null,this.#p=F4({}),this.#o=N4({}),this.#l=z4({}),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.#u=new HF,this.#y=null,this.#w=!1,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...$0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},this.#Z=new WeakSet,this.#Q=null,this.#j=null,this.#L=null,!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#g=new LF({getModuleConfig:()=>this.#l}),this.#h=t,t.addEventListener("click",this.#f,!0),this.#I(e,t)}async#k(e){const t=this.#h;if(!t)return;const n=KV(e,t),r=this.activeEditor?.doc?.contentControls?.list;if(!(!n||typeof r!="function"))try{const o=await r();if(this.#e)return;const i=YV(qV(o).find(s=>s.id===n));i&&this.emit("content-control:click",{target:i,source:"pointer"})}catch{return}}async#I(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),BF(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#ye(),this.config.user=zF(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=Pk(this.config.modules.comments),this.#p=F4(this.config),this.#o=N4(this.config),this.#l=z4(this.config),this.config.disableContextMenu=!this.#p.contextMenu.enabled,this.config.rulers=this.#p.ruler.enabled,this.#p.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#p.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&Object.assign(i,this.#o.comments)}if(this.config.colors=w6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.4.0-next.34",this.#C("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||ps(),this.colors=this.config.colors??[],this.#D(),await fT(),this.#e)return;if(await this.#b(this.config.modules),this.#e){this.#ue();return}this.config.cspNonce&&this.#P(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#y||(this.#y=this.#u.subscribe(i=>{this.#we(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#d=o,this.#S(),this.#M(),this.#Ce(),this.#x()}#x(){if(this.#E(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#d)}#M(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new rD({Renderer:EF,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#m("requiredNumberOfEditors").documents.filter(e=>e.type===Fr).length}get ui(){return this.#c||(this.#c=OV({superdoc:this}),this.#e&&this.#c.destroy()),this.#c}get state(){return{documents:this.#m("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#P(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#D(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}else if(n)this.config.documents=[{id:ps(),type:Fr,url:this.config.document,name:"document.docx"}];else if(r){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}else if(o){const s=Gd(this.config.document);this.config.documents=[{id:ps(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=Gd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||ps()}}))}#E(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=GP({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#g),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&Z8(this),this.#ce()}#a(e,t){t&&this.on(e,t)}#S(){this.#a("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#a("editorCreate",this.config.onEditorCreate),this.#a("editorDestroy",this.config.onEditorDestroy),this.#a("source:complete",this.config.onSourceComplete),this.#a("source:signals-complete",this.config.onSourceSignalsComplete),this.#a("ready",this.config.onReady),this.#a("comments-update",this.config.onCommentsUpdate),this.#a("content-control:active-change",this.config.onContentControlActiveChange),this.#a("content-control:click",this.config.onContentControlClick),this.#a("awareness-update",this.config.onAwarenessUpdate),this.#a("locked",this.config.onLocked),this.#a("pdf:document-ready",this.config.onPdfDocumentReady),this.#a("sidebar-toggle",this.config.onSidebarToggle),this.#a("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#$(e?.editor??null)),this.#a("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#a("exception",this.config.onException),this.#a("list-definitions-change",this.config.onListDefinitionsChange),this.#a("pagination-update",this.config.onPaginationUpdate),this.#a("fonts-resolved",this.config.onFontsResolved),this.#a("fonts-changed",this.config.onFontsChanged),this.#a("zoomChange",this.config.onZoomChange),this.#a("viewport-change",this.config.onViewportChange)}async#b({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:ps(),type:Fr,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#ee(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=qr(e),this.provider=qr(t),this.#_();const n=this.config;this._cleanupAwareness=W8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#H(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#A(){if(this.#r){try{this.#r()}catch{}this.#r=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#$(e){this.#A(),ni(e)&&(this.#O(e),this.#T(e))}#O(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=JP(()=>this.user),r=o=>{if(this.#e)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#r=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#T(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#e||this.#v(!!r.isLocked,this.#F(r.lockedBy??null))};try{if(this.#s&&typeof t.setLocked=="function"){const o=this.#s;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#s=null}const r=t.getSnapshot?.();r&&n(r),this.#i=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#F(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#G(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#v(e,t){this.isLocked===e&&this.#G(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#C("🦋 [superdoc] Locking superdoc:",e,t,`
103
103
 
104
104
 
105
105
  `),this.emit("locked",{isLocked:e,lockedBy:t}))}#_(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:$V,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration(e){const{target:t}=this.#pe(e);this.#n=!0;try{const n=await this.#he(),r=this.#W(),o=this.#N();this.#K();try{this.#s=o;const i=await this.#de(t,n);this.#fe(i,t),this.#s=null}catch(i){throw this.#B(r),i}}finally{this.#t=null,this.#n=!1}}#N(){return{isLocked:this.isLocked,lockedBy:this.lockedBy?{...this.lockedBy}:null}}#W(){const e=this.config.documents.find(r=>r.type===Fr),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?yn(t):null;return{isCollaborative:this.isCollaborative,configV2Collaboration:e.v2Collaboration??null,configData:e.data,storeDoc:t,storeV2Collaboration:this.#Y(n),storeData:t?.data}}#B(e){this.#s=null;const t=this.config.documents.find(n=>n.type===Fr);t.v2Collaboration=e.configV2Collaboration,t.data=e.configData,this.isCollaborative=e.isCollaborative,e.storeDoc&&(e.storeDoc.data=e.storeData,this.#z(e.storeDoc,e.storeV2Collaboration))}#K(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#m(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#te(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#R(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#q(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=yn(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#Y(e){if(!e)return null;const t=e.v2Collaboration;return t&&typeof t=="object"&&"value"in t?t.value:t??null}#z(e,t){const n=yn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#ne(e){return e.providerFamily==="liveblocks"?{providerType:"liveblocks",documentId:e.documentId,roomMode:e.roomMode,...e.publicApiKey?{publicApiKey:e.publicApiKey}:{},...e.authEndpoint?{authEndpoint:e.authEndpoint}:{}}:e.providerFamily==="hocuspocus"?{providerType:"hocuspocus",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{},...e.token?{token:e.token}:{}}:{providerType:"y-websocket",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{}}}async#de(e,t){const n=this.config.documents.find(s=>s.type===Fr),r=this.#m("upgradeToCollaboration").documents.find(s=>s.id===n.id);if(!r)throw new Error("SuperDoc: source document store entry is not available for upgrade");const o=r.getEditor?.();if(!ni(o)||typeof o.upgradeToCollaboration!="function")throw new Error("SuperDoc: live v2 editor cannot attach collaboration in place");const i=this.#ne({...e,roomMode:"create"});return n.v2Collaboration=i,this.#z(r,i),this.isCollaborative=!0,await o.upgradeToCollaboration(t,i),n.data=t,r.data=t,{configDoc:n,storeDoc:r}}#fe(e,t){const n=this.#ne({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#z(e.storeDoc,n)}async#he(){const e=this.activeEditor;if(ni(e)&&typeof e.save=="function"){const r=await e.save();return this.#X(r)}const t=this.config.documents.find(r=>r.type===Fr),n=(this.superdocStore?.documents.find(r=>r.id===t.id)??null)?.data??t.data;if(n instanceof Blob)return n;if(n instanceof Uint8Array||n instanceof ArrayBuffer)return this.#X(n);throw new Error("SuperDoc: upgradeToCollaboration() requires a live v2 editor save or DOCX Blob source")}#X(e){if(e instanceof Blob)return e;if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),new Blob([t],{type:Fr})}if(e instanceof ArrayBuffer)return new Blob([e],{type:Fr});throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#re(e,t){const n=AA(e),r=(n?this.config.documents.find(a=>a.id===n):null)??this.config.documents.find(a=>a.type==="application/vnd.openxmlformats-officedocument.wordprocessingml.document");if(!r)return;const o=this.#X(t),i=r.v2Collaboration&&typeof r.v2Collaboration=="object"&&r.v2Collaboration.roomMode==="create"?{...r.v2Collaboration,roomMode:"join"}:null;r.data=o,i&&(r.v2Collaboration=i);const s=this.superdocStore?.documents.find(a=>a.id===r.id)??null;s&&(s.data=o,i&&this.#z(s,i))}#Ae(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getDocumentRuntime?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#Ie(){this.#H(),this.#q(null,null)}#xe(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{i(),r(void 0)};this.#t=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#Ee(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=WV(e,()=>{i||(a(),n())}),i||(o=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#t=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#pe(e){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#n)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");const t=this.config,n=t.documents.filter(c=>c.type===Fr);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(t.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances");if(!ni(this.#ge()))throw new Error("SuperDoc: upgradeToCollaboration() requires a ready v2 DOCX editor");const r=n[0],o=r.id;if(typeof o!="string"||o.length===0)throw new Error("SuperDoc: source document is missing its mounted document identity");const i=t.modules?.collaboration,s=e.ydoc||e.provider?{ydoc:e.ydoc,provider:e.provider}:i?{...i}:null,a=e.v2Collaboration??this.#me(r.v2Collaboration)??i?.v2Collaboration??i?.v2??null,l=GS({v2Collaboration:a,legacyCollaboration:s,documentType:Fr,documentCount:t.documents.length,...typeof window<"u"?{authEndpointBaseUrl:window.location.href}:{}});if(!l.ok)throw new Error(`SuperDoc: upgradeToCollaboration() ${l.reason}: ${l.message}`);return{target:l.target}}#me(e){return e&&typeof e=="object"&&"value"in e?e.value:e}#ge(){const e=this.config.documents.find(n=>n.type===Fr),t=this.#m("upgradeToCollaboration").documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.#R("addSharedUser");const t=Hc({actor:e});t&&this.users.some(n=>Hc({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#R("removeSharedUser");const t=typeof e=="string"?Gv(e):"",n=typeof e=="string"?`email:${t}`:Hc({actor:e});this.users=this.users.filter(r=>{const o=Hc({actor:r});return n?o!==n:t?Gv(r.email)!==t:!0})}onContentError({error:e,editor:t}){const n=t.options?.documentId,r=this.#m("onContentError").documents.find(i=>i.id===n),o=typeof r?.id=="string"?r.id:typeof n=="string"?n:"";this.config.onContentError?.({error:e,editor:t,documentId:o,file:r?.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:x4(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#ve(e),this.emit("editorCreate",{editor:x4(e)})}broadcastSourceComplete(){this.emit("source:complete")}broadcastSourceSignalsComplete(){this.emit("source:signals-complete")}#Z;#ve(e){if(!e||typeof e.on!="function"||this.#Z.has(e))return;this.#Z.add(e),e.on("fonts-changed",n=>{this.#oe(e)&&this.#V(n)});const t=(e.documentRenderer??e.presentationEditor)?.getLastFontsChangedPayload?.();t&&this.#oe(e)&&this.#V(t)}#oe(e){return!this.activeEditor||e===this.activeEditor}#Q;#V(e){this.#Q=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#ye(){Array.isArray(this.config.editorExtensions)&&this.config.editorExtensions.length>0&&console.warn("[SuperDoc] `editorExtensions` is a legacy ProseMirror concept and is ignored by superdoc@2. Use `extensions` with `defineSuperDocExtension`; legacy ProseMirror extensions (Node.create, Mark.create, addPmPlugins, custom schema) do not run in v2.")}#C(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}#j;get fonts(){return this.#j||(this.#j={getReport:()=>ns(this.activeEditor)?.getReport()??[],getMissingFonts:()=>ns(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>ns(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>ns(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>ns(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?ns(t)?.getLastFontsChangedPayload?.()??null:this.#Q??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=ns(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=ns(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=ns(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=ns(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preload(e)}}),this.#j}#U(){const e=this.activeEditor!==null;this.#ie(),this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null),e&&this.emit("active-editor-change")}#L;#ie(){if(this.#L){try{this.#L()}catch{}this.#L=null}}#be(e){this.#ie();const t=ns(e);if(!t?.onChanged)return;const n=t.getLastFontsChangedPayload?.();n&&this.#V(n),this.#L=t.onChanged(r=>this.#V(r))}#we(e,t){this.#w=!0;try{if(e===null){this.#U();return}this.#u.get(e)?.kind==="v2"&&ni(t)?this.#se(t):this.#U()}finally{this.#w=!1}}#se(e){if(ni(e)){!this.#w&&this.#u.getActive()&&this.#u.setActive(null,"set-active-v2-facade");const t=this.activeEditor;this.activeEditor=e,this.#be(e),this.toolbar?.setActiveEditor?.(e),t!==this.activeEditor&&this.emit("active-editor-change");return}this.#U()}setActiveEditor(e){this.#se(e)}getV2FeatureMatrix(){return[{feature:"source.docx-bytes",status:"supported",reason:"SuperDoc normalizes File/Blob/ArrayBuffer/Uint8Array DOCX inputs for the separate DOCX Engine dependency"},{feature:"source.url",status:"supported",reason:"shell-owned source normalization resolves URL-backed DOCX inputs before opening the injected v2 editor"},{feature:"source.blank",status:"supported",reason:"shell-owned blank-document seeding resolves to DOCX bytes before mounting the injected v2 editor"},{feature:"execution.browser-worker",status:"supported",reason:"the shipped public v2 shell opens DOCX documents through the browser-worker path by default when collaboration is not active"},{feature:"distribution.cdn-iife",status:"supported",reason:"the CDN/IIFE distribution ships the public bundle plus the emitted v2 browser-worker asset and opens DOCX documents through the worker-backed v2 runtime"},{feature:"docx.open-render",status:"supported",reason:"superdoc@2 opens and renders DOCX documents through its DOCX Engine dependency"},{feature:"docx.review-handles",status:"supported",reason:"Comment/tracked-change list + decide via v2 host handles"},{feature:"shell.toolbar",status:"supported",reason:"new SuperDoc({ toolbar }) mounts the rendered built-in toolbar shell and the superdoc.toolbar handle, both backed by the V2 command controller and the internal compatibility catalog. Explicit item-level limits stay fail-closed in the shared command matrix (for example search replace and copyFormat)."},{feature:"shell.rich-formatting",status:"supported",reason:"Rich inline, paragraph, and list formatting route through the V2 command controller and public Document API (format.* / styles.* / lists.*): bold, italic, underline, strikethrough, font family/size, text/highlight color, alignment, line spacing, linked styles, bullet/numbered lists, indent, and clear formatting."},{feature:"shell.comments-sidebar",status:"supported",reason:"ui-phase3-002: v2 comments adapter routes create/reply/edit/resolve/delete through V2EditorHost.dispatch"},{feature:"shell.comments-sidebar.reopen",status:"supported",reason:'ui-phase3-002: v2 comments sidebar reopens resolved threads through the v2 comments adapter (activeEditor.doc.comments.patch({ status: "active" }))'},{feature:"shell.tracked-change-sidebar",status:"supported",reason:"SD-3722: v2 tracked-change adapter lists and decides exact body, header/footer-part, and note targets"},{feature:"shell.tracked-change-sidebar.bulk",status:"supported",reason:"SD-4039/SD-4040: the shipped v2 command posture exposes all-story Accept All and Reject All through the canonical doc.trackChanges.decide({ target: { kind: 'all' } }) mutation"},{feature:"shell.tracked-change-sidebar.non-body",status:"supported",reason:"SD-3722: public v2 shell hydrates and targets header/footer-part and note tracked changes"},{feature:"shell.comments-sidebar.persistence",status:"supported",reason:"ui-phase3-004: comment create/reply/edit/resolve/delete persist through SuperDoc.export() → re-mount via the v2 host save bridge"},{feature:"shell.tracked-change-sidebar.persistence",status:"supported",reason:"ui-phase3-004: tracked-change accept/reject persist through SuperDoc.export() → re-mount via the v2 host save bridge"},{feature:"shell.comments-sidebar.author-required",status:"supported",reason:"ui-phase3-004: v2 comments adapter surfaces commentCommandsReason=author-required from the host capability matrix; write controls disable and forced dispatch reports ok:false"},{feature:"shell.find-replace",status:"supported",reason:"Ctrl/Cmd+F opens the SuperDoc find/replace surface in v2; find/navigation/replace/replaceAll route through the single host search session (host.search) via ui.search, with replace failing closed in viewing/read-only mode"},{feature:"shell.ai-writer",status:"supported",reason:"built-in toolbar renders the modules.ai-gated AI writer and applies generated text through the public Document API facade"},{feature:"shell.collaboration",status:"supported",reason:"v2 single-doc y-websocket collaboration is wired through document.v2Collaboration, including collaboration-ready, awareness-update, and locked event bridges; arbitrary external { ydoc, provider } adapters remain unsupported"},{feature:"shell.context-menu",status:"supported",reason:"v2 renders the built-in right-click and slash context menu, forwards ui.contextMenu custom items, and honors ui.contextMenu: false for application-owned replacements"},{feature:"shell.page-metrics",status:"supported",reason:"ui-phase4-001: v2 page metrics snapshot (editorVersion: 2, documentId, renderEpoch, layoutGeneration, zoom, pages[], capabilities) available via superdoc.activeEditor.pageMetrics.{ getSnapshot, subscribe, setZoom, scrollToPage, revealBodyTarget, pageIndexForBodyTarget }"},{feature:"shell.zoom",status:"supported",reason:"ui-phase4-001: SuperDoc.setZoom routes to V2EditorHost.setZoom in v2 mode; single CSS-transform wrapper applies scale to the painted document, page metrics viewport coords scale with the same zoom value"},{feature:"shell.ruler-page-margins",status:"supported",reason:"ui-phase4-002: v2 ruler renders against the V2PageMetricsSnapshot and dispatches margin drags through a narrow v2 page-layout bridge (`activeEditor.pageLayout.setMargins(...)`) backed by `doc.sections.setPageMargins(...)`. The v2 page metrics snapshot now reports `capabilities.marginEdit = { supported: true }`"},{feature:"shell.custom-extensions",status:"supported",reason:"superdoc@2 supports customer extensions through `extensions` + `defineSuperDocExtension`; command execution and diagnostics are exposed through the narrow `activeEditor.extensions` facet. Legacy ProseMirror `editorExtensions` are ignored in v2."},{feature:"pdf.viewer",status:"supported",reason:"editorVersion ignored for PDF documents"},{feature:"html.viewer",status:"supported",reason:"editorVersion ignored for HTML documents"}]}get v2(){return this.editorVersion!==2?null:{version:2,featureMatrix:this.getV2FeatureMatrix()}}registerEditorRuntime(e){this.#u.register(e)}unregisterEditorRuntime(e){return this.#u.unregister(e)}getActiveRuntime(){return this.#u.getActive()}setActiveRuntime(e,t){this.#u.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#u.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#u.resolveFromEventTarget(e);return n?(this.#u.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#m("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers}),this.toolbar?.updateToolbarState?.()}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const l=this.commentsStore.getComment(s),c=l?.getValues;i=typeof c=="function"?c.call(l):l}const a={superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null};return Sa(e,t,n,a)}#Ce(){const e=this.config.modules?.toolbar,t=e&&typeof e=="object"?e:{},n=this.#p.toolbar;this.toolbarElement=n.container??void 0;const r=this.config.ui,o=typeof r=="object"&&r!==null&&r.toolbar!==void 0;if(!(n.enabled&&(n.container||e===!0||e!=null&&typeof e=="object"||o))){this.toolbar=null;return}try{this.toolbar=Lz({...t,...n.options,selector:this.toolbarElement,superdoc:this,editor:this.activeEditor,role:this.config.role,isDev:this.isDev,documentMode:this.config.documentMode,groups:n.options.groups,toolbarGroups:n.options.toolbarGroups,icons:n.options.icons,texts:n.options.texts,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont})}catch(i){console.warn("[SuperDoc] built-in toolbar mount failed",i),this.toolbar=null}}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(this.commentsList?.close(),e&&(this.config.modules.comments.element=e),this.commentsList=new TR(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}),this.emit("comments-list-change",{isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}),this.emit("comments-list-change",{isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){if(!e&&this.#p.contextMenu.suppressed)return;const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getDocumentRuntime?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const o=n.getEditor?.();o?.setOptions&&o.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#R("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#ce();const t={viewing:()=>this.#le(),editing:()=>this.#ke(),suggesting:()=>this.#ae()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#J(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null;if(n){const i=this.#u.getAllByDocumentId(n);if(i.length>0){for(const s of i)s.setDocumentMode(t);return}}const r=typeof e.getDocumentRuntime=="function"?e.getDocumentRuntime():null;if(typeof r?.setDocumentMode=="function"){r.setDocumentMode(t);return}const o=typeof e.getEditor=="function"?e.getEditor():null;o&&typeof o.setDocumentMode=="function"&&o.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getDocumentRuntime=="function"?n.getDocumentRuntime():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#ke(){if(this.config.role!=="editor")return this.#ae();const e=this.#m("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#J(t,"editing")})}#ae(){if(!["editor","suggester"].includes(this.config.role??""))return this.#le();const e=this.#m("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#J(t,"suggesting")})}#le(){const e=this.#m("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const t=this.config.comments?.visible===!0,n=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(n?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!t&&!n&&this.commentsStore?.clearEditorCommentPositions?.(),e.documents.forEach(r=>{t||n?r.restoreComments?.():r.removeComments?.(),this.#J(r,"viewing")})}#ce(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const o=this.superdocStore?.documents;Array.isArray(o)&&o.length>0&&o.forEach(i=>{const s=typeof i.getDocumentRuntime=="function"?i.getDocumentRuntime():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return!!n.call(t,e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}this.superdocStore.zoomMode!==e&&(this.superdocStore.zoomMode=e,this.emit("zoomChange",{zoom:this.getZoom(),mode:e}))}getZoomState(){const e=xk(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}getMeasurementUnit(){return this.superdocStore?.measurementUnit??"in"}setMeasurementUnit(e){if(e!=="in"&&e!=="cm"){console.warn("[SuperDoc] setMeasurementUnit expects 'in' or 'cm'");return}if(!this.superdocStore){console.warn("[SuperDoc] setMeasurementUnit called before initialization; use config.measurementUnit for the starting unit");return}this.superdocStore.measurementUnit!==e&&(this.superdocStore.measurementUnit=e,this.emit("measurement-unit-change",{unit:e}))}setLocked(e=!0){const t=this.activeEditor;if(ni(t)&&typeof t.lock?.setLocked=="function"){t.lock.setLocked(e,e?{...this.user}:null);const n=t.lock.getSnapshot?.();n&&this.#v(!!n.isLocked,this.#F(n.lockedBy??null));return}this.config.documents.forEach(n=>{const r=n.ydoc;if(!r)return;const o=r.getMap("meta");r.transact(()=>{o.set("locked",e),e?o.set("lockedBy",this.user):o.delete("lockedBy")})}),this.#v(e,e?this.user:null)}getHTML(e={}){const t=[];return this.#m("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.#v(e,t)}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:o=[],isFinalDoc:i=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=m_(n||this.config.title),c=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),u=[...r],f=[...o];if(e.includes("docx")&&c.forEach(g=>{u.push(g),f.push(`${l}.docx`)}),u.length===1)return s?p_(u[0],l,e[0]):u[0];const h=await GV(u,f);return s?p_(h,l,"zip"):h}async replaceFile(e){const t=this.activeEditor;if(ni(t)&&typeof t.replaceFile=="function"){const r=await t.replaceFile(e),o=r&&typeof r=="object"?r.state:null;return(o===null||o==="review-ready"||o==="editing-ready")&&(this.#re(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),r}const n=t&&!ni(t)?t.replaceFile:null;if(typeof n=="function"){const r=await n.call(t,e),o=r&&typeof r=="object"?r.state:void 0;return(o==null||o==="review-ready"||o==="editing-ready")&&(this.#re(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),r}throw new Error("SuperDoc: replaceFile is unavailable for the active editor")}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){const r=this.config?.modules?.comments!==!1;let o,i=!1;const s=()=>(i||(i=!0,e==="clean"?o=[]:r&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(o=this.commentsStore.translateCommentsForExport(),Array.isArray(o)||(o=[]))),o),a=new WeakSet,l=c=>{"editor"in c&&c.error&&typeof c.error=="object"&&a.add(c.error)};this.on("exception",l);try{const c=this.#m("exportEditorsToDOCX").documents.map(async u=>{if(!u||u.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const f=typeof u.getEditor=="function"?u.getEditor():null,h=()=>!u.data||u.data.type&&u.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:u.data;if(!f||typeof f.exportDocx!="function")return h();const g=f.editorVersion===2;try{const m=await f.exportDocx(g?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(m)return m}catch(m){if((!m||typeof m!="object"||!a.has(m))&&this.emit("exception",{error:m,document:u}),g&&(e==="clean"||XV(m)))throw m}return h()});return(await Promise.all(c)).filter(u=>u!=null)}finally{this.off("exception",l)}}async#Se(){this.#C("🦋 [superdoc] Triggering collaboration saves");const e=this.#m("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#C(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#C(`After increment - Doc ${r}: pending = ${this.pendingCollaborationSaves}`);const o=n.ydoc.getMap("meta");o.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&t())}),o.set("immediate-save",!0)}}),this.#C(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#Se()];this.#C("🦋 [superdoc] Saving superdoc"),await Promise.all(e),this.#C("🦋 [superdoc] Save complete")}#_e(e,t){const n=e.provider;n&&n!==this.provider&&!t.some(o=>o.provider===n)&&(n.disconnect?.(),n.destroy?.());const r=e.ydoc;r&&r!==this.ydoc&&!t.some(o=>o.ydoc===r)&&r.destroy?.()}#ue(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.(),e.documents.forEach(t=>{t.provider?.disconnect?.(),t.provider?.destroy?.(),t.ydoc?.destroy()})}openSurface(e){return this.#g.open(e)}closeSurface(e){this.#g.close(e)}async removeDocument(e){const t=typeof e=="string"?e:String(e??"");if(!t)return!1;const n=this.#m("removeDocument"),r=this.activeEditor,o=AA(r);for(const s of this.#u.getAllByDocumentId(t))this.#u.unregister(s.id);o===t&&r!==null&&this.#U();const i=n.removeDocument(t);return i?(this.#_e(i,n.documents),await xt(),!0):!1}destroy(){this.#e=!0,this.#h?.removeEventListener("click",this.#f,!0),this.#h=null,this.#t&&(this.#t(),this.#t=null),this.#g&&this.#g.destroy(),this.toolbar?.destroy?.(),this.commentsList?.close(),this.commentsList=null,this.app&&(this.#C("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#c?.destroy(),this.#ue(),this.#y?.(),this.#y=null,this.#u.clear(),this.#d&&(this.#d.remove(),this.#d=null)}focus(e={}){const t=this.getActiveRuntime();if(t?.getCapabilities().lifecycle.canFocus){t.focus(e).catch(n=>{console.warn("[SuperDoc] active editor runtime focus failed",n)});return}this.activeEditor?ni(this.activeEditor)?this.activeEditor.focus?.(e):this.activeEditor.focus?.():this.#m("focus").documents.find(n=>{const r=n.getEditor?.();return r?(ni(r)?r.focus?.(e):r.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};Rt();var IA="__SUPERDOC_V2_BROWSER_RUNTIME__";function QV(e=globalThis){const t=e[IA];return t&&typeof t=="object"?t:null}function JV(e={},t=globalThis){const n=QV(t)??{},r={...n,...e,vue:e.vue??n.vue??c6};return t[IA]=r,r}JV();var ej={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},tj=0;function xA(e){const{name:t,font:n,radius:r,shadow:o,colors:i,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++tj}`}`,l=[];if(i)for(const[c,u]of Object.entries(i)){if(u==null)continue;const f=ej[c];f&&l.push(` ${f}: ${u};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),o!=null&&l.push(` --sd-ui-shadow: ${o};`),s)for(const[c,u]of Object.entries(s))u!=null&&l.push(` ${c}: ${u};`);return{className:a,css:l.length>0?`.${a} {
106
106
  ${l.join(`
107
107
  `)}
108
- }`:""}}function nj(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function rj(e){const{className:t,css:n}=xA(e);return nj(t,n),t}function oj(e){return xA(e)}function ij(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var sj=Ju({BlankDOCX:()=>rk,DOCX:()=>Fr,HTML:()=>Kh,PDF:()=>Hl,SuperDoc:()=>gm,buildTheme:()=>oj,compareVersions:()=>v6,createTheme:()=>rj,defineSuperDocExtension:()=>ij,getFileObject:()=>Wv}),aj="SUPERDOC_ENGINE_CDN_BASE_URL",EA=Symbol.for("superdoc.docx-engine.cdn-load-state"),vm="superdocDocxEngineStatus";function lj(e,t,n=null){const r=e?.[aj],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return cj(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function cj(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function uj({engineVersion:e,buildBaseUrl:t}){uT(()=>{const n=lj(globalThis,e,t),r=globalThis[EA],o=r instanceof Map?r:new Map;if(globalThis[EA]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),dj(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function dj(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[vm]==="loaded")return Promise.resolve();const r=n?.dataset[vm]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const c=(g,m)=>{a||(a=!0,l?.disconnect(),s.dataset[vm]=g,m())},u=()=>c("loaded",o),f=()=>c("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||c("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",u,{once:!0}),s.addEventListener("error",f,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[vm]="loading",document.head.appendChild(s))})}uj({engineVersion:"0.3.0-next.29",buildBaseUrl:null});for(const[e,t]of Object.entries(sj))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(gm,e)||(gm[e]=t);var fj=gm;return fj})();
108
+ }`:""}}function nj(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function rj(e){const{className:t,css:n}=xA(e);return nj(t,n),t}function oj(e){return xA(e)}function ij(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var sj=Ju({BlankDOCX:()=>rk,DOCX:()=>Fr,HTML:()=>Kh,PDF:()=>Hl,SuperDoc:()=>gm,buildTheme:()=>oj,compareVersions:()=>v6,createTheme:()=>rj,defineSuperDocExtension:()=>ij,getFileObject:()=>Wv}),aj="SUPERDOC_ENGINE_CDN_BASE_URL",EA=Symbol.for("superdoc.docx-engine.cdn-load-state"),vm="superdocDocxEngineStatus";function lj(e,t,n=null){const r=e?.[aj],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return cj(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function cj(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function uj({engineVersion:e,buildBaseUrl:t}){uT(()=>{const n=lj(globalThis,e,t),r=globalThis[EA],o=r instanceof Map?r:new Map;if(globalThis[EA]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),dj(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function dj(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[vm]==="loaded")return Promise.resolve();const r=n?.dataset[vm]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const c=(g,m)=>{a||(a=!0,l?.disconnect(),s.dataset[vm]=g,m())},u=()=>c("loaded",o),f=()=>c("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||c("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",u,{once:!0}),s.addEventListener("error",f,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[vm]="loading",document.head.appendChild(s))})}uj({engineVersion:"0.3.0-next.31",buildBaseUrl:null});for(const[e,t]of Object.entries(sj))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(gm,e)||(gm[e]=t);var fj=gm;return fj})();