@bitovi/vybit 0.4.4 → 0.4.6

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.
@@ -1,549 +0,0 @@
1
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function xm(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var qd={exports:{}},na={},Qd={exports:{}},Y={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Js=Symbol.for("react.element"),_m=Symbol.for("react.portal"),wm=Symbol.for("react.fragment"),Sm=Symbol.for("react.strict_mode"),Cm=Symbol.for("react.profiler"),bm=Symbol.for("react.provider"),Tm=Symbol.for("react.context"),km=Symbol.for("react.forward_ref"),Om=Symbol.for("react.suspense"),Em=Symbol.for("react.memo"),Dm=Symbol.for("react.lazy"),Bu=Symbol.iterator;function Pm(r){return r===null||typeof r!="object"?null:(r=Bu&&r[Bu]||r["@@iterator"],typeof r=="function"?r:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Zd=Object.assign,ef={};function Un(r,e,t){this.props=r,this.context=e,this.refs=ef,this.updater=t||Jd}Un.prototype.isReactComponent={};Un.prototype.setState=function(r,e){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,e,"setState")};Un.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function tf(){}tf.prototype=Un.prototype;function kc(r,e,t){this.props=r,this.context=e,this.refs=ef,this.updater=t||Jd}var Oc=kc.prototype=new tf;Oc.constructor=kc;Zd(Oc,Un.prototype);Oc.isPureReactComponent=!0;var Vu=Array.isArray,rf=Object.prototype.hasOwnProperty,Ec={current:null},nf={key:!0,ref:!0,__self:!0,__source:!0};function sf(r,e,t){var n,s={},i=null,o=null;if(e!=null)for(n in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)rf.call(e,n)&&!nf.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=t;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];s.children=l}if(r&&r.defaultProps)for(n in a=r.defaultProps,a)s[n]===void 0&&(s[n]=a[n]);return{$$typeof:Js,type:r,key:i,ref:o,props:s,_owner:Ec.current}}function Mm(r,e){return{$$typeof:Js,type:r.type,key:e,ref:r.ref,props:r.props,_owner:r._owner}}function Dc(r){return typeof r=="object"&&r!==null&&r.$$typeof===Js}function jm(r){var e={"=":"=0",":":"=2"};return"$"+r.replace(/[=:]/g,function(t){return e[t]})}var Wu=/\/+/g;function Ma(r,e){return typeof r=="object"&&r!==null&&r.key!=null?jm(""+r.key):e.toString(36)}function Qi(r,e,t,n,s){var i=typeof r;(i==="undefined"||i==="boolean")&&(r=null);var o=!1;if(r===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(r.$$typeof){case Js:case _m:o=!0}}if(o)return o=r,s=s(o),r=n===""?"."+Ma(o,0):n,Vu(s)?(t="",r!=null&&(t=r.replace(Wu,"$&/")+"/"),Qi(s,e,t,"",function(c){return c})):s!=null&&(Dc(s)&&(s=Mm(s,t+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(Wu,"$&/")+"/")+r)),e.push(s)),1;if(o=0,n=n===""?".":n+":",Vu(r))for(var a=0;a<r.length;a++){i=r[a];var l=n+Ma(i,a);o+=Qi(i,e,t,l,s)}else if(l=Pm(r),typeof l=="function")for(r=l.call(r),a=0;!(i=r.next()).done;)i=i.value,l=n+Ma(i,a++),o+=Qi(i,e,t,l,s);else if(i==="object")throw e=String(r),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function oi(r,e,t){if(r==null)return r;var n=[],s=0;return Qi(r,n,"","",function(i){return e.call(t,i,s++)}),n}function Am(r){if(r._status===-1){var e=r._result;e=e(),e.then(function(t){(r._status===0||r._status===-1)&&(r._status=1,r._result=t)},function(t){(r._status===0||r._status===-1)&&(r._status=2,r._result=t)}),r._status===-1&&(r._status=0,r._result=e)}if(r._status===1)return r._result.default;throw r._result}var Be={current:null},Ji={transition:null},Lm={ReactCurrentDispatcher:Be,ReactCurrentBatchConfig:Ji,ReactCurrentOwner:Ec};function of(){throw Error("act(...) is not supported in production builds of React.")}Y.Children={map:oi,forEach:function(r,e,t){oi(r,function(){e.apply(this,arguments)},t)},count:function(r){var e=0;return oi(r,function(){e++}),e},toArray:function(r){return oi(r,function(e){return e})||[]},only:function(r){if(!Dc(r))throw Error("React.Children.only expected to receive a single React element child.");return r}};Y.Component=Un;Y.Fragment=wm;Y.Profiler=Cm;Y.PureComponent=kc;Y.StrictMode=Sm;Y.Suspense=Om;Y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Lm;Y.act=of;Y.cloneElement=function(r,e,t){if(r==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+r+".");var n=Zd({},r.props),s=r.key,i=r.ref,o=r._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,o=Ec.current),e.key!==void 0&&(s=""+e.key),r.type&&r.type.defaultProps)var a=r.type.defaultProps;for(l in e)rf.call(e,l)&&!nf.hasOwnProperty(l)&&(n[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)n.children=t;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];n.children=a}return{$$typeof:Js,type:r.type,key:s,ref:i,props:n,_owner:o}};Y.createContext=function(r){return r={$$typeof:Tm,_currentValue:r,_currentValue2:r,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},r.Provider={$$typeof:bm,_context:r},r.Consumer=r};Y.createElement=sf;Y.createFactory=function(r){var e=sf.bind(null,r);return e.type=r,e};Y.createRef=function(){return{current:null}};Y.forwardRef=function(r){return{$$typeof:km,render:r}};Y.isValidElement=Dc;Y.lazy=function(r){return{$$typeof:Dm,_payload:{_status:-1,_result:r},_init:Am}};Y.memo=function(r,e){return{$$typeof:Em,type:r,compare:e===void 0?null:e}};Y.startTransition=function(r){var e=Ji.transition;Ji.transition={};try{r()}finally{Ji.transition=e}};Y.unstable_act=of;Y.useCallback=function(r,e){return Be.current.useCallback(r,e)};Y.useContext=function(r){return Be.current.useContext(r)};Y.useDebugValue=function(){};Y.useDeferredValue=function(r){return Be.current.useDeferredValue(r)};Y.useEffect=function(r,e){return Be.current.useEffect(r,e)};Y.useId=function(){return Be.current.useId()};Y.useImperativeHandle=function(r,e,t){return Be.current.useImperativeHandle(r,e,t)};Y.useInsertionEffect=function(r,e){return Be.current.useInsertionEffect(r,e)};Y.useLayoutEffect=function(r,e){return Be.current.useLayoutEffect(r,e)};Y.useMemo=function(r,e){return Be.current.useMemo(r,e)};Y.useReducer=function(r,e,t){return Be.current.useReducer(r,e,t)};Y.useRef=function(r){return Be.current.useRef(r)};Y.useState=function(r){return Be.current.useState(r)};Y.useSyncExternalStore=function(r,e,t){return Be.current.useSyncExternalStore(r,e,t)};Y.useTransition=function(){return Be.current.useTransition()};Y.version="18.3.1";Qd.exports=Y;var V=Qd.exports;const Fm=xm(V);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Rm=V,Nm=Symbol.for("react.element"),Im=Symbol.for("react.fragment"),zm=Object.prototype.hasOwnProperty,Bm=Rm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vm={key:!0,ref:!0,__self:!0,__source:!0};function af(r,e,t){var n,s={},i=null,o=null;t!==void 0&&(i=""+t),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(o=e.ref);for(n in e)zm.call(e,n)&&!Vm.hasOwnProperty(n)&&(s[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)s[n]===void 0&&(s[n]=e[n]);return{$$typeof:Nm,type:r,key:i,ref:o,props:s,_owner:Bm.current}}na.Fragment=Im;na.jsx=af;na.jsxs=af;qd.exports=na;var S=qd.exports,yl={},lf={exports:{}},nt={},cf={exports:{}},uf={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(r){function e(P,z){var A=P.length;P.push(z);e:for(;0<A;){var U=A-1>>>1,G=P[U];if(0<s(G,z))P[U]=z,P[A]=G,A=U;else break e}}function t(P){return P.length===0?null:P[0]}function n(P){if(P.length===0)return null;var z=P[0],A=P.pop();if(A!==z){P[0]=A;e:for(var U=0,G=P.length,ae=G>>>1;U<ae;){var ee=2*(U+1)-1,fr=P[ee],Ae=ee+1,Mt=P[Ae];if(0>s(fr,A))Ae<G&&0>s(Mt,fr)?(P[U]=Mt,P[Ae]=A,U=Ae):(P[U]=fr,P[ee]=A,U=ee);else if(Ae<G&&0>s(Mt,A))P[U]=Mt,P[Ae]=A,U=Ae;else break e}}return z}function s(P,z){var A=P.sortIndex-z.sortIndex;return A!==0?A:P.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;r.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,d=3,f=!1,m=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(P){for(var z=t(c);z!==null;){if(z.callback===null)n(c);else if(z.startTime<=P)n(c),z.sortIndex=z.expirationTime,e(l,z);else break;z=t(c)}}function x(P){if(v=!1,y(P),!m)if(t(l)!==null)m=!0,j(_);else{var z=t(c);z!==null&&I(x,z.startTime-P)}}function _(P,z){m=!1,v&&(v=!1,g(k),k=-1),f=!0;var A=d;try{for(y(z),h=t(l);h!==null&&(!(h.expirationTime>z)||P&&!X());){var U=h.callback;if(typeof U=="function"){h.callback=null,d=h.priorityLevel;var G=U(h.expirationTime<=z);z=r.unstable_now(),typeof G=="function"?h.callback=G:h===t(l)&&n(l),y(z)}else n(l);h=t(l)}if(h!==null)var ae=!0;else{var ee=t(c);ee!==null&&I(x,ee.startTime-z),ae=!1}return ae}finally{h=null,d=A,f=!1}}var E=!1,D=null,k=-1,N=5,L=-1;function X(){return!(r.unstable_now()-L<N)}function T(){if(D!==null){var P=r.unstable_now();L=P;var z=!0;try{z=D(!0,P)}finally{z?M():(E=!1,D=null)}}else E=!1}var M;if(typeof p=="function")M=function(){p(T)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,B=R.port2;R.port1.onmessage=T,M=function(){B.postMessage(null)}}else M=function(){w(T,0)};function j(P){D=P,E||(E=!0,M())}function I(P,z){k=w(function(){P(r.unstable_now())},z)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(P){P.callback=null},r.unstable_continueExecution=function(){m||f||(m=!0,j(_))},r.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<P?Math.floor(1e3/P):5},r.unstable_getCurrentPriorityLevel=function(){return d},r.unstable_getFirstCallbackNode=function(){return t(l)},r.unstable_next=function(P){switch(d){case 1:case 2:case 3:var z=3;break;default:z=d}var A=d;d=z;try{return P()}finally{d=A}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(P,z){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var A=d;d=P;try{return z()}finally{d=A}},r.unstable_scheduleCallback=function(P,z,A){var U=r.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?U+A:U):A=U,P){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=A+G,P={id:u++,callback:z,priorityLevel:P,startTime:A,expirationTime:G,sortIndex:-1},A>U?(P.sortIndex=A,e(c,P),t(l)===null&&P===t(c)&&(v?(g(k),k=-1):v=!0,I(x,A-U))):(P.sortIndex=G,e(l,P),m||f||(m=!0,j(_))),P},r.unstable_shouldYield=X,r.unstable_wrapCallback=function(P){var z=d;return function(){var A=d;d=z;try{return P.apply(this,arguments)}finally{d=A}}}})(uf);cf.exports=uf;var Wm=cf.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var Hm=V,rt=Wm;function F(r){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+r,t=1;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var hf=new Set,Ds={};function on(r,e){Nn(r,e),Nn(r+"Capture",e)}function Nn(r,e){for(Ds[r]=e,r=0;r<e.length;r++)hf.add(e[r])}var rr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xl=Object.prototype.hasOwnProperty,Xm=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Hu={},Xu={};function Um(r){return xl.call(Xu,r)?!0:xl.call(Hu,r)?!1:Xm.test(r)?Xu[r]=!0:(Hu[r]=!0,!1)}function $m(r,e,t,n){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:t!==null?!t.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function Ym(r,e,t,n){if(e===null||typeof e>"u"||$m(r,e,t,n))return!0;if(n)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ve(r,e,t,n,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=t,this.propertyName=r,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){Oe[r]=new Ve(r,0,!1,r,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var e=r[0];Oe[e]=new Ve(e,1,!1,r[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(r){Oe[r]=new Ve(r,2,!1,r.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){Oe[r]=new Ve(r,2,!1,r,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){Oe[r]=new Ve(r,3,!1,r.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(r){Oe[r]=new Ve(r,3,!0,r,null,!1,!1)});["capture","download"].forEach(function(r){Oe[r]=new Ve(r,4,!1,r,null,!1,!1)});["cols","rows","size","span"].forEach(function(r){Oe[r]=new Ve(r,6,!1,r,null,!1,!1)});["rowSpan","start"].forEach(function(r){Oe[r]=new Ve(r,5,!1,r.toLowerCase(),null,!1,!1)});var Pc=/[\-:]([a-z])/g;function Mc(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var e=r.replace(Pc,Mc);Oe[e]=new Ve(e,1,!1,r,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var e=r.replace(Pc,Mc);Oe[e]=new Ve(e,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(r){var e=r.replace(Pc,Mc);Oe[e]=new Ve(e,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(r){Oe[r]=new Ve(r,1,!1,r.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(r){Oe[r]=new Ve(r,1,!1,r.toLowerCase(),null,!0,!0)});function jc(r,e,t,n){var s=Oe.hasOwnProperty(e)?Oe[e]:null;(s!==null?s.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(Ym(e,t,s,n)&&(t=null),n||s===null?Um(e)&&(t===null?r.removeAttribute(e):r.setAttribute(e,""+t)):s.mustUseProperty?r[s.propertyName]=t===null?s.type===3?!1:"":t:(e=s.attributeName,n=s.attributeNamespace,t===null?r.removeAttribute(e):(s=s.type,t=s===3||s===4&&t===!0?"":""+t,n?r.setAttributeNS(n,e,t):r.setAttribute(e,t))))}var ur=Hm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ai=Symbol.for("react.element"),fn=Symbol.for("react.portal"),gn=Symbol.for("react.fragment"),Ac=Symbol.for("react.strict_mode"),_l=Symbol.for("react.profiler"),df=Symbol.for("react.provider"),ff=Symbol.for("react.context"),Lc=Symbol.for("react.forward_ref"),wl=Symbol.for("react.suspense"),Sl=Symbol.for("react.suspense_list"),Fc=Symbol.for("react.memo"),yr=Symbol.for("react.lazy"),gf=Symbol.for("react.offscreen"),Uu=Symbol.iterator;function ts(r){return r===null||typeof r!="object"?null:(r=Uu&&r[Uu]||r["@@iterator"],typeof r=="function"?r:null)}var he=Object.assign,ja;function hs(r){if(ja===void 0)try{throw Error()}catch(t){var e=t.stack.trim().match(/\n( *(at )?)/);ja=e&&e[1]||""}return`
34
- `+ja+r}var Aa=!1;function La(r,e){if(!r||Aa)return"";Aa=!0;var t=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var n=c}Reflect.construct(r,[],e)}else{try{e.call()}catch(c){n=c}r.call(e.prototype)}else{try{throw Error()}catch(c){n=c}r()}}catch(c){if(c&&n&&typeof c.stack=="string"){for(var s=c.stack.split(`
35
- `),i=n.stack.split(`
36
- `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=`
37
- `+s[o].replace(" at new "," at ");return r.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",r.displayName)),l}while(1<=o&&0<=a);break}}}finally{Aa=!1,Error.prepareStackTrace=t}return(r=r?r.displayName||r.name:"")?hs(r):""}function Gm(r){switch(r.tag){case 5:return hs(r.type);case 16:return hs("Lazy");case 13:return hs("Suspense");case 19:return hs("SuspenseList");case 0:case 2:case 15:return r=La(r.type,!1),r;case 11:return r=La(r.type.render,!1),r;case 1:return r=La(r.type,!0),r;default:return""}}function Cl(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case gn:return"Fragment";case fn:return"Portal";case _l:return"Profiler";case Ac:return"StrictMode";case wl:return"Suspense";case Sl:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case ff:return(r.displayName||"Context")+".Consumer";case df:return(r._context.displayName||"Context")+".Provider";case Lc:var e=r.render;return r=r.displayName,r||(r=e.displayName||e.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Fc:return e=r.displayName||null,e!==null?e:Cl(r.type)||"Memo";case yr:e=r._payload,r=r._init;try{return Cl(r(e))}catch{}}return null}function Km(r){var e=r.type;switch(r.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=e.render,r=r.displayName||r.name||"",e.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Cl(e);case 8:return e===Ac?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Lr(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function pf(r){var e=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function qm(r){var e=pf(r)?"checked":"value",t=Object.getOwnPropertyDescriptor(r.constructor.prototype,e),n=""+r[e];if(!r.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var s=t.get,i=t.set;return Object.defineProperty(r,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){n=""+o,i.call(this,o)}}),Object.defineProperty(r,e,{enumerable:t.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){r._valueTracker=null,delete r[e]}}}}function li(r){r._valueTracker||(r._valueTracker=qm(r))}function mf(r){if(!r)return!1;var e=r._valueTracker;if(!e)return!0;var t=e.getValue(),n="";return r&&(n=pf(r)?r.checked?"true":"false":r.value),r=n,r!==t?(e.setValue(r),!0):!1}function xo(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function bl(r,e){var t=e.checked;return he({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??r._wrapperState.initialChecked})}function $u(r,e){var t=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;t=Lr(e.value!=null?e.value:t),r._wrapperState={initialChecked:n,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function vf(r,e){e=e.checked,e!=null&&jc(r,"checked",e,!1)}function Tl(r,e){vf(r,e);var t=Lr(e.value),n=e.type;if(t!=null)n==="number"?(t===0&&r.value===""||r.value!=t)&&(r.value=""+t):r.value!==""+t&&(r.value=""+t);else if(n==="submit"||n==="reset"){r.removeAttribute("value");return}e.hasOwnProperty("value")?kl(r,e.type,t):e.hasOwnProperty("defaultValue")&&kl(r,e.type,Lr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(r.defaultChecked=!!e.defaultChecked)}function Yu(r,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+r._wrapperState.initialValue,t||e===r.value||(r.value=e),r.defaultValue=e}t=r.name,t!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,t!==""&&(r.name=t)}function kl(r,e,t){(e!=="number"||xo(r.ownerDocument)!==r)&&(t==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+t&&(r.defaultValue=""+t))}var ds=Array.isArray;function En(r,e,t,n){if(r=r.options,e){e={};for(var s=0;s<t.length;s++)e["$"+t[s]]=!0;for(t=0;t<r.length;t++)s=e.hasOwnProperty("$"+r[t].value),r[t].selected!==s&&(r[t].selected=s),s&&n&&(r[t].defaultSelected=!0)}else{for(t=""+Lr(t),e=null,s=0;s<r.length;s++){if(r[s].value===t){r[s].selected=!0,n&&(r[s].defaultSelected=!0);return}e!==null||r[s].disabled||(e=r[s])}e!==null&&(e.selected=!0)}}function Ol(r,e){if(e.dangerouslySetInnerHTML!=null)throw Error(F(91));return he({},e,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Gu(r,e){var t=e.value;if(t==null){if(t=e.children,e=e.defaultValue,t!=null){if(e!=null)throw Error(F(92));if(ds(t)){if(1<t.length)throw Error(F(93));t=t[0]}e=t}e==null&&(e=""),t=e}r._wrapperState={initialValue:Lr(t)}}function yf(r,e){var t=Lr(e.value),n=Lr(e.defaultValue);t!=null&&(t=""+t,t!==r.value&&(r.value=t),e.defaultValue==null&&r.defaultValue!==t&&(r.defaultValue=t)),n!=null&&(r.defaultValue=""+n)}function Ku(r){var e=r.textContent;e===r._wrapperState.initialValue&&e!==""&&e!==null&&(r.value=e)}function xf(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function El(r,e){return r==null||r==="http://www.w3.org/1999/xhtml"?xf(e):r==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var ci,_f=function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,t,n,s){MSApp.execUnsafeLocalFunction(function(){return r(e,t,n,s)})}:r}(function(r,e){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=e;else{for(ci=ci||document.createElement("div"),ci.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=ci.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;e.firstChild;)r.appendChild(e.firstChild)}});function Ps(r,e){if(e){var t=r.firstChild;if(t&&t===r.lastChild&&t.nodeType===3){t.nodeValue=e;return}}r.textContent=e}var ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Qm=["Webkit","ms","Moz","O"];Object.keys(ms).forEach(function(r){Qm.forEach(function(e){e=e+r.charAt(0).toUpperCase()+r.substring(1),ms[e]=ms[r]})});function wf(r,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||ms.hasOwnProperty(r)&&ms[r]?(""+e).trim():e+"px"}function Sf(r,e){r=r.style;for(var t in e)if(e.hasOwnProperty(t)){var n=t.indexOf("--")===0,s=wf(t,e[t],n);t==="float"&&(t="cssFloat"),n?r.setProperty(t,s):r[t]=s}}var Jm=he({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Dl(r,e){if(e){if(Jm[r]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(F(137,r));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(F(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(F(61))}if(e.style!=null&&typeof e.style!="object")throw Error(F(62))}}function Pl(r,e){if(r.indexOf("-")===-1)return typeof e.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ml=null;function Rc(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var jl=null,Dn=null,Pn=null;function qu(r){if(r=ti(r)){if(typeof jl!="function")throw Error(F(280));var e=r.stateNode;e&&(e=la(e),jl(r.stateNode,r.type,e))}}function Cf(r){Dn?Pn?Pn.push(r):Pn=[r]:Dn=r}function bf(){if(Dn){var r=Dn,e=Pn;if(Pn=Dn=null,qu(r),e)for(r=0;r<e.length;r++)qu(e[r])}}function Tf(r,e){return r(e)}function kf(){}var Fa=!1;function Of(r,e,t){if(Fa)return r(e,t);Fa=!0;try{return Tf(r,e,t)}finally{Fa=!1,(Dn!==null||Pn!==null)&&(kf(),bf())}}function Ms(r,e){var t=r.stateNode;if(t===null)return null;var n=la(t);if(n===null)return null;t=n[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(r=r.type,n=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!n;break e;default:r=!1}if(r)return null;if(t&&typeof t!="function")throw Error(F(231,e,typeof t));return t}var Al=!1;if(rr)try{var rs={};Object.defineProperty(rs,"passive",{get:function(){Al=!0}}),window.addEventListener("test",rs,rs),window.removeEventListener("test",rs,rs)}catch{Al=!1}function Zm(r,e,t,n,s,i,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(t,c)}catch(u){this.onError(u)}}var vs=!1,_o=null,wo=!1,Ll=null,ev={onError:function(r){vs=!0,_o=r}};function tv(r,e,t,n,s,i,o,a,l){vs=!1,_o=null,Zm.apply(ev,arguments)}function rv(r,e,t,n,s,i,o,a,l){if(tv.apply(this,arguments),vs){if(vs){var c=_o;vs=!1,_o=null}else throw Error(F(198));wo||(wo=!0,Ll=c)}}function an(r){var e=r,t=r;if(r.alternate)for(;e.return;)e=e.return;else{r=e;do e=r,e.flags&4098&&(t=e.return),r=e.return;while(r)}return e.tag===3?t:null}function Ef(r){if(r.tag===13){var e=r.memoizedState;if(e===null&&(r=r.alternate,r!==null&&(e=r.memoizedState)),e!==null)return e.dehydrated}return null}function Qu(r){if(an(r)!==r)throw Error(F(188))}function nv(r){var e=r.alternate;if(!e){if(e=an(r),e===null)throw Error(F(188));return e!==r?null:r}for(var t=r,n=e;;){var s=t.return;if(s===null)break;var i=s.alternate;if(i===null){if(n=s.return,n!==null){t=n;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===t)return Qu(s),r;if(i===n)return Qu(s),e;i=i.sibling}throw Error(F(188))}if(t.return!==n.return)t=s,n=i;else{for(var o=!1,a=s.child;a;){if(a===t){o=!0,t=s,n=i;break}if(a===n){o=!0,n=s,t=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===t){o=!0,t=i,n=s;break}if(a===n){o=!0,n=i,t=s;break}a=a.sibling}if(!o)throw Error(F(189))}}if(t.alternate!==n)throw Error(F(190))}if(t.tag!==3)throw Error(F(188));return t.stateNode.current===t?r:e}function Df(r){return r=nv(r),r!==null?Pf(r):null}function Pf(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var e=Pf(r);if(e!==null)return e;r=r.sibling}return null}var Mf=rt.unstable_scheduleCallback,Ju=rt.unstable_cancelCallback,sv=rt.unstable_shouldYield,iv=rt.unstable_requestPaint,ge=rt.unstable_now,ov=rt.unstable_getCurrentPriorityLevel,Nc=rt.unstable_ImmediatePriority,jf=rt.unstable_UserBlockingPriority,So=rt.unstable_NormalPriority,av=rt.unstable_LowPriority,Af=rt.unstable_IdlePriority,sa=null,zt=null;function lv(r){if(zt&&typeof zt.onCommitFiberRoot=="function")try{zt.onCommitFiberRoot(sa,r,void 0,(r.current.flags&128)===128)}catch{}}var Ot=Math.clz32?Math.clz32:hv,cv=Math.log,uv=Math.LN2;function hv(r){return r>>>=0,r===0?32:31-(cv(r)/uv|0)|0}var ui=64,hi=4194304;function fs(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Co(r,e){var t=r.pendingLanes;if(t===0)return 0;var n=0,s=r.suspendedLanes,i=r.pingedLanes,o=t&268435455;if(o!==0){var a=o&~s;a!==0?n=fs(a):(i&=o,i!==0&&(n=fs(i)))}else o=t&~s,o!==0?n=fs(o):i!==0&&(n=fs(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=t&16),e=r.entangledLanes,e!==0)for(r=r.entanglements,e&=n;0<e;)t=31-Ot(e),s=1<<t,n|=r[t],e&=~s;return n}function dv(r,e){switch(r){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function fv(r,e){for(var t=r.suspendedLanes,n=r.pingedLanes,s=r.expirationTimes,i=r.pendingLanes;0<i;){var o=31-Ot(i),a=1<<o,l=s[o];l===-1?(!(a&t)||a&n)&&(s[o]=dv(a,e)):l<=e&&(r.expiredLanes|=a),i&=~a}}function Fl(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Lf(){var r=ui;return ui<<=1,!(ui&4194240)&&(ui=64),r}function Ra(r){for(var e=[],t=0;31>t;t++)e.push(r);return e}function Zs(r,e,t){r.pendingLanes|=e,e!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,e=31-Ot(e),r[e]=t}function gv(r,e){var t=r.pendingLanes&~e;r.pendingLanes=e,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=e,r.mutableReadLanes&=e,r.entangledLanes&=e,e=r.entanglements;var n=r.eventTimes;for(r=r.expirationTimes;0<t;){var s=31-Ot(t),i=1<<s;e[s]=0,n[s]=-1,r[s]=-1,t&=~i}}function Ic(r,e){var t=r.entangledLanes|=e;for(r=r.entanglements;t;){var n=31-Ot(t),s=1<<n;s&e|r[n]&e&&(r[n]|=e),t&=~s}}var Z=0;function Ff(r){return r&=-r,1<r?4<r?r&268435455?16:536870912:4:1}var Rf,zc,Nf,If,zf,Rl=!1,di=[],kr=null,Or=null,Er=null,js=new Map,As=new Map,_r=[],pv="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Zu(r,e){switch(r){case"focusin":case"focusout":kr=null;break;case"dragenter":case"dragleave":Or=null;break;case"mouseover":case"mouseout":Er=null;break;case"pointerover":case"pointerout":js.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":As.delete(e.pointerId)}}function ns(r,e,t,n,s,i){return r===null||r.nativeEvent!==i?(r={blockedOn:e,domEventName:t,eventSystemFlags:n,nativeEvent:i,targetContainers:[s]},e!==null&&(e=ti(e),e!==null&&zc(e)),r):(r.eventSystemFlags|=n,e=r.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),r)}function mv(r,e,t,n,s){switch(e){case"focusin":return kr=ns(kr,r,e,t,n,s),!0;case"dragenter":return Or=ns(Or,r,e,t,n,s),!0;case"mouseover":return Er=ns(Er,r,e,t,n,s),!0;case"pointerover":var i=s.pointerId;return js.set(i,ns(js.get(i)||null,r,e,t,n,s)),!0;case"gotpointercapture":return i=s.pointerId,As.set(i,ns(As.get(i)||null,r,e,t,n,s)),!0}return!1}function Bf(r){var e=Ur(r.target);if(e!==null){var t=an(e);if(t!==null){if(e=t.tag,e===13){if(e=Ef(t),e!==null){r.blockedOn=e,zf(r.priority,function(){Nf(t)});return}}else if(e===3&&t.stateNode.current.memoizedState.isDehydrated){r.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Zi(r){if(r.blockedOn!==null)return!1;for(var e=r.targetContainers;0<e.length;){var t=Nl(r.domEventName,r.eventSystemFlags,e[0],r.nativeEvent);if(t===null){t=r.nativeEvent;var n=new t.constructor(t.type,t);Ml=n,t.target.dispatchEvent(n),Ml=null}else return e=ti(t),e!==null&&zc(e),r.blockedOn=t,!1;e.shift()}return!0}function eh(r,e,t){Zi(r)&&t.delete(e)}function vv(){Rl=!1,kr!==null&&Zi(kr)&&(kr=null),Or!==null&&Zi(Or)&&(Or=null),Er!==null&&Zi(Er)&&(Er=null),js.forEach(eh),As.forEach(eh)}function ss(r,e){r.blockedOn===e&&(r.blockedOn=null,Rl||(Rl=!0,rt.unstable_scheduleCallback(rt.unstable_NormalPriority,vv)))}function Ls(r){function e(s){return ss(s,r)}if(0<di.length){ss(di[0],r);for(var t=1;t<di.length;t++){var n=di[t];n.blockedOn===r&&(n.blockedOn=null)}}for(kr!==null&&ss(kr,r),Or!==null&&ss(Or,r),Er!==null&&ss(Er,r),js.forEach(e),As.forEach(e),t=0;t<_r.length;t++)n=_r[t],n.blockedOn===r&&(n.blockedOn=null);for(;0<_r.length&&(t=_r[0],t.blockedOn===null);)Bf(t),t.blockedOn===null&&_r.shift()}var Mn=ur.ReactCurrentBatchConfig,bo=!0;function yv(r,e,t,n){var s=Z,i=Mn.transition;Mn.transition=null;try{Z=1,Bc(r,e,t,n)}finally{Z=s,Mn.transition=i}}function xv(r,e,t,n){var s=Z,i=Mn.transition;Mn.transition=null;try{Z=4,Bc(r,e,t,n)}finally{Z=s,Mn.transition=i}}function Bc(r,e,t,n){if(bo){var s=Nl(r,e,t,n);if(s===null)$a(r,e,n,To,t),Zu(r,n);else if(mv(s,r,e,t,n))n.stopPropagation();else if(Zu(r,n),e&4&&-1<pv.indexOf(r)){for(;s!==null;){var i=ti(s);if(i!==null&&Rf(i),i=Nl(r,e,t,n),i===null&&$a(r,e,n,To,t),i===s)break;s=i}s!==null&&n.stopPropagation()}else $a(r,e,n,null,t)}}var To=null;function Nl(r,e,t,n){if(To=null,r=Rc(n),r=Ur(r),r!==null)if(e=an(r),e===null)r=null;else if(t=e.tag,t===13){if(r=Ef(e),r!==null)return r;r=null}else if(t===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;r=null}else e!==r&&(r=null);return To=r,null}function Vf(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ov()){case Nc:return 1;case jf:return 4;case So:case av:return 16;case Af:return 536870912;default:return 16}default:return 16}}var Cr=null,Vc=null,eo=null;function Wf(){if(eo)return eo;var r,e=Vc,t=e.length,n,s="value"in Cr?Cr.value:Cr.textContent,i=s.length;for(r=0;r<t&&e[r]===s[r];r++);var o=t-r;for(n=1;n<=o&&e[t-n]===s[i-n];n++);return eo=s.slice(r,1<n?1-n:void 0)}function to(r){var e=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&e===13&&(r=13)):r=e,r===10&&(r=13),32<=r||r===13?r:0}function fi(){return!0}function th(){return!1}function st(r){function e(t,n,s,i,o){this._reactName=t,this._targetInst=s,this.type=n,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in r)r.hasOwnProperty(a)&&(t=r[a],this[a]=t?t(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?fi:th,this.isPropagationStopped=th,this}return he(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var t=this.nativeEvent;t&&(t.preventDefault?t.preventDefault():typeof t.returnValue!="unknown"&&(t.returnValue=!1),this.isDefaultPrevented=fi)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=fi)},persist:function(){},isPersistent:fi}),e}var $n={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Wc=st($n),ei=he({},$n,{view:0,detail:0}),_v=st(ei),Na,Ia,is,ia=he({},ei,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hc,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==is&&(is&&r.type==="mousemove"?(Na=r.screenX-is.screenX,Ia=r.screenY-is.screenY):Ia=Na=0,is=r),Na)},movementY:function(r){return"movementY"in r?r.movementY:Ia}}),rh=st(ia),wv=he({},ia,{dataTransfer:0}),Sv=st(wv),Cv=he({},ei,{relatedTarget:0}),za=st(Cv),bv=he({},$n,{animationName:0,elapsedTime:0,pseudoElement:0}),Tv=st(bv),kv=he({},$n,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Ov=st(kv),Ev=he({},$n,{data:0}),nh=st(Ev),Dv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Mv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function jv(r){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(r):(r=Mv[r])?!!e[r]:!1}function Hc(){return jv}var Av=he({},ei,{key:function(r){if(r.key){var e=Dv[r.key]||r.key;if(e!=="Unidentified")return e}return r.type==="keypress"?(r=to(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Pv[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hc,charCode:function(r){return r.type==="keypress"?to(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?to(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),Lv=st(Av),Fv=he({},ia,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sh=st(Fv),Rv=he({},ei,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hc}),Nv=st(Rv),Iv=he({},$n,{propertyName:0,elapsedTime:0,pseudoElement:0}),zv=st(Iv),Bv=he({},ia,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Vv=st(Bv),Wv=[9,13,27,32],Xc=rr&&"CompositionEvent"in window,ys=null;rr&&"documentMode"in document&&(ys=document.documentMode);var Hv=rr&&"TextEvent"in window&&!ys,Hf=rr&&(!Xc||ys&&8<ys&&11>=ys),ih=" ",oh=!1;function Xf(r,e){switch(r){case"keyup":return Wv.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uf(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var pn=!1;function Xv(r,e){switch(r){case"compositionend":return Uf(e);case"keypress":return e.which!==32?null:(oh=!0,ih);case"textInput":return r=e.data,r===ih&&oh?null:r;default:return null}}function Uv(r,e){if(pn)return r==="compositionend"||!Xc&&Xf(r,e)?(r=Wf(),eo=Vc=Cr=null,pn=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return Hf&&e.locale!=="ko"?null:e.data;default:return null}}var $v={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ah(r){var e=r&&r.nodeName&&r.nodeName.toLowerCase();return e==="input"?!!$v[r.type]:e==="textarea"}function $f(r,e,t,n){Cf(n),e=ko(e,"onChange"),0<e.length&&(t=new Wc("onChange","change",null,t,n),r.push({event:t,listeners:e}))}var xs=null,Fs=null;function Yv(r){ng(r,0)}function oa(r){var e=yn(r);if(mf(e))return r}function Gv(r,e){if(r==="change")return e}var Yf=!1;if(rr){var Ba;if(rr){var Va="oninput"in document;if(!Va){var lh=document.createElement("div");lh.setAttribute("oninput","return;"),Va=typeof lh.oninput=="function"}Ba=Va}else Ba=!1;Yf=Ba&&(!document.documentMode||9<document.documentMode)}function ch(){xs&&(xs.detachEvent("onpropertychange",Gf),Fs=xs=null)}function Gf(r){if(r.propertyName==="value"&&oa(Fs)){var e=[];$f(e,Fs,r,Rc(r)),Of(Yv,e)}}function Kv(r,e,t){r==="focusin"?(ch(),xs=e,Fs=t,xs.attachEvent("onpropertychange",Gf)):r==="focusout"&&ch()}function qv(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return oa(Fs)}function Qv(r,e){if(r==="click")return oa(e)}function Jv(r,e){if(r==="input"||r==="change")return oa(e)}function Zv(r,e){return r===e&&(r!==0||1/r===1/e)||r!==r&&e!==e}var Pt=typeof Object.is=="function"?Object.is:Zv;function Rs(r,e){if(Pt(r,e))return!0;if(typeof r!="object"||r===null||typeof e!="object"||e===null)return!1;var t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(n=0;n<t.length;n++){var s=t[n];if(!xl.call(e,s)||!Pt(r[s],e[s]))return!1}return!0}function uh(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function hh(r,e){var t=uh(r);r=0;for(var n;t;){if(t.nodeType===3){if(n=r+t.textContent.length,r<=e&&n>=e)return{node:t,offset:e-r};r=n}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=uh(t)}}function Kf(r,e){return r&&e?r===e?!0:r&&r.nodeType===3?!1:e&&e.nodeType===3?Kf(r,e.parentNode):"contains"in r?r.contains(e):r.compareDocumentPosition?!!(r.compareDocumentPosition(e)&16):!1:!1}function qf(){for(var r=window,e=xo();e instanceof r.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)r=e.contentWindow;else break;e=xo(r.document)}return e}function Uc(r){var e=r&&r.nodeName&&r.nodeName.toLowerCase();return e&&(e==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||e==="textarea"||r.contentEditable==="true")}function ey(r){var e=qf(),t=r.focusedElem,n=r.selectionRange;if(e!==t&&t&&t.ownerDocument&&Kf(t.ownerDocument.documentElement,t)){if(n!==null&&Uc(t)){if(e=n.start,r=n.end,r===void 0&&(r=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(r,t.value.length);else if(r=(e=t.ownerDocument||document)&&e.defaultView||window,r.getSelection){r=r.getSelection();var s=t.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!r.extend&&i>n&&(s=n,n=i,i=s),s=hh(t,i);var o=hh(t,n);s&&o&&(r.rangeCount!==1||r.anchorNode!==s.node||r.anchorOffset!==s.offset||r.focusNode!==o.node||r.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),r.removeAllRanges(),i>n?(r.addRange(e),r.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),r.addRange(e)))}}for(e=[],r=t;r=r.parentNode;)r.nodeType===1&&e.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t<e.length;t++)r=e[t],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var ty=rr&&"documentMode"in document&&11>=document.documentMode,mn=null,Il=null,_s=null,zl=!1;function dh(r,e,t){var n=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;zl||mn==null||mn!==xo(n)||(n=mn,"selectionStart"in n&&Uc(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),_s&&Rs(_s,n)||(_s=n,n=ko(Il,"onSelect"),0<n.length&&(e=new Wc("onSelect","select",null,e,t),r.push({event:e,listeners:n}),e.target=mn)))}function gi(r,e){var t={};return t[r.toLowerCase()]=e.toLowerCase(),t["Webkit"+r]="webkit"+e,t["Moz"+r]="moz"+e,t}var vn={animationend:gi("Animation","AnimationEnd"),animationiteration:gi("Animation","AnimationIteration"),animationstart:gi("Animation","AnimationStart"),transitionend:gi("Transition","TransitionEnd")},Wa={},Qf={};rr&&(Qf=document.createElement("div").style,"AnimationEvent"in window||(delete vn.animationend.animation,delete vn.animationiteration.animation,delete vn.animationstart.animation),"TransitionEvent"in window||delete vn.transitionend.transition);function aa(r){if(Wa[r])return Wa[r];if(!vn[r])return r;var e=vn[r],t;for(t in e)if(e.hasOwnProperty(t)&&t in Qf)return Wa[r]=e[t];return r}var Jf=aa("animationend"),Zf=aa("animationiteration"),eg=aa("animationstart"),tg=aa("transitionend"),rg=new Map,fh="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ir(r,e){rg.set(r,e),on(e,[r])}for(var Ha=0;Ha<fh.length;Ha++){var Xa=fh[Ha],ry=Xa.toLowerCase(),ny=Xa[0].toUpperCase()+Xa.slice(1);Ir(ry,"on"+ny)}Ir(Jf,"onAnimationEnd");Ir(Zf,"onAnimationIteration");Ir(eg,"onAnimationStart");Ir("dblclick","onDoubleClick");Ir("focusin","onFocus");Ir("focusout","onBlur");Ir(tg,"onTransitionEnd");Nn("onMouseEnter",["mouseout","mouseover"]);Nn("onMouseLeave",["mouseout","mouseover"]);Nn("onPointerEnter",["pointerout","pointerover"]);Nn("onPointerLeave",["pointerout","pointerover"]);on("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));on("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));on("onBeforeInput",["compositionend","keypress","textInput","paste"]);on("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));on("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));on("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var gs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),sy=new Set("cancel close invalid load scroll toggle".split(" ").concat(gs));function gh(r,e,t){var n=r.type||"unknown-event";r.currentTarget=t,rv(n,e,void 0,r),r.currentTarget=null}function ng(r,e){e=(e&4)!==0;for(var t=0;t<r.length;t++){var n=r[t],s=n.event;n=n.listeners;e:{var i=void 0;if(e)for(var o=n.length-1;0<=o;o--){var a=n[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==i&&s.isPropagationStopped())break e;gh(s,a,c),i=l}else for(o=0;o<n.length;o++){if(a=n[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==i&&s.isPropagationStopped())break e;gh(s,a,c),i=l}}}if(wo)throw r=Ll,wo=!1,Ll=null,r}function ne(r,e){var t=e[Xl];t===void 0&&(t=e[Xl]=new Set);var n=r+"__bubble";t.has(n)||(sg(e,r,2,!1),t.add(n))}function Ua(r,e,t){var n=0;e&&(n|=4),sg(t,r,n,e)}var pi="_reactListening"+Math.random().toString(36).slice(2);function Ns(r){if(!r[pi]){r[pi]=!0,hf.forEach(function(t){t!=="selectionchange"&&(sy.has(t)||Ua(t,!1,r),Ua(t,!0,r))});var e=r.nodeType===9?r:r.ownerDocument;e===null||e[pi]||(e[pi]=!0,Ua("selectionchange",!1,e))}}function sg(r,e,t,n){switch(Vf(e)){case 1:var s=yv;break;case 4:s=xv;break;default:s=Bc}t=s.bind(null,e,t,r),s=void 0,!Al||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),n?s!==void 0?r.addEventListener(e,t,{capture:!0,passive:s}):r.addEventListener(e,t,!0):s!==void 0?r.addEventListener(e,t,{passive:s}):r.addEventListener(e,t,!1)}function $a(r,e,t,n,s){var i=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var o=n.tag;if(o===3||o===4){var a=n.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=n.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;o=o.return}for(;a!==null;){if(o=Ur(a),o===null)return;if(l=o.tag,l===5||l===6){n=i=o;continue e}a=a.parentNode}}n=n.return}Of(function(){var c=i,u=Rc(t),h=[];e:{var d=rg.get(r);if(d!==void 0){var f=Wc,m=r;switch(r){case"keypress":if(to(t)===0)break e;case"keydown":case"keyup":f=Lv;break;case"focusin":m="focus",f=za;break;case"focusout":m="blur",f=za;break;case"beforeblur":case"afterblur":f=za;break;case"click":if(t.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=rh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=Sv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=Nv;break;case Jf:case Zf:case eg:f=Tv;break;case tg:f=zv;break;case"scroll":f=_v;break;case"wheel":f=Vv;break;case"copy":case"cut":case"paste":f=Ov;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=sh}var v=(e&4)!==0,w=!v&&r==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var p=c,y;p!==null;){y=p;var x=y.stateNode;if(y.tag===5&&x!==null&&(y=x,g!==null&&(x=Ms(p,g),x!=null&&v.push(Is(p,x,y)))),w)break;p=p.return}0<v.length&&(d=new f(d,m,null,t,u),h.push({event:d,listeners:v}))}}if(!(e&7)){e:{if(d=r==="mouseover"||r==="pointerover",f=r==="mouseout"||r==="pointerout",d&&t!==Ml&&(m=t.relatedTarget||t.fromElement)&&(Ur(m)||m[nr]))break e;if((f||d)&&(d=u.window===u?u:(d=u.ownerDocument)?d.defaultView||d.parentWindow:window,f?(m=t.relatedTarget||t.toElement,f=c,m=m?Ur(m):null,m!==null&&(w=an(m),m!==w||m.tag!==5&&m.tag!==6)&&(m=null)):(f=null,m=c),f!==m)){if(v=rh,x="onMouseLeave",g="onMouseEnter",p="mouse",(r==="pointerout"||r==="pointerover")&&(v=sh,x="onPointerLeave",g="onPointerEnter",p="pointer"),w=f==null?d:yn(f),y=m==null?d:yn(m),d=new v(x,p+"leave",f,t,u),d.target=w,d.relatedTarget=y,x=null,Ur(u)===c&&(v=new v(g,p+"enter",m,t,u),v.target=y,v.relatedTarget=w,x=v),w=x,f&&m)t:{for(v=f,g=m,p=0,y=v;y;y=cn(y))p++;for(y=0,x=g;x;x=cn(x))y++;for(;0<p-y;)v=cn(v),p--;for(;0<y-p;)g=cn(g),y--;for(;p--;){if(v===g||g!==null&&v===g.alternate)break t;v=cn(v),g=cn(g)}v=null}else v=null;f!==null&&ph(h,d,f,v,!1),m!==null&&w!==null&&ph(h,w,m,v,!0)}}e:{if(d=c?yn(c):window,f=d.nodeName&&d.nodeName.toLowerCase(),f==="select"||f==="input"&&d.type==="file")var _=Gv;else if(ah(d))if(Yf)_=Jv;else{_=qv;var E=Kv}else(f=d.nodeName)&&f.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(_=Qv);if(_&&(_=_(r,c))){$f(h,_,t,u);break e}E&&E(r,d,c),r==="focusout"&&(E=d._wrapperState)&&E.controlled&&d.type==="number"&&kl(d,"number",d.value)}switch(E=c?yn(c):window,r){case"focusin":(ah(E)||E.contentEditable==="true")&&(mn=E,Il=c,_s=null);break;case"focusout":_s=Il=mn=null;break;case"mousedown":zl=!0;break;case"contextmenu":case"mouseup":case"dragend":zl=!1,dh(h,t,u);break;case"selectionchange":if(ty)break;case"keydown":case"keyup":dh(h,t,u)}var D;if(Xc)e:{switch(r){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else pn?Xf(r,t)&&(k="onCompositionEnd"):r==="keydown"&&t.keyCode===229&&(k="onCompositionStart");k&&(Hf&&t.locale!=="ko"&&(pn||k!=="onCompositionStart"?k==="onCompositionEnd"&&pn&&(D=Wf()):(Cr=u,Vc="value"in Cr?Cr.value:Cr.textContent,pn=!0)),E=ko(c,k),0<E.length&&(k=new nh(k,r,null,t,u),h.push({event:k,listeners:E}),D?k.data=D:(D=Uf(t),D!==null&&(k.data=D)))),(D=Hv?Xv(r,t):Uv(r,t))&&(c=ko(c,"onBeforeInput"),0<c.length&&(u=new nh("onBeforeInput","beforeinput",null,t,u),h.push({event:u,listeners:c}),u.data=D))}ng(h,e)})}function Is(r,e,t){return{instance:r,listener:e,currentTarget:t}}function ko(r,e){for(var t=e+"Capture",n=[];r!==null;){var s=r,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Ms(r,t),i!=null&&n.unshift(Is(r,i,s)),i=Ms(r,e),i!=null&&n.push(Is(r,i,s))),r=r.return}return n}function cn(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function ph(r,e,t,n,s){for(var i=e._reactName,o=[];t!==null&&t!==n;){var a=t,l=a.alternate,c=a.stateNode;if(l!==null&&l===n)break;a.tag===5&&c!==null&&(a=c,s?(l=Ms(t,i),l!=null&&o.unshift(Is(t,l,a))):s||(l=Ms(t,i),l!=null&&o.push(Is(t,l,a)))),t=t.return}o.length!==0&&r.push({event:e,listeners:o})}var iy=/\r\n?/g,oy=/\u0000|\uFFFD/g;function mh(r){return(typeof r=="string"?r:""+r).replace(iy,`
38
- `).replace(oy,"")}function mi(r,e,t){if(e=mh(e),mh(r)!==e&&t)throw Error(F(425))}function Oo(){}var Bl=null,Vl=null;function Wl(r,e){return r==="textarea"||r==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var Hl=typeof setTimeout=="function"?setTimeout:void 0,ay=typeof clearTimeout=="function"?clearTimeout:void 0,vh=typeof Promise=="function"?Promise:void 0,ly=typeof queueMicrotask=="function"?queueMicrotask:typeof vh<"u"?function(r){return vh.resolve(null).then(r).catch(cy)}:Hl;function cy(r){setTimeout(function(){throw r})}function Ya(r,e){var t=e,n=0;do{var s=t.nextSibling;if(r.removeChild(t),s&&s.nodeType===8)if(t=s.data,t==="/$"){if(n===0){r.removeChild(s),Ls(e);return}n--}else t!=="$"&&t!=="$?"&&t!=="$!"||n++;t=s}while(t);Ls(e)}function Dr(r){for(;r!=null;r=r.nextSibling){var e=r.nodeType;if(e===1||e===3)break;if(e===8){if(e=r.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return r}function yh(r){r=r.previousSibling;for(var e=0;r;){if(r.nodeType===8){var t=r.data;if(t==="$"||t==="$!"||t==="$?"){if(e===0)return r;e--}else t==="/$"&&e++}r=r.previousSibling}return null}var Yn=Math.random().toString(36).slice(2),Ft="__reactFiber$"+Yn,zs="__reactProps$"+Yn,nr="__reactContainer$"+Yn,Xl="__reactEvents$"+Yn,uy="__reactListeners$"+Yn,hy="__reactHandles$"+Yn;function Ur(r){var e=r[Ft];if(e)return e;for(var t=r.parentNode;t;){if(e=t[nr]||t[Ft]){if(t=e.alternate,e.child!==null||t!==null&&t.child!==null)for(r=yh(r);r!==null;){if(t=r[Ft])return t;r=yh(r)}return e}r=t,t=r.parentNode}return null}function ti(r){return r=r[Ft]||r[nr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function yn(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(F(33))}function la(r){return r[zs]||null}var Ul=[],xn=-1;function zr(r){return{current:r}}function se(r){0>xn||(r.current=Ul[xn],Ul[xn]=null,xn--)}function re(r,e){xn++,Ul[xn]=r.current,r.current=e}var Fr={},je=zr(Fr),Ue=zr(!1),Zr=Fr;function In(r,e){var t=r.type.contextTypes;if(!t)return Fr;var n=r.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in t)s[i]=e[i];return n&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=e,r.__reactInternalMemoizedMaskedChildContext=s),s}function $e(r){return r=r.childContextTypes,r!=null}function Eo(){se(Ue),se(je)}function xh(r,e,t){if(je.current!==Fr)throw Error(F(168));re(je,e),re(Ue,t)}function ig(r,e,t){var n=r.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return t;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(F(108,Km(r)||"Unknown",s));return he({},t,n)}function Do(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Fr,Zr=je.current,re(je,r),re(Ue,Ue.current),!0}function _h(r,e,t){var n=r.stateNode;if(!n)throw Error(F(169));t?(r=ig(r,e,Zr),n.__reactInternalMemoizedMergedChildContext=r,se(Ue),se(je),re(je,r)):se(Ue),re(Ue,t)}var Yt=null,ca=!1,Ga=!1;function og(r){Yt===null?Yt=[r]:Yt.push(r)}function dy(r){ca=!0,og(r)}function Br(){if(!Ga&&Yt!==null){Ga=!0;var r=0,e=Z;try{var t=Yt;for(Z=1;r<t.length;r++){var n=t[r];do n=n(!0);while(n!==null)}Yt=null,ca=!1}catch(s){throw Yt!==null&&(Yt=Yt.slice(r+1)),Mf(Nc,Br),s}finally{Z=e,Ga=!1}}return null}var _n=[],wn=0,Po=null,Mo=0,at=[],lt=0,en=null,Kt=1,qt="";function Wr(r,e){_n[wn++]=Mo,_n[wn++]=Po,Po=r,Mo=e}function ag(r,e,t){at[lt++]=Kt,at[lt++]=qt,at[lt++]=en,en=r;var n=Kt;r=qt;var s=32-Ot(n)-1;n&=~(1<<s),t+=1;var i=32-Ot(e)+s;if(30<i){var o=s-s%5;i=(n&(1<<o)-1).toString(32),n>>=o,s-=o,Kt=1<<32-Ot(e)+s|t<<s|n,qt=i+r}else Kt=1<<i|t<<s|n,qt=r}function $c(r){r.return!==null&&(Wr(r,1),ag(r,1,0))}function Yc(r){for(;r===Po;)Po=_n[--wn],_n[wn]=null,Mo=_n[--wn],_n[wn]=null;for(;r===en;)en=at[--lt],at[lt]=null,qt=at[--lt],at[lt]=null,Kt=at[--lt],at[lt]=null}var tt=null,et=null,oe=!1,St=null;function lg(r,e){var t=ut(5,null,null,0);t.elementType="DELETED",t.stateNode=e,t.return=r,e=r.deletions,e===null?(r.deletions=[t],r.flags|=16):e.push(t)}function wh(r,e){switch(r.tag){case 5:var t=r.type;return e=e.nodeType!==1||t.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(r.stateNode=e,tt=r,et=Dr(e.firstChild),!0):!1;case 6:return e=r.pendingProps===""||e.nodeType!==3?null:e,e!==null?(r.stateNode=e,tt=r,et=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(t=en!==null?{id:Kt,overflow:qt}:null,r.memoizedState={dehydrated:e,treeContext:t,retryLane:1073741824},t=ut(18,null,null,0),t.stateNode=e,t.return=r,r.child=t,tt=r,et=null,!0):!1;default:return!1}}function $l(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Yl(r){if(oe){var e=et;if(e){var t=e;if(!wh(r,e)){if($l(r))throw Error(F(418));e=Dr(t.nextSibling);var n=tt;e&&wh(r,e)?lg(n,t):(r.flags=r.flags&-4097|2,oe=!1,tt=r)}}else{if($l(r))throw Error(F(418));r.flags=r.flags&-4097|2,oe=!1,tt=r}}}function Sh(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;tt=r}function vi(r){if(r!==tt)return!1;if(!oe)return Sh(r),oe=!0,!1;var e;if((e=r.tag!==3)&&!(e=r.tag!==5)&&(e=r.type,e=e!=="head"&&e!=="body"&&!Wl(r.type,r.memoizedProps)),e&&(e=et)){if($l(r))throw cg(),Error(F(418));for(;e;)lg(r,e),e=Dr(e.nextSibling)}if(Sh(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(F(317));e:{for(r=r.nextSibling,e=0;r;){if(r.nodeType===8){var t=r.data;if(t==="/$"){if(e===0){et=Dr(r.nextSibling);break e}e--}else t!=="$"&&t!=="$!"&&t!=="$?"||e++}r=r.nextSibling}et=null}}else et=tt?Dr(r.stateNode.nextSibling):null;return!0}function cg(){for(var r=et;r;)r=Dr(r.nextSibling)}function zn(){et=tt=null,oe=!1}function Gc(r){St===null?St=[r]:St.push(r)}var fy=ur.ReactCurrentBatchConfig;function os(r,e,t){if(r=t.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(t._owner){if(t=t._owner,t){if(t.tag!==1)throw Error(F(309));var n=t.stateNode}if(!n)throw Error(F(147,r));var s=n,i=""+r;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},e._stringRef=i,e)}if(typeof r!="string")throw Error(F(284));if(!t._owner)throw Error(F(290,r))}return r}function yi(r,e){throw r=Object.prototype.toString.call(e),Error(F(31,r==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":r))}function Ch(r){var e=r._init;return e(r._payload)}function ug(r){function e(g,p){if(r){var y=g.deletions;y===null?(g.deletions=[p],g.flags|=16):y.push(p)}}function t(g,p){if(!r)return null;for(;p!==null;)e(g,p),p=p.sibling;return null}function n(g,p){for(g=new Map;p!==null;)p.key!==null?g.set(p.key,p):g.set(p.index,p),p=p.sibling;return g}function s(g,p){return g=Ar(g,p),g.index=0,g.sibling=null,g}function i(g,p,y){return g.index=y,r?(y=g.alternate,y!==null?(y=y.index,y<p?(g.flags|=2,p):y):(g.flags|=2,p)):(g.flags|=1048576,p)}function o(g){return r&&g.alternate===null&&(g.flags|=2),g}function a(g,p,y,x){return p===null||p.tag!==6?(p=tl(y,g.mode,x),p.return=g,p):(p=s(p,y),p.return=g,p)}function l(g,p,y,x){var _=y.type;return _===gn?u(g,p,y.props.children,x,y.key):p!==null&&(p.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===yr&&Ch(_)===p.type)?(x=s(p,y.props),x.ref=os(g,p,y),x.return=g,x):(x=lo(y.type,y.key,y.props,null,g.mode,x),x.ref=os(g,p,y),x.return=g,x)}function c(g,p,y,x){return p===null||p.tag!==4||p.stateNode.containerInfo!==y.containerInfo||p.stateNode.implementation!==y.implementation?(p=rl(y,g.mode,x),p.return=g,p):(p=s(p,y.children||[]),p.return=g,p)}function u(g,p,y,x,_){return p===null||p.tag!==7?(p=Qr(y,g.mode,x,_),p.return=g,p):(p=s(p,y),p.return=g,p)}function h(g,p,y){if(typeof p=="string"&&p!==""||typeof p=="number")return p=tl(""+p,g.mode,y),p.return=g,p;if(typeof p=="object"&&p!==null){switch(p.$$typeof){case ai:return y=lo(p.type,p.key,p.props,null,g.mode,y),y.ref=os(g,null,p),y.return=g,y;case fn:return p=rl(p,g.mode,y),p.return=g,p;case yr:var x=p._init;return h(g,x(p._payload),y)}if(ds(p)||ts(p))return p=Qr(p,g.mode,y,null),p.return=g,p;yi(g,p)}return null}function d(g,p,y,x){var _=p!==null?p.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return _!==null?null:a(g,p,""+y,x);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case ai:return y.key===_?l(g,p,y,x):null;case fn:return y.key===_?c(g,p,y,x):null;case yr:return _=y._init,d(g,p,_(y._payload),x)}if(ds(y)||ts(y))return _!==null?null:u(g,p,y,x,null);yi(g,y)}return null}function f(g,p,y,x,_){if(typeof x=="string"&&x!==""||typeof x=="number")return g=g.get(y)||null,a(p,g,""+x,_);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case ai:return g=g.get(x.key===null?y:x.key)||null,l(p,g,x,_);case fn:return g=g.get(x.key===null?y:x.key)||null,c(p,g,x,_);case yr:var E=x._init;return f(g,p,y,E(x._payload),_)}if(ds(x)||ts(x))return g=g.get(y)||null,u(p,g,x,_,null);yi(p,x)}return null}function m(g,p,y,x){for(var _=null,E=null,D=p,k=p=0,N=null;D!==null&&k<y.length;k++){D.index>k?(N=D,D=null):N=D.sibling;var L=d(g,D,y[k],x);if(L===null){D===null&&(D=N);break}r&&D&&L.alternate===null&&e(g,D),p=i(L,p,k),E===null?_=L:E.sibling=L,E=L,D=N}if(k===y.length)return t(g,D),oe&&Wr(g,k),_;if(D===null){for(;k<y.length;k++)D=h(g,y[k],x),D!==null&&(p=i(D,p,k),E===null?_=D:E.sibling=D,E=D);return oe&&Wr(g,k),_}for(D=n(g,D);k<y.length;k++)N=f(D,g,k,y[k],x),N!==null&&(r&&N.alternate!==null&&D.delete(N.key===null?k:N.key),p=i(N,p,k),E===null?_=N:E.sibling=N,E=N);return r&&D.forEach(function(X){return e(g,X)}),oe&&Wr(g,k),_}function v(g,p,y,x){var _=ts(y);if(typeof _!="function")throw Error(F(150));if(y=_.call(y),y==null)throw Error(F(151));for(var E=_=null,D=p,k=p=0,N=null,L=y.next();D!==null&&!L.done;k++,L=y.next()){D.index>k?(N=D,D=null):N=D.sibling;var X=d(g,D,L.value,x);if(X===null){D===null&&(D=N);break}r&&D&&X.alternate===null&&e(g,D),p=i(X,p,k),E===null?_=X:E.sibling=X,E=X,D=N}if(L.done)return t(g,D),oe&&Wr(g,k),_;if(D===null){for(;!L.done;k++,L=y.next())L=h(g,L.value,x),L!==null&&(p=i(L,p,k),E===null?_=L:E.sibling=L,E=L);return oe&&Wr(g,k),_}for(D=n(g,D);!L.done;k++,L=y.next())L=f(D,g,k,L.value,x),L!==null&&(r&&L.alternate!==null&&D.delete(L.key===null?k:L.key),p=i(L,p,k),E===null?_=L:E.sibling=L,E=L);return r&&D.forEach(function(T){return e(g,T)}),oe&&Wr(g,k),_}function w(g,p,y,x){if(typeof y=="object"&&y!==null&&y.type===gn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case ai:e:{for(var _=y.key,E=p;E!==null;){if(E.key===_){if(_=y.type,_===gn){if(E.tag===7){t(g,E.sibling),p=s(E,y.props.children),p.return=g,g=p;break e}}else if(E.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===yr&&Ch(_)===E.type){t(g,E.sibling),p=s(E,y.props),p.ref=os(g,E,y),p.return=g,g=p;break e}t(g,E);break}else e(g,E);E=E.sibling}y.type===gn?(p=Qr(y.props.children,g.mode,x,y.key),p.return=g,g=p):(x=lo(y.type,y.key,y.props,null,g.mode,x),x.ref=os(g,p,y),x.return=g,g=x)}return o(g);case fn:e:{for(E=y.key;p!==null;){if(p.key===E)if(p.tag===4&&p.stateNode.containerInfo===y.containerInfo&&p.stateNode.implementation===y.implementation){t(g,p.sibling),p=s(p,y.children||[]),p.return=g,g=p;break e}else{t(g,p);break}else e(g,p);p=p.sibling}p=rl(y,g.mode,x),p.return=g,g=p}return o(g);case yr:return E=y._init,w(g,p,E(y._payload),x)}if(ds(y))return m(g,p,y,x);if(ts(y))return v(g,p,y,x);yi(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,p!==null&&p.tag===6?(t(g,p.sibling),p=s(p,y),p.return=g,g=p):(t(g,p),p=tl(y,g.mode,x),p.return=g,g=p),o(g)):t(g,p)}return w}var Bn=ug(!0),hg=ug(!1),jo=zr(null),Ao=null,Sn=null,Kc=null;function qc(){Kc=Sn=Ao=null}function Qc(r){var e=jo.current;se(jo),r._currentValue=e}function Gl(r,e,t){for(;r!==null;){var n=r.alternate;if((r.childLanes&e)!==e?(r.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),r===t)break;r=r.return}}function jn(r,e){Ao=r,Kc=Sn=null,r=r.dependencies,r!==null&&r.firstContext!==null&&(r.lanes&e&&(Xe=!0),r.firstContext=null)}function dt(r){var e=r._currentValue;if(Kc!==r)if(r={context:r,memoizedValue:e,next:null},Sn===null){if(Ao===null)throw Error(F(308));Sn=r,Ao.dependencies={lanes:0,firstContext:r}}else Sn=Sn.next=r;return e}var $r=null;function Jc(r){$r===null?$r=[r]:$r.push(r)}function dg(r,e,t,n){var s=e.interleaved;return s===null?(t.next=t,Jc(e)):(t.next=s.next,s.next=t),e.interleaved=t,sr(r,n)}function sr(r,e){r.lanes|=e;var t=r.alternate;for(t!==null&&(t.lanes|=e),t=r,r=r.return;r!==null;)r.childLanes|=e,t=r.alternate,t!==null&&(t.childLanes|=e),t=r,r=r.return;return t.tag===3?t.stateNode:null}var xr=!1;function Zc(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fg(r,e){r=r.updateQueue,e.updateQueue===r&&(e.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function er(r,e){return{eventTime:r,lane:e,tag:0,payload:null,callback:null,next:null}}function Pr(r,e,t){var n=r.updateQueue;if(n===null)return null;if(n=n.shared,K&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,sr(r,t)}return s=n.interleaved,s===null?(e.next=e,Jc(n)):(e.next=s.next,s.next=e),n.interleaved=e,sr(r,t)}function ro(r,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194240)!==0)){var n=e.lanes;n&=r.pendingLanes,t|=n,e.lanes=t,Ic(r,t)}}function bh(r,e){var t=r.updateQueue,n=r.alternate;if(n!==null&&(n=n.updateQueue,t===n)){var s=null,i=null;if(t=t.firstBaseUpdate,t!==null){do{var o={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};i===null?s=i=o:i=i.next=o,t=t.next}while(t!==null);i===null?s=i=e:i=i.next=e}else s=i=e;t={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},r.updateQueue=t;return}r=t.lastBaseUpdate,r===null?t.firstBaseUpdate=e:r.next=e,t.lastBaseUpdate=e}function Lo(r,e,t,n){var s=r.updateQueue;xr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?i=c:o.next=c,o=l;var u=r.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(i!==null){var h=s.baseState;o=0,u=c=l=null,a=i;do{var d=a.lane,f=a.eventTime;if((n&d)===d){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var m=r,v=a;switch(d=e,f=t,v.tag){case 1:if(m=v.payload,typeof m=="function"){h=m.call(f,h,d);break e}h=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=v.payload,d=typeof m=="function"?m.call(f,h,d):m,d==null)break e;h=he({},h,d);break e;case 2:xr=!0}}a.callback!==null&&a.lane!==0&&(r.flags|=64,d=s.effects,d===null?s.effects=[a]:d.push(a))}else f={eventTime:f,lane:d,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=f,l=h):u=u.next=f,o|=d;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;d=a,a=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(u===null&&(l=h),s.baseState=l,s.firstBaseUpdate=c,s.lastBaseUpdate=u,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);rn|=o,r.lanes=o,r.memoizedState=h}}function Th(r,e,t){if(r=e.effects,e.effects=null,r!==null)for(e=0;e<r.length;e++){var n=r[e],s=n.callback;if(s!==null){if(n.callback=null,n=t,typeof s!="function")throw Error(F(191,s));s.call(n)}}}var ri={},Bt=zr(ri),Bs=zr(ri),Vs=zr(ri);function Yr(r){if(r===ri)throw Error(F(174));return r}function eu(r,e){switch(re(Vs,e),re(Bs,r),re(Bt,ri),r=e.nodeType,r){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:El(null,"");break;default:r=r===8?e.parentNode:e,e=r.namespaceURI||null,r=r.tagName,e=El(e,r)}se(Bt),re(Bt,e)}function Vn(){se(Bt),se(Bs),se(Vs)}function gg(r){Yr(Vs.current);var e=Yr(Bt.current),t=El(e,r.type);e!==t&&(re(Bs,r),re(Bt,t))}function tu(r){Bs.current===r&&(se(Bt),se(Bs))}var ce=zr(0);function Fo(r){for(var e=r;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break;for(;e.sibling===null;){if(e.return===null||e.return===r)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Ka=[];function ru(){for(var r=0;r<Ka.length;r++)Ka[r]._workInProgressVersionPrimary=null;Ka.length=0}var no=ur.ReactCurrentDispatcher,qa=ur.ReactCurrentBatchConfig,tn=0,ue=null,ye=null,Se=null,Ro=!1,ws=!1,Ws=0,gy=0;function Ee(){throw Error(F(321))}function nu(r,e){if(e===null)return!1;for(var t=0;t<e.length&&t<r.length;t++)if(!Pt(r[t],e[t]))return!1;return!0}function su(r,e,t,n,s,i){if(tn=i,ue=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,no.current=r===null||r.memoizedState===null?yy:xy,r=t(n,s),ws){i=0;do{if(ws=!1,Ws=0,25<=i)throw Error(F(301));i+=1,Se=ye=null,e.updateQueue=null,no.current=_y,r=t(n,s)}while(ws)}if(no.current=No,e=ye!==null&&ye.next!==null,tn=0,Se=ye=ue=null,Ro=!1,e)throw Error(F(300));return r}function iu(){var r=Ws!==0;return Ws=0,r}function At(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Se===null?ue.memoizedState=Se=r:Se=Se.next=r,Se}function ft(){if(ye===null){var r=ue.alternate;r=r!==null?r.memoizedState:null}else r=ye.next;var e=Se===null?ue.memoizedState:Se.next;if(e!==null)Se=e,ye=r;else{if(r===null)throw Error(F(310));ye=r,r={memoizedState:ye.memoizedState,baseState:ye.baseState,baseQueue:ye.baseQueue,queue:ye.queue,next:null},Se===null?ue.memoizedState=Se=r:Se=Se.next=r}return Se}function Hs(r,e){return typeof e=="function"?e(r):e}function Qa(r){var e=ft(),t=e.queue;if(t===null)throw Error(F(311));t.lastRenderedReducer=r;var n=ye,s=n.baseQueue,i=t.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}n.baseQueue=s=i,t.pending=null}if(s!==null){i=s.next,n=n.baseState;var a=o=null,l=null,c=i;do{var u=c.lane;if((tn&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),n=c.hasEagerState?c.eagerState:r(n,c.action);else{var h={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=h,o=n):l=l.next=h,ue.lanes|=u,rn|=u}c=c.next}while(c!==null&&c!==i);l===null?o=n:l.next=a,Pt(n,e.memoizedState)||(Xe=!0),e.memoizedState=n,e.baseState=o,e.baseQueue=l,t.lastRenderedState=n}if(r=t.interleaved,r!==null){s=r;do i=s.lane,ue.lanes|=i,rn|=i,s=s.next;while(s!==r)}else s===null&&(t.lanes=0);return[e.memoizedState,t.dispatch]}function Ja(r){var e=ft(),t=e.queue;if(t===null)throw Error(F(311));t.lastRenderedReducer=r;var n=t.dispatch,s=t.pending,i=e.memoizedState;if(s!==null){t.pending=null;var o=s=s.next;do i=r(i,o.action),o=o.next;while(o!==s);Pt(i,e.memoizedState)||(Xe=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),t.lastRenderedState=i}return[i,n]}function pg(){}function mg(r,e){var t=ue,n=ft(),s=e(),i=!Pt(n.memoizedState,s);if(i&&(n.memoizedState=s,Xe=!0),n=n.queue,ou(xg.bind(null,t,n,r),[r]),n.getSnapshot!==e||i||Se!==null&&Se.memoizedState.tag&1){if(t.flags|=2048,Xs(9,yg.bind(null,t,n,s,e),void 0,null),Ce===null)throw Error(F(349));tn&30||vg(t,e,s)}return s}function vg(r,e,t){r.flags|=16384,r={getSnapshot:e,value:t},e=ue.updateQueue,e===null?(e={lastEffect:null,stores:null},ue.updateQueue=e,e.stores=[r]):(t=e.stores,t===null?e.stores=[r]:t.push(r))}function yg(r,e,t,n){e.value=t,e.getSnapshot=n,_g(e)&&wg(r)}function xg(r,e,t){return t(function(){_g(e)&&wg(r)})}function _g(r){var e=r.getSnapshot;r=r.value;try{var t=e();return!Pt(r,t)}catch{return!0}}function wg(r){var e=sr(r,1);e!==null&&Et(e,r,1,-1)}function kh(r){var e=At();return typeof r=="function"&&(r=r()),e.memoizedState=e.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:r},e.queue=r,r=r.dispatch=vy.bind(null,ue,r),[e.memoizedState,r]}function Xs(r,e,t,n){return r={tag:r,create:e,destroy:t,deps:n,next:null},e=ue.updateQueue,e===null?(e={lastEffect:null,stores:null},ue.updateQueue=e,e.lastEffect=r.next=r):(t=e.lastEffect,t===null?e.lastEffect=r.next=r:(n=t.next,t.next=r,r.next=n,e.lastEffect=r)),r}function Sg(){return ft().memoizedState}function so(r,e,t,n){var s=At();ue.flags|=r,s.memoizedState=Xs(1|e,t,void 0,n===void 0?null:n)}function ua(r,e,t,n){var s=ft();n=n===void 0?null:n;var i=void 0;if(ye!==null){var o=ye.memoizedState;if(i=o.destroy,n!==null&&nu(n,o.deps)){s.memoizedState=Xs(e,t,i,n);return}}ue.flags|=r,s.memoizedState=Xs(1|e,t,i,n)}function Oh(r,e){return so(8390656,8,r,e)}function ou(r,e){return ua(2048,8,r,e)}function Cg(r,e){return ua(4,2,r,e)}function bg(r,e){return ua(4,4,r,e)}function Tg(r,e){if(typeof e=="function")return r=r(),e(r),function(){e(null)};if(e!=null)return r=r(),e.current=r,function(){e.current=null}}function kg(r,e,t){return t=t!=null?t.concat([r]):null,ua(4,4,Tg.bind(null,e,r),t)}function au(){}function Og(r,e){var t=ft();e=e===void 0?null:e;var n=t.memoizedState;return n!==null&&e!==null&&nu(e,n[1])?n[0]:(t.memoizedState=[r,e],r)}function Eg(r,e){var t=ft();e=e===void 0?null:e;var n=t.memoizedState;return n!==null&&e!==null&&nu(e,n[1])?n[0]:(r=r(),t.memoizedState=[r,e],r)}function Dg(r,e,t){return tn&21?(Pt(t,e)||(t=Lf(),ue.lanes|=t,rn|=t,r.baseState=!0),e):(r.baseState&&(r.baseState=!1,Xe=!0),r.memoizedState=t)}function py(r,e){var t=Z;Z=t!==0&&4>t?t:4,r(!0);var n=qa.transition;qa.transition={};try{r(!1),e()}finally{Z=t,qa.transition=n}}function Pg(){return ft().memoizedState}function my(r,e,t){var n=jr(r);if(t={lane:n,action:t,hasEagerState:!1,eagerState:null,next:null},Mg(r))jg(e,t);else if(t=dg(r,e,t,n),t!==null){var s=Ie();Et(t,r,n,s),Ag(t,e,n)}}function vy(r,e,t){var n=jr(r),s={lane:n,action:t,hasEagerState:!1,eagerState:null,next:null};if(Mg(r))jg(e,s);else{var i=r.alternate;if(r.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,t);if(s.hasEagerState=!0,s.eagerState=a,Pt(a,o)){var l=e.interleaved;l===null?(s.next=s,Jc(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}t=dg(r,e,s,n),t!==null&&(s=Ie(),Et(t,r,n,s),Ag(t,e,n))}}function Mg(r){var e=r.alternate;return r===ue||e!==null&&e===ue}function jg(r,e){ws=Ro=!0;var t=r.pending;t===null?e.next=e:(e.next=t.next,t.next=e),r.pending=e}function Ag(r,e,t){if(t&4194240){var n=e.lanes;n&=r.pendingLanes,t|=n,e.lanes=t,Ic(r,t)}}var No={readContext:dt,useCallback:Ee,useContext:Ee,useEffect:Ee,useImperativeHandle:Ee,useInsertionEffect:Ee,useLayoutEffect:Ee,useMemo:Ee,useReducer:Ee,useRef:Ee,useState:Ee,useDebugValue:Ee,useDeferredValue:Ee,useTransition:Ee,useMutableSource:Ee,useSyncExternalStore:Ee,useId:Ee,unstable_isNewReconciler:!1},yy={readContext:dt,useCallback:function(r,e){return At().memoizedState=[r,e===void 0?null:e],r},useContext:dt,useEffect:Oh,useImperativeHandle:function(r,e,t){return t=t!=null?t.concat([r]):null,so(4194308,4,Tg.bind(null,e,r),t)},useLayoutEffect:function(r,e){return so(4194308,4,r,e)},useInsertionEffect:function(r,e){return so(4,2,r,e)},useMemo:function(r,e){var t=At();return e=e===void 0?null:e,r=r(),t.memoizedState=[r,e],r},useReducer:function(r,e,t){var n=At();return e=t!==void 0?t(e):e,n.memoizedState=n.baseState=e,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:e},n.queue=r,r=r.dispatch=my.bind(null,ue,r),[n.memoizedState,r]},useRef:function(r){var e=At();return r={current:r},e.memoizedState=r},useState:kh,useDebugValue:au,useDeferredValue:function(r){return At().memoizedState=r},useTransition:function(){var r=kh(!1),e=r[0];return r=py.bind(null,r[1]),At().memoizedState=r,[e,r]},useMutableSource:function(){},useSyncExternalStore:function(r,e,t){var n=ue,s=At();if(oe){if(t===void 0)throw Error(F(407));t=t()}else{if(t=e(),Ce===null)throw Error(F(349));tn&30||vg(n,e,t)}s.memoizedState=t;var i={value:t,getSnapshot:e};return s.queue=i,Oh(xg.bind(null,n,i,r),[r]),n.flags|=2048,Xs(9,yg.bind(null,n,i,t,e),void 0,null),t},useId:function(){var r=At(),e=Ce.identifierPrefix;if(oe){var t=qt,n=Kt;t=(n&~(1<<32-Ot(n)-1)).toString(32)+t,e=":"+e+"R"+t,t=Ws++,0<t&&(e+="H"+t.toString(32)),e+=":"}else t=gy++,e=":"+e+"r"+t.toString(32)+":";return r.memoizedState=e},unstable_isNewReconciler:!1},xy={readContext:dt,useCallback:Og,useContext:dt,useEffect:ou,useImperativeHandle:kg,useInsertionEffect:Cg,useLayoutEffect:bg,useMemo:Eg,useReducer:Qa,useRef:Sg,useState:function(){return Qa(Hs)},useDebugValue:au,useDeferredValue:function(r){var e=ft();return Dg(e,ye.memoizedState,r)},useTransition:function(){var r=Qa(Hs)[0],e=ft().memoizedState;return[r,e]},useMutableSource:pg,useSyncExternalStore:mg,useId:Pg,unstable_isNewReconciler:!1},_y={readContext:dt,useCallback:Og,useContext:dt,useEffect:ou,useImperativeHandle:kg,useInsertionEffect:Cg,useLayoutEffect:bg,useMemo:Eg,useReducer:Ja,useRef:Sg,useState:function(){return Ja(Hs)},useDebugValue:au,useDeferredValue:function(r){var e=ft();return ye===null?e.memoizedState=r:Dg(e,ye.memoizedState,r)},useTransition:function(){var r=Ja(Hs)[0],e=ft().memoizedState;return[r,e]},useMutableSource:pg,useSyncExternalStore:mg,useId:Pg,unstable_isNewReconciler:!1};function xt(r,e){if(r&&r.defaultProps){e=he({},e),r=r.defaultProps;for(var t in r)e[t]===void 0&&(e[t]=r[t]);return e}return e}function Kl(r,e,t,n){e=r.memoizedState,t=t(n,e),t=t==null?e:he({},e,t),r.memoizedState=t,r.lanes===0&&(r.updateQueue.baseState=t)}var ha={isMounted:function(r){return(r=r._reactInternals)?an(r)===r:!1},enqueueSetState:function(r,e,t){r=r._reactInternals;var n=Ie(),s=jr(r),i=er(n,s);i.payload=e,t!=null&&(i.callback=t),e=Pr(r,i,s),e!==null&&(Et(e,r,s,n),ro(e,r,s))},enqueueReplaceState:function(r,e,t){r=r._reactInternals;var n=Ie(),s=jr(r),i=er(n,s);i.tag=1,i.payload=e,t!=null&&(i.callback=t),e=Pr(r,i,s),e!==null&&(Et(e,r,s,n),ro(e,r,s))},enqueueForceUpdate:function(r,e){r=r._reactInternals;var t=Ie(),n=jr(r),s=er(t,n);s.tag=2,e!=null&&(s.callback=e),e=Pr(r,s,n),e!==null&&(Et(e,r,n,t),ro(e,r,n))}};function Eh(r,e,t,n,s,i,o){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(n,i,o):e.prototype&&e.prototype.isPureReactComponent?!Rs(t,n)||!Rs(s,i):!0}function Lg(r,e,t){var n=!1,s=Fr,i=e.contextType;return typeof i=="object"&&i!==null?i=dt(i):(s=$e(e)?Zr:je.current,n=e.contextTypes,i=(n=n!=null)?In(r,s):Fr),e=new e(t,i),r.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=ha,r.stateNode=e,e._reactInternals=r,n&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=i),e}function Dh(r,e,t,n){r=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(t,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(t,n),e.state!==r&&ha.enqueueReplaceState(e,e.state,null)}function ql(r,e,t,n){var s=r.stateNode;s.props=t,s.state=r.memoizedState,s.refs={},Zc(r);var i=e.contextType;typeof i=="object"&&i!==null?s.context=dt(i):(i=$e(e)?Zr:je.current,s.context=In(r,i)),s.state=r.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(Kl(r,e,i,t),s.state=r.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&ha.enqueueReplaceState(s,s.state,null),Lo(r,t,s,n),s.state=r.memoizedState),typeof s.componentDidMount=="function"&&(r.flags|=4194308)}function Wn(r,e){try{var t="",n=e;do t+=Gm(n),n=n.return;while(n);var s=t}catch(i){s=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:r,source:e,stack:s,digest:null}}function Za(r,e,t){return{value:r,source:null,stack:t??null,digest:e??null}}function Ql(r,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var wy=typeof WeakMap=="function"?WeakMap:Map;function Fg(r,e,t){t=er(-1,t),t.tag=3,t.payload={element:null};var n=e.value;return t.callback=function(){zo||(zo=!0,ac=n),Ql(r,e)},t}function Rg(r,e,t){t=er(-1,t),t.tag=3;var n=r.type.getDerivedStateFromError;if(typeof n=="function"){var s=e.value;t.payload=function(){return n(s)},t.callback=function(){Ql(r,e)}}var i=r.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(t.callback=function(){Ql(r,e),typeof n!="function"&&(Mr===null?Mr=new Set([this]):Mr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),t}function Ph(r,e,t){var n=r.pingCache;if(n===null){n=r.pingCache=new wy;var s=new Set;n.set(e,s)}else s=n.get(e),s===void 0&&(s=new Set,n.set(e,s));s.has(t)||(s.add(t),r=Fy.bind(null,r,e,t),e.then(r,r))}function Mh(r){do{var e;if((e=r.tag===13)&&(e=r.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return r;r=r.return}while(r!==null);return null}function jh(r,e,t,n,s){return r.mode&1?(r.flags|=65536,r.lanes=s,r):(r===e?r.flags|=65536:(r.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(e=er(-1,1),e.tag=2,Pr(t,e,1))),t.lanes|=1),r)}var Sy=ur.ReactCurrentOwner,Xe=!1;function Le(r,e,t,n){e.child=r===null?hg(e,null,t,n):Bn(e,r.child,t,n)}function Ah(r,e,t,n,s){t=t.render;var i=e.ref;return jn(e,s),n=su(r,e,t,n,i,s),t=iu(),r!==null&&!Xe?(e.updateQueue=r.updateQueue,e.flags&=-2053,r.lanes&=~s,ir(r,e,s)):(oe&&t&&$c(e),e.flags|=1,Le(r,e,n,s),e.child)}function Lh(r,e,t,n,s){if(r===null){var i=t.type;return typeof i=="function"&&!pu(i)&&i.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=i,Ng(r,e,i,n,s)):(r=lo(t.type,null,n,e,e.mode,s),r.ref=e.ref,r.return=e,e.child=r)}if(i=r.child,!(r.lanes&s)){var o=i.memoizedProps;if(t=t.compare,t=t!==null?t:Rs,t(o,n)&&r.ref===e.ref)return ir(r,e,s)}return e.flags|=1,r=Ar(i,n),r.ref=e.ref,r.return=e,e.child=r}function Ng(r,e,t,n,s){if(r!==null){var i=r.memoizedProps;if(Rs(i,n)&&r.ref===e.ref)if(Xe=!1,e.pendingProps=n=i,(r.lanes&s)!==0)r.flags&131072&&(Xe=!0);else return e.lanes=r.lanes,ir(r,e,s)}return Jl(r,e,t,n,s)}function Ig(r,e,t){var n=e.pendingProps,s=n.children,i=r!==null?r.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},re(bn,Ze),Ze|=t;else{if(!(t&1073741824))return r=i!==null?i.baseLanes|t:t,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:r,cachePool:null,transitions:null},e.updateQueue=null,re(bn,Ze),Ze|=r,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:t,re(bn,Ze),Ze|=n}else i!==null?(n=i.baseLanes|t,e.memoizedState=null):n=t,re(bn,Ze),Ze|=n;return Le(r,e,s,t),e.child}function zg(r,e){var t=e.ref;(r===null&&t!==null||r!==null&&r.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function Jl(r,e,t,n,s){var i=$e(t)?Zr:je.current;return i=In(e,i),jn(e,s),t=su(r,e,t,n,i,s),n=iu(),r!==null&&!Xe?(e.updateQueue=r.updateQueue,e.flags&=-2053,r.lanes&=~s,ir(r,e,s)):(oe&&n&&$c(e),e.flags|=1,Le(r,e,t,s),e.child)}function Fh(r,e,t,n,s){if($e(t)){var i=!0;Do(e)}else i=!1;if(jn(e,s),e.stateNode===null)io(r,e),Lg(e,t,n),ql(e,t,n,s),n=!0;else if(r===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,c=t.contextType;typeof c=="object"&&c!==null?c=dt(c):(c=$e(t)?Zr:je.current,c=In(e,c));var u=t.getDerivedStateFromProps,h=typeof u=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==c)&&Dh(e,o,n,c),xr=!1;var d=e.memoizedState;o.state=d,Lo(e,n,o,s),l=e.memoizedState,a!==n||d!==l||Ue.current||xr?(typeof u=="function"&&(Kl(e,t,u,n),l=e.memoizedState),(a=xr||Eh(e,t,a,n,d,l,c))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=l),o.props=n,o.state=l,o.context=c,n=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{o=e.stateNode,fg(r,e),a=e.memoizedProps,c=e.type===e.elementType?a:xt(e.type,a),o.props=c,h=e.pendingProps,d=o.context,l=t.contextType,typeof l=="object"&&l!==null?l=dt(l):(l=$e(t)?Zr:je.current,l=In(e,l));var f=t.getDerivedStateFromProps;(u=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==h||d!==l)&&Dh(e,o,n,l),xr=!1,d=e.memoizedState,o.state=d,Lo(e,n,o,s);var m=e.memoizedState;a!==h||d!==m||Ue.current||xr?(typeof f=="function"&&(Kl(e,t,f,n),m=e.memoizedState),(c=xr||Eh(e,t,c,n,d,m,l)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,m,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,m,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=m),o.props=n,o.state=m,o.context=l,n=c):(typeof o.componentDidUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=1024),n=!1)}return Zl(r,e,t,n,i,s)}function Zl(r,e,t,n,s,i){zg(r,e);var o=(e.flags&128)!==0;if(!n&&!o)return s&&_h(e,t,!1),ir(r,e,i);n=e.stateNode,Sy.current=e;var a=o&&typeof t.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,r!==null&&o?(e.child=Bn(e,r.child,null,i),e.child=Bn(e,null,a,i)):Le(r,e,a,i),e.memoizedState=n.state,s&&_h(e,t,!0),e.child}function Bg(r){var e=r.stateNode;e.pendingContext?xh(r,e.pendingContext,e.pendingContext!==e.context):e.context&&xh(r,e.context,!1),eu(r,e.containerInfo)}function Rh(r,e,t,n,s){return zn(),Gc(s),e.flags|=256,Le(r,e,t,n),e.child}var ec={dehydrated:null,treeContext:null,retryLane:0};function tc(r){return{baseLanes:r,cachePool:null,transitions:null}}function Vg(r,e,t){var n=e.pendingProps,s=ce.current,i=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=r!==null&&r.memoizedState===null?!1:(s&2)!==0),a?(i=!0,e.flags&=-129):(r===null||r.memoizedState!==null)&&(s|=1),re(ce,s&1),r===null)return Yl(e),r=e.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?(e.mode&1?r.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=n.children,r=n.fallback,i?(n=e.mode,i=e.child,o={mode:"hidden",children:o},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=ga(o,n,0,null),r=Qr(r,n,t,null),i.return=e,r.return=e,i.sibling=r,e.child=i,e.child.memoizedState=tc(t),e.memoizedState=ec,r):lu(e,o));if(s=r.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return Cy(r,e,o,n,a,s,t);if(i){i=n.fallback,o=e.mode,s=r.child,a=s.sibling;var l={mode:"hidden",children:n.children};return!(o&1)&&e.child!==s?(n=e.child,n.childLanes=0,n.pendingProps=l,e.deletions=null):(n=Ar(s,l),n.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=Ar(a,i):(i=Qr(i,o,t,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,o=r.child.memoizedState,o=o===null?tc(t):{baseLanes:o.baseLanes|t,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=r.childLanes&~t,e.memoizedState=ec,n}return i=r.child,r=i.sibling,n=Ar(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=t),n.return=e,n.sibling=null,r!==null&&(t=e.deletions,t===null?(e.deletions=[r],e.flags|=16):t.push(r)),e.child=n,e.memoizedState=null,n}function lu(r,e){return e=ga({mode:"visible",children:e},r.mode,0,null),e.return=r,r.child=e}function xi(r,e,t,n){return n!==null&&Gc(n),Bn(e,r.child,null,t),r=lu(e,e.pendingProps.children),r.flags|=2,e.memoizedState=null,r}function Cy(r,e,t,n,s,i,o){if(t)return e.flags&256?(e.flags&=-257,n=Za(Error(F(422))),xi(r,e,o,n)):e.memoizedState!==null?(e.child=r.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=ga({mode:"visible",children:n.children},s,0,null),i=Qr(i,s,o,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&Bn(e,r.child,null,o),e.child.memoizedState=tc(o),e.memoizedState=ec,i);if(!(e.mode&1))return xi(r,e,o,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var a=n.dgst;return n=a,i=Error(F(419)),n=Za(i,n,void 0),xi(r,e,o,n)}if(a=(o&r.childLanes)!==0,Xe||a){if(n=Ce,n!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(n.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,sr(r,s),Et(n,r,s,-1))}return gu(),n=Za(Error(F(421))),xi(r,e,o,n)}return s.data==="$?"?(e.flags|=128,e.child=r.child,e=Ry.bind(null,r),s._reactRetry=e,null):(r=i.treeContext,et=Dr(s.nextSibling),tt=e,oe=!0,St=null,r!==null&&(at[lt++]=Kt,at[lt++]=qt,at[lt++]=en,Kt=r.id,qt=r.overflow,en=e),e=lu(e,n.children),e.flags|=4096,e)}function Nh(r,e,t){r.lanes|=e;var n=r.alternate;n!==null&&(n.lanes|=e),Gl(r.return,e,t)}function el(r,e,t,n,s){var i=r.memoizedState;i===null?r.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:t,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=t,i.tailMode=s)}function Wg(r,e,t){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(Le(r,e,n.children,t),n=ce.current,n&2)n=n&1|2,e.flags|=128;else{if(r!==null&&r.flags&128)e:for(r=e.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Nh(r,t,e);else if(r.tag===19)Nh(r,t,e);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}n&=1}if(re(ce,n),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(t=e.child,s=null;t!==null;)r=t.alternate,r!==null&&Fo(r)===null&&(s=t),t=t.sibling;t=s,t===null?(s=e.child,e.child=null):(s=t.sibling,t.sibling=null),el(e,!1,s,t,i);break;case"backwards":for(t=null,s=e.child,e.child=null;s!==null;){if(r=s.alternate,r!==null&&Fo(r)===null){e.child=s;break}r=s.sibling,s.sibling=t,t=s,s=r}el(e,!0,t,null,i);break;case"together":el(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function io(r,e){!(e.mode&1)&&r!==null&&(r.alternate=null,e.alternate=null,e.flags|=2)}function ir(r,e,t){if(r!==null&&(e.dependencies=r.dependencies),rn|=e.lanes,!(t&e.childLanes))return null;if(r!==null&&e.child!==r.child)throw Error(F(153));if(e.child!==null){for(r=e.child,t=Ar(r,r.pendingProps),e.child=t,t.return=e;r.sibling!==null;)r=r.sibling,t=t.sibling=Ar(r,r.pendingProps),t.return=e;t.sibling=null}return e.child}function by(r,e,t){switch(e.tag){case 3:Bg(e),zn();break;case 5:gg(e);break;case 1:$e(e.type)&&Do(e);break;case 4:eu(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;re(jo,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(re(ce,ce.current&1),e.flags|=128,null):t&e.child.childLanes?Vg(r,e,t):(re(ce,ce.current&1),r=ir(r,e,t),r!==null?r.sibling:null);re(ce,ce.current&1);break;case 19:if(n=(t&e.childLanes)!==0,r.flags&128){if(n)return Wg(r,e,t);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),re(ce,ce.current),n)break;return null;case 22:case 23:return e.lanes=0,Ig(r,e,t)}return ir(r,e,t)}var Hg,rc,Xg,Ug;Hg=function(r,e){for(var t=e.child;t!==null;){if(t.tag===5||t.tag===6)r.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};rc=function(){};Xg=function(r,e,t,n){var s=r.memoizedProps;if(s!==n){r=e.stateNode,Yr(Bt.current);var i=null;switch(t){case"input":s=bl(r,s),n=bl(r,n),i=[];break;case"select":s=he({},s,{value:void 0}),n=he({},n,{value:void 0}),i=[];break;case"textarea":s=Ol(r,s),n=Ol(r,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(r.onclick=Oo)}Dl(t,n);var o;t=null;for(c in s)if(!n.hasOwnProperty(c)&&s.hasOwnProperty(c)&&s[c]!=null)if(c==="style"){var a=s[c];for(o in a)a.hasOwnProperty(o)&&(t||(t={}),t[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Ds.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in n){var l=n[c];if(a=s!=null?s[c]:void 0,n.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(t||(t={}),t[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(t||(t={}),t[o]=l[o])}else t||(i||(i=[]),i.push(c,t)),t=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Ds.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&ne("scroll",r),i||a===l||(i=[])):(i=i||[]).push(c,l))}t&&(i=i||[]).push("style",t);var c=i;(e.updateQueue=c)&&(e.flags|=4)}};Ug=function(r,e,t,n){t!==n&&(e.flags|=4)};function as(r,e){if(!oe)switch(r.tailMode){case"hidden":e=r.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?r.tail=null:t.sibling=null;break;case"collapsed":t=r.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e||r.tail===null?r.tail=null:r.tail.sibling=null:n.sibling=null}}function De(r){var e=r.alternate!==null&&r.alternate.child===r.child,t=0,n=0;if(e)for(var s=r.child;s!==null;)t|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=r,s=s.sibling;else for(s=r.child;s!==null;)t|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=r,s=s.sibling;return r.subtreeFlags|=n,r.childLanes=t,e}function Ty(r,e,t){var n=e.pendingProps;switch(Yc(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return De(e),null;case 1:return $e(e.type)&&Eo(),De(e),null;case 3:return n=e.stateNode,Vn(),se(Ue),se(je),ru(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(r===null||r.child===null)&&(vi(e)?e.flags|=4:r===null||r.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,St!==null&&(uc(St),St=null))),rc(r,e),De(e),null;case 5:tu(e);var s=Yr(Vs.current);if(t=e.type,r!==null&&e.stateNode!=null)Xg(r,e,t,n,s),r.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(F(166));return De(e),null}if(r=Yr(Bt.current),vi(e)){n=e.stateNode,t=e.type;var i=e.memoizedProps;switch(n[Ft]=e,n[zs]=i,r=(e.mode&1)!==0,t){case"dialog":ne("cancel",n),ne("close",n);break;case"iframe":case"object":case"embed":ne("load",n);break;case"video":case"audio":for(s=0;s<gs.length;s++)ne(gs[s],n);break;case"source":ne("error",n);break;case"img":case"image":case"link":ne("error",n),ne("load",n);break;case"details":ne("toggle",n);break;case"input":$u(n,i),ne("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},ne("invalid",n);break;case"textarea":Gu(n,i),ne("invalid",n)}Dl(t,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?n.textContent!==a&&(i.suppressHydrationWarning!==!0&&mi(n.textContent,a,r),s=["children",a]):typeof a=="number"&&n.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&mi(n.textContent,a,r),s=["children",""+a]):Ds.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&ne("scroll",n)}switch(t){case"input":li(n),Yu(n,i,!0);break;case"textarea":li(n),Ku(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=Oo)}n=s,e.updateQueue=n,n!==null&&(e.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=xf(t)),r==="http://www.w3.org/1999/xhtml"?t==="script"?(r=o.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof n.is=="string"?r=o.createElement(t,{is:n.is}):(r=o.createElement(t),t==="select"&&(o=r,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):r=o.createElementNS(r,t),r[Ft]=e,r[zs]=n,Hg(r,e,!1,!1),e.stateNode=r;e:{switch(o=Pl(t,n),t){case"dialog":ne("cancel",r),ne("close",r),s=n;break;case"iframe":case"object":case"embed":ne("load",r),s=n;break;case"video":case"audio":for(s=0;s<gs.length;s++)ne(gs[s],r);s=n;break;case"source":ne("error",r),s=n;break;case"img":case"image":case"link":ne("error",r),ne("load",r),s=n;break;case"details":ne("toggle",r),s=n;break;case"input":$u(r,n),s=bl(r,n),ne("invalid",r);break;case"option":s=n;break;case"select":r._wrapperState={wasMultiple:!!n.multiple},s=he({},n,{value:void 0}),ne("invalid",r);break;case"textarea":Gu(r,n),s=Ol(r,n),ne("invalid",r);break;default:s=n}Dl(t,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?Sf(r,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&_f(r,l)):i==="children"?typeof l=="string"?(t!=="textarea"||l!=="")&&Ps(r,l):typeof l=="number"&&Ps(r,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Ds.hasOwnProperty(i)?l!=null&&i==="onScroll"&&ne("scroll",r):l!=null&&jc(r,i,l,o))}switch(t){case"input":li(r),Yu(r,n,!1);break;case"textarea":li(r),Ku(r);break;case"option":n.value!=null&&r.setAttribute("value",""+Lr(n.value));break;case"select":r.multiple=!!n.multiple,i=n.value,i!=null?En(r,!!n.multiple,i,!1):n.defaultValue!=null&&En(r,!!n.multiple,n.defaultValue,!0);break;default:typeof s.onClick=="function"&&(r.onclick=Oo)}switch(t){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return De(e),null;case 6:if(r&&e.stateNode!=null)Ug(r,e,r.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(F(166));if(t=Yr(Vs.current),Yr(Bt.current),vi(e)){if(n=e.stateNode,t=e.memoizedProps,n[Ft]=e,(i=n.nodeValue!==t)&&(r=tt,r!==null))switch(r.tag){case 3:mi(n.nodeValue,t,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&mi(n.nodeValue,t,(r.mode&1)!==0)}i&&(e.flags|=4)}else n=(t.nodeType===9?t:t.ownerDocument).createTextNode(n),n[Ft]=e,e.stateNode=n}return De(e),null;case 13:if(se(ce),n=e.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(oe&&et!==null&&e.mode&1&&!(e.flags&128))cg(),zn(),e.flags|=98560,i=!1;else if(i=vi(e),n!==null&&n.dehydrated!==null){if(r===null){if(!i)throw Error(F(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[Ft]=e}else zn(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;De(e),i=!1}else St!==null&&(uc(St),St=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=t,e):(n=n!==null,n!==(r!==null&&r.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(r===null||ce.current&1?xe===0&&(xe=3):gu())),e.updateQueue!==null&&(e.flags|=4),De(e),null);case 4:return Vn(),rc(r,e),r===null&&Ns(e.stateNode.containerInfo),De(e),null;case 10:return Qc(e.type._context),De(e),null;case 17:return $e(e.type)&&Eo(),De(e),null;case 19:if(se(ce),i=e.memoizedState,i===null)return De(e),null;if(n=(e.flags&128)!==0,o=i.rendering,o===null)if(n)as(i,!1);else{if(xe!==0||r!==null&&r.flags&128)for(r=e.child;r!==null;){if(o=Fo(r),o!==null){for(e.flags|=128,as(i,!1),n=o.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=t,t=e.child;t!==null;)i=t,r=n,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,r=o.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t=t.sibling;return re(ce,ce.current&1|2),e.child}r=r.sibling}i.tail!==null&&ge()>Hn&&(e.flags|=128,n=!0,as(i,!1),e.lanes=4194304)}else{if(!n)if(r=Fo(o),r!==null){if(e.flags|=128,n=!0,t=r.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),as(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!oe)return De(e),null}else 2*ge()-i.renderingStartTime>Hn&&t!==1073741824&&(e.flags|=128,n=!0,as(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(t=i.last,t!==null?t.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=ge(),e.sibling=null,t=ce.current,re(ce,n?t&1|2:t&1),e):(De(e),null);case 22:case 23:return fu(),n=e.memoizedState!==null,r!==null&&r.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?Ze&1073741824&&(De(e),e.subtreeFlags&6&&(e.flags|=8192)):De(e),null;case 24:return null;case 25:return null}throw Error(F(156,e.tag))}function ky(r,e){switch(Yc(e),e.tag){case 1:return $e(e.type)&&Eo(),r=e.flags,r&65536?(e.flags=r&-65537|128,e):null;case 3:return Vn(),se(Ue),se(je),ru(),r=e.flags,r&65536&&!(r&128)?(e.flags=r&-65537|128,e):null;case 5:return tu(e),null;case 13:if(se(ce),r=e.memoizedState,r!==null&&r.dehydrated!==null){if(e.alternate===null)throw Error(F(340));zn()}return r=e.flags,r&65536?(e.flags=r&-65537|128,e):null;case 19:return se(ce),null;case 4:return Vn(),null;case 10:return Qc(e.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var _i=!1,Pe=!1,Oy=typeof WeakSet=="function"?WeakSet:Set,H=null;function Cn(r,e){var t=r.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(n){de(r,e,n)}else t.current=null}function nc(r,e,t){try{t()}catch(n){de(r,e,n)}}var Ih=!1;function Ey(r,e){if(Bl=bo,r=qf(),Uc(r)){if("selectionStart"in r)var t={start:r.selectionStart,end:r.selectionEnd};else e:{t=(t=r.ownerDocument)&&t.defaultView||window;var n=t.getSelection&&t.getSelection();if(n&&n.rangeCount!==0){t=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{t.nodeType,i.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,u=0,h=r,d=null;t:for(;;){for(var f;h!==t||s!==0&&h.nodeType!==3||(a=o+s),h!==i||n!==0&&h.nodeType!==3||(l=o+n),h.nodeType===3&&(o+=h.nodeValue.length),(f=h.firstChild)!==null;)d=h,h=f;for(;;){if(h===r)break t;if(d===t&&++c===s&&(a=o),d===i&&++u===n&&(l=o),(f=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=f}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(Vl={focusedElem:r,selectionRange:t},bo=!1,H=e;H!==null;)if(e=H,r=e.child,(e.subtreeFlags&1028)!==0&&r!==null)r.return=e,H=r;else for(;H!==null;){e=H;try{var m=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,w=m.memoizedState,g=e.stateNode,p=g.getSnapshotBeforeUpdate(e.elementType===e.type?v:xt(e.type,v),w);g.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var y=e.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(x){de(e,e.return,x)}if(r=e.sibling,r!==null){r.return=e.return,H=r;break}H=e.return}return m=Ih,Ih=!1,m}function Ss(r,e,t){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&r)===r){var i=s.destroy;s.destroy=void 0,i!==void 0&&nc(e,t,i)}s=s.next}while(s!==n)}}function da(r,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&r)===r){var n=t.create;t.destroy=n()}t=t.next}while(t!==e)}}function sc(r){var e=r.ref;if(e!==null){var t=r.stateNode;switch(r.tag){case 5:r=t;break;default:r=t}typeof e=="function"?e(r):e.current=r}}function $g(r){var e=r.alternate;e!==null&&(r.alternate=null,$g(e)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(e=r.stateNode,e!==null&&(delete e[Ft],delete e[zs],delete e[Xl],delete e[uy],delete e[hy])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Yg(r){return r.tag===5||r.tag===3||r.tag===4}function zh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Yg(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function ic(r,e,t){var n=r.tag;if(n===5||n===6)r=r.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(r,e):t.insertBefore(r,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(r,t)):(e=t,e.appendChild(r)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Oo));else if(n!==4&&(r=r.child,r!==null))for(ic(r,e,t),r=r.sibling;r!==null;)ic(r,e,t),r=r.sibling}function oc(r,e,t){var n=r.tag;if(n===5||n===6)r=r.stateNode,e?t.insertBefore(r,e):t.appendChild(r);else if(n!==4&&(r=r.child,r!==null))for(oc(r,e,t),r=r.sibling;r!==null;)oc(r,e,t),r=r.sibling}var be=null,_t=!1;function pr(r,e,t){for(t=t.child;t!==null;)Gg(r,e,t),t=t.sibling}function Gg(r,e,t){if(zt&&typeof zt.onCommitFiberUnmount=="function")try{zt.onCommitFiberUnmount(sa,t)}catch{}switch(t.tag){case 5:Pe||Cn(t,e);case 6:var n=be,s=_t;be=null,pr(r,e,t),be=n,_t=s,be!==null&&(_t?(r=be,t=t.stateNode,r.nodeType===8?r.parentNode.removeChild(t):r.removeChild(t)):be.removeChild(t.stateNode));break;case 18:be!==null&&(_t?(r=be,t=t.stateNode,r.nodeType===8?Ya(r.parentNode,t):r.nodeType===1&&Ya(r,t),Ls(r)):Ya(be,t.stateNode));break;case 4:n=be,s=_t,be=t.stateNode.containerInfo,_t=!0,pr(r,e,t),be=n,_t=s;break;case 0:case 11:case 14:case 15:if(!Pe&&(n=t.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&nc(t,e,o),s=s.next}while(s!==n)}pr(r,e,t);break;case 1:if(!Pe&&(Cn(t,e),n=t.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=t.memoizedProps,n.state=t.memoizedState,n.componentWillUnmount()}catch(a){de(t,e,a)}pr(r,e,t);break;case 21:pr(r,e,t);break;case 22:t.mode&1?(Pe=(n=Pe)||t.memoizedState!==null,pr(r,e,t),Pe=n):pr(r,e,t);break;default:pr(r,e,t)}}function Bh(r){var e=r.updateQueue;if(e!==null){r.updateQueue=null;var t=r.stateNode;t===null&&(t=r.stateNode=new Oy),e.forEach(function(n){var s=Ny.bind(null,r,n);t.has(n)||(t.add(n),n.then(s,s))})}}function mt(r,e){var t=e.deletions;if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];try{var i=r,o=e,a=o;e:for(;a!==null;){switch(a.tag){case 5:be=a.stateNode,_t=!1;break e;case 3:be=a.stateNode.containerInfo,_t=!0;break e;case 4:be=a.stateNode.containerInfo,_t=!0;break e}a=a.return}if(be===null)throw Error(F(160));Gg(i,o,s),be=null,_t=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(c){de(s,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)Kg(e,r),e=e.sibling}function Kg(r,e){var t=r.alternate,n=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(mt(e,r),jt(r),n&4){try{Ss(3,r,r.return),da(3,r)}catch(v){de(r,r.return,v)}try{Ss(5,r,r.return)}catch(v){de(r,r.return,v)}}break;case 1:mt(e,r),jt(r),n&512&&t!==null&&Cn(t,t.return);break;case 5:if(mt(e,r),jt(r),n&512&&t!==null&&Cn(t,t.return),r.flags&32){var s=r.stateNode;try{Ps(s,"")}catch(v){de(r,r.return,v)}}if(n&4&&(s=r.stateNode,s!=null)){var i=r.memoizedProps,o=t!==null?t.memoizedProps:i,a=r.type,l=r.updateQueue;if(r.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&vf(s,i),Pl(a,o);var c=Pl(a,i);for(o=0;o<l.length;o+=2){var u=l[o],h=l[o+1];u==="style"?Sf(s,h):u==="dangerouslySetInnerHTML"?_f(s,h):u==="children"?Ps(s,h):jc(s,u,h,c)}switch(a){case"input":Tl(s,i);break;case"textarea":yf(s,i);break;case"select":var d=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var f=i.value;f!=null?En(s,!!i.multiple,f,!1):d!==!!i.multiple&&(i.defaultValue!=null?En(s,!!i.multiple,i.defaultValue,!0):En(s,!!i.multiple,i.multiple?[]:"",!1))}s[zs]=i}catch(v){de(r,r.return,v)}}break;case 6:if(mt(e,r),jt(r),n&4){if(r.stateNode===null)throw Error(F(162));s=r.stateNode,i=r.memoizedProps;try{s.nodeValue=i}catch(v){de(r,r.return,v)}}break;case 3:if(mt(e,r),jt(r),n&4&&t!==null&&t.memoizedState.isDehydrated)try{Ls(e.containerInfo)}catch(v){de(r,r.return,v)}break;case 4:mt(e,r),jt(r);break;case 13:mt(e,r),jt(r),s=r.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(hu=ge())),n&4&&Bh(r);break;case 22:if(u=t!==null&&t.memoizedState!==null,r.mode&1?(Pe=(c=Pe)||u,mt(e,r),Pe=c):mt(e,r),jt(r),n&8192){if(c=r.memoizedState!==null,(r.stateNode.isHidden=c)&&!u&&r.mode&1)for(H=r,u=r.child;u!==null;){for(h=H=u;H!==null;){switch(d=H,f=d.child,d.tag){case 0:case 11:case 14:case 15:Ss(4,d,d.return);break;case 1:Cn(d,d.return);var m=d.stateNode;if(typeof m.componentWillUnmount=="function"){n=d,t=d.return;try{e=n,m.props=e.memoizedProps,m.state=e.memoizedState,m.componentWillUnmount()}catch(v){de(n,t,v)}}break;case 5:Cn(d,d.return);break;case 22:if(d.memoizedState!==null){Wh(h);continue}}f!==null?(f.return=d,H=f):Wh(h)}u=u.sibling}e:for(u=null,h=r;;){if(h.tag===5){if(u===null){u=h;try{s=h.stateNode,c?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=h.stateNode,l=h.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=wf("display",o))}catch(v){de(r,r.return,v)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(v){de(r,r.return,v)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===r)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===r)break e;for(;h.sibling===null;){if(h.return===null||h.return===r)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:mt(e,r),jt(r),n&4&&Bh(r);break;case 21:break;default:mt(e,r),jt(r)}}function jt(r){var e=r.flags;if(e&2){try{e:{for(var t=r.return;t!==null;){if(Yg(t)){var n=t;break e}t=t.return}throw Error(F(160))}switch(n.tag){case 5:var s=n.stateNode;n.flags&32&&(Ps(s,""),n.flags&=-33);var i=zh(r);oc(r,i,s);break;case 3:case 4:var o=n.stateNode.containerInfo,a=zh(r);ic(r,a,o);break;default:throw Error(F(161))}}catch(l){de(r,r.return,l)}r.flags&=-3}e&4096&&(r.flags&=-4097)}function Dy(r,e,t){H=r,qg(r)}function qg(r,e,t){for(var n=(r.mode&1)!==0;H!==null;){var s=H,i=s.child;if(s.tag===22&&n){var o=s.memoizedState!==null||_i;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||Pe;a=_i;var c=Pe;if(_i=o,(Pe=l)&&!c)for(H=s;H!==null;)o=H,l=o.child,o.tag===22&&o.memoizedState!==null?Hh(s):l!==null?(l.return=o,H=l):Hh(s);for(;i!==null;)H=i,qg(i),i=i.sibling;H=s,_i=a,Pe=c}Vh(r)}else s.subtreeFlags&8772&&i!==null?(i.return=s,H=i):Vh(r)}}function Vh(r){for(;H!==null;){var e=H;if(e.flags&8772){var t=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Pe||da(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Pe)if(t===null)n.componentDidMount();else{var s=e.elementType===e.type?t.memoizedProps:xt(e.type,t.memoizedProps);n.componentDidUpdate(s,t.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&Th(e,i,n);break;case 3:var o=e.updateQueue;if(o!==null){if(t=null,e.child!==null)switch(e.child.tag){case 5:t=e.child.stateNode;break;case 1:t=e.child.stateNode}Th(e,o,t)}break;case 5:var a=e.stateNode;if(t===null&&e.flags&4){t=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&t.focus();break;case"img":l.src&&(t.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&Ls(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}Pe||e.flags&512&&sc(e)}catch(d){de(e,e.return,d)}}if(e===r){H=null;break}if(t=e.sibling,t!==null){t.return=e.return,H=t;break}H=e.return}}function Wh(r){for(;H!==null;){var e=H;if(e===r){H=null;break}var t=e.sibling;if(t!==null){t.return=e.return,H=t;break}H=e.return}}function Hh(r){for(;H!==null;){var e=H;try{switch(e.tag){case 0:case 11:case 15:var t=e.return;try{da(4,e)}catch(l){de(e,t,l)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var s=e.return;try{n.componentDidMount()}catch(l){de(e,s,l)}}var i=e.return;try{sc(e)}catch(l){de(e,i,l)}break;case 5:var o=e.return;try{sc(e)}catch(l){de(e,o,l)}}}catch(l){de(e,e.return,l)}if(e===r){H=null;break}var a=e.sibling;if(a!==null){a.return=e.return,H=a;break}H=e.return}}var Py=Math.ceil,Io=ur.ReactCurrentDispatcher,cu=ur.ReactCurrentOwner,ht=ur.ReactCurrentBatchConfig,K=0,Ce=null,ve=null,ke=0,Ze=0,bn=zr(0),xe=0,Us=null,rn=0,fa=0,uu=0,Cs=null,He=null,hu=0,Hn=1/0,Ut=null,zo=!1,ac=null,Mr=null,wi=!1,br=null,Bo=0,bs=0,lc=null,oo=-1,ao=0;function Ie(){return K&6?ge():oo!==-1?oo:oo=ge()}function jr(r){return r.mode&1?K&2&&ke!==0?ke&-ke:fy.transition!==null?(ao===0&&(ao=Lf()),ao):(r=Z,r!==0||(r=window.event,r=r===void 0?16:Vf(r.type)),r):1}function Et(r,e,t,n){if(50<bs)throw bs=0,lc=null,Error(F(185));Zs(r,t,n),(!(K&2)||r!==Ce)&&(r===Ce&&(!(K&2)&&(fa|=t),xe===4&&wr(r,ke)),Ye(r,n),t===1&&K===0&&!(e.mode&1)&&(Hn=ge()+500,ca&&Br()))}function Ye(r,e){var t=r.callbackNode;fv(r,e);var n=Co(r,r===Ce?ke:0);if(n===0)t!==null&&Ju(t),r.callbackNode=null,r.callbackPriority=0;else if(e=n&-n,r.callbackPriority!==e){if(t!=null&&Ju(t),e===1)r.tag===0?dy(Xh.bind(null,r)):og(Xh.bind(null,r)),ly(function(){!(K&6)&&Br()}),t=null;else{switch(Ff(n)){case 1:t=Nc;break;case 4:t=jf;break;case 16:t=So;break;case 536870912:t=Af;break;default:t=So}t=sp(t,Qg.bind(null,r))}r.callbackPriority=e,r.callbackNode=t}}function Qg(r,e){if(oo=-1,ao=0,K&6)throw Error(F(327));var t=r.callbackNode;if(An()&&r.callbackNode!==t)return null;var n=Co(r,r===Ce?ke:0);if(n===0)return null;if(n&30||n&r.expiredLanes||e)e=Vo(r,n);else{e=n;var s=K;K|=2;var i=Zg();(Ce!==r||ke!==e)&&(Ut=null,Hn=ge()+500,qr(r,e));do try{Ay();break}catch(a){Jg(r,a)}while(!0);qc(),Io.current=i,K=s,ve!==null?e=0:(Ce=null,ke=0,e=xe)}if(e!==0){if(e===2&&(s=Fl(r),s!==0&&(n=s,e=cc(r,s))),e===1)throw t=Us,qr(r,0),wr(r,n),Ye(r,ge()),t;if(e===6)wr(r,n);else{if(s=r.current.alternate,!(n&30)&&!My(s)&&(e=Vo(r,n),e===2&&(i=Fl(r),i!==0&&(n=i,e=cc(r,i))),e===1))throw t=Us,qr(r,0),wr(r,n),Ye(r,ge()),t;switch(r.finishedWork=s,r.finishedLanes=n,e){case 0:case 1:throw Error(F(345));case 2:Hr(r,He,Ut);break;case 3:if(wr(r,n),(n&130023424)===n&&(e=hu+500-ge(),10<e)){if(Co(r,0)!==0)break;if(s=r.suspendedLanes,(s&n)!==n){Ie(),r.pingedLanes|=r.suspendedLanes&s;break}r.timeoutHandle=Hl(Hr.bind(null,r,He,Ut),e);break}Hr(r,He,Ut);break;case 4:if(wr(r,n),(n&4194240)===n)break;for(e=r.eventTimes,s=-1;0<n;){var o=31-Ot(n);i=1<<o,o=e[o],o>s&&(s=o),n&=~i}if(n=s,n=ge()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Py(n/1960))-n,10<n){r.timeoutHandle=Hl(Hr.bind(null,r,He,Ut),n);break}Hr(r,He,Ut);break;case 5:Hr(r,He,Ut);break;default:throw Error(F(329))}}}return Ye(r,ge()),r.callbackNode===t?Qg.bind(null,r):null}function cc(r,e){var t=Cs;return r.current.memoizedState.isDehydrated&&(qr(r,e).flags|=256),r=Vo(r,e),r!==2&&(e=He,He=t,e!==null&&uc(e)),r}function uc(r){He===null?He=r:He.push.apply(He,r)}function My(r){for(var e=r;;){if(e.flags&16384){var t=e.updateQueue;if(t!==null&&(t=t.stores,t!==null))for(var n=0;n<t.length;n++){var s=t[n],i=s.getSnapshot;s=s.value;try{if(!Pt(i(),s))return!1}catch{return!1}}}if(t=e.child,e.subtreeFlags&16384&&t!==null)t.return=e,e=t;else{if(e===r)break;for(;e.sibling===null;){if(e.return===null||e.return===r)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function wr(r,e){for(e&=~uu,e&=~fa,r.suspendedLanes|=e,r.pingedLanes&=~e,r=r.expirationTimes;0<e;){var t=31-Ot(e),n=1<<t;r[t]=-1,e&=~n}}function Xh(r){if(K&6)throw Error(F(327));An();var e=Co(r,0);if(!(e&1))return Ye(r,ge()),null;var t=Vo(r,e);if(r.tag!==0&&t===2){var n=Fl(r);n!==0&&(e=n,t=cc(r,n))}if(t===1)throw t=Us,qr(r,0),wr(r,e),Ye(r,ge()),t;if(t===6)throw Error(F(345));return r.finishedWork=r.current.alternate,r.finishedLanes=e,Hr(r,He,Ut),Ye(r,ge()),null}function du(r,e){var t=K;K|=1;try{return r(e)}finally{K=t,K===0&&(Hn=ge()+500,ca&&Br())}}function nn(r){br!==null&&br.tag===0&&!(K&6)&&An();var e=K;K|=1;var t=ht.transition,n=Z;try{if(ht.transition=null,Z=1,r)return r()}finally{Z=n,ht.transition=t,K=e,!(K&6)&&Br()}}function fu(){Ze=bn.current,se(bn)}function qr(r,e){r.finishedWork=null,r.finishedLanes=0;var t=r.timeoutHandle;if(t!==-1&&(r.timeoutHandle=-1,ay(t)),ve!==null)for(t=ve.return;t!==null;){var n=t;switch(Yc(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&Eo();break;case 3:Vn(),se(Ue),se(je),ru();break;case 5:tu(n);break;case 4:Vn();break;case 13:se(ce);break;case 19:se(ce);break;case 10:Qc(n.type._context);break;case 22:case 23:fu()}t=t.return}if(Ce=r,ve=r=Ar(r.current,null),ke=Ze=e,xe=0,Us=null,uu=fa=rn=0,He=Cs=null,$r!==null){for(e=0;e<$r.length;e++)if(t=$r[e],n=t.interleaved,n!==null){t.interleaved=null;var s=n.next,i=t.pending;if(i!==null){var o=i.next;i.next=s,n.next=o}t.pending=n}$r=null}return r}function Jg(r,e){do{var t=ve;try{if(qc(),no.current=No,Ro){for(var n=ue.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}Ro=!1}if(tn=0,Se=ye=ue=null,ws=!1,Ws=0,cu.current=null,t===null||t.return===null){xe=1,Us=e,ve=null;break}e:{var i=r,o=t.return,a=t,l=e;if(e=ke,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var d=u.alternate;d?(u.updateQueue=d.updateQueue,u.memoizedState=d.memoizedState,u.lanes=d.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=Mh(o);if(f!==null){f.flags&=-257,jh(f,o,a,i,e),f.mode&1&&Ph(i,c,e),e=f,l=c;var m=e.updateQueue;if(m===null){var v=new Set;v.add(l),e.updateQueue=v}else m.add(l);break e}else{if(!(e&1)){Ph(i,c,e),gu();break e}l=Error(F(426))}}else if(oe&&a.mode&1){var w=Mh(o);if(w!==null){!(w.flags&65536)&&(w.flags|=256),jh(w,o,a,i,e),Gc(Wn(l,a));break e}}i=l=Wn(l,a),xe!==4&&(xe=2),Cs===null?Cs=[i]:Cs.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var g=Fg(i,l,e);bh(i,g);break e;case 1:a=l;var p=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof p.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Mr===null||!Mr.has(y)))){i.flags|=65536,e&=-e,i.lanes|=e;var x=Rg(i,a,e);bh(i,x);break e}}i=i.return}while(i!==null)}tp(t)}catch(_){e=_,ve===t&&t!==null&&(ve=t=t.return);continue}break}while(!0)}function Zg(){var r=Io.current;return Io.current=No,r===null?No:r}function gu(){(xe===0||xe===3||xe===2)&&(xe=4),Ce===null||!(rn&268435455)&&!(fa&268435455)||wr(Ce,ke)}function Vo(r,e){var t=K;K|=2;var n=Zg();(Ce!==r||ke!==e)&&(Ut=null,qr(r,e));do try{jy();break}catch(s){Jg(r,s)}while(!0);if(qc(),K=t,Io.current=n,ve!==null)throw Error(F(261));return Ce=null,ke=0,xe}function jy(){for(;ve!==null;)ep(ve)}function Ay(){for(;ve!==null&&!sv();)ep(ve)}function ep(r){var e=np(r.alternate,r,Ze);r.memoizedProps=r.pendingProps,e===null?tp(r):ve=e,cu.current=null}function tp(r){var e=r;do{var t=e.alternate;if(r=e.return,e.flags&32768){if(t=ky(t,e),t!==null){t.flags&=32767,ve=t;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{xe=6,ve=null;return}}else if(t=Ty(t,e,Ze),t!==null){ve=t;return}if(e=e.sibling,e!==null){ve=e;return}ve=e=r}while(e!==null);xe===0&&(xe=5)}function Hr(r,e,t){var n=Z,s=ht.transition;try{ht.transition=null,Z=1,Ly(r,e,t,n)}finally{ht.transition=s,Z=n}return null}function Ly(r,e,t,n){do An();while(br!==null);if(K&6)throw Error(F(327));t=r.finishedWork;var s=r.finishedLanes;if(t===null)return null;if(r.finishedWork=null,r.finishedLanes=0,t===r.current)throw Error(F(177));r.callbackNode=null,r.callbackPriority=0;var i=t.lanes|t.childLanes;if(gv(r,i),r===Ce&&(ve=Ce=null,ke=0),!(t.subtreeFlags&2064)&&!(t.flags&2064)||wi||(wi=!0,sp(So,function(){return An(),null})),i=(t.flags&15990)!==0,t.subtreeFlags&15990||i){i=ht.transition,ht.transition=null;var o=Z;Z=1;var a=K;K|=4,cu.current=null,Ey(r,t),Kg(t,r),ey(Vl),bo=!!Bl,Vl=Bl=null,r.current=t,Dy(t),iv(),K=a,Z=o,ht.transition=i}else r.current=t;if(wi&&(wi=!1,br=r,Bo=s),i=r.pendingLanes,i===0&&(Mr=null),lv(t.stateNode),Ye(r,ge()),e!==null)for(n=r.onRecoverableError,t=0;t<e.length;t++)s=e[t],n(s.value,{componentStack:s.stack,digest:s.digest});if(zo)throw zo=!1,r=ac,ac=null,r;return Bo&1&&r.tag!==0&&An(),i=r.pendingLanes,i&1?r===lc?bs++:(bs=0,lc=r):bs=0,Br(),null}function An(){if(br!==null){var r=Ff(Bo),e=ht.transition,t=Z;try{if(ht.transition=null,Z=16>r?16:r,br===null)var n=!1;else{if(r=br,br=null,Bo=0,K&6)throw Error(F(331));var s=K;for(K|=4,H=r.current;H!==null;){var i=H,o=i.child;if(H.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(H=c;H!==null;){var u=H;switch(u.tag){case 0:case 11:case 15:Ss(8,u,i)}var h=u.child;if(h!==null)h.return=u,H=h;else for(;H!==null;){u=H;var d=u.sibling,f=u.return;if($g(u),u===c){H=null;break}if(d!==null){d.return=f,H=d;break}H=f}}}var m=i.alternate;if(m!==null){var v=m.child;if(v!==null){m.child=null;do{var w=v.sibling;v.sibling=null,v=w}while(v!==null)}}H=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,H=o;else e:for(;H!==null;){if(i=H,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Ss(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,H=g;break e}H=i.return}}var p=r.current;for(H=p;H!==null;){o=H;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,H=y;else e:for(o=p;H!==null;){if(a=H,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:da(9,a)}}catch(_){de(a,a.return,_)}if(a===o){H=null;break e}var x=a.sibling;if(x!==null){x.return=a.return,H=x;break e}H=a.return}}if(K=s,Br(),zt&&typeof zt.onPostCommitFiberRoot=="function")try{zt.onPostCommitFiberRoot(sa,r)}catch{}n=!0}return n}finally{Z=t,ht.transition=e}}return!1}function Uh(r,e,t){e=Wn(t,e),e=Fg(r,e,1),r=Pr(r,e,1),e=Ie(),r!==null&&(Zs(r,1,e),Ye(r,e))}function de(r,e,t){if(r.tag===3)Uh(r,r,t);else for(;e!==null;){if(e.tag===3){Uh(e,r,t);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Mr===null||!Mr.has(n))){r=Wn(t,r),r=Rg(e,r,1),e=Pr(e,r,1),r=Ie(),e!==null&&(Zs(e,1,r),Ye(e,r));break}}e=e.return}}function Fy(r,e,t){var n=r.pingCache;n!==null&&n.delete(e),e=Ie(),r.pingedLanes|=r.suspendedLanes&t,Ce===r&&(ke&t)===t&&(xe===4||xe===3&&(ke&130023424)===ke&&500>ge()-hu?qr(r,0):uu|=t),Ye(r,e)}function rp(r,e){e===0&&(r.mode&1?(e=hi,hi<<=1,!(hi&130023424)&&(hi=4194304)):e=1);var t=Ie();r=sr(r,e),r!==null&&(Zs(r,e,t),Ye(r,t))}function Ry(r){var e=r.memoizedState,t=0;e!==null&&(t=e.retryLane),rp(r,t)}function Ny(r,e){var t=0;switch(r.tag){case 13:var n=r.stateNode,s=r.memoizedState;s!==null&&(t=s.retryLane);break;case 19:n=r.stateNode;break;default:throw Error(F(314))}n!==null&&n.delete(e),rp(r,t)}var np;np=function(r,e,t){if(r!==null)if(r.memoizedProps!==e.pendingProps||Ue.current)Xe=!0;else{if(!(r.lanes&t)&&!(e.flags&128))return Xe=!1,by(r,e,t);Xe=!!(r.flags&131072)}else Xe=!1,oe&&e.flags&1048576&&ag(e,Mo,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;io(r,e),r=e.pendingProps;var s=In(e,je.current);jn(e,t),s=su(null,e,n,r,s,t);var i=iu();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,$e(n)?(i=!0,Do(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Zc(e),s.updater=ha,e.stateNode=s,s._reactInternals=e,ql(e,n,r,t),e=Zl(null,e,n,!0,i,t)):(e.tag=0,oe&&i&&$c(e),Le(null,e,s,t),e=e.child),e;case 16:n=e.elementType;e:{switch(io(r,e),r=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=zy(n),r=xt(n,r),s){case 0:e=Jl(null,e,n,r,t);break e;case 1:e=Fh(null,e,n,r,t);break e;case 11:e=Ah(null,e,n,r,t);break e;case 14:e=Lh(null,e,n,xt(n.type,r),t);break e}throw Error(F(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:xt(n,s),Jl(r,e,n,s,t);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:xt(n,s),Fh(r,e,n,s,t);case 3:e:{if(Bg(e),r===null)throw Error(F(387));n=e.pendingProps,i=e.memoizedState,s=i.element,fg(r,e),Lo(e,n,null,t);var o=e.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=Wn(Error(F(423)),e),e=Rh(r,e,n,t,s);break e}else if(n!==s){s=Wn(Error(F(424)),e),e=Rh(r,e,n,t,s);break e}else for(et=Dr(e.stateNode.containerInfo.firstChild),tt=e,oe=!0,St=null,t=hg(e,null,n,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(zn(),n===s){e=ir(r,e,t);break e}Le(r,e,n,t)}e=e.child}return e;case 5:return gg(e),r===null&&Yl(e),n=e.type,s=e.pendingProps,i=r!==null?r.memoizedProps:null,o=s.children,Wl(n,s)?o=null:i!==null&&Wl(n,i)&&(e.flags|=32),zg(r,e),Le(r,e,o,t),e.child;case 6:return r===null&&Yl(e),null;case 13:return Vg(r,e,t);case 4:return eu(e,e.stateNode.containerInfo),n=e.pendingProps,r===null?e.child=Bn(e,null,n,t):Le(r,e,n,t),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:xt(n,s),Ah(r,e,n,s,t);case 7:return Le(r,e,e.pendingProps,t),e.child;case 8:return Le(r,e,e.pendingProps.children,t),e.child;case 12:return Le(r,e,e.pendingProps.children,t),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,re(jo,n._currentValue),n._currentValue=o,i!==null)if(Pt(i.value,o)){if(i.children===s.children&&!Ue.current){e=ir(r,e,t);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=er(-1,t&-t),l.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}i.lanes|=t,l=i.alternate,l!==null&&(l.lanes|=t),Gl(i.return,t,e),a.lanes|=t;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(F(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Gl(o,t,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Le(r,e,s.children,t),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,jn(e,t),s=dt(s),n=n(s),e.flags|=1,Le(r,e,n,t),e.child;case 14:return n=e.type,s=xt(n,e.pendingProps),s=xt(n.type,s),Lh(r,e,n,s,t);case 15:return Ng(r,e,e.type,e.pendingProps,t);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:xt(n,s),io(r,e),e.tag=1,$e(n)?(r=!0,Do(e)):r=!1,jn(e,t),Lg(e,n,s),ql(e,n,s,t),Zl(null,e,n,!0,r,t);case 19:return Wg(r,e,t);case 22:return Ig(r,e,t)}throw Error(F(156,e.tag))};function sp(r,e){return Mf(r,e)}function Iy(r,e,t,n){this.tag=r,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ut(r,e,t,n){return new Iy(r,e,t,n)}function pu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function zy(r){if(typeof r=="function")return pu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===Lc)return 11;if(r===Fc)return 14}return 2}function Ar(r,e){var t=r.alternate;return t===null?(t=ut(r.tag,e,r.key,r.mode),t.elementType=r.elementType,t.type=r.type,t.stateNode=r.stateNode,t.alternate=r,r.alternate=t):(t.pendingProps=e,t.type=r.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=r.flags&14680064,t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,e=r.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=r.sibling,t.index=r.index,t.ref=r.ref,t}function lo(r,e,t,n,s,i){var o=2;if(n=r,typeof r=="function")pu(r)&&(o=1);else if(typeof r=="string")o=5;else e:switch(r){case gn:return Qr(t.children,s,i,e);case Ac:o=8,s|=8;break;case _l:return r=ut(12,t,e,s|2),r.elementType=_l,r.lanes=i,r;case wl:return r=ut(13,t,e,s),r.elementType=wl,r.lanes=i,r;case Sl:return r=ut(19,t,e,s),r.elementType=Sl,r.lanes=i,r;case gf:return ga(t,s,i,e);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case df:o=10;break e;case ff:o=9;break e;case Lc:o=11;break e;case Fc:o=14;break e;case yr:o=16,n=null;break e}throw Error(F(130,r==null?r:typeof r,""))}return e=ut(o,t,e,s),e.elementType=r,e.type=n,e.lanes=i,e}function Qr(r,e,t,n){return r=ut(7,r,n,e),r.lanes=t,r}function ga(r,e,t,n){return r=ut(22,r,n,e),r.elementType=gf,r.lanes=t,r.stateNode={isHidden:!1},r}function tl(r,e,t){return r=ut(6,r,null,e),r.lanes=t,r}function rl(r,e,t){return e=ut(4,r.children!==null?r.children:[],r.key,e),e.lanes=t,e.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},e}function By(r,e,t,n,s){this.tag=e,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ra(0),this.expirationTimes=Ra(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ra(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function mu(r,e,t,n,s,i,o,a,l){return r=new By(r,e,t,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=ut(3,null,null,e),r.current=i,i.stateNode=r,i.memoizedState={element:n,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zc(i),r}function Vy(r,e,t){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:fn,key:n==null?null:""+n,children:r,containerInfo:e,implementation:t}}function ip(r){if(!r)return Fr;r=r._reactInternals;e:{if(an(r)!==r||r.tag!==1)throw Error(F(170));var e=r;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if($e(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(F(171))}if(r.tag===1){var t=r.type;if($e(t))return ig(r,t,e)}return e}function op(r,e,t,n,s,i,o,a,l){return r=mu(t,n,!0,r,s,i,o,a,l),r.context=ip(null),t=r.current,n=Ie(),s=jr(t),i=er(n,s),i.callback=e??null,Pr(t,i,s),r.current.lanes=s,Zs(r,s,n),Ye(r,n),r}function pa(r,e,t,n){var s=e.current,i=Ie(),o=jr(s);return t=ip(t),e.context===null?e.context=t:e.pendingContext=t,e=er(i,o),e.payload={element:r},n=n===void 0?null:n,n!==null&&(e.callback=n),r=Pr(s,e,o),r!==null&&(Et(r,s,o,i),ro(r,s,o)),o}function Wo(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function $h(r,e){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var t=r.retryLane;r.retryLane=t!==0&&t<e?t:e}}function vu(r,e){$h(r,e),(r=r.alternate)&&$h(r,e)}function Wy(){return null}var ap=typeof reportError=="function"?reportError:function(r){console.error(r)};function yu(r){this._internalRoot=r}ma.prototype.render=yu.prototype.render=function(r){var e=this._internalRoot;if(e===null)throw Error(F(409));pa(r,e,null,null)};ma.prototype.unmount=yu.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var e=r.containerInfo;nn(function(){pa(null,r,null,null)}),e[nr]=null}};function ma(r){this._internalRoot=r}ma.prototype.unstable_scheduleHydration=function(r){if(r){var e=If();r={blockedOn:null,target:r,priority:e};for(var t=0;t<_r.length&&e!==0&&e<_r[t].priority;t++);_r.splice(t,0,r),t===0&&Bf(r)}};function xu(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function va(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Yh(){}function Hy(r,e,t,n,s){if(s){if(typeof n=="function"){var i=n;n=function(){var c=Wo(o);i.call(c)}}var o=op(e,n,r,0,null,!1,!1,"",Yh);return r._reactRootContainer=o,r[nr]=o.current,Ns(r.nodeType===8?r.parentNode:r),nn(),o}for(;s=r.lastChild;)r.removeChild(s);if(typeof n=="function"){var a=n;n=function(){var c=Wo(l);a.call(c)}}var l=mu(r,0,!1,null,null,!1,!1,"",Yh);return r._reactRootContainer=l,r[nr]=l.current,Ns(r.nodeType===8?r.parentNode:r),nn(function(){pa(e,l,t,n)}),l}function ya(r,e,t,n,s){var i=t._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Wo(o);a.call(l)}}pa(e,o,r,s)}else o=Hy(t,e,r,s,n);return Wo(o)}Rf=function(r){switch(r.tag){case 3:var e=r.stateNode;if(e.current.memoizedState.isDehydrated){var t=fs(e.pendingLanes);t!==0&&(Ic(e,t|1),Ye(e,ge()),!(K&6)&&(Hn=ge()+500,Br()))}break;case 13:nn(function(){var n=sr(r,1);if(n!==null){var s=Ie();Et(n,r,1,s)}}),vu(r,1)}};zc=function(r){if(r.tag===13){var e=sr(r,134217728);if(e!==null){var t=Ie();Et(e,r,134217728,t)}vu(r,134217728)}};Nf=function(r){if(r.tag===13){var e=jr(r),t=sr(r,e);if(t!==null){var n=Ie();Et(t,r,e,n)}vu(r,e)}};If=function(){return Z};zf=function(r,e){var t=Z;try{return Z=r,e()}finally{Z=t}};jl=function(r,e,t){switch(e){case"input":if(Tl(r,t),e=t.name,t.type==="radio"&&e!=null){for(t=r;t.parentNode;)t=t.parentNode;for(t=t.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<t.length;e++){var n=t[e];if(n!==r&&n.form===r.form){var s=la(n);if(!s)throw Error(F(90));mf(n),Tl(n,s)}}}break;case"textarea":yf(r,t);break;case"select":e=t.value,e!=null&&En(r,!!t.multiple,e,!1)}};Tf=du;kf=nn;var Xy={usingClientEntryPoint:!1,Events:[ti,yn,la,Cf,bf,du]},ls={findFiberByHostInstance:Ur,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Uy={bundleType:ls.bundleType,version:ls.version,rendererPackageName:ls.rendererPackageName,rendererConfig:ls.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ur.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Df(r),r===null?null:r.stateNode},findFiberByHostInstance:ls.findFiberByHostInstance||Wy,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Si=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Si.isDisabled&&Si.supportsFiber)try{sa=Si.inject(Uy),zt=Si}catch{}}nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Xy;nt.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xu(e))throw Error(F(200));return Vy(r,e,null,t)};nt.createRoot=function(r,e){if(!xu(r))throw Error(F(299));var t=!1,n="",s=ap;return e!=null&&(e.unstable_strictMode===!0&&(t=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=mu(r,1,!1,null,null,t,!1,n,s),r[nr]=e.current,Ns(r.nodeType===8?r.parentNode:r),new yu(e)};nt.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var e=r._reactInternals;if(e===void 0)throw typeof r.render=="function"?Error(F(188)):(r=Object.keys(r).join(","),Error(F(268,r)));return r=Df(e),r=r===null?null:r.stateNode,r};nt.flushSync=function(r){return nn(r)};nt.hydrate=function(r,e,t){if(!va(e))throw Error(F(200));return ya(null,r,e,!0,t)};nt.hydrateRoot=function(r,e,t){if(!xu(r))throw Error(F(405));var n=t!=null&&t.hydratedSources||null,s=!1,i="",o=ap;if(t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),e=op(e,null,r,1,t??null,s,!1,i,o),r[nr]=e.current,Ns(r),n)for(r=0;r<n.length;r++)t=n[r],s=t._getVersion,s=s(t._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[t,s]:e.mutableSourceEagerHydrationData.push(t,s);return new ma(e)};nt.render=function(r,e,t){if(!va(e))throw Error(F(200));return ya(null,r,e,!1,t)};nt.unmountComponentAtNode=function(r){if(!va(r))throw Error(F(40));return r._reactRootContainer?(nn(function(){ya(null,null,r,!1,function(){r._reactRootContainer=null,r[nr]=null})}),!0):!1};nt.unstable_batchedUpdates=du;nt.unstable_renderSubtreeIntoContainer=function(r,e,t,n){if(!va(t))throw Error(F(200));if(r==null||r._reactInternals===void 0)throw Error(F(38));return ya(r,e,t,!1,n)};nt.version="18.3.1-next-f1338f8080-20240426";function lp(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(lp)}catch(r){console.error(r)}}lp(),lf.exports=nt;var $y=lf.exports,Gh=$y;yl.createRoot=Gh.createRoot,yl.hydrateRoot=Gh.hydrateRoot;function nl(r){return r==="colors"?"color":r!==null?"scalar":"enum"}const Kh=[{prefix:"px-",category:"spacing",themeKey:"spacing"},{prefix:"py-",category:"spacing",themeKey:"spacing"},{prefix:"pt-",category:"spacing",themeKey:"spacing"},{prefix:"pr-",category:"spacing",themeKey:"spacing"},{prefix:"pb-",category:"spacing",themeKey:"spacing"},{prefix:"pl-",category:"spacing",themeKey:"spacing"},{prefix:"ps-",category:"spacing",themeKey:"spacing"},{prefix:"pe-",category:"spacing",themeKey:"spacing"},{prefix:"p-",category:"spacing",themeKey:"spacing"},{prefix:"mx-",category:"spacing",themeKey:"spacing"},{prefix:"my-",category:"spacing",themeKey:"spacing"},{prefix:"mt-",category:"spacing",themeKey:"spacing"},{prefix:"mr-",category:"spacing",themeKey:"spacing"},{prefix:"mb-",category:"spacing",themeKey:"spacing"},{prefix:"ml-",category:"spacing",themeKey:"spacing"},{prefix:"ms-",category:"spacing",themeKey:"spacing"},{prefix:"me-",category:"spacing",themeKey:"spacing"},{prefix:"m-",category:"spacing",themeKey:"spacing"},{prefix:"gap-x-",category:"spacing",themeKey:"spacing"},{prefix:"gap-y-",category:"spacing",themeKey:"spacing"},{prefix:"gap-",category:"spacing",themeKey:"spacing"},{prefix:"space-x-",category:"spacing",themeKey:"spacing"},{prefix:"space-y-",category:"spacing",themeKey:"spacing"},{prefix:"min-w-",category:"sizing",themeKey:"spacing"},{prefix:"max-w-",category:"sizing",themeKey:"spacing"},{prefix:"min-h-",category:"sizing",themeKey:"spacing"},{prefix:"max-h-",category:"sizing",themeKey:"spacing"},{prefix:"size-",category:"sizing",themeKey:"spacing"},{prefix:"w-",category:"sizing",themeKey:"spacing"},{prefix:"h-",category:"sizing",themeKey:"spacing"},{prefix:"bg-",category:"color",themeKey:"colors"},{prefix:"ring-",category:"color",themeKey:"colors"},{prefix:"outline-",category:"color",themeKey:"colors"},{prefix:"fill-",category:"color",themeKey:"colors"},{prefix:"stroke-",category:"color",themeKey:"colors"},{prefix:"decoration-",category:"color",themeKey:"colors"},{prefix:"font-",category:"typography",themeKey:"fontWeight"},{prefix:"leading-",category:"typography",themeKey:"lineHeight"},{prefix:"tracking-",category:"typography",themeKey:"letterSpacing"},{prefix:"rounded-tl-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-tr-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-br-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-bl-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-t-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-r-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-b-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-l-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-",category:"borders",themeKey:"borderRadius"},{prefix:"border-t-",category:"borders",themeKey:"borderWidth"},{prefix:"border-r-",category:"borders",themeKey:"borderWidth"},{prefix:"border-b-",category:"borders",themeKey:"borderWidth"},{prefix:"border-l-",category:"borders",themeKey:"borderWidth"},{prefix:"opacity-",category:"effects",themeKey:null},{prefix:"shadow-",category:"effects",themeKey:null},{prefix:"inset-",category:"layout",themeKey:"spacing"},{prefix:"top-",category:"layout",themeKey:"spacing"},{prefix:"right-",category:"layout",themeKey:"spacing"},{prefix:"bottom-",category:"layout",themeKey:"spacing"},{prefix:"left-",category:"layout",themeKey:"spacing"},{prefix:"z-",category:"layout",themeKey:null},{prefix:"basis-",category:"flexbox",themeKey:"spacing"},{prefix:"grid-cols-",category:"flexbox",themeKey:null},{prefix:"grid-rows-",category:"flexbox",themeKey:null},{prefix:"col-span-",category:"flexbox",themeKey:null},{prefix:"row-span-",category:"flexbox",themeKey:null},{prefix:"order-",category:"flexbox",themeKey:null}].sort((r,e)=>e.prefix.length-r.prefix.length),Yy=new Set(["0","2","4","8"]),Gy=new Set(["solid","dashed","dotted","double","hidden","none"]),Ky=new Set(["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","9xl"]),qy=new Set(["left","center","right","justify","start","end"]),Qy={rounded:{category:"borders",themeKey:"borderRadius"},border:{category:"borders",themeKey:"borderWidth"},shadow:{category:"effects",themeKey:null},underline:{category:"typography",themeKey:null},overline:{category:"typography",themeKey:null},"line-through":{category:"typography",themeKey:null},"no-underline":{category:"typography",themeKey:null},uppercase:{category:"typography",themeKey:null},lowercase:{category:"typography",themeKey:null},capitalize:{category:"typography",themeKey:null},"normal-case":{category:"typography",themeKey:null},truncate:{category:"typography",themeKey:null},italic:{category:"typography",themeKey:null},"not-italic":{category:"typography",themeKey:null},block:{category:"layout",themeKey:null},"inline-block":{category:"layout",themeKey:null},inline:{category:"layout",themeKey:null},flex:{category:"layout",themeKey:null},"inline-flex":{category:"layout",themeKey:null},grid:{category:"layout",themeKey:null},"inline-grid":{category:"layout",themeKey:null},hidden:{category:"layout",themeKey:null},table:{category:"layout",themeKey:null},contents:{category:"layout",themeKey:null},static:{category:"layout",themeKey:null},fixed:{category:"layout",themeKey:null},absolute:{category:"layout",themeKey:null},relative:{category:"layout",themeKey:null},sticky:{category:"layout",themeKey:null},"flex-row":{category:"flexbox",themeKey:null},"flex-row-reverse":{category:"flexbox",themeKey:null},"flex-col":{category:"flexbox",themeKey:null},"flex-col-reverse":{category:"flexbox",themeKey:null},"flex-wrap":{category:"flexbox",themeKey:null},"flex-wrap-reverse":{category:"flexbox",themeKey:null},"flex-nowrap":{category:"flexbox",themeKey:null},"flex-1":{category:"flexbox",themeKey:null},"flex-auto":{category:"flexbox",themeKey:null},"flex-initial":{category:"flexbox",themeKey:null},"flex-none":{category:"flexbox",themeKey:null},grow:{category:"flexbox",themeKey:null},"grow-0":{category:"flexbox",themeKey:null},shrink:{category:"flexbox",themeKey:null},"shrink-0":{category:"flexbox",themeKey:null},"justify-start":{category:"flexbox",themeKey:null},"justify-end":{category:"flexbox",themeKey:null},"justify-center":{category:"flexbox",themeKey:null},"justify-between":{category:"flexbox",themeKey:null},"justify-around":{category:"flexbox",themeKey:null},"justify-evenly":{category:"flexbox",themeKey:null},"justify-stretch":{category:"flexbox",themeKey:null},"items-start":{category:"flexbox",themeKey:null},"items-end":{category:"flexbox",themeKey:null},"items-center":{category:"flexbox",themeKey:null},"items-baseline":{category:"flexbox",themeKey:null},"items-stretch":{category:"flexbox",themeKey:null},"self-auto":{category:"flexbox",themeKey:null},"self-start":{category:"flexbox",themeKey:null},"self-end":{category:"flexbox",themeKey:null},"self-center":{category:"flexbox",themeKey:null},"self-stretch":{category:"flexbox",themeKey:null},"self-baseline":{category:"flexbox",themeKey:null}},Jy=/^(sm:|md:|lg:|xl:|2xl:|hover:|focus:|active:|disabled:|visited:|first:|last:|odd:|even:|group-hover:|focus-within:|focus-visible:|dark:|motion-safe:|motion-reduce:)+/;function Zy(r){return Jy.test(r)}function e0(r){return Ky.has(r)?{category:"typography",valueType:"scalar",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:"fontSize"}:qy.has(r)?{category:"typography",valueType:"enum",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:null}:{category:"color",valueType:"color",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:"colors"}}function t0(r){return Yy.has(r)?{category:"borders",valueType:"scalar",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:"borderWidth"}:Gy.has(r)?{category:"borders",valueType:"enum",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:null}:{category:"color",valueType:"color",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:"colors"}}function r0(r){const e=[],t=r.trim().split(/\s+/).filter(Boolean);for(const n of t){if(Zy(n))continue;const s=Qy[n];if(s){e.push({category:s.category,valueType:nl(s.themeKey),prefix:n,value:"",fullClass:n,themeKey:s.themeKey});continue}if(n.startsWith("text-")){const i=n.slice(5),o=e0(i);o&&e.push(o);continue}if(n.startsWith("border-")){const i=n.slice(7);let o=!1;for(const a of Kh)if(a.prefix!=="border-"&&n.startsWith(a.prefix)){o=!0,e.push({category:a.category,valueType:nl(a.themeKey),prefix:a.prefix,value:n.slice(a.prefix.length),fullClass:n,themeKey:a.themeKey});break}if(!o){const a=t0(i);a&&e.push(a)}continue}for(const i of Kh)if(n.startsWith(i.prefix)){e.push({category:i.category,valueType:nl(i.themeKey),prefix:i.prefix,value:n.slice(i.prefix.length),fullClass:n,themeKey:i.themeKey});break}}return e}let $t=null,Ho=!1;const co=[],uo=[],ho=[];function n0(){return window.location.origin.replace(/^http/,"ws")}function _u(){if($t)return;const r=n0();$t=new WebSocket(r),$t.addEventListener("open",()=>{Ho=!0,Qt({type:"REGISTER",role:"panel"});for(const e of uo)e()}),$t.addEventListener("close",()=>{Ho=!1,$t=null;for(const e of ho)e();setTimeout(()=>_u(),3e3)}),$t.addEventListener("message",e=>{try{const t=JSON.parse(e.data);for(const n of co)n(t)}catch(t){console.error("[tw-panel] Failed to parse message:",t)}}),$t.addEventListener("error",e=>{console.error("[tw-panel] WebSocket error:",e)})}function Qt(r){Ho&&$t&&$t.send(JSON.stringify(r))}function Re(r,e){Qt({...e,to:r})}function cp(r){return co.push(r),()=>{const e=co.indexOf(r);e!==-1&&co.splice(e,1)}}function up(r){return uo.push(r),()=>{const e=uo.indexOf(r);e!==-1&&uo.splice(e,1)}}function s0(r){return ho.push(r),()=>{const e=ho.indexOf(r);e!==-1&&ho.splice(e,1)}}function i0(){return Ho}const o0=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],a0=["50","100","200","300","400","500","600","700","800","900","950"];function qh({prefix:r,currentValue:e,colors:t,locked:n,lockedValue:s,onHover:i,onLeave:o,onClick:a}){return S.jsxs("div",{className:"p-2 bg-bv-surface border border-bv-border rounded-md my-2",onMouseLeave:()=>{n||o()},children:[S.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[S.jsx("span",{className:"w-[52px] text-[10px] text-bv-muted text-right pr-1.5 shrink-0"}),["black","white","transparent"].map(l=>t[l]!==void 0?S.jsx(Qh,{prefix:r,colorName:l,colorValue:t[l],isCurrent:l===e,isLocked:s===`${r}${l}`,locked:n,onHover:i,onClick:a},l):null)]}),o0.map(l=>{const c=t[l];return!c||typeof c!="object"?null:S.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[S.jsx("span",{className:"w-[52px] text-[10px] text-bv-muted text-right pr-1.5 shrink-0",children:l}),a0.map(u=>c[u]!==void 0?S.jsx(Qh,{prefix:r,colorName:`${l}-${u}`,colorValue:c[u],isCurrent:`${l}-${u}`===e,isLocked:s===`${r}${l}-${u}`,locked:n,onHover:i,onClick:a},`${l}-${u}`):null)]},l)})]})}function Qh({prefix:r,colorName:e,colorValue:t,isCurrent:n,isLocked:s,locked:i,onHover:o,onClick:a}){const l=`${r}${e}`,c=s?"outline outline-2 outline-offset-2 outline-bv-teal border-transparent":n?"outline outline-2 outline-offset-2 outline-bv-orange border-transparent":i?"border-transparent":"border-transparent hover:border-bv-text hover:scale-110 hover:z-10",u=e==="transparent"?{background:"repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 50% / 8px 8px"}:{backgroundColor:t};return S.jsx("div",{title:l,className:`w-5 h-5 rounded cursor-pointer border-2 shrink-0 transition-[border-color,transform] ${c}`,style:u,onMouseEnter:()=>{i||o(l)},onClick:h=>{h.stopPropagation(),a(l)}})}const l0=4,c0=10;function Ci({values:r,currentValue:e,lockedValue:t,locked:n,ghost:s,onStart:i,onHover:o,onLeave:a,onClick:l}){const[c,u]=V.useState(!1),[h,d]=V.useState(null),f=V.useRef(null),m=V.useRef(null),v=V.useRef(null),w=t!==null&&r.includes(t),g=h!==null?r[h]:w?t:e;V.useEffect(()=>{if(!c)return;const k=N=>{var L;(L=m.current)!=null&&L.contains(N.target)||(u(!1),a())};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[c,a]),V.useEffect(()=>{var k,N;c&&v.current&&((N=(k=v.current).scrollIntoView)==null||N.call(k,{block:"nearest"}))},[c]);const p=n&&!w;function y(k){if(p)return;i==null||i();const N=w?t:e,L=r.indexOf(N);f.current={startX:k.clientX,startIndex:L>=0?L:0,didScrub:!1},k.currentTarget.setPointerCapture(k.pointerId),k.preventDefault()}function x(k){const N=f.current;if(!N)return;const L=k.clientX-N.startX;if(!N.didScrub&&Math.abs(L)>l0&&(N.didScrub=!0,u(!1)),N.didScrub){const X=Math.round(L/c0),T=Math.max(0,Math.min(r.length-1,N.startIndex+X));d(T),o(r[T])}}function _(){const k=f.current;k&&(k.didScrub&&h!==null?l(r[h]):k.didScrub||u(N=>(N&&a(),!N)),d(null),f.current=null)}const E=h!==null,D=E?"border-bv-teal bg-bv-teal/9 text-bv-teal":w?"border-bv-border bg-bv-surface-hi text-bv-text hover:border-bv-teal hover:bg-bv-teal/9 hover:text-bv-teal":c?"border-bv-border bg-bv-surface-hi text-bv-text":p?"bg-bv-surface text-bv-text-mid border-transparent":s?"border-dashed border-bv-border text-bv-muted bg-transparent hover:border-bv-teal hover:text-bv-teal":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:bg-bv-teal/9 hover:text-bv-teal";return S.jsxs("div",{ref:m,className:"relative inline-block",children:[S.jsxs("div",{className:`group select-none px-2 py-0.5 rounded text-[11px] font-mono border transition-colors ${p?"cursor-default":"cursor-ew-resize"} ${D}`,onPointerDown:y,onPointerMove:x,onPointerUp:_,children:[!p&&S.jsx("span",{className:`inline-block mr-0.5 text-[9px] transition-opacity ${E?"opacity-100":"opacity-0 group-hover:opacity-50"}`,children:"‹"}),g,!p&&S.jsx("span",{className:`inline-block ml-0.5 text-[9px] transition-opacity ${E?"opacity-100":"opacity-0 group-hover:opacity-50"}`,children:"›"})]}),c&&S.jsx("div",{className:"absolute z-50 top-full left-0 mt-0.5 max-h-52 overflow-y-auto bg-bv-bg border border-bv-border rounded-md shadow-md min-w-[5rem]",onMouseLeave:a,children:r.map(k=>{const N=k===(t??e),L=N?"bg-bv-teal/9 text-bv-teal":"text-bv-text-mid hover:bg-bv-surface hover:text-bv-text";return S.jsx("div",{ref:N?v:void 0,className:`px-2 py-[3px] text-[11px] font-mono cursor-pointer ${L}`,onMouseEnter:()=>o(k),onClick:X=>{X.stopPropagation(),l(k),u(!1)},children:k},k)})})]})}const u0={px:.0625};function Jh(r){return isNaN(Number(r))?u0[r]??1/0:Number(r)}function bi(r,e,t){return e==="spacing"&&(t!=null&&t.spacing)?Object.keys(t.spacing).sort((s,i)=>Jh(s)-Jh(i)).map(s=>`${r}${s}`):e==="fontSize"?["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"]:e==="fontWeight"?["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"]:e==="borderRadius"?["rounded-none","rounded-sm","rounded","rounded-md","rounded-lg","rounded-xl","rounded-2xl","rounded-3xl","rounded-full"]:e==="lineHeight"?["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"]:e==="letterSpacing"?["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"]:[]}const h0=4,d0=10;function hp({placeholder:r,values:e,currentValue:t,displayValue:n,formatValue:s,axis:i="x",disabled:o,onHover:a,onLeave:l,onClick:c,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f}){const[m,v]=V.useState(!1),[w,g]=V.useState(null),p=V.useRef(null),y=V.useRef(null),x=V.useRef(null),_=t!=null,E=t?e.indexOf(t):-1,D=w!==null?e[w]:null,k=D?s?s(D):D:n??r;V.useEffect(()=>{if(!m)return;const j=I=>{var P;(P=y.current)!=null&&P.contains(I.target)||(v(!1),f==null||f(),l==null||l())};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[m,l,f]),V.useEffect(()=>{var j,I;m&&x.current&&((I=(j=x.current).scrollIntoView)==null||I.call(j,{block:"nearest"}))},[m]);function N(j){var P,z;if(o)return;j.preventDefault(),j.stopPropagation();const I=E>=0?E:0;p.current={startX:j.clientX,startY:j.clientY,startIndex:I,didScrub:!1},(z=(P=j.target).setPointerCapture)==null||z.call(P,j.pointerId)}function L(j){const I=p.current;if(!I)return;const P=i==="y"?-(j.clientY-I.startY):j.clientX-I.startX;if(!I.didScrub&&Math.abs(P)>h0&&(I.didScrub=!0,v(!1),u==null||u()),I.didScrub){const z=Math.round(P/d0),A=Math.max(0,Math.min(e.length-1,I.startIndex+z));g(A),a==null||a(e[A])}}function X(){const j=p.current;j&&(j.didScrub&&w!==null?(c==null||c(e[w]),g(null),p.current=null,h==null||h()):j.didScrub||(g(null),p.current=null,v(I=>I?(f==null||f(),l==null||l(),!1):(d==null||d(),!0))))}const T=w!==null,R=["bm-slot",_||T?"bm-has-val":"",T?"bm-scrubbing":""].filter(Boolean).join(" "),B=o?"default":i==="y"?"ns-resize":"ew-resize";return S.jsxs("span",{ref:y,className:R,style:{position:"relative",cursor:B},onPointerDown:N,onPointerMove:L,onPointerUp:X,role:"button",tabIndex:o?-1:0,children:[k,m&&S.jsx("div",{className:"bm-mini-dropdown",onClick:j=>j.stopPropagation(),onMouseLeave:()=>l==null?void 0:l(),onMouseDown:j=>j.stopPropagation(),children:e.map(j=>{const I=j===t;return S.jsx("div",{ref:I?x:void 0,className:`bm-mini-dropdown-item${I?" bm-active":""}`,onMouseEnter:()=>a==null?void 0:a(j),onClick:P=>{P.stopPropagation(),c==null||c(j),v(!1),f==null||f()},children:j},j)})})]})}function Zh(r,e){const n={padding:"p",margin:"m",border:"border-",outline:"outline-"}[e];return r.startsWith(n)?r.slice(n.length):r}function f0({value:r,placeholder:e,layer:t,frozen:n,scaleValues:s,axis:i,onClick:o,onValueChange:a,onValueHover:l,onValueLeave:c,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f}){const m=r!=null,v=m?Zh(r,t):null;if(s&&s.length>0)return S.jsx(hp,{placeholder:e,values:s,currentValue:r,displayValue:v,formatValue:g=>Zh(g,t),axis:i,disabled:n,onHover:l,onLeave:c,onClick:a,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f});const w=`bm-slot${m?" bm-has-val":""}`;return S.jsx("span",{className:w,onClick:n?void 0:o,role:"button",tabIndex:n?-1:0,children:v??e})}const g0={top:["y","t"],right:["r"],bottom:["b"],left:["x","l"],tr:["color"],bl:["style"],br:["offset"]},p0={margin:["top","right","bottom","left"],outline:["top","right","bottom","left","tr","bl","br"],border:["top","right","bottom","left","tr","bl"],padding:["top","right","bottom","left"]},m0={top:"y",bottom:"y",left:"x",right:"x",tr:"x",bl:"x",br:"x"};function v0({layer:r,classState:e,shorthandValue:t,shorthandScaleValues:n,slots:s,isHovered:i,frozen:o,onHoverChange:a,onSlotClick:l,onSlotChange:c,onSlotHover:u,onScrubStart:h,onScrubEnd:d,onSlotOpen:f,onSlotClose:m,children:v}){const w=`bm-layer bm-${r}${i?" bm-hovered":""}`,[g,p]=V.useState(null),y=new Map(s.map(L=>[L.key,L])),x=(e==="shorthand"||e==="mixed")&&t,_=n&&n.length>0?S.jsx("span",{className:"bm-name bm-name-scrubber",children:S.jsx(hp,{placeholder:r,values:n,currentValue:x?t:null,displayValue:x?t:null,formatValue:L=>L,axis:"x",disabled:o,onHover:L=>u==null?void 0:u("shorthand",L),onLeave:()=>u==null?void 0:u("shorthand",null),onClick:L=>c==null?void 0:c("shorthand",L),onScrubStart:()=>{h==null||h()},onScrubEnd:d,onOpen:()=>{p("__shorthand__"),f==null||f()},onClose:()=>{p(null),m==null||m()}})}):x?S.jsx("span",{className:"bm-name",children:S.jsx("span",{className:"bm-val",onClick:()=>l==null?void 0:l("shorthand"),children:t})}):S.jsx("span",{className:"bm-name",children:r}),D=(p0[r]??[]).map(L=>{const T=(g0[L]??[]).map(I=>y.get(I)).filter(I=>I!=null);if(T.length===0)return null;const M=T.some(I=>I.value!=null),B=`bm-slot-group bm-sg-${L}${M?" bm-has-values":""}${g===L?" bm-sg-active":""}`,j=m0[L];return S.jsx("div",{className:B,children:T.map(I=>S.jsx(f0,{slotKey:I.key,value:I.value,placeholder:I.placeholder,layer:r,isExpanded:i,frozen:o,scaleValues:I.scaleValues,axis:j,onClick:()=>l==null?void 0:l(I.key),onValueChange:c?P=>c(I.key,P):void 0,onValueHover:u?P=>u(I.key,P):void 0,onValueLeave:u?()=>u(I.key,null):void 0,onScrubStart:h,onScrubEnd:d,onOpen:()=>{p(L),f==null||f()},onClose:()=>{p(null),m==null||m()}},I.key))},L)}),k=L=>{L.stopPropagation(),o||a(!0)},N=L=>{const X=L.relatedTarget,T=L.currentTarget;X&&T.contains(X)||o||a(!1)};return S.jsxs("div",{className:w,onMouseOver:k,onMouseOut:N,"data-layer":r,children:[_,D,v]})}const ed=["margin","outline","border","padding"];function y0({layers:r,frozen:e=!1,onSlotClick:t,onSlotChange:n,onSlotHover:s,onEditStart:i}){const[o,a]=V.useState(null),[l,c]=V.useState(null),u=e||l!==null,h=new Map(r.map(g=>[g.layer,g])),d=(g,p)=>{u||a(p?g:null)},f=(g,p)=>{u||t==null||t(g,p)};let v=S.jsx("div",{className:"bm-content"});for(let g=ed.length-1;g>=0;g--){const p=ed[g],y=h.get(p);y&&(v=S.jsx(v0,{layer:y.layer,classState:y.classState,shorthandValue:y.shorthandValue,shorthandScaleValues:y.shorthandScaleValues,slots:y.slots,isHovered:o===p||l===p,frozen:u,onHoverChange:x=>d(p,x),onSlotClick:x=>f(p,x),onSlotChange:n?(x,_)=>n(p,x,_):void 0,onSlotHover:s?(x,_)=>s(p,x,_):void 0,onScrubStart:()=>{c(p),i==null||i()},onScrubEnd:()=>c(null),onSlotOpen:()=>{c(p),i==null||i()},onSlotClose:()=>c(null),children:v}))}const w=`bm-root${u?" bm-frozen":""}`;return S.jsx("div",{className:w,children:v})}const x0={margin:{shorthand:"m",x:"mx",y:"my",t:"mt",r:"mr",b:"mb",l:"ml"},outline:{shorthand:"outline",x:"outline-x",y:"outline-y",t:"outline-t",r:"outline-r",b:"outline-b",l:"outline-l"},border:{shorthand:"border",x:"border-x",y:"border-y",t:"border-t",r:"border-r",b:"border-b",l:"border-l"},padding:{shorthand:"p",x:"px",y:"py",t:"pt",r:"pr",b:"pb",l:"pl"}},_0=["y","t","r","b","x","l"];function w0(r){const e=_0.map(t=>({key:t,placeholder:t}));return(r==="border"||r==="outline")&&e.push({key:"color",placeholder:"color"},{key:"style",placeholder:"style"}),r==="outline"&&e.push({key:"offset",placeholder:"offset"}),e}function S0(r,e){const t=x0[r],n=w0(r),s=e[t.shorthand]??null,i=s!=null?`${t.shorthand}-${s}`:null,o=n.map(({key:d,placeholder:f})=>{let m;if(d==="color"){const g=r==="outline"?"outline-color":"border-color";m=g in e?g:void 0}else if(d==="style"){const g=r==="outline"?"outline-style":"border-style";m=g in e?g:void 0}else d==="offset"?m="outline-offset"in e?"outline-offset":void 0:m=t[d];const v=m?e[m]??null:null,w=v!=null&&m?`${m}-${v}`:null;return{key:d,value:w,placeholder:f}}),a=i!=null,l=o.some(d=>(d.key==="x"||d.key==="y")&&d.value!=null),c=o.some(d=>(d.key==="t"||d.key==="r"||d.key==="b"||d.key==="l")&&d.value!=null),u=l||c;let h;return!a&&!u?h="none":a&&!u?h="shorthand":!a&&l&&!c?h="axis":a?h="mixed":h="individual",{layer:r,classState:h,shorthandValue:i,slots:o}}const hc=["px","0","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96"],dp=["0","2","4","8"];function C0(r,e,t){var o,a,l;if(e==="color"||e==="style")return[];let n;r==="border"||r==="outline"?e==="offset"?n=(o=t==null?void 0:t.theme)!=null&&o.spacing?Object.keys(t.theme.spacing):hc:n=(a=t==null?void 0:t.theme)!=null&&a.borderWidth?Object.keys(t.theme.borderWidth):dp:n=(l=t==null?void 0:t.theme)!=null&&l.spacing?Object.keys(t.theme.spacing):hc;const i={margin:{shorthand:"m",t:"mt",r:"mr",b:"mb",l:"ml",x:"mx",y:"my"},padding:{shorthand:"p",t:"pt",r:"pr",b:"pb",l:"pl",x:"px",y:"py"},border:{t:"border-t",r:"border-r",b:"border-b",l:"border-l",x:"border-x",y:"border-y",offset:"outline-offset"},outline:{t:"outline-t",r:"outline-r",b:"outline-b",l:"outline-l",x:"outline-x",y:"outline-y",offset:"outline-offset"}}[r][e];return i?n.map(c=>`${i}-${c}`):[]}function sl(r,e){const t={};for(const o of r){const a=o.prefix.replace(/-$/,"");t[a]=o.value}const n={margin:"m",padding:"p",border:"border",outline:"outline"},s={margin:!1,padding:!1,border:!0,outline:!1};return["margin","outline","border","padding"].map(o=>{var h,d;const a=S0(o,t),l=a.slots.map(f=>{const m=C0(o,f.key,e);return m.length>0?{...f,scaleValues:m}:f}),u=(s[o]?(h=e==null?void 0:e.theme)!=null&&h.borderWidth?Object.keys(e.theme.borderWidth):dp:(d=e==null?void 0:e.theme)!=null&&d.spacing?Object.keys(e.theme.spacing):hc).map(f=>`${n[o]}-${f}`);return{...a,slots:l,shorthandScaleValues:u}})}function b0({label:r,availableProperties:e=[],onAddProperty:t,isEmpty:n=!1,children:s}){const[i,o]=V.useState(!1),a=V.useRef(null);V.useEffect(()=>{if(!i)return;function c(u){a.current&&!a.current.contains(u.target)&&o(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);function l(c){t==null||t(c),o(!1)}return S.jsxs("div",{className:"mb-1",children:[S.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[S.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),S.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:r}),e.length>0&&S.jsxs("div",{className:"relative ml-auto",ref:a,children:[S.jsx("button",{type:"button","aria-label":`Add ${r} property`,className:`w-[18px] h-[18px] flex items-center justify-center rounded text-[11px] leading-none border transition-colors cursor-pointer ${i?"border-bv-teal text-bv-teal bg-bv-teal/10":"border-bv-border text-bv-muted bg-transparent hover:border-bv-teal hover:text-bv-teal hover:bg-bv-teal/10"}`,onClick:()=>o(c=>!c),children:"+"}),i&&S.jsx("div",{className:"absolute z-50 top-[calc(100%+2px)] right-0 bg-bv-bg border border-bv-border rounded-md shadow-[0_4px_16px_rgba(0,0,0,0.10)] min-w-[180px] py-1",children:e.map(c=>S.jsxs("button",{type:"button",className:"w-full px-2.5 py-[5px] text-[11px] font-[family-name:var(--font-ui)] text-bv-text-mid flex items-center gap-1.5 transition-colors hover:bg-bv-teal/10 hover:text-bv-teal cursor-pointer border-none bg-transparent text-left",onClick:()=>l(c.prefix),children:[c.name,S.jsx("span",{className:"font-mono text-[10px] text-bv-muted group-hover:text-bv-teal/60",children:c.prefixHint})]},c.prefix))})]})]}),n?S.jsxs("div",{className:"text-[10px] text-bv-muted italic mb-2",children:["No ",r.toLowerCase()," classes — click + to add"]}):S.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:s}),S.jsx("hr",{className:"border-none border-t border-bv-border my-1"})]})}const td={spacing:"Spacing",sizing:"Sizing",typography:"Typography",color:"Color",borders:"Borders",effects:"Effects",layout:"Layout",flexbox:"Flexbox & Grid"},rd=new Set(["m-","mx-","my-","mt-","mr-","mb-","ml-","ms-","me-","p-","px-","py-","pt-","pr-","pb-","pl-","ps-","pe-","border-","border-t-","border-r-","border-b-","border-l-","outline-","outline-offset-","rounded-","rounded-t-","rounded-r-","rounded-b-","rounded-l-","rounded-tl-","rounded-tr-","rounded-br-","rounded-bl-","gap-","gap-x-","gap-y-","space-x-","space-y-"]),nd=new Set(["border","rounded"]),T0=[{name:"Font size",prefixHint:"text-{size}",prefix:"text-size"},{name:"Font weight",prefixHint:"font-*",prefix:"font-"},{name:"Text color",prefixHint:"text-{color}",prefix:"text-color"},{name:"Text align",prefixHint:"text-{align}",prefix:"text-align"},{name:"Line height",prefixHint:"leading-*",prefix:"leading-"},{name:"Letter spacing",prefixHint:"tracking-*",prefix:"tracking-"}],k0=[{name:"Width",prefixHint:"w-*",prefix:"w-"},{name:"Height",prefixHint:"h-*",prefix:"h-"},{name:"Min width",prefixHint:"min-w-*",prefix:"min-w-"},{name:"Max width",prefixHint:"max-w-*",prefix:"max-w-"},{name:"Min height",prefixHint:"min-h-*",prefix:"min-h-"},{name:"Max height",prefixHint:"max-h-*",prefix:"max-h-"},{name:"Size",prefixHint:"size-*",prefix:"size-"}],O0=[{name:"Background color",prefixHint:"bg-{color}",prefix:"bg-"}],sd=["sizing","typography","color"],fo={"w-":{parserPrefix:"w-",themeKey:"spacing",valueType:"scalar"},"h-":{parserPrefix:"h-",themeKey:"spacing",valueType:"scalar"},"min-w-":{parserPrefix:"min-w-",themeKey:"spacing",valueType:"scalar"},"max-w-":{parserPrefix:"max-w-",themeKey:"spacing",valueType:"scalar"},"min-h-":{parserPrefix:"min-h-",themeKey:"spacing",valueType:"scalar"},"max-h-":{parserPrefix:"max-h-",themeKey:"spacing",valueType:"scalar"},"size-":{parserPrefix:"size-",themeKey:"spacing",valueType:"scalar"},"font-":{parserPrefix:"font-",themeKey:"fontWeight",valueType:"scalar"},"text-size":{parserPrefix:"text-",themeKey:"fontSize",valueType:"scalar"},"text-color":{parserPrefix:"text-",themeKey:"colors",valueType:"color"},"text-align":{parserPrefix:"text-",themeKey:null,valueType:"enum"},"leading-":{parserPrefix:"leading-",themeKey:"lineHeight",valueType:"scalar"},"tracking-":{parserPrefix:"tracking-",themeKey:"letterSpacing",valueType:"scalar"},"bg-":{parserPrefix:"bg-",themeKey:"colors",valueType:"color"}};function E0(r,e,t,n){const s=new Set(e.map(i=>i.prefix));return r.filter(i=>{if(t.has(i.prefix)||n!=null&&n.has(i.prefix))return!1;const o=fo[i.prefix],a=(o==null?void 0:o.parserPrefix)??i.prefix;return!s.has(a)})}function D0(r){const e=new Map;for(const t of r){const n=e.get(t.category)||[];n.push(t),e.set(t.category,n)}return e}function P0({componentName:r,instanceCount:e,parsedClasses:t,tailwindConfig:n,patchManager:s}){const[i,o]=V.useState(null),[a,l]=V.useState(new Map),[c,u]=V.useState(new Set),h=V.useRef(t.map(T=>T.fullClass).join(" ")),d=t.map(T=>T.fullClass).join(" ");V.useEffect(()=>{h.current!==d&&(h.current=d,l(new Map),u(new Set))});const f=r,m=s.patches.filter(T=>T.status==="staged"),v=new Set(m.filter(T=>T.originalClass==="").map(T=>T.property));function w(T){return a.size===0?T:T.map(M=>{const R=a.get(`${M.layer}-shorthand`),B=M.slots.map(P=>{const z=a.get(`${M.layer}-${P.key}`);return z!==void 0?{...P,value:z}:P}),j=R??M.shorthandValue;let I=M.classState;return R!==void 0&&(I=B.some(z=>z.value!=null)?"mixed":"shorthand"),{...M,shorthandValue:j,classState:I,slots:B}})}const g=D0(t);function p(T,M){s.preview(T,M)}function y(){s.revertPreview()}function x(T,M,R){s.stage(f,T,M,R)}function _(T){s.revertPreview(),Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),o(T)}function E(T,M){s.preview(T.fullClass,M)}function D(T){s.revertPreview()}function k(T){u(M=>new Set(M).add(T))}function N(T,M){s.preview("",M)}function L(T){s.revertPreview()}function X(T,M){const R=fo[T];s.stage(f,(R==null?void 0:R.parserPrefix)??T,"",M),u(B=>{const j=new Set(B);return j.delete(T),j})}return S.jsxs("div",{className:"p-3",children:[S.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[S.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),S.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:"Box Model"})]}),S.jsx("div",{className:"mb-4",children:S.jsx(y0,{layers:w(sl(t,n)),onEditStart:()=>Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),onSlotHover:(T,M,R)=>{var B;if(R===null)s.revertPreview();else{const j=`${T}-${M}`,I=sl(t,n).find(z=>z.layer===T),P=M==="shorthand"?a.get(j)??(I==null?void 0:I.shorthandValue):a.get(j)??((B=I==null?void 0:I.slots.find(z=>z.key===M))==null?void 0:B.value);s.preview(P??"",R)}},onSlotChange:(T,M,R)=>{var P;const B=`${T}-${M}`,j=sl(t,n).find(z=>z.layer===T),I=M==="shorthand"?a.get(B)??(j==null?void 0:j.shorthandValue):a.get(B)??((P=j==null?void 0:j.slots.find(z=>z.key===M))==null?void 0:P.value);x(`${T}-${M}`,I??"",R),l(z=>new Map(z).set(B,R))}})}),sd.map(T=>{var z;const R=(g.get(T)||[]).filter(A=>!rd.has(A.prefix)&&!nd.has(A.fullClass)),B={typography:T0,sizing:k0,color:O0},j=E0(B[T]||[],R,c,v),I=(B[T]||[]).filter(A=>c.has(A.prefix)).map(A=>A.prefix),P=(B[T]||[]).filter(A=>v.has(A.prefix)).map(A=>A.prefix);return S.jsxs(b0,{label:T==="color"?"Backgrounds":td[T]||T,availableProperties:j,onAddProperty:k,isEmpty:R.length===0&&I.length===0&&P.length===0,children:[R.map(A=>{var U;if(A.valueType==="scalar"){const G=bi(A.prefix,A.themeKey,n);if(G.length>0){const ae=((U=m.find(ee=>ee.property===A.prefix))==null?void 0:U.newClass)??null;return S.jsx(Ci,{values:G,currentValue:A.fullClass,lockedValue:ae,locked:!1,onStart:()=>Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:ee=>E(A,ee),onLeave:()=>D(),onClick:ee=>x(A.prefix,A.fullClass,ee)},A.fullClass)}}return S.jsx("div",{className:`px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border transition-colors ${(i==null?void 0:i.fullClass)===A.fullClass?"border-bv-border bg-bv-surface-hi text-bv-text":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:text-bv-teal"}`,onClick:()=>_(A),children:A.fullClass},A.fullClass)}),(B[T]||[]).filter(A=>v.has(A.prefix)).map(A=>{const U=fo[A.prefix];if(!U||U.valueType!=="scalar")return null;const G=bi(U.parserPrefix,U.themeKey,n);if(G.length===0)return null;const ae=m.find(ee=>ee.property===(U.parserPrefix??A.prefix));return S.jsx(Ci,{values:G,currentValue:(ae==null?void 0:ae.newClass)??G[Math.floor(G.length/2)],lockedValue:(ae==null?void 0:ae.newClass)??null,locked:!1,onStart:()=>Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:ee=>N(A.prefix,ee),onLeave:()=>L(A.prefix),onClick:ee=>X(A.prefix,ee)},`staged-${A.prefix}`)}),I.map(A=>{const U=fo[A];if(!U)return null;if(U.valueType==="scalar"){const G=bi(U.parserPrefix,U.themeKey,n);if(G.length>0)return S.jsx(Ci,{values:G,currentValue:G[Math.floor(G.length/2)],lockedValue:null,locked:!1,ghost:!0,onStart:()=>Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:ae=>N(A,ae),onLeave:()=>L(),onClick:ae=>X(A,ae)},`pending-${A}`)}return U.valueType==="color"?S.jsxs("div",{"data-testid":`pending-ghost-${A}`,className:"px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border border-dashed border-bv-border text-bv-muted hover:border-bv-teal hover:text-bv-teal transition-colors",onClick:()=>{o({category:"color",valueType:"color",prefix:U.parserPrefix,value:"",fullClass:"",themeKey:"colors"})},children:[U.parserPrefix,"color"]},`pending-${A}`):null}),i&&R.some(A=>A.fullClass===i.fullClass)&&i.valueType==="color"&&S.jsx(qh,{prefix:i.prefix,currentValue:i.value,colors:(n==null?void 0:n.colors)||{},locked:!1,lockedValue:((z=m.find(A=>A.property===i.prefix))==null?void 0:z.newClass)??null,onHover:A=>p(i.fullClass,A),onLeave:y,onClick:A=>x(i.prefix,i.fullClass,A)})]},T)}),Array.from(g).filter(([T])=>!sd.includes(T)).map(([T,M])=>{var B;const R=M.filter(j=>!rd.has(j.prefix)&&!nd.has(j.fullClass));return R.length===0?null:S.jsxs("div",{children:[S.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[S.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),S.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:td[T]||T})]}),S.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:R.map(j=>{var I;if(j.valueType==="scalar"){const P=bi(j.prefix,j.themeKey,n);if(P.length>0){const z=((I=m.find(A=>A.property===j.prefix))==null?void 0:I.newClass)??null;return S.jsx(Ci,{values:P,currentValue:j.fullClass,lockedValue:z,locked:!1,onStart:()=>Re("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:A=>E(j,A),onLeave:()=>D(),onClick:A=>x(j.prefix,j.fullClass,A)},j.fullClass)}}return S.jsx("div",{className:`px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border transition-colors ${(i==null?void 0:i.fullClass)===j.fullClass?"border-bv-border bg-bv-surface-hi text-bv-text":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:text-bv-teal"}`,onClick:()=>_(j),children:j.fullClass},j.fullClass)})}),i&&R.some(j=>j.fullClass===i.fullClass)&&i.valueType==="color"&&S.jsx(qh,{prefix:i.prefix,currentValue:i.value,colors:(n==null?void 0:n.colors)||{},locked:!1,lockedValue:((B=m.find(j=>j.property===i.prefix))==null?void 0:B.newClass)??null,onHover:j=>p(i.fullClass,j),onLeave:y,onClick:j=>x(i.prefix,i.fullClass,j)})]},T)})]})}function M0(){const[r,e]=V.useState([]),[t,n]=V.useState({draft:0,committed:0,implementing:0,implemented:0,partial:0,error:0}),[s,i]=V.useState({draft:[],commits:[]}),o=V.useRef(r);o.current=r;const a=V.useRef(s);a.current=s;const l=V.useCallback((x,_)=>{Re("overlay",{type:"PATCH_PREVIEW",oldClass:x,newClass:_})},[]),c=V.useCallback(()=>{Re("overlay",{type:"PATCH_REVERT"})},[]),u=V.useCallback((x,_,E,D)=>{if(D===E){e(N=>N.filter(L=>!(L.kind==="class-change"&&L.elementKey===x&&L.property===_))),Re("overlay",{type:"PATCH_REVERT"});return}const k=crypto.randomUUID();e(N=>{const L=N.filter(T=>!(T.kind==="class-change"&&T.elementKey===x&&T.property===_)),X={id:k,kind:"class-change",elementKey:x,status:"staged",originalClass:E,newClass:D,property:_,timestamp:new Date().toISOString()};return[...L,X]}),Re("overlay",{type:"PATCH_STAGE",id:k,oldClass:E,newClass:D,property:_})},[]),h=V.useCallback((x,_,E)=>{const D=crypto.randomUUID(),k=E?{name:E}:void 0;e(N=>{const L={id:D,kind:"message",elementKey:_,status:"staged",originalClass:"",newClass:"",property:"",timestamp:new Date().toISOString(),message:x,component:k};return[...N,L]}),Qt(k?{type:"MESSAGE_STAGE",id:D,message:x,elementKey:_,component:k}:{type:"MESSAGE_STAGE",id:D,message:x,elementKey:_})},[]),d=V.useCallback(()=>{const x=a.current.draft.map(D=>D.id),_=o.current.filter(D=>D.status==="staged").map(D=>D.id),E=Array.from(new Set([...x,..._]));E.length!==0&&(Qt({type:"PATCH_COMMIT",ids:E}),e([]))},[]),f=V.useCallback(x=>{e(_=>_.filter(E=>E.id!==x)),Qt({type:"DISCARD_DRAFTS",ids:[x]}),Re("overlay",{type:"PATCH_REVERT"})},[]),m=V.useCallback(()=>{const x=a.current.draft.map(D=>D.id),_=o.current.filter(D=>D.status==="staged").map(D=>D.id),E=Array.from(new Set([...x,..._]));e([]),E.length>0&&Qt({type:"DISCARD_DRAFTS",ids:E}),Re("overlay",{type:"PATCH_REVERT"})},[]),v=V.useCallback(()=>{},[]),w=V.useCallback(x=>{n({draft:x.draftCount,committed:x.committedCount,implementing:x.implementingCount,implemented:x.implementedCount,partial:x.partialCount,error:x.errorCount}),i({draft:x.draft,commits:x.commits})},[]),g=V.useCallback(x=>{n({draft:x.staged,committed:x.committed,implementing:x.implementing,implemented:x.implemented,partial:0,error:0})},[]),p=r.filter(x=>x.status==="staged").length,y={draft:Math.max(p,t.draft),committed:t.committed,implementing:t.implementing,implemented:t.implemented,partial:t.partial,error:t.error};return{patches:r,counts:y,queueState:s,preview:l,revertPreview:c,stage:u,stageMessage:h,commitAll:d,discard:f,discardAll:m,reset:v,handleQueueUpdate:w,handlePatchUpdate:g}}function Ti({label:r,count:e,items:t,activeColor:n,onCommit:s,onDiscard:i,onCommitAll:o,onDiscardAll:a}){const[l,c]=V.useState(!1),u=V.useRef(null),h=V.useRef(null),[d,f]=V.useState(void 0);V.useEffect(()=>{if(!l||!h.current)return;const g=h.current.getBoundingClientRect(),p=220,y=window.innerWidth,x=4;let _=g.left+g.width/2-p/2;_=Math.max(x,Math.min(_,y-p-x)),f(_-g.left)},[l]),V.useEffect(()=>{if(!l)return;function w(g){u.current&&!u.current.contains(g.target)&&c(!1)}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),V.useEffect(()=>{if(!l)return;function w(g){g.key==="Escape"&&c(!1)}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[l]);const m=e>0,v=s||i||o||a;return S.jsxs("div",{ref:u,className:"relative",children:[S.jsxs("button",{ref:h,className:`text-[11px] tabular-nums border-none bg-transparent cursor-pointer px-0 py-0 ${m?`${n} font-medium`:"text-bv-muted"} ${m?"hover:underline":""}`,onClick:()=>m&&c(!l),disabled:!m,type:"button",children:[e," ",r]}),l&&S.jsxs("div",{className:"absolute bottom-full mb-1 min-w-[220px] bg-bv-surface border border-bv-border rounded-lg shadow-lg overflow-hidden flex flex-col z-[9999]",style:d!==void 0?{left:`${d}px`}:void 0,children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-bv-border text-[11px] font-semibold text-bv-text-mid uppercase tracking-wide",children:[r," (",e,")"]}),S.jsx("div",{className:"flex-1 overflow-auto",children:t.length===0?S.jsx("div",{className:"px-3 py-2 text-[11px] text-bv-muted italic",children:"No patches"}):t.map(w=>{var y,x;const g="kind"in w&&w.kind==="message",p="kind"in w&&w.kind==="design";return S.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-bv-border last:border-b-0 group",children:[S.jsxs("div",{className:"flex-1 min-w-0",children:[!g&&!p&&((y=w.component)==null?void 0:y.name)&&S.jsx("div",{className:"text-[10px] text-bv-muted truncate",children:w.component.name}),p?S.jsxs("div",{className:"text-[11px] text-bv-text",children:[S.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[S.jsx("span",{children:"✏️"}),S.jsxs("span",{className:"truncate",children:["Drawing",(x=w.component)!=null&&x.name?` in ${w.component.name}`:""]})]}),"image"in w&&w.image&&S.jsx("img",{src:w.image,alt:"Design drawing",className:"w-full max-h-16 object-contain rounded border border-bv-border bg-white"})]}):g?S.jsxs("div",{className:"text-[11px] text-bv-text truncate",children:[S.jsx("span",{className:"mr-1",children:"💬"}),'"',"message"in w&&w.message||"",'"']}):S.jsx("div",{className:"text-[11px] font-mono text-bv-text truncate",children:w.originalClass?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"line-through text-bv-muted",children:w.originalClass})," → ",S.jsx("span",{className:"text-bv-teal",children:w.newClass})]}):S.jsxs("span",{className:"text-bv-teal",children:["+",w.newClass]})})]}),(s||i)&&S.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[s&&S.jsx("button",{className:"text-[10px] px-1.5 py-0.5 rounded border-none cursor-pointer bg-bv-teal text-white hover:bg-bv-teal-dark transition-colors",onClick:_=>{_.stopPropagation(),s(w.id)},title:"Commit to Agent",type:"button",children:"✓"}),i&&S.jsx("button",{className:"text-[10px] px-1.5 py-0.5 rounded border-none cursor-pointer bg-transparent text-bv-muted hover:text-bv-orange hover:bg-bv-surface-hi transition-colors",onClick:_=>{_.stopPropagation(),i(w.id)},title:"Discard",type:"button",children:"✕"})]})]},w.id)})}),v&&t.length>0&&(o||a)&&S.jsxs("div",{className:"flex gap-2 px-3 py-1.5 border-t border-bv-border",children:[o&&S.jsx("button",{className:"text-[10px] px-2 py-1 rounded border-none cursor-pointer font-semibold bg-bv-teal text-white hover:bg-bv-teal-dark transition-colors",onClick:()=>{o(),c(!1)},type:"button",children:"Commit All"}),a&&S.jsx("button",{className:"text-[10px] px-2 py-1 rounded cursor-pointer font-semibold bg-transparent border border-bv-border text-bv-text-mid hover:text-bv-orange hover:border-bv-orange transition-colors",onClick:()=>{a(),c(!1)},type:"button",children:"Discard All"})]})]})]})}function id({tabs:r,activeTab:e,onTabChange:t}){const[n,s]=V.useState(null);return S.jsx("div",{className:"relative flex border-b border-bv-border px-3",children:r.map(i=>{const o=i.id===e,a=i.disabled===!0;return S.jsxs("div",{className:"relative",onMouseEnter:()=>a&&i.tooltip&&s(i.id),onMouseLeave:()=>s(null),children:[S.jsxs("button",{type:"button",className:`relative px-3 py-2 text-[12px] font-medium font-[family-name:var(--font-ui)] border-none bg-transparent cursor-pointer transition-colors ${a?"text-bv-muted cursor-not-allowed":o?"text-bv-text":"text-bv-text-mid hover:text-bv-text"}`,disabled:a,onClick:()=>!a&&t(i.id),"aria-selected":o,role:"tab",children:[i.label,o&&S.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-[2px] bg-bv-teal"})]}),n===i.id&&i.tooltip&&S.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-[10px] text-white bg-bv-text rounded whitespace-nowrap z-[9999]",children:i.tooltip})]},i.id)})})}function od({draft:r,currentElementKey:e,onAddMessage:t,onDiscard:n}){const[s,i]=V.useState(""),o=V.useRef(null);V.useEffect(()=>{var h;(h=o.current)==null||h.focus()},[]);const a=r.filter(h=>h.kind==="message"),l=!!s.trim()&&!!e;function c(){var d;const h=s.trim();!h||!e||(t(h,e),i(""),(d=o.current)==null||d.focus())}function u(h){(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),c())}return S.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsx("textarea",{ref:o,className:"w-full min-h-[80px] p-2 bg-bv-bg border border-bv-border rounded text-[13px] font-[family-name:var(--font-ui)] text-bv-text placeholder:text-bv-muted resize-y focus:outline-none focus:border-bv-teal",placeholder:e?"Add context for the AI agent…":"Select an element to add contextual message…",value:s,onChange:h=>i(h.target.value),onKeyDown:u,disabled:!e}),S.jsx("div",{className:"flex items-center justify-end",children:S.jsx("button",{type:"button",className:"px-3 py-1 text-[11px] font-semibold rounded bg-bv-teal text-white border-none cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",disabled:!l,onClick:c,children:"Add Message"})})]}),a.length>0&&S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),S.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:"Staged Messages"})]}),a.map(h=>{var d;return S.jsxs("div",{className:"flex items-start gap-2 p-2 bg-bv-surface rounded border border-bv-border group",children:[S.jsx("span",{className:"text-[12px] shrink-0 mt-0.5",children:"💬"}),S.jsxs("div",{className:"flex-1 min-w-0",children:[S.jsxs("div",{className:"text-[12px] font-[family-name:var(--font-ui)] text-bv-text break-words",children:['"',h.message,'"']}),h.elementKey&&S.jsx("div",{className:"text-[11px] text-bv-text-mid mt-0.5",children:((d=h.component)==null?void 0:d.name)||h.elementKey})]}),S.jsx("button",{type:"button",className:"shrink-0 text-[10px] px-1 py-0.5 rounded border-none cursor-pointer bg-transparent text-bv-muted hover:text-bv-orange transition-colors opacity-0 group-hover:opacity-100",onClick:()=>n(h.id),title:"Discard",children:"✕"})]},h.id)})]})]})}const dc=[{name:"popover",label:"Popover",icon:S.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[S.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),S.jsx("rect",{x:"4",y:"4",width:"8",height:"6",rx:"1",fill:"currentColor"})]})},{name:"sidebar",label:"Sidebar",icon:S.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[S.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),S.jsx("rect",{x:"9",y:"1",width:"6",height:"14",rx:"1.5",fill:"currentColor",opacity:"0.85"})]})},{name:"modal",label:"Modal",icon:S.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[S.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",fill:"currentColor",opacity:"0.12"}),S.jsx("rect",{x:"3",y:"4",width:"10",height:"8",rx:"1",fill:"currentColor",opacity:"0.9"})]})},{name:"popup",label:"Popup",icon:S.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[S.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),S.jsx("rect",{x:"8",y:"8",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.85"})]})}],fp="tw-panel-container";function j0(){try{const r=localStorage.getItem(fp);if(r&&dc.some(e=>e.name===r))return r}catch{}return"popover"}function A0(){const[r,e]=V.useState(j0),[t,n]=V.useState(!1),s=V.useRef(null);V.useEffect(()=>{function a(l){s.current&&!s.current.contains(l.target)&&n(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]);function i(a){if(a!==r){try{localStorage.setItem(fp,a)}catch{}e(a),Re("overlay",{type:"SWITCH_CONTAINER",container:a})}n(!1)}const o=dc.find(a=>a.name===r);return S.jsxs("div",{ref:s,className:"relative",children:[S.jsx("button",{title:"Change container",onClick:()=>n(a=>!a),className:"w-7 h-7 flex items-center justify-center rounded border border-transparent text-bv-text-mid bg-transparent cursor-pointer transition-colors hover:bg-bv-surface hover:border-bv-border hover:text-bv-text",children:o.icon}),t&&S.jsxs("div",{className:"absolute top-[calc(100%+4px)] right-0 bg-white border border-bv-border rounded-lg shadow-[0_4px_16px_rgba(0,0,0,0.12)] p-1.5 flex flex-col gap-px min-w-[148px] z-50",children:[S.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.8px] text-bv-muted px-2 pt-1 pb-1.5",children:"Container"}),dc.map(a=>S.jsxs("button",{onClick:()=>i(a.name),className:`flex items-center gap-2 px-2 py-1.5 rounded text-[12px] cursor-pointer border-none w-full text-left transition-colors ${a.name===r?"bg-bv-teal/9 text-bv-teal":"bg-transparent text-bv-text-mid hover:bg-bv-surface hover:text-bv-text"}`,children:[a.icon,a.label]},a.name))]})]})}function L0({componentName:r}){const e=t=>{Re("overlay",{type:"INSERT_DESIGN_CANVAS",insertMode:t})};return S.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[S.jsx("div",{className:"text-[11px] text-bv-text-mid leading-relaxed",children:"Insert a drawing canvas into the page to visually sketch a new UI element. The sketch will be queued as a change for an AI agent to implement."}),S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted",children:"Insert Drawing Canvas"}),S.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[S.jsxs("button",{onClick:()=>e("before"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[S.jsx("span",{className:"text-[13px]",children:"↑"}),"Before element"]}),S.jsxs("button",{onClick:()=>e("after"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[S.jsx("span",{className:"text-[13px]",children:"↓"}),"After element"]}),S.jsxs("button",{onClick:()=>e("first-child"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[S.jsx("span",{className:"text-[13px]",children:"⤒"}),"First child"]}),S.jsxs("button",{onClick:()=>e("last-child"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[S.jsx("span",{className:"text-[13px]",children:"⤓"}),"Last child"]})]})]}),S.jsxs("div",{className:"text-[9px] text-bv-muted italic",children:["The canvas will be injected relative to the selected ",S.jsxs("span",{className:"font-mono",children:["<",r,">"]})," element."]})]})}function C(r,e,t){return(e=function(n){var s=function(i,o){if(typeof i!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}(n,"string");return typeof s=="symbol"?s:s+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ad(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function b(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ad(Object(t),!0).forEach(function(n){C(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ad(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function ie(r,e){if(r==null)return{};var t,n,s=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||{}.propertyIsEnumerable.call(r,t)&&(s[t]=r[t])}return s}function Ht(r,e){return e||(e=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(e)}}))}class ld{constructor(){C(this,"browserShadowBlurConstant",1),C(this,"DPI",96),C(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),C(this,"perfLimitSizeTotal",2097152),C(this,"maxCacheSideLimit",4096),C(this,"minCacheSideLimit",256),C(this,"disableStyleCopyPaste",!1),C(this,"enableGLFiltering",!0),C(this,"textureSize",4096),C(this,"forceGLPutImageData",!1),C(this,"cachesBoundsOfCurve",!1),C(this,"fontPaths",{}),C(this,"NUM_FRACTION_DIGITS",4)}}const q=new class extends ld{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=b(b({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(r=>{delete this.fontPaths[r]})}clearFonts(){this.fontPaths={}}restoreDefaults(r){const e=new ld,t=(r==null?void 0:r.reduce((n,s)=>(n[s]=e[s],n),{}))||e;this.configure(t)}},Rr=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return console[r]("fabric",...t)};class It extends Error{constructor(e,t){super("fabric: ".concat(e),t)}}class F0 extends It{constructor(e){super("".concat(e," 'options.signal' is in 'aborted' state"))}}class R0{}class N0 extends R0{testPrecision(e,t){const n="precision ".concat(t,` float;
41
- void main(){}`),s=e.createShader(e.FRAGMENT_SHADER);return!!s&&(e.shaderSource(s,n),e.compileShader(s),!!e.getShaderParameter(s,e.COMPILE_STATUS))}queryWebGL(e){const t=e.getContext("webgl");t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(n=>this.testPrecision(t,n)),t.getExtension("WEBGL_lose_context").loseContext(),Rr("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}}const I0={};let cd;const Wt=()=>cd||(cd={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new N0,dispose(){},copyPasteData:I0}),Gn=()=>Wt().document,xa=()=>Wt().window,gp=()=>{var r;return Math.max((r=q.devicePixelRatio)!==null&&r!==void 0?r:xa().devicePixelRatio,1)},Ts=new class{constructor(){C(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(r){let{fontFamily:e,fontStyle:t,fontWeight:n}=r;e=e.toLowerCase();const s=this.charWidthsCache;s.has(e)||s.set(e,new Map);const i=s.get(e),o="".concat(t.toLowerCase(),"_").concat((n+"").toLowerCase());return i.has(o)||i.set(o,new Map),i.get(o)}clearFontCache(r){r?this.charWidthsCache.delete((r||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(r){const{perfLimitSizeTotal:e}=q,t=Math.sqrt(e*r);return[Math.floor(t),Math.floor(e/t)]}},fc="6.9.1";function go(){}const ni=Math.PI/2,Xo=2*Math.PI,wu=Math.PI/180,ze=Object.freeze([1,0,0,1,0,0]),Su=16,mr=.4477152502,$="center",J="left",Ge="top",gc="bottom",fe="right",Ke="none",Cu=/\r?\n/,pp="moving",_a="scaling",mp="rotating",bu="rotate",vp="skewing",$s="resizing",z0="modifyPoly",B0="modifyPath",Uo="changed",wa="scale",Qe="scaleX",gt="scaleY",Kn="skewX",qn="skewY",_e="fill",qe="stroke",$o="modified",un="json",il="svg",W=new class{constructor(){this[un]=new Map,this[il]=new Map}has(r){return this[un].has(r)}getClass(r){const e=this[un].get(r);if(!e)throw new It("No class registered for ".concat(r));return e}setClass(r,e){e?this[un].set(e,r):(this[un].set(r.type,r),this[un].set(r.type.toLowerCase(),r))}getSVGClass(r){return this[il].get(r)}setSVGClass(r,e){this[il].set(e??r.type.toLowerCase(),r)}},Yo=new class extends Array{remove(r){const e=this.indexOf(r);e>-1&&this.splice(e,1)}cancelAll(){const r=this.splice(0);return r.forEach(e=>e.abort()),r}cancelByCanvas(r){if(!r)return[];const e=this.filter(t=>{var n;return t.target===r||typeof t.target=="object"&&((n=t.target)===null||n===void 0?void 0:n.canvas)===r});return e.forEach(t=>t.abort()),e}cancelByTarget(r){if(!r)return[];const e=this.filter(t=>t.target===r);return e.forEach(t=>t.abort()),e}};class V0{constructor(){C(this,"__eventListeners",{})}on(e,t){if(this.__eventListeners||(this.__eventListeners={}),typeof e=="object")return Object.entries(e).forEach(n=>{let[s,i]=n;this.on(s,i)}),()=>this.off(e);if(t){const n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}return()=>!1}once(e,t){if(typeof e=="object"){const n=[];return Object.entries(e).forEach(s=>{let[i,o]=s;n.push(this.once(i,o))}),()=>n.forEach(s=>s())}if(t){const n=this.on(e,function(){for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];t.call(this,...i),n()});return n}return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){const n=this.__eventListeners[e],s=n.indexOf(t);s>-1&&n.splice(s,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(const n in this.__eventListeners)this._removeEventListener(n);else typeof e=="object"?Object.entries(e).forEach(n=>{let[s,i]=n;this._removeEventListener(s,i)}):this._removeEventListener(e,t)}fire(e,t){var n;if(!this.__eventListeners)return;const s=(n=this.__eventListeners[e])===null||n===void 0?void 0:n.concat();if(s)for(let i=0;i<s.length;i++)s[i].call(this,t||{})}}const dn=(r,e)=>{const t=r.indexOf(e);return t!==-1&&r.splice(t,1),r},or=r=>{if(r===0)return 1;switch(Math.abs(r)/ni){case 1:case 3:return 0;case 2:return-1}return Math.cos(r)},ar=r=>{if(r===0)return 0;const e=r/ni,t=Math.sign(r);switch(e){case 1:return t;case 2:return 0;case 3:return-t}return Math.sin(r)};class O{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof e=="object"?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(e){return new O(this.x+e.x,this.y+e.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(e){return new O(this.x+e,this.y+e)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(e){return new O(this.x-e.x,this.y-e.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(e){return new O(this.x-e,this.y-e)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(e){return new O(this.x*e.x,this.y*e.y)}scalarMultiply(e){return new O(this.x*e,this.y*e)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(e){return new O(this.x/e.x,this.y/e.y)}scalarDivide(e){return new O(this.x/e,this.y/e)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return t=Math.max(Math.min(1,t),0),new O(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}distanceFrom(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(e){return new O(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new O(Math.max(this.x,e.x),Math.max(this.y,e.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){const t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new O(this.x,this.y)}rotate(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tu;const n=ar(e),s=or(e),i=this.subtract(t);return new O(i.x*s-i.y*n,i.x*n+i.y*s).add(t)}transform(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new O(e[0]*this.x+e[2]*this.y+(t?0:e[4]),e[1]*this.x+e[3]*this.y+(t?0:e[5]))}}const Tu=new O(0,0),po=r=>!!r&&Array.isArray(r._objects);function yp(r){class e extends r{constructor(){super(...arguments),C(this,"_objects",[])}_onObjectAdded(n){}_onObjectRemoved(n){}_onStackOrderChanged(n){}add(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(n){for(var s=arguments.length,i=new Array(s>1?s-1:0),o=1;o<s;o++)i[o-1]=arguments[o];return this._objects.splice(n,0,...i),i.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const n=this._objects,s=[];for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach(l=>{const c=n.indexOf(l);c!==-1&&(n.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(n){this.getObjects().forEach((s,i,o)=>n(s,i,o))}getObjects(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(n){return this._objects[n]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(n,s){return!!this._objects.includes(n)||!!s&&this._objects.some(i=>i instanceof e&&i.contains(n,!0))}complexity(){return this._objects.reduce((n,s)=>n+=s.complexity?s.complexity():0,0)}sendObjectToBack(n){return!(!n||n===this._objects[0])&&(dn(this._objects,n),this._objects.unshift(n),this._onStackOrderChanged(n),!0)}bringObjectToFront(n){return!(!n||n===this._objects[this._objects.length-1])&&(dn(this._objects,n),this._objects.push(n),this._onStackOrderChanged(n),!0)}sendObjectBackwards(n,s){if(!n)return!1;const i=this._objects.indexOf(n);if(i!==0){const o=this.findNewLowerIndex(n,i,s);return dn(this._objects,n),this._objects.splice(o,0,n),this._onStackOrderChanged(n),!0}return!1}bringObjectForward(n,s){if(!n)return!1;const i=this._objects.indexOf(n);if(i!==this._objects.length-1){const o=this.findNewUpperIndex(n,i,s);return dn(this._objects,n),this._objects.splice(o,0,n),this._onStackOrderChanged(n),!0}return!1}moveObjectTo(n,s){return n!==this._objects[s]&&(dn(this._objects,n),this._objects.splice(s,0,n),this._onStackOrderChanged(n),!0)}findNewLowerIndex(n,s,i){let o;if(i){o=s;for(let a=s-1;a>=0;--a)if(n.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(n,s,i){let o;if(i){o=s;for(let a=s+1;a<this._objects.length;++a)if(n.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(n){let{left:s,top:i,width:o,height:a}=n,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],u=new O(s,i),h=u.add(new O(o,a));for(let d=this._objects.length-1;d>=0;d--){const f=this._objects[d];f.selectable&&f.visible&&(l&&f.intersectsWithRect(u,h)||f.isContainedWithinRect(u,h)||l&&f.containsPoint(u)||l&&f.containsPoint(h))&&c.push(f)}return c}}return e}class xp extends V0{_setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const t in e)this.set(t,e[t])}_setObject(e){for(const t in e)this._set(t,e[t])}set(e,t){return typeof e=="object"?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){const t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this}get(e){return this[e]}}function mo(r){return xa().requestAnimationFrame(r)}function W0(r){return xa().cancelAnimationFrame(r)}let H0=0;const Nr=()=>H0++,lr=()=>{const r=Gn().createElement("canvas");if(!r||r.getContext===void 0)throw new It("Failed to create `canvas` element");return r},X0=()=>Gn().createElement("img"),pt=r=>{const e=lr();return e.width=r.width,e.height=r.height,e},_p=(r,e,t)=>r.toDataURL("image/".concat(e),t),wp=(r,e,t)=>new Promise((n,s)=>{r.toBlob(n,"image/".concat(e),t)}),pe=r=>r*wu,cr=r=>r/wu,U0=r=>r.every((e,t)=>e===ze[t]),We=(r,e,t)=>new O(r).transform(e,t),Tt=r=>{const e=1/(r[0]*r[3]-r[1]*r[2]),t=[e*r[3],-e*r[1],-e*r[2],e*r[0],0,0],{x:n,y:s}=new O(r[4],r[5]).transform(t,!0);return t[4]=-n,t[5]=-s,t},Te=(r,e,t)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],t?0:r[0]*e[4]+r[2]*e[5]+r[4],t?0:r[1]*e[4]+r[3]*e[5]+r[5]],ku=(r,e)=>r.reduceRight((t,n)=>n&&t?Te(n,t,e):n||t,void 0)||ze.concat(),Sp=r=>{let[e,t]=r;return Math.atan2(t,e)},Go=r=>{const e=Sp(r),t=Math.pow(r[0],2)+Math.pow(r[1],2),n=Math.sqrt(t),s=(r[0]*r[3]-r[2]*r[1])/n,i=Math.atan2(r[0]*r[2]+r[1]*r[3],t);return{angle:cr(e),scaleX:n,scaleY:s,skewX:cr(i),skewY:0,translateX:r[4]||0,translateY:r[5]||0}},si=function(r){return[1,0,0,1,r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Qn(){let{angle:r=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:e=0,y:t=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=pe(r),s=or(n),i=ar(n);return[s,i,-i,s,e?e-(s*e-i*t):0,t?t-(i*e+s*t):0]}const Ou=function(r){return[r,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:r,0,0]},Cp=r=>Math.tan(pe(r)),bp=r=>[1,0,Cp(r),1,0,0],Tp=r=>[1,Cp(r),0,1,0,0],Sa=r=>{let{scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:s=!1,skewX:i=0,skewY:o=0}=r,a=Ou(n?-e:e,s?-t:t);return i&&(a=Te(a,bp(i),!0)),o&&(a=Te(a,Tp(o),!0)),a},$0=r=>{const{translateX:e=0,translateY:t=0,angle:n=0}=r;let s=si(e,t);n&&(s=Te(s,Qn({angle:n})));const i=Sa(r);return U0(i)||(s=Te(s,i)),s},vo=function(r){let{signal:e,crossOrigin:t=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(n,s){if(e&&e.aborted)return s(new F0("loadImage"));const i=X0();let o;e&&(o=function(l){i.src="",s(l)},e.addEventListener("abort",o,{once:!0}));const a=function(){i.onload=i.onerror=null,o&&(e==null||e.removeEventListener("abort",o)),n(i)};r?(i.onload=a,i.onerror=function(){o&&(e==null||e.removeEventListener("abort",o)),s(new It("Error loading ".concat(i.src)))},t&&(i.crossOrigin=t),i.src=r):a()})},Ys=function(r){let{signal:e,reviver:t=go}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((n,s)=>{const i=[];e&&e.addEventListener("abort",s,{once:!0}),Promise.all(r.map(o=>W.getClass(o.type).fromObject(o,{signal:e}).then(a=>(t(o,a),i.push(a),a)))).then(n).catch(o=>{i.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{e&&e.removeEventListener("abort",s)})})},Ca=function(r){let{signal:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((t,n)=>{const s=[];e&&e.addEventListener("abort",n,{once:!0});const i=Object.values(r).map(a=>a&&a.type&&W.has(a.type)?Ys([a],{signal:e}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(r);Promise.all(i).then(a=>a.reduce((l,c,u)=>(l[o[u]]=c,l),{})).then(t).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),n(a)}).finally(()=>{e&&e.removeEventListener("abort",n)})})},Jn=function(r){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((e,t)=>(t in r&&(e[t]=r[t]),e),{})},Eu=(r,e)=>Object.keys(r).reduce((t,n)=>(e(r[n],n,r)&&(t[n]=r[n]),t),{}),te=(r,e)=>parseFloat(Number(r).toFixed(e)),Gs=r=>"matrix("+r.map(e=>te(e,q.NUM_FRACTION_DIGITS)).join(" ")+")",ct=r=>!!r&&r.toLive!==void 0,ud=r=>!!r&&typeof r.toObject=="function",hd=r=>!!r&&r.offsetX!==void 0&&"source"in r,Xr=r=>!!r&&"multiSelectionStacking"in r;function kp(r){const e=r&&bt(r);let t=0,n=0;if(!r||!e)return{left:t,top:n};let s=r;const i=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===e?(t=o.scrollLeft||i.scrollLeft||0,n=o.scrollTop||i.scrollTop||0):(t+=s.scrollLeft||0,n+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:t,top:n}}const bt=r=>r.ownerDocument||null,Op=r=>{var e;return((e=r.ownerDocument)===null||e===void 0?void 0:e.defaultView)||null},Ep=function(r,e,t){let{width:n,height:s}=t,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;r.width=n,r.height=s,i>1&&(r.setAttribute("width",(n*i).toString()),r.setAttribute("height",(s*i).toString()),e.scale(i,i))},pc=(r,e)=>{let{width:t,height:n}=e;t&&(r.style.width=typeof t=="number"?"".concat(t,"px"):t),n&&(r.style.height=typeof n=="number"?"".concat(n,"px"):n)};function dd(r){return r.onselectstart!==void 0&&(r.onselectstart=()=>!1),r.style.userSelect=Ke,r}class Dp{constructor(e){C(this,"_originalCanvasStyle",void 0),C(this,"lower",void 0);const t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext("2d")}}createLowerCanvas(e){const t=(n=e)&&n.getContext!==void 0?e:e&&Gn().getElementById(e)||lr();var n;if(t.hasAttribute("data-fabric"))throw new It("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=t.style.cssText,t.setAttribute("data-fabric","main"),t.classList.add("lower-canvas"),t}cleanupDOM(e){let{width:t,height:n}=e;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(t)),s.setAttribute("height","".concat(n)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(e,t){const{el:n,ctx:s}=this.lower;Ep(n,s,e,t)}setCSSDimensions(e){pc(this.lower.el,e)}calcOffset(){return function(e){var t;const n=e&&bt(e),s={left:0,top:0};if(!n)return s;const i=((t=Op(e))===null||t===void 0?void 0:t.getComputedStyle(e,null))||{};s.left+=parseInt(i.borderLeftWidth,10)||0,s.top+=parseInt(i.borderTopWidth,10)||0,s.left+=parseInt(i.paddingLeft,10)||0,s.top+=parseInt(i.paddingTop,10)||0;let o={left:0,top:0};const a=n.documentElement;e.getBoundingClientRect!==void 0&&(o=e.getBoundingClientRect());const l=kp(e);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}}(this.lower.el)}dispose(){Wt().dispose(this.lower.el),delete this.lower}}const Y0={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...ze]},G0=["objects"];class ii extends yp(xp){get lowerCanvasEl(){var e;return(e=this.elements.lower)===null||e===void 0?void 0:e.el}get contextContainer(){var e;return(e=this.elements.lower)===null||e===void 0?void 0:e.ctx}static getDefaults(){return ii.ownDefaults}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new Dp(e)}add(){const e=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}insertAt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];const i=super.insertAt(e,...n);return n.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),i}remove(){const e=super.remove(...arguments);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(Rr("warn",`Canvas is trying to add an object that belongs to a different canvas.
42
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set("canvas",this),e.setCoords(),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e){e._set("canvas",void 0),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?gp():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(e,t){return this.setDimensions({width:e},t)}setHeight(e,t){return this.setDimensions({height:e},t)}_setDimensionsImpl(e){let{cssOnly:t=!1,backstoreOnly:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!t){const s=b({width:this.width,height:this.height},e);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){const n=e,s=[...this.viewportTransform],i=We(e,Tt(s));s[0]=t,s[3]=t;const o=We(i,s);s[4]+=n.x-o.x,s[5]+=n.y-o.y,this.setViewportTransform(s)}setZoom(e){this.zoomToPoint(new O(0,0),e)}absolutePan(e){const t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new O(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=mo(()=>this.renderAndReset()))}calcViewportBoundaries(){const e=this.width,t=this.height,n=Tt(this.viewportTransform),s=We({x:0,y:0},n),i=We({x:e,y:t},n),o=s.min(i),a=s.max(i);return this.vptCoords={tl:o,tr:new O(a.x,o.y),bl:new O(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(W0(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;const n=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality="best",this.fire("before:render",{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,s)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire("after:render",{ctx:e}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(e,t){const n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation="destination-in",t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,s=t.length;n<s;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){const n=this["".concat(t,"Color")],s=this["".concat(t,"Image")],i=this.viewportTransform,o=this["".concat(t,"Vpt")];if(!n&&!s)return;const a=ct(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=a?n.toLive(e):n,o&&e.transform(...i),a){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);const l=n.gradientTransform||n.patternTransform;l&&e.transform(...l)}e.fill(),e.restore()}if(s){e.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&e.transform(...i),s.render(e),this.skipOffscreen=l,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,"background")}_renderOverlay(e){this._renderBackgroundOrOverlay(e,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new O(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new O(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new O(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new O(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new O(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return We(this.getCenterPoint(),Tt(this.viewportTransform))}_centerObject(e,t){e.setXY(t,$,$),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod("toObject",e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod("toDatalessObject",e)}_toObjectMethod(e,t){const n=this.clipPath,s=n&&!n.excludeFromExport?this._toObject(n,e,t):null;return b(b(b({version:fc},Jn(this,t)),{},{objects:this._objects.filter(i=>!i.excludeFromExport).map(i=>this._toObject(i,e,t))},this.__serializeBgOverlay(e,t)),s?{clipPath:s}:null)}_toObject(e,t,n){let s;this.includeDefaultValues||(s=e.includeDefaultValues,e.includeDefaultValues=!1);const i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=!!s),i}__serializeBgOverlay(e,t){const n={},s=this.backgroundImage,i=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ct(o)?o.excludeFromExport||(n.background=o.toObject(t)):o&&(n.background=o),ct(a)?a.excludeFromExport||(n.overlay=a.toObject(t)):a&&(n.overlay=a),s&&!s.excludeFromExport&&(n.backgroundImage=this._toObject(s,e,t)),i&&!i.excludeFromExport&&(n.overlayImage=this._toObject(i,e,t)),n}toSVG(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;e.reviver=t;const n=[];return this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this.clipPath&&n.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
43
- `)),this._setSVGBgOverlayColor(n,"background"),this._setSVGBgOverlayImage(n,"backgroundImage",t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
44
- `),this._setSVGBgOverlayColor(n,"overlay"),this._setSVGBgOverlayImage(n,"overlayImage",t),n.push("</svg>"),n.join("")}_setSVGPreamble(e,t){t.suppressPreamble||e.push('<?xml version="1.0" encoding="',t.encoding||"UTF-8",`" standalone="no" ?>
45
- `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
46
- `)}_setSVGHeader(e,t){const n=t.width||"".concat(this.width),s=t.height||"".concat(this.height),i=q.NUM_FRACTION_DIGITS,o=t.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(te(-l[4]/l[0],i)," ").concat(te(-l[5]/l[3],i)," ").concat(te(this.width/l[0],i)," ").concat(te(this.height/l[3],i),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');e.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',s,'" ',a,`xml:space="preserve">
47
- `,"<desc>Created with Fabric.js ",fc,`</desc>
48
- `,`<defs>
49
- `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
50
- `)}createSVGClipPathMarkup(e){const t=this.clipPath;return t?(t.clipPathId="CLIPPATH_".concat(Nr()),'<clipPath id="'.concat(t.clipPathId,`" >
51
- `).concat(t.toClipPathSVG(e.reviver),`</clipPath>
52
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(e=>{const t=this["".concat(e,"Color")];if(ct(t)){const n=this["".concat(e,"Vpt")],s=this.viewportTransform,i={isType:()=>!1,width:this.width/(n?s[0]:1),height:this.height/(n?s[3]:1)};return t.toSVG(i,{additionalTransform:n?Gs(s):""})}}).join("")}createSVGFontFacesMarkup(){const e=[],t={},n=q.fontPaths;this._objects.forEach(function i(o){e.push(o),po(o)&&o._objects.forEach(i)}),e.forEach(i=>{if(!(o=i)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=i;!t[l]&&n[l]&&(t[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(u=>{let{fontFamily:h=""}=u;!t[h]&&n[h]&&(t[h]=!0)})}))});const s=Object.keys(t).map(i=>` @font-face {
53
- font-family: '`.concat(i,`';
54
- src: url('`).concat(n[i],`');
55
- }
56
- `)).join("");return s?` <style type="text/css"><![CDATA[
57
- `.concat(s,`]]></style>
58
- `):""}_setSVGObjects(e,t){this.forEachObject(n=>{n.excludeFromExport||this._setSVGObject(e,n,t)})}_setSVGObject(e,t,n){e.push(t.toSVG(n))}_setSVGBgOverlayImage(e,t,n){const s=this[t];s&&!s.excludeFromExport&&s.toSVG&&e.push(s.toSVG(n))}_setSVGBgOverlayColor(e,t){const n=this["".concat(t,"Color")];if(n)if(ct(n)){const s=n.repeat||"",i=this.width,o=this.height,a=this["".concat(t,"Vpt")]?Gs(Tt(this.viewportTransform)):"";e.push('<rect transform="'.concat(a," translate(").concat(i/2,",").concat(o/2,')" x="').concat(n.offsetX-i/2,'" y="').concat(n.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!hd(n)?i:n.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!hd(n)?o:n.source.height,'" fill="url(#SVGID_').concat(n.id,`)"></rect>
59
- `))}else e.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',n,'"',`></rect>
60
- `)}loadFromJSON(e,t){let{signal:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e)return Promise.reject(new It("`json` is undefined"));const s=typeof e=="string"?JSON.parse(e):e,{objects:i=[]}=s,o=ie(s,G0),{backgroundImage:a,background:l,overlayImage:c,overlay:u,clipPath:h}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Ys(i,{reviver:t,signal:n}),Ca({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:u,clipPath:h},{signal:n})]).then(f=>{let[m,v]=f;return this.clear(),this.add(...m),this.set(o),this.set(v),this.renderOnAddRemove=d,this})}clone(e){const t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){const e=pt(this);return new this.constructor(e)}toDataURL(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:t="png",quality:n=1,multiplier:s=1,enableRetinaScaling:i=!1}=e,o=s*(i?this.getRetinaScaling():1);return _p(this.toCanvasElement(o,e),t,n)}toBlob(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:t="png",quality:n=1,multiplier:s=1,enableRetinaScaling:i=!1}=e,o=s*(i?this.getRetinaScaling():1);return wp(this.toCanvasElement(o,e),t,n)}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:t,height:n,left:s,top:i,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(t||this.width)*e,l=(n||this.height)*e,c=this.getZoom(),u=this.width,h=this.height,d=this.skipControlsDrawing,f=c*e,m=this.viewportTransform,v=[f,0,0,f,(m[4]-(s||0))*e,(m[5]-(i||0))*e],w=this.enableRetinaScaling,g=pt({width:a,height:l}),p=o?this._objects.filter(y=>o(y)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=v,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),p),this.viewportTransform=m,this.width=u,this.height=h,this.calcViewportBoundaries(),this.enableRetinaScaling=w,this.skipControlsDrawing=d,g}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Yo.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{const n=()=>{this.destroy(),e(!0)};n.kill=t,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=n:n()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}C(ii,"ownDefaults",Y0);const K0=["touchstart","touchmove","touchend"],q0=r=>{const e=kp(r.target),t=function(n){const s=n.changedTouches;return s&&s[0]?s[0]:n}(r);return new O(t.clientX+e.left,t.clientY+e.top)},mc=r=>K0.includes(r.type)||r.pointerType==="touch",fd=r=>{r.preventDefault(),r.stopPropagation()},tr=r=>{let e=0,t=0,n=0,s=0;for(let i=0,o=r.length;i<o;i++){const{x:a,y:l}=r[i];(a>n||!i)&&(n=a),(a<e||!i)&&(e=a),(l>s||!i)&&(s=l),(l<t||!i)&&(t=l)}return{left:e,top:t,width:n-e,height:s-t}},Q0=["translateX","translateY","scaleX","scaleY"],J0=(r,e)=>Ko(r,Te(e,r.calcOwnMatrix())),Ko=(r,e)=>{const t=Go(e),{translateX:n,translateY:s,scaleX:i,scaleY:o}=t,a=ie(t,Q0),l=new O(n,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:i,scaleY:o}),r.setPositionByOrigin(l,$,$)},Z0=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},Pp=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Du=(r,e,t)=>{const n=r/2,s=e/2,i=[new O(-n,-s),new O(n,-s),new O(-n,s),new O(n,s)].map(a=>a.transform(t)),o=tr(i);return new O(o.width,o.height)},ba=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ze;return Te(Tt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:ze),r)},Ln=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ze,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ze;return r.transform(ba(e,t))},ex=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ze,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ze;return r.transform(ba(e,t),!0)},tx=(r,e,t)=>{const n=ba(e,t);return Ko(r,Te(n,r.calcOwnMatrix())),n},Mp=(r,e)=>{var t;const{transform:{target:n}}=e;(t=n.canvas)===null||t===void 0||t.fire("object:".concat(r),b(b({},e),{},{target:n})),n.fire(r,e)},rx={left:-.5,top:-.5,center:0,bottom:.5,right:.5},me=r=>typeof r=="string"?rx[r]:r-.5,qo="not-allowed";function jp(r){return me(r.originX)===me($)&&me(r.originY)===me($)}function gd(r){return .5-me(r)}const Dt=(r,e)=>r[e],Ap=(r,e,t,n)=>({e:r,transform:e,pointer:new O(t,n)});function Lp(r,e){const t=r.getTotalAngle()+cr(Math.atan2(e.y,e.x))+360;return Math.round(t%360/45)}function Pu(r,e,t,n,s){var i;let{target:o,corner:a}=r;const l=o.controls[a],c=((i=o.canvas)===null||i===void 0?void 0:i.getZoom())||1,u=o.padding/c,h=function(d,f,m,v){const w=d.getRelativeCenterPoint(),g=m!==void 0&&v!==void 0?d.translateToGivenOrigin(w,$,$,m,v):new O(d.left,d.top);return(d.angle?f.rotate(-pe(d.angle),w):f).subtract(g)}(o,new O(n,s),e,t);return h.x>=u&&(h.x-=u),h.x<=-u&&(h.x+=u),h.y>=u&&(h.y-=u),h.y<=u&&(h.y+=u),h.x-=l.offsetX,h.y-=l.offsetY,h}const nx=(r,e,t,n)=>{const{target:s,offsetX:i,offsetY:o}=e,a=t-i,l=n-o,c=!Dt(s,"lockMovementX")&&s.left!==a,u=!Dt(s,"lockMovementY")&&s.top!==l;return c&&s.set(J,a),u&&s.set(Ge,l),(c||u)&&Mp(pp,Ap(r,e,t,n)),c||u},Qo=r=>r.replace(/\s+/g," "),pd={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},ol=(r,e,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+6*(e-r)*t:t<.5?e:t<2/3?r+(e-r)*(2/3-t)*6:r),md=(r,e,t,n)=>{r/=255,e/=255,t/=255;const s=Math.max(r,e,t),i=Math.min(r,e,t);let o,a;const l=(s+i)/2;if(s===i)o=a=0;else{const c=s-i;switch(a=l>.5?c/(2-s-i):c/(s+i),s){case r:o=(e-t)/c+(e<t?6:0);break;case e:o=(t-r)/c+2;break;case t:o=(r-e)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),n]},vd=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},ki=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),yd=r=>{let[e,t,n,s=1]=r;const i=Math.round(.3*e+.59*t+.11*n);return[i,i,i,s]};class Q{constructor(e){if(C(this,"isUnrecognised",!1),e)if(e instanceof Q)this.setSource([...e._source]);else if(Array.isArray(e)){const[t,n,s,i=1]=e;this.setSource([t,n,s,i])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(e){return(e=e.toLowerCase())in pd&&(e=pd[e]),e==="transparent"?[255,255,255,0]:Q.sourceFromHex(e)||Q.sourceFromRgb(e)||Q.sourceFromHsl(e)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(e){this._source=e}toRgb(){const[e,t,n]=this.getSource();return"rgb(".concat(e,",").concat(t,",").concat(n,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[e,t,n]=md(...this.getSource());return"hsl(".concat(e,",").concat(t,"%,").concat(n,"%)")}toHsla(){const[e,t,n,s]=md(...this.getSource());return"hsla(".concat(e,",").concat(t,"%,").concat(n,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[e,t,n,s]=this.getSource();return"".concat(ki(e)).concat(ki(t)).concat(ki(n)).concat(ki(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(e){return this._source[3]=e,this}toGrayscale(){return this.setSource(yd(this.getSource())),this}toBlackWhite(e){const[t,,,n]=yd(this.getSource()),s=t<(e||127)?0:255;return this.setSource([s,s,s,n]),this}overlayWith(e){e instanceof Q||(e=new Q(e));const t=this.getSource(),n=e.getSource(),[s,i,o]=t.map((a,l)=>Math.round(.5*a+.5*n[l]));return this.setSource([s,i,o,t[3]]),this}static fromRgb(e){return Q.fromRgba(e)}static fromRgba(e){return new Q(Q.sourceFromRgb(e))}static sourceFromRgb(e){const t=Qo(e).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(t){const[n,s,i]=t.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[n,s,i,vd(t[4])]}}static fromHsl(e){return Q.fromHsla(e)}static fromHsla(e){return new Q(Q.sourceFromHsl(e))}static sourceFromHsl(e){const t=Qo(e).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!t)return;const n=(Q.parseAngletoDegrees(t[1])%360+360)%360/360,s=parseFloat(t[2])/100,i=parseFloat(t[3])/100;let o,a,l;if(s===0)o=a=l=i;else{const c=i<=.5?i*(s+1):i+s-i*s,u=2*i-c;o=ol(u,c,n+1/3),a=ol(u,c,n),l=ol(u,c,n-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),vd(t[4])]}static fromHex(e){return new Q(Q.sourceFromHex(e))}static sourceFromHex(e){if(e.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const t=e.slice(e.indexOf("#")+1);let n;n=t.length<=4?t.split("").map(l=>l+l):t.match(/.{2}/g);const[s,i,o,a=255]=n.map(l=>parseInt(l,16));return[s,i,o,a/255]}}static parseAngletoDegrees(e){const t=e.toLowerCase(),n=parseFloat(t);return t.includes("rad")?cr(n):t.includes("turn")?360*n:n}}const Fn=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Su;const t=/\D{0,2}$/.exec(r),n=parseFloat(r),s=q.DPI;switch(t==null?void 0:t[0]){case"mm":return n*s/25.4;case"cm":return n*s/2.54;case"in":return n*s;case"pt":return n*s/72;case"pc":return n*s/72*12;case"em":return n*e;default:return n}},sx=r=>{const[e,t]=r.trim().split(" "),[n,s]=(i=e)&&i!==Ke?[i.slice(1,4),i.slice(5,8)]:i===Ke?[i,i]:["Mid","Mid"];var i;return{meetOrSlice:t||"meet",alignX:n,alignY:s}},Ks=function(r,e){let t,n,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(e)if(e.toLive)t="url(#SVGID_".concat(e.id,")");else{const i=new Q(e),o=i.getAlpha();t=i.toRgb(),o!==1&&(n=o.toString())}else t="none";return s?"".concat(r,": ").concat(t,"; ").concat(n?"".concat(r,"-opacity: ").concat(n,"; "):""):"".concat(r,'="').concat(t,'" ').concat(n?"".concat(r,'-opacity="').concat(n,'" '):"")};class Fp{getSvgStyles(e){const t=this.fillRule?this.fillRule:"nonzero",n=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Ke,i=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",u=this.visible?"":" visibility: hidden;",h=e?"":this.getSvgFilter(),d=Ks(_e,this.fill);return[Ks(qe,this.stroke),"stroke-width: ",n,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",i,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",t,"; ","opacity: ",c,";",h,u].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const n=e?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Gs(n));return"".concat(s).concat(t,'" ')}_toSVG(e){return[""]}toSVG(e){return this._createBaseSVGMarkup(this._toSVG(e),{reviver:e})}toClipPathSVG(e){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(e),{reviver:e})}_createBaseClipPathSVGMarkup(e){let{reviver:t,additionalTransform:n=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),i=e.indexOf("COMMON_PARTS");return e[i]=s,t?t(e.join("")):e.join("")}_createBaseSVGMarkup(e){let{noStyle:t,reviver:n,withShadow:s,additionalTransform:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=t?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",u=l&&l.absolutePositioned,h=this.stroke,d=this.fill,f=this.shadow,m=[],v=e.indexOf("COMMON_PARTS");let w;l&&(l.clipPathId="CLIPPATH_".concat(Nr()),w='<clipPath id="'.concat(l.clipPathId,`" >
61
- `).concat(l.toClipPathSVG(n),`</clipPath>
62
- `)),u&&m.push("<g ",a,this.getSvgCommons(),` >
63
- `),m.push("<g ",this.getSvgTransform(!1),u?"":a+this.getSvgCommons(),` >
64
- `);const g=[o,c,t?"":this.addPaintOrder()," ",i?'transform="'.concat(i,'" '):""].join("");return e[v]=g,ct(d)&&m.push(d.toSVG(this)),ct(h)&&m.push(h.toSVG(this)),f&&m.push(f.toSVG(this)),l&&m.push(w),m.push(e.join("")),m.push(`</g>
65
- `),u&&m.push(`</g>
66
- `),n?n(m.join("")):m.join("")}addPaintOrder(){return this.paintFirst!==_e?' paint-order="'.concat(this.paintFirst,'" '):""}}function Ta(r){return new RegExp("^("+r.join("|")+")\\b","i")}const sn="textDecorationThickness",Rp=["fontSize","fontWeight","fontFamily","fontStyle"],Np=["underline","overline","linethrough"],Ip=[...Rp,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],zp=[...Ip,...Np,"textBackgroundColor","direction",sn],ix=[...Rp,...Np,qe,"strokeWidth",_e,"deltaY","textBackgroundColor",sn],ox={_reNewline:Cu,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:J,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:J,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[sn]:66.667},Rt="justify",Jo="justify-left",ks="justify-right",Os="justify-center";var xd,_d,wd;const kt=String.raw(xd||(xd=Ht(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),al=String.raw(_d||(_d=Ht(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),ax=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+kt+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+kt+"))?\\s+(.*)"),lx={cx:J,x:J,r:"radius",cy:Ge,y:Ge,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":sn},ll="font-size",cl="clip-path";Ta(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);Ta(["symbol","image","marker","pattern","view","svg"]);const Sd=Ta(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(wd||(wd=Ht(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),kt,al,kt,al,kt,al,kt));const cx=new O(1,0),Bp=new O,Vp=(r,e)=>r.rotate(e),vc=(r,e)=>new O(e).subtract(r),yc=r=>r.distanceFrom(Bp),xc=(r,e)=>Math.atan2(Es(r,e),hx(r,e)),ux=r=>xc(cx,r),Mu=r=>r.eq(Bp)?r:r.scalarDivide(yc(r)),Wp=function(r){let e=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Mu(new O(-r.y,r.x).scalarMultiply(e?1:-1))},Es=(r,e)=>r.x*e.y-r.y*e.x,hx=(r,e)=>r.x*e.x+r.y*e.y,Cd=(r,e,t)=>{if(r.eq(e)||r.eq(t))return!0;const n=Es(e,t),s=Es(e,r),i=Es(t,r);return n>=0?s>=0&&i<=0:!(s<=0&&i>=0)},bd="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Td=new RegExp("(?:\\s|^)"+bd+bd+"("+kt+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Vt{constructor(e){const t=typeof e=="string"?Vt.parseShadow(e):e;Object.assign(this,Vt.ownDefaults,t),this.id=Nr()}static parseShadow(e){const t=e.trim(),[,n=0,s=0,i=0]=(Td.exec(t)||[]).map(o=>parseFloat(o)||0);return{color:(t.replace(Td,"")||"rgb(0,0,0)").trim(),offsetX:n,offsetY:s,blur:i}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(e){const t=Vp(new O(this.offsetX,this.offsetY),pe(-e.angle)),n=new Q(this.color);let s=40,i=40;return e.width&&e.height&&(s=100*te((Math.abs(t.x)+this.blur)/e.width,q.NUM_FRACTION_DIGITS)+20,i=100*te((Math.abs(t.y)+this.blur)/e.height,q.NUM_FRACTION_DIGITS)+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(i,'%" height="').concat(100+2*i,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
67
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(te(this.blur?this.blur/2:0,q.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
68
- <feOffset dx="`).concat(te(t.x,q.NUM_FRACTION_DIGITS),'" dy="').concat(te(t.y,q.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
69
- <feFlood flood-color="`).concat(n.toRgb(),'" flood-opacity="').concat(n.getAlpha(),`"/>
70
- <feComposite in2="oBlur" operator="in" />
71
- <feMerge>
72
- <feMergeNode></feMergeNode>
73
- <feMergeNode in="SourceGraphic"></feMergeNode>
74
- </feMerge>
75
- </filter>
76
- `)}toObject(){const e={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},t=Vt.ownDefaults;return this.includeDefaultValues?e:Eu(e,(n,s)=>n!==t[s])}static async fromObject(e){return new this(e)}}C(Vt,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),C(Vt,"type","shadow"),W.setClass(Vt,"shadow");const Xn=(r,e,t)=>Math.max(r,Math.min(e,t)),dx=[Ge,J,Qe,gt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Kn,qn],hr=[_e,qe,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],fx={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:J,originY:Ge,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:_e,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},gx=(r,e,t,n)=>-t*Math.cos(r/n*ni)+t+e,px=()=>!1;class ju{constructor(e){let{startValue:t,byValue:n,duration:s=500,delay:i=0,easing:o=gx,onStart:a=go,onChange:l=go,onComplete:c=go,abort:u=px,target:h}=e;C(this,"_state","pending"),C(this,"durationProgress",0),C(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=i,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=u,this.target=h,this.startValue=t,this.byValue=n,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const e=t=>{this._state==="pending"&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>mo(e),this.delay):mo(e)}tick(e){const t=(e||+new Date)-this.startTime,n=Math.min(t,this.duration);this.durationProgress=n/this.duration;const{value:s,valueProgress:i}=this.calculate(n);this.value=Object.freeze(s),this.valueProgress=i,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):t>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),mo(this.tick)))}register(){Yo.push(this)}unregister(){Yo.remove(this)}abort(){this._state="aborted",this.unregister()}}const mx=["startValue","endValue"];class vx extends ju{constructor(e){let{startValue:t=0,endValue:n=100}=e;super(b(b({},ie(e,mx)),{},{startValue:t,byValue:n-t}))}calculate(e){const t=this.easing(e,this.startValue,this.byValue,this.duration);return{value:t,valueProgress:Math.abs((t-this.startValue)/this.byValue)}}}const yx=["startValue","endValue"];class xx extends ju{constructor(e){let{startValue:t=[0],endValue:n=[100]}=e;super(b(b({},ie(e,yx)),{},{startValue:t,byValue:n.map((s,i)=>s-t[i])}))}calculate(e){const t=this.startValue.map((n,s)=>this.easing(e,n,this.byValue[s],this.duration,s));return{value:t,valueProgress:Math.abs((t[0]-this.startValue[0])/this.byValue[0])}}}const _x=["startValue","endValue","easing","onChange","onComplete","abort"],wx=(r,e,t,n)=>e+t*(1-Math.cos(r/n*ni)),ul=r=>r&&((e,t,n)=>r(new Q(e).toRgba(),t,n));class Sx extends ju{constructor(e){let{startValue:t,endValue:n,easing:s=wx,onChange:i,onComplete:o,abort:a}=e,l=ie(e,_x);const c=new Q(t).getSource(),u=new Q(n).getSource();super(b(b({},l),{},{startValue:c,byValue:u.map((h,d)=>h-c[d]),easing:s,onChange:ul(i),onComplete:ul(o),abort:ul(a)}))}calculate(e){const[t,n,s,i]=this.startValue.map((a,l)=>this.easing(e,a,this.byValue[l],this.duration,l)),o=[...[t,n,s].map(Math.round),Xn(0,i,1)];return{value:o,valueProgress:o.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function Hp(r){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(r)?new xx(r):new vx(r);return e.start(),e}function Cx(r){const e=new Sx(r);return e.start(),e}class le{constructor(e){this.status=e,this.points=[]}includes(e){return this.points.some(t=>t.eq(e))}append(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.points=this.points.concat(t.filter(s=>!this.includes(s))),this}static isPointContained(e,t,n){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(t.eq(n))return e.eq(t);if(t.x===n.x)return e.x===t.x&&(s||e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y));if(t.y===n.y)return e.y===t.y&&(s||e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x));{const i=vc(t,n),o=vc(t,e).divide(i);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(e,t){const n=new O(e).setX(Math.min(e.x-1,...t.map(i=>i.x)));let s=0;for(let i=0;i<t.length;i++){const o=this.intersectSegmentSegment(t[i],t[(i+1)%t.length],e,n);if(o.includes(e))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(e,t,n,s){let i=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=t.x-e.x,l=t.y-e.y,c=s.x-n.x,u=s.y-n.y,h=e.x-n.x,d=e.y-n.y,f=c*d-u*h,m=a*d-l*h,v=u*a-c*l;if(v!==0){const w=f/v,g=m/v;return(i||0<=w&&w<=1)&&(o||0<=g&&g<=1)?new le("Intersection").append(new O(e.x+w*a,e.y+w*l)):new le}if(f===0||m===0){const w=i||o||le.isPointContained(e,n,s)||le.isPointContained(t,n,s)||le.isPointContained(n,e,t)||le.isPointContained(s,e,t);return new le(w?"Coincident":void 0)}return new le("Parallel")}static intersectSegmentLine(e,t,n,s){return le.intersectLineLine(e,t,n,s,!1,!0)}static intersectSegmentSegment(e,t,n,s){return le.intersectLineLine(e,t,n,s,!1,!1)}static intersectLinePolygon(e,t,n){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const i=new le,o=n.length;for(let a,l,c,u=0;u<o;u++){if(a=n[u],l=n[(u+1)%o],c=le.intersectLineLine(e,t,a,l,s,!1),c.status==="Coincident")return c;i.append(...c.points)}return i.points.length>0&&(i.status="Intersection"),i}static intersectSegmentPolygon(e,t,n){return le.intersectLinePolygon(e,t,n,!1)}static intersectPolygonPolygon(e,t){const n=new le,s=e.length,i=[];for(let o=0;o<s;o++){const a=e[o],l=e[(o+1)%s],c=le.intersectSegmentPolygon(a,l,t);c.status==="Coincident"?(i.push(c),n.append(a,l)):n.append(...c.points)}return i.length>0&&i.length===e.length?new le("Coincident"):(n.points.length>0&&(n.status="Intersection"),n)}static intersectPolygonRectangle(e,t,n){const s=t.min(n),i=t.max(n),o=new O(i.x,s.y),a=new O(s.x,i.y);return le.intersectPolygonPolygon(e,[s,o,i,a])}}class bx extends xp{getX(){return this.getXY().x}setX(e){this.setXY(this.getXY().setX(e))}getY(){return this.getXY().y}setY(e){this.setXY(this.getXY().setY(e))}getRelativeX(){return this.left}setRelativeX(e){this.left=e}getRelativeY(){return this.top}setRelativeY(e){this.top=e}getXY(){const e=this.getRelativeXY();return this.group?We(e,this.group.calcTransformMatrix()):e}setXY(e,t,n){this.group&&(e=We(e,Tt(this.group.calcTransformMatrix()))),this.setRelativeXY(e,t,n)}getRelativeXY(){return new O(this.left,this.top)}setRelativeXY(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(e,t,n)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:e,tr:t,br:n,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),i=[e,t,n,s];if(this.group){const o=this.group.calcTransformMatrix();return i.map(a=>We(a,o))}return i}intersectsWithRect(e,t){return le.intersectPolygonRectangle(this.getCoords(),e,t).status==="Intersection"}intersectsWithObject(e){const t=le.intersectPolygonPolygon(this.getCoords(),e.getCoords());return t.status==="Intersection"||t.status==="Coincident"||e.isContainedWithinObject(this)||this.isContainedWithinObject(e)}isContainedWithinObject(e){return this.getCoords().every(t=>e.containsPoint(t))}isContainedWithinRect(e,t){const{left:n,top:s,width:i,height:o}=this.getBoundingRect();return n>=e.x&&n+i<=t.x&&s>=e.y&&s+o<=t.y}isOverlapping(e){return this.intersectsWithObject(e)||this.isContainedWithinObject(e)||e.isContainedWithinObject(this)}containsPoint(e){return le.isPointInPolygon(e,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:e,br:t}=this.canvas.vptCoords;return!!this.getCoords().some(n=>n.x<=t.x&&n.x>=e.x&&n.y<=t.y&&n.y>=e.y)||!!this.intersectsWithRect(e,t)||this.containsPoint(e.midPointFrom(t))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:e,br:t}=this.canvas.vptCoords;return this.intersectsWithRect(e,t)?!0:this.getCoords().every(n=>(n.x>=t.x||n.x<=e.x)&&(n.y>=t.y||n.y<=e.y))&&this.containsPoint(e.midPointFrom(t))}getBoundingRect(){return tr(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(e){this._set(Qe,e),this._set(gt,e),this.setCoords()}scaleToWidth(e){const t=this.getBoundingRect().width/this.getScaledWidth();return this.scale(e/this.width/t)}scaleToHeight(e){const t=this.getBoundingRect().height/this.getScaledHeight();return this.scale(e/this.height/t)}getCanvasRetinaScaling(){var e;return((e=this.canvas)===null||e===void 0?void 0:e.getRetinaScaling())||1}getTotalAngle(){return this.group?cr(Sp(this.calcTransformMatrix())):this.angle}getViewportTransform(){var e;return((e=this.canvas)===null||e===void 0?void 0:e.viewportTransform)||ze.concat()}calcACoords(){const e=Qn({angle:this.angle}),{x:t,y:n}=this.getRelativeCenterPoint(),s=si(t,n),i=Te(s,e),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:We({x:-a,y:-l},i),tr:We({x:a,y:-l},i),bl:We({x:-a,y:l},i),br:We({x:a,y:l},i)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=[];return!e&&this.group&&(t=this.group.transformMatrixKey(e)),t.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,me(this.originX),me(this.originY)),t}calcTransformMatrix(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.calcOwnMatrix();if(e||!this.group)return t;const n=this.transformMatrixKey(e),s=this.matrixCache;return s&&s.key.every((i,o)=>i===n[o])?s.value:(this.group&&(t=Te(this.group.calcTransformMatrix(!1),t)),this.matrixCache={key:n,value:t},t)}calcOwnMatrix(){const e=this.transformMatrixKey(!0),t=this.ownMatrixCache;if(t&&t.key===e)return t.value;const n=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:n.x,translateY:n.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},i=$0(s);return this.ownMatrixCache={key:e,value:i},i}_getNonTransformedDimensions(){return new O(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(e){return this._getTransformedDimensions(e).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=b({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},e),n=t.strokeWidth;let s=n,i=0;this.strokeUniform&&(s=0,i=n);const o=t.width+s,a=t.height+s;let l;return l=t.skewX===0&&t.skewY===0?new O(o*t.scaleX,a*t.scaleY):Du(o,a,Sa(t)),l.scalarAdd(i)}translateToGivenOrigin(e,t,n,s,i){let o=e.x,a=e.y;const l=me(s)-me(t),c=me(i)-me(n);if(l||c){const u=this._getTransformedDimensions();o+=l*u.x,a+=c*u.y}return new O(o,a)}translateToCenterPoint(e,t,n){if(t===$&&n===$)return e;const s=this.translateToGivenOrigin(e,t,n,$,$);return this.angle?s.rotate(pe(this.angle),e):s}translateToOriginPoint(e,t,n){const s=this.translateToGivenOrigin(e,$,$,t,n);return this.angle?s.rotate(pe(this.angle),e):s}getCenterPoint(){const e=this.getRelativeCenterPoint();return this.group?We(e,this.group.calcTransformMatrix()):e}getRelativeCenterPoint(){return this.translateToCenterPoint(new O(this.left,this.top),this.originX,this.originY)}getPointByOrigin(e,t){return this.translateToOriginPoint(this.getRelativeCenterPoint(),e,t)}setPositionByOrigin(e,t,n){const s=this.translateToCenterPoint(e,t,n),i=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:i.x,top:i.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),J,Ge)}}const Tx=["type"],kx=["extraParam"];let Xt=class yo extends bx{static getDefaults(){return yo.ownDefaults}get type(){const e=this.constructor.type;return e==="FabricObject"?"object":e.toLowerCase()}set type(e){Rr("warn","Setting type has no effect",e)}constructor(e){super(),C(this,"_cacheContext",null),Object.assign(this,yo.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=lr(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(e){const t=e.width,n=e.height,s=q.maxCacheSideLimit,i=q.minCacheSideLimit;if(t<=s&&n<=s&&t*n<=q.perfLimitSizeTotal)return t<i&&(e.width=i),n<i&&(e.height=i),e;const o=t/n,[a,l]=Ts.limitDimsByArea(o),c=Xn(i,a,s),u=Xn(i,l,s);return t>c&&(e.zoomX/=t/c,e.width=c,e.capped=!0),n>u&&(e.zoomY/=n/u,e.height=u,e.capped=!0),e}_getCacheCanvasDimensions(){const e=this.getTotalObjectScaling(),t=this._getTransformedDimensions({skewX:0,skewY:0}),n=t.x*e.x/this.scaleX,s=t.y*e.y/this.scaleY;return{width:Math.ceil(n+2),height:Math.ceil(s+2),zoomX:e.x,zoomY:e.y,x:n,y:s}}_updateCacheCanvas(){const e=this._cacheCanvas,t=this._cacheContext,{width:n,height:s,zoomX:i,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=n!==e.width||s!==e.height,u=this.zoomX!==i||this.zoomY!==o;if(!e||!t)return!1;if(c||u){n!==e.width||s!==e.height?(e.width=n,e.height=s):(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height));const h=a/2,d=l/2;return this.cacheTranslationX=Math.round(e.width/2-h)+h,this.cacheTranslationY=Math.round(e.height/2-d)+d,t.translate(this.cacheTranslationX,this.cacheTranslationY),t.scale(i,o),this.zoomX=i,this.zoomY=o,!0}return!1}setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(e)}transform(e){const t=this.group&&!this.group._transformDone||this.group&&this.canvas&&e===this.canvas.contextTop,n=this.calcTransformMatrix(!t);e.transform(n[0],n[1],n[2],n[3],n[4],n[5])}getObjectScaling(){if(!this.group)return new O(Math.abs(this.scaleX),Math.abs(this.scaleY));const e=Go(this.calcTransformMatrix());return new O(Math.abs(e.scaleX),Math.abs(e.scaleY))}getTotalObjectScaling(){const e=this.getObjectScaling();if(this.canvas){const t=this.canvas.getZoom(),n=this.getCanvasRetinaScaling();return e.scalarMultiply(t*n)}return e}getObjectOpacity(){let e=this.opacity;return this.group&&(e*=this.group.getObjectOpacity()),e}_constrainScale(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e===0?1e-4:e}_set(e,t){e!==Qe&&e!==gt||(t=this._constrainScale(t)),e===Qe&&t<0?(this.flipX=!this.flipX,t*=-1):e==="scaleY"&&t<0?(this.flipY=!this.flipY,t*=-1):e!=="shadow"||!t||t instanceof Vt||(t=new Vt(t));const n=this[e]!==t;return this[e]=t,n&&this.constructor.cacheProperties.includes(e)&&(this.dirty=!0),this.parent&&(this.dirty||n&&this.constructor.stateProperties.includes(e))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(e){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(e.save(),this._setupCompositeOperation(e),this.drawSelectionBackground(e),this.transform(e),this._setOpacity(e),this._setShadow(e),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(e)):(this._removeCacheCanvas(),this.drawObject(e,!1,{}),this.dirty=!1),e.restore())}drawSelectionBackground(e){}renderCache(e){if(e=e||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:t,zoomY:n,cacheTranslationX:s,cacheTranslationY:i}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,e.forClipping,{zoomX:t,zoomY:n,cacheTranslationX:s,cacheTranslationY:i,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===qe&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(e,t,n){e.save(),t.inverted?e.globalCompositeOperation="destination-out":e.globalCompositeOperation="destination-in",e.setTransform(1,0,0,1,0,0),e.drawImage(n,0,0),e.restore()}drawObject(e,t,n){const s=this.fill,i=this.stroke;t?(this.fill="black",this.stroke="",this._setClippingProperties(e)):this._renderBackground(e),this._render(e),this._drawClipPath(e,this.clipPath,n),this.fill=s,this.stroke=i}createClipPathLayer(e,t){const n=pt(t),s=n.getContext("2d");if(s.translate(t.cacheTranslationX,t.cacheTranslationY),s.scale(t.zoomX,t.zoomY),e._cacheCanvas=n,t.parentClipPaths.forEach(i=>{i.transform(s)}),t.parentClipPaths.push(e),e.absolutePositioned){const i=Tt(this.calcTransformMatrix());s.transform(i[0],i[1],i[2],i[3],i[4],i[5])}return e.transform(s),e.drawObject(s,!0,t),n}_drawClipPath(e,t,n){if(!t)return;t._transformDone=!0;const s=this.createClipPathLayer(t,n);this.drawClipPathOnCache(e,t,s)}drawCacheOnCanvas(e){e.scale(1/this.zoomX,1/this.zoomY),e.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const t=this._cacheCanvas,n=this._cacheContext;return!(!t||!n||e||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(t&&n&&!e&&(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()),!0)}_renderBackground(e){if(!this.backgroundColor)return;const t=this._getNonTransformedDimensions();e.fillStyle=this.backgroundColor,e.fillRect(-t.x/2,-t.y/2,t.x,t.y),this._removeShadow(e)}_setOpacity(e){this.group&&!this.group._transformDone?e.globalAlpha=this.getObjectOpacity():e.globalAlpha*=this.opacity}_setStrokeStyles(e,t){const n=t.stroke;n&&(e.lineWidth=t.strokeWidth,e.lineCap=t.strokeLineCap,e.lineDashOffset=t.strokeDashOffset,e.lineJoin=t.strokeLineJoin,e.miterLimit=t.strokeMiterLimit,ct(n)?n.gradientUnits==="percentage"||n.gradientTransform||n.patternTransform?this._applyPatternForTransformedGradient(e,n):(e.strokeStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.strokeStyle=t.stroke)}_setFillStyles(e,t){let{fill:n}=t;n&&(ct(n)?(e.fillStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.fillStyle=n)}_setClippingProperties(e){e.globalAlpha=1,e.strokeStyle="transparent",e.fillStyle="#000000"}_setLineDash(e,t){t&&t.length!==0&&e.setLineDash(t)}_setShadow(e){if(!this.shadow)return;const t=this.shadow,n=this.canvas,s=this.getCanvasRetinaScaling(),[i,,,o]=(n==null?void 0:n.viewportTransform)||ze,a=i*s,l=o*s,c=t.nonScaling?new O(1,1):this.getObjectScaling();e.shadowColor=t.color,e.shadowBlur=t.blur*q.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,e.shadowOffsetX=t.offsetX*a*c.x,e.shadowOffsetY=t.offsetY*l*c.y}_removeShadow(e){this.shadow&&(e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0)}_applyPatternGradientTransform(e,t){if(!ct(t))return{offsetX:0,offsetY:0};const n=t.gradientTransform||t.patternTransform,s=-this.width/2+t.offsetX||0,i=-this.height/2+t.offsetY||0;return t.gradientUnits==="percentage"?e.transform(this.width,0,0,this.height,s,i):e.transform(1,0,0,1,s,i),n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),{offsetX:s,offsetY:i}}_renderPaintInOrder(e){this.paintFirst===qe?(this._renderStroke(e),this._renderFill(e)):(this._renderFill(e),this._renderStroke(e))}_render(e){}_renderFill(e){this.fill&&(e.save(),this._setFillStyles(e,this),this.fillRule==="evenodd"?e.fill("evenodd"):e.fill(),e.restore())}_renderStroke(e){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this.strokeUniform){const t=this.getObjectScaling();e.scale(1/t.x,1/t.y)}this._setLineDash(e,this.strokeDashArray),this._setStrokeStyles(e,this),e.stroke(),e.restore()}}_applyPatternForTransformedGradient(e,t){var n;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/i,a=s.y/this.scaleY/i,l=pt({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/i,s.zoomY/this.scaleY/i),this._applyPatternGradientTransform(c,t),c.fillStyle=t.toLive(e),c.fill(),e.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),e.scale(i*this.scaleX/s.zoomX,i*this.scaleY/s.zoomY),e.strokeStyle=(n=c.createPattern(l,"no-repeat"))!==null&&n!==void 0?n:"")}_findCenterFromElement(){return new O(this.left+this.width/2,this.top+this.height/2)}clone(e){const t=this.toObject(e);return this.constructor.fromObject(t)}cloneAsImage(e){const t=this.toCanvasElement(e);return new(W.getClass("image"))(t)}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=Pp(this),n=this.group,s=this.shadow,i=Math.abs,o=e.enableRetinaScaling?gp():1,a=(e.multiplier||1)*o,l=e.canvasProvider||(p=>new ii(p,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,e.withoutTransform&&Z0(this),e.withoutShadow&&(this.shadow=null),e.viewportTransform&&tx(this,this.getViewportTransform()),this.setCoords();const c=lr(),u=this.getBoundingRect(),h=this.shadow,d=new O;if(h){const p=h.blur,y=h.nonScaling?new O(1,1):this.getObjectScaling();d.x=2*Math.round(i(h.offsetX)+p)*i(y.x),d.y=2*Math.round(i(h.offsetY)+p)*i(y.y)}const f=u.width+d.x,m=u.height+d.y;c.width=Math.ceil(f),c.height=Math.ceil(m);const v=l(c);e.format==="jpeg"&&(v.backgroundColor="#fff"),this.setPositionByOrigin(new O(v.width/2,v.height/2),$,$);const w=this.canvas;v._objects=[this],this.set("canvas",v),this.setCoords();const g=v.toCanvasElement(a||1,e);return this.set("canvas",w),this.shadow=s,n&&(this.group=n),this.set(t),this.setCoords(),v._objects=[],v.destroy(),g}toDataURL(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return _p(this.toCanvasElement(e),e.format||"png",e.quality||1)}toBlob(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return wp(this.toCanvasElement(e),e.format||"png",e.quality||1)}isType(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.includes(this.constructor.type)||t.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(e){const{centeredRotation:t,originX:n,originY:s}=this;if(t){const{x:i,y:o}=this.getRelativeCenterPoint();this.originX=$,this.originY=$,this.left=i,this.top=o}if(this.set("angle",e),t){const{x:i,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),n,s);this.left=i,this.top=o,this.originX=n,this.originY=s}}setOnGroup(){}_setupCompositeOperation(e){this.globalCompositeOperation&&(e.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Yo.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Wt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(e,t){return Object.entries(e).reduce((n,s)=>{let[i,o]=s;return n[i]=this._animate(i,o,t),n},{})}_animate(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=e.split("."),i=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=n,u=b(b({},n),{},{target:this,startValue:a??s.reduce((h,d)=>h[d],this),endValue:t,abort:o==null?void 0:o.bind(this),onChange:(h,d,f)=>{s.reduce((m,v,w)=>(w===s.length-1&&(m[v]=h),m[v]),this),l&&l(h,d,f)},onComplete:(h,d,f)=>{this.setCoords(),c&&c(h,d,f)}});return i?Cx(u):Hp(u)}isDescendantOf(e){const{parent:t,group:n}=this;return t===e||n===e||!!t&&t.isDescendantOf(e)||!!n&&n!==t&&n.isDescendantOf(e)}getAncestors(){const e=[];let t=this;do t=t.parent,t&&e.push(t);while(t);return e}findCommonAncestors(e){if(this===e)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const t=this.getAncestors(),n=e.getAncestors();if(t.length===0&&n.length>0&&this===n[n.length-1])return{fork:[],otherFork:[e,...n.slice(0,n.length-1)],common:[this]};for(let s,i=0;i<t.length;i++){if(s=t[i],s===e)return{fork:[this,...t.slice(0,i)],otherFork:[],common:t.slice(i)};for(let o=0;o<n.length;o++){if(this===n[o])return{fork:[],otherFork:[e,...n.slice(0,o)],common:[this,...t]};if(s===n[o])return{fork:[this,...t.slice(0,i)],otherFork:[e,...n.slice(0,o)],common:t.slice(i)}}}return{fork:[this,...t],otherFork:[e,...n],common:[]}}hasCommonAncestors(e){const t=this.findCommonAncestors(e);return t&&!!t.common.length}isInFrontOf(e){if(this===e)return;const t=this.findCommonAncestors(e);if(t.fork.includes(e))return!0;if(t.otherFork.includes(this))return!1;const n=t.common[0]||this.canvas;if(!n)return;const s=t.fork.pop(),i=t.otherFork.pop(),o=n._objects.indexOf(s),a=n._objects.indexOf(i);return o>-1&&o>a}toObject(){const e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(yo.customProperties,this.constructor.customProperties||[]);let t;const n=q.NUM_FRACTION_DIGITS,{clipPath:s,fill:i,stroke:o,shadow:a,strokeDashArray:l,left:c,top:u,originX:h,originY:d,width:f,height:m,strokeWidth:v,strokeLineCap:w,strokeDashOffset:g,strokeLineJoin:p,strokeUniform:y,strokeMiterLimit:x,scaleX:_,scaleY:E,angle:D,flipX:k,flipY:N,opacity:L,visible:X,backgroundColor:T,fillRule:M,paintFirst:R,globalCompositeOperation:B,skewX:j,skewY:I}=this;s&&!s.excludeFromExport&&(t=s.toObject(e.concat("inverted","absolutePositioned")));const P=A=>te(A,n),z=b(b({},Jn(this,e)),{},{type:this.constructor.type,version:fc,originX:h,originY:d,left:P(c),top:P(u),width:P(f),height:P(m),fill:ud(i)?i.toObject():i,stroke:ud(o)?o.toObject():o,strokeWidth:P(v),strokeDashArray:l&&l.concat(),strokeLineCap:w,strokeDashOffset:g,strokeLineJoin:p,strokeUniform:y,strokeMiterLimit:P(x),scaleX:P(_),scaleY:P(E),angle:P(D),flipX:k,flipY:N,opacity:P(L),shadow:a&&a.toObject(),visible:X,backgroundColor:T,fillRule:M,paintFirst:R,globalCompositeOperation:B,skewX:P(j),skewY:P(I)},t?{clipPath:t}:null);return this.includeDefaultValues?z:this._removeDefaultValues(z)}toDatalessObject(e){return this.toObject(e)}_removeDefaultValues(e){const t=this.constructor.getDefaults(),n=Object.keys(t).length>0?t:Object.getPrototypeOf(this);return Eu(e,(s,i)=>{if(i===J||i===Ge||i==="type")return!0;const o=n[i];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(e){let t=ie(e,Tx),n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=n,i=ie(n,kx);return Ca(t,i).then(o=>s?(delete o[s],new this(t[s],o)):new this(o))}static fromObject(e,t){return this._fromObject(e,t)}};C(Xt,"stateProperties",dx),C(Xt,"cacheProperties",hr),C(Xt,"ownDefaults",fx),C(Xt,"type","FabricObject"),C(Xt,"colorProperties",[_e,qe,"backgroundColor"]),C(Xt,"customProperties",[]),W.setClass(Xt),W.setClass(Xt,"object");const Zn=(r,e,t)=>(n,s,i,o)=>{const a=e(n,s,i,o);return a&&Mp(r,b(b({},Ap(n,s,i,o)),t)),a};function es(r){return(e,t,n,s)=>{const{target:i,originX:o,originY:a}=t,l=i.getRelativeCenterPoint(),c=i.translateToOriginPoint(l,o,a),u=r(e,t,n,s);return i.setPositionByOrigin(c,t.originX,t.originY),u}}const kd=Zn($s,es((r,e,t,n)=>{const s=Pu(e,e.originX,e.originY,t,n);if(me(e.originX)===me($)||me(e.originX)===me(fe)&&s.x<0||me(e.originX)===me(J)&&s.x>0){const{target:i}=e,o=i.strokeWidth/(i.strokeUniform?i.scaleX:1),a=jp(e)?2:1,l=i.width,c=Math.abs(s.x*a/i.scaleX)-o;return i.set("width",Math.max(c,1)),l!==i.width}return!1}));function Ox(r,e,t,n,s){n=n||{};const i=this.sizeX||n.cornerSize||s.cornerSize,o=this.sizeY||n.cornerSize||s.cornerSize,a=n.transparentCorners!==void 0?n.transparentCorners:s.transparentCorners,l=a?qe:_e,c=!a&&(n.cornerStrokeColor||s.cornerStrokeColor);let u,h=e,d=t;r.save(),r.fillStyle=n.cornerColor||s.cornerColor||"",r.strokeStyle=n.cornerStrokeColor||s.cornerStrokeColor||"",i>o?(u=i,r.scale(1,o/i),d=t*i/o):o>i?(u=o,r.scale(i/o,1),h=e*o/i):u=i,r.beginPath(),r.arc(h,d,u/2,0,Xo,!1),r[l](),c&&r.stroke(),r.restore()}function Ex(r,e,t,n,s){n=n||{};const i=this.sizeX||n.cornerSize||s.cornerSize,o=this.sizeY||n.cornerSize||s.cornerSize,a=n.transparentCorners!==void 0?n.transparentCorners:s.transparentCorners,l=a?qe:_e,c=!a&&(n.cornerStrokeColor||s.cornerStrokeColor),u=i/2,h=o/2;r.save(),r.fillStyle=n.cornerColor||s.cornerColor||"",r.strokeStyle=n.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(e,t);const d=s.getTotalAngle();r.rotate(pe(d)),r["".concat(l,"Rect")](-u,-h,i,o),c&&r.strokeRect(-u,-h,i,o),r.restore()}class yt{constructor(e){C(this,"visible",!0),C(this,"actionName",wa),C(this,"angle",0),C(this,"x",0),C(this,"y",0),C(this,"offsetX",0),C(this,"offsetY",0),C(this,"sizeX",0),C(this,"sizeY",0),C(this,"touchSizeX",0),C(this,"touchSizeY",0),C(this,"cursorStyle","crosshair"),C(this,"withConnection",!1),Object.assign(this,e)}shouldActivate(e,t,n,s){var i;let{tl:o,tr:a,br:l,bl:c}=s;return((i=t.canvas)===null||i===void 0?void 0:i.getActiveObject())===t&&t.isControlVisible(e)&&le.isPointInPolygon(n,[o,a,l,c])}getActionHandler(e,t,n){return this.actionHandler}getMouseDownHandler(e,t,n){return this.mouseDownHandler}getMouseUpHandler(e,t,n){return this.mouseUpHandler}cursorStyleHandler(e,t,n){return t.cursorStyle}getActionName(e,t,n){return t.actionName}getVisibility(e,t){var n,s;return(n=(s=e._controlsVisibility)===null||s===void 0?void 0:s[t])!==null&&n!==void 0?n:this.visible}setVisibility(e,t,n){this.visible=e}positionHandler(e,t,n,s){return new O(this.x*e.x+this.offsetX,this.y*e.y+this.offsetY).transform(t)}calcCornerCoords(e,t,n,s,i,o){const a=ku([si(n,s),Qn({angle:e}),Ou((i?this.touchSizeX:this.sizeX)||t,(i?this.touchSizeY:this.sizeY)||t)]);return{tl:new O(-.5,-.5).transform(a),tr:new O(.5,-.5).transform(a),br:new O(.5,.5).transform(a),bl:new O(-.5,.5).transform(a)}}render(e,t,n,s,i){((s=s||{}).cornerStyle||i.cornerStyle)==="circle"?Ox.call(this,e,t,n,s,i):Ex.call(this,e,t,n,s,i)}}const Dx=(r,e,t)=>t.lockRotation?qo:e.cursorStyle,Px=Zn(mp,es((r,e,t,n)=>{let{target:s,ex:i,ey:o,theta:a,originX:l,originY:c}=e;const u=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Dt(s,"lockRotation"))return!1;const h=Math.atan2(o-u.y,i-u.x),d=Math.atan2(n-u.y,t-u.x);let f=cr(d-h+a);if(s.snapAngle&&s.snapAngle>0){const v=s.snapAngle,w=s.snapThreshold||v,g=Math.ceil(f/v)*v,p=Math.floor(f/v)*v;Math.abs(f-p)<w?f=p:Math.abs(f-g)<w&&(f=g)}f<0&&(f=360+f),f%=360;const m=s.angle!==f;return s.angle=f,m}));function Xp(r,e){const t=e.canvas,n=r[t.uniScaleKey];return t.uniformScaling&&!n||!t.uniformScaling&&n}function Up(r,e,t){const n=Dt(r,"lockScalingX"),s=Dt(r,"lockScalingY");if(n&&s||!e&&(n||s)&&t||n&&e==="x"||s&&e==="y")return!0;const{width:i,height:o,strokeWidth:a}=r;return i===0&&a===0&&e!=="y"||o===0&&a===0&&e!=="x"}const Mx=["e","se","s","sw","w","nw","n","ne","e"],ps=(r,e,t)=>{const n=Xp(r,t);if(Up(t,e.x!==0&&e.y===0?"x":e.x===0&&e.y!==0?"y":"",n))return qo;const s=Lp(t,e);return"".concat(Mx[s],"-resize")};function Au(r,e,t,n){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const i=e.target,o=s.by,a=Xp(r,i);let l,c,u,h,d,f;if(Up(i,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,u=e.scaleY*e.gestureScale;else{if(l=Pu(e,e.originX,e.originY,t,n),d=o!=="y"?Math.sign(l.x||e.signX||1):1,f=o!=="x"?Math.sign(l.y||e.signY||1):1,e.signX||(e.signX=d),e.signY||(e.signY=f),Dt(i,"lockScalingFlip")&&(e.signX!==d||e.signY!==f))return!1;if(h=i._getTransformedDimensions(),a&&!o){const w=Math.abs(l.x)+Math.abs(l.y),{original:g}=e,p=w/(Math.abs(h.x*g.scaleX/i.scaleX)+Math.abs(h.y*g.scaleY/i.scaleY));c=g.scaleX*p,u=g.scaleY*p}else c=Math.abs(l.x*i.scaleX/h.x),u=Math.abs(l.y*i.scaleY/h.y);jp(e)&&(c*=2,u*=2),e.signX!==d&&o!=="y"&&(e.originX=gd(e.originX),c*=-1,e.signX=d),e.signY!==f&&o!=="x"&&(e.originY=gd(e.originY),u*=-1,e.signY=f)}const m=i.scaleX,v=i.scaleY;return o?(o==="x"&&i.set(Qe,c),o==="y"&&i.set(gt,u)):(!Dt(i,"lockScalingX")&&i.set(Qe,c),!Dt(i,"lockScalingY")&&i.set(gt,u)),m!==i.scaleX||v!==i.scaleY}const Oi=Zn(_a,es((r,e,t,n)=>Au(r,e,t,n))),jx=Zn(_a,es((r,e,t,n)=>Au(r,e,t,n,{by:"x"}))),Ax=Zn(_a,es((r,e,t,n)=>Au(r,e,t,n,{by:"y"}))),Lx=["target","ex","ey","skewingSide"],hl={x:{counterAxis:"y",scale:Qe,skew:Kn,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:gt,skew:qn,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Fx=["ns","nesw","ew","nwse"],Rx=(r,e,t)=>{if(e.x!==0&&Dt(t,"lockSkewingY")||e.y!==0&&Dt(t,"lockSkewingX"))return qo;const n=Lp(t,e)%4;return"".concat(Fx[n],"-resize")};function $p(r,e,t,n,s){const{target:i}=t,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:u}=hl[r];if(Dt(i,l))return!1;const{origin:h,flip:d}=hl[o],f=me(t[h])*(i[d]?-1:1),m=-Math.sign(f)*(i[u]?-1:1),v=.5*-((i[c]===0&&Pu(t,$,$,n,s)[r]>0||i[c]>0?1:-1)*m)+.5;return Zn(vp,es((g,p,y,x)=>function(_,E,D){let{target:k,ex:N,ey:L,skewingSide:X}=E,T=ie(E,Lx);const{skew:M}=hl[_],R=D.subtract(new O(N,L)).divide(new O(k.scaleX,k.scaleY))[_],B=k[M],j=T[M],I=Math.tan(pe(j)),P=_==="y"?k._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:k._getTransformedDimensions({scaleX:1,scaleY:1}).y,z=2*R*X/Math.max(P,1)+I,A=cr(Math.atan(z));k.set(M,A);const U=B!==k[M];if(U&&_==="y"){const{skewX:G,scaleX:ae}=k,ee=k._getTransformedDimensions({skewY:B}),fr=k._getTransformedDimensions(),Ae=G!==0?ee.x/fr.x:1;Ae!==1&&k.set(Qe,Ae*ae)}return U}(r,p,new O(y,x))))(e,b(b({},t),{},{[a]:v,skewingSide:m}),n,s)}const Nx=(r,e,t,n)=>$p("x",r,e,t,n),Ix=(r,e,t,n)=>$p("y",r,e,t,n);function ka(r,e){return r[e.canvas.altActionKey]}const Ei=(r,e,t)=>{const n=ka(r,t);return e.x===0?n?Kn:gt:e.y===0?n?qn:Qe:""},Tn=(r,e,t)=>ka(r,t)?Rx(0,e,t):ps(r,e,t),Od=(r,e,t,n)=>ka(r,e.target)?Ix(r,e,t,n):jx(r,e,t,n),Ed=(r,e,t,n)=>ka(r,e.target)?Nx(r,e,t,n):Ax(r,e,t,n),Yp=()=>({ml:new yt({x:-.5,y:0,cursorStyleHandler:Tn,actionHandler:Od,getActionName:Ei}),mr:new yt({x:.5,y:0,cursorStyleHandler:Tn,actionHandler:Od,getActionName:Ei}),mb:new yt({x:0,y:.5,cursorStyleHandler:Tn,actionHandler:Ed,getActionName:Ei}),mt:new yt({x:0,y:-.5,cursorStyleHandler:Tn,actionHandler:Ed,getActionName:Ei}),tl:new yt({x:-.5,y:-.5,cursorStyleHandler:ps,actionHandler:Oi}),tr:new yt({x:.5,y:-.5,cursorStyleHandler:ps,actionHandler:Oi}),bl:new yt({x:-.5,y:.5,cursorStyleHandler:ps,actionHandler:Oi}),br:new yt({x:.5,y:.5,cursorStyleHandler:ps,actionHandler:Oi}),mtr:new yt({x:0,y:-.5,actionHandler:Px,cursorStyleHandler:Dx,offsetY:-40,withConnection:!0,actionName:bu})}),zx=()=>({mr:new yt({x:.5,y:0,actionHandler:kd,cursorStyleHandler:Tn,actionName:$s}),ml:new yt({x:-.5,y:0,actionHandler:kd,cursorStyleHandler:Tn,actionName:$s})}),Bx=()=>b(b({},Yp()),zx());class qs extends Xt{static getDefaults(){return b(b({},super.getDefaults()),qs.ownDefaults)}constructor(e){super(),Object.assign(this,this.constructor.createControls(),qs.ownDefaults),this.setOptions(e)}static createControls(){return{controls:Yp()}}_updateCacheCanvas(){const e=this.canvas;if(this.noScaleCache&&e&&e._currentTransform){const t=e._currentTransform,n=t.target,s=t.action;if(this===n&&s&&s.startsWith(wa))return!1}return super._updateCacheCanvas()}getActiveControl(){const e=this.__corner;return e?{key:e,control:this.controls[e],coord:this.oCoords[e]}:void 0}findControl(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const n=Object.entries(this.oCoords);for(let s=n.length-1;s>=0;s--){const[i,o]=n[s],a=this.controls[i];if(a.shouldActivate(i,this,e,t?o.touchCorner:o.corner))return this.__corner=i,{key:i,control:a,coord:this.oCoords[i]}}}calcOCoords(){const e=this.getViewportTransform(),t=this.getCenterPoint(),n=si(t.x,t.y),s=Qn({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),i=Te(n,s),o=Te(e,i),a=Te(o,[1/e[0],0,0,1/e[3],0,0]),l=this.group?Go(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),u={};return this.forEachControl((h,d)=>{const f=h.positionHandler(c,a,this,h);u[d]=Object.assign(f,this._calcCornerCoords(h,f))}),u}_calcCornerCoords(e,t){const n=this.getTotalAngle();return{corner:e.calcCornerCoords(n,this.cornerSize,t.x,t.y,!1,this),touchCorner:e.calcCornerCoords(n,this.touchCornerSize,t.x,t.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(e){for(const t in this.controls)e(this.controls[t],t,this)}drawSelectionBackground(e){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;e.save();const t=this.getRelativeCenterPoint(),n=this._calculateCurrentDimensions(),s=this.getViewportTransform();e.translate(t.x,t.y),e.scale(1/s[0],1/s[3]),e.rotate(pe(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore()}strokeBorders(e,t){e.strokeRect(-t.x/2,-t.y/2,t.x,t.y)}_drawBorders(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=b({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},n);e.save(),e.strokeStyle=s.borderColor,this._setLineDash(e,s.borderDashArray),this.strokeBorders(e,t),s.hasControls&&this.drawControlsConnectingLines(e,t),e.restore()}_renderControls(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:n,hasControls:s}=this,i=b({hasBorders:n,hasControls:s},t),o=this.getViewportTransform(),a=i.hasBorders,l=i.hasControls,c=Te(o,this.calcTransformMatrix()),u=Go(c);e.save(),e.translate(u.translateX,u.translateY),e.lineWidth=this.borderScaleFactor,this.group===this.parent&&(e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(u.angle-=180),e.rotate(pe(this.group?u.angle:this.angle)),a&&this.drawBorders(e,u,t),l&&this.drawControls(e,t),e.restore()}drawBorders(e,t,n){let s;if(n&&n.forActiveSelection||this.group){const i=Du(this.width,this.height,Sa(t)),o=this.isStrokeAccountedForInDimensions()?Tu:(this.strokeUniform?new O().scalarAdd(this.canvas?this.canvas.getZoom():1):new O(t.scaleX,t.scaleY)).scalarMultiply(this.strokeWidth);s=i.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(e,s,n)}drawControlsConnectingLines(e,t){let n=!1;e.beginPath(),this.forEachControl((s,i)=>{s.withConnection&&s.getVisibility(this,i)&&(n=!0,e.moveTo(s.x*t.x,s.y*t.y),e.lineTo(s.x*t.x+s.offsetX,s.y*t.y+s.offsetY))}),n&&e.stroke()}drawControls(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};e.save();const n=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:i,cornerColor:o}=this,a=b({cornerStrokeColor:s,cornerDashArray:i,cornerColor:o},t);e.setTransform(n,0,0,n,0,0),e.strokeStyle=e.fillStyle=a.cornerColor,this.transparentCorners||(e.strokeStyle=a.cornerStrokeColor),this._setLineDash(e,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const u=this.oCoords[c];l.render(e,u.x,u.y,a,this)}}),e.restore()}isControlVisible(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)}setControlVisible(e,t){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[e]=t}setControlsVisibility(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(e).forEach(t=>{let[n,s]=t;return this.setControlVisible(n,s)})}clearContextTop(e){if(!this.canvas)return;const t=this.canvas.contextTop;if(!t)return;const n=this.canvas.viewportTransform;t.save(),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this.transform(t);const s=this.width+4,i=this.height+4;return t.clearRect(-s/2,-i/2,s,i),e||t.restore(),t}onDeselect(e){return!1}onSelect(e){return!1}shouldStartDragging(e){return!1}onDragStart(e){return!1}canDrop(e){return!1}renderDragSourceEffect(e){}renderDropTargetEffect(e){}}function Gp(r,e){return e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}),r}C(qs,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Me extends qs{}Gp(Me,[Fp]),W.setClass(Me),W.setClass(Me,"object");const Vx=(r,e,t,n)=>{const s=2*(n=Math.round(n))+1,{data:i}=r.getImageData(e-n,t-n,s,s);for(let o=3;o<i.length;o+=4)if(i[o]>0)return!1;return!0};class Kp{constructor(e){this.options=e,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new O(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new O(1/this.options.scaleX,1/this.options.scaleY):new O(1,1)}createSideVector(e,t){const n=vc(e,t);return this.options.strokeUniform?n.multiply(this.scale):n}projectOrthogonally(e,t,n){return this.applySkew(e.add(this.calcOrthogonalProjection(e,t,n)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(e){const t=new O(e);return t.y+=t.x*Math.tan(pe(this.options.skewY)),t.x+=t.y*Math.tan(pe(this.options.skewX)),t}scaleUnitVector(e,t){return e.multiply(this.strokeUniformScalar).scalarMultiply(t)}}const Wx=new O;class Rn extends Kp{static getOrthogonalRotationFactor(e,t){const n=t?xc(e,t):ux(e);return Math.abs(n)<ni?-1:1}constructor(e,t,n,s){super(s),C(this,"AB",void 0),C(this,"AC",void 0),C(this,"alpha",void 0),C(this,"bisector",void 0),this.A=new O(e),this.B=new O(t),this.C=new O(n),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=xc(this.AB,this.AC),this.bisector=Mu(Vp(this.AB.eq(Wx)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(e,t),i=Wp(s),o=Rn.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,n*o)}projectBevel(){const e=[];return(this.alpha%Xo==0?[this.B]:[this.B,this.C]).forEach(t=>{e.push(this.projectOrthogonally(this.A,t)),e.push(this.projectOrthogonally(this.A,t,-this.strokeProjectionMagnitude))}),e}projectMiter(){const e=[],t=Math.abs(this.alpha),n=1/Math.sin(t/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*n),i=this.options.strokeUniform?yc(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return yc(s)/this.strokeProjectionMagnitude<=i&&e.push(this.applySkew(this.A.add(s))),e.push(...this.projectBevel()),e}projectRoundNoSkew(e,t){const n=[],s=new O(Rn.getOrthogonalRotationFactor(this.bisector),Rn.getOrthogonalRotationFactor(new O(this.bisector.y,this.bisector.x)));return[new O(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new O(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(i=>{Cd(i,e,t)&&n.push(this.A.add(i))}),n}projectRoundWithSkew(e,t){const n=[],{skewX:s,skewY:i,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new O(Math.tan(pe(s)),Math.tan(pe(i))),u=this.strokeProjectionMagnitude,h=l?u/a/Math.sqrt(1/a**2+1/o**2*c.y**2):u/Math.sqrt(1+c.y**2),d=new O(Math.sqrt(Math.max(u**2-h**2,0)),h),f=l?u/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):u/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),m=new O(f,Math.sqrt(Math.max(u**2-f**2,0)));return[m,m.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(v=>this.applySkew(l?v.multiply(this.strokeUniformScalar):v)).forEach(v=>{Cd(v,e,t)&&n.push(this.applySkew(this.A).add(v))}),n}projectRound(){const e=[];e.push(...this.projectBevel());const t=this.alpha%Xo==0,n=this.applySkew(this.A),s=e[t?0:2].subtract(n),i=e[t?1:0].subtract(n),o=t?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Es(s,o)>0,l=a?s:i,c=a?i:s;return this.isSkewed()?e.push(...this.projectRoundWithSkew(l,c)):e.push(...this.projectRoundNoSkew(l,c)),e}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e,angle:this.alpha,bisector:this.bisector}))}}class Dd extends Kp{constructor(e,t,n){super(n),this.A=new O(e),this.T=new O(t)}calcOrthogonalProjection(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(e,t);return this.scaleUnitVector(Wp(s),n)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const e=[];if(!this.isSkewed()&&this.A.eq(this.T)){const t=new O(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.applySkew(this.A.add(t)),this.applySkew(this.A.subtract(t)))}else e.push(...new Rn(this.A,this.T,this.T,this.options).projectRound());return e}projectSquare(){const e=[];if(this.A.eq(this.T)){const t=new O(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.A.add(t),this.A.subtract(t))}else{const t=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),n=this.scaleUnitVector(Mu(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(n);e.push(s.add(t),s.subtract(t))}return e.map(t=>this.applySkew(t))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e}))}}const Hx=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const n=[];if(r.length===0)return n;const s=r.reduce((i,o)=>(i[i.length-1].eq(o)||i.push(new O(o)),i),[new O(r[0])]);if(s.length===1)t=!0;else if(!t){const i=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,a=>!a.eq(i));s.splice(o+1)}return s.forEach((i,o,a)=>{let l,c;o===0?(c=a[1],l=t?i:a[a.length-1]):o===a.length-1?(l=a[o-1],c=t?i:a[0]):(l=a[o-1],c=a[o+1]),t&&a.length===1?n.push(...new Dd(i,i,e).project()):!t||o!==0&&o!==a.length-1?n.push(...new Rn(i,l,c,e).project()):n.push(...new Dd(i,o===0?c:l,e).project())}),n},Lu=r=>{const e={};return Object.keys(r).forEach(t=>{e[t]={},Object.keys(r[t]).forEach(n=>{e[t][n]=b({},r[t][n])})}),e},Xx=r=>r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let cs;const Fu=r=>{if(cs||cs||(cs="Intl"in xa()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),cs){const e=cs.segment(r);return Array.from(e).map(t=>{let{segment:n}=t;return n})}return Ux(r)},Ux=r=>{const e=[];for(let t,n=0;n<r.length;n++)(t=$x(r,n))!==!1&&e.push(t);return e},$x=(r,e)=>{const t=r.charCodeAt(e);if(isNaN(t))return"";if(t<55296||t>57343)return r.charAt(e);if(55296<=t&&t<=56319){if(r.length<=e+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(e+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(e)+r.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";const n=r.charCodeAt(e-1);if(55296>n||n>56319)throw"Low surrogate without preceding high surrogate";return!1},Ru=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==e.fill||r.stroke!==e.stroke||r.strokeWidth!==e.strokeWidth||r.fontSize!==e.fontSize||r.fontFamily!==e.fontFamily||r.fontWeight!==e.fontWeight||r.fontStyle!==e.fontStyle||r.textDecorationThickness!==e.textDecorationThickness||r.textBackgroundColor!==e.textBackgroundColor||r.deltaY!==e.deltaY||t&&(r.overline!==e.overline||r.underline!==e.underline||r.linethrough!==e.linethrough)},Yx=(r,e)=>{const t=e.split(`
77
- `),n=[];let s=-1,i={};r=Lu(r);for(let o=0;o<t.length;o++){const a=Fu(t[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Ru(i,c,!0)?n.push({start:s,end:s+1,style:c}):n[n.length-1].end++),i=c||{}}else s+=a.length,i={}}return n},Gx=(r,e)=>{if(!Array.isArray(r))return Lu(r);const t=e.split(Cu),n={};let s=-1,i=0;for(let o=0;o<t.length;o++){const a=Fu(t[o]);for(let l=0;l<a.length;l++)s++,r[i]&&r[i].start<=s&&s<r[i].end&&(n[o]=n[o]||{},n[o][l]=b({},r[i].style),s===r[i].end-1&&i++)}return n},Vr=["display","transform",_e,"fill-opacity","fill-rule","opacity",qe,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function Pd(r,e){const t=r.nodeName,n=r.getAttribute("class"),s=r.getAttribute("id"),i="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+t,"i"),e=e.replace(o,""),s&&e.length&&(o=new RegExp("#"+s+i,"i"),e=e.replace(o,"")),n&&e.length){const a=n.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+i,"i"),e=e.replace(o,"")}return e.length===0}function Kx(r,e){let t=!0;const n=Pd(r,e.pop());return n&&e.length&&(t=function(s,i){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&i.length;)a&&(o=i.pop()),a=Pd(s=s.parentElement,o);return i.length===0}(r,e)),n&&t&&e.length===0}const qx=r=>{var e;return(e=lx[r])!==null&&e!==void 0?e:r},Qx=new RegExp("(".concat(kt,")"),"gi"),Jx=r=>Qo(r.replace(Qx," $1 ").replace(/,/gi," "));var Md,jd,Ad,Ld,Fd,Rd,Nd;const Ne="(".concat(kt,")"),Zx=String.raw(Md||(Md=Ht(["(skewX)(",")"],["(skewX)\\(","\\)"])),Ne),e1=String.raw(jd||(jd=Ht(["(skewY)(",")"],["(skewY)\\(","\\)"])),Ne),t1=String.raw(Ad||(Ad=Ht(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Ne,Ne,Ne),r1=String.raw(Ld||(Ld=Ht(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Ne,Ne),n1=String.raw(Fd||(Fd=Ht(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Ne,Ne),s1=String.raw(Rd||(Rd=Ht(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Ne,Ne,Ne,Ne,Ne,Ne),Nu="(?:".concat(s1,"|").concat(n1,"|").concat(t1,"|").concat(r1,"|").concat(Zx,"|").concat(e1,")"),i1="(?:".concat(Nu,"*)"),o1=String.raw(Nd||(Nd=Ht(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),i1),a1=new RegExp(o1),l1=new RegExp(Nu),c1=new RegExp(Nu,"g");function _c(r){const e=[];if(!(r=Jx(r).replace(/\s*([()])\s*/gi,"$1"))||r&&!a1.test(r))return[...ze];for(const t of r.matchAll(c1)){const n=l1.exec(t[0]);if(!n)continue;let s=ze;const i=n.filter(m=>!!m),[,o,...a]=i,[l,c,u,h,d,f]=a.map(m=>parseFloat(m));switch(o){case"translate":s=si(l,c);break;case bu:s=Qn({angle:l},{x:c,y:u});break;case wa:s=Ou(l,c);break;case Kn:s=bp(l);break;case qn:s=Tp(l);break;case"matrix":s=[l,c,u,h,d,f]}e.push(s)}return ku(e)}function u1(r,e,t,n){const s=Array.isArray(e);let i,o=e;if(r!==_e&&r!==qe||e!==Ke){if(r==="strokeUniform")return e==="non-scaling-stroke";if(r==="strokeDashArray")o=e===Ke?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(r==="transformMatrix")o=t&&t.transformMatrix?Te(t.transformMatrix,_c(e)):_c(e);else if(r==="visible")o=e!==Ke&&e!=="hidden",t&&t.visible===!1&&(o=!1);else if(r==="opacity")o=parseFloat(e),t&&t.opacity!==void 0&&(o*=t.opacity);else if(r==="textAnchor")o=e==="start"?J:e==="end"?fe:$;else if(r==="charSpacing"||r===sn)i=Fn(e,n)/n*1e3;else if(r==="paintFirst"){const a=e.indexOf(_e),l=e.indexOf(qe);o=_e,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=qe)}else{if(r==="href"||r==="xlink:href"||r==="font"||r==="id")return e;if(r==="imageSmoothing")return e==="optimizeQuality";i=s?e.map(Fn):Fn(e,n)}}else o="";return!s&&isNaN(i)?o:i}function h1(r,e){const t=r.match(ax);if(!t)return;const n=t[1],s=t[3],i=t[4],o=t[5],a=t[6];n&&(e.fontStyle=n),s&&(e.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),i&&(e.fontSize=Fn(i)),a&&(e.fontFamily=a),o&&(e.lineHeight=o==="normal"?1:o)}function d1(r,e){r.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;const[n,s]=t.split(":");e[n.trim().toLowerCase()]=s.trim()})}function f1(r){const e={},t=r.getAttribute("style");return t&&(typeof t=="string"?d1(t,e):function(n,s){Object.entries(n).forEach(i=>{let[o,a]=i;a!==void 0&&(s[o.toLowerCase()]=a)})}(t,e)),e}const g1={stroke:"strokeOpacity",fill:"fillOpacity"};function dr(r,e,t){if(!r)return{};let n,s={},i=Su;r.parentNode&&Sd.test(r.parentNode.nodeName)&&(s=dr(r.parentElement,e,t),s.fontSize&&(n=i=Fn(s.fontSize)));const o=b(b(b({},e.reduce((c,u)=>{const h=r.getAttribute(u);return h&&(c[u]=h),c},{})),function(c){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h={};for(const d in u)Kx(c,d.split(" "))&&(h=b(b({},h),u[d]));return h}(r,t)),f1(r));o[cl]&&r.setAttribute(cl,o[cl]),o[ll]&&(n=Fn(o[ll],i),o[ll]="".concat(n));const a={};for(const c in o){const u=qx(c),h=u1(u,o[c],s,n);a[u]=h}a&&a.font&&h1(a.font,a);const l=b(b({},s),a);return Sd.test(r.nodeName)?l:function(c){const u=Me.getDefaults();return Object.entries(g1).forEach(h=>{let[d,f]=h;if(c[f]===void 0||c[d]==="")return;if(c[d]===void 0){if(!u[d])return;c[d]=u[d]}if(c[d].indexOf("url(")===0)return;const m=new Q(c[d]);c[d]=m.setAlpha(te(m.getAlpha()*c[f],2)).toRgba()}),c}(l)}const p1=["left","top","width","height","visible"],qp=["rx","ry"];class Ct extends Me{static getDefaults(){return b(b({},super.getDefaults()),Ct.ownDefaults)}constructor(e){super(),Object.assign(this,Ct.ownDefaults),this.setOptions(e),this._initRxRy()}_initRxRy(){const{rx:e,ry:t}=this;e&&!t?this.ry=e:t&&!e&&(this.rx=t)}_render(e){const{width:t,height:n}=this,s=-t/2,i=-n/2,o=this.rx?Math.min(this.rx,t/2):0,a=this.ry?Math.min(this.ry,n/2):0,l=o!==0||a!==0;e.beginPath(),e.moveTo(s+o,i),e.lineTo(s+t-o,i),l&&e.bezierCurveTo(s+t-mr*o,i,s+t,i+mr*a,s+t,i+a),e.lineTo(s+t,i+n-a),l&&e.bezierCurveTo(s+t,i+n-mr*a,s+t-mr*o,i+n,s+t-o,i+n),e.lineTo(s+o,i+n),l&&e.bezierCurveTo(s+mr*o,i+n,s,i+n-mr*a,s,i+n-a),e.lineTo(s,i+a),l&&e.bezierCurveTo(s,i+mr*a,s+mr*o,i,s+o,i),e.closePath(),this._renderPaintInOrder(e)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...qp,...e])}_toSVG(){const{width:e,height:t,rx:n,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-e/2,'" y="').concat(-t/2,'" rx="').concat(n,'" ry="').concat(s,'" width="').concat(e,'" height="').concat(t,`" />
78
- `)]}static async fromElement(e,t,n){const s=dr(e,this.ATTRIBUTE_NAMES,n),{left:i=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,u=ie(s,p1);return new this(b(b(b({},t),u),{},{left:i,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}C(Ct,"type","Rect"),C(Ct,"cacheProperties",[...hr,...qp]),C(Ct,"ownDefaults",{rx:0,ry:0}),C(Ct,"ATTRIBUTE_NAMES",[...Vr,"x","y","rx","ry","width","height"]),W.setClass(Ct),W.setSVGClass(Ct);const Jt="initialization",Zo="added",Iu="removed",ea="imperative",Qp=(r,e)=>{const{strokeUniform:t,strokeWidth:n,width:s,height:i,group:o}=e,a=o&&o!==r?ba(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),u=t&&c?ex(new O(n,n),void 0,r.calcTransformMatrix()):Tu,h=!t&&c?n:0,d=Du(s+h,i+h,ku([a,e.calcOwnMatrix()],!0)).add(u).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Oa{calcLayoutResult(e,t){if(this.shouldPerformLayout(e))return this.calcBoundingBox(t,e)}shouldPerformLayout(e){let{type:t,prevStrategy:n,strategy:s}=e;return t===Jt||t===ea||!!n&&s!==n}shouldLayoutClipPath(e){let{type:t,target:{clipPath:n}}=e;return t!==Jt&&n&&!n.absolutePositioned}getInitialSize(e,t){return t.size}calcBoundingBox(e,t){const{type:n,target:s}=t;if(n===ea&&t.overrides)return t.overrides;if(e.length===0)return;const{left:i,top:o,width:a,height:l}=tr(e.map(h=>Qp(s,h)).reduce((h,d)=>h.concat(d),[])),c=new O(a,l),u=new O(i,o).add(c.scalarDivide(2));if(n===Jt){const h=this.getInitialSize(t,{size:c,center:u});return{center:u,relativeCorrection:new O(0,0),size:h}}return{center:u.transform(s.calcOwnMatrix()),size:c}}}C(Oa,"type","strategy");class wc extends Oa{shouldPerformLayout(e){return!0}}C(wc,"type","fit-content"),W.setClass(wc);const m1=["strategy"],v1=["target","strategy","bubbles","prevStrategy"],Jp="layoutManager";class Qs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new wc;C(this,"strategy",void 0),this.strategy=e,this._subscriptions=new Map}performLayout(e){const t=b(b({bubbles:!0,strategy:this.strategy},e),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(t);const n=this.getLayoutResult(t);n&&this.commitLayout(t,n),this.onAfterLayout(t,n),this._prevLayoutStrategy=t.strategy}attachHandlers(e,t){const{target:n}=t;return[$o,pp,$s,mp,_a,vp,Uo,z0,B0].map(s=>e.on(s,i=>this.performLayout(s===$o?{type:"object_modified",trigger:s,e:i,target:n}:{type:"object_modifying",trigger:s,e:i,target:n})))}subscribe(e,t){this.unsubscribe(e,t);const n=this.attachHandlers(e,t);this._subscriptions.set(e,n)}unsubscribe(e,t){(this._subscriptions.get(e)||[]).forEach(n=>n()),this._subscriptions.delete(e)}unsubscribeTargets(e){e.targets.forEach(t=>this.unsubscribe(t,e))}subscribeTargets(e){e.targets.forEach(t=>this.subscribe(t,e))}onBeforeLayout(e){const{target:t,type:n}=e,{canvas:s}=t;if(n===Jt||n===Zo?this.subscribeTargets(e):n===Iu&&this.unsubscribeTargets(e),t.fire("layout:before",{context:e}),s&&s.fire("object:layout:before",{target:t,context:e}),n===ea&&e.deep){const i=ie(e,m1);t.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(b(b({},i),{},{bubbles:!1,target:o})))}}getLayoutResult(e){const{target:t,strategy:n,type:s}=e,i=n.calcLayoutResult(e,t.getObjects());if(!i)return;const o=s===Jt?new O:t.getRelativeCenterPoint(),{center:a,correction:l=new O,relativeCorrection:c=new O}=i,u=o.subtract(a).add(l).transform(s===Jt?ze:Tt(t.calcOwnMatrix()),!0).add(c);return{result:i,prevCenter:o,nextCenter:a,offset:u}}commitLayout(e,t){const{target:n}=e,{result:{size:s},nextCenter:i}=t;var o,a;n.set({width:s.x,height:s.y}),this.layoutObjects(e,t),e.type===Jt?n.set({left:(o=e.x)!==null&&o!==void 0?o:i.x+s.x*me(n.originX),top:(a=e.y)!==null&&a!==void 0?a:i.y+s.y*me(n.originY)}):(n.setPositionByOrigin(i,$,$),n.setCoords(),n.set("dirty",!0))}layoutObjects(e,t){const{target:n}=e;n.forEachObject(s=>{s.group===n&&this.layoutObject(e,t,s)}),e.strategy.shouldLayoutClipPath(e)&&this.layoutObject(e,t,n.clipPath)}layoutObject(e,t,n){let{offset:s}=t;n.set({left:n.left+s.x,top:n.top+s.y})}onAfterLayout(e,t){const{target:n,strategy:s,bubbles:i,prevStrategy:o}=e,a=ie(e,v1),{canvas:l}=n;n.fire("layout:after",{context:e,result:t}),l&&l.fire("object:layout:after",{context:e,result:t,target:n});const c=n.parent;i&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(n),c.layoutManager.performLayout(b(b({},a),{},{target:c}))),n.set("dirty",!0)}dispose(){const{_subscriptions:e}=this;e.forEach(t=>t.forEach(n=>n())),e.clear()}toObject(){return{type:Jp,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}W.setClass(Qs,Jp);const y1=["type","objects","layoutManager"];class x1 extends Qs{performLayout(){}}class Jr extends yp(Me){static getDefaults(){return b(b({},super.getDefaults()),Jr.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),C(this,"_activeObjects",[]),C(this,"__objectSelectionTracker",void 0),C(this,"__objectSelectionDisposer",void 0),Object.assign(this,Jr.ownDefaults),this.setOptions(t),this.groupInit(e,t)}groupInit(e,t){var n;this._objects=[...e],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(s=>{this.enterGroup(s,!1)}),this.layoutManager=(n=t.layoutManager)!==null&&n!==void 0?n:new Qs,this.layoutManager.performLayout({type:Jt,target:this,targets:[...e],x:t.left,y:t.top})}canEnterGroup(e){return e===this||this.isDescendantOf(e)?(Rr("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(e)===-1||(Rr("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(e){return e.filter((t,n,s)=>this.canEnterGroup(t)&&s.indexOf(t)===n)}add(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const s=this._filterObjectsBeforeEnteringGroup(t),i=super.add(...s);return this._onAfterObjectsChange(Zo,s),i}insertAt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];const i=this._filterObjectsBeforeEnteringGroup(n),o=super.insertAt(e,...i);return this._onAfterObjectsChange(Zo,i),o}remove(){const e=super.remove(...arguments);return this._onAfterObjectsChange(Iu,e),e}_onObjectAdded(e){this.enterGroup(e,!0),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e,t){this.exitGroup(e,t),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onAfterObjectsChange(e,t){this.layoutManager.performLayout({type:e,targets:t,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(e,t){const n=this[e];return super._set(e,t),e==="canvas"&&n!==t&&(this._objects||[]).forEach(s=>{s._set(e,t)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(e,t){let{target:n}=t;const s=this._activeObjects;if(e)s.push(n),this._set("dirty",!0);else if(s.length>0){const i=s.indexOf(n);i>-1&&(s.splice(i,1),this._set("dirty",!0))}}_watchObject(e,t){e&&this._watchObject(!1,t),e?(t.on("selected",this.__objectSelectionTracker),t.on("deselected",this.__objectSelectionDisposer)):(t.off("selected",this.__objectSelectionTracker),t.off("deselected",this.__objectSelectionDisposer))}enterGroup(e,t){e.group&&e.group.remove(e),e._set("parent",this),this._enterGroup(e,t)}_enterGroup(e,t){t&&Ko(e,Te(Tt(this.calcTransformMatrix()),e.calcTransformMatrix())),this._shouldSetNestedCoords()&&e.setCoords(),e._set("group",this),e._set("canvas",this.canvas),this._watchObject(!0,e);const n=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();n&&(n===e||e.isDescendantOf(n))&&this._activeObjects.push(e)}exitGroup(e,t){this._exitGroup(e,t),e._set("parent",void 0),e._set("canvas",void 0)}_exitGroup(e,t){e._set("group",void 0),t||(Ko(e,Te(this.calcTransformMatrix(),e.calcTransformMatrix())),e.setCoords()),this._watchObject(!1,e);const n=this._activeObjects.length>0?this._activeObjects.indexOf(e):-1;n>-1&&this._activeObjects.splice(n,1)}shouldCache(){const e=Me.prototype.shouldCache.call(this);if(e){for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1}return e}willDrawShadow(){if(super.willDrawShadow())return!0;for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(e,t,n){this._renderBackground(e);for(let i=0;i<this._objects.length;i++){var s;const o=this._objects[i];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(e.save(),e.transform(...Tt(this.calcTransformMatrix())),o.render(e),e.restore()):o.group===this&&o.render(e)}this._drawClipPath(e,this.clipPath,n)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(e=>e.setCoords())}triggerLayout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(b({target:this,type:ea},e))}render(e){this._transformDone=!0,super.render(e),this._transformDone=!1}__serializeObjects(e,t){const n=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const i=s.includeDefaultValues;s.includeDefaultValues=n;const o=s[e||"toObject"](t);return s.includeDefaultValues=i,o})}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=this.layoutManager.toObject();return b(b(b({},super.toObject(["subTargetCheck","interactive",...e])),t.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:t}:{}),{},{objects:this.__serializeObjects("toObject",e)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(e=>{this._watchObject(!1,e),e.dispose()}),super.dispose()}_createSVGBgRect(e){if(!this.backgroundColor)return"";const t=Ct.prototype._toSVG.call(this),n=t.indexOf("COMMON_PARTS");t[n]='for="group" ';const s=t.join("");return e?e(s):s}_toSVG(e){const t=["<g ","COMMON_PARTS",` >
79
- `],n=this._createSVGBgRect(e);n&&t.push(" ",n);for(let s=0;s<this._objects.length;s++)t.push(" ",this._objects[s].toSVG(e));return t.push(`</g>
80
- `),t}getSvgStyles(){const e=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",t=this.visible?"":" visibility: hidden;";return[e,this.getSvgFilter(),t].join("")}toClipPathSVG(e){const t=[],n=this._createSVGBgRect(e);n&&t.push(" ",n);for(let s=0;s<this._objects.length;s++)t.push(" ",this._objects[s].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject(e,t){let{type:n,objects:s=[],layoutManager:i}=e,o=ie(e,y1);return Promise.all([Ys(s,t),Ca(o,t)]).then(a=>{let[l,c]=a;const u=new this(l,b(b(b({},o),c),{},{layoutManager:new x1}));if(i){const h=W.getClass(i.type),d=W.getClass(i.strategy);u.layoutManager=new h(new d)}else u.layoutManager=new Qs;return u.layoutManager.subscribeTargets({type:Jt,target:u,targets:u.getObjects()}),u.setCoords(),u})}}C(Jr,"type","Group"),C(Jr,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),W.setClass(Jr);const _1=(r,e)=>Math.min(e.width/r.width,e.height/r.height),w1=(r,e)=>Math.max(e.width/r.width,e.height/r.height),Sc="\\s*,?\\s*",us="".concat(Sc,"(").concat(kt,")"),S1="".concat(us).concat(us).concat(us).concat(Sc,"([01])").concat(Sc,"([01])").concat(us).concat(us),C1={m:"l",M:"L"},b1=(r,e,t,n,s,i,o,a,l,c,u)=>{const h=or(r),d=ar(r),f=or(e),m=ar(e),v=t*s*f-n*i*m+o,w=n*s*f+t*i*m+a;return["C",c+l*(-t*s*d-n*i*h),u+l*(-n*s*d+t*i*h),v+l*(t*s*m+n*i*f),w+l*(n*s*m-t*i*f),v,w]},Id=(r,e,t,n)=>{const s=Math.atan2(e,r),i=Math.atan2(n,t);return i>=s?i-s:2*Math.PI-(s-i)};function zd(r,e,t,n,s,i,o,a){let l;if(q.cachesBoundsOfCurve&&(l=[...arguments].join(),Ts.boundsOfCurveCache[l]))return Ts.boundsOfCurveCache[l];const c=Math.sqrt,u=Math.abs,h=[],d=[[0,0],[0,0]];let f=6*r-12*t+6*s,m=-3*r+9*t-9*s+3*o,v=3*t-3*r;for(let x=0;x<2;++x){if(x>0&&(f=6*e-12*n+6*i,m=-3*e+9*n-9*i+3*a,v=3*n-3*e),u(m)<1e-12){if(u(f)<1e-12)continue;const N=-v/f;0<N&&N<1&&h.push(N);continue}const _=f*f-4*v*m;if(_<0)continue;const E=c(_),D=(-f+E)/(2*m);0<D&&D<1&&h.push(D);const k=(-f-E)/(2*m);0<k&&k<1&&h.push(k)}let w=h.length;const g=w,p=Zp(r,e,t,n,s,i,o,a);for(;w--;){const{x,y:_}=p(h[w]);d[0][w]=x,d[1][w]=_}d[0][g]=r,d[1][g]=e,d[0][g+1]=o,d[1][g+1]=a;const y=[new O(Math.min(...d[0]),Math.min(...d[1])),new O(Math.max(...d[0]),Math.max(...d[1]))];return q.cachesBoundsOfCurve&&(Ts.boundsOfCurveCache[l]=y),y}const T1=(r,e,t)=>{let[n,s,i,o,a,l,c,u]=t;const h=((d,f,m,v,w,g,p)=>{if(m===0||v===0)return[];let y=0,x=0,_=0;const E=Math.PI,D=p*wu,k=ar(D),N=or(D),L=.5*(-N*d-k*f),X=.5*(-N*f+k*d),T=m**2,M=v**2,R=X**2,B=L**2,j=T*M-T*R-M*B;let I=Math.abs(m),P=Math.abs(v);if(j<0){const gr=Math.sqrt(1-j/(T*M));I*=gr,P*=gr}else _=(w===g?-1:1)*Math.sqrt(j/(T*R+M*B));const z=_*I*X/P,A=-_*P*L/I,U=N*z-k*A+.5*d,G=k*z+N*A+.5*f;let ae=Id(1,0,(L-z)/I,(X-A)/P),ee=Id((L-z)/I,(X-A)/P,(-L-z)/I,(-X-A)/P);g===0&&ee>0?ee-=2*E:g===1&&ee<0&&(ee+=2*E);const fr=Math.ceil(Math.abs(ee/E*2)),Ae=[],Mt=ee/fr,ym=8/3*Math.sin(Mt/4)*Math.sin(Mt/4)/Math.sin(Mt/2);let Pa=ae+Mt;for(let gr=0;gr<fr;gr++)Ae[gr]=b1(ae,Pa,N,k,I,P,U,G,ym,y,x),y=Ae[gr][5],x=Ae[gr][6],ae=Pa,Pa+=Mt;return Ae})(c-r,u-e,s,i,a,l,o);for(let d=0,f=h.length;d<f;d++)h[d][1]+=r,h[d][2]+=e,h[d][3]+=r,h[d][4]+=e,h[d][5]+=r,h[d][6]+=e;return h},k1=r=>{let e=0,t=0,n=0,s=0;const i=[];let o,a=0,l=0;for(const c of r){const u=[...c];let h;switch(u[0]){case"l":u[1]+=e,u[2]+=t;case"L":e=u[1],t=u[2],h=["L",e,t];break;case"h":u[1]+=e;case"H":e=u[1],h=["L",e,t];break;case"v":u[1]+=t;case"V":t=u[1],h=["L",e,t];break;case"m":u[1]+=e,u[2]+=t;case"M":e=u[1],t=u[2],n=u[1],s=u[2],h=["M",e,t];break;case"c":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t,u[5]+=e,u[6]+=t;case"C":a=u[3],l=u[4],e=u[5],t=u[6],h=["C",u[1],u[2],a,l,e,t];break;case"s":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t;case"S":o==="C"?(a=2*e-a,l=2*t-l):(a=e,l=t),e=u[3],t=u[4],h=["C",a,l,u[1],u[2],e,t],a=h[3],l=h[4];break;case"q":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t;case"Q":a=u[1],l=u[2],e=u[3],t=u[4],h=["Q",a,l,e,t];break;case"t":u[1]+=e,u[2]+=t;case"T":o==="Q"?(a=2*e-a,l=2*t-l):(a=e,l=t),e=u[1],t=u[2],h=["Q",a,l,e,t];break;case"a":u[6]+=e,u[7]+=t;case"A":T1(e,t,u).forEach(d=>i.push(d)),e=u[6],t=u[7];break;case"z":case"Z":e=n,t=s,h=["Z"]}h?(i.push(h),o=h[0]):o=""}return i},ta=(r,e,t,n)=>Math.sqrt((t-r)**2+(n-e)**2),Zp=(r,e,t,n,s,i,o,a)=>l=>{const c=l**3,u=(f=>3*f**2*(1-f))(l),h=(f=>3*f*(1-f)**2)(l),d=(f=>(1-f)**3)(l);return new O(o*c+s*u+t*h+r*d,a*c+i*u+n*h+e*d)},em=r=>r**2,tm=r=>2*r*(1-r),rm=r=>(1-r)**2,O1=(r,e,t,n,s,i,o,a)=>l=>{const c=em(l),u=tm(l),h=rm(l),d=3*(h*(t-r)+u*(s-t)+c*(o-s)),f=3*(h*(n-e)+u*(i-n)+c*(a-i));return Math.atan2(f,d)},E1=(r,e,t,n,s,i)=>o=>{const a=em(o),l=tm(o),c=rm(o);return new O(s*a+t*l+r*c,i*a+n*l+e*c)},D1=(r,e,t,n,s,i)=>o=>{const a=1-o,l=2*(a*(t-r)+o*(s-t)),c=2*(a*(n-e)+o*(i-n));return Math.atan2(c,l)},Bd=(r,e,t)=>{let n=new O(e,t),s=0;for(let i=1;i<=100;i+=1){const o=r(i/100);s+=ta(n.x,n.y,o.x,o.y),n=o}return s},P1=(r,e)=>{let t,n=0,s=0,i={x:r.x,y:r.y},o=b({},i),a=.01,l=0;const c=r.iterator,u=r.angleFinder;for(;s<e&&a>1e-4;)o=c(n),l=n,t=ta(i.x,i.y,o.x,o.y),t+s>e?(n-=a,a/=2):(i=o,n+=a,s+=t);return b(b({},o),{},{angle:u(l)})},nm=r=>{let e,t,n=0,s=0,i=0,o=0,a=0;const l=[];for(const c of r){const u={x:s,y:i,command:c[0],length:0};switch(c[0]){case"M":t=u,t.x=o=s=c[1],t.y=a=i=c[2];break;case"L":t=u,t.length=ta(s,i,c[1],c[2]),s=c[1],i=c[2];break;case"C":e=Zp(s,i,c[1],c[2],c[3],c[4],c[5],c[6]),t=u,t.iterator=e,t.angleFinder=O1(s,i,c[1],c[2],c[3],c[4],c[5],c[6]),t.length=Bd(e,s,i),s=c[5],i=c[6];break;case"Q":e=E1(s,i,c[1],c[2],c[3],c[4]),t=u,t.iterator=e,t.angleFinder=D1(s,i,c[1],c[2],c[3],c[4]),t.length=Bd(e,s,i),s=c[3],i=c[4];break;case"Z":t=u,t.destX=o,t.destY=a,t.length=ta(s,i,o,a),s=o,i=a}n+=t.length,l.push(t)}return l.push({length:n,x:s,y:i}),l},M1=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nm(r),n=0;for(;e-t[n].length>0&&n<t.length-2;)e-=t[n].length,n++;const s=t[n],i=e/s.length,o=r[n];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return b(b({},new O(s.x,s.y).lerp(new O(s.destX,s.destY),i)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return b(b({},new O(s.x,s.y).lerp(new O(o[1],o[2]),i)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return P1(s,e)}},j1=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Vd=new RegExp(S1,"g"),A1=new RegExp(kt,"gi"),L1={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},F1=r=>{var e;const t=[],n=(e=r.match(j1))!==null&&e!==void 0?e:[];for(const s of n){const i=s[0];if(i==="z"||i==="Z"){t.push([i]);continue}const o=L1[i.toLowerCase()];let a=[];if(i==="a"||i==="A"){Vd.lastIndex=0;for(let l=null;l=Vd.exec(s);)a.push(...l.slice(1))}else a=s.match(A1)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),u=C1[i];c[0]=l>0&&u?u:i;for(let h=0;h<o;h++)c[h+1]=parseFloat(a[l+h]);t.push(c)}}return t},R1=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=new O(r[0]),n=new O(r[1]),s=1,i=0;const o=[],a=r.length,l=a>2;let c;for(l&&(s=r[2].x<n.x?-1:r[2].x===n.x?0:1,i=r[2].y<n.y?-1:r[2].y===n.y?0:1),o.push(["M",t.x-s*e,t.y-i*e]),c=1;c<a;c++){if(!t.eq(n)){const u=t.midPointFrom(n);o.push(["Q",t.x,t.y,u.x,u.y])}t=r[c],c+1<r.length&&(n=r[c+1])}return l&&(s=t.x>r[c-2].x?1:t.x===r[c-2].x?0:-1,i=t.y>r[c-2].y?1:t.y===r[c-2].y?0:-1),o.push(["L",t.x+s*e,t.y+i*e]),o},sm=(r,e)=>r.map(t=>t.map((n,s)=>s===0||e===void 0?n:te(n,e)).join(" ")).join(" ");function Cc(r,e){const t=r.style;t&&e&&(typeof e=="string"?t.cssText+=";"+e:Object.entries(e).forEach(n=>{let[s,i]=n;return t.setProperty(s,i)}))}class N1 extends Dp{constructor(e){let{allowTouchScrolling:t=!1,containerClass:n=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(e),C(this,"upper",void 0),C(this,"container",void 0);const{el:s}=this.lower,i=this.createUpperCanvas();this.upper={el:i,ctx:i.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:t}),this.applyCanvasStyle(i,{allowTouchScrolling:t,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(n),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,i),this.container=o}createUpperCanvas(){const{el:e}=this.lower,t=lr();return t.className=e.className,t.classList.remove("lower-canvas"),t.classList.add("upper-canvas"),t.setAttribute("data-fabric","top"),t.style.cssText=e.style.cssText,t.setAttribute("draggable","true"),t}createContainerElement(){const e=Gn().createElement("div");return e.setAttribute("data-fabric","wrapper"),Cc(e,{position:"relative"}),dd(e),e}applyCanvasStyle(e,t){const{styles:n,allowTouchScrolling:s}=t;Cc(e,b(b({},n),{},{"touch-action":s?"manipulation":Ke})),dd(e)}setDimensions(e,t){super.setDimensions(e,t);const{el:n,ctx:s}=this.upper;Ep(n,s,e,t)}setCSSDimensions(e){super.setCSSDimensions(e),pc(this.upper.el,e),pc(this.container,e)}cleanupDOM(e){const t=this.container,{el:n}=this.lower,{el:s}=this.upper;super.cleanupDOM(e),t.removeChild(s),t.removeChild(n),t.parentNode&&t.parentNode.replaceChild(n,t)}dispose(){super.dispose(),Wt().dispose(this.upper.el),delete this.upper,delete this.container}}class Ea extends ii{constructor(){super(...arguments),C(this,"targets",[]),C(this,"_hoveredTargets",[]),C(this,"_currentTransform",null),C(this,"_groupSelector",null),C(this,"contextTopDirty",!1)}static getDefaults(){return b(b({},super.getDefaults()),Ea.ownDefaults)}get upperCanvasEl(){var e;return(e=this.elements.upper)===null||e===void 0?void 0:e.el}get contextTop(){var e;return(e=this.elements.upper)===null||e===void 0?void 0:e.ctx}get wrapperEl(){return this.elements.container}initElements(e){this.elements=new N1(e,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(e){this._objectsToRender=void 0,super._onObjectAdded(e)}_onObjectRemoved(e){this._objectsToRender=void 0,e===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[e]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[e]}),e.fire("deselected",{target:e})),e===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(e)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const e=this._activeObject;return!this.preserveObjectStacking&&e?this._objects.filter(t=>!t.group&&t!==e).concat(e):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(e){e.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(e),this.contextTopDirty=!0),e.restore()}renderTop(){const e=this.contextTop;this.clearContext(e),this.renderTopLayer(e),this.fire("after:render",{ctx:e})}setTargetFindTolerance(e){e=Math.round(e),this.targetFindTolerance=e;const t=this.getRetinaScaling(),n=Math.ceil((2*e+1)*t);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=n,this.pixelFindContext.scale(t,t)}isTargetTransparent(e,t,n){const s=this.targetFindTolerance,i=this.pixelFindContext;this.clearContext(i),i.save(),i.translate(-t+s,-n+s),i.transform(...this.viewportTransform);const o=e.selectionBackgroundColor;e.selectionBackgroundColor="",e.render(i),e.selectionBackgroundColor=o,i.restore();const a=Math.round(s*this.getRetinaScaling());return Vx(i,a,a,a)}_isSelectionKeyPressed(e){const t=this.selectionKey;return!!t&&(Array.isArray(t)?!!t.find(n=>!!n&&e[n]===!0):e[t])}_shouldClearSelection(e,t){const n=this.getActiveObjects(),s=this._activeObject;return!!(!t||t&&s&&n.length>1&&n.indexOf(t)===-1&&s!==t&&!this._isSelectionKeyPressed(e)||t&&!t.evented||t&&!t.selectable&&s&&s!==t)}_shouldCenterTransform(e,t,n){if(!e)return;let s;return t===wa||t===Qe||t===gt||t===$s?s=this.centeredScaling||e.centeredScaling:t===bu&&(s=this.centeredRotation||e.centeredRotation),s?!n:n}_getOriginFromCorner(e,t){const n={x:e.originX,y:e.originY};return t&&(["ml","tl","bl"].includes(t)?n.x=fe:["mr","tr","br"].includes(t)&&(n.x=J),["tl","mt","tr"].includes(t)?n.y=gc:["bl","mb","br"].includes(t)&&(n.y=Ge)),n}_setupCurrentTransform(e,t,n){var s;const i=t.group?Ln(this.getScenePoint(e),void 0,t.group.calcTransformMatrix()):this.getScenePoint(e),{key:o="",control:a}=t.getActiveControl()||{},l=n&&a?(s=a.getActionHandler(e,t,a))===null||s===void 0?void 0:s.bind(a):nx,c=((f,m,v,w)=>{if(!m||!f)return"drag";const g=w.controls[m];return g.getActionName(v,g,w)})(n,o,e,t),u=e[this.centeredKey],h=this._shouldCenterTransform(t,c,u)?{x:$,y:$}:this._getOriginFromCorner(t,o),d={target:t,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,offsetX:i.x-t.left,offsetY:i.y-t.top,originX:h.x,originY:h.y,ex:i.x,ey:i.y,lastX:i.x,lastY:i.y,theta:pe(t.angle),width:t.width,height:t.height,shiftKey:e.shiftKey,altKey:u,original:b(b({},Pp(t)),{},{originX:h.x,originY:h.y})};this._currentTransform=d,this.fire("before:transform",{e,transform:d})}setCursor(e){this.upperCanvasEl.style.cursor=e}_drawSelection(e){const{x:t,y:n,deltaX:s,deltaY:i}=this._groupSelector,o=new O(t,n).transform(this.viewportTransform),a=new O(t+s,n+i).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),u=Math.min(o.y,a.y),h=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(e.fillStyle=this.selectionColor,e.fillRect(c,u,h-c,d-u)),this.selectionLineWidth&&this.selectionBorderColor&&(e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor,c+=l,u+=l,h-=l,d-=l,Me.prototype._setLineDash.call(this,e,this.selectionDashArray),e.strokeRect(c,u,h-c,d-u))}findTarget(e){if(this.skipTargetFind)return;const t=this.getViewportPoint(e),n=this._activeObject,s=this.getActiveObjects();if(this.targets=[],n&&s.length>=1){if(n.findControl(t,mc(e))||s.length>1&&this.searchPossibleTargets([n],t))return n;if(n===this.searchPossibleTargets([n],t)){if(this.preserveObjectStacking){const i=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,t);return e[this.altSelectionKey]&&o&&o!==n?(this.targets=i,n):o}return n}}return this.searchPossibleTargets(this._objects,t)}_pointIsInObjectSelectionArea(e,t){let n=e.getCoords();const s=this.getZoom(),i=e.padding/s;if(i){const[o,a,l,c]=n,u=Math.atan2(a.y-o.y,a.x-o.x),h=or(u)*i,d=ar(u)*i,f=h+d,m=h-d;n=[new O(o.x-m,o.y-f),new O(a.x+f,a.y-m),new O(l.x+m,l.y+f),new O(c.x-f,c.y+m)]}return le.isPointInPolygon(t,n)}_checkTarget(e,t){return!!(e&&e.visible&&e.evented&&this._pointIsInObjectSelectionArea(e,Ln(t,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing||!this.isTargetTransparent(e,t.x,t.y)))}_searchPossibleTargets(e,t){let n=e.length;for(;n--;){const s=e[n];if(this._checkTarget(s,t)){if(po(s)&&s.subTargetCheck){const i=this._searchPossibleTargets(s._objects,t);i&&this.targets.push(i)}return s}}}searchPossibleTargets(e,t){const n=this._searchPossibleTargets(e,t);if(n&&po(n)&&n.interactive&&this.targets[0]){const s=this.targets;for(let i=s.length-1;i>0;i--){const o=s[i];if(!po(o)||!o.interactive)return o}return s[0]}return n}getViewportPoint(e){return this._pointer?this._pointer:this.getPointer(e,!0)}getScenePoint(e){return this._absolutePointer?this._absolutePointer:this.getPointer(e)}getPointer(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const n=this.upperCanvasEl,s=n.getBoundingClientRect();let i=q0(e),o=s.width||0,a=s.height||0;o&&a||(Ge in s&&gc in s&&(a=Math.abs(s.top-s.bottom)),fe in s&&J in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),i.x=i.x-this._offset.left,i.y=i.y-this._offset.top,t||(i=Ln(i,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(i.x/=l,i.y/=l);const c=o===0||a===0?new O(1,1):new O(n.width/o,n.height/a);return i.multiply(c)}_setDimensionsImpl(e,t){this._resetTransformEventData(),super._setDimensionsImpl(e,t),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=lr(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const e=this._activeObject;return Xr(e)?e.getObjects():e?[e]:[]}_fireSelectionEvents(e,t){let n=!1,s=!1;const i=this.getActiveObjects(),o=[],a=[];e.forEach(l=>{i.includes(l)||(n=!0,l.fire("deselected",{e:t,target:l}),a.push(l))}),i.forEach(l=>{e.includes(l)||(n=!0,l.fire("selected",{e:t,target:l}),o.push(l))}),e.length>0&&i.length>0?(s=!0,n&&this.fire("selection:updated",{e:t,selected:o,deselected:a})):i.length>0?(s=!0,this.fire("selection:created",{e:t,selected:o})):e.length>0&&(s=!0,this.fire("selection:cleared",{e:t,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(e,t){const n=this.getActiveObjects(),s=this._setActiveObject(e,t);return this._fireSelectionEvents(n,t),s}_setActiveObject(e,t){const n=this._activeObject;return n!==e&&!(!this._discardActiveObject(t,e)&&this._activeObject)&&!e.onSelect({e:t})&&(this._activeObject=e,Xr(e)&&n!==e&&e.set("canvas",this),e.setCoords(),!0)}_discardActiveObject(e,t){const n=this._activeObject;return!!n&&!n.onDeselect({e,object:t})&&(this._currentTransform&&this._currentTransform.target===n&&this.endCurrentTransform(e),Xr(n)&&n===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(e){const t=this.getActiveObjects(),n=this.getActiveObject();t.length&&this.fire("before:selection:cleared",{e,deselected:[n]});const s=this._discardActiveObject(e);return this._fireSelectionEvents(t,e),s}endCurrentTransform(e){const t=this._currentTransform;this._finalizeCurrentTransform(e),t&&t.target&&(t.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(e){const t=this._currentTransform,n=t.target,s={e,target:n,transform:t,action:t.action};n._scaling&&(n._scaling=!1),n.setCoords(),t.actionPerformed&&(this.fire("object:modified",s),n.fire($o,s))}setViewportTransform(e){super.setViewportTransform(e);const t=this._activeObject;t&&t.setCoords()}destroy(){const e=this._activeObject;Xr(e)&&(e.removeAll(),e.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(e){const t=this._activeObject;t&&t._renderControls(e)}_toObject(e,t,n){const s=this._realizeGroupTransformOnObject(e),i=super._toObject(e,t,n);return e.set(s),i}_realizeGroupTransformOnObject(e){const{group:t}=e;if(t&&Xr(t)&&this._activeObject===t){const n=Jn(e,["angle","flipX","flipY",J,Qe,gt,Kn,qn,Ge]);return J0(e,t.calcOwnMatrix()),n}return{}}_setSVGObject(e,t,n){const s=this._realizeGroupTransformOnObject(t);super._setSVGObject(e,t,n),t.set(s)}}C(Ea,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class I1{constructor(e){C(this,"targets",[]),C(this,"__disposer",void 0);const t=()=>{const{hiddenTextarea:s}=e.getActiveObject()||{};s&&s.focus()},n=e.upperCanvasEl;n.addEventListener("click",t),this.__disposer=()=>n.removeEventListener("click",t)}exitTextEditing(){this.target=void 0,this.targets.forEach(e=>{e.isEditing&&e.exitEditing()})}add(e){this.targets.push(e)}remove(e){this.unregister(e),dn(this.targets,e)}register(e){this.target=e}unregister(e){e===this.target&&(this.target=void 0)}onMouseMove(e){var t;!((t=this.target)===null||t===void 0)&&t.isEditing&&this.target.updateSelectionOnMouseMove(e)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const z1=["target","oldTarget","fireCanvas","e"],Je={passive:!1},hn=(r,e)=>{const t=r.getViewportPoint(e),n=r.getScenePoint(e);return{viewportPoint:t,scenePoint:n,pointer:t,absolutePointer:n}},vr=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return r.addEventListener(...t)},it=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return r.removeEventListener(...t)},B1={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class bc extends Ea{constructor(e){super(e,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),C(this,"_isClick",void 0),C(this,"textEditingManager",new I1(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(vr,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(e,t){const n=this.upperCanvasEl,s=this._getEventPrefix();e(Op(n),"resize",this._onResize),e(n,s+"down",this._onMouseDown),e(n,"".concat(s,"move"),this._onMouseMove,Je),e(n,"".concat(s,"out"),this._onMouseOut),e(n,"".concat(s,"enter"),this._onMouseEnter),e(n,"wheel",this._onMouseWheel,{passive:!1}),e(n,"contextmenu",this._onContextMenu),e(n,"click",this._onClick),e(n,"dblclick",this._onClick),e(n,"dragstart",this._onDragStart),e(n,"dragend",this._onDragEnd),e(n,"dragover",this._onDragOver),e(n,"dragenter",this._onDragEnter),e(n,"dragleave",this._onDragLeave),e(n,"drop",this._onDrop),this.enablePointerEvents||e(n,"touchstart",this._onTouchStart,Je)}removeListeners(){this.addOrRemove(it,"remove");const e=this._getEventPrefix(),t=bt(this.upperCanvasEl);it(t,"".concat(e,"up"),this._onMouseUp),it(t,"touchend",this._onTouchEnd,Je),it(t,"".concat(e,"move"),this._onMouseMove,Je),it(t,"touchmove",this._onMouseMove,Je),clearTimeout(this._willAddMouseDown)}_onMouseWheel(e){this.__onMouseWheel(e)}_onMouseOut(e){const t=this._hoveredTarget,n=b({e},hn(this,e));this.fire("mouse:out",b(b({},n),{},{target:t})),this._hoveredTarget=void 0,t&&t.fire("mouseout",b({},n)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",b(b({},n),{},{target:s})),s&&s.fire("mouseout",b({},n))}),this._hoveredTargets=[]}_onMouseEnter(e){this._currentTransform||this.findTarget(e)||(this.fire("mouse:over",b({e},hn(this,e))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(e){this._isClick=!1;const t=this.getActiveObject();if(t&&t.onDragStart(e)){this._dragSource=t;const n={e,target:t};return this.fire("dragstart",n),t.fire("dragstart",n),void vr(this.upperCanvasEl,"drag",this._onDragProgress)}fd(e)}_renderDragEffects(e,t,n){let s=!1;const i=this._dropTarget;i&&i!==t&&i!==n&&(i.clearContextTop(),s=!0),t==null||t.clearContextTop(),n!==t&&(n==null||n.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),t&&(o.save(),t.transform(o),t.renderDragSourceEffect(e),o.restore(),s=!0),n&&(o.save(),n.transform(o),n.renderDropTargetEffect(e),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(e){const t=!!e.dataTransfer&&e.dataTransfer.dropEffect!==Ke,n=t?this._activeObject:void 0,s={e,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:t,dropTarget:n};it(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(e)}_onDragProgress(e){const t={e,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",t),this._dragSource&&this._dragSource.fire("drag",t)}findDragTargets(e){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(e)),targets:[...this.targets]}}_onDragOver(e){const t="dragover",{target:n,targets:s}=this.findDragTargets(e),i=this._dragSource,o={e,target:n,subTargets:s,dragSource:i,canDrop:!1,dropTarget:void 0};let a;this.fire(t,o),this._fireEnterLeaveEvents(n,o),n&&(n.canDrop(e)&&(a=n),n.fire(t,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(e)&&(a=c),c.fire(t,o)}this._renderDragEffects(e,i,a),this._dropTarget=a}_onDragEnter(e){const{target:t,targets:n}=this.findDragTargets(e),s={e,target:t,subTargets:n,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(t,s)}_onDragLeave(e){const t={e,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",t),this._fireEnterLeaveEvents(void 0,t),this._renderDragEffects(e,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(e){const{target:t,targets:n}=this.findDragTargets(e),s=this._basicEventHandler("drop:before",b({e,target:t,subTargets:n,dragSource:this._dragSource},hn(this,e)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(e){const t=this.findTarget(e),n=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e,target:t,subTargets:n});return this.stopContextMenu&&fd(e),this._basicEventHandler("contextmenu",s),!1}_onClick(e){const t=e.detail;t>3||t<2||(this._cacheTransformEventData(e),t==2&&e.type==="dblclick"&&this._handleEvent(e,"dblclick"),t==3&&this._handleEvent(e,"tripleclick"),this._resetTransformEventData())}getPointerId(e){const t=e.changedTouches;return t?t[0]&&t[0].identifier:this.enablePointerEvents?e.pointerId:-1}_isMainEvent(e){return e.isPrimary===!0||e.isPrimary!==!1&&(e.type==="touchend"&&e.touches.length===0||!e.changedTouches||e.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(e){let t=!this.allowTouchScrolling;const n=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(e)),this.__onMouseDown(e),(this.isDrawingMode||n&&this._target===n)&&(t=!0),t&&e.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,i=this._getEventPrefix(),o=bt(s);vr(o,"touchend",this._onTouchEnd,Je),t&&vr(o,"touchmove",this._onMouseMove,Je),it(s,"".concat(i,"down"),this._onMouseDown)}_onMouseDown(e){this.__onMouseDown(e),this._resetTransformEventData();const t=this.upperCanvasEl,n=this._getEventPrefix();it(t,"".concat(n,"move"),this._onMouseMove,Je);const s=bt(t);vr(s,"".concat(n,"up"),this._onMouseUp),vr(s,"".concat(n,"move"),this._onMouseMove,Je)}_onTouchEnd(e){if(e.touches.length>0)return;this.__onMouseUp(e),this._resetTransformEventData(),delete this.mainTouchId;const t=this._getEventPrefix(),n=bt(this.upperCanvasEl);it(n,"touchend",this._onTouchEnd,Je),it(n,"touchmove",this._onMouseMove,Je),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{vr(this.upperCanvasEl,"".concat(t,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(e){this.__onMouseUp(e),this._resetTransformEventData();const t=this.upperCanvasEl,n=this._getEventPrefix();if(this._isMainEvent(e)){const s=bt(this.upperCanvasEl);it(s,"".concat(n,"up"),this._onMouseUp),it(s,"".concat(n,"move"),this._onMouseMove,Je),vr(t,"".concat(n,"move"),this._onMouseMove,Je)}}_onMouseMove(e){const t=this.getActiveObject();!this.allowTouchScrolling&&(!t||!t.shouldStartDragging(e))&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(e){const t=this.getActiveObject();return!!t!=!!e||t&&e&&t!==e}__onMouseUp(e){var t;this._cacheTransformEventData(e),this._handleEvent(e,"up:before");const n=this._currentTransform,s=this._isClick,i=this._target,{button:o}=e;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(e,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(e);if(!this._isMainEvent(e))return;let a,l,c=!1;if(n&&(this._finalizeCurrentTransform(e),c=n.actionPerformed),!s){const u=i===this._activeObject;this.handleSelection(e),c||(c=this._shouldRender(i)||!u&&i===this._activeObject)}if(i){const u=i.findControl(this.getViewportPoint(e),mc(e)),{key:h,control:d}=u||{};if(l=h,i.selectable&&i!==this._activeObject&&i.activeOn==="up")this.setActiveObject(i,e),c=!0;else if(d){const f=d.getMouseUpHandler(e,i,d);f&&(a=this.getScenePoint(e),f.call(d,e,n,a.x,a.y))}i.isMoving=!1}if(n&&(n.target!==i||n.corner!==l)){const u=n.target&&n.target.controls[n.corner],h=u&&u.getMouseUpHandler(e,n.target,u);a=a||this.getScenePoint(e),h&&h.call(u,e,n,a.x,a.y)}this._setCursorFromEvent(e,i),this._handleEvent(e,"up"),this._groupSelector=null,this._currentTransform=null,i&&(i.__corner=void 0),c?this.requestRenderAll():s||(t=this._activeObject)!==null&&t!==void 0&&t.isEditing||this.renderTop()}_basicEventHandler(e,t){const{target:n,subTargets:s=[]}=t;this.fire(e,t),n&&n.fire(e,t);for(let i=0;i<s.length;i++)s[i]!==n&&s[i].fire(e,t);return t}_handleEvent(e,t,n){const s=this._target,i=this.targets||[],o=b(b(b({e,target:s,subTargets:i},hn(this,e)),{},{transform:this._currentTransform},t==="up:before"||t==="up"?{isClick:this._isClick,currentTarget:this.findTarget(e),currentSubTargets:this.targets}:{}),t==="down:before"||t==="down"?n:{});this.fire("mouse:".concat(t),o),s&&s.fire("mouse".concat(t),o);for(let a=0;a<i.length;a++)i[a]!==s&&i[a].fire("mouse".concat(t),o)}_onMouseDownInDrawingMode(e){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(e),this.requestRenderAll());const t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(t,{e,pointer:t}),this._handleEvent(e,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(e){if(this._isCurrentlyDrawing){const t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(t,{e,pointer:t})}this.setCursor(this.freeDrawingCursor),this._handleEvent(e,"move")}_onMouseUpInDrawingMode(e){const t=this.getScenePoint(e);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e,pointer:t}):this._isCurrentlyDrawing=!1,this._handleEvent(e,"up")}__onMouseDown(e){this._isClick=!0,this._cacheTransformEventData(e),this._handleEvent(e,"down:before");let t=this._target,n=!!t&&t===this._activeObject;const{button:s}=e;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(e,"down",{alreadySelected:n}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(e);if(!this._isMainEvent(e)||this._currentTransform)return;let i=this._shouldRender(t),o=!1;if(this.handleMultiSelection(e,t)?(t=this._activeObject,o=!0,i=!0):this._shouldClearSelection(e,t)&&this.discardActiveObject(e),this.selection&&(!t||!t.selectable&&!t.isEditing&&t!==this._activeObject)){const a=this.getScenePoint(e);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(n=!!t&&t===this._activeObject,t){t.selectable&&t.activeOn==="down"&&this.setActiveObject(t,e);const a=t.findControl(this.getViewportPoint(e),mc(e));if(t===this._activeObject&&(a||!o)){this._setupCurrentTransform(e,t,n);const l=a?a.control:void 0,c=this.getScenePoint(e),u=l&&l.getMouseDownHandler(e,t,l);u&&u.call(l,e,this._currentTransform,c.x,c.y)}}i&&(this._objectsToRender=void 0),this._handleEvent(e,"down",{alreadySelected:n}),i&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(e){this._resetTransformEventData(),this._pointer=this.getViewportPoint(e),this._absolutePointer=Ln(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(e)}__onMouseMove(e){if(this._isClick=!1,this._cacheTransformEventData(e),this._handleEvent(e,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(e);if(!this._isMainEvent(e))return;const t=this._groupSelector;if(t){const n=this.getScenePoint(e);t.deltaX=n.x-t.x,t.deltaY=n.y-t.y,this.renderTop()}else if(this._currentTransform)this._transformObject(e);else{const n=this.findTarget(e);this._setCursorFromEvent(e,n),this._fireOverOutEvents(e,n)}this.textEditingManager.onMouseMove(e),this._handleEvent(e,"move"),this._resetTransformEventData()}_fireOverOutEvents(e,t){const n=this._hoveredTarget,s=this._hoveredTargets,i=this.targets,o=Math.max(s.length,i.length);this.fireSyntheticInOutEvents("mouse",{e,target:t,oldTarget:n,fireCanvas:!0});for(let a=0;a<o;a++)i[a]===t||s[a]&&s[a]===n||this.fireSyntheticInOutEvents("mouse",{e,target:i[a],oldTarget:s[a]});this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(e,t){const n=this._draggedoverTarget,s=this._hoveredTargets,i=this.targets,o=Math.max(s.length,i.length);this.fireSyntheticInOutEvents("drag",b(b({},t),{},{target:e,oldTarget:n,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",b(b({},t),{},{target:i[a],oldTarget:s[a]}));this._draggedoverTarget=e}fireSyntheticInOutEvents(e,t){let{target:n,oldTarget:s,fireCanvas:i,e:o}=t,a=ie(t,z1);const{targetIn:l,targetOut:c,canvasIn:u,canvasOut:h}=B1[e],d=s!==n;if(s&&d){const f=b(b({},a),{},{e:o,target:s,nextTarget:n},hn(this,o));i&&this.fire(h,f),s.fire(c,f)}if(n&&d){const f=b(b({},a),{},{e:o,target:n,previousTarget:s},hn(this,o));i&&this.fire(u,f),n.fire(l,f)}}__onMouseWheel(e){this._cacheTransformEventData(e),this._handleEvent(e,"wheel"),this._resetTransformEventData()}_transformObject(e){const t=this.getScenePoint(e),n=this._currentTransform,s=n.target,i=s.group?Ln(t,void 0,s.group.calcTransformMatrix()):t;n.shiftKey=e.shiftKey,n.altKey=!!this.centeredKey&&e[this.centeredKey],this._performTransformAction(e,n,i),n.actionPerformed&&this.requestRenderAll()}_performTransformAction(e,t,n){const{action:s,actionHandler:i,target:o}=t,a=!!i&&i(e,t,n.x,n.y);a&&o.setCoords(),s==="drag"&&a&&(t.target.isMoving=!0,this.setCursor(t.target.moveCursor||this.moveCursor)),t.actionPerformed=t.actionPerformed||a}_setCursorFromEvent(e,t){if(!t)return void this.setCursor(this.defaultCursor);let n=t.hoverCursor||this.hoverCursor;const s=Xr(this._activeObject)?this._activeObject:null,i=(!s||t.group!==s)&&t.findControl(this.getViewportPoint(e));if(i){const o=i.control;this.setCursor(o.cursorStyleHandler(e,o,t))}else t.subTargetCheck&&this.targets.concat().reverse().map(o=>{n=o.hoverCursor||n}),this.setCursor(n)}handleMultiSelection(e,t){const n=this._activeObject,s=Xr(n);if(n&&this._isSelectionKeyPressed(e)&&this.selection&&t&&t.selectable&&(n!==t||s)&&(s||!t.isDescendantOf(n)&&!n.isDescendantOf(t))&&!t.onSelect({e})&&!n.getActiveControl()){if(s){const i=n.getObjects();if(t===n){const o=this.getViewportPoint(e);if(!(t=this.searchPossibleTargets(i,o)||this.searchPossibleTargets(this._objects,o))||!t.selectable)return!1}t.group===n?(n.remove(t),this._hoveredTarget=t,this._hoveredTargets=[...this.targets],n.size()===1&&this._setActiveObject(n.item(0),e)):(n.multiSelectAdd(t),this._hoveredTarget=n,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(i,e)}else{n.isEditing&&n.exitEditing();const i=new(W.getClass("ActiveSelection"))([],{canvas:this});i.multiSelectAdd(n,t),this._hoveredTarget=i,this._setActiveObject(i,e),this._fireSelectionEvents([n],e)}return!0}return!1}handleSelection(e){if(!this.selection||!this._groupSelector)return!1;const{x:t,y:n,deltaX:s,deltaY:i}=this._groupSelector,o=new O(t,n),a=o.add(new O(s,i)),l=o.min(a),c=o.max(a).subtract(l),u=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),h=o.eq(a)?u[0]?[u[0]]:[]:u.length>1?u.filter(d=>!d.onSelect({e})).reverse():u;if(h.length===1)this.setActiveObject(h[0],e);else if(h.length>1){const d=W.getClass("ActiveSelection");this.setActiveObject(new d(h,{canvas:this}),e)}return this._groupSelector=null,!0}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;const{upper:n}=this.elements;n.ctx=void 0;const s=super.toCanvasElement(e,t);return n.ctx=n.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const im={x1:0,y1:0,x2:0,y2:0},V1=b(b({},im),{},{r1:0,r2:0}),kn=(r,e)=>isNaN(r)&&typeof e=="number"?e:r;function om(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function am(r,e){const t=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(om(r)?100:1):NaN;return Xn(0,kn(t,e),1)}const W1=/\s*;\s*/,H1=/\s*:\s*/;function X1(r,e){let t,n;const s=r.getAttribute("style");if(s){const o=s.split(W1);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(H1).map(u=>u.trim());l==="stop-color"?t=c:l==="stop-opacity"&&(n=c)}}const i=new Q(t||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:am(r.getAttribute("offset"),0),color:i.toRgb(),opacity:kn(parseFloat(n||r.getAttribute("stop-opacity")||""),1)*i.getAlpha()*e}}function U1(r,e){const t=[],n=r.getElementsByTagName("stop"),s=am(e,1);for(let i=n.length;i--;)t.push(X1(n[i],s));return t}function lm(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function cm(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function vt(r,e){return r.getAttribute(e)}function $1(r,e){return function(t,n){let s,{width:i,height:o,gradientUnits:a}=n;return Object.entries(t).reduce((l,c)=>{let[u,h]=c;if(h==="Infinity")s=1;else if(h==="-Infinity")s=0;else{const d=typeof h=="string";s=d?parseFloat(h):h,d&&om(h)&&(s*=.01,a==="pixels"&&(u!=="x1"&&u!=="x2"&&u!=="r2"||(s*=i),u!=="y1"&&u!=="y2"||(s*=o)))}return l[u]=s,l},{})}(lm(r)==="linear"?function(t){return{x1:vt(t,"x1")||0,y1:vt(t,"y1")||0,x2:vt(t,"x2")||"100%",y2:vt(t,"y2")||0}}(r):function(t){return{x1:vt(t,"fx")||vt(t,"cx")||"50%",y1:vt(t,"fy")||vt(t,"cy")||"50%",r1:0,x2:vt(t,"cx")||"50%",y2:vt(t,"cy")||"50%",r2:vt(t,"r")||"50%"}}(r),b(b({},e),{},{gradientUnits:cm(r)}))}class Di{constructor(e){const{type:t="linear",gradientUnits:n="pixels",coords:s={},colorStops:i=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=e||{};Object.assign(this,{type:t,gradientUnits:n,coords:b(b({},t==="radial"?V1:im),s),colorStops:i,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Nr()):Nr()})}addColorStop(e){for(const t in e){const n=new Q(e[t]);this.colorStops.push({offset:parseFloat(t),color:n.toRgb(),opacity:n.getAlpha()})}return this}toObject(e){return b(b({},Jn(this,e)),{},{type:this.type,coords:b({},this.coords),colorStops:this.colorStops.map(t=>b({},t)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(e){let{additionalTransform:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[],s=this.gradientTransform?this.gradientTransform.concat():ze.concat(),i=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(h=>b({},h)).sort((h,d)=>h.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;i==="objectBoundingBox"?(a/=e.width,l/=e.height):(a+=e.width/2,l+=e.height/2),(c=e)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=e.pathOffset.x,l-=e.pathOffset.y),s[4]-=a,s[5]-=l;const u=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(i,'"'),'gradientTransform="'.concat(t?t+" ":"").concat(Gs(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:h,y1:d,x2:f,y2:m}=this.coords;n.push("<linearGradient ",u,' x1="',h,'" y1="',d,'" x2="',f,'" y2="',m,`">
81
- `)}else if(this.type==="radial"){const{x1:h,y1:d,x2:f,y2:m,r1:v,r2:w}=this.coords,g=v>w;n.push("<radialGradient ",u,' cx="',g?h:f,'" cy="',g?d:m,'" r="',g?v:w,'" fx="',g?f:h,'" fy="',g?m:d,`">
82
- `),g&&(o.reverse(),o.forEach(y=>{y.offset=1-y.offset}));const p=Math.min(v,w);if(p>0){const y=p/Math.max(v,w);o.forEach(x=>{x.offset+=y*(1-x.offset)})}}return o.forEach(h=>{let{color:d,offset:f,opacity:m}=h;n.push("<stop ",'offset="',100*f+"%",'" style="stop-color:',d,m!==void 0?";stop-opacity: "+m:";",`"/>
83
- `)}),n.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
84
- `),n.join("")}toLive(e){const{x1:t,y1:n,x2:s,y2:i,r1:o,r2:a}=this.coords,l=this.type==="linear"?e.createLinearGradient(t,n,s,i):e.createRadialGradient(t,n,o,s,i,a);return this.colorStops.forEach(c=>{let{color:u,opacity:h,offset:d}=c;l.addColorStop(d,h!==void 0?new Q(u).setAlpha(h).toRgba():u)}),l}static async fromObject(e){const{colorStops:t,gradientTransform:n}=e;return new this(b(b({},e),{},{colorStops:t?t.map(s=>b({},s)):void 0,gradientTransform:n?[...n]:void 0}))}static fromElement(e,t,n){const s=cm(e),i=t._findCenterFromElement();return new this(b({id:e.getAttribute("id")||void 0,type:lm(e),coords:$1(e,{width:n.viewBoxWidth||n.width,height:n.viewBoxHeight||n.height}),colorStops:U1(e,n.opacity),gradientUnits:s,gradientTransform:_c(e.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:t.width/2-i.x,offsetY:t.height/2-i.y}:{offsetX:0,offsetY:0}))}}C(Di,"type","Gradient"),W.setClass(Di,"gradient"),W.setClass(Di,"linear"),W.setClass(Di,"radial");const Y1=["type","source","patternTransform"];class dl{get type(){return"pattern"}set type(e){Rr("warn","Setting type has no effect",e)}constructor(e){C(this,"repeat","repeat"),C(this,"offsetX",0),C(this,"offsetY",0),C(this,"crossOrigin",""),this.id=Nr(),Object.assign(this,e)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(e){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?e.createPattern(this.source,this.repeat):null}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:t,crossOrigin:n}=this;return b(b({},Jn(this,e)),{},{type:"pattern",source:this.sourceToString(),repeat:t,crossOrigin:n,offsetX:te(this.offsetX,q.NUM_FRACTION_DIGITS),offsetY:te(this.offsetY,q.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(e){let{width:t,height:n}=e;const{source:s,repeat:i,id:o}=this,a=kn(this.offsetX/t,0),l=kn(this.offsetY/n,0),c=i==="repeat-y"||i==="no-repeat"?1+Math.abs(a||0):kn(s.width/t,0),u=i==="repeat-x"||i==="no-repeat"?1+Math.abs(l||0):kn(s.height/n,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(u,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
85
- `)}static async fromObject(e,t){let{type:n,source:s,patternTransform:i}=e,o=ie(e,Y1);const a=await vo(s,b(b({},t),{},{crossOrigin:o.crossOrigin}));return new this(b(b({},o),{},{patternTransform:i&&i.slice(0),source:a}))}}C(dl,"type","Pattern"),W.setClass(dl),W.setClass(dl,"pattern");class G1{constructor(e){C(this,"color","rgb(0, 0, 0)"),C(this,"width",1),C(this,"shadow",null),C(this,"strokeLineCap","round"),C(this,"strokeLineJoin","round"),C(this,"strokeMiterLimit",10),C(this,"strokeDashArray",null),C(this,"limitedToCanvasSize",!1),this.canvas=e}_setBrushStyles(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeDashArray||[])}_saveAndTransform(e){const t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new Q(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const e=this.canvas,t=this.shadow,n=e.contextTop,s=e.getZoom()*e.getRetinaScaling();n.shadowColor=t.color,n.shadowBlur=t.blur*s,n.shadowOffsetX=t.offsetX*s,n.shadowOffsetY=t.offsetY*s}_resetShadow(){const e=this.canvas.contextTop;e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}_isOutSideCanvas(e){return e.x<0||e.x>this.canvas.getWidth()||e.y<0||e.y>this.canvas.getHeight()}}const K1=["path","left","top"],q1=["d"];class Sr extends Me{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:n,left:s,top:i}=t,o=ie(t,K1);super(),Object.assign(this,Sr.ownDefaults),this.setOptions(o),this._setPath(e||[],!0),typeof s=="number"&&this.set(J,s),typeof i=="number"&&this.set(Ge,i)}_setPath(e,t){this.path=k1(Array.isArray(e)?e:F1(e)),this.setBoundingBox(t)}_findCenterFromElement(){const e=this._calcBoundsFromPath();return new O(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){const t=-this.pathOffset.x,n=-this.pathOffset.y;e.beginPath();for(const s of this.path)switch(s[0]){case"L":e.lineTo(s[1]+t,s[2]+n);break;case"M":e.moveTo(s[1]+t,s[2]+n);break;case"C":e.bezierCurveTo(s[1]+t,s[2]+n,s[3]+t,s[4]+n,s[5]+t,s[6]+n);break;case"Q":e.quadraticCurveTo(s[1]+t,s[2]+n,s[3]+t,s[4]+n);break;case"Z":e.closePath()}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(e)),{},{path:this.path.map(t=>t.slice())})}toDatalessObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){const e=sm(this.path,q.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(e,`" stroke-linecap="round" />
86
- `)]}_getOffsetTransform(){const e=q.NUM_FRACTION_DIGITS;return" translate(".concat(te(-this.pathOffset.x,e),", ").concat(te(-this.pathOffset.y,e),")")}toClipPathSVG(e){const t=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){const t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){const{width:t,height:n,pathOffset:s}=this._calcDimensions();this.set({width:t,height:n,pathOffset:s}),e&&this.setPositionByOrigin(s,$,$)}_calcBoundsFromPath(){const e=[];let t=0,n=0,s=0,i=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],i=o[2],e.push({x:t,y:n},{x:s,y:i});break;case"M":s=o[1],i=o[2],t=s,n=i;break;case"C":e.push(...zd(s,i,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],i=o[6];break;case"Q":e.push(...zd(s,i,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],i=o[4];break;case"Z":s=t,i=n}return tr(e)}_calcDimensions(){const e=this._calcBoundsFromPath();return b(b({},e),{},{pathOffset:new O(e.left+e.width/2,e.top+e.height/2)})}static fromObject(e){return this._fromObject(e,{extraParam:"path"})}static async fromElement(e,t,n){const s=dr(e,this.ATTRIBUTE_NAMES,n),{d:i}=s;return new this(i,b(b(b({},ie(s,q1)),t),{},{left:void 0,top:void 0}))}}C(Sr,"type","Path"),C(Sr,"cacheProperties",[...hr,"path","fillRule"]),C(Sr,"ATTRIBUTE_NAMES",[...Vr,"d"]),W.setClass(Sr),W.setSVGClass(Sr);class ra extends G1{constructor(e){super(e),C(this,"decimate",.4),C(this,"drawStraightLine",!1),C(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(e,t,n){const s=t.midPointFrom(n);return e.quadraticCurveTo(t.x,t.y,s.x,s.y),s}onMouseDown(e,t){let{e:n}=t;this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],this._prepareForDrawing(e),this._addPoint(e),this._render())}onMouseMove(e,t){let{e:n}=t;if(this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(e))&&this._addPoint(e)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const s=this._points,i=s.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=ra.drawSegment(o,s[i-2],s[i-1]),o.stroke(),o.restore()}}onMouseUp(e){let{e:t}=e;return!this.canvas._isMainEvent(t)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(e){this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)}_addPoint(e){return!(this._points.length>1&&e.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(e),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,t=this._points[0],n=this._points[1];if(this._saveAndTransform(e),e.beginPath(),this._points.length===2&&t.x===n.x&&t.y===n.y){const s=this.width/1e3;t.x-=s,n.x+=s}e.moveTo(t.x,t.y);for(let s=1;s<this._points.length;s++)ra.drawSegment(e,t,n),t=this._points[s],n=this._points[s+1];e.lineTo(t.x,t.y),e.stroke(),e.restore()}convertPointsToSVGPath(e){const t=this.width/1e3;return R1(e,t)}createPath(e){const t=new Sr(e,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,t.shadow=new Vt(this.shadow)),t}decimatePoints(e,t){if(e.length<=2)return e;let n,s=e[0];const i=this.canvas.getZoom(),o=Math.pow(t/i,2),a=e.length-1,l=[s];for(let c=1;c<a-1;c++)n=Math.pow(s.x-e[c].x,2)+Math.pow(s.y-e[c].y,2),n>=o&&(s=e[c],l.push(s));return l.push(e[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const e=this.convertPointsToSVGPath(this._points);if(function(n){return sm(n)==="M 0 0 Q 0 0 0 0 L 0 0"}(e))return void this.canvas.requestRenderAll();const t=this.createPath(e);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:t}),this.canvas.add(t),this.canvas.requestRenderAll(),t.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:t})}}const Q1=["left","top","radius"],um=["radius","startAngle","endAngle","counterClockwise"];class Lt extends Me{static getDefaults(){return b(b({},super.getDefaults()),Lt.ownDefaults)}constructor(e){super(),Object.assign(this,Lt.ownDefaults),this.setOptions(e)}_set(e,t){return super._set(e,t),e==="radius"&&this.setRadius(t),this}_render(e){e.beginPath(),e.arc(0,0,this.radius,pe(this.startAngle),pe(this.endAngle),this.counterClockwise),this._renderPaintInOrder(e)}getRadiusX(){return this.get("radius")*this.get(Qe)}getRadiusY(){return this.get("radius")*this.get(gt)}setRadius(e){this.radius=e,this.set({width:2*e,height:2*e})}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...um,...e])}_toSVG(){const e=(this.endAngle-this.startAngle)%360;if(e===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
87
- `];{const{radius:t}=this,n=pe(this.startAngle),s=pe(this.endAngle),i=or(n)*t,o=ar(n)*t,a=or(s)*t,l=ar(s)*t,c=e>180?1:0,u=this.counterClockwise?0:1;return['<path d="M '.concat(i," ").concat(o," A ").concat(t," ").concat(t," 0 ").concat(c," ").concat(u," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
88
- `]}}static async fromElement(e,t,n){const s=dr(e,this.ATTRIBUTE_NAMES,n),{left:i=0,top:o=0,radius:a=0}=s;return new this(b(b({},ie(s,Q1)),{},{radius:a,left:i-a,top:o-a}))}static fromObject(e){return super._fromObject(e)}}C(Lt,"type","Circle"),C(Lt,"cacheProperties",[...hr,...um]),C(Lt,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),C(Lt,"ATTRIBUTE_NAMES",["cx","cy","r",...Vr]),W.setClass(Lt),W.setSVGClass(Lt);const J1=["x1","y1","x2","y2"],Z1=["x1","y1","x2","y2"],Tc=["x1","x2","y1","y2"];class Nt extends Me{constructor(){let[e,t,n,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Nt.ownDefaults),this.setOptions(i),this.x1=e,this.x2=n,this.y1=t,this.y2=s,this._setWidthHeight();const{left:o,top:a}=i;typeof o=="number"&&this.set(J,o),typeof a=="number"&&this.set(Ge,a)}_setWidthHeight(){const{x1:e,y1:t,x2:n,y2:s}=this;this.width=Math.abs(n-e),this.height=Math.abs(s-t);const{left:i,top:o,width:a,height:l}=tr([{x:e,y:t},{x:n,y:s}]),c=new O(i+a/2,o+l/2);this.setPositionByOrigin(c,$,$)}_set(e,t){return super._set(e,t),Tc.includes(e)&&this._setWidthHeight(),this}_render(e){e.beginPath();const t=this.calcLinePoints();e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.lineWidth=this.strokeWidth;const n=e.strokeStyle;var s;ct(this.stroke)?e.strokeStyle=this.stroke.toLive(e):e.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=n}_findCenterFromElement(){return new O((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(e)),this.calcLinePoints())}_getNonTransformedDimensions(){const e=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e}calcLinePoints(){const{x1:e,x2:t,y1:n,y2:s,width:i,height:o}=this,a=e<=t?-1:1,l=n<=s?-1:1;return{x1:a*i/2,x2:a*-i/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:e,x2:t,y1:n,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(e,'" y1="').concat(n,'" x2="').concat(t,'" y2="').concat(s,`" />
89
- `)]}static async fromElement(e,t,n){const s=dr(e,this.ATTRIBUTE_NAMES,n),{x1:i=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([i,o,a,l],ie(s,J1))}static fromObject(e){let{x1:t,y1:n,x2:s,y2:i}=e,o=ie(e,Z1);return this._fromObject(b(b({},o),{},{points:[t,n,s,i]}),{extraParam:"points"})}}C(Nt,"type","Line"),C(Nt,"cacheProperties",[...hr,...Tc]),C(Nt,"ATTRIBUTE_NAMES",Vr.concat(Tc)),W.setClass(Nt),W.setSVGClass(Nt);class Gr extends Me{static getDefaults(){return b(b({},super.getDefaults()),Gr.ownDefaults)}constructor(e){super(),Object.assign(this,Gr.ownDefaults),this.setOptions(e)}_render(e){const t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderPaintInOrder(e)}_toSVG(){const e=this.width/2,t=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-e," ").concat(t,",0 ").concat(-t,",").concat(e," ").concat(t),'" />']}}C(Gr,"type","Triangle"),C(Gr,"ownDefaults",{width:100,height:100}),W.setClass(Gr),W.setSVGClass(Gr);const hm=["rx","ry"];class Gt extends Me{static getDefaults(){return b(b({},super.getDefaults()),Gt.ownDefaults)}constructor(e){super(),Object.assign(this,Gt.ownDefaults),this.setOptions(e)}_set(e,t){switch(super._set(e,t),e){case"rx":this.rx=t,this.set("width",2*t);break;case"ry":this.ry=t,this.set("height",2*t)}return this}getRx(){return this.get("rx")*this.get(Qe)}getRy(){return this.get("ry")*this.get(gt)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...hm,...e])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
90
- `)]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,Xo,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,n){const s=dr(e,this.ATTRIBUTE_NAMES,n);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function e_(r){if(!r)return[];const e=r.replace(/,/g," ").trim().split(/\s+/),t=[];for(let n=0;n<e.length;n+=2)t.push({x:parseFloat(e[n]),y:parseFloat(e[n+1])});return t}C(Gt,"type","Ellipse"),C(Gt,"cacheProperties",[...hr,...hm]),C(Gt,"ownDefaults",{rx:0,ry:0}),C(Gt,"ATTRIBUTE_NAMES",[...Vr,"cx","cy","rx","ry"]),W.setClass(Gt),W.setSVGClass(Gt);const t_=["left","top"],dm={exactBoundingBox:!1};class wt extends Me{static getDefaults(){return b(b({},super.getDefaults()),wt.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),C(this,"strokeDiff",void 0),Object.assign(this,wt.ownDefaults),this.setOptions(t),this.points=e;const{left:n,top:s}=t;this.initialized=!0,this.setBoundingBox(!0),typeof n=="number"&&this.set(J,n),typeof s=="number"&&this.set(Ge,s)}isOpen(){return!0}_projectStrokeOnPoints(e){return Hx(this.points,e,this.isOpen())}_calcDimensions(e){e=b({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},e||{});const t=this.exactBoundingBox?this._projectStrokeOnPoints(e).map(c=>c.projectedPoint):this.points;if(t.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new O,strokeOffset:new O,strokeDiff:new O};const n=tr(t),s=Sa(b(b({},e),{},{scaleX:1,scaleY:1})),i=tr(this.points.map(c=>We(c,s,!0))),o=new O(this.scaleX,this.scaleY);let a=n.left+n.width/2,l=n.top+n.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(pe(this.skewX)),l-=a*Math.tan(pe(this.skewY))),b(b({},n),{},{pathOffset:new O(a,l),strokeOffset:new O(i.left,i.top).subtract(new O(n.left,n.top)).multiply(o),strokeDiff:new O(n.width,n.height).subtract(new O(i.width,i.height)).multiply(o)})}_findCenterFromElement(){const e=tr(this.points);return new O(e.left+e.width/2,e.top+e.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(e){const{left:t,top:n,width:s,height:i,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:i,pathOffset:o,strokeOffset:a,strokeDiff:l}),e&&this.setPositionByOrigin(new O(t+s/2,n+i/2),$,$)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new O(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(e).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var t,n;const{width:a,height:l}=this._calcDimensions(e);o=new O((t=e.width)!==null&&t!==void 0?t:a,(n=e.height)!==null&&n!==void 0?n:l)}else{var s,i;o=new O((s=e.width)!==null&&s!==void 0?s:this.width,(i=e.height)!==null&&i!==void 0?i:this.height)}return o.multiply(new O(e.scaleX||this.scaleX,e.scaleY||this.scaleY))}return super._getTransformedDimensions(e)}_set(e,t){const n=this.initialized&&this[e]!==t,s=super._set(e,t);return this.exactBoundingBox&&n&&((e===Qe||e===gt)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(e))&&this.setDimensions(),s}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(e)),{},{points:this.points.map(t=>{let{x:n,y:s}=t;return{x:n,y:s}})})}_toSVG(){const e=[],t=this.pathOffset.x,n=this.pathOffset.y,s=q.NUM_FRACTION_DIGITS;for(let i=0,o=this.points.length;i<o;i++)e.push(te(this.points[i].x-t,s),",",te(this.points[i].y-n,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(e.join(""),`" />
91
- `)]}_render(e){const t=this.points.length,n=this.pathOffset.x,s=this.pathOffset.y;if(t&&!isNaN(this.points[t-1].y)){e.beginPath(),e.moveTo(this.points[0].x-n,this.points[0].y-s);for(let i=0;i<t;i++){const o=this.points[i];e.lineTo(o.x-n,o.y-s)}!this.isOpen()&&e.closePath(),this._renderPaintInOrder(e)}}complexity(){return this.points.length}static async fromElement(e,t,n){return new this(e_(e.getAttribute("points")),b(b({},ie(dr(e,this.ATTRIBUTE_NAMES,n),t_)),t))}static fromObject(e){return this._fromObject(e,{extraParam:"points"})}}C(wt,"ownDefaults",dm),C(wt,"type","Polyline"),C(wt,"layoutProperties",[Kn,qn,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),C(wt,"cacheProperties",[...hr,"points"]),C(wt,"ATTRIBUTE_NAMES",[...Vr]),W.setClass(wt),W.setSVGClass(wt);class Pi extends wt{isOpen(){return!1}}C(Pi,"ownDefaults",dm),C(Pi,"type","Polygon"),W.setClass(Pi),W.setSVGClass(Pi);class fm extends Me{isEmptyStyles(e){if(!this.styles||e!==void 0&&!this.styles[e])return!0;const t=e===void 0?this.styles:{line:this.styles[e]};for(const n in t)for(const s in t[n])for(const i in t[n][s])return!1;return!0}styleHas(e,t){if(!this.styles||t!==void 0&&!this.styles[t])return!1;const n=t===void 0?this.styles:{0:this.styles[t]};for(const s in n)for(const i in n[s])if(n[s][i][e]!==void 0)return!0;return!1}cleanStyle(e){if(!this.styles)return!1;const t=this.styles;let n,s,i=0,o=!0,a=0;for(const l in t){n=0;for(const c in t[l]){const u=t[l][c]||{};i++,u[e]!==void 0?(s?u[e]!==s&&(o=!1):s=u[e],u[e]===this[e]&&delete u[e]):o=!1,Object.keys(u).length!==0?n++:delete t[l][c]}n===0&&delete t[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&i===a&&(this[e]=s,this.removeStyle(e))}removeStyle(e){if(!this.styles)return;const t=this.styles;let n,s,i;for(s in t){for(i in n=t[s],n)delete n[i][e],Object.keys(n[i]).length===0&&delete n[i];Object.keys(n).length===0&&delete t[s]}}_extendStyles(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e);this._getLineStyle(n)||this._setLineStyle(n);const i=Eu(b(b({},this._getStyleDeclaration(n,s)),t),o=>o!==void 0);this._setStyleDeclaration(n,s,i)}getSelectionStyles(e,t,n){const s=[];for(let i=e;i<(t||e);i++)s.push(this.getStyleAtPosition(i,n));return s}getStyleAtPosition(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e);return t?this.getCompleteStyleDeclaration(n,s):this._getStyleDeclaration(n,s)}setSelectionStyles(e,t,n){for(let s=t;s<(n||t);s++)this._extendStyles(s,e);this._forceClearCache=!0}_getStyleDeclaration(e,t){var n;const s=this.styles&&this.styles[e];return s&&(n=s[t])!==null&&n!==void 0?n:{}}getCompleteStyleDeclaration(e,t){return b(b({},Jn(this,this.constructor._styleProperties)),this._getStyleDeclaration(e,t))}_setStyleDeclaration(e,t,n){this.styles[e][t]=n}_deleteStyleDeclaration(e,t){delete this.styles[e][t]}_getLineStyle(e){return!!this.styles[e]}_setLineStyle(e){this.styles[e]={}}_deleteLineStyle(e){delete this.styles[e]}}C(fm,"_styleProperties",ix);const r_=/ +/g,n_=/"/g;function fl(r,e,t,n,s){return" ".concat(function(i,o){let{left:a,top:l,width:c,height:u}=o,h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:q.NUM_FRACTION_DIGITS;const d=Ks(_e,i,!1),[f,m,v,w]=[a,l,c,u].map(g=>te(g,h));return"<rect ".concat(d,' x="').concat(f,'" y="').concat(m,'" width="').concat(v,'" height="').concat(w,'"></rect>')}(r,{left:e,top:t,width:n,height:s}),`
92
- `)}const s_=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let gl;class Fe extends fm{static getDefaults(){return b(b({},super.getDefaults()),Fe.ownDefaults)}constructor(e,t){super(),C(this,"__charBounds",[]),Object.assign(this,Fe.ownDefaults),this.setOptions(t),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const e=this.path;e&&(e.segmentsInfo=nm(e.path))}_splitText(){const e=this._splitTextIntoLines(this.text);return this.textLines=e.lines,this._textLines=e.graphemeLines,this._unwrappedTextLines=e._unwrappedLines,this._text=e.graphemeText,e}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Rt)&&this.enlargeSpaces()}enlargeSpaces(){let e,t,n,s,i,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Rt||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,i=this._textLines[l],t=this.getLineWidth(l),t<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){n=a.length,e=(this.width-t)/n;for(let u=0;u<=i.length;u++)o=this.__charBounds[l][u],this._reSpaceAndTab.test(i[u])?(o.width+=e,o.kernedWidth+=e,o.left+=s,s+=e):o.left+=s}}isEndOfWrapping(e){return e===this._textLines.length-1}missingNewlineOffset(e){return 1}get2DCursorLocation(e,t){const n=t?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<n.length;s++){if(e<=n[s].length)return{lineIndex:s,charIndex:e};e-=n[s].length+this.missingNewlineOffset(s,t)}return{lineIndex:s-1,charIndex:n[s-1].length<e?n[s-1].length:e}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const e=super._getCacheCanvasDimensions(),t=this.fontSize;return e.width+=t*e.zoomX,e.height+=t*e.zoomY,e}_render(e){const t=this.path;t&&!t.isNotVisible()&&t._render(e),this._setTextStyles(e),this._renderTextLinesBackground(e),this._renderTextDecoration(e,"underline"),this._renderText(e),this._renderTextDecoration(e,"overline"),this._renderTextDecoration(e,"linethrough")}_renderText(e){this.paintFirst===qe?(this._renderTextStroke(e),this._renderTextFill(e)):(this._renderTextFill(e),this._renderTextStroke(e))}_setTextStyles(e,t,n){if(e.textBaseline="alphabetic",this.path)switch(this.pathAlign){case $:e.textBaseline="middle";break;case"ascender":e.textBaseline=Ge;break;case"descender":e.textBaseline=gc}e.font=this._getFontDeclaration(t,n)}calcTextWidth(){let e=this.getLineWidth(0);for(let t=1,n=this._textLines.length;t<n;t++){const s=this.getLineWidth(t);s>e&&(e=s)}return e}_renderTextLine(e,t,n,s,i,o){this._renderChars(e,t,n,s,i,o)}_renderTextLinesBackground(e){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const t=e.fillStyle,n=this._getLeftOffset();let s=this._getTopOffset();for(let i=0,o=this._textLines.length;i<o;i++){const a=this.getHeightOfLine(i);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",i)){s+=a;continue}const l=this._textLines[i].length,c=this._getLineLeftOffset(i);let u,h,d=0,f=0,m=this.getValueOfPropertyAt(i,0,"textBackgroundColor");const v=this.getHeightOfLineImpl(i);for(let w=0;w<l;w++){const g=this.__charBounds[i][w];h=this.getValueOfPropertyAt(i,w,"textBackgroundColor"),this.path?(e.save(),e.translate(g.renderLeft,g.renderTop),e.rotate(g.angle),e.fillStyle=h,h&&e.fillRect(-g.width/2,-v*(1-this._fontSizeFraction),g.width,v),e.restore()):h!==m?(u=n+c+f,this.direction==="rtl"&&(u=this.width-u-d),e.fillStyle=m,m&&e.fillRect(u,s,d,v),f=g.left,d=g.width,m=h):d+=g.kernedWidth}h&&!this.path&&(u=n+c+f,this.direction==="rtl"&&(u=this.width-u-d),e.fillStyle=h,e.fillRect(u,s,d,v)),s+=a}e.fillStyle=t,this._removeShadow(e)}_measureChar(e,t,n,s){const i=Ts.getFontCache(t),o=this._getFontDeclaration(t),a=n?n+e:e,l=n&&o===this._getFontDeclaration(s),c=t.fontSize/this.CACHE_FONT_SIZE;let u,h,d,f;if(n&&i.has(n)&&(d=i.get(n)),i.has(e)&&(f=u=i.get(e)),l&&i.has(a)&&(h=i.get(a),f=h-d),u===void 0||d===void 0||h===void 0){const m=function(){return gl||(gl=pt({width:0,height:0}).getContext("2d")),gl}();this._setTextStyles(m,t,!0),u===void 0&&(f=u=m.measureText(e).width,i.set(e,u)),d===void 0&&l&&n&&(d=m.measureText(n).width,i.set(n,d)),l&&h===void 0&&(h=m.measureText(a).width,i.set(a,h),f=h-d)}return{width:u*c,kernedWidth:f*c}}getHeightOfChar(e,t){return this.getValueOfPropertyAt(e,t,"fontSize")}measureLine(e){const t=this._measureLine(e);return this.charSpacing!==0&&(t.width-=this._getWidthOfCharSpacing()),t.width<0&&(t.width=0),t}_measureLine(e){let t,n,s=0;const i=this.pathSide===fe,o=this.path,a=this._textLines[e],l=a.length,c=new Array(l);this.__charBounds[e]=c;for(let u=0;u<l;u++){const h=a[u];n=this._getGraphemeBox(h,e,u,t),c[u]=n,s+=n.kernedWidth,t=h}if(c[l]={left:n?n.left+n.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let u=0;const h=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case J:u=i?h-s:0;break;case $:u=(h-s)/2;break;case fe:u=i?0:h-s}u+=this.pathStartOffset*(i?-1:1);for(let d=i?l-1:0;i?d>=0:d<l;i?d--:d++)n=c[d],u>h?u%=h:u<0&&(u+=h),this._setGraphemeOnPath(u,n),u+=n.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(e,t){const n=e+t.kernedWidth/2,s=this.path,i=M1(s.path,n,s.segmentsInfo);t.renderLeft=i.x-s.pathOffset.x,t.renderTop=i.y-s.pathOffset.y,t.angle=i.angle+(this.pathSide===fe?Math.PI:0)}_getGraphemeBox(e,t,n,s,i){const o=this.getCompleteStyleDeclaration(t,n),a=s?this.getCompleteStyleDeclaration(t,n-1):{},l=this._measureChar(e,o,s,a);let c,u=l.kernedWidth,h=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),h+=c,u+=c);const d={width:h,left:0,height:o.fontSize,kernedWidth:u,deltaY:o.deltaY};if(n>0&&!i){const f=this.__charBounds[t][n-1];d.left=f.left+f.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(e){const t=this.__lineHeights;if(t[e])return t[e];let n=this.getHeightOfChar(e,0);for(let s=1,i=this._textLines[e].length;s<i;s++)n=Math.max(this.getHeightOfChar(e,s),n);return t[e]=n*this._fontSizeMult}getHeightOfLine(e){return this.getHeightOfLineImpl(e)*this.lineHeight}calcTextHeight(){let e=0;for(let t=0,n=this._textLines.length;t<n;t++)e+=t===n-1?this.getHeightOfLineImpl(t):this.getHeightOfLine(t);return e}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(e,t){e.save();let n=0;const s=this._getLeftOffset(),i=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(t,e,this._textLines[o],s+this._getLineLeftOffset(o),i+n+this.getHeightOfLineImpl(o),o),n+=this.getHeightOfLine(o);e.restore()}_renderTextFill(e){(this.fill||this.styleHas(_e))&&this._renderTextCommon(e,"fillText")}_renderTextStroke(e){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this._setLineDash(e,this.strokeDashArray),e.beginPath(),this._renderTextCommon(e,"strokeText"),e.closePath(),e.restore())}_renderChars(e,t,n,s,i,o){const a=this.textAlign.includes(Rt),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,u=this.direction==="ltr",h=this.direction==="ltr"?1:-1,d=t.direction;let f,m,v,w,g,p="",y=0;if(t.save(),d!==this.direction&&(t.canvas.setAttribute("dir",u?"ltr":"rtl"),t.direction=u?"ltr":"rtl",t.textAlign=u?J:fe),i-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(e,t,o,0,n.join(""),s,i),void t.restore();for(let x=0,_=n.length-1;x<=_;x++)w=x===_||this.charSpacing||l,p+=n[x],v=this.__charBounds[o][x],y===0?(s+=h*(v.kernedWidth-v.width),y+=v.width):y+=v.kernedWidth,a&&!w&&this._reSpaceAndTab.test(n[x])&&(w=!0),w||(f=f||this.getCompleteStyleDeclaration(o,x),m=this.getCompleteStyleDeclaration(o,x+1),w=Ru(f,m,!1)),w&&(l?(t.save(),t.translate(v.renderLeft,v.renderTop),t.rotate(v.angle),this._renderChar(e,t,o,x,p,-y/2,0),t.restore()):(g=s,this._renderChar(e,t,o,x,p,g,i)),p="",f=m,s+=h*y,y=0);t.restore()}_applyPatternGradientTransformText(e){const t=this.width+this.strokeWidth,n=this.height+this.strokeWidth,s=pt({width:t,height:n}),i=s.getContext("2d");return s.width=t,s.height=n,i.beginPath(),i.moveTo(0,0),i.lineTo(t,0),i.lineTo(t,n),i.lineTo(0,n),i.closePath(),i.translate(t/2,n/2),i.fillStyle=e.toLive(i),this._applyPatternGradientTransform(i,e),i.fill(),i.createPattern(s,"no-repeat")}handleFiller(e,t,n){let s,i;return ct(n)?n.gradientUnits==="percentage"||n.gradientTransform||n.patternTransform?(s=-this.width/2,i=-this.height/2,e.translate(s,i),e[t]=this._applyPatternGradientTransformText(n),{offsetX:s,offsetY:i}):(e[t]=n.toLive(e),this._applyPatternGradientTransform(e,n)):(e[t]=n,{offsetX:0,offsetY:0})}_setStrokeStyles(e,t){let{stroke:n,strokeWidth:s}=t;return e.lineWidth=s,e.lineCap=this.strokeLineCap,e.lineDashOffset=this.strokeDashOffset,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,this.handleFiller(e,"strokeStyle",n)}_setFillStyles(e,t){let{fill:n}=t;return this.handleFiller(e,"fillStyle",n)}_renderChar(e,t,n,s,i,o,a){const l=this._getStyleDeclaration(n,s),c=this.getCompleteStyleDeclaration(n,s),u=e==="fillText"&&c.fill,h=e==="strokeText"&&c.stroke&&c.strokeWidth;if(h||u){if(t.save(),t.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(t),l.deltaY&&(a+=l.deltaY),u){const d=this._setFillStyles(t,c);t.fillText(i,o-d.offsetX,a-d.offsetY)}if(h){const d=this._setStrokeStyles(t,c);t.strokeText(i,o-d.offsetX,a-d.offsetY)}t.restore()}}setSuperscript(e,t){this._setScript(e,t,this.superscript)}setSubscript(e,t){this._setScript(e,t,this.subscript)}_setScript(e,t,n){const s=this.get2DCursorLocation(e,!0),i=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:i*n.size,deltaY:o+i*n.baseline};this.setSelectionStyles(a,e,t)}_getLineLeftOffset(e){const t=this.getLineWidth(e),n=this.width-t,s=this.textAlign,i=this.direction,o=this.isEndOfWrapping(e);let a=0;return s===Rt||s===Os&&!o||s===ks&&!o||s===Jo&&!o?0:(s===$&&(a=n/2),s===fe&&(a=n),s===Os&&(a=n/2),s===ks&&(a=n),i==="rtl"&&(s===fe||s===Rt||s===ks?a=0:s===J||s===Jo?a=-n:s!==$&&s!==Os||(a=-n/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(e){if(this.__lineWidths[e]!==void 0)return this.__lineWidths[e];const{width:t}=this.measureLine(e);return this.__lineWidths[e]=t,t}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(e,t,n){var s;return(s=this._getStyleDeclaration(e,t)[n])!==null&&s!==void 0?s:this[n]}_renderTextDecoration(e,t){if(!this[t]&&!this.styleHas(t))return;let n=this._getTopOffset();const s=this._getLeftOffset(),i=this.path,o=this._getWidthOfCharSpacing(),a=t==="linethrough"?.5:t==="overline"?1:0,l=this.offsets[t];for(let c=0,u=this._textLines.length;c<u;c++){const h=this.getHeightOfLine(c);if(!this[t]&&!this.styleHas(t,c)){n+=h;continue}const d=this._textLines[c],f=h/this.lineHeight,m=this._getLineLeftOffset(c);let v=0,w=0,g=this.getValueOfPropertyAt(c,0,t),p=this.getValueOfPropertyAt(c,0,_e),y=this.getValueOfPropertyAt(c,0,sn),x=g,_=p,E=y;const D=n+f*(1-this._fontSizeFraction);let k=this.getHeightOfChar(c,0),N=this.getValueOfPropertyAt(c,0,"deltaY");for(let T=0,M=d.length;T<M;T++){const R=this.__charBounds[c][T];x=this.getValueOfPropertyAt(c,T,t),_=this.getValueOfPropertyAt(c,T,_e),E=this.getValueOfPropertyAt(c,T,sn);const B=this.getHeightOfChar(c,T),j=this.getValueOfPropertyAt(c,T,"deltaY");if(i&&x&&_){const I=this.fontSize*E/1e3;e.save(),e.fillStyle=p,e.translate(R.renderLeft,R.renderTop),e.rotate(R.angle),e.fillRect(-R.kernedWidth/2,l*B+j-a*I,R.kernedWidth,I),e.restore()}else if((x!==g||_!==p||B!==k||E!==y||j!==N)&&w>0){const I=this.fontSize*y/1e3;let P=s+m+v;this.direction==="rtl"&&(P=this.width-P-w),g&&p&&y&&(e.fillStyle=p,e.fillRect(P,D+l*k+N-a*I,w,I)),v=R.left,w=R.width,g=x,y=E,p=_,k=B,N=j}else w+=R.kernedWidth}let L=s+m+v;this.direction==="rtl"&&(L=this.width-L-w),e.fillStyle=_;const X=this.fontSize*E/1e3;x&&_&&E&&e.fillRect(L,D+l*k+N-a*X,w-o,X),n+=h}this._removeShadow(e)}_getFontDeclaration(){let{fontFamily:e=this.fontFamily,fontStyle:t=this.fontStyle,fontWeight:n=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;const o=e.includes("'")||e.includes('"')||e.includes(",")||Fe.genericFonts.includes(e.toLowerCase())?e:'"'.concat(e,'"');return[t,n,"".concat(i?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(e)))}graphemeSplit(e){return Fu(e)}_splitTextIntoLines(e){const t=e.split(this._reNewline),n=new Array(t.length),s=[`
93
- `];let i=[];for(let o=0;o<t.length;o++)n[o]=this.graphemeSplit(t[o]),i=i.concat(n[o],s);return i.pop(),{_unwrappedLines:n,lines:t,graphemeText:i,graphemeLines:n}}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject([...zp,...e])),{},{styles:Yx(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(e,t){const{textLayoutProperties:n}=this.constructor;super.set(e,t);let s=!1,i=!1;if(typeof e=="object")for(const o in e)o==="path"&&this.setPathInfo(),s=s||n.includes(o),i=i||o==="path";else s=n.includes(e),i=e==="path";return i&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(e,t,n){const s=dr(e,Fe.ATTRIBUTE_NAMES,n),i=b(b({},t),s),{textAnchor:o=J,textDecoration:a="",dx:l=0,dy:c=0,top:u=0,left:h=0,fontSize:d=Su,strokeWidth:f=1}=i,m=ie(i,s_),v=new this(Qo(e.textContent||"").trim(),b({left:h+l,top:u+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},m)),w=v.getScaledHeight()/v.height,g=((v.height+v.strokeWidth)*v.lineHeight-v.height)*w,p=v.getScaledHeight()+g;let y=0;return o===$&&(y=v.getScaledWidth()/2),o===fe&&(y=v.getScaledWidth()),v.set({left:v.left-y,top:v.top-(p-v.fontSize*(.07+v._fontSizeFraction))/v.lineHeight,strokeWidth:f}),v}static fromObject(e){return this._fromObject(b(b({},e),{},{styles:Gx(e.styles||{},e.text)}),{extraParam:"text"})}}C(Fe,"textLayoutProperties",Ip),C(Fe,"cacheProperties",[...hr,...zp]),C(Fe,"ownDefaults",ox),C(Fe,"type","Text"),C(Fe,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),C(Fe,"ATTRIBUTE_NAMES",Vr.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Gp(Fe,[class extends Fp{_toSVG(){const r=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(r){const e=this._createBaseSVGMarkup(this._toSVG(),{reviver:r,noStyle:!0,withShadow:!0}),t=this.path;return t?e+t._createBaseSVGMarkup(t._toSVG(),{reviver:r,withShadow:!0,additionalTransform:Gs(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(r){let{textBgRects:e,textSpans:t}=r;const n=this.getSvgTextDecoration(this);return[e.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(n_,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",n?'text-decoration="'.concat(n,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",t.join(""),`</text>
94
- `]}_getSVGTextAndBg(r,e){const t=[],n=[];let s,i=r;this.backgroundColor&&n.push(...fl(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(n,o,e+s,i),this._setSVGTextLineText(t,o,e+s,i),i+=this.getHeightOfLine(o);return{textSpans:t,textBgRects:n}}_createTextCharSpan(r,e,t,n,s){const i=q.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(e,r!==r.trim()||!!r.match(r_)),a=o?'style="'.concat(o,'"'):"",l=e.deltaY,c=l?' dy="'.concat(te(l,i),'" '):"",{angle:u,renderLeft:h,renderTop:d,width:f}=s;let m="";if(h!==void 0){const v=f/2;u&&(m=' rotate="'.concat(te(cr(u),i),'"'));const w=Qn({angle:cr(u)});w[4]=h,w[5]=d;const g=new O(-v,0).transform(w);t=g.x,n=g.y}return'<tspan x="'.concat(te(t,i),'" y="').concat(te(n,i),'" ').concat(c).concat(m).concat(a,">").concat(Xx(r),"</tspan>")}_setSVGTextLineText(r,e,t,n){const s=this.getHeightOfLine(e),i=this.textAlign.includes(Rt),o=this._textLines[e];let a,l,c,u,h,d="",f=0;n+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let m=0,v=o.length-1;m<=v;m++)h=m===v||this.charSpacing||this.path,d+=o[m],c=this.__charBounds[e][m],f===0?(t+=c.kernedWidth-c.width,f+=c.width):f+=c.kernedWidth,i&&!h&&this._reSpaceAndTab.test(o[m])&&(h=!0),h||(a=a||this.getCompleteStyleDeclaration(e,m),l=this.getCompleteStyleDeclaration(e,m+1),h=Ru(a,l,!0)),h&&(u=this._getStyleDeclaration(e,m),r.push(this._createTextCharSpan(d,u,t,n,c)),d="",a=l,this.direction==="rtl"?t-=f:t+=f,f=0)}_setSVGTextLineBg(r,e,t,n){const s=this._textLines[e],i=this.getHeightOfLine(e)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let u=0;u<s.length;u++){const{left:h,width:d,kernedWidth:f}=this.__charBounds[e][u];o=this.getValueOfPropertyAt(e,u,"textBackgroundColor"),o!==c?(c&&r.push(...fl(c,t+l,n,a,i)),l=h,a=d,c=o):a+=f}o&&r.push(...fl(c,t+l,n,a,i))}_getSVGLineTopOffset(r){let e,t=0;for(e=0;e<r;e++)t+=this.getHeightOfLine(e);const n=this.getHeightOfLine(e);return{lineTop:t,offset:(this._fontSizeMult-this._fontSizeFraction)*n/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(te(this.textDecorationThickness*this.getObjectScaling().y/10,q.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,e){const{fontFamily:t,strokeWidth:n,stroke:s,fill:i,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:u,linethrough:h,overline:d,underline:f}=r,m=this.getSvgTextDecoration({underline:f??this.underline,overline:d??this.overline,linethrough:h??this.linethrough}),v=u||this.textDecorationThickness;return[s?Ks(qe,s):"",n?"stroke-width: ".concat(n,"; "):"",t?"font-family: ".concat(t.includes("'")||t.includes('"')?t:"'".concat(t,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",m?"text-decoration: ".concat(m,"; text-decoration-thickness: ").concat(te(v*this.getObjectScaling().y/10,q.NUM_FRACTION_DIGITS),"%; "):"",i?Ks(_e,i):"",c?"baseline-shift: ".concat(-c,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter(e=>r[e.replace("-","")]).join(" ")}}]),W.setClass(Fe),W.setSVGClass(Fe);class i_{constructor(e){C(this,"target",void 0),C(this,"__mouseDownInPlace",!1),C(this,"__dragStartFired",!1),C(this,"__isDraggingOver",!1),C(this,"__dragStartSelection",void 0),C(this,"__dragImageDisposer",void 0),C(this,"_dispose",void 0),this.target=e;const t=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{t.forEach(n=>n()),this._dispose=void 0}}isPointerOverSelection(e){const t=this.target,n=t.getSelectionStartFromPointer(e);return t.isEditing&&n>=t.selectionStart&&n<=t.selectionEnd&&t.selectionStart<t.selectionEnd}start(e){return this.__mouseDownInPlace=this.isPointerOverSelection(e)}isActive(){return this.__mouseDownInPlace}end(e){const t=this.isActive();return t&&!this.__dragStartFired&&(this.target.setCursorByClick(e),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,t}getDragStartSelection(){return this.__dragStartSelection}setDragImage(e,t){var n;let{selectionStart:s,selectionEnd:i}=t;const o=this.target,a=o.canvas,l=new O(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),u=new O(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),h=a.getScenePoint(e).subtract(u),d=o.getCanvasRetinaScaling(),f=o.getBoundingRect(),m=u.subtract(new O(f.left,f.top)),v=a.viewportTransform,w=m.add(h).transform(v,!0),g=o.backgroundColor,p=Lu(o.styles);o.backgroundColor="";const y={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(y,0,s),o.setSelectionStyles(y,i,o.text.length),o.dirty=!0;const x=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=g,o.styles=p,o.dirty=!0,Cc(x,{position:"fixed",left:"".concat(-x.width,"px"),border:Ke,width:"".concat(x.width/d,"px"),height:"".concat(x.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{x.remove()},bt(e.target||this.target.hiddenTextarea).body.appendChild(x),(n=e.dataTransfer)===null||n===void 0||n.setDragImage(x,w.x,w.y)}onDragStart(e){this.__dragStartFired=!0;const t=this.target,n=this.isActive();if(n&&e.dataTransfer){const s=this.__dragStartSelection={selectionStart:t.selectionStart,selectionEnd:t.selectionEnd},i=t._text.slice(s.selectionStart,s.selectionEnd).join(""),o=b({text:t.text,value:i},s);e.dataTransfer.setData("text/plain",i),e.dataTransfer.setData("application/fabric",JSON.stringify({value:i,styles:t.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),e.dataTransfer.effectAllowed="copyMove",this.setDragImage(e,o)}return t.abortCursorAnimation(),n}canDrop(e){if(this.target.editable&&!this.target.getActiveControl()&&!e.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const t=this.target.getSelectionStartFromPointer(e),n=this.__dragStartSelection;return t<n.selectionStart||t>n.selectionEnd}return!0}return!1}targetCanDrop(e){return this.target.canDrop(e)}dragEnterHandler(e){let{e:t}=e;const n=this.targetCanDrop(t);!this.__isDraggingOver&&n&&(this.__isDraggingOver=!0)}dragOverHandler(e){const{e:t}=e,n=this.targetCanDrop(t);!this.__isDraggingOver&&n?this.__isDraggingOver=!0:this.__isDraggingOver&&!n&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(t.preventDefault(),e.canDrop=!0,e.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(e){var t;const{e:n}=e,s=n.defaultPrevented;this.__isDraggingOver=!1,n.preventDefault();let i=(t=n.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain");if(i&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(n);const{styles:c}=n.dataTransfer.types.includes("application/fabric")?JSON.parse(n.dataTransfer.getData("application/fabric")):{},u=i[Math.max(0,i.length-1)],h=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,f=this.__dragStartSelection.selectionEnd;l>d&&l<=f?l=d:l>f&&(l-=f-d),o.removeChars(d,f),delete this.__dragStartSelection}o._reNewline.test(u)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(i=i.trimEnd()),e.didDrop=!0,e.dropTarget=o,o.insertChars(i,c,l),a.setActiveObject(o),o.enterEditing(n),o.selectionStart=Math.min(l+h,o._text.length),o.selectionEnd=Math.min(o.selectionStart+i.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Uo,{index:l+h,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(e){let{e:t}=e;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var n;const s=this.target,i=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((n=t.dataTransfer)===null||n===void 0?void 0:n.dropEffect)||Ke;l===Ke?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Uo,{index:o,action:"dragend"}),i.fire("text:changed",{target:s}),i.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Wd=/[ \n\.,;!\?\-]/;class o_ extends Fe{constructor(){super(...arguments),C(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(e){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(e)}_animateCursor(e){let{toValue:t,duration:n,delay:s,onComplete:i}=e;return Hp({startValue:this._currentCursorOpacity,endValue:t,duration:n,delay:s,onComplete:i,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(e){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(e||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var e;(e=this._currentTickCompleteState)===null||e===void 0||e.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(e){this.abortCursorAnimation(),this._tick(e?0:this.cursorDelay)}abortCursorAnimation(){let e=!1;[this._currentTickState,this._currentTickCompleteState].forEach(t=>{t&&!t.isDone()&&(e=!0,t.abort())}),this._currentCursorOpacity=1,e&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(e=>!e||e.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(e){let t=0,n=e-1;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n--;for(;/\S/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findWordBoundaryRight(e){let t=0,n=e;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n++;for(;/\S/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}findLineBoundaryLeft(e){let t=0,n=e-1;for(;!/\n/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findLineBoundaryRight(e){let t=0,n=e;for(;!/\n/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}searchWordBoundary(e,t){const n=this._text;let s=e>0&&this._reSpace.test(n[e])&&(t===-1||!Cu.test(n[e-1]))?e-1:e,i=n[s];for(;s>0&&s<n.length&&!Wd.test(i);)s+=t,i=n[s];return t===-1&&Wd.test(i)&&s++,s}selectWord(e){var t;e=(t=e)!==null&&t!==void 0?t:this.selectionStart;const n=this.searchWordBoundary(e,-1),s=Math.max(n,this.searchWordBoundary(e,1));this.selectionStart=n,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(e){var t;e=(t=e)!==null&&t!==void 0?t:this.selectionStart;const n=this.findLineBoundaryLeft(e),s=this.findLineBoundaryRight(e);this.selectionStart=n,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(e){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",e?{e}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(e){if(this.getActiveControl())return;const t=this.hiddenTextarea;bt(t).activeElement!==t&&t.focus();const n=this.getSelectionStartFromPointer(e),s=this.selectionStart,i=this.selectionEnd;(n===this.__selectionStartOnMouseDown&&s!==i||s!==n&&i!==n)&&(n>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=n):(this.selectionStart=n,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===i||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(e,t,n){const s=n.slice(0,e),i=this.graphemeSplit(s).length;if(e===t)return{selectionStart:i,selectionEnd:i};const o=n.slice(e,t);return{selectionStart:i,selectionEnd:i+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(e,t,n){const s=n.slice(0,e).join("").length;return e===t?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+n.slice(e,t).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const e=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=e.selectionStart,this.hiddenTextarea.selectionEnd=e.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const e=this.hiddenTextarea;this.text=e.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const t=this.fromStringToGraphemeSelection(e.selectionStart,e.selectionEnd,e.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const e=this._calcTextareaPosition();this.hiddenTextarea.style.left=e.left,this.hiddenTextarea.style.top=e.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const e=this.inCompositionMode?this.compositionStart:this.selectionStart,t=this._getCursorBoundaries(e),n=this.get2DCursorLocation(e),s=n.lineIndex,i=n.charIndex,o=this.getValueOfPropertyAt(s,i,"fontSize")*this.lineHeight,a=t.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,u=c.width/l,h=c.height/l,d=u-o,f=h-o,m=new O(t.left+a,t.top+t.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new O(c.clientWidth/u,c.clientHeight/h));return m.x<0&&(m.x=0),m.x>d&&(m.x=d),m.y<0&&(m.y=0),m.y>f&&(m.y=f),m.x+=this.canvas._offset.left,m.y+=this.canvas._offset.top,{left:"".concat(m.x,"px"),top:"".concat(m.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const e=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const e=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),e&&this.fire($o),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),e&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const e in this.styles)this._textLines[e]||delete this.styles[e]}removeStyleFromTo(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e,!0),{lineIndex:i,charIndex:o}=this.get2DCursorLocation(t,!0);if(n!==i){if(this.styles[n])for(let a=s;a<this._unwrappedTextLines[n].length;a++)delete this.styles[n][a];if(this.styles[i])for(let a=o;a<this._unwrappedTextLines[i].length;a++){const l=this.styles[i][a];l&&(this.styles[n]||(this.styles[n]={}),this.styles[n][s+a-o]=l)}for(let a=n+1;a<=i;a++)delete this.styles[a];this.shiftLineStyles(i,n-i)}else if(this.styles[n]){const a=this.styles[n],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[n]){const u=parseInt(c,10);u>=o&&(a[u-l]=a[c],delete a[c])}}}shiftLineStyles(e,t){const n=Object.assign({},this.styles);for(const s in this.styles){const i=parseInt(s,10);i>e&&(this.styles[i+t]=n[i],n[i-t]||delete this.styles[i])}}insertNewlineStyleObject(e,t,n,s){const i={},o=this._unwrappedTextLines[e].length,a=o===t;let l=!1;n||(n=1),this.shiftLineStyles(e,n);const c=this.styles[e]?this.styles[e][t===0?t:t-1]:void 0;for(const h in this.styles[e]){const d=parseInt(h,10);d>=t&&(l=!0,i[d-t]=this.styles[e][h],a&&t===0||delete this.styles[e][h])}let u=!1;for(l&&!a&&(this.styles[e+n]=i,u=!0),(u||o>t)&&n--;n>0;)s&&s[n-1]?this.styles[e+n]={0:b({},s[n-1])}:c?this.styles[e+n]={0:b({},c)}:delete this.styles[e+n],n--;this._forceClearCache=!0}insertCharStyleObject(e,t,n,s){this.styles||(this.styles={});const i=this.styles[e],o=i?b({},i):{};n||(n=1);for(const l in o){const c=parseInt(l,10);c>=t&&(i[c+n]=o[c],o[c-n]||delete i[c])}if(this._forceClearCache=!0,s){for(;n--;)Object.keys(s[n]).length&&(this.styles[e]||(this.styles[e]={}),this.styles[e][t+n]=b({},s[n]));return}if(!i)return;const a=i[t?t-1:1];for(;a&&n--;)this.styles[e][t+n]=b({},a)}insertNewStyleBlock(e,t,n){const s=this.get2DCursorLocation(t,!0),i=[0];let o,a=0;for(let l=0;l<e.length;l++)e[l]===`
95
- `?(a++,i[a]=0):i[a]++;for(i[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,i[0],n),n=n&&n.slice(i[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+i[0],a),o=1;o<a;o++)i[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,i[o],n):n&&this.styles[s.lineIndex+o]&&n[0]&&(this.styles[s.lineIndex+o][0]=n[0]),n=n&&n.slice(i[o]+1);i[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,i[o],n)}removeChars(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e+1;this.removeStyleFromTo(e,t),this._text.splice(e,t-e),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(e,t,n){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:n;s>n&&this.removeStyleFromTo(n,s);const i=this.graphemeSplit(e);this.insertNewStyleBlock(i,n,t),this._text=[...this._text.slice(0,n),...i,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(e,t,n){n<=e?(t===e?this._selectionDirection=J:this._selectionDirection===fe&&(this._selectionDirection=J,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===fe?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=fe:this._selectionDirection===J&&(this._selectionDirection=fe,this.selectionStart=t),this.selectionEnd=n)}}class a_ extends o_{initHiddenTextarea(){const e=this.canvas&&bt(this.canvas.getElement())||Gn(),t=e.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(o=>{let[a,l]=o;return t.setAttribute(a,l)});const{top:n,left:s,fontSize:i}=this._calcTextareaPosition();t.style.cssText="position: absolute; top: ".concat(n,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(i,";"),(this.hiddenTextareaContainer||e.body).appendChild(t),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(o=>{let[a,l]=o;return t.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=t}blur(){this.abortCursorAnimation()}onKeyDown(e){if(!this.isEditing)return;const t=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(e.keyCode in t)this[t[e.keyCode]](e);else{if(!(e.keyCode in this.ctrlKeysMapDown)||!e.ctrlKey&&!e.metaKey)return;this[this.ctrlKeysMapDown[e.keyCode]](e)}e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(e){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey)&&(this[this.ctrlKeysMapUp[e.keyCode]](e),e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(e){const t=this.fromPaste,{value:n,selectionStart:s,selectionEnd:i}=this.hiddenTextarea;if(this.fromPaste=!1,e&&e.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Uo),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(n).graphemeText,l=this._text.length,c=a.length,u=this.selectionStart,h=this.selectionEnd,d=u!==h;let f,m,v,w,g=c-l;const p=this.fromStringToGraphemeSelection(s,i,n),y=u>p.selectionStart;d?(m=this._text.slice(u,h),g+=h-u):c<l&&(m=y?this._text.slice(h+g,h):this._text.slice(u,u-g));const x=a.slice(p.selectionEnd-g,p.selectionEnd);if(m&&m.length&&(x.length&&(f=this.getSelectionStyles(u,u+1,!1),f=x.map(()=>f[0])),d?(v=u,w=h):y?(v=h-m.length,w=h):(v=h,w=h+m.length),this.removeStyleFromTo(v,w)),x.length){const{copyPasteData:_}=Wt();t&&x.join("")===_.copiedText&&!q.disableStyleCopyPaste&&(f=_.copiedTextStyle),this.insertNewStyleBlock(x,u,f)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(e){let{target:t}=e;const{selectionStart:n,selectionEnd:s}=t;this.compositionStart=n,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:e}=Wt();e.copiedText=this.getSelectedText(),q.disableStyleCopyPaste?e.copiedTextStyle=void 0:e.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(e,t){let n,s=this._getLineLeftOffset(e);return t>0&&(n=this.__charBounds[e][t-1],s+=n.left+n.width),s}getDownCursorOffset(e,t){const n=this._getSelectionForOffset(e,t),s=this.get2DCursorLocation(n),i=s.lineIndex;if(i===this._textLines.length-1||e.metaKey||e.keyCode===34)return this._text.length-n;const o=s.charIndex,a=this._getWidthBeforeCursor(i,o),l=this._getIndexOnLine(i+1,a);return this._textLines[i].slice(o).length+l+1+this.missingNewlineOffset(i)}_getSelectionForOffset(e,t){return e.shiftKey&&this.selectionStart!==this.selectionEnd&&t?this.selectionEnd:this.selectionStart}getUpCursorOffset(e,t){const n=this._getSelectionForOffset(e,t),s=this.get2DCursorLocation(n),i=s.lineIndex;if(i===0||e.metaKey||e.keyCode===33)return-n;const o=s.charIndex,a=this._getWidthBeforeCursor(i,o),l=this._getIndexOnLine(i-1,a),c=this._textLines[i].slice(0,o),u=this.missingNewlineOffset(i-1);return-this._textLines[i-1].length+l-c.length+(1-u)}_getIndexOnLine(e,t){const n=this._textLines[e];let s,i,o=this._getLineLeftOffset(e),a=0;for(let l=0,c=n.length;l<c;l++)if(s=this.__charBounds[e][l].width,o+=s,o>t){i=!0;const u=o-s,h=o,d=Math.abs(u-t);a=Math.abs(h-t)<d?l:l-1;break}return i||(a=n.length-1),a}moveCursorDown(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",e)}moveCursorUp(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",e)}_moveCursorUpOrDown(e,t){const n=this["get".concat(e,"CursorOffset")](t,this._selectionDirection===fe);if(t.shiftKey?this.moveCursorWithShift(n):this.moveCursorWithoutShift(n),n!==0){const s=this.text.length;this.selectionStart=Xn(0,this.selectionStart,s),this.selectionEnd=Xn(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(e){const t=this._selectionDirection===J?this.selectionStart+e:this.selectionEnd+e;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,t),e!==0}moveCursorWithoutShift(e){return e<0?(this.selectionStart+=e,this.selectionEnd=this.selectionStart):(this.selectionEnd+=e,this.selectionStart=this.selectionEnd),e!==0}moveCursorLeft(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",e)}_move(e,t,n){let s;if(e.altKey)s=this["findWordBoundary".concat(n)](this[t]);else{if(!e.metaKey&&e.keyCode!==35&&e.keyCode!==36)return this[t]+=n==="Left"?-1:1,!0;s=this["findLineBoundary".concat(n)](this[t])}return s!==void 0&&this[t]!==s&&(this[t]=s,!0)}_moveLeft(e,t){return this._move(e,t,"Left")}_moveRight(e,t){return this._move(e,t,"Right")}moveCursorLeftWithoutShift(e){let t=!0;return this._selectionDirection=J,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(t=this._moveLeft(e,"selectionStart")),this.selectionEnd=this.selectionStart,t}moveCursorLeftWithShift(e){return this._selectionDirection===fe&&this.selectionStart!==this.selectionEnd?this._moveLeft(e,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=J,this._moveLeft(e,"selectionStart")):void 0}moveCursorRight(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",e)}_moveCursorLeftOrRight(e,t){const n="moveCursor".concat(e).concat(t.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[n](t)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(e){return this._selectionDirection===J&&this.selectionStart!==this.selectionEnd?this._moveRight(e,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=fe,this._moveRight(e,"selectionEnd")):void 0}moveCursorRightWithoutShift(e){let t=!0;return this._selectionDirection=fe,this.selectionStart===this.selectionEnd?(t=this._moveRight(e,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,t}}const Hd=r=>!!r.button;class l_ extends a_{constructor(){super(...arguments),C(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new i_(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(e){return this.draggableTextDelegate.onDragStart(e)}canDrop(e){return this.draggableTextDelegate.canDrop(e)}doubleClickHandler(e){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}tripleClickHandler(e){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}_mouseDownHandler(e){let{e:t,alreadySelected:n}=e;this.canvas&&this.editable&&!Hd(t)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(t)||(this.canvas.textEditingManager.register(this),n&&(this.inCompositionMode=!1,this.setCursorByClick(t)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=n||this.isEditing)))}mouseUpHandler(e){let{e:t,transform:n}=e;const s=this.draggableTextDelegate.end(t);if(this.canvas){this.canvas.textEditingManager.unregister(this);const i=this.canvas._activeObject;if(i&&i!==this)return}!this.editable||this.group&&!this.group.interactive||n&&n.actionPerformed||Hd(t)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(t),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(e){const t=this.getSelectionStartFromPointer(e),n=this.selectionStart,s=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(n,s,t):(this.selectionStart=t,this.selectionEnd=t),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(e){const t=this.canvas.getScenePoint(e).transform(Tt(this.calcTransformMatrix())).add(new O(-this._getLeftOffset(),-this._getTopOffset()));let n=0,s=0,i=0;for(let c=0;c<this._textLines.length&&n<=t.y;c++)n+=this.getHeightOfLine(c),i=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(i));const a=this._textLines[i].length,l=this.__charBounds[i];for(let c=0;c<a;c++){const u=o+l[c].kernedWidth;if(t.x<=u){Math.abs(t.x-u)<=Math.abs(t.x-o)&&s++;break}o=u,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const Mi="moveCursorUp",ji="moveCursorDown",Ai="moveCursorLeft",Li="moveCursorRight",Fi="exitEditing",Xd=(r,e)=>{const t=e.getRetinaScaling();r.setTransform(t,0,0,t,0,0);const n=e.viewportTransform;r.transform(n[0],n[1],n[2],n[3],n[4],n[5])},c_=b({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:Fi,27:Fi,33:Mi,34:ji,35:Li,36:Ai,37:Ai,38:Mi,39:Li,40:ji},keysMapRtl:{9:Fi,27:Fi,33:Mi,34:ji,35:Ai,36:Li,37:Li,38:Mi,39:Ai,40:ji},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Zt extends l_{static getDefaults(){return b(b({},super.getDefaults()),Zt.ownDefaults)}get type(){const e=super.type;return e==="itext"?"i-text":e}constructor(e,t){super(e,b(b({},Zt.ownDefaults),t)),this.initBehavior()}_set(e,t){return this.isEditing&&this._savedProps&&e in this._savedProps?(this._savedProps[e]=t,this):(e==="canvas"&&(this.canvas instanceof bc&&this.canvas.textEditingManager.remove(this),t instanceof bc&&t.textEditingManager.add(this)),super._set(e,t))}setSelectionStart(e){e=Math.max(e,0),this._updateAndFire("selectionStart",e)}setSelectionEnd(e){e=Math.min(e,this.text.length),this._updateAndFire("selectionEnd",e)}_updateAndFire(e,t){this[e]!==t&&(this._fireSelectionChanged(),this[e]=t),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,n=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(e,t,n)}setSelectionStyles(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(e,t,n)}get2DCursorLocation(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(e,t)}render(e){super.render(e),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(e){const t=this.isEditing;this.isEditing=!1;const n=super.toCanvasElement(e);return this.isEditing=t,n}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const e=this.clearContextTop(!0);if(!e)return;const t=this._getCursorBoundaries(),n=this.findAncestorsWithClipPath(),s=n.length>0;let i,o=e;if(s){i=pt(e.canvas),o=i.getContext("2d"),Xd(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,t):this.renderCursor(o,t),s)for(const a of n){const l=a.clipPath,c=pt(e.canvas),u=c.getContext("2d");if(Xd(u,this.canvas),!l.absolutePositioned){const h=a.calcTransformMatrix();u.transform(h[0],h[1],h[2],h[3],h[4],h[5])}l.transform(u),l.drawObject(u,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(e.setTransform(1,0,0,1,0,0),e.drawImage(i,0,0)),this.canvas.contextTopDirty=!0,e.restore()}findAncestorsWithClipPath(){const e=[];let t=this;for(;t;)t.clipPath&&e.push(t),t=t.parent;return e}_getCursorBoundaries(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1?arguments[1]:void 0;const n=this._getLeftOffset(),s=this._getTopOffset(),i=this._getCursorBoundariesOffsets(e,t);return{left:n,top:s,leftOffset:i.left,topOffset:i.top}}_getCursorBoundariesOffsets(e,t){return t?this.__getCursorBoundariesOffsets(e):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(e)}__getCursorBoundariesOffsets(e){let t=0,n=0;const{charIndex:s,lineIndex:i}=this.get2DCursorLocation(e);for(let c=0;c<i;c++)t+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(i),a=this.__charBounds[i][s];a&&(n=a.left),this.charSpacing!==0&&s===this._textLines[i].length&&(n-=this._getWidthOfCharSpacing());const l={top:t,left:o+(n>0?n:0)};return this.direction==="rtl"&&(this.textAlign===fe||this.textAlign===Rt||this.textAlign===ks?l.left*=-1:this.textAlign===J||this.textAlign===Jo?l.left=o-(n>0?n:0):this.textAlign!==$&&this.textAlign!==Os||(l.left=o-(n>0?n:0))),l}renderCursorAt(e){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(e,!0),e)}renderCursor(e,t){this._renderCursor(e,t,this.selectionStart)}getCursorRenderingData(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(e);const n=this.get2DCursorLocation(e),s=n.lineIndex,i=n.charIndex>0?n.charIndex-1:0,o=this.getValueOfPropertyAt(s,i,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,i,"deltaY"),u=t.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,i,"fill"),opacity:this._currentCursorOpacity,left:t.left+t.leftOffset-l/2,top:u+t.top+c,width:l,height:o}}_renderCursor(e,t,n){const{color:s,opacity:i,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(n,t);e.fillStyle=s,e.globalAlpha=i,e.fillRect(o,a,l,c)}renderSelection(e,t){const n={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(e,n,t)}renderDragSourceEffect(){const e=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,e,this._getCursorBoundaries(e.selectionStart,!0))}renderDropTargetEffect(e){const t=this.getSelectionStartFromPointer(e);this.renderCursorAt(t)}_renderSelection(e,t,n){const s=t.selectionStart,i=t.selectionEnd,o=this.textAlign.includes(Rt),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(i),c=a.lineIndex,u=l.lineIndex,h=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let f=c;f<=u;f++){const m=this._getLineLeftOffset(f)||0;let v=this.getHeightOfLine(f),w=0,g=0,p=0;if(f===c&&(g=this.__charBounds[c][h].left),f>=c&&f<u)p=o&&!this.isEndOfWrapping(f)?this.width:this.getLineWidth(f)||5;else if(f===u)if(d===0)p=this.__charBounds[u][d].left;else{const D=this._getWidthOfCharSpacing();p=this.__charBounds[u][d-1].left+this.__charBounds[u][d-1].width-D}w=v,(this.lineHeight<1||f===u&&this.lineHeight>1)&&(v/=this.lineHeight);let y=n.left+m+g,x=v,_=0;const E=p-g;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",x=1,_=v):e.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===fe||this.textAlign===Rt||this.textAlign===ks?y=this.width-y-E:this.textAlign===J||this.textAlign===Jo?y=n.left+m-p:this.textAlign!==$&&this.textAlign!==Os||(y=n.left+m-p)),e.fillRect(y,n.top+n.topOffset+_,E,x),n.topOffset+=w}}getCurrentCharFontSize(){const e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,"fontSize")}getCurrentCharColor(){const e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,_e)}_getCurrentCharIndex(){const e=this.get2DCursorLocation(this.selectionStart,!0),t=e.charIndex>0?e.charIndex-1:0;return{l:e.lineIndex,c:t}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}C(Zt,"ownDefaults",c_),C(Zt,"type","IText"),W.setClass(Zt),W.setClass(Zt,"i-text");class Tr extends Zt{static getDefaults(){return b(b({},super.getDefaults()),Tr.ownDefaults)}constructor(e,t){super(e,b(b({},Tr.ownDefaults),t))}static createControls(){return{controls:Bx()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Rt)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(e){let t=0,n=0,s=0;const i={};for(let o=0;o<e.graphemeLines.length;o++)e.graphemeText[s]===`
96
- `&&o>0?(n=0,s++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[s])&&o>0&&(n++,s++),i[o]={line:t,offset:n},s+=e.graphemeLines[o].length,n+=e.graphemeLines[o].length;return i}styleHas(e,t){if(this._styleMap&&!this.isWrapping){const n=this._styleMap[t];n&&(t=n.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t,n=0,s=e+1,i=!1;const o=this._styleMap[e],a=this._styleMap[e+1];o&&(e=o.line,n=o.offset),a&&(s=a.line,i=s===e,t=a.offset);const l=e===void 0?this.styles:{line:this.styles[e]};for(const c in l)for(const u in l[c]){const h=parseInt(u,10);if(h>=n&&(!i||h<t))for(const d in l[c][u])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){const n=this._styleMap[e];if(!n)return{};e=n.line,t=n.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,n){const s=this._styleMap[e];super._setStyleDeclaration(s.line,s.offset+t,n)}_deleteStyleDeclaration(e,t){const n=this._styleMap[e];super._deleteStyleDeclaration(n.line,n.offset+t)}_getLineStyle(e){const t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){const t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;const n=this.getGraphemeDataForRender(e),s=[];for(let i=0;i<n.wordsData.length;i++)s.push(...this._wrapLine(i,t,n));return this.isWrapping=!1,s}getGraphemeDataForRender(e){const t=this.splitByGrapheme,n=t?"":" ";let s=0;return{wordsData:e.map((i,o)=>{let a=0;const l=t?this.graphemeSplit(i):this.wordSplit(i);return l.length===0?[{word:[],width:0}]:l.map(c=>{const u=t?[c]:this.graphemeSplit(c),h=this._measureWord(u,o,a);return s=Math.max(h,s),a+=u.length+n.length,{word:u,width:h}})}),largestWordWidth:s}}_measureWord(e,t){let n,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=0;for(let o=0,a=e.length;o<a;o++)i+=this._getGraphemeBox(e[o],t,o+s,n,!0).kernedWidth,n=e[o];return i}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,n){let{largestWordWidth:s,wordsData:i}=n,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],u=l?"":" ";let h=0,d=[],f=0,m=0,v=!0;t-=o;const w=Math.max(t,s,this.dynamicMinWidth),g=i[e];let p;for(f=0,p=0;p<g.length;p++){const{word:y,width:x}=g[p];f+=y.length,h+=m+x-a,h>w&&!v?(c.push(d),d=[],h=x,v=!0):h+=a,v||l||d.push(u),d=d.concat(y),m=l?0:this._measureWord([u],e,f),f++,v=!1}return p&&c.push(d),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?this.isEndOfWrapping(e)?1:0:1}_splitTextIntoLines(e){const t=super._splitTextIntoLines(e),n=this._wrapText(t.lines,this.width),s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=n[i].join("");return t.lines=s,t.graphemeLines=n,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const e=new Map;for(const t in this._styleMap){const n=parseInt(t,10);if(this._textLines[n]){const s=this._styleMap[t].line;e.set("".concat(s),!0)}}for(const t in this.styles)e.has(t)||delete this.styles[t]}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...e])}}C(Tr,"type","Textbox"),C(Tr,"textLayoutProperties",[...Zt.textLayoutProperties,"width"]),C(Tr,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),W.setClass(Tr);class Ud extends Oa{shouldPerformLayout(e){return!!e.target.clipPath&&super.shouldPerformLayout(e)}shouldLayoutClipPath(){return!1}calcLayoutResult(e,t){const{target:n}=e,{clipPath:s,group:i}=n;if(!s||!this.shouldPerformLayout(e))return;const{width:o,height:a}=tr(Qp(n,s)),l=new O(o,a);if(s.absolutePositioned)return{center:Ln(s.getRelativeCenterPoint(),void 0,i?i.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(n.calcOwnMatrix(),!0);if(this.shouldPerformLayout(e)){const{center:u=new O,correction:h=new O}=this.calcBoundingBox(t,e)||{};return{center:u.add(c),correction:h.subtract(c),size:l}}return{center:n.getRelativeCenterPoint().add(c),size:l}}}}C(Ud,"type","clip-path"),W.setClass(Ud);class $d extends Oa{getInitialSize(e,t){let{target:n}=e,{size:s}=t;return new O(n.width||s.x,n.height||s.y)}}C($d,"type","fixed"),W.setClass($d);class u_ extends Qs{subscribeTargets(e){const t=e.target;e.targets.reduce((n,s)=>(s.parent&&n.add(s.parent),n),new Set).forEach(n=>{n.layoutManager.subscribeTargets({target:n,targets:[t]})})}unsubscribeTargets(e){const t=e.target,n=t.getObjects();e.targets.reduce((s,i)=>(i.parent&&s.add(i.parent),s),new Set).forEach(s=>{!n.some(i=>i.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[t]})})}}class Kr extends Jr{static getDefaults(){return b(b({},super.getDefaults()),Kr.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Kr.ownDefaults),this.setOptions(t);const{left:n,top:s,layoutManager:i}=t;this.groupInit(e,{left:n,top:s,layoutManager:i??new u_})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.multiSelectionStacking==="selection-order"?this.add(...t):t.forEach(s=>{const i=this._objects.findIndex(a=>a.isInFrontOf(s)),o=i===-1?this.size():i;this.insertAt(o,s)})}canEnterGroup(e){return this.getObjects().some(t=>t.isDescendantOf(e)||e.isDescendantOf(t))?(Rr("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(e)}enterGroup(e,t){e.parent&&e.parent===e.group?e.parent._exitGroup(e):e.group&&e.parent!==e.group&&e.group.remove(e),this._enterGroup(e,t)}exitGroup(e,t){this._exitGroup(e,t),e.parent&&e.parent._enterGroup(e,!0)}_onAfterObjectsChange(e,t){super._onAfterObjectsChange(e,t);const n=new Set;t.forEach(s=>{const{parent:i}=s;i&&n.add(i)}),e===Iu?n.forEach(s=>{s._onAfterObjectsChange(Zo,t)}):n.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(e,t,n){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=b(b({hasControls:!1},n),{},{forActiveSelection:!0});for(let i=0;i<this._objects.length;i++)this._objects[i]._renderControls(e,s);super._renderControls(e,t),e.restore()}}C(Kr,"type","ActiveSelection"),C(Kr,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),W.setClass(Kr),W.setClass(Kr,"activeSelection");class h_{constructor(){C(this,"resources",{})}applyFilters(e,t,n,s,i){const o=i.getContext("2d");if(!o)return;o.drawImage(t,0,0,n,s);const a={sourceWidth:n,sourceHeight:s,imageData:o.getImageData(0,0,n,s),originalEl:t,originalImageData:o.getImageData(0,0,n,s),canvasEl:i,ctx:o,filterBackend:this};e.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===n&&l.height===s||(i.width=l.width,i.height=l.height),o.putImageData(l,0,0),a}}class gm{constructor(){let{tileSize:e=q.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),C(this,"resources",{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(e,t){this.dispose(),this.createWebGLCanvas(e,t)}createWebGLCanvas(e,t){const n=pt({width:e,height:t}),s=n.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=n,this.gl=s)}applyFilters(e,t,n,s,i,o){const a=this.gl,l=i.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,t));const u={originalWidth:t.width||t.naturalWidth||0,originalHeight:t.height||t.naturalHeight||0,sourceWidth:n,sourceHeight:s,destinationWidth:n,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,n,s,c?void 0:t),targetTexture:this.createTexture(a,n,s),originalTexture:c||this.createTexture(a,n,s,c?void 0:t),passes:e.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:i},h=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,h),e.forEach(d=>{d&&d.applyTo(u)}),function(d){const f=d.targetCanvas,m=f.width,v=f.height,w=d.destinationWidth,g=d.destinationHeight;m===w&&v===g||(f.width=w,f.height=g)}(u),this.copyGLTo2D(a,u),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(u.sourceTexture),a.deleteTexture(u.targetTexture),a.deleteFramebuffer(h),l.setTransform(1,0,0,1,0,0),u}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(e,t,n,s,i){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:u,TEXTURE_MAG_FILTER:h,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:m}=e,v=e.createTexture();return e.bindTexture(a,v),e.texParameteri(a,h,i||o),e.texParameteri(a,d,i||o),e.texParameteri(a,f,u),e.texParameteri(a,m,u),s?e.texImage2D(a,0,l,l,c,s):e.texImage2D(a,0,l,t,n,0,l,c,null),v}getCachedTexture(e,t,n){const{textureCache:s}=this;if(s[e])return s[e];{const i=this.createTexture(this.gl,t.width,t.height,t,n);return i&&(s[e]=i),i}}evictCachesForKey(e){this.textureCache[e]&&(this.gl.deleteTexture(this.textureCache[e]),delete this.textureCache[e])}copyGLTo2D(e,t){const n=e.canvas,s=t.targetCanvas,i=s.getContext("2d");if(!i)return;i.translate(0,s.height),i.scale(1,-1);const o=n.height-s.height;i.drawImage(n,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(e,t){const n=t.targetCanvas.getContext("2d"),s=t.destinationWidth,i=t.destinationHeight,o=s*i*4;if(!n)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);e.readPixels(0,0,s,i,e.RGBA,e.UNSIGNED_BYTE,a);const c=new ImageData(l,s,i);n.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const e=this.gl,t={renderer:"",vendor:""};if(!e)return t;const n=e.getExtension("WEBGL_debug_renderer_info");if(n){const s=e.getParameter(n.UNMASKED_RENDERER_WEBGL),i=e.getParameter(n.UNMASKED_VENDOR_WEBGL);s&&(t.renderer=s.toLowerCase()),i&&(t.vendor=i.toLowerCase())}return this.gpuInfo=t,t}}let pl;function d_(){const{WebGLProbe:r}=Wt();return r.queryWebGL(lr()),q.enableGLFiltering&&r.isSupported(q.textureSize)?new gm({tileSize:q.textureSize}):new h_}function ml(){return!pl&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(pl=d_()),pl}const f_=["filters","resizeFilter","src","crossOrigin","type"],pm=["cropX","cropY"];class ot extends Me{static getDefaults(){return b(b({},super.getDefaults()),ot.ownDefaults)}constructor(e,t){super(),C(this,"_lastScaleX",1),C(this,"_lastScaleY",1),C(this,"_filterScalingX",1),C(this,"_filterScalingY",1),this.filters=[],Object.assign(this,ot.ownDefaults),this.setOptions(t),this.cacheKey="texture".concat(Nr()),this.setElement(typeof e=="string"?(this.canvas&&bt(this.canvas.getElement())||Gn()).getElementById(e):e,t)}getElement(){return this._element}setElement(e){var t;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=e,this._originalElement=e,this._setWidthHeight(n),(t=e.classList)===null||t===void 0||t.add(ot.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(e){const t=ml(!1);t instanceof gm&&t.evictCachesForKey(e)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(e=>{const t=this[e];t&&Wt().dispose(t),this[e]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const e=this.getElement();return e?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}}_stroke(e){if(!this.stroke||this.strokeWidth===0)return;const t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,-n),e.lineTo(t,-n),e.lineTo(t,n),e.lineTo(-t,n),e.lineTo(-t,-n),e.closePath()}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=[];return this.filters.forEach(n=>{n&&t.push(n.toObject())}),b(b({},super.toObject([...pm,...e])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:t},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const e=[],t=this._element,n=-this.width/2,s=-this.height/2;let i=[],o=[],a="",l="";if(!t)return[];if(this.hasCrop()){const c=Nr();i.push('<clipPath id="imageCrop_'+c+`">
97
- `,' <rect x="'+n+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
98
- `,`</clipPath>
99
- `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),e.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(n-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(t.width||t.naturalWidth,'" height="').concat(t.height||t.naturalHeight,'"').concat(l).concat(a,`></image>
100
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(n,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
101
- `)],this.fill=c}return i=this.paintFirst!==_e?i.concat(o,e):i.concat(e,o),i}getSrc(e){const t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute("src")||"":t.src:this.src||""}getSvgSrc(e){return this.getSrc(e)}setSrc(e){let{crossOrigin:t,signal:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vo(e,{crossOrigin:t,signal:n}).then(s=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const e=this.resizeFilter,t=this.minimumScaleTrigger,n=this.getTotalObjectScaling(),s=n.x,i=n.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!e||s>t&&i>t)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=i);const a=pt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=e.scaleX=s,this._lastScaleY=e.scaleY=i,ml().applyFilters([e],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(e=e.filter(i=>i&&!i.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),e.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const t=this._originalElement,n=t.naturalWidth||t.width,s=t.naturalHeight||t.height;if(this._element===this._originalElement){const i=pt({width:n,height:s});this._element=i,this._filteredEl=i}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,n,s),this._lastScaleX=1,this._lastScaleY=1);ml().applyFilters(e,this._originalElement,n,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){const t=this._element;if(!t)return;const n=this._filterScalingX,s=this._filterScalingY,i=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=t.naturalWidth||t.width,u=t.naturalHeight||t.height,h=a*n,d=l*s,f=Math.min(i*n,c-h),m=Math.min(o*s,u-d),v=-i/2,w=-o/2,g=Math.min(i,c/n-a),p=Math.min(o,u/s-l);t&&e.drawImage(t,h,d,f,m,v,w,g,p)}_needsResize(){const e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:e,height:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=this.getOriginalSize();this.width=e||n.width,this.height=t||n.height}parsePreserveAspectRatioAttribute(){const e=sx(this.preserveAspectRatio||""),t=this.width,n=this.height,s={width:t,height:n};let i,o=this._element.width,a=this._element.height,l=1,c=1,u=0,h=0,d=0,f=0;return!e||e.alignX===Ke&&e.alignY===Ke?(l=t/o,c=n/a):(e.meetOrSlice==="meet"&&(l=c=_1(this._element,s),i=(t-o*l)/2,e.alignX==="Min"&&(u=-i),e.alignX==="Max"&&(u=i),i=(n-a*c)/2,e.alignY==="Min"&&(h=-i),e.alignY==="Max"&&(h=i)),e.meetOrSlice==="slice"&&(l=c=w1(this._element,s),i=o-t/l,e.alignX==="Mid"&&(d=i/2),e.alignX==="Max"&&(d=i),i=a-n/c,e.alignY==="Mid"&&(f=i/2),e.alignY==="Max"&&(f=i),o=t/l,a=n/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:u,offsetTop:h,cropX:d,cropY:f}}static fromObject(e,t){let{filters:n,resizeFilter:s,src:i,crossOrigin:o,type:a}=e,l=ie(e,f_);return Promise.all([vo(i,b(b({},t),{},{crossOrigin:o})),n&&Ys(n,t),s&&Ys([s],t),Ca(l,t)]).then(c=>{let[u,h=[],[d]=[],f={}]=c;return new this(u,b(b({},l),{},{src:i,filters:h,resizeFilter:d},f))})}static fromURL(e){let{crossOrigin:t=null,signal:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return vo(e,{crossOrigin:t,signal:n}).then(i=>new this(i,s))}static async fromElement(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const s=dr(e,this.ATTRIBUTE_NAMES,n);return this.fromURL(s["xlink:href"]||s.href,t,s).catch(i=>(Rr("log","Unable to parse Image",i),null))}}C(ot,"type","Image"),C(ot,"cacheProperties",[...hr,...pm]),C(ot,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),C(ot,"CSS_CANVAS","canvas-img"),C(ot,"ATTRIBUTE_NAMES",[...Vr,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),W.setClass(ot),W.setSVGClass(ot);Ta(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Da=r=>r.webgl!==void 0,zu="precision highp float",g_=`
102
- `.concat(zu,`;
103
- varying vec2 vTexCoord;
104
- uniform sampler2D uTexture;
105
- void main() {
106
- gl_FragColor = texture2D(uTexture, vTexCoord);
107
- }`),p_=["type"],m_=["type"],v_=new RegExp(zu,"g");class we{get type(){return this.constructor.type}constructor(){let e=ie(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p_);Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return g_}getVertexSource(){return`
108
- attribute vec2 aPosition;
109
- varying vec2 vTexCoord;
110
- void main() {
111
- vTexCoord = aPosition;
112
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
113
- }`}createProgram(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Wt();s!=="highp"&&(t=t.replace(v_,zu.replace("highp",s)));const i=e.createShader(e.VERTEX_SHADER),o=e.createShader(e.FRAGMENT_SHADER),a=e.createProgram();if(!i||!o||!a)throw new It("Vertex, fragment shader or program creation error");if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new It("Vertex shader compile error for ".concat(this.type,": ").concat(e.getShaderInfoLog(i)));if(e.shaderSource(o,t),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new It("Fragment shader compile error for ".concat(this.type,": ").concat(e.getShaderInfoLog(o)));if(e.attachShader(a,i),e.attachShader(a,o),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS))throw new It('Shader link error for "'.concat(this.type,'" ').concat(e.getProgramInfoLog(a)));const l=this.getUniformLocations(e,a)||{};return l.uStepW=e.getUniformLocation(a,"uStepW"),l.uStepH=e.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(e,a),uniformLocations:l}}getAttributeLocations(e,t){return{aPosition:e.getAttribLocation(t,"aPosition")}}getUniformLocations(e,t){const n=this.constructor.uniformLocations,s={};for(let i=0;i<n.length;i++)s[n[i]]=e.getUniformLocation(t,n[i]);return s}sendAttributeData(e,t,n){const s=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(s),e.vertexAttribPointer(s,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)}_setupFrameBuffer(e){const t=e.context;if(e.passes>1){const n=e.destinationWidth,s=e.destinationHeight;e.sourceWidth===n&&e.sourceHeight===s||(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,s)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)}else t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish()}_swapTextures(e){e.passes--,e.pass++;const t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t}isNeutralState(e){return!1}applyTo(e){Da(e)?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){}getCacheKey(){return this.type}retrieveShader(e){const t=this.getCacheKey();return e.programCache[t]||(e.programCache[t]=this.createProgram(e.context)),e.programCache[t]}applyToWebGL(e){const t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)}unbindAdditionalTexture(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)}sendUniformData(e,t){}createHelpLayer(e){if(!e.helpLayer){const{sourceWidth:t,sourceHeight:n}=e,s=pt({width:t,height:n});e.helpLayer=s}}toObject(){const e=Object.keys(this.constructor.defaults||{});return b({type:this.type},e.reduce((t,n)=>(t[n]=this[n],t),{}))}toJSON(){return this.toObject()}static async fromObject(e,t){return new this(ie(e,m_))}}C(we,"type","BaseFilter"),C(we,"uniformLocations",[]);const y_={multiply:`gl_FragColor.rgb *= uColor.rgb;
114
- `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
115
- `,add:`gl_FragColor.rgb += uColor.rgb;
116
- `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
117
- `,subtract:`gl_FragColor.rgb -= uColor.rgb;
118
- `,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
119
- `,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
120
- `,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
121
- `,overlay:`
122
- if (uColor.r < 0.5) {
123
- gl_FragColor.r *= 2.0 * uColor.r;
124
- } else {
125
- gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
126
- }
127
- if (uColor.g < 0.5) {
128
- gl_FragColor.g *= 2.0 * uColor.g;
129
- } else {
130
- gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
131
- }
132
- if (uColor.b < 0.5) {
133
- gl_FragColor.b *= 2.0 * uColor.b;
134
- } else {
135
- gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
136
- }
137
- `,tint:`
138
- gl_FragColor.rgb *= (1.0 - uColor.a);
139
- gl_FragColor.rgb += uColor.rgb;
140
- `};class Ri extends we{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
141
- precision highp float;
142
- uniform sampler2D uTexture;
143
- uniform vec4 uColor;
144
- varying vec2 vTexCoord;
145
- void main() {
146
- vec4 color = texture2D(uTexture, vTexCoord);
147
- gl_FragColor = color;
148
- if (color.a > 0.0) {
149
- `.concat(y_[this.mode],`
150
- }
151
- }
152
- `)}applyTo2d(e){let{imageData:{data:t}}=e;const n=new Q(this.color).getSource(),s=this.alpha,i=n[0]*s,o=n[1]*s,a=n[2]*s,l=1-s;for(let c=0;c<t.length;c+=4){const u=t[c],h=t[c+1],d=t[c+2];let f,m,v;switch(this.mode){case"multiply":f=u*i/255,m=h*o/255,v=d*a/255;break;case"screen":f=255-(255-u)*(255-i)/255,m=255-(255-h)*(255-o)/255,v=255-(255-d)*(255-a)/255;break;case"add":f=u+i,m=h+o,v=d+a;break;case"difference":f=Math.abs(u-i),m=Math.abs(h-o),v=Math.abs(d-a);break;case"subtract":f=u-i,m=h-o,v=d-a;break;case"darken":f=Math.min(u,i),m=Math.min(h,o),v=Math.min(d,a);break;case"lighten":f=Math.max(u,i),m=Math.max(h,o),v=Math.max(d,a);break;case"overlay":f=i<128?2*u*i/255:255-2*(255-u)*(255-i)/255,m=o<128?2*h*o/255:255-2*(255-h)*(255-o)/255,v=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":f=i+u-2*i*u/255,m=o+h-2*o*h/255,v=a+d-2*a*d/255;break;case"tint":f=i+u*l,m=o+h*l,v=a+d*l}t[c]=f,t[c+1]=m,t[c+2]=v}}sendUniformData(e,t){const n=new Q(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,e.uniform4fv(t.uColor,n)}}C(Ri,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),C(Ri,"type","BlendColor"),C(Ri,"uniformLocations",["uColor"]),W.setClass(Ri);const x_={multiply:`
153
- precision highp float;
154
- uniform sampler2D uTexture;
155
- uniform sampler2D uImage;
156
- uniform vec4 uColor;
157
- varying vec2 vTexCoord;
158
- varying vec2 vTexCoord2;
159
- void main() {
160
- vec4 color = texture2D(uTexture, vTexCoord);
161
- vec4 color2 = texture2D(uImage, vTexCoord2);
162
- color.rgba *= color2.rgba;
163
- gl_FragColor = color;
164
- }
165
- `,mask:`
166
- precision highp float;
167
- uniform sampler2D uTexture;
168
- uniform sampler2D uImage;
169
- uniform vec4 uColor;
170
- varying vec2 vTexCoord;
171
- varying vec2 vTexCoord2;
172
- void main() {
173
- vec4 color = texture2D(uTexture, vTexCoord);
174
- vec4 color2 = texture2D(uImage, vTexCoord2);
175
- color.a = color2.a;
176
- gl_FragColor = color;
177
- }
178
- `},__=["type","image"];class Ni extends we{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return x_[this.mode]}getVertexSource(){return`
179
- attribute vec2 aPosition;
180
- varying vec2 vTexCoord;
181
- varying vec2 vTexCoord2;
182
- uniform mat3 uTransformMatrix;
183
- void main() {
184
- vTexCoord = aPosition;
185
- vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
186
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
187
- }
188
- `}applyToWebGL(e){const t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),super.applyToWebGL(e),this.unbindAdditionalTexture(t,t.TEXTURE1)}createTexture(e,t){return e.getCachedTexture(t.cacheKey,t.getElement())}calculateMatrix(){const e=this.image,{width:t,height:n}=e.getElement();return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]}applyTo2d(e){let{imageData:{data:t,width:n,height:s},filterBackend:{resources:i}}=e;const o=this.image;i.blendImage||(i.blendImage=lr());const a=i.blendImage,l=a.getContext("2d");a.width!==n||a.height!==s?(a.width=n,a.height=s):l.clearRect(0,0,n,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,n,s);const c=l.getImageData(0,0,n,s).data;for(let u=0;u<t.length;u+=4){const h=t[u],d=t[u+1],f=t[u+2],m=t[u+3],v=c[u],w=c[u+1],g=c[u+2],p=c[u+3];switch(this.mode){case"multiply":t[u]=h*v/255,t[u+1]=d*w/255,t[u+2]=f*g/255,t[u+3]=m*p/255;break;case"mask":t[u+3]=p}}}sendUniformData(e,t){const n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)}toObject(){return b(b({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(e,t){let{type:n,image:s}=e,i=ie(e,__);return ot.fromObject(s,t).then(o=>new this(b(b({},i),{},{image:o})))}}C(Ni,"type","BlendImage"),C(Ni,"defaults",{mode:"multiply",alpha:1}),C(Ni,"uniformLocations",["uTransformMatrix","uImage"]),W.setClass(Ni);class Ii extends we{getFragmentSource(){return`
189
- precision highp float;
190
- uniform sampler2D uTexture;
191
- uniform vec2 uDelta;
192
- varying vec2 vTexCoord;
193
- const float nSamples = 15.0;
194
- vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
195
- float random(vec3 scale) {
196
- /* use the fragment position for a different seed per-pixel */
197
- return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
198
- }
199
- void main() {
200
- vec4 color = vec4(0.0);
201
- float totalC = 0.0;
202
- float totalA = 0.0;
203
- float offset = random(v3offset);
204
- for (float t = -nSamples; t <= nSamples; t++) {
205
- float percent = (t + offset - 0.5) / nSamples;
206
- vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
207
- float weight = 1.0 - abs(percent);
208
- float alpha = weight * sample.a;
209
- color.rgb += sample.rgb * alpha;
210
- color.a += alpha;
211
- totalA += weight;
212
- totalC += alpha;
213
- }
214
- gl_FragColor.rgb = color.rgb / totalC;
215
- gl_FragColor.a = color.a / totalA;
216
- }
217
- `}applyTo(e){Da(e)?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){let{imageData:{data:t,width:n,height:s}}=e;this.aspectRatio=n/s,this.horizontal=!0;let i=this.getBlurValue()*n;const o=new Uint8ClampedArray(t),a=15,l=4*n;for(let c=0;c<t.length;c+=4){let u=0,h=0,d=0,f=0,m=0;const v=c-c%l,w=v+l;for(let g=-14;g<a;g++){const p=g/a,y=4*Math.floor(i*p),x=1-Math.abs(p);let _=c+y;_<v?_=v:_>w&&(_=w);const E=t[_+3]*x;u+=t[_]*E,h+=t[_+1]*E,d+=t[_+2]*E,f+=E,m+=x}o[c]=u/f,o[c+1]=h/f,o[c+2]=d/f,o[c+3]=f/m}this.horizontal=!1,i=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let u=0,h=0,d=0,f=0,m=0;const v=c%l,w=o.length-l+v;for(let g=-14;g<a;g++){const p=g/a,y=Math.floor(i*p)*l,x=1-Math.abs(p);let _=c+y;_<v?_=v:_>w&&(_=w);const E=o[_+3]*x;u+=o[_]*E,h+=o[_+1]*E,d+=o[_+2]*E,f+=E,m+=x}t[c]=u/f,t[c+1]=h/f,t[c+2]=d/f,t[c+3]=f/m}}sendUniformData(e,t){const n=this.chooseRightDelta();e.uniform2fv(t.uDelta,n)}isNeutralState(){return this.blur===0}getBlurValue(){let e=1;const{horizontal:t,aspectRatio:n}=this;return t?n>1&&(e=1/n):n<1&&(e=n),e*this.blur*.12}chooseRightDelta(){const e=this.getBlurValue();return this.horizontal?[e,0]:[0,e]}}C(Ii,"type","Blur"),C(Ii,"defaults",{blur:0}),C(Ii,"uniformLocations",["uDelta"]),W.setClass(Ii);class zi extends we{getFragmentSource(){return`
218
- precision highp float;
219
- uniform sampler2D uTexture;
220
- uniform float uBrightness;
221
- varying vec2 vTexCoord;
222
- void main() {
223
- vec4 color = texture2D(uTexture, vTexCoord);
224
- color.rgb += uBrightness;
225
- gl_FragColor = color;
226
- }
227
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=Math.round(255*this.brightness);for(let s=0;s<t.length;s+=4)t[s]+=n,t[s+1]+=n,t[s+2]+=n}isNeutralState(){return this.brightness===0}sendUniformData(e,t){e.uniform1f(t.uBrightness,this.brightness)}}C(zi,"type","Brightness"),C(zi,"defaults",{brightness:0}),C(zi,"uniformLocations",["uBrightness"]),W.setClass(zi);const mm={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class On extends we{getFragmentSource(){return`
228
- precision highp float;
229
- uniform sampler2D uTexture;
230
- varying vec2 vTexCoord;
231
- uniform mat4 uColorMatrix;
232
- uniform vec4 uConstants;
233
- void main() {
234
- vec4 color = texture2D(uTexture, vTexCoord);
235
- color *= uColorMatrix;
236
- color += uConstants;
237
- gl_FragColor = color;
238
- }`}applyTo2d(e){const t=e.imageData.data,n=this.matrix,s=this.colorsOnly;for(let i=0;i<t.length;i+=4){const o=t[i],a=t[i+1],l=t[i+2];if(t[i]=o*n[0]+a*n[1]+l*n[2]+255*n[4],t[i+1]=o*n[5]+a*n[6]+l*n[7]+255*n[9],t[i+2]=o*n[10]+a*n[11]+l*n[12]+255*n[14],!s){const c=t[i+3];t[i]+=c*n[3],t[i+1]+=c*n[8],t[i+2]+=c*n[13],t[i+3]=o*n[15]+a*n[16]+l*n[17]+c*n[18]+255*n[19]}}}sendUniformData(e,t){const n=this.matrix,s=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,s),e.uniform4fv(t.uConstants,i)}toObject(){return b(b({},super.toObject()),{},{matrix:[...this.matrix]})}}function ln(r,e){var t;const n=(C(t=class extends On{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",r),C(t,"defaults",{colorsOnly:!1,matrix:e}),t);return W.setClass(n,r),n}C(On,"type","ColorMatrix"),C(On,"defaults",mm),C(On,"uniformLocations",["uColorMatrix","uConstants"]),W.setClass(On);ln("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);ln("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);ln("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);ln("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);ln("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);ln("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);ln("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Yd extends we{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(e),this.subFilters=e.subFilters||[]}applyTo(e){Da(e)&&(e.passes+=this.subFilters.length-1),this.subFilters.forEach(t=>{t.applyTo(e)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(e=>e.toObject())}}isNeutralState(){return!this.subFilters.some(e=>!e.isNeutralState())}static fromObject(e,t){return Promise.all((e.subFilters||[]).map(n=>W.getClass(n.type).fromObject(n,t))).then(n=>new this({subFilters:n}))}}C(Yd,"type","Composed"),W.setClass(Yd);class Bi extends we{getFragmentSource(){return`
239
- precision highp float;
240
- uniform sampler2D uTexture;
241
- uniform float uContrast;
242
- varying vec2 vTexCoord;
243
- void main() {
244
- vec4 color = texture2D(uTexture, vTexCoord);
245
- float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
246
- color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
247
- gl_FragColor = color;
248
- }`}isNeutralState(){return this.contrast===0}applyTo2d(e){let{imageData:{data:t}}=e;const n=Math.floor(255*this.contrast),s=259*(n+255)/(255*(259-n));for(let i=0;i<t.length;i+=4)t[i]=s*(t[i]-128)+128,t[i+1]=s*(t[i+1]-128)+128,t[i+2]=s*(t[i+2]-128)+128}sendUniformData(e,t){e.uniform1f(t.uContrast,this.contrast)}}C(Bi,"type","Contrast"),C(Bi,"defaults",{contrast:0}),C(Bi,"uniformLocations",["uContrast"]),W.setClass(Bi);const w_={Convolute_3_1:`
249
- precision highp float;
250
- uniform sampler2D uTexture;
251
- uniform float uMatrix[9];
252
- uniform float uStepW;
253
- uniform float uStepH;
254
- varying vec2 vTexCoord;
255
- void main() {
256
- vec4 color = vec4(0, 0, 0, 0);
257
- for (float h = 0.0; h < 3.0; h+=1.0) {
258
- for (float w = 0.0; w < 3.0; w+=1.0) {
259
- vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
260
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
261
- }
262
- }
263
- gl_FragColor = color;
264
- }
265
- `,Convolute_3_0:`
266
- precision highp float;
267
- uniform sampler2D uTexture;
268
- uniform float uMatrix[9];
269
- uniform float uStepW;
270
- uniform float uStepH;
271
- varying vec2 vTexCoord;
272
- void main() {
273
- vec4 color = vec4(0, 0, 0, 1);
274
- for (float h = 0.0; h < 3.0; h+=1.0) {
275
- for (float w = 0.0; w < 3.0; w+=1.0) {
276
- vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
277
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
278
- }
279
- }
280
- float alpha = texture2D(uTexture, vTexCoord).a;
281
- gl_FragColor = color;
282
- gl_FragColor.a = alpha;
283
- }
284
- `,Convolute_5_1:`
285
- precision highp float;
286
- uniform sampler2D uTexture;
287
- uniform float uMatrix[25];
288
- uniform float uStepW;
289
- uniform float uStepH;
290
- varying vec2 vTexCoord;
291
- void main() {
292
- vec4 color = vec4(0, 0, 0, 0);
293
- for (float h = 0.0; h < 5.0; h+=1.0) {
294
- for (float w = 0.0; w < 5.0; w+=1.0) {
295
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
296
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
297
- }
298
- }
299
- gl_FragColor = color;
300
- }
301
- `,Convolute_5_0:`
302
- precision highp float;
303
- uniform sampler2D uTexture;
304
- uniform float uMatrix[25];
305
- uniform float uStepW;
306
- uniform float uStepH;
307
- varying vec2 vTexCoord;
308
- void main() {
309
- vec4 color = vec4(0, 0, 0, 1);
310
- for (float h = 0.0; h < 5.0; h+=1.0) {
311
- for (float w = 0.0; w < 5.0; w+=1.0) {
312
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
313
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
314
- }
315
- }
316
- float alpha = texture2D(uTexture, vTexCoord).a;
317
- gl_FragColor = color;
318
- gl_FragColor.a = alpha;
319
- }
320
- `,Convolute_7_1:`
321
- precision highp float;
322
- uniform sampler2D uTexture;
323
- uniform float uMatrix[49];
324
- uniform float uStepW;
325
- uniform float uStepH;
326
- varying vec2 vTexCoord;
327
- void main() {
328
- vec4 color = vec4(0, 0, 0, 0);
329
- for (float h = 0.0; h < 7.0; h+=1.0) {
330
- for (float w = 0.0; w < 7.0; w+=1.0) {
331
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
332
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
333
- }
334
- }
335
- gl_FragColor = color;
336
- }
337
- `,Convolute_7_0:`
338
- precision highp float;
339
- uniform sampler2D uTexture;
340
- uniform float uMatrix[49];
341
- uniform float uStepW;
342
- uniform float uStepH;
343
- varying vec2 vTexCoord;
344
- void main() {
345
- vec4 color = vec4(0, 0, 0, 1);
346
- for (float h = 0.0; h < 7.0; h+=1.0) {
347
- for (float w = 0.0; w < 7.0; w+=1.0) {
348
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
349
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
350
- }
351
- }
352
- float alpha = texture2D(uTexture, vTexCoord).a;
353
- gl_FragColor = color;
354
- gl_FragColor.a = alpha;
355
- }
356
- `,Convolute_9_1:`
357
- precision highp float;
358
- uniform sampler2D uTexture;
359
- uniform float uMatrix[81];
360
- uniform float uStepW;
361
- uniform float uStepH;
362
- varying vec2 vTexCoord;
363
- void main() {
364
- vec4 color = vec4(0, 0, 0, 0);
365
- for (float h = 0.0; h < 9.0; h+=1.0) {
366
- for (float w = 0.0; w < 9.0; w+=1.0) {
367
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
368
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
369
- }
370
- }
371
- gl_FragColor = color;
372
- }
373
- `,Convolute_9_0:`
374
- precision highp float;
375
- uniform sampler2D uTexture;
376
- uniform float uMatrix[81];
377
- uniform float uStepW;
378
- uniform float uStepH;
379
- varying vec2 vTexCoord;
380
- void main() {
381
- vec4 color = vec4(0, 0, 0, 1);
382
- for (float h = 0.0; h < 9.0; h+=1.0) {
383
- for (float w = 0.0; w < 9.0; w+=1.0) {
384
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
385
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
386
- }
387
- }
388
- float alpha = texture2D(uTexture, vTexCoord).a;
389
- gl_FragColor = color;
390
- gl_FragColor.a = alpha;
391
- }
392
- `};class Vi extends we{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return w_[this.getCacheKey()]}applyTo2d(e){const t=e.imageData,n=t.data,s=this.matrix,i=Math.round(Math.sqrt(s.length)),o=Math.floor(i/2),a=t.width,l=t.height,c=e.ctx.createImageData(a,l),u=c.data,h=this.opaque?1:0;let d,f,m,v,w,g,p,y,x,_,E,D,k;for(E=0;E<l;E++)for(_=0;_<a;_++){for(w=4*(E*a+_),d=0,f=0,m=0,v=0,k=0;k<i;k++)for(D=0;D<i;D++)p=E+k-o,g=_+D-o,p<0||p>=l||g<0||g>=a||(y=4*(p*a+g),x=s[k*i+D],d+=n[y]*x,f+=n[y+1]*x,m+=n[y+2]*x,h||(v+=n[y+3]*x));u[w]=d,u[w+1]=f,u[w+2]=m,u[w+3]=h?n[w+3]:v}e.imageData=c}sendUniformData(e,t){e.uniform1fv(t.uMatrix,this.matrix)}toObject(){return b(b({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}C(Vi,"type","Convolute"),C(Vi,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),C(Vi,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),W.setClass(Vi);const vm="Gamma";class Wi extends we{getFragmentSource(){return`
393
- precision highp float;
394
- uniform sampler2D uTexture;
395
- uniform vec3 uGamma;
396
- varying vec2 vTexCoord;
397
- void main() {
398
- vec4 color = texture2D(uTexture, vTexCoord);
399
- vec3 correction = (1.0 / uGamma);
400
- color.r = pow(color.r, correction.r);
401
- color.g = pow(color.g, correction.g);
402
- color.b = pow(color.b, correction.b);
403
- gl_FragColor = color;
404
- gl_FragColor.rgb *= color.a;
405
- }
406
- `}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(e),this.gamma=e.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(e){let{imageData:{data:t}}=e;const n=this.gamma,s=1/n[0],i=1/n[1],o=1/n[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,i),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<t.length;l+=4)t[l]=a.r[t[l]],t[l+1]=a.g[t[l+1]],t[l+2]=a.b[t[l+2]]}sendUniformData(e,t){e.uniform3fv(t.uGamma,this.gamma)}isNeutralState(){const{gamma:e}=this;return e[0]===1&&e[1]===1&&e[2]===1}toObject(){return{type:vm,gamma:this.gamma.concat()}}}C(Wi,"type",vm),C(Wi,"defaults",{gamma:[1,1,1]}),C(Wi,"uniformLocations",["uGamma"]),W.setClass(Wi);const S_={average:`
407
- precision highp float;
408
- uniform sampler2D uTexture;
409
- varying vec2 vTexCoord;
410
- void main() {
411
- vec4 color = texture2D(uTexture, vTexCoord);
412
- float average = (color.r + color.b + color.g) / 3.0;
413
- gl_FragColor = vec4(average, average, average, color.a);
414
- }
415
- `,lightness:`
416
- precision highp float;
417
- uniform sampler2D uTexture;
418
- uniform int uMode;
419
- varying vec2 vTexCoord;
420
- void main() {
421
- vec4 col = texture2D(uTexture, vTexCoord);
422
- float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
423
- gl_FragColor = vec4(average, average, average, col.a);
424
- }
425
- `,luminosity:`
426
- precision highp float;
427
- uniform sampler2D uTexture;
428
- uniform int uMode;
429
- varying vec2 vTexCoord;
430
- void main() {
431
- vec4 col = texture2D(uTexture, vTexCoord);
432
- float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
433
- gl_FragColor = vec4(average, average, average, col.a);
434
- }
435
- `};class Hi extends we{applyTo2d(e){let{imageData:{data:t}}=e;for(let n,s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2];switch(this.mode){case"average":n=(i+o+a)/3;break;case"lightness":n=(Math.min(i,o,a)+Math.max(i,o,a))/2;break;case"luminosity":n=.21*i+.72*o+.07*a}t[s+2]=t[s+1]=t[s]=n}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return S_[this.mode]}sendUniformData(e,t){e.uniform1i(t.uMode,1)}isNeutralState(){return!1}}C(Hi,"type","Grayscale"),C(Hi,"defaults",{mode:"average"}),C(Hi,"uniformLocations",["uMode"]),W.setClass(Hi);const C_=b(b({},mm),{},{rotation:0});class vl extends On{calculateMatrix(){const e=this.rotation*Math.PI,t=or(e),n=ar(e),s=1/3,i=Math.sqrt(s)*n,o=1-t;this.matrix=[t+o/3,s*o-i,s*o+i,0,0,s*o+i,t+s*o,s*o-i,0,0,s*o-i,s*o+i,t+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(e){this.calculateMatrix(),super.applyTo(e)}toObject(){return{type:this.type,rotation:this.rotation}}}C(vl,"type","HueRotation"),C(vl,"defaults",C_),W.setClass(vl);class Xi extends we{applyTo2d(e){let{imageData:{data:t}}=e;for(let n=0;n<t.length;n+=4)t[n]=255-t[n],t[n+1]=255-t[n+1],t[n+2]=255-t[n+2],this.alpha&&(t[n+3]=255-t[n+3])}getFragmentSource(){return`
436
- precision highp float;
437
- uniform sampler2D uTexture;
438
- uniform int uInvert;
439
- uniform int uAlpha;
440
- varying vec2 vTexCoord;
441
- void main() {
442
- vec4 color = texture2D(uTexture, vTexCoord);
443
- if (uInvert == 1) {
444
- if (uAlpha == 1) {
445
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
446
- } else {
447
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
448
- }
449
- } else {
450
- gl_FragColor = color;
451
- }
452
- }
453
- `}isNeutralState(){return!this.invert}sendUniformData(e,t){e.uniform1i(t.uInvert,Number(this.invert)),e.uniform1i(t.uAlpha,Number(this.alpha))}}C(Xi,"type","Invert"),C(Xi,"defaults",{alpha:!1,invert:!0}),C(Xi,"uniformLocations",["uInvert","uAlpha"]),W.setClass(Xi);class Ui extends we{getFragmentSource(){return`
454
- precision highp float;
455
- uniform sampler2D uTexture;
456
- uniform float uStepH;
457
- uniform float uNoise;
458
- uniform float uSeed;
459
- varying vec2 vTexCoord;
460
- float rand(vec2 co, float seed, float vScale) {
461
- return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
462
- }
463
- void main() {
464
- vec4 color = texture2D(uTexture, vTexCoord);
465
- color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
466
- gl_FragColor = color;
467
- }
468
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=this.noise;for(let s=0;s<t.length;s+=4){const i=(.5-Math.random())*n;t[s]+=i,t[s+1]+=i,t[s+2]+=i}}sendUniformData(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())}isNeutralState(){return this.noise===0}}C(Ui,"type","Noise"),C(Ui,"defaults",{noise:0}),C(Ui,"uniformLocations",["uNoise","uSeed"]),W.setClass(Ui);class $i extends we{applyTo2d(e){let{imageData:{data:t,width:n,height:s}}=e;for(let i=0;i<s;i+=this.blocksize)for(let o=0;o<n;o+=this.blocksize){const a=4*i*n+4*o,l=t[a],c=t[a+1],u=t[a+2],h=t[a+3];for(let d=i;d<Math.min(i+this.blocksize,s);d++)for(let f=o;f<Math.min(o+this.blocksize,n);f++){const m=4*d*n+4*f;t[m]=l,t[m+1]=c,t[m+2]=u,t[m+3]=h}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
469
- precision highp float;
470
- uniform sampler2D uTexture;
471
- uniform float uBlocksize;
472
- uniform float uStepW;
473
- uniform float uStepH;
474
- varying vec2 vTexCoord;
475
- void main() {
476
- float blockW = uBlocksize * uStepW;
477
- float blockH = uBlocksize * uStepH;
478
- int posX = int(vTexCoord.x / blockW);
479
- int posY = int(vTexCoord.y / blockH);
480
- float fposX = float(posX);
481
- float fposY = float(posY);
482
- vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
483
- vec4 color = texture2D(uTexture, squareCoords);
484
- gl_FragColor = color;
485
- }
486
- `}sendUniformData(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}}C($i,"type","Pixelate"),C($i,"defaults",{blocksize:4}),C($i,"uniformLocations",["uBlocksize"]),W.setClass($i);class Yi extends we{getFragmentSource(){return`
487
- precision highp float;
488
- uniform sampler2D uTexture;
489
- uniform vec4 uLow;
490
- uniform vec4 uHigh;
491
- varying vec2 vTexCoord;
492
- void main() {
493
- gl_FragColor = texture2D(uTexture, vTexCoord);
494
- if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
495
- gl_FragColor.a = 0.0;
496
- }
497
- }
498
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=255*this.distance,s=new Q(this.color).getSource(),i=[s[0]-n,s[1]-n,s[2]-n],o=[s[0]+n,s[1]+n,s[2]+n];for(let a=0;a<t.length;a+=4){const l=t[a],c=t[a+1],u=t[a+2];l>i[0]&&c>i[1]&&u>i[2]&&l<o[0]&&c<o[1]&&u<o[2]&&(t[a+3]=0)}}sendUniformData(e,t){const n=new Q(this.color).getSource(),s=this.distance,i=[0+n[0]/255-s,0+n[1]/255-s,0+n[2]/255-s,1],o=[n[0]/255+s,n[1]/255+s,n[2]/255+s,1];e.uniform4fv(t.uLow,i),e.uniform4fv(t.uHigh,o)}}C(Yi,"type","RemoveColor"),C(Yi,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),C(Yi,"uniformLocations",["uLow","uHigh"]),W.setClass(Yi);class Gi extends we{sendUniformData(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)}getFilterWindow(){const e=this.tempScale;return Math.ceil(this.lanczosLobes/e)}getCacheKey(){const e=this.getFilterWindow();return"".concat(this.type,"_").concat(e)}getFragmentSource(){const e=this.getFilterWindow();return this.generateShader(e)}getTaps(){const e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),s=new Array(n);for(let i=1;i<=n;i++)s[i-1]=e(i*t);return s}generateShader(e){const t=new Array(e);for(let n=1;n<=e;n++)t[n-1]="".concat(n,".0 * uDelta");return`
499
- precision highp float;
500
- uniform sampler2D uTexture;
501
- uniform vec2 uDelta;
502
- varying vec2 vTexCoord;
503
- uniform float uTaps[`.concat(e,`];
504
- void main() {
505
- vec4 color = texture2D(uTexture, vTexCoord);
506
- float sum = 1.0;
507
- `).concat(t.map((n,s)=>`
508
- color += texture2D(uTexture, vTexCoord + `.concat(n,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(n,") * uTaps[").concat(s,`];
509
- sum += 2.0 * uTaps[`).concat(s,`];
510
- `)).join(`
511
- `),`
512
- gl_FragColor = color / sum;
513
- }
514
- `)}applyToForWebgl(e){e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,super.applyTo(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,super.applyTo(e),e.sourceHeight=e.destinationHeight}applyTo(e){Da(e)?this.applyToForWebgl(e):this.applyTo2d(e)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(e){return t=>{if(t>=e||t<=-e)return 0;if(t<11920929e-14&&t>-11920929e-14)return 1;const n=(t*=Math.PI)/e;return Math.sin(t)/t*Math.sin(n)/n}}applyTo2d(e){const t=e.imageData,n=this.scaleX,s=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/s;const i=t.width,o=t.height,a=Math.round(i*n),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(e,i,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(e,i,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(e,i,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(e,i,o,a,l):new ImageData(a,l),e.imageData=c}sliceByTwo(e,t,n,s,i){const o=e.imageData,a=.5;let l=!1,c=!1,u=t*a,h=n*a;const d=e.filterBackend.resources;let f=0,m=0;const v=t;let w=0;d.sliceByTwo||(d.sliceByTwo=lr());const g=d.sliceByTwo;(g.width<1.5*t||g.height<n)&&(g.width=1.5*t,g.height=n);const p=g.getContext("2d");for(p.clearRect(0,0,1.5*t,n),p.putImageData(o,0,0),s=Math.floor(s),i=Math.floor(i);!l||!c;)t=u,n=h,s<Math.floor(u*a)?u=Math.floor(u*a):(u=s,l=!0),i<Math.floor(h*a)?h=Math.floor(h*a):(h=i,c=!0),p.drawImage(g,f,m,t,n,v,w,u,h),f=v,m=w,w+=h;return p.getImageData(f,m,s,i)}lanczosResize(e,t,n,s,i){const o=e.imageData.data,a=e.ctx.createImageData(s,i),l=a.data,c=this.lanczosCreate(this.lanczosLobes),u=this.rcpScaleX,h=this.rcpScaleY,d=2/this.rcpScaleX,f=2/this.rcpScaleY,m=Math.ceil(u*this.lanczosLobes/2),v=Math.ceil(h*this.lanczosLobes/2),w={},g={x:0,y:0},p={x:0,y:0};return function y(x){let _,E,D,k,N,L,X,T,M,R,B;for(g.x=(x+.5)*u,p.x=Math.floor(g.x),_=0;_<i;_++){for(g.y=(_+.5)*h,p.y=Math.floor(g.y),N=0,L=0,X=0,T=0,M=0,E=p.x-m;E<=p.x+m;E++)if(!(E<0||E>=t)){R=Math.floor(1e3*Math.abs(E-g.x)),w[R]||(w[R]={});for(let j=p.y-v;j<=p.y+v;j++)j<0||j>=n||(B=Math.floor(1e3*Math.abs(j-g.y)),w[R][B]||(w[R][B]=c(Math.sqrt(Math.pow(R*d,2)+Math.pow(B*f,2))/1e3)),D=w[R][B],D>0&&(k=4*(j*t+E),N+=D,L+=D*o[k],X+=D*o[k+1],T+=D*o[k+2],M+=D*o[k+3]))}k=4*(_*s+x),l[k]=L/N,l[k+1]=X/N,l[k+2]=T/N,l[k+3]=M/N}return++x<s?y(x):a}(0)}bilinearFiltering(e,t,n,s,i){let o,a,l,c,u,h,d,f,m,v,w,g,p,y=0;const x=this.rcpScaleX,_=this.rcpScaleY,E=4*(t-1),D=e.imageData.data,k=e.ctx.createImageData(s,i),N=k.data;for(d=0;d<i;d++)for(f=0;f<s;f++)for(u=Math.floor(x*f),h=Math.floor(_*d),m=x*f-u,v=_*d-h,p=4*(h*t+u),w=0;w<4;w++)o=D[p+w],a=D[p+4+w],l=D[p+E+w],c=D[p+E+4+w],g=o*(1-m)*(1-v)+a*m*(1-v)+l*v*(1-m)+c*m*v,N[y++]=g;return k}hermiteFastResize(e,t,n,s,i){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),u=e.imageData.data,h=e.ctx.createImageData(s,i),d=h.data;for(let f=0;f<i;f++)for(let m=0;m<s;m++){const v=4*(m+f*s);let w=0,g=0,p=0,y=0,x=0,_=0,E=0;const D=(f+.5)*a;for(let k=Math.floor(f*a);k<(f+1)*a;k++){const N=Math.abs(D-(k+.5))/c,L=(m+.5)*o,X=N*N;for(let T=Math.floor(m*o);T<(m+1)*o;T++){let M=Math.abs(L-(T+.5))/l;const R=Math.sqrt(X+M*M);R>1&&R<-1||(w=2*R*R*R-3*R*R+1,w>0&&(M=4*(T+k*t),E+=w*u[M+3],p+=w,u[M+3]<255&&(w=w*u[M+3]/250),y+=w*u[M],x+=w*u[M+1],_+=w*u[M+2],g+=w))}}d[v]=y/g,d[v+1]=x/g,d[v+2]=_/g,d[v+3]=E/p}return h}}C(Gi,"type","Resize"),C(Gi,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),C(Gi,"uniformLocations",["uDelta","uTaps"]),W.setClass(Gi);class Ki extends we{getFragmentSource(){return`
515
- precision highp float;
516
- uniform sampler2D uTexture;
517
- uniform float uSaturation;
518
- varying vec2 vTexCoord;
519
- void main() {
520
- vec4 color = texture2D(uTexture, vTexCoord);
521
- float rgMax = max(color.r, color.g);
522
- float rgbMax = max(rgMax, color.b);
523
- color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
524
- color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
525
- color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
526
- gl_FragColor = color;
527
- }
528
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=-this.saturation;for(let s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2],l=Math.max(i,o,a);t[s]+=l!==i?(l-i)*n:0,t[s+1]+=l!==o?(l-o)*n:0,t[s+2]+=l!==a?(l-a)*n:0}}sendUniformData(e,t){e.uniform1f(t.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}C(Ki,"type","Saturation"),C(Ki,"defaults",{saturation:0}),C(Ki,"uniformLocations",["uSaturation"]),W.setClass(Ki);class qi extends we{getFragmentSource(){return`
529
- precision highp float;
530
- uniform sampler2D uTexture;
531
- uniform float uVibrance;
532
- varying vec2 vTexCoord;
533
- void main() {
534
- vec4 color = texture2D(uTexture, vTexCoord);
535
- float max = max(color.r, max(color.g, color.b));
536
- float avg = (color.r + color.g + color.b) / 3.0;
537
- float amt = (abs(max - avg) * 2.0) * uVibrance;
538
- color.r += max != color.r ? (max - color.r) * amt : 0.00;
539
- color.g += max != color.g ? (max - color.g) * amt : 0.00;
540
- color.b += max != color.b ? (max - color.b) * amt : 0.00;
541
- gl_FragColor = color;
542
- }
543
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=-this.vibrance;for(let s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2],l=Math.max(i,o,a),c=(i+o+a)/3,u=2*Math.abs(l-c)/255*n;t[s]+=l!==i?(l-i)*u:0,t[s+1]+=l!==o?(l-o)*u:0,t[s+2]+=l!==a?(l-a)*u:0}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}C(qi,"type","Vibrance"),C(qi,"defaults",{vibrance:0}),C(qi,"uniformLocations",["uVibrance"]),W.setClass(qi);const Gd=["#000000","#ffffff","#9CA3AF","#EF4444","#F97316","#EAB308","#22C55E","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#6366F1"];function b_({onSubmit:r,onClose:e}){const t=V.useRef(null),n=V.useRef(null),s=V.useRef(null),[i,o]=V.useState("freehand"),[a,l]=V.useState("#3B82F6"),[c,u]=V.useState("#000000"),[h,d]=V.useState(!1),[f,m]=V.useState(!1),[v,w]=V.useState([]),[g,p]=V.useState([]),y=V.useRef(null),x=V.useRef(!1);V.useEffect(()=>{if(!t.current||n.current)return;const T=new bc(t.current,{backgroundColor:"#ffffff",selection:!0});n.current=T;const M=()=>{if(!s.current)return;const{width:B,height:j}=s.current.getBoundingClientRect();T.setDimensions({width:B,height:j})};M();const R=new ResizeObserver(M);return s.current&&R.observe(s.current),w([JSON.stringify(T.toJSON())]),()=>{R.disconnect(),T.dispose(),n.current=null}},[]);const _=V.useCallback(()=>{const T=n.current;if(!T)return;const M=JSON.stringify(T.toJSON());w(R=>[...R,M]),p([])},[]);V.useEffect(()=>{const T=n.current;if(T){if(T.isDrawingMode=!1,T.selection=!0,T.defaultCursor="default",T.off("mouse:down"),T.off("mouse:move"),T.off("mouse:up"),i==="freehand"){T.isDrawingMode=!0;const M=new ra(T);M.color=c,M.width=2,T.freeDrawingBrush=M,T.on("path:created",()=>_())}else if(i==="eraser")T.selection=!1,T.defaultCursor="crosshair",T.on("mouse:down",M=>{const R=T.findTarget(M.e);R&&(T.remove(R),_())});else if(i!=="select"){if(i==="text")T.selection=!1,T.defaultCursor="text",T.on("mouse:down",M=>{if(x.current)return;const R=T.getScenePoint(M.e),B=new Tr("Text",{left:R.x,top:R.y,fontSize:16,fill:c,width:120});T.add(B),T.setActiveObject(B),B.enterEditing(),_()});else if(["rectangle","circle","line","arrow"].includes(i)){T.selection=!1,T.defaultCursor="crosshair";let M=null;T.on("mouse:down",R=>{x.current=!0;const B=T.getScenePoint(R.e);y.current={x:B.x,y:B.y},i==="rectangle"?(M=new Ct({left:B.x,top:B.y,width:0,height:0,fill:a==="transparent"?"transparent":a,stroke:c,strokeWidth:2,selectable:!1}),T.add(M)):i==="circle"?(M=new Lt({left:B.x,top:B.y,radius:0,fill:a==="transparent"?"transparent":a,stroke:c,strokeWidth:2,selectable:!1}),T.add(M)):(i==="line"||i==="arrow")&&(M=new Nt([B.x,B.y,B.x,B.y],{stroke:c,strokeWidth:2,selectable:!1}),T.add(M))}),T.on("mouse:move",R=>{if(!y.current||!M)return;const B=T.getScenePoint(R.e),j=y.current;if(i==="rectangle"){const I=Math.min(j.x,B.x),P=Math.min(j.y,B.y);M.set({left:I,top:P,width:Math.abs(B.x-j.x),height:Math.abs(B.y-j.y)})}else if(i==="circle"){const I=Math.abs(B.x-j.x)/2,P=Math.abs(B.y-j.y)/2;M.set({left:Math.min(j.x,B.x),top:Math.min(j.y,B.y),radius:Math.max(I,P)})}else(i==="line"||i==="arrow")&&M.set({x2:B.x,y2:B.y});T.requestRenderAll()}),T.on("mouse:up",()=>{if(M){if(M.set({selectable:!0}),T.setActiveObject(M),i==="arrow"&&y.current){const R=M.x1,B=M.y1,j=M.x2,I=M.y2,P=Math.atan2(I-B,j-R),z=12,A=new Nt([j-z*Math.cos(P-Math.PI/6),I-z*Math.sin(P-Math.PI/6),j,I],{stroke:c,strokeWidth:2,selectable:!1}),U=new Nt([j-z*Math.cos(P+Math.PI/6),I-z*Math.sin(P+Math.PI/6),j,I],{stroke:c,strokeWidth:2,selectable:!1});T.add(A,U)}_()}M=null,y.current=null,x.current=!1})}}}},[i,a,c,_]);const E=()=>{const T=n.current;if(!T||v.length<=1)return;const M=v[v.length-1],R=v[v.length-2];p(B=>[...B,M]),w(B=>B.slice(0,-1)),T.loadFromJSON(JSON.parse(R)).then(()=>T.requestRenderAll())},D=()=>{const T=n.current;if(!T||g.length===0)return;const M=g[g.length-1];p(R=>R.slice(0,-1)),w(R=>[...R,M]),T.loadFromJSON(JSON.parse(M)).then(()=>T.requestRenderAll())},k=()=>{const T=n.current;T&&(T.clear(),T.backgroundColor="#ffffff",T.requestRenderAll(),_())},N=()=>{const T=n.current;if(!T)return;const M=T.toDataURL({format:"png",multiplier:1});r(M,T.getWidth(),T.getHeight())},L=V.useCallback(()=>{const T=n.current;if(!T)return;const M=T.getActiveObjects();if(M.length>0){for(const R of M)T.remove(R);T.discardActiveObject(),T.requestRenderAll(),_()}},[_]);V.useEffect(()=>{const T=M=>{if(M.key==="Delete"||M.key==="Backspace"){const R=n.current;if(R){const B=R.getActiveObject();if(B&&B.type==="textbox"&&B.isEditing)return}L()}(M.metaKey||M.ctrlKey)&&M.key==="z"&&(M.preventDefault(),M.shiftKey?D():E())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[L,v,g]);const X=[{id:"select",label:"Select",icon:"◇"},{id:"freehand",label:"Freehand",icon:"✎"},{id:"rectangle",label:"Rectangle",icon:"□"},{id:"circle",label:"Circle",icon:"○"},{id:"line",label:"Line",icon:"╱"},{id:"arrow",label:"Arrow",icon:"→"},{id:"text",label:"Text",icon:"T"},{id:"eraser",label:"Eraser",icon:"⊘"}];return S.jsxs("div",{className:"flex flex-col h-full","data-testid":"design-canvas",children:[S.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-1 bg-bv-bg border-b border-bv-border text-[10px] shrink-0 flex-wrap",children:[X.map(T=>S.jsx("button",{title:T.label,onClick:()=>o(T.id),className:`w-7 h-[26px] rounded border flex items-center justify-center text-[13px] cursor-pointer transition-all
544
- ${i===T.id?"bg-bv-teal/10 border-bv-teal text-bv-teal":"bg-transparent border-transparent text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text"}`,children:T.icon},T.id)),S.jsx("div",{className:"w-px h-[18px] bg-bv-border mx-1"}),S.jsx("span",{className:"text-[9px] font-mono text-bv-muted ml-0.5 mr-1",children:"Fill"}),S.jsxs("div",{className:"relative",children:[S.jsx("button",{className:"w-5 h-5 rounded border-2 border-bv-border cursor-pointer transition-all hover:border-bv-teal hover:scale-110",style:{background:a==="transparent"?"repeating-conic-gradient(#ddd 0% 25%, white 0% 50%) 50%/8px 8px":a},onClick:()=>{d(!h),m(!1)}}),h&&S.jsxs("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bv-bg border border-bv-border rounded-lg shadow-lg p-2 w-[164px]",children:[S.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted mb-1.5",children:"Fill Color"}),S.jsx("div",{className:"grid grid-cols-6 gap-1 mb-2",children:Gd.map(T=>S.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer transition-all hover:scale-110
545
- ${a===T?"ring-2 ring-bv-teal ring-offset-1":"border border-black/10"}`,style:{background:T},onClick:()=>{l(T),d(!1)}},T))}),S.jsxs("div",{className:"pt-1 border-t border-bv-border flex items-center gap-1.5",children:[S.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer border border-bv-border
546
- ${a==="transparent"?"ring-2 ring-bv-teal ring-offset-1":""}`,style:{background:"repeating-conic-gradient(#ddd 0% 25%, white 0% 50%) 50%/8px 8px"},onClick:()=>{l("transparent"),d(!1)}}),S.jsx("span",{className:"text-[9px] text-bv-muted",children:"None"})]})]})]}),S.jsx("span",{className:"text-[9px] font-mono text-bv-muted ml-1.5 mr-1",children:"Stroke"}),S.jsxs("div",{className:"relative",children:[S.jsx("button",{className:"w-5 h-5 rounded border-2 border-bv-border cursor-pointer transition-all hover:border-bv-teal hover:scale-110",style:{background:c},onClick:()=>{m(!f),d(!1)}}),f&&S.jsxs("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bv-bg border border-bv-border rounded-lg shadow-lg p-2 w-[164px]",children:[S.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted mb-1.5",children:"Stroke Color"}),S.jsx("div",{className:"grid grid-cols-6 gap-1",children:Gd.map(T=>S.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer transition-all hover:scale-110
547
- ${c===T?"ring-2 ring-bv-teal ring-offset-1":"border border-black/10"}`,style:{background:T},onClick:()=>{u(T),m(!1)}},T))})]})]}),S.jsx("div",{className:"w-px h-[18px] bg-bv-border mx-1"}),S.jsx("button",{title:"Undo",onClick:E,disabled:v.length<=1,className:`w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer transition-all
548
- ${v.length<=1?"opacity-35 cursor-default":"text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text"}`,children:"↶"}),S.jsx("button",{title:"Redo",onClick:D,disabled:g.length===0,className:`w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer transition-all
549
- ${g.length===0?"opacity-35 cursor-default":"text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text"}`,children:"↷"}),S.jsx("button",{title:"Clear canvas",onClick:k,className:"w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text transition-all",children:"🗑"})]}),S.jsx("div",{ref:s,className:"flex-1 bg-white cursor-crosshair overflow-hidden relative",children:S.jsx("canvas",{ref:t})}),S.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 bg-bv-bg border-t border-bv-border text-[10px] shrink-0",children:[S.jsx("div",{className:"flex gap-1.5",children:e&&S.jsx("button",{onClick:e,className:"px-2.5 py-0.5 rounded border border-bv-border bg-bv-bg text-bv-muted text-[10px] font-medium cursor-pointer hover:bg-bv-orange/10 hover:border-bv-orange hover:text-bv-orange transition-all",children:"✕ Close"})}),S.jsx("button",{onClick:N,className:"px-2.5 py-0.5 rounded border border-bv-teal bg-bv-teal text-white text-[10px] font-medium cursor-pointer hover:bg-bv-teal/80 transition-all",children:"✓ Queue as Change"})]})]})}function T_(){const[r,e]=V.useState(null);V.useEffect(()=>{up(()=>{Qt({type:"REGISTER",role:"design"})}),cp(s=>{s.type==="ELEMENT_CONTEXT"&&e({componentName:s.componentName,instanceCount:s.instanceCount,target:s.target,context:s.context,insertMode:s.insertMode??"after"})}),_u()},[]);const t=(s,i,o)=>{Qt({type:"DESIGN_SUBMIT",image:s,componentName:(r==null?void 0:r.componentName)??"",target:(r==null?void 0:r.target)??{tag:"",classes:"",innerText:""},context:(r==null?void 0:r.context)??"",insertMode:(r==null?void 0:r.insertMode)??"after",canvasWidth:i,canvasHeight:o})},n=()=>{Qt({type:"DESIGN_CLOSE"})};return S.jsxs("div",{className:"h-screen w-screen flex flex-col",children:[r&&S.jsxs("div",{className:"px-2 py-1 bg-bv-surface border-b border-bv-border text-[10px] font-mono text-bv-muted shrink-0",children:[r.insertMode," <",r.target.tag,".",r.target.classes.split(" ")[0],">"," ","in ",r.componentName]}),S.jsx("div",{className:"flex-1 overflow-hidden",children:S.jsx(b_,{onSubmit:t,onClose:n})})]})}const k_=new URLSearchParams(window.location.search),O_=k_.get("mode"),Kd=[{id:"design",label:"Design"},{id:"message",label:"Message"},{id:"draw",label:"Draw"}];function E_(){return O_==="design"?S.jsx(T_,{}):S.jsx(D_,{})}function D_(){const[r,e]=V.useState(!1),[t,n]=V.useState(null),[s,i]=V.useState("design"),o=M0();V.useEffect(()=>{const _=up(()=>{e(!0);try{const k=localStorage.getItem("tw-panel-container");k&&k!=="popover"&&Re("overlay",{type:"SWITCH_CONTAINER",container:k})}catch{}}),E=s0(()=>e(!1)),D=cp(k=>{k.type==="ELEMENT_SELECTED"?n({componentName:k.componentName,instanceCount:k.instanceCount,classes:k.classes,tailwindConfig:k.tailwindConfig}):k.type==="QUEUE_UPDATE"?o.handleQueueUpdate({draftCount:k.draftCount,committedCount:k.committedCount,implementingCount:k.implementingCount,implementedCount:k.implementedCount,partialCount:k.partialCount,errorCount:k.errorCount,draft:k.draft,commits:k.commits}):k.type==="PATCH_UPDATE"&&o.handlePatchUpdate({staged:k.staged,committed:k.committed,implementing:k.implementing,implemented:k.implemented,patches:k.patches})});return _u(),e(i0()),()=>{_(),E(),D()}},[]);const{draft:a,committed:l,implementing:c,implemented:u,partial:h,error:d}=o.counts,f=new Map(o.patches.filter(_=>_.status==="staged").map(_=>[_.id,{id:_.id,kind:_.kind??"class-change",elementKey:_.elementKey,status:_.status,originalClass:_.originalClass,newClass:_.newClass,property:_.property,timestamp:_.timestamp,component:_.component,message:_.message,image:_.image}])),m=new Set(o.queueState.draft.map(_=>_.id)),v=[...o.queueState.draft.map(_=>f.get(_.id)??_),...o.patches.filter(_=>_.status==="staged"&&!m.has(_.id)).map(_=>f.get(_.id))],w=o.queueState.commits.filter(_=>_.status==="committed"),g=o.queueState.commits.filter(_=>_.status==="implementing"),p=o.queueState.commits.filter(_=>_.status==="implemented"),y=S.jsxs("div",{className:"flex items-center justify-center px-3 py-1.5 border-t border-bv-border shrink-0 gap-2.5",children:[S.jsx(Ti,{label:"draft",count:a,items:v,activeColor:"text-bv-text",onDiscard:_=>o.discard(_),onCommitAll:()=>o.commitAll(),onDiscardAll:()=>o.discardAll()}),S.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),S.jsx(Ti,{label:"committed",count:l,items:w.flatMap(_=>_.patches),activeColor:"text-bv-orange"}),S.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),S.jsx(Ti,{label:"implementing",count:c,items:g.flatMap(_=>_.patches),activeColor:"text-bv-orange"}),S.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),S.jsx(Ti,{label:"implemented",count:u,items:p.flatMap(_=>_.patches),activeColor:"text-bv-teal"})]});if(!r)return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6",children:[S.jsx("div",{className:"w-2 h-2 rounded-full bg-bv-orange animate-pulse"}),S.jsx("span",{className:"text-bv-text-mid text-[12px]",children:"Waiting for connection…"})]}),y]});if(!t)return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsx(id,{tabs:Kd,activeTab:s,onTabChange:i}),S.jsx("div",{className:"flex-1 overflow-auto",children:s==="message"?S.jsx(od,{draft:v,currentElementKey:"",onAddMessage:(_,E)=>o.stageMessage(_,E),onDiscard:_=>o.discard(_)}):S.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6",children:[S.jsx("span",{className:"text-3xl mb-2 opacity-30",children:"⊕"}),S.jsx("span",{className:"text-bv-text-mid text-[12px]",children:"Click an element to inspect"})]})}),y]});const x=r0(t.classes);return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsx("div",{className:"px-3 pt-3 pb-2 border-b border-bv-border",children:S.jsxs("div",{className:"flex items-start justify-between gap-2",children:[S.jsxs("div",{className:"font-[family-name:var(--font-display)] font-bold text-[13px] text-bv-text leading-tight",children:[t.componentName," ",S.jsxs("span",{className:"font-[family-name:var(--font-ui)] font-normal text-bv-text-mid",children:["— ",t.instanceCount," instance",t.instanceCount!==1?"s":""," on this page"]})]}),S.jsx(A0,{})]})}),S.jsx(id,{tabs:Kd,activeTab:s,onTabChange:i}),S.jsxs("div",{className:"flex-1 overflow-auto",children:[s==="design"&&S.jsx(P0,{componentName:t.componentName,instanceCount:t.instanceCount,parsedClasses:x,tailwindConfig:t.tailwindConfig,patchManager:o}),s==="message"&&S.jsx(od,{draft:v,currentElementKey:t.componentName,onAddMessage:(_,E)=>o.stageMessage(_,E,t.componentName),onDiscard:_=>o.discard(_)}),s==="draw"&&S.jsx(L0,{componentName:t.componentName,instanceCount:t.instanceCount})]}),y]})}yl.createRoot(document.getElementById("root")).render(S.jsx(Fm.StrictMode,{children:S.jsx(E_,{})}));