@oh-just-another/diagram 0.1.1 → 0.2.0

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,17 +1,19 @@
1
- var Q6=Object.create;var Kg=Object.defineProperty;var J6=Object.getOwnPropertyDescriptor;var eP=Object.getOwnPropertyNames;var tP=Object.getPrototypeOf,nP=Object.prototype.hasOwnProperty;var Ht=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ho=(e,t)=>{for(var n in t)Kg(e,n,{get:t[n],enumerable:!0})},oP=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of eP(t))!nP.call(e,a)&&a!==n&&Kg(e,a,{get:()=>t[a],enumerable:!(o=J6(t,a))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?Q6(tP(e)):{},oP(t||!e||!e.__esModule?Kg(n,"default",{value:e,enumerable:!0}):n,e));var E3=Ht(je=>{"use strict";function ex(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Ph(a,t))e[o]=t,e[n]=a,n=o;else break e}}function Do(e){return e.length===0?null:e[0]}function Nh(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var o=0,a=e.length,r=a>>>1;o<r;){var s=2*(o+1)-1,i=e[s],l=s+1,c=e[l];if(0>Ph(i,n))l<a&&0>Ph(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Ph(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Ph(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}je.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(b3=performance,je.unstable_now=function(){return b3.now()}):($g=Date,A3=$g.now(),je.unstable_now=function(){return $g.now()-A3});var b3,$g,A3,pa=[],fr=[],aP=1,Un=null,Ut=3,tx=!1,gu=!1,xu=!1,nx=!1,L3=typeof setTimeout=="function"?setTimeout:null,k3=typeof clearTimeout=="function"?clearTimeout:null,v3=typeof setImmediate<"u"?setImmediate:null;function Bh(e){for(var t=Do(fr);t!==null;){if(t.callback===null)Nh(fr);else if(t.startTime<=e)Nh(fr),t.sortIndex=t.expirationTime,ex(pa,t);else break;t=Do(fr)}}function ox(e){if(xu=!1,Bh(e),!gu)if(Do(pa)!==null)gu=!0,sl||(sl=!0,rl());else{var t=Do(fr);t!==null&&ax(ox,t.startTime-e)}}var sl=!1,bu=-1,w3=5,_3=-1;function C3(){return nx?!0:!(je.unstable_now()-_3<w3)}function Qg(){if(nx=!1,sl){var e=je.unstable_now();_3=e;var t=!0;try{e:{gu=!1,xu&&(xu=!1,k3(bu),bu=-1),tx=!0;var n=Ut;try{t:{for(Bh(e),Un=Do(pa);Un!==null&&!(Un.expirationTime>e&&C3());){var o=Un.callback;if(typeof o=="function"){Un.callback=null,Ut=Un.priorityLevel;var a=o(Un.expirationTime<=e);if(e=je.unstable_now(),typeof a=="function"){Un.callback=a,Bh(e),t=!0;break t}Un===Do(pa)&&Nh(pa),Bh(e)}else Nh(pa);Un=Do(pa)}if(Un!==null)t=!0;else{var r=Do(fr);r!==null&&ax(ox,r.startTime-e),t=!1}}break e}finally{Un=null,Ut=n,tx=!1}t=void 0}}finally{t?rl():sl=!1}}}var rl;typeof v3=="function"?rl=function(){v3(Qg)}:typeof MessageChannel<"u"?(Jg=new MessageChannel,S3=Jg.port2,Jg.port1.onmessage=Qg,rl=function(){S3.postMessage(null)}):rl=function(){L3(Qg,0)};var Jg,S3;function ax(e,t){bu=L3(function(){e(je.unstable_now())},t)}je.unstable_IdlePriority=5;je.unstable_ImmediatePriority=1;je.unstable_LowPriority=4;je.unstable_NormalPriority=3;je.unstable_Profiling=null;je.unstable_UserBlockingPriority=2;je.unstable_cancelCallback=function(e){e.callback=null};je.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):w3=0<e?Math.floor(1e3/e):5};je.unstable_getCurrentPriorityLevel=function(){return Ut};je.unstable_next=function(e){switch(Ut){case 1:case 2:case 3:var t=3;break;default:t=Ut}var n=Ut;Ut=t;try{return e()}finally{Ut=n}};je.unstable_requestPaint=function(){nx=!0};je.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Ut;Ut=e;try{return t()}finally{Ut=n}};je.unstable_scheduleCallback=function(e,t,n){var o=je.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?o+n:o):n=o,e){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return a=n+a,e={id:aP++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,ex(fr,e),Do(pa)===null&&e===Do(fr)&&(xu?(k3(bu),bu=-1):xu=!0,ax(ox,n-o))):(e.sortIndex=a,ex(pa,e),gu||tx||(gu=!0,sl||(sl=!0,rl()))),e};je.unstable_shouldYield=C3;je.unstable_wrapCallback=function(e){var t=Ut;return function(){var n=Ut;Ut=t;try{return e.apply(this,arguments)}finally{Ut=n}}}});var I3=Ht((f$,T3)=>{"use strict";T3.exports=E3()});var U3=Ht(te=>{"use strict";var ix=Symbol.for("react.transitional.element"),rP=Symbol.for("react.portal"),sP=Symbol.for("react.fragment"),iP=Symbol.for("react.strict_mode"),lP=Symbol.for("react.profiler"),cP=Symbol.for("react.consumer"),uP=Symbol.for("react.context"),dP=Symbol.for("react.forward_ref"),fP=Symbol.for("react.suspense"),pP=Symbol.for("react.memo"),P3=Symbol.for("react.lazy"),hP=Symbol.for("react.activity"),M3=Symbol.iterator;function mP(e){return e===null||typeof e!="object"?null:(e=M3&&e[M3]||e["@@iterator"],typeof e=="function"?e:null)}var B3={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N3=Object.assign,z3={};function ll(e,t,n){this.props=e,this.context=t,this.refs=z3,this.updater=n||B3}ll.prototype.isReactComponent={};ll.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ll.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function F3(){}F3.prototype=ll.prototype;function lx(e,t,n){this.props=e,this.context=t,this.refs=z3,this.updater=n||B3}var cx=lx.prototype=new F3;cx.constructor=lx;N3(cx,ll.prototype);cx.isPureReactComponent=!0;var R3=Array.isArray;function sx(){}var Ue={H:null,A:null,T:null,S:null},H3=Object.prototype.hasOwnProperty;function ux(e,t,n){var o=n.ref;return{$$typeof:ix,type:e,key:t,ref:o!==void 0?o:null,props:n}}function yP(e,t){return ux(e.type,t,e.props)}function dx(e){return typeof e=="object"&&e!==null&&e.$$typeof===ix}function gP(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var O3=/\/+/g;function rx(e,t){return typeof e=="object"&&e!==null&&e.key!=null?gP(""+e.key):t.toString(36)}function xP(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(sx,sx):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function il(e,t,n,o,a){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case ix:case rP:s=!0;break;case P3:return s=e._init,il(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+rx(e,0):o,R3(a)?(n="",s!=null&&(n=s.replace(O3,"$&/")+"/"),il(a,t,n,"",function(c){return c})):a!=null&&(dx(a)&&(a=yP(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(O3,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(R3(e))for(var l=0;l<e.length;l++)o=e[l],r=i+rx(o,l),s+=il(o,t,n,r,a);else if(l=mP(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+rx(o,l++),s+=il(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return il(xP(e),t,n,o,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function zh(e,t,n){if(e==null)return e;var o=[],a=0;return il(e,o,"","",function(r){return t.call(n,r,a++)}),o}function bP(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var D3=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},AP={map:zh,forEach:function(e,t,n){zh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return zh(e,function(){t++}),t},toArray:function(e){return zh(e,function(t){return t})||[]},only:function(e){if(!dx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};te.Activity=hP;te.Children=AP;te.Component=ll;te.Fragment=sP;te.Profiler=lP;te.PureComponent=lx;te.StrictMode=iP;te.Suspense=fP;te.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Ue;te.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Ue.H.useMemoCache(e)}};te.cache=function(e){return function(){return e.apply(null,arguments)}};te.cacheSignal=function(){return null};te.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=N3({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!H3.call(t,r)||r==="key"||r==="__self"||r==="__source"||r==="ref"&&t.ref===void 0||(o[r]=t[r]);var r=arguments.length-2;if(r===1)o.children=n;else if(1<r){for(var s=Array(r),i=0;i<r;i++)s[i]=arguments[i+2];o.children=s}return ux(e.type,a,o)};te.createContext=function(e){return e={$$typeof:uP,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:cP,_context:e},e};te.createElement=function(e,t,n){var o,a={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)H3.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(a[o]=t[o]);var s=arguments.length-2;if(s===1)a.children=n;else if(1<s){for(var i=Array(s),l=0;l<s;l++)i[l]=arguments[l+2];a.children=i}if(e&&e.defaultProps)for(o in s=e.defaultProps,s)a[o]===void 0&&(a[o]=s[o]);return ux(e,r,a)};te.createRef=function(){return{current:null}};te.forwardRef=function(e){return{$$typeof:dP,render:e}};te.isValidElement=dx;te.lazy=function(e){return{$$typeof:P3,_payload:{_status:-1,_result:e},_init:bP}};te.memo=function(e,t){return{$$typeof:pP,type:e,compare:t===void 0?null:t}};te.startTransition=function(e){var t=Ue.T,n={};Ue.T=n;try{var o=e(),a=Ue.S;a!==null&&a(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(sx,D3)}catch(r){D3(r)}finally{t!==null&&n.types!==null&&(t.types=n.types),Ue.T=t}};te.unstable_useCacheRefresh=function(){return Ue.H.useCacheRefresh()};te.use=function(e){return Ue.H.use(e)};te.useActionState=function(e,t,n){return Ue.H.useActionState(e,t,n)};te.useCallback=function(e,t){return Ue.H.useCallback(e,t)};te.useContext=function(e){return Ue.H.useContext(e)};te.useDebugValue=function(){};te.useDeferredValue=function(e,t){return Ue.H.useDeferredValue(e,t)};te.useEffect=function(e,t){return Ue.H.useEffect(e,t)};te.useEffectEvent=function(e){return Ue.H.useEffectEvent(e)};te.useId=function(){return Ue.H.useId()};te.useImperativeHandle=function(e,t,n){return Ue.H.useImperativeHandle(e,t,n)};te.useInsertionEffect=function(e,t){return Ue.H.useInsertionEffect(e,t)};te.useLayoutEffect=function(e,t){return Ue.H.useLayoutEffect(e,t)};te.useMemo=function(e,t){return Ue.H.useMemo(e,t)};te.useOptimistic=function(e,t){return Ue.H.useOptimistic(e,t)};te.useReducer=function(e,t,n){return Ue.H.useReducer(e,t,n)};te.useRef=function(e){return Ue.H.useRef(e)};te.useState=function(e){return Ue.H.useState(e)};te.useSyncExternalStore=function(e,t,n){return Ue.H.useSyncExternalStore(e,t,n)};te.useTransition=function(){return Ue.H.useTransition()};te.version="19.2.6"});var re=Ht((h$,G3)=>{"use strict";G3.exports=U3()});var q3=Ht(Vt=>{"use strict";var vP=re();function W3(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function pr(){}var jt={d:{f:pr,r:function(){throw Error(W3(522))},D:pr,C:pr,L:pr,m:pr,X:pr,S:pr,M:pr},p:0,findDOMNode:null},SP=Symbol.for("react.portal");function LP(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:SP,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var Au=vP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function Fh(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}Vt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=jt;Vt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(W3(299));return LP(e,t,null,n)};Vt.flushSync=function(e){var t=Au.T,n=jt.p;try{if(Au.T=null,jt.p=2,e)return e()}finally{Au.T=t,jt.p=n,jt.d.f()}};Vt.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,jt.d.C(e,t))};Vt.prefetchDNS=function(e){typeof e=="string"&&jt.d.D(e)};Vt.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=Fh(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?jt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&jt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};Vt.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=Fh(t.as,t.crossOrigin);jt.d.M(e,{crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&jt.d.M(e)};Vt.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=Fh(n,t.crossOrigin);jt.d.L(e,n,{crossOrigin:o,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};Vt.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=Fh(t.as,t.crossOrigin);jt.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else jt.d.m(e)};Vt.requestFormReset=function(e){jt.d.r(e)};Vt.unstable_batchedUpdates=function(e,t){return e(t)};Vt.useFormState=function(e,t,n){return Au.H.useFormState(e,t,n)};Vt.useFormStatus=function(){return Au.H.useHostTransitionStatus()};Vt.version="19.2.6"});var ha=Ht((y$,V3)=>{"use strict";function j3(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(j3)}catch(e){console.error(e)}}j3(),V3.exports=q3()});var aE=Ht(u0=>{"use strict";var ht=I3(),xw=re(),kP=ha();function O(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function bw(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function sd(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Aw(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function vw(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Z3(e){if(sd(e)!==e)throw Error(O(188))}function wP(e){var t=e.alternate;if(!t){if(t=sd(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,o=t;;){var a=n.return;if(a===null)break;var r=a.alternate;if(r===null){if(o=a.return,o!==null){n=o;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===n)return Z3(a),e;if(r===o)return Z3(a),t;r=r.sibling}throw Error(O(188))}if(n.return!==o.return)n=a,o=r;else{for(var s=!1,i=a.child;i;){if(i===n){s=!0,n=a,o=r;break}if(i===o){s=!0,o=a,n=r;break}i=i.sibling}if(!s){for(i=r.child;i;){if(i===n){s=!0,n=r,o=a;break}if(i===o){s=!0,o=r,n=a;break}i=i.sibling}if(!s)throw Error(O(189))}}if(n.alternate!==o)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function Sw(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=Sw(e),t!==null)return t;e=e.sibling}return null}var qe=Object.assign,_P=Symbol.for("react.element"),Hh=Symbol.for("react.transitional.element"),Eu=Symbol.for("react.portal"),hl=Symbol.for("react.fragment"),Lw=Symbol.for("react.strict_mode"),jx=Symbol.for("react.profiler"),kw=Symbol.for("react.consumer"),Sa=Symbol.for("react.context"),H1=Symbol.for("react.forward_ref"),Vx=Symbol.for("react.suspense"),Zx=Symbol.for("react.suspense_list"),U1=Symbol.for("react.memo"),hr=Symbol.for("react.lazy");Symbol.for("react.scope");var Xx=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var CP=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var X3=Symbol.iterator;function vu(e){return e===null||typeof e!="object"?null:(e=X3&&e[X3]||e["@@iterator"],typeof e=="function"?e:null)}var EP=Symbol.for("react.client.reference");function Yx(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===EP?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case hl:return"Fragment";case jx:return"Profiler";case Lw:return"StrictMode";case Vx:return"Suspense";case Zx:return"SuspenseList";case Xx:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Eu:return"Portal";case Sa:return e.displayName||"Context";case kw:return(e._context.displayName||"Context")+".Consumer";case H1:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U1:return t=e.displayName||null,t!==null?t:Yx(e.type)||"Memo";case hr:t=e._payload,e=e._init;try{return Yx(e(t))}catch{}}return null}var Tu=Array.isArray,K=xw.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,we=kP.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Os={pending:!1,data:null,method:null,action:null},Kx=[],ml=-1;function Fo(e){return{current:e}}function kt(e){0>ml||(e.current=Kx[ml],Kx[ml]=null,ml--)}function Ne(e,t){ml++,Kx[ml]=e.current,e.current=t}var zo=Fo(null),Vu=Fo(null),wr=Fo(null),bm=Fo(null);function Am(e,t){switch(Ne(wr,t),Ne(Vu,e),Ne(zo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?tw(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=tw(t),e=qC(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}kt(zo),Ne(zo,e)}function Ol(){kt(zo),kt(Vu),kt(wr)}function $x(e){e.memoizedState!==null&&Ne(bm,e);var t=zo.current,n=qC(t,e.type);t!==n&&(Ne(Vu,e),Ne(zo,n))}function vm(e){Vu.current===e&&(kt(zo),kt(Vu)),bm.current===e&&(kt(bm),od._currentValue=Os)}var fx,Y3;function Ts(e){if(fx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);fx=t&&t[1]||"",Y3=-1<n.stack.indexOf(`
1
+ var OP=Object.create;var lx=Object.defineProperty;var DP=Object.getOwnPropertyDescriptor;var PP=Object.getOwnPropertyNames;var BP=Object.getPrototypeOf,NP=Object.prototype.hasOwnProperty;var Ut=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yo=(e,t)=>{for(var n in t)lx(e,n,{get:t[n],enumerable:!0})},zP=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of PP(t))!NP.call(e,a)&&a!==n&&lx(e,a,{get:()=>t[a],enumerable:!(o=DP(t,a))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?OP(BP(e)):{},zP(t||!e||!e.__esModule?lx(n,"default",{value:e,enumerable:!0}):n,e));var X3=Ut(Ve=>{"use strict";function fx(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Zh(a,t))e[o]=t,e[n]=a,n=o;else break e}}function No(e){return e.length===0?null:e[0]}function Yh(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var o=0,a=e.length,r=a>>>1;o<r;){var s=2*(o+1)-1,i=e[s],l=s+1,c=e[l];if(0>Zh(i,n))l<a&&0>Zh(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Zh(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Zh(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}Ve.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(F3=performance,Ve.unstable_now=function(){return F3.now()}):(cx=Date,H3=cx.now(),Ve.unstable_now=function(){return cx.now()-H3});var F3,cx,H3,ma=[],pr=[],FP=1,Gn=null,Gt=3,px=!1,Su=!1,Lu=!1,hx=!1,W3=typeof setTimeout=="function"?setTimeout:null,q3=typeof clearTimeout=="function"?clearTimeout:null,U3=typeof setImmediate<"u"?setImmediate:null;function Xh(e){for(var t=No(pr);t!==null;){if(t.callback===null)Yh(pr);else if(t.startTime<=e)Yh(pr),t.sortIndex=t.expirationTime,fx(ma,t);else break;t=No(pr)}}function mx(e){if(Lu=!1,Xh(e),!Su)if(No(ma)!==null)Su=!0,ll||(ll=!0,il());else{var t=No(pr);t!==null&&yx(mx,t.startTime-e)}}var ll=!1,ku=-1,V3=5,j3=-1;function Z3(){return hx?!0:!(Ve.unstable_now()-j3<V3)}function ux(){if(hx=!1,ll){var e=Ve.unstable_now();j3=e;var t=!0;try{e:{Su=!1,Lu&&(Lu=!1,q3(ku),ku=-1),px=!0;var n=Gt;try{t:{for(Xh(e),Gn=No(ma);Gn!==null&&!(Gn.expirationTime>e&&Z3());){var o=Gn.callback;if(typeof o=="function"){Gn.callback=null,Gt=Gn.priorityLevel;var a=o(Gn.expirationTime<=e);if(e=Ve.unstable_now(),typeof a=="function"){Gn.callback=a,Xh(e),t=!0;break t}Gn===No(ma)&&Yh(ma),Xh(e)}else Yh(ma);Gn=No(ma)}if(Gn!==null)t=!0;else{var r=No(pr);r!==null&&yx(mx,r.startTime-e),t=!1}}break e}finally{Gn=null,Gt=n,px=!1}t=void 0}}finally{t?il():ll=!1}}}var il;typeof U3=="function"?il=function(){U3(ux)}:typeof MessageChannel<"u"?(dx=new MessageChannel,G3=dx.port2,dx.port1.onmessage=ux,il=function(){G3.postMessage(null)}):il=function(){W3(ux,0)};var dx,G3;function yx(e,t){ku=W3(function(){e(Ve.unstable_now())},t)}Ve.unstable_IdlePriority=5;Ve.unstable_ImmediatePriority=1;Ve.unstable_LowPriority=4;Ve.unstable_NormalPriority=3;Ve.unstable_Profiling=null;Ve.unstable_UserBlockingPriority=2;Ve.unstable_cancelCallback=function(e){e.callback=null};Ve.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V3=0<e?Math.floor(1e3/e):5};Ve.unstable_getCurrentPriorityLevel=function(){return Gt};Ve.unstable_next=function(e){switch(Gt){case 1:case 2:case 3:var t=3;break;default:t=Gt}var n=Gt;Gt=t;try{return e()}finally{Gt=n}};Ve.unstable_requestPaint=function(){hx=!0};Ve.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Gt;Gt=e;try{return t()}finally{Gt=n}};Ve.unstable_scheduleCallback=function(e,t,n){var o=Ve.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?o+n:o):n=o,e){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return a=n+a,e={id:FP++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,fx(pr,e),No(ma)===null&&e===No(pr)&&(Lu?(q3(ku),ku=-1):Lu=!0,yx(mx,n-o))):(e.sortIndex=a,fx(ma,e),Su||px||(Su=!0,ll||(ll=!0,il()))),e};Ve.unstable_shouldYield=Z3;Ve.unstable_wrapCallback=function(e){var t=Gt;return function(){var n=Gt;Gt=t;try{return e.apply(this,arguments)}finally{Gt=n}}}});var K3=Ut((UQ,Y3)=>{"use strict";Y3.exports=X3()});var ik=Ut(te=>{"use strict";var bx=Symbol.for("react.transitional.element"),HP=Symbol.for("react.portal"),UP=Symbol.for("react.fragment"),GP=Symbol.for("react.strict_mode"),WP=Symbol.for("react.profiler"),qP=Symbol.for("react.consumer"),VP=Symbol.for("react.context"),jP=Symbol.for("react.forward_ref"),ZP=Symbol.for("react.suspense"),XP=Symbol.for("react.memo"),tk=Symbol.for("react.lazy"),YP=Symbol.for("react.activity"),$3=Symbol.iterator;function KP(e){return e===null||typeof e!="object"?null:(e=$3&&e[$3]||e["@@iterator"],typeof e=="function"?e:null)}var nk={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ok=Object.assign,ak={};function ul(e,t,n){this.props=e,this.context=t,this.refs=ak,this.updater=n||nk}ul.prototype.isReactComponent={};ul.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ul.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rk(){}rk.prototype=ul.prototype;function Ax(e,t,n){this.props=e,this.context=t,this.refs=ak,this.updater=n||nk}var vx=Ax.prototype=new rk;vx.constructor=Ax;ok(vx,ul.prototype);vx.isPureReactComponent=!0;var Q3=Array.isArray;function xx(){}var Ue={H:null,A:null,T:null,S:null},sk=Object.prototype.hasOwnProperty;function Sx(e,t,n){var o=n.ref;return{$$typeof:bx,type:e,key:t,ref:o!==void 0?o:null,props:n}}function $P(e,t){return Sx(e.type,t,e.props)}function Lx(e){return typeof e=="object"&&e!==null&&e.$$typeof===bx}function QP(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var J3=/\/+/g;function gx(e,t){return typeof e=="object"&&e!==null&&e.key!=null?QP(""+e.key):t.toString(36)}function JP(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(xx,xx):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function cl(e,t,n,o,a){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case bx:case HP:s=!0;break;case tk:return s=e._init,cl(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+gx(e,0):o,Q3(a)?(n="",s!=null&&(n=s.replace(J3,"$&/")+"/"),cl(a,t,n,"",function(c){return c})):a!=null&&(Lx(a)&&(a=$P(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(J3,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(Q3(e))for(var l=0;l<e.length;l++)o=e[l],r=i+gx(o,l),s+=cl(o,t,n,r,a);else if(l=KP(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+gx(o,l++),s+=cl(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return cl(JP(e),t,n,o,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function Kh(e,t,n){if(e==null)return e;var o=[],a=0;return cl(e,o,"","",function(r){return t.call(n,r,a++)}),o}function e7(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ek=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},t7={map:Kh,forEach:function(e,t,n){Kh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Kh(e,function(){t++}),t},toArray:function(e){return Kh(e,function(t){return t})||[]},only:function(e){if(!Lx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};te.Activity=YP;te.Children=t7;te.Component=ul;te.Fragment=UP;te.Profiler=WP;te.PureComponent=Ax;te.StrictMode=GP;te.Suspense=ZP;te.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Ue;te.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Ue.H.useMemoCache(e)}};te.cache=function(e){return function(){return e.apply(null,arguments)}};te.cacheSignal=function(){return null};te.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=ok({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!sk.call(t,r)||r==="key"||r==="__self"||r==="__source"||r==="ref"&&t.ref===void 0||(o[r]=t[r]);var r=arguments.length-2;if(r===1)o.children=n;else if(1<r){for(var s=Array(r),i=0;i<r;i++)s[i]=arguments[i+2];o.children=s}return Sx(e.type,a,o)};te.createContext=function(e){return e={$$typeof:VP,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:qP,_context:e},e};te.createElement=function(e,t,n){var o,a={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)sk.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(a[o]=t[o]);var s=arguments.length-2;if(s===1)a.children=n;else if(1<s){for(var i=Array(s),l=0;l<s;l++)i[l]=arguments[l+2];a.children=i}if(e&&e.defaultProps)for(o in s=e.defaultProps,s)a[o]===void 0&&(a[o]=s[o]);return Sx(e,r,a)};te.createRef=function(){return{current:null}};te.forwardRef=function(e){return{$$typeof:jP,render:e}};te.isValidElement=Lx;te.lazy=function(e){return{$$typeof:tk,_payload:{_status:-1,_result:e},_init:e7}};te.memo=function(e,t){return{$$typeof:XP,type:e,compare:t===void 0?null:t}};te.startTransition=function(e){var t=Ue.T,n={};Ue.T=n;try{var o=e(),a=Ue.S;a!==null&&a(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(xx,ek)}catch(r){ek(r)}finally{t!==null&&n.types!==null&&(t.types=n.types),Ue.T=t}};te.unstable_useCacheRefresh=function(){return Ue.H.useCacheRefresh()};te.use=function(e){return Ue.H.use(e)};te.useActionState=function(e,t,n){return Ue.H.useActionState(e,t,n)};te.useCallback=function(e,t){return Ue.H.useCallback(e,t)};te.useContext=function(e){return Ue.H.useContext(e)};te.useDebugValue=function(){};te.useDeferredValue=function(e,t){return Ue.H.useDeferredValue(e,t)};te.useEffect=function(e,t){return Ue.H.useEffect(e,t)};te.useEffectEvent=function(e){return Ue.H.useEffectEvent(e)};te.useId=function(){return Ue.H.useId()};te.useImperativeHandle=function(e,t,n){return Ue.H.useImperativeHandle(e,t,n)};te.useInsertionEffect=function(e,t){return Ue.H.useInsertionEffect(e,t)};te.useLayoutEffect=function(e,t){return Ue.H.useLayoutEffect(e,t)};te.useMemo=function(e,t){return Ue.H.useMemo(e,t)};te.useOptimistic=function(e,t){return Ue.H.useOptimistic(e,t)};te.useReducer=function(e,t,n){return Ue.H.useReducer(e,t,n)};te.useRef=function(e){return Ue.H.useRef(e)};te.useState=function(e){return Ue.H.useState(e)};te.useSyncExternalStore=function(e,t,n){return Ue.H.useSyncExternalStore(e,t,n)};te.useTransition=function(){return Ue.H.useTransition()};te.version="19.2.6"});var re=Ut((WQ,lk)=>{"use strict";lk.exports=ik()});var uk=Ut(jt=>{"use strict";var n7=re();function ck(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function hr(){}var Vt={d:{f:hr,r:function(){throw Error(ck(522))},D:hr,C:hr,L:hr,m:hr,X:hr,S:hr,M:hr},p:0,findDOMNode:null},o7=Symbol.for("react.portal");function a7(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o7,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var _u=n7.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function $h(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}jt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Vt;jt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(ck(299));return a7(e,t,null,n)};jt.flushSync=function(e){var t=_u.T,n=Vt.p;try{if(_u.T=null,Vt.p=2,e)return e()}finally{_u.T=t,Vt.p=n,Vt.d.f()}};jt.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,Vt.d.C(e,t))};jt.prefetchDNS=function(e){typeof e=="string"&&Vt.d.D(e)};jt.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=$h(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?Vt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&Vt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};jt.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=$h(t.as,t.crossOrigin);Vt.d.M(e,{crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&Vt.d.M(e)};jt.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=$h(n,t.crossOrigin);Vt.d.L(e,n,{crossOrigin:o,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};jt.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=$h(t.as,t.crossOrigin);Vt.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else Vt.d.m(e)};jt.requestFormReset=function(e){Vt.d.r(e)};jt.unstable_batchedUpdates=function(e,t){return e(t)};jt.useFormState=function(e,t,n){return _u.H.useFormState(e,t,n)};jt.useFormStatus=function(){return _u.H.useHostTransitionStatus()};jt.version="19.2.6"});var ya=Ut((VQ,fk)=>{"use strict";function dk(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dk)}catch(e){console.error(e)}}dk(),fk.exports=uk()});var kE=Ut(S0=>{"use strict";var mt=K3(),z_=re(),r7=ya();function O(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function F_(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function dd(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function H_(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function U_(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function pk(e){if(dd(e)!==e)throw Error(O(188))}function s7(e){var t=e.alternate;if(!t){if(t=dd(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,o=t;;){var a=n.return;if(a===null)break;var r=a.alternate;if(r===null){if(o=a.return,o!==null){n=o;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===n)return pk(a),e;if(r===o)return pk(a),t;r=r.sibling}throw Error(O(188))}if(n.return!==o.return)n=a,o=r;else{for(var s=!1,i=a.child;i;){if(i===n){s=!0,n=a,o=r;break}if(i===o){s=!0,o=a,n=r;break}i=i.sibling}if(!s){for(i=r.child;i;){if(i===n){s=!0,n=r,o=a;break}if(i===o){s=!0,o=r,n=a;break}i=i.sibling}if(!s)throw Error(O(189))}}if(n.alternate!==o)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function G_(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=G_(e),t!==null)return t;e=e.sibling}return null}var qe=Object.assign,i7=Symbol.for("react.element"),Qh=Symbol.for("react.transitional.element"),Ou=Symbol.for("react.portal"),yl=Symbol.for("react.fragment"),W_=Symbol.for("react.strict_mode"),o1=Symbol.for("react.profiler"),q_=Symbol.for("react.consumer"),ka=Symbol.for("react.context"),Q1=Symbol.for("react.forward_ref"),a1=Symbol.for("react.suspense"),r1=Symbol.for("react.suspense_list"),J1=Symbol.for("react.memo"),mr=Symbol.for("react.lazy");Symbol.for("react.scope");var s1=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var l7=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var hk=Symbol.iterator;function wu(e){return e===null||typeof e!="object"?null:(e=hk&&e[hk]||e["@@iterator"],typeof e=="function"?e:null)}var c7=Symbol.for("react.client.reference");function i1(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===c7?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case yl:return"Fragment";case o1:return"Profiler";case W_:return"StrictMode";case a1:return"Suspense";case r1:return"SuspenseList";case s1:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Ou:return"Portal";case ka:return e.displayName||"Context";case q_:return(e._context.displayName||"Context")+".Consumer";case Q1:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J1:return t=e.displayName||null,t!==null?t:i1(e.type)||"Memo";case mr:t=e._payload,e=e._init;try{return i1(e(t))}catch{}}return null}var Du=Array.isArray,K=z_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=r7.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ds={pending:!1,data:null,method:null,action:null},l1=[],gl=-1;function Go(e){return{current:e}}function _t(e){0>gl||(e.current=l1[gl],l1[gl]=null,gl--)}function Ne(e,t){gl++,l1[gl]=e.current,e.current=t}var Uo=Go(null),$u=Go(null),wr=Go(null),Mm=Go(null);function Rm(e,t){switch(Ne(wr,t),Ne($u,e),Ne(Uo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?v_(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=v_(t),e=uE(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_t(Uo),Ne(Uo,e)}function Pl(){_t(Uo),_t($u),_t(wr)}function c1(e){e.memoizedState!==null&&Ne(Mm,e);var t=Uo.current,n=uE(t,e.type);t!==n&&(Ne($u,e),Ne(Uo,n))}function Om(e){$u.current===e&&(_t(Uo),_t($u)),Mm.current===e&&(_t(Mm),ld._currentValue=Ds)}var kx,mk;function Is(e){if(kx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);kx=t&&t[1]||"",mk=-1<n.stack.indexOf(`
2
2
  at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+fx+e+Y3}var px=!1;function hx(e,t){if(!e||px)return"";px=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(p){var f=p}Reflect.construct(e,[],d)}else{try{d.call()}catch(p){f=p}e.call(d.prototype)}}else{try{throw Error()}catch(p){f=p}(d=e())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(p){if(p&&f&&typeof p.stack=="string")return[p.stack,f.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=o.DetermineComponentFrameRoot(),s=r[0],i=r[1];if(s&&i){var l=s.split(`
3
+ `+kx+e+mk}var _x=!1;function wx(e,t){if(!e||_x)return"";_x=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(p){var f=p}Reflect.construct(e,[],d)}else{try{d.call()}catch(p){f=p}e.call(d.prototype)}}else{try{throw Error()}catch(p){f=p}(d=e())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(p){if(p&&f&&typeof p.stack=="string")return[p.stack,f.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=o.DetermineComponentFrameRoot(),s=r[0],i=r[1];if(s&&i){var l=s.split(`
4
4
  `),c=i.split(`
5
5
  `);for(a=o=0;o<l.length&&!l[o].includes("DetermineComponentFrameRoot");)o++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(o===l.length||a===c.length)for(o=l.length-1,a=c.length-1;1<=o&&0<=a&&l[o]!==c[a];)a--;for(;1<=o&&0<=a;o--,a--)if(l[o]!==c[a]){if(o!==1||a!==1)do if(o--,a--,0>a||l[o]!==c[a]){var u=`
6
- `+l[o].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{px=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Ts(n):""}function TP(e,t){switch(e.tag){case 26:case 27:case 5:return Ts(e.type);case 16:return Ts("Lazy");case 13:return e.child!==t&&t!==null?Ts("Suspense Fallback"):Ts("Suspense");case 19:return Ts("SuspenseList");case 0:case 15:return hx(e.type,!1);case 11:return hx(e.type.render,!1);case 1:return hx(e.type,!0);case 31:return Ts("Activity");default:return""}}function K3(e){try{var t="",n=null;do t+=TP(e,n),n=e,e=e.return;while(e);return t}catch(o){return`
6
+ `+l[o].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{_x=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Is(n):""}function u7(e,t){switch(e.tag){case 26:case 27:case 5:return Is(e.type);case 16:return Is("Lazy");case 13:return e.child!==t&&t!==null?Is("Suspense Fallback"):Is("Suspense");case 19:return Is("SuspenseList");case 0:case 15:return wx(e.type,!1);case 11:return wx(e.type.render,!1);case 1:return wx(e.type,!0);case 31:return Is("Activity");default:return""}}function yk(e){try{var t="",n=null;do t+=u7(e,n),n=e,e=e.return;while(e);return t}catch(o){return`
7
7
  Error generating stack: `+o.message+`
8
- `+o.stack}}var Qx=Object.prototype.hasOwnProperty,G1=ht.unstable_scheduleCallback,mx=ht.unstable_cancelCallback,IP=ht.unstable_shouldYield,MP=ht.unstable_requestPaint,Ln=ht.unstable_now,RP=ht.unstable_getCurrentPriorityLevel,ww=ht.unstable_ImmediatePriority,_w=ht.unstable_UserBlockingPriority,Sm=ht.unstable_NormalPriority,OP=ht.unstable_LowPriority,Cw=ht.unstable_IdlePriority,DP=ht.log,PP=ht.unstable_setDisableYieldValue,id=null,kn=null;function Ar(e){if(typeof DP=="function"&&PP(e),kn&&typeof kn.setStrictMode=="function")try{kn.setStrictMode(id,e)}catch{}}var wn=Math.clz32?Math.clz32:zP,BP=Math.log,NP=Math.LN2;function zP(e){return e>>>=0,e===0?32:31-(BP(e)/NP|0)|0}var Uh=256,Gh=262144,Wh=4194304;function Is(e){var t=e&42;if(t!==0)return t;switch(e&-e){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Xm(e,t,n){var o=e.pendingLanes;if(o===0)return 0;var a=0,r=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var i=o&134217727;return i!==0?(o=i&~r,o!==0?a=Is(o):(s&=i,s!==0?a=Is(s):n||(n=i&~e,n!==0&&(a=Is(n))))):(i=o&~r,i!==0?a=Is(i):s!==0?a=Is(s):n||(n=o&~e,n!==0&&(a=Is(n)))),a===0?0:t!==0&&t!==a&&(t&r)===0&&(r=a&-a,n=t&-t,r>=n||r===32&&(n&4194048)!==0)?t:a}function ld(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function FP(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ew(){var e=Wh;return Wh<<=1,(Wh&62914560)===0&&(Wh=4194304),e}function yx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function cd(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function HP(e,t,n,o,a,r){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var i=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-wn(n),d=1<<u;i[u]=0,l[u]=-1;var f=c[u];if(f!==null)for(c[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}o!==0&&Tw(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function Tw(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-wn(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function Iw(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-wn(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function Mw(e,t){var n=t&-t;return n=(n&42)!==0?1:W1(n),(n&(e.suspendedLanes|t))!==0?0:n}function W1(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function q1(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Rw(){var e=we.p;return e!==0?e:(e=window.event,e===void 0?32:tE(e.type))}function $3(e,t){var n=we.p;try{return we.p=e,t()}finally{we.p=n}}var zr=Math.random().toString(36).slice(2),It="__reactFiber$"+zr,an="__reactProps$"+zr,ql="__reactContainer$"+zr,Jx="__reactEvents$"+zr,UP="__reactListeners$"+zr,GP="__reactHandles$"+zr,Q3="__reactResources$"+zr,ud="__reactMarker$"+zr;function j1(e){delete e[It],delete e[an],delete e[Jx],delete e[UP],delete e[GP]}function yl(e){var t=e[It];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ql]||n[It]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=sw(e);e!==null;){if(n=e[It])return n;e=sw(e)}return t}e=n,n=e.parentNode}return null}function jl(e){if(e=e[It]||e[ql]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Iu(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function _l(e){var t=e[Q3];return t||(t=e[Q3]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Lt(e){e[ud]=!0}var Ow=new Set,Dw={};function Ws(e,t){Dl(e,t),Dl(e+"Capture",t)}function Dl(e,t){for(Dw[e]=t,e=0;e<t.length;e++)Ow.add(t[e])}var WP=RegExp("^[: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]*$"),J3={},ek={};function qP(e){return Qx.call(ek,e)?!0:Qx.call(J3,e)?!1:WP.test(e)?ek[e]=!0:(J3[e]=!0,!1)}function am(e,t,n){if(qP(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function qh(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function ma(e,t,n,o){if(o===null)e.removeAttribute(n);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+o)}}function Wn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Pw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function jP(e,t,n){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,r=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(s){n=""+s,r.call(this,s)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function e1(e){if(!e._valueTracker){var t=Pw(e)?"checked":"value";e._valueTracker=jP(e,t,""+e[t])}}function Bw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=Pw(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function Lm(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var VP=/[\n"\\]/g;function Vn(e){return e.replace(VP,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function t1(e,t,n,o,a,r,s,i){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Wn(t)):e.value!==""+Wn(t)&&(e.value=""+Wn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?n1(e,s,Wn(t)):n!=null?n1(e,s,Wn(n)):o!=null&&e.removeAttribute("value"),a==null&&r!=null&&(e.defaultChecked=!!r),a!=null&&(e.checked=a&&typeof a!="function"&&typeof a!="symbol"),i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?e.name=""+Wn(i):e.removeAttribute("name")}function Nw(e,t,n,o,a,r,s,i){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(e.type=r),t!=null||n!=null){if(!(r!=="submit"&&r!=="reset"||t!=null)){e1(e);return}n=n!=null?""+Wn(n):"",t=t!=null?""+Wn(t):n,i||t===e.value||(e.value=t),e.defaultValue=t}o=o??a,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=i?e.checked:!!o,e.defaultChecked=!!o,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),e1(e)}function n1(e,t,n){t==="number"&&Lm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Cl(e,t,n,o){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&o&&(e[n].defaultSelected=!0)}else{for(n=""+Wn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,o&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function zw(e,t,n){if(t!=null&&(t=""+Wn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Wn(n):""}function Fw(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Tu(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=Wn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),e1(e)}function Pl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ZP=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function tk(e,t,n){var o=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,n):typeof n!="number"||n===0||ZP.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Hw(e,t,n){if(t!=null&&typeof t!="object")throw Error(O(62));if(e=e.style,n!=null){for(var o in n)!n.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var a in t)o=t[a],t.hasOwnProperty(a)&&n[a]!==o&&tk(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&tk(e,r,t[r])}function V1(e){if(e.indexOf("-")===-1)return!1;switch(e){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 XP=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),YP=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rm(e){return YP.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function La(){}var o1=null;function Z1(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gl=null,El=null;function nk(e){var t=jl(e);if(t&&(e=t.stateNode)){var n=e[an]||null;e:switch(e=t.stateNode,t.type){case"input":if(t1(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Vn(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var o=n[t];if(o!==e&&o.form===e.form){var a=o[an]||null;if(!a)throw Error(O(90));t1(o,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)o=n[t],o.form===e.form&&Bw(o)}break e;case"textarea":zw(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Cl(e,!!n.multiple,t,!1)}}}var gx=!1;function Uw(e,t,n){if(gx)return e(t,n);gx=!0;try{var o=e(t);return o}finally{if(gx=!1,(gl!==null||El!==null)&&(s0(),gl&&(t=gl,e=El,El=gl=null,nk(t),e)))for(t=0;t<e.length;t++)nk(e[t])}}function Zu(e,t){var n=e.stateNode;if(n===null)return null;var o=n[an]||null;if(o===null)return null;n=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var Ea=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),a1=!1;if(Ea)try{cl={},Object.defineProperty(cl,"passive",{get:function(){a1=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch{a1=!1}var cl,vr=null,X1=null,sm=null;function Gw(){if(sm)return sm;var e,t=X1,n=t.length,o,a="value"in vr?vr.value:vr.textContent,r=a.length;for(e=0;e<n&&t[e]===a[e];e++);var s=n-e;for(o=1;o<=s&&t[n-o]===a[r-o];o++);return sm=a.slice(e,1<o?1-o:void 0)}function im(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function jh(){return!0}function ok(){return!1}function rn(e){function t(n,o,a,r,s){this._reactName=n,this._targetInst=a,this.type=o,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var i in e)e.hasOwnProperty(i)&&(n=e[i],this[i]=n?n(r):r[i]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?jh:ok,this.isPropagationStopped=ok,this}return qe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=jh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=jh)},persist:function(){},isPersistent:jh}),t}var qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ym=rn(qs),dd=qe({},qs,{view:0,detail:0}),KP=rn(dd),xx,bx,Su,Km=qe({},dd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Y1,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Su&&(Su&&e.type==="mousemove"?(xx=e.screenX-Su.screenX,bx=e.screenY-Su.screenY):bx=xx=0,Su=e),xx)},movementY:function(e){return"movementY"in e?e.movementY:bx}}),ak=rn(Km),$P=qe({},Km,{dataTransfer:0}),QP=rn($P),JP=qe({},dd,{relatedTarget:0}),Ax=rn(JP),e7=qe({},qs,{animationName:0,elapsedTime:0,pseudoElement:0}),t7=rn(e7),n7=qe({},qs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),o7=rn(n7),a7=qe({},qs,{data:0}),rk=rn(a7),r7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},s7={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"},i7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=i7[e])?!!t[e]:!1}function Y1(){return l7}var c7=qe({},dd,{key:function(e){if(e.key){var t=r7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=im(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?s7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Y1,charCode:function(e){return e.type==="keypress"?im(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?im(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),u7=rn(c7),d7=qe({},Km,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sk=rn(d7),f7=qe({},dd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Y1}),p7=rn(f7),h7=qe({},qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),m7=rn(h7),y7=qe({},Km,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),g7=rn(y7),x7=qe({},qs,{newState:0,oldState:0}),b7=rn(x7),A7=[9,13,27,32],K1=Ea&&"CompositionEvent"in window,Ou=null;Ea&&"documentMode"in document&&(Ou=document.documentMode);var v7=Ea&&"TextEvent"in window&&!Ou,Ww=Ea&&(!K1||Ou&&8<Ou&&11>=Ou),ik=" ",lk=!1;function qw(e,t){switch(e){case"keyup":return A7.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xl=!1;function S7(e,t){switch(e){case"compositionend":return jw(t);case"keypress":return t.which!==32?null:(lk=!0,ik);case"textInput":return e=t.data,e===ik&&lk?null:e;default:return null}}function L7(e,t){if(xl)return e==="compositionend"||!K1&&qw(e,t)?(e=Gw(),sm=X1=vr=null,xl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ww&&t.locale!=="ko"?null:t.data;default:return null}}var k7={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 ck(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!k7[e.type]:t==="textarea"}function Vw(e,t,n,o){gl?El?El.push(o):El=[o]:gl=o,t=Um(t,"onChange"),0<t.length&&(n=new Ym("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Du=null,Xu=null;function w7(e){UC(e,0)}function $m(e){var t=Iu(e);if(Bw(t))return e}function uk(e,t){if(e==="change")return t}var Zw=!1;Ea&&(Ea?(Zh="oninput"in document,Zh||(vx=document.createElement("div"),vx.setAttribute("oninput","return;"),Zh=typeof vx.oninput=="function"),Vh=Zh):Vh=!1,Zw=Vh&&(!document.documentMode||9<document.documentMode));var Vh,Zh,vx;function dk(){Du&&(Du.detachEvent("onpropertychange",Xw),Xu=Du=null)}function Xw(e){if(e.propertyName==="value"&&$m(Xu)){var t=[];Vw(t,Xu,e,Z1(e)),Uw(w7,t)}}function _7(e,t,n){e==="focusin"?(dk(),Du=t,Xu=n,Du.attachEvent("onpropertychange",Xw)):e==="focusout"&&dk()}function C7(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return $m(Xu)}function E7(e,t){if(e==="click")return $m(t)}function T7(e,t){if(e==="input"||e==="change")return $m(t)}function I7(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Cn=typeof Object.is=="function"?Object.is:I7;function Yu(e,t){if(Cn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(o=0;o<n.length;o++){var a=n[o];if(!Qx.call(t,a)||!Cn(e[a],t[a]))return!1}return!0}function fk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pk(e,t){var n=fk(e);e=0;for(var o;n;){if(n.nodeType===3){if(o=e+n.textContent.length,e<=t&&o>=t)return{node:n,offset:t-e};e=o}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=fk(n)}}function Yw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Kw(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Lm(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lm(e.document)}return t}function $1(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var M7=Ea&&"documentMode"in document&&11>=document.documentMode,bl=null,r1=null,Pu=null,s1=!1;function hk(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;s1||bl==null||bl!==Lm(o)||(o=bl,"selectionStart"in o&&$1(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Pu&&Yu(Pu,o)||(Pu=o,o=Um(r1,"onSelect"),0<o.length&&(t=new Ym("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=bl)))}function Es(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Al={animationend:Es("Animation","AnimationEnd"),animationiteration:Es("Animation","AnimationIteration"),animationstart:Es("Animation","AnimationStart"),transitionrun:Es("Transition","TransitionRun"),transitionstart:Es("Transition","TransitionStart"),transitioncancel:Es("Transition","TransitionCancel"),transitionend:Es("Transition","TransitionEnd")},Sx={},$w={};Ea&&($w=document.createElement("div").style,"AnimationEvent"in window||(delete Al.animationend.animation,delete Al.animationiteration.animation,delete Al.animationstart.animation),"TransitionEvent"in window||delete Al.transitionend.transition);function js(e){if(Sx[e])return Sx[e];if(!Al[e])return e;var t=Al[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in $w)return Sx[e]=t[n];return e}var Qw=js("animationend"),Jw=js("animationiteration"),e_=js("animationstart"),R7=js("transitionrun"),O7=js("transitionstart"),D7=js("transitioncancel"),t_=js("transitionend"),n_=new Map,i1="abort auxClick beforeToggle 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(" ");i1.push("scrollEnd");function go(e,t){n_.set(e,t),Ws(t,[e])}var km=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Gn=[],vl=0,Q1=0;function Qm(){for(var e=vl,t=Q1=vl=0;t<e;){var n=Gn[t];Gn[t++]=null;var o=Gn[t];Gn[t++]=null;var a=Gn[t];Gn[t++]=null;var r=Gn[t];if(Gn[t++]=null,o!==null&&a!==null){var s=o.pending;s===null?a.next=a:(a.next=s.next,s.next=a),o.pending=a}r!==0&&o_(n,a,r)}}function Jm(e,t,n,o){Gn[vl++]=e,Gn[vl++]=t,Gn[vl++]=n,Gn[vl++]=o,Q1|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function J1(e,t,n,o){return Jm(e,t,n,o),wm(e)}function Vs(e,t){return Jm(e,null,null,t),wm(e)}function o_(e,t,n){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n);for(var a=!1,r=e.return;r!==null;)r.childLanes|=n,o=r.alternate,o!==null&&(o.childLanes|=n),r.tag===22&&(e=r.stateNode,e===null||e._visibility&1||(a=!0)),e=r,r=r.return;return e.tag===3?(r=e.stateNode,a&&t!==null&&(a=31-wn(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function wm(e){if(50<qu)throw qu=0,E1=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Sl={};function P7(e,t,n,o){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,t,n,o){return new P7(e,t,n,o)}function eb(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wa(e,t){var n=e.alternate;return n===null?(n=vn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function a_(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function lm(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")eb(e)&&(s=1);else if(typeof e=="string")s=zB(e,n,zo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Xx:return e=vn(31,n,t,a),e.elementType=Xx,e.lanes=r,e;case hl:return Ds(n.children,a,r,t);case Lw:s=8,a|=24;break;case jx:return e=vn(12,n,t,a|2),e.elementType=jx,e.lanes=r,e;case Vx:return e=vn(13,n,t,a),e.elementType=Vx,e.lanes=r,e;case Zx:return e=vn(19,n,t,a),e.elementType=Zx,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Sa:s=10;break e;case kw:s=9;break e;case H1:s=11;break e;case U1:s=14;break e;case hr:s=16,o=null;break e}s=29,n=Error(O(130,e===null?"null":typeof e,"")),o=null}return t=vn(s,n,t,a),t.elementType=e,t.type=o,t.lanes=r,t}function Ds(e,t,n,o){return e=vn(7,e,o,t),e.lanes=n,e}function Lx(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function r_(e){var t=vn(18,null,null,0);return t.stateNode=e,t}function kx(e,t,n){return t=vn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var mk=new WeakMap;function Zn(e,t){if(typeof e=="object"&&e!==null){var n=mk.get(e);return n!==void 0?n:(t={value:e,source:t,stack:K3(t)},mk.set(e,t),t)}return{value:e,source:t,stack:K3(t)}}var Ll=[],kl=0,_m=null,Ku=0,qn=[],jn=0,Dr=null,Po=1,Bo="";function Aa(e,t){Ll[kl++]=Ku,Ll[kl++]=_m,_m=e,Ku=t}function s_(e,t,n){qn[jn++]=Po,qn[jn++]=Bo,qn[jn++]=Dr,Dr=e;var o=Po;e=Bo;var a=32-wn(o)-1;o&=~(1<<a),n+=1;var r=32-wn(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,Po=1<<32-wn(t)+a|n<<a|o,Bo=r+e}else Po=1<<r|n<<a|o,Bo=e}function tb(e){e.return!==null&&(Aa(e,1),s_(e,1,0))}function nb(e){for(;e===_m;)_m=Ll[--kl],Ll[kl]=null,Ku=Ll[--kl],Ll[kl]=null;for(;e===Dr;)Dr=qn[--jn],qn[jn]=null,Bo=qn[--jn],qn[jn]=null,Po=qn[--jn],qn[jn]=null}function i_(e,t){qn[jn++]=Po,qn[jn++]=Bo,qn[jn++]=Dr,Po=t.id,Bo=t.overflow,Dr=e}var Mt=null,We=null,xe=!1,_r=null,Xn=!1,l1=Error(O(519));function Pr(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw $u(Zn(t,e)),l1}function yk(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[It]=e,t[an]=o,n){case"dialog":ue("cancel",t),ue("close",t);break;case"iframe":case"object":case"embed":ue("load",t);break;case"video":case"audio":for(n=0;n<td.length;n++)ue(td[n],t);break;case"source":ue("error",t);break;case"img":case"image":case"link":ue("error",t),ue("load",t);break;case"details":ue("toggle",t);break;case"input":ue("invalid",t),Nw(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ue("invalid",t);break;case"textarea":ue("invalid",t),Fw(t,o.value,o.defaultValue,o.children)}n=o.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||o.suppressHydrationWarning===!0||WC(t.textContent,n)?(o.popover!=null&&(ue("beforetoggle",t),ue("toggle",t)),o.onScroll!=null&&ue("scroll",t),o.onScrollEnd!=null&&ue("scrollend",t),o.onClick!=null&&(t.onclick=La),t=!0):t=!1,t||Pr(e,!0)}function gk(e){for(Mt=e.return;Mt;)switch(Mt.tag){case 5:case 31:case 13:Xn=!1;return;case 27:case 3:Xn=!0;return;default:Mt=Mt.return}}function ul(e){if(e!==Mt)return!1;if(!xe)return gk(e),xe=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||O1(e.type,e.memoizedProps)),n=!n),n&&We&&Pr(e),gk(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=rw(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=rw(e)}else t===27?(t=We,Fr(e.type)?(e=N1,N1=null,We=e):We=t):We=Mt?Kn(e.stateNode.nextSibling):null;return!0}function zs(){We=Mt=null,xe=!1}function wx(){var e=_r;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),_r=null),e}function $u(e){_r===null?_r=[e]:_r.push(e)}var c1=Fo(null),Zs=null,ka=null;function yr(e,t,n){Ne(c1,t._currentValue),t._currentValue=n}function _a(e){e._currentValue=c1.current,kt(c1)}function u1(e,t,n){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===n)break;e=e.return}}function d1(e,t,n,o){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var i=r;r=a;for(var l=0;l<t.length;l++)if(i.context===t[l]){r.lanes|=n,i=r.alternate,i!==null&&(i.lanes|=n),u1(r.return,n,e),o||(s=null);break e}r=i.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(O(341));s.lanes|=n,r=s.alternate,r!==null&&(r.lanes|=n),u1(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Vl(e,t,n,o){e=null;for(var a=t,r=!1;a!==null;){if(!r){if((a.flags&524288)!==0)r=!0;else if((a.flags&262144)!==0)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(O(387));if(s=s.memoizedProps,s!==null){var i=a.type;Cn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===bm.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(od):e=[od])}a=a.return}e!==null&&d1(t,e,n,o),t.flags|=262144}function Cm(e){for(e=e.firstContext;e!==null;){if(!Cn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Fs(e){Zs=e,ka=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Rt(e){return l_(Zs,e)}function Xh(e,t){return Zs===null&&Fs(e),l_(e,t)}function l_(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ka===null){if(e===null)throw Error(O(308));ka=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ka=ka.next=t;return n}var B7=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},N7=ht.unstable_scheduleCallback,z7=ht.unstable_NormalPriority,it={$$typeof:Sa,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ob(){return{controller:new B7,data:new Map,refCount:0}}function fd(e){e.refCount--,e.refCount===0&&N7(z7,function(){e.controller.abort()})}var Bu=null,f1=0,Bl=0,Tl=null;function F7(e,t){if(Bu===null){var n=Bu=[];f1=0,Bl=Eb(),Tl={status:"pending",value:void 0,then:function(o){n.push(o)}}}return f1++,t.then(xk,xk),t}function xk(){if(--f1===0&&Bu!==null){Tl!==null&&(Tl.status="fulfilled");var e=Bu;Bu=null,Bl=0,Tl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function H7(e,t){var n=[],o={status:"pending",value:null,reason:null,then:function(a){n.push(a)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var a=0;a<n.length;a++)(0,n[a])(t)},function(a){for(o.status="rejected",o.reason=a,a=0;a<n.length;a++)(0,n[a])(void 0)}),o}var bk=K.S;K.S=function(e,t){SC=Ln(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&F7(e,t),bk!==null&&bk(e,t)};var Ps=Fo(null);function ab(){var e=Ps.current;return e!==null?e:De.pooledCache}function cm(e,t){t===null?Ne(Ps,Ps.current):Ne(Ps,t.pool)}function c_(){var e=ab();return e===null?null:{parent:it._currentValue,pool:e}}var Zl=Error(O(460)),rb=Error(O(474)),e0=Error(O(542)),Em={then:function(){}};function Ak(e){return e=e.status,e==="fulfilled"||e==="rejected"}function u_(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(La,La),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Sk(e),e;default:if(typeof t.status=="string")t.then(La,La);else{if(e=De,e!==null&&100<e.shellSuspendCounter)throw Error(O(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var a=t;a.status="fulfilled",a.value=o}},function(o){if(t.status==="pending"){var a=t;a.status="rejected",a.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Sk(e),e}throw Bs=t,Zl}}function Ms(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Bs=n,Zl):n}}var Bs=null;function vk(){if(Bs===null)throw Error(O(459));var e=Bs;return Bs=null,e}function Sk(e){if(e===Zl||e===e0)throw Error(O(483))}var Il=null,Qu=0;function Yh(e){var t=Qu;return Qu+=1,Il===null&&(Il=[]),u_(Il,e,t)}function Lu(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Kh(e,t){throw t.$$typeof===_P?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function d_(e){function t(y,g){if(e){var b=y.deletions;b===null?(y.deletions=[g],y.flags|=16):b.push(g)}}function n(y,g){if(!e)return null;for(;g!==null;)t(y,g),g=g.sibling;return null}function o(y){for(var g=new Map;y!==null;)y.key!==null?g.set(y.key,y):g.set(y.index,y),y=y.sibling;return g}function a(y,g){return y=wa(y,g),y.index=0,y.sibling=null,y}function r(y,g,b){return y.index=b,e?(b=y.alternate,b!==null?(b=b.index,b<g?(y.flags|=67108866,g):b):(y.flags|=67108866,g)):(y.flags|=1048576,g)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function i(y,g,b,A){return g===null||g.tag!==6?(g=Lx(b,y.mode,A),g.return=y,g):(g=a(g,b),g.return=y,g)}function l(y,g,b,A){var _=b.type;return _===hl?u(y,g,b.props.children,A,b.key):g!==null&&(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===hr&&Ms(_)===g.type)?(g=a(g,b.props),Lu(g,b),g.return=y,g):(g=lm(b.type,b.key,b.props,null,y.mode,A),Lu(g,b),g.return=y,g)}function c(y,g,b,A){return g===null||g.tag!==4||g.stateNode.containerInfo!==b.containerInfo||g.stateNode.implementation!==b.implementation?(g=kx(b,y.mode,A),g.return=y,g):(g=a(g,b.children||[]),g.return=y,g)}function u(y,g,b,A,_){return g===null||g.tag!==7?(g=Ds(b,y.mode,A,_),g.return=y,g):(g=a(g,b),g.return=y,g)}function d(y,g,b){if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return g=Lx(""+g,y.mode,b),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Hh:return b=lm(g.type,g.key,g.props,null,y.mode,b),Lu(b,g),b.return=y,b;case Eu:return g=kx(g,y.mode,b),g.return=y,g;case hr:return g=Ms(g),d(y,g,b)}if(Tu(g)||vu(g))return g=Ds(g,y.mode,b,null),g.return=y,g;if(typeof g.then=="function")return d(y,Yh(g),b);if(g.$$typeof===Sa)return d(y,Xh(y,g),b);Kh(y,g)}return null}function f(y,g,b,A){var _=g!==null?g.key:null;if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return _!==null?null:i(y,g,""+b,A);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Hh:return b.key===_?l(y,g,b,A):null;case Eu:return b.key===_?c(y,g,b,A):null;case hr:return b=Ms(b),f(y,g,b,A)}if(Tu(b)||vu(b))return _!==null?null:u(y,g,b,A,null);if(typeof b.then=="function")return f(y,g,Yh(b),A);if(b.$$typeof===Sa)return f(y,g,Xh(y,b),A);Kh(y,b)}return null}function p(y,g,b,A,_){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return y=y.get(b)||null,i(g,y,""+A,_);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Hh:return y=y.get(A.key===null?b:A.key)||null,l(g,y,A,_);case Eu:return y=y.get(A.key===null?b:A.key)||null,c(g,y,A,_);case hr:return A=Ms(A),p(y,g,b,A,_)}if(Tu(A)||vu(A))return y=y.get(b)||null,u(g,y,A,_,null);if(typeof A.then=="function")return p(y,g,b,Yh(A),_);if(A.$$typeof===Sa)return p(y,g,b,Xh(g,A),_);Kh(g,A)}return null}function h(y,g,b,A){for(var _=null,T=null,w=g,S=g=0,L=null;w!==null&&S<b.length;S++){w.index>S?(L=w,w=null):L=w.sibling;var M=f(y,w,b[S],A);if(M===null){w===null&&(w=L);break}e&&w&&M.alternate===null&&t(y,w),g=r(M,g,S),T===null?_=M:T.sibling=M,T=M,w=L}if(S===b.length)return n(y,w),xe&&Aa(y,S),_;if(w===null){for(;S<b.length;S++)w=d(y,b[S],A),w!==null&&(g=r(w,g,S),T===null?_=w:T.sibling=w,T=w);return xe&&Aa(y,S),_}for(w=o(w);S<b.length;S++)L=p(w,y,S,b[S],A),L!==null&&(e&&L.alternate!==null&&w.delete(L.key===null?S:L.key),g=r(L,g,S),T===null?_=L:T.sibling=L,T=L);return e&&w.forEach(function(B){return t(y,B)}),xe&&Aa(y,S),_}function m(y,g,b,A){if(b==null)throw Error(O(151));for(var _=null,T=null,w=g,S=g=0,L=null,M=b.next();w!==null&&!M.done;S++,M=b.next()){w.index>S?(L=w,w=null):L=w.sibling;var B=f(y,w,M.value,A);if(B===null){w===null&&(w=L);break}e&&w&&B.alternate===null&&t(y,w),g=r(B,g,S),T===null?_=B:T.sibling=B,T=B,w=L}if(M.done)return n(y,w),xe&&Aa(y,S),_;if(w===null){for(;!M.done;S++,M=b.next())M=d(y,M.value,A),M!==null&&(g=r(M,g,S),T===null?_=M:T.sibling=M,T=M);return xe&&Aa(y,S),_}for(w=o(w);!M.done;S++,M=b.next())M=p(w,y,S,M.value,A),M!==null&&(e&&M.alternate!==null&&w.delete(M.key===null?S:M.key),g=r(M,g,S),T===null?_=M:T.sibling=M,T=M);return e&&w.forEach(function(W){return t(y,W)}),xe&&Aa(y,S),_}function x(y,g,b,A){if(typeof b=="object"&&b!==null&&b.type===hl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Hh:e:{for(var _=b.key;g!==null;){if(g.key===_){if(_=b.type,_===hl){if(g.tag===7){n(y,g.sibling),A=a(g,b.props.children),A.return=y,y=A;break e}}else if(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===hr&&Ms(_)===g.type){n(y,g.sibling),A=a(g,b.props),Lu(A,b),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}b.type===hl?(A=Ds(b.props.children,y.mode,A,b.key),A.return=y,y=A):(A=lm(b.type,b.key,b.props,null,y.mode,A),Lu(A,b),A.return=y,y=A)}return s(y);case Eu:e:{for(_=b.key;g!==null;){if(g.key===_)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){n(y,g.sibling),A=a(g,b.children||[]),A.return=y,y=A;break e}else{n(y,g);break}else t(y,g);g=g.sibling}A=kx(b,y.mode,A),A.return=y,y=A}return s(y);case hr:return b=Ms(b),x(y,g,b,A)}if(Tu(b))return h(y,g,b,A);if(vu(b)){if(_=vu(b),typeof _!="function")throw Error(O(150));return b=_.call(b),m(y,g,b,A)}if(typeof b.then=="function")return x(y,g,Yh(b),A);if(b.$$typeof===Sa)return x(y,g,Xh(y,b),A);Kh(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,g!==null&&g.tag===6?(n(y,g.sibling),A=a(g,b),A.return=y,y=A):(n(y,g),A=Lx(b,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,b,A){try{Qu=0;var _=x(y,g,b,A);return Il=null,_}catch(w){if(w===Zl||w===e0)throw w;var T=vn(29,w,null,y.mode);return T.lanes=A,T.return=y,T}finally{}}}var Hs=d_(!0),f_=d_(!1),mr=!1;function sb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function p1(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Cr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Er(e,t,n){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ke&2)!==0){var a=o.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),o.pending=t,t=wm(e),o_(e,null,n),t}return Jm(e,o,t,n),wm(e)}function Nu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,Iw(e,n)}}function _x(e,t){var n=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,n===o)){var a=null,r=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,n=n.next}while(n!==null);r===null?a=r=t:r=r.next=t}else a=r=t;n={baseState:o.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:o.shared,callbacks:o.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var h1=!1;function zu(){if(h1){var e=Tl;if(e!==null)throw e}}function Fu(e,t,n,o){h1=!1;var a=e.updateQueue;mr=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var l=i,c=l.next;l.next=null,s===null?r=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,i=u.lastBaseUpdate,i!==s&&(i===null?u.firstBaseUpdate=c:i.next=c,u.lastBaseUpdate=l))}if(r!==null){var d=a.baseState;s=0,u=c=l=null,i=r;do{var f=i.lane&-536870913,p=f!==i.lane;if(p?(he&f)===f:(o&f)===f){f!==0&&f===Bl&&(h1=!0),u!==null&&(u=u.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var h=e,m=i;f=t;var x=n;switch(m.tag){case 1:if(h=m.payload,typeof h=="function"){d=h.call(x,d,f);break e}d=h;break e;case 3:h.flags=h.flags&-65537|128;case 0:if(h=m.payload,f=typeof h=="function"?h.call(x,d,f):h,f==null)break e;d=qe({},d,f);break e;case 2:mr=!0}}f=i.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=a.callbacks,p===null?a.callbacks=[f]:p.push(f))}else p={lane:f,tag:i.tag,payload:i.payload,callback:i.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,s|=f;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;p=i,i=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);u===null&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,r===null&&(a.shared.lanes=0),Nr|=s,e.lanes=s,e.memoizedState=d}}function p_(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function h_(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)p_(n[e],t)}var Nl=Fo(null),Tm=Fo(0);function Lk(e,t){e=Ra,Ne(Tm,e),Ne(Nl,t),Ra=e|t.baseLanes}function m1(){Ne(Tm,Ra),Ne(Nl,Nl.current)}function ib(){Ra=Tm.current,kt(Nl),kt(Tm)}var En=Fo(null),Yn=null;function gr(e){var t=e.alternate;Ne(tt,tt.current&1),Ne(En,e),Yn===null&&(t===null||Nl.current!==null||t.memoizedState!==null)&&(Yn=e)}function y1(e){Ne(tt,tt.current),Ne(En,e),Yn===null&&(Yn=e)}function m_(e){e.tag===22?(Ne(tt,tt.current),Ne(En,e),Yn===null&&(Yn=e)):xr(e)}function xr(){Ne(tt,tt.current),Ne(En,En.current)}function An(e){kt(En),Yn===e&&(Yn=null),kt(tt)}var tt=Fo(0);function Im(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||P1(n)||B1(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(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 null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ta=0,oe=null,Me=null,rt=null,Mm=!1,Ml=!1,Us=!1,Rm=0,Ju=0,Rl=null,U7=0;function $e(){throw Error(O(321))}function lb(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Cn(e[n],t[n]))return!1;return!0}function cb(e,t,n,o,a,r){return Ta=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?V_:Ab,Us=!1,r=n(o,a),Us=!1,Ml&&(r=g_(t,n,o,a)),y_(e),r}function y_(e){K.H=ed;var t=Me!==null&&Me.next!==null;if(Ta=0,rt=Me=oe=null,Mm=!1,Ju=0,Rl=null,t)throw Error(O(300));e===null||lt||(e=e.dependencies,e!==null&&Cm(e)&&(lt=!0))}function g_(e,t,n,o){oe=e;var a=0;do{if(Ml&&(Rl=null),Ju=0,Ml=!1,25<=a)throw Error(O(301));if(a+=1,rt=Me=null,e.updateQueue!=null){var r=e.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}K.H=Z_,r=t(n,o)}while(Ml);return r}function G7(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?pd(t):t,e=e.useState()[0],(Me!==null?Me.memoizedState:null)!==e&&(oe.flags|=1024),t}function ub(){var e=Rm!==0;return Rm=0,e}function db(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function fb(e){if(Mm){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Mm=!1}Ta=0,rt=Me=oe=null,Ml=!1,Ju=Rm=0,Rl=null}function Zt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rt===null?oe.memoizedState=rt=e:rt=rt.next=e,rt}function nt(){if(Me===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=rt===null?oe.memoizedState:rt.next;if(t!==null)rt=t,Me=e;else{if(e===null)throw oe.alternate===null?Error(O(467)):Error(O(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},rt===null?oe.memoizedState=rt=e:rt=rt.next=e}return rt}function t0(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function pd(e){var t=Ju;return Ju+=1,Rl===null&&(Rl=[]),e=u_(Rl,e,t),t=oe,(rt===null?t.memoizedState:rt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?V_:Ab),e}function n0(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return pd(e);if(e.$$typeof===Sa)return Rt(e)}throw Error(O(438,String(e)))}function pb(e){var t=null,n=oe.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var o=oe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(a){return a.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=t0(),oe.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),o=0;o<e;o++)n[o]=CP;return t.index++,n}function Ia(e,t){return typeof t=="function"?t(e):t}function um(e){var t=nt();return hb(t,Me,e)}function hb(e,t,n){var o=e.queue;if(o===null)throw Error(O(311));o.lastRenderedReducer=n;var a=e.baseQueue,r=o.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}t.baseQueue=a=r,o.pending=null}if(r=e.baseState,a===null)e.memoizedState=r;else{t=a.next;var i=s=null,l=null,c=t,u=!1;do{var d=c.lane&-536870913;if(d!==c.lane?(he&d)===d:(Ta&d)===d){var f=c.revertLane;if(f===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),d===Bl&&(u=!0);else if((Ta&f)===f){c=c.next,f===Bl&&(u=!0);continue}else d={lane:0,revertLane:c.revertLane,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=d,s=r):l=l.next=d,oe.lanes|=f,Nr|=f;d=c.action,Us&&n(r,d),r=c.hasEagerState?c.eagerState:n(r,d)}else f={lane:d,revertLane:c.revertLane,gesture:c.gesture,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=f,s=r):l=l.next=f,oe.lanes|=d,Nr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!Cn(r,e.memoizedState)&&(lt=!0,u&&(n=Tl,n!==null)))throw n;e.memoizedState=r,e.baseState=s,e.baseQueue=l,o.lastRenderedState=r}return a===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Cx(e){var t=nt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var o=n.dispatch,a=n.pending,r=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do r=e(r,s.action),s=s.next;while(s!==a);Cn(r,t.memoizedState)||(lt=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function x_(e,t,n){var o=oe,a=nt(),r=xe;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!Cn((Me||a).memoizedState,n);if(s&&(a.memoizedState=n,lt=!0),a=a.queue,mb(v_.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||rt!==null&&rt.memoizedState.tag&1){if(o.flags|=2048,zl(9,{destroy:void 0},A_.bind(null,o,a,n,t),null),De===null)throw Error(O(349));r||(Ta&127)!==0||b_(o,t,n)}return n}function b_(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=t0(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function A_(e,t,n,o){t.value=n,t.getSnapshot=o,S_(t)&&L_(e)}function v_(e,t,n){return n(function(){S_(t)&&L_(e)})}function S_(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Cn(e,n)}catch{return!0}}function L_(e){var t=Vs(e,2);t!==null&&on(t,e,2)}function g1(e){var t=Zt();if(typeof e=="function"){var n=e;if(e=n(),Us){Ar(!0);try{n()}finally{Ar(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:e},t}function k_(e,t,n,o){return e.baseState=n,hb(e,Me,typeof o=="function"?o:Ia)}function W7(e,t,n,o,a){if(a0(e))throw Error(O(485));if(e=t.action,e!==null){var r={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};K.T!==null?n(!0):r.isTransition=!1,o(r),n=t.pending,n===null?(r.next=t.pending=r,w_(t,r)):(r.next=n.next,t.pending=n.next=r)}}function w_(e,t){var n=t.action,o=t.payload,a=e.state;if(t.isTransition){var r=K.T,s={};K.T=s;try{var i=n(a,o),l=K.S;l!==null&&l(s,i),kk(e,t,i)}catch(c){x1(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),kk(e,t,r)}catch(c){x1(e,t,c)}}function kk(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){wk(e,t,o)},function(o){return x1(e,t,o)}):wk(e,t,n)}function wk(e,t,n){t.status="fulfilled",t.value=n,__(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,w_(e,n)))}function x1(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,__(t),t=t.next;while(t!==o)}e.action=null}function __(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function C_(e,t){return t}function _k(e,t){if(xe){var n=De.formState;if(n!==null){e:{var o=oe;if(xe){if(We){t:{for(var a=We,r=Xn;a.nodeType!==8;){if(!r){a=null;break t}if(a=Kn(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){We=Kn(a.nextSibling),o=a.data==="F!";break e}}Pr(o)}o=!1}o&&(t=n[0])}}return n=Zt(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:C_,lastRenderedState:t},n.queue=o,n=W_.bind(null,oe,o),o.dispatch=n,o=g1(!1),r=bb.bind(null,oe,!1,o.queue),o=Zt(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=W7.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function Ck(e){var t=nt();return E_(t,Me,e)}function E_(e,t,n){if(t=hb(e,t,C_)[0],e=um(Ia)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=pd(t)}catch(s){throw s===Zl?e0:s}else o=t;t=nt();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,zl(9,{destroy:void 0},q7.bind(null,a,n),null)),[o,r,e]}function q7(e,t){e.action=t}function Ek(e){var t=nt(),n=Me;if(n!==null)return E_(t,n,e);nt(),t=t.memoizedState,n=nt();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function zl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=t0(),oe.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(o=n.next,n.next=e,e.next=o,t.lastEffect=e),e}function T_(){return nt().memoizedState}function dm(e,t,n,o){var a=Zt();oe.flags|=e,a.memoizedState=zl(1|t,{destroy:void 0},n,o===void 0?null:o)}function o0(e,t,n,o){var a=nt();o=o===void 0?null:o;var r=a.memoizedState.inst;Me!==null&&o!==null&&lb(o,Me.memoizedState.deps)?a.memoizedState=zl(t,r,n,o):(oe.flags|=e,a.memoizedState=zl(1|t,r,n,o))}function Tk(e,t){dm(8390656,8,e,t)}function mb(e,t){o0(2048,8,e,t)}function j7(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=t0(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function I_(e){var t=nt().memoizedState;return j7({ref:t,nextImpl:e}),function(){if((ke&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function M_(e,t){return o0(4,2,e,t)}function R_(e,t){return o0(4,4,e,t)}function O_(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function D_(e,t,n){n=n!=null?n.concat([e]):null,o0(4,4,O_.bind(null,t,e),n)}function yb(){}function P_(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&lb(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function B_(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&lb(t,o[1]))return o[0];if(o=e(),Us){Ar(!0);try{e()}finally{Ar(!1)}}return n.memoizedState=[o,t],o}function gb(e,t,n){return n===void 0||(Ta&1073741824)!==0&&(he&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=kC(),oe.lanes|=e,Nr|=e,n)}function N_(e,t,n,o){return Cn(n,t)?n:Nl.current!==null?(e=gb(e,n,o),Cn(e,t)||(lt=!0),e):(Ta&42)===0||(Ta&1073741824)!==0&&(he&261930)===0?(lt=!0,e.memoizedState=n):(e=kC(),oe.lanes|=e,Nr|=e,t)}function z_(e,t,n,o,a){var r=we.p;we.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,bb(e,!1,t,n);try{var l=a(),c=K.S;if(c!==null&&c(i,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=H7(l,o);Hu(e,t,u,_n(e))}else Hu(e,t,o,_n(e))}catch(d){Hu(e,t,{then:function(){},status:"rejected",reason:d},_n())}finally{we.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function V7(){}function b1(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=F_(e).queue;z_(e,a,t,Os,n===null?V7:function(){return H_(e),n(o)})}function F_(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Os,baseState:Os,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:Os},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function H_(e){var t=F_(e);t.next===null&&(t=e.alternate.memoizedState),Hu(e,t.next.queue,{},_n())}function xb(){return Rt(od)}function U_(){return nt().memoizedState}function G_(){return nt().memoizedState}function Z7(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=_n();e=Cr(n);var o=Er(t,e,n);o!==null&&(on(o,t,n),Nu(o,t,n)),t={cache:ob()},e.payload=t;return}t=t.return}}function X7(e,t,n){var o=_n();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},a0(e)?q_(t,n):(n=J1(e,t,n,o),n!==null&&(on(n,e,o),j_(n,t,o)))}function W_(e,t,n){var o=_n();Hu(e,t,n,o)}function Hu(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(a0(e))q_(t,a);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=t.lastRenderedReducer,r!==null))try{var s=t.lastRenderedState,i=r(s,n);if(a.hasEagerState=!0,a.eagerState=i,Cn(i,s))return Jm(e,t,a,0),De===null&&Qm(),!1}catch{}finally{}if(n=J1(e,t,a,o),n!==null)return on(n,e,o),j_(n,t,o),!0}return!1}function bb(e,t,n,o){if(o={lane:2,revertLane:Eb(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},a0(e)){if(t)throw Error(O(479))}else t=J1(e,n,o,2),t!==null&&on(t,e,2)}function a0(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function q_(e,t){Ml=Mm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function j_(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,Iw(e,n)}}var ed={readContext:Rt,use:n0,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useLayoutEffect:$e,useInsertionEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useSyncExternalStore:$e,useId:$e,useHostTransitionStatus:$e,useFormState:$e,useActionState:$e,useOptimistic:$e,useMemoCache:$e,useCacheRefresh:$e};ed.useEffectEvent=$e;var V_={readContext:Rt,use:n0,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:Tk,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,dm(4194308,4,O_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return dm(4194308,4,e,t)},useInsertionEffect:function(e,t){dm(4,2,e,t)},useMemo:function(e,t){var n=Zt();t=t===void 0?null:t;var o=e();if(Us){Ar(!0);try{e()}finally{Ar(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Zt();if(n!==void 0){var a=n(t);if(Us){Ar(!0);try{n(t)}finally{Ar(!1)}}}else a=t;return o.memoizedState=o.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},o.queue=e,e=e.dispatch=X7.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:function(e){e=g1(e);var t=e.queue,n=W_.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:yb,useDeferredValue:function(e,t){var n=Zt();return gb(n,e,t)},useTransition:function(){var e=g1(!1);return e=z_.bind(null,oe,e.queue,!0,!1),Zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Zt();if(xe){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),De===null)throw Error(O(349));(he&127)!==0||b_(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,Tk(v_.bind(null,o,r,e),[e]),o.flags|=2048,zl(9,{destroy:void 0},A_.bind(null,o,r,n,t),null),n},useId:function(){var e=Zt(),t=De.identifierPrefix;if(xe){var n=Bo,o=Po;n=(o&~(1<<32-wn(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Rm++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=U7++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:xb,useFormState:_k,useActionState:_k,useOptimistic:function(e){var t=Zt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=bb.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:pb,useCacheRefresh:function(){return Zt().memoizedState=Z7.bind(null,oe)},useEffectEvent:function(e){var t=Zt(),n={impl:e};return t.memoizedState=n,function(){if((ke&2)!==0)throw Error(O(440));return n.impl.apply(void 0,arguments)}}},Ab={readContext:Rt,use:n0,useCallback:P_,useContext:Rt,useEffect:mb,useImperativeHandle:D_,useInsertionEffect:M_,useLayoutEffect:R_,useMemo:B_,useReducer:um,useRef:T_,useState:function(){return um(Ia)},useDebugValue:yb,useDeferredValue:function(e,t){var n=nt();return N_(n,Me.memoizedState,e,t)},useTransition:function(){var e=um(Ia)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:pd(e),t]},useSyncExternalStore:x_,useId:U_,useHostTransitionStatus:xb,useFormState:Ck,useActionState:Ck,useOptimistic:function(e,t){var n=nt();return k_(n,Me,e,t)},useMemoCache:pb,useCacheRefresh:G_};Ab.useEffectEvent=I_;var Z_={readContext:Rt,use:n0,useCallback:P_,useContext:Rt,useEffect:mb,useImperativeHandle:D_,useInsertionEffect:M_,useLayoutEffect:R_,useMemo:B_,useReducer:Cx,useRef:T_,useState:function(){return Cx(Ia)},useDebugValue:yb,useDeferredValue:function(e,t){var n=nt();return Me===null?gb(n,e,t):N_(n,Me.memoizedState,e,t)},useTransition:function(){var e=Cx(Ia)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:pd(e),t]},useSyncExternalStore:x_,useId:U_,useHostTransitionStatus:xb,useFormState:Ek,useActionState:Ek,useOptimistic:function(e,t){var n=nt();return Me!==null?k_(n,Me,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:pb,useCacheRefresh:G_};Z_.useEffectEvent=I_;function Ex(e,t,n,o){t=e.memoizedState,n=n(o,t),n=n==null?t:qe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var A1={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=_n(),a=Cr(o);a.payload=t,n!=null&&(a.callback=n),t=Er(e,a,o),t!==null&&(on(t,e,o),Nu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=_n(),a=Cr(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Er(e,a,o),t!==null&&(on(t,e,o),Nu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=_n(),o=Cr(n);o.tag=2,t!=null&&(o.callback=t),t=Er(e,o,n),t!==null&&(on(t,e,n),Nu(t,e,n))}};function Ik(e,t,n,o,a,r,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,r,s):t.prototype&&t.prototype.isPureReactComponent?!Yu(n,o)||!Yu(a,r):!0}function Mk(e,t,n,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,o),t.state!==e&&A1.enqueueReplaceState(t,t.state,null)}function Gs(e,t){var n=t;if("ref"in t){n={};for(var o in t)o!=="ref"&&(n[o]=t[o])}if(e=e.defaultProps){n===t&&(n=qe({},n));for(var a in e)n[a]===void 0&&(n[a]=e[a])}return n}function X_(e){km(e)}function Y_(e){console.error(e)}function K_(e){km(e)}function Om(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Rk(e,t,n){try{var o=e.onCaughtError;o(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function v1(e,t,n){return n=Cr(n),n.tag=3,n.payload={element:null},n.callback=function(){Om(e,t)},n}function $_(e){return e=Cr(e),e.tag=3,e}function Q_(e,t,n,o){var a=n.type.getDerivedStateFromError;if(typeof a=="function"){var r=o.value;e.payload=function(){return a(r)},e.callback=function(){Rk(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){Rk(t,n,o),typeof a!="function"&&(Tr===null?Tr=new Set([this]):Tr.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function Y7(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&Vl(t,n,a,!0),n=En.current,n!==null){switch(n.tag){case 31:case 13:return Yn===null?zm():n.alternate===null&&Qe===0&&(Qe=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Em?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),Fx(e,o,a)),!1;case 22:return n.flags|=65536,o===Em?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([o]):n.add(o)),Fx(e,o,a)),!1}throw Error(O(435,n.tag))}return Fx(e,o,a),zm(),!1}if(xe)return t=En.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==l1&&(e=Error(O(422),{cause:o}),$u(Zn(e,n)))):(o!==l1&&(t=Error(O(423),{cause:o}),$u(Zn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Zn(o,n),a=v1(e.stateNode,o,a),_x(e,a),Qe!==4&&(Qe=2)),!1;var r=Error(O(520),{cause:o});if(r=Zn(r,n),Wu===null?Wu=[r]:Wu.push(r),Qe!==4&&(Qe=2),t===null)return!0;o=Zn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=v1(n.stateNode,o,e),_x(n,e),!1;case 1:if(t=n.type,r=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(Tr===null||!Tr.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=$_(a),Q_(a,e,n,o),_x(n,a),!1}n=n.return}while(n!==null);return!1}var vb=Error(O(461)),lt=!1;function Tt(e,t,n,o){t.child=e===null?f_(t,null,n,o):Hs(t,e.child,n,o)}function Ok(e,t,n,o,a){n=n.render;var r=t.ref;if("ref"in o){var s={};for(var i in o)i!=="ref"&&(s[i]=o[i])}else s=o;return Fs(t),o=cb(e,t,n,s,r,a),i=ub(),e!==null&&!lt?(db(e,t,a),Ma(e,t,a)):(xe&&i&&tb(t),t.flags|=1,Tt(e,t,o,a),t.child)}function Dk(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!eb(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,J_(e,t,r,o,a)):(e=lm(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!Sb(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:Yu,n(s,o)&&e.ref===t.ref)return Ma(e,t,a)}return t.flags|=1,e=wa(r,o),e.ref=t.ref,e.return=t,t.child=e}function J_(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(Yu(r,o)&&e.ref===t.ref)if(lt=!1,t.pendingProps=o=r,Sb(e,a))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,Ma(e,t,a)}return S1(e,t,n,o,a)}function eC(e,t,n,o){var a=o.children,r=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(r=r!==null?r.baseLanes|n:n,e!==null){for(o=t.child=e.child,a=0;o!==null;)a=a|o.lanes|o.childLanes,o=o.sibling;o=a&~r}else o=0,t.child=null;return Pk(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&cm(t,r!==null?r.cachePool:null),r!==null?Lk(t,r):m1(),m_(t);else return o=t.lanes=536870912,Pk(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(cm(t,r.cachePool),Lk(t,r),xr(t),t.memoizedState=null):(e!==null&&cm(t,null),m1(),xr(t));return Tt(e,t,a,n),t.child}function Mu(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Pk(e,t,n,o,a){var r=ab();return r=r===null?null:{parent:it._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&cm(t,null),m1(),m_(t),e!==null&&Vl(e,t,o,!0),t.childLanes=a,null}function fm(e,t){return t=Dm({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Bk(e,t,n){return Hs(t,e.child,null,n),e=fm(t,t.pendingProps),e.flags|=2,An(t),t.memoizedState=null,e}function K7(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(xe){if(o.mode==="hidden")return e=fm(t,o),t.lanes=536870912,Mu(null,e);if(y1(t),(e=We)?(e=VC(e,Xn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Dr!==null?{id:Po,overflow:Bo}:null,retryLane:536870912,hydrationErrors:null},n=r_(e),n.return=t,t.child=n,Mt=t,We=null)):e=null,e===null)throw Pr(t);return t.lanes=536870912,null}return fm(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(y1(t),a)if(t.flags&256)t.flags&=-257,t=Bk(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(O(558));else if(lt||Vl(e,t,n,!1),a=(n&e.childLanes)!==0,lt||a){if(o=De,o!==null&&(s=Mw(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Vs(e,s),on(o,e,s),vb;zm(),t=Bk(e,t,n)}else e=r.treeContext,We=Kn(s.nextSibling),Mt=t,xe=!0,_r=null,Xn=!1,e!==null&&i_(t,e),t=fm(t,o),t.flags|=4096;return t}return e=wa(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pm(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(O(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function S1(e,t,n,o,a){return Fs(t),n=cb(e,t,n,o,void 0,a),o=ub(),e!==null&&!lt?(db(e,t,a),Ma(e,t,a)):(xe&&o&&tb(t),t.flags|=1,Tt(e,t,n,a),t.child)}function Nk(e,t,n,o,a,r){return Fs(t),t.updateQueue=null,n=g_(t,o,n,a),y_(e),o=ub(),e!==null&&!lt?(db(e,t,r),Ma(e,t,r)):(xe&&o&&tb(t),t.flags|=1,Tt(e,t,n,r),t.child)}function zk(e,t,n,o,a){if(Fs(t),t.stateNode===null){var r=Sl,s=n.contextType;typeof s=="object"&&s!==null&&(r=Rt(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=A1,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},sb(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Rt(s):Sl,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Ex(t,n,s,o),r.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&A1.enqueueReplaceState(r,r.state,null),Fu(t,o,r,a),zu(),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){r=t.stateNode;var i=t.memoizedProps,l=Gs(n,i);r.props=l;var c=r.context,u=n.contextType;s=Sl,typeof u=="object"&&u!==null&&(s=Rt(u));var d=n.getDerivedStateFromProps;u=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",i=t.pendingProps!==i,u||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(i||c!==s)&&Mk(t,r,o,s),mr=!1;var f=t.memoizedState;r.state=f,Fu(t,o,r,a),zu(),c=t.memoizedState,i||f!==c||mr?(typeof d=="function"&&(Ex(t,n,d,o),c=t.memoizedState),(l=mr||Ik(t,n,l,o,f,c,s))?(u||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(t.flags|=4194308)):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=c),r.props=o,r.state=c,r.context=s,o=l):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{r=t.stateNode,p1(e,t),s=t.memoizedProps,u=Gs(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=Sl,typeof c=="object"&&c!==null&&(l=Rt(c)),i=n.getDerivedStateFromProps,(c=typeof i=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||f!==l)&&Mk(t,r,o,l),mr=!1,f=t.memoizedState,r.state=f,Fu(t,o,r,a),zu();var p=t.memoizedState;s!==d||f!==p||mr||e!==null&&e.dependencies!==null&&Cm(e.dependencies)?(typeof i=="function"&&(Ex(t,n,i,o),p=t.memoizedState),(u=mr||Ik(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&Cm(e.dependencies))?(c||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(o,p,l),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(o,p,l)),typeof r.componentDidUpdate=="function"&&(t.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=p),r.props=o,r.state=p,r.context=l,o=u):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),o=!1)}return r=o,pm(e,t),o=(t.flags&128)!==0,r||o?(r=t.stateNode,n=o&&typeof n.getDerivedStateFromError!="function"?null:r.render(),t.flags|=1,e!==null&&o?(t.child=Hs(t,e.child,null,a),t.child=Hs(t,null,n,a)):Tt(e,t,n,a),t.memoizedState=r.state,e=t.child):e=Ma(e,t,a),e}function Fk(e,t,n,o){return zs(),t.flags|=256,Tt(e,t,n,o),t.child}var Tx={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ix(e){return{baseLanes:e,cachePool:c_()}}function Mx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Sn),e}function tC(e,t,n){var o=t.pendingProps,a=!1,r=(t.flags&128)!==0,s;if((s=r)||(s=e!==null&&e.memoizedState===null?!1:(tt.current&2)!==0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(xe){if(a?gr(t):xr(t),(e=We)?(e=VC(e,Xn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Dr!==null?{id:Po,overflow:Bo}:null,retryLane:536870912,hydrationErrors:null},n=r_(e),n.return=t,t.child=n,Mt=t,We=null)):e=null,e===null)throw Pr(t);return B1(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?(xr(t),a=t.mode,i=Dm({mode:"hidden",children:i},a),o=Ds(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=Ix(n),o.childLanes=Mx(e,s,n),t.memoizedState=Tx,Mu(null,o)):(gr(t),L1(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(gr(t),t.flags&=-257,t=Rx(e,t,n)):t.memoizedState!==null?(xr(t),t.child=e.child,t.flags|=128,t=null):(xr(t),i=o.fallback,a=t.mode,o=Dm({mode:"visible",children:o.children},a),i=Ds(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,Hs(t,e.child,null,n),o=t.child,o.memoizedState=Ix(n),o.childLanes=Mx(e,s,n),t.memoizedState=Tx,t=Mu(null,o));else if(gr(t),B1(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,$u({value:o,source:null,stack:null}),t=Rx(e,t,n)}else if(lt||Vl(e,t,n,!1),s=(n&e.childLanes)!==0,lt||s){if(s=De,s!==null&&(o=Mw(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Vs(e,o),on(s,e,o),vb;P1(i)||zm(),t=Rx(e,t,n)}else P1(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,We=Kn(i.nextSibling),Mt=t,xe=!0,_r=null,Xn=!1,e!==null&&i_(t,e),t=L1(t,o.children),t.flags|=4096);return t}return a?(xr(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=wa(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=wa(c,i):(i=Ds(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Mu(null,o),o=t.child,i=e.child.memoizedState,i===null?i=Ix(n):(a=i.cachePool,a!==null?(l=it._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=c_(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=Mx(e,s,n),t.memoizedState=Tx,Mu(e.child,o)):(gr(t),n=e.child,e=n.sibling,n=wa(n,{mode:"visible",children:o.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function L1(e,t){return t=Dm({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Dm(e,t){return e=vn(22,e,null,t),e.lanes=0,e}function Rx(e,t,n){return Hs(t,e.child,null,n),e=L1(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hk(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),u1(e.return,t,n)}function Ox(e,t,n,o,a,r){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:n,tailMode:a,treeForkCount:r}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=o,s.tail=n,s.tailMode=a,s.treeForkCount=r)}function nC(e,t,n){var o=t.pendingProps,a=o.revealOrder,r=o.tail;o=o.children;var s=tt.current,i=(s&2)!==0;if(i?(s=s&1|2,t.flags|=128):s&=1,Ne(tt,s),Tt(e,t,o,n),o=xe?Ku:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Hk(e,n,t);else if(e.tag===19)Hk(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&Im(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Ox(t,!1,a,n,r,o);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&Im(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Ox(t,!0,n,null,r,o);break;case"together":Ox(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Ma(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Nr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Vl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=wa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=wa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sb(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Cm(e)))}function $7(e,t,n){switch(t.tag){case 3:Am(t,t.stateNode.containerInfo),yr(t,it,e.memoizedState.cache),zs();break;case 27:case 5:$x(t);break;case 4:Am(t,t.stateNode.containerInfo);break;case 10:yr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,y1(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(gr(t),t.flags|=128,null):(n&t.child.childLanes)!==0?tC(e,t,n):(gr(t),e=Ma(e,t,n),e!==null?e.sibling:null);gr(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(Vl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return nC(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Ne(tt,tt.current),o)break;return null;case 22:return t.lanes=0,eC(e,t,n,t.pendingProps);case 24:yr(t,it,e.memoizedState.cache)}return Ma(e,t,n)}function oC(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!Sb(e,n)&&(t.flags&128)===0)return lt=!1,$7(e,t,n);lt=(e.flags&131072)!==0}else lt=!1,xe&&(t.flags&1048576)!==0&&s_(t,Ku,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Ms(t.elementType),t.type=e,typeof e=="function")eb(e)?(o=Gs(e,o),t.tag=1,t=zk(null,t,e,o,n)):(t.tag=0,t=S1(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===H1){t.tag=11,t=Ok(null,t,e,o,n);break e}else if(a===U1){t.tag=14,t=Dk(null,t,e,o,n);break e}}throw t=Yx(e)||e,Error(O(306,t,""))}}return t;case 0:return S1(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=Gs(o,t.pendingProps),zk(e,t,o,a,n);case 3:e:{if(Am(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,p1(e,t),Fu(t,o,null,n);var s=t.memoizedState;if(o=s.cache,yr(t,it,o),o!==r.cache&&d1(t,[it],n,!0),zu(),o=s.element,r.isDehydrated)if(r={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=r,t.memoizedState=r,t.flags&256){t=Fk(e,t,o,n);break e}else if(o!==a){a=Zn(Error(O(424)),t),$u(a),t=Fk(e,t,o,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(We=Kn(e.firstChild),Mt=t,xe=!0,_r=null,Xn=!0,n=f_(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(zs(),o===a){t=Ma(e,t,n);break e}Tt(e,t,o,n)}t=t.child}return t;case 26:return pm(e,t),e===null?(n=lw(t.type,null,t.pendingProps,null))?t.memoizedState=n:xe||(n=t.type,e=t.pendingProps,o=Gm(wr.current).createElement(n),o[It]=t,o[an]=e,Ot(o,n,e),Lt(o),t.stateNode=o):t.memoizedState=lw(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $x(t),e===null&&xe&&(o=t.stateNode=ZC(t.type,t.pendingProps,wr.current),Mt=t,Xn=!0,a=We,Fr(t.type)?(N1=a,We=Kn(o.firstChild)):We=a),Tt(e,t,t.pendingProps.children,n),pm(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&xe&&((a=o=We)&&(o=wB(o,t.type,t.pendingProps,Xn),o!==null?(t.stateNode=o,Mt=t,We=Kn(o.firstChild),Xn=!1,a=!0):a=!1),a||Pr(t)),$x(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,O1(a,r)?o=null:s!==null&&O1(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=cb(e,t,G7,null,null,n),od._currentValue=a),pm(e,t),Tt(e,t,o,n),t.child;case 6:return e===null&&xe&&((e=n=We)&&(n=_B(n,t.pendingProps,Xn),n!==null?(t.stateNode=n,Mt=t,We=null,e=!0):e=!1),e||Pr(t)),null;case 13:return tC(e,t,n);case 4:return Am(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Hs(t,null,o,n):Tt(e,t,o,n),t.child;case 11:return Ok(e,t,t.type,t.pendingProps,n);case 7:return Tt(e,t,t.pendingProps,n),t.child;case 8:return Tt(e,t,t.pendingProps.children,n),t.child;case 12:return Tt(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,yr(t,t.type,o.value),Tt(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,Fs(t),a=Rt(a),o=o(a),t.flags|=1,Tt(e,t,o,n),t.child;case 14:return Dk(e,t,t.type,t.pendingProps,n);case 15:return J_(e,t,t.type,t.pendingProps,n);case 19:return nC(e,t,n);case 31:return K7(e,t,n);case 22:return eC(e,t,n,t.pendingProps);case 24:return Fs(t),o=Rt(it),e===null?(a=ab(),a===null&&(a=De,r=ob(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},sb(t),yr(t,it,a)):((e.lanes&n)!==0&&(p1(e,t),Fu(t,null,null,n),zu()),a=e.memoizedState,r=t.memoizedState,a.parent!==o?(a={parent:o,cache:o},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),yr(t,it,o)):(o=r.cache,yr(t,it,o),o!==a.cache&&d1(t,[it],n,!0))),Tt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function ya(e){e.flags|=4}function Dx(e,t,n,o,a){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(a&335544128)===a)if(e.stateNode.complete)e.flags|=8192;else if(CC())e.flags|=8192;else throw Bs=Em,rb}else e.flags&=-16777217}function Uk(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!KC(t))if(CC())e.flags|=8192;else throw Bs=Em,rb}function $h(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Ew():536870912,e.lanes|=t,Fl|=t)}function ku(e,t){if(!xe)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var o=null;n!==null;)n.alternate!==null&&(o=n),n=n.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Ge(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,o=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags&65011712,o|=a.flags&65011712,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags,o|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=o,e.childLanes=n,t}function Q7(e,t,n){var o=t.pendingProps;switch(nb(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return Ge(t),null;case 3:return n=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),_a(it),Ol(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ul(t)?ya(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,wx())),Ge(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?(ya(t),r!==null?(Ge(t),Uk(t,r)):(Ge(t),Dx(t,a,null,o,n))):r?r!==e.memoizedState?(ya(t),Ge(t),Uk(t,r)):(Ge(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&ya(t),Ge(t),Dx(t,a,e,o,n)),null;case 27:if(vm(t),n=wr.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}e=zo.current,ul(t)?yk(t,e):(e=ZC(a,o,n),t.stateNode=e,ya(t))}return Ge(t),null;case 5:if(vm(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}if(r=zo.current,ul(t))yk(t,r);else{var s=Gm(wr.current);switch(r){case 1:r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":r=s.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild);break;case"select":r=typeof o.is=="string"?s.createElement("select",{is:o.is}):s.createElement("select"),o.multiple?r.multiple=!0:o.size&&(r.size=o.size);break;default:r=typeof o.is=="string"?s.createElement(a,{is:o.is}):s.createElement(a)}}r[It]=t,r[an]=o;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)r.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=r;e:switch(Ot(r,a,o),a){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&ya(t)}}return Ge(t),Dx(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=wr.current,ul(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Mt,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[It]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||WC(e.nodeValue,n)),e||Pr(t,!0)}else e=Gm(e).createTextNode(o),e[It]=t,t.stateNode=e}return Ge(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=ul(t),n!==null){if(e===null){if(!o)throw Error(O(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(557));e[It]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),e=!1}else n=wx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(An(t),t):(An(t),null);if((t.flags&128)!==0)throw Error(O(558))}return Ge(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ul(t),o!==null&&o.dehydrated!==null){if(e===null){if(!a)throw Error(O(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(O(317));a[It]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),a=!1}else a=wx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(An(t),t):(An(t),null)}return An(t),(t.flags&128)!==0?(t.lanes=n,t):(n=o!==null,e=e!==null&&e.memoizedState!==null,n&&(o=t.child,a=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(a=o.alternate.memoizedState.cachePool.pool),r=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(r=o.memoizedState.cachePool.pool),r!==a&&(o.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),$h(t,t.updateQueue),Ge(t),null);case 4:return Ol(),e===null&&Tb(t.stateNode.containerInfo),Ge(t),null;case 10:return _a(t.type),Ge(t),null;case 19:if(kt(tt),o=t.memoizedState,o===null)return Ge(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)ku(o,!1);else{if(Qe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=Im(e),r!==null){for(t.flags|=128,ku(o,!1),e=r.updateQueue,t.updateQueue=e,$h(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)a_(n,e),n=n.sibling;return Ne(tt,tt.current&1|2),xe&&Aa(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ln()>Bm&&(t.flags|=128,a=!0,ku(o,!1),t.lanes=4194304)}else{if(!a)if(e=Im(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,$h(t,e),ku(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!xe)return Ge(t),null}else 2*Ln()-o.renderingStartTime>Bm&&n!==536870912&&(t.flags|=128,a=!0,ku(o,!1),t.lanes=4194304);o.isBackwards?(r.sibling=t.child,t.child=r):(e=o.last,e!==null?e.sibling=r:t.child=r,o.last=r)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ln(),e.sibling=null,n=tt.current,Ne(tt,a?n&1|2:n&1),xe&&Aa(t,o.treeForkCount),e):(Ge(t),null);case 22:case 23:return An(t),ib(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(n&536870912)!==0&&(t.flags&128)===0&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),n=t.updateQueue,n!==null&&$h(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==n&&(t.flags|=2048),e!==null&&kt(Ps),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),_a(it),Ge(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function J7(e,t){switch(nb(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return _a(it),Ol(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return vm(t),null;case 31:if(t.memoizedState!==null){if(An(t),t.alternate===null)throw Error(O(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(An(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return kt(tt),null;case 4:return Ol(),null;case 10:return _a(t.type),null;case 22:case 23:return An(t),ib(),e!==null&&kt(Ps),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return _a(it),null;case 25:return null;default:return null}}function aC(e,t){switch(nb(t),t.tag){case 3:_a(it),Ol();break;case 26:case 27:case 5:vm(t);break;case 4:Ol();break;case 31:t.memoizedState!==null&&An(t);break;case 13:An(t);break;case 19:kt(tt);break;case 10:_a(t.type);break;case 22:case 23:An(t),ib(),e!==null&&kt(Ps);break;case 24:_a(it)}}function hd(e,t){try{var n=t.updateQueue,o=n!==null?n.lastEffect:null;if(o!==null){var a=o.next;n=a;do{if((n.tag&e)===e){o=void 0;var r=n.create,s=n.inst;o=r(),s.destroy=o}n=n.next}while(n!==a)}}catch(i){Te(t,t.return,i)}}function Br(e,t,n){try{var o=t.updateQueue,a=o!==null?o.lastEffect:null;if(a!==null){var r=a.next;o=r;do{if((o.tag&e)===e){var s=o.inst,i=s.destroy;if(i!==void 0){s.destroy=void 0,a=t;var l=n,c=i;try{c()}catch(u){Te(a,l,u)}}}o=o.next}while(o!==r)}}catch(u){Te(t,t.return,u)}}function rC(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{h_(t,n)}catch(o){Te(e,e.return,o)}}}function sC(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Te(e,t,o)}}function Uu(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof n=="function"?e.refCleanup=n(o):n.current=o}}catch(a){Te(e,t,a)}}function No(e,t){var n=e.ref,o=e.refCleanup;if(n!==null)if(typeof o=="function")try{o()}catch(a){Te(e,t,a)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(a){Te(e,t,a)}else n.current=null}function iC(e){var t=e.type,n=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&o.focus();break e;case"img":n.src?o.src=n.src:n.srcSet&&(o.srcset=n.srcSet)}}catch(a){Te(e,e.return,a)}}function Px(e,t,n){try{var o=e.stateNode;bB(o,e.type,n,t),o[an]=t}catch(a){Te(e,e.return,a)}}function lC(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Fr(e.type)||e.tag===4}function Bx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||lC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Fr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function k1(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=La));else if(o!==4&&(o===27&&Fr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(k1(e,t,n),e=e.sibling;e!==null;)k1(e,t,n),e=e.sibling}function Pm(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(o!==4&&(o===27&&Fr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Pm(e,t,n),e=e.sibling;e!==null;)Pm(e,t,n),e=e.sibling}function cC(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Ot(t,o,n),t[It]=e,t[an]=n}catch(r){Te(e,e.return,r)}}var va=!1,st=!1,Nx=!1,Gk=typeof WeakSet=="function"?WeakSet:Set,St=null;function eB(e,t){if(e=e.containerInfo,M1=Vm,e=Kw(e),$1(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var o=n.getSelection&&n.getSelection();if(o&&o.rangeCount!==0){n=o.anchorNode;var a=o.anchorOffset,r=o.focusNode;o=o.focusOffset;try{n.nodeType,r.nodeType}catch{n=null;break e}var s=0,i=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||a!==0&&d.nodeType!==3||(i=s+a),d!==r||o!==0&&d.nodeType!==3||(l=s+o),d.nodeType===3&&(s+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===a&&(i=s),f===r&&++u===o&&(l=s),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=i===-1||l===-1?null:{start:i,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(R1={focusedElem:e,selectionRange:n},Vm=!1,St=t;St!==null;)if(t=St,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,St=e;else for(;St!==null;){switch(t=St,r=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&r!==null){e=void 0,n=t,a=r.memoizedProps,r=r.memoizedState,o=n.stateNode;try{var h=Gs(n.type,a);e=o.getSnapshotBeforeUpdate(h,r),o.__reactInternalSnapshotBeforeUpdate=e}catch(m){Te(n,n.return,m)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)D1(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":D1(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(O(163))}if(e=t.sibling,e!==null){e.return=t.return,St=e;break}St=t.return}}function uC(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:xa(e,n),o&4&&hd(5,n);break;case 1:if(xa(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Te(n,n.return,s)}else{var a=Gs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Te(n,n.return,s)}}o&64&&rC(n),o&512&&Uu(n,n.return);break;case 3:if(xa(e,n),o&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{h_(e,t)}catch(s){Te(n,n.return,s)}}break;case 27:t===null&&o&4&&cC(n);case 26:case 5:xa(e,n),t===null&&o&4&&iC(n),o&512&&Uu(n,n.return);break;case 12:xa(e,n);break;case 31:xa(e,n),o&4&&pC(e,n);break;case 13:xa(e,n),o&4&&hC(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=cB.bind(null,n),CB(e,n))));break;case 22:if(o=n.memoizedState!==null||va,!o){t=t!==null&&t.memoizedState!==null||st,a=va;var r=st;va=o,(st=t)&&!r?ba(e,n,(n.subtreeFlags&8772)!==0):xa(e,n),va=a,st=r}break;case 30:break;default:xa(e,n)}}function dC(e){var t=e.alternate;t!==null&&(e.alternate=null,dC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&j1(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ve=null,tn=!1;function ga(e,t,n){for(n=n.child;n!==null;)fC(e,t,n),n=n.sibling}function fC(e,t,n){if(kn&&typeof kn.onCommitFiberUnmount=="function")try{kn.onCommitFiberUnmount(id,n)}catch{}switch(n.tag){case 26:st||No(n,t),ga(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:st||No(n,t);var o=Ve,a=tn;Fr(n.type)&&(Ve=n.stateNode,tn=!1),ga(e,t,n),ju(n.stateNode),Ve=o,tn=a;break;case 5:st||No(n,t);case 6:if(o=Ve,a=tn,Ve=null,ga(e,t,n),Ve=o,tn=a,Ve!==null)if(tn)try{(Ve.nodeType===9?Ve.body:Ve.nodeName==="HTML"?Ve.ownerDocument.body:Ve).removeChild(n.stateNode)}catch(r){Te(n,t,r)}else try{Ve.removeChild(n.stateNode)}catch(r){Te(n,t,r)}break;case 18:Ve!==null&&(tn?(e=Ve,ow(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Wl(e)):ow(Ve,n.stateNode));break;case 4:o=Ve,a=tn,Ve=n.stateNode.containerInfo,tn=!0,ga(e,t,n),Ve=o,tn=a;break;case 0:case 11:case 14:case 15:Br(2,n,t),st||Br(4,n,t),ga(e,t,n);break;case 1:st||(No(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&sC(n,t,o)),ga(e,t,n);break;case 21:ga(e,t,n);break;case 22:st=(o=st)||n.memoizedState!==null,ga(e,t,n),st=o;break;default:ga(e,t,n)}}function pC(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wl(e)}catch(n){Te(t,t.return,n)}}}function hC(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wl(e)}catch(n){Te(t,t.return,n)}}function tB(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Gk),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Gk),t;default:throw Error(O(435,e.tag))}}function Qh(e,t){var n=tB(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=uB.bind(null,e,o);o.then(a,a)}})}function Jt(e,t){var n=t.deletions;if(n!==null)for(var o=0;o<n.length;o++){var a=n[o],r=e,s=t,i=s;e:for(;i!==null;){switch(i.tag){case 27:if(Fr(i.type)){Ve=i.stateNode,tn=!1;break e}break;case 5:Ve=i.stateNode,tn=!1;break e;case 3:case 4:Ve=i.stateNode.containerInfo,tn=!0;break e}i=i.return}if(Ve===null)throw Error(O(160));fC(r,s,a),Ve=null,tn=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)mC(t,e),t=t.sibling}var yo=null;function mC(e,t){var n=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Jt(t,e),en(e),o&4&&(Br(3,e,e.return),hd(3,e),Br(5,e,e.return));break;case 1:Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),o&64&&va&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?o:n.concat(o))));break;case 26:var a=yo;if(Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),o&4){var r=n!==null?n.memoizedState:null;if(o=e.memoizedState,n===null)if(o===null)if(e.stateNode===null){e:{o=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(o){case"title":r=a.getElementsByTagName("title")[0],(!r||r[ud]||r[It]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),Ot(r,o,n),r[It]=e,Lt(r),o=r;break e;case"link":var s=uw("link","href",a).get(o+(n.href||""));if(s){for(var i=0;i<s.length;i++)if(r=s[i],r.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&r.getAttribute("rel")===(n.rel==null?null:n.rel)&&r.getAttribute("title")===(n.title==null?null:n.title)&&r.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(i,1);break t}}r=a.createElement(o),Ot(r,o,n),a.head.appendChild(r);break;case"meta":if(s=uw("meta","content",a).get(o+(n.content||""))){for(i=0;i<s.length;i++)if(r=s[i],r.getAttribute("content")===(n.content==null?null:""+n.content)&&r.getAttribute("name")===(n.name==null?null:n.name)&&r.getAttribute("property")===(n.property==null?null:n.property)&&r.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(i,1);break t}}r=a.createElement(o),Ot(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[It]=e,Lt(r),o=r}e.stateNode=o}else dw(a,e.type,e.stateNode);else e.stateNode=cw(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?dw(a,e.type,e.stateNode):cw(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Px(e,e.memoizedProps,n.memoizedProps)}break;case 27:Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),n!==null&&o&4&&Px(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),e.flags&32){a=e.stateNode;try{Pl(a,"")}catch(h){Te(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,Px(e,a,n!==null?n.memoizedProps:a)),o&1024&&(Nx=!0);break;case 6:if(Jt(t,e),en(e),o&4){if(e.stateNode===null)throw Error(O(162));o=e.memoizedProps,n=e.stateNode;try{n.nodeValue=o}catch(h){Te(e,e.return,h)}}break;case 3:if(ym=null,a=yo,yo=Wm(t.containerInfo),Jt(t,e),yo=a,en(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{Wl(t.containerInfo)}catch(h){Te(e,e.return,h)}Nx&&(Nx=!1,yC(e));break;case 4:o=yo,yo=Wm(e.stateNode.containerInfo),Jt(t,e),en(e),yo=o;break;case 12:Jt(t,e),en(e);break;case 31:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 13:Jt(t,e),en(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(r0=Ln()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=va,u=st;if(va=c||a,st=u||l,Jt(t,e),st=u,va=c,en(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||va||st||Rs(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(r=l.stateNode,a)s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{i=l.stateNode;var d=l.memoizedProps.style,f=d!=null&&d.hasOwnProperty("display")?d.display:null;i.style.display=f==null||typeof f=="boolean"?"":(""+f).trim()}}catch(h){Te(l,l.return,h)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?"":l.memoizedProps}catch(h){Te(l,l.return,h)}}}else if(t.tag===18){if(n===null){l=t;try{var p=l.stateNode;a?aw(p,!0):aw(l.stateNode,!1)}catch(h){Te(l,l.return,h)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(n=o.retryQueue,n!==null&&(o.retryQueue=null,Qh(e,n))));break;case 19:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 30:break;case 21:break;default:Jt(t,e),en(e)}}function en(e){var t=e.flags;if(t&2){try{for(var n,o=e.return;o!==null;){if(lC(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=Bx(e);Pm(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(Pl(s,""),n.flags&=-33);var i=Bx(e);Pm(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=Bx(e);k1(e,c,l);break;default:throw Error(O(161))}}catch(u){Te(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yC(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yC(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function xa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)uC(e,t.alternate,t),t=t.sibling}function Rs(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Br(4,t,t.return),Rs(t);break;case 1:No(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&sC(t,t.return,n),Rs(t);break;case 27:ju(t.stateNode);case 26:case 5:No(t,t.return),Rs(t);break;case 22:t.memoizedState===null&&Rs(t);break;case 30:Rs(t);break;default:Rs(t)}e=e.sibling}}function ba(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,a=e,r=t,s=r.flags;switch(r.tag){case 0:case 11:case 15:ba(a,r,n),hd(4,r);break;case 1:if(ba(a,r,n),o=r,a=o.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(c){Te(o,o.return,c)}if(o=r,a=o.updateQueue,a!==null){var i=o.stateNode;try{var l=a.shared.hiddenCallbacks;if(l!==null)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)p_(l[a],i)}catch(c){Te(o,o.return,c)}}n&&s&64&&rC(r),Uu(r,r.return);break;case 27:cC(r);case 26:case 5:ba(a,r,n),n&&o===null&&s&4&&iC(r),Uu(r,r.return);break;case 12:ba(a,r,n);break;case 31:ba(a,r,n),n&&s&4&&pC(a,r);break;case 13:ba(a,r,n),n&&s&4&&hC(a,r);break;case 22:r.memoizedState===null&&ba(a,r,n),Uu(r,r.return);break;case 30:break;default:ba(a,r,n)}t=t.sibling}}function Lb(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&fd(n))}function kb(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fd(e))}function mo(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)gC(e,t,n,o),t=t.sibling}function gC(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:mo(e,t,n,o),a&2048&&hd(9,t);break;case 1:mo(e,t,n,o);break;case 3:mo(e,t,n,o),a&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fd(e)));break;case 12:if(a&2048){mo(e,t,n,o),e=t.stateNode;try{var r=t.memoizedProps,s=r.id,i=r.onPostCommit;typeof i=="function"&&i(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(l){Te(t,t.return,l)}}else mo(e,t,n,o);break;case 31:mo(e,t,n,o);break;case 13:mo(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?mo(e,t,n,o):Gu(e,t):r._visibility&2?mo(e,t,n,o):(r._visibility|=2,fl(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&Lb(s,t);break;case 24:mo(e,t,n,o),a&2048&&kb(t.alternate,t);break;default:mo(e,t,n,o)}}function fl(e,t,n,o,a){for(a=a&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var r=e,s=t,i=n,l=o,c=s.flags;switch(s.tag){case 0:case 11:case 15:fl(r,s,i,l,a),hd(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?fl(r,s,i,l,a):Gu(r,s):(u._visibility|=2,fl(r,s,i,l,a)),a&&c&2048&&Lb(s.alternate,s);break;case 24:fl(r,s,i,l,a),a&&c&2048&&kb(s.alternate,s);break;default:fl(r,s,i,l,a)}t=t.sibling}}function Gu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,o=t,a=o.flags;switch(o.tag){case 22:Gu(n,o),a&2048&&Lb(o.alternate,o);break;case 24:Gu(n,o),a&2048&&kb(o.alternate,o);break;default:Gu(n,o)}t=t.sibling}}var Ru=8192;function dl(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)xC(e,t,n),e=e.sibling}function xC(e,t,n){switch(e.tag){case 26:dl(e,t,n),e.flags&Ru&&e.memoizedState!==null&&FB(n,yo,e.memoizedState,e.memoizedProps);break;case 5:dl(e,t,n);break;case 3:case 4:var o=yo;yo=Wm(e.stateNode.containerInfo),dl(e,t,n),yo=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Ru,Ru=16777216,dl(e,t,n),Ru=o):dl(e,t,n));break;default:dl(e,t,n)}}function bC(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function wu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];St=o,vC(o,e)}bC(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)AC(e),e=e.sibling}function AC(e){switch(e.tag){case 0:case 11:case 15:wu(e),e.flags&2048&&Br(9,e,e.return);break;case 3:wu(e);break;case 12:wu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,hm(e)):wu(e);break;default:wu(e)}}function hm(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];St=o,vC(o,e)}bC(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Br(8,t,t.return),hm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,hm(t));break;default:hm(t)}e=e.sibling}}function vC(e,t){for(;St!==null;){var n=St;switch(n.tag){case 0:case 11:case 15:Br(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var o=n.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:fd(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,St=o;else e:for(n=e;St!==null;){o=St;var a=o.sibling,r=o.return;if(dC(o),o===n){St=null;break e}if(a!==null){a.return=r,St=a;break e}St=r}}}var nB={getCacheForType:function(e){var t=Rt(it),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Rt(it).controller.signal}},oB=typeof WeakMap=="function"?WeakMap:Map,ke=0,De=null,de=null,he=0,Ee=0,bn=null,Sr=!1,Xl=!1,wb=!1,Ra=0,Qe=0,Nr=0,Ns=0,_b=0,Sn=0,Fl=0,Wu=null,nn=null,w1=!1,r0=0,SC=0,Bm=1/0,Nm=null,Tr=null,pt=0,Ir=null,Hl=null,Ca=0,_1=0,C1=null,LC=null,qu=0,E1=null;function _n(){return(ke&2)!==0&&he!==0?he&-he:K.T!==null?Eb():Rw()}function kC(){if(Sn===0)if((he&536870912)===0||xe){var e=Gh;Gh<<=1,(Gh&3932160)===0&&(Gh=262144),Sn=e}else Sn=536870912;return e=En.current,e!==null&&(e.flags|=32),Sn}function on(e,t,n){(e===De&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)&&(Ul(e,0),Lr(e,he,Sn,!1)),cd(e,n),((ke&2)===0||e!==De)&&(e===De&&((ke&2)===0&&(Ns|=n),Qe===4&&Lr(e,he,Sn,!1)),Ho(e))}function wC(e,t,n){if((ke&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||ld(e,t),a=o?sB(e,t):zx(e,t,!0),r=o;do{if(a===0){Xl&&!o&&Lr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!aB(n)){a=zx(e,t,!1),r=!1;continue}if(a===2){if(r=t,e.errorRecoveryDisabledLanes&r)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var i=e;a=Wu;var l=i.current.memoizedState.isDehydrated;if(l&&(Ul(i,s).flags|=256),s=zx(i,s,!1),s!==2){if(wb&&!l){i.errorRecoveryDisabledLanes|=r,Ns|=r,a=4;break e}r=nn,nn=a,r!==null&&(nn===null?nn=r:nn.push.apply(nn,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){Ul(e,0),Lr(e,t,0,!0);break}e:{switch(o=e,r=a,r){case 0:case 1:throw Error(O(345));case 4:if((t&4194048)!==t)break;case 6:Lr(o,t,Sn,!Sr);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=r0+300-Ln(),10<a)){if(Lr(o,t,Sn,!Sr),Xm(o,0,!0)!==0)break e;Ca=t,o.timeoutHandle=jC(Wk.bind(null,o,n,nn,Nm,w1,t,Sn,Ns,Fl,Sr,r,"Throttled",-0,0),a);break e}Wk(o,n,nn,Nm,w1,t,Sn,Ns,Fl,Sr,r,null,-0,0)}}break}while(!0);Ho(e)}function Wk(e,t,n,o,a,r,s,i,l,c,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:La},xC(t,r,d);var h=(r&62914560)===r?r0-Ln():(r&4194048)===r?SC-Ln():0;if(h=HB(d,h),h!==null){Ca=r,e.cancelPendingCommit=h(jk.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),Lr(e,r,s,!c);return}}jk(e,t,r,n,o,a,s,i,l)}function aB(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var o=0;o<n.length;o++){var a=n[o],r=a.getSnapshot;a=a.value;try{if(!Cn(r(),a))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Lr(e,t,n,o){t&=~_b,t&=~Ns,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-wn(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&Tw(e,n,t)}function s0(){return(ke&6)===0?(md(0,!1),!1):!0}function Cb(){if(de!==null){if(Ee===0)var e=de.return;else e=de,ka=Zs=null,fb(e),Il=null,Qu=0,e=de;for(;e!==null;)aC(e.alternate,e),e=e.return;de=null}}function Ul(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,SB(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ca=0,Cb(),De=e,de=n=wa(e.current,null),he=t,Ee=0,bn=null,Sr=!1,Xl=ld(e,t),wb=!1,Fl=Sn=_b=Ns=Nr=Qe=0,nn=Wu=null,w1=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var a=31-wn(o),r=1<<a;t|=e[a],o&=~r}return Ra=t,Qm(),n}function _C(e,t){oe=null,K.H=ed,t===Zl||t===e0?(t=vk(),Ee=3):t===rb?(t=vk(),Ee=4):Ee=t===vb?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,bn=t,de===null&&(Qe=1,Om(e,Zn(t,e.current)))}function CC(){var e=En.current;return e===null?!0:(he&4194048)===he?Yn===null:(he&62914560)===he||(he&536870912)!==0?e===Yn:!1}function EC(){var e=K.H;return K.H=ed,e===null?ed:e}function TC(){var e=K.A;return K.A=nB,e}function zm(){Qe=4,Sr||(he&4194048)!==he&&En.current!==null||(Xl=!0),(Nr&134217727)===0&&(Ns&134217727)===0||De===null||Lr(De,he,Sn,!1)}function zx(e,t,n){var o=ke;ke|=2;var a=EC(),r=TC();(De!==e||he!==t)&&(Nm=null,Ul(e,t)),t=!1;var s=Qe;e:do try{if(Ee!==0&&de!==null){var i=de,l=bn;switch(Ee){case 8:Cb(),s=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(t=!0);var c=Ee;if(Ee=0,bn=null,wl(e,i,l,c),n&&Xl){s=0;break e}break;default:c=Ee,Ee=0,bn=null,wl(e,i,l,c)}}rB(),s=Qe;break}catch(u){_C(e,u)}while(!0);return t&&e.shellSuspendCounter++,ka=Zs=null,ke=o,K.H=a,K.A=r,de===null&&(De=null,he=0,Qm()),s}function rB(){for(;de!==null;)IC(de)}function sB(e,t){var n=ke;ke|=2;var o=EC(),a=TC();De!==e||he!==t?(Nm=null,Bm=Ln()+500,Ul(e,t)):Xl=ld(e,t);e:do try{if(Ee!==0&&de!==null){t=de;var r=bn;t:switch(Ee){case 1:Ee=0,bn=null,wl(e,t,r,1);break;case 2:case 9:if(Ak(r)){Ee=0,bn=null,qk(t);break}t=function(){Ee!==2&&Ee!==9||De!==e||(Ee=7),Ho(e)},r.then(t,t);break e;case 3:Ee=7;break e;case 4:Ee=5;break e;case 7:Ak(r)?(Ee=0,bn=null,qk(t)):(Ee=0,bn=null,wl(e,t,r,7));break;case 5:var s=null;switch(de.tag){case 26:s=de.memoizedState;case 5:case 27:var i=de;if(s?KC(s):i.stateNode.complete){Ee=0,bn=null;var l=i.sibling;if(l!==null)de=l;else{var c=i.return;c!==null?(de=c,i0(c)):de=null}break t}}Ee=0,bn=null,wl(e,t,r,5);break;case 6:Ee=0,bn=null,wl(e,t,r,6);break;case 8:Cb(),Qe=6;break e;default:throw Error(O(462))}}iB();break}catch(u){_C(e,u)}while(!0);return ka=Zs=null,K.H=o,K.A=a,ke=n,de!==null?0:(De=null,he=0,Qm(),Qe)}function iB(){for(;de!==null&&!IP();)IC(de)}function IC(e){var t=oC(e.alternate,e,Ra);e.memoizedProps=e.pendingProps,t===null?i0(e):de=t}function qk(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Nk(n,t,t.pendingProps,t.type,void 0,he);break;case 11:t=Nk(n,t,t.pendingProps,t.type.render,t.ref,he);break;case 5:fb(t);default:aC(n,t),t=de=a_(t,Ra),t=oC(n,t,Ra)}e.memoizedProps=e.pendingProps,t===null?i0(e):de=t}function wl(e,t,n,o){ka=Zs=null,fb(t),Il=null,Qu=0;var a=t.return;try{if(Y7(e,a,t,n,he)){Qe=1,Om(e,Zn(n,e.current)),de=null;return}}catch(r){if(a!==null)throw de=a,r;Qe=1,Om(e,Zn(n,e.current)),de=null;return}t.flags&32768?(xe||o===1?e=!0:Xl||(he&536870912)!==0?e=!1:(Sr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),MC(t,e)):i0(t)}function i0(e){var t=e;do{if((t.flags&32768)!==0){MC(t,Sr);return}e=t.return;var n=Q7(t.alternate,t,Ra);if(n!==null){de=n;return}if(t=t.sibling,t!==null){de=t;return}de=t=e}while(t!==null);Qe===0&&(Qe=5)}function MC(e,t){do{var n=J7(e.alternate,e);if(n!==null){n.flags&=32767,de=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){de=e;return}de=e=n}while(e!==null);Qe=6,de=null}function jk(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do l0();while(pt!==0);if((ke&6)!==0)throw Error(O(327));if(t!==null){if(t===e.current)throw Error(O(177));if(r=t.lanes|t.childLanes,r|=Q1,HP(e,n,r,s,i,l),e===De&&(de=De=null,he=0),Hl=t,Ir=e,Ca=n,_1=r,C1=a,LC=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,dB(Sm,function(){return BC(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=we.p,we.p=2,s=ke,ke|=4;try{eB(e,t,n)}finally{ke=s,we.p=a,K.T=o}}pt=1,RC(),OC(),DC()}}function RC(){if(pt===1){pt=0;var e=Ir,t=Hl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=we.p;we.p=2;var a=ke;ke|=4;try{mC(t,e);var r=R1,s=Kw(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&Yw(i.ownerDocument.documentElement,i)){if(l!==null&&$1(i)){var c=l.start,u=l.end;if(u===void 0&&(u=c),"selectionStart"in i)i.selectionStart=c,i.selectionEnd=Math.min(u,i.value.length);else{var d=i.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),h=i.textContent.length,m=Math.min(l.start,h),x=l.end===void 0?m:Math.min(l.end,h);!p.extend&&m>x&&(s=x,x=m,m=s);var y=pk(i,m),g=pk(i,x);if(y&&g&&(p.rangeCount!==1||p.anchorNode!==y.node||p.anchorOffset!==y.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var b=d.createRange();b.setStart(y.node,y.offset),p.removeAllRanges(),m>x?(p.addRange(b),p.extend(g.node,g.offset)):(b.setEnd(g.node,g.offset),p.addRange(b))}}}}for(d=[],p=i;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<d.length;i++){var A=d[i];A.element.scrollLeft=A.left,A.element.scrollTop=A.top}}Vm=!!M1,R1=M1=null}finally{ke=a,we.p=o,K.T=n}}e.current=t,pt=2}}function OC(){if(pt===2){pt=0;var e=Ir,t=Hl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=we.p;we.p=2;var a=ke;ke|=4;try{uC(e,t.alternate,t)}finally{ke=a,we.p=o,K.T=n}}pt=3}}function DC(){if(pt===4||pt===3){pt=0,MP();var e=Ir,t=Hl,n=Ca,o=LC;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?pt=5:(pt=0,Hl=Ir=null,PC(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(Tr=null),q1(n),t=t.stateNode,kn&&typeof kn.onCommitFiberRoot=="function")try{kn.onCommitFiberRoot(id,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=we.p,we.p=2,K.T=null;try{for(var r=e.onRecoverableError,s=0;s<o.length;s++){var i=o[s];r(i.value,{componentStack:i.stack})}}finally{K.T=t,we.p=a}}(Ca&3)!==0&&l0(),Ho(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===E1?qu++:(qu=0,E1=e):qu=0,md(0,!1)}}function PC(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,fd(t)))}function l0(){return RC(),OC(),DC(),BC()}function BC(){if(pt!==5)return!1;var e=Ir,t=_1;_1=0;var n=q1(Ca),o=K.T,a=we.p;try{we.p=32>n?32:n,K.T=null,n=C1,C1=null;var r=Ir,s=Ca;if(pt=0,Hl=Ir=null,Ca=0,(ke&6)!==0)throw Error(O(331));var i=ke;if(ke|=4,AC(r.current),gC(r,r.current,s,n),ke=i,md(0,!1),kn&&typeof kn.onPostCommitFiberRoot=="function")try{kn.onPostCommitFiberRoot(id,r)}catch{}return!0}finally{we.p=a,K.T=o,PC(e,t)}}function Vk(e,t,n){t=Zn(n,t),t=v1(e.stateNode,t,2),e=Er(e,t,2),e!==null&&(cd(e,2),Ho(e))}function Te(e,t,n){if(e.tag===3)Vk(e,e,n);else for(;t!==null;){if(t.tag===3){Vk(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Tr===null||!Tr.has(o))){e=Zn(n,e),n=$_(2),o=Er(t,n,2),o!==null&&(Q_(n,o,t,e),cd(o,2),Ho(o));break}}t=t.return}}function Fx(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new oB;var a=new Set;o.set(t,a)}else a=o.get(t),a===void 0&&(a=new Set,o.set(t,a));a.has(n)||(wb=!0,a.add(n),e=lB.bind(null,e,t,n),t.then(e,e))}function lB(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,De===e&&(he&n)===n&&(Qe===4||Qe===3&&(he&62914560)===he&&300>Ln()-r0?(ke&2)===0&&Ul(e,0):_b|=n,Fl===he&&(Fl=0)),Ho(e)}function NC(e,t){t===0&&(t=Ew()),e=Vs(e,t),e!==null&&(cd(e,t),Ho(e))}function cB(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),NC(e,n)}function uB(e,t){var n=0;switch(e.tag){case 31:case 13:var o=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(O(314))}o!==null&&o.delete(t),NC(e,n)}function dB(e,t){return G1(e,t)}var Fm=null,pl=null,T1=!1,Hm=!1,Hx=!1,kr=0;function Ho(e){e!==pl&&e.next===null&&(pl===null?Fm=pl=e:pl=pl.next=e),Hm=!0,T1||(T1=!0,pB())}function md(e,t){if(!Hx&&Hm){Hx=!0;do for(var n=!1,o=Fm;o!==null;){if(!t)if(e!==0){var a=o.pendingLanes;if(a===0)var r=0;else{var s=o.suspendedLanes,i=o.pingedLanes;r=(1<<31-wn(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,Zk(o,r))}else r=he,r=Xm(o,o===De?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||ld(o,r)||(n=!0,Zk(o,r));o=o.next}while(n);Hx=!1}}function fB(){zC()}function zC(){Hm=T1=!1;var e=0;kr!==0&&vB()&&(e=kr);for(var t=Ln(),n=null,o=Fm;o!==null;){var a=o.next,r=FC(o,t);r===0?(o.next=null,n===null?Fm=a:n.next=a,a===null&&(pl=n)):(n=o,(e!==0||(r&3)!==0)&&(Hm=!0)),o=a}pt!==0&&pt!==5||md(e,!1),kr!==0&&(kr=0)}function FC(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-wn(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=FP(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=De,n=he,n=Xm(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,n===0||e===t&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&mx(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||ld(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&mx(o),q1(n)){case 2:case 8:n=_w;break;case 32:n=Sm;break;case 268435456:n=Cw;break;default:n=Sm}return o=HC.bind(null,e),n=G1(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&mx(o),e.callbackPriority=2,e.callbackNode=null,2}function HC(e,t){if(pt!==0&&pt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(l0()&&e.callbackNode!==n)return null;var o=he;return o=Xm(e,e===De?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(wC(e,o,t),FC(e,Ln()),e.callbackNode!=null&&e.callbackNode===n?HC.bind(null,e):null)}function Zk(e,t){if(l0())return null;wC(e,t,!0)}function pB(){LB(function(){(ke&6)!==0?G1(ww,fB):zC()})}function Eb(){if(kr===0){var e=Bl;e===0&&(e=Uh,Uh<<=1,(Uh&261888)===0&&(Uh=256)),kr=e}return kr}function Xk(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:rm(""+e)}function Yk(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function hB(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=Xk((a[an]||null).action),s=o.submitter;s&&(t=(t=s[an]||null)?Xk(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new Ym("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(kr!==0){var l=s?Yk(a,s):new FormData(a);b1(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?Yk(a,s):new FormData(a),b1(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(Jh=0;Jh<i1.length;Jh++)em=i1[Jh],Kk=em.toLowerCase(),$k=em[0].toUpperCase()+em.slice(1),go(Kk,"on"+$k);var em,Kk,$k,Jh;go(Qw,"onAnimationEnd");go(Jw,"onAnimationIteration");go(e_,"onAnimationStart");go("dblclick","onDoubleClick");go("focusin","onFocus");go("focusout","onBlur");go(R7,"onTransitionRun");go(O7,"onTransitionStart");go(D7,"onTransitionCancel");go(t_,"onTransitionEnd");Dl("onMouseEnter",["mouseout","mouseover"]);Dl("onMouseLeave",["mouseout","mouseover"]);Dl("onPointerEnter",["pointerout","pointerover"]);Dl("onPointerLeave",["pointerout","pointerover"]);Ws("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ws("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ws("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ws("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ws("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ws("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var td="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(" "),mB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(td));function UC(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var o=e[n],a=o.event;o=o.listeners;e:{var r=void 0;if(t)for(var s=o.length-1;0<=s;s--){var i=o[s],l=i.instance,c=i.currentTarget;if(i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){km(u)}a.currentTarget=null,r=l}else for(s=0;s<o.length;s++){if(i=o[s],l=i.instance,c=i.currentTarget,i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){km(u)}a.currentTarget=null,r=l}}}}function ue(e,t){var n=t[Jx];n===void 0&&(n=t[Jx]=new Set);var o=e+"__bubble";n.has(o)||(GC(t,e,2,!1),n.add(o))}function Ux(e,t,n){var o=0;t&&(o|=4),GC(n,e,o,t)}var tm="_reactListening"+Math.random().toString(36).slice(2);function Tb(e){if(!e[tm]){e[tm]=!0,Ow.forEach(function(n){n!=="selectionchange"&&(mB.has(n)||Ux(n,!1,e),Ux(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[tm]||(t[tm]=!0,Ux("selectionchange",!1,t))}}function GC(e,t,n,o){switch(tE(t)){case 2:var a=WB;break;case 8:a=qB;break;default:a=Ob}n=a.bind(null,t,n,e),a=void 0,!a1||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),o?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Gx(e,t,n,o,a){var r=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var s=o.tag;if(s===3||s===4){var i=o.stateNode.containerInfo;if(i===a)break;if(s===4)for(s=o.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===a)return;s=s.return}for(;i!==null;){if(s=yl(i),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){o=r=s;continue e}i=i.parentNode}}o=o.return}Uw(function(){var c=r,u=Z1(n),d=[];e:{var f=n_.get(e);if(f!==void 0){var p=Ym,h=e;switch(e){case"keypress":if(im(n)===0)break e;case"keydown":case"keyup":p=u7;break;case"focusin":h="focus",p=Ax;break;case"focusout":h="blur",p=Ax;break;case"beforeblur":case"afterblur":p=Ax;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=ak;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=QP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=p7;break;case Qw:case Jw:case e_:p=t7;break;case t_:p=m7;break;case"scroll":case"scrollend":p=KP;break;case"wheel":p=g7;break;case"copy":case"cut":case"paste":p=o7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=sk;break;case"toggle":case"beforetoggle":p=b7}var m=(t&4)!==0,x=!m&&(e==="scroll"||e==="scrollend"),y=m?f!==null?f+"Capture":null:f;m=[];for(var g=c,b;g!==null;){var A=g;if(b=A.stateNode,A=A.tag,A!==5&&A!==26&&A!==27||b===null||y===null||(A=Zu(g,y),A!=null&&m.push(nd(g,A,b))),x)break;g=g.return}0<m.length&&(f=new p(f,h,null,n,u),d.push({event:f,listeners:m}))}}if((t&7)===0){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==o1&&(h=n.relatedTarget||n.fromElement)&&(yl(h)||h[ql]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(h=n.relatedTarget||n.toElement,p=c,h=h?yl(h):null,h!==null&&(x=sd(h),m=h.tag,h!==x||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=ak,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=sk,A="onPointerLeave",y="onPointerEnter",g="pointer"),x=p==null?f:Iu(p),b=h==null?f:Iu(h),f=new m(A,g+"leave",p,n,u),f.target=x,f.relatedTarget=b,A=null,yl(u)===c&&(m=new m(y,g+"enter",h,n,u),m.target=b,m.relatedTarget=x,A=m),x=A,p&&h)t:{for(m=yB,y=p,g=h,b=0,A=y;A;A=m(A))b++;A=0;for(var _=g;_;_=m(_))A++;for(;0<b-A;)y=m(y),b--;for(;0<A-b;)g=m(g),A--;for(;b--;){if(y===g||g!==null&&y===g.alternate){m=y;break t}y=m(y),g=m(g)}m=null}else m=null;p!==null&&Qk(d,f,p,m,!1),h!==null&&x!==null&&Qk(d,x,h,m,!0)}}e:{if(f=c?Iu(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var T=uk;else if(ck(f))if(Zw)T=T7;else{T=C7;var w=_7}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&V1(c.elementType)&&(T=uk):T=E7;if(T&&(T=T(e,c))){Vw(d,T,n,u);break e}w&&w(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&n1(f,"number",f.value)}switch(w=c?Iu(c):window,e){case"focusin":(ck(w)||w.contentEditable==="true")&&(bl=w,r1=c,Pu=null);break;case"focusout":Pu=r1=bl=null;break;case"mousedown":s1=!0;break;case"contextmenu":case"mouseup":case"dragend":s1=!1,hk(d,n,u);break;case"selectionchange":if(M7)break;case"keydown":case"keyup":hk(d,n,u)}var S;if(K1)e:{switch(e){case"compositionstart":var L="onCompositionStart";break e;case"compositionend":L="onCompositionEnd";break e;case"compositionupdate":L="onCompositionUpdate";break e}L=void 0}else xl?qw(e,n)&&(L="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(L="onCompositionStart");L&&(Ww&&n.locale!=="ko"&&(xl||L!=="onCompositionStart"?L==="onCompositionEnd"&&xl&&(S=Gw()):(vr=u,X1="value"in vr?vr.value:vr.textContent,xl=!0)),w=Um(c,L),0<w.length&&(L=new rk(L,e,null,n,u),d.push({event:L,listeners:w}),S?L.data=S:(S=jw(n),S!==null&&(L.data=S)))),(S=v7?S7(e,n):L7(e,n))&&(L=Um(c,"onBeforeInput"),0<L.length&&(w=new rk("onBeforeInput","beforeinput",null,n,u),d.push({event:w,listeners:L}),w.data=S)),hB(d,e,c,n,u)}UC(d,t)})}function nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Um(e,t){for(var n=t+"Capture",o=[];e!==null;){var a=e,r=a.stateNode;if(a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=Zu(e,n),a!=null&&o.unshift(nd(e,a,r)),a=Zu(e,t),a!=null&&o.push(nd(e,a,r))),e.tag===3)return o;e=e.return}return[]}function yB(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Qk(e,t,n,o,a){for(var r=t._reactName,s=[];n!==null&&n!==o;){var i=n,l=i.alternate,c=i.stateNode;if(i=i.tag,l!==null&&l===o)break;i!==5&&i!==26&&i!==27||c===null||(l=c,a?(c=Zu(n,r),c!=null&&s.unshift(nd(n,c,l))):a||(c=Zu(n,r),c!=null&&s.push(nd(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var gB=/\r\n?/g,xB=/\u0000|\uFFFD/g;function Jk(e){return(typeof e=="string"?e:""+e).replace(gB,`
9
- `).replace(xB,"")}function WC(e,t){return t=Jk(t),Jk(e)===t}function Ie(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Pl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Pl(e,""+o);break;case"className":qh(e,"class",o);break;case"tabIndex":qh(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":qh(e,n,o);break;case"style":Hw(e,o,r);break;case"data":if(t!=="object"){qh(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=rm(""+o),e.setAttribute(n,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof r=="function"&&(n==="formAction"?(t!=="input"&&Ie(e,t,"name",a.name,a,null),Ie(e,t,"formEncType",a.formEncType,a,null),Ie(e,t,"formMethod",a.formMethod,a,null),Ie(e,t,"formTarget",a.formTarget,a,null)):(Ie(e,t,"encType",a.encType,a,null),Ie(e,t,"method",a.method,a,null),Ie(e,t,"target",a.target,a,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=rm(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=La);break;case"onScroll":o!=null&&ue("scroll",e);break;case"onScrollEnd":o!=null&&ue("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}n=rm(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""+o):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":o===!0?e.setAttribute(n,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,o):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(n,o):e.removeAttribute(n);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(n):e.setAttribute(n,o);break;case"popover":ue("beforetoggle",e),ue("toggle",e),am(e,"popover",o);break;case"xlinkActuate":ma(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ma(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ma(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ma(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ma(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ma(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ma(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ma(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ma(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":am(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=XP.get(n)||n,am(e,n,o))}}function I1(e,t,n,o,a,r){switch(n){case"style":Hw(e,o,r);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"children":typeof o=="string"?Pl(e,o):(typeof o=="number"||typeof o=="bigint")&&Pl(e,""+o);break;case"onScroll":o!=null&&ue("scroll",e);break;case"onScrollEnd":o!=null&&ue("scrollend",e);break;case"onClick":o!=null&&(e.onclick=La);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Dw.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),r=e[an]||null,r=r!=null?r[n]:null,typeof r=="function"&&e.removeEventListener(t,r,a),typeof o=="function")){typeof r!="function"&&r!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,o,a);break e}n in e?e[n]=o:o===!0?e.setAttribute(n,""):am(e,n,o)}}}function Ot(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ue("error",e),ue("load",e);var o=!1,a=!1,r;for(r in n)if(n.hasOwnProperty(r)){var s=n[r];if(s!=null)switch(r){case"src":o=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,r,s,n,null)}}a&&Ie(e,t,"srcSet",n.srcSet,n,null),o&&Ie(e,t,"src",n.src,n,null);return;case"input":ue("invalid",e);var i=r=s=a=null,l=null,c=null;for(o in n)if(n.hasOwnProperty(o)){var u=n[o];if(u!=null)switch(o){case"name":a=u;break;case"type":s=u;break;case"checked":l=u;break;case"defaultChecked":c=u;break;case"value":r=u;break;case"defaultValue":i=u;break;case"children":case"dangerouslySetInnerHTML":if(u!=null)throw Error(O(137,t));break;default:Ie(e,t,o,u,n,null)}}Nw(e,r,i,l,c,s,a,!1);return;case"select":ue("invalid",e),o=s=r=null;for(a in n)if(n.hasOwnProperty(a)&&(i=n[a],i!=null))switch(a){case"value":r=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:Ie(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Cl(e,!!o,t,!1):n!=null&&Cl(e,!!o,n,!0);return;case"textarea":ue("invalid",e),r=a=o=null;for(s in n)if(n.hasOwnProperty(s)&&(i=n[s],i!=null))switch(s){case"value":o=i;break;case"defaultValue":a=i;break;case"children":r=i;break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(O(91));break;default:Ie(e,t,s,i,n,null)}Fw(e,o,a,r);return;case"option":for(l in n)if(n.hasOwnProperty(l)&&(o=n[l],o!=null))switch(l){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:Ie(e,t,l,o,n,null)}return;case"dialog":ue("beforetoggle",e),ue("toggle",e),ue("cancel",e),ue("close",e);break;case"iframe":case"object":ue("load",e);break;case"video":case"audio":for(o=0;o<td.length;o++)ue(td[o],e);break;case"image":ue("error",e),ue("load",e);break;case"details":ue("toggle",e);break;case"embed":case"source":case"link":ue("error",e),ue("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(c in n)if(n.hasOwnProperty(c)&&(o=n[c],o!=null))switch(c){case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,c,o,n,null)}return;default:if(V1(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&I1(e,t,u,o,n,void 0));return}}for(i in n)n.hasOwnProperty(i)&&(o=n[i],o!=null&&Ie(e,t,i,o,n,null))}function bB(e,t,n,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,r=null,s=null,i=null,l=null,c=null,u=null;for(p in n){var d=n[p];if(n.hasOwnProperty(p)&&d!=null)switch(p){case"checked":break;case"value":break;case"defaultValue":l=d;default:o.hasOwnProperty(p)||Ie(e,t,p,null,o,d)}}for(var f in o){var p=o[f];if(d=n[f],o.hasOwnProperty(f)&&(p!=null||d!=null))switch(f){case"type":r=p;break;case"name":a=p;break;case"checked":c=p;break;case"defaultChecked":u=p;break;case"value":s=p;break;case"defaultValue":i=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(O(137,t));break;default:p!==d&&Ie(e,t,f,p,o,d)}}t1(e,s,i,l,c,u,r,a);return;case"select":p=s=i=f=null;for(r in n)if(l=n[r],n.hasOwnProperty(r)&&l!=null)switch(r){case"value":break;case"multiple":p=l;default:o.hasOwnProperty(r)||Ie(e,t,r,null,o,l)}for(a in o)if(r=o[a],l=n[a],o.hasOwnProperty(a)&&(r!=null||l!=null))switch(a){case"value":f=r;break;case"defaultValue":i=r;break;case"multiple":s=r;default:r!==l&&Ie(e,t,a,r,o,l)}t=i,n=s,o=p,f!=null?Cl(e,!!n,f,!1):!!o!=!!n&&(t!=null?Cl(e,!!n,t,!0):Cl(e,!!n,n?[]:"",!1));return;case"textarea":p=f=null;for(i in n)if(a=n[i],n.hasOwnProperty(i)&&a!=null&&!o.hasOwnProperty(i))switch(i){case"value":break;case"children":break;default:Ie(e,t,i,null,o,a)}for(s in o)if(a=o[s],r=n[s],o.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(O(91));break;default:a!==r&&Ie(e,t,s,a,o,r)}zw(e,f,p);return;case"option":for(var h in n)if(f=n[h],n.hasOwnProperty(h)&&f!=null&&!o.hasOwnProperty(h))switch(h){case"selected":e.selected=!1;break;default:Ie(e,t,h,null,o,f)}for(l in o)if(f=o[l],p=n[l],o.hasOwnProperty(l)&&f!==p&&(f!=null||p!=null))switch(l){case"selected":e.selected=f&&typeof f!="function"&&typeof f!="symbol";break;default:Ie(e,t,l,f,o,p)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var m in n)f=n[m],n.hasOwnProperty(m)&&f!=null&&!o.hasOwnProperty(m)&&Ie(e,t,m,null,o,f);for(c in o)if(f=o[c],p=n[c],o.hasOwnProperty(c)&&f!==p&&(f!=null||p!=null))switch(c){case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(O(137,t));break;default:Ie(e,t,c,f,o,p)}return;default:if(V1(t)){for(var x in n)f=n[x],n.hasOwnProperty(x)&&f!==void 0&&!o.hasOwnProperty(x)&&I1(e,t,x,void 0,o,f);for(u in o)f=o[u],p=n[u],!o.hasOwnProperty(u)||f===p||f===void 0&&p===void 0||I1(e,t,u,f,o,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&f!=null&&!o.hasOwnProperty(y)&&Ie(e,t,y,null,o,f);for(d in o)f=o[d],p=n[d],!o.hasOwnProperty(d)||f===p||f==null&&p==null||Ie(e,t,d,f,o,p)}function ew(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function AB(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),o=0;o<n.length;o++){var a=n[o],r=a.transferSize,s=a.initiatorType,i=a.duration;if(r&&i&&ew(s)){for(s=0,i=a.responseEnd,o+=1;o<n.length;o++){var l=n[o],c=l.startTime;if(c>i)break;var u=l.transferSize,d=l.initiatorType;u&&ew(d)&&(l=l.responseEnd,s+=u*(l<i?1:(i-c)/(l-c)))}if(--o,t+=8*(r+s)/(a.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var M1=null,R1=null;function Gm(e){return e.nodeType===9?e:e.ownerDocument}function tw(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function qC(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function O1(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wx=null;function vB(){var e=window.event;return e&&e.type==="popstate"?e===Wx?!1:(Wx=e,!0):(Wx=null,!1)}var jC=typeof setTimeout=="function"?setTimeout:void 0,SB=typeof clearTimeout=="function"?clearTimeout:void 0,nw=typeof Promise=="function"?Promise:void 0,LB=typeof queueMicrotask=="function"?queueMicrotask:typeof nw<"u"?function(e){return nw.resolve(null).then(e).catch(kB)}:jC;function kB(e){setTimeout(function(){throw e})}function Fr(e){return e==="head"}function ow(e,t){var n=t,o=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"||n==="/&"){if(o===0){e.removeChild(a),Wl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")ju(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,ju(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[ud]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&ju(e.ownerDocument.body);n=a}while(n);Wl(t)}function aw(e,t){var n=e;e=0;do{var o=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=o}while(n)}function D1(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":D1(n),j1(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function wB(e,t,n,o){for(;e.nodeType===1;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[ud])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(r=e.getAttribute("rel"),r==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(a.href==null||a.href===""?null:a.href)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||e.getAttribute("title")!==(a.title==null?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(r=e.getAttribute("src"),(r!==(a.src==null?null:a.src)||e.getAttribute("type")!==(a.type==null?null:a.type)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&e.getAttribute("name")===r)return e}else return e;if(e=Kn(e.nextSibling),e===null)break}return null}function _B(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Kn(e.nextSibling),e===null))return null;return e}function VC(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Kn(e.nextSibling),e===null))return null;return e}function P1(e){return e.data==="$?"||e.data==="$~"}function B1(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function CB(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var o=function(){t(),n.removeEventListener("DOMContentLoaded",o)};n.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Kn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var N1=null;function rw(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Kn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function sw(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function ZC(e,t,n){switch(t=Gm(n),e){case"html":if(e=t.documentElement,!e)throw Error(O(452));return e;case"head":if(e=t.head,!e)throw Error(O(453));return e;case"body":if(e=t.body,!e)throw Error(O(454));return e;default:throw Error(O(451))}}function ju(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);j1(e)}var $n=new Map,iw=new Set;function Wm(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Oa=we.d;we.d={f:EB,r:TB,D:IB,C:MB,L:RB,m:OB,X:PB,S:DB,M:BB};function EB(){var e=Oa.f(),t=s0();return e||t}function TB(e){var t=jl(e);t!==null&&t.tag===5&&t.type==="form"?H_(t):Oa.r(e)}var Yl=typeof document>"u"?null:document;function XC(e,t,n){var o=Yl;if(o&&typeof t=="string"&&t){var a=Vn(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),iw.has(a)||(iw.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),Ot(t,"link",e),Lt(t),o.head.appendChild(t)))}}function IB(e){Oa.D(e),XC("dns-prefetch",e,null)}function MB(e,t){Oa.C(e,t),XC("preconnect",e,t)}function RB(e,t,n){Oa.L(e,t,n);var o=Yl;if(o&&e&&t){var a='link[rel="preload"][as="'+Vn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+Vn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+Vn(n.imageSizes)+'"]')):a+='[href="'+Vn(e)+'"]';var r=a;switch(t){case"style":r=Gl(e);break;case"script":r=Kl(e)}$n.has(r)||(e=qe({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),$n.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(yd(r))||t==="script"&&o.querySelector(gd(r))||(t=o.createElement("link"),Ot(t,"link",e),Lt(t),o.head.appendChild(t)))}}function OB(e,t){Oa.m(e,t);var n=Yl;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+Vn(o)+'"][href="'+Vn(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Kl(e)}if(!$n.has(r)&&(e=qe({rel:"modulepreload",href:e},t),$n.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(gd(r)))return}o=n.createElement("link"),Ot(o,"link",e),Lt(o),n.head.appendChild(o)}}}function DB(e,t,n){Oa.S(e,t,n);var o=Yl;if(o&&e){var a=_l(o).hoistableStyles,r=Gl(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(yd(r)))i.loading=5;else{e=qe({rel:"stylesheet",href:e,"data-precedence":t},n),(n=$n.get(r))&&Ib(e,n);var l=s=o.createElement("link");Lt(l),Ot(l,"link",e),l._p=new Promise(function(c,u){l.onload=c,l.onerror=u}),l.addEventListener("load",function(){i.loading|=1}),l.addEventListener("error",function(){i.loading|=2}),i.loading|=4,mm(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function PB(e,t){Oa.X(e,t);var n=Yl;if(n&&e){var o=_l(n).hoistableScripts,a=Kl(e),r=o.get(a);r||(r=n.querySelector(gd(a)),r||(e=qe({src:e,async:!0},t),(t=$n.get(a))&&Mb(e,t),r=n.createElement("script"),Lt(r),Ot(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function BB(e,t){Oa.M(e,t);var n=Yl;if(n&&e){var o=_l(n).hoistableScripts,a=Kl(e),r=o.get(a);r||(r=n.querySelector(gd(a)),r||(e=qe({src:e,async:!0,type:"module"},t),(t=$n.get(a))&&Mb(e,t),r=n.createElement("script"),Lt(r),Ot(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function lw(e,t,n,o){var a=(a=wr.current)?Wm(a):null;if(!a)throw Error(O(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Gl(n.href),n=_l(a).hoistableStyles,o=n.get(t),o||(o={type:"style",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Gl(n.href);var r=_l(a).hoistableStyles,s=r.get(e);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(e,s),(r=a.querySelector(yd(e)))&&!r._p&&(s.instance=r,s.state.loading=5),$n.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},$n.set(e,n),r||NB(a,e,n,s.state))),t&&o===null)throw Error(O(528,""));return s}if(t&&o!==null)throw Error(O(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Kl(n),n=_l(a).hoistableScripts,o=n.get(t),o||(o={type:"script",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(O(444,e))}}function Gl(e){return'href="'+Vn(e)+'"'}function yd(e){return'link[rel="stylesheet"]['+e+"]"}function YC(e){return qe({},e,{"data-precedence":e.precedence,precedence:null})}function NB(e,t,n,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),Ot(t,"link",n),Lt(t),e.head.appendChild(t))}function Kl(e){return'[src="'+Vn(e)+'"]'}function gd(e){return"script[async]"+e}function cw(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Vn(n.href)+'"]');if(o)return t.instance=o,Lt(o),o;var a=qe({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Lt(o),Ot(o,"style",a),mm(o,n.precedence,e),t.instance=o;case"stylesheet":a=Gl(n.href);var r=e.querySelector(yd(a));if(r)return t.state.loading|=4,t.instance=r,Lt(r),r;o=YC(n),(a=$n.get(a))&&Ib(o,a),r=(e.ownerDocument||e).createElement("link"),Lt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Ot(r,"link",o),t.state.loading|=4,mm(r,n.precedence,e),t.instance=r;case"script":return r=Kl(n.src),(a=e.querySelector(gd(r)))?(t.instance=a,Lt(a),a):(o=n,(a=$n.get(r))&&(o=qe({},n),Mb(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),Lt(a),Ot(a,"link",o),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(O(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,mm(o,n.precedence,e));return t.instance}function mm(e,t,n){for(var o=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=o.length?o[o.length-1]:null,r=a,s=0;s<o.length;s++){var i=o[s];if(i.dataset.precedence===t)r=i;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Ib(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Mb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ym=null;function uw(e,t,n){if(ym===null){var o=new Map,a=ym=new Map;a.set(n,o)}else a=ym,o=a.get(n),o||(o=new Map,a.set(n,o));if(o.has(e))return o;for(o.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var r=n[a];if(!(r[ud]||r[It]||e==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(t)||"";s=e+s;var i=o.get(s);i?i.push(r):o.set(s,[r])}}return o}function dw(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function zB(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function KC(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function FB(e,t,n,o){if(n.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var a=Gl(o.href),r=t.querySelector(yd(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=qm.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,Lt(r);return}r=t.ownerDocument||t,o=YC(o),(a=$n.get(a))&&Ib(o,a),r=r.createElement("link"),Lt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Ot(r,"link",o),n.instance=r}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=qm.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var qx=0;function HB(e,t){return e.stylesheets&&e.count===0&&gm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&gm(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&qx===0&&(qx=62500*AB());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&gm(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>qx?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function qm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var jm=null;function gm(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,jm=new Map,t.forEach(UB,e),jm=null,qm.call(e))}function UB(e,t){if(!(t.state.loading&4)){var n=jm.get(e);if(n)var o=n.get(null);else{n=new Map,jm.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),o=s)}o&&n.set(null,o)}a=t.instance,s=a.getAttribute("data-precedence"),r=n.get(s)||o,r===o&&n.set(null,a),n.set(s,a),this.count++,o=qm.bind(this),a.addEventListener("load",o),a.addEventListener("error",o),r?r.parentNode.insertBefore(a,r.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(a,e.firstChild)),t.state.loading|=4}}var od={$$typeof:Sa,Provider:null,Consumer:null,_currentValue:Os,_currentValue2:Os,_threadCount:0};function GB(e,t,n,o,a,r,s,i,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=yx(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yx(0),this.hiddenUpdates=yx(null),this.identifierPrefix=o,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function $C(e,t,n,o,a,r,s,i,l,c,u,d){return e=new GB(e,t,n,s,l,c,u,d,i),t=1,r===!0&&(t|=24),r=vn(3,null,null,t),e.current=r,r.stateNode=e,t=ob(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},sb(r),e}function QC(e){return e?(e=Sl,e):Sl}function JC(e,t,n,o,a,r){a=QC(a),o.context===null?o.context=a:o.pendingContext=a,o=Cr(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=Er(e,o,t),n!==null&&(on(n,e,t),Nu(n,e,t))}function fw(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rb(e,t){fw(e,t),(e=e.alternate)&&fw(e,t)}function eE(e){if(e.tag===13||e.tag===31){var t=Vs(e,67108864);t!==null&&on(t,e,67108864),Rb(e,67108864)}}function pw(e){if(e.tag===13||e.tag===31){var t=_n();t=W1(t);var n=Vs(e,t);n!==null&&on(n,e,t),Rb(e,t)}}var Vm=!0;function WB(e,t,n,o){var a=K.T;K.T=null;var r=we.p;try{we.p=2,Ob(e,t,n,o)}finally{we.p=r,K.T=a}}function qB(e,t,n,o){var a=K.T;K.T=null;var r=we.p;try{we.p=8,Ob(e,t,n,o)}finally{we.p=r,K.T=a}}function Ob(e,t,n,o){if(Vm){var a=z1(o);if(a===null)Gx(e,t,o,Zm,n),hw(e,o);else if(VB(a,e,t,n,o))o.stopPropagation();else if(hw(e,o),t&4&&-1<jB.indexOf(e)){for(;a!==null;){var r=jl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=Is(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-wn(s);i.entanglements[1]|=l,s&=~l}Ho(r),(ke&6)===0&&(Bm=Ln()+500,md(0,!1))}}break;case 31:case 13:i=Vs(r,2),i!==null&&on(i,r,2),s0(),Rb(r,2)}if(r=z1(o),r===null&&Gx(e,t,o,Zm,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else Gx(e,t,o,null,n)}}function z1(e){return e=Z1(e),Db(e)}var Zm=null;function Db(e){if(Zm=null,e=yl(e),e!==null){var t=sd(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=Aw(t),e!==null)return e;e=null}else if(n===31){if(e=vw(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Zm=e,null}function tE(e){switch(e){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(RP()){case ww:return 2;case _w:return 8;case Sm:case OP:return 32;case Cw:return 268435456;default:return 32}default:return 32}}var F1=!1,Mr=null,Rr=null,Or=null,ad=new Map,rd=new Map,br=[],jB="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".split(" ");function hw(e,t){switch(e){case"focusin":case"focusout":Mr=null;break;case"dragenter":case"dragleave":Rr=null;break;case"mouseover":case"mouseout":Or=null;break;case"pointerover":case"pointerout":ad.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":rd.delete(t.pointerId)}}function _u(e,t,n,o,a,r){return e===null||e.nativeEvent!==r?(e={blockedOn:t,domEventName:n,eventSystemFlags:o,nativeEvent:r,targetContainers:[a]},t!==null&&(t=jl(t),t!==null&&eE(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function VB(e,t,n,o,a){switch(t){case"focusin":return Mr=_u(Mr,e,t,n,o,a),!0;case"dragenter":return Rr=_u(Rr,e,t,n,o,a),!0;case"mouseover":return Or=_u(Or,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return ad.set(r,_u(ad.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,rd.set(r,_u(rd.get(r)||null,e,t,n,o,a)),!0}return!1}function nE(e){var t=yl(e.target);if(t!==null){var n=sd(t);if(n!==null){if(t=n.tag,t===13){if(t=Aw(n),t!==null){e.blockedOn=t,$3(e.priority,function(){pw(n)});return}}else if(t===31){if(t=vw(n),t!==null){e.blockedOn=t,$3(e.priority,function(){pw(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function xm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=z1(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);o1=o,n.target.dispatchEvent(o),o1=null}else return t=jl(n),t!==null&&eE(t),e.blockedOn=n,!1;t.shift()}return!0}function mw(e,t,n){xm(e)&&n.delete(t)}function ZB(){F1=!1,Mr!==null&&xm(Mr)&&(Mr=null),Rr!==null&&xm(Rr)&&(Rr=null),Or!==null&&xm(Or)&&(Or=null),ad.forEach(mw),rd.forEach(mw)}function nm(e,t){e.blockedOn===t&&(e.blockedOn=null,F1||(F1=!0,ht.unstable_scheduleCallback(ht.unstable_NormalPriority,ZB)))}var om=null;function yw(e){om!==e&&(om=e,ht.unstable_scheduleCallback(ht.unstable_NormalPriority,function(){om===e&&(om=null);for(var t=0;t<e.length;t+=3){var n=e[t],o=e[t+1],a=e[t+2];if(typeof o!="function"){if(Db(o||n)===null)continue;break}var r=jl(n);r!==null&&(e.splice(t,3),t-=3,b1(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function Wl(e){function t(l){return nm(l,e)}Mr!==null&&nm(Mr,e),Rr!==null&&nm(Rr,e),Or!==null&&nm(Or,e),ad.forEach(t),rd.forEach(t);for(var n=0;n<br.length;n++){var o=br[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<br.length&&(n=br[0],n.blockedOn===null);)nE(n),n.blockedOn===null&&br.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(o=0;o<n.length;o+=3){var a=n[o],r=n[o+1],s=a[an]||null;if(typeof r=="function")s||yw(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[an]||null)i=s.formAction;else if(Db(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),yw(n)}}}function oE(){function e(r){r.canIntercept&&r.info==="react-transition"&&r.intercept({handler:function(){return new Promise(function(s){return a=s})},focusReset:"manual",scroll:"manual"})}function t(){a!==null&&(a(),a=null),o||setTimeout(n,20)}function n(){if(!o&&!navigation.transition){var r=navigation.currentEntry;r&&r.url!=null&&navigation.navigate(r.url,{state:r.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),a!==null&&(a(),a=null)}}}function Pb(e){this._internalRoot=e}c0.prototype.render=Pb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=_n();JC(n,o,e,t,null,null)};c0.prototype.unmount=Pb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;JC(e.current,2,null,e,null,null),s0(),t[ql]=null}};function c0(e){this._internalRoot=e}c0.prototype.unstable_scheduleHydration=function(e){if(e){var t=Rw();e={blockedOn:null,target:e,priority:t};for(var n=0;n<br.length&&t!==0&&t<br[n].priority;n++);br.splice(n,0,e),n===0&&nE(e)}};var gw=xw.version;if(gw!=="19.2.6")throw Error(O(527,gw,"19.2.6"));we.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=wP(t),e=e!==null?Sw(e):null,e=e===null?null:e.stateNode,e};var XB={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(Cu=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Cu.isDisabled&&Cu.supportsFiber))try{id=Cu.inject(XB),kn=Cu}catch{}var Cu;u0.createRoot=function(e,t){if(!bw(e))throw Error(O(299));var n=!1,o="",a=X_,r=Y_,s=K_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(r=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=$C(e,1,!1,null,null,n,o,null,a,r,s,oE),e[ql]=t.current,Tb(e),new Pb(t)};u0.hydrateRoot=function(e,t,n){if(!bw(e))throw Error(O(299));var o=!1,a="",r=X_,s=Y_,i=K_,l=null;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onUncaughtError!==void 0&&(r=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(i=n.onRecoverableError),n.formState!==void 0&&(l=n.formState)),t=$C(e,1,!0,t,n??null,o,a,l,r,s,i,oE),t.context=QC(null),n=t.current,o=_n(),o=W1(o),a=Cr(o),a.callback=null,Er(n,a,o),n=o,t.current.lanes=n,cd(t,n),Ho(t),e[ql]=t.current,Tb(e),new c0(t)};u0.version="19.2.6"});var iE=Ht((x$,sE)=>{"use strict";function rE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rE)}catch(e){console.error(e)}}rE(),sE.exports=aE()});var cE=Ht(d0=>{"use strict";var YB=Symbol.for("react.transitional.element"),KB=Symbol.for("react.fragment");function lE(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var a in t)a!=="key"&&(n[a]=t[a])}else n=t;return t=n.ref,{$$typeof:YB,type:e,key:o,ref:t!==void 0?t:null,props:n}}d0.Fragment=KB;d0.jsx=lE;d0.jsxs=lE});var se=Ht((A$,uE)=>{"use strict";uE.exports=cE()});var JL=Ht(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.loop=Ss.conditional=Ss.parse=void 0;var lK=function e(t,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:o;if(Array.isArray(n))n.forEach(function(s){return e(t,s,o,a)});else if(typeof n=="function")n(t,o,a,e);else{var r=Object.keys(n)[0];Array.isArray(n[r])?(a[r]={},e(t,n[r],o,a[r])):a[r]=n[r](t,o,a,e)}return o};Ss.parse=lK;var cK=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Ss.conditional=cK;var uK=function(t,n){return function(o,a,r,s){for(var i=[],l=o.pos;n(o,a,r);){var c={};if(s(o,t,a,c),o.pos===l)break;l=o.pos,i.push(c)}return i}};Ss.loop=uK});var e3=Ht(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.readBits=dt.readArray=dt.readUnsigned=dt.readString=dt.peekBytes=dt.readBytes=dt.peekByte=dt.readByte=dt.buildStream=void 0;var dK=function(t){return{data:t,pos:0}};dt.buildStream=dK;var L6=function(){return function(t){return t.data[t.pos++]}};dt.readByte=L6;var fK=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};dt.peekByte=fK;var Gg=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};dt.readBytes=Gg;var pK=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};dt.peekBytes=pK;var hK=function(t){return function(n){return Array.from(Gg(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};dt.readString=hK;var mK=function(t){return function(n){var o=Gg(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};dt.readUnsigned=mK;var yK=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=Gg(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};dt.readArray=yK;var gK=function(t,n,o){for(var a=0,r=0;r<o;r++)a+=t[n+r]&&Math.pow(2,o-r-1);return a},xK=function(t){return function(n){for(var o=L6()(n),a=new Array(8),r=0;r<8;r++)a[7-r]=!!(o&1<<r);return Object.keys(t).reduce(function(s,i){var l=t[i];return l.length?s[i]=gK(a,l.index,l.length):s[i]=a[l.index],s},{})}};dt.readBits=xK});var k6=Ht(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0});qg.default=void 0;var Ls=JL(),ce=e3(),Wg={blocks:function(t){for(var n=0,o=[],a=t.data.length,r=0,s=(0,ce.readByte)()(t);s!==n&&s;s=(0,ce.readByte)()(t)){if(t.pos+s>=a){var i=a-t.pos;o.push((0,ce.readBytes)(i)(t)),r+=i;break}o.push((0,ce.readBytes)(s)(t)),r+=s}for(var l=new Uint8Array(r),c=0,u=0;u<o.length;u++)l.set(o[u],c),c+=o[u].length;return l}},bK=(0,Ls.conditional)({gce:[{codes:(0,ce.readBytes)(2)},{byteSize:(0,ce.readByte)()},{extras:(0,ce.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,ce.readUnsigned)(!0)},{transparentColorIndex:(0,ce.readByte)()},{terminator:(0,ce.readByte)()}]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===249}),AK=(0,Ls.conditional)({image:[{code:(0,ce.readByte)()},{descriptor:[{left:(0,ce.readUnsigned)(!0)},{top:(0,ce.readUnsigned)(!0)},{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{lct:(0,ce.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,Ls.conditional)({lct:(0,ce.readArray)(3,function(e,t,n){return Math.pow(2,n.descriptor.lct.size+1)})},function(e,t,n){return n.descriptor.lct.exists}),{data:[{minCodeSize:(0,ce.readByte)()},Wg]}]},function(e){return(0,ce.peekByte)()(e)===44}),vK=(0,Ls.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),SK=(0,Ls.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),LK=(0,Ls.conditional)({comment:[{codes:(0,ce.readBytes)(2)},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),kK=[{header:[{signature:(0,ce.readString)(3)},{version:(0,ce.readString)(3)}]},{lsd:[{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{gct:(0,ce.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,ce.readByte)()},{pixelAspectRatio:(0,ce.readByte)()}]},(0,Ls.conditional)({gct:(0,ce.readArray)(3,function(e,t){return Math.pow(2,t.lsd.gct.size+1)})},function(e,t){return t.lsd.gct.exists}),{frames:(0,Ls.loop)([bK,SK,LK,AK,vK],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],wK=kK;qg.default=wK});var w6=Ht(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0});jg.deinterlace=void 0;var _K=function(t,n){for(var o=new Array(t.length),a=t.length/n,r=function(f,p){var h=t.slice(p*n,(p+1)*n);o.splice.apply(o,[f*n,n].concat(h))},s=[0,4,2,1],i=[8,8,4,2],l=0,c=0;c<4;c++)for(var u=s[c];u<a;u+=i[c])r(u,l),l++;return o};jg.deinterlace=_K});var _6=Ht(Vg=>{"use strict";Object.defineProperty(Vg,"__esModule",{value:!0});Vg.lzw=void 0;var CK=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,T,h,m,_,x,S,L,B,M,y=new Array(o),g=new Array(a),b=new Array(a),A=new Array(a+1);for(x=t,l=1<<x,d=l+1,i=l+2,p=r,u=x+1,c=(1<<u)-1,h=0;h<l;h++)g[h]=0,b[h]=h;var _,T,w,S,L,M,B;for(_=T=w=S=L=M=B=0,m=0;m<s;){if(L===0){if(T<u){_+=n[B]<<T,T+=8,B++;continue}if(h=_&c,_>>=u,T-=u,h>i||h==d)break;if(h==l){u=x+1,c=(1<<u)-1,i=l+2,p=r;continue}if(p==r){A[L++]=b[h],p=h,S=h;continue}for(f=h,h==i&&(A[L++]=S,h=p);h>l;)A[L++]=b[h],h=g[h];S=b[h]&255,A[L++]=S,i<a&&(g[i]=p,b[i]=S,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}L--,y[M++]=A[L],m++}for(m=M;m<s;m++)y[m]=0;return y};Vg.lzw=CK});var E6=Ht(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.decompressFrames=ks.decompressFrame=ks.parseGIF=void 0;var EK=OK(k6()),TK=JL(),IK=e3(),MK=w6(),RK=_6();function OK(e){return e&&e.__esModule?e:{default:e}}var DK=function(t){var n=new Uint8Array(t);return(0,TK.parse)((0,IK.buildStream)(n),EK.default)};ks.parseGIF=DK;var PK=function(t){for(var n=t.pixels.length,o=new Uint8ClampedArray(n*4),a=0;a<n;a++){var r=a*4,s=t.pixels[a],i=t.colorTable[s]||[0,0,0];o[r]=i[0],o[r+1]=i[1],o[r+2]=i[2],o[r+3]=s!==t.transparentIndex?255:0}return o},C6=function(t,n,o){if(!t.image){console.warn("gif frame does not have associated image.");return}var a=t.image,r=a.descriptor.width*a.descriptor.height,s=(0,RK.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,MK.deinterlace)(s,a.descriptor.width));var i={pixels:s,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return a.descriptor.lct&&a.descriptor.lct.exists?i.colorTable=a.lct:i.colorTable=n,t.gce&&(i.delay=(t.gce.delay||10)*10,i.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(i.transparentIndex=t.gce.transparentColorIndex)),o&&(i.patch=PK(i)),i};ks.decompressFrame=C6;var BK=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return C6(o,t.gct,n)})};ks.decompressFrames=BK});var F6=P(iE(),1);var R=P(se(),1),me=P(re(),1);var h0=P(re(),1);var f0=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var dE=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var fE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var Bb=e=>{let t=fE(e);return t.charAt(0).toUpperCase()+t.slice(1)};var xd=P(re(),1);var p0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var pE=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var $l=P(re(),1);var $B=(0,$l.createContext)({});var hE=()=>(0,$l.useContext)($B);var mE=(0,xd.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:o,className:a="",children:r,iconNode:s,...i},l)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f="currentColor",className:p=""}=hE()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,xd.createElement)("svg",{ref:l,...p0,width:t??c??p0.width,height:t??c??p0.height,stroke:e??f,strokeWidth:h,className:f0("lucide",p,a),...!r&&!pE(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,x])=>(0,xd.createElement)(m,x)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,h0.forwardRef)(({className:o,...a},r)=>(0,h0.createElement)(mE,{ref:r,iconNode:t,className:f0(`lucide-${dE(Bb(e))}`,`lucide-${e}`,o),...a}));return n.displayName=Bb(e),n};var QB=[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]],bd=E("align-center-horizontal",QB);var JB=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],Ql=E("align-center-vertical",JB);var eN=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]],Ad=E("align-end-horizontal",eN);var tN=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],vd=E("align-end-vertical",tN);var nN=[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]],Sd=E("align-horizontal-distribute-center",nN);var oN=[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]],Ld=E("align-start-horizontal",oN);var aN=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],kd=E("align-start-vertical",aN);var rN=[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]],wd=E("align-vertical-distribute-center",rN);var sN=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],_d=E("bold",sN);var iN=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Cd=E("case-sensitive",iN);var lN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ed=E("check",lN);var cN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Td=E("chevron-down",cN);var uN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xs=E("chevron-right",uN);var dN=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Id=E("chevrons-down",dN);var fN=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Md=E("chevrons-up",fN);var pN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Tn=E("circle-question-mark",pN);var hN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ys=E("circle",hN);var mN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],Rd=E("clipboard",mN);var yN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Hr=E("copy",yN);var gN=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],Od=E("crop",gN);var xN=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Dd=E("delete",xN);var bN=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],Pd=E("diamond",bN);var AN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Jl=E("download",AN);var vN=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ur=E("ellipsis-vertical",vN);var SN=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Gr=E("ellipsis",SN);var LN=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],Bd=E("eraser",LN);var kN=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Nd=E("external-link",kN);var wN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],zd=E("file-down",wN);var _N=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],Fd=E("file-up",_N);var CN=[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]],Hd=E("flip-horizontal-2",CN);var EN=[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]],Ud=E("flip-vertical-2",EN);var TN=[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]],Gd=E("frame",TN);var IN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xo=E("grid-3x3",IN);var MN=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Wd=E("grip",MN);var RN=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],qd=E("group",RN);var ON=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],jd=E("hand",ON);var DN=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Ks=E("image-down",DN);var PN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],$s=E("image",PN);var BN=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Vd=E("italic",BN);var NN=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Zd=E("library",NN);var zN=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Xd=E("link",zN);var FN=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Yd=E("locate-fixed",FN);var HN=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Kd=E("lock",HN);var UN=[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]],$d=E("magnet",UN);var GN=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],ec=E("maximize",GN);var WN=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Qd=E("menu",WN);var qN=[["path",{d:"M5 12h14",key:"1ays0h"}]],Da=E("minus",qN);var jN=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Jd=E("monitor",jN);var VN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ef=E("moon",VN);var ZN=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],tf=E("mouse-pointer-2",ZN);var XN=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],nf=E("mouse-pointer",XN);var YN=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],of=E("move-down",YN);var KN=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],af=E("move-right",KN);var $N=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],rf=E("move-up",$N);var QN=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Wr=E("pen-line",QN);var JN=[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]],sf=E("pipette",JN);var ez=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Qs=E("plus",ez);var tz=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],lf=E("radio",tz);var nz=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Js=E("redo-2",nz);var oz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],cf=E("rotate-ccw",oz);var az=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],uf=E("scissors",az);var rz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],df=E("search",rz);var sz=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],ff=E("slash",sz);var iz=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],pf=E("spline",iz);var lz=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],Pa=E("square-dashed",lz);var cz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Ba=E("square-dot",cz);var uz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Uo=E("square",uz);var dz=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],hf=E("strikethrough",dz);var fz=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],mf=E("sun",fz);var pz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],qr=E("text-align-end",pz);var hz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],jr=E("text-align-center",hz);var mz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],bo=E("text-align-start",mz);var yz=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],tc=E("trash-2",yz);var gz=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],yf=E("type",gz);var xz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],gf=E("underline",xz);var bz=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ei=E("undo-2",bz);var Az=[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]],xf=E("ungroup",Az);var vz=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],bf=E("upload",vz);var Sz=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],Af=E("waypoints",Sz);var Lz=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Na=E("x",Lz);var kz=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],vf=E("zoom-out",kz);var wz=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Sf=E("zoom-in",wz);var _z=P(se(),1),Ao=P(re(),1),yE=(0,Ao.createContext)(null);var gE=yE;var Nb=()=>(0,Ao.useContext)(yE),sn=(e,t,n)=>{let o=Nb(),[a,r]=(0,Ao.useState)(()=>o?e(o):t),s=(0,Ao.useRef)(e);s.current=e;let i=(0,Ao.useRef)(t);return i.current=t,(0,Ao.useEffect)(()=>{if(!o){r(i.current);return}let l=()=>{let c=s.current(o);r(u=>Object.is(u,c)?u:c)};return l(),n!==void 0?o.on(n,l):o.subscribe(l)},[o,n]),a};var Xb=P(se(),1);var nc=P(se(),1),Je=P(re(),1),DE=P(ha(),1);var xE=P(se(),1),m0=P(re(),1),bE=(0,m0.createContext)(null),Lf=({container:e,children:t})=>(0,xE.jsx)(bE.Provider,{value:e,children:t}),Dt=()=>(0,m0.useContext)(bE)??document.body;var zb=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],AE=8,vE=256,SE=160,LE=200,kE=150,Fb=8,Hb=150,wE="#2563eb",_E=1.5,CE="rgba(37, 99, 235, 0.12)",EE=1,Ub=10,Gb=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}],TE=176,IE=1,ME=40;var qb=new Set,kf=null,Go=null,Wo=null,Vb=0,jb=!1,Cz=()=>{for(let e of qb)e(kf)},y0=e=>{kf=e,Cz()},Ez=e=>(qb.add(e),()=>{qb.delete(e)}),Tz=e=>{if(jb)return;Wo&&(clearTimeout(Wo),Wo=null),Go&&clearTimeout(Go);let t=Date.now()-Vb;if(kf!==null||t<600){y0(e);return}Go=setTimeout(()=>{Go=null,y0(e)},600)},RE=e=>{Go&&(clearTimeout(Go),Go=null),kf?.id===e&&(Wo&&clearTimeout(Wo),Wo=setTimeout(()=>{Wo=null,Vb=Date.now(),y0(null)},80))},OE=()=>{Go&&(clearTimeout(Go),Go=null),Wo&&(clearTimeout(Wo),Wo=null),kf&&(Vb=Date.now(),y0(null))},Zb=({children:e})=>((0,Je.useEffect)(()=>{let t=()=>{jb=!0,OE()},n=()=>{jb=!1},o=a=>{a.key==="Escape"&&OE()};return document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointerup",n,{capture:!0}),document.addEventListener("keydown",o,{capture:!0}),()=>{document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointerup",n,{capture:!0}),document.removeEventListener("keydown",o,{capture:!0})}},[]),(0,nc.jsxs)(PE.Provider,{value:!0,children:[e,(0,nc.jsx)(Mz,{})]})),PE=(0,Je.createContext)(!1),Iz=()=>(0,Je.useContext)(PE),Mz=()=>{let[e,t]=(0,Je.useState)(null),n=Dt();return(0,Je.useEffect)(()=>Ez(t),[]),!e||typeof document>"u"?null:(0,DE.createPortal)((0,nc.jsx)(Rz,{target:e}),n)},Rz=({target:e})=>{let t=(0,Je.useRef)(null),[n,o]=(0,Je.useState)(null);(0,Je.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let s=r.getBoundingClientRect(),{rect:i,side:l}=e,c=i.left+i.width/2-s.width/2,u=i.top+i.height/2-s.height/2;switch(l){case"top":u=i.top-s.height-6;break;case"bottom":u=i.bottom+6;break;case"left":c=i.left-s.width-6;break;case"right":c=i.right+6;break}let d=4;c=Math.max(d,Math.min(c,window.innerWidth-s.width-d)),u=Math.max(d,Math.min(u,window.innerHeight-s.height-d)),o({left:c,top:u})},[e]);let a={position:"fixed",left:n?.left??-9999,top:n?.top??-9999,pointerEvents:"none",zIndex:1e4,visibility:n?"visible":"hidden"};return(0,nc.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},ti=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,Je.useId)();if(!Iz()||n||e===void 0||e===null)return(0,Je.isValidElement)(o)&&typeof e=="string"&&!n?(0,Je.cloneElement)(o,{title:e}):o;if(!(0,Je.isValidElement)(o))return o;let s=o,i=f=>{Tz({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,Je.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),RE(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),RE(a)},title:void 0})};var Qn=({label:e,active:t,size:n="default",className:o,children:a,...r})=>{let s=["du-icon-button",n==="sm"?"du-icon-button-sm":"",t?"is-active":"",o??""].filter(Boolean).join(" ");return(0,Xb.jsx)(ti,{content:e,children:(0,Xb.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var BE=P(se(),1),ni=({children:e,className:t,ariaLabel:n})=>(0,BE.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var Yb=P(se(),1);var In=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,Yb.jsx)(ni,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,Yb.jsx)(Qn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var wf=P(se(),1),_f=({value:e,min:t,max:n,step:o=1,onChange:a,ariaLabel:r,valueLabel:s})=>{let i=c=>{a(Number(c.target.value))},l=e??(t+n)/2;return(0,wf.jsxs)("div",{className:"du-slider",children:[(0,wf.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,wf.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var NE=P(se(),1),Kb=({children:e,className:t,style:n})=>(0,NE.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var Jn=P(se(),1),$b=({left:e,center:t,right:n})=>(0,Jn.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,Jn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Jn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Jn.jsx)("div",{}),(0,Jn.jsx)("div",{className:"du-bar-zone",children:n})]}),Qb=({left:e,center:t,right:n})=>(0,Jn.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,Jn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Jn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Jn.jsx)("div",{}),(0,Jn.jsx)("div",{className:"du-bar-zone",children:n})]});var ss=P(se(),1),o8=P(re(),1);var Ye=P(se(),1),Gc=P(re(),1);var zE="select";var qo={};ho(qo,{EMPTY:()=>Pe,add:()=>Xt,clear:()=>Pz,equals:()=>oi,has:()=>Oz,remove:()=>Tf,replace:()=>Dz,single:()=>wt,toggle:()=>tA});var Ze=e=>e,Jb=e=>e,ln=e=>e,Cf=e=>e,oc=e=>e,eA=e=>e;var v=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Ef=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var g0=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};var Pe=Object.freeze(new Set),wt=e=>new Set([e]),Oz=(e,t)=>e.has(t),Xt=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Tf=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},tA=(e,t)=>e.has(t)?Tf(e,t):Xt(e,t),Dz=e=>wt(e),Pz=()=>Pe,oi=(e,t)=>g0(e,t);var U={};ho(U,{ZERO:()=>FE,add:()=>Nz,angle:()=>Xz,cross:()=>Wz,distance:()=>qz,distanceSq:()=>GE,div:()=>Hz,dot:()=>Gz,equals:()=>Qz,length:()=>UE,lengthSq:()=>HE,lerp:()=>Vz,midpoint:()=>Zz,mul:()=>Fz,negate:()=>Uz,normalize:()=>jz,of:()=>Bz,perp:()=>$z,rotate:()=>Yz,rotateAround:()=>Kz,sub:()=>zz});var FE=Object.freeze({x:0,y:0}),Bz=(e,t)=>({x:e,y:t}),Nz=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),zz=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Fz=(e,t)=>({x:e.x*t,y:e.y*t}),Hz=(e,t)=>({x:e.x/t,y:e.y/t}),Uz=e=>({x:-e.x,y:-e.y}),Gz=(e,t)=>e.x*t.x+e.y*t.y,Wz=(e,t)=>e.x*t.y-e.y*t.x,HE=e=>e.x*e.x+e.y*e.y,UE=e=>Math.sqrt(HE(e)),GE=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},qz=(e,t)=>Math.sqrt(GE(e,t)),jz=e=>{let t=UE(e);return t===0?FE:{x:e.x/t,y:e.y/t}},Vz=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Zz=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Xz=e=>Math.atan2(e.y,e.x),Yz=(e,t)=>{let n=Math.cos(t),o=Math.sin(t);return{x:e.x*n-e.y*o,y:e.x*o+e.y*n}},Kz=(e,t,n)=>{let o=Math.cos(n),a=Math.sin(n),r=e.x-t.x,s=e.y-t.y;return{x:t.x+(r*o-s*a),y:t.y+(r*a+s*o)}},$z=e=>({x:-e.y,y:e.x}),Qz=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n;var ac={};ho(ac,{clamp:()=>Jz,clamp01:()=>eF});var Jz=(e,t,n)=>Math.max(t,Math.min(n,e)),eF=e=>e<0?0:e>1?1:e;var N={};ho(N,{IDENTITY:()=>tF,applyToBounds:()=>lF,applyToPoint:()=>If,decompose:()=>cF,equals:()=>uF,inverse:()=>iF,multiply:()=>sF,of:()=>nF,rotation:()=>rF,scaling:()=>aF,translation:()=>oF});var tF=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),nF=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),oF=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),aF=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),rF=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},sF=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),iF=e=>{let t=e.a*e.d-e.b*e.c;if(t===0)throw new Error("Cannot invert singular matrix");return{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,e:(e.c*e.f-e.d*e.e)/t,f:(e.b*e.e-e.a*e.f)/t}},If=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),lF=(e,t)=>{let n=If(e,{x:t.x,y:t.y}),o=If(e,{x:t.x+t.width,y:t.y}),a=If(e,{x:t.x,y:t.y+t.height}),r=If(e,{x:t.x+t.width,y:t.y+t.height}),s=Math.min(n.x,o.x,a.x,r.x),i=Math.min(n.y,o.y,a.y,r.y),l=Math.max(n.x,o.x,a.x,r.x),c=Math.max(n.y,o.y,a.y,r.y);return{x:s,y:i,width:l-s,height:c-i}},cF=e=>{let t=Math.sqrt(e.a*e.a+e.b*e.b),n=Math.sqrt(e.c*e.c+e.d*e.d),a=e.a*e.d-e.b*e.c<0?-n:n;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:t,y:a}}},uF=(e,t,n=0)=>{let o=["a","b","c","d","e","f"];return n===0?o.every(a=>e[a]===t[a]):o.every(a=>Math.abs(e[a]-t[a])<=n)};var V={};ho(V,{EMPTY:()=>WE,centerOf:()=>pF,contains:()=>oA,containsBounds:()=>yF,equals:()=>bF,expand:()=>gF,fromCenter:()=>fF,fromPoints:()=>x0,intersection:()=>qE,intersects:()=>mF,isEmpty:()=>nA,maxX:()=>Vr,maxY:()=>Zr,normalize:()=>xF,of:()=>dF,union:()=>hF});var WE=Object.freeze({x:0,y:0,width:0,height:0}),dF=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),x0=e=>{if(e.length===0)return WE;let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e)r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>a&&(a=r.y);return{x:t,y:n,width:o-t,height:a-n}},fF=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),pF=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Vr=e=>e.x+e.width,Zr=e=>e.y+e.height,nA=e=>e.width<=0||e.height<=0,hF=(e,t)=>{if(nA(e))return t;if(nA(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(Vr(e),Vr(t)),r=Math.max(Zr(e),Zr(t));return{x:n,y:o,width:a-n,height:r-o}},qE=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(Vr(e),Vr(t)),r=Math.min(Zr(e),Zr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},mF=(e,t)=>qE(e,t)!==null,oA=(e,t)=>t.x>=e.x&&t.x<=Vr(e)&&t.y>=e.y&&t.y<=Zr(e),yF=(e,t)=>t.x>=e.x&&t.y>=e.y&&Vr(t)<=Vr(e)&&Zr(t)<=Zr(e),gF=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),xF=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),bF=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n&&Math.abs(e.width-t.width)<=n&&Math.abs(e.height-t.height)<=n;var za={};ho(za,{distanceToSegment:()=>SF,distanceToSegmentSq:()=>rc,pointInPolygon:()=>vF,pointInRect:()=>AF,pointOnPolyline:()=>LF,pointOnSegment:()=>jE});var AF=(e,t)=>oA(t,e),vF=(e,t)=>{if(t.length<3)return!1;let n=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){let r=t[o],s=t[a];if(!r||!s)continue;r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},rc=(e,t,n)=>{let o=n.x-t.x,a=n.y-t.y,r=o*o+a*a;if(r===0){let d=e.x-t.x,f=e.y-t.y;return d*d+f*f}let s=((e.x-t.x)*o+(e.y-t.y)*a)/r;s<0?s=0:s>1&&(s=1);let i=t.x+s*o,l=t.y+s*a,c=e.x-i,u=e.y-l;return c*c+u*u},SF=(e,t,n)=>Math.sqrt(rc(e,t,n)),jE=(e,t,n,o=1)=>rc(e,t,n)<=o*o,LF=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&jE(e,a,r,n))return!0}return!1};var cn={};ho(cn,{cubicAt:()=>ri,cubicBounds:()=>wF,flattenCubic:()=>TF,flattenQuadratic:()=>EF,pointOnCubic:()=>CF,pointOnQuadratic:()=>_F,quadraticAt:()=>ai,quadraticBounds:()=>kF});var ai=(e,t,n,o)=>{let a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}},ri=(e,t,n,o,a)=>{let r=1-a,s=r*r,i=s*r,l=a*a,c=l*a;return{x:i*e.x+3*s*a*t.x+3*r*l*n.x+c*o.x,y:i*e.y+3*s*a*t.y+3*r*l*n.y+c*o.y}},kF=(e,t,n)=>{let o=[e,n];for(let a of VE(e.x,t.x,n.x))o.push(ai(e,t,n,a));for(let a of VE(e.y,t.y,n.y))o.push(ai(e,t,n,a));return x0(o)},wF=(e,t,n,o)=>{let a=[e,o];for(let r of ZE(e.x,t.x,n.x,o.x))a.push(ri(e,t,n,o,r));for(let r of ZE(e.y,t.y,n.y,o.y))a.push(ri(e,t,n,o,r));return x0(a)},_F=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=ai(t,n,o,l/r);if(rc(e,i,c)<=s)return!0;i=c}return!1},CF=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=ri(t,n,o,a,c/s);if(rc(e,l,u)<=i)return!0;l=u}return!1},EF=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=ai(e,t,n,r/o);return a},TF=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=ri(e,t,n,o,s/a);return r},VE=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},ZE=(e,t,n,o)=>{let a=-e+3*t-3*n+o,r=2*(e-2*t+n),s=t-e,i=[];if(Math.abs(a)<1e-12){if(Math.abs(r)>1e-12){let f=-s/r;f>0&&f<1&&i.push(f)}return i}let l=r*r-4*a*s;if(l<0)return i;let c=Math.sqrt(l),u=(-r+c)/(2*a),d=(-r-c)/(2*a);return u>0&&u<1&&i.push(u),d>0&&d<1&&i.push(d),i};var A0={};ho(A0,{lineLine:()=>IF,segmentCubic:()=>RF,segmentQuadratic:()=>MF,segmentSegment:()=>XE});var b0=1e-12,IF=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<b0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l;return{x:e.x+d*a,y:e.y+d*r}},XE=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<b0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l,f=(c*r-u*a)/l;return d<0||d>1||f<0||f>1?null:{x:e.x+d*a,y:e.y+d*r}},MF=(e,t,n,o,a)=>{let r=t.y-e.y,s=-(t.x-e.x),i=-(r*e.x+s*e.y),l=r*n.x+s*n.y,c=r*o.x+s*o.y,u=r*a.x+s*a.y,d=l-2*c+u,f=-2*l+2*c,p=l+i,h=[];if(Math.abs(d)<b0){if(Math.abs(f)>b0){let b=-p/f;b>=0&&b<=1&&h.push(b)}}else{let b=f*f-4*d*p;if(b>=0){let A=Math.sqrt(b),_=(-f+A)/(2*d),T=(-f-A)/(2*d);_>=0&&_<=1&&h.push(_),T>=0&&T<=1&&h.push(T)}}let m=[],x=t.x-e.x,y=t.y-e.y,g=x*x+y*y;for(let b of h){let A=ai(n,o,a,b);if(g===0){m.push(A);continue}let _=((A.x-e.x)*x+(A.y-e.y)*y)/g;_>=0&&_<=1&&m.push(A)}return m},RF=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=ri(n,o,a,r,c/s),d=XE(e,t,l,u);d!==null&&i.push(d),l=u}return i};var v0={};ho(v0,{contrastRatio:()=>iA,format:()=>PF,luminance:()=>sA,meetsContrastAA:()=>zF,meetsContrastAAA:()=>FF,mix:()=>BF,parse:()=>DF,withAlpha:()=>NF});var OF=Object.freeze({transparent:{r:0,g:0,b:0,a:0},black:{r:0,g:0,b:0,a:1},white:{r:255,g:255,b:255,a:1},red:{r:255,g:0,b:0,a:1},green:{r:0,g:128,b:0,a:1},blue:{r:0,g:0,b:255,a:1},yellow:{r:255,g:255,b:0,a:1},cyan:{r:0,g:255,b:255,a:1},magenta:{r:255,g:0,b:255,a:1},gray:{r:128,g:128,b:128,a:1},grey:{r:128,g:128,b:128,a:1}}),DF=e=>{let t=e.trim().toLowerCase(),n=OF[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=Xr(a.charAt(0)+a.charAt(0)),s=Xr(a.charAt(1)+a.charAt(1)),i=Xr(a.charAt(2)+a.charAt(2)),l=a.length===4?Xr(a.charAt(3)+a.charAt(3))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}if(a.length===6||a.length===8){let r=Xr(a.slice(0,2)),s=Xr(a.slice(2,4)),i=Xr(a.slice(4,6)),l=a.length===8?Xr(a.slice(6,8))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Invalid hex color length: ${e}`)}let o=/^rgba?\(([^)]+)\)$/.exec(t);if(o){let a=(o[1]??"").split(",").map(c=>c.trim());if(a.length!==3&&a.length!==4)throw new Error(`Expected 3 or 4 components: ${e}`);let r=Math.round(Number(a[0])),s=Math.round(Number(a[1])),i=Math.round(Number(a[2])),l=a.length===4?Number(a[3]):1;if([r,s,i,l].some(Number.isNaN))throw new Error(`Invalid component: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Cannot parse color: ${e}`)},PF=e=>{let t=aA(e.r),n=aA(e.g),o=aA(e.b),a=HF(e.a);return a===1?`#${rA(t)}${rA(n)}${rA(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},BF=(e,t,n)=>({r:e.r+(t.r-e.r)*n,g:e.g+(t.g-e.g)*n,b:e.b+(t.b-e.b)*n,a:e.a+(t.a-e.a)*n}),NF=(e,t)=>({...e,a:t}),sA=e=>{let t=n=>{let o=n/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)},iA=(e,t)=>{let n=sA(e),o=sA(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},zF=(e,t,n=!1)=>iA(e,t)>=(n?3:4.5),FF=(e,t,n=!1)=>iA(e,t)>=(n?4.5:7),Xr=e=>parseInt(e,16),aA=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},HF=e=>e<0?0:e>1?1:e,rA=e=>e.toString(16).padStart(2,"0");var Mf={};ho(Mf,{offsetClosedPath:()=>UF,signedArea:()=>GF});var UF=(e,t)=>{if(e.length<3||t===0)return e.map(l=>({x:l.x,y:l.y}));let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let a=e.length,r=new Array(a),s=new Array(a);for(let l=0;l<a;l++){let c=v(e[l]),u=v(e[(l+1)%a]),d=u.x-c.x,f=u.y-c.y,p=Math.hypot(d,f)||1;r[l]=-f/p,s[l]=d/p}let i=[];for(let l=0;l<a;l++){let c=(l-1+a)%a,u=v(r[c]),d=v(s[c]),f=v(r[l]),p=v(s[l]),h=u+f,m=d+p,x=Math.hypot(h,m);x<1e-6?(h=u,m=d):(h/=x,m/=x);let y=v(e[l]),g=n-y.x,b=o-y.y,_=h*g+m*b>=0?1:-1,T=h*u+m*d,w=T>1e-6?t/T:t;i.push({x:y.x+_*h*w,y:y.y+_*m*w})}return i},GF=e=>{let t=0;for(let n=0;n<e.length;n++){let o=v(e[n]),a=v(e[(n+1)%e.length]);t+=o.x*a.y-a.x*o.y}return t/2};var lA=e=>{if(!(e.stroke!==void 0&&e.stroke!=="transparent"))return 0;let n=e.strokeWidth??1;if(n<=0)return 0;switch(e.strokeAlign??"center"){case"outside":return n;case"inside":return 0;default:return n/2}},Rf=(e,t,n)=>{if(!e||e.type==="sharp")return 0;let o=Math.min(Math.abs(t),Math.abs(n));if(o<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,o/2));let a=32/.25;return o<=a?o*.25:32};var YE=e=>{if(!e)return"";let t=Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[o])=>n<o?-1:n>o?1:0);return JSON.stringify(t)},cA=e=>{let t=[];for(let n of e){if(n.text==="")continue;let o=t[t.length-1];o!==void 0&&YE(o.style)===YE(n.style)?t[t.length-1]={text:o.text+n.text,...o.style!==void 0?{style:o.style}:{}}:t.push(n)}return t},KE=e=>{let t=e.runs;return t!==void 0&&t.length>0?cA(t):e.text===""?[]:[{text:e.text}]},Of=(e,t,n)=>{let o=Math.min(t,n),a=Math.max(t,n),r=[],s=0;for(let i of KE(e)){let l=s,c=s+i.text.length;s=c;let u=Math.max(l,o),d=Math.min(c,a);u>=d||r.push({text:i.text.slice(u-l,d-l),...i.style!==void 0?{style:i.style}:{}})}return r},jF=(e,t)=>{let n={...e??{},...t},o=Object.entries(n).filter(([,r])=>r!==void 0);return o.length===0?void 0:Object.fromEntries(o)},uA=(e,t,n,o)=>{let a=Math.max(0,Math.min(t,n)),r=Math.min(e.text.length,Math.max(t,n));if(a>=r)return e;let s=[],i=0;for(let u of KE(e)){let d=i,f=i+u.text.length;i=f;let p=Math.max(d,a),h=Math.min(f,r);if(p>=h){s.push(u);continue}d<p&&s.push({text:u.text.slice(0,p-d),...u.style!==void 0?{style:u.style}:{}});let m=jF(u.style,o);s.push({text:u.text.slice(p-d,h-d),...m!==void 0?{style:m}:{}}),h<f&&s.push({text:u.text.slice(h-d),...u.style!==void 0?{style:u.style}:{}})}let l=cA(s),c=l[0];if(l.length===1&&c!==void 0&&(c.style===void 0||Object.keys(c.style).length===0)){let{runs:u,...d}=e;return d}return{...e,runs:l}};var dA=e=>{if(typeof e!="object"||e===null)return!1;let t=e.kind;return t==="named"||t==="ratio"||t==="absolute"||t==="edge"},si=e=>e.kind==="point"?void 0:e.elementId;var $E=null,fA=e=>{$E=e},pA=()=>$E;var ii=e=>e.type==="rectangle",sc=e=>e.type==="ellipse",Fa=e=>e.type==="polygon",hA=e=>e.type==="path",fe=e=>e.type==="text",ct=e=>e.type==="image";var ze=e=>e.type==="group",Be=e=>e.type==="frame";var Ha=e=>e.type==="brush",Df=e=>e.stroke??e.fill??"#000",QE=new Map,eo=(e,t)=>{QE.set(e,t)};var Re=e=>{let t=QE.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},z=e=>{let t=Re(e),n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],o=Math.sin(e.rotation),a=Math.cos(e.rotation),r=n.map(s=>{let i=s.x*e.scale.x,l=s.y*e.scale.y;return{x:e.position.x+(i*a-l*o),y:e.position.y+(i*o+l*a)}});return V.fromPoints(r)};eo("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));eo("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));eo("polygon",e=>V.fromPoints(e.points));eo("path",e=>{let t=[],n={x:0,y:0};for(let o of e.commands)switch(o.kind){case"M":case"L":t.push(o.to),n=o.to;break;case"Q":t.push(o.control,o.to),n=o.to;break;case"C":t.push(o.control1,o.control2,o.to),n=o.to;break;case"Z":break}return V.fromPoints(t)});eo("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
10
- `),o=pA(),a={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},r=i=>{if(o){let l=o(i,e.fontFamily,e.fontSize,a);if(l!==null)return l}return i.length*e.fontSize*.6};if(e.maxWidth===void 0){let i=0;for(let l of n)i=Math.max(i,r(l));return i=Math.max(i,e.fontSize*.5),{x:0,y:0,width:i,height:Math.max(1,n.length)*t}}let s=0;for(let i of n)s+=Math.max(1,Math.ceil(r(i)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,s)*t}});eo("image",e=>({x:0,y:0,width:e.width,height:e.height}));eo("template",e=>({x:0,y:0,width:e.width,height:e.height}));eo("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e.points)r.x-r.width<t&&(t=r.x-r.width),r.y-r.width<n&&(n=r.y-r.width),r.x+r.width>o&&(o=r.x+r.width),r.y+r.width>a&&(a=r.y+r.width);return{x:t,y:n,width:o-t,height:a-n}});eo("group",()=>({x:0,y:0,width:0,height:0}));eo("frame",e=>({x:0,y:0,width:e.width,height:e.height}));eo("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var S0=class{cellSize;cells=new Map;bounds=new Map;constructor(t=256){if(t<=0)throw new Error("cellSize must be positive");this.cellSize=t}get size(){return this.bounds.size}insert(t,n){if(this.bounds.has(t))throw new Error(`Element already indexed: ${t}`);this.bounds.set(t,n),this.eachCell(n,o=>{let a=this.cells.get(o);a||(a=new Set,this.cells.set(o,a)),a.add(t)})}remove(t){let n=this.bounds.get(t);n&&(this.bounds.delete(t),this.eachCell(n,o=>{let a=this.cells.get(o);a&&(a.delete(t),a.size===0&&this.cells.delete(o))}))}update(t,n){this.remove(t),this.insert(t,n)}query(t){let n=new Set;return this.eachCell(t,o=>{let a=this.cells.get(o);if(a)for(let r of a)n.add(r)}),n}clear(){this.cells.clear(),this.bounds.clear()}eachCell(t,n){let o=Math.floor(t.x/this.cellSize),a=Math.floor(t.y/this.cellSize),r=Math.floor((t.x+t.width)/this.cellSize),s=Math.floor((t.y+t.height)/this.cellSize);for(let i=a;i<=s;i++)for(let l=o;l<=r;l++)n(`${l},${i}`)}};var _t=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Pf=(e,t)=>_t(t,e);var Mn=(e,t)=>{let n=t.x*e.scale.x,o=t.y*e.scale.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation);return{x:e.position.x+(n*a-o*r),y:e.position.y+(n*r+o*a)}},li=(e,t)=>{let n=t.x-e.position.x,o=t.y-e.position.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation),s=n*a+o*r,i=-n*r+o*a;return{x:e.scale.x===0?0:s/e.scale.x,y:e.scale.y===0?0:i/e.scale.y}};var L0=(e,t,n,o,a)=>{let r=a*Math.PI*2-Math.PI/2;return{x:e+n*Math.cos(r),y:t+o*Math.sin(r)}};var I=(e,t)=>e.elements.get(t),be=(e,t)=>e.links.get(t);var vo=e=>[...e.layers.values()].sort(_t),Ua=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(_t),yA=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(_t),JE=48,k0=10,mA=e=>[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],eT=6,VF=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=eT;p++){let h=u+(d-u)*(p/eT);f.push({x:l+t*Math.cos(h),y:c+t*Math.sin(h)})}return f},i=Math.PI/2;return[...s(n+t,o+t,Math.PI,Math.PI+i),...s(n+a-t,o+t,-i,0),...s(n+a-t,o+r-t,0,i),...s(n+t,o+r-t,i,Math.PI)]},ZF=e=>{let t=[],n={x:0,y:0};for(let o of e)if(o.kind==="M"||o.kind==="L")n=o.to,t.push({x:n.x,y:n.y});else if(o.kind==="Q"){for(let a=1;a<=k0;a++){let r=a/k0,s=1-r;t.push({x:s*s*n.x+2*s*r*o.control.x+r*r*o.to.x,y:s*s*n.y+2*s*r*o.control.y+r*r*o.to.y})}n=o.to}else if(o.kind==="C"){for(let a=1;a<=k0;a++){let r=a/k0,s=1-r;t.push({x:s**3*n.x+3*s*s*r*o.control1.x+3*s*r*r*o.control2.x+r**3*o.to.x,y:s**3*n.y+3*s*s*r*o.control1.y+3*s*r*r*o.control2.y+r**3*o.to.y})}n=o.to}return t},XF=new Map;var YF=e=>{if(Fa(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(sc(e)){let t=Re(e),n=t.x+t.width/2,o=t.y+t.height/2,a=t.width/2,r=t.height/2,s=[];for(let i=0;i<JE;i++)s.push(L0(n,o,a,r,i/JE));return[s]}if(ii(e)){let t=Re(e),n=Rf(e.style.roundness,t.width,t.height);return[n>0?VF(t,n):mA(t)]}return ct(e)||fe(e)?[mA(Re(e))]:hA(e)?[ZF(e.commands)]:null},Bf=(e,t)=>{if(ze(t)){let r=[];for(let s of gA(e,t.id))r.push(...Bf(e,s));return r}let n=YF(t);if(n)return n.map(r=>r.map(s=>Mn(t,s)));let o=XF.get(t.type);if(o){let r=o(t).filter(s=>s.length>=2);if(r.length>0)return r.map(s=>s.map(i=>Mn(t,i)))}let a=z(t);return[mA(a)]},gA=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(_t),n},xA=(e,t)=>{let n=t;for(let o=0;n&&o<tT;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},ic=(e,t)=>{let n=t;for(let o=0;n&&o<tT;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var bA=(e,t)=>{let n=e.elements.get(t);if(!n)return[];let o=new Set([t]),a=[n],r=[t];for(;r.length>0;){let s=r.pop();if(s===void 0)break;for(let i of gA(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},tT=64;var w0=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=z(a);if(!V.intersects(r,t))continue;let s=r.width*r.height;if(s<=0){o.push(a);continue}let i=Math.max(r.x,t.x),l=Math.max(r.y,t.y),c=Math.min(r.x+r.width,t.x+t.width),u=Math.min(r.y+r.height,t.y+t.height),d=c-i,f=u-l;if(d<=0||f<=0)continue;if(d*f/s>=n){o.push(a);continue}let h=t.width*t.height;h>0&&d*f/h>=n&&o.push(a)}return o},ci=(e,t)=>{let n=vo(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=Ua(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&V.contains(z(i),t))return i}}},AA=(e,t)=>{let n=new S0(t);for(let o of e.elements.values())n.insert(o.id,z(o));return n};var vA=(e,t,n)=>{let o={x:n.x,y:n.y,width:0,height:0},a=t.query(o);if(a.size===0)return;let r,s="",i="",l=!1;for(let c of a){let u=e.elements.get(c);if(!u||!V.contains(z(u),n))continue;let d=e.layers.get(u.layerId);if(!d?.visible)continue;let f=d.order;(!l||f>s||f===s&&u.order>i)&&(r=u,s=f,i=u.order,l=!0)}return r};var KF=[];var Nf=e=>ui(e)!==null,ui=e=>{for(let s of KF){let i=s(e);if(i)return i}let t=e.metadata,n=e;if(t?.autoLayout!=null&&typeof n.width=="number"&&typeof n.height=="number"){let s=t.container?.padding??$F,i=n.width,l=n.height;return{dropZone:{x:s,y:s,width:Math.max(0,i-2*s),height:Math.max(0,l-2*s)},padding:s}}let o=e.metadata?.container;if(!o||typeof o!="object")return null;let a=o;return a.dropZone?a.padding!==void 0?{dropZone:a.dropZone,padding:a.padding}:{dropZone:a.dropZone}:null},$F=0,to=e=>{let t=ui(e);return t?{x:e.position.x+t.dropZone.x,y:e.position.y+t.dropZone.y,width:t.dropZone.width,height:t.dropZone.height}:null},QF=[];var SA=e=>{for(let n of QF){let o=n(e);if(o)return o.map(a=>({x:e.position.x+a.x,y:e.position.y+a.y,width:a.width,height:a.height}))}let t=to(e);return t?[t]:[]},zf=(e,t,n=new Set)=>{let o=vo(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=Ua(e,r.id);for(let i=s.length-1;i>=0;i--){let l=s[i];if(l===void 0||n.has(l.id))continue;let c=to(l);if(c&&V.contains(c,t))return l}}return null},LA=(e,t)=>{let n=ui(e);if(!n)return null;let o=n.padding??0,a={x:t.x-e.position.x,y:t.y-e.position.y,width:t.width,height:t.height},r=n.dropZone,s=a.x,i=a.y,l=a.x+a.width,c=a.y+a.height,u=r.x,d=r.y,f=r.x+r.width,p=r.y+r.height,h=s<u?s-o:u,m=i<d?i-o:d,x=l>f?l+o:f,y=c>p?c+o:p;return h===u&&m===d&&x===f&&y===p?null:{x:h,y:m,width:x-h,height:y-m}},kA=(e,t)=>{let n=e.spec.dropZone,o=n.x-t.x,a=n.y-t.y,r=t.x+t.width-(n.x+n.width),s=t.y+t.height-(n.y+n.height);return{width:e.width+o+r,height:e.height+a+s,positionOffset:{x:-o,y:-a}}};var nT=new Set,wA={"top-left":{x:0,y:0},top:{x:.5,y:0},"top-right":{x:1,y:0},right:{x:1,y:.5},"bottom-right":{x:1,y:1},bottom:{x:.5,y:1},"bottom-left":{x:0,y:1},left:{x:0,y:.5},center:{x:.5,y:.5}},oT=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var aT=(e,t)=>_A(e,t),Yt=(e,t)=>{let n=aT(e,t),o=n.x*e.scale.x,a=n.y*e.scale.y,r=Math.cos(e.rotation),s=Math.sin(e.rotation);return{x:e.position.x+(o*r-a*s),y:e.position.y+(o*s+a*r)}},jo=(e,t)=>{let n=Yt(e,t),o=Yt(e,{kind:"named",name:"center"}),a=n.x-o.x,r=n.y-o.y,s=Math.hypot(a,r);return s<1e-6?{x:0,y:-1}:{x:a/s,y:r/s}},Ga=(e,t,n=nT)=>{let o=null;for(let[a,r]of _0(e)){if(n.has(a))continue;let s=JF(a),i=Yt(e,s),l=i.x-t.x,c=i.y-t.y,u=Math.hypot(l,c);(o===null||u<o.distance)&&(o={ref:s,world:i,distance:u})}return o||{ref:{kind:"named",name:"center"},world:Yt(e,{kind:"named",name:"center"}),distance:1/0}},JF=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},So=e=>Nf(e)?eH:nT,eH=new Set(["center"]);var _0=e=>{let t=new Map;if(Fa(e))tH(e,t);else{let n=Re(e);for(let o of rT){let a=wA[o];t.set(o,{x:n.x+n.width*a.x,y:n.y+n.height*a.y})}}if(e.anchors)for(let[n,o]of Object.entries(e.anchors))t.set(n,_A(e,o));return t},rT=["top","right","bottom","left"],tH=(e,t)=>{let n=e.points;if(!(n.length<2))for(let o=0;o<n.length;o++){let a=n[o],r=n[(o+1)%n.length];a===void 0||r===void 0||t.set(`edge-${o}`,U.midpoint(a,r))}},_A=(e,t)=>{switch(t.kind){case"named":{let n=iT(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${oT.join(", ")}; custom anchors live on shape.anchors.`);return n}case"ratio":{let n=Re(e);return{x:n.x+n.width*t.position.x,y:n.y+n.height*t.position.y}}case"absolute":{let n=Re(e);return{x:n.x+t.offset.x,y:n.y+t.offset.y}}case"edge":return sT(e,t.index,t.t)}},sT=(e,t,n)=>{if(Fa(e)&&e.points.length>=2){let a=e.points,r=a.length,s=(t%r+r)%r,i=a[s],l=a[(s+1)%r];if(i!==void 0&&l!==void 0){let c=n<0?0:n>1?1:n;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}}let o=Re(e);return{x:o.x+o.width/2,y:o.y+o.height/2}},iT=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?iT(e,n.name):_A(e,n);if(Fa(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return sT(e,r,.5)}let o=wA[t];if(!o)return;let a=Re(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var CA=(e,t,n,o)=>{let a=Math.hypot(t.x-e.x,t.y-e.y),r=Math.min(a*.8,240);return{c1:{x:e.x+n.x*r,y:e.y+n.y*r},c2:{x:t.x+o.x*r,y:t.y+o.y*r},to:t}},Ff=e=>{let t=[],n=6;for(let o=0;o<e.length-1;o++){let a=v(e[o]),r=v(e[o+1]),s=e[o-1]??a,i=e[o+2]??r;t.push({c1:{x:a.x+(r.x-s.x)/n,y:a.y+(r.y-s.y)/n},c2:{x:r.x-(i.x-a.x)/n,y:r.y-(i.y-a.y)/n},to:r})}return t},Hf=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(cn.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var lc={x:1,y:0},Uf={x:0,y:1},Gf={x:-1,y:0},Wf={x:0,y:-1},lT=e=>e.y===0;var nH=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?lc:e.x<=-n?Gf:e.y>t?Uf:Wf},qf=(e,t)=>nH({x:e.x-t.x,y:e.y-t.y}),C0=(e,t)=>{let n=z(e),o=Math.abs(t.x-n.x),a=Math.abs(n.x+n.width-t.x),r=Math.abs(t.y-n.y),s=Math.abs(n.y+n.height-t.y),i=Math.min(o,a,r,s);return i===o?Gf:i===a?lc:i===r?Wf:Uf},cT=(e,t)=>{let n=z(e),o=n.x+n.width/2,a=n.y+n.height/2,r=t.x-o,s=t.y-a;if(r===0&&s===0)return lc;let i=n.width||1,l=n.height||1,c=r/(i/2),u=s/(l/2);return Math.abs(c)>=Math.abs(u)?c>=0?lc:Gf:u>=0?Uf:Wf};var E0=new Map,EA=(e,t)=>{E0.set(e,t)},uT=e=>E0.get(e),T0=(e,t)=>{let n=E0.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,ac.clamp01(t));return Mn(e,o)},dT=(e,t,n=64)=>{let o=E0.get(e.type);if(!o)return null;let a=0,r=Mn(e,o(e,0)),s=U.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=Mn(e,o(e,l)),u=U.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},fT=(e,t)=>{if(e.length===0)return{x:0,y:0};if(e.length===1)return v(e[0]);let n=0,o=[];for(let r=0;r<e.length;r++){let s=v(e[r]),i=v(e[(r+1)%e.length]),l=U.distance(s,i);o.push(l),n+=l}if(n===0)return v(e[0]);let a=n*t;for(let r=0;r<e.length;r++){let s=v(o[r]);if(a<=s){let i=v(e[r]),l=v(e[(r+1)%e.length]),c=s===0?0:a/s;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}a-=s}return v(e[0])};EA("rectangle",(e,t)=>{let n=Re(e),o=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}];return fT(o,t)});EA("ellipse",(e,t)=>{let n=Re(e),o=n.x+n.width/2,a=n.y+n.height/2,r=n.width/2,s=n.height/2;return L0(o,a,r,s,t)});EA("polygon",(e,t)=>fT(e.points,t));var pT=e=>e.kind==="point"?null:e.elementId,hT=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},mT=(e,t,n)=>{if(t.kind==="anchor"){let a=hT(jo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=hT(C0(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},sH=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2;return t.y<0?{x:n,y:e.y}:t.y>0?{x:n,y:e.y+e.height}:t.x<0?{x:e.x,y:o}:{x:e.x+e.width,y:o}},IA=(e,t)=>{let n=pT(t.from);if(!n||n!==pT(t.to))return null;let o=I(e,n);if(!o)return null;let a=z(o),r=no(e,t.from),s=no(e,t.to);if(!r||!s)return null;let i=r,l=s,c=mT(o,t.from,i),u=mT(o,t.to,l);if(Math.hypot(l.x-i.x,l.y-i.y)<1){let d=c.x!==0||c.y!==0?c:{x:0,y:-1};c=d,u=d;let f={x:-d.y,y:d.x},p=d.x!==0?a.height:a.width,h=Math.min(24,p/3),m=sH(a,d);i={x:m.x-f.x*h,y:m.y-f.y*h},l={x:m.x+f.x*h,y:m.y+f.y*h}}return{p1:i,n1:c,p2:l,n2:u,bounds:a}},iH=e=>{let t=40,{p1:n,n1:o,p2:a,n2:r,bounds:s}=e,i={x:n.x+o.x*t,y:n.y+o.y*t},l={x:a.x+r.x*t,y:a.y+r.y*t},c=o.x===r.x&&o.y===r.y,u=o.x===-r.x&&o.y===-r.y;if(c)return[n,i,l,a];if(u){if(o.x===0){let p=s.x+s.width+t;return[n,i,{x:p,y:i.y},{x:p,y:l.y},l,a]}let f=s.y+s.height+t;return[n,i,{x:i.x,y:f},{x:l.x,y:f},l,a]}let d={x:o.y!==0?l.x:i.x,y:o.y!==0?i.y:l.y};return[n,i,d,l,a]},lH=e=>{let t=40*2.2,{p1:n,n1:o,p2:a,n2:r}=e;return{start:n,segments:[{c1:{x:n.x+o.x*t,y:n.y+o.y*t},c2:{x:a.x+r.x*t,y:a.y+r.y*t},to:a}]}},gT=e=>{let t=z(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},cH=(e,t)=>{let n=gT(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!uT(e.type))return n;let s=Math.hypot(o,a),i={x:n.x+o/s*1e6,y:n.y+a/s*1e6},l=null,c=1/0,u=T0(e,0);for(let d=1;d<=96;d++){let f=T0(e,d/96),p=A0.segmentSegment(n,i,u,f);if(p){let h=Math.hypot(p.x-t.x,p.y-t.y);h<c&&(c=h,l=p)}u=f}return l??n},no=(e,t,n)=>{if(t.kind==="point")return t.position;let o=I(e,t.elementId);return o?t.kind==="anchor"?Yt(o,t.anchor):t.kind==="floating"?cH(o,n??gT(o)):T0(o,t.ratio):null},ot=(e,t)=>{let n=IA(e,t);if(n)return iH(n);let o=no(e,t.from);if(!o)return null;let a=no(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?no(e,t.from,a)??o:o,s=t.to.kind==="floating"?no(e,t.to,o)??a:a;return(t.routing??"straight")!=="orthogonal"?[r,...t.waypoints??[],s]:t.routedPoints!==void 0?[r,...t.routedPoints,s]:xT(r,s,TA(t.from),TA(t.to))},xT=(e,t,n,o)=>{let a=Math.min(40,Math.max(8,Math.abs(t.x-e.x)/4,Math.abs(t.y-e.y)/4));if(n||o){let c=[e],u=e,d=t;n&&(u={x:e.x+n.x*a,y:e.y+n.y*a},c.push(u));let f=null;o&&(f={x:t.x+o.x*a,y:t.y+o.y*a});let p=f??d,h=p.x-u.x,m=p.y-u.y,x=n?Math.abs(n.x)>Math.abs(n.y):Math.abs(h)>=Math.abs(m);if(Math.abs(h)>.5&&Math.abs(m)>.5){let y=x?{x:p.x,y:u.y}:{x:u.x,y:p.y};c.push(y)}return f&&c.push(f),c.push(t),c}let r=t.x-e.x,s=t.y-e.y,l=Math.abs(r)>=Math.abs(s)?{x:t.x,y:e.y}:{x:e.x,y:t.y};return[e,l,t]},TA=e=>{if(e.kind!=="anchor"||e.anchor.kind!=="named")return null;switch(e.anchor.name){case"top":return{x:0,y:-1};case"right":return{x:1,y:0};case"bottom":return{x:0,y:1};case"left":return{x:-1,y:0};default:return null}},yT=(e,t,n)=>{let o=TA(e);if(o)return o;let a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>=Math.abs(r)?{x:Math.sign(a)||1,y:0}:{x:0,y:Math.sign(r)||1}},jf=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=IA(e,t);if(n)return lH(n);let o=ot(e,t);if(!o||o.length<2)return null;let a=v(o[0]),r=v(o[o.length-1]);if(o.length===2){let s=yT(t.from,a,r),i=yT(t.to,r,a);return{start:a,segments:[CA(a,r,s,i)]}}return{start:a,segments:Ff(o)}},cc=(e,t)=>{if((t.routing??"straight")!=="bezier")return ot(e,t);let n=jf(e,t);return n?Hf(n.start,n.segments):null},Vf=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;if(n==="bezier"){let r=jf(e,t);if(!r)return null;let s=[],i=r.start;for(let l of r.segments)s.push(cn.cubicAt(i,l.c1,l.c2,l.to,.5)),i=l.to;return s}let o=ot(e,t);if(!o||o.length<2)return null;let a=[];for(let r=0;r<o.length-1;r++){let s=v(o[r]),i=v(o[r+1]);a.push(U.midpoint(s,i))}return a},MA=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=cc(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=za.distanceToSegment(t,v(r[i-1]),v(r[i]));l<s&&(s=l)}s>n||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null};var Zf=e=>{let t=e.length;if(t<2)return[];let n=d=>{let f=v(e[d]);return{x:f.x,y:f.y}},o=d=>v(e[d]).width,a=[],r=[];for(let d=0;d<t-1;d++){let f=U.sub(n(d+1),n(d)),p=U.lengthSq(f)>0?U.normalize(f):{x:1,y:0};a.push(p),r.push(U.perp(p))}let s=[],i=[];for(let d=0;d<t;d++){let f=o(d),p=n(d);if(d===0){let y=v(r[0]);s.push(U.add(p,U.mul(y,f))),i.push(U.sub(p,U.mul(y,f)));continue}if(d===t-1){let y=v(r[t-2]);s.push(U.add(p,U.mul(y,f))),i.push(U.sub(p,U.mul(y,f)));continue}let h=v(r[d-1]),m=v(r[d]),x=U.cross(v(a[d-1]),v(a[d]));if(Math.abs(x)<1e-9){s.push(U.add(p,U.mul(h,f))),i.push(U.sub(p,U.mul(h,f)));continue}x>0?(s.push(...bT(p,h,m,f,1)),i.push(...AT(p,h,m,f,-1))):(s.push(...AT(p,h,m,f,1)),i.push(...bT(p,h,m,f,-1)))}let l=vT(n(t-1),v(r[t-2]),o(t-1),!1),c=vT(n(0),v(r[0]),o(0),!0),u=[];for(let d of s)u.push(d);for(let d of l)u.push(d);for(let d=i.length-1;d>=0;d--)u.push(v(i[d]));for(let d of c)u.push(d);return u},bT=(e,t,n,o,a)=>{let r=U.normalize(U.add(t,n)),s=U.dot(r,t);return s>.001&&1/s<=2.5?[U.add(e,U.mul(r,a*(o/s)))]:[U.add(e,U.mul(t,a*o)),U.add(e,U.mul(n,a*o))]},AT=(e,t,n,o,a)=>ST(e,o,U.angle(U.mul(t,a)),U.angle(U.mul(n,a))),vT=(e,t,n,o)=>{let a=U.angle(t)+(o?Math.PI:0);return ST(e,n,a,a-Math.PI)},ST=(e,t,n,o)=>{let a=o-n;for(;a>Math.PI+1e-9;)a-=2*Math.PI;for(;a<-Math.PI-1e-9;)a+=2*Math.PI;let r=Math.max(1,Math.ceil(Math.abs(a)/.35)),s=[];for(let i=0;i<=r;i++){let l=n+a*i/r;s.push({x:e.x+t*Math.cos(l),y:e.y+t*Math.sin(l)})}return s};var LT=new Map,RA=(e,t)=>{LT.set(e,t)},Xf=e=>{let t=z(e),n=LT.get(e.type);if(!n)return t;let o=n(e),a=o.top??0,r=o.right??0,s=o.bottom??0,i=o.left??0;return a===0&&r===0&&s===0&&i===0?t:{x:t.x-i,y:t.y-a,width:t.width+i+r,height:t.height+a+s}};var Yf=class{contributors;constructor(t){this.contributors=t}snap(t){let n=[];for(let o of this.contributors)for(let a of o.contribute(t))a.distance<=t.threshold*t.threshold&&n.push(a);return n.sort((o,a)=>o.distance-a.distance),{best:n[0]??null,all:n}}},DA={id:"grid",contribute(e){if(!e.scene.viewport.gridEnabled)return[];let t=20,n={x:Math.round(e.probe.x/t)*t,y:Math.round(e.probe.y/t)*t},o=n.x-e.probe.x,a=n.y-e.probe.y;return[{snapped:n,distance:o*o+a*a,kind:"grid"}]}},PA={id:"anchor",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!kT(n,e.probe,e.threshold))continue;let o=Ga(n,e.probe,So(n)),a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"anchor",metadata:{elementId:n.id,ref:o.ref}})}return t}},BA={id:"outline",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!kT(n,e.probe,e.threshold))continue;let o=dT(n,e.probe);if(!o)continue;let a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"outline",metadata:{elementId:n.id,ratio:o.ratio}})}return t}},kT=(e,t,n)=>{let o=n,a=t.x-e.position.x,r=t.y-e.position.y;return Math.abs(a)<=1e3+o&&Math.abs(r)<=1e3+o};var NA=()=>20,I0=e=>e.snapToGrid??!0,zA=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),oo=e=>{let t=N.translation(-e.pan.x,-e.pan.y),n=N.rotation(e.rotation),o=N.scaling(e.zoom);return N.multiply(o,N.multiply(n,t))},Wa=e=>N.inverse(oo(e)),FA=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),M0=(e,t,n)=>{let o=e.zoom*t;return{...e,zoom:o,pan:{x:n.x-(n.x-e.pan.x)/t,y:n.y-(n.y-e.pan.y)/t}}},HA=(e,t,n)=>({...e,size:{width:t,height:n}});var Ct=class extends Error{name="FractionalIndexError"};var R0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function wT(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Ct("invalid order key head: "+e)}function _T(e){let t=e.charAt(0);if(e.length!==wT(t))throw new Ct("invalid integer part of order key: "+e)}function uc(e){let t=wT(e.charAt(0));if(t>e.length)throw new Ct("invalid order key: "+e);return e.slice(0,t)}function UA(e,t){_T(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Ct("invalid integer part of order key: "+e);let r=!0;for(let s=a.length-1;r&&s>=0;s--){let i=a[s];if(i===void 0)continue;let l=t.indexOf(i)+1;l===t.length?a[s]=n:(a[s]=t.charAt(l),r=!1)}if(r){if(o==="Z")return"a"+n;if(o==="z")return null;let s=String.fromCharCode(o.charCodeAt(0)+1);return s>"a"?a.push(n):a.pop(),s+a.join("")}return o+a.join("")}function CT(e,t){_T(e);let[n,...o]=e.split("");if(n===void 0)throw new Ct("invalid integer part of order key: "+e);let a=t.slice(-1),r=!0;for(let s=o.length-1;r&&s>=0;s--){let i=o[s];if(i===void 0)continue;let l=t.indexOf(i)-1;l===-1?o[s]=a:(o[s]=t.charAt(l),r=!1)}if(r){if(n==="a")return"Z"+a;if(n==="A")return null;let s=String.fromCharCode(n.charCodeAt(0)-1);return s<"Z"?o.push(a):o.pop(),s+o.join("")}return n+o.join("")}function di(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Ct(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Ct("trailing zero");if(t!==null){let s=0;for(;(e.charAt(s)||o)===t.charAt(s);)s++;if(s>0)return t.slice(0,s)+di(e.slice(s),t.slice(s),n)}let a=e?n.indexOf(e.charAt(0)):0,r=t!==null?n.indexOf(t.charAt(0)):n.length;if(r-a>1){let s=Math.round(.5*(a+r));return n.charAt(s)}return t!==null&&t.length>1?t.slice(0,1):n.charAt(a)+di(e.slice(1),null,n)}function ET(e){return"A"+e.charAt(0).repeat(26)}function dH(e){return"a"+e.charAt(0)}function GA(e,t=R0){if(e===ET(t))throw new Ct("invalid order key: "+e);let n=uc(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Ct("invalid order key: "+e)}function ao(e,t,n=R0){let o=e??null,a=t??null;if(o!==null&&GA(o,n),a!==null&&GA(a,n),o!==null&&a!==null&&o>=a)throw new Ct(o+" >= "+a);if(o===null&&a===null)return dH(n);if(o===null){let u=uc(a),d=a.slice(u.length);if(u===ET(n))return u+di("",d,n);if(u<a)return u;let f=CT(u,n);if(f===null)throw new Ct("cannot decrement any more");return f}if(a===null){let u=uc(o),d=o.slice(u.length),f=UA(u,n);return f===null?u+di(d,null,n):f}let r=uc(o),s=o.slice(r.length),i=uc(a),l=a.slice(i.length);if(r===i)return r+di(s,l,n);let c=UA(r,n);if(c===null)throw new Ct("cannot increment any more");return c<a?c:r+di(s,null,n)}function Kf(e,t,n,o=R0){if(!Number.isInteger(n)||n<0)throw new Ct(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[ao(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=ao(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ao(l,r,o),c.push(l);return c}if(a===null){let l=ao(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ao(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=ao(a,r,o);return[...Kf(a,i,s,o),i,...Kf(i,r,n-s-1,o)]}var Rn=ln("default"),fH=()=>({id:Rn,name:"Default",visible:!0,locked:!1,order:ao(null,null)}),un=Object.freeze({elements:new Map,links:new Map,layers:new Map([[Rn,fH()]]),annotations:new Map,files:new Map,viewport:zA}),WA=()=>({elements:new Map(un.elements),links:new Map(un.links),layers:new Map(un.layers),annotations:new Map(un.annotations),files:new Map(un.files),viewport:un.viewport});var O0=(e,t)=>e.files.get(t),Q=(e,t)=>{switch(t.kind){case"element":{let n=new Map(e.elements);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,elements:n}}case"link":{let n=new Map(e.links);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,links:n}}case"layer":{let n=new Map(e.layers);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,layers:n}}case"annotation":{let n=new Map(e.annotations);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,annotations:n}}case"viewport":return{...e,viewport:t.after};case"file":{let n=new Map(e.files);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,files:n}}case"batch":return t.patches.reduce(Q,e)}},Ae=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return ao(t,null)},dc=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return ao(null,t)},fc=(e,t)=>ao(e,t),qA=(e,t,n)=>Kf(e,t,n);var jA={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},TT=Object.keys(jA),Tae=TT.filter(e=>jA[e]==="ephemeral"),pH=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of TT)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},VA=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??un.elements),links:new Map(t?.links??un.links),layers:new Map(t?.layers??un.layers),annotations:new Map(t?.annotations??un.annotations),files:new Map(t?.files??un.files),viewport:pH(un.viewport,n?.viewport,t?.viewport)}};var ZA=(e,t,n={})=>({id:e,data:t,mime:n.mime??"application/octet-stream",createdAt:n.createdAt??Date.now(),...n.name!==void 0?{name:n.name}:{}});var pc=e=>{switch(e.kind){case"element":return{kind:"element",id:e.id,before:e.after,after:e.before};case"link":return{kind:"link",id:e.id,before:e.after,after:e.before};case"layer":return{kind:"layer",id:e.id,before:e.after,after:e.before};case"annotation":return{kind:"annotation",id:e.id,before:e.after,after:e.before};case"viewport":return{kind:"viewport",before:e.after,after:e.before};case"file":return{kind:"file",id:e.id,before:e.after,after:e.before};case"batch":return{kind:"batch",patches:e.patches.map(pc).reverse()}}},Vo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Yr=e=>{switch(e.kind){case"element":case"link":case"layer":case"annotation":case"file":return e.before===e.after;case"viewport":return e.before===e.after;case"batch":return e.patches.length===0||e.patches.every(Yr)}};var Fe=(e,t)=>{if(e.elements.has(t.id))throw new Error(`Element already exists: ${t.id}`);let n={kind:"element",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},dn=(e,t)=>{let n=e.elements.get(t);if(!n)throw new Error(`Element not found: ${t}`);let o={kind:"element",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},J=(e,t,n)=>{let o=e.elements.get(t);if(!o)throw new Error(`Element not found: ${t}`);let a=n(o),r={kind:"element",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}};var fi=(e,t)=>{if(e.links.has(t.id))throw new Error(`Link already exists: ${t.id}`);let n={kind:"link",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},pi=(e,t)=>{let n=e.links.get(t);if(!n)throw new Error(`Link not found: ${t}`);let o={kind:"link",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},et=(e,t,n)=>{let o=e.links.get(t);if(!o)throw new Error(`Link not found: ${t}`);let a=n(o),r={kind:"link",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}},XA=(e,t)=>{if(e.layers.has(t.id))throw new Error(`Layer already exists: ${t.id}`);let n={kind:"layer",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},YA=(e,t)=>{let n=e.layers.get(t);if(!n)throw new Error(`Layer not found: ${t}`);let o={kind:"layer",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},$f=(e,t,n)=>{let o=e.layers.get(t);if(!o)throw new Error(`Layer not found: ${t}`);let a=n(o),r={kind:"layer",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}},KA=(e,t)=>{if(e.annotations.has(t.id))throw new Error(`Annotation already exists: ${t.id}`);let n={kind:"annotation",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},$A=(e,t)=>{let n=e.annotations.get(t);if(!n)throw new Error(`Annotation not found: ${t}`);let o={kind:"annotation",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},qa=(e,t,n)=>{let o=e.annotations.get(t);if(!o)throw new Error(`Annotation not found: ${t}`);let a=n(o),r={kind:"annotation",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}};var Kr=(e,t)=>{if(t.elementId===null)return t.position;let n=I(e,t.elementId);return n?{x:n.position.x+t.position.x,y:n.position.y+t.position.y}:t.position};var IT=new Map,QA=(e,t)=>{IT.set(e,t)},JA=e=>{let t=IT.get(e.type);if(t){let n=t(e).trim();if(n)return n}return MT(e.type)},MT=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");QA("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});QA("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():MT(e.templateId)});var RT=new Map,e2=e=>{RT.set(e.kind,e)};var D0=e=>RT.get(e);var Qf=e=>{try{let t=Re(e);return{width:t.width*Math.abs(e.scale.x),height:t.height*Math.abs(e.scale.y)}}catch{return{width:0,height:0}}},P0=(e,t)=>{if(t.shapeIds.length===0||t.cols<1)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let d of t.shapeIds){let f=I(e,d);f&&a.push(f)}a.sort(_t);let r=a.map(Qf),s=r.reduce((d,f)=>Math.max(d,f.width),0),i=r.reduce((d,f)=>Math.max(d,f.height),0),l={x:s+n,y:i+n},c=[],u=e;return a.forEach((d,f)=>{let p=f%t.cols,h=Math.floor(f/t.cols),m={x:o.x+p*l.x,y:o.y+h*l.y};if(d.position.x===m.x&&d.position.y===m.y)return;let x=J(u,d.id,y=>({...y,position:m}));u=x.scene,c.push(x.patch)}),c.length===0?null:Vo(c)},B0=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let l of t.shapeIds){let c=I(e,l);c&&a.push(c)}a.sort(_t);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=Qf(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=J(s,l.id,p=>({...p,position:d}));s=f.scene,r.push(f.patch)}t.direction==="horizontal"?i={x:i.x+c+n,y:i.y}:i={x:i.x,y:i.y+u+n}}return r.length===0?null:Vo(r)},OT=(e,t,n,o)=>{let a=[],r=o.x,s=o.y,i=0,l=0,c=0,u=!0;for(let d of e)l=Math.max(l,d.w),!u&&r-o.x+d.w>n+1e-6&&(c=Math.max(c,r-t-o.x),r=o.x,s+=i+t,i=0,u=!0),a.push({id:d.id,x:r,y:s}),r+=d.w+t,i=Math.max(i,d.h),u=!1;return c=Math.max(c,r-t-o.x),{placements:a,widest:l,contentWidth:Math.max(0,c),contentHeight:s+i-o.y}},DT=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n.sort(_t),n.map(o=>{let a=Qf(o);return{id:o.id,w:a.width,h:a.height}})},PT=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=DT(e,t.shapeIds),{placements:r}=OT(a,n,t.innerWidth,o),s=[],i=e;for(let l of r){let c=I(i,l.id);if(!c||c.position.x===l.x&&c.position.y===l.y)continue;let u=J(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Vo(s)},N0=(e,t,n)=>{let o=[];for(let l of e.elements.values())l.parentId===t&&o.push(l.id);if(o.length===0)return null;let a=DT(e,o),r=I(e,t),s=(r?On(r):null)?.gap??16,i=OT(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},On=e=>{let t=e.metadata?.autoLayout;if(!t||typeof t!="object")return null;let n=t;if(n.kind==="grid")return typeof n.cols!="number"||n.cols<1?null:{kind:"grid",cols:n.cols,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="stack")return n.direction!=="horizontal"&&n.direction!=="vertical"?null:{kind:"stack",direction:n.direction,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="wrap")return{kind:"wrap",...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="tree"){let o=t;return{kind:"tree",...typeof o.ranksep=="number"?{ranksep:o.ranksep}:{},...typeof o.nodesep=="number"?{nodesep:o.nodesep}:{}}}if(typeof n.kind=="string"){let o=D0(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},Jf=(e,t)=>{let n=I(e,t);if(!n)return null;let o=On(n);if(!o)return null;let a=[];for(let c of e.elements.values())c.parentId===t&&a.push(c.id);if(a.length===0)return null;let r=to(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return P0(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return B0(e,{shapeIds:a,origin:s,direction:o.direction,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="wrap"){let c=r?r.width:Number.POSITIVE_INFINITY;return PT(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return BT(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=D0(i.kind);return l?l.run(e,t,a,s,i):null},BT=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.ranksep??80,o=t.nodesep??24,a=t.origin??{x:0,y:0},r=m=>{let x=[];for(let y of e.elements.values())y.parentId===m&&x.push(y);return x.sort(_t),x},s=new Map,i=new Map,l=m=>Qf(m).width,c=m=>Qf(m).height,u=m=>{let x=s.get(m),y=i.get(m);if(x!==void 0&&y!==void 0)return{w:x,h:y};let g=I(e,m);if(!g)return s.set(m,0),i.set(m,0),{w:0,h:0};let b=l(g),A=c(g),_=r(m);if(_.length===0)return s.set(m,b),i.set(m,A),{w:b,h:A};let T=0,w=0;for(let M=0;M<_.length;M++){let B=u(v(_[M]).id);T+=B.w,M>0&&(T+=o),B.h>w&&(w=B.h)}let S=Math.max(b,T),L=A+n+w;return s.set(m,S),i.set(m,L),{w:S,h:L}};for(let m of t.shapeIds)u(m);let d=[],f=e,p=(m,x,y)=>{let g=I(f,m);if(!g)return;let b=u(m),A=l(g),_=c(g),T={x:x+(b.w-A)/2,y};if(g.position.x!==T.x||g.position.y!==T.y){let M=J(f,m,B=>({...B,position:T}));f=M.scene,d.push(M.patch)}let w=r(m);if(w.length===0)return;let S=x,L=y+_+n;for(let M of w)p(M.id,S,L),S+=u(M.id).w+o},h=a.x;for(let m of t.shapeIds)p(m,h,a.y),h+=u(m).w+o;return d.length===0?null:Vo(d)};var mH=20,z0=.5,yH=1e5,n2=(e,t,n,o={})=>{if(gH(e,t))return[e];let a=o.margin??mH,r=n.map(S=>xH(S,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let S of r)l.add(S.x),l.add(S.x+S.width),c.add(S.y),c.add(S.y+S.height);let u=[...l].sort((S,L)=>S-L),d=[...c].sort((S,L)=>S-L),f=(S,L)=>`${S},${L}`,p=S=>v(u[S]),h=S=>v(d[S]),m=u.indexOf(e.x),x=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),b=(S,L)=>Math.abs(p(S)-p(y))+Math.abs(h(L)-h(g)),A=f(m,x),_=[{key:A,skey:`${A},0`,xi:m,yi:x,axis:0,g:0,f:b(m,x)}],T=new Map,w=new Map([[`${A},0`,0]]);for(;_.length>0;){_.sort((L,M)=>L.f-M.f||L.g-M.g||(L.skey<M.skey?-1:1));let S=v(_.shift());if(S.xi===y&&S.yi===g)return vH(T,S.skey,p,h);for(let L of bH(S.xi,S.yi,u.length,d.length)){let M={x:p(S.xi),y:h(S.yi)},B={x:p(L.xi),y:h(L.yi)};if(AH(M,B,r))continue;let W=Math.sign(B.x-M.x),ie=Math.sign(B.y-M.y);if(S.axis===0&&s&&W===-Math.sign(s.x)&&ie===-Math.sign(s.y)||L.xi===y&&L.yi===g&&i&&W===Math.sign(i.x)&&ie===Math.sign(i.y))continue;let ne=L.xi!==S.xi?1:2,j=Math.abs(M.x-B.x)+Math.abs(M.y-B.y),ve=S.axis!==0&&S.axis!==ne?yH:0,ye=S.g+j+ve,ee=f(L.xi,L.yi),Se=`${ee},${ne}`,Oe=w.get(Se);Oe!==void 0&&ye>=Oe||(w.set(Se,ye),T.set(Se,S.skey),_.push({key:ee,skey:Se,xi:L.xi,yi:L.yi,axis:ne,g:ye,f:ye+b(L.xi,L.yi)}))}}return null},gH=(e,t)=>e.x===t.x&&e.y===t.y,xH=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),bH=(e,t,n,o)=>{let a=[];return e>0&&a.push({xi:e-1,yi:t}),e<n-1&&a.push({xi:e+1,yi:t}),t>0&&a.push({xi:e,yi:t-1}),t<o-1&&a.push({xi:e,yi:t+1}),a},AH=(e,t,n)=>{let o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),r=Math.min(e.y,t.y),s=Math.max(e.y,t.y);for(let i of n){let l=i.x+i.width,c=i.y+i.height;if(!(a<=i.x||o>=l||s<=i.y||r>=c)&&!(a-i.x<=z0||l-o<=z0||s-i.y<=z0||c-r<=z0))return!0}return!1},vH=(e,t,n,o)=>{let a=[],r=new Set,s=t;for(;s&&!r.has(s);){r.add(s);let i=s.split(",").map(Number);a.unshift({x:n(v(i[0])),y:o(v(i[1]))}),s=e.get(s)}return SH(a)},SH=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(e[n-1]),a=v(e[n]),r=v(e[n+1]),s=o.y===a.y&&a.y===r.y,i=o.x===a.x&&a.x===r.x;s||i||t.push(a)}return t.push(v(e[e.length-1])),t};var tp=(e,t)=>{let n=no(e,t.from),o=no(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?no(e,t.from,o)??n:n,r=t.to.kind==="floating"?no(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=UT(e,t.from,a,r),i=UT(e,t.to,r,a),l=t.avoidObstacles===!0?LH(e,t):void 0,c=l&&l.length<=150?l:void 0,u=WT(a,r,s,i,t.routedPoints,c);return u=_H(u,t.fixedSegments),u},LH=(e,t)=>{let n=new Set;for(let a of[t.from,t.to])a.kind!=="point"&&n.add(a.elementId);let o=[];for(let a of e.elements.values())n.has(a.id)||o.push(z(a));return o},o2=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=HT(e,t,n,a),s=HT(e,o,a,n);return[n,...WT(n,a,r,s),a]},WT=(e,t,n,o,a,r)=>{let s=30,i={x:e.x+n.heading.x*s,y:e.y+n.heading.y*s},l={x:t.x+o.heading.x*s,y:t.y+o.heading.y*s},c=[];if(n.obstacle&&c.push(n.obstacle),o.obstacle&&c.push(o.obstacle),r){let h=[...c,...r],m=n2(i,l,h,{startHeading:n.heading,endHeading:o.heading}),x=m&&m.length>=2?m:[i,GT(i,l,n.heading),l];return ep(x)}let u=kH(e,t,n,o,i,l);if(u&&!FT(u,c))return ep(u);let d=wH(e,t,n,o,i,l,c,a);if(d&&!FT(d,c))return ep(d);let f=n2(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,GT(i,l,n.heading),l];return ep(p)},kH=(e,t,n,o,a,r)=>{if(n.heading.y!==0&&o.heading.y===-n.heading.y){if(Math.sign(a.y-r.y)===Math.sign(n.heading.y)){let l=(e.x+t.x)/2;return[a,{x:l,y:a.y},{x:l,y:r.y},r]}let i=(a.y+r.y)/2;return[a,{x:a.x,y:i},{x:r.x,y:i},r]}if(n.heading.x!==0&&o.heading.x===-n.heading.x){if(Math.sign(a.x-r.x)===Math.sign(n.heading.x)){let l=(e.y+t.y)/2;return[a,{x:a.x,y:l},{x:r.x,y:l},r]}let i=(a.x+r.x)/2;return[a,{x:i,y:a.y},{x:i,y:r.y},r]}return null},NT=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},wH=(e,t,n,o,a,r,s,i)=>{if(s.length===0)return null;let l=1/0,c=1/0,u=-1/0,d=-1/0;for(let p of s)l=Math.min(l,p.x),c=Math.min(c,p.y),u=Math.max(u,p.x+p.width),d=Math.max(d,p.y+p.height);let f=20;if(l-=f,c-=f,u+=f,d+=f,n.heading.y===0&&o.heading.y===0&&n.heading.x!==0&&o.heading.x===-n.heading.x){let p=(e.y+t.y)/2,h=NT(p,(c+d)/2,c,d,zT(i,"y"));return[a,{x:a.x,y:h},{x:r.x,y:h},r]}if(n.heading.x===0&&o.heading.x===0&&n.heading.y!==0&&o.heading.y===-n.heading.y){let p=(e.x+t.x)/2,h=NT(p,(l+u)/2,l,u,zT(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},zT=(e,t)=>{if(!e||e.length<3)return null;let n=d=>t==="y"?d.y:d.x,o=n(v(e[0])),a=n(v(e[e.length-1])),r=Math.min(o,a),s=Math.max(o,a),i=1/0,l=-1/0;for(let d of e){let f=n(d);f<i&&(i=f),f>l&&(l=f)}let c=r-i,u=l-s;return c<=0&&u<=0?null:c>=u},FT=(e,t)=>{let n=1;for(let o=1;o<e.length;o++){let a=v(e[o-1]),r=v(e[o]);for(let s=0;s<=1;s+=.1){let i=a.x+(r.x-a.x)*s,l=a.y+(r.y-a.y)*s;for(let c of t)if(i>c.x+n&&i<c.x+c.width-n&&l>c.y+n&&l<c.y+c.height-n)return!0}}return!1},HT=(e,t,n,o)=>{if(!t)return{heading:qf(o,n),obstacle:null};let a=I(e,t);return a?{heading:cT(a,n),obstacle:z(a)}:{heading:qf(o,n),obstacle:null}},_H=(e,t)=>{if(!t||t.length===0)return e;let n=e.map(o=>({...o}));for(let o of t){let a=n.length-2,r=-1,s=1/0;for(let c=1;c<a;c++){let u=v(n[c]),d=v(n[c+1]),f=Math.abs(u.y-d.y)<1e-6,p=Math.abs(u.x-d.x)<1e-6;if(o.axis==="h"!==f||o.axis==="v"!==p)continue;let h=o.axis==="h"?(u.x+d.x)/2:(u.y+d.y)/2,m=Math.abs(h-o.at);m<s&&(s=m,r=c)}if(r>=0){let c=v(n[r]),u=v(n[r+1]);o.axis==="h"?(c.y=o.pos,u.y=o.pos):(c.x=o.pos,u.x=o.pos);continue}let i=v(n[0]),l=v(n[n.length-1]);n=o.axis==="h"?[i,{x:i.x,y:o.pos},{x:l.x,y:o.pos},l]:[i,{x:o.pos,y:i.y},{x:o.pos,y:l.y},l]}return ep(n)},CH=e=>{switch(e){case"top":return Wf;case"bottom":return Uf;case"left":return Gf;case"right":return lc;default:return null}},UT=(e,t,n,o)=>{if(t.kind==="point")return{heading:qf(o,n),obstacle:null};let a=I(e,t.elementId);if(!a)return{heading:qf(o,n),obstacle:null};let r=z(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=CH(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:C0(a,n),obstacle:r}},GT=(e,t,n)=>lT(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},ep=e=>{if(e.length<=2)return[...e];let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=1e-6,i=Math.abs(o.y-a.y)<s&&Math.abs(a.y-r.y)<s,l=Math.abs(o.x-a.x)<s&&Math.abs(a.x-r.x)<s,c=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;i||l||c||t.push(a)}return t.push(v(e[e.length-1])),t};var hi="orthogonal",np="triangle";var a2=Math.PI/12,Zo=11,qT=6,jT=4,VT=12,F0=9,r2=4,ZT="#1a73e8",XT="#fff",op=3.5,Xo=5,YT=8,KT=1.5,$T=ZT,s2=XT,QT=XT,i2=ZT,Lo=20,JT=0,eI="#ffffff",H0=6,U0=7,tI=18,l2=40,hc=.16,ap=.7,c2="#e8118c",nI="#f59e0b",rp="#2563eb",u2="#16a34a",oI="#06b6d4",aI="#a855f7",rI="#eab308",sI="#dc2626",iI="#14b8a6",lI="#f43f5e",cI=16,d2=14,f2=6,p2=3,h2=11,uI=1.5,dI=[4,3],fI=3;var m2=1,y2=1.6,g2=10,pI=1,hI=.05,mI=32,yI=.5,gI=500,mc=8,G0=300,W0=8,xI=.6,bI=.2,AI=.85,q0=.4,vI=22,SI=22,LI=18,kI=16,wI=16,_I=9,j0=12,CI="#f9a825",EI="#fff",TI="#888",II=10,x2=2e3,b2=.5,MI=.5,A2=12,sp=6,RI=2,OI="#222222",DI=1,PI=4,v2=sp*3,BI=6,V0="#888888",NI=1.5,Z0=120,zI=.25,FI=.5,HI=10,UI=1,X0=1400,GI="#ff2d2d",S2=4,WI=8,L2=480,qI=1e3/60,jI=1e3/12,VI=2,ZI=2*1024*1024,XI=3e4,YI=24,KI="system-ui, sans-serif",$I="#1a1a1a",QI=1e3,JI=1,e4=10,t4=530,n4="#1a73e8",o4=.25,a4=1.5,Y0=4,k2=1.1,ko=80,r4=8,K0=.5,s4=256,i4=30,l4=16,w2=4,c4=4,u4="rgba(0,0,0,0.65)",d4=16,f4="#1a73e8",p4="#fff",ip=10,h4=11,m4=.12,y4=14,g4=3;var mi=["nw","n","ne","e","se","s","sw","w"],yi=["nw","ne","se","sw"],x4=e=>{switch(e){case"nw":case"se":return"nwse-resize";case"ne":case"sw":return"nesw-resize";case"n":case"s":return"ns-resize";case"e":case"w":return"ew-resize"}};var gi=(e,t,n=1)=>{let o=t.x+t.width/2,a=t.y+t.height/2,r=t.x+t.width,s=t.y+t.height,i=3/n;switch(e){case"nw":return{x:t.x-i,y:t.y-i};case"n":return{x:o,y:t.y-i};case"ne":return{x:r+i,y:t.y-i};case"e":return{x:r+i,y:a};case"se":return{x:r+i,y:s+i};case"s":return{x:o,y:s+i};case"sw":return{x:t.x-i,y:s+i};case"w":return{x:t.x-i,y:a}}},_2=(e,t,n,o=11,a=mi)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=gi(f,t,n);if(Math.abs(e.x-p.x)<=r&&Math.abs(e.y-p.y)<=r)return f}let s=t.x,i=t.x+t.width,l=t.y,c=t.y+t.height,u=e.x>=s-r&&e.x<=i+r,d=e.y>=l-r&&e.y<=c+r;for(let f of a)switch(f){case"n":if(u&&Math.abs(e.y-l)<=r)return"n";break;case"s":if(u&&Math.abs(e.y-c)<=r)return"s";break;case"w":if(d&&Math.abs(e.x-s)<=r)return"w";break;case"e":if(d&&Math.abs(e.x-i)<=r)return"e";break}return null},yc=(e,t)=>e.rotation===0?t:U.rotateAround(t,e.pivot,e.rotation),TH=(e,t)=>e.rotation===0?t:U.rotateAround(t,e.pivot,-e.rotation),xi=e=>{let t=Re(e),n=t.x*e.scale.x,o=(t.x+t.width)*e.scale.x,a=t.y*e.scale.y,r=(t.y+t.height)*e.scale.y;return{bounds:{x:e.position.x+Math.min(n,o),y:e.position.y+Math.min(a,r),width:Math.abs(o-n),height:Math.abs(r-a)},rotation:e.rotation,pivot:e.position}},cp=e=>{let t=e.bounds;return[yc(e,{x:t.x,y:t.y}),yc(e,{x:t.x+t.width,y:t.y}),yc(e,{x:t.x+t.width,y:t.y+t.height}),yc(e,{x:t.x,y:t.y+t.height})]},b4=e=>yc(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),A4=(e,t,n=1)=>yc(t,gi(e,t.bounds,n)),v4=(e,t,n,o=11,a=mi)=>_2(TH(t,e),t.bounds,n,o,a),IH={kind:"ratio",position:{x:0,y:1}},MH=new Map;var RH=e=>MH.get(e)??IH,$0=(e,t=1)=>{let n=RH(e.type),o=Yt(e,n),a=jo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},Q0=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},C2=(e,t,n,o=11)=>{let a=o/n;return Math.abs(e.x-t.x)<=a&&Math.abs(e.y-t.y)<=a};function OH(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function DH(){let e=OH();if(e.__xstate__)return e.__xstate__}var S4=e=>{if(typeof window>"u")return;let t=DH();t&&t.register(e)};var J0=class{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}},P2=".",PH="",B2="",BH="#",NH="*",E4="xstate.init",T4="xstate.error",I2="xstate.stop";function zH(e,t){return{type:`xstate.after.${e}.${t}`}}function M2(e,t){return{type:`xstate.done.state.${e}`,output:t}}function FH(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function N2(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function ty(e){return{type:E4,input:e}}function Yo(e){setTimeout(()=>{throw e})}var HH=typeof Symbol=="function"&&Symbol.observable||"@@observable";function z2(e,t){let n=L4(e),o=L4(t);return typeof o=="string"?typeof n=="string"?o===n:!1:typeof n=="string"?n in o:Object.keys(n).every(a=>a in o?z2(n[a],o[a]):!1)}function ny(e){if(R4(e))return e;let t=[],n="";for(let o=0;o<e.length;o++){switch(e.charCodeAt(o)){case 92:n+=e[o+1],o++;continue;case 46:t.push(n),n="";continue}n+=e[o]}return t.push(n),t}function L4(e){if(Q4(e))return e.value;if(typeof e!="string")return e;let t=ny(e);return I4(t)}function I4(e){if(e.length===1)return e[0];let t={},n=t;for(let o=0;o<e.length-1;o++)if(o===e.length-2)n[e[o]]=e[o+1];else{let a=n;n={},a[e[o]]=n}return t}function F2(e,t){let n={},o=Object.keys(e);for(let a=0;a<o.length;a++){let r=o[a];n[r]=t(e[r],r,e,a)}return n}function M4(e){return R4(e)?e:[e]}function Ko(e){return e===void 0?[]:M4(e)}function R2(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function R4(e){return Array.isArray(e)}function UH(e){return e.type.startsWith("xstate.error.actor")}function bi(e){return M4(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function O4(e){if(!(e===void 0||e===PH))return Ko(e)}function up(e,t,n){let o=typeof e=="object",a=o?e:void 0;return{next:(o?e.next:e)?.bind(a),error:(o?e.error:t)?.bind(a),complete:(o?e.complete:n)?.bind(a)}}function H2(e,t){return`${t}.${e}`}function fp(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,o,a]=n,s=e.getStateNodeById(a).config.invoke;return(Array.isArray(s)?s[o]:s).src}function D4(e,t){if(t===e||t===NH)return!0;if(!t.endsWith(".*"))return!1;let n=t.split("."),o=e.split(".");for(let a=0;a<n.length;a++){let r=n[a],s=o[a];if(r==="*")return a===n.length-1;if(r!==s)return!1}return!0}function k4(e,t){return`${e.sessionId}.${t}`}var GH=0;function WH(e,t){let n=new Map,o=new Map,a=new WeakMap,r=new Set,s={},{clock:i,logger:l}=t,c={schedule:(f,p,h,m,x=Math.random().toString(36).slice(2))=>{let y={source:f,target:p,event:h,delay:m,id:x,startedAt:Date.now()},g=k4(f,x);d._snapshot._scheduledEvents[g]=y;let b=i.setTimeout(()=>{delete s[g],delete d._snapshot._scheduledEvents[g],d._relay(f,p,h)},m);s[g]=b},cancel:(f,p)=>{let h=k4(f,p),m=s[h];delete s[h],delete d._snapshot._scheduledEvents[h],m!==void 0&&i.clearTimeout(m)},cancelAll:f=>{for(let p in d._snapshot._scheduledEvents){let h=d._snapshot._scheduledEvents[p];h.source===f&&c.cancel(f,h.id)}}},u=f=>{if(!r.size)return;let p={...f,rootId:e.sessionId};r.forEach(h=>h.next?.(p))},d={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${GH++}`,_register:(f,p)=>(n.set(f,p),f),_unregister:f=>{n.delete(f.sessionId);let p=a.get(f);p!==void 0&&(o.delete(p),a.delete(f))},get:f=>o.get(f),getAll:()=>Object.fromEntries(o.entries()),_set:(f,p)=>{let h=o.get(f);if(h&&h!==p)throw new Error(`Actor with system ID '${f}' already exists.`);o.set(f,p),a.set(p,f)},inspect:f=>{let p=up(f);return r.add(p),{unsubscribe(){r.delete(p)}}},_sendInspectionEvent:u,_relay:(f,p,h)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:p,event:h}),p._send(h)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{let f=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(let p in f){let{source:h,target:m,event:x,delay:y,id:g}=f[p];c.schedule(h,m,x,y,g)}},_clock:i,_logger:l};return d}var E2=!1,oy=1,Kt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),qH={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},ey=class{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new J0(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Kt.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let o={...qH,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:WH(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(up(u)),this.sessionId=this.system._bookId(),this.id=l??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=s,this._syncSnapshot=i,this.options=o,this.src=o.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{let f=this.eventListeners.get(d.type),p=this.eventListeners.get("*");if(!f&&!p)return;let h=[...f?f.values():[],...p?p.values():[]];for(let m of h)try{m(d)}catch(x){Yo(x)}},actionExecutor:d=>{let f=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;let p=E2;try{E2=!0,d.exec(d.info,d.params)}finally{E2=p}};this._processingStatus===Kt.Running?f():this._deferred.push(f)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(n?.snapshot??n?.state),c&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,n){this._snapshot=t;let o;for(;o=this._deferred.shift();)try{o()}catch(a){this._deferred.length=0,this._snapshot={...t,status:"error",error:a}}switch(this._snapshot.status){case"active":for(let a of this.observers)try{a.next?.(t)}catch(r){Yo(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Yo(r)}this._stopProcedure(),this._complete(),this._doneEvent=FH(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,o){let a=up(t,n,o);if(this._processingStatus!==Kt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Yo(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Yo(r);else try{a.error(r)}catch(s){Yo(s)}break}}return{unsubscribe:()=>{this.observers.delete(a)}}}on(t,n){let o=this.eventListeners.get(t);o||(o=new Set,this.eventListeners.set(t,o));let a=n.bind(void 0);return o.add(a),{unsubscribe:()=>{o.delete(a)}}}select(t,n=Object.is){return{subscribe:o=>{let a=up(o),r=this.getSnapshot(),s=t(r);return this.subscribe(i=>{let l=t(i);n(s,l)||(s=l,a.next?.(l))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===Kt.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=Kt.Running;let t=ty(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,o;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(a){o={err:a}}if(o){let{err:a}=o;this._snapshot={...this._snapshot,status:"error",error:a},this._error(a);return}this.update(n,t),t.type===I2&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Kt.Stopped?this:(this.mailbox.clear(),this._processingStatus===Kt.NotStarted?(this._processingStatus=Kt.Stopped,this):(this.mailbox.enqueue({type:I2}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(n){Yo(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Yo(t),this.eventListeners.clear();return}let n=!1;for(let o of this.observers){let a=o.error;n||=!a;try{a?.(t)}catch(r){Yo(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Yo(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,N2(this.id,t))}_stopProcedure(){return this._processingStatus!==Kt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new J0(this._process.bind(this)),this._processingStatus=Kt.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==Kt.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&(typeof t=="function"?t:S4)(this)}toJSON(){return{xstate$$type:oy,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[HH](){return this}getSnapshot(){return this._snapshot}};function $o(e,...[t]){return new ey(e,t)}function jH(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function VH(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Ac(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=jH,t.execute=VH,t}function ZH(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?fp(t.machine,s):s,u=typeof a=="function"?a(n):a,d,f;return c&&(f=typeof i=="function"?i({context:t.context,event:n.event,self:e.self}):i,d=$o(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Qr(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function XH(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Kt.Stopped&&t.start()})}function vc(...[e,{id:t,systemId:n,input:o,syncSnapshot:a=!1}={}]){function r(s,i){}return r.type="xstate.spawnChild",r.id=t,r.systemId=n,r.src=e,r.input=o,r.syncSnapshot=a,r.resolve=ZH,r.execute=XH,r}function YH(e,t,n,o,{actorRef:a}){let r=typeof a=="function"?a(n,o):a,s=typeof r=="string"?t.children[r]:r,i=t.children;return s&&(i={...i},delete i[s.id]),[Qr(t,{children:i}),s,void 0]}function P4(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))P4(e,o);e.system._unregister(t)}function KH(e,t){if(t){if(P4(e,t),t._processingStatus!==Kt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Si(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=YH,t.execute=KH,t}function $H(e,{context:t,event:n},{guards:o}){return o.every(a=>Li(a,t,n,e))}function B4(e){function t(n,o){return!1}return t.check=$H,t.guards=e,t}function Li(e,t,n,o){let{machine:a}=o,r=typeof e=="function",s=r?e:a.implementations.guards[typeof e=="string"?e:e.type];if(!r&&!s)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof s!="function")return Li(s,t,n,o);let i={context:t,event:n},l=r||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in s?s.check(o,i,s):s(i,l)}function ay(e){return e.type==="atomic"||e.type==="final"}function xc(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Sc(e,t){let n=[];if(t===e)return n;let o=e.parent;for(;o&&o!==t;)n.push(o),o=o.parent;return n}function pp(e){let t=new Set(e),n=z4(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))w4(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of xc(o))if(a.type!=="history"&&!t.has(a)){let r=w4(a);for(let s of r)t.add(s)}}for(let o of t){let a=o.parent;for(;a;)t.add(a),a=a.parent}return t}function N4(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(ay(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=N4(a,t);return o}function z4(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function F4(e,t){let n=pp(t);return N4(e,z4(n))}function ry(e,t){return t.type==="compound"?xc(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?xc(t).every(n=>ry(e,n)):t.type==="final"}var hp=e=>e[0]===BH;function H4(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>D4(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function U4(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=zH(a,e.id),s=r.type;return e.entry.push(kc(r,{id:s,delay:a})),e.exit.push(Ac(s)),s};return Object.keys(t).flatMap(a=>{let r=t[a],s=typeof r=="string"?{target:r}:r,i=Number.isNaN(+a)?a:+a,l=n(i);return Ko(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{...ja(e,a.event,a),delay:r}})}function ja(e,t,n){let o=O4(n.target),a=n.reenter??!1,r=QH(e,o),s={...n,actions:Ko(n.actions),guard:n.guard,target:r,source:e,reenter:a,eventType:t,toJSON:()=>({...s,source:`#${e.id}`,target:r?r.map(i=>`#${i.id}`):void 0})};return s}function G4(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===B2)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,bi(o).map(a=>ja(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,bi(e.config.onDone).map(o=>ja(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,bi(n.onDone).map(a=>ja(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,bi(n.onError).map(a=>ja(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,bi(n.onSnapshot).map(a=>ja(e,o,a)))}}for(let n of e.after){let o=t.get(n.eventType);o||(o=[],t.set(n.eventType,o)),o.push(n)}return t}function W4(e){let t=[],n=o=>{Object.values(o).forEach(a=>{if(a.config.route&&a.config.id){let r=a.config.id,s=a.config.route.guard,i=({event:c})=>c.to===`#${r}`,l={...a.config.route,guard:s?B4([i,s]):i,target:`#${r}`};t.push(ja(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function q4(e,t){let n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let o={source:e,actions:!t||typeof t=="string"?[]:Ko(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function QH(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(hp(n))return e.machine.getStateNodeById(n);let o=n[0]===P2;if(o&&!e.parent)return dp(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return dp(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
11
- ${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function j4(e){let t=O4(e.config.target);return t?{target:t.map(n=>typeof n=="string"?dp(e.parent,n):n)}:e.parent.initial}function Ai(e){return e.type==="history"}function w4(e){let t=V4(e);for(let n of t)for(let o of Sc(n,e))t.add(o);return t}function V4(e){let t=new Set;function n(o){if(!t.has(o)){if(t.add(o),o.type==="compound")n(o.initial.target[0]);else if(o.type==="parallel")for(let a of xc(o))n(a)}}return n(e),t}function bc(e,t){if(hp(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function dp(e,t){if(typeof t=="string"&&hp(t))try{return e.machine.getStateNodeById(t)}catch{}let n=ny(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=bc(o,a)}return o}function Lc(e,t){if(typeof t=="string"){let a=e.states[t];if(!a)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,a]}let n=Object.keys(t),o=n.map(a=>bc(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=bc(e,r);if(!s)return a;let i=Lc(s,t[r]);return a.concat(i)},[]))}function JH(e,t,n,o){let r=bc(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function eU(e,t,n,o){let a=Object.keys(t),r=bc(e,a[0]),s=sy(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function tU(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=bc(e,r),l=sy(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function sy(e,t,n,o){return typeof t=="string"?JH(e,t,n,o):Object.keys(t).length===1?eU(e,t,n,o):tU(e,t,n,o)}function nU(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function $r(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function oU(e,t){let n=new Set(e),o=new Set(t);for(let a of n)if(o.has(a))return!0;for(let a of o)if(n.has(a))return!0;return!1}function Z4(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(oU(O2([a],t,n),O2([i],t,n)))if($r(a.source,i.source))s.add(i);else{r=!0;break}if(!r){for(let i of s)o.delete(i);o.add(a)}}return Array.from(o)}function aU(e){let[t,...n]=e;for(let o of Sc(t,void 0))if(n.every(a=>$r(a,o)))return o}function U2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(Ai(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of U2(j4(o),t))n.add(a);else n.add(o);return[...n]}function X4(e,t){let n=U2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||$r(a,e.source)))return e.source;let o=aU(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function O2(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=X4(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)$r(s,r)&&o.add(s)}return[...o]}function rU(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function G2(e,t,n,o,a){return D2([{target:[...V4(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function D2(e,t,n,o,a,r){let s=[];if(!e.length)return[t,s];let i=n.actionExecutor;n.actionExecutor=l=>{s.push(l),i(l)};try{let l=new Set(t._nodes),c=t.historyValue,u=Z4(e,l,c),d=t;a||([d,c]=cU(d,o,n,u,l,c,r,n.actionExecutor)),d=vi(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=iU(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=vi(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&rU(t._nodes,l)?[d,s]:[Qr(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function sU(e,t,n,o,a){if(o.output===void 0)return;let r=M2(a.id,a.output!==void 0&&a.parent?R2(a.output,e.context,t,n.self):void 0);return R2(o.output,e.context,r,n.self)}function iU(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;lU(o,s,u,c),i&&u.add(e.machine.root);let d=new Set;for(let f of[...c].sort((p,h)=>p.order-h.order)){a.add(f);let p=[];p.push(...f.entry);for(let h of f.invoke)p.push(vc(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=vi(l,t,n,p,r,f.invoke.map(h=>h.id)),f.type==="final"){let h=f.parent,m=h?.type==="parallel"?h:h?.parent,x=m||f;for(h?.type==="compound"&&r.push(M2(h.id,f.output!==void 0?R2(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&ry(a,m);)d.add(m),r.push(M2(m.id)),x=m,m=m.parent;if(m)continue;l=Qr(l,{status:"done",output:sU(l,t,n,l.machine.root,x)})}}return l}function lU(e,t,n,o){for(let a of e){let r=X4(a,t);for(let i of a.target||[])!Ai(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),gc(i,t,n,o);let s=U2(a,t);for(let i of s){let l=Sc(i,r);r?.type==="parallel"&&l.push(r),Y4(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function gc(e,t,n,o){if(Ai(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),gc(r,t,n,o);for(let r of a)T2(r,e.parent,o,t,n)}else{let a=j4(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),gc(r,t,n,o);for(let r of a.target)T2(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;Ai(a)||(o.add(a),n.add(a)),gc(a,t,n,o),T2(a,e,o,t,n)}else if(e.type==="parallel")for(let a of xc(e).filter(r=>!Ai(r)))[...o].some(r=>$r(r,a))||(Ai(a)||(o.add(a),n.add(a)),gc(a,t,n,o))}function Y4(e,t,n,o,a){for(let r of o)if((!a||$r(r,a))&&e.add(r),r.type==="parallel")for(let s of xc(r).filter(i=>!Ai(i)))[...e].some(i=>$r(i,s))||(e.add(s),gc(s,t,n,e))}function T2(e,t,n,o,a){Y4(n,o,a,Sc(e,t))}function cU(e,t,n,o,a,r,s,i){let l=e,c=O2(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of nU(d)){let p;f.history==="deep"?p=h=>ay(h)&&$r(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=vi(l,t,n,[...d.exit,...d.invoke.map(f=>Si(f.id))],s,void 0),a.delete(d);return[l,u||r]}function uU(e,t){return e.implementations.actions[t]}function K4(e,t,n,o,a,r){let{machine:s}=e,i=e;for(let l of o){let c=typeof l=="function",u=c?l:uU(s,typeof l=="string"?l:l.type),d={context:i.context,event:t,self:n.self,system:n.system},f=c||typeof l=="string"?void 0:"params"in l?typeof l.params=="function"?l.params({context:i.context,event:t}):l.params:void 0;if(!u||!("resolve"in u)){n.actionExecutor({type:typeof l=="string"?l:typeof l=="object"?l.type:l.name||"(anonymous)",info:d,params:f,exec:u});continue}let p=u,[h,m,x]=p.resolve(n,i,d,f,u,a);i=h,"retryResolve"in p&&r?.push([p,m]),"execute"in p&&n.actionExecutor({type:p.type,info:d,params:m,exec:p.execute.bind(null,n,m)}),x&&(i=K4(i,t,n,x,a,r))}return i}function vi(e,t,n,o,a,r){let s=r?[]:void 0,i=K4(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function mp(e,t,n,o){let a=e,r=[];function s(d,f,p){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:f,snapshot:d[0],_transitions:p}),r.push(d)}if(t.type===I2)return a=Qr(_4(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==E4){let d=i,f=UH(d),p=C4(d,a);if(f&&!p.length)return a=Qr(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=D2(p,e,n,i,!1,o);a=h[0],s(h,d,p)}let l=!0,c=e.machine.options?.maxIterations??1/0,u=0;for(;a.status==="active";){if(u++,u>c)throw new Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let d=l?dU(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=C4(i,a)}let p=D2(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&_4(a,i,n),{snapshot:a,microsteps:r}}function _4(e,t,n){return vi(e,t,n,Object.values(e.children).map(o=>Si(o)),[],void 0)}function C4(e,t){return t.machine.getTransitionData(t,e)}function dU(e,t){let n=new Set,o=e._nodes.filter(ay);for(let a of o)e:for(let r of[a].concat(Sc(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||Li(s.guard,e.context,t,e)){n.add(s);break e}}return Z4(Array.from(n),new Set(e._nodes),e.historyValue)}function $4(e,t){let n=pp(Lc(e,t));return F4(e,[...n])}function Q4(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var fU=function(t){return z2(t,this.value)},pU=function(t){return this.tags.has(t)},hU=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},mU=function(){let{_nodes:t,tags:n,machine:o,getMeta:a,toJSON:r,can:s,hasTag:i,matches:l,...c}=this;return{...c,tags:Array.from(n)}},yU=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function yp(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:F4(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:fU,hasTag:pU,can:hU,getMeta:yU,toJSON:mU}}function Qr(e,t={}){return yp({...e,...t},e.machine)}function gU(e){if(typeof e!="object"||e===null)return{};let t={};for(let n in e){let o=e[n];Array.isArray(o)&&(t[n]=o.map(a=>({id:a.id})))}return t}function J4(e,t){let{_nodes:n,tags:o,machine:a,children:r,context:s,can:i,hasTag:l,matches:c,getMeta:u,toJSON:d,...f}=e,p={};for(let m in r){let x=r[m];p[m]={snapshot:x.getPersistedSnapshot(t),src:x.src,systemId:x.systemId,syncSnapshot:x._syncSnapshot}}return{...f,context:e5(s),children:p,historyValue:gU(f.historyValue)}}function e5(e){let t;for(let n in e){let o=e[n];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:oy,id:o.id};else{let a=e5(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function xU(e,t,n,o,{event:a,id:r,delay:s},{internalQueue:i}){let l=t.machine.implementations.delays;if(typeof a=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${a}" }) instead`);let c=typeof a=="function"?a(n,o):a,u;if(typeof s=="string"){let d=l&&l[s];u=typeof d=="function"?d(n,o):d}else u=typeof s=="function"?s(n,o):s;return typeof u!="number"&&i.push(c),[t,{event:c,id:r,delay:u},void 0]}function bU(e,t){let{event:n,delay:o,id:a}=t;if(typeof o=="number"){e.defer(()=>{let r=e.self;e.system.scheduler.schedule(r,r,n,o,a)});return}}function kc(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=xU,n.execute=bU,n}function t5(e,t){return{config:e,transition:(n,o,a)=>({...n,context:e(n.context,o,a)}),getInitialSnapshot:(n,o)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:o}):t}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}var hse=t5(e=>{},void 0);function AU(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=fp(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=$o(l,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:typeof i?.input=="function"?i.input({context:n,event:o,self:e.self}):i?.input,src:s,systemId:i?.systemId});return a[c.id]=c,c}else return $o(s,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:i?.input,src:s,systemId:i?.systemId})};return(s,i)=>{let l=r(s,i);return a[l.id]=l,e.defer(()=>{l._processingStatus!==Kt.Stopped&&l.start()}),l}}function vU(e,t,n,o,{assignment:a}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let r={},s={context:t.context,event:n.event,spawn:AU(e,t,n.event,r),self:e.self,system:e.system},i={};if(typeof a=="function")i=a(s,o);else for(let c of Object.keys(a)){let u=a[c];i[c]=typeof u=="function"?u(s,o):u}let l=Object.assign({},t.context,i);return[Qr(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function Dn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=vU,t}var n5=new WeakMap;function wc(e,t,n){let o=n5.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},n5.set(e,o)),o[t]}var SU={},gp=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,iy=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(P2),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?F2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):SU,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=Ko(this.config.entry).slice(),this.exit=Ko(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Ko(t.tags).slice()}_initialize(){this.transitions=G4(this),this.config.always&&(this.always=bi(this.config.always).map(t=>ja(this,B2,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(gp),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(gp),eventType:null})}:void 0,history:this.history,states:F2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(gp)})),entry:this.entry.map(gp),exit:this.exit.map(gp),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return wc(this,"invoke",()=>Ko(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??H2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${H2(this.id,n)}`;return{...t,src:s,id:r,systemId:a,toJSON(){let{onDone:i,onError:l,...c}=t;return{...c,type:"xstate.invoke",src:s,id:r}}}}))}get on(){return wc(this,"on",()=>[...this.transitions].flatMap(([n,o])=>o.map(a=>[n,a])).reduce((n,[o,a])=>(n[o]=n[o]||[],n[o].push(a),n),{}))}get after(){return wc(this,"delayedTransitions",()=>U4(this))}get initial(){return wc(this,"initial",()=>q4(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=wc(this,`candidates-${o}`,()=>H4(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||Li(l,c,n,t)}catch(d){let f=typeof l=="string"?l:typeof l=="object"?l.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${o}' in state node '${this.id}':
12
- ${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return wc(this,"events",()=>{let{states:t}=this,n=new Set(this.ownEvents);if(t)for(let o of Object.keys(t)){let a=t[o];if(a.states)for(let r of a.events)n.add(`${r}`)}return Array.from(n)})}get ownEvents(){let t=Object.keys(Object.fromEntries(this.transitions)),n=new Set(t.filter(o=>this.transitions.get(o).some(a=>!(!a.target&&!a.actions.length&&!a.reenter))));return Array.from(n)}},LU="#",ly=class e{constructor(t,n){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new iy(t,{_key:this.id,_machine:this}),this.root._initialize(),W4(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:o,actors:a,delays:r}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...o,...t.guards},actors:{...a,...t.actors},delays:{...r,...t.delays}})}resolveState(t){let n=$4(this.root,t.value),o=pp(Lc(this.root,n));return yp({_nodes:[...o],context:t.context||{},children:{},status:ry(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return mp(t,n,o,[]).snapshot}microstep(t,n,o){return mp(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return sy(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=yp({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?vi(r,n,t,[Dn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=ty(n),a=[],r=this._getPreInitialState(t,o,a),[s]=G2(this.root,r,t,o,a),{snapshot:i}=mp(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=ny(t),o=n.slice(1),a=hp(n[0])?n[0].slice(LU.length):n[0],r=this.idMap.get(a);if(!r)throw new Error(`Child state node '#${a}' does not exist on machine '${this.id}'`);return dp(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return J4(t,n)}restoreSnapshot(t,n){let o={},a=t.children;Object.keys(a).forEach(d=>{let f=a[d],p=f.snapshot,h=f.src,m=typeof h=="string"?fp(this,h):h;if(!m)return;let x=$o(m,{id:d,parent:n.self,syncSnapshot:f.syncSnapshot,snapshot:p,src:h,systemId:f.systemId});o[d]=x});function r(d,f){if(f instanceof iy)return f;try{return d.machine.getStateNodeById(f.id)}catch{}}function s(d,f){if(!f||typeof f!="object")return{};let p={};for(let h in f){let m=f[h];for(let x of m){let y=r(d,x);y&&(p[h]??=[],p[h].push(y))}}return p}let i=s(this.root,t.historyValue),l=yp({...t,children:o,_nodes:Array.from(pp(Lc(this.root,t.value))),historyValue:i},this),c=new Set;function u(d,f){if(!c.has(d)){c.add(d);for(let p in d){let h=d[p];if(h&&typeof h=="object"){if("xstate$$type"in h&&h.xstate$$type===oy){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function kU(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function wU(e,{event:t}){e.defer(()=>e.emit(t))}function uy(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=kU,t.execute=wU,t}var cy=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function _U(e,t,n,o,{to:a,event:r,id:s,delay:i},l){let c=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);let u=typeof r=="function"?r(n,o):r,d;if(typeof i=="string"){let h=c&&c[i];d=typeof h=="function"?h(n,o):h}else d=typeof i=="function"?i(n,o):i;let f=typeof a=="function"?a(n,o):a,p;if(typeof f=="string"){if(f===cy.Parent?p=e.self._parent:f===cy.Internal?p=e.self:f.startsWith("#_")?p=t.children[f.slice(2)]:p=l.deferredActorIds?.includes(f)?f:t.children[f],!p)throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f=="string"?f:void 0,event:u,id:s,delay:d},void 0]}function CU(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function EU(e,t){e.defer(()=>{let{to:n,event:o,delay:a,id:r}=t;if(typeof a=="number"){e.system.scheduler.schedule(e.self,n,o,a,r);return}e.system._relay(e.self,n,o.type===T4?N2(e.self.id,o.data):o)})}function xp(e,t,n){function o(a,r){}return o.type="xstate.sendTo",o.to=e,o.event=t,o.id=n?.id,o.delay=n?.delay,o.resolve=_U,o.retryResolve=CU,o.execute=EU,o}function o5(e,t){return xp(cy.Parent,e,t)}function TU(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(Dn(...i))},s.cancel=(...i)=>{r.push(Ac(...i))},s.raise=(...i)=>{r.push(kc(...i))},s.sendTo=(...i)=>{r.push(xp(...i))},s.sendParent=(...i)=>{r.push(o5(...i))},s.spawnChild=(...i)=>{r.push(vc(...i))},s.stopChild=(...i)=>{r.push(Si(...i))},s.emit=(...i)=>{r.push(uy(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>Li(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function Et(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=TU,t}function IU(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function MU({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function W2(e=({context:n,event:o})=>({context:n,event:o}),t){function n(o,a){}return n.type="xstate.log",n.value=e,n.label=t,n.resolve=IU,n.execute=MU,n}function RU(e,t){return new ly(e,t)}function q2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:Dn,sendTo:xp,raise:kc,log:W2,cancel:Ac,stopChild:Si,enqueueActions:Et,emit:uy,spawnChild:vc,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>RU({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>q2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var OU=()=>({mode:zE,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),ki=4,Qo=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=ki*ki},bp=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y);return{x:n,y:o,width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}},a5=q2({types:{context:{},events:{},emitted:{}},actions:{startPress:Dn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:Dn((e,t)=>({pressLast:t.point})),setDrawingType:Dn((e,t)=>({drawingType:t.kind})),resetGesture:Dn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:Dn((e,t)=>({mode:t.mode})),emitMoveElement:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||n.emit({type:"MOVE_SHAPE",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitMoveAnnotation:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||n.emit({type:"MOVE_ANNOTATION",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalPosition:e.pressTarget.origin})}),emitCommitAnnotationDrag:Et(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"||n.emit({type:"RESIZE_SHAPE",id:e.pressTarget.elementId,handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitResizeGroup:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"||n.emit({type:"RESIZE_GROUP",handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitRotate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle")return;let{pivot:o}=e.pressTarget,a=Math.atan2(e.pressOrigin.y-o.y,e.pressOrigin.x-o.x),r=Math.atan2(t.point.y-o.y,t.point.x-o.x);n.emit({type:"ROTATE",pivot:o,deltaAngle:r-a})}),maybeEmitCreate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=bp(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||n.emit({type:"DRAW_EDGE_PREVIEW",fromElement:e.pressTarget?.kind==="element"?e.pressTarget.id:null,fromPoint:e.pressOrigin,toPoint:t.point})}),emitLinkPreviewClear:Et(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind==="edge-endpoint"&&n.emit({type:"UPDATE_EDGE_ENDPOINT_PREVIEW",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point})}),emitLinkEndpointUpdate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint")return;let o=t.target,a=o?.kind==="element"?o.id:null;n.emit({type:"UPDATE_EDGE_ENDPOINT",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point,toElement:a})}),emitLassoProgress:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin)return;let o=e.pressModifiers,a=!!(o&&(o.shift||o.meta||o.ctrl));n.emit({type:"LASSO_PROGRESS",bounds:bp(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=bp(e.pressOrigin,t.point);if(o.width<1&&o.height<1){n.emit({type:"LASSO_CLEAR"});return}let a=e.pressModifiers,r=!!(a&&(a.shift||a.meta||a.ctrl));n.emit({type:"SELECT_BY_BOUNDS",bounds:o,mode:r?"add":"replace"}),n.emit({type:"LASSO_CLEAR"})}),emitCreateLink:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=t.target,a=o?.kind==="element"?o.id:null,r=e.pressTarget?.kind==="element"?e.pressTarget.id:null,s=t.point.x-e.pressOrigin.x,i=t.point.y-e.pressOrigin.y;s*s+i*i<ki*ki||n.emit({type:"CREATE_EDGE",fromElement:r,toElement:a,fromPoint:e.pressOrigin,toPoint:t.point})})},guards:{movedAndOnElement:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||e.mode!=="select"?!1:Qo(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:Qo(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:Qo(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:Qo(e.pressOrigin,t.point),movedAndDrawing:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-rect"&&e.mode!=="draw-ellipse"&&e.mode!=="draw-frame"?!1:Qo(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:Qo(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:Qo(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:Qo(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:Qo(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:OU(),on:{SET_MODE:{target:".idle",actions:[{type:"setMode",params:({event:e})=>({mode:e.mode})},{type:"resetGesture"}]}},states:{idle:{on:{POINTER_DOWN:{target:"pressing",actions:[{type:"startPress",params:({event:e})=>({point:e.point,target:e.target,modifiers:e.modifiers??null})}]}}},pressing:{on:{POINTER_MOVE:[{guard:"movedAndOnHandle",target:"draggingHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},{guard:"movedAndOnGroupHandle",target:"draggingGroupHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},{guard:"movedAndOnRotateHandle",target:"draggingRotateHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},{guard:"movedAndOnElement",target:"draggingElement",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},{guard:"movedAndDrawing",target:"drawing",actions:[{type:"setDrawingType",params:({context:e})=>({kind:e.mode==="draw-rect"?"rect":e.mode==="draw-frame"?"frame":"ellipse"})},{type:"updateLast",params:({event:e})=>({point:e.point})}]},{guard:"movedAndDrawingLink",target:"drawingLink",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},{guard:"movedAndOnLinkEndpoint",target:"draggingLinkEndpoint",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},{guard:"movedAndOnAnnotation",target:"draggingAnnotation",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},{guard:"movedAndLasso",target:"lassoing",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]}],POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingElement:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingGroupHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingRotateHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]},POINTER_UP:{target:"idle",actions:[{type:"maybeEmitCreate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawingLink:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCreateLink"},{type:"emitLinkPreviewClear"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLinkPreviewClear"},{type:"resetGesture"}]}}},draggingLinkEndpoint:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLinkEndpointUpdate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingAnnotation:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCommitAnnotationDrag"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},lassoing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]}}}}}),r5=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||Qo(e.pressOrigin,t)||e.mode==="draw-edge")return null;if(e.pressTarget.kind==="element"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_REPLACE",id:e.pressTarget.id}}if(e.pressTarget.kind==="link"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_EDGE_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_EDGE_REPLACE",id:e.pressTarget.id}}return e.pressTarget.kind==="empty"&&e.mode==="select"?{type:"SELECT_CLEAR"}:null};var s5=new Map,ro=(e,t)=>{s5.set(e,t)},Jr=e=>s5.get(e);var wi=["background","main","overlay"];var i5=(e,t)=>{let n=new Map,o=r=>{e.setOpacity(r*t)},a={get(r,s){if(s==="setOpacity")return o;if(n.has(s))return n.get(s);let i=Reflect.get(r,s),l=typeof i=="function"?i.bind(r):i;return n.set(s,l),l}};return new Proxy(e,a)};var es=class{entries=new Map;get(t){let n=this.entries.get(t.id);if(n){if(n.ref!==t){this.entries.delete(t.id);return}return n.value}}set(t,n){return this.entries.set(t.id,{ref:t,value:n}),n}getOrCompute(t,n){let o=this.get(t);return o!==void 0?o:this.set(t,n(t))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.elements.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},DU=new es,_c=(e,t)=>e.getOrCompute(t,z);var j2={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var dy={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var V2={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var _i={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var Z2={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var X2={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var Y2={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var Cc={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var Ci={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var K2={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var Va={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var $2={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var Ec={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var Tc={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var ts=["tomato","amber","grass","cyan","iris","plum","gray"],Ap=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},fn=(e,t)=>({fill:Ap(e,`${t}4`),solid:Ap(e,`${t}9`),solidHover:Ap(e,`${t}10`),textLow:Ap(e,`${t}11`),textHigh:Ap(e,`${t}12`)}),Ic={light:{tomato:fn(Ci,"tomato"),amber:fn(Tc,"amber"),grass:fn(Ec,"grass"),cyan:fn($2,"cyan"),iris:fn(Va,"iris"),plum:fn(K2,"plum"),gray:fn(Cc,"gray")},dark:{tomato:fn(dy,"tomato"),amber:fn(Y2,"amber"),grass:fn(X2,"grass"),cyan:fn(Z2,"cyan"),iris:fn(_i,"iris"),plum:fn(V2,"plum"),gray:fn(j2,"gray")}},fy={light:{tomato:Ci.tomato2,amber:Tc.amber2,grass:Ec.grass2,cyan:$2.cyan2,iris:Va.iris2,plum:K2.plum2,gray:Cc.gray2},dark:{tomato:dy.tomato2,amber:Y2.amber2,grass:X2.grass2,cyan:Z2.cyan2,iris:_i.iris2,plum:V2.plum2,gray:j2.gray2}};var PU={light:{accent:Va.iris9,accentHover:Va.iris10,selectedBg:Va.iris4,selectedFg:Va.iris11,danger:Ci.tomato9},dark:{accent:_i.iris9,accentHover:_i.iris10,selectedBg:_i.iris4,selectedFg:_i.iris11,danger:dy.tomato9}},Q2=Cc.gray6,J2=Cc.gray9,ns={rectangle:{fill:Va.iris3,stroke:Va.iris9,strokeWidth:2},ellipse:{fill:Ci.tomato3,stroke:Ci.tomato9,strokeWidth:2},flowchart:{fill:Ec.grass3,stroke:Ec.grass9,strokeWidth:2},sticky:{fill:Tc.amber3,stroke:Tc.amber9,strokeWidth:1}},Mc={stroke:Cc.gray12,strokeWidth:1.5},BU={added:Ec.grass9,removed:Ci.tomato9,modified:Tc.amber9};var ev={placeholder:.15,hideText:.4},tv="#bbb";var nv=.06,ov=.92,av=.5,Rc=10,rv=Q2,sv=J2,iv=1,lv=1,cv=4,uv=4,dv=3,fv=12,pv=56,hv=10,mv=20,l5=.4,c5=.5,yv=.1,gv=.9,u5="#888",d5="#ffffff",f5="#222",p5="#ddd",h5=18,m5=12,y5="#444",g5="#222",x5=10,xv="#000",b5=.5,A5=12,v5="#222",S5="#fff";var vp=class{cap;onEvict;map=new Map;constructor(t,n){this.cap=t,this.onEvict=n}get(t){let n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}has(t){return this.map.has(t)}set(t,n){for(this.map.delete(t),this.map.set(t,n);this.map.size>this.cap;){let o=this.map.keys().next().value,a=this.map.get(o);this.map.delete(o),a!==void 0&&this.onEvict?.(o,a)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var py=e=>e<=0?1:2**Math.round(Math.log2(e));var Za=(e,t,n={})=>{let o=oo(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let T=[N.applyToPoint(o,{x:a.x,y:a.y}),N.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],w=V.expand(V.fromPoints(T),2);t.clear(w)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new es,s=n.viewport,i=null;s&&n.spatialIndex&&(i=n.spatialIndex.query(s));let l=e.viewport.zoom,c=n.clock,u=c?{zoom:l,clock:c}:{zoom:l},d=n.lod,f=d?.placeholder!==void 0&&l<d.placeholder,p=d?.hideText!==void 0&&l<d.hideText,h=n.placeholderFill??tv,m=n.layerCompositeCache,x=n.dirtyLayerIds,y=n.compositeLayerBitmap,g=py(l),b=T=>{let w=null;for(let S of Ua(e,T)){let L=_c(r,S);w=w?V.union(w,L):L}return w},A=n.dimOpacity,_=n.dimElements!==void 0&&A!==void 0?i5(t,A):null;for(let T of vo(e))if(T.visible){if(m&&y){x?.has(T.id)&&m.invalidateLayer(T.id);let w=m.get(T.id,g);if(w===void 0){let S=y(T.id,g,e);S!==null&&(m.set(T.id,g,S),w=S)}if(w!==void 0){let S=b(T.id);S&&t.drawImage(w,S.x,S.y,S.width,S.height);continue}}for(let w of Ua(e,T.id)){if(n.hideElements?.has(w.id)||i&&!i.has(w.id))continue;if(s){let B=_c(r,w);if(!V.intersects(B,s))continue}if(a){let B=_c(r,w);if(!V.intersects(B,a))continue}if(p&&fe(w))continue;if(f){let B=_c(r,w);t.setFill(h),t.setStrokeWidth(0),t.beginPath(),t.rect(B.x,B.y,B.width,B.height),t.fill();continue}let S=Jr(w.type);if(!S){n.onUnknownElement?.(w);continue}t.save();let L=_!==null&&n.dimElements?.has(w.id)===!0,M=L?_:t;L&&M.setOpacity(1),M.translate(w.position.x,w.position.y),w.rotation!==0&&M.rotate(w.rotation),(w.scale.x!==1||w.scale.y!==1)&&M.scale(w.scale.x,w.scale.y),S(w,M,u),t.restore()}}t.restore()};var hy=class{entries=new Map;get(t,n){let o=this.entries.get(n.id);if(o){if(o.edge!==n||o.scene!==t){this.entries.delete(n.id);return}return o.value}}set(t,n,o){return this.entries.set(n.id,{edge:n,scene:t,value:o}),o}getOrCompute(t,n){let o=this.get(t,n);return o!==void 0?o:this.set(t,n,os(t,n))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.links.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},os=(e,t)=>{let n=cc(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let u of n)u.x<o&&(o=u.x),u.y<a&&(a=u.y),u.x>r&&(r=u.x),u.y>s&&(s=u.y);let i=t.arrowheads,l=i?.from!==void 0&&i.from!=="none"||i?.to!==void 0&&i.to!=="none",c=Math.max(2,(t.style.strokeWidth??1)/2+(l?i.size??10:0));return{x:o-c,y:a-c,width:r-o+c*2,height:s-a+c*2}},bv=new hy;var Pn=(e,t,n={})=>{t.save(),t.setTransform(oo(e.viewport));let o=n.edgeBoundsCache??bv,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=py(n.zoom??e.viewport.zoom);for(let c of vo(e))if(c.visible)for(let u of yA(e,c.id)){let d=null;if(a||r||s&&i){if(d=o.getOrCompute(e,u),d===null){n.onMissingEndpoint?.(u);continue}if(a&&!V.intersects(d,a)||r&&!V.intersects(d,r))continue}if(s&&i&&d){let f=s.get(u,l);if(f===void 0){let p=i(u,d,e,l);p!==null&&(s.set(u,l,p),f=p)}if(f!==void 0){t.drawImage(f,d.x,d.y,d.width,d.height);continue}}NU(e,u,t,n)}t.restore()},NU=(e,t,n,o)=>{let a=ot(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}if(n.save(),(t.lineKind??"line")==="block-arrow")zU(t,a,n);else{UU(t,n);let r=(t.routing??"straight")==="bezier"?jf(e,t):null;if(n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let s of r.segments)n.bezierCurveTo(s.c1.x,s.c1.y,s.c2.x,s.c2.y,s.to.x,s.to.y)}else if(a.length>=3&&Rc>0)my(n,a,Rc);else{let s=v(a[0]);n.moveTo(s.x,s.y);for(let i=1;i<a.length;i++){let l=v(a[i]);n.lineTo(l.x,l.y)}}if(n.stroke(),t.arrowheads){let s=r?Hf(r.start,r.segments):a;GU(s,t.arrowheads,n,t.style.stroke??xv)}}t.label&&WU(a,t.label,n),n.restore()},zU=(e,t,n)=>{let o=e.blockArrow?.headLength??h5,a=e.blockArrow?.bodyThickness??m5,r=e.style.fill??e.style.stroke??y5,s=e.style.stroke??g5,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=FU(t,o);if(l.length<2)return;let c=L5(l,a/2),u=L5(l,-a/2),d=v(c[c.length-1]),f=v(u[u.length-1]),p=v(t[t.length-1]);n.setFill(r),n.setStroke(s),n.setStrokeWidth(i),n.beginPath();let h=v(c[0]);n.moveTo(h.x,h.y);for(let g=1;g<c.length;g++){let b=v(c[g]);n.lineTo(b.x,b.y)}let m=Math.max(0,a*.5),x=k5(d,p,m),y=k5(f,p,-m);n.lineTo(x.x,x.y),n.lineTo(p.x,p.y),n.lineTo(y.x,y.y);for(let g=u.length-1;g>=0;g--){let b=v(u[g]);n.lineTo(b.x,b.y)}n.closePath(),n.fill(),i>0&&n.stroke()},FU=(e,t)=>{if(e.length<2)return e;let n=t,o=[...e].reverse(),a=[v(o[0])];for(let r=1;r<o.length;r++){let s=v(a[a.length-1]),i=v(o[r]),l=i.x-s.x,c=i.y-s.y,u=Math.hypot(l,c);if(u>n){let d=n/u,f={x:s.x+l*d,y:s.y+c*d};return a[a.length-1]=f,a.push(...o.slice(r)),a.reverse()}n-=u,a[a.length-1]=i}return e},L5=(e,t)=>{if(e.length<2)return e;let n=[];for(let o=0;o<e.length;o++){let a=v(e[Math.max(0,o-1)]),r=v(e[Math.min(e.length-1,o+1)]),s=v(e[o]),i=r.x-a.x,l=r.y-a.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;n.push({x:s.x+u*t,y:s.y+d*t})}return n},k5=(e,t,n)=>{let o=t.x-e.x,a=t.y-e.y,r=Math.hypot(o,a)||1,s=-a/r,i=o/r;return{x:e.x+s*n,y:e.y+i*n}},HU=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=Math.abs(o.y-a.y)<1e-6&&Math.abs(a.y-r.y)<1e-6,i=Math.abs(o.x-a.x)<1e-6&&Math.abs(a.x-r.x)<1e-6,l=Math.abs(o.x-a.x)<1e-6&&Math.abs(o.y-a.y)<1e-6;s||i||l||t.push(a)}return t.push(v(e[e.length-1])),t},my=(e,t,n)=>{let o=HU(t);if(o.length<3){let s=v(o[0]);e.moveTo(s.x,s.y);for(let i=1;i<o.length;i++){let l=v(o[i]);e.lineTo(l.x,l.y)}return}let a=v(o[0]);e.moveTo(a.x,a.y);for(let s=1;s<o.length-1;s++){let i=v(o[s-1]),l=v(o[s]),c=v(o[s+1]),u=Math.hypot(i.x-l.x,i.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-6||d<1e-6){e.lineTo(l.x,l.y);continue}let f=Math.min(n,u/2,d/2),p={x:l.x+(i.x-l.x)/u*f,y:l.y+(i.y-l.y)/u*f},h={x:l.x+(c.x-l.x)/d*f,y:l.y+(c.y-l.y)/d*f};e.lineTo(p.x,p.y),e.quadraticCurveTo(l.x,l.y,h.x,h.y)}let r=v(o[o.length-1]);e.lineTo(r.x,r.y)},UU=(e,t)=>{let n=e.style.stroke??xv;t.setStroke(n),t.setFill(null),t.setStrokeWidth(e.style.strokeWidth??1),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.style.lineCap!==void 0&&t.setLineCap(e.style.lineCap),e.style.lineJoin!==void 0&&t.setLineJoin(e.style.lineJoin),t.setDashArray(e.style.dashArray??null)},GU=(e,t,n,o)=>{let a=t.size??x5;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&w5(r,s,t.from,a,n,o)}if(t.to&&t.to!=="none"){let r=e[e.length-1],s=e[e.length-2];r!==void 0&&s!==void 0&&w5(r,s,t.to,a,n,o)}},w5=(e,t,n,o,a,r)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i)||1,c=s/l,u=i/l,d=-u,f=c,p=o*.5,h=y=>({x:e.x+c*y,y:e.y+u*y}),m=(y,g)=>({x:e.x+c*y+d*g,y:e.y+u*y+f*g}),x=()=>{a.setFill(r),a.fill(),a.setFill(null),a.stroke()};switch(n){case"arrow":case"openArrow":case"roundedArrow":{let y=n==="openArrow"?o*.65:p,g=n==="openArrow"?o*1.1:o;n==="roundedArrow"&&a.setLineCap("round"),a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g+d*y,e.y+u*g+f*y),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g-d*y,e.y+u*g-f*y),a.stroke(),n==="roundedArrow"&&a.setLineCap("butt");break}case"arcArrow":{let y=m(o,p),g=m(o,-p),b=h(o*.45);a.beginPath(),a.moveTo(y.x,y.y),a.lineTo(e.x,e.y),a.lineTo(g.x,g.y),a.quadraticCurveTo(b.x,b.y,y.x,y.y),a.stroke();break}case"triangle":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(m(o,-p))),a.closePath(),x();break}case"circle":case"filledCircle":{let y=p,g=h(y);a.beginPath(),a.ellipse(g.x,g.y,y,y),n==="filledCircle"?x():a.stroke();break}case"diamond":case"rhombus":case"filledRhombus":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(h(o*2))),a.lineTo(...wo(m(o,-p))),a.closePath(),n==="filledRhombus"?x():a.stroke();break}case"erdOne":case"erdOnlyOne":case"erdMany":case"erdOneOrMany":case"erdZeroOrOne":case"erdZeroOrMany":{let y=n==="erdMany"||n==="erdOneOrMany"||n==="erdZeroOrMany",g=n==="erdZeroOrOne"||n==="erdZeroOrMany",b=n==="erdOnlyOne",A=n==="erdOne"||n==="erdOnlyOne"||n==="erdOneOrMany"||n==="erdZeroOrOne";if(y){let w=h(o);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(e.x,e.y),a.moveTo(w.x,w.y),a.lineTo(...wo(m(0,p))),a.moveTo(w.x,w.y),a.lineTo(...wo(m(0,-p))),a.stroke()}let _=y?o*1.15:o*.55,T=w=>{a.beginPath(),a.moveTo(...wo(m(w,p))),a.lineTo(...wo(m(w,-p))),a.stroke()};if(A&&T(_),b&&T(_+o*.4),g){let w=p*.6,S=h(o*(y?1.6:1)+w);a.beginPath(),a.ellipse(S.x,S.y,w,w),a.stroke()}break}}},wo=e=>[e.x,e.y],WU=(e,t,n)=>{let o=t.position??b5,a=t.fontSize??A5,r=t.fill??v5,s=t.background??S5,i=qU(e,o),l=t.text.length*a*.3+4,c=a*.7;n.beginPath(),n.setFill(s),n.setStroke(null),n.rect(i.x-l,i.y-c,l*2,c*2),n.fill(),n.setFill(r),n.setFont("system-ui, sans-serif",a),n.setTextAlign("center"),n.setTextBaseline("middle"),n.fillText(t.text,i.x,i.y)},qU=(e,t)=>{if(e.length===2){let[r,s]=e;return{x:r.x+(s.x-r.x)*t,y:r.y+(s.y-r.y)*t}}let n=[],o=0;for(let r=1;r<e.length;r++){let s=v(e[r]),i=v(e[r-1]),l=s.x-i.x,c=s.y-i.y,u=Math.hypot(l,c);n.push(u),o+=u}let a=o*t;for(let r=0;r<n.length;r++){let s=v(n[r]);if(a<=s){let i=s===0?0:a/s,l=v(e[r]),c=v(e[r+1]);return{x:l.x+(c.x-l.x)*i,y:l.y+(c.y-l.y)*i}}a-=s}return v(e[e.length-1])};var _5=(e,t,n,o,a=uv,r=dv)=>{let s=[];if(e<=0||t<=0)return s;let i=e*t,l=Math.ceil(Math.log(n/i)/Math.log(a));for(let c=0;c<r;c++){let u=l+c,d=e*a**u,f=d*t,p=Math.max(0,Math.min(1,(f-n)/(o-n)));p<=0||s.push({step:d,opacity:p})}return s},Sp=(e,t,n={})=>{if(n.skipClear||t.clear(),!e.viewport.gridEnabled)return;let o=20,r=(e.viewport.gridStyle??"lines")==="dots",s=n.color??(r?sv:rv),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=XU(e,l,c);if(!u)return;let d=f=>{r?VU(t,u,f,s,i):jU(t,u,f,s,i)};if(t.save(),t.setTransform(oo(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=ZU(i,f);if(p<=0)continue;let h=f.step*o;h*i<cv||(t.setOpacity(p),d(h))}else{let f=r?hv:fv,p=r?mv:pv;for(let h of _5(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},jU=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=C5(t,n),c=iv/a;e.setStroke(o),e.setStrokeWidth(c),e.beginPath();for(let u=r;u<=s;u+=n)e.moveTo(u,i),e.lineTo(u,l);for(let u=i;u<=l;u+=n)e.moveTo(r,u),e.lineTo(s,u);e.stroke()},VU=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=C5(t,n);e.setStroke(null),e.setFill(o);let c=lv/a,u=c*2;for(let d=r;d<=s;d+=n)for(let f=i;f<=l;f+=n)e.beginPath(),e.rect(d-c,f-c,u,u),e.fill()},C5=(e,t)=>({minX:Math.floor(e.x/t)*t-t,maxX:Math.ceil((e.x+e.width)/t)*t+t,minY:Math.floor(e.y/t)*t-t,maxY:Math.ceil((e.y+e.height)/t)*t+t}),ZU=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),XU=(e,t,n)=>{let o=Wa(e.viewport),a=[N.applyToPoint(o,{x:0,y:0}),N.applyToPoint(o,{x:t,y:0}),N.applyToPoint(o,{x:t,y:n}),N.applyToPoint(o,{x:0,y:n})],r=V.fromPoints(a);return Number.isFinite(r.x)?r:null};var E5=1.2,YU=(e,t,n,o,a)=>{if(e===""){a.push({text:"",start:t,end:t,width:0});return}let r=[],s=/\S+/g,i;for(;(i=s.exec(e))!==null;)r.push({s:i.index,e:i.index+i[0].length});if(r.length===0){a.push({text:e,start:t,end:t+e.length,width:o(e)});return}let l=0,c=(d,f)=>{let p=e.slice(d,f);a.push({text:p,start:t+d,end:t+f,width:o(p)})},u=0;for(;u<r.length;){let d=v(r[u]);if(o(e.slice(l,d.e))<=n){u++;continue}if(d.s>l){c(l,d.s),l=d.s;continue}let f=d.s+1;for(;f<d.e&&o(e.slice(l,f+1))<=n;)f++;if(f>=d.e){u++;continue}c(l,f),l=f,d.s=f}c(l,e.length)},Oc=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??E5),a=[],r=0;for(let l=0;l<=e.length;l++)if(l===e.length||e[l]===`
13
- `){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):YU(c,r,n.maxWidth,t,a),r=l+1}a.length===0&&a.push({text:"",start:0,end:0,width:0});let s=0;for(let l of a)s=Math.max(s,l.width);let i=n.maxWidth??s;return{lines:a,lineHeight:o,blockWidth:i}},Av=(e,t,n)=>n==="center"?t/2-e/2:n==="right"?t-e:0,KU=(e,t)=>{let{lines:n}=e;for(let o=0;o<n.length;o++){let a=v(n[o]);if(t<=a.end)return o}return n.length-1},vv=(e,t,n,o,a)=>{let r=KU(e,t),s=v(e.lines[r]),i=Math.max(0,Math.min(t,s.end)-s.start),l=i===0?0:n(s.text.slice(0,i));return{x:Av(s.width,e.blockWidth,a)+l,y:r*e.lineHeight,height:o,line:r}},Sv=(e,t,n,o)=>{let{lines:a,lineHeight:r}=e,s=Math.max(0,Math.min(a.length-1,Math.floor(t.y/r))),i=v(a[s]),l=Av(i.width,e.blockWidth,o),c=0,u=Math.abs(l-t.x);for(let d=1;d<=i.text.length;d++){let f=l+n(i.text.slice(0,d)),p=Math.abs(f-t.x);p<u&&(u=p,c=d)}return i.start+c},Lv=(e,t,n,o,a)=>{let r=Math.min(t,n),s=Math.max(t,n);if(r===s)return[];let i=[];for(let l=0;l<e.lines.length;l++){let c=v(e.lines[l]),u=Math.max(r,c.start),d=Math.min(s,c.end);if(u>d||u===d&&!(r<=c.start&&s>c.end)&&!(s>c.end&&r<=c.end))continue;let f=Av(c.width,e.blockWidth,a),p=f+(u===c.start?0:o(c.text.slice(0,u-c.start))),h=f+(d===c.start?0:o(c.text.slice(0,d-c.start))),m=s>c.end?e.lineHeight*.25:0;i.push({x:p,y:l*e.lineHeight,width:Math.max(0,h-p)+m,height:e.lineHeight})}return i};var T5=new Map,Lp=e=>{T5.set(e.kind,e)};var kv=new Set,wv=e=>(kv.add(e),()=>kv.delete(e)),_v=()=>{for(let e of kv)try{e()}catch{}},I5=()=>typeof performance<"u"?performance.now():0,Cv=e=>{I5=e};var Ei=(e,t=I5(e))=>{if(!e.animationKind)return e.src;let n=T5.get(e.animationKind);if(!n)return e.src;try{return n.getFrameAt(e.animationData,t)}catch{return e.src}};var wp=(e,t)=>{let n=e.fill!==void 0&&e.fill!=="transparent",o=e.stroke!==void 0&&e.stroke!=="transparent"&&(e.strokeWidth??1)>0;return n&&t.setFill(e.fill),o&&(t.setStroke(e.stroke),t.setStrokeWidth(e.strokeWidth??1),e.lineCap&&t.setLineCap(e.lineCap),e.lineJoin&&t.setLineJoin(e.lineJoin),e.dashArray&&t.setDashArray(e.dashArray)),e.opacity!==void 0&&t.setOpacity(e.opacity),{fill:n,stroke:o}},$U=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t);if(!n&&!o)return;let a=Rf(e.style.roundness,e.width,e.height);if(n&&(t.beginPath(),a>0?M5(t,0,0,e.width,e.height,a):t.rect(0,0,e.width,e.height),t.fill()),o){let r=gy(e.style),s=r,i=r,l=e.width-2*r,c=e.height-2*r;if(l<=0||c<=0)return;let u=a>0?Math.max(0,a-r):0;t.beginPath(),u>0?M5(t,s,i,l,c,u):t.rect(s,i,l,c),t.stroke()}},gy=e=>{let t=e.strokeAlign??"center";if(t==="center")return 0;let n=(e.strokeWidth??1)/2;return t==="inside"?n:-n},M5=(e,t,n,o,a,r)=>{e.moveTo(t+r,n),e.lineTo(t+o-r,n),e.quadraticCurveTo(t+o,n,t+o,n+r),e.lineTo(t+o,n+a-r),e.quadraticCurveTo(t+o,n+a,t+o-r,n+a),e.lineTo(t+r,n+a),e.quadraticCurveTo(t,n+a,t,n+a-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},QU=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t);if(!n&&!o)return;let a=e.width/2,r=e.height/2;if(n&&(t.beginPath(),t.ellipse(a,r,a,r),t.fill()),o){let s=gy(e.style),i=a-s,l=r-s;if(i<=0||l<=0)return;t.beginPath(),t.ellipse(a,r,i,l),t.stroke()}},JU=(e,t)=>{if(e.points.length<2)return;let{fill:n,stroke:o}=wp(e.style,t);if(!(!n&&!o)&&(n&&(t.beginPath(),yy(t,e.points),t.fill()),o)){let a=gy(e.style),r=a!==0?Mf.offsetClosedPath(e.points,a):e.points;t.beginPath(),yy(t,r),t.stroke()}},yy=(e,t)=>{let n=t[0];if(n!==void 0){e.moveTo(n.x,n.y);for(let o=1;o<t.length;o++){let a=t[o];a!==void 0&&e.lineTo(a.x,a.y)}e.closePath()}},eG=(e,t)=>{if(e.commands.length===0)return;let{fill:n,stroke:o}=wp(e.style,t);if(!(!n&&!o)){t.beginPath();for(let a of e.commands)switch(a.kind){case"M":t.moveTo(a.to.x,a.to.y);break;case"L":t.lineTo(a.to.x,a.to.y);break;case"Q":t.quadraticCurveTo(a.control.x,a.control.y,a.to.x,a.to.y);break;case"C":t.bezierCurveTo(a.control1.x,a.control1.y,a.control2.x,a.control2.y,a.to.x,a.to.y);break;case"Z":t.closePath();break}n&&t.fill(),o&&t.stroke()}},tG=(e,t)=>{let n=e.style.textAlign??"left",o=e.fontSize;t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let a=c=>{let u=c?.fontWeight??e.style.fontWeight,d=c?.fontStyle??e.style.fontStyle;t.setFont(e.fontFamily,o,{...u?{weight:u}:{},...d?{style:d}:{}})};a(void 0);let r=Oc(e.text,c=>t.measureText(c).width,{fontSize:o,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}}),s=r.lines.map(c=>{let u=Of(e,c.start,c.end).map(f=>(a(f.style),{text:f.text,style:f.style,width:t.measureText(f.text).width})),d=u.reduce((f,p)=>f+p.width,0);return{segs:u,total:d}}),i=e.maxWidth??s.reduce((c,u)=>Math.max(c,u.total),0),l=Math.max(1,o*nv);s.forEach((c,u)=>{let d=u*r.lineHeight,f=n==="center"?i/2-c.total/2:n==="right"?i-c.total:0;for(let p of c.segs){let h=p.style?.fill??e.style.fill??"#000",m=p.style?.opacity??e.style.opacity;a(p.style),t.setFill(h),m!==void 0&&t.setOpacity(m),t.fillText(p.text,f,d);let x=p.style?.textDecoration??e.style.textDecoration;p.width>0&&(x?.underline||x?.strikethrough)&&(x.underline&&(t.beginPath(),t.rect(f,d+o*ov,p.width,l),t.fill()),x.strikethrough&&(t.beginPath(),t.rect(f,d+o*av-l/2,p.width,l),t.fill())),f+=p.width}})},nG=(e,t)=>{if(e.runs!==void 0&&e.runs.length>0){tG(e,t);return}let n=e.style.textAlign??"left",o=e.style.fontWeight,a=e.style.fontStyle;t.setFont(e.fontFamily,e.fontSize,{...o?{weight:o}:{},...a?{style:a}:{}}),t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let r=e.style.fill??"#000";t.setFill(r),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity);let s=e.fontSize,i;if(e.maxWidth===void 0&&!e.text.includes(`
14
- `))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=Oc(e.text,c,{fontSize:s,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}});i=u.lines.map((d,f)=>({text:d.text,x:n==="center"?u.blockWidth/2-d.width/2:n==="right"?u.blockWidth-d.width:0,width:d.width,top:f*u.lineHeight}))}for(let c of i)t.fillText(c.text,c.x,c.top);let l=e.style.textDecoration;if(l?.underline||l?.strikethrough){let c=Math.max(1,s*nv);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*ov,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*av-c/2,u.width,c),t.fill()))}},oG=(e,t)=>{let n=e.points;if(n.length===0)return;if(e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.closed===!0&&e.style.fill!==void 0&&n.length>=3){t.setFill(e.style.fill),t.setStroke(null),t.beginPath();let r=v(n[0]);t.moveTo(r.x,r.y);for(let s=1;s<n.length;s++){let i=v(n[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}let o=Df(e.style);if(t.setFill(o),t.setStroke(null),n.length===1){let r=v(n[0]);t.beginPath(),t.ellipse(r.x,r.y,r.width,r.width),t.fill();return}let a=Zf(n);if(a.length>=3){t.beginPath();let r=v(a[0]);t.moveTo(r.x,r.y);for(let s=1;s<a.length;s++){let i=v(a[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}},aG=(e,t,n)=>{let o=n?.clock?.(e),a=e.animationKind?Ei(e,o):e.metadata?.image??Ei(e,o),r=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(a,0,0,e.width,e.height,r,e.crop)},Dc=()=>{ro("rectangle",$U),ro("ellipse",QU),ro("polygon",JU),ro("path",eG),ro("text",nG),ro("image",aG),ro("group",()=>{}),ro("frame",lG),RA("frame",()=>({top:24})),ro("block-arrow",rG),ro("brush",oG)},rG=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t),a=e.direction??"right",r=Math.max(yv,Math.min(gv,e.headRatio??l5)),s=Math.max(yv,Math.min(gv,e.bodyThickness??c5)),i=e.width,l=e.height,c=i*r,u=i-c,d=l*s/2,f=l/2,p=[[0,f-d],[u,f-d],[u,0],[i,f],[u,l],[u,f+d],[0,f+d]];a!=="right"&&(p=p.map(([m,x])=>sG([m,x],a,i,l)));let h=p.map(([m,x])=>({x:m,y:x}));if(n&&(t.beginPath(),yy(t,h),t.fill()),o){let m=gy(e.style),x=m!==0?Mf.offsetClosedPath(h,m):h;t.beginPath(),yy(t,x),t.stroke()}},sG=([e,t],n,o,a)=>{switch(n){case"left":return[o-e,t];case"up":return[t*(o/a),a-e*(a/o)];case"down":return[(a-t)*(o/a),e*(a/o)]}},Ev="\u2026",iG=(e,t,n)=>{if(t<=0)return"";if(n.measureText(e).width<=t)return e;let o=0,a=e.length;for(;o<a;){let r=Math.ceil((o+a)/2);n.measureText(e.slice(0,r)+Ev).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+Ev:Ev},lG=(e,t,n)=>{t.setFill(e.style.fill??d5),t.setStroke(null),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.fill();let o=(n?.zoom??1)*(e.scale.x||1);t.setFill(null),t.setStroke(u5),t.setStrokeWidth(1/(o||1)),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.stroke();let a=e.name??"Frame";t.setFont("system-ui, sans-serif",12);let r=e.width-16,s=t.measureText(a).width<=r,i=s?a:iG(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(f5),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(p5),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var R5=async(e,t)=>{if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if(e instanceof Response)return e.arrayBuffer();let n=typeof e=="string"?e:e.href;if(n.startsWith("file:")){let{readFile:a}=await import("node:fs/promises"),{fileURLToPath:r}=await import("node:url"),s=r(n),i=await a(s);return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await fetch(e);if(!o.ok)throw new Error(`${t}: fetch failed (${o.status})`);return o.arrayBuffer()},_p=async(e,t)=>{if(typeof WebAssembly.instantiateStreaming=="function"&&(e instanceof Response||(typeof e=="string"||e instanceof URL)&&!String(e).startsWith("file:")))try{let r=e instanceof Response?e.clone():await fetch(e),{instance:s}=await WebAssembly.instantiateStreaming(r,{});return s}catch{}let o=await R5(e,t),{instance:a}=await WebAssembly.instantiate(o,{});return a},as=(e,t)=>{let n=t.byteLength,o=e.alloc(n);return new Uint8Array(e.memory.buffer,o,n).set(t),{ptr:o,len:n,free:()=>{e.free(o,n)}}};var O5=null,Cp=e=>{O5=e},Iv=()=>O5;var D5=null,Ep=e=>{D5=e},xy=()=>D5;var by={flatten(e,t){let n=r=>Math.min(128,Math.max(8,Math.ceil(r/Math.max(.1,t)))),o=[],a={x:0,y:0};for(let r of e)switch(r.kind){case"M":a=r.to,o.push(a);break;case"L":a=r.to,o.push(a);break;case"Q":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenQuadratic(a,r.control,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"C":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenCubic(a,r.control1,r.control2,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"Z":if(o.length>0){let s=v(o[0]);o.push(s),a=s}break}return o},strokeToFill(e,t,n){if(e.length<2)return e;let o=t/2,a=n?.cap??"butt";n?.join;let r=[],s=[];for(let i=0;i<e.length;i++){let l=v(e[Math.max(0,i-1)]),c=v(e[Math.min(e.length-1,i+1)]),u=v(e[i]),d=c.x-l.x,f=c.y-l.y,p=Math.hypot(d,f)||1,h=-f/p,m=d/p;r.push({x:u.x+h*o,y:u.y+m*o}),s.push({x:u.x-h*o,y:u.y-m*o})}return[...r,...s.reverse(),v(r[0])]}};var Ay=(e,t,n)=>{if(e.length<3)return e;let o=Ff(e.map(i=>({x:i.x,y:i.y}))),a=v(e[0]),r=[a],s={x:a.x,y:a.y};for(let i=0;i<o.length;i++){let l=v(o[i]),c=v(e[i]),u=v(e[i+1]);for(let d=1;d<=t;d++){let f=d/t,p=cn.cubicAt(s,l.c1,l.c2,l.to,f);r.push(n(c,u,p,f))}s=l.to}return r};var vy=(e,t)=>({points:[{x:e.x,y:e.y,t}]}),Mv=(e,t,n)=>{e.points.push({x:t.x,y:t.y,t:n})},Rv=(e,t,n=X0)=>{let o=!1,a=[];for(let r of e){let s=r.points.filter(i=>t-i.t<n);if(s.length===r.points.length){a.push(r);continue}o=!0,s.length>0&&a.push({points:s})}return o?{strokes:a,changed:o}:{strokes:e,changed:o}},P5=(e,t=WI)=>Ay(e,t,(n,o,a,r)=>({x:a.x,y:a.y,t:n.t+(o.t-n.t)*r}));var Ti=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",cG=new Set(["rectangle","ellipse","template","text","frame"]),Ii=e=>cG.has(e.type),Ov=e=>mi;var _o=(e,t)=>{let n=So(e),a=[..._0(e).keys()].filter(s=>!n.has(s)),r=a.map(s=>{let i={kind:"named",name:s},l=Yt(e,i);if(t===0)return l;let c=jo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var z5=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let l=t.scene.annotations.get(o);if(l)return{kind:"annotation",id:o,origin:Kr(t.scene,l)}}let a=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(a){let l=t.combinedSelectionBounds();if(l){let u=t.selectionIsAspectLocked()?yi:mi,d=_2(e,l,n,t.handleHitSlop,u);if(d)return{kind:"group-handle",handle:d,bounds:l}}}if(t.selection.size===1)for(let l of t.selection){let c=I(t.scene,l);if(!c||!Ii(c)||c.locked===!0)continue;let u=xi(c),d=v4(e,u,n,t.handleHitSlop,Ov(c));if(d)return{kind:"handle",elementId:l,handle:d,bounds:u.bounds}}let r=a?t.combinedSelectionBounds():null;if(r){let l=Q0(r,n);if(C2(e,l,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:r.x+r.width/2,y:r.y+r.height/2},bounds:r}}else if(t.selection.size===1)for(let l of t.selection){let c=I(t.scene,l);if(!c||!Ii(c)||c.locked===!0)continue;let u=$0(c,n);if(C2(e,u,n,t.handleHitSlop)){let d=xi(c);return{kind:"rotate-handle",pivot:b4(d),bounds:d.bounds}}}if(t.selectedLink){let l=be(t.scene,t.selectedLink);if(l){let c=ot(t.scene,l);if(c&&c.length>=2){let u=t.edgeHandleHitSlop/n,d=v(c[0]),f=v(c[c.length-1]);if(U.distance(e,d)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"from"};if(U.distance(e,f)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"to"}}}}let s=t.acceleratedElementAt(e);if(s&&t.isElementInteractable(s)){let l=t.promoteToGroupRoot(s);return{kind:"element",id:l.id,bounds:z(l)}}let i=MA(t.scene,e,t.edgeHitThreshold/n);return i&&!t.isLayerLocked(i.layerId)?{kind:"link",id:i.id}:{kind:"empty"}},Tp=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(hc),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.rect(t,n,o,a),e.stroke()},Mi=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(hc),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},uG=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(ap),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},B5=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(hc),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.fill(),e.setFill(null),e.setStroke(n),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.stroke()},N5=(e,t,n,o,a,r)=>{let s=N.applyToPoint(t,{x:n.x,y:n.y}),i=N.applyToPoint(t,{x:n.x+n.width,y:n.y+n.height}),l=Math.min(s.x,i.x),c=Math.min(s.y,i.y),u=Math.abs(i.x-s.x),d=Math.abs(i.y-s.y),f=11;for(let p of a)switch(p){case"nw":case"ne":case"se":case"sw":{let h=N.applyToPoint(t,gi(p,n,o));Tp(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Tp(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Tp(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Tp(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Tp(e,l+u-f,c-f,f*2,d+f*2,r);break}},Sy=e=>{let t={resizeHandles:!1,linkBodies:!1,selectedEdgeHandles:!1,anchorDots:!1,attachDropZones:!1,containerDropZones:!1,groupHandles:!1,annotationPins:!1};return e.linkDragActive?{...t,attachDropZones:!0}:e.elementDragActive?{...t,containerDropZones:!0}:{...t,resizeHandles:!0,linkBodies:!0,selectedEdgeHandles:!0,anchorDots:!0,groupHandles:!0,annotationPins:!0}},F5=(e,t)=>{let{scene:n,w2s:o,zoom:a,selection:r,visibility:s,edgeSelection:i,attach:l,containers:c}=t,{groupBounds:u,groupAspectLocked:d}=t;if(e.save(),s.resizeHandles&&r.size===1){let f=v([...r][0]),p=I(n,f);p&&Ii(p)&&p.locked!==!0&&N5(e,o,z(p),a,Ov(p),c2)}if(s.linkBodies)for(let f of n.links.values()){let p=ot(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(nI),e.setStrokeWidth(F0*2),e.setOpacity(hc),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=N.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=N.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=N.applyToPoint(o,i.from),p=N.applyToPoint(o,i.to);Mi(e,f.x,f.y,Zo,rp),Mi(e,p.x,p.y,Zo,rp);for(let h of i.waypoints??[]){let m=N.applyToPoint(o,h);Mi(e,m.x,m.y,Zo,rp)}for(let h of i.midpoints??[]){let m=N.applyToPoint(o,h);Mi(e,m.x,m.y,Zo,rp)}}if(s.anchorDots&&r.size===1){let f=v([...r][0]),p=I(n,f);if(p){let h=Xo+H0,{worldPoints:m}=_o(p,Lo/a);for(let x of m){let y=N.applyToPoint(o,x);Mi(e,y.x,y.y,h,u2),uG(e,y.x,y.y,U0,u2)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)B5(e,p.map(h=>N.applyToPoint(o,h)),rI);e.setFill(null),e.setStroke(aI),e.setStrokeWidth(f*2),e.setOpacity(hc),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=N.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=N.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=N.applyToPoint(o,p);Mi(e,h.x,h.y,f,oI)}}if(s.containerDropZones&&c){let f=(p,h)=>{let m=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}].map(x=>N.applyToPoint(o,x));B5(e,m,h)};for(let p of c.frames)f(p,sI);for(let p of c.containers)f(p,iI)}if(s.groupHandles&&u&&N5(e,o,u,a,d?yi:mi,c2),s.annotationPins)for(let f of n.annotations.values()){let p=N.applyToPoint(o,Kr(n,f));Mi(e,p.x,p.y,j0,lI)}e.setOpacity(1),e.restore()};var G5=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?G5(e,o.id):z(o);a&&(n=n?V.union(n,a):a)}return n},W5={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},q5=.32,j5=(e,t,n,o,a=W5)=>{if(n.length===0)return;let s=r2/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(q5),e.setDashArray(null),e.setLineJoin("miter"),e.setLineCap("butt");for(let{loops:i,outsetWorld:l}of n){e.setStrokeWidth(2*(l+s));for(let c of i){if(c.length<2)continue;e.beginPath();let u=!1;for(let d of c)u?e.lineTo(d.x,d.y):(e.moveTo(d.x,d.y),u=!0);e.closePath(),e.stroke()}}e.setOpacity(1),e.setTransform(N.IDENTITY)},V5=(e,t,n,o={})=>{let a={...W5,...o.style};n.clear();let r=oo(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(N.IDENTITY);let i={scene:e,selection:t,target:n,options:o,style:a,w2s:r,zoom:s};pG(i),hG(i),mG(i),yG(i),gG(i),xG(i),bG(i),vG(i),SG(i),LG(i),kG(i),wG(i),_G(i),CG(i),n.restore()},pG=e=>{let{scene:t,selection:n,target:o,options:a,w2s:r,zoom:s}=e;a.debugHitZones&&F5(o,{scene:t,w2s:r,zoom:s,selection:n,visibility:a.debugHitZoneVisibility??Sy({linkDragActive:!1,elementDragActive:!1}),...a.edgeSelection?{edgeSelection:a.edgeSelection}:{},...a.debugAttachZones?{attach:a.debugAttachZones}:{},...a.debugContainerZones?{containers:a.debugContainerZones}:{},...a.groupBounds?{groupBounds:a.groupBounds}:{},...a.groupAspectLocked!==void 0?{groupAspectLocked:a.groupAspectLocked}:{}})},hG=e=>{let{scene:t,selection:n,target:o,options:a,style:r,w2s:s,zoom:i}=e;if(a.cropFrame)return;let l=n.size>1;for(let c of n){let u=t.elements.get(c);if(!u)continue;if(ze(u)){let f=G5(t,c);if(!f)continue;let p=Jo(f,s);if(Pv(o,p,r),u.locked===!0){U5(o,p);continue}if(l||!Ii(u)||a.readOnly===!0)continue;for(let h of yi){let m=gi(h,f,i);Bv(o,N.applyToPoint(s,m),r)}X5(o,f,i,s,r);continue}let d=xi(u);if(d.rotation===0?Pv(o,Jo(d.bounds,s),r):TG(o,d,s,r),u.locked===!0){U5(o,IG(d,s));continue}if(!(l||!Ii(u)||a.readOnly===!0)){for(let f of yi){let p=A4(f,d,i);Bv(o,N.applyToPoint(s,p),r)}Z5(o,N.applyToPoint(s,$0(u,i)),r)}}},mG=e=>{let{target:t,options:n,style:o,w2s:a}=e;if(n.cropGhost&&PG(t,n.cropGhost,a),n.cropFrame&&n.cropFrame.length>=4){let r=n.cropFrame.map(s=>N.applyToPoint(a,s));OG(t,r,o),DG(t,r,o)}if(n.drawingPreview){let r=Jo(n.drawingPreview,a);MG(t,r,o)}if(n.drawingPreviewElement){let r=n.drawingPreviewElement,s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(AI),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.flowchartPreviewElements&&n.flowchartPreviewElements.length>0)for(let r of n.flowchartPreviewElements){let s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(K0),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.strokeErasePreviewElements&&n.strokeErasePreviewElements.length>0)for(let r of n.strokeErasePreviewElements){let s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(1),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.edgePreview){let r=n.edgePreview.points;if(r&&r.length>=2)BG(t,r.map(s=>N.applyToPoint(a,s)),o);else{let s=N.applyToPoint(a,n.edgePreview.from),i=N.applyToPoint(a,n.edgePreview.to);RG(t,s,i,o)}}if(n.ghostElement||n.ghostElementShape){t.setOpacity(q0);let r=n.ghostElementShape,s=r?Jr(r.type):void 0;if(r&&s)t.save(),t.setTransform(a),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore();else if(n.ghostElement){let i=Jo(n.ghostElement,a);t.setStroke(o.selectionStroke),t.setStrokeWidth(1.5),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.stroke()}t.setOpacity(1)}if(n.linkAttachHighlight){let r=Jo(n.linkAttachHighlight,a),s=2;t.setStroke(o.selectionStroke),t.setStrokeWidth(2),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(r.x-s,r.y-s,r.width+s*2,r.height+s*2),t.stroke()}},yG=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(n.ports){let s=Array.isArray(n.ports)?n.ports:[n.ports];for(let i of s)for(let l=0;l<i.worldPoints.length;l++){let c=N.applyToPoint(a,v(i.worldPoints[l])),u=i.activeIndex===l;NG(t,c,u,i.role,u?i.activeRadius:void 0)}}if(n.selectedLinkPaths&&n.selectedLinkPaths.length>0){t.setTransform(a),t.setStroke(o.selectionStroke),t.setOpacity(q5),t.setDashArray(null),t.setLineJoin("round"),t.setLineCap("round");let s=r2/(r||1);for(let{path:i,width:l}of n.selectedLinkPaths)i.length<2||(t.setStrokeWidth(l+2*s),t.beginPath(),my(t,i,Rc),t.stroke());t.setOpacity(1),t.setLineJoin("miter"),t.setLineCap("butt"),t.setTransform(N.IDENTITY)}if(n.edgeSelection&&n.readOnly!==!0){let s=N.applyToPoint(a,n.edgeSelection.from),i=N.applyToPoint(a,n.edgeSelection.to);for(let l of n.edgeSelection.midpoints??[])zG(t,N.applyToPoint(a,l),o);Dv(t,s,o),Dv(t,i,o);for(let l of n.edgeSelection.waypoints??[])Dv(t,N.applyToPoint(a,l),o)}},gG=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerSelections)for(let a of n.peerSelections)for(let r of a.bounds){let s=Jo(r,o);FG(t,s,a.color)}},xG=e=>{let{target:t,options:n,w2s:o}=e;if(n.brushPreview&&n.brushPreview.points.length>0){let a=n.brushPreview;t.save(),t.setTransform(o),t.setOpacity(a.opacity),t.setFill(a.fill),t.setStroke(null);let r=a.points,s=a.origin.x,i=a.origin.y;if(r.length===1){let l=v(r[0]);t.beginPath(),t.ellipse(s+l.x,i+l.y,l.width,l.width),t.fill()}else{let l=Zf(r);if(l.length>=3){t.beginPath();let c=v(l[0]);t.moveTo(s+c.x,i+c.y);for(let u=1;u<l.length;u++){let d=v(l[u]);t.lineTo(s+d.x,i+d.y)}t.closePath(),t.fill()}}t.restore()}},bG=e=>{let{target:t,options:n,w2s:o}=e;H5(t,o,n.laserStrokes,GI,S2,X0);let a=(n.eraserCursor?.radius??S2/2)*2;H5(t,o,n.eraserTrail,V0,a,Z0)},H5=(e,t,n,o,a,r)=>{if(!n||n.length===0)return;let s=typeof performance<"u"?performance.now():Date.now(),i=a/2;e.setStroke(null),e.setDashArray(null),e.setFill(o);for(let l of n){let c=P5(l.points);if(c.length===0)continue;let u=v(c[c.length-1]),d=1-(s-u.t)/r;if(d<=0)continue;e.setOpacity(d);let f=c.map(m=>N.applyToPoint(t,{x:m.x,y:m.y}));if(f.length===1){let m=v(f[0]);e.beginPath(),e.ellipse(m.x,m.y,i,i),e.fill();continue}let p=AG(f,i),h=v(p[0]);e.beginPath(),e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=v(p[m]);e.lineTo(x.x,x.y)}e.closePath(),e.fill()}e.setOpacity(1)},AG=(e,t)=>{let n=e.length,o=[],a=[];for(let r=0;r<n;r++){let s=v(e[r]),i=v(e[Math.max(0,r-1)]),l=v(e[Math.min(n-1,r+1)]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u)||1;c/=d,u/=d;let f=t*(n>1?r/(n-1):1),p=-u*f,h=c*f;o.push({x:s.x+p,y:s.y+h}),a.push({x:s.x-p,y:s.y-h})}return a.reverse(),[...o,...a]},vG=e=>{let{target:t,options:n,w2s:o}=e,a=n.eraserCursor;if(!a||a.radius<=0)return;let r=N.applyToPoint(o,a.center);t.setDashArray(null),t.setOpacity(1),t.beginPath(),t.ellipse(r.x,r.y,a.radius,a.radius),t.setFill(V0),t.fill(),t.setFill(null),t.setStroke(V0),t.setStrokeWidth(NI),t.stroke()},SG=e=>{let{target:t,options:n,w2s:o}=e;if(n.containerDropZone){let a=Jo(n.containerDropZone,o);t.setFill("rgba(26, 115, 232, 0.10)"),t.setStroke("#1a73e8"),t.setStrokeWidth(2),t.setDashArray([6,3]),t.beginPath(),t.rect(a.x,a.y,a.width,a.height),t.fill(),t.stroke(),t.setDashArray(null)}},LG=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(!n.cropFrame&&n.groupBounds){let s=Jo(n.groupBounds,a);if(Pv(t,s,o),n.readOnly===!0)return;let i=yi;for(let l of i){let c=gi(l,n.groupBounds,r),u=N.applyToPoint(a,c);Bv(t,u,o)}X5(t,n.groupBounds,r,a,o)}},kG=e=>{let{scene:t,target:n,options:o,w2s:a}=e;if(o.annotations&&o.annotations.length>0)for(let r of o.annotations){let s=Kr(t,r),i=N.applyToPoint(a,s);UG(n,i,r,o.selectedAnnotation??null)}},wG=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerCursors)for(let a of n.peerCursors){let r=N.applyToPoint(o,a.position);HG(t,r,a.color,a.name)}},_G=e=>{let{target:t,options:n,w2s:o}=e;if(n.gifBadges)for(let a of n.gifBadges)EG(t,Jo(a,o))},CG=e=>{let{target:t,options:n,w2s:o,zoom:a}=e;if(n.editingText){let r=n.editingText;if(r.selectionRects.length>0){t.setFill(n4),t.setOpacity(o4);for(let s of r.selectionRects){let i=Jo(s,o);t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fill()}t.setOpacity(1)}if(r.caret){let s=N.applyToPoint(o,{x:r.caret.x,y:r.caret.y});t.setFill(r.caretColor),t.setOpacity(1),t.beginPath(),t.rect(s.x,s.y,a4,r.caret.height*a),t.fill()}}},U5=(e,t)=>{let n=d4,o=t.x+t.width-n-2,a=t.y+2,r=f4;e.setStroke(r),e.setFill(null),e.setStrokeWidth(2),e.setDashArray(null),e.setOpacity(1),e.beginPath(),e.ellipse(o+n/2,a+n*.46,n*.22,n*.26),e.stroke(),e.setStroke(null),e.setFill(r),e.beginPath(),e.rect(o+n*.2,a+n*.44,n*.6,n*.48),e.fill(),e.setFill(p4),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},EG=(e,t)=>{let n=t.x+w2,o=t.y+w2,a=i4,r=l4,s=c4;e.setStroke(null),e.setFill(u4),e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+a-s,o),e.quadraticCurveTo(n+a,o,n+a,o+s),e.lineTo(n+a,o+r-s),e.quadraticCurveTo(n+a,o+r,n+a-s,o+r),e.lineTo(n+s,o+r),e.quadraticCurveTo(n,o+r,n,o+r-s),e.lineTo(n,o+s),e.quadraticCurveTo(n,o,n+s,o),e.closePath(),e.fill(),e.setFill("#ffffff"),e.setFont("system-ui, sans-serif",10),e.setTextAlign("center"),e.setTextBaseline("middle"),e.fillText("gif",n+a/2,o+r/2)},Jo=(e,t)=>{let n=N.applyToPoint(t,{x:e.x,y:e.y}),o=N.applyToPoint(t,{x:e.x+e.width,y:e.y+e.height}),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y);return{x:a,y:r,width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)}},Pv=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(n.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},TG=(e,t,n,o)=>{let[a,r,s,i]=cp(t),l=N.applyToPoint(n,a),c=N.applyToPoint(n,r),u=N.applyToPoint(n,s),d=N.applyToPoint(n,i);e.setStroke(o.selectionStroke),e.setStrokeWidth(o.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.stroke()},IG=(e,t)=>{let n=cp(e).map(i=>N.applyToPoint(t,i)),o=1/0,a=1/0,r=-1/0,s=-1/0;for(let i of n)i.x<o&&(o=i.x),i.y<a&&(a=i.y),i.x>r&&(r=i.x),i.y>s&&(s=i.y);return{x:o,y:a,width:r-o,height:s-a}},Ly=(e,t,n,o)=>{o.opacity!==void 0&&e.setOpacity(o.opacity),e.setStroke(o.stroke),e.setStrokeWidth(o.strokeWidth),e.setDashArray(null),e.setFill(o.fill),e.beginPath(),e.ellipse(t.x,t.y,n,n),e.fill(),e.stroke(),o.opacity!==void 0&&e.setOpacity(1)},Bv=(e,t,n)=>{Ly(e,t,5,{fill:n.handleFill,stroke:n.handleStroke,strokeWidth:1})},Z5=(e,t,n)=>{let o=7/9,a=(u,d)=>({x:t.x+(u-12)*o,y:t.y+(d-12)*o});e.setStroke(n.handleStroke),e.setFill(null),e.setStrokeWidth(2*o),e.setLineCap("round"),e.setLineJoin("round"),e.setDashArray(null);let r=336,s=30;e.beginPath();for(let u=0;u<=s;u++){let d=r*u/s*(Math.PI/180),f=a(12+9*Math.cos(d),12+9*Math.sin(d));u===0?e.moveTo(f.x,f.y):e.lineTo(f.x,f.y)}e.stroke();let i=a(21,3),l=a(21,8),c=a(16,8);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.stroke(),e.setLineCap("butt"),e.setLineJoin("miter")},X5=(e,t,n,o,a)=>{let r=Q0(t,n);Z5(e,N.applyToPoint(o,r),a)},MG=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1),e.setDashArray(n.drawingDash),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},RG=(e,t,n,o)=>{e.setStroke(o.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(o.drawingDash),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.stroke()},OG=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.lineTo(o.x,o.y),e.stroke(),e.setDashArray(null)},DG=(e,t,n)=>{if(t.length<4)return;e.setStroke(n.selectionStroke),e.setStrokeWidth(g4),e.setDashArray(null),e.setLineCap("round"),e.setLineJoin("round");let o=(a,r)=>{let s=r.x-a.x,i=r.y-a.y,l=Math.hypot(s,i)||1,c=Math.min(y4,l)/l;return{x:a.x+s*c,y:a.y+i*c}};for(let a=0;a<4;a++){let r=v(t[a]),s=v(t[(a+3)%4]),i=v(t[(a+1)%4]),l=o(r,s),c=o(r,i);e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(r.x,r.y),e.lineTo(c.x,c.y),e.stroke()}e.setLineCap("butt"),e.setLineJoin("miter")},PG=(e,t,n)=>{let o=t.element,a=o.animationKind!==void 0?Ei(o,void 0):o.metadata?.image??Ei(o,void 0);if(a==null)return;let r=o.metadata?.animated===!0||o.animationKind!==void 0,{fullRect:s}=t;e.save(),e.setTransform(n),e.setDashArray(null),e.translate(o.position.x,o.position.y),o.rotation!==0&&e.rotate(o.rotation),(o.scale.x!==1||o.scale.y!==1)&&e.scale(o.scale.x,o.scale.y),e.setOpacity(m4),e.drawImage(a,s.x,s.y,s.width,s.height,r),e.setOpacity(1),e.restore()},BG=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.stroke()},NG=(e,t,n,o="link-start",a)=>{let r=n?a??Xo:op,s=o==="link-start";Ly(e,t,r,{fill:n?s?s2:i2:s?$T:QT,stroke:s?s2:i2,strokeWidth:KT})},Dv=(e,t,n)=>{Ly(e,t,qT,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:2})},zG=(e,t,n)=>{Ly(e,t,jT,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:1.5,opacity:.55})},FG=(e,t,n)=>{let o=fI;e.setStroke(n),e.setStrokeWidth(uI),e.setDashArray(dI),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},HG=(e,t,n,o)=>{let a=cI;e.setFill(n),e.setStroke("#fff"),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x+a*.7,t.y+a*.25),e.lineTo(t.x+a*.35,t.y+a*.4),e.lineTo(t.x+a*.5,t.y+a*.95),e.lineTo(t.x+a*.35,t.y+a*1.05),e.lineTo(t.x+a*.2,t.y+a*.5),e.lineTo(t.x,t.y+a*.65),e.closePath(),e.fill(),e.stroke(),e.setFont("sans-serif",h2),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+d2,i=t.y+d2,l=r+2*f2,c=h2+2*p2;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+f2,i+p2)},UG=(e,t,n,o)=>{let a=_I,r=n.resolved?TI:CI,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":EI),e.setStrokeWidth(s?2:1.5),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,a,a),e.fill(),e.stroke(),n.thread.length>0){let i=n.thread.length,l=i>9?"9+":String(i);e.setFont("sans-serif",II),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var Pc=(e,t)=>{let n=t.getBoundingClientRect();return{kind:WG(e.pointerType),phase:qG(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:GG(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var ea=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},GG=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),WG=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",qG=e=>{switch(e){case"pointerdown":return"down";case"pointermove":return"move";case"pointerup":return"up";case"pointercancel":return"cancel";case"pointerenter":return"enter";case"pointerleave":return"leave";default:return"move"}};var Nv=()=>typeof navigator<"u"?navigator.userAgent:"",Ip=()=>typeof navigator<"u"&&navigator.platform||"",rs=/Mac|iPod|iPhone|iPad/.test(Ip()),jG=Ip().startsWith("Win"),Y5=/\b(android)\b/i.test(Nv()),VG=/iPad|iPhone/i.test(Ip())||typeof navigator<"u"&&/Mac/i.test(Ip())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,ZG=/Linux/i.test(Ip())&&!Y5,XG=/Firefox/i.test(Nv()),YG=/^((?!chrome|android).)*safari/i.test(Nv());var KG={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},$G={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},ky=e=>{let t=[];rs?(e.ctrl&&t.push("\u2303"),e.alt&&t.push("\u2325"),e.shift&&t.push("\u21E7"),e.meta&&t.push("\u2318")):(e.meta&&t.push("Ctrl"),e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));let n=rs?KG:$G,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},ut=e=>{let t=ky(e);return rs?t.join(""):t.join("+")};var K5={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},$5={id:"redo",label:"Redo",category:"history",hotkey:[{key:"z",meta:!0,shift:!0},{key:"y",meta:!0}],iconId:"redo",predicate:({editor:e})=>e.canRedo,perform:({editor:e})=>e.redo()},zv=[K5,$5];var mt=e=>e.editor.selection.size>0,Fv=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var Q5={id:"select-all",label:"Select all",category:"selection",viewMode:!0,hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},J5={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:Fv,perform:({editor:e})=>{e.deleteSelected()}},e9={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:mt,perform:({editor:e})=>{e.duplicateSelected()}},t9={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.toggleLockSelection()}},n9={id:"enter-container",label:"Enter container",category:"selection",hotkey:{key:"ArrowDown",meta:!0,shift:!0},predicate:({editor:e})=>e.selection.size===1,perform:({editor:e})=>{e.enterContainer()}},o9={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.exitContainer()}},Hv=[Q5,J5,e9,t9,n9,o9];var a9={id:"copy",label:"Copy",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0},predicate:mt,perform:({editor:e})=>{e.copySelected()}},r9={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:mt,perform:({editor:e})=>{e.cutSelected()}},s9={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},i9={id:"copy-style",label:"Copy style",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0,alt:!0},predicate:mt,perform:({editor:e})=>{e.copySelectionStyle()}},l9={id:"paste-style",label:"Paste style",category:"clipboard",hotkey:{key:"v",meta:!0,alt:!0},predicate:({editor:e})=>e.selection.size>0&&e.hasStyleClipboard,perform:({editor:e})=>{e.pasteSelectionStyle()}},Uv=[a9,r9,s9,i9,l9];var c9={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.bringToFront()}},u9={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.sendToBack()}},d9={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:mt,perform:({editor:e})=>{e.bringForward()}},f9={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:mt,perform:({editor:e})=>{e.sendBackward()}},Gv=[c9,d9,f9,u9];var p9={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},h9={id:"ungroup-selection",label:"Ungroup",category:"grouping",hotkey:{key:"g",meta:!0,shift:!0},predicate:e=>{for(let t of e.editor.selection)if(e.editor.scene.elements.get(t)?.type==="group")return!0;return!1},perform:({editor:e})=>{e.ungroup()}},Wv=[p9,h9];var m9={id:"zoom-in",label:"Zoom in",category:"zoom",viewMode:!0,hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},y9={id:"zoom-out",label:"Zoom out",category:"zoom",viewMode:!0,hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},g9={id:"zoom-reset",label:"Reset zoom",category:"zoom",viewMode:!0,hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},x9={id:"zoom-to-fit",label:"Fit to screen",category:"zoom",viewMode:!0,hotkey:[{key:"1",alt:!0},{key:"1",meta:!0}],perform:({editor:e})=>{e.zoomToFit()}},b9={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",viewMode:!0,hotkey:{key:"2",alt:!0},predicate:mt,perform:({editor:e})=>{e.zoomToSelection()}},qv=[m9,y9,g9,x9,b9];var A9={id:"mode-select",label:"Select tool",category:"mode",viewMode:!0,hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.mode==="select",perform:({editor:e})=>{e.setMode("select")}},v9={id:"mode-hand",label:"Hand tool",category:"mode",viewMode:!0,hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.mode==="hand",perform:({editor:e})=>{e.setMode("hand")}},S9={id:"mode-rect",label:"Rectangle tool",category:"mode",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-rect",perform:({editor:e})=>{e.setMode("draw-rect")}},L9={id:"mode-ellipse",label:"Ellipse tool",category:"mode",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-ellipse",perform:({editor:e})=>{e.setMode("draw-ellipse")}},k9={id:"mode-text",label:"Text tool",category:"mode",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-text",perform:({editor:e})=>{e.setMode("draw-text")}},w9={id:"mode-edge",label:"Link tool",category:"mode",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-edge",perform:({editor:e})=>{e.setMode("draw-edge")}},_9={id:"mode-brush",label:"Brush tool",category:"mode",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.mode==="brush",perform:({editor:e})=>{e.setMode("brush")}},C9={id:"mode-erase",label:"Eraser tool",category:"mode",hotkey:{key:"e"},iconId:"mode-erase",uiKind:"toggle",checked:({editor:e})=>e.mode==="erase",perform:({editor:e})=>{e.setMode("erase")}},E9={id:"mode-laser",label:"Laser pointer",category:"mode",viewMode:!0,hotkey:{key:"k"},iconId:"mode-laser",uiKind:"toggle",checked:({editor:e})=>e.mode==="laser",perform:({editor:e})=>{e.setMode("laser")}},T9={id:"mode-frame",label:"Frame tool",category:"mode",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-frame",perform:({editor:e})=>{e.setMode("draw-frame")}},I9={id:"toggle-tool-lock",label:"Toggle tool lock",category:"mode",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.toolLocked,perform:({editor:e})=>{e.setToolLocked(!e.toolLocked)}},QG={id:"commit-image-crop",label:"Apply crop",category:"edit",hotkey:{key:"Enter"},predicate:({editor:e})=>e.mode==="crop",perform:({editor:e})=>{e.commitImageCrop()}},JG={id:"cancel-image-crop",label:"Cancel crop",category:"edit",viewMode:!0,hotkey:{key:"Escape"},predicate:({editor:e})=>e.mode==="crop",perform:({editor:e})=>{e.cancelImageCrop()}},M9={id:"cancel",label:"Cancel / clear selection",category:"edit",viewMode:!0,hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},jv=[A9,v9,S9,L9,k9,w9,_9,C9,E9,T9,I9,QG,JG,M9];var eW={id:"nudge-selection",label:"Nudge selection",category:"selection",displayHotkey:[{key:"ArrowLeft"},{key:"ArrowRight"},{key:"ArrowUp"},{key:"ArrowDown"}],keyTest:e=>(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown")&&!e.metaKey&&!e.ctrlKey&&!e.altKey,perform:({editor:e,event:t})=>{if(!t)return;let n=t.shiftKey?e4:JI;switch(t.key){case"ArrowLeft":e.moveSelectionBy({x:-n,y:0});return;case"ArrowRight":e.moveSelectionBy({x:n,y:0});return;case"ArrowUp":e.moveSelectionBy({x:0,y:-n});return;case"ArrowDown":e.moveSelectionBy({x:0,y:n});return}}},tW={id:"select-closest",label:"Navigate to adjacent node",category:"selection",displayHotkey:[{key:"ArrowLeft",alt:!0},{key:"ArrowRight",alt:!0},{key:"ArrowUp",alt:!0},{key:"ArrowDown",alt:!0}],keyTest:e=>e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.navigateFlowchart("left");return;case"ArrowRight":e.navigateFlowchart("right");return;case"ArrowUp":e.navigateFlowchart("up");return;case"ArrowDown":e.navigateFlowchart("down");return}}},nW={id:"spawn-connected",label:"Create connected node",category:"edit",displayHotkey:[{key:"ArrowLeft",meta:!0},{key:"ArrowRight",meta:!0},{key:"ArrowUp",meta:!0},{key:"ArrowDown",meta:!0}],keyTest:e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),predicate:({editor:e})=>e.selection.size===1,perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.growFlowchart("left");return;case"ArrowRight":e.growFlowchart("right");return;case"ArrowUp":e.growFlowchart("up");return;case"ArrowDown":e.growFlowchart("down");return}}},oW={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},aW={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},rW={id:"edit-or-create",label:"Edit / create",category:"edit",displayHotkey:{key:"Enter"},keyTest:e=>e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey,predicate:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text")return!0}return e.mode==="draw-rect"||e.mode==="draw-ellipse"},perform:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text"){e.beginTextEdit(t);return}}(e.mode==="draw-rect"||e.mode==="draw-ellipse")&&e.createElementAtCursor()}},R9=[eW,tW,nW,oW,aW,rW];var sW={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},iW={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},lW={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},cW={id:"auto-arrange",label:"Auto-arrange children",category:"layout",predicate:({editor:e})=>{if(e.selection.size!==1)return!1;let[t]=[...e.selection];if(!t)return!1;let n=e.scene.elements.get(t);return n?On(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},uW={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},O9=[sW,iW,lW,cW,uW];var D9={id:"toggle-grid",label:"Toggle grid",category:"other",viewMode:!0,hotkey:{key:"g"},uiKind:"toggle",checked:({editor:e})=>e.gridEnabled,perform:({editor:e})=>{e.toggleGrid()}},P9={id:"toggle-read-only",label:"Read-only mode",category:"other",viewMode:!0,hotkey:{key:"r",alt:!0},uiKind:"toggle",checked:({editor:e})=>e.readOnly,perform:({editor:e})=>{e.toggleReadOnly()}},Vv=[D9,P9];var Bc=e=>e.editor.selection.size>=2,B9=e=>e.editor.selection.size>=3,N9={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:mt,perform:({editor:e})=>{e.flipSelection("horizontal")}},z9={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:mt,perform:({editor:e})=>{e.flipSelection("vertical")}},F9={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",meta:!0,shift:!0},iconId:"align-left",predicate:Bc,perform:({editor:e})=>{e.alignSelection("left")}},H9={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:Bc,perform:({editor:e})=>{e.alignSelection("h-center")}},U9={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",meta:!0,shift:!0},iconId:"align-right",predicate:Bc,perform:({editor:e})=>{e.alignSelection("right")}},G9={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",meta:!0,shift:!0},iconId:"align-top",predicate:Bc,perform:({editor:e})=>{e.alignSelection("top")}},W9={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:Bc,perform:({editor:e})=>{e.alignSelection("v-center")}},q9={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",meta:!0,shift:!0},iconId:"align-bottom",predicate:Bc,perform:({editor:e})=>{e.alignSelection("bottom")}},j9={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:B9,perform:({editor:e})=>{e.distributeSelection("horizontal")}},V9={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:B9,perform:({editor:e})=>{e.distributeSelection("vertical")}},Zv=[N9,z9,F9,H9,U9,G9,W9,q9,j9,V9];var Z9=e=>{let{editor:t}=e;for(let n of t.selection){let o=I(t.scene,n);if(o!==void 0&&fe(o))return!0}return!1},X9={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:Z9,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},Y9={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:Z9,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},Xv=[X9,Y9];var Mp=class{entries=new Map;order=[];seqBuffer=[];register(t){if(this.entries.has(t.id))throw new Error(`Action already registered: ${t.id}`);this.entries.set(t.id,t),this.order.push(t.id)}replace(t){if(this.entries.has(t.id)){this.entries.set(t.id,t);return}this.register(t)}unregister(t){if(!this.entries.delete(t))return;let n=this.order.indexOf(t);n!==-1&&this.order.splice(n,1)}get(t){return this.entries.get(t)}getAll(){return this.order.map(t=>this.entries.get(t)).filter(t=>t!==void 0)}dispatch(t,n){let o=this.entries.get(t);return!o||Yv(o,n)||o.predicate&&!o.predicate(n)?!1:(o.perform(n),!0)}dispatchHotkey(t,n){let o={...n,event:t};if(this.trySequence(t,o))return!0;for(let a of this.order){let r=this.entries.get(a);if(!r||Yv(r,o))continue;if(r.keyTest?.(t,o)){if(r.predicate&&!r.predicate(o))continue;return r.perform(o),!0}if(!r.hotkey)continue;let s=Array.isArray(r.hotkey)?r.hotkey:[r.hotkey];for(let i of s)if(dW(t,i)&&!(r.predicate&&!r.predicate(o)))return r.perform(o),!0}return!1}trySequence(t,n){if(!(t.key.length===1&&!t.metaKey&&!t.ctrlKey&&!t.altKey))return this.seqBuffer=[],!1;let a=t.timeStamp;this.seqBuffer=this.seqBuffer.filter(r=>a-r.t<=QI),this.seqBuffer.push({key:t.key,code:t.code,t:a});for(let r of this.order){let s=this.entries.get(r);if(!s?.sequence||s.sequence.length===0||Yv(s,n))continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>K9(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},Yv=(e,t)=>t.editor.readOnly&&e.viewMode!==!0,dW=(e,t)=>{if(t.key!==void 0&&!fW(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=rs?e.metaKey:e.ctrlKey;return!(n(t.meta)!==o||n(t.shift)!==e.shiftKey||n(t.alt)!==e.altKey||t.ctrl!==void 0&&n(t.ctrl)!==e.ctrlKey)},fW=(e,t)=>K9(e.key,e.code,t),K9=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(pW(e))return!1;let o=hW(n);return o!==null&&t===o},pW=e=>/^[a-z]$/i.test(e),hW=e=>{if(e.length!==1)return null;let t=e.toLowerCase();if(t>="a"&&t<="z")return`Key${t.toUpperCase()}`;if(t>="0"&&t<="9")return`Digit${t}`;switch(t){case"[":return"BracketLeft";case"]":return"BracketRight";case",":return"Comma";case".":return"Period";case"/":return"Slash";case";":return"Semicolon";case"'":return"Quote";case"`":return"Backquote";case"-":return"Minus";case"=":return"Equal";case"\\":return"Backslash";default:return null}},Kv=e=>{let t=[...zv,...Hv,...Uv,...Gv,...Wv,...qv,...jv,...R9,...O9,...Vv,...Zv,...Xv];for(let n of t)e.register(n)},_e=new Mp;Kv(_e);var wy=(e,t={})=>{let n=t.target??window,o=t.registry??_e,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(ea(s)){if(r.key!=="Escape")return;s instanceof HTMLElement&&s.blur()}o.dispatchHotkey(r,{editor:e})&&r.preventDefault()};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}};var $9=e=>{if(fe(e))return e.text.length>0?e.text:null;if(Be(e)){let t=e.name;return t!==void 0&&t.length>0?t:null}return null},$v=(e,t)=>{let n=t.trim().toLowerCase();if(n==="")return[];let o=[];for(let a of e.elements.values()){let r=$9(a);r?.toLowerCase().includes(n)&&o.push({kind:"element",id:a.id,text:r})}for(let a of e.links.values()){let r=a.label?.text;r?.toLowerCase().includes(n)&&o.push({kind:"link",id:a.id,text:r})}return o};var mW=new Map;var Q9=e=>mW.get(e);var Qv=()=>{let e=new Map;return{on:(s,i)=>{let l=e.get(s);return l||(l=new Set,e.set(s,l)),l.add(i),()=>{let c=e.get(s);c&&(c.delete(i),c.size===0&&e.delete(s))}},off:(s,i)=>{let l=e.get(s);l&&(l.delete(i),l.size===0&&e.delete(s))},emit:(s,...i)=>{let l=e.get(s);if(!l||l.size===0)return 0;let c=Array.from(l),u=null,d=0;for(let f of c)try{f(...i),d++}catch(p){u??=p instanceof Error?p:new Error(String(p))}if(u!==null)throw u;return d},clear:s=>{if(s===void 0){e.clear();return}e.delete(s)},listenerCount:s=>{let i=e.get(s);return i?i.size:0}}};var Jv=()=>{let e=new Set;return{add:t=>(e.add(t),()=>e.delete(t)),emit:t=>{for(let n of[...e])n(t)},clear:()=>{e.clear()},size:()=>e.size}};var J9=e=>{let t=new Map,n=new Map,o=new Map,a=new Map,r=new Map,s=null,i=()=>s,l=[],c=-1,u=p=>{if(p.kind==="batch"){for(let h of p.patches)u(h);return}if(p.kind==="element"){let h=t.get(p.id);h?h.latest={...h.latest,after:p.after}:(t.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="link"){let h=n.get(p.id);h?h.latest={...h.latest,after:p.after}:(n.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="layer"){let h=o.get(p.id);h?h.latest={...h.latest,after:p.after}:(o.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="annotation"){let h=a.get(p.id);h?h.latest={...h.latest,after:p.after}:(a.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="file"){let h=r.get(p.id);h?h.latest={...h.latest,after:p.after}:(r.set(p.id,{first:p,latest:p}),l.push(p));return}s?s={first:s.first,latest:{...s.latest,after:p.after}}:(s={first:p,latest:p},c=l.length,l.push(p))};for(let p of e)u(p);let d=i(),f=[];for(let p=0;p<l.length;p++){let h=v(l[p]),m;if(h.kind==="element"){let x=v(t.get(h.id));m={kind:"element",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="link"){let x=v(n.get(h.id));m={kind:"link",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="layer"){let x=v(o.get(h.id));m={kind:"layer",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="annotation"){let x=v(a.get(h.id));m={kind:"annotation",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="file"){let x=v(r.get(h.id));m={kind:"file",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(p===c&&d!==null)m={kind:"viewport",before:d.first.before,after:d.latest.after};else continue;yW(m)||f.push(m)}return f},yW=e=>e.kind==="element"||e.kind==="link"||e.kind==="layer"||e.kind==="annotation"||e.kind==="file"||e.kind==="viewport"?e.before===e.after:!1;var Rp=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Yr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),pc(t)):null}redo(){let t=this.future.pop();return t?(this.past.push(t),t):null}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}get size(){return this.past.length}get redoSize(){return this.future.length}get undoStack(){return this.past}get redoStack(){return this.future}clear(){this.past.length=0,this.future.length=0}transaction(){if(this.current!==null)throw new Error("A transaction is already open");let t=[];return this.current=t,{add:n=>{if(this.current!==t)throw new Error("Transaction is no longer open");Yr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?J9(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Vo(n);Yr(a)||(this.past.push(a),this.future.length=0,this.trim())},cancel:()=>{this.current===t&&(this.current=null)},isOpen:()=>this.current===t}}hasOpenTransaction(){return this.current!==null}record(t,n){if(n?.transaction?.isOpen()){n.transaction.add(t);return}this.push(t)}current=null;trim(){if(Number.isFinite(this.limit))for(;this.past.length>this.limit;)this.past.shift()}};var Op=class{entries=[];register(t){let n=this.entries.findIndex(o=>o.id===t.id);if(n!==-1){this.entries[n]=t;return}this.entries.push(t)}unregister(t){let n=this.entries.findIndex(o=>o.id===t);n!==-1&&this.entries.splice(n,1)}getAll(){return this.entries}async dispatch(t,n){for(let o of this.entries)if(o.accept(t))return await o.handle(t,n),!0;return!1}},eM=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var eS=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},tS=e=>{if(e.type&&eM.includes(e.type))return!0;let t=e.name.toLowerCase().split(".").pop();return t?{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jfif",svg:"image/svg+xml",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"}[t]!==void 0:!1};var nS=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let a=o.result;typeof a=="string"?t(a):n(new Error(`Unexpected FileReader result type for ${e.name}`))},o.onerror=()=>{n(o.error??new Error(`Failed to read ${e.name}`))},o.readAsDataURL(e)});var gW=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),oS=async function*(e,t={}){let n=t.skipDirectory??gW,o=t.maxDepth??32,a=e.items,r=a!==null&&a.length>0&&typeof a[0]?.webkitGetAsEntry=="function";if(a===null||!r){for(let s of Array.from(e.files))yield s;return}for(let s of Array.from(a)){if(s.kind!=="file")continue;let i=s.webkitGetAsEntry?.();i&&(yield*tM(i,"",0,n,o,t.onError))}};async function*tM(e,t,n,o,a,r){let s=t?`${t}/${e.name}`:e.name;if(e.isFile){try{yield await new Promise((c,u)=>{e.file?.(c,u)})}catch(l){r?.(s,l)}return}if(!e.isDirectory||o(e.name))return;if(n>=a){r?.(s,new Error(`Folder depth exceeds ${a}`));return}let i=e.createReader?.();if(i)for(;;){let l;try{l=await new Promise((c,u)=>{i.readEntries(c,u)})}catch(c){r?.(s,c);return}if(l.length===0)return;for(let c of l)yield*tM(c,s,n+1,o,a,r)}}var xW=e=>new Promise((t,n)=>{if(typeof Image>"u"){n(new Error("Image() is not available in this environment"));return}let o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{n(new Error("Failed to decode image data URL"))},o.src=e}),oM={id:"image",accept:e=>tS(e),handle:async(e,{editor:t,worldPoint:n})=>{let o=typeof URL<"u"&&typeof URL.createObjectURL=="function",a=await t.addBinaryFile(e,e.name),r=o?URL.createObjectURL(e):await nS(e),s=await xW(r),i=L2,l=Math.max(s.width,s.height)>i?i/Math.max(s.width,s.height):1,c=Math.round(s.width*l),u=Math.round(s.height*l),d={x:n.x-c/2,y:n.y-u/2},f=e.type==="image/gif"||/\.gif$/i.test(e.name),p=null;if(typeof Image<"u"){if(p=new Image,p.src=r,typeof document<"u"){let y=aM();p.style.position="fixed",p.style.left="0",p.style.top="0",p.style.width="1px",p.style.height="1px",p.style.opacity="0.01",p.style.zIndex="-1",p.style.pointerEvents="none",y.appendChild(p)}let x=p;x.complete||await new Promise(y=>{x.onload=()=>{y()},x.onerror=()=>{y()}})}let h=f?await e.arrayBuffer():void 0,m=p??void 0;if(p&&!f&&typeof createImageBitmap=="function")try{m=await createImageBitmap(p)}catch{}t.insertImage({src:r,fileId:a,width:c,height:u,position:d,...m?{image:m}:{},animated:f,...f?{animationKind:"gif"}:{},...h?{animationData:h}:{}})}},nM="oh-just-another-animated-image-sink",aM=()=>{let e=document.getElementById(nM);if(e)return e;let t=document.createElement("div");return t.id=nM,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.width="0",t.style.height="0",t.style.overflow="visible",t.style.pointerEvents="none",t.style.zIndex="-1",document.body.appendChild(t),t},rM={id:"video",accept:e=>eS(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=URL.createObjectURL(e),a=document.createElement("video");a.src=o,a.muted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!0;let r=aM();a.style.position="absolute",a.style.left="-99999px",a.style.top="-99999px",a.style.width="1px",a.style.height="1px",r.appendChild(a),await new Promise(p=>{let h=()=>{p()};a.onloadedmetadata=h,a.onerror=h});let s=a.videoWidth||480,i=a.videoHeight||270,l=L2,c=Math.max(s,i)>l?l/Math.max(s,i):1,u=Math.round(s*c),d=Math.round(i*c),f={x:n.x-u/2,y:n.y-d/2};a.play().catch(()=>{}),t.insertImage({src:o,width:u,height:d,position:f,image:a,animated:!0})}};var _y=64,sM=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<_y;){let r=I(e,o.parentId);if(!r)break;ze(r)&&(n=r),o=r,a++}return n},aS=(e,t,n)=>{let o=I(e,t),a=0;for(;o&&a<_y;){if(o.id===n)return!0;if(!o.parentId)return!1;o=I(e,o.parentId),a++}return!1},iM=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<_y&&n!==o.parentId;){let r=I(e,o.parentId);if(!r||!ze(r))break;o=r,a++}return o},lM=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||aS(e,r.id,n)||o.add(r.id);return o},cM=(e,t,n,o)=>{if(!n)return null;if(o!==n.id)return n;let a=t,r=null,s=0;for(;a.parentId&&s<_y;){let i=I(e,a.parentId);if(!i||i.id===n.id)break;ze(i)&&(r=i),a=i,s++}return r};var bW=/^Frame (\d+)$/,uM=e=>{let t=0;for(let n of e.elements.values()){if(!Be(n))continue;let o=bW.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},dM=(e,t,n,o)=>{let a=o.x,r=o.y,s=o.x+o.width,i=o.y+o.height,l=e;for(let c of e.elements.values()){if(c.id===n||Be(c)||c.frameId!==void 0)continue;let u=z(c),d=u.x+u.width/2,f=u.y+u.height/2;if(d<a||d>s||f<r||f>i)continue;let p=J(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},fM=(e,t)=>{let n=[...e.elements.values()].filter(Be).sort((a,r)=>a.order<r.order?1:a.order>r.order?-1:0).map(a=>({id:a.id,b:z(a)})),o=e;for(let a of e.elements.values()){if(Be(a))continue;let r=z(a),s=r.x+r.width/2,i=r.y+r.height/2,l;for(let u of n)if(s>=u.b.x&&s<=u.b.x+u.b.width&&i>=u.b.y&&i<=u.b.y+u.b.height){l=u.id;break}if(a.frameId===l)continue;let c=J(o,a.id,u=>{let d={...u};return l===void 0?delete d.frameId:d.frameId=l,d});o=c.scene,t.push(c.patch)}return o};var Cy=class{pending=!1;getScene;compact;constructor(t){this.getScene=t.getScene,this.compact=t.compact}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}runCheck(){let t=this.getScene(),n=new Set;for(let o of t.elements.values())o.order.length>A2&&n.add(o.layerId);for(let o of t.links.values())o.order.length>A2&&n.add(o.layerId);for(let o of n)this.compact(o)}};var Ey=class{opts;pending=!1;signatures=new Map;constructor(t){this.opts=t}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}resetSignature(t){this.signatures.set(t,this.signatureFor(t))}runCheck(){let t=this.opts.getScene(),n=!1;for(let o of t.elements.values()){if(!On(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=Jf(this.opts.getScene(),o.id);if(!r)continue;this.opts.applyPatch(r);let s=this.opts.getScene();for(let i of s.elements.values())i.parentId===o.id&&this.opts.growContainer(o.id,i.id);n=!0}n&&this.opts.onMutated()}signatureFor(t){let n=this.opts.getScene(),o=I(n,t),a=[...n.elements.values()].filter(s=>s.parentId===t);if(o&&On(o)?.kind==="wrap"){let s=to(o),i=s?`${Math.round(s.x)},${Math.round(s.y)}`:"0,0",l=s?Math.round(s.width):0,c=a.map(u=>{let d=z(u);return`${u.id}:${Math.round(d.width)}x${Math.round(d.height)}`}).sort();return`o${i}|w${l}|${c.join(",")}`}let r=a.map(s=>s.id);return r.sort(),r.join(",")}};var pM=()=>({mode:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),hM=(e,t,n)=>{n.mode!==e.mode&&(e.mode=n.mode,t.emit("mode",n.mode)),n.selection!==e.selection&&(e.selection=n.selection,t.emit("selection",n.selection)),n.scene!==e.scene&&(e.scene=n.scene,t.emit("scene",n.scene)),n.scene.viewport!==e.viewport&&(e.viewport=n.scene.viewport,t.emit("viewport",n.scene)),(n.canUndo!==e.canUndo||n.canRedo!==e.canRedo)&&(e.canUndo=n.canUndo,e.canRedo=n.canRedo,t.emit("history",{canUndo:n.canUndo,canRedo:n.canRedo})),t.emit("change")},mM=(e,t)=>{e.mode=t.mode,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var Ty=class{frameId=null;isAnimated;onTick;constructor(t){this.isAnimated=t.isAnimated,this.onTick=t.onTick}start(){if(this.frameId!==null||typeof requestAnimationFrame>"u")return;let t=()=>{if(!this.isAnimated()){this.frameId=null;return}this.onTick(),this.frameId=requestAnimationFrame(t)};this.frameId=requestAnimationFrame(t)}stop(){this.frameId!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameId),this.frameId=null)}get running(){return this.frameId!==null}};var Iy=class{host;tick;costEma=0;lastTickMs=0;onVisibilityChange=()=>{typeof document>"u"||(document.hidden?this.tick.stop():this.maybe())};constructor(t){this.host=t,this.tick=new Ty({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(jI,Math.max(qI,this.costEma*VI));if(t-this.lastTickMs<n)return;this.lastTickMs=t,this.host.autoStopHeavyGifs(),this.host.forceAnimationRepaint();let o=(typeof performance<"u"?performance.now():Date.now())-t;this.costEma=this.costEma*.8+o*.2}attach(){typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange)}detach(){this.tick.stop(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange)}maybe(){this.host.hasVisibleAnimatedElement()&&this.tick.start()}};var My=class{ref;constructor(t){this.ref=t}record(t){this.ref.gestureTx??=this.ref.history.transaction(),this.ref.gestureTx.add(t)}commit(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.dragElementId=null,this.ref.containerHover!==null&&(this.ref.containerHover=null),this.ref.gestureTx&&(this.ref.gestureTx.commit(),this.ref.gestureTx=null),this.ref.notify()}cancel(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.gestureTx&&(this.ref.gestureTx.cancel(),this.ref.gestureTx=null)}finalize(){if(this.ref.gestureTx){try{this.ref.gestureTx.commit()}catch{this.ref.gestureTx.cancel()}this.ref.gestureTx=null}}maybeRevertModeAfterCreate(){this.ref.toolLocked||this.ref.mode==="select"||this.ref.mode==="hand"||this.ref.setMode("select")}};function Dp(){return typeof performance<"u"?performance.now():Date.now()}function AW(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Ry=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Dp();this.state.set(t,{playing:!AW(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Dp();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Dp(),o=this.state.get(t);o?o.playing?(o.frozenMs=n-o.originMs,o.playing=!1):(o.originMs=n-o.frozenMs,o.playStartMs=n,o.playing=!0):this.state.set(t,{playing:!0,originMs:n,playStartMs:n,frozenMs:0})}hoverEnter(t){if(this.hoveredId===t||(this.hoveredId=t,t===null))return!1;let n=this.state.get(t);if(n&&!n.playing){let o=Dp();return n.originMs=o-n.frozenMs,n.playStartMs=o,n.playing=!0,!0}return!1}isPaused(t){return this.state.get(t)?.playing===!1}autoStopHeavy(t){let n=Dp();for(let o of t){let a=this.state.get(o);if(a?.playing){if(o===this.hoveredId){a.playStartMs=n;continue}n-a.playStartMs>XI&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var yM=(e,t,n,o)=>{let a=Ae(Array.from(e.elements.values()).filter(s=>s.layerId===o).map(s=>s.order)),r={};return t.image&&(r.image=t.image),t.animated&&(r.animated=!0),{id:n,layerId:o,type:"image",position:t.position,rotation:0,scale:{x:1,y:1},order:a,style:{},width:t.width,height:t.height,src:t.src,...t.fileId?{fileId:t.fileId}:{},...t.animationKind?{animationKind:t.animationKind}:{},...t.animationData!==void 0?{animationData:t.animationData}:{},...Object.keys(r).length>0?{metadata:r}:{}}},gM=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=eA(`file-${o()}-${Date.now().toString(36)}`),s=ZA(r,a,{mime:t.type||"application/octet-stream",...n!==void 0?{name:n}:{}}),i={kind:"file",id:r,before:null,after:s};return{scene:Q(e,i),patch:i,id:r}},Oy=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var bM=e=>{if(!Oy(e._scene))return!1;let t=e.computeViewportWorld();if(!t)return!0;for(let n of e._scene.elements.values())if(n.metadata?.animated===!0&&V.intersects(z(n),t))return!0;return!1},AM=e=>{let t=[];for(let n of e._scene.elements.values()){if(!ct(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>ZI&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},rS=e=>{for(let t of e._scene.elements.values()){if(!ct(t)||!t.animationKind||(e.gifPlayback.ensure(t.id),!t.fileId)||t.animationData instanceof ArrayBuffer)continue;let n=O0(e._scene,t.fileId);n&&(e._scene=Q(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}},vW=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],xM=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of vW){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},SW=async(e,t)=>{if(typeof Blob>"u")return null;let n=new Blob([e],{type:t||"application/octet-stream"});if(typeof createImageBitmap=="function")try{return await createImageBitmap(n)}catch{}if(typeof Image<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"){let o=URL.createObjectURL(n);return new Promise(a=>{let r=new Image;r.onload=()=>{a(r)},r.onerror=()=>{URL.revokeObjectURL(o),a(null)},r.src=o})}return null},sS=async e=>{let t=[];for(let o of e._scene.elements.values()){if(!ct(o)||o.animationKind||xM(o.metadata?.image)||!o.fileId)continue;let a=O0(e._scene,o.fileId);a&&t.push({id:o.id,data:a.data,mime:a.mime})}if(t.length===0)return;let n=!1;for(let o of t){let a=await SW(o.data,o.mime);if(!a)continue;let r=e._scene.elements.get(o.id);!r||!ct(r)||xM(r.metadata?.image)||(e._scene=Q(e._scene,{kind:"element",id:r.id,before:r,after:{...r,metadata:{...r.metadata,image:a}}}),n=!0)}n&&e.forceRender()};var vM={x:-1e9,y:-1e9,width:0,height:0},kW=4,SM=(e,t)=>{let n=new Map;if(e===t)return{world:vM,tileDirty:n};let o=null,a=u=>{o=o?V.union(o,u):u},r=new Set;for(let[u,d]of t.elements){let f=e.elements.get(u);if(f===d)continue;r.add(u);let p=Xf(d),h=f?Xf(f):null;a(p),h&&a(h),n.set(u,{before:h,after:p})}for(let[u,d]of e.elements)if(!t.elements.has(u)){r.add(u);let f=Xf(d);a(f),n.set(u,{before:f,after:null})}let s=u=>{for(let d of[u.from,u.to])if(d.kind!=="point"&&r.has(d.elementId))return!0;return!1};for(let[u,d]of t.links){let f=e.links.get(u);if(f===d&&!s(d))continue;let p=os(t,d);p&&a(p);let m=os(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=os(e,d);f&&a(f)}if(o===null)return{world:vM,tileDirty:n};let i=new Set,l=o,c=!0;for(;c;){c=!1;for(let u of t.elements.values()){if(i.has(u.id))continue;let d=z(u);if(!V.intersects(d,l))continue;i.add(u.id);let f=V.union(l,d);(f.x!==l.x||f.y!==l.y||f.width!==l.width||f.height!==l.height)&&(l=f,c=!0)}}return{world:V.expand(l,kW),tileDirty:n}};var Dy=class{screenToWorld;onFire;timer=null;origin=null;constructor(t,n){this.screenToWorld=t,this.onFire=n}start(t){this.cancel(),this.origin=t,this.timer=setTimeout(()=>{this.timer=null;let n=this.origin;if(this.origin=null,!n)return;let o=this.screenToWorld(n);this.onFire({screenPoint:n,worldPoint:o})},gI)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&U.distance(this.origin,t)>n&&this.cancel()}};var Py=class{screenToWorld;zoomAt;panBy;origin=null;constructor(t,n,o){this.screenToWorld=t,this.zoomAt=n,this.panBy=o}isActive(){return this.origin!==null}begin(t){if(t.length<2)return;let[n,o]=t,a=U.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:U.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=U.distance(n,o),r=U.midpoint(n,o);if(U.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<yI)return;let i=a/this.origin.distance;if(i!==1){let u=this.screenToWorld(r);this.zoomAt(i,u)}let l=r.x-this.origin.midpointScreen.x,c=r.y-this.origin.midpointScreen.y;(l!==0||c!==0)&&this.panBy({x:l,y:c}),this.origin={midpointWorld:this.screenToWorld(r),distance:a,midpointScreen:r}}end(){this.origin=null}};var wW=(e,t)=>{let n=e.width*e.height;if(n<=0)return 0;let o=Math.max(e.x,t.x),a=Math.max(e.y,t.y),r=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height),i=r-o,l=s-a;return i<=0||l<=0?0:i*l/n},_W=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=z(o);n=n?V.union(n,a):a}return n},LM=(e,t,n,o)=>{if(!Nf(t)||!Ti(t))return n;if(On(t)?.kind==="wrap")return CW(e,t,n,o);let a=_W(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=to(r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.x,f=s.y,p=s.x+s.width,h=s.y+s.height,m=a.x,x=a.y,y=a.x+a.width,g=a.y+a.height;if(o.includes("e")&&p<y&&(c+=y-p),o.includes("s")&&h<g&&(u+=g-h),o.includes("w")&&d>m){let b=d-m;i-=b,c+=b}if(o.includes("n")&&f>x){let b=f-x;l-=b,u+=b}return{x:i,y:l,width:c,height:u}},CW=(e,t,n,o)=>{let a=ui(t)?.padding??0,r=Math.max(0,n.width-2*a),s=N0(e,t.id,r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.widest+2*a;if(c<d){let m=d-c;c=d,o.includes("w")&&(i-=m)}let f=Math.max(0,c-2*a),h=(f===r?s:N0(e,t.id,f)??s).contentHeight+2*a;if(u<h){let m=h-u;u=h,o.includes("n")&&(l-=m)}return{x:i,y:l,width:c,height:u}},kM=(e,t)=>{let n=e.dragElementId;if(!n)return;let o=I(e.scene,n);if(!o)return;let a=e.containerHover;if(a&&a.id!==o.parentId){let r=Ae([...e.scene.elements.values()].filter(i=>i.layerId===o.layerId&&i.id!==n).map(i=>i.order)),s=J(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),Pp(e,a.id,n);return}if(a&&a.id===o.parentId){Pp(e,o.parentId,n);return}if(o.parentId){let r=I(e.scene,o.parentId);if(r!==void 0&&ze(r))return;let s=r?to(r):null,i=z(o),l=s?wW(i,s):0;if(s&&l>=MI){Pp(e,o.parentId,n);return}let c=J(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},Pp=(e,t,n)=>{let o=I(e.scene,t),a=I(e.scene,n);if(!o||!a)return;let r=ui(o);if(!r)return;let s=z(a),i=LA(o,s);if(!i)return;if(Ti(o)){let c=kA({width:o.width,height:o.height,spec:r},i),u=J(e.scene,t,d=>({...d,position:{x:d.position.x+c.positionOffset.x,y:d.position.y+c.positionOffset.y},width:c.width,height:c.height,metadata:{...d.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(u.patch,u.scene);return}let l=J(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var Bp=(e,t,n)=>{let o=e.x,a=e.y,r=e.width,s=e.height;switch(t){case"nw":o+=n.x,a+=n.y,r-=n.x,s-=n.y;break;case"n":a+=n.y,s-=n.y;break;case"ne":a+=n.y,r+=n.x,s-=n.y;break;case"e":r+=n.x;break;case"se":r+=n.x,s+=n.y;break;case"s":s+=n.y;break;case"sw":o+=n.x,r-=n.x,s+=n.y;break;case"w":o+=n.x,r-=n.x;break}return{x:o,y:a,width:r,height:s}},iS=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2,a=e.width+2*(t.width-e.width),r=e.height+2*(t.height-e.height);return{x:n-a/2,y:o-r/2,width:a,height:r}},lS=(e,t)=>{if(e.width===0||e.height===0)return t;let n=t.width/e.width,o=t.height/e.height,a=Math.abs(n-1)>=Math.abs(o-1)?n:o;return{x:t.x,y:t.y,width:e.width*a,height:e.height*a}},wM=e=>e==="nw"||e==="w"||e==="sw",_M=e=>e==="ne"||e==="e"||e==="se",CM=e=>e==="nw"||e==="n"||e==="ne",EM=e=>e==="sw"||e==="s"||e==="se",cS=(e,t,n,o,a=!1)=>{let r=o.noFlip?o.minWidth??0:o.minWidth,s=o.noFlip?o.minHeight??0:o.minHeight,i=o.maxWidth,l=o.maxHeight,c=(m,x,y)=>{let g=m;return x!==void 0&&g<x&&(g=x),y!==void 0&&g>y&&(g=y),g},u=t.width;o.noFlip?u=c(u,r,i):i!==void 0&&Math.abs(u)>i?u=u<0?-i:i:r!==void 0&&Math.abs(u)<r&&u!==0&&(u=u<0?-r:r);let d=t.height;if(o.noFlip?d=c(d,s,l):l!==void 0&&Math.abs(d)>l?d=d<0?-l:l:s!==void 0&&Math.abs(d)<s&&d!==0&&(d=d<0?-s:s),a){let m=o.noFlip?u:Math.abs(u),x=o.noFlip?d:Math.abs(d),y=e.x+e.width/2,g=e.y+e.height/2;return{x:y-m/2,y:g-x/2,width:m,height:x}}let f=t.x;wM(n)&&!_M(n)?f=e.x+e.width-u:_M(n)&&!wM(n)&&(f=e.x);let p=t.y;CM(n)&&!EM(n)?p=e.y+e.height-d:EM(n)&&!CM(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:V.normalize(h)};var TM=(e,t)=>e.kind!=="point"&&t.has(e.elementId),EW=(e,t)=>TM(e.from,t)&&TM(e.to,t),RM=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,IM=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),TW=(e,t)=>{if(!RM(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=IM(e.waypoints,t)),e.fixedSegments?.length&&(n.fixedSegments=e.fixedSegments.map(o=>({axis:o.axis,pos:o.pos+(o.axis==="h"?t.y:t.x),at:o.at+(o.axis==="h"?t.x:t.y)}))),e.routedPoints?.length&&(n.routedPoints=IM(e.routedPoints,t)),n},MM=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,uS=(e,t)=>{let n=TW(e,t),o=e.from.kind==="point",a=e.to.kind==="point";if(!n&&!o&&!a)return null;let r={...n??{}};return o&&(r.from=MM(e.from,t)),a&&(r.to=MM(e.to,t)),r},OM=(e,t,n,o,a)=>{let r=c=>({x:t+(c.x-t)*o,y:n+(c.y-n)*a}),s=e.from.kind==="point",i=e.to.kind==="point";if(!RM(e)&&!s&&!i)return null;let l={};return e.waypoints?.length&&(l.waypoints=e.waypoints.map(r)),e.fixedSegments?.length&&(l.fixedSegments=e.fixedSegments.map(c=>({axis:c.axis,pos:c.axis==="h"?n+(c.pos-n)*a:t+(c.pos-t)*o,at:c.axis==="h"?t+(c.at-t)*o:n+(c.at-n)*a}))),e.routedPoints?.length&&(l.routedPoints=e.routedPoints.map(r)),e.from.kind==="point"&&(l.from={kind:"point",position:r(e.from.position)}),e.to.kind==="point"&&(l.to={kind:"point",position:r(e.to.position)}),l},DM=(e,t,n)=>n.has(e.id)||EW(e,t),dS=(e,t,n)=>{let o=new Map;for(let a of e.links.values())DM(a,t,n)&&uS(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},PM=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=be(e,a);if(!s)continue;let i=uS(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},BM=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!DM(s,t,n))continue;let i=uS(s,o);if(!i)continue;let l=et(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var NM=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=I(e,t);if(!l||!Ti(l))return null;let c=Bp(a,n,o),u=s?lS(a,c):c,d=i?iS(a,u):u,p=l.noFlip===!0||On(l)!==null?{...l,noFlip:!0}:l,h=cS(a,d,n,p,i),m=r(l,h,n),x={...l,position:{x:m.x,y:m.y},scale:{x:1,y:1},width:m.width,height:m.height},y={kind:"element",id:t,before:l,after:x};return{scene:Q(e,y),patch:y}},zM=(e,t,n,o,a=!1,r=!1)=>{let s=I(e,t.id);if(!s||!Ti(t))return null;let i=xi(t),[l]=cp(i),c=Math.cos(i.rotation),u=Math.sin(i.rotation),d={x:c,y:u},f={x:-u,y:c},p={x:o.x*d.x+o.y*d.y,y:o.x*f.x+o.y*f.y},h={x:0,y:0,width:i.bounds.width,height:i.bounds.height},m=Bp(h,n,p),x=a?lS(h,m):m,y=r?iS(h,x):x,b=t.noFlip===!0||On(t)!==null?{...t,noFlip:!0}:t,A=cS(h,y,n,b,r),_={x:l.x+A.x*d.x+A.y*f.x,y:l.y+A.x*d.y+A.y*f.y},T={...t,position:_,scale:{x:1,y:1},width:A.width,height:A.height},w={kind:"element",id:t.id,before:s,after:T};return{scene:Q(e,w),patch:w}},FM=(e,t,n,o,a,r=!1)=>{let s=I(e,t.id);if(!s)return null;let i=Bp(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let S=Math.max(t.fontSize,Math.abs(i.width)),L=n==="w"?a.x+a.width:a.x,M=r?l-S/2:n==="w"?L-S:L,B={...t,position:{x:M,y:a.y},scale:{x:1,y:1},maxWidth:S},W={kind:"element",id:t.id,before:s,after:B};return{scene:Q(e,W),patch:W}}let u=n==="n"||n==="s",d=a.width>0?Math.abs(i.width/a.width):1,f=a.height>0?Math.abs(i.height/a.height):1,p=u?f:Math.max(d,f),h=Math.max(Y0,t.fontSize*p),m=h/t.fontSize,x=a.width*m,y=a.height*m,g=n.includes("w")?a.x+a.width:a.x,b=n.includes("n")?a.y+a.height:a.y,A=r?l-x/2:n.includes("w")?g-x:g,_=r?c-y/2:n.includes("n")?b-y:b,T={...t,position:{x:A,y:_},scale:{x:1,y:1},fontSize:h,...t.maxWidth!==void 0?{maxWidth:t.maxWidth*m}:{}},w={kind:"element",id:t.id,before:s,after:T};return{scene:Q(e,w),patch:w}},HM=(e,t,n,o,a,r,s=!1)=>{let i=Bp(a,n,o),l=1,c=a.width>0?i.width/a.width:1,u=a.height>0?i.height/a.height:1;if(r){let x=Math.max(Math.abs(c),Math.abs(u));c=x*(c>=0?1:-1),u=x*(u>=0?1:-1)}s&&(c=1+2*(c-1),u=1+2*(u-1));let d=Math.abs(c-1)>=Math.abs(u-1)?c:u,f=s?a.x+a.width/2:n.includes("w")?a.x+a.width:a.x,p=s?a.y+a.height/2:n.includes("n")?a.y+a.height:a.y,h=e,m=[];for(let[x,y]of t.elements){let g=I(h,x);if(!g)continue;let b=f+(y.position.x-f)*c,A=p+(y.position.y-p)*u;if(Ti(g)){let L=g.type==="image",M=L?d:c,B=L?d:u,W=y.bounds.width*M,ie=y.bounds.height*B;if(Math.abs(W)<l||Math.abs(ie)<l)continue;let ne={...g,position:{x:b,y:A},scale:{x:W>=0?1:-1,y:ie>=0?1:-1},width:Math.abs(W),height:Math.abs(ie)},j={kind:"element",id:x,before:g,after:ne};h=Q(h,j),m.push(j);continue}let _=y.scale.x*c,T=y.scale.y*u;if(Math.abs(_)<l/Math.max(1,y.bounds.width)||Math.abs(T)<l/Math.max(1,y.bounds.height))continue;let w={...g,position:{x:b,y:A},scale:{x:_,y:T}},S={kind:"element",id:x,before:g,after:w};h=Q(h,S),m.push(S)}for(let[x,y]of t.links??[]){let g=be(h,x);if(!g)continue;let b=OM(y,f,p,c,u);if(!b)continue;let A={kind:"link",id:x,before:g,after:{...g,...b}};h=Q(h,A),m.push(A)}return{scene:h,patches:m}};var yt=Object.freeze(new Set),By=e=>new Set([e]),fS=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},IW=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},UM=(e,t)=>e.has(t)?IW(e,t):fS(e,t),Np=(e,t)=>g0(e,t),GM=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var zp=e=>Math.min(mI,Math.max(hI,e)),WM=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:FA(e.viewport,t)},qM=(e,t,n)=>{let o=e.viewport.zoom,r=zp(o*t)/o;return r===1?null:{...e,viewport:M0(e.viewport,r,n)}},jM=e=>{let t=e.viewport;if(t.zoom===1)return null;let n={x:t.pan.x+t.size.width/2/t.zoom,y:t.pan.y+t.size.height/2/t.zoom};return{...e,viewport:M0(t,1/t.zoom,n)}},hS=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=zp(Math.min(a/t.width,r/t.height)),i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:i.x-o.size.width/2/s,y:i.y-o.size.height/2/s};return{...e,viewport:{...o,zoom:s,pan:l}}},VM=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=Math.min(a/t.width,r/t.height),i=zp(Math.min(o.zoom,s)),l={x:t.x+t.width/2,y:t.y+t.height/2},c={x:l.x-o.size.width/2/i,y:l.y-o.size.height/2/i};return{...e,viewport:{...o,zoom:i,pan:c}}},ZM=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=z(o);n=n?V.union(n,a):a}return n?hS(e,n,t):null},XM=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:HA(o,t,n)}},YM=(e,t)=>{let n=e.viewport,o=t.enabled??n.gridEnabled,a=t.style??n.gridStyle,r=t.snap??n.snapToGrid;if(o===n.gridEnabled&&a===n.gridStyle&&r===n.snapToGrid)return null;let s={...n,gridEnabled:o,...a===void 0?{}:{gridStyle:a},...r===void 0?{}:{snapToGrid:r}};return{...e,viewport:s}};var MW=(e,t)=>{let n=[];for(let o=e;o<=t;o++)n.push(o);return n},KM=(e,t,n)=>{let o=e.x-t.x,a=e.y-t.y;return o*o+a*a<=n},RW=(e,t,n)=>{let o=t.button===2||t.button===1,a=t.button===0&&e.spaceHeld,r=t.button===0&&e.mode==="hand";return o||a||r?(o&&(e.suppressNextContextMenu=!0),e.beginPanGesture(t.pointerId,t.button,n.point),!0):!1},OW=(e,t,n)=>(e.activePointers.set(t.pointerId,n.point),e.activePointers.size===2?(e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture(),e.cancelLongPress(),e.panGesture=null,e.touchPanCandidate=null,e.beginPinch(),!0):e.activePointers.size>2),DW=(e,t)=>e.readOnly||e.editingTextElement===null?!1:e.editedElementContainsPoint(t)?(e.cancelLongPress(),e.setTextCaretFromPoint(t),!0):(e.commitTextEdit(),!1),PW=(e,t)=>e.mode!=="crop"||e.cropSession?.drag==null?!1:(e.updateImageCropDrag(t),!0),BW=e=>e.mode!=="crop"||e.cropSession?.drag==null?!1:(e.endImageCropDrag(),!0),NW=(e,t,n)=>e.readOnly||e.mode!=="brush"?!1:(e.beginBrushStroke(t,n),!0),zW=(e,t,n,o)=>e.readOnly||e.mode!=="erase"?!1:(e.cancelLongPress(),e.beginEraseStroke(t,n,o),!0),FW=(e,t)=>e.mode!=="laser"?!1:(e.cancelLongPress(),e.beginLaserStroke(t),!0),HW=(e,t)=>e.mode!=="eyedropper"&&!e.isEyedropperArmed?!1:(e.cancelLongPress(),e.applyEyedropperAt(t),!0),UW=(e,t)=>{if(e.mode!=="crop"||e.cropSession===null)return!1;let n=e.cropHandleAtWorld(t);return n===null?(e.commitImageCrop(),!1):(e.cancelLongPress(),n==="body"?e.beginImageCropBody(t):e.beginImageCropHandle(n,t),!0)},GW=(e,t,n)=>{if(e.readOnly||e.mode!=="select"||(n||0)<2)return!1;let o=e.hitTest(t);if(o.kind!=="element")return!1;let a=I(e._scene,o.id);return a===void 0||!ct(a)?!1:(e.beginImageCrop(o.id),!0)},WW=(e,t)=>{if(e.readOnly||e.mode!=="draw-text")return!1;e.cancelLongPress();let n=e.hitTest(t),o=n.kind==="element"?I(e._scene,n.id):void 0;return o!==void 0&&fe(o)?(e._selection=wt(o.id),e.beginTextEdit(o.id),e.notify()):e.createTextAt(t),!0},qW=(e,t)=>{if(e.readOnly)return!1;let n=e.hitAnnotation(t);if(!n)return!1;let o=e._scene.annotations.get(n);return o?(e.annotationDrag={id:n,originPosition:{...o.position},originWorldPoint:t,moved:!1},e.setSelectedAnnotation(n),!0):!1},jW=(e,t)=>{let n=e.acceleratedElementAt(t);if(!n)return!1;let o=Q9(n.type);if(!o)return!1;let a={x:t.x-n.position.x,y:t.y-n.position.y},r=o(n,a);return r?(e.applyEmit(r),!0):!1},VW=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.mode==="select"&&n))return!1;let o=be(e._scene,n);if(!(o&&(o.routing??"straight")==="orthogonal"))return!1;let a=ot(e._scene,o);if(!(a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Zo/r,i=s*s,l=a.length===2?[0]:MW(1,a.length-3);for(let c of l){let u=v(a[c]),d=v(a[c+1]),f=(u.x+d.x)/2,p=(u.y+d.y)/2,h=f-t.x,m=p-t.y;if(h*h+m*m<=i){let x=Math.abs(u.y-d.y)<1e-6?"h":"v",y=x==="h"?(u.x+d.x)/2:(u.y+d.y)/2,g=x==="h"?u.y:u.x;return e.isHandleDoubleClick(t)?e.resetSegmentPin(n,x,g,y):e.beginSegmentDrag(n,x,y),e.cancelLongPress(),!0}}return!1},ZW=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.mode==="select"&&n))return!1;let o=be(e._scene,n),a=o&&(o.routing??"straight")!=="orthogonal"?ot(e._scene,o):null;if(!(o&&a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Zo/r,i=s*s,l=[...o.waypoints??[]],c=!1;for(let u=0;u<l.length;u++)if(KM(v(l[u]),t,i)){e.isHandleDoubleClick(t)?e.deleteWaypoint(n,u):e.beginWaypointDrag(n,u,!1),c=!0;break}if(!c){let u=Vf(e._scene,o)??[];for(let d=0;d<u.length;d++)if(KM(v(u[d]),t,i)){e.beginWaypointDrag(n,d,!0),c=!0;break}}return c?(e.cancelLongPress(),!0):!1},XW=(e,t,n)=>{let o=I(e._scene,t);if(!o)return!1;let a=e._scene.viewport.zoom||1,{names:r,worldPoints:s}=_o(o,Lo/a),i=(Xo+e.anchorStartHitSlop)/a,l=null,c=i*i;for(let u=0;u<s.length;u++){let d=v(s[u]),f=d.x-n.x,p=d.y-n.y,h=f*f+p*p;h<=c&&(c=h,l=v(r[u]))}return l===null?!1:(e.cancelLongPress(),e.linkDragFromAnchor={fromElement:t,fromWorld:Yt(o,{kind:"named",name:l}),anchorName:l,origin:n,moved:!1},!0)},YW=(e,t,n,o)=>{if(e.readOnly||!(e.mode==="select"&&!t.modifiers.shift&&!t.modifiers.meta&&!t.modifiers.ctrl&&o.kind!=="rotate-handle"))return!1;let a=e._selection.size===1?[...e._selection][0]:null;return!!(a&&XW(e,a,n))},KW=(e,t,n)=>{if(!((t.modifiers.meta||t.modifiers.ctrl)&&n.kind==="element"&&e.elementLink(n.id)!==null)&&n.kind==="element"&&!e._selection.has(n.id)){let r=t.modifiers.shift||t.modifiers.meta||t.modifiers.ctrl;e._selection=r?Xt(e._selection,n.id):wt(n.id),r&&(e.additivePressAdded=n.id),!r&&e._selectedLinks.size>0&&(e._selectedLinks=yt),e.notify()}},$W=(e,t,n)=>{if(e.readOnly)return n;if(t.modifiers.alt&&e.mode==="select"&&n.kind==="element"&&e._selection.has(n.id)){let o=e.duplicateSelectedInPlace(n.id);if(o!==null)return{kind:"element",id:o,bounds:n.bounds}}return n},QM=(e,t,n)=>{if(!n.has(t)){n.add(t);for(let o of e._scene.elements.values())o.parentId===t&&QM(e,o.id,n)}},QW=(e,t)=>{if(t.kind==="element"){let n=I(e._scene,t.id),o=n!==void 0&&ze(n),a=n!==void 0&&Be(n),r=e._selection.has(t.id);if(r||o||a){let s=new Set;if(r)for(let l of e.expandSelectionWithDescendants()){let c=I(e._scene,l);c&&e.isElementManipulable(c)&&s.add(l)}if(o&&QM(e,t.id,s),a){s.add(t.id);for(let l of e._scene.elements.values())l.frameId===t.id&&s.add(l.id)}let i=dS(e._scene,s,e._selectedLinks);if(s.size>1||i.size>0){let l=new Map;for(let c of s){let u=I(e._scene,c);u&&l.set(c,u.position)}e.groupMoveOrigin=l,e.groupLinkMoveOrigin=i.size>0?i:null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null},JW=(e,t)=>{if(t.kind==="group-handle"){let n=new Map;for(let a of e.expandSelectionWithDescendants()){let r=I(e._scene,a);r&&n.set(a,{position:r.position,bounds:z(r),scale:r.scale})}let o=dS(e._scene,new Set(n.keys()),e._selectedLinks);e.groupResizeOrigin={combined:t.bounds,elements:n,links:o}}else e.groupResizeOrigin=null},eq=(e,t)=>{if(t.kind==="rotate-handle"){let n=new Map;for(let o of e.expandSelectionWithDescendants()){let a=I(e._scene,o);a&&n.set(o,{position:a.position,rotation:a.rotation})}e.rotateGestureOrigin={pivot:t.pivot,origin:n}}else e.rotateGestureOrigin=null},tq=(e,t,n)=>{let o=e.panGesture;if(o?.pointerId!==t.pointerId)return!1;let a=n.point.x-o.lastPoint.x,r=n.point.y-o.lastPoint.y;return o.lastPoint=n.point,!o.moved&&U.distance(o.startPoint,n.point)>mc&&(o.moved=!0),e.panBy({x:a,y:r}),!0},nq=(e,t,n)=>(e.activePointers.has(t.pointerId)&&e.activePointers.set(t.pointerId,n.point),e.pinch.isActive()?(e.applyPinch(),!0):!1),oq=(e,t,n)=>{if(e.touchPanCandidate!==null&&e.activePointers.size===1&&U.distance(e.touchPanCandidate,n.point)>mc){let o=e.touchPanCandidate;e.touchPanCandidate=null,e.beginPanGesture(t.pointerId,t.button,o);let a=e.panGesture;return a&&(a.moved=!0,e.panBy({x:n.point.x-o.x,y:n.point.y-o.y}),a.lastPoint=n.point),!0}return!1},aq=(e,t)=>e.isDraggingSegment?(e.updateSegmentDrag(t),!0):!1,rq=(e,t)=>e.isDraggingWaypoint?(e.updateWaypointDrag(t),!0):!1,sq=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;if(!n.moved){let o=t.x-n.origin.x,a=t.y-n.origin.y;if(o*o+a*a<ki*ki)return!0;n.moved=!0}return e.applyLinkPreview(n.fromElement,n.fromWorld,t),e.updateHoveredLinkTarget(t),!0},iq=(e,t)=>e.editingTextElement!==null&&e.isTextDragging?(e.extendTextSelectionToPoint(t),!0):!1,lq=(e,t,n)=>e.brushStroke?(e.extendBrushStroke(t,n),!0):!1,cq=(e,t,n)=>e.eraseStroke?(e.extendEraseStroke(t,n),!0):!1,uq=(e,t)=>e.laserDrawing?(e.extendLaserStroke(t),!0):!1,dq=(e,t)=>{if(!e.dragElementId)return;let n=e.dragElementId,o=new Set([n]);for(let r of e._scene.elements.values()){let s=r.parentId;for(let i=0;s&&i<64;i++){if(s===n){o.add(r.id);break}s=e._scene.elements.get(s)?.parentId}}let a=zf(e._scene,t,o);if(a){let r=to(a);if(r){let s={id:a.id,dropZone:r};(e.containerHover?.id!==s.id||e.containerHover.dropZone!==s.dropZone)&&(e.containerHover=s,e.notify())}}else e.containerHover!==null&&(e.containerHover=null,e.notify())},fq=(e,t)=>{let n=e.annotationDrag;if(!n)return!1;let o=t.x-n.originWorldPoint.x,a=t.y-n.originWorldPoint.y;(o!==0||a!==0)&&(n.moved=!0);let r=e._scene.annotations.get(n.id);if(r){let s={x:n.originPosition.x+o,y:n.originPosition.y+a},i={...r,position:s},l=new Map(e._scene.annotations);l.set(n.id,i),e._scene={...e._scene,annotations:l},e.notify()}return!0},pq=(e,t)=>{for(let o of e.cursorListeners)o(t);let n=e.actor.getSnapshot().context;if(n.pressOrigin&&n.mode!=="select"&&n.mode!=="draw-edge"&&e.isDrawingPhase(n)&&(e.drawingPreview=bp(n.pressOrigin,t)),n.mode==="draw-edge"?e.updateHoveredLinkTarget(t):e.hoveredLinkTarget!==null&&(e.hoveredLinkTarget=null,e.notify()),!n.pressOrigin){let o=e.hitTest(t),a=o.kind==="element"?e._scene.elements.get(o.id):void 0;e.hoverAnimatedElement(a&&ct(a)&&a.animationKind?a.id:null),e.setHoverCursorWorld(e.mode==="select"?t:null),e.mode==="erase"&&e.notify()}e.actor.send({type:"POINTER_MOVE",point:t})},hq=(e,t)=>e.panGesture?.pointerId!==t.pointerId?!1:(e.endPanGesture(),!0),mq=e=>e.pinch.isActive()?(e.activePointers.size<2&&e.pinch.end(),!0):!1,yq=e=>e.isDraggingSegment?(e.endSegmentDrag(),!0):!1,gq=e=>e.isDraggingWaypoint?(e.endWaypointDrag(),!0):!1,xq=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;e.linkDragFromAnchor=null;let o=Pc(t,e.host),a=e.screenToWorld(o.point);if(n.moved){let r=e.hitTest(a),s=r.kind==="element"?r.id:null;e.applyEmit({type:"CREATE_EDGE",fromElement:n.fromElement,toElement:s,fromPoint:n.fromWorld,toPoint:a})}else{let r=I(e._scene,n.fromElement),s=e._scene.viewport.zoom||1,i=!1;if(r){let{names:l,worldPoints:c}=_o(r,Lo/s),u=l.indexOf(n.anchorName);if(u>=0){let d=v(c[u]),f=e.anchorClickRadius/s,p=d.x-n.origin.x,h=d.y-n.origin.y;i=p*p+h*h<=f*f}}if(i)e.createLinkedElementFromAnchor(n.fromElement,n.anchorName);else{let l=e.hitTest(a);l.kind==="empty"?e.applyEmit({type:"SELECT_CLEAR"}):l.kind==="element"?e.applyEmit({type:"SELECT_REPLACE",id:l.id}):l.kind==="link"&&e.applyEmit({type:"SELECT_EDGE_REPLACE",id:l.id})}}return e.edgePreview=null,e.hoveredLinkTarget=null,e.notify(),!0},bq=e=>e.editingTextElement!==null&&e.isTextDragging?(e.endTextDragSelect(),!0):!1,Aq=e=>e.brushStroke?(e.commitBrushStroke(),!0):!1,vq=e=>e.eraseStroke?(e.commitEraseStroke(),!0):!1,Sq=e=>e.laserDrawing?(e.endLaserStroke(),!0):!1,Lq=e=>{let t=e.annotationDrag;if(!t)return!1;if(e.annotationDrag=null,t.moved){let n=e._scene.annotations.get(t.id);if(n){let o={...n,position:t.originPosition},a=new Map(e._scene.annotations);a.set(t.id,o),e._scene={...e._scene,annotations:a};let r=qa(e._scene,t.id,()=>n);e._scene=r.scene,e._history.push(r.patch),e.notify()}}return!0},kq=(e,t,n)=>{let o=e.actor.getSnapshot().context.pressOrigin,a=t.modifiers.meta||t.modifiers.ctrl;if(o&&a){let r=e._scene.viewport.zoom||1;if(Math.hypot(n.x-o.x,n.y-o.y)*r<mc){let i=e.hitTest(n);if(i.kind==="element"){let l=e.elementLink(i.id);if(l)return e.openLink(l),e.actor.send({type:"POINTER_UP",point:n}),e.commitGesture(),!0}}}return!1},wq=(e,t)=>{let n=e.actor.getSnapshot().context,o=r5(n,t);o?.type==="SELECT_TOGGLE"&&e.additivePressAdded===o.id&&(o=null),e.additivePressAdded=null,!e.routeIsolationClick(o,t)&&o&&e.applyEmit(o),e.drawingPreview=null;let r;n.mode==="draw-edge"?r=e.hitTest(t):n.pressTarget?.kind==="edge-endpoint"&&(r=e.linkAttachTargetAt(t)),e.actor.send(r!==void 0?{type:"POINTER_UP",point:t,target:r}:{type:"POINTER_UP",point:t}),e.applyContainerDrop(t),e.reconcileFrameMembership(),e.commitGesture();let s=n.pressOrigin;if(s){let i=e._scene.viewport.zoom||1;if(Math.hypot(t.x-s.x,t.y-s.y)*i<mc){let c=e.hitTest(t);if(c.kind==="element"){let u=e._scene.elements.get(c.id);u&&ct(u)&&u.animationKind&&e.togglePlayback(u.id)}}}e.refreshCursor(t)},$M=(e,t,n)=>{if(t.deltaY===0)return;let a=1-(Math.abs(t.deltaY)>g2?g2*Math.sign(t.deltaY):t.deltaY)*pI/100;if(a<=0)return;let r=e._scene.viewport.zoom,s=zp(r*a);if(s===r)return;let i=e.screenToWorld(n);e.zoomAt(s/r,i)},_q=(e,t)=>{let n=t.deltaX,o=t.deltaY;t.shiftKey&&n===0&&(n=o,o=0),e.panBy({x:-n*m2,y:-o*m2})},JM=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!ea(c.target)&&e.host.focus({preventScroll:!0});let u=Pc(c,e.host);if(e.additivePressAdded=null,RW(e,c,u)||OW(e,c,u))return;e.startLongPress(u.point);let d=e.screenToWorld(u.point);if(HW(e,d)||DW(e,d)||UW(e,d)||GW(e,d,c.detail)||NW(e,d,c.pressure)||zW(e,d,u.modifiers.alt,u.modifiers.shift)||FW(e,d)||WW(e,d)||qW(e,d)||jW(e,d)||VW(e,d)||ZW(e,d))return;let f=e.hitTest(d);YW(e,u,d,f)||(KW(e,u,f),f=$W(e,u,f),e.dragElementId=f.kind==="element"?f.id:null,e.containerHover=null,QW(e,f),JW(e,f),eq(e,f),e.touchPanCandidate=u.kind==="touch"&&e.mode==="select"&&f.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:d,target:f,modifiers:u.modifiers}))},n=c=>{let u=Pc(c,e.host);if(tq(e,c,u)||nq(e,c,u)||oq(e,c,u))return;e.longPress.cancelIfMovedBeyond(u.point,mc);let d=e.screenToWorld(u.point);e.lastPointerWorld=d,e.refreshCursor(d),!PW(e,d)&&(aq(e,d)||rq(e,d)||sq(e,d)||iq(e,d)||lq(e,d,c.pressure)||cq(e,d,u.modifiers.alt)||uq(e,d)||(dq(e,d),!fq(e,d)&&pq(e,d)))},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,hq(e,c)||mq(e)||(e.cancelLongPress(),BW(e))||yq(e)||gq(e)||xq(e,c)||bq(e)||Aq(e)||vq(e)||Sq(e)||Lq(e))return;let u=Pc(c,e.host),d=e.screenToWorld(u.point);kq(e,u,d)||wq(e,d)},a=c=>{if(e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,e.panGesture?.pointerId===c.pointerId){e.endPanGesture();return}if(e.pinch.isActive()){e.activePointers.size<2&&e.pinch.end();return}if(e.cancelLongPress(),e.linkDragFromAnchor){e.linkDragFromAnchor=null,e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.brushStroke){e.cancelBrushStroke();return}if(e.eraseStroke){e.cancelEraseStroke();return}if(e.laserDrawing){e.endLaserStroke();return}if(e.annotationDrag){let u=e.annotationDrag;e.annotationDrag=null;let d=e._scene.annotations.get(u.id);if(d){let f=new Map(e._scene.annotations);f.set(u.id,{...d,position:u.originPosition}),e._scene={...e._scene,annotations:f},e.notify()}return}e.drawingPreview=null,e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture()};e.host.addEventListener("pointerdown",t),e.host.addEventListener("pointermove",n),e.host.addEventListener("pointerup",o),e.host.addEventListener("pointercancel",a);let r=c=>{e.suppressNextContextMenu&&(e.suppressNextContextMenu=!1,c.preventDefault(),c.stopPropagation())};e.host.addEventListener("contextmenu",r,!0);let s=c=>{c.code!=="Space"&&c.key!==" "||ea(c.target)||e.spaceHeld||(e.spaceHeld=!0,e.refreshCursor(),c.preventDefault())},i=c=>{c.code!=="Space"&&c.key!==" "||e.spaceHeld&&(e.spaceHeld=!1,e.refreshCursor())};typeof window<"u"&&(window.addEventListener("keydown",s),window.addEventListener("keyup",i));let l=c=>{c.preventDefault();let u=e.host.getBoundingClientRect(),d={x:c.clientX-u.left,y:c.clientY-u.top};if(c.ctrlKey||c.metaKey){$M(e,c,d);return}if(c.deltaX!==0){_q(e,c);return}$M(e,c,d)};return e.host.addEventListener("wheel",l,{passive:!1}),()=>{e.host.removeEventListener("pointerdown",t),e.host.removeEventListener("pointermove",n),e.host.removeEventListener("pointerup",o),e.host.removeEventListener("pointercancel",a),e.host.removeEventListener("contextmenu",r,!0),e.host.removeEventListener("wheel",l),typeof window<"u"&&(window.removeEventListener("keydown",s),window.removeEventListener("keyup",i))}};var Ny=class{drawingPreview=null;edgePreview=null;lassoPreview=null;hoveredLinkTarget=null;hoverCursorWorld=null;annotationDrag=null;linkDragFromAnchor=null;pendingLinkDropMenu=null;lassoBaseSelection=null;lassoBaseLinks=null;groupMoveOrigin=null;groupLinkMoveOrigin=null;groupResizeOrigin=null;rotateGestureOrigin=null;resizeOriginElement=null;snapSuppressed=!1;transformAltKey=!1;transformShiftKey=!1;lastClickAt=0;lastClickWorldPoint=null;brushStroke=null;eraseStroke=null;laserStrokes=[];eraserTrail=[];laserDrawing=!1;lastPointerWorld=null;dragElementId=null;additivePressAdded=null;containerHover=null;activePointers=new Map;touchPanCandidate=null;spaceHeld=!1;panGesture=null;suppressNextContextMenu=!1;editingLinkCaption=null;resetPreviews(){this.drawingPreview=null,this.edgePreview=null,this.lassoPreview=null,this.hoveredLinkTarget=null,this.hoverCursorWorld=null}reset(){this.resetPreviews(),this.annotationDrag=null,this.linkDragFromAnchor=null,this.pendingLinkDropMenu=null,this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.groupMoveOrigin=null,this.groupLinkMoveOrigin=null,this.groupResizeOrigin=null,this.rotateGestureOrigin=null,this.resizeOriginElement=null,this.snapSuppressed=!1,this.transformAltKey=!1,this.transformShiftKey=!1,this.lastClickAt=0,this.lastClickWorldPoint=null,this.brushStroke=null,this.eraseStroke=null,this.laserStrokes=[],this.eraserTrail=[],this.laserDrawing=!1,this.lastPointerWorld=null,this.dragElementId=null,this.additivePressAdded=null,this.containerHover=null,this.activePointers.clear(),this.touchPanCandidate=null,this.spaceHeld=!1,this.panGesture=null,this.suppressNextContextMenu=!1,this.editingLinkCaption=null}};var Nc={stroke:OI,fill:null,opacity:DI,width:sp},zy=e=>({stroke:e.stroke,...e.fill!==null?{fill:e.fill}:{},...e.opacity!==1?{opacity:e.opacity}:{}}),eR=(e,t)=>e<=0?RI:Math.max(.5,e*t),tR=(e,t,n=sp)=>({points:[{x:0,y:0,width:eR(t,n)}],origin:e}),nR=(e,t,n,o=sp)=>{let a=e.origin;e.points.push({x:t.x-a.x,y:t.y-a.y,width:eR(n,o)})},mS=(e,t=PI)=>Ay(e,t,(n,o,a,r)=>({x:a.x,y:a.y,width:n.width+(o.width-n.width)*r})),Cq=(e,t)=>{if(t.fill===void 0||e.length<3)return!1;let n=e[0],o=e[e.length-1];if(!n||!o)return!1;let a=o.x-n.x,r=o.y-n.y;return a*a+r*r<=v2*v2},oR=(e,t,n,o,a=zy(Nc))=>{if(!t||t.points.length===0)return null;let r=Ae([...e.elements.values()].filter(c=>c.layerId===n).map(c=>c.order)),s=mS(t.points),i={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:r,style:a,points:s,...Cq(s,a)?{closed:!0}:{}},l=Fe(e,i);return{scene:l.scene,patch:l.patch,elementId:o}},yS=e=>Ze(`brush-${e}-${Date.now().toString(36)}`);var aR=(e,t,n,o)=>{if(n.x===0&&n.y===0)return null;let a=e,r=[],s=0;for(let i of t){let l=I(a,i);if(!l||o(l.layerId))continue;let c=J(a,i,u=>({...u,position:{x:u.position.x+n.x,y:u.position.y+n.y}}));a=c.scene,r.push(c.patch),s++}return s===0?null:{scene:a,patches:r,moved:s}},Fy=(e,t,n)=>{if(t.size===0&&n.size===0)return null;let o=e,a=[],r=new Set,s=i=>{if(r.has(i)||!o.links.has(i))return;let l=pi(o,i);o=l.scene,a.push(l.patch),r.add(i)};for(let i of t){for(let c of[...o.links.values()])(c.from.kind!=="point"&&c.from.elementId===i||c.to.kind!=="point"&&c.to.elementId===i)&&s(c.id);let l=dn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},rR=(e,t,n)=>{let o=[...t];if(o.length===0)return null;let a=e,r=[],s=[];for(let i of o){let l=I(a,i);if(!l)continue;let c=Ze(`shape-${n()}-${Date.now().toString(36)}`),u=Ae([...a.elements.values()].filter(p=>p.layerId===l.layerId).map(p=>p.order)),d={...l,id:c,position:{x:l.position.x+10,y:l.position.y+10},order:u},f=Fe(a,d);a=f.scene,r.push(f.patch),s.push(c)}return{scene:a,patches:r,newIds:s}},sR=(e,t,n)=>{let o=Pe;for(let a of t)e.elements.has(a)&&(o=Xt(o,a));return oi(o,n)?null:o},iR=(e,t)=>{let n=Pe;for(let o of e.elements.values()){let a=e.layers.get(o.layerId);!a||!a.visible||a.locked||(n=Xt(n,o.id))}return oi(n,t)?null:n},lR=e=>{let t=new Set;for(let n of e.links.values()){let o=e.layers.get(n.layerId);!o||!o.visible||o.locked||t.add(n.id)}return t},cR=(e,t,n)=>{let o=[];for(let i of t)e.elements.has(i)&&o.push(i);if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>({...c,style:{...c.style,...n}}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},uR=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0||!fe(r))return null;let s=uA(r,n,o,a);if(s===r)return null;let i=J(e,t,()=>s);return{scene:i.scene,patch:i.patch}},dR=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l!==void 0&&fe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>({...c,...n}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},fR=(e,t,n)=>{let o=n==="increase",a=o?k2:1/k2,r=e,s=[];for(let l of t){let c=I(r,l);if(c===void 0||!fe(c))continue;let u=Math.round(c.fontSize*a),d=o?Math.max(c.fontSize+1,u):Math.min(c.fontSize-1,u),f=Math.min(s4,Math.max(Y0,d));if(f===c.fontSize)continue;let p=J(r,l,h=>({...h,fontSize:f}));r=p.scene,s.push(p.patch)}let i=s[0];return i===void 0?null:{scene:r,patch:s.length===1?i:{kind:"batch",patches:s}}},pR=(e,t)=>{let n=[];return e.x>0?n.push(`${e.x} px right`):e.x<0&&n.push(`${-e.x} px left`),e.y>0?n.push(`${e.y} px down`):e.y<0&&n.push(`${-e.y} px up`),`Moved ${t===1?"shape":`${t} shapes`} ${n.join(" and ")}`},gS=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t},xS=(e,t,n,o,a)=>{let r=n==="left"?{x:-1,y:0}:n==="right"?{x:1,y:0}:n==="up"?{x:0,y:-1}:{x:0,y:1},s=null,i=1/0;for(let l of e.elements.values()){if(l.parentId!==void 0||t.has(l.id)||!a(l))continue;let c=z(l),u=c.x+c.width/2-o.x,d=c.y+c.height/2-o.y,f=u*r.x+d*r.y;if(f<=0)continue;let p=Math.abs(u*r.y-d*r.x);if(p>f)continue;let h=f+p;h<i&&(i=h,s=l.id)}return s};var hR=(e,t=!1)=>({pending:new Set,last:e,erased:new Map,strokeMode:t}),mR=(e,t,n,o,a=!1,r=!1)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i),c=Math.max(1,Math.ceil(l/BI)),u=!1;for(let d=1;d<=c;d++){let f=d/c,p=n({x:e.x+s*f,y:e.y+i*f});p&&(r&&p.type==="brush"||(a?o.delete(p.id)&&(u=!0):o.has(p.id)||(o.add(p.id),u=!0)))}return u},yR=(e,t)=>{let n=Pe;for(let o of t)e.elements.has(o)&&(n=Xt(n,o));return n.size===0?null:Fy(e,n,new Set)};var bS=1e-6,AS=e=>{let t=e.points,n=t.length,o=new Array(Math.max(1,n)).fill(0),a=0;for(let r=1;r<n;r++){let s=v(t[r-1]),i=v(t[r]);a+=Math.hypot(i.x-s.x,i.y-s.y),o[r]=a}return{pts:t,position:e.position,cum:o,total:a}},Hy=(e,t)=>{let{pts:n,cum:o,total:a}=e,r=n.length;if(r===0)return{x:0,y:0,width:0};if(r===1||t<=0)return{...v(n[0])};if(t>=a)return{...v(n[r-1])};let s=0,i=r-1;for(;i-s>1;){let f=s+i>>1;v(o[f])<=t?s=f:i=f}let l=v(n[s]),c=v(n[s+1]),u=v(o[s+1])-v(o[s]),d=u>0?(t-v(o[s]))/u:0;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d,width:l.width+(c.width-l.width)*d}},xR=(e,t,n,o)=>{let a=Hy(e,t);return za.distanceToSegmentSq({x:e.position.x+a.x,y:e.position.y+a.y},n,o)},gR=(e,t,n,o,a,r)=>{let s=t,i=n;for(let l=0;l<HI;l++){let c=(s+i)/2;xR(e,c,o,a)<=r?i=c:s=c}return i},bR=(e,t,n,o)=>{let{pts:a,cum:r,total:s}=e,i=a.length;if(i===0)return[];let l=o*o;if(s===0){let y=v(a[0]);return za.distanceToSegmentSq({x:e.position.x+y.x,y:e.position.y+y.y},t,n)<=l?[[0,0]]:[]}let c=Math.min(t.x,n.x)-o,u=Math.max(t.x,n.x)+o,d=Math.min(t.y,n.y)-o,f=Math.max(t.y,n.y)+o,p=e.position.x,h=e.position.y,m=Math.max(FI,o*zI),x=[];for(let y=0;y<i-1;y++){let g=v(a[y]),b=v(a[y+1]);if(Math.max(g.x,b.x)+p<c||Math.min(g.x,b.x)+p>u||Math.max(g.y,b.y)+h<d||Math.min(g.y,b.y)+h>f)continue;let A=v(r[y]),_=v(r[y+1])-A;if(_<=0)continue;let T=Math.max(1,Math.ceil(_/m)),w=-1,S=A;for(let L=0;L<=T;L++){let M=L===T?A+_:A+_*L/T,B=xR(e,M,t,n)<=l;B&&w<0?w=L===0?M:gR(e,S,M,t,n,l):!B&&w>=0&&(x.push([w,gR(e,M,S,t,n,l)]),w=-1),S=M}w>=0&&x.push([w,A+_])}return Fp(x)},Fp=e=>{if(e.length<=1)return e.map(o=>[o[0],o[1]]);let t=[...e].sort((o,a)=>o[0]-a[0]),n=[];for(let[o,a]of t){let r=n[n.length-1];r&&o<=r[1]+bS?a>r[1]&&(r[1]=a):n.push([o,a])}return n},vS=e=>e.reduce((t,[n,o])=>t+(o-n),0),AR=(e,t)=>{let n=Fp(e),o=[],a=0;for(let[r,s]of n)r>a+bS&&o.push([a,r]),s>a&&(a=s);return t>a+bS&&o.push([a,t]),o};var vR=1e-6,SR=(e,t,n)=>{let o=AS(e);if(o.total===0)return[];let a=AR(t,o.total),r=[],s=e.order,i=0;for(let[l,c]of a){if(c-l<UI)continue;let u=[Hy(o,l)];for(let m=0;m<o.pts.length;m++){let x=v(o.cum[m]);x>l+vR&&x<c-vR&&u.push({...v(o.pts[m])})}if(u.push(Hy(o,c)),u.length<2)continue;let d=v(u[0]),f={x:e.position.x+d.x,y:e.position.y+d.y},p=u.map(m=>({x:m.x-d.x,y:m.y-d.y,width:m.width})),h=i===0?e.order:fc(s,null);s=h,i++,r.push({id:n(),layerId:e.layerId,type:"brush",position:f,rotation:0,scale:{x:1,y:1},order:h,style:e.style,points:p})}return r},LR=(e,t,n,o,a)=>{let r=bR(AS(e),n,o,a);return r.length===0?t.length>0?Fp(t):[]:Fp([...t,...r])};var kR=(e,t,n)=>{let o=e,a=[],r=[],s=[],i=new Set;for(let[l,c]of t){if(c.length===0)continue;let u=e.elements.get(l);if(u===void 0||!Ha(u))continue;let d=SR(u,c,n);for(let p of[...o.links.values()])if(!i.has(p.id)&&(si(p.from)===u.id||si(p.to)===u.id)){let h=pi(o,p.id);o=h.scene,a.push(h.patch),i.add(p.id)}let f=dn(o,u.id);o=f.scene,a.push(f.patch),r.push(u.id);for(let p of d){let h=Fe(o,p);o=h.scene,a.push(h.patch),s.push(p.id)}}return a.length===0?null:{scene:o,patches:a,removedIds:r,addedIds:s}},wR=(e,t)=>{let n=[],o=new Set;for(let[a,r]of t){if(r.length===0)continue;let s=e.elements.get(a);if(s===void 0||!Ha(s))continue;let i=0,l=SR(s,r,()=>Ze(`stroke-erase-preview-${s.id}-${i++}`));o.add(s.id),n.push(...l)}return o.size===0?null:{fragments:n,hidden:o}};var _R=e=>{let t=e.metadata,n=t&&"image"in t?t.image:void 0,o=e.animationData,a={...e};if(o!==void 0&&delete a.animationData,t){let s={...t};delete s.image,a.metadata=s}let r=structuredClone(a);return n!==void 0&&(r.metadata={...r.metadata,image:n}),o!==void 0&&(r.animationData=o),r},CR=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(_R(a))}return n},ER=(e,t,n,o,a)=>{if(n.length===0)return{scene:e,newIds:[]};let r=0,s=0;for(let f of n)r+=f.position.x,s+=f.position.y;r/=n.length,s/=n.length;let i=o?{x:o.x-r,y:o.y-s}:{x:10,y:10},l=[],c=[],u=e;for(let f of n){let p=a(),h=Ae([...u.elements.values()].filter(y=>y.layerId===f.layerId).map(y=>y.order)),m={..._R(f),id:p,position:{x:f.position.x+i.x,y:f.position.y+i.y},order:h},x=Fe(u,m);u=x.scene,l.push(x.patch),c.push(p)}let d=l[0];return d!==void 0&&t.push(l.length===1?d:Vo(l)),{scene:u,newIds:c}};var TR=(e,t)=>CR(e,t),IR=(e,t,n,o,a)=>{let r=ER(e,t,n,o,()=>Ze(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},MR=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t};var RR=(e,t,n)=>{let o=Ae([...e.layers.values()].map(s=>s.order)),r=XA(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},OR=(e,t,n)=>{if(!e.layers.has(t))return null;if(e.layers.size<=1)throw new Error("Cannot remove the only remaining layer.");let o=[],a=e;for(let i of[...a.elements.values()]){if(i.layerId!==t)continue;let l=dn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=pi(a,i.id);a=l.scene,o.push(l.patch)}let r=YA(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Pf)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},DR=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=$f(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},PR=(e,t)=>{if(!e.layers.has(t))return null;let n=$f(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},BR=(e,t)=>{if(!e.layers.has(t))return null;let n=$f(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},NR=(e,t,n)=>{if(!e.layers.has(n)||t.size===0)return null;let o=e,a=[];for(let r of t){let s=I(o,r);if(!s||s.layerId===n)continue;let i=J(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},zR=e=>ln(`layer-${e}-${Date.now().toString(36)}`);var FR=(e,t,n,o)=>{let a=new Date().toISOString(),r=Cf(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:oc(o("cmt")),authorId:n.id,authorName:n.name,body:t.firstComment.trim(),createdAt:a});let i={id:r,elementId:t.elementId??null,position:t.position,resolved:!1,thread:s,createdAt:a},l=KA(e,i);return{scene:l.scene,patch:l.patch,id:r}},HR=(e,t)=>{if(!e.annotations.has(t))return null;let n=$A(e,t);return{scene:n.scene,patch:n.patch}},UR=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=qa(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},GR=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:oc(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=qa(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},WR=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=qa(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},qR=(e,t)=>{let n=e.viewport.zoom,o=j0/n,a=[...e.annotations.values()];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s===void 0)continue;let i=Kr(e,s),l=t.x-i.x,c=t.y-i.y;if(l*l+c*c<=o*o)return s.id}return null};var jR=(e,t)=>{let n=null,o="";for(let a of e.elements.values()){if(!Be(a))continue;let r=a.position.x,s=a.width*a.scale.x,i=24*a.scale.y,l=a.position.y-i;t.x>=r&&t.x<=r+s&&t.y>=l&&t.y<=l+i&&(n===null||a.order>o)&&(n=a.id,o=a.order)}return n},VR=(e,t,n)=>{let o=I(e,t);if(o===void 0||!Be(o))return null;let a=n.trim(),r=o.name??"";if(a===r)return null;let s=J(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var Eq={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},Tq=(e,t)=>{if(typeof e=="string")return e;let n=e.hotspot?.x??0,o=e.hotspot?.y??0;return`${e.url2x!==void 0?`image-set(url("${e.url}") 1x, url("${e.url2x}") 2x)`:`url("${e.url}")`} ${String(n)} ${String(o)}, ${e.fallback??t}`},Iq=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:Tq(o,n)},Mq=(e,t)=>{if(e.mode!=="select"||e._selection.size!==1)return!1;let n=[...e._selection][0];if(n===void 0)return!1;let o=I(e._scene,n);if(!o)return!1;let a=e._scene.viewport.zoom||1,{worldPoints:r}=_o(o,Lo/a),s=(Xo+e.anchorStartHitSlop)/a,i=s*s;for(let l of r){let c=l.x-t.x,u=l.y-t.y;if(c*c+u*u<=i)return!0}return!1},ZR=(e,t)=>{let n=(a,r)=>Iq(e,a,r),o=a=>n(Eq[a],x4(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.annotationDrag?.moved===!0)return n("move","grabbing");if(e.brushStroke)return n("draw","crosshair");if(e.gestureTx){let a=e.actor.getSnapshot().context.pressTarget;if(a&&(a.kind==="handle"||a.kind==="group-handle"))return o(a.handle);if(a?.kind==="rotate-handle")return n("rotate","grabbing");if(a&&(a.kind==="element"||a.kind==="link"||a.kind==="edge-endpoint"))return n("move","grabbing")}if(e.isEyedropperArmed)return n("draw","crosshair");if(e.editingTextElement!==null)return n("text","text");if(e.spaceHeld||e.mode==="hand")return n("pan-ready","grab");switch(e.mode){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":case"laser":case"eyedropper":case"crop":return n("draw","crosshair");case"erase":return n("erase","none");case"draw-text":return n("text","text");default:break}if(t){if(Mq(e,t))return n("link-start","crosshair");let a=e.hitTest(t);switch(a.kind){case"handle":case"group-handle":return o(a.handle);case"rotate-handle":return n("rotate","grab");case"edge-endpoint":return n("link-handle","grab");case"annotation":return n("annotation","pointer");default:return n("default","default")}}return n("default","default")};var Uy=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},YR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=Ae([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=J(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},KR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=dc([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=J(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},$R=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(_t),s=r.find(u=>u.order>a.order)??null;if(!s)return null;let i=r.find(u=>u.order>s.order)??null,l=i?fc(s.order,i.order):Ae(r.map(u=>u.order));if(l===a.order)return null;let c=J(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},QR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Pf),s=r.find(u=>u.order<a.order)??null;if(!s)return null;let i=r.find(u=>u.order<s.order)??null,l=i?fc(i.order,s.order):dc(r.map(u=>u.order));if(l===a.order)return null;let c=J(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},XR=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(_t),o=qA(null,null,n.length),a=0;return n.forEach((r,s)=>{let i=o[s];i===void 0||i===r.order||(t(r,i),a++)}),a},JR=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=XR([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=J(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=XR([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=et(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var eO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=Math.max(1,n.cols??Math.ceil(Math.sqrt(a.length))),s=n.gap??16,i=P0(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:Q(e,i),patch:i,count:a.length,cols:r}:null},tO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=B0(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:Q(e,i),patch:i,count:a.length,direction:r}:null},SS=(e,t)=>{let n=[],o=new Set;for(let a of t){let r=I(e,a);if(!r)continue;let s=r,i=!1;for(let l=0;s?.parentId&&l<64;l++){if(t.has(s.parentId)){i=!0;break}s=I(e,s.parentId)}i||o.has(r.id)||(o.add(r.id),n.push(r))}return n},nO=(e,t)=>{let n=new Set,o=a=>{if(!(n.has(a)||!I(e,a))){n.add(a);for(let s of e.elements.values())s.parentId===a&&o(s.id)}};for(let a of t)o(a);return n},oO=(e,t,n)=>{let o=SS(e,t),a=o[0];if(o.length<2||a===void 0)return null;let r=a.layerId,s=Ae([...e.elements.values()].filter(d=>d.layerId===r).map(d=>d.order)),i={id:n,layerId:r,type:"group",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:s,style:{}},l=e,c=[],u=Fe(l,i);l=u.scene,c.push(u.patch);for(let d of o){let f=J(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},aO=(e,t)=>{let n=[...t].map(s=>I(e,s)).filter(s=>s!==void 0&&ze(s));if(n.length===0)return null;let o=e,a=[],r=new Set;for(let s of n){let i=[...o.elements.values()].filter(c=>c.parentId===s.id);for(let c of i){let u=J(o,c.id,d=>{let f={...d};return delete f.parentId,f});o=u.scene,a.push(u.patch),r.add(c.id)}let l=dn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},rO=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(_t),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(_t);for(let u of c)a.push(u.id)}if(a.length===0)return null;let r=t?a.indexOf(t):-1;n==="next"?r=r===-1?0:(r+1)%a.length:r=r===-1?a.length-1:(r-1+a.length)%a.length;let s=a[r];if(!s)return null;let i=I(e,s);return{id:s,name:i?JA(i):s}},sO=e=>Ze(`group-${e}-${Date.now().toString(36)}`);var iO=/^(https?:|mailto:)/i,Rq=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,lO=e=>{let t=e.trim();return t===""?null:iO.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:Rq.test(t)?`mailto:${t}`:`https://${t}`},Gy=e=>e&&iO.test(e.trim())?e.trim():null,cO=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l&&(l.href??null)!==n&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>{let u={...c};return n===null?delete u.href:u.href=n,u});a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},Oq=(e,t,n)=>{if(t.kind==="anchor"){let o=t.metadata?.ref;if(o)return{kind:"anchor",elementId:e,anchor:o}}return t.kind==="outline"&&typeof t.metadata?.ratio=="number"?{kind:"outline",elementId:e,ratio:t.metadata.ratio}:{kind:"point",position:t.snapped}},uO=(e,t,n,o,a)=>{let r=t.snap({scene:e,probe:a,threshold:n,gesture:"draw-edge"}),s=u=>{if(o!==null){let d=r.all.find(f=>f.kind===u&&f.metadata?.elementId===o);if(d)return d}return r.all.find(d=>d.kind===u)},i=(u,d)=>{if(!u)return null;let f=u.metadata?.elementId;if(f===void 0)return null;let p=I(e,f);if(!p)return null;let h=Oq(f,u,p);return h.kind===d?h:null},l=i(s("anchor"),"anchor");if(l)return l;let c=i(s("outline"),"outline");return c||(o!==null&&I(e,o)?{kind:"floating",elementId:o}:{kind:"point",position:a})};var Dq=ns.rectangle,Pq=ns.ellipse,LS=(e,t,n,o,a,r)=>{let s=Array.from(e.elements.values()).filter(c=>c.layerId===a).map(c=>c.order),i=t==="frame"?dc(s):Ae(s),l={id:o,layerId:a,position:{x:n.x,y:n.y},rotation:0,scale:{x:1,y:1},order:i,width:n.width,height:n.height};return t==="rect"?{...l,type:"rectangle",style:{...Dq}}:t==="ellipse"?{...l,type:"ellipse",style:{...Pq}}:{...l,type:"frame",style:{fill:eI},name:r()}},dO=(e,t,n,o,a)=>{let r=Ae(Array.from(e.links.values()).filter(s=>s.layerId===a).map(s=>s.order));return{id:o,layerId:a,from:t,to:n,order:r,routing:hi,style:{...Mc},arrowheads:{to:np}}},fO=(e,t,n,o)=>{let a=dO(e,{kind:"point",position:t.from},{kind:"point",position:t.to},n,o);return t.points&&t.points.length>2?{...a,routedPoints:t.points.slice(1,-1)}:a},pO=(e,t,n,o,a,r)=>{let s=LS(e,t,n,o,a,r),i=Fe(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Hp=(e,t,n,o,a)=>{let r=dO(e,t,n,o,a),s=fi(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},zc=e=>`shape-${e}-${Date.now().toString(36)}`,Up=e=>`edge-${e}-${Date.now().toString(36)}`;var hO=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(c=>c.layerId===o).map(c=>c.order)),s=t==="draw-ellipse"?"ellipse":"rectangle",i=120,l=80;return{id:a,layerId:o,type:s,position:{x:n.x-i/2,y:n.y-l/2},rotation:0,scale:{x:1,y:1},order:r,style:{fill:"#bbb",stroke:"#000",strokeWidth:1},width:i,height:l}},mO=(e,t,n,o)=>{let a=Ae([...e.elements.values()].filter(r=>r.layerId===n).map(r=>r.order));return{id:o,layerId:n,type:"text",position:{x:t.x,y:t.y},rotation:0,scale:{x:1,y:1},order:a,text:"",fontFamily:KI,fontSize:YI,style:{fill:$I,textAlign:"left",textBaseline:"top"}}},wS=e=>Ze(`shape-${e}-${Date.now().toString(36)}`),yO=(e,t,n)=>{let o={...t.current,position:{x:n.x-t.halfWidth,y:n.y-t.halfHeight}},a={kind:"element",id:t.current.id,before:t.current,after:o};return{scene:Q(e,a),patch:a,next:o}},gO=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=zf(e,n,new Set([t.current.id]));if(!o)return null;let a={...t.current,parentId:o.id},r={kind:"element",id:t.current.id,before:t.current,after:a};return{scene:Q(e,r),patch:r,next:a}},xO=e=>{let t=z(e);return{scene:n=>{let o=Fe(n,e);return{scene:o.scene,patch:o.patch}},state:{current:e,halfWidth:t.width/2,halfHeight:t.height/2}}},bO=(e,t)=>({scene:dn(e,t).scene}),kS="__ghost-preview__",Fc="__ghost-preview-link__",AO=(e,t,n,o)=>{let a=I(e,n);if(!a||Ha(a))return null;let r={kind:"named",name:o},s=jo(a,r),i=z(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+l2,u={x:s.x*c,y:s.y*c},d={x:i.x+u.x,y:i.y+u.y,width:i.width,height:i.height},f=Yt(a,r),p=d.x+d.width/2,h=d.y+d.height/2,m={x:p-s.x*(l/2),y:h-s.y*(l/2)},x={...a,id:kS,position:{x:a.position.x+u.x,y:a.position.y+u.y}};fe(x)?x={...x,text:""}:Be(x)&&(x={...x,name:""});let y={x:i.x+i.width/2,y:i.y+i.height/2},g=Fe(e,x).scene,b=v(I(g,kS)),{ref:A}=Ga(b,y,So(b)),T=Hp(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:kS,anchor:A},Fc,t).scene,w=v(be(T,Fc));if((w.routing??"straight")==="orthogonal"){let S=tp(T,w);T=et(T,Fc,L=>({...L,routedPoints:S})).scene}return T={...T,links:new Map([[Fc,v(be(T,Fc))]])},{bounds:d,path:[f,m],element:x,ghostScene:T,ghostLinkId:Fc}},vO=(e,t,n,o,a,r)=>{let s=I(e,n);if(!s||Ha(s))return null;let i={kind:"named",name:o},l=jo(s,i),c=z(s),u={x:c.x+c.width/2,y:c.y+c.height/2},f=Math.abs(l.x)*c.width+Math.abs(l.y)*c.height+l2,p={x:l.x*f,y:l.y*f},h=Ae([...e.elements.values()].filter(A=>A.layerId===s.layerId).map(A=>A.order)),m={...s,id:a,position:{x:s.position.x+p.x,y:s.position.y+p.y},order:h};fe(m)?m={...m,text:""}:Be(m)&&(m={...m,name:""});let x=Fe(e,m),y=v(I(x.scene,a)),{ref:g}=Ga(y,u,So(y)),b=Hp(x.scene,{kind:"anchor",elementId:n,anchor:i},{kind:"anchor",elementId:a,anchor:g},r,t);return{scene:b.scene,addPatch:x.patch,linkPatch:b.patch}},SO=(e,t,n)=>{let o=e,a=[];for(let r of t){let s=I(o,r);if(!s)continue;let i=n.get(r);if(i===void 0)continue;let l=Ae([...o.elements.values()].filter(d=>d.layerId===s.layerId).map(d=>d.order)),c={...s,id:i,order:l};if(c.parentId!==void 0){let d=n.get(c.parentId);d!==void 0&&(c.parentId=d)}if(c.frameId!==void 0){let d=n.get(c.frameId);d!==void 0&&(c.frameId=d)}let u=Fe(o,c);o=u.scene,a.push(u.patch)}return{scene:o,patches:a}},LO=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(d=>d.layerId===t).map(d=>d.order)),s=a({id:o,layerId:t,position:n.world,order:r}),i=z(s),l={...s,position:{x:s.position.x+(n.world.x-(i.x+i.width/2)),y:s.position.y+(n.world.y-(i.y+i.height/2))}},c=Fe(e,l),u=et(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var _S=(e,t,n="fill")=>{let o=ci(e,t);if(o===void 0)return null;let{fill:a,stroke:r}=o.style;return(n==="fill"?a:r)??(n==="fill"?r:a)??null},Bq=new Set(["rectangle","ellipse","polygon"]),Nq=(e,t)=>[{x:e/2,y:0},{x:e,y:t/2},{x:e/2,y:t},{x:0,y:t/2}],kO=(e,t,n)=>{let o=e,a=[];for(let s of t){let i=I(o,s);if(i===void 0||!Bq.has(i.type)||i.type===n)continue;let l=Re(i),c=l.width,u=l.height,d=J(o,s,f=>{let{width:p,height:h,points:m,...x}=f;return n==="polygon"?{...x,type:"polygon",points:Nq(c,u)}:{...x,type:n,width:c,height:u}});o=d.scene,a.push(d.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}},wO=e=>{let t=Math.min(Math.max(e.x,0),1),n=Math.min(Math.max(e.y,0),1),o=Math.min(Math.max(e.width,0),1-t),a=Math.min(Math.max(e.height,0),1-n);return{x:t,y:n,width:o,height:a}},zq=(e,t)=>e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;var Wy={x:0,y:0,width:1,height:1},_O=["nw","ne","se","sw","n","e","s","w"],Hc=(e,t,n)=>Math.min(Math.max(e,t),n),qy=(e,t)=>{let n=Re(e),o=t.width||1,a=t.height||1,r=n.width/o,s=n.height/a;return{x:n.x-t.x*r,y:n.y-t.y*s,width:r,height:s}},CO=e=>{let t=Re(e),{x:n,y:o,width:a,height:r}=t,s=(i,l)=>Mn(e,{x:i,y:l});return{nw:s(n,o),n:s(n+a/2,o),ne:s(n+a,o),e:s(n+a,o+r/2),se:s(n+a,o+r),s:s(n+a/2,o+r),sw:s(n,o+r),w:s(n,o+r/2)}},Fq=e=>({west:e==="nw"||e==="w"||e==="sw",east:e==="ne"||e==="e"||e==="se",north:e==="nw"||e==="n"||e==="ne",south:e==="sw"||e==="s"||e==="se"}),EO=(e,t,n,o)=>{let a=qy(e,t),r=Re(e),s=li(e,o),i=r.x,l=r.y,c=r.x+r.width,u=r.y+r.height,{west:d,east:f,north:p,south:h}=Fq(n),m=a.x+a.width,x=a.y+a.height;d&&(i=Hc(s.x,a.x,c-ip)),f&&(c=Hc(s.x,i+ip,m)),p&&(l=Hc(s.y,a.y,u-ip)),h&&(u=Hc(s.y,l+ip,x));let y={x:i,y:l,width:c-i,height:u-l};return{crop:wO({x:(y.x-a.x)/a.width,y:(y.y-a.y)/a.height,width:y.width/a.width,height:y.height/a.height}),position:Mn(e,{x:y.x,y:y.y}),width:y.width,height:y.height}},TO=(e,t,n,o)=>{let a=qy(e,t),r=li(e,n),s=li(e,o),i=s.x-r.x,l=s.y-r.y;return{crop:{x:Hc(t.x-i/a.width,0,1-t.width),y:Hc(t.y-l/a.height,0,1-t.height),width:t.width,height:t.height}}},Hq=(e,t=1e-4)=>Math.abs(e.x)<t&&Math.abs(e.y)<t&&Math.abs(e.width-1)<t&&Math.abs(e.height-1)<t,IO=(e,t,n)=>{let o=I(e,t);if(o?.type!=="image")return null;let a=wO(n.crop),r=Hq(a)?void 0:a,s=o.crop;if(zq(r,s)&&o.position.x===n.position.x&&o.position.y===n.position.y&&o.width===n.width&&o.height===n.height)return null;let l=J(e,t,c=>{let{crop:u,...d}=c,f={...d,position:n.position,width:n.width,height:n.height};return r===void 0?f:{...f,crop:r}});return{scene:l.scene,patch:l.patch}},MO=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0)return null;let s=Re(r),i=s.width*r.scale.x,l=s.height*r.scale.y,c=n==="right"?i+ko:n==="left"?-(i+ko):0,u=n==="down"?l+ko:n==="up"?-(l+ko):0,d=Ae([...e.elements.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),{parentId:f,frameId:p,...h}=r,m={...h,id:o,position:{x:r.position.x+c,y:r.position.y+u},order:d},x=Fe(e,m),y={id:a,layerId:r.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:o},order:Ae([...x.scene.links.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),routing:hi,style:{...Mc},arrowheads:{to:np}},g=fi(x.scene,y);return{scene:g.scene,patches:[x.patch,g.patch],newElementId:o,linkId:a}},RO=(e,t,n,o,a,r)=>{let s=I(e,t);if(s===void 0||o<1)return{elements:[],links:[]};let i=Re(s),l=i.width*s.scale.x,c=i.height*s.scale.y,u=n==="left"||n==="right",d=n==="right"?l+ko:n==="left"?-(l+ko):0,f=n==="down"?c+ko:n==="up"?-(c+ko):0,p=u?c+ko:l+ko,h=Ae([...e.elements.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),m=Ae([...e.links.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),{parentId:x,frameId:y,...g}=s,b=[],A=[];for(let _=0;_<o;_++){let T=(_-(o-1)/2)*p,w=d+(u?0:T),S=f+(u?T:0),L=a();b.push({...g,id:L,position:{x:s.position.x+w,y:s.position.y+S},order:h}),A.push({id:r(),layerId:s.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:L},order:m,routing:hi,style:{...Mc},arrowheads:{to:np}})}return{elements:b,links:A}};var Uq="__draw-preview__",OO="__draw-preview-link__",DO=new WeakMap,Gq=e=>[e.scene,e.selection,e.selectedLinks,e.selectedLink,e.selectedAnnotation,e.mode,e.activeLayerId,e.cropFrame,e.cropGhost,e.flowchartPreview,e.strokeErasePreview,e.lassoPreview,e.drawingPreview,e.edgePreview,e.linkDragFromAnchor,e.hoveredLinkTarget,e.panGesture,e.pinchActive,e.gestureActive,e.linkEndpointDrag,e.linkSegmentDrag,e.linkWaypointDrag,e.hoverCursorWorld,e.anchorStartHitSlop,e.anchorClickRadius,e.containerHover,e.brushStroke,e.laserStrokes,e.eraserTrail,e.eraserCursor,e.peerCursors,e.peerSelections,e.debugHitZones,e.readOnly,e.groupMoveOrigin,e.editingText],Wq=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},PO=e=>{if(e.backgroundTarget){e.gridEnabled?Sp(e.scene,e.backgroundTarget):e.backgroundTarget.clear();let u=[];for(let d of e.selection){let f=I(e.scene,d);if(!f)continue;let p=f.style??{};u.push({loops:Bf(e.scene,f),outsetWorld:lA(p)})}u.length>0&&j5(e.backgroundTarget,oo(e.scene.viewport),u,e.scene.viewport.zoom||1)}let t=e.viewportWorld,n=e.dirtyWorld,o=e.dimElements,a=e.hideElements,r=o!==void 0&&o.size>0||a!==void 0&&a.size>0;if(e.tileComposeFn&&t&&!r)Cv(e.animationClock),e.mainTarget.clear(),e.tileComposeFn(e.scene,e.mainTarget,{viewport:t,changedElements:e.tileDirtyElements,zoomBucket:e.scene.viewport.zoom>0?2**Math.round(Math.log2(e.scene.viewport.zoom)):1,...e.sharedIndex?{index:e.sharedIndex}:{}}),Pn(e.scene,e.mainTarget,{viewportWorld:t});else{let u=e.sharedIndex;Za(e.scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,clock:e.animationClock,lod:ev,...o?{dimElements:o,dimOpacity:e.eraseActive?bI:xI}:{},...a?{hideElements:a}:{},...u?{spatialIndex:u}:{}}),Pn(e.scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}let s=Gq(e),i=DO.get(e.overlayTarget);if(i===void 0||!Wq(i.sig,s)){let u={};e.readOnly&&(u.readOnly=!0),e.cropFrame&&(u.cropFrame=e.cropFrame),e.cropGhost&&(u.cropGhost=e.cropGhost);let d=null;if(e.lassoPreview)u.drawingPreview=e.lassoPreview;else if(e.drawingPreview){let x=e.mode==="draw-rect"?"rect":e.mode==="draw-ellipse"?"ellipse":null;x?u.drawingPreviewElement=LS(e.scene,x,e.drawingPreview,Uq,e.activeLayerId,()=>""):u.drawingPreview=e.drawingPreview}let f=null;if(e.edgePreview){let x=fO(e.scene,e.edgePreview,OO,e.activeLayerId);f={...e.scene,links:new Map([[OO,x]])}}let p=null;if(e.flowchartPreview&&e.flowchartPreview.elements.length>0){u.flowchartPreviewElements=e.flowchartPreview.elements;let x=new Map(e.scene.elements);for(let g of e.flowchartPreview.elements)x.set(g.id,g);let y=new Map;for(let g of e.flowchartPreview.links)y.set(g.id,g);p={...e.scene,elements:x,links:y}}if(e.strokeErasePreview&&e.strokeErasePreview.elements.length>0&&(u.strokeErasePreviewElements=e.strokeErasePreview.elements),e.mode!=="brush"&&e.mode!=="hand"&&!e.readOnly){let x=e.scene.viewport.zoom||1,y=(A,_,T,w)=>{let S=I(e.scene,A);if(!S)return null;let L=_==="link-start"?Lo:JT,{names:M,worldPoints:B}=_o(S,L/x),W=[...B],ie=T!==null?M.indexOf(T):-1;_==="link-attach"&&w&&W.push(w);let ne=ie>=0?ie:_==="link-attach"&&w?W.length-1:-1;return{worldPoints:W,...ne>=0?{activeIndex:ne}:{},role:_}},g=[];if(e.linkDragFromAnchor){let A=y(e.linkDragFromAnchor.fromElement,"link-start",null);if(A&&g.push(A),e.hoveredLinkTarget){let _=e.hoveredLinkTarget,T=y(_.elementId,"link-attach",_.activeAnchor,_.outlinePoint);T&&g.push(T)}}else if(e.hoveredLinkTarget){let A=e.hoveredLinkTarget,_=y(A.elementId,"link-attach",A.activeAnchor,A.outlinePoint);_&&g.push(_)}else if(!e.panGesture&&!e.pinchActive&&!e.gestureActive&&!e.edgePreview&&!e.linkEndpointDrag){let A=e.hoverCursorWorld;if(e.selection.size===1&&A){let _=v([...e.selection][0]),T=I(e.scene,_);if(T){let w=z(T),S=(Lo+Xo+e.anchorStartHitSlop)/x;if(A.x>=w.x-S&&A.x<=w.x+w.width+S&&A.y>=w.y-S&&A.y<=w.y+w.height+S){let M=y(_,"link-start",null);if(M){let j=tI/x,ve=-1,ye=j*j;if(M.worldPoints.forEach((ee,Se)=>{let Oe=ee.x-A.x,qt=ee.y-A.y,xn=Oe*Oe+qt*qt;xn<=ye&&(ye=xn,ve=Se)}),ve>=0){let ee=j>0?Math.max(0,1-Math.sqrt(ye)/j):0,Se=op+(YT-op)*ee;g.push({...M,activeIndex:ve,activeRadius:Se})}else g.push(M)}let{names:B,worldPoints:W}=_o(T,Lo/x),ie=(e.anchorClickRadius/x)**2,ne=null;for(let j=0;j<W.length;j++){let ve=v(W[j]);if((ve.x-A.x)**2+(ve.y-A.y)**2<=ie){ne=v(B[j]);break}}if(ne){let j=e.previewClickCreate(_,ne);j&&(u.ghostElement=j.bounds,u.ghostElementShape=j.element,d=j.ghostScene)}}}}}g.length===1?u.ports=v(g[0]):g.length>1&&(u.ports=g);let b=e.hoveredLinkTarget;if(b?.mode==="element"){let A=I(e.scene,b.elementId);A&&(u.linkAttachHighlight=z(A))}}if(e.selection.size+e.selectedLinks.size>1||e.aspectLocked){let x=e.combinedSelectionBounds;x&&(u.groupBounds=x),e.aspectLocked&&(u.groupAspectLocked=!0)}if(e.containerHover&&(u.containerDropZone=e.containerHover.dropZone),e.brushStroke&&(u.brushPreview={origin:e.brushStroke.origin,points:e.brushStroke.points,fill:e.brushStroke.fill,opacity:e.brushStroke.opacity}),e.laserStrokes.length>0&&(u.laserStrokes=e.laserStrokes),e.eraserTrail.length>0&&(u.eraserTrail=e.eraserTrail),e.eraserCursor&&(u.eraserCursor=e.eraserCursor),e.selectedLinks.size>0){let x=[];for(let y of e.selectedLinks){let g=be(e.scene,y);if(!g)continue;let b=cc(e.scene,g);b&&b.length>=2&&x.push({path:b,width:g.style.strokeWidth??1})}x.length>0&&(u.selectedLinkPaths=x)}let h=e.selectedLink;if(h){let x=be(e.scene,h);if(x){let y=ot(e.scene,x);if(y&&y.length>=2){let g=v(y[0]),b=v(y[y.length-1]);if((x.routing??"straight")==="orthogonal"){let _=[];if(!e.linkSegmentDrag&&!e.linkEndpointDrag){let T=y.length===2?[0]:Array.from({length:Math.max(0,y.length-3)},(w,S)=>S+1);for(let w of T){let S=v(y[w]),L=v(y[w+1]);_.push({x:(S.x+L.x)/2,y:(S.y+L.y)/2})}}u.edgeSelection={from:g,to:b,midpoints:_}}else{let _=[...x.waypoints??[]],T=e.linkWaypointDrag?[]:Vf(e.scene,x)??[];u.edgeSelection={from:g,to:b,waypoints:_,midpoints:T}}}}}e.peerCursors.length>0&&(u.peerCursors=e.peerCursors),e.peerSelections.length>0&&(u.peerSelections=e.peerSelections),e.scene.annotations.size>0&&(u.annotations=[...e.scene.annotations.values()],u.selectedAnnotation=e.selectedAnnotation);let m=e.editingText;if(m&&(u.editingText=m),e.debugHitZones){u.debugHitZones=!0;let x=e.linkDragFromAnchor!==null||e.edgePreview!==null||e.linkEndpointDrag!==null,y=e.groupMoveOrigin!==null&&e.gestureActive,g=Sy({linkDragActive:x,elementDragActive:y});if(u.debugHitZoneVisibility=g,g.attachDropZones){let b=e.linkDragFromAnchor?.fromElement,A=[],_=[];for(let T of e.scene.elements.values())if(T.id!==b){A.push(..._o(T,0).worldPoints);for(let w of Bf(e.scene,T))_.push(w)}u.debugAttachZones={anchors:A,outlineLoops:_,thresholdWorld:12}}if(g.containerDropZones){let b=e.groupMoveOrigin,A=[],_=[];for(let T of e.scene.elements.values())if(!b?.has(T.id)){if(Be(T)){A.push(z(T));continue}_.push(...SA(T))}u.debugContainerZones={frames:A,containers:_}}}i={sig:s,opts:u,ghostScene:d,edgePreviewScene:f,flowchartPreviewScene:p},DO.set(e.overlayTarget,i)}let l=i.opts,c=[];for(let u of e.scene.elements.values())ct(u)&&u.animationKind&&e.isPlaybackPaused(u.id)&&c.push(z(u));c.length>0?l.gifBadges=c:l.gifBadges!==void 0&&delete l.gifBadges,V5(e.scene,e.selection,e.overlayTarget,l),i.ghostScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(q0),Pn(i.ghostScene,e.overlayTarget,{}),e.overlayTarget.restore()),i.edgePreviewScene&&Pn(i.edgePreviewScene,e.overlayTarget,{}),i.flowchartPreviewScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(K0),Pn(i.flowchartPreviewScene,e.overlayTarget,{}),e.overlayTarget.restore())};var jy=class{onTick;_on=!0;timer=null;constructor(t){this.onTick=t}get on(){return this._on}start(){this._on=!0,this.stop(),!(typeof window>"u")&&(this.timer=setInterval(()=>{this._on=!this._on,this.onTick()},t4))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var BO=(e,t,n)=>{let o=I(e,t);return!(o===void 0||!fe(o)||n(o.layerId))};var Vy=class{host;_editingElement=null;_pendingCreate=null;_origin=null;_sel=null;_dragAnchor=null;caretBlink;constructor(t){this.host=t,this.caretBlink=new jy(()=>{this.host.notify()})}get editingElement(){return this._editingElement}get selection(){return this._sel}get caret(){return this._sel?this._sel.dir==="backward"?this._sel.start:this._sel.end:null}get caretBlinkOn(){return this.caretBlink.on}get isDragging(){return this._dragAnchor!==null}markPendingCreate(t){this._pendingCreate=t}begin(t){if(!BO(this.host.scene,t,a=>this.host.isLayerLocked(a)))return;this._editingElement!==null&&this._editingElement!==t&&this.commit(),this._editingElement=t,this._origin=this._pendingCreate===t?null:I(this.host.scene,t)??null;let n=I(this.host.scene,t),o=n!==void 0&&fe(n)?n.text.length:0;this._sel={start:o,end:o,dir:"forward"},this.caretBlink.start(),this.host.notify()}setText(t,n,o,a="forward"){let r=this._editingElement;if(!r)return;let s=J(this.host.scene,r,i=>({...i,text:t}));this.host.scene=s.scene,this._sel={start:n,end:o,dir:a},this.caretBlink.wake(),this.host.notify()}setSelection(t,n,o="forward"){this._editingElement&&(this._sel={start:t,end:n,dir:o},this.caretBlink.wake(),this.host.notify())}caretIndexAtWorldPoint(t){let n=this._editingElement;if(!n)return null;let o=I(this.host.scene,n);if(o===void 0||!fe(o))return null;let a=this.editingTextLayout(o);if(!a)return null;let r=o.scale.x||1,s=o.scale.y||1,i={x:(t.x-o.position.x)/r,y:(t.y-o.position.y)/s},l=o.style.textAlign??"left";return Sv(a,i,this.measureFor(o),l)}editedElementContainsPoint(t){let n=this._editingElement;if(!n)return!1;let o=I(this.host.scene,n);if(!o)return!1;let a=z(o);return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height}setCaretFromPoint(t){let n=this.caretIndexAtWorldPoint(t);n!==null&&(this._dragAnchor=n,this.setSelection(n,n,"forward"))}extendSelectionToPoint(t){if(this._dragAnchor===null)return;let n=this.caretIndexAtWorldPoint(t);if(n===null)return;let o=this._dragAnchor;n>=o?this.setSelection(o,n,"forward"):this.setSelection(n,o,"backward")}endDragSelect(){this._dragAnchor=null}editingTextLayout(t){return Oc(t.text,this.measureFor(t),{fontSize:t.fontSize,...t.maxWidth!==void 0?{maxWidth:t.maxWidth}:{}})}measureFor(t){let n=this.host.mainTarget;return n.setFont(t.fontFamily,t.fontSize,{...t.style.fontWeight==="bold"?{weight:"bold"}:{},...t.style.fontStyle==="italic"?{style:"italic"}:{}}),o=>n.measureText(o).width}overlay(){let t=this._editingElement;if(!t||!this._sel)return null;let n=I(this.host.scene,t);if(n===void 0||!fe(n))return null;let o=this.editingTextLayout(n);if(!o)return null;let a=n.style.textAlign??"left",r=this.measureFor(n),{x:s,y:i}=n.position,l=n.scale.x,c=n.scale.y,d=Lv(o,this._sel.start,this._sel.end,r,a).map(p=>({x:s+Math.min(p.x*l,(p.x+p.width)*l),y:i+Math.min(p.y*c,(p.y+p.height)*c),width:Math.abs(p.width*l),height:Math.abs(p.height*c)})),f=null;if(this.caretBlink.on){let p=this._sel.dir==="backward"?this._sel.start:this._sel.end,h=vv(o,p,r,n.fontSize,a);f={x:s+h.x*l,y:i+h.y*c,height:h.height*Math.abs(c)}}return{caret:f,caretColor:n.style.fill??"#1a1a1a",selectionRects:d}}commit(t){let n=this._editingElement;if(!n)return;let o=this._pendingCreate===n,a=this._origin;t!==void 0&&(this.host.scene=J(this.host.scene,n,l=>({...l,text:t})).scene),this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop();let r=I(this.host.scene,n),s=r!==void 0&&fe(r)?r:void 0;if((s?.text??"").trim()===""){s&&(this.host.scene=dn(this.host.scene,n).scene,!o&&a&&this.host.pushHistory({kind:"element",id:n,before:a,after:null}),this.host.clearSelectionFor(n)),this.host.notify();return}if(o)s&&this.host.pushHistory({kind:"element",id:n,before:null,after:s});else if(a&&s){let l=fe(a)?a.text:"";if(l!==s.text){let c={...s,text:l};this.host.pushHistory({kind:"element",id:n,before:c,after:s})}}this.host.notify()}cancel(){let t=this._editingElement;if(t===null)return;let n=this._pendingCreate===t,o=this._origin;if(this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop(),n)I(this.host.scene,t)&&(this.host.scene=dn(this.host.scene,t).scene,this.host.clearSelectionFor(t));else if(o){let a=fe(o)?o.text:"";this.host.scene=J(this.host.scene,t,r=>({...r,text:a})).scene}this.host.notify()}};var NO=(e,t,n,o)=>{let a=n;if(t){let i=I(e,t);i&&(a=Ga(i,n,So(i)).world)}let r=o,s=ci(e,o);return s&&(r=Ga(s,o,So(s)).world),{from:a,to:r}},zO=(e,t,n)=>{let o=be(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=et(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},FO=(e,t)=>{let n=a=>{if(a.kind==="point")return`p:${a.position.x},${a.position.y}`;let r=I(e,a.elementId),s=r?z(r):null,i=a.kind==="anchor"?JSON.stringify(a.anchor):a.kind==="outline"?`o:${a.ratio}`:"f";return`${a.kind}:${a.elementId}:${i}:${s?`${s.x},${s.y},${s.width},${s.height}`:"x"}`},o=`${n(t.from)}|${n(t.to)}|${JSON.stringify(t.fixedSegments??null)}`;if(t.avoidObstacles===!0){let a="|avoid:";for(let r of e.elements.values()){let s=z(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var Zy=class{host;_endpointDrag=null;_waypointDrag=null;_segmentDrag=null;lastHandleClickAt=0;lastHandleClickWorld=null;constructor(t){this.host=t}get endpointDrag(){return this._endpointDrag}get waypointDrag(){return this._waypointDrag}get segmentDrag(){return this._segmentDrag}reset(){this._waypointDrag=null,this._segmentDrag=null,this._endpointDrag=null}applyEndpointMove(t,n,o){if(!be(this.host.scene,t))return;this.lastHandleClickAt=0;let r=this.host.linkAttachTargetAt(o),s=r?.kind==="element"?r.id:null,i=this.host.snapLinkEndpoint(s,o),l=et(this.host.scene,t,c=>n==="from"?{...c,from:i}:{...c,to:i});this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this._endpointDrag={linkId:t,side:n,toPoint:o},this.host.updateHoveredLinkTarget(o),this.host.notify()}applyEndpointUpdate(t){let n=this.host.hasGestureTx(),o=zO(this.host.scene,t,(a,r)=>this.host.snapLinkEndpoint(a,r));if(o===null){this.host.cancelGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}if(!n&&Yr(o.patch)){this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}this.host.scene=o.scene,this.host.recordGesturePatch(o.patch),this.host.commitGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget()}get isDraggingWaypoint(){return this._waypointDrag!==null}beginWaypointDrag(t,n,o){be(this.host.scene,t)&&(this._waypointDrag={linkId:t,index:n,pendingInsert:o})}updateWaypointDrag(t){let n=this._waypointDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this.host.scene,n.linkId);if(!o)return;let a=[...o.waypoints??[]];if(n.pendingInsert)a.splice(n.index,0,t),n.pendingInsert=!1;else{if(n.index<0||n.index>=a.length)return;a[n.index]=t}let r=et(this.host.scene,n.linkId,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.recordGesturePatch(r.patch),this.host.notify()}endWaypointDrag(){let t=this._waypointDrag;if(this._waypointDrag=null,!t)return;if(t.pendingInsert){this.host.commitGesture();return}let n=be(this.host.scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=ot(this.host.scene,n),a=v(n.waypoints[t.index]),r=VT/(this.host.scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&za.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=et(this.host.scene,t.linkId,u=>({...u,waypoints:l}));this.host.scene=c.scene,this.host.recordGesturePatch(c.patch)}}this.host.commitGesture()}get isDraggingSegment(){return this._segmentDrag!==null}beginSegmentDrag(t,n,o){be(this.host.scene,t)&&(this._segmentDrag={linkId:t,axis:n,at:o})}updateSegmentDrag(t){let n=this._segmentDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this.host.scene,n.linkId);if(!o)return;let a=n.axis==="h"?t.y:t.x,r=[...o.fixedSegments??[]],s={axis:n.axis,pos:a,at:n.at},i=r.findIndex(c=>c.axis===n.axis&&Math.abs(c.at-n.at)<.5);i>=0?r[i]=s:r.push(s);let l=et(this.host.scene,n.linkId,c=>({...c,fixedSegments:r}));this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this.host.notify()}endSegmentDrag(){this._segmentDrag&&(this._segmentDrag=null,this.host.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<G0&&this.lastHandleClickWorld!==null&&U.distance(this.lastHandleClickWorld,t)<=W0;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=be(this.host.scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=et(this.host.scene,t,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.pushHistory(r.patch),this.host.notify()}resetSegmentPin(t,n,o,a){let r=be(this.host.scene,t);if(!r?.fixedSegments||r.fixedSegments.length===0)return;let s=-1,i=1/0;for(let u=0;u<r.fixedSegments.length;u++){let d=v(r.fixedSegments[u]);if(d.axis!==n)continue;let f=Math.abs(d.pos-o)+Math.abs(d.at-a)*.001;f<i&&(i=f,s=u)}if(s<0)return;let l=r.fixedSegments.filter((u,d)=>d!==s),c=et(this.host.scene,t,u=>({...u,fixedSegments:l}));this.host.scene=c.scene,this.host.pushHistory(c.patch),this.host.notify()}};var HO=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=Wa(t),r=[N.applyToPoint(a,{x:0,y:0}),N.applyToPoint(a,{x:n,y:0}),N.applyToPoint(a,{x:0,y:o}),N.applyToPoint(a,{x:n,y:o})],s=V.fromPoints(r);return V.expand(s,Math.max(s.width,s.height)*.05)},Xy=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?Xy(e,o.id):z(o);a&&(n=n?V.union(n,a):a)}return n},UO=(e,t)=>{let n=null;for(let o of t){let a=I(e,o);if(!a)continue;let r=ze(a)?Xy(e,a.id):z(a);r&&(n=n?V.union(n,r):r)}return n};var GO=e=>{let t=null;for(let n of e.elements.values())ic(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var WO=(e,t,n,o,a)=>{let r=w0(e,o,b2),s=a==="replace"?Pe:t;for(let i of r)n(i.layerId)||(s=Xt(s,i.id));return s},qO=(e,t,n,o,a)=>{let r=a==="replace"?Pe:t,s=w0(e,o,b2);for(let i of s)n(i.layerId)||(r=Xt(r,i.id));return r},qq=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,ES=(e,t,n,o,a)=>{let r=a==="replace"?yt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=ot(e,s);!i||i.length<2||i.every(l=>qq(l,o))&&(r=fS(r,s.id))}return r};var TS=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},jO=(e,t,n,o)=>{let a=I(e,t);if(!a)return null;let r=z(a),s=o.x-r.x,i=o.y-r.y,l={...a,position:{x:a.position.x+n.x+s,y:a.position.y+n.y+i}};return{kind:"element",id:t,before:a,after:l}},VO=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=I(e,a);if(!s)continue;let i={...s,position:{x:r.x+n.x,y:r.y+n.y}};i.position.x===s.position.x&&i.position.y===s.position.y||o.push({kind:"element",id:a,before:s,after:i})}return o},ZO=(e,t,n,o)=>{let a=e.annotations.get(t);if(!a)return null;let r={x:o.x+n.x,y:o.y+n.y},s=r;if(a.elementId){let l=I(e,a.elementId);l&&(s={x:r.x-l.position.x,y:r.y-l.position.y})}if(s.x===a.position.x&&s.y===a.position.y)return null;let i=qa(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var IS=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n},MS=e=>e.map(t=>z(t)).reduce((t,n)=>V.union(t,n)),XO=(e,t,n)=>{let o=IS(e,t);if(o.length===0)return[];let a=MS(o),r=a.x+a.width/2,s=a.y+a.height/2,i=n==="horizontal",l=[];for(let c of o){let u=i?{...c,position:{x:2*r-c.position.x,y:c.position.y},scale:{x:-c.scale.x,y:c.scale.y}}:{...c,position:{x:c.position.x,y:2*s-c.position.y},scale:{x:c.scale.x,y:-c.scale.y}};l.push({kind:"element",id:c.id,before:c,after:u})}return l},YO=(e,t,n)=>{let o=IS(e,t);if(o.length<2)return[];let a=MS(o),r=[];for(let s of o){let i=z(s),l=0,c=0;switch(n){case"left":l=a.x-i.x;break;case"right":l=a.x+a.width-(i.x+i.width);break;case"h-center":l=a.x+a.width/2-(i.x+i.width/2);break;case"top":c=a.y-i.y;break;case"bottom":c=a.y+a.height-(i.y+i.height);break;case"v-center":c=a.y+a.height/2-(i.y+i.height/2);break}if(l===0&&c===0)continue;let u={...s,position:{x:s.position.x+l,y:s.position.y+c}};r.push({kind:"element",id:s.id,before:s,after:u})}return r},KO=(e,t,n)=>{let o=IS(e,t);if(o.length<3)return[];let a=n==="horizontal",r=m=>a?m.x:m.y,s=m=>a?m.width:m.height,i=o.map(m=>({el:m,b:z(m)})).sort((m,x)=>r(m.b)-r(x.b)),l=i[0],c=i[i.length-1];if(!l||!c)return[];let u=r(c.b)+s(c.b)-r(l.b),d=i.reduce((m,x)=>m+s(x.b),0),f=(u-d)/(i.length-1),p=[],h=r(l.b)+s(l.b)+f;for(let m=1;m<i.length-1;m++){let x=i[m];if(!x)continue;let y=h-r(x.b);if(y!==0){let g=a?{...x.el,position:{x:x.el.position.x+y,y:x.el.position.y}}:{...x.el,position:{x:x.el.position.x,y:x.el.position.y+y}};p.push({kind:"element",id:x.el.id,before:x.el,after:g})}h+=s(x.b)+f}return p},RS=(e,t,n,o)=>{let a=Math.cos(o),r=Math.sin(o),s=[];for(let[i,l]of t){let c=I(e,i);if(!c)continue;let u=l.position.x-n.x,d=l.position.y-n.y,f={...c,position:{x:n.x+(u*a-d*r),y:n.y+(u*r+d*a)},rotation:l.rotation+o};s.push({kind:"element",id:i,before:c,after:f})}return s},$O=e=>{let t=MS(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var Yy=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),e8=(e,t,n)=>{let o=Yy({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},t8=(e,t,n)=>{let o=1/0,a=1/0;for(let s of e.values())s.x<o&&(o=s.x),s.y<a&&(a=s.y);if(!Number.isFinite(o))return t;let r=Yy({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},QO=new Set(["nw","w","sw"]),jq=new Set(["ne","e","se"]),JO=new Set(["nw","n","ne"]),Vq=new Set(["sw","s","se"]),OS=(e,t,n,o)=>{let a=n.x,r=n.y;if(QO.has(t)||jq.has(t)){let s=QO.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(JO.has(t)||Vq.has(t)){let s=JO.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},n8=(e,t)=>{let n=Yy({x:e.x,y:e.y},t),o=Yy({x:e.x+e.width,y:e.y+e.height},t);return{x:n.x,y:n.y,width:Math.max(0,o.x-n.x),height:Math.max(0,o.y-n.y)}};var Zq=new Set(["MOVE_SHAPE","RESIZE_GROUP","RESIZE_SHAPE","ROTATE","CREATE_SHAPE","CREATE_EDGE","MOVE_ANNOTATION","COMMIT_ANNOTATION_DRAG","UPDATE_EDGE_ENDPOINT","UPDATE_EDGE_ENDPOINT_PREVIEW","DRAW_EDGE_PREVIEW"]),Xq=Object.freeze(new Set),Ri=()=>typeof performance<"u"?performance.now():Date.now(),Gp=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;_readOnly=!1;actor;listeners=new Set;events=Qv();eventCache=pM();unbind;_scene;_selection=Pe;interaction=new Ny;get annotationDrag(){return this.interaction.annotationDrag}set annotationDrag(t){this.interaction.annotationDrag=t}get drawingPreview(){return this.interaction.drawingPreview}set drawingPreview(t){this.interaction.drawingPreview=t}get edgePreview(){return this.interaction.edgePreview}set edgePreview(t){this.interaction.edgePreview=t}get linkDragFromAnchor(){return this.interaction.linkDragFromAnchor}set linkDragFromAnchor(t){this.interaction.linkDragFromAnchor=t}get hoveredLinkTarget(){return this.interaction.hoveredLinkTarget}set hoveredLinkTarget(t){this.interaction.hoveredLinkTarget=t}get hoverCursorWorld(){return this.interaction.hoverCursorWorld}set hoverCursorWorld(t){this.interaction.hoverCursorWorld=t}_selectedLinks=yt;_selectedAnnotation=null;commentAuthor={id:"local",name:"You"};get linkEndpointDrag(){return this.linkHandles.endpointDrag}get linkWaypointDrag(){return this.linkHandles.waypointDrag}get linkSegmentDrag(){return this.linkHandles.segmentDrag}get lassoPreview(){return this.interaction.lassoPreview}set lassoPreview(t){this.interaction.lassoPreview=t}get groupMoveOrigin(){return this.interaction.groupMoveOrigin}set groupMoveOrigin(t){this.interaction.groupMoveOrigin=t}get groupLinkMoveOrigin(){return this.interaction.groupLinkMoveOrigin}set groupLinkMoveOrigin(t){this.interaction.groupLinkMoveOrigin=t}get groupResizeOrigin(){return this.interaction.groupResizeOrigin}set groupResizeOrigin(t){this.interaction.groupResizeOrigin=t}get rotateGestureOrigin(){return this.interaction.rotateGestureOrigin}set rotateGestureOrigin(t){this.interaction.rotateGestureOrigin=t}_activeLayerId=ln(Rn);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new Yf([DA,PA,BA]);snapThreshold=12;styleClipboard=null;boundsCache=new es;spatialIndexCache=null;_enteredGroup=null;get brushStroke(){return this.interaction.brushStroke}set brushStroke(t){this.interaction.brushStroke=t}get brushPreviewStroke(){let t=this.interaction.brushStroke;if(!t)return null;let n=zy(this._brushSettings);return{origin:t.origin,points:mS(t.points),fill:Df(n),opacity:n.opacity??1}}get eraseStroke(){return this.interaction.eraseStroke}set eraseStroke(t){this.interaction.eraseStroke=t}get pendingErase(){return this.interaction.eraseStroke?.pending??Xq}get laserStrokes(){return this.interaction.laserStrokes}get lastPointerWorld(){return this.interaction.lastPointerWorld}set lastPointerWorld(t){this.interaction.lastPointerWorld=t}cursorOverrides=new Map;lastRenderedScene=null;lastRenderedEnteredGroup=null;lastRenderedEraseActive=!1;eraseDirty=!1;autoCompactScheduler=new Cy({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new Ey({getScene:()=>this._scene,applyPatch:t=>{this._scene=Q(this._scene,t),this.gestureTx?this.gestureTx.add(t):this._history.push(t)},growContainer:(t,n)=>{this.maybeGrowContainer(t,n)},onMutated:()=>{this.scheduleRender();for(let t of this.listeners)t()}});get dragElementId(){return this.interaction.dragElementId}set dragElementId(t){this.interaction.dragElementId=t}get additivePressAdded(){return this.interaction.additivePressAdded}set additivePressAdded(t){this.interaction.additivePressAdded=t}get containerHover(){return this.interaction.containerHover}set containerHover(t){this.interaction.containerHover=t}_peerCursors=[];_peerSelections=[];cursorListeners=new Set;get activePointers(){return this.interaction.activePointers}get touchPanCandidate(){return this.interaction.touchPanCandidate}set touchPanCandidate(t){this.interaction.touchPanCandidate=t}pinch;containerOpsRef;get spaceHeld(){return this.interaction.spaceHeld}set spaceHeld(t){this.interaction.spaceHeld=t}tileComposeFn;tileDirtyElements=new Map;_toolLocked=!1;fileDropRegistry=new Op;get panGesture(){return this.interaction.panGesture}set panGesture(t){this.interaction.panGesture=t}get suppressNextContextMenu(){return this.interaction.suppressNextContextMenu}set suppressNextContextMenu(t){this.interaction.suppressNextContextMenu=t}longPress;longPressListeners=new Set;announceListeners=new Set;inputMode;handleHitSlop;edgeHandleHitSlop;edgeHitThreshold;anchorStartHitSlop;anchorClickRadius;_history;gestureTx=null;gestureStartScene=null;gestures;textEdit;linkHandles;constructor(t){this.host=t.host,this.mainTarget=t.mainTarget,this.overlayTarget=t.overlayTarget,this.backgroundTarget=t.backgroundTarget??null,this.onAfterRender=t.onAfterRender??null,this._scene=t.initialScene,this._history=Yq(t.history)?t.history:new Rp(t.history??{}),this.tileComposeFn=t.useTileCache===!0&&t.tileCompose?t.tileCompose:null,this.initControllers(),this.initGlobalHooks(t),this.initInputMode(t),this.initActor(t),this.unbind=this.bindPointerEvents(),this.animation.attach(),rS(this),sS(this),this.maybeAnimate(),this.animationContentOff=wv(()=>{this.scheduleRender()}),this.forceRender(),mM(this.eventCache,this.observableSnapshot())}initControllers(){let t=this;this.gestures=new My({get history(){return t._history},get gestureTx(){return t.gestureTx},set gestureTx(n){t.gestureTx=n},get groupMoveOrigin(){return t.groupMoveOrigin},set groupMoveOrigin(n){t.groupMoveOrigin=n},get groupLinkMoveOrigin(){return t.groupLinkMoveOrigin},set groupLinkMoveOrigin(n){t.groupLinkMoveOrigin=n},get groupResizeOrigin(){return t.groupResizeOrigin},set groupResizeOrigin(n){t.groupResizeOrigin=n},get dragElementId(){return t.dragElementId},set dragElementId(n){t.dragElementId=n},get containerHover(){return t.containerHover},set containerHover(n){t.containerHover=n},get toolLocked(){return t._toolLocked},get mode(){return t.mode},setMode:n=>{t.setMode(n)},notify:()=>{t.notify()}}),this.textEdit=new Vy({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},notify:()=>{t.notify()},isLayerLocked:n=>t.isLayerLocked(n),clearSelectionFor:n=>{t._selection.has(n)&&(t._selection=Pe)},mainTarget:this.mainTarget}),this.linkHandles=new Zy({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},recordGesturePatch:n=>{t.recordGesturePatch(n)},commitGesture:()=>{t.commitGesture()},cancelGesture:()=>{t.cancelGesture()},hasGestureTx:()=>t.gestureTx!==null,notify:()=>{t.notify()},linkAttachTargetAt:n=>t.linkAttachTargetAt(n),snapLinkEndpoint:(n,o)=>t.snapLinkEndpoint(n,o),updateHoveredLinkTarget:n=>{t.updateHoveredLinkTarget(n)},clearHoveredLinkTarget:()=>{t.hoveredLinkTarget=null}}),this.longPress=new Dy(n=>this.screenToWorld(n),n=>{for(let o of this.longPressListeners)o(n)}),this.pinch=new Py(n=>this.screenToWorld(n),(n,o)=>{this.zoomAt(n,o)},n=>{this.panBy(n)}),this.containerOpsRef={get scene(){return t._scene},get dragElementId(){return t.dragElementId},get containerHover(){return t.containerHover},applyPatch(n,o){t._scene=o,t.beginOrAttachGesture().add(n)}}}initGlobalHooks(t){t.textShaper&&Cp(t.textShaper),t.rasterizer&&Ep(t.rasterizer),fA((n,o,a,r)=>(this.mainTarget.setFont(o,a,{...r?.bold?{weight:"bold"}:{},...r?.italic?{style:"italic"}:{}}),this.mainTarget.measureText(n).width))}initInputMode(t){let n=t.inputMode??"auto";n==="touch"?this.inputMode="touch":n==="mouse"?this.inputMode="mouse":typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?this.inputMode="touch":this.inputMode="mouse",this.handleHitSlop=this.inputMode==="touch"?vI:11,this.edgeHandleHitSlop=this.inputMode==="touch"?SI:Zo,this.edgeHitThreshold=this.inputMode==="touch"?LI:F0,this.anchorStartHitSlop=this.inputMode==="touch"?kI:H0,this.anchorClickRadius=this.inputMode==="touch"?wI:U0}initActor(t){this.actor=$o(a5),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",n=>{this.applyEmit(n)}),this.actor.start(),this.fileDropRegistry.register(oM),this.fileDropRegistry.register(rM),this._readOnly=t.readOnly??!1,t.initialMode&&this.actor.send({type:"SET_MODE",mode:t.initialMode})}snapshotCache=null;observableSnapshot(){let t=this.mode,n=this._selection,o=this._selectedLinks,a=this._scene,r=this.canUndo,s=this.canRedo,i=this.snapshotCache;if(i!==null&&i.mode===t&&i.selection===n&&i.selectedLinks===o&&i.scene===a&&i.canUndo===r&&i.canRedo===s)return i;let l={mode:t,selection:n,selectedLinks:o,scene:a,canUndo:r,canRedo:s};return this.snapshotCache=l,l}get scene(){return this._scene}get selection(){return this._selection}get mode(){return this.actor.getSnapshot().context.mode}get history(){return this._history}get canUndo(){return this._history.canUndo}get canRedo(){return this._history.canRedo}get hostElement(){return this.host}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCursorMove(t){return this.cursorListeners.add(t),()=>this.cursorListeners.delete(t)}setCommentAuthor(t){this.commentAuthor=t}get selectedAnnotation(){return this._selectedAnnotation}setSelectedAnnotation(t){this._selectedAnnotation!==t&&(this._selectedAnnotation=t,this.notify())}addAnnotation(t){let n=FR(this._scene,t,this.commentAuthor,o=>this.uniqueId(o));return this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation=n.id,this.notify(),this.announce("Annotation added"),n.id}removeAnnotation(t){let n=HR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation===t&&(this._selectedAnnotation=null),this.notify(),this.announce("Annotation removed"))}toggleAnnotationResolved(t){let n=UR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify(),this.announce(n.wasResolved?"Annotation reopened":"Annotation resolved"))}addComment(t,n,o){let a=GR(this._scene,t,n,o??this.commentAuthor,r=>this.uniqueId(r));a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}removeComment(t,n){let o=WR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return qR(this._scene,t)}onLongPress(t){return this.longPressListeners.add(t),()=>this.longPressListeners.delete(t)}onAnnounce(t){return this.announceListeners.add(t),()=>this.announceListeners.delete(t)}announce(t){if(t)for(let n of this.announceListeners)n(t)}setPeerCursors(t){this._peerCursors=t,this.scheduleRender()}setPeerSelections(t){this._peerSelections=t,this.scheduleRender()}setDebugHitZones(t){this.debugHitZones!==t&&(this.debugHitZones=t,this.scheduleRender())}get readOnly(){return this._readOnly}setReadOnly(t){this._readOnly!==t&&(this._readOnly=t,this.notify(),this.scheduleRender())}toggleReadOnly(){this.setReadOnly(!this._readOnly)}get gridEnabled(){return this._scene.viewport.gridEnabled}setGridVisible(t){this.setGrid({enabled:t})}toggleGrid(){this.setGrid({enabled:!this.gridEnabled})}get toolLocked(){return this._toolLocked}get selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:GM(this._selectedLinks)}updateSelectedLink(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=et(this._scene,n,t);this._scene=o.scene,this._history.push(o.patch),this.notify()}registerFileDropHandler(t){this.fileDropRegistry.register(t)}unregisterFileDropHandler(t){this.fileDropRegistry.unregister(t)}async dispatchFileDrop(t,n){let o={editor:this,worldPoint:n};return this.fileDropRegistry.dispatch(t,o)}setToolLocked(t){this._toolLocked!==t&&(this._toolLocked=t,this.notify())}maybeRevertModeAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setMode(t){this.pendingEyedropperPick=null,this.editingTextElement!==null&&this.commitTextEdit(),this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),t!=="draw-edge"&&this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null),this.actor.send({type:"SET_MODE",mode:t}),this.refreshCursor(),this.notify()}undo(){let t=this._history.undo();return t?(this._scene=Q(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}redo(){let t=this._history.redo();return t?(this._scene=Q(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}addElement(t,n){let o=Fe(this._scene,t);return this._scene=o.scene,(n?.select??!0)&&(this._selection=wt(t.id)),this._history.push(o.patch),this.notify(),o.patch}insertImage(t){let n=Ze(this.uniqueId("img")),o=yM(this._scene,t,n,this._activeLayerId);return this.addElement(o),t.animated&&(this.gifPlayback.ensure(n),this.maybeAnimate()),n}async addBinaryFile(t,n){let o=await gM(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new Iy({hasVisibleAnimatedElement:()=>bM(this)||this.hasActiveLaser(),autoStopHeavyGifs:()=>{AM(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return Oy(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new Ry;togglePlayback(t){this.gifPlayback.toggle(t),this.maybeAnimate(),this.scheduleRender()}hoverAnimatedElement(t){this.gifPlayback.hoverEnter(t)&&(this.maybeAnimate(),this.scheduleRender())}isPlaybackPaused(t){return this.gifPlayback.isPaused(t)}setHoverCursorWorld(t){this.hoverCursorWorld=t,this._selection.size===1&&this.notify()}get linkPreviewPath(){return this.edgePreview?.points??null}get linkAttachTarget(){let t=this.hoveredLinkTarget;return t?{elementId:t.elementId,mode:t.mode}:null}beginPlacement(t){let n=this._history.transaction(),{scene:o,state:a}=xO(t),r=o(this._scene);this._scene=r.scene,this._selection=wt(t.id),this.notify();let s={...a};return{update:i=>{let l=yO(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=gO(this._scene,s);i&&(this._scene=i.scene,s.current=i.next),n.add({kind:"element",id:t.id,before:null,after:s.current}),n.commit(),this.notify()},cancel:()=>{let{scene:i}=bO(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Pe,this.notify()}}}deleteSelected(){if(this.readOnly)return;let t=Fy(this._scene,this._selection,this._selectedLinks);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=Pe,this._selectedLinks=yt,this.notify()}get editingTextElement(){return this.textEdit.editingElement}get editingLinkCaption(){return this.interaction.editingLinkCaption}_editingFrameName=null;get editingFrameName(){return this._editingFrameName}get editingTextSelection(){return this.textEdit.selection}get editingTextCaret(){return this.textEdit.caret}get caretBlinkOn(){return this.textEdit.caretBlinkOn}get isTextDragging(){return this.textEdit.isDragging}beginLinkCaptionEdit(t){be(this._scene,t)&&(this.editingTextElement!==null&&this.commitTextEdit(),this.interaction.editingLinkCaption=t,this.notify())}commitLinkCaptionEdit(t){let n=this.interaction.editingLinkCaption;if(this.interaction.editingLinkCaption=null,n===null){this.notify();return}let o=be(this._scene,n);if(o){let a=t.trim(),r=a===""?void 0:{...o.label??{},text:a};if(!((o.label?.text??"")===(r?.text??""))){let i=et(this._scene,n,l=>{let c={...l};return r?c.label=r:delete c.label,c});this._scene=i.scene,this._history.push(i.patch)}}this.notify()}cancelLinkCaptionEdit(){this.interaction.editingLinkCaption!==null&&(this.interaction.editingLinkCaption=null,this.notify())}linkLabelWorld(t){let n=be(this._scene,t);if(!n)return null;let o=ot(this._scene,n);if(!o||o.length<2)return null;let a=n.label?.position??.5,r=0;for(let i=1;i<o.length;i++)r+=U.distance(v(o[i-1]),v(o[i]));let s=r*a;for(let i=1;i<o.length;i++){let l=v(o[i-1]),c=v(o[i]),u=U.distance(l,c);if(s<=u){let d=u===0?0:s/u;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d}}s-=u}return v(o[o.length-1])}beginTextEdit(t){this.textEdit.begin(t)}beginFrameNameEdit(t){let n=I(this._scene,t);n===void 0||!Be(n)||this.isLayerLocked(n.layerId)||(this.editingTextElement!==null&&this.commitTextEdit(),this._editingFrameName=t,this.notify())}commitFrameNameEdit(t){let n=this._editingFrameName;if(n===null)return;this._editingFrameName=null;let o=VR(this._scene,n,t);o&&(this._scene=o.scene,this._history.push(o.patch)),this.notify()}cancelFrameNameEdit(){this._editingFrameName!==null&&(this._editingFrameName=null,this.notify())}frameHeaderAt(t){return jR(this._scene,t)}setEditingText(t,n,o,a="forward"){this.textEdit.setText(t,n,o,a)}setEditingSelection(t,n,o="forward"){this.textEdit.setSelection(t,n,o)}caretIndexAtWorldPoint(t){return this.textEdit.caretIndexAtWorldPoint(t)}editedElementContainsPoint(t){return this.textEdit.editedElementContainsPoint(t)}setTextCaretFromPoint(t){this.textEdit.setCaretFromPoint(t)}extendTextSelectionToPoint(t){this.textEdit.extendSelectionToPoint(t)}endTextDragSelect(){this.textEdit.endDragSelect()}editingTextOverlay(){return this.textEdit.overlay()}commitTextEdit(t){this.textEdit.commit(t)}cancelTextEdit(){this.textEdit.cancel()}moveSelectionBy(t){if(this.readOnly||this._selection.size===0&&this._selectedLinks.size===0)return;let n=new Set([...this.expandSelectionWithDescendants()].filter(i=>{let l=I(this._scene,i);return l?this.isElementManipulable(l):!1})),o=this._selection.size>0?aR(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=BM(a,n,this._selectedLinks,t);if(!o&&r.patches.length===0)return;let s=this._history.transaction();if(this._scene=r.scene,o)for(let i of o.patches)s.add(i);for(let i of r.patches)s.add(i);s.commit(),this.notify(),this.announce(pR(t,o?.moved??0))}createElementAtCursor(){let t=this._scene.viewport,n=this.screenToWorld({x:(t.size.width||200)/2,y:(t.size.height||200)/2}),o=wS(++this.nextId),a=hO(this._scene,this.mode,n,this._activeLayerId,o),r=Fe(this._scene,a);return this._scene=r.scene,this._history.push(r.patch),this._selection=wt(o),this.notify(),this.announce(`Created ${a.type} ${o}`),o}createTextAt(t){let n=wS(++this.nextId),o=mO(this._scene,t,this._activeLayerId,n),a=Fe(this._scene,o);return this._scene=a.scene,this.textEdit.markPendingCreate(n),this._selection=wt(n),this.maybeRevertModeAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}_brushSettings=Nc;get brushSettings(){return this._brushSettings}setBrushSettings(t){this._brushSettings={...this._brushSettings,...t},this.notify()}beginBrushStroke(t,n=.5){this.brushStroke=tR(t,n,this._brushSettings.width),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(nR(this.brushStroke,t,n,this._brushSettings.width),this.notify())}commitBrushStroke(){let t=oR(this._scene,this.brushStroke,this._activeLayerId,yS(++this.nextId),zy(this._brushSettings));return t?(this._scene=t.scene,this._history.push(t.patch),this.brushStroke=null,this.notify(),t.elementId):(this.brushStroke=null,this.notify(),null)}cancelBrushStroke(){this.brushStroke&&(this.brushStroke=null,this.notify())}get pendingBrushStroke(){return this.brushStroke}beginEraseStroke(t,n=!1,o=!1){let a=hR(t,o);if(!n){let r=this.acceleratedElementAt(t);r&&!(o&&r.type==="brush")&&a.pending.add(r.id)}this.eraseStroke=a,this.eraseDirty=!0,o&&this.markStrokeEraseSegment(a,t,t),this.interaction.eraserTrail=[vy(t,Ri())],this.maybeAnimate(),this.notify()}markStrokeEraseSegment(t,n,o){let a=this._scene.viewport.zoom||1,r=this._brushSettings.width/a,s=!1;for(let i of this._scene.elements.values()){if(!Ha(i))continue;let l=t.erased.get(i.id)??[],c=LR(i,l,n,o,r);(c.length>l.length||vS(c)>vS(l)+1e-6)&&(t.erased.set(i.id,c),s=!0)}return s}extendEraseStroke(t,n=!1){let o=this.eraseStroke;if(!o)return;let a=mR(o.last,t,l=>this.acceleratedElementAt(l),o.pending,n,o.strokeMode),r=o.strokeMode?this.markStrokeEraseSegment(o,o.last,t):!1;(a||r)&&(this.eraseDirty=!0),o.last=t;let s=this.interaction.eraserTrail,i=s[s.length-1];i?(Mv(i,t,Ri()),this.interaction.eraserTrail=s.slice()):this.interaction.eraserTrail=[vy(t,Ri())],this.maybeAnimate(),this.notify()}commitEraseStroke(){let t=this.eraseStroke;if(!t)return 0;this.eraseStroke=null;let n=yR(this._scene,t.pending),o=n?n.scene:this._scene,a=n?[...n.patches]:[],r=[];if(t.strokeMode){let l=kR(o,t.erased,()=>yS(++this.nextId));l&&(o=l.scene,a.push(...l.patches),r.push(...l.removedIds))}if(a.length===0)return this.notify(),0;let s=this._history.transaction();this._scene=o;for(let l of a)s.add(l);s.commit();let i=this._selection;for(let l of t.pending)i=Tf(i,l);for(let l of r)i=Tf(i,l);return this._selection=i,this.notify(),t.pending.size+r.length}cancelEraseStroke(){this.eraseStroke&&(this.eraseStroke=null,this.notify())}get laserDrawing(){return this.interaction.laserDrawing}beginLaserStroke(t){this.interaction.laserStrokes=[...this.interaction.laserStrokes,vy(t,Ri())],this.interaction.laserDrawing=!0,this.maybeAnimate(),this.notify()}extendLaserStroke(t){if(!this.interaction.laserDrawing)return;let n=this.interaction.laserStrokes,o=n[n.length-1];o&&(Mv(o,t,Ri()),this.interaction.laserStrokes=n.slice(),this.maybeAnimate(),this.notify())}endLaserStroke(){this.interaction.laserDrawing=!1,this.maybeAnimate()}hasActiveLaser(){return this.interaction.laserStrokes.length>0||this.interaction.eraserTrail.length>0}get eraserTrail(){return this.interaction.eraserTrail}pruneLaser(){let t=this.interaction.laserStrokes;if(t.length>0){let o=Rv(t,Ri());o.changed&&(this.interaction.laserStrokes=o.strokes)}let n=this.interaction.eraserTrail;if(n.length>0){let o=Rv(n,Ri(),Z0);o.changed&&(this.interaction.eraserTrail=o.strokes)}}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=eO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Arranged ${o.count} shapes on a ${o.cols}-column grid`))}arrangeAsStack(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=tO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Stacked ${o.count} shapes ${o.direction}`))}groupSelected(){if(this.readOnly)return{kind:"noop"};let t=oO(this._scene,this._selection,sO(++this.nextId));if(!t)return{kind:"noop"};let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);return n.commit(),this._selection=wt(t.groupId),this.notify(),{kind:"grouped",groupId:t.groupId}}ungroup(){if(this.readOnly)return;let t=aO(this._scene,this._selection);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=new Set(t.nextSelection),this.notify()}selectionRoots(){return SS(this._scene,this._selection)}expandSelectionWithDescendants(){return nO(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=rO(this._scene,n,t);o&&(this._selection=wt(o.id),this.notify(),this.announce(`Selected ${o.name}`))}cancelInteraction(){this.cancelGesture(),this.actor.send({type:"POINTER_CANCEL"}),this.interaction.resetPreviews(),this.interaction.linkDragFromAnchor=null,this.interaction.editingLinkCaption=null,this.interaction.pendingLinkDropMenu=null,this.interaction.eraseStroke=null,this.interaction.laserDrawing=!1,this.flowchartSession=null,this.linkHandles.reset(),this._enteredGroup!==null&&(this._enteredGroup=null),this._selection=Pe,this._selectedLinks=yt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){if(this.readOnly)return;let t=rR(this._scene,this._selection,()=>++this.nextId);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),t.newIds.length>0&&(this._selection=gS(t.newIds)),this.notify()}duplicateSelectedInPlace(t=null){if(this.readOnly||this._selection.size===0)return null;let n=new Set,o=l=>{if(!n.has(l)){n.add(l);for(let c of this._scene.elements.values())(c.parentId===l||c.frameId===l)&&o(c.id)}};for(let l of this._selection)o(l);let a=new Map;for(let l of n)a.set(l,Ze(this.uniqueId("shape")));let r=SO(this._scene,n,a),s=this._history.transaction();this._scene=r.scene;for(let l of r.patches)s.add(l);s.commit();let i=[];for(let l of this._selection){let c=a.get(l);c!==void 0&&i.push(c)}return i.length>0&&(this._selection=gS(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=sR(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify())}selectLink(t){let n=t===null?yt:By(t),o=!Np(n,this._selectedLinks),a=this._selection.size>0;!o&&!a||(this._selection=Pe,this._selectedLinks=n,this.notify())}selectAll(){let t=iR(this._scene,this._selection),n=lR(this._scene),o=!Np(n,this._selectedLinks);if(!t&&!o)return;t&&(this._selection=t),this._selectedLinks=n,this.notify();let a=this._selection.size+this._selectedLinks.size;this.announce(`Selected ${a} objects`)}clipboard=[];copySelected(){let t=TR(this._scene,this._selection);t.length!==0&&(this.clipboard=[...t],this.announce(`Copied ${t.length} shapes`))}cutSelected(){this.readOnly||(this.copySelected(),this.deleteSelected())}paste(t){if(this.clipboard.length===0)return;this.finalizeOpenGestureTx();let n=t??this.lastPointerWorld,o=IR(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=MR(o.newIds),this.notify(),this.announce(`Pasted ${o.newIds.length} shapes`)}copySelectionStyle(){for(let t of this._selection){let n=I(this._scene,t);if(n!==void 0){this.styleClipboard={...n.style};return}}}pasteSelectionStyle(){this.styleClipboard!==null&&this.updateStyle(this._selection,this.styleClipboard)}get hasStyleClipboard(){return this.styleClipboard!==null}updateStyle(t,n){if(this.readOnly)return;let o=cR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}applyTextStyleToRange(t,n,o,a){if(this.readOnly)return;let r=uR(this._scene,t,n,o,a);r&&(this._scene=r.scene,this._history.push(r.patch),this.notify())}pickColorAt(t,n="fill"){return _S(this._scene,t,n)}pendingEyedropperPick=null;get isEyedropperArmed(){return this.pendingEyedropperPick!==null}beginEyedropperPick(t){this.pendingEyedropperPick=t,this.refreshCursor(),this.notify()}applyEyedropperAt(t){let n=_S(this._scene,t,"fill"),o=this.pendingEyedropperPick;return o!==null?(this.pendingEyedropperPick=null,n!==null&&o(n),this.refreshCursor(),this.notify(),n):n===null?null:(!this.readOnly&&this._selection.size>0&&this.updateStyle(this._selection,{fill:n}),this.mode==="eyedropper"&&!this.toolLocked&&this.setMode("select"),n)}convertSelection(t){if(this.readOnly)return;let n=kO(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}spawnConnectedNode(t){if(this.readOnly)return;let n=[...this._selection],o=n.length===1?n[0]:void 0;if(o===void 0)return;let a=MO(this._scene,o,t,zc(++this.nextId),Up(++this.nextId));a&&(this._scene=a.scene,this._history.push({kind:"batch",patches:[...a.patches]}),this.setSelection([a.newElementId]),this.notify())}flowchartSession=null;growFlowchart(t){if(this._readOnly||this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0||I(this._scene,o)===void 0)return;let a=this.flowchartSession,r=a?.direction===t&&a.sourceId===o?Math.min(a.count+1,r4):1,{elements:s,links:i}=RO(this._scene,o,t,r,()=>zc(++this.nextId),()=>Up(++this.nextId));this.flowchartSession={sourceId:o,direction:t,count:r,elements:s,links:i},this.notify()}commitFlowchart(){let t=this.flowchartSession;if(t===null)return null;let n=this._scene,o=[];for(let r of t.elements){let s=Fe(n,r);n=s.scene,o.push(s.patch)}for(let r of t.links){let s=fi(n,r);n=s.scene,o.push(s.patch)}this.flowchartSession=null;let a=t.elements[0]?.id??null;return o.length===0?(this.notify(),a):(this._scene=n,this._history.push({kind:"batch",patches:o}),a!==null&&this.setSelection([a]),this.notify(),a)}cancelFlowchart(){this.flowchartSession!==null&&(this.flowchartSession=null,this.notify())}get flowchartPreview(){let t=this.flowchartSession;return t===null?null:{elements:t.elements,links:t.links}}navigateFlowchart(t){if(this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0)return;let a=new Set;for(let r of this._scene.links.values()){let s=si(r.from),i=si(r.to);s===o&&i!==void 0&&i!==o?a.add(i):i===o&&s!==void 0&&s!==o&&a.add(s)}if(a.size>0){let r=this.combinedSelectionBounds(),s=r?{x:r.x+r.width/2,y:r.y+r.height/2}:{x:0,y:0},i=xS(this._scene,this._selection,t,s,l=>this.isElementInteractable(l)&&a.has(l.id));if(i!==null){this.setSelection([i]);return}}this.selectClosest(t)}cropSession=null;get imageCropSession(){let t=this.cropSession;return t===null?null:{id:t.id,crop:t.crop,position:t.position,width:t.width,height:t.height}}beginImageCrop(t){if(this.readOnly)return;let n=I(this._scene,t);n===void 0||!ct(n)||(this.cancelInteraction(),this._selection=wt(t),this.cropSession={id:t,crop:n.crop??Wy,position:n.position,width:n.width,height:n.height,drag:null,dragStartWorld:null},this.setMode("crop"),this.refreshCursor(),this.notify())}cropHandleAtWorld(t){let n=this.cropSession;if(n===null)return null;let o=I(this._scene,n.id);if(o===void 0)return null;let a=this.pendingCropElement(o),r=CO(a),s=this._scene.viewport.zoom||1,i=h4/s;for(let c of _O){let u=r[c];if(Math.hypot(t.x-u.x,t.y-u.y)<=i)return c}let l=li(a,t);return l.x>=0&&l.x<=n.width&&l.y>=0&&l.y<=n.height?"body":null}beginImageCropHandle(t,n){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"handle",handle:t},dragStartWorld:n})}beginImageCropBody(t){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"body"},dragStartWorld:t})}updateImageCropDrag(t){let n=this.cropSession;if(n?.drag==null||n.dragStartWorld===null)return;let o=I(this._scene,n.id);if(o===void 0)return;let a=o.crop??Wy;if(n.drag.kind==="handle"){let r=EO(o,a,n.drag.handle,t);this.cropSession={...n,crop:r.crop,position:r.position,width:r.width,height:r.height}}else{let r=TO(o,a,n.dragStartWorld,t);this.cropSession={...n,crop:r.crop}}this.notify()}endImageCropDrag(){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:null,dragStartWorld:null})}commitImageCrop(){let t=this.cropSession;if(t===null)return;let n=IO(this._scene,t.id,{crop:t.crop,position:t.position,width:t.width,height:t.height});this.cropSession=null,n&&(this._scene=n.scene,this._history.push(n.patch)),this.setMode("select"),this.refreshCursor(),this.notify()}cancelImageCrop(){this.cropSession!==null&&(this.cropSession=null,this.setMode("select"),this.refreshCursor(),this.notify())}pendingCropElement(t){let n=this.cropSession;return n===null?t:{...t,position:n.position,width:n.width,height:n.height}}cropFrameCorners(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=this.pendingCropElement(n),a=Re(o);return[{x:a.x,y:a.y},{x:a.x+a.width,y:a.y},{x:a.x+a.width,y:a.y+a.height},{x:a.x,y:a.y+a.height}].map(r=>Mn(o,r))}cropGhost(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=n.crop??Wy;return{element:n,fullRect:qy(n,o)}}updateTextProps(t,n){if(this.readOnly)return;let o=dR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){if(this.readOnly)return;let n=fR(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}setLink(t,n){if(this.readOnly)return;let o=n===null?null:lO(n),a=cO(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=Gy(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return Gy(I(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=Gy(n.href);return o?{id:n.id,href:o,bounds:z(n)}:null}bringToFront(t){if(this.readOnly)return;let n=YR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendToBack(t){if(this.readOnly)return;let n=KR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}bringForward(t){if(this.readOnly)return;let n=$R(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendBackward(t){if(this.readOnly)return;let n=QR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(XO(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(YO(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(KO(this._scene,this._selection,t))}rotateSelection(t){let n=[],o=new Map;for(let r of this._selection){let s=I(this._scene,r);s!==void 0&&(n.push(s),o.set(r,{position:s.position,rotation:s.rotation}))}if(n.length===0)return;let a=$O(n);this.commitArrange(RS(this._scene,o,a,t))}commitArrange(t){if(this.readOnly||t.length===0)return;let n=this._history.transaction();for(let o of t)this._scene=Q(this._scene,o),n.add(o);n.commit(),this.notify()}compactLayerZOrder(t,n={}){let o=n.recordHistory??!0,a=t?[t]:[...this._scene.layers.keys()],r=o?this._history.transaction():null;if(JR(this._scene,a,(i,l)=>{this._scene=i,r?.add(l)})===0){r?.cancel();return}r?.commit(),this.notify(),o&&this.announce(`Compacted z-order across ${a.length} layer(s)`)}clear(){this.readOnly||this._scene.elements.size===0&&this._scene.links.size===0||(this._scene={...this._scene,elements:new Map,links:new Map},this._selection=Pe,this._selectedLinks=yt,this._history.clear(),this.notify())}get activeLayerId(){return this._activeLayerId}setActiveLayer(t){this._scene.layers.has(t)&&this._activeLayerId!==t&&(this._activeLayerId=t,this.notify())}createLayer(t){let n=RR(this._scene,t,zR(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=OR(this._scene,t,this._activeLayerId);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this._activeLayerId=n.nextActiveLayerId,this._selection=Pe,this.notify()}renameLayer(t,n){let o=DR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=PR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=BR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){if(this.readOnly)return;let n=NR(this._scene,this._selection,t);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this.notify()}panBy(t){let n=WM(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(y2)}zoomOut(){this.zoomStep(1/y2)}zoomStep(t){let n=this._scene.viewport;if(n.size.width<=0||n.size.height<=0)return;let o=this.screenToWorld({x:n.size.width/2,y:n.size.height/2});this.zoomAt(t,o)}resetZoom(){let t=jM(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=ZM(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=hS(this._scene,n,t);o&&(this._scene=o,this.notify())}revealSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=VM(this._scene,n,t);o&&(this._scene=o,this.notify())}selectClosest(t){let n=this.combinedSelectionBounds(),o=this._scene.viewport,a=n?{x:n.x+n.width/2,y:n.y+n.height/2}:{x:o.pan.x+o.size.width/2/o.zoom,y:o.pan.y+o.size.height/2/o.zoom},r=xS(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=qM(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=XM(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=YM(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return I0(this._scene.viewport)}setSnapToGrid(t){this.setGrid({snap:t})}setSnapSuppressed(t){this.interaction.snapSuppressed=t}setTransformModifiers(t){this.interaction.transformAltKey=t.alt,this.interaction.transformShiftKey=t.shift}snapActive(){let t=this._scene.viewport;return!this.interaction.snapSuppressed&&t.gridEnabled&&I0(t)}snapSpacing(){return NA()}loadScene(t,n={}){if(this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),this._scene=t,!t.layers.has(this._activeLayerId)){let o=t.layers.keys().next().value;this._activeLayerId=o??ln(Rn)}n.preserveHistory?this.pruneSelection():(this._selection=Pe,this._history.clear()),rS(this),sS(this),this.notify(),this.maybeAnimate()}dispose(){this.cancelLongPress(),this.unbind(),this.actor.stop(),this.listeners.clear(),this.cursorListeners.clear(),this.longPressListeners.clear(),this.announceListeners.clear(),this.animation.detach(),this.animationContentOff?.(),this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null)}bindPointerEvents(){return JM(this)}beginPanGesture(t,n,o){this.actor.send({type:"POINTER_CANCEL"}),this.cancelGesture(),this.cancelLongPress(),this.host.setPointerCapture(t),this.panGesture={pointerId:t,button:n,startPoint:o,lastPoint:o,moved:!1},this.refreshCursor()}endPanGesture(){let t=this.panGesture;if(this.panGesture=null,t&&(t.button===2||t.button===1)&&!t.moved){let n=this.screenToWorld(t.startPoint);for(let o of this.longPressListeners)o({screenPoint:t.startPoint,worldPoint:n})}this.refreshCursor()}isDrawingPhase(t){return t.mode==="draw-rect"||t.mode==="draw-ellipse"||t.mode==="draw-edge"}startLongPress(t){this.longPress.start(t)}cancelLongPress(){this.longPress.cancel()}beginPinch(){this.pinch.begin([...this.activePointers.values()])}applyPinch(){this.pinch.apply([...this.activePointers.values()])}screenToWorld(t){return N.applyToPoint(Wa(this._scene.viewport),t)}linkAttachTargetAt(t){let n=this.acceleratedElementAt(t);if(n&&this.isElementInteractable(n)){let o=this.promoteToGroupRoot(n);return{kind:"element",id:o.id,bounds:z(o)}}}hitTest(t){return z5(t,{scene:this._scene,selection:this._selection,selectedLink:this.selectedLink,selectedLinkCount:this._selectedLinks.size,enteredGroup:this._enteredGroup,handleHitSlop:this.handleHitSlop,edgeHandleHitSlop:this.edgeHandleHitSlop,edgeHitThreshold:this.edgeHitThreshold,hitAnnotation:n=>this.hitAnnotation(n),selectionIsAspectLocked:()=>this.selectionIsAspectLocked(),combinedSelectionBounds:()=>this.combinedSelectionBounds(),acceleratedElementAt:n=>this.acceleratedElementAt(n),isElementInteractable:n=>this.isElementInteractable(n),isLayerLocked:n=>this.isLayerLocked(n),promoteToGroupRoot:n=>this.promoteToGroupRoot(n)})}refreshCursor(t){let n=ZR(this,t??this.lastPointerWorld);this.host.style.cursor!==n&&(this.host.style.cursor=n)}setCursorOverride(t,n){n===null?this.cursorOverrides.delete(t):this.cursorOverrides.set(t,n),this.refreshCursor()}getCursorOverride(t){return this.cursorOverrides.get(t)}isLayerLocked(t){return this._scene.layers.get(t)?.locked===!0}isElementInteractable(t){return!(this.isLayerLocked(t.layerId)||ic(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||xA(this._scene,t)||ic(this._scene,t))}toggleLockSelection(){if(this.readOnly||this._selection.size===0)return;let t=[...this._selection],n=t.some(a=>I(this._scene,a)?.locked!==!0),o=this._history.transaction();for(let a of t){let r=J(this._scene,a,s=>{let i={...s};return n?i.locked=!0:delete i.locked,i});this._scene=r.scene,o.add(r.patch)}o.commit(),this.notify()}promoteToGroupRoot(t){return iM(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return sM(this._scene,t)}isDescendantOfGroup(t,n){return aS(this._scene,t,n)}computeHiddenElements(){return GO(this._scene)}computeStrokeErasePreview(){let t=this.eraseStroke;if(!t||!t.strokeMode||t.erased.size===0)return null;let n=wR(this._scene,t.erased);return n?{elements:n.fragments,hidden:n.hidden}:null}computeDimElements(t){return lM(this._scene,this._selection,t)}computeDimSet(){let t=this._enteredGroup?this.computeDimElements(this._enteredGroup):void 0,n=this.interaction.eraseStroke?.pending;if(!n||n.size===0)return t;let o=new Set(t);for(let a of n)o.add(a);return o}enterGroup(t){this._enteredGroup=t,this.notify()}enterContainer(){if(this._selection.size!==1)return;let t=v([...this._selection][0]),n=I(this._scene,t);if(!n)return;let o=Be(n),a=[];for(let r of this._scene.elements.values())(r.parentId===t||o&&r.frameId===t)&&a.push(r.id);a.length!==0&&(ze(n)&&(this._enteredGroup=t),this.setSelection(a))}exitContainer(){if(this._selection.size===0)return;let t,n=!0;for(let o of this._selection){let a=I(this._scene,o),r=a?.parentId??a?.frameId;if(r===void 0){n=!1;break}if(t===void 0)t=r;else if(t!==r){n=!1;break}}this._enteredGroup=null,n&&t!==void 0?this.setSelection([t]):this.notify()}get enteredGroup(){return this._enteredGroup}acceleratedElementAt(t){return this._scene.elements.size<x2?ci(this._scene,t):vA(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=AA(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.interaction.lastClickAt<G0&&this.interaction.lastClickWorldPoint!==null&&U.distance(this.interaction.lastClickWorldPoint,n)<=W0;if(this.interaction.lastClickAt=o,this.interaction.lastClickWorldPoint=n,a){let r=this.frameHeaderAt(n);if(r!==null)return this.beginFrameNameEdit(r),!0}if(!t)return!1;if(this._enteredGroup!==null){let r=t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE"?t.id:null;if(!(r!==null&&this.isDescendantOfGroup(r,this._enteredGroup)))return this._enteredGroup=null,this.notify(),!1}if(a&&t.type==="SELECT_EDGE_REPLACE")return this._selectedLinks=By(t.id),this._selection=Pe,this.beginLinkCaptionEdit(t.id),!0;if(a&&(t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE")){let r=this.acceleratedElementAt(n);if(r!==void 0&&fe(r))return this.beginTextEdit(r.id),!0;if(r!==void 0&&Be(r))return this.beginFrameNameEdit(r.id),!0;if(r){let s=this.topGroupAncestor(r),i=this.pickDrillTarget(r,s);if(i)return this._enteredGroup=i.id,this._selection=wt(r.id),this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return cM(this._scene,t,n,this._enteredGroup)}applyEmit(t){if(!(this._readOnly&&Zq.has(t.type)))switch(t.type){case"SELECT_REPLACE":this._selection=wt(t.id),this._selectedLinks=yt,this.notify();return;case"SELECT_TOGGLE":this._selection=tA(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Pe,this._selectedLinks=yt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=By(t.id),this._selection=Pe,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=UM(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=yt,this.notify());return;case"UPDATE_EDGE_ENDPOINT_PREVIEW":this.applyLinkEndpointMove(t.linkId,t.side,t.toPoint);return;case"UPDATE_EDGE_ENDPOINT":this.applyLinkEndpointUpdate(t);return;case"LASSO_PROGRESS":this.interaction.lassoBaseSelection??=this._selection,this.interaction.lassoBaseLinks??=this._selectedLinks,this.lassoPreview=t.bounds,this.applyLassoLiveSelection(t.bounds,t.mode),this.notify();return;case"LASSO_CLEAR":(this.lassoPreview!==null||this.interaction.lassoBaseSelection!==null||this.interaction.lassoBaseLinks!==null)&&(this.lassoPreview=null,this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.notify());return;case"SELECT_BY_BOUNDS":this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.applySelectByBounds(t.bounds,t.mode);return;case"MOVE_SHAPE":this.groupMoveOrigin?this.applyGroupMove(t.delta):this.applyMove(t.id,t.delta,t.originalBounds);return;case"RESIZE_GROUP":this.applyGroupResize(t.handle,t.delta,t.originalBounds);return;case"RESIZE_SHAPE":this.applyResize(t.id,t.handle,t.delta,t.originalBounds);return;case"ROTATE":this.applyRotate(t.deltaAngle);return;case"CREATE_SHAPE":this.applyCreate(t.shapeType,t.bounds);return;case"CREATE_EDGE":this.applyCreateLink(t);return;case"DRAW_EDGE_PREVIEW":this.applyLinkPreview(t.fromElement,t.fromPoint,t.toPoint);return;case"DRAW_EDGE_PREVIEW_CLEAR":this.edgePreview&&(this.edgePreview=null,this.notify());return;case"TEMPLATE_TAP":for(let n of this.templateTapListeners)n(t);return;case"TEMPLATE_DROP":for(let n of this.templateDropListeners)n(t);return;case"MOVE_ANNOTATION":this.applyAnnotationMove(t.id,t.delta,t.originalPosition);return;case"COMMIT_ANNOTATION_DRAG":this.finalizeOpenGestureTx();return}}applyAnnotationMove(t,n,o){let a=ZO(this._scene,t,n,o);a&&(this._scene=a.scene,this.recordGesturePatch(a.patch),this.notify())}templateTapListeners=new Set;templateDropListeners=new Set;onTemplateTap(t){return this.templateTapListeners.add(t),()=>this.templateTapListeners.delete(t)}onTemplateDrop(t){return this.templateDropListeners.add(t),()=>this.templateDropListeners.delete(t)}dispatchTemplateDrop(t){this.applyEmit(t)}applyMove(t,n,o){let a=I(this._scene,t);if(a&&!this.isElementManipulable(a))return;let r=this.interaction.transformShiftKey?TS(n):n,s=this.snapActive()?e8(o,r,this.snapSpacing()):r,i=jO(this._scene,t,s,o);i&&(this._scene=Q(this._scene,i),this.recordGesturePatch(i),this.notify())}applyGroupMove(t){if(!this.groupMoveOrigin)return;let n=this.interaction.transformShiftKey?TS(t):t,o=this.snapActive()?t8(this.groupMoveOrigin,n,this.snapSpacing()):n,a=VO(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=Q(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=PM(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=Q(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return HO(this._scene)}computeDirtyWorld(){let t=this.lastRenderedScene,n=this._scene;if(!t||t.viewport.size.width<=0||t.viewport.size.height<=0||n.viewport.size.width<=0||n.viewport.size.height<=0||this.gestureTx!==null||this.dragElementId!==null||this.drawingPreview!==null||this.edgePreview!==null||this.brushStroke!==null||this.lassoPreview!==null||this.interaction.eraseStroke!==null&&this.eraseDirty||t.viewport!==n.viewport||t.layers!==n.layers||this.lastRenderedEnteredGroup!==this._enteredGroup||this.lastRenderedEraseActive)return null;let{world:o,tileDirty:a}=SM(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=UO(this._scene,this._selection);for(let n of this._selectedLinks){let o=be(this._scene,n);if(!o)continue;let a=ot(this._scene,o);if(!a||a.length===0)continue;let r=1/0,s=1/0,i=-1/0,l=-1/0;for(let u of a)u.x<r&&(r=u.x),u.y<s&&(s=u.y),u.x>i&&(i=u.x),u.y>l&&(l=u.y);let c={x:r,y:s,width:i-r,height:l-s};t=t?V.union(t,c):c}return t}groupChildrenUnion(t){return Xy(this._scene,t)}selectionIsAspectLocked(){if(this._selection.size===0)return!1;if(this._selection.size===1){let[t]=[...this._selection];if(!t)return!1;let n=I(this._scene,t)?.type;return n==="group"||n==="image"}for(let t of this._selection){let n=I(this._scene,t);if(n===void 0||!ct(n))return!1}return!0}applyRotate(t){let n=this.rotateGestureOrigin;if(!n)return;let o=this.interaction.transformShiftKey?Math.round(t/a2)*a2:t,a=RS(this._scene,n.origin,n.pivot,o);for(let r of a)this._scene=Q(this._scene,r),this.recordGesturePatch(r);this.notify()}applyGroupResize(t,n,o){if(!this.groupResizeOrigin)return;let a=this.snapActive()?OS(o,t,n,this.snapSpacing()):n,r=HM(this._scene,this.groupResizeOrigin,t,a,o,this.selectionIsAspectLocked()||this.interaction.transformShiftKey,this.interaction.transformAltKey);this._scene=r.scene;for(let s of r.patches)this.recordGesturePatch(s);this.notify()}applyResize(t,n,o,a){let r=I(this._scene,t);if(r!==void 0&&!fe(r)&&r.rotation!==0){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=zM(this._scene,this.interaction.resizeOriginElement,n,o,this.interaction.transformShiftKey,this.interaction.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let s=this.snapActive()?OS(a,n,o,this.snapSpacing()):o;if(r!==void 0&&fe(r)){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=this.interaction.resizeOriginElement,c=fe(l)?l:r,u=FM(this._scene,c,n,s,a,this.interaction.transformAltKey);if(!u)return;this._scene=u.scene,this.recordGesturePatch(u.patch),this.notify();return}let i=NM(this._scene,t,n,s,a,(l,c,u)=>this.clampContainerToChildren(l,c,u),this.interaction.transformShiftKey,this.interaction.transformAltKey);i&&(this._scene=i.scene,this.recordGesturePatch(i.patch),this.notify())}applyCreate(t,n){let o=zc(++this.nextId),a=this.snapActive()?n8(n,this.snapSpacing()):n,r=pO(this._scene,t,a,o,this._activeLayerId,()=>this.nextFrameName());this._scene=r.scene,this._selection=wt(o),this._history.push(r.patch),t==="frame"&&this.assignFrameMembers(o,a),this.maybeRevertModeAfterCreate(),this.notify()}nextFrameName(){return uM(this._scene)}assignFrameMembers(t,n){this._scene=dM(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=fM(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=Up(++this.nextId),r=Hp(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertModeAfterCreate(),o.kind==="point"&&(this.interaction.pendingLinkDropMenu={linkId:a,side:"to",world:o.position}),this.notify()}get linkDropMenu(){return this.interaction.pendingLinkDropMenu}placeShapeAtLinkDrop(t){let n=this.interaction.pendingLinkDropMenu;if(!n)return;if(!be(this._scene,n.linkId)){this.interaction.pendingLinkDropMenu=null,this.notify();return}let a=zc(++this.nextId),r=LO(this._scene,this._activeLayerId,n,a,t),s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this.interaction.pendingLinkDropMenu=null,this._selection=wt(a),this._selectedLinks=yt,this.notify()}dismissLinkDropMenu(){this.interaction.pendingLinkDropMenu&&(this.interaction.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=zc(++this.nextId),a=Up(++this.nextId),r=vO(this._scene,this._activeLayerId,t,n,o,a);if(!r)return;let s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this._selection=wt(o),this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify()}previewClickCreate(t,n){return AO(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return uO(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=WO(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=ES(this._scene,n==="add"?this._selectedLinks:yt,s=>this.isLayerLocked(s),t,n),r=!Np(a,this._selectedLinks);if(this._selectedLinks=a,oi(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.interaction.lassoBaseSelection??Pe,a=qO(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.interaction.lassoBaseLinks??yt,s=ES(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!Np(s,this._selectedLinks);oi(a,this._selection)&&!i||(this._selectedLinks=s,this._selection=a)}applyLinkEndpointMove(t,n,o){this.linkHandles.applyEndpointMove(t,n,o)}applyLinkEndpointUpdate(t){this.linkHandles.applyEndpointUpdate(t)}get isDraggingWaypoint(){return this.linkHandles.isDraggingWaypoint}beginWaypointDrag(t,n,o){this.linkHandles.beginWaypointDrag(t,n,o)}updateWaypointDrag(t){this.linkHandles.updateWaypointDrag(t)}endWaypointDrag(){this.linkHandles.endWaypointDrag()}get isDraggingSegment(){return this.linkHandles.isDraggingSegment}beginSegmentDrag(t,n,o){this.linkHandles.beginSegmentDrag(t,n,o)}updateSegmentDrag(t){this.linkHandles.updateSegmentDrag(t)}endSegmentDrag(){this.linkHandles.endSegmentDrag()}isHandleDoubleClick(t){return this.linkHandles.isHandleDoubleClick(t)}deleteWaypoint(t,n){this.linkHandles.deleteWaypoint(t,n)}resetSegmentPin(t,n,o,a){this.linkHandles.resetSegmentPin(t,n,o,a)}get selectedLinkAvoidsObstacles(){let t=this.selectedLink;return t===null?!1:be(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=be(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=et(this._scene,n,r=>({...r,avoidObstacles:t,...t?{routing:"orthogonal"}:{}}));this._scene=a.scene,this._history.push(a.patch),this.elbowRoutes.delete(n),this.notify()}updateHoveredLinkTarget(t){let n=this.acceleratedElementAt(t);if(!n){this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null,this.notify());return}let a=this.snapEngine.snap({scene:this._scene,probe:t,threshold:this.snapThreshold,gesture:"draw-edge"}).all.filter(p=>p.metadata?.elementId===n.id),r=a.find(p=>p.kind==="anchor"),s=a.find(p=>p.kind==="outline"),i=r?.metadata?.ref,l=dA(i)?i:void 0,c=null;l?.kind==="named"?c=l.name:l?.kind==="edge"&&l.t===.5&&(c=`edge-${l.index}`);let u=!c&&s?s.snapped:void 0,d=this.hoveredLinkTarget;if(d?.elementId===n.id&&d.activeAnchor===c&&d.outlinePoint?.x===u?.x&&d.outlinePoint?.y===u?.y)return;let f=c!==null||u?"point":"element";this.hoveredLinkTarget={elementId:n.id,activeAnchor:c,outlinePoint:u,mode:f},this.notify()}applyLinkPreview(t,n,o){let a=NO(this._scene,t,n,o);if(hi==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=o2(this._scene,t,a.from,s,a.to);this.edgePreview={...a,points:i}}else this.edgePreview=a;this.notify()}recordGesturePatch(t){this.gestureTx===null&&(this.gestureStartScene=Q(this._scene,pc(t))),this.gestures.record(t)}commitGesture(){this.interaction.resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.commit(),this.gestureStartScene=null}finalizeOpenGestureTx(){this.gestures.finalize()}applyContainerDrop(t){kM(this.containerOpsRef,t)}maybeGrowContainer(t,n){Pp(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return LM(this._scene,t,n,o)}beginOrAttachGesture(){return this.gestureTx??=this._history.transaction(),this.gestureTx}cancelGesture(){this.interaction.resizeOriginElement=null,this.interaction.rotateGestureOrigin=null,this.gestures.cancel(),this.gestureStartScene!==null&&(this._scene=this.gestureStartScene,this.gestureStartScene=null)}pruneSelection(){let t=null;for(let n of this._selection)this._scene.elements.has(n)||(t??=new Set(this._selection),t.delete(n));t!==null&&(this._selection=t)}notify(){this.scheduleRender(),hM(this.eventCache,this.events,this.observableSnapshot());for(let t of this.listeners)t();this.autoCompactScheduler.schedule(),this.autoLayoutScheduler.schedule(),this.maybeAnimate()}renderRafId=null;animationContentOff=null;scheduleRender(){if(this.renderRafId===null){if(typeof requestAnimationFrame>"u"){this.render();return}this.renderRafId=requestAnimationFrame(()=>{this.renderRafId=null,this.render()})}}forceRender(){this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null),this.render()}on(t,n){return this.events.on(t,n)}off(t,n){this.events.off(t,n)}runLayout(t){let n=Jf(this._scene,t);return n?(this._scene=Q(this._scene,n),this._history.push(n),this.autoLayoutScheduler.resetSignature(t),this.notify(),n):null}elbowRoutes=new Map;rerouteElbows(){let t=this._scene;for(let[n,o]of this._scene.links){if((o.routing??"straight")!=="orthogonal")continue;let a=FO(this._scene,o);if(this.elbowRoutes.get(n)?.sig===a)continue;let r=tp(t,o);this.elbowRoutes.set(n,{sig:a,points:r}),t=et(t,n,s=>({...s,routedPoints:r})).scene}this._scene=t}buildRenderSnapshot(){let t=this.computeStrokeErasePreview(),n=this.computeHiddenElements(),o=t===null?n:new Set([...n??[],...t.hidden]);return{mainTarget:this.mainTarget,overlayTarget:this.overlayTarget,backgroundTarget:this.backgroundTarget,scene:this._scene,selection:this._selection,selectedLinks:this._selectedLinks,selectedLink:this.selectedLink,selectedAnnotation:this._selectedAnnotation,enteredGroup:this._enteredGroup,gridEnabled:this.gridEnabled,viewportWorld:this.computeViewportWorld(),dirtyWorld:this.computeDirtyWorld(),dimElements:this.computeDimSet(),eraseActive:(this.interaction.eraseStroke?.pending.size??0)>0,hideElements:o,strokeErasePreview:t,sharedIndex:this._scene.elements.size>=x2?this.ensureSpatialIndex():null,boundsCache:this.boundsCache,animationClock:a=>this.gifPlayback.clock(Ze(typeof a.id=="string"?a.id:"")),tileComposeFn:this.tileComposeFn,tileDirtyElements:this.tileDirtyElements,mode:this.mode,activeLayerId:this._activeLayerId,cropFrame:this.cropFrameCorners(),cropGhost:this.cropGhost(),flowchartPreview:this.flowchartPreview,lassoPreview:this.lassoPreview,drawingPreview:this.drawingPreview,edgePreview:this.edgePreview,linkDragFromAnchor:this.linkDragFromAnchor,hoveredLinkTarget:this.hoveredLinkTarget,panGesture:this.panGesture,pinchActive:this.pinch?.isActive()??!1,gestureActive:this.gestureTx!==null,linkEndpointDrag:this.linkEndpointDrag,linkSegmentDrag:this.linkSegmentDrag,linkWaypointDrag:this.linkWaypointDrag,hoverCursorWorld:this.hoverCursorWorld,anchorStartHitSlop:this.anchorStartHitSlop,anchorClickRadius:this.anchorClickRadius,containerHover:this.containerHover,brushStroke:this.brushPreviewStroke,laserStrokes:this.interaction.laserStrokes,eraserTrail:this.interaction.eraserTrail,eraserCursor:this.mode==="erase"&&!this._readOnly&&this.lastPointerWorld!==null?{center:this.lastPointerWorld,radius:this._brushSettings.width}:null,peerCursors:this._peerCursors,peerSelections:this._peerSelections,debugHitZones:this.debugHitZones,readOnly:this._readOnly,groupMoveOrigin:this.groupMoveOrigin,aspectLocked:this.selectionIsAspectLocked(),combinedSelectionBounds:this.combinedSelectionBounds(),editingText:this.editingTextOverlay(),previewClickCreate:(a,r)=>this.previewClickCreate(a,r),isPlaybackPaused:a=>this.isPlaybackPaused(a)}}render(){this.rerouteElbows(),this.pruneLaser();let t=this.buildRenderSnapshot();PO(t),this.lastRenderedScene=this._scene,this.lastRenderedEnteredGroup=this._enteredGroup,this.lastRenderedEraseActive=t.eraseActive,this.eraseDirty=!1;let n=t.dimElements!==void 0&&t.dimElements.size>0||t.hideElements!==void 0&&t.hideElements.size>0;t.tileComposeFn&&t.viewportWorld&&!n&&(this.tileDirtyElements=new Map),this.onAfterRender?.()}},Yq=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var DS=P(se(),1),Uc=P(re(),1),Ky=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,Uc.useRef)(null),l=(0,Uc.useRef)(null);if((0,Uc.useEffect)(()=>{if(!e)return;l.current=document.activeElement;let d=p=>{p.key==="Escape"&&(p.preventDefault(),t())};window.addEventListener("keydown",d);let f=i.current;return f&&(f.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??f).focus(),()=>{window.removeEventListener("keydown",d),l.current?.focus()}},[e,t]),(0,Uc.useEffect)(()=>{if(!e)return;let d=f=>{if(f.key!=="Tab")return;let p=i.current;if(!p)return;let h=p.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(h.length===0)return;let m=h[0],x=h[h.length-1];if(m===void 0||x===void 0)return;let y=document.activeElement;f.shiftKey&&y===m?(f.preventDefault(),x.focus()):!f.shiftKey&&y===x&&(f.preventDefault(),m.focus())};return window.addEventListener("keydown",d,!0),()=>{window.removeEventListener("keydown",d,!0)}},[e]),!e)return null;let c={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},u={background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderRadius:8,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.45)",maxWidth:"calc(100vw - 64px)",maxHeight:"calc(100vh - 64px)",overflow:"auto",outline:"none",...s};return(0,DS.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,DS.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var Kq={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",mode:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},$q=["mode","edit","selection","clipboard","history","z-order","grouping","arrange","layout","zoom","other"],PS=e=>{(0,Gc.useEffect)(()=>{let t=n=>{let o=n.target;o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||!(n.key==="?"||n.shiftKey&&n.key==="/")||(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e])},Qq=e=>{let t=[],n=e.hotkey??e.displayHotkey;if(n){let o=Array.isArray(n)?n:[n];for(let a of o)t.push(ky(a))}if(e.sequence&&e.sequence.length>0){let o=e.sequence.map(a=>a.length===1?a.toUpperCase():a).join(" ");t.push([o])}return t},Wp=({registry:e=_e,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,Gc.useMemo)(()=>{let c=new Map;for(let d of e.getAll()){if(!d.label)continue;let f=d.category??"other",p=c.get(f)??[];p.push({label:d.label,keys:Qq(d)}),c.set(f,p)}let u=[];for(let d of $q){let f=c.get(d);!f||f.length===0||u.push({title:Kq[d],rows:f})}return a&&u.push(...a),u},[e,a]),s={maxWidth:720,width:"calc(100vw - 64px)",display:"flex",flexDirection:"column"},i={padding:"16px 20px",borderBottom:"1px solid var(--du-ui-border)",display:"flex",alignItems:"center",justifyContent:"space-between"},l={padding:"16px 20px 20px",overflowY:"auto"};return(0,Ye.jsx)(Ky,{open:t,onClose:n,title:o,style:s,children:(0,Ye.jsxs)("div",{children:[(0,Ye.jsxs)("div",{style:i,children:[(0,Ye.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,Ye.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,Ye.jsx)("span",{className:"du-help-platform-badge",children:rs?"macOS":"Win / Linux"}),(0,Ye.jsx)("button",{type:"button","aria-label":"Close help",onClick:n,style:{background:"transparent",border:"none",color:"var(--du-text)",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:4},children:(0,Ye.jsx)(Na,{size:18,strokeWidth:1.75})})]})]}),(0,Ye.jsx)("div",{style:l,children:(0,Ye.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,Ye.jsxs)("section",{className:"du-help-island",children:[(0,Ye.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,Ye.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,Ye.jsxs)("div",{className:"du-help-row",children:[(0,Ye.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,Ye.jsx)(Jq,{combos:u.keys})]},u.label))})]},c.title))})})]})})},Jq=({combos:e})=>e.length===0?(0,Ye.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,Ye.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,Ye.jsxs)(Gc.Fragment,{children:[n>0?(0,Ye.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,Ye.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var ej=16,tj=1.75,$y=({renderDialog:e})=>{let[t,n]=(0,o8.useState)(!1);return(0,ss.jsxs)(ss.Fragment,{children:[(0,ss.jsx)(Qn,{label:"Help",onClick:()=>{n(!0)},children:(0,ss.jsx)(Tn,{size:ej,strokeWidth:tj})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,ss.jsx)(Wp,{open:t,onClose:()=>{n(!1)}})]})};var Zp=P(se(),1),r8=P(re(),1);var qp=P(re(),1);var a8=`(pointer: coarse), (max-width: ${640}px)`,nj=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(a8).matches:!1,jp=()=>(0,qp.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(a8);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},nj,()=>!1),G=()=>Nb(),oj=WA(),Ya=()=>sn(e=>e.scene,oj,"scene"),Qy=()=>sn(e=>e.selection,qo.EMPTY,"selection"),Vp=()=>sn(e=>e.mode,"select","mode"),BS=()=>sn(e=>e.brushSettings,Nc),is=()=>sn(e=>e.readOnly,!1),NS=()=>{let e=G(),t=sn(r=>r.canUndo,!1,"history"),n=sn(r=>r.canRedo,!1,"history"),o=(0,qp.useCallback)(()=>{e?.undo()},[e]),a=(0,qp.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var Zhe=ln(Rn);var zS=()=>sn(e=>e.selectedLink,null);var aj=14,rj=1.75,FS=()=>{let e=G(),t=Ya(),n=(0,r8.useMemo)(()=>sj(t),[t]);return!e||t.elements.size===0||!n?null:(0,Zp.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,Zp.jsx)(Yd,{size:aj,strokeWidth:rj,"aria-hidden":!0}),(0,Zp.jsx)("span",{children:"Back to content"})]})},sj=e=>{if(e.elements.size===0)return!1;let t=e.viewport;if(t.size.width<=0||t.size.height<=0)return!1;let n=null;for(let c of e.elements.values()){let u=z(c);n=n?V.union(n,u):u}if(!n)return!1;let o=Wa(t),a=N.applyToPoint(o,{x:0,y:0}),r=N.applyToPoint(o,{x:t.size.width,y:t.size.height}),s={x:Math.min(a.x,r.x),y:Math.min(a.y,r.y),width:Math.abs(r.x-a.x),height:Math.abs(r.y-a.y)},i=n.x<s.x+s.width&&s.x<n.x+n.width,l=n.y<s.y+s.height&&s.y<n.y+n.height;return!(i&&l)};var mn=P(se(),1),Ki=P(re(),1);var gt=P(se(),1),co=P(re(),1);var Jy=class{items=new Map;register(t){if(this.items.has(t.id))throw new Error(`Template already registered: ${t.id}`);this.items.set(t.id,t)}replace(t){this.items.set(t.id,t)}get(t){return this.items.get(t)}has(t){return this.items.has(t)}list(){return[...this.items.values()]}byCategory(t){return this.list().filter(n=>n.category===t)}categories(){let t=new Set;for(let n of this.items.values())t.add(n.category);return[...t]}clear(){this.items.clear()}},Oi=new Jy;var nme={...ns.rectangle},ome={...ns.sticky},ame={...ns.flowchart};var HS=(e,t)=>{let n=t.trim().toLowerCase();if(!n||e.name.toLowerCase().includes(n)||typeof e.category=="string"&&e.category.toLowerCase().includes(n))return!0;if(e.tags){for(let o of e.tags)if(o.toLowerCase().includes(n))return!0}return!1};var C={};ho(C,{BRAND:()=>Rj,DIRTY:()=>Di,EMPTY_PATH:()=>uj,INVALID:()=>Z,NEVER:()=>yV,OK:()=>Gt,ParseStatus:()=>Pt,Schema:()=>le,ZodAny:()=>us,ZodArray:()=>Ja,ZodBigInt:()=>Bi,ZodBoolean:()=>Ni,ZodBranded:()=>Yp,ZodCatch:()=>Xi,ZodDate:()=>zi,ZodDefault:()=>Zi,ZodDiscriminatedUnion:()=>ng,ZodEffects:()=>lo,ZodEnum:()=>ji,ZodError:()=>pn,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>ag,ZodIntersection:()=>Gi,ZodIssueCode:()=>D,ZodLazy:()=>Wi,ZodLiteral:()=>qi,ZodMap:()=>Xc,ZodNaN:()=>Kc,ZodNativeEnum:()=>Vi,ZodNever:()=>Co,ZodNull:()=>Hi,ZodNullable:()=>oa,ZodNumber:()=>Pi,ZodObject:()=>hn,ZodOptional:()=>so,ZodParsedType:()=>H,ZodPipeline:()=>Kp,ZodPromise:()=>ds,ZodReadonly:()=>Yi,ZodRecord:()=>og,ZodSchema:()=>le,ZodSet:()=>Yc,ZodString:()=>cs,ZodSymbol:()=>Vc,ZodTransformer:()=>lo,ZodTuple:()=>na,ZodType:()=>le,ZodUndefined:()=>Fi,ZodUnion:()=>Ui,ZodUnknown:()=>Qa,ZodVoid:()=>Zc,addIssueToContext:()=>F,any:()=>Uj,array:()=>jj,bigint:()=>Bj,boolean:()=>y8,coerce:()=>mV,custom:()=>p8,date:()=>Nj,datetimeRegex:()=>d8,defaultErrorMap:()=>Ka,discriminatedUnion:()=>Yj,effect:()=>iV,enum:()=>aV,function:()=>tV,getErrorMap:()=>Wc,getParsedType:()=>ta,instanceof:()=>Dj,intersection:()=>Kj,isAborted:()=>eg,isAsync:()=>qc,isDirty:()=>tg,isValid:()=>ls,late:()=>Oj,lazy:()=>nV,literal:()=>oV,makeIssue:()=>Xp,map:()=>Jj,nan:()=>Pj,nativeEnum:()=>rV,never:()=>Wj,null:()=>Hj,nullable:()=>cV,number:()=>m8,object:()=>Vj,objectUtil:()=>US,oboolean:()=>hV,onumber:()=>pV,optional:()=>lV,ostring:()=>fV,pipeline:()=>dV,preprocess:()=>uV,promise:()=>sV,quotelessJson:()=>ij,record:()=>Qj,set:()=>eV,setErrorMap:()=>cj,strictObject:()=>Zj,string:()=>h8,symbol:()=>zj,transformer:()=>iV,tuple:()=>$j,undefined:()=>Fj,union:()=>Xj,unknown:()=>Gj,util:()=>pe,void:()=>qj});var pe;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{let r={};for(let s of a)r[s]=s;return r},e.getValidEnumValues=a=>{let r=e.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),s={};for(let i of r)s[i]=a[i];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(r){return a[r]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let r=[];for(let s in a)Object.prototype.hasOwnProperty.call(a,s)&&r.push(s);return r},e.find=(a,r)=>{for(let s of a)if(r(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,r=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(r)}e.joinValues=o,e.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(pe||(pe={}));var US;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(US||(US={}));var H=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ta=e=>{switch(typeof e){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(e)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?H.promise:typeof Map<"u"&&e instanceof Map?H.map:typeof Set<"u"&&e instanceof Set?H.set:typeof Date<"u"&&e instanceof Date?H.date:H.object;default:return H.unknown}};var D=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ij=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),pn=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(r){return r.message},o={_errors:[]},a=r=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)o._errors.push(n(s));else{let i=o,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(n(s))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return a(this),o}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},o=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}};pn.create=e=>new pn(e);var lj=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===H.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,pe.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${pe.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${pe.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${pe.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n="Invalid function arguments";break;case D.invalid_return_type:n="Invalid function return type";break;case D.invalid_date:n="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:pe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case D.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case D.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case D.custom:n="Invalid input";break;case D.invalid_intersection_types:n="Intersection results could not be merged";break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n="Number must be finite";break;default:n=t.defaultError,pe.assertNever(e)}return{message:n}},Ka=lj;var s8=Ka;function cj(e){s8=e}function Wc(){return s8}var Xp=e=>{let{data:t,path:n,errorMaps:o,issueData:a}=e,r=[...n,...a.path||[]],s={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let i="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)i=c(s,{data:t,defaultError:i}).message;return{...a,path:r,message:i}},uj=[];function F(e,t){let n=Wc(),o=Xp({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ka?void 0:Ka].filter(a=>!!a)});e.common.issues.push(o)}var Pt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let o=[];for(let a of n){if(a.status==="aborted")return Z;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){let o=[];for(let a of n){let r=await a.key,s=await a.value;o.push({key:r,value:s})}return e.mergeObjectSync(t,o)}static mergeObjectSync(t,n){let o={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted"||s.status==="aborted")return Z;r.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(o[r.value]=s.value)}return{status:t.value,value:o}}},Z=Object.freeze({status:"aborted"}),Di=e=>({status:"dirty",value:e}),Gt=e=>({status:"valid",value:e}),eg=e=>e.status==="aborted",tg=e=>e.status==="dirty",ls=e=>e.status==="valid",qc=e=>typeof Promise<"u"&&e instanceof Promise;var q;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(q||(q={}));var io=class{constructor(t,n,o,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},i8=(e,t)=>{if(ls(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new pn(e.common.issues);return this._error=n,this._error}}};function ae(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:o,description:a}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,i)=>{let{message:l}=e;return s.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??o??i.defaultError}:s.code!=="invalid_type"?{message:i.defaultError}:{message:l??n??i.defaultError}},description:a}}var le=class{get description(){return this._def.description}_getType(t){return ta(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ta(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pt,ctx:{common:t.parent.common,data:t.data,parsedType:ta(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(qc(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){let o={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)},a=this._parseSync({data:t,path:o.path,parent:o});return i8(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return ls(o)?{value:o.value}:{issues:n.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>ls(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){let o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){let o={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(qc(a)?a:Promise.resolve(a));return i8(o,r)}refine(t,n){let o=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{let s=t(a),i=()=>r.addIssue({code:D.custom,...o(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(i(),!1)):s?!0:(i(),!1)})}refinement(t,n){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof n=="function"?n(o,a):n),!1))}_refinement(t){return new lo({schema:this,typeName:Y.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return so.create(this,this._def)}nullable(){return oa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ja.create(this)}promise(){return ds.create(this,this._def)}or(t){return Ui.create([this,t],this._def)}and(t){return Gi.create(this,t,this._def)}transform(t){return new lo({...ae(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Zi({...ae(this._def),innerType:this,defaultValue:n,typeName:Y.ZodDefault})}brand(){return new Yp({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Xi({...ae(this._def),innerType:this,catchValue:n,typeName:Y.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Kp.create(this,t)}readonly(){return Yi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},dj=/^c[^\s-]{8,}$/i,fj=/^[0-9a-z]+$/,pj=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hj=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mj=/^[a-z0-9_-]{21}$/i,yj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,gj=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",GS,Aj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Sj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wj=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,c8="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_j=new RegExp(`^${c8}$`);function u8(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Cj(e){return new RegExp(`^${u8(e)}$`)}function d8(e){let t=`${c8}T${u8(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ej(e,t){return!!((t==="v4"||!t)&&Aj.test(e)||(t==="v6"||!t)&&Sj.test(e))}function Tj(e,t){if(!yj.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function Ij(e,t){return!!((t==="v4"||!t)&&vj.test(e)||(t==="v6"||!t)&&Lj.test(e))}var cs=class e extends le{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==H.string){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.string,received:r.parsedType}),Z}let o=new Pt,a;for(let r of this._def.checks)if(r.kind==="min")t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="max")t.data.length>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="length"){let s=t.data.length>r.value,i=t.data.length<r.value;(s||i)&&(a=this._getOrReturnCtx(t,a),s?F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")xj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"email",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")GS||(GS=new RegExp(bj,"u")),GS.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"emoji",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")hj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"uuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")mj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"nanoid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")dj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")fj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid2",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")pj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ulid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),F(a,{validation:"url",code:D.invalid_string,message:r.message}),o.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"regex",code:D.invalid_string,message:r.message}),o.dirty())):r.kind==="trim"?t.data=t.data.trim():r.kind==="includes"?t.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),o.dirty()):r.kind==="toLowerCase"?t.data=t.data.toLowerCase():r.kind==="toUpperCase"?t.data=t.data.toUpperCase():r.kind==="startsWith"?t.data.startsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{startsWith:r.value},message:r.message}),o.dirty()):r.kind==="endsWith"?t.data.endsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?d8(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?_j.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?Cj(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?gj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?Ej(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ip",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?Tj(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"jwt",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?Ij(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cidr",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?kj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?wj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):pe.assertNever(r);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(a=>t.test(a),{validation:n,code:D.invalid_string,...q.errToObj(o)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...q.errToObj(t)})}url(t){return this._addCheck({kind:"url",...q.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...q.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...q.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...q.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...q.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...q.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...q.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...q.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...q.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...q.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...q.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...q.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...q.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...q.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...q.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...q.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...q.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...q.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...q.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...q.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...q.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...q.errToObj(n)})}nonempty(t){return this.min(1,q.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};cs.create=e=>new cs({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function Mj(e,t){let n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=n>o?n:o,r=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return r%s/10**a}var Pi=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==H.number){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.number,received:r.parsedType}),Z}let o,a=new Pt;for(let r of this._def.checks)r.kind==="int"?pe.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Mj(t.data,r.value)!==0&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_finite,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:q.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:q.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Pi.create=e=>new Pi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var Bi=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==H.bigint)return this._getInvalidInput(t);let o,a=new Pt;for(let r of this._def.checks)r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?t.data%r.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.bigint,received:n.parsedType}),Z}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Bi.create=e=>new Bi({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var Ni=class extends le{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==H.boolean){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.boolean,received:o.parsedType}),Z}return Gt(t.data)}};Ni.create=e=>new Ni({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var zi=class e extends le{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==H.date){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.date,received:r.parsedType}),Z}if(Number.isNaN(t.data.getTime())){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_date}),Z}let o=new Pt,a;for(let r of this._def.checks)r.kind==="min"?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),o.dirty()):r.kind==="max"?t.data.getTime()>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),o.dirty()):pe.assertNever(r);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:q.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:q.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};zi.create=e=>new zi({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var Vc=class extends le{_parse(t){if(this._getType(t)!==H.symbol){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.symbol,received:o.parsedType}),Z}return Gt(t.data)}};Vc.create=e=>new Vc({typeName:Y.ZodSymbol,...ae(e)});var Fi=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.undefined,received:o.parsedType}),Z}return Gt(t.data)}};Fi.create=e=>new Fi({typeName:Y.ZodUndefined,...ae(e)});var Hi=class extends le{_parse(t){if(this._getType(t)!==H.null){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.null,received:o.parsedType}),Z}return Gt(t.data)}};Hi.create=e=>new Hi({typeName:Y.ZodNull,...ae(e)});var us=class extends le{constructor(){super(...arguments),this._any=!0}_parse(t){return Gt(t.data)}};us.create=e=>new us({typeName:Y.ZodAny,...ae(e)});var Qa=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Gt(t.data)}};Qa.create=e=>new Qa({typeName:Y.ZodUnknown,...ae(e)});var Co=class extends le{_parse(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),Z}};Co.create=e=>new Co({typeName:Y.ZodNever,...ae(e)});var Zc=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.void,received:o.parsedType}),Z}return Gt(t.data)}};Zc.create=e=>new Zc({typeName:Y.ZodVoid,...ae(e)});var Ja=class e extends le{_parse(t){let{ctx:n,status:o}=this._processInputParams(t),a=this._def;if(n.parsedType!==H.array)return F(n,{code:D.invalid_type,expected:H.array,received:n.parsedType}),Z;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(s||i)&&(F(n,{code:s?D.too_big:D.too_small,minimum:i?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(F(n,{code:D.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(F(n,{code:D.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((s,i)=>a.type._parseAsync(new io(n,s,n.path,i)))).then(s=>Pt.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new io(n,s,n.path,i)));return Pt.mergeArray(o,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:q.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:q.toString(n)}})}nonempty(t){return this.min(1,t)}};Ja.create=(e,t)=>new Ja({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function jc(e){if(e instanceof hn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=so.create(jc(o))}return new hn({...e._def,shape:()=>t})}else return e instanceof Ja?new Ja({...e._def,type:jc(e.element)}):e instanceof so?so.create(jc(e.unwrap())):e instanceof oa?oa.create(jc(e.unwrap())):e instanceof na?na.create(e.items.map(t=>jc(t))):e}var hn=class e extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=pe.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==H.object){let c=this._getOrReturnCtx(t);return F(c,{code:D.invalid_type,expected:H.object,received:c.parsedType}),Z}let{status:o,ctx:a}=this._processInputParams(t),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof Co&&this._def.unknownKeys==="strip"))for(let c in a.data)s.includes(c)||i.push(c);let l=[];for(let c of s){let u=r[c],d=a.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new io(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Co){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of i)l.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(c==="strict")i.length>0&&(F(a,{code:D.unrecognized_keys,keys:i}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of i){let d=a.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new io(a,d,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Pt.mergeObjectSync(o,c)):Pt.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(t){return q.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{let a=this._def.errorMap?.(n,o).message??o.defaultError;return n.code==="unrecognized_keys"?{message:q.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let o of pe.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let o of pe.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return jc(this)}partial(t){let n={};for(let o of pe.objectKeys(this.shape)){let a=this.shape[o];t&&!t[o]?n[o]=a:n[o]=a.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let o of pe.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof so;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return f8(pe.objectKeys(this.shape))}};hn.create=(e,t)=>new hn({shape:()=>e,unknownKeys:"strip",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});hn.strictCreate=(e,t)=>new hn({shape:()=>e,unknownKeys:"strict",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});hn.lazycreate=(e,t)=>new hn({shape:e,unknownKeys:"strip",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});var Ui=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=this._def.options;function a(r){for(let i of r)if(i.result.status==="valid")return i.result;for(let i of r)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let s=r.map(i=>new pn(i.ctx.common.issues));return F(n,{code:D.invalid_union,unionErrors:s}),Z}if(n.common.async)return Promise.all(o.map(async r=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);{let r,s=[];for(let l of o){let c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!r&&(r={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let i=s.map(l=>new pn(l));return F(n,{code:D.invalid_union,unionErrors:i}),Z}}get options(){return this._def.options}};Ui.create=(e,t)=>new Ui({options:e,typeName:Y.ZodUnion,...ae(t)});var $a=e=>e instanceof Wi?$a(e.schema):e instanceof lo?$a(e.innerType()):e instanceof qi?[e.value]:e instanceof ji?e.options:e instanceof Vi?pe.objectValues(e.enum):e instanceof Zi?$a(e._def.innerType):e instanceof Fi?[void 0]:e instanceof Hi?[null]:e instanceof so?[void 0,...$a(e.unwrap())]:e instanceof oa?[null,...$a(e.unwrap())]:e instanceof Yp||e instanceof Yi?$a(e.unwrap()):e instanceof Xi?$a(e._def.innerType):[],ng=class e extends le{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.object)return F(n,{code:D.invalid_type,expected:H.object,received:n.parsedType}),Z;let o=this.discriminator,a=n.data[o],r=this.optionsMap.get(a);return r?n.common.async?r._parseAsync({data:n.data,path:n.path,parent:n}):r._parseSync({data:n.data,path:n.path,parent:n}):(F(n,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,o){let a=new Map;for(let r of n){let s=$a(r.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let i of s){if(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,r)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...ae(o)})}};function WS(e,t){let n=ta(e),o=ta(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&o===H.object){let a=pe.objectKeys(t),r=pe.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=WS(e[i],t[i]);if(!l.valid)return{valid:!1};s[i]=l.data}return{valid:!0,data:s}}else if(n===H.array&&o===H.array){if(e.length!==t.length)return{valid:!1};let a=[];for(let r=0;r<e.length;r++){let s=e[r],i=t[r],l=WS(s,i);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===H.date&&o===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Gi=class extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(eg(r)||eg(s))return Z;let i=WS(r.value,s.value);return i.valid?((tg(r)||tg(s))&&n.dirty(),{status:n.value,value:i.data}):(F(o,{code:D.invalid_intersection_types}),Z)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([r,s])=>a(r,s)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};Gi.create=(e,t,n)=>new Gi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var na=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.array)return F(o,{code:D.invalid_type,expected:H.array,received:o.parsedType}),Z;if(o.data.length<this._def.items.length)return F(o,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&o.data.length>this._def.items.length&&(F(o,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let r=[...o.data].map((s,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new io(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Pt.mergeArray(n,s)):Pt.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};na.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new na({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var og=class e extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.object)return F(o,{code:D.invalid_type,expected:H.object,received:o.parsedType}),Z;let a=[],r=this._def.keyType,s=this._def.valueType;for(let i in o.data)a.push({key:r._parse(new io(o,i,o.path,i)),value:s._parse(new io(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Pt.mergeObjectAsync(n,a):Pt.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof le?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...ae(o)}):new e({keyType:cs.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},Xc=class extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.map)return F(o,{code:D.invalid_type,expected:H.map,received:o.parsedType}),Z;let a=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([i,l],c)=>({key:a._parse(new io(o,i,o.path,[c,"key"])),value:r._parse(new io(o,l,o.path,[c,"value"]))}));if(o.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let l of s){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}}}};Xc.create=(e,t,n)=>new Xc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var Yc=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.set)return F(o,{code:D.invalid_type,expected:H.set,received:o.parsedType}),Z;let a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(F(o,{code:D.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(F(o,{code:D.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let r=this._def.valueType;function s(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Z;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}let i=[...o.data.values()].map((l,c)=>r._parse(new io(o,l,o.path,c)));return o.common.async?Promise.all(i).then(l=>s(l)):s(i)}min(t,n){return new e({...this._def,minSize:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:q.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};Yc.create=(e,t)=>new Yc({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var ag=class e extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.function)return F(n,{code:D.invalid_type,expected:H.function,received:n.parsedType}),Z;function o(i,l){return Xp({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wc(),Ka].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return Xp({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wc(),Ka].filter(c=>!!c),issueData:{code:D.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof ds){let i=this;return Gt(async function(...l){let c=new pn([]),u=await i._def.args.parseAsync(l,r).catch(p=>{throw c.addIssue(o(l,p)),c}),d=await Reflect.apply(s,this,u);return await i._def.returns._def.type.parseAsync(d,r).catch(p=>{throw c.addIssue(a(d,p)),c})})}else{let i=this;return Gt(function(...l){let c=i._def.args.safeParse(l,r);if(!c.success)throw new pn([o(l,c.error)]);let u=Reflect.apply(s,this,c.data),d=i._def.returns.safeParse(u,r);if(!d.success)throw new pn([a(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:na.create(t).rest(Qa.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,o){return new e({args:t||na.create([]).rest(Qa.create()),returns:n||Qa.create(),typeName:Y.ZodFunction,...ae(o)})}},Wi=class extends le{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Wi.create=(e,t)=>new Wi({getter:e,typeName:Y.ZodLazy,...ae(t)});var qi=class extends le{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return F(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:t.data}}get value(){return this._def.value}};qi.create=(e,t)=>new qi({value:e,typeName:Y.ZodLiteral,...ae(t)});function f8(e,t){return new ji({values:e,typeName:Y.ZodEnum,...ae(t)})}var ji=class e extends le{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{expected:pe.joinValues(o),received:n.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{received:n.data,code:D.invalid_enum_value,options:o}),Z}return Gt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}};ji.create=f8;var Vi=class extends le{_parse(t){let n=pe.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==H.string&&o.parsedType!==H.number){let a=pe.objectValues(n);return F(o,{expected:pe.joinValues(a),received:o.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=pe.objectValues(n);return F(o,{received:o.data,code:D.invalid_enum_value,options:a}),Z}return Gt(t.data)}get enum(){return this._def.values}};Vi.create=(e,t)=>new Vi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var ds=class extends le{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.promise&&n.common.async===!1)return F(n,{code:D.invalid_type,expected:H.promise,received:n.parsedType}),Z;let o=n.parsedType===H.promise?n.data:Promise.resolve(n.data);return Gt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ds.create=(e,t)=>new ds({type:e,typeName:Y.ZodPromise,...ae(t)});var lo=class extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=this._def.effect||null,r={addIssue:s=>{F(o,s),s.fatal?n.abort():n.dirty()},get path(){return o.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(o.data,r);if(o.common.async)return Promise.resolve(s).then(async i=>{if(n.value==="aborted")return Z;let l=await this._def.schema._parseAsync({data:i,path:o.path,parent:o});return l.status==="aborted"?Z:l.status==="dirty"?Di(l.value):n.value==="dirty"?Di(l.value):l});{if(n.value==="aborted")return Z;let i=this._def.schema._parseSync({data:s,path:o.path,parent:o});return i.status==="aborted"?Z:i.status==="dirty"?Di(i.value):n.value==="dirty"?Di(i.value):i}}if(a.type==="refinement"){let s=i=>{let l=a.refinement(i,r);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(o.common.async===!1){let i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(o.common.async===!1){let s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!ls(s))return Z;let i=a.transform(s.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>ls(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):Z);pe.assertNever(a)}};lo.create=(e,t,n)=>new lo({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});lo.createWithPreprocess=(e,t,n)=>new lo({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var so=class extends le{_parse(t){return this._getType(t)===H.undefined?Gt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};so.create=(e,t)=>new so({innerType:e,typeName:Y.ZodOptional,...ae(t)});var oa=class extends le{_parse(t){return this._getType(t)===H.null?Gt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};oa.create=(e,t)=>new oa({innerType:e,typeName:Y.ZodNullable,...ae(t)});var Zi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return n.parsedType===H.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Zi.create=(e,t)=>new Zi({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var Xi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return qc(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};Xi.create=(e,t)=>new Xi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var Kc=class extends le{_parse(t){if(this._getType(t)!==H.nan){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.nan,received:o.parsedType}),Z}return{status:"valid",value:t.data}}};Kc.create=e=>new Kc({typeName:Y.ZodNaN,...ae(e)});var Rj=Symbol("zod_brand"),Yp=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}},Kp=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Z:r.status==="dirty"?(n.dirty(),Di(r.value)):this._def.out._parseAsync({data:r.value,path:o.path,parent:o})})();{let a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Z:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},Yi=class extends le{_parse(t){let n=this._def.innerType._parse(t),o=a=>(ls(a)&&(a.value=Object.freeze(a.value)),a);return qc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Yi.create=(e,t)=>new Yi({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function l8(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function p8(e,t={},n){return e?us.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=l8(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=l8(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):us.create()}var Oj={object:hn.lazycreate},Y;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Y||(Y={}));var Dj=(e,t={message:`Input not instance of ${e.name}`})=>p8(n=>n instanceof e,t),h8=cs.create,m8=Pi.create,Pj=Kc.create,Bj=Bi.create,y8=Ni.create,Nj=zi.create,zj=Vc.create,Fj=Fi.create,Hj=Hi.create,Uj=us.create,Gj=Qa.create,Wj=Co.create,qj=Zc.create,jj=Ja.create,Vj=hn.create,Zj=hn.strictCreate,Xj=Ui.create,Yj=ng.create,Kj=Gi.create,$j=na.create,Qj=og.create,Jj=Xc.create,eV=Yc.create,tV=ag.create,nV=Wi.create,oV=qi.create,aV=ji.create,rV=Vi.create,sV=ds.create,iV=lo.create,lV=so.create,cV=oa.create,uV=lo.createWithPreprocess,dV=Kp.create,fV=()=>h8().optional(),pV=()=>m8().optional(),hV=()=>y8().optional(),mV={string:(e=>cs.create({...e,coerce:!0})),number:(e=>Pi.create({...e,coerce:!0})),boolean:(e=>Ni.create({...e,coerce:!0})),bigint:(e=>Bi.create({...e,coerce:!0})),date:(e=>zi.create({...e,coerce:!0}))};var yV=Z;var xV=["basic","layout","flowchart","custom","rich"],qS=({registry:e=Oi,categories:t=xV,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,co.useMemo)(()=>new Set(e.categories()),[e]),c=(0,co.useMemo)(()=>t.filter(x=>l.has(x)),[t,l]),u=(0,co.useMemo)(()=>c.map(x=>({category:x,items:e.byCategory(x)})),[e,c]),[d,f]=(0,co.useState)(()=>new Set(n)),p=x=>{f(y=>{let g=new Set(y);return g.has(x)?g.delete(x):g.add(x),g})},h=o?.trim()??"",m=(0,co.useMemo)(()=>{if(!h)return[];let x=[];for(let{items:y}of u)for(let g of y)HS(g,h)&&x.push(g);return x},[u,h]);return(0,gt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,gt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,gt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,gt.jsx)("div",{className:i,children:m.map(x=>(0,gt.jsx)(A8,{template:x},x.id))}):u.map(({category:x,items:y})=>(0,gt.jsx)(bV,{category:x,items:y,itemsClass:i,collapsed:d.has(x),onToggle:()=>{p(x)}},x))})})},bV=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,gt.jsxs)("section",{className:"du-palette-section",children:[(0,gt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,gt.jsx)("span",{children:e}),(0,gt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,gt.jsx)(Xs,{size:12,strokeWidth:1.75}):(0,gt.jsx)(Td,{size:12,strokeWidth:1.75})})]}),o?null:(0,gt.jsx)("div",{className:n,children:t.map(r=>(0,gt.jsx)(A8,{template:r},r.id))})]}),$p=null,x8=Jv(),g8=e=>{$p!==e&&($p=e,x8.emit())};var b8=e=>x8.add(e);var rg=null,AV=()=>{if(typeof document>"u")return null;if(rg&&document.body.contains(rg))return rg;let e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;top:-1000px;left:-1000px;width:1px;height:1px;background:rgba(0,0,0,0.01)",document.body.appendChild(e),rg=e,e},A8=({template:e})=>{let t=G(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=AV();s&&r.dataTransfer.setDragImage(s,0,0),g8(e)},o=()=>{g8(null)},a=()=>{if(!t||typeof window<"u"&&!window.matchMedia("(pointer: coarse)").matches)return;let s=t.hostElement.getBoundingClientRect(),i=t.screenToWorld({x:s.width/2,y:s.height/2}),l=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),c=e.factory({id:l,layerId:Rn,position:i,order:Ae([...t.scene.elements.values()].filter(d=>d.layerId===Rn).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,gt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,gt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,gt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},jS=()=>{let e=G(),t=(0,co.useRef)(null);(0,co.useEffect)(()=>{let a=r=>{r.key!=="Escape"||!t.current||(t.current.cancel(),t.current=null)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[]),(0,co.useEffect)(()=>b8(()=>{$p===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!$p)return!1;let r=$p,s=a.currentTarget.getBoundingClientRect(),i={x:a.clientX-s.left,y:a.clientY-s.top},l=e.screenToWorld(i),c=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),u=r.factory({id:c,layerId:Rn,position:l,order:Ae([...e.scene.elements.values()].filter(d=>d.layerId===Rn).map(d=>d.order))});return t.current=e.beginPlacement(u),t.current.update(l),!0},o=a=>{if(!e)return null;let r=a.currentTarget.getBoundingClientRect();return e.screenToWorld({x:a.clientX-r.left,y:a.clientY-r.top})};return{onDragEnter:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");!s&&!i||(a.preventDefault(),s&&n(a))},onDragOver:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");if(!(!s&&!i)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy",s)){t.current||n(a);let l=o(a);l&&t.current&&t.current.update(l)}},onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||t.current&&(t.current.cancel(),t.current=null)},onDrop:a=>{if(a.preventDefault(),t.current){let l=o(a);l&&t.current.update(l),t.current.commit(),t.current=null;return}let r=a.dataTransfer;if(!r)return;let i=o(a)??{x:0,y:0};e&&(async()=>{for await(let l of oS(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var VS=14,ZS=1.75,sg=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,Ki.useState)("");(0,Ki.useEffect)(()=>{e||i("")},[e]);let l=(0,Ki.useRef)(null);return(0,Ki.useEffect)(()=>{e&&l.current?.focus()},[e]),e?(0,mn.jsxs)("aside",{className:`du-side-panel ${o?"du-side-panel-sheet":n==="right"?"du-side-panel-right":"du-side-panel-left"}`,style:r,children:[(0,mn.jsx)("header",{className:"du-side-panel-header",children:(0,mn.jsxs)("div",{style:{display:"inline-flex",gap:4},children:[a?(0,mn.jsx)(Qn,{label:"Import templates",size:"sm",onClick:a,children:(0,mn.jsx)(bf,{size:VS,strokeWidth:ZS})}):null,(0,mn.jsx)(Qn,{label:"Close library",size:"sm",onClick:t,children:(0,mn.jsx)(Na,{size:VS,strokeWidth:ZS})})]})}),(0,mn.jsxs)("div",{className:"du-side-panel-search",children:[(0,mn.jsx)(df,{size:VS,strokeWidth:ZS,className:"du-side-panel-search-icon","aria-hidden":!0}),(0,mn.jsx)("input",{ref:l,type:"search",value:s,placeholder:"Search templates\u2026","aria-label":"Search templates",onChange:u=>{i(u.target.value)},onKeyDown:u=>{u.key==="Escape"&&s&&(u.stopPropagation(),i(""))}})]}),(0,mn.jsx)("div",{className:"du-side-panel-body du-side-panel-body-flush",children:(0,mn.jsx)(qS,{searchQuery:s,layout:"list"})})]}):null};var sh=P(se(),1);var $c=Math.min,er=Math.max,Jp=Math.round,eh=Math.floor,Eo=e=>({x:e,y:e}),vV={left:"right",right:"left",bottom:"top",top:"bottom"};function XS(e,t,n){return er(e,$c(t,n))}function th(e,t){return typeof e=="function"?e(t):e}function fs(e){return e.split("-")[0]}function nh(e){return e.split("-")[1]}function YS(e){return e==="x"?"y":"x"}function KS(e){return e==="y"?"height":"width"}function tr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function $S(e){return YS(tr(e))}function L8(e,t,n){n===void 0&&(n=!1);let o=nh(e),a=$S(e),r=KS(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=Qp(s)),[s,Qp(s)]}function k8(e){let t=Qp(e);return[ig(e),t,ig(t)]}function ig(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var v8=["left","right"],S8=["right","left"],SV=["top","bottom"],LV=["bottom","top"];function kV(e,t,n){switch(e){case"top":case"bottom":return n?t?S8:v8:t?v8:S8;case"left":case"right":return t?SV:LV;default:return[]}}function w8(e,t,n,o){let a=nh(e),r=kV(fs(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(ig)))),r}function Qp(e){let t=fs(e);return vV[t]+e.slice(t.length)}function wV(e){return{top:0,right:0,bottom:0,left:0,...e}}function _8(e){return typeof e!="number"?wV(e):{top:e,right:e,bottom:e,left:e}}function $i(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function C8(e,t,n){let{reference:o,floating:a}=e,r=tr(t),s=$S(t),i=KS(s),l=fs(t),c=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,f=o[i]/2-a[i]/2,p;switch(l){case"top":p={x:u,y:o.y-a.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch(nh(t)){case"start":p[s]-=f*(n&&c?-1:1);break;case"end":p[s]+=f*(n&&c?-1:1);break}return p}async function E8(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:s,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=th(t,e),h=_8(p),x=i[f?d==="floating"?"reference":"floating":d],y=$i(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(x)))==null||n?x:x.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),g=d==="floating"?{x:o,y:a,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(i.floating)),A=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},_=$i(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:g,offsetParent:b,strategy:l}):g);return{top:(y.top-_.top+h.top)/A.y,bottom:(_.bottom-y.bottom+h.bottom)/A.y,left:(y.left-_.left+h.left)/A.x,right:(_.right-y.right+h.right)/A.x}}var _V=50,T8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:E8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=C8(c,o,l),f=o,p=0,h={};for(let m=0;m<r.length;m++){let x=r[m];if(!x)continue;let{name:y,fn:g}=x,{x:b,y:A,data:_,reset:T}=await g({x:u,y:d,initialPlacement:o,placement:f,strategy:a,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});u=b??u,d=A??d,h[y]={...h[y],..._},T&&p<_V&&(p++,typeof T=="object"&&(T.placement&&(f=T.placement),T.rects&&(c=T.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):T.rects),{x:u,y:d}=C8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var I8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:s,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=!0,...x}=th(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=fs(a),g=tr(i),b=fs(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(b||!m?[Qp(i)]:k8(i)),T=h!=="none";!f&&T&&_.push(...w8(i,m,h,A));let w=[i,..._],S=await l.detectOverflow(t,x),L=[],M=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&L.push(S[y]),d){let ne=L8(a,s,A);L.push(S[ne[0]],S[ne[1]])}if(M=[...M,{placement:a,overflows:L}],!L.every(ne=>ne<=0)){var B,W;let ne=(((B=r.flip)==null?void 0:B.index)||0)+1,j=w[ne];if(j&&(!(d==="alignment"?g!==tr(j):!1)||M.every(ee=>tr(ee.placement)===g?ee.overflows[0]>0:!0)))return{data:{index:ne,overflows:M},reset:{placement:j}};let ve=(W=M.filter(ye=>ye.overflows[0]<=0).sort((ye,ee)=>ye.overflows[1]-ee.overflows[1])[0])==null?void 0:W.placement;if(!ve)switch(p){case"bestFit":{var ie;let ye=(ie=M.filter(ee=>{if(T){let Se=tr(ee.placement);return Se===g||Se==="y"}return!0}).map(ee=>[ee.placement,ee.overflows.filter(Se=>Se>0).reduce((Se,Oe)=>Se+Oe,0)]).sort((ee,Se)=>ee[1]-Se[1])[0])==null?void 0:ie[0];ye&&(ve=ye);break}case"initialPlacement":ve=i;break}if(a!==ve)return{reset:{placement:ve}}}return{}}}};var CV=new Set(["left","top"]);async function EV(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=fs(n),i=nh(n),l=tr(n)==="y",c=CV.has(s)?-1:1,u=r&&l?-1:1,d=th(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof h=="number"&&(p=i==="end"?h*-1:h),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}var M8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:s,middlewareData:i}=t,l=await EV(t,e);return s===((n=i.offset)==null?void 0:n.placement)&&(o=i.arrow)!=null&&o.alignmentOffset?{}:{x:a+l.x,y:r+l.y,data:{...l,placement:s}}}}},R8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:y=>{let{x:g,y:b}=y;return{x:g,y:b}}},...c}=th(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=tr(fs(a)),p=YS(f),h=u[p],m=u[f];if(s){let y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[y],A=h-d[g];h=XS(b,h,A)}if(i){let y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=m+d[y],A=m-d[g];m=XS(b,m,A)}let x=l.fn({...t,[p]:h,[f]:m});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:s,[f]:i}}}}}};function lg(){return typeof window<"u"}function Ji(e){return D8(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function To(e){var t;return(t=(D8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function D8(e){return lg()?e instanceof Node||e instanceof yn(e).Node:!1}function uo(e){return lg()?e instanceof Element||e instanceof yn(e).Element:!1}function aa(e){return lg()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function O8(e){return!lg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function Jc(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=fo(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function P8(e){return/^(table|td|th)$/.test(Ji(e))}function oh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var TV=/transform|translate|scale|rotate|perspective|filter/,IV=/paint|layout|strict|content/,Qi=e=>!!e&&e!=="none",QS;function cg(e){let t=uo(e)?fo(e):e;return Qi(t.transform)||Qi(t.translate)||Qi(t.scale)||Qi(t.rotate)||Qi(t.perspective)||!ug()&&(Qi(t.backdropFilter)||Qi(t.filter))||TV.test(t.willChange||"")||IV.test(t.contain||"")}function B8(e){let t=nr(e);for(;aa(t)&&!el(t);){if(cg(t))return t;if(oh(t))return null;t=nr(t)}return null}function ug(){return QS==null&&(QS=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),QS}function el(e){return/^(html|body|#document)$/.test(Ji(e))}function fo(e){return yn(e).getComputedStyle(e)}function ah(e){return uo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nr(e){if(Ji(e)==="html")return e;let t=e.assignedSlot||e.parentNode||O8(e)&&e.host||To(e);return O8(t)?t.host:t}function N8(e){let t=nr(e);return el(t)?e.ownerDocument?e.ownerDocument.body:e.body:aa(t)&&Jc(t)?t:N8(t)}function Qc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=N8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=yn(a);if(r){let i=dg(s);return t.concat(s,s.visualViewport||[],Jc(a)?a:[],i&&n?Qc(i):[])}else return t.concat(a,Qc(a,[],n))}function dg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function U8(e){let t=fo(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=aa(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=Jp(n)!==r||Jp(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function eL(e){return uo(e)?e:e.contextElement}function eu(e){let t=eL(e);if(!aa(t))return Eo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=U8(t),s=(r?Jp(n.width):n.width)/o,i=(r?Jp(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var MV=Eo(0);function G8(e){let t=yn(e);return!ug()||!t.visualViewport?MV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function RV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function tl(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=eL(e),s=Eo(1);t&&(o?uo(o)&&(s=eu(o)):s=eu(e));let i=RV(r,n,o)?G8(r):Eo(0),l=(a.left+i.x)/s.x,c=(a.top+i.y)/s.y,u=a.width/s.x,d=a.height/s.y;if(r){let f=yn(r),p=o&&uo(o)?yn(o):o,h=f,m=dg(h);for(;m&&o&&p!==h;){let x=eu(m),y=m.getBoundingClientRect(),g=fo(m),b=y.left+(m.clientLeft+parseFloat(g.paddingLeft))*x.x,A=y.top+(m.clientTop+parseFloat(g.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=b,c+=A,h=yn(m),m=dg(h)}}return $i({width:u,height:d,x:l,y:c})}function fg(e,t){let n=ah(e).scrollLeft;return t?t.left+n:tl(To(e)).left+n}function W8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-fg(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function OV(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=To(o),i=t?oh(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=Eo(1),u=Eo(0),d=aa(o);if((d||!d&&!r)&&((Ji(o)!=="body"||Jc(s))&&(l=ah(o)),d)){let p=tl(o);c=eu(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?W8(s,l):Eo(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function DV(e){return Array.from(e.getClientRects())}function PV(e){let t=To(e),n=ah(e),o=e.ownerDocument.body,a=er(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=er(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+fg(e),i=-n.scrollTop;return fo(o).direction==="rtl"&&(s+=er(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var z8=25;function BV(e,t){let n=yn(e),o=To(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=ug();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=fg(o);if(c<=0){let u=o.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-p);h<=z8&&(r-=h)}else c<=z8&&(r+=c);return{width:r,height:s,x:i,y:l}}function NV(e,t){let n=tl(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=aa(e)?eu(e):Eo(1),s=e.clientWidth*r.x,i=e.clientHeight*r.y,l=a*r.x,c=o*r.y;return{width:s,height:i,x:l,y:c}}function F8(e,t,n){let o;if(t==="viewport")o=BV(e,n);else if(t==="document")o=PV(To(e));else if(uo(t))o=NV(t,n);else{let a=G8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return $i(o)}function q8(e,t){let n=nr(e);return n===t||!uo(n)||el(n)?!1:fo(n).position==="fixed"||q8(n,t)}function zV(e,t){let n=t.get(e);if(n)return n;let o=Qc(e,[],!1).filter(i=>uo(i)&&Ji(i)!=="body"),a=null,r=fo(e).position==="fixed",s=r?nr(e):e;for(;uo(s)&&!el(s);){let i=fo(s),l=cg(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Jc(s)&&!l&&q8(e,s))?o=o.filter(u=>u!==s):a=i,s=nr(s)}return t.set(e,o),o}function FV(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?oh(t)?[]:zV(t,this._c):[].concat(n),o],i=F8(t,s[0],a),l=i.top,c=i.right,u=i.bottom,d=i.left;for(let f=1;f<s.length;f++){let p=F8(t,s[f],a);l=er(p.top,l),c=$c(p.right,c),u=$c(p.bottom,u),d=er(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function HV(e){let{width:t,height:n}=U8(e);return{width:t,height:n}}function UV(e,t,n){let o=aa(t),a=To(t),r=n==="fixed",s=tl(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=Eo(0);function c(){l.x=fg(a)}if(o||!o&&!r)if((Ji(t)!=="body"||Jc(a))&&(i=ah(t)),o){let p=tl(t,!0,r,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else a&&c();r&&!o&&a&&c();let u=a&&!o&&!r?W8(a,i):Eo(0),d=s.left+i.scrollLeft-l.x-u.x,f=s.top+i.scrollTop-l.y-u.y;return{x:d,y:f,width:s.width,height:s.height}}function JS(e){return fo(e).position==="static"}function H8(e,t){if(!aa(e)||fo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return To(e)===n&&(n=n.ownerDocument.body),n}function j8(e,t){let n=yn(e);if(oh(e))return n;if(!aa(e)){let a=nr(e);for(;a&&!el(a);){if(uo(a)&&!JS(a))return a;a=nr(a)}return n}let o=H8(e,t);for(;o&&P8(o)&&JS(o);)o=H8(o,t);return o&&el(o)&&JS(o)&&!cg(o)?n:o||B8(e)||n}var GV=async function(e){let t=this.getOffsetParent||j8,n=this.getDimensions,o=await n(e.floating);return{reference:UV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function WV(e){return fo(e).direction==="rtl"}var qV={convertOffsetParentRelativeRectToViewportRelativeRect:OV,getDocumentElement:To,getClippingRect:FV,getOffsetParent:j8,getElementRects:GV,getClientRects:DV,getDimensions:HV,getScale:eu,isElement:uo,isRTL:WV};function V8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jV(e,t){let n=null,o,a=To(e);function r(){var i;clearTimeout(o),(i=n)==null||i.disconnect(),n=null}function s(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),r();let c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(i||t(),!f||!p)return;let h=eh(d),m=eh(a.clientWidth-(u+f)),x=eh(a.clientHeight-(d+p)),y=eh(u),b={rootMargin:-h+"px "+-m+"px "+-x+"px "+-y+"px",threshold:er(0,$c(1,l))||1},A=!0;function _(T){let w=T[0].intersectionRatio;if(w!==l){if(!A)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!V8(c,e.getBoundingClientRect())&&s(),A=!1}try{n=new IntersectionObserver(_,{...b,root:a.ownerDocument})}catch{n=new IntersectionObserver(_,b)}n.observe(e)}return s(!0),r}function pg(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,c=eL(e),u=a||r?[...c?Qc(c):[],...t?Qc(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?jV(c,n):null,f=-1,p=null;s&&(p=new ResizeObserver(y=>{let[g]=y;g&&g.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let h,m=l?tl(e):null;l&&x();function x(){let y=tl(e);m&&!V8(m,y)&&n(),m=y,h=requestAnimationFrame(x)}return n(),()=>{var y;u.forEach(g=>{a&&g.removeEventListener("scroll",n),r&&g.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(h)}}var hg=M8;var mg=R8,yg=I8;var gg=(e,t,n)=>{let o=new Map,a={platform:qV,...n},r={...a.platform,_c:o};return T8(e,t,{...a,platform:r})};var sa=P(re(),1),rL=P(ha(),1);var k=P(se(),1),hs=P(re(),1);var Z8=P(se(),1),ps=P(re(),1),X8=(0,ps.createContext)(null),Y8=({children:e})=>{let t=(0,ps.useRef)(null),n=(0,ps.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,Z8.jsx)(X8.Provider,{value:n,children:e})},xg=()=>(0,ps.useContext)(X8);var Bt=P(se(),1),Q8=P(re(),1);var VV=ts.map(e=>Ic.light[e].fill),ZV=ts.map(e=>Ic.light[e].solid),XV=ts.map(e=>Ic.dark[e].fill),YV=ts.map(e=>Ic.dark[e].solid),KV=ts.map(e=>fy.light[e]),$V=ts.map(e=>fy.dark[e]),bg=[...VV,...ZV,"#ffffff","#1e1e1e","transparent"],tL=[...XV,...YV,"#1e1e1e","#ffffff","transparent"],y0e=["#ffffff",...KV],g0e=["#121113",...$V],K8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var tu=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0,onEyedrop:r})=>{let s=n??tZ(),[i,l]=(0,Q8.useState)(!1);return(0,Bt.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[s.map(c=>(0,Bt.jsx)(QV,{color:c,selected:$8(c)===$8(e),onClick:()=>{t(c==="transparent"?null:c)}},c)),o?(0,Bt.jsx)(JV,{value:e,onChange:t,open:i,onOpenChange:l}):null,r?(0,Bt.jsx)("button",{type:"button","aria-label":"Pick colour from canvas",title:"Pick colour from canvas",onClick:()=>{r(c=>{t(c)})},className:"du-swatch du-swatch-eyedrop",children:(0,Bt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Bt.jsx)(sf,{size:12,strokeWidth:2})})}):null,a?(0,Bt.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,Bt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Bt.jsx)(Na,{size:12,strokeWidth:2})})}):null]})},QV=({color:e,selected:t,onClick:n})=>(0,Bt.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,Bt.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),JV=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,Bt.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,Bt.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,Bt.jsx)(Qs,{size:12,strokeWidth:2})}),(0,Bt.jsx)("input",{type:"color","aria-label":"Custom colour",value:eZ(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},$8=e=>e===null?"transparent":e.toLowerCase(),eZ=e=>{if(!e||e==="transparent")return"#000000";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(e)){let t=e.slice(1);return`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`.toLowerCase()}return"#000000"},tZ=()=>{if(typeof document>"u")return bg;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?tL:e==="light"?bg:K8("system")==="dark"?tL:bg};var nu=P(se(),1);var xt=P(re(),1),J8=P(ha(),1);var Io=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Dt(),[c,u]=(0,xt.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,xt.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,xt.useId)(),m=(0,xt.useRef)(null),x=(0,xt.useRef)(null);(0,xt.useLayoutEffect)(()=>{if(!f)return;let g=m.current,b=x.current;if(!g||!b)return;let A=()=>{gg(g,b,{placement:n,middleware:[hg(o),yg(),mg({padding:6})]}).then(({x:T,y:w})=>{b.style.transform=`translate(${Math.round(T)}px, ${Math.round(w)}px)`})};return A(),pg(g,b,A)},[f,n,o]),(0,xt.useEffect)(()=>{if(!f)return;let g=A=>{let _=A.target;_&&(m.current?.contains(_)||x.current?.contains(_)||p(!1))},b=A=>{A.key==="Escape"&&(A.stopPropagation(),p(!1),m.current?.focus())};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",b)}},[f,p]);let y=(0,xt.useMemo)(()=>{if(!(0,xt.isValidElement)(e))return e;let g=e.props;return(0,xt.cloneElement)(e,{ref:b=>{m.current=b;let A=e.ref;typeof A=="function"?A(b):A&&typeof A=="object"&&(A.current=b)},onClick:b=>{let A=g.onClick;A?.(b),!b.defaultPrevented&&p(!f)},"aria-haspopup":"dialog","aria-expanded":f,"aria-controls":f?h:void 0})},[e,f,p,h]);return(0,nu.jsxs)(nu.Fragment,{children:[y,f?(0,J8.createPortal)((0,nu.jsx)("div",{ref:x,id:h,role:"dialog","aria-label":i,className:`du-popover ${a??""}`.trim(),style:{position:"absolute",top:0,left:0,zIndex:1600},children:t}),l):null]})};var oL=({style:e,className:t,mobile:n=!1})=>{let o=Qy(),a=zS(),r=Ya();if(is())return null;if(o.size>0){let i=[...o].map(p=>r.elements.get(p)).filter(p=>p!==void 0);if(i.length===0)return null;let l=i.every(p=>fe(p)),c=i.every(p=>ct(p)),u=i.every(p=>Be(p)),d=[],f=[];return u?d.push((0,k.jsx)(nD,{shapes:i},"fill")):l?(d.push((0,k.jsx)(aZ,{shapes:i},"size"),(0,k.jsx)(oZ,{shapes:i},"color"),(0,k.jsx)(sZ,{shapes:i},"align")),f.push((0,k.jsx)(rZ,{shapes:i},"family"),(0,k.jsx)(iZ,{shapes:i},"decor"))):c?d.push((0,k.jsx)(oD,{shapes:i},"opacity"),(0,k.jsx)(hZ,{shapes:i},"crop")):(d.push((0,k.jsx)(nD,{shapes:i},"fill"),(0,k.jsx)(lZ,{shapes:i},"stroke"),(0,k.jsx)(cZ,{shapes:i},"width")),f.push((0,k.jsx)(uZ,{shapes:i},"dash"),(0,k.jsx)(dZ,{shapes:i},"round"),(0,k.jsx)(oD,{shapes:i},"opacity"),(0,k.jsx)(pZ,{shapes:i},"convert"))),f.push((0,k.jsx)(fZ,{},"z"),(0,k.jsx)(nZ,{shapes:i},"link")),i.length>=2&&f.push((0,k.jsx)(gZ,{},"align")),f.push((0,k.jsx)(mZ,{shapes:i},"actions"),(0,k.jsx)(tD,{},"more")),(0,k.jsx)(eD,{mobile:n,primary:d,overflow:f,className:t,style:e})}if(a!==null){let i=r.links.get(a);if(!i)return null;let l=[(0,k.jsx)(xZ,{edge:i},"color"),(0,k.jsx)(bZ,{edge:i},"width"),(0,k.jsx)(aD,{edge:i,side:"to"},"arrow-to")],c=[(0,k.jsx)(AZ,{edge:i},"dash"),(0,k.jsx)(SZ,{edge:i},"routing"),(0,k.jsx)(vZ,{edge:i},"kind"),(0,k.jsx)(aD,{edge:i,side:"from"},"arrow-from"),(0,k.jsx)(LZ,{edge:i},"auto"),(0,k.jsx)(kZ,{},"delete"),(0,k.jsx)(tD,{},"more")];return(0,k.jsx)(eD,{mobile:n,primary:l,overflow:c,className:t,style:e})}return null},eD=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,hs.useState)(!1),i=(0,hs.useRef)(null);return(0,hs.useEffect)(()=>{if(!e||!r)return;let l=c=>{let u=i.current;u&&c.target instanceof Node&&!u.contains(c.target)&&s(!1)};return document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("pointerdown",l,!0)}},[e,r]),e?(0,k.jsxs)("div",{ref:i,className:`du-sel-panel du-sel-panel-mobile ${o??""}`.trim(),style:a,children:[(0,k.jsxs)("div",{className:"du-sel-mobile-row",children:[(0,k.jsx)("div",{className:"du-sel-mobile-primary",children:t}),n.length>0?(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button du-sel-mobile-expand${r?" is-active":""}`,"aria-expanded":r,"aria-label":r?"Hide more properties":"More properties",title:"More properties",onClick:()=>{s(l=>!l)},children:(0,k.jsx)(Ur,{size:18,strokeWidth:1.75,"aria-hidden":!0})}):null]}),r&&n.length>0?(0,k.jsx)("div",{className:"du-sel-mobile-overflow",children:n}):null]}):(0,k.jsxs)("div",{className:`du-sel-panel ${o??""}`.trim(),style:a,children:[t,n.length>0?(0,k.jsx)(CZ,{}):null,n]})},nZ=({shapes:e})=>{let t=G(),n=(0,hs.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=rh(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,k.jsx)(Io,{ariaLabel:"Link",trigger:(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${r?" is-active":""}`,title:"Link","aria-label":"Link",children:(0,k.jsx)(Xd,{size:14,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Link"}),(0,k.jsx)("input",{ref:n,className:"du-sel-link-input",type:"text",placeholder:"https://\u2026 \xB7 name@mail",defaultValue:a??"","aria-label":"Link URL",onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s(i.currentTarget.value))}}),(0,k.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{s(n.current?.value??"")},children:"Save"}),r?(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.openLink(a)},children:"Open"}):null,r?(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.setLink(o,null)},children:"Remove"}):null]})]})})},tD=()=>{let e=G(),t=xg();return!e||!t?null:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"More actions","aria-label":"More actions",onClick:n=>{let o=n.currentTarget.getBoundingClientRect(),a={x:o.left,y:o.bottom+4},s=e.hostElement?.getBoundingClientRect(),i=s?e.screenToWorld({x:a.x-s.left,y:a.y-s.top}):{x:0,y:0};t.open({screenPoint:a,worldPoint:i})},children:(0,k.jsx)(Gr,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},aL=({label:e,color:t,onChange:n,ariaLabel:o,onEyedrop:a})=>(0,k.jsx)(Io,{ariaLabel:o,trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:e,"aria-label":o,children:(0,k.jsx)("span",{className:"du-sel-color-swatch",style:{background:!t||t==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":t}})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:e}),(0,k.jsx)(tu,{value:t,onChange:n,...a?{onEyedrop:a}:{}})]})}),iD=e=>{let t=sn(a=>a.editingTextElement,null),n=sn(a=>a.editingTextSelection,null);if(t===null||n===null||n.start===n.end)return null;let o=e.find(a=>a.id===t);return o===void 0||!fe(o)?null:{target:o,from:Math.min(n.start,n.end),to:Math.max(n.start,n.end)}},oZ=({shapes:e})=>{let t=G(),n=iD(e);if(!t)return null;let o=e.map(l=>l.id),a=rh(e,l=>l.style.fill),r=ra(e,l=>l.style.opacity??1),s=r===null?null:Math.round(r*100);return(0,k.jsx)(Io,{ariaLabel:"Text color and opacity",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:"Color & opacity","aria-label":"Text color and opacity",children:(0,k.jsx)("span",{className:"du-sel-color-swatch",style:{background:!a||a==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":a,opacity:r??1}})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Color"}),(0,k.jsx)(tu,{value:a,onChange:l=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,{fill:l??"transparent"}):t.updateStyle(o,{fill:l??"transparent"})},onEyedrop:l=>{t.beginEyedropperPick(l)}}),(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,k.jsx)(_f,{value:s,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:s===null?"\u2014":`${s}%`,onChange:l=>{t.updateStyle(o,{opacity:l/100})}})]})})},nD=({shapes:e})=>{let t=G();if(!t||!e.some(EZ))return null;let n=rh(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,k.jsx)(aL,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},aZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(r=>r.id),o=ra(e,r=>r.fontSize??null),a=o!==null&&zb.some(r=>r.value===o)?o:null;return(0,k.jsx)(Io,{ariaLabel:"Font size",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font size","aria-label":`Font size ${o??"mixed"}`,children:o===null?"\u2014":`${Math.round(o)}`}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Font size"}),(0,k.jsx)(In,{ariaLabel:"Font size preset",value:a,options:zb.map(r=>({value:r.value,label:r.label,icon:(0,k.jsx)("span",{style:{fontSize:11,fontWeight:600},children:r.label})})),onChange:r=>{t.updateTextProps(n,{fontSize:r})}}),(0,k.jsx)(_f,{value:o,min:AE,max:vE,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},rZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(s=>s.id),o=rh(e,s=>s.fontFamily),a=Gb.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,k.jsx)(Io,{ariaLabel:"Font family",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font family","aria-label":`Font family ${r}`,style:o?{fontFamily:o}:void 0,children:r}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Font family"}),Gb.map(s=>(0,k.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":s.value===o,className:`du-sel-menu-row${s.value===o?" is-active":""}`,style:{fontFamily:s.value},onClick:()=>{t.updateTextProps(n,{fontFamily:s.value})},children:s.label},s.value))]})})},sZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(a=>a.id),o=ra(e,a=>a.style.textAlign??"left");return(0,k.jsx)(In,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,k.jsx)(bo,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,k.jsx)(jr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,k.jsx)(qr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},Ag=({active:e,label:t,icon:n,onClick:o})=>(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${e?" is-active":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:o,children:n}),iZ=({shapes:e})=>{let t=G(),n=iD(e);if(!t)return null;let o=e.map(p=>p.id),a=n?Of(n.target,n.from,n.to):[],r=n?.target.style,s=p=>a.length>0&&a.every(h=>p(h.style)),i=n?s(p=>(p?.fontWeight??r?.fontWeight)==="bold"):e.every(p=>p.style?.fontWeight==="bold"),l=n?s(p=>(p?.fontStyle??r?.fontStyle)==="italic"):e.every(p=>p.style?.fontStyle==="italic"),c=n?s(p=>(p?.textDecoration??r?.textDecoration)?.underline===!0):e.every(p=>p.style?.textDecoration?.underline===!0),u=n?s(p=>(p?.textDecoration??r?.textDecoration)?.strikethrough===!0):e.every(p=>p.style?.textDecoration?.strikethrough===!0),d=p=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,p):t.updateStyle(o,p)},f=(p,h)=>{if(n)t.applyTextStyleToRange(n.target.id,n.from,n.to,{textDecoration:{underline:c,strikethrough:u,[p]:h}});else for(let m of e){let x=m.style?.textDecoration??{};t.updateStyle([m.id],{textDecoration:{...x,[p]:h}})}};return(0,k.jsx)(Io,{ariaLabel:"Text style",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Text style (bold / italic / \u2026)","aria-label":"Text style",children:(0,k.jsx)(Cd,{size:16,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Style"}),(0,k.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,k.jsx)(Ag,{active:i,label:"Bold",icon:(0,k.jsx)(_d,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontWeight:i?"normal":"bold"})}}),(0,k.jsx)(Ag,{active:l,label:"Italic",icon:(0,k.jsx)(Vd,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontStyle:l?"normal":"italic"})}}),(0,k.jsx)(Ag,{active:c,label:"Underline",icon:(0,k.jsx)(gf,{size:14,strokeWidth:1.75}),onClick:()=>{f("underline",!c)}}),(0,k.jsx)(Ag,{active:u,label:"Strikethrough",icon:(0,k.jsx)(hf,{size:14,strokeWidth:1.75}),onClick:()=>{f("strikethrough",!u)}})]})]})})},lZ=({shapes:e})=>{let t=G();if(!t||!e.some(cD))return null;let n=rh(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,k.jsx)(aL,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},cZ=({shapes:e})=>{let t=G();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=ra(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,k.jsx)(In,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,k.jsx)(ou,{thickness:1})},{value:2,label:"Medium",icon:(0,k.jsx)(ou,{thickness:2.5})},{value:4,label:"Thick",icon:(0,k.jsx)(ou,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},uZ=({shapes:e})=>{let t=G();if(!t||!e.some(cD))return null;let n=ra(e,a=>{let r=a.style.dashArray;return!r||r.length===0?"solid":(r[0]??0)<=3?"dotted":"dashed"}),o=e.map(a=>a.id);return(0,k.jsx)(In,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,k.jsx)(Pa,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,k.jsx)(Ba,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},dZ=({shapes:e})=>{let t=G();if(!t||!e.every(i=>ii(i)||i.type==="container"))return null;let o=ra(e,i=>i.style.roundness?.type??"sharp"),a=ra(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,k.jsx)(Io,{ariaLabel:"Corners",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,k.jsx)(nL,{kind:o??"sharp"})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Corners"}),(0,k.jsx)(In,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,k.jsx)(nL,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,k.jsx)(nL,{kind:"round"})}],onChange:i=>{t.updateStyle(r,{roundness:{type:i}})}}),o==="round"?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("label",{className:"du-prop-checkbox",children:[(0,k.jsx)("input",{type:"checkbox",checked:s,onChange:i=>{i.target.checked?t.updateStyle(r,{roundness:{type:"round"}}):t.updateStyle(r,{roundness:{type:"round",value:a??8}})}}),(0,k.jsx)("span",{children:"Auto radius"})]}),s?null:(0,k.jsx)(_f,{value:a,min:0,max:64,step:1,ariaLabel:"Corner radius",valueLabel:`${a}px`,onChange:i=>{t.updateStyle(r,{roundness:{type:"round",value:i}})}})]}):null]})})},oD=({shapes:e})=>{let t=G();if(!t)return null;let n=ra(e,s=>s.style.opacity??1),o=e.map(s=>s.id),a=n===null?null:Math.round(n*100),r=a===null?"\u2014":`${a}%`;return(0,k.jsx)(Io,{ariaLabel:"Opacity",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Opacity","aria-label":`Opacity ${r}`,children:r}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,k.jsx)(_f,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},fZ=()=>{let e=G();return e?(0,k.jsx)(In,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,k.jsx)(Id,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,k.jsx)(of,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,k.jsx)(rf,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,k.jsx)(Md,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},pZ=({shapes:e})=>{let t=G();if(!t||!e.every(a=>ii(a)||sc(a)||Fa(a)))return null;let o=ra(e,a=>ii(a)?"rectangle":sc(a)?"ellipse":"polygon");return(0,k.jsx)(In,{ariaLabel:"Shape type",value:o,options:[{value:"rectangle",label:"Rectangle",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"ellipse",label:"Ellipse",icon:(0,k.jsx)(Ys,{size:14,strokeWidth:1.75})},{value:"polygon",label:"Diamond",icon:(0,k.jsx)(Pd,{size:14,strokeWidth:1.75})}],onChange:a=>{t.convertSelection(a)}})},hZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.length===1?e[0]:void 0;if(n===void 0||!ct(n))return null;let o=n.id;return(0,k.jsx)("button",{type:"button",className:"du-icon-button",title:"Crop image (double-click)","aria-label":"Crop image",onClick:()=>{t.beginImageCrop(o)},children:(0,k.jsx)(Od,{size:16,strokeWidth:1.75})})},mZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.length>=2,o=e.some(r=>ze(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,k.jsx)(Hr,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,k.jsx)(tc,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,k.jsx)(qd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,k.jsx)(xf,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,k.jsx)(Hd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,k.jsx)(Ud,{size:14,strokeWidth:1.75})}),(0,k.jsx)(In,{ariaLabel:"Element actions",value:null,options:a,onChange:r=>{r==="duplicate"?t.duplicateSelected():r==="delete"?t.deleteSelected():r==="group"?t.groupSelected():r==="ungroup"?t.ungroup():r==="flip-h"?t.flipSelection("horizontal"):t.flipSelection("vertical")}})},yZ=[{edge:"left",label:"Align left",icon:(0,k.jsx)(kd,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,k.jsx)(Ql,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,k.jsx)(vd,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,k.jsx)(Ld,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,k.jsx)(bd,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,k.jsx)(Ad,{size:16,strokeWidth:1.75})}],gZ=()=>{let e=G(),t=Qy();if(!e)return null;let n=t.size>=3;return(0,k.jsx)(Io,{ariaLabel:"Align and distribute",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Align","aria-label":"Align",children:(0,k.jsx)(Ql,{size:16,strokeWidth:1.75})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Align"}),(0,k.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:4},children:yZ.map(o=>(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:o.label,"aria-label":o.label,onClick:()=>{e.alignSelection(o.edge)},children:o.icon},o.edge))}),n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Distribute"}),(0,k.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute horizontally","aria-label":"Distribute horizontally",onClick:()=>{e.distributeSelection("horizontal")},children:(0,k.jsx)(Sd,{size:16,strokeWidth:1.75})}),(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute vertically","aria-label":"Distribute vertically",onClick:()=>{e.distributeSelection("vertical")},children:(0,k.jsx)(wd,{size:16,strokeWidth:1.75})})]})]}):null]})})},xZ=({edge:e})=>{let t=G();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,k.jsx)(aL,{label:"Stroke",ariaLabel:"Link stroke color",color:n,onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,stroke:o??"transparent"}}))},onEyedrop:o=>{t.beginEyedropperPick(o)}})},bZ=({edge:e})=>{let t=G();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,k.jsx)(In,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,k.jsx)(ou,{thickness:1})},{value:2,label:"Medium",icon:(0,k.jsx)(ou,{thickness:2.5})},{value:4,label:"Thick",icon:(0,k.jsx)(ou,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},AZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.style.dashArray,o=!n||n.length===0?"solid":(n[0]??0)<=3?"dotted":"dashed";return(0,k.jsx)(In,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,k.jsx)(Pa,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,k.jsx)(Ba,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateSelectedLink(s=>({...s,style:{...s.style,dashArray:r}}))}})},vZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.lineKind??"line";return(0,k.jsx)(In,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,k.jsx)(Da,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,k.jsx)(af,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},SZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.routing??"straight";return(0,k.jsx)(In,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,k.jsx)(rD,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,k.jsx)(rD,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,k.jsx)(pf,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},aD=({edge:e,side:t})=>{let n=G(),[o,a]=(0,hs.useState)(!1);if(!n)return null;let r=e.arrowheads?.[t]??"none",s=l=>{n.updateSelectedLink(c=>({...c,arrowheads:{...c.arrowheads??{},[t]:l}}))},i=({style:l})=>(0,k.jsx)("button",{type:"button",className:`du-arrowhead-option${l===r?" du-arrowhead-option--active":""}`,title:vg[l],"aria-label":vg[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,k.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):lD(l)==="none"?(0,k.jsx)("span",{className:"du-arrowhead-erd-label",children:vg[l].replace(/^ERD /,"")}):(0,k.jsx)(sD,{kind:l,side:t})});return(0,k.jsx)(Io,{trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${vg[r]}`,"aria-label":`Arrow ${t}`,children:(0,k.jsx)(sD,{kind:r,side:t})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsxs)("header",{className:"du-sel-popover-label",children:["Arrow ",t]}),(0,k.jsx)("div",{className:"du-arrowhead-grid",children:wZ.map(l=>(0,k.jsx)(i,{style:l},l))}),(0,k.jsxs)("button",{type:"button",className:"du-arrowhead-erd-toggle","aria-expanded":o,onClick:()=>{a(l=>!l)},children:[o?"\u25BE":"\u25B8"," ER diagram"]}),o&&(0,k.jsx)("div",{className:"du-arrowhead-grid",children:_Z.map(l=>(0,k.jsx)(i,{style:l},l))})]})})},LZ=({edge:e})=>{let t=G();if(!t||(e.routing??"straight")==="bezier")return null;let o=e.avoidObstacles===!0;return(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${o?" is-active":""}`,title:"Route around shapes","aria-label":"Route around shapes","aria-pressed":o,onClick:()=>{t.setSelectedLinkAvoidObstacles(!o)},children:(0,k.jsx)(Af,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},kZ=()=>{let e=G();return e?(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Delete edge","aria-label":"Delete edge",onClick:()=>{e.deleteSelected()},children:(0,k.jsx)(tc,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},rD=({kind:e})=>e==="straight"?(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("line",{x1:2,y1:11,x2:12,y2:3,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"})}):(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("path",{d:"M 2 11 L 2 7 L 12 7 L 12 3",stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),lD=e=>{switch(e){case"arrow":case"openArrow":case"roundedArrow":case"arcArrow":return"open";case"triangle":case"filledArrow":return"triangle";case"diamond":case"rhombus":case"filledRhombus":return"diamond";case"circle":case"filledCircle":return"circle";default:return"none"}},wZ=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],_Z=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],vg={none:"None",arrow:"Arrow",openArrow:"Open arrow",roundedArrow:"Rounded arrow",arcArrow:"Arc arrow",triangle:"Triangle",filledArrow:"Filled arrow",circle:"Circle",filledCircle:"Filled circle",diamond:"Diamond",rhombus:"Rhombus",filledRhombus:"Filled rhombus",erdOne:"ERD one",erdOnlyOne:"ERD only one",erdMany:"ERD many",erdOneOrMany:"ERD one or many",erdZeroOrOne:"ERD zero or one",erdZeroOrMany:"ERD zero or many"},sD=({kind:e,side:t})=>{let n=t==="from",o=n?12:2,a=n?5:9,r=n?3:11,s=n?5:9,i=(0,k.jsx)("line",{x1:o,y1:7,x2:a,y2:7,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"}),l=lD(e),c=null;return l==="open"?c=(0,k.jsx)("polyline",{points:n?`${r+3},4 ${r},7 ${r+3},10`:`${r-3},4 ${r},7 ${r-3},10`,stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}):l==="triangle"?c=(0,k.jsx)("polygon",{points:n?`${r},7 ${s},4 ${s},10`:`${r},7 ${s},4 ${s},10`,fill:"currentColor"}):l==="diamond"?c=(0,k.jsx)("polygon",{points:`${r},4 ${r+(n?-3:3)},7 ${r},10 ${r+(n?3:-3)},7`,fill:e==="filledRhombus"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2}):l==="circle"&&(c=(0,k.jsx)("circle",{cx:r,cy:7,r:2.2,fill:e==="filledCircle"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2})),(0,k.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[i,c]})},CZ=()=>(0,k.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),ou=({thickness:e})=>(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("line",{x1:2,y1:7,x2:12,y2:7,stroke:"currentColor",strokeWidth:e,strokeLinecap:"round"})}),nL=({kind:e})=>e==="sharp"?(0,k.jsx)(Uo,{size:14,strokeWidth:1.75,"aria-hidden":!0}):(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("rect",{x:2,y:2,width:10,height:10,rx:3,ry:3,stroke:"currentColor",strokeWidth:1.5})}),ra=(e,t)=>{let n=new Set;for(let a of e)n.add(t(a));return n.size!==1?null:n.values().next().value??null},rh=(e,t)=>{let n=ra(e,o=>t(o));return typeof n=="string"?n:null},EZ=e=>e.style.fill!==void 0||Be(e),cD=e=>e.style.stroke!==void 0;var sL=({offset:e=48,placement:t="top",edgeInset:n}={})=>{let o={top:n?.top??66,right:n?.right??16,bottom:n?.bottom??66,left:n?.left??16},a=G(),r=is(),s=Dt(),i=jp(),[l,c]=(0,sa.useState)(!1),u=(0,sa.useRef)(null),[d,f]=(0,sa.useState)(0),[p,h]=(0,sa.useState)(!1);return(0,sa.useEffect)(()=>{if(!a)return;let m=()=>{let x=a.selection,y=a.selection.size>0||a.selectedLink!==null;c(g=>(!g&&y&&h(!1),y)),f(g=>g+1)};return m(),a.on("change",m)},[a]),(0,sa.useLayoutEffect)(()=>{if(!a||!l||i)return;let m=u.current;if(!m)return;let x=TZ(a);if(!x)return;let y=()=>{gg(x,m,{placement:t,middleware:[hg(e),yg({fallbackPlacements:["bottom","right","left"],padding:o}),mg({padding:o})]}).then(({x:b,y:A})=>{m.style.transform=`translate(${Math.round(b)}px, ${Math.round(A)}px)`,h(!0)})};return y(),pg(x,m,y)},[a,l,i,d,e,t,o.top,o.right,o.bottom,o.left]),!a||!l||r?null:i?(0,rL.createPortal)((0,sh.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,sh.jsx)(oL,{mobile:!0})}),s):(0,rL.createPortal)((0,sh.jsx)("div",{ref:u,className:"du-sel-panel-floating",role:"toolbar","aria-label":"Selection actions",style:{position:"absolute",top:0,left:0,zIndex:1500,pointerEvents:"auto",opacity:p?1:0,transition:p?"opacity 120ms ease":"none",...p?{}:{pointerEvents:"none"}},children:(0,sh.jsx)(oL,{})}),s)},TZ=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=IZ(e);if(!n){let c=t.getBoundingClientRect();return new DOMRect(c.left,c.top,0,0)}let o=e.scene.viewport,a=(n.x-o.pan.x)*o.zoom,r=(n.y-o.pan.y)*o.zoom,s=Math.max(1,n.width*o.zoom),i=Math.max(1,n.height*o.zoom),l=t.getBoundingClientRect();return new DOMRect(l.left+a,l.top+r,s,i)},contextElement:t}:null},IZ=e=>{let t=[];for(let o of e.selection){let a=e.scene.elements.get(o);a&&t.push(a)}if(t.length===0){let o=e.selectedLink;if(o){let a=e.scene.links.get(o);if(a)return os(e.scene,a)}return null}let n=null;for(let o of t){if(ze(o)&&e.scene.elements.has(o.id)){let r=bA(e.scene,o.id);for(let s of r){if(ze(s))continue;let i;try{i=z(s)}catch{continue}i.width===0&&i.height===0||(n=uD(n,i))}continue}let a;try{a=z(o)}catch{continue}n=uD(n,a)}return n},uD=(e,t)=>{if(!e)return{...t};let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var ys=P(se(),1),Le=P(re(),1);var au="Roboto",ih="PT Serif",lh="Roboto Mono",ru=e=>{let t=e.toLowerCase();return t.includes("mono")?lh:t.includes("sans")?au:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?ih:au},MZ=[{family:au,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:au,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:au,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:au,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:ih,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:ih,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:ih,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:ih,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:lh,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:lh,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:lh,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:lh,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],dD=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(MZ.map(async n=>{let o=new FontFace(n.family,`url(${n.url.href})`,{weight:n.weight,style:n.style});await o.load(),t.add(o)}))};var RZ=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],Sg=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of RZ){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},pD=e=>{let t=e;return typeof t.naturalWidth=="number"&&t.naturalWidth>0?{width:t.naturalWidth,height:t.naturalHeight??t.naturalWidth}:typeof t.videoWidth=="number"&&t.videoWidth>0?{width:t.videoWidth,height:t.videoHeight??t.videoWidth}:typeof t.width=="number"&&t.width>0&&typeof t.height=="number"?{width:t.width,height:t.height}:null},fD=new Set,Lg=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";fD.has(t)||(fD.add(t),console.warn(`[renderer] skipped a non-drawable image source (kind: ${t}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap \u2014 likely a scene restored from storage where the <img> was lost (metadata.image) and src is a dead blob: URL. The image won't render until rehydrated from Scene.files.`))};var or=class{ctx;_width;_height;dpr;constructor(t,n,o,a=1){this.ctx=t,this._width=n,this._height=o,this.dpr=a}get size(){return{width:this._width,height:this._height}}resize(t,n,o){this._width=t,this._height=n,o!==void 0&&(this.dpr=o)}setFill(t){this.ctx.fillStyle=t??"transparent"}setStroke(t){this.ctx.strokeStyle=t??"transparent"}setStrokeWidth(t){this.ctx.lineWidth=t}setOpacity(t){this.ctx.globalAlpha=t}setLineCap(t){this.ctx.lineCap=t}setLineJoin(t){this.ctx.lineJoin=t}setDashArray(t){this.ctx.setLineDash(t?[...t]:[])}setFont(t,n,o){let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.ctx.font=`${a}${r}${n}px "${ru(t)}", ${t}`}setTextAlign(t){this.ctx.textAlign=t==="center"?"center":t}setTextBaseline(t){this.ctx.textBaseline=t==="middle"?"middle":t==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,n){this.ctx.translate(t,n)}rotate(t){this.ctx.rotate(t)}scale(t,n){this.ctx.scale(t,n)}setTransform(t){let n=this.dpr;this.ctx.setTransform(n*t.a,n*t.b,n*t.c,n*t.d,n*t.e,n*t.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(t,n){this.ctx.moveTo(t,n)}lineTo(t,n){this.ctx.lineTo(t,n)}quadraticCurveTo(t,n,o,a){this.ctx.quadraticCurveTo(t,n,o,a)}bezierCurveTo(t,n,o,a,r,s){this.ctx.bezierCurveTo(t,n,o,a,r,s)}rect(t,n,o,a){this.ctx.rect(t,n,o,a)}ellipse(t,n,o,a){this.ctx.ellipse(t,n,o,a,0,0,Math.PI*2)}fill(t){this.ctx.fill(t)}stroke(){this.ctx.stroke()}fillText(t,n,o,a){a!==void 0?this.ctx.fillText(t,n,o,a):this.ctx.fillText(t,n,o)}measureText(t){return{width:this.ctx.measureText(t).width}}drawImage(t,n,o,a,r,s,i){if(!Sg(t)){Lg(t);return}if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){let l=pD(t);if(l){this.ctx.drawImage(t,i.x*l.width,i.y*l.height,i.width*l.width,i.height*l.height,n,o,a,r);return}}this.ctx.drawImage(t,n,o,a,r)}clear(t){this.dirtyRect=null,t?this.ctx.clearRect(t.x,t.y,t.width,t.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(t){if(!this.dirtyRect){this.dirtyRect=t;return}let n=Math.min(this.dirtyRect.x,t.x),o=Math.min(this.dirtyRect.y,t.y),a=Math.max(this.dirtyRect.x+this.dirtyRect.width,t.x+t.width),r=Math.max(this.dirtyRect.y+this.dirtyRect.height,t.y+t.height);this.dirtyRect={x:n,y:o,width:a-n,height:r-o}}getDirtyRect(){return this.dirtyRect}};var ch=class{shaper;atlasSize;tileSize;range;columns;capacity;glyphs=new Map;buffer;dirtyTiles=new Set;needsFullUpload=!0;nextSlot=0;texture=null;constructor(t,n={}){if(this.shaper=t,this.atlasSize=n.atlasSize??2048,this.tileSize=n.tileSize??64,this.range=n.range??8,this.atlasSize%this.tileSize!==0)throw new Error(`GlyphAtlas: atlasSize (${this.atlasSize}) must be a multiple of tileSize (${this.tileSize})`);this.columns=this.atlasSize/this.tileSize,this.capacity=this.columns*this.columns,this.buffer=new Uint8Array(this.atlasSize*this.atlasSize*3)}resolveFontId(t,n=!1,o=!1){return this.shaper.resolveFontId?.(t,n,o)??0}getOrRasterize(t,n=0){let o=n*1114112+t,a=this.glyphs.get(o);if(a)return a;if(this.nextSlot>=this.capacity)return null;let r=this.shaper.glyphMetrics(t,n);if(!r)return null;let s=this.nextSlot++,i=s%this.columns,l=Math.floor(s/this.columns),c=i*this.tileSize,u=l*this.tileSize,d=r.bboxW<=0||r.bboxH<=0;if(!d){let p=this.shaper.rasterizeGlyphMSDF(t,this.tileSize,this.range,n);if(p){for(let h=0;h<this.tileSize;h++){let m=h*this.tileSize*3,x=((u+h)*this.atlasSize+c)*3;this.buffer.set(p.data.subarray(m,m+this.tileSize*3),x)}this.dirtyTiles.add(s)}}let f={codePoint:t,atlasX:c,atlasY:u,tileSize:this.tileSize,range:this.range,advance:r.advance,bboxXMin:r.bboxXMin,bboxYMin:r.bboxYMin,bboxW:r.bboxW,bboxH:r.bboxH,unitsPerEm:r.unitsPerEm,empty:d};return this.glyphs.set(o,f),f}get glyphCount(){return this.glyphs.size}get cpuBuffer(){return this.buffer}uploadTo(t){if(this.texture)t.bindTexture(t.TEXTURE_2D,this.texture);else{let n=t.createTexture();if(!n)throw new Error("GlyphAtlas: gl.createTexture() returned null");this.texture=n,t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}if(this.needsFullUpload)return t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGB8,this.atlasSize,this.atlasSize,0,t.RGB,t.UNSIGNED_BYTE,this.buffer),this.needsFullUpload=!1,this.dirtyTiles.clear(),this.texture;if(this.dirtyTiles.size===0)return this.texture;t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ROW_LENGTH,this.atlasSize);for(let n of this.dirtyTiles){let o=n%this.columns,a=Math.floor(n/this.columns),r=o*this.tileSize,s=a*this.tileSize,i=r,l=s;t.pixelStorei(t.UNPACK_SKIP_PIXELS,i),t.pixelStorei(t.UNPACK_SKIP_ROWS,l),t.texSubImage2D(t.TEXTURE_2D,0,r,s,this.tileSize,this.tileSize,t.RGB,t.UNSIGNED_BYTE,this.buffer)}return t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),this.dirtyTiles.clear(),this.texture}dispose(t){this.texture&&t&&t.deleteTexture(this.texture),this.texture=null,this.needsFullUpload=!0}};function cL(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=mD(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=NZ(e,t,r,n)),e.length>80*n){i=e[0],l=e[1];let u=i,d=l;for(let f=n;f<a;f+=n){let p=e[f],h=e[f+1];p<i&&(i=p),h<l&&(l=h),p>u&&(u=p),h>d&&(d=h)}c=Math.max(u-i,d-l),c=c!==0?32767/c:0}return dh(r,s,n,i,l,c,0),s}function mD(e,t,n,o,a){let r;if(a===XZ(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=hD(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=hD(s/o|0,e[s],e[s+1],r);return r&&su(r,r.next)&&(ph(r),r=r.next),r}function nl(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(su(n,n.next)||Ke(n.prev,n,n.next)===0)){if(ph(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function dh(e,t,n,o,a,r,s){if(!e)return;!s&&r&&GZ(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?DZ(e,o,a,r):OZ(e)){t.push(l.i,e.i,c.i),ph(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=PZ(nl(e),t),dh(e,t,n,o,a,r,2)):s===2&&BZ(e,t,n,o,a,r):dh(nl(e),t,n,o,a,r,1);break}}}function OZ(e){let t=e.prev,n=e,o=e.next;if(Ke(t,n,o)>=0)return!1;let a=t.x,r=n.x,s=o.x,i=t.y,l=n.y,c=o.y,u=Math.min(a,r,s),d=Math.min(i,l,c),f=Math.max(a,r,s),p=Math.max(i,l,c),h=o.next;for(;h!==t;){if(h.x>=u&&h.x<=f&&h.y>=d&&h.y<=p&&uh(a,i,r,l,s,c,h.x,h.y)&&Ke(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function DZ(e,t,n,o){let a=e.prev,r=e,s=e.next;if(Ke(a,r,s)>=0)return!1;let i=a.x,l=r.x,c=s.x,u=a.y,d=r.y,f=s.y,p=Math.min(i,l,c),h=Math.min(u,d,f),m=Math.max(i,l,c),x=Math.max(u,d,f),y=iL(p,h,t,n,o),g=iL(m,x,t,n,o),b=e.prevZ,A=e.nextZ;for(;b&&b.z>=y&&A&&A.z<=g;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&uh(i,u,l,d,c,f,b.x,b.y)&&Ke(b.prev,b,b.next)>=0||(b=b.prevZ,A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&uh(i,u,l,d,c,f,A.x,A.y)&&Ke(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&uh(i,u,l,d,c,f,b.x,b.y)&&Ke(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=g;){if(A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&uh(i,u,l,d,c,f,A.x,A.y)&&Ke(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function PZ(e,t){let n=e;do{let o=n.prev,a=n.next.next;!su(o,a)&&gD(o,n,n.next,a)&&fh(o,a)&&fh(a,o)&&(t.push(o.i,n.i,a.i),ph(n),ph(n.next),n=e=a),n=n.next}while(n!==e);return nl(n)}function BZ(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&jZ(s,i)){let l=xD(s,i);s=nl(s,s.next),l=nl(l,l.next),dh(s,t,n,o,a,r,0),dh(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function NZ(e,t,n,o){let a=[];for(let r=0,s=t.length;r<s;r++){let i=t[r]*o,l=r<s-1?t[r+1]*o:e.length,c=mD(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(qZ(c))}a.sort(zZ);for(let r=0;r<a.length;r++)n=FZ(a[r],n);return n}function zZ(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){let o=(e.next.y-e.y)/(e.next.x-e.x),a=(t.next.y-t.y)/(t.next.x-t.x);n=o-a}return n}function FZ(e,t){let n=HZ(e,t);if(!n)return t;let o=xD(n,e);return nl(o,o.next),nl(n,n.next)}function HZ(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(su(e,n))return n;do{if(su(e,n.next))return n.next;if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){let d=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(d<=o&&d>r&&(r=d,s=n.x<n.next.x?n:n.next,d===o))return s}n=n.next}while(n!==t);if(!s)return null;let i=s,l=s.x,c=s.y,u=1/0;n=s;do{if(o>=n.x&&n.x>=l&&o!==n.x&&yD(a<c?o:r,a,l,c,a<c?r:o,a,n.x,n.y)){let d=Math.abs(a-n.y)/(o-n.x);fh(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&UZ(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function UZ(e,t){return Ke(e.prev,e,t.prev)<0&&Ke(t.next,e,e.next)<0}function GZ(e,t,n,o){let a=e;do a.z===0&&(a.z=iL(a.x,a.y,t,n,o)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,WZ(a)}function WZ(e){let t,n=1;do{let o=e,a;e=null;let r=null;for(t=0;o;){t++;let s=o,i=0;for(let c=0;c<n&&(i++,s=s.nextZ,!!s);c++);let l=n;for(;i>0||l>0&&s;)i!==0&&(l===0||!s||o.z<=s.z)?(a=o,o=o.nextZ,i--):(a=s,s=s.nextZ,l--),r?r.nextZ=a:e=a,a.prevZ=r,r=a;o=s}r.nextZ=null,n*=2}while(t>1);return e}function iL(e,t,n,o,a){return e=(e-n)*a|0,t=(t-o)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function qZ(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function yD(e,t,n,o,a,r,s,i){return(a-s)*(t-i)>=(e-s)*(r-i)&&(e-s)*(o-i)>=(n-s)*(t-i)&&(n-s)*(r-i)>=(a-s)*(o-i)}function uh(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&yD(e,t,n,o,a,r,s,i)}function jZ(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!VZ(e,t)&&(fh(e,t)&&fh(t,e)&&ZZ(e,t)&&(Ke(e.prev,e,t.prev)||Ke(e,t.prev,t))||su(e,t)&&Ke(e.prev,e,e.next)>0&&Ke(t.prev,t,t.next)>0)}function Ke(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function su(e,t){return e.x===t.x&&e.y===t.y}function gD(e,t,n,o){let a=wg(Ke(e,t,n)),r=wg(Ke(e,t,o)),s=wg(Ke(n,o,e)),i=wg(Ke(n,o,t));return!!(a!==r&&s!==i||a===0&&kg(e,n,t)||r===0&&kg(e,o,t)||s===0&&kg(n,e,o)||i===0&&kg(n,t,o))}function kg(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function wg(e){return e>0?1:e<0?-1:0}function VZ(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&gD(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function fh(e,t){return Ke(e.prev,e,e.next)<0?Ke(e,t,e.next)>=0&&Ke(e,e.prev,t)>=0:Ke(e,t,e.prev)<0||Ke(e,e.next,t)<0}function ZZ(e,t){let n=e,o=!1,a=(e.x+t.x)/2,r=(e.y+t.y)/2;do n.y>r!=n.next.y>r&&n.next.y!==n.y&&a<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==e);return o}function xD(e,t){let n=lL(e.i,e.x,e.y),o=lL(t.i,t.x,t.y),a=e.next,r=t.prev;return e.next=t,t.prev=e,n.next=a,a.prev=n,o.next=n,n.prev=o,r.next=o,o.prev=r,o}function hD(e,t,n,o){let a=lL(e,t,n);return o?(a.next=o.next,a.prev=o,o.next.prev=a,o.next=a):(a.prev=a,a.next=a),a}function ph(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function lL(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function XZ(e,t,n,o){let a=0;for(let r=t,s=n-o;r<n;r+=o)a+=(e[s]-e[r])*(e[r+1]+e[s+1]),s=r;return a}var uL=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=v0.parse(e);return[t/255,n/255,o/255,a]}catch{return typeof console<"u"&&console.warn(`[WebGL2Target] cannot parse color '${e}', falling back to black`),[0,0,0,1]}};var Wt=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},Nt=(e,t,n,o)=>{let a=Wt(e.createShader(t));if(e.shaderSource(a,n),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS)){let r=e.getShaderInfoLog(a);throw e.deleteShader(a),new Error(`${o} shader compile failed: ${r}`)}return a},Mo=(e,t,n,o)=>{let a=Wt(e.createProgram());if(e.attachShader(a,t),e.attachShader(a,n),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let r=e.getProgramInfoLog(a);throw e.deleteProgram(a),new Error(`${o} program link failed: ${r}`)}return a};var Cg=class{gl;program;vbo;uTransform;uColor;uOpacity;uPxRange;uAtlas;aPos;aUV;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,JZ,"MSDF"),o=Nt(t,t.FRAGMENT_SHADER,eX,"MSDF");this.program=Mo(t,n,o,"MSDF"),this.vbo=Wt(t.createBuffer()),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aUV=t.getAttribLocation(this.program,"aUV"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.uPxRange=t.getUniformLocation(this.program,"uPxRange"),this.uAtlas=t.getUniformLocation(this.program,"uAtlas")}drawText(t,n,o,a,r,s,i,l=0,c=0){if(t.length===0)return 0;let u=6,d=4,f=t.length*u*d;$Z(f);let p=_g,h=0,m=n,x=!0;for(let w of t){let S=w.codePointAt(0);if(S===void 0)continue;let L=r.getOrRasterize(S,c);if(!L){x=!1;break}let M=L.advance*a/L.unitsPerEm;if(L.empty){m+=M;continue}KZ(p,h,L,m,o,a,r),h+=u*d,m+=M}if(x&&a>0&&vD(r,t,c,(m-n)/a),h===0)return m-n;let y=r.uploadTo(this.gl),g=this.gl;g.useProgram(this.program),g.bindBuffer(g.ARRAY_BUFFER,this.vbo),g.bufferData(g.ARRAY_BUFFER,p.subarray(0,h),g.DYNAMIC_DRAW),g.enableVertexAttribArray(this.aPos),g.vertexAttribPointer(this.aPos,2,g.FLOAT,!1,16,0),g.enableVertexAttribArray(this.aUV),g.vertexAttribPointer(this.aUV,2,g.FLOAT,!1,16,8);let b=s.transform,A=b;if(l!==0){let w=-(m-n)*l;A={...b,e:b.e+b.a*w,f:b.f+b.b*w}}QZ(bD,A,i.width,i.height),g.uniformMatrix3fv(this.uTransform,!1,bD),g.uniform3f(this.uColor,s.color[0],s.color[1],s.color[2]),g.uniform1f(this.uOpacity,s.opacity);let _=r.tileSize-2*r.range,T=r.range*a/Math.max(1,_);return g.uniform1f(this.uPxRange,T),g.activeTexture(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y),g.uniform1i(this.uAtlas,0),g.drawArrays(g.TRIANGLES,0,h/d),m-n}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},YZ=(e,t,n,o,a)=>{let r=o/e.unitsPerEm,s=Math.max(1,a.tileSize-2*a.range),i=Math.max(e.bboxW,e.bboxH)/s,l=e.bboxW/i+2*a.range,c=e.bboxH/i+2*a.range,u=a.range*i*r,d=e.bboxW*r+2*u,f=e.bboxH*r+2*u,p=t+e.bboxXMin*r-u,h=n+(-e.bboxYMin-e.bboxH)*r-u,m=p+d,x=h+f,y=.5,g=(e.atlasX+y)/a.atlasSize,b=(e.atlasY+y)/a.atlasSize,A=(e.atlasX+l-y)/a.atlasSize,_=(e.atlasY+c-y)/a.atlasSize;return{left:p,top:h,right:m,bottom:x,u0:g,v0:b,u1:A,v1:_}},dL=new WeakMap,AD=(e,t)=>`${t}\0${e}`,vD=(e,t,n,o)=>{let a=dL.get(e);a||(a=new Map,dL.set(e,a));let r=AD(t,n);if(a.delete(r),a.set(r,o),a.size>1024){let s=a.keys().next().value;s!==void 0&&a.delete(s)}},SD=(e,t,n=0)=>{if(e.length===0)return 0;let o=AD(e,n),a=dL.get(t);if(a){let s=a.get(o);if(s!==void 0)return a.delete(o),a.set(o,s),s}let r=0;for(let s of e){let i=s.codePointAt(0);if(i===void 0)continue;let l=t.getOrRasterize(i,n);l&&(r+=l.advance/l.unitsPerEm)}return vD(t,e,n,r),r},KZ=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=YZ(n,o,a,r,s);e.set([i,l,d,f,c,l,p,f,i,u,d,h,c,l,p,f,c,u,p,h,i,u,d,h],t)},_g=new Float32Array(512),bD=new Float32Array(9),$Z=e=>{if(_g.length>=e)return;let t=_g.length;for(;t<e;)t*=2;_g=new Float32Array(t)},QZ=(e,t,n,o)=>{let a=2/n,r=-2/o;e[0]=t.a*a,e[1]=t.b*r,e[2]=0,e[3]=t.c*a,e[4]=t.d*r,e[5]=0,e[6]=t.e*a-1,e[7]=t.f*r+1,e[8]=1},JZ=`#version 300 es
8
+ `+o.stack}}var u1=Object.prototype.hasOwnProperty,eb=mt.unstable_scheduleCallback,Tx=mt.unstable_cancelCallback,d7=mt.unstable_shouldYield,f7=mt.unstable_requestPaint,Ln=mt.unstable_now,p7=mt.unstable_getCurrentPriorityLevel,V_=mt.unstable_ImmediatePriority,j_=mt.unstable_UserBlockingPriority,Dm=mt.unstable_NormalPriority,h7=mt.unstable_LowPriority,Z_=mt.unstable_IdlePriority,m7=mt.log,y7=mt.unstable_setDisableYieldValue,fd=null,kn=null;function vr(e){if(typeof m7=="function"&&y7(e),kn&&typeof kn.setStrictMode=="function")try{kn.setStrictMode(fd,e)}catch{}}var _n=Math.clz32?Math.clz32:b7,g7=Math.log,x7=Math.LN2;function b7(e){return e>>>=0,e===0?32:31-(g7(e)/x7|0)|0}var Jh=256,em=262144,tm=4194304;function Ms(e){var t=e&42;if(t!==0)return t;switch(e&-e){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function s0(e,t,n){var o=e.pendingLanes;if(o===0)return 0;var a=0,r=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var i=o&134217727;return i!==0?(o=i&~r,o!==0?a=Ms(o):(s&=i,s!==0?a=Ms(s):n||(n=i&~e,n!==0&&(a=Ms(n))))):(i=o&~r,i!==0?a=Ms(i):s!==0?a=Ms(s):n||(n=o&~e,n!==0&&(a=Ms(n)))),a===0?0:t!==0&&t!==a&&(t&r)===0&&(r=a&-a,n=t&-t,r>=n||r===32&&(n&4194048)!==0)?t:a}function pd(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function A7(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function X_(){var e=tm;return tm<<=1,(tm&62914560)===0&&(tm=4194304),e}function Ex(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function hd(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function v7(e,t,n,o,a,r){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var i=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-_n(n),d=1<<u;i[u]=0,l[u]=-1;var f=c[u];if(f!==null)for(c[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}o!==0&&Y_(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function Y_(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-_n(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function K_(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-_n(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function $_(e,t){var n=t&-t;return n=(n&42)!==0?1:tb(n),(n&(e.suspendedLanes|t))!==0?0:n}function tb(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function nb(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Q_(){var e=_e.p;return e!==0?e:(e=window.event,e===void 0?32:vE(e.type))}function gk(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var Fr=Math.random().toString(36).slice(2),Mt="__reactFiber$"+Fr,an="__reactProps$"+Fr,jl="__reactContainer$"+Fr,d1="__reactEvents$"+Fr,S7="__reactListeners$"+Fr,L7="__reactHandles$"+Fr,xk="__reactResources$"+Fr,md="__reactMarker$"+Fr;function ob(e){delete e[Mt],delete e[an],delete e[d1],delete e[S7],delete e[L7]}function xl(e){var t=e[Mt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[jl]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=w_(e);e!==null;){if(n=e[Mt])return n;e=w_(e)}return t}e=n,n=e.parentNode}return null}function Zl(e){if(e=e[Mt]||e[jl]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Pu(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function El(e){var t=e[xk];return t||(t=e[xk]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function kt(e){e[md]=!0}var J_=new Set,ew={};function qs(e,t){Bl(e,t),Bl(e+"Capture",t)}function Bl(e,t){for(ew[e]=t,e=0;e<t.length;e++)J_.add(t[e])}var k7=RegExp("^[: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]*$"),bk={},Ak={};function _7(e){return u1.call(Ak,e)?!0:u1.call(bk,e)?!1:k7.test(e)?Ak[e]=!0:(bk[e]=!0,!1)}function ym(e,t,n){if(_7(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function nm(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function ga(e,t,n,o){if(o===null)e.removeAttribute(n);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+o)}}function qn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function w7(e,t,n){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,r=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(s){n=""+s,r.call(this,s)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function f1(e){if(!e._valueTracker){var t=tw(e)?"checked":"value";e._valueTracker=w7(e,t,""+e[t])}}function nw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=tw(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function Pm(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var T7=/[\n"\\]/g;function Zn(e){return e.replace(T7,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function p1(e,t,n,o,a,r,s,i){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+qn(t)):e.value!==""+qn(t)&&(e.value=""+qn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?h1(e,s,qn(t)):n!=null?h1(e,s,qn(n)):o!=null&&e.removeAttribute("value"),a==null&&r!=null&&(e.defaultChecked=!!r),a!=null&&(e.checked=a&&typeof a!="function"&&typeof a!="symbol"),i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?e.name=""+qn(i):e.removeAttribute("name")}function ow(e,t,n,o,a,r,s,i){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(e.type=r),t!=null||n!=null){if(!(r!=="submit"&&r!=="reset"||t!=null)){f1(e);return}n=n!=null?""+qn(n):"",t=t!=null?""+qn(t):n,i||t===e.value||(e.value=t),e.defaultValue=t}o=o??a,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=i?e.checked:!!o,e.defaultChecked=!!o,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),f1(e)}function h1(e,t,n){t==="number"&&Pm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Cl(e,t,n,o){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&o&&(e[n].defaultSelected=!0)}else{for(n=""+qn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,o&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function aw(e,t,n){if(t!=null&&(t=""+qn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+qn(n):""}function rw(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Du(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=qn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),f1(e)}function Nl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var E7=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function vk(e,t,n){var o=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,n):typeof n!="number"||n===0||E7.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function sw(e,t,n){if(t!=null&&typeof t!="object")throw Error(O(62));if(e=e.style,n!=null){for(var o in n)!n.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var a in t)o=t[a],t.hasOwnProperty(a)&&n[a]!==o&&vk(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&vk(e,r,t[r])}function ab(e){if(e.indexOf("-")===-1)return!1;switch(e){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 C7=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),I7=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function gm(e){return I7.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function _a(){}var m1=null;function rb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bl=null,Il=null;function Sk(e){var t=Zl(e);if(t&&(e=t.stateNode)){var n=e[an]||null;e:switch(e=t.stateNode,t.type){case"input":if(p1(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Zn(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var o=n[t];if(o!==e&&o.form===e.form){var a=o[an]||null;if(!a)throw Error(O(90));p1(o,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)o=n[t],o.form===e.form&&nw(o)}break e;case"textarea":aw(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Cl(e,!!n.multiple,t,!1)}}}var Cx=!1;function iw(e,t,n){if(Cx)return e(t,n);Cx=!0;try{var o=e(t);return o}finally{if(Cx=!1,(bl!==null||Il!==null)&&(x0(),bl&&(t=bl,e=Il,Il=bl=null,Sk(t),e)))for(t=0;t<e.length;t++)Sk(e[t])}}function Qu(e,t){var n=e.stateNode;if(n===null)return null;var o=n[an]||null;if(o===null)return null;n=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var Ia=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),y1=!1;if(Ia)try{dl={},Object.defineProperty(dl,"passive",{get:function(){y1=!0}}),window.addEventListener("test",dl,dl),window.removeEventListener("test",dl,dl)}catch{y1=!1}var dl,Sr=null,sb=null,xm=null;function lw(){if(xm)return xm;var e,t=sb,n=t.length,o,a="value"in Sr?Sr.value:Sr.textContent,r=a.length;for(e=0;e<n&&t[e]===a[e];e++);var s=n-e;for(o=1;o<=s&&t[n-o]===a[r-o];o++);return xm=a.slice(e,1<o?1-o:void 0)}function bm(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function om(){return!0}function Lk(){return!1}function rn(e){function t(n,o,a,r,s){this._reactName=n,this._targetInst=a,this.type=o,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var i in e)e.hasOwnProperty(i)&&(n=e[i],this[i]=n?n(r):r[i]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?om:Lk,this.isPropagationStopped=Lk,this}return qe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=om)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=om)},persist:function(){},isPersistent:om}),t}var Vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},i0=rn(Vs),yd=qe({},Vs,{view:0,detail:0}),M7=rn(yd),Ix,Mx,Tu,l0=qe({},yd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ib,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Tu&&(Tu&&e.type==="mousemove"?(Ix=e.screenX-Tu.screenX,Mx=e.screenY-Tu.screenY):Mx=Ix=0,Tu=e),Ix)},movementY:function(e){return"movementY"in e?e.movementY:Mx}}),kk=rn(l0),R7=qe({},l0,{dataTransfer:0}),O7=rn(R7),D7=qe({},yd,{relatedTarget:0}),Rx=rn(D7),P7=qe({},Vs,{animationName:0,elapsedTime:0,pseudoElement:0}),B7=rn(P7),N7=qe({},Vs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),z7=rn(N7),F7=qe({},Vs,{data:0}),_k=rn(F7),H7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},U7={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"},G7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function W7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=G7[e])?!!t[e]:!1}function ib(){return W7}var q7=qe({},yd,{key:function(e){if(e.key){var t=H7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=bm(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?U7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ib,charCode:function(e){return e.type==="keypress"?bm(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?bm(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),V7=rn(q7),j7=qe({},l0,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wk=rn(j7),Z7=qe({},yd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ib}),X7=rn(Z7),Y7=qe({},Vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),K7=rn(Y7),$7=qe({},l0,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Q7=rn($7),J7=qe({},Vs,{newState:0,oldState:0}),eB=rn(J7),tB=[9,13,27,32],lb=Ia&&"CompositionEvent"in window,zu=null;Ia&&"documentMode"in document&&(zu=document.documentMode);var nB=Ia&&"TextEvent"in window&&!zu,cw=Ia&&(!lb||zu&&8<zu&&11>=zu),Tk=" ",Ek=!1;function uw(e,t){switch(e){case"keyup":return tB.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Al=!1;function oB(e,t){switch(e){case"compositionend":return dw(t);case"keypress":return t.which!==32?null:(Ek=!0,Tk);case"textInput":return e=t.data,e===Tk&&Ek?null:e;default:return null}}function aB(e,t){if(Al)return e==="compositionend"||!lb&&uw(e,t)?(e=lw(),xm=sb=Sr=null,Al=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return cw&&t.locale!=="ko"?null:t.data;default:return null}}var rB={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 Ck(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!rB[e.type]:t==="textarea"}function fw(e,t,n,o){bl?Il?Il.push(o):Il=[o]:bl=o,t=Jm(t,"onChange"),0<t.length&&(n=new i0("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Fu=null,Ju=null;function sB(e){iE(e,0)}function c0(e){var t=Pu(e);if(nw(t))return e}function Ik(e,t){if(e==="change")return t}var pw=!1;Ia&&(Ia?(rm="oninput"in document,rm||(Ox=document.createElement("div"),Ox.setAttribute("oninput","return;"),rm=typeof Ox.oninput=="function"),am=rm):am=!1,pw=am&&(!document.documentMode||9<document.documentMode));var am,rm,Ox;function Mk(){Fu&&(Fu.detachEvent("onpropertychange",hw),Ju=Fu=null)}function hw(e){if(e.propertyName==="value"&&c0(Ju)){var t=[];fw(t,Ju,e,rb(e)),iw(sB,t)}}function iB(e,t,n){e==="focusin"?(Mk(),Fu=t,Ju=n,Fu.attachEvent("onpropertychange",hw)):e==="focusout"&&Mk()}function lB(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return c0(Ju)}function cB(e,t){if(e==="click")return c0(t)}function uB(e,t){if(e==="input"||e==="change")return c0(t)}function dB(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Tn=typeof Object.is=="function"?Object.is:dB;function ed(e,t){if(Tn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(o=0;o<n.length;o++){var a=n[o];if(!u1.call(t,a)||!Tn(e[a],t[a]))return!1}return!0}function Rk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ok(e,t){var n=Rk(e);e=0;for(var o;n;){if(n.nodeType===3){if(o=e+n.textContent.length,e<=t&&o>=t)return{node:n,offset:t-e};e=o}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Rk(n)}}function mw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yw(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Pm(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pm(e.document)}return t}function cb(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var fB=Ia&&"documentMode"in document&&11>=document.documentMode,vl=null,g1=null,Hu=null,x1=!1;function Dk(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;x1||vl==null||vl!==Pm(o)||(o=vl,"selectionStart"in o&&cb(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Hu&&ed(Hu,o)||(Hu=o,o=Jm(g1,"onSelect"),0<o.length&&(t=new i0("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=vl)))}function Cs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Sl={animationend:Cs("Animation","AnimationEnd"),animationiteration:Cs("Animation","AnimationIteration"),animationstart:Cs("Animation","AnimationStart"),transitionrun:Cs("Transition","TransitionRun"),transitionstart:Cs("Transition","TransitionStart"),transitioncancel:Cs("Transition","TransitionCancel"),transitionend:Cs("Transition","TransitionEnd")},Dx={},gw={};Ia&&(gw=document.createElement("div").style,"AnimationEvent"in window||(delete Sl.animationend.animation,delete Sl.animationiteration.animation,delete Sl.animationstart.animation),"TransitionEvent"in window||delete Sl.transitionend.transition);function js(e){if(Dx[e])return Dx[e];if(!Sl[e])return e;var t=Sl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in gw)return Dx[e]=t[n];return e}var xw=js("animationend"),bw=js("animationiteration"),Aw=js("animationstart"),pB=js("transitionrun"),hB=js("transitionstart"),mB=js("transitioncancel"),vw=js("transitionend"),Sw=new Map,b1="abort auxClick beforeToggle 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(" ");b1.push("scrollEnd");function bo(e,t){Sw.set(e,t),qs(t,[e])}var Bm=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Wn=[],Ll=0,ub=0;function u0(){for(var e=Ll,t=ub=Ll=0;t<e;){var n=Wn[t];Wn[t++]=null;var o=Wn[t];Wn[t++]=null;var a=Wn[t];Wn[t++]=null;var r=Wn[t];if(Wn[t++]=null,o!==null&&a!==null){var s=o.pending;s===null?a.next=a:(a.next=s.next,s.next=a),o.pending=a}r!==0&&Lw(n,a,r)}}function d0(e,t,n,o){Wn[Ll++]=e,Wn[Ll++]=t,Wn[Ll++]=n,Wn[Ll++]=o,ub|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function db(e,t,n,o){return d0(e,t,n,o),Nm(e)}function Zs(e,t){return d0(e,null,null,t),Nm(e)}function Lw(e,t,n){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n);for(var a=!1,r=e.return;r!==null;)r.childLanes|=n,o=r.alternate,o!==null&&(o.childLanes|=n),r.tag===22&&(e=r.stateNode,e===null||e._visibility&1||(a=!0)),e=r,r=r.return;return e.tag===3?(r=e.stateNode,a&&t!==null&&(a=31-_n(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function Nm(e){if(50<Yu)throw Yu=0,H1=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var kl={};function yB(e,t,n,o){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,t,n,o){return new yB(e,t,n,o)}function fb(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ta(e,t){var n=e.alternate;return n===null?(n=vn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function kw(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Am(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")fb(e)&&(s=1);else if(typeof e=="string")s=bN(e,n,Uo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case s1:return e=vn(31,n,t,a),e.elementType=s1,e.lanes=r,e;case yl:return Ps(n.children,a,r,t);case W_:s=8,a|=24;break;case o1:return e=vn(12,n,t,a|2),e.elementType=o1,e.lanes=r,e;case a1:return e=vn(13,n,t,a),e.elementType=a1,e.lanes=r,e;case r1:return e=vn(19,n,t,a),e.elementType=r1,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ka:s=10;break e;case q_:s=9;break e;case Q1:s=11;break e;case J1:s=14;break e;case mr:s=16,o=null;break e}s=29,n=Error(O(130,e===null?"null":typeof e,"")),o=null}return t=vn(s,n,t,a),t.elementType=e,t.type=o,t.lanes=r,t}function Ps(e,t,n,o){return e=vn(7,e,o,t),e.lanes=n,e}function Px(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function _w(e){var t=vn(18,null,null,0);return t.stateNode=e,t}function Bx(e,t,n){return t=vn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Pk=new WeakMap;function Xn(e,t){if(typeof e=="object"&&e!==null){var n=Pk.get(e);return n!==void 0?n:(t={value:e,source:t,stack:yk(t)},Pk.set(e,t),t)}return{value:e,source:t,stack:yk(t)}}var _l=[],wl=0,zm=null,td=0,Vn=[],jn=0,Pr=null,zo=1,Fo="";function Sa(e,t){_l[wl++]=td,_l[wl++]=zm,zm=e,td=t}function ww(e,t,n){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Pr,Pr=e;var o=zo;e=Fo;var a=32-_n(o)-1;o&=~(1<<a),n+=1;var r=32-_n(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,zo=1<<32-_n(t)+a|n<<a|o,Fo=r+e}else zo=1<<r|n<<a|o,Fo=e}function pb(e){e.return!==null&&(Sa(e,1),ww(e,1,0))}function hb(e){for(;e===zm;)zm=_l[--wl],_l[wl]=null,td=_l[--wl],_l[wl]=null;for(;e===Pr;)Pr=Vn[--jn],Vn[jn]=null,Fo=Vn[--jn],Vn[jn]=null,zo=Vn[--jn],Vn[jn]=null}function Tw(e,t){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Pr,zo=t.id,Fo=t.overflow,Pr=e}var Rt=null,We=null,be=!1,Tr=null,Yn=!1,A1=Error(O(519));function Br(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw nd(Xn(t,e)),A1}function Bk(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[Mt]=e,t[an]=o,n){case"dialog":de("cancel",t),de("close",t);break;case"iframe":case"object":case"embed":de("load",t);break;case"video":case"audio":for(n=0;n<sd.length;n++)de(sd[n],t);break;case"source":de("error",t);break;case"img":case"image":case"link":de("error",t),de("load",t);break;case"details":de("toggle",t);break;case"input":de("invalid",t),ow(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":de("invalid",t);break;case"textarea":de("invalid",t),rw(t,o.value,o.defaultValue,o.children)}n=o.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||o.suppressHydrationWarning===!0||cE(t.textContent,n)?(o.popover!=null&&(de("beforetoggle",t),de("toggle",t)),o.onScroll!=null&&de("scroll",t),o.onScrollEnd!=null&&de("scrollend",t),o.onClick!=null&&(t.onclick=_a),t=!0):t=!1,t||Br(e,!0)}function Nk(e){for(Rt=e.return;Rt;)switch(Rt.tag){case 5:case 31:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:Rt=Rt.return}}function fl(e){if(e!==Rt)return!1;if(!be)return Nk(e),be=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||V1(e.type,e.memoizedProps)),n=!n),n&&We&&Br(e),Nk(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=__(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=__(e)}else t===27?(t=We,Hr(e.type)?(e=Y1,Y1=null,We=e):We=t):We=Rt?$n(e.stateNode.nextSibling):null;return!0}function Fs(){We=Rt=null,be=!1}function Nx(){var e=Tr;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),Tr=null),e}function nd(e){Tr===null?Tr=[e]:Tr.push(e)}var v1=Go(null),Xs=null,wa=null;function gr(e,t,n){Ne(v1,t._currentValue),t._currentValue=n}function Ea(e){e._currentValue=v1.current,_t(v1)}function S1(e,t,n){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===n)break;e=e.return}}function L1(e,t,n,o){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var i=r;r=a;for(var l=0;l<t.length;l++)if(i.context===t[l]){r.lanes|=n,i=r.alternate,i!==null&&(i.lanes|=n),S1(r.return,n,e),o||(s=null);break e}r=i.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(O(341));s.lanes|=n,r=s.alternate,r!==null&&(r.lanes|=n),S1(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Xl(e,t,n,o){e=null;for(var a=t,r=!1;a!==null;){if(!r){if((a.flags&524288)!==0)r=!0;else if((a.flags&262144)!==0)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(O(387));if(s=s.memoizedProps,s!==null){var i=a.type;Tn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===Mm.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(ld):e=[ld])}a=a.return}e!==null&&L1(t,e,n,o),t.flags|=262144}function Fm(e){for(e=e.firstContext;e!==null;){if(!Tn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hs(e){Xs=e,wa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ot(e){return Ew(Xs,e)}function sm(e,t){return Xs===null&&Hs(e),Ew(e,t)}function Ew(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},wa===null){if(e===null)throw Error(O(308));wa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wa=wa.next=t;return n}var gB=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},xB=mt.unstable_scheduleCallback,bB=mt.unstable_NormalPriority,it={$$typeof:ka,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mb(){return{controller:new gB,data:new Map,refCount:0}}function gd(e){e.refCount--,e.refCount===0&&xB(bB,function(){e.controller.abort()})}var Uu=null,k1=0,zl=0,Ml=null;function AB(e,t){if(Uu===null){var n=Uu=[];k1=0,zl=Hb(),Ml={status:"pending",value:void 0,then:function(o){n.push(o)}}}return k1++,t.then(zk,zk),t}function zk(){if(--k1===0&&Uu!==null){Ml!==null&&(Ml.status="fulfilled");var e=Uu;Uu=null,zl=0,Ml=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function vB(e,t){var n=[],o={status:"pending",value:null,reason:null,then:function(a){n.push(a)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var a=0;a<n.length;a++)(0,n[a])(t)},function(a){for(o.status="rejected",o.reason=a,a=0;a<n.length;a++)(0,n[a])(void 0)}),o}var Fk=K.S;K.S=function(e,t){GT=Ln(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&AB(e,t),Fk!==null&&Fk(e,t)};var Bs=Go(null);function yb(){var e=Bs.current;return e!==null?e:De.pooledCache}function vm(e,t){t===null?Ne(Bs,Bs.current):Ne(Bs,t.pool)}function Cw(){var e=yb();return e===null?null:{parent:it._currentValue,pool:e}}var Yl=Error(O(460)),gb=Error(O(474)),f0=Error(O(542)),Hm={then:function(){}};function Hk(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Iw(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(_a,_a),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Gk(e),e;default:if(typeof t.status=="string")t.then(_a,_a);else{if(e=De,e!==null&&100<e.shellSuspendCounter)throw Error(O(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var a=t;a.status="fulfilled",a.value=o}},function(o){if(t.status==="pending"){var a=t;a.status="rejected",a.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Gk(e),e}throw Ns=t,Yl}}function Rs(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Ns=n,Yl):n}}var Ns=null;function Uk(){if(Ns===null)throw Error(O(459));var e=Ns;return Ns=null,e}function Gk(e){if(e===Yl||e===f0)throw Error(O(483))}var Rl=null,od=0;function im(e){var t=od;return od+=1,Rl===null&&(Rl=[]),Iw(Rl,e,t)}function Eu(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function lm(e,t){throw t.$$typeof===i7?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Mw(e){function t(y,g){if(e){var b=y.deletions;b===null?(y.deletions=[g],y.flags|=16):b.push(g)}}function n(y,g){if(!e)return null;for(;g!==null;)t(y,g),g=g.sibling;return null}function o(y){for(var g=new Map;y!==null;)y.key!==null?g.set(y.key,y):g.set(y.index,y),y=y.sibling;return g}function a(y,g){return y=Ta(y,g),y.index=0,y.sibling=null,y}function r(y,g,b){return y.index=b,e?(b=y.alternate,b!==null?(b=b.index,b<g?(y.flags|=67108866,g):b):(y.flags|=67108866,g)):(y.flags|=1048576,g)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function i(y,g,b,A){return g===null||g.tag!==6?(g=Px(b,y.mode,A),g.return=y,g):(g=a(g,b),g.return=y,g)}function l(y,g,b,A){var _=b.type;return _===yl?u(y,g,b.props.children,A,b.key):g!==null&&(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===mr&&Rs(_)===g.type)?(g=a(g,b.props),Eu(g,b),g.return=y,g):(g=Am(b.type,b.key,b.props,null,y.mode,A),Eu(g,b),g.return=y,g)}function c(y,g,b,A){return g===null||g.tag!==4||g.stateNode.containerInfo!==b.containerInfo||g.stateNode.implementation!==b.implementation?(g=Bx(b,y.mode,A),g.return=y,g):(g=a(g,b.children||[]),g.return=y,g)}function u(y,g,b,A,_){return g===null||g.tag!==7?(g=Ps(b,y.mode,A,_),g.return=y,g):(g=a(g,b),g.return=y,g)}function d(y,g,b){if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return g=Px(""+g,y.mode,b),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Qh:return b=Am(g.type,g.key,g.props,null,y.mode,b),Eu(b,g),b.return=y,b;case Ou:return g=Bx(g,y.mode,b),g.return=y,g;case mr:return g=Rs(g),d(y,g,b)}if(Du(g)||wu(g))return g=Ps(g,y.mode,b,null),g.return=y,g;if(typeof g.then=="function")return d(y,im(g),b);if(g.$$typeof===ka)return d(y,sm(y,g),b);lm(y,g)}return null}function f(y,g,b,A){var _=g!==null?g.key:null;if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return _!==null?null:i(y,g,""+b,A);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Qh:return b.key===_?l(y,g,b,A):null;case Ou:return b.key===_?c(y,g,b,A):null;case mr:return b=Rs(b),f(y,g,b,A)}if(Du(b)||wu(b))return _!==null?null:u(y,g,b,A,null);if(typeof b.then=="function")return f(y,g,im(b),A);if(b.$$typeof===ka)return f(y,g,sm(y,b),A);lm(y,b)}return null}function p(y,g,b,A,_){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return y=y.get(b)||null,i(g,y,""+A,_);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Qh:return y=y.get(A.key===null?b:A.key)||null,l(g,y,A,_);case Ou:return y=y.get(A.key===null?b:A.key)||null,c(g,y,A,_);case mr:return A=Rs(A),p(y,g,b,A,_)}if(Du(A)||wu(A))return y=y.get(b)||null,u(g,y,A,_,null);if(typeof A.then=="function")return p(y,g,b,im(A),_);if(A.$$typeof===ka)return p(y,g,b,sm(g,A),_);lm(g,A)}return null}function h(y,g,b,A){for(var _=null,C=null,w=g,L=g=0,k=null;w!==null&&L<b.length;L++){w.index>L?(k=w,w=null):k=w.sibling;var M=f(y,w,b[L],A);if(M===null){w===null&&(w=k);break}e&&w&&M.alternate===null&&t(y,w),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M,w=k}if(L===b.length)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;L<b.length;L++)w=d(y,b[L],A),w!==null&&(g=r(w,g,L),C===null?_=w:C.sibling=w,C=w);return be&&Sa(y,L),_}for(w=o(w);L<b.length;L++)k=p(w,y,L,b[L],A),k!==null&&(e&&k.alternate!==null&&w.delete(k.key===null?L:k.key),g=r(k,g,L),C===null?_=k:C.sibling=k,C=k);return e&&w.forEach(function(B){return t(y,B)}),be&&Sa(y,L),_}function m(y,g,b,A){if(b==null)throw Error(O(151));for(var _=null,C=null,w=g,L=g=0,k=null,M=b.next();w!==null&&!M.done;L++,M=b.next()){w.index>L?(k=w,w=null):k=w.sibling;var B=f(y,w,M.value,A);if(B===null){w===null&&(w=k);break}e&&w&&B.alternate===null&&t(y,w),g=r(B,g,L),C===null?_=B:C.sibling=B,C=B,w=k}if(M.done)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;!M.done;L++,M=b.next())M=d(y,M.value,A),M!==null&&(g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return be&&Sa(y,L),_}for(w=o(w);!M.done;L++,M=b.next())M=p(w,y,L,M.value,A),M!==null&&(e&&M.alternate!==null&&w.delete(M.key===null?L:M.key),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return e&&w.forEach(function(G){return t(y,G)}),be&&Sa(y,L),_}function x(y,g,b,A){if(typeof b=="object"&&b!==null&&b.type===yl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Qh:e:{for(var _=b.key;g!==null;){if(g.key===_){if(_=b.type,_===yl){if(g.tag===7){n(y,g.sibling),A=a(g,b.props.children),A.return=y,y=A;break e}}else if(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===mr&&Rs(_)===g.type){n(y,g.sibling),A=a(g,b.props),Eu(A,b),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}b.type===yl?(A=Ps(b.props.children,y.mode,A,b.key),A.return=y,y=A):(A=Am(b.type,b.key,b.props,null,y.mode,A),Eu(A,b),A.return=y,y=A)}return s(y);case Ou:e:{for(_=b.key;g!==null;){if(g.key===_)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){n(y,g.sibling),A=a(g,b.children||[]),A.return=y,y=A;break e}else{n(y,g);break}else t(y,g);g=g.sibling}A=Bx(b,y.mode,A),A.return=y,y=A}return s(y);case mr:return b=Rs(b),x(y,g,b,A)}if(Du(b))return h(y,g,b,A);if(wu(b)){if(_=wu(b),typeof _!="function")throw Error(O(150));return b=_.call(b),m(y,g,b,A)}if(typeof b.then=="function")return x(y,g,im(b),A);if(b.$$typeof===ka)return x(y,g,sm(y,b),A);lm(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,g!==null&&g.tag===6?(n(y,g.sibling),A=a(g,b),A.return=y,y=A):(n(y,g),A=Px(b,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,b,A){try{od=0;var _=x(y,g,b,A);return Rl=null,_}catch(w){if(w===Yl||w===f0)throw w;var C=vn(29,w,null,y.mode);return C.lanes=A,C.return=y,C}finally{}}}var Us=Mw(!0),Rw=Mw(!1),yr=!1;function xb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _1(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Er(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Cr(e,t,n){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ke&2)!==0){var a=o.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),o.pending=t,t=Nm(e),Lw(e,null,n),t}return d0(e,o,t,n),Nm(e)}function Gu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,K_(e,n)}}function zx(e,t){var n=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,n===o)){var a=null,r=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,n=n.next}while(n!==null);r===null?a=r=t:r=r.next=t}else a=r=t;n={baseState:o.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:o.shared,callbacks:o.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var w1=!1;function Wu(){if(w1){var e=Ml;if(e!==null)throw e}}function qu(e,t,n,o){w1=!1;var a=e.updateQueue;yr=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var l=i,c=l.next;l.next=null,s===null?r=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,i=u.lastBaseUpdate,i!==s&&(i===null?u.firstBaseUpdate=c:i.next=c,u.lastBaseUpdate=l))}if(r!==null){var d=a.baseState;s=0,u=c=l=null,i=r;do{var f=i.lane&-536870913,p=f!==i.lane;if(p?(me&f)===f:(o&f)===f){f!==0&&f===zl&&(w1=!0),u!==null&&(u=u.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var h=e,m=i;f=t;var x=n;switch(m.tag){case 1:if(h=m.payload,typeof h=="function"){d=h.call(x,d,f);break e}d=h;break e;case 3:h.flags=h.flags&-65537|128;case 0:if(h=m.payload,f=typeof h=="function"?h.call(x,d,f):h,f==null)break e;d=qe({},d,f);break e;case 2:yr=!0}}f=i.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=a.callbacks,p===null?a.callbacks=[f]:p.push(f))}else p={lane:f,tag:i.tag,payload:i.payload,callback:i.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,s|=f;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;p=i,i=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);u===null&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,r===null&&(a.shared.lanes=0),zr|=s,e.lanes=s,e.memoizedState=d}}function Ow(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function Dw(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ow(n[e],t)}var Fl=Go(null),Um=Go(0);function Wk(e,t){e=Da,Ne(Um,e),Ne(Fl,t),Da=e|t.baseLanes}function T1(){Ne(Um,Da),Ne(Fl,Fl.current)}function bb(){Da=Um.current,_t(Fl),_t(Um)}var En=Go(null),Kn=null;function xr(e){var t=e.alternate;Ne(tt,tt.current&1),Ne(En,e),Kn===null&&(t===null||Fl.current!==null||t.memoizedState!==null)&&(Kn=e)}function E1(e){Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)}function Pw(e){e.tag===22?(Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)):br(e)}function br(){Ne(tt,tt.current),Ne(En,En.current)}function An(e){_t(En),Kn===e&&(Kn=null),_t(tt)}var tt=Go(0);function Gm(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Z1(n)||X1(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(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 null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ma=0,oe=null,Me=null,rt=null,Wm=!1,Ol=!1,Gs=!1,qm=0,ad=0,Dl=null,SB=0;function Qe(){throw Error(O(321))}function Ab(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Tn(e[n],t[n]))return!1;return!0}function vb(e,t,n,o,a,r){return Ma=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?fT:Rb,Gs=!1,r=n(o,a),Gs=!1,Ol&&(r=Nw(t,n,o,a)),Bw(e),r}function Bw(e){K.H=rd;var t=Me!==null&&Me.next!==null;if(Ma=0,rt=Me=oe=null,Wm=!1,ad=0,Dl=null,t)throw Error(O(300));e===null||lt||(e=e.dependencies,e!==null&&Fm(e)&&(lt=!0))}function Nw(e,t,n,o){oe=e;var a=0;do{if(Ol&&(Dl=null),ad=0,Ol=!1,25<=a)throw Error(O(301));if(a+=1,rt=Me=null,e.updateQueue!=null){var r=e.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}K.H=pT,r=t(n,o)}while(Ol);return r}function LB(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?xd(t):t,e=e.useState()[0],(Me!==null?Me.memoizedState:null)!==e&&(oe.flags|=1024),t}function Sb(){var e=qm!==0;return qm=0,e}function Lb(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function kb(e){if(Wm){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wm=!1}Ma=0,rt=Me=oe=null,Ol=!1,ad=qm=0,Dl=null}function Zt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rt===null?oe.memoizedState=rt=e:rt=rt.next=e,rt}function nt(){if(Me===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=rt===null?oe.memoizedState:rt.next;if(t!==null)rt=t,Me=e;else{if(e===null)throw oe.alternate===null?Error(O(467)):Error(O(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},rt===null?oe.memoizedState=rt=e:rt=rt.next=e}return rt}function p0(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function xd(e){var t=ad;return ad+=1,Dl===null&&(Dl=[]),e=Iw(Dl,e,t),t=oe,(rt===null?t.memoizedState:rt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?fT:Rb),e}function h0(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return xd(e);if(e.$$typeof===ka)return Ot(e)}throw Error(O(438,String(e)))}function _b(e){var t=null,n=oe.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var o=oe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(a){return a.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=p0(),oe.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),o=0;o<e;o++)n[o]=l7;return t.index++,n}function Ra(e,t){return typeof t=="function"?t(e):t}function Sm(e){var t=nt();return wb(t,Me,e)}function wb(e,t,n){var o=e.queue;if(o===null)throw Error(O(311));o.lastRenderedReducer=n;var a=e.baseQueue,r=o.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}t.baseQueue=a=r,o.pending=null}if(r=e.baseState,a===null)e.memoizedState=r;else{t=a.next;var i=s=null,l=null,c=t,u=!1;do{var d=c.lane&-536870913;if(d!==c.lane?(me&d)===d:(Ma&d)===d){var f=c.revertLane;if(f===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),d===zl&&(u=!0);else if((Ma&f)===f){c=c.next,f===zl&&(u=!0);continue}else d={lane:0,revertLane:c.revertLane,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=d,s=r):l=l.next=d,oe.lanes|=f,zr|=f;d=c.action,Gs&&n(r,d),r=c.hasEagerState?c.eagerState:n(r,d)}else f={lane:d,revertLane:c.revertLane,gesture:c.gesture,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=f,s=r):l=l.next=f,oe.lanes|=d,zr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!Tn(r,e.memoizedState)&&(lt=!0,u&&(n=Ml,n!==null)))throw n;e.memoizedState=r,e.baseState=s,e.baseQueue=l,o.lastRenderedState=r}return a===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Fx(e){var t=nt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var o=n.dispatch,a=n.pending,r=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do r=e(r,s.action),s=s.next;while(s!==a);Tn(r,t.memoizedState)||(lt=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function zw(e,t,n){var o=oe,a=nt(),r=be;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!Tn((Me||a).memoizedState,n);if(s&&(a.memoizedState=n,lt=!0),a=a.queue,Tb(Uw.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||rt!==null&&rt.memoizedState.tag&1){if(o.flags|=2048,Hl(9,{destroy:void 0},Hw.bind(null,o,a,n,t),null),De===null)throw Error(O(349));r||(Ma&127)!==0||Fw(o,t,n)}return n}function Fw(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=p0(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Hw(e,t,n,o){t.value=n,t.getSnapshot=o,Gw(t)&&Ww(e)}function Uw(e,t,n){return n(function(){Gw(t)&&Ww(e)})}function Gw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Tn(e,n)}catch{return!0}}function Ww(e){var t=Zs(e,2);t!==null&&on(t,e,2)}function C1(e){var t=Zt();if(typeof e=="function"){var n=e;if(e=n(),Gs){vr(!0);try{n()}finally{vr(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:e},t}function qw(e,t,n,o){return e.baseState=n,wb(e,Me,typeof o=="function"?o:Ra)}function kB(e,t,n,o,a){if(y0(e))throw Error(O(485));if(e=t.action,e!==null){var r={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};K.T!==null?n(!0):r.isTransition=!1,o(r),n=t.pending,n===null?(r.next=t.pending=r,Vw(t,r)):(r.next=n.next,t.pending=n.next=r)}}function Vw(e,t){var n=t.action,o=t.payload,a=e.state;if(t.isTransition){var r=K.T,s={};K.T=s;try{var i=n(a,o),l=K.S;l!==null&&l(s,i),qk(e,t,i)}catch(c){I1(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),qk(e,t,r)}catch(c){I1(e,t,c)}}function qk(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){Vk(e,t,o)},function(o){return I1(e,t,o)}):Vk(e,t,n)}function Vk(e,t,n){t.status="fulfilled",t.value=n,jw(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Vw(e,n)))}function I1(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,jw(t),t=t.next;while(t!==o)}e.action=null}function jw(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zw(e,t){return t}function jk(e,t){if(be){var n=De.formState;if(n!==null){e:{var o=oe;if(be){if(We){t:{for(var a=We,r=Yn;a.nodeType!==8;){if(!r){a=null;break t}if(a=$n(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){We=$n(a.nextSibling),o=a.data==="F!";break e}}Br(o)}o=!1}o&&(t=n[0])}}return n=Zt(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zw,lastRenderedState:t},n.queue=o,n=cT.bind(null,oe,o),o.dispatch=n,o=C1(!1),r=Mb.bind(null,oe,!1,o.queue),o=Zt(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=kB.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function Zk(e){var t=nt();return Xw(t,Me,e)}function Xw(e,t,n){if(t=wb(e,t,Zw)[0],e=Sm(Ra)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=xd(t)}catch(s){throw s===Yl?f0:s}else o=t;t=nt();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,Hl(9,{destroy:void 0},_B.bind(null,a,n),null)),[o,r,e]}function _B(e,t){e.action=t}function Xk(e){var t=nt(),n=Me;if(n!==null)return Xw(t,n,e);nt(),t=t.memoizedState,n=nt();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function Hl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=p0(),oe.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(o=n.next,n.next=e,e.next=o,t.lastEffect=e),e}function Yw(){return nt().memoizedState}function Lm(e,t,n,o){var a=Zt();oe.flags|=e,a.memoizedState=Hl(1|t,{destroy:void 0},n,o===void 0?null:o)}function m0(e,t,n,o){var a=nt();o=o===void 0?null:o;var r=a.memoizedState.inst;Me!==null&&o!==null&&Ab(o,Me.memoizedState.deps)?a.memoizedState=Hl(t,r,n,o):(oe.flags|=e,a.memoizedState=Hl(1|t,r,n,o))}function Yk(e,t){Lm(8390656,8,e,t)}function Tb(e,t){m0(2048,8,e,t)}function wB(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=p0(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Kw(e){var t=nt().memoizedState;return wB({ref:t,nextImpl:e}),function(){if((ke&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function $w(e,t){return m0(4,2,e,t)}function Qw(e,t){return m0(4,4,e,t)}function Jw(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function eT(e,t,n){n=n!=null?n.concat([e]):null,m0(4,4,Jw.bind(null,t,e),n)}function Eb(){}function tT(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&Ab(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function nT(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&Ab(t,o[1]))return o[0];if(o=e(),Gs){vr(!0);try{e()}finally{vr(!1)}}return n.memoizedState=[o,t],o}function Cb(e,t,n){return n===void 0||(Ma&1073741824)!==0&&(me&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=qT(),oe.lanes|=e,zr|=e,n)}function oT(e,t,n,o){return Tn(n,t)?n:Fl.current!==null?(e=Cb(e,n,o),Tn(e,t)||(lt=!0),e):(Ma&42)===0||(Ma&1073741824)!==0&&(me&261930)===0?(lt=!0,e.memoizedState=n):(e=qT(),oe.lanes|=e,zr|=e,t)}function aT(e,t,n,o,a){var r=_e.p;_e.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,Mb(e,!1,t,n);try{var l=a(),c=K.S;if(c!==null&&c(i,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=vB(l,o);Vu(e,t,u,wn(e))}else Vu(e,t,o,wn(e))}catch(d){Vu(e,t,{then:function(){},status:"rejected",reason:d},wn())}finally{_e.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function TB(){}function M1(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=rT(e).queue;aT(e,a,t,Ds,n===null?TB:function(){return sT(e),n(o)})}function rT(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Ds,baseState:Ds,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:Ds},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function sT(e){var t=rT(e);t.next===null&&(t=e.alternate.memoizedState),Vu(e,t.next.queue,{},wn())}function Ib(){return Ot(ld)}function iT(){return nt().memoizedState}function lT(){return nt().memoizedState}function EB(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=wn();e=Er(n);var o=Cr(t,e,n);o!==null&&(on(o,t,n),Gu(o,t,n)),t={cache:mb()},e.payload=t;return}t=t.return}}function CB(e,t,n){var o=wn();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},y0(e)?uT(t,n):(n=db(e,t,n,o),n!==null&&(on(n,e,o),dT(n,t,o)))}function cT(e,t,n){var o=wn();Vu(e,t,n,o)}function Vu(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(y0(e))uT(t,a);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=t.lastRenderedReducer,r!==null))try{var s=t.lastRenderedState,i=r(s,n);if(a.hasEagerState=!0,a.eagerState=i,Tn(i,s))return d0(e,t,a,0),De===null&&u0(),!1}catch{}finally{}if(n=db(e,t,a,o),n!==null)return on(n,e,o),dT(n,t,o),!0}return!1}function Mb(e,t,n,o){if(o={lane:2,revertLane:Hb(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},y0(e)){if(t)throw Error(O(479))}else t=db(e,n,o,2),t!==null&&on(t,e,2)}function y0(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function uT(e,t){Ol=Wm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function dT(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,K_(e,n)}}var rd={readContext:Ot,use:h0,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useLayoutEffect:Qe,useInsertionEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useSyncExternalStore:Qe,useId:Qe,useHostTransitionStatus:Qe,useFormState:Qe,useActionState:Qe,useOptimistic:Qe,useMemoCache:Qe,useCacheRefresh:Qe};rd.useEffectEvent=Qe;var fT={readContext:Ot,use:h0,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Ot,useEffect:Yk,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,Lm(4194308,4,Jw.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Lm(4194308,4,e,t)},useInsertionEffect:function(e,t){Lm(4,2,e,t)},useMemo:function(e,t){var n=Zt();t=t===void 0?null:t;var o=e();if(Gs){vr(!0);try{e()}finally{vr(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Zt();if(n!==void 0){var a=n(t);if(Gs){vr(!0);try{n(t)}finally{vr(!1)}}}else a=t;return o.memoizedState=o.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},o.queue=e,e=e.dispatch=CB.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:function(e){e=C1(e);var t=e.queue,n=cT.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Eb,useDeferredValue:function(e,t){var n=Zt();return Cb(n,e,t)},useTransition:function(){var e=C1(!1);return e=aT.bind(null,oe,e.queue,!0,!1),Zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Zt();if(be){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),De===null)throw Error(O(349));(me&127)!==0||Fw(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,Yk(Uw.bind(null,o,r,e),[e]),o.flags|=2048,Hl(9,{destroy:void 0},Hw.bind(null,o,r,n,t),null),n},useId:function(){var e=Zt(),t=De.identifierPrefix;if(be){var n=Fo,o=zo;n=(o&~(1<<32-_n(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=qm++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=SB++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Ib,useFormState:jk,useActionState:jk,useOptimistic:function(e){var t=Zt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Mb.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:_b,useCacheRefresh:function(){return Zt().memoizedState=EB.bind(null,oe)},useEffectEvent:function(e){var t=Zt(),n={impl:e};return t.memoizedState=n,function(){if((ke&2)!==0)throw Error(O(440));return n.impl.apply(void 0,arguments)}}},Rb={readContext:Ot,use:h0,useCallback:tT,useContext:Ot,useEffect:Tb,useImperativeHandle:eT,useInsertionEffect:$w,useLayoutEffect:Qw,useMemo:nT,useReducer:Sm,useRef:Yw,useState:function(){return Sm(Ra)},useDebugValue:Eb,useDeferredValue:function(e,t){var n=nt();return oT(n,Me.memoizedState,e,t)},useTransition:function(){var e=Sm(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:xd(e),t]},useSyncExternalStore:zw,useId:iT,useHostTransitionStatus:Ib,useFormState:Zk,useActionState:Zk,useOptimistic:function(e,t){var n=nt();return qw(n,Me,e,t)},useMemoCache:_b,useCacheRefresh:lT};Rb.useEffectEvent=Kw;var pT={readContext:Ot,use:h0,useCallback:tT,useContext:Ot,useEffect:Tb,useImperativeHandle:eT,useInsertionEffect:$w,useLayoutEffect:Qw,useMemo:nT,useReducer:Fx,useRef:Yw,useState:function(){return Fx(Ra)},useDebugValue:Eb,useDeferredValue:function(e,t){var n=nt();return Me===null?Cb(n,e,t):oT(n,Me.memoizedState,e,t)},useTransition:function(){var e=Fx(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:xd(e),t]},useSyncExternalStore:zw,useId:iT,useHostTransitionStatus:Ib,useFormState:Xk,useActionState:Xk,useOptimistic:function(e,t){var n=nt();return Me!==null?qw(n,Me,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:_b,useCacheRefresh:lT};pT.useEffectEvent=Kw;function Hx(e,t,n,o){t=e.memoizedState,n=n(o,t),n=n==null?t:qe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var R1={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Er(o);a.payload=t,n!=null&&(a.callback=n),t=Cr(e,a,o),t!==null&&(on(t,e,o),Gu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Er(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Cr(e,a,o),t!==null&&(on(t,e,o),Gu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=wn(),o=Er(n);o.tag=2,t!=null&&(o.callback=t),t=Cr(e,o,n),t!==null&&(on(t,e,n),Gu(t,e,n))}};function Kk(e,t,n,o,a,r,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,r,s):t.prototype&&t.prototype.isPureReactComponent?!ed(n,o)||!ed(a,r):!0}function $k(e,t,n,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,o),t.state!==e&&R1.enqueueReplaceState(t,t.state,null)}function Ws(e,t){var n=t;if("ref"in t){n={};for(var o in t)o!=="ref"&&(n[o]=t[o])}if(e=e.defaultProps){n===t&&(n=qe({},n));for(var a in e)n[a]===void 0&&(n[a]=e[a])}return n}function hT(e){Bm(e)}function mT(e){console.error(e)}function yT(e){Bm(e)}function Vm(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Qk(e,t,n){try{var o=e.onCaughtError;o(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function O1(e,t,n){return n=Er(n),n.tag=3,n.payload={element:null},n.callback=function(){Vm(e,t)},n}function gT(e){return e=Er(e),e.tag=3,e}function xT(e,t,n,o){var a=n.type.getDerivedStateFromError;if(typeof a=="function"){var r=o.value;e.payload=function(){return a(r)},e.callback=function(){Qk(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){Qk(t,n,o),typeof a!="function"&&(Ir===null?Ir=new Set([this]):Ir.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function IB(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&Xl(t,n,a,!0),n=En.current,n!==null){switch(n.tag){case 31:case 13:return Kn===null?Km():n.alternate===null&&Je===0&&(Je=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Hm?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),$x(e,o,a)),!1;case 22:return n.flags|=65536,o===Hm?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([o]):n.add(o)),$x(e,o,a)),!1}throw Error(O(435,n.tag))}return $x(e,o,a),Km(),!1}if(be)return t=En.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==A1&&(e=Error(O(422),{cause:o}),nd(Xn(e,n)))):(o!==A1&&(t=Error(O(423),{cause:o}),nd(Xn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Xn(o,n),a=O1(e.stateNode,o,a),zx(e,a),Je!==4&&(Je=2)),!1;var r=Error(O(520),{cause:o});if(r=Xn(r,n),Xu===null?Xu=[r]:Xu.push(r),Je!==4&&(Je=2),t===null)return!0;o=Xn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=O1(n.stateNode,o,e),zx(n,e),!1;case 1:if(t=n.type,r=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(Ir===null||!Ir.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=gT(a),xT(a,e,n,o),zx(n,a),!1}n=n.return}while(n!==null);return!1}var Ob=Error(O(461)),lt=!1;function It(e,t,n,o){t.child=e===null?Rw(t,null,n,o):Us(t,e.child,n,o)}function Jk(e,t,n,o,a){n=n.render;var r=t.ref;if("ref"in o){var s={};for(var i in o)i!=="ref"&&(s[i]=o[i])}else s=o;return Hs(t),o=vb(e,t,n,s,r,a),i=Sb(),e!==null&&!lt?(Lb(e,t,a),Oa(e,t,a)):(be&&i&&pb(t),t.flags|=1,It(e,t,o,a),t.child)}function e_(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!fb(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,bT(e,t,r,o,a)):(e=Am(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!Db(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:ed,n(s,o)&&e.ref===t.ref)return Oa(e,t,a)}return t.flags|=1,e=Ta(r,o),e.ref=t.ref,e.return=t,t.child=e}function bT(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(ed(r,o)&&e.ref===t.ref)if(lt=!1,t.pendingProps=o=r,Db(e,a))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,Oa(e,t,a)}return D1(e,t,n,o,a)}function AT(e,t,n,o){var a=o.children,r=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(r=r!==null?r.baseLanes|n:n,e!==null){for(o=t.child=e.child,a=0;o!==null;)a=a|o.lanes|o.childLanes,o=o.sibling;o=a&~r}else o=0,t.child=null;return t_(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&vm(t,r!==null?r.cachePool:null),r!==null?Wk(t,r):T1(),Pw(t);else return o=t.lanes=536870912,t_(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(vm(t,r.cachePool),Wk(t,r),br(t),t.memoizedState=null):(e!==null&&vm(t,null),T1(),br(t));return It(e,t,a,n),t.child}function Bu(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function t_(e,t,n,o,a){var r=yb();return r=r===null?null:{parent:it._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&vm(t,null),T1(),Pw(t),e!==null&&Xl(e,t,o,!0),t.childLanes=a,null}function km(e,t){return t=jm({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function n_(e,t,n){return Us(t,e.child,null,n),e=km(t,t.pendingProps),e.flags|=2,An(t),t.memoizedState=null,e}function MB(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(be){if(o.mode==="hidden")return e=km(t,o),t.lanes=536870912,Bu(null,e);if(E1(t),(e=We)?(e=fE(e,Yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Pr!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=_w(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Br(t);return t.lanes=536870912,null}return km(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(E1(t),a)if(t.flags&256)t.flags&=-257,t=n_(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(O(558));else if(lt||Xl(e,t,n,!1),a=(n&e.childLanes)!==0,lt||a){if(o=De,o!==null&&(s=$_(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Zs(e,s),on(o,e,s),Ob;Km(),t=n_(e,t,n)}else e=r.treeContext,We=$n(s.nextSibling),Rt=t,be=!0,Tr=null,Yn=!1,e!==null&&Tw(t,e),t=km(t,o),t.flags|=4096;return t}return e=Ta(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function _m(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(O(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function D1(e,t,n,o,a){return Hs(t),n=vb(e,t,n,o,void 0,a),o=Sb(),e!==null&&!lt?(Lb(e,t,a),Oa(e,t,a)):(be&&o&&pb(t),t.flags|=1,It(e,t,n,a),t.child)}function o_(e,t,n,o,a,r){return Hs(t),t.updateQueue=null,n=Nw(t,o,n,a),Bw(e),o=Sb(),e!==null&&!lt?(Lb(e,t,r),Oa(e,t,r)):(be&&o&&pb(t),t.flags|=1,It(e,t,n,r),t.child)}function a_(e,t,n,o,a){if(Hs(t),t.stateNode===null){var r=kl,s=n.contextType;typeof s=="object"&&s!==null&&(r=Ot(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=R1,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},xb(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Ot(s):kl,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Hx(t,n,s,o),r.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&R1.enqueueReplaceState(r,r.state,null),qu(t,o,r,a),Wu(),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){r=t.stateNode;var i=t.memoizedProps,l=Ws(n,i);r.props=l;var c=r.context,u=n.contextType;s=kl,typeof u=="object"&&u!==null&&(s=Ot(u));var d=n.getDerivedStateFromProps;u=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",i=t.pendingProps!==i,u||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(i||c!==s)&&$k(t,r,o,s),yr=!1;var f=t.memoizedState;r.state=f,qu(t,o,r,a),Wu(),c=t.memoizedState,i||f!==c||yr?(typeof d=="function"&&(Hx(t,n,d,o),c=t.memoizedState),(l=yr||Kk(t,n,l,o,f,c,s))?(u||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(t.flags|=4194308)):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=c),r.props=o,r.state=c,r.context=s,o=l):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{r=t.stateNode,_1(e,t),s=t.memoizedProps,u=Ws(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=kl,typeof c=="object"&&c!==null&&(l=Ot(c)),i=n.getDerivedStateFromProps,(c=typeof i=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||f!==l)&&$k(t,r,o,l),yr=!1,f=t.memoizedState,r.state=f,qu(t,o,r,a),Wu();var p=t.memoizedState;s!==d||f!==p||yr||e!==null&&e.dependencies!==null&&Fm(e.dependencies)?(typeof i=="function"&&(Hx(t,n,i,o),p=t.memoizedState),(u=yr||Kk(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&Fm(e.dependencies))?(c||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(o,p,l),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(o,p,l)),typeof r.componentDidUpdate=="function"&&(t.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=p),r.props=o,r.state=p,r.context=l,o=u):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),o=!1)}return r=o,_m(e,t),o=(t.flags&128)!==0,r||o?(r=t.stateNode,n=o&&typeof n.getDerivedStateFromError!="function"?null:r.render(),t.flags|=1,e!==null&&o?(t.child=Us(t,e.child,null,a),t.child=Us(t,null,n,a)):It(e,t,n,a),t.memoizedState=r.state,e=t.child):e=Oa(e,t,a),e}function r_(e,t,n,o){return Fs(),t.flags|=256,It(e,t,n,o),t.child}var Ux={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gx(e){return{baseLanes:e,cachePool:Cw()}}function Wx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Sn),e}function vT(e,t,n){var o=t.pendingProps,a=!1,r=(t.flags&128)!==0,s;if((s=r)||(s=e!==null&&e.memoizedState===null?!1:(tt.current&2)!==0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(be){if(a?xr(t):br(t),(e=We)?(e=fE(e,Yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Pr!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=_w(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Br(t);return X1(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?(br(t),a=t.mode,i=jm({mode:"hidden",children:i},a),o=Ps(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=Gx(n),o.childLanes=Wx(e,s,n),t.memoizedState=Ux,Bu(null,o)):(xr(t),P1(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(xr(t),t.flags&=-257,t=qx(e,t,n)):t.memoizedState!==null?(br(t),t.child=e.child,t.flags|=128,t=null):(br(t),i=o.fallback,a=t.mode,o=jm({mode:"visible",children:o.children},a),i=Ps(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,Us(t,e.child,null,n),o=t.child,o.memoizedState=Gx(n),o.childLanes=Wx(e,s,n),t.memoizedState=Ux,t=Bu(null,o));else if(xr(t),X1(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,nd({value:o,source:null,stack:null}),t=qx(e,t,n)}else if(lt||Xl(e,t,n,!1),s=(n&e.childLanes)!==0,lt||s){if(s=De,s!==null&&(o=$_(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Zs(e,o),on(s,e,o),Ob;Z1(i)||Km(),t=qx(e,t,n)}else Z1(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,We=$n(i.nextSibling),Rt=t,be=!0,Tr=null,Yn=!1,e!==null&&Tw(t,e),t=P1(t,o.children),t.flags|=4096);return t}return a?(br(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=Ta(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=Ta(c,i):(i=Ps(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Bu(null,o),o=t.child,i=e.child.memoizedState,i===null?i=Gx(n):(a=i.cachePool,a!==null?(l=it._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=Cw(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=Wx(e,s,n),t.memoizedState=Ux,Bu(e.child,o)):(xr(t),n=e.child,e=n.sibling,n=Ta(n,{mode:"visible",children:o.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function P1(e,t){return t=jm({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function jm(e,t){return e=vn(22,e,null,t),e.lanes=0,e}function qx(e,t,n){return Us(t,e.child,null,n),e=P1(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function s_(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),S1(e.return,t,n)}function Vx(e,t,n,o,a,r){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:n,tailMode:a,treeForkCount:r}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=o,s.tail=n,s.tailMode=a,s.treeForkCount=r)}function ST(e,t,n){var o=t.pendingProps,a=o.revealOrder,r=o.tail;o=o.children;var s=tt.current,i=(s&2)!==0;if(i?(s=s&1|2,t.flags|=128):s&=1,Ne(tt,s),It(e,t,o,n),o=be?td:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&s_(e,n,t);else if(e.tag===19)s_(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&Gm(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Vx(t,!1,a,n,r,o);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&Gm(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Vx(t,!0,n,null,r,o);break;case"together":Vx(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Oa(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),zr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Xl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=Ta(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ta(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Db(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Fm(e)))}function RB(e,t,n){switch(t.tag){case 3:Rm(t,t.stateNode.containerInfo),gr(t,it,e.memoizedState.cache),Fs();break;case 27:case 5:c1(t);break;case 4:Rm(t,t.stateNode.containerInfo);break;case 10:gr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,E1(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(xr(t),t.flags|=128,null):(n&t.child.childLanes)!==0?vT(e,t,n):(xr(t),e=Oa(e,t,n),e!==null?e.sibling:null);xr(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(Xl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return ST(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Ne(tt,tt.current),o)break;return null;case 22:return t.lanes=0,AT(e,t,n,t.pendingProps);case 24:gr(t,it,e.memoizedState.cache)}return Oa(e,t,n)}function LT(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!Db(e,n)&&(t.flags&128)===0)return lt=!1,RB(e,t,n);lt=(e.flags&131072)!==0}else lt=!1,be&&(t.flags&1048576)!==0&&ww(t,td,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Rs(t.elementType),t.type=e,typeof e=="function")fb(e)?(o=Ws(e,o),t.tag=1,t=a_(null,t,e,o,n)):(t.tag=0,t=D1(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===Q1){t.tag=11,t=Jk(null,t,e,o,n);break e}else if(a===J1){t.tag=14,t=e_(null,t,e,o,n);break e}}throw t=i1(e)||e,Error(O(306,t,""))}}return t;case 0:return D1(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=Ws(o,t.pendingProps),a_(e,t,o,a,n);case 3:e:{if(Rm(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,_1(e,t),qu(t,o,null,n);var s=t.memoizedState;if(o=s.cache,gr(t,it,o),o!==r.cache&&L1(t,[it],n,!0),Wu(),o=s.element,r.isDehydrated)if(r={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=r,t.memoizedState=r,t.flags&256){t=r_(e,t,o,n);break e}else if(o!==a){a=Xn(Error(O(424)),t),nd(a),t=r_(e,t,o,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(We=$n(e.firstChild),Rt=t,be=!0,Tr=null,Yn=!0,n=Rw(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Fs(),o===a){t=Oa(e,t,n);break e}It(e,t,o,n)}t=t.child}return t;case 26:return _m(e,t),e===null?(n=E_(t.type,null,t.pendingProps,null))?t.memoizedState=n:be||(n=t.type,e=t.pendingProps,o=e0(wr.current).createElement(n),o[Mt]=t,o[an]=e,Dt(o,n,e),kt(o),t.stateNode=o):t.memoizedState=E_(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return c1(t),e===null&&be&&(o=t.stateNode=pE(t.type,t.pendingProps,wr.current),Rt=t,Yn=!0,a=We,Hr(t.type)?(Y1=a,We=$n(o.firstChild)):We=a),It(e,t,t.pendingProps.children,n),_m(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&be&&((a=o=We)&&(o=sN(o,t.type,t.pendingProps,Yn),o!==null?(t.stateNode=o,Rt=t,We=$n(o.firstChild),Yn=!1,a=!0):a=!1),a||Br(t)),c1(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,V1(a,r)?o=null:s!==null&&V1(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=vb(e,t,LB,null,null,n),ld._currentValue=a),_m(e,t),It(e,t,o,n),t.child;case 6:return e===null&&be&&((e=n=We)&&(n=iN(n,t.pendingProps,Yn),n!==null?(t.stateNode=n,Rt=t,We=null,e=!0):e=!1),e||Br(t)),null;case 13:return vT(e,t,n);case 4:return Rm(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Us(t,null,o,n):It(e,t,o,n),t.child;case 11:return Jk(e,t,t.type,t.pendingProps,n);case 7:return It(e,t,t.pendingProps,n),t.child;case 8:return It(e,t,t.pendingProps.children,n),t.child;case 12:return It(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,gr(t,t.type,o.value),It(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,Hs(t),a=Ot(a),o=o(a),t.flags|=1,It(e,t,o,n),t.child;case 14:return e_(e,t,t.type,t.pendingProps,n);case 15:return bT(e,t,t.type,t.pendingProps,n);case 19:return ST(e,t,n);case 31:return MB(e,t,n);case 22:return AT(e,t,n,t.pendingProps);case 24:return Hs(t),o=Ot(it),e===null?(a=yb(),a===null&&(a=De,r=mb(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},xb(t),gr(t,it,a)):((e.lanes&n)!==0&&(_1(e,t),qu(t,null,null,n),Wu()),a=e.memoizedState,r=t.memoizedState,a.parent!==o?(a={parent:o,cache:o},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),gr(t,it,o)):(o=r.cache,gr(t,it,o),o!==a.cache&&L1(t,[it],n,!0))),It(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function xa(e){e.flags|=4}function jx(e,t,n,o,a){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(a&335544128)===a)if(e.stateNode.complete)e.flags|=8192;else if(ZT())e.flags|=8192;else throw Ns=Hm,gb}else e.flags&=-16777217}function i_(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!yE(t))if(ZT())e.flags|=8192;else throw Ns=Hm,gb}function cm(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?X_():536870912,e.lanes|=t,Ul|=t)}function Cu(e,t){if(!be)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var o=null;n!==null;)n.alternate!==null&&(o=n),n=n.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Ge(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,o=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags&65011712,o|=a.flags&65011712,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags,o|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=o,e.childLanes=n,t}function OB(e,t,n){var o=t.pendingProps;switch(hb(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return Ge(t),null;case 3:return n=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Ea(it),Pl(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(fl(t)?xa(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Nx())),Ge(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?(xa(t),r!==null?(Ge(t),i_(t,r)):(Ge(t),jx(t,a,null,o,n))):r?r!==e.memoizedState?(xa(t),Ge(t),i_(t,r)):(Ge(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&xa(t),Ge(t),jx(t,a,e,o,n)),null;case 27:if(Om(t),n=wr.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}e=Uo.current,fl(t)?Bk(t,e):(e=pE(a,o,n),t.stateNode=e,xa(t))}return Ge(t),null;case 5:if(Om(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}if(r=Uo.current,fl(t))Bk(t,r);else{var s=e0(wr.current);switch(r){case 1:r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":r=s.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild);break;case"select":r=typeof o.is=="string"?s.createElement("select",{is:o.is}):s.createElement("select"),o.multiple?r.multiple=!0:o.size&&(r.size=o.size);break;default:r=typeof o.is=="string"?s.createElement(a,{is:o.is}):s.createElement(a)}}r[Mt]=t,r[an]=o;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)r.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=r;e:switch(Dt(r,a,o),a){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&xa(t)}}return Ge(t),jx(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=wr.current,fl(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Rt,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[Mt]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||cE(e.nodeValue,n)),e||Br(t,!0)}else e=e0(e).createTextNode(o),e[Mt]=t,t.stateNode=e}return Ge(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=fl(t),n!==null){if(e===null){if(!o)throw Error(O(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(557));e[Mt]=t}else Fs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),e=!1}else n=Nx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(An(t),t):(An(t),null);if((t.flags&128)!==0)throw Error(O(558))}return Ge(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=fl(t),o!==null&&o.dehydrated!==null){if(e===null){if(!a)throw Error(O(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(O(317));a[Mt]=t}else Fs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),a=!1}else a=Nx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(An(t),t):(An(t),null)}return An(t),(t.flags&128)!==0?(t.lanes=n,t):(n=o!==null,e=e!==null&&e.memoizedState!==null,n&&(o=t.child,a=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(a=o.alternate.memoizedState.cachePool.pool),r=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(r=o.memoizedState.cachePool.pool),r!==a&&(o.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),cm(t,t.updateQueue),Ge(t),null);case 4:return Pl(),e===null&&Ub(t.stateNode.containerInfo),Ge(t),null;case 10:return Ea(t.type),Ge(t),null;case 19:if(_t(tt),o=t.memoizedState,o===null)return Ge(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)Cu(o,!1);else{if(Je!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=Gm(e),r!==null){for(t.flags|=128,Cu(o,!1),e=r.updateQueue,t.updateQueue=e,cm(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)kw(n,e),n=n.sibling;return Ne(tt,tt.current&1|2),be&&Sa(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ln()>Xm&&(t.flags|=128,a=!0,Cu(o,!1),t.lanes=4194304)}else{if(!a)if(e=Gm(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,cm(t,e),Cu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!be)return Ge(t),null}else 2*Ln()-o.renderingStartTime>Xm&&n!==536870912&&(t.flags|=128,a=!0,Cu(o,!1),t.lanes=4194304);o.isBackwards?(r.sibling=t.child,t.child=r):(e=o.last,e!==null?e.sibling=r:t.child=r,o.last=r)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ln(),e.sibling=null,n=tt.current,Ne(tt,a?n&1|2:n&1),be&&Sa(t,o.treeForkCount),e):(Ge(t),null);case 22:case 23:return An(t),bb(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(n&536870912)!==0&&(t.flags&128)===0&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),n=t.updateQueue,n!==null&&cm(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==n&&(t.flags|=2048),e!==null&&_t(Bs),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ea(it),Ge(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function DB(e,t){switch(hb(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea(it),Pl(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Om(t),null;case 31:if(t.memoizedState!==null){if(An(t),t.alternate===null)throw Error(O(340));Fs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(An(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));Fs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _t(tt),null;case 4:return Pl(),null;case 10:return Ea(t.type),null;case 22:case 23:return An(t),bb(),e!==null&&_t(Bs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea(it),null;case 25:return null;default:return null}}function kT(e,t){switch(hb(t),t.tag){case 3:Ea(it),Pl();break;case 26:case 27:case 5:Om(t);break;case 4:Pl();break;case 31:t.memoizedState!==null&&An(t);break;case 13:An(t);break;case 19:_t(tt);break;case 10:Ea(t.type);break;case 22:case 23:An(t),bb(),e!==null&&_t(Bs);break;case 24:Ea(it)}}function bd(e,t){try{var n=t.updateQueue,o=n!==null?n.lastEffect:null;if(o!==null){var a=o.next;n=a;do{if((n.tag&e)===e){o=void 0;var r=n.create,s=n.inst;o=r(),s.destroy=o}n=n.next}while(n!==a)}}catch(i){Ce(t,t.return,i)}}function Nr(e,t,n){try{var o=t.updateQueue,a=o!==null?o.lastEffect:null;if(a!==null){var r=a.next;o=r;do{if((o.tag&e)===e){var s=o.inst,i=s.destroy;if(i!==void 0){s.destroy=void 0,a=t;var l=n,c=i;try{c()}catch(u){Ce(a,l,u)}}}o=o.next}while(o!==r)}}catch(u){Ce(t,t.return,u)}}function _T(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Dw(t,n)}catch(o){Ce(e,e.return,o)}}}function wT(e,t,n){n.props=Ws(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Ce(e,t,o)}}function ju(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof n=="function"?e.refCleanup=n(o):n.current=o}}catch(a){Ce(e,t,a)}}function Ho(e,t){var n=e.ref,o=e.refCleanup;if(n!==null)if(typeof o=="function")try{o()}catch(a){Ce(e,t,a)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(a){Ce(e,t,a)}else n.current=null}function TT(e){var t=e.type,n=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&o.focus();break e;case"img":n.src?o.src=n.src:n.srcSet&&(o.srcset=n.srcSet)}}catch(a){Ce(e,e.return,a)}}function Zx(e,t,n){try{var o=e.stateNode;eN(o,e.type,n,t),o[an]=t}catch(a){Ce(e,e.return,a)}}function ET(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hr(e.type)||e.tag===4}function Xx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ET(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Hr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function B1(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=_a));else if(o!==4&&(o===27&&Hr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(B1(e,t,n),e=e.sibling;e!==null;)B1(e,t,n),e=e.sibling}function Zm(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(o!==4&&(o===27&&Hr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Zm(e,t,n),e=e.sibling;e!==null;)Zm(e,t,n),e=e.sibling}function CT(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Dt(t,o,n),t[Mt]=e,t[an]=n}catch(r){Ce(e,e.return,r)}}var La=!1,st=!1,Yx=!1,l_=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function PB(e,t){if(e=e.containerInfo,W1=a0,e=yw(e),cb(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var o=n.getSelection&&n.getSelection();if(o&&o.rangeCount!==0){n=o.anchorNode;var a=o.anchorOffset,r=o.focusNode;o=o.focusOffset;try{n.nodeType,r.nodeType}catch{n=null;break e}var s=0,i=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||a!==0&&d.nodeType!==3||(i=s+a),d!==r||o!==0&&d.nodeType!==3||(l=s+o),d.nodeType===3&&(s+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===a&&(i=s),f===r&&++u===o&&(l=s),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=i===-1||l===-1?null:{start:i,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(q1={focusedElem:e,selectionRange:n},a0=!1,Lt=t;Lt!==null;)if(t=Lt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Lt=e;else for(;Lt!==null;){switch(t=Lt,r=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&r!==null){e=void 0,n=t,a=r.memoizedProps,r=r.memoizedState,o=n.stateNode;try{var h=Ws(n.type,a);e=o.getSnapshotBeforeUpdate(h,r),o.__reactInternalSnapshotBeforeUpdate=e}catch(m){Ce(n,n.return,m)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)j1(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":j1(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(O(163))}if(e=t.sibling,e!==null){e.return=t.return,Lt=e;break}Lt=t.return}}function IT(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:Aa(e,n),o&4&&bd(5,n);break;case 1:if(Aa(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Ce(n,n.return,s)}else{var a=Ws(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Ce(n,n.return,s)}}o&64&&_T(n),o&512&&ju(n,n.return);break;case 3:if(Aa(e,n),o&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Dw(e,t)}catch(s){Ce(n,n.return,s)}}break;case 27:t===null&&o&4&&CT(n);case 26:case 5:Aa(e,n),t===null&&o&4&&TT(n),o&512&&ju(n,n.return);break;case 12:Aa(e,n);break;case 31:Aa(e,n),o&4&&OT(e,n);break;case 13:Aa(e,n),o&4&&DT(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qB.bind(null,n),lN(e,n))));break;case 22:if(o=n.memoizedState!==null||La,!o){t=t!==null&&t.memoizedState!==null||st,a=La;var r=st;La=o,(st=t)&&!r?va(e,n,(n.subtreeFlags&8772)!==0):Aa(e,n),La=a,st=r}break;case 30:break;default:Aa(e,n)}}function MT(e){var t=e.alternate;t!==null&&(e.alternate=null,MT(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ob(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var je=null,tn=!1;function ba(e,t,n){for(n=n.child;n!==null;)RT(e,t,n),n=n.sibling}function RT(e,t,n){if(kn&&typeof kn.onCommitFiberUnmount=="function")try{kn.onCommitFiberUnmount(fd,n)}catch{}switch(n.tag){case 26:st||Ho(n,t),ba(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:st||Ho(n,t);var o=je,a=tn;Hr(n.type)&&(je=n.stateNode,tn=!1),ba(e,t,n),Ku(n.stateNode),je=o,tn=a;break;case 5:st||Ho(n,t);case 6:if(o=je,a=tn,je=null,ba(e,t,n),je=o,tn=a,je!==null)if(tn)try{(je.nodeType===9?je.body:je.nodeName==="HTML"?je.ownerDocument.body:je).removeChild(n.stateNode)}catch(r){Ce(n,t,r)}else try{je.removeChild(n.stateNode)}catch(r){Ce(n,t,r)}break;case 18:je!==null&&(tn?(e=je,L_(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Vl(e)):L_(je,n.stateNode));break;case 4:o=je,a=tn,je=n.stateNode.containerInfo,tn=!0,ba(e,t,n),je=o,tn=a;break;case 0:case 11:case 14:case 15:Nr(2,n,t),st||Nr(4,n,t),ba(e,t,n);break;case 1:st||(Ho(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&wT(n,t,o)),ba(e,t,n);break;case 21:ba(e,t,n);break;case 22:st=(o=st)||n.memoizedState!==null,ba(e,t,n),st=o;break;default:ba(e,t,n)}}function OT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vl(e)}catch(n){Ce(t,t.return,n)}}}function DT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vl(e)}catch(n){Ce(t,t.return,n)}}function BB(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new l_),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new l_),t;default:throw Error(O(435,e.tag))}}function um(e,t){var n=BB(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=VB.bind(null,e,o);o.then(a,a)}})}function Jt(e,t){var n=t.deletions;if(n!==null)for(var o=0;o<n.length;o++){var a=n[o],r=e,s=t,i=s;e:for(;i!==null;){switch(i.tag){case 27:if(Hr(i.type)){je=i.stateNode,tn=!1;break e}break;case 5:je=i.stateNode,tn=!1;break e;case 3:case 4:je=i.stateNode.containerInfo,tn=!0;break e}i=i.return}if(je===null)throw Error(O(160));RT(r,s,a),je=null,tn=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)PT(t,e),t=t.sibling}var xo=null;function PT(e,t){var n=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Jt(t,e),en(e),o&4&&(Nr(3,e,e.return),bd(3,e),Nr(5,e,e.return));break;case 1:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),o&64&&La&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?o:n.concat(o))));break;case 26:var a=xo;if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),o&4){var r=n!==null?n.memoizedState:null;if(o=e.memoizedState,n===null)if(o===null)if(e.stateNode===null){e:{o=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(o){case"title":r=a.getElementsByTagName("title")[0],(!r||r[md]||r[Mt]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),Dt(r,o,n),r[Mt]=e,kt(r),o=r;break e;case"link":var s=I_("link","href",a).get(o+(n.href||""));if(s){for(var i=0;i<s.length;i++)if(r=s[i],r.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&r.getAttribute("rel")===(n.rel==null?null:n.rel)&&r.getAttribute("title")===(n.title==null?null:n.title)&&r.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(i,1);break t}}r=a.createElement(o),Dt(r,o,n),a.head.appendChild(r);break;case"meta":if(s=I_("meta","content",a).get(o+(n.content||""))){for(i=0;i<s.length;i++)if(r=s[i],r.getAttribute("content")===(n.content==null?null:""+n.content)&&r.getAttribute("name")===(n.name==null?null:n.name)&&r.getAttribute("property")===(n.property==null?null:n.property)&&r.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(i,1);break t}}r=a.createElement(o),Dt(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[Mt]=e,kt(r),o=r}e.stateNode=o}else M_(a,e.type,e.stateNode);else e.stateNode=C_(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?M_(a,e.type,e.stateNode):C_(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Zx(e,e.memoizedProps,n.memoizedProps)}break;case 27:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),n!==null&&o&4&&Zx(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),e.flags&32){a=e.stateNode;try{Nl(a,"")}catch(h){Ce(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,Zx(e,a,n!==null?n.memoizedProps:a)),o&1024&&(Yx=!0);break;case 6:if(Jt(t,e),en(e),o&4){if(e.stateNode===null)throw Error(O(162));o=e.memoizedProps,n=e.stateNode;try{n.nodeValue=o}catch(h){Ce(e,e.return,h)}}break;case 3:if(Em=null,a=xo,xo=t0(t.containerInfo),Jt(t,e),xo=a,en(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(h){Ce(e,e.return,h)}Yx&&(Yx=!1,BT(e));break;case 4:o=xo,xo=t0(e.stateNode.containerInfo),Jt(t,e),en(e),xo=o;break;case 12:Jt(t,e),en(e);break;case 31:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,um(e,o)));break;case 13:Jt(t,e),en(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(g0=Ln()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,um(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=La,u=st;if(La=c||a,st=u||l,Jt(t,e),st=u,La=c,en(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||La||st||Os(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(r=l.stateNode,a)s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{i=l.stateNode;var d=l.memoizedProps.style,f=d!=null&&d.hasOwnProperty("display")?d.display:null;i.style.display=f==null||typeof f=="boolean"?"":(""+f).trim()}}catch(h){Ce(l,l.return,h)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?"":l.memoizedProps}catch(h){Ce(l,l.return,h)}}}else if(t.tag===18){if(n===null){l=t;try{var p=l.stateNode;a?k_(p,!0):k_(l.stateNode,!1)}catch(h){Ce(l,l.return,h)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(n=o.retryQueue,n!==null&&(o.retryQueue=null,um(e,n))));break;case 19:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,um(e,o)));break;case 30:break;case 21:break;default:Jt(t,e),en(e)}}function en(e){var t=e.flags;if(t&2){try{for(var n,o=e.return;o!==null;){if(ET(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=Xx(e);Zm(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(Nl(s,""),n.flags&=-33);var i=Xx(e);Zm(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=Xx(e);B1(e,c,l);break;default:throw Error(O(161))}}catch(u){Ce(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function BT(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;BT(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Aa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)IT(e,t.alternate,t),t=t.sibling}function Os(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Nr(4,t,t.return),Os(t);break;case 1:Ho(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&wT(t,t.return,n),Os(t);break;case 27:Ku(t.stateNode);case 26:case 5:Ho(t,t.return),Os(t);break;case 22:t.memoizedState===null&&Os(t);break;case 30:Os(t);break;default:Os(t)}e=e.sibling}}function va(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,a=e,r=t,s=r.flags;switch(r.tag){case 0:case 11:case 15:va(a,r,n),bd(4,r);break;case 1:if(va(a,r,n),o=r,a=o.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(c){Ce(o,o.return,c)}if(o=r,a=o.updateQueue,a!==null){var i=o.stateNode;try{var l=a.shared.hiddenCallbacks;if(l!==null)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)Ow(l[a],i)}catch(c){Ce(o,o.return,c)}}n&&s&64&&_T(r),ju(r,r.return);break;case 27:CT(r);case 26:case 5:va(a,r,n),n&&o===null&&s&4&&TT(r),ju(r,r.return);break;case 12:va(a,r,n);break;case 31:va(a,r,n),n&&s&4&&OT(a,r);break;case 13:va(a,r,n),n&&s&4&&DT(a,r);break;case 22:r.memoizedState===null&&va(a,r,n),ju(r,r.return);break;case 30:break;default:va(a,r,n)}t=t.sibling}}function Pb(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&gd(n))}function Bb(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&gd(e))}function go(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)NT(e,t,n,o),t=t.sibling}function NT(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:go(e,t,n,o),a&2048&&bd(9,t);break;case 1:go(e,t,n,o);break;case 3:go(e,t,n,o),a&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&gd(e)));break;case 12:if(a&2048){go(e,t,n,o),e=t.stateNode;try{var r=t.memoizedProps,s=r.id,i=r.onPostCommit;typeof i=="function"&&i(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(l){Ce(t,t.return,l)}}else go(e,t,n,o);break;case 31:go(e,t,n,o);break;case 13:go(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?go(e,t,n,o):Zu(e,t):r._visibility&2?go(e,t,n,o):(r._visibility|=2,hl(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&Pb(s,t);break;case 24:go(e,t,n,o),a&2048&&Bb(t.alternate,t);break;default:go(e,t,n,o)}}function hl(e,t,n,o,a){for(a=a&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var r=e,s=t,i=n,l=o,c=s.flags;switch(s.tag){case 0:case 11:case 15:hl(r,s,i,l,a),bd(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?hl(r,s,i,l,a):Zu(r,s):(u._visibility|=2,hl(r,s,i,l,a)),a&&c&2048&&Pb(s.alternate,s);break;case 24:hl(r,s,i,l,a),a&&c&2048&&Bb(s.alternate,s);break;default:hl(r,s,i,l,a)}t=t.sibling}}function Zu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,o=t,a=o.flags;switch(o.tag){case 22:Zu(n,o),a&2048&&Pb(o.alternate,o);break;case 24:Zu(n,o),a&2048&&Bb(o.alternate,o);break;default:Zu(n,o)}t=t.sibling}}var Nu=8192;function pl(e,t,n){if(e.subtreeFlags&Nu)for(e=e.child;e!==null;)zT(e,t,n),e=e.sibling}function zT(e,t,n){switch(e.tag){case 26:pl(e,t,n),e.flags&Nu&&e.memoizedState!==null&&AN(n,xo,e.memoizedState,e.memoizedProps);break;case 5:pl(e,t,n);break;case 3:case 4:var o=xo;xo=t0(e.stateNode.containerInfo),pl(e,t,n),xo=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Nu,Nu=16777216,pl(e,t,n),Nu=o):pl(e,t,n));break;default:pl(e,t,n)}}function FT(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Iu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];Lt=o,UT(o,e)}FT(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)HT(e),e=e.sibling}function HT(e){switch(e.tag){case 0:case 11:case 15:Iu(e),e.flags&2048&&Nr(9,e,e.return);break;case 3:Iu(e);break;case 12:Iu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,wm(e)):Iu(e);break;default:Iu(e)}}function wm(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];Lt=o,UT(o,e)}FT(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Nr(8,t,t.return),wm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,wm(t));break;default:wm(t)}e=e.sibling}}function UT(e,t){for(;Lt!==null;){var n=Lt;switch(n.tag){case 0:case 11:case 15:Nr(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var o=n.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:gd(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,Lt=o;else e:for(n=e;Lt!==null;){o=Lt;var a=o.sibling,r=o.return;if(MT(o),o===n){Lt=null;break e}if(a!==null){a.return=r,Lt=a;break e}Lt=r}}}var NB={getCacheForType:function(e){var t=Ot(it),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ot(it).controller.signal}},zB=typeof WeakMap=="function"?WeakMap:Map,ke=0,De=null,fe=null,me=0,Ee=0,bn=null,Lr=!1,Kl=!1,Nb=!1,Da=0,Je=0,zr=0,zs=0,zb=0,Sn=0,Ul=0,Xu=null,nn=null,N1=!1,g0=0,GT=0,Xm=1/0,Ym=null,Ir=null,ht=0,Mr=null,Gl=null,Ca=0,z1=0,F1=null,WT=null,Yu=0,H1=null;function wn(){return(ke&2)!==0&&me!==0?me&-me:K.T!==null?Hb():Q_()}function qT(){if(Sn===0)if((me&536870912)===0||be){var e=em;em<<=1,(em&3932160)===0&&(em=262144),Sn=e}else Sn=536870912;return e=En.current,e!==null&&(e.flags|=32),Sn}function on(e,t,n){(e===De&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)&&(Wl(e,0),kr(e,me,Sn,!1)),hd(e,n),((ke&2)===0||e!==De)&&(e===De&&((ke&2)===0&&(zs|=n),Je===4&&kr(e,me,Sn,!1)),Wo(e))}function VT(e,t,n){if((ke&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||pd(e,t),a=o?UB(e,t):Kx(e,t,!0),r=o;do{if(a===0){Kl&&!o&&kr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!FB(n)){a=Kx(e,t,!1),r=!1;continue}if(a===2){if(r=t,e.errorRecoveryDisabledLanes&r)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var i=e;a=Xu;var l=i.current.memoizedState.isDehydrated;if(l&&(Wl(i,s).flags|=256),s=Kx(i,s,!1),s!==2){if(Nb&&!l){i.errorRecoveryDisabledLanes|=r,zs|=r,a=4;break e}r=nn,nn=a,r!==null&&(nn===null?nn=r:nn.push.apply(nn,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){Wl(e,0),kr(e,t,0,!0);break}e:{switch(o=e,r=a,r){case 0:case 1:throw Error(O(345));case 4:if((t&4194048)!==t)break;case 6:kr(o,t,Sn,!Lr);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=g0+300-Ln(),10<a)){if(kr(o,t,Sn,!Lr),s0(o,0,!0)!==0)break e;Ca=t,o.timeoutHandle=dE(c_.bind(null,o,n,nn,Ym,N1,t,Sn,zs,Ul,Lr,r,"Throttled",-0,0),a);break e}c_(o,n,nn,Ym,N1,t,Sn,zs,Ul,Lr,r,null,-0,0)}}break}while(!0);Wo(e)}function c_(e,t,n,o,a,r,s,i,l,c,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_a},zT(t,r,d);var h=(r&62914560)===r?g0-Ln():(r&4194048)===r?GT-Ln():0;if(h=vN(d,h),h!==null){Ca=r,e.cancelPendingCommit=h(d_.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),kr(e,r,s,!c);return}}d_(e,t,r,n,o,a,s,i,l)}function FB(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var o=0;o<n.length;o++){var a=n[o],r=a.getSnapshot;a=a.value;try{if(!Tn(r(),a))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function kr(e,t,n,o){t&=~zb,t&=~zs,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-_n(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&Y_(e,n,t)}function x0(){return(ke&6)===0?(Ad(0,!1),!1):!0}function Fb(){if(fe!==null){if(Ee===0)var e=fe.return;else e=fe,wa=Xs=null,kb(e),Rl=null,od=0,e=fe;for(;e!==null;)kT(e.alternate,e),e=e.return;fe=null}}function Wl(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,oN(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ca=0,Fb(),De=e,fe=n=Ta(e.current,null),me=t,Ee=0,bn=null,Lr=!1,Kl=pd(e,t),Nb=!1,Ul=Sn=zb=zs=zr=Je=0,nn=Xu=null,N1=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var a=31-_n(o),r=1<<a;t|=e[a],o&=~r}return Da=t,u0(),n}function jT(e,t){oe=null,K.H=rd,t===Yl||t===f0?(t=Uk(),Ee=3):t===gb?(t=Uk(),Ee=4):Ee=t===Ob?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,bn=t,fe===null&&(Je=1,Vm(e,Xn(t,e.current)))}function ZT(){var e=En.current;return e===null?!0:(me&4194048)===me?Kn===null:(me&62914560)===me||(me&536870912)!==0?e===Kn:!1}function XT(){var e=K.H;return K.H=rd,e===null?rd:e}function YT(){var e=K.A;return K.A=NB,e}function Km(){Je=4,Lr||(me&4194048)!==me&&En.current!==null||(Kl=!0),(zr&134217727)===0&&(zs&134217727)===0||De===null||kr(De,me,Sn,!1)}function Kx(e,t,n){var o=ke;ke|=2;var a=XT(),r=YT();(De!==e||me!==t)&&(Ym=null,Wl(e,t)),t=!1;var s=Je;e:do try{if(Ee!==0&&fe!==null){var i=fe,l=bn;switch(Ee){case 8:Fb(),s=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(t=!0);var c=Ee;if(Ee=0,bn=null,Tl(e,i,l,c),n&&Kl){s=0;break e}break;default:c=Ee,Ee=0,bn=null,Tl(e,i,l,c)}}HB(),s=Je;break}catch(u){jT(e,u)}while(!0);return t&&e.shellSuspendCounter++,wa=Xs=null,ke=o,K.H=a,K.A=r,fe===null&&(De=null,me=0,u0()),s}function HB(){for(;fe!==null;)KT(fe)}function UB(e,t){var n=ke;ke|=2;var o=XT(),a=YT();De!==e||me!==t?(Ym=null,Xm=Ln()+500,Wl(e,t)):Kl=pd(e,t);e:do try{if(Ee!==0&&fe!==null){t=fe;var r=bn;t:switch(Ee){case 1:Ee=0,bn=null,Tl(e,t,r,1);break;case 2:case 9:if(Hk(r)){Ee=0,bn=null,u_(t);break}t=function(){Ee!==2&&Ee!==9||De!==e||(Ee=7),Wo(e)},r.then(t,t);break e;case 3:Ee=7;break e;case 4:Ee=5;break e;case 7:Hk(r)?(Ee=0,bn=null,u_(t)):(Ee=0,bn=null,Tl(e,t,r,7));break;case 5:var s=null;switch(fe.tag){case 26:s=fe.memoizedState;case 5:case 27:var i=fe;if(s?yE(s):i.stateNode.complete){Ee=0,bn=null;var l=i.sibling;if(l!==null)fe=l;else{var c=i.return;c!==null?(fe=c,b0(c)):fe=null}break t}}Ee=0,bn=null,Tl(e,t,r,5);break;case 6:Ee=0,bn=null,Tl(e,t,r,6);break;case 8:Fb(),Je=6;break e;default:throw Error(O(462))}}GB();break}catch(u){jT(e,u)}while(!0);return wa=Xs=null,K.H=o,K.A=a,ke=n,fe!==null?0:(De=null,me=0,u0(),Je)}function GB(){for(;fe!==null&&!d7();)KT(fe)}function KT(e){var t=LT(e.alternate,e,Da);e.memoizedProps=e.pendingProps,t===null?b0(e):fe=t}function u_(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=o_(n,t,t.pendingProps,t.type,void 0,me);break;case 11:t=o_(n,t,t.pendingProps,t.type.render,t.ref,me);break;case 5:kb(t);default:kT(n,t),t=fe=kw(t,Da),t=LT(n,t,Da)}e.memoizedProps=e.pendingProps,t===null?b0(e):fe=t}function Tl(e,t,n,o){wa=Xs=null,kb(t),Rl=null,od=0;var a=t.return;try{if(IB(e,a,t,n,me)){Je=1,Vm(e,Xn(n,e.current)),fe=null;return}}catch(r){if(a!==null)throw fe=a,r;Je=1,Vm(e,Xn(n,e.current)),fe=null;return}t.flags&32768?(be||o===1?e=!0:Kl||(me&536870912)!==0?e=!1:(Lr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),$T(t,e)):b0(t)}function b0(e){var t=e;do{if((t.flags&32768)!==0){$T(t,Lr);return}e=t.return;var n=OB(t.alternate,t,Da);if(n!==null){fe=n;return}if(t=t.sibling,t!==null){fe=t;return}fe=t=e}while(t!==null);Je===0&&(Je=5)}function $T(e,t){do{var n=DB(e.alternate,e);if(n!==null){n.flags&=32767,fe=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){fe=e;return}fe=e=n}while(e!==null);Je=6,fe=null}function d_(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do A0();while(ht!==0);if((ke&6)!==0)throw Error(O(327));if(t!==null){if(t===e.current)throw Error(O(177));if(r=t.lanes|t.childLanes,r|=ub,v7(e,n,r,s,i,l),e===De&&(fe=De=null,me=0),Gl=t,Mr=e,Ca=n,z1=r,F1=a,WT=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,jB(Dm,function(){return nE(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=_e.p,_e.p=2,s=ke,ke|=4;try{PB(e,t,n)}finally{ke=s,_e.p=a,K.T=o}}ht=1,QT(),JT(),eE()}}function QT(){if(ht===1){ht=0;var e=Mr,t=Gl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{PT(t,e);var r=q1,s=yw(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&mw(i.ownerDocument.documentElement,i)){if(l!==null&&cb(i)){var c=l.start,u=l.end;if(u===void 0&&(u=c),"selectionStart"in i)i.selectionStart=c,i.selectionEnd=Math.min(u,i.value.length);else{var d=i.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),h=i.textContent.length,m=Math.min(l.start,h),x=l.end===void 0?m:Math.min(l.end,h);!p.extend&&m>x&&(s=x,x=m,m=s);var y=Ok(i,m),g=Ok(i,x);if(y&&g&&(p.rangeCount!==1||p.anchorNode!==y.node||p.anchorOffset!==y.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var b=d.createRange();b.setStart(y.node,y.offset),p.removeAllRanges(),m>x?(p.addRange(b),p.extend(g.node,g.offset)):(b.setEnd(g.node,g.offset),p.addRange(b))}}}}for(d=[],p=i;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<d.length;i++){var A=d[i];A.element.scrollLeft=A.left,A.element.scrollTop=A.top}}a0=!!W1,q1=W1=null}finally{ke=a,_e.p=o,K.T=n}}e.current=t,ht=2}}function JT(){if(ht===2){ht=0;var e=Mr,t=Gl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{IT(e,t.alternate,t)}finally{ke=a,_e.p=o,K.T=n}}ht=3}}function eE(){if(ht===4||ht===3){ht=0,f7();var e=Mr,t=Gl,n=Ca,o=WT;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ht=5:(ht=0,Gl=Mr=null,tE(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(Ir=null),nb(n),t=t.stateNode,kn&&typeof kn.onCommitFiberRoot=="function")try{kn.onCommitFiberRoot(fd,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=_e.p,_e.p=2,K.T=null;try{for(var r=e.onRecoverableError,s=0;s<o.length;s++){var i=o[s];r(i.value,{componentStack:i.stack})}}finally{K.T=t,_e.p=a}}(Ca&3)!==0&&A0(),Wo(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===H1?Yu++:(Yu=0,H1=e):Yu=0,Ad(0,!1)}}function tE(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,gd(t)))}function A0(){return QT(),JT(),eE(),nE()}function nE(){if(ht!==5)return!1;var e=Mr,t=z1;z1=0;var n=nb(Ca),o=K.T,a=_e.p;try{_e.p=32>n?32:n,K.T=null,n=F1,F1=null;var r=Mr,s=Ca;if(ht=0,Gl=Mr=null,Ca=0,(ke&6)!==0)throw Error(O(331));var i=ke;if(ke|=4,HT(r.current),NT(r,r.current,s,n),ke=i,Ad(0,!1),kn&&typeof kn.onPostCommitFiberRoot=="function")try{kn.onPostCommitFiberRoot(fd,r)}catch{}return!0}finally{_e.p=a,K.T=o,tE(e,t)}}function f_(e,t,n){t=Xn(n,t),t=O1(e.stateNode,t,2),e=Cr(e,t,2),e!==null&&(hd(e,2),Wo(e))}function Ce(e,t,n){if(e.tag===3)f_(e,e,n);else for(;t!==null;){if(t.tag===3){f_(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ir===null||!Ir.has(o))){e=Xn(n,e),n=gT(2),o=Cr(t,n,2),o!==null&&(xT(n,o,t,e),hd(o,2),Wo(o));break}}t=t.return}}function $x(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new zB;var a=new Set;o.set(t,a)}else a=o.get(t),a===void 0&&(a=new Set,o.set(t,a));a.has(n)||(Nb=!0,a.add(n),e=WB.bind(null,e,t,n),t.then(e,e))}function WB(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,De===e&&(me&n)===n&&(Je===4||Je===3&&(me&62914560)===me&&300>Ln()-g0?(ke&2)===0&&Wl(e,0):zb|=n,Ul===me&&(Ul=0)),Wo(e)}function oE(e,t){t===0&&(t=X_()),e=Zs(e,t),e!==null&&(hd(e,t),Wo(e))}function qB(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),oE(e,n)}function VB(e,t){var n=0;switch(e.tag){case 31:case 13:var o=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(O(314))}o!==null&&o.delete(t),oE(e,n)}function jB(e,t){return eb(e,t)}var $m=null,ml=null,U1=!1,Qm=!1,Qx=!1,_r=0;function Wo(e){e!==ml&&e.next===null&&(ml===null?$m=ml=e:ml=ml.next=e),Qm=!0,U1||(U1=!0,XB())}function Ad(e,t){if(!Qx&&Qm){Qx=!0;do for(var n=!1,o=$m;o!==null;){if(!t)if(e!==0){var a=o.pendingLanes;if(a===0)var r=0;else{var s=o.suspendedLanes,i=o.pingedLanes;r=(1<<31-_n(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,p_(o,r))}else r=me,r=s0(o,o===De?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||pd(o,r)||(n=!0,p_(o,r));o=o.next}while(n);Qx=!1}}function ZB(){aE()}function aE(){Qm=U1=!1;var e=0;_r!==0&&nN()&&(e=_r);for(var t=Ln(),n=null,o=$m;o!==null;){var a=o.next,r=rE(o,t);r===0?(o.next=null,n===null?$m=a:n.next=a,a===null&&(ml=n)):(n=o,(e!==0||(r&3)!==0)&&(Qm=!0)),o=a}ht!==0&&ht!==5||Ad(e,!1),_r!==0&&(_r=0)}function rE(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-_n(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=A7(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=De,n=me,n=s0(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,n===0||e===t&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Tx(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||pd(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&Tx(o),nb(n)){case 2:case 8:n=j_;break;case 32:n=Dm;break;case 268435456:n=Z_;break;default:n=Dm}return o=sE.bind(null,e),n=eb(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&Tx(o),e.callbackPriority=2,e.callbackNode=null,2}function sE(e,t){if(ht!==0&&ht!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(A0()&&e.callbackNode!==n)return null;var o=me;return o=s0(e,e===De?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(VT(e,o,t),rE(e,Ln()),e.callbackNode!=null&&e.callbackNode===n?sE.bind(null,e):null)}function p_(e,t){if(A0())return null;VT(e,t,!0)}function XB(){aN(function(){(ke&6)!==0?eb(V_,ZB):aE()})}function Hb(){if(_r===0){var e=zl;e===0&&(e=Jh,Jh<<=1,(Jh&261888)===0&&(Jh=256)),_r=e}return _r}function h_(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:gm(""+e)}function m_(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function YB(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=h_((a[an]||null).action),s=o.submitter;s&&(t=(t=s[an]||null)?h_(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new i0("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(_r!==0){var l=s?m_(a,s):new FormData(a);M1(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?m_(a,s):new FormData(a),M1(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(dm=0;dm<b1.length;dm++)fm=b1[dm],y_=fm.toLowerCase(),g_=fm[0].toUpperCase()+fm.slice(1),bo(y_,"on"+g_);var fm,y_,g_,dm;bo(xw,"onAnimationEnd");bo(bw,"onAnimationIteration");bo(Aw,"onAnimationStart");bo("dblclick","onDoubleClick");bo("focusin","onFocus");bo("focusout","onBlur");bo(pB,"onTransitionRun");bo(hB,"onTransitionStart");bo(mB,"onTransitionCancel");bo(vw,"onTransitionEnd");Bl("onMouseEnter",["mouseout","mouseover"]);Bl("onMouseLeave",["mouseout","mouseover"]);Bl("onPointerEnter",["pointerout","pointerover"]);Bl("onPointerLeave",["pointerout","pointerover"]);qs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));qs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));qs("onBeforeInput",["compositionend","keypress","textInput","paste"]);qs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));qs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));qs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sd="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(" "),KB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(sd));function iE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var o=e[n],a=o.event;o=o.listeners;e:{var r=void 0;if(t)for(var s=o.length-1;0<=s;s--){var i=o[s],l=i.instance,c=i.currentTarget;if(i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){Bm(u)}a.currentTarget=null,r=l}else for(s=0;s<o.length;s++){if(i=o[s],l=i.instance,c=i.currentTarget,i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){Bm(u)}a.currentTarget=null,r=l}}}}function de(e,t){var n=t[d1];n===void 0&&(n=t[d1]=new Set);var o=e+"__bubble";n.has(o)||(lE(t,e,2,!1),n.add(o))}function Jx(e,t,n){var o=0;t&&(o|=4),lE(n,e,o,t)}var pm="_reactListening"+Math.random().toString(36).slice(2);function Ub(e){if(!e[pm]){e[pm]=!0,J_.forEach(function(n){n!=="selectionchange"&&(KB.has(n)||Jx(n,!1,e),Jx(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[pm]||(t[pm]=!0,Jx("selectionchange",!1,t))}}function lE(e,t,n,o){switch(vE(t)){case 2:var a=kN;break;case 8:a=_N;break;default:a=Vb}n=a.bind(null,t,n,e),a=void 0,!y1||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),o?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function e1(e,t,n,o,a){var r=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var s=o.tag;if(s===3||s===4){var i=o.stateNode.containerInfo;if(i===a)break;if(s===4)for(s=o.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===a)return;s=s.return}for(;i!==null;){if(s=xl(i),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){o=r=s;continue e}i=i.parentNode}}o=o.return}iw(function(){var c=r,u=rb(n),d=[];e:{var f=Sw.get(e);if(f!==void 0){var p=i0,h=e;switch(e){case"keypress":if(bm(n)===0)break e;case"keydown":case"keyup":p=V7;break;case"focusin":h="focus",p=Rx;break;case"focusout":h="blur",p=Rx;break;case"beforeblur":case"afterblur":p=Rx;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=kk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=O7;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=X7;break;case xw:case bw:case Aw:p=B7;break;case vw:p=K7;break;case"scroll":case"scrollend":p=M7;break;case"wheel":p=Q7;break;case"copy":case"cut":case"paste":p=z7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=wk;break;case"toggle":case"beforetoggle":p=eB}var m=(t&4)!==0,x=!m&&(e==="scroll"||e==="scrollend"),y=m?f!==null?f+"Capture":null:f;m=[];for(var g=c,b;g!==null;){var A=g;if(b=A.stateNode,A=A.tag,A!==5&&A!==26&&A!==27||b===null||y===null||(A=Qu(g,y),A!=null&&m.push(id(g,A,b))),x)break;g=g.return}0<m.length&&(f=new p(f,h,null,n,u),d.push({event:f,listeners:m}))}}if((t&7)===0){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==m1&&(h=n.relatedTarget||n.fromElement)&&(xl(h)||h[jl]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(h=n.relatedTarget||n.toElement,p=c,h=h?xl(h):null,h!==null&&(x=dd(h),m=h.tag,h!==x||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=kk,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=wk,A="onPointerLeave",y="onPointerEnter",g="pointer"),x=p==null?f:Pu(p),b=h==null?f:Pu(h),f=new m(A,g+"leave",p,n,u),f.target=x,f.relatedTarget=b,A=null,xl(u)===c&&(m=new m(y,g+"enter",h,n,u),m.target=b,m.relatedTarget=x,A=m),x=A,p&&h)t:{for(m=$B,y=p,g=h,b=0,A=y;A;A=m(A))b++;A=0;for(var _=g;_;_=m(_))A++;for(;0<b-A;)y=m(y),b--;for(;0<A-b;)g=m(g),A--;for(;b--;){if(y===g||g!==null&&y===g.alternate){m=y;break t}y=m(y),g=m(g)}m=null}else m=null;p!==null&&x_(d,f,p,m,!1),h!==null&&x!==null&&x_(d,x,h,m,!0)}}e:{if(f=c?Pu(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var C=Ik;else if(Ck(f))if(pw)C=uB;else{C=lB;var w=iB}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&ab(c.elementType)&&(C=Ik):C=cB;if(C&&(C=C(e,c))){fw(d,C,n,u);break e}w&&w(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&h1(f,"number",f.value)}switch(w=c?Pu(c):window,e){case"focusin":(Ck(w)||w.contentEditable==="true")&&(vl=w,g1=c,Hu=null);break;case"focusout":Hu=g1=vl=null;break;case"mousedown":x1=!0;break;case"contextmenu":case"mouseup":case"dragend":x1=!1,Dk(d,n,u);break;case"selectionchange":if(fB)break;case"keydown":case"keyup":Dk(d,n,u)}var L;if(lb)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Al?uw(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(cw&&n.locale!=="ko"&&(Al||k!=="onCompositionStart"?k==="onCompositionEnd"&&Al&&(L=lw()):(Sr=u,sb="value"in Sr?Sr.value:Sr.textContent,Al=!0)),w=Jm(c,k),0<w.length&&(k=new _k(k,e,null,n,u),d.push({event:k,listeners:w}),L?k.data=L:(L=dw(n),L!==null&&(k.data=L)))),(L=nB?oB(e,n):aB(e,n))&&(k=Jm(c,"onBeforeInput"),0<k.length&&(w=new _k("onBeforeInput","beforeinput",null,n,u),d.push({event:w,listeners:k}),w.data=L)),YB(d,e,c,n,u)}iE(d,t)})}function id(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Jm(e,t){for(var n=t+"Capture",o=[];e!==null;){var a=e,r=a.stateNode;if(a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=Qu(e,n),a!=null&&o.unshift(id(e,a,r)),a=Qu(e,t),a!=null&&o.push(id(e,a,r))),e.tag===3)return o;e=e.return}return[]}function $B(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function x_(e,t,n,o,a){for(var r=t._reactName,s=[];n!==null&&n!==o;){var i=n,l=i.alternate,c=i.stateNode;if(i=i.tag,l!==null&&l===o)break;i!==5&&i!==26&&i!==27||c===null||(l=c,a?(c=Qu(n,r),c!=null&&s.unshift(id(n,c,l))):a||(c=Qu(n,r),c!=null&&s.push(id(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var QB=/\r\n?/g,JB=/\u0000|\uFFFD/g;function b_(e){return(typeof e=="string"?e:""+e).replace(QB,`
9
+ `).replace(JB,"")}function cE(e,t){return t=b_(t),b_(e)===t}function Ie(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Nl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Nl(e,""+o);break;case"className":nm(e,"class",o);break;case"tabIndex":nm(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":nm(e,n,o);break;case"style":sw(e,o,r);break;case"data":if(t!=="object"){nm(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=gm(""+o),e.setAttribute(n,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof r=="function"&&(n==="formAction"?(t!=="input"&&Ie(e,t,"name",a.name,a,null),Ie(e,t,"formEncType",a.formEncType,a,null),Ie(e,t,"formMethod",a.formMethod,a,null),Ie(e,t,"formTarget",a.formTarget,a,null)):(Ie(e,t,"encType",a.encType,a,null),Ie(e,t,"method",a.method,a,null),Ie(e,t,"target",a.target,a,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=gm(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=_a);break;case"onScroll":o!=null&&de("scroll",e);break;case"onScrollEnd":o!=null&&de("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}n=gm(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""+o):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":o===!0?e.setAttribute(n,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,o):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(n,o):e.removeAttribute(n);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(n):e.setAttribute(n,o);break;case"popover":de("beforetoggle",e),de("toggle",e),ym(e,"popover",o);break;case"xlinkActuate":ga(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ga(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ga(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ga(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ga(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ga(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ga(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ga(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ga(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ym(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=C7.get(n)||n,ym(e,n,o))}}function G1(e,t,n,o,a,r){switch(n){case"style":sw(e,o,r);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"children":typeof o=="string"?Nl(e,o):(typeof o=="number"||typeof o=="bigint")&&Nl(e,""+o);break;case"onScroll":o!=null&&de("scroll",e);break;case"onScrollEnd":o!=null&&de("scrollend",e);break;case"onClick":o!=null&&(e.onclick=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ew.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),r=e[an]||null,r=r!=null?r[n]:null,typeof r=="function"&&e.removeEventListener(t,r,a),typeof o=="function")){typeof r!="function"&&r!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,o,a);break e}n in e?e[n]=o:o===!0?e.setAttribute(n,""):ym(e,n,o)}}}function Dt(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":de("error",e),de("load",e);var o=!1,a=!1,r;for(r in n)if(n.hasOwnProperty(r)){var s=n[r];if(s!=null)switch(r){case"src":o=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,r,s,n,null)}}a&&Ie(e,t,"srcSet",n.srcSet,n,null),o&&Ie(e,t,"src",n.src,n,null);return;case"input":de("invalid",e);var i=r=s=a=null,l=null,c=null;for(o in n)if(n.hasOwnProperty(o)){var u=n[o];if(u!=null)switch(o){case"name":a=u;break;case"type":s=u;break;case"checked":l=u;break;case"defaultChecked":c=u;break;case"value":r=u;break;case"defaultValue":i=u;break;case"children":case"dangerouslySetInnerHTML":if(u!=null)throw Error(O(137,t));break;default:Ie(e,t,o,u,n,null)}}ow(e,r,i,l,c,s,a,!1);return;case"select":de("invalid",e),o=s=r=null;for(a in n)if(n.hasOwnProperty(a)&&(i=n[a],i!=null))switch(a){case"value":r=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:Ie(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Cl(e,!!o,t,!1):n!=null&&Cl(e,!!o,n,!0);return;case"textarea":de("invalid",e),r=a=o=null;for(s in n)if(n.hasOwnProperty(s)&&(i=n[s],i!=null))switch(s){case"value":o=i;break;case"defaultValue":a=i;break;case"children":r=i;break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(O(91));break;default:Ie(e,t,s,i,n,null)}rw(e,o,a,r);return;case"option":for(l in n)if(n.hasOwnProperty(l)&&(o=n[l],o!=null))switch(l){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:Ie(e,t,l,o,n,null)}return;case"dialog":de("beforetoggle",e),de("toggle",e),de("cancel",e),de("close",e);break;case"iframe":case"object":de("load",e);break;case"video":case"audio":for(o=0;o<sd.length;o++)de(sd[o],e);break;case"image":de("error",e),de("load",e);break;case"details":de("toggle",e);break;case"embed":case"source":case"link":de("error",e),de("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(c in n)if(n.hasOwnProperty(c)&&(o=n[c],o!=null))switch(c){case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,c,o,n,null)}return;default:if(ab(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&G1(e,t,u,o,n,void 0));return}}for(i in n)n.hasOwnProperty(i)&&(o=n[i],o!=null&&Ie(e,t,i,o,n,null))}function eN(e,t,n,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,r=null,s=null,i=null,l=null,c=null,u=null;for(p in n){var d=n[p];if(n.hasOwnProperty(p)&&d!=null)switch(p){case"checked":break;case"value":break;case"defaultValue":l=d;default:o.hasOwnProperty(p)||Ie(e,t,p,null,o,d)}}for(var f in o){var p=o[f];if(d=n[f],o.hasOwnProperty(f)&&(p!=null||d!=null))switch(f){case"type":r=p;break;case"name":a=p;break;case"checked":c=p;break;case"defaultChecked":u=p;break;case"value":s=p;break;case"defaultValue":i=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(O(137,t));break;default:p!==d&&Ie(e,t,f,p,o,d)}}p1(e,s,i,l,c,u,r,a);return;case"select":p=s=i=f=null;for(r in n)if(l=n[r],n.hasOwnProperty(r)&&l!=null)switch(r){case"value":break;case"multiple":p=l;default:o.hasOwnProperty(r)||Ie(e,t,r,null,o,l)}for(a in o)if(r=o[a],l=n[a],o.hasOwnProperty(a)&&(r!=null||l!=null))switch(a){case"value":f=r;break;case"defaultValue":i=r;break;case"multiple":s=r;default:r!==l&&Ie(e,t,a,r,o,l)}t=i,n=s,o=p,f!=null?Cl(e,!!n,f,!1):!!o!=!!n&&(t!=null?Cl(e,!!n,t,!0):Cl(e,!!n,n?[]:"",!1));return;case"textarea":p=f=null;for(i in n)if(a=n[i],n.hasOwnProperty(i)&&a!=null&&!o.hasOwnProperty(i))switch(i){case"value":break;case"children":break;default:Ie(e,t,i,null,o,a)}for(s in o)if(a=o[s],r=n[s],o.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(O(91));break;default:a!==r&&Ie(e,t,s,a,o,r)}aw(e,f,p);return;case"option":for(var h in n)if(f=n[h],n.hasOwnProperty(h)&&f!=null&&!o.hasOwnProperty(h))switch(h){case"selected":e.selected=!1;break;default:Ie(e,t,h,null,o,f)}for(l in o)if(f=o[l],p=n[l],o.hasOwnProperty(l)&&f!==p&&(f!=null||p!=null))switch(l){case"selected":e.selected=f&&typeof f!="function"&&typeof f!="symbol";break;default:Ie(e,t,l,f,o,p)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var m in n)f=n[m],n.hasOwnProperty(m)&&f!=null&&!o.hasOwnProperty(m)&&Ie(e,t,m,null,o,f);for(c in o)if(f=o[c],p=n[c],o.hasOwnProperty(c)&&f!==p&&(f!=null||p!=null))switch(c){case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(O(137,t));break;default:Ie(e,t,c,f,o,p)}return;default:if(ab(t)){for(var x in n)f=n[x],n.hasOwnProperty(x)&&f!==void 0&&!o.hasOwnProperty(x)&&G1(e,t,x,void 0,o,f);for(u in o)f=o[u],p=n[u],!o.hasOwnProperty(u)||f===p||f===void 0&&p===void 0||G1(e,t,u,f,o,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&f!=null&&!o.hasOwnProperty(y)&&Ie(e,t,y,null,o,f);for(d in o)f=o[d],p=n[d],!o.hasOwnProperty(d)||f===p||f==null&&p==null||Ie(e,t,d,f,o,p)}function A_(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function tN(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),o=0;o<n.length;o++){var a=n[o],r=a.transferSize,s=a.initiatorType,i=a.duration;if(r&&i&&A_(s)){for(s=0,i=a.responseEnd,o+=1;o<n.length;o++){var l=n[o],c=l.startTime;if(c>i)break;var u=l.transferSize,d=l.initiatorType;u&&A_(d)&&(l=l.responseEnd,s+=u*(l<i?1:(i-c)/(l-c)))}if(--o,t+=8*(r+s)/(a.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var W1=null,q1=null;function e0(e){return e.nodeType===9?e:e.ownerDocument}function v_(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function uE(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function V1(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var t1=null;function nN(){var e=window.event;return e&&e.type==="popstate"?e===t1?!1:(t1=e,!0):(t1=null,!1)}var dE=typeof setTimeout=="function"?setTimeout:void 0,oN=typeof clearTimeout=="function"?clearTimeout:void 0,S_=typeof Promise=="function"?Promise:void 0,aN=typeof queueMicrotask=="function"?queueMicrotask:typeof S_<"u"?function(e){return S_.resolve(null).then(e).catch(rN)}:dE;function rN(e){setTimeout(function(){throw e})}function Hr(e){return e==="head"}function L_(e,t){var n=t,o=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"||n==="/&"){if(o===0){e.removeChild(a),Vl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")Ku(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Ku(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[md]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&Ku(e.ownerDocument.body);n=a}while(n);Vl(t)}function k_(e,t){var n=e;e=0;do{var o=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=o}while(n)}function j1(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":j1(n),ob(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function sN(e,t,n,o){for(;e.nodeType===1;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[md])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(r=e.getAttribute("rel"),r==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(a.href==null||a.href===""?null:a.href)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||e.getAttribute("title")!==(a.title==null?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(r=e.getAttribute("src"),(r!==(a.src==null?null:a.src)||e.getAttribute("type")!==(a.type==null?null:a.type)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&e.getAttribute("name")===r)return e}else return e;if(e=$n(e.nextSibling),e===null)break}return null}function iN(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=$n(e.nextSibling),e===null))return null;return e}function fE(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=$n(e.nextSibling),e===null))return null;return e}function Z1(e){return e.data==="$?"||e.data==="$~"}function X1(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function lN(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var o=function(){t(),n.removeEventListener("DOMContentLoaded",o)};n.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function $n(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Y1=null;function __(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return $n(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function w_(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function pE(e,t,n){switch(t=e0(n),e){case"html":if(e=t.documentElement,!e)throw Error(O(452));return e;case"head":if(e=t.head,!e)throw Error(O(453));return e;case"body":if(e=t.body,!e)throw Error(O(454));return e;default:throw Error(O(451))}}function Ku(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ob(e)}var Qn=new Map,T_=new Set;function t0(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pa=_e.d;_e.d={f:cN,r:uN,D:dN,C:fN,L:pN,m:hN,X:yN,S:mN,M:gN};function cN(){var e=Pa.f(),t=x0();return e||t}function uN(e){var t=Zl(e);t!==null&&t.tag===5&&t.type==="form"?sT(t):Pa.r(e)}var $l=typeof document>"u"?null:document;function hE(e,t,n){var o=$l;if(o&&typeof t=="string"&&t){var a=Zn(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),T_.has(a)||(T_.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function dN(e){Pa.D(e),hE("dns-prefetch",e,null)}function fN(e,t){Pa.C(e,t),hE("preconnect",e,t)}function pN(e,t,n){Pa.L(e,t,n);var o=$l;if(o&&e&&t){var a='link[rel="preload"][as="'+Zn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+Zn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+Zn(n.imageSizes)+'"]')):a+='[href="'+Zn(e)+'"]';var r=a;switch(t){case"style":r=ql(e);break;case"script":r=Ql(e)}Qn.has(r)||(e=qe({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Qn.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(vd(r))||t==="script"&&o.querySelector(Sd(r))||(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function hN(e,t){Pa.m(e,t);var n=$l;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+Zn(o)+'"][href="'+Zn(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Ql(e)}if(!Qn.has(r)&&(e=qe({rel:"modulepreload",href:e},t),Qn.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Sd(r)))return}o=n.createElement("link"),Dt(o,"link",e),kt(o),n.head.appendChild(o)}}}function mN(e,t,n){Pa.S(e,t,n);var o=$l;if(o&&e){var a=El(o).hoistableStyles,r=ql(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(vd(r)))i.loading=5;else{e=qe({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Qn.get(r))&&Gb(e,n);var l=s=o.createElement("link");kt(l),Dt(l,"link",e),l._p=new Promise(function(c,u){l.onload=c,l.onerror=u}),l.addEventListener("load",function(){i.loading|=1}),l.addEventListener("error",function(){i.loading|=2}),i.loading|=4,Tm(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function yN(e,t){Pa.X(e,t);var n=$l;if(n&&e){var o=El(n).hoistableScripts,a=Ql(e),r=o.get(a);r||(r=n.querySelector(Sd(a)),r||(e=qe({src:e,async:!0},t),(t=Qn.get(a))&&Wb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function gN(e,t){Pa.M(e,t);var n=$l;if(n&&e){var o=El(n).hoistableScripts,a=Ql(e),r=o.get(a);r||(r=n.querySelector(Sd(a)),r||(e=qe({src:e,async:!0,type:"module"},t),(t=Qn.get(a))&&Wb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function E_(e,t,n,o){var a=(a=wr.current)?t0(a):null;if(!a)throw Error(O(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=ql(n.href),n=El(a).hoistableStyles,o=n.get(t),o||(o={type:"style",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=ql(n.href);var r=El(a).hoistableStyles,s=r.get(e);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(e,s),(r=a.querySelector(vd(e)))&&!r._p&&(s.instance=r,s.state.loading=5),Qn.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Qn.set(e,n),r||xN(a,e,n,s.state))),t&&o===null)throw Error(O(528,""));return s}if(t&&o!==null)throw Error(O(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ql(n),n=El(a).hoistableScripts,o=n.get(t),o||(o={type:"script",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(O(444,e))}}function ql(e){return'href="'+Zn(e)+'"'}function vd(e){return'link[rel="stylesheet"]['+e+"]"}function mE(e){return qe({},e,{"data-precedence":e.precedence,precedence:null})}function xN(e,t,n,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),Dt(t,"link",n),kt(t),e.head.appendChild(t))}function Ql(e){return'[src="'+Zn(e)+'"]'}function Sd(e){return"script[async]"+e}function C_(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Zn(n.href)+'"]');if(o)return t.instance=o,kt(o),o;var a=qe({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),kt(o),Dt(o,"style",a),Tm(o,n.precedence,e),t.instance=o;case"stylesheet":a=ql(n.href);var r=e.querySelector(vd(a));if(r)return t.state.loading|=4,t.instance=r,kt(r),r;o=mE(n),(a=Qn.get(a))&&Gb(o,a),r=(e.ownerDocument||e).createElement("link"),kt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(r,"link",o),t.state.loading|=4,Tm(r,n.precedence,e),t.instance=r;case"script":return r=Ql(n.src),(a=e.querySelector(Sd(r)))?(t.instance=a,kt(a),a):(o=n,(a=Qn.get(r))&&(o=qe({},n),Wb(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),kt(a),Dt(a,"link",o),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(O(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,Tm(o,n.precedence,e));return t.instance}function Tm(e,t,n){for(var o=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=o.length?o[o.length-1]:null,r=a,s=0;s<o.length;s++){var i=o[s];if(i.dataset.precedence===t)r=i;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Gb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Wb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Em=null;function I_(e,t,n){if(Em===null){var o=new Map,a=Em=new Map;a.set(n,o)}else a=Em,o=a.get(n),o||(o=new Map,a.set(n,o));if(o.has(e))return o;for(o.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var r=n[a];if(!(r[md]||r[Mt]||e==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(t)||"";s=e+s;var i=o.get(s);i?i.push(r):o.set(s,[r])}}return o}function M_(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function bN(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function yE(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function AN(e,t,n,o){if(n.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var a=ql(o.href),r=t.querySelector(vd(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=n0.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,kt(r);return}r=t.ownerDocument||t,o=mE(o),(a=Qn.get(a))&&Gb(o,a),r=r.createElement("link"),kt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(r,"link",o),n.instance=r}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=n0.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var n1=0;function vN(e,t){return e.stylesheets&&e.count===0&&Cm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&Cm(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&n1===0&&(n1=62500*tN());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Cm(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>n1?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function n0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Cm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var o0=null;function Cm(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,o0=new Map,t.forEach(SN,e),o0=null,n0.call(e))}function SN(e,t){if(!(t.state.loading&4)){var n=o0.get(e);if(n)var o=n.get(null);else{n=new Map,o0.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),o=s)}o&&n.set(null,o)}a=t.instance,s=a.getAttribute("data-precedence"),r=n.get(s)||o,r===o&&n.set(null,a),n.set(s,a),this.count++,o=n0.bind(this),a.addEventListener("load",o),a.addEventListener("error",o),r?r.parentNode.insertBefore(a,r.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(a,e.firstChild)),t.state.loading|=4}}var ld={$$typeof:ka,Provider:null,Consumer:null,_currentValue:Ds,_currentValue2:Ds,_threadCount:0};function LN(e,t,n,o,a,r,s,i,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ex(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ex(0),this.hiddenUpdates=Ex(null),this.identifierPrefix=o,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function gE(e,t,n,o,a,r,s,i,l,c,u,d){return e=new LN(e,t,n,s,l,c,u,d,i),t=1,r===!0&&(t|=24),r=vn(3,null,null,t),e.current=r,r.stateNode=e,t=mb(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},xb(r),e}function xE(e){return e?(e=kl,e):kl}function bE(e,t,n,o,a,r){a=xE(a),o.context===null?o.context=a:o.pendingContext=a,o=Er(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=Cr(e,o,t),n!==null&&(on(n,e,t),Gu(n,e,t))}function R_(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function qb(e,t){R_(e,t),(e=e.alternate)&&R_(e,t)}function AE(e){if(e.tag===13||e.tag===31){var t=Zs(e,67108864);t!==null&&on(t,e,67108864),qb(e,67108864)}}function O_(e){if(e.tag===13||e.tag===31){var t=wn();t=tb(t);var n=Zs(e,t);n!==null&&on(n,e,t),qb(e,t)}}var a0=!0;function kN(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=2,Vb(e,t,n,o)}finally{_e.p=r,K.T=a}}function _N(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=8,Vb(e,t,n,o)}finally{_e.p=r,K.T=a}}function Vb(e,t,n,o){if(a0){var a=K1(o);if(a===null)e1(e,t,o,r0,n),D_(e,o);else if(TN(a,e,t,n,o))o.stopPropagation();else if(D_(e,o),t&4&&-1<wN.indexOf(e)){for(;a!==null;){var r=Zl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=Ms(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-_n(s);i.entanglements[1]|=l,s&=~l}Wo(r),(ke&6)===0&&(Xm=Ln()+500,Ad(0,!1))}}break;case 31:case 13:i=Zs(r,2),i!==null&&on(i,r,2),x0(),qb(r,2)}if(r=K1(o),r===null&&e1(e,t,o,r0,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else e1(e,t,o,null,n)}}function K1(e){return e=rb(e),jb(e)}var r0=null;function jb(e){if(r0=null,e=xl(e),e!==null){var t=dd(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=H_(t),e!==null)return e;e=null}else if(n===31){if(e=U_(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return r0=e,null}function vE(e){switch(e){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(p7()){case V_:return 2;case j_:return 8;case Dm:case h7:return 32;case Z_:return 268435456;default:return 32}default:return 32}}var $1=!1,Rr=null,Or=null,Dr=null,cd=new Map,ud=new Map,Ar=[],wN="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".split(" ");function D_(e,t){switch(e){case"focusin":case"focusout":Rr=null;break;case"dragenter":case"dragleave":Or=null;break;case"mouseover":case"mouseout":Dr=null;break;case"pointerover":case"pointerout":cd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ud.delete(t.pointerId)}}function Mu(e,t,n,o,a,r){return e===null||e.nativeEvent!==r?(e={blockedOn:t,domEventName:n,eventSystemFlags:o,nativeEvent:r,targetContainers:[a]},t!==null&&(t=Zl(t),t!==null&&AE(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function TN(e,t,n,o,a){switch(t){case"focusin":return Rr=Mu(Rr,e,t,n,o,a),!0;case"dragenter":return Or=Mu(Or,e,t,n,o,a),!0;case"mouseover":return Dr=Mu(Dr,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return cd.set(r,Mu(cd.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,ud.set(r,Mu(ud.get(r)||null,e,t,n,o,a)),!0}return!1}function SE(e){var t=xl(e.target);if(t!==null){var n=dd(t);if(n!==null){if(t=n.tag,t===13){if(t=H_(n),t!==null){e.blockedOn=t,gk(e.priority,function(){O_(n)});return}}else if(t===31){if(t=U_(n),t!==null){e.blockedOn=t,gk(e.priority,function(){O_(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Im(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=K1(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);m1=o,n.target.dispatchEvent(o),m1=null}else return t=Zl(n),t!==null&&AE(t),e.blockedOn=n,!1;t.shift()}return!0}function P_(e,t,n){Im(e)&&n.delete(t)}function EN(){$1=!1,Rr!==null&&Im(Rr)&&(Rr=null),Or!==null&&Im(Or)&&(Or=null),Dr!==null&&Im(Dr)&&(Dr=null),cd.forEach(P_),ud.forEach(P_)}function hm(e,t){e.blockedOn===t&&(e.blockedOn=null,$1||($1=!0,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,EN)))}var mm=null;function B_(e){mm!==e&&(mm=e,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,function(){mm===e&&(mm=null);for(var t=0;t<e.length;t+=3){var n=e[t],o=e[t+1],a=e[t+2];if(typeof o!="function"){if(jb(o||n)===null)continue;break}var r=Zl(n);r!==null&&(e.splice(t,3),t-=3,M1(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function Vl(e){function t(l){return hm(l,e)}Rr!==null&&hm(Rr,e),Or!==null&&hm(Or,e),Dr!==null&&hm(Dr,e),cd.forEach(t),ud.forEach(t);for(var n=0;n<Ar.length;n++){var o=Ar[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Ar.length&&(n=Ar[0],n.blockedOn===null);)SE(n),n.blockedOn===null&&Ar.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(o=0;o<n.length;o+=3){var a=n[o],r=n[o+1],s=a[an]||null;if(typeof r=="function")s||B_(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[an]||null)i=s.formAction;else if(jb(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),B_(n)}}}function LE(){function e(r){r.canIntercept&&r.info==="react-transition"&&r.intercept({handler:function(){return new Promise(function(s){return a=s})},focusReset:"manual",scroll:"manual"})}function t(){a!==null&&(a(),a=null),o||setTimeout(n,20)}function n(){if(!o&&!navigation.transition){var r=navigation.currentEntry;r&&r.url!=null&&navigation.navigate(r.url,{state:r.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),a!==null&&(a(),a=null)}}}function Zb(e){this._internalRoot=e}v0.prototype.render=Zb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=wn();bE(n,o,e,t,null,null)};v0.prototype.unmount=Zb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;bE(e.current,2,null,e,null,null),x0(),t[jl]=null}};function v0(e){this._internalRoot=e}v0.prototype.unstable_scheduleHydration=function(e){if(e){var t=Q_();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ar.length&&t!==0&&t<Ar[n].priority;n++);Ar.splice(n,0,e),n===0&&SE(e)}};var N_=z_.version;if(N_!=="19.2.6")throw Error(O(527,N_,"19.2.6"));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=s7(t),e=e!==null?G_(e):null,e=e===null?null:e.stateNode,e};var CN={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(Ru=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Ru.isDisabled&&Ru.supportsFiber))try{fd=Ru.inject(CN),kn=Ru}catch{}var Ru;S0.createRoot=function(e,t){if(!F_(e))throw Error(O(299));var n=!1,o="",a=hT,r=mT,s=yT;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(r=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=gE(e,1,!1,null,null,n,o,null,a,r,s,LE),e[jl]=t.current,Ub(e),new Zb(t)};S0.hydrateRoot=function(e,t,n){if(!F_(e))throw Error(O(299));var o=!1,a="",r=hT,s=mT,i=yT,l=null;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onUncaughtError!==void 0&&(r=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(i=n.onRecoverableError),n.formState!==void 0&&(l=n.formState)),t=gE(e,1,!0,t,n??null,o,a,l,r,s,i,LE),t.context=xE(null),n=t.current,o=wn(),o=tb(o),a=Er(o),a.callback=null,Cr(n,a,o),n=o,t.current.lanes=n,hd(t,n),Wo(t),e[jl]=t.current,Ub(e),new v0(t)};S0.version="19.2.6"});var TE=Ut((ZQ,wE)=>{"use strict";function _E(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_E)}catch(e){console.error(e)}}_E(),wE.exports=kE()});var CE=Ut(L0=>{"use strict";var IN=Symbol.for("react.transitional.element"),MN=Symbol.for("react.fragment");function EE(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var a in t)a!=="key"&&(n[a]=t[a])}else n=t;return t=n.ref,{$$typeof:IN,type:e,key:o,ref:t!==void 0?t:null,props:n}}L0.Fragment=MN;L0.jsx=EE;L0.jsxs=EE});var se=Ut((YQ,IE)=>{"use strict";IE.exports=CE()});var b3=Ut(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.loop=Ls.conditional=Ls.parse=void 0;var N$=function e(t,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:o;if(Array.isArray(n))n.forEach(function(s){return e(t,s,o,a)});else if(typeof n=="function")n(t,o,a,e);else{var r=Object.keys(n)[0];Array.isArray(n[r])?(a[r]={},e(t,n[r],o,a[r])):a[r]=n[r](t,o,a,e)}return o};Ls.parse=N$;var z$=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Ls.conditional=z$;var F$=function(t,n){return function(o,a,r,s){for(var i=[],l=o.pos;n(o,a,r);){var c={};if(s(o,t,a,c),o.pos===l)break;l=o.pos,i.push(c)}return i}};Ls.loop=F$});var A3=Ut(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.readBits=ft.readArray=ft.readUnsigned=ft.readString=ft.peekBytes=ft.readBytes=ft.peekByte=ft.readByte=ft.buildStream=void 0;var H$=function(t){return{data:t,pos:0}};ft.buildStream=H$;var aP=function(){return function(t){return t.data[t.pos++]}};ft.readByte=aP;var U$=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};ft.peekByte=U$;var ex=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};ft.readBytes=ex;var G$=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};ft.peekBytes=G$;var W$=function(t){return function(n){return Array.from(ex(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};ft.readString=W$;var q$=function(t){return function(n){var o=ex(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};ft.readUnsigned=q$;var V$=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=ex(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};ft.readArray=V$;var j$=function(t,n,o){for(var a=0,r=0;r<o;r++)a+=t[n+r]&&Math.pow(2,o-r-1);return a},Z$=function(t){return function(n){for(var o=aP()(n),a=new Array(8),r=0;r<8;r++)a[7-r]=!!(o&1<<r);return Object.keys(t).reduce(function(s,i){var l=t[i];return l.length?s[i]=j$(a,l.index,l.length):s[i]=a[l.index],s},{})}};ft.readBits=Z$});var rP=Ut(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});nx.default=void 0;var ks=b3(),ce=A3(),tx={blocks:function(t){for(var n=0,o=[],a=t.data.length,r=0,s=(0,ce.readByte)()(t);s!==n&&s;s=(0,ce.readByte)()(t)){if(t.pos+s>=a){var i=a-t.pos;o.push((0,ce.readBytes)(i)(t)),r+=i;break}o.push((0,ce.readBytes)(s)(t)),r+=s}for(var l=new Uint8Array(r),c=0,u=0;u<o.length;u++)l.set(o[u],c),c+=o[u].length;return l}},X$=(0,ks.conditional)({gce:[{codes:(0,ce.readBytes)(2)},{byteSize:(0,ce.readByte)()},{extras:(0,ce.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,ce.readUnsigned)(!0)},{transparentColorIndex:(0,ce.readByte)()},{terminator:(0,ce.readByte)()}]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===249}),Y$=(0,ks.conditional)({image:[{code:(0,ce.readByte)()},{descriptor:[{left:(0,ce.readUnsigned)(!0)},{top:(0,ce.readUnsigned)(!0)},{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{lct:(0,ce.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,ks.conditional)({lct:(0,ce.readArray)(3,function(e,t,n){return Math.pow(2,n.descriptor.lct.size+1)})},function(e,t,n){return n.descriptor.lct.exists}),{data:[{minCodeSize:(0,ce.readByte)()},tx]}]},function(e){return(0,ce.peekByte)()(e)===44}),K$=(0,ks.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),$$=(0,ks.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),Q$=(0,ks.conditional)({comment:[{codes:(0,ce.readBytes)(2)},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),J$=[{header:[{signature:(0,ce.readString)(3)},{version:(0,ce.readString)(3)}]},{lsd:[{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{gct:(0,ce.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,ce.readByte)()},{pixelAspectRatio:(0,ce.readByte)()}]},(0,ks.conditional)({gct:(0,ce.readArray)(3,function(e,t){return Math.pow(2,t.lsd.gct.size+1)})},function(e,t){return t.lsd.gct.exists}),{frames:(0,ks.loop)([X$,$$,Q$,Y$,K$],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],eQ=J$;nx.default=eQ});var sP=Ut(ox=>{"use strict";Object.defineProperty(ox,"__esModule",{value:!0});ox.deinterlace=void 0;var tQ=function(t,n){for(var o=new Array(t.length),a=t.length/n,r=function(f,p){var h=t.slice(p*n,(p+1)*n);o.splice.apply(o,[f*n,n].concat(h))},s=[0,4,2,1],i=[8,8,4,2],l=0,c=0;c<4;c++)for(var u=s[c];u<a;u+=i[c])r(u,l),l++;return o};ox.deinterlace=tQ});var iP=Ut(ax=>{"use strict";Object.defineProperty(ax,"__esModule",{value:!0});ax.lzw=void 0;var nQ=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,C,h,m,_,x,L,k,B,M,y=new Array(o),g=new Array(a),b=new Array(a),A=new Array(a+1);for(x=t,l=1<<x,d=l+1,i=l+2,p=r,u=x+1,c=(1<<u)-1,h=0;h<l;h++)g[h]=0,b[h]=h;var _,C,w,L,k,M,B;for(_=C=w=L=k=M=B=0,m=0;m<s;){if(k===0){if(C<u){_+=n[B]<<C,C+=8,B++;continue}if(h=_&c,_>>=u,C-=u,h>i||h==d)break;if(h==l){u=x+1,c=(1<<u)-1,i=l+2,p=r;continue}if(p==r){A[k++]=b[h],p=h,L=h;continue}for(f=h,h==i&&(A[k++]=L,h=p);h>l;)A[k++]=b[h],h=g[h];L=b[h]&255,A[k++]=L,i<a&&(g[i]=p,b[i]=L,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}k--,y[M++]=A[k],m++}for(m=M;m<s;m++)y[m]=0;return y};ax.lzw=nQ});var cP=Ut(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.decompressFrames=_s.decompressFrame=_s.parseGIF=void 0;var oQ=lQ(rP()),aQ=b3(),rQ=A3(),sQ=sP(),iQ=iP();function lQ(e){return e&&e.__esModule?e:{default:e}}var cQ=function(t){var n=new Uint8Array(t);return(0,aQ.parse)((0,rQ.buildStream)(n),oQ.default)};_s.parseGIF=cQ;var uQ=function(t){for(var n=t.pixels.length,o=new Uint8ClampedArray(n*4),a=0;a<n;a++){var r=a*4,s=t.pixels[a],i=t.colorTable[s]||[0,0,0];o[r]=i[0],o[r+1]=i[1],o[r+2]=i[2],o[r+3]=s!==t.transparentIndex?255:0}return o},lP=function(t,n,o){if(!t.image){console.warn("gif frame does not have associated image.");return}var a=t.image,r=a.descriptor.width*a.descriptor.height,s=(0,iQ.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,sQ.deinterlace)(s,a.descriptor.width));var i={pixels:s,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return a.descriptor.lct&&a.descriptor.lct.exists?i.colorTable=a.lct:i.colorTable=n,t.gce&&(i.delay=(t.gce.delay||10)*10,i.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(i.transparentIndex=t.gce.transparentColorIndex)),o&&(i.patch=uQ(i)),i};_s.decompressFrame=lP;var dQ=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return lP(o,t.gct,n)})};_s.decompressFrames=dQ});var AP=P(TE(),1);var R=P(se(),1),ye=P(re(),1);var w0=P(re(),1);var k0=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var ME=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var RE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var Xb=e=>{let t=RE(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Ld=P(re(),1);var _0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var OE=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Jl=P(re(),1);var RN=(0,Jl.createContext)({});var DE=()=>(0,Jl.useContext)(RN);var PE=(0,Ld.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:o,className:a="",children:r,iconNode:s,...i},l)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f="currentColor",className:p=""}=DE()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,Ld.createElement)("svg",{ref:l,..._0,width:t??c??_0.width,height:t??c??_0.height,stroke:e??f,strokeWidth:h,className:k0("lucide",p,a),...!r&&!OE(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,x])=>(0,Ld.createElement)(m,x)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,w0.forwardRef)(({className:o,...a},r)=>(0,w0.createElement)(PE,{ref:r,iconNode:t,className:k0(`lucide-${ME(Xb(e))}`,`lucide-${e}`,o),...a}));return n.displayName=Xb(e),n};var ON=[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]],kd=E("align-center-horizontal",ON);var DN=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],ec=E("align-center-vertical",DN);var PN=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]],_d=E("align-end-horizontal",PN);var BN=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],wd=E("align-end-vertical",BN);var NN=[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]],Td=E("align-horizontal-distribute-center",NN);var zN=[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]],Ed=E("align-start-horizontal",zN);var FN=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],Cd=E("align-start-vertical",FN);var HN=[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]],Id=E("align-vertical-distribute-center",HN);var UN=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Md=E("bold",UN);var GN=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Rd=E("case-sensitive",GN);var WN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Od=E("check",WN);var qN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Dd=E("chevron-down",qN);var VN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ys=E("chevron-right",VN);var jN=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Pd=E("chevrons-down",jN);var ZN=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Bd=E("chevrons-up",ZN);var XN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Cn=E("circle-question-mark",XN);var YN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ks=E("circle",YN);var KN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],Nd=E("clipboard",KN);var $N=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ur=E("copy",$N);var QN=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],zd=E("crop",QN);var JN=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Fd=E("delete",JN);var ez=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],Hd=E("diamond",ez);var tz=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],tc=E("download",tz);var nz=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Gr=E("ellipsis-vertical",nz);var oz=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Wr=E("ellipsis",oz);var az=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],Ud=E("eraser",az);var rz=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Gd=E("external-link",rz);var sz=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Wd=E("file-down",sz);var iz=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],qd=E("file-up",iz);var lz=[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]],Vd=E("flip-horizontal-2",lz);var cz=[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]],jd=E("flip-vertical-2",cz);var uz=[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]],Zd=E("frame",uz);var dz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ao=E("grid-3x3",dz);var fz=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Xd=E("grip",fz);var pz=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],Yd=E("group",pz);var hz=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],Kd=E("hand",hz);var mz=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],$s=E("image-down",mz);var yz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Qs=E("image",yz);var gz=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],$d=E("italic",gz);var xz=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Qd=E("library",xz);var bz=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Jd=E("link",bz);var Az=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ef=E("locate-fixed",Az);var vz=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],tf=E("lock",vz);var Sz=[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]],nf=E("magnet",Sz);var Lz=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],nc=E("maximize",Lz);var kz=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],of=E("menu",kz);var _z=[["path",{d:"M5 12h14",key:"1ays0h"}]],Ba=E("minus",_z);var wz=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],af=E("monitor",wz);var Tz=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],rf=E("moon",Tz);var Ez=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],sf=E("mouse-pointer-2",Ez);var Cz=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],lf=E("mouse-pointer",Cz);var Iz=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],cf=E("move-down",Iz);var Mz=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],uf=E("move-right",Mz);var Rz=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],df=E("move-up",Rz);var Oz=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],qr=E("pen-line",Oz);var Dz=[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]],ff=E("pipette",Dz);var Pz=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Js=E("plus",Pz);var Bz=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],pf=E("radio",Bz);var Nz=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],ei=E("redo-2",Nz);var zz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],hf=E("rotate-ccw",zz);var Fz=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],mf=E("scissors",Fz);var Hz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yf=E("search",Hz);var Uz=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],gf=E("slash",Uz);var Gz=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],xf=E("spline",Gz);var Wz=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],Na=E("square-dashed",Wz);var qz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],za=E("square-dot",qz);var Vz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qo=E("square",Vz);var jz=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],bf=E("strikethrough",jz);var Zz=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Af=E("sun",Zz);var Xz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Vr=E("text-align-end",Xz);var Yz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],jr=E("text-align-center",Yz);var Kz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],vo=E("text-align-start",Kz);var $z=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],oc=E("trash-2",$z);var Qz=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],vf=E("type",Qz);var Jz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Sf=E("underline",Jz);var eF=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ti=E("undo-2",eF);var tF=[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]],Lf=E("ungroup",tF);var nF=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],kf=E("upload",nF);var oF=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],_f=E("waypoints",oF);var aF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Fa=E("x",aF);var rF=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],wf=E("zoom-out",rF);var sF=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Tf=E("zoom-in",sF);var iF=P(se(),1),So=P(re(),1),BE=(0,So.createContext)(null);var NE=BE;var Yb=()=>(0,So.useContext)(BE),sn=(e,t,n)=>{let o=Yb(),[a,r]=(0,So.useState)(()=>o?e(o):t),s=(0,So.useRef)(e);s.current=e;let i=(0,So.useRef)(t);return i.current=t,(0,So.useEffect)(()=>{if(!o){r(i.current);return}let l=()=>{let c=s.current(o);r(u=>Object.is(u,c)?u:c)};return l(),n!==void 0?o.on(n,l):o.subscribe(l)},[o,n]),a};var sA=P(se(),1);var ac=P(se(),1),et=P(re(),1),QE=P(ya(),1);var zE=P(se(),1),T0=P(re(),1),FE=(0,T0.createContext)(null),Ef=({container:e,children:t})=>(0,zE.jsx)(FE.Provider,{value:e,children:t}),Pt=()=>(0,T0.useContext)(FE)??document.body;var Kb=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],HE=8,UE=256,GE=160,WE=200,qE=150,$b=8,Qb=150,VE="#2563eb",jE=1.5,ZE="rgba(37, 99, 235, 0.12)",XE=1,Jb=10,eA=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}],YE=176,Cf=1,E0=40;var nA=new Set,If=null,Vo=null,jo=null,aA=0,oA=!1,lF=()=>{for(let e of nA)e(If)},C0=e=>{If=e,lF()},cF=e=>(nA.add(e),()=>{nA.delete(e)}),uF=e=>{if(oA)return;jo&&(clearTimeout(jo),jo=null),Vo&&clearTimeout(Vo);let t=Date.now()-aA;if(If!==null||t<600){C0(e);return}Vo=setTimeout(()=>{Vo=null,C0(e)},600)},KE=e=>{Vo&&(clearTimeout(Vo),Vo=null),If?.id===e&&(jo&&clearTimeout(jo),jo=setTimeout(()=>{jo=null,aA=Date.now(),C0(null)},80))},$E=()=>{Vo&&(clearTimeout(Vo),Vo=null),jo&&(clearTimeout(jo),jo=null),If&&(aA=Date.now(),C0(null))},rA=({children:e})=>((0,et.useEffect)(()=>{let t=()=>{oA=!0,$E()},n=()=>{oA=!1},o=a=>{a.key==="Escape"&&$E()};return document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointerup",n,{capture:!0}),document.addEventListener("keydown",o,{capture:!0}),()=>{document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointerup",n,{capture:!0}),document.removeEventListener("keydown",o,{capture:!0})}},[]),(0,ac.jsxs)(JE.Provider,{value:!0,children:[e,(0,ac.jsx)(fF,{})]})),JE=(0,et.createContext)(!1),dF=()=>(0,et.useContext)(JE),fF=()=>{let[e,t]=(0,et.useState)(null),n=Pt();return(0,et.useEffect)(()=>cF(t),[]),!e||typeof document>"u"?null:(0,QE.createPortal)((0,ac.jsx)(pF,{target:e}),n)},pF=({target:e})=>{let t=(0,et.useRef)(null),[n,o]=(0,et.useState)(null);(0,et.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let s=r.getBoundingClientRect(),{rect:i,side:l}=e,c=i.left+i.width/2-s.width/2,u=i.top+i.height/2-s.height/2;switch(l){case"top":u=i.top-s.height-6;break;case"bottom":u=i.bottom+6;break;case"left":c=i.left-s.width-6;break;case"right":c=i.right+6;break}let d=4;c=Math.max(d,Math.min(c,window.innerWidth-s.width-d)),u=Math.max(d,Math.min(u,window.innerHeight-s.height-d)),o({left:c,top:u})},[e]);let a={position:"fixed",left:n?.left??-9999,top:n?.top??-9999,pointerEvents:"none",zIndex:1e4,visibility:n?"visible":"hidden"};return(0,ac.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},ni=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,et.useId)();if(!dF()||n||e===void 0||e===null)return(0,et.isValidElement)(o)&&typeof e=="string"&&!n?(0,et.cloneElement)(o,{title:e}):o;if(!(0,et.isValidElement)(o))return o;let s=o,i=f=>{uF({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,et.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),KE(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),KE(a)},title:void 0})};var Jn=({label:e,active:t,size:n="default",className:o,children:a,...r})=>{let s=["du-icon-button",n==="sm"?"du-icon-button-sm":"",t?"is-active":"",o??""].filter(Boolean).join(" ");return(0,sA.jsx)(ni,{content:e,children:(0,sA.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var eC=P(se(),1),oi=({children:e,className:t,ariaLabel:n})=>(0,eC.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var iA=P(se(),1);var In=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,iA.jsx)(oi,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,iA.jsx)(Jn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var Mf=P(se(),1),Rf=({value:e,min:t,max:n,step:o=1,onChange:a,ariaLabel:r,valueLabel:s})=>{let i=c=>{a(Number(c.target.value))},l=e??(t+n)/2;return(0,Mf.jsxs)("div",{className:"du-slider",children:[(0,Mf.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,Mf.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var tC=P(se(),1),lA=({children:e,className:t,style:n})=>(0,tC.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var eo=P(se(),1),cA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]}),uA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]});var is=P(se(),1),BD=P(re(),1);var Ke=P(se(),1),Zc=P(re(),1);var I0="select";var Zo={};yo(Zo,{EMPTY:()=>Pe,add:()=>Xt,clear:()=>yF,equals:()=>ai,has:()=>hF,remove:()=>Pf,replace:()=>mF,single:()=>wt,toggle:()=>pA});var Ze=e=>e,dA=e=>e,ln=e=>e,Of=e=>e,rc=e=>e,fA=e=>e;var v=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Df=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var M0=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};var Pe=Object.freeze(new Set),wt=e=>new Set([e]),hF=(e,t)=>e.has(t),Xt=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Pf=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},pA=(e,t)=>e.has(t)?Pf(e,t):Xt(e,t),mF=e=>wt(e),yF=()=>Pe,ai=(e,t)=>M0(e,t);var W={};yo(W,{ZERO:()=>nC,add:()=>xF,angle:()=>CF,cross:()=>kF,distance:()=>_F,distanceSq:()=>rC,div:()=>vF,dot:()=>LF,equals:()=>OF,length:()=>aC,lengthSq:()=>oC,lerp:()=>TF,midpoint:()=>EF,mul:()=>AF,negate:()=>SF,normalize:()=>wF,of:()=>gF,perp:()=>RF,rotate:()=>IF,rotateAround:()=>MF,sub:()=>bF});var nC=Object.freeze({x:0,y:0}),gF=(e,t)=>({x:e,y:t}),xF=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),bF=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),AF=(e,t)=>({x:e.x*t,y:e.y*t}),vF=(e,t)=>({x:e.x/t,y:e.y/t}),SF=e=>({x:-e.x,y:-e.y}),LF=(e,t)=>e.x*t.x+e.y*t.y,kF=(e,t)=>e.x*t.y-e.y*t.x,oC=e=>e.x*e.x+e.y*e.y,aC=e=>Math.sqrt(oC(e)),rC=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},_F=(e,t)=>Math.sqrt(rC(e,t)),wF=e=>{let t=aC(e);return t===0?nC:{x:e.x/t,y:e.y/t}},TF=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),EF=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),CF=e=>Math.atan2(e.y,e.x),IF=(e,t)=>{let n=Math.cos(t),o=Math.sin(t);return{x:e.x*n-e.y*o,y:e.x*o+e.y*n}},MF=(e,t,n)=>{let o=Math.cos(n),a=Math.sin(n),r=e.x-t.x,s=e.y-t.y;return{x:t.x+(r*o-s*a),y:t.y+(r*a+s*o)}},RF=e=>({x:-e.y,y:e.x}),OF=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n;var sc={};yo(sc,{clamp:()=>DF,clamp01:()=>PF});var DF=(e,t,n)=>Math.max(t,Math.min(n,e)),PF=e=>e<0?0:e>1?1:e;var z={};yo(z,{IDENTITY:()=>BF,applyToBounds:()=>WF,applyToPoint:()=>Bf,decompose:()=>qF,equals:()=>VF,inverse:()=>GF,multiply:()=>UF,of:()=>NF,rotation:()=>HF,scaling:()=>FF,translation:()=>zF});var BF=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),NF=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),zF=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),FF=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),HF=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},UF=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),GF=e=>{let t=e.a*e.d-e.b*e.c;if(t===0)throw new Error("Cannot invert singular matrix");return{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,e:(e.c*e.f-e.d*e.e)/t,f:(e.b*e.e-e.a*e.f)/t}},Bf=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),WF=(e,t)=>{let n=Bf(e,{x:t.x,y:t.y}),o=Bf(e,{x:t.x+t.width,y:t.y}),a=Bf(e,{x:t.x,y:t.y+t.height}),r=Bf(e,{x:t.x+t.width,y:t.y+t.height}),s=Math.min(n.x,o.x,a.x,r.x),i=Math.min(n.y,o.y,a.y,r.y),l=Math.max(n.x,o.x,a.x,r.x),c=Math.max(n.y,o.y,a.y,r.y);return{x:s,y:i,width:l-s,height:c-i}},qF=e=>{let t=Math.sqrt(e.a*e.a+e.b*e.b),n=Math.sqrt(e.c*e.c+e.d*e.d),a=e.a*e.d-e.b*e.c<0?-n:n;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:t,y:a}}},VF=(e,t,n=0)=>{let o=["a","b","c","d","e","f"];return n===0?o.every(a=>e[a]===t[a]):o.every(a=>Math.abs(e[a]-t[a])<=n)};var j={};yo(j,{EMPTY:()=>sC,centerOf:()=>XF,contains:()=>mA,containsBounds:()=>$F,equals:()=>eH,expand:()=>QF,fromCenter:()=>ZF,fromPoints:()=>R0,intersection:()=>iC,intersects:()=>KF,isEmpty:()=>hA,maxX:()=>Zr,maxY:()=>Xr,normalize:()=>JF,of:()=>jF,union:()=>YF});var sC=Object.freeze({x:0,y:0,width:0,height:0}),jF=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),R0=e=>{if(e.length===0)return sC;let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e)r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>a&&(a=r.y);return{x:t,y:n,width:o-t,height:a-n}},ZF=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),XF=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Zr=e=>e.x+e.width,Xr=e=>e.y+e.height,hA=e=>e.width<=0||e.height<=0,YF=(e,t)=>{if(hA(e))return t;if(hA(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(Zr(e),Zr(t)),r=Math.max(Xr(e),Xr(t));return{x:n,y:o,width:a-n,height:r-o}},iC=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(Zr(e),Zr(t)),r=Math.min(Xr(e),Xr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},KF=(e,t)=>iC(e,t)!==null,mA=(e,t)=>t.x>=e.x&&t.x<=Zr(e)&&t.y>=e.y&&t.y<=Xr(e),$F=(e,t)=>t.x>=e.x&&t.y>=e.y&&Zr(t)<=Zr(e)&&Xr(t)<=Xr(e),QF=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),JF=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),eH=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n&&Math.abs(e.width-t.width)<=n&&Math.abs(e.height-t.height)<=n;var Ha={};yo(Ha,{distanceToSegment:()=>oH,distanceToSegmentSq:()=>ic,pointInPolygon:()=>nH,pointInRect:()=>tH,pointOnPolyline:()=>aH,pointOnSegment:()=>lC});var tH=(e,t)=>mA(t,e),nH=(e,t)=>{if(t.length<3)return!1;let n=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){let r=t[o],s=t[a];if(!r||!s)continue;r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},ic=(e,t,n)=>{let o=n.x-t.x,a=n.y-t.y,r=o*o+a*a;if(r===0){let d=e.x-t.x,f=e.y-t.y;return d*d+f*f}let s=((e.x-t.x)*o+(e.y-t.y)*a)/r;s<0?s=0:s>1&&(s=1);let i=t.x+s*o,l=t.y+s*a,c=e.x-i,u=e.y-l;return c*c+u*u},oH=(e,t,n)=>Math.sqrt(ic(e,t,n)),lC=(e,t,n,o=1)=>ic(e,t,n)<=o*o,aH=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&lC(e,a,r,n))return!0}return!1};var cn={};yo(cn,{cubicAt:()=>si,cubicBounds:()=>sH,flattenCubic:()=>uH,flattenQuadratic:()=>cH,pointOnCubic:()=>lH,pointOnQuadratic:()=>iH,quadraticAt:()=>ri,quadraticBounds:()=>rH});var ri=(e,t,n,o)=>{let a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}},si=(e,t,n,o,a)=>{let r=1-a,s=r*r,i=s*r,l=a*a,c=l*a;return{x:i*e.x+3*s*a*t.x+3*r*l*n.x+c*o.x,y:i*e.y+3*s*a*t.y+3*r*l*n.y+c*o.y}},rH=(e,t,n)=>{let o=[e,n];for(let a of cC(e.x,t.x,n.x))o.push(ri(e,t,n,a));for(let a of cC(e.y,t.y,n.y))o.push(ri(e,t,n,a));return R0(o)},sH=(e,t,n,o)=>{let a=[e,o];for(let r of uC(e.x,t.x,n.x,o.x))a.push(si(e,t,n,o,r));for(let r of uC(e.y,t.y,n.y,o.y))a.push(si(e,t,n,o,r));return R0(a)},iH=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=ri(t,n,o,l/r);if(ic(e,i,c)<=s)return!0;i=c}return!1},lH=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=si(t,n,o,a,c/s);if(ic(e,l,u)<=i)return!0;l=u}return!1},cH=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=ri(e,t,n,r/o);return a},uH=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=si(e,t,n,o,s/a);return r},cC=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},uC=(e,t,n,o)=>{let a=-e+3*t-3*n+o,r=2*(e-2*t+n),s=t-e,i=[];if(Math.abs(a)<1e-12){if(Math.abs(r)>1e-12){let f=-s/r;f>0&&f<1&&i.push(f)}return i}let l=r*r-4*a*s;if(l<0)return i;let c=Math.sqrt(l),u=(-r+c)/(2*a),d=(-r-c)/(2*a);return u>0&&u<1&&i.push(u),d>0&&d<1&&i.push(d),i};var D0={};yo(D0,{lineLine:()=>dH,segmentCubic:()=>pH,segmentQuadratic:()=>fH,segmentSegment:()=>dC});var O0=1e-12,dH=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<O0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l;return{x:e.x+d*a,y:e.y+d*r}},dC=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<O0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l,f=(c*r-u*a)/l;return d<0||d>1||f<0||f>1?null:{x:e.x+d*a,y:e.y+d*r}},fH=(e,t,n,o,a)=>{let r=t.y-e.y,s=-(t.x-e.x),i=-(r*e.x+s*e.y),l=r*n.x+s*n.y,c=r*o.x+s*o.y,u=r*a.x+s*a.y,d=l-2*c+u,f=-2*l+2*c,p=l+i,h=[];if(Math.abs(d)<O0){if(Math.abs(f)>O0){let b=-p/f;b>=0&&b<=1&&h.push(b)}}else{let b=f*f-4*d*p;if(b>=0){let A=Math.sqrt(b),_=(-f+A)/(2*d),C=(-f-A)/(2*d);_>=0&&_<=1&&h.push(_),C>=0&&C<=1&&h.push(C)}}let m=[],x=t.x-e.x,y=t.y-e.y,g=x*x+y*y;for(let b of h){let A=ri(n,o,a,b);if(g===0){m.push(A);continue}let _=((A.x-e.x)*x+(A.y-e.y)*y)/g;_>=0&&_<=1&&m.push(A)}return m},pH=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=si(n,o,a,r,c/s),d=dC(e,t,l,u);d!==null&&i.push(d),l=u}return i};var P0={};yo(P0,{contrastRatio:()=>bA,format:()=>yH,luminance:()=>xA,meetsContrastAA:()=>bH,meetsContrastAAA:()=>AH,mix:()=>gH,parse:()=>mH,withAlpha:()=>xH});var hH=Object.freeze({transparent:{r:0,g:0,b:0,a:0},black:{r:0,g:0,b:0,a:1},white:{r:255,g:255,b:255,a:1},red:{r:255,g:0,b:0,a:1},green:{r:0,g:128,b:0,a:1},blue:{r:0,g:0,b:255,a:1},yellow:{r:255,g:255,b:0,a:1},cyan:{r:0,g:255,b:255,a:1},magenta:{r:255,g:0,b:255,a:1},gray:{r:128,g:128,b:128,a:1},grey:{r:128,g:128,b:128,a:1}}),mH=e=>{let t=e.trim().toLowerCase(),n=hH[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=Yr(a.charAt(0)+a.charAt(0)),s=Yr(a.charAt(1)+a.charAt(1)),i=Yr(a.charAt(2)+a.charAt(2)),l=a.length===4?Yr(a.charAt(3)+a.charAt(3))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}if(a.length===6||a.length===8){let r=Yr(a.slice(0,2)),s=Yr(a.slice(2,4)),i=Yr(a.slice(4,6)),l=a.length===8?Yr(a.slice(6,8))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Invalid hex color length: ${e}`)}let o=/^rgba?\(([^)]+)\)$/.exec(t);if(o){let a=(o[1]??"").split(",").map(c=>c.trim());if(a.length!==3&&a.length!==4)throw new Error(`Expected 3 or 4 components: ${e}`);let r=Math.round(Number(a[0])),s=Math.round(Number(a[1])),i=Math.round(Number(a[2])),l=a.length===4?Number(a[3]):1;if([r,s,i,l].some(Number.isNaN))throw new Error(`Invalid component: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Cannot parse color: ${e}`)},yH=e=>{let t=yA(e.r),n=yA(e.g),o=yA(e.b),a=vH(e.a);return a===1?`#${gA(t)}${gA(n)}${gA(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},gH=(e,t,n)=>({r:e.r+(t.r-e.r)*n,g:e.g+(t.g-e.g)*n,b:e.b+(t.b-e.b)*n,a:e.a+(t.a-e.a)*n}),xH=(e,t)=>({...e,a:t}),xA=e=>{let t=n=>{let o=n/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)},bA=(e,t)=>{let n=xA(e),o=xA(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},bH=(e,t,n=!1)=>bA(e,t)>=(n?3:4.5),AH=(e,t,n=!1)=>bA(e,t)>=(n?4.5:7),Yr=e=>parseInt(e,16),yA=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},vH=e=>e<0?0:e>1?1:e,gA=e=>e.toString(16).padStart(2,"0");var Nf={};yo(Nf,{offsetClosedPath:()=>SH,signedArea:()=>LH});var SH=(e,t)=>{if(e.length<3||t===0)return e.map(l=>({x:l.x,y:l.y}));let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let a=e.length,r=new Array(a),s=new Array(a);for(let l=0;l<a;l++){let c=v(e[l]),u=v(e[(l+1)%a]),d=u.x-c.x,f=u.y-c.y,p=Math.hypot(d,f)||1;r[l]=-f/p,s[l]=d/p}let i=[];for(let l=0;l<a;l++){let c=(l-1+a)%a,u=v(r[c]),d=v(s[c]),f=v(r[l]),p=v(s[l]),h=u+f,m=d+p,x=Math.hypot(h,m);x<1e-6?(h=u,m=d):(h/=x,m/=x);let y=v(e[l]),g=n-y.x,b=o-y.y,_=h*g+m*b>=0?1:-1,C=h*u+m*d,w=C>1e-6?t/C:t;i.push({x:y.x+_*h*w,y:y.y+_*m*w})}return i},LH=e=>{let t=0;for(let n=0;n<e.length;n++){let o=v(e[n]),a=v(e[(n+1)%e.length]);t+=o.x*a.y-a.x*o.y}return t/2};var AA=e=>{if(!(e.stroke!==void 0&&e.stroke!=="transparent"))return 0;let n=e.strokeWidth??1;if(n<=0)return 0;switch(e.strokeAlign??"center"){case"outside":return n;case"inside":return 0;default:return n/2}},zf=(e,t,n)=>{if(!e||e.type==="sharp")return 0;let o=Math.min(Math.abs(t),Math.abs(n));if(o<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,o/2));let a=32/.25;return o<=a?o*.25:32};var fC=e=>{if(!e)return"";let t=Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[o])=>n<o?-1:n>o?1:0);return JSON.stringify(t)},vA=e=>{let t=[];for(let n of e){if(n.text==="")continue;let o=t[t.length-1];o!==void 0&&fC(o.style)===fC(n.style)?t[t.length-1]={text:o.text+n.text,...o.style!==void 0?{style:o.style}:{}}:t.push(n)}return t},pC=e=>{let t=e.runs;return t!==void 0&&t.length>0?vA(t):e.text===""?[]:[{text:e.text}]},Ff=(e,t,n)=>{let o=Math.min(t,n),a=Math.max(t,n),r=[],s=0;for(let i of pC(e)){let l=s,c=s+i.text.length;s=c;let u=Math.max(l,o),d=Math.min(c,a);u>=d||r.push({text:i.text.slice(u-l,d-l),...i.style!==void 0?{style:i.style}:{}})}return r},wH=(e,t)=>{let n={...e??{},...t},o=Object.entries(n).filter(([,r])=>r!==void 0);return o.length===0?void 0:Object.fromEntries(o)},SA=(e,t,n,o)=>{let a=Math.max(0,Math.min(t,n)),r=Math.min(e.text.length,Math.max(t,n));if(a>=r)return e;let s=[],i=0;for(let u of pC(e)){let d=i,f=i+u.text.length;i=f;let p=Math.max(d,a),h=Math.min(f,r);if(p>=h){s.push(u);continue}d<p&&s.push({text:u.text.slice(0,p-d),...u.style!==void 0?{style:u.style}:{}});let m=wH(u.style,o);s.push({text:u.text.slice(p-d,h-d),...m!==void 0?{style:m}:{}}),h<f&&s.push({text:u.text.slice(h-d),...u.style!==void 0?{style:u.style}:{}})}let l=vA(s),c=l[0];if(l.length===1&&c!==void 0&&(c.style===void 0||Object.keys(c.style).length===0)){let{runs:u,...d}=e;return d}return{...e,runs:l}};var LA=e=>{if(typeof e!="object"||e===null)return!1;let t=e.kind;return t==="named"||t==="ratio"||t==="absolute"||t==="edge"},ii=e=>e.kind==="point"?void 0:e.elementId;var hC=null,kA=e=>{hC=e},_A=()=>hC;var li=e=>e.type==="rectangle",lc=e=>e.type==="ellipse",Ua=e=>e.type==="polygon",wA=e=>e.type==="path",pe=e=>e.type==="text",ct=e=>e.type==="image";var ze=e=>e.type==="group",Be=e=>e.type==="frame";var Mn=e=>e.type==="brush",Hf=e=>e.stroke??e.fill??"#000",mC=new Map,to=(e,t)=>{mC.set(e,t)};var Re=e=>{let t=mC.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},N=e=>{let t=Re(e),n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],o=Math.sin(e.rotation),a=Math.cos(e.rotation),r=n.map(s=>{let i=s.x*e.scale.x,l=s.y*e.scale.y;return{x:e.position.x+(i*a-l*o),y:e.position.y+(i*o+l*a)}});return j.fromPoints(r)};to("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));to("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));to("polygon",e=>j.fromPoints(e.points));to("path",e=>{let t=[],n={x:0,y:0};for(let o of e.commands)switch(o.kind){case"M":case"L":t.push(o.to),n=o.to;break;case"Q":t.push(o.control,o.to),n=o.to;break;case"C":t.push(o.control1,o.control2,o.to),n=o.to;break;case"Z":break}return j.fromPoints(t)});to("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
10
+ `),o=_A(),a={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},r=i=>{if(o){let l=o(i,e.fontFamily,e.fontSize,a);if(l!==null)return l}return i.length*e.fontSize*.6};if(e.maxWidth===void 0){let i=0;for(let l of n)i=Math.max(i,r(l));return i=Math.max(i,e.fontSize*.5),{x:0,y:0,width:i,height:Math.max(1,n.length)*t}}let s=0;for(let i of n)s+=Math.max(1,Math.ceil(r(i)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,s)*t}});to("image",e=>({x:0,y:0,width:e.width,height:e.height}));to("template",e=>({x:0,y:0,width:e.width,height:e.height}));to("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e.points)r.x-r.width<t&&(t=r.x-r.width),r.y-r.width<n&&(n=r.y-r.width),r.x+r.width>o&&(o=r.x+r.width),r.y+r.width>a&&(a=r.y+r.width);return{x:t,y:n,width:o-t,height:a-n}});to("group",()=>({x:0,y:0,width:0,height:0}));to("frame",e=>({x:0,y:0,width:e.width,height:e.height}));to("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var B0=class{cellSize;cells=new Map;bounds=new Map;constructor(t=256){if(t<=0)throw new Error("cellSize must be positive");this.cellSize=t}get size(){return this.bounds.size}insert(t,n){if(this.bounds.has(t))throw new Error(`Element already indexed: ${t}`);this.bounds.set(t,n),this.eachCell(n,o=>{let a=this.cells.get(o);a||(a=new Set,this.cells.set(o,a)),a.add(t)})}remove(t){let n=this.bounds.get(t);n&&(this.bounds.delete(t),this.eachCell(n,o=>{let a=this.cells.get(o);a&&(a.delete(t),a.size===0&&this.cells.delete(o))}))}update(t,n){this.remove(t),this.insert(t,n)}query(t){let n=new Set;return this.eachCell(t,o=>{let a=this.cells.get(o);if(a)for(let r of a)n.add(r)}),n}clear(){this.cells.clear(),this.bounds.clear()}eachCell(t,n){let o=Math.floor(t.x/this.cellSize),a=Math.floor(t.y/this.cellSize),r=Math.floor((t.x+t.width)/this.cellSize),s=Math.floor((t.y+t.height)/this.cellSize);for(let i=a;i<=s;i++)for(let l=o;l<=r;l++)n(`${l},${i}`)}};var Tt=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Uf=(e,t)=>Tt(t,e);var Rn=(e,t)=>{let n=t.x*e.scale.x,o=t.y*e.scale.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation);return{x:e.position.x+(n*a-o*r),y:e.position.y+(n*r+o*a)}},ci=(e,t)=>{let n=t.x-e.position.x,o=t.y-e.position.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation),s=n*a+o*r,i=-n*r+o*a;return{x:e.scale.x===0?0:s/e.scale.x,y:e.scale.y===0?0:i/e.scale.y}};var N0=(e,t,n,o,a)=>{let r=a*Math.PI*2-Math.PI/2;return{x:e+n*Math.cos(r),y:t+o*Math.sin(r)}};var I=(e,t)=>e.elements.get(t),ue=(e,t)=>e.links.get(t);var Lo=e=>[...e.layers.values()].sort(Tt),Ga=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(Tt),EA=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(Tt),yC=48,z0=10,TA=e=>[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],gC=6,TH=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=gC;p++){let h=u+(d-u)*(p/gC);f.push({x:l+t*Math.cos(h),y:c+t*Math.sin(h)})}return f},i=Math.PI/2;return[...s(n+t,o+t,Math.PI,Math.PI+i),...s(n+a-t,o+t,-i,0),...s(n+a-t,o+r-t,0,i),...s(n+t,o+r-t,i,Math.PI)]},EH=e=>{let t=[],n={x:0,y:0};for(let o of e)if(o.kind==="M"||o.kind==="L")n=o.to,t.push({x:n.x,y:n.y});else if(o.kind==="Q"){for(let a=1;a<=z0;a++){let r=a/z0,s=1-r;t.push({x:s*s*n.x+2*s*r*o.control.x+r*r*o.to.x,y:s*s*n.y+2*s*r*o.control.y+r*r*o.to.y})}n=o.to}else if(o.kind==="C"){for(let a=1;a<=z0;a++){let r=a/z0,s=1-r;t.push({x:s**3*n.x+3*s*s*r*o.control1.x+3*s*r*r*o.control2.x+r**3*o.to.x,y:s**3*n.y+3*s*s*r*o.control1.y+3*s*r*r*o.control2.y+r**3*o.to.y})}n=o.to}return t},CH=new Map;var IH=e=>{if(Ua(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(lc(e)){let t=Re(e),n=t.x+t.width/2,o=t.y+t.height/2,a=t.width/2,r=t.height/2,s=[];for(let i=0;i<yC;i++)s.push(N0(n,o,a,r,i/yC));return[s]}if(li(e)){let t=Re(e),n=zf(e.style.roundness,t.width,t.height);return[n>0?TH(t,n):TA(t)]}return ct(e)||pe(e)?[TA(Re(e))]:wA(e)?[EH(e.commands)]:null},Gf=(e,t)=>{if(ze(t)){let r=[];for(let s of CA(e,t.id))r.push(...Gf(e,s));return r}let n=IH(t);if(n)return n.map(r=>r.map(s=>Rn(t,s)));let o=CH.get(t.type);if(o){let r=o(t).filter(s=>s.length>=2);if(r.length>0)return r.map(s=>s.map(i=>Rn(t,i)))}let a=N(t);return[TA(a)]},CA=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(Tt),n},IA=(e,t)=>{let n=t;for(let o=0;n&&o<xC;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},cc=(e,t)=>{let n=t;for(let o=0;n&&o<xC;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var MA=(e,t)=>{let n=e.elements.get(t);if(!n)return[];let o=new Set([t]),a=[n],r=[t];for(;r.length>0;){let s=r.pop();if(s===void 0)break;for(let i of CA(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},xC=64;var F0=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=N(a);if(!j.intersects(r,t))continue;let s=r.width*r.height;if(s<=0){o.push(a);continue}let i=Math.max(r.x,t.x),l=Math.max(r.y,t.y),c=Math.min(r.x+r.width,t.x+t.width),u=Math.min(r.y+r.height,t.y+t.height),d=c-i,f=u-l;if(d<=0||f<=0)continue;if(d*f/s>=n){o.push(a);continue}let h=t.width*t.height;h>0&&d*f/h>=n&&o.push(a)}return o},ui=(e,t)=>{let n=Lo(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=Ga(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&j.contains(N(i),t))return i}}},RA=(e,t)=>{let n=new B0(t);for(let o of e.elements.values())n.insert(o.id,N(o));return n};var OA=(e,t,n)=>{let o={x:n.x,y:n.y,width:0,height:0},a=t.query(o);if(a.size===0)return;let r,s="",i="",l=!1;for(let c of a){let u=e.elements.get(c);if(!u||!j.contains(N(u),n))continue;let d=e.layers.get(u.layerId);if(!d?.visible)continue;let f=d.order;(!l||f>s||f===s&&u.order>i)&&(r=u,s=f,i=u.order,l=!0)}return r};var MH=[];var Wf=e=>di(e)!==null,di=e=>{for(let s of MH){let i=s(e);if(i)return i}let t=e.metadata,n=e;if(t?.autoLayout!=null&&typeof n.width=="number"&&typeof n.height=="number"){let s=t.container?.padding??RH,i=n.width,l=n.height;return{dropZone:{x:s,y:s,width:Math.max(0,i-2*s),height:Math.max(0,l-2*s)},padding:s}}let o=e.metadata?.container;if(!o||typeof o!="object")return null;let a=o;return a.dropZone?a.padding!==void 0?{dropZone:a.dropZone,padding:a.padding}:{dropZone:a.dropZone}:null},RH=0,no=e=>{let t=di(e);return t?{x:e.position.x+t.dropZone.x,y:e.position.y+t.dropZone.y,width:t.dropZone.width,height:t.dropZone.height}:null},OH=[];var DA=e=>{for(let n of OH){let o=n(e);if(o)return o.map(a=>({x:e.position.x+a.x,y:e.position.y+a.y,width:a.width,height:a.height}))}let t=no(e);return t?[t]:[]},qf=(e,t,n=new Set)=>{let o=Lo(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=Ga(e,r.id);for(let i=s.length-1;i>=0;i--){let l=s[i];if(l===void 0||n.has(l.id))continue;let c=no(l);if(c&&j.contains(c,t))return l}}return null},PA=(e,t)=>{let n=di(e);if(!n)return null;let o=n.padding??0,a={x:t.x-e.position.x,y:t.y-e.position.y,width:t.width,height:t.height},r=n.dropZone,s=a.x,i=a.y,l=a.x+a.width,c=a.y+a.height,u=r.x,d=r.y,f=r.x+r.width,p=r.y+r.height,h=s<u?s-o:u,m=i<d?i-o:d,x=l>f?l+o:f,y=c>p?c+o:p;return h===u&&m===d&&x===f&&y===p?null:{x:h,y:m,width:x-h,height:y-m}},BA=(e,t)=>{let n=e.spec.dropZone,o=n.x-t.x,a=n.y-t.y,r=t.x+t.width-(n.x+n.width),s=t.y+t.height-(n.y+n.height);return{width:e.width+o+r,height:e.height+a+s,positionOffset:{x:-o,y:-a}}};var bC=new Set,NA={"top-left":{x:0,y:0},top:{x:.5,y:0},"top-right":{x:1,y:0},right:{x:1,y:.5},"bottom-right":{x:1,y:1},bottom:{x:.5,y:1},"bottom-left":{x:0,y:1},left:{x:0,y:.5},center:{x:.5,y:.5}},AC=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var vC=(e,t)=>zA(e,t),Yt=(e,t)=>{let n=vC(e,t),o=n.x*e.scale.x,a=n.y*e.scale.y,r=Math.cos(e.rotation),s=Math.sin(e.rotation);return{x:e.position.x+(o*r-a*s),y:e.position.y+(o*s+a*r)}},Xo=(e,t)=>{let n=Yt(e,t),o=Yt(e,{kind:"named",name:"center"}),a=n.x-o.x,r=n.y-o.y,s=Math.hypot(a,r);return s<1e-6?{x:0,y:-1}:{x:a/s,y:r/s}},Wa=(e,t,n=bC)=>{let o=null;for(let[a,r]of H0(e)){if(n.has(a))continue;let s=DH(a),i=Yt(e,s),l=i.x-t.x,c=i.y-t.y,u=Math.hypot(l,c);(o===null||u<o.distance)&&(o={ref:s,world:i,distance:u})}return o||{ref:{kind:"named",name:"center"},world:Yt(e,{kind:"named",name:"center"}),distance:1/0}},DH=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},ko=e=>Wf(e)?PH:bC,PH=new Set(["center"]);var H0=e=>{let t=new Map;if(Ua(e))BH(e,t);else{let n=Re(e);for(let o of SC){let a=NA[o];t.set(o,{x:n.x+n.width*a.x,y:n.y+n.height*a.y})}}if(e.anchors)for(let[n,o]of Object.entries(e.anchors))t.set(n,zA(e,o));return t},SC=["top","right","bottom","left"],BH=(e,t)=>{let n=e.points;if(!(n.length<2))for(let o=0;o<n.length;o++){let a=n[o],r=n[(o+1)%n.length];a===void 0||r===void 0||t.set(`edge-${o}`,W.midpoint(a,r))}},zA=(e,t)=>{switch(t.kind){case"named":{let n=kC(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${AC.join(", ")}; custom anchors live on shape.anchors.`);return n}case"ratio":{let n=Re(e);return{x:n.x+n.width*t.position.x,y:n.y+n.height*t.position.y}}case"absolute":{let n=Re(e);return{x:n.x+t.offset.x,y:n.y+t.offset.y}}case"edge":return LC(e,t.index,t.t)}},LC=(e,t,n)=>{if(Ua(e)&&e.points.length>=2){let a=e.points,r=a.length,s=(t%r+r)%r,i=a[s],l=a[(s+1)%r];if(i!==void 0&&l!==void 0){let c=n<0?0:n>1?1:n;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}}let o=Re(e);return{x:o.x+o.width/2,y:o.y+o.height/2}},kC=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?kC(e,n.name):zA(e,n);if(Ua(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return LC(e,r,.5)}let o=NA[t];if(!o)return;let a=Re(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var FA=(e,t,n,o)=>{let a=Math.hypot(t.x-e.x,t.y-e.y),r=Math.min(a*.8,240);return{c1:{x:e.x+n.x*r,y:e.y+n.y*r},c2:{x:t.x+o.x*r,y:t.y+o.y*r},to:t}},Vf=e=>{let t=[],n=6;for(let o=0;o<e.length-1;o++){let a=v(e[o]),r=v(e[o+1]),s=e[o-1]??a,i=e[o+2]??r;t.push({c1:{x:a.x+(r.x-s.x)/n,y:a.y+(r.y-s.y)/n},c2:{x:r.x-(i.x-a.x)/n,y:r.y-(i.y-a.y)/n},to:r})}return t},jf=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(cn.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var IC=(e,t)=>{if(e.length===2){let[r,s]=e;return{x:r.x+(s.x-r.x)*t,y:r.y+(s.y-r.y)*t}}let n=[],o=0;for(let r=1;r<e.length;r++){let s=v(e[r]),i=v(e[r-1]),l=Math.hypot(s.x-i.x,s.y-i.y);n.push(l),o+=l}let a=o*t;for(let r=0;r<n.length;r++){let s=v(n[r]);if(a<=s){let i=v(e[r]),l=v(e[r+1]),c=s===0?0:a/s;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}a-=s}return v(e[e.length-1])},NH=e=>{let t=0;for(let n=1;n<e.length;n++){let o=v(e[n-1]),a=v(e[n]);t+=Math.hypot(a.x-o.x,a.y-o.y)}return t},uc=(e,t)=>{let n=t.label?.position;if(n===void 0&&(t.routing??"straight")==="orthogonal"&&e.length>2){let s=-1,i=v(e[0]);for(let l=1;l<e.length;l++){let c=v(e[l-1]),u=v(e[l]),d=Math.hypot(u.x-c.x,u.y-c.y);d>s&&(s=d,i={x:(c.x+u.x)/2,y:(c.y+u.y)/2})}return i}let o=NH(e),a=o>0?Math.min(.5,24/o):0,r=Math.min(1-a,Math.max(a,n??.5));return IC(e,r)},MC=e=>{let t=e.fontSize??12,n=t*.62,o=Math.max(1,Math.floor(160/n)),a=0,r=0;for(let s of e.text.split(`
11
+ `)){let i=s.split(/\s+/).filter(c=>c.length>0);if(i.length===0){a+=1;continue}let l="";for(let c of i){let u=l===""?c:`${l} ${c}`;u.length<=o||l===""?l=u:(r=Math.max(r,l.length),a+=1,l=c)}r=Math.max(r,l.length),a+=1}return{width:Math.min(r*n,160)+12,height:a*t*1.25+6}},Zf=(e,t)=>{if(!t.label||t.label.text===""||e.length<2)return null;let n=uc(e,t),o=MC(t.label);return{x:n.x-o.width/2,y:n.y-o.height/2,width:o.width,height:o.height}},zH=[.5,.38,.62,.26,.74,.14,.86],_C=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,Xf=(e,t)=>{let n=e(.5);if(t===null||!_C(n,t))return n;for(let o of zH){let a=e(o);if(!_C(a,t))return a}return n},UA=(e,t)=>{let n=0,o=1/0,a=0,r=0;for(let s=1;s<e.length;s++){let i=v(e[s-1]),l=v(e[s]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u);if(d>0){let f=Math.max(0,Math.min(1,((t.x-i.x)*c+(t.y-i.y)*u)/(d*d))),p=i.x+c*f,h=i.y+u*f,m=(t.x-p)**2+(t.y-h)**2;m<o&&(o=m,a=r+d*f)}r+=d,n+=d}return n>0?a/n:.5};var dc={x:1,y:0},Yf={x:0,y:1},Kf={x:-1,y:0},$f={x:0,y:-1},RC=e=>e.y===0;var FH=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?dc:e.x<=-n?Kf:e.y>t?Yf:$f},Qf=(e,t)=>FH({x:e.x-t.x,y:e.y-t.y}),U0=(e,t)=>{let n=N(e),o=Math.abs(t.x-n.x),a=Math.abs(n.x+n.width-t.x),r=Math.abs(t.y-n.y),s=Math.abs(n.y+n.height-t.y),i=Math.min(o,a,r,s);return i===o?Kf:i===a?dc:i===r?$f:Yf},OC=(e,t)=>{let n=N(e),o=n.x+n.width/2,a=n.y+n.height/2,r=t.x-o,s=t.y-a;if(r===0&&s===0)return dc;let i=n.width||1,l=n.height||1,c=r/(i/2),u=s/(l/2);return Math.abs(c)>=Math.abs(u)?c>=0?dc:Kf:u>=0?Yf:$f};var G0=new Map,GA=(e,t)=>{G0.set(e,t)},DC=e=>G0.get(e),W0=(e,t)=>{let n=G0.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,sc.clamp01(t));return Rn(e,o)},PC=(e,t,n=64)=>{let o=G0.get(e.type);if(!o)return null;let a=0,r=Rn(e,o(e,0)),s=W.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=Rn(e,o(e,l)),u=W.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},BC=(e,t)=>{if(e.length===0)return{x:0,y:0};if(e.length===1)return v(e[0]);let n=0,o=[];for(let r=0;r<e.length;r++){let s=v(e[r]),i=v(e[(r+1)%e.length]),l=W.distance(s,i);o.push(l),n+=l}if(n===0)return v(e[0]);let a=n*t;for(let r=0;r<e.length;r++){let s=v(o[r]);if(a<=s){let i=v(e[r]),l=v(e[(r+1)%e.length]),c=s===0?0:a/s;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}a-=s}return v(e[0])};GA("rectangle",(e,t)=>{let n=Re(e),o=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}];return BC(o,t)});GA("ellipse",(e,t)=>{let n=Re(e),o=n.x+n.width/2,a=n.y+n.height/2,r=n.width/2,s=n.height/2;return N0(o,a,r,s,t)});GA("polygon",(e,t)=>BC(e.points,t));var NC=e=>e.kind==="point"?null:e.elementId,zC=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},FC=(e,t,n)=>{if(t.kind==="anchor"){let a=zC(Xo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=zC(U0(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},WH=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2;return t.y<0?{x:n,y:e.y}:t.y>0?{x:n,y:e.y+e.height}:t.x<0?{x:e.x,y:o}:{x:e.x+e.width,y:o}},qA=(e,t)=>{let n=NC(t.from);if(!n||n!==NC(t.to))return null;let o=I(e,n);if(!o)return null;let a=N(o),r=oo(e,t.from),s=oo(e,t.to);if(!r||!s)return null;let i=r,l=s,c=FC(o,t.from,i),u=FC(o,t.to,l);if(Math.hypot(l.x-i.x,l.y-i.y)<1){let d=c.x!==0||c.y!==0?c:{x:0,y:-1};c=d,u=d;let f={x:-d.y,y:d.x},p=d.x!==0?a.height:a.width,h=Math.min(24,p/3),m=WH(a,d);i={x:m.x-f.x*h,y:m.y-f.y*h},l={x:m.x+f.x*h,y:m.y+f.y*h}}return{p1:i,n1:c,p2:l,n2:u,bounds:a}},qH=e=>{let t=40,{p1:n,n1:o,p2:a,n2:r,bounds:s}=e,i={x:n.x+o.x*t,y:n.y+o.y*t},l={x:a.x+r.x*t,y:a.y+r.y*t},c=o.x===r.x&&o.y===r.y,u=o.x===-r.x&&o.y===-r.y;if(c)return[n,i,l,a];if(u){if(o.x===0){let p=s.x+s.width+t;return[n,i,{x:p,y:i.y},{x:p,y:l.y},l,a]}let f=s.y+s.height+t;return[n,i,{x:i.x,y:f},{x:l.x,y:f},l,a]}let d={x:o.y!==0?l.x:i.x,y:o.y!==0?i.y:l.y};return[n,i,d,l,a]},VH=e=>{let t=40*2.2,{p1:n,n1:o,p2:a,n2:r}=e;return{start:n,segments:[{c1:{x:n.x+o.x*t,y:n.y+o.y*t},c2:{x:a.x+r.x*t,y:a.y+r.y*t},to:a}]}},UC=e=>{let t=N(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},jH=(e,t)=>{let n=UC(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!DC(e.type))return n;let s=Math.hypot(o,a),i={x:n.x+o/s*1e6,y:n.y+a/s*1e6},l=null,c=1/0,u=W0(e,0);for(let d=1;d<=96;d++){let f=W0(e,d/96),p=D0.segmentSegment(n,i,u,f);if(p){let h=Math.hypot(p.x-t.x,p.y-t.y);h<c&&(c=h,l=p)}u=f}return l??n},oo=(e,t,n)=>{if(t.kind==="point")return t.position;let o=I(e,t.elementId);return o?t.kind==="anchor"?Yt(o,t.anchor):t.kind==="floating"?jH(o,n??UC(o)):W0(o,t.ratio):null},ut=(e,t)=>{let n=qA(e,t);if(n)return qH(n);let o=oo(e,t.from);if(!o)return null;let a=oo(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?oo(e,t.from,a)??o:o,s=t.to.kind==="floating"?oo(e,t.to,o)??a:a;return(t.routing??"straight")!=="orthogonal"?[r,...t.waypoints??[],s]:t.routedPoints!==void 0?[r,...t.routedPoints,s]:GC(r,s,WA(t.from),WA(t.to))},GC=(e,t,n,o)=>{let a=Math.min(40,Math.max(8,Math.abs(t.x-e.x)/4,Math.abs(t.y-e.y)/4));if(n||o){let c=[e],u=e,d=t;n&&(u={x:e.x+n.x*a,y:e.y+n.y*a},c.push(u));let f=null;o&&(f={x:t.x+o.x*a,y:t.y+o.y*a});let p=f??d,h=p.x-u.x,m=p.y-u.y,x=n?Math.abs(n.x)>Math.abs(n.y):Math.abs(h)>=Math.abs(m);if(Math.abs(h)>.5&&Math.abs(m)>.5){let y=x?{x:p.x,y:u.y}:{x:u.x,y:p.y};c.push(y)}return f&&c.push(f),c.push(t),c}let r=t.x-e.x,s=t.y-e.y,l=Math.abs(r)>=Math.abs(s)?{x:t.x,y:e.y}:{x:e.x,y:t.y};return[e,l,t]},WA=e=>{if(e.kind!=="anchor"||e.anchor.kind!=="named")return null;switch(e.anchor.name){case"top":return{x:0,y:-1};case"right":return{x:1,y:0};case"bottom":return{x:0,y:1};case"left":return{x:-1,y:0};default:return null}},HC=(e,t,n)=>{let o=WA(e);if(o)return o;let a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>=Math.abs(r)?{x:Math.sign(a)||1,y:0}:{x:0,y:Math.sign(r)||1}},Jf=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=qA(e,t);if(n)return VH(n);let o=ut(e,t);if(!o||o.length<2)return null;let a=v(o[0]),r=v(o[o.length-1]);if(o.length===2){let s=HC(t.from,a,r),i=HC(t.to,r,a);return{start:a,segments:[FA(a,r,s,i)]}}return{start:a,segments:Vf(o)}},_o=(e,t)=>{if((t.routing??"straight")!=="bezier")return ut(e,t);let n=Jf(e,t);return n?jf(n.start,n.segments):null},ep=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;let o=fc(e,t);if(n==="bezier"){let s=Jf(e,t);if(!s)return null;let i=[],l=s.start;for(let c of s.segments){let u=l;i.push(Xf(d=>cn.cubicAt(u,c.c1,c.c2,c.to,d),o)),l=c.to}return i}let a=ut(e,t);if(!a||a.length<2)return null;let r=[];for(let s=0;s<a.length-1;s++){let i=v(a[s]),l=v(a[s+1]);r.push(Xf(c=>({x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}),o))}return r},tp=(e,t,n)=>{let o=fc(e,t);return(n.length===2?[0]:Array.from({length:Math.max(0,n.length-3)},(r,s)=>s+1)).map(r=>{let s=v(n[r]),i=v(n[r+1]);return{k:r,point:Xf(l=>({x:s.x+(i.x-s.x)*l,y:s.y+(i.y-s.y)*l}),o)}})},VA=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=_o(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=Ha.distanceToSegment(t,v(r[i-1]),v(r[i]));l<s&&(s=l)}s>n&&!ZH(e,a,t)||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null},fc=(e,t)=>{let n=_o(e,t);return!n||n.length<2?null:Zf(n,t)},ZH=(e,t,n)=>{let o=fc(e,t);return o!==null&&n.x>=o.x&&n.x<=o.x+o.width&&n.y>=o.y&&n.y<=o.y+o.height};var np=e=>{let t=e.length;if(t<2)return[];let n=d=>{let f=v(e[d]);return{x:f.x,y:f.y}},o=d=>v(e[d]).width,a=[],r=[];for(let d=0;d<t-1;d++){let f=W.sub(n(d+1),n(d)),p=W.lengthSq(f)>0?W.normalize(f):{x:1,y:0};a.push(p),r.push(W.perp(p))}let s=[],i=[];for(let d=0;d<t;d++){let f=o(d),p=n(d);if(d===0){let y=v(r[0]);s.push(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}if(d===t-1){let y=v(r[t-2]);s.push(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}let h=v(r[d-1]),m=v(r[d]),x=W.cross(v(a[d-1]),v(a[d]));if(Math.abs(x)<1e-9){s.push(W.add(p,W.mul(h,f))),i.push(W.sub(p,W.mul(h,f)));continue}x>0?(s.push(...WC(p,h,m,f,1)),i.push(...qC(p,h,m,f,-1))):(s.push(...qC(p,h,m,f,1)),i.push(...WC(p,h,m,f,-1)))}let l=VC(n(t-1),v(r[t-2]),o(t-1),!1),c=VC(n(0),v(r[0]),o(0),!0),u=[];for(let d of s)u.push(d);for(let d of l)u.push(d);for(let d=i.length-1;d>=0;d--)u.push(v(i[d]));for(let d of c)u.push(d);return u},WC=(e,t,n,o,a)=>{let r=W.normalize(W.add(t,n)),s=W.dot(r,t);return s>.001&&1/s<=2.5?[W.add(e,W.mul(r,a*(o/s)))]:[W.add(e,W.mul(t,a*o)),W.add(e,W.mul(n,a*o))]},qC=(e,t,n,o,a)=>jC(e,o,W.angle(W.mul(t,a)),W.angle(W.mul(n,a))),VC=(e,t,n,o)=>{let a=W.angle(t)+(o?Math.PI:0);return jC(e,n,a,a-Math.PI)},jC=(e,t,n,o)=>{let a=o-n;for(;a>Math.PI+1e-9;)a-=2*Math.PI;for(;a<-Math.PI-1e-9;)a+=2*Math.PI;let r=Math.max(1,Math.ceil(Math.abs(a)/.35)),s=[];for(let i=0;i<=r;i++){let l=n+a*i/r;s.push({x:e.x+t*Math.cos(l),y:e.y+t*Math.sin(l)})}return s};var ZC=new Map,jA=(e,t)=>{ZC.set(e,t)},op=e=>{let t=N(e),n=ZC.get(e.type);if(!n)return t;let o=n(e),a=o.top??0,r=o.right??0,s=o.bottom??0,i=o.left??0;return a===0&&r===0&&s===0&&i===0?t:{x:t.x-i,y:t.y-a,width:t.width+i+r,height:t.height+a+s}};var ap=class{contributors;constructor(t){this.contributors=t}snap(t){let n=[];for(let o of this.contributors)for(let a of o.contribute(t))a.distance<=t.threshold*t.threshold&&n.push(a);return n.sort((o,a)=>o.distance-a.distance),{best:n[0]??null,all:n}}},XA={id:"grid",contribute(e){if(!e.scene.viewport.gridEnabled)return[];let t=20,n={x:Math.round(e.probe.x/t)*t,y:Math.round(e.probe.y/t)*t},o=n.x-e.probe.x,a=n.y-e.probe.y;return[{snapped:n,distance:o*o+a*a,kind:"grid"}]}},YA={id:"anchor",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!XC(n,e.probe,e.threshold))continue;let o=Wa(n,e.probe,ko(n)),a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"anchor",metadata:{elementId:n.id,ref:o.ref}})}return t}},KA={id:"outline",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!XC(n,e.probe,e.threshold))continue;let o=PC(n,e.probe);if(!o)continue;let a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"outline",metadata:{elementId:n.id,ratio:o.ratio}})}return t}},XC=(e,t,n)=>{let o=n,a=t.x-e.position.x,r=t.y-e.position.y;return Math.abs(a)<=1e3+o&&Math.abs(r)<=1e3+o};var $A=()=>20,q0=e=>e.snapToGrid??!0,QA=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),ao=e=>{let t=z.translation(-e.pan.x,-e.pan.y),n=z.rotation(e.rotation),o=z.scaling(e.zoom);return z.multiply(o,z.multiply(n,t))},qa=e=>z.inverse(ao(e)),JA=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),V0=(e,t,n)=>{let o=e.zoom*t;return{...e,zoom:o,pan:{x:n.x-(n.x-e.pan.x)/t,y:n.y-(n.y-e.pan.y)/t}}},ev=(e,t,n)=>({...e,size:{width:t,height:n}});var Et=class extends Error{name="FractionalIndexError"};var j0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function YC(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Et("invalid order key head: "+e)}function KC(e){let t=e.charAt(0);if(e.length!==YC(t))throw new Et("invalid integer part of order key: "+e)}function pc(e){let t=YC(e.charAt(0));if(t>e.length)throw new Et("invalid order key: "+e);return e.slice(0,t)}function tv(e,t){KC(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Et("invalid integer part of order key: "+e);let r=!0;for(let s=a.length-1;r&&s>=0;s--){let i=a[s];if(i===void 0)continue;let l=t.indexOf(i)+1;l===t.length?a[s]=n:(a[s]=t.charAt(l),r=!1)}if(r){if(o==="Z")return"a"+n;if(o==="z")return null;let s=String.fromCharCode(o.charCodeAt(0)+1);return s>"a"?a.push(n):a.pop(),s+a.join("")}return o+a.join("")}function $C(e,t){KC(e);let[n,...o]=e.split("");if(n===void 0)throw new Et("invalid integer part of order key: "+e);let a=t.slice(-1),r=!0;for(let s=o.length-1;r&&s>=0;s--){let i=o[s];if(i===void 0)continue;let l=t.indexOf(i)-1;l===-1?o[s]=a:(o[s]=t.charAt(l),r=!1)}if(r){if(n==="a")return"Z"+a;if(n==="A")return null;let s=String.fromCharCode(n.charCodeAt(0)-1);return s<"Z"?o.push(a):o.pop(),s+o.join("")}return n+o.join("")}function fi(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Et(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Et("trailing zero");if(t!==null){let s=0;for(;(e.charAt(s)||o)===t.charAt(s);)s++;if(s>0)return t.slice(0,s)+fi(e.slice(s),t.slice(s),n)}let a=e?n.indexOf(e.charAt(0)):0,r=t!==null?n.indexOf(t.charAt(0)):n.length;if(r-a>1){let s=Math.round(.5*(a+r));return n.charAt(s)}return t!==null&&t.length>1?t.slice(0,1):n.charAt(a)+fi(e.slice(1),null,n)}function QC(e){return"A"+e.charAt(0).repeat(26)}function YH(e){return"a"+e.charAt(0)}function nv(e,t=j0){if(e===QC(t))throw new Et("invalid order key: "+e);let n=pc(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Et("invalid order key: "+e)}function ro(e,t,n=j0){let o=e??null,a=t??null;if(o!==null&&nv(o,n),a!==null&&nv(a,n),o!==null&&a!==null&&o>=a)throw new Et(o+" >= "+a);if(o===null&&a===null)return YH(n);if(o===null){let u=pc(a),d=a.slice(u.length);if(u===QC(n))return u+fi("",d,n);if(u<a)return u;let f=$C(u,n);if(f===null)throw new Et("cannot decrement any more");return f}if(a===null){let u=pc(o),d=o.slice(u.length),f=tv(u,n);return f===null?u+fi(d,null,n):f}let r=pc(o),s=o.slice(r.length),i=pc(a),l=a.slice(i.length);if(r===i)return r+fi(s,l,n);let c=tv(r,n);if(c===null)throw new Et("cannot increment any more");return c<a?c:r+fi(s,null,n)}function rp(e,t,n,o=j0){if(!Number.isInteger(n)||n<0)throw new Et(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[ro(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(l,r,o),c.push(l);return c}if(a===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=ro(a,r,o);return[...rp(a,i,s,o),i,...rp(i,r,n-s-1,o)]}var On=ln("default"),KH=()=>({id:On,name:"Default",visible:!0,locked:!1,order:ro(null,null)}),un=Object.freeze({elements:new Map,links:new Map,layers:new Map([[On,KH()]]),annotations:new Map,files:new Map,viewport:QA}),ov=()=>({elements:new Map(un.elements),links:new Map(un.links),layers:new Map(un.layers),annotations:new Map(un.annotations),files:new Map(un.files),viewport:un.viewport});var Z0=(e,t)=>e.files.get(t),J=(e,t)=>{switch(t.kind){case"element":{let n=new Map(e.elements);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,elements:n}}case"link":{let n=new Map(e.links);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,links:n}}case"layer":{let n=new Map(e.layers);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,layers:n}}case"annotation":{let n=new Map(e.annotations);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,annotations:n}}case"viewport":return{...e,viewport:t.after};case"file":{let n=new Map(e.files);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,files:n}}case"batch":return t.patches.reduce(J,e)}},Ae=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return ro(t,null)},hc=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return ro(null,t)},mc=(e,t)=>ro(e,t),av=(e,t,n)=>rp(e,t,n);var rv={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},JC=Object.keys(rv),use=JC.filter(e=>rv[e]==="ephemeral"),$H=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of JC)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},sv=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??un.elements),links:new Map(t?.links??un.links),layers:new Map(t?.layers??un.layers),annotations:new Map(t?.annotations??un.annotations),files:new Map(t?.files??un.files),viewport:$H(un.viewport,n?.viewport,t?.viewport)}};var iv=(e,t,n={})=>({id:e,data:t,mime:n.mime??"application/octet-stream",createdAt:n.createdAt??Date.now(),...n.name!==void 0?{name:n.name}:{}});var yc=e=>{switch(e.kind){case"element":return{kind:"element",id:e.id,before:e.after,after:e.before};case"link":return{kind:"link",id:e.id,before:e.after,after:e.before};case"layer":return{kind:"layer",id:e.id,before:e.after,after:e.before};case"annotation":return{kind:"annotation",id:e.id,before:e.after,after:e.before};case"viewport":return{kind:"viewport",before:e.after,after:e.before};case"file":return{kind:"file",id:e.id,before:e.after,after:e.before};case"batch":return{kind:"batch",patches:e.patches.map(yc).reverse()}}},Yo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Kr=e=>{switch(e.kind){case"element":case"link":case"layer":case"annotation":case"file":return e.before===e.after;case"viewport":return e.before===e.after;case"batch":return e.patches.length===0||e.patches.every(Kr)}};var Fe=(e,t)=>{if(e.elements.has(t.id))throw new Error(`Element already exists: ${t.id}`);let n={kind:"element",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},dn=(e,t)=>{let n=e.elements.get(t);if(!n)throw new Error(`Element not found: ${t}`);let o={kind:"element",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},$=(e,t,n)=>{let o=e.elements.get(t);if(!o)throw new Error(`Element not found: ${t}`);let a=n(o),r={kind:"element",id:t,before:o,after:a};return{scene:J(e,r),patch:r}};var pi=(e,t)=>{if(e.links.has(t.id))throw new Error(`Link already exists: ${t.id}`);let n={kind:"link",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},hi=(e,t)=>{let n=e.links.get(t);if(!n)throw new Error(`Link not found: ${t}`);let o={kind:"link",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},Ye=(e,t,n)=>{let o=e.links.get(t);if(!o)throw new Error(`Link not found: ${t}`);let a=n(o),r={kind:"link",id:t,before:o,after:a};return{scene:J(e,r),patch:r}},lv=(e,t)=>{if(e.layers.has(t.id))throw new Error(`Layer already exists: ${t.id}`);let n={kind:"layer",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},cv=(e,t)=>{let n=e.layers.get(t);if(!n)throw new Error(`Layer not found: ${t}`);let o={kind:"layer",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},sp=(e,t,n)=>{let o=e.layers.get(t);if(!o)throw new Error(`Layer not found: ${t}`);let a=n(o),r={kind:"layer",id:t,before:o,after:a};return{scene:J(e,r),patch:r}},uv=(e,t)=>{if(e.annotations.has(t.id))throw new Error(`Annotation already exists: ${t.id}`);let n={kind:"annotation",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},dv=(e,t)=>{let n=e.annotations.get(t);if(!n)throw new Error(`Annotation not found: ${t}`);let o={kind:"annotation",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},Va=(e,t,n)=>{let o=e.annotations.get(t);if(!o)throw new Error(`Annotation not found: ${t}`);let a=n(o),r={kind:"annotation",id:t,before:o,after:a};return{scene:J(e,r),patch:r}};var $r=(e,t)=>{if(t.elementId===null)return t.position;let n=I(e,t.elementId);return n?{x:n.position.x+t.position.x,y:n.position.y+t.position.y}:t.position};var eI=new Map,fv=(e,t)=>{eI.set(e,t)},pv=e=>{let t=eI.get(e.type);if(t){let n=t(e).trim();if(n)return n}return tI(e.type)},tI=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");fv("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});fv("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():tI(e.templateId)});var nI=new Map,hv=e=>{nI.set(e.kind,e)};var X0=e=>nI.get(e);var ip=e=>{try{let t=Re(e);return{width:t.width*Math.abs(e.scale.x),height:t.height*Math.abs(e.scale.y)}}catch{return{width:0,height:0}}},Y0=(e,t)=>{if(t.shapeIds.length===0||t.cols<1)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let d of t.shapeIds){let f=I(e,d);f&&a.push(f)}a.sort(Tt);let r=a.map(ip),s=r.reduce((d,f)=>Math.max(d,f.width),0),i=r.reduce((d,f)=>Math.max(d,f.height),0),l={x:s+n,y:i+n},c=[],u=e;return a.forEach((d,f)=>{let p=f%t.cols,h=Math.floor(f/t.cols),m={x:o.x+p*l.x,y:o.y+h*l.y};if(d.position.x===m.x&&d.position.y===m.y)return;let x=$(u,d.id,y=>({...y,position:m}));u=x.scene,c.push(x.patch)}),c.length===0?null:Yo(c)},K0=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let l of t.shapeIds){let c=I(e,l);c&&a.push(c)}a.sort(Tt);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=ip(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=$(s,l.id,p=>({...p,position:d}));s=f.scene,r.push(f.patch)}t.direction==="horizontal"?i={x:i.x+c+n,y:i.y}:i={x:i.x,y:i.y+u+n}}return r.length===0?null:Yo(r)},oI=(e,t,n,o)=>{let a=[],r=o.x,s=o.y,i=0,l=0,c=0,u=!0;for(let d of e)l=Math.max(l,d.w),!u&&r-o.x+d.w>n+1e-6&&(c=Math.max(c,r-t-o.x),r=o.x,s+=i+t,i=0,u=!0),a.push({id:d.id,x:r,y:s}),r+=d.w+t,i=Math.max(i,d.h),u=!1;return c=Math.max(c,r-t-o.x),{placements:a,widest:l,contentWidth:Math.max(0,c),contentHeight:s+i-o.y}},aI=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n.sort(Tt),n.map(o=>{let a=ip(o);return{id:o.id,w:a.width,h:a.height}})},rI=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=aI(e,t.shapeIds),{placements:r}=oI(a,n,t.innerWidth,o),s=[],i=e;for(let l of r){let c=I(i,l.id);if(!c||c.position.x===l.x&&c.position.y===l.y)continue;let u=$(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Yo(s)},$0=(e,t,n)=>{let o=[];for(let l of e.elements.values())l.parentId===t&&o.push(l.id);if(o.length===0)return null;let a=aI(e,o),r=I(e,t),s=(r?Dn(r):null)?.gap??16,i=oI(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},Dn=e=>{let t=e.metadata?.autoLayout;if(!t||typeof t!="object")return null;let n=t;if(n.kind==="grid")return typeof n.cols!="number"||n.cols<1?null:{kind:"grid",cols:n.cols,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="stack")return n.direction!=="horizontal"&&n.direction!=="vertical"?null:{kind:"stack",direction:n.direction,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="wrap")return{kind:"wrap",...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="tree"){let o=t;return{kind:"tree",...typeof o.ranksep=="number"?{ranksep:o.ranksep}:{},...typeof o.nodesep=="number"?{nodesep:o.nodesep}:{}}}if(typeof n.kind=="string"){let o=X0(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},lp=(e,t)=>{let n=I(e,t);if(!n)return null;let o=Dn(n);if(!o)return null;let a=[];for(let c of e.elements.values())c.parentId===t&&a.push(c.id);if(a.length===0)return null;let r=no(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return Y0(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return K0(e,{shapeIds:a,origin:s,direction:o.direction,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="wrap"){let c=r?r.width:Number.POSITIVE_INFINITY;return rI(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return sI(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=X0(i.kind);return l?l.run(e,t,a,s,i):null},sI=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.ranksep??80,o=t.nodesep??24,a=t.origin??{x:0,y:0},r=m=>{let x=[];for(let y of e.elements.values())y.parentId===m&&x.push(y);return x.sort(Tt),x},s=new Map,i=new Map,l=m=>ip(m).width,c=m=>ip(m).height,u=m=>{let x=s.get(m),y=i.get(m);if(x!==void 0&&y!==void 0)return{w:x,h:y};let g=I(e,m);if(!g)return s.set(m,0),i.set(m,0),{w:0,h:0};let b=l(g),A=c(g),_=r(m);if(_.length===0)return s.set(m,b),i.set(m,A),{w:b,h:A};let C=0,w=0;for(let M=0;M<_.length;M++){let B=u(v(_[M]).id);C+=B.w,M>0&&(C+=o),B.h>w&&(w=B.h)}let L=Math.max(b,C),k=A+n+w;return s.set(m,L),i.set(m,k),{w:L,h:k}};for(let m of t.shapeIds)u(m);let d=[],f=e,p=(m,x,y)=>{let g=I(f,m);if(!g)return;let b=u(m),A=l(g),_=c(g),C={x:x+(b.w-A)/2,y};if(g.position.x!==C.x||g.position.y!==C.y){let M=$(f,m,B=>({...B,position:C}));f=M.scene,d.push(M.patch)}let w=r(m);if(w.length===0)return;let L=x,k=y+_+n;for(let M of w)p(M.id,L,k),L+=u(M.id).w+o},h=a.x;for(let m of t.shapeIds)p(m,h,a.y),h+=u(m).w+o;return d.length===0?null:Yo(d)};var JH=20,Q0=.5,eU=1e5,yv=(e,t,n,o={})=>{if(tU(e,t))return[e];let a=o.margin??JH,r=n.map(L=>nU(L,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let L of r)l.add(L.x),l.add(L.x+L.width),c.add(L.y),c.add(L.y+L.height);let u=[...l].sort((L,k)=>L-k),d=[...c].sort((L,k)=>L-k),f=(L,k)=>`${L},${k}`,p=L=>v(u[L]),h=L=>v(d[L]),m=u.indexOf(e.x),x=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),b=(L,k)=>Math.abs(p(L)-p(y))+Math.abs(h(k)-h(g)),A=f(m,x),_=[{key:A,skey:`${A},0`,xi:m,yi:x,axis:0,g:0,f:b(m,x)}],C=new Map,w=new Map([[`${A},0`,0]]);for(;_.length>0;){_.sort((k,M)=>k.f-M.f||k.g-M.g||(k.skey<M.skey?-1:1));let L=v(_.shift());if(L.xi===y&&L.yi===g)return rU(C,L.skey,p,h);for(let k of oU(L.xi,L.yi,u.length,d.length)){let M={x:p(L.xi),y:h(L.yi)},B={x:p(k.xi),y:h(k.yi)};if(aU(M,B,r))continue;let G=Math.sign(B.x-M.x),ie=Math.sign(B.y-M.y);if(L.axis===0&&s&&G===-Math.sign(s.x)&&ie===-Math.sign(s.y)||k.xi===y&&k.yi===g&&i&&G===Math.sign(i.x)&&ie===Math.sign(i.y))continue;let ne=k.xi!==L.xi?1:2,V=Math.abs(M.x-B.x)+Math.abs(M.y-B.y),ve=L.axis!==0&&L.axis!==ne?eU:0,ge=L.g+V+ve,ee=f(k.xi,k.yi),Se=`${ee},${ne}`,Oe=w.get(Se);Oe!==void 0&&ge>=Oe||(w.set(Se,ge),C.set(Se,L.skey),_.push({key:ee,skey:Se,xi:k.xi,yi:k.yi,axis:ne,g:ge,f:ge+b(k.xi,k.yi)}))}}return null},tU=(e,t)=>e.x===t.x&&e.y===t.y,nU=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),oU=(e,t,n,o)=>{let a=[];return e>0&&a.push({xi:e-1,yi:t}),e<n-1&&a.push({xi:e+1,yi:t}),t>0&&a.push({xi:e,yi:t-1}),t<o-1&&a.push({xi:e,yi:t+1}),a},aU=(e,t,n)=>{let o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),r=Math.min(e.y,t.y),s=Math.max(e.y,t.y);for(let i of n){let l=i.x+i.width,c=i.y+i.height;if(!(a<=i.x||o>=l||s<=i.y||r>=c)&&!(a-i.x<=Q0||l-o<=Q0||s-i.y<=Q0||c-r<=Q0))return!0}return!1},rU=(e,t,n,o)=>{let a=[],r=new Set,s=t;for(;s&&!r.has(s);){r.add(s);let i=s.split(",").map(Number);a.unshift({x:n(v(i[0])),y:o(v(i[1]))}),s=e.get(s)}return sU(a)},sU=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(e[n-1]),a=v(e[n]),r=v(e[n+1]),s=o.y===a.y&&a.y===r.y,i=o.x===a.x&&a.x===r.x;s||i||t.push(a)}return t.push(v(e[e.length-1])),t};var up=(e,t)=>{let n=oo(e,t.from),o=oo(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?oo(e,t.from,o)??n:n,r=t.to.kind==="floating"?oo(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=dI(e,t.from,a,r),i=dI(e,t.to,r,a),l=t.avoidObstacles===!0?iU(e,t):void 0,c=l&&l.length<=150?l:void 0,u=pI(a,r,s,i,t.routedPoints,c);return u=uU(u,t.fixedSegments),u},iU=(e,t)=>{let n=new Set;for(let a of[t.from,t.to])a.kind!=="point"&&n.add(a.elementId);let o=[];for(let a of e.elements.values())n.has(a.id)||o.push(N(a));return o},gv=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=uI(e,t,n,a),s=uI(e,o,a,n);return[n,...pI(n,a,r,s),a]},pI=(e,t,n,o,a,r)=>{let s=30,i={x:e.x+n.heading.x*s,y:e.y+n.heading.y*s},l={x:t.x+o.heading.x*s,y:t.y+o.heading.y*s},c=[];if(n.obstacle&&c.push(n.obstacle),o.obstacle&&c.push(o.obstacle),r){let h=[...c,...r],m=yv(i,l,h,{startHeading:n.heading,endHeading:o.heading}),x=m&&m.length>=2?m:[i,fI(i,l,n.heading),l];return cp(x)}let u=lU(e,t,n,o,i,l);if(u&&!cI(u,c))return cp(u);let d=cU(e,t,n,o,i,l,c,a);if(d&&!cI(d,c))return cp(d);let f=yv(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,fI(i,l,n.heading),l];return cp(p)},lU=(e,t,n,o,a,r)=>{if(n.heading.y!==0&&o.heading.y===-n.heading.y){if(Math.sign(a.y-r.y)===Math.sign(n.heading.y)){let l=(e.x+t.x)/2;return[a,{x:l,y:a.y},{x:l,y:r.y},r]}let i=(a.y+r.y)/2;return[a,{x:a.x,y:i},{x:r.x,y:i},r]}if(n.heading.x!==0&&o.heading.x===-n.heading.x){if(Math.sign(a.x-r.x)===Math.sign(n.heading.x)){let l=(e.y+t.y)/2;return[a,{x:a.x,y:l},{x:r.x,y:l},r]}let i=(a.x+r.x)/2;return[a,{x:i,y:a.y},{x:i,y:r.y},r]}return null},iI=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},cU=(e,t,n,o,a,r,s,i)=>{if(s.length===0)return null;let l=1/0,c=1/0,u=-1/0,d=-1/0;for(let p of s)l=Math.min(l,p.x),c=Math.min(c,p.y),u=Math.max(u,p.x+p.width),d=Math.max(d,p.y+p.height);let f=20;if(l-=f,c-=f,u+=f,d+=f,n.heading.y===0&&o.heading.y===0&&n.heading.x!==0&&o.heading.x===-n.heading.x){let p=(e.y+t.y)/2,h=iI(p,(c+d)/2,c,d,lI(i,"y"));return[a,{x:a.x,y:h},{x:r.x,y:h},r]}if(n.heading.x===0&&o.heading.x===0&&n.heading.y!==0&&o.heading.y===-n.heading.y){let p=(e.x+t.x)/2,h=iI(p,(l+u)/2,l,u,lI(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},lI=(e,t)=>{if(!e||e.length<3)return null;let n=d=>t==="y"?d.y:d.x,o=n(v(e[0])),a=n(v(e[e.length-1])),r=Math.min(o,a),s=Math.max(o,a),i=1/0,l=-1/0;for(let d of e){let f=n(d);f<i&&(i=f),f>l&&(l=f)}let c=r-i,u=l-s;return c<=0&&u<=0?null:c>=u},cI=(e,t)=>{let n=1;for(let o=1;o<e.length;o++){let a=v(e[o-1]),r=v(e[o]);for(let s=0;s<=1;s+=.1){let i=a.x+(r.x-a.x)*s,l=a.y+(r.y-a.y)*s;for(let c of t)if(i>c.x+n&&i<c.x+c.width-n&&l>c.y+n&&l<c.y+c.height-n)return!0}}return!1},uI=(e,t,n,o)=>{if(!t)return{heading:Qf(o,n),obstacle:null};let a=I(e,t);return a?{heading:OC(a,n),obstacle:N(a)}:{heading:Qf(o,n),obstacle:null}},uU=(e,t)=>{if(!t||t.length===0)return e;let n=e.map(o=>({...o}));for(let o of t){let a=n.length-2,r=-1,s=1/0;for(let c=1;c<a;c++){let u=v(n[c]),d=v(n[c+1]),f=Math.abs(u.y-d.y)<1e-6,p=Math.abs(u.x-d.x)<1e-6;if(o.axis==="h"!==f||o.axis==="v"!==p)continue;let h=o.axis==="h"?(u.x+d.x)/2:(u.y+d.y)/2,m=Math.abs(h-o.at);m<s&&(s=m,r=c)}if(r>=0){let c=v(n[r]),u=v(n[r+1]);o.axis==="h"?(c.y=o.pos,u.y=o.pos):(c.x=o.pos,u.x=o.pos);continue}let i=v(n[0]),l=v(n[n.length-1]);n=o.axis==="h"?[i,{x:i.x,y:o.pos},{x:l.x,y:o.pos},l]:[i,{x:o.pos,y:i.y},{x:o.pos,y:l.y},l]}return cp(n)},dU=e=>{switch(e){case"top":return $f;case"bottom":return Yf;case"left":return Kf;case"right":return dc;default:return null}},dI=(e,t,n,o)=>{if(t.kind==="point")return{heading:Qf(o,n),obstacle:null};let a=I(e,t.elementId);if(!a)return{heading:Qf(o,n),obstacle:null};let r=N(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=dU(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:U0(a,n),obstacle:r}},fI=(e,t,n)=>RC(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},cp=e=>{if(e.length<=2)return[...e];let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=1e-6,i=Math.abs(o.y-a.y)<s&&Math.abs(a.y-r.y)<s,l=Math.abs(o.x-a.x)<s&&Math.abs(a.x-r.x)<s,c=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;i||l||c||t.push(a)}return t.push(v(e[e.length-1])),t};var mi="orthogonal",dp="triangle";var xv=Math.PI/12,Ko=11,hI=6,mI=4,yI=12,J0=9,bv=4,gI="#1a73e8",xI="#fff",fp=3.5,$o=5,bI=8,AI=1.5,vI=gI,Av=xI,SI=xI,vv=gI,wo=20,LI=0,kI="#ffffff",ey=6,ty=7,_I=18,Sv=40,gc=.16,pp=.7,Lv="#e8118c",wI="#f59e0b",hp="#2563eb",kv="#16a34a",TI="#06b6d4",EI="#a855f7",CI="#eab308",II="#dc2626",MI="#14b8a6",RI="#f43f5e",OI=16,_v=14,wv=6,Tv=3,Ev=11,DI=1.5,PI=[4,3],BI=3;var Cv=1,Iv=1.6,Mv=10,NI=1,zI=.05,FI=32,HI=.5,UI=500,xc=8,bc=300,Ac=8,GI=.6,WI=.2,qI=.85,ny=.4,VI=22,jI=22,ZI=18,XI=16,YI=16,KI=9,oy=12,$I="#f9a825",QI="#fff",JI="#888",e4=10,Rv=2e3,Ov=.5,t4=.5,Dv=12,ay=6,n4=2,o4="#222222",a4=1,r4=4,s4=.5,Pv=.3,i4=32,l4=.55,c4=.7,ry=.7,Bv=1.5,u4=2048,d4=0,f4=.1,Nv=ay*3,p4=6,sy="#888888",h4=1.5,iy=120,m4=.25,y4=.5,g4=10,x4=1,ly=1400,b4="#ff2d2d",zv=4,A4=8,Fv=480,v4=480,S4=270,L4=1e3/60,k4=1e3/12,_4=2,w4=2*1024*1024,T4=3e4,E4=24,C4="system-ui, sans-serif",I4="#1a1a1a",M4=1e3,R4=1,O4=10,D4=530,P4="#1a73e8",B4=.25,N4=1.5,cy=4,Hv=1.1,To=80,z4=8,uy=.5,F4=256,H4=30,U4=16,Uv=4,G4=4,W4="rgba(0,0,0,0.65)",q4=16,V4="#1a73e8",j4="#fff",mp=10,Z4=11,X4=.12,Y4=14,K4=3,$4=8;var yi=["nw","n","ne","e","se","s","sw","w"],gi=["nw","ne","se","sw"],Q4=e=>{switch(e){case"nw":case"se":return"nwse-resize";case"ne":case"sw":return"nesw-resize";case"n":case"s":return"ns-resize";case"e":case"w":return"ew-resize"}};var xi=(e,t,n=1)=>{let o=t.x+t.width/2,a=t.y+t.height/2,r=t.x+t.width,s=t.y+t.height,i=3/n;switch(e){case"nw":return{x:t.x-i,y:t.y-i};case"n":return{x:o,y:t.y-i};case"ne":return{x:r+i,y:t.y-i};case"e":return{x:r+i,y:a};case"se":return{x:r+i,y:s+i};case"s":return{x:o,y:s+i};case"sw":return{x:t.x-i,y:s+i};case"w":return{x:t.x-i,y:a}}},Gv=(e,t,n,o=11,a=yi)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=xi(f,t,n);if(Math.abs(e.x-p.x)<=r&&Math.abs(e.y-p.y)<=r)return f}let s=t.x,i=t.x+t.width,l=t.y,c=t.y+t.height,u=e.x>=s-r&&e.x<=i+r,d=e.y>=l-r&&e.y<=c+r;for(let f of a)switch(f){case"n":if(u&&Math.abs(e.y-l)<=r)return"n";break;case"s":if(u&&Math.abs(e.y-c)<=r)return"s";break;case"w":if(d&&Math.abs(e.x-s)<=r)return"w";break;case"e":if(d&&Math.abs(e.x-i)<=r)return"e";break}return null},vc=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,e.rotation),pU=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,-e.rotation),bi=e=>{let t=Re(e),n=t.x*e.scale.x,o=(t.x+t.width)*e.scale.x,a=t.y*e.scale.y,r=(t.y+t.height)*e.scale.y;return{bounds:{x:e.position.x+Math.min(n,o),y:e.position.y+Math.min(a,r),width:Math.abs(o-n),height:Math.abs(r-a)},rotation:e.rotation,pivot:e.position}},gp=e=>{let t=e.bounds;return[vc(e,{x:t.x,y:t.y}),vc(e,{x:t.x+t.width,y:t.y}),vc(e,{x:t.x+t.width,y:t.y+t.height}),vc(e,{x:t.x,y:t.y+t.height})]},J4=e=>vc(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),e5=(e,t,n=1)=>vc(t,xi(e,t.bounds,n)),t5=(e,t,n,o=11,a=yi)=>Gv(pU(t,e),t.bounds,n,o,a),hU={kind:"ratio",position:{x:0,y:1}},mU=new Map;var yU=e=>mU.get(e)??hU,dy=(e,t=1)=>{let n=yU(e.type),o=Yt(e,n),a=Xo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},fy=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},Wv=(e,t,n,o=11)=>{let a=o/n;return Math.abs(e.x-t.x)<=a&&Math.abs(e.y-t.y)<=a};function gU(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function xU(){let e=gU();if(e.__xstate__)return e.__xstate__}var n5=e=>{if(typeof window>"u")return;let t=xU();t&&t.register(e)};var py=class{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}},$v=".",bU="",Qv="",AU="#",vU="*",l5="xstate.init",c5="xstate.error",jv="xstate.stop";function SU(e,t){return{type:`xstate.after.${e}.${t}`}}function Zv(e,t){return{type:`xstate.done.state.${e}`,output:t}}function LU(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function Jv(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function my(e){return{type:l5,input:e}}function Qo(e){setTimeout(()=>{throw e})}var kU=typeof Symbol=="function"&&Symbol.observable||"@@observable";function e2(e,t){let n=o5(e),o=o5(t);return typeof o=="string"?typeof n=="string"?o===n:!1:typeof n=="string"?n in o:Object.keys(n).every(a=>a in o?e2(n[a],o[a]):!1)}function yy(e){if(f5(e))return e;let t=[],n="";for(let o=0;o<e.length;o++){switch(e.charCodeAt(o)){case 92:n+=e[o+1],o++;continue;case 46:t.push(n),n="";continue}n+=e[o]}return t.push(n),t}function o5(e){if(R5(e))return e.value;if(typeof e!="string")return e;let t=yy(e);return u5(t)}function u5(e){if(e.length===1)return e[0];let t={},n=t;for(let o=0;o<e.length-1;o++)if(o===e.length-2)n[e[o]]=e[o+1];else{let a=n;n={},a[e[o]]=n}return t}function t2(e,t){let n={},o=Object.keys(e);for(let a=0;a<o.length;a++){let r=o[a];n[r]=t(e[r],r,e,a)}return n}function d5(e){return f5(e)?e:[e]}function Jo(e){return e===void 0?[]:d5(e)}function Xv(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function f5(e){return Array.isArray(e)}function _U(e){return e.type.startsWith("xstate.error.actor")}function Ai(e){return d5(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function p5(e){if(!(e===void 0||e===bU))return Jo(e)}function xp(e,t,n){let o=typeof e=="object",a=o?e:void 0;return{next:(o?e.next:e)?.bind(a),error:(o?e.error:t)?.bind(a),complete:(o?e.complete:n)?.bind(a)}}function n2(e,t){return`${t}.${e}`}function Ap(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,o,a]=n,s=e.getStateNodeById(a).config.invoke;return(Array.isArray(s)?s[o]:s).src}function h5(e,t){if(t===e||t===vU)return!0;if(!t.endsWith(".*"))return!1;let n=t.split("."),o=e.split(".");for(let a=0;a<n.length;a++){let r=n[a],s=o[a];if(r==="*")return a===n.length-1;if(r!==s)return!1}return!0}function a5(e,t){return`${e.sessionId}.${t}`}var wU=0;function TU(e,t){let n=new Map,o=new Map,a=new WeakMap,r=new Set,s={},{clock:i,logger:l}=t,c={schedule:(f,p,h,m,x=Math.random().toString(36).slice(2))=>{let y={source:f,target:p,event:h,delay:m,id:x,startedAt:Date.now()},g=a5(f,x);d._snapshot._scheduledEvents[g]=y;let b=i.setTimeout(()=>{delete s[g],delete d._snapshot._scheduledEvents[g],d._relay(f,p,h)},m);s[g]=b},cancel:(f,p)=>{let h=a5(f,p),m=s[h];delete s[h],delete d._snapshot._scheduledEvents[h],m!==void 0&&i.clearTimeout(m)},cancelAll:f=>{for(let p in d._snapshot._scheduledEvents){let h=d._snapshot._scheduledEvents[p];h.source===f&&c.cancel(f,h.id)}}},u=f=>{if(!r.size)return;let p={...f,rootId:e.sessionId};r.forEach(h=>h.next?.(p))},d={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${wU++}`,_register:(f,p)=>(n.set(f,p),f),_unregister:f=>{n.delete(f.sessionId);let p=a.get(f);p!==void 0&&(o.delete(p),a.delete(f))},get:f=>o.get(f),getAll:()=>Object.fromEntries(o.entries()),_set:(f,p)=>{let h=o.get(f);if(h&&h!==p)throw new Error(`Actor with system ID '${f}' already exists.`);o.set(f,p),a.set(p,f)},inspect:f=>{let p=xp(f);return r.add(p),{unsubscribe(){r.delete(p)}}},_sendInspectionEvent:u,_relay:(f,p,h)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:p,event:h}),p._send(h)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{let f=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(let p in f){let{source:h,target:m,event:x,delay:y,id:g}=f[p];c.schedule(h,m,x,y,g)}},_clock:i,_logger:l};return d}var qv=!1,gy=1,Kt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),EU={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},hy=class{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new py(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Kt.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let o={...EU,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:TU(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(xp(u)),this.sessionId=this.system._bookId(),this.id=l??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=s,this._syncSnapshot=i,this.options=o,this.src=o.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{let f=this.eventListeners.get(d.type),p=this.eventListeners.get("*");if(!f&&!p)return;let h=[...f?f.values():[],...p?p.values():[]];for(let m of h)try{m(d)}catch(x){Qo(x)}},actionExecutor:d=>{let f=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;let p=qv;try{qv=!0,d.exec(d.info,d.params)}finally{qv=p}};this._processingStatus===Kt.Running?f():this._deferred.push(f)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(n?.snapshot??n?.state),c&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,n){this._snapshot=t;let o;for(;o=this._deferred.shift();)try{o()}catch(a){this._deferred.length=0,this._snapshot={...t,status:"error",error:a}}switch(this._snapshot.status){case"active":for(let a of this.observers)try{a.next?.(t)}catch(r){Qo(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Qo(r)}this._stopProcedure(),this._complete(),this._doneEvent=LU(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,o){let a=xp(t,n,o);if(this._processingStatus!==Kt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Qo(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Qo(r);else try{a.error(r)}catch(s){Qo(s)}break}}return{unsubscribe:()=>{this.observers.delete(a)}}}on(t,n){let o=this.eventListeners.get(t);o||(o=new Set,this.eventListeners.set(t,o));let a=n.bind(void 0);return o.add(a),{unsubscribe:()=>{o.delete(a)}}}select(t,n=Object.is){return{subscribe:o=>{let a=xp(o),r=this.getSnapshot(),s=t(r);return this.subscribe(i=>{let l=t(i);n(s,l)||(s=l,a.next?.(l))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===Kt.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=Kt.Running;let t=my(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,o;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(a){o={err:a}}if(o){let{err:a}=o;this._snapshot={...this._snapshot,status:"error",error:a},this._error(a);return}this.update(n,t),t.type===jv&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Kt.Stopped?this:(this.mailbox.clear(),this._processingStatus===Kt.NotStarted?(this._processingStatus=Kt.Stopped,this):(this.mailbox.enqueue({type:jv}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(n){Qo(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Qo(t),this.eventListeners.clear();return}let n=!1;for(let o of this.observers){let a=o.error;n||=!a;try{a?.(t)}catch(r){Qo(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Qo(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,Jv(this.id,t))}_stopProcedure(){return this._processingStatus!==Kt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new py(this._process.bind(this)),this._processingStatus=Kt.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==Kt.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&(typeof t=="function"?t:n5)(this)}toJSON(){return{xstate$$type:gy,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[kU](){return this}getSnapshot(){return this._snapshot}};function ea(e,...[t]){return new hy(e,t)}function CU(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function IU(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function _c(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=CU,t.execute=IU,t}function MU(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?Ap(t.machine,s):s,u=typeof a=="function"?a(n):a,d,f;return c&&(f=typeof i=="function"?i({context:t.context,event:n.event,self:e.self}):i,d=ea(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Jr(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function RU(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Kt.Stopped&&t.start()})}function wc(...[e,{id:t,systemId:n,input:o,syncSnapshot:a=!1}={}]){function r(s,i){}return r.type="xstate.spawnChild",r.id=t,r.systemId=n,r.src=e,r.input=o,r.syncSnapshot=a,r.resolve=MU,r.execute=RU,r}function OU(e,t,n,o,{actorRef:a}){let r=typeof a=="function"?a(n,o):a,s=typeof r=="string"?t.children[r]:r,i=t.children;return s&&(i={...i},delete i[s.id]),[Jr(t,{children:i}),s,void 0]}function m5(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))m5(e,o);e.system._unregister(t)}function DU(e,t){if(t){if(m5(e,t),t._processingStatus!==Kt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Li(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=OU,t.execute=DU,t}function PU(e,{context:t,event:n},{guards:o}){return o.every(a=>ki(a,t,n,e))}function y5(e){function t(n,o){return!1}return t.check=PU,t.guards=e,t}function ki(e,t,n,o){let{machine:a}=o,r=typeof e=="function",s=r?e:a.implementations.guards[typeof e=="string"?e:e.type];if(!r&&!s)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof s!="function")return ki(s,t,n,o);let i={context:t,event:n},l=r||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in s?s.check(o,i,s):s(i,l)}function xy(e){return e.type==="atomic"||e.type==="final"}function Lc(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Tc(e,t){let n=[];if(t===e)return n;let o=e.parent;for(;o&&o!==t;)n.push(o),o=o.parent;return n}function vp(e){let t=new Set(e),n=x5(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))r5(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of Lc(o))if(a.type!=="history"&&!t.has(a)){let r=r5(a);for(let s of r)t.add(s)}}for(let o of t){let a=o.parent;for(;a;)t.add(a),a=a.parent}return t}function g5(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(xy(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=g5(a,t);return o}function x5(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function b5(e,t){let n=vp(t);return g5(e,x5(n))}function by(e,t){return t.type==="compound"?Lc(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?Lc(t).every(n=>by(e,n)):t.type==="final"}var Sp=e=>e[0]===AU;function A5(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>h5(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function v5(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=SU(a,e.id),s=r.type;return e.entry.push(Cc(r,{id:s,delay:a})),e.exit.push(_c(s)),s};return Object.keys(t).flatMap(a=>{let r=t[a],s=typeof r=="string"?{target:r}:r,i=Number.isNaN(+a)?a:+a,l=n(i);return Jo(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{...ja(e,a.event,a),delay:r}})}function ja(e,t,n){let o=p5(n.target),a=n.reenter??!1,r=BU(e,o),s={...n,actions:Jo(n.actions),guard:n.guard,target:r,source:e,reenter:a,eventType:t,toJSON:()=>({...s,source:`#${e.id}`,target:r?r.map(i=>`#${i.id}`):void 0})};return s}function S5(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===Qv)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,Ai(o).map(a=>ja(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,Ai(e.config.onDone).map(o=>ja(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,Ai(n.onDone).map(a=>ja(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,Ai(n.onError).map(a=>ja(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,Ai(n.onSnapshot).map(a=>ja(e,o,a)))}}for(let n of e.after){let o=t.get(n.eventType);o||(o=[],t.set(n.eventType,o)),o.push(n)}return t}function L5(e){let t=[],n=o=>{Object.values(o).forEach(a=>{if(a.config.route&&a.config.id){let r=a.config.id,s=a.config.route.guard,i=({event:c})=>c.to===`#${r}`,l={...a.config.route,guard:s?y5([i,s]):i,target:`#${r}`};t.push(ja(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function k5(e,t){let n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let o={source:e,actions:!t||typeof t=="string"?[]:Jo(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function BU(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(Sp(n))return e.machine.getStateNodeById(n);let o=n[0]===$v;if(o&&!e.parent)return bp(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return bp(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
12
+ ${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function _5(e){let t=p5(e.config.target);return t?{target:t.map(n=>typeof n=="string"?bp(e.parent,n):n)}:e.parent.initial}function vi(e){return e.type==="history"}function r5(e){let t=w5(e);for(let n of t)for(let o of Tc(n,e))t.add(o);return t}function w5(e){let t=new Set;function n(o){if(!t.has(o)){if(t.add(o),o.type==="compound")n(o.initial.target[0]);else if(o.type==="parallel")for(let a of Lc(o))n(a)}}return n(e),t}function kc(e,t){if(Sp(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function bp(e,t){if(typeof t=="string"&&Sp(t))try{return e.machine.getStateNodeById(t)}catch{}let n=yy(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=kc(o,a)}return o}function Ec(e,t){if(typeof t=="string"){let a=e.states[t];if(!a)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,a]}let n=Object.keys(t),o=n.map(a=>kc(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=kc(e,r);if(!s)return a;let i=Ec(s,t[r]);return a.concat(i)},[]))}function NU(e,t,n,o){let r=kc(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function zU(e,t,n,o){let a=Object.keys(t),r=kc(e,a[0]),s=Ay(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function FU(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=kc(e,r),l=Ay(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function Ay(e,t,n,o){return typeof t=="string"?NU(e,t,n,o):Object.keys(t).length===1?zU(e,t,n,o):FU(e,t,n,o)}function HU(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function Qr(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function UU(e,t){let n=new Set(e),o=new Set(t);for(let a of n)if(o.has(a))return!0;for(let a of o)if(n.has(a))return!0;return!1}function T5(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(UU(Yv([a],t,n),Yv([i],t,n)))if(Qr(a.source,i.source))s.add(i);else{r=!0;break}if(!r){for(let i of s)o.delete(i);o.add(a)}}return Array.from(o)}function GU(e){let[t,...n]=e;for(let o of Tc(t,void 0))if(n.every(a=>Qr(a,o)))return o}function o2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(vi(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of o2(_5(o),t))n.add(a);else n.add(o);return[...n]}function E5(e,t){let n=o2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||Qr(a,e.source)))return e.source;let o=GU(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function Yv(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=E5(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)Qr(s,r)&&o.add(s)}return[...o]}function WU(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function a2(e,t,n,o,a){return Kv([{target:[...w5(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function Kv(e,t,n,o,a,r){let s=[];if(!e.length)return[t,s];let i=n.actionExecutor;n.actionExecutor=l=>{s.push(l),i(l)};try{let l=new Set(t._nodes),c=t.historyValue,u=T5(e,l,c),d=t;a||([d,c]=ZU(d,o,n,u,l,c,r,n.actionExecutor)),d=Si(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=VU(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=Si(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&WU(t._nodes,l)?[d,s]:[Jr(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function qU(e,t,n,o,a){if(o.output===void 0)return;let r=Zv(a.id,a.output!==void 0&&a.parent?Xv(a.output,e.context,t,n.self):void 0);return Xv(o.output,e.context,r,n.self)}function VU(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;jU(o,s,u,c),i&&u.add(e.machine.root);let d=new Set;for(let f of[...c].sort((p,h)=>p.order-h.order)){a.add(f);let p=[];p.push(...f.entry);for(let h of f.invoke)p.push(wc(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=Si(l,t,n,p,r,f.invoke.map(h=>h.id)),f.type==="final"){let h=f.parent,m=h?.type==="parallel"?h:h?.parent,x=m||f;for(h?.type==="compound"&&r.push(Zv(h.id,f.output!==void 0?Xv(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&by(a,m);)d.add(m),r.push(Zv(m.id)),x=m,m=m.parent;if(m)continue;l=Jr(l,{status:"done",output:qU(l,t,n,l.machine.root,x)})}}return l}function jU(e,t,n,o){for(let a of e){let r=E5(a,t);for(let i of a.target||[])!vi(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),Sc(i,t,n,o);let s=o2(a,t);for(let i of s){let l=Tc(i,r);r?.type==="parallel"&&l.push(r),C5(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function Sc(e,t,n,o){if(vi(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),Sc(r,t,n,o);for(let r of a)Vv(r,e.parent,o,t,n)}else{let a=_5(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),Sc(r,t,n,o);for(let r of a.target)Vv(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;vi(a)||(o.add(a),n.add(a)),Sc(a,t,n,o),Vv(a,e,o,t,n)}else if(e.type==="parallel")for(let a of Lc(e).filter(r=>!vi(r)))[...o].some(r=>Qr(r,a))||(vi(a)||(o.add(a),n.add(a)),Sc(a,t,n,o))}function C5(e,t,n,o,a){for(let r of o)if((!a||Qr(r,a))&&e.add(r),r.type==="parallel")for(let s of Lc(r).filter(i=>!vi(i)))[...e].some(i=>Qr(i,s))||(e.add(s),Sc(s,t,n,e))}function Vv(e,t,n,o,a){C5(n,o,a,Tc(e,t))}function ZU(e,t,n,o,a,r,s,i){let l=e,c=Yv(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of HU(d)){let p;f.history==="deep"?p=h=>xy(h)&&Qr(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=Si(l,t,n,[...d.exit,...d.invoke.map(f=>Li(f.id))],s,void 0),a.delete(d);return[l,u||r]}function XU(e,t){return e.implementations.actions[t]}function I5(e,t,n,o,a,r){let{machine:s}=e,i=e;for(let l of o){let c=typeof l=="function",u=c?l:XU(s,typeof l=="string"?l:l.type),d={context:i.context,event:t,self:n.self,system:n.system},f=c||typeof l=="string"?void 0:"params"in l?typeof l.params=="function"?l.params({context:i.context,event:t}):l.params:void 0;if(!u||!("resolve"in u)){n.actionExecutor({type:typeof l=="string"?l:typeof l=="object"?l.type:l.name||"(anonymous)",info:d,params:f,exec:u});continue}let p=u,[h,m,x]=p.resolve(n,i,d,f,u,a);i=h,"retryResolve"in p&&r?.push([p,m]),"execute"in p&&n.actionExecutor({type:p.type,info:d,params:m,exec:p.execute.bind(null,n,m)}),x&&(i=I5(i,t,n,x,a,r))}return i}function Si(e,t,n,o,a,r){let s=r?[]:void 0,i=I5(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function Lp(e,t,n,o){let a=e,r=[];function s(d,f,p){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:f,snapshot:d[0],_transitions:p}),r.push(d)}if(t.type===jv)return a=Jr(s5(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==l5){let d=i,f=_U(d),p=i5(d,a);if(f&&!p.length)return a=Jr(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=Kv(p,e,n,i,!1,o);a=h[0],s(h,d,p)}let l=!0,c=e.machine.options?.maxIterations??1/0,u=0;for(;a.status==="active";){if(u++,u>c)throw new Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let d=l?YU(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=i5(i,a)}let p=Kv(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&s5(a,i,n),{snapshot:a,microsteps:r}}function s5(e,t,n){return Si(e,t,n,Object.values(e.children).map(o=>Li(o)),[],void 0)}function i5(e,t){return t.machine.getTransitionData(t,e)}function YU(e,t){let n=new Set,o=e._nodes.filter(xy);for(let a of o)e:for(let r of[a].concat(Tc(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||ki(s.guard,e.context,t,e)){n.add(s);break e}}return T5(Array.from(n),new Set(e._nodes),e.historyValue)}function M5(e,t){let n=vp(Ec(e,t));return b5(e,[...n])}function R5(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var KU=function(t){return e2(t,this.value)},$U=function(t){return this.tags.has(t)},QU=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},JU=function(){let{_nodes:t,tags:n,machine:o,getMeta:a,toJSON:r,can:s,hasTag:i,matches:l,...c}=this;return{...c,tags:Array.from(n)}},eG=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function kp(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:b5(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:KU,hasTag:$U,can:QU,getMeta:eG,toJSON:JU}}function Jr(e,t={}){return kp({...e,...t},e.machine)}function tG(e){if(typeof e!="object"||e===null)return{};let t={};for(let n in e){let o=e[n];Array.isArray(o)&&(t[n]=o.map(a=>({id:a.id})))}return t}function O5(e,t){let{_nodes:n,tags:o,machine:a,children:r,context:s,can:i,hasTag:l,matches:c,getMeta:u,toJSON:d,...f}=e,p={};for(let m in r){let x=r[m];p[m]={snapshot:x.getPersistedSnapshot(t),src:x.src,systemId:x.systemId,syncSnapshot:x._syncSnapshot}}return{...f,context:D5(s),children:p,historyValue:tG(f.historyValue)}}function D5(e){let t;for(let n in e){let o=e[n];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:gy,id:o.id};else{let a=D5(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function nG(e,t,n,o,{event:a,id:r,delay:s},{internalQueue:i}){let l=t.machine.implementations.delays;if(typeof a=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${a}" }) instead`);let c=typeof a=="function"?a(n,o):a,u;if(typeof s=="string"){let d=l&&l[s];u=typeof d=="function"?d(n,o):d}else u=typeof s=="function"?s(n,o):s;return typeof u!="number"&&i.push(c),[t,{event:c,id:r,delay:u},void 0]}function oG(e,t){let{event:n,delay:o,id:a}=t;if(typeof o=="number"){e.defer(()=>{let r=e.self;e.system.scheduler.schedule(r,r,n,o,a)});return}}function Cc(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=nG,n.execute=oG,n}function P5(e,t){return{config:e,transition:(n,o,a)=>({...n,context:e(n.context,o,a)}),getInitialSnapshot:(n,o)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:o}):t}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}var Kie=P5(e=>{},void 0);function aG(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=Ap(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=ea(l,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:typeof i?.input=="function"?i.input({context:n,event:o,self:e.self}):i?.input,src:s,systemId:i?.systemId});return a[c.id]=c,c}else return ea(s,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:i?.input,src:s,systemId:i?.systemId})};return(s,i)=>{let l=r(s,i);return a[l.id]=l,e.defer(()=>{l._processingStatus!==Kt.Stopped&&l.start()}),l}}function rG(e,t,n,o,{assignment:a}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let r={},s={context:t.context,event:n.event,spawn:aG(e,t,n.event,r),self:e.self,system:e.system},i={};if(typeof a=="function")i=a(s,o);else for(let c of Object.keys(a)){let u=a[c];i[c]=typeof u=="function"?u(s,o):u}let l=Object.assign({},t.context,i);return[Jr(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function Pn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=rG,t}var B5=new WeakMap;function Ic(e,t,n){let o=B5.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},B5.set(e,o)),o[t]}var sG={},_p=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,vy=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join($v),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?t2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):sG,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=Jo(this.config.entry).slice(),this.exit=Jo(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Jo(t.tags).slice()}_initialize(){this.transitions=S5(this),this.config.always&&(this.always=Ai(this.config.always).map(t=>ja(this,Qv,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(_p),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(_p),eventType:null})}:void 0,history:this.history,states:t2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(_p)})),entry:this.entry.map(_p),exit:this.exit.map(_p),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Ic(this,"invoke",()=>Jo(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??n2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${n2(this.id,n)}`;return{...t,src:s,id:r,systemId:a,toJSON(){let{onDone:i,onError:l,...c}=t;return{...c,type:"xstate.invoke",src:s,id:r}}}}))}get on(){return Ic(this,"on",()=>[...this.transitions].flatMap(([n,o])=>o.map(a=>[n,a])).reduce((n,[o,a])=>(n[o]=n[o]||[],n[o].push(a),n),{}))}get after(){return Ic(this,"delayedTransitions",()=>v5(this))}get initial(){return Ic(this,"initial",()=>k5(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=Ic(this,`candidates-${o}`,()=>A5(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||ki(l,c,n,t)}catch(d){let f=typeof l=="string"?l:typeof l=="object"?l.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${o}' in state node '${this.id}':
13
+ ${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return Ic(this,"events",()=>{let{states:t}=this,n=new Set(this.ownEvents);if(t)for(let o of Object.keys(t)){let a=t[o];if(a.states)for(let r of a.events)n.add(`${r}`)}return Array.from(n)})}get ownEvents(){let t=Object.keys(Object.fromEntries(this.transitions)),n=new Set(t.filter(o=>this.transitions.get(o).some(a=>!(!a.target&&!a.actions.length&&!a.reenter))));return Array.from(n)}},iG="#",Sy=class e{constructor(t,n){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new vy(t,{_key:this.id,_machine:this}),this.root._initialize(),L5(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:o,actors:a,delays:r}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...o,...t.guards},actors:{...a,...t.actors},delays:{...r,...t.delays}})}resolveState(t){let n=M5(this.root,t.value),o=vp(Ec(this.root,n));return kp({_nodes:[...o],context:t.context||{},children:{},status:by(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return Lp(t,n,o,[]).snapshot}microstep(t,n,o){return Lp(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return Ay(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=kp({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?Si(r,n,t,[Pn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=my(n),a=[],r=this._getPreInitialState(t,o,a),[s]=a2(this.root,r,t,o,a),{snapshot:i}=Lp(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=yy(t),o=n.slice(1),a=Sp(n[0])?n[0].slice(iG.length):n[0],r=this.idMap.get(a);if(!r)throw new Error(`Child state node '#${a}' does not exist on machine '${this.id}'`);return bp(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return O5(t,n)}restoreSnapshot(t,n){let o={},a=t.children;Object.keys(a).forEach(d=>{let f=a[d],p=f.snapshot,h=f.src,m=typeof h=="string"?Ap(this,h):h;if(!m)return;let x=ea(m,{id:d,parent:n.self,syncSnapshot:f.syncSnapshot,snapshot:p,src:h,systemId:f.systemId});o[d]=x});function r(d,f){if(f instanceof vy)return f;try{return d.machine.getStateNodeById(f.id)}catch{}}function s(d,f){if(!f||typeof f!="object")return{};let p={};for(let h in f){let m=f[h];for(let x of m){let y=r(d,x);y&&(p[h]??=[],p[h].push(y))}}return p}let i=s(this.root,t.historyValue),l=kp({...t,children:o,_nodes:Array.from(vp(Ec(this.root,t.value))),historyValue:i},this),c=new Set;function u(d,f){if(!c.has(d)){c.add(d);for(let p in d){let h=d[p];if(h&&typeof h=="object"){if("xstate$$type"in h&&h.xstate$$type===gy){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function lG(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function cG(e,{event:t}){e.defer(()=>e.emit(t))}function ky(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=lG,t.execute=cG,t}var Ly=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function uG(e,t,n,o,{to:a,event:r,id:s,delay:i},l){let c=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);let u=typeof r=="function"?r(n,o):r,d;if(typeof i=="string"){let h=c&&c[i];d=typeof h=="function"?h(n,o):h}else d=typeof i=="function"?i(n,o):i;let f=typeof a=="function"?a(n,o):a,p;if(typeof f=="string"){if(f===Ly.Parent?p=e.self._parent:f===Ly.Internal?p=e.self:f.startsWith("#_")?p=t.children[f.slice(2)]:p=l.deferredActorIds?.includes(f)?f:t.children[f],!p)throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f=="string"?f:void 0,event:u,id:s,delay:d},void 0]}function dG(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function fG(e,t){e.defer(()=>{let{to:n,event:o,delay:a,id:r}=t;if(typeof a=="number"){e.system.scheduler.schedule(e.self,n,o,a,r);return}e.system._relay(e.self,n,o.type===c5?Jv(e.self.id,o.data):o)})}function wp(e,t,n){function o(a,r){}return o.type="xstate.sendTo",o.to=e,o.event=t,o.id=n?.id,o.delay=n?.delay,o.resolve=uG,o.retryResolve=dG,o.execute=fG,o}function N5(e,t){return wp(Ly.Parent,e,t)}function pG(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(Pn(...i))},s.cancel=(...i)=>{r.push(_c(...i))},s.raise=(...i)=>{r.push(Cc(...i))},s.sendTo=(...i)=>{r.push(wp(...i))},s.sendParent=(...i)=>{r.push(N5(...i))},s.spawnChild=(...i)=>{r.push(wc(...i))},s.stopChild=(...i)=>{r.push(Li(...i))},s.emit=(...i)=>{r.push(ky(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>ki(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function Ct(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=pG,t}function hG(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function mG({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function r2(e=({context:n,event:o})=>({context:n,event:o}),t){function n(o,a){}return n.type="xstate.log",n.value=e,n.label=t,n.resolve=hG,n.execute=mG,n}function yG(e,t){return new Sy(e,t)}function s2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:Pn,sendTo:wp,raise:Cc,log:r2,cancel:_c,stopChild:Li,enqueueActions:Ct,emit:ky,spawnChild:wc,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>yG({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>s2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var gG=()=>({mode:I0,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),_i=4,ta=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=_i*_i},Tp=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y);return{x:n,y:o,width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}},z5=s2({types:{context:{},events:{},emitted:{}},actions:{startPress:Pn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:Pn((e,t)=>({pressLast:t.point})),setDrawingType:Pn((e,t)=>({drawingType:t.kind})),resetGesture:Pn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:Pn((e,t)=>({mode:t.mode})),emitMoveElement:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||n.emit({type:"MOVE_SHAPE",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitMoveAnnotation:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||n.emit({type:"MOVE_ANNOTATION",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalPosition:e.pressTarget.origin})}),emitCommitAnnotationDrag:Ct(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"||n.emit({type:"RESIZE_SHAPE",id:e.pressTarget.elementId,handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitResizeGroup:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"||n.emit({type:"RESIZE_GROUP",handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitRotate:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle")return;let{pivot:o}=e.pressTarget,a=Math.atan2(e.pressOrigin.y-o.y,e.pressOrigin.x-o.x),r=Math.atan2(t.point.y-o.y,t.point.x-o.x);n.emit({type:"ROTATE",pivot:o,deltaAngle:r-a})}),maybeEmitCreate:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=Tp(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||n.emit({type:"DRAW_EDGE_PREVIEW",fromElement:e.pressTarget?.kind==="element"?e.pressTarget.id:null,fromPoint:e.pressOrigin,toPoint:t.point})}),emitLinkPreviewClear:Ct(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:Ct(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind==="edge-endpoint"&&n.emit({type:"UPDATE_EDGE_ENDPOINT_PREVIEW",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point})}),emitLinkEndpointUpdate:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint")return;let o=t.target,a=o?.kind==="element"?o.id:null;n.emit({type:"UPDATE_EDGE_ENDPOINT",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point,toElement:a})}),emitLassoProgress:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin)return;let o=e.pressModifiers,a=!!(o&&(o.shift||o.meta||o.ctrl));n.emit({type:"LASSO_PROGRESS",bounds:Tp(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=Tp(e.pressOrigin,t.point);if(o.width<1&&o.height<1){n.emit({type:"LASSO_CLEAR"});return}let a=e.pressModifiers,r=!!(a&&(a.shift||a.meta||a.ctrl));n.emit({type:"SELECT_BY_BOUNDS",bounds:o,mode:r?"add":"replace"}),n.emit({type:"LASSO_CLEAR"})}),emitCreateLink:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=t.target,a=o?.kind==="element"?o.id:null,r=e.pressTarget?.kind==="element"?e.pressTarget.id:null,s=t.point.x-e.pressOrigin.x,i=t.point.y-e.pressOrigin.y;s*s+i*i<_i*_i||n.emit({type:"CREATE_EDGE",fromElement:r,toElement:a,fromPoint:e.pressOrigin,toPoint:t.point})})},guards:{movedAndOnElement:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||e.mode!=="select"?!1:ta(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:ta(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:ta(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:ta(e.pressOrigin,t.point),movedAndDrawing:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-rect"&&e.mode!=="draw-ellipse"&&e.mode!=="draw-frame"?!1:ta(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:ta(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:ta(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:ta(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:ta(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:gG(),on:{SET_MODE:{target:".idle",actions:[{type:"setMode",params:({event:e})=>({mode:e.mode})},{type:"resetGesture"}]}},states:{idle:{on:{POINTER_DOWN:{target:"pressing",actions:[{type:"startPress",params:({event:e})=>({point:e.point,target:e.target,modifiers:e.modifiers??null})}]}}},pressing:{on:{POINTER_MOVE:[{guard:"movedAndOnHandle",target:"draggingHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},{guard:"movedAndOnGroupHandle",target:"draggingGroupHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},{guard:"movedAndOnRotateHandle",target:"draggingRotateHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},{guard:"movedAndOnElement",target:"draggingElement",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},{guard:"movedAndDrawing",target:"drawing",actions:[{type:"setDrawingType",params:({context:e})=>({kind:e.mode==="draw-rect"?"rect":e.mode==="draw-frame"?"frame":"ellipse"})},{type:"updateLast",params:({event:e})=>({point:e.point})}]},{guard:"movedAndDrawingLink",target:"drawingLink",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},{guard:"movedAndOnLinkEndpoint",target:"draggingLinkEndpoint",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},{guard:"movedAndOnAnnotation",target:"draggingAnnotation",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},{guard:"movedAndLasso",target:"lassoing",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]}],POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingElement:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingGroupHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingRotateHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]},POINTER_UP:{target:"idle",actions:[{type:"maybeEmitCreate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawingLink:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCreateLink"},{type:"emitLinkPreviewClear"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLinkPreviewClear"},{type:"resetGesture"}]}}},draggingLinkEndpoint:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLinkEndpointUpdate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingAnnotation:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCommitAnnotationDrag"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},lassoing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]}}}}}),F5=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||ta(e.pressOrigin,t)||e.mode==="draw-edge")return null;if(e.pressTarget.kind==="element"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_REPLACE",id:e.pressTarget.id}}if(e.pressTarget.kind==="link"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_EDGE_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_EDGE_REPLACE",id:e.pressTarget.id}}return e.pressTarget.kind==="empty"&&e.mode==="select"?{type:"SELECT_CLEAR"}:null};var H5=new Map,so=(e,t)=>{H5.set(e,t)},es=e=>H5.get(e);var wi=["background","main","overlay"];var U5=(e,t)=>{let n=new Map,o=r=>{e.setOpacity(r*t)},a={get(r,s){if(s==="setOpacity")return o;if(n.has(s))return n.get(s);let i=Reflect.get(r,s),l=typeof i=="function"?i.bind(r):i;return n.set(s,l),l}};return new Proxy(e,a)};var ts=class{entries=new Map;get(t){let n=this.entries.get(t.id);if(n){if(n.ref!==t){this.entries.delete(t.id);return}return n.value}}set(t,n){return this.entries.set(t.id,{ref:t,value:n}),n}getOrCompute(t,n){let o=this.get(t);return o!==void 0?o:this.set(t,n(t))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.elements.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},xG=new ts,Mc=(e,t)=>e.getOrCompute(t,N);var i2={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var _y={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var l2={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var Ti={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var c2={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var u2={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var d2={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var Rc={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var Ei={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var f2={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var Za={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var p2={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var Oc={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var Dc={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var ns=["tomato","amber","grass","cyan","iris","plum","gray"],Ep=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},fn=(e,t)=>({fill:Ep(e,`${t}4`),solid:Ep(e,`${t}9`),solidHover:Ep(e,`${t}10`),textLow:Ep(e,`${t}11`),textHigh:Ep(e,`${t}12`)}),Pc={light:{tomato:fn(Ei,"tomato"),amber:fn(Dc,"amber"),grass:fn(Oc,"grass"),cyan:fn(p2,"cyan"),iris:fn(Za,"iris"),plum:fn(f2,"plum"),gray:fn(Rc,"gray")},dark:{tomato:fn(_y,"tomato"),amber:fn(d2,"amber"),grass:fn(u2,"grass"),cyan:fn(c2,"cyan"),iris:fn(Ti,"iris"),plum:fn(l2,"plum"),gray:fn(i2,"gray")}},wy={light:{tomato:Ei.tomato2,amber:Dc.amber2,grass:Oc.grass2,cyan:p2.cyan2,iris:Za.iris2,plum:f2.plum2,gray:Rc.gray2},dark:{tomato:_y.tomato2,amber:d2.amber2,grass:u2.grass2,cyan:c2.cyan2,iris:Ti.iris2,plum:l2.plum2,gray:i2.gray2}};var bG={light:{accent:Za.iris9,accentHover:Za.iris10,selectedBg:Za.iris4,selectedFg:Za.iris11,danger:Ei.tomato9},dark:{accent:Ti.iris9,accentHover:Ti.iris10,selectedBg:Ti.iris4,selectedFg:Ti.iris11,danger:_y.tomato9}},h2=Rc.gray6,m2=Rc.gray9,os={rectangle:{fill:Za.iris3,stroke:Za.iris9,strokeWidth:2},ellipse:{fill:Ei.tomato3,stroke:Ei.tomato9,strokeWidth:2},flowchart:{fill:Oc.grass3,stroke:Oc.grass9,strokeWidth:2},sticky:{fill:Dc.amber3,stroke:Dc.amber9,strokeWidth:1}},Bc={stroke:Rc.gray12,strokeWidth:1.5},AG={added:Oc.grass9,removed:Ei.tomato9,modified:Dc.amber9};var y2={placeholder:.15,hideText:.4},g2="#bbb";var x2=.06,b2=.92,A2=.5,Nc=10,v2=h2,S2=m2,L2=1,k2=1,_2=4,w2=4,T2=3,E2=12,C2=56,I2=10,M2=20,G5=.4,W5=.5,R2=.1,O2=.9,q5="#888",V5="#ffffff",j5="#222",Z5="#ddd",X5=18,Y5=12,K5="#444",$5="#222",Q5=10,D2="#000",J5="#222",eM="#fff",tM=4;var Cp=class{cap;onEvict;map=new Map;constructor(t,n){this.cap=t,this.onEvict=n}get(t){let n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}has(t){return this.map.has(t)}set(t,n){for(this.map.delete(t),this.map.set(t,n);this.map.size>this.cap;){let o=this.map.keys().next().value,a=this.map.get(o);this.map.delete(o),a!==void 0&&this.onEvict?.(o,a)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var Ty=e=>e<=0?1:2**Math.round(Math.log2(e));var Xa=(e,t,n={})=>{let o=ao(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let C=[z.applyToPoint(o,{x:a.x,y:a.y}),z.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],w=j.expand(j.fromPoints(C),2);t.clear(w)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new ts,s=n.viewport,i=null;s&&n.spatialIndex&&(i=n.spatialIndex.query(s));let l=e.viewport.zoom,c=n.clock,u=c?{zoom:l,clock:c}:{zoom:l},d=n.lod,f=d?.placeholder!==void 0&&l<d.placeholder,p=d?.hideText!==void 0&&l<d.hideText,h=n.placeholderFill??g2,m=n.layerCompositeCache,x=n.dirtyLayerIds,y=n.compositeLayerBitmap,g=Ty(l),b=C=>{let w=null;for(let L of Ga(e,C)){let k=Mc(r,L);w=w?j.union(w,k):k}return w},A=n.dimOpacity,_=n.dimElements!==void 0&&A!==void 0?U5(t,A):null;for(let C of Lo(e))if(C.visible){if(m&&y){x?.has(C.id)&&m.invalidateLayer(C.id);let w=m.get(C.id,g);if(w===void 0){let L=y(C.id,g,e);L!==null&&(m.set(C.id,g,L),w=L)}if(w!==void 0){let L=b(C.id);L&&t.drawImage(w,L.x,L.y,L.width,L.height);continue}}for(let w of Ga(e,C.id)){if(n.hideElements?.has(w.id)||i&&!i.has(w.id))continue;if(s){let B=Mc(r,w);if(!j.intersects(B,s))continue}if(a){let B=Mc(r,w);if(!j.intersects(B,a))continue}if(p&&pe(w))continue;if(f){let B=Mc(r,w);t.setFill(h),t.setStrokeWidth(0),t.beginPath(),t.rect(B.x,B.y,B.width,B.height),t.fill();continue}let L=es(w.type);if(!L){n.onUnknownElement?.(w);continue}t.save();let k=_!==null&&n.dimElements?.has(w.id)===!0,M=k?_:t;k&&M.setOpacity(1),M.translate(w.position.x,w.position.y),w.rotation!==0&&M.rotate(w.rotation),(w.scale.x!==1||w.scale.y!==1)&&M.scale(w.scale.x,w.scale.y),L(w,M,u),t.restore()}}t.restore()};var P2=(e,t,n)=>{let{maxWidth:o}=n,a=n.lineHeightFactor??1.2,r=[],s=n.fontFamily??"sans-serif",i=n.shaper,l=i?u=>i.measure(u,{family:s,size:n.fontSize}).width:u=>t.measureText(u).width;for(let u of e.split(`
14
+ `)){if(u===""){r.push({text:"",width:0});continue}let d=u.split(/\s+/).filter(m=>m.length>0);if(d.length===0){r.push({text:"",width:0});continue}let f=d[0];if(f===void 0){r.push({text:"",width:0});continue}let p=f,h=l(p);for(let m=1;m<d.length;m++){let x=d[m];if(x===void 0)continue;let y=`${p} ${x}`,g=l(y);g<=o?(p=y,h=g):(r.push({text:p,width:h}),p=x,h=l(x))}r.push({text:p,width:h})}let c=n.fontSize*a;return{lines:r,lineHeight:c}};var nM=1.2,vG=(e,t,n,o,a)=>{if(e===""){a.push({text:"",start:t,end:t,width:0});return}let r=[],s=/\S+/g,i;for(;(i=s.exec(e))!==null;)r.push({s:i.index,e:i.index+i[0].length});if(r.length===0){a.push({text:e,start:t,end:t+e.length,width:o(e)});return}let l=0,c=(d,f)=>{let p=e.slice(d,f);a.push({text:p,start:t+d,end:t+f,width:o(p)})},u=0;for(;u<r.length;){let d=v(r[u]);if(o(e.slice(l,d.e))<=n){u++;continue}if(d.s>l){c(l,d.s),l=d.s;continue}let f=d.s+1;for(;f<d.e&&o(e.slice(l,f+1))<=n;)f++;if(f>=d.e){u++;continue}c(l,f),l=f,d.s=f}c(l,e.length)},zc=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??nM),a=[],r=0;for(let l=0;l<=e.length;l++)if(l===e.length||e[l]===`
15
+ `){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):vG(c,r,n.maxWidth,t,a),r=l+1}a.length===0&&a.push({text:"",start:0,end:0,width:0});let s=0;for(let l of a)s=Math.max(s,l.width);let i=n.maxWidth??s;return{lines:a,lineHeight:o,blockWidth:i}},B2=(e,t,n)=>n==="center"?t/2-e/2:n==="right"?t-e:0,SG=(e,t)=>{let{lines:n}=e;for(let o=0;o<n.length;o++){let a=v(n[o]);if(t<=a.end)return o}return n.length-1},N2=(e,t,n,o,a)=>{let r=SG(e,t),s=v(e.lines[r]),i=Math.max(0,Math.min(t,s.end)-s.start),l=i===0?0:n(s.text.slice(0,i));return{x:B2(s.width,e.blockWidth,a)+l,y:r*e.lineHeight,height:o,line:r}},z2=(e,t,n,o)=>{let{lines:a,lineHeight:r}=e,s=Math.max(0,Math.min(a.length-1,Math.floor(t.y/r))),i=v(a[s]),l=B2(i.width,e.blockWidth,o),c=0,u=Math.abs(l-t.x);for(let d=1;d<=i.text.length;d++){let f=l+n(i.text.slice(0,d)),p=Math.abs(f-t.x);p<u&&(u=p,c=d)}return i.start+c},F2=(e,t,n,o,a)=>{let r=Math.min(t,n),s=Math.max(t,n);if(r===s)return[];let i=[];for(let l=0;l<e.lines.length;l++){let c=v(e.lines[l]),u=Math.max(r,c.start),d=Math.min(s,c.end);if(u>d||u===d&&!(r<=c.start&&s>c.end)&&!(s>c.end&&r<=c.end))continue;let f=B2(c.width,e.blockWidth,a),p=f+(u===c.start?0:o(c.text.slice(0,u-c.start))),h=f+(d===c.start?0:o(c.text.slice(0,d-c.start))),m=s>c.end?e.lineHeight*.25:0;i.push({x:p,y:l*e.lineHeight,width:Math.max(0,h-p)+m,height:e.lineHeight})}return i};var oM=new Map,Ip=e=>{oM.set(e.kind,e)};var H2=new Set,U2=e=>(H2.add(e),()=>H2.delete(e)),G2=()=>{for(let e of H2)try{e()}catch{}},aM=()=>typeof performance<"u"?performance.now():0,W2=e=>{aM=e};var Ci=(e,t=aM(e))=>{if(!e.animationKind)return e.src;let n=oM.get(e.animationKind);if(!n)return e.src;try{return n.getFrameAt(e.animationData,t)}catch{return e.src}};var Rp=(e,t)=>{let n=e.fill!==void 0&&e.fill!=="transparent",o=e.stroke!==void 0&&e.stroke!=="transparent"&&(e.strokeWidth??1)>0;return n&&t.setFill(e.fill),o&&(t.setStroke(e.stroke),t.setStrokeWidth(e.strokeWidth??1),e.lineCap&&t.setLineCap(e.lineCap),e.lineJoin&&t.setLineJoin(e.lineJoin),e.dashArray&&t.setDashArray(e.dashArray)),e.opacity!==void 0&&t.setOpacity(e.opacity),{fill:n,stroke:o}},LG=(e,t)=>{let{fill:n,stroke:o}=Rp(e.style,t);if(!n&&!o)return;let a=zf(e.style.roundness,e.width,e.height);if(n&&(t.beginPath(),a>0?Ey(t,0,0,e.width,e.height,a):t.rect(0,0,e.width,e.height),t.fill()),o){let r=Iy(e.style),s=r,i=r,l=e.width-2*r,c=e.height-2*r;if(l<=0||c<=0)return;let u=a>0?Math.max(0,a-r):0;t.beginPath(),u>0?Ey(t,s,i,l,c,u):t.rect(s,i,l,c),t.stroke()}},Iy=e=>{let t=e.strokeAlign??"center";if(t==="center")return 0;let n=(e.strokeWidth??1)/2;return t==="inside"?n:-n},Ey=(e,t,n,o,a,r)=>{e.moveTo(t+r,n),e.lineTo(t+o-r,n),e.quadraticCurveTo(t+o,n,t+o,n+r),e.lineTo(t+o,n+a-r),e.quadraticCurveTo(t+o,n+a,t+o-r,n+a),e.lineTo(t+r,n+a),e.quadraticCurveTo(t,n+a,t,n+a-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},kG=(e,t)=>{let{fill:n,stroke:o}=Rp(e.style,t);if(!n&&!o)return;let a=e.width/2,r=e.height/2;if(n&&(t.beginPath(),t.ellipse(a,r,a,r),t.fill()),o){let s=Iy(e.style),i=a-s,l=r-s;if(i<=0||l<=0)return;t.beginPath(),t.ellipse(a,r,i,l),t.stroke()}},_G=(e,t)=>{if(e.points.length<2)return;let{fill:n,stroke:o}=Rp(e.style,t);if(!(!n&&!o)&&(n&&(t.beginPath(),Cy(t,e.points),t.fill()),o)){let a=Iy(e.style),r=a!==0?Nf.offsetClosedPath(e.points,a):e.points;t.beginPath(),Cy(t,r),t.stroke()}},Cy=(e,t)=>{let n=t[0];if(n!==void 0){e.moveTo(n.x,n.y);for(let o=1;o<t.length;o++){let a=t[o];a!==void 0&&e.lineTo(a.x,a.y)}e.closePath()}},wG=(e,t)=>{if(e.commands.length===0)return;let{fill:n,stroke:o}=Rp(e.style,t);if(!(!n&&!o)){t.beginPath();for(let a of e.commands)switch(a.kind){case"M":t.moveTo(a.to.x,a.to.y);break;case"L":t.lineTo(a.to.x,a.to.y);break;case"Q":t.quadraticCurveTo(a.control.x,a.control.y,a.to.x,a.to.y);break;case"C":t.bezierCurveTo(a.control1.x,a.control1.y,a.control2.x,a.control2.y,a.to.x,a.to.y);break;case"Z":t.closePath();break}n&&t.fill(),o&&t.stroke()}},TG=(e,t)=>{let n=e.style.textAlign??"left",o=e.fontSize;t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let a=c=>{let u=c?.fontWeight??e.style.fontWeight,d=c?.fontStyle??e.style.fontStyle;t.setFont(e.fontFamily,o,{...u?{weight:u}:{},...d?{style:d}:{}})};a(void 0);let r=zc(e.text,c=>t.measureText(c).width,{fontSize:o,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}}),s=r.lines.map(c=>{let u=Ff(e,c.start,c.end).map(f=>(a(f.style),{text:f.text,style:f.style,width:t.measureText(f.text).width})),d=u.reduce((f,p)=>f+p.width,0);return{segs:u,total:d}}),i=e.maxWidth??s.reduce((c,u)=>Math.max(c,u.total),0),l=Math.max(1,o*x2);s.forEach((c,u)=>{let d=u*r.lineHeight,f=n==="center"?i/2-c.total/2:n==="right"?i-c.total:0;for(let p of c.segs){let h=p.style?.fill??e.style.fill??"#000",m=p.style?.opacity??e.style.opacity;a(p.style),t.setFill(h),m!==void 0&&t.setOpacity(m),t.fillText(p.text,f,d);let x=p.style?.textDecoration??e.style.textDecoration;p.width>0&&(x?.underline||x?.strikethrough)&&(x.underline&&(t.beginPath(),t.rect(f,d+o*b2,p.width,l),t.fill()),x.strikethrough&&(t.beginPath(),t.rect(f,d+o*A2-l/2,p.width,l),t.fill())),f+=p.width}})},EG=(e,t)=>{if(e.runs!==void 0&&e.runs.length>0){TG(e,t);return}let n=e.style.textAlign??"left",o=e.style.fontWeight,a=e.style.fontStyle;t.setFont(e.fontFamily,e.fontSize,{...o?{weight:o}:{},...a?{style:a}:{}}),t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let r=e.style.fill??"#000";t.setFill(r),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity);let s=e.fontSize,i;if(e.maxWidth===void 0&&!e.text.includes(`
16
+ `))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=zc(e.text,c,{fontSize:s,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}});i=u.lines.map((d,f)=>({text:d.text,x:n==="center"?u.blockWidth/2-d.width/2:n==="right"?u.blockWidth-d.width:0,width:d.width,top:f*u.lineHeight}))}for(let c of i)t.fillText(c.text,c.x,c.top);let l=e.style.textDecoration;if(l?.underline||l?.strikethrough){let c=Math.max(1,s*x2);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*b2,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*A2-c/2,u.width,c),t.fill()))}},CG=(e,t)=>{let n=e.points;if(n.length===0)return;if(e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.closed===!0&&e.style.fill!==void 0&&n.length>=3){t.setFill(e.style.fill),t.setStroke(null),t.beginPath();let r=v(n[0]);t.moveTo(r.x,r.y);for(let s=1;s<n.length;s++){let i=v(n[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}let o=Hf(e.style);if(t.setFill(o),t.setStroke(null),n.length===1){let r=v(n[0]);t.beginPath(),t.ellipse(r.x,r.y,r.width,r.width),t.fill();return}let a=np(n);if(a.length>=3){t.beginPath();let r=v(a[0]);t.moveTo(r.x,r.y);for(let s=1;s<a.length;s++){let i=v(a[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}},IG=(e,t,n)=>{let o=n?.clock?.(e),a=e.animationKind?Ci(e,o):e.metadata?.image??Ci(e,o),r=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(a,0,0,e.width,e.height,r,e.crop)},Fc=()=>{so("rectangle",LG),so("ellipse",kG),so("polygon",_G),so("path",wG),so("text",EG),so("image",IG),so("group",()=>{}),so("frame",DG),jA("frame",()=>({top:24})),so("block-arrow",MG),so("brush",CG)},MG=(e,t)=>{let{fill:n,stroke:o}=Rp(e.style,t),a=e.direction??"right",r=Math.max(R2,Math.min(O2,e.headRatio??G5)),s=Math.max(R2,Math.min(O2,e.bodyThickness??W5)),i=e.width,l=e.height,c=i*r,u=i-c,d=l*s/2,f=l/2,p=[[0,f-d],[u,f-d],[u,0],[i,f],[u,l],[u,f+d],[0,f+d]];a!=="right"&&(p=p.map(([m,x])=>RG([m,x],a,i,l)));let h=p.map(([m,x])=>({x:m,y:x}));if(n&&(t.beginPath(),Cy(t,h),t.fill()),o){let m=Iy(e.style),x=m!==0?Nf.offsetClosedPath(h,m):h;t.beginPath(),Cy(t,x),t.stroke()}},RG=([e,t],n,o,a)=>{switch(n){case"left":return[o-e,t];case"up":return[t*(o/a),a-e*(a/o)];case"down":return[(a-t)*(o/a),e*(a/o)]}},q2="\u2026",OG=(e,t,n)=>{if(t<=0)return"";if(n.measureText(e).width<=t)return e;let o=0,a=e.length;for(;o<a;){let r=Math.ceil((o+a)/2);n.measureText(e.slice(0,r)+q2).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+q2:q2},DG=(e,t,n)=>{t.setFill(e.style.fill??V5),t.setStroke(null),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.fill();let o=(n?.zoom??1)*(e.scale.x||1);t.setFill(null),t.setStroke(q5),t.setStrokeWidth(1/(o||1)),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.stroke();let a=e.name??"Frame";t.setFont("system-ui, sans-serif",12);let r=e.width-16,s=t.measureText(a).width<=r,i=s?a:OG(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(j5),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(Z5),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var My=class{entries=new Map;get(t,n){let o=this.entries.get(n.id);if(o){if(o.edge!==n||o.scene!==t){this.entries.delete(n.id);return}return o.value}}set(t,n,o){return this.entries.set(n.id,{edge:n,scene:t,value:o}),o}getOrCompute(t,n){let o=this.get(t,n);return o!==void 0?o:this.set(t,n,as(t,n))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.links.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},as=(e,t)=>{let n=_o(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let m of n)m.x<o&&(o=m.x),m.y<a&&(a=m.y),m.x>r&&(r=m.x),m.y>s&&(s=m.y);let i=t.arrowheads,l=i?.from!==void 0&&i.from!=="none"||i?.to!==void 0&&i.to!=="none",c=Math.max(2,(t.style.strokeWidth??1)/2+(l?i.size??10:0)),u=o-c,d=a-c,f=r+c,p=s+c,h=Zf(n,t);return h&&(u=Math.min(u,h.x),d=Math.min(d,h.y),f=Math.max(f,h.x+h.width),p=Math.max(p,h.y+h.height)),{x:u,y:d,width:f-u,height:p-d}},j2=new My;var Bn=(e,t,n={})=>{t.save(),t.setTransform(ao(e.viewport));let o=n.edgeBoundsCache??j2,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=Ty(n.zoom??e.viewport.zoom);for(let c of Lo(e))if(c.visible)for(let u of EA(e,c.id)){let d=null;if(a||r||s&&i){if(d=o.getOrCompute(e,u),d===null){n.onMissingEndpoint?.(u);continue}if(a&&!j.intersects(d,a)||r&&!j.intersects(d,r))continue}if(s&&i&&d){let f=s.get(u,l);if(f===void 0){let p=i(u,d,e,l);p!==null&&(s.set(u,l,p),f=p)}if(f!==void 0){t.drawImage(f,d.x,d.y,d.width,d.height);continue}}PG(e,u,t,n)}t.restore()},PG=(e,t,n,o)=>{let a=ut(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}let r=(t.routing??"straight")==="bezier"?Jf(e,t):null,s=r?jf(r.start,r.segments):a;if(n.save(),(t.lineKind??"line")==="block-arrow")BG(t,a,n);else{if(FG(t,n),n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let i of r.segments)n.bezierCurveTo(i.c1.x,i.c1.y,i.c2.x,i.c2.y,i.to.x,i.to.y)}else if(a.length>=3&&Nc>0)Ry(n,a,Nc);else{let i=v(a[0]);n.moveTo(i.x,i.y);for(let l=1;l<a.length;l++){let c=v(a[l]);n.lineTo(c.x,c.y)}}n.stroke(),t.arrowheads&&HG(s,t.arrowheads,n,t.style.stroke??D2)}t.label&&UG(s,t,n),n.restore()},BG=(e,t,n)=>{let o=e.blockArrow?.headLength??X5,a=e.blockArrow?.bodyThickness??Y5,r=e.style.fill??e.style.stroke??K5,s=e.style.stroke??$5,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=NG(t,o);if(l.length<2)return;let c=rM(l,a/2),u=rM(l,-a/2),d=v(c[c.length-1]),f=v(u[u.length-1]),p=v(t[t.length-1]);n.setFill(r),n.setStroke(s),n.setStrokeWidth(i),n.beginPath();let h=v(c[0]);n.moveTo(h.x,h.y);for(let g=1;g<c.length;g++){let b=v(c[g]);n.lineTo(b.x,b.y)}let m=Math.max(0,a*.5),x=sM(d,p,m),y=sM(f,p,-m);n.lineTo(x.x,x.y),n.lineTo(p.x,p.y),n.lineTo(y.x,y.y);for(let g=u.length-1;g>=0;g--){let b=v(u[g]);n.lineTo(b.x,b.y)}n.closePath(),n.fill(),i>0&&n.stroke()},NG=(e,t)=>{if(e.length<2)return e;let n=t,o=[...e].reverse(),a=[v(o[0])];for(let r=1;r<o.length;r++){let s=v(a[a.length-1]),i=v(o[r]),l=i.x-s.x,c=i.y-s.y,u=Math.hypot(l,c);if(u>n){let d=n/u,f={x:s.x+l*d,y:s.y+c*d};return a[a.length-1]=f,a.push(...o.slice(r)),a.reverse()}n-=u,a[a.length-1]=i}return e},rM=(e,t)=>{if(e.length<2)return e;let n=[];for(let o=0;o<e.length;o++){let a=v(e[Math.max(0,o-1)]),r=v(e[Math.min(e.length-1,o+1)]),s=v(e[o]),i=r.x-a.x,l=r.y-a.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;n.push({x:s.x+u*t,y:s.y+d*t})}return n},sM=(e,t,n)=>{let o=t.x-e.x,a=t.y-e.y,r=Math.hypot(o,a)||1,s=-a/r,i=o/r;return{x:e.x+s*n,y:e.y+i*n}},zG=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=Math.abs(o.y-a.y)<1e-6&&Math.abs(a.y-r.y)<1e-6,i=Math.abs(o.x-a.x)<1e-6&&Math.abs(a.x-r.x)<1e-6,l=Math.abs(o.x-a.x)<1e-6&&Math.abs(o.y-a.y)<1e-6;s||i||l||t.push(a)}return t.push(v(e[e.length-1])),t},Ry=(e,t,n)=>{let o=zG(t);if(o.length<3){let s=v(o[0]);e.moveTo(s.x,s.y);for(let i=1;i<o.length;i++){let l=v(o[i]);e.lineTo(l.x,l.y)}return}let a=v(o[0]);e.moveTo(a.x,a.y);for(let s=1;s<o.length-1;s++){let i=v(o[s-1]),l=v(o[s]),c=v(o[s+1]),u=Math.hypot(i.x-l.x,i.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-6||d<1e-6){e.lineTo(l.x,l.y);continue}let f=Math.min(n,u/2,d/2),p={x:l.x+(i.x-l.x)/u*f,y:l.y+(i.y-l.y)/u*f},h={x:l.x+(c.x-l.x)/d*f,y:l.y+(c.y-l.y)/d*f};e.lineTo(p.x,p.y),e.quadraticCurveTo(l.x,l.y,h.x,h.y)}let r=v(o[o.length-1]);e.lineTo(r.x,r.y)},FG=(e,t)=>{let n=e.style.stroke??D2;t.setStroke(n),t.setFill(null),t.setStrokeWidth(e.style.strokeWidth??1),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.style.lineCap!==void 0&&t.setLineCap(e.style.lineCap),e.style.lineJoin!==void 0&&t.setLineJoin(e.style.lineJoin),t.setDashArray(e.style.dashArray??null)},HG=(e,t,n,o)=>{let a=t.size??Q5;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&iM(r,s,t.from,a,n,o)}if(t.to&&t.to!=="none"){let r=e[e.length-1],s=e[e.length-2];r!==void 0&&s!==void 0&&iM(r,s,t.to,a,n,o)}},iM=(e,t,n,o,a,r)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i)||1,c=s/l,u=i/l,d=-u,f=c,p=o*.5,h=y=>({x:e.x+c*y,y:e.y+u*y}),m=(y,g)=>({x:e.x+c*y+d*g,y:e.y+u*y+f*g}),x=()=>{a.setFill(r),a.fill(),a.setFill(null),a.stroke()};switch(n){case"arrow":case"openArrow":case"roundedArrow":{let y=n==="openArrow"?o*.65:p,g=n==="openArrow"?o*1.1:o;n==="roundedArrow"&&a.setLineCap("round"),a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g+d*y,e.y+u*g+f*y),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g-d*y,e.y+u*g-f*y),a.stroke(),n==="roundedArrow"&&a.setLineCap("butt");break}case"arcArrow":{let y=m(o,p),g=m(o,-p),b=h(o*.45);a.beginPath(),a.moveTo(y.x,y.y),a.lineTo(e.x,e.y),a.lineTo(g.x,g.y),a.quadraticCurveTo(b.x,b.y,y.x,y.y),a.stroke();break}case"triangle":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...Eo(m(o,p))),a.lineTo(...Eo(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...Eo(m(o,p))),a.lineTo(...Eo(m(o,-p))),a.closePath(),x();break}case"circle":case"filledCircle":{let y=p,g=h(y);a.beginPath(),a.ellipse(g.x,g.y,y,y),n==="filledCircle"?x():a.stroke();break}case"diamond":case"rhombus":case"filledRhombus":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...Eo(m(o,p))),a.lineTo(...Eo(h(o*2))),a.lineTo(...Eo(m(o,-p))),a.closePath(),n==="filledRhombus"?x():a.stroke();break}case"erdOne":case"erdOnlyOne":case"erdMany":case"erdOneOrMany":case"erdZeroOrOne":case"erdZeroOrMany":{let y=n==="erdMany"||n==="erdOneOrMany"||n==="erdZeroOrMany",g=n==="erdZeroOrOne"||n==="erdZeroOrMany",b=n==="erdOnlyOne",A=n==="erdOne"||n==="erdOnlyOne"||n==="erdOneOrMany"||n==="erdZeroOrOne";if(y){let w=h(o);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(e.x,e.y),a.moveTo(w.x,w.y),a.lineTo(...Eo(m(0,p))),a.moveTo(w.x,w.y),a.lineTo(...Eo(m(0,-p))),a.stroke()}let _=y?o*1.15:o*.55,C=w=>{a.beginPath(),a.moveTo(...Eo(m(w,p))),a.lineTo(...Eo(m(w,-p))),a.stroke()};if(A&&C(_),b&&C(_+o*.4),g){let w=p*.6,L=h(o*(y?1.6:1)+w);a.beginPath(),a.ellipse(L.x,L.y,w,w),a.stroke()}break}}},Eo=e=>[e.x,e.y],UG=(e,t,n)=>{let o=t.label;if(!o||o.text==="")return;let a=o.fontSize??12,r=o.fill??J5,s=o.background??eM,i=uc(e,t);n.setFont("system-ui, sans-serif",a);let{lines:l,lineHeight:c}=P2(o.text,n,{maxWidth:160,fontSize:a,lineHeightFactor:1.25}),u=0;for(let h of l)u=Math.max(u,h.width);let d=u+12,f=l.length*c+6;n.beginPath(),n.setFill(s),n.setStroke(null),Ey(n,i.x-d/2,i.y-f/2,d,f,Math.min(tM,f/2)),n.fill(),n.setFill(r),n.setTextAlign("center"),n.setTextBaseline("middle");let p=i.y-(l.length-1)*c/2;for(let h=0;h<l.length;h++){let m=l[h];m===void 0||m.text===""||n.fillText(m.text,i.x,p+h*c)}};var lM=(e,t,n,o,a=w2,r=T2)=>{let s=[];if(e<=0||t<=0)return s;let i=e*t,l=Math.ceil(Math.log(n/i)/Math.log(a));for(let c=0;c<r;c++){let u=l+c,d=e*a**u,f=d*t,p=Math.max(0,Math.min(1,(f-n)/(o-n)));p<=0||s.push({step:d,opacity:p})}return s},Op=(e,t,n={})=>{if(n.skipClear||t.clear(),!e.viewport.gridEnabled)return;let o=20,r=(e.viewport.gridStyle??"lines")==="dots",s=n.color??(r?S2:v2),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=VG(e,l,c);if(!u)return;let d=f=>{r?WG(t,u,f,s,i):GG(t,u,f,s,i)};if(t.save(),t.setTransform(ao(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=qG(i,f);if(p<=0)continue;let h=f.step*o;h*i<_2||(t.setOpacity(p),d(h))}else{let f=r?I2:E2,p=r?M2:C2;for(let h of lM(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},GG=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=cM(t,n),c=L2/a;e.setStroke(o),e.setStrokeWidth(c),e.beginPath();for(let u=r;u<=s;u+=n)e.moveTo(u,i),e.lineTo(u,l);for(let u=i;u<=l;u+=n)e.moveTo(r,u),e.lineTo(s,u);e.stroke()},WG=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=cM(t,n);e.setStroke(null),e.setFill(o);let c=k2/a,u=c*2;for(let d=r;d<=s;d+=n)for(let f=i;f<=l;f+=n)e.beginPath(),e.rect(d-c,f-c,u,u),e.fill()},cM=(e,t)=>({minX:Math.floor(e.x/t)*t-t,maxX:Math.ceil((e.x+e.width)/t)*t+t,minY:Math.floor(e.y/t)*t-t,maxY:Math.ceil((e.y+e.height)/t)*t+t}),qG=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),VG=(e,t,n)=>{let o=qa(e.viewport),a=[z.applyToPoint(o,{x:0,y:0}),z.applyToPoint(o,{x:t,y:0}),z.applyToPoint(o,{x:t,y:n}),z.applyToPoint(o,{x:0,y:n})],r=j.fromPoints(a);return Number.isFinite(r.x)?r:null};var uM=async(e,t)=>{if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if(e instanceof Response)return e.arrayBuffer();let n=typeof e=="string"?e:e.href;if(n.startsWith("file:")){let{readFile:a}=await import("node:fs/promises"),{fileURLToPath:r}=await import("node:url"),s=r(n),i=await a(s);return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await fetch(e);if(!o.ok)throw new Error(`${t}: fetch failed (${o.status})`);return o.arrayBuffer()},Dp=async(e,t)=>{if(typeof WebAssembly.instantiateStreaming=="function"&&(e instanceof Response||(typeof e=="string"||e instanceof URL)&&!String(e).startsWith("file:")))try{let r=e instanceof Response?e.clone():await fetch(e),{instance:s}=await WebAssembly.instantiateStreaming(r,{});return s}catch{}let o=await uM(e,t),{instance:a}=await WebAssembly.instantiate(o,{});return a},rs=(e,t)=>{let n=t.byteLength,o=e.alloc(n);return new Uint8Array(e.memory.buffer,o,n).set(t),{ptr:o,len:n,free:()=>{e.free(o,n)}}};var dM=null,Pp=e=>{dM=e},Z2=()=>dM;var fM=null,Bp=e=>{fM=e},Oy=()=>fM;var Dy={flatten(e,t){let n=r=>Math.min(128,Math.max(8,Math.ceil(r/Math.max(.1,t)))),o=[],a={x:0,y:0};for(let r of e)switch(r.kind){case"M":a=r.to,o.push(a);break;case"L":a=r.to,o.push(a);break;case"Q":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenQuadratic(a,r.control,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"C":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenCubic(a,r.control1,r.control2,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"Z":if(o.length>0){let s=v(o[0]);o.push(s),a=s}break}return o},strokeToFill(e,t,n){if(e.length<2)return e;let o=t/2,a=n?.cap??"butt";n?.join;let r=[],s=[];for(let i=0;i<e.length;i++){let l=v(e[Math.max(0,i-1)]),c=v(e[Math.min(e.length-1,i+1)]),u=v(e[i]),d=c.x-l.x,f=c.y-l.y,p=Math.hypot(d,f)||1,h=-f/p,m=d/p;r.push({x:u.x+h*o,y:u.y+m*o}),s.push({x:u.x-h*o,y:u.y-m*o})}return[...r,...s.reverse(),v(r[0])]}};var Py=(e,t,n)=>{if(e.length<3)return e;let o=Vf(e.map(i=>({x:i.x,y:i.y}))),a=v(e[0]),r=[a],s={x:a.x,y:a.y};for(let i=0;i<o.length;i++){let l=v(o[i]),c=v(e[i]),u=v(e[i+1]);for(let d=1;d<=t;d++){let f=d/t,p=cn.cubicAt(s,l.c1,l.c2,l.to,f);r.push(n(c,u,p,f))}s=l.to}return r};var By=(e,t)=>({points:[{x:e.x,y:e.y,t}]}),X2=(e,t,n)=>{e.points.push({x:t.x,y:t.y,t:n})},Y2=(e,t,n=ly)=>{let o=!1,a=[];for(let r of e){let s=r.points.filter(i=>t-i.t<n);if(s.length===r.points.length){a.push(r);continue}o=!0,s.length>0&&a.push({points:s})}return o?{strokes:a,changed:o}:{strokes:e,changed:o}},pM=(e,t=A4)=>Py(e,t,(n,o,a,r)=>({x:a.x,y:a.y,t:n.t+(o.t-n.t)*r}));var Ii=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",jG=new Set(["rectangle","ellipse","template","text","frame"]),Mi=e=>jG.has(e.type),K2=e=>yi;var Co=(e,t)=>{let n=ko(e),a=[...H0(e).keys()].filter(s=>!n.has(s)),r=a.map(s=>{let i={kind:"named",name:s},l=Yt(e,i);if(t===0)return l;let c=Xo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var yM=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let s=t.scene.annotations.get(o);if(s)return{kind:"annotation",id:o,origin:$r(t.scene,s)}}if(t.selectionChromeActive){let s=ZG(e,t,n);if(s)return s}let a=t.acceleratedElementAt(e);if(a&&t.isElementInteractable(a)){let s=t.promoteToGroupRoot(a);return{kind:"element",id:s.id,bounds:N(s)}}let r=VA(t.scene,e,t.edgeHitThreshold/n);return r&&!t.isLayerLocked(r.layerId)?{kind:"link",id:r.id}:{kind:"empty"}},ZG=(e,t,n)=>{let o=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(o){let r=t.combinedSelectionBounds();if(r){let i=t.selectionIsAspectLocked()?gi:yi,l=Gv(e,r,n,t.handleHitSlop,i);if(l)return{kind:"group-handle",handle:l,bounds:r}}}if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Mi(s)||s.locked===!0)continue;let i=bi(s),l=t5(e,i,n,t.handleHitSlop,K2(s));if(l)return{kind:"handle",elementId:r,handle:l,bounds:i.bounds}}let a=o?t.combinedSelectionBounds():null;if(a){let r=fy(a,n);if(Wv(e,r,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:a.x+a.width/2,y:a.y+a.height/2},bounds:a}}else if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Mi(s)||s.locked===!0)continue;let i=dy(s,n);if(Wv(e,i,n,t.handleHitSlop)){let l=bi(s);return{kind:"rotate-handle",pivot:J4(l),bounds:l.bounds}}}if(t.selectedLink){let r=ue(t.scene,t.selectedLink);if(r){let s=ut(t.scene,r);if(s&&s.length>=2){let i=t.edgeHandleHitSlop/n,l=v(s[0]),c=v(s[s.length-1]);if(W.distance(e,l)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"from"};if(W.distance(e,c)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"to"}}}}return null},Np=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(gc),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(pp),e.beginPath(),e.rect(t,n,o,a),e.stroke()},Ri=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(gc),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(pp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},XG=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(pp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},hM=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(gc),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.fill(),e.setFill(null),e.setStroke(n),e.setStrokeWidth(1),e.setOpacity(pp),e.beginPath(),e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.stroke()},mM=(e,t,n,o,a,r)=>{let s=z.applyToPoint(t,{x:n.x,y:n.y}),i=z.applyToPoint(t,{x:n.x+n.width,y:n.y+n.height}),l=Math.min(s.x,i.x),c=Math.min(s.y,i.y),u=Math.abs(i.x-s.x),d=Math.abs(i.y-s.y),f=11;for(let p of a)switch(p){case"nw":case"ne":case"se":case"sw":{let h=z.applyToPoint(t,xi(p,n,o));Np(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Np(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Np(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Np(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Np(e,l+u-f,c-f,f*2,d+f*2,r);break}},Ny=e=>{let t={resizeHandles:!1,linkBodies:!1,selectedEdgeHandles:!1,anchorDots:!1,attachDropZones:!1,containerDropZones:!1,groupHandles:!1,annotationPins:!1};return e.linkDragActive?{...t,attachDropZones:!0}:e.elementDragActive?{...t,containerDropZones:!0}:{...t,resizeHandles:!0,linkBodies:!0,selectedEdgeHandles:!0,anchorDots:!0,groupHandles:!0,annotationPins:!0}},gM=(e,t)=>{let{scene:n,w2s:o,zoom:a,selection:r,visibility:s,edgeSelection:i,attach:l,containers:c}=t,{groupBounds:u,groupAspectLocked:d}=t;if(e.save(),s.resizeHandles&&r.size===1){let f=v([...r][0]),p=I(n,f);p&&Mi(p)&&p.locked!==!0&&mM(e,o,N(p),a,K2(p),Lv)}if(s.linkBodies)for(let f of n.links.values()){let p=ut(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(wI),e.setStrokeWidth(J0*2),e.setOpacity(gc),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=z.applyToPoint(o,i.from),p=z.applyToPoint(o,i.to);Ri(e,f.x,f.y,Ko,hp),Ri(e,p.x,p.y,Ko,hp);for(let h of i.waypoints??[]){let m=z.applyToPoint(o,h);Ri(e,m.x,m.y,Ko,hp)}for(let h of i.midpoints??[]){let m=z.applyToPoint(o,h);Ri(e,m.x,m.y,Ko,hp)}}if(s.anchorDots&&r.size===1){let f=v([...r][0]),p=I(n,f);if(p){let h=$o+ey,{worldPoints:m}=Co(p,wo/a);for(let x of m){let y=z.applyToPoint(o,x);Ri(e,y.x,y.y,h,kv),XG(e,y.x,y.y,ty,kv)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)hM(e,p.map(h=>z.applyToPoint(o,h)),CI);e.setFill(null),e.setStroke(EI),e.setStrokeWidth(f*2),e.setOpacity(gc),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=z.applyToPoint(o,p);Ri(e,h.x,h.y,f,TI)}}if(s.containerDropZones&&c){let f=(p,h)=>{let m=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}].map(x=>z.applyToPoint(o,x));hM(e,m,h)};for(let p of c.frames)f(p,II);for(let p of c.containers)f(p,MI)}if(s.groupHandles&&u&&mM(e,o,u,a,d?gi:yi,Lv),s.annotationPins)for(let f of n.annotations.values()){let p=z.applyToPoint(o,$r(n,f));Ri(e,p.x,p.y,oy,RI)}e.setOpacity(1),e.restore()};var AM=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?AM(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},vM={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},SM=.32,LM=(e,t,n,o,a=vM)=>{if(n.length===0)return;let s=bv/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(SM),e.setDashArray(null),e.setLineJoin("miter"),e.setLineCap("butt");for(let{loops:i,outsetWorld:l}of n){e.setStrokeWidth(2*(l+s));for(let c of i){if(c.length<2)continue;e.beginPath();let u=!1;for(let d of c)u?e.lineTo(d.x,d.y):(e.moveTo(d.x,d.y),u=!0);e.closePath(),e.stroke()}}e.setOpacity(1),e.setTransform(z.IDENTITY)},kM=(e,t,n,o={})=>{let a={...vM,...o.style};n.clear();let r=ao(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(z.IDENTITY);let i={scene:e,selection:t,target:n,options:o,style:a,w2s:r,zoom:s};$G(i),QG(i),JG(i),eW(i),tW(i),nW(i),oW(i),rW(i),sW(i),iW(i),lW(i),cW(i),uW(i),dW(i),n.restore()},$G=e=>{let{scene:t,selection:n,target:o,options:a,w2s:r,zoom:s}=e;a.debugHitZones&&gM(o,{scene:t,w2s:r,zoom:s,selection:n,visibility:a.debugHitZoneVisibility??Ny({linkDragActive:!1,elementDragActive:!1}),...a.edgeSelection?{edgeSelection:a.edgeSelection}:{},...a.debugAttachZones?{attach:a.debugAttachZones}:{},...a.debugContainerZones?{containers:a.debugContainerZones}:{},...a.groupBounds?{groupBounds:a.groupBounds}:{},...a.groupAspectLocked!==void 0?{groupAspectLocked:a.groupAspectLocked}:{}})},QG=e=>{let{scene:t,selection:n,target:o,options:a,style:r,w2s:s,zoom:i}=e;if(a.cropFrame)return;let l=n.size>1;for(let c of n){let u=t.elements.get(c);if(!u)continue;if(ze(u)){let f=AM(t,c);if(!f)continue;let p=na(f,s);if(Q2(o,p,r),u.locked===!0){bM(o,p);continue}if(l||!Mi(u)||a.readOnly===!0||a.suppressHandles===!0)continue;for(let h of gi){let m=xi(h,f,i);J2(o,z.applyToPoint(s,m),r)}wM(o,f,i,s,r);continue}let d=bi(u);if(d.rotation===0?Q2(o,na(d.bounds,s),r):pW(o,d,s,r),u.locked===!0){bM(o,hW(d,s));continue}if(!(l||!Mi(u)||a.readOnly===!0||a.suppressHandles===!0)){for(let f of gi){let p=e5(f,d,i);J2(o,z.applyToPoint(s,p),r)}_M(o,z.applyToPoint(s,dy(u,i)),r)}}},JG=e=>{let{target:t,options:n,style:o,w2s:a}=e;if(n.cropGhost&&xW(t,n.cropGhost,a),n.cropFrame&&n.cropFrame.length>=4){let r=n.cropFrame.map(s=>z.applyToPoint(a,s));yW(t,r,o),gW(t,r,o)}if(n.drawingPreview){let r=na(n.drawingPreview,a);mW(t,r,o)}if(n.drawingPreviewElement){let r=n.drawingPreviewElement,s=es(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(qI),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.flowchartPreviewElements&&n.flowchartPreviewElements.length>0)for(let r of n.flowchartPreviewElements){let s=es(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(uy),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.strokeErasePreviewElements&&n.strokeErasePreviewElements.length>0)for(let r of n.strokeErasePreviewElements){let s=es(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(1),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.ghostElement||n.ghostElementShape){t.setOpacity(ny);let r=n.ghostElementShape,s=r?es(r.type):void 0;if(r&&s)t.save(),t.setTransform(a),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore();else if(n.ghostElement){let i=na(n.ghostElement,a);t.setStroke(o.selectionStroke),t.setStrokeWidth(1.5),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.stroke()}t.setOpacity(1)}if(n.linkAttachHighlight){let r=na(n.linkAttachHighlight,a),s=2;t.setStroke(o.selectionStroke),t.setStrokeWidth(2),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(r.x-s,r.y-s,r.width+s*2,r.height+s*2),t.stroke()}},eW=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(n.ports){let s=Array.isArray(n.ports)?n.ports:[n.ports];for(let i of s)for(let l=0;l<i.worldPoints.length;l++){let c=z.applyToPoint(a,v(i.worldPoints[l])),u=i.activeIndex===l;bW(t,c,u,i.role,u?i.activeRadius:void 0)}}if(n.selectedLinkPaths&&n.selectedLinkPaths.length>0){t.setTransform(a),t.setStroke(o.selectionStroke),t.setOpacity(SM),t.setDashArray(null),t.setLineJoin("round"),t.setLineCap("round");let s=bv/(r||1);for(let{path:i,width:l}of n.selectedLinkPaths)i.length<2||(t.setStrokeWidth(l+2*s),t.beginPath(),Ry(t,i,Nc),t.stroke());t.setOpacity(1),t.setLineJoin("miter"),t.setLineCap("butt"),t.setTransform(z.IDENTITY)}if(n.edgeSelection&&n.readOnly!==!0&&n.suppressHandles!==!0){let s=z.applyToPoint(a,n.edgeSelection.from),i=z.applyToPoint(a,n.edgeSelection.to);for(let l of n.edgeSelection.midpoints??[])AW(t,z.applyToPoint(a,l),o);$2(t,s,o),$2(t,i,o);for(let l of n.edgeSelection.waypoints??[])$2(t,z.applyToPoint(a,l),o)}},tW=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerSelections)for(let a of n.peerSelections)for(let r of a.bounds){let s=na(r,o);vW(t,s,a.color)}},nW=e=>{let{target:t,options:n,w2s:o}=e;if(n.brushPreview&&n.brushPreview.points.length>0){let a=n.brushPreview;t.save(),t.setTransform(o),t.setOpacity(a.opacity),t.setFill(a.fill),t.setStroke(null);let r=a.points,s=a.origin.x,i=a.origin.y;if(r.length===1){let l=v(r[0]);t.beginPath(),t.ellipse(s+l.x,i+l.y,l.width,l.width),t.fill()}else{let l=np(r);if(l.length>=3){t.beginPath();let c=v(l[0]);t.moveTo(s+c.x,i+c.y);for(let u=1;u<l.length;u++){let d=v(l[u]);t.lineTo(s+d.x,i+d.y)}t.closePath(),t.fill()}}t.restore()}},oW=e=>{let{target:t,options:n,w2s:o}=e;xM(t,o,n.laserStrokes,b4,zv,ly);let a=(n.eraserCursor?.radius??zv/2)*2;xM(t,o,n.eraserTrail,sy,a,iy)},xM=(e,t,n,o,a,r)=>{if(!n||n.length===0)return;let s=typeof performance<"u"?performance.now():Date.now(),i=a/2;e.setStroke(null),e.setDashArray(null),e.setFill(o);for(let l of n){let c=pM(l.points);if(c.length===0)continue;let u=v(c[c.length-1]),d=1-(s-u.t)/r;if(d<=0)continue;e.setOpacity(d);let f=c.map(m=>z.applyToPoint(t,{x:m.x,y:m.y}));if(f.length===1){let m=v(f[0]);e.beginPath(),e.ellipse(m.x,m.y,i,i),e.fill();continue}let p=aW(f,i),h=v(p[0]);e.beginPath(),e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=v(p[m]);e.lineTo(x.x,x.y)}e.closePath(),e.fill()}e.setOpacity(1)},aW=(e,t)=>{let n=e.length,o=[],a=[];for(let r=0;r<n;r++){let s=v(e[r]),i=v(e[Math.max(0,r-1)]),l=v(e[Math.min(n-1,r+1)]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u)||1;c/=d,u/=d;let f=t*(n>1?r/(n-1):1),p=-u*f,h=c*f;o.push({x:s.x+p,y:s.y+h}),a.push({x:s.x-p,y:s.y-h})}return a.reverse(),[...o,...a]},rW=e=>{let{target:t,options:n,w2s:o}=e,a=n.eraserCursor;if(!a||a.radius<=0)return;let r=z.applyToPoint(o,a.center);t.setDashArray(null),t.setOpacity(1),t.beginPath(),t.ellipse(r.x,r.y,a.radius,a.radius),t.setFill(sy),t.fill(),t.setFill(null),t.setStroke(sy),t.setStrokeWidth(h4),t.stroke()},sW=e=>{let{target:t,options:n,w2s:o}=e;if(n.containerDropZone){let a=na(n.containerDropZone,o);t.setFill("rgba(26, 115, 232, 0.10)"),t.setStroke("#1a73e8"),t.setStrokeWidth(2),t.setDashArray([6,3]),t.beginPath(),t.rect(a.x,a.y,a.width,a.height),t.fill(),t.stroke(),t.setDashArray(null)}},iW=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(!n.cropFrame&&n.groupBounds){let s=na(n.groupBounds,a);if(Q2(t,s,o),n.readOnly===!0||n.suppressHandles===!0)return;let i=gi;for(let l of i){let c=xi(l,n.groupBounds,r),u=z.applyToPoint(a,c);J2(t,u,o)}wM(t,n.groupBounds,r,a,o)}},lW=e=>{let{scene:t,target:n,options:o,w2s:a}=e;if(o.annotations&&o.annotations.length>0)for(let r of o.annotations){let s=$r(t,r),i=z.applyToPoint(a,s);LW(n,i,r,o.selectedAnnotation??null)}},cW=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerCursors)for(let a of n.peerCursors){let r=z.applyToPoint(o,a.position);SW(t,r,a.color,a.name)}},uW=e=>{let{target:t,options:n,w2s:o}=e;if(n.gifBadges)for(let a of n.gifBadges)fW(t,na(a,o))},dW=e=>{let{target:t,options:n,w2s:o,zoom:a}=e;if(n.editingText){let r=n.editingText;if(r.selectionRects.length>0){t.setFill(P4),t.setOpacity(B4);for(let s of r.selectionRects){let i=na(s,o);t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fill()}t.setOpacity(1)}if(r.caret){let s=z.applyToPoint(o,{x:r.caret.x,y:r.caret.y});t.setFill(r.caretColor),t.setOpacity(1),t.beginPath(),t.rect(s.x,s.y,N4,r.caret.height*a),t.fill()}}},bM=(e,t)=>{let n=q4,o=t.x+t.width-n-2,a=t.y+2,r=V4;e.setStroke(r),e.setFill(null),e.setStrokeWidth(2),e.setDashArray(null),e.setOpacity(1),e.beginPath(),e.ellipse(o+n/2,a+n*.46,n*.22,n*.26),e.stroke(),e.setStroke(null),e.setFill(r),e.beginPath(),e.rect(o+n*.2,a+n*.44,n*.6,n*.48),e.fill(),e.setFill(j4),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},fW=(e,t)=>{let n=t.x+Uv,o=t.y+Uv,a=H4,r=U4,s=G4;e.setStroke(null),e.setFill(W4),e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+a-s,o),e.quadraticCurveTo(n+a,o,n+a,o+s),e.lineTo(n+a,o+r-s),e.quadraticCurveTo(n+a,o+r,n+a-s,o+r),e.lineTo(n+s,o+r),e.quadraticCurveTo(n,o+r,n,o+r-s),e.lineTo(n,o+s),e.quadraticCurveTo(n,o,n+s,o),e.closePath(),e.fill(),e.setFill("#ffffff"),e.setFont("system-ui, sans-serif",10),e.setTextAlign("center"),e.setTextBaseline("middle"),e.fillText("gif",n+a/2,o+r/2)},na=(e,t)=>{let n=z.applyToPoint(t,{x:e.x,y:e.y}),o=z.applyToPoint(t,{x:e.x+e.width,y:e.y+e.height}),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y);return{x:a,y:r,width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)}},Q2=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(n.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},pW=(e,t,n,o)=>{let[a,r,s,i]=gp(t),l=z.applyToPoint(n,a),c=z.applyToPoint(n,r),u=z.applyToPoint(n,s),d=z.applyToPoint(n,i);e.setStroke(o.selectionStroke),e.setStrokeWidth(o.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.stroke()},hW=(e,t)=>{let n=gp(e).map(i=>z.applyToPoint(t,i)),o=1/0,a=1/0,r=-1/0,s=-1/0;for(let i of n)i.x<o&&(o=i.x),i.y<a&&(a=i.y),i.x>r&&(r=i.x),i.y>s&&(s=i.y);return{x:o,y:a,width:r-o,height:s-a}},zy=(e,t,n,o)=>{o.opacity!==void 0&&e.setOpacity(o.opacity),e.setStroke(o.stroke),e.setStrokeWidth(o.strokeWidth),e.setDashArray(null),e.setFill(o.fill),e.beginPath(),e.ellipse(t.x,t.y,n,n),e.fill(),e.stroke(),o.opacity!==void 0&&e.setOpacity(1)},J2=(e,t,n)=>{zy(e,t,5,{fill:n.handleFill,stroke:n.handleStroke,strokeWidth:1})},_M=(e,t,n)=>{let o=7/9,a=(u,d)=>({x:t.x+(u-12)*o,y:t.y+(d-12)*o});e.setStroke(n.handleStroke),e.setFill(null),e.setStrokeWidth(2*o),e.setLineCap("round"),e.setLineJoin("round"),e.setDashArray(null);let r=336,s=30;e.beginPath();for(let u=0;u<=s;u++){let d=r*u/s*(Math.PI/180),f=a(12+9*Math.cos(d),12+9*Math.sin(d));u===0?e.moveTo(f.x,f.y):e.lineTo(f.x,f.y)}e.stroke();let i=a(21,3),l=a(21,8),c=a(16,8);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.stroke(),e.setLineCap("butt"),e.setLineJoin("miter")},wM=(e,t,n,o,a)=>{let r=fy(t,n);_M(e,z.applyToPoint(o,r),a)},mW=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1),e.setDashArray(n.drawingDash),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},yW=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.lineTo(o.x,o.y),e.stroke(),e.setDashArray(null)},gW=(e,t,n)=>{if(t.length<4)return;e.setStroke(n.selectionStroke),e.setStrokeWidth(K4),e.setDashArray(null),e.setLineCap("round"),e.setLineJoin("round");let o=(a,r)=>{let s=r.x-a.x,i=r.y-a.y,l=Math.hypot(s,i)||1,c=Math.min(Y4,l)/l;return{x:a.x+s*c,y:a.y+i*c}};for(let a=0;a<4;a++){let r=v(t[a]),s=v(t[(a+3)%4]),i=v(t[(a+1)%4]),l=o(r,s),c=o(r,i);e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(r.x,r.y),e.lineTo(c.x,c.y),e.stroke()}e.setLineCap("butt"),e.setLineJoin("miter")},xW=(e,t,n)=>{let o=t.element,a=o.animationKind!==void 0?Ci(o,void 0):o.metadata?.image??Ci(o,void 0);if(a==null)return;let r=o.metadata?.animated===!0||o.animationKind!==void 0,{fullRect:s}=t;e.save(),e.setTransform(n),e.setDashArray(null),e.translate(o.position.x,o.position.y),o.rotation!==0&&e.rotate(o.rotation),(o.scale.x!==1||o.scale.y!==1)&&e.scale(o.scale.x,o.scale.y),e.setOpacity(X4),e.drawImage(a,s.x,s.y,s.width,s.height,r),e.setOpacity(1),e.restore()},bW=(e,t,n,o="link-start",a)=>{let r=n?a??$o:fp,s=o==="link-start";zy(e,t,r,{fill:n?s?Av:vv:s?vI:SI,stroke:s?Av:vv,strokeWidth:AI})},$2=(e,t,n)=>{zy(e,t,hI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:2})},AW=(e,t,n)=>{zy(e,t,mI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:1.5,opacity:.55})},vW=(e,t,n)=>{let o=BI;e.setStroke(n),e.setStrokeWidth(DI),e.setDashArray(PI),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},SW=(e,t,n,o)=>{let a=OI;e.setFill(n),e.setStroke("#fff"),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x+a*.7,t.y+a*.25),e.lineTo(t.x+a*.35,t.y+a*.4),e.lineTo(t.x+a*.5,t.y+a*.95),e.lineTo(t.x+a*.35,t.y+a*1.05),e.lineTo(t.x+a*.2,t.y+a*.5),e.lineTo(t.x,t.y+a*.65),e.closePath(),e.fill(),e.stroke(),e.setFont("sans-serif",Ev),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+_v,i=t.y+_v,l=r+2*wv,c=Ev+2*Tv;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+wv,i+Tv)},LW=(e,t,n,o)=>{let a=KI,r=n.resolved?JI:$I,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":QI),e.setStrokeWidth(s?2:1.5),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,a,a),e.fill(),e.stroke(),n.thread.length>0){let i=n.thread.length,l=i>9?"9+":String(i);e.setFont("sans-serif",e4),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var Hc=(e,t)=>{let n=t.getBoundingClientRect();return{kind:_W(e.pointerType),phase:wW(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:kW(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var oa=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},kW=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),_W=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",wW=e=>{switch(e){case"pointerdown":return"down";case"pointermove":return"move";case"pointerup":return"up";case"pointercancel":return"cancel";case"pointerenter":return"enter";case"pointerleave":return"leave";default:return"move"}};var eS=()=>typeof navigator<"u"?navigator.userAgent:"",zp=()=>typeof navigator<"u"&&navigator.platform||"",ss=/Mac|iPod|iPhone|iPad/.test(zp()),TW=zp().startsWith("Win"),TM=/\b(android)\b/i.test(eS()),EW=/iPad|iPhone/i.test(zp())||typeof navigator<"u"&&/Mac/i.test(zp())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,CW=/Linux/i.test(zp())&&!TM,IW=/Firefox/i.test(eS()),MW=/^((?!chrome|android).)*safari/i.test(eS());var RW={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},OW={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},Fy=e=>{let t=[];ss?(e.ctrl&&t.push("\u2303"),e.alt&&t.push("\u2325"),e.shift&&t.push("\u21E7"),e.meta&&t.push("\u2318")):(e.meta&&t.push("Ctrl"),e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));let n=ss?RW:OW,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},dt=e=>{let t=Fy(e);return ss?t.join(""):t.join("+")};var EM={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},CM={id:"redo",label:"Redo",category:"history",hotkey:[{key:"z",meta:!0,shift:!0},{key:"y",meta:!0}],iconId:"redo",predicate:({editor:e})=>e.canRedo,perform:({editor:e})=>e.redo()},tS=[EM,CM];var yt=e=>e.editor.selection.size>0,nS=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var IM={id:"select-all",label:"Select all",category:"selection",viewMode:!0,hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},MM={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:nS,perform:({editor:e})=>{e.deleteSelected()}},RM={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:yt,perform:({editor:e})=>{e.duplicateSelected()}},OM={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.toggleLockSelection()}},DM={id:"enter-container",label:"Enter container",category:"selection",hotkey:{key:"ArrowDown",meta:!0,shift:!0},predicate:({editor:e})=>e.selection.size===1,perform:({editor:e})=>{e.enterContainer()}},PM={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.exitContainer()}},oS=[IM,MM,RM,OM,DM,PM];var BM={id:"copy",label:"Copy",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0},predicate:yt,perform:({editor:e})=>{e.copySelected()}},NM={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:yt,perform:({editor:e})=>{e.cutSelected()}},zM={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},FM={id:"copy-style",label:"Copy style",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0,alt:!0},predicate:yt,perform:({editor:e})=>{e.copySelectionStyle()}},HM={id:"paste-style",label:"Paste style",category:"clipboard",hotkey:{key:"v",meta:!0,alt:!0},predicate:({editor:e})=>e.selection.size>0&&e.hasStyleClipboard,perform:({editor:e})=>{e.pasteSelectionStyle()}},aS=[BM,NM,zM,FM,HM];var UM={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.bringToFront()}},GM={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.sendToBack()}},WM={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:yt,perform:({editor:e})=>{e.bringForward()}},qM={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:yt,perform:({editor:e})=>{e.sendBackward()}},rS=[UM,WM,qM,GM];var VM={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},jM={id:"ungroup-selection",label:"Ungroup",category:"grouping",hotkey:{key:"g",meta:!0,shift:!0},predicate:e=>{for(let t of e.editor.selection)if(e.editor.scene.elements.get(t)?.type==="group")return!0;return!1},perform:({editor:e})=>{e.ungroup()}},sS=[VM,jM];var ZM={id:"zoom-in",label:"Zoom in",category:"zoom",viewMode:!0,hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},XM={id:"zoom-out",label:"Zoom out",category:"zoom",viewMode:!0,hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},YM={id:"zoom-reset",label:"Reset zoom",category:"zoom",viewMode:!0,hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},KM={id:"zoom-to-fit",label:"Fit to screen",category:"zoom",viewMode:!0,hotkey:[{key:"1",alt:!0},{key:"1",meta:!0}],perform:({editor:e})=>{e.zoomToFit()}},$M={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",viewMode:!0,hotkey:{key:"2",alt:!0},predicate:yt,perform:({editor:e})=>{e.zoomToSelection()}},iS=[ZM,XM,YM,KM,$M];var QM={id:"mode-select",label:"Select tool",category:"tool",viewMode:!0,hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="select",perform:({editor:e})=>{e.setActiveTool("select")}},JM={id:"mode-hand",label:"Hand tool",category:"tool",viewMode:!0,hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="hand",perform:({editor:e})=>{e.setActiveTool("hand")}},e9={id:"mode-rect",label:"Rectangle tool",category:"tool",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-rect",perform:({editor:e})=>{e.setActiveTool("draw-rect")}},t9={id:"mode-ellipse",label:"Ellipse tool",category:"tool",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-ellipse",perform:({editor:e})=>{e.setActiveTool("draw-ellipse")}},n9={id:"mode-text",label:"Text tool",category:"tool",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-text",perform:({editor:e})=>{e.setActiveTool("draw-text")}},o9={id:"mode-edge",label:"Link tool",category:"tool",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-edge",perform:({editor:e})=>{e.setActiveTool("draw-edge")}},a9={id:"mode-brush",label:"Brush tool",category:"tool",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="brush",perform:({editor:e})=>{e.setActiveTool("brush")}},r9={id:"mode-erase",label:"Eraser tool",category:"tool",hotkey:{key:"e"},iconId:"mode-erase",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="erase",perform:({editor:e})=>{e.setActiveTool("erase")}},s9={id:"mode-laser",label:"Laser pointer",category:"tool",viewMode:!0,hotkey:{key:"k"},iconId:"mode-laser",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="laser",perform:({editor:e})=>{e.setActiveTool("laser")}},i9={id:"mode-frame",label:"Frame tool",category:"tool",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-frame",perform:({editor:e})=>{e.setActiveTool("draw-frame")}},l9={id:"toggle-tool-lock",label:"Toggle tool lock",category:"tool",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.activeTool.locked,perform:({editor:e})=>{e.setToolLocked(!e.activeTool.locked)}},DW={id:"commit-image-crop",label:"Apply crop",category:"edit",hotkey:{key:"Enter"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.commitImageCrop()}},PW={id:"cancel-image-crop",label:"Cancel crop",category:"edit",viewMode:!0,hotkey:{key:"Escape"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.cancelImageCrop()}},c9={id:"cancel",label:"Cancel / clear selection",category:"edit",viewMode:!0,hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},lS=[QM,JM,e9,t9,n9,o9,a9,r9,s9,i9,l9,DW,PW,c9];var BW={id:"nudge-selection",label:"Nudge selection",category:"selection",displayHotkey:[{key:"ArrowLeft"},{key:"ArrowRight"},{key:"ArrowUp"},{key:"ArrowDown"}],keyTest:e=>(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown")&&!e.metaKey&&!e.ctrlKey&&!e.altKey,perform:({editor:e,event:t})=>{if(!t)return;let n=t.shiftKey?O4:R4;switch(t.key){case"ArrowLeft":e.moveSelectionBy({x:-n,y:0});return;case"ArrowRight":e.moveSelectionBy({x:n,y:0});return;case"ArrowUp":e.moveSelectionBy({x:0,y:-n});return;case"ArrowDown":e.moveSelectionBy({x:0,y:n});return}}},NW={id:"select-closest",label:"Navigate to adjacent node",category:"selection",displayHotkey:[{key:"ArrowLeft",alt:!0},{key:"ArrowRight",alt:!0},{key:"ArrowUp",alt:!0},{key:"ArrowDown",alt:!0}],keyTest:e=>e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.navigateFlowchart("left");return;case"ArrowRight":e.navigateFlowchart("right");return;case"ArrowUp":e.navigateFlowchart("up");return;case"ArrowDown":e.navigateFlowchart("down");return}}},zW={id:"spawn-connected",label:"Create connected node",category:"edit",displayHotkey:[{key:"ArrowLeft",meta:!0},{key:"ArrowRight",meta:!0},{key:"ArrowUp",meta:!0},{key:"ArrowDown",meta:!0}],keyTest:e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),predicate:({editor:e})=>e.selection.size===1,perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.growFlowchart("left");return;case"ArrowRight":e.growFlowchart("right");return;case"ArrowUp":e.growFlowchart("up");return;case"ArrowDown":e.growFlowchart("down");return}}},FW={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},HW={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},UW={id:"edit-or-create",label:"Edit / create",category:"edit",displayHotkey:{key:"Enter"},keyTest:e=>e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey,predicate:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text")return!0}return e.activeTool.type==="draw-rect"||e.activeTool.type==="draw-ellipse"},perform:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text"){e.beginTextEdit(t);return}}(e.activeTool.type==="draw-rect"||e.activeTool.type==="draw-ellipse")&&e.createElementAtCursor()}},u9=[BW,NW,zW,FW,HW,UW];var GW={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},WW={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},qW={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},VW={id:"auto-arrange",label:"Auto-arrange children",category:"layout",predicate:({editor:e})=>{if(e.selection.size!==1)return!1;let[t]=[...e.selection];if(!t)return!1;let n=e.scene.elements.get(t);return n?Dn(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},jW={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},d9=[GW,WW,qW,VW,jW];var f9={id:"toggle-grid",label:"Toggle grid",category:"other",viewMode:!0,hotkey:{key:"g"},uiKind:"toggle",checked:({editor:e})=>e.gridEnabled,perform:({editor:e})=>{e.toggleGrid()}},p9={id:"toggle-read-only",label:"Read-only mode",category:"other",viewMode:!0,hotkey:{key:"r",alt:!0},uiKind:"toggle",checked:({editor:e})=>e.readOnly,perform:({editor:e})=>{e.toggleReadOnly()}},cS=[f9,p9];var Uc=e=>e.editor.selection.size>=2,h9=e=>e.editor.selection.size>=3,m9={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:yt,perform:({editor:e})=>{e.flipSelection("horizontal")}},y9={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:yt,perform:({editor:e})=>{e.flipSelection("vertical")}},g9={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",meta:!0,shift:!0},iconId:"align-left",predicate:Uc,perform:({editor:e})=>{e.alignSelection("left")}},x9={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:Uc,perform:({editor:e})=>{e.alignSelection("h-center")}},b9={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",meta:!0,shift:!0},iconId:"align-right",predicate:Uc,perform:({editor:e})=>{e.alignSelection("right")}},A9={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",meta:!0,shift:!0},iconId:"align-top",predicate:Uc,perform:({editor:e})=>{e.alignSelection("top")}},v9={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:Uc,perform:({editor:e})=>{e.alignSelection("v-center")}},S9={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",meta:!0,shift:!0},iconId:"align-bottom",predicate:Uc,perform:({editor:e})=>{e.alignSelection("bottom")}},L9={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:h9,perform:({editor:e})=>{e.distributeSelection("horizontal")}},k9={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:h9,perform:({editor:e})=>{e.distributeSelection("vertical")}},uS=[m9,y9,g9,x9,b9,A9,v9,S9,L9,k9];var _9=e=>{let{editor:t}=e;for(let n of t.selection){let o=I(t.scene,n);if(o!==void 0&&pe(o))return!0}return!1},w9={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:_9,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},T9={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:_9,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},dS=[w9,T9];var Fp=class{entries=new Map;order=[];seqBuffer=[];register(t){if(this.entries.has(t.id))throw new Error(`Action already registered: ${t.id}`);this.entries.set(t.id,t),this.order.push(t.id)}replace(t){if(this.entries.has(t.id)){this.entries.set(t.id,t);return}this.register(t)}unregister(t){if(!this.entries.delete(t))return;let n=this.order.indexOf(t);n!==-1&&this.order.splice(n,1)}get(t){return this.entries.get(t)}getAll(){return this.order.map(t=>this.entries.get(t)).filter(t=>t!==void 0)}dispatch(t,n){let o=this.entries.get(t);return!o||fS(o,n)||o.predicate&&!o.predicate(n)?!1:(o.perform(n),!0)}dispatchHotkey(t,n){let o={...n,event:t};if(this.trySequence(t,o))return!0;for(let a of this.order){let r=this.entries.get(a);if(!r||fS(r,o))continue;if(r.keyTest?.(t,o)){if(r.predicate&&!r.predicate(o))continue;return r.perform(o),!0}if(!r.hotkey)continue;let s=Array.isArray(r.hotkey)?r.hotkey:[r.hotkey];for(let i of s)if(ZW(t,i)&&!(r.predicate&&!r.predicate(o)))return r.perform(o),!0}return!1}trySequence(t,n){if(!(t.key.length===1&&!t.metaKey&&!t.ctrlKey&&!t.altKey))return this.seqBuffer=[],!1;let a=t.timeStamp;this.seqBuffer=this.seqBuffer.filter(r=>a-r.t<=M4),this.seqBuffer.push({key:t.key,code:t.code,t:a});for(let r of this.order){let s=this.entries.get(r);if(!s?.sequence||s.sequence.length===0||fS(s,n))continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>E9(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},fS=(e,t)=>t.editor.readOnly&&e.viewMode!==!0,ZW=(e,t)=>{if(t.key!==void 0&&!XW(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=ss?e.metaKey:e.ctrlKey;return!(n(t.meta)!==o||n(t.shift)!==e.shiftKey||n(t.alt)!==e.altKey||t.ctrl!==void 0&&n(t.ctrl)!==e.ctrlKey)},XW=(e,t)=>E9(e.key,e.code,t),E9=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(YW(e))return!1;let o=KW(n);return o!==null&&t===o},YW=e=>/^[a-z]$/i.test(e),KW=e=>{if(e.length!==1)return null;let t=e.toLowerCase();if(t>="a"&&t<="z")return`Key${t.toUpperCase()}`;if(t>="0"&&t<="9")return`Digit${t}`;switch(t){case"[":return"BracketLeft";case"]":return"BracketRight";case",":return"Comma";case".":return"Period";case"/":return"Slash";case";":return"Semicolon";case"'":return"Quote";case"`":return"Backquote";case"-":return"Minus";case"=":return"Equal";case"\\":return"Backslash";default:return null}},pS=e=>{let t=[...tS,...oS,...aS,...rS,...sS,...iS,...lS,...u9,...d9,...cS,...uS,...dS];for(let n of t)e.register(n)},we=new Fp;pS(we);var Hy=(e,t={})=>{let n=t.target??window,o=t.registry??we,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(oa(s)){if(r.key!=="Escape")return;s instanceof HTMLElement&&s.blur()}o.dispatchHotkey(r,{editor:e})&&r.preventDefault()};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}};var C9=e=>{if(pe(e))return e.text.length>0?e.text:null;if(Be(e)){let t=e.name;return t!==void 0&&t.length>0?t:null}return null},hS=(e,t)=>{let n=t.trim().toLowerCase();if(n==="")return[];let o=[];for(let a of e.elements.values()){let r=C9(a);r?.toLowerCase().includes(n)&&o.push({kind:"element",id:a.id,text:r})}for(let a of e.links.values()){let r=a.label?.text;r?.toLowerCase().includes(n)&&o.push({kind:"link",id:a.id,text:r})}return o};var $W=new Map;var I9=e=>$W.get(e);var mS=()=>{let e=new Map;return{on:(s,i)=>{let l=e.get(s);return l||(l=new Set,e.set(s,l)),l.add(i),()=>{let c=e.get(s);c&&(c.delete(i),c.size===0&&e.delete(s))}},off:(s,i)=>{let l=e.get(s);l&&(l.delete(i),l.size===0&&e.delete(s))},emit:(s,...i)=>{let l=e.get(s);if(!l||l.size===0)return 0;let c=Array.from(l),u=null,d=0;for(let f of c)try{f(...i),d++}catch(p){u??=p instanceof Error?p:new Error(String(p))}if(u!==null)throw u;return d},clear:s=>{if(s===void 0){e.clear();return}e.delete(s)},listenerCount:s=>{let i=e.get(s);return i?i.size:0}}};var yS=()=>{let e=new Set;return{add:t=>(e.add(t),()=>e.delete(t)),emit:t=>{for(let n of[...e])n(t)},clear:()=>{e.clear()},size:()=>e.size}};var M9=e=>{let t=new Map,n=new Map,o=new Map,a=new Map,r=new Map,s=null,i=()=>s,l=[],c=-1,u=p=>{if(p.kind==="batch"){for(let h of p.patches)u(h);return}if(p.kind==="element"){let h=t.get(p.id);h?h.latest={...h.latest,after:p.after}:(t.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="link"){let h=n.get(p.id);h?h.latest={...h.latest,after:p.after}:(n.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="layer"){let h=o.get(p.id);h?h.latest={...h.latest,after:p.after}:(o.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="annotation"){let h=a.get(p.id);h?h.latest={...h.latest,after:p.after}:(a.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="file"){let h=r.get(p.id);h?h.latest={...h.latest,after:p.after}:(r.set(p.id,{first:p,latest:p}),l.push(p));return}s?s={first:s.first,latest:{...s.latest,after:p.after}}:(s={first:p,latest:p},c=l.length,l.push(p))};for(let p of e)u(p);let d=i(),f=[];for(let p=0;p<l.length;p++){let h=v(l[p]),m;if(h.kind==="element"){let x=v(t.get(h.id));m={kind:"element",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="link"){let x=v(n.get(h.id));m={kind:"link",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="layer"){let x=v(o.get(h.id));m={kind:"layer",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="annotation"){let x=v(a.get(h.id));m={kind:"annotation",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="file"){let x=v(r.get(h.id));m={kind:"file",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(p===c&&d!==null)m={kind:"viewport",before:d.first.before,after:d.latest.after};else continue;QW(m)||f.push(m)}return f},QW=e=>e.kind==="element"||e.kind==="link"||e.kind==="layer"||e.kind==="annotation"||e.kind==="file"||e.kind==="viewport"?e.before===e.after:!1;var Hp=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Kr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),yc(t)):null}redo(){let t=this.future.pop();return t?(this.past.push(t),t):null}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}get size(){return this.past.length}get redoSize(){return this.future.length}get undoStack(){return this.past}get redoStack(){return this.future}clear(){this.past.length=0,this.future.length=0}transaction(){if(this.current!==null)throw new Error("A transaction is already open");let t=[];return this.current=t,{add:n=>{if(this.current!==t)throw new Error("Transaction is no longer open");Kr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?M9(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Yo(n);Kr(a)||(this.past.push(a),this.future.length=0,this.trim())},cancel:()=>{this.current===t&&(this.current=null)},isOpen:()=>this.current===t}}hasOpenTransaction(){return this.current!==null}record(t,n){if(n?.transaction?.isOpen()){n.transaction.add(t);return}this.push(t)}current=null;trim(){if(Number.isFinite(this.limit))for(;this.past.length>this.limit;)this.past.shift()}};var Up=class{entries=[];register(t){let n=this.entries.findIndex(o=>o.id===t.id);if(n!==-1){this.entries[n]=t;return}this.entries.push(t)}unregister(t){let n=this.entries.findIndex(o=>o.id===t);n!==-1&&this.entries.splice(n,1)}getAll(){return this.entries}async dispatch(t,n){for(let o of this.entries)if(o.accept(t))return await o.handle(t,n),!0;return!1}},R9=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var gS=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},xS=e=>{if(e.type&&R9.includes(e.type))return!0;let t=e.name.toLowerCase().split(".").pop();return t?{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jfif",svg:"image/svg+xml",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"}[t]!==void 0:!1};var bS=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let a=o.result;typeof a=="string"?t(a):n(new Error(`Unexpected FileReader result type for ${e.name}`))},o.onerror=()=>{n(o.error??new Error(`Failed to read ${e.name}`))},o.readAsDataURL(e)});var JW=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),AS=async function*(e,t={}){let n=t.skipDirectory??JW,o=t.maxDepth??32,a=e.items,r=a!==null&&a.length>0&&typeof a[0]?.webkitGetAsEntry=="function";if(a===null||!r){for(let s of Array.from(e.files))yield s;return}for(let s of Array.from(a)){if(s.kind!=="file")continue;let i=s.webkitGetAsEntry?.();i&&(yield*O9(i,"",0,n,o,t.onError))}};async function*O9(e,t,n,o,a,r){let s=t?`${t}/${e.name}`:e.name;if(e.isFile){try{yield await new Promise((c,u)=>{e.file?.(c,u)})}catch(l){r?.(s,l)}return}if(!e.isDirectory||o(e.name))return;if(n>=a){r?.(s,new Error(`Folder depth exceeds ${a}`));return}let i=e.createReader?.();if(i)for(;;){let l;try{l=await new Promise((c,u)=>{i.readEntries(c,u)})}catch(c){r?.(s,c);return}if(l.length===0)return;for(let c of l)yield*O9(c,s,n+1,o,a,r)}}var eq=e=>new Promise((t,n)=>{if(typeof Image>"u"){n(new Error("Image() is not available in this environment"));return}let o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{n(new Error("Failed to decode image data URL"))},o.src=e}),P9={id:"image",accept:e=>xS(e),handle:async(e,{editor:t,worldPoint:n})=>{let o=typeof URL<"u"&&typeof URL.createObjectURL=="function",a=await t.addBinaryFile(e,e.name),r=o?URL.createObjectURL(e):await bS(e),s=await eq(r),i=Fv,l=Math.max(s.width,s.height)>i?i/Math.max(s.width,s.height):1,c=Math.round(s.width*l),u=Math.round(s.height*l),d={x:n.x-c/2,y:n.y-u/2},f=e.type==="image/gif"||/\.gif$/i.test(e.name),p=null;if(typeof Image<"u"){if(p=new Image,p.src=r,typeof document<"u"){let y=B9();p.style.position="fixed",p.style.left="0",p.style.top="0",p.style.width="1px",p.style.height="1px",p.style.opacity="0.01",p.style.zIndex="-1",p.style.pointerEvents="none",y.appendChild(p)}let x=p;x.complete||await new Promise(y=>{x.onload=()=>{y()},x.onerror=()=>{y()}})}let h=f?await e.arrayBuffer():void 0,m=p??void 0;if(p&&!f&&typeof createImageBitmap=="function")try{m=await createImageBitmap(p)}catch{}t.insertImage({src:r,fileId:a,width:c,height:u,position:d,...m?{image:m}:{},animated:f,...f?{animationKind:"gif"}:{},...h?{animationData:h}:{}})}},D9="oh-just-another-animated-image-sink",B9=()=>{let e=document.getElementById(D9);if(e)return e;let t=document.createElement("div");return t.id=D9,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.width="0",t.style.height="0",t.style.overflow="visible",t.style.pointerEvents="none",t.style.zIndex="-1",document.body.appendChild(t),t},vS=e=>{let t=document.createElement("video");return t.src=e,t.muted=!0,t.loop=!0,t.playsInline=!0,t.autoplay=!0,t.style.position="absolute",t.style.left="-99999px",t.style.top="-99999px",t.style.width="1px",t.style.height="1px",B9().appendChild(t),t},N9={id:"video",accept:e=>gS(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=await t.addBinaryFile(e,e.name),a=URL.createObjectURL(e),r=vS(a);await new Promise(p=>{let h=()=>{p()};r.onloadedmetadata=h,r.onerror=h});let s=r.videoWidth||v4,i=r.videoHeight||S4,l=Fv,c=Math.max(s,i)>l?l/Math.max(s,i):1,u=Math.round(s*c),d=Math.round(i*c),f={x:n.x-u/2,y:n.y-d/2};r.play().catch(()=>{}),t.insertImage({src:a,width:u,height:d,position:f,image:r,animated:!0,fileId:o})}};var Uy=64,z9=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<Uy;){let r=I(e,o.parentId);if(!r)break;ze(r)&&(n=r),o=r,a++}return n},SS=(e,t,n)=>{let o=I(e,t),a=0;for(;o&&a<Uy;){if(o.id===n)return!0;if(!o.parentId)return!1;o=I(e,o.parentId),a++}return!1},F9=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<Uy&&n!==o.parentId;){let r=I(e,o.parentId);if(!r||!ze(r))break;o=r,a++}return o},H9=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||SS(e,r.id,n)||o.add(r.id);return o},U9=(e,t,n,o)=>{if(!n)return null;if(o!==n.id)return n;let a=t,r=null,s=0;for(;a.parentId&&s<Uy;){let i=I(e,a.parentId);if(!i||i.id===n.id)break;ze(i)&&(r=i),a=i,s++}return r};var tq=/^Frame (\d+)$/,G9=e=>{let t=0;for(let n of e.elements.values()){if(!Be(n))continue;let o=tq.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},W9=(e,t,n,o)=>{let a=o.x,r=o.y,s=o.x+o.width,i=o.y+o.height,l=e;for(let c of e.elements.values()){if(c.id===n||Be(c)||c.frameId!==void 0)continue;let u=N(c),d=u.x+u.width/2,f=u.y+u.height/2;if(d<a||d>s||f<r||f>i)continue;let p=$(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},q9=(e,t)=>{let n=[...e.elements.values()].filter(Be).sort((a,r)=>a.order<r.order?1:a.order>r.order?-1:0).map(a=>({id:a.id,b:N(a)})),o=e;for(let a of e.elements.values()){if(Be(a))continue;let r=N(a),s=r.x+r.width/2,i=r.y+r.height/2,l;for(let u of n)if(s>=u.b.x&&s<=u.b.x+u.b.width&&i>=u.b.y&&i<=u.b.y+u.b.height){l=u.id;break}if(a.frameId===l)continue;let c=$(o,a.id,u=>{let d={...u};return l===void 0?delete d.frameId:d.frameId=l,d});o=c.scene,t.push(c.patch)}return o};var Gy=class{pending=!1;getScene;compact;constructor(t){this.getScene=t.getScene,this.compact=t.compact}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}runCheck(){let t=this.getScene(),n=new Set;for(let o of t.elements.values())o.order.length>Dv&&n.add(o.layerId);for(let o of t.links.values())o.order.length>Dv&&n.add(o.layerId);for(let o of n)this.compact(o)}};var Wy=class{opts;pending=!1;signatures=new Map;constructor(t){this.opts=t}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}resetSignature(t){this.signatures.set(t,this.signatureFor(t))}runCheck(){let t=this.opts.getScene(),n=!1;for(let o of t.elements.values()){if(!Dn(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=lp(this.opts.getScene(),o.id);if(!r)continue;this.opts.applyPatch(r);let s=this.opts.getScene();for(let i of s.elements.values())i.parentId===o.id&&this.opts.growContainer(o.id,i.id);n=!0}n&&this.opts.onMutated()}signatureFor(t){let n=this.opts.getScene(),o=I(n,t),a=[...n.elements.values()].filter(s=>s.parentId===t);if(o&&Dn(o)?.kind==="wrap"){let s=no(o),i=s?`${Math.round(s.x)},${Math.round(s.y)}`:"0,0",l=s?Math.round(s.width):0,c=a.map(u=>{let d=N(u);return`${u.id}:${Math.round(d.width)}x${Math.round(d.height)}`}).sort();return`o${i}|w${l}|${c.join(",")}`}let r=a.map(s=>s.id);return r.sort(),r.join(",")}};var V9=()=>({activeTool:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),j9=(e,t,n)=>{n.activeTool!==e.activeTool&&(e.activeTool=n.activeTool,t.emit("tool",n.activeTool)),n.selection!==e.selection&&(e.selection=n.selection,t.emit("selection",n.selection)),n.scene!==e.scene&&(e.scene=n.scene,t.emit("scene",n.scene)),n.scene.viewport!==e.viewport&&(e.viewport=n.scene.viewport,t.emit("viewport",n.scene)),(n.canUndo!==e.canUndo||n.canRedo!==e.canRedo)&&(e.canUndo=n.canUndo,e.canRedo=n.canRedo,t.emit("history",{canUndo:n.canUndo,canRedo:n.canRedo})),t.emit("change")},Z9=(e,t)=>{e.activeTool=t.activeTool,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var qy=class{frameId=null;isAnimated;onTick;constructor(t){this.isAnimated=t.isAnimated,this.onTick=t.onTick}start(){if(this.frameId!==null||typeof requestAnimationFrame>"u")return;let t=()=>{if(!this.isAnimated()){this.frameId=null;return}this.onTick(),this.frameId=requestAnimationFrame(t)};this.frameId=requestAnimationFrame(t)}stop(){this.frameId!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameId),this.frameId=null)}get running(){return this.frameId!==null}};var Vy=class{host;tick;costEma=0;lastTickMs=0;onVisibilityChange=()=>{typeof document>"u"||(document.hidden?this.tick.stop():this.maybe())};constructor(t){this.host=t,this.tick=new qy({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(k4,Math.max(L4,this.costEma*_4));if(t-this.lastTickMs<n)return;this.lastTickMs=t,this.host.autoStopHeavyGifs(),this.host.forceAnimationRepaint();let o=(typeof performance<"u"?performance.now():Date.now())-t;this.costEma=this.costEma*.8+o*.2}attach(){typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange)}detach(){this.tick.stop(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange)}maybe(){this.host.hasVisibleAnimatedElement()&&this.tick.start()}};var jy=class{ref;constructor(t){this.ref=t}record(t){this.ref.gestureTx??=this.ref.history.transaction(),this.ref.gestureTx.add(t)}commit(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.dragElementId=null,this.ref.containerHover!==null&&(this.ref.containerHover=null),this.ref.gestureTx&&(this.ref.gestureTx.commit(),this.ref.gestureTx=null),this.ref.notify()}cancel(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.gestureTx&&(this.ref.gestureTx.cancel(),this.ref.gestureTx=null)}finalize(){if(this.ref.gestureTx){try{this.ref.gestureTx.commit()}catch{this.ref.gestureTx.cancel()}this.ref.gestureTx=null}}maybeRevertModeAfterCreate(){this.ref.toolLocked||this.ref.mode==="select"||this.ref.mode==="hand"||this.ref.setMode("select")}};function Gp(){return typeof performance<"u"?performance.now():Date.now()}function nq(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Zy=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Gp();this.state.set(t,{playing:!nq(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Gp();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Gp(),o=this.state.get(t);o?o.playing?(o.frozenMs=n-o.originMs,o.playing=!1):(o.originMs=n-o.frozenMs,o.playStartMs=n,o.playing=!0):this.state.set(t,{playing:!0,originMs:n,playStartMs:n,frozenMs:0})}hoverEnter(t){if(this.hoveredId===t||(this.hoveredId=t,t===null))return!1;let n=this.state.get(t);if(n&&!n.playing){let o=Gp();return n.originMs=o-n.frozenMs,n.playStartMs=o,n.playing=!0,!0}return!1}isPaused(t){return this.state.get(t)?.playing===!1}autoStopHeavy(t){let n=Gp();for(let o of t){let a=this.state.get(o);if(a?.playing){if(o===this.hoveredId){a.playStartMs=n;continue}n-a.playStartMs>T4&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var X9=(e,t,n,o)=>{let a=Ae(Array.from(e.elements.values()).filter(s=>s.layerId===o).map(s=>s.order)),r={};return t.image&&(r.image=t.image),t.animated&&(r.animated=!0),{id:n,layerId:o,type:"image",position:t.position,rotation:0,scale:{x:1,y:1},order:a,style:{},width:t.width,height:t.height,src:t.src,...t.fileId?{fileId:t.fileId}:{},...t.animationKind?{animationKind:t.animationKind}:{},...t.animationData!==void 0?{animationData:t.animationData}:{},...Object.keys(r).length>0?{metadata:r}:{}}},Y9=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=fA(`file-${o()}-${Date.now().toString(36)}`),s=iv(r,a,{mime:t.type||"application/octet-stream",...n!==void 0?{name:n}:{}}),i={kind:"file",id:r,before:null,after:s};return{scene:J(e,i),patch:i,id:r}},Xy=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var $9=e=>{if(!Xy(e._scene))return!1;let t=e.computeViewportWorld();if(!t)return!0;for(let n of e._scene.elements.values())if(n.metadata?.animated===!0&&j.intersects(N(n),t))return!0;return!1},Q9=e=>{let t=[];for(let n of e._scene.elements.values()){if(!ct(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>w4&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},LS=e=>{for(let t of e._scene.elements.values()){if(!ct(t)||!t.animationKind||(e.gifPlayback.ensure(t.id),!t.fileId)||t.animationData instanceof ArrayBuffer)continue;let n=Z0(e._scene,t.fileId);n&&(e._scene=J(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}},oq=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],K9=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of oq){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},aq=async(e,t)=>{if(typeof Blob>"u")return null;let n=new Blob([e],{type:t||"application/octet-stream"});if(typeof createImageBitmap=="function")try{return await createImageBitmap(n)}catch{}if(typeof Image<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"){let o=URL.createObjectURL(n);return new Promise(a=>{let r=new Image;r.onload=()=>{a(r)},r.onerror=()=>{URL.revokeObjectURL(o),a(null)},r.src=o})}return null},rq=async(e,t)=>{if(typeof document>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return null;let n=URL.createObjectURL(new Blob([e],{type:t})),o=vS(n);return await new Promise(r=>{o.onloadedmetadata=()=>{r(!0)},o.onerror=()=>{r(!1)}})?(o.play().catch(()=>{}),o):(URL.revokeObjectURL(n),o.remove(),null)},kS=async e=>{let t=[];for(let o of e._scene.elements.values()){if(!ct(o)||o.animationKind||K9(o.metadata?.image)||!o.fileId)continue;let a=Z0(e._scene,o.fileId);a&&t.push({id:o.id,data:a.data,mime:a.mime})}if(t.length===0)return;let n=!1;for(let o of t){let a=o.mime.startsWith("video/")?await rq(o.data,o.mime):await aq(o.data,o.mime);if(!a)continue;let r=e._scene.elements.get(o.id);!r||!ct(r)||K9(r.metadata?.image)||(e._scene=J(e._scene,{kind:"element",id:r.id,before:r,after:{...r,metadata:{...r.metadata,image:a}}}),n=!0)}n&&e.forceRender()};var J9={x:-1e9,y:-1e9,width:0,height:0},iq=4,eR=(e,t)=>{let n=new Map;if(e===t)return{world:J9,tileDirty:n};let o=null,a=u=>{o=o?j.union(o,u):u},r=new Set;for(let[u,d]of t.elements){let f=e.elements.get(u);if(f===d)continue;r.add(u);let p=op(d),h=f?op(f):null;a(p),h&&a(h),n.set(u,{before:h,after:p})}for(let[u,d]of e.elements)if(!t.elements.has(u)){r.add(u);let f=op(d);a(f),n.set(u,{before:f,after:null})}let s=u=>{for(let d of[u.from,u.to])if(d.kind!=="point"&&r.has(d.elementId))return!0;return!1};for(let[u,d]of t.links){let f=e.links.get(u);if(f===d&&!s(d))continue;let p=as(t,d);p&&a(p);let m=as(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=as(e,d);f&&a(f)}if(o===null)return{world:J9,tileDirty:n};let i=new Set,l=o,c=!0;for(;c;){c=!1;for(let u of t.elements.values()){if(i.has(u.id))continue;let d=N(u);if(!j.intersects(d,l))continue;i.add(u.id);let f=j.union(l,d);(f.x!==l.x||f.y!==l.y||f.width!==l.width||f.height!==l.height)&&(l=f,c=!0)}}return{world:j.expand(l,iq),tileDirty:n}};var Yy=class{screenToWorld;onFire;timer=null;origin=null;constructor(t,n){this.screenToWorld=t,this.onFire=n}start(t){this.cancel(),this.origin=t,this.timer=setTimeout(()=>{this.timer=null;let n=this.origin;if(this.origin=null,!n)return;let o=this.screenToWorld(n);this.onFire({screenPoint:n,worldPoint:o})},UI)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&W.distance(this.origin,t)>n&&this.cancel()}};var Ky=class{screenToWorld;zoomAt;panBy;origin=null;constructor(t,n,o){this.screenToWorld=t,this.zoomAt=n,this.panBy=o}isActive(){return this.origin!==null}begin(t){if(t.length<2)return;let[n,o]=t,a=W.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:W.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=W.distance(n,o),r=W.midpoint(n,o);if(W.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<HI)return;let i=a/this.origin.distance;if(i!==1){let u=this.screenToWorld(r);this.zoomAt(i,u)}let l=r.x-this.origin.midpointScreen.x,c=r.y-this.origin.midpointScreen.y;(l!==0||c!==0)&&this.panBy({x:l,y:c}),this.origin={midpointWorld:this.screenToWorld(r),distance:a,midpointScreen:r}}end(){this.origin=null}};var lq=(e,t)=>{let n=e.width*e.height;if(n<=0)return 0;let o=Math.max(e.x,t.x),a=Math.max(e.y,t.y),r=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height),i=r-o,l=s-a;return i<=0||l<=0?0:i*l/n},cq=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=N(o);n=n?j.union(n,a):a}return n},tR=(e,t,n,o)=>{if(!Wf(t)||!Ii(t))return n;if(Dn(t)?.kind==="wrap")return uq(e,t,n,o);let a=cq(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=no(r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.x,f=s.y,p=s.x+s.width,h=s.y+s.height,m=a.x,x=a.y,y=a.x+a.width,g=a.y+a.height;if(o.includes("e")&&p<y&&(c+=y-p),o.includes("s")&&h<g&&(u+=g-h),o.includes("w")&&d>m){let b=d-m;i-=b,c+=b}if(o.includes("n")&&f>x){let b=f-x;l-=b,u+=b}return{x:i,y:l,width:c,height:u}},uq=(e,t,n,o)=>{let a=di(t)?.padding??0,r=Math.max(0,n.width-2*a),s=$0(e,t.id,r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.widest+2*a;if(c<d){let m=d-c;c=d,o.includes("w")&&(i-=m)}let f=Math.max(0,c-2*a),h=(f===r?s:$0(e,t.id,f)??s).contentHeight+2*a;if(u<h){let m=h-u;u=h,o.includes("n")&&(l-=m)}return{x:i,y:l,width:c,height:u}},nR=(e,t)=>{let n=e.dragElementId;if(!n)return;let o=I(e.scene,n);if(!o)return;let a=e.containerHover;if(a&&a.id!==o.parentId){let r=Ae([...e.scene.elements.values()].filter(i=>i.layerId===o.layerId&&i.id!==n).map(i=>i.order)),s=$(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),Wp(e,a.id,n);return}if(a&&a.id===o.parentId){Wp(e,o.parentId,n);return}if(o.parentId){let r=I(e.scene,o.parentId);if(r!==void 0&&ze(r))return;let s=r?no(r):null,i=N(o),l=s?lq(i,s):0;if(s&&l>=t4){Wp(e,o.parentId,n);return}let c=$(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},Wp=(e,t,n)=>{let o=I(e.scene,t),a=I(e.scene,n);if(!o||!a)return;let r=di(o);if(!r)return;let s=N(a),i=PA(o,s);if(!i)return;if(Ii(o)){let c=BA({width:o.width,height:o.height,spec:r},i),u=$(e.scene,t,d=>({...d,position:{x:d.position.x+c.positionOffset.x,y:d.position.y+c.positionOffset.y},width:c.width,height:c.height,metadata:{...d.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(u.patch,u.scene);return}let l=$(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var qp=(e,t,n)=>{let o=e.x,a=e.y,r=e.width,s=e.height;switch(t){case"nw":o+=n.x,a+=n.y,r-=n.x,s-=n.y;break;case"n":a+=n.y,s-=n.y;break;case"ne":a+=n.y,r+=n.x,s-=n.y;break;case"e":r+=n.x;break;case"se":r+=n.x,s+=n.y;break;case"s":s+=n.y;break;case"sw":o+=n.x,r-=n.x,s+=n.y;break;case"w":o+=n.x,r-=n.x;break}return{x:o,y:a,width:r,height:s}},_S=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2,a=e.width+2*(t.width-e.width),r=e.height+2*(t.height-e.height);return{x:n-a/2,y:o-r/2,width:a,height:r}},wS=(e,t)=>{if(e.width===0||e.height===0)return t;let n=t.width/e.width,o=t.height/e.height,a=Math.abs(n-1)>=Math.abs(o-1)?n:o;return{x:t.x,y:t.y,width:e.width*a,height:e.height*a}},oR=e=>e==="nw"||e==="w"||e==="sw",aR=e=>e==="ne"||e==="e"||e==="se",rR=e=>e==="nw"||e==="n"||e==="ne",sR=e=>e==="sw"||e==="s"||e==="se",TS=(e,t,n,o,a=!1)=>{let r=o.noFlip?o.minWidth??0:o.minWidth,s=o.noFlip?o.minHeight??0:o.minHeight,i=o.maxWidth,l=o.maxHeight,c=(m,x,y)=>{let g=m;return x!==void 0&&g<x&&(g=x),y!==void 0&&g>y&&(g=y),g},u=t.width;o.noFlip?u=c(u,r,i):i!==void 0&&Math.abs(u)>i?u=u<0?-i:i:r!==void 0&&Math.abs(u)<r&&u!==0&&(u=u<0?-r:r);let d=t.height;if(o.noFlip?d=c(d,s,l):l!==void 0&&Math.abs(d)>l?d=d<0?-l:l:s!==void 0&&Math.abs(d)<s&&d!==0&&(d=d<0?-s:s),a){let m=o.noFlip?u:Math.abs(u),x=o.noFlip?d:Math.abs(d),y=e.x+e.width/2,g=e.y+e.height/2;return{x:y-m/2,y:g-x/2,width:m,height:x}}let f=t.x;oR(n)&&!aR(n)?f=e.x+e.width-u:aR(n)&&!oR(n)&&(f=e.x);let p=t.y;rR(n)&&!sR(n)?p=e.y+e.height-d:sR(n)&&!rR(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:j.normalize(h)};var iR=(e,t)=>e.kind!=="point"&&t.has(e.elementId),dq=(e,t)=>iR(e.from,t)&&iR(e.to,t),uR=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,lR=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),fq=(e,t)=>{if(!uR(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=lR(e.waypoints,t)),e.fixedSegments?.length&&(n.fixedSegments=e.fixedSegments.map(o=>({axis:o.axis,pos:o.pos+(o.axis==="h"?t.y:t.x),at:o.at+(o.axis==="h"?t.x:t.y)}))),e.routedPoints?.length&&(n.routedPoints=lR(e.routedPoints,t)),n},cR=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,ES=(e,t)=>{let n=fq(e,t),o=e.from.kind==="point",a=e.to.kind==="point";if(!n&&!o&&!a)return null;let r={...n??{}};return o&&(r.from=cR(e.from,t)),a&&(r.to=cR(e.to,t)),r},dR=(e,t,n,o,a)=>{let r=c=>({x:t+(c.x-t)*o,y:n+(c.y-n)*a}),s=e.from.kind==="point",i=e.to.kind==="point";if(!uR(e)&&!s&&!i)return null;let l={};return e.waypoints?.length&&(l.waypoints=e.waypoints.map(r)),e.fixedSegments?.length&&(l.fixedSegments=e.fixedSegments.map(c=>({axis:c.axis,pos:c.axis==="h"?n+(c.pos-n)*a:t+(c.pos-t)*o,at:c.axis==="h"?t+(c.at-t)*o:n+(c.at-n)*a}))),e.routedPoints?.length&&(l.routedPoints=e.routedPoints.map(r)),e.from.kind==="point"&&(l.from={kind:"point",position:r(e.from.position)}),e.to.kind==="point"&&(l.to={kind:"point",position:r(e.to.position)}),l},fR=(e,t,n)=>n.has(e.id)||dq(e,t),CS=(e,t,n)=>{let o=new Map;for(let a of e.links.values())fR(a,t,n)&&ES(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},pR=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=ue(e,a);if(!s)continue;let i=ES(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},hR=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!fR(s,t,n))continue;let i=ES(s,o);if(!i)continue;let l=Ye(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var mR=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=I(e,t);if(!l||!Ii(l))return null;let c=qp(a,n,o),u=s?wS(a,c):c,d=i?_S(a,u):u,p=l.noFlip===!0||Dn(l)!==null?{...l,noFlip:!0}:l,h=TS(a,d,n,p,i),m=r(l,h,n),x={...l,position:{x:m.x,y:m.y},scale:{x:1,y:1},width:m.width,height:m.height},y={kind:"element",id:t,before:l,after:x};return{scene:J(e,y),patch:y}},yR=(e,t,n,o,a=!1,r=!1)=>{let s=I(e,t.id);if(!s||!Ii(t))return null;let i=bi(t),[l]=gp(i),c=Math.cos(i.rotation),u=Math.sin(i.rotation),d={x:c,y:u},f={x:-u,y:c},p={x:o.x*d.x+o.y*d.y,y:o.x*f.x+o.y*f.y},h={x:0,y:0,width:i.bounds.width,height:i.bounds.height},m=qp(h,n,p),x=a?wS(h,m):m,y=r?_S(h,x):x,b=t.noFlip===!0||Dn(t)!==null?{...t,noFlip:!0}:t,A=TS(h,y,n,b,r),_={x:l.x+A.x*d.x+A.y*f.x,y:l.y+A.x*d.y+A.y*f.y},C={...t,position:_,scale:{x:1,y:1},width:A.width,height:A.height},w={kind:"element",id:t.id,before:s,after:C};return{scene:J(e,w),patch:w}},gR=(e,t,n,o,a,r=!1)=>{let s=I(e,t.id);if(!s)return null;let i=qp(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let L=Math.max(t.fontSize,Math.abs(i.width)),k=n==="w"?a.x+a.width:a.x,M=r?l-L/2:n==="w"?k-L:k,B={...t,position:{x:M,y:a.y},scale:{x:1,y:1},maxWidth:L},G={kind:"element",id:t.id,before:s,after:B};return{scene:J(e,G),patch:G}}let u=n==="n"||n==="s",d=a.width>0?Math.abs(i.width/a.width):1,f=a.height>0?Math.abs(i.height/a.height):1,p=u?f:Math.max(d,f),h=Math.max(cy,t.fontSize*p),m=h/t.fontSize,x=a.width*m,y=a.height*m,g=n.includes("w")?a.x+a.width:a.x,b=n.includes("n")?a.y+a.height:a.y,A=r?l-x/2:n.includes("w")?g-x:g,_=r?c-y/2:n.includes("n")?b-y:b,C={...t,position:{x:A,y:_},scale:{x:1,y:1},fontSize:h,...t.maxWidth!==void 0?{maxWidth:t.maxWidth*m}:{}},w={kind:"element",id:t.id,before:s,after:C};return{scene:J(e,w),patch:w}},xR=(e,t,n,o,a,r,s=!1)=>{let i=qp(a,n,o),l=1,c=a.width>0?i.width/a.width:1,u=a.height>0?i.height/a.height:1;if(r){let x=Math.max(Math.abs(c),Math.abs(u));c=x*(c>=0?1:-1),u=x*(u>=0?1:-1)}s&&(c=1+2*(c-1),u=1+2*(u-1));let d=Math.abs(c-1)>=Math.abs(u-1)?c:u,f=s?a.x+a.width/2:n.includes("w")?a.x+a.width:a.x,p=s?a.y+a.height/2:n.includes("n")?a.y+a.height:a.y,h=e,m=[];for(let[x,y]of t.elements){let g=I(h,x);if(!g)continue;let b=f+(y.position.x-f)*c,A=p+(y.position.y-p)*u;if(Ii(g)){let k=g.type==="image",M=k?d:c,B=k?d:u,G=y.bounds.width*M,ie=y.bounds.height*B;if(Math.abs(G)<l||Math.abs(ie)<l)continue;let ne={...g,position:{x:b,y:A},scale:{x:G>=0?1:-1,y:ie>=0?1:-1},width:Math.abs(G),height:Math.abs(ie)},V={kind:"element",id:x,before:g,after:ne};h=J(h,V),m.push(V);continue}let _=y.scale.x*c,C=y.scale.y*u;if(Math.abs(_)<l/Math.max(1,y.bounds.width)||Math.abs(C)<l/Math.max(1,y.bounds.height))continue;let w={...g,position:{x:b,y:A},scale:{x:_,y:C}},L={kind:"element",id:x,before:g,after:w};h=J(h,L),m.push(L)}for(let[x,y]of t.links??[]){let g=ue(h,x);if(!g)continue;let b=dR(y,f,p,c,u);if(!b)continue;let A={kind:"link",id:x,before:g,after:{...g,...b}};h=J(h,A),m.push(A)}return{scene:h,patches:m}};var gt=Object.freeze(new Set),$y=e=>new Set([e]),IS=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},pq=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},bR=(e,t)=>e.has(t)?pq(e,t):IS(e,t),Vp=(e,t)=>M0(e,t),AR=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var jp=e=>Math.min(FI,Math.max(zI,e)),vR=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:JA(e.viewport,t)},SR=(e,t,n)=>{let o=e.viewport.zoom,r=jp(o*t)/o;return r===1?null:{...e,viewport:V0(e.viewport,r,n)}},LR=e=>{let t=e.viewport;if(t.zoom===1)return null;let n={x:t.pan.x+t.size.width/2/t.zoom,y:t.pan.y+t.size.height/2/t.zoom};return{...e,viewport:V0(t,1/t.zoom,n)}},RS=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=jp(Math.min(a/t.width,r/t.height)),i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:i.x-o.size.width/2/s,y:i.y-o.size.height/2/s};return{...e,viewport:{...o,zoom:s,pan:l}}},kR=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=Math.min(a/t.width,r/t.height),i=jp(Math.min(o.zoom,s)),l={x:t.x+t.width/2,y:t.y+t.height/2},c={x:l.x-o.size.width/2/i,y:l.y-o.size.height/2/i};return{...e,viewport:{...o,zoom:i,pan:c}}},_R=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=N(o);n=n?j.union(n,a):a}return n?RS(e,n,t):null},wR=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:ev(o,t,n)}},TR=(e,t)=>{let n=e.viewport,o=t.enabled??n.gridEnabled,a=t.style??n.gridStyle,r=t.snap??n.snapToGrid;if(o===n.gridEnabled&&a===n.gridStyle&&r===n.snapToGrid)return null;let s={...n,gridEnabled:o,...a===void 0?{}:{gridStyle:a},...r===void 0?{}:{snapToGrid:r}};return{...e,viewport:s}};var hq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!o?.label)return!1;let a=fc(e._scene,o);if(!(a!==null&&t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height))return!1;e.cancelLongPress();let s=performance.now(),i=e.interaction.lastClickWorldPoint,l=s-e.interaction.lastClickAt<bc&&i!==null&&Math.hypot(i.x-t.x,i.y-t.y)<=Ac;return e.interaction.lastClickAt=s,e.interaction.lastClickWorldPoint=t,l?(e.beginLinkCaptionEdit(n),!0):(e.beginLabelDrag(n),!0)},mq=(e,t)=>e.isDraggingLabel?(e.updateLabelDrag(t),!0):!1,yq=e=>e.isDraggingLabel?(e.endLabelDrag(),!0):!1,ER=(e,t,n)=>{let o=e.x-t.x,a=e.y-t.y;return o*o+a*a<=n},gq=(e,t,n)=>{let o=t.button===2||t.button===1,a=t.button===0&&e.spaceHeld,r=t.button===0&&e.activeTool.type==="hand";return o||a||r?(o&&(e.suppressNextContextMenu=!0),e.beginPanGesture(t.pointerId,t.button,n.point),!0):!1},xq=(e,t,n)=>(e.activePointers.set(t.pointerId,n.point),e.activePointers.size===2?(e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture(),e.cancelLongPress(),e.panGesture=null,e.touchPanCandidate=null,e.beginPinch(),!0):e.activePointers.size>2),bq=(e,t)=>e.readOnly||e.editingTextElement===null?!1:e.editedElementContainsPoint(t)?(e.cancelLongPress(),e.setTextCaretFromPoint(t),!0):(e.commitTextEdit(),!1),Aq=(e,t)=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.updateImageCropDrag(t),!0),vq=e=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.endImageCropDrag(),!0),Sq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="brush"?!1:(e.beginBrushStroke(t,n,o),!0),Lq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="erase"?!1:(e.cancelLongPress(),e.beginEraseStroke(t,n,o),!0),kq=(e,t)=>e.activeTool.type!=="laser"?!1:(e.cancelLongPress(),e.beginLaserStroke(t),!0),_q=(e,t)=>e.isEyedropperArmed?(e.cancelLongPress(),e.applyEyedropperAt(t),!0):!1,wq=(e,t)=>{if(e.activeTool.type!=="crop"||e.cropSession===null)return!1;let n=e.cropHandleAtWorld(t);return n===null?(e.commitImageCrop(),!1):(e.cancelLongPress(),n==="body"?e.beginImageCropBody(t):e.beginImageCropHandle(n,t),!0)},Tq=(e,t,n)=>{if(e.readOnly||e.activeTool.type!=="select"||(n||0)<2)return!1;let o=e.hitTest(t);if(o.kind!=="element")return!1;let a=I(e._scene,o.id);return a===void 0||!ct(a)?!1:(e.beginImageCrop(o.id),!0)},Eq=(e,t)=>{if(e.readOnly||e.activeTool.type!=="draw-text")return!1;e.cancelLongPress();let n=e.hitTest(t),o=n.kind==="element"?I(e._scene,n.id):void 0;return o!==void 0&&pe(o)?(e._selection=wt(o.id),e.beginTextEdit(o.id),e.notify()):e.createTextAt(t),!0},Cq=(e,t)=>{if(e.readOnly)return!1;let n=e.hitAnnotation(t);if(!n)return!1;let o=e._scene.annotations.get(n);return o?(e.annotationDrag={id:n,originPosition:{...o.position},originWorldPoint:t,moved:!1},e.setSelectedAnnotation(n),!0):!1},Iq=(e,t)=>{let n=e.acceleratedElementAt(t);if(!n)return!1;let o=I9(n.type);if(!o)return!1;let a={x:t.x-n.position.x,y:t.y-n.position.y},r=o(n,a);return r?(e.applyEmit(r),!0):!1},Mq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!(o&&(o.routing??"straight")==="orthogonal"))return!1;let a=ut(e._scene,o);if(!(a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s;for(let{k:l,point:c}of tp(e._scene,o,a)){let u=v(a[l]),d=v(a[l+1]),f=c.x-t.x,p=c.y-t.y;if(f*f+p*p<=i){let h=Math.abs(u.y-d.y)<1e-6?"h":"v",m=h==="h"?(u.x+d.x)/2:(u.y+d.y)/2,x=h==="h"?u.y:u.x;return e.isHandleDoubleClick(t)?e.resetSegmentPin(n,h,x,m):e.beginSegmentDrag(n,h,m),e.cancelLongPress(),!0}}return!1},Rq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n),a=o&&(o.routing??"straight")!=="orthogonal"?ut(e._scene,o):null;if(!(o&&a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s,l=[...o.waypoints??[]],c=!1;for(let u=0;u<l.length;u++)if(ER(v(l[u]),t,i)){e.isHandleDoubleClick(t)?e.deleteWaypoint(n,u):e.beginWaypointDrag(n,u,!1),c=!0;break}if(!c){let u=ep(e._scene,o)??[];for(let d=0;d<u.length;d++)if(ER(v(u[d]),t,i)){e.beginWaypointDrag(n,d,!0),c=!0;break}}return c?(e.cancelLongPress(),!0):!1},Oq=(e,t,n)=>{let o=I(e._scene,t);if(!o)return!1;let a=e._scene.viewport.zoom||1,{names:r,worldPoints:s}=Co(o,wo/a),i=($o+e.anchorStartHitSlop)/a,l=null,c=i*i;for(let u=0;u<s.length;u++){let d=v(s[u]),f=d.x-n.x,p=d.y-n.y,h=f*f+p*p;h<=c&&(c=h,l=v(r[u]))}return l===null?!1:(e.cancelLongPress(),e.linkDragFromAnchor={fromElement:t,fromWorld:Yt(o,{kind:"named",name:l}),anchorName:l,origin:n,moved:!1},!0)},Dq=(e,t,n,o)=>{if(e.readOnly||!(e.activeTool.type==="select"&&!t.modifiers.shift&&!t.modifiers.meta&&!t.modifiers.ctrl&&o.kind!=="rotate-handle"))return!1;let a=e._selection.size===1?[...e._selection][0]:null;return!!(a&&Oq(e,a,n))},Pq=(e,t,n)=>{if(!((t.modifiers.meta||t.modifiers.ctrl)&&n.kind==="element"&&e.elementLink(n.id)!==null)&&n.kind==="element"&&!e._selection.has(n.id)){let r=t.modifiers.shift||t.modifiers.meta||t.modifiers.ctrl;e._selection=r?Xt(e._selection,n.id):wt(n.id),r&&(e.additivePressAdded=n.id),!r&&e._selectedLinks.size>0&&(e._selectedLinks=gt),e.notify()}},Bq=(e,t,n)=>{if(e.readOnly)return n;if(t.modifiers.alt&&e.activeTool.type==="select"&&n.kind==="element"&&e._selection.has(n.id)){let o=e.duplicateSelectedInPlace(n.id);if(o!==null)return{kind:"element",id:o,bounds:n.bounds}}return n},IR=(e,t,n)=>{if(!n.has(t)){n.add(t);for(let o of e._scene.elements.values())o.parentId===t&&IR(e,o.id,n)}},Nq=(e,t)=>{if(t.kind==="element"){let n=I(e._scene,t.id),o=n!==void 0&&ze(n),a=n!==void 0&&Be(n),r=e._selection.has(t.id);if(r||o||a){let s=new Set;if(r)for(let l of e.expandSelectionWithDescendants()){let c=I(e._scene,l);c&&e.isElementManipulable(c)&&s.add(l)}if(o&&IR(e,t.id,s),a){s.add(t.id);for(let l of e._scene.elements.values())l.frameId===t.id&&s.add(l.id)}let i=CS(e._scene,s,e._selectedLinks);if(s.size>1||i.size>0){let l=new Map;for(let c of s){let u=I(e._scene,c);u&&l.set(c,u.position)}e.groupMoveOrigin=l,e.groupLinkMoveOrigin=i.size>0?i:null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null},zq=(e,t)=>{if(t.kind==="group-handle"){let n=new Map;for(let a of e.expandSelectionWithDescendants()){let r=I(e._scene,a);r&&n.set(a,{position:r.position,bounds:N(r),scale:r.scale})}let o=CS(e._scene,new Set(n.keys()),e._selectedLinks);e.groupResizeOrigin={combined:t.bounds,elements:n,links:o}}else e.groupResizeOrigin=null},Fq=(e,t)=>{if(t.kind==="rotate-handle"){let n=new Map;for(let o of e.expandSelectionWithDescendants()){let a=I(e._scene,o);a&&n.set(o,{position:a.position,rotation:a.rotation})}e.rotateGestureOrigin={pivot:t.pivot,origin:n}}else e.rotateGestureOrigin=null},Hq=(e,t,n)=>{let o=e.panGesture;if(o?.pointerId!==t.pointerId)return!1;let a=n.point.x-o.lastPoint.x,r=n.point.y-o.lastPoint.y;return o.lastPoint=n.point,!o.moved&&W.distance(o.startPoint,n.point)>xc&&(o.moved=!0),e.panBy({x:a,y:r}),!0},Uq=(e,t,n)=>(e.activePointers.has(t.pointerId)&&e.activePointers.set(t.pointerId,n.point),e.pinch.isActive()?(e.applyPinch(),!0):!1),Gq=(e,t,n)=>{if(e.touchPanCandidate!==null&&e.activePointers.size===1&&W.distance(e.touchPanCandidate,n.point)>xc){let o=e.touchPanCandidate;e.touchPanCandidate=null,e.beginPanGesture(t.pointerId,t.button,o);let a=e.panGesture;return a&&(a.moved=!0,e.panBy({x:n.point.x-o.x,y:n.point.y-o.y}),a.lastPoint=n.point),!0}return!1},Wq=(e,t)=>e.isDraggingSegment?(e.updateSegmentDrag(t),!0):!1,qq=(e,t)=>e.isDraggingWaypoint?(e.updateWaypointDrag(t),!0):!1,Vq=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;if(!n.moved){let o=t.x-n.origin.x,a=t.y-n.origin.y;if(o*o+a*a<_i*_i)return!0;n.moved=!0}return e.applyLinkPreview(n.fromElement,n.fromWorld,t),e.updateHoveredLinkTarget(t),!0},jq=(e,t)=>e.editingTextElement!==null&&e.isTextDragging?(e.extendTextSelectionToPoint(t),!0):!1,Zq=(e,t,n)=>e.brushStroke?(e.extendBrushStroke(t,n),!0):!1,Xq=(e,t,n)=>e.eraseStroke?(e.extendEraseStroke(t,n),!0):!1,Yq=(e,t)=>e.laserDrawing?(e.extendLaserStroke(t),!0):!1,Kq=(e,t)=>{if(!e.dragElementId)return;let n=e.dragElementId,o=new Set([n]);for(let r of e._scene.elements.values()){let s=r.parentId;for(let i=0;s&&i<64;i++){if(s===n){o.add(r.id);break}s=e._scene.elements.get(s)?.parentId}}let a=qf(e._scene,t,o);if(a){let r=no(a);if(r){let s={id:a.id,dropZone:r};(e.containerHover?.id!==s.id||e.containerHover.dropZone!==s.dropZone)&&(e.containerHover=s,e.notify())}}else e.containerHover!==null&&(e.containerHover=null,e.notify())},$q=(e,t)=>{let n=e.annotationDrag;if(!n)return!1;let o=t.x-n.originWorldPoint.x,a=t.y-n.originWorldPoint.y;(o!==0||a!==0)&&(n.moved=!0);let r=e._scene.annotations.get(n.id);if(r){let s={x:n.originPosition.x+o,y:n.originPosition.y+a},i={...r,position:s},l=new Map(e._scene.annotations);l.set(n.id,i),e._scene={...e._scene,annotations:l},e.notify()}return!0},Qq=(e,t)=>{for(let o of e.cursorListeners)o(t);let n=e.actor.getSnapshot().context;if(n.pressOrigin&&n.mode!=="select"&&n.mode!=="draw-edge"&&e.isDrawingPhase(n)&&(e.drawingPreview=Tp(n.pressOrigin,t)),n.mode==="draw-edge"?e.updateHoveredLinkTarget(t):e.hoveredLinkTarget!==null&&(e.hoveredLinkTarget=null,e.notify()),!n.pressOrigin){let o=e.hitTest(t),a=o.kind==="element"?e._scene.elements.get(o.id):void 0;e.hoverAnimatedElement(a&&ct(a)&&a.animationKind?a.id:null),e.setHoverCursorWorld(e.activeTool.type==="select"?t:null),e.activeTool.type==="erase"&&e.notify()}e.actor.send({type:"POINTER_MOVE",point:t})},Jq=(e,t)=>e.panGesture?.pointerId!==t.pointerId?!1:(e.endPanGesture(),!0),eV=e=>e.pinch.isActive()?(e.activePointers.size<2&&e.pinch.end(),!0):!1,tV=e=>e.isDraggingSegment?(e.endSegmentDrag(),!0):!1,nV=e=>e.isDraggingWaypoint?(e.endWaypointDrag(),!0):!1,oV=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;e.linkDragFromAnchor=null;let o=Hc(t,e.host),a=e.screenToWorld(o.point);if(n.moved){let r=e.hitTest(a),s=r.kind==="element"?r.id:null;e.applyEmit({type:"CREATE_EDGE",fromElement:n.fromElement,toElement:s,fromPoint:n.fromWorld,toPoint:a})}else{let r=I(e._scene,n.fromElement),s=e._scene.viewport.zoom||1,i=!1;if(r){let{names:l,worldPoints:c}=Co(r,wo/s),u=l.indexOf(n.anchorName);if(u>=0){let d=v(c[u]),f=e.anchorClickRadius/s,p=d.x-n.origin.x,h=d.y-n.origin.y;i=p*p+h*h<=f*f}}if(i)e.createLinkedElementFromAnchor(n.fromElement,n.anchorName);else{let l=e.hitTest(a);l.kind==="empty"?e.applyEmit({type:"SELECT_CLEAR"}):l.kind==="element"?e.applyEmit({type:"SELECT_REPLACE",id:l.id}):l.kind==="link"&&e.applyEmit({type:"SELECT_EDGE_REPLACE",id:l.id})}}return e.edgePreview=null,e.hoveredLinkTarget=null,e.notify(),!0},aV=e=>e.editingTextElement!==null&&e.isTextDragging?(e.endTextDragSelect(),!0):!1,rV=e=>e.brushStroke?(e.commitBrushStroke(),!0):!1,sV=e=>e.eraseStroke?(e.commitEraseStroke(),!0):!1,iV=e=>e.laserDrawing?(e.endLaserStroke(),!0):!1,lV=e=>{let t=e.annotationDrag;if(!t)return!1;if(e.annotationDrag=null,t.moved){let n=e._scene.annotations.get(t.id);if(n){let o={...n,position:t.originPosition},a=new Map(e._scene.annotations);a.set(t.id,o),e._scene={...e._scene,annotations:a};let r=Va(e._scene,t.id,()=>n);e._scene=r.scene,e._history.push(r.patch),e.notify()}}return!0},cV=(e,t,n)=>{let o=e.actor.getSnapshot().context.pressOrigin,a=t.modifiers.meta||t.modifiers.ctrl;if(o&&a){let r=e._scene.viewport.zoom||1;if(Math.hypot(n.x-o.x,n.y-o.y)*r<xc){let i=e.hitTest(n);if(i.kind==="element"){let l=e.elementLink(i.id);if(l)return e.openLink(l),e.actor.send({type:"POINTER_UP",point:n}),e.commitGesture(),!0}}}return!1},uV=(e,t)=>{let n=e.actor.getSnapshot().context,o=F5(n,t);o?.type==="SELECT_TOGGLE"&&e.additivePressAdded===o.id&&(o=null),e.additivePressAdded=null,!e.routeIsolationClick(o,t)&&o&&e.applyEmit(o),e.drawingPreview=null;let r;n.mode==="draw-edge"?r=e.hitTest(t):n.pressTarget?.kind==="edge-endpoint"&&(r=e.linkAttachTargetAt(t)),e.actor.send(r!==void 0?{type:"POINTER_UP",point:t,target:r}:{type:"POINTER_UP",point:t}),e.applyContainerDrop(t),e.reconcileFrameMembership(),e.commitGesture();let s=n.pressOrigin;if(s){let i=e._scene.viewport.zoom||1;if(Math.hypot(t.x-s.x,t.y-s.y)*i<xc){let c=e.hitTest(t);if(c.kind==="element"){let u=e._scene.elements.get(c.id);u&&ct(u)&&u.animationKind&&e.togglePlayback(u.id)}}}e.refreshCursor(t)},CR=(e,t,n)=>{if(t.deltaY===0)return;let a=1-(Math.abs(t.deltaY)>Mv?Mv*Math.sign(t.deltaY):t.deltaY)*NI/100;if(a<=0)return;let r=e._scene.viewport.zoom,s=jp(r*a);if(s===r)return;let i=e.screenToWorld(n);e.zoomAt(s/r,i)},dV=(e,t)=>{let n=t.deltaX,o=t.deltaY;t.shiftKey&&n===0&&(n=o,o=0),e.panBy({x:-n*Cv,y:-o*Cv})},MR=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!oa(c.target)&&e.host.focus({preventScroll:!0});let u=Hc(c,e.host);if(e.additivePressAdded=null,gq(e,c,u)||xq(e,c,u))return;e.startLongPress(u.point);let d=e.screenToWorld(u.point);if(_q(e,d)||bq(e,d)||wq(e,d)||Tq(e,d,c.detail)||Sq(e,d,c.pressure,c.pointerType)||Lq(e,d,u.modifiers.alt,u.modifiers.shift)||kq(e,d)||Eq(e,d)||Cq(e,d)||Iq(e,d)||Mq(e,d)||Rq(e,d)||hq(e,d))return;let f=e.hitTest(d);Dq(e,u,d,f)||(Pq(e,u,f),f=Bq(e,u,f),e.dragElementId=f.kind==="element"?f.id:null,e.containerHover=null,Nq(e,f),zq(e,f),Fq(e,f),e.touchPanCandidate=u.kind==="touch"&&e.activeTool.type==="select"&&f.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:d,target:f,modifiers:u.modifiers}))},n=c=>{let u=Hc(c,e.host);if(Hq(e,c,u)||Uq(e,c,u)||Gq(e,c,u))return;e.longPress.cancelIfMovedBeyond(u.point,xc);let d=e.screenToWorld(u.point);e.lastPointerWorld=d,e.refreshCursor(d),!Aq(e,d)&&(mq(e,d)||Wq(e,d)||qq(e,d)||Vq(e,d)||jq(e,d)||Zq(e,d,c.pressure)||Xq(e,d,u.modifiers.alt)||Yq(e,d)||(Kq(e,d),!$q(e,d)&&Qq(e,d)))},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,Jq(e,c)||eV(e)||(e.cancelLongPress(),vq(e))||yq(e)||tV(e)||nV(e)||oV(e,c)||aV(e)||rV(e)||sV(e)||iV(e)||lV(e))return;let u=Hc(c,e.host),d=e.screenToWorld(u.point);cV(e,u,d)||uV(e,d)},a=c=>{if(e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,e.panGesture?.pointerId===c.pointerId){e.endPanGesture();return}if(e.pinch.isActive()){e.activePointers.size<2&&e.pinch.end();return}if(e.cancelLongPress(),e.linkDragFromAnchor){e.linkDragFromAnchor=null,e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.brushStroke){e.cancelBrushStroke();return}if(e.eraseStroke){e.cancelEraseStroke();return}if(e.laserDrawing){e.endLaserStroke();return}if(e.annotationDrag){let u=e.annotationDrag;e.annotationDrag=null;let d=e._scene.annotations.get(u.id);if(d){let f=new Map(e._scene.annotations);f.set(u.id,{...d,position:u.originPosition}),e._scene={...e._scene,annotations:f},e.notify()}return}e.drawingPreview=null,e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture()};e.host.addEventListener("pointerdown",t),e.host.addEventListener("pointermove",n),e.host.addEventListener("pointerup",o),e.host.addEventListener("pointercancel",a);let r=c=>{e.suppressNextContextMenu&&(e.suppressNextContextMenu=!1,c.preventDefault(),c.stopPropagation())};e.host.addEventListener("contextmenu",r,!0);let s=c=>{c.code!=="Space"&&c.key!==" "||oa(c.target)||e.spaceHeld||(e.spaceHeld=!0,e.refreshCursor(),c.preventDefault())},i=c=>{c.code!=="Space"&&c.key!==" "||e.spaceHeld&&(e.spaceHeld=!1,e.refreshCursor())};typeof window<"u"&&(window.addEventListener("keydown",s),window.addEventListener("keyup",i));let l=c=>{c.preventDefault();let u=e.host.getBoundingClientRect(),d={x:c.clientX-u.left,y:c.clientY-u.top};if(c.ctrlKey||c.metaKey){CR(e,c,d);return}if(c.deltaX!==0){dV(e,c);return}CR(e,c,d)};return e.host.addEventListener("wheel",l,{passive:!1}),()=>{e.host.removeEventListener("pointerdown",t),e.host.removeEventListener("pointermove",n),e.host.removeEventListener("pointerup",o),e.host.removeEventListener("pointercancel",a),e.host.removeEventListener("contextmenu",r,!0),e.host.removeEventListener("wheel",l),typeof window<"u"&&(window.removeEventListener("keydown",s),window.removeEventListener("keyup",i))}};var Qy=class{drawingPreview=null;edgePreview=null;lassoPreview=null;hoveredLinkTarget=null;hoverCursorWorld=null;annotationDrag=null;linkDragFromAnchor=null;pendingLinkDropMenu=null;lassoBaseSelection=null;lassoBaseLinks=null;groupMoveOrigin=null;groupLinkMoveOrigin=null;groupResizeOrigin=null;rotateGestureOrigin=null;resizeOriginElement=null;snapSuppressed=!1;transformAltKey=!1;transformShiftKey=!1;lastClickAt=0;lastClickWorldPoint=null;brushStroke=null;eraseStroke=null;laserStrokes=[];eraserTrail=[];laserDrawing=!1;lastPointerWorld=null;dragElementId=null;additivePressAdded=null;containerHover=null;activePointers=new Map;touchPanCandidate=null;spaceHeld=!1;panGesture=null;suppressNextContextMenu=!1;editingLinkCaption=null;resetPreviews(){this.drawingPreview=null,this.edgePreview=null,this.lassoPreview=null,this.hoveredLinkTarget=null,this.hoverCursorWorld=null}reset(){this.resetPreviews(),this.annotationDrag=null,this.linkDragFromAnchor=null,this.pendingLinkDropMenu=null,this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.groupMoveOrigin=null,this.groupLinkMoveOrigin=null,this.groupResizeOrigin=null,this.rotateGestureOrigin=null,this.resizeOriginElement=null,this.snapSuppressed=!1,this.transformAltKey=!1,this.transformShiftKey=!1,this.lastClickAt=0,this.lastClickWorldPoint=null,this.brushStroke=null,this.eraseStroke=null,this.laserStrokes=[],this.eraserTrail=[],this.laserDrawing=!1,this.lastPointerWorld=null,this.dragElementId=null,this.additivePressAdded=null,this.containerHover=null,this.activePointers.clear(),this.touchPanCandidate=null,this.spaceHeld=!1,this.panGesture=null,this.suppressNextContextMenu=!1,this.editingLinkCaption=null}};var Gc={stroke:o4,fill:null,opacity:a4,width:ay},Jy=e=>({stroke:e.stroke,...e.fill!==null?{fill:e.fill}:{},...e.opacity!==1?{opacity:e.opacity}:{}}),OS=(e,t)=>e<=0?n4:Math.max(.5,e*t),RR=(e,t,n=ay,o=!1)=>{let a=o?ry:t,r={x:0,y:0,width:OS(a,n),pressure:a};return{points:[r],pressures:[a],simulatePressure:o,baseWidth:n,lastRaw:r,lastStoredRaw:{x:0,y:0},origin:e}},fV=e=>{let t=(n,o)=>n===0||n===o-1||n%2===0;e.points=e.points.filter((n,o,a)=>t(o,a.length)),e.pressures=e.pressures.filter((n,o,a)=>t(o,a.length))},OR=(e,t,n,o=1)=>{let a=e.origin,r=t.x-a.x,s=t.y-a.y,i=e.pressures[e.pressures.length-1]??ry,l;if(e.simulatePressure){let h=Math.hypot(r-e.lastRaw.x,s-e.lastRaw.y)*o,m=1-Math.min(1,h/i4);l=i+(m-i)*Pv,l=Math.min(c4,Math.max(l4,l))}else l=i+(n-i)*Pv;let c={x:r,y:s,width:OS(e.simulatePressure?l:n,e.baseWidth),pressure:e.simulatePressure?l:n},u=(r-e.lastStoredRaw.x)*o,d=(s-e.lastStoredRaw.y)*o;if(u*u+d*d<Bv*Bv){e.lastRaw=c;return}let f=e.points[e.points.length-1]??c,p=1-s4;e.points.push({x:f.x+(c.x-f.x)*p,y:f.y+(c.y-f.y)*p,width:OS(l,e.baseWidth)}),e.pressures.push(l),e.lastRaw=c,e.lastStoredRaw={x:r,y:s},e.points.length>u4&&fV(e)},pV=(e,t,n=d4,o=f4)=>{let a=e.length;if(a<3||n<=0)return e.slice();let r=new Array(a);r[0]=0;for(let l=1;l<a;l++){let c=v(e[l-1]),u=v(e[l]);r[l]=v(r[l-1])+Math.hypot(u.x-c.x,u.y-c.y)}let s=v(r[a-1]),i=Math.min(t*n,s/2);return i<=0?e.slice():e.map((l,c)=>{let u=Math.min(v(r[c]),s-v(r[c]));if(u>=i)return l;let d=u/i,f=o+(1-o)*d*(2-d);return{x:l.x,y:l.y,width:l.width*f}})},DS=(e,t)=>{let n=e.points.map((l,c)=>({...l,pressure:e.pressures[c]??ry})),o=n[n.length-1],a=e.lastRaw;o!==void 0&&(Math.abs(o.x-a.x)>.001||Math.abs(o.y-a.y)>.001)&&n.push(a);let r=Py(n,r4,(l,c,u,d)=>({x:u.x,y:u.y,width:l.width+(c.width-l.width)*d,pressure:l.pressure+(c.pressure-l.pressure)*d})),s=r.map(({x:l,y:c,width:u})=>({x:l,y:c,width:u}));return{points:t!==void 0&&DR(s,t)?s:pV(s,e.baseWidth),pressures:r.map(l=>l.pressure)}},DR=(e,t)=>{if(t.fill===void 0||e.length<3)return!1;let n=e[0],o=e[e.length-1];if(!n||!o)return!1;let a=o.x-n.x,r=o.y-n.y;return a*a+r*r<=Nv*Nv},PR=(e,t,n,o,a=Jy(Gc))=>{if(!t||t.points.length===0)return null;let r=Ae([...e.elements.values()].filter(u=>u.layerId===n).map(u=>u.order)),{points:s,pressures:i}=DS(t,a),l={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:r,style:a,points:s,pressures:i,baseWidth:t.baseWidth,...t.simulatePressure?{simulatePressure:!0}:{},...DR(s,a)?{closed:!0}:{}},c=Fe(e,l);return{scene:c.scene,patch:c.patch,elementId:o}},PS=e=>Ze(`brush-${e}-${Date.now().toString(36)}`),BR=(e,t,n)=>{if(!(n>0))return null;let o=e,a=[];for(let s of t){let i=I(o,s);if(!i||!Mn(i))continue;let l=i.baseWidth??i.points.reduce((d,f)=>Math.max(d,f.width),0);if(!(l>0)||l===n)continue;let c=n/l,u=$(o,s,d=>({...d,points:d.points.map(f=>({...f,width:f.width*c})),baseWidth:n}));o=u.scene,a.push(u.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}};var NR=(e,t,n,o)=>{if(n.x===0&&n.y===0)return null;let a=e,r=[],s=0;for(let i of t){let l=I(a,i);if(!l||o(l.layerId))continue;let c=$(a,i,u=>({...u,position:{x:u.position.x+n.x,y:u.position.y+n.y}}));a=c.scene,r.push(c.patch),s++}return s===0?null:{scene:a,patches:r,moved:s}},eg=(e,t,n)=>{if(t.size===0&&n.size===0)return null;let o=e,a=[],r=new Set,s=i=>{if(r.has(i)||!o.links.has(i))return;let l=hi(o,i);o=l.scene,a.push(l.patch),r.add(i)};for(let i of t){for(let c of[...o.links.values()])(c.from.kind!=="point"&&c.from.elementId===i||c.to.kind!=="point"&&c.to.elementId===i)&&s(c.id);let l=dn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},zR=(e,t,n)=>{let o=[...t];if(o.length===0)return null;let a=e,r=[],s=[];for(let i of o){let l=I(a,i);if(!l)continue;let c=Ze(`shape-${n()}-${Date.now().toString(36)}`),u=Ae([...a.elements.values()].filter(p=>p.layerId===l.layerId).map(p=>p.order)),d={...l,id:c,position:{x:l.position.x+10,y:l.position.y+10},order:u},f=Fe(a,d);a=f.scene,r.push(f.patch),s.push(c)}return{scene:a,patches:r,newIds:s}},FR=(e,t,n)=>{let o=Pe;for(let a of t)e.elements.has(a)&&(o=Xt(o,a));return ai(o,n)?null:o},HR=(e,t)=>{let n=Pe;for(let o of e.elements.values()){let a=e.layers.get(o.layerId);!a||!a.visible||a.locked||(n=Xt(n,o.id))}return ai(n,t)?null:n},UR=e=>{let t=new Set;for(let n of e.links.values()){let o=e.layers.get(n.layerId);!o||!o.visible||o.locked||t.add(n.id)}return t},GR=(e,t,n)=>{let o=[];for(let i of t)e.elements.has(i)&&o.push(i);if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=$(a,i,c=>({...c,style:{...c.style,...n}}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},WR=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0||!pe(r))return null;let s=SA(r,n,o,a);if(s===r)return null;let i=$(e,t,()=>s);return{scene:i.scene,patch:i.patch}},qR=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l!==void 0&&pe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=$(a,i,c=>({...c,...n}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},VR=(e,t,n)=>{let o=n==="increase",a=o?Hv:1/Hv,r=e,s=[];for(let l of t){let c=I(r,l);if(c===void 0||!pe(c))continue;let u=Math.round(c.fontSize*a),d=o?Math.max(c.fontSize+1,u):Math.min(c.fontSize-1,u),f=Math.min(F4,Math.max(cy,d));if(f===c.fontSize)continue;let p=$(r,l,h=>({...h,fontSize:f}));r=p.scene,s.push(p.patch)}let i=s[0];return i===void 0?null:{scene:r,patch:s.length===1?i:{kind:"batch",patches:s}}},jR=(e,t)=>{let n=[];return e.x>0?n.push(`${e.x} px right`):e.x<0&&n.push(`${-e.x} px left`),e.y>0?n.push(`${e.y} px down`):e.y<0&&n.push(`${-e.y} px up`),`Moved ${t===1?"shape":`${t} shapes`} ${n.join(" and ")}`},BS=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t},NS=(e,t,n,o,a)=>{let r=n==="left"?{x:-1,y:0}:n==="right"?{x:1,y:0}:n==="up"?{x:0,y:-1}:{x:0,y:1},s=null,i=1/0;for(let l of e.elements.values()){if(l.parentId!==void 0||t.has(l.id)||!a(l))continue;let c=N(l),u=c.x+c.width/2-o.x,d=c.y+c.height/2-o.y,f=u*r.x+d*r.y;if(f<=0)continue;let p=Math.abs(u*r.y-d*r.x);if(p>f)continue;let h=f+p;h<i&&(i=h,s=l.id)}return s};var ZR=(e,t=!1)=>({pending:new Set,last:e,erased:new Map,strokeMode:t}),XR=(e,t,n,o,a=!1,r=!1)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i),c=Math.max(1,Math.ceil(l/p4)),u=!1;for(let d=1;d<=c;d++){let f=d/c,p=n({x:e.x+s*f,y:e.y+i*f});p&&(r&&p.type==="brush"||(a?o.delete(p.id)&&(u=!0):o.has(p.id)||(o.add(p.id),u=!0)))}return u},YR=(e,t)=>{let n=Pe;for(let o of t)e.elements.has(o)&&(n=Xt(n,o));return n.size===0?null:eg(e,n,new Set)};var zS=1e-6,FS=e=>{let t=e.points,n=t.length,o=new Array(Math.max(1,n)).fill(0),a=0;for(let r=1;r<n;r++){let s=v(t[r-1]),i=v(t[r]);a+=Math.hypot(i.x-s.x,i.y-s.y),o[r]=a}return{pts:t,position:e.position,cum:o,total:a}},tg=(e,t)=>{let{pts:n,cum:o,total:a}=e,r=n.length;if(r===0)return{x:0,y:0,width:0};if(r===1||t<=0)return{...v(n[0])};if(t>=a)return{...v(n[r-1])};let s=0,i=r-1;for(;i-s>1;){let f=s+i>>1;v(o[f])<=t?s=f:i=f}let l=v(n[s]),c=v(n[s+1]),u=v(o[s+1])-v(o[s]),d=u>0?(t-v(o[s]))/u:0;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d,width:l.width+(c.width-l.width)*d}},$R=(e,t,n,o)=>{let a=tg(e,t);return Ha.distanceToSegmentSq({x:e.position.x+a.x,y:e.position.y+a.y},n,o)},KR=(e,t,n,o,a,r)=>{let s=t,i=n;for(let l=0;l<g4;l++){let c=(s+i)/2;$R(e,c,o,a)<=r?i=c:s=c}return i},QR=(e,t,n,o)=>{let{pts:a,cum:r,total:s}=e,i=a.length;if(i===0)return[];let l=o*o;if(s===0){let y=v(a[0]);return Ha.distanceToSegmentSq({x:e.position.x+y.x,y:e.position.y+y.y},t,n)<=l?[[0,0]]:[]}let c=Math.min(t.x,n.x)-o,u=Math.max(t.x,n.x)+o,d=Math.min(t.y,n.y)-o,f=Math.max(t.y,n.y)+o,p=e.position.x,h=e.position.y,m=Math.max(y4,o*m4),x=[];for(let y=0;y<i-1;y++){let g=v(a[y]),b=v(a[y+1]);if(Math.max(g.x,b.x)+p<c||Math.min(g.x,b.x)+p>u||Math.max(g.y,b.y)+h<d||Math.min(g.y,b.y)+h>f)continue;let A=v(r[y]),_=v(r[y+1])-A;if(_<=0)continue;let C=Math.max(1,Math.ceil(_/m)),w=-1,L=A;for(let k=0;k<=C;k++){let M=k===C?A+_:A+_*k/C,B=$R(e,M,t,n)<=l;B&&w<0?w=k===0?M:KR(e,L,M,t,n,l):!B&&w>=0&&(x.push([w,KR(e,M,L,t,n,l)]),w=-1),L=M}w>=0&&x.push([w,A+_])}return Zp(x)},Zp=e=>{if(e.length<=1)return e.map(o=>[o[0],o[1]]);let t=[...e].sort((o,a)=>o[0]-a[0]),n=[];for(let[o,a]of t){let r=n[n.length-1];r&&o<=r[1]+zS?a>r[1]&&(r[1]=a):n.push([o,a])}return n},HS=e=>e.reduce((t,[n,o])=>t+(o-n),0),JR=(e,t)=>{let n=Zp(e),o=[],a=0;for(let[r,s]of n)r>a+zS&&o.push([a,r]),s>a&&(a=s);return t>a+zS&&o.push([a,t]),o};var eO=1e-6,tO=(e,t,n)=>{let o=FS(e);if(o.total===0)return[];let a=JR(t,o.total),r=[],s=e.order,i=0;for(let[l,c]of a){if(c-l<x4)continue;let u=[tg(o,l)];for(let m=0;m<o.pts.length;m++){let x=v(o.cum[m]);x>l+eO&&x<c-eO&&u.push({...v(o.pts[m])})}if(u.push(tg(o,c)),u.length<2)continue;let d=v(u[0]),f={x:e.position.x+d.x,y:e.position.y+d.y},p=u.map(m=>({x:m.x-d.x,y:m.y-d.y,width:m.width})),h=i===0?e.order:mc(s,null);s=h,i++,r.push({id:n(),layerId:e.layerId,type:"brush",position:f,rotation:0,scale:{x:1,y:1},order:h,style:e.style,points:p})}return r},nO=(e,t,n,o,a)=>{let r=QR(FS(e),n,o,a);return r.length===0?t.length>0?Zp(t):[]:Zp([...t,...r])};var oO=(e,t,n)=>{let o=e,a=[],r=[],s=[],i=new Set;for(let[l,c]of t){if(c.length===0)continue;let u=e.elements.get(l);if(u===void 0||!Mn(u))continue;let d=tO(u,c,n);for(let p of[...o.links.values()])if(!i.has(p.id)&&(ii(p.from)===u.id||ii(p.to)===u.id)){let h=hi(o,p.id);o=h.scene,a.push(h.patch),i.add(p.id)}let f=dn(o,u.id);o=f.scene,a.push(f.patch),r.push(u.id);for(let p of d){let h=Fe(o,p);o=h.scene,a.push(h.patch),s.push(p.id)}}return a.length===0?null:{scene:o,patches:a,removedIds:r,addedIds:s}},aO=(e,t)=>{let n=[],o=new Set;for(let[a,r]of t){if(r.length===0)continue;let s=e.elements.get(a);if(s===void 0||!Mn(s))continue;let i=0,l=tO(s,r,()=>Ze(`stroke-erase-preview-${s.id}-${i++}`));o.add(s.id),n.push(...l)}return o.size===0?null:{fragments:n,hidden:o}};var rO=e=>{let t=e.metadata,n=t&&"image"in t?t.image:void 0,o=e.animationData,a={...e};if(o!==void 0&&delete a.animationData,t){let s={...t};delete s.image,a.metadata=s}let r=structuredClone(a);return n!==void 0&&(r.metadata={...r.metadata,image:n}),o!==void 0&&(r.animationData=o),r},sO=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(rO(a))}return n},iO=(e,t,n,o,a)=>{if(n.length===0)return{scene:e,newIds:[]};let r=0,s=0;for(let f of n)r+=f.position.x,s+=f.position.y;r/=n.length,s/=n.length;let i=o?{x:o.x-r,y:o.y-s}:{x:10,y:10},l=[],c=[],u=e;for(let f of n){let p=a(),h=Ae([...u.elements.values()].filter(y=>y.layerId===f.layerId).map(y=>y.order)),m={...rO(f),id:p,position:{x:f.position.x+i.x,y:f.position.y+i.y},order:h},x=Fe(u,m);u=x.scene,l.push(x.patch),c.push(p)}let d=l[0];return d!==void 0&&t.push(l.length===1?d:Yo(l)),{scene:u,newIds:c}};var lO=(e,t)=>sO(e,t),cO=(e,t,n,o,a)=>{let r=iO(e,t,n,o,()=>Ze(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},uO=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t};var dO=(e,t,n)=>{let o=Ae([...e.layers.values()].map(s=>s.order)),r=lv(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},fO=(e,t,n)=>{if(!e.layers.has(t))return null;if(e.layers.size<=1)throw new Error("Cannot remove the only remaining layer.");let o=[],a=e;for(let i of[...a.elements.values()]){if(i.layerId!==t)continue;let l=dn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=hi(a,i.id);a=l.scene,o.push(l.patch)}let r=cv(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Uf)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},pO=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=sp(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},hO=(e,t)=>{if(!e.layers.has(t))return null;let n=sp(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},mO=(e,t)=>{if(!e.layers.has(t))return null;let n=sp(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},yO=(e,t,n)=>{if(!e.layers.has(n)||t.size===0)return null;let o=e,a=[];for(let r of t){let s=I(o,r);if(!s||s.layerId===n)continue;let i=$(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},gO=e=>ln(`layer-${e}-${Date.now().toString(36)}`);var xO=(e,t,n,o)=>{let a=new Date().toISOString(),r=Of(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:rc(o("cmt")),authorId:n.id,authorName:n.name,body:t.firstComment.trim(),createdAt:a});let i={id:r,elementId:t.elementId??null,position:t.position,resolved:!1,thread:s,createdAt:a},l=uv(e,i);return{scene:l.scene,patch:l.patch,id:r}},bO=(e,t)=>{if(!e.annotations.has(t))return null;let n=dv(e,t);return{scene:n.scene,patch:n.patch}},AO=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=Va(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},vO=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:rc(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=Va(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},SO=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=Va(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},LO=(e,t)=>{let n=e.viewport.zoom,o=oy/n,a=[...e.annotations.values()];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s===void 0)continue;let i=$r(e,s),l=t.x-i.x,c=t.y-i.y;if(l*l+c*c<=o*o)return s.id}return null};var kO=(e,t)=>{let n=null,o="";for(let a of e.elements.values()){if(!Be(a))continue;let r=a.position.x,s=a.width*a.scale.x,i=24*a.scale.y,l=a.position.y-i;t.x>=r&&t.x<=r+s&&t.y>=l&&t.y<=l+i&&(n===null||a.order>o)&&(n=a.id,o=a.order)}return n},_O=(e,t,n)=>{let o=I(e,t);if(o===void 0||!Be(o))return null;let a=n.trim(),r=o.name??"";if(a===r)return null;let s=$(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var hV={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},mV=(e,t)=>{if(typeof e=="string")return e;let n=e.hotspot?.x??0,o=e.hotspot?.y??0;return`${e.url2x!==void 0?`image-set(url("${e.url}") 1x, url("${e.url2x}") 2x)`:`url("${e.url}")`} ${String(n)} ${String(o)}, ${e.fallback??t}`},yV=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:mV(o,n)},gV=(e,t)=>{if(e.activeTool.type!=="select"||e._selection.size!==1)return!1;let n=[...e._selection][0];if(n===void 0)return!1;let o=I(e._scene,n);if(!o)return!1;let a=e._scene.viewport.zoom||1,{worldPoints:r}=Co(o,wo/a),s=($o+e.anchorStartHitSlop)/a,i=s*s;for(let l of r){let c=l.x-t.x,u=l.y-t.y;if(c*c+u*u<=i)return!0}return!1},wO=(e,t)=>{let n=(a,r)=>yV(e,a,r),o=a=>n(hV[a],Q4(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.isDraggingLabel||e.annotationDrag?.moved===!0)return n("move","grabbing");if(e.brushStroke)return n("draw","crosshair");if(e.gestureTx){let a=e.actor.getSnapshot().context.pressTarget;if(a&&(a.kind==="handle"||a.kind==="group-handle"))return o(a.handle);if(a?.kind==="rotate-handle")return n("rotate","grabbing");if(a&&(a.kind==="element"||a.kind==="link"||a.kind==="edge-endpoint"))return n("move","grabbing")}if(e.isEyedropperArmed)return n("draw","crosshair");if(e.editingTextElement!==null)return n("text","text");if(e.spaceHeld||e.activeTool.type==="hand")return n("pan-ready","grab");switch(e.activeTool.type){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":case"laser":case"crop":return n("draw","crosshair");case"erase":return n("erase","none");case"draw-text":return n("text","text");default:break}if(t){if(gV(e,t))return n("link-start","crosshair");let a=e.hitTest(t);switch(a.kind){case"handle":case"group-handle":return o(a.handle);case"rotate-handle":return n("rotate","grab");case"edge-endpoint":return n("link-handle","grab");case"annotation":return n("annotation","pointer");default:return n("default","default")}}return n("default","default")};var ng=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},EO=(e,t,n)=>{let o=ng(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=Ae([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},CO=(e,t,n)=>{let o=ng(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=hc([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},IO=(e,t,n)=>{let o=ng(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Tt),s=r.find(u=>u.order>a.order)??null;if(!s)return null;let i=r.find(u=>u.order>s.order)??null,l=i?mc(s.order,i.order):Ae(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},MO=(e,t,n)=>{let o=ng(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Uf),s=r.find(u=>u.order<a.order)??null;if(!s)return null;let i=r.find(u=>u.order<s.order)??null,l=i?mc(i.order,s.order):hc(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},TO=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(Tt),o=av(null,null,n.length),a=0;return n.forEach((r,s)=>{let i=o[s];i===void 0||i===r.order||(t(r,i),a++)}),a},RO=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=TO([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=$(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=TO([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=Ye(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var OO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=Math.max(1,n.cols??Math.ceil(Math.sqrt(a.length))),s=n.gap??16,i=Y0(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,cols:r}:null},DO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=K0(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,direction:r}:null},US=(e,t)=>{let n=[],o=new Set;for(let a of t){let r=I(e,a);if(!r)continue;let s=r,i=!1;for(let l=0;s?.parentId&&l<64;l++){if(t.has(s.parentId)){i=!0;break}s=I(e,s.parentId)}i||o.has(r.id)||(o.add(r.id),n.push(r))}return n},PO=(e,t)=>{let n=new Set,o=a=>{if(!(n.has(a)||!I(e,a))){n.add(a);for(let s of e.elements.values())s.parentId===a&&o(s.id)}};for(let a of t)o(a);return n},BO=(e,t,n)=>{let o=US(e,t),a=o[0];if(o.length<2||a===void 0)return null;let r=a.layerId,s=Ae([...e.elements.values()].filter(d=>d.layerId===r).map(d=>d.order)),i={id:n,layerId:r,type:"group",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:s,style:{}},l=e,c=[],u=Fe(l,i);l=u.scene,c.push(u.patch);for(let d of o){let f=$(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},NO=(e,t)=>{let n=[...t].map(s=>I(e,s)).filter(s=>s!==void 0&&ze(s));if(n.length===0)return null;let o=e,a=[],r=new Set;for(let s of n){let i=[...o.elements.values()].filter(c=>c.parentId===s.id);for(let c of i){let u=$(o,c.id,d=>{let f={...d};return delete f.parentId,f});o=u.scene,a.push(u.patch),r.add(c.id)}let l=dn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},zO=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(Tt),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(Tt);for(let u of c)a.push(u.id)}if(a.length===0)return null;let r=t?a.indexOf(t):-1;n==="next"?r=r===-1?0:(r+1)%a.length:r=r===-1?a.length-1:(r-1+a.length)%a.length;let s=a[r];if(!s)return null;let i=I(e,s);return{id:s,name:i?pv(i):s}},FO=e=>Ze(`group-${e}-${Date.now().toString(36)}`);var HO=/^(https?:|mailto:)/i,xV=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,UO=e=>{let t=e.trim();return t===""?null:HO.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:xV.test(t)?`mailto:${t}`:`https://${t}`},og=e=>e&&HO.test(e.trim())?e.trim():null,GO=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l&&(l.href??null)!==n&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=$(a,i,c=>{let u={...c};return n===null?delete u.href:u.href=n,u});a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},bV=(e,t,n)=>{if(t.kind==="anchor"){let o=t.metadata?.ref;if(o)return{kind:"anchor",elementId:e,anchor:o}}return t.kind==="outline"&&typeof t.metadata?.ratio=="number"?{kind:"outline",elementId:e,ratio:t.metadata.ratio}:{kind:"point",position:t.snapped}},WO=(e,t,n,o,a)=>{let r=t.snap({scene:e,probe:a,threshold:n,gesture:"draw-edge"}),s=u=>{if(o!==null){let d=r.all.find(f=>f.kind===u&&f.metadata?.elementId===o);if(d)return d}return r.all.find(d=>d.kind===u)},i=(u,d)=>{if(!u)return null;let f=u.metadata?.elementId;if(f===void 0)return null;let p=I(e,f);if(!p)return null;let h=bV(f,u,p);return h.kind===d?h:null},l=i(s("anchor"),"anchor");if(l)return l;let c=i(s("outline"),"outline");return c||(o!==null&&I(e,o)?{kind:"floating",elementId:o}:{kind:"point",position:a})};var AV=os.rectangle,vV=os.ellipse,GS=(e,t,n,o,a,r)=>{let s=Array.from(e.elements.values()).filter(c=>c.layerId===a).map(c=>c.order),i=t==="frame"?hc(s):Ae(s),l={id:o,layerId:a,position:{x:n.x,y:n.y},rotation:0,scale:{x:1,y:1},order:i,width:n.width,height:n.height};return t==="rect"?{...l,type:"rectangle",style:{...AV}}:t==="ellipse"?{...l,type:"ellipse",style:{...vV}}:{...l,type:"frame",style:{fill:kI},name:r()}},qO=(e,t,n,o,a)=>{let r=Ae(Array.from(e.links.values()).filter(s=>s.layerId===a).map(s=>s.order));return{id:o,layerId:a,from:t,to:n,order:r,routing:mi,style:{...Bc},arrowheads:{to:dp}}},VO=(e,t,n,o)=>{let a=qO(e,{kind:"point",position:t.from},{kind:"point",position:t.to},n,o);return t.points&&t.points.length>2?{...a,routedPoints:t.points.slice(1,-1)}:a},jO=(e,t,n,o,a,r)=>{let s=GS(e,t,n,o,a,r),i=Fe(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Xp=(e,t,n,o,a)=>{let r=qO(e,t,n,o,a),s=pi(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},Wc=e=>`shape-${e}-${Date.now().toString(36)}`,Yp=e=>`edge-${e}-${Date.now().toString(36)}`;var ZO=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(c=>c.layerId===o).map(c=>c.order)),s=t==="draw-ellipse"?"ellipse":"rectangle",i=120,l=80;return{id:a,layerId:o,type:s,position:{x:n.x-i/2,y:n.y-l/2},rotation:0,scale:{x:1,y:1},order:r,style:{fill:"#bbb",stroke:"#000",strokeWidth:1},width:i,height:l}},XO=(e,t,n,o)=>{let a=Ae([...e.elements.values()].filter(r=>r.layerId===n).map(r=>r.order));return{id:o,layerId:n,type:"text",position:{x:t.x,y:t.y},rotation:0,scale:{x:1,y:1},order:a,text:"",fontFamily:C4,fontSize:E4,style:{fill:I4,textAlign:"left",textBaseline:"top"}}},qS=e=>Ze(`shape-${e}-${Date.now().toString(36)}`),YO=(e,t,n)=>{let o={...t.current,position:{x:n.x-t.halfWidth,y:n.y-t.halfHeight}},a={kind:"element",id:t.current.id,before:t.current,after:o};return{scene:J(e,a),patch:a,next:o}},KO=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=qf(e,n,new Set([t.current.id]));if(!o)return null;let a={...t.current,parentId:o.id},r={kind:"element",id:t.current.id,before:t.current,after:a};return{scene:J(e,r),patch:r,next:a}},$O=e=>{let t=N(e);return{scene:n=>{let o=Fe(n,e);return{scene:o.scene,patch:o.patch}},state:{current:e,halfWidth:t.width/2,halfHeight:t.height/2}}},QO=(e,t)=>({scene:dn(e,t).scene}),WS="__ghost-preview__",qc="__ghost-preview-link__",JO=(e,t,n,o)=>{let a=I(e,n);if(!a||Mn(a))return null;let r={kind:"named",name:o},s=Xo(a,r),i=N(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+Sv,u={x:s.x*c,y:s.y*c},d={x:i.x+u.x,y:i.y+u.y,width:i.width,height:i.height},f=Yt(a,r),p=d.x+d.width/2,h=d.y+d.height/2,m={x:p-s.x*(l/2),y:h-s.y*(l/2)},x={...a,id:WS,position:{x:a.position.x+u.x,y:a.position.y+u.y}};pe(x)?x={...x,text:""}:Be(x)&&(x={...x,name:""});let y={x:i.x+i.width/2,y:i.y+i.height/2},g=Fe(e,x).scene,b=v(I(g,WS)),{ref:A}=Wa(b,y,ko(b)),C=Xp(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:WS,anchor:A},qc,t).scene,w=v(ue(C,qc));if((w.routing??"straight")==="orthogonal"){let L=up(C,w);C=Ye(C,qc,k=>({...k,routedPoints:L})).scene}return C={...C,links:new Map([[qc,v(ue(C,qc))]])},{bounds:d,path:[f,m],element:x,ghostScene:C,ghostLinkId:qc}},eD=(e,t,n,o,a,r)=>{let s=I(e,n);if(!s||Mn(s))return null;let i={kind:"named",name:o},l=Xo(s,i),c=N(s),u={x:c.x+c.width/2,y:c.y+c.height/2},f=Math.abs(l.x)*c.width+Math.abs(l.y)*c.height+Sv,p={x:l.x*f,y:l.y*f},h=Ae([...e.elements.values()].filter(A=>A.layerId===s.layerId).map(A=>A.order)),m={...s,id:a,position:{x:s.position.x+p.x,y:s.position.y+p.y},order:h};pe(m)?m={...m,text:""}:Be(m)&&(m={...m,name:""});let x=Fe(e,m),y=v(I(x.scene,a)),{ref:g}=Wa(y,u,ko(y)),b=Xp(x.scene,{kind:"anchor",elementId:n,anchor:i},{kind:"anchor",elementId:a,anchor:g},r,t);return{scene:b.scene,addPatch:x.patch,linkPatch:b.patch}},tD=(e,t,n)=>{let o=e,a=[];for(let r of t){let s=I(o,r);if(!s)continue;let i=n.get(r);if(i===void 0)continue;let l=Ae([...o.elements.values()].filter(d=>d.layerId===s.layerId).map(d=>d.order)),c={...s,id:i,order:l};if(c.parentId!==void 0){let d=n.get(c.parentId);d!==void 0&&(c.parentId=d)}if(c.frameId!==void 0){let d=n.get(c.frameId);d!==void 0&&(c.frameId=d)}let u=Fe(o,c);o=u.scene,a.push(u.patch)}return{scene:o,patches:a}},nD=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(d=>d.layerId===t).map(d=>d.order)),s=a({id:o,layerId:t,position:n.world,order:r}),i=N(s),l={...s,position:{x:s.position.x+(n.world.x-(i.x+i.width/2)),y:s.position.y+(n.world.y-(i.y+i.height/2))}},c=Fe(e,l),u=Ye(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var VS=(e,t,n="fill")=>{let o=ui(e,t);if(o===void 0)return null;let{fill:a,stroke:r}=o.style;return(n==="fill"?a:r)??(n==="fill"?r:a)??null},SV=new Set(["rectangle","ellipse","polygon"]),LV=(e,t)=>[{x:e/2,y:0},{x:e,y:t/2},{x:e/2,y:t},{x:0,y:t/2}],oD=(e,t,n)=>{let o=e,a=[];for(let s of t){let i=I(o,s);if(i===void 0||!SV.has(i.type)||i.type===n)continue;let l=Re(i),c=l.width,u=l.height,d=$(o,s,f=>{let{width:p,height:h,points:m,...x}=f;return n==="polygon"?{...x,type:"polygon",points:LV(c,u)}:{...x,type:n,width:c,height:u}});o=d.scene,a.push(d.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}},aD=e=>{let t=Math.min(Math.max(e.x,0),1),n=Math.min(Math.max(e.y,0),1),o=Math.min(Math.max(e.width,0),1-t),a=Math.min(Math.max(e.height,0),1-n);return{x:t,y:n,width:o,height:a}},kV=(e,t)=>e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;var ag={x:0,y:0,width:1,height:1},rD=["nw","ne","se","sw","n","e","s","w"],Vc=(e,t,n)=>Math.min(Math.max(e,t),n),rg=(e,t)=>{let n=Re(e),o=t.width||1,a=t.height||1,r=n.width/o,s=n.height/a;return{x:n.x-t.x*r,y:n.y-t.y*s,width:r,height:s}},sD=e=>{let t=Re(e),{x:n,y:o,width:a,height:r}=t,s=(i,l)=>Rn(e,{x:i,y:l});return{nw:s(n,o),n:s(n+a/2,o),ne:s(n+a,o),e:s(n+a,o+r/2),se:s(n+a,o+r),s:s(n+a/2,o+r),sw:s(n,o+r),w:s(n,o+r/2)}},_V=e=>({west:e==="nw"||e==="w"||e==="sw",east:e==="ne"||e==="e"||e==="se",north:e==="nw"||e==="n"||e==="ne",south:e==="sw"||e==="s"||e==="se"}),iD=(e,t,n,o)=>{let a=rg(e,t),r=Re(e),s=ci(e,o),i=r.x,l=r.y,c=r.x+r.width,u=r.y+r.height,{west:d,east:f,north:p,south:h}=_V(n),m=a.x+a.width,x=a.y+a.height;d&&(i=Vc(s.x,a.x,c-mp)),f&&(c=Vc(s.x,i+mp,m)),p&&(l=Vc(s.y,a.y,u-mp)),h&&(u=Vc(s.y,l+mp,x));let y={x:i,y:l,width:c-i,height:u-l};return{crop:aD({x:(y.x-a.x)/a.width,y:(y.y-a.y)/a.height,width:y.width/a.width,height:y.height/a.height}),position:Rn(e,{x:y.x,y:y.y}),width:y.width,height:y.height}},lD=(e,t,n,o)=>{let a=rg(e,t),r=ci(e,n),s=ci(e,o),i=s.x-r.x,l=s.y-r.y;return{crop:{x:Vc(t.x-i/a.width,0,1-t.width),y:Vc(t.y-l/a.height,0,1-t.height),width:t.width,height:t.height}}},wV=(e,t=1e-4)=>Math.abs(e.x)<t&&Math.abs(e.y)<t&&Math.abs(e.width-1)<t&&Math.abs(e.height-1)<t,cD=(e,t,n)=>{let o=I(e,t);if(o?.type!=="image")return null;let a=aD(n.crop),r=wV(a)?void 0:a,s=o.crop;if(kV(r,s)&&o.position.x===n.position.x&&o.position.y===n.position.y&&o.width===n.width&&o.height===n.height)return null;let l=$(e,t,c=>{let{crop:u,...d}=c,f={...d,position:n.position,width:n.width,height:n.height};return r===void 0?f:{...f,crop:r}});return{scene:l.scene,patch:l.patch}},uD=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0)return null;let s=Re(r),i=s.width*r.scale.x,l=s.height*r.scale.y,c=n==="right"?i+To:n==="left"?-(i+To):0,u=n==="down"?l+To:n==="up"?-(l+To):0,d=Ae([...e.elements.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),{parentId:f,frameId:p,...h}=r,m={...h,id:o,position:{x:r.position.x+c,y:r.position.y+u},order:d},x=Fe(e,m),y={id:a,layerId:r.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:o},order:Ae([...x.scene.links.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),routing:mi,style:{...Bc},arrowheads:{to:dp}},g=pi(x.scene,y);return{scene:g.scene,patches:[x.patch,g.patch],newElementId:o,linkId:a}},dD=(e,t,n,o,a,r)=>{let s=I(e,t);if(s===void 0||o<1)return{elements:[],links:[]};let i=Re(s),l=i.width*s.scale.x,c=i.height*s.scale.y,u=n==="left"||n==="right",d=n==="right"?l+To:n==="left"?-(l+To):0,f=n==="down"?c+To:n==="up"?-(c+To):0,p=u?c+To:l+To,h=Ae([...e.elements.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),m=Ae([...e.links.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),{parentId:x,frameId:y,...g}=s,b=[],A=[];for(let _=0;_<o;_++){let C=(_-(o-1)/2)*p,w=d+(u?0:C),L=f+(u?C:0),k=a();b.push({...g,id:k,position:{x:s.position.x+w,y:s.position.y+L},order:h}),A.push({id:r(),layerId:s.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:k},order:m,routing:mi,style:{...Bc},arrowheads:{to:dp}})}return{elements:b,links:A}};var TV="__draw-preview__",fD="__draw-preview-link__",pD=new WeakMap,EV=e=>[e.scene,e.selection,e.selectedLinks,e.selectedLink,e.selectedAnnotation,e.mode,e.activeLayerId,e.cropFrame,e.cropGhost,e.flowchartPreview,e.strokeErasePreview,e.lassoPreview,e.drawingPreview,e.edgePreview,e.linkDragFromAnchor,e.hoveredLinkTarget,e.panGesture,e.pinchActive,e.gestureActive,e.linkEndpointDrag,e.linkSegmentDrag,e.linkWaypointDrag,e.hoverCursorWorld,e.anchorStartHitSlop,e.anchorClickRadius,e.containerHover,e.brushStroke,e.laserStrokes,e.eraserTrail,e.eraserCursor,e.peerCursors,e.peerSelections,e.debugHitZones,e.readOnly,e.groupMoveOrigin,e.editingText],CV=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},hD=e=>{if(e.backgroundTarget){e.gridEnabled?Op(e.scene,e.backgroundTarget):e.backgroundTarget.clear();let u=[];for(let d of e.selection){let f=I(e.scene,d);if(!f)continue;let p=f.style??{};u.push({loops:Gf(e.scene,f),outsetWorld:AA(p)})}u.length>0&&LM(e.backgroundTarget,ao(e.scene.viewport),u,e.scene.viewport.zoom||1)}let t=e.viewportWorld,n=e.dirtyWorld,o=e.dimElements,a=e.hideElements,r=o!==void 0&&o.size>0;if(e.tileComposeFn&&t&&!r)W2(e.animationClock),e.mainTarget.clear(),e.tileComposeFn(e.scene,e.mainTarget,{viewport:t,changedElements:e.tileDirtyElements,zoomBucket:e.scene.viewport.zoom>0?2**Math.round(Math.log2(e.scene.viewport.zoom)):1,...a&&a.size>0?{hideElements:a}:{},...e.sharedIndex?{index:e.sharedIndex}:{}}),Bn(e.scene,e.mainTarget,{viewportWorld:t});else{let u=e.sharedIndex;Xa(e.scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,clock:e.animationClock,lod:y2,...o?{dimElements:o,dimOpacity:e.eraseActive?WI:GI}:{},...a?{hideElements:a}:{},...u?{spatialIndex:u}:{}}),Bn(e.scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}let s=EV(e),i=pD.get(e.overlayTarget);if(i===void 0||!CV(i.sig,s)){let u={};e.readOnly&&(u.readOnly=!0),e.mode!=="select"&&e.mode!=="hand"&&(u.suppressHandles=!0),e.cropFrame&&(u.cropFrame=e.cropFrame),e.cropGhost&&(u.cropGhost=e.cropGhost);let d=null;if(e.lassoPreview)u.drawingPreview=e.lassoPreview;else if(e.drawingPreview){let x=e.mode==="draw-rect"?"rect":e.mode==="draw-ellipse"?"ellipse":null;x?u.drawingPreviewElement=GS(e.scene,x,e.drawingPreview,TV,e.activeLayerId,()=>""):u.drawingPreview=e.drawingPreview}let f=null;if(e.edgePreview){let x=VO(e.scene,e.edgePreview,fD,e.activeLayerId);f={...e.scene,links:new Map([[fD,x]])}}let p=null;if(e.flowchartPreview&&e.flowchartPreview.elements.length>0){u.flowchartPreviewElements=e.flowchartPreview.elements;let x=new Map(e.scene.elements);for(let g of e.flowchartPreview.elements)x.set(g.id,g);let y=new Map;for(let g of e.flowchartPreview.links)y.set(g.id,g);p={...e.scene,elements:x,links:y}}if(e.strokeErasePreview&&e.strokeErasePreview.elements.length>0&&(u.strokeErasePreviewElements=e.strokeErasePreview.elements),e.mode!=="brush"&&e.mode!=="hand"&&!e.readOnly){let x=e.scene.viewport.zoom||1,y=(A,_,C,w)=>{let L=I(e.scene,A);if(!L)return null;let k=_==="link-start"?wo:LI,{names:M,worldPoints:B}=Co(L,k/x),G=[...B],ie=C!==null?M.indexOf(C):-1;_==="link-attach"&&w&&G.push(w);let ne=ie>=0?ie:_==="link-attach"&&w?G.length-1:-1;return{worldPoints:G,...ne>=0?{activeIndex:ne}:{},role:_}},g=[];if(e.linkDragFromAnchor){let A=y(e.linkDragFromAnchor.fromElement,"link-start",null);if(A&&g.push(A),e.hoveredLinkTarget){let _=e.hoveredLinkTarget,C=y(_.elementId,"link-attach",_.activeAnchor,_.outlinePoint);C&&g.push(C)}}else if(e.hoveredLinkTarget){let A=e.hoveredLinkTarget,_=y(A.elementId,"link-attach",A.activeAnchor,A.outlinePoint);_&&g.push(_)}else if(!e.panGesture&&!e.pinchActive&&!e.gestureActive&&!e.edgePreview&&!e.linkEndpointDrag){let A=e.hoverCursorWorld;if(e.selection.size===1&&A){let _=v([...e.selection][0]),C=I(e.scene,_);if(C){let w=N(C),L=(wo+$o+e.anchorStartHitSlop)/x;if(A.x>=w.x-L&&A.x<=w.x+w.width+L&&A.y>=w.y-L&&A.y<=w.y+w.height+L){let M=y(_,"link-start",null);if(M){let V=_I/x,ve=-1,ge=V*V;if(M.worldPoints.forEach((ee,Se)=>{let Oe=ee.x-A.x,qt=ee.y-A.y,xn=Oe*Oe+qt*qt;xn<=ge&&(ge=xn,ve=Se)}),ve>=0){let ee=V>0?Math.max(0,1-Math.sqrt(ge)/V):0,Se=fp+(bI-fp)*ee;g.push({...M,activeIndex:ve,activeRadius:Se})}else g.push(M)}let{names:B,worldPoints:G}=Co(C,wo/x),ie=(e.anchorClickRadius/x)**2,ne=null;for(let V=0;V<G.length;V++){let ve=v(G[V]);if((ve.x-A.x)**2+(ve.y-A.y)**2<=ie){ne=v(B[V]);break}}if(ne){let V=e.previewClickCreate(_,ne);V&&(u.ghostElement=V.bounds,u.ghostElementShape=V.element,d=V.ghostScene)}}}}}g.length===1?u.ports=v(g[0]):g.length>1&&(u.ports=g);let b=e.hoveredLinkTarget;if(b?.mode==="element"){let A=I(e.scene,b.elementId);A&&(u.linkAttachHighlight=N(A))}}if(e.selection.size+e.selectedLinks.size>1||e.aspectLocked){let x=e.combinedSelectionBounds;x&&(u.groupBounds=x),e.aspectLocked&&(u.groupAspectLocked=!0)}if(e.containerHover&&(u.containerDropZone=e.containerHover.dropZone),e.brushStroke&&(u.brushPreview={origin:e.brushStroke.origin,points:e.brushStroke.points,fill:e.brushStroke.fill,opacity:e.brushStroke.opacity}),e.laserStrokes.length>0&&(u.laserStrokes=e.laserStrokes),e.eraserTrail.length>0&&(u.eraserTrail=e.eraserTrail),e.eraserCursor&&(u.eraserCursor=e.eraserCursor),e.selectedLinks.size>0){let x=[];for(let y of e.selectedLinks){let g=ue(e.scene,y);if(!g)continue;let b=_o(e.scene,g);b&&b.length>=2&&x.push({path:b,width:g.style.strokeWidth??1})}x.length>0&&(u.selectedLinkPaths=x)}let h=e.selectedLink;if(h){let x=ue(e.scene,h);if(x){let y=ut(e.scene,x);if(y&&y.length>=2){let g=v(y[0]),b=v(y[y.length-1]);if((x.routing??"straight")==="orthogonal"){let _=e.linkSegmentDrag||e.linkEndpointDrag?[]:tp(e.scene,x,y).map(C=>C.point);u.edgeSelection={from:g,to:b,midpoints:_}}else{let _=[...x.waypoints??[]],C=e.linkWaypointDrag?[]:ep(e.scene,x)??[];u.edgeSelection={from:g,to:b,waypoints:_,midpoints:C}}}}}e.peerCursors.length>0&&(u.peerCursors=e.peerCursors),e.peerSelections.length>0&&(u.peerSelections=e.peerSelections),e.scene.annotations.size>0&&(u.annotations=[...e.scene.annotations.values()],u.selectedAnnotation=e.selectedAnnotation);let m=e.editingText;if(m&&(u.editingText=m),e.debugHitZones){u.debugHitZones=!0;let x=e.linkDragFromAnchor!==null||e.edgePreview!==null||e.linkEndpointDrag!==null,y=e.groupMoveOrigin!==null&&e.gestureActive,g=Ny({linkDragActive:x,elementDragActive:y});if(u.debugHitZoneVisibility=g,g.attachDropZones){let b=e.linkDragFromAnchor?.fromElement,A=[],_=[];for(let C of e.scene.elements.values())if(C.id!==b){A.push(...Co(C,0).worldPoints);for(let w of Gf(e.scene,C))_.push(w)}u.debugAttachZones={anchors:A,outlineLoops:_,thresholdWorld:12}}if(g.containerDropZones){let b=e.groupMoveOrigin,A=[],_=[];for(let C of e.scene.elements.values())if(!b?.has(C.id)){if(Be(C)){A.push(N(C));continue}_.push(...DA(C))}u.debugContainerZones={frames:A,containers:_}}}i={sig:s,opts:u,ghostScene:d,edgePreviewScene:f,flowchartPreviewScene:p},pD.set(e.overlayTarget,i)}let l=i.opts,c=[];for(let u of e.scene.elements.values())ct(u)&&u.animationKind&&e.isPlaybackPaused(u.id)&&c.push(N(u));c.length>0?l.gifBadges=c:l.gifBadges!==void 0&&delete l.gifBadges,kM(e.scene,e.selection,e.overlayTarget,l),i.ghostScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(ny),Bn(i.ghostScene,e.overlayTarget,{}),e.overlayTarget.restore()),i.edgePreviewScene&&Bn(i.edgePreviewScene,e.overlayTarget,{}),i.flowchartPreviewScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(uy),Bn(i.flowchartPreviewScene,e.overlayTarget,{}),e.overlayTarget.restore())};var sg=class{onTick;_on=!0;timer=null;constructor(t){this.onTick=t}get on(){return this._on}start(){this._on=!0,this.stop(),!(typeof window>"u")&&(this.timer=setInterval(()=>{this._on=!this._on,this.onTick()},D4))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var mD=(e,t,n)=>{let o=I(e,t);return!(o===void 0||!pe(o)||n(o.layerId))};var ig=class{host;_editingElement=null;_pendingCreate=null;_origin=null;_sel=null;_dragAnchor=null;caretBlink;constructor(t){this.host=t,this.caretBlink=new sg(()=>{this.host.notify()})}get editingElement(){return this._editingElement}get selection(){return this._sel}get caret(){return this._sel?this._sel.dir==="backward"?this._sel.start:this._sel.end:null}get caretBlinkOn(){return this.caretBlink.on}get isDragging(){return this._dragAnchor!==null}markPendingCreate(t){this._pendingCreate=t}begin(t){if(!mD(this.host.scene,t,a=>this.host.isLayerLocked(a)))return;this._editingElement!==null&&this._editingElement!==t&&this.commit(),this._editingElement=t,this._origin=this._pendingCreate===t?null:I(this.host.scene,t)??null;let n=I(this.host.scene,t),o=n!==void 0&&pe(n)?n.text.length:0;this._sel={start:o,end:o,dir:"forward"},this.caretBlink.start(),this.host.notify()}setText(t,n,o,a="forward"){let r=this._editingElement;if(!r)return;let s=$(this.host.scene,r,i=>({...i,text:t}));this.host.scene=s.scene,this._sel={start:n,end:o,dir:a},this.caretBlink.wake(),this.host.notify()}setSelection(t,n,o="forward"){this._editingElement&&(this._sel={start:t,end:n,dir:o},this.caretBlink.wake(),this.host.notify())}caretIndexAtWorldPoint(t){let n=this._editingElement;if(!n)return null;let o=I(this.host.scene,n);if(o===void 0||!pe(o))return null;let a=this.editingTextLayout(o);if(!a)return null;let r=o.scale.x||1,s=o.scale.y||1,i={x:(t.x-o.position.x)/r,y:(t.y-o.position.y)/s},l=o.style.textAlign??"left";return z2(a,i,this.measureFor(o),l)}editedElementContainsPoint(t){let n=this._editingElement;if(!n)return!1;let o=I(this.host.scene,n);if(!o)return!1;let a=N(o);return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height}setCaretFromPoint(t){let n=this.caretIndexAtWorldPoint(t);n!==null&&(this._dragAnchor=n,this.setSelection(n,n,"forward"))}extendSelectionToPoint(t){if(this._dragAnchor===null)return;let n=this.caretIndexAtWorldPoint(t);if(n===null)return;let o=this._dragAnchor;n>=o?this.setSelection(o,n,"forward"):this.setSelection(n,o,"backward")}endDragSelect(){this._dragAnchor=null}editingTextLayout(t){return zc(t.text,this.measureFor(t),{fontSize:t.fontSize,...t.maxWidth!==void 0?{maxWidth:t.maxWidth}:{}})}measureFor(t){let n=this.host.mainTarget;return n.setFont(t.fontFamily,t.fontSize,{...t.style.fontWeight==="bold"?{weight:"bold"}:{},...t.style.fontStyle==="italic"?{style:"italic"}:{}}),o=>n.measureText(o).width}overlay(){let t=this._editingElement;if(!t||!this._sel)return null;let n=I(this.host.scene,t);if(n===void 0||!pe(n))return null;let o=this.editingTextLayout(n);if(!o)return null;let a=n.style.textAlign??"left",r=this.measureFor(n),{x:s,y:i}=n.position,l=n.scale.x,c=n.scale.y,d=F2(o,this._sel.start,this._sel.end,r,a).map(p=>({x:s+Math.min(p.x*l,(p.x+p.width)*l),y:i+Math.min(p.y*c,(p.y+p.height)*c),width:Math.abs(p.width*l),height:Math.abs(p.height*c)})),f=null;if(this.caretBlink.on){let p=this._sel.dir==="backward"?this._sel.start:this._sel.end,h=N2(o,p,r,n.fontSize,a);f={x:s+h.x*l,y:i+h.y*c,height:h.height*Math.abs(c)}}return{caret:f,caretColor:n.style.fill??"#1a1a1a",selectionRects:d}}commit(t){let n=this._editingElement;if(!n)return;let o=this._pendingCreate===n,a=this._origin;t!==void 0&&(this.host.scene=$(this.host.scene,n,l=>({...l,text:t})).scene),this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop();let r=I(this.host.scene,n),s=r!==void 0&&pe(r)?r:void 0;if((s?.text??"").trim()===""){s&&(this.host.scene=dn(this.host.scene,n).scene,!o&&a&&this.host.pushHistory({kind:"element",id:n,before:a,after:null}),this.host.clearSelectionFor(n)),this.host.notify();return}if(o)s&&this.host.pushHistory({kind:"element",id:n,before:null,after:s});else if(a&&s){let l=pe(a)?a.text:"";if(l!==s.text){let c={...s,text:l};this.host.pushHistory({kind:"element",id:n,before:c,after:s})}}this.host.notify()}cancel(){let t=this._editingElement;if(t===null)return;let n=this._pendingCreate===t,o=this._origin;if(this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop(),n)I(this.host.scene,t)&&(this.host.scene=dn(this.host.scene,t).scene,this.host.clearSelectionFor(t));else if(o){let a=pe(o)?o.text:"";this.host.scene=$(this.host.scene,t,r=>({...r,text:a})).scene}this.host.notify()}};var yD=(e,t,n,o)=>{let a=n;if(t){let i=I(e,t);i&&(a=Wa(i,n,ko(i)).world)}let r=o,s=ui(e,o);return s&&(r=Wa(s,o,ko(s)).world),{from:a,to:r}},gD=(e,t,n)=>{let o=ue(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=Ye(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},xD=(e,t)=>{let n=a=>{if(a.kind==="point")return`p:${a.position.x},${a.position.y}`;let r=I(e,a.elementId),s=r?N(r):null,i=a.kind==="anchor"?JSON.stringify(a.anchor):a.kind==="outline"?`o:${a.ratio}`:"f";return`${a.kind}:${a.elementId}:${i}:${s?`${s.x},${s.y},${s.width},${s.height}`:"x"}`},o=`${n(t.from)}|${n(t.to)}|${JSON.stringify(t.fixedSegments??null)}`;if(t.avoidObstacles===!0){let a="|avoid:";for(let r of e.elements.values()){let s=N(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var lg=class{host;_endpointDrag=null;_waypointDrag=null;_segmentDrag=null;_labelDrag=null;lastHandleClickAt=0;lastHandleClickWorld=null;constructor(t){this.host=t}get endpointDrag(){return this._endpointDrag}get waypointDrag(){return this._waypointDrag}get segmentDrag(){return this._segmentDrag}get labelDrag(){return this._labelDrag}get isDraggingLabel(){return this._labelDrag!==null}reset(){this._waypointDrag=null,this._segmentDrag=null,this._endpointDrag=null,this._labelDrag=null}applyEndpointMove(t,n,o){if(!ue(this.host.scene,t))return;this.lastHandleClickAt=0;let r=this.host.linkAttachTargetAt(o),s=r?.kind==="element"?r.id:null,i=this.host.snapLinkEndpoint(s,o),l=Ye(this.host.scene,t,c=>n==="from"?{...c,from:i}:{...c,to:i});this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this._endpointDrag={linkId:t,side:n,toPoint:o},this.host.updateHoveredLinkTarget(o),this.host.notify()}applyEndpointUpdate(t){let n=this.host.hasGestureTx(),o=gD(this.host.scene,t,(a,r)=>this.host.snapLinkEndpoint(a,r));if(o===null){this.host.cancelGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}if(!n&&Kr(o.patch)){this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}this.host.scene=o.scene,this.host.recordGesturePatch(o.patch),this.host.commitGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget()}get isDraggingWaypoint(){return this._waypointDrag!==null}beginWaypointDrag(t,n,o){ue(this.host.scene,t)&&(this._waypointDrag={linkId:t,index:n,pendingInsert:o})}updateWaypointDrag(t){let n=this._waypointDrag;if(!n)return;this.lastHandleClickAt=0;let o=ue(this.host.scene,n.linkId);if(!o)return;let a=[...o.waypoints??[]];if(n.pendingInsert)a.splice(n.index,0,t),n.pendingInsert=!1;else{if(n.index<0||n.index>=a.length)return;a[n.index]=t}let r=Ye(this.host.scene,n.linkId,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.recordGesturePatch(r.patch),this.host.notify()}endWaypointDrag(){let t=this._waypointDrag;if(this._waypointDrag=null,!t)return;if(t.pendingInsert){this.host.commitGesture();return}let n=ue(this.host.scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=ut(this.host.scene,n),a=v(n.waypoints[t.index]),r=yI/(this.host.scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&Ha.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=Ye(this.host.scene,t.linkId,u=>({...u,waypoints:l}));this.host.scene=c.scene,this.host.recordGesturePatch(c.patch)}}this.host.commitGesture()}get isDraggingSegment(){return this._segmentDrag!==null}beginSegmentDrag(t,n,o){ue(this.host.scene,t)&&(this._segmentDrag={linkId:t,axis:n,at:o})}updateSegmentDrag(t){let n=this._segmentDrag;if(!n)return;this.lastHandleClickAt=0;let o=ue(this.host.scene,n.linkId);if(!o)return;let a=n.axis==="h"?t.y:t.x,r=[...o.fixedSegments??[]],s={axis:n.axis,pos:a,at:n.at},i=r.findIndex(c=>c.axis===n.axis&&Math.abs(c.at-n.at)<.5);i>=0?r[i]=s:r.push(s);let l=Ye(this.host.scene,n.linkId,c=>({...c,fixedSegments:r}));this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this.host.notify()}endSegmentDrag(){this._segmentDrag&&(this._segmentDrag=null,this.host.commitGesture())}beginLabelDrag(t){ue(this.host.scene,t)?.label&&(this._labelDrag={linkId:t,moved:!1})}updateLabelDrag(t){let n=this._labelDrag;if(!n)return;n.moved=!0,this.lastHandleClickAt=0;let o=ue(this.host.scene,n.linkId);if(!o?.label)return;let a=_o(this.host.scene,o);if(!a||a.length<2)return;let r=0;for(let u=1;u<a.length;u++){let d=a[u-1],f=a[u];d&&f&&(r+=Math.hypot(f.x-d.x,f.y-d.y))}let s=UA(a,t),i=this.host.scene.viewport.zoom||1,l=r>0&&Math.abs(s-.5)*r<$4/i,c=Ye(this.host.scene,n.linkId,u=>{if(!u.label)return u;if(l){let{position:d,...f}=u.label;return{...u,label:f}}return{...u,label:{...u.label,position:s}}});this.host.scene=c.scene,this.host.recordGesturePatch(c.patch),this.host.notify()}endLabelDrag(){this._labelDrag&&(this._labelDrag=null,this.host.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<bc&&this.lastHandleClickWorld!==null&&W.distance(this.lastHandleClickWorld,t)<=Ac;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=ue(this.host.scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=Ye(this.host.scene,t,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.pushHistory(r.patch),this.host.notify()}resetSegmentPin(t,n,o,a){let r=ue(this.host.scene,t);if(!r?.fixedSegments||r.fixedSegments.length===0)return;let s=-1,i=1/0;for(let u=0;u<r.fixedSegments.length;u++){let d=v(r.fixedSegments[u]);if(d.axis!==n)continue;let f=Math.abs(d.pos-o)+Math.abs(d.at-a)*.001;f<i&&(i=f,s=u)}if(s<0)return;let l=r.fixedSegments.filter((u,d)=>d!==s),c=Ye(this.host.scene,t,u=>({...u,fixedSegments:l}));this.host.scene=c.scene,this.host.pushHistory(c.patch),this.host.notify()}};var bD=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=qa(t),r=[z.applyToPoint(a,{x:0,y:0}),z.applyToPoint(a,{x:n,y:0}),z.applyToPoint(a,{x:0,y:o}),z.applyToPoint(a,{x:n,y:o})],s=j.fromPoints(r);return j.expand(s,Math.max(s.width,s.height)*.05)},cg=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?cg(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},AD=(e,t)=>{let n=null;for(let o of t){let a=I(e,o);if(!a)continue;let r=ze(a)?cg(e,a.id):N(a);r&&(n=n?j.union(n,r):r)}return n};var vD=e=>{let t=null;for(let n of e.elements.values())cc(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var SD=(e,t,n,o,a)=>{let r=F0(e,o,Ov),s=a==="replace"?Pe:t;for(let i of r)n(i.layerId)||(s=Xt(s,i.id));return s},LD=(e,t,n,o,a)=>{let r=a==="replace"?Pe:t,s=F0(e,o,Ov);for(let i of s)n(i.layerId)||(r=Xt(r,i.id));return r},IV=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,ZS=(e,t,n,o,a)=>{let r=a==="replace"?gt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=ut(e,s);!i||i.length<2||i.every(l=>IV(l,o))&&(r=IS(r,s.id))}return r};var XS=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},kD=(e,t,n,o)=>{let a=I(e,t);if(!a)return null;let r=N(a),s=o.x-r.x,i=o.y-r.y,l={...a,position:{x:a.position.x+n.x+s,y:a.position.y+n.y+i}};return{kind:"element",id:t,before:a,after:l}},_D=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=I(e,a);if(!s)continue;let i={...s,position:{x:r.x+n.x,y:r.y+n.y}};i.position.x===s.position.x&&i.position.y===s.position.y||o.push({kind:"element",id:a,before:s,after:i})}return o},wD=(e,t,n,o)=>{let a=e.annotations.get(t);if(!a)return null;let r={x:o.x+n.x,y:o.y+n.y},s=r;if(a.elementId){let l=I(e,a.elementId);l&&(s={x:r.x-l.position.x,y:r.y-l.position.y})}if(s.x===a.position.x&&s.y===a.position.y)return null;let i=Va(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var YS=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n},KS=e=>e.map(t=>N(t)).reduce((t,n)=>j.union(t,n)),TD=(e,t,n)=>{let o=YS(e,t);if(o.length===0)return[];let a=KS(o),r=a.x+a.width/2,s=a.y+a.height/2,i=n==="horizontal",l=[];for(let c of o){let u=i?{...c,position:{x:2*r-c.position.x,y:c.position.y},scale:{x:-c.scale.x,y:c.scale.y}}:{...c,position:{x:c.position.x,y:2*s-c.position.y},scale:{x:c.scale.x,y:-c.scale.y}};l.push({kind:"element",id:c.id,before:c,after:u})}return l},ED=(e,t,n)=>{let o=YS(e,t);if(o.length<2)return[];let a=KS(o),r=[];for(let s of o){let i=N(s),l=0,c=0;switch(n){case"left":l=a.x-i.x;break;case"right":l=a.x+a.width-(i.x+i.width);break;case"h-center":l=a.x+a.width/2-(i.x+i.width/2);break;case"top":c=a.y-i.y;break;case"bottom":c=a.y+a.height-(i.y+i.height);break;case"v-center":c=a.y+a.height/2-(i.y+i.height/2);break}if(l===0&&c===0)continue;let u={...s,position:{x:s.position.x+l,y:s.position.y+c}};r.push({kind:"element",id:s.id,before:s,after:u})}return r},CD=(e,t,n)=>{let o=YS(e,t);if(o.length<3)return[];let a=n==="horizontal",r=m=>a?m.x:m.y,s=m=>a?m.width:m.height,i=o.map(m=>({el:m,b:N(m)})).sort((m,x)=>r(m.b)-r(x.b)),l=i[0],c=i[i.length-1];if(!l||!c)return[];let u=r(c.b)+s(c.b)-r(l.b),d=i.reduce((m,x)=>m+s(x.b),0),f=(u-d)/(i.length-1),p=[],h=r(l.b)+s(l.b)+f;for(let m=1;m<i.length-1;m++){let x=i[m];if(!x)continue;let y=h-r(x.b);if(y!==0){let g=a?{...x.el,position:{x:x.el.position.x+y,y:x.el.position.y}}:{...x.el,position:{x:x.el.position.x,y:x.el.position.y+y}};p.push({kind:"element",id:x.el.id,before:x.el,after:g})}h+=s(x.b)+f}return p},$S=(e,t,n,o)=>{let a=Math.cos(o),r=Math.sin(o),s=[];for(let[i,l]of t){let c=I(e,i);if(!c)continue;let u=l.position.x-n.x,d=l.position.y-n.y,f={...c,position:{x:n.x+(u*a-d*r),y:n.y+(u*r+d*a)},rotation:l.rotation+o};s.push({kind:"element",id:i,before:c,after:f})}return s},ID=e=>{let t=KS(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var ug=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),OD=(e,t,n)=>{let o=ug({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},DD=(e,t,n)=>{let o=1/0,a=1/0;for(let s of e.values())s.x<o&&(o=s.x),s.y<a&&(a=s.y);if(!Number.isFinite(o))return t;let r=ug({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},MD=new Set(["nw","w","sw"]),MV=new Set(["ne","e","se"]),RD=new Set(["nw","n","ne"]),RV=new Set(["sw","s","se"]),QS=(e,t,n,o)=>{let a=n.x,r=n.y;if(MD.has(t)||MV.has(t)){let s=MD.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(RD.has(t)||RV.has(t)){let s=RD.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},PD=(e,t)=>{let n=ug({x:e.x,y:e.y},t),o=ug({x:e.x+e.width,y:e.y+e.height},t);return{x:n.x,y:n.y,width:Math.max(0,o.x-n.x),height:Math.max(0,o.y-n.y)}};var OV=new Set(["MOVE_SHAPE","RESIZE_GROUP","RESIZE_SHAPE","ROTATE","CREATE_SHAPE","CREATE_EDGE","MOVE_ANNOTATION","COMMIT_ANNOTATION_DRAG","UPDATE_EDGE_ENDPOINT","UPDATE_EDGE_ENDPOINT_PREVIEW","DRAW_EDGE_PREVIEW"]),DV=Object.freeze(new Set),Oi=()=>typeof performance<"u"?performance.now():Date.now(),Kp=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;_readOnly=!1;actor;listeners=new Set;events=mS();eventCache=V9();unbind;_scene;_selection=Pe;interaction=new Qy;get annotationDrag(){return this.interaction.annotationDrag}set annotationDrag(t){this.interaction.annotationDrag=t}get drawingPreview(){return this.interaction.drawingPreview}set drawingPreview(t){this.interaction.drawingPreview=t}get edgePreview(){return this.interaction.edgePreview}set edgePreview(t){this.interaction.edgePreview=t}get linkDragFromAnchor(){return this.interaction.linkDragFromAnchor}set linkDragFromAnchor(t){this.interaction.linkDragFromAnchor=t}get hoveredLinkTarget(){return this.interaction.hoveredLinkTarget}set hoveredLinkTarget(t){this.interaction.hoveredLinkTarget=t}get hoverCursorWorld(){return this.interaction.hoverCursorWorld}set hoverCursorWorld(t){this.interaction.hoverCursorWorld=t}_selectedLinks=gt;_selectedAnnotation=null;commentAuthor={id:"local",name:"You"};get linkEndpointDrag(){return this.linkHandles.endpointDrag}get linkWaypointDrag(){return this.linkHandles.waypointDrag}get linkSegmentDrag(){return this.linkHandles.segmentDrag}get lassoPreview(){return this.interaction.lassoPreview}set lassoPreview(t){this.interaction.lassoPreview=t}get groupMoveOrigin(){return this.interaction.groupMoveOrigin}set groupMoveOrigin(t){this.interaction.groupMoveOrigin=t}get groupLinkMoveOrigin(){return this.interaction.groupLinkMoveOrigin}set groupLinkMoveOrigin(t){this.interaction.groupLinkMoveOrigin=t}get groupResizeOrigin(){return this.interaction.groupResizeOrigin}set groupResizeOrigin(t){this.interaction.groupResizeOrigin=t}get rotateGestureOrigin(){return this.interaction.rotateGestureOrigin}set rotateGestureOrigin(t){this.interaction.rotateGestureOrigin=t}_activeLayerId=ln(On);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new ap([XA,YA,KA]);snapThreshold=12;styleClipboard=null;boundsCache=new ts;spatialIndexCache=null;_enteredGroup=null;get brushStroke(){return this.interaction.brushStroke}set brushStroke(t){this.interaction.brushStroke=t}get brushPreviewStroke(){let t=this.interaction.brushStroke;if(!t)return null;let n=Jy(this._brushSettings);return{origin:t.origin,points:DS(t,n).points,fill:Hf(n),opacity:n.opacity??1}}get eraseStroke(){return this.interaction.eraseStroke}set eraseStroke(t){this.interaction.eraseStroke=t}get pendingErase(){return this.interaction.eraseStroke?.pending??DV}get laserStrokes(){return this.interaction.laserStrokes}get lastPointerWorld(){return this.interaction.lastPointerWorld}set lastPointerWorld(t){this.interaction.lastPointerWorld=t}cursorOverrides=new Map;lastRenderedScene=null;lastRenderedEnteredGroup=null;lastRenderedEraseActive=!1;eraseDirty=!1;autoCompactScheduler=new Gy({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new Wy({getScene:()=>this._scene,applyPatch:t=>{this._scene=J(this._scene,t),this.gestureTx?this.gestureTx.add(t):this._history.push(t)},growContainer:(t,n)=>{this.maybeGrowContainer(t,n)},onMutated:()=>{this.scheduleRender();for(let t of this.listeners)t()}});get dragElementId(){return this.interaction.dragElementId}set dragElementId(t){this.interaction.dragElementId=t}get additivePressAdded(){return this.interaction.additivePressAdded}set additivePressAdded(t){this.interaction.additivePressAdded=t}get containerHover(){return this.interaction.containerHover}set containerHover(t){this.interaction.containerHover=t}_peerCursors=[];_peerSelections=[];cursorListeners=new Set;get activePointers(){return this.interaction.activePointers}get touchPanCandidate(){return this.interaction.touchPanCandidate}set touchPanCandidate(t){this.interaction.touchPanCandidate=t}pinch;containerOpsRef;get spaceHeld(){return this.interaction.spaceHeld}set spaceHeld(t){this.interaction.spaceHeld=t}tileComposeFn;tileDirtyElements=new Map;_toolLocked=!1;_lastActiveTool=null;_activeToolCache={type:I0,locked:!1,lastActiveTool:null};fileDropRegistry=new Up;get panGesture(){return this.interaction.panGesture}set panGesture(t){this.interaction.panGesture=t}get suppressNextContextMenu(){return this.interaction.suppressNextContextMenu}set suppressNextContextMenu(t){this.interaction.suppressNextContextMenu=t}longPress;longPressListeners=new Set;announceListeners=new Set;inputMode;handleHitSlop;edgeHandleHitSlop;edgeHitThreshold;anchorStartHitSlop;anchorClickRadius;_history;gestureTx=null;gestureStartScene=null;gestures;textEdit;linkHandles;constructor(t){this.host=t.host,this.mainTarget=t.mainTarget,this.overlayTarget=t.overlayTarget,this.backgroundTarget=t.backgroundTarget??null,this.onAfterRender=t.onAfterRender??null,this._scene=t.initialScene,this._history=PV(t.history)?t.history:new Hp(t.history??{}),this.tileComposeFn=t.useTileCache===!0&&t.tileCompose?t.tileCompose:null,this.initControllers(),this.initGlobalHooks(t),this.initInputMode(t),this.initActor(t),this.unbind=this.bindPointerEvents(),this.animation.attach(),LS(this),kS(this),this.maybeAnimate(),this.animationContentOff=U2(()=>{this.scheduleRender()}),this.forceRender(),Z9(this.eventCache,this.observableSnapshot())}initControllers(){let t=this;this.gestures=new jy({get history(){return t._history},get gestureTx(){return t.gestureTx},set gestureTx(n){t.gestureTx=n},get groupMoveOrigin(){return t.groupMoveOrigin},set groupMoveOrigin(n){t.groupMoveOrigin=n},get groupLinkMoveOrigin(){return t.groupLinkMoveOrigin},set groupLinkMoveOrigin(n){t.groupLinkMoveOrigin=n},get groupResizeOrigin(){return t.groupResizeOrigin},set groupResizeOrigin(n){t.groupResizeOrigin=n},get dragElementId(){return t.dragElementId},set dragElementId(n){t.dragElementId=n},get containerHover(){return t.containerHover},set containerHover(n){t.containerHover=n},get toolLocked(){return t._toolLocked},get mode(){return t.activeTool.type},setMode:n=>{t.setActiveTool(n)},notify:()=>{t.notify()}}),this.textEdit=new ig({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},notify:()=>{t.notify()},isLayerLocked:n=>t.isLayerLocked(n),clearSelectionFor:n=>{t._selection.has(n)&&(t._selection=Pe)},mainTarget:this.mainTarget}),this.linkHandles=new lg({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},recordGesturePatch:n=>{t.recordGesturePatch(n)},commitGesture:()=>{t.commitGesture()},cancelGesture:()=>{t.cancelGesture()},hasGestureTx:()=>t.gestureTx!==null,notify:()=>{t.notify()},linkAttachTargetAt:n=>t.linkAttachTargetAt(n),snapLinkEndpoint:(n,o)=>t.snapLinkEndpoint(n,o),updateHoveredLinkTarget:n=>{t.updateHoveredLinkTarget(n)},clearHoveredLinkTarget:()=>{t.hoveredLinkTarget=null}}),this.longPress=new Yy(n=>this.screenToWorld(n),n=>{for(let o of this.longPressListeners)o(n)}),this.pinch=new Ky(n=>this.screenToWorld(n),(n,o)=>{this.zoomAt(n,o)},n=>{this.panBy(n)}),this.containerOpsRef={get scene(){return t._scene},get dragElementId(){return t.dragElementId},get containerHover(){return t.containerHover},applyPatch(n,o){t._scene=o,t.beginOrAttachGesture().add(n)}}}initGlobalHooks(t){t.textShaper&&Pp(t.textShaper),t.rasterizer&&Bp(t.rasterizer),kA((n,o,a,r)=>(this.mainTarget.setFont(o,a,{...r?.bold?{weight:"bold"}:{},...r?.italic?{style:"italic"}:{}}),this.mainTarget.measureText(n).width))}initInputMode(t){let n=t.inputMode??"auto";n==="touch"?this.inputMode="touch":n==="mouse"?this.inputMode="mouse":typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?this.inputMode="touch":this.inputMode="mouse",this.handleHitSlop=this.inputMode==="touch"?VI:11,this.edgeHandleHitSlop=this.inputMode==="touch"?jI:Ko,this.edgeHitThreshold=this.inputMode==="touch"?ZI:J0,this.anchorStartHitSlop=this.inputMode==="touch"?XI:ey,this.anchorClickRadius=this.inputMode==="touch"?YI:ty}initActor(t){this.actor=ea(z5),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",n=>{this.applyEmit(n)}),this.actor.start(),this.fileDropRegistry.register(P9),this.fileDropRegistry.register(N9),this._readOnly=t.readOnly??!1,t.initialTool&&this.actor.send({type:"SET_MODE",mode:t.initialTool})}snapshotCache=null;observableSnapshot(){let t=this.activeTool,n=this._selection,o=this._selectedLinks,a=this._scene,r=this.canUndo,s=this.canRedo,i=this.snapshotCache;if(i!==null&&i.activeTool===t&&i.selection===n&&i.selectedLinks===o&&i.scene===a&&i.canUndo===r&&i.canRedo===s)return i;let l={activeTool:t,selection:n,selectedLinks:o,scene:a,canUndo:r,canRedo:s};return this.snapshotCache=l,l}get scene(){return this._scene}get selection(){return this._selection}get activeTool(){let t=this.actor.getSnapshot().context.mode,n=this._activeToolCache;return(n.type!==t||n.locked!==this._toolLocked||n.lastActiveTool!==this._lastActiveTool)&&(this._activeToolCache={type:t,locked:this._toolLocked,lastActiveTool:this._lastActiveTool}),this._activeToolCache}get history(){return this._history}get canUndo(){return this._history.canUndo}get canRedo(){return this._history.canRedo}get hostElement(){return this.host}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCursorMove(t){return this.cursorListeners.add(t),()=>this.cursorListeners.delete(t)}setCommentAuthor(t){this.commentAuthor=t}get selectedAnnotation(){return this._selectedAnnotation}setSelectedAnnotation(t){this._selectedAnnotation!==t&&(this._selectedAnnotation=t,this.notify())}addAnnotation(t){let n=xO(this._scene,t,this.commentAuthor,o=>this.uniqueId(o));return this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation=n.id,this.notify(),this.announce("Annotation added"),n.id}removeAnnotation(t){let n=bO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation===t&&(this._selectedAnnotation=null),this.notify(),this.announce("Annotation removed"))}toggleAnnotationResolved(t){let n=AO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify(),this.announce(n.wasResolved?"Annotation reopened":"Annotation resolved"))}addComment(t,n,o){let a=vO(this._scene,t,n,o??this.commentAuthor,r=>this.uniqueId(r));a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}removeComment(t,n){let o=SO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return LO(this._scene,t)}onLongPress(t){return this.longPressListeners.add(t),()=>this.longPressListeners.delete(t)}onAnnounce(t){return this.announceListeners.add(t),()=>this.announceListeners.delete(t)}announce(t){if(t)for(let n of this.announceListeners)n(t)}setPeerCursors(t){this._peerCursors=t,this.scheduleRender()}setPeerSelections(t){this._peerSelections=t,this.scheduleRender()}setDebugHitZones(t){this.debugHitZones!==t&&(this.debugHitZones=t,this.scheduleRender())}get readOnly(){return this._readOnly}setReadOnly(t){this._readOnly!==t&&(this._readOnly=t,this.notify(),this.scheduleRender())}toggleReadOnly(){this.setReadOnly(!this._readOnly)}get gridEnabled(){return this._scene.viewport.gridEnabled}setGridVisible(t){this.setGrid({enabled:t})}toggleGrid(){this.setGrid({enabled:!this.gridEnabled})}get selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:AR(this._selectedLinks)}updateSelectedLink(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=Ye(this._scene,n,t);this._scene=o.scene,this._history.push(o.patch),this.notify()}registerFileDropHandler(t){this.fileDropRegistry.register(t)}unregisterFileDropHandler(t){this.fileDropRegistry.unregister(t)}async dispatchFileDrop(t,n){let o={editor:this,worldPoint:n};return this.fileDropRegistry.dispatch(t,o)}setToolLocked(t){this._toolLocked!==t&&(this._toolLocked=t,this.notify())}maybeRevertToolAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setActiveTool(t){let n=this.actor.getSnapshot().context.mode;n!==t&&(this._lastActiveTool=n),this.pendingEyedropperPick=null,this.editingTextElement!==null&&this.commitTextEdit(),this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),t!=="draw-edge"&&this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null),this.actor.send({type:"SET_MODE",mode:t}),this.refreshCursor(),this.notify()}undo(){let t=this._history.undo();return t?(this._scene=J(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}redo(){let t=this._history.redo();return t?(this._scene=J(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}addElement(t,n){let o=Fe(this._scene,t);return this._scene=o.scene,(n?.select??!0)&&(this._selection=wt(t.id)),this._history.push(o.patch),this.notify(),o.patch}insertImage(t){let n=Ze(this.uniqueId("img")),o=X9(this._scene,t,n,this._activeLayerId);return this.addElement(o),t.animated&&(this.gifPlayback.ensure(n),this.maybeAnimate()),n}async addBinaryFile(t,n){let o=await Y9(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new Vy({hasVisibleAnimatedElement:()=>$9(this)||this.hasActiveLaser(),autoStopHeavyGifs:()=>{Q9(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return Xy(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new Zy;togglePlayback(t){this.gifPlayback.toggle(t),this.maybeAnimate(),this.scheduleRender()}hoverAnimatedElement(t){this.gifPlayback.hoverEnter(t)&&(this.maybeAnimate(),this.scheduleRender())}isPlaybackPaused(t){return this.gifPlayback.isPaused(t)}setHoverCursorWorld(t){this.hoverCursorWorld=t,this._selection.size===1&&this.notify()}get linkPreviewPath(){return this.edgePreview?.points??null}get linkAttachTarget(){let t=this.hoveredLinkTarget;return t?{elementId:t.elementId,mode:t.mode}:null}beginPlacement(t){let n=this._history.transaction(),{scene:o,state:a}=$O(t),r=o(this._scene);this._scene=r.scene,this._selection=wt(t.id),this.notify();let s={...a};return{update:i=>{let l=YO(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=KO(this._scene,s);i&&(this._scene=i.scene,s.current=i.next),n.add({kind:"element",id:t.id,before:null,after:s.current}),n.commit(),this.notify()},cancel:()=>{let{scene:i}=QO(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Pe,this.notify()}}}deleteSelected(){if(this.readOnly)return;let t=eg(this._scene,this._selection,this._selectedLinks);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=Pe,this._selectedLinks=gt,this.notify()}get editingTextElement(){return this.textEdit.editingElement}get editingLinkCaption(){return this.interaction.editingLinkCaption}_editingFrameName=null;get editingFrameName(){return this._editingFrameName}get editingTextSelection(){return this.textEdit.selection}get editingTextCaret(){return this.textEdit.caret}get caretBlinkOn(){return this.textEdit.caretBlinkOn}get isTextDragging(){return this.textEdit.isDragging}beginLinkCaptionEdit(t){ue(this._scene,t)&&(this.editingTextElement!==null&&this.commitTextEdit(),this.interaction.editingLinkCaption=t,this.notify())}commitLinkCaptionEdit(t){let n=this.interaction.editingLinkCaption;if(this.interaction.editingLinkCaption=null,n===null){this.notify();return}let o=ue(this._scene,n);if(o){let a=t.trim(),r=a===""?void 0:{...o.label??{},text:a};if(!((o.label?.text??"")===(r?.text??""))){let i=Ye(this._scene,n,l=>{let c={...l};return r?c.label=r:delete c.label,c});this._scene=i.scene,this._history.push(i.patch)}}this.notify()}cancelLinkCaptionEdit(){this.interaction.editingLinkCaption!==null&&(this.interaction.editingLinkCaption=null,this.notify())}linkLabelWorld(t){let n=ue(this._scene,t);if(!n)return null;let o=_o(this._scene,n);return!o||o.length<2?null:uc(o,n)}beginTextEdit(t){this.textEdit.begin(t)}beginFrameNameEdit(t){let n=I(this._scene,t);n===void 0||!Be(n)||this.isLayerLocked(n.layerId)||(this.editingTextElement!==null&&this.commitTextEdit(),this._editingFrameName=t,this.notify())}commitFrameNameEdit(t){let n=this._editingFrameName;if(n===null)return;this._editingFrameName=null;let o=_O(this._scene,n,t);o&&(this._scene=o.scene,this._history.push(o.patch)),this.notify()}cancelFrameNameEdit(){this._editingFrameName!==null&&(this._editingFrameName=null,this.notify())}frameHeaderAt(t){return kO(this._scene,t)}setEditingText(t,n,o,a="forward"){this.textEdit.setText(t,n,o,a)}setEditingSelection(t,n,o="forward"){this.textEdit.setSelection(t,n,o)}caretIndexAtWorldPoint(t){return this.textEdit.caretIndexAtWorldPoint(t)}editedElementContainsPoint(t){return this.textEdit.editedElementContainsPoint(t)}setTextCaretFromPoint(t){this.textEdit.setCaretFromPoint(t)}extendTextSelectionToPoint(t){this.textEdit.extendSelectionToPoint(t)}endTextDragSelect(){this.textEdit.endDragSelect()}editingTextOverlay(){return this.textEdit.overlay()}commitTextEdit(t){this.textEdit.commit(t)}cancelTextEdit(){this.textEdit.cancel()}moveSelectionBy(t){if(this.readOnly||this._selection.size===0&&this._selectedLinks.size===0)return;let n=new Set([...this.expandSelectionWithDescendants()].filter(i=>{let l=I(this._scene,i);return l?this.isElementManipulable(l):!1})),o=this._selection.size>0?NR(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=hR(a,n,this._selectedLinks,t);if(!o&&r.patches.length===0)return;let s=this._history.transaction();if(this._scene=r.scene,o)for(let i of o.patches)s.add(i);for(let i of r.patches)s.add(i);s.commit(),this.notify(),this.announce(jR(t,o?.moved??0))}createElementAtCursor(){let t=this._scene.viewport,n=this.screenToWorld({x:(t.size.width||200)/2,y:(t.size.height||200)/2}),o=qS(++this.nextId),a=ZO(this._scene,this.activeTool.type,n,this._activeLayerId,o),r=Fe(this._scene,a);return this._scene=r.scene,this._history.push(r.patch),this._selection=wt(o),this.notify(),this.announce(`Created ${a.type} ${o}`),o}createTextAt(t){let n=qS(++this.nextId),o=XO(this._scene,t,this._activeLayerId,n),a=Fe(this._scene,o);return this._scene=a.scene,this.textEdit.markPendingCreate(n),this._selection=wt(n),this.maybeRevertToolAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}_brushSettings=Gc;get brushSettings(){return this._brushSettings}setBrushSettings(t){this._brushSettings={...this._brushSettings,...t},this.notify()}beginBrushStroke(t,n=.5,o="pen"){this.brushStroke=RR(t,n,this._brushSettings.width,o!=="pen"),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(OR(this.brushStroke,t,n,this._scene.viewport.zoom||1),this.notify())}commitBrushStroke(){let t=PR(this._scene,this.brushStroke,this._activeLayerId,PS(++this.nextId),Jy(this._brushSettings));return t?(this._scene=t.scene,this._history.push(t.patch),this.brushStroke=null,this.notify(),t.elementId):(this.brushStroke=null,this.notify(),null)}cancelBrushStroke(){this.brushStroke&&(this.brushStroke=null,this.notify())}get pendingBrushStroke(){return this.brushStroke}beginEraseStroke(t,n=!1,o=!1){let a=ZR(t,o);if(!n){let r=this.acceleratedElementAt(t);r&&!(o&&r.type==="brush")&&a.pending.add(r.id)}this.eraseStroke=a,this.eraseDirty=!0,o&&this.markStrokeEraseSegment(a,t,t),this.interaction.eraserTrail=[By(t,Oi())],this.maybeAnimate(),this.notify()}markStrokeEraseSegment(t,n,o){let a=this._scene.viewport.zoom||1,r=this._brushSettings.width/a,s=!1;for(let i of this._scene.elements.values()){if(!Mn(i))continue;let l=t.erased.get(i.id)??[],c=nO(i,l,n,o,r);(c.length>l.length||HS(c)>HS(l)+1e-6)&&(t.erased.set(i.id,c),s=!0)}return s}extendEraseStroke(t,n=!1){let o=this.eraseStroke;if(!o)return;let a=XR(o.last,t,l=>this.acceleratedElementAt(l),o.pending,n,o.strokeMode),r=o.strokeMode?this.markStrokeEraseSegment(o,o.last,t):!1;(a||r)&&(this.eraseDirty=!0),o.last=t;let s=this.interaction.eraserTrail,i=s[s.length-1];i?(X2(i,t,Oi()),this.interaction.eraserTrail=s.slice()):this.interaction.eraserTrail=[By(t,Oi())],this.maybeAnimate(),this.notify()}commitEraseStroke(){let t=this.eraseStroke;if(!t)return 0;this.eraseStroke=null;let n=YR(this._scene,t.pending),o=n?n.scene:this._scene,a=n?[...n.patches]:[],r=[];if(t.strokeMode){let l=oO(o,t.erased,()=>PS(++this.nextId));l&&(o=l.scene,a.push(...l.patches),r.push(...l.removedIds))}if(a.length===0)return this.notify(),0;let s=this._history.transaction();this._scene=o;for(let l of a)s.add(l);s.commit();let i=this._selection;for(let l of t.pending)i=Pf(i,l);for(let l of r)i=Pf(i,l);return this._selection=i,this.notify(),t.pending.size+r.length}cancelEraseStroke(){this.eraseStroke&&(this.eraseStroke=null,this.notify())}get laserDrawing(){return this.interaction.laserDrawing}beginLaserStroke(t){this.interaction.laserStrokes=[...this.interaction.laserStrokes,By(t,Oi())],this.interaction.laserDrawing=!0,this.maybeAnimate(),this.notify()}extendLaserStroke(t){if(!this.interaction.laserDrawing)return;let n=this.interaction.laserStrokes,o=n[n.length-1];o&&(X2(o,t,Oi()),this.interaction.laserStrokes=n.slice(),this.maybeAnimate(),this.notify())}endLaserStroke(){this.interaction.laserDrawing=!1,this.maybeAnimate()}hasActiveLaser(){return this.interaction.laserStrokes.length>0||this.interaction.eraserTrail.length>0}get eraserTrail(){return this.interaction.eraserTrail}pruneLaser(){let t=this.interaction.laserStrokes;if(t.length>0){let o=Y2(t,Oi());o.changed&&(this.interaction.laserStrokes=o.strokes)}let n=this.interaction.eraserTrail;if(n.length>0){let o=Y2(n,Oi(),iy);o.changed&&(this.interaction.eraserTrail=o.strokes)}}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=OO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Arranged ${o.count} shapes on a ${o.cols}-column grid`))}arrangeAsStack(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=DO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Stacked ${o.count} shapes ${o.direction}`))}groupSelected(){if(this.readOnly)return{kind:"noop"};let t=BO(this._scene,this._selection,FO(++this.nextId));if(!t)return{kind:"noop"};let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);return n.commit(),this._selection=wt(t.groupId),this.notify(),{kind:"grouped",groupId:t.groupId}}ungroup(){if(this.readOnly)return;let t=NO(this._scene,this._selection);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=new Set(t.nextSelection),this.notify()}selectionRoots(){return US(this._scene,this._selection)}expandSelectionWithDescendants(){return PO(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=zO(this._scene,n,t);o&&(this._selection=wt(o.id),this.notify(),this.announce(`Selected ${o.name}`))}cancelInteraction(){this.cancelGesture(),this.actor.send({type:"POINTER_CANCEL"}),this.interaction.resetPreviews(),this.interaction.linkDragFromAnchor=null,this.interaction.editingLinkCaption=null,this.interaction.pendingLinkDropMenu=null,this.interaction.eraseStroke=null,this.interaction.laserDrawing=!1,this.flowchartSession=null,this.linkHandles.reset(),this._enteredGroup!==null&&(this._enteredGroup=null),this._selection=Pe,this._selectedLinks=gt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){if(this.readOnly)return;let t=zR(this._scene,this._selection,()=>++this.nextId);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),t.newIds.length>0&&(this._selection=BS(t.newIds)),this.notify()}duplicateSelectedInPlace(t=null){if(this.readOnly||this._selection.size===0)return null;let n=new Set,o=l=>{if(!n.has(l)){n.add(l);for(let c of this._scene.elements.values())(c.parentId===l||c.frameId===l)&&o(c.id)}};for(let l of this._selection)o(l);let a=new Map;for(let l of n)a.set(l,Ze(this.uniqueId("shape")));let r=tD(this._scene,n,a),s=this._history.transaction();this._scene=r.scene;for(let l of r.patches)s.add(l);s.commit();let i=[];for(let l of this._selection){let c=a.get(l);c!==void 0&&i.push(c)}return i.length>0&&(this._selection=BS(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=FR(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=gt),this.notify())}selectLink(t){let n=t===null?gt:$y(t),o=!Vp(n,this._selectedLinks),a=this._selection.size>0;!o&&!a||(this._selection=Pe,this._selectedLinks=n,this.notify())}selectAll(){let t=HR(this._scene,this._selection),n=UR(this._scene),o=!Vp(n,this._selectedLinks);if(!t&&!o)return;t&&(this._selection=t),this._selectedLinks=n,this.notify();let a=this._selection.size+this._selectedLinks.size;this.announce(`Selected ${a} objects`)}clipboard=[];copySelected(){let t=lO(this._scene,this._selection);t.length!==0&&(this.clipboard=[...t],this.announce(`Copied ${t.length} shapes`))}cutSelected(){this.readOnly||(this.copySelected(),this.deleteSelected())}paste(t){if(this.clipboard.length===0)return;this.finalizeOpenGestureTx();let n=t??this.lastPointerWorld,o=cO(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=uO(o.newIds),this.notify(),this.announce(`Pasted ${o.newIds.length} shapes`)}copySelectionStyle(){for(let t of this._selection){let n=I(this._scene,t);if(n!==void 0){this.styleClipboard={...n.style};return}}}pasteSelectionStyle(){this.styleClipboard!==null&&this.updateStyle(this._selection,this.styleClipboard)}get hasStyleClipboard(){return this.styleClipboard!==null}updateStyle(t,n){if(this.readOnly)return;let o=GR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}setBrushWidth(t,n){if(this.readOnly)return;let o=BR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}applyTextStyleToRange(t,n,o,a){if(this.readOnly)return;let r=WR(this._scene,t,n,o,a);r&&(this._scene=r.scene,this._history.push(r.patch),this.notify())}pickColorAt(t,n="fill"){return VS(this._scene,t,n)}pendingEyedropperPick=null;get isEyedropperArmed(){return this.pendingEyedropperPick!==null}beginEyedropperPick(t){this.pendingEyedropperPick=t,this.refreshCursor(),this.notify()}applyEyedropperAt(t){let n=VS(this._scene,t,"fill"),o=this.pendingEyedropperPick;return o!==null?(this.pendingEyedropperPick=null,n!==null&&o(n),this.refreshCursor(),this.notify(),n):n===null?null:(!this.readOnly&&this._selection.size>0&&this.updateStyle(this._selection,{fill:n}),n)}convertSelection(t){if(this.readOnly)return;let n=oD(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}spawnConnectedNode(t){if(this.readOnly)return;let n=[...this._selection],o=n.length===1?n[0]:void 0;if(o===void 0)return;let a=uD(this._scene,o,t,Wc(++this.nextId),Yp(++this.nextId));a&&(this._scene=a.scene,this._history.push({kind:"batch",patches:[...a.patches]}),this.setSelection([a.newElementId]),this.notify())}flowchartSession=null;growFlowchart(t){if(this._readOnly||this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0||I(this._scene,o)===void 0)return;let a=this.flowchartSession,r=a?.direction===t&&a.sourceId===o?Math.min(a.count+1,z4):1,{elements:s,links:i}=dD(this._scene,o,t,r,()=>Wc(++this.nextId),()=>Yp(++this.nextId));this.flowchartSession={sourceId:o,direction:t,count:r,elements:s,links:i},this.notify()}commitFlowchart(){let t=this.flowchartSession;if(t===null)return null;let n=this._scene,o=[];for(let r of t.elements){let s=Fe(n,r);n=s.scene,o.push(s.patch)}for(let r of t.links){let s=pi(n,r);n=s.scene,o.push(s.patch)}this.flowchartSession=null;let a=t.elements[0]?.id??null;return o.length===0?(this.notify(),a):(this._scene=n,this._history.push({kind:"batch",patches:o}),a!==null&&this.setSelection([a]),this.notify(),a)}cancelFlowchart(){this.flowchartSession!==null&&(this.flowchartSession=null,this.notify())}get flowchartPreview(){let t=this.flowchartSession;return t===null?null:{elements:t.elements,links:t.links}}navigateFlowchart(t){if(this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0)return;let a=new Set;for(let r of this._scene.links.values()){let s=ii(r.from),i=ii(r.to);s===o&&i!==void 0&&i!==o?a.add(i):i===o&&s!==void 0&&s!==o&&a.add(s)}if(a.size>0){let r=this.combinedSelectionBounds(),s=r?{x:r.x+r.width/2,y:r.y+r.height/2}:{x:0,y:0},i=NS(this._scene,this._selection,t,s,l=>this.isElementInteractable(l)&&a.has(l.id));if(i!==null){this.setSelection([i]);return}}this.selectClosest(t)}cropSession=null;get imageCropSession(){let t=this.cropSession;return t===null?null:{id:t.id,crop:t.crop,position:t.position,width:t.width,height:t.height}}beginImageCrop(t){if(this.readOnly)return;let n=I(this._scene,t);n===void 0||!ct(n)||(this.cancelInteraction(),this._selection=wt(t),this.cropSession={id:t,crop:n.crop??ag,position:n.position,width:n.width,height:n.height,drag:null,dragStartWorld:null},this.setActiveTool("crop"),this.refreshCursor(),this.notify())}cropHandleAtWorld(t){let n=this.cropSession;if(n===null)return null;let o=I(this._scene,n.id);if(o===void 0)return null;let a=this.pendingCropElement(o),r=sD(a),s=this._scene.viewport.zoom||1,i=Z4/s;for(let c of rD){let u=r[c];if(Math.hypot(t.x-u.x,t.y-u.y)<=i)return c}let l=ci(a,t);return l.x>=0&&l.x<=n.width&&l.y>=0&&l.y<=n.height?"body":null}beginImageCropHandle(t,n){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"handle",handle:t},dragStartWorld:n})}beginImageCropBody(t){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"body"},dragStartWorld:t})}updateImageCropDrag(t){let n=this.cropSession;if(n?.drag==null||n.dragStartWorld===null)return;let o=I(this._scene,n.id);if(o===void 0)return;let a=o.crop??ag;if(n.drag.kind==="handle"){let r=iD(o,a,n.drag.handle,t);this.cropSession={...n,crop:r.crop,position:r.position,width:r.width,height:r.height}}else{let r=lD(o,a,n.dragStartWorld,t);this.cropSession={...n,crop:r.crop}}this.notify()}endImageCropDrag(){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:null,dragStartWorld:null})}commitImageCrop(){let t=this.cropSession;if(t===null)return;let n=cD(this._scene,t.id,{crop:t.crop,position:t.position,width:t.width,height:t.height});this.cropSession=null,n&&(this._scene=n.scene,this._history.push(n.patch)),this.setActiveTool("select"),this.refreshCursor(),this.notify()}cancelImageCrop(){this.cropSession!==null&&(this.cropSession=null,this.setActiveTool("select"),this.refreshCursor(),this.notify())}pendingCropElement(t){let n=this.cropSession;return n===null?t:{...t,position:n.position,width:n.width,height:n.height}}cropFrameCorners(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=this.pendingCropElement(n),a=Re(o);return[{x:a.x,y:a.y},{x:a.x+a.width,y:a.y},{x:a.x+a.width,y:a.y+a.height},{x:a.x,y:a.y+a.height}].map(r=>Rn(o,r))}cropGhost(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=n.crop??ag;return{element:n,fullRect:rg(n,o)}}updateTextProps(t,n){if(this.readOnly)return;let o=qR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){if(this.readOnly)return;let n=VR(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}setLink(t,n){if(this.readOnly)return;let o=n===null?null:UO(n),a=GO(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=og(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return og(I(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=og(n.href);return o?{id:n.id,href:o,bounds:N(n)}:null}bringToFront(t){if(this.readOnly)return;let n=EO(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendToBack(t){if(this.readOnly)return;let n=CO(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}bringForward(t){if(this.readOnly)return;let n=IO(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendBackward(t){if(this.readOnly)return;let n=MO(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(TD(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(ED(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(CD(this._scene,this._selection,t))}rotateSelection(t){let n=[],o=new Map;for(let r of this._selection){let s=I(this._scene,r);s!==void 0&&(n.push(s),o.set(r,{position:s.position,rotation:s.rotation}))}if(n.length===0)return;let a=ID(n);this.commitArrange($S(this._scene,o,a,t))}commitArrange(t){if(this.readOnly||t.length===0)return;let n=this._history.transaction();for(let o of t)this._scene=J(this._scene,o),n.add(o);n.commit(),this.notify()}compactLayerZOrder(t,n={}){let o=n.recordHistory??!0,a=t?[t]:[...this._scene.layers.keys()],r=o?this._history.transaction():null;if(RO(this._scene,a,(i,l)=>{this._scene=i,r?.add(l)})===0){r?.cancel();return}r?.commit(),this.notify(),o&&this.announce(`Compacted z-order across ${a.length} layer(s)`)}clear(){this.readOnly||this._scene.elements.size===0&&this._scene.links.size===0||(this._scene={...this._scene,elements:new Map,links:new Map},this._selection=Pe,this._selectedLinks=gt,this._history.clear(),this.notify())}get activeLayerId(){return this._activeLayerId}setActiveLayer(t){this._scene.layers.has(t)&&this._activeLayerId!==t&&(this._activeLayerId=t,this.notify())}createLayer(t){let n=dO(this._scene,t,gO(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=fO(this._scene,t,this._activeLayerId);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this._activeLayerId=n.nextActiveLayerId,this._selection=Pe,this.notify()}renameLayer(t,n){let o=pO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=hO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=mO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){if(this.readOnly)return;let n=yO(this._scene,this._selection,t);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this.notify()}panBy(t){let n=vR(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(Iv)}zoomOut(){this.zoomStep(1/Iv)}zoomStep(t){let n=this._scene.viewport;if(n.size.width<=0||n.size.height<=0)return;let o=this.screenToWorld({x:n.size.width/2,y:n.size.height/2});this.zoomAt(t,o)}resetZoom(){let t=LR(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=_R(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=RS(this._scene,n,t);o&&(this._scene=o,this.notify())}revealSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=kR(this._scene,n,t);o&&(this._scene=o,this.notify())}selectClosest(t){let n=this.combinedSelectionBounds(),o=this._scene.viewport,a=n?{x:n.x+n.width/2,y:n.y+n.height/2}:{x:o.pan.x+o.size.width/2/o.zoom,y:o.pan.y+o.size.height/2/o.zoom},r=NS(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=SR(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=wR(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=TR(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return q0(this._scene.viewport)}setSnapToGrid(t){this.setGrid({snap:t})}setSnapSuppressed(t){this.interaction.snapSuppressed=t}setTransformModifiers(t){this.interaction.transformAltKey=t.alt,this.interaction.transformShiftKey=t.shift}snapActive(){let t=this._scene.viewport;return!this.interaction.snapSuppressed&&t.gridEnabled&&q0(t)}snapSpacing(){return $A()}loadScene(t,n={}){if(this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),this._scene=t,!t.layers.has(this._activeLayerId)){let o=t.layers.keys().next().value;this._activeLayerId=o??ln(On)}n.preserveHistory?this.pruneSelection():(this._selection=Pe,this._history.clear()),LS(this),kS(this),this.notify(),this.maybeAnimate()}dispose(){this.cancelLongPress(),this.unbind(),this.actor.stop(),this.listeners.clear(),this.cursorListeners.clear(),this.longPressListeners.clear(),this.announceListeners.clear(),this.animation.detach(),this.animationContentOff?.(),this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null)}bindPointerEvents(){return MR(this)}beginPanGesture(t,n,o){this.actor.send({type:"POINTER_CANCEL"}),this.cancelGesture(),this.cancelLongPress(),this.host.setPointerCapture(t),this.panGesture={pointerId:t,button:n,startPoint:o,lastPoint:o,moved:!1},this.refreshCursor()}endPanGesture(){let t=this.panGesture;if(this.panGesture=null,t&&(t.button===2||t.button===1)&&!t.moved){let n=this.screenToWorld(t.startPoint);for(let o of this.longPressListeners)o({screenPoint:t.startPoint,worldPoint:n})}this.refreshCursor()}isDrawingPhase(t){return t.mode==="draw-rect"||t.mode==="draw-ellipse"||t.mode==="draw-edge"}startLongPress(t){this.longPress.start(t)}cancelLongPress(){this.longPress.cancel()}beginPinch(){this.pinch.begin([...this.activePointers.values()])}applyPinch(){this.pinch.apply([...this.activePointers.values()])}screenToWorld(t){return z.applyToPoint(qa(this._scene.viewport),t)}linkAttachTargetAt(t){let n=this.acceleratedElementAt(t);if(n&&this.isElementInteractable(n)){let o=this.promoteToGroupRoot(n);return{kind:"element",id:o.id,bounds:N(o)}}}hitTest(t){return yM(t,{scene:this._scene,selection:this._selection,selectionChromeActive:this.activeTool.type==="select",selectedLink:this.selectedLink,selectedLinkCount:this._selectedLinks.size,enteredGroup:this._enteredGroup,handleHitSlop:this.handleHitSlop,edgeHandleHitSlop:this.edgeHandleHitSlop,edgeHitThreshold:this.edgeHitThreshold,hitAnnotation:n=>this.hitAnnotation(n),selectionIsAspectLocked:()=>this.selectionIsAspectLocked(),combinedSelectionBounds:()=>this.combinedSelectionBounds(),acceleratedElementAt:n=>this.acceleratedElementAt(n),isElementInteractable:n=>this.isElementInteractable(n),isLayerLocked:n=>this.isLayerLocked(n),promoteToGroupRoot:n=>this.promoteToGroupRoot(n)})}refreshCursor(t){let n=wO(this,t??this.lastPointerWorld);this.host.style.cursor!==n&&(this.host.style.cursor=n)}setCursorOverride(t,n){n===null?this.cursorOverrides.delete(t):this.cursorOverrides.set(t,n),this.refreshCursor()}getCursorOverride(t){return this.cursorOverrides.get(t)}isLayerLocked(t){return this._scene.layers.get(t)?.locked===!0}isElementInteractable(t){return!(this.isLayerLocked(t.layerId)||cc(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||IA(this._scene,t)||cc(this._scene,t))}toggleLockSelection(){if(this.readOnly||this._selection.size===0)return;let t=[...this._selection],n=t.some(a=>I(this._scene,a)?.locked!==!0),o=this._history.transaction();for(let a of t){let r=$(this._scene,a,s=>{let i={...s};return n?i.locked=!0:delete i.locked,i});this._scene=r.scene,o.add(r.patch)}o.commit(),this.notify()}promoteToGroupRoot(t){return F9(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return z9(this._scene,t)}isDescendantOfGroup(t,n){return SS(this._scene,t,n)}computeHiddenElements(){return vD(this._scene)}computeStrokeErasePreview(){let t=this.eraseStroke;if(!t||!t.strokeMode||t.erased.size===0)return null;let n=aO(this._scene,t.erased);return n?{elements:n.fragments,hidden:n.hidden}:null}computeDimElements(t){return H9(this._scene,this._selection,t)}computeDimSet(){let t=this._enteredGroup?this.computeDimElements(this._enteredGroup):void 0,n=this.interaction.eraseStroke?.pending;if(!n||n.size===0)return t;let o=new Set(t);for(let a of n)o.add(a);return o}enterGroup(t){this._enteredGroup=t,this.notify()}enterContainer(){if(this._selection.size!==1)return;let t=v([...this._selection][0]),n=I(this._scene,t);if(!n)return;let o=Be(n),a=[];for(let r of this._scene.elements.values())(r.parentId===t||o&&r.frameId===t)&&a.push(r.id);a.length!==0&&(ze(n)&&(this._enteredGroup=t),this.setSelection(a))}exitContainer(){if(this._selection.size===0)return;let t,n=!0;for(let o of this._selection){let a=I(this._scene,o),r=a?.parentId??a?.frameId;if(r===void 0){n=!1;break}if(t===void 0)t=r;else if(t!==r){n=!1;break}}this._enteredGroup=null,n&&t!==void 0?this.setSelection([t]):this.notify()}get enteredGroup(){return this._enteredGroup}acceleratedElementAt(t){return this._scene.elements.size<Rv?ui(this._scene,t):OA(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=RA(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.interaction.lastClickAt<bc&&this.interaction.lastClickWorldPoint!==null&&W.distance(this.interaction.lastClickWorldPoint,n)<=Ac;if(this.interaction.lastClickAt=o,this.interaction.lastClickWorldPoint=n,a){let r=this.frameHeaderAt(n);if(r!==null)return this.beginFrameNameEdit(r),!0}if(!t)return!1;if(this._enteredGroup!==null){let r=t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE"?t.id:null;if(!(r!==null&&this.isDescendantOfGroup(r,this._enteredGroup)))return this._enteredGroup=null,this.notify(),!1}if(a&&t.type==="SELECT_EDGE_REPLACE")return this._selectedLinks=$y(t.id),this._selection=Pe,this.beginLinkCaptionEdit(t.id),!0;if(a&&(t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE")){let r=this.acceleratedElementAt(n);if(r!==void 0&&pe(r))return this.beginTextEdit(r.id),!0;if(r!==void 0&&Be(r))return this.beginFrameNameEdit(r.id),!0;if(r){let s=this.topGroupAncestor(r),i=this.pickDrillTarget(r,s);if(i)return this._enteredGroup=i.id,this._selection=wt(r.id),this._selectedLinks.size>0&&(this._selectedLinks=gt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return U9(this._scene,t,n,this._enteredGroup)}applyEmit(t){if(!(this._readOnly&&OV.has(t.type)))switch(t.type){case"SELECT_REPLACE":this._selection=wt(t.id),this._selectedLinks=gt,this.notify();return;case"SELECT_TOGGLE":this._selection=pA(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Pe,this._selectedLinks=gt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=$y(t.id),this._selection=Pe,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=bR(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=gt,this.notify());return;case"UPDATE_EDGE_ENDPOINT_PREVIEW":this.applyLinkEndpointMove(t.linkId,t.side,t.toPoint);return;case"UPDATE_EDGE_ENDPOINT":this.applyLinkEndpointUpdate(t);return;case"LASSO_PROGRESS":this.interaction.lassoBaseSelection??=this._selection,this.interaction.lassoBaseLinks??=this._selectedLinks,this.lassoPreview=t.bounds,this.applyLassoLiveSelection(t.bounds,t.mode),this.notify();return;case"LASSO_CLEAR":(this.lassoPreview!==null||this.interaction.lassoBaseSelection!==null||this.interaction.lassoBaseLinks!==null)&&(this.lassoPreview=null,this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.notify());return;case"SELECT_BY_BOUNDS":this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.applySelectByBounds(t.bounds,t.mode);return;case"MOVE_SHAPE":this.groupMoveOrigin?this.applyGroupMove(t.delta):this.applyMove(t.id,t.delta,t.originalBounds);return;case"RESIZE_GROUP":this.applyGroupResize(t.handle,t.delta,t.originalBounds);return;case"RESIZE_SHAPE":this.applyResize(t.id,t.handle,t.delta,t.originalBounds);return;case"ROTATE":this.applyRotate(t.deltaAngle);return;case"CREATE_SHAPE":this.applyCreate(t.shapeType,t.bounds);return;case"CREATE_EDGE":this.applyCreateLink(t);return;case"DRAW_EDGE_PREVIEW":this.applyLinkPreview(t.fromElement,t.fromPoint,t.toPoint);return;case"DRAW_EDGE_PREVIEW_CLEAR":this.edgePreview&&(this.edgePreview=null,this.notify());return;case"TEMPLATE_TAP":for(let n of this.templateTapListeners)n(t);return;case"TEMPLATE_DROP":for(let n of this.templateDropListeners)n(t);return;case"MOVE_ANNOTATION":this.applyAnnotationMove(t.id,t.delta,t.originalPosition);return;case"COMMIT_ANNOTATION_DRAG":this.finalizeOpenGestureTx();return}}applyAnnotationMove(t,n,o){let a=wD(this._scene,t,n,o);a&&(this._scene=a.scene,this.recordGesturePatch(a.patch),this.notify())}templateTapListeners=new Set;templateDropListeners=new Set;onTemplateTap(t){return this.templateTapListeners.add(t),()=>this.templateTapListeners.delete(t)}onTemplateDrop(t){return this.templateDropListeners.add(t),()=>this.templateDropListeners.delete(t)}dispatchTemplateDrop(t){this.applyEmit(t)}applyMove(t,n,o){let a=I(this._scene,t);if(a&&!this.isElementManipulable(a))return;let r=this.interaction.transformShiftKey?XS(n):n,s=this.snapActive()?OD(o,r,this.snapSpacing()):r,i=kD(this._scene,t,s,o);i&&(this._scene=J(this._scene,i),this.recordGesturePatch(i),this.notify())}applyGroupMove(t){if(!this.groupMoveOrigin)return;let n=this.interaction.transformShiftKey?XS(t):t,o=this.snapActive()?DD(this.groupMoveOrigin,n,this.snapSpacing()):n,a=_D(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=pR(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=J(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return bD(this._scene)}computeDirtyWorld(){let t=this.lastRenderedScene,n=this._scene;if(!t||t.viewport.size.width<=0||t.viewport.size.height<=0||n.viewport.size.width<=0||n.viewport.size.height<=0||this.gestureTx!==null||this.dragElementId!==null||this.drawingPreview!==null||this.edgePreview!==null||this.brushStroke!==null||this.lassoPreview!==null||this.interaction.eraseStroke!==null&&this.eraseDirty||t.viewport!==n.viewport||t.layers!==n.layers||this.lastRenderedEnteredGroup!==this._enteredGroup||this.lastRenderedEraseActive)return null;let{world:o,tileDirty:a}=eR(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=AD(this._scene,this._selection);for(let n of this._selectedLinks){let o=ue(this._scene,n);if(!o)continue;let a=ut(this._scene,o);if(!a||a.length===0)continue;let r=1/0,s=1/0,i=-1/0,l=-1/0;for(let u of a)u.x<r&&(r=u.x),u.y<s&&(s=u.y),u.x>i&&(i=u.x),u.y>l&&(l=u.y);let c={x:r,y:s,width:i-r,height:l-s};t=t?j.union(t,c):c}return t}groupChildrenUnion(t){return cg(this._scene,t)}selectionIsAspectLocked(){if(this._selection.size===0)return!1;if(this._selection.size===1){let[t]=[...this._selection];if(!t)return!1;let n=I(this._scene,t)?.type;return n==="group"||n==="image"}for(let t of this._selection){let n=I(this._scene,t);if(n===void 0||!ct(n))return!1}return!0}applyRotate(t){let n=this.rotateGestureOrigin;if(!n)return;let o=this.interaction.transformShiftKey?Math.round(t/xv)*xv:t,a=$S(this._scene,n.origin,n.pivot,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);this.notify()}applyGroupResize(t,n,o){if(!this.groupResizeOrigin)return;let a=this.snapActive()?QS(o,t,n,this.snapSpacing()):n,r=xR(this._scene,this.groupResizeOrigin,t,a,o,this.selectionIsAspectLocked()||this.interaction.transformShiftKey,this.interaction.transformAltKey);this._scene=r.scene;for(let s of r.patches)this.recordGesturePatch(s);this.notify()}applyResize(t,n,o,a){let r=I(this._scene,t);if(r!==void 0&&!pe(r)&&r.rotation!==0){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=yR(this._scene,this.interaction.resizeOriginElement,n,o,this.interaction.transformShiftKey,this.interaction.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let s=this.snapActive()?QS(a,n,o,this.snapSpacing()):o;if(r!==void 0&&pe(r)){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=this.interaction.resizeOriginElement,c=pe(l)?l:r,u=gR(this._scene,c,n,s,a,this.interaction.transformAltKey);if(!u)return;this._scene=u.scene,this.recordGesturePatch(u.patch),this.notify();return}let i=mR(this._scene,t,n,s,a,(l,c,u)=>this.clampContainerToChildren(l,c,u),this.interaction.transformShiftKey,this.interaction.transformAltKey);i&&(this._scene=i.scene,this.recordGesturePatch(i.patch),this.notify())}applyCreate(t,n){let o=Wc(++this.nextId),a=this.snapActive()?PD(n,this.snapSpacing()):n,r=jO(this._scene,t,a,o,this._activeLayerId,()=>this.nextFrameName());this._scene=r.scene,this._selection=wt(o),this._history.push(r.patch),t==="frame"&&this.assignFrameMembers(o,a),this.maybeRevertToolAfterCreate(),this.notify()}nextFrameName(){return G9(this._scene)}assignFrameMembers(t,n){this._scene=W9(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=q9(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=Yp(++this.nextId),r=Xp(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertToolAfterCreate(),o.kind==="point"&&(this.interaction.pendingLinkDropMenu={linkId:a,side:"to",world:o.position}),this.notify()}get linkDropMenu(){return this.interaction.pendingLinkDropMenu}placeShapeAtLinkDrop(t){let n=this.interaction.pendingLinkDropMenu;if(!n)return;if(!ue(this._scene,n.linkId)){this.interaction.pendingLinkDropMenu=null,this.notify();return}let a=Wc(++this.nextId),r=nD(this._scene,this._activeLayerId,n,a,t),s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this.interaction.pendingLinkDropMenu=null,this._selection=wt(a),this._selectedLinks=gt,this.notify()}dismissLinkDropMenu(){this.interaction.pendingLinkDropMenu&&(this.interaction.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=Wc(++this.nextId),a=Yp(++this.nextId),r=eD(this._scene,this._activeLayerId,t,n,o,a);if(!r)return;let s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this._selection=wt(o),this._selectedLinks.size>0&&(this._selectedLinks=gt),this.notify()}previewClickCreate(t,n){return JO(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return WO(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=SD(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=ZS(this._scene,n==="add"?this._selectedLinks:gt,s=>this.isLayerLocked(s),t,n),r=!Vp(a,this._selectedLinks);if(this._selectedLinks=a,ai(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.interaction.lassoBaseSelection??Pe,a=LD(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.interaction.lassoBaseLinks??gt,s=ZS(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!Vp(s,this._selectedLinks);ai(a,this._selection)&&!i||(this._selectedLinks=s,this._selection=a)}applyLinkEndpointMove(t,n,o){this.linkHandles.applyEndpointMove(t,n,o)}applyLinkEndpointUpdate(t){this.linkHandles.applyEndpointUpdate(t)}get isDraggingWaypoint(){return this.linkHandles.isDraggingWaypoint}beginWaypointDrag(t,n,o){this.linkHandles.beginWaypointDrag(t,n,o)}get isDraggingLabel(){return this.linkHandles.isDraggingLabel}beginLabelDrag(t){this.linkHandles.beginLabelDrag(t)}updateLabelDrag(t){this.linkHandles.updateLabelDrag(t)}endLabelDrag(){this.linkHandles.endLabelDrag()}updateWaypointDrag(t){this.linkHandles.updateWaypointDrag(t)}endWaypointDrag(){this.linkHandles.endWaypointDrag()}get isDraggingSegment(){return this.linkHandles.isDraggingSegment}beginSegmentDrag(t,n,o){this.linkHandles.beginSegmentDrag(t,n,o)}updateSegmentDrag(t){this.linkHandles.updateSegmentDrag(t)}endSegmentDrag(){this.linkHandles.endSegmentDrag()}isHandleDoubleClick(t){return this.linkHandles.isHandleDoubleClick(t)}deleteWaypoint(t,n){this.linkHandles.deleteWaypoint(t,n)}resetSegmentPin(t,n,o,a){this.linkHandles.resetSegmentPin(t,n,o,a)}get selectedLinkAvoidsObstacles(){let t=this.selectedLink;return t===null?!1:ue(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=ue(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=Ye(this._scene,n,r=>({...r,avoidObstacles:t,...t?{routing:"orthogonal"}:{}}));this._scene=a.scene,this._history.push(a.patch),this.elbowRoutes.delete(n),this.notify()}updateHoveredLinkTarget(t){let n=this.acceleratedElementAt(t);if(!n){this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null,this.notify());return}let a=this.snapEngine.snap({scene:this._scene,probe:t,threshold:this.snapThreshold,gesture:"draw-edge"}).all.filter(p=>p.metadata?.elementId===n.id),r=a.find(p=>p.kind==="anchor"),s=a.find(p=>p.kind==="outline"),i=r?.metadata?.ref,l=LA(i)?i:void 0,c=null;l?.kind==="named"?c=l.name:l?.kind==="edge"&&l.t===.5&&(c=`edge-${l.index}`);let u=!c&&s?s.snapped:void 0,d=this.hoveredLinkTarget;if(d?.elementId===n.id&&d.activeAnchor===c&&d.outlinePoint?.x===u?.x&&d.outlinePoint?.y===u?.y)return;let f=c!==null||u?"point":"element";this.hoveredLinkTarget={elementId:n.id,activeAnchor:c,outlinePoint:u,mode:f},this.notify()}applyLinkPreview(t,n,o){let a=yD(this._scene,t,n,o);if(mi==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=gv(this._scene,t,a.from,s,a.to);this.edgePreview={...a,points:i}}else this.edgePreview=a;this.notify()}recordGesturePatch(t){this.gestureTx===null&&(this.gestureStartScene=J(this._scene,yc(t))),this.gestures.record(t)}commitGesture(){this.interaction.resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.commit(),this.gestureStartScene=null}finalizeOpenGestureTx(){this.gestures.finalize()}applyContainerDrop(t){nR(this.containerOpsRef,t)}maybeGrowContainer(t,n){Wp(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return tR(this._scene,t,n,o)}beginOrAttachGesture(){return this.gestureTx??=this._history.transaction(),this.gestureTx}cancelGesture(){this.interaction.resizeOriginElement=null,this.interaction.rotateGestureOrigin=null,this.gestures.cancel(),this.gestureStartScene!==null&&(this._scene=this.gestureStartScene,this.gestureStartScene=null)}pruneSelection(){let t=null;for(let n of this._selection)this._scene.elements.has(n)||(t??=new Set(this._selection),t.delete(n));t!==null&&(this._selection=t)}notify(){this.scheduleRender(),j9(this.eventCache,this.events,this.observableSnapshot());for(let t of this.listeners)t();this.autoCompactScheduler.schedule(),this.autoLayoutScheduler.schedule(),this.maybeAnimate()}renderRafId=null;animationContentOff=null;scheduleRender(){if(this.renderRafId===null){if(typeof requestAnimationFrame>"u"){this.render();return}this.renderRafId=requestAnimationFrame(()=>{this.renderRafId=null,this.render()})}}forceRender(){this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null),this.render()}on(t,n){return this.events.on(t,n)}off(t,n){this.events.off(t,n)}runLayout(t){let n=lp(this._scene,t);return n?(this._scene=J(this._scene,n),this._history.push(n),this.autoLayoutScheduler.resetSignature(t),this.notify(),n):null}elbowRoutes=new Map;rerouteElbows(){let t=this._scene;for(let[n,o]of this._scene.links){if((o.routing??"straight")!=="orthogonal")continue;let a=xD(this._scene,o);if(this.elbowRoutes.get(n)?.sig===a)continue;let r=up(t,o);this.elbowRoutes.set(n,{sig:a,points:r}),t=Ye(t,n,s=>({...s,routedPoints:r})).scene}this._scene=t}buildRenderSnapshot(){let t=this.computeStrokeErasePreview(),n=this.computeHiddenElements(),o=t===null?n:new Set([...n??[],...t.hidden]);return{mainTarget:this.mainTarget,overlayTarget:this.overlayTarget,backgroundTarget:this.backgroundTarget,scene:this._scene,selection:this._selection,selectedLinks:this._selectedLinks,selectedLink:this.selectedLink,selectedAnnotation:this._selectedAnnotation,enteredGroup:this._enteredGroup,gridEnabled:this.gridEnabled,viewportWorld:this.computeViewportWorld(),dirtyWorld:this.computeDirtyWorld(),dimElements:this.computeDimSet(),eraseActive:(this.interaction.eraseStroke?.pending.size??0)>0,hideElements:o,strokeErasePreview:t,sharedIndex:this._scene.elements.size>=Rv?this.ensureSpatialIndex():null,boundsCache:this.boundsCache,animationClock:a=>this.gifPlayback.clock(Ze(typeof a.id=="string"?a.id:"")),tileComposeFn:this.tileComposeFn,tileDirtyElements:this.tileDirtyElements,mode:this.activeTool.type,activeLayerId:this._activeLayerId,cropFrame:this.cropFrameCorners(),cropGhost:this.cropGhost(),flowchartPreview:this.flowchartPreview,lassoPreview:this.lassoPreview,drawingPreview:this.drawingPreview,edgePreview:this.edgePreview,linkDragFromAnchor:this.linkDragFromAnchor,hoveredLinkTarget:this.hoveredLinkTarget,panGesture:this.panGesture,pinchActive:this.pinch?.isActive()??!1,gestureActive:this.gestureTx!==null,linkEndpointDrag:this.linkEndpointDrag,linkSegmentDrag:this.linkSegmentDrag,linkWaypointDrag:this.linkWaypointDrag,hoverCursorWorld:this.hoverCursorWorld,anchorStartHitSlop:this.anchorStartHitSlop,anchorClickRadius:this.anchorClickRadius,containerHover:this.containerHover,brushStroke:this.brushPreviewStroke,laserStrokes:this.interaction.laserStrokes,eraserTrail:this.interaction.eraserTrail,eraserCursor:this.activeTool.type==="erase"&&!this._readOnly&&this.lastPointerWorld!==null?{center:this.lastPointerWorld,radius:this._brushSettings.width}:null,peerCursors:this._peerCursors,peerSelections:this._peerSelections,debugHitZones:this.debugHitZones,readOnly:this._readOnly,groupMoveOrigin:this.groupMoveOrigin,aspectLocked:this.selectionIsAspectLocked(),combinedSelectionBounds:this.combinedSelectionBounds(),editingText:this.editingTextOverlay(),previewClickCreate:(a,r)=>this.previewClickCreate(a,r),isPlaybackPaused:a=>this.isPlaybackPaused(a)}}render(){this.rerouteElbows(),this.pruneLaser();let t=this.buildRenderSnapshot();hD(t),this.lastRenderedScene=this._scene,this.lastRenderedEnteredGroup=this._enteredGroup,this.lastRenderedEraseActive=t.eraseActive,this.eraseDirty=!1;let n=t.dimElements!==void 0&&t.dimElements.size>0||t.hideElements!==void 0&&t.hideElements.size>0;t.tileComposeFn&&t.viewportWorld&&!n&&(this.tileDirtyElements=new Map),this.onAfterRender?.()}},PV=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var JS=P(se(),1),jc=P(re(),1),dg=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,jc.useRef)(null),l=(0,jc.useRef)(null);if((0,jc.useEffect)(()=>{if(!e)return;l.current=document.activeElement;let d=p=>{p.key==="Escape"&&(p.preventDefault(),t())};window.addEventListener("keydown",d);let f=i.current;return f&&(f.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??f).focus(),()=>{window.removeEventListener("keydown",d),l.current?.focus()}},[e,t]),(0,jc.useEffect)(()=>{if(!e)return;let d=f=>{if(f.key!=="Tab")return;let p=i.current;if(!p)return;let h=p.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(h.length===0)return;let m=h[0],x=h[h.length-1];if(m===void 0||x===void 0)return;let y=document.activeElement;f.shiftKey&&y===m?(f.preventDefault(),x.focus()):!f.shiftKey&&y===x&&(f.preventDefault(),m.focus())};return window.addEventListener("keydown",d,!0),()=>{window.removeEventListener("keydown",d,!0)}},[e]),!e)return null;let c={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},u={background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderRadius:8,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.45)",maxWidth:"calc(100vw - 64px)",maxHeight:"calc(100vh - 64px)",overflow:"auto",outline:"none",...s};return(0,JS.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,JS.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var BV={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",tool:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},NV=["tool","edit","selection","clipboard","history","z-order","grouping","arrange","layout","zoom","other"],eL=e=>{(0,Zc.useEffect)(()=>{let t=n=>{let o=n.target;o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||!(n.key==="?"||n.shiftKey&&n.key==="/")||(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e])},zV=e=>{let t=[],n=e.hotkey??e.displayHotkey;if(n){let o=Array.isArray(n)?n:[n];for(let a of o)t.push(Fy(a))}if(e.sequence&&e.sequence.length>0){let o=e.sequence.map(a=>a.length===1?a.toUpperCase():a).join(" ");t.push([o])}return t},$p=({registry:e=we,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,Zc.useMemo)(()=>{let c=new Map;for(let d of e.getAll()){if(!d.label)continue;let f=d.category??"other",p=c.get(f)??[];p.push({label:d.label,keys:zV(d)}),c.set(f,p)}let u=[];for(let d of NV){let f=c.get(d);!f||f.length===0||u.push({title:BV[d],rows:f})}return a&&u.push(...a),u},[e,a]),s={maxWidth:720,width:"calc(100vw - 64px)",display:"flex",flexDirection:"column"},i={padding:"16px 20px",borderBottom:"1px solid var(--du-ui-border)",display:"flex",alignItems:"center",justifyContent:"space-between"},l={padding:"16px 20px 20px",overflowY:"auto"};return(0,Ke.jsx)(dg,{open:t,onClose:n,title:o,style:s,children:(0,Ke.jsxs)("div",{children:[(0,Ke.jsxs)("div",{style:i,children:[(0,Ke.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,Ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,Ke.jsx)("span",{className:"du-help-platform-badge",children:ss?"macOS":"Win / Linux"}),(0,Ke.jsx)("button",{type:"button","aria-label":"Close help",onClick:n,style:{background:"transparent",border:"none",color:"var(--du-text)",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:4},children:(0,Ke.jsx)(Fa,{size:18,strokeWidth:1.75})})]})]}),(0,Ke.jsx)("div",{style:l,children:(0,Ke.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,Ke.jsxs)("section",{className:"du-help-island",children:[(0,Ke.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,Ke.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,Ke.jsxs)("div",{className:"du-help-row",children:[(0,Ke.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,Ke.jsx)(FV,{combos:u.keys})]},u.label))})]},c.title))})})]})})},FV=({combos:e})=>e.length===0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,Ke.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,Ke.jsxs)(Zc.Fragment,{children:[n>0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,Ke.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var HV=16,UV=1.75,fg=({renderDialog:e})=>{let[t,n]=(0,BD.useState)(!1);return(0,is.jsxs)(is.Fragment,{children:[(0,is.jsx)(Jn,{label:"Help",onClick:()=>{n(!0)},children:(0,is.jsx)(Cn,{size:HV,strokeWidth:UV})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,is.jsx)($p,{open:t,onClose:()=>{n(!1)}})]})};var th=P(se(),1),zD=P(re(),1);var Qp=P(re(),1);var ND=`(pointer: coarse), (max-width: ${640}px)`,GV=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(ND).matches:!1,Jp=()=>(0,Qp.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(ND);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},GV,()=>!1),U=()=>Yb(),WV=ov(),Ka=()=>sn(e=>e.scene,WV,"scene"),pg=()=>sn(e=>e.selection,Zo.EMPTY,"selection"),qV={type:"select",locked:!1,lastActiveTool:null},eh=()=>sn(e=>e.activeTool,qV,"tool"),tL=()=>sn(e=>e.brushSettings,Gc),ls=()=>sn(e=>e.readOnly,!1),nL=()=>{let e=U(),t=sn(r=>r.canUndo,!1,"history"),n=sn(r=>r.canRedo,!1,"history"),o=(0,Qp.useCallback)(()=>{e?.undo()},[e]),a=(0,Qp.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var P0e=ln(On);var oL=()=>sn(e=>e.selectedLink,null);var VV=14,jV=1.75,aL=()=>{let e=U(),t=Ka(),n=(0,zD.useMemo)(()=>ZV(t),[t]);return!e||t.elements.size===0||!n?null:(0,th.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,th.jsx)(ef,{size:VV,strokeWidth:jV,"aria-hidden":!0}),(0,th.jsx)("span",{children:"Back to content"})]})},ZV=e=>{if(e.elements.size===0)return!1;let t=e.viewport;if(t.size.width<=0||t.size.height<=0)return!1;let n=null;for(let c of e.elements.values()){let u=N(c);n=n?j.union(n,u):u}if(!n)return!1;let o=qa(t),a=z.applyToPoint(o,{x:0,y:0}),r=z.applyToPoint(o,{x:t.size.width,y:t.size.height}),s={x:Math.min(a.x,r.x),y:Math.min(a.y,r.y),width:Math.abs(r.x-a.x),height:Math.abs(r.y-a.y)},i=n.x<s.x+s.width&&s.x<n.x+n.width,l=n.y<s.y+s.height&&s.y<n.y+n.height;return!(i&&l)};var mn=P(se(),1),$i=P(re(),1);var xt=P(se(),1),uo=P(re(),1);var hg=class{items=new Map;register(t){if(this.items.has(t.id))throw new Error(`Template already registered: ${t.id}`);this.items.set(t.id,t)}replace(t){this.items.set(t.id,t)}get(t){return this.items.get(t)}has(t){return this.items.has(t)}list(){return[...this.items.values()]}byCategory(t){return this.list().filter(n=>n.category===t)}categories(){let t=new Set;for(let n of this.items.values())t.add(n.category);return[...t]}clear(){this.items.clear()}},Di=new hg;var q0e={...os.rectangle},V0e={...os.sticky},j0e={...os.flowchart};var rL=(e,t)=>{let n=t.trim().toLowerCase();if(!n||e.name.toLowerCase().includes(n)||typeof e.category=="string"&&e.category.toLowerCase().includes(n))return!0;if(e.tags){for(let o of e.tags)if(o.toLowerCase().includes(n))return!0}return!1};var T={};yo(T,{BRAND:()=>bj,DIRTY:()=>Pi,EMPTY_PATH:()=>$V,INVALID:()=>Z,NEVER:()=>oZ,OK:()=>Wt,ParseStatus:()=>Bt,Schema:()=>le,ZodAny:()=>ds,ZodArray:()=>er,ZodBigInt:()=>Ni,ZodBoolean:()=>zi,ZodBranded:()=>oh,ZodCatch:()=>Yi,ZodDate:()=>Fi,ZodDefault:()=>Xi,ZodDiscriminatedUnion:()=>gg,ZodEffects:()=>co,ZodEnum:()=>ji,ZodError:()=>pn,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>bg,ZodIntersection:()=>Wi,ZodIssueCode:()=>D,ZodLazy:()=>qi,ZodLiteral:()=>Vi,ZodMap:()=>Jc,ZodNaN:()=>tu,ZodNativeEnum:()=>Zi,ZodNever:()=>Io,ZodNull:()=>Ui,ZodNullable:()=>sa,ZodNumber:()=>Bi,ZodObject:()=>hn,ZodOptional:()=>io,ZodParsedType:()=>H,ZodPipeline:()=>ah,ZodPromise:()=>fs,ZodReadonly:()=>Ki,ZodRecord:()=>xg,ZodSchema:()=>le,ZodSet:()=>eu,ZodString:()=>us,ZodSymbol:()=>$c,ZodTransformer:()=>co,ZodTuple:()=>ra,ZodType:()=>le,ZodUndefined:()=>Hi,ZodUnion:()=>Gi,ZodUnknown:()=>Ja,ZodVoid:()=>Qc,addIssueToContext:()=>F,any:()=>Ej,array:()=>Rj,bigint:()=>Lj,boolean:()=>YD,coerce:()=>nZ,custom:()=>jD,date:()=>kj,datetimeRegex:()=>qD,defaultErrorMap:()=>$a,discriminatedUnion:()=>Bj,effect:()=>Xj,enum:()=>Vj,function:()=>Gj,getErrorMap:()=>Xc,getParsedType:()=>aa,instanceof:()=>vj,intersection:()=>Nj,isAborted:()=>mg,isAsync:()=>Yc,isDirty:()=>yg,isValid:()=>cs,late:()=>Aj,lazy:()=>Wj,literal:()=>qj,makeIssue:()=>nh,map:()=>Hj,nan:()=>Sj,nativeEnum:()=>jj,never:()=>Ij,null:()=>Tj,nullable:()=>Kj,number:()=>XD,object:()=>Oj,objectUtil:()=>sL,oboolean:()=>tZ,onumber:()=>eZ,optional:()=>Yj,ostring:()=>Jj,pipeline:()=>Qj,preprocess:()=>$j,promise:()=>Zj,quotelessJson:()=>XV,record:()=>Fj,set:()=>Uj,setErrorMap:()=>KV,strictObject:()=>Dj,string:()=>ZD,symbol:()=>_j,transformer:()=>Xj,tuple:()=>zj,undefined:()=>wj,union:()=>Pj,unknown:()=>Cj,util:()=>he,void:()=>Mj});var he;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{let r={};for(let s of a)r[s]=s;return r},e.getValidEnumValues=a=>{let r=e.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),s={};for(let i of r)s[i]=a[i];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(r){return a[r]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let r=[];for(let s in a)Object.prototype.hasOwnProperty.call(a,s)&&r.push(s);return r},e.find=(a,r)=>{for(let s of a)if(r(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,r=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(r)}e.joinValues=o,e.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(he||(he={}));var sL;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(sL||(sL={}));var H=he.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),aa=e=>{switch(typeof e){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(e)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?H.promise:typeof Map<"u"&&e instanceof Map?H.map:typeof Set<"u"&&e instanceof Set?H.set:typeof Date<"u"&&e instanceof Date?H.date:H.object;default:return H.unknown}};var D=he.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),XV=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),pn=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(r){return r.message},o={_errors:[]},a=r=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)o._errors.push(n(s));else{let i=o,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(n(s))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return a(this),o}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,he.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},o=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}};pn.create=e=>new pn(e);var YV=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===H.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,he.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${he.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${he.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${he.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n="Invalid function arguments";break;case D.invalid_return_type:n="Invalid function return type";break;case D.invalid_date:n="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:he.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case D.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case D.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case D.custom:n="Invalid input";break;case D.invalid_intersection_types:n="Intersection results could not be merged";break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n="Number must be finite";break;default:n=t.defaultError,he.assertNever(e)}return{message:n}},$a=YV;var FD=$a;function KV(e){FD=e}function Xc(){return FD}var nh=e=>{let{data:t,path:n,errorMaps:o,issueData:a}=e,r=[...n,...a.path||[]],s={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let i="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)i=c(s,{data:t,defaultError:i}).message;return{...a,path:r,message:i}},$V=[];function F(e,t){let n=Xc(),o=nh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$a?void 0:$a].filter(a=>!!a)});e.common.issues.push(o)}var Bt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let o=[];for(let a of n){if(a.status==="aborted")return Z;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){let o=[];for(let a of n){let r=await a.key,s=await a.value;o.push({key:r,value:s})}return e.mergeObjectSync(t,o)}static mergeObjectSync(t,n){let o={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted"||s.status==="aborted")return Z;r.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(o[r.value]=s.value)}return{status:t.value,value:o}}},Z=Object.freeze({status:"aborted"}),Pi=e=>({status:"dirty",value:e}),Wt=e=>({status:"valid",value:e}),mg=e=>e.status==="aborted",yg=e=>e.status==="dirty",cs=e=>e.status==="valid",Yc=e=>typeof Promise<"u"&&e instanceof Promise;var q;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(q||(q={}));var lo=class{constructor(t,n,o,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},HD=(e,t)=>{if(cs(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new pn(e.common.issues);return this._error=n,this._error}}};function ae(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:o,description:a}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,i)=>{let{message:l}=e;return s.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??o??i.defaultError}:s.code!=="invalid_type"?{message:i.defaultError}:{message:l??n??i.defaultError}},description:a}}var le=class{get description(){return this._def.description}_getType(t){return aa(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Bt,ctx:{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(Yc(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){let o={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:aa(t)},a=this._parseSync({data:t,path:o.path,parent:o});return HD(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:aa(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return cs(o)?{value:o.value}:{issues:n.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>cs(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){let o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){let o={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:aa(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(Yc(a)?a:Promise.resolve(a));return HD(o,r)}refine(t,n){let o=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{let s=t(a),i=()=>r.addIssue({code:D.custom,...o(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(i(),!1)):s?!0:(i(),!1)})}refinement(t,n){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof n=="function"?n(o,a):n),!1))}_refinement(t){return new co({schema:this,typeName:Y.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return io.create(this,this._def)}nullable(){return sa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return fs.create(this,this._def)}or(t){return Gi.create([this,t],this._def)}and(t){return Wi.create(this,t,this._def)}transform(t){return new co({...ae(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Xi({...ae(this._def),innerType:this,defaultValue:n,typeName:Y.ZodDefault})}brand(){return new oh({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Yi({...ae(this._def),innerType:this,catchValue:n,typeName:Y.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return ah.create(this,t)}readonly(){return Ki.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},QV=/^c[^\s-]{8,}$/i,JV=/^[0-9a-z]+$/,ej=/^[0-9A-HJKMNP-TV-Z]{26}$/i,tj=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nj=/^[a-z0-9_-]{21}$/i,oj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,aj=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,rj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",iL,ij=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,lj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,cj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,uj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,dj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fj=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,GD="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",pj=new RegExp(`^${GD}$`);function WD(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function hj(e){return new RegExp(`^${WD(e)}$`)}function qD(e){let t=`${GD}T${WD(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function mj(e,t){return!!((t==="v4"||!t)&&ij.test(e)||(t==="v6"||!t)&&cj.test(e))}function yj(e,t){if(!oj.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function gj(e,t){return!!((t==="v4"||!t)&&lj.test(e)||(t==="v6"||!t)&&uj.test(e))}var us=class e extends le{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==H.string){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.string,received:r.parsedType}),Z}let o=new Bt,a;for(let r of this._def.checks)if(r.kind==="min")t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="max")t.data.length>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="length"){let s=t.data.length>r.value,i=t.data.length<r.value;(s||i)&&(a=this._getOrReturnCtx(t,a),s?F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")rj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"email",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")iL||(iL=new RegExp(sj,"u")),iL.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"emoji",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")tj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"uuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")nj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"nanoid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")QV.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")JV.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid2",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")ej.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ulid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),F(a,{validation:"url",code:D.invalid_string,message:r.message}),o.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"regex",code:D.invalid_string,message:r.message}),o.dirty())):r.kind==="trim"?t.data=t.data.trim():r.kind==="includes"?t.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),o.dirty()):r.kind==="toLowerCase"?t.data=t.data.toLowerCase():r.kind==="toUpperCase"?t.data=t.data.toUpperCase():r.kind==="startsWith"?t.data.startsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{startsWith:r.value},message:r.message}),o.dirty()):r.kind==="endsWith"?t.data.endsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?qD(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?pj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?hj(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?aj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?mj(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ip",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?yj(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"jwt",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?gj(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cidr",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?dj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?fj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):he.assertNever(r);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(a=>t.test(a),{validation:n,code:D.invalid_string,...q.errToObj(o)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...q.errToObj(t)})}url(t){return this._addCheck({kind:"url",...q.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...q.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...q.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...q.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...q.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...q.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...q.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...q.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...q.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...q.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...q.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...q.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...q.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...q.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...q.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...q.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...q.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...q.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...q.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...q.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...q.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...q.errToObj(n)})}nonempty(t){return this.min(1,q.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};us.create=e=>new us({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function xj(e,t){let n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=n>o?n:o,r=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return r%s/10**a}var Bi=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==H.number){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.number,received:r.parsedType}),Z}let o,a=new Bt;for(let r of this._def.checks)r.kind==="int"?he.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?xj(t.data,r.value)!==0&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_finite,message:r.message}),a.dirty()):he.assertNever(r);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:q.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:q.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&he.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Bi.create=e=>new Bi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var Ni=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==H.bigint)return this._getInvalidInput(t);let o,a=new Bt;for(let r of this._def.checks)r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?t.data%r.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):he.assertNever(r);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.bigint,received:n.parsedType}),Z}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Ni.create=e=>new Ni({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var zi=class extends le{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==H.boolean){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.boolean,received:o.parsedType}),Z}return Wt(t.data)}};zi.create=e=>new zi({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var Fi=class e extends le{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==H.date){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.date,received:r.parsedType}),Z}if(Number.isNaN(t.data.getTime())){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_date}),Z}let o=new Bt,a;for(let r of this._def.checks)r.kind==="min"?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),o.dirty()):r.kind==="max"?t.data.getTime()>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),o.dirty()):he.assertNever(r);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:q.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:q.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};Fi.create=e=>new Fi({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var $c=class extends le{_parse(t){if(this._getType(t)!==H.symbol){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.symbol,received:o.parsedType}),Z}return Wt(t.data)}};$c.create=e=>new $c({typeName:Y.ZodSymbol,...ae(e)});var Hi=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.undefined,received:o.parsedType}),Z}return Wt(t.data)}};Hi.create=e=>new Hi({typeName:Y.ZodUndefined,...ae(e)});var Ui=class extends le{_parse(t){if(this._getType(t)!==H.null){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.null,received:o.parsedType}),Z}return Wt(t.data)}};Ui.create=e=>new Ui({typeName:Y.ZodNull,...ae(e)});var ds=class extends le{constructor(){super(...arguments),this._any=!0}_parse(t){return Wt(t.data)}};ds.create=e=>new ds({typeName:Y.ZodAny,...ae(e)});var Ja=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Wt(t.data)}};Ja.create=e=>new Ja({typeName:Y.ZodUnknown,...ae(e)});var Io=class extends le{_parse(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),Z}};Io.create=e=>new Io({typeName:Y.ZodNever,...ae(e)});var Qc=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.void,received:o.parsedType}),Z}return Wt(t.data)}};Qc.create=e=>new Qc({typeName:Y.ZodVoid,...ae(e)});var er=class e extends le{_parse(t){let{ctx:n,status:o}=this._processInputParams(t),a=this._def;if(n.parsedType!==H.array)return F(n,{code:D.invalid_type,expected:H.array,received:n.parsedType}),Z;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(s||i)&&(F(n,{code:s?D.too_big:D.too_small,minimum:i?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(F(n,{code:D.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(F(n,{code:D.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((s,i)=>a.type._parseAsync(new lo(n,s,n.path,i)))).then(s=>Bt.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new lo(n,s,n.path,i)));return Bt.mergeArray(o,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:q.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:q.toString(n)}})}nonempty(t){return this.min(1,t)}};er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function Kc(e){if(e instanceof hn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=io.create(Kc(o))}return new hn({...e._def,shape:()=>t})}else return e instanceof er?new er({...e._def,type:Kc(e.element)}):e instanceof io?io.create(Kc(e.unwrap())):e instanceof sa?sa.create(Kc(e.unwrap())):e instanceof ra?ra.create(e.items.map(t=>Kc(t))):e}var hn=class e extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=he.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==H.object){let c=this._getOrReturnCtx(t);return F(c,{code:D.invalid_type,expected:H.object,received:c.parsedType}),Z}let{status:o,ctx:a}=this._processInputParams(t),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof Io&&this._def.unknownKeys==="strip"))for(let c in a.data)s.includes(c)||i.push(c);let l=[];for(let c of s){let u=r[c],d=a.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new lo(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Io){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of i)l.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(c==="strict")i.length>0&&(F(a,{code:D.unrecognized_keys,keys:i}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of i){let d=a.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new lo(a,d,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Bt.mergeObjectSync(o,c)):Bt.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(t){return q.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{let a=this._def.errorMap?.(n,o).message??o.defaultError;return n.code==="unrecognized_keys"?{message:q.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let o of he.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let o of he.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return Kc(this)}partial(t){let n={};for(let o of he.objectKeys(this.shape)){let a=this.shape[o];t&&!t[o]?n[o]=a:n[o]=a.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let o of he.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof io;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return VD(he.objectKeys(this.shape))}};hn.create=(e,t)=>new hn({shape:()=>e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.strictCreate=(e,t)=>new hn({shape:()=>e,unknownKeys:"strict",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.lazycreate=(e,t)=>new hn({shape:e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});var Gi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=this._def.options;function a(r){for(let i of r)if(i.result.status==="valid")return i.result;for(let i of r)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let s=r.map(i=>new pn(i.ctx.common.issues));return F(n,{code:D.invalid_union,unionErrors:s}),Z}if(n.common.async)return Promise.all(o.map(async r=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);{let r,s=[];for(let l of o){let c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!r&&(r={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let i=s.map(l=>new pn(l));return F(n,{code:D.invalid_union,unionErrors:i}),Z}}get options(){return this._def.options}};Gi.create=(e,t)=>new Gi({options:e,typeName:Y.ZodUnion,...ae(t)});var Qa=e=>e instanceof qi?Qa(e.schema):e instanceof co?Qa(e.innerType()):e instanceof Vi?[e.value]:e instanceof ji?e.options:e instanceof Zi?he.objectValues(e.enum):e instanceof Xi?Qa(e._def.innerType):e instanceof Hi?[void 0]:e instanceof Ui?[null]:e instanceof io?[void 0,...Qa(e.unwrap())]:e instanceof sa?[null,...Qa(e.unwrap())]:e instanceof oh||e instanceof Ki?Qa(e.unwrap()):e instanceof Yi?Qa(e._def.innerType):[],gg=class e extends le{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.object)return F(n,{code:D.invalid_type,expected:H.object,received:n.parsedType}),Z;let o=this.discriminator,a=n.data[o],r=this.optionsMap.get(a);return r?n.common.async?r._parseAsync({data:n.data,path:n.path,parent:n}):r._parseSync({data:n.data,path:n.path,parent:n}):(F(n,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,o){let a=new Map;for(let r of n){let s=Qa(r.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let i of s){if(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,r)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...ae(o)})}};function lL(e,t){let n=aa(e),o=aa(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&o===H.object){let a=he.objectKeys(t),r=he.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=lL(e[i],t[i]);if(!l.valid)return{valid:!1};s[i]=l.data}return{valid:!0,data:s}}else if(n===H.array&&o===H.array){if(e.length!==t.length)return{valid:!1};let a=[];for(let r=0;r<e.length;r++){let s=e[r],i=t[r],l=lL(s,i);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===H.date&&o===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Wi=class extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(mg(r)||mg(s))return Z;let i=lL(r.value,s.value);return i.valid?((yg(r)||yg(s))&&n.dirty(),{status:n.value,value:i.data}):(F(o,{code:D.invalid_intersection_types}),Z)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([r,s])=>a(r,s)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};Wi.create=(e,t,n)=>new Wi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var ra=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.array)return F(o,{code:D.invalid_type,expected:H.array,received:o.parsedType}),Z;if(o.data.length<this._def.items.length)return F(o,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&o.data.length>this._def.items.length&&(F(o,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let r=[...o.data].map((s,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new lo(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Bt.mergeArray(n,s)):Bt.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ra.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ra({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var xg=class e extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.object)return F(o,{code:D.invalid_type,expected:H.object,received:o.parsedType}),Z;let a=[],r=this._def.keyType,s=this._def.valueType;for(let i in o.data)a.push({key:r._parse(new lo(o,i,o.path,i)),value:s._parse(new lo(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Bt.mergeObjectAsync(n,a):Bt.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof le?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...ae(o)}):new e({keyType:us.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},Jc=class extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.map)return F(o,{code:D.invalid_type,expected:H.map,received:o.parsedType}),Z;let a=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([i,l],c)=>({key:a._parse(new lo(o,i,o.path,[c,"key"])),value:r._parse(new lo(o,l,o.path,[c,"value"]))}));if(o.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let l of s){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}}}};Jc.create=(e,t,n)=>new Jc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var eu=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.set)return F(o,{code:D.invalid_type,expected:H.set,received:o.parsedType}),Z;let a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(F(o,{code:D.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(F(o,{code:D.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let r=this._def.valueType;function s(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Z;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}let i=[...o.data.values()].map((l,c)=>r._parse(new lo(o,l,o.path,c)));return o.common.async?Promise.all(i).then(l=>s(l)):s(i)}min(t,n){return new e({...this._def,minSize:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:q.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};eu.create=(e,t)=>new eu({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var bg=class e extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.function)return F(n,{code:D.invalid_type,expected:H.function,received:n.parsedType}),Z;function o(i,l){return nh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Xc(),$a].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return nh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Xc(),$a].filter(c=>!!c),issueData:{code:D.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof fs){let i=this;return Wt(async function(...l){let c=new pn([]),u=await i._def.args.parseAsync(l,r).catch(p=>{throw c.addIssue(o(l,p)),c}),d=await Reflect.apply(s,this,u);return await i._def.returns._def.type.parseAsync(d,r).catch(p=>{throw c.addIssue(a(d,p)),c})})}else{let i=this;return Wt(function(...l){let c=i._def.args.safeParse(l,r);if(!c.success)throw new pn([o(l,c.error)]);let u=Reflect.apply(s,this,c.data),d=i._def.returns.safeParse(u,r);if(!d.success)throw new pn([a(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:ra.create(t).rest(Ja.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,o){return new e({args:t||ra.create([]).rest(Ja.create()),returns:n||Ja.create(),typeName:Y.ZodFunction,...ae(o)})}},qi=class extends le{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};qi.create=(e,t)=>new qi({getter:e,typeName:Y.ZodLazy,...ae(t)});var Vi=class extends le{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return F(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:t.data}}get value(){return this._def.value}};Vi.create=(e,t)=>new Vi({value:e,typeName:Y.ZodLiteral,...ae(t)});function VD(e,t){return new ji({values:e,typeName:Y.ZodEnum,...ae(t)})}var ji=class e extends le{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{expected:he.joinValues(o),received:n.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{received:n.data,code:D.invalid_enum_value,options:o}),Z}return Wt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}};ji.create=VD;var Zi=class extends le{_parse(t){let n=he.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==H.string&&o.parsedType!==H.number){let a=he.objectValues(n);return F(o,{expected:he.joinValues(a),received:o.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(he.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=he.objectValues(n);return F(o,{received:o.data,code:D.invalid_enum_value,options:a}),Z}return Wt(t.data)}get enum(){return this._def.values}};Zi.create=(e,t)=>new Zi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var fs=class extends le{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.promise&&n.common.async===!1)return F(n,{code:D.invalid_type,expected:H.promise,received:n.parsedType}),Z;let o=n.parsedType===H.promise?n.data:Promise.resolve(n.data);return Wt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};fs.create=(e,t)=>new fs({type:e,typeName:Y.ZodPromise,...ae(t)});var co=class extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=this._def.effect||null,r={addIssue:s=>{F(o,s),s.fatal?n.abort():n.dirty()},get path(){return o.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(o.data,r);if(o.common.async)return Promise.resolve(s).then(async i=>{if(n.value==="aborted")return Z;let l=await this._def.schema._parseAsync({data:i,path:o.path,parent:o});return l.status==="aborted"?Z:l.status==="dirty"?Pi(l.value):n.value==="dirty"?Pi(l.value):l});{if(n.value==="aborted")return Z;let i=this._def.schema._parseSync({data:s,path:o.path,parent:o});return i.status==="aborted"?Z:i.status==="dirty"?Pi(i.value):n.value==="dirty"?Pi(i.value):i}}if(a.type==="refinement"){let s=i=>{let l=a.refinement(i,r);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(o.common.async===!1){let i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(o.common.async===!1){let s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!cs(s))return Z;let i=a.transform(s.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>cs(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):Z);he.assertNever(a)}};co.create=(e,t,n)=>new co({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});co.createWithPreprocess=(e,t,n)=>new co({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var io=class extends le{_parse(t){return this._getType(t)===H.undefined?Wt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};io.create=(e,t)=>new io({innerType:e,typeName:Y.ZodOptional,...ae(t)});var sa=class extends le{_parse(t){return this._getType(t)===H.null?Wt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sa.create=(e,t)=>new sa({innerType:e,typeName:Y.ZodNullable,...ae(t)});var Xi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return n.parsedType===H.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Xi.create=(e,t)=>new Xi({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var Yi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Yc(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};Yi.create=(e,t)=>new Yi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var tu=class extends le{_parse(t){if(this._getType(t)!==H.nan){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.nan,received:o.parsedType}),Z}return{status:"valid",value:t.data}}};tu.create=e=>new tu({typeName:Y.ZodNaN,...ae(e)});var bj=Symbol("zod_brand"),oh=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}},ah=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Z:r.status==="dirty"?(n.dirty(),Pi(r.value)):this._def.out._parseAsync({data:r.value,path:o.path,parent:o})})();{let a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Z:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},Ki=class extends le{_parse(t){let n=this._def.innerType._parse(t),o=a=>(cs(a)&&(a.value=Object.freeze(a.value)),a);return Yc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Ki.create=(e,t)=>new Ki({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function UD(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function jD(e,t={},n){return e?ds.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=UD(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=UD(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):ds.create()}var Aj={object:hn.lazycreate},Y;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Y||(Y={}));var vj=(e,t={message:`Input not instance of ${e.name}`})=>jD(n=>n instanceof e,t),ZD=us.create,XD=Bi.create,Sj=tu.create,Lj=Ni.create,YD=zi.create,kj=Fi.create,_j=$c.create,wj=Hi.create,Tj=Ui.create,Ej=ds.create,Cj=Ja.create,Ij=Io.create,Mj=Qc.create,Rj=er.create,Oj=hn.create,Dj=hn.strictCreate,Pj=Gi.create,Bj=gg.create,Nj=Wi.create,zj=ra.create,Fj=xg.create,Hj=Jc.create,Uj=eu.create,Gj=bg.create,Wj=qi.create,qj=Vi.create,Vj=ji.create,jj=Zi.create,Zj=fs.create,Xj=co.create,Yj=io.create,Kj=sa.create,$j=co.createWithPreprocess,Qj=ah.create,Jj=()=>ZD().optional(),eZ=()=>XD().optional(),tZ=()=>YD().optional(),nZ={string:(e=>us.create({...e,coerce:!0})),number:(e=>Bi.create({...e,coerce:!0})),boolean:(e=>zi.create({...e,coerce:!0})),bigint:(e=>Ni.create({...e,coerce:!0})),date:(e=>Fi.create({...e,coerce:!0}))};var oZ=Z;var rZ=["basic","layout","flowchart","custom","rich"],cL=({registry:e=Di,categories:t=rZ,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,uo.useMemo)(()=>new Set(e.categories()),[e]),c=(0,uo.useMemo)(()=>t.filter(x=>l.has(x)),[t,l]),u=(0,uo.useMemo)(()=>c.map(x=>({category:x,items:e.byCategory(x)})),[e,c]),[d,f]=(0,uo.useState)(()=>new Set(n)),p=x=>{f(y=>{let g=new Set(y);return g.has(x)?g.delete(x):g.add(x),g})},h=o?.trim()??"",m=(0,uo.useMemo)(()=>{if(!h)return[];let x=[];for(let{items:y}of u)for(let g of y)rL(g,h)&&x.push(g);return x},[u,h]);return(0,xt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,xt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,xt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,xt.jsx)("div",{className:i,children:m.map(x=>(0,xt.jsx)(JD,{template:x},x.id))}):u.map(({category:x,items:y})=>(0,xt.jsx)(sZ,{category:x,items:y,itemsClass:i,collapsed:d.has(x),onToggle:()=>{p(x)}},x))})})},sZ=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,xt.jsxs)("section",{className:"du-palette-section",children:[(0,xt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,xt.jsx)("span",{children:e}),(0,xt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,xt.jsx)(Ys,{size:12,strokeWidth:1.75}):(0,xt.jsx)(Dd,{size:12,strokeWidth:1.75})})]}),o?null:(0,xt.jsx)("div",{className:n,children:t.map(r=>(0,xt.jsx)(JD,{template:r},r.id))})]}),rh=null,$D=yS(),KD=e=>{rh!==e&&(rh=e,$D.emit())};var QD=e=>$D.add(e);var Ag=null,iZ=()=>{if(typeof document>"u")return null;if(Ag&&document.body.contains(Ag))return Ag;let e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;top:-1000px;left:-1000px;width:1px;height:1px;background:rgba(0,0,0,0.01)",document.body.appendChild(e),Ag=e,e},JD=({template:e})=>{let t=U(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=iZ();s&&r.dataTransfer.setDragImage(s,0,0),KD(e)},o=()=>{KD(null)},a=()=>{if(!t||typeof window<"u"&&!window.matchMedia("(pointer: coarse)").matches)return;let s=t.hostElement.getBoundingClientRect(),i=t.screenToWorld({x:s.width/2,y:s.height/2}),l=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),c=e.factory({id:l,layerId:On,position:i,order:Ae([...t.scene.elements.values()].filter(d=>d.layerId===On).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,xt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,xt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,xt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},uL=()=>{let e=U(),t=(0,uo.useRef)(null);(0,uo.useEffect)(()=>{let a=r=>{r.key!=="Escape"||!t.current||(t.current.cancel(),t.current=null)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[]),(0,uo.useEffect)(()=>QD(()=>{rh===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!rh)return!1;let r=rh,s=a.currentTarget.getBoundingClientRect(),i={x:a.clientX-s.left,y:a.clientY-s.top},l=e.screenToWorld(i),c=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),u=r.factory({id:c,layerId:On,position:l,order:Ae([...e.scene.elements.values()].filter(d=>d.layerId===On).map(d=>d.order))});return t.current=e.beginPlacement(u),t.current.update(l),!0},o=a=>{if(!e)return null;let r=a.currentTarget.getBoundingClientRect();return e.screenToWorld({x:a.clientX-r.left,y:a.clientY-r.top})};return{onDragEnter:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");!s&&!i||(a.preventDefault(),s&&n(a))},onDragOver:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");if(!(!s&&!i)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy",s)){t.current||n(a);let l=o(a);l&&t.current&&t.current.update(l)}},onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||t.current&&(t.current.cancel(),t.current=null)},onDrop:a=>{if(a.preventDefault(),t.current){let l=o(a);l&&t.current.update(l),t.current.commit(),t.current=null;return}let r=a.dataTransfer;if(!r)return;let i=o(a)??{x:0,y:0};e&&(async()=>{for await(let l of AS(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var dL=14,fL=1.75,vg=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,$i.useState)("");(0,$i.useEffect)(()=>{e||i("")},[e]);let l=(0,$i.useRef)(null);return(0,$i.useEffect)(()=>{e&&l.current?.focus()},[e]),e?(0,mn.jsxs)("aside",{className:`du-side-panel ${o?"du-side-panel-sheet":n==="right"?"du-side-panel-right":"du-side-panel-left"}`,style:r,children:[(0,mn.jsx)("header",{className:"du-side-panel-header",children:(0,mn.jsxs)("div",{style:{display:"inline-flex",gap:4},children:[a?(0,mn.jsx)(Jn,{label:"Import templates",size:"sm",onClick:a,children:(0,mn.jsx)(kf,{size:dL,strokeWidth:fL})}):null,(0,mn.jsx)(Jn,{label:"Close library",size:"sm",onClick:t,children:(0,mn.jsx)(Fa,{size:dL,strokeWidth:fL})})]})}),(0,mn.jsxs)("div",{className:"du-side-panel-search",children:[(0,mn.jsx)(yf,{size:dL,strokeWidth:fL,className:"du-side-panel-search-icon","aria-hidden":!0}),(0,mn.jsx)("input",{ref:l,type:"search",value:s,placeholder:"Search templates\u2026","aria-label":"Search templates",onChange:u=>{i(u.target.value)},onKeyDown:u=>{u.key==="Escape"&&s&&(u.stopPropagation(),i(""))}})]}),(0,mn.jsx)("div",{className:"du-side-panel-body du-side-panel-body-flush",children:(0,mn.jsx)(cL,{searchQuery:s,layout:"list"})})]}):null};var hh=P(se(),1);var nu=Math.min,tr=Math.max,ih=Math.round,lh=Math.floor,Mo=e=>({x:e,y:e}),lZ={left:"right",right:"left",bottom:"top",top:"bottom"};function pL(e,t,n){return tr(e,nu(t,n))}function ch(e,t){return typeof e=="function"?e(t):e}function ps(e){return e.split("-")[0]}function uh(e){return e.split("-")[1]}function hL(e){return e==="x"?"y":"x"}function mL(e){return e==="y"?"height":"width"}function nr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function yL(e){return hL(nr(e))}function n8(e,t,n){n===void 0&&(n=!1);let o=uh(e),a=yL(e),r=mL(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=sh(s)),[s,sh(s)]}function o8(e){let t=sh(e);return[Sg(e),t,Sg(t)]}function Sg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var e8=["left","right"],t8=["right","left"],cZ=["top","bottom"],uZ=["bottom","top"];function dZ(e,t,n){switch(e){case"top":case"bottom":return n?t?t8:e8:t?e8:t8;case"left":case"right":return t?cZ:uZ;default:return[]}}function a8(e,t,n,o){let a=uh(e),r=dZ(ps(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(Sg)))),r}function sh(e){let t=ps(e);return lZ[t]+e.slice(t.length)}function fZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function r8(e){return typeof e!="number"?fZ(e):{top:e,right:e,bottom:e,left:e}}function Qi(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function s8(e,t,n){let{reference:o,floating:a}=e,r=nr(t),s=yL(t),i=mL(s),l=ps(t),c=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,f=o[i]/2-a[i]/2,p;switch(l){case"top":p={x:u,y:o.y-a.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch(uh(t)){case"start":p[s]-=f*(n&&c?-1:1);break;case"end":p[s]+=f*(n&&c?-1:1);break}return p}async function i8(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:s,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=ch(t,e),h=r8(p),x=i[f?d==="floating"?"reference":"floating":d],y=Qi(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(x)))==null||n?x:x.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),g=d==="floating"?{x:o,y:a,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(i.floating)),A=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},_=Qi(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:g,offsetParent:b,strategy:l}):g);return{top:(y.top-_.top+h.top)/A.y,bottom:(_.bottom-y.bottom+h.bottom)/A.y,left:(y.left-_.left+h.left)/A.x,right:(_.right-y.right+h.right)/A.x}}var pZ=50,l8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:i8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=s8(c,o,l),f=o,p=0,h={};for(let m=0;m<r.length;m++){let x=r[m];if(!x)continue;let{name:y,fn:g}=x,{x:b,y:A,data:_,reset:C}=await g({x:u,y:d,initialPlacement:o,placement:f,strategy:a,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});u=b??u,d=A??d,h[y]={...h[y],..._},C&&p<pZ&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):C.rects),{x:u,y:d}=s8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var c8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:s,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=!0,...x}=ch(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=ps(a),g=nr(i),b=ps(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(b||!m?[sh(i)]:o8(i)),C=h!=="none";!f&&C&&_.push(...a8(i,m,h,A));let w=[i,..._],L=await l.detectOverflow(t,x),k=[],M=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&k.push(L[y]),d){let ne=n8(a,s,A);k.push(L[ne[0]],L[ne[1]])}if(M=[...M,{placement:a,overflows:k}],!k.every(ne=>ne<=0)){var B,G;let ne=(((B=r.flip)==null?void 0:B.index)||0)+1,V=w[ne];if(V&&(!(d==="alignment"?g!==nr(V):!1)||M.every(ee=>nr(ee.placement)===g?ee.overflows[0]>0:!0)))return{data:{index:ne,overflows:M},reset:{placement:V}};let ve=(G=M.filter(ge=>ge.overflows[0]<=0).sort((ge,ee)=>ge.overflows[1]-ee.overflows[1])[0])==null?void 0:G.placement;if(!ve)switch(p){case"bestFit":{var ie;let ge=(ie=M.filter(ee=>{if(C){let Se=nr(ee.placement);return Se===g||Se==="y"}return!0}).map(ee=>[ee.placement,ee.overflows.filter(Se=>Se>0).reduce((Se,Oe)=>Se+Oe,0)]).sort((ee,Se)=>ee[1]-Se[1])[0])==null?void 0:ie[0];ge&&(ve=ge);break}case"initialPlacement":ve=i;break}if(a!==ve)return{reset:{placement:ve}}}return{}}}};var hZ=new Set(["left","top"]);async function mZ(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=ps(n),i=uh(n),l=nr(n)==="y",c=hZ.has(s)?-1:1,u=r&&l?-1:1,d=ch(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof h=="number"&&(p=i==="end"?h*-1:h),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}var u8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:s,middlewareData:i}=t,l=await mZ(t,e);return s===((n=i.offset)==null?void 0:n.placement)&&(o=i.arrow)!=null&&o.alignmentOffset?{}:{x:a+l.x,y:r+l.y,data:{...l,placement:s}}}}},d8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:y=>{let{x:g,y:b}=y;return{x:g,y:b}}},...c}=ch(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=nr(ps(a)),p=hL(f),h=u[p],m=u[f];if(s){let y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[y],A=h-d[g];h=pL(b,h,A)}if(i){let y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=m+d[y],A=m-d[g];m=pL(b,m,A)}let x=l.fn({...t,[p]:h,[f]:m});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:s,[f]:i}}}}}};function Lg(){return typeof window<"u"}function el(e){return p8(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=(p8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p8(e){return Lg()?e instanceof Node||e instanceof yn(e).Node:!1}function fo(e){return Lg()?e instanceof Element||e instanceof yn(e).Element:!1}function ia(e){return Lg()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function f8(e){return!Lg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function au(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=po(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function h8(e){return/^(table|td|th)$/.test(el(e))}function dh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var yZ=/transform|translate|scale|rotate|perspective|filter/,gZ=/paint|layout|strict|content/,Ji=e=>!!e&&e!=="none",gL;function kg(e){let t=fo(e)?po(e):e;return Ji(t.transform)||Ji(t.translate)||Ji(t.scale)||Ji(t.rotate)||Ji(t.perspective)||!_g()&&(Ji(t.backdropFilter)||Ji(t.filter))||yZ.test(t.willChange||"")||gZ.test(t.contain||"")}function m8(e){let t=or(e);for(;ia(t)&&!tl(t);){if(kg(t))return t;if(dh(t))return null;t=or(t)}return null}function _g(){return gL==null&&(gL=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),gL}function tl(e){return/^(html|body|#document)$/.test(el(e))}function po(e){return yn(e).getComputedStyle(e)}function fh(e){return fo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function or(e){if(el(e)==="html")return e;let t=e.assignedSlot||e.parentNode||f8(e)&&e.host||Ro(e);return f8(t)?t.host:t}function y8(e){let t=or(e);return tl(t)?e.ownerDocument?e.ownerDocument.body:e.body:ia(t)&&au(t)?t:y8(t)}function ou(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=y8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=yn(a);if(r){let i=wg(s);return t.concat(s,s.visualViewport||[],au(a)?a:[],i&&n?ou(i):[])}else return t.concat(a,ou(a,[],n))}function wg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function A8(e){let t=po(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=ia(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=ih(n)!==r||ih(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function bL(e){return fo(e)?e:e.contextElement}function ru(e){let t=bL(e);if(!ia(t))return Mo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=A8(t),s=(r?ih(n.width):n.width)/o,i=(r?ih(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var xZ=Mo(0);function v8(e){let t=yn(e);return!_g()||!t.visualViewport?xZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function nl(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=bL(e),s=Mo(1);t&&(o?fo(o)&&(s=ru(o)):s=ru(e));let i=bZ(r,n,o)?v8(r):Mo(0),l=(a.left+i.x)/s.x,c=(a.top+i.y)/s.y,u=a.width/s.x,d=a.height/s.y;if(r){let f=yn(r),p=o&&fo(o)?yn(o):o,h=f,m=wg(h);for(;m&&o&&p!==h;){let x=ru(m),y=m.getBoundingClientRect(),g=po(m),b=y.left+(m.clientLeft+parseFloat(g.paddingLeft))*x.x,A=y.top+(m.clientTop+parseFloat(g.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=b,c+=A,h=yn(m),m=wg(h)}}return Qi({width:u,height:d,x:l,y:c})}function Tg(e,t){let n=fh(e).scrollLeft;return t?t.left+n:nl(Ro(e)).left+n}function S8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Tg(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function AZ(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=Ro(o),i=t?dh(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=Mo(1),u=Mo(0),d=ia(o);if((d||!d&&!r)&&((el(o)!=="body"||au(s))&&(l=fh(o)),d)){let p=nl(o);c=ru(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?S8(s,l):Mo(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function vZ(e){return Array.from(e.getClientRects())}function SZ(e){let t=Ro(e),n=fh(e),o=e.ownerDocument.body,a=tr(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=tr(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+Tg(e),i=-n.scrollTop;return po(o).direction==="rtl"&&(s+=tr(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var g8=25;function LZ(e,t){let n=yn(e),o=Ro(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=_g();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=Tg(o);if(c<=0){let u=o.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-p);h<=g8&&(r-=h)}else c<=g8&&(r+=c);return{width:r,height:s,x:i,y:l}}function kZ(e,t){let n=nl(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=ia(e)?ru(e):Mo(1),s=e.clientWidth*r.x,i=e.clientHeight*r.y,l=a*r.x,c=o*r.y;return{width:s,height:i,x:l,y:c}}function x8(e,t,n){let o;if(t==="viewport")o=LZ(e,n);else if(t==="document")o=SZ(Ro(e));else if(fo(t))o=kZ(t,n);else{let a=v8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Qi(o)}function L8(e,t){let n=or(e);return n===t||!fo(n)||tl(n)?!1:po(n).position==="fixed"||L8(n,t)}function _Z(e,t){let n=t.get(e);if(n)return n;let o=ou(e,[],!1).filter(i=>fo(i)&&el(i)!=="body"),a=null,r=po(e).position==="fixed",s=r?or(e):e;for(;fo(s)&&!tl(s);){let i=po(s),l=kg(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||au(s)&&!l&&L8(e,s))?o=o.filter(u=>u!==s):a=i,s=or(s)}return t.set(e,o),o}function wZ(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?dh(t)?[]:_Z(t,this._c):[].concat(n),o],i=x8(t,s[0],a),l=i.top,c=i.right,u=i.bottom,d=i.left;for(let f=1;f<s.length;f++){let p=x8(t,s[f],a);l=tr(p.top,l),c=nu(p.right,c),u=nu(p.bottom,u),d=tr(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function TZ(e){let{width:t,height:n}=A8(e);return{width:t,height:n}}function EZ(e,t,n){let o=ia(t),a=Ro(t),r=n==="fixed",s=nl(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=Mo(0);function c(){l.x=Tg(a)}if(o||!o&&!r)if((el(t)!=="body"||au(a))&&(i=fh(t)),o){let p=nl(t,!0,r,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else a&&c();r&&!o&&a&&c();let u=a&&!o&&!r?S8(a,i):Mo(0),d=s.left+i.scrollLeft-l.x-u.x,f=s.top+i.scrollTop-l.y-u.y;return{x:d,y:f,width:s.width,height:s.height}}function xL(e){return po(e).position==="static"}function b8(e,t){if(!ia(e)||po(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function k8(e,t){let n=yn(e);if(dh(e))return n;if(!ia(e)){let a=or(e);for(;a&&!tl(a);){if(fo(a)&&!xL(a))return a;a=or(a)}return n}let o=b8(e,t);for(;o&&h8(o)&&xL(o);)o=b8(o,t);return o&&tl(o)&&xL(o)&&!kg(o)?n:o||m8(e)||n}var CZ=async function(e){let t=this.getOffsetParent||k8,n=this.getDimensions,o=await n(e.floating);return{reference:EZ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function IZ(e){return po(e).direction==="rtl"}var MZ={convertOffsetParentRelativeRectToViewportRelativeRect:AZ,getDocumentElement:Ro,getClippingRect:wZ,getOffsetParent:k8,getElementRects:CZ,getClientRects:vZ,getDimensions:TZ,getScale:ru,isElement:fo,isRTL:IZ};function _8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function RZ(e,t){let n=null,o,a=Ro(e);function r(){var i;clearTimeout(o),(i=n)==null||i.disconnect(),n=null}function s(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),r();let c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(i||t(),!f||!p)return;let h=lh(d),m=lh(a.clientWidth-(u+f)),x=lh(a.clientHeight-(d+p)),y=lh(u),b={rootMargin:-h+"px "+-m+"px "+-x+"px "+-y+"px",threshold:tr(0,nu(1,l))||1},A=!0;function _(C){let w=C[0].intersectionRatio;if(w!==l){if(!A)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!_8(c,e.getBoundingClientRect())&&s(),A=!1}try{n=new IntersectionObserver(_,{...b,root:a.ownerDocument})}catch{n=new IntersectionObserver(_,b)}n.observe(e)}return s(!0),r}function Eg(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,c=bL(e),u=a||r?[...c?ou(c):[],...t?ou(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?RZ(c,n):null,f=-1,p=null;s&&(p=new ResizeObserver(y=>{let[g]=y;g&&g.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let h,m=l?nl(e):null;l&&x();function x(){let y=nl(e);m&&!_8(m,y)&&n(),m=y,h=requestAnimationFrame(x)}return n(),()=>{var y;u.forEach(g=>{a&&g.removeEventListener("scroll",n),r&&g.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(h)}}var Cg=u8;var Ig=d8,Mg=c8;var Rg=(e,t,n)=>{let o=new Map,a={platform:MZ,...n},r={...a.platform,_c:o};return l8(e,t,{...a,platform:r})};var la=P(re(),1),kL=P(ya(),1);var S=P(se(),1),ms=P(re(),1);var w8=P(se(),1),hs=P(re(),1),T8=(0,hs.createContext)(null),E8=({children:e})=>{let t=(0,hs.useRef)(null),n=(0,hs.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,w8.jsx)(T8.Provider,{value:n,children:e})},Og=()=>(0,hs.useContext)(T8);var Nt=P(se(),1),M8=P(re(),1);var OZ=ns.map(e=>Pc.light[e].fill),DZ=ns.map(e=>Pc.light[e].solid),PZ=ns.map(e=>Pc.dark[e].fill),BZ=ns.map(e=>Pc.dark[e].solid),NZ=ns.map(e=>wy.light[e]),zZ=ns.map(e=>wy.dark[e]),Dg=[...OZ,...DZ,"#ffffff","#1e1e1e","transparent"],AL=[...PZ,...BZ,"#1e1e1e","#ffffff","transparent"],age=["#ffffff",...NZ],rge=["#121113",...zZ],C8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var su=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0,onEyedrop:r})=>{let s=n??GZ(),[i,l]=(0,M8.useState)(!1);return(0,Nt.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[s.map(c=>(0,Nt.jsx)(FZ,{color:c,selected:I8(c)===I8(e),onClick:()=>{t(c==="transparent"?null:c)}},c)),o?(0,Nt.jsx)(HZ,{value:e,onChange:t,open:i,onOpenChange:l}):null,r?(0,Nt.jsx)("button",{type:"button","aria-label":"Pick colour from canvas",title:"Pick colour from canvas",onClick:()=>{r(c=>{t(c)})},className:"du-swatch du-swatch-eyedrop",children:(0,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(ff,{size:12,strokeWidth:2})})}):null,a?(0,Nt.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(Fa,{size:12,strokeWidth:2})})}):null]})},FZ=({color:e,selected:t,onClick:n})=>(0,Nt.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,Nt.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),HZ=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,Nt.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,Nt.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,Nt.jsx)(Js,{size:12,strokeWidth:2})}),(0,Nt.jsx)("input",{type:"color","aria-label":"Custom colour",value:UZ(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},I8=e=>e===null?"transparent":e.toLowerCase(),UZ=e=>{if(!e||e==="transparent")return"#000000";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(e)){let t=e.slice(1);return`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`.toLowerCase()}return"#000000"},GZ=()=>{if(typeof document>"u")return Dg;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?AL:e==="light"?Dg:C8("system")==="dark"?AL:Dg};var iu=P(se(),1);var bt=P(re(),1),R8=P(ya(),1);var ho=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Pt(),[c,u]=(0,bt.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,bt.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,bt.useId)(),m=(0,bt.useRef)(null),x=(0,bt.useRef)(null);(0,bt.useLayoutEffect)(()=>{if(!f)return;let g=m.current,b=x.current;if(!g||!b)return;let A=()=>{Rg(g,b,{placement:n,middleware:[Cg(o),Mg(),Ig({padding:6})]}).then(({x:C,y:w})=>{b.style.transform=`translate(${Math.round(C)}px, ${Math.round(w)}px)`})};return A(),Eg(g,b,A)},[f,n,o]),(0,bt.useEffect)(()=>{if(!f)return;let g=A=>{let _=A.target;_&&(m.current?.contains(_)||x.current?.contains(_)||p(!1))},b=A=>{A.key==="Escape"&&(A.stopPropagation(),p(!1),m.current?.focus())};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",b)}},[f,p]);let y=(0,bt.useMemo)(()=>{if(!(0,bt.isValidElement)(e))return e;let g=e.props;return(0,bt.cloneElement)(e,{ref:b=>{m.current=b;let A=e.ref;typeof A=="function"?A(b):A&&typeof A=="object"&&(A.current=b)},onClick:b=>{let A=g.onClick;A?.(b),!b.defaultPrevented&&p(!f)},"aria-haspopup":"dialog","aria-expanded":f,"aria-controls":f?h:void 0})},[e,f,p,h]);return(0,iu.jsxs)(iu.Fragment,{children:[y,f?(0,R8.createPortal)((0,iu.jsx)("div",{ref:x,id:h,role:"dialog","aria-label":i,className:`du-popover ${a??""}`.trim(),style:{position:"absolute",top:0,left:0,zIndex:1600},children:t}),l):null]})};var SL=({style:e,className:t,mobile:n=!1})=>{let o=pg(),a=oL(),r=Ka();if(ls())return null;if(o.size>0){let i=[...o].map(h=>r.elements.get(h)).filter(h=>h!==void 0);if(i.length===0)return null;let l=i.every(h=>pe(h)),c=i.every(h=>ct(h)),u=i.every(h=>Mn(h)),d=i.every(h=>Be(h)),f=[],p=[];return d?f.push((0,S.jsx)(P8,{shapes:i},"fill")):l?(f.push((0,S.jsx)(VZ,{shapes:i},"size"),(0,S.jsx)(qZ,{shapes:i},"color"),(0,S.jsx)(ZZ,{shapes:i},"align")),p.push((0,S.jsx)(jZ,{shapes:i},"family"),(0,S.jsx)(XZ,{shapes:i},"decor"))):c?f.push((0,S.jsx)(B8,{shapes:i},"opacity"),(0,S.jsx)(nX,{shapes:i},"crop")):(f.push((0,S.jsx)(P8,{shapes:i},"fill"),(0,S.jsx)(YZ,{shapes:i},"stroke"),u?(0,S.jsx)(KZ,{shapes:i},"width"):(0,S.jsx)($Z,{shapes:i},"width")),p.push((0,S.jsx)(QZ,{shapes:i},"dash"),(0,S.jsx)(JZ,{shapes:i},"round"),(0,S.jsx)(B8,{shapes:i},"opacity"),(0,S.jsx)(tX,{shapes:i},"convert"))),p.push((0,S.jsx)(eX,{},"z"),(0,S.jsx)(WZ,{shapes:i},"link")),i.length>=2&&p.push((0,S.jsx)(rX,{},"align")),p.push((0,S.jsx)(oX,{shapes:i},"actions"),(0,S.jsx)(D8,{},"more")),(0,S.jsx)(O8,{mobile:n,primary:f,overflow:p,className:t,style:e})}if(a!==null){let i=r.links.get(a);if(!i)return null;let l=[(0,S.jsx)(sX,{edge:i},"color"),(0,S.jsx)(iX,{edge:i},"width"),(0,S.jsx)(N8,{edge:i,side:"to"},"arrow-to")],c=[(0,S.jsx)(lX,{edge:i},"dash"),(0,S.jsx)(uX,{edge:i},"routing"),(0,S.jsx)(cX,{edge:i},"kind"),(0,S.jsx)(N8,{edge:i,side:"from"},"arrow-from"),(0,S.jsx)(dX,{edge:i},"auto"),(0,S.jsx)(fX,{},"delete"),(0,S.jsx)(D8,{},"more")];return(0,S.jsx)(O8,{mobile:n,primary:l,overflow:c,className:t,style:e})}return null},O8=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,ms.useState)(!1),i=(0,ms.useRef)(null);return(0,ms.useEffect)(()=>{if(!e||!r)return;let l=c=>{let u=i.current;u&&c.target instanceof Node&&!u.contains(c.target)&&s(!1)};return document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("pointerdown",l,!0)}},[e,r]),e?(0,S.jsxs)("div",{ref:i,className:`du-sel-panel du-sel-panel-mobile ${o??""}`.trim(),style:a,children:[(0,S.jsxs)("div",{className:"du-sel-mobile-row",children:[(0,S.jsx)("div",{className:"du-sel-mobile-primary",children:t}),n.length>0?(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button du-sel-mobile-expand${r?" is-active":""}`,"aria-expanded":r,"aria-label":r?"Hide more properties":"More properties",title:"More properties",onClick:()=>{s(l=>!l)},children:(0,S.jsx)(Gr,{size:18,strokeWidth:1.75,"aria-hidden":!0})}):null]}),r&&n.length>0?(0,S.jsx)("div",{className:"du-sel-mobile-overflow",children:n}):null]}):(0,S.jsxs)("div",{className:`du-sel-panel ${o??""}`.trim(),style:a,children:[t,n.length>0?(0,S.jsx)(mX,{}):null,n]})},WZ=({shapes:e})=>{let t=U(),n=(0,ms.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=ph(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,S.jsx)(ho,{ariaLabel:"Link",trigger:(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${r?" is-active":""}`,title:"Link","aria-label":"Link",children:(0,S.jsx)(Jd,{size:14,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Link"}),(0,S.jsx)("input",{ref:n,className:"du-sel-link-input",type:"text",placeholder:"https://\u2026 \xB7 name@mail",defaultValue:a??"","aria-label":"Link URL",onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s(i.currentTarget.value))}}),(0,S.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{s(n.current?.value??"")},children:"Save"}),r?(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.openLink(a)},children:"Open"}):null,r?(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.setLink(o,null)},children:"Remove"}):null]})]})})},D8=()=>{let e=U(),t=Og();return!e||!t?null:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"More actions","aria-label":"More actions",onClick:n=>{let o=n.currentTarget.getBoundingClientRect(),a={x:o.left,y:o.bottom+4},s=e.hostElement?.getBoundingClientRect(),i=s?e.screenToWorld({x:a.x-s.left,y:a.y-s.top}):{x:0,y:0};t.open({screenPoint:a,worldPoint:i})},children:(0,S.jsx)(Wr,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},LL=({label:e,color:t,onChange:n,ariaLabel:o,onEyedrop:a})=>(0,S.jsx)(ho,{ariaLabel:o,trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:e,"aria-label":o,children:(0,S.jsx)("span",{className:"du-sel-color-swatch",style:{background:!t||t==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":t}})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:e}),(0,S.jsx)(su,{value:t,onChange:n,...a?{onEyedrop:a}:{}})]})}),H8=e=>{let t=sn(a=>a.editingTextElement,null),n=sn(a=>a.editingTextSelection,null);if(t===null||n===null||n.start===n.end)return null;let o=e.find(a=>a.id===t);return o===void 0||!pe(o)?null:{target:o,from:Math.min(n.start,n.end),to:Math.max(n.start,n.end)}},qZ=({shapes:e})=>{let t=U(),n=H8(e);if(!t)return null;let o=e.map(l=>l.id),a=ph(e,l=>l.style.fill),r=Oo(e,l=>l.style.opacity??1),s=r===null?null:Math.round(r*100);return(0,S.jsx)(ho,{ariaLabel:"Text color and opacity",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:"Color & opacity","aria-label":"Text color and opacity",children:(0,S.jsx)("span",{className:"du-sel-color-swatch",style:{background:!a||a==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":a,opacity:r??1}})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Color"}),(0,S.jsx)(su,{value:a,onChange:l=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,{fill:l??"transparent"}):t.updateStyle(o,{fill:l??"transparent"})},onEyedrop:l=>{t.beginEyedropperPick(l)}}),(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Rf,{value:s,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:s===null?"\u2014":`${s}%`,onChange:l=>{t.updateStyle(o,{opacity:l/100})}})]})})},P8=({shapes:e})=>{let t=U();if(!t||!e.some(yX))return null;let n=ph(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,S.jsx)(LL,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},VZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(r=>r.id),o=Oo(e,r=>r.fontSize??null),a=o!==null&&Kb.some(r=>r.value===o)?o:null;return(0,S.jsx)(ho,{ariaLabel:"Font size",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font size","aria-label":`Font size ${o??"mixed"}`,children:o===null?"\u2014":`${Math.round(o)}`}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Font size"}),(0,S.jsx)(In,{ariaLabel:"Font size preset",value:a,options:Kb.map(r=>({value:r.value,label:r.label,icon:(0,S.jsx)("span",{style:{fontSize:11,fontWeight:600},children:r.label})})),onChange:r=>{t.updateTextProps(n,{fontSize:r})}}),(0,S.jsx)(Rf,{value:o,min:HE,max:UE,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},jZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(s=>s.id),o=ph(e,s=>s.fontFamily),a=eA.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,S.jsx)(ho,{ariaLabel:"Font family",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font family","aria-label":`Font family ${r}`,style:o?{fontFamily:o}:void 0,children:r}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Font family"}),eA.map(s=>(0,S.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":s.value===o,className:`du-sel-menu-row${s.value===o?" is-active":""}`,style:{fontFamily:s.value},onClick:()=>{t.updateTextProps(n,{fontFamily:s.value})},children:s.label},s.value))]})})},ZZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>a.style.textAlign??"left");return(0,S.jsx)(In,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,S.jsx)(vo,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,S.jsx)(jr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,S.jsx)(Vr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},Pg=({active:e,label:t,icon:n,onClick:o})=>(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${e?" is-active":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:o,children:n}),XZ=({shapes:e})=>{let t=U(),n=H8(e);if(!t)return null;let o=e.map(p=>p.id),a=n?Ff(n.target,n.from,n.to):[],r=n?.target.style,s=p=>a.length>0&&a.every(h=>p(h.style)),i=n?s(p=>(p?.fontWeight??r?.fontWeight)==="bold"):e.every(p=>p.style?.fontWeight==="bold"),l=n?s(p=>(p?.fontStyle??r?.fontStyle)==="italic"):e.every(p=>p.style?.fontStyle==="italic"),c=n?s(p=>(p?.textDecoration??r?.textDecoration)?.underline===!0):e.every(p=>p.style?.textDecoration?.underline===!0),u=n?s(p=>(p?.textDecoration??r?.textDecoration)?.strikethrough===!0):e.every(p=>p.style?.textDecoration?.strikethrough===!0),d=p=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,p):t.updateStyle(o,p)},f=(p,h)=>{if(n)t.applyTextStyleToRange(n.target.id,n.from,n.to,{textDecoration:{underline:c,strikethrough:u,[p]:h}});else for(let m of e){let x=m.style?.textDecoration??{};t.updateStyle([m.id],{textDecoration:{...x,[p]:h}})}};return(0,S.jsx)(ho,{ariaLabel:"Text style",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Text style (bold / italic / \u2026)","aria-label":"Text style",children:(0,S.jsx)(Rd,{size:16,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Style"}),(0,S.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,S.jsx)(Pg,{active:i,label:"Bold",icon:(0,S.jsx)(Md,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontWeight:i?"normal":"bold"})}}),(0,S.jsx)(Pg,{active:l,label:"Italic",icon:(0,S.jsx)($d,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontStyle:l?"normal":"italic"})}}),(0,S.jsx)(Pg,{active:c,label:"Underline",icon:(0,S.jsx)(Sf,{size:14,strokeWidth:1.75}),onClick:()=>{f("underline",!c)}}),(0,S.jsx)(Pg,{active:u,label:"Strikethrough",icon:(0,S.jsx)(bf,{size:14,strokeWidth:1.75}),onClick:()=>{f("strikethrough",!u)}})]})]})})},YZ=({shapes:e})=>{let t=U();if(!t||!e.some(G8))return null;let n=ph(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,S.jsx)(LL,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},KZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>{let r=a,s=r.baseWidth??r.points.reduce((i,l)=>Math.max(i,l.width),0);return s>0?Math.round(s):null});return(0,S.jsx)(ho,{ariaLabel:"Brush width",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Brush width","aria-label":"Brush width",children:(0,S.jsx)(ol,{thickness:2.5})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:`Width ${o!==null?String(o):"mixed"}`}),(0,S.jsx)("input",{type:"range",min:Cf,max:E0,step:1,value:o??Cf,onChange:a=>{t.setBrushWidth(n,a.currentTarget.valueAsNumber)},style:{width:"100%"},"aria-label":"Brush width"})]})})},$Z=({shapes:e})=>{let t=U();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=Oo(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,S.jsx)(In,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(ol,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(ol,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(ol,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},QZ=({shapes:e})=>{let t=U();if(!t||!e.some(G8))return null;let n=Oo(e,a=>{let r=a.style.dashArray;return!r||r.length===0?"solid":(r[0]??0)<=3?"dotted":"dashed"}),o=e.map(a=>a.id);return(0,S.jsx)(In,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},JZ=({shapes:e})=>{let t=U();if(!t||!e.every(i=>li(i)||i.type==="container"))return null;let o=Oo(e,i=>i.style.roundness?.type??"sharp"),a=Oo(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,S.jsx)(ho,{ariaLabel:"Corners",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,S.jsx)(vL,{kind:o??"sharp"})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Corners"}),(0,S.jsx)(In,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,S.jsx)(vL,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,S.jsx)(vL,{kind:"round"})}],onChange:i=>{t.updateStyle(r,{roundness:{type:i}})}}),o==="round"?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("label",{className:"du-prop-checkbox",children:[(0,S.jsx)("input",{type:"checkbox",checked:s,onChange:i=>{i.target.checked?t.updateStyle(r,{roundness:{type:"round"}}):t.updateStyle(r,{roundness:{type:"round",value:a??8}})}}),(0,S.jsx)("span",{children:"Auto radius"})]}),s?null:(0,S.jsx)(Rf,{value:a,min:0,max:64,step:1,ariaLabel:"Corner radius",valueLabel:`${a}px`,onChange:i=>{t.updateStyle(r,{roundness:{type:"round",value:i}})}})]}):null]})})},B8=({shapes:e})=>{let t=U();if(!t)return null;let n=Oo(e,s=>s.style.opacity??1),o=e.map(s=>s.id),a=n===null?null:Math.round(n*100),r=a===null?"\u2014":`${a}%`;return(0,S.jsx)(ho,{ariaLabel:"Opacity",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Opacity","aria-label":`Opacity ${r}`,children:r}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Rf,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},eX=()=>{let e=U();return e?(0,S.jsx)(In,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,S.jsx)(Pd,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,S.jsx)(cf,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,S.jsx)(df,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,S.jsx)(Bd,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},tX=({shapes:e})=>{let t=U();if(!t||!e.every(a=>li(a)||lc(a)||Ua(a)))return null;let o=Oo(e,a=>li(a)?"rectangle":lc(a)?"ellipse":"polygon");return(0,S.jsx)(In,{ariaLabel:"Shape type",value:o,options:[{value:"rectangle",label:"Rectangle",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"ellipse",label:"Ellipse",icon:(0,S.jsx)(Ks,{size:14,strokeWidth:1.75})},{value:"polygon",label:"Diamond",icon:(0,S.jsx)(Hd,{size:14,strokeWidth:1.75})}],onChange:a=>{t.convertSelection(a)}})},nX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.length===1?e[0]:void 0;if(n===void 0||!ct(n))return null;let o=n.id;return(0,S.jsx)("button",{type:"button",className:"du-icon-button",title:"Crop image (double-click)","aria-label":"Crop image",onClick:()=>{t.beginImageCrop(o)},children:(0,S.jsx)(zd,{size:16,strokeWidth:1.75})})},oX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.length>=2,o=e.some(r=>ze(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,S.jsx)(Ur,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,S.jsx)(oc,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,S.jsx)(Yd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,S.jsx)(Lf,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,S.jsx)(Vd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,S.jsx)(jd,{size:14,strokeWidth:1.75})}),(0,S.jsx)(In,{ariaLabel:"Element actions",value:null,options:a,onChange:r=>{r==="duplicate"?t.duplicateSelected():r==="delete"?t.deleteSelected():r==="group"?t.groupSelected():r==="ungroup"?t.ungroup():r==="flip-h"?t.flipSelection("horizontal"):t.flipSelection("vertical")}})},aX=[{edge:"left",label:"Align left",icon:(0,S.jsx)(Cd,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,S.jsx)(ec,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,S.jsx)(wd,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,S.jsx)(Ed,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,S.jsx)(kd,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,S.jsx)(_d,{size:16,strokeWidth:1.75})}],rX=()=>{let e=U(),t=pg();if(!e)return null;let n=t.size>=3;return(0,S.jsx)(ho,{ariaLabel:"Align and distribute",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Align","aria-label":"Align",children:(0,S.jsx)(ec,{size:16,strokeWidth:1.75})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Align"}),(0,S.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:4},children:aX.map(o=>(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:o.label,"aria-label":o.label,onClick:()=>{e.alignSelection(o.edge)},children:o.icon},o.edge))}),n?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Distribute"}),(0,S.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute horizontally","aria-label":"Distribute horizontally",onClick:()=>{e.distributeSelection("horizontal")},children:(0,S.jsx)(Td,{size:16,strokeWidth:1.75})}),(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute vertically","aria-label":"Distribute vertically",onClick:()=>{e.distributeSelection("vertical")},children:(0,S.jsx)(Id,{size:16,strokeWidth:1.75})})]})]}):null]})})},sX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,S.jsx)(LL,{label:"Stroke",ariaLabel:"Link stroke color",color:n,onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,stroke:o??"transparent"}}))},onEyedrop:o=>{t.beginEyedropperPick(o)}})},iX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,S.jsx)(In,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(ol,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(ol,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(ol,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},lX=({edge:e})=>{let t=U();if(!t)return null;let n=e.style.dashArray,o=!n||n.length===0?"solid":(n[0]??0)<=3?"dotted":"dashed";return(0,S.jsx)(In,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateSelectedLink(s=>({...s,style:{...s.style,dashArray:r}}))}})},cX=({edge:e})=>{let t=U();if(!t)return null;let n=e.lineKind??"line";return(0,S.jsx)(In,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,S.jsx)(Ba,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,S.jsx)(uf,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},uX=({edge:e})=>{let t=U();if(!t)return null;let n=e.routing??"straight";return(0,S.jsx)(In,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,S.jsx)(z8,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,S.jsx)(z8,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,S.jsx)(xf,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},N8=({edge:e,side:t})=>{let n=U(),[o,a]=(0,ms.useState)(!1);if(!n)return null;let r=e.arrowheads?.[t]??"none",s=l=>{n.updateSelectedLink(c=>({...c,arrowheads:{...c.arrowheads??{},[t]:l}}))},i=({style:l})=>(0,S.jsx)("button",{type:"button",className:`du-arrowhead-option${l===r?" du-arrowhead-option--active":""}`,title:Bg[l],"aria-label":Bg[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,S.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):U8(l)==="none"?(0,S.jsx)("span",{className:"du-arrowhead-erd-label",children:Bg[l].replace(/^ERD /,"")}):(0,S.jsx)(F8,{kind:l,side:t})});return(0,S.jsx)(ho,{trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${Bg[r]}`,"aria-label":`Arrow ${t}`,children:(0,S.jsx)(F8,{kind:r,side:t})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsxs)("header",{className:"du-sel-popover-label",children:["Arrow ",t]}),(0,S.jsx)("div",{className:"du-arrowhead-grid",children:pX.map(l=>(0,S.jsx)(i,{style:l},l))}),(0,S.jsxs)("button",{type:"button",className:"du-arrowhead-erd-toggle","aria-expanded":o,onClick:()=>{a(l=>!l)},children:[o?"\u25BE":"\u25B8"," ER diagram"]}),o&&(0,S.jsx)("div",{className:"du-arrowhead-grid",children:hX.map(l=>(0,S.jsx)(i,{style:l},l))})]})})},dX=({edge:e})=>{let t=U();if(!t||(e.routing??"straight")==="bezier")return null;let o=e.avoidObstacles===!0;return(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${o?" is-active":""}`,title:"Route around shapes","aria-label":"Route around shapes","aria-pressed":o,onClick:()=>{t.setSelectedLinkAvoidObstacles(!o)},children:(0,S.jsx)(_f,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},fX=()=>{let e=U();return e?(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Delete edge","aria-label":"Delete edge",onClick:()=>{e.deleteSelected()},children:(0,S.jsx)(oc,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},z8=({kind:e})=>e==="straight"?(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("line",{x1:2,y1:11,x2:12,y2:3,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"})}):(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("path",{d:"M 2 11 L 2 7 L 12 7 L 12 3",stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),U8=e=>{switch(e){case"arrow":case"openArrow":case"roundedArrow":case"arcArrow":return"open";case"triangle":case"filledArrow":return"triangle";case"diamond":case"rhombus":case"filledRhombus":return"diamond";case"circle":case"filledCircle":return"circle";default:return"none"}},pX=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],hX=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],Bg={none:"None",arrow:"Arrow",openArrow:"Open arrow",roundedArrow:"Rounded arrow",arcArrow:"Arc arrow",triangle:"Triangle",filledArrow:"Filled arrow",circle:"Circle",filledCircle:"Filled circle",diamond:"Diamond",rhombus:"Rhombus",filledRhombus:"Filled rhombus",erdOne:"ERD one",erdOnlyOne:"ERD only one",erdMany:"ERD many",erdOneOrMany:"ERD one or many",erdZeroOrOne:"ERD zero or one",erdZeroOrMany:"ERD zero or many"},F8=({kind:e,side:t})=>{let n=t==="from",o=n?12:2,a=n?5:9,r=n?3:11,s=n?5:9,i=(0,S.jsx)("line",{x1:o,y1:7,x2:a,y2:7,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"}),l=U8(e),c=null;return l==="open"?c=(0,S.jsx)("polyline",{points:n?`${r+3},4 ${r},7 ${r+3},10`:`${r-3},4 ${r},7 ${r-3},10`,stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}):l==="triangle"?c=(0,S.jsx)("polygon",{points:n?`${r},7 ${s},4 ${s},10`:`${r},7 ${s},4 ${s},10`,fill:"currentColor"}):l==="diamond"?c=(0,S.jsx)("polygon",{points:`${r},4 ${r+(n?-3:3)},7 ${r},10 ${r+(n?3:-3)},7`,fill:e==="filledRhombus"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2}):l==="circle"&&(c=(0,S.jsx)("circle",{cx:r,cy:7,r:2.2,fill:e==="filledCircle"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2})),(0,S.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[i,c]})},mX=()=>(0,S.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),ol=({thickness:e})=>(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("line",{x1:2,y1:7,x2:12,y2:7,stroke:"currentColor",strokeWidth:e,strokeLinecap:"round"})}),vL=({kind:e})=>e==="sharp"?(0,S.jsx)(qo,{size:14,strokeWidth:1.75,"aria-hidden":!0}):(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("rect",{x:2,y:2,width:10,height:10,rx:3,ry:3,stroke:"currentColor",strokeWidth:1.5})}),Oo=(e,t)=>{let n=new Set;for(let a of e)n.add(t(a));return n.size!==1?null:n.values().next().value??null},ph=(e,t)=>{let n=Oo(e,o=>t(o));return typeof n=="string"?n:null},yX=e=>e.style.fill!==void 0||Be(e),G8=e=>e.style.stroke!==void 0;var _L=({offset:e=48,placement:t="top",edgeInset:n}={})=>{let o={top:n?.top??66,right:n?.right??16,bottom:n?.bottom??66,left:n?.left??16},a=U(),r=ls(),s=Pt(),i=Jp(),[l,c]=(0,la.useState)(!1),u=(0,la.useRef)(null),[d,f]=(0,la.useState)(0),[p,h]=(0,la.useState)(!1);return(0,la.useEffect)(()=>{if(!a)return;let m=()=>{let x=a.selection,y=a.selection.size>0||a.selectedLink!==null;c(g=>(!g&&y&&h(!1),y)),f(g=>g+1)};return m(),a.on("change",m)},[a]),(0,la.useLayoutEffect)(()=>{if(!a||!l||i)return;let m=u.current;if(!m)return;let x=gX(a);if(!x)return;let y=()=>{Rg(x,m,{placement:t,middleware:[Cg(e),Mg({fallbackPlacements:["bottom","right","left"],padding:o}),Ig({padding:o})]}).then(({x:b,y:A})=>{m.style.transform=`translate(${Math.round(b)}px, ${Math.round(A)}px)`,h(!0)})};return y(),Eg(x,m,y)},[a,l,i,d,e,t,o.top,o.right,o.bottom,o.left]),!a||!l||r?null:i?(0,kL.createPortal)((0,hh.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,hh.jsx)(SL,{mobile:!0})}),s):(0,kL.createPortal)((0,hh.jsx)("div",{ref:u,className:"du-sel-panel-floating",role:"toolbar","aria-label":"Selection actions",style:{position:"absolute",top:0,left:0,zIndex:1500,pointerEvents:"auto",opacity:p?1:0,transition:p?"opacity 120ms ease":"none",...p?{}:{pointerEvents:"none"}},children:(0,hh.jsx)(SL,{})}),s)},gX=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=xX(e);if(!n){let c=t.getBoundingClientRect();return new DOMRect(c.left,c.top,0,0)}let o=e.scene.viewport,a=(n.x-o.pan.x)*o.zoom,r=(n.y-o.pan.y)*o.zoom,s=Math.max(1,n.width*o.zoom),i=Math.max(1,n.height*o.zoom),l=t.getBoundingClientRect();return new DOMRect(l.left+a,l.top+r,s,i)},contextElement:t}:null},xX=e=>{let t=[];for(let o of e.selection){let a=e.scene.elements.get(o);a&&t.push(a)}if(t.length===0){let o=e.selectedLink;if(o){let a=e.scene.links.get(o);if(a)return as(e.scene,a)}return null}let n=null;for(let o of t){if(ze(o)&&e.scene.elements.has(o.id)){let r=MA(e.scene,o.id);for(let s of r){if(ze(s))continue;let i;try{i=N(s)}catch{continue}i.width===0&&i.height===0||(n=W8(n,i))}continue}let a;try{a=N(o)}catch{continue}n=W8(n,a)}return n},W8=(e,t)=>{if(!e)return{...t};let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var gs=P(se(),1),Le=P(re(),1);var lu="Roboto",mh="PT Serif",yh="Roboto Mono",cu=e=>{let t=e.toLowerCase();return t.includes("mono")?yh:t.includes("sans")?lu:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?mh:lu},bX=[{family:lu,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:lu,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:lu,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:lu,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:mh,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:mh,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:mh,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:mh,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:yh,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:yh,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:yh,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:yh,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],q8=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(bX.map(async n=>{let o=new FontFace(n.family,`url(${n.url.href})`,{weight:n.weight,style:n.style});await o.load(),t.add(o)}))};var AX=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],uu=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of AX){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Ng=e=>{let t=e;return typeof t.naturalWidth=="number"&&t.naturalWidth>0?{width:t.naturalWidth,height:t.naturalHeight??t.naturalWidth}:typeof t.videoWidth=="number"&&t.videoWidth>0?{width:t.videoWidth,height:t.videoHeight??t.videoWidth}:typeof t.width=="number"&&t.width>0&&typeof t.height=="number"?{width:t.width,height:t.height}:null},V8=new Set,zg=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";V8.has(t)||(V8.add(t),console.warn(`[renderer] skipped a non-drawable image source (kind: ${t}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap \u2014 likely a scene restored from storage where the <img> was lost (metadata.image) and src is a dead blob: URL. The image won't render until rehydrated from Scene.files.`))};var ar=class{ctx;_width;_height;dpr;constructor(t,n,o,a=1){this.ctx=t,this._width=n,this._height=o,this.dpr=a}get size(){return{width:this._width,height:this._height}}resize(t,n,o){this._width=t,this._height=n,o!==void 0&&(this.dpr=o)}setFill(t){this.ctx.fillStyle=t??"transparent"}setStroke(t){this.ctx.strokeStyle=t??"transparent"}setStrokeWidth(t){this.ctx.lineWidth=t}setOpacity(t){this.ctx.globalAlpha=t}setLineCap(t){this.ctx.lineCap=t}setLineJoin(t){this.ctx.lineJoin=t}setDashArray(t){this.ctx.setLineDash(t?[...t]:[])}setFont(t,n,o){let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.ctx.font=`${a}${r}${n}px "${cu(t)}", ${t}`}setTextAlign(t){this.ctx.textAlign=t==="center"?"center":t}setTextBaseline(t){this.ctx.textBaseline=t==="middle"?"middle":t==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,n){this.ctx.translate(t,n)}rotate(t){this.ctx.rotate(t)}scale(t,n){this.ctx.scale(t,n)}setTransform(t){let n=this.dpr;this.ctx.setTransform(n*t.a,n*t.b,n*t.c,n*t.d,n*t.e,n*t.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(t,n){this.ctx.moveTo(t,n)}lineTo(t,n){this.ctx.lineTo(t,n)}quadraticCurveTo(t,n,o,a){this.ctx.quadraticCurveTo(t,n,o,a)}bezierCurveTo(t,n,o,a,r,s){this.ctx.bezierCurveTo(t,n,o,a,r,s)}rect(t,n,o,a){this.ctx.rect(t,n,o,a)}ellipse(t,n,o,a){this.ctx.ellipse(t,n,o,a,0,0,Math.PI*2)}fill(t){this.ctx.fill(t)}stroke(){this.ctx.stroke()}fillText(t,n,o,a){a!==void 0?this.ctx.fillText(t,n,o,a):this.ctx.fillText(t,n,o)}measureText(t){return{width:this.ctx.measureText(t).width}}drawImage(t,n,o,a,r,s,i){if(!uu(t)){zg(t);return}if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){let l=Ng(t);if(l){this.ctx.drawImage(t,i.x*l.width,i.y*l.height,i.width*l.width,i.height*l.height,n,o,a,r);return}}this.ctx.drawImage(t,n,o,a,r)}clear(t){this.dirtyRect=null,t?this.ctx.clearRect(t.x,t.y,t.width,t.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(t){if(!this.dirtyRect){this.dirtyRect=t;return}let n=Math.min(this.dirtyRect.x,t.x),o=Math.min(this.dirtyRect.y,t.y),a=Math.max(this.dirtyRect.x+this.dirtyRect.width,t.x+t.width),r=Math.max(this.dirtyRect.y+this.dirtyRect.height,t.y+t.height);this.dirtyRect={x:n,y:o,width:a-n,height:r-o}}getDirtyRect(){return this.dirtyRect}};var gh=class{shaper;atlasSize;tileSize;range;columns;capacity;glyphs=new Map;buffer;dirtyTiles=new Set;needsFullUpload=!0;nextSlot=0;texture=null;constructor(t,n={}){if(this.shaper=t,this.atlasSize=n.atlasSize??2048,this.tileSize=n.tileSize??64,this.range=n.range??8,this.atlasSize%this.tileSize!==0)throw new Error(`GlyphAtlas: atlasSize (${this.atlasSize}) must be a multiple of tileSize (${this.tileSize})`);this.columns=this.atlasSize/this.tileSize,this.capacity=this.columns*this.columns,this.buffer=new Uint8Array(this.atlasSize*this.atlasSize*3)}resolveFontId(t,n=!1,o=!1){return this.shaper.resolveFontId?.(t,n,o)??0}getOrRasterize(t,n=0){let o=n*1114112+t,a=this.glyphs.get(o);if(a)return a;if(this.nextSlot>=this.capacity)return null;let r=this.shaper.glyphMetrics(t,n);if(!r)return null;let s=this.nextSlot++,i=s%this.columns,l=Math.floor(s/this.columns),c=i*this.tileSize,u=l*this.tileSize,d=r.bboxW<=0||r.bboxH<=0;if(!d){let p=this.shaper.rasterizeGlyphMSDF(t,this.tileSize,this.range,n);if(p){for(let h=0;h<this.tileSize;h++){let m=h*this.tileSize*3,x=((u+h)*this.atlasSize+c)*3;this.buffer.set(p.data.subarray(m,m+this.tileSize*3),x)}this.dirtyTiles.add(s)}}let f={codePoint:t,atlasX:c,atlasY:u,tileSize:this.tileSize,range:this.range,advance:r.advance,bboxXMin:r.bboxXMin,bboxYMin:r.bboxYMin,bboxW:r.bboxW,bboxH:r.bboxH,unitsPerEm:r.unitsPerEm,empty:d};return this.glyphs.set(o,f),f}get glyphCount(){return this.glyphs.size}get cpuBuffer(){return this.buffer}uploadTo(t){if(this.texture)t.bindTexture(t.TEXTURE_2D,this.texture);else{let n=t.createTexture();if(!n)throw new Error("GlyphAtlas: gl.createTexture() returned null");this.texture=n,t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}if(this.needsFullUpload)return t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGB8,this.atlasSize,this.atlasSize,0,t.RGB,t.UNSIGNED_BYTE,this.buffer),this.needsFullUpload=!1,this.dirtyTiles.clear(),this.texture;if(this.dirtyTiles.size===0)return this.texture;t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ROW_LENGTH,this.atlasSize);for(let n of this.dirtyTiles){let o=n%this.columns,a=Math.floor(n/this.columns),r=o*this.tileSize,s=a*this.tileSize,i=r,l=s;t.pixelStorei(t.UNPACK_SKIP_PIXELS,i),t.pixelStorei(t.UNPACK_SKIP_ROWS,l),t.texSubImage2D(t.TEXTURE_2D,0,r,s,this.tileSize,this.tileSize,t.RGB,t.UNSIGNED_BYTE,this.buffer)}return t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),this.dirtyTiles.clear(),this.texture}dispose(t){this.texture&&t&&t.deleteTexture(this.texture),this.texture=null,this.needsFullUpload=!0}};function EL(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=Z8(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=_X(e,t,r,n)),e.length>80*n){i=e[0],l=e[1];let u=i,d=l;for(let f=n;f<a;f+=n){let p=e[f],h=e[f+1];p<i&&(i=p),h<l&&(l=h),p>u&&(u=p),h>d&&(d=h)}c=Math.max(u-i,d-l),c=c!==0?32767/c:0}return bh(r,s,n,i,l,c,0),s}function Z8(e,t,n,o,a){let r;if(a===BX(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=j8(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=j8(s/o|0,e[s],e[s+1],r);return r&&du(r,r.next)&&(vh(r),r=r.next),r}function al(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(du(n,n.next)||$e(n.prev,n,n.next)===0)){if(vh(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function bh(e,t,n,o,a,r,s){if(!e)return;!s&&r&&IX(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?SX(e,o,a,r):vX(e)){t.push(l.i,e.i,c.i),vh(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=LX(al(e),t),bh(e,t,n,o,a,r,2)):s===2&&kX(e,t,n,o,a,r):bh(al(e),t,n,o,a,r,1);break}}}function vX(e){let t=e.prev,n=e,o=e.next;if($e(t,n,o)>=0)return!1;let a=t.x,r=n.x,s=o.x,i=t.y,l=n.y,c=o.y,u=Math.min(a,r,s),d=Math.min(i,l,c),f=Math.max(a,r,s),p=Math.max(i,l,c),h=o.next;for(;h!==t;){if(h.x>=u&&h.x<=f&&h.y>=d&&h.y<=p&&xh(a,i,r,l,s,c,h.x,h.y)&&$e(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function SX(e,t,n,o){let a=e.prev,r=e,s=e.next;if($e(a,r,s)>=0)return!1;let i=a.x,l=r.x,c=s.x,u=a.y,d=r.y,f=s.y,p=Math.min(i,l,c),h=Math.min(u,d,f),m=Math.max(i,l,c),x=Math.max(u,d,f),y=wL(p,h,t,n,o),g=wL(m,x,t,n,o),b=e.prevZ,A=e.nextZ;for(;b&&b.z>=y&&A&&A.z<=g;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&xh(i,u,l,d,c,f,b.x,b.y)&&$e(b.prev,b,b.next)>=0||(b=b.prevZ,A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&xh(i,u,l,d,c,f,A.x,A.y)&&$e(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&xh(i,u,l,d,c,f,b.x,b.y)&&$e(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=g;){if(A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&xh(i,u,l,d,c,f,A.x,A.y)&&$e(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function LX(e,t){let n=e;do{let o=n.prev,a=n.next.next;!du(o,a)&&Y8(o,n,n.next,a)&&Ah(o,a)&&Ah(a,o)&&(t.push(o.i,n.i,a.i),vh(n),vh(n.next),n=e=a),n=n.next}while(n!==e);return al(n)}function kX(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&OX(s,i)){let l=K8(s,i);s=al(s,s.next),l=al(l,l.next),bh(s,t,n,o,a,r,0),bh(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function _X(e,t,n,o){let a=[];for(let r=0,s=t.length;r<s;r++){let i=t[r]*o,l=r<s-1?t[r+1]*o:e.length,c=Z8(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(RX(c))}a.sort(wX);for(let r=0;r<a.length;r++)n=TX(a[r],n);return n}function wX(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){let o=(e.next.y-e.y)/(e.next.x-e.x),a=(t.next.y-t.y)/(t.next.x-t.x);n=o-a}return n}function TX(e,t){let n=EX(e,t);if(!n)return t;let o=K8(n,e);return al(o,o.next),al(n,n.next)}function EX(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(du(e,n))return n;do{if(du(e,n.next))return n.next;if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){let d=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(d<=o&&d>r&&(r=d,s=n.x<n.next.x?n:n.next,d===o))return s}n=n.next}while(n!==t);if(!s)return null;let i=s,l=s.x,c=s.y,u=1/0;n=s;do{if(o>=n.x&&n.x>=l&&o!==n.x&&X8(a<c?o:r,a,l,c,a<c?r:o,a,n.x,n.y)){let d=Math.abs(a-n.y)/(o-n.x);Ah(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&CX(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function CX(e,t){return $e(e.prev,e,t.prev)<0&&$e(t.next,e,e.next)<0}function IX(e,t,n,o){let a=e;do a.z===0&&(a.z=wL(a.x,a.y,t,n,o)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,MX(a)}function MX(e){let t,n=1;do{let o=e,a;e=null;let r=null;for(t=0;o;){t++;let s=o,i=0;for(let c=0;c<n&&(i++,s=s.nextZ,!!s);c++);let l=n;for(;i>0||l>0&&s;)i!==0&&(l===0||!s||o.z<=s.z)?(a=o,o=o.nextZ,i--):(a=s,s=s.nextZ,l--),r?r.nextZ=a:e=a,a.prevZ=r,r=a;o=s}r.nextZ=null,n*=2}while(t>1);return e}function wL(e,t,n,o,a){return e=(e-n)*a|0,t=(t-o)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function RX(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function X8(e,t,n,o,a,r,s,i){return(a-s)*(t-i)>=(e-s)*(r-i)&&(e-s)*(o-i)>=(n-s)*(t-i)&&(n-s)*(r-i)>=(a-s)*(o-i)}function xh(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&X8(e,t,n,o,a,r,s,i)}function OX(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!DX(e,t)&&(Ah(e,t)&&Ah(t,e)&&PX(e,t)&&($e(e.prev,e,t.prev)||$e(e,t.prev,t))||du(e,t)&&$e(e.prev,e,e.next)>0&&$e(t.prev,t,t.next)>0)}function $e(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function du(e,t){return e.x===t.x&&e.y===t.y}function Y8(e,t,n,o){let a=Hg($e(e,t,n)),r=Hg($e(e,t,o)),s=Hg($e(n,o,e)),i=Hg($e(n,o,t));return!!(a!==r&&s!==i||a===0&&Fg(e,n,t)||r===0&&Fg(e,o,t)||s===0&&Fg(n,e,o)||i===0&&Fg(n,t,o))}function Fg(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Hg(e){return e>0?1:e<0?-1:0}function DX(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Y8(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ah(e,t){return $e(e.prev,e,e.next)<0?$e(e,t,e.next)>=0&&$e(e,e.prev,t)>=0:$e(e,t,e.prev)<0||$e(e,e.next,t)<0}function PX(e,t){let n=e,o=!1,a=(e.x+t.x)/2,r=(e.y+t.y)/2;do n.y>r!=n.next.y>r&&n.next.y!==n.y&&a<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==e);return o}function K8(e,t){let n=TL(e.i,e.x,e.y),o=TL(t.i,t.x,t.y),a=e.next,r=t.prev;return e.next=t,t.prev=e,n.next=a,a.prev=n,o.next=n,n.prev=o,r.next=o,o.prev=r,o}function j8(e,t,n,o){let a=TL(e,t,n);return o?(a.next=o.next,a.prev=o,o.next.prev=a,o.next=a):(a.prev=a,a.next=a),a}function vh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function TL(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function BX(e,t,n,o){let a=0;for(let r=t,s=n-o;r<n;r+=o)a+=(e[s]-e[r])*(e[r+1]+e[s+1]),s=r;return a}var CL=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=P0.parse(e);return[t/255,n/255,o/255,a]}catch{return typeof console<"u"&&console.warn(`[WebGL2Target] cannot parse color '${e}', falling back to black`),[0,0,0,1]}};var ot=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},zt=(e,t,n,o)=>{let a=ot(e.createShader(t));if(e.shaderSource(a,n),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS)){let r=e.getShaderInfoLog(a);throw e.deleteShader(a),new Error(`${o} shader compile failed: ${r}`)}return a},Do=(e,t,n,o)=>{let a=ot(e.createProgram());if(e.attachShader(a,t),e.attachShader(a,n),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let r=e.getProgramInfoLog(a);throw e.deleteProgram(a),new Error(`${o} program link failed: ${r}`)}return a};var Sh=class{gl;program;vbo;vao;uTransform;uColor;uOpacity;uPxRange;uAtlas;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,UX,"MSDF"),o=zt(t,t.FRAGMENT_SHADER,GX,"MSDF");this.program=Do(t,n,o,"MSDF"),this.vbo=ot(t.createBuffer());let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aUV");this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.uPxRange=t.getUniformLocation(this.program,"uPxRange"),this.uAtlas=t.getUniformLocation(this.program,"uAtlas"),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,16,0),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,16,8),t.bindVertexArray(null)}drawText(t,n,o,a,r,s,i,l=0,c=0){if(t.length===0)return 0;let u=6,d=4,f=t.length*u*d;FX(f);let p=Ug,h=0,m=n,x=!0;for(let w of t){let L=w.codePointAt(0);if(L===void 0)continue;let k=r.getOrRasterize(L,c);if(!k){x=!1;break}let M=k.advance*a/k.unitsPerEm;if(k.empty){m+=M;continue}zX(p,h,k,m,o,a,r),h+=u*d,m+=M}if(x&&a>0&&J8(r,t,c,(m-n)/a),h===0)return m-n;let y=r.uploadTo(this.gl),g=this.gl;g.useProgram(this.program),g.bindVertexArray(this.vao),g.bindBuffer(g.ARRAY_BUFFER,this.vbo),g.bufferData(g.ARRAY_BUFFER,p.subarray(0,h),g.DYNAMIC_DRAW);let b=s.transform,A=b;if(l!==0){let w=-(m-n)*l;A={...b,e:b.e+b.a*w,f:b.f+b.b*w}}HX($8,A,i.width,i.height),g.uniformMatrix3fv(this.uTransform,!1,$8),g.uniform3f(this.uColor,s.color[0],s.color[1],s.color[2]),g.uniform1f(this.uOpacity,s.opacity);let _=r.tileSize-2*r.range,C=r.range*a/Math.max(1,_);return g.uniform1f(this.uPxRange,C),g.activeTexture(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y),g.uniform1i(this.uAtlas,0),g.drawArrays(g.TRIANGLES,0,h/d),g.bindVertexArray(null),m-n}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},NX=(e,t,n,o,a)=>{let r=o/e.unitsPerEm,s=Math.max(1,a.tileSize-2*a.range),i=Math.max(e.bboxW,e.bboxH)/s,l=e.bboxW/i+2*a.range,c=e.bboxH/i+2*a.range,u=a.range*i*r,d=e.bboxW*r+2*u,f=e.bboxH*r+2*u,p=t+e.bboxXMin*r-u,h=n+(-e.bboxYMin-e.bboxH)*r-u,m=p+d,x=h+f,y=.5,g=(e.atlasX+y)/a.atlasSize,b=(e.atlasY+y)/a.atlasSize,A=(e.atlasX+l-y)/a.atlasSize,_=(e.atlasY+c-y)/a.atlasSize;return{left:p,top:h,right:m,bottom:x,u0:g,v0:b,u1:A,v1:_}},IL=new WeakMap,Q8=(e,t)=>`${t}\0${e}`,J8=(e,t,n,o)=>{let a=IL.get(e);a||(a=new Map,IL.set(e,a));let r=Q8(t,n);if(a.delete(r),a.set(r,o),a.size>1024){let s=a.keys().next().value;s!==void 0&&a.delete(s)}},e6=(e,t,n=0)=>{if(e.length===0)return 0;let o=Q8(e,n),a=IL.get(t);if(a){let s=a.get(o);if(s!==void 0)return a.delete(o),a.set(o,s),s}let r=0;for(let s of e){let i=s.codePointAt(0);if(i===void 0)continue;let l=t.getOrRasterize(i,n);l&&(r+=l.advance/l.unitsPerEm)}return J8(t,e,n,r),r},zX=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=NX(n,o,a,r,s);e.set([i,l,d,f,c,l,p,f,i,u,d,h,c,l,p,f,c,u,p,h,i,u,d,h],t)},Ug=new Float32Array(512),$8=new Float32Array(9),FX=e=>{if(Ug.length>=e)return;let t=Ug.length;for(;t<e;)t*=2;Ug=new Float32Array(t)},HX=(e,t,n,o)=>{let a=2/n,r=-2/o;e[0]=t.a*a,e[1]=t.b*r,e[2]=0,e[3]=t.c*a,e[4]=t.d*r,e[5]=0,e[6]=t.e*a-1,e[7]=t.f*r+1,e[8]=1},UX=`#version 300 es
15
17
  in vec2 aPos;
16
18
  in vec2 aUV;
17
19
  uniform mat3 uTransform;
@@ -20,7 +22,7 @@ void main() {
20
22
  vec3 p = uTransform * vec3(aPos, 1.0);
21
23
  gl_Position = vec4(p.xy, 0.0, 1.0);
22
24
  vUV = aUV;
23
- }`,eX=`#version 300 es
25
+ }`,GX=`#version 300 es
24
26
  precision mediump float;
25
27
  uniform vec3 uColor;
26
28
  uniform float uOpacity;
@@ -46,7 +48,7 @@ void main() {
46
48
  // contract + blendFunc(ONE, 1-SRC_ALPHA).
47
49
  float a = alpha * uOpacity;
48
50
  fragColor = vec4(uColor * a, a);
49
- }`;var tX=10,kD=12,Eg=new Float32Array(64),wD=new Float32Array(64),po=new Float32Array(1024),ia=0,nX=e=>{if(Eg.length>=e)return;let t=Eg.length;for(;t<e;)t*=2;Eg=new Float32Array(t),wD=new Float32Array(t)},oX=e=>{if(po.length>=e)return;let t=po.length;for(;t<e;)t*=2;let n=new Float32Array(t);n.set(po.subarray(0,ia)),po=n},aX=(e,t)=>{ia+2>po.length&&oX(ia+2),po[ia++]=e,po[ia++]=t},rX=(e,t,n,o,a)=>{let r=e+n,s=t+o,i=Math.hypot(r,s);if(i<1e-6)return{ox:e*a,oy:t*a};r/=i,s/=i;let l=r*e+s*t,c=l>1e-6?a/l:a,u=Math.min(c,a*tX);return{ox:r*u,oy:s*u}},_D=(e,t,n,o,a,r,s,i,l,c,u,d,f)=>{if(o.width<=0||n<2)return;let p=o.width/2,h=n-1;nX(h);let m=Eg,x=wD;for(let S=0;S<h;S++){let L=v(t[S*2+2])-v(t[S*2]),M=v(t[S*2+3])-v(t[S*2+1]),B=Math.hypot(L,M)||1;m[S]=-M/B,x[S]=L/B}let y=n>=3&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1];ia=0;let g=aX,b=(S,L,M,B,W,ie,ne,j)=>{g(S+M,L+B),g(S-M,L-B),g(W+ne,ie+j),g(W+ne,ie+j),g(S-M,L-B),g(W-ne,ie-j)},A=S=>({ox:v(m[S])*p,oy:v(x[S])*p});for(let S=0;S<h;S++){let L=A(S);b(v(t[S*2]),v(t[S*2+1]),L.ox,L.oy,v(t[S*2+2]),v(t[S*2+3]),L.ox,L.oy)}let _=(S,L,M,B,W,ie)=>{if(o.join==="miter"){let{ox:ne,oy:j}=rX(M,B,W,ie,p),ve=M*ie-B*W;if(Math.abs(ve)<1e-9)return;let ye=ve<0?1:-1,ee=S+ye*ne,Se=L+ye*j,Oe=ye*M*p,qt=ye*B*p,xn=ye*W*p,Oo=ye*ie*p;g(S,L),g(S+Oe,L+qt),g(ee,Se),g(S,L),g(ee,Se),g(S+xn,L+Oo)}else if(o.join==="bevel"){let ne=M*ie-B*W;if(Math.abs(ne)<1e-9)return;let j=ne<0?1:-1,ve=S+j*M*p,ye=L+j*B*p,ee=S+j*W*p,Se=L+j*ie*p;g(S,L),g(ve,ye),g(ee,Se)}else{let ne=M*ie-B*W;if(Math.abs(ne)<1e-9)return;let j=ne<0?1:-1,ve=Math.atan2(j*B,j*M),ee=Math.atan2(j*ie,j*W)-ve;for(;ee>Math.PI;)ee-=2*Math.PI;for(;ee<-Math.PI;)ee+=2*Math.PI;let Se=Math.max(2,Math.ceil(Math.abs(ee)/Math.PI*kD)),Oe=S+Math.cos(ve)*p,qt=L+Math.sin(ve)*p;for(let xn=1;xn<=Se;xn++){let Oo=xn/Se,vt=ve+ee*Oo,Eh=S+Math.cos(vt)*p,Th=L+Math.sin(vt)*p;g(S,L),g(Oe,qt),g(Eh,Th),Oe=Eh,qt=Th}}};for(let S=1;S<h;S++)_(v(t[S*2]),v(t[S*2+1]),v(m[S-1]),v(x[S-1]),v(m[S]),v(x[S]));if(y&&_(v(t[0]),v(t[1]),v(m[h-1]),v(x[h-1]),v(m[0]),v(x[0])),y||(LD(g,v(t[0]),v(t[1]),v(t[2]),v(t[3]),v(m[0]),v(x[0]),p,o.cap,!0),LD(g,v(t[(n-1)*2]),v(t[(n-1)*2+1]),v(t[(n-2)*2]),v(t[(n-2)*2+1]),v(m[h-1]),v(x[h-1]),p,o.cap,!1)),ia===0)return;let T=2/r.width,w=-2/r.height;for(let S=0;S<ia;S+=2){let L=v(po[S]),M=v(po[S+1]),B=a.a*L+a.c*M+a.e,W=a.b*L+a.d*M+a.f;po[S]=B*T-1,po[S+1]=W*w+1}e.useProgram(s),e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,po.subarray(0,ia),e.DYNAMIC_DRAW),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,2,e.FLOAT,!1,0,0),e.uniformMatrix3fv(i,!1,f),e.uniform3f(l,o.color[0],o.color[1],o.color[2]),e.uniform1f(c,o.opacity),e.drawArrays(e.TRIANGLES,0,ia/2)},LD=(e,t,n,o,a,r,s,i,l,c)=>{if(l==="butt")return;let u=o-t,d=a-n,f=Math.hypot(u,d)||1,p=-u/f,h=-d/f,m=c?1:-1,x=m*p,y=m*h;if(l==="square"){let S={x:t+r*i,y:n+s*i},L={x:t-r*i,y:n-s*i},M={x:S.x+x*i,y:S.y+y*i},B={x:L.x+x*i,y:L.y+y*i};e(S.x,S.y),e(M.x,M.y),e(L.x,L.y),e(L.x,L.y),e(M.x,M.y),e(B.x,B.y);return}let g=Math.atan2(s,r),b=kD,_=r*y-s*x>=0?1:-1,T=t+Math.cos(g)*i,w=n+Math.sin(g)*i;for(let S=1;S<=b;S++){let L=S/b,M=g+_*Math.PI*L,B=t+Math.cos(M)*i,W=n+Math.sin(M)*i;e(t,n),e(T,w),e(B,W),T=B,w=W}};var ED=(e,t,n,o,a=8)=>{let r=[],s=e;for(let i=0;i<a;i++){let l=i/a,c=(i+1)/a,u=(l+c)/2,d=cn.cubicAt(e,t,n,o,c),f=cn.cubicAt(e,t,n,o,u),p={x:2*f.x-(s.x+d.x)/2,y:2*f.y-(s.y+d.y)/2};r.push([s,p,d]),s=d}return r};var hh=class{positionsBuf=new Float32Array(CD*6);uvsBuf=new Float32Array(CD*9);count=0;get triangleCount(){return this.count}get positions(){return this.positionsBuf.subarray(0,this.count*6)}get uvs(){return this.uvsBuf.subarray(0,this.count*9)}reset(){this.count=0}addQuadratic(t,n,o){let a=(n.x-t.x)*(o.y-t.y)-(n.y-t.y)*(o.x-t.x);if(a===0)return!1;let r=a>0?1:-1;this.ensureCapacity(this.count+1);let s=this.count*6,i=this.positionsBuf;i[s++]=t.x,i[s++]=t.y,i[s++]=n.x,i[s++]=n.y,i[s++]=o.x,i[s]=o.y;let l=this.count*9,c=this.uvsBuf;return c[l++]=0,c[l++]=0,c[l++]=r,c[l++]=.5,c[l++]=0,c[l++]=r,c[l++]=1,c[l++]=1,c[l]=r,this.count++,!0}addCubic(t,n,o,a,r=8){for(let[s,i,l]of ED(t,n,o,a,r))this.addQuadratic(s,i,l)}ensureCapacity(t){if(this.positionsBuf.length>=t*6)return;let n=this.positionsBuf.length/6;for(;n<t;)n*=2;let o=new Float32Array(n*6);o.set(this.positionsBuf),this.positionsBuf=o;let a=new Float32Array(n*9);a.set(this.uvsBuf),this.uvsBuf=a}},CD=64;var Tg=class{gl;program;vbo;uvBuf;uTransform;uColor;uOpacity;aPos;aUVW;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,hX,"Loop-Blinn"),o=Nt(t,t.FRAGMENT_SHADER,mX,"Loop-Blinn");this.program=Mo(t,n,o,"Loop-Blinn"),this.vbo=Wt(t.createBuffer()),this.uvBuf=Wt(t.createBuffer()),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aUVW=t.getAttribLocation(this.program,"aUVW"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity")}draw(t,n,o,a,r){if(t.length===0||o<=0)return;let{positions:s,uvs:i}=pX(t);if(s.length===0)return;let l=this.gl;l.useProgram(this.program),l.bindBuffer(l.ARRAY_BUFFER,this.vbo),l.bufferData(l.ARRAY_BUFFER,s,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this.aPos),l.vertexAttribPointer(this.aPos,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,this.uvBuf),l.bufferData(l.ARRAY_BUFFER,i,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this.aUVW),l.vertexAttribPointer(this.aUVW,3,l.FLOAT,!1,0,0),l.uniformMatrix3fv(this.uTransform,!1,iX(a,r.width,r.height)),l.uniform3f(this.uColor,n[0],n[1],n[2]),l.uniform1f(this.uOpacity,o),l.drawArrays(l.TRIANGLES,0,s.length/2)}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteBuffer(this.uvBuf),this.gl.deleteProgram(this.program)}},la=new Float32Array(9),iX=(e,t,n)=>{let o=2/t,a=-2/n;return la[0]=e.a*o,la[1]=e.b*a,la[2]=0,la[3]=e.c*o,la[4]=e.d*a,la[5]=0,la[6]=e.e*o-1,la[7]=e.f*a+1,la[8]=1,la},ms=new Map,ol=new Float64Array(64),lX=e=>{if(ol.length>=e)return;let t=ol.length;for(;t<e;)t*=2;ol=new Float64Array(t)},ID=new Float64Array(1),TD=new Uint32Array(ID.buffer),mh=new hh,cX=e=>{lX(e.length*9);let t=ol,n=0;for(let o of e){t[n++]=o.kind==="q"?1:2;for(let a of o.points)t[n++]=a.x,t[n++]=a.y}return n},uX=(e,t)=>{let n=2166136261;for(let o=0;o<t;o++)ID[0]=e[o]??0,n=Math.imul(n^(TD[0]??0),16777619),n=Math.imul(n^(TD[1]??0),16777619);return n>>>0},dX=(e,t,n)=>{if(e.length!==n)return!1;for(let o=0;o<n;o++)if(e[o]!==t[o])return!1;return!0},fX=(e,t)=>{mh.reset();for(let n of e)if(n.kind==="q"){let[o,a,r]=n.points;if(!o||!a||!r)continue;mh.addQuadratic(o,a,r)}else{let[o,a,r,s]=n.points;if(!o||!a||!r||!s)continue;mh.addCubic(o,a,r,s)}return{key:ol.slice(0,t),positions:new Float32Array(mh.positions),uvs:new Float32Array(mh.uvs)}},pX=e=>{let t=cX(e),n=uX(ol,t),o=ms.get(n);if(o&&dX(o.key,ol,t))return ms.delete(n),ms.set(n,o),o;let a=fX(e,t);for(ms.delete(n),ms.set(n,a);ms.size>4096;){let r=ms.keys().next().value;if(r===void 0)break;ms.delete(r)}return a},hX=`#version 300 es
51
+ }`;var WX=10,n6=12,Gg=new Float32Array(64),o6=new Float32Array(64),mo=new Float32Array(1024),ca=0,qX=e=>{if(Gg.length>=e)return;let t=Gg.length;for(;t<e;)t*=2;Gg=new Float32Array(t),o6=new Float32Array(t)},VX=e=>{if(mo.length>=e)return;let t=mo.length;for(;t<e;)t*=2;let n=new Float32Array(t);n.set(mo.subarray(0,ca)),mo=n},jX=(e,t)=>{ca+2>mo.length&&VX(ca+2),mo[ca++]=e,mo[ca++]=t},ZX=(e,t,n,o,a)=>{let r=e+n,s=t+o,i=Math.hypot(r,s);if(i<1e-6)return{ox:e*a,oy:t*a};r/=i,s/=i;let l=r*e+s*t,c=l>1e-6?a/l:a,u=Math.min(c,a*WX);return{ox:r*u,oy:s*u}},a6=(e,t,n,o,a,r,s,i,l,c,u,d,f)=>{if(o.width<=0||n<2)return;let p=o.width/2,h=n-1;qX(h);let m=Gg,x=o6;for(let L=0;L<h;L++){let k=v(t[L*2+2])-v(t[L*2]),M=v(t[L*2+3])-v(t[L*2+1]),B=Math.hypot(k,M)||1;m[L]=-M/B,x[L]=k/B}let y=n>=3&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1];ca=0;let g=jX,b=(L,k,M,B,G,ie,ne,V)=>{g(L+M,k+B),g(L-M,k-B),g(G+ne,ie+V),g(G+ne,ie+V),g(L-M,k-B),g(G-ne,ie-V)},A=L=>({ox:v(m[L])*p,oy:v(x[L])*p});for(let L=0;L<h;L++){let k=A(L);b(v(t[L*2]),v(t[L*2+1]),k.ox,k.oy,v(t[L*2+2]),v(t[L*2+3]),k.ox,k.oy)}let _=(L,k,M,B,G,ie)=>{if(o.join==="miter"){let{ox:ne,oy:V}=ZX(M,B,G,ie,p),ve=M*ie-B*G;if(Math.abs(ve)<1e-9)return;let ge=ve<0?1:-1,ee=L+ge*ne,Se=k+ge*V,Oe=ge*M*p,qt=ge*B*p,xn=ge*G*p,Bo=ge*ie*p;g(L,k),g(L+Oe,k+qt),g(ee,Se),g(L,k),g(ee,Se),g(L+xn,k+Bo)}else if(o.join==="bevel"){let ne=M*ie-B*G;if(Math.abs(ne)<1e-9)return;let V=ne<0?1:-1,ve=L+V*M*p,ge=k+V*B*p,ee=L+V*G*p,Se=k+V*ie*p;g(L,k),g(ve,ge),g(ee,Se)}else{let ne=M*ie-B*G;if(Math.abs(ne)<1e-9)return;let V=ne<0?1:-1,ve=Math.atan2(V*B,V*M),ee=Math.atan2(V*ie,V*G)-ve;for(;ee>Math.PI;)ee-=2*Math.PI;for(;ee<-Math.PI;)ee+=2*Math.PI;let Se=Math.max(2,Math.ceil(Math.abs(ee)/Math.PI*n6)),Oe=L+Math.cos(ve)*p,qt=k+Math.sin(ve)*p;for(let xn=1;xn<=Se;xn++){let Bo=xn/Se,St=ve+ee*Bo,Hh=L+Math.cos(St)*p,Uh=k+Math.sin(St)*p;g(L,k),g(Oe,qt),g(Hh,Uh),Oe=Hh,qt=Uh}}};for(let L=1;L<h;L++)_(v(t[L*2]),v(t[L*2+1]),v(m[L-1]),v(x[L-1]),v(m[L]),v(x[L]));if(y&&_(v(t[0]),v(t[1]),v(m[h-1]),v(x[h-1]),v(m[0]),v(x[0])),y||(t6(g,v(t[0]),v(t[1]),v(t[2]),v(t[3]),v(m[0]),v(x[0]),p,o.cap,!0),t6(g,v(t[(n-1)*2]),v(t[(n-1)*2+1]),v(t[(n-2)*2]),v(t[(n-2)*2+1]),v(m[h-1]),v(x[h-1]),p,o.cap,!1)),ca===0)return;let C=2/r.width,w=-2/r.height;for(let L=0;L<ca;L+=2){let k=v(mo[L]),M=v(mo[L+1]),B=a.a*k+a.c*M+a.e,G=a.b*k+a.d*M+a.f;mo[L]=B*C-1,mo[L+1]=G*w+1}e.useProgram(s),e.bindVertexArray(d),e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,mo.subarray(0,ca),e.DYNAMIC_DRAW),e.uniformMatrix3fv(i,!1,f),e.uniform3f(l,o.color[0],o.color[1],o.color[2]),e.uniform1f(c,o.opacity),e.drawArrays(e.TRIANGLES,0,ca/2),e.bindVertexArray(null)},t6=(e,t,n,o,a,r,s,i,l,c)=>{if(l==="butt")return;let u=o-t,d=a-n,f=Math.hypot(u,d)||1,p=-u/f,h=-d/f,m=c?1:-1,x=m*p,y=m*h;if(l==="square"){let L={x:t+r*i,y:n+s*i},k={x:t-r*i,y:n-s*i},M={x:L.x+x*i,y:L.y+y*i},B={x:k.x+x*i,y:k.y+y*i};e(L.x,L.y),e(M.x,M.y),e(k.x,k.y),e(k.x,k.y),e(M.x,M.y),e(B.x,B.y);return}let g=Math.atan2(s,r),b=n6,_=r*y-s*x>=0?1:-1,C=t+Math.cos(g)*i,w=n+Math.sin(g)*i;for(let L=1;L<=b;L++){let k=L/b,M=g+_*Math.PI*k,B=t+Math.cos(M)*i,G=n+Math.sin(M)*i;e(t,n),e(C,w),e(B,G),C=B,w=G}};var s6=(e,t,n,o,a=8)=>{let r=[],s=e;for(let i=0;i<a;i++){let l=i/a,c=(i+1)/a,u=(l+c)/2,d=cn.cubicAt(e,t,n,o,c),f=cn.cubicAt(e,t,n,o,u),p={x:2*f.x-(s.x+d.x)/2,y:2*f.y-(s.y+d.y)/2};r.push([s,p,d]),s=d}return r};var Lh=class{positionsBuf=new Float32Array(r6*6);uvsBuf=new Float32Array(r6*9);count=0;get triangleCount(){return this.count}get positions(){return this.positionsBuf.subarray(0,this.count*6)}get uvs(){return this.uvsBuf.subarray(0,this.count*9)}reset(){this.count=0}addQuadratic(t,n,o){let a=(n.x-t.x)*(o.y-t.y)-(n.y-t.y)*(o.x-t.x);if(a===0)return!1;let r=a>0?1:-1;this.ensureCapacity(this.count+1);let s=this.count*6,i=this.positionsBuf;i[s++]=t.x,i[s++]=t.y,i[s++]=n.x,i[s++]=n.y,i[s++]=o.x,i[s]=o.y;let l=this.count*9,c=this.uvsBuf;return c[l++]=0,c[l++]=0,c[l++]=r,c[l++]=.5,c[l++]=0,c[l++]=r,c[l++]=1,c[l++]=1,c[l]=r,this.count++,!0}addCubic(t,n,o,a,r=8){for(let[s,i,l]of s6(t,n,o,a,r))this.addQuadratic(s,i,l)}ensureCapacity(t){if(this.positionsBuf.length>=t*6)return;let n=this.positionsBuf.length/6;for(;n<t;)n*=2;let o=new Float32Array(n*6);o.set(this.positionsBuf),this.positionsBuf=o;let a=new Float32Array(n*9);a.set(this.uvsBuf),this.uvsBuf=a}},r6=64;var _h=class{gl;program;vbo;uvBuf;vao;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,nY,"Loop-Blinn"),o=zt(t,t.FRAGMENT_SHADER,oY,"Loop-Blinn");this.program=Do(t,n,o,"Loop-Blinn"),this.vbo=ot(t.createBuffer()),this.uvBuf=ot(t.createBuffer());let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aUVW");this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuf),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,3,t.FLOAT,!1,0,0),t.bindVertexArray(null)}draw(t,n,o,a,r){if(t.length===0||o<=0)return;let{positions:s,uvs:i}=tY(t);if(s.length===0)return;let l=this.gl;l.useProgram(this.program),l.bindVertexArray(this.vao),l.bindBuffer(l.ARRAY_BUFFER,this.vbo),l.bufferData(l.ARRAY_BUFFER,s,l.DYNAMIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,this.uvBuf),l.bufferData(l.ARRAY_BUFFER,i,l.DYNAMIC_DRAW),l.uniformMatrix3fv(this.uTransform,!1,YX(a,r.width,r.height)),l.uniform3f(this.uColor,n[0],n[1],n[2]),l.uniform1f(this.uOpacity,o),l.drawArrays(l.TRIANGLES,0,s.length/2),l.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteBuffer(this.uvBuf),this.gl.deleteProgram(this.program)}},ua=new Float32Array(9),YX=(e,t,n)=>{let o=2/t,a=-2/n;return ua[0]=e.a*o,ua[1]=e.b*a,ua[2]=0,ua[3]=e.c*o,ua[4]=e.d*a,ua[5]=0,ua[6]=e.e*o-1,ua[7]=e.f*a+1,ua[8]=1,ua},ys=new Map,rl=new Float64Array(64),KX=e=>{if(rl.length>=e)return;let t=rl.length;for(;t<e;)t*=2;rl=new Float64Array(t)},l6=new Float64Array(1),i6=new Uint32Array(l6.buffer),kh=new Lh,$X=e=>{KX(e.length*9);let t=rl,n=0;for(let o of e){t[n++]=o.kind==="q"?1:2;for(let a of o.points)t[n++]=a.x,t[n++]=a.y}return n},QX=(e,t)=>{let n=2166136261;for(let o=0;o<t;o++)l6[0]=e[o]??0,n=Math.imul(n^(i6[0]??0),16777619),n=Math.imul(n^(i6[1]??0),16777619);return n>>>0},JX=(e,t,n)=>{if(e.length!==n)return!1;for(let o=0;o<n;o++)if(e[o]!==t[o])return!1;return!0},eY=(e,t)=>{kh.reset();for(let n of e)if(n.kind==="q"){let[o,a,r]=n.points;if(!o||!a||!r)continue;kh.addQuadratic(o,a,r)}else{let[o,a,r,s]=n.points;if(!o||!a||!r||!s)continue;kh.addCubic(o,a,r,s)}return{key:rl.slice(0,t),positions:new Float32Array(kh.positions),uvs:new Float32Array(kh.uvs)}},tY=e=>{let t=$X(e),n=QX(rl,t),o=ys.get(n);if(o&&JX(o.key,rl,t))return ys.delete(n),ys.set(n,o),o;let a=eY(e,t);for(ys.delete(n),ys.set(n,a);ys.size>4096;){let r=ys.keys().next().value;if(r===void 0)break;ys.delete(r)}return a},nY=`#version 300 es
50
52
  in vec2 aPos;
51
53
  in vec3 aUVW;
52
54
  uniform mat3 uTransform;
@@ -55,7 +57,7 @@ void main() {
55
57
  vec3 p = uTransform * vec3(aPos, 1.0);
56
58
  gl_Position = vec4(p.xy, 0.0, 1.0);
57
59
  vUVW = aUVW;
58
- }`,mX=`#version 300 es
60
+ }`,oY=`#version 300 es
59
61
  precision mediump float;
60
62
  uniform vec3 uColor;
61
63
  uniform float uOpacity;
@@ -78,7 +80,7 @@ void main() {
78
80
  // contract + blendFunc(ONE, 1-SRC_ALPHA).
79
81
  float a = coverage * uOpacity;
80
82
  fragColor = vec4(uColor * a, a);
81
- }`;var ca=new Float32Array(9),Ig=class{gl;program;vbo;aPos;aLocal;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,yX,"Ellipse"),o=Nt(t,t.FRAGMENT_SHADER,gX,"Ellipse");this.program=Mo(t,n,o,"Ellipse"),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aLocal=t.getAttribLocation(this.program,"aLocal"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.vbo=Wt(t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,-1,-1,1,0,1,-1,0,1,-1,1,1,1,1,1]),t.STATIC_DRAW)}draw(t,n,o,a,r,s,i,l){if(s<=0||o<=0||a<=0)return;let c=this.gl;c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,this.vbo),c.enableVertexAttribArray(this.aPos),c.vertexAttribPointer(this.aPos,2,c.FLOAT,!1,16,0),c.enableVertexAttribArray(this.aLocal),c.vertexAttribPointer(this.aLocal,2,c.FLOAT,!1,16,8);let u=2*o,d=2*a,f=t-o,p=n-a,h=2/l.width,m=-2/l.height,x=i;ca[0]=x.a*u*h,ca[1]=x.b*u*m,ca[2]=0,ca[3]=x.c*d*h,ca[4]=x.d*d*m,ca[5]=0,ca[6]=(x.a*f+x.c*p+x.e)*h-1,ca[7]=(x.b*f+x.d*p+x.f)*m+1,ca[8]=1,c.uniformMatrix3fv(this.uTransform,!1,ca),c.uniform3f(this.uColor,r[0],r[1],r[2]),c.uniform1f(this.uOpacity,s),c.drawArrays(c.TRIANGLE_STRIP,0,4)}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},yX=`#version 300 es
83
+ }`;var da=new Float32Array(9),wh=class{gl;program;vbo;vao;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,aY,"Ellipse"),o=zt(t,t.FRAGMENT_SHADER,rY,"Ellipse");this.program=Do(t,n,o,"Ellipse");let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aLocal");this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.vbo=ot(t.createBuffer()),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,-1,-1,1,0,1,-1,0,1,-1,1,1,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,16,0),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,16,8),t.bindVertexArray(null)}draw(t,n,o,a,r,s,i,l){if(s<=0||o<=0||a<=0)return;let c=this.gl;c.useProgram(this.program),c.bindVertexArray(this.vao);let u=2*o,d=2*a,f=t-o,p=n-a,h=2/l.width,m=-2/l.height,x=i;da[0]=x.a*u*h,da[1]=x.b*u*m,da[2]=0,da[3]=x.c*d*h,da[4]=x.d*d*m,da[5]=0,da[6]=(x.a*f+x.c*p+x.e)*h-1,da[7]=(x.b*f+x.d*p+x.f)*m+1,da[8]=1,c.uniformMatrix3fv(this.uTransform,!1,da),c.uniform3f(this.uColor,r[0],r[1],r[2]),c.uniform1f(this.uOpacity,s),c.drawArrays(c.TRIANGLE_STRIP,0,4),c.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},aY=`#version 300 es
82
84
  in vec2 aPos;
83
85
  in vec2 aLocal;
84
86
  uniform mat3 uTransform;
@@ -87,7 +89,7 @@ void main() {
87
89
  vec3 p = uTransform * vec3(aPos, 1.0);
88
90
  gl_Position = vec4(p.xy, 0.0, 1.0);
89
91
  vLocal = aLocal;
90
- }`,gX=`#version 300 es
92
+ }`,rY=`#version 300 es
91
93
  precision mediump float;
92
94
  uniform vec3 uColor;
93
95
  uniform float uOpacity;
@@ -100,7 +102,7 @@ void main() {
100
102
  if (coverage <= 0.0) discard;
101
103
  float a = coverage * uOpacity;
102
104
  fragColor = vec4(uColor * a, a);
103
- }`;var yh=10,Mg=class{data;instanceCount=0;constructor(t=256){this.data=new Float32Array(Math.max(1,t)*yh)}get pending(){return this.instanceCount}add(t,n,o,a,r,s,i,l,c,u){let d=(this.instanceCount+1)*yh;if(d>this.data.length){let p=this.data.length;for(;p<d;)p*=2;let h=new Float32Array(p);h.set(this.data),this.data=h}let f=this.instanceCount*yh;this.data[f]=t,this.data[f+1]=n,this.data[f+2]=o,this.data[f+3]=a,this.data[f+4]=r,this.data[f+5]=s,this.data[f+6]=i,this.data[f+7]=l,this.data[f+8]=c,this.data[f+9]=u,this.instanceCount++}flush(t){return this.instanceCount===0?!1:(t(this.data,this.instanceCount),this.instanceCount=0,!0)}reset(){this.instanceCount=0}},Rg=class{gl;program;vao;unitQuadVbo;instanceVbo;instanceBytes=0;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,xX,"RectInstance"),o=Nt(t,t.FRAGMENT_SHADER,bX,"RectInstance");this.program=Mo(t,n,o,"RectInstance");let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aM0"),s=t.getAttribLocation(this.program,"aM1"),i=t.getAttribLocation(this.program,"aTrans"),l=t.getAttribLocation(this.program,"aColor");this.vao=Wt(t.createVertexArray()),this.unitQuadVbo=Wt(t.createBuffer()),this.instanceVbo=Wt(t.createBuffer()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.unitQuadVbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(a,0);let c=yh*4;t.bindBuffer(t.ARRAY_BUFFER,this.instanceVbo),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,c,0),t.vertexAttribDivisor(r,1),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,c,8),t.vertexAttribDivisor(s,1),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,c,16),t.vertexAttribDivisor(i,1),t.enableVertexAttribArray(l),t.vertexAttribPointer(l,4,t.FLOAT,!1,c,24),t.vertexAttribDivisor(l,1),t.bindVertexArray(null)}draw(t,n){if(n===0)return;let o=this.gl,a=t.subarray(0,n*yh);o.useProgram(this.program),o.bindVertexArray(this.vao),o.bindBuffer(o.ARRAY_BUFFER,this.instanceVbo);let r=a.byteLength;r>this.instanceBytes?(o.bufferData(o.ARRAY_BUFFER,a,o.DYNAMIC_DRAW),this.instanceBytes=r):o.bufferSubData(o.ARRAY_BUFFER,0,a),o.drawArraysInstanced(o.TRIANGLE_STRIP,0,4,n),o.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.unitQuadVbo),this.gl.deleteBuffer(this.instanceVbo),this.gl.deleteProgram(this.program)}},xX=`#version 300 es
105
+ }`;var Th=10,Wg=class{data;instanceCount=0;constructor(t=256){this.data=new Float32Array(Math.max(1,t)*Th)}get pending(){return this.instanceCount}add(t,n,o,a,r,s,i,l,c,u){let d=(this.instanceCount+1)*Th;if(d>this.data.length){let p=this.data.length;for(;p<d;)p*=2;let h=new Float32Array(p);h.set(this.data),this.data=h}let f=this.instanceCount*Th;this.data[f]=t,this.data[f+1]=n,this.data[f+2]=o,this.data[f+3]=a,this.data[f+4]=r,this.data[f+5]=s,this.data[f+6]=i,this.data[f+7]=l,this.data[f+8]=c,this.data[f+9]=u,this.instanceCount++}flush(t){return this.instanceCount===0?!1:(t(this.data,this.instanceCount),this.instanceCount=0,!0)}reset(){this.instanceCount=0}},Eh=class{gl;program;vao;unitQuadVbo;instanceVbo;instanceBytes=0;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,sY,"RectInstance"),o=zt(t,t.FRAGMENT_SHADER,iY,"RectInstance");this.program=Do(t,n,o,"RectInstance");let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aM0"),s=t.getAttribLocation(this.program,"aM1"),i=t.getAttribLocation(this.program,"aTrans"),l=t.getAttribLocation(this.program,"aColor");this.vao=ot(t.createVertexArray()),this.unitQuadVbo=ot(t.createBuffer()),this.instanceVbo=ot(t.createBuffer()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.unitQuadVbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(a,0);let c=Th*4;t.bindBuffer(t.ARRAY_BUFFER,this.instanceVbo),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,c,0),t.vertexAttribDivisor(r,1),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,c,8),t.vertexAttribDivisor(s,1),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,c,16),t.vertexAttribDivisor(i,1),t.enableVertexAttribArray(l),t.vertexAttribPointer(l,4,t.FLOAT,!1,c,24),t.vertexAttribDivisor(l,1),t.bindVertexArray(null)}draw(t,n){if(n===0)return;let o=this.gl,a=t.subarray(0,n*Th);o.useProgram(this.program),o.bindVertexArray(this.vao),o.bindBuffer(o.ARRAY_BUFFER,this.instanceVbo);let r=a.byteLength;r>this.instanceBytes?(o.bufferData(o.ARRAY_BUFFER,a,o.DYNAMIC_DRAW),this.instanceBytes=r):o.bufferSubData(o.ARRAY_BUFFER,0,a),o.drawArraysInstanced(o.TRIANGLE_STRIP,0,4,n),o.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.unitQuadVbo),this.gl.deleteBuffer(this.instanceVbo),this.gl.deleteProgram(this.program)}},sY=`#version 300 es
104
106
  in vec2 aPos;
105
107
  in vec2 aM0;
106
108
  in vec2 aM1;
@@ -113,7 +115,7 @@ void main() {
113
115
  vec2 p = aM0 * aPos.x + aM1 * aPos.y + aTrans;
114
116
  gl_Position = vec4(p, 0.0, 1.0);
115
117
  vColor = aColor;
116
- }`,bX=`#version 300 es
118
+ }`,iY=`#version 300 es
117
119
  precision mediump float;
118
120
  in vec4 vColor;
119
121
  out vec4 fragColor;
@@ -121,7 +123,7 @@ void main() {
121
123
  // Premultiplied output (rgb*a, a) \u2014 matches premultipliedAlpha:true +
122
124
  // blendFunc(ONE, 1-SRC_ALPHA).
123
125
  fragColor = vec4(vColor.rgb * vColor.a, vColor.a);
124
- }`;var Og=class{gl;program;vbo;dynamicVbo;uTransformLoc;uColorLoc;uOpacityLoc;aPosLoc;_size;fillColor=[0,0,0];fillAlpha=1;strokeColor=[0,0,0];strokeAlpha=1;fillColorString="#000";strokeWidth=1;lineCap="butt";lineJoin="miter";dashArray=null;opacity=1;currentPath=null;fontFamily="sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";pathXY=new Float64Array(LX*2);pathPts=0;pushPathPoint(t,n){if((this.pathPts+1)*2>this.pathXY.length){let o=new Float64Array(this.pathXY.length*2);o.set(this.pathXY),this.pathXY=o}this.pathXY[this.pathPts*2]=t,this.pathXY[this.pathPts*2+1]=n,this.pathPts++}currentCurves=[];currentEllipse=null;transform={a:1,b:0,c:0,d:1,e:0,f:0};stack=[];rectBatch=new Mg;rectPipeline=null;constructor(t,n,o,a={}){let r=a.preserveDrawingBuffer??!0,s=t.getContext("webgl2",{antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:r});if(s??=t.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:r}),!s)throw new Error("WebGL2 unavailable in this environment (probably hit the per-page GL context cap; Chrome allows ~16). LayeredSurface will fall back to canvas2d.");this.gl=s,this._size={width:n,height:o};let i=Nt(this.gl,this.gl.VERTEX_SHADER,EX,"WebGL2"),l=Nt(this.gl,this.gl.FRAGMENT_SHADER,TX,"WebGL2");this.program=Mo(this.gl,i,l,"WebGL2"),this.gl.useProgram(this.program),this.vbo=Wt(this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),this.gl.STATIC_DRAW),this.dynamicVbo=Wt(this.gl.createBuffer()),this.aPosLoc=this.gl.getAttribLocation(this.program,"aPos"),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.uTransformLoc=this.gl.getUniformLocation(this.program,"uTransform"),this.uColorLoc=this.gl.getUniformLocation(this.program,"uColor"),this.uOpacityLoc=this.gl.getUniformLocation(this.program,"uOpacity"),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.viewport(0,0,t.width,t.height)}get size(){return this._size}resize(t,n){this.flushRectBatch(),this._size.width=t,this._size.height=n,this.gl.viewport(0,0,t,n)}dispose(){this.rectBatch.reset(),this.rectPipeline&&(this.rectPipeline.dispose(),this.rectPipeline=null),this.msdfPipeline&&(this.msdfPipeline.dispose(),this.msdfPipeline=null),this.glyphAtlas&&(this.glyphAtlas.dispose(this.gl),this.glyphAtlas=null,this.glyphAtlasShaper=null),this.indexBuffer&&(this.gl.deleteBuffer(this.indexBuffer),this.indexBuffer=null),this.curvePipeline&&(this.curvePipeline.dispose(),this.curvePipeline=null),this.ellipsePipeline&&(this.ellipsePipeline.dispose(),this.ellipsePipeline=null),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVbo&&(this.gl.deleteBuffer(this.imageQuadVbo),this.imageQuadVbo=null);for(let n of this.textures.values())this.gl.deleteTexture(n);this.textures.clear(),this.gl.getExtension("WEBGL_lose_context")?.loseContext()}setFill(t){let n=uL(t);this.fillColor=[n[0],n[1],n[2]],this.fillAlpha=n[3],this.fillColorString=t??"transparent"}setOpacity(t){this.opacity=t}save(){this.stack.push({transform:{...this.transform},fillColor:[this.fillColor[0],this.fillColor[1],this.fillColor[2]],fillAlpha:this.fillAlpha,strokeColor:[this.strokeColor[0],this.strokeColor[1],this.strokeColor[2]],strokeAlpha:this.strokeAlpha,fillColorString:this.fillColorString,strokeWidth:this.strokeWidth,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,opacity:this.opacity,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline})}restore(){let t=this.stack.pop();t&&(this.transform=t.transform,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.strokeColor=t.strokeColor,this.strokeAlpha=t.strokeAlpha,this.fillColorString=t.fillColorString,this.strokeWidth=t.strokeWidth,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.opacity=t.opacity,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline)}setTransform(t){this.transform={a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}resetTransform(){this.transform={a:1,b:0,c:0,d:1,e:0,f:0}}translate(t,n){this.transform.e+=this.transform.a*t+this.transform.c*n,this.transform.f+=this.transform.b*t+this.transform.d*n}rotate(t){let n=Math.cos(t),o=Math.sin(t),{a,b:r,c:s,d:i}=this.transform;this.transform.a=a*n+s*o,this.transform.b=r*n+i*o,this.transform.c=a*-o+s*n,this.transform.d=r*-o+i*n}scale(t,n){this.transform.a*=t,this.transform.b*=t,this.transform.c*=n,this.transform.d*=n}beginPath(){this.currentPath=null,this.pathPts=0,this.currentCurves=[],this.currentEllipse=null}rect(t,n,o,a){this._pathRect.x=t,this._pathRect.y=n,this._pathRect.width=o,this._pathRect.height=a,this.currentPath=this._pathRect}_pathRect={x:0,y:0,width:0,height:0};moveTo(t,n){this.pathPts=0,this.pushPathPoint(t,n)}lineTo(t,n){this.pushPathPoint(t,n)}closePath(){this.pathPts>1&&this.pushPathPoint(v(this.pathXY[0]),v(this.pathXY[1]))}ellipse(t,n,o,a){this.currentEllipse={cx:t,cy:n,rx:o,ry:a},this.pathPts=0,this.currentPath=null}buildEllipseStrokePolyline(t){let n=Math.hypot(this.transform.a,this.transform.b),o=Math.max(t.rx,t.ry)*(Number.isFinite(n)&&n>0?n:1),a=Math.max(24,Math.min(512,Math.ceil(Math.PI*o*.7)));this.pathPts=0;for(let r=0;r<=a;r++){let s=r/a*Math.PI*2;this.pushPathPoint(t.cx+t.rx*Math.cos(s),t.cy+t.ry*Math.sin(s))}}quadraticCurveTo(t,n,o,a){let r=this.lastPathPoint()??{x:t,y:n};this.currentCurves.push({kind:"q",points:[r,{x:t,y:n},{x:o,y:a}]});let s=this.currentFlattenTolerance(),i=xy();if(i){let c=i.flatten([{kind:"M",to:r},{kind:"Q",control:{x:t,y:n},to:{x:o,y:a}}],s);for(let u=1;u<c.length;u++){let d=v(c[u]);this.pushPathPoint(d.x,d.y)}return}let l=Math.max(8,Math.min(128,Math.ceil(OD(r.x,r.y,o,a)/s)));for(let c=1;c<=l;c++){let u=c/l,d=1-u;this.pushPathPoint(d*d*r.x+2*d*u*t+u*u*o,d*d*r.y+2*d*u*n+u*u*a)}}bezierCurveTo(t,n,o,a,r,s){let i=this.lastPathPoint()??{x:r,y:s};this.currentCurves.push({kind:"c",points:[i,{x:t,y:n},{x:o,y:a},{x:r,y:s}]});let l=this.currentFlattenTolerance(),c=xy();if(c){let d=c.flatten([{kind:"M",to:i},{kind:"C",control1:{x:t,y:n},control2:{x:o,y:a},to:{x:r,y:s}}],l);for(let f=1;f<d.length;f++){let p=v(d[f]);this.pushPathPoint(p.x,p.y)}return}let u=Math.max(12,Math.min(192,Math.ceil(OD(i.x,i.y,r,s)/l)));for(let d=1;d<=u;d++){let f=d/u,p=1-f,h=p*p,m=h*p,x=f*f,y=x*f;this.pushPathPoint(m*i.x+3*h*f*t+3*p*x*o+y*r,m*i.y+3*h*f*n+3*p*x*a+y*s)}}lastPathPoint(){if(this.pathPts!==0)return{x:v(this.pathXY[(this.pathPts-1)*2]),y:v(this.pathXY[(this.pathPts-1)*2+1])}}currentFlattenTolerance(){let t=Math.hypot(this.transform.a,this.transform.b);return!Number.isFinite(t)||t<=0?RD:RD/t}drawImage(t,n,o,a,r,s,i){this.flushRectBatch();let l=this.textureFor(t,s??!1);if(!l)return;this.imageProgram||(this.imageProgram=_X(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,1,1,1,1]),this.gl.STATIC_DRAW));let c=this.imageProgram;this.gl.useProgram(c.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.enableVertexAttribArray(c.aPos),this.gl.vertexAttribPointer(c.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(c.aUV),this.gl.vertexAttribPointer(c.aUV,2,this.gl.FLOAT,!1,16,8);let u=CX({a:this.transform.a*a,b:this.transform.b*a,c:this.transform.c*r,d:this.transform.d*r,e:this.transform.e+this.transform.a*n+this.transform.c*o,f:this.transform.f+this.transform.b*n+this.transform.d*o},this._size.width,this._size.height);this.gl.uniformMatrix3fv(c.uTransform,!1,u),this.gl.uniform1f(c.uOpacity,this.opacity),i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)?(this.gl.uniform2f(c.uUvOffset,i.x,i.y),this.gl.uniform2f(c.uUvScale,i.width,i.height)):(this.gl.uniform2f(c.uUvOffset,0,0),this.gl.uniform2f(c.uUvScale,1,1)),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,l),this.gl.uniform1i(c.uTex,0),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.restoreSolidProgram()}imageProgram=null;imageQuadVbo=null;textures=new Map;textureFor(t,n){if(!Sg(t))return Lg(t),null;let o=t,a=this.textures.get(o);if(a)return this.textures.delete(o),this.textures.set(o,a),n&&(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)),a;let r=this.gl.createTexture();return r?(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.textures.set(o,r),this.evictImageTexturesIfOverCap(),r):null}evictImageTexturesIfOverCap(){for(;this.textures.size>64;){let t=this.textures.keys().next().value;if(t===void 0)break;if(AX(this.textBitmaps,t)){let o=this.textures.get(t);if(o===void 0)continue;this.textures.delete(t),this.textures.set(t,o);continue}let n=this.textures.get(t);this.textures.delete(t),n&&this.gl.deleteTexture(n)}}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.flushRectBatch(),this.ellipsePipeline??=new Ig(this.gl);let o=this.currentEllipse;this.ellipsePipeline.draw(o.cx,o.cy,o.rx,o.ry,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram();return}if(this.currentPath){let o=this.currentPath,a=this.transform,r=2/this._size.width,s=-2/this._size.height,i=a.a*o.width,l=a.b*o.width,c=a.c*o.height,u=a.d*o.height,d=a.e+a.a*o.x+a.c*o.y,f=a.f+a.b*o.x+a.d*o.y;this.rectBatch.add(i*r,l*s,c*r,u*s,d*r-1,f*s+1,this.fillColor[0],this.fillColor[1],this.fillColor[2],n);return}this.pathPts>=3&&(this.flushRectBatch(),this.fillPolygonEarcut(this.pathXY,this.pathPts,n)),this.currentCurves.length>0&&(this.flushRectBatch(),this.curvePipeline??=new Tg(this.gl),this.curvePipeline.draw(this.currentCurves,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram())}}curvePipeline=null;ellipsePipeline=null;fillPolygonEarcut(t,n,o){let a=n>=4&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1]?n-1:n;if(a<3)return;let r=cL(t.subarray(0,a*2));if(r.length===0){this.drawTriangleFan(t,a,o);return}MD(a);let s=2/this._size.width,i=-2/this._size.height,l=gh;for(let u=0;u<a;u++){let d=v(t[u*2]),f=v(t[u*2+1]),p=this.transform.a*d+this.transform.c*f+this.transform.e,h=this.transform.b*d+this.transform.d*f+this.transform.f;l[u*2]=p*s-1,l[u*2+1]=h*i+1}kX(r.length);for(let u=0;u<r.length;u++)xh[u]=v(r[u]);let c=this.gl;c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,this.dynamicVbo),c.bufferData(c.ARRAY_BUFFER,l.subarray(0,a*2),c.DYNAMIC_DRAW),c.enableVertexAttribArray(this.aPosLoc),c.vertexAttribPointer(this.aPosLoc,2,c.FLOAT,!1,0,0),c.uniformMatrix3fv(this.uTransformLoc,!1,fL),c.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),c.uniform1f(this.uOpacityLoc,o),this.indexBuffer??=c.createBuffer(),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,xh.subarray(0,r.length),c.DYNAMIC_DRAW),c.drawElements(c.TRIANGLES,r.length,c.UNSIGNED_SHORT,0),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;MD(n);let s=gh;for(let l=0;l<n;l++){let c=v(t[l*2]),u=v(t[l*2+1]),d=this.transform.a*c+this.transform.c*u+this.transform.e,f=this.transform.b*c+this.transform.d*u+this.transform.f;s[l*2]=d*a-1,s[l*2+1]=f*r+1}let i=this.gl;i.useProgram(this.program),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.aPosLoc),i.vertexAttribPointer(this.aPosLoc,2,i.FLOAT,!1,0,0),i.uniformMatrix3fv(this.uTransformLoc,!1,fL),i.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),i.uniform1f(this.uOpacityLoc,o),i.drawArrays(i.TRIANGLE_FAN,0,n),this.restoreSolidProgram()}clear(t){this.flushRectBatch();let n=this.gl.canvas.width,o=this.gl.canvas.height;if(t){if(t.width<=0||t.height<=0)return;let a=this._size.width>0?n/this._size.width:1,r=this._size.height>0?o/this._size.height:1,s=Math.floor(t.x*a),i=Math.ceil(t.width*a),l=Math.ceil(t.height*r),c=Math.floor(o-(t.y+t.height)*r);this.gl.viewport(0,0,n,o),this.gl.enable(this.gl.SCISSOR_TEST),this.gl.scissor(s,c,i,l),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.disable(this.gl.SCISSOR_TEST);return}this.gl.viewport(0,0,n,o),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}setStroke(t){let n=uL(t);this.strokeColor=[n[0],n[1],n[2]],this.strokeAlpha=n[3]}setStrokeWidth(t){this.strokeWidth=Math.max(0,t)}stroke(){if(this.flushRectBatch(),this.currentPath){let o=this.currentPath;this.pathPts=0,this.pushPathPoint(o.x,o.y),this.pushPathPoint(o.x+o.width,o.y),this.pushPathPoint(o.x+o.width,o.y+o.height),this.pushPathPoint(o.x,o.y+o.height),this.pushPathPoint(o.x,o.y)}if(this.currentEllipse&&this.pathPts<2&&this.buildEllipseStrokePolyline(this.currentEllipse),this.pathPts<2)return;let t=this.opacity*this.strokeAlpha;if(t<=0)return;let n={width:this.strokeWidth,color:this.strokeColor,opacity:t,join:this.lineJoin,cap:this.lineCap};if(this.dashArray){let o=new Array(this.pathPts);for(let a=0;a<this.pathPts;a++)o[a]={x:v(this.pathXY[a*2]),y:v(this.pathXY[a*2+1])};for(let a of vX(o,this.dashArray))if(!(a.length<2)){SX(a.length*2);for(let r=0;r<a.length;r++){let s=v(a[r]);iu[r*2]=s.x,iu[r*2+1]=s.y}this.strokePolylineFlat(iu,a.length,n)}}else this.strokePolylineFlat(this.pathXY,this.pathPts,n);this.restoreSolidProgram()}strokePolylineFlat(t,n,o){_D(this.gl,t,n,o,this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.aPosLoc,fL)}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t&&t.length>0?t:null}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}fillText(t,n,o,a){if(t.length===0)return;this.flushRectBatch();let r=this.ensureGlyphAtlas();if(r){this.fillTextMSDF(t,n,o,r);return}let s=this.rasteriseString(t);if(!s)return;let i=this.textMetrics(t),l=n;this.textAlign==="center"?l-=i.width/2:this.textAlign==="right"&&(l-=i.width);let c=o;this.textBaseline==="middle"?c-=this.fontSize/2:this.textBaseline==="bottom"&&(c-=this.fontSize),this.drawImage(s,l,c,i.width,this.fontSize*1.4)}msdfPipeline=null;glyphAtlas=null;glyphAtlasShaper=null;ensureGlyphAtlas(){let t=Iv();return!t||!wX(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new ch(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new Cg(this.gl);let r=a.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic"),s=this.textAlign==="center"?.5:this.textAlign==="right"?1:0,i=o+this.baselineOffsetForBaseline();this.msdfPipeline.drawText(t,n,i,this.fontSize,a,{opacity:this.opacity,color:this.fillColor,transform:this.transform},this._size,s,r),this.restoreSolidProgram()}restoreSolidProgram(){this.gl.useProgram(this.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0)}flushRectBatch(){if(this.rectBatch.pending===0)return;this.rectPipeline??=new Rg(this.gl);let t=this.rectPipeline;this.rectBatch.flush((n,o)=>{t.draw(n,o)}),this.restoreSolidProgram()}flushBatch(){this.flushRectBatch()}measureText(t){return this.textMetrics(t)}textCtx=null;textBitmaps=new Map;ensureTextCtx(){if(this.textCtx)return this.textCtx;if(typeof OffscreenCanvas>"u")return null;let n=new OffscreenCanvas(1,1).getContext("2d");return n?(this.textCtx=n,this.textCtx):null}textFontSpec(){let t=this.fontStyle==="italic"?"italic ":"",n=this.fontWeight==="bold"?"bold ":"";return`${t}${n}${this.fontSize}px "${ru(this.fontFamily)}", ${this.fontFamily}`}baselineOffsetCache=new Map;baselineOffsetForBaseline(){let t=this.ensureTextCtx();if(!t)return this.fontSize*.8;let n=this.textFontSpec(),o=`${n}|${this.textBaseline}`,a=this.baselineOffsetCache.get(o);if(a!==void 0)return a;t.font=n,t.textBaseline="alphabetic";let r=t.measureText("Mg").fontBoundingBoxDescent;t.textBaseline=this.textBaseline;let s=t.measureText("Mg").fontBoundingBoxDescent,i=Number.isFinite(r)&&Number.isFinite(s)?s-r:this.fontSize*.8;return this.baselineOffsetCache.set(o,i),i}textMetrics(t){let n=this.ensureGlyphAtlas();if(n){let a=n.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic");return{width:SD(t,n,a)*this.fontSize}}let o=this.ensureTextCtx();return o?(o.font=this.textFontSpec(),{width:o.measureText(t).width}):{width:t.length*this.fontSize*.55}}rasteriseString(t){if(typeof OffscreenCanvas>"u")return null;let n=`${t}|${this.textFontSpec()}|${this.fillColorString}`,o=this.textBitmaps.get(n);if(o)return this.textBitmaps.delete(n),this.textBitmaps.set(n,o),o;let a=this.textMetrics(t),r=Math.max(1,Math.ceil(a.width)),s=Math.max(1,Math.ceil(this.fontSize*1.4)),i=new OffscreenCanvas(r,s),l=i.getContext("2d");return l?(l.font=this.textFontSpec(),l.textAlign="left",l.textBaseline="top",l.fillStyle=this.fillColorString,l.fillText(t,0,0),this.textBitmaps.set(n,i),this.evictTextBitmapsIfOverCap(),i):null}evictTextBitmapsIfOverCap(){for(;this.textBitmaps.size>256;){let t=this.textBitmaps.keys().next().value;if(t===void 0)break;let n=this.textBitmaps.get(t);if(this.textBitmaps.delete(t),n){let o=this.textures.get(n);o&&(this.gl.deleteTexture(o),this.textures.delete(n))}}}},AX=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},vX=(e,t)=>{let n=[],o=0,a=t[0]??0,r=!0,s=[];if(a<=0)return[e.slice()];for(let i=0;i<e.length-1;i++){let l=v(e[i]),c=v(e[i+1]),u=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-9)continue;let d=(c.x-l.x)/u,f=(c.y-l.y)/u,p={x:l.x,y:l.y},h=u;for(r&&s.length===0&&s.push(p);h>1e-9;){let m=Math.min(h,a),x={x:p.x+d*m,y:p.y+f*m};r&&s.push(x),p=x,h-=m,a-=m,a<=1e-9&&(r&&s.length>=2&&n.push(s),r=!r,o=(o+1)%t.length,a=t[o]??0,s=r?[{x:p.x,y:p.y}]:[],a<=0&&(a=1e-6))}}return r&&s.length>=2&&n.push(s),n},gh=new Float32Array(128),xh=new Uint16Array(256),MD=e=>{let t=e*2;if(gh.length>=t)return;let n=gh.length;for(;n<t;)n*=2;gh=new Float32Array(n)},iu=new Float64Array(128),SX=e=>{if(iu.length>=e)return;let t=iu.length;for(;t<e;)t*=2;iu=new Float64Array(t)},LX=128,kX=e=>{if(xh.length>=e)return;let t=xh.length;for(;t<e;)t*=2;xh=new Uint16Array(t)},fL=new Float32Array([1,0,0,0,1,0,0,0,1]),RD=.5,wX=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},OD=(e,t,n,o)=>Math.hypot(e-n,t-o),_X=e=>{let t=Nt(e,e.VERTEX_SHADER,`#version 300 es
126
+ }`;var qg=class{gl;program;vbo;dynamicVbo;dynamicVao;uTransformLoc;uColorLoc;uOpacityLoc;aPosLoc;_size;fillColor=[0,0,0];fillAlpha=1;strokeColor=[0,0,0];strokeAlpha=1;fillColorString="#000";strokeWidth=1;lineCap="butt";lineJoin="miter";dashArray=null;opacity=1;currentPath=null;fontFamily="sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";pathXY=new Float64Array(uY*2);pathPts=0;pushPathPoint(t,n){if((this.pathPts+1)*2>this.pathXY.length){let o=new Float64Array(this.pathXY.length*2);o.set(this.pathXY),this.pathXY=o}this.pathXY[this.pathPts*2]=t,this.pathXY[this.pathPts*2+1]=n,this.pathPts++}currentCurves=[];currentEllipse=null;transform={a:1,b:0,c:0,d:1,e:0,f:0};stack=[];rectBatch=new Wg;rectPipeline=null;constructor(t,n,o,a={}){let r=a.preserveDrawingBuffer??!0,s=t.getContext("webgl2",{antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:r});if(s??=t.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:r}),!s)throw new Error("WebGL2 unavailable in this environment (probably hit the per-page GL context cap; Chrome allows ~16). LayeredSurface will fall back to canvas2d.");this.gl=s,this._size={width:n,height:o};let i=zt(this.gl,this.gl.VERTEX_SHADER,mY,"WebGL2"),l=zt(this.gl,this.gl.FRAGMENT_SHADER,yY,"WebGL2");this.program=Do(this.gl,i,l,"WebGL2"),this.gl.useProgram(this.program),this.vbo=ot(this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),this.gl.STATIC_DRAW),this.dynamicVbo=ot(this.gl.createBuffer()),this.aPosLoc=this.gl.getAttribLocation(this.program,"aPos"),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.dynamicVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.dynamicVao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.dynamicVbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.gl.bindVertexArray(null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.uTransformLoc=this.gl.getUniformLocation(this.program,"uTransform"),this.uColorLoc=this.gl.getUniformLocation(this.program,"uColor"),this.uOpacityLoc=this.gl.getUniformLocation(this.program,"uOpacity"),this.rectPipeline=new Eh(this.gl),this.curvePipeline=new _h(this.gl),this.ellipsePipeline=new wh(this.gl),this.msdfPipeline=new Sh(this.gl),this.ensureImageProgram(),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.viewport(0,0,t.width,t.height)}get size(){return this._size}resize(t,n){this.flushRectBatch(),this._size.width=t,this._size.height=n,this.gl.viewport(0,0,t,n)}dispose(){this.rectBatch.reset(),this.rectPipeline&&(this.rectPipeline.dispose(),this.rectPipeline=null),this.msdfPipeline&&(this.msdfPipeline.dispose(),this.msdfPipeline=null),this.glyphAtlas&&(this.glyphAtlas.dispose(this.gl),this.glyphAtlas=null,this.glyphAtlasShaper=null),this.indexBuffer&&(this.gl.deleteBuffer(this.indexBuffer),this.indexBuffer=null),this.curvePipeline&&(this.curvePipeline.dispose(),this.curvePipeline=null),this.ellipsePipeline&&(this.ellipsePipeline.dispose(),this.ellipsePipeline=null),this.gl.deleteVertexArray(this.dynamicVao),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVao&&(this.gl.deleteVertexArray(this.imageQuadVao),this.imageQuadVao=null),this.imageQuadVbo&&(this.gl.deleteBuffer(this.imageQuadVbo),this.imageQuadVbo=null);for(let n of this.textures.values())this.gl.deleteTexture(n);this.textures.clear(),this.gl.getExtension("WEBGL_lose_context")?.loseContext()}setFill(t){let n=CL(t);this.fillColor=[n[0],n[1],n[2]],this.fillAlpha=n[3],this.fillColorString=t??"transparent"}setOpacity(t){this.opacity=t}save(){this.stack.push({transform:{...this.transform},fillColor:[this.fillColor[0],this.fillColor[1],this.fillColor[2]],fillAlpha:this.fillAlpha,strokeColor:[this.strokeColor[0],this.strokeColor[1],this.strokeColor[2]],strokeAlpha:this.strokeAlpha,fillColorString:this.fillColorString,strokeWidth:this.strokeWidth,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,opacity:this.opacity,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline})}restore(){let t=this.stack.pop();t&&(this.transform=t.transform,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.strokeColor=t.strokeColor,this.strokeAlpha=t.strokeAlpha,this.fillColorString=t.fillColorString,this.strokeWidth=t.strokeWidth,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.opacity=t.opacity,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline)}setTransform(t){this.transform={a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}resetTransform(){this.transform={a:1,b:0,c:0,d:1,e:0,f:0}}translate(t,n){this.transform.e+=this.transform.a*t+this.transform.c*n,this.transform.f+=this.transform.b*t+this.transform.d*n}rotate(t){let n=Math.cos(t),o=Math.sin(t),{a,b:r,c:s,d:i}=this.transform;this.transform.a=a*n+s*o,this.transform.b=r*n+i*o,this.transform.c=a*-o+s*n,this.transform.d=r*-o+i*n}scale(t,n){this.transform.a*=t,this.transform.b*=t,this.transform.c*=n,this.transform.d*=n}beginPath(){this.currentPath=null,this.pathPts=0,this.currentCurves=[],this.currentEllipse=null}rect(t,n,o,a){this._pathRect.x=t,this._pathRect.y=n,this._pathRect.width=o,this._pathRect.height=a,this.currentPath=this._pathRect}_pathRect={x:0,y:0,width:0,height:0};moveTo(t,n){this.pathPts=0,this.pushPathPoint(t,n)}lineTo(t,n){this.pushPathPoint(t,n)}closePath(){this.pathPts>1&&this.pushPathPoint(v(this.pathXY[0]),v(this.pathXY[1]))}ellipse(t,n,o,a){this.currentEllipse={cx:t,cy:n,rx:o,ry:a},this.pathPts=0,this.currentPath=null}buildEllipseStrokePolyline(t){let n=Math.hypot(this.transform.a,this.transform.b),o=Math.max(t.rx,t.ry)*(Number.isFinite(n)&&n>0?n:1),a=Math.max(24,Math.min(512,Math.ceil(Math.PI*o*.7)));this.pathPts=0;for(let r=0;r<=a;r++){let s=r/a*Math.PI*2;this.pushPathPoint(t.cx+t.rx*Math.cos(s),t.cy+t.ry*Math.sin(s))}}quadraticCurveTo(t,n,o,a){let r=this.lastPathPoint()??{x:t,y:n};this.currentCurves.push({kind:"q",points:[r,{x:t,y:n},{x:o,y:a}]});let s=this.currentFlattenTolerance(),i=Oy();if(i){let c=i.flatten([{kind:"M",to:r},{kind:"Q",control:{x:t,y:n},to:{x:o,y:a}}],s);for(let u=1;u<c.length;u++){let d=v(c[u]);this.pushPathPoint(d.x,d.y)}return}let l=Math.max(8,Math.min(128,Math.ceil(f6(r.x,r.y,o,a)/s)));for(let c=1;c<=l;c++){let u=c/l,d=1-u;this.pushPathPoint(d*d*r.x+2*d*u*t+u*u*o,d*d*r.y+2*d*u*n+u*u*a)}}bezierCurveTo(t,n,o,a,r,s){let i=this.lastPathPoint()??{x:r,y:s};this.currentCurves.push({kind:"c",points:[i,{x:t,y:n},{x:o,y:a},{x:r,y:s}]});let l=this.currentFlattenTolerance(),c=Oy();if(c){let d=c.flatten([{kind:"M",to:i},{kind:"C",control1:{x:t,y:n},control2:{x:o,y:a},to:{x:r,y:s}}],l);for(let f=1;f<d.length;f++){let p=v(d[f]);this.pushPathPoint(p.x,p.y)}return}let u=Math.max(12,Math.min(192,Math.ceil(f6(i.x,i.y,r,s)/l)));for(let d=1;d<=u;d++){let f=d/u,p=1-f,h=p*p,m=h*p,x=f*f,y=x*f;this.pushPathPoint(m*i.x+3*h*f*t+3*p*x*o+y*r,m*i.y+3*h*f*n+3*p*x*a+y*s)}}lastPathPoint(){if(this.pathPts!==0)return{x:v(this.pathXY[(this.pathPts-1)*2]),y:v(this.pathXY[(this.pathPts-1)*2+1])}}currentFlattenTolerance(){let t=Math.hypot(this.transform.a,this.transform.b);return!Number.isFinite(t)||t<=0?d6:d6/t}drawImage(t,n,o,a,r,s,i){this.flushRectBatch();let l=this.textureFor(t,s??!1);if(!l)return;let c=this.ensureImageProgram();this.gl.useProgram(c.program),this.gl.bindVertexArray(this.imageQuadVao);let u=hY({a:this.transform.a*a,b:this.transform.b*a,c:this.transform.c*r,d:this.transform.d*r,e:this.transform.e+this.transform.a*n+this.transform.c*o,f:this.transform.f+this.transform.b*n+this.transform.d*o},this._size.width,this._size.height);this.gl.uniformMatrix3fv(c.uTransform,!1,u),this.gl.uniform1f(c.uOpacity,this.opacity),i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)?(this.gl.uniform2f(c.uUvOffset,i.x,i.y),this.gl.uniform2f(c.uUvScale,i.width,i.height)):(this.gl.uniform2f(c.uUvOffset,0,0),this.gl.uniform2f(c.uUvScale,1,1)),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,l),this.gl.uniform1i(c.uTex,0),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(null),this.restoreSolidProgram()}imageProgram=null;ensureImageProgram(){return this.imageProgram?this.imageProgram:(this.imageProgram=pY(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.imageQuadVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.imageQuadVao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,1,1,1,1]),this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(this.imageProgram.aPos),this.gl.vertexAttribPointer(this.imageProgram.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(this.imageProgram.aUV),this.gl.vertexAttribPointer(this.imageProgram.aUV,2,this.gl.FLOAT,!1,16,8),this.gl.bindVertexArray(null),this.imageProgram)}imageQuadVbo=null;imageQuadVao=null;textures=new Map;textureFor(t,n){if(!uu(t))return zg(t),null;let o=t,a=this.textures.get(o);if(a)return this.textures.delete(o),this.textures.set(o,a),n&&(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)),a;let r=this.gl.createTexture();return r?(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.textures.set(o,r),this.evictImageTexturesIfOverCap(),r):null}evictImageTexturesIfOverCap(){for(;this.textures.size>64;){let t=this.textures.keys().next().value;if(t===void 0)break;if(c6(this.textBitmaps,t)){let o=this.textures.get(t);if(o===void 0)continue;this.textures.delete(t),this.textures.set(t,o);continue}let n=this.textures.get(t);this.textures.delete(t),n&&this.gl.deleteTexture(n)}}invalidateImage(t){let n=t,o=this.textures.get(n);return o===void 0||c6(this.textBitmaps,n)?!1:(this.textures.delete(n),this.gl.deleteTexture(o),!0)}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.flushRectBatch(),this.ellipsePipeline??=new wh(this.gl);let o=this.currentEllipse;this.ellipsePipeline.draw(o.cx,o.cy,o.rx,o.ry,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram();return}if(this.currentPath){let o=this.currentPath,a=this.transform,r=2/this._size.width,s=-2/this._size.height,i=a.a*o.width,l=a.b*o.width,c=a.c*o.height,u=a.d*o.height,d=a.e+a.a*o.x+a.c*o.y,f=a.f+a.b*o.x+a.d*o.y;this.rectBatch.add(i*r,l*s,c*r,u*s,d*r-1,f*s+1,this.fillColor[0],this.fillColor[1],this.fillColor[2],n);return}this.pathPts>=3&&(this.flushRectBatch(),this.fillPolygonEarcut(this.pathXY,this.pathPts,n)),this.currentCurves.length>0&&(this.flushRectBatch(),this.curvePipeline??=new _h(this.gl),this.curvePipeline.draw(this.currentCurves,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram())}}curvePipeline=null;ellipsePipeline=null;fillPolygonEarcut(t,n,o){let a=n>=4&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1]?n-1:n;if(a<3)return;let r=EL(t.subarray(0,a*2));if(r.length===0){this.drawTriangleFan(t,a,o);return}u6(a);let s=2/this._size.width,i=-2/this._size.height,l=Ch;for(let u=0;u<a;u++){let d=v(t[u*2]),f=v(t[u*2+1]),p=this.transform.a*d+this.transform.c*f+this.transform.e,h=this.transform.b*d+this.transform.d*f+this.transform.f;l[u*2]=p*s-1,l[u*2+1]=h*i+1}dY(r.length);for(let u=0;u<r.length;u++)Ih[u]=v(r[u]);let c=this.gl;c.useProgram(this.program),c.bindVertexArray(this.dynamicVao),c.bindBuffer(c.ARRAY_BUFFER,this.dynamicVbo),c.bufferData(c.ARRAY_BUFFER,l.subarray(0,a*2),c.DYNAMIC_DRAW),c.uniformMatrix3fv(this.uTransformLoc,!1,ML),c.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),c.uniform1f(this.uOpacityLoc,o),this.indexBuffer??=c.createBuffer(),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,Ih.subarray(0,r.length),c.DYNAMIC_DRAW),c.drawElements(c.TRIANGLES,r.length,c.UNSIGNED_SHORT,0),c.bindVertexArray(null),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;u6(n);let s=Ch;for(let l=0;l<n;l++){let c=v(t[l*2]),u=v(t[l*2+1]),d=this.transform.a*c+this.transform.c*u+this.transform.e,f=this.transform.b*c+this.transform.d*u+this.transform.f;s[l*2]=d*a-1,s[l*2+1]=f*r+1}let i=this.gl;i.useProgram(this.program),i.bindVertexArray(this.dynamicVao),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.uniformMatrix3fv(this.uTransformLoc,!1,ML),i.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),i.uniform1f(this.uOpacityLoc,o),i.drawArrays(i.TRIANGLE_FAN,0,n),i.bindVertexArray(null),this.restoreSolidProgram()}clear(t){this.flushRectBatch();let n=this.gl.canvas.width,o=this.gl.canvas.height;if(t){if(t.width<=0||t.height<=0)return;let a=this._size.width>0?n/this._size.width:1,r=this._size.height>0?o/this._size.height:1,s=Math.floor(t.x*a),i=Math.ceil(t.width*a),l=Math.ceil(t.height*r),c=Math.floor(o-(t.y+t.height)*r);this.gl.viewport(0,0,n,o),this.gl.enable(this.gl.SCISSOR_TEST),this.gl.scissor(s,c,i,l),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.disable(this.gl.SCISSOR_TEST);return}this.gl.viewport(0,0,n,o),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}setStroke(t){let n=CL(t);this.strokeColor=[n[0],n[1],n[2]],this.strokeAlpha=n[3]}setStrokeWidth(t){this.strokeWidth=Math.max(0,t)}stroke(){if(this.flushRectBatch(),this.currentPath){let o=this.currentPath;this.pathPts=0,this.pushPathPoint(o.x,o.y),this.pushPathPoint(o.x+o.width,o.y),this.pushPathPoint(o.x+o.width,o.y+o.height),this.pushPathPoint(o.x,o.y+o.height),this.pushPathPoint(o.x,o.y)}if(this.currentEllipse&&this.pathPts<2&&this.buildEllipseStrokePolyline(this.currentEllipse),this.pathPts<2)return;let t=this.opacity*this.strokeAlpha;if(t<=0)return;let n={width:this.strokeWidth,color:this.strokeColor,opacity:t,join:this.lineJoin,cap:this.lineCap};if(this.dashArray){let o=new Array(this.pathPts);for(let a=0;a<this.pathPts;a++)o[a]={x:v(this.pathXY[a*2]),y:v(this.pathXY[a*2+1])};for(let a of lY(o,this.dashArray))if(!(a.length<2)){cY(a.length*2);for(let r=0;r<a.length;r++){let s=v(a[r]);fu[r*2]=s.x,fu[r*2+1]=s.y}this.strokePolylineFlat(fu,a.length,n)}}else this.strokePolylineFlat(this.pathXY,this.pathPts,n);this.restoreSolidProgram()}strokePolylineFlat(t,n,o){a6(this.gl,t,n,o,this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.dynamicVao,ML)}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t&&t.length>0?t:null}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}fillText(t,n,o,a){if(t.length===0)return;this.flushRectBatch();let r=this.ensureGlyphAtlas();if(r){this.fillTextMSDF(t,n,o,r);return}let s=this.rasteriseString(t);if(!s)return;let i=this.textMetrics(t),l=n;this.textAlign==="center"?l-=i.width/2:this.textAlign==="right"&&(l-=i.width);let c=o;this.textBaseline==="middle"?c-=this.fontSize/2:this.textBaseline==="bottom"&&(c-=this.fontSize),this.drawImage(s,l,c,i.width,this.fontSize*1.4)}msdfPipeline=null;glyphAtlas=null;glyphAtlasShaper=null;ensureGlyphAtlas(){let t=Z2();return!t||!fY(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new gh(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new Sh(this.gl);let r=a.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic"),s=this.textAlign==="center"?.5:this.textAlign==="right"?1:0,i=o+this.baselineOffsetForBaseline();this.msdfPipeline.drawText(t,n,i,this.fontSize,a,{opacity:this.opacity,color:this.fillColor,transform:this.transform},this._size,s,r),this.restoreSolidProgram()}restoreSolidProgram(){this.gl.useProgram(this.program)}flushRectBatch(){if(this.rectBatch.pending===0)return;this.rectPipeline??=new Eh(this.gl);let t=this.rectPipeline;this.rectBatch.flush((n,o)=>{t.draw(n,o)}),this.restoreSolidProgram()}flushBatch(){this.flushRectBatch()}measureText(t){return this.textMetrics(t)}textCtx=null;textBitmaps=new Map;ensureTextCtx(){if(this.textCtx)return this.textCtx;if(typeof OffscreenCanvas>"u")return null;let n=new OffscreenCanvas(1,1).getContext("2d");return n?(this.textCtx=n,this.textCtx):null}textFontSpec(){let t=this.fontStyle==="italic"?"italic ":"",n=this.fontWeight==="bold"?"bold ":"";return`${t}${n}${this.fontSize}px "${cu(this.fontFamily)}", ${this.fontFamily}`}baselineOffsetCache=new Map;baselineOffsetForBaseline(){let t=this.ensureTextCtx();if(!t)return this.fontSize*.8;let n=this.textFontSpec(),o=`${n}|${this.textBaseline}`,a=this.baselineOffsetCache.get(o);if(a!==void 0)return a;t.font=n,t.textBaseline="alphabetic";let r=t.measureText("Mg").fontBoundingBoxDescent;t.textBaseline=this.textBaseline;let s=t.measureText("Mg").fontBoundingBoxDescent,i=Number.isFinite(r)&&Number.isFinite(s)?s-r:this.fontSize*.8;return this.baselineOffsetCache.set(o,i),i}textMetrics(t){let n=this.ensureGlyphAtlas();if(n){let a=n.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic");return{width:e6(t,n,a)*this.fontSize}}let o=this.ensureTextCtx();return o?(o.font=this.textFontSpec(),{width:o.measureText(t).width}):{width:t.length*this.fontSize*.55}}rasteriseString(t){if(typeof OffscreenCanvas>"u")return null;let n=`${t}|${this.textFontSpec()}|${this.fillColorString}`,o=this.textBitmaps.get(n);if(o)return this.textBitmaps.delete(n),this.textBitmaps.set(n,o),o;let a=this.textMetrics(t),r=Math.max(1,Math.ceil(a.width)),s=Math.max(1,Math.ceil(this.fontSize*1.4)),i=new OffscreenCanvas(r,s),l=i.getContext("2d");return l?(l.font=this.textFontSpec(),l.textAlign="left",l.textBaseline="top",l.fillStyle=this.fillColorString,l.fillText(t,0,0),this.textBitmaps.set(n,i),this.evictTextBitmapsIfOverCap(),i):null}evictTextBitmapsIfOverCap(){for(;this.textBitmaps.size>256;){let t=this.textBitmaps.keys().next().value;if(t===void 0)break;let n=this.textBitmaps.get(t);if(this.textBitmaps.delete(t),n){let o=this.textures.get(n);o&&(this.gl.deleteTexture(o),this.textures.delete(n))}}}},c6=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},lY=(e,t)=>{let n=[],o=0,a=t[0]??0,r=!0,s=[];if(a<=0)return[e.slice()];for(let i=0;i<e.length-1;i++){let l=v(e[i]),c=v(e[i+1]),u=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-9)continue;let d=(c.x-l.x)/u,f=(c.y-l.y)/u,p={x:l.x,y:l.y},h=u;for(r&&s.length===0&&s.push(p);h>1e-9;){let m=Math.min(h,a),x={x:p.x+d*m,y:p.y+f*m};r&&s.push(x),p=x,h-=m,a-=m,a<=1e-9&&(r&&s.length>=2&&n.push(s),r=!r,o=(o+1)%t.length,a=t[o]??0,s=r?[{x:p.x,y:p.y}]:[],a<=0&&(a=1e-6))}}return r&&s.length>=2&&n.push(s),n},Ch=new Float32Array(128),Ih=new Uint16Array(256),u6=e=>{let t=e*2;if(Ch.length>=t)return;let n=Ch.length;for(;n<t;)n*=2;Ch=new Float32Array(n)},fu=new Float64Array(128),cY=e=>{if(fu.length>=e)return;let t=fu.length;for(;t<e;)t*=2;fu=new Float64Array(t)},uY=128,dY=e=>{if(Ih.length>=e)return;let t=Ih.length;for(;t<e;)t*=2;Ih=new Uint16Array(t)},ML=new Float32Array([1,0,0,0,1,0,0,0,1]),d6=.5,fY=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},f6=(e,t,n,o)=>Math.hypot(e-n,t-o),pY=e=>{let t=zt(e,e.VERTEX_SHADER,`#version 300 es
125
127
  in vec2 aPos;
126
128
  in vec2 aUV;
127
129
  uniform mat3 uTransform;
@@ -134,7 +136,7 @@ void main() {
134
136
  // Crop: map the unit-quad UV into the source sub-rect. Identity is
135
137
  // offset (0,0) + scale (1,1); a crop narrows it to the kept region.
136
138
  vUV = aUV * uUvScale + uUvOffset;
137
- }`,"WebGL2"),n=Nt(e,e.FRAGMENT_SHADER,`#version 300 es
139
+ }`,"WebGL2"),n=zt(e,e.FRAGMENT_SHADER,`#version 300 es
138
140
  precision mediump float;
139
141
  in vec2 vUV;
140
142
  uniform sampler2D uTex;
@@ -147,13 +149,13 @@ void main() {
147
149
  // channels by the per-call opacity.
148
150
  vec4 t = texture(uTex, vUV);
149
151
  fragColor = vec4(t.rgb * uOpacity, t.a * uOpacity);
150
- }`,"WebGL2"),o=Mo(e,t,n,"WebGL2");return{program:o,aPos:e.getAttribLocation(o,"aPos"),aUV:e.getAttribLocation(o,"aUV"),uTransform:e.getUniformLocation(o,"uTransform"),uTex:e.getUniformLocation(o,"uTex"),uOpacity:e.getUniformLocation(o,"uOpacity"),uUvOffset:e.getUniformLocation(o,"uUvOffset"),uUvScale:e.getUniformLocation(o,"uUvScale")}},ua=new Float32Array(9),CX=(e,t,n)=>{let o=2/t,a=-2/n;return ua[0]=e.a*o,ua[1]=e.b*a,ua[2]=0,ua[3]=e.c*o,ua[4]=e.d*a,ua[5]=0,ua[6]=e.e*o-1,ua[7]=e.f*a+1,ua[8]=1,ua},EX=`#version 300 es
152
+ }`,"WebGL2"),o=Do(e,t,n,"WebGL2");return{program:o,aPos:e.getAttribLocation(o,"aPos"),aUV:e.getAttribLocation(o,"aUV"),uTransform:e.getUniformLocation(o,"uTransform"),uTex:e.getUniformLocation(o,"uTex"),uOpacity:e.getUniformLocation(o,"uOpacity"),uUvOffset:e.getUniformLocation(o,"uUvOffset"),uUvScale:e.getUniformLocation(o,"uUvScale")}},fa=new Float32Array(9),hY=(e,t,n)=>{let o=2/t,a=-2/n;return fa[0]=e.a*o,fa[1]=e.b*a,fa[2]=0,fa[3]=e.c*o,fa[4]=e.d*a,fa[5]=0,fa[6]=e.e*o-1,fa[7]=e.f*a+1,fa[8]=1,fa},mY=`#version 300 es
151
153
  in vec2 aPos;
152
154
  uniform mat3 uTransform;
153
155
  void main() {
154
156
  vec3 p = uTransform * vec3(aPos, 1.0);
155
157
  gl_Position = vec4(p.xy, 0.0, 1.0);
156
- }`,TX=`#version 300 es
158
+ }`,yY=`#version 300 es
157
159
  precision mediump float;
158
160
  uniform vec3 uColor;
159
161
  uniform float uOpacity;
@@ -162,9 +164,10 @@ void main() {
162
164
  // Output premultiplied (rgb*a, a) \u2014 matches the context's
163
165
  // premultipliedAlpha:true contract + blendFunc(ONE, 1-SRC_ALPHA).
164
166
  fragColor = vec4(uColor * uOpacity, uOpacity);
165
- }`;var Dg=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",pL=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new or(o,e,t);return{canvas:n,target:a}};var ar=(e,t,n,o=rr(),a=!0)=>{let r=Math.round(t*o),s=Math.round(n*o),i=`${t}px`,l=`${n}px`;if(e.width===r&&e.height===s&&e.style.width===i&&e.style.height===l)return o;if(e.width=r,e.height=s,e.style.width=i,e.style.height=l,a){let c=e.getContext("2d");if(!c)throw new Error("Failed to obtain 2D context");c.setTransform(o,0,0,o,0,0)}return o},rr=(e=2)=>Math.min(typeof window<"u"&&window.devicePixelRatio||1,e);var bh=class{host;layers;canvases;width;height;dprOverride;maxDpr;constructor(t,n,o,a={}){this.host=t,this.width=n,this.height=o,this.dprOverride=a.dpr,this.maxDpr=a.maxDpr??2,getComputedStyle(t).position==="static"&&(t.style.position="relative");let r=a.layers??wi,s=new Map,i=new Map;for(let l of wi){if(!r.includes(l))continue;let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",t.appendChild(c);let u=ar(c,n,o,this.dprOverride??rr(this.maxDpr)),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new or(d,n,o,u)),i.set(l,c)}this.layers=s,this.canvases=i}get(t){let n=this.layers.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this.width===t&&this.height===n)){this.width=t,this.height=n;for(let[o,a]of this.canvases){let r=ar(a,t,n,this.dprOverride??rr(this.maxDpr)),s=this.layers.get(o);s!==void 0&&s.resize(t,n,r)}}}get size(){return{width:this.width,height:this.height}}dispose(){for(let t of this.canvases.values())t.remove()}};var mL=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var DD=-2128831035,PD=522970236,IX=16777619,MX=2246822507,BD=-1640531527,RX=2147483647,OX=1431655765,zD=new Float64Array(1),ND=new Int32Array(zD.buffer),Pg=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new vp(64);nextImageId=0;sigA=DD;sigB=PD;cmdCount=0;_lastSignature="";constructor(t,n){this._width=t,this._height=n}get size(){return{width:this._width,height:this._height}}resize(t,n){this._width=t,this._height=n,this.emit({k:"resize",w:t,h:n})}emit(t){this.commands.push(t),this.cmdCount++,this.mixString(t.k);for(let n in t)n!=="k"&&this.mixValue(t[n])}mix32(t){let n=t|0;this.sigA=(Math.imul(this.sigA^n,IX)|0)^BD,this.sigB=Math.imul(this.sigB^n+BD,MX)|0}mixNumber(t){zD[0]=t,this.mix32(ND[0]??0),this.mix32(ND[1]??0)}mixString(t){for(let n=0;n<t.length;n++)this.mix32(t.charCodeAt(n));this.mix32(t.length^65536)}mixValue(t){if(t==null){this.mix32(RX);return}switch(typeof t){case"number":this.mixNumber(t);return;case"boolean":this.mix32(t?1:2);return;case"string":this.mixString(t);return;case"object":{if(Array.isArray(t)){for(let n of t)this.mixValue(n);this.mix32(t.length^OX);return}if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap)return;for(let n in t)this.mixValue(t[n]);return}default:return}}get lastSignature(){return this._lastSignature}flush(){let t=this.commands;return this._lastSignature=`${this.cmdCount}:${(this.sigA>>>0).toString(36)}:${(this.sigB>>>0).toString(36)}`,this.commands=[],this.sigA=DD,this.sigB=PD,this.cmdCount=0,t}peek(){return this.commands}setFill(t){this.emit({k:"setFill",color:t})}setStroke(t){this.emit({k:"setStroke",color:t})}setStrokeWidth(t){this.emit({k:"setStrokeWidth",w:t})}setOpacity(t){this.emit({k:"setOpacity",a:t})}setLineCap(t){this.emit({k:"setLineCap",cap:t})}setLineJoin(t){this.emit({k:"setLineJoin",join:t})}setDashArray(t){this.emit({k:"setDashArray",dash:t})}setFont(t,n,o){this.emit({k:"setFont",family:t,size:n,...o?{options:o}:{}});let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.fontSpec=`${a}${r}${n}px "${ru(t)}", ${t}`}setTextAlign(t){this.emit({k:"setTextAlign",align:t})}setTextBaseline(t){this.emit({k:"setTextBaseline",baseline:t})}save(){this.emit({k:"save"})}restore(){this.emit({k:"restore"})}translate(t,n){this.emit({k:"translate",x:t,y:n})}rotate(t){this.emit({k:"rotate",r:t})}scale(t,n){this.emit({k:"scale",sx:t,sy:n})}setTransform(t){this.emit({k:"setTransform",t})}resetTransform(){this.emit({k:"resetTransform"})}beginPath(){this.emit({k:"beginPath"})}closePath(){this.emit({k:"closePath"})}moveTo(t,n){this.emit({k:"moveTo",x:t,y:n})}lineTo(t,n){this.emit({k:"lineTo",x:t,y:n})}quadraticCurveTo(t,n,o,a){this.emit({k:"quadraticCurveTo",cx:t,cy:n,x:o,y:a})}bezierCurveTo(t,n,o,a,r,s){this.emit({k:"bezierCurveTo",c1x:t,c1y:n,c2x:o,c2y:a,x:r,y:s})}rect(t,n,o,a){this.emit({k:"rect",x:t,y:n,w:o,h:a})}ellipse(t,n,o,a){this.emit({k:"ellipse",cx:t,cy:n,rx:o,ry:a})}fill(t){this.emit(t!==void 0?{k:"fill",rule:t}:{k:"fill"})}stroke(){this.emit({k:"stroke"})}fillText(t,n,o,a){this.emit(a!==void 0?{k:"fillText",text:t,x:n,y:o,maxWidth:a}:{k:"fillText",text:t,x:n,y:o})}measureText(t){let n=this.ensureMeasureCtx();return n?(n.font=this.fontSpec,{width:n.measureText(t).width}):{width:t.length*(Number.parseFloat(this.fontSpec)||8)*.5}}ensureMeasureCtx(){if(this.measureCtx)return this.measureCtx;if(typeof OffscreenCanvas>"u")return null;let t=new OffscreenCanvas(1,1).getContext("2d");return this.measureCtx=t??null,this.measureCtx}drawImage(t,n,o,a,r,s){if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let i=this.imageIds.get(t);i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i),this.emit({k:"defineImage",id:i,bitmap:t})),this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r})}else this.skippedImageDraws++}clear(t){this.emit(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.emit({k:"markDirty",bounds:t})}};var yL=(e,t,n,o={})=>{let a=o.backend??"canvas2d",r=o.maxDpr??2;switch(a){case"canvas2d":return new gL(e,t,n,r);case"webgl2":return new xL(e,t,n,r,{...o.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:o.preserveDrawingBuffer}:{}});case"offscreen":if(!o.workerFactory)throw new Error("createLayeredSurface: workerFactory is required for the offscreen backend");return new bL(e,t,n,o.workerFactory,o.onWorkerError,r)}},AL=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:yL(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:yL(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},gL=class{backend="canvas2d";inner;constructor(t,n,o,a){this.inner=new bh(t,n,o,{maxDpr:a})}get(t){return this.inner.get(t)}getCanvas(t){return this.inner.getCanvas(t)}resize(t,n){this.inner.resize(t,n)}get size(){return this.inner.size}present(){}dispose(){this.inner.dispose()}},xL=class{backend="webgl2";base;mainCanvas;mainTarget;_width;_height;maxDpr;constructor(t,n,o,a,r={}){this._width=n,this._height=o,this.maxDpr=a,this.base=new bh(t,n,o,{layers:wi.filter(l=>l!=="main"),maxDpr:a});let s=this.base.getCanvas("overlay"),i=t.ownerDocument.createElement("canvas");i.dataset.layer="main",i.dataset.backend="webgl2",i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none",t.insertBefore(i,s),ar(i,n,o,rr(a),!1);try{this.mainCanvas=i,this.mainTarget=new Og(i,n,o,{...r.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:r.preserveDrawingBuffer}:{}})}catch(l){throw i.remove(),this.base.dispose(),l}}get(t){return t==="main"?this.mainTarget:this.base.get(t)}getCanvas(t){return t==="main"?this.mainCanvas:this.base.getCanvas(t)}resize(t,n){this._width===t&&this._height===n||(this._width=t,this._height=n,this.base.resize(t,n),ar(this.mainCanvas,t,n,rr(this.maxDpr),!1),this.mainTarget.resize(t,n))}get size(){return{width:this._width,height:this._height}}present(){this.mainTarget.flushBatch()}dispose(){this.mainTarget.dispose(),this.mainCanvas.remove(),this.base.dispose()}},bL=class{backend="offscreen";canvases=new Map;targets=new Map;workers=new Map;lastSentSig=new Map;_width;_height;dpr;constructor(t,n,o,a,r,s=2){this._width=n,this._height=o,this.dpr=rr(s),getComputedStyle(t).position==="static"&&(t.style.position="relative");let i=!1,l=c=>{i||(i=!0,r?.(c))};try{for(let c of wi){let u=t.ownerDocument.createElement("canvas");u.dataset.layer=c,u.dataset.backend="offscreen",u.style.position="absolute",u.style.inset="0",u.style.pointerEvents=c==="overlay"?"auto":"none",u.style.width=`${n}px`,u.style.height=`${o}px`,t.appendChild(u);let d=a();d.onerror=p=>{l(p)};let f=u.transferControlToOffscreen();d.postMessage({type:"init",canvas:f,width:n,height:o,dpr:this.dpr},[f]),this.canvases.set(c,u),this.workers.set(c,d),this.targets.set(c,new Pg(n,o))}}catch(c){throw this.dispose(),c}}get(t){let n=this.targets.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this._width===t&&this._height===n)){this._width=t,this._height=n;for(let[o,a]of this.canvases)a.style.width=`${t}px`,a.style.height=`${n}px`,this.targets.get(o)?.resize(t,n),this.workers.get(o)?.postMessage({type:"resize",width:t,height:n});this.lastSentSig.clear()}}get size(){return{width:this._width,height:this._height}}present(){for(let[t,n]of this.targets){let o=n.flush();if(o.length===0)continue;let a=n.lastSignature;this.lastSentSig.get(t)!==a&&(this.lastSentSig.set(t,a),this.workers.get(t)?.postMessage({type:"replay",commands:o}))}}dispose(){for(let t of this.workers.values())t.terminate();for(let t of this.canvases.values())t.remove();this.workers.clear(),this.canvases.clear(),this.targets.clear()}};var vL=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},SL=()=>{if(typeof document>"u")return!1;try{let t=document.createElement("canvas").getContext("webgl2");return t?(t.getExtension?.("WEBGL_lose_context")?.loseContext(),!0):!1}catch{return!1}};var FD=(0,Le.createContext)(null),LL=({initialScene:e,initialMode:t,children:n,onReady:o,skipInstallRenderers:a,renderer:r="canvas2d",workerFactory:s,textShaper:i,rasterizer:l,readOnly:c=!1})=>{let[u,d]=(0,Le.useState)(null),f=(0,Le.useRef)(null),p=(0,Le.useRef)(null),h=(0,Le.useRef)(null),m=(0,Le.useRef)(null),x=(0,Le.useRef)(null),y=(0,Le.useRef)(!1),g=(0,Le.useRef)(()=>{}),b=(0,Le.useRef)(r),A=(0,Le.useRef)(s),_=(0,Le.useRef)(i),T=(0,Le.useRef)(l),w=(0,Le.useRef)(c);b.current=r,A.current=s,_.current=i,T.current=l,w.current=c;let S=(0,Le.useCallback)(W=>{a||Dc();let{width:ie,height:ne}=W.getBoundingClientRect(),{surface:j,effectiveBackend:ve}=AL(W,ie,ne,{backend:y.current?"canvas2d":b.current,...A.current?{workerFactory:A.current}:{},onWorkerError:Oe=>{g.current(Oe)}},(Oe,qt)=>{console.warn(`[DiagramRoot] ${Oe} renderer unavailable, falling back to canvas2d:`,qt)});W.dataset.effectiveBackend=ve;let ye={host:W,mainTarget:j.get("main"),overlayTarget:j.get("overlay"),backgroundTarget:j.get("background"),onAfterRender:()=>p.current?.present(),initialScene:e,...t!==void 0?{initialMode:t}:{},..._.current?{textShaper:_.current}:{},...T.current?{rasterizer:T.current}:{}},ee=new Gp(ye);ee.setViewportSize(ie,ne),ee.setReadOnly(w.current),p.current=j,f.current=ee,d(ee),o?.(ee),j.present();let Se=new ResizeObserver(()=>{let Oe=W.getBoundingClientRect();j.resize(Oe.width,Oe.height),ee.setViewportSize(Oe.width,Oe.height),ee.forceRender()});Se.observe(W),h.current=Se},[]),L=(0,Le.useCallback)(()=>{h.current?.disconnect(),h.current=null,x.current?.(),x.current=null,f.current?.dispose(),f.current=null,p.current?.dispose(),p.current=null},[]);g.current=W=>{if(y.current)return;y.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",W);let ie=m.current;ie&&(L(),S(ie))};let M=(0,Le.useCallback)(W=>{if(L(),m.current=W,!W){d(null);return}S(W)},[S,L]),B=(0,Le.useRef)(null);return(0,Le.useEffect)(()=>{let W=m.current;if(W){if(B.current===null){B.current=r;return}B.current!==r&&(B.current=r,y.current=!1,L(),S(W))}},[r,S,L]),(0,Le.useEffect)(()=>{u?.setReadOnly(c)},[u,c]),(0,Le.useLayoutEffect)(()=>()=>{L(),m.current=null},[L]),(0,ys.jsx)(gE.Provider,{value:u,children:(0,ys.jsx)(FD.Provider,{value:M,children:(0,ys.jsxs)(Y8,{children:[n,(0,ys.jsx)(DX,{editor:u})]})})})},DX=({editor:e})=>{let[t,n]=(0,Le.useState)("");return(0,Le.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,ys.jsx)("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:t})},kL=({style:e,className:t,ariaLabel:n})=>{let o=(0,Le.useContext)(FD),a=(0,Le.useRef)(null);if((0,Le.useLayoutEffect)(()=>{if(o)return o(a.current),()=>{o(null)}},[o]),!o)throw new Error("@oh-just-another/react-ui: <DiagramSurface> rendered outside <DiagramRoot>.");return(0,ys.jsx)("div",{ref:a,className:t?`du-canvas-surface ${t}`:"du-canvas-surface",role:"application",tabIndex:0,"aria-label":n??"Diagram canvas",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:"none",userSelect:"none",...e}})};var HD=P(se(),1),gn=P(re(),1);var PX=e=>{let t=null;for(let n of e.elements.values()){if(n.hidden===!0)continue;let o=z(n);t=t?V.union(t,o):o}return t},BX=(e,t,n)=>{let o=t-Fb*2,a=n-Fb*2;if(o<=0||a<=0||e.width<=0||e.height<=0)return null;let r=Math.min(o/e.width,a/e.height),s=e.x+e.width/2,i=e.y+e.height/2;return{zoom:r,pan:{x:s-t/2/r,y:i-n/2/r}}},wL=({width:e=LE,height:t=kE,className:n,style:o,editor:a})=>{let r=G(),s=a??r,i=(0,gn.useRef)(null),l=(0,gn.useRef)(null),c=(0,gn.useRef)(!1),u=(0,gn.useCallback)(()=>{let y=i.current;if(!y||!s)return;let g=s.scene,b=ar(y,e,t),A=y.getContext("2d");if(!A)return;let _=new or(A,e,t,b);_.clear();let T=PX(g),w=T?BX(T,e,t):null;if(l.current=w,!w)return;let S={...g,viewport:{...g.viewport,pan:w.pan,zoom:w.zoom,rotation:0,size:{width:e,height:t}}};Za(S,_),Pn(S,_);let L=g.viewport;if(L.zoom>0&&L.size.width>0&&L.size.height>0){let M=(L.pan.x-w.pan.x)*w.zoom,B=(L.pan.y-w.pan.y)*w.zoom,W=L.size.width/L.zoom*w.zoom,ie=L.size.height/L.zoom*w.zoom;A.setTransform(b,0,0,b,0,0),A.fillStyle=CE,A.fillRect(M,B,W,ie),A.strokeStyle=wE,A.lineWidth=_E,A.strokeRect(M,B,W,ie)}},[s,e,t]);(0,gn.useEffect)(()=>{if(!s)return;u();let y=Date.now(),g=null,b=()=>{let _=Date.now()-y;_>=Hb?(y=Date.now(),u()):g??=setTimeout(()=>{g=null,y=Date.now(),u()},Hb-_)},A=s.subscribe(b);return()=>{A(),g!==null&&clearTimeout(g)}},[s,u]);let d=(0,gn.useCallback)((y,g)=>{let b=l.current;if(!s||!b)return;let A={x:y/b.zoom+b.pan.x,y:g/b.zoom+b.pan.y},_=s.scene.viewport,T=_.pan.x+_.size.width/2/_.zoom,w=_.pan.y+_.size.height/2/_.zoom;s.panBy({x:(T-A.x)*_.zoom,y:(w-A.y)*_.zoom})},[s]),f=(0,gn.useCallback)((y,g,b)=>{let A=l.current;if(!s||!A||b===0)return;let _={x:y/A.zoom+A.pan.x,y:g/A.zoom+A.pan.y},w=1-(Math.abs(b)>Ub?Ub*Math.sign(b):b)*EE/100;if(w<=0)return;let S=s.scene.viewport,L=S.pan.x+S.size.width/2/S.zoom,M=S.pan.y+S.size.height/2/S.zoom;s.panBy({x:(L-_.x)*S.zoom,y:(M-_.y)*S.zoom}),s.zoomAt(w,_)},[s]);(0,gn.useEffect)(()=>{let y=i.current;if(!y)return;let g=b=>{b.preventDefault();let A=y.getBoundingClientRect();f(b.clientX-A.left,b.clientY-A.top,b.deltaY)};return y.addEventListener("wheel",g,{passive:!1}),()=>{y.removeEventListener("wheel",g)}},[f]);let p=y=>{let g=y.currentTarget.getBoundingClientRect();return{x:y.clientX-g.left,y:y.clientY-g.top}},h=(0,gn.useCallback)(y=>{c.current=!0,y.currentTarget.setPointerCapture(y.pointerId);let g=p(y);d(g.x,g.y)},[d]),m=(0,gn.useCallback)(y=>{if(!c.current)return;let g=p(y);d(g.x,g.y)},[d]),x=(0,gn.useCallback)(y=>{c.current=!1,y.currentTarget.releasePointerCapture(y.pointerId)},[]);return(0,HD.jsx)("canvas",{ref:i,className:n,"aria-label":"Diagram minimap",onPointerDown:h,onPointerMove:m,onPointerUp:x,style:{display:"block",width:e,height:t,cursor:"pointer",touchAction:"none",...o}})};var zt=P(se(),1),zge=P(re(),1);var _L=({style:e})=>{let t=G(),n=Vp(),o=BS();if(!t||n!=="brush"&&n!=="erase")return null;let a=n==="erase";return(0,zt.jsxs)("div",{className:"du-drawing-panel",style:{...NX,...e},children:[(0,zt.jsx)("div",{style:zX,children:a?"Eraser":"Drawing"}),!a&&(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsx)(Bg,{label:"Stroke",children:(0,zt.jsx)(tu,{value:o.stroke,onChange:r=>{t.setBrushSettings({stroke:r??o.stroke})},onEyedrop:r=>{t.beginEyedropperPick(r)},allowClear:!1})}),(0,zt.jsx)(Bg,{label:"Fill",children:(0,zt.jsx)(tu,{value:o.fill,onChange:r=>{t.setBrushSettings({fill:r})},onEyedrop:r=>{t.beginEyedropperPick(r)}})}),(0,zt.jsx)(Bg,{label:`Opacity ${Math.round(o.opacity*100)}%`,children:(0,zt.jsx)("input",{type:"range",min:0,max:1,step:.05,value:o.opacity,onChange:r=>{t.setBrushSettings({opacity:r.currentTarget.valueAsNumber})},style:UD,"aria-label":"Brush opacity"})})]}),(0,zt.jsx)(Bg,{label:`${a?"Radius":"Width"} ${o.width}`,children:(0,zt.jsx)("input",{type:"range",min:IE,max:ME,step:1,value:o.width,onChange:r=>{t.setBrushSettings({width:r.currentTarget.valueAsNumber})},style:UD,"aria-label":a?"Eraser radius":"Brush width"})})]})},Bg=({label:e,children:t})=>(0,zt.jsxs)("label",{style:FX,children:[(0,zt.jsx)("span",{style:HX,children:e}),t]}),NX={width:TE,display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid var(--du-border, #d0d0d0)",borderRadius:8,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",font:"12px/1.4 system-ui, sans-serif",color:"var(--du-text, #222)"},zX={fontWeight:600,opacity:.7},FX={display:"flex",flexDirection:"column",gap:4},HX={opacity:.7},UD={width:"100%"};var lu=2,Ft=C.object({x:C.number(),y:C.number()}),qge=C.object({x:C.number(),y:C.number(),width:C.number(),height:C.number()}),UX=C.object({type:C.enum(["sharp","round"]),value:C.number().optional()}).strict(),Ro=C.object({fill:C.string().optional(),stroke:C.string().optional(),strokeWidth:C.number().optional(),opacity:C.number().optional(),dashArray:C.array(C.number()).readonly().optional(),lineCap:C.enum(["butt","round","square"]).optional(),lineJoin:C.enum(["miter","round","bevel"]).optional(),strokeAlign:C.enum(["center","inside","outside"]).optional(),roundness:UX.optional()}).strict(),qD=Ro.extend({textAlign:C.enum(["left","center","right"]).optional(),textBaseline:C.enum(["top","middle","bottom"]).optional(),fontWeight:C.enum(["normal","bold"]).optional(),fontStyle:C.enum(["normal","italic"]).optional(),textDecoration:C.object({underline:C.boolean().optional(),strikethrough:C.boolean().optional()}).strict().optional()}).strict(),jD=C.record(C.string(),C.unknown()).optional(),GX=C.string(),VD=C.discriminatedUnion("kind",[C.object({kind:C.literal("named"),name:GX}).strict(),C.object({kind:C.literal("ratio"),position:Ft}).strict(),C.object({kind:C.literal("absolute"),offset:Ft}).strict(),C.object({kind:C.literal("edge"),index:C.number().int().nonnegative(),t:C.number()}).strict()]),da=C.object({id:C.string(),layerId:C.string(),position:Ft,rotation:C.number(),scale:Ft,order:C.string(),metadata:jD,minWidth:C.number().optional(),minHeight:C.number().optional(),maxWidth:C.number().optional(),maxHeight:C.number().optional(),noFlip:C.boolean().optional(),anchors:C.record(C.string(),VD).optional(),parentId:C.string().optional(),frameId:C.string().optional(),href:C.string().optional()}),WX=da.extend({type:C.literal("rectangle"),style:Ro,width:C.number(),height:C.number()}).strict(),qX=da.extend({type:C.literal("ellipse"),style:Ro,width:C.number(),height:C.number()}).strict(),jX=da.extend({type:C.literal("polygon"),style:Ro,points:C.array(Ft)}).strict(),VX=C.discriminatedUnion("kind",[C.object({kind:C.literal("M"),to:Ft}).strict(),C.object({kind:C.literal("L"),to:Ft}).strict(),C.object({kind:C.literal("Q"),control:Ft,to:Ft}).strict(),C.object({kind:C.literal("C"),control1:Ft,control2:Ft,to:Ft}).strict(),C.object({kind:C.literal("Z")}).strict()]),ZX=da.extend({type:C.literal("path"),style:Ro,commands:C.array(VX)}).strict(),XX=C.object({text:C.string(),style:qD.optional()}).strict(),YX=da.extend({type:C.literal("text"),style:qD,text:C.string(),fontFamily:C.string(),fontSize:C.number(),maxWidth:C.number().optional(),runs:C.array(XX).optional()}).strict(),KX=da.extend({type:C.literal("image"),style:Ro,src:C.string(),width:C.number(),height:C.number(),fileId:C.string().optional(),crop:C.object({x:C.number(),y:C.number(),width:C.number(),height:C.number()}).optional(),animationKind:C.string().optional(),animationData:C.unknown().optional()}).strict(),$X=da.extend({type:C.literal("template"),style:Ro.optional(),templateId:C.string(),data:C.record(C.string(),C.unknown()),width:C.number(),height:C.number()}).strict(),QX=da.extend({type:C.literal("group"),style:Ro.optional()}).strict(),JX=C.object({x:C.number(),y:C.number(),width:C.number()}).strict(),eY=da.extend({type:C.literal("brush"),style:Ro,points:C.array(JX),closed:C.boolean().optional()}).strict(),tY=da.extend({type:C.string(),style:Ro.optional()}).passthrough().refine(e=>!["rectangle","ellipse","polygon","path","text","image","template","group","brush"].includes(e.type),{message:"Use the specific built-in schema for built-in shape types"}),nY=C.union([WX,qX,jX,ZX,YX,KX,$X,QX,eY,tY]),GD=C.discriminatedUnion("kind",[C.object({kind:C.literal("point"),position:Ft}).strict(),C.object({kind:C.literal("anchor"),elementId:C.string(),anchor:VD}).strict(),C.object({kind:C.literal("outline"),elementId:C.string(),ratio:C.number()}).strict(),C.object({kind:C.literal("floating"),elementId:C.string()}).strict()]),oY=C.enum(["straight","orthogonal","bezier"]),WD=C.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),aY=C.object({from:WD.optional(),to:WD.optional(),size:C.number().optional()}).strict(),rY=C.object({text:C.string(),position:C.number().optional(),fontSize:C.number().optional(),fill:C.string().optional(),background:C.string().optional()}).strict(),sY=C.object({id:C.string(),layerId:C.string(),from:GD,to:GD,waypoints:C.array(Ft).readonly().optional(),routedPoints:C.array(Ft).readonly().optional(),fixedSegments:C.array(C.object({axis:C.enum(["h","v"]),pos:C.number(),at:C.number()}).strict()).readonly().optional(),routing:oY.optional(),avoidObstacles:C.boolean().optional(),arrowheads:aY.optional(),label:rY.optional(),order:C.string(),style:Ro,metadata:jD}).strict(),iY=C.object({id:C.string(),name:C.string(),visible:C.boolean(),locked:C.boolean(),order:C.string()}).strict(),lY=C.object({pan:Ft,zoom:C.number(),rotation:C.number(),size:C.object({width:C.number(),height:C.number()}).strict(),gridEnabled:C.boolean(),gridStyle:C.enum(["lines","dots"]).optional(),snapToGrid:C.boolean().optional()}).strict(),cY=C.object({id:C.string(),authorId:C.string(),authorName:C.string(),body:C.string(),createdAt:C.string()}).strict(),uY=C.object({id:C.string(),elementId:C.string().nullable(),position:Ft,resolved:C.boolean(),thread:C.array(cY),createdAt:C.string()}).strict(),ZD=C.object({format:C.literal("oh-just-another/scene"),version:C.number().int().nonnegative(),elements:C.array(nY),links:C.array(sY),layers:C.array(iY),annotations:C.array(uY).optional(),viewport:lY}).strict();var XD=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:lu,elements:[...e.elements.values()].map(dY),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},dY=e=>{let t=e.metadata,n=t&&"image"in t,o=e.animationData!==void 0;if(!n&&!o)return e;let a={...e};if(n){let{image:r,...s}=t;Object.keys(s).length>0?a.metadata=s:delete a.metadata}return o&&delete a.animationData,a},CL=(e,t=null)=>JSON.stringify(XD(e),null,t??void 0);var YD=new Map,KD=(e,t)=>{YD.set(e,t)},$D=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=YD.get(a);if(!r)throw new EL(a,n);o=r(o)}return o},EL=class extends Error{fromVersion;toVersion;constructor(t,n){super(`No migration registered from v${t} \u2192 v${t+1} (target v${n})`),this.name="MissingMigrationError",this.fromVersion=t,this.toVersion=n}};var fY=e=>{let t=e,n={...t.viewport??{}},o=n.gridSize;return delete n.gridSize,n.gridEnabled=typeof o=="number"&&o>0,{...t,version:2,viewport:n}};KD(1,fY);var cu=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},QD=(e,t={})=>{if(typeof e!="object"||e===null)throw new cu("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??lu;if(o>a)throw new cu(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===lu?e:$D(e,o,lu),s;try{s=ZD.parse(r)}catch(i){throw i instanceof C.ZodError?new cu(`Invalid scene document: ${i.message}`,i):i}return pY(s)},TL=(e,t)=>QD(JSON.parse(e),t),pY=e=>{let t=new Map;for(let s of e.elements){let i=Ze(s.id);t.set(i,hY(s,i))}let n=new Map;for(let s of e.links){let i=Jb(s.id);n.set(i,mY(s,i))}let o=new Map;for(let s of e.layers){let i=ln(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Ef(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Cf(s.id);r.set(i,{id:i,elementId:s.elementId===null?null:Ze(s.elementId),position:s.position,resolved:s.resolved,thread:s.thread.map(l=>({id:oc(l.id),authorId:l.authorId,authorName:l.authorName,body:l.body,createdAt:l.createdAt})),createdAt:s.createdAt})}return{elements:t,links:n,layers:o,annotations:r,files:new Map,viewport:a}},hY=(e,t)=>({...Ef(e),id:t,layerId:ln(e.layerId),order:e.order}),mY=(e,t)=>{let n=s=>s.kind==="anchor"||s.kind==="outline"||s.kind==="floating"?{...s,elementId:Ze(s.elementId)}:s,o=n(e.from),a=n(e.to);return{...Ef(e),id:t,layerId:ln(e.layerId),order:e.order,from:o,to:a}};var uu=P(se(),1),sr=P(re(),1);var yY=[0,50,90],IL=({children:e,snapPoints:t=yY,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,sr.useState)(()=>o??t.find(x=>x>0)??50),c=n??i,u=(0,sr.useCallback)(x=>{l(x),a?.(x)},[a]),d=(0,sr.useRef)(null),f=(0,sr.useRef)(null),p=x=>{d.current={startY:x.clientY,startHeight:c,pointerId:x.pointerId},x.target.setPointerCapture?.(x.pointerId)},h=x=>{if(d.current?.pointerId!==x.pointerId)return;let y=window.innerHeight||1,g=(d.current.startY-x.clientY)/y*100,b=ac.clamp(d.current.startHeight+g,0,100);u(b)},m=x=>{if(d.current?.pointerId!==x.pointerId)return;d.current=null;let y=t[0];if(y===void 0)return;let g=Math.abs(c-y);for(let b of t){let A=Math.abs(c-b);A<g&&(y=b,g=A)}u(y)};return(0,sr.useEffect)(()=>{let x=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[u,t]),(0,uu.jsxs)("div",{ref:f,role:"dialog","aria-label":"Bottom sheet",className:r,style:{position:"fixed",left:0,right:0,bottom:0,height:`${c}vh`,background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",borderTop:"1px solid var(--border, #2a2a2a)",borderTopLeftRadius:12,borderTopRightRadius:12,boxShadow:"0 -4px 18px rgba(0,0,0,0.4)",display:"flex",flexDirection:"column",overflow:"hidden",transition:d.current?"none":"height 180ms ease",zIndex:100,...s},children:[(0,uu.jsx)("div",{role:"separator","aria-orientation":"horizontal",onPointerDown:p,onPointerMove:h,onPointerUp:m,onPointerCancel:m,style:{touchAction:"none",padding:"8px 0",display:"flex",justifyContent:"center",cursor:"grab"},children:(0,uu.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,uu.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var JD=P(se(),1),ir=P(re(),1);var ML=()=>{let e=G(),t=(0,ir.useRef)(null),[,n]=(0,ir.useReducer)(c=>c+1,0);(0,ir.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,ir.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,ir.useLayoutEffect)(()=>{let c=t.current;if(!e||!o||!c)return;let u=I(e.scene,o),d=u?.type==="text"?u.text:"";c.value!==d&&(c.value=d);let f=e.editingTextSelection;f&&(c.selectionStart!==f.start||c.selectionEnd!==f.end)&&c.setSelectionRange(f.start,f.end,f.dir)}),!e||!o)return null;let a=I(e.scene,o);if(a?.type!=="text")return null;let r=e.scene.viewport,s=(a.position.x-r.pan.x)*r.zoom,i=(a.position.y-r.pan.y)*r.zoom,l=c=>c.selectionDirection==="backward"?"backward":"forward";return(0,JD.jsx)("textarea",{ref:t,defaultValue:a.text,onInput:c=>{let u=c.currentTarget;e.setEditingText(u.value,u.selectionStart,u.selectionEnd,l(u))},onSelect:c=>{let u=c.currentTarget;e.setEditingSelection(u.selectionStart,u.selectionEnd,l(u))},onKeyDown:c=>{(c.key==="Escape"||c.key==="Enter"&&(c.metaKey||c.ctrlKey))&&(c.preventDefault(),c.stopPropagation(),e.commitTextEdit())},onBlur:()=>{let c=o;setTimeout(()=>{let u=t.current;u&&e.editingTextElement===c&&document.activeElement!==u&&u.focus()},0)},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":"Text editor",style:{position:"absolute",top:i,left:s,width:1,height:1,padding:0,margin:0,border:0,outline:"none",opacity:0,resize:"none",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none",zIndex:100}})};var e6=P(se(),1),al=P(re(),1);var RL=()=>{let e=G(),t=(0,al.useRef)(null),[,n]=(0,al.useReducer)(d=>d+1,0);(0,al.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,al.useEffect)(()=>{if(!o)return;let d=t.current;d&&(d.focus(),d.select())},[o]),!e||!o)return null;let a=I(e.scene,o);if(!a||!Be(a))return null;let r=e.scene.viewport,s=r.zoom,i=(a.position.x-r.pan.x)*s,l=(a.position.y-24*a.scale.y-r.pan.y)*s,c=a.width*a.scale.x*s,u=24*a.scale.y*s;return(0,e6.jsx)("input",{ref:t,type:"text",defaultValue:a.name??"",placeholder:"Frame","aria-label":"Frame name",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onKeyDown:d=>{d.key==="Enter"?(d.preventDefault(),d.stopPropagation(),e.commitFrameNameEdit(d.currentTarget.value)):d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),e.cancelFrameNameEdit()):d.stopPropagation()},onBlur:d=>{e.commitFrameNameEdit(d.currentTarget.value)},style:{position:"absolute",left:i,top:l,width:c,height:u,boxSizing:"border-box",padding:`0 ${8*s}px`,margin:0,border:0,outline:"none",background:"#222",color:"#ddd",font:`${12*s}px system-ui, sans-serif`,lineHeight:`${u}px`,pointerEvents:"auto",zIndex:100}},o)};var du=P(se(),1),xs=P(re(),1),o6=P(ha(),1);var gs=P(re(),1),t6=e=>{let t=(0,gs.useRef)(null),n=(0,gs.useRef)(e);n.current=e;let o=(0,gs.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,gs.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,gs.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var n6=220,OL=()=>{let e=G(),[t,n]=(0,xs.useState)(null),[,o]=(0,xs.useReducer)(m=>m+1,0),a=(0,xs.useRef)(!1),r=Dt(),{schedule:s,cancel:i}=t6(()=>{a.current||n(null)});if((0,xs.useEffect)(()=>{if(!e)return;let m=e.hostElement;if(!m)return;let x=b=>{if(e.editingTextElement!==null){n(null);return}let A=m.getBoundingClientRect(),_=e.screenToWorld({x:b.clientX-A.left,y:b.clientY-A.top}),T=e.linkAt(_);T?(i(),n({href:T.href,bounds:T.bounds})):a.current||s(n6)},y=()=>{s(n6)};m.addEventListener("pointermove",x),m.addEventListener("pointerleave",y);let g=e.on("change",()=>{o()});return()=>{m.removeEventListener("pointermove",x),m.removeEventListener("pointerleave",y),g(),i()}},[e,s,i]),!e||!t)return null;let l=e.hostElement;if(!l)return null;let c=e.scene.viewport,u=l.getBoundingClientRect(),d=(t.bounds.x-c.pan.x)*c.zoom+u.left,f=(t.bounds.y-c.pan.y)*c.zoom+u.top,p=t.bounds.width*c.zoom,h=t.href.replace(/^mailto:/,"").replace(/^https?:\/\//,"");return(0,o6.createPortal)((0,du.jsx)("div",{className:"du-link-popup",style:{position:"fixed",left:d+p/2,top:f,transform:"translate(-50%, -100%)"},onPointerEnter:()=>{a.current=!0},onPointerLeave:()=>{a.current=!1,n(null)},children:(0,du.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,du.jsx)("span",{className:"du-link-popup-text",children:h}),(0,du.jsx)(Nd,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var bs=P(se(),1),Ng=P(re(),1),a6=P(ha(),1);var DL=()=>{let e=G(),[,t]=(0,Ng.useReducer)(u=>u+1,0),n=Dt();if((0,Ng.useEffect)(()=>{if(!e)return;let u=e.on("change",()=>{t()}),d=f=>{f.key==="Escape"&&e.linkDropMenu&&e.dismissLinkDropMenu()};return window.addEventListener("keydown",d),()=>{u(),window.removeEventListener("keydown",d)}},[e]),!e)return null;let o=e.linkDropMenu;if(!o)return null;let a=e.hostElement;if(!a)return null;let r=e.scene.viewport,s=a.getBoundingClientRect(),i=(o.world.x-r.pan.x)*r.zoom+s.left,l=(o.world.y-r.pan.y)*r.zoom+s.top,c=Oi.byCategory("basic");return(0,a6.createPortal)((0,bs.jsxs)(bs.Fragment,{children:[(0,bs.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,bs.jsx)("div",{className:"du-link-drop-menu",role:"menu","aria-label":"Create shape",style:{position:"fixed",left:i,top:l,transform:"translate(-50%, -100%)",zIndex:1601},onPointerDown:u=>{u.stopPropagation()},children:c.map(u=>(0,bs.jsx)("button",{type:"button",className:"du-link-drop-item",title:u.name,"aria-label":`Create ${u.name}`,onClick:()=>{e.placeShapeAtLinkDrop(d=>u.factory(d))},dangerouslySetInnerHTML:{__html:u.icon}},u.id))})]}),n)};var r6=P(se(),1),lr=P(re(),1),s6=P(ha(),1);var PL=()=>{let e=G(),[,t]=(0,lr.useReducer)(h=>h+1,0),[n,o]=(0,lr.useState)(""),a=(0,lr.useRef)(null),r=Dt();(0,lr.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,lr.useEffect)(()=>{if(!e||s===null)return;let h=e.scene.links.get(s);o(h?.label?.text??"");let m=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(m)}},[e,s]),!e||s===null)return null;let i=e.hostElement;if(!i)return null;let l=e.linkLabelWorld(s);if(!l)return null;let c=e.scene.viewport,u=i.getBoundingClientRect(),d=(l.x-c.pan.x)*c.zoom+u.left,f=(l.y-c.pan.y)*c.zoom+u.top,p=()=>{e.commitLinkCaptionEdit(n)};return(0,s6.createPortal)((0,r6.jsx)("input",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:h=>{o(h.target.value)},onBlur:p,onKeyDown:h=>{h.key==="Enter"?(h.preventDefault(),p()):h.key==="Escape"&&(h.preventDefault(),e.cancelLinkCaptionEdit()),h.stopPropagation()}}),r)};var bt=P(se(),1),zg=P(re(),1);var gY=16,xY=1.75,BL={size:gY,strokeWidth:xY},bY={"mode-select":tf,"mode-hand":jd,"mode-rect":Uo,"mode-ellipse":Ys,"mode-text":yf,"mode-edge":ff,"mode-brush":Wr,"mode-erase":Bd,"mode-laser":lf,"mode-frame":Gd,"insert-image":$s,"tool-lock":Kd,undo:ei,redo:Js},AY=({id:e})=>{let t=G(),[,n]=(0,zg.useState)(0);(0,zg.useEffect)(()=>{if(t)return t.on("change",()=>{n(f=>f+1)})},[t]);let o=_e.get(e);if(!o)return null;let a=o.iconId?bY[o.iconId]:void 0,r=t?{editor:t}:null,s=r?o.checked?.(r)??!1:!1,i=!!t?.readOnly&&o.viewMode!==!0,l=r&&!i?o.predicate?o.predicate(r):!0:!1,u=(o.hotkey===void 0?[]:Array.isArray(o.hotkey)?o.hotkey:[o.hotkey])[0],d=`${o.label??e}${u?` (${ut(u)})`:""}`;return(0,bt.jsx)(fu,{title:d,active:s,disabled:!l,onClick:()=>{t&&_e.dispatch(e,{editor:t})},children:a?(0,bt.jsx)(a,{...BL}):o.label??e})},Rxe=ut({meta:!0,key:"\u2212"}),Oxe=ut({meta:!0,key:"+"}),Dxe=ut({meta:!0,key:"0"}),Pxe=ut({meta:!0,key:"1"}),NL=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="image/*",t.multiple=!0,t.addEventListener("change",()=>{let n=t.files;if(!n||n.length===0)return;let o=e.scene.viewport,a=e.screenToWorld({x:o.size.width/2,y:o.size.height/2});for(let r of Array.from(n))e.dispatchFileDrop(r,a)}),t.click()},i6=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,bt.jsx)($s,{...BL}),title:"Insert image (I)",onClick:e=>{NL(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],Fg=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"divider"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,bt.jsx)($s,{...BL}),title:"Insert image (I)",onClick:e=>{NL(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],zL=({items:e=i6,style:t,className:n,orientation:o="horizontal"})=>{let a=G(),r=Vp(),s=is(),{canUndo:i,canRedo:l,undo:c,redo:u}=NS(),d=o==="vertical";return(0,bt.jsx)("div",{role:"toolbar","aria-orientation":o,className:`du-button-group${d?" du-button-group-vertical":""} ${n??""}`.trim(),style:t,children:e.map((f,p)=>{switch(f.kind){case"divider":return(0,bt.jsx)(SY,{vertical:d},p);case"action-ref":return(0,bt.jsx)(AY,{id:f.id},p);case"mode":{let h=r===f.mode,m=f.mode==="select"||f.mode==="hand";return(0,bt.jsx)(fu,{...f.title!==void 0?{title:f.title}:{},disabled:!a||s&&!m,active:h,onClick:()=>a?.setMode(f.mode),children:f.label},p)}case"action":return(0,bt.jsx)(fu,{...f.title!==void 0?{title:f.title}:{},disabled:f.disabled??(!a||s),active:f.active,onClick:()=>{a&&f.onClick(a)},children:f.label},p);case"undo":return(0,bt.jsx)(fu,{disabled:!i||s,onClick:c,children:f.label??"Undo"},p);case"redo":return(0,bt.jsx)(fu,{disabled:!l||s,onClick:u,children:f.label??"Redo"},p);case"tool-lock":return(0,bt.jsx)(vY,{...f.label!==void 0?{label:f.label}:{},...f.title!==void 0?{title:f.title}:{}},p)}})})},vY=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=G(),o=sn(r=>r.toolLocked,!1),a=is();return(0,bt.jsx)(fu,{disabled:!n||a,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var fu=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,bt.jsx)("button",{type:"button",onClick:t,disabled:o,"aria-label":a,"aria-pressed":n,className:`du-icon-button${n?" is-active":""}${r?` ${r}`:""}`,style:{width:"auto",minWidth:"var(--du-button-size, 36px)",padding:"0 8px",...s},children:e});return a?(0,bt.jsx)(ti,{content:a,children:i}):i},SY=({vertical:e=!1})=>e?(0,bt.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,bt.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var FL=.5522847498307936,l6=.55;var LY={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},c6=(e,t,n)=>{let o=0;for(let a of e)o+=(LY[a]??l6)*n;return o};var Hg=class{size;measure;fillColor=null;strokeColor=null;strokeWidth=1;opacity=1;lineCap="butt";lineJoin="miter";dashArray=null;fontFamily="system-ui, sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";currentTransform=N.IDENTITY;pathSegments=[];pathCursor=null;elements=[];clipIdCounter=0;stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??c6}toSvg(){let t=this.size.width,n=this.size.height;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">`+this.elements.join("")+"</svg>"}setFill(t){this.fillColor=t}setStroke(t){this.strokeColor=t}setStrokeWidth(t){this.strokeWidth=t}setOpacity(t){this.opacity=t}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}save(){this.stack.push({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,opacity:this.opacity,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline,transform:this.currentTransform})}restore(){let t=this.stack.pop();t&&(this.fillColor=t.fillColor,this.strokeColor=t.strokeColor,this.strokeWidth=t.strokeWidth,this.opacity=t.opacity,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline,this.currentTransform=t.transform)}translate(t,n){this.currentTransform=N.multiply(this.currentTransform,N.translation(t,n))}rotate(t){this.currentTransform=N.multiply(this.currentTransform,N.rotation(t))}scale(t,n){this.currentTransform=N.multiply(this.currentTransform,N.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=N.IDENTITY}beginPath(){this.pathSegments=[],this.pathCursor=null}closePath(){this.pathSegments.push("Z")}moveTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`M${He(o.x)} ${He(o.y)}`),this.pathCursor=o}lineTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`L${He(o.x)} ${He(o.y)}`),this.pathCursor=o}quadraticCurveTo(t,n,o,a){let r=this.apply(t,n),s=this.apply(o,a);this.pathSegments.push(`Q${He(r.x)} ${He(r.y)} ${He(s.x)} ${He(s.y)}`),this.pathCursor=s}bezierCurveTo(t,n,o,a,r,s){let i=this.apply(t,n),l=this.apply(o,a),c=this.apply(r,s);this.pathSegments.push(`C${He(i.x)} ${He(i.y)} ${He(l.x)} ${He(l.y)} ${He(c.x)} ${He(c.y)}`),this.pathCursor=c}rect(t,n,o,a){this.moveTo(t,n),this.lineTo(t+o,n),this.lineTo(t+o,n+a),this.lineTo(t,n+a),this.closePath()}ellipse(t,n,o,a){let r=o*FL,s=a*FL;this.moveTo(t+o,n),this.bezierCurveTo(t+o,n+s,t+r,n+a,t,n+a),this.bezierCurveTo(t-r,n+a,t-o,n+s,t-o,n),this.bezierCurveTo(t-o,n-s,t-r,n-a,t,n-a),this.bezierCurveTo(t+r,n-a,t+o,n-s,t+o,n),this.closePath()}fill(t="nonzero"){if(this.pathSegments.length===0)return;let o=[`d="${this.pathSegments.join(" ")}"`,`fill="${this.fillColor??"none"}"`,t==="evenodd"?'fill-rule="evenodd"':"",this.opacity!==1?`fill-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}stroke(){if(this.pathSegments.length===0||this.strokeColor===null||this.strokeWidth<=0)return;let t=this.pathSegments.join(" "),n=this.dashArray&&this.dashArray.length>0?`stroke-dasharray="${this.dashArray.join(" ")}"`:"",o=[`d="${t}"`,'fill="none"',`stroke="${this.strokeColor}"`,`stroke-width="${this.strokeWidth}"`,this.lineCap!=="butt"?`stroke-linecap="${this.lineCap}"`:"",this.lineJoin!=="miter"?`stroke-linejoin="${this.lineJoin}"`:"",n,this.opacity!==1?`stroke-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}fillText(t,n,o,a){if(!t)return;let r=this.apply(n,o),s=this.textAlign==="center"?"middle":this.textAlign==="right"?"end":"start",i=this.textBaseline==="middle"?"central":this.textBaseline==="bottom"?"alphabetic":"hanging",l=[`x="${He(r.x)}"`,`y="${He(r.y)}"`,`font-family="${HL(this.fontFamily)}"`,`font-size="${this.fontSize}"`,this.fontWeight==="bold"?'font-weight="bold"':"",this.fontStyle==="italic"?'font-style="italic"':"",`fill="${this.fillColor??"#000"}"`,`text-anchor="${s}"`,`dominant-baseline="${i}"`,this.opacity!==1?`fill-opacity="${this.opacity}"`:"",a!==void 0?`textLength="${a}" lengthAdjust="spacingAndGlyphs"`:""].filter(Boolean).join(" ");this.elements.push(`<text ${l}>${wY(t)}</text>`)}measureText(t){return{width:this.measure(t,this.fontFamily,this.fontSize)}}drawImage(t,n,o,a,r,s,i){if(typeof t!="string"||t==="")return;let l=this.apply(n,o);if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){this.drawCroppedImage(t,l.x,l.y,a,r,i);return}this.elements.push(`<image x="${He(l.x)}" y="${He(l.y)}" width="${a}" height="${r}" href="${HL(t)}"/>`)}drawCroppedImage(t,n,o,a,r,s){let i=a/s.width,l=r/s.height,c=n-s.x*i,u=o-s.y*l,d=`oja-crop-${(this.clipIdCounter++).toString()}`;this.elements.push(`<clipPath id="${d}"><rect x="${He(n)}" y="${He(o)}" width="${a}" height="${r}"/></clipPath><g clip-path="url(#${d})"><image x="${He(c)}" y="${He(u)}" width="${He(i)}" height="${He(l)}" preserveAspectRatio="none" href="${HL(t)}"/></g>`)}clear(t){if(!t){this.elements.length=0;return}let n=this.apply(t.x,t.y),o=this.apply(t.x+t.width,t.y+t.height),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y),s=Math.abs(o.x-n.x),i=Math.abs(o.y-n.y);this.elements.push(`<rect x="${He(a)}" y="${He(r)}" width="${s}" height="${i}" fill="#fff"/>`)}apply(t,n){return N.applyToPoint(this.currentTransform,{x:t,y:n})}},He=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),HL=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),wY=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");var UL=(e,t={})=>{t.skipInstall||Dc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Hg({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Za(e,a,t),Pn(e,a),a.toSvg()};var As=P(se(),1),fa=P(re(),1),u6=P(ha(),1);var GL=({items:e,style:t,className:n})=>{let o=G(),a=xg(),r=Dt(),[s,i]=(0,fa.useState)(null),l=(0,fa.useRef)(null);(0,fa.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,fa.useEffect)(()=>{if(o)return o.onLongPress(({screenPoint:p,worldPoint:h})=>{let m=o.hostElement.getBoundingClientRect();i({screenPoint:{x:p.x+m.left,y:p.y+m.top},worldPoint:h})})},[o]),(0,fa.useEffect)(()=>{if(!s)return;let p=m=>{l.current?.contains(m.target)||i(null)},h=m=>{m.key==="Escape"&&i(null)};return window.addEventListener("pointerdown",p,!0),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",p,!0),window.removeEventListener("keydown",h)}},[s]);let c=(0,fa.useCallback)(()=>{i(null)},[]);if(!o||!s)return null;let u={worldPoint:s.worldPoint,screenPoint:s.screenPoint},d=e.filter(p=>p.kind==="divider"||p.visible?.(o,u)!==!1),f=CY(d);return f.length===0?null:(0,u6.createPortal)((0,As.jsx)("div",{ref:l,role:"menu",style:{position:"fixed",zIndex:1e3,top:s.screenPoint.y,left:s.screenPoint.x,background:"var(--menu-bg, var(--du-ui-bg-solid, #fff))",color:"var(--menu-text, var(--du-text, #1a1a1a))",border:"1px solid var(--menu-border, var(--du-ui-border, rgba(0,0,0,0.08)))",borderRadius:6,padding:"4px 0",minWidth:180,boxShadow:"var(--du-ui-shadow, 0 4px 16px rgba(0,0,0,0.18))",font:"13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",...t},className:n,children:f.map((p,h)=>p.kind==="divider"?(0,As.jsx)("hr",{style:{border:0,borderTop:"1px solid var(--menu-divider, var(--du-ui-border, rgba(0,0,0,0.08)))",margin:"4px 0"}},`d-${h}`):(0,As.jsx)(_Y,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},_Y=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,As.jsxs)("button",{type:"button",role:"menuitem",onClick:s=>{if(a){s.preventDefault();return}s.stopPropagation(),o()},disabled:a,style:{all:"unset",display:"flex",justifyContent:"space-between",padding:"6px 12px",cursor:a?"not-allowed":"pointer",opacity:a?.4:1,width:"100%",boxSizing:"border-box"},onMouseEnter:s=>{a||(s.currentTarget.style.background="var(--du-hover-overlay, rgba(0,0,0,0.05))")},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[(0,As.jsx)("span",{children:e.label}),e.shortcut?(0,As.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},CY=e=>{let t=[];for(let n of e)n.kind==="divider"&&(t.length===0||t[t.length-1]?.kind==="divider")||t.push(n);for(;t.length>0&&t[t.length-1]?.kind==="divider";)t.pop();return t},WL=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},Ce=(e,t)=>{let n=_e.get(e),o=n?.predicate,r=(n?.hotkey?Array.isArray(n.hotkey)?n.hotkey:[n.hotkey]:[])[0],s=t?.visible??(o?l=>o({editor:l}):void 0),i=(l,c)=>(!l.readOnly||n?.viewMode===!0)&&(s?.(l,c)??!0);return{kind:"action",id:e,label:t?.label??n?.label??e,...r?{shortcut:ut(r)}:{},visible:i,onClick:l=>{_e.dispatch(e,{editor:l})}}},qL=[{kind:"action",id:"annotation-open",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"annotation-toggle-resolved",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"annotation-delete",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"divider"},Ce("delete-selection",{label:"Delete"}),Ce("duplicate-selection",{label:"Duplicate"}),Ce("copy"),Ce("cut"),Ce("paste"),Ce("copy-style",{label:"Copy style"}),Ce("paste-style",{label:"Paste style"}),Ce("select-all"),{kind:"divider"},Ce("group-selection",{label:"Group"}),Ce("ungroup-selection",{label:"Ungroup"}),Ce("flip-horizontal",{label:"Flip horizontal"}),Ce("flip-vertical",{label:"Flip vertical"}),Ce("align-left",{label:"Align left"}),Ce("align-h-center",{label:"Align horizontal centres"}),Ce("align-right",{label:"Align right"}),Ce("align-top",{label:"Align top"}),Ce("align-v-center",{label:"Align vertical centres"}),Ce("align-bottom",{label:"Align bottom"}),Ce("distribute-horizontal",{label:"Distribute horizontally"}),Ce("distribute-vertical",{label:"Distribute vertically"}),Ce("arrange-grid"),Ce("arrange-stack-h"),Ce("arrange-stack-v"),Ce("auto-arrange"),Ce("compact-z-order"),{kind:"divider"},Ce("bring-to-front",{visible:e=>e.selection.size===1}),Ce("send-to-back",{visible:e=>e.selection.size===1}),{kind:"action",id:"move-to-layer",label:"Move to layer\u2026",visible:e=>!e.readOnly&&e.selection.size>0&&e.scene.layers.size>1,onClick:e=>{if(typeof window>"u")return;let t=[...e.scene.layers.values()],n=t.map((s,i)=>`${i+1}. ${s.name}`).join(`
167
+ }`;var Vg=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",RL=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new ar(o,e,t);return{canvas:n,target:a}};var rr=(e,t,n,o=sr(),a=!0)=>{let r=Math.round(t*o),s=Math.round(n*o),i=`${t}px`,l=`${n}px`;if(e.width===r&&e.height===s&&e.style.width===i&&e.style.height===l)return o;if(e.width=r,e.height=s,e.style.width=i,e.style.height=l,a){let c=e.getContext("2d");if(!c)throw new Error("Failed to obtain 2D context");c.setTransform(o,0,0,o,0,0)}return o},sr=(e=2)=>Math.min(typeof window<"u"&&window.devicePixelRatio||1,e);var Mh=class{host;layers;canvases;width;height;dprOverride;maxDpr;constructor(t,n,o,a={}){this.host=t,this.width=n,this.height=o,this.dprOverride=a.dpr,this.maxDpr=a.maxDpr??2,getComputedStyle(t).position==="static"&&(t.style.position="relative");let r=a.layers??wi,s=new Map,i=new Map;for(let l of wi){if(!r.includes(l))continue;let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",t.appendChild(c);let u=rr(c,n,o,this.dprOverride??sr(this.maxDpr)),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new ar(d,n,o,u)),i.set(l,c)}this.layers=s,this.canvases=i}get(t){let n=this.layers.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this.width===t&&this.height===n)){this.width=t,this.height=n;for(let[o,a]of this.canvases){let r=rr(a,t,n,this.dprOverride??sr(this.maxDpr)),s=this.layers.get(o);s!==void 0&&s.resize(t,n,r)}}}get size(){return{width:this.width,height:this.height}}dispose(){for(let t of this.canvases.values())t.remove()}};var DL=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var p6=-2128831035,h6=522970236,gY=16777619,xY=2246822507,m6=-1640531527,bY=2147483647,AY=1431655765,g6=new Float64Array(1),y6=new Int32Array(g6.buffer),jg=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new Cp(64);captureGen=0;captureCanvas=null;nextImageId=0;sigA=p6;sigB=h6;cmdCount=0;_lastSignature="";constructor(t,n){this._width=t,this._height=n}get size(){return{width:this._width,height:this._height}}resize(t,n){this._width=t,this._height=n,this.emit({k:"resize",w:t,h:n})}emit(t){this.commands.push(t),this.cmdCount++,this.mixString(t.k);for(let n in t)n!=="k"&&this.mixValue(t[n])}mix32(t){let n=t|0;this.sigA=(Math.imul(this.sigA^n,gY)|0)^m6,this.sigB=Math.imul(this.sigB^n+m6,xY)|0}mixNumber(t){g6[0]=t,this.mix32(y6[0]??0),this.mix32(y6[1]??0)}mixString(t){for(let n=0;n<t.length;n++)this.mix32(t.charCodeAt(n));this.mix32(t.length^65536)}mixValue(t){if(t==null){this.mix32(bY);return}switch(typeof t){case"number":this.mixNumber(t);return;case"boolean":this.mix32(t?1:2);return;case"string":this.mixString(t);return;case"object":{if(Array.isArray(t)){for(let n of t)this.mixValue(n);this.mix32(t.length^AY);return}if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap)return;for(let n in t)this.mixValue(t[n]);return}default:return}}get lastSignature(){return this._lastSignature}flush(){let t=this.commands;return this._lastSignature=`${this.cmdCount}:${(this.sigA>>>0).toString(36)}:${(this.sigB>>>0).toString(36)}`,this.commands=[],this.sigA=p6,this.sigB=h6,this.cmdCount=0,t}peek(){return this.commands}setFill(t){this.emit({k:"setFill",color:t})}setStroke(t){this.emit({k:"setStroke",color:t})}setStrokeWidth(t){this.emit({k:"setStrokeWidth",w:t})}setOpacity(t){this.emit({k:"setOpacity",a:t})}setLineCap(t){this.emit({k:"setLineCap",cap:t})}setLineJoin(t){this.emit({k:"setLineJoin",join:t})}setDashArray(t){this.emit({k:"setDashArray",dash:t})}setFont(t,n,o){this.emit({k:"setFont",family:t,size:n,...o?{options:o}:{}});let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.fontSpec=`${a}${r}${n}px "${cu(t)}", ${t}`}setTextAlign(t){this.emit({k:"setTextAlign",align:t})}setTextBaseline(t){this.emit({k:"setTextBaseline",baseline:t})}save(){this.emit({k:"save"})}restore(){this.emit({k:"restore"})}translate(t,n){this.emit({k:"translate",x:t,y:n})}rotate(t){this.emit({k:"rotate",r:t})}scale(t,n){this.emit({k:"scale",sx:t,sy:n})}setTransform(t){this.emit({k:"setTransform",t})}resetTransform(){this.emit({k:"resetTransform"})}beginPath(){this.emit({k:"beginPath"})}closePath(){this.emit({k:"closePath"})}moveTo(t,n){this.emit({k:"moveTo",x:t,y:n})}lineTo(t,n){this.emit({k:"lineTo",x:t,y:n})}quadraticCurveTo(t,n,o,a){this.emit({k:"quadraticCurveTo",cx:t,cy:n,x:o,y:a})}bezierCurveTo(t,n,o,a,r,s){this.emit({k:"bezierCurveTo",c1x:t,c1y:n,c2x:o,c2y:a,x:r,y:s})}rect(t,n,o,a){this.emit({k:"rect",x:t,y:n,w:o,h:a})}ellipse(t,n,o,a){this.emit({k:"ellipse",cx:t,cy:n,rx:o,ry:a})}fill(t){this.emit(t!==void 0?{k:"fill",rule:t}:{k:"fill"})}stroke(){this.emit({k:"stroke"})}fillText(t,n,o,a){this.emit(a!==void 0?{k:"fillText",text:t,x:n,y:o,maxWidth:a}:{k:"fillText",text:t,x:n,y:o})}measureText(t){let n=this.ensureMeasureCtx();return n?(n.font=this.fontSpec,{width:n.measureText(t).width}):{width:t.length*(Number.parseFloat(this.fontSpec)||8)*.5}}ensureMeasureCtx(){if(this.measureCtx)return this.measureCtx;if(typeof OffscreenCanvas>"u")return null;let t=new OffscreenCanvas(1,1).getContext("2d");return this.measureCtx=t??null,this.measureCtx}drawImage(t,n,o,a,r,s){if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let i=this.imageIds.get(t);i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i),this.emit({k:"defineImage",id:i,bitmap:t})),this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r});return}if(uu(t)){let i=this.imageIds.get(t);if(i===void 0||s===!0){let l=this.captureBitmap(t);if(!l){this.skippedImageDraws++;return}i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i)),this.emit({k:"defineImage",id:i,bitmap:l,gen:++this.captureGen})}this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r});return}this.skippedImageDraws++}captureBitmap(t){if(typeof OffscreenCanvas>"u")return null;let n=Ng(t);if(!n||n.width<=0||n.height<=0)return null;let o=t;if(typeof o.readyState=="number"&&o.readyState<2)return null;this.captureCanvas??=new OffscreenCanvas(n.width,n.height);let a=this.captureCanvas;(a.width!==n.width||a.height!==n.height)&&(a.width=n.width,a.height=n.height);let r=a.getContext("2d");return r?(r.clearRect(0,0,n.width,n.height),r.drawImage(t,0,0),a.transferToImageBitmap()):null}clear(t){this.emit(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.emit({k:"markDirty",bounds:t})}};var vY=0,SY=1,LY=2,kY=3,_Y=4,wY=5,TY=6,EY=7,CY=8,IY=9,MY=10,RY=11,OY=12,DY=13,PY=14,BY=15,NY=16,zY=17,FY=18,HY=19,UY=20,GY=21,WY=22,qY=23,VY=24,jY=25,ZY=26,XY=27,YY=28,KY=29,$Y=30,QY=31,x6=-1,JY=-1;var eK={butt:0,round:1,square:2};var tK={miter:0,round:1,bevel:2};var nK={left:0,center:1,right:2};var oK={top:0,middle:1,bottom:2},aK={nonzero:1,evenodd:2},rK={normal:1,bold:2},sK={normal:1,italic:2},Zg=0,PL=1,iK=4,lK=64,b6=e=>{let t=new Float64Array(Math.max(lK,e.length*iK)),n=0,o=l=>{if(n===t.length){let c=new Float64Array(t.length*2);c.set(t),t=c}t[n++]=l},a=[],r=new Map,s=l=>{let c=r.get(l);return c===void 0&&(c=a.length,a.push(l),r.set(l,c)),c},i=[];for(let l of e)switch(l.k){case"setFill":o(vY),o(l.color===null?x6:s(l.color));break;case"setStroke":o(SY),o(l.color===null?x6:s(l.color));break;case"setStrokeWidth":o(LY),o(l.w);break;case"setOpacity":o(kY),o(l.a);break;case"setLineCap":o(_Y),o(eK[l.cap]);break;case"setLineJoin":o(wY),o(tK[l.join]);break;case"setDashArray":if(o(TY),l.dash===null)o(JY);else{o(l.dash.length);for(let c of l.dash)o(c)}break;case"setFont":o(EY),o(s(l.family)),o(l.size),l.options===void 0?o(Zg):(o(PL),o(l.options.weight===void 0?0:rK[l.options.weight]),o(l.options.style===void 0?0:sK[l.options.style]));break;case"setTextAlign":o(CY),o(nK[l.align]);break;case"setTextBaseline":o(IY),o(oK[l.baseline]);break;case"save":o(MY);break;case"restore":o(RY);break;case"translate":o(OY),o(l.x),o(l.y);break;case"rotate":o(DY),o(l.r);break;case"scale":o(PY),o(l.sx),o(l.sy);break;case"setTransform":o(BY),o(l.t.a),o(l.t.b),o(l.t.c),o(l.t.d),o(l.t.e),o(l.t.f);break;case"resetTransform":o(NY);break;case"beginPath":o(zY);break;case"closePath":o(FY);break;case"moveTo":o(HY),o(l.x),o(l.y);break;case"lineTo":o(UY),o(l.x),o(l.y);break;case"quadraticCurveTo":o(GY),o(l.cx),o(l.cy),o(l.x),o(l.y);break;case"bezierCurveTo":o(WY),o(l.c1x),o(l.c1y),o(l.c2x),o(l.c2y),o(l.x),o(l.y);break;case"rect":o(qY),o(l.x),o(l.y),o(l.w),o(l.h);break;case"ellipse":o(VY),o(l.cx),o(l.cy),o(l.rx),o(l.ry);break;case"fill":o(jY),o(l.rule===void 0?Zg:aK[l.rule]);break;case"stroke":o(ZY);break;case"fillText":o(XY),o(s(l.text)),o(l.x),o(l.y),l.maxWidth===void 0?o(Zg):(o(PL),o(l.maxWidth));break;case"clear":o(YY),l.bounds===void 0?o(Zg):(o(PL),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height));break;case"markDirty":o(KY),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height);break;case"resize":o($Y),o(l.w),o(l.h);break;case"defineImage":i.push({id:l.id,bitmap:l.bitmap});break;case"drawImage":o(QY),o(l.id),o(l.dx),o(l.dy),o(l.dw),o(l.dh);break}return{buffer:t.slice(0,n).buffer,strings:a,bitmaps:i}};var BL=(e,t,n,o={})=>{let a=o.backend??"canvas2d",r=o.maxDpr??2;switch(a){case"canvas2d":return new NL(e,t,n,r);case"webgl2":return new zL(e,t,n,r,{...o.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:o.preserveDrawingBuffer}:{}});case"offscreen":if(!o.workerFactory)throw new Error("createLayeredSurface: workerFactory is required for the offscreen backend");return new FL(e,t,n,o.workerFactory,o.onWorkerError,r)}},HL=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:BL(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:BL(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},NL=class{backend="canvas2d";inner;constructor(t,n,o,a){this.inner=new Mh(t,n,o,{maxDpr:a})}get(t){return this.inner.get(t)}getCanvas(t){return this.inner.getCanvas(t)}resize(t,n){this.inner.resize(t,n)}get size(){return this.inner.size}present(){}dispose(){this.inner.dispose()}},zL=class{backend="webgl2";base;mainCanvas;mainTarget;_width;_height;maxDpr;constructor(t,n,o,a,r={}){this._width=n,this._height=o,this.maxDpr=a,this.base=new Mh(t,n,o,{layers:wi.filter(l=>l!=="main"),maxDpr:a});let s=this.base.getCanvas("overlay"),i=t.ownerDocument.createElement("canvas");i.dataset.layer="main",i.dataset.backend="webgl2",i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none",t.insertBefore(i,s),rr(i,n,o,sr(a),!1);try{this.mainCanvas=i,this.mainTarget=new qg(i,n,o,{...r.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:r.preserveDrawingBuffer}:{}})}catch(l){throw i.remove(),this.base.dispose(),l}}get(t){return t==="main"?this.mainTarget:this.base.get(t)}getCanvas(t){return t==="main"?this.mainCanvas:this.base.getCanvas(t)}resize(t,n){this._width===t&&this._height===n||(this._width=t,this._height=n,this.base.resize(t,n),rr(this.mainCanvas,t,n,sr(this.maxDpr),!1),this.mainTarget.resize(t,n))}get size(){return{width:this._width,height:this._height}}present(){this.mainTarget.flushBatch()}dispose(){this.mainTarget.dispose(),this.mainCanvas.remove(),this.base.dispose()}},FL=class{backend="offscreen";canvases=new Map;targets=new Map;workers=new Map;lastSentSig=new Map;_width;_height;dpr;constructor(t,n,o,a,r,s=2){this._width=n,this._height=o,this.dpr=sr(s),getComputedStyle(t).position==="static"&&(t.style.position="relative");let i=!1,l=c=>{i||(i=!0,r?.(c))};try{for(let c of wi){let u=t.ownerDocument.createElement("canvas");u.dataset.layer=c,u.dataset.backend="offscreen",u.style.position="absolute",u.style.inset="0",u.style.pointerEvents=c==="overlay"?"auto":"none",u.style.width=`${n}px`,u.style.height=`${o}px`,t.appendChild(u);let d=a();d.onerror=p=>{l(p)};let f=u.transferControlToOffscreen();d.postMessage({type:"init",canvas:f,width:n,height:o,dpr:this.dpr},[f]),this.canvases.set(c,u),this.workers.set(c,d),this.targets.set(c,new jg(n,o))}}catch(c){throw this.dispose(),c}}get(t){let n=this.targets.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this._width===t&&this._height===n)){this._width=t,this._height=n;for(let[o,a]of this.canvases)a.style.width=`${t}px`,a.style.height=`${n}px`,this.targets.get(o)?.resize(t,n),this.workers.get(o)?.postMessage({type:"resize",width:t,height:n});this.lastSentSig.clear()}}get size(){return{width:this._width,height:this._height}}present(){for(let[t,n]of this.targets){let o=n.flush();if(o.length===0)continue;let a=n.lastSignature;if(this.lastSentSig.get(t)===a)continue;this.lastSentSig.set(t,a);let{buffer:r,strings:s,bitmaps:i}=b6(o),l={type:"replay",buffer:r,strings:s,bitmaps:i};this.workers.get(t)?.postMessage(l,[r])}}dispose(){for(let t of this.workers.values())t.terminate();for(let t of this.canvases.values())t.remove();this.workers.clear(),this.canvases.clear(),this.targets.clear()}};var UL=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},GL=()=>{if(typeof document>"u")return!1;try{let t=document.createElement("canvas").getContext("webgl2");return t?(t.getExtension?.("WEBGL_lose_context")?.loseContext(),!0):!1}catch{return!1}};var A6=(0,Le.createContext)(null),WL=({initialScene:e,initialTool:t,children:n,onReady:o,skipInstallRenderers:a,renderer:r="canvas2d",workerFactory:s,textShaper:i,rasterizer:l,readOnly:c=!1})=>{let[u,d]=(0,Le.useState)(null),f=(0,Le.useRef)(null),p=(0,Le.useRef)(null),h=(0,Le.useRef)(null),m=(0,Le.useRef)(null),x=(0,Le.useRef)(null),y=(0,Le.useRef)(!1),g=(0,Le.useRef)(()=>{}),b=(0,Le.useRef)(r),A=(0,Le.useRef)(s),_=(0,Le.useRef)(i),C=(0,Le.useRef)(l),w=(0,Le.useRef)(c);b.current=r,A.current=s,_.current=i,C.current=l,w.current=c;let L=(0,Le.useCallback)(G=>{a||Fc();let{width:ie,height:ne}=G.getBoundingClientRect(),{surface:V,effectiveBackend:ve}=HL(G,ie,ne,{backend:y.current?"canvas2d":b.current,...A.current?{workerFactory:A.current}:{},onWorkerError:Oe=>{g.current(Oe)}},(Oe,qt)=>{console.warn(`[DiagramRoot] ${Oe} renderer unavailable, falling back to canvas2d:`,qt)});G.dataset.effectiveBackend=ve;let ge={host:G,mainTarget:V.get("main"),overlayTarget:V.get("overlay"),backgroundTarget:V.get("background"),onAfterRender:()=>p.current?.present(),initialScene:e,...t!==void 0?{initialTool:t}:{},..._.current?{textShaper:_.current}:{},...C.current?{rasterizer:C.current}:{}},ee=new Kp(ge);ee.setViewportSize(ie,ne),ee.setReadOnly(w.current),p.current=V,f.current=ee,d(ee),o?.(ee),V.present();let Se=new ResizeObserver(()=>{let Oe=G.getBoundingClientRect();V.resize(Oe.width,Oe.height),ee.setViewportSize(Oe.width,Oe.height),ee.forceRender()});Se.observe(G),h.current=Se},[]),k=(0,Le.useCallback)(()=>{h.current?.disconnect(),h.current=null,x.current?.(),x.current=null,f.current?.dispose(),f.current=null,p.current?.dispose(),p.current=null},[]);g.current=G=>{if(y.current)return;y.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",G);let ie=m.current;ie&&(k(),L(ie))};let M=(0,Le.useCallback)(G=>{if(k(),m.current=G,!G){d(null);return}L(G)},[L,k]),B=(0,Le.useRef)(null);return(0,Le.useEffect)(()=>{let G=m.current;if(G){if(B.current===null){B.current=r;return}B.current!==r&&(B.current=r,y.current=!1,k(),L(G))}},[r,L,k]),(0,Le.useEffect)(()=>{u?.setReadOnly(c)},[u,c]),(0,Le.useLayoutEffect)(()=>()=>{k(),m.current=null},[k]),(0,gs.jsx)(NE.Provider,{value:u,children:(0,gs.jsx)(A6.Provider,{value:M,children:(0,gs.jsxs)(E8,{children:[n,(0,gs.jsx)(cK,{editor:u})]})})})},cK=({editor:e})=>{let[t,n]=(0,Le.useState)("");return(0,Le.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,gs.jsx)("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:t})},qL=({style:e,className:t,ariaLabel:n})=>{let o=(0,Le.useContext)(A6),a=(0,Le.useRef)(null);if((0,Le.useLayoutEffect)(()=>{if(o)return o(a.current),()=>{o(null)}},[o]),!o)throw new Error("@oh-just-another/react-ui: <DiagramSurface> rendered outside <DiagramRoot>.");return(0,gs.jsx)("div",{ref:a,className:t?`du-canvas-surface ${t}`:"du-canvas-surface",role:"application",tabIndex:0,"aria-label":n??"Diagram canvas",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:"none",userSelect:"none",...e}})};var v6=P(se(),1),gn=P(re(),1);var uK=e=>{let t=null;for(let n of e.elements.values()){if(n.hidden===!0)continue;let o=N(n);t=t?j.union(t,o):o}return t},dK=(e,t,n)=>{let o=t-$b*2,a=n-$b*2;if(o<=0||a<=0||e.width<=0||e.height<=0)return null;let r=Math.min(o/e.width,a/e.height),s=e.x+e.width/2,i=e.y+e.height/2;return{zoom:r,pan:{x:s-t/2/r,y:i-n/2/r}}},VL=({width:e=WE,height:t=qE,className:n,style:o,editor:a})=>{let r=U(),s=a??r,i=(0,gn.useRef)(null),l=(0,gn.useRef)(null),c=(0,gn.useRef)(!1),u=(0,gn.useCallback)(()=>{let y=i.current;if(!y||!s)return;let g=s.scene,b=rr(y,e,t),A=y.getContext("2d");if(!A)return;let _=new ar(A,e,t,b);_.clear();let C=uK(g),w=C?dK(C,e,t):null;if(l.current=w,!w)return;let L={...g,viewport:{...g.viewport,pan:w.pan,zoom:w.zoom,rotation:0,size:{width:e,height:t}}};Xa(L,_),Bn(L,_);let k=g.viewport;if(k.zoom>0&&k.size.width>0&&k.size.height>0){let M=(k.pan.x-w.pan.x)*w.zoom,B=(k.pan.y-w.pan.y)*w.zoom,G=k.size.width/k.zoom*w.zoom,ie=k.size.height/k.zoom*w.zoom;A.setTransform(b,0,0,b,0,0),A.fillStyle=ZE,A.fillRect(M,B,G,ie),A.strokeStyle=VE,A.lineWidth=jE,A.strokeRect(M,B,G,ie)}},[s,e,t]);(0,gn.useEffect)(()=>{if(!s)return;u();let y=Date.now(),g=null,b=()=>{let _=Date.now()-y;_>=Qb?(y=Date.now(),u()):g??=setTimeout(()=>{g=null,y=Date.now(),u()},Qb-_)},A=s.subscribe(b);return()=>{A(),g!==null&&clearTimeout(g)}},[s,u]);let d=(0,gn.useCallback)((y,g)=>{let b=l.current;if(!s||!b)return;let A={x:y/b.zoom+b.pan.x,y:g/b.zoom+b.pan.y},_=s.scene.viewport,C=_.pan.x+_.size.width/2/_.zoom,w=_.pan.y+_.size.height/2/_.zoom;s.panBy({x:(C-A.x)*_.zoom,y:(w-A.y)*_.zoom})},[s]),f=(0,gn.useCallback)((y,g,b)=>{let A=l.current;if(!s||!A||b===0)return;let _={x:y/A.zoom+A.pan.x,y:g/A.zoom+A.pan.y},w=1-(Math.abs(b)>Jb?Jb*Math.sign(b):b)*XE/100;if(w<=0)return;let L=s.scene.viewport,k=L.pan.x+L.size.width/2/L.zoom,M=L.pan.y+L.size.height/2/L.zoom;s.panBy({x:(k-_.x)*L.zoom,y:(M-_.y)*L.zoom}),s.zoomAt(w,_)},[s]);(0,gn.useEffect)(()=>{let y=i.current;if(!y)return;let g=b=>{b.preventDefault();let A=y.getBoundingClientRect();f(b.clientX-A.left,b.clientY-A.top,b.deltaY)};return y.addEventListener("wheel",g,{passive:!1}),()=>{y.removeEventListener("wheel",g)}},[f]);let p=y=>{let g=y.currentTarget.getBoundingClientRect();return{x:y.clientX-g.left,y:y.clientY-g.top}},h=(0,gn.useCallback)(y=>{c.current=!0,y.currentTarget.setPointerCapture(y.pointerId);let g=p(y);d(g.x,g.y)},[d]),m=(0,gn.useCallback)(y=>{if(!c.current)return;let g=p(y);d(g.x,g.y)},[d]),x=(0,gn.useCallback)(y=>{c.current=!1,y.currentTarget.releasePointerCapture(y.pointerId)},[]);return(0,v6.jsx)("canvas",{ref:i,className:n,"aria-label":"Diagram minimap",onPointerDown:h,onPointerMove:m,onPointerUp:x,style:{display:"block",width:e,height:t,cursor:"pointer",touchAction:"none",...o}})};var Ft=P(se(),1),E1e=P(re(),1);var jL=({style:e})=>{let t=U(),n=eh().type,o=tL();if(!t||n!=="brush"&&n!=="erase")return null;let a=n==="erase";return(0,Ft.jsxs)("div",{className:"du-drawing-panel",style:{...fK,...e},children:[(0,Ft.jsx)("div",{style:pK,children:a?"Eraser":"Drawing"}),!a&&(0,Ft.jsxs)(Ft.Fragment,{children:[(0,Ft.jsx)(Xg,{label:"Stroke",children:(0,Ft.jsx)(su,{value:o.stroke,onChange:r=>{t.setBrushSettings({stroke:r??o.stroke})},onEyedrop:r=>{t.beginEyedropperPick(r)},allowClear:!1})}),(0,Ft.jsx)(Xg,{label:"Fill",children:(0,Ft.jsx)(su,{value:o.fill,onChange:r=>{t.setBrushSettings({fill:r})},onEyedrop:r=>{t.beginEyedropperPick(r)}})}),(0,Ft.jsx)(Xg,{label:`Opacity ${Math.round(o.opacity*100)}%`,children:(0,Ft.jsx)("input",{type:"range",min:0,max:1,step:.05,value:o.opacity,onChange:r=>{t.setBrushSettings({opacity:r.currentTarget.valueAsNumber})},style:S6,"aria-label":"Brush opacity"})})]}),(0,Ft.jsx)(Xg,{label:`${a?"Radius":"Width"} ${o.width}`,children:(0,Ft.jsx)("input",{type:"range",min:Cf,max:E0,step:1,value:o.width,onChange:r=>{t.setBrushSettings({width:r.currentTarget.valueAsNumber})},style:S6,"aria-label":a?"Eraser radius":"Brush width"})})]})},Xg=({label:e,children:t})=>(0,Ft.jsxs)("label",{style:hK,children:[(0,Ft.jsx)("span",{style:mK,children:e}),t]}),fK={width:YE,display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid var(--du-border, #d0d0d0)",borderRadius:8,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",font:"12px/1.4 system-ui, sans-serif",color:"var(--du-text, #222)"},pK={fontWeight:600,opacity:.7},hK={display:"flex",flexDirection:"column",gap:4},mK={opacity:.7},S6={width:"100%"};var pu=2,Ht=T.object({x:T.number(),y:T.number()}),D1e=T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}),yK=T.object({type:T.enum(["sharp","round"]),value:T.number().optional()}).strict(),Po=T.object({fill:T.string().optional(),stroke:T.string().optional(),strokeWidth:T.number().optional(),opacity:T.number().optional(),dashArray:T.array(T.number()).readonly().optional(),lineCap:T.enum(["butt","round","square"]).optional(),lineJoin:T.enum(["miter","round","bevel"]).optional(),strokeAlign:T.enum(["center","inside","outside"]).optional(),roundness:yK.optional()}).strict(),_6=Po.extend({textAlign:T.enum(["left","center","right"]).optional(),textBaseline:T.enum(["top","middle","bottom"]).optional(),fontWeight:T.enum(["normal","bold"]).optional(),fontStyle:T.enum(["normal","italic"]).optional(),textDecoration:T.object({underline:T.boolean().optional(),strikethrough:T.boolean().optional()}).strict().optional()}).strict(),w6=T.record(T.string(),T.unknown()).optional(),gK=T.string(),T6=T.discriminatedUnion("kind",[T.object({kind:T.literal("named"),name:gK}).strict(),T.object({kind:T.literal("ratio"),position:Ht}).strict(),T.object({kind:T.literal("absolute"),offset:Ht}).strict(),T.object({kind:T.literal("edge"),index:T.number().int().nonnegative(),t:T.number()}).strict()]),pa=T.object({id:T.string(),layerId:T.string(),position:Ht,rotation:T.number(),scale:Ht,order:T.string(),metadata:w6,minWidth:T.number().optional(),minHeight:T.number().optional(),maxWidth:T.number().optional(),maxHeight:T.number().optional(),noFlip:T.boolean().optional(),anchors:T.record(T.string(),T6).optional(),parentId:T.string().optional(),frameId:T.string().optional(),href:T.string().optional()}),xK=pa.extend({type:T.literal("rectangle"),style:Po,width:T.number(),height:T.number()}).strict(),bK=pa.extend({type:T.literal("ellipse"),style:Po,width:T.number(),height:T.number()}).strict(),AK=pa.extend({type:T.literal("polygon"),style:Po,points:T.array(Ht)}).strict(),vK=T.discriminatedUnion("kind",[T.object({kind:T.literal("M"),to:Ht}).strict(),T.object({kind:T.literal("L"),to:Ht}).strict(),T.object({kind:T.literal("Q"),control:Ht,to:Ht}).strict(),T.object({kind:T.literal("C"),control1:Ht,control2:Ht,to:Ht}).strict(),T.object({kind:T.literal("Z")}).strict()]),SK=pa.extend({type:T.literal("path"),style:Po,commands:T.array(vK)}).strict(),LK=T.object({text:T.string(),style:_6.optional()}).strict(),kK=pa.extend({type:T.literal("text"),style:_6,text:T.string(),fontFamily:T.string(),fontSize:T.number(),maxWidth:T.number().optional(),runs:T.array(LK).optional()}).strict(),_K=pa.extend({type:T.literal("image"),style:Po,src:T.string(),width:T.number(),height:T.number(),fileId:T.string().optional(),crop:T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}).optional(),animationKind:T.string().optional(),animationData:T.unknown().optional()}).strict(),wK=pa.extend({type:T.literal("template"),style:Po.optional(),templateId:T.string(),data:T.record(T.string(),T.unknown()),width:T.number(),height:T.number()}).strict(),TK=pa.extend({type:T.literal("group"),style:Po.optional()}).strict(),EK=T.object({x:T.number(),y:T.number(),width:T.number()}).strict(),CK=pa.extend({type:T.literal("brush"),style:Po,points:T.array(EK),closed:T.boolean().optional(),pressures:T.array(T.number()).optional(),simulatePressure:T.boolean().optional(),baseWidth:T.number().optional()}).strict(),IK=pa.extend({type:T.string(),style:Po.optional()}).passthrough().refine(e=>!["rectangle","ellipse","polygon","path","text","image","template","group","brush"].includes(e.type),{message:"Use the specific built-in schema for built-in shape types"}),MK=T.union([xK,bK,AK,SK,kK,_K,wK,TK,CK,IK]),L6=T.discriminatedUnion("kind",[T.object({kind:T.literal("point"),position:Ht}).strict(),T.object({kind:T.literal("anchor"),elementId:T.string(),anchor:T6}).strict(),T.object({kind:T.literal("outline"),elementId:T.string(),ratio:T.number()}).strict(),T.object({kind:T.literal("floating"),elementId:T.string()}).strict()]),RK=T.enum(["straight","orthogonal","bezier"]),k6=T.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),OK=T.object({from:k6.optional(),to:k6.optional(),size:T.number().optional()}).strict(),DK=T.object({text:T.string(),position:T.number().optional(),fontSize:T.number().optional(),fill:T.string().optional(),background:T.string().optional()}).strict(),PK=T.object({id:T.string(),layerId:T.string(),from:L6,to:L6,waypoints:T.array(Ht).readonly().optional(),routedPoints:T.array(Ht).readonly().optional(),fixedSegments:T.array(T.object({axis:T.enum(["h","v"]),pos:T.number(),at:T.number()}).strict()).readonly().optional(),routing:RK.optional(),avoidObstacles:T.boolean().optional(),arrowheads:OK.optional(),label:DK.optional(),order:T.string(),style:Po,metadata:w6}).strict(),BK=T.object({id:T.string(),name:T.string(),visible:T.boolean(),locked:T.boolean(),order:T.string()}).strict(),NK=T.object({pan:Ht,zoom:T.number(),rotation:T.number(),size:T.object({width:T.number(),height:T.number()}).strict(),gridEnabled:T.boolean(),gridStyle:T.enum(["lines","dots"]).optional(),snapToGrid:T.boolean().optional()}).strict(),zK=T.object({id:T.string(),authorId:T.string(),authorName:T.string(),body:T.string(),createdAt:T.string()}).strict(),FK=T.object({id:T.string(),elementId:T.string().nullable(),position:Ht,resolved:T.boolean(),thread:T.array(zK),createdAt:T.string()}).strict(),E6=T.object({format:T.literal("oh-just-another/scene"),version:T.number().int().nonnegative(),elements:T.array(MK),links:T.array(PK),layers:T.array(BK),annotations:T.array(FK).optional(),viewport:NK}).strict();var C6=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:pu,elements:[...e.elements.values()].map(HK),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},HK=e=>{let t=e.metadata,n=t&&"image"in t,o=e.animationData!==void 0;if(!n&&!o)return e;let a={...e};if(n){let{image:r,...s}=t;Object.keys(s).length>0?a.metadata=s:delete a.metadata}return o&&delete a.animationData,a},ZL=(e,t=null)=>JSON.stringify(C6(e),null,t??void 0);var I6=new Map,M6=(e,t)=>{I6.set(e,t)},R6=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=I6.get(a);if(!r)throw new XL(a,n);o=r(o)}return o},XL=class extends Error{fromVersion;toVersion;constructor(t,n){super(`No migration registered from v${t} \u2192 v${t+1} (target v${n})`),this.name="MissingMigrationError",this.fromVersion=t,this.toVersion=n}};var UK=e=>{let t=e,n={...t.viewport??{}},o=n.gridSize;return delete n.gridSize,n.gridEnabled=typeof o=="number"&&o>0,{...t,version:2,viewport:n}};M6(1,UK);var hu=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},O6=(e,t={})=>{if(typeof e!="object"||e===null)throw new hu("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??pu;if(o>a)throw new hu(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===pu?e:R6(e,o,pu),s;try{s=E6.parse(r)}catch(i){throw i instanceof T.ZodError?new hu(`Invalid scene document: ${i.message}`,i):i}return GK(s)},YL=(e,t)=>O6(JSON.parse(e),t),GK=e=>{let t=new Map;for(let s of e.elements){let i=Ze(s.id);t.set(i,WK(s,i))}let n=new Map;for(let s of e.links){let i=dA(s.id);n.set(i,qK(s,i))}let o=new Map;for(let s of e.layers){let i=ln(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Df(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Of(s.id);r.set(i,{id:i,elementId:s.elementId===null?null:Ze(s.elementId),position:s.position,resolved:s.resolved,thread:s.thread.map(l=>({id:rc(l.id),authorId:l.authorId,authorName:l.authorName,body:l.body,createdAt:l.createdAt})),createdAt:s.createdAt})}return{elements:t,links:n,layers:o,annotations:r,files:new Map,viewport:a}},WK=(e,t)=>({...Df(e),id:t,layerId:ln(e.layerId),order:e.order}),qK=(e,t)=>{let n=s=>s.kind==="anchor"||s.kind==="outline"||s.kind==="floating"?{...s,elementId:Ze(s.elementId)}:s,o=n(e.from),a=n(e.to);return{...Df(e),id:t,layerId:ln(e.layerId),order:e.order,from:o,to:a}};var mu=P(se(),1),ir=P(re(),1);var VK=[0,50,90],KL=({children:e,snapPoints:t=VK,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,ir.useState)(()=>o??t.find(x=>x>0)??50),c=n??i,u=(0,ir.useCallback)(x=>{l(x),a?.(x)},[a]),d=(0,ir.useRef)(null),f=(0,ir.useRef)(null),p=x=>{d.current={startY:x.clientY,startHeight:c,pointerId:x.pointerId},x.target.setPointerCapture?.(x.pointerId)},h=x=>{if(d.current?.pointerId!==x.pointerId)return;let y=window.innerHeight||1,g=(d.current.startY-x.clientY)/y*100,b=sc.clamp(d.current.startHeight+g,0,100);u(b)},m=x=>{if(d.current?.pointerId!==x.pointerId)return;d.current=null;let y=t[0];if(y===void 0)return;let g=Math.abs(c-y);for(let b of t){let A=Math.abs(c-b);A<g&&(y=b,g=A)}u(y)};return(0,ir.useEffect)(()=>{let x=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[u,t]),(0,mu.jsxs)("div",{ref:f,role:"dialog","aria-label":"Bottom sheet",className:r,style:{position:"fixed",left:0,right:0,bottom:0,height:`${c}vh`,background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",borderTop:"1px solid var(--border, #2a2a2a)",borderTopLeftRadius:12,borderTopRightRadius:12,boxShadow:"0 -4px 18px rgba(0,0,0,0.4)",display:"flex",flexDirection:"column",overflow:"hidden",transition:d.current?"none":"height 180ms ease",zIndex:100,...s},children:[(0,mu.jsx)("div",{role:"separator","aria-orientation":"horizontal",onPointerDown:p,onPointerMove:h,onPointerUp:m,onPointerCancel:m,style:{touchAction:"none",padding:"8px 0",display:"flex",justifyContent:"center",cursor:"grab"},children:(0,mu.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,mu.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var D6=P(se(),1),lr=P(re(),1);var $L=()=>{let e=U(),t=(0,lr.useRef)(null),[,n]=(0,lr.useReducer)(c=>c+1,0);(0,lr.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,lr.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,lr.useLayoutEffect)(()=>{let c=t.current;if(!e||!o||!c)return;let u=I(e.scene,o),d=u?.type==="text"?u.text:"";c.value!==d&&(c.value=d);let f=e.editingTextSelection;f&&(c.selectionStart!==f.start||c.selectionEnd!==f.end)&&c.setSelectionRange(f.start,f.end,f.dir)}),!e||!o)return null;let a=I(e.scene,o);if(a?.type!=="text")return null;let r=e.scene.viewport,s=(a.position.x-r.pan.x)*r.zoom,i=(a.position.y-r.pan.y)*r.zoom,l=c=>c.selectionDirection==="backward"?"backward":"forward";return(0,D6.jsx)("textarea",{ref:t,defaultValue:a.text,onInput:c=>{let u=c.currentTarget;e.setEditingText(u.value,u.selectionStart,u.selectionEnd,l(u))},onSelect:c=>{let u=c.currentTarget;e.setEditingSelection(u.selectionStart,u.selectionEnd,l(u))},onKeyDown:c=>{(c.key==="Escape"||c.key==="Enter"&&(c.metaKey||c.ctrlKey))&&(c.preventDefault(),c.stopPropagation(),e.commitTextEdit())},onBlur:()=>{let c=o;setTimeout(()=>{let u=t.current;u&&e.editingTextElement===c&&document.activeElement!==u&&u.focus()},0)},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":"Text editor",style:{position:"absolute",top:i,left:s,width:1,height:1,padding:0,margin:0,border:0,outline:"none",opacity:0,resize:"none",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none",zIndex:100}})};var P6=P(se(),1),sl=P(re(),1);var QL=()=>{let e=U(),t=(0,sl.useRef)(null),[,n]=(0,sl.useReducer)(d=>d+1,0);(0,sl.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,sl.useEffect)(()=>{if(!o)return;let d=t.current;d&&(d.focus(),d.select())},[o]),!e||!o)return null;let a=I(e.scene,o);if(!a||!Be(a))return null;let r=e.scene.viewport,s=r.zoom,i=(a.position.x-r.pan.x)*s,l=(a.position.y-24*a.scale.y-r.pan.y)*s,c=a.width*a.scale.x*s,u=24*a.scale.y*s;return(0,P6.jsx)("input",{ref:t,type:"text",defaultValue:a.name??"",placeholder:"Frame","aria-label":"Frame name",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onKeyDown:d=>{d.key==="Enter"?(d.preventDefault(),d.stopPropagation(),e.commitFrameNameEdit(d.currentTarget.value)):d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),e.cancelFrameNameEdit()):d.stopPropagation()},onBlur:d=>{e.commitFrameNameEdit(d.currentTarget.value)},style:{position:"absolute",left:i,top:l,width:c,height:u,boxSizing:"border-box",padding:`0 ${8*s}px`,margin:0,border:0,outline:"none",background:"#222",color:"#ddd",font:`${12*s}px system-ui, sans-serif`,lineHeight:`${u}px`,pointerEvents:"auto",zIndex:100}},o)};var yu=P(se(),1),bs=P(re(),1),z6=P(ya(),1);var xs=P(re(),1),B6=e=>{let t=(0,xs.useRef)(null),n=(0,xs.useRef)(e);n.current=e;let o=(0,xs.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,xs.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,xs.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var N6=220,JL=()=>{let e=U(),[t,n]=(0,bs.useState)(null),[,o]=(0,bs.useReducer)(m=>m+1,0),a=(0,bs.useRef)(!1),r=Pt(),{schedule:s,cancel:i}=B6(()=>{a.current||n(null)});if((0,bs.useEffect)(()=>{if(!e)return;let m=e.hostElement;if(!m)return;let x=b=>{if(e.editingTextElement!==null){n(null);return}let A=m.getBoundingClientRect(),_=e.screenToWorld({x:b.clientX-A.left,y:b.clientY-A.top}),C=e.linkAt(_);C?(i(),n({href:C.href,bounds:C.bounds})):a.current||s(N6)},y=()=>{s(N6)};m.addEventListener("pointermove",x),m.addEventListener("pointerleave",y);let g=e.on("change",()=>{o()});return()=>{m.removeEventListener("pointermove",x),m.removeEventListener("pointerleave",y),g(),i()}},[e,s,i]),!e||!t)return null;let l=e.hostElement;if(!l)return null;let c=e.scene.viewport,u=l.getBoundingClientRect(),d=(t.bounds.x-c.pan.x)*c.zoom+u.left,f=(t.bounds.y-c.pan.y)*c.zoom+u.top,p=t.bounds.width*c.zoom,h=t.href.replace(/^mailto:/,"").replace(/^https?:\/\//,"");return(0,z6.createPortal)((0,yu.jsx)("div",{className:"du-link-popup",style:{position:"fixed",left:d+p/2,top:f,transform:"translate(-50%, -100%)"},onPointerEnter:()=>{a.current=!0},onPointerLeave:()=>{a.current=!1,n(null)},children:(0,yu.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,yu.jsx)("span",{className:"du-link-popup-text",children:h}),(0,yu.jsx)(Gd,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var As=P(se(),1),Yg=P(re(),1),F6=P(ya(),1);var e3=()=>{let e=U(),[,t]=(0,Yg.useReducer)(u=>u+1,0),n=Pt();if((0,Yg.useEffect)(()=>{if(!e)return;let u=e.on("change",()=>{t()}),d=f=>{f.key==="Escape"&&e.linkDropMenu&&e.dismissLinkDropMenu()};return window.addEventListener("keydown",d),()=>{u(),window.removeEventListener("keydown",d)}},[e]),!e)return null;let o=e.linkDropMenu;if(!o)return null;let a=e.hostElement;if(!a)return null;let r=e.scene.viewport,s=a.getBoundingClientRect(),i=(o.world.x-r.pan.x)*r.zoom+s.left,l=(o.world.y-r.pan.y)*r.zoom+s.top,c=Di.byCategory("basic");return(0,F6.createPortal)((0,As.jsxs)(As.Fragment,{children:[(0,As.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,As.jsx)("div",{className:"du-link-drop-menu",role:"menu","aria-label":"Create shape",style:{position:"fixed",left:i,top:l,transform:"translate(-50%, -100%)",zIndex:1601},onPointerDown:u=>{u.stopPropagation()},children:c.map(u=>(0,As.jsx)("button",{type:"button",className:"du-link-drop-item",title:u.name,"aria-label":`Create ${u.name}`,onClick:()=>{e.placeShapeAtLinkDrop(d=>u.factory(d))},dangerouslySetInnerHTML:{__html:u.icon}},u.id))})]}),n)};var H6=P(se(),1),cr=P(re(),1),U6=P(ya(),1);var t3=()=>{let e=U(),[,t]=(0,cr.useReducer)(m=>m+1,0),[n,o]=(0,cr.useState)(""),a=(0,cr.useRef)(null),r=Pt();(0,cr.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,cr.useEffect)(()=>{if(!e||s===null)return;let m=e.scene.links.get(s);o(m?.label?.text??"");let x=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(x)}},[e,s]),!e||s===null)return null;let i=e.hostElement;if(!i)return null;let l=e.linkLabelWorld(s);if(!l)return null;let c=e.scene.viewport,u=i.getBoundingClientRect(),d=(l.x-c.pan.x)*c.zoom+u.left,f=(l.y-c.pan.y)*c.zoom+u.top,p=()=>{e.commitLinkCaptionEdit(n)},h=Math.min(5,n.split(`
168
+ `).length);return(0,U6.createPortal)((0,H6.jsx)("textarea",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",rows:h,style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:m=>{o(m.target.value)},onBlur:p,onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),e.cancelLinkCaptionEdit()),m.stopPropagation()}}),r)};var At=P(se(),1),Kg=P(re(),1);var jK=16,ZK=1.75,n3={size:jK,strokeWidth:ZK},XK={"mode-select":sf,"mode-hand":Kd,"mode-rect":qo,"mode-ellipse":Ks,"mode-text":vf,"mode-edge":gf,"mode-brush":qr,"mode-erase":Ud,"mode-laser":pf,"mode-frame":Zd,"insert-image":Qs,"tool-lock":tf,undo:ti,redo:ei},YK=({id:e})=>{let t=U(),[,n]=(0,Kg.useState)(0);(0,Kg.useEffect)(()=>{if(t)return t.on("change",()=>{n(f=>f+1)})},[t]);let o=we.get(e);if(!o)return null;let a=o.iconId?XK[o.iconId]:void 0,r=t?{editor:t}:null,s=r?o.checked?.(r)??!1:!1,i=!!t?.readOnly&&o.viewMode!==!0,l=r&&!i?o.predicate?o.predicate(r):!0:!1,u=(o.hotkey===void 0?[]:Array.isArray(o.hotkey)?o.hotkey:[o.hotkey])[0],d=`${o.label??e}${u?` (${dt(u)})`:""}`;return(0,At.jsx)(gu,{title:d,active:s,disabled:!l,onClick:()=>{t&&we.dispatch(e,{editor:t})},children:a?(0,At.jsx)(a,{...n3}):o.label??e})},Sbe=dt({meta:!0,key:"\u2212"}),Lbe=dt({meta:!0,key:"+"}),kbe=dt({meta:!0,key:"0"}),_be=dt({meta:!0,key:"1"}),o3=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="image/*",t.multiple=!0,t.addEventListener("change",()=>{let n=t.files;if(!n||n.length===0)return;let o=e.scene.viewport,a=e.screenToWorld({x:o.size.width/2,y:o.size.height/2});for(let r of Array.from(n))e.dispatchFileDrop(r,a)}),t.click()},G6=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,At.jsx)(Qs,{...n3}),title:"Insert image (I)",onClick:e=>{o3(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],$g=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"divider"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,At.jsx)(Qs,{...n3}),title:"Insert image (I)",onClick:e=>{o3(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],a3=({items:e=G6,style:t,className:n,orientation:o="horizontal"})=>{let a=U(),r=eh(),s=ls(),{canUndo:i,canRedo:l,undo:c,redo:u}=nL(),d=o==="vertical";return(0,At.jsx)("div",{role:"toolbar","aria-orientation":o,className:`du-button-group${d?" du-button-group-vertical":""} ${n??""}`.trim(),style:t,children:e.map((f,p)=>{switch(f.kind){case"divider":return(0,At.jsx)($K,{vertical:d},p);case"action-ref":return(0,At.jsx)(YK,{id:f.id},p);case"mode":{let h=r.type===f.mode,m=f.mode==="select"||f.mode==="hand";return(0,At.jsx)(gu,{...f.title!==void 0?{title:f.title}:{},disabled:!a||s&&!m,active:h,onClick:()=>a?.setActiveTool(f.mode),children:f.label},p)}case"action":return(0,At.jsx)(gu,{...f.title!==void 0?{title:f.title}:{},disabled:f.disabled??(!a||s),active:f.active,onClick:()=>{a&&f.onClick(a)},children:f.label},p);case"undo":return(0,At.jsx)(gu,{disabled:!i||s,onClick:c,children:f.label??"Undo"},p);case"redo":return(0,At.jsx)(gu,{disabled:!l||s,onClick:u,children:f.label??"Redo"},p);case"tool-lock":return(0,At.jsx)(KK,{...f.label!==void 0?{label:f.label}:{},...f.title!==void 0?{title:f.title}:{}},p)}})})},KK=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=U(),o=sn(r=>r.activeTool.locked,!1),a=ls();return(0,At.jsx)(gu,{disabled:!n||a,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var gu=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,At.jsx)("button",{type:"button",onClick:t,disabled:o,"aria-label":a,"aria-pressed":n,className:`du-icon-button${n?" is-active":""}${r?` ${r}`:""}`,style:{width:"auto",minWidth:"var(--du-button-size, 36px)",padding:"0 8px",...s},children:e});return a?(0,At.jsx)(ni,{content:a,children:i}):i},$K=({vertical:e=!1})=>e?(0,At.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,At.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var r3=.5522847498307936,W6=.55;var QK={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},q6=(e,t,n)=>{let o=0;for(let a of e)o+=(QK[a]??W6)*n;return o};var Qg=class{size;measure;fillColor=null;strokeColor=null;strokeWidth=1;opacity=1;lineCap="butt";lineJoin="miter";dashArray=null;fontFamily="system-ui, sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";currentTransform=z.IDENTITY;pathSegments=[];pathCursor=null;elements=[];clipIdCounter=0;stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??q6}toSvg(){let t=this.size.width,n=this.size.height;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">`+this.elements.join("")+"</svg>"}setFill(t){this.fillColor=t}setStroke(t){this.strokeColor=t}setStrokeWidth(t){this.strokeWidth=t}setOpacity(t){this.opacity=t}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}save(){this.stack.push({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,opacity:this.opacity,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline,transform:this.currentTransform})}restore(){let t=this.stack.pop();t&&(this.fillColor=t.fillColor,this.strokeColor=t.strokeColor,this.strokeWidth=t.strokeWidth,this.opacity=t.opacity,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline,this.currentTransform=t.transform)}translate(t,n){this.currentTransform=z.multiply(this.currentTransform,z.translation(t,n))}rotate(t){this.currentTransform=z.multiply(this.currentTransform,z.rotation(t))}scale(t,n){this.currentTransform=z.multiply(this.currentTransform,z.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=z.IDENTITY}beginPath(){this.pathSegments=[],this.pathCursor=null}closePath(){this.pathSegments.push("Z")}moveTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`M${He(o.x)} ${He(o.y)}`),this.pathCursor=o}lineTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`L${He(o.x)} ${He(o.y)}`),this.pathCursor=o}quadraticCurveTo(t,n,o,a){let r=this.apply(t,n),s=this.apply(o,a);this.pathSegments.push(`Q${He(r.x)} ${He(r.y)} ${He(s.x)} ${He(s.y)}`),this.pathCursor=s}bezierCurveTo(t,n,o,a,r,s){let i=this.apply(t,n),l=this.apply(o,a),c=this.apply(r,s);this.pathSegments.push(`C${He(i.x)} ${He(i.y)} ${He(l.x)} ${He(l.y)} ${He(c.x)} ${He(c.y)}`),this.pathCursor=c}rect(t,n,o,a){this.moveTo(t,n),this.lineTo(t+o,n),this.lineTo(t+o,n+a),this.lineTo(t,n+a),this.closePath()}ellipse(t,n,o,a){let r=o*r3,s=a*r3;this.moveTo(t+o,n),this.bezierCurveTo(t+o,n+s,t+r,n+a,t,n+a),this.bezierCurveTo(t-r,n+a,t-o,n+s,t-o,n),this.bezierCurveTo(t-o,n-s,t-r,n-a,t,n-a),this.bezierCurveTo(t+r,n-a,t+o,n-s,t+o,n),this.closePath()}fill(t="nonzero"){if(this.pathSegments.length===0)return;let o=[`d="${this.pathSegments.join(" ")}"`,`fill="${this.fillColor??"none"}"`,t==="evenodd"?'fill-rule="evenodd"':"",this.opacity!==1?`fill-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}stroke(){if(this.pathSegments.length===0||this.strokeColor===null||this.strokeWidth<=0)return;let t=this.pathSegments.join(" "),n=this.dashArray&&this.dashArray.length>0?`stroke-dasharray="${this.dashArray.join(" ")}"`:"",o=[`d="${t}"`,'fill="none"',`stroke="${this.strokeColor}"`,`stroke-width="${this.strokeWidth}"`,this.lineCap!=="butt"?`stroke-linecap="${this.lineCap}"`:"",this.lineJoin!=="miter"?`stroke-linejoin="${this.lineJoin}"`:"",n,this.opacity!==1?`stroke-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}fillText(t,n,o,a){if(!t)return;let r=this.apply(n,o),s=this.textAlign==="center"?"middle":this.textAlign==="right"?"end":"start",i=this.textBaseline==="middle"?"central":this.textBaseline==="bottom"?"alphabetic":"hanging",l=[`x="${He(r.x)}"`,`y="${He(r.y)}"`,`font-family="${s3(this.fontFamily)}"`,`font-size="${this.fontSize}"`,this.fontWeight==="bold"?'font-weight="bold"':"",this.fontStyle==="italic"?'font-style="italic"':"",`fill="${this.fillColor??"#000"}"`,`text-anchor="${s}"`,`dominant-baseline="${i}"`,this.opacity!==1?`fill-opacity="${this.opacity}"`:"",a!==void 0?`textLength="${a}" lengthAdjust="spacingAndGlyphs"`:""].filter(Boolean).join(" ");this.elements.push(`<text ${l}>${e$(t)}</text>`)}measureText(t){return{width:this.measure(t,this.fontFamily,this.fontSize)}}drawImage(t,n,o,a,r,s,i){if(typeof t!="string"||t==="")return;let l=this.apply(n,o);if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){this.drawCroppedImage(t,l.x,l.y,a,r,i);return}this.elements.push(`<image x="${He(l.x)}" y="${He(l.y)}" width="${a}" height="${r}" href="${s3(t)}"/>`)}drawCroppedImage(t,n,o,a,r,s){let i=a/s.width,l=r/s.height,c=n-s.x*i,u=o-s.y*l,d=`oja-crop-${(this.clipIdCounter++).toString()}`;this.elements.push(`<clipPath id="${d}"><rect x="${He(n)}" y="${He(o)}" width="${a}" height="${r}"/></clipPath><g clip-path="url(#${d})"><image x="${He(c)}" y="${He(u)}" width="${He(i)}" height="${He(l)}" preserveAspectRatio="none" href="${s3(t)}"/></g>`)}clear(t){if(!t){this.elements.length=0;return}let n=this.apply(t.x,t.y),o=this.apply(t.x+t.width,t.y+t.height),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y),s=Math.abs(o.x-n.x),i=Math.abs(o.y-n.y);this.elements.push(`<rect x="${He(a)}" y="${He(r)}" width="${s}" height="${i}" fill="#fff"/>`)}apply(t,n){return z.applyToPoint(this.currentTransform,{x:t,y:n})}},He=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),s3=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e$=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");var i3=(e,t={})=>{t.skipInstall||Fc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Qg({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Xa(e,a,t),Bn(e,a),a.toSvg()};var vs=P(se(),1),ha=P(re(),1),V6=P(ya(),1);var l3=({items:e,style:t,className:n})=>{let o=U(),a=Og(),r=Pt(),[s,i]=(0,ha.useState)(null),l=(0,ha.useRef)(null);(0,ha.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,ha.useEffect)(()=>{if(o)return o.onLongPress(({screenPoint:p,worldPoint:h})=>{let m=o.hostElement.getBoundingClientRect();i({screenPoint:{x:p.x+m.left,y:p.y+m.top},worldPoint:h})})},[o]),(0,ha.useEffect)(()=>{if(!s)return;let p=m=>{l.current?.contains(m.target)||i(null)},h=m=>{m.key==="Escape"&&i(null)};return window.addEventListener("pointerdown",p,!0),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",p,!0),window.removeEventListener("keydown",h)}},[s]);let c=(0,ha.useCallback)(()=>{i(null)},[]);if(!o||!s)return null;let u={worldPoint:s.worldPoint,screenPoint:s.screenPoint},d=e.filter(p=>p.kind==="divider"||p.visible?.(o,u)!==!1),f=n$(d);return f.length===0?null:(0,V6.createPortal)((0,vs.jsx)("div",{ref:l,role:"menu",style:{position:"fixed",zIndex:1e3,top:s.screenPoint.y,left:s.screenPoint.x,background:"var(--menu-bg, var(--du-ui-bg-solid, #fff))",color:"var(--menu-text, var(--du-text, #1a1a1a))",border:"1px solid var(--menu-border, var(--du-ui-border, rgba(0,0,0,0.08)))",borderRadius:6,padding:"4px 0",minWidth:180,boxShadow:"var(--du-ui-shadow, 0 4px 16px rgba(0,0,0,0.18))",font:"13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",...t},className:n,children:f.map((p,h)=>p.kind==="divider"?(0,vs.jsx)("hr",{style:{border:0,borderTop:"1px solid var(--menu-divider, var(--du-ui-border, rgba(0,0,0,0.08)))",margin:"4px 0"}},`d-${h}`):(0,vs.jsx)(t$,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},t$=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,vs.jsxs)("button",{type:"button",role:"menuitem",onClick:s=>{if(a){s.preventDefault();return}s.stopPropagation(),o()},disabled:a,style:{all:"unset",display:"flex",justifyContent:"space-between",padding:"6px 12px",cursor:a?"not-allowed":"pointer",opacity:a?.4:1,width:"100%",boxSizing:"border-box"},onMouseEnter:s=>{a||(s.currentTarget.style.background="var(--du-hover-overlay, rgba(0,0,0,0.05))")},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[(0,vs.jsx)("span",{children:e.label}),e.shortcut?(0,vs.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},n$=e=>{let t=[];for(let n of e)n.kind==="divider"&&(t.length===0||t[t.length-1]?.kind==="divider")||t.push(n);for(;t.length>0&&t[t.length-1]?.kind==="divider";)t.pop();return t},c3=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},Te=(e,t)=>{let n=we.get(e),o=n?.predicate,r=(n?.hotkey?Array.isArray(n.hotkey)?n.hotkey:[n.hotkey]:[])[0],s=t?.visible??(o?l=>o({editor:l}):void 0),i=(l,c)=>(!l.readOnly||n?.viewMode===!0)&&(s?.(l,c)??!0);return{kind:"action",id:e,label:t?.label??n?.label??e,...r?{shortcut:dt(r)}:{},visible:i,onClick:l=>{we.dispatch(e,{editor:l})}}},u3=[{kind:"action",id:"annotation-open",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"annotation-toggle-resolved",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"annotation-delete",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"divider"},Te("delete-selection",{label:"Delete"}),Te("duplicate-selection",{label:"Duplicate"}),Te("copy"),Te("cut"),Te("paste"),Te("copy-style",{label:"Copy style"}),Te("paste-style",{label:"Paste style"}),Te("select-all"),{kind:"divider"},Te("group-selection",{label:"Group"}),Te("ungroup-selection",{label:"Ungroup"}),Te("flip-horizontal",{label:"Flip horizontal"}),Te("flip-vertical",{label:"Flip vertical"}),Te("align-left",{label:"Align left"}),Te("align-h-center",{label:"Align horizontal centres"}),Te("align-right",{label:"Align right"}),Te("align-top",{label:"Align top"}),Te("align-v-center",{label:"Align vertical centres"}),Te("align-bottom",{label:"Align bottom"}),Te("distribute-horizontal",{label:"Distribute horizontally"}),Te("distribute-vertical",{label:"Distribute vertically"}),Te("arrange-grid"),Te("arrange-stack-h"),Te("arrange-stack-v"),Te("auto-arrange"),Te("compact-z-order"),{kind:"divider"},Te("bring-to-front",{visible:e=>e.selection.size===1}),Te("send-to-back",{visible:e=>e.selection.size===1}),{kind:"action",id:"move-to-layer",label:"Move to layer\u2026",visible:e=>!e.readOnly&&e.selection.size>0&&e.scene.layers.size>1,onClick:e=>{if(typeof window>"u")return;let t=[...e.scene.layers.values()],n=t.map((s,i)=>`${i+1}. ${s.name}`).join(`
166
169
  `),o=window.prompt(`Move selection to layer (1-${t.length}):
167
- ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id)}},{kind:"divider"},{kind:"action",id:"open-thread",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"resolve-annotation",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"remove-annotation",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"action",id:"add-comment",label:"Add comment",visible:(e,t)=>e.hitAnnotation(t.worldPoint)===null,onClick:(e,t)=>{let n=[...e.scene.elements.values()].reverse().find(a=>{let r=a.position,s="width"in a&&typeof a.width=="number"?a.width:0,i="height"in a&&typeof a.height=="number"?a.height:0;return t.worldPoint.x>=r.x&&t.worldPoint.y>=r.y&&t.worldPoint.x<=r.x+s&&t.worldPoint.y<=r.y+i}),o=n?{x:t.worldPoint.x-n.position.x,y:t.worldPoint.y-n.position.y}:t.worldPoint;e.addAnnotation({position:o,elementId:n?.id??null})}},{kind:"divider"},Ce("zoom-in"),Ce("zoom-out"),Ce("zoom-reset",{label:"Reset zoom (100%)"}),Ce("zoom-to-fit",{label:"Fit to screen",visible:e=>e.scene.elements.size>0}),{kind:"divider"},{kind:"action",id:"clear-canvas",label:"Clear canvas",visible:e=>!e.readOnly&&(e.scene.elements.size>0||e.scene.links.size>0),onClick:e=>{WL(e)}}];var cr=P(se(),1),Bn=P(re(),1);var jL=()=>{let e=G(),[t,n]=(0,Bn.useState)(!1),[o,a]=(0,Bn.useState)(""),[r,s]=(0,Bn.useState)(0),i=(0,Bn.useRef)(null);(0,Bn.useEffect)(()=>(_e.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),_e.replace({id:"clear-canvas",label:"Clear canvas",category:"edit",hotkey:[{key:"Delete",meta:!0},{key:"Backspace",meta:!0}],predicate:({editor:m})=>m.scene.elements.size>0||m.scene.links.size>0,perform:({editor:m})=>{WL(m)}}),()=>{_e.unregister("open-command-palette"),_e.unregister("clear-canvas")}),[]);let l=(0,Bn.useMemo)(()=>_e.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Bn.useMemo)(()=>{let m=o.trim().toLowerCase();return(m?l.filter(y=>(y.label??"").toLowerCase().includes(m)):l).map(y=>({action:y,enabled:c?y.predicate?y.predicate(c):!0:!1}))},[l,o,c]);if((0,Bn.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Bn.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),_e.dispatch(m.action.id,c))},p=m=>{if(m.key==="ArrowDown")m.preventDefault(),s(x=>Math.min(u.length-1,x+1));else if(m.key==="ArrowUp")m.preventDefault(),s(x=>Math.max(0,x-1));else if(m.key==="Enter"){m.preventDefault();let x=u[r];x&&f(x)}},h=(m,x)=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 14px",cursor:x?"pointer":"default",opacity:x?1:.4,background:m===r?"var(--du-ui-hover, rgba(0,0,0,0.06))":"transparent"});return(0,cr.jsxs)(Ky,{open:t,onClose:d,title:"Command palette",style:TY,children:[(0,cr.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:IY}),(0,cr.jsx)("ul",{style:MY,role:"listbox",children:u.length===0?(0,cr.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,x)=>{let y=EY(m.action);return(0,cr.jsxs)("li",{role:"option","aria-selected":x===r,"aria-disabled":!m.enabled,style:h(x,m.enabled),onPointerEnter:()=>{s(x)},onClick:()=>{f(m)},children:[(0,cr.jsx)("span",{children:m.action.label}),y?(0,cr.jsx)("kbd",{style:RY,children:y}):null]},m.action.id)})})]})},EY=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return ut(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},TY={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},IY={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},MY={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},RY={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var vs=P(se(),1),Nn=P(re(),1);var ZL=()=>{let e=G(),t=Ya(),[n,o]=(0,Nn.useState)(!1),[a,r]=(0,Nn.useState)(""),[s,i]=(0,Nn.useState)(0),l=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>(_e.replace({id:"open-search",label:"Find text",category:"other",viewMode:!0,hotkey:{key:"f",meta:!0},perform:()=>{o(!0)}}),()=>{_e.unregister("open-search")}),[]);let c=(0,Nn.useMemo)(()=>a.trim()?$v(t,a):[],[t,a]),u=(0,Nn.useRef)(c);if(u.current=c,(0,Nn.useEffect)(()=>{if(!n||!e)return;let m=u.current[s];m&&(m.kind==="element"?e.setSelection([m.id]):e.selectLink(m.id),e.revealSelection(SE))},[n,s,a,e]),(0,Nn.useEffect)(()=>{if(!n)return;r(""),i(0);let m=requestAnimationFrame(()=>l.current?.focus());return()=>{cancelAnimationFrame(m)}},[n]),!n)return null;let d=()=>{r(""),i(0),o(!1)},f=m=>{c.length!==0&&i(x=>(x+m+c.length)%c.length)},p=m=>{m.key==="Escape"?(m.preventDefault(),m.stopPropagation(),d()):m.key==="Enter"?(m.preventDefault(),f(m.shiftKey?-1:1)):m.key==="ArrowDown"?(m.preventDefault(),f(1)):m.key==="ArrowUp"&&(m.preventDefault(),f(-1))},h=c.length===0?a.trim()?"No results":"":`${String(s+1)} of ${String(c.length)}`;return(0,vs.jsxs)("div",{style:OY,role:"search",children:[(0,vs.jsx)("input",{ref:l,value:a,onChange:m=>{r(m.target.value),i(0)},onKeyDown:p,placeholder:"Find in diagram\u2026","aria-label":"Find text in diagram",style:DY}),(0,vs.jsx)("span",{style:PY,"aria-live":"polite",children:h}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Previous match",title:"Previous (\u21E7\u23CE)",disabled:c.length===0,onClick:()=>{f(-1)},style:VL,children:"\u2191"}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Next match",title:"Next (\u23CE)",disabled:c.length===0,onClick:()=>{f(1)},style:VL,children:"\u2193"}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Close search",title:"Close (Esc)",onClick:d,style:VL,children:"\u2715"})]})},OY={position:"absolute",top:64,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",zIndex:80,pointerEvents:"auto"},DY={border:"none",outline:"none",padding:"4px 8px",fontSize:14,minWidth:180,background:"transparent",color:"inherit"},PY={fontSize:12,color:"var(--du-text-muted)",minWidth:56,textAlign:"right",whiteSpace:"nowrap"},VL={minWidth:28,height:28};var at=P(se(),1),pu=P(re(),1);var XL=()=>{let e=G(),[t,n]=(0,pu.useState)(!1),[,o]=(0,pu.useState)(0);if((0,pu.useEffect)(()=>(_e.replace({id:"toggle-stats",label:"Stats panel",category:"other",viewMode:!0,hotkey:{key:"/",alt:!0},perform:()=>{n(u=>!u)}}),()=>{_e.unregister("toggle-stats")}),[]),(0,pu.useEffect)(()=>{if(!(!e||!t))return e.subscribe(()=>{o(u=>u+1)})},[e,t]),!t||!e)return null;let a=e.combinedSelectionBounds(),r=e.selection.size,s=e.selectedLinks.size,i=r+s,l=e.scene,c=null;if(r===1&&s===0){let u=[...e.selection][0],d=u?l.elements.get(u):void 0;d&&(c=d.rotation*180/Math.PI)}return(0,at.jsxs)("div",{style:BY,role:"status","aria-label":"Selection stats","aria-live":"polite",children:[(0,at.jsx)("div",{style:d6,children:"Selection"}),a?(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)(ur,{label:"X",value:Ah(a.x)}),(0,at.jsx)(ur,{label:"Y",value:Ah(a.y)}),(0,at.jsx)(ur,{label:"W",value:Ah(a.width)}),(0,at.jsx)(ur,{label:"H",value:Ah(a.height)}),c!==null?(0,at.jsx)(ur,{label:"\u2220",value:`${String(Ah(c))}\xB0`}):null,i>1?(0,at.jsx)(ur,{label:"Count",value:String(i)}):null]}):(0,at.jsx)("div",{style:HY,children:"Nothing selected"}),(0,at.jsx)("div",{style:{...d6,marginTop:8},children:"Scene"}),(0,at.jsx)(ur,{label:"Elements",value:String(l.elements.size)}),(0,at.jsx)(ur,{label:"Edges",value:String(l.links.size)}),(0,at.jsx)(ur,{label:"Selected",value:String(i)})]})},Ah=e=>Math.round(e*10)/10,ur=({label:e,value:t})=>(0,at.jsxs)("div",{style:NY,children:[(0,at.jsx)("span",{style:zY,children:e}),(0,at.jsx)("span",{style:FY,children:t})]}),BY={position:"absolute",top:64,right:12,minWidth:148,padding:"8px 10px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",fontSize:12,zIndex:80,pointerEvents:"auto"},d6={fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"var(--du-text-muted)",marginBottom:4},NY={display:"flex",justifyContent:"space-between",gap:12,lineHeight:"18px"},zY={color:"var(--du-text-muted)"},FY={fontVariantNumeric:"tabular-nums",fontFamily:"ui-monospace, monospace"},HY={color:"var(--du-text-muted)",fontStyle:"italic"};var f6=P(se(),1),zn=P(re(),1);var p6=(0,zn.createContext)(null),YL=({children:e})=>{let[t,n]=(0,zn.useState)(!1),o=(0,zn.useCallback)(()=>{n(r=>!r)},[]);(0,zn.useEffect)(()=>(_e.replace({id:"toggle-zen-mode",label:"Zen mode",category:"other",viewMode:!0,hotkey:{key:"z",alt:!0},perform:()=>{n(r=>!r)}}),()=>{_e.unregister("toggle-zen-mode")}),[]),(0,zn.useEffect)(()=>{if(!t)return;let r=s=>{s.key==="Escape"&&n(!1)};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[t]);let a=(0,zn.useMemo)(()=>({zen:t,setZen:n,toggle:o}),[t,o]);return(0,f6.jsx)(p6.Provider,{value:a,children:e})},KL=()=>{let e=(0,zn.useContext)(p6);if(!e)throw new Error("@oh-just-another/react-ui: useZenMode called outside <ZenModeProvider>.");return e};var dr=P(se(),1),Fn=P(re(),1);var UY=(0,Fn.createContext)(null);var $L=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Fn.useState)([]),r=(0,Fn.useRef)(0),s=(0,Fn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Fn.useCallback)((c,u="info",d)=>{let f=`toast-${++r.current}`,p=d??t;return a(h=>[...h,{id:f,kind:u,message:c,duration:p}]),p>0&&Number.isFinite(p)&&window.setTimeout(()=>{s(f)},p),f},[t,s]),l=(0,Fn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,dr.jsxs)(UY.Provider,{value:l,children:[e,(0,dr.jsx)(GY,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},GY=({toasts:e,onDismiss:t,style:n})=>{let o={position:"fixed",top:16,right:16,zIndex:1100,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none",...n};return(0,dr.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,dr.jsx)(qY,{toast:a,onDismiss:t},a.id))})},WY={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},qY=({toast:e,onDismiss:t})=>{let n={pointerEvents:"auto",minWidth:240,maxWidth:360,padding:"10px 12px",background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderLeft:`4px solid ${WY[e.kind]}`,borderRadius:4,boxShadow:"0 4px 14px rgba(0, 0, 0, 0.3)",fontSize:13,display:"flex",alignItems:"flex-start",gap:12};return(0,dr.jsxs)("div",{role:"status",style:n,children:[(0,dr.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,dr.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:()=>{t(e.id)},style:{background:"transparent",border:"none",color:"var(--muted, #888)",cursor:"pointer",fontSize:16,lineHeight:1,padding:0},children:"\xD7"})]})};var Xe=P(se(),1),At=P(re(),1);var jY=16,VY=1.75,h6=(0,At.createContext)(null),m6=()=>(0,At.useContext)(h6)??{close:()=>{}},$=({children:e,trigger:t=(0,Xe.jsx)(Qd,{size:jY,strokeWidth:VY}),className:n,style:o})=>{let[a,r]=(0,At.useState)(!1),s=(0,At.useRef)(null),i=(0,At.useId)();(0,At.useEffect)(()=>{if(!a)return;let d=p=>{s.current&&(s.current.contains(p.target)||r(!1))},f=p=>{p.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",d),window.addEventListener("pointerdown",d),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("pointerdown",d),window.removeEventListener("keydown",f)}},[a]);let l=(0,At.useCallback)(()=>{r(!1)},[]),c={position:"relative",display:"inline-flex",...o},u={position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:200,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:900};return(0,Xe.jsxs)("div",{ref:s,className:n,style:c,children:[(0,Xe.jsx)("button",{type:"button",className:`du-icon-button du-icon-button-flat${a?" is-active":""}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":i,"aria-label":"Main menu",title:"Main menu",onClick:()=>{r(d=>!d)},children:t}),a?(0,Xe.jsx)("div",{id:i,role:"menu",style:u,children:(0,Xe.jsx)(h6.Provider,{value:{close:l},children:e})}):null]})},ZY={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},QL=e=>({...ZY,...e}),XY=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=m6();return(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...QL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:a?"var(--du-accent, #1a73e8)":"var(--du-text-muted, #888)"},children:a?(0,Xe.jsx)(Ed,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,Xe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},YY=({children:e,href:t,external:n})=>{let{close:o}=m6();return(0,Xe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...QL({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},KY=()=>(0,Xe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),$Y=({title:e,children:t})=>(0,Xe.jsxs)("div",{children:[(0,Xe.jsx)("div",{style:{padding:"6px 10px 2px",fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"var(--muted, #888)"},children:e}),t]}),QY=({value:e,onChange:t,options:n})=>(0,Xe.jsx)("div",{role:"radiogroup",style:{display:"flex",margin:"4px 8px 6px",background:"var(--menu-divider, #2a2a2a)",borderRadius:6,padding:2,gap:2},children:n.map(o=>{let a=o.value===e;return(0,Xe.jsx)("button",{type:"button",role:"radio","aria-checked":a,title:o.label,"aria-label":o.label,onClick:()=>{t(o.value)},style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:26,padding:"0 8px",background:a?"var(--menu-bg, #1a1a1a)":"transparent",color:a?"var(--text, #ddd)":"var(--muted, #888)",border:"none",borderRadius:4,cursor:"pointer",fontSize:12,fontWeight:a?600:400,boxShadow:a?"0 1px 2px rgba(0, 0, 0, 0.15)":"none",transition:"background 0.12s ease, color 0.12s ease"},children:o.icon??o.label},o.value)})}),JY=120,eK=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,At.useState)(!1),s=(0,At.useRef)(null),i=(0,At.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,At.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},JY)},[i]);(0,At.useEffect)(()=>i,[i]);let c={position:"absolute",top:-4,left:"100%",marginLeft:4,minWidth:220,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:1e3};return(0,Xe.jsxs)("div",{style:{position:"relative"},onMouseEnter:()=>{o||(i(),r(!0))},onMouseLeave:l,children:[(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>{o||(i(),r(u=>!u))},style:{...QL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--du-text-muted, #888)"},children:n??""}),t]}),(0,Xe.jsx)(Xs,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,Xe.jsx)("div",{role:"menu",style:c,children:e}):null]})};$.Item=XY;$.ItemLink=YY;$.Separator=KY;$.Group=$Y;$.Toggle=QY;$.Submenu=eK;var vh=class e{cacheSize;fallbackFactor;cache=new Map;wasm=null;currentFontKey=null;textEncoder=new TextEncoder;constructor(t={}){this.cacheSize=t.cacheSize??1e4,this.fallbackFactor=t.fallbackAdvanceFactor??.55}get isReady(){return this.wasm!==null}async loadModule(t){let n=await _p(t,"WasmTextShaper.loadModule");this.wasm=n.exports,this.cache.clear(),this.currentFontKey=null}static async loadBundled(){let t=new e,n=new URL("../wasm/text_shaper.wasm",import.meta.url);return await t.loadModule(n),t}measure(t,n){let o=`${y6(n)}|${t}`,a=this.cache.get(o);if(a)return this.cache.delete(o),this.cache.set(o,a),a;let r=this.wasm?this.measureViaWasm(t,n,this.wasm):this.measureFallback(t,n);if(this.cache.size>=this.cacheSize){let s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}return this.cache.set(o,r),r}shape(t,n){let o=this.measure(t,n),a=t.length===0?0:o.width/t.length,r=[];for(let s=0;s<t.length;s++)r.push({glyphId:t.charCodeAt(s),advance:a,x:s*a,y:0});return r}resolveFontId(t,n=!1,o=!1){let a=this.wasm;if(!a?.resolveFont)return 0;let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=as(a,r),c=a.resolveFont(s,i,n?1:0,o?1:0);return l(),c}glyphMetrics(t,n=0){let o=this.wasm;if(!o?.glyphMetrics)return null;let a=o.glyphMetrics(n,t),r=o.memory.buffer;if(a<=0||a+24>r.byteLength)return null;let s=new DataView(r,a,24);return{advance:s.getFloat32(0,!0),bboxXMin:s.getFloat32(4,!0),bboxYMin:s.getFloat32(8,!0),bboxW:s.getFloat32(12,!0),bboxH:s.getFloat32(16,!0),unitsPerEm:s.getFloat32(20,!0)}}rasterizeGlyphMSDF(t,n,o,a=0){let r=this.wasm;if(!r?.rasterizeGlyphMSDF)return null;let s=r.rasterizeGlyphMSDF(a,t,n,o),i=n*n*3,l=new Uint8Array(r.memory.buffer,s,i),c=new Uint8Array(l);return{atlasSize:n,range:o,data:c}}resetArena(){this.wasm?.reset?.(),this.currentFontKey=null}measureFallback(t,n){return{width:t.length*n.size*this.fallbackFactor}}measureViaWasm(t,n,o){let a=y6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=as(o,u);o.setFont(d.ptr,d.len,n.size,0,0),d.free(),this.currentFontKey=a}let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=as(o,r),c=o.measure(s,i);return l(),{width:c}}},y6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var tK={butt:0,round:1,square:2},nK={miter:0,round:1,bevel:2},oK={M:0,L:1,Q:2,C:3,Z:4},Lh=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await _p(t,"WasmRasterizer.loadModule");this.wasm=n.exports}static async loadBundled(t={}){let n=new e(t),o=new URL("../wasm/rasterizer.wasm",import.meta.url);return await n.loadModule(o),n}flatten(t,n){let o=n>0?n:this.defaultTolerance;return this.wasm?this.flattenViaWasm(t,o,this.wasm):by.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):by.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=aK(t),r=as(o,new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),s=o.alloc(4),i=o.alloc(4);try{o.flattenF32(r.ptr,a.length,n,s,i);let l=Ug(o.memory,s),c=Ug(o.memory,i);return g6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=rK(t),s=as(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=tK[o?.cap??"butt"],u=nK[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=Ug(a.memory,i),f=Ug(a.memory,l);return g6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},Sh=new Float32Array(256),x6=e=>{if(Sh.length>=e)return;let t=Sh.length;for(;t<e;)t*=2;Sh=new Float32Array(t)},aK=e=>{x6(e.length*7);let t=Sh,n=0;for(let o of e)switch(t[n++]=oK[o.kind],o.kind){case"M":case"L":t[n++]=o.to.x,t[n++]=o.to.y;break;case"Q":t[n++]=o.control.x,t[n++]=o.control.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"C":t[n++]=o.control1.x,t[n++]=o.control1.y,t[n++]=o.control2.x,t[n++]=o.control2.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"Z":break}return t.subarray(0,n)},rK=e=>{x6(e.length*2);let t=Sh;for(let n=0;n<e.length;n++){let o=e[n];t[n*2]=o?.x??0,t[n*2+1]=o?.y??0}return t.subarray(0,e.length*2)},Ug=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),g6=(e,t,n)=>{let o=new Float32Array(e.buffer,t,n*2),a=new Array(n);for(let r=0;r<n;r++)a[r]={x:v(o[r*2]),y:v(o[r*2+1])};return a};var A6=()=>typeof Worker<"u",b6=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",sK=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},iK=async()=>await vL()||SL()?"webgl2":Dg()&&A6()?"offscreen":"canvas2d",v6=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await iK(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:b6(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:b6()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:Dg()&&A6(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:sK()}},S6=e=>{let t=e.renderer==="webgl2"?"WebGL2":e.renderer==="offscreen"?"OffscreenCanvas + Worker":"Canvas2D";console.log("%c[diagram]%c renderer=%s, wasmText=%s, wasmRaster=%s, workers=%s, tiles=%s, touch=%s (%s)","color: #1a73e8; font-weight: 700","color: inherit",e.renderer,e.wasmText,e.wasmRaster,e.workers,e.tiles,e.touch,t)};var t3=new WeakMap,n3=new WeakSet,NK=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>P(E6(),1)),o=t(e),a=n(o,!0),r=o.lsd.width,s=o.lsd.height;if(r<=0||s<=0||a.length===0)return{frames:[],totalMs:0};let i=new OffscreenCanvas(r,s),l=i.getContext("2d"),c=new OffscreenCanvas(r,s),u=c.getContext("2d");if(!l||!u)return{frames:[],totalMs:0};let d=[],f=0;for(let p of a){let h=new ImageData(new Uint8ClampedArray(p.patch),p.dims.width,p.dims.height);c.width=p.dims.width,c.height=p.dims.height,u.putImageData(h,0,0),l.drawImage(c,p.dims.left,p.dims.top);let m=await createImageBitmap(i);f+=p.delay>0?p.delay:100,d.push({bitmap:m,endMs:f}),p.disposalType===2&&l.clearRect(p.dims.left,p.dims.top,p.dims.width,p.dims.height)}return{frames:d,totalMs:f}},zK={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=t3.get(e);if(!n)return n3.has(e)||(n3.add(e),NK(e).then(r=>{t3.set(e,r),_v()}).catch(()=>{}).finally(()=>n3.delete(e))),null;if(n.frames.length===0)return null;let o=n.totalMs>0?t%n.totalMs:0;for(let r of n.frames)if(o<r.endMs)return r.bitmap;let a=n.frames[n.frames.length-1];return a?a.bitmap:null},totalDurationMs(e){return t3.get(e)?.totalMs??0}},T6=!1,I6=()=>{T6||(T6=!0,Lp(zK))};var kh=P(re(),1);var M6=e=>{let t=Dt(),[n]=(0,kh.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,kh.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,kh.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var a3=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=FK(e);if(!n)return null;let o={x:n.x-20,y:n.y-20,width:n.width+40,height:n.height+40},a=Math.max(1,Math.ceil(o.width*t.scale)),r=Math.max(1,Math.ceil(o.height*t.scale)),{canvas:s,target:i}=pL(a,r);t.background!=="transparent"&&(i.setFill(t.backgroundColor),i.beginPath(),i.rect(0,0,a,r),i.fill());let l={...e,viewport:{pan:{x:o.x,y:o.y},zoom:t.scale,rotation:0,size:{width:a,height:r},gridEnabled:e.viewport.gridEnabled,...e.viewport.gridStyle!==void 0?{gridStyle:e.viewport.gridStyle}:{}}};return t.background==="color-and-grid"&&l.viewport.gridEnabled&&Sp(l,i),Za(l,i,{skipClear:!0}),Pn(l,i),s.convertToBlob({type:"image/png"})},FK=e=>{let t=null;for(let n of vo(e))if(n.visible)for(let o of Ua(e,n.id)){let a=z(o);t=t?HK(t,a):a}return t},HK=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var R6=2,hu=e=>{typeof window<"u"&&window.alert(e)},O6=e=>{hu=e},r3=(e,t)=>{let n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),requestAnimationFrame(()=>{URL.revokeObjectURL(n)})},s3=e=>{let t=CL(e,2);r3(new Blob([t],{type:"application/json"}),"scene.diagram.json")},i3=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="application/json,.json",t.onchange=()=>{let n=t.files?.[0];n&&n.text().then(o=>{try{let a=TL(o);e.loadScene(a)}catch(a){console.error("[diagram] failed to parse scene file:",a),hu("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},t.click()},D6=()=>{if(typeof document>"u")return"#ffffff";let e=document.querySelector('canvas[data-layer="main"]')??document.body;return getComputedStyle(e).getPropertyValue("--du-canvas-bg").trim()||"#ffffff"},wh=async(e,t)=>{let n=await a3(e.scene,{background:t,scale:R6,backgroundColor:D6()});if(!n){hu("Nothing to export \u2014 the canvas is empty.");return}r3(n,"scene.png")},P6=e=>{let t=UL(e);r3(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},l3=async e=>{let t=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof t?.write!="function"||typeof ClipboardItem>"u"){hu("Copy to clipboard isn't supported in this browser.");return}let n=await a3(e.scene,{background:"color",scale:R6,backgroundColor:D6()});if(!n){hu("Nothing to copy \u2014 the canvas is empty.");return}try{await t.write([new ClipboardItem({"image/png":n})])}catch(o){console.error("[diagram] copy-as-image failed:",o),hu("Couldn't copy the image to the clipboard.")}},UK=[{id:"save-scene",label:"Save as JSON",category:"other",viewMode:!0,hotkey:{key:"s",meta:!0},perform:({editor:e})=>{s3(e.scene)}},{id:"open-scene",label:"Open\u2026",category:"other",hotkey:{key:"o",meta:!0},perform:({editor:e})=>{i3(e)}},{id:"export-png",label:"Export as PNG",category:"other",viewMode:!0,hotkey:{key:"e",meta:!0,shift:!0},perform:({editor:e})=>{wh(e,"color")}},{id:"copy-as-image",label:"Copy as image",category:"other",viewMode:!0,hotkey:{key:"c",shift:!0,alt:!0},perform:({editor:e})=>{l3(e)}}],B6=(e=_e)=>{for(let t of UK)e.replace(t)};var GK=14,WK=14,qK=16,c3=1.75,ft={size:GK,strokeWidth:c3},ws={size:WK,strokeWidth:c3},Zg={size:qK,strokeWidth:c3},jK="https://github.com/oh-just-another/diagram",_h=(0,me.forwardRef)(function(t,n){let{initialScene:o,initialMode:a="select",grid:r,snap:s,templates:i,fileDropHandlers:l,layoutKinds:c,animationAdapters:u,onReady:d,onSceneChange:f,onSelectionChange:p,capabilities:h,workerFactory:m,hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:T,hideHelpButton:w,hideContextMenu:S,hideSelectionPanel:L,hideDrawingPanel:M,minimap:B,renderTopBarLeft:W,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:j,renderBottomBarCenter:ve,renderBottomBarRight:ye,renderMainMenuExtras:ee,onImportTemplates:Se,theme:Oe,defaultTheme:qt="system",onThemeChange:xn,persistTheme:Oo,repositoryUrl:vt,onConfirm:Eh,onNotify:Th,className:Ih,style:Mh}=t,mu=(0,me.useMemo)(()=>Oo===!0?"diagram-theme":typeof Oo=="string"?Oo:null,[Oo]),[G6,W6]=(0,me.useState)(()=>{if(!mu||typeof window>"u")return qt;let X=window.localStorage.getItem(mu);return X==="light"||X==="dark"||X==="system"?X:qt}),Rh=Oe??G6,q6=M6(Rh),j6=(0,me.useCallback)(X=>{Oe===void 0&&W6(X),mu&&typeof window<"u"&&window.localStorage.setItem(mu,X),xn?.(X)},[Oe,xn,mu]),d3=r?.enabled,f3=r?.style,yu=(0,me.useMemo)(()=>VA({...o?{saved:o}:{},hostSettings:QK(d3,f3,s)}),[o,d3,f3,s]),p3=(0,me.useMemo)(()=>{for(let X of yu.elements.values())if(fe(X))return!0;return!1},[yu]);(0,me.useEffect)(()=>{if(I6(),i)for(let X of i)Oi.register(X);if(c)for(let X of c)e2(X);if(u)for(let X of u)Lp(X)},[i,c,u]);let[_s,V6]=(0,me.useState)(null),[Oh,Z6]=(0,me.useState)(null),[Dh,X6]=(0,me.useState)(null),[Y6,h3]=(0,me.useState)(!1),[Yg,m3]=(0,me.useState)(!1),y3=(0,me.useRef)(null),g3=(0,me.useRef)(!1);(0,me.useEffect)(()=>{let X=!1;return(async()=>{y3.current??=v6(h);let Hn=await y3.current;if(X)return;g3.current||(g3.current=!0,S6(Hn)),V6(Hn);let Cs=[];Cs.push(dD(document).then(()=>{X||m3(!0)},$t=>{X||m3(!0),console.warn("[diagram] bundled fonts load failed",$t)})),Hn.wasmText&&Cs.push(vh.loadBundled().then($t=>{X||(Cp($t),Z6($t),h3(!0))},$t=>{X||(h3(!0),console.warn("[diagram] WASM text shaper load failed",$t))})),Hn.wasmRaster&&Cs.push(Lh.loadBundled().then($t=>{X||(Ep($t),X6($t))},$t=>{console.warn("[diagram] WASM rasterizer load failed",$t)})),await Promise.allSettled(Cs)})(),()=>{X=!0}},[h]);let[ge,K6]=(0,me.useState)(null),$6=(0,me.useCallback)(X=>{if(l)for(let Hn of l)X.registerFileDropHandler(Hn);K6(X),d?.(X)},[l,d]);return(0,me.useEffect)(()=>{ge&&(!Oh&&!Dh||ge.setMode(ge.mode))},[ge,Oh,Dh]),(0,me.useEffect)(()=>{ge&&ge.forceRender()},[ge,u]),(0,me.useEffect)(()=>{ge&&Yg&&ge.forceRender()},[ge,Yg]),(0,me.useEffect)(()=>{if(!ge||!f&&!p)return;let X=ge.scene,Hn=ge.selection;return ge.subscribe(()=>{f&&ge.scene!==X&&(X=ge.scene,f(ge.scene)),p&&ge.selection!==Hn&&(Hn=ge.selection,p(ge.selection))})},[ge,f,p]),(0,me.useEffect)(()=>{if(!ge)return;let X=ge,Hn=Qt=>{ea(Qt.target)||(X.setSnapSuppressed(Qt.metaKey||Qt.ctrlKey),X.setTransformModifiers({alt:Qt.altKey,shift:Qt.shiftKey}))},Cs=Qt=>{Hn(Qt),!ea(Qt.target)&&Qt.key==="Escape"&&X.flowchartPreview!==null&&(X.cancelFlowchart(),Qt.preventDefault())},$t=Qt=>{Hn(Qt),!Qt.metaKey&&!Qt.ctrlKey&&X.flowchartPreview!==null&&X.commitFlowchart()},x3=()=>{X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1}),X.flowchartPreview!==null&&X.commitFlowchart()};return window.addEventListener("keydown",Cs),window.addEventListener("keyup",$t),window.addEventListener("blur",x3),()=>{window.removeEventListener("keydown",Cs),window.removeEventListener("keyup",$t),window.removeEventListener("blur",x3),X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1})}},[ge]),(0,me.useImperativeHandle)(n,()=>({editor:ge,capabilities:_s,getScene:()=>ge?.scene??yu,loadScene:X=>ge?.loadScene(X),getMode:()=>ge?.mode??null,setMode:X=>ge?.setMode(X),getSelection:()=>ge?.selection??new Set,setSelection:X=>ge?.setSelection(X),undo:()=>{ge?.undo()},redo:()=>{ge?.redo()},zoomToFit:()=>{ge?.zoomToFit()}}),[ge,yu,_s]),_s?p3&&!Yg?(0,R.jsx)("div",{className:Ih,style:Mh}):_s.renderer==="webgl2"&&_s.wasmText&&!Y6&&p3?(0,R.jsx)("div",{className:Ih,style:Mh}):(0,R.jsx)(Lf,{container:q6,children:(0,R.jsx)($L,{children:(0,R.jsx)(Zb,{children:(0,R.jsx)("div",{className:Ih,"data-diagram-root":!0,...Rh==="system"?{}:{"data-theme":Rh},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...Mh},children:(0,R.jsx)(LL,{initialScene:yu,initialMode:a,onReady:$6,renderer:_s.renderer,..._s.renderer==="offscreen"?{workerFactory:m??mL}:{},...Oh?{textShaper:Oh}:{},...Dh?{rasterizer:Dh}:{},children:(0,R.jsx)(YL,{children:(0,R.jsx)(VK,{hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:T,hideHelpButton:w,hideContextMenu:S,hideSelectionPanel:L,hideDrawingPanel:M,minimap:B,renderTopBarLeft:W,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:j,renderBottomBarCenter:ve,renderBottomBarRight:ye,renderMainMenuExtras:ee,onImportTemplates:Se,repositoryUrl:vt,onConfirm:Eh,onNotify:Th,theme:Rh,changeTheme:j6})})})})})})}):(0,R.jsx)("div",{className:Ih,style:Mh})});_h.displayName="Editor";var VK=({hideTopBar:e,hideBottomBar:t,hideToolbar:n,hideLibraryButton:o,hideMainMenu:a,hideZoomControls:r,hideResetToContent:s,hideHelpButton:i,hideContextMenu:l,hideSelectionPanel:c,hideDrawingPanel:u,minimap:d,renderTopBarLeft:f,renderTopBarCenter:p,renderTopBarRight:h,renderBottomBarLeft:m,renderBottomBarCenter:x,renderBottomBarRight:y,renderMainMenuExtras:g,onImportTemplates:b,repositoryUrl:A,onConfirm:_,onNotify:T,theme:w,changeTheme:S})=>{let L=G(),{zen:M}=KL(),B=A===void 0?jK:A,W=_??(vt=>window.confirm(vt)),ie=T??(vt=>{window.alert(vt)});(0,me.useEffect)(()=>{B6(),O6(ie)},[ie]),Ya();let ne=jS(),j=jp(),[ve,ye]=(0,me.useState)(!1),[ee,Se]=(0,me.useState)(!1);PS(()=>{Se(vt=>!vt)});let Oe=240,qt=12,xn=!j&&ve?Oe+qt:qt,Oo=(0,me.useMemo)(()=>o?[...Fg]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(Zd,{...Zg}),title:"Templates library",active:ve,onClick:()=>{ye(vt=>!vt)}},{kind:"divider"},...Fg],[o,ve]);return(0,R.jsxs)("div",{style:{position:"absolute",inset:0},onDragEnter:ne.onDragEnter,onDragOver:ne.onDragOver,onDragLeave:ne.onDragLeave,onDrop:ne.onDrop,children:[(0,R.jsxs)("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0},children:[(0,R.jsx)(kL,{style:{position:"absolute",inset:0}}),(0,R.jsx)(ML,{}),(0,R.jsx)(RL,{}),(0,R.jsx)(OL,{}),(0,R.jsx)(DL,{}),(0,R.jsx)(PL,{}),!l&&(0,R.jsx)(GL,{items:qL})]}),!n&&!M?(0,R.jsx)(zL,{orientation:"vertical",items:Oo,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${xn}px)`,transform:"translateY(-50%)",zIndex:60}}):null,(0,R.jsxs)(Kb,{children:[!e&&!M&&(0,R.jsx)($b,{left:(0,R.jsxs)(ni,{ariaLabel:"Logo and main menu",children:[(0,R.jsx)("span",{"aria-label":"Diagram",title:"Diagram",className:"du-icon-button",style:{minWidth:36,padding:"0 10px",cursor:"default",fontWeight:600,letterSpacing:.5},children:"\u2317"}),!a&&(0,R.jsxs)($,{children:[(0,R.jsxs)($.Group,{title:"File",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Fd,{...ft}),onClick:()=>{L&&i3(L)},shortcut:ut({key:"O",meta:!0}),children:"Open\u2026"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(zd,{...ft}),onClick:()=>{L&&s3(L.scene)},disabled:!L,shortcut:ut({key:"S",meta:!0}),children:"Save as JSON"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Hr,{...ft}),onClick:()=>{L&&l3(L)},disabled:!L,shortcut:ut({key:"C",shift:!0,alt:!0}),children:"Copy as image"}),(0,R.jsxs)($.Submenu,{icon:(0,R.jsx)(Jl,{...ft}),label:"Export\u2026",disabled:!L,children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"transparent"),disabled:!L,children:"PNG (transparent)"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"color"),disabled:!L,shortcut:ut({key:"E",meta:!0,shift:!0}),children:"PNG (with background)"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"color-and-grid"),disabled:!L,children:"PNG (with background + grid)"}),(0,R.jsx)($.Separator,{}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Jl,{...ft}),onClick:()=>{L&&P6(L.scene)},disabled:!L,children:"SVG"})]}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(cf,{...ft}),onClick:()=>{L&&W("Reset canvas? This clears all shapes.")&&L.clear()},disabled:!L,children:"Reset canvas"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"Edit",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(ei,{...ft}),shortcut:"\u2318Z",onClick:()=>L?.undo(),disabled:!L,children:"Undo"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Js,{...ft}),shortcut:"\u21E7\u2318Z",onClick:()=>L?.redo(),disabled:!L,children:"Redo"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(uf,{...ft}),shortcut:"\u2318X",onClick:()=>L?.cutSelected(),disabled:!L,children:"Cut"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Hr,{...ft}),shortcut:"\u2318C",onClick:()=>L?.copySelected(),disabled:!L,children:"Copy"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Rd,{...ft}),shortcut:"\u2318V",onClick:()=>L?.paste(),disabled:!L,children:"Paste"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(nf,{...ft}),shortcut:"\u2318A",onClick:()=>L?.selectAll(),disabled:!L,children:"Select all"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Dd,{...ft}),shortcut:"\u232B",onClick:()=>L?.deleteSelected(),disabled:!L,children:"Delete selected"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"View",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(ec,{...ft}),shortcut:"\u21E7F",onClick:()=>L?.zoomToFit(),disabled:!L,children:"Fit to screen"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Sf,{...ft}),shortcut:"\u2318+",onClick:()=>L?.zoomIn(),disabled:!L,children:"Zoom in"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(vf,{...ft}),shortcut:"\u2318\u2212",onClick:()=>L?.zoomOut(),disabled:!L,children:"Zoom out"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsx)($.Group,{title:"Theme",children:(0,R.jsx)($.Toggle,{value:w,onChange:S,options:[{value:"light",label:"Light",icon:(0,R.jsx)(mf,{...ws})},{value:"dark",label:"Dark",icon:(0,R.jsx)(ef,{...ws})},{value:"system",label:"System",icon:(0,R.jsx)(Jd,{...ws})}]})}),(0,R.jsx)($.Group,{title:"Grid",children:(0,R.jsx)($.Toggle,{value:JK(L),onChange:vt=>{t$(L,vt)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(xo,{...ws})},{value:"dots",label:"Dots",icon:(0,R.jsx)(Wd,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Da,{...ws})}]})}),(0,R.jsx)($.Group,{title:"Snap to grid",children:(0,R.jsx)($.Toggle,{value:e$(L),onChange:vt=>{L?.setSnapToGrid(vt==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)($d,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Da,{...ws})}]})}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"Help",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Tn,{...ft}),shortcut:"?",onClick:()=>{Se(!0)},children:"Hotkeys"}),B?(0,R.jsx)($.ItemLink,{href:B,external:!0,children:"GitHub"}):null]}),g?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($.Separator,{}),g()]}):null]}),f?f():null]}),center:p?.(),right:(0,R.jsx)(ni,{ariaLabel:"Top bar actions",children:h?h():null})}),!t&&!M&&(0,R.jsx)(Qb,{left:m?m():null,center:x?x():s?null:(0,R.jsx)(FS,{}),right:y?y():r?i?null:(0,R.jsx)($y,{}):(0,R.jsx)($K,{trailing:i?void 0:(0,R.jsx)($y,{})})}),M?null:j?ve?(0,R.jsx)(IL,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:vt=>{vt<=0&&ye(!1)},children:(0,R.jsx)(sg,{open:!0,sheet:!0,onClose:()=>{ye(!1)},...b?{onImport:b}:{}})}):null:(0,R.jsx)(sg,{open:ve,side:"left",style:{left:0},onClose:()=>{ye(!1)},...b?{onImport:b}:{}})]}),d&&!M&&(0,R.jsx)("div",{style:{position:"absolute",right:"var(--du-bar-inset, 12px)",bottom:"calc(var(--du-bar-inset, 12px) + 52px)",border:"1px solid var(--du-border, #d0d0d0)",borderRadius:6,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",overflow:"hidden",zIndex:40},children:(0,R.jsx)(wL,{})}),!u&&!M&&(0,R.jsx)("div",{style:{position:"absolute",top:"calc(var(--du-bar-inset, 12px) + 52px)",right:"var(--du-bar-inset, 12px)",zIndex:40},children:(0,R.jsx)(_L,{})}),!c&&!M&&(0,R.jsx)(sL,{}),(0,R.jsx)(Wp,{open:ee,onClose:()=>{Se(!1)}}),(0,R.jsx)(jL,{}),(0,R.jsx)(ZL,{}),(0,R.jsx)(XL,{}),void 0]})},ZK=ut({meta:!0,key:"\u2212"}),XK=ut({meta:!0,key:"+"}),YK=ut({meta:!0,key:"0"}),KK=ut({alt:!0,key:"1"}),$K=({trailing:e})=>{let t=G(),[,n]=(0,me.useState)(0);if((0,me.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(ni,{ariaLabel:"Zoom",children:[(0,R.jsx)(Qn,{label:`Zoom out (${ZK})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(Da,{...Zg})}),(0,R.jsx)(ti,{content:`Reset zoom to 100% (${YK})`,children:(0,R.jsxs)("button",{type:"button",className:"du-icon-button","aria-label":"Reset zoom to 100%",onClick:()=>{t.resetZoom()},style:{minWidth:56,padding:"0 8px",borderRadius:0},children:[Math.round(o*100),"%"]})}),(0,R.jsx)(Qn,{label:`Zoom in (${XK})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Qs,{...Zg})}),(0,R.jsx)(Qn,{label:`Fit to screen (${KK})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(ec,{...Zg})}),e]})},QK=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),JK=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},e$=e=>e?.snapToGridEnabled??!0?"on":"off",t$=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var N6=`/**
170
+ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id)}},{kind:"divider"},{kind:"action",id:"open-thread",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"resolve-annotation",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"remove-annotation",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"action",id:"add-comment",label:"Add comment",visible:(e,t)=>e.hitAnnotation(t.worldPoint)===null,onClick:(e,t)=>{let n=[...e.scene.elements.values()].reverse().find(a=>{let r=a.position,s="width"in a&&typeof a.width=="number"?a.width:0,i="height"in a&&typeof a.height=="number"?a.height:0;return t.worldPoint.x>=r.x&&t.worldPoint.y>=r.y&&t.worldPoint.x<=r.x+s&&t.worldPoint.y<=r.y+i}),o=n?{x:t.worldPoint.x-n.position.x,y:t.worldPoint.y-n.position.y}:t.worldPoint;e.addAnnotation({position:o,elementId:n?.id??null})}},{kind:"divider"},Te("zoom-in"),Te("zoom-out"),Te("zoom-reset",{label:"Reset zoom (100%)"}),Te("zoom-to-fit",{label:"Fit to screen",visible:e=>e.scene.elements.size>0}),{kind:"divider"},{kind:"action",id:"clear-canvas",label:"Clear canvas",visible:e=>!e.readOnly&&(e.scene.elements.size>0||e.scene.links.size>0),onClick:e=>{c3(e)}}];var ur=P(se(),1),Nn=P(re(),1);var d3=()=>{let e=U(),[t,n]=(0,Nn.useState)(!1),[o,a]=(0,Nn.useState)(""),[r,s]=(0,Nn.useState)(0),i=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>(we.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),we.replace({id:"clear-canvas",label:"Clear canvas",category:"edit",hotkey:[{key:"Delete",meta:!0},{key:"Backspace",meta:!0}],predicate:({editor:m})=>m.scene.elements.size>0||m.scene.links.size>0,perform:({editor:m})=>{c3(m)}}),()=>{we.unregister("open-command-palette"),we.unregister("clear-canvas")}),[]);let l=(0,Nn.useMemo)(()=>we.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Nn.useMemo)(()=>{let m=o.trim().toLowerCase();return(m?l.filter(y=>(y.label??"").toLowerCase().includes(m)):l).map(y=>({action:y,enabled:c?y.predicate?y.predicate(c):!0:!1}))},[l,o,c]);if((0,Nn.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Nn.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),we.dispatch(m.action.id,c))},p=m=>{if(m.key==="ArrowDown")m.preventDefault(),s(x=>Math.min(u.length-1,x+1));else if(m.key==="ArrowUp")m.preventDefault(),s(x=>Math.max(0,x-1));else if(m.key==="Enter"){m.preventDefault();let x=u[r];x&&f(x)}},h=(m,x)=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 14px",cursor:x?"pointer":"default",opacity:x?1:.4,background:m===r?"var(--du-ui-hover, rgba(0,0,0,0.06))":"transparent"});return(0,ur.jsxs)(dg,{open:t,onClose:d,title:"Command palette",style:a$,children:[(0,ur.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:r$}),(0,ur.jsx)("ul",{style:s$,role:"listbox",children:u.length===0?(0,ur.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,x)=>{let y=o$(m.action);return(0,ur.jsxs)("li",{role:"option","aria-selected":x===r,"aria-disabled":!m.enabled,style:h(x,m.enabled),onPointerEnter:()=>{s(x)},onClick:()=>{f(m)},children:[(0,ur.jsx)("span",{children:m.action.label}),y?(0,ur.jsx)("kbd",{style:i$,children:y}):null]},m.action.id)})})]})},o$=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return dt(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},a$={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},r$={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},s$={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},i$={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var Ss=P(se(),1),zn=P(re(),1);var p3=()=>{let e=U(),t=Ka(),[n,o]=(0,zn.useState)(!1),[a,r]=(0,zn.useState)(""),[s,i]=(0,zn.useState)(0),l=(0,zn.useRef)(null);(0,zn.useEffect)(()=>(we.replace({id:"open-search",label:"Find text",category:"other",viewMode:!0,hotkey:{key:"f",meta:!0},perform:()=>{o(!0)}}),()=>{we.unregister("open-search")}),[]);let c=(0,zn.useMemo)(()=>a.trim()?hS(t,a):[],[t,a]),u=(0,zn.useRef)(c);if(u.current=c,(0,zn.useEffect)(()=>{if(!n||!e)return;let m=u.current[s];m&&(m.kind==="element"?e.setSelection([m.id]):e.selectLink(m.id),e.revealSelection(GE))},[n,s,a,e]),(0,zn.useEffect)(()=>{if(!n)return;r(""),i(0);let m=requestAnimationFrame(()=>l.current?.focus());return()=>{cancelAnimationFrame(m)}},[n]),!n)return null;let d=()=>{r(""),i(0),o(!1)},f=m=>{c.length!==0&&i(x=>(x+m+c.length)%c.length)},p=m=>{m.key==="Escape"?(m.preventDefault(),m.stopPropagation(),d()):m.key==="Enter"?(m.preventDefault(),f(m.shiftKey?-1:1)):m.key==="ArrowDown"?(m.preventDefault(),f(1)):m.key==="ArrowUp"&&(m.preventDefault(),f(-1))},h=c.length===0?a.trim()?"No results":"":`${String(s+1)} of ${String(c.length)}`;return(0,Ss.jsxs)("div",{style:l$,role:"search",children:[(0,Ss.jsx)("input",{ref:l,value:a,onChange:m=>{r(m.target.value),i(0)},onKeyDown:p,placeholder:"Find in diagram\u2026","aria-label":"Find text in diagram",style:c$}),(0,Ss.jsx)("span",{style:u$,"aria-live":"polite",children:h}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Previous match",title:"Previous (\u21E7\u23CE)",disabled:c.length===0,onClick:()=>{f(-1)},style:f3,children:"\u2191"}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Next match",title:"Next (\u23CE)",disabled:c.length===0,onClick:()=>{f(1)},style:f3,children:"\u2193"}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Close search",title:"Close (Esc)",onClick:d,style:f3,children:"\u2715"})]})},l$={position:"absolute",top:64,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",zIndex:80,pointerEvents:"auto"},c$={border:"none",outline:"none",padding:"4px 8px",fontSize:14,minWidth:180,background:"transparent",color:"inherit"},u$={fontSize:12,color:"var(--du-text-muted)",minWidth:56,textAlign:"right",whiteSpace:"nowrap"},f3={minWidth:28,height:28};var at=P(se(),1),xu=P(re(),1);var h3=()=>{let e=U(),[t,n]=(0,xu.useState)(!1),[,o]=(0,xu.useState)(0);if((0,xu.useEffect)(()=>(we.replace({id:"toggle-stats",label:"Stats panel",category:"other",viewMode:!0,hotkey:{key:"/",alt:!0},perform:()=>{n(u=>!u)}}),()=>{we.unregister("toggle-stats")}),[]),(0,xu.useEffect)(()=>{if(!(!e||!t))return e.subscribe(()=>{o(u=>u+1)})},[e,t]),!t||!e)return null;let a=e.combinedSelectionBounds(),r=e.selection.size,s=e.selectedLinks.size,i=r+s,l=e.scene,c=null;if(r===1&&s===0){let u=[...e.selection][0],d=u?l.elements.get(u):void 0;d&&(c=d.rotation*180/Math.PI)}return(0,at.jsxs)("div",{style:d$,role:"status","aria-label":"Selection stats","aria-live":"polite",children:[(0,at.jsx)("div",{style:j6,children:"Selection"}),a?(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)(dr,{label:"X",value:Rh(a.x)}),(0,at.jsx)(dr,{label:"Y",value:Rh(a.y)}),(0,at.jsx)(dr,{label:"W",value:Rh(a.width)}),(0,at.jsx)(dr,{label:"H",value:Rh(a.height)}),c!==null?(0,at.jsx)(dr,{label:"\u2220",value:`${String(Rh(c))}\xB0`}):null,i>1?(0,at.jsx)(dr,{label:"Count",value:String(i)}):null]}):(0,at.jsx)("div",{style:m$,children:"Nothing selected"}),(0,at.jsx)("div",{style:{...j6,marginTop:8},children:"Scene"}),(0,at.jsx)(dr,{label:"Elements",value:String(l.elements.size)}),(0,at.jsx)(dr,{label:"Edges",value:String(l.links.size)}),(0,at.jsx)(dr,{label:"Selected",value:String(i)})]})},Rh=e=>Math.round(e*10)/10,dr=({label:e,value:t})=>(0,at.jsxs)("div",{style:f$,children:[(0,at.jsx)("span",{style:p$,children:e}),(0,at.jsx)("span",{style:h$,children:t})]}),d$={position:"absolute",top:64,right:12,minWidth:148,padding:"8px 10px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",fontSize:12,zIndex:80,pointerEvents:"auto"},j6={fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"var(--du-text-muted)",marginBottom:4},f$={display:"flex",justifyContent:"space-between",gap:12,lineHeight:"18px"},p$={color:"var(--du-text-muted)"},h$={fontVariantNumeric:"tabular-nums",fontFamily:"ui-monospace, monospace"},m$={color:"var(--du-text-muted)",fontStyle:"italic"};var Z6=P(se(),1),Fn=P(re(),1);var X6=(0,Fn.createContext)(null),m3=({children:e})=>{let[t,n]=(0,Fn.useState)(!1),o=(0,Fn.useCallback)(()=>{n(r=>!r)},[]);(0,Fn.useEffect)(()=>(we.replace({id:"toggle-zen-mode",label:"Zen mode",category:"other",viewMode:!0,hotkey:{key:"z",alt:!0},perform:()=>{n(r=>!r)}}),()=>{we.unregister("toggle-zen-mode")}),[]),(0,Fn.useEffect)(()=>{if(!t)return;let r=s=>{s.key==="Escape"&&n(!1)};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[t]);let a=(0,Fn.useMemo)(()=>({zen:t,setZen:n,toggle:o}),[t,o]);return(0,Z6.jsx)(X6.Provider,{value:a,children:e})},y3=()=>{let e=(0,Fn.useContext)(X6);if(!e)throw new Error("@oh-just-another/react-ui: useZenMode called outside <ZenModeProvider>.");return e};var fr=P(se(),1),Hn=P(re(),1);var y$=(0,Hn.createContext)(null);var g3=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Hn.useState)([]),r=(0,Hn.useRef)(0),s=(0,Hn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Hn.useCallback)((c,u="info",d)=>{let f=`toast-${++r.current}`,p=d??t;return a(h=>[...h,{id:f,kind:u,message:c,duration:p}]),p>0&&Number.isFinite(p)&&window.setTimeout(()=>{s(f)},p),f},[t,s]),l=(0,Hn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,fr.jsxs)(y$.Provider,{value:l,children:[e,(0,fr.jsx)(g$,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},g$=({toasts:e,onDismiss:t,style:n})=>{let o={position:"fixed",top:16,right:16,zIndex:1100,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none",...n};return(0,fr.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,fr.jsx)(b$,{toast:a,onDismiss:t},a.id))})},x$={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},b$=({toast:e,onDismiss:t})=>{let n={pointerEvents:"auto",minWidth:240,maxWidth:360,padding:"10px 12px",background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderLeft:`4px solid ${x$[e.kind]}`,borderRadius:4,boxShadow:"0 4px 14px rgba(0, 0, 0, 0.3)",fontSize:13,display:"flex",alignItems:"flex-start",gap:12};return(0,fr.jsxs)("div",{role:"status",style:n,children:[(0,fr.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,fr.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:()=>{t(e.id)},style:{background:"transparent",border:"none",color:"var(--muted, #888)",cursor:"pointer",fontSize:16,lineHeight:1,padding:0},children:"\xD7"})]})};var Xe=P(se(),1),vt=P(re(),1);var A$=16,v$=1.75,Y6=(0,vt.createContext)(null),K6=()=>(0,vt.useContext)(Y6)??{close:()=>{}},Q=({children:e,trigger:t=(0,Xe.jsx)(of,{size:A$,strokeWidth:v$}),className:n,style:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useId)();(0,vt.useEffect)(()=>{if(!a)return;let d=p=>{s.current&&(s.current.contains(p.target)||r(!1))},f=p=>{p.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",d),window.addEventListener("pointerdown",d),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("pointerdown",d),window.removeEventListener("keydown",f)}},[a]);let l=(0,vt.useCallback)(()=>{r(!1)},[]),c={position:"relative",display:"inline-flex",...o},u={position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:200,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:900};return(0,Xe.jsxs)("div",{ref:s,className:n,style:c,children:[(0,Xe.jsx)("button",{type:"button",className:`du-icon-button du-icon-button-flat${a?" is-active":""}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":i,"aria-label":"Main menu",title:"Main menu",onClick:()=>{r(d=>!d)},children:t}),a?(0,Xe.jsx)("div",{id:i,role:"menu",style:u,children:(0,Xe.jsx)(Y6.Provider,{value:{close:l},children:e})}):null]})},S$={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},x3=e=>({...S$,...e}),L$=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=K6();return(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...x3(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:a?"var(--du-accent, #1a73e8)":"var(--du-text-muted, #888)"},children:a?(0,Xe.jsx)(Od,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,Xe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},k$=({children:e,href:t,external:n})=>{let{close:o}=K6();return(0,Xe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...x3({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},_$=()=>(0,Xe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),w$=({title:e,children:t})=>(0,Xe.jsxs)("div",{children:[(0,Xe.jsx)("div",{style:{padding:"6px 10px 2px",fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"var(--muted, #888)"},children:e}),t]}),T$=({value:e,onChange:t,options:n})=>(0,Xe.jsx)("div",{role:"radiogroup",style:{display:"flex",margin:"4px 8px 6px",background:"var(--menu-divider, #2a2a2a)",borderRadius:6,padding:2,gap:2},children:n.map(o=>{let a=o.value===e;return(0,Xe.jsx)("button",{type:"button",role:"radio","aria-checked":a,title:o.label,"aria-label":o.label,onClick:()=>{t(o.value)},style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:26,padding:"0 8px",background:a?"var(--menu-bg, #1a1a1a)":"transparent",color:a?"var(--text, #ddd)":"var(--muted, #888)",border:"none",borderRadius:4,cursor:"pointer",fontSize:12,fontWeight:a?600:400,boxShadow:a?"0 1px 2px rgba(0, 0, 0, 0.15)":"none",transition:"background 0.12s ease, color 0.12s ease"},children:o.icon??o.label},o.value)})}),E$=120,C$=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,vt.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},E$)},[i]);(0,vt.useEffect)(()=>i,[i]);let c={position:"absolute",top:-4,left:"100%",marginLeft:4,minWidth:220,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:1e3};return(0,Xe.jsxs)("div",{style:{position:"relative"},onMouseEnter:()=>{o||(i(),r(!0))},onMouseLeave:l,children:[(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>{o||(i(),r(u=>!u))},style:{...x3(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--du-text-muted, #888)"},children:n??""}),t]}),(0,Xe.jsx)(Ys,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,Xe.jsx)("div",{role:"menu",style:c,children:e}):null]})};Q.Item=L$;Q.ItemLink=k$;Q.Separator=_$;Q.Group=w$;Q.Toggle=T$;Q.Submenu=C$;var Oh=class e{cacheSize;fallbackFactor;cache=new Map;wasm=null;currentFontKey=null;textEncoder=new TextEncoder;constructor(t={}){this.cacheSize=t.cacheSize??1e4,this.fallbackFactor=t.fallbackAdvanceFactor??.55}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Dp(t,"WasmTextShaper.loadModule");this.wasm=n.exports,this.cache.clear(),this.currentFontKey=null}static async loadBundled(){let t=new e,n=new URL("../wasm/text_shaper.wasm",import.meta.url);return await t.loadModule(n),t}measure(t,n){let o=`${$6(n)}|${t}`,a=this.cache.get(o);if(a)return this.cache.delete(o),this.cache.set(o,a),a;let r=this.wasm?this.measureViaWasm(t,n,this.wasm):this.measureFallback(t,n);if(this.cache.size>=this.cacheSize){let s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}return this.cache.set(o,r),r}shape(t,n){let o=this.measure(t,n),a=t.length===0?0:o.width/t.length,r=[];for(let s=0;s<t.length;s++)r.push({glyphId:t.charCodeAt(s),advance:a,x:s*a,y:0});return r}resolveFontId(t,n=!1,o=!1){let a=this.wasm;if(!a?.resolveFont)return 0;let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=rs(a,r),c=a.resolveFont(s,i,n?1:0,o?1:0);return l(),c}glyphMetrics(t,n=0){let o=this.wasm;if(!o?.glyphMetrics)return null;let a=o.glyphMetrics(n,t),r=o.memory.buffer;if(a<=0||a+24>r.byteLength)return null;let s=new DataView(r,a,24);return{advance:s.getFloat32(0,!0),bboxXMin:s.getFloat32(4,!0),bboxYMin:s.getFloat32(8,!0),bboxW:s.getFloat32(12,!0),bboxH:s.getFloat32(16,!0),unitsPerEm:s.getFloat32(20,!0)}}rasterizeGlyphMSDF(t,n,o,a=0){let r=this.wasm;if(!r?.rasterizeGlyphMSDF)return null;let s=r.rasterizeGlyphMSDF(a,t,n,o),i=n*n*3,l=new Uint8Array(r.memory.buffer,s,i),c=new Uint8Array(l);return{atlasSize:n,range:o,data:c}}resetArena(){this.wasm?.reset?.(),this.currentFontKey=null}measureFallback(t,n){return{width:t.length*n.size*this.fallbackFactor}}measureViaWasm(t,n,o){let a=$6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=rs(o,u);o.setFont(d.ptr,d.len,n.size,0,0),d.free(),this.currentFontKey=a}let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=rs(o,r),c=o.measure(s,i);return l(),{width:c}}},$6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var I$={butt:0,round:1,square:2},M$={miter:0,round:1,bevel:2},R$={M:0,L:1,Q:2,C:3,Z:4},Ph=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Dp(t,"WasmRasterizer.loadModule");this.wasm=n.exports}static async loadBundled(t={}){let n=new e(t),o=new URL("../wasm/rasterizer.wasm",import.meta.url);return await n.loadModule(o),n}flatten(t,n){let o=n>0?n:this.defaultTolerance;return this.wasm?this.flattenViaWasm(t,o,this.wasm):Dy.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):Dy.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=O$(t),r=rs(o,new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),s=o.alloc(4),i=o.alloc(4);try{o.flattenF32(r.ptr,a.length,n,s,i);let l=Jg(o.memory,s),c=Jg(o.memory,i);return Q6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=D$(t),s=rs(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=I$[o?.cap??"butt"],u=M$[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=Jg(a.memory,i),f=Jg(a.memory,l);return Q6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},Dh=new Float32Array(256),J6=e=>{if(Dh.length>=e)return;let t=Dh.length;for(;t<e;)t*=2;Dh=new Float32Array(t)},O$=e=>{J6(e.length*7);let t=Dh,n=0;for(let o of e)switch(t[n++]=R$[o.kind],o.kind){case"M":case"L":t[n++]=o.to.x,t[n++]=o.to.y;break;case"Q":t[n++]=o.control.x,t[n++]=o.control.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"C":t[n++]=o.control1.x,t[n++]=o.control1.y,t[n++]=o.control2.x,t[n++]=o.control2.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"Z":break}return t.subarray(0,n)},D$=e=>{J6(e.length*2);let t=Dh;for(let n=0;n<e.length;n++){let o=e[n];t[n*2]=o?.x??0,t[n*2+1]=o?.y??0}return t.subarray(0,e.length*2)},Jg=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),Q6=(e,t,n)=>{let o=new Float32Array(e.buffer,t,n*2),a=new Array(n);for(let r=0;r<n;r++)a[r]={x:v(o[r*2]),y:v(o[r*2+1])};return a};var tP=()=>typeof Worker<"u",eP=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",P$=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},B$=async()=>await UL()||GL()?"webgl2":Vg()&&tP()?"offscreen":"canvas2d",nP=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await B$(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:eP(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:eP()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:Vg()&&tP(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:P$()}},oP=e=>{let t=e.renderer==="webgl2"?"WebGL2":e.renderer==="offscreen"?"OffscreenCanvas + Worker":"Canvas2D";console.log("%c[diagram]%c renderer=%s, wasmText=%s, wasmRaster=%s, workers=%s, tiles=%s, touch=%s (%s)","color: #1a73e8; font-weight: 700","color: inherit",e.renderer,e.wasmText,e.wasmRaster,e.workers,e.tiles,e.touch,t)};var v3=new WeakMap,S3=new WeakSet,fQ=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>P(cP(),1)),o=t(e),a=n(o,!0),r=o.lsd.width,s=o.lsd.height;if(r<=0||s<=0||a.length===0)return{frames:[],totalMs:0};let i=new OffscreenCanvas(r,s),l=i.getContext("2d"),c=new OffscreenCanvas(r,s),u=c.getContext("2d");if(!l||!u)return{frames:[],totalMs:0};let d=[],f=0;for(let p of a){let h=new ImageData(new Uint8ClampedArray(p.patch),p.dims.width,p.dims.height);c.width=p.dims.width,c.height=p.dims.height,u.putImageData(h,0,0),l.drawImage(c,p.dims.left,p.dims.top);let m=await createImageBitmap(i);f+=p.delay>0?p.delay:100,d.push({bitmap:m,endMs:f}),p.disposalType===2&&l.clearRect(p.dims.left,p.dims.top,p.dims.width,p.dims.height)}return{frames:d,totalMs:f}},pQ={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=v3.get(e);if(!n)return S3.has(e)||(S3.add(e),fQ(e).then(r=>{v3.set(e,r),G2()}).catch(()=>{}).finally(()=>S3.delete(e))),null;if(n.frames.length===0)return null;let o=n.totalMs>0?t%n.totalMs:0;for(let r of n.frames)if(o<r.endMs)return r.bitmap;let a=n.frames[n.frames.length-1];return a?a.bitmap:null},totalDurationMs(e){return v3.get(e)?.totalMs??0}},uP=!1,dP=()=>{uP||(uP=!0,Ip(pQ))};var Bh=P(re(),1);var fP=e=>{let t=Pt(),[n]=(0,Bh.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,Bh.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,Bh.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var k3=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=hQ(e);if(!n)return null;let o={x:n.x-20,y:n.y-20,width:n.width+40,height:n.height+40},a=Math.max(1,Math.ceil(o.width*t.scale)),r=Math.max(1,Math.ceil(o.height*t.scale)),{canvas:s,target:i}=RL(a,r);t.background!=="transparent"&&(i.setFill(t.backgroundColor),i.beginPath(),i.rect(0,0,a,r),i.fill());let l={...e,viewport:{pan:{x:o.x,y:o.y},zoom:t.scale,rotation:0,size:{width:a,height:r},gridEnabled:e.viewport.gridEnabled,...e.viewport.gridStyle!==void 0?{gridStyle:e.viewport.gridStyle}:{}}};return t.background==="color-and-grid"&&l.viewport.gridEnabled&&Op(l,i),Xa(l,i,{skipClear:!0}),Bn(l,i),s.convertToBlob({type:"image/png"})},hQ=e=>{let t=null;for(let n of Lo(e))if(n.visible)for(let o of Ga(e,n.id)){let a=N(o);t=t?mQ(t,a):a}return t},mQ=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var pP=2,bu=e=>{typeof window<"u"&&window.alert(e)},hP=e=>{bu=e},_3=(e,t)=>{let n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),requestAnimationFrame(()=>{URL.revokeObjectURL(n)})},w3=e=>{let t=ZL(e,2);_3(new Blob([t],{type:"application/json"}),"scene.diagram.json")},T3=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="application/json,.json",t.onchange=()=>{let n=t.files?.[0];n&&n.text().then(o=>{try{let a=YL(o);e.loadScene(a)}catch(a){console.error("[diagram] failed to parse scene file:",a),bu("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},t.click()},mP=()=>{if(typeof document>"u")return"#ffffff";let e=document.querySelector('canvas[data-layer="main"]')??document.body;return getComputedStyle(e).getPropertyValue("--du-canvas-bg").trim()||"#ffffff"},Nh=async(e,t)=>{let n=await k3(e.scene,{background:t,scale:pP,backgroundColor:mP()});if(!n){bu("Nothing to export \u2014 the canvas is empty.");return}_3(n,"scene.png")},yP=e=>{let t=i3(e);_3(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},E3=async e=>{let t=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof t?.write!="function"||typeof ClipboardItem>"u"){bu("Copy to clipboard isn't supported in this browser.");return}let n=await k3(e.scene,{background:"color",scale:pP,backgroundColor:mP()});if(!n){bu("Nothing to copy \u2014 the canvas is empty.");return}try{await t.write([new ClipboardItem({"image/png":n})])}catch(o){console.error("[diagram] copy-as-image failed:",o),bu("Couldn't copy the image to the clipboard.")}},yQ=[{id:"save-scene",label:"Save as JSON",category:"other",viewMode:!0,hotkey:{key:"s",meta:!0},perform:({editor:e})=>{w3(e.scene)}},{id:"open-scene",label:"Open\u2026",category:"other",hotkey:{key:"o",meta:!0},perform:({editor:e})=>{T3(e)}},{id:"export-png",label:"Export as PNG",category:"other",viewMode:!0,hotkey:{key:"e",meta:!0,shift:!0},perform:({editor:e})=>{Nh(e,"color")}},{id:"copy-as-image",label:"Copy as image",category:"other",viewMode:!0,hotkey:{key:"c",shift:!0,alt:!0},perform:({editor:e})=>{E3(e)}}],gP=(e=we)=>{for(let t of yQ)e.replace(t)};var gQ=14,xQ=14,bQ=16,C3=1.75,pt={size:gQ,strokeWidth:C3},ws={size:xQ,strokeWidth:C3},rx={size:bQ,strokeWidth:C3},AQ="https://github.com/oh-just-another/diagram",zh=(0,ye.forwardRef)(function(t,n){let{initialScene:o,initialTool:a="select",grid:r,snap:s,templates:i,fileDropHandlers:l,layoutKinds:c,animationAdapters:u,onReady:d,onSceneChange:f,onSelectionChange:p,capabilities:h,workerFactory:m,hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,theme:Oe,defaultTheme:qt="system",onThemeChange:xn,persistTheme:Bo,repositoryUrl:St,onConfirm:Hh,onNotify:Uh,className:Gh,style:Wh}=t,Au=(0,ye.useMemo)(()=>Bo===!0?"diagram-theme":typeof Bo=="string"?Bo:null,[Bo]),[LP,kP]=(0,ye.useState)(()=>{if(!Au||typeof window>"u")return qt;let X=window.localStorage.getItem(Au);return X==="light"||X==="dark"||X==="system"?X:qt}),qh=Oe??LP,_P=fP(qh),wP=(0,ye.useCallback)(X=>{Oe===void 0&&kP(X),Au&&typeof window<"u"&&window.localStorage.setItem(Au,X),xn?.(X)},[Oe,xn,Au]),M3=r?.enabled,R3=r?.style,vu=(0,ye.useMemo)(()=>sv({...o?{saved:o}:{},hostSettings:TQ(M3,R3,s)}),[o,M3,R3,s]),O3=(0,ye.useMemo)(()=>{for(let X of vu.elements.values())if(pe(X))return!0;return!1},[vu]);(0,ye.useEffect)(()=>{if(dP(),i)for(let X of i)Di.register(X);if(c)for(let X of c)hv(X);if(u)for(let X of u)Ip(X)},[i,c,u]);let[Ts,TP]=(0,ye.useState)(null),[Vh,EP]=(0,ye.useState)(null),[jh,CP]=(0,ye.useState)(null),[IP,D3]=(0,ye.useState)(!1),[ix,P3]=(0,ye.useState)(!1),B3=(0,ye.useRef)(null),N3=(0,ye.useRef)(!1);(0,ye.useEffect)(()=>{let X=!1;return(async()=>{B3.current??=nP(h);let Un=await B3.current;if(X)return;N3.current||(N3.current=!0,oP(Un)),TP(Un);let Es=[];Es.push(q8(document).then(()=>{X||P3(!0)},$t=>{X||P3(!0),console.warn("[diagram] bundled fonts load failed",$t)})),Un.wasmText&&Es.push(Oh.loadBundled().then($t=>{X||(Pp($t),EP($t),D3(!0))},$t=>{X||(D3(!0),console.warn("[diagram] WASM text shaper load failed",$t))})),Un.wasmRaster&&Es.push(Ph.loadBundled().then($t=>{X||(Bp($t),CP($t))},$t=>{console.warn("[diagram] WASM rasterizer load failed",$t)})),await Promise.allSettled(Es)})(),()=>{X=!0}},[h]);let[xe,MP]=(0,ye.useState)(null),RP=(0,ye.useCallback)(X=>{if(l)for(let Un of l)X.registerFileDropHandler(Un);MP(X),d?.(X)},[l,d]);return(0,ye.useEffect)(()=>{xe&&(!Vh&&!jh||xe.setActiveTool(xe.activeTool.type))},[xe,Vh,jh]),(0,ye.useEffect)(()=>{xe&&xe.forceRender()},[xe,u]),(0,ye.useEffect)(()=>{xe&&ix&&xe.forceRender()},[xe,ix]),(0,ye.useEffect)(()=>{if(!xe||!f&&!p)return;let X=xe.scene,Un=xe.selection;return xe.subscribe(()=>{f&&xe.scene!==X&&(X=xe.scene,f(xe.scene)),p&&xe.selection!==Un&&(Un=xe.selection,p(xe.selection))})},[xe,f,p]),(0,ye.useEffect)(()=>{if(!xe)return;let X=xe,Un=Qt=>{oa(Qt.target)||(X.setSnapSuppressed(Qt.metaKey||Qt.ctrlKey),X.setTransformModifiers({alt:Qt.altKey,shift:Qt.shiftKey}))},Es=Qt=>{Un(Qt),!oa(Qt.target)&&Qt.key==="Escape"&&X.flowchartPreview!==null&&(X.cancelFlowchart(),Qt.preventDefault())},$t=Qt=>{Un(Qt),!Qt.metaKey&&!Qt.ctrlKey&&X.flowchartPreview!==null&&X.commitFlowchart()},z3=()=>{X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1}),X.flowchartPreview!==null&&X.commitFlowchart()};return window.addEventListener("keydown",Es),window.addEventListener("keyup",$t),window.addEventListener("blur",z3),()=>{window.removeEventListener("keydown",Es),window.removeEventListener("keyup",$t),window.removeEventListener("blur",z3),X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1})}},[xe]),(0,ye.useImperativeHandle)(n,()=>({editor:xe,capabilities:Ts,getScene:()=>xe?.scene??vu,loadScene:X=>xe?.loadScene(X),getActiveTool:()=>xe?.activeTool??null,setActiveTool:X=>xe?.setActiveTool(X),getSelection:()=>xe?.selection??new Set,setSelection:X=>xe?.setSelection(X),undo:()=>{xe?.undo()},redo:()=>{xe?.redo()},zoomToFit:()=>{xe?.zoomToFit()}}),[xe,vu,Ts]),Ts?O3&&!ix?(0,R.jsx)("div",{className:Gh,style:Wh}):Ts.renderer==="webgl2"&&Ts.wasmText&&!IP&&O3?(0,R.jsx)("div",{className:Gh,style:Wh}):(0,R.jsx)(Ef,{container:_P,children:(0,R.jsx)(g3,{children:(0,R.jsx)(rA,{children:(0,R.jsx)("div",{className:Gh,"data-diagram-root":!0,...qh==="system"?{}:{"data-theme":qh},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...Wh},children:(0,R.jsx)(WL,{initialScene:vu,initialTool:a,onReady:RP,renderer:Ts.renderer,...Ts.renderer==="offscreen"?{workerFactory:m??DL}:{},...Vh?{textShaper:Vh}:{},...jh?{rasterizer:jh}:{},children:(0,R.jsx)(m3,{children:(0,R.jsx)(vQ,{hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,repositoryUrl:St,onConfirm:Hh,onNotify:Uh,theme:qh,changeTheme:wP})})})})})})}):(0,R.jsx)("div",{className:Gh,style:Wh})});zh.displayName="Editor";var vQ=({hideTopBar:e,hideBottomBar:t,hideToolbar:n,hideLibraryButton:o,hideMainMenu:a,hideZoomControls:r,hideResetToContent:s,hideHelpButton:i,hideContextMenu:l,hideSelectionPanel:c,hideDrawingPanel:u,minimap:d,renderTopBarLeft:f,renderTopBarCenter:p,renderTopBarRight:h,renderBottomBarLeft:m,renderBottomBarCenter:x,renderBottomBarRight:y,renderMainMenuExtras:g,onImportTemplates:b,repositoryUrl:A,onConfirm:_,onNotify:C,theme:w,changeTheme:L})=>{let k=U(),{zen:M}=y3(),B=A===void 0?AQ:A,G=_??(St=>window.confirm(St)),ie=C??(St=>{window.alert(St)});(0,ye.useEffect)(()=>{gP(),hP(ie)},[ie]),Ka();let ne=uL(),V=Jp(),[ve,ge]=(0,ye.useState)(!1),[ee,Se]=(0,ye.useState)(!1);eL(()=>{Se(St=>!St)});let Oe=240,qt=12,xn=!V&&ve?Oe+qt:qt,Bo=(0,ye.useMemo)(()=>o?[...$g]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(Qd,{...rx}),title:"Templates library",active:ve,onClick:()=>{ge(St=>!St)}},{kind:"divider"},...$g],[o,ve]);return(0,R.jsxs)("div",{style:{position:"absolute",inset:0},onDragEnter:ne.onDragEnter,onDragOver:ne.onDragOver,onDragLeave:ne.onDragLeave,onDrop:ne.onDrop,children:[(0,R.jsxs)("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0},children:[(0,R.jsx)(qL,{style:{position:"absolute",inset:0}}),(0,R.jsx)($L,{}),(0,R.jsx)(QL,{}),(0,R.jsx)(JL,{}),(0,R.jsx)(e3,{}),(0,R.jsx)(t3,{}),!l&&(0,R.jsx)(l3,{items:u3})]}),!n&&!M?(0,R.jsx)(a3,{orientation:"vertical",items:Bo,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${xn}px)`,transform:"translateY(-50%)",zIndex:60}}):null,(0,R.jsxs)(lA,{children:[!e&&!M&&(0,R.jsx)(cA,{left:(0,R.jsxs)(oi,{ariaLabel:"Logo and main menu",children:[(0,R.jsx)("span",{"aria-label":"Diagram",title:"Diagram",className:"du-icon-button",style:{minWidth:36,padding:"0 10px",cursor:"default",fontWeight:600,letterSpacing:.5},children:"\u2317"}),!a&&(0,R.jsxs)(Q,{children:[(0,R.jsxs)(Q.Group,{title:"File",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(qd,{...pt}),onClick:()=>{k&&T3(k)},shortcut:dt({key:"O",meta:!0}),children:"Open\u2026"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Wd,{...pt}),onClick:()=>{k&&w3(k.scene)},disabled:!k,shortcut:dt({key:"S",meta:!0}),children:"Save as JSON"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ur,{...pt}),onClick:()=>{k&&E3(k)},disabled:!k,shortcut:dt({key:"C",shift:!0,alt:!0}),children:"Copy as image"}),(0,R.jsxs)(Q.Submenu,{icon:(0,R.jsx)(tc,{...pt}),label:"Export\u2026",disabled:!k,children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"transparent"),disabled:!k,children:"PNG (transparent)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"color"),disabled:!k,shortcut:dt({key:"E",meta:!0,shift:!0}),children:"PNG (with background)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"color-and-grid"),disabled:!k,children:"PNG (with background + grid)"}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(tc,{...pt}),onClick:()=>{k&&yP(k.scene)},disabled:!k,children:"SVG"})]}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(hf,{...pt}),onClick:()=>{k&&G("Reset canvas? This clears all shapes.")&&k.clear()},disabled:!k,children:"Reset canvas"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Edit",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ti,{...pt}),shortcut:"\u2318Z",onClick:()=>k?.undo(),disabled:!k,children:"Undo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ei,{...pt}),shortcut:"\u21E7\u2318Z",onClick:()=>k?.redo(),disabled:!k,children:"Redo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(mf,{...pt}),shortcut:"\u2318X",onClick:()=>k?.cutSelected(),disabled:!k,children:"Cut"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ur,{...pt}),shortcut:"\u2318C",onClick:()=>k?.copySelected(),disabled:!k,children:"Copy"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Nd,{...pt}),shortcut:"\u2318V",onClick:()=>k?.paste(),disabled:!k,children:"Paste"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(lf,{...pt}),shortcut:"\u2318A",onClick:()=>k?.selectAll(),disabled:!k,children:"Select all"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Fd,{...pt}),shortcut:"\u232B",onClick:()=>k?.deleteSelected(),disabled:!k,children:"Delete selected"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"View",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(nc,{...pt}),shortcut:"\u21E7F",onClick:()=>k?.zoomToFit(),disabled:!k,children:"Fit to screen"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Tf,{...pt}),shortcut:"\u2318+",onClick:()=>k?.zoomIn(),disabled:!k,children:"Zoom in"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(wf,{...pt}),shortcut:"\u2318\u2212",onClick:()=>k?.zoomOut(),disabled:!k,children:"Zoom out"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Group,{title:"Theme",children:(0,R.jsx)(Q.Toggle,{value:w,onChange:L,options:[{value:"light",label:"Light",icon:(0,R.jsx)(Af,{...ws})},{value:"dark",label:"Dark",icon:(0,R.jsx)(rf,{...ws})},{value:"system",label:"System",icon:(0,R.jsx)(af,{...ws})}]})}),(0,R.jsx)(Q.Group,{title:"Grid",children:(0,R.jsx)(Q.Toggle,{value:EQ(k),onChange:St=>{IQ(k,St)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(Ao,{...ws})},{value:"dots",label:"Dots",icon:(0,R.jsx)(Xd,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...ws})}]})}),(0,R.jsx)(Q.Group,{title:"Snap to grid",children:(0,R.jsx)(Q.Toggle,{value:CQ(k),onChange:St=>{k?.setSnapToGrid(St==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)(nf,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...ws})}]})}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Help",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Cn,{...pt}),shortcut:"?",onClick:()=>{Se(!0)},children:"Hotkeys"}),B?(0,R.jsx)(Q.ItemLink,{href:B,external:!0,children:"GitHub"}):null]}),g?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Q.Separator,{}),g()]}):null]}),f?f():null]}),center:p?.(),right:(0,R.jsx)(oi,{ariaLabel:"Top bar actions",children:h?h():null})}),!t&&!M&&(0,R.jsx)(uA,{left:m?m():null,center:x?x():s?null:(0,R.jsx)(aL,{}),right:y?y():r?i?null:(0,R.jsx)(fg,{}):(0,R.jsx)(wQ,{trailing:i?void 0:(0,R.jsx)(fg,{})})}),M?null:V?ve?(0,R.jsx)(KL,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:St=>{St<=0&&ge(!1)},children:(0,R.jsx)(vg,{open:!0,sheet:!0,onClose:()=>{ge(!1)},...b?{onImport:b}:{}})}):null:(0,R.jsx)(vg,{open:ve,side:"left",style:{left:0},onClose:()=>{ge(!1)},...b?{onImport:b}:{}})]}),d&&!M&&(0,R.jsx)("div",{style:{position:"absolute",right:"var(--du-bar-inset, 12px)",bottom:"calc(var(--du-bar-inset, 12px) + 52px)",border:"1px solid var(--du-border, #d0d0d0)",borderRadius:6,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",overflow:"hidden",zIndex:40},children:(0,R.jsx)(VL,{})}),!u&&!M&&(0,R.jsx)("div",{style:{position:"absolute",top:"calc(var(--du-bar-inset, 12px) + 52px)",right:"var(--du-bar-inset, 12px)",zIndex:40},children:(0,R.jsx)(jL,{})}),!c&&!M&&(0,R.jsx)(_L,{}),(0,R.jsx)($p,{open:ee,onClose:()=>{Se(!1)}}),(0,R.jsx)(d3,{}),(0,R.jsx)(p3,{}),(0,R.jsx)(h3,{}),void 0]})},SQ=dt({meta:!0,key:"\u2212"}),LQ=dt({meta:!0,key:"+"}),kQ=dt({meta:!0,key:"0"}),_Q=dt({alt:!0,key:"1"}),wQ=({trailing:e})=>{let t=U(),[,n]=(0,ye.useState)(0);if((0,ye.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(oi,{ariaLabel:"Zoom",children:[(0,R.jsx)(Jn,{label:`Zoom out (${SQ})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(Ba,{...rx})}),(0,R.jsx)(ni,{content:`Reset zoom to 100% (${kQ})`,children:(0,R.jsxs)("button",{type:"button",className:"du-icon-button","aria-label":"Reset zoom to 100%",onClick:()=>{t.resetZoom()},style:{minWidth:56,padding:"0 8px",borderRadius:0},children:[Math.round(o*100),"%"]})}),(0,R.jsx)(Jn,{label:`Zoom in (${LQ})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Js,{...rx})}),(0,R.jsx)(Jn,{label:`Fit to screen (${_Q})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(nc,{...rx})}),e]})},TQ=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),EQ=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},CQ=e=>e?.snapToGridEnabled??!0?"on":"off",IQ=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var xP=`/**
168
171
  * Diagram UI stylesheet. Imported once by the host:
169
172
  *
170
173
  * import "@oh-just-another/react-ui/styles.css";
@@ -1664,7 +1667,7 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
1664
1667
  color: var(--du-fg, #1c1c1e);
1665
1668
  }
1666
1669
 
1667
- /* Inline link caption editor. */
1670
+ /* Inline link caption editor (multiline textarea). */
1668
1671
  .du-link-caption-input {
1669
1672
  min-width: 60px;
1670
1673
  max-width: 220px;
@@ -1672,6 +1675,7 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
1672
1675
  font:
1673
1676
  12px system-ui,
1674
1677
  sans-serif;
1678
+ line-height: 1.25;
1675
1679
  text-align: center;
1676
1680
  color: var(--du-fg, #222);
1677
1681
  background: var(--du-panel-bg, #fff);
@@ -1679,6 +1683,8 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
1679
1683
  border-radius: 4px;
1680
1684
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
1681
1685
  outline: none;
1686
+ resize: none;
1687
+ overflow: hidden;
1682
1688
  }
1683
1689
 
1684
1690
  /* Mini shape-picker shown after a link is dropped on empty canvas. */
@@ -1716,7 +1722,7 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
1716
1722
  outline: 2px solid var(--du-accent, #5082ff);
1717
1723
  outline-offset: -2px;
1718
1724
  }
1719
- `;var u3=P(se(),1),z6=new Set(["dark","light","system"]),n$=new Set(["canvas2d","webgl2","offscreen"]),Xg=null,o$=()=>(Xg||(Xg=new CSSStyleSheet,Xg.replaceSync(N6.replace(/:root\b/g,":host"))),Xg),Ch=class extends HTMLElement{static get observedAttributes(){return["theme","renderer","grid","snap"]}#n=null;#r=null;#s=null;#e=null;#o=null;#t=void 0;connectedCallback(){if(this.#n)return;let t=this.shadowRoot??this.attachShadow({mode:"open"});t.adoptedStyleSheets=[o$()],this.style.display||(this.style.display="block");let n=document.createElement("div");n.style.cssText="width:100%;height:100%;position:relative";let o=document.createElement("div");o.style.cssText="width:100%;height:100%";let a=document.createElement("div");this.#r=a,n.append(o,a),t.append(n),this.#s=n,this.#i(),this.#n=(0,F6.createRoot)(o),this.#l()}disconnectedCallback(){this.#o?.(),this.#o=null,this.#n?.unmount(),this.#n=null,this.#e=null,this.#r=null,this.#s=null}attributeChangedCallback(t){t==="theme"&&this.#i(),this.#n&&this.#l()}#i(){let t=this.#s;if(!t)return;let n=this.getAttribute("theme");n==="dark"||n==="light"?t.dataset.theme=n:delete t.dataset.theme}get scene(){return this.#e?this.#e.getScene():this.#t}set scene(t){this.#t=t,this.#e&&t&&this.#e.loadScene(t)}get theme(){let t=this.getAttribute("theme");return t&&z6.has(t)?t:null}set theme(t){t?this.setAttribute("theme",t):this.removeAttribute("theme")}get editor(){return this.#e?.editor??null}getScene(){return this.#e?.getScene()}loadScene(t){this.#t=t,this.#e?.loadScene(t)}undo(){this.#e?.undo()}redo(){this.#e?.redo()}zoomToFit(){this.#e?.zoomToFit()}getMode(){return this.#e?.getMode()??null}setMode(t){this.#e?.setMode(t)}getSelection(){return this.#e?.getSelection()??new Set}setSelection(t){this.#e?.setSelection(t)}#a(t,n){this.dispatchEvent(new CustomEvent(t,{detail:n}))}#c(){let t=this.getAttribute("theme"),n=this.getAttribute("renderer"),o=t&&z6.has(t)?t:void 0,a=n&&n$.has(n)?n:void 0;return{...this.#t?{initialScene:this.#t}:{},grid:{enabled:this.hasAttribute("grid")},snap:this.hasAttribute("snap"),...o?{theme:o}:{},...a?{capabilities:{renderer:a}}:{},onReady:r=>{this.#o?.(),this.#o=wy(r),this.#t&&r.loadScene(this.#t),this.#a("ready",{editor:r})},onSceneChange:r=>{this.#a("scenechange",r)},onSelectionChange:r=>{this.#a("selectionchange",[...r])},onThemeChange:r=>{this.#a("themechange",r)}}}#l(){this.#n?.render((0,u3.jsx)(Lf,{container:this.#r,children:(0,u3.jsx)(_h,{ref:t=>{this.#e=t},...this.#c()})}))}};var a$=["ready","scenechange","selectionchange","themechange"],H6=(e,t,n)=>{n?e.setAttribute(t,""):e.removeAttribute(t)},U6=(e,t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)},r$=(e,t)=>{U6(e,"theme",t.theme),U6(e,"renderer",t.renderer),H6(e,"grid",t.grid??!1),H6(e,"snap",t.snap??!1),t.scene!==void 0&&(e.scene=t.scene)},s$=(e,t)=>{let n=[],o=(a,r)=>{if(!r)return;let s=i=>{r(i.detail)};e.addEventListener(a,s),n.push(()=>{e.removeEventListener(a,s)})};return o("ready",t.ready),o("scenechange",t.scenechange),o("selectionchange",t.selectionchange),o("themechange",t.themechange),()=>{for(let a of n)a()}},i$=e=>({getScene:()=>e()?.getScene(),loadScene:t=>e()?.loadScene(t),undo:()=>e()?.undo(),redo:()=>e()?.redo(),zoomToFit:()=>e()?.zoomToFit(),getMode:()=>e()?.getMode()??null,setMode:t=>e()?.setMode(t),getSelection:()=>e()?.getSelection()??new Set,setSelection:t=>e()?.setSelection(t)});var l$="oja-diagram",c$=(e=l$)=>{typeof customElements>"u"||customElements.get(e)||customElements.define(e,Ch)};c$();export{a$ as OJA_DIAGRAM_EVENTS,l$ as OJA_DIAGRAM_TAG,Ch as OjaDiagramElement,r$ as applyOjaDiagramProps,s$ as bindOjaDiagramEvents,c$ as defineOjaDiagram,i$ as ojaDiagramController};
1725
+ `;var I3=P(se(),1),bP=new Set(["dark","light","system"]),MQ=new Set(["canvas2d","webgl2","offscreen"]),sx=null,RQ=()=>(sx||(sx=new CSSStyleSheet,sx.replaceSync(xP.replace(/:root\b/g,":host"))),sx),Fh=class extends HTMLElement{static get observedAttributes(){return["theme","renderer","grid","snap"]}#n=null;#r=null;#s=null;#e=null;#o=null;#t=void 0;connectedCallback(){if(this.#n)return;let t=this.shadowRoot??this.attachShadow({mode:"open"});t.adoptedStyleSheets=[RQ()],this.style.display||(this.style.display="block");let n=document.createElement("div");n.style.cssText="width:100%;height:100%;position:relative";let o=document.createElement("div");o.style.cssText="width:100%;height:100%";let a=document.createElement("div");this.#r=a,n.append(o,a),t.append(n),this.#s=n,this.#i(),this.#n=(0,AP.createRoot)(o),this.#l()}disconnectedCallback(){this.#o?.(),this.#o=null,this.#n?.unmount(),this.#n=null,this.#e=null,this.#r=null,this.#s=null}attributeChangedCallback(t){t==="theme"&&this.#i(),this.#n&&this.#l()}#i(){let t=this.#s;if(!t)return;let n=this.getAttribute("theme");n==="dark"||n==="light"?t.dataset.theme=n:delete t.dataset.theme}get scene(){return this.#e?this.#e.getScene():this.#t}set scene(t){this.#t=t,this.#e&&t&&this.#e.loadScene(t)}get theme(){let t=this.getAttribute("theme");return t&&bP.has(t)?t:null}set theme(t){t?this.setAttribute("theme",t):this.removeAttribute("theme")}get editor(){return this.#e?.editor??null}getScene(){return this.#e?.getScene()}loadScene(t){this.#t=t,this.#e?.loadScene(t)}undo(){this.#e?.undo()}redo(){this.#e?.redo()}zoomToFit(){this.#e?.zoomToFit()}getActiveTool(){return this.#e?.getActiveTool()??null}setActiveTool(t){this.#e?.setActiveTool(t)}getSelection(){return this.#e?.getSelection()??new Set}setSelection(t){this.#e?.setSelection(t)}#a(t,n){this.dispatchEvent(new CustomEvent(t,{detail:n}))}#c(){let t=this.getAttribute("theme"),n=this.getAttribute("renderer"),o=t&&bP.has(t)?t:void 0,a=n&&MQ.has(n)?n:void 0;return{...this.#t?{initialScene:this.#t}:{},grid:{enabled:this.hasAttribute("grid")},snap:this.hasAttribute("snap"),...o?{theme:o}:{},...a?{capabilities:{renderer:a}}:{},onReady:r=>{this.#o?.(),this.#o=Hy(r),this.#t&&r.loadScene(this.#t),this.#a("ready",{editor:r})},onSceneChange:r=>{this.#a("scenechange",r)},onSelectionChange:r=>{this.#a("selectionchange",[...r])},onThemeChange:r=>{this.#a("themechange",r)}}}#l(){this.#n?.render((0,I3.jsx)(Ef,{container:this.#r,children:(0,I3.jsx)(zh,{ref:t=>{this.#e=t},...this.#c()})}))}};var OQ=["ready","scenechange","selectionchange","themechange"],vP=(e,t,n)=>{n?e.setAttribute(t,""):e.removeAttribute(t)},SP=(e,t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)},DQ=(e,t)=>{SP(e,"theme",t.theme),SP(e,"renderer",t.renderer),vP(e,"grid",t.grid??!1),vP(e,"snap",t.snap??!1),t.scene!==void 0&&(e.scene=t.scene)},PQ=(e,t)=>{let n=[],o=(a,r)=>{if(!r)return;let s=i=>{r(i.detail)};e.addEventListener(a,s),n.push(()=>{e.removeEventListener(a,s)})};return o("ready",t.ready),o("scenechange",t.scenechange),o("selectionchange",t.selectionchange),o("themechange",t.themechange),()=>{for(let a of n)a()}},BQ=e=>({getScene:()=>e()?.getScene(),loadScene:t=>e()?.loadScene(t),undo:()=>e()?.undo(),redo:()=>e()?.redo(),zoomToFit:()=>e()?.zoomToFit(),getActiveTool:()=>e()?.getActiveTool()??null,setActiveTool:t=>e()?.setActiveTool(t),getSelection:()=>e()?.getSelection()??new Set,setSelection:t=>e()?.setSelection(t)});var NQ="oja-diagram",zQ=(e=NQ)=>{typeof customElements>"u"||customElements.get(e)||customElements.define(e,Fh)};zQ();export{OQ as OJA_DIAGRAM_EVENTS,NQ as OJA_DIAGRAM_TAG,Fh as OjaDiagramElement,DQ as applyOjaDiagramProps,PQ as bindOjaDiagramEvents,zQ as defineOjaDiagram,BQ as ojaDiagramController};
1720
1726
  /*! Bundled license information:
1721
1727
 
1722
1728
  scheduler/cjs/scheduler.production.js: