@oh-just-another/diagram 0.1.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +68 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/bindings.d.ts +73 -0
  5. package/dist/bindings.d.ts.map +1 -0
  6. package/dist/bindings.js +77 -0
  7. package/dist/bindings.js.map +1 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +20 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/oja-diagram-element.d.ts +42 -0
  13. package/dist/oja-diagram-element.d.ts.map +1 -0
  14. package/dist/oja-diagram-element.js +202 -0
  15. package/dist/oja-diagram-element.js.map +1 -0
  16. package/dist/oja-diagram.global.js +1846 -0
  17. package/dist/oja-diagram.global.js.map +7 -0
  18. package/dist/render-worker.js +5 -0
  19. package/dist/render-worker.js.map +7 -0
  20. package/dist/styles.generated.d.ts +2 -0
  21. package/dist/styles.generated.d.ts.map +1 -0
  22. package/dist/styles.generated.js +4 -0
  23. package/dist/styles.generated.js.map +1 -0
  24. package/fonts/LICENSE +25 -0
  25. package/fonts/PTSerif-Bold.woff2 +0 -0
  26. package/fonts/PTSerif-BoldItalic.woff2 +0 -0
  27. package/fonts/PTSerif-Italic.woff2 +0 -0
  28. package/fonts/PTSerif-Regular.woff2 +0 -0
  29. package/fonts/Roboto-Bold.woff2 +0 -0
  30. package/fonts/Roboto-BoldItalic.woff2 +0 -0
  31. package/fonts/Roboto-Italic.woff2 +0 -0
  32. package/fonts/Roboto-Regular.woff2 +0 -0
  33. package/fonts/RobotoMono-Bold.woff2 +0 -0
  34. package/fonts/RobotoMono-BoldItalic.woff2 +0 -0
  35. package/fonts/RobotoMono-Italic.woff2 +0 -0
  36. package/fonts/RobotoMono-Regular.woff2 +0 -0
  37. package/package.json +72 -0
  38. package/wasm/rasterizer.wasm +0 -0
  39. package/wasm/text_shaper.wasm +0 -0
@@ -0,0 +1,1846 @@
1
+ var dM=Object.create;var Ey=Object.defineProperty;var fM=Object.getOwnPropertyDescriptor;var pM=Object.getOwnPropertyNames;var hM=Object.getPrototypeOf,mM=Object.prototype.hasOwnProperty;var Dt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),no=(e,t)=>{for(var n in t)Ey(e,n,{get:t[n],enumerable:!0})},yM=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pM(t))!mM.call(e,a)&&a!==n&&Ey(e,a,{get:()=>t[a],enumerable:!(o=fM(t,a))||o.enumerable});return e};var F=(e,t,n)=>(n=e!=null?dM(hM(e)):{},yM(t||!e||!e.__esModule?Ey(n,"default",{value:e,enumerable:!0}):n,e));var DL=Dt(Ue=>{"use strict";function Dy(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Ip(a,t))e[o]=t,e[n]=a,n=o;else break e}}function vo(e){return e.length===0?null:e[0]}function Mp(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>Ip(i,n))l<a&&0>Ip(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Ip(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Ip(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}Ue.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(wL=performance,Ue.unstable_now=function(){return wL.now()}):(My=Date,_L=My.now(),Ue.unstable_now=function(){return My.now()-_L});var wL,My,_L,Xo=[],ja=[],gM=1,wn=null,Pt=3,Py=!1,Pc=!1,Bc=!1,By=!1,IL=typeof setTimeout=="function"?setTimeout:null,EL=typeof clearTimeout=="function"?clearTimeout:null,CL=typeof setImmediate<"u"?setImmediate:null;function Ep(e){for(var t=vo(ja);t!==null;){if(t.callback===null)Mp(ja);else if(t.startTime<=e)Mp(ja),t.sortIndex=t.expirationTime,Dy(Xo,t);else break;t=vo(ja)}}function zy(e){if(Bc=!1,Ep(e),!Pc)if(vo(Xo)!==null)Pc=!0,Mi||(Mi=!0,Ei());else{var t=vo(ja);t!==null&&Ny(zy,t.startTime-e)}}var Mi=!1,zc=-1,ML=5,OL=-1;function RL(){return By?!0:!(Ue.unstable_now()-OL<ML)}function Oy(){if(By=!1,Mi){var e=Ue.unstable_now();OL=e;var t=!0;try{e:{Pc=!1,Bc&&(Bc=!1,EL(zc),zc=-1),Py=!0;var n=Pt;try{t:{for(Ep(e),wn=vo(Xo);wn!==null&&!(wn.expirationTime>e&&RL());){var o=wn.callback;if(typeof o=="function"){wn.callback=null,Pt=wn.priorityLevel;var a=o(wn.expirationTime<=e);if(e=Ue.unstable_now(),typeof a=="function"){wn.callback=a,Ep(e),t=!0;break t}wn===vo(Xo)&&Mp(Xo),Ep(e)}else Mp(Xo);wn=vo(Xo)}if(wn!==null)t=!0;else{var r=vo(ja);r!==null&&Ny(zy,r.startTime-e),t=!1}}break e}finally{wn=null,Pt=n,Py=!1}t=void 0}}finally{t?Ei():Mi=!1}}}var Ei;typeof CL=="function"?Ei=function(){CL(Oy)}:typeof MessageChannel<"u"?(Ry=new MessageChannel,TL=Ry.port2,Ry.port1.onmessage=Oy,Ei=function(){TL.postMessage(null)}):Ei=function(){IL(Oy,0)};var Ry,TL;function Ny(e,t){zc=IL(function(){e(Ue.unstable_now())},t)}Ue.unstable_IdlePriority=5;Ue.unstable_ImmediatePriority=1;Ue.unstable_LowPriority=4;Ue.unstable_NormalPriority=3;Ue.unstable_Profiling=null;Ue.unstable_UserBlockingPriority=2;Ue.unstable_cancelCallback=function(e){e.callback=null};Ue.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"):ML=0<e?Math.floor(1e3/e):5};Ue.unstable_getCurrentPriorityLevel=function(){return Pt};Ue.unstable_next=function(e){switch(Pt){case 1:case 2:case 3:var t=3;break;default:t=Pt}var n=Pt;Pt=t;try{return e()}finally{Pt=n}};Ue.unstable_requestPaint=function(){By=!0};Ue.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Pt;Pt=e;try{return t()}finally{Pt=n}};Ue.unstable_scheduleCallback=function(e,t,n){var o=Ue.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:gM++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,Dy(ja,e),vo(Xo)===null&&e===vo(ja)&&(Bc?(EL(zc),zc=-1):Bc=!0,Ny(zy,n-o))):(e.sortIndex=a,Dy(Xo,e),Pc||Py||(Pc=!0,Mi||(Mi=!0,Ei()))),e};Ue.unstable_shouldYield=RL;Ue.unstable_wrapCallback=function(e){var t=Pt;return function(){var n=Pt;Pt=t;try{return e.apply(this,arguments)}finally{Pt=n}}}});var BL=Dt((Hj,PL)=>{"use strict";PL.exports=DL()});var ZL=Dt(ee=>{"use strict";var Uy=Symbol.for("react.transitional.element"),xM=Symbol.for("react.portal"),bM=Symbol.for("react.fragment"),AM=Symbol.for("react.strict_mode"),vM=Symbol.for("react.profiler"),LM=Symbol.for("react.consumer"),SM=Symbol.for("react.context"),kM=Symbol.for("react.forward_ref"),wM=Symbol.for("react.suspense"),_M=Symbol.for("react.memo"),UL=Symbol.for("react.lazy"),CM=Symbol.for("react.activity"),zL=Symbol.iterator;function TM(e){return e===null||typeof e!="object"?null:(e=zL&&e[zL]||e["@@iterator"],typeof e=="function"?e:null)}var GL={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qL=Object.assign,WL={};function Ri(e,t,n){this.props=e,this.context=t,this.refs=WL,this.updater=n||GL}Ri.prototype.isReactComponent={};Ri.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")};Ri.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function jL(){}jL.prototype=Ri.prototype;function Gy(e,t,n){this.props=e,this.context=t,this.refs=WL,this.updater=n||GL}var qy=Gy.prototype=new jL;qy.constructor=Gy;qL(qy,Ri.prototype);qy.isPureReactComponent=!0;var NL=Array.isArray;function Hy(){}var De={H:null,A:null,T:null,S:null},VL=Object.prototype.hasOwnProperty;function Wy(e,t,n){var o=n.ref;return{$$typeof:Uy,type:e,key:t,ref:o!==void 0?o:null,props:n}}function IM(e,t){return Wy(e.type,t,e.props)}function jy(e){return typeof e=="object"&&e!==null&&e.$$typeof===Uy}function EM(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var FL=/\/+/g;function Fy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?EM(""+e.key):t.toString(36)}function MM(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(Hy,Hy):(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 Oi(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 Uy:case xM:s=!0;break;case UL:return s=e._init,Oi(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+Fy(e,0):o,NL(a)?(n="",s!=null&&(n=s.replace(FL,"$&/")+"/"),Oi(a,t,n,"",function(c){return c})):a!=null&&(jy(a)&&(a=IM(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(FL,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(NL(e))for(var l=0;l<e.length;l++)o=e[l],r=i+Fy(o,l),s+=Oi(o,t,n,r,a);else if(l=TM(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+Fy(o,l++),s+=Oi(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return Oi(MM(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 Op(e,t,n){if(e==null)return e;var o=[],a=0;return Oi(e,o,"","",function(r){return t.call(n,r,a++)}),o}function OM(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 HL=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)},RM={map:Op,forEach:function(e,t,n){Op(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Op(e,function(){t++}),t},toArray:function(e){return Op(e,function(t){return t})||[]},only:function(e){if(!jy(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ee.Activity=CM;ee.Children=RM;ee.Component=Ri;ee.Fragment=bM;ee.Profiler=vM;ee.PureComponent=Gy;ee.StrictMode=AM;ee.Suspense=wM;ee.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=De;ee.__COMPILER_RUNTIME={__proto__:null,c:function(e){return De.H.useMemoCache(e)}};ee.cache=function(e){return function(){return e.apply(null,arguments)}};ee.cacheSignal=function(){return null};ee.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=qL({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!VL.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 Wy(e.type,a,o)};ee.createContext=function(e){return e={$$typeof:SM,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:LM,_context:e},e};ee.createElement=function(e,t,n){var o,a={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)VL.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 Wy(e,r,a)};ee.createRef=function(){return{current:null}};ee.forwardRef=function(e){return{$$typeof:kM,render:e}};ee.isValidElement=jy;ee.lazy=function(e){return{$$typeof:UL,_payload:{_status:-1,_result:e},_init:OM}};ee.memo=function(e,t){return{$$typeof:_M,type:e,compare:t===void 0?null:t}};ee.startTransition=function(e){var t=De.T,n={};De.T=n;try{var o=e(),a=De.S;a!==null&&a(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(Hy,HL)}catch(r){HL(r)}finally{t!==null&&n.types!==null&&(t.types=n.types),De.T=t}};ee.unstable_useCacheRefresh=function(){return De.H.useCacheRefresh()};ee.use=function(e){return De.H.use(e)};ee.useActionState=function(e,t,n){return De.H.useActionState(e,t,n)};ee.useCallback=function(e,t){return De.H.useCallback(e,t)};ee.useContext=function(e){return De.H.useContext(e)};ee.useDebugValue=function(){};ee.useDeferredValue=function(e,t){return De.H.useDeferredValue(e,t)};ee.useEffect=function(e,t){return De.H.useEffect(e,t)};ee.useEffectEvent=function(e){return De.H.useEffectEvent(e)};ee.useId=function(){return De.H.useId()};ee.useImperativeHandle=function(e,t,n){return De.H.useImperativeHandle(e,t,n)};ee.useInsertionEffect=function(e,t){return De.H.useInsertionEffect(e,t)};ee.useLayoutEffect=function(e,t){return De.H.useLayoutEffect(e,t)};ee.useMemo=function(e,t){return De.H.useMemo(e,t)};ee.useOptimistic=function(e,t){return De.H.useOptimistic(e,t)};ee.useReducer=function(e,t,n){return De.H.useReducer(e,t,n)};ee.useRef=function(e){return De.H.useRef(e)};ee.useState=function(e){return De.H.useState(e)};ee.useSyncExternalStore=function(e,t,n){return De.H.useSyncExternalStore(e,t,n)};ee.useTransition=function(){return De.H.useTransition()};ee.version="19.2.6"});var he=Dt((Gj,XL)=>{"use strict";XL.exports=ZL()});var KL=Dt(Ft=>{"use strict";var DM=he();function YL(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 Va(){}var Nt={d:{f:Va,r:function(){throw Error(YL(522))},D:Va,C:Va,L:Va,m:Va,X:Va,S:Va,M:Va},p:0,findDOMNode:null},PM=Symbol.for("react.portal");function BM(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:PM,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var Nc=DM.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function Rp(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}Ft.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Nt;Ft.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(YL(299));return BM(e,t,null,n)};Ft.flushSync=function(e){var t=Nc.T,n=Nt.p;try{if(Nc.T=null,Nt.p=2,e)return e()}finally{Nc.T=t,Nt.p=n,Nt.d.f()}};Ft.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,Nt.d.C(e,t))};Ft.prefetchDNS=function(e){typeof e=="string"&&Nt.d.D(e)};Ft.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=Rp(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?Nt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&Nt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};Ft.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=Rp(t.as,t.crossOrigin);Nt.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&&Nt.d.M(e)};Ft.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=Rp(n,t.crossOrigin);Nt.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})}};Ft.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=Rp(t.as,t.crossOrigin);Nt.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 Nt.d.m(e)};Ft.requestFormReset=function(e){Nt.d.r(e)};Ft.unstable_batchedUpdates=function(e,t){return e(t)};Ft.useFormState=function(e,t,n){return Nc.H.useFormState(e,t,n)};Ft.useFormStatus=function(){return Nc.H.useHostTransitionStatus()};Ft.version="19.2.6"});var Yo=Dt((Wj,QL)=>{"use strict";function $L(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($L)}catch(e){console.error(e)}}$L(),QL.exports=KL()});var u_=Dt(am=>{"use strict";var ut=BL(),k3=he(),zM=Yo();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 w3(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ku(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 _3(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 C3(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 JL(e){if(ku(e)!==e)throw Error(O(188))}function NM(e){var t=e.alternate;if(!t){if(t=ku(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 JL(a),e;if(r===o)return JL(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 T3(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=T3(e),t!==null)return t;e=e.sibling}return null}var ze=Object.assign,FM=Symbol.for("react.element"),Dp=Symbol.for("react.transitional.element"),Vc=Symbol.for("react.portal"),Fi=Symbol.for("react.fragment"),I3=Symbol.for("react.strict_mode"),wg=Symbol.for("react.profiler"),E3=Symbol.for("react.consumer"),oa=Symbol.for("react.context"),Ax=Symbol.for("react.forward_ref"),_g=Symbol.for("react.suspense"),Cg=Symbol.for("react.suspense_list"),vx=Symbol.for("react.memo"),Za=Symbol.for("react.lazy");Symbol.for("react.scope");var Tg=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var HM=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var eS=Symbol.iterator;function Fc(e){return e===null||typeof e!="object"?null:(e=eS&&e[eS]||e["@@iterator"],typeof e=="function"?e:null)}var UM=Symbol.for("react.client.reference");function Ig(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===UM?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Fi:return"Fragment";case wg:return"Profiler";case I3:return"StrictMode";case _g:return"Suspense";case Cg:return"SuspenseList";case Tg:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Vc:return"Portal";case oa:return e.displayName||"Context";case E3:return(e._context.displayName||"Context")+".Consumer";case Ax:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vx:return t=e.displayName||null,t!==null?t:Ig(e.type)||"Memo";case Za:t=e._payload,e=e._init;try{return Ig(e(t))}catch{}}return null}var Zc=Array.isArray,K=k3.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Le=zM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,cs={pending:!1,data:null,method:null,action:null},Eg=[],Hi=-1;function _o(e){return{current:e}}function At(e){0>Hi||(e.current=Eg[Hi],Eg[Hi]=null,Hi--)}function Me(e,t){Hi++,Eg[Hi]=e.current,e.current=t}var wo=_o(null),uu=_o(null),ar=_o(null),ph=_o(null);function hh(e,t){switch(Me(ar,t),Me(uu,e),Me(wo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?i3(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=i3(t),e=Kw(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}At(wo),Me(wo,e)}function al(){At(wo),At(uu),At(ar)}function Mg(e){e.memoizedState!==null&&Me(ph,e);var t=wo.current,n=Kw(t,e.type);t!==n&&(Me(uu,e),Me(wo,n))}function mh(e){uu.current===e&&(At(wo),At(uu)),ph.current===e&&(At(ph),vu._currentValue=cs)}var Vy,tS;function rs(e){if(Vy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Vy=t&&t[1]||"",tS=-1<n.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Vy+e+tS}var Zy=!1;function Xy(e,t){if(!e||Zy)return"";Zy=!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
+ `),c=i.split(`
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{Zy=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?rs(n):""}function GM(e,t){switch(e.tag){case 26:case 27:case 5:return rs(e.type);case 16:return rs("Lazy");case 13:return e.child!==t&&t!==null?rs("Suspense Fallback"):rs("Suspense");case 19:return rs("SuspenseList");case 0:case 15:return Xy(e.type,!1);case 11:return Xy(e.type.render,!1);case 1:return Xy(e.type,!0);case 31:return rs("Activity");default:return""}}function nS(e){try{var t="",n=null;do t+=GM(e,n),n=e,e=e.return;while(e);return t}catch(o){return`
7
+ Error generating stack: `+o.message+`
8
+ `+o.stack}}var Og=Object.prototype.hasOwnProperty,Lx=ut.unstable_scheduleCallback,Yy=ut.unstable_cancelCallback,qM=ut.unstable_shouldYield,WM=ut.unstable_requestPaint,dn=ut.unstable_now,jM=ut.unstable_getCurrentPriorityLevel,M3=ut.unstable_ImmediatePriority,O3=ut.unstable_UserBlockingPriority,yh=ut.unstable_NormalPriority,VM=ut.unstable_LowPriority,R3=ut.unstable_IdlePriority,ZM=ut.log,XM=ut.unstable_setDisableYieldValue,wu=null,fn=null;function Ja(e){if(typeof ZM=="function"&&XM(e),fn&&typeof fn.setStrictMode=="function")try{fn.setStrictMode(wu,e)}catch{}}var pn=Math.clz32?Math.clz32:$M,YM=Math.log,KM=Math.LN2;function $M(e){return e>>>=0,e===0?32:31-(YM(e)/KM|0)|0}var Pp=256,Bp=262144,zp=4194304;function ss(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 Gh(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=ss(o):(s&=i,s!==0?a=ss(s):n||(n=i&~e,n!==0&&(a=ss(n))))):(i=o&~r,i!==0?a=ss(i):s!==0?a=ss(s):n||(n=o&~e,n!==0&&(a=ss(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 _u(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function QM(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 D3(){var e=zp;return zp<<=1,(zp&62914560)===0&&(zp=4194304),e}function Ky(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Cu(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function JM(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-pn(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&&P3(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function P3(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-pn(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function B3(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-pn(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function z3(e,t){var n=t&-t;return n=(n&42)!==0?1:Sx(n),(n&(e.suspendedLanes|t))!==0?0:n}function Sx(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 kx(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function N3(){var e=Le.p;return e!==0?e:(e=window.event,e===void 0?32:i_(e.type))}function oS(e,t){var n=Le.p;try{return Le.p=e,t()}finally{Le.p=n}}var gr=Math.random().toString(36).slice(2),_t="__reactFiber$"+gr,Yt="__reactProps$"+gr,ml="__reactContainer$"+gr,Rg="__reactEvents$"+gr,eO="__reactListeners$"+gr,tO="__reactHandles$"+gr,aS="__reactResources$"+gr,Tu="__reactMarker$"+gr;function wx(e){delete e[_t],delete e[Yt],delete e[Rg],delete e[eO],delete e[tO]}function Ui(e){var t=e[_t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ml]||n[_t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=f3(e);e!==null;){if(n=e[_t])return n;e=f3(e)}return t}e=n,n=e.parentNode}return null}function yl(e){if(e=e[_t]||e[ml]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Xc(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function $i(e){var t=e[aS];return t||(t=e[aS]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function bt(e){e[Tu]=!0}var F3=new Set,H3={};function bs(e,t){rl(e,t),rl(e+"Capture",t)}function rl(e,t){for(H3[e]=t,e=0;e<t.length;e++)F3.add(t[e])}var nO=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]*$"),rS={},sS={};function oO(e){return Og.call(sS,e)?!0:Og.call(rS,e)?!1:nO.test(e)?sS[e]=!0:(rS[e]=!0,!1)}function Qp(e,t,n){if(oO(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 Np(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 Ko(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 Cn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function U3(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function aO(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 Dg(e){if(!e._valueTracker){var t=U3(e)?"checked":"value";e._valueTracker=aO(e,t,""+e[t])}}function G3(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=U3(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function gh(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 rO=/[\n"\\]/g;function En(e){return e.replace(rO,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Pg(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=""+Cn(t)):e.value!==""+Cn(t)&&(e.value=""+Cn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?Bg(e,s,Cn(t)):n!=null?Bg(e,s,Cn(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=""+Cn(i):e.removeAttribute("name")}function q3(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)){Dg(e);return}n=n!=null?""+Cn(n):"",t=t!=null?""+Cn(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),Dg(e)}function Bg(e,t,n){t==="number"&&gh(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Qi(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=""+Cn(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 W3(e,t,n){if(t!=null&&(t=""+Cn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Cn(n):""}function j3(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Zc(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=Cn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),Dg(e)}function sl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var sO=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 iS(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||sO.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function V3(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&&iS(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&iS(e,r,t[r])}function _x(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 iO=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"]]),lO=/^[\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 Jp(e){return lO.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function aa(){}var zg=null;function Cx(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Gi=null,Ji=null;function lS(e){var t=yl(e);if(t&&(e=t.stateNode)){var n=e[Yt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Pg(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="'+En(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var o=n[t];if(o!==e&&o.form===e.form){var a=o[Yt]||null;if(!a)throw Error(O(90));Pg(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&&G3(o)}break e;case"textarea":W3(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Qi(e,!!n.multiple,t,!1)}}}var $y=!1;function Z3(e,t,n){if($y)return e(t,n);$y=!0;try{var o=e(t);return o}finally{if($y=!1,(Gi!==null||Ji!==null)&&(em(),Gi&&(t=Gi,e=Ji,Ji=Gi=null,lS(t),e)))for(t=0;t<e.length;t++)lS(e[t])}}function du(e,t){var n=e.stateNode;if(n===null)return null;var o=n[Yt]||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 ca=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ng=!1;if(ca)try{Di={},Object.defineProperty(Di,"passive",{get:function(){Ng=!0}}),window.addEventListener("test",Di,Di),window.removeEventListener("test",Di,Di)}catch{Ng=!1}var Di,er=null,Tx=null,eh=null;function X3(){if(eh)return eh;var e,t=Tx,n=t.length,o,a="value"in er?er.value:er.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 eh=a.slice(e,1<o?1-o:void 0)}function th(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 Fp(){return!0}function cS(){return!1}function Kt(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)?Fp:cS,this.isPropagationStopped=cS,this}return ze(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=Fp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Fp)},persist:function(){},isPersistent:Fp}),t}var As={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qh=Kt(As),Iu=ze({},As,{view:0,detail:0}),cO=Kt(Iu),Qy,Jy,Hc,Wh=ze({},Iu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ix,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!==Hc&&(Hc&&e.type==="mousemove"?(Qy=e.screenX-Hc.screenX,Jy=e.screenY-Hc.screenY):Jy=Qy=0,Hc=e),Qy)},movementY:function(e){return"movementY"in e?e.movementY:Jy}}),uS=Kt(Wh),uO=ze({},Wh,{dataTransfer:0}),dO=Kt(uO),fO=ze({},Iu,{relatedTarget:0}),eg=Kt(fO),pO=ze({},As,{animationName:0,elapsedTime:0,pseudoElement:0}),hO=Kt(pO),mO=ze({},As,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),yO=Kt(mO),gO=ze({},As,{data:0}),dS=Kt(gO),xO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bO={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"},AO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=AO[e])?!!t[e]:!1}function Ix(){return vO}var LO=ze({},Iu,{key:function(e){if(e.key){var t=xO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=th(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?bO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ix,charCode:function(e){return e.type==="keypress"?th(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?th(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),SO=Kt(LO),kO=ze({},Wh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fS=Kt(kO),wO=ze({},Iu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ix}),_O=Kt(wO),CO=ze({},As,{propertyName:0,elapsedTime:0,pseudoElement:0}),TO=Kt(CO),IO=ze({},Wh,{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}),EO=Kt(IO),MO=ze({},As,{newState:0,oldState:0}),OO=Kt(MO),RO=[9,13,27,32],Ex=ca&&"CompositionEvent"in window,$c=null;ca&&"documentMode"in document&&($c=document.documentMode);var DO=ca&&"TextEvent"in window&&!$c,Y3=ca&&(!Ex||$c&&8<$c&&11>=$c),pS=" ",hS=!1;function K3(e,t){switch(e){case"keyup":return RO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $3(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qi=!1;function PO(e,t){switch(e){case"compositionend":return $3(t);case"keypress":return t.which!==32?null:(hS=!0,pS);case"textInput":return e=t.data,e===pS&&hS?null:e;default:return null}}function BO(e,t){if(qi)return e==="compositionend"||!Ex&&K3(e,t)?(e=X3(),eh=Tx=er=null,qi=!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 Y3&&t.locale!=="ko"?null:t.data;default:return null}}var zO={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 mS(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!zO[e.type]:t==="textarea"}function Q3(e,t,n,o){Gi?Ji?Ji.push(o):Ji=[o]:Gi=o,t=Ph(t,"onChange"),0<t.length&&(n=new qh("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Qc=null,fu=null;function NO(e){Zw(e,0)}function jh(e){var t=Xc(e);if(G3(t))return e}function yS(e,t){if(e==="change")return t}var J3=!1;ca&&(ca?(Up="oninput"in document,Up||(tg=document.createElement("div"),tg.setAttribute("oninput","return;"),Up=typeof tg.oninput=="function"),Hp=Up):Hp=!1,J3=Hp&&(!document.documentMode||9<document.documentMode));var Hp,Up,tg;function gS(){Qc&&(Qc.detachEvent("onpropertychange",ek),fu=Qc=null)}function ek(e){if(e.propertyName==="value"&&jh(fu)){var t=[];Q3(t,fu,e,Cx(e)),Z3(NO,t)}}function FO(e,t,n){e==="focusin"?(gS(),Qc=t,fu=n,Qc.attachEvent("onpropertychange",ek)):e==="focusout"&&gS()}function HO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return jh(fu)}function UO(e,t){if(e==="click")return jh(t)}function GO(e,t){if(e==="input"||e==="change")return jh(t)}function qO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var mn=typeof Object.is=="function"?Object.is:qO;function pu(e,t){if(mn(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(!Og.call(t,a)||!mn(e[a],t[a]))return!1}return!0}function xS(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function bS(e,t){var n=xS(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=xS(n)}}function tk(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?tk(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function nk(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=gh(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=gh(e.document)}return t}function Mx(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 WO=ca&&"documentMode"in document&&11>=document.documentMode,Wi=null,Fg=null,Jc=null,Hg=!1;function AS(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hg||Wi==null||Wi!==gh(o)||(o=Wi,"selectionStart"in o&&Mx(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}),Jc&&pu(Jc,o)||(Jc=o,o=Ph(Fg,"onSelect"),0<o.length&&(t=new qh("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=Wi)))}function as(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ji={animationend:as("Animation","AnimationEnd"),animationiteration:as("Animation","AnimationIteration"),animationstart:as("Animation","AnimationStart"),transitionrun:as("Transition","TransitionRun"),transitionstart:as("Transition","TransitionStart"),transitioncancel:as("Transition","TransitionCancel"),transitionend:as("Transition","TransitionEnd")},ng={},ok={};ca&&(ok=document.createElement("div").style,"AnimationEvent"in window||(delete ji.animationend.animation,delete ji.animationiteration.animation,delete ji.animationstart.animation),"TransitionEvent"in window||delete ji.transitionend.transition);function vs(e){if(ng[e])return ng[e];if(!ji[e])return e;var t=ji[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ok)return ng[e]=t[n];return e}var ak=vs("animationend"),rk=vs("animationiteration"),sk=vs("animationstart"),jO=vs("transitionrun"),VO=vs("transitionstart"),ZO=vs("transitioncancel"),ik=vs("transitionend"),lk=new Map,Ug="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(" ");Ug.push("scrollEnd");function ro(e,t){lk.set(e,t),bs(t,[e])}var xh=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)},_n=[],Vi=0,Ox=0;function Vh(){for(var e=Vi,t=Ox=Vi=0;t<e;){var n=_n[t];_n[t++]=null;var o=_n[t];_n[t++]=null;var a=_n[t];_n[t++]=null;var r=_n[t];if(_n[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&&ck(n,a,r)}}function Zh(e,t,n,o){_n[Vi++]=e,_n[Vi++]=t,_n[Vi++]=n,_n[Vi++]=o,Ox|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Rx(e,t,n,o){return Zh(e,t,n,o),bh(e)}function Ls(e,t){return Zh(e,null,null,t),bh(e)}function ck(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-pn(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function bh(e){if(50<lu)throw lu=0,lx=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Zi={};function XO(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 cn(e,t,n,o){return new XO(e,t,n,o)}function Dx(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sa(e,t){var n=e.alternate;return n===null?(n=cn(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 uk(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 nh(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")Dx(e)&&(s=1);else if(typeof e=="string")s=$R(e,n,wo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Tg:return e=cn(31,n,t,a),e.elementType=Tg,e.lanes=r,e;case Fi:return us(n.children,a,r,t);case I3:s=8,a|=24;break;case wg:return e=cn(12,n,t,a|2),e.elementType=wg,e.lanes=r,e;case _g:return e=cn(13,n,t,a),e.elementType=_g,e.lanes=r,e;case Cg:return e=cn(19,n,t,a),e.elementType=Cg,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case oa:s=10;break e;case E3:s=9;break e;case Ax:s=11;break e;case vx:s=14;break e;case Za:s=16,o=null;break e}s=29,n=Error(O(130,e===null?"null":typeof e,"")),o=null}return t=cn(s,n,t,a),t.elementType=e,t.type=o,t.lanes=r,t}function us(e,t,n,o){return e=cn(7,e,o,t),e.lanes=n,e}function og(e,t,n){return e=cn(6,e,null,t),e.lanes=n,e}function dk(e){var t=cn(18,null,null,0);return t.stateNode=e,t}function ag(e,t,n){return t=cn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vS=new WeakMap;function Mn(e,t){if(typeof e=="object"&&e!==null){var n=vS.get(e);return n!==void 0?n:(t={value:e,source:t,stack:nS(t)},vS.set(e,t),t)}return{value:e,source:t,stack:nS(t)}}var Xi=[],Yi=0,Ah=null,hu=0,Tn=[],In=0,pr=null,Lo=1,So="";function ta(e,t){Xi[Yi++]=hu,Xi[Yi++]=Ah,Ah=e,hu=t}function fk(e,t,n){Tn[In++]=Lo,Tn[In++]=So,Tn[In++]=pr,pr=e;var o=Lo;e=So;var a=32-pn(o)-1;o&=~(1<<a),n+=1;var r=32-pn(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,Lo=1<<32-pn(t)+a|n<<a|o,So=r+e}else Lo=1<<r|n<<a|o,So=e}function Px(e){e.return!==null&&(ta(e,1),fk(e,1,0))}function Bx(e){for(;e===Ah;)Ah=Xi[--Yi],Xi[Yi]=null,hu=Xi[--Yi],Xi[Yi]=null;for(;e===pr;)pr=Tn[--In],Tn[In]=null,So=Tn[--In],Tn[In]=null,Lo=Tn[--In],Tn[In]=null}function pk(e,t){Tn[In++]=Lo,Tn[In++]=So,Tn[In++]=pr,Lo=t.id,So=t.overflow,pr=e}var Ct=null,Be=null,ge=!1,rr=null,On=!1,Gg=Error(O(519));function hr(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw mu(Mn(t,e)),Gg}function LS(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[_t]=e,t[Yt]=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<bu.length;n++)de(bu[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),q3(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),j3(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||Yw(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=aa),t=!0):t=!1,t||hr(e,!0)}function SS(e){for(Ct=e.return;Ct;)switch(Ct.tag){case 5:case 31:case 13:On=!1;return;case 27:case 3:On=!0;return;default:Ct=Ct.return}}function Pi(e){if(e!==Ct)return!1;if(!ge)return SS(e),ge=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||px(e.type,e.memoizedProps)),n=!n),n&&Be&&hr(e),SS(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));Be=d3(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));Be=d3(e)}else t===27?(t=Be,xr(e.type)?(e=gx,gx=null,Be=e):Be=t):Be=Ct?Dn(e.stateNode.nextSibling):null;return!0}function hs(){Be=Ct=null,ge=!1}function rg(){var e=rr;return e!==null&&(Zt===null?Zt=e:Zt.push.apply(Zt,e),rr=null),e}function mu(e){rr===null?rr=[e]:rr.push(e)}var qg=_o(null),Ss=null,ra=null;function Ya(e,t,n){Me(qg,t._currentValue),t._currentValue=n}function ia(e){e._currentValue=qg.current,At(qg)}function Wg(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 jg(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),Wg(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),Wg(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 gl(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;mn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===ph.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(vu):e=[vu])}a=a.return}e!==null&&jg(t,e,n,o),t.flags|=262144}function vh(e){for(e=e.firstContext;e!==null;){if(!mn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ms(e){Ss=e,ra=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Tt(e){return hk(Ss,e)}function Gp(e,t){return Ss===null&&ms(e),hk(e,t)}function hk(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ra===null){if(e===null)throw Error(O(308));ra=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ra=ra.next=t;return n}var YO=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()})}},KO=ut.unstable_scheduleCallback,$O=ut.unstable_NormalPriority,ot={$$typeof:oa,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zx(){return{controller:new YO,data:new Map,refCount:0}}function Eu(e){e.refCount--,e.refCount===0&&KO($O,function(){e.controller.abort()})}var eu=null,Vg=0,il=0,el=null;function QO(e,t){if(eu===null){var n=eu=[];Vg=0,il=l1(),el={status:"pending",value:void 0,then:function(o){n.push(o)}}}return Vg++,t.then(kS,kS),t}function kS(){if(--Vg===0&&eu!==null){el!==null&&(el.status="fulfilled");var e=eu;eu=null,il=0,el=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function JO(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 wS=K.S;K.S=function(e,t){Tw=dn(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&QO(e,t),wS!==null&&wS(e,t)};var ds=_o(null);function Nx(){var e=ds.current;return e!==null?e:Ee.pooledCache}function oh(e,t){t===null?Me(ds,ds.current):Me(ds,t.pool)}function mk(){var e=Nx();return e===null?null:{parent:ot._currentValue,pool:e}}var xl=Error(O(460)),Fx=Error(O(474)),Xh=Error(O(542)),Lh={then:function(){}};function _S(e){return e=e.status,e==="fulfilled"||e==="rejected"}function yk(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(aa,aa),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,TS(e),e;default:if(typeof t.status=="string")t.then(aa,aa);else{if(e=Ee,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,TS(e),e}throw fs=t,xl}}function is(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(fs=n,xl):n}}var fs=null;function CS(){if(fs===null)throw Error(O(459));var e=fs;return fs=null,e}function TS(e){if(e===xl||e===Xh)throw Error(O(483))}var tl=null,yu=0;function qp(e){var t=yu;return yu+=1,tl===null&&(tl=[]),yk(tl,e,t)}function Uc(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Wp(e,t){throw t.$$typeof===FM?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gk(e){function t(y,g){if(e){var x=y.deletions;x===null?(y.deletions=[g],y.flags|=16):x.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=sa(y,g),y.index=0,y.sibling=null,y}function r(y,g,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<g?(y.flags|=67108866,g):x):(y.flags|=67108866,g)):(y.flags|=1048576,g)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function i(y,g,x,A){return g===null||g.tag!==6?(g=og(x,y.mode,A),g.return=y,g):(g=a(g,x),g.return=y,g)}function l(y,g,x,A){var C=x.type;return C===Fi?u(y,g,x.props.children,A,x.key):g!==null&&(g.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Za&&is(C)===g.type)?(g=a(g,x.props),Uc(g,x),g.return=y,g):(g=nh(x.type,x.key,x.props,null,y.mode,A),Uc(g,x),g.return=y,g)}function c(y,g,x,A){return g===null||g.tag!==4||g.stateNode.containerInfo!==x.containerInfo||g.stateNode.implementation!==x.implementation?(g=ag(x,y.mode,A),g.return=y,g):(g=a(g,x.children||[]),g.return=y,g)}function u(y,g,x,A,C){return g===null||g.tag!==7?(g=us(x,y.mode,A,C),g.return=y,g):(g=a(g,x),g.return=y,g)}function d(y,g,x){if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return g=og(""+g,y.mode,x),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Dp:return x=nh(g.type,g.key,g.props,null,y.mode,x),Uc(x,g),x.return=y,x;case Vc:return g=ag(g,y.mode,x),g.return=y,g;case Za:return g=is(g),d(y,g,x)}if(Zc(g)||Fc(g))return g=us(g,y.mode,x,null),g.return=y,g;if(typeof g.then=="function")return d(y,qp(g),x);if(g.$$typeof===oa)return d(y,Gp(y,g),x);Wp(y,g)}return null}function f(y,g,x,A){var C=g!==null?g.key:null;if(typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint")return C!==null?null:i(y,g,""+x,A);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Dp:return x.key===C?l(y,g,x,A):null;case Vc:return x.key===C?c(y,g,x,A):null;case Za:return x=is(x),f(y,g,x,A)}if(Zc(x)||Fc(x))return C!==null?null:u(y,g,x,A,null);if(typeof x.then=="function")return f(y,g,qp(x),A);if(x.$$typeof===oa)return f(y,g,Gp(y,x),A);Wp(y,x)}return null}function p(y,g,x,A,C){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return y=y.get(x)||null,i(g,y,""+A,C);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Dp:return y=y.get(A.key===null?x:A.key)||null,l(g,y,A,C);case Vc:return y=y.get(A.key===null?x:A.key)||null,c(g,y,A,C);case Za:return A=is(A),p(y,g,x,A,C)}if(Zc(A)||Fc(A))return y=y.get(x)||null,u(g,y,A,C,null);if(typeof A.then=="function")return p(y,g,x,qp(A),C);if(A.$$typeof===oa)return p(y,g,x,Gp(g,A),C);Wp(g,A)}return null}function h(y,g,x,A){for(var C=null,_=null,v=g,I=g=0,k=null;v!==null&&I<x.length;I++){v.index>I?(k=v,v=null):k=v.sibling;var T=f(y,v,x[I],A);if(T===null){v===null&&(v=k);break}e&&v&&T.alternate===null&&t(y,v),g=r(T,g,I),_===null?C=T:_.sibling=T,_=T,v=k}if(I===x.length)return n(y,v),ge&&ta(y,I),C;if(v===null){for(;I<x.length;I++)v=d(y,x[I],A),v!==null&&(g=r(v,g,I),_===null?C=v:_.sibling=v,_=v);return ge&&ta(y,I),C}for(v=o(v);I<x.length;I++)k=p(v,y,I,x[I],A),k!==null&&(e&&k.alternate!==null&&v.delete(k.key===null?I:k.key),g=r(k,g,I),_===null?C=k:_.sibling=k,_=k);return e&&v.forEach(function(P){return t(y,P)}),ge&&ta(y,I),C}function m(y,g,x,A){if(x==null)throw Error(O(151));for(var C=null,_=null,v=g,I=g=0,k=null,T=x.next();v!==null&&!T.done;I++,T=x.next()){v.index>I?(k=v,v=null):k=v.sibling;var P=f(y,v,T.value,A);if(P===null){v===null&&(v=k);break}e&&v&&P.alternate===null&&t(y,v),g=r(P,g,I),_===null?C=P:_.sibling=P,_=P,v=k}if(T.done)return n(y,v),ge&&ta(y,I),C;if(v===null){for(;!T.done;I++,T=x.next())T=d(y,T.value,A),T!==null&&(g=r(T,g,I),_===null?C=T:_.sibling=T,_=T);return ge&&ta(y,I),C}for(v=o(v);!T.done;I++,T=x.next())T=p(v,y,I,T.value,A),T!==null&&(e&&T.alternate!==null&&v.delete(T.key===null?I:T.key),g=r(T,g,I),_===null?C=T:_.sibling=T,_=T);return e&&v.forEach(function(N){return t(y,N)}),ge&&ta(y,I),C}function b(y,g,x,A){if(typeof x=="object"&&x!==null&&x.type===Fi&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Dp:e:{for(var C=x.key;g!==null;){if(g.key===C){if(C=x.type,C===Fi){if(g.tag===7){n(y,g.sibling),A=a(g,x.props.children),A.return=y,y=A;break e}}else if(g.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Za&&is(C)===g.type){n(y,g.sibling),A=a(g,x.props),Uc(A,x),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}x.type===Fi?(A=us(x.props.children,y.mode,A,x.key),A.return=y,y=A):(A=nh(x.type,x.key,x.props,null,y.mode,A),Uc(A,x),A.return=y,y=A)}return s(y);case Vc:e:{for(C=x.key;g!==null;){if(g.key===C)if(g.tag===4&&g.stateNode.containerInfo===x.containerInfo&&g.stateNode.implementation===x.implementation){n(y,g.sibling),A=a(g,x.children||[]),A.return=y,y=A;break e}else{n(y,g);break}else t(y,g);g=g.sibling}A=ag(x,y.mode,A),A.return=y,y=A}return s(y);case Za:return x=is(x),b(y,g,x,A)}if(Zc(x))return h(y,g,x,A);if(Fc(x)){if(C=Fc(x),typeof C!="function")throw Error(O(150));return x=C.call(x),m(y,g,x,A)}if(typeof x.then=="function")return b(y,g,qp(x),A);if(x.$$typeof===oa)return b(y,g,Gp(y,x),A);Wp(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,g!==null&&g.tag===6?(n(y,g.sibling),A=a(g,x),A.return=y,y=A):(n(y,g),A=og(x,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,x,A){try{yu=0;var C=b(y,g,x,A);return tl=null,C}catch(v){if(v===xl||v===Xh)throw v;var _=cn(29,v,null,y.mode);return _.lanes=A,_.return=y,_}finally{}}}var ys=gk(!0),xk=gk(!1),Xa=!1;function Hx(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Zg(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 sr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ir(e,t,n){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ve&2)!==0){var a=o.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),o.pending=t,t=bh(e),ck(e,null,n),t}return Zh(e,o,t,n),bh(e)}function tu(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,B3(e,n)}}function sg(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 Xg=!1;function nu(){if(Xg){var e=el;if(e!==null)throw e}}function ou(e,t,n,o){Xg=!1;var a=e.updateQueue;Xa=!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===il&&(Xg=!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 b=n;switch(m.tag){case 1:if(h=m.payload,typeof h=="function"){d=h.call(b,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(b,d,f):h,f==null)break e;d=ze({},d,f);break e;case 2:Xa=!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),yr|=s,e.lanes=s,e.memoizedState=d}}function bk(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function Ak(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)bk(n[e],t)}var ll=_o(null),Sh=_o(0);function IS(e,t){e=pa,Me(Sh,e),Me(ll,t),pa=e|t.baseLanes}function Yg(){Me(Sh,pa),Me(ll,ll.current)}function Ux(){pa=Sh.current,At(ll),At(Sh)}var yn=_o(null),Rn=null;function Ka(e){var t=e.alternate;Me(Ke,Ke.current&1),Me(yn,e),Rn===null&&(t===null||ll.current!==null||t.memoizedState!==null)&&(Rn=e)}function Kg(e){Me(Ke,Ke.current),Me(yn,e),Rn===null&&(Rn=e)}function vk(e){e.tag===22?(Me(Ke,Ke.current),Me(yn,e),Rn===null&&(Rn=e)):$a(e)}function $a(){Me(Ke,Ke.current),Me(yn,yn.current)}function ln(e){At(yn),Rn===e&&(Rn=null),At(Ke)}var Ke=_o(0);function kh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||mx(n)||yx(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 ua=0,oe=null,Ie=null,tt=null,wh=!1,nl=!1,gs=!1,_h=0,gu=0,ol=null,eR=0;function Ze(){throw Error(O(321))}function Gx(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!mn(e[n],t[n]))return!1;return!0}function qx(e,t,n,o,a,r){return ua=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?Qk:e1,gs=!1,r=n(o,a),gs=!1,nl&&(r=Sk(t,n,o,a)),Lk(e),r}function Lk(e){K.H=xu;var t=Ie!==null&&Ie.next!==null;if(ua=0,tt=Ie=oe=null,wh=!1,gu=0,ol=null,t)throw Error(O(300));e===null||at||(e=e.dependencies,e!==null&&vh(e)&&(at=!0))}function Sk(e,t,n,o){oe=e;var a=0;do{if(nl&&(ol=null),gu=0,nl=!1,25<=a)throw Error(O(301));if(a+=1,tt=Ie=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=Jk,r=t(n,o)}while(nl);return r}function tR(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?Mu(t):t,e=e.useState()[0],(Ie!==null?Ie.memoizedState:null)!==e&&(oe.flags|=1024),t}function Wx(){var e=_h!==0;return _h=0,e}function jx(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Vx(e){if(wh){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}wh=!1}ua=0,tt=Ie=oe=null,nl=!1,gu=_h=0,ol=null}function Ht(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tt===null?oe.memoizedState=tt=e:tt=tt.next=e,tt}function $e(){if(Ie===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Ie.next;var t=tt===null?oe.memoizedState:tt.next;if(t!==null)tt=t,Ie=e;else{if(e===null)throw oe.alternate===null?Error(O(467)):Error(O(310));Ie=e,e={memoizedState:Ie.memoizedState,baseState:Ie.baseState,baseQueue:Ie.baseQueue,queue:Ie.queue,next:null},tt===null?oe.memoizedState=tt=e:tt=tt.next=e}return tt}function Yh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Mu(e){var t=gu;return gu+=1,ol===null&&(ol=[]),e=yk(ol,e,t),t=oe,(tt===null?t.memoizedState:tt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?Qk:e1),e}function Kh(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Mu(e);if(e.$$typeof===oa)return Tt(e)}throw Error(O(438,String(e)))}function Zx(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=Yh(),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]=HM;return t.index++,n}function da(e,t){return typeof t=="function"?t(e):t}function ah(e){var t=$e();return Xx(t,Ie,e)}function Xx(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:(ua&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===il&&(u=!0);else if((ua&f)===f){c=c.next,f===il&&(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,yr|=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,yr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!mn(r,e.memoizedState)&&(at=!0,u&&(n=el,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 ig(e){var t=$e(),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);mn(r,t.memoizedState)||(at=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function kk(e,t,n){var o=oe,a=$e(),r=ge;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!mn((Ie||a).memoizedState,n);if(s&&(a.memoizedState=n,at=!0),a=a.queue,Yx(Ck.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||tt!==null&&tt.memoizedState.tag&1){if(o.flags|=2048,cl(9,{destroy:void 0},_k.bind(null,o,a,n,t),null),Ee===null)throw Error(O(349));r||(ua&127)!==0||wk(o,t,n)}return n}function wk(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=Yh(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function _k(e,t,n,o){t.value=n,t.getSnapshot=o,Tk(t)&&Ik(e)}function Ck(e,t,n){return n(function(){Tk(t)&&Ik(e)})}function Tk(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mn(e,n)}catch{return!0}}function Ik(e){var t=Ls(e,2);t!==null&&Xt(t,e,2)}function $g(e){var t=Ht();if(typeof e=="function"){var n=e;if(e=n(),gs){Ja(!0);try{n()}finally{Ja(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:e},t}function Ek(e,t,n,o){return e.baseState=n,Xx(e,Ie,typeof o=="function"?o:da)}function nR(e,t,n,o,a){if(Qh(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,Mk(t,r)):(r.next=n.next,t.pending=n.next=r)}}function Mk(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),ES(e,t,i)}catch(c){Qg(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),ES(e,t,r)}catch(c){Qg(e,t,c)}}function ES(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){MS(e,t,o)},function(o){return Qg(e,t,o)}):MS(e,t,n)}function MS(e,t,n){t.status="fulfilled",t.value=n,Ok(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Mk(e,n)))}function Qg(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,Ok(t),t=t.next;while(t!==o)}e.action=null}function Ok(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rk(e,t){return t}function OS(e,t){if(ge){var n=Ee.formState;if(n!==null){e:{var o=oe;if(ge){if(Be){t:{for(var a=Be,r=On;a.nodeType!==8;){if(!r){a=null;break t}if(a=Dn(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){Be=Dn(a.nextSibling),o=a.data==="F!";break e}}hr(o)}o=!1}o&&(t=n[0])}}return n=Ht(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rk,lastRenderedState:t},n.queue=o,n=Yk.bind(null,oe,o),o.dispatch=n,o=$g(!1),r=Jx.bind(null,oe,!1,o.queue),o=Ht(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=nR.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function RS(e){var t=$e();return Dk(t,Ie,e)}function Dk(e,t,n){if(t=Xx(e,t,Rk)[0],e=ah(da)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=Mu(t)}catch(s){throw s===xl?Xh:s}else o=t;t=$e();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,cl(9,{destroy:void 0},oR.bind(null,a,n),null)),[o,r,e]}function oR(e,t){e.action=t}function DS(e){var t=$e(),n=Ie;if(n!==null)return Dk(t,n,e);$e(),t=t.memoizedState,n=$e();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function cl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=Yh(),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 Pk(){return $e().memoizedState}function rh(e,t,n,o){var a=Ht();oe.flags|=e,a.memoizedState=cl(1|t,{destroy:void 0},n,o===void 0?null:o)}function $h(e,t,n,o){var a=$e();o=o===void 0?null:o;var r=a.memoizedState.inst;Ie!==null&&o!==null&&Gx(o,Ie.memoizedState.deps)?a.memoizedState=cl(t,r,n,o):(oe.flags|=e,a.memoizedState=cl(1|t,r,n,o))}function PS(e,t){rh(8390656,8,e,t)}function Yx(e,t){$h(2048,8,e,t)}function aR(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=Yh(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Bk(e){var t=$e().memoizedState;return aR({ref:t,nextImpl:e}),function(){if((ve&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function zk(e,t){return $h(4,2,e,t)}function Nk(e,t){return $h(4,4,e,t)}function Fk(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 Hk(e,t,n){n=n!=null?n.concat([e]):null,$h(4,4,Fk.bind(null,t,e),n)}function Kx(){}function Uk(e,t){var n=$e();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&Gx(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function Gk(e,t){var n=$e();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&Gx(t,o[1]))return o[0];if(o=e(),gs){Ja(!0);try{e()}finally{Ja(!1)}}return n.memoizedState=[o,t],o}function $x(e,t,n){return n===void 0||(ua&1073741824)!==0&&(me&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Ew(),oe.lanes|=e,yr|=e,n)}function qk(e,t,n,o){return mn(n,t)?n:ll.current!==null?(e=$x(e,n,o),mn(e,t)||(at=!0),e):(ua&42)===0||(ua&1073741824)!==0&&(me&261930)===0?(at=!0,e.memoizedState=n):(e=Ew(),oe.lanes|=e,yr|=e,t)}function Wk(e,t,n,o,a){var r=Le.p;Le.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,Jx(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=JO(l,o);au(e,t,u,hn(e))}else au(e,t,o,hn(e))}catch(d){au(e,t,{then:function(){},status:"rejected",reason:d},hn())}finally{Le.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function rR(){}function Jg(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=jk(e).queue;Wk(e,a,t,cs,n===null?rR:function(){return Vk(e),n(o)})}function jk(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:cs,baseState:cs,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:cs},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Vk(e){var t=jk(e);t.next===null&&(t=e.alternate.memoizedState),au(e,t.next.queue,{},hn())}function Qx(){return Tt(vu)}function Zk(){return $e().memoizedState}function Xk(){return $e().memoizedState}function sR(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=hn();e=sr(n);var o=ir(t,e,n);o!==null&&(Xt(o,t,n),tu(o,t,n)),t={cache:zx()},e.payload=t;return}t=t.return}}function iR(e,t,n){var o=hn();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Qh(e)?Kk(t,n):(n=Rx(e,t,n,o),n!==null&&(Xt(n,e,o),$k(n,t,o)))}function Yk(e,t,n){var o=hn();au(e,t,n,o)}function au(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qh(e))Kk(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,mn(i,s))return Zh(e,t,a,0),Ee===null&&Vh(),!1}catch{}finally{}if(n=Rx(e,t,a,o),n!==null)return Xt(n,e,o),$k(n,t,o),!0}return!1}function Jx(e,t,n,o){if(o={lane:2,revertLane:l1(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Qh(e)){if(t)throw Error(O(479))}else t=Rx(e,n,o,2),t!==null&&Xt(t,e,2)}function Qh(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function Kk(e,t){nl=wh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function $k(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,B3(e,n)}}var xu={readContext:Tt,use:Kh,useCallback:Ze,useContext:Ze,useEffect:Ze,useImperativeHandle:Ze,useLayoutEffect:Ze,useInsertionEffect:Ze,useMemo:Ze,useReducer:Ze,useRef:Ze,useState:Ze,useDebugValue:Ze,useDeferredValue:Ze,useTransition:Ze,useSyncExternalStore:Ze,useId:Ze,useHostTransitionStatus:Ze,useFormState:Ze,useActionState:Ze,useOptimistic:Ze,useMemoCache:Ze,useCacheRefresh:Ze};xu.useEffectEvent=Ze;var Qk={readContext:Tt,use:Kh,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:Tt,useEffect:PS,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,rh(4194308,4,Fk.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rh(4194308,4,e,t)},useInsertionEffect:function(e,t){rh(4,2,e,t)},useMemo:function(e,t){var n=Ht();t=t===void 0?null:t;var o=e();if(gs){Ja(!0);try{e()}finally{Ja(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Ht();if(n!==void 0){var a=n(t);if(gs){Ja(!0);try{n(t)}finally{Ja(!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=iR.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:function(e){e=$g(e);var t=e.queue,n=Yk.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Kx,useDeferredValue:function(e,t){var n=Ht();return $x(n,e,t)},useTransition:function(){var e=$g(!1);return e=Wk.bind(null,oe,e.queue,!0,!1),Ht().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Ht();if(ge){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),Ee===null)throw Error(O(349));(me&127)!==0||wk(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,PS(Ck.bind(null,o,r,e),[e]),o.flags|=2048,cl(9,{destroy:void 0},_k.bind(null,o,r,n,t),null),n},useId:function(){var e=Ht(),t=Ee.identifierPrefix;if(ge){var n=So,o=Lo;n=(o&~(1<<32-pn(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=_h++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=eR++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Qx,useFormState:OS,useActionState:OS,useOptimistic:function(e){var t=Ht();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Jx.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:Zx,useCacheRefresh:function(){return Ht().memoizedState=sR.bind(null,oe)},useEffectEvent:function(e){var t=Ht(),n={impl:e};return t.memoizedState=n,function(){if((ve&2)!==0)throw Error(O(440));return n.impl.apply(void 0,arguments)}}},e1={readContext:Tt,use:Kh,useCallback:Uk,useContext:Tt,useEffect:Yx,useImperativeHandle:Hk,useInsertionEffect:zk,useLayoutEffect:Nk,useMemo:Gk,useReducer:ah,useRef:Pk,useState:function(){return ah(da)},useDebugValue:Kx,useDeferredValue:function(e,t){var n=$e();return qk(n,Ie.memoizedState,e,t)},useTransition:function(){var e=ah(da)[0],t=$e().memoizedState;return[typeof e=="boolean"?e:Mu(e),t]},useSyncExternalStore:kk,useId:Zk,useHostTransitionStatus:Qx,useFormState:RS,useActionState:RS,useOptimistic:function(e,t){var n=$e();return Ek(n,Ie,e,t)},useMemoCache:Zx,useCacheRefresh:Xk};e1.useEffectEvent=Bk;var Jk={readContext:Tt,use:Kh,useCallback:Uk,useContext:Tt,useEffect:Yx,useImperativeHandle:Hk,useInsertionEffect:zk,useLayoutEffect:Nk,useMemo:Gk,useReducer:ig,useRef:Pk,useState:function(){return ig(da)},useDebugValue:Kx,useDeferredValue:function(e,t){var n=$e();return Ie===null?$x(n,e,t):qk(n,Ie.memoizedState,e,t)},useTransition:function(){var e=ig(da)[0],t=$e().memoizedState;return[typeof e=="boolean"?e:Mu(e),t]},useSyncExternalStore:kk,useId:Zk,useHostTransitionStatus:Qx,useFormState:DS,useActionState:DS,useOptimistic:function(e,t){var n=$e();return Ie!==null?Ek(n,Ie,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Zx,useCacheRefresh:Xk};Jk.useEffectEvent=Bk;function lg(e,t,n,o){t=e.memoizedState,n=n(o,t),n=n==null?t:ze({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ex={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=hn(),a=sr(o);a.payload=t,n!=null&&(a.callback=n),t=ir(e,a,o),t!==null&&(Xt(t,e,o),tu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=hn(),a=sr(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=ir(e,a,o),t!==null&&(Xt(t,e,o),tu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=hn(),o=sr(n);o.tag=2,t!=null&&(o.callback=t),t=ir(e,o,n),t!==null&&(Xt(t,e,n),tu(t,e,n))}};function BS(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?!pu(n,o)||!pu(a,r):!0}function zS(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&&ex.enqueueReplaceState(t,t.state,null)}function xs(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=ze({},n));for(var a in e)n[a]===void 0&&(n[a]=e[a])}return n}function ew(e){xh(e)}function tw(e){console.error(e)}function nw(e){xh(e)}function Ch(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function NS(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 tx(e,t,n){return n=sr(n),n.tag=3,n.payload={element:null},n.callback=function(){Ch(e,t)},n}function ow(e){return e=sr(e),e.tag=3,e}function aw(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(){NS(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){NS(t,n,o),typeof a!="function"&&(lr===null?lr=new Set([this]):lr.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function lR(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&gl(t,n,a,!0),n=yn.current,n!==null){switch(n.tag){case 31:case 13:return Rn===null?Oh():n.alternate===null&&Xe===0&&(Xe=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Lh?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),bg(e,o,a)),!1;case 22:return n.flags|=65536,o===Lh?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)),bg(e,o,a)),!1}throw Error(O(435,n.tag))}return bg(e,o,a),Oh(),!1}if(ge)return t=yn.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==Gg&&(e=Error(O(422),{cause:o}),mu(Mn(e,n)))):(o!==Gg&&(t=Error(O(423),{cause:o}),mu(Mn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Mn(o,n),a=tx(e.stateNode,o,a),sg(e,a),Xe!==4&&(Xe=2)),!1;var r=Error(O(520),{cause:o});if(r=Mn(r,n),iu===null?iu=[r]:iu.push(r),Xe!==4&&(Xe=2),t===null)return!0;o=Mn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=tx(n.stateNode,o,e),sg(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"&&(lr===null||!lr.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=ow(a),aw(a,e,n,o),sg(n,a),!1}n=n.return}while(n!==null);return!1}var t1=Error(O(461)),at=!1;function wt(e,t,n,o){t.child=e===null?xk(t,null,n,o):ys(t,e.child,n,o)}function FS(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 ms(t),o=qx(e,t,n,s,r,a),i=Wx(),e!==null&&!at?(jx(e,t,a),fa(e,t,a)):(ge&&i&&Px(t),t.flags|=1,wt(e,t,o,a),t.child)}function HS(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!Dx(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,rw(e,t,r,o,a)):(e=nh(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!n1(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:pu,n(s,o)&&e.ref===t.ref)return fa(e,t,a)}return t.flags|=1,e=sa(r,o),e.ref=t.ref,e.return=t,t.child=e}function rw(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(pu(r,o)&&e.ref===t.ref)if(at=!1,t.pendingProps=o=r,n1(e,a))(e.flags&131072)!==0&&(at=!0);else return t.lanes=e.lanes,fa(e,t,a)}return nx(e,t,n,o,a)}function sw(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 US(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&oh(t,r!==null?r.cachePool:null),r!==null?IS(t,r):Yg(),vk(t);else return o=t.lanes=536870912,US(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(oh(t,r.cachePool),IS(t,r),$a(t),t.memoizedState=null):(e!==null&&oh(t,null),Yg(),$a(t));return wt(e,t,a,n),t.child}function Yc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function US(e,t,n,o,a){var r=Nx();return r=r===null?null:{parent:ot._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&oh(t,null),Yg(),vk(t),e!==null&&gl(e,t,o,!0),t.childLanes=a,null}function sh(e,t){return t=Th({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function GS(e,t,n){return ys(t,e.child,null,n),e=sh(t,t.pendingProps),e.flags|=2,ln(t),t.memoizedState=null,e}function cR(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(ge){if(o.mode==="hidden")return e=sh(t,o),t.lanes=536870912,Yc(null,e);if(Kg(t),(e=Be)?(e=Qw(e,On),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pr!==null?{id:Lo,overflow:So}:null,retryLane:536870912,hydrationErrors:null},n=dk(e),n.return=t,t.child=n,Ct=t,Be=null)):e=null,e===null)throw hr(t);return t.lanes=536870912,null}return sh(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(Kg(t),a)if(t.flags&256)t.flags&=-257,t=GS(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(O(558));else if(at||gl(e,t,n,!1),a=(n&e.childLanes)!==0,at||a){if(o=Ee,o!==null&&(s=z3(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Ls(e,s),Xt(o,e,s),t1;Oh(),t=GS(e,t,n)}else e=r.treeContext,Be=Dn(s.nextSibling),Ct=t,ge=!0,rr=null,On=!1,e!==null&&pk(t,e),t=sh(t,o),t.flags|=4096;return t}return e=sa(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ih(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 nx(e,t,n,o,a){return ms(t),n=qx(e,t,n,o,void 0,a),o=Wx(),e!==null&&!at?(jx(e,t,a),fa(e,t,a)):(ge&&o&&Px(t),t.flags|=1,wt(e,t,n,a),t.child)}function qS(e,t,n,o,a,r){return ms(t),t.updateQueue=null,n=Sk(t,o,n,a),Lk(e),o=Wx(),e!==null&&!at?(jx(e,t,r),fa(e,t,r)):(ge&&o&&Px(t),t.flags|=1,wt(e,t,n,r),t.child)}function WS(e,t,n,o,a){if(ms(t),t.stateNode===null){var r=Zi,s=n.contextType;typeof s=="object"&&s!==null&&(r=Tt(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ex,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},Hx(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Tt(s):Zi,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(lg(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&&ex.enqueueReplaceState(r,r.state,null),ou(t,o,r,a),nu(),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=xs(n,i);r.props=l;var c=r.context,u=n.contextType;s=Zi,typeof u=="object"&&u!==null&&(s=Tt(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)&&zS(t,r,o,s),Xa=!1;var f=t.memoizedState;r.state=f,ou(t,o,r,a),nu(),c=t.memoizedState,i||f!==c||Xa?(typeof d=="function"&&(lg(t,n,d,o),c=t.memoizedState),(l=Xa||BS(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,Zg(e,t),s=t.memoizedProps,u=xs(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=Zi,typeof c=="object"&&c!==null&&(l=Tt(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)&&zS(t,r,o,l),Xa=!1,f=t.memoizedState,r.state=f,ou(t,o,r,a),nu();var p=t.memoizedState;s!==d||f!==p||Xa||e!==null&&e.dependencies!==null&&vh(e.dependencies)?(typeof i=="function"&&(lg(t,n,i,o),p=t.memoizedState),(u=Xa||BS(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&vh(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,ih(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=ys(t,e.child,null,a),t.child=ys(t,null,n,a)):wt(e,t,n,a),t.memoizedState=r.state,e=t.child):e=fa(e,t,a),e}function jS(e,t,n,o){return hs(),t.flags|=256,wt(e,t,n,o),t.child}var cg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ug(e){return{baseLanes:e,cachePool:mk()}}function dg(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=un),e}function iw(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:(Ke.current&2)!==0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(ge){if(a?Ka(t):$a(t),(e=Be)?(e=Qw(e,On),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pr!==null?{id:Lo,overflow:So}:null,retryLane:536870912,hydrationErrors:null},n=dk(e),n.return=t,t.child=n,Ct=t,Be=null)):e=null,e===null)throw hr(t);return yx(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?($a(t),a=t.mode,i=Th({mode:"hidden",children:i},a),o=us(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=ug(n),o.childLanes=dg(e,s,n),t.memoizedState=cg,Yc(null,o)):(Ka(t),ox(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(Ka(t),t.flags&=-257,t=fg(e,t,n)):t.memoizedState!==null?($a(t),t.child=e.child,t.flags|=128,t=null):($a(t),i=o.fallback,a=t.mode,o=Th({mode:"visible",children:o.children},a),i=us(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,ys(t,e.child,null,n),o=t.child,o.memoizedState=ug(n),o.childLanes=dg(e,s,n),t.memoizedState=cg,t=Yc(null,o));else if(Ka(t),yx(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,mu({value:o,source:null,stack:null}),t=fg(e,t,n)}else if(at||gl(e,t,n,!1),s=(n&e.childLanes)!==0,at||s){if(s=Ee,s!==null&&(o=z3(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Ls(e,o),Xt(s,e,o),t1;mx(i)||Oh(),t=fg(e,t,n)}else mx(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Be=Dn(i.nextSibling),Ct=t,ge=!0,rr=null,On=!1,e!==null&&pk(t,e),t=ox(t,o.children),t.flags|=4096);return t}return a?($a(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=sa(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=sa(c,i):(i=us(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Yc(null,o),o=t.child,i=e.child.memoizedState,i===null?i=ug(n):(a=i.cachePool,a!==null?(l=ot._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=mk(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=dg(e,s,n),t.memoizedState=cg,Yc(e.child,o)):(Ka(t),n=e.child,e=n.sibling,n=sa(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 ox(e,t){return t=Th({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Th(e,t){return e=cn(22,e,null,t),e.lanes=0,e}function fg(e,t,n){return ys(t,e.child,null,n),e=ox(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function VS(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),Wg(e.return,t,n)}function pg(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 lw(e,t,n){var o=t.pendingProps,a=o.revealOrder,r=o.tail;o=o.children;var s=Ke.current,i=(s&2)!==0;if(i?(s=s&1|2,t.flags|=128):s&=1,Me(Ke,s),wt(e,t,o,n),o=ge?hu:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&VS(e,n,t);else if(e.tag===19)VS(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&&kh(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),pg(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&&kh(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}pg(t,!0,n,null,r,o);break;case"together":pg(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function fa(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),yr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(gl(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=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function n1(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&vh(e)))}function uR(e,t,n){switch(t.tag){case 3:hh(t,t.stateNode.containerInfo),Ya(t,ot,e.memoizedState.cache),hs();break;case 27:case 5:Mg(t);break;case 4:hh(t,t.stateNode.containerInfo);break;case 10:Ya(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Kg(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(Ka(t),t.flags|=128,null):(n&t.child.childLanes)!==0?iw(e,t,n):(Ka(t),e=fa(e,t,n),e!==null?e.sibling:null);Ka(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(gl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return lw(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Me(Ke,Ke.current),o)break;return null;case 22:return t.lanes=0,sw(e,t,n,t.pendingProps);case 24:Ya(t,ot,e.memoizedState.cache)}return fa(e,t,n)}function cw(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)at=!0;else{if(!n1(e,n)&&(t.flags&128)===0)return at=!1,uR(e,t,n);at=(e.flags&131072)!==0}else at=!1,ge&&(t.flags&1048576)!==0&&fk(t,hu,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=is(t.elementType),t.type=e,typeof e=="function")Dx(e)?(o=xs(e,o),t.tag=1,t=WS(null,t,e,o,n)):(t.tag=0,t=nx(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===Ax){t.tag=11,t=FS(null,t,e,o,n);break e}else if(a===vx){t.tag=14,t=HS(null,t,e,o,n);break e}}throw t=Ig(e)||e,Error(O(306,t,""))}}return t;case 0:return nx(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=xs(o,t.pendingProps),WS(e,t,o,a,n);case 3:e:{if(hh(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,Zg(e,t),ou(t,o,null,n);var s=t.memoizedState;if(o=s.cache,Ya(t,ot,o),o!==r.cache&&jg(t,[ot],n,!0),nu(),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=jS(e,t,o,n);break e}else if(o!==a){a=Mn(Error(O(424)),t),mu(a),t=jS(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(Be=Dn(e.firstChild),Ct=t,ge=!0,rr=null,On=!0,n=xk(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(hs(),o===a){t=fa(e,t,n);break e}wt(e,t,o,n)}t=t.child}return t;case 26:return ih(e,t),e===null?(n=h3(t.type,null,t.pendingProps,null))?t.memoizedState=n:ge||(n=t.type,e=t.pendingProps,o=Bh(ar.current).createElement(n),o[_t]=t,o[Yt]=e,It(o,n,e),bt(o),t.stateNode=o):t.memoizedState=h3(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Mg(t),e===null&&ge&&(o=t.stateNode=Jw(t.type,t.pendingProps,ar.current),Ct=t,On=!0,a=Be,xr(t.type)?(gx=a,Be=Dn(o.firstChild)):Be=a),wt(e,t,t.pendingProps.children,n),ih(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ge&&((a=o=Be)&&(o=NR(o,t.type,t.pendingProps,On),o!==null?(t.stateNode=o,Ct=t,Be=Dn(o.firstChild),On=!1,a=!0):a=!1),a||hr(t)),Mg(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,px(a,r)?o=null:s!==null&&px(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=qx(e,t,tR,null,null,n),vu._currentValue=a),ih(e,t),wt(e,t,o,n),t.child;case 6:return e===null&&ge&&((e=n=Be)&&(n=FR(n,t.pendingProps,On),n!==null?(t.stateNode=n,Ct=t,Be=null,e=!0):e=!1),e||hr(t)),null;case 13:return iw(e,t,n);case 4:return hh(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=ys(t,null,o,n):wt(e,t,o,n),t.child;case 11:return FS(e,t,t.type,t.pendingProps,n);case 7:return wt(e,t,t.pendingProps,n),t.child;case 8:return wt(e,t,t.pendingProps.children,n),t.child;case 12:return wt(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,Ya(t,t.type,o.value),wt(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,ms(t),a=Tt(a),o=o(a),t.flags|=1,wt(e,t,o,n),t.child;case 14:return HS(e,t,t.type,t.pendingProps,n);case 15:return rw(e,t,t.type,t.pendingProps,n);case 19:return lw(e,t,n);case 31:return cR(e,t,n);case 22:return sw(e,t,n,t.pendingProps);case 24:return ms(t),o=Tt(ot),e===null?(a=Nx(),a===null&&(a=Ee,r=zx(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},Hx(t),Ya(t,ot,a)):((e.lanes&n)!==0&&(Zg(e,t),ou(t,null,null,n),nu()),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),Ya(t,ot,o)):(o=r.cache,Ya(t,ot,o),o!==a.cache&&jg(t,[ot],n,!0))),wt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function $o(e){e.flags|=4}function hg(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(Rw())e.flags|=8192;else throw fs=Lh,Fx}else e.flags&=-16777217}function ZS(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!n_(t))if(Rw())e.flags|=8192;else throw fs=Lh,Fx}function jp(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?D3():536870912,e.lanes|=t,ul|=t)}function Gc(e,t){if(!ge)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 Pe(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 dR(e,t,n){var o=t.pendingProps;switch(Bx(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pe(t),null;case 1:return Pe(t),null;case 3:return n=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),ia(ot),al(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Pi(t)?$o(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,rg())),Pe(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?($o(t),r!==null?(Pe(t),ZS(t,r)):(Pe(t),hg(t,a,null,o,n))):r?r!==e.memoizedState?($o(t),Pe(t),ZS(t,r)):(Pe(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&$o(t),Pe(t),hg(t,a,e,o,n)),null;case 27:if(mh(t),n=ar.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Pe(t),null}e=wo.current,Pi(t)?LS(t,e):(e=Jw(a,o,n),t.stateNode=e,$o(t))}return Pe(t),null;case 5:if(mh(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Pe(t),null}if(r=wo.current,Pi(t))LS(t,r);else{var s=Bh(ar.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[_t]=t,r[Yt]=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(It(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&&$o(t)}}return Pe(t),hg(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=ar.current,Pi(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Ct,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||Yw(e.nodeValue,n)),e||hr(t,!0)}else e=Bh(e).createTextNode(o),e[_t]=t,t.stateNode=e}return Pe(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=Pi(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[_t]=t}else hs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Pe(t),e=!1}else n=rg(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ln(t),t):(ln(t),null);if((t.flags&128)!==0)throw Error(O(558))}return Pe(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Pi(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[_t]=t}else hs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Pe(t),a=!1}else a=rg(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(ln(t),t):(ln(t),null)}return ln(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),jp(t,t.updateQueue),Pe(t),null);case 4:return al(),e===null&&c1(t.stateNode.containerInfo),Pe(t),null;case 10:return ia(t.type),Pe(t),null;case 19:if(At(Ke),o=t.memoizedState,o===null)return Pe(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)Gc(o,!1);else{if(Xe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=kh(e),r!==null){for(t.flags|=128,Gc(o,!1),e=r.updateQueue,t.updateQueue=e,jp(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)uk(n,e),n=n.sibling;return Me(Ke,Ke.current&1|2),ge&&ta(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&dn()>Eh&&(t.flags|=128,a=!0,Gc(o,!1),t.lanes=4194304)}else{if(!a)if(e=kh(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,jp(t,e),Gc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!ge)return Pe(t),null}else 2*dn()-o.renderingStartTime>Eh&&n!==536870912&&(t.flags|=128,a=!0,Gc(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=dn(),e.sibling=null,n=Ke.current,Me(Ke,a?n&1|2:n&1),ge&&ta(t,o.treeForkCount),e):(Pe(t),null);case 22:case 23:return ln(t),Ux(),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&&(Pe(t),t.subtreeFlags&6&&(t.flags|=8192)):Pe(t),n=t.updateQueue,n!==null&&jp(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&&At(ds),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ia(ot),Pe(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function fR(e,t){switch(Bx(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ia(ot),al(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return mh(t),null;case 31:if(t.memoizedState!==null){if(ln(t),t.alternate===null)throw Error(O(340));hs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ln(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));hs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return At(Ke),null;case 4:return al(),null;case 10:return ia(t.type),null;case 22:case 23:return ln(t),Ux(),e!==null&&At(ds),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ia(ot),null;case 25:return null;default:return null}}function uw(e,t){switch(Bx(t),t.tag){case 3:ia(ot),al();break;case 26:case 27:case 5:mh(t);break;case 4:al();break;case 31:t.memoizedState!==null&&ln(t);break;case 13:ln(t);break;case 19:At(Ke);break;case 10:ia(t.type);break;case 22:case 23:ln(t),Ux(),e!==null&&At(ds);break;case 24:ia(ot)}}function Ou(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 mr(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 dw(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ak(t,n)}catch(o){Ce(e,e.return,o)}}}function fw(e,t,n){n.props=xs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Ce(e,t,o)}}function ru(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 ko(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 pw(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 mg(e,t,n){try{var o=e.stateNode;OR(o,e.type,n,t),o[Yt]=t}catch(a){Ce(e,e.return,a)}}function hw(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&xr(e.type)||e.tag===4}function yg(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||hw(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&&xr(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 ax(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=aa));else if(o!==4&&(o===27&&xr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(ax(e,t,n),e=e.sibling;e!==null;)ax(e,t,n),e=e.sibling}function Ih(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&&xr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Ih(e,t,n),e=e.sibling;e!==null;)Ih(e,t,n),e=e.sibling}function mw(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);It(t,o,n),t[_t]=e,t[Yt]=n}catch(r){Ce(e,e.return,r)}}var na=!1,nt=!1,gg=!1,XS=typeof WeakSet=="function"?WeakSet:Set,xt=null;function pR(e,t){if(e=e.containerInfo,dx=Hh,e=nk(e),Mx(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(fx={focusedElem:e,selectionRange:n},Hh=!1,xt=t;xt!==null;)if(t=xt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,xt=e;else for(;xt!==null;){switch(t=xt,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=xs(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)hx(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":hx(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,xt=e;break}xt=t.return}}function yw(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:Jo(e,n),o&4&&Ou(5,n);break;case 1:if(Jo(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Ce(n,n.return,s)}else{var a=xs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Ce(n,n.return,s)}}o&64&&dw(n),o&512&&ru(n,n.return);break;case 3:if(Jo(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{Ak(e,t)}catch(s){Ce(n,n.return,s)}}break;case 27:t===null&&o&4&&mw(n);case 26:case 5:Jo(e,n),t===null&&o&4&&pw(n),o&512&&ru(n,n.return);break;case 12:Jo(e,n);break;case 31:Jo(e,n),o&4&&bw(e,n);break;case 13:Jo(e,n),o&4&&Aw(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=LR.bind(null,n),HR(e,n))));break;case 22:if(o=n.memoizedState!==null||na,!o){t=t!==null&&t.memoizedState!==null||nt,a=na;var r=nt;na=o,(nt=t)&&!r?ea(e,n,(n.subtreeFlags&8772)!==0):Jo(e,n),na=a,nt=r}break;case 30:break;default:Jo(e,n)}}function gw(e){var t=e.alternate;t!==null&&(e.alternate=null,gw(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&wx(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 Ge=null,Vt=!1;function Qo(e,t,n){for(n=n.child;n!==null;)xw(e,t,n),n=n.sibling}function xw(e,t,n){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(wu,n)}catch{}switch(n.tag){case 26:nt||ko(n,t),Qo(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:nt||ko(n,t);var o=Ge,a=Vt;xr(n.type)&&(Ge=n.stateNode,Vt=!1),Qo(e,t,n),cu(n.stateNode),Ge=o,Vt=a;break;case 5:nt||ko(n,t);case 6:if(o=Ge,a=Vt,Ge=null,Qo(e,t,n),Ge=o,Vt=a,Ge!==null)if(Vt)try{(Ge.nodeType===9?Ge.body:Ge.nodeName==="HTML"?Ge.ownerDocument.body:Ge).removeChild(n.stateNode)}catch(r){Ce(n,t,r)}else try{Ge.removeChild(n.stateNode)}catch(r){Ce(n,t,r)}break;case 18:Ge!==null&&(Vt?(e=Ge,c3(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),hl(e)):c3(Ge,n.stateNode));break;case 4:o=Ge,a=Vt,Ge=n.stateNode.containerInfo,Vt=!0,Qo(e,t,n),Ge=o,Vt=a;break;case 0:case 11:case 14:case 15:mr(2,n,t),nt||mr(4,n,t),Qo(e,t,n);break;case 1:nt||(ko(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&fw(n,t,o)),Qo(e,t,n);break;case 21:Qo(e,t,n);break;case 22:nt=(o=nt)||n.memoizedState!==null,Qo(e,t,n),nt=o;break;default:Qo(e,t,n)}}function bw(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{hl(e)}catch(n){Ce(t,t.return,n)}}}function Aw(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{hl(e)}catch(n){Ce(t,t.return,n)}}function hR(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new XS),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new XS),t;default:throw Error(O(435,e.tag))}}function Vp(e,t){var n=hR(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=SR.bind(null,e,o);o.then(a,a)}})}function Wt(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(xr(i.type)){Ge=i.stateNode,Vt=!1;break e}break;case 5:Ge=i.stateNode,Vt=!1;break e;case 3:case 4:Ge=i.stateNode.containerInfo,Vt=!0;break e}i=i.return}if(Ge===null)throw Error(O(160));xw(r,s,a),Ge=null,Vt=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)vw(t,e),t=t.sibling}var ao=null;function vw(e,t){var n=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Wt(t,e),jt(e),o&4&&(mr(3,e,e.return),Ou(3,e),mr(5,e,e.return));break;case 1:Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),o&64&&na&&(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=ao;if(Wt(t,e),jt(e),o&512&&(nt||n===null||ko(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[Tu]||r[_t]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),It(r,o,n),r[_t]=e,bt(r),o=r;break e;case"link":var s=y3("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),It(r,o,n),a.head.appendChild(r);break;case"meta":if(s=y3("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),It(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[_t]=e,bt(r),o=r}e.stateNode=o}else g3(a,e.type,e.stateNode);else e.stateNode=m3(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?g3(a,e.type,e.stateNode):m3(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&mg(e,e.memoizedProps,n.memoizedProps)}break;case 27:Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),n!==null&&o&4&&mg(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),e.flags&32){a=e.stateNode;try{sl(a,"")}catch(h){Ce(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,mg(e,a,n!==null?n.memoizedProps:a)),o&1024&&(gg=!0);break;case 6:if(Wt(t,e),jt(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(uh=null,a=ao,ao=zh(t.containerInfo),Wt(t,e),ao=a,jt(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{hl(t.containerInfo)}catch(h){Ce(e,e.return,h)}gg&&(gg=!1,Lw(e));break;case 4:o=ao,ao=zh(e.stateNode.containerInfo),Wt(t,e),jt(e),ao=o;break;case 12:Wt(t,e),jt(e);break;case 31:Wt(t,e),jt(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 13:Wt(t,e),jt(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Jh=dn()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=na,u=nt;if(na=c||a,nt=u||l,Wt(t,e),nt=u,na=c,jt(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||na||nt||ls(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?u3(p,!0):u3(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,Vp(e,n))));break;case 19:Wt(t,e),jt(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 30:break;case 21:break;default:Wt(t,e),jt(e)}}function jt(e){var t=e.flags;if(t&2){try{for(var n,o=e.return;o!==null;){if(hw(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=yg(e);Ih(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(sl(s,""),n.flags&=-33);var i=yg(e);Ih(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=yg(e);ax(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 Lw(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Lw(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Jo(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)yw(e,t.alternate,t),t=t.sibling}function ls(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:mr(4,t,t.return),ls(t);break;case 1:ko(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&fw(t,t.return,n),ls(t);break;case 27:cu(t.stateNode);case 26:case 5:ko(t,t.return),ls(t);break;case 22:t.memoizedState===null&&ls(t);break;case 30:ls(t);break;default:ls(t)}e=e.sibling}}function ea(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:ea(a,r,n),Ou(4,r);break;case 1:if(ea(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++)bk(l[a],i)}catch(c){Ce(o,o.return,c)}}n&&s&64&&dw(r),ru(r,r.return);break;case 27:mw(r);case 26:case 5:ea(a,r,n),n&&o===null&&s&4&&pw(r),ru(r,r.return);break;case 12:ea(a,r,n);break;case 31:ea(a,r,n),n&&s&4&&bw(a,r);break;case 13:ea(a,r,n),n&&s&4&&Aw(a,r);break;case 22:r.memoizedState===null&&ea(a,r,n),ru(r,r.return);break;case 30:break;default:ea(a,r,n)}t=t.sibling}}function o1(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&&Eu(n))}function a1(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Eu(e))}function oo(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Sw(e,t,n,o),t=t.sibling}function Sw(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:oo(e,t,n,o),a&2048&&Ou(9,t);break;case 1:oo(e,t,n,o);break;case 3:oo(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&&Eu(e)));break;case 12:if(a&2048){oo(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 oo(e,t,n,o);break;case 31:oo(e,t,n,o);break;case 13:oo(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?oo(e,t,n,o):su(e,t):r._visibility&2?oo(e,t,n,o):(r._visibility|=2,zi(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&o1(s,t);break;case 24:oo(e,t,n,o),a&2048&&a1(t.alternate,t);break;default:oo(e,t,n,o)}}function zi(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:zi(r,s,i,l,a),Ou(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?zi(r,s,i,l,a):su(r,s):(u._visibility|=2,zi(r,s,i,l,a)),a&&c&2048&&o1(s.alternate,s);break;case 24:zi(r,s,i,l,a),a&&c&2048&&a1(s.alternate,s);break;default:zi(r,s,i,l,a)}t=t.sibling}}function su(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:su(n,o),a&2048&&o1(o.alternate,o);break;case 24:su(n,o),a&2048&&a1(o.alternate,o);break;default:su(n,o)}t=t.sibling}}var Kc=8192;function Bi(e,t,n){if(e.subtreeFlags&Kc)for(e=e.child;e!==null;)kw(e,t,n),e=e.sibling}function kw(e,t,n){switch(e.tag){case 26:Bi(e,t,n),e.flags&Kc&&e.memoizedState!==null&&QR(n,ao,e.memoizedState,e.memoizedProps);break;case 5:Bi(e,t,n);break;case 3:case 4:var o=ao;ao=zh(e.stateNode.containerInfo),Bi(e,t,n),ao=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Kc,Kc=16777216,Bi(e,t,n),Kc=o):Bi(e,t,n));break;default:Bi(e,t,n)}}function ww(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 qc(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];xt=o,Cw(o,e)}ww(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)_w(e),e=e.sibling}function _w(e){switch(e.tag){case 0:case 11:case 15:qc(e),e.flags&2048&&mr(9,e,e.return);break;case 3:qc(e);break;case 12:qc(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,lh(e)):qc(e);break;default:qc(e)}}function lh(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];xt=o,Cw(o,e)}ww(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:mr(8,t,t.return),lh(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,lh(t));break;default:lh(t)}e=e.sibling}}function Cw(e,t){for(;xt!==null;){var n=xt;switch(n.tag){case 0:case 11:case 15:mr(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:Eu(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,xt=o;else e:for(n=e;xt!==null;){o=xt;var a=o.sibling,r=o.return;if(gw(o),o===n){xt=null;break e}if(a!==null){a.return=r,xt=a;break e}xt=r}}}var mR={getCacheForType:function(e){var t=Tt(ot),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Tt(ot).controller.signal}},yR=typeof WeakMap=="function"?WeakMap:Map,ve=0,Ee=null,fe=null,me=0,_e=0,sn=null,tr=!1,bl=!1,r1=!1,pa=0,Xe=0,yr=0,ps=0,s1=0,un=0,ul=0,iu=null,Zt=null,rx=!1,Jh=0,Tw=0,Eh=1/0,Mh=null,lr=null,ct=0,cr=null,dl=null,la=0,sx=0,ix=null,Iw=null,lu=0,lx=null;function hn(){return(ve&2)!==0&&me!==0?me&-me:K.T!==null?l1():N3()}function Ew(){if(un===0)if((me&536870912)===0||ge){var e=Bp;Bp<<=1,(Bp&3932160)===0&&(Bp=262144),un=e}else un=536870912;return e=yn.current,e!==null&&(e.flags|=32),un}function Xt(e,t,n){(e===Ee&&(_e===2||_e===9)||e.cancelPendingCommit!==null)&&(fl(e,0),nr(e,me,un,!1)),Cu(e,n),((ve&2)===0||e!==Ee)&&(e===Ee&&((ve&2)===0&&(ps|=n),Xe===4&&nr(e,me,un,!1)),Co(e))}function Mw(e,t,n){if((ve&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||_u(e,t),a=o?bR(e,t):xg(e,t,!0),r=o;do{if(a===0){bl&&!o&&nr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!gR(n)){a=xg(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=iu;var l=i.current.memoizedState.isDehydrated;if(l&&(fl(i,s).flags|=256),s=xg(i,s,!1),s!==2){if(r1&&!l){i.errorRecoveryDisabledLanes|=r,ps|=r,a=4;break e}r=Zt,Zt=a,r!==null&&(Zt===null?Zt=r:Zt.push.apply(Zt,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){fl(e,0),nr(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:nr(o,t,un,!tr);break e;case 2:Zt=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=Jh+300-dn(),10<a)){if(nr(o,t,un,!tr),Gh(o,0,!0)!==0)break e;la=t,o.timeoutHandle=$w(YS.bind(null,o,n,Zt,Mh,rx,t,un,ps,ul,tr,r,"Throttled",-0,0),a);break e}YS(o,n,Zt,Mh,rx,t,un,ps,ul,tr,r,null,-0,0)}}break}while(!0);Co(e)}function YS(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:aa},kw(t,r,d);var h=(r&62914560)===r?Jh-dn():(r&4194048)===r?Tw-dn():0;if(h=JR(d,h),h!==null){la=r,e.cancelPendingCommit=h($S.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),nr(e,r,s,!c);return}}$S(e,t,r,n,o,a,s,i,l)}function gR(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(!mn(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 nr(e,t,n,o){t&=~s1,t&=~ps,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-pn(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&P3(e,n,t)}function em(){return(ve&6)===0?(Ru(0,!1),!1):!0}function i1(){if(fe!==null){if(_e===0)var e=fe.return;else e=fe,ra=Ss=null,Vx(e),tl=null,yu=0,e=fe;for(;e!==null;)uw(e.alternate,e),e=e.return;fe=null}}function fl(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,PR(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),la=0,i1(),Ee=e,fe=n=sa(e.current,null),me=t,_e=0,sn=null,tr=!1,bl=_u(e,t),r1=!1,ul=un=s1=ps=yr=Xe=0,Zt=iu=null,rx=!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-pn(o),r=1<<a;t|=e[a],o&=~r}return pa=t,Vh(),n}function Ow(e,t){oe=null,K.H=xu,t===xl||t===Xh?(t=CS(),_e=3):t===Fx?(t=CS(),_e=4):_e=t===t1?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,sn=t,fe===null&&(Xe=1,Ch(e,Mn(t,e.current)))}function Rw(){var e=yn.current;return e===null?!0:(me&4194048)===me?Rn===null:(me&62914560)===me||(me&536870912)!==0?e===Rn:!1}function Dw(){var e=K.H;return K.H=xu,e===null?xu:e}function Pw(){var e=K.A;return K.A=mR,e}function Oh(){Xe=4,tr||(me&4194048)!==me&&yn.current!==null||(bl=!0),(yr&134217727)===0&&(ps&134217727)===0||Ee===null||nr(Ee,me,un,!1)}function xg(e,t,n){var o=ve;ve|=2;var a=Dw(),r=Pw();(Ee!==e||me!==t)&&(Mh=null,fl(e,t)),t=!1;var s=Xe;e:do try{if(_e!==0&&fe!==null){var i=fe,l=sn;switch(_e){case 8:i1(),s=6;break e;case 3:case 2:case 9:case 6:yn.current===null&&(t=!0);var c=_e;if(_e=0,sn=null,Ki(e,i,l,c),n&&bl){s=0;break e}break;default:c=_e,_e=0,sn=null,Ki(e,i,l,c)}}xR(),s=Xe;break}catch(u){Ow(e,u)}while(!0);return t&&e.shellSuspendCounter++,ra=Ss=null,ve=o,K.H=a,K.A=r,fe===null&&(Ee=null,me=0,Vh()),s}function xR(){for(;fe!==null;)Bw(fe)}function bR(e,t){var n=ve;ve|=2;var o=Dw(),a=Pw();Ee!==e||me!==t?(Mh=null,Eh=dn()+500,fl(e,t)):bl=_u(e,t);e:do try{if(_e!==0&&fe!==null){t=fe;var r=sn;t:switch(_e){case 1:_e=0,sn=null,Ki(e,t,r,1);break;case 2:case 9:if(_S(r)){_e=0,sn=null,KS(t);break}t=function(){_e!==2&&_e!==9||Ee!==e||(_e=7),Co(e)},r.then(t,t);break e;case 3:_e=7;break e;case 4:_e=5;break e;case 7:_S(r)?(_e=0,sn=null,KS(t)):(_e=0,sn=null,Ki(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?n_(s):i.stateNode.complete){_e=0,sn=null;var l=i.sibling;if(l!==null)fe=l;else{var c=i.return;c!==null?(fe=c,tm(c)):fe=null}break t}}_e=0,sn=null,Ki(e,t,r,5);break;case 6:_e=0,sn=null,Ki(e,t,r,6);break;case 8:i1(),Xe=6;break e;default:throw Error(O(462))}}AR();break}catch(u){Ow(e,u)}while(!0);return ra=Ss=null,K.H=o,K.A=a,ve=n,fe!==null?0:(Ee=null,me=0,Vh(),Xe)}function AR(){for(;fe!==null&&!qM();)Bw(fe)}function Bw(e){var t=cw(e.alternate,e,pa);e.memoizedProps=e.pendingProps,t===null?tm(e):fe=t}function KS(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=qS(n,t,t.pendingProps,t.type,void 0,me);break;case 11:t=qS(n,t,t.pendingProps,t.type.render,t.ref,me);break;case 5:Vx(t);default:uw(n,t),t=fe=uk(t,pa),t=cw(n,t,pa)}e.memoizedProps=e.pendingProps,t===null?tm(e):fe=t}function Ki(e,t,n,o){ra=Ss=null,Vx(t),tl=null,yu=0;var a=t.return;try{if(lR(e,a,t,n,me)){Xe=1,Ch(e,Mn(n,e.current)),fe=null;return}}catch(r){if(a!==null)throw fe=a,r;Xe=1,Ch(e,Mn(n,e.current)),fe=null;return}t.flags&32768?(ge||o===1?e=!0:bl||(me&536870912)!==0?e=!1:(tr=e=!0,(o===2||o===9||o===3||o===6)&&(o=yn.current,o!==null&&o.tag===13&&(o.flags|=16384))),zw(t,e)):tm(t)}function tm(e){var t=e;do{if((t.flags&32768)!==0){zw(t,tr);return}e=t.return;var n=dR(t.alternate,t,pa);if(n!==null){fe=n;return}if(t=t.sibling,t!==null){fe=t;return}fe=t=e}while(t!==null);Xe===0&&(Xe=5)}function zw(e,t){do{var n=fR(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);Xe=6,fe=null}function $S(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do nm();while(ct!==0);if((ve&6)!==0)throw Error(O(327));if(t!==null){if(t===e.current)throw Error(O(177));if(r=t.lanes|t.childLanes,r|=Ox,JM(e,n,r,s,i,l),e===Ee&&(fe=Ee=null,me=0),dl=t,cr=e,la=n,sx=r,ix=a,Iw=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,kR(yh,function(){return Gw(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=Le.p,Le.p=2,s=ve,ve|=4;try{pR(e,t,n)}finally{ve=s,Le.p=a,K.T=o}}ct=1,Nw(),Fw(),Hw()}}function Nw(){if(ct===1){ct=0;var e=cr,t=dl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=Le.p;Le.p=2;var a=ve;ve|=4;try{vw(t,e);var r=fx,s=nk(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&tk(i.ownerDocument.documentElement,i)){if(l!==null&&Mx(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),b=l.end===void 0?m:Math.min(l.end,h);!p.extend&&m>b&&(s=b,b=m,m=s);var y=bS(i,m),g=bS(i,b);if(y&&g&&(p.rangeCount!==1||p.anchorNode!==y.node||p.anchorOffset!==y.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var x=d.createRange();x.setStart(y.node,y.offset),p.removeAllRanges(),m>b?(p.addRange(x),p.extend(g.node,g.offset)):(x.setEnd(g.node,g.offset),p.addRange(x))}}}}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}}Hh=!!dx,fx=dx=null}finally{ve=a,Le.p=o,K.T=n}}e.current=t,ct=2}}function Fw(){if(ct===2){ct=0;var e=cr,t=dl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=Le.p;Le.p=2;var a=ve;ve|=4;try{yw(e,t.alternate,t)}finally{ve=a,Le.p=o,K.T=n}}ct=3}}function Hw(){if(ct===4||ct===3){ct=0,WM();var e=cr,t=dl,n=la,o=Iw;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ct=5:(ct=0,dl=cr=null,Uw(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(lr=null),kx(n),t=t.stateNode,fn&&typeof fn.onCommitFiberRoot=="function")try{fn.onCommitFiberRoot(wu,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=Le.p,Le.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,Le.p=a}}(la&3)!==0&&nm(),Co(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===lx?lu++:(lu=0,lx=e):lu=0,Ru(0,!1)}}function Uw(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Eu(t)))}function nm(){return Nw(),Fw(),Hw(),Gw()}function Gw(){if(ct!==5)return!1;var e=cr,t=sx;sx=0;var n=kx(la),o=K.T,a=Le.p;try{Le.p=32>n?32:n,K.T=null,n=ix,ix=null;var r=cr,s=la;if(ct=0,dl=cr=null,la=0,(ve&6)!==0)throw Error(O(331));var i=ve;if(ve|=4,_w(r.current),Sw(r,r.current,s,n),ve=i,Ru(0,!1),fn&&typeof fn.onPostCommitFiberRoot=="function")try{fn.onPostCommitFiberRoot(wu,r)}catch{}return!0}finally{Le.p=a,K.T=o,Uw(e,t)}}function QS(e,t,n){t=Mn(n,t),t=tx(e.stateNode,t,2),e=ir(e,t,2),e!==null&&(Cu(e,2),Co(e))}function Ce(e,t,n){if(e.tag===3)QS(e,e,n);else for(;t!==null;){if(t.tag===3){QS(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(lr===null||!lr.has(o))){e=Mn(n,e),n=ow(2),o=ir(t,n,2),o!==null&&(aw(n,o,t,e),Cu(o,2),Co(o));break}}t=t.return}}function bg(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new yR;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)||(r1=!0,a.add(n),e=vR.bind(null,e,t,n),t.then(e,e))}function vR(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ee===e&&(me&n)===n&&(Xe===4||Xe===3&&(me&62914560)===me&&300>dn()-Jh?(ve&2)===0&&fl(e,0):s1|=n,ul===me&&(ul=0)),Co(e)}function qw(e,t){t===0&&(t=D3()),e=Ls(e,t),e!==null&&(Cu(e,t),Co(e))}function LR(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qw(e,n)}function SR(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),qw(e,n)}function kR(e,t){return Lx(e,t)}var Rh=null,Ni=null,cx=!1,Dh=!1,Ag=!1,or=0;function Co(e){e!==Ni&&e.next===null&&(Ni===null?Rh=Ni=e:Ni=Ni.next=e),Dh=!0,cx||(cx=!0,_R())}function Ru(e,t){if(!Ag&&Dh){Ag=!0;do for(var n=!1,o=Rh;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-pn(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,JS(o,r))}else r=me,r=Gh(o,o===Ee?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||_u(o,r)||(n=!0,JS(o,r));o=o.next}while(n);Ag=!1}}function wR(){Ww()}function Ww(){Dh=cx=!1;var e=0;or!==0&&DR()&&(e=or);for(var t=dn(),n=null,o=Rh;o!==null;){var a=o.next,r=jw(o,t);r===0?(o.next=null,n===null?Rh=a:n.next=a,a===null&&(Ni=n)):(n=o,(e!==0||(r&3)!==0)&&(Dh=!0)),o=a}ct!==0&&ct!==5||Ru(e,!1),or!==0&&(or=0)}function jw(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-pn(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=QM(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=Ee,n=me,n=Gh(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,n===0||e===t&&(_e===2||_e===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Yy(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||_u(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&Yy(o),kx(n)){case 2:case 8:n=O3;break;case 32:n=yh;break;case 268435456:n=R3;break;default:n=yh}return o=Vw.bind(null,e),n=Lx(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&Yy(o),e.callbackPriority=2,e.callbackNode=null,2}function Vw(e,t){if(ct!==0&&ct!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(nm()&&e.callbackNode!==n)return null;var o=me;return o=Gh(e,e===Ee?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Mw(e,o,t),jw(e,dn()),e.callbackNode!=null&&e.callbackNode===n?Vw.bind(null,e):null)}function JS(e,t){if(nm())return null;Mw(e,t,!0)}function _R(){BR(function(){(ve&6)!==0?Lx(M3,wR):Ww()})}function l1(){if(or===0){var e=il;e===0&&(e=Pp,Pp<<=1,(Pp&261888)===0&&(Pp=256)),or=e}return or}function e3(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Jp(""+e)}function t3(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 CR(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=e3((a[Yt]||null).action),s=o.submitter;s&&(t=(t=s[Yt]||null)?e3(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new qh("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(or!==0){var l=s?t3(a,s):new FormData(a);Jg(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?t3(a,s):new FormData(a),Jg(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(Zp=0;Zp<Ug.length;Zp++)Xp=Ug[Zp],n3=Xp.toLowerCase(),o3=Xp[0].toUpperCase()+Xp.slice(1),ro(n3,"on"+o3);var Xp,n3,o3,Zp;ro(ak,"onAnimationEnd");ro(rk,"onAnimationIteration");ro(sk,"onAnimationStart");ro("dblclick","onDoubleClick");ro("focusin","onFocus");ro("focusout","onBlur");ro(jO,"onTransitionRun");ro(VO,"onTransitionStart");ro(ZO,"onTransitionCancel");ro(ik,"onTransitionEnd");rl("onMouseEnter",["mouseout","mouseover"]);rl("onMouseLeave",["mouseout","mouseover"]);rl("onPointerEnter",["pointerout","pointerover"]);rl("onPointerLeave",["pointerout","pointerover"]);bs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bs("onBeforeInput",["compositionend","keypress","textInput","paste"]);bs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bu="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(" "),TR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bu));function Zw(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){xh(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){xh(u)}a.currentTarget=null,r=l}}}}function de(e,t){var n=t[Rg];n===void 0&&(n=t[Rg]=new Set);var o=e+"__bubble";n.has(o)||(Xw(t,e,2,!1),n.add(o))}function vg(e,t,n){var o=0;t&&(o|=4),Xw(n,e,o,t)}var Yp="_reactListening"+Math.random().toString(36).slice(2);function c1(e){if(!e[Yp]){e[Yp]=!0,F3.forEach(function(n){n!=="selectionchange"&&(TR.has(n)||vg(n,!1,e),vg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Yp]||(t[Yp]=!0,vg("selectionchange",!1,t))}}function Xw(e,t,n,o){switch(i_(t)){case 2:var a=nD;break;case 8:a=oD;break;default:a=p1}n=a.bind(null,t,n,e),a=void 0,!Ng||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 Lg(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=Ui(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}Z3(function(){var c=r,u=Cx(n),d=[];e:{var f=lk.get(e);if(f!==void 0){var p=qh,h=e;switch(e){case"keypress":if(th(n)===0)break e;case"keydown":case"keyup":p=SO;break;case"focusin":h="focus",p=eg;break;case"focusout":h="blur",p=eg;break;case"beforeblur":case"afterblur":p=eg;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=uS;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=dO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=_O;break;case ak:case rk:case sk:p=hO;break;case ik:p=TO;break;case"scroll":case"scrollend":p=cO;break;case"wheel":p=EO;break;case"copy":case"cut":case"paste":p=yO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=fS;break;case"toggle":case"beforetoggle":p=OO}var m=(t&4)!==0,b=!m&&(e==="scroll"||e==="scrollend"),y=m?f!==null?f+"Capture":null:f;m=[];for(var g=c,x;g!==null;){var A=g;if(x=A.stateNode,A=A.tag,A!==5&&A!==26&&A!==27||x===null||y===null||(A=du(g,y),A!=null&&m.push(Au(g,A,x))),b)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!==zg&&(h=n.relatedTarget||n.fromElement)&&(Ui(h)||h[ml]))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?Ui(h):null,h!==null&&(b=ku(h),m=h.tag,h!==b||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=uS,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=fS,A="onPointerLeave",y="onPointerEnter",g="pointer"),b=p==null?f:Xc(p),x=h==null?f:Xc(h),f=new m(A,g+"leave",p,n,u),f.target=b,f.relatedTarget=x,A=null,Ui(u)===c&&(m=new m(y,g+"enter",h,n,u),m.target=x,m.relatedTarget=b,A=m),b=A,p&&h)t:{for(m=IR,y=p,g=h,x=0,A=y;A;A=m(A))x++;A=0;for(var C=g;C;C=m(C))A++;for(;0<x-A;)y=m(y),x--;for(;0<A-x;)g=m(g),A--;for(;x--;){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&&a3(d,f,p,m,!1),h!==null&&b!==null&&a3(d,b,h,m,!0)}}e:{if(f=c?Xc(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var _=yS;else if(mS(f))if(J3)_=GO;else{_=HO;var v=FO}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&_x(c.elementType)&&(_=yS):_=UO;if(_&&(_=_(e,c))){Q3(d,_,n,u);break e}v&&v(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&Bg(f,"number",f.value)}switch(v=c?Xc(c):window,e){case"focusin":(mS(v)||v.contentEditable==="true")&&(Wi=v,Fg=c,Jc=null);break;case"focusout":Jc=Fg=Wi=null;break;case"mousedown":Hg=!0;break;case"contextmenu":case"mouseup":case"dragend":Hg=!1,AS(d,n,u);break;case"selectionchange":if(WO)break;case"keydown":case"keyup":AS(d,n,u)}var I;if(Ex)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 qi?K3(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(Y3&&n.locale!=="ko"&&(qi||k!=="onCompositionStart"?k==="onCompositionEnd"&&qi&&(I=X3()):(er=u,Tx="value"in er?er.value:er.textContent,qi=!0)),v=Ph(c,k),0<v.length&&(k=new dS(k,e,null,n,u),d.push({event:k,listeners:v}),I?k.data=I:(I=$3(n),I!==null&&(k.data=I)))),(I=DO?PO(e,n):BO(e,n))&&(k=Ph(c,"onBeforeInput"),0<k.length&&(v=new dS("onBeforeInput","beforeinput",null,n,u),d.push({event:v,listeners:k}),v.data=I)),CR(d,e,c,n,u)}Zw(d,t)})}function Au(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ph(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=du(e,n),a!=null&&o.unshift(Au(e,a,r)),a=du(e,t),a!=null&&o.push(Au(e,a,r))),e.tag===3)return o;e=e.return}return[]}function IR(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function a3(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=du(n,r),c!=null&&s.unshift(Au(n,c,l))):a||(c=du(n,r),c!=null&&s.push(Au(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var ER=/\r\n?/g,MR=/\u0000|\uFFFD/g;function r3(e){return(typeof e=="string"?e:""+e).replace(ER,`
9
+ `).replace(MR,"")}function Yw(e,t){return t=r3(t),r3(e)===t}function Te(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||sl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&sl(e,""+o);break;case"className":Np(e,"class",o);break;case"tabIndex":Np(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Np(e,n,o);break;case"style":V3(e,o,r);break;case"data":if(t!=="object"){Np(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=Jp(""+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"&&Te(e,t,"name",a.name,a,null),Te(e,t,"formEncType",a.formEncType,a,null),Te(e,t,"formMethod",a.formMethod,a,null),Te(e,t,"formTarget",a.formTarget,a,null)):(Te(e,t,"encType",a.encType,a,null),Te(e,t,"method",a.method,a,null),Te(e,t,"target",a.target,a,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=Jp(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=aa);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=Jp(""+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),Qp(e,"popover",o);break;case"xlinkActuate":Ko(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Ko(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Ko(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Ko(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Ko(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Ko(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Qp(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=iO.get(n)||n,Qp(e,n,o))}}function ux(e,t,n,o,a,r){switch(n){case"style":V3(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"?sl(e,o):(typeof o=="number"||typeof o=="bigint")&&sl(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=aa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!H3.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[Yt]||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,""):Qp(e,n,o)}}}function It(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:Te(e,t,r,s,n,null)}}a&&Te(e,t,"srcSet",n.srcSet,n,null),o&&Te(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:Te(e,t,o,u,n,null)}}q3(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:Te(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Qi(e,!!o,t,!1):n!=null&&Qi(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:Te(e,t,s,i,n,null)}j3(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:Te(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<bu.length;o++)de(bu[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:Te(e,t,c,o,n,null)}return;default:if(_x(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&ux(e,t,u,o,n,void 0));return}}for(i in n)n.hasOwnProperty(i)&&(o=n[i],o!=null&&Te(e,t,i,o,n,null))}function OR(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)||Te(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&&Te(e,t,f,p,o,d)}}Pg(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)||Te(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&&Te(e,t,a,r,o,l)}t=i,n=s,o=p,f!=null?Qi(e,!!n,f,!1):!!o!=!!n&&(t!=null?Qi(e,!!n,t,!0):Qi(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:Te(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&&Te(e,t,s,a,o,r)}W3(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:Te(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:Te(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)&&Te(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:Te(e,t,c,f,o,p)}return;default:if(_x(t)){for(var b in n)f=n[b],n.hasOwnProperty(b)&&f!==void 0&&!o.hasOwnProperty(b)&&ux(e,t,b,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||ux(e,t,u,f,o,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&f!=null&&!o.hasOwnProperty(y)&&Te(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||Te(e,t,d,f,o,p)}function s3(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function RR(){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&&s3(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&&s3(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 dx=null,fx=null;function Bh(e){return e.nodeType===9?e:e.ownerDocument}function i3(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 Kw(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 px(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 Sg=null;function DR(){var e=window.event;return e&&e.type==="popstate"?e===Sg?!1:(Sg=e,!0):(Sg=null,!1)}var $w=typeof setTimeout=="function"?setTimeout:void 0,PR=typeof clearTimeout=="function"?clearTimeout:void 0,l3=typeof Promise=="function"?Promise:void 0,BR=typeof queueMicrotask=="function"?queueMicrotask:typeof l3<"u"?function(e){return l3.resolve(null).then(e).catch(zR)}:$w;function zR(e){setTimeout(function(){throw e})}function xr(e){return e==="head"}function c3(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),hl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")cu(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,cu(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[Tu]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&cu(e.ownerDocument.body);n=a}while(n);hl(t)}function u3(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 hx(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":hx(n),wx(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function NR(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[Tu])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=Dn(e.nextSibling),e===null)break}return null}function FR(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Dn(e.nextSibling),e===null))return null;return e}function Qw(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Dn(e.nextSibling),e===null))return null;return e}function mx(e){return e.data==="$?"||e.data==="$~"}function yx(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function HR(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 Dn(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 gx=null;function d3(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Dn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function f3(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 Jw(e,t,n){switch(t=Bh(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 cu(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);wx(e)}var Pn=new Map,p3=new Set;function zh(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ha=Le.d;Le.d={f:UR,r:GR,D:qR,C:WR,L:jR,m:VR,X:XR,S:ZR,M:YR};function UR(){var e=ha.f(),t=em();return e||t}function GR(e){var t=yl(e);t!==null&&t.tag===5&&t.type==="form"?Vk(t):ha.r(e)}var Al=typeof document>"u"?null:document;function e_(e,t,n){var o=Al;if(o&&typeof t=="string"&&t){var a=En(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),p3.has(a)||(p3.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),It(t,"link",e),bt(t),o.head.appendChild(t)))}}function qR(e){ha.D(e),e_("dns-prefetch",e,null)}function WR(e,t){ha.C(e,t),e_("preconnect",e,t)}function jR(e,t,n){ha.L(e,t,n);var o=Al;if(o&&e&&t){var a='link[rel="preload"][as="'+En(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+En(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+En(n.imageSizes)+'"]')):a+='[href="'+En(e)+'"]';var r=a;switch(t){case"style":r=pl(e);break;case"script":r=vl(e)}Pn.has(r)||(e=ze({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Pn.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(Du(r))||t==="script"&&o.querySelector(Pu(r))||(t=o.createElement("link"),It(t,"link",e),bt(t),o.head.appendChild(t)))}}function VR(e,t){ha.m(e,t);var n=Al;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+En(o)+'"][href="'+En(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=vl(e)}if(!Pn.has(r)&&(e=ze({rel:"modulepreload",href:e},t),Pn.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Pu(r)))return}o=n.createElement("link"),It(o,"link",e),bt(o),n.head.appendChild(o)}}}function ZR(e,t,n){ha.S(e,t,n);var o=Al;if(o&&e){var a=$i(o).hoistableStyles,r=pl(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(Du(r)))i.loading=5;else{e=ze({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Pn.get(r))&&u1(e,n);var l=s=o.createElement("link");bt(l),It(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,ch(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function XR(e,t){ha.X(e,t);var n=Al;if(n&&e){var o=$i(n).hoistableScripts,a=vl(e),r=o.get(a);r||(r=n.querySelector(Pu(a)),r||(e=ze({src:e,async:!0},t),(t=Pn.get(a))&&d1(e,t),r=n.createElement("script"),bt(r),It(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function YR(e,t){ha.M(e,t);var n=Al;if(n&&e){var o=$i(n).hoistableScripts,a=vl(e),r=o.get(a);r||(r=n.querySelector(Pu(a)),r||(e=ze({src:e,async:!0,type:"module"},t),(t=Pn.get(a))&&d1(e,t),r=n.createElement("script"),bt(r),It(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function h3(e,t,n,o){var a=(a=ar.current)?zh(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=pl(n.href),n=$i(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=pl(n.href);var r=$i(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(Du(e)))&&!r._p&&(s.instance=r,s.state.loading=5),Pn.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},Pn.set(e,n),r||KR(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=vl(n),n=$i(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 pl(e){return'href="'+En(e)+'"'}function Du(e){return'link[rel="stylesheet"]['+e+"]"}function t_(e){return ze({},e,{"data-precedence":e.precedence,precedence:null})}function KR(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}),It(t,"link",n),bt(t),e.head.appendChild(t))}function vl(e){return'[src="'+En(e)+'"]'}function Pu(e){return"script[async]"+e}function m3(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+En(n.href)+'"]');if(o)return t.instance=o,bt(o),o;var a=ze({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),bt(o),It(o,"style",a),ch(o,n.precedence,e),t.instance=o;case"stylesheet":a=pl(n.href);var r=e.querySelector(Du(a));if(r)return t.state.loading|=4,t.instance=r,bt(r),r;o=t_(n),(a=Pn.get(a))&&u1(o,a),r=(e.ownerDocument||e).createElement("link"),bt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),It(r,"link",o),t.state.loading|=4,ch(r,n.precedence,e),t.instance=r;case"script":return r=vl(n.src),(a=e.querySelector(Pu(r)))?(t.instance=a,bt(a),a):(o=n,(a=Pn.get(r))&&(o=ze({},n),d1(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),bt(a),It(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,ch(o,n.precedence,e));return t.instance}function ch(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 u1(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function d1(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var uh=null;function y3(e,t,n){if(uh===null){var o=new Map,a=uh=new Map;a.set(n,o)}else a=uh,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[Tu]||r[_t]||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 g3(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function $R(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 n_(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function QR(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=pl(o.href),r=t.querySelector(Du(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,bt(r);return}r=t.ownerDocument||t,o=t_(o),(a=Pn.get(a))&&u1(o,a),r=r.createElement("link"),bt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),It(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=Nh.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var kg=0;function JR(e,t){return e.stylesheets&&e.count===0&&dh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&dh(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&kg===0&&(kg=62500*RR());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&dh(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>kg?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function Nh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)dh(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Fh=null;function dh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Fh=new Map,t.forEach(eD,e),Fh=null,Nh.call(e))}function eD(e,t){if(!(t.state.loading&4)){var n=Fh.get(e);if(n)var o=n.get(null);else{n=new Map,Fh.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=Nh.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 vu={$$typeof:oa,Provider:null,Consumer:null,_currentValue:cs,_currentValue2:cs,_threadCount:0};function tD(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=Ky(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ky(0),this.hiddenUpdates=Ky(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 o_(e,t,n,o,a,r,s,i,l,c,u,d){return e=new tD(e,t,n,s,l,c,u,d,i),t=1,r===!0&&(t|=24),r=cn(3,null,null,t),e.current=r,r.stateNode=e,t=zx(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},Hx(r),e}function a_(e){return e?(e=Zi,e):Zi}function r_(e,t,n,o,a,r){a=a_(a),o.context===null?o.context=a:o.pendingContext=a,o=sr(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=ir(e,o,t),n!==null&&(Xt(n,e,t),tu(n,e,t))}function x3(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function f1(e,t){x3(e,t),(e=e.alternate)&&x3(e,t)}function s_(e){if(e.tag===13||e.tag===31){var t=Ls(e,67108864);t!==null&&Xt(t,e,67108864),f1(e,67108864)}}function b3(e){if(e.tag===13||e.tag===31){var t=hn();t=Sx(t);var n=Ls(e,t);n!==null&&Xt(n,e,t),f1(e,t)}}var Hh=!0;function nD(e,t,n,o){var a=K.T;K.T=null;var r=Le.p;try{Le.p=2,p1(e,t,n,o)}finally{Le.p=r,K.T=a}}function oD(e,t,n,o){var a=K.T;K.T=null;var r=Le.p;try{Le.p=8,p1(e,t,n,o)}finally{Le.p=r,K.T=a}}function p1(e,t,n,o){if(Hh){var a=xx(o);if(a===null)Lg(e,t,o,Uh,n),A3(e,o);else if(rD(a,e,t,n,o))o.stopPropagation();else if(A3(e,o),t&4&&-1<aD.indexOf(e)){for(;a!==null;){var r=yl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=ss(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-pn(s);i.entanglements[1]|=l,s&=~l}Co(r),(ve&6)===0&&(Eh=dn()+500,Ru(0,!1))}}break;case 31:case 13:i=Ls(r,2),i!==null&&Xt(i,r,2),em(),f1(r,2)}if(r=xx(o),r===null&&Lg(e,t,o,Uh,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else Lg(e,t,o,null,n)}}function xx(e){return e=Cx(e),h1(e)}var Uh=null;function h1(e){if(Uh=null,e=Ui(e),e!==null){var t=ku(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=_3(t),e!==null)return e;e=null}else if(n===31){if(e=C3(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 Uh=e,null}function i_(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(jM()){case M3:return 2;case O3:return 8;case yh:case VM:return 32;case R3:return 268435456;default:return 32}default:return 32}}var bx=!1,ur=null,dr=null,fr=null,Lu=new Map,Su=new Map,Qa=[],aD="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 A3(e,t){switch(e){case"focusin":case"focusout":ur=null;break;case"dragenter":case"dragleave":dr=null;break;case"mouseover":case"mouseout":fr=null;break;case"pointerover":case"pointerout":Lu.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Su.delete(t.pointerId)}}function Wc(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=yl(t),t!==null&&s_(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function rD(e,t,n,o,a){switch(t){case"focusin":return ur=Wc(ur,e,t,n,o,a),!0;case"dragenter":return dr=Wc(dr,e,t,n,o,a),!0;case"mouseover":return fr=Wc(fr,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return Lu.set(r,Wc(Lu.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,Su.set(r,Wc(Su.get(r)||null,e,t,n,o,a)),!0}return!1}function l_(e){var t=Ui(e.target);if(t!==null){var n=ku(t);if(n!==null){if(t=n.tag,t===13){if(t=_3(n),t!==null){e.blockedOn=t,oS(e.priority,function(){b3(n)});return}}else if(t===31){if(t=C3(n),t!==null){e.blockedOn=t,oS(e.priority,function(){b3(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 fh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xx(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);zg=o,n.target.dispatchEvent(o),zg=null}else return t=yl(n),t!==null&&s_(t),e.blockedOn=n,!1;t.shift()}return!0}function v3(e,t,n){fh(e)&&n.delete(t)}function sD(){bx=!1,ur!==null&&fh(ur)&&(ur=null),dr!==null&&fh(dr)&&(dr=null),fr!==null&&fh(fr)&&(fr=null),Lu.forEach(v3),Su.forEach(v3)}function Kp(e,t){e.blockedOn===t&&(e.blockedOn=null,bx||(bx=!0,ut.unstable_scheduleCallback(ut.unstable_NormalPriority,sD)))}var $p=null;function L3(e){$p!==e&&($p=e,ut.unstable_scheduleCallback(ut.unstable_NormalPriority,function(){$p===e&&($p=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(h1(o||n)===null)continue;break}var r=yl(n);r!==null&&(e.splice(t,3),t-=3,Jg(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function hl(e){function t(l){return Kp(l,e)}ur!==null&&Kp(ur,e),dr!==null&&Kp(dr,e),fr!==null&&Kp(fr,e),Lu.forEach(t),Su.forEach(t);for(var n=0;n<Qa.length;n++){var o=Qa[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Qa.length&&(n=Qa[0],n.blockedOn===null);)l_(n),n.blockedOn===null&&Qa.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[Yt]||null;if(typeof r=="function")s||L3(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[Yt]||null)i=s.formAction;else if(h1(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),L3(n)}}}function c_(){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 m1(e){this._internalRoot=e}om.prototype.render=m1.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=hn();r_(n,o,e,t,null,null)};om.prototype.unmount=m1.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;r_(e.current,2,null,e,null,null),em(),t[ml]=null}};function om(e){this._internalRoot=e}om.prototype.unstable_scheduleHydration=function(e){if(e){var t=N3();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Qa.length&&t!==0&&t<Qa[n].priority;n++);Qa.splice(n,0,e),n===0&&l_(e)}};var S3=k3.version;if(S3!=="19.2.6")throw Error(O(527,S3,"19.2.6"));Le.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=NM(t),e=e!==null?T3(e):null,e=e===null?null:e.stateNode,e};var iD={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(jc=__REACT_DEVTOOLS_GLOBAL_HOOK__,!jc.isDisabled&&jc.supportsFiber))try{wu=jc.inject(iD),fn=jc}catch{}var jc;am.createRoot=function(e,t){if(!w3(e))throw Error(O(299));var n=!1,o="",a=ew,r=tw,s=nw;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=o_(e,1,!1,null,null,n,o,null,a,r,s,c_),e[ml]=t.current,c1(e),new m1(t)};am.hydrateRoot=function(e,t,n){if(!w3(e))throw Error(O(299));var o=!1,a="",r=ew,s=tw,i=nw,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=o_(e,1,!0,t,n??null,o,a,l,r,s,i,c_),t.context=a_(null),n=t.current,o=hn(),o=Sx(o),a=sr(o),a.callback=null,ir(n,a,o),n=o,t.current.lanes=n,Cu(t,n),Co(t),e[ml]=t.current,c1(e),new om(t)};am.version="19.2.6"});var p_=Dt((Vj,f_)=>{"use strict";function d_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(d_)}catch(e){console.error(e)}}d_(),f_.exports=u_()});var m_=Dt(rm=>{"use strict";var lD=Symbol.for("react.transitional.element"),cD=Symbol.for("react.fragment");function h_(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:lD,type:e,key:o,ref:t!==void 0?t:null,props:n}}rm.Fragment=cD;rm.jsx=h_;rm.jsxs=h_});var ye=Dt((Xj,y_)=>{"use strict";y_.exports=m_()});var cL=Dt(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.loop=Kr.conditional=Kr.parse=void 0;var OW=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};Kr.parse=OW;var RW=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Kr.conditional=RW;var DW=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}};Kr.loop=DW});var uL=Dt(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.readBits=lt.readArray=lt.readUnsigned=lt.readString=lt.peekBytes=lt.readBytes=lt.peekByte=lt.readByte=lt.buildStream=void 0;var PW=function(t){return{data:t,pos:0}};lt.buildStream=PW;var H6=function(){return function(t){return t.data[t.pos++]}};lt.readByte=H6;var BW=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};lt.peekByte=BW;var Ly=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};lt.readBytes=Ly;var zW=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};lt.peekBytes=zW;var NW=function(t){return function(n){return Array.from(Ly(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};lt.readString=NW;var FW=function(t){return function(n){var o=Ly(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};lt.readUnsigned=FW;var HW=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=Ly(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};lt.readArray=HW;var UW=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},GW=function(t){return function(n){for(var o=H6()(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]=UW(a,l.index,l.length):s[i]=a[l.index],s},{})}};lt.readBits=GW});var U6=Dt(ky=>{"use strict";Object.defineProperty(ky,"__esModule",{value:!0});ky.default=void 0;var $r=cL(),ce=uL(),Sy={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}},qW=(0,$r.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}),WW=(0,$r.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,$r.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)()},Sy]}]},function(e){return(0,ce.peekByte)()(e)===44}),jW=(0,$r.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),VW=(0,$r.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),ZW=(0,$r.conditional)({comment:[{codes:(0,ce.readBytes)(2)},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),XW=[{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,$r.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,$r.loop)([qW,VW,ZW,WW,jW],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],YW=XW;ky.default=YW});var G6=Dt(wy=>{"use strict";Object.defineProperty(wy,"__esModule",{value:!0});wy.deinterlace=void 0;var KW=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};wy.deinterlace=KW});var q6=Dt(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.lzw=void 0;var $W=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,_,h,m,C,b,I,k,P,T,y=new Array(o),g=new Array(a),x=new Array(a),A=new Array(a+1);for(b=t,l=1<<b,d=l+1,i=l+2,p=r,u=b+1,c=(1<<u)-1,h=0;h<l;h++)g[h]=0,x[h]=h;var C,_,v,I,k,T,P;for(C=_=v=I=k=T=P=0,m=0;m<s;){if(k===0){if(_<u){C+=n[P]<<_,_+=8,P++;continue}if(h=C&c,C>>=u,_-=u,h>i||h==d)break;if(h==l){u=b+1,c=(1<<u)-1,i=l+2,p=r;continue}if(p==r){A[k++]=x[h],p=h,I=h;continue}for(f=h,h==i&&(A[k++]=I,h=p);h>l;)A[k++]=x[h],h=g[h];I=x[h]&255,A[k++]=I,i<a&&(g[i]=p,x[i]=I,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}k--,y[T++]=A[k],m++}for(m=T;m<s;m++)y[m]=0;return y};_y.lzw=$W});var j6=Dt(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.decompressFrames=Qr.decompressFrame=Qr.parseGIF=void 0;var QW=oj(U6()),JW=cL(),ej=uL(),tj=G6(),nj=q6();function oj(e){return e&&e.__esModule?e:{default:e}}var aj=function(t){var n=new Uint8Array(t);return(0,JW.parse)((0,ej.buildStream)(n),QW.default)};Qr.parseGIF=aj;var rj=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},W6=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,nj.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,tj.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=rj(i)),i};Qr.decompressFrame=W6;var sj=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return W6(o,t.gct,n)})};Qr.decompressFrames=sj});var Q6=F(p_(),1);var R=F(ye(),1),xe=F(he(),1);var lm=F(he(),1);var sm=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var g_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var x_=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var y1=e=>{let t=x_(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Bu=F(he(),1);var im={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 b_=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Ll=F(he(),1);var uD=(0,Ll.createContext)({});var A_=()=>(0,Ll.useContext)(uD);var v_=(0,Bu.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=""}=A_()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,Bu.createElement)("svg",{ref:l,...im,width:t??c??im.width,height:t??c??im.height,stroke:e??f,strokeWidth:h,className:sm("lucide",p,a),...!r&&!b_(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,b])=>(0,Bu.createElement)(m,b)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,lm.forwardRef)(({className:o,...a},r)=>(0,lm.createElement)(v_,{ref:r,iconNode:t,className:sm(`lucide-${g_(y1(e))}`,`lucide-${e}`,o),...a}));return n.displayName=y1(e),n};var dD=[["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"}]],zu=E("align-center-horizontal",dD);var fD=[["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"}]],Sl=E("align-center-vertical",fD);var pD=[["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"}]],Nu=E("align-end-horizontal",pD);var hD=[["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"}]],Fu=E("align-end-vertical",hD);var mD=[["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"}]],Hu=E("align-horizontal-distribute-center",mD);var yD=[["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"}]],Uu=E("align-start-horizontal",yD);var gD=[["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"}]],Gu=E("align-start-vertical",gD);var xD=[["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"}]],qu=E("align-vertical-distribute-center",xD);var bD=[["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"}]],Wu=E("bold",bD);var AD=[["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"}]],ju=E("case-sensitive",AD);var vD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Vu=E("check",vD);var LD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Zu=E("chevron-down",LD);var SD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ks=E("chevron-right",SD);var kD=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Xu=E("chevrons-down",kD);var wD=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Yu=E("chevrons-up",wD);var _D=[["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"}]],gn=E("circle-question-mark",_D);var CD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ku=E("circle",CD);var TD=[["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"}]],$u=E("clipboard",TD);var ID=[["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"}]],ws=E("copy",ID);var ED=[["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"}]],Qu=E("delete",ED);var MD=[["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"}]],kl=E("download",MD);var OD=[["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"}]],br=E("ellipsis-vertical",OD);var RD=[["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"}]],Ar=E("ellipsis",RD);var DD=[["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"}]],Ju=E("external-link",DD);var PD=[["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"}]],ed=E("file-down",PD);var BD=[["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"}]],td=E("file-up",BD);var zD=[["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"}]],nd=E("flip-horizontal-2",zD);var ND=[["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"}]],od=E("flip-vertical-2",ND);var FD=[["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"}]],ad=E("frame",FD);var HD=[["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"}]],so=E("grid-3x3",HD);var UD=[["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"}]],rd=E("grip",UD);var GD=[["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"}]],sd=E("group",GD);var qD=[["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"}]],id=E("hand",qD);var WD=[["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",WD);var jD=[["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"}]],Cs=E("image",jD);var VD=[["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"}]],ld=E("italic",VD);var ZD=[["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"}]],cd=E("library",ZD);var XD=[["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"}]],ud=E("link",XD);var YD=[["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"}]],dd=E("locate-fixed",YD);var KD=[["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"}]],fd=E("lock",KD);var $D=[["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"}]],pd=E("magnet",$D);var QD=[["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"}]],wl=E("maximize",QD);var JD=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],hd=E("menu",JD);var e7=[["path",{d:"M5 12h14",key:"1ays0h"}]],ma=E("minus",e7);var t7=[["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"}]],md=E("monitor",t7);var n7=[["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"}]],yd=E("moon",n7);var o7=[["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"}]],gd=E("mouse-pointer-2",o7);var a7=[["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"}]],xd=E("mouse-pointer",a7);var r7=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],bd=E("move-down",r7);var s7=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Ad=E("move-right",s7);var i7=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],vd=E("move-up",i7);var l7=[["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"}]],vr=E("pen-line",l7);var c7=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ts=E("plus",c7);var u7=[["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"}]],Is=E("redo-2",u7);var d7=[["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"}]],Ld=E("rotate-ccw",d7);var f7=[["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"}]],Sd=E("scissors",f7);var p7=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],kd=E("search",p7);var h7=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],wd=E("slash",h7);var m7=[["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"}]],_d=E("spline",m7);var y7=[["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"}]],ya=E("square-dashed",y7);var g7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ga=E("square-dot",g7);var x7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],xa=E("square",x7);var b7=[["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"}]],Cd=E("strikethrough",b7);var A7=[["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"}]],Td=E("sun",A7);var v7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Lr=E("text-align-end",v7);var L7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Sr=E("text-align-center",L7);var S7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],io=E("text-align-start",S7);var k7=[["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"}]],_l=E("trash-2",k7);var w7=[["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"}]],Id=E("type",w7);var _7=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ed=E("underline",_7);var C7=[["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"}]],Es=E("undo-2",C7);var T7=[["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"}]],Md=E("ungroup",T7);var I7=[["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"}]],Od=E("upload",I7);var E7=[["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"}]],Rd=E("waypoints",E7);var M7=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ba=E("x",M7);var O7=[["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"}]],Dd=E("zoom-out",O7);var R7=[["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"}]],Pd=E("zoom-in",R7);var D7=F(ye(),1),lo=F(he(),1),L_=(0,lo.createContext)(null);var S_=L_;var g1=()=>(0,lo.useContext)(L_),Aa=(e,t,n)=>{let o=g1(),[a,r]=(0,lo.useState)(()=>o?e(o):t),s=(0,lo.useRef)(e);s.current=e;let i=(0,lo.useRef)(t);return i.current=t,(0,lo.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 w1=F(ye(),1);var Cl=F(ye(),1),Ye=F(he(),1),E_=F(Yo(),1);var k_=F(ye(),1),cm=F(he(),1),w_=(0,cm.createContext)(null),Bd=({container:e,children:t})=>(0,k_.jsx)(w_.Provider,{value:e,children:t}),Et=()=>(0,cm.useContext)(w_)??document.body;var x1=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],__=8,C_=256,b1=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}];var v1=new Set,zd=null,To=null,Io=null,S1=0,L1=!1,P7=()=>{for(let e of v1)e(zd)},um=e=>{zd=e,P7()},B7=e=>(v1.add(e),()=>{v1.delete(e)}),z7=e=>{if(L1)return;Io&&(clearTimeout(Io),Io=null),To&&clearTimeout(To);let t=Date.now()-S1;if(zd!==null||t<600){um(e);return}To=setTimeout(()=>{To=null,um(e)},600)},T_=e=>{To&&(clearTimeout(To),To=null),zd?.id===e&&(Io&&clearTimeout(Io),Io=setTimeout(()=>{Io=null,S1=Date.now(),um(null)},80))},I_=()=>{To&&(clearTimeout(To),To=null),Io&&(clearTimeout(Io),Io=null),zd&&(S1=Date.now(),um(null))},k1=({children:e})=>((0,Ye.useEffect)(()=>{let t=()=>{L1=!0,I_()},n=()=>{L1=!1},o=a=>{a.key==="Escape"&&I_()};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,Cl.jsxs)(M_.Provider,{value:!0,children:[e,(0,Cl.jsx)(F7,{})]})),M_=(0,Ye.createContext)(!1),N7=()=>(0,Ye.useContext)(M_),F7=()=>{let[e,t]=(0,Ye.useState)(null),n=Et();return(0,Ye.useEffect)(()=>B7(t),[]),!e||typeof document>"u"?null:(0,E_.createPortal)((0,Cl.jsx)(H7,{target:e}),n)},H7=({target:e})=>{let t=(0,Ye.useRef)(null),[n,o]=(0,Ye.useState)(null);(0,Ye.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,Cl.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},Ms=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,Ye.useId)();if(!N7()||n||e===void 0||e===null)return(0,Ye.isValidElement)(o)&&typeof e=="string"&&!n?(0,Ye.cloneElement)(o,{title:e}):o;if(!(0,Ye.isValidElement)(o))return o;let s=o,i=f=>{z7({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,Ye.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),T_(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),T_(a)},title:void 0})};var Bn=({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,w1.jsx)(Ms,{content:e,children:(0,w1.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var O_=F(ye(),1),Os=({children:e,className:t,ariaLabel:n})=>(0,O_.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var _1=F(ye(),1);var zn=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,_1.jsx)(Os,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,_1.jsx)(Bn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var Nd=F(ye(),1),Fd=({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,Nd.jsxs)("div",{className:"du-slider",children:[(0,Nd.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,Nd.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var R_=F(ye(),1),C1=({children:e,className:t,style:n})=>(0,R_.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var Nn=F(ye(),1),T1=({left:e,center:t,right:n})=>(0,Nn.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,Nn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Nn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Nn.jsx)("div",{}),(0,Nn.jsx)("div",{className:"du-bar-zone",children:n})]}),I1=({left:e,center:t,right:n})=>(0,Nn.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,Nn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Nn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Nn.jsx)("div",{}),(0,Nn.jsx)("div",{className:"du-bar-zone",children:n})]});var zr=F(ye(),1),F9=F(he(),1);var je=F(ye(),1),lc=F(he(),1);var D_="select";var va={};no(va,{EMPTY:()=>Ne,add:()=>xn,clear:()=>q7,equals:()=>Rs,has:()=>U7,remove:()=>P_,replace:()=>G7,single:()=>Mt,toggle:()=>O1});var Qe=e=>e,E1=e=>e,$t=e=>e,Hd=e=>e,Tl=e=>e,M1=e=>e;var L=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Ud=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var dm=(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 Ne=Object.freeze(new Set),Mt=e=>new Set([e]),U7=(e,t)=>e.has(t),xn=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},P_=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},O1=(e,t)=>e.has(t)?P_(e,t):xn(e,t),G7=e=>Mt(e),q7=()=>Ne,Rs=(e,t)=>dm(e,t);var Ae={};no(Ae,{ZERO:()=>B_,add:()=>j7,angle:()=>nP,cross:()=>$7,distance:()=>Q7,distanceSq:()=>F_,div:()=>X7,dot:()=>K7,equals:()=>sP,length:()=>N_,lengthSq:()=>z_,lerp:()=>eP,midpoint:()=>tP,mul:()=>Z7,negate:()=>Y7,normalize:()=>J7,of:()=>W7,perp:()=>rP,rotate:()=>oP,rotateAround:()=>aP,sub:()=>V7});var B_=Object.freeze({x:0,y:0}),W7=(e,t)=>({x:e,y:t}),j7=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V7=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Z7=(e,t)=>({x:e.x*t,y:e.y*t}),X7=(e,t)=>({x:e.x/t,y:e.y/t}),Y7=e=>({x:-e.x,y:-e.y}),K7=(e,t)=>e.x*t.x+e.y*t.y,$7=(e,t)=>e.x*t.y-e.y*t.x,z_=e=>e.x*e.x+e.y*e.y,N_=e=>Math.sqrt(z_(e)),F_=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},Q7=(e,t)=>Math.sqrt(F_(e,t)),J7=e=>{let t=N_(e);return t===0?B_:{x:e.x/t,y:e.y/t}},eP=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),tP=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),nP=e=>Math.atan2(e.y,e.x),oP=(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}},aP=(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)}},rP=e=>({x:-e.y,y:e.x}),sP=(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 Il={};no(Il,{clamp:()=>iP,clamp01:()=>lP});var iP=(e,t,n)=>Math.max(t,Math.min(n,e)),lP=e=>e<0?0:e>1?1:e;var B={};no(B,{IDENTITY:()=>cP,applyToBounds:()=>yP,applyToPoint:()=>Gd,decompose:()=>gP,equals:()=>xP,inverse:()=>mP,multiply:()=>hP,of:()=>uP,rotation:()=>pP,scaling:()=>fP,translation:()=>dP});var cP=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),uP=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),dP=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),fP=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),pP=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},hP=(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}),mP=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}},Gd=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),yP=(e,t)=>{let n=Gd(e,{x:t.x,y:t.y}),o=Gd(e,{x:t.x+t.width,y:t.y}),a=Gd(e,{x:t.x,y:t.y+t.height}),r=Gd(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}},gP=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}}},xP=(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 X={};no(X,{EMPTY:()=>H_,centerOf:()=>vP,contains:()=>D1,containsBounds:()=>kP,equals:()=>CP,expand:()=>wP,fromCenter:()=>AP,fromPoints:()=>fm,intersection:()=>U_,intersects:()=>SP,isEmpty:()=>R1,maxX:()=>kr,maxY:()=>wr,normalize:()=>_P,of:()=>bP,union:()=>LP});var H_=Object.freeze({x:0,y:0,width:0,height:0}),bP=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),fm=e=>{if(e.length===0)return H_;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}},AP=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),vP=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),kr=e=>e.x+e.width,wr=e=>e.y+e.height,R1=e=>e.width<=0||e.height<=0,LP=(e,t)=>{if(R1(e))return t;if(R1(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(kr(e),kr(t)),r=Math.max(wr(e),wr(t));return{x:n,y:o,width:a-n,height:r-o}},U_=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(kr(e),kr(t)),r=Math.min(wr(e),wr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},SP=(e,t)=>U_(e,t)!==null,D1=(e,t)=>t.x>=e.x&&t.x<=kr(e)&&t.y>=e.y&&t.y<=wr(e),kP=(e,t)=>t.x>=e.x&&t.y>=e.y&&kr(t)<=kr(e)&&wr(t)<=wr(e),wP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),_P=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)}),CP=(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 Ml={};no(Ml,{distanceToSegment:()=>EP,distanceToSegmentSq:()=>El,pointInPolygon:()=>IP,pointInRect:()=>TP,pointOnPolyline:()=>MP,pointOnSegment:()=>G_});var TP=(e,t)=>D1(t,e),IP=(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},El=(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},EP=(e,t,n)=>Math.sqrt(El(e,t,n)),G_=(e,t,n,o=1)=>El(e,t,n)<=o*o,MP=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&G_(e,a,r,n))return!0}return!1};var Fn={};no(Fn,{cubicAt:()=>Ps,cubicBounds:()=>RP,flattenCubic:()=>zP,flattenQuadratic:()=>BP,pointOnCubic:()=>PP,pointOnQuadratic:()=>DP,quadraticAt:()=>Ds,quadraticBounds:()=>OP});var Ds=(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}},Ps=(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}},OP=(e,t,n)=>{let o=[e,n];for(let a of q_(e.x,t.x,n.x))o.push(Ds(e,t,n,a));for(let a of q_(e.y,t.y,n.y))o.push(Ds(e,t,n,a));return fm(o)},RP=(e,t,n,o)=>{let a=[e,o];for(let r of W_(e.x,t.x,n.x,o.x))a.push(Ps(e,t,n,o,r));for(let r of W_(e.y,t.y,n.y,o.y))a.push(Ps(e,t,n,o,r));return fm(a)},DP=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=Ds(t,n,o,l/r);if(El(e,i,c)<=s)return!0;i=c}return!1},PP=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=Ps(t,n,o,a,c/s);if(El(e,l,u)<=i)return!0;l=u}return!1},BP=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=Ds(e,t,n,r/o);return a},zP=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=Ps(e,t,n,o,s/a);return r},q_=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},W_=(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 hm={};no(hm,{lineLine:()=>NP,segmentCubic:()=>HP,segmentQuadratic:()=>FP,segmentSegment:()=>j_});var pm=1e-12,NP=(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)<pm)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}},j_=(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)<pm)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}},FP=(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)<pm){if(Math.abs(f)>pm){let x=-p/f;x>=0&&x<=1&&h.push(x)}}else{let x=f*f-4*d*p;if(x>=0){let A=Math.sqrt(x),C=(-f+A)/(2*d),_=(-f-A)/(2*d);C>=0&&C<=1&&h.push(C),_>=0&&_<=1&&h.push(_)}}let m=[],b=t.x-e.x,y=t.y-e.y,g=b*b+y*y;for(let x of h){let A=Ds(n,o,a,x);if(g===0){m.push(A);continue}let C=((A.x-e.x)*b+(A.y-e.y)*y)/g;C>=0&&C<=1&&m.push(A)}return m},HP=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=Ps(n,o,a,r,c/s),d=j_(e,t,l,u);d!==null&&i.push(d),l=u}return i};var mm={};no(mm,{contrastRatio:()=>N1,format:()=>qP,luminance:()=>z1,meetsContrastAA:()=>VP,meetsContrastAAA:()=>ZP,mix:()=>WP,parse:()=>GP,withAlpha:()=>jP});var UP=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}}),GP=e=>{let t=e.trim().toLowerCase(),n=UP[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=_r(a.charAt(0)+a.charAt(0)),s=_r(a.charAt(1)+a.charAt(1)),i=_r(a.charAt(2)+a.charAt(2)),l=a.length===4?_r(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=_r(a.slice(0,2)),s=_r(a.slice(2,4)),i=_r(a.slice(4,6)),l=a.length===8?_r(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}`)},qP=e=>{let t=P1(e.r),n=P1(e.g),o=P1(e.b),a=XP(e.a);return a===1?`#${B1(t)}${B1(n)}${B1(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},WP=(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}),jP=(e,t)=>({...e,a:t}),z1=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)},N1=(e,t)=>{let n=z1(e),o=z1(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},VP=(e,t,n=!1)=>N1(e,t)>=(n?3:4.5),ZP=(e,t,n=!1)=>N1(e,t)>=(n?4.5:7),_r=e=>parseInt(e,16),P1=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},XP=e=>e<0?0:e>1?1:e,B1=e=>e.toString(16).padStart(2,"0");var qd={};no(qd,{offsetClosedPath:()=>YP,signedArea:()=>KP});var YP=(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=L(e[l]),u=L(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=L(r[c]),d=L(s[c]),f=L(r[l]),p=L(s[l]),h=u+f,m=d+p,b=Math.hypot(h,m);b<1e-6?(h=u,m=d):(h/=b,m/=b);let y=L(e[l]),g=n-y.x,x=o-y.y,C=h*g+m*x>=0?1:-1,_=h*u+m*d,v=_>1e-6?t/_:t;i.push({x:y.x+C*h*v,y:y.y+C*m*v})}return i},KP=e=>{let t=0;for(let n=0;n<e.length;n++){let o=L(e[n]),a=L(e[(n+1)%e.length]);t+=o.x*a.y-a.x*o.y}return t/2};var F1=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}},Wd=(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 V_=null,H1=e=>{V_=e},U1=()=>V_;var jd=e=>e.type==="rectangle",G1=e=>e.type==="ellipse",Bs=e=>e.type==="polygon",q1=e=>e.type==="path",Fe=e=>e.type==="text",Ut=e=>e.type==="image";var Oe=e=>e.type==="group",He=e=>e.type==="frame";var Z_=new Map,Hn=(e,t)=>{Z_.set(e,t)};var dt=e=>{let t=Z_.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},z=e=>{let t=dt(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 X.fromPoints(r)};Hn("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("polygon",e=>X.fromPoints(e.points));Hn("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 X.fromPoints(t)});Hn("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
10
+ `),o=U1(),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}});Hn("image",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("template",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("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}});Hn("group",()=>({x:0,y:0,width:0,height:0}));Hn("frame",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var ym=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 vt=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Vd=(e,t)=>vt(t,e);var zs=(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)}};var gm=(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 M=(e,t)=>e.elements.get(t),be=(e,t)=>e.links.get(t);var co=e=>[...e.layers.values()].sort(vt),La=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(vt),j1=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(vt),X_=48,xm=10,W1=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}],Y_=6,JP=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=Y_;p++){let h=u+(d-u)*(p/Y_);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)]},eB=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<=xm;a++){let r=a/xm,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<=xm;a++){let r=a/xm,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},tB=new Map;var nB=e=>{if(Bs(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(G1(e)){let t=dt(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<X_;i++)s.push(gm(n,o,a,r,i/X_));return[s]}if(jd(e)){let t=dt(e),n=Wd(e.style.roundness,t.width,t.height);return[n>0?JP(t,n):W1(t)]}return Ut(e)||Fe(e)?[W1(dt(e))]:q1(e)?[eB(e.commands)]:null},Zd=(e,t)=>{if(Oe(t)){let r=[];for(let s of V1(e,t.id))r.push(...Zd(e,s));return r}let n=nB(t);if(n)return n.map(r=>r.map(s=>zs(t,s)));let o=tB.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=>zs(t,i)))}let a=z(t);return[W1(a)]},V1=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(vt),n},Z1=(e,t)=>{let n=t;for(let o=0;n&&o<K_;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},Ol=(e,t)=>{let n=t;for(let o=0;n&&o<K_;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var X1=(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 V1(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},K_=64;var bm=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=z(a);if(!X.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},Xd=(e,t)=>{let n=co(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=La(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&X.contains(z(i),t))return i}}},Y1=(e,t)=>{let n=new ym(t);for(let o of e.elements.values())n.insert(o.id,z(o));return n};var K1=(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||!X.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 oB=[];var Yd=e=>Ns(e)!==null,Ns=e=>{for(let s of oB){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??aB,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},aB=0,Un=e=>{let t=Ns(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},rB=[];var $1=e=>{for(let n of rB){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=Un(e);return t?[t]:[]},Kd=(e,t,n=new Set)=>{let o=co(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=La(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=Un(l);if(c&&X.contains(c,t))return l}}return null},Q1=(e,t)=>{let n=Ns(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,b=l>f?l+o:f,y=c>p?c+o:p;return h===u&&m===d&&b===f&&y===p?null:{x:h,y:m,width:b-h,height:y-m}},J1=(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 $_=new Set,eb={"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}},Q_=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var J_=(e,t)=>tb(e,t),Gt=(e,t)=>{let n=J_(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)}},Eo=(e,t)=>{let n=Gt(e,t),o=Gt(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}},Sa=(e,t,n=$_)=>{let o=null;for(let[a,r]of Am(e)){if(n.has(a))continue;let s=sB(a),i=Gt(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:Gt(e,{kind:"named",name:"center"}),distance:1/0}},sB=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},uo=e=>Yd(e)?iB:$_,iB=new Set(["center"]);var Am=e=>{let t=new Map;if(Bs(e))lB(e,t);else{let n=dt(e);for(let o of eC){let a=eb[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,tb(e,o));return t},eC=["top","right","bottom","left"],lB=(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}`,Ae.midpoint(a,r))}},tb=(e,t)=>{switch(t.kind){case"named":{let n=nC(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${Q_.join(", ")}; custom anchors live on shape.anchors.`);return n}case"ratio":{let n=dt(e);return{x:n.x+n.width*t.position.x,y:n.y+n.height*t.position.y}}case"absolute":{let n=dt(e);return{x:n.x+t.offset.x,y:n.y+t.offset.y}}case"edge":return tC(e,t.index,t.t)}},tC=(e,t,n)=>{if(Bs(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=dt(e);return{x:o.x+o.width/2,y:o.y+o.height/2}},nC=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?nC(e,n.name):tb(e,n);if(Bs(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return tC(e,r,.5)}let o=eb[t];if(!o)return;let a=dt(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var nb=(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}},ob=e=>{let t=[],n=6;for(let o=0;o<e.length-1;o++){let a=L(e[o]),r=L(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},$d=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(Fn.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var Rl={x:1,y:0},Qd={x:0,y:1},Jd={x:-1,y:0},ef={x:0,y:-1},oC=e=>e.y===0;var cB=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?Rl:e.x<=-n?Jd:e.y>t?Qd:ef},tf=(e,t)=>cB({x:e.x-t.x,y:e.y-t.y}),vm=(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?Jd:i===a?Rl:i===r?ef:Qd},aC=(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 Rl;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?Rl:Jd:u>=0?Qd:ef};var Lm=new Map,ab=(e,t)=>{Lm.set(e,t)},rC=e=>Lm.get(e),Sm=(e,t)=>{let n=Lm.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,Il.clamp01(t));return zs(e,o)},sC=(e,t,n=64)=>{let o=Lm.get(e.type);if(!o)return null;let a=0,r=zs(e,o(e,0)),s=Ae.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=zs(e,o(e,l)),u=Ae.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},iC=(e,t)=>{if(e.length===0)return{x:0,y:0};if(e.length===1)return L(e[0]);let n=0,o=[];for(let r=0;r<e.length;r++){let s=L(e[r]),i=L(e[(r+1)%e.length]),l=Ae.distance(s,i);o.push(l),n+=l}if(n===0)return L(e[0]);let a=n*t;for(let r=0;r<e.length;r++){let s=L(o[r]);if(a<=s){let i=L(e[r]),l=L(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 L(e[0])};ab("rectangle",(e,t)=>{let n=dt(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 iC(o,t)});ab("ellipse",(e,t)=>{let n=dt(e),o=n.x+n.width/2,a=n.y+n.height/2,r=n.width/2,s=n.height/2;return gm(o,a,r,s,t)});ab("polygon",(e,t)=>iC(e.points,t));var lC=e=>e.kind==="point"?null:e.elementId,cC=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},uC=(e,t,n)=>{if(t.kind==="anchor"){let a=cC(Eo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=cC(vm(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},fB=(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}},sb=(e,t)=>{let n=lC(t.from);if(!n||n!==lC(t.to))return null;let o=M(e,n);if(!o)return null;let a=z(o),r=Gn(e,t.from),s=Gn(e,t.to);if(!r||!s)return null;let i=r,l=s,c=uC(o,t.from,i),u=uC(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=fB(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}},pB=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]},hB=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}]}},fC=e=>{let t=z(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},mB=(e,t)=>{let n=fC(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!rC(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=Sm(e,0);for(let d=1;d<=96;d++){let f=Sm(e,d/96),p=hm.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},Gn=(e,t,n)=>{if(t.kind==="point")return t.position;let o=M(e,t.elementId);return o?t.kind==="anchor"?Gt(o,t.anchor):t.kind==="floating"?mB(o,n??fC(o)):Sm(o,t.ratio):null},rt=(e,t)=>{let n=sb(e,t);if(n)return pB(n);let o=Gn(e,t.from);if(!o)return null;let a=Gn(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?Gn(e,t.from,a)??o:o,s=t.to.kind==="floating"?Gn(e,t.to,o)??a:a;if((t.routing??"straight")!=="orthogonal")return[r,...t.waypoints??[],s];if(t.routedPoints!==void 0)return[r,...t.routedPoints,s];let l=rb(t.from),c=rb(t.to),u=Math.min(40,Math.max(8,Math.abs(s.x-r.x)/4,Math.abs(s.y-r.y)/4));if(l||c){let m=[r],b=r,y=s;l&&(b={x:r.x+l.x*u,y:r.y+l.y*u},m.push(b));let g=null;c&&(g={x:s.x+c.x*u,y:s.y+c.y*u});let x=g??y,A=x.x-b.x,C=x.y-b.y,_=l?Math.abs(l.x)>Math.abs(l.y):Math.abs(A)>=Math.abs(C);if(Math.abs(A)>.5&&Math.abs(C)>.5){let v=_?{x:x.x,y:b.y}:{x:b.x,y:x.y};m.push(v)}return g&&m.push(g),m.push(s),m}let d=s.x-r.x,f=s.y-r.y,h=Math.abs(d)>=Math.abs(f)?{x:s.x,y:r.y}:{x:r.x,y:s.y};return[r,h,s]},rb=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}},dC=(e,t,n)=>{let o=rb(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}},nf=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=sb(e,t);if(n)return hB(n);let o=rt(e,t);if(!o||o.length<2)return null;let a=L(o[0]),r=L(o[o.length-1]);if(o.length===2){let s=dC(t.from,a,r),i=dC(t.to,r,a);return{start:a,segments:[nb(a,r,s,i)]}}return{start:a,segments:ob(o)}},Dl=(e,t)=>{if((t.routing??"straight")!=="bezier")return rt(e,t);let n=nf(e,t);return n?$d(n.start,n.segments):null},of=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;if(n==="bezier"){let r=nf(e,t);if(!r)return null;let s=[],i=r.start;for(let l of r.segments)s.push(Fn.cubicAt(i,l.c1,l.c2,l.to,.5)),i=l.to;return s}let o=rt(e,t);if(!o||o.length<2)return null;let a=[];for(let r=0;r<o.length-1;r++){let s=L(o[r]),i=L(o[r+1]);a.push(Ae.midpoint(s,i))}return a},ib=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=Dl(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=Ml.distanceToSegment(t,L(r[i-1]),L(r[i]));l<s&&(s=l)}s>n||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null};var pC=new Map,lb=(e,t)=>{pC.set(e,t)},af=e=>{let t=z(e),n=pC.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 rf=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}}},ub={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"}]}},db={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)||!hC(n,e.probe,e.threshold))continue;let o=Sa(n,e.probe,uo(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}},fb={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)||!hC(n,e.probe,e.threshold))continue;let o=sC(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}},hC=(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 pb=()=>20,km=e=>e.snapToGrid??!0,hb=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),qn=e=>{let t=B.translation(-e.pan.x,-e.pan.y),n=B.rotation(e.rotation),o=B.scaling(e.zoom);return B.multiply(o,B.multiply(n,t))},ka=e=>B.inverse(qn(e)),mb=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),wm=(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}}},yb=(e,t,n)=>({...e,size:{width:t,height:n}});var Lt=class extends Error{name="FractionalIndexError"};var _m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function mC(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 Lt("invalid order key head: "+e)}function yC(e){let t=e.charAt(0);if(e.length!==mC(t))throw new Lt("invalid integer part of order key: "+e)}function Pl(e){let t=mC(e.charAt(0));if(t>e.length)throw new Lt("invalid order key: "+e);return e.slice(0,t)}function gb(e,t){yC(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Lt("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 gC(e,t){yC(e);let[n,...o]=e.split("");if(n===void 0)throw new Lt("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 Fs(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Lt(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Lt("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)+Fs(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)+Fs(e.slice(1),null,n)}function xC(e){return"A"+e.charAt(0).repeat(26)}function gB(e){return"a"+e.charAt(0)}function xb(e,t=_m){if(e===xC(t))throw new Lt("invalid order key: "+e);let n=Pl(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Lt("invalid order key: "+e)}function Wn(e,t,n=_m){let o=e??null,a=t??null;if(o!==null&&xb(o,n),a!==null&&xb(a,n),o!==null&&a!==null&&o>=a)throw new Lt(o+" >= "+a);if(o===null&&a===null)return gB(n);if(o===null){let u=Pl(a),d=a.slice(u.length);if(u===xC(n))return u+Fs("",d,n);if(u<a)return u;let f=gC(u,n);if(f===null)throw new Lt("cannot decrement any more");return f}if(a===null){let u=Pl(o),d=o.slice(u.length),f=gb(u,n);return f===null?u+Fs(d,null,n):f}let r=Pl(o),s=o.slice(r.length),i=Pl(a),l=a.slice(i.length);if(r===i)return r+Fs(s,l,n);let c=gb(r,n);if(c===null)throw new Lt("cannot increment any more");return c<a?c:r+Fs(s,null,n)}function sf(e,t,n,o=_m){if(!Number.isInteger(n)||n<0)throw new Lt(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[Wn(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=Wn(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=Wn(l,r,o),c.push(l);return c}if(a===null){let l=Wn(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=Wn(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=Wn(a,r,o);return[...sf(a,i,s,o),i,...sf(i,r,n-s-1,o)]}var bn=$t("default"),xB=()=>({id:bn,name:"Default",visible:!0,locked:!1,order:Wn(null,null)}),Qt=Object.freeze({elements:new Map,links:new Map,layers:new Map([[bn,xB()]]),annotations:new Map,files:new Map,viewport:hb}),bb=()=>({elements:new Map(Qt.elements),links:new Map(Qt.links),layers:new Map(Qt.layers),annotations:new Map(Qt.annotations),files:new Map(Qt.files),viewport:Qt.viewport});var Ab=(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)}},we=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return Wn(t,null)},Bl=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return Wn(null,t)},Cm=(e,t)=>Wn(e,t),vb=(e,t,n)=>sf(e,t,n);var Lb={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},bC=Object.keys(Lb),RQ=bC.filter(e=>Lb[e]==="ephemeral"),bB=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of bC)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},Sb=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??Qt.elements),links:new Map(t?.links??Qt.links),layers:new Map(t?.layers??Qt.layers),annotations:new Map(t?.annotations??Qt.annotations),files:new Map(t?.files??Qt.files),viewport:bB(Qt.viewport,n?.viewport,t?.viewport)}};var kb=(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 zl=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(zl).reverse()}}},Mo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Cr=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(Cr)}};var Je=(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}},jn=(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}},le=(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 wb=(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}},lf=(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}},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:J(e,r),patch:r}},_b=(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}},Cb=(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}},cf=(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}},Tb=(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}},Ib=(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}},wa=(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 Tr=(e,t)=>{if(t.elementId===null)return t.position;let n=M(e,t.elementId);return n?{x:n.position.x+t.position.x,y:n.position.y+t.position.y}:t.position};var AC=new Map,Eb=(e,t)=>{AC.set(e,t)},Mb=e=>{let t=AC.get(e.type);if(t){let n=t(e).trim();if(n)return n}return vC(e.type)},vC=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");Eb("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});Eb("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():vC(e.templateId)});var LC=new Map,Ob=e=>{LC.set(e.kind,e)};var Tm=e=>LC.get(e);var uf=e=>{try{let t=dt(e);return{width:t.width*Math.abs(e.scale.x),height:t.height*Math.abs(e.scale.y)}}catch{return{width:0,height:0}}},Im=(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=M(e,d);f&&a.push(f)}a.sort(vt);let r=a.map(uf),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 b=le(u,d.id,y=>({...y,position:m}));u=b.scene,c.push(b.patch)}),c.length===0?null:Mo(c)},Em=(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=M(e,l);c&&a.push(c)}a.sort(vt);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=uf(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=le(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:Mo(r)},SC=(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}},kC=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(a)}return n.sort(vt),n.map(o=>{let a=uf(o);return{id:o.id,w:a.width,h:a.height}})},wC=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=kC(e,t.shapeIds),{placements:r}=SC(a,n,t.innerWidth,o),s=[],i=e;for(let l of r){let c=M(i,l.id);if(!c||c.position.x===l.x&&c.position.y===l.y)continue;let u=le(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Mo(s)},Mm=(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=kC(e,o),r=M(e,t),s=(r?An(r):null)?.gap??16,i=SC(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},An=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=Tm(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},df=(e,t)=>{let n=M(e,t);if(!n)return null;let o=An(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=Un(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return Im(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return Em(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 wC(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return _C(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=Tm(i.kind);return l?l.run(e,t,a,s,i):null},_C=(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 b=[];for(let y of e.elements.values())y.parentId===m&&b.push(y);return b.sort(vt),b},s=new Map,i=new Map,l=m=>uf(m).width,c=m=>uf(m).height,u=m=>{let b=s.get(m),y=i.get(m);if(b!==void 0&&y!==void 0)return{w:b,h:y};let g=M(e,m);if(!g)return s.set(m,0),i.set(m,0),{w:0,h:0};let x=l(g),A=c(g),C=r(m);if(C.length===0)return s.set(m,x),i.set(m,A),{w:x,h:A};let _=0,v=0;for(let T=0;T<C.length;T++){let P=u(L(C[T]).id);_+=P.w,T>0&&(_+=o),P.h>v&&(v=P.h)}let I=Math.max(x,_),k=A+n+v;return s.set(m,I),i.set(m,k),{w:I,h:k}};for(let m of t.shapeIds)u(m);let d=[],f=e,p=(m,b,y)=>{let g=M(f,m);if(!g)return;let x=u(m),A=l(g),C=c(g),_={x:b+(x.w-A)/2,y};if(g.position.x!==_.x||g.position.y!==_.y){let T=le(f,m,P=>({...P,position:_}));f=T.scene,d.push(T.patch)}let v=r(m);if(v.length===0)return;let I=b,k=y+C+n;for(let T of v)p(T.id,I,k),I+=u(T.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:Mo(d)};var vB=20,Om=.5,LB=1e5,Db=(e,t,n,o={})=>{if(SB(e,t))return[e];let a=o.margin??vB,r=n.map(I=>kB(I,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let I of r)l.add(I.x),l.add(I.x+I.width),c.add(I.y),c.add(I.y+I.height);let u=[...l].sort((I,k)=>I-k),d=[...c].sort((I,k)=>I-k),f=(I,k)=>`${I},${k}`,p=I=>L(u[I]),h=I=>L(d[I]),m=u.indexOf(e.x),b=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),x=(I,k)=>Math.abs(p(I)-p(y))+Math.abs(h(k)-h(g)),A=f(m,b),C=[{key:A,skey:`${A},0`,xi:m,yi:b,axis:0,g:0,f:x(m,b)}],_=new Map,v=new Map([[`${A},0`,0]]);for(;C.length>0;){C.sort((k,T)=>k.f-T.f||k.g-T.g||(k.skey<T.skey?-1:1));let I=L(C.shift());if(I.xi===y&&I.yi===g)return CB(_,I.skey,p,h);for(let k of wB(I.xi,I.yi,u.length,d.length)){let T={x:p(I.xi),y:h(I.yi)},P={x:p(k.xi),y:h(k.yi)};if(_B(T,P,r))continue;let N=Math.sign(P.x-T.x),U=Math.sign(P.y-T.y);if(I.axis===0&&s&&N===-Math.sign(s.x)&&U===-Math.sign(s.y)||k.xi===y&&k.yi===g&&i&&N===Math.sign(i.x)&&U===Math.sign(i.y))continue;let q=k.xi!==I.xi?1:2,te=Math.abs(T.x-P.x)+Math.abs(T.y-P.y),Z=I.axis!==0&&I.axis!==q?LB:0,ue=I.g+te+Z,$=f(k.xi,k.yi),re=`${$},${q}`,We=v.get(re);We!==void 0&&ue>=We||(v.set(re,ue),_.set(re,I.skey),C.push({key:$,skey:re,xi:k.xi,yi:k.yi,axis:q,g:ue,f:ue+x(k.xi,k.yi)}))}}return null},SB=(e,t)=>e.x===t.x&&e.y===t.y,kB=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),wB=(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},_B=(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<=Om||l-o<=Om||s-i.y<=Om||c-r<=Om))return!0}return!1},CB=(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(L(i[0])),y:o(L(i[1]))}),s=e.get(s)}return TB(a)},TB=e=>{if(e.length<=2)return e;let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(e[n-1]),a=L(e[n]),r=L(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(L(e[e.length-1])),t};var pf=(e,t)=>{let n=Gn(e,t.from),o=Gn(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?Gn(e,t.from,o)??n:n,r=t.to.kind==="floating"?Gn(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=MC(e,t.from,a,r),i=MC(e,t.to,r,a),l=t.avoidObstacles===!0?IB(e,t):void 0,c=l&&l.length<=150?l:void 0,u=RC(a,r,s,i,t.routedPoints,c);return u=OB(u,t.fixedSegments),u},IB=(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},Pb=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=EC(e,t,n,a),s=EC(e,o,a,n);return[n,...RC(n,a,r,s),a]},RC=(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=Db(i,l,h,{startHeading:n.heading,endHeading:o.heading}),b=m&&m.length>=2?m:[i,OC(i,l,n.heading),l];return ff(b)}let u=EB(e,t,n,o,i,l);if(u&&!IC(u,c))return ff(u);let d=MB(e,t,n,o,i,l,c,a);if(d&&!IC(d,c))return ff(d);let f=Db(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,OC(i,l,n.heading),l];return ff(p)},EB=(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},CC=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},MB=(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=CC(p,(c+d)/2,c,d,TC(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=CC(p,(l+u)/2,l,u,TC(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},TC=(e,t)=>{if(!e||e.length<3)return null;let n=d=>t==="y"?d.y:d.x,o=n(L(e[0])),a=n(L(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},IC=(e,t)=>{let n=1;for(let o=1;o<e.length;o++){let a=L(e[o-1]),r=L(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},EC=(e,t,n,o)=>{if(!t)return{heading:tf(o,n),obstacle:null};let a=M(e,t);return a?{heading:aC(a,n),obstacle:z(a)}:{heading:tf(o,n),obstacle:null}},OB=(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=L(n[c]),d=L(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=L(n[r]),u=L(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=L(n[0]),l=L(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 ff(n)},RB=e=>{switch(e){case"top":return ef;case"bottom":return Qd;case"left":return Jd;case"right":return Rl;default:return null}},MC=(e,t,n,o)=>{if(t.kind==="point")return{heading:tf(o,n),obstacle:null};let a=M(e,t.elementId);if(!a)return{heading:tf(o,n),obstacle:null};let r=z(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=RB(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:vm(a,n),obstacle:r}},OC=(e,t,n)=>oC(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},ff=e=>{if(e.length<=2)return[...e];let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(t[t.length-1]),a=L(e[n]),r=L(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(L(e[e.length-1])),t};var Rm="orthogonal",DC="triangle";var Bb=Math.PI/12,Oo=11,PC=6,BC=4,zC=12,Dm=9,zb=4,NC="#1a73e8",FC="#fff",hf=3.5,Ro=5,HC=8,UC=1.5,GC=NC,Nb=FC,qC=FC,Fb=NC,fo=20,WC=0,jC="#ffffff",Pm=6,Bm=7,VC=18,Hb=40,Nl=.16,mf=.7,Ub="#e8118c",ZC="#f59e0b",yf="#2563eb",Gb="#16a34a",XC="#06b6d4",YC="#a855f7",KC="#eab308",$C="#dc2626",QC="#14b8a6",JC="#f43f5e",eT=16,qb=14,Wb=6,jb=3,Vb=11,tT=1.5,nT=[4,3],oT=3;var Zb=1,Xb=1.6,Yb=10,aT=1,rT=.05,sT=32,iT=.5,lT=500,Fl=8,Kb=300,$b=8,cT=.6,uT=.85,zm=.4,dT=22,fT=22,pT=18,hT=16,mT=16,yT=9,Nm=12,gT="#f9a825",xT="#fff",bT="#888",AT=10,Fm=2e3,Qb=.5,vT=.5,Jb=12,LT=6,ST=2,e2=480,kT=1e3/60,wT=1e3/12,_T=2,CT=2*1024*1024,TT=3e4,IT=24,ET="system-ui, sans-serif",MT="#1a1a1a",OT=1e3,RT=1,DT=10,PT=530,BT="#1a73e8",zT=.25,NT=1.5,Hm=4,t2=1.1,FT=256,HT=30,UT=16,n2=4,GT=4,qT="rgba(0,0,0,0.65)",WT=16,jT="#1a73e8",VT="#fff";var Hs=["nw","n","ne","e","se","s","sw","w"],Us=["nw","ne","se","sw"],ZT=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 Gs=(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}}},o2=(e,t,n,o=11,a=Hs)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=Gs(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},Hl=(e,t)=>e.rotation===0?t:Ae.rotateAround(t,e.pivot,e.rotation),PB=(e,t)=>e.rotation===0?t:Ae.rotateAround(t,e.pivot,-e.rotation),qs=e=>{let t=dt(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}};var xf=e=>{let t=e.bounds;return[Hl(e,{x:t.x,y:t.y}),Hl(e,{x:t.x+t.width,y:t.y}),Hl(e,{x:t.x+t.width,y:t.y+t.height}),Hl(e,{x:t.x,y:t.y+t.height})]},XT=e=>Hl(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),YT=(e,t,n=1)=>Hl(t,Gs(e,t.bounds,n)),KT=(e,t,n,o=11,a=Hs)=>o2(PB(t,e),t.bounds,n,o,a),BB={kind:"ratio",position:{x:0,y:1}},zB=new Map;var NB=e=>zB.get(e)??BB,Um=(e,t=1)=>{let n=NB(e.type),o=Gt(e,n),a=Eo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},Gm=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},a2=(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 FB(){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 HB(){let e=FB();if(e.__xstate__)return e.__xstate__}var $T=e=>{if(typeof window>"u")return;let t=HB();t&&t.register(e)};var qm=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}},f2=".",UB="",p2="",GB="#",qB="*",oI="xstate.init",aI="xstate.error",i2="xstate.stop";function WB(e,t){return{type:`xstate.after.${e}.${t}`}}function l2(e,t){return{type:`xstate.done.state.${e}`,output:t}}function jB(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function h2(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function jm(e){return{type:oI,input:e}}function Do(e){setTimeout(()=>{throw e})}var VB=typeof Symbol=="function"&&Symbol.observable||"@@observable";function m2(e,t){let n=QT(e),o=QT(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?m2(n[a],o[a]):!1)}function Vm(e){if(iI(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 QT(e){if(CI(e))return e.value;if(typeof e!="string")return e;let t=Vm(e);return rI(t)}function rI(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 y2(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 sI(e){return iI(e)?e:[e]}function Po(e){return e===void 0?[]:sI(e)}function c2(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function iI(e){return Array.isArray(e)}function ZB(e){return e.type.startsWith("xstate.error.actor")}function Ws(e){return sI(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function lI(e){if(!(e===void 0||e===UB))return Po(e)}function bf(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 g2(e,t){return`${t}.${e}`}function vf(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 cI(e,t){if(t===e||t===qB)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 JT(e,t){return`${e.sessionId}.${t}`}var XB=0;function YB(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,b=Math.random().toString(36).slice(2))=>{let y={source:f,target:p,event:h,delay:m,id:b,startedAt:Date.now()},g=JT(f,b);d._snapshot._scheduledEvents[g]=y;let x=i.setTimeout(()=>{delete s[g],delete d._snapshot._scheduledEvents[g],d._relay(f,p,h)},m);s[g]=x},cancel:(f,p)=>{let h=JT(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:${XB++}`,_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=bf(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:b,delay:y,id:g}=f[p];c.schedule(h,m,b,y,g)}},_clock:i,_logger:l};return d}var r2=!1,Zm=1,qt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),KB={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Wm=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 qm(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=qt.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={...KB,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:YB(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(bf(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(b){Do(b)}},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=r2;try{r2=!0,d.exec(d.info,d.params)}finally{r2=p}};this._processingStatus===qt.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){Do(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Do(r)}this._stopProcedure(),this._complete(),this._doneEvent=jB(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=bf(t,n,o);if(this._processingStatus!==qt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Do(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Do(r);else try{a.error(r)}catch(s){Do(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=bf(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===qt.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=qt.Running;let t=jm(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===qt.Stopped?this:(this.mailbox.clear(),this._processingStatus===qt.NotStarted?(this._processingStatus=qt.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){Do(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Do(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){Do(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Do(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,h2(this.id,t))}_stopProcedure(){return this._processingStatus!==qt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new qm(this._process.bind(this)),this._processingStatus=qt.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==qt.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:$T)(this)}toJSON(){return{xstate$$type:Zm,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[VB](){return this}getSnapshot(){return this._snapshot}};function Bo(e,...[t]){return new Wm(e,t)}function $B(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function QB(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Wl(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=$B,t.execute=QB,t}function JB(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?vf(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=Bo(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Er(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function ez(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==qt.Stopped&&t.start()})}function jl(...[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=JB,r.execute=ez,r}function tz(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]),[Er(t,{children:i}),s,void 0]}function uI(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))uI(e,o);e.system._unregister(t)}function nz(e,t){if(t){if(uI(e,t),t._processingStatus!==qt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Zs(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=tz,t.execute=nz,t}function oz(e,{context:t,event:n},{guards:o}){return o.every(a=>Xs(a,t,n,e))}function dI(e){function t(n,o){return!1}return t.check=oz,t.guards=e,t}function Xs(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 Xs(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 Xm(e){return e.type==="atomic"||e.type==="final"}function Gl(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Vl(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 Lf(e){let t=new Set(e),n=pI(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))eI(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of Gl(o))if(a.type!=="history"&&!t.has(a)){let r=eI(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 fI(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(Xm(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=fI(a,t);return o}function pI(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 hI(e,t){let n=Lf(t);return fI(e,pI(n))}function Ym(e,t){return t.type==="compound"?Gl(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?Gl(t).every(n=>Ym(e,n)):t.type==="final"}var Sf=e=>e[0]===GB;function mI(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>cI(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function yI(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=WB(a,e.id),s=r.type;return e.entry.push(Xl(r,{id:s,delay:a})),e.exit.push(Wl(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 Po(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{..._a(e,a.event,a),delay:r}})}function _a(e,t,n){let o=lI(n.target),a=n.reenter??!1,r=az(e,o),s={...n,actions:Po(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 gI(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===p2)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,Ws(o).map(a=>_a(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,Ws(e.config.onDone).map(o=>_a(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,Ws(n.onDone).map(a=>_a(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,Ws(n.onError).map(a=>_a(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,Ws(n.onSnapshot).map(a=>_a(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 xI(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?dI([i,s]):i,target:`#${r}`};t.push(_a(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function bI(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"?[]:Po(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function az(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(Sf(n))return e.machine.getStateNodeById(n);let o=n[0]===f2;if(o&&!e.parent)return Af(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return Af(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 AI(e){let t=lI(e.config.target);return t?{target:t.map(n=>typeof n=="string"?Af(e.parent,n):n)}:e.parent.initial}function js(e){return e.type==="history"}function eI(e){let t=vI(e);for(let n of t)for(let o of Vl(n,e))t.add(o);return t}function vI(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 Gl(o))n(a)}}return n(e),t}function ql(e,t){if(Sf(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 Af(e,t){if(typeof t=="string"&&Sf(t))try{return e.machine.getStateNodeById(t)}catch{}let n=Vm(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=ql(o,a)}return o}function Zl(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=>ql(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=ql(e,r);if(!s)return a;let i=Zl(s,t[r]);return a.concat(i)},[]))}function rz(e,t,n,o){let r=ql(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function sz(e,t,n,o){let a=Object.keys(t),r=ql(e,a[0]),s=Km(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function iz(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=ql(e,r),l=Km(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function Km(e,t,n,o){return typeof t=="string"?rz(e,t,n,o):Object.keys(t).length===1?sz(e,t,n,o):iz(e,t,n,o)}function lz(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function Ir(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function cz(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 LI(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(cz(u2([a],t,n),u2([i],t,n)))if(Ir(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 uz(e){let[t,...n]=e;for(let o of Vl(t,void 0))if(n.every(a=>Ir(a,o)))return o}function x2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(js(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of x2(AI(o),t))n.add(a);else n.add(o);return[...n]}function SI(e,t){let n=x2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||Ir(a,e.source)))return e.source;let o=uz(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function u2(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=SI(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)Ir(s,r)&&o.add(s)}return[...o]}function dz(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function b2(e,t,n,o,a){return d2([{target:[...vI(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=LI(e,l,c),d=t;a||([d,c]=mz(d,o,n,u,l,c,r,n.actionExecutor)),d=Vs(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=pz(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=Vs(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&dz(t._nodes,l)?[d,s]:[Er(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function fz(e,t,n,o,a){if(o.output===void 0)return;let r=l2(a.id,a.output!==void 0&&a.parent?c2(a.output,e.context,t,n.self):void 0);return c2(o.output,e.context,r,n.self)}function pz(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;hz(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(jl(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=Vs(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,b=m||f;for(h?.type==="compound"&&r.push(l2(h.id,f.output!==void 0?c2(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&Ym(a,m);)d.add(m),r.push(l2(m.id)),b=m,m=m.parent;if(m)continue;l=Er(l,{status:"done",output:fz(l,t,n,l.machine.root,b)})}}return l}function hz(e,t,n,o){for(let a of e){let r=SI(a,t);for(let i of a.target||[])!js(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),Ul(i,t,n,o);let s=x2(a,t);for(let i of s){let l=Vl(i,r);r?.type==="parallel"&&l.push(r),kI(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function Ul(e,t,n,o){if(js(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),Ul(r,t,n,o);for(let r of a)s2(r,e.parent,o,t,n)}else{let a=AI(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),Ul(r,t,n,o);for(let r of a.target)s2(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;js(a)||(o.add(a),n.add(a)),Ul(a,t,n,o),s2(a,e,o,t,n)}else if(e.type==="parallel")for(let a of Gl(e).filter(r=>!js(r)))[...o].some(r=>Ir(r,a))||(js(a)||(o.add(a),n.add(a)),Ul(a,t,n,o))}function kI(e,t,n,o,a){for(let r of o)if((!a||Ir(r,a))&&e.add(r),r.type==="parallel")for(let s of Gl(r).filter(i=>!js(i)))[...e].some(i=>Ir(i,s))||(e.add(s),Ul(s,t,n,e))}function s2(e,t,n,o,a){kI(n,o,a,Vl(e,t))}function mz(e,t,n,o,a,r,s,i){let l=e,c=u2(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of lz(d)){let p;f.history==="deep"?p=h=>Xm(h)&&Ir(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=Vs(l,t,n,[...d.exit,...d.invoke.map(f=>Zs(f.id))],s,void 0),a.delete(d);return[l,u||r]}function yz(e,t){return e.implementations.actions[t]}function wI(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:yz(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,b]=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)}),b&&(i=wI(i,t,n,b,a,r))}return i}function Vs(e,t,n,o,a,r){let s=r?[]:void 0,i=wI(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function kf(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=Er(tI(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==oI){let d=i,f=ZB(d),p=nI(d,a);if(f&&!p.length)return a=Er(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?gz(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=nI(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"&&tI(a,i,n),{snapshot:a,microsteps:r}}function tI(e,t,n){return Vs(e,t,n,Object.values(e.children).map(o=>Zs(o)),[],void 0)}function nI(e,t){return t.machine.getTransitionData(t,e)}function gz(e,t){let n=new Set,o=e._nodes.filter(Xm);for(let a of o)e:for(let r of[a].concat(Vl(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||Xs(s.guard,e.context,t,e)){n.add(s);break e}}return LI(Array.from(n),new Set(e._nodes),e.historyValue)}function _I(e,t){let n=Lf(Zl(e,t));return hI(e,[...n])}function CI(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var xz=function(t){return m2(t,this.value)},bz=function(t){return this.tags.has(t)},Az=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},vz=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)}},Lz=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function wf(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:hI(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:xz,hasTag:bz,can:Az,getMeta:Lz,toJSON:vz}}function Er(e,t={}){return wf({...e,...t},e.machine)}function Sz(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 TI(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 b=r[m];p[m]={snapshot:b.getPersistedSnapshot(t),src:b.src,systemId:b.systemId,syncSnapshot:b._syncSnapshot}}return{...f,context:II(s),children:p,historyValue:Sz(f.historyValue)}}function II(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:Zm,id:o.id};else{let a=II(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function kz(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 wz(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 Xl(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=kz,n.execute=wz,n}function EI(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 hee=EI(e=>{},void 0);function _z(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=vf(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=Bo(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 Bo(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!==qt.Stopped&&l.start()}),l}}function Cz(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:_z(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[Er(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function vn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=Cz,t}var MI=new WeakMap;function Yl(e,t,n){let o=MI.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},MI.set(e,o)),o[t]}var Tz={},_f=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,$m=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(f2),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?y2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):Tz,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=Po(this.config.entry).slice(),this.exit=Po(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Po(t.tags).slice()}_initialize(){this.transitions=gI(this),this.config.always&&(this.always=Ws(this.config.always).map(t=>_a(this,p2,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(_f),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(_f),eventType:null})}:void 0,history:this.history,states:y2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(_f)})),entry:this.entry.map(_f),exit:this.exit.map(_f),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 Yl(this,"invoke",()=>Po(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??g2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${g2(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 Yl(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 Yl(this,"delayedTransitions",()=>yI(this))}get initial(){return Yl(this,"initial",()=>bI(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=Yl(this,`candidates-${o}`,()=>mI(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||Xs(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 Yl(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)}},Iz="#",Qm=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 $m(t,{_key:this.id,_machine:this}),this.root._initialize(),xI(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=_I(this.root,t.value),o=Lf(Zl(this.root,n));return wf({_nodes:[...o],context:t.context||{},children:{},status:Ym(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return kf(t,n,o,[]).snapshot}microstep(t,n,o){return kf(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return Km(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=wf({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?Vs(r,n,t,[vn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=jm(n),a=[],r=this._getPreInitialState(t,o,a),[s]=b2(this.root,r,t,o,a),{snapshot:i}=kf(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=Vm(t),o=n.slice(1),a=Sf(n[0])?n[0].slice(Iz.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 Af(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return TI(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"?vf(this,h):h;if(!m)return;let b=Bo(m,{id:d,parent:n.self,syncSnapshot:f.syncSnapshot,snapshot:p,src:h,systemId:f.systemId});o[d]=b});function r(d,f){if(f instanceof $m)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 b of m){let y=r(d,b);y&&(p[h]??=[],p[h].push(y))}}return p}let i=s(this.root,t.historyValue),l=wf({...t,children:o,_nodes:Array.from(Lf(Zl(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===Zm){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function Ez(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function Mz(e,{event:t}){e.defer(()=>e.emit(t))}function e0(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=Ez,t.execute=Mz,t}var Jm=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function Oz(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===Jm.Parent?p=e.self._parent:f===Jm.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 Rz(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function Dz(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===aI?h2(e.self.id,o.data):o)})}function Cf(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=Oz,o.retryResolve=Rz,o.execute=Dz,o}function OI(e,t){return Cf(Jm.Parent,e,t)}function Pz(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(vn(...i))},s.cancel=(...i)=>{r.push(Wl(...i))},s.raise=(...i)=>{r.push(Xl(...i))},s.sendTo=(...i)=>{r.push(Cf(...i))},s.sendParent=(...i)=>{r.push(OI(...i))},s.spawnChild=(...i)=>{r.push(jl(...i))},s.stopChild=(...i)=>{r.push(Zs(...i))},s.emit=(...i)=>{r.push(e0(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>Xs(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function St(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=Pz,t}function Bz(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function zz({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function A2(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=Bz,n.execute=zz,n}function Nz(e,t){return new Qm(e,t)}function v2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:vn,sendTo:Cf,raise:Xl,log:A2,cancel:Wl,stopChild:Zs,enqueueActions:St,emit:e0,spawnChild:jl,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>Nz({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>v2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var Fz=()=>({mode:D_,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),Ys=4,zo=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=Ys*Ys},Tf=(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)}},RI=v2({types:{context:{},events:{},emitted:{}},actions:{startPress:vn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:vn((e,t)=>({pressLast:t.point})),setDrawingType:vn((e,t)=>({drawingType:t.kind})),resetGesture:vn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:vn((e,t)=>({mode:t.mode})),emitMoveElement:St(({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:St(({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:St(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:St(({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:St(({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:St(({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:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=Tf(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:St(({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:St(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:St(({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:St(({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:St(({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:Tf(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=Tf(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:St(({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<Ys*Ys||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:zo(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:zo(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:zo(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:zo(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:zo(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:zo(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:zo(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:zo(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:zo(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:Fz(),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"}]}}}}}),DI=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||zo(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 PI=new Map,Vn=(e,t)=>{PI.set(e,t)},Kl=e=>PI.get(e);var Ks=["background","main","overlay"];var Mr=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}},Hz=new Mr,$l=(e,t)=>e.getOrCompute(t,z);var L2={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 t0={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 S2={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 $s={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 k2={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 w2={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 _2={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 Ql={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 Qs={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 C2={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 Ca={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 T2={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 Jl={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 ec={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 Or=["tomato","amber","grass","cyan","iris","plum","gray"],If=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},Jt=(e,t)=>({fill:If(e,`${t}4`),solid:If(e,`${t}9`),solidHover:If(e,`${t}10`),textLow:If(e,`${t}11`),textHigh:If(e,`${t}12`)}),tc={light:{tomato:Jt(Qs,"tomato"),amber:Jt(ec,"amber"),grass:Jt(Jl,"grass"),cyan:Jt(T2,"cyan"),iris:Jt(Ca,"iris"),plum:Jt(C2,"plum"),gray:Jt(Ql,"gray")},dark:{tomato:Jt(t0,"tomato"),amber:Jt(_2,"amber"),grass:Jt(w2,"grass"),cyan:Jt(k2,"cyan"),iris:Jt($s,"iris"),plum:Jt(S2,"plum"),gray:Jt(L2,"gray")}},n0={light:{tomato:Qs.tomato2,amber:ec.amber2,grass:Jl.grass2,cyan:T2.cyan2,iris:Ca.iris2,plum:C2.plum2,gray:Ql.gray2},dark:{tomato:t0.tomato2,amber:_2.amber2,grass:w2.grass2,cyan:k2.cyan2,iris:$s.iris2,plum:S2.plum2,gray:L2.gray2}};var Uz={light:{accent:Ca.iris9,accentHover:Ca.iris10,selectedBg:Ca.iris4,selectedFg:Ca.iris11,danger:Qs.tomato9},dark:{accent:$s.iris9,accentHover:$s.iris10,selectedBg:$s.iris4,selectedFg:$s.iris11,danger:t0.tomato9}},I2=Ql.gray6,E2=Ql.gray9,Rr={rectangle:{fill:Ca.iris3,stroke:Ca.iris9,strokeWidth:2},ellipse:{fill:Qs.tomato3,stroke:Qs.tomato9,strokeWidth:2},flowchart:{fill:Jl.grass3,stroke:Jl.grass9,strokeWidth:2},sticky:{fill:ec.amber3,stroke:ec.amber9,strokeWidth:1}},M2={stroke:Ql.gray12,strokeWidth:1.5},Gz={added:Jl.grass9,removed:Qs.tomato9,modified:ec.amber9};var O2={placeholder:.15,hideText:.4},R2="#bbb";var BI=.06,zI=.92,NI=.5,nc=10,D2=I2,P2=E2,B2=1,z2=1,N2=4,F2=4,H2=3,U2=12,G2=56,q2=10,W2=20,FI=.4,HI=.5,j2=.1,V2=.9,UI="#888",GI="#ffffff",qI="#222",WI="#ddd",jI=18,VI=12,ZI="#444",XI="#222",YI=10,Z2="#000",KI=.5,$I=12,QI="#222",JI="#fff";var Ef=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 o0=e=>e<=0?1:2**Math.round(Math.log2(e));var Js=(e,t,n={})=>{let o=qn(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let g=[B.applyToPoint(o,{x:a.x,y:a.y}),B.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],x=X.expand(X.fromPoints(g),2);t.clear(x)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new Mr,s=n.viewport,i=null;s&&n.spatialIndex&&(i=n.spatialIndex.query(s));let l=e.viewport.zoom,c=n.lod,u=c?.placeholder!==void 0&&l<c.placeholder,d=c?.hideText!==void 0&&l<c.hideText,f=n.placeholderFill??R2,p=n.layerCompositeCache,h=n.dirtyLayerIds,m=n.compositeLayerBitmap,b=o0(l),y=g=>{let x=null;for(let A of La(e,g)){let C=$l(r,A);x=x?X.union(x,C):C}return x};for(let g of co(e))if(g.visible){if(p&&m){h?.has(g.id)&&p.invalidateLayer(g.id);let x=p.get(g.id,b);if(x===void 0){let A=m(g.id,b,e);A!==null&&(p.set(g.id,b,A),x=A)}if(x!==void 0){let A=y(g.id);A&&t.drawImage(x,A.x,A.y,A.width,A.height);continue}}for(let x of La(e,g.id)){if(n.hideElements?.has(x.id)||i&&!i.has(x.id))continue;if(s){let C=$l(r,x);if(!X.intersects(C,s))continue}if(a){let C=$l(r,x);if(!X.intersects(C,a))continue}if(d&&Fe(x))continue;if(u){let C=$l(r,x);t.setFill(f),t.setStrokeWidth(0),t.beginPath(),t.rect(C.x,C.y,C.width,C.height),t.fill();continue}let A=Kl(x.type);if(!A){n.onUnknownElement?.(x);continue}t.save(),n.dimElements?.has(x.id)&&n.dimOpacity!==void 0&&t.setOpacity(n.dimOpacity),t.translate(x.position.x,x.position.y),x.rotation!==0&&t.rotate(x.rotation),(x.scale.x!==1||x.scale.y!==1)&&t.scale(x.scale.x,x.scale.y),A(x,t,{zoom:l}),t.restore()}}t.restore()};var a0=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,Dr(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}},Dr=(e,t)=>{let n=Dl(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}},X2=new a0;var No=(e,t,n={})=>{t.save(),t.setTransform(qn(e.viewport));let o=n.edgeBoundsCache??X2,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=o0(n.zoom??e.viewport.zoom);for(let c of co(e))if(c.visible)for(let u of j1(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&&!X.intersects(d,a)||r&&!X.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}}qz(e,u,t,n)}t.restore()},qz=(e,t,n,o)=>{let a=rt(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}if(n.save(),(t.lineKind??"line")==="block-arrow")Wz(t,a,n);else{Zz(t,n);let r=(t.routing??"straight")==="bezier"?nf(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&&nc>0)r0(n,a,nc);else{let s=L(a[0]);n.moveTo(s.x,s.y);for(let i=1;i<a.length;i++){let l=L(a[i]);n.lineTo(l.x,l.y)}}if(n.stroke(),t.arrowheads){let s=r?$d(r.start,r.segments):a;Xz(s,t.arrowheads,n,t.style.stroke??Z2)}}t.label&&Yz(a,t.label,n),n.restore()},Wz=(e,t,n)=>{let o=e.blockArrow?.headLength??jI,a=e.blockArrow?.bodyThickness??VI,r=e.style.fill??e.style.stroke??ZI,s=e.style.stroke??XI,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=jz(t,o);if(l.length<2)return;let c=eE(l,a/2),u=eE(l,-a/2),d=L(c[c.length-1]),f=L(u[u.length-1]),p=L(t[t.length-1]);n.setFill(r),n.setStroke(s),n.setStrokeWidth(i),n.beginPath();let h=L(c[0]);n.moveTo(h.x,h.y);for(let g=1;g<c.length;g++){let x=L(c[g]);n.lineTo(x.x,x.y)}let m=Math.max(0,a*.5),b=tE(d,p,m),y=tE(f,p,-m);n.lineTo(b.x,b.y),n.lineTo(p.x,p.y),n.lineTo(y.x,y.y);for(let g=u.length-1;g>=0;g--){let x=L(u[g]);n.lineTo(x.x,x.y)}n.closePath(),n.fill(),i>0&&n.stroke()},jz=(e,t)=>{if(e.length<2)return e;let n=t,o=[...e].reverse(),a=[L(o[0])];for(let r=1;r<o.length;r++){let s=L(a[a.length-1]),i=L(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},eE=(e,t)=>{if(e.length<2)return e;let n=[];for(let o=0;o<e.length;o++){let a=L(e[Math.max(0,o-1)]),r=L(e[Math.min(e.length-1,o+1)]),s=L(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},tE=(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}},Vz=e=>{if(e.length<=2)return e;let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(t[t.length-1]),a=L(e[n]),r=L(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(L(e[e.length-1])),t},r0=(e,t,n)=>{let o=Vz(t);if(o.length<3){let s=L(o[0]);e.moveTo(s.x,s.y);for(let i=1;i<o.length;i++){let l=L(o[i]);e.lineTo(l.x,l.y)}return}let a=L(o[0]);e.moveTo(a.x,a.y);for(let s=1;s<o.length-1;s++){let i=L(o[s-1]),l=L(o[s]),c=L(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=L(o[o.length-1]);e.lineTo(r.x,r.y)},Zz=(e,t)=>{let n=e.style.stroke??Z2;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)},Xz=(e,t,n,o)=>{let a=t.size??YI;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&nE(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&&nE(r,s,t.to,a,n,o)}},nE=(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}),b=()=>{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),x=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(x.x,x.y,y.x,y.y),a.stroke();break}case"triangle":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(m(o,-p))),a.closePath(),b();break}case"circle":case"filledCircle":{let y=p,g=h(y);a.beginPath(),a.ellipse(g.x,g.y,y,y),n==="filledCircle"?b():a.stroke();break}case"diamond":case"rhombus":case"filledRhombus":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(h(o*2))),a.lineTo(...po(m(o,-p))),a.closePath(),n==="filledRhombus"?b():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",x=n==="erdOnlyOne",A=n==="erdOne"||n==="erdOnlyOne"||n==="erdOneOrMany"||n==="erdZeroOrOne";if(y){let v=h(o);a.beginPath(),a.moveTo(v.x,v.y),a.lineTo(e.x,e.y),a.moveTo(v.x,v.y),a.lineTo(...po(m(0,p))),a.moveTo(v.x,v.y),a.lineTo(...po(m(0,-p))),a.stroke()}let C=y?o*1.15:o*.55,_=v=>{a.beginPath(),a.moveTo(...po(m(v,p))),a.lineTo(...po(m(v,-p))),a.stroke()};if(A&&_(C),x&&_(C+o*.4),g){let v=p*.6,I=h(o*(y?1.6:1)+v);a.beginPath(),a.ellipse(I.x,I.y,v,v),a.stroke()}break}}},po=e=>[e.x,e.y],Yz=(e,t,n)=>{let o=t.position??KI,a=t.fontSize??$I,r=t.fill??QI,s=t.background??JI,i=Kz(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)},Kz=(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=L(e[r]),i=L(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=L(n[r]);if(a<=s){let i=s===0?0:a/s,l=L(e[r]),c=L(e[r+1]);return{x:l.x+(c.x-l.x)*i,y:l.y+(c.y-l.y)*i}}a-=s}return L(e[e.length-1])};var oE=(e,t,n,o,a=F2,r=H2)=>{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},Mf=(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?P2:D2),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=eN(e,l,c);if(!u)return;let d=f=>{r?Qz(t,u,f,s,i):$z(t,u,f,s,i)};if(t.save(),t.setTransform(qn(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=Jz(i,f);if(p<=0)continue;let h=f.step*o;h*i<N2||(t.setOpacity(p),d(h))}else{let f=r?q2:U2,p=r?W2:G2;for(let h of oE(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},$z=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=aE(t,n),c=B2/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()},Qz=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=aE(t,n);e.setStroke(null),e.setFill(o);let c=z2/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()},aE=(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}),Jz=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),eN=(e,t,n)=>{let o=ka(e.viewport),a=[B.applyToPoint(o,{x:0,y:0}),B.applyToPoint(o,{x:t,y:0}),B.applyToPoint(o,{x:t,y:n}),B.applyToPoint(o,{x:0,y:n})],r=X.fromPoints(a);return Number.isFinite(r.x)?r:null};var rE=1.2,tN=(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=L(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)},Of=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??rE),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)}):tN(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}},Y2=(e,t,n)=>n==="center"?t/2-e/2:n==="right"?t-e:0,nN=(e,t)=>{let{lines:n}=e;for(let o=0;o<n.length;o++){let a=L(n[o]);if(t<=a.end)return o}return n.length-1},K2=(e,t,n,o,a)=>{let r=nN(e,t),s=L(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:Y2(s.width,e.blockWidth,a)+l,y:r*e.lineHeight,height:o,line:r}},$2=(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=L(a[s]),l=Y2(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},Q2=(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=L(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=Y2(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 sE=new Map,Rf=e=>{sE.set(e.kind,e)};var J2=new Set,eA=e=>(J2.add(e),()=>J2.delete(e)),tA=()=>{for(let e of J2)try{e()}catch{}},iE=()=>typeof performance<"u"?performance.now():0,nA=e=>{iE=e};var s0=(e,t=iE(e))=>{if(!e.animationKind)return e.src;let n=sE.get(e.animationKind);if(!n)return e.src;try{return n.getFrameAt(e.animationData,t)}catch{return e.src}};var Pf=(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}},oN=(e,t)=>{let{fill:n,stroke:o}=Pf(e.style,t);if(!n&&!o)return;let a=Wd(e.style.roundness,e.width,e.height);if(n&&(t.beginPath(),a>0?lE(t,0,0,e.width,e.height,a):t.rect(0,0,e.width,e.height),t.fill()),o){let r=l0(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?lE(t,s,i,l,c,u):t.rect(s,i,l,c),t.stroke()}},l0=e=>{let t=e.strokeAlign??"center";if(t==="center")return 0;let n=(e.strokeWidth??1)/2;return t==="inside"?n:-n},lE=(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()},aN=(e,t)=>{let{fill:n,stroke:o}=Pf(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=l0(e.style),i=a-s,l=r-s;if(i<=0||l<=0)return;t.beginPath(),t.ellipse(a,r,i,l),t.stroke()}},rN=(e,t)=>{if(e.points.length<2)return;let{fill:n,stroke:o}=Pf(e.style,t);if(!(!n&&!o)&&(n&&(t.beginPath(),i0(t,e.points),t.fill()),o)){let a=l0(e.style),r=a!==0?qd.offsetClosedPath(e.points,a):e.points;t.beginPath(),i0(t,r),t.stroke()}},i0=(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()}},sN=(e,t)=>{if(e.commands.length===0)return;let{fill:n,stroke:o}=Pf(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()}},iN=(e,t)=>{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=Of(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*BI);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*zI,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*NI-c/2,u.width,c),t.fill()))}},lN=(e,t)=>{let n=e.points;if(n.length===0)return;let o=e.style.fill??e.style.stroke??"#000";if(t.setFill(o),t.setStroke(null),n.length===1){let a=L(n[0]);t.beginPath(),t.ellipse(a.x,a.y,a.width,a.width),t.fill();return}for(let a=0;a<n.length-1;a++){let r=L(n[a]),s=L(n[a+1]),i=s.x-r.x,l=s.y-r.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;t.beginPath(),t.moveTo(r.x+u*r.width,r.y+d*r.width),t.lineTo(s.x+u*s.width,s.y+d*s.width),t.lineTo(s.x-u*s.width,s.y-d*s.width),t.lineTo(r.x-u*r.width,r.y-d*r.width),t.closePath(),t.fill(),t.beginPath(),t.ellipse(s.x,s.y,s.width,s.width),t.fill()}},cN=(e,t)=>{let n=e.animationKind?s0(e):e.metadata?.image??s0(e),o=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(n,0,0,e.width,e.height,o)},oc=()=>{Vn("rectangle",oN),Vn("ellipse",aN),Vn("polygon",rN),Vn("path",sN),Vn("text",iN),Vn("image",cN),Vn("group",()=>{}),Vn("frame",pN),lb("frame",()=>({top:24})),Vn("block-arrow",uN),Vn("brush",lN)},uN=(e,t)=>{let{fill:n,stroke:o}=Pf(e.style,t),a=e.direction??"right",r=Math.max(j2,Math.min(V2,e.headRatio??FI)),s=Math.max(j2,Math.min(V2,e.bodyThickness??HI)),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,b])=>dN([m,b],a,i,l)));let h=p.map(([m,b])=>({x:m,y:b}));if(n&&(t.beginPath(),i0(t,h),t.fill()),o){let m=l0(e.style),b=m!==0?qd.offsetClosedPath(h,m):h;t.beginPath(),i0(t,b),t.stroke()}},dN=([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)]}},oA="\u2026",fN=(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)+oA).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+oA:oA},pN=(e,t,n)=>{t.setFill(e.style.fill??GI),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(UI),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:fN(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(qI),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(WI),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var Bf=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()},Pr=(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 cE=null,zf=e=>{cE=e},rA=()=>cE;var uE=null,Nf=e=>{uE=e},c0=()=>uE;var u0={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=Fn.flattenQuadratic(a,r.control,r.to,n(s));for(let l=1;l<i.length;l++)o.push(L(i[l]));a=r.to;break}case"C":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=Fn.flattenCubic(a,r.control1,r.control2,r.to,n(s));for(let l=1;l<i.length;l++)o.push(L(i[l]));a=r.to;break}case"Z":if(o.length>0){let s=L(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=L(e[Math.max(0,i-1)]),c=L(e[Math.min(e.length-1,i+1)]),u=L(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(),L(r[0])]}};var ei=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",hN=new Set(["rectangle","ellipse","template","text","frame"]),ti=e=>hN.has(e.type),sA=e=>Hs;var ho=(e,t)=>{let n=uo(e),a=[...Am(e).keys()].filter(s=>!n.has(s)),r=a.map(s=>{let i={kind:"named",name:s},l=Gt(e,i);if(t===0)return l;let c=Eo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var pE=(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:Tr(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()?Us:Hs,d=o2(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=M(t.scene,l);if(!c||!ti(c)||c.locked===!0)continue;let u=qs(c),d=KT(e,u,n,t.handleHitSlop,sA(c));if(d)return{kind:"handle",elementId:l,handle:d,bounds:u.bounds}}let r=a?t.combinedSelectionBounds():null;if(r){let l=Gm(r,n);if(a2(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=M(t.scene,l);if(!c||!ti(c)||c.locked===!0)continue;let u=Um(c,n);if(a2(e,u,n,t.handleHitSlop)){let d=qs(c);return{kind:"rotate-handle",pivot:XT(d),bounds:d.bounds}}}if(t.selectedLink){let l=be(t.scene,t.selectedLink);if(l){let c=rt(t.scene,l);if(c&&c.length>=2){let u=t.edgeHandleHitSlop/n,d=L(c[0]),f=L(c[c.length-1]);if(Ae.distance(e,d)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"from"};if(Ae.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=ib(t.scene,e,t.edgeHitThreshold/n);return i&&!t.isLayerLocked(i.layerId)?{kind:"link",id:i.id}:{kind:"empty"}},Ff=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(Nl),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.rect(t,n,o,a),e.stroke()},ni=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(Nl),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},mN=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(mf),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},dE=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(Nl),e.beginPath();let o=L(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.fill(),e.setFill(null),e.setStroke(n),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.stroke()},fE=(e,t,n,o,a,r)=>{let s=B.applyToPoint(t,{x:n.x,y:n.y}),i=B.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=B.applyToPoint(t,Gs(p,n,o));Ff(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Ff(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Ff(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Ff(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Ff(e,l+u-f,c-f,f*2,d+f*2,r);break}},d0=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}},hE=(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=L([...r][0]),p=M(n,f);p&&ti(p)&&p.locked!==!0&&fE(e,o,z(p),a,sA(p),Ub)}if(s.linkBodies)for(let f of n.links.values()){let p=rt(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(ZC),e.setStrokeWidth(Dm*2),e.setOpacity(Nl),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=B.applyToPoint(o,L(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let b=B.applyToPoint(o,L(p[m]));e.lineTo(b.x,b.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=B.applyToPoint(o,i.from),p=B.applyToPoint(o,i.to);ni(e,f.x,f.y,Oo,yf),ni(e,p.x,p.y,Oo,yf);for(let h of i.waypoints??[]){let m=B.applyToPoint(o,h);ni(e,m.x,m.y,Oo,yf)}for(let h of i.midpoints??[]){let m=B.applyToPoint(o,h);ni(e,m.x,m.y,Oo,yf)}}if(s.anchorDots&&r.size===1){let f=L([...r][0]),p=M(n,f);if(p){let h=Ro+Pm,{worldPoints:m}=ho(p,fo/a);for(let b of m){let y=B.applyToPoint(o,b);ni(e,y.x,y.y,h,Gb),mN(e,y.x,y.y,Bm,Gb)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)dE(e,p.map(h=>B.applyToPoint(o,h)),KC);e.setFill(null),e.setStroke(YC),e.setStrokeWidth(f*2),e.setOpacity(Nl),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=B.applyToPoint(o,L(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let b=B.applyToPoint(o,L(p[m]));e.lineTo(b.x,b.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=B.applyToPoint(o,p);ni(e,h.x,h.y,f,XC)}}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(b=>B.applyToPoint(o,b));dE(e,m,h)};for(let p of c.frames)f(p,$C);for(let p of c.containers)f(p,QC)}if(s.groupHandles&&u&&fE(e,o,u,a,d?Us:Hs,Ub),s.annotationPins)for(let f of n.annotations.values()){let p=B.applyToPoint(o,Tr(n,f));ni(e,p.x,p.y,Nm,JC)}e.setOpacity(1),e.restore()};var xE=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=Oe(o)?xE(e,o.id):z(o);a&&(n=n?X.union(n,a):a)}return n},bE={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},AE=.32,vE=(e,t,n,o,a=bE)=>{if(n.length===0)return;let s=zb/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(AE),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(B.IDENTITY)},LE=(e,t,n,o={})=>{let a={...bE,...o.style};n.clear();let r=qn(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(B.IDENTITY),o.debugHitZones&&hE(n,{scene:e,w2s:r,zoom:s,selection:t,visibility:o.debugHitZoneVisibility??d0({linkDragActive:!1,elementDragActive:!1}),...o.edgeSelection?{edgeSelection:o.edgeSelection}:{},...o.debugAttachZones?{attach:o.debugAttachZones}:{},...o.debugContainerZones?{containers:o.debugContainerZones}:{},...o.groupBounds?{groupBounds:o.groupBounds}:{},...o.groupAspectLocked!==void 0?{groupAspectLocked:o.groupAspectLocked}:{}});let i=t.size>1;for(let l of t){let c=e.elements.get(l);if(!c)continue;if(Oe(c)){let d=xE(e,l);if(!d)continue;let f=Fo(d,r);if(iA(n,f,a),c.locked===!0){yE(n,f);continue}if(i||!ti(c))continue;for(let p of Us){let h=Gs(p,d,s);lA(n,B.applyToPoint(r,h),a)}gE(n,d,s,r,a);continue}let u=qs(c);if(u.rotation===0?iA(n,Fo(u.bounds,r),a):xN(n,u,r,a),c.locked===!0){yE(n,bN(u,r));continue}if(!(i||!ti(c))){for(let d of Us){let f=YT(d,u,s);lA(n,B.applyToPoint(r,f),a)}SE(n,B.applyToPoint(r,Um(c,s)),a)}}if(o.drawingPreview){let l=Fo(o.drawingPreview,r);AN(n,l,a)}if(o.drawingPreviewElement){let l=o.drawingPreviewElement,c=Kl(l.type);c&&(n.save(),n.setTransform(r),n.setOpacity(uT),n.setDashArray(null),n.translate(l.position.x,l.position.y),l.rotation!==0&&n.rotate(l.rotation),(l.scale.x!==1||l.scale.y!==1)&&n.scale(l.scale.x,l.scale.y),c(l,n),n.restore())}if(o.edgePreview){let l=o.edgePreview.points;if(l&&l.length>=2)LN(n,l.map(c=>B.applyToPoint(r,c)),a);else{let c=B.applyToPoint(r,o.edgePreview.from),u=B.applyToPoint(r,o.edgePreview.to);vN(n,c,u,a)}}if(o.ghostElement||o.ghostElementShape){n.setOpacity(zm);let l=o.ghostElementShape,c=l?Kl(l.type):void 0;if(l&&c)n.save(),n.setTransform(r),n.setDashArray(null),n.translate(l.position.x,l.position.y),l.rotation!==0&&n.rotate(l.rotation),(l.scale.x!==1||l.scale.y!==1)&&n.scale(l.scale.x,l.scale.y),c(l,n),n.restore();else if(o.ghostElement){let u=Fo(o.ghostElement,r);n.setStroke(a.selectionStroke),n.setStrokeWidth(1.5),n.setDashArray(null),n.setFill(null),n.beginPath(),n.rect(u.x,u.y,u.width,u.height),n.stroke()}n.setOpacity(1)}if(o.linkAttachHighlight){let l=Fo(o.linkAttachHighlight,r),c=2;n.setStroke(a.selectionStroke),n.setStrokeWidth(2),n.setDashArray(null),n.setFill(null),n.beginPath(),n.rect(l.x-c,l.y-c,l.width+c*2,l.height+c*2),n.stroke()}if(o.ports){let l=Array.isArray(o.ports)?o.ports:[o.ports];for(let c of l)for(let u=0;u<c.worldPoints.length;u++){let d=B.applyToPoint(r,L(c.worldPoints[u])),f=c.activeIndex===u;SN(n,d,a,f,c.role,f?c.activeRadius:void 0)}}if(o.selectedLinkPaths&&o.selectedLinkPaths.length>0){n.setTransform(r),n.setStroke(a.selectionStroke),n.setOpacity(AE),n.setDashArray(null),n.setLineJoin("round"),n.setLineCap("round");let l=zb/(s||1);for(let{path:c,width:u}of o.selectedLinkPaths)c.length<2||(n.setStrokeWidth(u+2*l),n.beginPath(),r0(n,c,nc),n.stroke());n.setOpacity(1),n.setLineJoin("miter"),n.setLineCap("butt"),n.setTransform(B.IDENTITY)}if(o.edgeSelection){let l=B.applyToPoint(r,o.edgeSelection.from),c=B.applyToPoint(r,o.edgeSelection.to);for(let u of o.edgeSelection.midpoints??[])kN(n,B.applyToPoint(r,u),a);cA(n,l,a),cA(n,c,a);for(let u of o.edgeSelection.waypoints??[])cA(n,B.applyToPoint(r,u),a)}if(o.peerSelections)for(let l of o.peerSelections)for(let c of l.bounds){let u=Fo(c,r);wN(n,u,l.color)}if(o.brushPreview&&o.brushPreview.points.length>0){let l=o.brushPreview;n.save(),n.setTransform(r),n.setFill(l.fill),n.setStroke(null);let c=l.points,u=l.origin.x,d=l.origin.y;if(c.length===1){let f=L(c[0]);n.beginPath(),n.ellipse(u+f.x,d+f.y,f.width,f.width),n.fill()}else for(let f=0;f<c.length-1;f++){let p=L(c[f]),h=L(c[f+1]),m=u+p.x,b=d+p.y,y=u+h.x,g=d+h.y,x=y-m,A=g-b,C=Math.hypot(x,A)||1,_=-A/C,v=x/C;n.beginPath(),n.moveTo(m+_*p.width,b+v*p.width),n.lineTo(y+_*h.width,g+v*h.width),n.lineTo(y-_*h.width,g-v*h.width),n.lineTo(m-_*p.width,b-v*p.width),n.closePath(),n.fill(),n.beginPath(),n.ellipse(y,g,h.width,h.width),n.fill()}n.restore()}if(o.containerDropZone){let l=Fo(o.containerDropZone,r);n.setFill("rgba(26, 115, 232, 0.10)"),n.setStroke("#1a73e8"),n.setStrokeWidth(2),n.setDashArray([6,3]),n.beginPath(),n.rect(l.x,l.y,l.width,l.height),n.fill(),n.stroke(),n.setDashArray(null)}if(o.groupBounds){let l=Fo(o.groupBounds,r);iA(n,l,a);let c=Us;for(let u of c){let d=Gs(u,o.groupBounds,s),f=B.applyToPoint(r,d);lA(n,f,a)}gE(n,o.groupBounds,s,r,a)}if(o.annotations&&o.annotations.length>0)for(let l of o.annotations){let c=Tr(e,l),u=B.applyToPoint(r,c);CN(n,u,l,o.selectedAnnotation??null)}if(o.peerCursors)for(let l of o.peerCursors){let c=B.applyToPoint(r,l.position);_N(n,c,l.color,l.name)}if(o.gifBadges)for(let l of o.gifBadges)gN(n,Fo(l,r));if(o.editingText){let l=o.editingText;if(l.selectionRects.length>0){n.setFill(BT),n.setOpacity(zT);for(let c of l.selectionRects){let u=Fo(c,r);n.beginPath(),n.rect(u.x,u.y,u.width,u.height),n.fill()}n.setOpacity(1)}if(l.caret){let c=B.applyToPoint(r,{x:l.caret.x,y:l.caret.y});n.setFill(l.caretColor),n.setOpacity(1),n.beginPath(),n.rect(c.x,c.y,NT,l.caret.height*s),n.fill()}}n.restore()},yE=(e,t)=>{let n=WT,o=t.x+t.width-n-2,a=t.y+2,r=jT;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(VT),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},gN=(e,t)=>{let n=t.x+n2,o=t.y+n2,a=HT,r=UT,s=GT;e.setStroke(null),e.setFill(qT),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)},Fo=(e,t)=>{let n=B.applyToPoint(t,{x:e.x,y:e.y}),o=B.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)}},iA=(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()},xN=(e,t,n,o)=>{let[a,r,s,i]=xf(t),l=B.applyToPoint(n,a),c=B.applyToPoint(n,r),u=B.applyToPoint(n,s),d=B.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()},bN=(e,t)=>{let n=xf(e).map(i=>B.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}},lA=(e,t,n)=>{e.setFill(n.handleFill),e.setStroke(n.handleStroke),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,5,5),e.fill(),e.stroke()},SE=(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")},gE=(e,t,n,o,a)=>{let r=Gm(t,n);SE(e,B.applyToPoint(o,r),a)},AN=(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()},vN=(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()},LN=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=L(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.stroke()},SN=(e,t,n,o,a="link-start",r)=>{let s=o?r??Ro:hf,i=a==="link-start",l=o?i?Nb:Fb:i?GC:qC,c=i?Nb:Fb;e.setStroke(c),e.setStrokeWidth(UC),e.setDashArray(null),e.setFill(l),e.beginPath(),e.ellipse(t.x,t.y,s,s),e.fill(),e.stroke()},cA=(e,t,n)=>{let o=PC;e.setStroke(n.selectionStroke),e.setStrokeWidth(2),e.setDashArray(null),e.setFill(n.handleFill),e.beginPath(),e.ellipse(t.x,t.y,o,o),e.fill(),e.stroke()},kN=(e,t,n)=>{let o=BC;e.setOpacity(.55),e.setStroke(n.selectionStroke),e.setStrokeWidth(1.5),e.setDashArray(null),e.setFill(n.handleFill),e.beginPath(),e.ellipse(t.x,t.y,o,o),e.fill(),e.stroke(),e.setOpacity(1)},wN=(e,t,n)=>{let o=oT;e.setStroke(n),e.setStrokeWidth(tT),e.setDashArray(nT),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},_N=(e,t,n,o)=>{let a=eT;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",Vb),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+qb,i=t.y+qb,l=r+2*Wb,c=Vb+2*jb;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+Wb,i+jb)},CN=(e,t,n,o)=>{let a=yT,r=n.resolved?bT:gT,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":xT),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",AT),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var ac=(e,t)=>{let n=t.getBoundingClientRect();return{kind:IN(e.pointerType),phase:EN(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:TN(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var Ia=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},TN=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),IN=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",EN=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 uA=()=>typeof navigator<"u"?navigator.userAgent:"",Hf=()=>typeof navigator<"u"&&navigator.platform||"",Br=/Mac|iPod|iPhone|iPad/.test(Hf()),MN=Hf().startsWith("Win"),kE=/\b(android)\b/i.test(uA()),ON=/iPad|iPhone/i.test(Hf())||typeof navigator<"u"&&/Mac/i.test(Hf())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,RN=/Linux/i.test(Hf())&&!kE,DN=/Firefox/i.test(uA()),PN=/^((?!chrome|android).)*safari/i.test(uA());var BN={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},zN={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},f0=e=>{let t=[];Br?(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=Br?BN:zN,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},Bt=e=>{let t=f0(e);return Br?t.join(""):t.join("+")};var wE={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},_E={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()},dA=[wE,_E];var ft=e=>e.editor.selection.size>0,fA=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var CE={id:"select-all",label:"Select all",category:"selection",hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},TE={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:fA,perform:({editor:e})=>{e.deleteSelected()}},IE={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:ft,perform:({editor:e})=>{e.duplicateSelected()}},NN={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.toggleLockSelection()}},FN={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()}},HN={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.exitContainer()}},pA=[CE,TE,IE,NN,FN,HN];var EE={id:"copy",label:"Copy",category:"clipboard",hotkey:{key:"c",meta:!0},predicate:ft,perform:({editor:e})=>{e.copySelected()}},ME={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:ft,perform:({editor:e})=>{e.cutSelected()}},OE={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},UN={id:"copy-style",label:"Copy style",category:"clipboard",hotkey:{key:"c",meta:!0,alt:!0},predicate:ft,perform:({editor:e})=>{e.copySelectionStyle()}},GN={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()}},hA=[EE,ME,OE,UN,GN];var RE={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.bringToFront()}},DE={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.sendToBack()}},qN={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:ft,perform:({editor:e})=>{e.bringForward()}},WN={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:ft,perform:({editor:e})=>{e.sendBackward()}},mA=[RE,qN,WN,DE];var PE={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},BE={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()}},yA=[PE,BE];var zE={id:"zoom-in",label:"Zoom in",category:"zoom",hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},NE={id:"zoom-out",label:"Zoom out",category:"zoom",hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},FE={id:"zoom-reset",label:"Reset zoom",category:"zoom",hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},HE={id:"zoom-to-fit",label:"Fit to screen",category:"zoom",hotkey:[{key:"1",alt:!0},{key:"1",meta:!0}],perform:({editor:e})=>{e.zoomToFit()}},jN={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",hotkey:{key:"2",alt:!0},predicate:ft,perform:({editor:e})=>{e.zoomToSelection()}},gA=[zE,NE,FE,HE,jN];var UE={id:"mode-select",label:"Select tool",category:"mode",hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.mode==="select",perform:({editor:e})=>{e.setMode("select")}},GE={id:"mode-hand",label:"Hand tool",category:"mode",hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.mode==="hand",perform:({editor:e})=>{e.setMode("hand")}},qE={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")}},WE={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")}},jE={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")}},VE={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")}},ZE={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")}},XE={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")}},YE={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)}},KE={id:"cancel",label:"Cancel / clear selection",category:"edit",hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},xA=[UE,GE,qE,WE,jE,VE,ZE,XE,YE,KE];var VN={id:"nudge-selection",label:"Nudge selection",category:"selection",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?DT:RT;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}}},ZN={id:"select-closest",label:"Select closest in direction",category:"selection",keyTest:e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&!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.selectClosest("left");return;case"ArrowRight":e.selectClosest("right");return;case"ArrowUp":e.selectClosest("up");return;case"ArrowDown":e.selectClosest("down");return}}},XN={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},YN={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},KN={id:"edit-or-create",label:"Edit / create",category:"edit",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()}},$E=[VN,ZN,XN,YN,KN];var $N={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},QN={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},JN={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},eF={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?An(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},tF={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},QE=[$N,QN,JN,eF,tF];var nF={id:"toggle-grid",label:"Toggle grid",category:"other",hotkey:{key:"g"},uiKind:"toggle",checked:({editor:e})=>e.gridEnabled,perform:({editor:e})=>{e.toggleGrid()}},JE=[nF];var rc=e=>e.editor.selection.size>=2,e4=e=>e.editor.selection.size>=3,oF={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:ft,perform:({editor:e})=>{e.flipSelection("horizontal")}},aF={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:ft,perform:({editor:e})=>{e.flipSelection("vertical")}},rF={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",alt:!0},iconId:"align-left",predicate:rc,perform:({editor:e})=>{e.alignSelection("left")}},sF={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:rc,perform:({editor:e})=>{e.alignSelection("h-center")}},iF={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",alt:!0},iconId:"align-right",predicate:rc,perform:({editor:e})=>{e.alignSelection("right")}},lF={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",alt:!0},iconId:"align-top",predicate:rc,perform:({editor:e})=>{e.alignSelection("top")}},cF={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:rc,perform:({editor:e})=>{e.alignSelection("v-center")}},uF={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",alt:!0},iconId:"align-bottom",predicate:rc,perform:({editor:e})=>{e.alignSelection("bottom")}},dF={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:e4,perform:({editor:e})=>{e.distributeSelection("horizontal")}},fF={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:e4,perform:({editor:e})=>{e.distributeSelection("vertical")}},t4=[oF,aF,rF,sF,iF,lF,cF,uF,dF,fF];var n4=e=>{let{editor:t}=e;for(let n of t.selection){let o=M(t.scene,n);if(o!==void 0&&Fe(o))return!0}return!1},pF={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:n4,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},hF={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:n4,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},o4=[pF,hF];var Uf=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||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)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(mF(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<=OT),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)continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>a4(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},mF=(e,t)=>{if(t.key!==void 0&&!yF(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=Br?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)},yF=(e,t)=>a4(e.key,e.code,t),a4=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(gF(e))return!1;let o=xF(n);return o!==null&&t===o},gF=e=>/^[a-z]$/i.test(e),xF=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}},bA=e=>{let t=[...dA,...pA,...hA,...mA,...yA,...gA,...xA,...$E,...QE,...JE,...t4,...o4];for(let n of t)e.register(n)},st=new Uf;bA(st);var p0=(e,t={})=>{let n=t.target??window,o=t.registry??st,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(Ia(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 bF=new Map;var r4=e=>bF.get(e);var AA=()=>{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 vA=()=>{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 s4=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=L(l[p]),m;if(h.kind==="element"){let b=L(t.get(h.id));m={kind:"element",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="link"){let b=L(n.get(h.id));m={kind:"link",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="layer"){let b=L(o.get(h.id));m={kind:"layer",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="annotation"){let b=L(a.get(h.id));m={kind:"annotation",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="file"){let b=L(r.get(h.id));m={kind:"file",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(p===c&&d!==null)m={kind:"viewport",before:d.first.before,after:d.latest.after};else continue;AF(m)||f.push(m)}return f},AF=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 Gf=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Cr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),zl(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");Cr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?s4(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Mo(n);Cr(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 qf=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}},i4=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var LA=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},SA=e=>{if(e.type&&i4.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 kA=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 vF=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),wA=async function*(e,t={}){let n=t.skipDirectory??vF,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*l4(i,"",0,n,o,t.onError))}};async function*l4(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*l4(c,s,n+1,o,a,r)}}var LF=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}),u4={id:"image",accept:e=>SA(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 kA(e),s=await LF(r),i=e2,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=d4();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 b=p;b.complete||await new Promise(y=>{b.onload=()=>{y()},b.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}:{}})}},c4="oh-just-another-animated-image-sink",d4=()=>{let e=document.getElementById(c4);if(e)return e;let t=document.createElement("div");return t.id=c4,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},f4={id:"video",accept:e=>LA(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=d4();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=e2,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 h0=64,p4=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<h0;){let r=M(e,o.parentId);if(!r)break;Oe(r)&&(n=r),o=r,a++}return n},_A=(e,t,n)=>{let o=M(e,t),a=0;for(;o&&a<h0;){if(o.id===n)return!0;if(!o.parentId)return!1;o=M(e,o.parentId),a++}return!1},h4=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<h0&&n!==o.parentId;){let r=M(e,o.parentId);if(!r||!Oe(r))break;o=r,a++}return o},m4=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||_A(e,r.id,n)||o.add(r.id);return o},y4=(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<h0;){let i=M(e,a.parentId);if(!i||i.id===n.id)break;Oe(i)&&(r=i),a=i,s++}return r};var SF=/^Frame (\d+)$/,g4=e=>{let t=0;for(let n of e.elements.values()){if(!He(n))continue;let o=SF.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},x4=(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||He(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=le(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},b4=(e,t)=>{let n=[...e.elements.values()].filter(He).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(He(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=le(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 m0=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>Jb&&n.add(o.layerId);for(let o of t.links.values())o.order.length>Jb&&n.add(o.layerId);for(let o of n)this.compact(o)}};var y0=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(!An(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=df(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=M(n,t),a=[...n.elements.values()].filter(s=>s.parentId===t);if(o&&An(o)?.kind==="wrap"){let s=Un(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 A4=()=>({mode:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),v4=(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")},L4=(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 g0=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 x0=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 g0({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(wT,Math.max(kT,this.costEma*_T));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 b0=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()},PT))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var A0=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 Wf(){return typeof performance<"u"?performance.now():Date.now()}function kF(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var v0=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Wf();this.state.set(t,{playing:!kF(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Wf();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Wf(),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=Wf();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=Wf();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>TT&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var S4=(e,t,n,o)=>{let a=we(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}:{}}},k4=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=M1(`file-${o()}-${Date.now().toString(36)}`),s=kb(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}},L0=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var w4=e=>{if(!L0(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&&X.intersects(z(n),t))return!0;return!1},_4=e=>{let t=[];for(let n of e._scene.elements.values()){if(!Ut(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>CT&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},CA=e=>{for(let t of e._scene.elements.values()){if(!Ut(t)||!t.animationKind||(e.gifPlayback.ensure(t.id),!t.fileId)||t.animationData instanceof ArrayBuffer)continue;let n=Ab(e._scene,t.fileId);n&&(e._scene=J(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}};var C4={x:-1e9,y:-1e9,width:0,height:0},_F=4,T4=(e,t)=>{let n=new Map;if(e===t)return{world:C4,tileDirty:n};let o=null,a=u=>{o=o?X.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=af(d),h=f?af(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=af(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=Dr(t,d);p&&a(p);let m=Dr(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=Dr(e,d);f&&a(f)}if(o===null)return{world:C4,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(!X.intersects(d,l))continue;i.add(u.id);let f=X.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:X.expand(l,_F),tileDirty:n}};var S0=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})},lT)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&Ae.distance(this.origin,t)>n&&this.cancel()}};var k0=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=Ae.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:Ae.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=Ae.distance(n,o),r=Ae.midpoint(n,o);if(Ae.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<iT)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 CF=(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},TF=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=z(o);n=n?X.union(n,a):a}return n},I4=(e,t,n,o)=>{if(!Yd(t)||!ei(t))return n;if(An(t)?.kind==="wrap")return IF(e,t,n,o);let a=TF(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=Un(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,b=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 x=d-m;i-=x,c+=x}if(o.includes("n")&&f>b){let x=f-b;l-=x,u+=x}return{x:i,y:l,width:c,height:u}},IF=(e,t,n,o)=>{let a=Ns(t)?.padding??0,r=Math.max(0,n.width-2*a),s=Mm(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:Mm(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}},E4=(e,t)=>{let n=e.dragElementId;if(!n)return;let o=M(e.scene,n);if(!o)return;let a=e.containerHover;if(a&&a.id!==o.parentId){let r=we([...e.scene.elements.values()].filter(i=>i.layerId===o.layerId&&i.id!==n).map(i=>i.order)),s=le(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),jf(e,a.id,n);return}if(a&&a.id===o.parentId){jf(e,o.parentId,n);return}if(o.parentId){let r=M(e.scene,o.parentId);if(r!==void 0&&Oe(r))return;let s=r?Un(r):null,i=z(o),l=s?CF(i,s):0;if(s&&l>=vT){jf(e,o.parentId,n);return}let c=le(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},jf=(e,t,n)=>{let o=M(e.scene,t),a=M(e.scene,n);if(!o||!a)return;let r=Ns(o);if(!r)return;let s=z(a),i=Q1(o,s);if(!i)return;if(ei(o)){let c=J1({width:o.width,height:o.height,spec:r},i),u=le(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=le(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var Vf=(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}},TA=(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}},IA=(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}},M4=e=>e==="nw"||e==="w"||e==="sw",O4=e=>e==="ne"||e==="e"||e==="se",R4=e=>e==="nw"||e==="n"||e==="ne",D4=e=>e==="sw"||e==="s"||e==="se",EA=(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,b,y)=>{let g=m;return b!==void 0&&g<b&&(g=b),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),b=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-b/2,width:m,height:b}}let f=t.x;M4(n)&&!O4(n)?f=e.x+e.width-u:O4(n)&&!M4(n)&&(f=e.x);let p=t.y;R4(n)&&!D4(n)?p=e.y+e.height-d:D4(n)&&!R4(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:X.normalize(h)};var P4=(e,t)=>e.kind!=="point"&&t.has(e.elementId),EF=(e,t)=>P4(e.from,t)&&P4(e.to,t),N4=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,B4=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),MF=(e,t)=>{if(!N4(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=B4(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=B4(e.routedPoints,t)),n},z4=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,MA=(e,t)=>{let n=MF(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=z4(e.from,t)),a&&(r.to=z4(e.to,t)),r},F4=(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(!N4(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},H4=(e,t,n)=>n.has(e.id)||EF(e,t),OA=(e,t,n)=>{let o=new Map;for(let a of e.links.values())H4(a,t,n)&&MA(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},U4=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=be(e,a);if(!s)continue;let i=MA(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},G4=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!H4(s,t,n))continue;let i=MA(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 q4=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=M(e,t);if(!l||!ei(l))return null;let c=Vf(a,n,o),u=s?IA(a,c):c,d=i?TA(a,u):u,p=l.noFlip===!0||An(l)!==null?{...l,noFlip:!0}:l,h=EA(a,d,n,p,i),m=r(l,h,n),b={...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:b};return{scene:J(e,y),patch:y}},W4=(e,t,n,o,a=!1,r=!1)=>{let s=M(e,t.id);if(!s||!ei(t))return null;let i=qs(t),[l]=xf(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=Vf(h,n,p),b=a?IA(h,m):m,y=r?TA(h,b):b,x=t.noFlip===!0||An(t)!==null?{...t,noFlip:!0}:t,A=EA(h,y,n,x,r),C={x:l.x+A.x*d.x+A.y*f.x,y:l.y+A.x*d.y+A.y*f.y},_={...t,position:C,scale:{x:1,y:1},width:A.width,height:A.height},v={kind:"element",id:t.id,before:s,after:_};return{scene:J(e,v),patch:v}},j4=(e,t,n,o,a,r=!1)=>{let s=M(e,t.id);if(!s)return null;let i=Vf(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let I=Math.max(t.fontSize,Math.abs(i.width)),k=n==="w"?a.x+a.width:a.x,T=r?l-I/2:n==="w"?k-I:k,P={...t,position:{x:T,y:a.y},scale:{x:1,y:1},maxWidth:I},N={kind:"element",id:t.id,before:s,after:P};return{scene:J(e,N),patch:N}}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(Hm,t.fontSize*p),m=h/t.fontSize,b=a.width*m,y=a.height*m,g=n.includes("w")?a.x+a.width:a.x,x=n.includes("n")?a.y+a.height:a.y,A=r?l-b/2:n.includes("w")?g-b:g,C=r?c-y/2:n.includes("n")?x-y:x,_={...t,position:{x:A,y:C},scale:{x:1,y:1},fontSize:h,...t.maxWidth!==void 0?{maxWidth:t.maxWidth*m}:{}},v={kind:"element",id:t.id,before:s,after:_};return{scene:J(e,v),patch:v}},V4=(e,t,n,o,a,r,s=!1)=>{let i=Vf(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 b=Math.max(Math.abs(c),Math.abs(u));c=b*(c>=0?1:-1),u=b*(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[b,y]of t.elements){let g=M(h,b);if(!g)continue;let x=f+(y.position.x-f)*c,A=p+(y.position.y-p)*u;if(ei(g)){let k=g.type==="image",T=k?d:c,P=k?d:u,N=y.bounds.width*T,U=y.bounds.height*P;if(Math.abs(N)<l||Math.abs(U)<l)continue;let q={...g,position:{x,y:A},scale:{x:N>=0?1:-1,y:U>=0?1:-1},width:Math.abs(N),height:Math.abs(U)},te={kind:"element",id:b,before:g,after:q};h=J(h,te),m.push(te);continue}let C=y.scale.x*c,_=y.scale.y*u;if(Math.abs(C)<l/Math.max(1,y.bounds.width)||Math.abs(_)<l/Math.max(1,y.bounds.height))continue;let v={...g,position:{x,y:A},scale:{x:C,y:_}},I={kind:"element",id:b,before:g,after:v};h=J(h,I),m.push(I)}for(let[b,y]of t.links??[]){let g=be(h,b);if(!g)continue;let x=F4(y,f,p,c,u);if(!x)continue;let A={kind:"link",id:b,before:g,after:{...g,...x}};h=J(h,A),m.push(A)}return{scene:h,patches:m}};var kt=Object.freeze(new Set),RA=e=>new Set([e]),DA=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},OF=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},Z4=(e,t)=>e.has(t)?OF(e,t):DA(e,t),w0=(e,t)=>dm(e,t),X4=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var _0=e=>Math.min(sT,Math.max(rT,e)),Y4=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:mb(e.viewport,t)},K4=(e,t,n)=>{let o=e.viewport.zoom,r=_0(o*t)/o;return r===1?null:{...e,viewport:wm(e.viewport,r,n)}},$4=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:wm(t,1/t.zoom,n)}},BA=(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=_0(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}}},Q4=(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?X.union(n,a):a}return n?BA(e,n,t):null},J4=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:yb(o,t,n)}},e5=(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 RF=(e,t)=>{let n=[];for(let o=e;o<=t;o++)n.push(o);return n},t5=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!Ia(c.target)&&e.host.focus({preventScroll:!0});let u=ac(c,e.host);e.additivePressAdded=null;let d=c.button===2||c.button===1,f=c.button===0&&e.spaceHeld,p=c.button===0&&e.mode==="hand";if(d||f||p){d&&(e.suppressNextContextMenu=!0),e.beginPanGesture(c.pointerId,c.button,u.point);return}if(e.activePointers.set(c.pointerId,u.point),e.activePointers.size===2){e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture(),e.cancelLongPress(),e.panGesture=null,e.touchPanCandidate=null,e.beginPinch();return}if(e.activePointers.size>2)return;e.startLongPress(u.point);let h=e.screenToWorld(u.point);if(e.editingTextElement!==null){if(e.editedElementContainsPoint(h)){e.cancelLongPress(),e.setTextCaretFromPoint(h);return}e.commitTextEdit()}if(e.mode==="brush"){e.beginBrushStroke(h,c.pressure);return}if(e.mode==="draw-text"){e.cancelLongPress();let _=e.hitTest(h),v=_.kind==="element"?M(e._scene,_.id):void 0;v!==void 0&&Fe(v)?(e._selection=Mt(v.id),e.beginTextEdit(v.id),e.notify()):e.createTextAt(h);return}let m=e.hitAnnotation(h);if(m){let _=e._scene.annotations.get(m);if(_){e.annotationDrag={id:m,originPosition:{..._.position},originWorldPoint:h,moved:!1},e.setSelectedAnnotation(m);return}}let b=e.acceleratedElementAt(h);if(b){let _=r4(b.type);if(_){let v={x:h.x-b.position.x,y:h.y-b.position.y},I=_(b,v);if(I){e.applyEmit(I);return}}}let y=e.selectedLink;if(e.mode==="select"&&y){let _=be(e._scene,y);if(_&&(_.routing??"straight")==="orthogonal"){let v=rt(e._scene,_);if(v&&v.length>=2){let I=e._scene.viewport.zoom||1,k=Oo/I,T=k*k,P=v.length===2?[0]:RF(1,v.length-3);for(let N of P){let U=L(v[N]),q=L(v[N+1]),te=(U.x+q.x)/2,Z=(U.y+q.y)/2,ue=te-h.x,$=Z-h.y;if(ue*ue+$*$<=T){let re=Math.abs(U.y-q.y)<1e-6?"h":"v",We=re==="h"?(U.x+q.x)/2:(U.y+q.y)/2,Re=re==="h"?U.y:U.x;e.isHandleDoubleClick(h)?e.resetSegmentPin(y,re,Re,We):e.beginSegmentDrag(y,re,We),e.cancelLongPress();return}}}}}let g=e.selectedLink;if(e.mode==="select"&&g){let _=be(e._scene,g),v=_&&(_.routing??"straight")!=="orthogonal"?rt(e._scene,_):null;if(_&&v&&v.length>=2){let I=e._scene.viewport.zoom||1,k=Oo/I,T=k*k,P=[..._.waypoints??[]],N=q=>{let te=q.x-h.x,Z=q.y-h.y;return te*te+Z*Z<=T},U=!1;for(let q=0;q<P.length;q++)if(N(L(P[q]))){e.isHandleDoubleClick(h)?e.deleteWaypoint(g,q):e.beginWaypointDrag(g,q,!1),U=!0;break}if(!U){let q=of(e._scene,_)??[];for(let te=0;te<q.length;te++)if(N(L(q[te]))){e.beginWaypointDrag(g,te,!0),U=!0;break}}if(U){e.cancelLongPress();return}}}let x=e.hitTest(h);if(e.mode==="select"&&!u.modifiers.shift&&!u.modifiers.meta&&!u.modifiers.ctrl&&x.kind!=="rotate-handle"){let _=I=>{let k=M(e._scene,I);if(!k)return!1;let T=e._scene.viewport.zoom||1,{names:P,worldPoints:N}=ho(k,fo/T),U=(Ro+e.anchorStartHitSlop)/T,q=null,te=U*U;for(let Z=0;Z<N.length;Z++){let ue=L(N[Z]),$=ue.x-h.x,re=ue.y-h.y,We=$*$+re*re;We<=te&&(te=We,q=L(P[Z]))}return q===null?!1:(e.cancelLongPress(),e.linkDragFromAnchor={fromElement:I,fromWorld:Gt(k,{kind:"named",name:q}),anchorName:q,origin:h,moved:!1},!0)},v=e._selection.size===1?[...e._selection][0]:null;if(v&&_(v))return}if(!((u.modifiers.meta||u.modifiers.ctrl)&&x.kind==="element"&&e.elementLink(x.id)!==null)&&x.kind==="element"&&!e._selection.has(x.id)){let _=u.modifiers.shift||u.modifiers.meta||u.modifiers.ctrl;e._selection=_?xn(e._selection,x.id):Mt(x.id),_&&(e.additivePressAdded=x.id),!_&&e._selectedLinks.size>0&&(e._selectedLinks=kt),e.notify()}if(u.modifiers.alt&&e.mode==="select"&&x.kind==="element"&&e._selection.has(x.id)){let _=e.duplicateSelectedInPlace(x.id);_!==null&&(x={kind:"element",id:_,bounds:x.bounds})}if(e.dragElementId=x.kind==="element"?x.id:null,e.containerHover=null,x.kind==="element"){let _=M(e._scene,x.id),v=_!==void 0&&Oe(_),I=_!==void 0&&He(_),k=e._selection.has(x.id);if(k||v||I){let T=new Set;if(k)for(let N of e.expandSelectionWithDescendants()){let U=M(e._scene,N);U&&e.isElementManipulable(U)&&T.add(N)}if(v){let N=U=>{if(!T.has(U)){T.add(U);for(let q of e._scene.elements.values())q.parentId===U&&N(q.id)}};N(x.id)}if(I){T.add(x.id);for(let N of e._scene.elements.values())N.frameId===x.id&&T.add(N.id)}let P=OA(e._scene,T,e._selectedLinks);if(T.size>1||P.size>0){let N=new Map;for(let U of T){let q=M(e._scene,U);q&&N.set(U,q.position)}e.groupMoveOrigin=N,e.groupLinkMoveOrigin=P.size>0?P:null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null;if(x.kind==="group-handle"){let _=new Map;for(let I of e.expandSelectionWithDescendants()){let k=M(e._scene,I);k&&_.set(I,{position:k.position,bounds:z(k),scale:k.scale})}let v=OA(e._scene,new Set(_.keys()),e._selectedLinks);e.groupResizeOrigin={combined:x.bounds,elements:_,links:v}}else e.groupResizeOrigin=null;if(x.kind==="rotate-handle"){let _=new Map;for(let v of e.expandSelectionWithDescendants()){let I=M(e._scene,v);I&&_.set(v,{position:I.position,rotation:I.rotation})}e.rotateGestureOrigin={pivot:x.pivot,origin:_}}else e.rotateGestureOrigin=null;e.touchPanCandidate=u.kind==="touch"&&e.mode==="select"&&x.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:h,target:x,modifiers:u.modifiers})},n=c=>{let u=ac(c,e.host);if(e.panGesture?.pointerId===c.pointerId){let p=u.point.x-e.panGesture.lastPoint.x,h=u.point.y-e.panGesture.lastPoint.y;e.panGesture.lastPoint=u.point,!e.panGesture.moved&&Ae.distance(e.panGesture.startPoint,u.point)>Fl&&(e.panGesture.moved=!0),e.panBy({x:p,y:h});return}if(e.activePointers.has(c.pointerId)&&e.activePointers.set(c.pointerId,u.point),e.pinch.isActive()){e.applyPinch();return}if(e.touchPanCandidate!==null&&e.activePointers.size===1&&Ae.distance(e.touchPanCandidate,u.point)>Fl){let p=e.touchPanCandidate;e.touchPanCandidate=null,e.beginPanGesture(c.pointerId,c.button,p);let h=e.panGesture;h&&(h.moved=!0,e.panBy({x:u.point.x-p.x,y:u.point.y-p.y}),h.lastPoint=u.point);return}e.longPress.cancelIfMovedBeyond(u.point,Fl);let d=e.screenToWorld(u.point);if(e.lastPointerWorld=d,e.refreshCursor(d),e.isDraggingSegment){e.updateSegmentDrag(d);return}if(e.isDraggingWaypoint){e.updateWaypointDrag(d);return}if(e.linkDragFromAnchor){let p=e.linkDragFromAnchor;if(!p.moved){let h=d.x-p.origin.x,m=d.y-p.origin.y;if(h*h+m*m<Ys*Ys)return;p.moved=!0}e.applyLinkPreview(p.fromElement,p.fromWorld,d),e.updateHoveredLinkTarget(d);return}if(e.editingTextElement!==null&&e.isTextDragging){e.extendTextSelectionToPoint(d);return}if(e.brushStroke){e.extendBrushStroke(d,c.pressure);return}if(e.dragElementId){let p=e.dragElementId,h=new Set([p]);for(let b of e._scene.elements.values()){let y=b.parentId;for(let g=0;y&&g<64;g++){if(y===p){h.add(b.id);break}y=e._scene.elements.get(y)?.parentId}}let m=Kd(e._scene,d,h);if(m){let b=Un(m);if(b){let y={id:m.id,dropZone:b};(e.containerHover?.id!==y.id||e.containerHover.dropZone!==y.dropZone)&&(e.containerHover=y,e.notify())}}else e.containerHover!==null&&(e.containerHover=null,e.notify())}if(e.annotationDrag){let p=e.annotationDrag,h=d.x-p.originWorldPoint.x,m=d.y-p.originWorldPoint.y;(h!==0||m!==0)&&(p.moved=!0);let b=e._scene.annotations.get(p.id);if(b){let y={x:p.originPosition.x+h,y:p.originPosition.y+m},g={...b,position:y},x=new Map(e._scene.annotations);x.set(p.id,g),e._scene={...e._scene,annotations:x},e.notify()}return}for(let p of e.cursorListeners)p(d);let f=e.actor.getSnapshot().context;if(f.pressOrigin&&f.mode!=="select"&&f.mode!=="draw-edge"&&e.isDrawingPhase(f)&&(e.drawingPreview=Tf(f.pressOrigin,d)),f.mode==="draw-edge"?e.updateHoveredLinkTarget(d):e.hoveredLinkTarget!==null&&(e.hoveredLinkTarget=null,e.notify()),!f.pressOrigin){let p=e.hitTest(d),h=p.kind==="element"?e._scene.elements.get(p.id):void 0;e.hoverAnimatedElement(h&&Ut(h)&&h.animationKind?h.id:null),e.setHoverCursorWorld(e.mode==="select"?d:null)}e.actor.send({type:"POINTER_MOVE",point:d})},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),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.isDraggingSegment){e.endSegmentDrag();return}if(e.isDraggingWaypoint){e.endWaypointDrag();return}if(e.linkDragFromAnchor){let y=e.linkDragFromAnchor;e.linkDragFromAnchor=null;let g=ac(c,e.host),x=e.screenToWorld(g.point);if(y.moved){let A=e.hitTest(x),C=A.kind==="element"?A.id:null;e.applyEmit({type:"CREATE_EDGE",fromElement:y.fromElement,toElement:C,fromPoint:y.fromWorld,toPoint:x})}else{let A=M(e._scene,y.fromElement),C=e._scene.viewport.zoom||1,_=!1;if(A){let{names:v,worldPoints:I}=ho(A,fo/C),k=v.indexOf(y.anchorName);if(k>=0){let T=L(I[k]),P=e.anchorClickRadius/C,N=T.x-y.origin.x,U=T.y-y.origin.y;_=N*N+U*U<=P*P}}if(_)e.createLinkedElementFromAnchor(y.fromElement,y.anchorName);else{let v=e.hitTest(x);v.kind==="empty"?e.applyEmit({type:"SELECT_CLEAR"}):v.kind==="element"?e.applyEmit({type:"SELECT_REPLACE",id:v.id}):v.kind==="link"&&e.applyEmit({type:"SELECT_EDGE_REPLACE",id:v.id})}}e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.editingTextElement!==null&&e.isTextDragging){e.endTextDragSelect();return}if(e.brushStroke){e.commitBrushStroke();return}if(e.annotationDrag){let y=e.annotationDrag;if(e.annotationDrag=null,y.moved){let g=e._scene.annotations.get(y.id);if(g){let x={...g,position:y.originPosition},A=new Map(e._scene.annotations);A.set(y.id,x),e._scene={...e._scene,annotations:A};let C=wa(e._scene,y.id,()=>g);e._scene=C.scene,e._history.push(C.patch),e.notify()}}return}let u=ac(c,e.host),d=e.screenToWorld(u.point);{let y=e.actor.getSnapshot().context.pressOrigin,g=u.modifiers.meta||u.modifiers.ctrl;if(y&&g){let x=e._scene.viewport.zoom||1;if(Math.hypot(d.x-y.x,d.y-y.y)*x<Fl){let C=e.hitTest(d);if(C.kind==="element"){let _=e.elementLink(C.id);if(_){e.openLink(_),e.actor.send({type:"POINTER_UP",point:d}),e.commitGesture();return}}}}}let f=e.actor.getSnapshot().context,p=DI(f,d);p?.type==="SELECT_TOGGLE"&&e.additivePressAdded===p.id&&(p=null),e.additivePressAdded=null,!e.routeIsolationClick(p,d)&&p&&e.applyEmit(p),e.drawingPreview=null;let m;f.mode==="draw-edge"?m=e.hitTest(d):f.pressTarget?.kind==="edge-endpoint"&&(m=e.linkAttachTargetAt(d)),e.actor.send(m!==void 0?{type:"POINTER_UP",point:d,target:m}:{type:"POINTER_UP",point:d}),e.applyContainerDrop(d),e.reconcileFrameMembership(),e.commitGesture();let b=f.pressOrigin;if(b){let y=e._scene.viewport.zoom||1;if(Math.hypot(d.x-b.x,d.y-b.y)*y<Fl){let x=e.hitTest(d);if(x.kind==="element"){let A=e._scene.elements.get(x.id);A&&Ut(A)&&A.animationKind&&e.togglePlayback(A.id)}}}e.refreshCursor(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.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!==" "||Ia(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},f=()=>{if(c.deltaY===0)return;let m=1-(Math.abs(c.deltaY)>Yb?Yb*Math.sign(c.deltaY):c.deltaY)*aT/100;if(m<=0)return;let b=e._scene.viewport.zoom,y=_0(b*m);if(y===b)return;let g=e.screenToWorld(d);e.zoomAt(y/b,g)},p=()=>{let h=c.deltaX,m=c.deltaY;c.shiftKey&&h===0&&(h=m,m=0),e.panBy({x:-h*Zb,y:-m*Zb})};if(c.ctrlKey||c.metaKey){f();return}if(c.deltaX!==0){p();return}f()};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 n5=e=>e<=0?ST:Math.max(.5,e*LT),o5=(e,t)=>({points:[{x:0,y:0,width:n5(t)}],origin:e}),a5=(e,t,n)=>{let o=e.origin;e.points.push({x:t.x-o.x,y:t.y-o.y,width:n5(n)})},r5=(e,t,n,o)=>{if(!t||t.points.length===0)return null;let a=we([...e.elements.values()].filter(i=>i.layerId===n).map(i=>i.order)),r={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:a,style:{fill:"#222"},points:t.points.slice()},s=Je(e,r);return{scene:s.scene,patch:s.patch,elementId:o}},s5=e=>Qe(`brush-${e}-${Date.now().toString(36)}`);var i5=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},l5=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(i5(a))}return n},c5=(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=we([...u.elements.values()].filter(y=>y.layerId===f.layerId).map(y=>y.order)),m={...i5(f),id:p,position:{x:f.position.x+i.x,y:f.position.y+i.y},order:h},b=Je(u,m);u=b.scene,l.push(b.patch),c.push(p)}let d=l[0];return d!==void 0&&t.push(l.length===1?d:Mo(l)),{scene:u,newIds:c}};var u5=(e,t)=>l5(e,t),d5=(e,t,n,o,a)=>{let r=c5(e,t,n,o,()=>Qe(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},f5=e=>{let t=Ne;for(let n of e)t=xn(t,n);return t};var p5=(e,t,n)=>{let o=we([...e.layers.values()].map(s=>s.order)),r=_b(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},h5=(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=jn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=lf(a,i.id);a=l.scene,o.push(l.patch)}let r=Cb(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Vd)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},m5=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=cf(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},y5=(e,t)=>{if(!e.layers.has(t))return null;let n=cf(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},g5=(e,t)=>{if(!e.layers.has(t))return null;let n=cf(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},x5=(e,t,n)=>{if(!e.layers.has(n)||t.size===0)return null;let o=e,a=[];for(let r of t){let s=M(o,r);if(!s||s.layerId===n)continue;let i=le(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},b5=e=>$t(`layer-${e}-${Date.now().toString(36)}`);var A5=(e,t,n,o)=>{let a=new Date().toISOString(),r=Hd(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:Tl(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=Tb(e,i);return{scene:l.scene,patch:l.patch,id:r}},v5=(e,t)=>{if(!e.annotations.has(t))return null;let n=Ib(e,t);return{scene:n.scene,patch:n.patch}},L5=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=wa(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},S5=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:Tl(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=wa(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},k5=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=wa(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},w5=(e,t)=>{let n=e.viewport.zoom,o=Nm/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=Tr(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 _5=(e,t,n)=>{let o=M(e,t);return!(o===void 0||!Fe(o)||n(o.layerId))};var C5=(e,t)=>{let n=null,o="";for(let a of e.elements.values()){if(!He(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},T5=(e,t,n)=>{let o=M(e,t);if(o===void 0||!He(o))return null;let a=n.trim(),r=o.name??"";if(a===r)return null;let s=le(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var DF={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},PF=(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}`},BF=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:PF(o,n)},zF=(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=M(e._scene,n);if(!o)return!1;let a=e._scene.viewport.zoom||1,{worldPoints:r}=ho(o,fo/a),s=(Ro+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},I5=(e,t)=>{let n=(a,r)=>BF(e,a,r),o=a=>n(DF[a],ZT(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.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":return n("draw","crosshair");case"draw-text":return n("text","text");default:break}if(t){if(zF(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 C0=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},M5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=we([...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=le(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},O5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=Bl([...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=le(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},R5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(vt),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?Cm(s.order,i.order):we(r.map(u=>u.order));if(l===a.order)return null;let c=le(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},D5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Vd),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?Cm(i.order,s.order):Bl(r.map(u=>u.order));if(l===a.order)return null;let c=le(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},E5=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(vt),o=vb(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},P5=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=E5([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=le(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=E5([...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 B5=(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=Im(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,cols:r}:null},z5=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=Em(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,direction:r}:null},zA=(e,t)=>{let n=[],o=new Set;for(let a of t){let r=M(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=M(e,s.parentId)}i||o.has(r.id)||(o.add(r.id),n.push(r))}return n},N5=(e,t)=>{let n=new Set,o=a=>{if(!(n.has(a)||!M(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},F5=(e,t,n)=>{let o=zA(e,t),a=o[0];if(o.length<2||a===void 0)return null;let r=a.layerId,s=we([...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=Je(l,i);l=u.scene,c.push(u.patch);for(let d of o){let f=le(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},H5=(e,t)=>{let n=[...t].map(s=>M(e,s)).filter(s=>s!==void 0&&Oe(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=le(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=jn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},U5=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(vt),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(vt);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=M(e,s);return{id:s,name:i?Mb(i):s}},G5=e=>Qe(`group-${e}-${Date.now().toString(36)}`);var q5=(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=M(a,i);if(!l||o(l.layerId))continue;let c=le(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}},W5=(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=lf(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=jn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},j5=(e,t,n)=>{let o=[...t];if(o.length===0)return null;let a=e,r=[],s=[];for(let i of o){let l=M(a,i);if(!l)continue;let c=Qe(`shape-${n()}-${Date.now().toString(36)}`),u=we([...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=Je(a,d);a=f.scene,r.push(f.patch),s.push(c)}return{scene:a,patches:r,newIds:s}},V5=(e,t,n)=>{let o=Ne;for(let a of t)e.elements.has(a)&&(o=xn(o,a));return Rs(o,n)?null:o},Z5=(e,t)=>{let n=Ne;for(let o of e.elements.values()){let a=e.layers.get(o.layerId);!a||!a.visible||a.locked||(n=xn(n,o.id))}return Rs(n,t)?null:n},X5=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},Y5=(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=le(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}}},K5=(e,t,n)=>{let o=[];for(let i of t){let l=M(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=le(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}}},$5=(e,t,n)=>{let o=n==="increase",a=o?t2:1/t2,r=e,s=[];for(let l of t){let c=M(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(FT,Math.max(Hm,d));if(f===c.fontSize)continue;let p=le(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}}},Q5=(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 ")}`},NA=e=>{let t=Ne;for(let n of e)t=xn(t,n);return t},J5=(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 e9=/^(https?:|mailto:)/i,NF=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,t9=e=>{let t=e.trim();return t===""?null:e9.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:NF.test(t)?`mailto:${t}`:`https://${t}`},T0=e=>e&&e9.test(e.trim())?e.trim():null,n9=(e,t,n)=>{let o=[];for(let i of t){let l=M(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=le(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}}},FF=(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}},o9=(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=M(e,f);if(!p)return null;let h=FF(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&&M(e,o)?{kind:"floating",elementId:o}:{kind:"point",position:a})};var HF=Rr.rectangle,UF=Rr.ellipse,FA=(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"?Bl(s):we(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:{...HF}}:t==="ellipse"?{...l,type:"ellipse",style:{...UF}}:{...l,type:"frame",style:{fill:jC},name:r()}},a9=(e,t,n,o,a)=>{let r=we(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:Rm,style:{...M2},arrowheads:{to:DC}}},r9=(e,t,n,o)=>{let a=a9(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},s9=(e,t,n,o,a,r)=>{let s=FA(e,t,n,o,a,r),i=Je(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Zf=(e,t,n,o,a)=>{let r=a9(e,t,n,o,a),s=wb(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},I0=e=>`shape-${e}-${Date.now().toString(36)}`,HA=e=>`edge-${e}-${Date.now().toString(36)}`;var i9=(e,t,n,o,a)=>{let r=we([...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}},l9=(e,t,n,o)=>{let a=we([...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:ET,fontSize:IT,style:{fill:MT,textAlign:"left",textBaseline:"top"}}},GA=e=>Qe(`shape-${e}-${Date.now().toString(36)}`),c9=(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}},u9=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=Kd(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}},d9=e=>{let t=z(e);return{scene:n=>{let o=Je(n,e);return{scene:o.scene,patch:o.patch}},state:{current:e,halfWidth:t.width/2,halfHeight:t.height/2}}},f9=(e,t)=>({scene:jn(e,t).scene}),UA="__ghost-preview__",sc="__ghost-preview-link__",p9=(e,t,n,o)=>{let a=M(e,n);if(!a)return null;let r={kind:"named",name:o},s=Eo(a,r),i=z(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+Hb,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=Gt(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)},b={...a,id:UA,position:{x:a.position.x+u.x,y:a.position.y+u.y}};Fe(b)?b={...b,text:""}:He(b)&&(b={...b,name:""});let y={x:i.x+i.width/2,y:i.y+i.height/2},g=Je(e,b).scene,x=L(M(g,UA)),{ref:A}=Sa(x,y,uo(x)),_=Zf(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:UA,anchor:A},sc,t).scene,v=L(be(_,sc));if((v.routing??"straight")==="orthogonal"){let I=pf(_,v);_=et(_,sc,k=>({...k,routedPoints:I})).scene}return _={..._,links:new Map([[sc,L(be(_,sc))]])},{bounds:d,path:[f,m],element:b,ghostScene:_,ghostLinkId:sc}},h9=(e,t,n,o,a,r)=>{let s=M(e,n);if(!s)return null;let i={kind:"named",name:o},l=Eo(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+Hb,p={x:l.x*f,y:l.y*f},h=we([...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:""}:He(m)&&(m={...m,name:""});let b=Je(e,m),y=L(M(b.scene,a)),{ref:g}=Sa(y,u,uo(y)),x=Zf(b.scene,{kind:"anchor",elementId:n,anchor:i},{kind:"anchor",elementId:a,anchor:g},r,t);return{scene:x.scene,addPatch:b.patch,linkPatch:x.patch}},m9=(e,t,n)=>{let o=e,a=[];for(let r of t){let s=M(o,r);if(!s)continue;let i=n.get(r);if(i===void 0)continue;let l=we([...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=Je(o,c);o=u.scene,a.push(u.patch)}return{scene:o,patches:a}},y9=(e,t,n,o,a)=>{let r=we([...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=Je(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 GF="__draw-preview__",g9="__draw-preview-link__",x9=e=>{if(e.backgroundTarget){e.gridEnabled?Mf(e._scene,e.backgroundTarget):e.backgroundTarget.clear();let d=[];for(let f of e._selection){let p=M(e._scene,f);if(!p)continue;let h=p.style??{};d.push({loops:Zd(e._scene,p),outsetWorld:F1(h)})}d.length>0&&vE(e.backgroundTarget,qn(e._scene.viewport),d,e._scene.viewport.zoom||1)}let t=e.computeViewportWorld(),n=e.computeDirtyWorld(),o=e._enteredGroup?e.computeDimElements(e._enteredGroup):void 0,a=e.computeHiddenElements();if(e.tileComposeFn&&t)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.tileDirtyElements=new Map,No(e._scene,e.mainTarget,{viewportWorld:t});else{let d=e._scene.elements.size>=Fm?e.ensureSpatialIndex():null;Js(e._scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,lod:O2,...o?{dimElements:o,dimOpacity:cT}:{},...a?{hideElements:a}:{},...d?{spatialIndex:d}:{}}),No(e._scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}e.lastRenderedScene=e._scene,e.lastRenderedEnteredGroup=e._enteredGroup;let r={},s=null;if(e.lassoPreview)r.drawingPreview=e.lassoPreview;else if(e.drawingPreview){let d=e.mode==="draw-rect"?"rect":e.mode==="draw-ellipse"?"ellipse":null;d?r.drawingPreviewElement=FA(e._scene,d,e.drawingPreview,GF,e._activeLayerId,()=>""):r.drawingPreview=e.drawingPreview}let i=null;if(e.edgePreview){let d=r9(e._scene,e.edgePreview,g9,e._activeLayerId);i={...e._scene,links:new Map([[g9,d]])}}if(e.mode!=="brush"&&e.mode!=="hand"){let d=e._scene.viewport.zoom||1,f=(m,b,y,g)=>{let x=M(e._scene,m);if(!x)return null;let A=b==="link-start"?fo:WC,{names:C,worldPoints:_}=ho(x,A/d),v=[..._],I=y!==null?C.indexOf(y):-1;b==="link-attach"&&g&&v.push(g);let k=I>=0?I:b==="link-attach"&&g?v.length-1:-1;return{worldPoints:v,...k>=0?{activeIndex:k}:{},role:b}},p=[];if(e.linkDragFromAnchor){let m=f(e.linkDragFromAnchor.fromElement,"link-start",null);if(m&&p.push(m),e.hoveredLinkTarget){let b=e.hoveredLinkTarget,y=f(b.elementId,"link-attach",b.activeAnchor,b.outlinePoint);y&&p.push(y)}}else if(e.hoveredLinkTarget){let m=e.hoveredLinkTarget,b=f(m.elementId,"link-attach",m.activeAnchor,m.outlinePoint);b&&p.push(b)}else if(!e.panGesture&&!e.pinch?.isActive()&&!e.gestureTx&&!e.edgePreview&&!e.linkEndpointDrag){let m=e.hoverCursorWorld;if(e._selection.size===1&&m){let b=L([...e._selection][0]),y=M(e._scene,b);if(y){let g=z(y),x=(fo+Ro+e.anchorStartHitSlop)/d;if(m.x>=g.x-x&&m.x<=g.x+g.width+x&&m.y>=g.y-x&&m.y<=g.y+g.height+x){let C=f(b,"link-start",null);if(C){let T=VC/d,P=-1,N=T*T;if(C.worldPoints.forEach((U,q)=>{let te=U.x-m.x,Z=U.y-m.y,ue=te*te+Z*Z;ue<=N&&(N=ue,P=q)}),P>=0){let U=T>0?Math.max(0,1-Math.sqrt(N)/T):0,q=hf+(HC-hf)*U;p.push({...C,activeIndex:P,activeRadius:q})}else p.push(C)}let{names:_,worldPoints:v}=ho(y,fo/d),I=(e.anchorClickRadius/d)**2,k=null;for(let T=0;T<v.length;T++){let P=L(v[T]);if((P.x-m.x)**2+(P.y-m.y)**2<=I){k=L(_[T]);break}}if(k){let T=e.previewClickCreate(b,k);T&&(r.ghostElement=T.bounds,r.ghostElementShape=T.element,s=T.ghostScene)}}}}}p.length===1?r.ports=L(p[0]):p.length>1&&(r.ports=p);let h=e.hoveredLinkTarget;if(h?.mode==="element"){let m=M(e._scene,h.elementId);m&&(r.linkAttachHighlight=z(m))}}if(e._selection.size+e._selectedLinks.size>1||e.selectionIsAspectLocked()){let d=e.combinedSelectionBounds();d&&(r.groupBounds=d),e.selectionIsAspectLocked()&&(r.groupAspectLocked=!0)}if(e.containerHover&&(r.containerDropZone=e.containerHover.dropZone),e.brushStroke&&(r.brushPreview={origin:e.brushStroke.origin,points:e.brushStroke.points,fill:"#222"}),e._selectedLinks.size>0){let d=[];for(let f of e._selectedLinks){let p=be(e._scene,f);if(!p)continue;let h=Dl(e._scene,p);h&&h.length>=2&&d.push({path:h,width:p.style.strokeWidth??1})}d.length>0&&(r.selectedLinkPaths=d)}let l=e.selectedLink;if(l){let d=be(e._scene,l);if(d){let f=rt(e._scene,d);if(f&&f.length>=2){let p=L(f[0]),h=L(f[f.length-1]);if((d.routing??"straight")==="orthogonal"){let b=[];if(!e.linkSegmentDrag&&!e.linkEndpointDrag){let y=f.length===2?[0]:Array.from({length:Math.max(0,f.length-3)},(g,x)=>x+1);for(let g of y){let x=L(f[g]),A=L(f[g+1]);b.push({x:(x.x+A.x)/2,y:(x.y+A.y)/2})}}r.edgeSelection={from:p,to:h,midpoints:b}}else{let b=[...d.waypoints??[]],y=e.linkWaypointDrag?[]:of(e._scene,d)??[];r.edgeSelection={from:p,to:h,waypoints:b,midpoints:y}}}}}e._peerCursors.length>0&&(r.peerCursors=e._peerCursors),e._peerSelections.length>0&&(r.peerSelections=e._peerSelections),e._scene.annotations.size>0&&(r.annotations=[...e._scene.annotations.values()],r.selectedAnnotation=e._selectedAnnotation);let c=[];for(let d of e._scene.elements.values())Ut(d)&&d.animationKind&&e.isPlaybackPaused(d.id)&&c.push(z(d));c.length>0&&(r.gifBadges=c);let u=e.editingTextOverlay();if(u&&(r.editingText=u),e.debugHitZones){r.debugHitZones=!0;let d=e.linkDragFromAnchor!==null||e.edgePreview!==null||e.linkEndpointDrag!==null,f=e.groupMoveOrigin!==null&&e.gestureTx!==null,p=d0({linkDragActive:d,elementDragActive:f});if(r.debugHitZoneVisibility=p,p.attachDropZones){let h=e.linkDragFromAnchor?.fromElement,m=[],b=[];for(let y of e._scene.elements.values())if(y.id!==h){m.push(...ho(y,0).worldPoints);for(let g of Zd(e._scene,y))b.push(g)}r.debugAttachZones={anchors:m,outlineLoops:b,thresholdWorld:12}}if(p.containerDropZones){let h=e.groupMoveOrigin,m=[],b=[];for(let y of e._scene.elements.values())if(!h?.has(y.id)){if(He(y)){m.push(z(y));continue}b.push(...$1(y))}r.debugContainerZones={frames:m,containers:b}}}LE(e._scene,e._selection,e.overlayTarget,r),s&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(zm),No(s,e.overlayTarget,{}),e.overlayTarget.restore()),i&&No(i,e.overlayTarget,{})};var b9=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=ka(t),r=[B.applyToPoint(a,{x:0,y:0}),B.applyToPoint(a,{x:n,y:0}),B.applyToPoint(a,{x:0,y:o}),B.applyToPoint(a,{x:n,y:o})],s=X.fromPoints(r);return X.expand(s,Math.max(s.width,s.height)*.05)},E0=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=Oe(o)?E0(e,o.id):z(o);a&&(n=n?X.union(n,a):a)}return n},A9=(e,t)=>{let n=null;for(let o of t){let a=M(e,o);if(!a)continue;let r=Oe(a)?E0(e,a.id):z(a);r&&(n=n?X.union(n,r):r)}return n};var v9=e=>{let t=null;for(let n of e.elements.values())Ol(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var L9=(e,t,n,o,a)=>{let r=bm(e,o,Qb),s=a==="replace"?Ne:t;for(let i of r)n(i.layerId)||(s=xn(s,i.id));return s},S9=(e,t,n,o,a)=>{let r=a==="replace"?Ne:t,s=bm(e,o,Qb);for(let i of s)n(i.layerId)||(r=xn(r,i.id));return r},qF=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,WA=(e,t,n,o,a)=>{let r=a==="replace"?kt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=rt(e,s);!i||i.length<2||i.every(l=>qF(l,o))&&(r=DA(r,s.id))}return r};var k9=(e,t,n,o)=>{let a=n;if(t){let i=M(e,t);i&&(a=Sa(i,n,uo(i)).world)}let r=o,s=Xd(e,o);return s&&(r=Sa(s,o,uo(s)).world),{from:a,to:r}},w9=(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}},_9=(e,t)=>{let n=a=>{if(a.kind==="point")return`p:${a.position.x},${a.position.y}`;let r=M(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 jA=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},C9=(e,t,n,o)=>{let a=M(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}},T9=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=M(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},I9=(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=M(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=wa(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var VA=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(a)}return n},ZA=e=>e.map(t=>z(t)).reduce((t,n)=>X.union(t,n)),E9=(e,t,n)=>{let o=VA(e,t);if(o.length===0)return[];let a=ZA(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},M9=(e,t,n)=>{let o=VA(e,t);if(o.length<2)return[];let a=ZA(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},O9=(e,t,n)=>{let o=VA(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,b)=>r(m.b)-r(b.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,b)=>m+s(b.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 b=i[m];if(!b)continue;let y=h-r(b.b);if(y!==0){let g=a?{...b.el,position:{x:b.el.position.x+y,y:b.el.position.y}}:{...b.el,position:{x:b.el.position.x,y:b.el.position.y+y}};p.push({kind:"element",id:b.el.id,before:b.el,after:g})}h+=s(b.b)+f}return p},XA=(e,t,n,o)=>{let a=Math.cos(o),r=Math.sin(o),s=[];for(let[i,l]of t){let c=M(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},R9=e=>{let t=ZA(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var M0=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),B9=(e,t,n)=>{let o=M0({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},z9=(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=M0({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},D9=new Set(["nw","w","sw"]),WF=new Set(["ne","e","se"]),P9=new Set(["nw","n","ne"]),jF=new Set(["sw","s","se"]),YA=(e,t,n,o)=>{let a=n.x,r=n.y;if(D9.has(t)||WF.has(t)){let s=D9.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(P9.has(t)||jF.has(t)){let s=P9.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},N9=(e,t)=>{let n=M0({x:e.x,y:e.y},t),o=M0({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 Xf=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;actor;listeners=new Set;events=AA();eventCache=A4();unbind;_scene;_selection=Ne;annotationDrag=null;drawingPreview=null;edgePreview=null;linkDragFromAnchor=null;hoveredLinkTarget=null;hoverCursorWorld=null;pendingLinkDropMenu=null;_selectedLinks=kt;_selectedAnnotation=null;commentAuthor={id:"local",name:"You"};linkEndpointDrag=null;linkWaypointDrag=null;linkSegmentDrag=null;lassoPreview=null;lassoBaseSelection=null;lassoBaseLinks=null;groupMoveOrigin=null;groupLinkMoveOrigin=null;groupResizeOrigin=null;rotateGestureOrigin=null;_resizeOriginElement=null;_activeLayerId=$t(bn);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new rf([ub,db,fb]);snapThreshold=12;snapSuppressed=!1;transformAltKey=!1;transformShiftKey=!1;styleClipboard=null;boundsCache=new Mr;spatialIndexCache=null;_enteredGroup=null;lastClickAt=0;lastClickWorldPoint=null;lastHandleClickAt=0;lastHandleClickWorld=null;brushStroke=null;lastPointerWorld=null;cursorOverrides=new Map;lastRenderedScene=null;lastRenderedEnteredGroup=null;autoCompactScheduler=new m0({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new y0({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()}});dragElementId=null;additivePressAdded=null;containerHover=null;_peerCursors=[];_peerSelections=[];cursorListeners=new Set;activePointers=new Map;touchPanCandidate=null;pinch;containerOpsRef;spaceHeld=!1;tileComposeFn;tileDirtyElements=new Map;_toolLocked=!1;fileDropRegistry=new qf;panGesture=null;suppressNextContextMenu=!1;longPress;longPressListeners=new Set;announceListeners=new Set;inputMode;handleHitSlop;edgeHandleHitSlop;edgeHitThreshold;anchorStartHitSlop;anchorClickRadius;_history;gestureTx=null;gestureStartScene=null;gestures;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=VF(t.history)?t.history:new Gf(t.history??{});let n=this;this.gestures=new A0({get history(){return n._history},get gestureTx(){return n.gestureTx},set gestureTx(r){n.gestureTx=r},get groupMoveOrigin(){return n.groupMoveOrigin},set groupMoveOrigin(r){n.groupMoveOrigin=r},get groupLinkMoveOrigin(){return n.groupLinkMoveOrigin},set groupLinkMoveOrigin(r){n.groupLinkMoveOrigin=r},get groupResizeOrigin(){return n.groupResizeOrigin},set groupResizeOrigin(r){n.groupResizeOrigin=r},get dragElementId(){return n.dragElementId},set dragElementId(r){n.dragElementId=r},get containerHover(){return n.containerHover},set containerHover(r){n.containerHover=r},get toolLocked(){return n._toolLocked},get mode(){return n.mode},setMode:r=>{n.setMode(r)},notify:()=>{n.notify()}}),this.tileComposeFn=t.useTileCache===!0&&t.tileCompose?t.tileCompose:null,t.textShaper&&zf(t.textShaper),t.rasterizer&&Nf(t.rasterizer),H1((r,s,i,l)=>(this.mainTarget.setFont(s,i,{...l?.bold?{weight:"bold"}:{},...l?.italic?{style:"italic"}:{}}),this.mainTarget.measureText(r).width));let o=t.inputMode??"auto";o==="touch"?this.inputMode="touch":o==="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"?dT:11,this.edgeHandleHitSlop=this.inputMode==="touch"?fT:Oo,this.edgeHitThreshold=this.inputMode==="touch"?pT:Dm,this.anchorStartHitSlop=this.inputMode==="touch"?hT:Pm,this.anchorClickRadius=this.inputMode==="touch"?mT:Bm,this.actor=Bo(RI),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",r=>{this.applyEmit(r)}),this.actor.start(),this.fileDropRegistry.register(u4),this.fileDropRegistry.register(f4),t.initialMode&&this.actor.send({type:"SET_MODE",mode:t.initialMode}),this.longPress=new S0(r=>this.screenToWorld(r),r=>{for(let s of this.longPressListeners)s(r)}),this.pinch=new k0(r=>this.screenToWorld(r),(r,s)=>{this.zoomAt(r,s)},r=>{this.panBy(r)});let a=this;this.containerOpsRef={get scene(){return a._scene},get dragElementId(){return a.dragElementId},get containerHover(){return a.containerHover},applyPatch(r,s){a._scene=s,a.beginOrAttachGesture().add(r)}},this.unbind=this.bindPointerEvents(),this.animation.attach(),CA(this),this.maybeAnimate(),this.animationContentOff=eA(()=>{this.scheduleRender()}),this.forceRender(),L4(this.eventCache,this.observableSnapshot())}observableSnapshot(){return{mode:this.mode,selection:this._selection,selectedLinks:this._selectedLinks,scene:this._scene,canUndo:this.canUndo,canRedo:this.canRedo}}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=A5(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=v5(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=L5(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=S5(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=k5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return w5(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 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:X4(this._selectedLinks)}updateSelectedLink(t){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._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=Je(this._scene,t);return this._scene=o.scene,(n?.select??!0)&&(this._selection=Mt(t.id)),this._history.push(o.patch),this.notify(),o.patch}insertImage(t){let n=Qe(this.uniqueId("img")),o=S4(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 k4(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new x0({hasVisibleAnimatedElement:()=>w4(this),autoStopHeavyGifs:()=>{_4(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return L0(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new v0;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}=d9(t),r=o(this._scene);this._scene=r.scene,this._selection=Mt(t.id),this.notify();let s={...a};return{update:i=>{let l=c9(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=u9(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}=f9(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Ne,this.notify()}}}deleteSelected(){let t=W5(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=Ne,this._selectedLinks=kt,this.notify()}_editingTextElement=null;get editingTextElement(){return this._editingTextElement}_editingLinkCaption=null;get editingLinkCaption(){return this._editingLinkCaption}_editingFrameName=null;get editingFrameName(){return this._editingFrameName}_pendingTextCreate=null;_textEditOrigin=null;_textSel=null;_textDragAnchor=null;caretBlink=new b0(()=>{this.notify()});get editingTextSelection(){return this._textSel}get editingTextCaret(){return this._textSel?this._textSel.dir==="backward"?this._textSel.start:this._textSel.end:null}get caretBlinkOn(){return this.caretBlink.on}get isTextDragging(){return this._textDragAnchor!==null}beginLinkCaptionEdit(t){be(this._scene,t)&&(this._editingTextElement!==null&&this.commitTextEdit(),this._editingLinkCaption=t,this.notify())}commitLinkCaptionEdit(t){let n=this._editingLinkCaption;if(this._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._editingLinkCaption!==null&&(this._editingLinkCaption=null,this.notify())}linkLabelWorld(t){let n=be(this._scene,t);if(!n)return null;let o=rt(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+=Ae.distance(L(o[i-1]),L(o[i]));let s=r*a;for(let i=1;i<o.length;i++){let l=L(o[i-1]),c=L(o[i]),u=Ae.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 L(o[o.length-1])}beginTextEdit(t){if(!_5(this._scene,t,a=>this.isLayerLocked(a)))return;this._editingTextElement!==null&&this._editingTextElement!==t&&this.commitTextEdit(),this._editingTextElement=t,this._textEditOrigin=this._pendingTextCreate===t?null:M(this._scene,t)??null;let o=M(this._scene,t)?.text.length??0;this._textSel={start:o,end:o,dir:"forward"},this.caretBlink.start(),this.notify()}beginFrameNameEdit(t){let n=M(this._scene,t);n===void 0||!He(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=T5(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 C5(this._scene,t)}setEditingText(t,n,o,a="forward"){let r=this._editingTextElement;if(!r)return;let s=le(this._scene,r,i=>({...i,text:t}));this._scene=s.scene,this._textSel={start:n,end:o,dir:a},this.caretBlink.wake(),this.notify()}setEditingSelection(t,n,o="forward"){this._editingTextElement&&(this._textSel={start:t,end:n,dir:o},this.caretBlink.wake(),this.notify())}caretIndexAtWorldPoint(t){let n=this._editingTextElement;if(!n)return null;let o=M(this._scene,n);if(o?.type!=="text")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 $2(a,i,this.measureFor(o),l)}editedElementContainsPoint(t){let n=this._editingTextElement;if(!n)return!1;let o=M(this._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}setTextCaretFromPoint(t){let n=this.caretIndexAtWorldPoint(t);n!==null&&(this._textDragAnchor=n,this.setEditingSelection(n,n,"forward"))}extendTextSelectionToPoint(t){if(this._textDragAnchor===null)return;let n=this.caretIndexAtWorldPoint(t);if(n===null)return;let o=this._textDragAnchor;n>=o?this.setEditingSelection(o,n,"forward"):this.setEditingSelection(n,o,"backward")}endTextDragSelect(){this._textDragAnchor=null}editingTextLayout(t){return Of(t.text,this.measureFor(t),{fontSize:t.fontSize,...t.maxWidth!==void 0?{maxWidth:t.maxWidth}:{}})}measureFor(t){let n=this.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}editingTextOverlay(){let t=this._editingTextElement;if(!t||!this._textSel)return null;let n=M(this._scene,t);if(n?.type!=="text")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=Q2(o,this._textSel.start,this._textSel.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._textSel.dir==="backward"?this._textSel.start:this._textSel.end,h=K2(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}}commitTextEdit(t){let n=this._editingTextElement;if(!n)return;let o=this._pendingTextCreate===n,a=this._textEditOrigin;t!==void 0&&(this._scene=le(this._scene,n,i=>({...i,text:t})).scene),this._editingTextElement=null,this._pendingTextCreate=null,this._textEditOrigin=null,this._textSel=null,this.caretBlink.stop();let r=M(this._scene,n);if((r?.text??"").trim()===""){r&&(this._scene=jn(this._scene,n).scene,!o&&a&&this._history.push({kind:"element",id:n,before:a,after:null}),this._selection.has(n)&&(this._selection=Ne)),this.notify();return}if(o)r&&this._history.push({kind:"element",id:n,before:null,after:r});else if(a&&r){let i=a.text;if(i!==r.text){let l={...r,text:i};this._history.push({kind:"element",id:n,before:l,after:r})}}this.notify()}cancelTextEdit(){let t=this._editingTextElement;if(t===null)return;let n=this._pendingTextCreate===t,o=this._textEditOrigin;if(this._editingTextElement=null,this._pendingTextCreate=null,this._textEditOrigin=null,this._textSel=null,this.caretBlink.stop(),n)M(this._scene,t)&&(this._scene=jn(this._scene,t).scene,this._selection.has(t)&&(this._selection=Ne));else if(o){let a=o.text;this._scene=le(this._scene,t,r=>({...r,text:a})).scene}this.notify()}moveSelectionBy(t){if(this._selection.size===0&&this._selectedLinks.size===0)return;let n=new Set([...this.expandSelectionWithDescendants()].filter(i=>{let l=M(this._scene,i);return l?this.isElementManipulable(l):!1})),o=this._selection.size>0?q5(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=G4(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(Q5(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=GA(++this.nextId),a=i9(this._scene,this.mode,n,this._activeLayerId,o),r=Je(this._scene,a);return this._scene=r.scene,this._history.push(r.patch),this._selection=Mt(o),this.notify(),this.announce(`Created ${a.type} ${o}`),o}createTextAt(t){let n=GA(++this.nextId),o=l9(this._scene,t,this._activeLayerId,n),a=Je(this._scene,o);return this._scene=a.scene,this._pendingTextCreate=n,this._selection=Mt(n),this.maybeRevertModeAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}beginBrushStroke(t,n=.5){this.brushStroke=o5(t,n),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(a5(this.brushStroke,t,n),this.notify())}commitBrushStroke(){let t=r5(this._scene,this.brushStroke,this._activeLayerId,s5(++this.nextId));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}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=B5(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=z5(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(){let t=F5(this._scene,this._selection,G5(++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=Mt(t.groupId),this.notify(),{kind:"grouped",groupId:t.groupId}}ungroup(){let t=H5(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 zA(this._scene,this._selection)}expandSelectionWithDescendants(){return N5(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=U5(this._scene,n,t);o&&(this._selection=Mt(o.id),this.notify(),this.announce(`Selected ${o.name}`))}cancelInteraction(){this.cancelGesture(),this.actor.send({type:"POINTER_CANCEL"}),this.drawingPreview=null,this.edgePreview=null,this.lassoPreview=null,this.linkDragFromAnchor=null,this.hoveredLinkTarget=null,this.hoverCursorWorld=null,this._editingLinkCaption=null,this.pendingLinkDropMenu=null,this.linkWaypointDrag=null,this.linkSegmentDrag=null,this.linkEndpointDrag=null,this._enteredGroup!==null&&(this._enteredGroup=null),this._selection=Ne,this._selectedLinks=kt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){let t=j5(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=NA(t.newIds)),this.notify()}duplicateSelectedInPlace(t=null){if(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,Qe(this.uniqueId("shape")));let r=m9(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=NA(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=V5(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify())}selectAll(){let t=Z5(this._scene,this._selection),n=X5(this._scene),o=!w0(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=u5(this._scene,this._selection);t.length!==0&&(this.clipboard=[...t],this.announce(`Copied ${t.length} shapes`))}cutSelected(){this.copySelected(),this.deleteSelected()}paste(t){if(this.clipboard.length===0)return;this.finalizeOpenGestureTx();let n=t??this.lastPointerWorld,o=d5(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=f5(o.newIds),this.notify(),this.announce(`Pasted ${o.newIds.length} shapes`)}copySelectionStyle(){for(let t of this._selection){let n=M(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){let o=Y5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}updateTextProps(t,n){let o=K5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){let n=$5(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}setLink(t,n){let o=n===null?null:t9(n),a=n9(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=T0(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return T0(M(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=T0(n.href);return o?{id:n.id,href:o,bounds:z(n)}:null}bringToFront(t){let n=M5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendToBack(t){let n=O5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}bringForward(t){let n=R5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendBackward(t){let n=D5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(E9(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(M9(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(O9(this._scene,this._selection,t))}rotateSelection(t){let n=[],o=new Map;for(let r of this._selection){let s=M(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=R9(n);this.commitArrange(XA(this._scene,o,a,t))}commitArrange(t){if(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(P5(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._scene.elements.size===0&&this._scene.links.size===0||(this._scene={...this._scene,elements:new Map,links:new Map},this._selection=Ne,this._selectedLinks=kt,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=p5(this._scene,t,b5(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=h5(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=Ne,this.notify()}renameLayer(t,n){let o=m5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=y5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=g5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){let n=x5(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=Y4(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(Xb)}zoomOut(){this.zoomStep(1/Xb)}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=$4(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=Q4(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=BA(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=J5(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=K4(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=J4(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=e5(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return km(this._scene.viewport)}setSnapToGrid(t){this.setGrid({snap:t})}setSnapSuppressed(t){this.snapSuppressed=t}setTransformModifiers(t){this.transformAltKey=t.alt,this.transformShiftKey=t.shift}snapActive(){let t=this._scene.viewport;return!this.snapSuppressed&&t.gridEnabled&&km(t)}snapSpacing(){return pb()}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??$t(bn)}n.preserveHistory?this.pruneSelection():(this._selection=Ne,this._history.clear()),CA(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 t5(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 B.applyToPoint(ka(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 pE(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=I5(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)||Ol(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||Z1(this._scene,t)||Ol(this._scene,t))}toggleLockSelection(){if(this._selection.size===0)return;let t=[...this._selection],n=t.some(a=>M(this._scene,a)?.locked!==!0),o=this._history.transaction();for(let a of t){let r=le(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 h4(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return p4(this._scene,t)}isDescendantOfGroup(t,n){return _A(this._scene,t,n)}computeHiddenElements(){return v9(this._scene)}computeDimElements(t){return m4(this._scene,this._selection,t)}enterGroup(t){this._enteredGroup=t,this.notify()}enterContainer(){if(this._selection.size!==1)return;let t=L([...this._selection][0]),n=M(this._scene,t);if(!n)return;let o=He(n),a=[];for(let r of this._scene.elements.values())(r.parentId===t||o&&r.frameId===t)&&a.push(r.id);a.length!==0&&(Oe(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=M(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<Fm?Xd(this._scene,t):K1(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=Y1(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.lastClickAt<Kb&&this.lastClickWorldPoint!==null&&Ae.distance(this.lastClickWorldPoint,n)<=$b;if(this.lastClickAt=o,this.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=RA(t.id),this._selection=Ne,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&&He(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=Mt(r.id),this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return y4(this._scene,t,n,this._enteredGroup)}applyEmit(t){switch(t.type){case"SELECT_REPLACE":this._selection=Mt(t.id),this._selectedLinks=kt,this.notify();return;case"SELECT_TOGGLE":this._selection=O1(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Ne,this._selectedLinks=kt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=RA(t.id),this._selection=Ne,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=Z4(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=kt,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.lassoBaseSelection??=this._selection,this.lassoBaseLinks??=this._selectedLinks,this.lassoPreview=t.bounds,this.applyLassoLiveSelection(t.bounds,t.mode),this.notify();return;case"LASSO_CLEAR":(this.lassoPreview!==null||this.lassoBaseSelection!==null||this.lassoBaseLinks!==null)&&(this.lassoPreview=null,this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.notify());return;case"SELECT_BY_BOUNDS":this.lassoBaseSelection=null,this.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=I9(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=M(this._scene,t);if(a&&!this.isElementManipulable(a))return;let r=this.transformShiftKey?jA(n):n,s=this.snapActive()?B9(o,r,this.snapSpacing()):r,i=C9(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.transformShiftKey?jA(t):t,o=this.snapActive()?z9(this.groupMoveOrigin,n,this.snapSpacing()):n,a=T9(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=U4(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=J(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return b9(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||t.viewport!==n.viewport||t.layers!==n.layers||this.lastRenderedEnteredGroup!==this._enteredGroup)return null;let{world:o,tileDirty:a}=T4(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=A9(this._scene,this._selection);for(let n of this._selectedLinks){let o=be(this._scene,n);if(!o)continue;let a=rt(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?X.union(t,c):c}return t}groupChildrenUnion(t){return E0(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=M(this._scene,t)?.type;return n==="group"||n==="image"}for(let t of this._selection){let n=M(this._scene,t);if(n===void 0||!Ut(n))return!1}return!0}applyRotate(t){let n=this.rotateGestureOrigin;if(!n)return;let o=this.transformShiftKey?Math.round(t/Bb)*Bb:t,a=XA(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()?YA(o,t,n,this.snapSpacing()):n,r=V4(this._scene,this.groupResizeOrigin,t,a,o,this.selectionIsAspectLocked()||this.transformShiftKey,this.transformAltKey);this._scene=r.scene;for(let s of r.patches)this.recordGesturePatch(s);this.notify()}applyResize(t,n,o,a){let r=M(this._scene,t);if(r!==void 0&&!Fe(r)&&r.rotation!==0){this._resizeOriginElement?.id!==t&&(this._resizeOriginElement=r);let l=W4(this._scene,this._resizeOriginElement,n,o,this.transformShiftKey,this.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let s=this.snapActive()?YA(a,n,o,this.snapSpacing()):o;if(r!==void 0&&Fe(r)){this._resizeOriginElement?.id!==t&&(this._resizeOriginElement=r);let l=j4(this._scene,this._resizeOriginElement,n,s,a,this.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let i=q4(this._scene,t,n,s,a,(l,c,u)=>this.clampContainerToChildren(l,c,u),this.transformShiftKey,this.transformAltKey);i&&(this._scene=i.scene,this.recordGesturePatch(i.patch),this.notify())}applyCreate(t,n){let o=I0(++this.nextId),a=this.snapActive()?N9(n,this.snapSpacing()):n,r=s9(this._scene,t,a,o,this._activeLayerId,()=>this.nextFrameName());this._scene=r.scene,this._selection=Mt(o),this._history.push(r.patch),t==="frame"&&this.assignFrameMembers(o,a),this.maybeRevertModeAfterCreate(),this.notify()}nextFrameName(){return g4(this._scene)}assignFrameMembers(t,n){this._scene=x4(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=b4(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=HA(++this.nextId),r=Zf(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.pendingLinkDropMenu={linkId:a,side:"to",world:o.position}),this.notify()}get linkDropMenu(){return this.pendingLinkDropMenu}placeShapeAtLinkDrop(t){let n=this.pendingLinkDropMenu;if(!n)return;if(!be(this._scene,n.linkId)){this.pendingLinkDropMenu=null,this.notify();return}let a=I0(++this.nextId),r=y9(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.pendingLinkDropMenu=null,this._selection=Mt(a),this._selectedLinks=kt,this.notify()}dismissLinkDropMenu(){this.pendingLinkDropMenu&&(this.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=I0(++this.nextId),a=HA(++this.nextId),r=h9(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=Mt(o),this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify()}previewClickCreate(t,n){return p9(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return o9(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=L9(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=WA(this._scene,n==="add"?this._selectedLinks:kt,s=>this.isLayerLocked(s),t,n),r=!w0(a,this._selectedLinks);if(this._selectedLinks=a,Rs(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.lassoBaseSelection??Ne,a=S9(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.lassoBaseLinks??kt,s=WA(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!w0(s,this._selectedLinks);Rs(a,this._selection)&&!i||(this._selectedLinks=s,this._selection=a)}applyLinkEndpointMove(t,n,o){if(!be(this._scene,t))return;this.lastHandleClickAt=0;let r=this.linkAttachTargetAt(o),s=r?.kind==="element"?r.id:null,i=this.snapLinkEndpoint(s,o),l=et(this._scene,t,c=>n==="from"?{...c,from:i}:{...c,to:i});this._scene=l.scene,this.recordGesturePatch(l.patch),this.linkEndpointDrag={linkId:t,side:n,toPoint:o},this.updateHoveredLinkTarget(o),this.notify()}applyLinkEndpointUpdate(t){let n=this.gestureTx!==null,o=w9(this._scene,t,(a,r)=>this.snapLinkEndpoint(a,r));if(o===null){this.cancelGesture(),this.linkEndpointDrag=null,this.hoveredLinkTarget=null,this.notify();return}if(!n&&Cr(o.patch)){this.linkEndpointDrag=null,this.hoveredLinkTarget=null,this.notify();return}this._scene=o.scene,this.recordGesturePatch(o.patch),this.commitGesture(),this.linkEndpointDrag=null,this.hoveredLinkTarget=null}get isDraggingWaypoint(){return this.linkWaypointDrag!==null}beginWaypointDrag(t,n,o){be(this._scene,t)&&(this.linkWaypointDrag={linkId:t,index:n,pendingInsert:o})}updateWaypointDrag(t){let n=this.linkWaypointDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this._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._scene,n.linkId,s=>({...s,waypoints:a}));this._scene=r.scene,this.recordGesturePatch(r.patch),this.notify()}endWaypointDrag(){let t=this.linkWaypointDrag;if(this.linkWaypointDrag=null,!t)return;if(t.pendingInsert){this.commitGesture();return}let n=be(this._scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=rt(this._scene,n),a=L(n.waypoints[t.index]),r=zC/(this._scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&Ml.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=et(this._scene,t.linkId,u=>({...u,waypoints:l}));this._scene=c.scene,this.recordGesturePatch(c.patch)}}this.commitGesture()}get isDraggingSegment(){return this.linkSegmentDrag!==null}beginSegmentDrag(t,n,o){be(this._scene,t)&&(this.linkSegmentDrag={linkId:t,axis:n,at:o})}updateSegmentDrag(t){let n=this.linkSegmentDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this._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._scene,n.linkId,c=>({...c,fixedSegments:r}));this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify()}endSegmentDrag(){this.linkSegmentDrag&&(this.linkSegmentDrag=null,this.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<Kb&&this.lastHandleClickWorld!==null&&Ae.distance(this.lastHandleClickWorld,t)<=$b;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=be(this._scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=et(this._scene,t,s=>({...s,waypoints:a}));this._scene=r.scene,this._history.push(r.patch),this.notify()}resetSegmentPin(t,n,o,a){let r=be(this._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=L(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._scene,t,u=>({...u,fixedSegments:l}));this._scene=c.scene,this._history.push(c.patch),this.notify()}get selectedLinkAvoidsObstacles(){let t=this.selectedLink;return t===null?!1:be(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){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.elbowRouteSig.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(f=>f.metadata?.elementId===n.id),r=a.find(f=>f.kind==="anchor"),s=a.find(f=>f.kind==="outline"),i=r?.metadata?.ref,l=null;i?.kind==="named"?l=i.name:i?.kind==="edge"&&i.t===.5&&(l=`edge-${i.index}`);let c=!l&&s?s.snapped:void 0,u=this.hoveredLinkTarget;if(u?.elementId===n.id&&u.activeAnchor===l&&u.outlinePoint?.x===c?.x&&u.outlinePoint?.y===c?.y)return;let d=l!==null||c?"point":"element";this.hoveredLinkTarget={elementId:n.id,activeAnchor:l,outlinePoint:c,mode:d},this.notify()}applyLinkPreview(t,n,o){let a=k9(this._scene,t,n,o);if(Rm==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=Pb(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,zl(t))),this.gestures.record(t)}commitGesture(){this._resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.commit(),this.gestureStartScene=null}finalizeOpenGestureTx(){this.gestures.finalize()}applyContainerDrop(t){E4(this.containerOpsRef,t)}maybeGrowContainer(t,n){jf(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return I4(this._scene,t,n,o)}beginOrAttachGesture(){return this.gestureTx??=this._history.transaction(),this.gestureTx}cancelGesture(){this._resizeOriginElement=null,this.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(),v4(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=df(this._scene,t);return n?(this._scene=J(this._scene,n),this._history.push(n),this.autoLayoutScheduler.resetSignature(t),this.notify(),n):null}elbowRouteSig=new Map;rerouteElbows(){let t=this._scene;for(let[n,o]of this._scene.links){if((o.routing??"straight")!=="orthogonal")continue;let a=_9(this._scene,o);if(this.elbowRouteSig.get(n)===a)continue;this.elbowRouteSig.set(n,a);let r=pf(t,o);t=et(t,n,s=>({...s,routedPoints:r})).scene}this._scene=t}render(){this.rerouteElbows(),nA(t=>this.gifPlayback.clock(t.id)),x9(this),this.onAfterRender?.()}},VF=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var KA=F(ye(),1),ic=F(he(),1),O0=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,ic.useRef)(null),l=(0,ic.useRef)(null);if((0,ic.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,ic.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],b=h[h.length-1];if(m===void 0||b===void 0)return;let y=document.activeElement;f.shiftKey&&y===m?(f.preventDefault(),b.focus()):!f.shiftKey&&y===b&&(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,KA.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,KA.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var ZF={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",mode:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},XF=["mode","edit","selection","clipboard","history","z-order","grouping","layout","zoom","other"],$A=e=>{(0,lc.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])},YF=e=>{let t=[];if(e.hotkey){let n=Array.isArray(e.hotkey)?e.hotkey:[e.hotkey];for(let o of n)t.push(f0(o))}if(e.sequence&&e.sequence.length>0){let n=e.sequence.map(o=>o.length===1?o.toUpperCase():o).join(" ");t.push([n])}return t},Yf=({registry:e=st,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,lc.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:YF(d)}),c.set(f,p)}let u=[];for(let d of XF){let f=c.get(d);!f||f.length===0||u.push({title:ZF[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,je.jsx)(O0,{open:t,onClose:n,title:o,style:s,children:(0,je.jsxs)("div",{children:[(0,je.jsxs)("div",{style:i,children:[(0,je.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,je.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,je.jsx)("span",{className:"du-help-platform-badge",children:Br?"macOS":"Win / Linux"}),(0,je.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,je.jsx)(ba,{size:18,strokeWidth:1.75})})]})]}),(0,je.jsx)("div",{style:l,children:(0,je.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,je.jsxs)("section",{className:"du-help-island",children:[(0,je.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,je.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,je.jsxs)("div",{className:"du-help-row",children:[(0,je.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,je.jsx)(KF,{combos:u.keys})]},u.label))})]},c.title))})})]})})},KF=({combos:e})=>e.length===0?(0,je.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,je.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,je.jsxs)(lc.Fragment,{children:[n>0?(0,je.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,je.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var $F=16,QF=1.75,R0=({renderDialog:e})=>{let[t,n]=(0,F9.useState)(!1);return(0,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(Bn,{label:"Help",onClick:()=>{n(!0)},children:(0,zr.jsx)(gn,{size:$F,strokeWidth:QF})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,zr.jsx)(Yf,{open:t,onClose:()=>{n(!1)}})]})};var Qf=F(ye(),1),U9=F(he(),1);var Kf=F(he(),1);var H9=`(pointer: coarse), (max-width: ${640}px)`,JF=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(H9).matches:!1,$f=()=>(0,Kf.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(H9);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},JF,()=>!1),j=()=>g1(),eH=bb(),oi=()=>Aa(e=>e.scene,eH,"scene"),D0=()=>Aa(e=>e.selection,va.EMPTY,"selection"),QA=()=>Aa(e=>e.mode,"select","mode"),JA=()=>{let e=j(),t=Aa(r=>r.canUndo,!1,"history"),n=Aa(r=>r.canRedo,!1,"history"),o=(0,Kf.useCallback)(()=>{e?.undo()},[e]),a=(0,Kf.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var $ie=$t(bn);var ev=()=>Aa(e=>e.selectedLink,null);var tH=14,nH=1.75,tv=()=>{let e=j(),t=oi(),n=(0,U9.useMemo)(()=>oH(t),[t]);return!e||t.elements.size===0||!n?null:(0,Qf.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,Qf.jsx)(dd,{size:tH,strokeWidth:nH,"aria-hidden":!0}),(0,Qf.jsx)("span",{children:"Back to content"})]})},oH=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?X.union(n,u):u}if(!n)return!1;let o=ka(t),a=B.applyToPoint(o,{x:0,y:0}),r=B.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 nn=F(ye(),1),vi=F(he(),1);var pt=F(ye(),1),Kn=F(he(),1);var P0=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()}},ai=new P0;var sle={...Rr.rectangle},ile={...Rr.sticky},lle={...Rr.flowchart};var nv=(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 w={};no(w,{BRAND:()=>IH,DIRTY:()=>ri,EMPTY_PATH:()=>iH,INVALID:()=>V,NEVER:()=>pU,OK:()=>zt,ParseStatus:()=>Ot,Schema:()=>ie,ZodAny:()=>Hr,ZodArray:()=>Ra,ZodBigInt:()=>ii,ZodBoolean:()=>li,ZodBranded:()=>ep,ZodCatch:()=>bi,ZodDate:()=>ci,ZodDefault:()=>xi,ZodDiscriminatedUnion:()=>N0,ZodEffects:()=>Yn,ZodEnum:()=>yi,ZodError:()=>en,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>H0,ZodIntersection:()=>pi,ZodIssueCode:()=>D,ZodLazy:()=>hi,ZodLiteral:()=>mi,ZodMap:()=>hc,ZodNaN:()=>yc,ZodNativeEnum:()=>gi,ZodNever:()=>mo,ZodNull:()=>di,ZodNullable:()=>Go,ZodNumber:()=>si,ZodObject:()=>tn,ZodOptional:()=>Zn,ZodParsedType:()=>G,ZodPipeline:()=>tp,ZodPromise:()=>Ur,ZodReadonly:()=>Ai,ZodRecord:()=>F0,ZodSchema:()=>ie,ZodSet:()=>mc,ZodString:()=>Fr,ZodSymbol:()=>fc,ZodTransformer:()=>Yn,ZodTuple:()=>Uo,ZodType:()=>ie,ZodUndefined:()=>ui,ZodUnion:()=>fi,ZodUnknown:()=>Oa,ZodVoid:()=>pc,addIssueToContext:()=>H,any:()=>NH,array:()=>GH,bigint:()=>RH,boolean:()=>Q9,coerce:()=>fU,custom:()=>Y9,date:()=>DH,datetimeRegex:()=>Z9,defaultErrorMap:()=>Ea,discriminatedUnion:()=>VH,effect:()=>aU,enum:()=>tU,function:()=>QH,getErrorMap:()=>cc,getParsedType:()=>Ho,instanceof:()=>MH,intersection:()=>ZH,isAborted:()=>B0,isAsync:()=>uc,isDirty:()=>z0,isValid:()=>Nr,late:()=>EH,lazy:()=>JH,literal:()=>eU,makeIssue:()=>Jf,map:()=>KH,nan:()=>OH,nativeEnum:()=>nU,never:()=>HH,null:()=>zH,nullable:()=>sU,number:()=>$9,object:()=>qH,objectUtil:()=>ov,oboolean:()=>dU,onumber:()=>uU,optional:()=>rU,ostring:()=>cU,pipeline:()=>lU,preprocess:()=>iU,promise:()=>oU,quotelessJson:()=>aH,record:()=>YH,set:()=>$H,setErrorMap:()=>sH,strictObject:()=>WH,string:()=>K9,symbol:()=>PH,transformer:()=>aU,tuple:()=>XH,undefined:()=>BH,union:()=>jH,unknown:()=>FH,util:()=>pe,void:()=>UH});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 ov;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ov||(ov={}));var G=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ho=e=>{switch(typeof e){case"undefined":return G.undefined;case"string":return G.string;case"number":return Number.isNaN(e)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(e)?G.array:e===null?G.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?G.promise:typeof Map<"u"&&e instanceof Map?G.map:typeof Set<"u"&&e instanceof Set?G.set:typeof Date<"u"&&e instanceof Date?G.date:G.object;default:return G.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"]),aH=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),en=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()}};en.create=e=>new en(e);var rH=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===G.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}},Ea=rH;var G9=Ea;function sH(e){G9=e}function cc(){return G9}var Jf=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}},iH=[];function H(e,t){let n=cc(),o=Jf({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ea?void 0:Ea].filter(a=>!!a)});e.common.issues.push(o)}var Ot=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 V;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 V;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}}},V=Object.freeze({status:"aborted"}),ri=e=>({status:"dirty",value:e}),zt=e=>({status:"valid",value:e}),B0=e=>e.status==="aborted",z0=e=>e.status==="dirty",Nr=e=>e.status==="valid",uc=e=>typeof Promise<"u"&&e instanceof Promise;var W;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(W||(W={}));var Xn=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}},q9=(e,t)=>{if(Nr(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 en(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 ie=class{get description(){return this._def.description}_getType(t){return Ho(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ho(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ot,ctx:{common:t.parent.common,data:t.data,parsedType:Ho(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(uc(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:Ho(t)},a=this._parseSync({data:t,path:o.path,parent:o});return q9(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ho(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return Nr(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=>Nr(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:Ho(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(uc(a)?a:Promise.resolve(a));return q9(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 Yn({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 Zn.create(this,this._def)}nullable(){return Go.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ra.create(this)}promise(){return Ur.create(this,this._def)}or(t){return fi.create([this,t],this._def)}and(t){return pi.create(this,t,this._def)}transform(t){return new Yn({...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 ep({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new bi({...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 tp.create(this,t)}readonly(){return Ai.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},lH=/^c[^\s-]{8,}$/i,cH=/^[0-9a-z]+$/,uH=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dH=/^[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,fH=/^[a-z0-9_-]{21}$/i,pH=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hH=/^[-+]?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)?)??$/,mH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",av,gH=/^(?:(?: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])$/,xH=/^(?:(?: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])$/,bH=/^(([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]))$/,AH=/^(([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])$/,vH=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,LH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,j9="((\\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])))",SH=new RegExp(`^${j9}$`);function V9(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 kH(e){return new RegExp(`^${V9(e)}$`)}function Z9(e){let t=`${j9}T${V9(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 wH(e,t){return!!((t==="v4"||!t)&&gH.test(e)||(t==="v6"||!t)&&bH.test(e))}function _H(e,t){if(!pH.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 CH(e,t){return!!((t==="v4"||!t)&&xH.test(e)||(t==="v6"||!t)&&AH.test(e))}var Fr=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==G.string){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.string,received:r.parsedType}),V}let o=new Ot,a;for(let r of this._def.checks)if(r.kind==="min")t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),H(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),H(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?H(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&H(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")mH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"email",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")av||(av=new RegExp(yH,"u")),av.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"emoji",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")dH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"uuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")fH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"nanoid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")lH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")cH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cuid2",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")uH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(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),H(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),H(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),H(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),H(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),H(a,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?Z9(r).test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?SH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?kH(r).test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?hH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?wH(t.data,r.version)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"ip",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?_H(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"jwt",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?CH(t.data,r.version)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cidr",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?vH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?LH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(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,...W.errToObj(o)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...W.errToObj(t)})}url(t){return this._addCheck({kind:"url",...W.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...W.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...W.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...W.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...W.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...W.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...W.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...W.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...W.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...W.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...W.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...W.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,...W.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,...W.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...W.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...W.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...W.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...W.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...W.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...W.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...W.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...W.errToObj(n)})}nonempty(t){return this.min(1,W.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}};Fr.create=e=>new Fr({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function TH(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 si=class e extends ie{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)!==G.number){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.number,received:r.parsedType}),V}let o,a=new Ot;for(let r of this._def.checks)r.kind==="int"?pe.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),H(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),H(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),H(o,{code:D.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?TH(t.data,r.value)!==0&&(o=this._getOrReturnCtx(t,o),H(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),H(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,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:W.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:W.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:W.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.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)}};si.create=e=>new si({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var ii=class e extends ie{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)!==G.bigint)return this._getInvalidInput(t);let o,a=new Ot;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),H(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),H(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),H(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 H(n,{code:D.invalid_type,expected:G.bigint,received:n.parsedType}),V}gte(t,n){return this.setLimit("min",t,!0,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:W.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:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.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}};ii.create=e=>new ii({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var li=class extends ie{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==G.boolean){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.boolean,received:o.parsedType}),V}return zt(t.data)}};li.create=e=>new li({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var ci=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==G.date){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.date,received:r.parsedType}),V}if(Number.isNaN(t.data.getTime())){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_date}),V}let o=new Ot,a;for(let r of this._def.checks)r.kind==="min"?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),H(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),H(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:W.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:W.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}};ci.create=e=>new ci({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var fc=class extends ie{_parse(t){if(this._getType(t)!==G.symbol){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.symbol,received:o.parsedType}),V}return zt(t.data)}};fc.create=e=>new fc({typeName:Y.ZodSymbol,...ae(e)});var ui=class extends ie{_parse(t){if(this._getType(t)!==G.undefined){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.undefined,received:o.parsedType}),V}return zt(t.data)}};ui.create=e=>new ui({typeName:Y.ZodUndefined,...ae(e)});var di=class extends ie{_parse(t){if(this._getType(t)!==G.null){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.null,received:o.parsedType}),V}return zt(t.data)}};di.create=e=>new di({typeName:Y.ZodNull,...ae(e)});var Hr=class extends ie{constructor(){super(...arguments),this._any=!0}_parse(t){return zt(t.data)}};Hr.create=e=>new Hr({typeName:Y.ZodAny,...ae(e)});var Oa=class extends ie{constructor(){super(...arguments),this._unknown=!0}_parse(t){return zt(t.data)}};Oa.create=e=>new Oa({typeName:Y.ZodUnknown,...ae(e)});var mo=class extends ie{_parse(t){let n=this._getOrReturnCtx(t);return H(n,{code:D.invalid_type,expected:G.never,received:n.parsedType}),V}};mo.create=e=>new mo({typeName:Y.ZodNever,...ae(e)});var pc=class extends ie{_parse(t){if(this._getType(t)!==G.undefined){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.void,received:o.parsedType}),V}return zt(t.data)}};pc.create=e=>new pc({typeName:Y.ZodVoid,...ae(e)});var Ra=class e extends ie{_parse(t){let{ctx:n,status:o}=this._processInputParams(t),a=this._def;if(n.parsedType!==G.array)return H(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),V;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(s||i)&&(H(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&&(H(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&&(H(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 Xn(n,s,n.path,i)))).then(s=>Ot.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new Xn(n,s,n.path,i)));return Ot.mergeArray(o,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:W.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:W.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:W.toString(n)}})}nonempty(t){return this.min(1,t)}};Ra.create=(e,t)=>new Ra({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function dc(e){if(e instanceof tn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=Zn.create(dc(o))}return new tn({...e._def,shape:()=>t})}else return e instanceof Ra?new Ra({...e._def,type:dc(e.element)}):e instanceof Zn?Zn.create(dc(e.unwrap())):e instanceof Go?Go.create(dc(e.unwrap())):e instanceof Uo?Uo.create(e.items.map(t=>dc(t))):e}var tn=class e extends ie{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)!==G.object){let c=this._getOrReturnCtx(t);return H(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),V}let{status:o,ctx:a}=this._processInputParams(t),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof mo&&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 Xn(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof mo){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&&(H(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 Xn(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=>Ot.mergeObjectSync(o,c)):Ot.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(t){return W.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:W.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 dc(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 Zn;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return X9(pe.objectKeys(this.shape))}};tn.create=(e,t)=>new tn({shape:()=>e,unknownKeys:"strip",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});tn.strictCreate=(e,t)=>new tn({shape:()=>e,unknownKeys:"strict",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});tn.lazycreate=(e,t)=>new tn({shape:e,unknownKeys:"strip",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});var fi=class extends ie{_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 en(i.ctx.common.issues));return H(n,{code:D.invalid_union,unionErrors:s}),V}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 en(l));return H(n,{code:D.invalid_union,unionErrors:i}),V}}get options(){return this._def.options}};fi.create=(e,t)=>new fi({options:e,typeName:Y.ZodUnion,...ae(t)});var Ma=e=>e instanceof hi?Ma(e.schema):e instanceof Yn?Ma(e.innerType()):e instanceof mi?[e.value]:e instanceof yi?e.options:e instanceof gi?pe.objectValues(e.enum):e instanceof xi?Ma(e._def.innerType):e instanceof ui?[void 0]:e instanceof di?[null]:e instanceof Zn?[void 0,...Ma(e.unwrap())]:e instanceof Go?[null,...Ma(e.unwrap())]:e instanceof ep||e instanceof Ai?Ma(e.unwrap()):e instanceof bi?Ma(e._def.innerType):[],N0=class e extends ie{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.object)return H(n,{code:D.invalid_type,expected:G.object,received:n.parsedType}),V;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}):(H(n,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),V)}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=Ma(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 rv(e,t){let n=Ho(e),o=Ho(t);if(e===t)return{valid:!0,data:e};if(n===G.object&&o===G.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=rv(e[i],t[i]);if(!l.valid)return{valid:!1};s[i]=l.data}return{valid:!0,data:s}}else if(n===G.array&&o===G.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=rv(s,i);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===G.date&&o===G.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var pi=class extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(B0(r)||B0(s))return V;let i=rv(r.value,s.value);return i.valid?((z0(r)||z0(s))&&n.dirty(),{status:n.value,value:i.data}):(H(o,{code:D.invalid_intersection_types}),V)};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}))}};pi.create=(e,t,n)=>new pi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var Uo=class e extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.array)return H(o,{code:D.invalid_type,expected:G.array,received:o.parsedType}),V;if(o.data.length<this._def.items.length)return H(o,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&o.data.length>this._def.items.length&&(H(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 Xn(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Ot.mergeArray(n,s)):Ot.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Uo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Uo({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var F0=class e extends ie{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!==G.object)return H(o,{code:D.invalid_type,expected:G.object,received:o.parsedType}),V;let a=[],r=this._def.keyType,s=this._def.valueType;for(let i in o.data)a.push({key:r._parse(new Xn(o,i,o.path,i)),value:s._parse(new Xn(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Ot.mergeObjectAsync(n,a):Ot.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof ie?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...ae(o)}):new e({keyType:Fr.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},hc=class extends ie{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!==G.map)return H(o,{code:D.invalid_type,expected:G.map,received:o.parsedType}),V;let a=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([i,l],c)=>({key:a._parse(new Xn(o,i,o.path,[c,"key"])),value:r._parse(new Xn(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 V;(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 V;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}}}};hc.create=(e,t,n)=>new hc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var mc=class e extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.set)return H(o,{code:D.invalid_type,expected:G.set,received:o.parsedType}),V;let a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(H(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&&(H(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 V;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 Xn(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:W.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:W.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};mc.create=(e,t)=>new mc({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var H0=class e extends ie{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.function)return H(n,{code:D.invalid_type,expected:G.function,received:n.parsedType}),V;function o(i,l){return Jf({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cc(),Ea].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return Jf({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cc(),Ea].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 Ur){let i=this;return zt(async function(...l){let c=new en([]),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 zt(function(...l){let c=i._def.args.safeParse(l,r);if(!c.success)throw new en([o(l,c.error)]);let u=Reflect.apply(s,this,c.data),d=i._def.returns.safeParse(u,r);if(!d.success)throw new en([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:Uo.create(t).rest(Oa.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||Uo.create([]).rest(Oa.create()),returns:n||Oa.create(),typeName:Y.ZodFunction,...ae(o)})}},hi=class extends ie{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})}};hi.create=(e,t)=>new hi({getter:e,typeName:Y.ZodLazy,...ae(t)});var mi=class extends ie{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return H(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:t.data}}get value(){return this._def.value}};mi.create=(e,t)=>new mi({value:e,typeName:Y.ZodLiteral,...ae(t)});function X9(e,t){return new yi({values:e,typeName:Y.ZodEnum,...ae(t)})}var yi=class e extends ie{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return H(n,{expected:pe.joinValues(o),received:n.parsedType,code:D.invalid_type}),V}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 H(n,{received:n.data,code:D.invalid_enum_value,options:o}),V}return zt(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})}};yi.create=X9;var gi=class extends ie{_parse(t){let n=pe.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==G.string&&o.parsedType!==G.number){let a=pe.objectValues(n);return H(o,{expected:pe.joinValues(a),received:o.parsedType,code:D.invalid_type}),V}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=pe.objectValues(n);return H(o,{received:o.data,code:D.invalid_enum_value,options:a}),V}return zt(t.data)}get enum(){return this._def.values}};gi.create=(e,t)=>new gi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var Ur=class extends ie{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.promise&&n.common.async===!1)return H(n,{code:D.invalid_type,expected:G.promise,received:n.parsedType}),V;let o=n.parsedType===G.promise?n.data:Promise.resolve(n.data);return zt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ur.create=(e,t)=>new Ur({type:e,typeName:Y.ZodPromise,...ae(t)});var Yn=class extends ie{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=>{H(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 V;let l=await this._def.schema._parseAsync({data:i,path:o.path,parent:o});return l.status==="aborted"?V:l.status==="dirty"?ri(l.value):n.value==="dirty"?ri(l.value):l});{if(n.value==="aborted")return V;let i=this._def.schema._parseSync({data:s,path:o.path,parent:o});return i.status==="aborted"?V:i.status==="dirty"?ri(i.value):n.value==="dirty"?ri(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"?V:(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"?V:(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(!Nr(s))return V;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=>Nr(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):V);pe.assertNever(a)}};Yn.create=(e,t,n)=>new Yn({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});Yn.createWithPreprocess=(e,t,n)=>new Yn({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var Zn=class extends ie{_parse(t){return this._getType(t)===G.undefined?zt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zn.create=(e,t)=>new Zn({innerType:e,typeName:Y.ZodOptional,...ae(t)});var Go=class extends ie{_parse(t){return this._getType(t)===G.null?zt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Go.create=(e,t)=>new Go({innerType:e,typeName:Y.ZodNullable,...ae(t)});var xi=class extends ie{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return n.parsedType===G.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 bi=class extends ie{_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 uc(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new en(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new en(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};bi.create=(e,t)=>new bi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var yc=class extends ie{_parse(t){if(this._getType(t)!==G.nan){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.nan,received:o.parsedType}),V}return{status:"valid",value:t.data}}};yc.create=e=>new yc({typeName:Y.ZodNaN,...ae(e)});var IH=Symbol("zod_brand"),ep=class extends ie{_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}},tp=class e extends ie{_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"?V:r.status==="dirty"?(n.dirty(),ri(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"?V: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})}},Ai=class extends ie{_parse(t){let n=this._def.innerType._parse(t),o=a=>(Nr(a)&&(a.value=Object.freeze(a.value)),a);return uc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Ai.create=(e,t)=>new Ai({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function W9(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Y9(e,t={},n){return e?Hr.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=W9(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=W9(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):Hr.create()}var EH={object:tn.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 MH=(e,t={message:`Input not instance of ${e.name}`})=>Y9(n=>n instanceof e,t),K9=Fr.create,$9=si.create,OH=yc.create,RH=ii.create,Q9=li.create,DH=ci.create,PH=fc.create,BH=ui.create,zH=di.create,NH=Hr.create,FH=Oa.create,HH=mo.create,UH=pc.create,GH=Ra.create,qH=tn.create,WH=tn.strictCreate,jH=fi.create,VH=N0.create,ZH=pi.create,XH=Uo.create,YH=F0.create,KH=hc.create,$H=mc.create,QH=H0.create,JH=hi.create,eU=mi.create,tU=yi.create,nU=gi.create,oU=Ur.create,aU=Yn.create,rU=Zn.create,sU=Go.create,iU=Yn.createWithPreprocess,lU=tp.create,cU=()=>K9().optional(),uU=()=>$9().optional(),dU=()=>Q9().optional(),fU={string:(e=>Fr.create({...e,coerce:!0})),number:(e=>si.create({...e,coerce:!0})),boolean:(e=>li.create({...e,coerce:!0})),bigint:(e=>ii.create({...e,coerce:!0})),date:(e=>ci.create({...e,coerce:!0}))};var pU=V;var mU=["basic","layout","flowchart","custom","rich"],sv=({registry:e=ai,categories:t=mU,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,Kn.useMemo)(()=>new Set(e.categories()),[e]),c=(0,Kn.useMemo)(()=>t.filter(b=>l.has(b)),[t,l]),u=(0,Kn.useMemo)(()=>c.map(b=>({category:b,items:e.byCategory(b)})),[e,c]),[d,f]=(0,Kn.useState)(()=>new Set(n)),p=b=>{f(y=>{let g=new Set(y);return g.has(b)?g.delete(b):g.add(b),g})},h=o?.trim()??"",m=(0,Kn.useMemo)(()=>{if(!h)return[];let b=[];for(let{items:y}of u)for(let g of y)nv(g,h)&&b.push(g);return b},[u,h]);return(0,pt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,pt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,pt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,pt.jsx)("div",{className:i,children:m.map(b=>(0,pt.jsx)(n8,{template:b},b.id))}):u.map(({category:b,items:y})=>(0,pt.jsx)(yU,{category:b,items:y,itemsClass:i,collapsed:d.has(b),onToggle:()=>{p(b)}},b))})})},yU=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,pt.jsxs)("section",{className:"du-palette-section",children:[(0,pt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,pt.jsx)("span",{children:e}),(0,pt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,pt.jsx)(ks,{size:12,strokeWidth:1.75}):(0,pt.jsx)(Zu,{size:12,strokeWidth:1.75})})]}),o?null:(0,pt.jsx)("div",{className:n,children:t.map(r=>(0,pt.jsx)(n8,{template:r},r.id))})]}),np=null,e8=vA(),J9=e=>{np!==e&&(np=e,e8.emit())};var t8=e=>e8.add(e);var U0=null,gU=()=>{if(typeof document>"u")return null;if(U0&&document.body.contains(U0))return U0;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),U0=e,e},n8=({template:e})=>{let t=j(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=gU();s&&r.dataTransfer.setDragImage(s,0,0),J9(e)},o=()=>{J9(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=Qe(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),c=e.factory({id:l,layerId:bn,position:i,order:we([...t.scene.elements.values()].filter(d=>d.layerId===bn).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,pt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,pt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,pt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},iv=()=>{let e=j(),t=(0,Kn.useRef)(null);(0,Kn.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,Kn.useEffect)(()=>t8(()=>{np===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!np)return!1;let r=np,s=a.currentTarget.getBoundingClientRect(),i={x:a.clientX-s.left,y:a.clientY-s.top},l=e.screenToWorld(i),c=Qe(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),u=r.factory({id:c,layerId:bn,position:l,order:we([...e.scene.elements.values()].filter(d=>d.layerId===bn).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 wA(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var lv=14,cv=1.75,G0=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,vi.useState)("");(0,vi.useEffect)(()=>{e||i("")},[e]);let l=(0,vi.useRef)(null);return(0,vi.useEffect)(()=>{e&&l.current?.focus()},[e]),e?(0,nn.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,nn.jsx)("header",{className:"du-side-panel-header",children:(0,nn.jsxs)("div",{style:{display:"inline-flex",gap:4},children:[a?(0,nn.jsx)(Bn,{label:"Import templates",size:"sm",onClick:a,children:(0,nn.jsx)(Od,{size:lv,strokeWidth:cv})}):null,(0,nn.jsx)(Bn,{label:"Close library",size:"sm",onClick:t,children:(0,nn.jsx)(ba,{size:lv,strokeWidth:cv})})]})}),(0,nn.jsxs)("div",{className:"du-side-panel-search",children:[(0,nn.jsx)(kd,{size:lv,strokeWidth:cv,className:"du-side-panel-search-icon","aria-hidden":!0}),(0,nn.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,nn.jsx)("div",{className:"du-side-panel-body du-side-panel-body-flush",children:(0,nn.jsx)(sv,{searchQuery:s,layout:"list"})})]}):null};var dp=F(ye(),1);var gc=Math.min,Da=Math.max,ap=Math.round,rp=Math.floor,yo=e=>({x:e,y:e}),xU={left:"right",right:"left",bottom:"top",top:"bottom"};function uv(e,t,n){return Da(e,gc(t,n))}function sp(e,t){return typeof e=="function"?e(t):e}function Gr(e){return e.split("-")[0]}function ip(e){return e.split("-")[1]}function dv(e){return e==="x"?"y":"x"}function fv(e){return e==="y"?"height":"width"}function Pa(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function pv(e){return dv(Pa(e))}function r8(e,t,n){n===void 0&&(n=!1);let o=ip(e),a=pv(e),r=fv(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=op(s)),[s,op(s)]}function s8(e){let t=op(e);return[q0(e),t,q0(t)]}function q0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var o8=["left","right"],a8=["right","left"],bU=["top","bottom"],AU=["bottom","top"];function vU(e,t,n){switch(e){case"top":case"bottom":return n?t?a8:o8:t?o8:a8;case"left":case"right":return t?bU:AU;default:return[]}}function i8(e,t,n,o){let a=ip(e),r=vU(Gr(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(q0)))),r}function op(e){let t=Gr(e);return xU[t]+e.slice(t.length)}function LU(e){return{top:0,right:0,bottom:0,left:0,...e}}function l8(e){return typeof e!="number"?LU(e):{top:e,right:e,bottom:e,left:e}}function Li(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=Pa(t),s=pv(t),i=fv(s),l=Gr(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(ip(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 u8(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}=sp(t,e),h=l8(p),b=i[f?d==="floating"?"reference":"floating":d],y=Li(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(b)))==null||n?b:b.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,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(i.floating)),A=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},C=Li(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:g,offsetParent:x,strategy:l}):g);return{top:(y.top-C.top+h.top)/A.y,bottom:(C.bottom-y.bottom+h.bottom)/A.y,left:(y.left-C.left+h.left)/A.x,right:(C.right-y.right+h.right)/A.x}}var SU=50,d8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:u8},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 b=r[m];if(!b)continue;let{name:y,fn:g}=b,{x,y:A,data:C,reset:_}=await g({x:u,y:d,initialPlacement:o,placement:f,strategy:a,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});u=x??u,d=A??d,h[y]={...h[y],...C},_&&p<SU&&(p++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:u,y:d}=c8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var f8=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,...b}=sp(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=Gr(a),g=Pa(i),x=Gr(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(x||!m?[op(i)]:s8(i)),_=h!=="none";!f&&_&&C.push(...i8(i,m,h,A));let v=[i,...C],I=await l.detectOverflow(t,b),k=[],T=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&k.push(I[y]),d){let q=r8(a,s,A);k.push(I[q[0]],I[q[1]])}if(T=[...T,{placement:a,overflows:k}],!k.every(q=>q<=0)){var P,N;let q=(((P=r.flip)==null?void 0:P.index)||0)+1,te=v[q];if(te&&(!(d==="alignment"?g!==Pa(te):!1)||T.every($=>Pa($.placement)===g?$.overflows[0]>0:!0)))return{data:{index:q,overflows:T},reset:{placement:te}};let Z=(N=T.filter(ue=>ue.overflows[0]<=0).sort((ue,$)=>ue.overflows[1]-$.overflows[1])[0])==null?void 0:N.placement;if(!Z)switch(p){case"bestFit":{var U;let ue=(U=T.filter($=>{if(_){let re=Pa($.placement);return re===g||re==="y"}return!0}).map($=>[$.placement,$.overflows.filter(re=>re>0).reduce((re,We)=>re+We,0)]).sort(($,re)=>$[1]-re[1])[0])==null?void 0:U[0];ue&&(Z=ue);break}case"initialPlacement":Z=i;break}if(a!==Z)return{reset:{placement:Z}}}return{}}}};var kU=new Set(["left","top"]);async function wU(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=Gr(n),i=ip(n),l=Pa(n)==="y",c=kU.has(s)?-1:1,u=r&&l?-1:1,d=sp(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 p8=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 wU(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}}}}},h8=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:x}=y;return{x:g,y:x}}},...c}=sp(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=Pa(Gr(a)),p=dv(f),h=u[p],m=u[f];if(s){let y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",x=h+d[y],A=h-d[g];h=uv(x,h,A)}if(i){let y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",x=m+d[y],A=m-d[g];m=uv(x,m,A)}let b=l.fn({...t,[p]:h,[f]:m});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[p]:s,[f]:i}}}}}};function W0(){return typeof window<"u"}function ki(e){return y8(e)?(e.nodeName||"").toLowerCase():"#document"}function on(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function go(e){var t;return(t=(y8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function y8(e){return W0()?e instanceof Node||e instanceof on(e).Node:!1}function $n(e){return W0()?e instanceof Element||e instanceof on(e).Element:!1}function qo(e){return W0()?e instanceof HTMLElement||e instanceof on(e).HTMLElement:!1}function m8(e){return!W0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof on(e).ShadowRoot}function bc(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Qn(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function g8(e){return/^(table|td|th)$/.test(ki(e))}function lp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var _U=/transform|translate|scale|rotate|perspective|filter/,CU=/paint|layout|strict|content/,Si=e=>!!e&&e!=="none",hv;function j0(e){let t=$n(e)?Qn(e):e;return Si(t.transform)||Si(t.translate)||Si(t.scale)||Si(t.rotate)||Si(t.perspective)||!V0()&&(Si(t.backdropFilter)||Si(t.filter))||_U.test(t.willChange||"")||CU.test(t.contain||"")}function x8(e){let t=Ba(e);for(;qo(t)&&!wi(t);){if(j0(t))return t;if(lp(t))return null;t=Ba(t)}return null}function V0(){return hv==null&&(hv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hv}function wi(e){return/^(html|body|#document)$/.test(ki(e))}function Qn(e){return on(e).getComputedStyle(e)}function cp(e){return $n(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ba(e){if(ki(e)==="html")return e;let t=e.assignedSlot||e.parentNode||m8(e)&&e.host||go(e);return m8(t)?t.host:t}function b8(e){let t=Ba(e);return wi(t)?e.ownerDocument?e.ownerDocument.body:e.body:qo(t)&&bc(t)?t:b8(t)}function xc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=b8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=on(a);if(r){let i=Z0(s);return t.concat(s,s.visualViewport||[],bc(a)?a:[],i&&n?xc(i):[])}else return t.concat(a,xc(a,[],n))}function Z0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function S8(e){let t=Qn(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=qo(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=ap(n)!==r||ap(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function yv(e){return $n(e)?e:e.contextElement}function Ac(e){let t=yv(e);if(!qo(t))return yo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=S8(t),s=(r?ap(n.width):n.width)/o,i=(r?ap(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var TU=yo(0);function k8(e){let t=on(e);return!V0()||!t.visualViewport?TU:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function IU(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==on(e)?!1:t}function _i(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=yv(e),s=yo(1);t&&(o?$n(o)&&(s=Ac(o)):s=Ac(e));let i=IU(r,n,o)?k8(r):yo(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=on(r),p=o&&$n(o)?on(o):o,h=f,m=Z0(h);for(;m&&o&&p!==h;){let b=Ac(m),y=m.getBoundingClientRect(),g=Qn(m),x=y.left+(m.clientLeft+parseFloat(g.paddingLeft))*b.x,A=y.top+(m.clientTop+parseFloat(g.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=A,h=on(m),m=Z0(h)}}return Li({width:u,height:d,x:l,y:c})}function X0(e,t){let n=cp(e).scrollLeft;return t?t.left+n:_i(go(e)).left+n}function w8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-X0(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function EU(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=go(o),i=t?lp(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=yo(1),u=yo(0),d=qo(o);if((d||!d&&!r)&&((ki(o)!=="body"||bc(s))&&(l=cp(o)),d)){let p=_i(o);c=Ac(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?w8(s,l):yo(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 MU(e){return Array.from(e.getClientRects())}function OU(e){let t=go(e),n=cp(e),o=e.ownerDocument.body,a=Da(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=Da(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+X0(e),i=-n.scrollTop;return Qn(o).direction==="rtl"&&(s+=Da(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var A8=25;function RU(e,t){let n=on(e),o=go(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=V0();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=X0(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<=A8&&(r-=h)}else c<=A8&&(r+=c);return{width:r,height:s,x:i,y:l}}function DU(e,t){let n=_i(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=qo(e)?Ac(e):yo(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 v8(e,t,n){let o;if(t==="viewport")o=RU(e,n);else if(t==="document")o=OU(go(e));else if($n(t))o=DU(t,n);else{let a=k8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Li(o)}function _8(e,t){let n=Ba(e);return n===t||!$n(n)||wi(n)?!1:Qn(n).position==="fixed"||_8(n,t)}function PU(e,t){let n=t.get(e);if(n)return n;let o=xc(e,[],!1).filter(i=>$n(i)&&ki(i)!=="body"),a=null,r=Qn(e).position==="fixed",s=r?Ba(e):e;for(;$n(s)&&!wi(s);){let i=Qn(s),l=j0(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||bc(s)&&!l&&_8(e,s))?o=o.filter(u=>u!==s):a=i,s=Ba(s)}return t.set(e,o),o}function BU(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?lp(t)?[]:PU(t,this._c):[].concat(n),o],i=v8(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=v8(t,s[f],a);l=Da(p.top,l),c=gc(p.right,c),u=gc(p.bottom,u),d=Da(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function zU(e){let{width:t,height:n}=S8(e);return{width:t,height:n}}function NU(e,t,n){let o=qo(t),a=go(t),r=n==="fixed",s=_i(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=yo(0);function c(){l.x=X0(a)}if(o||!o&&!r)if((ki(t)!=="body"||bc(a))&&(i=cp(t)),o){let p=_i(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):yo(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 mv(e){return Qn(e).position==="static"}function L8(e,t){if(!qo(e)||Qn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return go(e)===n&&(n=n.ownerDocument.body),n}function C8(e,t){let n=on(e);if(lp(e))return n;if(!qo(e)){let a=Ba(e);for(;a&&!wi(a);){if($n(a)&&!mv(a))return a;a=Ba(a)}return n}let o=L8(e,t);for(;o&&g8(o)&&mv(o);)o=L8(o,t);return o&&wi(o)&&mv(o)&&!j0(o)?n:o||x8(e)||n}var FU=async function(e){let t=this.getOffsetParent||C8,n=this.getDimensions,o=await n(e.floating);return{reference:NU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function HU(e){return Qn(e).direction==="rtl"}var UU={convertOffsetParentRelativeRectToViewportRelativeRect:EU,getDocumentElement:go,getClippingRect:BU,getOffsetParent:C8,getElementRects:FU,getClientRects:MU,getDimensions:zU,getScale:Ac,isElement:$n,isRTL:HU};function T8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function GU(e,t){let n=null,o,a=go(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=rp(d),m=rp(a.clientWidth-(u+f)),b=rp(a.clientHeight-(d+p)),y=rp(u),x={rootMargin:-h+"px "+-m+"px "+-b+"px "+-y+"px",threshold:Da(0,gc(1,l))||1},A=!0;function C(_){let v=_[0].intersectionRatio;if(v!==l){if(!A)return s();v?s(!1,v):o=setTimeout(()=>{s(!1,1e-7)},1e3)}v===1&&!T8(c,e.getBoundingClientRect())&&s(),A=!1}try{n=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return s(!0),r}function Y0(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=yv(e),u=a||r?[...c?xc(c):[],...t?xc(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?GU(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 x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let h,m=l?_i(e):null;l&&b();function b(){let y=_i(e);m&&!T8(m,y)&&n(),m=y,h=requestAnimationFrame(b)}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 K0=p8;var $0=h8,Q0=f8;var J0=(e,t,n)=>{let o=new Map,a={platform:UU,...n},r={...a.platform,_c:o};return d8(e,t,{...a,platform:r})};var Wo=F(he(),1),Lv=F(Yo(),1);var S=F(ye(),1),Wr=F(he(),1);var I8=F(ye(),1),qr=F(he(),1),E8=(0,qr.createContext)(null),M8=({children:e})=>{let t=(0,qr.useRef)(null),n=(0,qr.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,I8.jsx)(E8.Provider,{value:n,children:e})},ey=()=>(0,qr.useContext)(E8);var an=F(ye(),1),D8=F(he(),1);var qU=Or.map(e=>tc.light[e].fill),WU=Or.map(e=>tc.light[e].solid),jU=Or.map(e=>tc.dark[e].fill),VU=Or.map(e=>tc.dark[e].solid),ZU=Or.map(e=>n0.light[e]),XU=Or.map(e=>n0.dark[e]),ty=[...qU,...WU,"#ffffff","#1e1e1e","transparent"],gv=[...jU,...VU,"#1e1e1e","#ffffff","transparent"],Ace=["#ffffff",...ZU],vce=["#121113",...XU],O8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var xv=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0})=>{let r=n??QU(),[s,i]=(0,D8.useState)(!1);return(0,an.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[r.map(l=>(0,an.jsx)(YU,{color:l,selected:R8(l)===R8(e),onClick:()=>{t(l==="transparent"?null:l)}},l)),o?(0,an.jsx)(KU,{value:e,onChange:t,open:s,onOpenChange:i}):null,a?(0,an.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,an.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,an.jsx)(ba,{size:12,strokeWidth:2})})}):null]})},YU=({color:e,selected:t,onClick:n})=>(0,an.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,an.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),KU=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,an.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,an.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,an.jsx)(Ts,{size:12,strokeWidth:2})}),(0,an.jsx)("input",{type:"color","aria-label":"Custom colour",value:$U(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},R8=e=>e===null?"transparent":e.toLowerCase(),$U=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"},QU=()=>{if(typeof document>"u")return ty;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?gv:e==="light"?ty:O8("system")==="dark"?gv:ty};var vc=F(ye(),1);var ht=F(he(),1),P8=F(Yo(),1);var xo=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Et(),[c,u]=(0,ht.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,ht.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,ht.useId)(),m=(0,ht.useRef)(null),b=(0,ht.useRef)(null);(0,ht.useLayoutEffect)(()=>{if(!f)return;let g=m.current,x=b.current;if(!g||!x)return;let A=()=>{J0(g,x,{placement:n,middleware:[K0(o),Q0(),$0({padding:6})]}).then(({x:_,y:v})=>{x.style.transform=`translate(${Math.round(_)}px, ${Math.round(v)}px)`})};return A(),Y0(g,x,A)},[f,n,o]),(0,ht.useEffect)(()=>{if(!f)return;let g=A=>{let C=A.target;C&&(m.current?.contains(C)||b.current?.contains(C)||p(!1))},x=A=>{A.key==="Escape"&&(A.stopPropagation(),p(!1),m.current?.focus())};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",x)}},[f,p]);let y=(0,ht.useMemo)(()=>{if(!(0,ht.isValidElement)(e))return e;let g=e.props;return(0,ht.cloneElement)(e,{ref:x=>{m.current=x;let A=e.ref;typeof A=="function"?A(x):A&&typeof A=="object"&&(A.current=x)},onClick:x=>{let A=g.onClick;A?.(x),!x.defaultPrevented&&p(!f)},"aria-haspopup":"dialog","aria-expanded":f,"aria-controls":f?h:void 0})},[e,f,p,h]);return(0,vc.jsxs)(vc.Fragment,{children:[y,f?(0,P8.createPortal)((0,vc.jsx)("div",{ref:b,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 Av=({style:e,className:t,mobile:n=!1})=>{let o=D0(),a=ev(),r=oi();if(o.size>0){let s=[...o].map(f=>r.elements.get(f)).filter(f=>f!==void 0);if(s.length===0)return null;let i=s.every(f=>Fe(f)),l=s.every(f=>Ut(f)),c=s.every(f=>He(f)),u=[],d=[];return c?u.push((0,S.jsx)(N8,{shapes:s},"fill")):i?(u.push((0,S.jsx)(tG,{shapes:s},"size"),(0,S.jsx)(eG,{shapes:s},"color"),(0,S.jsx)(oG,{shapes:s},"align")),d.push((0,S.jsx)(nG,{shapes:s},"family"),(0,S.jsx)(aG,{shapes:s},"decor"))):l?u.push((0,S.jsx)(F8,{shapes:s},"opacity")):(u.push((0,S.jsx)(N8,{shapes:s},"fill"),(0,S.jsx)(rG,{shapes:s},"stroke"),(0,S.jsx)(sG,{shapes:s},"width")),d.push((0,S.jsx)(iG,{shapes:s},"dash"),(0,S.jsx)(lG,{shapes:s},"round"),(0,S.jsx)(F8,{shapes:s},"opacity"))),d.push((0,S.jsx)(cG,{},"z"),(0,S.jsx)(JU,{shapes:s},"link")),s.length>=2&&d.push((0,S.jsx)(fG,{},"align")),d.push((0,S.jsx)(uG,{shapes:s},"actions"),(0,S.jsx)(z8,{},"more")),(0,S.jsx)(B8,{mobile:n,primary:u,overflow:d,className:t,style:e})}if(a!==null){let s=r.links.get(a);if(!s)return null;let i=[(0,S.jsx)(pG,{edge:s},"color"),(0,S.jsx)(hG,{edge:s},"width"),(0,S.jsx)(H8,{edge:s,side:"to"},"arrow-to")],l=[(0,S.jsx)(mG,{edge:s},"dash"),(0,S.jsx)(gG,{edge:s},"routing"),(0,S.jsx)(yG,{edge:s},"kind"),(0,S.jsx)(H8,{edge:s,side:"from"},"arrow-from"),(0,S.jsx)(xG,{edge:s},"auto"),(0,S.jsx)(bG,{},"delete"),(0,S.jsx)(z8,{},"more")];return(0,S.jsx)(B8,{mobile:n,primary:i,overflow:l,className:t,style:e})}return null},B8=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,Wr.useState)(!1),i=(0,Wr.useRef)(null);return(0,Wr.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)(br,{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)(LG,{}):null,n]})},JU=({shapes:e})=>{let t=j(),n=(0,Wr.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=up(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,S.jsx)(xo,{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)(ud,{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]})]})})},z8=()=>{let e=j(),t=ey();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)(Ar,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},vv=({label:e,color:t,onChange:n,ariaLabel:o})=>(0,S.jsx)(xo,{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)(xv,{value:t,onChange:n})]})}),eG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(i=>i.id),o=up(e,i=>i.style.fill),a=za(e,i=>i.style.opacity??1),r=a===null?null:Math.round(a*100);return(0,S.jsx)(xo,{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:!o||o==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":o,opacity:a??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)(xv,{value:o,onChange:i=>{t.updateStyle(n,{fill:i??"transparent"})}}),(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Fd,{value:r,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r===null?"\u2014":`${r}%`,onChange:i=>{t.updateStyle(n,{opacity:i/100})}})]})})},N8=({shapes:e})=>{let t=j();if(!t||!e.some(SG))return null;let n=up(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,S.jsx)(vv,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})}})},tG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(r=>r.id),o=za(e,r=>r.fontSize??null),a=o!==null&&x1.some(r=>r.value===o)?o:null;return(0,S.jsx)(xo,{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)(zn,{ariaLabel:"Font size preset",value:a,options:x1.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)(Fd,{value:o,min:__,max:C_,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},nG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(s=>s.id),o=up(e,s=>s.fontFamily),a=b1.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,S.jsx)(xo,{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"}),b1.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))]})})},oG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(a=>a.id),o=za(e,a=>a.style.textAlign??"left");return(0,S.jsx)(zn,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,S.jsx)(io,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,S.jsx)(Sr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,S.jsx)(Lr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},aG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(c=>c.id),o=e.every(c=>c.style?.fontWeight==="bold"),a=e.every(c=>c.style?.fontStyle==="italic"),r=e.every(c=>c.style?.textDecoration?.underline===!0),s=e.every(c=>c.style?.textDecoration?.strikethrough===!0),i=(c,u)=>{for(let d of e){let f=d.style?.textDecoration??{};t.updateStyle([d.id],{textDecoration:{...f,[c]:u}})}},l=({active:c,label:u,icon:d,onClick:f})=>(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${c?" is-active":""}`,title:u,"aria-label":u,"aria-pressed":c,onClick:f,children:d});return(0,S.jsx)(xo,{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)(ju,{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)(l,{active:o,label:"Bold",icon:(0,S.jsx)(Wu,{size:14,strokeWidth:1.75}),onClick:()=>{t.updateStyle(n,{fontWeight:o?"normal":"bold"})}}),(0,S.jsx)(l,{active:a,label:"Italic",icon:(0,S.jsx)(ld,{size:14,strokeWidth:1.75}),onClick:()=>{t.updateStyle(n,{fontStyle:a?"normal":"italic"})}}),(0,S.jsx)(l,{active:r,label:"Underline",icon:(0,S.jsx)(Ed,{size:14,strokeWidth:1.75}),onClick:()=>{i("underline",!r)}}),(0,S.jsx)(l,{active:s,label:"Strikethrough",icon:(0,S.jsx)(Cd,{size:14,strokeWidth:1.75}),onClick:()=>{i("strikethrough",!s)}})]})]})})},rG=({shapes:e})=>{let t=j();if(!t||!e.some(W8))return null;let n=up(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,S.jsx)(vv,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})}})},sG=({shapes:e})=>{let t=j();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=za(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,S.jsx)(zn,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(Lc,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(Lc,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(Lc,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},iG=({shapes:e})=>{let t=j();if(!t||!e.some(W8))return null;let n=za(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)(zn,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(xa,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(ya,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(ga,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},lG=({shapes:e})=>{let t=j();if(!t||!e.every(i=>jd(i)||i.type==="container"))return null;let o=za(e,i=>i.style.roundness?.type??"sharp"),a=za(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,S.jsx)(xo,{ariaLabel:"Corners",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,S.jsx)(bv,{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)(zn,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,S.jsx)(bv,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,S.jsx)(bv,{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)(Fd,{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]})})},F8=({shapes:e})=>{let t=j();if(!t)return null;let n=za(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)(xo,{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)(Fd,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},cG=()=>{let e=j();return e?(0,S.jsx)(zn,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,S.jsx)(Xu,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,S.jsx)(bd,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,S.jsx)(vd,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,S.jsx)(Yu,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},uG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.length>=2,o=e.some(r=>Oe(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,S.jsx)(ws,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,S.jsx)(_l,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,S.jsx)(sd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,S.jsx)(Md,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,S.jsx)(nd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,S.jsx)(od,{size:14,strokeWidth:1.75})}),(0,S.jsx)(zn,{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")}})},dG=[{edge:"left",label:"Align left",icon:(0,S.jsx)(Gu,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,S.jsx)(Sl,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,S.jsx)(Fu,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,S.jsx)(Uu,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,S.jsx)(zu,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,S.jsx)(Nu,{size:16,strokeWidth:1.75})}],fG=()=>{let e=j(),t=D0();if(!e)return null;let n=t.size>=3;return(0,S.jsx)(xo,{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)(Sl,{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:dG.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)(Hu,{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)(qu,{size:16,strokeWidth:1.75})})]})]}):null]})})},pG=({edge:e})=>{let t=j();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,S.jsx)(vv,{label:"Stroke",ariaLabel:"Link stroke color",color:n,onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,stroke:o??"transparent"}}))}})},hG=({edge:e})=>{let t=j();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,S.jsx)(zn,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(Lc,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(Lc,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(Lc,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},mG=({edge:e})=>{let t=j();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)(zn,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(xa,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(ya,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(ga,{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}}))}})},yG=({edge:e})=>{let t=j();if(!t)return null;let n=e.lineKind??"line";return(0,S.jsx)(zn,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,S.jsx)(ma,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,S.jsx)(Ad,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},gG=({edge:e})=>{let t=j();if(!t)return null;let n=e.routing??"straight";return(0,S.jsx)(zn,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,S.jsx)(U8,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,S.jsx)(U8,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,S.jsx)(_d,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},H8=({edge:e,side:t})=>{let n=j(),[o,a]=(0,Wr.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:ny[l],"aria-label":ny[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,S.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):q8(l)==="none"?(0,S.jsx)("span",{className:"du-arrowhead-erd-label",children:ny[l].replace(/^ERD /,"")}):(0,S.jsx)(G8,{kind:l,side:t})});return(0,S.jsx)(xo,{trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${ny[r]}`,"aria-label":`Arrow ${t}`,children:(0,S.jsx)(G8,{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:AG.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:vG.map(l=>(0,S.jsx)(i,{style:l},l))})]})})},xG=({edge:e})=>{let t=j();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)(Rd,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},bG=()=>{let e=j();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)(_l,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},U8=({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"})}),q8=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"}},AG=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],vG=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],ny={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"},G8=({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=q8(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]})},LG=()=>(0,S.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),Lc=({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"})}),bv=({kind:e})=>e==="sharp"?(0,S.jsx)(xa,{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})}),za=(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},up=(e,t)=>{let n=za(e,o=>t(o));return typeof n=="string"?n:null},SG=e=>e.style.fill!==void 0||He(e),W8=e=>e.style.stroke!==void 0;var Sv=({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=j(),r=Et(),s=$f(),[i,l]=(0,Wo.useState)(!1),c=(0,Wo.useRef)(null),[u,d]=(0,Wo.useState)(0),[f,p]=(0,Wo.useState)(!1);return(0,Wo.useEffect)(()=>{if(!a)return;let h=()=>{let m=a.selection,b=a.selection.size>0||a.selectedLink!==null;l(y=>(!y&&b&&p(!1),b)),d(y=>y+1)};return h(),a.on("change",h)},[a]),(0,Wo.useLayoutEffect)(()=>{if(!a||!i||s)return;let h=c.current;if(!h)return;let m=kG(a);if(!m)return;let b=()=>{J0(m,h,{placement:t,middleware:[K0(e),Q0({fallbackPlacements:["bottom","right","left"],padding:o}),$0({padding:o})]}).then(({x:g,y:x})=>{h.style.transform=`translate(${Math.round(g)}px, ${Math.round(x)}px)`,p(!0)})};return b(),Y0(m,h,b)},[a,i,s,u,e,t,o.top,o.right,o.bottom,o.left]),!a||!i?null:s?(0,Lv.createPortal)((0,dp.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,dp.jsx)(Av,{mobile:!0})}),r):(0,Lv.createPortal)((0,dp.jsx)("div",{ref:c,className:"du-sel-panel-floating",role:"toolbar","aria-label":"Selection actions",style:{position:"absolute",top:0,left:0,zIndex:1500,pointerEvents:"auto",opacity:f?1:0,transition:f?"opacity 120ms ease":"none",...f?{}:{pointerEvents:"none"}},children:(0,dp.jsx)(Av,{})}),r)},kG=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=wG(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},wG=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 Dr(e.scene,a)}return null}let n=null;for(let o of t){if(Oe(o)&&e.scene.elements.has(o.id)){let r=X1(e.scene,o.id);for(let s of r){if(Oe(s))continue;let i;try{i=z(s)}catch{continue}i.width===0&&i.height===0||(n=j8(n,i))}continue}let a;try{a=z(o)}catch{continue}n=j8(n,a)}return n},j8=(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 jr=F(ye(),1),Se=F(he(),1);var Sc="Roboto",fp="PT Serif",pp="Roboto Mono",kc=e=>{let t=e.toLowerCase();return t.includes("mono")?pp:t.includes("sans")?Sc:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?fp:Sc},_G=[{family:Sc,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:Sc,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:Sc,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:Sc,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:fp,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:fp,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:fp,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:fp,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:pp,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:pp,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:pp,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:pp,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],V8=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(_G.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 CG=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],oy=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of CG){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Z8=new Set,ay=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";Z8.has(t)||(Z8.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 wc=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 "${kc(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){if(!oy(t)){ay(t);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 hp=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,b=((u+h)*this.atlasSize+c)*3;this.buffer.set(p.data.subarray(m,m+this.tileSize*3),b)}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 _v(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=Y8(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=OG(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 yp(r,s,n,i,l,c,0),s}function Y8(e,t,n,o,a){let r;if(a===qG(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=X8(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=X8(s/o|0,e[s],e[s+1],r);return r&&_c(r,r.next)&&(xp(r),r=r.next),r}function Ci(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(_c(n,n.next)||Ve(n.prev,n,n.next)===0)){if(xp(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function yp(e,t,n,o,a,r,s){if(!e)return;!s&&r&&zG(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?IG(e,o,a,r):TG(e)){t.push(l.i,e.i,c.i),xp(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=EG(Ci(e),t),yp(e,t,n,o,a,r,2)):s===2&&MG(e,t,n,o,a,r):yp(Ci(e),t,n,o,a,r,1);break}}}function TG(e){let t=e.prev,n=e,o=e.next;if(Ve(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&&mp(a,i,r,l,s,c,h.x,h.y)&&Ve(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function IG(e,t,n,o){let a=e.prev,r=e,s=e.next;if(Ve(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),b=Math.max(u,d,f),y=kv(p,h,t,n,o),g=kv(m,b,t,n,o),x=e.prevZ,A=e.nextZ;for(;x&&x.z>=y&&A&&A.z<=g;){if(x.x>=p&&x.x<=m&&x.y>=h&&x.y<=b&&x!==a&&x!==s&&mp(i,u,l,d,c,f,x.x,x.y)&&Ve(x.prev,x,x.next)>=0||(x=x.prevZ,A.x>=p&&A.x<=m&&A.y>=h&&A.y<=b&&A!==a&&A!==s&&mp(i,u,l,d,c,f,A.x,A.y)&&Ve(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=h&&x.y<=b&&x!==a&&x!==s&&mp(i,u,l,d,c,f,x.x,x.y)&&Ve(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;A&&A.z<=g;){if(A.x>=p&&A.x<=m&&A.y>=h&&A.y<=b&&A!==a&&A!==s&&mp(i,u,l,d,c,f,A.x,A.y)&&Ve(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function EG(e,t){let n=e;do{let o=n.prev,a=n.next.next;!_c(o,a)&&$8(o,n,n.next,a)&&gp(o,a)&&gp(a,o)&&(t.push(o.i,n.i,a.i),xp(n),xp(n.next),n=e=a),n=n.next}while(n!==e);return Ci(n)}function MG(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&HG(s,i)){let l=Q8(s,i);s=Ci(s,s.next),l=Ci(l,l.next),yp(s,t,n,o,a,r,0),yp(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function OG(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=Y8(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(FG(c))}a.sort(RG);for(let r=0;r<a.length;r++)n=DG(a[r],n);return n}function RG(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 DG(e,t){let n=PG(e,t);if(!n)return t;let o=Q8(n,e);return Ci(o,o.next),Ci(n,n.next)}function PG(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(_c(e,n))return n;do{if(_c(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&&K8(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);gp(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&BG(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function BG(e,t){return Ve(e.prev,e,t.prev)<0&&Ve(t.next,e,e.next)<0}function zG(e,t,n,o){let a=e;do a.z===0&&(a.z=kv(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,NG(a)}function NG(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 kv(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 FG(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 K8(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 mp(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&K8(e,t,n,o,a,r,s,i)}function HG(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!UG(e,t)&&(gp(e,t)&&gp(t,e)&&GG(e,t)&&(Ve(e.prev,e,t.prev)||Ve(e,t.prev,t))||_c(e,t)&&Ve(e.prev,e,e.next)>0&&Ve(t.prev,t,t.next)>0)}function Ve(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function _c(e,t){return e.x===t.x&&e.y===t.y}function $8(e,t,n,o){let a=sy(Ve(e,t,n)),r=sy(Ve(e,t,o)),s=sy(Ve(n,o,e)),i=sy(Ve(n,o,t));return!!(a!==r&&s!==i||a===0&&ry(e,n,t)||r===0&&ry(e,o,t)||s===0&&ry(n,e,o)||i===0&&ry(n,t,o))}function ry(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 sy(e){return e>0?1:e<0?-1:0}function UG(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&&$8(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function gp(e,t){return Ve(e.prev,e,e.next)<0?Ve(e,t,e.next)>=0&&Ve(e,e.prev,t)>=0:Ve(e,t,e.prev)<0||Ve(e,e.next,t)<0}function GG(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 Q8(e,t){let n=wv(e.i,e.x,e.y),o=wv(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 X8(e,t,n,o){let a=wv(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 xp(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 wv(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qG(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 Cv=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=mm.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 Jn=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},rn=(e,t,n,o)=>{let a=Jn(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},Na=(e,t,n,o)=>{let a=Jn(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 ly=class{gl;program;vbo;uTransform;uColor;uOpacity;uPxRange;uAtlas;aPos;aUV;constructor(t){this.gl=t;let n=rn(t,t.VERTEX_SHADER,XG,"MSDF"),o=rn(t,t.FRAGMENT_SHADER,YG,"MSDF");this.program=Na(t,n,o,"MSDF"),this.vbo=Jn(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;VG(f);let p=iy,h=0,m=n;for(let _ of t){let v=_.codePointAt(0);if(v===void 0)continue;let I=r.getOrRasterize(v,c);if(!I)break;let k=I.advance*a/I.unitsPerEm;if(I.empty){m+=k;continue}jG(p,h,I,m,o,a,r),h+=u*d,m+=k}if(h===0)return m-n;let b=r.uploadTo(this.gl),y=this.gl;y.useProgram(this.program),y.bindBuffer(y.ARRAY_BUFFER,this.vbo),y.bufferData(y.ARRAY_BUFFER,p.subarray(0,h),y.DYNAMIC_DRAW),y.enableVertexAttribArray(this.aPos),y.vertexAttribPointer(this.aPos,2,y.FLOAT,!1,16,0),y.enableVertexAttribArray(this.aUV),y.vertexAttribPointer(this.aUV,2,y.FLOAT,!1,16,8);let g=s.transform,x=g;if(l!==0){let _=-(m-n)*l;x={...g,e:g.e+g.a*_,f:g.f+g.b*_}}ZG(J8,x,i.width,i.height),y.uniformMatrix3fv(this.uTransform,!1,J8),y.uniform3f(this.uColor,s.color[0],s.color[1],s.color[2]),y.uniform1f(this.uOpacity,s.opacity);let A=r.tileSize-2*r.range,C=r.range*a/Math.max(1,A);return y.uniform1f(this.uPxRange,C),y.activeTexture(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b),y.uniform1i(this.uAtlas,0),y.drawArrays(y.TRIANGLES,0,h/d),m-n}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},WG=(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,b=h+f,y=.5,g=(e.atlasX+y)/a.atlasSize,x=(e.atlasY+y)/a.atlasSize,A=(e.atlasX+l-y)/a.atlasSize,C=(e.atlasY+c-y)/a.atlasSize;return{left:p,top:h,right:m,bottom:b,u0:g,v0:x,u1:A,v1:C}},jG=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=WG(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)},iy=new Float32Array(512),J8=new Float32Array(9),VG=e=>{if(iy.length>=e)return;let t=iy.length;for(;t<e;)t*=2;iy=new Float32Array(t)},ZG=(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},XG=`#version 300 es
15
+ in vec2 aPos;
16
+ in vec2 aUV;
17
+ uniform mat3 uTransform;
18
+ out vec2 vUV;
19
+ void main() {
20
+ vec3 p = uTransform * vec3(aPos, 1.0);
21
+ gl_Position = vec4(p.xy, 0.0, 1.0);
22
+ vUV = aUV;
23
+ }`,YG=`#version 300 es
24
+ precision mediump float;
25
+ uniform vec3 uColor;
26
+ uniform float uOpacity;
27
+ uniform float uPxRange;
28
+ uniform sampler2D uAtlas;
29
+ in vec2 vUV;
30
+ out vec4 fragColor;
31
+
32
+ float median(float r, float g, float b) {
33
+ return max(min(r, g), min(max(r, g), b));
34
+ }
35
+
36
+ void main() {
37
+ vec3 msd = texture(uAtlas, vUV).rgb;
38
+ float sd = median(msd.r, msd.g, msd.b);
39
+ // Convert signed distance to screen-space AA: fwidth(vUV) tracks how
40
+ // much UV changes per screen pixel, multiplied by pxRange gives the
41
+ // screen-pixel cover of one SDF step.
42
+ float dx = fwidth(sd) * 0.5;
43
+ float alpha = smoothstep(0.5 - dx, 0.5 + dx, sd);
44
+ if (alpha < 0.001) discard;
45
+ // Premultiplied output to match the context's premultipliedAlpha
46
+ // contract + blendFunc(ONE, 1-SRC_ALPHA).
47
+ float a = alpha * uOpacity;
48
+ fragColor = vec4(uColor * a, a);
49
+ }`;var KG=10,t6=12,cy=new Float32Array(64),n6=new Float32Array(64),eo=new Float32Array(1024),jo=0,$G=e=>{if(cy.length>=e)return;let t=cy.length;for(;t<e;)t*=2;cy=new Float32Array(t),n6=new Float32Array(t)},QG=e=>{if(eo.length>=e)return;let t=eo.length;for(;t<e;)t*=2;let n=new Float32Array(t);n.set(eo.subarray(0,jo)),eo=n},JG=(e,t)=>{jo+2>eo.length&&QG(jo+2),eo[jo++]=e,eo[jo++]=t},eq=(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*KG);return{ox:r*u,oy:s*u}},o6=(e,t,n,o,a,r,s,i,l,c,u,d)=>{if(n.width<=0||t.length<2)return;let f=n.width/2,p=t.length-1;$G(p);let h=cy,m=n6;for(let k=0;k<p;k++){let T=L(t[k]),P=L(t[k+1]),N=P.x-T.x,U=P.y-T.y,q=Math.hypot(N,U)||1;h[k]=-U/q,m[k]=N/q}let b=L(t[0]),y=L(t[t.length-1]),g=t.length>=3&&b.x===y.x&&b.y===y.y;jo=0;let x=JG,A=(k,T,P,N,U,q,te,Z)=>{x(k+P,T+N),x(k-P,T-N),x(U+te,q+Z),x(U+te,q+Z),x(k-P,T-N),x(U-te,q-Z)},C=k=>({ox:L(h[k])*f,oy:L(m[k])*f});for(let k=0;k<p;k++){let T=L(t[k]),P=L(t[k+1]),N=C(k);A(T.x,T.y,N.ox,N.oy,P.x,P.y,N.ox,N.oy)}let _=(k,T,P,N,U,q)=>{if(n.join==="miter"){let{ox:te,oy:Z}=eq(P,N,U,q,f),ue=P*q-N*U;if(Math.abs(ue)<1e-9)return;let $=ue<0?1:-1,re=k+$*te,We=T+$*Z,Re=$*P*f,Ii=$*N*f,es=$*U*f,Rc=$*q*f;x(k,T),x(k+Re,T+Ii),x(re,We),x(k,T),x(re,We),x(k+es,T+Rc)}else if(n.join==="bevel"){let te=P*q-N*U;if(Math.abs(te)<1e-9)return;let Z=te<0?1:-1,ue=k+Z*P*f,$=T+Z*N*f,re=k+Z*U*f,We=T+Z*q*f;x(k,T),x(ue,$),x(re,We)}else{let te=P*q-N*U;if(Math.abs(te)<1e-9)return;let Z=te<0?1:-1,ue=Math.atan2(Z*N,Z*P),re=Math.atan2(Z*q,Z*U)-ue;for(;re>Math.PI;)re-=2*Math.PI;for(;re<-Math.PI;)re+=2*Math.PI;let We=Math.max(2,Math.ceil(Math.abs(re)/Math.PI*t6)),Re=k+Math.cos(ue)*f,Ii=T+Math.sin(ue)*f;for(let es=1;es<=We;es++){let Rc=es/We,ts=ue+re*Rc,ns=k+Math.cos(ts)*f,Wa=T+Math.sin(ts)*f;x(k,T),x(Re,Ii),x(ns,Wa),Re=ns,Ii=Wa}}};for(let k=1;k<p;k++){let T=L(t[k]);_(T.x,T.y,L(h[k-1]),L(m[k-1]),L(h[k]),L(m[k]))}if(g){let k=L(t[0]);_(k.x,k.y,L(h[p-1]),L(m[p-1]),L(h[0]),L(m[0]))}if(!g){let k=L(t[0]),T=L(t[1]);e6(x,k.x,k.y,T.x,T.y,L(h[0]),L(m[0]),f,n.cap,!0);let P=L(t[t.length-1]),N=L(t[t.length-2]);e6(x,P.x,P.y,N.x,N.y,L(h[p-1]),L(m[p-1]),f,n.cap,!1)}if(jo===0)return;let v=2/a.width,I=-2/a.height;for(let k=0;k<jo;k+=2){let T=L(eo[k]),P=L(eo[k+1]),N=o.a*T+o.c*P+o.e,U=o.b*T+o.d*P+o.f;eo[k]=N*v-1,eo[k+1]=U*I+1}e.useProgram(r),e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,eo.subarray(0,jo),e.DYNAMIC_DRAW),e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.uniformMatrix3fv(s,!1,d),e.uniform3f(i,n.color[0],n.color[1],n.color[2]),e.uniform1f(l,n.opacity),e.drawArrays(e.TRIANGLES,0,jo/2)},e6=(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,b=m*p,y=m*h;if(l==="square"){let I={x:t+r*i,y:n+s*i},k={x:t-r*i,y:n-s*i},T={x:I.x+b*i,y:I.y+y*i},P={x:k.x+b*i,y:k.y+y*i};e(I.x,I.y),e(T.x,T.y),e(k.x,k.y),e(k.x,k.y),e(T.x,T.y),e(P.x,P.y);return}let g=Math.atan2(s,r),x=t6,C=r*y-s*b>=0?1:-1,_=t+Math.cos(g)*i,v=n+Math.sin(g)*i;for(let I=1;I<=x;I++){let k=I/x,T=g+C*Math.PI*k,P=t+Math.cos(T)*i,N=n+Math.sin(T)*i;e(t,n),e(_,v),e(P,N),_=P,v=N}};var uy=(e,t,n)=>{let o=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x);if(o===0)return null;let a=o>0?1:-1;return{positions:new Float32Array([e.x,e.y,t.x,t.y,n.x,n.y]),uvs:new Float32Array([0,0,a,.5,0,a,1,1,a])}},a6=(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=Fn.cubicAt(e,t,n,o,c),f=Fn.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},Tv=(e,t,n,o,a=8)=>{let r=[];for(let[s,i,l]of a6(e,t,n,o,a)){let c=uy(s,i,l);c&&r.push(c)}return r},Iv=e=>{let t=new Float32Array(e.length*6),n=new Float32Array(e.length*9),o=0,a=0;for(let r of e)t.set(r.positions,o),n.set(r.uvs,a),o+=6,a+=9;return{positions:t,uvs:n}};var dy=class{gl;program;vbo;uvBuf;uTransform;uColor;uOpacity;aPos;aUVW;constructor(t){this.gl=t;let n=rn(t,t.VERTEX_SHADER,oq,"Loop-Blinn"),o=rn(t,t.FRAGMENT_SHADER,aq,"Loop-Blinn");this.program=Na(t,n,o,"Loop-Blinn"),this.vbo=Jn(t.createBuffer()),this.uvBuf=Jn(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 s=[];for(let u of t)if(u.kind==="q"){let[d,f,p]=u.points;if(!d||!f||!p)continue;let h=uy(d,f,p);h&&s.push(h)}else{let[d,f,p,h]=u.points;if(!d||!f||!p||!h)continue;for(let m of Tv(d,f,p,h))s.push(m)}if(s.length===0)return;let{positions:i,uvs:l}=Iv(s),c=this.gl;c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,this.vbo),c.bufferData(c.ARRAY_BUFFER,i,c.DYNAMIC_DRAW),c.enableVertexAttribArray(this.aPos),c.vertexAttribPointer(this.aPos,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.uvBuf),c.bufferData(c.ARRAY_BUFFER,l,c.DYNAMIC_DRAW),c.enableVertexAttribArray(this.aUVW),c.vertexAttribPointer(this.aUVW,3,c.FLOAT,!1,0,0),c.uniformMatrix3fv(this.uTransform,!1,nq(a,r.width,r.height)),c.uniform3f(this.uColor,n[0],n[1],n[2]),c.uniform1f(this.uOpacity,o),c.drawArrays(c.TRIANGLES,0,i.length/2)}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteBuffer(this.uvBuf),this.gl.deleteProgram(this.program)}},nq=(e,t,n)=>{let o=2/t,a=-2/n;return new Float32Array([e.a*o,e.b*a,0,e.c*o,e.d*a,0,e.e*o-1,e.f*a+1,1])},oq=`#version 300 es
50
+ in vec2 aPos;
51
+ in vec3 aUVW;
52
+ uniform mat3 uTransform;
53
+ out vec3 vUVW;
54
+ void main() {
55
+ vec3 p = uTransform * vec3(aPos, 1.0);
56
+ gl_Position = vec4(p.xy, 0.0, 1.0);
57
+ vUVW = aUVW;
58
+ }`,aq=`#version 300 es
59
+ precision mediump float;
60
+ uniform vec3 uColor;
61
+ uniform float uOpacity;
62
+ in vec3 vUVW;
63
+ out vec4 fragColor;
64
+
65
+ void main() {
66
+ float u = vUVW.x;
67
+ float v = vUVW.y;
68
+ float w = vUVW.z;
69
+ float p = u * u - v;
70
+ float dp = fwidth(p);
71
+ // Signed distance to the curve in procedural units; multiplied by w
72
+ // so the "outside" side discards regardless of curve orientation.
73
+ // smoothstep antialiases the edge over one screen pixel of
74
+ // procedural-space.
75
+ float coverage = smoothstep(dp, -dp, p * w);
76
+ if (coverage <= 0.0) discard;
77
+ // Premultiplied output to match the context's premultipliedAlpha
78
+ // contract + blendFunc(ONE, 1-SRC_ALPHA).
79
+ float a = coverage * uOpacity;
80
+ fragColor = vec4(uColor * a, a);
81
+ }`;var fy=class{gl;program;vbo;aPos;aLocal;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=rn(t,t.VERTEX_SHADER,rq,"Ellipse"),o=rn(t,t.FRAGMENT_SHADER,sq,"Ellipse");this.program=Na(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=Jn(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,b=i,y=new Float32Array([b.a*u*h,b.b*u*m,0,b.c*d*h,b.d*d*m,0,(b.a*f+b.c*p+b.e)*h-1,(b.b*f+b.d*p+b.f)*m+1,1]);c.uniformMatrix3fv(this.uTransform,!1,y),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)}},rq=`#version 300 es
82
+ in vec2 aPos;
83
+ in vec2 aLocal;
84
+ uniform mat3 uTransform;
85
+ out vec2 vLocal;
86
+ void main() {
87
+ vec3 p = uTransform * vec3(aPos, 1.0);
88
+ gl_Position = vec4(p.xy, 0.0, 1.0);
89
+ vLocal = aLocal;
90
+ }`,sq=`#version 300 es
91
+ precision mediump float;
92
+ uniform vec3 uColor;
93
+ uniform float uOpacity;
94
+ in vec2 vLocal;
95
+ out vec4 fragColor;
96
+ void main() {
97
+ float r2 = dot(vLocal, vLocal);
98
+ float dr = fwidth(r2);
99
+ float coverage = smoothstep(1.0 + dr, 1.0 - dr, r2);
100
+ if (coverage <= 0.0) discard;
101
+ float a = coverage * uOpacity;
102
+ fragColor = vec4(uColor * a, a);
103
+ }`;var hy=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";currentPolyline=[];currentCurves=[];currentEllipse=null;transform={a:1,b:0,c:0,d:1,e:0,f:0};stack=[];constructor(t,n,o){let a=t.getContext("webgl2",{antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!0});if(a??=t.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:!0}),!a)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=a,this._size={width:n,height:o};let r=rn(this.gl,this.gl.VERTEX_SHADER,yq,"WebGL2"),s=rn(this.gl,this.gl.FRAGMENT_SHADER,gq,"WebGL2");this.program=Na(this.gl,r,s,"WebGL2"),this.gl.useProgram(this.program),this.vbo=Jn(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=Jn(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._size.width=t,this._size.height=n,this.gl.viewport(0,0,t,n)}dispose(){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=Cv(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.currentPolyline=[],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.currentPolyline=[{x:t,y:n}]}lineTo(t,n){this.currentPolyline.push({x:t,y:n})}closePath(){let t=this.currentPolyline[0];this.currentPolyline.length>1&&t!==void 0&&this.currentPolyline.push({...t})}ellipse(t,n,o,a){this.currentEllipse={cx:t,cy:n,rx:o,ry:a},this.currentPolyline=[],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.currentPolyline=[];for(let r=0;r<=a;r++){let s=r/a*Math.PI*2;this.currentPolyline.push({x:t.cx+t.rx*Math.cos(s),y:t.cy+t.ry*Math.sin(s)})}}quadraticCurveTo(t,n,o,a){let r=this.currentPolyline[this.currentPolyline.length-1]??{x:t,y:n};this.currentCurves.push({kind:"q",points:[r,{x:t,y:n},{x:o,y:a}]});let s=this.currentFlattenTolerance(),i=c0();if(i){let u=i.flatten([{kind:"M",to:r},{kind:"Q",control:{x:t,y:n},to:{x:o,y:a}}],s);for(let d=1;d<u.length;d++)this.currentPolyline.push(L(u[d]));return}let l=Math.max(8,Math.min(128,Math.ceil(i6(r,{x:o,y:a})/s))),c=dq(r,{x:t,y:n},{x:o,y:a},l);for(let u=1;u<c.length;u++)this.currentPolyline.push(L(c[u]))}bezierCurveTo(t,n,o,a,r,s){let i=this.currentPolyline[this.currentPolyline.length-1]??{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=c0();if(c){let f=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 p=1;p<f.length;p++)this.currentPolyline.push(L(f[p]));return}let u=Math.max(12,Math.min(192,Math.ceil(i6(i,{x:r,y:s})/l))),d=fq(i,{x:t,y:n},{x:o,y:a},{x:r,y:s},u);for(let f=1;f<d.length;f++)this.currentPolyline.push(L(d[f]))}currentFlattenTolerance(){let t=Math.hypot(this.transform.a,this.transform.b);return!Number.isFinite(t)||t<=0?s6:s6/t}drawImage(t,n,o,a,r,s){let i=this.textureFor(t,s??!1);if(!i)return;this.imageProgram||(this.imageProgram=hq(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 l=this.imageProgram;this.gl.useProgram(l.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.enableVertexAttribArray(l.aPos),this.gl.vertexAttribPointer(l.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(l.aUV),this.gl.vertexAttribPointer(l.aUV,2,this.gl.FLOAT,!1,16,8);let c=pq({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(l.uTransform,!1,c),this.gl.uniform1f(l.uOpacity,this.opacity),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(l.uTex,0),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.restoreSolidProgram()}imageProgram=null;imageQuadVbo=null;textures=new Map;textureFor(t,n){if(!oy(t))return ay(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(iq(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.ellipsePipeline??=new fy(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=mq({a:this.transform.a*o.width,b:this.transform.b*o.width,c:this.transform.c*o.height,d:this.transform.d*o.height,e:this.transform.e+this.transform.a*o.x+this.transform.c*o.y,f:this.transform.f+this.transform.b*o.x+this.transform.d*o.y},this._size.width,this._size.height);this.restoreSolidProgram(),this.gl.uniformMatrix3fv(this.uTransformLoc,!1,a),this.gl.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),this.gl.uniform1f(this.uOpacityLoc,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);return}this.currentPolyline.length>=3&&this.fillPolygonEarcut(this.currentPolyline,n),this.currentCurves.length>0&&(this.curvePipeline??=new dy(this.gl),this.curvePipeline.draw(this.currentCurves,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram())}}curvePipeline=null;ellipsePipeline=null;fillPolygonEarcut(t,n){let o=t[0],a=t[t.length-1],r=t.length>=4&&o!==void 0&&o.x===a?.x&&o.y===a.y?t.length-1:t.length;if(r<3)return;r6(r);let s=py;for(let f=0;f<r;f++){let p=L(t[f]);s[f*2]=p.x,s[f*2+1]=p.y}let i=_v(s.subarray(0,r*2));if(i.length===0){this.drawTriangleFan(t,r,n);return}let l=2/this._size.width,c=-2/this._size.height,u=Mv;for(let f=0;f<r;f++){let p=L(t[f]),h=this.transform.a*p.x+this.transform.c*p.y+this.transform.e,m=this.transform.b*p.x+this.transform.d*p.y+this.transform.f;u[f*2]=h*l-1,u[f*2+1]=m*c+1}cq(i.length);for(let f=0;f<i.length;f++)bp[f]=L(i[f]);let d=this.gl;d.useProgram(this.program),d.bindBuffer(d.ARRAY_BUFFER,this.dynamicVbo),d.bufferData(d.ARRAY_BUFFER,u.subarray(0,r*2),d.DYNAMIC_DRAW),d.enableVertexAttribArray(this.aPosLoc),d.vertexAttribPointer(this.aPosLoc,2,d.FLOAT,!1,0,0),d.uniformMatrix3fv(this.uTransformLoc,!1,Ev),d.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),d.uniform1f(this.uOpacityLoc,n),this.indexBuffer??=d.createBuffer(),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,this.indexBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,bp.subarray(0,i.length),d.DYNAMIC_DRAW),d.drawElements(d.TRIANGLES,i.length,d.UNSIGNED_SHORT,0),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;r6(n);let s=Mv;for(let l=0;l<n;l++){let c=L(t[l]),u=this.transform.a*c.x+this.transform.c*c.y+this.transform.e,d=this.transform.b*c.x+this.transform.d*c.y+this.transform.f;s[l*2]=u*a-1,s[l*2+1]=d*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,Ev),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){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=Cv(t);this.strokeColor=[n[0],n[1],n[2]],this.strokeAlpha=n[3]}setStrokeWidth(t){this.strokeWidth=Math.max(0,t)}stroke(){if(this.currentPath){let o=this.currentPath;this.currentPolyline=[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height},{x:o.x,y:o.y}]}if(this.currentEllipse&&this.currentPolyline.length<2&&this.buildEllipseStrokePolyline(this.currentEllipse),this.currentPolyline.length<2)return;let t=this.opacity*this.strokeAlpha;if(t<=0)return;let n=this.dashArray?lq(this.currentPolyline,this.dashArray):[this.currentPolyline];for(let o of n)o.length<2||o6(this.gl,o,{width:this.strokeWidth,color:this.strokeColor,opacity:t,join:this.lineJoin,cap:this.lineCap},this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.aPosLoc,Ev);this.restoreSolidProgram()}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;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=rA();return!t||!uq(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new hp(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new ly(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)}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(){return`${this.fontSize}px "${kc(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"),r=0;for(let s of t){let i=s.codePointAt(0);if(i===void 0)continue;let l=n.getOrRasterize(i,a);l&&(r+=l.advance*this.fontSize/l.unitsPerEm)}return{width:r}}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))}}}},iq=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},lq=(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=L(e[i]),c=L(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),b={x:p.x+d*m,y:p.y+f*m};r&&s.push(b),p=b,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},py=new Float64Array(128),Mv=new Float32Array(128),bp=new Uint16Array(256),r6=e=>{let t=e*2;if(py.length>=t)return;let n=py.length;for(;n<t;)n*=2;py=new Float64Array(n),Mv=new Float32Array(n)},cq=e=>{if(bp.length>=e)return;let t=bp.length;for(;t<e;)t*=2;bp=new Uint16Array(t)},Ev=new Float32Array([1,0,0,0,1,0,0,0,1]),s6=.5,uq=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},i6=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),dq=(e,t,n,o)=>{let a=[];for(let r=0;r<=o;r++){let s=r/o,i=1-s;a.push({x:i*i*e.x+2*i*s*t.x+s*s*n.x,y:i*i*e.y+2*i*s*t.y+s*s*n.y})}return a},fq=(e,t,n,o,a)=>{let r=[];for(let s=0;s<=a;s++){let i=s/a,l=1-i,c=l*l,u=c*l,d=i*i,f=d*i;r.push({x:u*e.x+3*c*i*t.x+3*l*d*n.x+f*o.x,y:u*e.y+3*c*i*t.y+3*l*d*n.y+f*o.y})}return r},pq=(e,t,n)=>{let o=2/t,a=-2/n;return new Float32Array([e.a*o,e.b*a,0,e.c*o,e.d*a,0,e.e*o-1,e.f*a+1,1])},hq=e=>{let t=rn(e,e.VERTEX_SHADER,`#version 300 es
104
+ in vec2 aPos;
105
+ in vec2 aUV;
106
+ uniform mat3 uTransform;
107
+ out vec2 vUV;
108
+ void main() {
109
+ vec3 p = uTransform * vec3(aPos, 1.0);
110
+ gl_Position = vec4(p.xy, 0.0, 1.0);
111
+ vUV = aUV;
112
+ }`,"WebGL2"),n=rn(e,e.FRAGMENT_SHADER,`#version 300 es
113
+ precision mediump float;
114
+ in vec2 vUV;
115
+ uniform sampler2D uTex;
116
+ uniform float uOpacity;
117
+ out vec4 fragColor;
118
+ void main() {
119
+ // The texture is uploaded with UNPACK_PREMULTIPLY_ALPHA_WEBGL=true,
120
+ // so t.rgb is already premultiplied by t.a. Output stays
121
+ // premultiplied for blendFunc(ONE, 1-SRC_ALPHA) \u2014 scale both
122
+ // channels by the per-call opacity.
123
+ vec4 t = texture(uTex, vUV);
124
+ fragColor = vec4(t.rgb * uOpacity, t.a * uOpacity);
125
+ }`,"WebGL2"),o=Na(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")}},mq=(e,t,n)=>{let o=2/t,a=-2/n;return new Float32Array([e.a*o,e.b*a,0,e.c*o,e.d*a,0,e.e*o-1,e.f*a+1,1])},yq=`#version 300 es
126
+ in vec2 aPos;
127
+ uniform mat3 uTransform;
128
+ void main() {
129
+ vec3 p = uTransform * vec3(aPos, 1.0);
130
+ gl_Position = vec4(p.xy, 0.0, 1.0);
131
+ }`,gq=`#version 300 es
132
+ precision mediump float;
133
+ uniform vec3 uColor;
134
+ uniform float uOpacity;
135
+ out vec4 fragColor;
136
+ void main() {
137
+ // Output premultiplied (rgb*a, a) \u2014 matches the context's
138
+ // premultipliedAlpha:true contract + blendFunc(ONE, 1-SRC_ALPHA).
139
+ fragColor = vec4(uColor * uOpacity, uOpacity);
140
+ }`;var my=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",Ov=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new wc(o,e,t);return{canvas:n,target:a}};var Cc=(e,t,n,o=window.devicePixelRatio||1,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};var Ap=class{host;layers;canvases;width;height;dprOverride;constructor(t,n,o,a={}){this.host=t,this.width=n,this.height=o,this.dprOverride=a.dpr,getComputedStyle(t).position==="static"&&(t.style.position="relative");let r=a.layers??Ks,s=new Map,i=new Map;for(let l of Ks){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=Cc(c,n,o,this.dprOverride),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new wc(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=Cc(a,t,n,this.dprOverride),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 Rv=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var yy=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new Ef(64);nextImageId=0;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.commands.push({k:"resize",w:t,h:n})}flush(){let t=this.commands;return this.commands=[],t}peek(){return this.commands}setFill(t){this.commands.push({k:"setFill",color:t})}setStroke(t){this.commands.push({k:"setStroke",color:t})}setStrokeWidth(t){this.commands.push({k:"setStrokeWidth",w:t})}setOpacity(t){this.commands.push({k:"setOpacity",a:t})}setLineCap(t){this.commands.push({k:"setLineCap",cap:t})}setLineJoin(t){this.commands.push({k:"setLineJoin",join:t})}setDashArray(t){this.commands.push({k:"setDashArray",dash:t})}setFont(t,n,o){this.commands.push({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 "${kc(t)}", ${t}`}setTextAlign(t){this.commands.push({k:"setTextAlign",align:t})}setTextBaseline(t){this.commands.push({k:"setTextBaseline",baseline:t})}save(){this.commands.push({k:"save"})}restore(){this.commands.push({k:"restore"})}translate(t,n){this.commands.push({k:"translate",x:t,y:n})}rotate(t){this.commands.push({k:"rotate",r:t})}scale(t,n){this.commands.push({k:"scale",sx:t,sy:n})}setTransform(t){this.commands.push({k:"setTransform",t})}resetTransform(){this.commands.push({k:"resetTransform"})}beginPath(){this.commands.push({k:"beginPath"})}closePath(){this.commands.push({k:"closePath"})}moveTo(t,n){this.commands.push({k:"moveTo",x:t,y:n})}lineTo(t,n){this.commands.push({k:"lineTo",x:t,y:n})}quadraticCurveTo(t,n,o,a){this.commands.push({k:"quadraticCurveTo",cx:t,cy:n,x:o,y:a})}bezierCurveTo(t,n,o,a,r,s){this.commands.push({k:"bezierCurveTo",c1x:t,c1y:n,c2x:o,c2y:a,x:r,y:s})}rect(t,n,o,a){this.commands.push({k:"rect",x:t,y:n,w:o,h:a})}ellipse(t,n,o,a){this.commands.push({k:"ellipse",cx:t,cy:n,rx:o,ry:a})}fill(t){this.commands.push(t!==void 0?{k:"fill",rule:t}:{k:"fill"})}stroke(){this.commands.push({k:"stroke"})}fillText(t,n,o,a){this.commands.push(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.commands.push({k:"defineImage",id:i,bitmap:t})),this.commands.push({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r})}else this.skippedImageDraws++}clear(t){this.commands.push(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.commands.push({k:"markDirty",bounds:t})}};var Dv=(e,t,n,o={})=>{switch(o.backend??"canvas2d"){case"canvas2d":return new Pv(e,t,n);case"webgl2":return new Bv(e,t,n);case"offscreen":if(!o.workerFactory)throw new Error("createLayeredSurface: workerFactory is required for the offscreen backend");return new zv(e,t,n,o.workerFactory,o.onWorkerError)}},Nv=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:Dv(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:Dv(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},Pv=class{backend="canvas2d";inner;constructor(t,n,o){this.inner=new Ap(t,n,o)}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()}},Bv=class{backend="webgl2";base;mainCanvas;mainTarget;_width;_height;constructor(t,n,o){this._width=n,this._height=o,this.base=new Ap(t,n,o,{layers:Ks.filter(s=>s!=="main")});let a=this.base.getCanvas("overlay"),r=t.ownerDocument.createElement("canvas");r.dataset.layer="main",r.dataset.backend="webgl2",r.style.position="absolute",r.style.inset="0",r.style.pointerEvents="none",t.insertBefore(r,a),Cc(r,n,o,window.devicePixelRatio||1,!1);try{this.mainCanvas=r,this.mainTarget=new hy(r,n,o)}catch(s){throw r.remove(),this.base.dispose(),s}}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),Cc(this.mainCanvas,t,n,window.devicePixelRatio||1,!1),this.mainTarget.resize(t,n))}get size(){return{width:this._width,height:this._height}}present(){}dispose(){this.mainTarget.dispose(),this.mainCanvas.remove(),this.base.dispose()}},zv=class{backend="offscreen";canvases=new Map;targets=new Map;workers=new Map;_width;_height;dpr;constructor(t,n,o,a,r){this._width=n,this._height=o,this.dpr=typeof window<"u"&&window.devicePixelRatio||1,getComputedStyle(t).position==="static"&&(t.style.position="relative");let s=!1,i=l=>{s||(s=!0,r?.(l))};try{for(let l of Ks){let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.dataset.backend="offscreen",c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",c.style.width=`${n}px`,c.style.height=`${o}px`,t.appendChild(c);let u=a();u.onerror=f=>{i(f)};let d=c.transferControlToOffscreen();u.postMessage({type:"init",canvas:d,width:n,height:o,dpr:this.dpr},[d]),this.canvases.set(l,c),this.workers.set(l,u),this.targets.set(l,new yy(n,o))}}catch(l){throw this.dispose(),l}}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})}}get size(){return{width:this._width,height:this._height}}present(){for(let[t,n]of this.targets){let o=n.flush();o.length!==0&&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 Fv=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},Hv=()=>{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 l6=(0,Se.createContext)(null),Uv=({initialScene:e,initialMode:t,children:n,onReady:o,skipInstallRenderers:a,renderer:r="canvas2d",workerFactory:s,textShaper:i,rasterizer:l})=>{let[c,u]=(0,Se.useState)(null),d=(0,Se.useRef)(null),f=(0,Se.useRef)(null),p=(0,Se.useRef)(null),h=(0,Se.useRef)(null),m=(0,Se.useRef)(null),b=(0,Se.useRef)(!1),y=(0,Se.useRef)(()=>{}),g=(0,Se.useRef)(r),x=(0,Se.useRef)(s),A=(0,Se.useRef)(i),C=(0,Se.useRef)(l);g.current=r,x.current=s,A.current=i,C.current=l;let _=(0,Se.useCallback)(T=>{a||oc();let{width:P,height:N}=T.getBoundingClientRect(),{surface:U,effectiveBackend:q}=Nv(T,P,N,{backend:b.current?"canvas2d":g.current,...x.current?{workerFactory:x.current}:{},onWorkerError:$=>{y.current($)}},($,re)=>{console.warn(`[DiagramRoot] ${$} renderer unavailable, falling back to canvas2d:`,re)});T.dataset.effectiveBackend=q;let te={host:T,mainTarget:U.get("main"),overlayTarget:U.get("overlay"),backgroundTarget:U.get("background"),onAfterRender:()=>f.current?.present(),initialScene:e,...t!==void 0?{initialMode:t}:{},...A.current?{textShaper:A.current}:{},...C.current?{rasterizer:C.current}:{}},Z=new Xf(te);Z.setViewportSize(P,N),f.current=U,d.current=Z,u(Z),o?.(Z),U.present();let ue=new ResizeObserver(()=>{let $=T.getBoundingClientRect();U.resize($.width,$.height),Z.setViewportSize($.width,$.height),Z.forceRender()});ue.observe(T),p.current=ue},[]),v=(0,Se.useCallback)(()=>{p.current?.disconnect(),p.current=null,m.current?.(),m.current=null,d.current?.dispose(),d.current=null,f.current?.dispose(),f.current=null},[]);y.current=T=>{if(b.current)return;b.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",T);let P=h.current;P&&(v(),_(P))};let I=(0,Se.useCallback)(T=>{if(v(),h.current=T,!T){u(null);return}_(T)},[_,v]),k=(0,Se.useRef)(null);return(0,Se.useEffect)(()=>{let T=h.current;if(T){if(k.current===null){k.current=r;return}k.current!==r&&(k.current=r,b.current=!1,v(),_(T))}},[r,_,v]),(0,Se.useLayoutEffect)(()=>()=>{v(),h.current=null},[v]),(0,jr.jsx)(S_.Provider,{value:c,children:(0,jr.jsx)(l6.Provider,{value:I,children:(0,jr.jsxs)(M8,{children:[n,(0,jr.jsx)(xq,{editor:c})]})})})},xq=({editor:e})=>{let[t,n]=(0,Se.useState)("");return(0,Se.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,jr.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})},Gv=({style:e,className:t,ariaLabel:n})=>{let o=(0,Se.useContext)(l6),a=(0,Se.useRef)(null);if((0,Se.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,jr.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 Tc=2,Rt=w.object({x:w.number(),y:w.number()}),kde=w.object({x:w.number(),y:w.number(),width:w.number(),height:w.number()}),bq=w.object({type:w.enum(["sharp","round"]),value:w.number().optional()}).strict(),bo=w.object({fill:w.string().optional(),stroke:w.string().optional(),strokeWidth:w.number().optional(),opacity:w.number().optional(),dashArray:w.array(w.number()).readonly().optional(),lineCap:w.enum(["butt","round","square"]).optional(),lineJoin:w.enum(["miter","round","bevel"]).optional(),strokeAlign:w.enum(["center","inside","outside"]).optional(),roundness:bq.optional()}).strict(),Aq=bo.extend({textAlign:w.enum(["left","center","right"]).optional(),textBaseline:w.enum(["top","middle","bottom"]).optional(),fontWeight:w.enum(["normal","bold"]).optional(),fontStyle:w.enum(["normal","italic"]).optional(),textDecoration:w.object({underline:w.boolean().optional(),strikethrough:w.boolean().optional()}).strict().optional()}).strict(),d6=w.record(w.string(),w.unknown()).optional(),vq=w.string(),f6=w.discriminatedUnion("kind",[w.object({kind:w.literal("named"),name:vq}).strict(),w.object({kind:w.literal("ratio"),position:Rt}).strict(),w.object({kind:w.literal("absolute"),offset:Rt}).strict(),w.object({kind:w.literal("edge"),index:w.number().int().nonnegative(),t:w.number()}).strict()]),Vo=w.object({id:w.string(),layerId:w.string(),position:Rt,rotation:w.number(),scale:Rt,order:w.string(),metadata:d6,minWidth:w.number().optional(),minHeight:w.number().optional(),maxWidth:w.number().optional(),maxHeight:w.number().optional(),noFlip:w.boolean().optional(),anchors:w.record(w.string(),f6).optional(),parentId:w.string().optional(),frameId:w.string().optional(),href:w.string().optional()}),Lq=Vo.extend({type:w.literal("rectangle"),style:bo,width:w.number(),height:w.number()}).strict(),Sq=Vo.extend({type:w.literal("ellipse"),style:bo,width:w.number(),height:w.number()}).strict(),kq=Vo.extend({type:w.literal("polygon"),style:bo,points:w.array(Rt)}).strict(),wq=w.discriminatedUnion("kind",[w.object({kind:w.literal("M"),to:Rt}).strict(),w.object({kind:w.literal("L"),to:Rt}).strict(),w.object({kind:w.literal("Q"),control:Rt,to:Rt}).strict(),w.object({kind:w.literal("C"),control1:Rt,control2:Rt,to:Rt}).strict(),w.object({kind:w.literal("Z")}).strict()]),_q=Vo.extend({type:w.literal("path"),style:bo,commands:w.array(wq)}).strict(),Cq=Vo.extend({type:w.literal("text"),style:Aq,text:w.string(),fontFamily:w.string(),fontSize:w.number(),maxWidth:w.number().optional()}).strict(),Tq=Vo.extend({type:w.literal("image"),style:bo,src:w.string(),width:w.number(),height:w.number(),fileId:w.string().optional(),animationKind:w.string().optional(),animationData:w.unknown().optional()}).strict(),Iq=Vo.extend({type:w.literal("template"),style:bo.optional(),templateId:w.string(),data:w.record(w.string(),w.unknown()),width:w.number(),height:w.number()}).strict(),Eq=Vo.extend({type:w.literal("group"),style:bo.optional()}).strict(),Mq=w.object({x:w.number(),y:w.number(),width:w.number()}).strict(),Oq=Vo.extend({type:w.literal("brush"),style:bo,points:w.array(Mq)}).strict(),Rq=Vo.extend({type:w.string(),style:bo.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"}),Dq=w.union([Lq,Sq,kq,_q,Cq,Tq,Iq,Eq,Oq,Rq]),c6=w.discriminatedUnion("kind",[w.object({kind:w.literal("point"),position:Rt}).strict(),w.object({kind:w.literal("anchor"),elementId:w.string(),anchor:f6}).strict(),w.object({kind:w.literal("outline"),elementId:w.string(),ratio:w.number()}).strict(),w.object({kind:w.literal("floating"),elementId:w.string()}).strict()]),Pq=w.enum(["straight","orthogonal","bezier"]),u6=w.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),Bq=w.object({from:u6.optional(),to:u6.optional(),size:w.number().optional()}).strict(),zq=w.object({text:w.string(),position:w.number().optional(),fontSize:w.number().optional(),fill:w.string().optional(),background:w.string().optional()}).strict(),Nq=w.object({id:w.string(),layerId:w.string(),from:c6,to:c6,waypoints:w.array(Rt).readonly().optional(),routedPoints:w.array(Rt).readonly().optional(),fixedSegments:w.array(w.object({axis:w.enum(["h","v"]),pos:w.number(),at:w.number()}).strict()).readonly().optional(),routing:Pq.optional(),avoidObstacles:w.boolean().optional(),arrowheads:Bq.optional(),label:zq.optional(),order:w.string(),style:bo,metadata:d6}).strict(),Fq=w.object({id:w.string(),name:w.string(),visible:w.boolean(),locked:w.boolean(),order:w.string()}).strict(),Hq=w.object({pan:Rt,zoom:w.number(),rotation:w.number(),size:w.object({width:w.number(),height:w.number()}).strict(),gridEnabled:w.boolean(),gridStyle:w.enum(["lines","dots"]).optional(),snapToGrid:w.boolean().optional()}).strict(),Uq=w.object({id:w.string(),authorId:w.string(),authorName:w.string(),body:w.string(),createdAt:w.string()}).strict(),Gq=w.object({id:w.string(),elementId:w.string().nullable(),position:Rt,resolved:w.boolean(),thread:w.array(Uq),createdAt:w.string()}).strict(),p6=w.object({format:w.literal("oh-just-another/scene"),version:w.number().int().nonnegative(),elements:w.array(Dq),links:w.array(Nq),layers:w.array(Fq),annotations:w.array(Gq).optional(),viewport:Hq}).strict();var h6=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:Tc,elements:[...e.elements.values()].map(qq),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},qq=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},qv=(e,t=null)=>JSON.stringify(h6(e),null,t??void 0);var m6=new Map,y6=(e,t)=>{m6.set(e,t)},g6=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=m6.get(a);if(!r)throw new Wv(a,n);o=r(o)}return o},Wv=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 Wq=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}};y6(1,Wq);var Ic=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},x6=(e,t={})=>{if(typeof e!="object"||e===null)throw new Ic("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??Tc;if(o>a)throw new Ic(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===Tc?e:g6(e,o,Tc),s;try{s=p6.parse(r)}catch(i){throw i instanceof w.ZodError?new Ic(`Invalid scene document: ${i.message}`,i):i}return jq(s)},jv=(e,t)=>x6(JSON.parse(e),t),jq=e=>{let t=new Map;for(let s of e.elements){let i=Qe(s.id);t.set(i,Vq(s,i))}let n=new Map;for(let s of e.links){let i=E1(s.id);n.set(i,Zq(s,i))}let o=new Map;for(let s of e.layers){let i=$t(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Ud(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Hd(s.id);r.set(i,{id:i,elementId:s.elementId===null?null:Qe(s.elementId),position:s.position,resolved:s.resolved,thread:s.thread.map(l=>({id:Tl(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}},Vq=(e,t)=>({...Ud(e),id:t,layerId:$t(e.layerId),order:e.order}),Zq=(e,t)=>{let n=s=>s.kind==="anchor"||s.kind==="outline"||s.kind==="floating"?{...s,elementId:Qe(s.elementId)}:s,o=n(e.from),a=n(e.to);return{...Ud(e),id:t,layerId:$t(e.layerId),order:e.order,from:o,to:a}};var Ec=F(ye(),1),Fa=F(he(),1);var Xq=[0,50,90],Vv=({children:e,snapPoints:t=Xq,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,Fa.useState)(()=>o??t.find(b=>b>0)??50),c=n??i,u=(0,Fa.useCallback)(b=>{l(b),a?.(b)},[a]),d=(0,Fa.useRef)(null),f=(0,Fa.useRef)(null),p=b=>{d.current={startY:b.clientY,startHeight:c,pointerId:b.pointerId},b.target.setPointerCapture?.(b.pointerId)},h=b=>{if(d.current?.pointerId!==b.pointerId)return;let y=window.innerHeight||1,g=(d.current.startY-b.clientY)/y*100,x=Il.clamp(d.current.startHeight+g,0,100);u(x)},m=b=>{if(d.current?.pointerId!==b.pointerId)return;d.current=null;let y=t[0];if(y===void 0)return;let g=Math.abs(c-y);for(let x of t){let A=Math.abs(c-x);A<g&&(y=x,g=A)}u(y)};return(0,Fa.useEffect)(()=>{let b=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[u,t]),(0,Ec.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,Ec.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,Ec.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,Ec.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var b6=F(ye(),1),Ha=F(he(),1);var Zv=()=>{let e=j(),t=(0,Ha.useRef)(null),[,n]=(0,Ha.useReducer)(c=>c+1,0);(0,Ha.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,Ha.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,Ha.useLayoutEffect)(()=>{let c=t.current;if(!e||!o||!c)return;let u=M(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=M(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,b6.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 A6=F(ye(),1),Ti=F(he(),1);var Xv=()=>{let e=j(),t=(0,Ti.useRef)(null),[,n]=(0,Ti.useReducer)(d=>d+1,0);(0,Ti.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,Ti.useEffect)(()=>{if(!o)return;let d=t.current;d&&(d.focus(),d.select())},[o]),!e||!o)return null;let a=M(e.scene,o);if(!a||!He(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,A6.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 Mc=F(ye(),1),Zr=F(he(),1),S6=F(Yo(),1);var Vr=F(he(),1),v6=e=>{let t=(0,Vr.useRef)(null),n=(0,Vr.useRef)(e);n.current=e;let o=(0,Vr.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,Vr.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,Vr.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var L6=220,Yv=()=>{let e=j(),[t,n]=(0,Zr.useState)(null),[,o]=(0,Zr.useReducer)(m=>m+1,0),a=(0,Zr.useRef)(!1),r=Et(),{schedule:s,cancel:i}=v6(()=>{a.current||n(null)});if((0,Zr.useEffect)(()=>{if(!e)return;let m=e.hostElement;if(!m)return;let b=x=>{if(e.editingTextElement!==null){n(null);return}let A=m.getBoundingClientRect(),C=e.screenToWorld({x:x.clientX-A.left,y:x.clientY-A.top}),_=e.linkAt(C);_?(i(),n({href:_.href,bounds:_.bounds})):a.current||s(L6)},y=()=>{s(L6)};m.addEventListener("pointermove",b),m.addEventListener("pointerleave",y);let g=e.on("change",()=>{o()});return()=>{m.removeEventListener("pointermove",b),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,S6.createPortal)((0,Mc.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,Mc.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,Mc.jsx)("span",{className:"du-link-popup-text",children:h}),(0,Mc.jsx)(Ju,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var Xr=F(ye(),1),gy=F(he(),1),k6=F(Yo(),1);var Kv=()=>{let e=j(),[,t]=(0,gy.useReducer)(u=>u+1,0),n=Et();if((0,gy.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=ai.byCategory("basic");return(0,k6.createPortal)((0,Xr.jsxs)(Xr.Fragment,{children:[(0,Xr.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,Xr.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,Xr.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 w6=F(ye(),1),Ua=F(he(),1),_6=F(Yo(),1);var $v=()=>{let e=j(),[,t]=(0,Ua.useReducer)(h=>h+1,0),[n,o]=(0,Ua.useState)(""),a=(0,Ua.useRef)(null),r=Et();(0,Ua.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,Ua.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,_6.createPortal)((0,w6.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 mt=F(ye(),1),xy=F(he(),1);var Yq=16,Kq=1.75,Qv={size:Yq,strokeWidth:Kq},$q={"mode-select":gd,"mode-hand":id,"mode-rect":xa,"mode-ellipse":Ku,"mode-text":Id,"mode-edge":wd,"mode-brush":vr,"mode-frame":ad,"insert-image":Cs,"tool-lock":fd,undo:Es,redo:Is},Qq=({id:e})=>{let t=j(),[,n]=(0,xy.useState)(0);(0,xy.useEffect)(()=>{if(t)return t.on("change",()=>{n(d=>d+1)})},[t]);let o=st.get(e);if(!o)return null;let a=o.iconId?$q[o.iconId]:void 0,r=t?{editor:t}:null,s=r?o.checked?.(r)??!1:!1,i=r?o.predicate?o.predicate(r):!0:!1,c=(o.hotkey===void 0?[]:Array.isArray(o.hotkey)?o.hotkey:[o.hotkey])[0],u=`${o.label??e}${c?` (${Bt(c)})`:""}`;return(0,mt.jsx)(Oc,{title:u,active:s,disabled:!i,onClick:()=>{t&&st.dispatch(e,{editor:t})},children:a?(0,mt.jsx)(a,{...Qv}):o.label??e})},ffe=Bt({meta:!0,key:"\u2212"}),pfe=Bt({meta:!0,key:"+"}),hfe=Bt({meta:!0,key:"0"}),mfe=Bt({meta:!0,key:"1"}),Jv=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()},C6=[{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-frame"},{kind:"action",id:"insert-image",label:(0,mt.jsx)(Cs,{...Qv}),title:"Insert image (I)",onClick:e=>{Jv(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],by=[{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-frame"},{kind:"action",id:"insert-image",label:(0,mt.jsx)(Cs,{...Qv}),title:"Insert image (I)",onClick:e=>{Jv(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],eL=({items:e=C6,style:t,className:n,orientation:o="horizontal"})=>{let a=j(),r=QA(),{canUndo:s,canRedo:i,undo:l,redo:c}=JA(),u=o==="vertical";return(0,mt.jsx)("div",{role:"toolbar","aria-orientation":o,className:`du-button-group${u?" du-button-group-vertical":""} ${n??""}`.trim(),style:t,children:e.map((d,f)=>{switch(d.kind){case"divider":return(0,mt.jsx)(eW,{vertical:u},f);case"action-ref":return(0,mt.jsx)(Qq,{id:d.id},f);case"mode":{let p=r===d.mode;return(0,mt.jsx)(Oc,{...d.title!==void 0?{title:d.title}:{},disabled:!a,active:p,onClick:()=>a?.setMode(d.mode),children:d.label},f)}case"action":return(0,mt.jsx)(Oc,{...d.title!==void 0?{title:d.title}:{},disabled:d.disabled??!a,active:d.active,onClick:()=>{a&&d.onClick(a)},children:d.label},f);case"undo":return(0,mt.jsx)(Oc,{disabled:!s,onClick:l,children:d.label??"Undo"},f);case"redo":return(0,mt.jsx)(Oc,{disabled:!i,onClick:c,children:d.label??"Redo"},f);case"tool-lock":return(0,mt.jsx)(Jq,{...d.label!==void 0?{label:d.label}:{},...d.title!==void 0?{title:d.title}:{}},f)}})})},Jq=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=j(),o=Aa(a=>a.toolLocked,!1);return(0,mt.jsx)(Oc,{disabled:!n,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var Oc=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,mt.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,mt.jsx)(Ms,{content:a,children:i}):i},eW=({vertical:e=!1})=>e?(0,mt.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,mt.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var tL=.5522847498307936,T6=.55;var tW={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},I6=(e,t,n)=>{let o=0;for(let a of e)o+=(tW[a]??T6)*n;return o};var Ay=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=B.IDENTITY;pathSegments=[];pathCursor=null;elements=[];stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??I6}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=B.multiply(this.currentTransform,B.translation(t,n))}rotate(t){this.currentTransform=B.multiply(this.currentTransform,B.rotation(t))}scale(t,n){this.currentTransform=B.multiply(this.currentTransform,B.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=B.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${it(o.x)} ${it(o.y)}`),this.pathCursor=o}lineTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`L${it(o.x)} ${it(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${it(r.x)} ${it(r.y)} ${it(s.x)} ${it(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${it(i.x)} ${it(i.y)} ${it(l.x)} ${it(l.y)} ${it(c.x)} ${it(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*tL,s=a*tL;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="${it(r.x)}"`,`y="${it(r.y)}"`,`font-family="${E6(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}>${oW(t)}</text>`)}measureText(t){return{width:this.measure(t,this.fontFamily,this.fontSize)}}drawImage(t,n,o,a,r){if(typeof t!="string"||t==="")return;let s=this.apply(n,o);this.elements.push(`<image x="${it(s.x)}" y="${it(s.y)}" width="${a}" height="${r}" href="${E6(t)}"/>`)}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="${it(a)}" y="${it(r)}" width="${s}" height="${i}" fill="#fff"/>`)}apply(t,n){return B.applyToPoint(this.currentTransform,{x:t,y:n})}},it=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),E6=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),oW=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");var nL=(e,t={})=>{t.skipInstall||oc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Ay({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Js(e,a,t),No(e,a),a.toSvg()};var Yr=F(ye(),1),Zo=F(he(),1),M6=F(Yo(),1);var oL=({items:e,style:t,className:n})=>{let o=j(),a=ey(),r=Et(),[s,i]=(0,Zo.useState)(null),l=(0,Zo.useRef)(null);(0,Zo.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,Zo.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,Zo.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,Zo.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=rW(d);return f.length===0?null:(0,M6.createPortal)((0,Yr.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,Yr.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,Yr.jsx)(aW,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},aW=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,Yr.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,Yr.jsx)("span",{children:e.label}),e.shortcut?(0,Yr.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},rW=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},aL=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},ke=(e,t)=>{let n=st.get(e),o=n?.predicate,r=(n?.hotkey?Array.isArray(n.hotkey)?n.hotkey:[n.hotkey]:[])[0],s=t?.visible??(o?i=>o({editor:i}):void 0);return{kind:"action",id:e,label:t?.label??n?.label??e,...r?{shortcut:Bt(r)}:{},...s?{visible:s}:{},onClick:i=>{st.dispatch(e,{editor:i})}}},rL=[{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"},ke("delete-selection",{label:"Delete"}),ke("duplicate-selection",{label:"Duplicate"}),ke("copy"),ke("cut"),ke("paste"),ke("copy-style",{label:"Copy style"}),ke("paste-style",{label:"Paste style"}),ke("select-all"),{kind:"divider"},ke("group-selection",{label:"Group"}),ke("ungroup-selection",{label:"Ungroup"}),ke("flip-horizontal",{label:"Flip horizontal"}),ke("flip-vertical",{label:"Flip vertical"}),ke("align-left",{label:"Align left"}),ke("align-h-center",{label:"Align horizontal centres"}),ke("align-right",{label:"Align right"}),ke("align-top",{label:"Align top"}),ke("align-v-center",{label:"Align vertical centres"}),ke("align-bottom",{label:"Align bottom"}),ke("distribute-horizontal",{label:"Distribute horizontally"}),ke("distribute-vertical",{label:"Distribute vertically"}),ke("arrange-grid"),ke("arrange-stack-h"),ke("arrange-stack-v"),ke("auto-arrange"),ke("compact-z-order"),{kind:"divider"},ke("bring-to-front",{visible:e=>e.selection.size===1}),ke("send-to-back",{visible:e=>e.selection.size===1}),{kind:"action",id:"move-to-layer",label:"Move to layer\u2026",visible:e=>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(`
141
+ `),o=window.prompt(`Move selection to layer (1-${t.length}):
142
+ ${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"},ke("zoom-in"),ke("zoom-out"),ke("zoom-reset",{label:"Reset zoom (100%)"}),ke("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.scene.elements.size>0||e.scene.links.size>0,onClick:e=>{aL(e)}}];var Ga=F(ye(),1),Ln=F(he(),1);var sL=()=>{let e=j(),[t,n]=(0,Ln.useState)(!1),[o,a]=(0,Ln.useState)(""),[r,s]=(0,Ln.useState)(0),i=(0,Ln.useRef)(null);(0,Ln.useEffect)(()=>(st.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),st.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})=>{aL(m)}}),()=>{st.unregister("open-command-palette"),st.unregister("clear-canvas")}),[]);let l=(0,Ln.useMemo)(()=>st.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Ln.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,Ln.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Ln.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),st.dispatch(m.action.id,c))},p=m=>{if(m.key==="ArrowDown")m.preventDefault(),s(b=>Math.min(u.length-1,b+1));else if(m.key==="ArrowUp")m.preventDefault(),s(b=>Math.max(0,b-1));else if(m.key==="Enter"){m.preventDefault();let b=u[r];b&&f(b)}},h=(m,b)=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 14px",cursor:b?"pointer":"default",opacity:b?1:.4,background:m===r?"var(--du-ui-hover, rgba(0,0,0,0.06))":"transparent"});return(0,Ga.jsxs)(O0,{open:t,onClose:d,title:"Command palette",style:iW,children:[(0,Ga.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:lW}),(0,Ga.jsx)("ul",{style:cW,role:"listbox",children:u.length===0?(0,Ga.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,b)=>{let y=sW(m.action);return(0,Ga.jsxs)("li",{role:"option","aria-selected":b===r,"aria-disabled":!m.enabled,style:h(b,m.enabled),onPointerEnter:()=>{s(b)},onClick:()=>{f(m)},children:[(0,Ga.jsx)("span",{children:m.action.label}),y?(0,Ga.jsx)("kbd",{style:uW,children:y}):null]},m.action.id)})})]})},sW=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return Bt(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},iW={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},lW={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},cW={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},uW={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var qa=F(ye(),1),Sn=F(he(),1);var dW=(0,Sn.createContext)(null);var iL=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Sn.useState)([]),r=(0,Sn.useRef)(0),s=(0,Sn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Sn.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,Sn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,qa.jsxs)(dW.Provider,{value:l,children:[e,(0,qa.jsx)(fW,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},fW=({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,qa.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,qa.jsx)(hW,{toast:a,onDismiss:t},a.id))})},pW={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},hW=({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 ${pW[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,qa.jsxs)("div",{role:"status",style:n,children:[(0,qa.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,qa.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 qe=F(ye(),1),yt=F(he(),1);var mW=16,yW=1.75,O6=(0,yt.createContext)(null),R6=()=>(0,yt.useContext)(O6)??{close:()=>{}},Q=({children:e,trigger:t=(0,qe.jsx)(hd,{size:mW,strokeWidth:yW}),className:n,style:o})=>{let[a,r]=(0,yt.useState)(!1),s=(0,yt.useRef)(null),i=(0,yt.useId)();(0,yt.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,yt.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,qe.jsxs)("div",{ref:s,className:n,style:c,children:[(0,qe.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,qe.jsx)("div",{id:i,role:"menu",style:u,children:(0,qe.jsx)(O6.Provider,{value:{close:l},children:e})}):null]})},gW={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},lL=e=>({...gW,...e}),xW=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=R6();return(0,qe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...lL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,qe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,qe.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,qe.jsx)(Vu,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,qe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},bW=({children:e,href:t,external:n})=>{let{close:o}=R6();return(0,qe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...lL({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},AW=()=>(0,qe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),vW=({title:e,children:t})=>(0,qe.jsxs)("div",{children:[(0,qe.jsx)("div",{style:{padding:"6px 10px 2px",fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"var(--muted, #888)"},children:e}),t]}),LW=({value:e,onChange:t,options:n})=>(0,qe.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,qe.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)})}),SW=120,kW=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,yt.useState)(!1),s=(0,yt.useRef)(null),i=(0,yt.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,yt.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},SW)},[i]);(0,yt.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,qe.jsxs)("div",{style:{position:"relative"},onMouseEnter:()=>{o||(i(),r(!0))},onMouseLeave:l,children:[(0,qe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>{o||(i(),r(u=>!u))},style:{...lL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,qe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,qe.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,qe.jsx)(ks,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,qe.jsx)("div",{role:"menu",style:c,children:e}):null]})};Q.Item=xW;Q.ItemLink=bW;Q.Separator=AW;Q.Group=vW;Q.Toggle=LW;Q.Submenu=kW;var vp=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 Bf(t,"WasmTextShaper.loadModule"),{instance:o}=await WebAssembly.instantiate(n,{});this.wasm=o.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=`${D6(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}=Pr(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=D6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=Pr(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}=Pr(o,r),c=o.measure(s,i);return l(),{width:c}}},D6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var wW={butt:0,round:1,square:2},_W={miter:0,round:1,bevel:2},CW={M:0,L:1,Q:2,C:3,Z:4},Lp=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Bf(t,"WasmRasterizer.loadModule"),{instance:o}=await WebAssembly.instantiate(n,{});this.wasm=o.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):u0.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):u0.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=TW(t),r=Pr(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=vy(o.memory,s),c=vy(o.memory,i);return P6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=IW(t),s=Pr(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=wW[o?.cap??"butt"],u=_W[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=vy(a.memory,i),f=vy(a.memory,l);return P6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},TW=e=>{let t=new Float32Array(e.length*7),n=0;for(let o of e)switch(t[n++]=CW[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.slice(0,n)},IW=e=>{let t=new Float32Array(e.length*2);for(let n=0;n<e.length;n++){let o=e[n];o!==void 0&&(t[n*2]=o.x,t[n*2+1]=o.y)}return t},vy=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),P6=(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:L(o[r*2]),y:L(o[r*2+1])};return a};var z6=()=>typeof Worker<"u",B6=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",EW=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},MW=async()=>await Fv()||Hv()?"webgl2":my()&&z6()?"offscreen":"canvas2d",N6=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await MW(),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:my()&&z6(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:EW()}},F6=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 dL=new WeakMap,fL=new WeakSet,ij=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>F(j6(),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}},lj={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=dL.get(e);if(!n)return fL.has(e)||(fL.add(e),ij(e).then(r=>{dL.set(e,r),tA()}).catch(()=>{}).finally(()=>fL.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 dL.get(e)?.totalMs??0}},V6=!1,Z6=()=>{V6||(V6=!0,Rf(lj))};var Sp=F(he(),1);var X6=e=>{let t=Et(),[n]=(0,Sp.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,Sp.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,Sp.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var Y6=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=cj(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}=Ov(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&&Mf(l,i),Js(l,i,{skipClear:!0}),No(l,i),s.convertToBlob({type:"image/png"})},cj=e=>{let t=null;for(let n of co(e))if(n.visible)for(let o of La(e,n.id)){let a=z(o);t=t?uj(t,a):a}return t},uj=(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 dj=14,fj=14,pj=16,mL=1.75,gt={size:dj,strokeWidth:mL},Jr={size:fj,strokeWidth:mL},Cy={size:pj,strokeWidth:mL},hj="https://github.com/oh-just-another/diagram",kp=(0,xe.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:b,hideBottomBar:y,hideToolbar:g,hideLibraryButton:x,hideMainMenu:A,hideZoomControls:C,hideResetToContent:_,hideHelpButton:v,hideContextMenu:I,hideSelectionPanel:k,renderTopBarLeft:T,renderTopBarCenter:P,renderTopBarRight:N,renderBottomBarLeft:U,renderBottomBarCenter:q,renderBottomBarRight:te,renderMainMenuExtras:Z,onImportTemplates:ue,theme:$,defaultTheme:re="system",onThemeChange:We,persistTheme:Re,repositoryUrl:Ii,onConfirm:es,onNotify:Rc,className:ts,style:ns}=t,Wa=(0,xe.useMemo)(()=>Re===!0?"diagram-theme":typeof Re=="string"?Re:null,[Re]),[tM,nM]=(0,xe.useState)(()=>{if(!Wa||typeof window>"u")return re;let ne=window.localStorage.getItem(Wa);return ne==="light"||ne==="dark"||ne==="system"?ne:re}),_p=$??tM,oM=X6(_p),aM=(0,xe.useCallback)(ne=>{$===void 0&&nM(ne),Wa&&typeof window<"u"&&window.localStorage.setItem(Wa,ne),We?.(ne)},[$,We,Wa]),xL=r?.enabled,bL=r?.style,Dc=(0,xe.useMemo)(()=>Sb({...o?{saved:o}:{},hostSettings:_j(xL,bL,s)}),[o,xL,bL,s]),AL=(0,xe.useMemo)(()=>{for(let ne of Dc.elements.values())if(Fe(ne))return!0;return!1},[Dc]);(0,xe.useEffect)(()=>{if(Z6(),i)for(let ne of i)ai.register(ne);if(c)for(let ne of c)Ob(ne);if(u)for(let ne of u)Rf(ne)},[i,c,u]);let[os,rM]=(0,xe.useState)(null),[Cp,sM]=(0,xe.useState)(null),[Tp,iM]=(0,xe.useState)(null),[lM,vL]=(0,xe.useState)(!1),[Iy,LL]=(0,xe.useState)(!1),SL=(0,xe.useRef)(null),kL=(0,xe.useRef)(!1);(0,xe.useEffect)(()=>{let ne=!1;return(async()=>{SL.current??=N6(h);let kn=await SL.current;if(ne)return;kL.current||(kL.current=!0,F6(kn)),rM(kn);let Ao=[];Ao.push(V8(document).then(()=>{ne||LL(!0)},to=>{ne||LL(!0),console.warn("[diagram] bundled fonts load failed",to)})),kn.wasmText&&Ao.push(vp.loadBundled().then(to=>{ne||(zf(to),sM(to),vL(!0))},to=>{ne||(vL(!0),console.warn("[diagram] WASM text shaper load failed",to))})),kn.wasmRaster&&Ao.push(Lp.loadBundled().then(to=>{ne||(Nf(to),iM(to))},to=>{console.warn("[diagram] WASM rasterizer load failed",to)})),await Promise.allSettled(Ao)})(),()=>{ne=!0}},[h]);let[se,cM]=(0,xe.useState)(null),uM=(0,xe.useCallback)(ne=>{if(l)for(let kn of l)ne.registerFileDropHandler(kn);cM(ne),d?.(ne)},[l,d]);return(0,xe.useEffect)(()=>{se&&(!Cp&&!Tp||se.setMode(se.mode))},[se,Cp,Tp]),(0,xe.useEffect)(()=>{se&&se.forceRender()},[se,u]),(0,xe.useEffect)(()=>{se&&Iy&&se.forceRender()},[se,Iy]),(0,xe.useEffect)(()=>{if(!se||!f&&!p)return;let ne=se.scene,kn=se.selection;return se.subscribe(()=>{f&&se.scene!==ne&&(ne=se.scene,f(se.scene)),p&&se.selection!==kn&&(kn=se.selection,p(se.selection))})},[se,f,p]),(0,xe.useEffect)(()=>{if(!se)return;let ne=Ao=>{Ia(Ao.target)||(se.setSnapSuppressed(Ao.metaKey||Ao.ctrlKey),se.setTransformModifiers({alt:Ao.altKey,shift:Ao.shiftKey}))},kn=()=>{se.setSnapSuppressed(!1),se.setTransformModifiers({alt:!1,shift:!1})};return window.addEventListener("keydown",ne),window.addEventListener("keyup",ne),window.addEventListener("blur",kn),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",ne),window.removeEventListener("blur",kn),se.setSnapSuppressed(!1),se.setTransformModifiers({alt:!1,shift:!1})}},[se]),(0,xe.useImperativeHandle)(n,()=>({editor:se,capabilities:os,getScene:()=>se?.scene??Dc,loadScene:ne=>se?.loadScene(ne),getMode:()=>se?.mode??null,setMode:ne=>se?.setMode(ne),getSelection:()=>se?.selection??new Set,setSelection:ne=>se?.setSelection(ne),undo:()=>{se?.undo()},redo:()=>{se?.redo()},zoomToFit:()=>{se?.zoomToFit()}}),[se,Dc,os]),os?AL&&!Iy?(0,R.jsx)("div",{className:ts,style:ns}):os.renderer==="webgl2"&&os.wasmText&&!lM&&AL?(0,R.jsx)("div",{className:ts,style:ns}):(0,R.jsx)(Bd,{container:oM,children:(0,R.jsx)(iL,{children:(0,R.jsx)(k1,{children:(0,R.jsx)("div",{className:ts,"data-diagram-root":!0,..._p==="system"?{}:{"data-theme":_p},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...ns},children:(0,R.jsx)(Uv,{initialScene:Dc,initialMode:a,onReady:uM,renderer:os.renderer,...os.renderer==="offscreen"?{workerFactory:m??Rv}:{},...Cp?{textShaper:Cp}:{},...Tp?{rasterizer:Tp}:{},children:(0,R.jsx)(mj,{hideTopBar:b,hideBottomBar:y,hideToolbar:g,hideLibraryButton:x,hideMainMenu:A,hideZoomControls:C,hideResetToContent:_,hideHelpButton:v,hideContextMenu:I,hideSelectionPanel:k,renderTopBarLeft:T,renderTopBarCenter:P,renderTopBarRight:N,renderBottomBarLeft:U,renderBottomBarCenter:q,renderBottomBarRight:te,renderMainMenuExtras:Z,onImportTemplates:ue,repositoryUrl:Ii,onConfirm:es,onNotify:Rc,theme:_p,changeTheme:aM})})})})})}):(0,R.jsx)("div",{className:ts,style:ns})});kp.displayName="Editor";var mj=({hideTopBar:e,hideBottomBar:t,hideToolbar:n,hideLibraryButton:o,hideMainMenu:a,hideZoomControls:r,hideResetToContent:s,hideHelpButton:i,hideContextMenu:l,hideSelectionPanel:c,renderTopBarLeft:u,renderTopBarCenter:d,renderTopBarRight:f,renderBottomBarLeft:p,renderBottomBarCenter:h,renderBottomBarRight:m,renderMainMenuExtras:b,onImportTemplates:y,repositoryUrl:g,onConfirm:x,onNotify:A,theme:C,changeTheme:_})=>{let v=j(),I=g===void 0?hj:g,k=x??(Re=>window.confirm(Re)),T=A??(Re=>{window.alert(Re)});oi();let P=iv(),N=$f(),[U,q]=(0,xe.useState)(!1),[te,Z]=(0,xe.useState)(!1);$A(()=>{Z(Re=>!Re)});let ue=240,$=12,re=!N&&U?ue+$:$,We=(0,xe.useMemo)(()=>o?[...by]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(cd,{...Cy}),title:"Templates library",active:U,onClick:()=>{q(Re=>!Re)}},{kind:"divider"},...by],[o,U]);return(0,R.jsxs)("div",{style:{position:"absolute",inset:0},onDragEnter:P.onDragEnter,onDragOver:P.onDragOver,onDragLeave:P.onDragLeave,onDrop:P.onDrop,children:[(0,R.jsxs)("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0},children:[(0,R.jsx)(Gv,{style:{position:"absolute",inset:0}}),(0,R.jsx)(Zv,{}),(0,R.jsx)(Xv,{}),(0,R.jsx)(Yv,{}),(0,R.jsx)(Kv,{}),(0,R.jsx)($v,{}),!l&&(0,R.jsx)(oL,{items:rL})]}),n?null:(0,R.jsx)(eL,{orientation:"vertical",items:We,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${re}px)`,transform:"translateY(-50%)",zIndex:60}}),(0,R.jsxs)(C1,{children:[!e&&(0,R.jsx)(T1,{left:(0,R.jsxs)(Os,{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)(td,{...gt}),onClick:()=>{Lj(v,T)},children:"Open\u2026"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ed,{...gt}),onClick:()=>{v&&vj(v.scene)},disabled:!v,children:"Save as JSON"}),(0,R.jsxs)(Q.Submenu,{icon:(0,R.jsx)(kl,{...gt}),label:"Export\u2026",disabled:!v,children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"transparent",T),disabled:!v,children:"PNG (transparent)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"color",T),disabled:!v,children:"PNG (with background)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"color-and-grid",T),disabled:!v,children:"PNG (with background + grid)"}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(kl,{...gt}),onClick:()=>{v&&wj(v.scene)},disabled:!v,children:"SVG"})]}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ld,{...gt}),onClick:()=>{v&&k("Reset canvas? This clears all shapes.")&&v.clear()},disabled:!v,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)(Es,{...gt}),shortcut:"\u2318Z",onClick:()=>v?.undo(),disabled:!v,children:"Undo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Is,{...gt}),shortcut:"\u21E7\u2318Z",onClick:()=>v?.redo(),disabled:!v,children:"Redo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Sd,{...gt}),shortcut:"\u2318X",onClick:()=>v?.cutSelected(),disabled:!v,children:"Cut"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ws,{...gt}),shortcut:"\u2318C",onClick:()=>v?.copySelected(),disabled:!v,children:"Copy"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($u,{...gt}),shortcut:"\u2318V",onClick:()=>v?.paste(),disabled:!v,children:"Paste"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(xd,{...gt}),shortcut:"\u2318A",onClick:()=>v?.selectAll(),disabled:!v,children:"Select all"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Qu,{...gt}),shortcut:"\u232B",onClick:()=>v?.deleteSelected(),disabled:!v,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)(wl,{...gt}),shortcut:"\u21E7F",onClick:()=>v?.zoomToFit(),disabled:!v,children:"Fit to screen"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Pd,{...gt}),shortcut:"\u2318+",onClick:()=>v?.zoomIn(),disabled:!v,children:"Zoom in"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Dd,{...gt}),shortcut:"\u2318\u2212",onClick:()=>v?.zoomOut(),disabled:!v,children:"Zoom out"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Group,{title:"Theme",children:(0,R.jsx)(Q.Toggle,{value:C,onChange:_,options:[{value:"light",label:"Light",icon:(0,R.jsx)(Td,{...Jr})},{value:"dark",label:"Dark",icon:(0,R.jsx)(yd,{...Jr})},{value:"system",label:"System",icon:(0,R.jsx)(md,{...Jr})}]})}),(0,R.jsx)(Q.Group,{title:"Grid",children:(0,R.jsx)(Q.Toggle,{value:Cj(v),onChange:Re=>{Ij(v,Re)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(so,{...Jr})},{value:"dots",label:"Dots",icon:(0,R.jsx)(rd,{...Jr})},{value:"off",label:"Off",icon:(0,R.jsx)(ma,{...Jr})}]})}),(0,R.jsx)(Q.Group,{title:"Snap to grid",children:(0,R.jsx)(Q.Toggle,{value:Tj(v),onChange:Re=>{v?.setSnapToGrid(Re==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)(pd,{...Jr})},{value:"off",label:"Off",icon:(0,R.jsx)(ma,{...Jr})}]})}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Help",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(gn,{...gt}),shortcut:"?",onClick:()=>{Z(!0)},children:"Hotkeys"}),I?(0,R.jsx)(Q.ItemLink,{href:I,external:!0,children:"GitHub"}):null]}),b?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Q.Separator,{}),b()]}):null]}),u?u():null]}),center:d?.(),right:(0,R.jsx)(Os,{ariaLabel:"Top bar actions",children:f?f():null})}),!t&&(0,R.jsx)(I1,{left:p?p():null,center:h?h():s?null:(0,R.jsx)(tv,{}),right:m?m():r?i?null:(0,R.jsx)(R0,{}):(0,R.jsx)(Aj,{trailing:i?void 0:(0,R.jsx)(R0,{})})}),N?U?(0,R.jsx)(Vv,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:Re=>{Re<=0&&q(!1)},children:(0,R.jsx)(G0,{open:!0,sheet:!0,onClose:()=>{q(!1)},...y?{onImport:y}:{}})}):null:(0,R.jsx)(G0,{open:U,side:"left",style:{left:0},onClose:()=>{q(!1)},...y?{onImport:y}:{}})]}),!c&&(0,R.jsx)(Sv,{}),(0,R.jsx)(Yf,{open:te,onClose:()=>{Z(!1)}}),(0,R.jsx)(sL,{}),void 0]})},yj=Bt({meta:!0,key:"\u2212"}),gj=Bt({meta:!0,key:"+"}),xj=Bt({meta:!0,key:"0"}),bj=Bt({alt:!0,key:"1"}),Aj=({trailing:e})=>{let t=j(),[,n]=(0,xe.useState)(0);if((0,xe.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(Os,{ariaLabel:"Zoom",children:[(0,R.jsx)(Bn,{label:`Zoom out (${yj})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(ma,{...Cy})}),(0,R.jsx)(Ms,{content:`Reset zoom to 100% (${xj})`,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)(Bn,{label:`Zoom in (${gj})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Ts,{...Cy})}),(0,R.jsx)(Bn,{label:`Fit to screen (${bj})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(wl,{...Cy})}),e]})},yL=(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)})},vj=e=>{let t=qv(e,2);yL(new Blob([t],{type:"application/json"}),"scene.diagram.json")},Lj=(e,t)=>{if(!e)return;let n=document.createElement("input");n.type="file",n.accept="application/json,.json",n.onchange=()=>{let o=n.files?.[0];o&&o.text().then(a=>{try{let r=jv(a);e.loadScene(r)}catch(r){console.error("[diagram] failed to parse scene file:",r),t("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},n.click()},Sj=2,hL=async(e,t,n)=>{let o=kj(),a=await Y6(e.scene,{background:t,scale:Sj,backgroundColor:o});if(!a){n("Nothing to export \u2014 the canvas is empty.");return}yL(a,"scene.png")},kj=()=>{let e=document.querySelector('canvas[data-layer="main"]')??document.body;return getComputedStyle(e).getPropertyValue("--du-canvas-bg").trim()||"#ffffff"},wj=e=>{let t=nL(e);yL(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},_j=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),Cj=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},Tj=e=>e?.snapToGridEnabled??!0?"on":"off",Ij=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var K6=`/**
143
+ * Diagram UI stylesheet. Imported once by the host:
144
+ *
145
+ * import "@oh-just-another/react-ui/styles.css";
146
+ *
147
+ * Provides:
148
+ * \u2022 CSS variables for theme (\`:root\` + \`[data-theme="dark"]\`)
149
+ * \u2022 Utility classes prefixed \`du-\` ("diagram ui") so they don't
150
+ * collide with host's own styles.
151
+ * \u2022 Per-component blocks (.du-icon-button, .du-top-bar, ...).
152
+ *
153
+ * Hosts can override any variable in their own stylesheet for
154
+ * theming \u2014 every component reads colours / sizes through these
155
+ * variables, never hard-coded.
156
+ *
157
+ * Colour values mirror \`@oh-just-another/tokens\` \u2014 CSS can't import
158
+ * TypeScript, so values are hand-copied with comments pointing
159
+ * back to the token name. Keep this in sync when you change a
160
+ * value in \`packages/tokens/src/colors.ts\`.
161
+ */
162
+
163
+ :root {
164
+ /* --- Surfaces (from UI_SURFACE.light) --- */
165
+ --du-canvas-bg: #f5f5f5; /* UI_SURFACE.light.canvas */
166
+ --du-ui-bg: rgba(255, 255, 255, 0.95); /* UI_SURFACE.light.bg */
167
+ --du-ui-bg-solid: #ffffff; /* UI_SURFACE.light.bgSolid */
168
+ --du-ui-border: rgba(0, 0, 0, 0.08); /* UI_SURFACE.light.border */
169
+ --du-ui-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
170
+
171
+ /* --- Text (from UI_SURFACE.light) --- */
172
+ --du-text: #1a1a1a; /* UI_SURFACE.light.text */
173
+ --du-text-muted: #6b6b6b; /* UI_SURFACE.light.textMuted */
174
+ --du-text-on-accent: #ffffff;
175
+
176
+ /* --- Accent (from UI_ACCENT.light \u2014 Radix iris) --- */
177
+ --du-accent: #5b5bd6; /* UI_ACCENT.light.accent (iris.iris9) */
178
+ --du-accent-hover: #5151cd; /* UI_ACCENT.light.accentHover (iris.iris10) */
179
+ --du-danger: #e54d2e; /* UI_ACCENT.light.danger (tomato.tomato9) */
180
+
181
+ /* --- Selected (tonal, modern-style) --- */
182
+ /* Active toolbar / icon buttons get a *muted* tonal fill so they
183
+ read as "this state is selected" without hijacking the eye like
184
+ a saturated accent fill would. The icon switches to the accent
185
+ hue, the background stays close to the surface. */
186
+ --du-selected-bg: #e6e7ff; /* UI_ACCENT.light.selectedBg (iris.iris4) */
187
+ --du-selected-fg: #5753c6; /* UI_ACCENT.light.selectedFg (iris.iris11) */
188
+
189
+ /* --- Sizing --- */
190
+ --du-radius: 10px;
191
+ --du-radius-sm: 6px;
192
+ --du-radius-lg: 14px;
193
+ --du-button-size: 36px;
194
+ --du-button-size-sm: 32px;
195
+ --du-icon-size: 18px;
196
+ --du-gap: 8px;
197
+ --du-gap-sm: 4px;
198
+ --du-pad: 8px;
199
+ --du-pad-sm: 4px;
200
+ --du-hover-overlay: rgba(0, 0, 0, 0.05);
201
+ --du-bar-inset: 12px;
202
+ --du-z-canvas: 1;
203
+ --du-z-ui: 100;
204
+ --du-z-modal: 1000;
205
+ }
206
+
207
+ /**
208
+ * Theme resolution priority (highest wins):
209
+ * [data-theme="light"] \u2014 host forced light.
210
+ * [data-theme="dark"] \u2014 host forced dark.
211
+ * @media prefers-color-scheme: dark \u2192 :root \u2014 OS-derived dark when
212
+ * no data-theme is present.
213
+ * :root \u2014 light defaults.
214
+ *
215
+ * Hosts set \`data-theme\` via the Diagram component's \`theme\` prop
216
+ * ("light" / "dark" / "system" \u2014 "system" omits the attribute so
217
+ * the media query takes over).
218
+ */
219
+ @media (prefers-color-scheme: dark) {
220
+ :root {
221
+ /* All values mirror UI_SURFACE.dark + UI_ACCENT.dark from
222
+ \`@oh-just-another/tokens\`. */
223
+ --du-canvas-bg: #121212; /* UI_SURFACE.dark.canvas */
224
+ --du-ui-bg: rgba(35, 35, 35, 0.95); /* UI_SURFACE.dark.bg */
225
+ --du-ui-bg-solid: #252525; /* UI_SURFACE.dark.bgSolid */
226
+ --du-ui-border: rgba(255, 255, 255, 0.08); /* UI_SURFACE.dark.border */
227
+ --du-ui-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
228
+ --du-text: #e8e8e8; /* UI_SURFACE.dark.text */
229
+ --du-text-muted: #9a9a9a; /* UI_SURFACE.dark.textMuted */
230
+ --du-accent: #5b5bd6; /* UI_ACCENT.dark.accent (irisDark.iris9) */
231
+ --du-accent-hover: #6e6ade; /* UI_ACCENT.dark.accentHover (irisDark.iris10) */
232
+ --du-hover-overlay: rgba(255, 255, 255, 0.06); /* UI_SURFACE.dark.hoverOverlay */
233
+ --du-selected-bg: #262a65; /* UI_ACCENT.dark.selectedBg (irisDark.iris4) */
234
+ --du-selected-fg: #b1a9ff; /* UI_ACCENT.dark.selectedFg (irisDark.iris11) */
235
+ }
236
+ }
237
+
238
+ [data-theme="light"] {
239
+ /* Same as :root \u2014 explicit override so a host that toggles
240
+ \`data-theme\` between "light" / "dark" / unset still picks
241
+ up the light palette under all conditions. Mirrors
242
+ UI_SURFACE.light + UI_ACCENT.light. */
243
+ --du-canvas-bg: #f5f5f5;
244
+ --du-ui-bg: rgba(255, 255, 255, 0.95);
245
+ --du-ui-bg-solid: #ffffff;
246
+ --du-ui-border: rgba(0, 0, 0, 0.08);
247
+ --du-ui-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
248
+ --du-text: #1a1a1a;
249
+ --du-text-muted: #6b6b6b;
250
+ --du-accent: #5b5bd6; /* iris.iris9 */
251
+ --du-accent-hover: #5151cd; /* iris.iris10 */
252
+ --du-hover-overlay: rgba(0, 0, 0, 0.05);
253
+ --du-selected-bg: #e6e7ff; /* iris.iris4 */
254
+ --du-selected-fg: #5753c6; /* iris.iris11 */
255
+ }
256
+
257
+ /* ------------------------------------------------------------------ */
258
+ /* Legacy variable aliases \u2014 kept so the older components (MainMenu, */
259
+ /* ContextMenu, Modal, HelpDialog) that read \`var(--panel)\` / */
260
+ /* \`var(--text)\` / \`var(--button-bg)\` etc. still pick up the active */
261
+ /* theme without being rewritten to the \`--du-*\` namespace. */
262
+ /* */
263
+ /* Hosts can still override the legacy names individually \u2014 these */
264
+ /* are defaults that *forward* to the unified theme variables. */
265
+ /* */
266
+ /* Declared at every theme scope (not just \`:root\`) on purpose: a */
267
+ /* \`var()\` inside a custom property resolves on the element where the */
268
+ /* property is declared. If these lived on \`:root\` alone, the alias */
269
+ /* would bake in \`:root\`'s \`--du-*\` (e.g. the OS \`prefers-color-scheme\` */
270
+ /* dark value) and inherit that frozen colour past a \`[data-theme]\` */
271
+ /* override \u2014 so a light app would still get a dark context menu. */
272
+ /* Re-declaring per scope lets each alias re-resolve against the */
273
+ /* scoped \`--du-*\`, including the themed portal wrapper menus mount */
274
+ /* into. */
275
+ /* ------------------------------------------------------------------ */
276
+ :root,
277
+ [data-theme="light"],
278
+ [data-theme="dark"] {
279
+ --bg: var(--du-canvas-bg);
280
+ --panel: var(--du-ui-bg-solid);
281
+ --surface: var(--du-ui-bg-solid);
282
+ --text: var(--du-text);
283
+ --muted: var(--du-text-muted);
284
+ --border: var(--du-ui-border);
285
+ --button-bg: var(--du-ui-bg-solid);
286
+ --button-hover-bg: var(--du-ui-bg);
287
+ --accent: var(--du-accent);
288
+ --menu-bg: var(--du-ui-bg-solid);
289
+ --menu-text: var(--du-text);
290
+ --menu-border: var(--du-ui-border);
291
+ --menu-divider: var(--du-ui-border);
292
+ /* Remaining legacy names the chrome reads \u2014 defined here (forwarding to the
293
+ theme-aware \`--du-*\` set) so the editor is fully themed from this stylesheet
294
+ alone, without a host-provided token block. */
295
+ --divider: var(--du-ui-border);
296
+ --text-strong: var(--du-text);
297
+ --faint: var(--du-text-muted);
298
+ --toolbar-bg: var(--du-ui-bg-solid);
299
+ --cursor-bg: var(--du-selected-bg);
300
+ --code-bg: var(--du-ui-bg-solid);
301
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
302
+ }
303
+
304
+ [data-theme="dark"] {
305
+ /* Mirrors UI_SURFACE.dark + UI_ACCENT.dark from \`@oh-just-another/tokens\`. */
306
+ --du-canvas-bg: #121212;
307
+ --du-ui-bg: rgba(35, 35, 35, 0.95);
308
+ --du-ui-bg-solid: #252525;
309
+ --du-ui-border: rgba(255, 255, 255, 0.08);
310
+ --du-ui-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
311
+ --du-text: #e8e8e8;
312
+ --du-text-muted: #9a9a9a;
313
+ --du-accent: #5b5bd6; /* irisDark.iris9 */
314
+ --du-accent-hover: #6e6ade; /* irisDark.iris10 */
315
+ --du-hover-overlay: rgba(255, 255, 255, 0.06);
316
+ --du-selected-bg: #262a65; /* irisDark.iris4 */
317
+ --du-selected-fg: #b1a9ff; /* irisDark.iris11 */
318
+ }
319
+
320
+ /* ------------------------------------------------------------------ */
321
+ /* Canvas surface focus ring. The surface is \`tabIndex=0\` so keyboard */
322
+ /* users can land on it, but it also takes focus on a pointer press */
323
+ /* (so shortcuts work right after a click). Gate the ring on */
324
+ /* \`:focus-visible\` so it shows ONLY for keyboard focus \u2014 a mouse click */
325
+ /* never draws an input-like outline. Class+pseudo specificity (0,2,0) */
326
+ /* beats a host's \`*:focus { outline: none }\`. */
327
+ /* ------------------------------------------------------------------ */
328
+ .du-canvas-surface {
329
+ outline: none;
330
+ }
331
+ .du-canvas-surface:focus-visible {
332
+ outline: 2px solid var(--du-accent);
333
+ outline-offset: -2px;
334
+ }
335
+
336
+ /* ------------------------------------------------------------------ */
337
+ /* UI layer \u2014 absolute overlay above the canvas surface. */
338
+ /* pointer-events: none on the wrapper, auto on children, so the */
339
+ /* canvas keeps receiving pointer events anywhere the UI isn't drawn. */
340
+ /* ------------------------------------------------------------------ */
341
+ .du-ui-layer {
342
+ position: absolute;
343
+ inset: 0;
344
+ pointer-events: none;
345
+ z-index: var(--du-z-ui);
346
+ }
347
+
348
+ .du-ui-layer > * {
349
+ pointer-events: auto;
350
+ }
351
+
352
+ /* ------------------------------------------------------------------ */
353
+ /* Bars \u2014 top / bottom 3-zone layout (left / center / right). */
354
+ /* ------------------------------------------------------------------ */
355
+ .du-bar {
356
+ position: absolute;
357
+ left: var(--du-bar-inset);
358
+ right: var(--du-bar-inset);
359
+ display: flex;
360
+ justify-content: space-between;
361
+ align-items: center;
362
+ gap: var(--du-gap);
363
+ pointer-events: none;
364
+ }
365
+
366
+ .du-bar > * {
367
+ pointer-events: auto;
368
+ }
369
+
370
+ .du-bar-top {
371
+ top: var(--du-bar-inset);
372
+ }
373
+
374
+ .du-bar-bottom {
375
+ bottom: var(--du-bar-inset);
376
+ }
377
+
378
+ .du-bar-zone {
379
+ display: inline-flex;
380
+ align-items: center;
381
+ gap: var(--du-gap);
382
+ }
383
+
384
+ .du-bar-zone-center {
385
+ margin: 0 auto;
386
+ }
387
+
388
+ /* ------------------------------------------------------------------ */
389
+ /* Icon button \u2014 square clickable. Two visual modes: */
390
+ /* 1. Standalone (outside \`du-button-group\`): full pill with */
391
+ /* surface, border, shadow. */
392
+ /* 2. Inside \`du-button-group\`: transparent surface, subtle radius, */
393
+ /* lets the group's pill chrome carry the framing. */
394
+ /* ------------------------------------------------------------------ */
395
+ .du-icon-button {
396
+ width: var(--du-button-size);
397
+ height: var(--du-button-size);
398
+ display: inline-flex;
399
+ align-items: center;
400
+ justify-content: center;
401
+ background: var(--du-ui-bg);
402
+ color: var(--du-text);
403
+ border: 1px solid var(--du-ui-border);
404
+ border-radius: var(--du-radius);
405
+ cursor: pointer;
406
+ font-size: 14px;
407
+ line-height: 1;
408
+ box-shadow: var(--du-ui-shadow);
409
+ transition:
410
+ background 0.12s ease,
411
+ color 0.12s ease,
412
+ transform 0.05s ease;
413
+ padding: 0;
414
+ outline: none;
415
+ user-select: none;
416
+ }
417
+
418
+ .du-icon-button:hover:not(:disabled) {
419
+ background: var(--du-ui-bg-solid);
420
+ }
421
+
422
+ .du-icon-button:active:not(:disabled) {
423
+ transform: scale(0.96);
424
+ }
425
+
426
+ .du-icon-button:disabled {
427
+ opacity: 0.4;
428
+ cursor: not-allowed;
429
+ }
430
+
431
+ .du-icon-button:focus-visible {
432
+ outline: 2px solid var(--du-accent);
433
+ outline-offset: 2px;
434
+ }
435
+
436
+ .du-icon-button[aria-pressed="true"],
437
+ .du-icon-button.is-active {
438
+ background: var(--du-selected-bg);
439
+ color: var(--du-selected-fg);
440
+ border-color: var(--du-selected-bg);
441
+ }
442
+
443
+ .du-icon-button[aria-pressed="true"]:hover:not(:disabled),
444
+ .du-icon-button.is-active:hover:not(:disabled) {
445
+ /* Slight tint shift on hover \u2014 keeps the "selected" cue but
446
+ acknowledges the cursor. Same hue family, marginally darker. */
447
+ background: color-mix(in srgb, var(--du-selected-bg) 90%, var(--du-text) 10%);
448
+ }
449
+
450
+ .du-icon-button-sm {
451
+ width: var(--du-button-size-sm);
452
+ height: var(--du-button-size-sm);
453
+ font-size: 12px;
454
+ }
455
+
456
+ /**
457
+ * Flat modifier \u2014 strips the standalone pill chrome (background,
458
+ * border, shadow) and adopts the same look as an IconButton sitting
459
+ * inside a \`du-button-group\`. Use this when a button has to live
460
+ * inside a container that the descendant selector can't reach (e.g.
461
+ * the MainMenu trigger, which is wrapped in a positioning <div> so
462
+ * its dropdown can be \`position: absolute\`).
463
+ */
464
+ .du-icon-button-flat {
465
+ background: transparent;
466
+ border: none;
467
+ box-shadow: none;
468
+ border-radius: var(--du-radius-sm);
469
+ width: var(--du-button-size-sm);
470
+ height: var(--du-button-size-sm);
471
+ }
472
+
473
+ .du-icon-button-flat:hover:not(:disabled) {
474
+ background: var(--du-hover-overlay);
475
+ }
476
+
477
+ /* ------------------------------------------------------------------ */
478
+ /* Button group \u2014 pill that wraps one or more IconButtons. Group */
479
+ /* carries the surface, border, shadow; the buttons inside drop */
480
+ /* their own chrome so the row reads as one cohesive control. */
481
+ /* Padding + gap match standard's tool bar feel. */
482
+ /* ------------------------------------------------------------------ */
483
+ .du-button-group {
484
+ display: inline-flex;
485
+ align-items: center;
486
+ gap: var(--du-gap-sm);
487
+ background: var(--du-ui-bg);
488
+ border: 1px solid var(--du-ui-border);
489
+ border-radius: var(--du-radius);
490
+ box-shadow: var(--du-ui-shadow);
491
+ padding: var(--du-pad-sm);
492
+ /* No \`overflow: hidden\` \u2014 a child popup (MainMenu dropdown) must
493
+ be able to render outside the group's bounds. */
494
+ }
495
+
496
+ /* Vertical variant \u2014 the left creation dock. Stacks buttons in a
497
+ column; dividers (rendered inline by <Toolbar>) become horizontal. */
498
+ .du-button-group-vertical {
499
+ flex-direction: column;
500
+ align-items: stretch;
501
+ }
502
+
503
+ .du-button-group > .du-icon-button {
504
+ border: none;
505
+ box-shadow: none;
506
+ border-radius: var(--du-radius-sm);
507
+ background: transparent;
508
+ width: var(--du-button-size-sm);
509
+ height: var(--du-button-size-sm);
510
+ }
511
+
512
+ /* Vertical dock buttons are square + centred (icon-only tools). */
513
+ .du-button-group-vertical > .du-icon-button {
514
+ width: var(--du-button-size-sm) !important;
515
+ min-width: var(--du-button-size-sm) !important;
516
+ padding: 0 !important;
517
+ }
518
+
519
+ /* ------------------------------------------------------------------ */
520
+ /* Mobile / coarse-pointer chrome (keep the 640px breakpoint in sync */
521
+ /* with MOBILE_MAX_WIDTH_PX in constants.ts). */
522
+ /* ------------------------------------------------------------------ */
523
+ @media (pointer: coarse), (max-width: 640px) {
524
+ /* Bars clear the notch / home indicator + rounded corners. */
525
+ .du-bar-top {
526
+ top: calc(var(--du-bar-inset) + env(safe-area-inset-top, 0px));
527
+ }
528
+ .du-bar-bottom {
529
+ bottom: calc(var(--du-bar-inset) + env(safe-area-inset-bottom, 0px));
530
+ }
531
+ .du-bar {
532
+ left: calc(var(--du-bar-inset) + env(safe-area-inset-left, 0px));
533
+ right: calc(var(--du-bar-inset) + env(safe-area-inset-right, 0px));
534
+ }
535
+
536
+ /* Vertical creation dock: \u226544px touch targets; scroll inside the dock
537
+ when a short screen can't fit every tool. */
538
+ .du-button-group-vertical {
539
+ max-height: calc(
540
+ 100vh - 2 * var(--du-bar-inset) - env(safe-area-inset-top, 0px) -
541
+ env(safe-area-inset-bottom, 0px)
542
+ );
543
+ overflow-y: auto;
544
+ scrollbar-width: none;
545
+ }
546
+ .du-button-group-vertical::-webkit-scrollbar {
547
+ display: none;
548
+ }
549
+ .du-button-group-vertical > .du-icon-button {
550
+ width: 44px !important;
551
+ min-width: 44px !important;
552
+ height: 44px !important;
553
+ }
554
+ }
555
+
556
+ .du-button-group > .du-icon-button:hover:not(:disabled) {
557
+ background: var(--du-hover-overlay);
558
+ }
559
+
560
+ .du-button-group > .du-icon-button[aria-pressed="true"],
561
+ .du-button-group > .du-icon-button.is-active {
562
+ background: var(--du-selected-bg);
563
+ color: var(--du-selected-fg);
564
+ }
565
+
566
+ .du-button-group > .du-icon-button[aria-pressed="true"]:hover:not(:disabled),
567
+ .du-button-group > .du-icon-button.is-active:hover:not(:disabled) {
568
+ background: color-mix(in srgb, var(--du-selected-bg) 90%, var(--du-text) 10%);
569
+ }
570
+
571
+ /* ------------------------------------------------------------------ */
572
+ /* Floating side panel \u2014 used by Library / SelectedShapeActions. */
573
+ /* Fixed-width, fixed-height-with-scroll, sits flush against the */
574
+ /* corresponding side of the canvas with a \`du-bar-inset\` margin. */
575
+ /* ------------------------------------------------------------------ */
576
+ .du-side-panel {
577
+ position: absolute;
578
+ top: calc(var(--du-bar-inset) + var(--du-button-size) + var(--du-gap));
579
+ bottom: calc(var(--du-bar-inset) + var(--du-button-size) + var(--du-gap));
580
+ width: 240px;
581
+ background: var(--du-ui-bg);
582
+ color: var(--du-text);
583
+ border: 1px solid var(--du-ui-border);
584
+ border-radius: var(--du-radius);
585
+ box-shadow: var(--du-ui-shadow);
586
+ display: flex;
587
+ flex-direction: column;
588
+ overflow: hidden;
589
+ }
590
+
591
+ .du-side-panel-left {
592
+ left: var(--du-bar-inset);
593
+ }
594
+
595
+ .du-side-panel-right {
596
+ right: var(--du-bar-inset);
597
+ }
598
+
599
+ /* Sheet mode \u2014 fills the parent BottomSheet; the sheet provides the
600
+ surface, so drop the floating-pill position / border / shadow. */
601
+ .du-side-panel.du-side-panel-sheet {
602
+ position: static;
603
+ top: auto;
604
+ bottom: auto;
605
+ left: auto;
606
+ right: auto;
607
+ width: 100%;
608
+ height: 100%;
609
+ border: none;
610
+ border-radius: 0;
611
+ box-shadow: none;
612
+ background: transparent;
613
+ }
614
+
615
+ .du-side-panel-header {
616
+ display: flex;
617
+ align-items: center;
618
+ justify-content: flex-end;
619
+ gap: var(--du-gap-sm);
620
+ padding: var(--du-pad-sm) var(--du-pad-sm) var(--du-pad-sm) var(--du-pad);
621
+ font-size: 12px;
622
+ font-weight: 600;
623
+ text-transform: uppercase;
624
+ letter-spacing: 0.5px;
625
+ color: var(--du-text-muted);
626
+ }
627
+
628
+ /* Hide the header when it's empty (no action buttons configured). */
629
+ .du-side-panel-header:empty {
630
+ display: none;
631
+ }
632
+
633
+ /* Auto-height variant \u2014 content hugs its natural height instead
634
+ of stretching from top to bottom of the canvas area. Used by
635
+ the Properties panel so it shrinks to whatever the inspector
636
+ sections need. The Library panel keeps the default full-height
637
+ so its long grid can scroll. */
638
+ .du-side-panel-auto-height {
639
+ bottom: auto;
640
+ max-height: calc(100% - 2 * var(--du-bar-inset) - 2 * var(--du-button-size) - 2 * var(--du-gap));
641
+ }
642
+
643
+ .du-side-panel-body {
644
+ flex: 1;
645
+ overflow-y: auto;
646
+ padding: var(--du-pad);
647
+ }
648
+
649
+ /* Variant for hosts that lay out their own grid / list inside the
650
+ panel body (e.g. <Palette>) and would otherwise have to subtract
651
+ the body's padding from their own paddings. Keeps overflow + flex
652
+ behaviour. */
653
+ .du-side-panel-body-flush {
654
+ padding: 0;
655
+ }
656
+
657
+ /* ------------------------------------------------------------------ */
658
+ /* Palette (template library content) \u2014 sectioned grid of icon tiles. */
659
+ /* No per-tile borders, no per-section dividers \u2014 visual structure */
660
+ /* comes from spacing alone so the panel reads as one calm surface. */
661
+ /* ------------------------------------------------------------------ */
662
+ .du-palette {
663
+ display: flex;
664
+ flex-direction: column;
665
+ min-height: 0;
666
+ color: var(--du-text);
667
+ width: 100%;
668
+ }
669
+
670
+ .du-palette-body {
671
+ flex: 1 1 auto;
672
+ overflow-y: auto;
673
+ display: flex;
674
+ flex-direction: column;
675
+ }
676
+
677
+ .du-palette-section {
678
+ padding: 0 var(--du-pad) var(--du-pad-sm);
679
+ }
680
+
681
+ .du-palette-category {
682
+ width: 100%;
683
+ background: transparent;
684
+ color: var(--du-text-muted);
685
+ border: none;
686
+ padding: 10px 0 6px;
687
+ font: inherit;
688
+ font-size: 11px;
689
+ font-weight: 600;
690
+ text-transform: uppercase;
691
+ letter-spacing: 0.5px;
692
+ text-align: left;
693
+ cursor: pointer;
694
+ display: flex;
695
+ align-items: center;
696
+ justify-content: space-between;
697
+ gap: var(--du-gap-sm);
698
+ }
699
+
700
+ .du-palette-category-caret {
701
+ display: inline-flex;
702
+ align-items: center;
703
+ opacity: 0.6;
704
+ }
705
+
706
+ .du-palette-grid {
707
+ display: grid;
708
+ grid-template-columns: repeat(2, 1fr);
709
+ gap: var(--du-gap-sm);
710
+ align-content: start;
711
+ padding: 0 var(--du-pad) var(--du-pad-sm);
712
+ }
713
+
714
+ /* \`.du-palette-section > .du-palette-grid\` already gets padding via
715
+ .du-palette-section; remove the duplicate to avoid double margin. */
716
+ .du-palette-section > .du-palette-grid {
717
+ padding: 0;
718
+ }
719
+
720
+ /* Compact list layout (modern-style templates panel) \u2014 single column of
721
+ icon + name rows. Denser than the grid; the label reads left-aligned
722
+ beside a small icon. */
723
+ .du-palette-list {
724
+ display: flex;
725
+ flex-direction: column;
726
+ gap: 2px;
727
+ padding: 0 var(--du-pad) var(--du-pad-sm);
728
+ }
729
+ .du-palette-section > .du-palette-list {
730
+ padding: 0;
731
+ }
732
+ .du-palette-list .du-palette-item {
733
+ flex-direction: row;
734
+ align-items: center;
735
+ justify-content: flex-start;
736
+ aspect-ratio: auto;
737
+ gap: 8px;
738
+ padding: 5px 8px;
739
+ text-align: left;
740
+ font-size: 12px;
741
+ line-height: 1.2;
742
+ }
743
+ .du-palette-list .du-palette-item-icon {
744
+ width: 20px !important;
745
+ height: 20px !important;
746
+ flex: 0 0 auto;
747
+ }
748
+ .du-palette-list .du-palette-item-label {
749
+ flex: 1 1 auto;
750
+ white-space: nowrap;
751
+ overflow: hidden;
752
+ text-overflow: ellipsis;
753
+ }
754
+
755
+ .du-palette-empty {
756
+ padding: 24px 12px;
757
+ text-align: center;
758
+ font-size: 12px;
759
+ color: var(--du-text-muted);
760
+ }
761
+
762
+ .du-palette-item {
763
+ display: flex;
764
+ flex-direction: column;
765
+ align-items: center;
766
+ justify-content: center;
767
+ gap: 4px;
768
+ aspect-ratio: 1;
769
+ padding: 6px 4px;
770
+ background: transparent;
771
+ color: var(--du-text);
772
+ border: none;
773
+ border-radius: var(--du-radius-sm);
774
+ cursor: grab;
775
+ text-align: center;
776
+ font-size: 10px;
777
+ line-height: 1.1;
778
+ transition: background 0.12s ease;
779
+ }
780
+
781
+ .du-palette-item:hover {
782
+ background: var(--du-hover-overlay);
783
+ }
784
+
785
+ .du-palette-item:active {
786
+ cursor: grabbing;
787
+ }
788
+
789
+ .du-palette-item-icon {
790
+ display: inline-flex;
791
+ align-items: center;
792
+ justify-content: center;
793
+ color: var(--du-text);
794
+ }
795
+
796
+ .du-palette-item-icon svg {
797
+ width: 100%;
798
+ height: 100%;
799
+ display: block;
800
+ }
801
+
802
+ .du-palette-item-label {
803
+ /* Two-line clamp so long names don't push the tile out of square. */
804
+ display: -webkit-box;
805
+ -webkit-line-clamp: 2;
806
+ -webkit-box-orient: vertical;
807
+ overflow: hidden;
808
+ text-overflow: ellipsis;
809
+ }
810
+
811
+ /* ------------------------------------------------------------------ */
812
+ /* Property panel \u2014 modern-style sectioned inspector. */
813
+ /* Sections are stacked top-to-bottom; each one has a tiny uppercase */
814
+ /* label, then a row of controls (color swatches, segmented buttons, */
815
+ /* slider). No card chrome \u2014 visual structure comes from spacing. */
816
+ /* ------------------------------------------------------------------ */
817
+ .du-prop-panel {
818
+ display: flex;
819
+ flex-direction: column;
820
+ gap: 16px;
821
+ padding: 4px 0;
822
+ color: var(--du-text);
823
+ font-size: 12px;
824
+ }
825
+
826
+ .du-prop-section {
827
+ display: flex;
828
+ flex-direction: column;
829
+ gap: 6px;
830
+ }
831
+
832
+ .du-prop-section-label {
833
+ margin: 0;
834
+ font-size: 10px;
835
+ font-weight: 600;
836
+ text-transform: uppercase;
837
+ letter-spacing: 0.5px;
838
+ color: var(--du-text-muted);
839
+ }
840
+
841
+ .du-prop-row {
842
+ display: flex;
843
+ align-items: center;
844
+ gap: var(--du-gap-sm);
845
+ flex-wrap: wrap;
846
+ }
847
+
848
+ .du-prop-row-label {
849
+ font-size: 11px;
850
+ color: var(--du-text-muted);
851
+ min-width: 48px;
852
+ }
853
+
854
+ .du-prop-empty {
855
+ font-style: italic;
856
+ color: var(--du-text-muted);
857
+ font-size: 12px;
858
+ }
859
+
860
+ /* modern-style flat segmented control inside the panel:
861
+ no card chrome on the ButtonGroup wrapper. The buttons still
862
+ read as a row through their tonal \`is-active\` fill + hover. */
863
+ .du-prop-panel .du-button-group {
864
+ background: transparent;
865
+ border: none;
866
+ box-shadow: none;
867
+ padding: 0;
868
+ gap: 2px;
869
+ }
870
+
871
+ /* Tighter active state inside the panel (smaller buttons, same
872
+ tonal pair). Keeps the rest of the toolbar unaffected. */
873
+ .du-prop-panel .du-button-group > .du-icon-button {
874
+ width: var(--du-button-size-sm);
875
+ height: var(--du-button-size-sm);
876
+ }
877
+
878
+ /* Checkbox row \u2014 small native input + label. Used by Corners
879
+ "Auto radius" toggle. */
880
+ .du-prop-checkbox {
881
+ display: inline-flex;
882
+ align-items: center;
883
+ gap: 6px;
884
+ cursor: pointer;
885
+ font-size: 12px;
886
+ color: var(--du-text);
887
+ user-select: none;
888
+ }
889
+
890
+ .du-prop-checkbox input[type="checkbox"] {
891
+ width: 14px;
892
+ height: 14px;
893
+ margin: 0;
894
+ accent-color: var(--du-selected-fg);
895
+ cursor: pointer;
896
+ }
897
+
898
+ /* ------------------------------------------------------------------ */
899
+ /* Colour swatch grid \u2014 modern-style fixed 26 \xD7 26 cell with a */
900
+ /* 24 \xD7 24 fill that grows on hover to fill the cell. Selected cells */
901
+ /* get a 2 px tonal ring on the OUTER cell so the ring lands beside */
902
+ /* the colour, not over it. */
903
+ /* ------------------------------------------------------------------ */
904
+ .du-swatch-grid {
905
+ display: inline-flex;
906
+ flex-wrap: wrap;
907
+ gap: 4px;
908
+ max-width: 232px; /* 8 cells (26 \xD7 8 = 208) + 7 gaps \xD7 4 = ~232 */
909
+ }
910
+
911
+ .du-swatch {
912
+ position: relative;
913
+ width: 26px;
914
+ height: 26px;
915
+ padding: 0;
916
+ background: transparent;
917
+ border: none;
918
+ border-radius: var(--du-radius-sm);
919
+ cursor: pointer;
920
+ display: inline-flex;
921
+ align-items: center;
922
+ justify-content: center;
923
+ /* Reserve the ring space so width never changes on selection. */
924
+ box-shadow: inset 0 0 0 0 transparent;
925
+ transition: box-shadow 0.12s ease;
926
+ /* Suppress the UA tap-highlight on iOS so the cell looks clean
927
+ while the user drags through swatches. */
928
+ -webkit-tap-highlight-color: transparent;
929
+ }
930
+
931
+ .du-swatch:focus-visible {
932
+ outline: none;
933
+ box-shadow: inset 0 0 0 2px var(--du-accent);
934
+ }
935
+
936
+ .du-swatch[aria-checked="true"] {
937
+ box-shadow: inset 0 0 0 2px var(--du-selected-fg);
938
+ }
939
+
940
+ .du-swatch-fill {
941
+ display: inline-flex;
942
+ align-items: center;
943
+ justify-content: center;
944
+ width: 24px;
945
+ height: 24px;
946
+ border-radius: var(--du-radius-sm);
947
+ border: 1px solid var(--du-ui-border);
948
+ box-sizing: border-box;
949
+ transition:
950
+ width 0.12s ease,
951
+ height 0.12s ease,
952
+ border-color 0.12s ease;
953
+ }
954
+
955
+ .du-swatch:hover .du-swatch-fill,
956
+ .du-swatch:focus-visible .du-swatch-fill {
957
+ width: 26px;
958
+ height: 26px;
959
+ }
960
+
961
+ /* Clear (\xD7) + custom-picker (+) cells use the same chrome as a
962
+ regular swatch but with a neutral fill + glyph slot. */
963
+ .du-swatch-fill-blank {
964
+ background: var(--du-ui-bg-solid);
965
+ color: var(--du-text-muted);
966
+ }
967
+
968
+ .du-swatch-custom .du-swatch-fill {
969
+ background: var(--du-ui-bg-solid);
970
+ color: var(--du-text-muted);
971
+ }
972
+
973
+ .du-swatch-color-input {
974
+ position: absolute;
975
+ inset: 0;
976
+ opacity: 0;
977
+ cursor: pointer;
978
+ border: none;
979
+ padding: 0;
980
+ }
981
+
982
+ /* ------------------------------------------------------------------ */
983
+ /* Slider \u2014 themed native <input type=range> + value badge. */
984
+ /* ------------------------------------------------------------------ */
985
+ .du-slider {
986
+ display: flex;
987
+ align-items: center;
988
+ gap: 8px;
989
+ width: 100%;
990
+ }
991
+
992
+ .du-slider-track {
993
+ flex: 1;
994
+ -webkit-appearance: none;
995
+ appearance: none;
996
+ background: transparent;
997
+ height: 18px;
998
+ margin: 0;
999
+ padding: 0;
1000
+ cursor: pointer;
1001
+ }
1002
+
1003
+ .du-slider-track::-webkit-slider-runnable-track {
1004
+ height: 4px;
1005
+ background: var(--du-selected-bg);
1006
+ border-radius: 2px;
1007
+ }
1008
+
1009
+ .du-slider-track::-moz-range-track {
1010
+ height: 4px;
1011
+ background: var(--du-selected-bg);
1012
+ border-radius: 2px;
1013
+ border: none;
1014
+ }
1015
+
1016
+ .du-slider-track::-webkit-slider-thumb {
1017
+ -webkit-appearance: none;
1018
+ appearance: none;
1019
+ width: 14px;
1020
+ height: 14px;
1021
+ background: var(--du-selected-fg);
1022
+ border-radius: 50%;
1023
+ border: 2px solid var(--du-ui-bg-solid);
1024
+ margin-top: -5px;
1025
+ cursor: grab;
1026
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
1027
+ }
1028
+
1029
+ .du-slider-track::-moz-range-thumb {
1030
+ width: 14px;
1031
+ height: 14px;
1032
+ background: var(--du-selected-fg);
1033
+ border-radius: 50%;
1034
+ border: 2px solid var(--du-ui-bg-solid);
1035
+ cursor: grab;
1036
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
1037
+ }
1038
+
1039
+ .du-slider-track:focus {
1040
+ outline: none;
1041
+ }
1042
+
1043
+ .du-slider-track:focus-visible::-webkit-slider-thumb {
1044
+ outline: 2px solid var(--du-accent);
1045
+ outline-offset: 2px;
1046
+ }
1047
+
1048
+ .du-slider-value {
1049
+ min-width: 36px;
1050
+ text-align: right;
1051
+ font-variant-numeric: tabular-nums;
1052
+ font-size: 11px;
1053
+ color: var(--du-text-muted);
1054
+ }
1055
+
1056
+ /* ------------------------------------------------------------------ */
1057
+ /* Number input \u2014 small themed \`<input type=number>\`. */
1058
+ /* ------------------------------------------------------------------ */
1059
+ .du-number-input {
1060
+ width: 64px;
1061
+ height: 24px;
1062
+ box-sizing: border-box;
1063
+ background: var(--du-ui-bg-solid);
1064
+ color: var(--du-text);
1065
+ border: 1px solid var(--du-ui-border);
1066
+ border-radius: var(--du-radius-sm);
1067
+ padding: 0 6px;
1068
+ font: inherit;
1069
+ font-size: 11px;
1070
+ font-variant-numeric: tabular-nums;
1071
+ outline: none;
1072
+ }
1073
+
1074
+ .du-number-input:focus {
1075
+ border-color: var(--du-accent);
1076
+ }
1077
+
1078
+ /* Search input row \u2014 sits between the header and the body. */
1079
+ .du-side-panel-search {
1080
+ position: relative;
1081
+ padding: var(--du-pad-sm) var(--du-pad);
1082
+ border-bottom: 1px solid var(--du-ui-border);
1083
+ }
1084
+
1085
+ .du-side-panel-search input[type="search"] {
1086
+ width: 100%;
1087
+ height: 28px;
1088
+ box-sizing: border-box;
1089
+ background: var(--du-ui-bg-solid);
1090
+ color: var(--du-text);
1091
+ border: 1px solid var(--du-ui-border);
1092
+ border-radius: var(--du-radius-sm);
1093
+ padding: 0 8px 0 26px;
1094
+ font: inherit;
1095
+ font-size: 12px;
1096
+ outline: none;
1097
+ }
1098
+
1099
+ .du-side-panel-search input[type="search"]::placeholder {
1100
+ color: var(--du-text-muted);
1101
+ }
1102
+
1103
+ .du-side-panel-search input[type="search"]:focus {
1104
+ border-color: var(--du-accent);
1105
+ }
1106
+
1107
+ .du-side-panel-search-icon {
1108
+ position: absolute;
1109
+ left: calc(var(--du-pad) + 8px);
1110
+ top: 50%;
1111
+ transform: translateY(-50%);
1112
+ color: var(--du-text-muted);
1113
+ pointer-events: none;
1114
+ }
1115
+
1116
+ /* ------------------------------------------------------------------ */
1117
+ /* Toast for reset-to-content visibility hint. */
1118
+ /* ------------------------------------------------------------------ */
1119
+ .du-pill-button {
1120
+ display: inline-flex;
1121
+ align-items: center;
1122
+ gap: var(--du-gap-sm);
1123
+ padding: 0 12px;
1124
+ height: var(--du-button-size);
1125
+ background: var(--du-ui-bg);
1126
+ color: var(--du-text);
1127
+ border: 1px solid var(--du-ui-border);
1128
+ border-radius: 999px;
1129
+ box-shadow: var(--du-ui-shadow);
1130
+ cursor: pointer;
1131
+ font-size: 13px;
1132
+ line-height: 1;
1133
+ white-space: nowrap;
1134
+ transition:
1135
+ background 0.15s ease,
1136
+ transform 0.05s ease;
1137
+ }
1138
+
1139
+ .du-pill-button:hover {
1140
+ background: var(--du-ui-bg-solid);
1141
+ }
1142
+
1143
+ .du-pill-button:active {
1144
+ transform: scale(0.96);
1145
+ }
1146
+
1147
+ /* ------------------------------------------------------------------ */
1148
+ /* Tooltip \u2014 singleton popup rendered via portal by <TooltipProvider>.*/
1149
+ /* Pointer-events-none so it never blocks hover on neighbour buttons. */
1150
+ /* ------------------------------------------------------------------ */
1151
+ .du-tooltip {
1152
+ background: var(--du-text);
1153
+ color: var(--du-ui-bg-solid);
1154
+ padding: 4px 8px;
1155
+ border-radius: var(--du-radius-sm);
1156
+ font-size: 12px;
1157
+ line-height: 1.4;
1158
+ white-space: nowrap;
1159
+ box-shadow: var(--du-ui-shadow);
1160
+ font-family: inherit;
1161
+ max-width: 260px;
1162
+ }
1163
+
1164
+ /* ------------------------------------------------------------------ */
1165
+ /* Help dialog \u2014 modern-style hotkey cheatsheet. */
1166
+ /* Each section is an "island" with bordered rows; each key is its */
1167
+ /* own pill \`<kbd>\` rendered with the same tonal selected fill as */
1168
+ /* active toolbar buttons so the visual language stays consistent. */
1169
+ /* ------------------------------------------------------------------ */
1170
+ .du-help-islands {
1171
+ display: grid;
1172
+ gap: 24px;
1173
+ grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
1174
+ }
1175
+
1176
+ .du-help-island {
1177
+ display: flex;
1178
+ flex-direction: column;
1179
+ gap: 8px;
1180
+ }
1181
+
1182
+ .du-help-island-title {
1183
+ margin: 0;
1184
+ font-size: 13px;
1185
+ font-weight: 600;
1186
+ color: var(--du-text);
1187
+ letter-spacing: 0.2px;
1188
+ }
1189
+
1190
+ .du-help-island-rows {
1191
+ border: 1px solid var(--du-ui-border);
1192
+ border-radius: var(--du-radius);
1193
+ overflow: hidden;
1194
+ }
1195
+
1196
+ .du-help-row {
1197
+ display: flex;
1198
+ align-items: center;
1199
+ justify-content: space-between;
1200
+ gap: 12px;
1201
+ padding: 8px 12px;
1202
+ font-size: 13px;
1203
+ color: var(--du-text);
1204
+ border-bottom: 1px solid var(--du-ui-border);
1205
+ }
1206
+
1207
+ .du-help-row:last-child {
1208
+ border-bottom: none;
1209
+ }
1210
+
1211
+ .du-help-row-label {
1212
+ /* Label may wrap on narrow viewports; keys stay on a single line. */
1213
+ min-width: 0;
1214
+ }
1215
+
1216
+ .du-help-keys {
1217
+ display: inline-flex;
1218
+ align-items: center;
1219
+ gap: 4px;
1220
+ flex-shrink: 0;
1221
+ }
1222
+
1223
+ .du-help-keys-separator {
1224
+ font-size: 11px;
1225
+ color: var(--du-text-muted);
1226
+ padding: 0 2px;
1227
+ }
1228
+
1229
+ .du-help-key {
1230
+ display: inline-flex;
1231
+ align-items: center;
1232
+ justify-content: center;
1233
+ min-width: 22px;
1234
+ height: 22px;
1235
+ padding: 0 6px;
1236
+ background: var(--du-selected-bg);
1237
+ color: var(--du-selected-fg);
1238
+ border-radius: var(--du-radius-sm);
1239
+ font-family: inherit;
1240
+ font-size: 11px;
1241
+ font-weight: 600;
1242
+ line-height: 1;
1243
+ white-space: nowrap;
1244
+ }
1245
+
1246
+ .du-help-platform-badge {
1247
+ font-size: 11px;
1248
+ color: var(--du-text-muted);
1249
+ text-transform: uppercase;
1250
+ letter-spacing: 0.5px;
1251
+ }
1252
+
1253
+ /* ------------------------------------------------------------------ */
1254
+ /* Selection floating panel \u2014 modern-style horizontal toolbar that */
1255
+ /* hovers above the selection bbox. Position is set inline via */
1256
+ /* \`transform:translate(...)\` by floating-ui \u2014 these rules cover only */
1257
+ /* the visual chrome (pill background, shadow, animation, layout of */
1258
+ /* inline controls + their popover triggers). */
1259
+ /* ------------------------------------------------------------------ */
1260
+ /* Fade-in is handled inline via the \`positioned\` state in
1261
+ <SelectionFloatingPanel> \u2014 a CSS animation here would override the
1262
+ inline \`transform: translate(...)\` floating-ui writes, causing
1263
+ the panel to flash at the (0, 0) origin before snapping into
1264
+ place. */
1265
+
1266
+ .du-sel-panel {
1267
+ display: inline-flex;
1268
+ align-items: center;
1269
+ gap: var(--du-gap-sm);
1270
+ background: var(--du-ui-bg-solid);
1271
+ border: 1px solid var(--du-ui-border);
1272
+ border-radius: var(--du-radius);
1273
+ box-shadow: var(--du-ui-shadow);
1274
+ padding: var(--du-pad-sm);
1275
+ font-size: 12px;
1276
+ color: var(--du-text);
1277
+ max-width: calc(100vw - 32px);
1278
+ /* Allow horizontal scroll within the pill when too many controls
1279
+ are visible; \`shift\` middleware clamps the outer position but
1280
+ a panel wider than viewport still needs internal overflow. */
1281
+ overflow-x: auto;
1282
+ overflow-y: visible;
1283
+ scrollbar-width: thin;
1284
+ }
1285
+
1286
+ /* ---- Mobile bottom-sheet property panel (modern-style) ---- */
1287
+ /* Fixed dock at the bottom edge; transparent container so only the
1288
+ panel itself catches touches. Honours the home-indicator safe area. */
1289
+ .du-sel-panel-dock {
1290
+ position: fixed;
1291
+ left: 0;
1292
+ right: 0;
1293
+ /* Sit ABOVE the bottom bar (zoom / help) + the home-indicator safe area
1294
+ so the two don't overlap. Mirrors the side-panel top offset. */
1295
+ bottom: calc(
1296
+ var(--du-bar-inset) + var(--du-button-size) + var(--du-gap) + env(safe-area-inset-bottom, 0px)
1297
+ );
1298
+ z-index: 1500;
1299
+ display: flex;
1300
+ justify-content: center;
1301
+ padding: 0 8px;
1302
+ pointer-events: none;
1303
+ }
1304
+
1305
+ /* Full-width sheet: a primary row + (when \u22EE is tapped) a wrapped
1306
+ overflow grid below. Overrides the floating pill's row/scroll chrome. */
1307
+ .du-sel-panel-mobile {
1308
+ pointer-events: auto;
1309
+ flex-direction: column;
1310
+ align-items: stretch;
1311
+ width: 100%;
1312
+ max-width: 560px;
1313
+ overflow: visible;
1314
+ gap: 6px;
1315
+ padding: 8px;
1316
+ }
1317
+ .du-sel-mobile-row {
1318
+ display: flex;
1319
+ align-items: center;
1320
+ gap: var(--du-gap-sm);
1321
+ width: 100%;
1322
+ }
1323
+ /* Primary controls scroll horizontally if they don't fit; the \u22EE button
1324
+ stays pinned to the right, always reachable. */
1325
+ .du-sel-mobile-primary {
1326
+ display: flex;
1327
+ align-items: center;
1328
+ gap: var(--du-gap-sm);
1329
+ flex: 1 1 auto;
1330
+ min-width: 0;
1331
+ overflow-x: auto;
1332
+ scrollbar-width: none;
1333
+ }
1334
+ .du-sel-mobile-primary::-webkit-scrollbar {
1335
+ display: none;
1336
+ }
1337
+ .du-sel-mobile-expand {
1338
+ flex: 0 0 auto;
1339
+ }
1340
+ .du-sel-mobile-overflow {
1341
+ display: flex;
1342
+ flex-wrap: wrap;
1343
+ align-items: center;
1344
+ gap: var(--du-gap-sm);
1345
+ border-top: 1px solid var(--du-ui-border);
1346
+ padding-top: 8px;
1347
+ }
1348
+ /* \u226544px touch targets on the mobile panel (Apple HIG). Standalone icon
1349
+ buttons + color triggers grow; grouped segmented buttons stay a touch
1350
+ smaller so wide controls (font-size S/M/L/XL) still fit one row. */
1351
+ .du-sel-panel-mobile .du-sel-icon-button,
1352
+ .du-sel-panel-mobile .du-sel-color-trigger {
1353
+ width: 44px;
1354
+ height: 44px;
1355
+ }
1356
+ .du-sel-panel-mobile .du-button-group > .du-icon-button {
1357
+ width: 38px;
1358
+ height: 38px;
1359
+ }
1360
+
1361
+ /* Flat segmented controls inside the floating panel \u2014 no group
1362
+ pill chrome (the outer panel already provides it). Reuses the
1363
+ button-group rules from PropertyPanel but with tighter gaps. */
1364
+ .du-sel-panel .du-button-group {
1365
+ background: transparent;
1366
+ border: none;
1367
+ box-shadow: none;
1368
+ padding: 0;
1369
+ gap: 2px;
1370
+ }
1371
+
1372
+ .du-sel-panel .du-button-group > .du-icon-button {
1373
+ width: var(--du-button-size-sm);
1374
+ height: var(--du-button-size-sm);
1375
+ }
1376
+
1377
+ /* Color swatch trigger \u2014 28\xD728 with 20\xD720 colored square inside. */
1378
+ .du-sel-color-trigger {
1379
+ display: inline-flex;
1380
+ align-items: center;
1381
+ justify-content: center;
1382
+ width: var(--du-button-size-sm);
1383
+ height: var(--du-button-size-sm);
1384
+ padding: 0;
1385
+ background: transparent;
1386
+ border: none;
1387
+ border-radius: var(--du-radius-sm);
1388
+ cursor: pointer;
1389
+ -webkit-tap-highlight-color: transparent;
1390
+ }
1391
+
1392
+ .du-sel-color-trigger:hover:not(:disabled) {
1393
+ background: var(--du-hover-overlay);
1394
+ }
1395
+
1396
+ .du-sel-color-trigger:focus-visible {
1397
+ outline: 2px solid var(--du-accent);
1398
+ outline-offset: 1px;
1399
+ }
1400
+
1401
+ .du-sel-color-swatch {
1402
+ display: inline-block;
1403
+ width: 18px;
1404
+ height: 18px;
1405
+ border-radius: 4px;
1406
+ border: 1px solid var(--du-ui-border);
1407
+ box-sizing: border-box;
1408
+ }
1409
+
1410
+ /* Plain icon button used for corners / etc. Same chrome as
1411
+ color-trigger but icon inside. */
1412
+ .du-sel-icon-button {
1413
+ display: inline-flex;
1414
+ align-items: center;
1415
+ justify-content: center;
1416
+ width: var(--du-button-size-sm);
1417
+ height: var(--du-button-size-sm);
1418
+ padding: 0;
1419
+ background: transparent;
1420
+ border: none;
1421
+ border-radius: var(--du-radius-sm);
1422
+ cursor: pointer;
1423
+ color: var(--du-text);
1424
+ }
1425
+
1426
+ .du-sel-icon-button:hover:not(:disabled) {
1427
+ background: var(--du-hover-overlay);
1428
+ }
1429
+
1430
+ /* Pressed / on state for toggle buttons (Bold / Italic / Underline /
1431
+ Strikethrough in the text style popover). Without this the computed
1432
+ \`is-active\` class had no visual, so toggles never reflected the
1433
+ selection's current style. */
1434
+ .du-sel-icon-button.is-active {
1435
+ background: var(--du-accent-soft, rgba(80, 130, 255, 0.22));
1436
+ color: var(--du-accent, #5082ff);
1437
+ }
1438
+
1439
+ .du-sel-icon-button:focus-visible {
1440
+ outline: 2px solid var(--du-accent);
1441
+ outline-offset: 1px;
1442
+ }
1443
+
1444
+ /* Text-label button (opacity badge "75%"). */
1445
+ .du-sel-text-button {
1446
+ display: inline-flex;
1447
+ align-items: center;
1448
+ justify-content: center;
1449
+ height: var(--du-button-size-sm);
1450
+ min-width: var(--du-button-size-sm);
1451
+ padding: 0 8px;
1452
+ background: transparent;
1453
+ border: none;
1454
+ border-radius: var(--du-radius-sm);
1455
+ cursor: pointer;
1456
+ color: var(--du-text);
1457
+ font-size: 12px;
1458
+ font-variant-numeric: tabular-nums;
1459
+ }
1460
+
1461
+ .du-sel-text-button:hover:not(:disabled) {
1462
+ background: var(--du-hover-overlay);
1463
+ }
1464
+
1465
+ .du-sel-text-button:focus-visible {
1466
+ outline: 2px solid var(--du-accent);
1467
+ outline-offset: 1px;
1468
+ }
1469
+
1470
+ /* Visual divider between inline groups (z-order, actions). */
1471
+ .du-sel-divider {
1472
+ display: inline-block;
1473
+ width: 1px;
1474
+ height: 18px;
1475
+ background: var(--du-ui-border);
1476
+ margin: 0 2px;
1477
+ }
1478
+
1479
+ /* ------------------------------------------------------------------ */
1480
+ /* Popover \u2014 generic floating panel used by color picker / corners / */
1481
+ /* opacity slider inside the selection floating panel. */
1482
+ /* ------------------------------------------------------------------ */
1483
+ .du-popover {
1484
+ background: var(--du-ui-bg-solid);
1485
+ border: 1px solid var(--du-ui-border);
1486
+ border-radius: var(--du-radius);
1487
+ box-shadow: var(--du-ui-shadow);
1488
+ padding: var(--du-pad);
1489
+ font-size: 12px;
1490
+ color: var(--du-text);
1491
+ min-width: 120px;
1492
+ max-width: 320px;
1493
+ }
1494
+
1495
+ .du-sel-popover-section {
1496
+ display: flex;
1497
+ flex-direction: column;
1498
+ gap: 8px;
1499
+ min-width: 0;
1500
+ }
1501
+
1502
+ .du-sel-popover-label {
1503
+ margin: 0;
1504
+ font-size: 10px;
1505
+ font-weight: 600;
1506
+ text-transform: uppercase;
1507
+ letter-spacing: 0.5px;
1508
+ color: var(--du-text-muted);
1509
+ }
1510
+
1511
+ /* Vertical list row inside a selection popover (e.g. font-family
1512
+ picker). One full-width clickable row; \`is-active\` marks the
1513
+ current value. */
1514
+ .du-sel-menu-row {
1515
+ all: unset;
1516
+ display: block;
1517
+ width: 100%;
1518
+ box-sizing: border-box;
1519
+ padding: 6px 10px;
1520
+ border-radius: 4px;
1521
+ font-size: 13px;
1522
+ color: var(--du-text, #ddd);
1523
+ cursor: pointer;
1524
+ }
1525
+
1526
+ .du-sel-menu-row:hover {
1527
+ background: var(--du-ui-hover, #2a2a2a);
1528
+ }
1529
+
1530
+ .du-sel-menu-row.is-active {
1531
+ background: var(--du-accent-soft, rgba(80, 130, 255, 0.2));
1532
+ }
1533
+
1534
+ /* URL field inside the element-link popover. */
1535
+ .du-sel-link-input {
1536
+ width: 220px;
1537
+ max-width: 60vw;
1538
+ box-sizing: border-box;
1539
+ padding: 6px 8px;
1540
+ font-size: 13px;
1541
+ color: var(--du-text, #ddd);
1542
+ background: var(--du-ui-bg, #1a1a1a);
1543
+ border: 1px solid var(--du-ui-border, #333);
1544
+ border-radius: 4px;
1545
+ outline: none;
1546
+ }
1547
+
1548
+ .du-sel-link-input:focus-visible {
1549
+ outline: 2px solid var(--du-accent, #5082ff);
1550
+ outline-offset: -1px;
1551
+ }
1552
+
1553
+ /* Hover link popup (chip above a linked element). */
1554
+ .du-link-popup {
1555
+ z-index: 1400;
1556
+ margin-top: -6px;
1557
+ pointer-events: auto;
1558
+ }
1559
+
1560
+ .du-link-popup-url {
1561
+ display: inline-flex;
1562
+ align-items: center;
1563
+ gap: 6px;
1564
+ max-width: 280px;
1565
+ padding: 4px 8px;
1566
+ font:
1567
+ 12px system-ui,
1568
+ -apple-system,
1569
+ Segoe UI,
1570
+ Roboto,
1571
+ sans-serif;
1572
+ color: var(--du-accent, #5082ff);
1573
+ text-decoration: none;
1574
+ background: var(--menu-bg, #1a1a1a);
1575
+ border: 1px solid var(--menu-border, #333);
1576
+ border-radius: 6px;
1577
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
1578
+ cursor: pointer;
1579
+ }
1580
+
1581
+ .du-link-popup-url:hover {
1582
+ background: var(--du-ui-hover, #2a2a2a);
1583
+ }
1584
+
1585
+ .du-link-popup-text {
1586
+ overflow: hidden;
1587
+ text-overflow: ellipsis;
1588
+ white-space: nowrap;
1589
+ max-width: 240px;
1590
+ }
1591
+
1592
+ /* Arrowhead picker popover (per-end). */
1593
+ .du-arrowhead-grid {
1594
+ display: grid;
1595
+ grid-template-columns: repeat(4, 1fr);
1596
+ gap: 2px;
1597
+ margin-top: 4px;
1598
+ }
1599
+ .du-arrowhead-option {
1600
+ display: inline-flex;
1601
+ align-items: center;
1602
+ justify-content: center;
1603
+ min-width: 30px;
1604
+ height: 26px;
1605
+ padding: 2px;
1606
+ border: 1px solid transparent;
1607
+ border-radius: 6px;
1608
+ background: transparent;
1609
+ cursor: pointer;
1610
+ color: var(--du-fg, #1c1c1e);
1611
+ }
1612
+ .du-arrowhead-option:hover {
1613
+ background: var(--du-hover, #f0f0f3);
1614
+ }
1615
+ .du-arrowhead-option--active {
1616
+ border-color: var(--du-accent, #5082ff);
1617
+ }
1618
+ .du-arrowhead-none {
1619
+ font-size: 13px;
1620
+ opacity: 0.6;
1621
+ }
1622
+ .du-arrowhead-erd-label {
1623
+ font-size: 9px;
1624
+ line-height: 1.05;
1625
+ text-align: center;
1626
+ }
1627
+ .du-arrowhead-erd-toggle {
1628
+ margin-top: 6px;
1629
+ width: 100%;
1630
+ text-align: left;
1631
+ border: none;
1632
+ background: transparent;
1633
+ cursor: pointer;
1634
+ font-size: 11px;
1635
+ color: var(--du-muted, #6b6b70);
1636
+ padding: 2px 0;
1637
+ }
1638
+ .du-arrowhead-erd-toggle:hover {
1639
+ color: var(--du-fg, #1c1c1e);
1640
+ }
1641
+
1642
+ /* Inline link caption editor. */
1643
+ .du-link-caption-input {
1644
+ min-width: 60px;
1645
+ max-width: 220px;
1646
+ padding: 2px 6px;
1647
+ font:
1648
+ 12px system-ui,
1649
+ sans-serif;
1650
+ text-align: center;
1651
+ color: var(--du-fg, #222);
1652
+ background: var(--du-panel-bg, #fff);
1653
+ border: 1px solid var(--du-accent, #5082ff);
1654
+ border-radius: 4px;
1655
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
1656
+ outline: none;
1657
+ }
1658
+
1659
+ /* Mini shape-picker shown after a link is dropped on empty canvas. */
1660
+ .du-link-drop-menu {
1661
+ display: flex;
1662
+ gap: 2px;
1663
+ padding: 4px;
1664
+ background: var(--du-panel-bg, #fff);
1665
+ border: 1px solid var(--du-border, #e3e3e6);
1666
+ border-radius: 8px;
1667
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
1668
+ }
1669
+ .du-link-drop-item {
1670
+ display: inline-flex;
1671
+ align-items: center;
1672
+ justify-content: center;
1673
+ width: 30px;
1674
+ height: 30px;
1675
+ padding: 4px;
1676
+ border: none;
1677
+ border-radius: 6px;
1678
+ background: transparent;
1679
+ cursor: pointer;
1680
+ color: var(--du-fg, #1c1c1e);
1681
+ }
1682
+ .du-link-drop-item:hover {
1683
+ background: var(--du-hover, #f0f0f3);
1684
+ }
1685
+ .du-link-drop-item svg {
1686
+ width: 100%;
1687
+ height: 100%;
1688
+ }
1689
+
1690
+ .du-sel-menu-row:focus-visible {
1691
+ outline: 2px solid var(--du-accent, #5082ff);
1692
+ outline-offset: -2px;
1693
+ }
1694
+ `;var gL=F(ye(),1),$6=new Set(["dark","light","system"]),Ej=new Set(["canvas2d","webgl2","offscreen"]),Ty=null,Mj=()=>(Ty||(Ty=new CSSStyleSheet,Ty.replaceSync(K6.replace(/:root\b/g,":host"))),Ty),wp=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=[Mj()],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,Q6.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&&$6.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&&$6.has(t)?t:void 0,a=n&&Ej.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=p0(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,gL.jsx)(Bd,{container:this.#r,children:(0,gL.jsx)(kp,{ref:t=>{this.#e=t},...this.#c()})}))}};var Oj=["ready","scenechange","selectionchange","themechange"],J6=(e,t,n)=>{n?e.setAttribute(t,""):e.removeAttribute(t)},eM=(e,t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)},Rj=(e,t)=>{eM(e,"theme",t.theme),eM(e,"renderer",t.renderer),J6(e,"grid",t.grid??!1),J6(e,"snap",t.snap??!1),t.scene!==void 0&&(e.scene=t.scene)},Dj=(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()}},Pj=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 Bj="oja-diagram",zj=(e=Bj)=>{typeof customElements>"u"||customElements.get(e)||customElements.define(e,wp)};zj();export{Oj as OJA_DIAGRAM_EVENTS,Bj as OJA_DIAGRAM_TAG,wp as OjaDiagramElement,Rj as applyOjaDiagramProps,Dj as bindOjaDiagramEvents,zj as defineOjaDiagram,Pj as ojaDiagramController};
1695
+ /*! Bundled license information:
1696
+
1697
+ scheduler/cjs/scheduler.production.js:
1698
+ (**
1699
+ * @license React
1700
+ * scheduler.production.js
1701
+ *
1702
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1703
+ *
1704
+ * This source code is licensed under the MIT license found in the
1705
+ * LICENSE file in the root directory of this source tree.
1706
+ *)
1707
+
1708
+ react/cjs/react.production.js:
1709
+ (**
1710
+ * @license React
1711
+ * react.production.js
1712
+ *
1713
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1714
+ *
1715
+ * This source code is licensed under the MIT license found in the
1716
+ * LICENSE file in the root directory of this source tree.
1717
+ *)
1718
+
1719
+ react-dom/cjs/react-dom.production.js:
1720
+ (**
1721
+ * @license React
1722
+ * react-dom.production.js
1723
+ *
1724
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1725
+ *
1726
+ * This source code is licensed under the MIT license found in the
1727
+ * LICENSE file in the root directory of this source tree.
1728
+ *)
1729
+
1730
+ react-dom/cjs/react-dom-client.production.js:
1731
+ (**
1732
+ * @license React
1733
+ * react-dom-client.production.js
1734
+ *
1735
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1736
+ *
1737
+ * This source code is licensed under the MIT license found in the
1738
+ * LICENSE file in the root directory of this source tree.
1739
+ *)
1740
+
1741
+ react/cjs/react-jsx-runtime.production.js:
1742
+ (**
1743
+ * @license React
1744
+ * react-jsx-runtime.production.js
1745
+ *
1746
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1747
+ *
1748
+ * This source code is licensed under the MIT license found in the
1749
+ * LICENSE file in the root directory of this source tree.
1750
+ *)
1751
+
1752
+ lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
1753
+ lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs:
1754
+ lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs:
1755
+ lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs:
1756
+ lucide-react/dist/esm/defaultAttributes.mjs:
1757
+ lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs:
1758
+ lucide-react/dist/esm/context.mjs:
1759
+ lucide-react/dist/esm/Icon.mjs:
1760
+ lucide-react/dist/esm/createLucideIcon.mjs:
1761
+ lucide-react/dist/esm/icons/align-center-horizontal.mjs:
1762
+ lucide-react/dist/esm/icons/align-center-vertical.mjs:
1763
+ lucide-react/dist/esm/icons/align-end-horizontal.mjs:
1764
+ lucide-react/dist/esm/icons/align-end-vertical.mjs:
1765
+ lucide-react/dist/esm/icons/align-horizontal-distribute-center.mjs:
1766
+ lucide-react/dist/esm/icons/align-start-horizontal.mjs:
1767
+ lucide-react/dist/esm/icons/align-start-vertical.mjs:
1768
+ lucide-react/dist/esm/icons/align-vertical-distribute-center.mjs:
1769
+ lucide-react/dist/esm/icons/bold.mjs:
1770
+ lucide-react/dist/esm/icons/case-sensitive.mjs:
1771
+ lucide-react/dist/esm/icons/check.mjs:
1772
+ lucide-react/dist/esm/icons/chevron-down.mjs:
1773
+ lucide-react/dist/esm/icons/chevron-right.mjs:
1774
+ lucide-react/dist/esm/icons/chevrons-down.mjs:
1775
+ lucide-react/dist/esm/icons/chevrons-up.mjs:
1776
+ lucide-react/dist/esm/icons/circle-question-mark.mjs:
1777
+ lucide-react/dist/esm/icons/circle.mjs:
1778
+ lucide-react/dist/esm/icons/clipboard.mjs:
1779
+ lucide-react/dist/esm/icons/copy.mjs:
1780
+ lucide-react/dist/esm/icons/delete.mjs:
1781
+ lucide-react/dist/esm/icons/download.mjs:
1782
+ lucide-react/dist/esm/icons/ellipsis-vertical.mjs:
1783
+ lucide-react/dist/esm/icons/ellipsis.mjs:
1784
+ lucide-react/dist/esm/icons/external-link.mjs:
1785
+ lucide-react/dist/esm/icons/file-down.mjs:
1786
+ lucide-react/dist/esm/icons/file-up.mjs:
1787
+ lucide-react/dist/esm/icons/flip-horizontal-2.mjs:
1788
+ lucide-react/dist/esm/icons/flip-vertical-2.mjs:
1789
+ lucide-react/dist/esm/icons/frame.mjs:
1790
+ lucide-react/dist/esm/icons/grid-3x3.mjs:
1791
+ lucide-react/dist/esm/icons/grip.mjs:
1792
+ lucide-react/dist/esm/icons/group.mjs:
1793
+ lucide-react/dist/esm/icons/hand.mjs:
1794
+ lucide-react/dist/esm/icons/image-down.mjs:
1795
+ lucide-react/dist/esm/icons/image.mjs:
1796
+ lucide-react/dist/esm/icons/italic.mjs:
1797
+ lucide-react/dist/esm/icons/library.mjs:
1798
+ lucide-react/dist/esm/icons/link.mjs:
1799
+ lucide-react/dist/esm/icons/locate-fixed.mjs:
1800
+ lucide-react/dist/esm/icons/lock.mjs:
1801
+ lucide-react/dist/esm/icons/magnet.mjs:
1802
+ lucide-react/dist/esm/icons/maximize.mjs:
1803
+ lucide-react/dist/esm/icons/menu.mjs:
1804
+ lucide-react/dist/esm/icons/minus.mjs:
1805
+ lucide-react/dist/esm/icons/monitor.mjs:
1806
+ lucide-react/dist/esm/icons/moon.mjs:
1807
+ lucide-react/dist/esm/icons/mouse-pointer-2.mjs:
1808
+ lucide-react/dist/esm/icons/mouse-pointer.mjs:
1809
+ lucide-react/dist/esm/icons/move-down.mjs:
1810
+ lucide-react/dist/esm/icons/move-right.mjs:
1811
+ lucide-react/dist/esm/icons/move-up.mjs:
1812
+ lucide-react/dist/esm/icons/pen-line.mjs:
1813
+ lucide-react/dist/esm/icons/plus.mjs:
1814
+ lucide-react/dist/esm/icons/redo-2.mjs:
1815
+ lucide-react/dist/esm/icons/rotate-ccw.mjs:
1816
+ lucide-react/dist/esm/icons/scissors.mjs:
1817
+ lucide-react/dist/esm/icons/search.mjs:
1818
+ lucide-react/dist/esm/icons/slash.mjs:
1819
+ lucide-react/dist/esm/icons/spline.mjs:
1820
+ lucide-react/dist/esm/icons/square-dashed.mjs:
1821
+ lucide-react/dist/esm/icons/square-dot.mjs:
1822
+ lucide-react/dist/esm/icons/square.mjs:
1823
+ lucide-react/dist/esm/icons/strikethrough.mjs:
1824
+ lucide-react/dist/esm/icons/sun.mjs:
1825
+ lucide-react/dist/esm/icons/text-align-end.mjs:
1826
+ lucide-react/dist/esm/icons/text-align-center.mjs:
1827
+ lucide-react/dist/esm/icons/text-align-start.mjs:
1828
+ lucide-react/dist/esm/icons/trash-2.mjs:
1829
+ lucide-react/dist/esm/icons/type.mjs:
1830
+ lucide-react/dist/esm/icons/underline.mjs:
1831
+ lucide-react/dist/esm/icons/undo-2.mjs:
1832
+ lucide-react/dist/esm/icons/ungroup.mjs:
1833
+ lucide-react/dist/esm/icons/upload.mjs:
1834
+ lucide-react/dist/esm/icons/waypoints.mjs:
1835
+ lucide-react/dist/esm/icons/x.mjs:
1836
+ lucide-react/dist/esm/icons/zoom-out.mjs:
1837
+ lucide-react/dist/esm/icons/zoom-in.mjs:
1838
+ lucide-react/dist/esm/lucide-react.mjs:
1839
+ (**
1840
+ * @license lucide-react v1.16.0 - ISC
1841
+ *
1842
+ * This source code is licensed under the ISC license.
1843
+ * See the LICENSE file in the root directory of this source tree.
1844
+ *)
1845
+ */
1846
+ //# sourceMappingURL=oja-diagram.global.js.map