superdoc 2.0.0-next.31 β†’ 2.0.0-next.32

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.
@@ -7,7 +7,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
7
7
  var PRIVATE_ENGINE_INFO = (0, __superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
8
8
  var ENGINE_INFO = Object.freeze({
9
9
  ...PRIVATE_ENGINE_INFO,
10
- superdocVersion: "2.0.0-next.31",
10
+ superdocVersion: "2.0.0-next.32",
11
11
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
12
12
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
13
13
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -6,7 +6,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
6
6
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
7
7
  var ENGINE_INFO = Object.freeze({
8
8
  ...PRIVATE_ENGINE_INFO,
9
- superdocVersion: "2.0.0-next.31",
9
+ superdocVersion: "2.0.0-next.32",
10
10
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
11
11
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
12
12
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
package/dist/superdoc.cjs CHANGED
@@ -34935,7 +34935,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
34935
34935
  this.config.colors = shuffleArray(this.config.colors);
34936
34936
  this.userColorMap = /* @__PURE__ */ new Map();
34937
34937
  this.colorIndex = 0;
34938
- this.version = "2.0.0-next.31";
34938
+ this.version = "2.0.0-next.32";
34939
34939
  this.#log("πŸ¦‹ [superdoc] Using SuperDoc version:", this.version);
34940
34940
  this.superdocId = config.superdocId || require_uuid.v4_default();
34941
34941
  this.colors = this.config.colors ?? [];
@@ -34653,7 +34653,7 @@ var SuperDoc = class extends import_eventemitter3.default {
34653
34653
  this.config.colors = shuffleArray(this.config.colors);
34654
34654
  this.userColorMap = /* @__PURE__ */ new Map();
34655
34655
  this.colorIndex = 0;
34656
- this.version = "2.0.0-next.31";
34656
+ this.version = "2.0.0-next.32";
34657
34657
  this.#log("πŸ¦‹ [superdoc] Using SuperDoc version:", this.version);
34658
34658
  this.superdocId = config.superdocId || v4_default();
34659
34659
  this.colors = this.config.colors ?? [];
@@ -99,10 +99,10 @@ js: import "konva/skia-backend";
99
99
  `,B4=()=>{if(typeof document>"u")throw new Error(dP)},_i=class Fk{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 Fk(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 u=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/u):-Math.acos(t/u),l.scaleX=u,l.scaleY=a/u,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const u=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/u):-Math.acos(r/u)),l.scaleX=a/u,l.scaleY=u,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=xe._getRotation(l.rotation),l}},fP="[object Array]",hP="[object Number]",pP="[object String]",mP="[object Boolean]",gP=Math.PI/180,vP=180/Math.PI,Vd="#",yP="",bP="0",wP="Konva warning: ",N4="Konva error: ",CP="rgb(",Ny={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]},_P=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,mp=[],jd=null,SP=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const xe={_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)===fP},_isNumber(e){return Object.prototype.toString.call(e)===hP&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===pP},_isBoolean(e){return Object.prototype.toString.call(e)===mP},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){mp.push(e),mp.length===1&&SP(function(){const t=mp;mp=[],t.forEach(function(n){n()})})},createCanvasElement(){B4();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return B4(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=xe.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(Vd,yP);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=bP+e;return Vd+e},isCanvasFarblingActive(){if(jd!==null)return jd;if(typeof document>"u")return jd=!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 jd=r,this.releaseCanvas(e),jd},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),Vd+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return Vd+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 Ny?(t=Ny[e],{r:t[0],g:t[1],b:t[2]}):e[0]===Vd?this._hexToRgb(e.substring(1)):e.substr(0,4)===CP?(t=_P.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",xe._namedColorToRBA(e)||xe._hex3ColorToRGBA(e)||xe._hex4ColorToRGBA(e)||xe._hex6ColorToRGBA(e)||xe._hex8ColorToRGBA(e)||xe._rgbColorToRGBA(e)||xe._rgbaColorToRGBA(e)||xe._hslColorToRGBA(e)},_namedColorToRBA(e){const t=Ny[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 u=2*i-s,c=[0,0,0];for(let d=0;d<3;d++)a=r+1/3*-(d-1),a<0&&a++,a>1&&a--,6*a<1?l=u+(s-u)*6*a:2*a<1?l=s:3*a<2?l=u+(s-u)*(2/3-a)*6:l=u,c[d]=l*255;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[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*gP},radToDeg(e){return e*vP},_degToRad(e){return xe.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),xe.degToRad(e)},_radToDeg(e){return xe.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),xe.radToDeg(e)},_getRotation(e){return gt.angleDeg?xe.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(N4+e)},error(e){console.error(N4+e)},warn(e){gt.showWarnings&&console.warn(wP+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 u=(e-n)*(e-n)+(t-r)*(t-r);if(u==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const c=((o-e)*(n-e)+(i-t)*(r-t))/u;c<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):c>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+c*(n-e),a=t+c*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=xe.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=xe._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),u=l[0],c=l[1],d=l[2];d<o&&(r.x=u,r.y=c,o=d)}),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=xe._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||xe._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(xe._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){gt.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,u=0;typeof r=="number"?s=a=l=u=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),u=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-u),e.arc(o+t-u,i+n-u,u,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],u={x:a.x-s.x,y:a.y-s.y},c={x:l.x-a.x,y:l.y-a.y},d=Math.hypot(u.x,u.y),p=Math.hypot(c.x,c.y);let m;typeof o=="number"?m=o:m=i<o.length?o[i]:0,m=r*Math.cos(Math.PI/n)*Math.min(1,m/r*2);const h={x:u.x/d,y:u.y/d},g={x:c.x/p,y:c.y/p},b={x:a.x-h.x*m,y:a.y-h.y*m},y={x:a.x+g.x*m,y:a.y+g.y*m};i===0?e.moveTo(b.x,b.y):e.lineTo(b.x,b.y),e.arcTo(a.x,a.y,y.x,y.y,m)}}};function kP(e){const t=[],n=e.length,r=xe;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 z4=",",AP="(",IP=")",EP="([",xP="])",TP=";",RP="()",MP="=",H4=["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"],LP=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],DP=100,gp=null;function U4(){if(gp!==null)return gp;try{const e=xe.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(gp=!1,!1)}catch{return gp=!1,!1}}var vp=class{constructor(e){this.canvas=e,gt.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+=RP:xe._isArray(l[0])?o+=EP+l.join(z4)+xP:(t&&(l=l.map(u=>typeof u=="number"?Math.floor(u):u)),o+=AP+l.join(z4)+IP)):(o+=s.property,e||(o+=MP+s.val)),o+=TP;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=DP&&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 u=arguments,c=this._context;u.length===3?c.drawImage(e,t,n):u.length===5?c.drawImage(e,t,n,r,o):u.length===9&&c.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=H4.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=kP(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(H4[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)}};LP.forEach(function(e){Object.defineProperty(vp.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var PP=class extends vp{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(),u=a.x*l,c=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(u),Math.abs(c))),this.setAttr("shadowOffsetX",s.x*u),this.setAttr("shadowOffsetY",s.y*c)}},FP=class extends vp{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()}}},yp;function OP(){if(yp)return yp;const e=xe.createCanvasElement(),t=e.getContext("2d");return yp=(function(){return(gt._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),xe.releaseCanvas(e),yp}var zy=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||gt.pixelRatio||OP(),this._canvas=xe.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 xe.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},Oa=class extends zy{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new PP(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Hy=class extends zy{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new FP(this),this.setSize(e.width,e.height)}};const Cn={get isDragging(){let e=!1;return Cn._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Cn._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Cn._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=xe._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=[];Cn._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")&&(Cn.justDragged=!0,gt._mouseListenClick=!1,gt._touchListenClick=!1,gt._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof gt.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Cn._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Cn._dragElements.delete(n)})}};gt.isBrowser&&(window.addEventListener("mouseup",Cn._endDragBefore,!0),window.addEventListener("touchend",Cn._endDragBefore,!0),window.addEventListener("touchcancel",Cn._endDragBefore,!0),window.addEventListener("mousemove",Cn._drag),window.addEventListener("touchmove",Cn._drag),window.addEventListener("mouseup",Cn._endDragAfter,!1),window.addEventListener("touchend",Cn._endDragAfter,!1),window.addEventListener("touchcancel",Cn._endDragAfter,!1));function Ba(e){return xe._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||xe._isBoolean(e)?e:Object.prototype.toString.call(e)}function V4(e){return e>255?255:e<0?0:Math.round(e)}function ft(){if(gt.isUnminified)return function(e,t){return xe._isNumber(e)||xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function bp(e){if(gt.isUnminified)return function(t,n){let r=xe._isNumber(t),o=xe._isArray(t)&&t.length==e;return!r&&!o&&xe.warn(Ba(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function Uy(){if(gt.isUnminified)return function(e,t){return xe._isNumber(e)||e==="auto"||xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Ml(){if(gt.isUnminified)return function(e,t){return xe._isString(e)||xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function j4(){if(gt.isUnminified)return function(e,t){const n=xe._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function BP(){if(gt.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(xe._isArray(e)?e.forEach(function(r){xe._isNumber(r)||xe.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Si(){if(gt.isUnminified)return function(e,t){return e===!0||e===!1||xe.warn(Ba(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function NP(e){if(gt.isUnminified)return function(t,n){return t==null||xe.isObject(t)||xe.warn(Ba(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var Gd="get",Wd="set";const ae={addGetterSetter(e,t,n,r,o){ae.addGetter(e,t,n),ae.addSetter(e,t,r,o),ae.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=Gd+xe._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=Wd+xe._capitalize(t);e.prototype[o]||ae.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=Wd+xe._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=xe._capitalize,a=Gd+s(t),l=Wd+s(t);e.prototype[a]=function(){const c={};for(let d=0;d<i;d++){const p=n[d];c[p]=this.getAttr(t+s(p))}return c};const u=NP(n);e.prototype[l]=function(c){const d=this.attrs[t];r&&(c=r.call(this,c,t)),u&&u.call(this,c,t);for(const p in c)c.hasOwnProperty(p)&&this._setAttr(t+s(p),c[p]);return c||n.forEach(p=>{this._setAttr(t+s(p),void 0)}),this._fireChangeEvent(t,d,c),o&&o.call(this),this},ae.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=xe._capitalize(t),r=Wd+n,o=Gd+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){xe.error("Adding deprecated "+t);const o=Gd+xe._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){xe.error(i);const s=this.attrs[t];return s===void 0?n:s},ae.addSetter(e,t,r,function(){xe.error(i)}),ae.addOverloadedGetterSetter(e,t)},backCompat(e,t){xe.each(t,function(n,r){const o=e.prototype[r],i=Gd+xe._capitalize(n),s=Wd+xe._capitalize(n);function a(){o.apply(this,arguments),xe.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 zP(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=gt.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=gt.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=gt.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=gt.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=gt.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=gt.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:xe.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var wp="absoluteOpacity",G4="allEventListeners",Zs="absoluteTransform",W4="absoluteScale",Ll="canvas",HP="Change",UP="children",VP="konva",Vy="listening",jP="mouseenter",GP="mouseleave",WP="pointerenter",KP="pointerleave",qP="touchenter",YP="touchleave",K4="set",q4="Shape",Cp=" ",Y4="stage",Na="transform",XP="Stage",jy="visible",QP=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Cp),ZP=1,bt=class kf{constructor(t){this._id=ZP++,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===Na||t===Zs)&&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===Na||t===Zs)&&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(Cp);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(Ll)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Zs&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Ll)){const{scene:t,filter:n,hit:r}=this._cache.get(Ll);xe.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(Ll)}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,u=n.offset||0,c=n.drawBorder||!1,d=n.hitCanvasPixelRatio||1;if(!o||!i){xe.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const p=Math.abs(Math.round(r.x)-a)>.5?1:0,m=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=u*2+p,i+=u*2+m,a-=u,l-=u;const h=new Oa({pixelRatio:s,width:o,height:i}),g=new Oa({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),b=new Hy({pixelRatio:d,width:o,height:i}),y=h.getContext(),k=b.getContext(),w=new Oa({width:h.width/h.pixelRatio+Math.abs(a),height:h.height/h.pixelRatio+Math.abs(l),pixelRatio:h.pixelRatio}),C=w.getContext();return b.isCache=!0,h.isCache=!0,this._cache.delete(Ll),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(h.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),y.save(),k.save(),C.save(),y.translate(-a,-l),k.translate(-a,-l),C.translate(-a,-l),w.x=a,w.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(wp),this._clearSelfAndDescendantCache(W4),this.drawScene(h,this,w),this.drawHit(b,this),this._isUnderCache=!1,y.restore(),k.restore(),c&&(y.save(),y.beginPath(),y.rect(0,0,o,i),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),xe.releaseCanvas(w._canvas),this._cache.set(Ll,{scene:h,filter:g,hit:b,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Ll)}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(u){const c=l.point(u);o===void 0&&(o=s=c.x,i=a=c.y),o=Math.min(o,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.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,u;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let c=!0;for(let p=0;p<t.length;p++)if(typeof t[p]=="string"&&U4(),typeof t[p]!="string"||!U4()){c=!1;break}const d=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),c){const p=t.join(" ");return i.save(),i.setAttr("filter",p),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)u=t[l],typeof u=="string"&&(u=zP(u)),u.call(this,a),i.putImageData(a,0,0)}catch(p){xe.error("Unable to apply filter. "+p.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(G4),t.length===3)return this._delegate.apply(this,t);const o=n.split(Cp);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(Cp),o=r.length,i,s,a,l,u,c;if(this._cache&&this._cache.delete(G4),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),u=l[0],c=l[1],u)this.eventListeners[u]&&this._off(u,c,n);else for(s in this.eventListeners)this._off(s,c,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=xe.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Cn._dragElements.delete(this._id),Cn._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Cn._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Zs),this._clearSelfAndDescendantCache(wp),this._clearSelfAndDescendantCache(W4),this._clearSelfAndDescendantCache(Y4),this._clearSelfAndDescendantCache(jy),this._clearSelfAndDescendantCache(Vy)}_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"+xe._capitalize(t);return xe._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!==UP&&(r=K4+xe._capitalize(n),xe._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(Vy,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(jy,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;Cn._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!gt.hitOnDragEnabled&&(o||gt.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(c){for(o=[],i=c.length,s=0;s<i;s++)a=c[s],r++,a.nodeType!==q4&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const u=this.getStage();return n.nodeType!==XP&&u&&l(u.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(Na),this._clearSelfAndDescendantCache(Zs)),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 _i,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(Na);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(Na),this._clearSelfAndDescendantCache(Zs),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 xe.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 xe.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 xe.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 xe.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 xe.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&xe.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(wp,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=xe.isObject(r)&&!xe._isPlainObject(r)&&!xe._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 xe._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],xe.isValidSelector(i)||(xe.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),xe.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),xe.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(Y4,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(Zs,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new _i,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(Zs)||new _i,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(Na,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(Na)||new _i;r.reset();const o=this.x(),i=this.y(),s=gt.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,u=this.attrs.skewX||0,c=this.attrs.skewY||0,d=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(u!==0||c!==0)&&r.skew(u,c),(a!==1||l!==1)&&r.scale(a,l),(d!==0||p!==0)&&r.translate(-1*d,-1*p),r.dirty=!1,r}clone(t){let n=xe.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(VP)<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 Oa({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(),u=new Oa({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,u),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,xe._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():gt.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+HP,{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[K4+xe._capitalize(t)];return xe._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(gt.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!xe.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===q4&&(n.target=this);const o=[jP,GP,WP,KP,qP,YP];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=kf.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,kf.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;Cn._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){Cn._dragElements.has(this._id)||this._createDragElement(t);const r=Cn._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:xe.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=Cn._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Cn._endDragBefore(t),Cn._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Cn._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||gt.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Cn._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=Cn._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Cn._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 xe.haveIntersection(r,this.getClientRect())}static create(t,n){return xe._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=kf.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),gt[r]||(xe.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=gt[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(kf._createNode(o[a]));return i}};bt.protoListenerMap=new Map,bt.prototype.nodeType="Node",bt.prototype._attrsAffectingSize=[],bt.prototype.eventListeners={},bt.prototype.on(QP,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Na),this._clearSelfAndDescendantCache(Zs)}),bt.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(jy)}),bt.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(Vy)}),bt.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(wp)});var Un=ae.addGetterSetter;Un(bt,"zIndex"),Un(bt,"absolutePosition"),Un(bt,"position"),Un(bt,"x",0,ft()),Un(bt,"y",0,ft()),Un(bt,"globalCompositeOperation","source-over",Ml()),Un(bt,"opacity",1,ft()),Un(bt,"name","",Ml()),Un(bt,"id","",Ml()),Un(bt,"rotation",0,ft()),ae.addComponentsGetterSetter(bt,"scale",["x","y"]),Un(bt,"scaleX",1,ft()),Un(bt,"scaleY",1,ft()),ae.addComponentsGetterSetter(bt,"skew",["x","y"]),Un(bt,"skewX",0,ft()),Un(bt,"skewY",0,ft()),ae.addComponentsGetterSetter(bt,"offset",["x","y"]),Un(bt,"offsetX",0,ft()),Un(bt,"offsetY",0,ft()),Un(bt,"dragDistance",void 0,ft()),Un(bt,"width",0,ft()),Un(bt,"height",0,ft()),Un(bt,"listening",!0,Si()),Un(bt,"preventDefault",!0,Si()),Un(bt,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Un(bt,"visible",!0,Si()),Un(bt,"transformsEnabled","all",Ml()),Un(bt,"size"),Un(bt,"dragBoundFunc"),Un(bt,"draggable",!1,Si()),ae.backCompat(bt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Qo=class extends bt{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=bt.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=bt.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 u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[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(),u=typeof s=="number"&&typeof a=="number"||l,c=n===this;if(u){i.save();const p=this.getAbsoluteTransform(n);let m=p.getMatrix();i.transform(m[0],m[1],m[2],m[3],m[4],m[5]),i.beginPath();let h;if(l)h=l.call(this,i,this);else{const g=this.clipX(),b=this.clipY();i.rect(g||0,b||0,s,a)}i.clip.apply(i,h),m=p.copy().invert().getMatrix(),i.transform(m[0],m[1],m[2],m[3],m[4],m[5])}const d=!c&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(p){p[e](t,n,r)}),d&&i.restore(),u&&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 u=this;(t=this.children)===null||t===void 0||t.forEach(function(p){if(!p.visible())return;const m=p.getClientRect({relativeTo:u,skipShadow:e.skipShadow,skipStroke:e.skipStroke});m.width===0&&m.height===0||(o===void 0?(o=m.x,i=m.y,s=m.x+m.width,a=m.y+m.height):(o=Math.min(o,m.x),i=Math.min(i,m.y),s=Math.max(s,m.x+m.width),a=Math.max(a,m.y+m.height)))});const c=this.find("Shape");let d=!1;for(let p=0;p<c.length;p++)if(c[p]._isVisible(this)){d=!0;break}return d&&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)}};ae.addComponentsGetterSetter(Qo,"clip",["x","y","width","height"]),ae.addGetterSetter(Qo,"clipX",void 0,ft()),ae.addGetterSetter(Qo,"clipY",void 0,ft()),ae.addGetterSetter(Qo,"clipWidth",void 0,ft()),ae.addGetterSetter(Qo,"clipHeight",void 0,ft()),ae.addGetterSetter(Qo,"clipFunc");var Kd=new Map,X4=gt._global.PointerEvent!==void 0;function Gy(e){return Kd.get(e)}function Wy(e){return{evt:e,pointerId:e.pointerId}}function Q4(e,t){return Kd.get(e)===t}function Z4(e,t){qd(e),t.getStage()&&(Kd.set(e,t),X4&&t._fire("gotpointercapture",Wy(new PointerEvent("gotpointercapture"))))}function qd(e,t){const n=Kd.get(e);if(!n)return;const r=n.getStage();r&&r.content,Kd.delete(e),X4&&n._fire("lostpointercapture",Wy(new PointerEvent("lostpointercapture")))}var JP="Stage",$P="string",J4="px",eF="mouseout",$4="mouseleave",eS="mouseover",tS="mouseenter",nS="mousemove",rS="mousedown",oS="mouseup",Yd="pointermove",Xd="pointerdown",Wc="pointerup",Qd="pointercancel",tF="lostpointercapture",_p="pointerout",Zd="pointerleave",Sp="pointerover",kp="pointerenter",Ky="contextmenu",iS="touchstart",sS="touchend",aS="touchmove",lS="touchcancel",qy="wheel",nF=5,rF=[[tS,"_pointerenter"],[rS,"_pointerdown"],[nS,"_pointermove"],[oS,"_pointerup"],[$4,"_pointerleave"],[iS,"_pointerdown"],[aS,"_pointermove"],[sS,"_pointerup"],[lS,"_pointercancel"],[eS,"_pointerover"],[qy,"_wheel"],[Ky,"_contextmenu"],[Xd,"_pointerdown"],[Yd,"_pointermove"],[Wc,"_pointerup"],[Qd,"_pointercancel"],[Zd,"_pointerleave"],[tF,"_lostpointercapture"]],Yy={mouse:{[_p]:eF,[Zd]:$4,[Sp]:eS,[kp]:tS,[Yd]:nS,[Xd]:rS,[Wc]:oS,[Qd]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[_p]:"touchout",[Zd]:"touchleave",[Sp]:"touchover",[kp]:"touchenter",[Yd]:aS,[Xd]:iS,[Wc]:sS,[Qd]:lS,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[_p]:_p,[Zd]:Zd,[Sp]:Sp,[kp]:kp,[Yd]:Yd,[Xd]:Xd,[Wc]:Wc,[Qd]:Qd,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Jd=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",Kc=e=>{const t=Jd(e);if(t==="pointer")return gt.pointerEventsEnabled&&Yy.pointer;if(t==="touch")return Yy.touch;if(t==="mouse")return Yy.mouse};function cS(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&xe.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var oF="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);";const $d=[];var Ap=class extends Qo{constructor(e){super(cS(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),$d.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{cS(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||xe.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===$P){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"),Qo.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&xe._isInDocument(e)&&this.container().removeChild(e);const t=$d.indexOf(this);return t>-1&&$d.splice(t,1),xe.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}:(xe.warn(oF),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 Oa({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+J4,this.content.style.height=t+J4),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>nF&&xe.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(),gt.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Q4(e,this)}setPointerCapture(e){Z4(e,this)}releaseCapture(e){qd(e,this)}getLayers(){return this.children}_bindContentEvents(){gt.isBrowser&&rF.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=Kc(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=Kc(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=Kc(e.type),n=Jd(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(gt.isDragging()||gt.isTransforming())||gt.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=Kc(e.type),n=Jd(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Cn.justDragged=!1,gt["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}gt.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=Kc(e.type),n=Jd(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(gt.isDragging()&&Cn.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(gt.isDragging()||gt.isTransforming())||gt.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=Gy(a.id)||this.getIntersection(a),u=a.id,c={evt:e,pointerId:u},d=s!==l;if(d&&s&&(s._fireAndBubble(t.pointerout,{...c},l),s._fireAndBubble(t.pointerleave,{...c},l)),l){if(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!0,d&&(l._fireAndBubble(t.pointerover,{...c},s),l._fireAndBubble(t.pointerenter,{...c},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...c})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=Kc(e.type),n=Jd(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=Gy(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const u=a.id,c={evt:e,pointerId:u};let d=!1;gt["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Cn.justDragged||(gt["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){gt["_"+n+"InDblClickWindow"]=!1},gt.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...c}),gt["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...c}),d&&o&&o===l&&l._fireAndBubble(t.pointerdblclick,{...c}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),gt["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:u}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:u}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),gt["_"+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(Ky,{evt:e}):this._fire(Ky,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(qy,{evt:e}):this._fire(qy,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=Gy(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(Wc,Wy(e)),qd(e.pointerId)}_lostpointercapture(e){qd(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:xe._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:xe._getFirstPointerId(e)}])}_setPointerPosition(e){xe.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 Oa({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Hy({pixelRatio:1,width:this.width(),height:this.height()}),!gt.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 xe.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}};Ap.prototype.nodeType=JP,ar(Ap),ae.addGetterSetter(Ap,"container"),gt.isBrowser&&document.addEventListener("visibilitychange",()=>{$d.forEach(e=>{e.batchDraw()})});var uS="hasShadow",dS="shadowRGBA",fS="patternImage",hS="linearGradient",pS="radialGradient",Ip;function Xy(){return Ip||(Ip=xe.createCanvasElement().getContext("2d"),Ip)}const ef={};function iF(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function sF(e){e.stroke()}function aF(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function lF(e){e.stroke()}function cF(){this._clearCache(uS)}function uF(){this._clearCache(dS)}function dF(){this._clearCache(fS)}function fF(){this._clearCache(hS)}function hF(){this._clearCache(pS)}var at=class extends bt{constructor(e){super(e);let t,n=0;for(;t=xe.getHitColor(),!(t&&!(t in ef));)if(n++,n>=1e4){xe.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=xe.getRandomColor();break}this.colorKey=t,ef[t]=this}getContext(){return xe.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return xe.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(uS,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(fS,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=Xy().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new _i;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(gt.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(hS,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=Xy(),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(pS,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=Xy(),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(dS,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=xe.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 bt.prototype.destroy.call(this),delete ef[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){xe.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,u=!e.skipShadow&&this.hasShadow(),c=u?this.shadowOffsetX():0,d=u?this.shadowOffsetY():0,p=a+Math.abs(c),m=l+Math.abs(d),h=u&&this.shadowBlur()||0,g={width:p+h*2,height:m+h*2,x:-(s/2+h)+Math.min(c,0)+i.x,y:-(s/2+h)+Math.min(d,0)+i.y};return r?g:this._transformedRect(g,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 u=t===this;if(!this.isVisible()&&!u)return this;if(i){o.save();const c=this.getAbsoluteTransform(t).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),this._useBufferCanvas()){l=this.getStage();const c=n||l.bufferCanvas,d=c.getContext();n?(d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.restore()):d.clear(),d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);const p=this.getAbsoluteTransform(t).getMatrix();d.transform(p[0],p[1],p[2],p[3],p[4],p[5]),s.call(this,d,this),d.restore();const m=c.pixelRatio;a&&o._applyShadow(this),u||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(c._canvas,c.x||0,c.y||0,c.width/m,c.height/m)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!u){const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[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||xe.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 u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[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,u=l.length,c=xe._hexToRgb(this.colorKey);for(let d=0;d<u;d+=4)l[d+3]>e?(l[d]=c.r,l[d+1]=c.g,l[d+2]=c.b,l[d+3]=255):l[d+3]=0;o.putImageData(a,0,0)}catch(a){xe.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return Q4(e,this)}setPointerCapture(e){Z4(e,this)}releaseCapture(e){qd(e,this)}};at.prototype._fillFunc=iF,at.prototype._strokeFunc=sF,at.prototype._fillFuncHit=aF,at.prototype._strokeFuncHit=lF,at.prototype._centroid=!1,at.prototype.nodeType="Shape",ar(at),at.prototype.eventListeners={},at.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",cF),at.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",uF),at.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",dF),at.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",fF),at.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",hF),ae.addGetterSetter(at,"stroke",void 0,j4()),ae.addGetterSetter(at,"strokeWidth",2,ft()),ae.addGetterSetter(at,"fillAfterStrokeEnabled",!1),ae.addGetterSetter(at,"hitStrokeWidth","auto",Uy()),ae.addGetterSetter(at,"strokeHitEnabled",!0,Si()),ae.addGetterSetter(at,"perfectDrawEnabled",!0,Si()),ae.addGetterSetter(at,"shadowForStrokeEnabled",!0,Si()),ae.addGetterSetter(at,"lineJoin"),ae.addGetterSetter(at,"lineCap"),ae.addGetterSetter(at,"miterLimit"),ae.addGetterSetter(at,"sceneFunc"),ae.addGetterSetter(at,"hitFunc"),ae.addGetterSetter(at,"dash"),ae.addGetterSetter(at,"dashOffset",0,ft()),ae.addGetterSetter(at,"shadowColor",void 0,Ml()),ae.addGetterSetter(at,"shadowBlur",0,ft()),ae.addGetterSetter(at,"shadowOpacity",1,ft()),ae.addComponentsGetterSetter(at,"shadowOffset",["x","y"]),ae.addGetterSetter(at,"shadowOffsetX",0,ft()),ae.addGetterSetter(at,"shadowOffsetY",0,ft()),ae.addGetterSetter(at,"fillPatternImage"),ae.addGetterSetter(at,"fill",void 0,j4()),ae.addGetterSetter(at,"fillPatternX",0,ft()),ae.addGetterSetter(at,"fillPatternY",0,ft()),ae.addGetterSetter(at,"fillLinearGradientColorStops"),ae.addGetterSetter(at,"strokeLinearGradientColorStops"),ae.addGetterSetter(at,"fillRadialGradientStartRadius",0),ae.addGetterSetter(at,"fillRadialGradientEndRadius",0),ae.addGetterSetter(at,"fillRadialGradientColorStops"),ae.addGetterSetter(at,"fillPatternRepeat","repeat"),ae.addGetterSetter(at,"fillEnabled",!0),ae.addGetterSetter(at,"strokeEnabled",!0),ae.addGetterSetter(at,"shadowEnabled",!0),ae.addGetterSetter(at,"dashEnabled",!0),ae.addGetterSetter(at,"strokeScaleEnabled",!0),ae.addGetterSetter(at,"fillPriority","color"),ae.addComponentsGetterSetter(at,"fillPatternOffset",["x","y"]),ae.addGetterSetter(at,"fillPatternOffsetX",0,ft()),ae.addGetterSetter(at,"fillPatternOffsetY",0,ft()),ae.addComponentsGetterSetter(at,"fillPatternScale",["x","y"]),ae.addGetterSetter(at,"fillPatternScaleX",1,ft()),ae.addGetterSetter(at,"fillPatternScaleY",1,ft()),ae.addComponentsGetterSetter(at,"fillLinearGradientStartPoint",["x","y"]),ae.addComponentsGetterSetter(at,"strokeLinearGradientStartPoint",["x","y"]),ae.addGetterSetter(at,"fillLinearGradientStartPointX",0),ae.addGetterSetter(at,"strokeLinearGradientStartPointX",0),ae.addGetterSetter(at,"fillLinearGradientStartPointY",0),ae.addGetterSetter(at,"strokeLinearGradientStartPointY",0),ae.addComponentsGetterSetter(at,"fillLinearGradientEndPoint",["x","y"]),ae.addComponentsGetterSetter(at,"strokeLinearGradientEndPoint",["x","y"]),ae.addGetterSetter(at,"fillLinearGradientEndPointX",0),ae.addGetterSetter(at,"strokeLinearGradientEndPointX",0),ae.addGetterSetter(at,"fillLinearGradientEndPointY",0),ae.addGetterSetter(at,"strokeLinearGradientEndPointY",0),ae.addComponentsGetterSetter(at,"fillRadialGradientStartPoint",["x","y"]),ae.addGetterSetter(at,"fillRadialGradientStartPointX",0),ae.addGetterSetter(at,"fillRadialGradientStartPointY",0),ae.addComponentsGetterSetter(at,"fillRadialGradientEndPoint",["x","y"]),ae.addGetterSetter(at,"fillRadialGradientEndPointX",0),ae.addGetterSetter(at,"fillRadialGradientEndPointY",0),ae.addGetterSetter(at,"fillPatternRotation",0),ae.addGetterSetter(at,"fillRule",void 0,Ml()),ae.backCompat(at,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var pF="beforeDraw",mF="draw",mS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],gF=mS.length,Dl=class extends Qo{constructor(e){super(e),this.canvas=new Oa,this.hitCanvas=new Hy({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(){bt.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(!bt.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(bt.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(bt.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 bt.prototype.remove.call(this),e&&e.parentNode&&xe._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"&&xe.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(),bt.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(){xe.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){xe.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,xe.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<gF;r++){const o=mS[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=ef[xe.getHitColorKey(n[0],n[1],n[2])];return o?{shape:o}:{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(pF,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),Qo.prototype.drawScene.call(this,o,t,n),this._fire(mF,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Qo.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){xe.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return xe.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 xe.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Dl.prototype.nodeType="Layer",ar(Dl),ae.addGetterSetter(Dl,"imageSmoothingEnabled",!0),ae.addGetterSetter(Dl,"clearBeforeDraw",!0),ae.addGetterSetter(Dl,"hitGraphEnabled",!0,Si());var Qy=class extends Dl{constructor(e){super(e),this.listening(!1),xe.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};Qy.prototype.nodeType="FastLayer",ar(Qy);var qc=class extends Qo{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&xe.throw("You may only add groups and shapes to groups.")}};qc.prototype.nodeType="Group",ar(qc);var Zy=(function(){return Rl.performance&&Rl.performance.now?function(){return Rl.performance.now()}:function(){return new Date().getTime()}})(),Yc=class Su{constructor(t,n){this.id=Su.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Zy(),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=Su.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=Zy(),Su._addAnimation(this),this}stop(){return Su._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(Zy());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let u=0;u<a;u++){const c=i[u];c._id!==void 0&&(t[c._id]=c)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Su;t.animations.length?(t._runFrames(),xe.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,xe.requestAnimFrame(this._animationLoop))}};Yc.animations=[],Yc.animIdCounter=0,Yc.animRunning=!1;var vF={node:1,duration:1,easing:1,onFinish:1,yoyo:1},yF=1,gS=2,vS=3,yS=["fill","stroke","shadowColor"],bF=0,wF=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=gS,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=vS,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===gS?this.setTime(e):this.state===vS&&this.setTime(this.duration-e)}pause(){this.state=yF,this.fire("onPause")}getTimer(){return new Date().getTime()}},Ep=class mr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||tf.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=bF++;const u=r.getLayer()||(r instanceof gt.Stage?r.getLayers():null);u||xe.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Yc(function(){n.tween.onEnterFrame()},u),this.tween=new wF(l,function(c){n._tweenFunc(c)},i,0,1,a*1e3,s),this._addListeners(),mr.attrs[o]||(mr.attrs[o]={}),mr.attrs[o][this._id]||(mr.attrs[o][this._id]={}),mr.tweens[o]||(mr.tweens[o]={});for(l in t)vF[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,u;const c=mr.tweens[o][t];c&&delete mr.attrs[o][c][t];let d=r.getAttr(t);if(xe._isArray(n))if(i=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=xe._prepareArrayForTween(d,n,r.closed())):(a=n,n=xe._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let p=0;p<s;p++)if(p%2===0)i.push(n[p]-d[p]);else{const m=xe.colorToRGBA(d[p]);u=xe.colorToRGBA(n[p]),d[p]=m,i.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(let p=0;p<s;p++)i.push(n[p]-d[p]);else yS.indexOf(t)!==-1?(d=xe.colorToRGBA(d),u=xe.colorToRGBA(n),i={r:u.r-d.r,g:u.g-d.g,b:u.b-d.b,a:u.a-d.a}):i=n-d;mr.attrs[o][this._id][t]={start:d,diff:i,end:n,trueEnd:a,trueStart:l},mr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=mr.attrs[n._id][this._id];let o,i,s,a,l,u,c,d;for(o in r){if(i=r[o],s=i.start,a=i.diff,d=i.end,xe._isArray(s))if(l=[],c=Math.max(s.length,d.length),o.indexOf("fill")===0)for(u=0;u<c;u++)u%2===0?l.push((s[u]||0)+a[u]*t):l.push("rgba("+Math.round(s[u].r+a[u].r*t)+","+Math.round(s[u].g+a[u].g*t)+","+Math.round(s[u].b+a[u].b*t)+","+(s[u].a+a[u].a*t)+")");else for(u=0;u<c;u++)l.push((s[u]||0)+a[u]*t);else yS.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=mr.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=mr.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=mr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete mr.tweens[t][o];delete mr.attrs[t][n],mr.tweens[t]&&(Object.keys(mr.tweens[t]).length===0&&delete mr.tweens[t],Object.keys(mr.attrs[t]).length===0&&delete mr.attrs[t])}};Ep.attrs={},Ep.tweens={},bt.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Ep(e).play()};const tf={BackEaseIn(e,t,n,r){return n*(e/=r)*e*((1.70158+1)*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*((1.70158+1)*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-tf.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?tf.BounceEaseIn(e*2,0,n,r)*.5+t:tf.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}},bS=xe._assign(gt,{Util:xe,Transform:_i,Node:bt,Container:Qo,Stage:Ap,stages:$d,Layer:Dl,FastLayer:Qy,Group:qc,DD:Cn,Shape:at,shapes:ef,Animation:Yc,Tween:Ep,Easings:tf,Context:vp,Canvas:zy});var Js=class extends at{_sceneFunc(e){const t=gt.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=gt.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),u=i*(i>0?t:e),c=s*(s>0?e:t),d=a*(a>0?t:e);return{x:l,y:n?-1*d:c,width:u-l,height:d-c}}};Js.prototype._centroid=!0,Js.prototype.className="Arc",Js.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],ar(Js),ae.addGetterSetter(Js,"innerRadius",0,ft()),ae.addGetterSetter(Js,"outerRadius",0,ft()),ae.addGetterSetter(Js,"angle",0,ft()),ae.addGetterSetter(Js,"clockwise",!1,Si());function Jy(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)),u=s*a/(a+l),c=s*l/(a+l);return[n-u*(o-e),r-u*(i-t),n+c*(o-e),r+c*(i-t)]}function wS(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=Jy(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 CF(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 $s=class extends at{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():wS(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=Jy(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=Jy(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=wS(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],...CF(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}}};$s.prototype.className="Line",$s.prototype._attrsAffectingSize=["points","bezier","tension"],ar($s),ae.addGetterSetter($s,"closed",!1),ae.addGetterSetter($s,"bezier",!1),ae.addGetterSetter($s,"tension",0,ft()),ae.addGetterSetter($s,"points",[],BP());const _F=[[],[],[-.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]],SF=[[],[],[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]],kF=[[1],[1,1],[1,2,1],[1,3,3,1]],CS=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*_F[20][a]+s,r+=SF[20][a]*AF(e,t,o);return s*r},_S=(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),u=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 c=l/(2*a),d=u/a,p=n+c,m=d-c*c,h=p*p+m>0?Math.sqrt(p*p+m):0,g=c*c+m>0?Math.sqrt(c*c+m):0,b=c+Math.sqrt(c*c+m)!==0?m*Math.log(Math.abs((p+h)/(c+g))):0;return Math.sqrt(a)/2*(p*h-c*g+b)};function AF(e,t,n){const r=$y(1,n,e),o=$y(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var $y=(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+=kF[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 $y(e-1,t,o)}};const SS=(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 u=n(o-i),c=Math.abs(e-u)/t;c<r?(r=c,o-=i):i/=2}if(s++,s>500)break}return o};var si=class Vo extends at{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Vo.parsePathData(this.data()),this.pathLength=Vo.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],u=s[2],c=s[3],d=s[4],p=s[5],m=s[6],h=s[7],g=u>c?u:c,b=u>c?1:u/c,y=u>c?c/u:1;t.translate(a,l),t.rotate(m),t.scale(b,y),t.arc(0,0,g,d,d+p,1-h),t.scale(1/b,1/y),t.rotate(-m),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const u=l.points[4],c=l.points[5],d=l.points[4]+c;let p=Math.PI/180;if(Math.abs(u-d)<p&&(p=Math.abs(u-d)),c<0)for(let m=u-p;m>d;m-=p){const h=Vo.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(h.x,h.y)}else for(let m=u+p;m<d;m+=p){const h=Vo.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(h.x,h.y)}}else if(l.command==="C")for(let u=0;u<=1;u+=.01){const c=Vo.getPointOnCubicBezier(u,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(c.x,c.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 Vo.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 Vo.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Vo.getPointOnCubicBezier(SS(t,Vo.getPathLength(n),g=>CS([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],g)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Vo.getPointOnQuadraticBezier(SS(t,Vo.getPathLength(n),g=>_S([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],g)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],u=a[1],c=a[2],d=a[3],p=a[5],m=a[6];let h=a[4];return h+=p*t/s.pathLength,Vo.getPointOnEllipticalArc(l,u,c,d,h,m)}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 u=(i-r)/(o-n),c=Math.sqrt(t*t/(1+u*u))*(o<n?-1:1),d=u*c;if(Math.abs(a-r-u*(s-n))<1e-10)return{x:s+c,y:a+d};const p=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),m=n+p*(o-n),h=r+p*(i-r),g=this.getLineLength(s,a,m,h),b=Math.sqrt(t*t-g*g),y=Math.sqrt(b*b/(1+u*u))*(o<n?-1:1),k=u*y;return{x:m+y,y:h+k}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,u){function c(h){return h*h*h}function d(h){return 3*h*h*(1-h)}function p(h){return 3*h*(1-h)*(1-h)}function m(h){return(1-h)*(1-h)*(1-h)}return{x:l*c(t)+s*d(t)+o*p(t)+n*m(t),y:u*c(t)+a*d(t)+i*p(t)+r*m(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(d){return d*d}function u(d){return 2*d*(1-d)}function c(d){return(1-d)*(1-d)}return{x:s*l(t)+o*u(t)+n*c(t),y:a*l(t)+i*u(t)+r*c(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),u={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(u.x*a-u.y*l),y:n+(u.x*l+u.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 d=0;d<r.length;d++)n=n.replace(new RegExp(r[d],"g"),"|"+r[d]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let d=1;d<o.length;d++){let p=o[d],m=p.charAt(0);for(p=p.slice(1),s.length=0;c=u.exec(p);)s.push(c[0]);let h=[],g=m==="A"||m==="a"?0:-1;for(let b=0,y=s.length;b<y;b++){const k=s[b];if(k==="00"){h.push(0,0),g>=0&&(g+=2,g>=7&&(g-=7));continue}if(g>=0){if(g===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(k)){h.push(parseInt(k[0],10)),h.push(parseInt(k[1],10)),h.push(parseFloat(k.slice(2))),g+=3,g>=7&&(g-=7);continue}if(k==="11"||k==="10"||k==="01"){h.push(parseInt(k[0],10)),h.push(parseInt(k[1],10)),g+=2,g>=7&&(g-=7);continue}if(k==="0"||k==="1"){h.push(parseInt(k,10)),g+=1,g>=7&&(g-=7);continue}}else if(g===4){if(/^[01]\d+(?:\.\d+)?$/.test(k)){h.push(parseInt(k[0],10)),h.push(parseFloat(k.slice(1))),g+=2,g>=7&&(g-=7);continue}if(k==="0"||k==="1"){h.push(parseInt(k,10)),g+=1,g>=7&&(g-=7);continue}}const w=parseFloat(k);isNaN(w)?h.push(0):h.push(w),g+=1,g>=7&&(g-=7)}else{const w=parseFloat(k);isNaN(w)?h.push(0):h.push(w)}}for(;h.length>0&&!isNaN(h[0]);){let b="",y=[];const k=a,w=l;let C,x,R,L,H,B,z,Y,F,M;switch(m){case"l":a+=h.shift(),l+=h.shift(),b="L",y.push(a,l);break;case"L":a=h.shift(),l=h.shift(),y.push(a,l);break;case"m":const A=h.shift(),N=h.shift();if(a+=A,l+=N,b="M",i.length>2&&i[i.length-1].command==="z"){for(let X=i.length-2;X>=0;X--)if(i[X].command==="M"){a=i[X].points[0]+A,l=i[X].points[1]+N;break}}y.push(a,l),m="l";break;case"M":a=h.shift(),l=h.shift(),b="M",y.push(a,l),m="L";break;case"h":a+=h.shift(),b="L",y.push(a,l);break;case"H":a=h.shift(),b="L",y.push(a,l);break;case"v":l+=h.shift(),b="L",y.push(a,l);break;case"V":l=h.shift(),b="L",y.push(a,l);break;case"C":y.push(h.shift(),h.shift(),h.shift(),h.shift()),a=h.shift(),l=h.shift(),y.push(a,l);break;case"c":y.push(a+h.shift(),l+h.shift(),a+h.shift(),l+h.shift()),a+=h.shift(),l+=h.shift(),b="C",y.push(a,l);break;case"S":x=a,R=l,C=i[i.length-1],C.command==="C"&&(x=a+(a-C.points[2]),R=l+(l-C.points[3])),y.push(x,R,h.shift(),h.shift()),a=h.shift(),l=h.shift(),b="C",y.push(a,l);break;case"s":x=a,R=l,C=i[i.length-1],C.command==="C"&&(x=a+(a-C.points[2]),R=l+(l-C.points[3])),y.push(x,R,a+h.shift(),l+h.shift()),a+=h.shift(),l+=h.shift(),b="C",y.push(a,l);break;case"Q":y.push(h.shift(),h.shift()),a=h.shift(),l=h.shift(),y.push(a,l);break;case"q":y.push(a+h.shift(),l+h.shift()),a+=h.shift(),l+=h.shift(),b="Q",y.push(a,l);break;case"T":x=a,R=l,C=i[i.length-1],C.command==="Q"&&(x=a+(a-C.points[0]),R=l+(l-C.points[1])),a=h.shift(),l=h.shift(),b="Q",y.push(x,R,a,l);break;case"t":x=a,R=l,C=i[i.length-1],C.command==="Q"&&(x=a+(a-C.points[0]),R=l+(l-C.points[1])),a+=h.shift(),l+=h.shift(),b="Q",y.push(x,R,a,l);break;case"A":L=h.shift(),H=h.shift(),B=h.shift(),z=h.shift(),Y=h.shift(),F=a,M=l,a=h.shift(),l=h.shift(),b="A",y=this.convertEndpointToCenterParameterization(F,M,a,l,z,Y,L,H,B);break;case"a":L=h.shift(),H=h.shift(),B=h.shift(),z=h.shift(),Y=h.shift(),F=a,M=l,a+=h.shift(),l+=h.shift(),b="A",y=this.convertEndpointToCenterParameterization(F,M,a,l,z,Y,L,H,B);break}i.push({command:b||m,points:y,start:{x:k,y:w},pathLength:this.calcLength(k,w,b||m,y)})}(m==="z"||m==="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 u=Vo;switch(r){case"L":return u.getLineLength(t,n,o[0],o[1]);case"C":return CS([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return _S([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const c=o[4],d=o[5],p=o[4]+d;let m=Math.PI/180;if(Math.abs(c-p)<m&&(m=Math.abs(c-p)),s=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],c,0),d<0)for(l=c-m;l>p;l-=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=c+m;l<p;l+=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],p,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,u){const c=u*(Math.PI/180),d=Math.cos(c)*(t-r)/2+Math.sin(c)*(n-o)/2,p=-1*Math.sin(c)*(t-r)/2+Math.cos(c)*(n-o)/2,m=d*d/(a*a)+p*p/(l*l);m>1&&(a*=Math.sqrt(m),l*=Math.sqrt(m));let h=Math.sqrt((a*a*(l*l)-a*a*(p*p)-l*l*(d*d))/(a*a*(p*p)+l*l*(d*d)));i===s&&(h*=-1),isNaN(h)&&(h=0);const g=h*a*p/l,b=h*-l*d/a,y=(t+r)/2+Math.cos(c)*g-Math.sin(c)*b,k=(n+o)/2+Math.sin(c)*g+Math.cos(c)*b,w=function(z){return Math.sqrt(z[0]*z[0]+z[1]*z[1])},C=function(z,Y){return(z[0]*Y[0]+z[1]*Y[1])/(w(z)*w(Y))},x=function(z,Y){return(z[0]*Y[1]<z[1]*Y[0]?-1:1)*Math.acos(C(z,Y))},R=x([1,0],[(d-g)/a,(p-b)/l]),L=[(d-g)/a,(p-b)/l],H=[(-1*d-g)/a,(-1*p-b)/l];let B=x(L,H);return C(L,H)<=-1&&(B=Math.PI),C(L,H)>=1&&(B=0),s===0&&B>0&&(B=B-2*Math.PI),s===1&&B<0&&(B=B+2*Math.PI),[y,k,a,l,R,B,c,s]}};si.prototype.className="Path",si.prototype._attrsAffectingSize=["data"],ar(si),ae.addGetterSetter(si,"data");var Pl=class extends $s{_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 d=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],p=si.calcLength(r[r.length-4],r[r.length-3],"C",d),m=si.getPointOnQuadraticBezier(Math.min(1,1-i/p),d[0],d[1],d[2],d[3],d[4],d[5]);a=n[s-2]-m.x,l=n[s-1]-m.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const u=(Math.atan2(l,a)+t)%t,c=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(u),e.moveTo(0,0),e.lineTo(-i,c/2),e.lineTo(-i,-c/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,c/2),e.lineTo(-i,-c/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}}};Pl.prototype.className="Arrow",ar(Pl),ae.addGetterSetter(Pl,"pointerLength",10,ft()),ae.addGetterSetter(Pl,"pointerWidth",10,ft()),ae.addGetterSetter(Pl,"pointerAtBeginning",!1),ae.addGetterSetter(Pl,"pointerAtEnding",!0);var Xc=class extends at{_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)}};Xc.prototype._centroid=!0,Xc.prototype.className="Circle",Xc.prototype._attrsAffectingSize=["radius"],ar(Xc),ae.addGetterSetter(Xc,"radius",0,ft());var za=class extends at{_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)}};za.prototype.className="Ellipse",za.prototype._centroid=!0,za.prototype._attrsAffectingSize=["radiusX","radiusY"],ar(za),ae.addComponentsGetterSetter(za,"radius",["x","y"]),ae.addGetterSetter(za,"radiusX",0,ft()),ae.addGetterSetter(za,"radiusY",0,ft());var ki=class Ok extends at{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?xe.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?xe.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=xe.createImageElement();o.onload=function(){n(new Ok({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};ki.prototype.className="Image",ki.prototype._attrsAffectingSize=["image"],ar(ki),ae.addGetterSetter(ki,"cornerRadius",0,bp(4)),ae.addGetterSetter(ki,"image"),ae.addComponentsGetterSetter(ki,"crop",["x","y","width","height"]),ae.addGetterSetter(ki,"cropX",0,ft()),ae.addGetterSetter(ki,"cropY",0,ft()),ae.addGetterSetter(ki,"cropWidth",0,ft()),ae.addGetterSetter(ki,"cropHeight",0,ft());var kS=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],IF="Change.konva",EF="none",e0="up",t0="right",n0="down",r0="left",xF=kS.length,o0=class extends qc{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<xF;n++)e.on(kS[n]+IF,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 e0:s=n/2,a=-1*l;break;case t0:s=n+i,a=r/2;break;case n0:s=n/2,a=r+l;break;case r0:s=-1*i,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};o0.prototype.className="Label",ar(o0);var Fl=class extends at{_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,u=0,c=0;typeof s=="number"?a=l=u=c=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),c=Math.min(s[2]||0,t/2,n/2),u=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===e0&&(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===t0&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-c),e.arc(t-c,n-c,c,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(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===r0&&(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===e0?(t-=r,s+=r):o===n0?s+=r:o===r0?(e-=n*1.5,i+=n):o===t0&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};Fl.prototype.className="Tag",ar(Fl),ae.addGetterSetter(Fl,"pointerDirection",EF),ae.addGetterSetter(Fl,"pointerWidth",0,ft()),ae.addGetterSetter(Fl,"pointerHeight",0,ft()),ae.addGetterSetter(Fl,"cornerRadius",0,bp(4));var nf=class extends at{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?xe.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};nf.prototype.className="Rect",ar(nf),ae.addGetterSetter(nf,"cornerRadius",0,bp(4));var Ha=class extends at{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)xe.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)}};Ha.prototype.className="RegularPolygon",Ha.prototype._centroid=!0,Ha.prototype._attrsAffectingSize=["radius"],ar(Ha),ae.addGetterSetter(Ha,"radius",0,ft()),ae.addGetterSetter(Ha,"sides",0,ft()),ae.addGetterSetter(Ha,"cornerRadius",0,bp(4));var AS=Math.PI*2,Ol=class extends at{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,AS,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),AS,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)}};Ol.prototype.className="Ring",Ol.prototype._centroid=!0,Ol.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ar(Ol),ae.addGetterSetter(Ol,"innerRadius",0,ft()),ae.addGetterSetter(Ol,"outerRadius",0,ft());var ns=class extends at{constructor(e){super(e),this._updated=!0,this.anim=new Yc(()=>{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],u=o[r+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,u),e.closePath(),e.fillStrokeShape(this)),c)if(i){const d=i[t],p=n*2;e.drawImage(c,s,a,l,u,d[p+0],d[p+1],l,u)}else e.drawImage(c,s,a,l,u,0,0,l,u)}_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],u=n*2;e.rect(l[u+0],l[u+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)}};ns.prototype.className="Sprite",ar(ns),ae.addGetterSetter(ns,"animation"),ae.addGetterSetter(ns,"animations"),ae.addGetterSetter(ns,"frameOffsets"),ae.addGetterSetter(ns,"image"),ae.addGetterSetter(ns,"frameIndex",0,ft()),ae.addGetterSetter(ns,"frameRate",17,ft()),ae.backCompat(ns,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Ua=class extends at{_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)}};Ua.prototype.className="Star",Ua.prototype._centroid=!0,Ua.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ar(Ua),ae.addGetterSetter(Ua,"numPoints",5,ft()),ae.addGetterSetter(Ua,"innerRadius",0,ft()),ae.addGetterSetter(Ua,"outerRadius",0,ft());function Va(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 Qc="auto",TF="center",IS="inherit",rf="justify",RF="Change.konva",ES="2d",xS="-",TS="left",MF="text",LF="Text",DF="top",PF="bottom",RS="middle",MS="normal",FF="px ",xp=" ",OF="right",LS="rtl",BF="word",NF="char",DS="none",i0="…",PS=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],zF=PS.length,of=null;function HF(){if(of!==null)return of;of=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(ES);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){of=!0;break}}}catch{}return of}function UF(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 Tp;function s0(){return Tp||(Tp=xe.createCanvasElement().getContext(ES),Tp)}function VF(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function jF(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function GF(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Wn=class extends at{constructor(e){super(GF(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<zF;t++)this.on(PS[t]+RF,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(),u=this.direction(),c=0,d=this.align(),p=this.getWidth(),m=this.letterSpacing(),h=this.charRenderFunc(),g=this.fill(),b=this.textDecoration(),y=this.underlineOffset(),k=b.indexOf("underline")!==-1,w=b.indexOf("line-through")!==-1,C;u=u===IS?e.direction:u;let x=a/2,R=RS;if(!gt.legacyTextRendering){const L=this.measureSize("M");R="alphabetic",x=(((t=L.fontBoundingBoxAscent)!==null&&t!==void 0?t:L.actualBoundingBoxAscent)-((n=L.fontBoundingBoxDescent)!==null&&n!==void 0?n:L.actualBoundingBoxDescent))/2+a/2}for(u===LS&&e.setAttr("direction",u),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",R),e.setAttr("textAlign",TS),l===RS?c=(this.getHeight()-o*a-i*2)/2:l===PF&&(c=this.getHeight()-o*a-i*2),e.translate(i,c+i),C=0;C<o;C++){let L=0,H=0;const B=r[C],z=B.text,Y=B.width,F=B.lastInParagraph;if(e.save(),d===OF?L+=p-Y-i*2:d===TF&&(L+=(p-Y-i*2)/2),k){e.save(),e.beginPath();const A=y??(gt.legacyTextRendering?Math.round(s/2):Math.round(s/4)),N=L,X=x+H+A;e.moveTo(N,X);const ee=d===rf&&!F?p-i*2:Y;e.lineTo(N+Math.round(ee),X),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}const M=L;if(u!==LS&&(m!==0||d===rf||h)){const A=z.split(" ").length-1,N=Va(z);for(let X=0;X<N.length;X++){const ee=N[X];if(ee===" "&&!F&&d===rf&&(L+=(p-i*2-Y)/A),this._partialTextX=L,this._partialTextY=x+H,this._partialText=ee,h){e.save();const se=r.slice(0,C).reduce((de,Oe)=>de+Va(Oe.text).length,0);h({char:ee,index:X+se,x:L,y:x+H,lineIndex:C,column:X,isLastInLine:F,width:this.measureSize(ee).width,context:e})}e.fillStrokeShape(this),h&&e.restore(),L+=this.measureSize(ee).width+m}}else m!==0&&e.setAttr("letterSpacing",`${m}px`),this._partialTextX=L,this._partialTextY=x+H,this._partialText=z,e.fillStrokeShape(this);if(w){e.save(),e.beginPath();const A=gt.legacyTextRendering?0:-Math.round(s/4),N=M;e.moveTo(N,x+H+A);const X=d===rf&&!F?p-i*2:Y;e.lineTo(N+Math.round(X),x+H+A),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}e.restore(),o>1&&(x+=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=xe._isString(e)?e:e==null?"":e+"";return this._setAttr(MF,t),this}getWidth(){return this.attrs.width===Qc||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Qc||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return xe.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,u,c,d;let p=s0(),m=this.fontSize(),h;p.save(),p.font=this._getContextFont(),h=p.measureText(e),p.restore();const g=m/100;return{actualBoundingBoxAscent:(t=h.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*g,actualBoundingBoxDescent:(n=h.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=h.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*g,actualBoundingBoxRight:(o=h.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*g,alphabeticBaseline:(i=h.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=h.emHeightAscent)!==null&&s!==void 0?s:100*g,emHeightDescent:(a=h.emHeightDescent)!==null&&a!==void 0?a:-20*g,fontBoundingBoxAscent:(l=h.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*g,fontBoundingBoxDescent:(u=h.fontBoundingBoxDescent)!==null&&u!==void 0?u:21*g,hangingBaseline:(c=h.hangingBaseline)!==null&&c!==void 0?c:72.80000305175781*g,ideographicBaseline:(d=h.ideographicBaseline)!==null&&d!==void 0?d:-21*g,width:h.width,height:m}}_getContextFont(){return this.fontStyle()+xp+this.fontVariant()+xp+(this.fontSize()+FF)+UF(this.fontFamily())}_addTextLine(e){this.align()===rf&&(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 s0().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!==Qc&&o!==void 0,a=i!==Qc&&i!==void 0,l=this.padding(),u=o-l*2,c=i-l*2,d=0,p=this.wrap(),m=p!==NF&&p!==DS,h=this.ellipsis();this.textArr=[],s0().font=this._getContextFont();const g=h?this._getTextWidth(i0):0;for(let b=0,y=e.length;b<y;++b){let k=e[b],w=this._getTextWidth(k);if(s&&w>u)for(;k.length>0;){let C=0,x=Va(k).length,R="",L=0;for(;C<x;){const H=C+x>>>1,B=Va(k).slice(0,H+1).join(""),z=this._getTextWidth(B);(h&&a&&d+r>c?z+g:z)<=u?(C=H+1,R=B,L=z):x=H}if(R){if(m){const H=Va(k),B=Va(R),z=H[B.length],Y=z===xp||z===xS;let F;if(Y&&L<=u)F=B.length;else{const M=B.lastIndexOf(xp),A=B.lastIndexOf(xS);F=Math.max(M,A)+1}F>0&&(C=F,R=H.slice(0,C).join(""),L=this._getTextWidth(R))}if(R=R.trimRight(),this._addTextLine(R),n=Math.max(n,L),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(k=Va(k).slice(C).join("").trimLeft(),k.length>0&&(w=this._getTextWidth(k),w<=u)){this._addTextLine(k),d+=r,n=Math.max(n,w);break}}else break}else this._addTextLine(k),d+=r,n=Math.max(n,w),this._shouldHandleEllipsis(d)&&b<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>c)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==Qc&&r!==void 0,i=r-this.padding()*2;return this.wrap()===DS||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==Qc&&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+i0)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+i0))}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&&HF()?!0:super._useBufferCanvas()}};Wn.prototype._fillFunc=VF,Wn.prototype._strokeFunc=jF,Wn.prototype.className=LF,Wn.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],ar(Wn),ae.overWriteSetter(Wn,"width",Uy()),ae.overWriteSetter(Wn,"height",Uy()),ae.addGetterSetter(Wn,"direction",IS),ae.addGetterSetter(Wn,"fontFamily","Arial"),ae.addGetterSetter(Wn,"fontSize",12,ft()),ae.addGetterSetter(Wn,"fontStyle",MS),ae.addGetterSetter(Wn,"fontVariant",MS),ae.addGetterSetter(Wn,"padding",0,ft()),ae.addGetterSetter(Wn,"align",TS),ae.addGetterSetter(Wn,"verticalAlign",DF),ae.addGetterSetter(Wn,"lineHeight",1,ft()),ae.addGetterSetter(Wn,"wrap",BF),ae.addGetterSetter(Wn,"ellipsis",!1,Si()),ae.addGetterSetter(Wn,"letterSpacing",0,ft()),ae.addGetterSetter(Wn,"text","",Ml()),ae.addGetterSetter(Wn,"textDecoration",""),ae.addGetterSetter(Wn,"underlineOffset",void 0,ft()),ae.addGetterSetter(Wn,"charRenderFunc",void 0);var WF="",FS="normal";function OS(e){e.fillText(this.partialText,0,0)}function BS(e){e.strokeText(this.partialText,0,0)}var Br=class extends at{constructor(e){super(e),this.dummyCanvas=xe.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 si.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:si.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=si.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 xe.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Wn.prototype.setText.call(this,e)}_getContextFont(){return Wn.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=Va(this.text()),t=[];let n=0;for(let p=0;p<e.length;p++)t.push({char:e[p],width:this._getTextSize(e[p]).width}),n+=t[p].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),u=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let c=0;s==="center"&&(c=Math.max(0,this.pathLength/2-u/2)),s==="right"&&(c=Math.max(0,this.pathLength-u));let d=c;for(let p=0;p<t.length;p++){const m=this._getPointAtLength(d);if(!m)return;const h=t[p].char;let g=t[p].width+i;if(h===" "&&s==="justify"){const R=this.text().split(" ").length-1;g+=(this.pathLength-u)/R}const b=d+g,y=this._getPointAtLength(b>this.pathLength&&b-this.pathLength<=l?this.pathLength:b);if(!y)return;const k=si.getLineLength(m.x,m.y,y.x,y.y);let w=0;if(a)try{w=a(t[p-1].char,h)*this.fontSize()}catch{w=0}m.x+=w,y.x+=w,this.textWidth+=w;const C=si.getPointOnLine(w+k/2,m.x,m.y,y.x,y.y),x=Math.atan2(y.y-m.y,y.x-m.x);this.glyphInfo.push({transposeX:C.x,transposeY:C.y,text:e[p],rotation:x,p0:m,p1:y,width:k}),d+=g}}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 xe.releaseCanvas(this.dummyCanvas),super.destroy()}};Br.prototype._fillFunc=OS,Br.prototype._strokeFunc=BS,Br.prototype._fillFuncHit=OS,Br.prototype._strokeFuncHit=BS,Br.prototype.className="TextPath",Br.prototype._attrsAffectingSize=["text","fontSize","data"],ar(Br),ae.addGetterSetter(Br,"data"),ae.addGetterSetter(Br,"fontFamily","Arial"),ae.addGetterSetter(Br,"fontSize",12,ft()),ae.addGetterSetter(Br,"fontStyle",FS),ae.addGetterSetter(Br,"align","left"),ae.addGetterSetter(Br,"letterSpacing",0,ft()),ae.addGetterSetter(Br,"textBaseline","middle"),ae.addGetterSetter(Br,"fontVariant",FS),ae.addGetterSetter(Br,"text",WF),ae.addGetterSetter(Br,"textDecoration",""),ae.addGetterSetter(Br,"kerningFunc",void 0);var NS="tr-konva",KF=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${NS}`).join(" "),zS="nodesRect",qF=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],YF={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},XF="ontouchstart"in gt._global;function QF(e,t,n){if(e==="rotater")return n;t+=xe.degToRad(YF[e]||0);const r=(xe.radToDeg(t)%360+360)%360;return xe._inRange(r,337.5,360)||xe._inRange(r,0,22.5)?"ns-resize":xe._inRange(r,22.5,67.5)?"nesw-resize":xe._inRange(r,67.5,112.5)?"ew-resize":xe._inRange(r,112.5,157.5)?"nwse-resize":xe._inRange(r,157.5,202.5)?"ns-resize":xe._inRange(r,202.5,247.5)?"nesw-resize":xe._inRange(r,247.5,292.5)?"ew-resize":xe._inRange(r,292.5,337.5)?"nwse-resize":(xe.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var Rp=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],HS=1e8;function ZF(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 US(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 JF(e,t){return US(e,t,ZF(e))}function $F(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=gt.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var a0=0,hn=class extends qc{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(KF,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return xe.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 NS+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(xe.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(o=>o+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(qF.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),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(zS),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(zS,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=(gt.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return US({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},-gt.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-HS,y:-HS,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),u=[{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}],c=a.getAbsoluteTransform();u.forEach(function(d){const p=c.point(d);e.push(p)})});const t=new _i;t.rotate(-gt.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:gt.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(),Rp.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new nf({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:XF?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=QF(e,gt.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 at({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(),u=xe.degToRad(a),c=Math.sin(u),d=-Math.cos(u),p=i/2,m=s/2;let h=1/0;d<0?h=Math.min(h,-m/d):d>0&&(h=Math.min(h,(s-m)/d)),c<0?h=Math.min(h,-p/c):c>0&&(h=Math.min(h,(i-p)/c));const g=p+c*h,b=m+d*h,y=xe._sign(s),k=g+c*l*y,w=b+d*l*y;t.moveTo(g,b),t.lineTo(k,w)}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},a0++,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 u=o.getAbsolutePosition();if(l.x===u.x&&l.y===u.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=o.x()-y.width/2,n=-o.y()+y.height/2;const k=gt.getAngle(this.rotateAnchorAngle());let w=Math.atan2(-n,t)+Math.PI/2-k;y.height<0&&(w-=Math.PI);const C=gt.getAngle(this.rotation())+w,x=gt.getAngle(this.rotationSnapTolerance()),R=JF(y,$F(this.rotationSnaps(),C,x)-y.rotation);this._fitNodesInto(R,e);return}const c=this.shiftBehavior();let d;c==="inverted"?d=this.keepRatio()&&!e.shiftKey:c==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let p=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const y=p?{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(y.x-o.x(),2)+Math.pow(y.y-o.y(),2));const k=this.findOne(".top-left").x()>y.x?-1:1,w=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*k,n=r*this.sin*w,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(d){const y=p?{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()-y.x,2)+Math.pow(y.y-o.y(),2));const k=this.findOne(".top-right").x()<y.x?-1:1,w=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*k,n=r*this.sin*w,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var m=o.position();this.findOne(".top-left").y(m.y),this.findOne(".bottom-right").x(m.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(d){const y=p?{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(y.x-o.x(),2)+Math.pow(o.y()-y.y,2));const k=y.x<o.x()?-1:1,w=o.y()<y.y?-1:1;t=r*this.cos*k,n=r*this.sin*w,o.x(y.x-t),o.y(y.y+n)}m=o.position(),this.findOne(".top-left").x(m.x),this.findOne(".bottom-right").y(m.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(d){const y=p?{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()-y.x,2)+Math.pow(o.y()-y.y,2));const k=this.findOne(".bottom-right").x()<y.x?-1:1,w=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*k,n=r*this.sin*w,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||e.altKey,p){const y=this.findOne(".top-left"),k=this.findOne(".bottom-right"),w=y.x(),C=y.y(),x=this.getWidth()-k.x(),R=this.getHeight()-k.y();k.move({x:-w,y:-C}),y.move({x,y:R})}const h=this.findOne(".top-left").getAbsolutePosition();t=h.x,n=h.y;const g=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),b=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:g,height:b,rotation:gt.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();a0--,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(xe._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(xe._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new _i;if(o.rotate(gt.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=o.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=o.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:xe.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new _i;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new _i,l=e.width/i,u=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(u))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,u));const c=a.multiply(s.invert());this._nodes.forEach(d=>{var p;if(!d.getStage())return;const m=d.getParent().getAbsoluteTransform(),h=d.getTransform().copy();h.translate(d.offsetX(),d.offsetY());const g=new _i;g.multiply(m.copy().invert()).multiply(c).multiply(m).multiply(h);const b=g.decompose();d.setAttrs(b),(p=d.getLayer())===null||p===void 0||p.batchDraw()}),this.rotation(xe._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),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(xe._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(x=>{x.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 u=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),d=xe.degToRad(u),p=Math.sin(d),m=-Math.cos(d),h=n/2,g=r/2;let b=1/0;m<0?b=Math.min(b,-g/m):m>0&&(b=Math.min(b,(r-g)/m)),p<0?b=Math.min(b,-h/p):p>0&&(b=Math.min(b,(n-h)/p));const y=h+p*b,k=g+m*b,w=xe._sign(r);this._batchChangeChild(".rotater",{x:y+p*c*w,y:k+m*c*w-s*m,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(x=>x.draggable()),x:0,y:0});const C=this.anchorStyleFunc();C&&l.forEach(x=>{C(x)}),(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=""),qc.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(xe.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return bt.prototype.toObject.call(this)}clone(e){return bt.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};hn.isTransforming=()=>a0>0;function eO(e){return e instanceof Array||xe.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){Rp.indexOf(t)===-1&&xe.warn("Unknown anchor name: "+t+". Available names are: "+Rp.join(", "))}),e||[]}hn.prototype.className="Transformer",ar(hn),ae.addGetterSetter(hn,"enabledAnchors",Rp,eO),ae.addGetterSetter(hn,"flipEnabled",!0,Si()),ae.addGetterSetter(hn,"resizeEnabled",!0),ae.addGetterSetter(hn,"anchorSize",10,ft()),ae.addGetterSetter(hn,"rotateEnabled",!0),ae.addGetterSetter(hn,"rotateLineVisible",!0),ae.addGetterSetter(hn,"rotationSnaps",[]),ae.addGetterSetter(hn,"rotateAnchorOffset",50,ft()),ae.addGetterSetter(hn,"rotateAnchorAngle",0,ft()),ae.addGetterSetter(hn,"rotateAnchorCursor","crosshair"),ae.addGetterSetter(hn,"rotationSnapTolerance",5,ft()),ae.addGetterSetter(hn,"borderEnabled",!0),ae.addGetterSetter(hn,"anchorStroke","rgb(0, 161, 255)"),ae.addGetterSetter(hn,"anchorStrokeWidth",1,ft()),ae.addGetterSetter(hn,"anchorFill","white"),ae.addGetterSetter(hn,"anchorCornerRadius",0,ft()),ae.addGetterSetter(hn,"borderStroke","rgb(0, 161, 255)"),ae.addGetterSetter(hn,"borderStrokeWidth",1,ft()),ae.addGetterSetter(hn,"borderDash"),ae.addGetterSetter(hn,"keepRatio",!0),ae.addGetterSetter(hn,"shiftBehavior","default"),ae.addGetterSetter(hn,"centeredScaling",!1),ae.addGetterSetter(hn,"ignoreStroke",!1),ae.addGetterSetter(hn,"padding",0,ft()),ae.addGetterSetter(hn,"nodes"),ae.addGetterSetter(hn,"node"),ae.addGetterSetter(hn,"boundBoxFunc"),ae.addGetterSetter(hn,"anchorDragBoundFunc"),ae.addGetterSetter(hn,"anchorStyleFunc"),ae.addGetterSetter(hn,"shouldOverdrawWholeArea",!1),ae.addGetterSetter(hn,"useSingleNodeRotation",!0),ae.backCompat(hn,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var ea=class extends at{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,gt.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)}};ea.prototype.className="Wedge",ea.prototype._centroid=!0,ea.prototype._attrsAffectingSize=["radius"],ar(ea),ae.addGetterSetter(ea,"radius",0,ft()),ae.addGetterSetter(ea,"angle",0,ft()),ae.addGetterSetter(ea,"clockwise",!1),ae.backCompat(ea,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function VS(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var tO=[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],nO=[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 rO(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,u,c,d,p,m,h,g,b,y,k,w,C,x,R,L,H;const B=t+t+1,z=r-1,Y=o-1,F=t+1,M=F*(F+1)/2,A=new VS,N=tO[t],X=nO[t];let ee=null,se=A,de=null,Oe=null;for(let le=1;le<B;le++)se=se.next=new VS,le===F&&(ee=se);se.next=A,a=s=0;for(let le=0;le<o;le++){b=y=k=w=l=u=c=d=0,p=F*(C=n[s]),m=F*(x=n[s+1]),h=F*(R=n[s+2]),g=F*(L=n[s+3]),l+=M*C,u+=M*x,c+=M*R,d+=M*L,se=A;for(let ve=0;ve<F;ve++)se.r=C,se.g=x,se.b=R,se.a=L,se=se.next;for(let ve=1;ve<F;ve++)i=s+((z<ve?z:ve)<<2),l+=(se.r=C=n[i])*(H=F-ve),u+=(se.g=x=n[i+1])*H,c+=(se.b=R=n[i+2])*H,d+=(se.a=L=n[i+3])*H,b+=C,y+=x,k+=R,w+=L,se=se.next;de=A,Oe=ee;for(let ve=0;ve<r;ve++)n[s+3]=L=d*N>>X,L!==0?(L=255/L,n[s]=(l*N>>X)*L,n[s+1]=(u*N>>X)*L,n[s+2]=(c*N>>X)*L):n[s]=n[s+1]=n[s+2]=0,l-=p,u-=m,c-=h,d-=g,p-=de.r,m-=de.g,h-=de.b,g-=de.a,i=a+((i=ve+t+1)<z?i:z)<<2,b+=de.r=n[i],y+=de.g=n[i+1],k+=de.b=n[i+2],w+=de.a=n[i+3],l+=b,u+=y,c+=k,d+=w,de=de.next,p+=C=Oe.r,m+=x=Oe.g,h+=R=Oe.b,g+=L=Oe.a,b-=C,y-=x,k-=R,w-=L,Oe=Oe.next,s+=4;a+=r}for(let le=0;le<r;le++){y=k=w=b=u=c=d=l=0,s=le<<2,p=F*(C=n[s]),m=F*(x=n[s+1]),h=F*(R=n[s+2]),g=F*(L=n[s+3]),l+=M*C,u+=M*x,c+=M*R,d+=M*L,se=A;for(let he=0;he<F;he++)se.r=C,se.g=x,se.b=R,se.a=L,se=se.next;let ve=r;for(let he=1;he<=t;he++)s=ve+le<<2,l+=(se.r=C=n[s])*(H=F-he),u+=(se.g=x=n[s+1])*H,c+=(se.b=R=n[s+2])*H,d+=(se.a=L=n[s+3])*H,b+=C,y+=x,k+=R,w+=L,se=se.next,he<Y&&(ve+=r);s=le,de=A,Oe=ee;for(let he=0;he<o;he++)i=s<<2,n[i+3]=L=d*N>>X,L>0?(L=255/L,n[i]=(l*N>>X)*L,n[i+1]=(u*N>>X)*L,n[i+2]=(c*N>>X)*L):n[i]=n[i+1]=n[i+2]=0,l-=p,u-=m,c-=h,d-=g,p-=de.r,m-=de.g,h-=de.b,g-=de.a,i=le+((i=he+F)<Y?i:Y)*r<<2,l+=b+=de.r=n[i],u+=y+=de.g=n[i+1],c+=k+=de.b=n[i+2],d+=w+=de.a=n[i+3],de=de.next,p+=C=Oe.r,m+=x=Oe.g,h+=R=Oe.b,g+=L=Oe.a,b-=C,y-=x,k-=R,w-=L,Oe=Oe.next,s+=r}}const oO=function(t){const n=Math.round(this.blurRadius());n>0&&rO(t,n)};ae.addGetterSetter(bt,"blurRadius",0,ft(),ae.afterSetFilter);const iO=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};ae.addGetterSetter(bt,"brightness",0,ft(),ae.afterSetFilter);const sO=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)},aO=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};ae.addGetterSetter(bt,"contrast",0,ft(),ae.afterSetFilter);const lO=function(e){var t,n,r,o,i,s,a,l,u;const c=e.data,d=e.width,p=e.height,m=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)),h=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)),g=(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,b=!!((u=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&u!==void 0&&u),y=m*10,k=h*255,w=g*Math.PI/180,C=Math.cos(w),x=Math.sin(w),R=128/1020*y,L=new Uint8ClampedArray(c),H=new Float32Array(d*p);for(let M=0,A=0;A<c.length;A+=4,M++)H[M]=.2126*L[A]+.7152*L[A+1]+.0722*L[A+2];const B=[-1,0,1,-2,0,2,-1,0,1],z=[-1,-2,-1,0,0,0,1,2,1],Y=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],F=M=>M<0?0:M>255?255:M;for(let M=1;M<p-1;M++)for(let A=1;A<d-1;A++){const N=M*d+A;let X=0,ee=0;X+=H[N+Y[0]]*B[0],ee+=H[N+Y[0]]*z[0],X+=H[N+Y[1]]*B[1],ee+=H[N+Y[1]]*z[1],X+=H[N+Y[2]]*B[2],ee+=H[N+Y[2]]*z[2],X+=H[N+Y[3]]*B[3],ee+=H[N+Y[3]]*z[3],X+=H[N+Y[5]]*B[5],ee+=H[N+Y[5]]*z[5],X+=H[N+Y[6]]*B[6],ee+=H[N+Y[6]]*z[6],X+=H[N+Y[7]]*B[7],ee+=H[N+Y[7]]*z[7],X+=H[N+Y[8]]*B[8],ee+=H[N+Y[8]]*z[8];const se=F(k+(C*X+x*ee)*R),de=N*4;if(b){const Oe=se-k;c[de]=F(L[de]+Oe),c[de+1]=F(L[de+1]+Oe),c[de+2]=F(L[de+2]+Oe),c[de+3]=L[de+3]}else c[de]=c[de+1]=c[de+2]=se,c[de+3]=L[de+3]}for(let M=0;M<d;M++){let A=M*4,N=((p-1)*d+M)*4;c[A]=L[A],c[A+1]=L[A+1],c[A+2]=L[A+2],c[A+3]=L[A+3],c[N]=L[N],c[N+1]=L[N+1],c[N+2]=L[N+2],c[N+3]=L[N+3]}for(let M=1;M<p-1;M++){let A=M*d*4,N=(M*d+(d-1))*4;c[A]=L[A],c[A+1]=L[A+1],c[A+2]=L[A+2],c[A+3]=L[A+3],c[N]=L[N],c[N+1]=L[N+1],c[N+2]=L[N+2],c[N+3]=L[N+3]}return e};ae.addGetterSetter(bt,"embossStrength",.5,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"embossWhiteLevel",.5,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"embossDirection","top-left",void 0,ae.afterSetFilter),ae.addGetterSetter(bt,"embossBlend",!1,void 0,ae.afterSetFilter);function l0(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}const cO=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,u=t[2],c=u,d;const p=this.enhance();if(p===0)return;for(let w=0;w<n;w+=4)i=t[w+0],i<r?r=i:i>o&&(o=i),l=t[w+1],l<s?s=l:l>a&&(a=l),d=t[w+2],d<u?u=d:d>c&&(c=d);o===r&&(o=255,r=0),a===s&&(a=255,s=0),c===u&&(c=255,u=0);let m,h,g,b,y,k;if(p>0)m=o+p*(255-o),h=r-p*(r-0),g=a+p*(255-a),b=s-p*(s-0),y=c+p*(255-c),k=u-p*(u-0);else{const w=(o+r)*.5;m=o+p*(o-w),h=r+p*(r-w);const C=(a+s)*.5;g=a+p*(a-C),b=s+p*(s-C);const x=(c+u)*.5;y=c+p*(c-x),k=u+p*(u-x)}for(let w=0;w<n;w+=4)t[w+0]=l0(t[w+0],r,o,h,m),t[w+1]=l0(t[w+1],s,a,b,g),t[w+2]=l0(t[w+2],u,c,k,y)};ae.addGetterSetter(bt,"enhance",0,ft(),ae.afterSetFilter);const uO=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}};ae.addGetterSetter(bt,"hue",0,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"saturation",0,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"luminance",0,ft(),ae.afterSetFilter);const dO=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),u=.299*r+.701*a+.167*l,c=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,p=.299*r-.299*a-.328*l,m=.587*r+.413*a+.035*l,h=.114*r-.114*a+.293*l,g=.299*r-.3*a+1.25*l,b=.587*r-.586*a-1.05*l,y=.114*r+.886*a-.2*l;let k,w,C,x;for(let R=0;R<n;R+=4)k=t[R+0],w=t[R+1],C=t[R+2],x=t[R+3],t[R+0]=u*k+c*w+d*C+s,t[R+1]=p*k+m*w+h*C+s,t[R+2]=g*k+b*w+y*C+s,t[R+3]=x},fO=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,u=.587*r-.587*s+.33*a,c=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,p=.587*r+.413*s+.035*a,m=.114*r-.114*s+.293*a,h=.299*r-.3*s+1.25*a,g=.587*r-.586*s-1.05*a,b=.114*r+.886*s-.2*a;for(let y=0;y<n;y+=4){const k=t[y+0],w=t[y+1],C=t[y+2],x=t[y+3];t[y+0]=l*k+u*w+c*C,t[y+1]=d*k+p*w+m*C,t[y+2]=h*k+g*w+b*C,t[y+3]=x}};ae.addGetterSetter(bt,"hue",0,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"saturation",0,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"value",0,ft(),ae.afterSetFilter);const hO=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]};var pO=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 u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const p=Math.sqrt(c*c+d*d);u=p>u?p:u;const m=s,h=i,g=360/h*Math.PI/180;for(let b=0;b<h;b+=1){const y=Math.sin(b*g),k=Math.cos(b*g);for(let w=0;w<m;w+=1){c=Math.floor(a+u*w/m*k),d=Math.floor(l+u*w/m*y);let C=(d*i+c)*4;const x=r[C+0],R=r[C+1],L=r[C+2],H=r[C+3];C=(b+w*i)*4,o[C+0]=x,o[C+1]=R,o[C+2]=L,o[C+3]=H}}},mO=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 u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const p=Math.sqrt(c*c+d*d);u=p>u?p:u;const m=s,h=i,g=n.polarRotation||0;let b,y;for(c=0;c<i;c+=1)for(d=0;d<s;d+=1){const k=c-a,w=d-l,C=Math.sqrt(k*k+w*w)*m/u;let x=(Math.atan2(w,k)*180/Math.PI+360+g)%360;x=x*h/360,b=Math.floor(x),y=Math.floor(C);let R=(y*i+b)*4;const L=r[R+0],H=r[R+1],B=r[R+2],z=r[R+3];R=(d*i+c)*4,o[R+0]=L,o[R+1]=H,o[R+2]=B,o[R+3]=z}};const gO=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,u,c,d,p,m=Math.round(this.kaleidoscopePower());const h=Math.round(this.kaleidoscopeAngle()),g=Math.floor(t*(h%360)/360);if(m<1)return;const b=xe.createCanvasElement();b.width=t,b.height=n;const y=b.getContext("2d").getImageData(0,0,t,n);xe.releaseCanvas(b),pO(e,y,{polarCenterX:t/2,polarCenterY:n/2});let k=t/Math.pow(2,m);for(;k<=8;)k=k*2,m-=1;k=Math.ceil(k);let w=k,C=0,x=w,R=1;for(g+k>t&&(C=w,x=0,R=-1),o=0;o<n;o+=1)for(r=C;r!==x;r+=R)i=Math.round(r+g)%t,d=(t*o+i)*4,a=y.data[d+0],l=y.data[d+1],u=y.data[d+2],c=y.data[d+3],p=(t*o+r)*4,y.data[p+0]=a,y.data[p+1]=l,y.data[p+2]=u,y.data[p+3]=c;for(o=0;o<n;o+=1)for(w=Math.floor(k),s=0;s<m;s+=1){for(r=0;r<w+1;r+=1)d=(t*o+r)*4,a=y.data[d+0],l=y.data[d+1],u=y.data[d+2],c=y.data[d+3],p=(t*o+w*2-r-1)*4,y.data[p+0]=a,y.data[p+1]=l,y.data[p+2]=u,y.data[p+3]=c;w*=2}mO(y,e,{polarRotation:0})};ae.addGetterSetter(bt,"kaleidoscopePower",2,ft(),ae.afterSetFilter),ae.addGetterSetter(bt,"kaleidoscopeAngle",0,ft(),ae.afterSetFilter);function Mp(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 sf(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 vO(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 yO(e,t){const n=Mp(e,0,0),r=Mp(e,e.width-1,0),o=Mp(e,0,e.height-1),i=Mp(e,e.width-1,e.height-1),s=t||10;if(sf(n,r)<s&&sf(r,i)<s&&sf(i,o)<s&&sf(o,n)<s){const a=vO([r,n,i,o]),l=[];for(let u=0;u<e.width*e.height;u++)l[u]=sf(a,[e.data[u*4],e.data[u*4+1],e.data[u*4+2]])<s?0:255;return l}}function bO(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function wO(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 u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let p=0;p<o;p++){const m=a+d-i,h=l+p-i;if(m>=0&&m<n&&h>=0&&h<t){const g=m*t+h,b=r[d*o+p];c+=e[g]*b}}s[u]=c===2040?255:0}return s}function CO(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 u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let p=0;p<o;p++){const m=a+d-i,h=l+p-i;if(m>=0&&m<n&&h>=0&&h<t){const g=m*t+h,b=r[d*o+p];c+=e[g]*b}}s[u]=c>=1020?255:0}return s}function _O(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 u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let p=0;p<o;p++){const m=a+d-i,h=l+p-i;if(m>=0&&m<n&&h>=0&&h<t){const g=m*t+h,b=r[d*o+p];c+=e[g]*b}}s[u]=c}return s}const SO=function(e){let t=yO(e,this.threshold());return t&&(t=wO(t,e.width,e.height),t=CO(t,e.width,e.height),t=_O(t,e.width,e.height),bO(e,t)),e};ae.addGetterSetter(bt,"threshold",0,ft(),ae.afterSetFilter);const kO=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()};ae.addGetterSetter(bt,"noise",.2,ft(),ae.afterSetFilter);const AO=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){xe.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 u=0,c=0,d=0,p=0;const m=a*t,h=m+t,g=l*t,b=g+t;let y=0;for(let k=m;k<h;k+=1)if(!(k>=n))for(let w=g;w<b;w+=1){if(w>=r)continue;const C=(n*w+k)*4;u+=s[C+0],c+=s[C+1],d+=s[C+2],p+=s[C+3],y+=1}u=u/y,c=c/y,d=d/y,p=p/y;for(let k=m;k<h;k+=1)if(!(k>=n))for(let w=g;w<b;w+=1){if(w>=r)continue;const C=(n*w+k)*4;s[C+0]=u,s[C+1]=c,s[C+2]=d,s[C+3]=p}}};ae.addGetterSetter(bt,"pixelSize",8,ft(),ae.afterSetFilter);const IO=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};ae.addGetterSetter(bt,"levels",.5,ft(),ae.afterSetFilter);const EO=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]}};ae.addGetterSetter(bt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ae.addGetterSetter(bt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ae.addGetterSetter(bt,"blue",0,V4,ae.afterSetFilter);const xO=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}};ae.addGetterSetter(bt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ae.addGetterSetter(bt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ae.addGetterSetter(bt,"blue",0,V4,ae.afterSetFilter),ae.addGetterSetter(bt,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const TO=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)}},RO=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},MO=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};ae.addGetterSetter(bt,"threshold",.5,ft(),ae.afterSetFilter);var LO=bS.Util._assign(bS,{Arc:Js,Arrow:Pl,Circle:Xc,Ellipse:za,Image:ki,Label:o0,Tag:Fl,Line:$s,Path:si,Rect:nf,RegularPolygon:Ha,Ring:Ol,Sprite:ns,Star:Ua,Text:Wn,TextPath:Br,Transformer:hn,Wedge:ea,Filters:{Blur:oO,Brightness:sO,Brighten:iO,Contrast:aO,Emboss:lO,Enhance:cO,Grayscale:uO,HSL:dO,HSV:fO,Invert:hO,Kaleidoscope:gO,Mask:SO,Noise:kO,Pixelate:AO,Posterize:IO,RGB:EO,RGBA:xO,Sepia:TO,Solarize:RO,Threshold:MO}});It();var DO=["dialog","floating"],jS=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function PO(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!DO.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&&!jS.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${jS.join(", ")}, got "${e.floating.placement}".`)}var FO=class{activeDialog=Or(null);activeFloating=Or(null);#t=!1;#n=1;#e;constructor({getModuleConfig:e}){this.#e=e}open(e){if(this.#t)return this.#r(e);PO(e);const t=this.#u(e),{component:n,props:r,render:o}=this.#d(t);let i,s=!1;const a=new Promise(m=>{i=h=>s?!1:(s=!0,m(h),!0)});let l;const u=m=>{i({status:"submitted",data:m})&&this.#i(l)},c=m=>{i({status:"closed",reason:m})&&this.#i(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:u,close:c,settle:m=>i(m),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",p=this[d].value;return p&&!p.settled&&p.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:m=>this.#o(l,m),result:a}}close(e,t){if(e!=null){const o=this.#s(e);o&&this.#o(o,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#o(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#o(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.#t=!0,this.settleAll({status:"destroyed"})}#o(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}#u(e){const t=e.id??`surface-${this.#n++}`,n=this.#e()??{},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}}#d(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.#e()?.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 modules.surfaces.resolver, or use a direct-render request.`)}#r(e){return{id:e?.id??`surface-${this.#n++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},OO="https://docs.superdoc.dev/guides/migration/document-api",GS=new Set;function BO(e,t){GS.has(e)||(GS.add(e),console.warn(t))}var NO={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},WS=Symbol.for("superdoc:rawEditor"),KS=new WeakMap;function qS(e){return!e||e[WS]?e:new Proxy(e,{get(t,n){if(n===WS)return t;const r=NO[n];r&&BO(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${OO}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=KS.get(t);return i||(i=new Map,KS.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var YS=["review","original","final","off"],zO=["paired","independent"],XS=Symbol.for("@superdoc/trackChanges:normalized"),QS=new Set;function ZS(e,t){QS.has(e)||(QS.add(e),console.warn(`[SuperDoc] ${e} is deprecated β€” use ${t} instead.`))}function JS(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function HO(e,t,n){return typeof e=="string"&&YS.includes(e)?e:typeof t=="string"&&YS.includes(t)?t:n}function UO(e){return typeof e=="string"&&zO.includes(e)?e:null}function Bl(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function VO(e){const t=e[XS]===!0;Bl(e.modules)||(e.modules={});const n=Bl(e.modules.trackChanges),r=Bl(e.trackChanges),o=Bl(e.layoutEngineOptions?.trackedChanges);t||(r&&ZS("config.trackChanges","config.modules.trackChanges"),o&&ZS("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=JS(n?.visible,r?.visible,!1),s=JS(n?.enabled,o?.enabled,!0),a=UO(n?.replacements)??"paired",l=Bl(n?.authorColors)?n.authorColors:void 0,u=Bl(n?.semanticColors)?n.semanticColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",d=HO(n?.mode,o?.mode,c),p={visible:i,mode:d,enabled:s,replacements:a};return l&&(p.authorColors=l),u&&(p.semanticColors=u),e.modules.trackChanges=p,e.trackChanges={visible:i},Bl(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:d,enabled:s},Object.defineProperty(e,XS,{value:!0,writable:!0,configurable:!0,enumerable:!1}),p}const c0=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function jO(e){return!e||typeof e!="object"?{...c0}:{...c0,...e}}var GO=class{#t=new Map;#n=new Map;#e=null;#o=new Set;register(e){if(this.#t.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.#t.set(e.id,e),t&&this.#n.set(t,e.id)}unregister(e){const t=this.#t.get(e);return t?(this.#t.delete(e),t.root&&this.#n.delete(t.root),this.#e===e&&(this.#e=null,this.#i({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#t.get(e)??null}getAll(){return Array.from(this.#t.values())}getAllByDocumentId(e){const t=[];for(const n of this.#t.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#e===null?null:this.#t.get(this.#e)}getActiveId(){return this.#e}setActive(e,t){if(e!==null&&!this.#t.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#e)return;const n=this.#e;this.#e=e;let r=null;e!==null&&(r=this.#t.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(`[${ip}]`);if(!n)return null;const r=n.getAttribute(ip),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#o.add(e),()=>{this.#o.delete(e)}}clear(){this.#t.clear(),this.#n.clear(),this.#e=null,this.#o.clear()}#i(e){for(const t of Array.from(this.#o))try{t(e)}catch{}}},WO=["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"];const $S=[{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:WO,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"}];var ek=new Map($S.map(e=>[e.name,e]));const KU=$S.map(e=>e.name);function u0(e){return ek.get(e)??null}function KO(e){const t=ek.get(e);return t?.disposition==="controller-routed"?t.commandId:null}const qO=".png,.jpg,.jpeg,image/png,image/jpeg";var tk=new Set(["image/png","image/jpeg","image/jpg"]),YO=/\.(png|jpe?g)$/i;function XO(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?tk.has(t):YO.test(String(e.name??""))}function nk(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(QO(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function QO(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(tk.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 ZO(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:JO(n,e)}return nk(e)}async function JO(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 nk(o?Object.assign(r,{name:o}):r)}function $O({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=qO,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(!XO(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 eB=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},tB=(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=(...u)=>{const c=Date.now();!s&&n.leading===!1&&(s=c);const d=t-(c-s);return o=u,d<=0||d>t?(r&&(clearTimeout(r),r=null),s=c,i=e(...u),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,d)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};It(),nn();var nB={class:"sd-toolbar-icon"},rB=["innerHTML"],oB={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=Ie(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=Ie(()=>["color","highlight"].includes(t.name));return(o,i)=>(me(),Ae("div",nB,[De("div",{class:qt(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,rB),r.value?(me(),Ae("div",{key:0,class:"color-bar",style:an(n.value)},null,4)):ct("",!0)]))}},rk=Jt(oB,[["__scopeId","data-v-d7d79424"]]);It(),nn();var iB=["role","aria-label"],sB=["data-item"],aB=["data-item"],lB={key:1,class:"sd-button-label"},cB=["data-item","aria-label"],uB=["innerHTML"],dB={key:2},fB=["onKeydown","id"],hB=["placeholder","onKeydown","id","data-item"],pB=["data-item","innerHTML"],mB={"aria-live":"polite",class:"sd-visually-hidden"},gB={__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}=Jn(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:u,iconColor:c,hasCaret:d,splitButton:p,disabled:m,expand:h,inlineTextInputVisible:g,hasInlineTextInput:b,minWidth:y,style:k,attributes:w}=o.toolbarItem,C=Ie(()=>!!p?.value&&!!d?.value),x=Ie(()=>i?.value??""),R=te(""),L=te(null),{isHighContrastMode:H}=wi();Lt(()=>l?.value,_e=>{document.activeElement!==L.value&&(R.value=_e==null?"":String(_e))},{immediate:!0});const B=()=>{b&&St(()=>{L.value?.focus(),L.value?.select()}),n("buttonClick")},z=_e=>{m?.value||(_e?.stopPropagation(),n("mainClick"))},Y=()=>{C.value||B()},F=_e=>{if(C.value){z(_e);return}B()},M=_e=>{o.allowEnterPropagation||_e.stopPropagation(),F(_e)},A=_e=>{const oe=o.toolbarItem?.nestedOptions?.value??[],Me=_e.trim();if(!Me)return"";const Be=oe.find(et=>typeof et?.label=="string"&&et.label.toLowerCase()===Me.toLowerCase());return Be?.label?Be.label:oe.find(et=>typeof et?.label=="string"&&et.label.toLowerCase().startsWith(Me.toLowerCase()))?.label??Me},N=()=>{const _e=String(R.value??"").trim();let oe=_e;if(x.value==="fontSize"){const Me=Number.parseFloat(_e);oe=_e.match(/^\d+(\.5)?$/)?_e:Number.isFinite(Me)?Math.floor(Me).toString():""}else x.value==="fontFamily"&&(oe=A(_e));return oe?(n("textSubmit",oe),R.value=oe,!0):!1},X=_e=>{const oe=_e?.currentTarget;oe instanceof HTMLInputElement&&(oe.focus({preventScroll:!0}),oe.select())},ee=_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},de=()=>{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())},Oe=()=>{N()&&de()},le=_e=>{if(N(),_e.shiftKey){x.value==="fontSize"&&(_e.preventDefault(),St(()=>ee("fontFamily")));return}if(_e.preventDefault(),x.value==="fontFamily"){St(()=>ee("fontSize"));return}x.value==="fontSize"&&St(de)},ve=Ie(()=>k.value?k.value:{minWidth:o.minWidth}),he=Ie(()=>h?.value?Gn.dropdownCaretUp:Gn.dropdownCaretDown);return(_e,oe)=>(me(),Ae("div",{class:qt(["sd-toolbar-item",Ye(w).className]),style:an(ve.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Ye(w).ariaLabel,"data-sd-part":"toolbar-item",onClick:Y,onKeydown:oe[9]||(oe[9]=Fo(Me=>M(Me),["enter"])),tabindex:"0"},[De("div",{class:qt(["sd-toolbar-button",{"sd-active":Ye(s),"sd-disabled":Ye(m),narrow:e.isNarrow,wide:e.isWide,split:C.value,"has-inline-text-input":Ye(b),"high-contrast":Ye(H)}]),"data-item":`btn-${Ye(i)||""}`},[C.value?(me(),Ae("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${Ye(i)||""}-main`,onClick:oe[0]||(oe[0]=Me=>z(Me))},[Ye(a)?(me(),Zt(rk,{key:0,color:Ye(c),class:"sd-toolbar-icon",icon:Ye(a),name:Ye(i)},null,8,["color","icon","name"])):ct("",!0),Ye(l)&&!Ye(u)&&!Ye(g)?(me(),Ae("div",lB,Ft(Ye(l)),1)):ct("",!0)],8,aB)):ct("",!0),C.value?(me(),Ae("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${Ye(i)||""}-caret`,"aria-label":`${Ye(w).ariaLabel} options`,role:"button"},[De("div",{class:"sd-dropdown-caret",innerHTML:he.value,style:an({opacity:Ye(m)?.6:1})},null,12,uB)],8,cB)):(me(),Ae(Ut,{key:2},[Ye(a)?(me(),Zt(rk,{key:0,color:Ye(c),class:"sd-toolbar-icon",icon:Ye(a),name:Ye(i)},null,8,["color","icon","name"])):ct("",!0),Ye(l)&&!Ye(u)&&(!Ye(g)||x.value==="fontFamily")?(me(),Ae("div",{key:1,class:qt(["sd-button-label",{"sd-visually-hidden":Ye(g)&&x.value==="fontFamily"}])},Ft(Ye(l)),3)):ct("",!0),Ye(g)?(me(),Ae("span",dB,[Ye(i)==="fontSize"?xs((me(),Ae("input",{key:0,"onUpdate:modelValue":oe[1]||(oe[1]=Me=>R.value=Me),onKeydown:[Fo(Gt(Oe,["stop","prevent"]),["enter"]),oe[2]||(oe[2]=Fo(Me=>le(Me),["tab"]))],onClick:oe[3]||(oe[3]=Gt(Me=>X(Me),["stop"])),onFocus:oe[4]||(oe[4]=Me=>X(Me)),type:"text",class:qt(["button-text-input button-text-input--font-size",{"high-contrast":Ye(H)}]),id:"inlineTextInput-"+Ye(i),autocomplete:"off",ref_key:"inlineInput",ref:L},null,42,fB)),[[oi,R.value]]):xs((me(),Ae("input",{key:1,"onUpdate:modelValue":oe[5]||(oe[5]=Me=>R.value=Me),placeholder:Ye(l),onKeydown:[Fo(Gt(Oe,["stop","prevent"]),["enter"]),oe[6]||(oe[6]=Fo(Me=>le(Me),["tab"]))],onClick:oe[7]||(oe[7]=Gt(Me=>X(Me),["stop"])),onFocus:oe[8]||(oe[8]=Me=>X(Me)),type:"text",class:qt(["button-text-input",{"button-text-input--font-family":x.value==="fontFamily","high-contrast":Ye(H)}]),id:"inlineTextInput-"+Ye(i),"data-item":x.value==="fontFamily"?`btn-${Ye(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:L},null,42,hB)),[[oi,R.value]])])):ct("",!0),Ye(d)?(me(),Ae("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${Ye(i)||""}-toggle`,innerHTML:he.value,style:an({opacity:Ye(m)?.6:1})},null,12,pB)):ct("",!0)],64)),De("div",mB,Ft(`${Ye(w).ariaLabel} ${Ye(s)?"selected":"unset"}`),1)],10,sB)],46,iB))}},d0=Jt(gB,[["__scopeId","data-v-dbdea151"]]);It(),nn();var vB={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},yB={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=wi(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(me(),Ae("div",vB,[De("div",{class:"separator-inner",style:an({backgroundColor:r()})},null,4)]))}},bB=Jt(yB,[["__scopeId","data-v-cb82253a"]]);It(),nn();var wB={class:"overflow-menu"},CB={class:"overflow-menu-trigger"},_B={key:0,class:"overflow-menu_items",role:"group"},SB={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=Jn(),r=t,o=e,i=Ie(()=>o.toolbarItem.expand.value),s=te(!1),a=Ie(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},u=({item:d,argument:p})=>{n.$toolbar.emitCommand({item:d,argument:p})},c=d=>{d.key==="Escape"&&i.value&&!s.value&&(d.preventDefault(),r("close"))};return In(()=>{document.addEventListener("keydown",c,!0)}),Zn(()=>{document.removeEventListener("keydown",c,!0)}),(d,p)=>(me(),Ae("div",wB,[De("div",CB,[zt(d0,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(me(),Ae("div",_B,[zt(Fp,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:u,onDropdownUpdateShow:p[0]||(p[0]=m=>s.value=m)},null,8,["toolbar-items"])])):ct("",!0)]))}},kB=Jt(SB,[["__scopeId","data-v-504ecd05"]]);It(),nn();var AB={class:"toolbar-dropdown"},IB=["onClick"],EB={key:0,class:"toolbar-dropdown-option__icon"},xB={class:"toolbar-dropdown-option__label"},Lp='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',TB={__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),u=Ie(()=>!!n.show),c=Ie(()=>n.options.some(oe=>oe?.type==="render")),d=Ie(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),p=Ie(()=>{const{class:oe,style:Me,...Be}=d.value;return Be}),m=Ie(()=>{const oe=d.value.class,Me=n.options.length>0&&n.options.every(Be=>Be&&Be.type==="render");return["toolbar-dropdown-menu",oe,{"toolbar-dropdown-menu--render-only":Me}]}),h=Ie(()=>{const oe=d.value.style||{};return{...n.contentStyle,...oe}}),g=Ie(()=>({...h.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),b=oe=>{r("update:show",oe)},y=()=>{u.value&&b(!1)},k=()=>{if(!o.value)return;const oe=o.value.getBoundingClientRect(),Me=i.value,Be=Me?.offsetWidth??0,et=Me?.scrollHeight??Me?.offsetHeight??0,rt=window.innerWidth||document.documentElement.clientWidth||0,Ee=window.innerHeight||document.documentElement.clientHeight||0,Ue=8,Le=4,Z=oe.bottom+Le,_=oe.top-Le,ne=Math.max(0,Ee-Z-Ue),O=Math.max(0,_-Ue),V=ne<et&&O>ne,U=V?O:ne,j=et?Math.min(et,U):U,Q=V?Math.max(Ue,_-j):Z;let q=oe.left;n.placement==="bottom-end"&&(q=oe.right-Be);const G=Math.max(Ue,rt-Be-Ue);q=Math.min(Math.max(Ue,q),G),s.value={top:`${Q}px`,left:`${q}px`,maxHeight:`${U}px`}},w=()=>{n.disabled||b(!u.value)},C=oe=>typeof n.nodeProps!="function"?{}:n.nodeProps(oe)||{},x=oe=>{oe?.disabled||oe?.type!=="render"&&(r("select",oe?.key,oe),y())},R=oe=>oe?.type==="render",L=oe=>!oe?.disabled&&oe?.type!=="render",H=oe=>typeof oe?.icon=="function"||!!oe?.icon,B=oe=>typeof oe?.icon=="function"?oe.icon(oe):oe?.icon||null,z=oe=>oe?typeof oe=="string"?oe.split(/\s+/).includes("sd-selected"):Array.isArray(oe)?oe.some(z):typeof oe=="object"?!!oe["sd-selected"]:!1:!1,Y=oe=>z(oe?.props?.class)||z(oe?.class),F=()=>n.options.map((oe,Me)=>L(oe)?Me:-1).filter(oe=>oe>=0),M=()=>{const oe=n.options.findIndex(Me=>L(Me)&&Y(Me));return oe>=0?oe:F()[0]??-1},A=(oe,Me)=>{if(!oe){delete a.value[Me];return}a.value[Me]=oe},N=()=>{a.value.forEach((Me,Be)=>{Me&&Me.setAttribute("tabindex",Be===l.value?"0":"-1")});const oe=a.value[l.value];oe&&typeof oe.focus=="function"&&(oe.focus(),oe.scrollIntoView?.({block:"nearest",inline:"nearest"}))},X=oe=>{const Me=F();if(!Me.length){l.value=-1;return}const Be=Me.indexOf(l.value);if(Be<0){l.value=oe>0?Me[0]:Me[Me.length-1];return}l.value=Me[(Be+oe+Me.length)%Me.length]},ee=()=>{let oe=n.options[l.value];if(!L(oe)){const Me=F()[0];oe=Me===void 0?null:n.options[Me]}oe&&x(oe)},se=fl({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(oe){return()=>typeof oe.option.render!="function"?null:oe.option.render()}}),de=fl({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(oe){return()=>B(oe.option)}}),Oe=oe=>{if(!u.value)return;const Me=oe.target;if(!(Me instanceof Element))return;const Be=o.value?.contains(Me),et=i.value?.contains(Me);Be||et||y()},le=te(null),ve=()=>{const oe=o.value,Me=document.activeElement;if(oe&&Me instanceof HTMLElement&&oe.contains(Me)){le.value=Me;return}le.value=oe?.matches?.(Lp)?oe:oe?.querySelector(Lp)},he=()=>{const oe=le.value;if(oe instanceof HTMLElement&&document.contains(oe)){oe.focus();return}const Me=o.value;if(!Me)return;const Be=Me.matches?.(Lp)?Me:Me.querySelector(Lp);if(Be instanceof HTMLElement){Be.focus();return}Me.setAttribute("tabindex","-1"),Me.focus()},_e=oe=>{if(!u.value)return;const{key:Me}=oe;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(Me)){if(Me==="Escape"){oe.preventDefault(),y(),St(()=>{requestAnimationFrame(he)});return}if(!c.value){if(oe.preventDefault(),Me==="ArrowDown"){X(1),N();return}if(Me==="ArrowUp"){X(-1),N();return}Me==="Enter"&&ee()}}};return Lt(u,async oe=>{if(!oe){l.value=-1,a.value=[];return}ve(),await St(),k(),!c.value&&(l.value=M(),await St(),N())},{immediate:!0}),Lt(u,oe=>{oe?(document.addEventListener("pointerdown",Oe,!0),document.addEventListener("keydown",_e,!0),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0)):(document.removeEventListener("pointerdown",Oe,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0))},{immediate:!0}),Zn(()=>{document.removeEventListener("pointerdown",Oe,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}),(oe,Me)=>(me(),Ae("div",AB,[De("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:w},[qu(oe.$slots,"trigger",{},void 0,!0)],512),(me(),Zt(ba,{to:"body"},[zt(ph,{name:"fade-in-scale-up-transition"},{default:ho(()=>[u.value?(me(),Ae("div",Gi({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:m.value,style:g.value},p.value),[(me(!0),Ae(Ut,null,Qn(e.options,(Be,et)=>(me(),Ae("div",Gi({key:Be.key,ref_for:!0,ref:rt=>A(rt,et),class:["toolbar-dropdown-option",[Be.class,Be.props?.class,{"sd-disabled":Be.disabled,"sd-render":R(Be)}]],tabindex:"-1",onClick:rt=>x(Be)},{ref_for:!0},{...Be.props,...C(Be)}),[R(Be)?(me(),Zt(Ye(se),{key:0,option:Be},null,8,["option"])):(me(),Ae(Ut,{key:1},[H(Be)?(me(),Ae("span",EB,[zt(Ye(de),{option:Be},null,8,["option"])])):ct("",!0),De("span",xB,Ft(Be.label),1)],64))],16,IB))),128))],16)):ct("",!0)]),_:1})]))]))}},RB=Jt(TB,[["__scopeId","data-v-fef410f7"]]),ok=e=>String(e??"").trim().toLowerCase();const Dp=(e,t)=>{const n=ok(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(ok(t[r]).startsWith(n))return r;return-1},MB=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=Dp(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}};var LB=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},DB=e=>e<=31||e===127,PB=e=>e===32||e===160||e===65279,FB=e=>Array.from(String(e)).filter(t=>!DB(t.charCodeAt(0))).join(""),OB=e=>{let t="",n=!1;for(const r of String(e)){if(PB(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t};const BB=e=>OB(LB(FB(String(e??"").split(",")[0]??""))).trim();var NB=1,zB=1638;const HB=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<NB?"":String(Math.min(r,zB))};It(),nn();var UB=["data-item"],VB=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],jB=["data-item","aria-label","disabled"],GB=["innerHTML"],WB=["id","aria-label"],KB=["id","aria-selected","aria-label","onMousedown","onMouseenter"],qB={class:"toolbar-dropdown-option__label"},YB={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},XB={__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}=wi(),i=te(null),s=te(null),a=te(null),l=te([]),u=te(!1),c=te(!1),d=te(-1),p=te(""),m=te(""),h=te(!1),g=te({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),b=Ie(()=>n.item.nestedOptions?.value??[]),y=Ie(()=>b.value.map(q=>String(q?.label??""))),k=Ie(()=>String(n.item.label?.value??"")),w=Ie(()=>!!n.item.disabled?.value),C=Ie(()=>String(n.item.name?.value??"")),x=Ie(()=>n.item.attributes?.value?.ariaLabel??"Font family"),R=Ie(()=>u.value?m.value:k.value),L=Ie(()=>`sd-${C.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),H=q=>`${L.value}-option-${q}`,B=Ie(()=>c.value&&d.value>=0?H(d.value):void 0),z=Ie(()=>c.value?Gn.dropdownCaretUp:Gn.dropdownCaretDown),Y=q=>{const G=String(q??"").trim().toLowerCase();return b.value.find(pe=>String(pe?.label??"").trim().toLowerCase()===G)?.props?.style?.fontFamily||q||n.uiFontFamily},F=Ie(()=>n.showPreview?{fontFamily:Y(u.value?m.value:k.value)}:{fontFamily:n.uiFontFamily}),M=()=>{const q=n.item.selectedValue?.value;if(q){const G=b.value.findIndex(pe=>pe?.key===q);if(G>=0)return G}return y.value.findIndex(G=>G.toLowerCase()===k.value.toLowerCase())},A=(q,G)=>{const pe=i.value;if(!(!pe||typeof pe.setSelectionRange!="function"))try{pe.setSelectionRange(q,G)}catch{}},N=()=>{l.value[d.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},X=()=>{l.value[d.value]?.focus?.()},ee=()=>{const q=s.value;if(!q)return;const G=q.getBoundingClientRect(),pe=a.value,Se=pe?.scrollHeight??pe?.offsetHeight??0,ye=window.innerHeight||document.documentElement.clientHeight||0,He=window.innerWidth||document.documentElement.clientWidth||0,ot=8,tt=4,pt=G.bottom+tt,jt=G.top-tt,_t=Math.max(0,ye-pt-ot),Rt=Math.max(0,jt-ot),xt=_t<Se&&Rt>_t,$t=xt?Rt:_t,Tn=Se?Math.min(Se,$t):$t,Mt=xt?Math.max(ot,jt-Tn):pt,qe=Math.min(Math.max(ot,G.left),Math.max(ot,He-G.width-ot));g.value={top:`${Mt}px`,left:`${qe}px`,minWidth:`${G.width}px`,maxHeight:`${$t}px`}},se=Ie(()=>({position:"fixed",top:g.value.top,left:g.value.left,minWidth:g.value.minWidth,maxHeight:g.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),de=q=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=q)},Oe=(q,{focusInput:G=!1,focusOption:pe=!1}={})=>{if(w.value||!b.value.length){de(!1);return}c.value=!0,de(!0),d.value=q??-1,G&&(u.value=!0,m.value=k.value,i.value?.focus()),St(()=>{ee(),N(),pe&&X()})},le=({syncItem:q=!0}={})=>{c.value=!1,d.value=-1,q&&de(!1)},ve=()=>{le(),u.value=!1,p.value="",m.value=k.value},he=()=>{w.value||(c.value||r("item-clicked"),u.value=!0,p.value="",m.value=k.value,St(()=>A(0,m.value.length)))},_e=q=>{if(w.value)return;const G=document.activeElement===i.value;if(r("item-clicked"),u.value=!0,G||(p.value="",m.value=k.value,q.preventDefault(),i.value?.focus(),A(0,k.value.length)),!c.value){const pe=M();Oe(pe>=0?pe:0)}},oe=q=>{const G=q.relatedTarget;G instanceof Node&&s.value?.contains(G)||G instanceof Node&&a.value?.contains(G)||ve()},Me=q=>{if(h.value)return;const G=q.target,pe=G.value,Se=typeof G.selectionStart=="number"?G.selectionStart:pe.length,ye=typeof G.selectionEnd=="number"?G.selectionEnd:Se,He=typeof q.inputType=="string"&&q.inputType.startsWith("delete"),ot=Se===pe.length&&ye===pe.length;p.value=pe;const tt=MB(pe,y.value,{autocomplete:!He&&ot});m.value=tt.display,G.value=tt.display,tt.display===pe&&!ot?A(Se,ye):A(tt.selectionStart,tt.selectionEnd),c.value&&(d.value=tt.matchIndex,St(N))},Be=q=>{h.value=!1,Me(q)},et=q=>{if(!b.value.length)return;const G=b.value.length;d.value=((d.value<0?q>0?-1:0:d.value)+q+G)%G,St(N)},rt=(q,G)=>{r("item-clicked"),r("command",{item:n.item,argument:q,option:G}),G&&(n.item.selectedValue.value=G.key)},Ee=q=>{q&&(rt(q.label,q),u.value=!1,p.value="",m.value=q.label,le())},Ue=()=>{if(c.value&&d.value>=0)return Ee(b.value[d.value]),!0;const q=Dp(p.value,y.value);if(q>=0)return Ee(b.value[q]),!0;const G=n.normalizeValue(p.value);return G?(rt(G,null),u.value=!1,p.value="",m.value=G,le(),!0):!1},Le=q=>{if(!(q.isComposing||h.value||q.keyCode===229)&&!(q.ctrlKey||q.metaKey||q.altKey))switch(q.key){case"ArrowDown":if(q.preventDefault(),c.value)X();else{const G=Dp(p.value,y.value),pe=G>=0?G:M();Oe(pe>=0?pe:0,{focusOption:!0})}break;case"ArrowUp":if(q.preventDefault(),c.value)X();else{const G=Dp(p.value,y.value),pe=G>=0?G:M();Oe(pe>=0?pe:b.value.length-1,{focusOption:!0})}break;case"Enter":q.preventDefault(),Ue()&&r("editor-handoff"),i.value?.blur();break;case"Tab":q.preventDefault(),Ue(),le(),i.value?.blur(),r("tab-out",q);break;case"Escape":q.preventDefault(),ve(),St(()=>i.value?.focus());break;default:break}},Z=q=>{if(q.preventDefault(),!w.value)if(r("item-clicked"),c.value)le(),i.value?.focus();else{const G=M();Oe(G>=0?G:0,{focusOption:!0})}},_=(q,G)=>{q.preventDefault(),Ee(G),r("editor-handoff"),i.value?.blur()},ne=q=>{d.value=q},O=q=>{if(!(q.ctrlKey||q.metaKey||q.altKey))switch(q.key){case"ArrowDown":q.preventDefault(),et(1),X();break;case"ArrowUp":q.preventDefault(),et(-1),X();break;case"Enter":q.preventDefault(),d.value>=0&&(Ee(b.value[d.value]),r("editor-handoff"));break;case"Escape":q.preventDefault(),ve(),St(()=>i.value?.focus());break;case"Tab":q.preventDefault(),d.value>=0?Ee(b.value[d.value]):le(),r("tab-out",{shiftKey:q.shiftKey,target:i.value});break;default:break}},V=q=>{if(!c.value)return;const G=q.target;G instanceof Element&&(s.value?.contains(G)||a.value?.contains(G)||ve())};Lt(c,q=>{q?(document.addEventListener("pointerdown",V,!0),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0)):(document.removeEventListener("pointerdown",V,!0),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0),l.value=[])},{immediate:!0}),Zn(()=>{document.removeEventListener("pointerdown",V,!0),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)});const U=(q,G)=>{if(!q){delete l.value[G];return}l.value[G]=q},j=q=>q===d.value,Q=q=>q?.key&&q.key===n.item.selectedValue?.value;return Lt(k,q=>{u.value||(m.value=q)}),Lt(()=>!!n.item.expand?.value,q=>{if(q&&!c.value){const G=M();Oe(G>=0?G:0,{focusInput:!0});return}!q&&c.value&&le({syncItem:!1})}),(q,G)=>(me(),Ae("div",{ref_key:"rootRef",ref:s,class:qt(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":w.value,"high-contrast":Ye(o)}]),style:an(n.item.style?.value),"data-item":`btn-${C.value}`},[De("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:_e},[De("input",{ref_key:"inputRef",ref:i,id:`inlineTextInput-${C.value}`,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:R.value,style:an(F.value),disabled:w.value,"aria-label":x.value,"aria-expanded":c.value?"true":"false","aria-controls":L.value,"aria-activedescendant":B.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${C.value}-input`,onFocus:he,onBlur:oe,onInput:Me,onKeydown:Le,onCompositionstart:G[0]||(G[0]=pe=>h.value=!0),onCompositionend:Be},null,44,VB)],32),De("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":`btn-${C.value}-toggle`,tabindex:"-1","aria-label":`${x.value} options`,disabled:w.value,onMousedown:Z},[De("span",{class:"sd-dropdown-caret",innerHTML:z.value},null,8,GB)],40,jB),(me(),Zt(ba,{to:"body"},[c.value?(me(),Ae("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:L.value,"aria-label":x.value,class:qt(["sd-font-combobox__listbox",{"high-contrast":Ye(o)}]),style:an(se.value)},[(me(!0),Ae(Ut,null,Qn(b.value,(pe,Se)=>(me(),Ae("div",Gi({key:pe.key,ref_for:!0,ref:ye=>U(ye,Se),id:H(Se),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":j(Se),"sd-selected":Q(pe)}],"aria-selected":Q(pe)?"true":"false","aria-label":`${x.value} - ${pe.label}`},{ref_for:!0},pe.props,{onMousedown:ye=>_(ye,pe),onMouseenter:ye=>ne(Se),onKeydown:O}),[De("span",qB,Ft(pe.label),1)],16,KB))),128))],14,WB)):ct("",!0)])),De("span",YB,Ft(k.value),1)],14,UB))}},ik=Jt(XB,[["__scopeId","data-v-c08c573e"]]);It();var QB={__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)=>(me(),Zt(ik,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":Ye(BB),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"]))}},ZB=QB;It();var JB={__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)=>(me(),Zt(ik,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":Ye(HB),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"]))}},$B=JB;It(),nn();var eN=2500,tN=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=Y2(),r=te(!1),o=te(null),i=te(null),s=te({top:"0px",left:"0px"});let a=null,l=null,u=null;const c=Ie(()=>["sd-tooltip-content",n.class]),d=Ie(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),p=()=>{a&&(window.clearTimeout(a),a=null)},m=()=>{l&&(window.clearTimeout(l),l=null)},h=()=>{u&&(window.clearTimeout(u),u=null)},g=()=>{h(),u=window.setTimeout(()=>{u=null,k()},eN)},b=()=>{if(!o.value||!i.value)return;const z=o.value.getBoundingClientRect(),Y=i.value.offsetWidth,F=i.value.offsetHeight,M=window.innerWidth||document.documentElement.clientWidth||0,A=8;let N=z.left+z.width/2-Y/2;N=Math.max(A,Math.min(N,M-Y-A)),s.value={top:`${z.top-F-10}px`,left:`${N}px`}},y=async()=>{t.disabled||(p(),m(),!r.value&&(r.value=!0,g(),await St(),b()))},k=()=>{m(),p(),h(),r.value&&(r.value=!1)},w=()=>{if(p(),m(),!r.value){if(t.delay===0){y();return}l=window.setTimeout(()=>{l=null,y()},t.delay)}},C=()=>{if(m(),p(),!!r.value){if(t.duration===0){k();return}a=window.setTimeout(()=>{a=null,k()},t.duration)}},x=()=>{t.trigger==="hover"&&w()},R=()=>{t.trigger==="hover"&&C()},L=()=>{m(),p()},H=()=>{C()},B=z=>{z.key==="Escape"&&k()};return Lt(()=>t.disabled,z=>{z&&k()}),Lt(r,z=>{z?(window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),document.addEventListener("keydown",B,!0)):(window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),document.removeEventListener("keydown",B,!0))}),Zn(()=>{m(),p(),h(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),document.removeEventListener("keydown",B,!0)}),(z,Y)=>(me(),Ae(Ut,null,[De("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:x,onMouseleave:R,onFocusin:x,onFocusout:R},[qu(z.$slots,"trigger",{},void 0,!0)],544),(me(),Zt(ba,{to:"body"},[zt(ph,{name:"fade-in-scale-up-transition"},{default:ho(()=>[r.value&&!e.disabled?(me(),Ae("div",{key:0,ref_key:"contentRef",ref:i,class:qt(c.value),style:an(d.value),onMouseenter:L,onMouseleave:H},[Y[0]||(Y[0]=De("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),qu(z.$slots,"default",{},void 0,!0)],38)):ct("",!0)]),_:3})]))],64))}}),Pp=Jt(tN,[["__scopeId","data-v-2a872eae"]]);It(),nn();var nN=["onKeydown","tabindex","data-item-id"],rN={key:0},oN={key:0},iN={key:0},sN={key:0},aN={key:0},lN={__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}=Jn(),o=te([]),i=te(null),s=e,a=te(null),{isHighContrastMode:l}=wi(),u=window.matchMedia("(max-width: 768px)").matches,c=Ie(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:u?0:1,justifyContent:"center"}),d=Ee=>Ee.type==="button",p=Ee=>Ee.type==="dropdown",m=Ee=>Ee.type==="dropdown"&&Ee.name?.value==="fontFamily",h=Ee=>Ee.type==="dropdown"&&Ee.name?.value==="fontSize",g=Ee=>Ee.type==="separator",b=Ee=>Ee.type==="overflow",y=Ee=>!!Ee.nestedOptions?.value?.length,k=Ee=>{if(!Ee)return!1;const Ue=Ee.expand;return typeof Ue=="object"&&Ue!==null&&"value"in Ue?!!Ue.value:!!Ue},w=(Ee,Ue)=>{Ee?.expand&&(Ee.expand.value=Ue)},C=(Ee,Ue=void 0)=>{if(Ee.disabled.value)return;if(b(Ee)){const Z=!k(Ee);Z&&L(),w(Ee,Z),a.value=Z?Ee:null,n("item-clicked");return}if(p(Ee))return;a.value&&p(a.value)&&k(a.value)&&L(),n("item-clicked");const Le=Ue!==void 0?Ue:Ee.argument?.value;n("command",Le===void 0?{item:Ee}:{item:Ee,argument:Le})},x=(Ee,Ue)=>{Ee.disabled.value||(a.value=null,n("command",{item:Ee,argument:Ue}))},R=Ee=>{if(Ee.disabled.value)return;L();const Ue=Ee.splitButtonCommand,Le=Ee.command,Z=Ue||Le;if(!Z)return;const _={...Ee,command:Z};n("item-clicked"),n("command",{item:_})},L=()=>{const Ee=r?.$toolbar?.toolbarItems||[],Ue=r?.$toolbar?.overflowItems||[],Le=[...Ee,...Ue];(Le.length?Le:s.toolbarItems).forEach(Z=>{const _=b(Z)&&!s.fromOverflow;(p(Z)||_)&&w(Z,!1)}),a.value=null},H=(Ee,Ue)=>{L(),n("command",{item:Ee,argument:Ee.dropdownValueKey.value?Ue[Ee.dropdownValueKey.value]:Ue.label,option:Ue}),Ee.selectedValue.value=Ue.key},B=Ee=>{n("command",Ee)},z=()=>{L(),n("item-clicked")},Y=()=>{const Ee=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Ee instanceof HTMLElement?(Ee.focus({preventScroll:!0}),!0):!1},F=()=>{const Ee=r?.$toolbar?.pendingSelectionCapture,Ue=()=>{Ee&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Ee)};if(Y()){Ue();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),Ue())},M=Ee=>!(Ee instanceof HTMLElement)||Ee.classList.contains("sd-disabled")?null:Ee.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||Ee.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),A=(Ee,Ue)=>{const Le=Ee?.target?.closest?.(".sd-toolbar-item-ctn");if(!(Le instanceof HTMLElement))return!1;let Z=Ue>0?Le.nextElementSibling:Le.previousElementSibling;for(;Z;){const _=M(Z);if(_ instanceof HTMLElement)return Le.setAttribute("tabindex","-1"),Z.setAttribute("tabindex","0"),_.focus(),!0;Z=Ue>0?Z.nextElementSibling:Z.previousElementSibling}return!1},N=Ee=>{L(),A(Ee,Ee?.shiftKey?-1:1)||F()},X=Ee=>{if(L(),Ee?.shiftKey){A(Ee,-1)||F();return}F()},ee=()=>{F()},se=Ee=>Ee.nestedOptions?.value?.length?Ee.nestedOptions.value.map(Ue=>{const Le=Ue?.type!=="render"&&Ee.selectedValue.value===Ue.key;return{...Ue,props:{...Ue.props,class:Le?"sd-selected":""}}}):[],de=(Ee,Ue)=>({role:"menuitem",ariaLabel:`${Ue.attributes.value.ariaLabel} - ${Ee.label}`}),Oe=Ee=>{const Ue=Ee.target,Le=Ee.target.closest(".sd-toolbar-item-ctn").nextElementSibling;Le&&(Ue.setAttribute("tabindex","-1"),Le.setAttribute("tabindex","0"),Le.focus())},le=Ee=>{const Ue=Ee.target,Le=Ee.target.closest(".sd-toolbar-item-ctn").previousElementSibling;Le&&(Ue.setAttribute("tabindex","-1"),Le.setAttribute("tabindex","0"),Le.focus())},ve=Ee=>{const Ue=Ee.target.closest(".button-group").nextElementSibling;if(Ue)Ue.setAttribute("tabindex","0"),Ue.focus();else{const Le=document.querySelector(".ProseMirror");Le&&Le.focus()}},he=Ee=>{const Ue=Ee.target.closest(".button-group").previousElementSibling;Ue&&(Ue.setAttribute("tabindex","0"),Ue.focus())},_e=Ee=>{if(!Ee.disabled.value){if(p(Ee)){Be(!k(Ee),Ee);return}C(Ee)}},oe=(Ee,Ue)=>{const Le=Ee.target.nodeName==="INPUT"||Ee.target.nodeName==="TEXTAREA",Z=Ue.name.value==="fontSize"||Ue.name.value==="fontFamily";if(!(Le&&Z)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(Ee.key))switch(Ee.preventDefault(),Ee.key){case"Enter":case" ":case"Spacebar":_e(Ue);break;case"Escape":L();break;case"ArrowRight":L(),Oe(Ee);break;case"ArrowLeft":L(),le(Ee);break;case"Tab":Ee.shiftKey?he(Ee):ve(Ee);break;default:break}},Me=Ee=>{const Ue=o.value.find(Le=>!Le.classList.contains("sd-disabled"));Ue&&(Ue.setAttribute("tabindex","0"),Ue.focus())},Be=(Ee,Ue)=>{if(n("item-clicked"),!Ee){L(),n("dropdown-update-show",!1);return}L(),a.value=Ue,w(Ue,!0),n("dropdown-update-show",!0)},et=Ee=>{if(!a.value)return;const Ue=Ee.target;Ue instanceof Element&&(Ue.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(Ue)||L())};return Lt(()=>k(a.value),Ee=>{Ee?document.addEventListener("pointerdown",et,!0):document.removeEventListener("pointerdown",et,!0)},{immediate:!0}),Zn(()=>{document.removeEventListener("pointerdown",et,!0)}),(Ee,Ue)=>(me(),Ae("div",{style:an(c.value),class:"button-group",role:"group",onFocus:Me,ref_key:"buttonGroupRef",ref:i},[(me(!0),Ae(Ut,null,Qn(e.toolbarItems,(Le,Z)=>(me(),Ae("div",{key:Le.id.value,class:qt([{narrow:Le.isNarrow.value,wide:Le.isWide.value,"sd-disabled":Le.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:_=>oe(_,Le),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:Z===0?0:-1,"data-item-id":Le.id.value},[g(Le)?(me(),Zt(bB,{key:0,style:{width:"20px"}})):ct("",!0),m(Le)&&y(Le)?(me(),Zt(Pp,{key:1,trigger:"hover",disabled:!Le.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[zt(ZB,{item:Le,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:B,onItemClicked:z,onTabOut:Ue[0]||(Ue[0]=_=>N(_)),onEditorHandoff:ee},null,8,["item","ui-font-family"])]),default:ho(()=>[De("div",null,[gi(Ft(Le.tooltip)+" ",1),Le.disabled.value?(me(),Ae("span",rN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])):h(Le)&&y(Le)?(me(),Zt(Pp,{key:2,trigger:"hover",disabled:!Le.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[zt($B,{item:Le,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:B,onItemClicked:z,onTabOut:Ue[1]||(Ue[1]=_=>X(_)),onEditorHandoff:ee},null,8,["item","ui-font-family"])]),default:ho(()=>[De("div",null,[gi(Ft(Le.tooltip)+" ",1),Le.disabled.value?(me(),Ae("span",oN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])):p(Le)&&Le.nestedOptions?.value?.length?(me(),Zt(RB,{key:3,options:se(Le),disabled:Le.disabled.value,show:k(Le),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(_,ne)=>H(Le,ne),"onUpdate:show":_=>Be(_,Le),style:an(Le.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Ye(l)}]}),"node-props":_=>de(_,Le)},{trigger:ho(()=>[zt(Pp,{trigger:"hover",disabled:!Le.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[zt(d0,{"toolbar-item":Le,disabled:Le.disabled.value,"allow-enter-propagation":!0,onTextSubmit:_=>x(Le,_),onMainClick:_=>R(Le)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:ho(()=>[De("div",null,[gi(Ft(Le.tooltip)+" ",1),Le.disabled.value?(me(),Ae("span",iN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(Le)?(me(),Zt(Pp,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[zt(d0,{"toolbar-item":Le,"is-overflow-item":e.fromOverflow,onTextSubmit:_=>x(Le,_),onButtonClick:_=>C(Le)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:ho(()=>[Le.tooltip?(me(),Ae("div",sN,[gi(Ft(Le.tooltip)+" ",1),Le.disabled.value?(me(),Ae("span",aN,"(disabled)")):ct("",!0)])):ct("",!0)]),_:2},1032,["content-style"])):ct("",!0),b(Le)&&e.overflowItems.length?(me(),Zt(kB,{key:5,"toolbar-item":Le,onButtonClick:_=>C(Le),"overflow-items":e.overflowItems,onClose:L},null,8,["toolbar-item","onButtonClick","overflow-items"])):ct("",!0)],42,nN))),128))],36))}},Fp=Jt(lN,[["__scopeId","data-v-590293ab"]]),cN=[["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"]];const uN=cN.map(([e,t])=>({label:e,key:e,fontWeight:400,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function dN(e){if(e?.length)return e.map(t=>({label:t.label,key:t.value,fontWeight:400,props:{style:{fontFamily:t.previewFamily||t.label},"data-item":"btn-fontFamily-option"}}))}const fN=[{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"}}],af={sm:768,md:1024,lg:1280,xl:1410},f0={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"},sk={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"},ak=Object.values(sk),qU=[...new Set([...Object.values(f0),...ak])];var hN=new Set(["link"]);const YU=new Set(Object.keys(f0).filter(e=>!hN.has(e)));It(),nn();var pN="Arial, Helvetica, sans-serif",mN={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=Jn();let r=te(1);const o=te(0),i=te(!1);let s=null,a=null;const l=Ie(()=>{const H=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof H=="string"&&H.trim()?H.trim():pN}),u=n.$toolbar.config?.toolbarGroups?.includes("left"),c=n.$toolbar.config?.toolbarGroups?.includes("right"),d=n.$toolbar.config?.toolbarButtonsExclude||[],p=H=>(o.value,n.$toolbar.getToolbarItemByGroup(H).filter(B=>!d.includes(B.name.value))),m=()=>{i.value=n.$toolbar.getAvailableWidth()<=af.lg},g=tB(async()=>{await n.$toolbar.onToolbarResize(),m(),r.value+=1},300),b=()=>{r.value+=1},y=()=>{o.value+=1};function k(){window.removeEventListener("resize",g),n.$toolbar.off?.("toolbar-items-changed",b),n.$toolbar.off?.("toolbar-state-change",y),s?.disconnect(),s=null}function w(){k(),window.addEventListener("resize",g),n.$toolbar.on?.("toolbar-items-changed",b),n.$toolbar.on?.("toolbar-state-change",y),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(s=new ResizeObserver(()=>{g()}),s.observe(n.$toolbar.toolbarContainer)),m()}In(w),Pm(w),Fm(k),Zn(k);const C=()=>{if(!n.$toolbar.activeEditor){a=null,n.$toolbar.pendingSelectionCapture=null;return}a=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=a},x=({item:H,argument:B,option:z})=>{R(),n.$toolbar.emitCommand({item:H,argument:B,option:z})},R=()=>{const H=n.$toolbar.activeEditor;if(!H)return;const B=n.$toolbar.pendingSelectionCapture??a;if(B&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(B);return}H.commands?.restoreSelection?.()},L=H=>{C(),!H.target.closest('input, textarea, [contenteditable="true"]')&&H.preventDefault()};return(H,B)=>(me(),Ae("div",{class:"superdoc-toolbar",key:Ye(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:L},[Ye(u)?(me(),Zt(Fp,{key:0,tabindex:"0","toolbar-items":p("left"),"overflow-items":Ye(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"left",onCommand:x,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ct("",!0),zt(Fp,{tabindex:"0","toolbar-items":p("center"),"overflow-items":Ye(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"center",onCommand:x},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Ye(c)?(me(),Zt(Fp,{key:1,tabindex:"0","toolbar-items":p("right"),"overflow-items":Ye(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"right",onCommand:x,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ct("",!0)],32))}},gN=Jt(mN,[["__scopeId","data-v-55b5af7a"]]);const vN=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"}}};It();const un=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 label - "+e.name);if(!e.name)throw new Error("Invalid toolbar item name - "+e.name);const t=te(zi()),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),u=te(e.attributes||{}),c=e.disabled||!1,d=te(e.disabled),p=te(!1),m=te(!1),h=te(e.style),g=te(e.isNarrow),b=te(e.isWide),y=te(e.minWidth),k=te(e.suppressActiveHighlight||!1),w=te(e.argument),C=te(null),x=te(null),R=te(e.iconColor),L=te(e.hasCaret),H=te(!!e.splitButton),B=e.splitButtonCommand,z=!!e.restoreEditorFocus,Y=te(e.dropdownStyles),F=te(e.tooltip),M=te(e.tooltipVisible),A=te(e.tooltipTimeout),N=te(e.defaultLabel),X=te(e.label),ee=te(e.hideLabel),se=te(e.inlineTextInputVisible),de=te(e.hasInlineTextInput),Oe=te(e.markName),le=te(e.labelAttr),ve=te(e.selectedValue),he=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);oe.value?.push(...e.options)}const Me=(_={},...ne)=>{Ee(_,...ne),!k.value&&(p.value=!0)},Be=()=>{Ue(),p.value=!1},et=_=>{d.value=_},rt=()=>{d.value=c},Ee=e.onActivate||(()=>null),Ue=e.onDeactivate||(()=>null),Le=()=>{const _={};return Object.keys(Z).forEach(ne=>{Z[ne].value!==void 0&&(_[ne]=Z[ne].value)}),_},Z={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:F,group:a,attributes:u,disabled:d,active:p,expand:m,nestedOptions:oe,style:h,isNarrow:g,isWide:b,minWidth:y,argument:w,parentItem:x,iconColor:R,hasCaret:L,splitButton:H,splitButtonCommand:B,dropdownStyles:Y,tooltipVisible:M,tooltipTimeout:A,defaultLabel:N,label:X,hideLabel:ee,inlineTextInputVisible:se,hasInlineTextInput:de,restoreEditorFocus:z,markName:Oe,labelAttr:le,childItem:C,allowWithoutEditor:l,dropdownValueKey:he,selectedValue:ve,inputRef:_e};return{...Z,unref:Le,activate:Me,deactivate:Be,setDisabled:et,resetDisabled:rt,onActivate:Ee,onDeactivate:Ue}};It(),nn();var yN=["onClick","innerHTML","aria-label","onKeydown"],bN={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=wi(),r=t,o=te([]),i=[{key:"left",ariaLabel:"Align left",icon:Gn.alignLeft},{key:"center",ariaLabel:"Align center",icon:Gn.alignCenter},{key:"right",ariaLabel:"Align right",icon:Gn.alignRight},{key:"justify",ariaLabel:"Justify",icon:Gn.alignJustify}],s=c=>{r("select",c)},a=c=>{if(c===o.value.length-1)return;const d=o.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=o.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowLeft":l(d);break;case"ArrowRight":a(d);break;case"Enter":s(i[d].key);break;default:break}};return In(()=>{const c=o.value[0];c&&(c.setAttribute("tabindex","0"),c.focus())}),(c,d)=>(me(),Ae("div",{class:qt(["alignment-buttons",{"high-contrast":Ye(n)}])},[(me(),Ae(Ut,null,Qn(i,(p,m)=>De("div",{key:p.key,class:"sd-button-icon",onClick:h=>s(p.key),innerHTML:p.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":p.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:o,onKeydown:Gt(h=>u(h,m),["prevent"])},null,40,yN)),64))],2))}},wN=Jt(bN,[["__scopeId","data-v-13e5f7a4"]]);It(),nn();var CN=["onClick","innerHTML","aria-label","onKeydown"],_N={__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}=wi(),r=t,o=e,i=te([]),s=Ie(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=d=>{r("select",d)},l=d=>{if(d===i.value.length-1)return;const p=i.value[d+1];p&&(p.setAttribute("tabindex","0"),p.focus())},u=d=>{if(d===0)return;const p=i.value[d-1];p&&(p.setAttribute("tabindex","0"),p.focus())},c=(d,p)=>{switch(d.key){case"ArrowLeft":u(p);break;case"ArrowRight":l(p);break;case"Enter":a(o.buttons[p].key);break;default:break}};return In(()=>{const d=i.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,p)=>(me(),Ae("div",{class:qt(["style-buttons-list",{"high-contrast":Ye(n)}])},[(me(!0),Ae(Ut,null,Qn(o.buttons,(m,h)=>(me(),Ae("div",{key:m.key,class:qt(["sd-button-icon",{"sd-selected":o.selectedStyle===m.key}]),style:an(s.value),onClick:g=>a(m.key),innerHTML:m.icon,role:"menuitem","aria-label":m.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:Gt(g=>c(g,h),["prevent"])},null,46,CN))),128))],2))}},lk=Jt(_N,[["__scopeId","data-v-44f37ff6"]]);const SN=[{key:"disc",icon:Gn.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:Gn.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:Gn.bulletListSquare,ariaLabel:"Opaque square"}],kN=[{key:"decimal",icon:Gn.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:Gn.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:Gn.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:Gn.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:Gn.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:Gn.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:Gn.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:Gn.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];It(),nn();var AN=["onClick","onKeydown"],IN={class:"document-mode-column icon-column"},EN=["innerHTML"],xN={class:"document-mode-column text-column"},TN={class:"document-mode-type"},RN={class:"document-mode-description"},MN={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=te([]),{isHighContrastMode:o}=wi(),i=e,s=c=>{n("select",c)},a=c=>{if(c===r.value.length-1)return;const d=r.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=r.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowDown":a(d);break;case"ArrowUp":l(d);break;case"Enter":s(i.options[d]);break;default:break}};return In(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,d)=>(me(),Ae("div",{class:qt(["document-mode",{"high-contrast":Ye(o)}])},[(me(!0),Ae(Ut,null,Qn(e.options,(p,m)=>(me(),Ae("div",{class:qt(["sd-option-item",{"sd-disabled":p.disabled}]),onClick:h=>s(p),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:Gt(h=>u(h,m),["prevent"])},[De("div",IN,[De("div",{class:"icon-column__icon",innerHTML:p.icon},null,8,EN)]),De("div",xN,[De("div",TN,Ft(p.label),1),De("div",RN,Ft(p.description),1)])],42,AN))),256))],2))}},LN=Jt(MN,[["__scopeId","data-v-bee14d7a"]]);It(),nn();var DN={class:"linked-style-buttons","data-editor-ui-surface":""},PN=["onClick","onKeydown","aria-label"],FN={__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=d=>{n("select",d)},s=d=>{if(d===r.value.length-1)return;const p=r.value[d+1];p.setAttribute("tabindex","0"),p.focus()},a=d=>{if(d===0)return;const p=r.value[d-1];p.setAttribute("tabindex","0"),p.focus()},l=(d,p,m)=>{switch(d.key){case"ArrowDown":s(p);break;case"ArrowUp":a(p);break;case"Enter":d.preventDefault(),i(m);break;default:break}},u=d=>d?.name??d?.id??"",c=d=>{const p=d?.preview?.css;return p&&typeof p=="object"?p:void 0};return In(()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())}),(d,p)=>(me(),Ae("div",DN,[(me(!0),Ae(Ut,null,Qn(o.styles,(m,h)=>(me(),Ae("div",{key:m.id??h,class:qt(["style-item",{selected:e.selectedOption===m.id}]),onClick:g=>i(m),onKeydown:g=>l(g,h,m),"aria-label":`Linked style - ${m.id??u(m)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[De("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:an(c(m))},Ft(u(m)),5)],42,PN))),128))]))}},ON=Jt(FN,[["__scopeId","data-v-43b5dcca"]]);It(),nn();var BN=["placeholder"],NN={class:"sd-ai-writer__footer"},zN={key:0,class:"sd-ai-writer__error",role:"alert"},HN=["disabled"],UN="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",VN="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",jN={__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=Ie(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=Ie(()=>n.value.trim().length>0&&!r.value);In(()=>{St(()=>{i.value?.focus()})});function l(h){if(typeof h=="string")return h;if(!h||typeof h!="object")return"";const g=h.custom_prompt;if(Array.isArray(g)){const b=g[0];if(b&&typeof b.value=="string")return b.value}return g&&typeof g=="object"&&typeof g.value=="string"?g.value:typeof h.value=="string"?h.value:typeof h.text=="string"?h.text:""}async function u(h){const g={"Content-Type":"application/json"};t.apiKey&&(g["x-api-key"]=t.apiKey);const b=t.selectedText.trim(),y=b?`Rewrite the following text: "${b}" using these instructions: ${h}`:`Generate text based on the following prompt: ${h}`,k=await fetch(t.endpoint||UN,{method:"POST",headers:g,body:JSON.stringify({stream:!1,context:VN,insights:[{type:"custom_prompt",name:b?"text_rewrite":"text_generation",message:y,format:[{value:""}]}]})});if(!k.ok){const C=await k.text().catch(()=>"");throw new Error(C||`AI request failed with ${k.status}`)}const w=l((k.headers.get("content-type")||"").includes("application/json")?await k.json():await k.text()).trim();if(!w)throw new Error("AI returned no text.");return w}function c(h){return!h||typeof h!="object"?!0:!(h.success===!1||h.ok===!1)}function d(h){const g=t.doc;if(!g)throw new Error("Document API is unavailable.");t.restoreSelection?.();let b=null,y=!1;if(t.selectedText&&t.target&&typeof g.replace=="function"?(b=g.replace({target:t.target,text:h}),y=!0):t.target&&typeof g.insert=="function"?(b=g.insert({target:t.target,value:h,type:"text"}),y=!0):typeof g.insert=="function"&&(b=g.insert({value:h,type:"text"}),y=!0),!y)throw new Error("Document text insertion is unavailable.");if(!c(b))throw new Error("Unable to insert generated text.")}async function p(){if(a.value){o.value="",r.value=!0;try{d(await u(n.value.trim())),t.handleClose()}catch(h){o.value=h instanceof Error?h.message:String(h)}finally{r.value=!1}}}function m(h){h.key!=="Enter"||h.shiftKey||(h.preventDefault(),p())}return(h,g)=>(me(),Ae("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:Gt(p,["prevent"])},[xs(De("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":g[0]||(g[0]=b=>n.value=b),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:m},null,40,BN),[[oi,n.value]]),De("div",NN,[o.value?(me(),Ae("p",zN,Ft(o.value),1)):ct("",!0),De("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},Ft(r.value?"Generating":"Generate"),9,HN)])],32))}},GN=Jt(jN,[["__scopeId","data-v-67f6c6f7"]]);It(),nn();var WN=["aria-label","onClick","onKeydown"],KN=["innerHTML"],qN=["innerHTML"],Op=7,YN={__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=Ie(()=>h=>r.activeColor.value?r.activeColor.value.toUpperCase()===h.value:!1),i=(h,g)=>g===5||["#FFFFFF","#FAFF09"].includes(h)?{color:"#000"}:{color:"#FFF"},s=h=>{n("select",h.value)},a=te([]),l=te([]);In(()=>{if(!r.icons.every(g=>Array.isArray(g)))throw new Error("icon props must be 2d array");const h=l.value[0];h&&(h.setAttribute("tabindex","0"),h.focus())});const u=(h,g)=>{const b=Op*h+g+1,y=l.value[b];y&&(y.setAttribute("tabindex","0"),y.focus())},c=(h,g)=>{const b=Op*h+g-1,y=l.value[b];y&&(y.setAttribute("tabindex","0"),y.focus())},d=(h,g)=>{const b=g+Op*(h+1),y=l.value[b];y&&(y.setAttribute("tabindex","0"),y.focus())},p=(h,g)=>{const b=g+Op*(h-1),y=l.value[b];y&&(y.setAttribute("tabindex","0"),y.focus())},m=(h,g,b,y)=>{switch(h.key){case"ArrowRight":u(g,b);break;case"ArrowLeft":c(g,b);break;case"ArrowDown":d(g,b);break;case"ArrowUp":p(g,b);break;case"Enter":s(y);break;case"Escape":n("clickoutside");break;default:break}};return(h,g)=>(me(!0),Ae(Ut,null,Qn(e.icons,(b,y)=>(me(),Ae("div",{class:"sd-option-row",key:y,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(me(!0),Ae(Ut,null,Qn(b,(k,w)=>(me(),Ae("div",{class:"sd-option",key:w,"aria-label":k.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:Gt(C=>s(k),["stop","prevent"]),onKeydown:Gt(C=>m(C,y,w,k),["prevent"])},[De("div",{class:"sd-option__icon",innerHTML:k.icon,style:an(k.style)},null,12,KN),o.value(k)?(me(),Ae("div",{key:0,class:"sd-option__check",innerHTML:Ye(Gn).colorOptionCheck,style:an(i(k.value,w))},null,12,qN)):ct("",!0)],40,WN))),128))]))),128))}},ck=Jt(YN,[["__scopeId","data-v-5f3db0a9"]]),XN=`<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
  `;It(),nn();var QN={class:"options-grid-wrap"},ZN=["innerHTML"],JN={class:"option-grid-ctn"},$N={__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)=>(me(),Ae("div",QN,[e.hasNoneIcon?(me(),Ae("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[De("span",{innerHTML:Ye(XN),class:"none-icon"},null,8,ZN),i[1]||(i[1]=gi(" None ",-1))])):ct("",!0),De("div",JN,[zt(ck,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(me(),Ae(Ut,{key:0},[i[2]||(i[2]=De("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),zt(ck,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):ct("",!0)])]))}},ez=Jt($N,[["__scopeId","data-v-52b0283a"]]);const uk=e=>{const t=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof t=="function"){t.call(e?.superdoc??e?.activeEditor);return}const n=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');n instanceof HTMLElement&&n.focus({preventScroll:!0})};It();var tz=e=>{e.expand.value=!1};const Ot=(e,t=null)=>({label:t,icon:Gn.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),h0=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),tz(t),uk(e)};return Ar("div",{},[Ar(ez,{icons:nz,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},nz=[[Ot("#111111","black"),Ot("#333333","dark gray"),Ot("#5C5C5C","medium gray"),Ot("#858585","light gray"),Ot("#ADADAD","very light gray"),Ot("#D6D6D6","transparent gray"),Ot("#FFFFFF","white")],[Ot("#860028","dark red"),Ot("#D2003F","red"),Ot("#DB3365","coral red"),Ot("#E4668C","light red"),Ot("#ED99B2","pale pink"),Ot("#F6CCD9","transparent pink"),Ot("#FF004D","bright pink")],[Ot("#83015E","dark purple"),Ot("#CD0194","purple"),Ot("#D734A9","orchid"),Ot("#E167BF","light purple"),Ot("#EB99D4","lavender"),Ot("#F5CCEA","transparent pink"),Ot("#FF00A8","neon pink")],[Ot("#8E220A","maroon"),Ot("#DD340F","red-orange"),Ot("#E45C3F","burnt orange"),Ot("#EB856F","peach"),Ot("#F1AE9F","pale peach"),Ot("#F8D6CF","transparent peach"),Ot("#FF7A00","orange")],[Ot("#947D02","olive"),Ot("#E7C302","mustard yellow"),Ot("#ECCF35","yellow"),Ot("#F1DB67","light yellow"),Ot("#F5E79A","very pale yellow"),Ot("#FAF3CC","transparent yellow"),Ot("#FAFF09","neon yellow")],[Ot("#055432","forest green"),Ot("#07834F","green"),Ot("#399C72","medium green"),Ot("#6AB595","light green"),Ot("#9CCDB9","mint"),Ot("#CDE6DC","transparent mint"),Ot("#05F38F","bright teal")],[Ot("#063E7E","navy blue"),Ot("#0A60C5","blue"),Ot("#3B80D1","sky blue"),Ot("#6CA0DC","cornflower blue"),Ot("#9DBFE8","light blue"),Ot("#CEDFF3","very light blue"),Ot("#21c8ce","cyan")],[Ot("#3E027A","deep purple"),Ot("#6103BF","indigo"),Ot("#8136CC","violet"),Ot("#A068D9","lavender pink"),Ot("#C09AE6","light lilac"),Ot("#DFCDF2","transparent lilac"),Ot("#A91DFF","neon purple")]];It(),nn();var rz=["data-cols","data-rows","onKeydown","onClick"],oz=["aria-valuetext"],Bp=5,iz={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=te(0),o=te(0),{isHighContrastMode:i}=wi(),s=te([]),a=d=>{let p=d.target;p.dataset.grid||l([...p.parentElement.querySelectorAll("[data-item]")],parseInt(p.dataset.cols,10),parseInt(p.dataset.rows,10))},l=(d,p,m)=>{o.value=p,r.value=m;for(let h=0;h<d.length;h++){let g=d[h],b=parseInt(g.dataset.cols,10),y=parseInt(g.dataset.rows,10);b<=p&&y<=m?g.classList.add("sd-selected"):g.classList.remove("sd-selected")}},u=({cols:d,rows:p})=>{n("select",{cols:d,rows:p})},c=(d,p,m)=>{let h=p-1,g=m-1;switch(d.key){case"ArrowRight":{if(h>=4)return;const b=g*Bp;s.value[b+h+1].setAttribute("tabindex","0"),s.value[b+h+1].focus(),l(s.value,p+1,m);break}case"ArrowLeft":{if(h<=0)return;const b=g*Bp;s.value[b+h-1].setAttribute("tabindex","0"),s.value[b+h-1].focus(),l(s.value,p-1,m);break}case"ArrowDown":{if(g>=4)return;const b=(g+1)*Bp;s.value[b+h].setAttribute("tabindex","0"),s.value[b+h].focus(),l(s.value,p,m+1);break}case"ArrowUp":{if(g<=0)return;const b=(g-1)*Bp;s.value[b+h].setAttribute("tabindex","0"),s.value[b+h].focus(),l(s.value,p,m-1);break}case"Enter":u({cols:p,rows:m});break;default:break}};return In(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(d,p)=>(me(),Ae("div",{class:qt(["toolbar-table-grid-wrapper",{"high-contrast":Ye(i)}])},[De("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(me(),Ae(Ut,null,Qn(5,m=>(me(),Ae(Ut,{key:m},[(me(),Ae(Ut,null,Qn(5,h=>De("div",{class:"toolbar-table-grid__item",key:`${m}_${h}`,"data-cols":h,"data-rows":m,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:Gt(g=>c(g,h,m),["prevent"]),onClick:Gt(g=>u({cols:h,rows:m}),["stop","prevent"])},null,40,rz)),64))],64))),64))],32),De("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},Ft(r.value)+" x "+Ft(o.value),9,oz)],2))}},sz=Jt(iz,[["__scopeId","data-v-b87d6ca2"]]);It(),nn();var az={class:"toolbar-table-actions"},lz=["onClick","data-item","ariaLabel"],cz={class:"toolbar-table-actions__icon"},uz=["innerHTML"],dz={class:"toolbar-table-actions__label"},fz={__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)=>(me(),Ae("div",az,[(me(!0),Ae(Ut,null,Qn(e.options,s=>(me(),Ae("div",{class:qt(["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"},[De("div",cz,[De("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,uz)]),De("div",dz,Ft(s.label),1)],10,lz))),256))]))}},hz=Jt(fz,[["__scopeId","data-v-0cdad084"]]),pz=`<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
- `;It();var rs=e=>{e.expand.value=!1};function dk(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 mz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function fk(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function gz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function vz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const yz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=un({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??uN).map(vN),c=un({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:u,onActivate:({fontFamily:qe}={},we=!1)=>{if(we){c.label.value="",c.selectedValue.value="";return}if(!qe)return;qe=qe.split(",")[0],c.label.value=qe;const Ce=u.find(Qe=>Qe.label===c.defaultLabel.value),Pe=u.find(Qe=>Qe.label===qe);Pe?c.selectedValue.value=Pe.key:Ce?c.selectedValue.value=Ce.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const qe=u.find(we=>we.label===c.defaultLabel.value);qe?c.selectedValue.value=qe.key:c.selectedValue.value=""}}),d=un({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:()=>p(d)}]});function p(qe){const we=fk(e),Ce=we?.selectionTarget??dk(we?.target),Pe=we?.empty?"":mz(we),Qe=vz(e),Et=()=>rs(qe),At=()=>{const pn=e.pendingSelectionCapture;pn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(pn)};return Ar("div",{},[Ar(GN,{handleClose:Et,selectedText:Pe,target:Ce,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Qe?.apiKey||e.config?.aiApiKey||"",endpoint:Qe?.endpoint||e.config?.aiEndpoint||"",restoreSelection:At})])}const m=fN,h=un({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:m,onActivate:({fontSize:qe},we=!1)=>{if(we){h.label.value="",h.selectedValue.value="";return}const Ce=m.find(At=>At.label===String(h.defaultLabel.value));if(!qe){h.label.value=h.defaultLabel.value,Ce?h.selectedValue.value=Ce.key:h.selectedValue.value="";return}let Pe=eB(qe,12);Pe<8&&(Pe=8),Pe>96&&(Pe=96);let Qe=String(Pe);const Et=m.find(At=>At.label===Qe||At.key===Qe);Et?h.selectedValue.value=Et.key:h.selectedValue.value="",h.label.value=Qe},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const qe=m.find(we=>we.label===String(h.defaultLabel.value));qe?h.selectedValue.value=qe.key:h.selectedValue.value=""}}),g=un({type:"separator",name:"separator",isNarrow:!0}),b=un({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),y=un({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=un({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),w=un({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:()=>h0(e,w,[],!0)}],onActivate:({color:qe})=>{w.iconColor.value=qe||""},onDeactivate:()=>w.iconColor.value=""}),C=un({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:()=>h0(e,C)}],onActivate:({color:qe})=>{C.iconColor.value=qe},onDeactivate:()=>C.iconColor.value="#000"}),x=un({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=un({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>L(R)}],onActivate:({href:qe})=>{qe?R.attributes.value={href:qe}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function L(qe){const we=fk(e),Ce=we?.selectionTarget??dk(we?.target),Pe=()=>{const Qe=e.pendingSelectionCapture;Qe&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qe)};return Ar("div",{},[Ar(k_,{ui:e.ui,linkItem:qe,textTarget:Ce,restoreSelection:Pe,closePopover:()=>rs(qe),goToAnchor:()=>{rs(qe);const Qe=qe.attributes.value?.href;if(!Qe)return;const Et=Qe.slice(1),At=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Et}']`);At&&Fd(At)}})])}const H=un({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=H,H.parentItem=R;const B=un({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=un({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Y=un({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:()=>F(Y)}]});function F(qe){return Ar("div",{},[Ar(sz,{onSelect:Ce=>{e.emitCommand({item:qe,argument:Ce}),rs(qe),uk(e)}})])}const M=un({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>N(M)}]}),A=[{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 N(qe){return Ar(hz,{options:A,onSelect:we=>{rs(qe);const{command:Ce}=we;e.emitCommand({item:qe,argument:{command:Ce}})}})}const X=un({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:()=>Ar("div",{},[Ar(wN,{onSelect:we=>{rs(X);const Ce={...X,command:"setTextAlign"};Ce.command="setTextAlign",e.emitCommand({item:Ce,argument:we}),ee(X,we)}})]),key:"alignment"}],onActivate:({textAlign:qe})=>{ee(X,qe)},onDeactivate:()=>{ee(X,"left")}}),ee=(qe,we)=>{let Ce=we==="both"?"justify":we,Pe={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Qe=Pe[Ce]??Pe.left;qe.icon.value=Qe},se=un({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=we=>{rs(se);const Ce={...se,command:"toggleBulletListStyle"};e.emitCommand({item:Ce,argument:we})};return Ar(lk,{buttons:SN,iconSize:25,selectedStyle:se.selectedValue.value,onSelect:qe})}}]}),de=un({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=we=>{rs(de);const Ce={...de,command:"toggleOrderedListStyle"};e.emitCommand({item:Ce,argument:we})};return Ar(lk,{buttons:kN,iconSize:30,selectedStyle:de.selectedValue.value,onSelect:qe})}}]}),Oe=un({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),le=un({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ve=un({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),he=un({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&&(he.label.value=qe)}}),_e=un({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=un({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Me=un({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Be=un({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),et=un({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),rt=un({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Ee=un({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Ue=(qe,we)=>qe==="editor"?we:qe==="suggester"?we.filter(Ce=>Ce.value==="suggesting"):we.filter(Ce=>Ce.value==="viewing"),Le=qe=>qe==="editor"?"Editing":qe==="suggester"?"Suggesting":"Viewing",Z=un({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Le(s),label:Le(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(Z)}]}),_=[{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){return Ar(LN,{options:Ue(s,_),onSelect:we=>{rs(qe);const{label:Ce,icon:Pe,value:Qe}=we;Z.label.value=Ce,Z.icon.value=Pe,e.emitCommand({item:Z,argument:Qe})}})}const O=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),V=["search","ruler","undo","overflow","documentMode"],U=un({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),j=un({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),Q=un({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=Ce=>{rs(Q);const Pe=typeof Ce=="string"?Ce:Ce?.id??null;if(!Pe)return;const Qe={...Q,command:"setLinkedStyle"};e.emitCommand({item:Qe,argument:Pe})},we=e.getActiveLinkedStyleId?.()??null;return Ar("div",{},[Ar(ON,{styles:e.getLinkedStyleOptions?.()??[],onSelect:qe,selectedOption:we})])}}],onActivate:({styleId:qe,styleName:we})=>{const Ce=we||qe;Q.label.value=qe&&qe!=="Normal"?String(Ce):n.formatText,Q.disabled.value=!1},onDeactivate:()=>{Q.disabled.value=!0,Q.label.value=n.formatText}}),q=(qe,we)=>{if(we.value==qe)return Ar("div",{innerHTML:pz,class:"dropdown-select-icon"})},G=un({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!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:()=>q(qe,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),pe=20,Se=32,ye=V.reduce((qe,we)=>qe+(O.get(we)||O.get("default")),0),He=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],ot=["zoom","fontFamily","fontSize","redo"],tt=i<=af.lg,pt=e.config?.showFormattingMarksButton===!0,jt=e.config?.showTableOfContentsButton===!0;tt&&(Z.attributes.value={...Z.attributes.value,className:`${Z.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),tt&&(Q.attributes.value={...Q.attributes.value,className:`${Q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let _t=[oe,Me,Be,et,x,he,c,g,h,g,l,b,y,k,C,w,g,R,B,...jt?[z]:[],Y,M,g,X,se,de,Oe,le,G,g,Q,g,U,_e,...pt?[j]:[],Ee,rt,...gz(e)?[d]:[],ve,Z];if(i<=af.md&&o&&(_t=_t.filter(qe=>qe.type!=="separator")),e.config.mode!=="docx"){const qe=_t.findIndex(Ce=>Ce.name.value==="linkedStyles");_t.splice(qe-1,2);const we=["ruler","zoom","undo","redo"];_t=_t.filter(Ce=>!we.includes(Ce.name.value))}const Rt=[];a||(s==="viewer"&&Rt.push(Be,et),_t=_t.filter(qe=>!Rt.includes(qe)));const xt=qe=>V.includes(qe.name.value),$t=[],Tn=[];let Mt=Se+ye;return _t.forEach(qe=>{const we=O.get(qe.name.value)||O.get("default");if(i<af.xl+pe&&He.includes(qe.name.value)&&o){if($t.push(qe),qe.name.value==="linkedStyles"){const Ce=_t.findIndex(Pe=>Pe.name.value==="linkedStyles");_t.splice(Ce+1,1)}return}if(i<af.sm&&ot.includes(qe.name.value)&&o){$t.push(qe);return}if(xt(qe)){Tn.push(qe),Mt+=we;return}Mt<i||!o?(Tn.push(qe),Mt+=we):$t.push(qe)}),{defaultItems:Tn,overflowItems:$t.filter(qe=>qe.type!=="separator")}},hk={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"},bz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;It();function pk(e){return KO(e)??f0[e]??null}function Np(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 wz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Cz=new Set(["list","numberedlist"]);function _z(e,t){if(e==="fontFamily"||e==="fontSize"||Cz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!wz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function mk(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Sz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var kz=class extends Jp.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Gn},texts:{...hk},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=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={...Gn,...e.icons},this.config.texts={...hk,...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._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=bz(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)}if(this.#e(),this.#u(),this.#r(),this.#i(),this._lastFontOptionsSignature=this.#a(),!this.toolbarContainer){this.updateToolbarState();return}this.app=wl(gN),this.app.directive("click-outside",tv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=Dy({superdoc:this.superdoc}),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.#R():this.#S()}))}#o(){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();try{this.ui?.destroy?.()}catch{}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.#a();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}#u(){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}#d(e){return e||dN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=yz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),r=this.config.customButtons||[],o=r.map(a=>this.#f(a));r.length&&t.push(...o);let i=[...t.map(a=>a.name.value),...n.map(a=>a.name.value)];if(this.config.groups){const a=Object.values(this.config.groups).flatMap(c=>c),l=new Set(Object.keys(this.config.groups)),u=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...u])]}const s=t.filter(a=>i.includes(a.name.value)).filter(a=>!this.config.excludeItems.includes(a.name.value));if(this.config.groups)for(const[a,l]of Object.entries(this.config.groups))for(const u of s)l.includes(u.name.value)&&(u.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=un({...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.#r(),this.emit("toolbar-items-changed")}#a(){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.#c().find(t=>t.name.value===e)}#c(){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.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#r(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#C(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){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)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>h0(this,e,[],!0)};e.nestedOptions.value=[t]}#l(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=ak.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(u0(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=pk(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];_z(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.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#l(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.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#V(),this.#c().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#c().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")}#V(){this.#c().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#D(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}#A(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#m(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=sk[t?.command];return i?Np(this.ui,i,void 0,r):!1}if(u0(n)?.disposition==="unsupported")return!0;const o=pk(n);return o?Np(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=$O({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await ZO(e,this.superdoc?.config?.handleImageUpload);Np(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#m(n,"image")})},onError:e=>this.#m(e,"image")})),this.#t.open()),!0}#R(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{mk(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!mk(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Sz(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)}#m(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}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(u0(r)?.disposition==="host-routed"){this.#D(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(!Np(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#m(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#A(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#m(s,r)}}}destroy(){this.#S(),this.#t?.destroy(),this.#t=null,this.#s(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Az(e){return new kz(e)}It();var Iz=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 Ez(e,t){const n=new K5.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function p0(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function gk(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function xz(e,t){if(!e)return()=>{};if(p0(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=()=>{gk(e),s()},l=u=>{u!==!1&&(u===!0||p0(e))&&(gk(e),s())};return n("synced",a),n("sync",l),p0(e)&&s(),i}function ai(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function Tz(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 vk(e){return typeof e=="string"&&e.length>0?e:null}function m0(e){return e?ai(e)?vk(e.documentId??e.options?.documentId??null):vk(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function Rz(e){if(!e||ai(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Ai(e){if(!e)return null;if(ai(e))return e.fonts??null;const t=Rz(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 zp=class extends Jp.default{static{this.allowedTypes=[yr,Cl,bh]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new GO;#f=null;#p=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...c0},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},!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.#d=new FO({getModuleConfig:()=>this.config.modules?.surfaces}),this.#a(e,t)}async#a(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),VO(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.#he(),this.config.user=jO(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=fR(this.config.modules.comments),this.config.colors=eI(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.31",this.#b("πŸ¦‹ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||zi(),this.colors=this.config.colors??[],this.#w(),await ox(),this.#t)return;if(await this.#x(this.config.modules),this.#t){this.#ae();return}this.config.cspNonce&&this.#C(),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.#f||(this.#f=this.#r.subscribe(i=>{this.#me(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.#u=o,this.#E(),this.#g(),this.#ge(),this.#c()}#c(){if(this.#_(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#g(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new lP({Renderer:LO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===yr).length}get state(){return{documents:this.#h("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}#C(){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}}#w(){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:zi(),...s}]}else if(n)this.config.documents=[{id:zi(),type:yr,url:this.config.document,name:"document.docx"}];else if(r){const s=gd(this.config.document);this.config.documents=[{id:zi(),...s}]}else if(o){const s=gd(this.config.document);this.config.documents=[{id:zi(),...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||zi()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=QD({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.#d),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&&G8(this),this.#se()}#l(e,t){t&&this.on(e,t)}#E(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#T(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#x({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:zi(),type:yr,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}#V(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Fr(e),this.provider=Fr(t),this.#P();const n=this.config;this._cleanupAwareness=z8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#D(){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.#o){try{this.#o()}catch{}this.#o=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#T(e){this.#A(),ai(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=oP(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#o=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#S(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#I(!!r.isLocked,this.#m(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)}}#m(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#j(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#I(e,t){this.isLocked===e&&this.#j(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("πŸ¦‹ [superdoc] Locking superdoc:",e,t,`
102
+ `;It();var rs=e=>{e.expand.value=!1};function dk(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 mz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function fk(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function gz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function vz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const yz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=un({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??uN).map(vN),c=un({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:u,onActivate:({fontFamily:qe}={},we=!1)=>{if(we){c.label.value="",c.selectedValue.value="";return}if(!qe)return;qe=qe.split(",")[0],c.label.value=qe;const Ce=u.find(Qe=>Qe.label===c.defaultLabel.value),Pe=u.find(Qe=>Qe.label===qe);Pe?c.selectedValue.value=Pe.key:Ce?c.selectedValue.value=Ce.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const qe=u.find(we=>we.label===c.defaultLabel.value);qe?c.selectedValue.value=qe.key:c.selectedValue.value=""}}),d=un({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:()=>p(d)}]});function p(qe){const we=fk(e),Ce=we?.selectionTarget??dk(we?.target),Pe=we?.empty?"":mz(we),Qe=vz(e),Et=()=>rs(qe),At=()=>{const pn=e.pendingSelectionCapture;pn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(pn)};return Ar("div",{},[Ar(GN,{handleClose:Et,selectedText:Pe,target:Ce,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Qe?.apiKey||e.config?.aiApiKey||"",endpoint:Qe?.endpoint||e.config?.aiEndpoint||"",restoreSelection:At})])}const m=fN,h=un({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:m,onActivate:({fontSize:qe},we=!1)=>{if(we){h.label.value="",h.selectedValue.value="";return}const Ce=m.find(At=>At.label===String(h.defaultLabel.value));if(!qe){h.label.value=h.defaultLabel.value,Ce?h.selectedValue.value=Ce.key:h.selectedValue.value="";return}let Pe=eB(qe,12);Pe<8&&(Pe=8),Pe>96&&(Pe=96);let Qe=String(Pe);const Et=m.find(At=>At.label===Qe||At.key===Qe);Et?h.selectedValue.value=Et.key:h.selectedValue.value="",h.label.value=Qe},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const qe=m.find(we=>we.label===String(h.defaultLabel.value));qe?h.selectedValue.value=qe.key:h.selectedValue.value=""}}),g=un({type:"separator",name:"separator",isNarrow:!0}),b=un({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),y=un({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=un({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),w=un({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:()=>h0(e,w,[],!0)}],onActivate:({color:qe})=>{w.iconColor.value=qe||""},onDeactivate:()=>w.iconColor.value=""}),C=un({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:()=>h0(e,C)}],onActivate:({color:qe})=>{C.iconColor.value=qe},onDeactivate:()=>C.iconColor.value="#000"}),x=un({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=un({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>L(R)}],onActivate:({href:qe})=>{qe?R.attributes.value={href:qe}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function L(qe){const we=fk(e),Ce=we?.selectionTarget??dk(we?.target),Pe=()=>{const Qe=e.pendingSelectionCapture;Qe&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qe)};return Ar("div",{},[Ar(k_,{ui:e.ui,linkItem:qe,textTarget:Ce,restoreSelection:Pe,closePopover:()=>rs(qe),goToAnchor:()=>{rs(qe);const Qe=qe.attributes.value?.href;if(!Qe)return;const Et=Qe.slice(1),At=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Et}']`);At&&Fd(At)}})])}const H=un({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=H,H.parentItem=R;const B=un({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=un({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Y=un({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:()=>F(Y)}]});function F(qe){return Ar("div",{},[Ar(sz,{onSelect:Ce=>{e.emitCommand({item:qe,argument:Ce}),rs(qe),uk(e)}})])}const M=un({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>N(M)}]}),A=[{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 N(qe){return Ar(hz,{options:A,onSelect:we=>{rs(qe);const{command:Ce}=we;e.emitCommand({item:qe,argument:{command:Ce}})}})}const X=un({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:()=>Ar("div",{},[Ar(wN,{onSelect:we=>{rs(X);const Ce={...X,command:"setTextAlign"};Ce.command="setTextAlign",e.emitCommand({item:Ce,argument:we}),ee(X,we)}})]),key:"alignment"}],onActivate:({textAlign:qe})=>{ee(X,qe)},onDeactivate:()=>{ee(X,"left")}}),ee=(qe,we)=>{let Ce=we==="both"?"justify":we,Pe={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Qe=Pe[Ce]??Pe.left;qe.icon.value=Qe},se=un({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=we=>{rs(se);const Ce={...se,command:"toggleBulletListStyle"};e.emitCommand({item:Ce,argument:we})};return Ar(lk,{buttons:SN,iconSize:25,selectedStyle:se.selectedValue.value,onSelect:qe})}}]}),de=un({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=we=>{rs(de);const Ce={...de,command:"toggleOrderedListStyle"};e.emitCommand({item:Ce,argument:we})};return Ar(lk,{buttons:kN,iconSize:30,selectedStyle:de.selectedValue.value,onSelect:qe})}}]}),Oe=un({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),le=un({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ve=un({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),he=un({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&&(he.label.value=qe)}}),_e=un({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=un({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Me=un({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Be=un({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),et=un({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),rt=un({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Ee=un({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Ue=(qe,we)=>qe==="editor"?we:qe==="suggester"?we.filter(Ce=>Ce.value==="suggesting"):we.filter(Ce=>Ce.value==="viewing"),Le=qe=>qe==="editor"?"Editing":qe==="suggester"?"Suggesting":"Viewing",Z=un({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Le(s),label:Le(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(Z)}]}),_=[{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){return Ar(LN,{options:Ue(s,_),onSelect:we=>{rs(qe);const{label:Ce,icon:Pe,value:Qe}=we;Z.label.value=Ce,Z.icon.value=Pe,e.emitCommand({item:Z,argument:Qe})}})}const O=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),V=["search","ruler","undo","overflow","documentMode"],U=un({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),j=un({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),Q=un({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=Ce=>{rs(Q);const Pe=typeof Ce=="string"?Ce:Ce?.id??null;if(!Pe)return;const Qe={...Q,command:"setLinkedStyle"};e.emitCommand({item:Qe,argument:Pe})},we=e.getActiveLinkedStyleId?.()??null;return Ar("div",{},[Ar(ON,{styles:e.getLinkedStyleOptions?.()??[],onSelect:qe,selectedOption:we})])}}],onActivate:({styleId:qe,styleName:we})=>{const Ce=we||qe;Q.label.value=qe&&qe!=="Normal"?String(Ce):n.formatText,Q.disabled.value=!1},onDeactivate:()=>{Q.disabled.value=!0,Q.label.value=n.formatText}}),q=(qe,we)=>{if(we.value==qe)return Ar("div",{innerHTML:pz,class:"dropdown-select-icon"})},G=un({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!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:()=>q(qe,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),pe=20,Se=32,ye=V.reduce((qe,we)=>qe+(O.get(we)||O.get("default")),0),He=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],ot=["zoom","fontFamily","fontSize","redo"],tt=i<=af.lg,pt=e.config?.showFormattingMarksButton===!0,jt=e.config?.showTableOfContentsButton===!0;tt&&(Z.attributes.value={...Z.attributes.value,className:`${Z.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),tt&&(Q.attributes.value={...Q.attributes.value,className:`${Q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let _t=[oe,Me,Be,et,x,he,c,g,h,g,l,b,y,k,C,w,g,R,B,...jt?[z]:[],Y,M,g,X,se,de,Oe,le,G,g,Q,g,U,_e,...pt?[j]:[],Ee,rt,...gz(e)?[d]:[],ve,Z];if(i<=af.md&&o&&(_t=_t.filter(qe=>qe.type!=="separator")),e.config.mode!=="docx"){const qe=_t.findIndex(Ce=>Ce.name.value==="linkedStyles");_t.splice(qe-1,2);const we=["ruler","zoom","undo","redo"];_t=_t.filter(Ce=>!we.includes(Ce.name.value))}const Rt=[];a||(s==="viewer"&&Rt.push(Be,et),_t=_t.filter(qe=>!Rt.includes(qe)));const xt=qe=>V.includes(qe.name.value),$t=[],Tn=[];let Mt=Se+ye;return _t.forEach(qe=>{const we=O.get(qe.name.value)||O.get("default");if(i<af.xl+pe&&He.includes(qe.name.value)&&o){if($t.push(qe),qe.name.value==="linkedStyles"){const Ce=_t.findIndex(Pe=>Pe.name.value==="linkedStyles");_t.splice(Ce+1,1)}return}if(i<af.sm&&ot.includes(qe.name.value)&&o){$t.push(qe);return}if(xt(qe)){Tn.push(qe),Mt+=we;return}Mt<i||!o?(Tn.push(qe),Mt+=we):$t.push(qe)}),{defaultItems:Tn,overflowItems:$t.filter(qe=>qe.type!=="separator")}},hk={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"},bz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;It();function pk(e){return KO(e)??f0[e]??null}function Np(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 wz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Cz=new Set(["list","numberedlist"]);function _z(e,t){if(e==="fontFamily"||e==="fontSize"||Cz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!wz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function mk(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Sz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var kz=class extends Jp.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Gn},texts:{...hk},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=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={...Gn,...e.icons},this.config.texts={...hk,...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._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=bz(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)}if(this.#e(),this.#u(),this.#r(),this.#i(),this._lastFontOptionsSignature=this.#a(),!this.toolbarContainer){this.updateToolbarState();return}this.app=wl(gN),this.app.directive("click-outside",tv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=Dy({superdoc:this.superdoc}),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.#R():this.#S()}))}#o(){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();try{this.ui?.destroy?.()}catch{}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.#a();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}#u(){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}#d(e){return e||dN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=yz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),r=this.config.customButtons||[],o=r.map(a=>this.#f(a));r.length&&t.push(...o);let i=[...t.map(a=>a.name.value),...n.map(a=>a.name.value)];if(this.config.groups){const a=Object.values(this.config.groups).flatMap(c=>c),l=new Set(Object.keys(this.config.groups)),u=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...u])]}const s=t.filter(a=>i.includes(a.name.value)).filter(a=>!this.config.excludeItems.includes(a.name.value));if(this.config.groups)for(const[a,l]of Object.entries(this.config.groups))for(const u of s)l.includes(u.name.value)&&(u.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=un({...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.#r(),this.emit("toolbar-items-changed")}#a(){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.#c().find(t=>t.name.value===e)}#c(){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.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#r(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#C(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){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)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>h0(this,e,[],!0)};e.nestedOptions.value=[t]}#l(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=ak.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(u0(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=pk(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];_z(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.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#l(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.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#V(),this.#c().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#c().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")}#V(){this.#c().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#D(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}#A(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#m(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=sk[t?.command];return i?Np(this.ui,i,void 0,r):!1}if(u0(n)?.disposition==="unsupported")return!0;const o=pk(n);return o?Np(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=$O({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await ZO(e,this.superdoc?.config?.handleImageUpload);Np(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#m(n,"image")})},onError:e=>this.#m(e,"image")})),this.#t.open()),!0}#R(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{mk(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!mk(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Sz(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)}#m(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}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(u0(r)?.disposition==="host-routed"){this.#D(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(!Np(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#m(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#A(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#m(s,r)}}}destroy(){this.#S(),this.#t?.destroy(),this.#t=null,this.#s(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Az(e){return new kz(e)}It();var Iz=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 Ez(e,t){const n=new K5.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function p0(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function gk(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function xz(e,t){if(!e)return()=>{};if(p0(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=()=>{gk(e),s()},l=u=>{u!==!1&&(u===!0||p0(e))&&(gk(e),s())};return n("synced",a),n("sync",l),p0(e)&&s(),i}function ai(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function Tz(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 vk(e){return typeof e=="string"&&e.length>0?e:null}function m0(e){return e?ai(e)?vk(e.documentId??e.options?.documentId??null):vk(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function Rz(e){if(!e||ai(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Ai(e){if(!e)return null;if(ai(e))return e.fonts??null;const t=Rz(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 zp=class extends Jp.default{static{this.allowedTypes=[yr,Cl,bh]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new GO;#f=null;#p=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...c0},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},!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.#d=new FO({getModuleConfig:()=>this.config.modules?.surfaces}),this.#a(e,t)}async#a(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),VO(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.#he(),this.config.user=jO(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=fR(this.config.modules.comments),this.config.colors=eI(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.32",this.#b("πŸ¦‹ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||zi(),this.colors=this.config.colors??[],this.#w(),await ox(),this.#t)return;if(await this.#x(this.config.modules),this.#t){this.#ae();return}this.config.cspNonce&&this.#C(),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.#f||(this.#f=this.#r.subscribe(i=>{this.#me(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.#u=o,this.#E(),this.#g(),this.#ge(),this.#c()}#c(){if(this.#_(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#g(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new lP({Renderer:LO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===yr).length}get state(){return{documents:this.#h("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}#C(){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}}#w(){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:zi(),...s}]}else if(n)this.config.documents=[{id:zi(),type:yr,url:this.config.document,name:"document.docx"}];else if(r){const s=gd(this.config.document);this.config.documents=[{id:zi(),...s}]}else if(o){const s=gd(this.config.document);this.config.documents=[{id:zi(),...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||zi()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=QD({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.#d),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&&G8(this),this.#se()}#l(e,t){t&&this.on(e,t)}#E(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#T(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#x({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:zi(),type:yr,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}#V(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Fr(e),this.provider=Fr(t),this.#P();const n=this.config;this._cleanupAwareness=z8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#D(){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.#o){try{this.#o()}catch{}this.#o=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#T(e){this.#A(),ai(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=oP(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#o=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#S(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#I(!!r.isLocked,this.#m(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)}}#m(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#j(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#I(e,t){this.isLocked===e&&this.#j(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("πŸ¦‹ [superdoc] Locking superdoc:",e,t,`
103
103
 
104
104
 
105
105
  `),this.emit("locked",{isLocked:e,lockedBy:t}))}#P(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:Iz,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,mountedDocumentId:n}=this.#ce(e);this.#n=!0;try{const r=await this.#X(),o=this.#F(),i=this.#G();this.#W();let s=null;try{this.#s=i,s=this.#le(n);const a=this.#q(t,r);await s,this.#Y(a,t),this.#s=null}catch(a){if(s&&this.#e){const l=this.#e;this.#e=null,l(),await s.catch(()=>{})}throw this.#M(o),a}}finally{this.#e=null,this.#n=!1}}#G(){return{isLocked:this.isLocked,lockedBy:this.lockedBy?{...this.lockedBy}:null}}#F(){const e=this.config.documents.find(r=>r.type===yr),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?tn(t):null;return{isCollaborative:this.isCollaborative,configV2Collaboration:e.v2Collaboration??null,configData:e.data,storeDoc:t,storeV2Collaboration:this.#K(n),storeData:t?.data}}#M(e){this.#s=null;const t=this.config.documents.find(n=>n.type===yr);t.v2Collaboration=e.configV2Collaboration,t.data=e.configData,this.isCollaborative=e.isCollaborative,e.storeDoc&&(e.storeDoc.data=e.storeData,this.#k(e.storeDoc,e.storeV2Collaboration),this.#B(e.storeDoc))}#W(){if(this.#t)throw new Error("SuperDoc: instance was destroyed during upgrade")}#h(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}#v(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}#y(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#O(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=tn(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)}}#K(e){if(!e)return null;const t=e.v2Collaboration;return t&&typeof t=="object"&&"value"in t?t.value:t??null}#k(e,t){const n=tn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#B(e){const t=tn(e).editorMountNonce;if(t&&typeof t=="object"&&"value"in t&&typeof t.value=="number"){t.value+=1;return}const n=e;n.editorMountNonce=(typeof n.editorMountNonce=="number"?n.editorMountNonce:0)+1}#N(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}:{}}}#q(e,t){const n=this.config.documents.find(i=>i.type===yr),r=this.#h("upgradeToCollaboration").documents.find(i=>i.id===n.id);if(!r)throw new Error("SuperDoc: source document store entry is not available for upgrade");const o=this.#N({...e,roomMode:"create"});return n.data=t,n.v2Collaboration=o,r.data=t,this.#k(r,o),this.isCollaborative=!0,this.readyEditors=0,this.#B(r),{configDoc:n,storeDoc:r}}#Y(e,t){const n=this.#N({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#k(e.storeDoc,n)}async#X(){const e=this.activeEditor;if(ai(e)&&typeof e.save=="function"){const r=await e.save();return this.#L(r)}const t=this.config.documents.find(r=>r.type===yr),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.#L(n);throw new Error("SuperDoc: upgradeToCollaboration() requires a live v2 editor save or DOCX Blob source")}#L(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:yr})}if(e instanceof ArrayBuffer)return new Blob([e],{type:yr});throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#J(e,t){const n=m0(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.#L(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.#k(s,i))}#we(){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}#Ce(){this.#D(),this.#O(null,null)}#_e(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.#e=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#le(e){return new Promise((n,r)=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(a),this.off("collaboration-ready",s))},s=l=>{const u=l?.editor;ai(u)&&m0(u)===e&&(!u.presence&&!u.lock||(i(),n()))},a=setTimeout(()=>{i(),r(new Error(`SuperDoc: v2 collaboration runtime did not become ready within 20000 ms for mounted document "${e}".`))},2e4);this.on("collaboration-ready",s),this.#e=()=>{i(),r(new Error("SuperDoc: instance was destroyed during upgrade"))}})}#Se(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=xz(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.#e=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#ce(e){if(this.#t)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(l=>l.type===yr);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(!ai(this.#de()))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=d4({v2Collaboration:e.v2Collaboration??this.#ue(r.v2Collaboration)??i?.v2Collaboration??i?.v2??null,legacyCollaboration:s,documentType:yr,documentCount:t.documents.length,...typeof window<"u"?{authEndpointBaseUrl:window.location.href}:{}});if(!a.ok)throw new Error(`SuperDoc: upgradeToCollaboration() ${a.reason}: ${a.message}`);return{target:a.target,mountedDocumentId:o}}#ue(e){return e&&typeof e=="object"&&"value"in e?e.value:e}#de(){const e=this.config.documents.find(n=>n.type===yr),t=this.#h("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.#y("addSharedUser");const t=wc({actor:e});t&&this.users.some(n=>wc({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#y("removeSharedUser");const t=typeof e=="string"?$g(e):"",n=typeof e=="string"?`email:${t}`:wc({actor:e});this.users=this.users.filter(r=>{const o=wc({actor:r});return n?o!==n:t?$g(r.email)!==t:!0})}onContentError({error:e,editor:t}){const n=t.options?.documentId,r=this.#h("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:qS(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#fe(e),this.emit("editorCreate",{editor:qS(e)})}broadcastSourceComplete(){this.emit("source:complete")}broadcastSourceSignalsComplete(){this.emit("source:signals-complete")}#$=new WeakSet;#fe(e){if(!e||typeof e.on!="function"||this.#$.has(e))return;this.#$.add(e),e.on("fonts-changed",n=>{this.#ee(e)&&this.#z(n)});const t=(e.documentRenderer??e.presentationEditor)?.getLastFontsChangedPayload?.();t&&this.#ee(e)&&this.#z(t)}#ee(e){return!this.activeEditor||e===this.activeEditor}#te=null;#z(e){this.#te=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#he(){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.")}#b(...e){(console.debug?console.debug:console.log)("πŸ¦‹ πŸ¦Έβ€β™€οΈ [superdoc]",...e)}#Q=null;get fonts(){return this.#Q||(this.#Q={getReport:()=>Ai(this.activeEditor)?.getReport()??[],getMissingFonts:()=>Ai(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>Ai(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>Ai(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>Ai(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?Ai(t)?.getLastFontsChangedPayload?.()??null:this.#te??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=Ai(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=Ai(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=Ai(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=Ai(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preload(e)}}),this.#Q}#H(){this.#ne(),this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null)}#U=null;#ne(){if(this.#U){try{this.#U()}catch{}this.#U=null}}#pe(e){this.#ne();const t=Ai(e);if(!t?.onChanged)return;const n=t.getLastFontsChangedPayload?.();n&&this.#z(n),this.#U=t.onChanged(r=>this.#z(r))}#me(e,t){this.#p=!0;try{if(e===null){this.#H();return}this.#r.get(e)?.kind==="v2"&&ai(t)?this.#re(t):this.#H()}finally{this.#p=!1}}#re(e){if(ai(e)){!this.#p&&this.#r.getActive()&&this.#r.setActive(null,"set-active-v2-facade"),this.activeEditor=e,this.#pe(e),this.toolbar?.setActiveEditor?.(e);return}this.#H()}setActiveEditor(e){this.#re(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:"not-shipped",reason:"bulk-tracked-change-decisions-omitted: acceptAll/rejectAll are matrix-disabled by default in the v2 host"},{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:"not-shipped",reason:"context-menu-omitted: public v2 shell disables the legacy context menu"},{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.#r.register(e)}unregisterEditorRuntime(e){return this.#r.unregister(e)}getActiveRuntime(){return this.#r.getActive()}setActiveRuntime(e,t){this.#r.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#r.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#r.resolveFromEventTarget(e);return n?(this.#r.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#h("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 a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return Ys(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#ge(){const e=this.config.modules?.toolbar,t=e&&typeof e=="object"?e:{};if(this.toolbarElement=t.selector||this.config.toolbar,!(this.config.toolbar||e===!0||e!=null&&typeof e=="object")){this.toolbar=null;return}try{this.toolbar=Az({...t,selector:this.toolbarElement,superdoc:this,editor:this.activeEditor,role:this.config.role,isDev:this.isDev,documentMode:this.config.documentMode,toolbarGroups:t.toolbarGroups??this.config.toolbarGroups,icons:{...this.config.toolbarIcons,...t.icons},texts:{...this.config.toolbarTexts,...t.texts},uiDisplayFallbackFont:this.config.uiDisplayFallbackFont})}catch(n){console.warn("[SuperDoc] built-in toolbar mount failed",n),this.toolbar=null}}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new S7(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({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){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.#y("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#se();const t={viewing:()=>this.#ie(),editing:()=>this.#ve(),suggesting:()=>this.#oe()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#Z(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null;if(n){const i=this.#r.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)})}#ve(){if(this.config.role!=="editor")return this.#oe();const e=this.#h("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.#Z(t,"editing")})}#oe(){if(!["editor","suggester"].includes(this.config.role??""))return this.#ie();const e=this.#h("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.#Z(t,"suggesting")})}#ie(){const e=this.#h("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.#Z(r,"viewing")})}#se(){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=AC(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(ai(t)&&typeof t.lock?.setLocked=="function"){t.lock.setLocked(e,e?{...this.user}:null);const n=t.lock.getSnapshot?.();n&&this.#I(!!n.isLocked,this.#m(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.#I(e,e?this.user:null)}getHTML(e={}){const t=[];return this.#h("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.#I(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=P4(n||this.config.title),u=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),c=[...r],d=[...o];if(e.includes("docx")&&u.forEach(m=>{c.push(m),d.push(`${l}.docx`)}),c.length===1)return s?D4(c[0],l,e[0]):c[0];const p=await Ez(c,d);return s?D4(p,l,"zip"):p}async replaceFile(e){const t=this.activeEditor;if(ai(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.#J(t,e),r}const n=t&&!ai(t)?t.replaceFile:null;if(typeof n=="function"){const r=await n.call(t,e);return this.#J(t,e),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=u=>{"editor"in u&&u.error&&typeof u.error=="object"&&a.add(u.error)};this.on("exception",l);try{const u=this.#h("exportEditorsToDOCX").documents.map(async c=>{if(!c||c.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const d=typeof c.getEditor=="function"?c.getEditor():null,p=()=>!c.data||c.data.type&&c.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:c.data;if(!d||typeof d.exportDocx!="function")return p();const m=d.editorVersion===2;try{const h=await d.exportDocx(m?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(h)return h}catch(h){if((!h||typeof h!="object"||!a.has(h))&&this.emit("exception",{error:h,document:c}),m&&(e==="clean"||Tz(h)))throw h}return p()});return(await Promise.all(u)).filter(c=>c!=null)}finally{this.off("exception",l)}}async#ye(){this.#b("πŸ¦‹ [superdoc] Triggering collaboration saves");const e=this.#h("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#b(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#b(`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.#b(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#ye()];this.#b("πŸ¦‹ [superdoc] Saving superdoc"),await Promise.all(e),this.#b("πŸ¦‹ [superdoc] Save complete")}#be(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?.()}#ae(){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.#d.open(e)}closeSurface(e){this.#d.close(e)}async removeDocument(e){const t=typeof e=="string"?e:String(e??"");if(!t)return!1;const n=this.#h("removeDocument"),r=this.activeEditor,o=m0(r);for(const s of this.#r.getAllByDocumentId(t))this.#r.unregister(s.id);o===t&&r!==null&&this.#H();const i=n.removeDocument(t);return i?(this.#be(i,n.documents),await St(),!0):!1}destroy(){this.#t=!0,this.#e&&(this.#e(),this.#e=null),this.#d&&this.#d.destroy(),this.toolbar?.destroy?.(),this.app&&(this.#b("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#ae(),this.#f?.(),this.#f=null,this.#r.clear(),this.#u&&(this.#u.remove(),this.#u=null)}focus(){const e=this.getActiveRuntime();if(e?.getCapabilities().lifecycle.canFocus){e.focus().catch(t=>{console.warn("[SuperDoc] active editor runtime focus failed",t)});return}this.activeEditor?this.activeEditor.focus?.():this.#h("focus").documents.find(t=>{const n=t.getEditor?.();return n?(n.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};It();const yk="__SUPERDOC_V2_BROWSER_RUNTIME__";function Mz(e=globalThis){const t=e[yk];return t&&typeof t=="object"?t:null}function Lz(e={},t=globalThis){const n=Mz(t)??{},r={...n,...e,vue:e.vue??n.vue??j5};return t[yk]=r,r}Lz();var Dz={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"},Pz=0;function bk(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-${++Pz}`}`,l=[];if(i)for(const[u,c]of Object.entries(i)){if(c==null)continue;const d=Dz[u];d&&l.push(` ${d}: ${c};`)}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[u,c]of Object.entries(s))c!=null&&l.push(` ${u}: ${c};`);return{className:a,css:l.length>0?`.${a} {
106
106
  ${l.join(`
107
107
  `)}
108
- }`:""}}function Fz(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 Oz(e){const{className:t,css:n}=bk(e);return Fz(t,n),t}function Bz(e){return bk(e)}function Nz(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 zz=ku({BlankDOCX:()=>rC,DOCX:()=>yr,HTML:()=>bh,PDF:()=>Cl,SuperDoc:()=>zp,buildTheme:()=>Bz,compareVersions:()=>Z5,createTheme:()=>Oz,defineSuperDocExtension:()=>Nz,getFileObject:()=>ev},1),Hz="SUPERDOC_ENGINE_CDN_BASE_URL",wk=Symbol.for("superdoc.docx-engine.cdn-load-state"),Hp="superdocDocxEngineStatus";function Uz(e,t,n=null){const r=e?.[Hz],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return Vz(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 Vz(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 jz({engineVersion:e,buildBaseUrl:t}){nx(()=>{const n=Uz(globalThis,e,t),r=globalThis[wk],o=r instanceof Map?r:new Map;if(globalThis[wk]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),Gz(`${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 Gz(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[Hp]==="loaded")return Promise.resolve();const r=n?.dataset[Hp]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,h)=>{a||(a=!0,l?.disconnect(),s.dataset[Hp]=m,h())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),p=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(p),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[Hp]="loading",document.head.appendChild(s))})}jz({engineVersion:"0.2.0-next.3",buildBaseUrl:null});for(const[e,t]of Object.entries(zz))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(zp,e)||(zp[e]=t);var Wz=zp;return Wz})();
108
+ }`:""}}function Fz(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 Oz(e){const{className:t,css:n}=bk(e);return Fz(t,n),t}function Bz(e){return bk(e)}function Nz(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 zz=ku({BlankDOCX:()=>rC,DOCX:()=>yr,HTML:()=>bh,PDF:()=>Cl,SuperDoc:()=>zp,buildTheme:()=>Bz,compareVersions:()=>Z5,createTheme:()=>Oz,defineSuperDocExtension:()=>Nz,getFileObject:()=>ev},1),Hz="SUPERDOC_ENGINE_CDN_BASE_URL",wk=Symbol.for("superdoc.docx-engine.cdn-load-state"),Hp="superdocDocxEngineStatus";function Uz(e,t,n=null){const r=e?.[Hz],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return Vz(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 Vz(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 jz({engineVersion:e,buildBaseUrl:t}){nx(()=>{const n=Uz(globalThis,e,t),r=globalThis[wk],o=r instanceof Map?r:new Map;if(globalThis[wk]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),Gz(`${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 Gz(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[Hp]==="loaded")return Promise.resolve();const r=n?.dataset[Hp]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,h)=>{a||(a=!0,l?.disconnect(),s.dataset[Hp]=m,h())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),p=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(p),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[Hp]="loading",document.head.appendChild(s))})}jz({engineVersion:"0.2.0-next.4",buildBaseUrl:null});for(const[e,t]of Object.entries(zz))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(zp,e)||(zp[e]=t);var Wz=zp;return Wz})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superdoc",
3
3
  "type": "module",
4
- "version": "2.0.0-next.31",
4
+ "version": "2.0.0-next.32",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -75,7 +75,7 @@
75
75
  "main": "./dist/superdoc.cjs",
76
76
  "module": "./dist/superdoc.es.js",
77
77
  "dependencies": {
78
- "@superdoc/docx-engine": "0.2.0-next.3",
78
+ "@superdoc/docx-engine": "0.2.0-next.4",
79
79
  "@types/mdast": "^4.0.4",
80
80
  "@types/ws": "^8.18.1",
81
81
  "buffer-crc32": "^1.0.0",