@kitschpatrol/tldraw-cli 4.6.16 → 4.6.18
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.
- package/bin/cli.js +24663 -2065
- package/dist/lib/index.js +24676 -2082
- package/dist/tldraw/assets/{index-Dt7-dFc-.css → index-BTgE_-vf.css} +1 -1
- package/dist/tldraw/assets/index-DVTri2z4.js +431 -0
- package/dist/tldraw/index.html +2 -2
- package/package.json +9 -9
- package/dist/.DS_Store +0 -0
- package/dist/tldraw/assets/index-DAN0_a7f.js +0 -441
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
var ghe=Object.defineProperty;var mhe=(t,e,r)=>e in t?ghe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var C=(t,e,r)=>mhe(t,typeof e!="symbol"?e+"":e,r);function vhe(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const o in n)if(o!=="default"&&!(o in t)){const i=Object.getOwnPropertyDescriptor(n,o);i&&Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>n[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(o){if(o.ep)return;o.ep=!0;const i=r(o);fetch(o.href,i)}})();var Zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Y9={exports:{}},cx={},X9={exports:{}},We={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Dg=Symbol.for("react.element"),yhe=Symbol.for("react.portal"),She=Symbol.for("react.fragment"),whe=Symbol.for("react.strict_mode"),xhe=Symbol.for("react.profiler"),bhe=Symbol.for("react.provider"),$he=Symbol.for("react.context"),Ihe=Symbol.for("react.forward_ref"),Phe=Symbol.for("react.suspense"),Ehe=Symbol.for("react.memo"),Che=Symbol.for("react.lazy"),kD=Symbol.iterator;function _he(t){return t===null||typeof t!="object"?null:(t=kD&&t[kD]||t["@@iterator"],typeof t=="function"?t:null)}var q9={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Z9=Object.assign,Q9={};function yh(t,e,r){this.props=t,this.context=e,this.refs=Q9,this.updater=r||q9}yh.prototype.isReactComponent={};yh.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};yh.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function J9(){}J9.prototype=yh.prototype;function IA(t,e,r){this.props=t,this.context=e,this.refs=Q9,this.updater=r||q9}var PA=IA.prototype=new J9;PA.constructor=IA;Z9(PA,yh.prototype);PA.isPureReactComponent=!0;var OD=Array.isArray,eH=Object.prototype.hasOwnProperty,EA={current:null},tH={key:!0,ref:!0,__self:!0,__source:!0};function rH(t,e,r){var n,o={},i=null,s=null;if(e!=null)for(n in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(i=""+e.key),e)eH.call(e,n)&&!tH.hasOwnProperty(n)&&(o[n]=e[n]);var a=arguments.length-2;if(a===1)o.children=r;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];o.children=l}if(t&&t.defaultProps)for(n in a=t.defaultProps,a)o[n]===void 0&&(o[n]=a[n]);return{$$typeof:Dg,type:t,key:i,ref:s,props:o,_owner:EA.current}}function The(t,e){return{$$typeof:Dg,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function CA(t){return typeof t=="object"&&t!==null&&t.$$typeof===Dg}function Ahe(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var MD=/\/+/g;function e$(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Ahe(""+t.key):e.toString(36)}function nS(t,e,r,n,o){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var s=!1;if(t===null)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(t.$$typeof){case Dg:case yhe:s=!0}}if(s)return s=t,o=o(s),t=n===""?"."+e$(s,0):n,OD(o)?(r="",t!=null&&(r=t.replace(MD,"$&/")+"/"),nS(o,e,r,"",function(c){return c})):o!=null&&(CA(o)&&(o=The(o,r+(!o.key||s&&s.key===o.key?"":(""+o.key).replace(MD,"$&/")+"/")+t)),e.push(o)),1;if(s=0,n=n===""?".":n+":",OD(t))for(var a=0;a<t.length;a++){i=t[a];var l=n+e$(i,a);s+=nS(i,e,r,l,o)}else if(l=_he(t),typeof l=="function")for(t=l.call(t),a=0;!(i=t.next()).done;)i=i.value,l=n+e$(i,a++),s+=nS(i,e,r,l,o);else if(i==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return s}function Jm(t,e,r){if(t==null)return t;var n=[],o=0;return nS(t,n,"","",function(i){return e.call(r,i,o++)}),n}function khe(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(r){(t._status===0||t._status===-1)&&(t._status=1,t._result=r)},function(r){(t._status===0||t._status===-1)&&(t._status=2,t._result=r)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var mn={current:null},oS={transition:null},Ohe={ReactCurrentDispatcher:mn,ReactCurrentBatchConfig:oS,ReactCurrentOwner:EA};function nH(){throw Error("act(...) is not supported in production builds of React.")}We.Children={map:Jm,forEach:function(t,e,r){Jm(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return Jm(t,function(){e++}),e},toArray:function(t){return Jm(t,function(e){return e})||[]},only:function(t){if(!CA(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};We.Component=yh;We.Fragment=She;We.Profiler=xhe;We.PureComponent=IA;We.StrictMode=whe;We.Suspense=Phe;We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ohe;We.act=nH;We.cloneElement=function(t,e,r){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var n=Z9({},t.props),o=t.key,i=t.ref,s=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,s=EA.current),e.key!==void 0&&(o=""+e.key),t.type&&t.type.defaultProps)var a=t.type.defaultProps;for(l in e)eH.call(e,l)&&!tH.hasOwnProperty(l)&&(n[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)n.children=r;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];n.children=a}return{$$typeof:Dg,type:t.type,key:o,ref:i,props:n,_owner:s}};We.createContext=function(t){return t={$$typeof:$he,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:bhe,_context:t},t.Consumer=t};We.createElement=rH;We.createFactory=function(t){var e=rH.bind(null,t);return e.type=t,e};We.createRef=function(){return{current:null}};We.forwardRef=function(t){return{$$typeof:Ihe,render:t}};We.isValidElement=CA;We.lazy=function(t){return{$$typeof:Che,_payload:{_status:-1,_result:t},_init:khe}};We.memo=function(t,e){return{$$typeof:Ehe,type:t,compare:e===void 0?null:e}};We.startTransition=function(t){var e=oS.transition;oS.transition={};try{t()}finally{oS.transition=e}};We.unstable_act=nH;We.useCallback=function(t,e){return mn.current.useCallback(t,e)};We.useContext=function(t){return mn.current.useContext(t)};We.useDebugValue=function(){};We.useDeferredValue=function(t){return mn.current.useDeferredValue(t)};We.useEffect=function(t,e){return mn.current.useEffect(t,e)};We.useId=function(){return mn.current.useId()};We.useImperativeHandle=function(t,e,r){return mn.current.useImperativeHandle(t,e,r)};We.useInsertionEffect=function(t,e){return mn.current.useInsertionEffect(t,e)};We.useLayoutEffect=function(t,e){return mn.current.useLayoutEffect(t,e)};We.useMemo=function(t,e){return mn.current.useMemo(t,e)};We.useReducer=function(t,e,r){return mn.current.useReducer(t,e,r)};We.useRef=function(t){return mn.current.useRef(t)};We.useState=function(t){return mn.current.useState(t)};We.useSyncExternalStore=function(t,e,r){return mn.current.useSyncExternalStore(t,e,r)};We.useTransition=function(){return mn.current.useTransition()};We.version="18.3.1";X9.exports=We;var x=X9.exports;const ze=_l(x),Mhe=vhe({__proto__:null,default:ze},[x]);/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Rhe=x,jhe=Symbol.for("react.element"),Dhe=Symbol.for("react.fragment"),Lhe=Object.prototype.hasOwnProperty,Nhe=Rhe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Fhe={key:!0,ref:!0,__self:!0,__source:!0};function oH(t,e,r){var n,o={},i=null,s=null;r!==void 0&&(i=""+r),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Lhe.call(e,n)&&!Fhe.hasOwnProperty(n)&&(o[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:jhe,type:t,key:i,ref:s,props:o,_owner:Nhe.current}}cx.Fragment=Dhe;cx.jsx=oH;cx.jsxs=oH;Y9.exports=cx;var h=Y9.exports,NC={},iH={exports:{}},yo={},sH={exports:{}},aH={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(t){function e(z,W){var J=z.length;z.push(W);e:for(;0<J;){var oe=J-1>>>1,we=z[oe];if(0<o(we,W))z[oe]=W,z[J]=we,J=oe;else break e}}function r(z){return z.length===0?null:z[0]}function n(z){if(z.length===0)return null;var W=z[0],J=z.pop();if(J!==W){z[0]=J;e:for(var oe=0,we=z.length,_e=we>>>1;oe<_e;){var Ge=2*(oe+1)-1,de=z[Ge],ht=Ge+1,tt=z[ht];if(0>o(de,J))ht<we&&0>o(tt,de)?(z[oe]=tt,z[ht]=J,oe=ht):(z[oe]=de,z[Ge]=J,oe=Ge);else if(ht<we&&0>o(tt,J))z[oe]=tt,z[ht]=J,oe=ht;else break e}}return W}function o(z,W){var J=z.sortIndex-W.sortIndex;return J!==0?J:z.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var s=Date,a=s.now();t.unstable_now=function(){return s.now()-a}}var l=[],c=[],u=1,d=null,f=3,p=!1,g=!1,m=!1,S=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(z){for(var W=r(c);W!==null;){if(W.callback===null)n(c);else if(W.startTime<=z)n(c),W.sortIndex=W.expirationTime,e(l,W);else break;W=r(c)}}function $(z){if(m=!1,b(z),!g)if(r(l)!==null)g=!0,B(P);else{var W=r(c);W!==null&&K($,W.startTime-z)}}function P(z,W){g=!1,m&&(m=!1,y(I),I=-1),p=!0;var J=f;try{for(b(W),d=r(l);d!==null&&(!(d.expirationTime>W)||z&&!D());){var oe=d.callback;if(typeof oe=="function"){d.callback=null,f=d.priorityLevel;var we=oe(d.expirationTime<=W);W=t.unstable_now(),typeof we=="function"?d.callback=we:d===r(l)&&n(l),b(W)}else n(l);d=r(l)}if(d!==null)var _e=!0;else{var Ge=r(c);Ge!==null&&K($,Ge.startTime-W),_e=!1}return _e}finally{d=null,f=J,p=!1}}var E=!1,T=null,I=-1,_=5,k=-1;function D(){return!(t.unstable_now()-k<_)}function R(){if(T!==null){var z=t.unstable_now();k=z;var W=!0;try{W=T(!0,z)}finally{W?j():(E=!1,T=null)}}else E=!1}var j;if(typeof v=="function")j=function(){v(R)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,U=M.port2;M.port1.onmessage=R,j=function(){U.postMessage(null)}}else j=function(){S(R,0)};function B(z){T=z,E||(E=!0,j())}function K(z,W){I=S(function(){z(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_continueExecution=function(){g||p||(g=!0,B(P))},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(l)},t.unstable_next=function(z){switch(f){case 1:case 2:case 3:var W=3;break;default:W=f}var J=f;f=W;try{return z()}finally{f=J}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(z,W){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var J=f;f=z;try{return W()}finally{f=J}},t.unstable_scheduleCallback=function(z,W,J){var oe=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?oe+J:oe):J=oe,z){case 1:var we=-1;break;case 2:we=250;break;case 5:we=1073741823;break;case 4:we=1e4;break;default:we=5e3}return we=J+we,z={id:u++,callback:W,priorityLevel:z,startTime:J,expirationTime:we,sortIndex:-1},J>oe?(z.sortIndex=J,e(c,z),r(l)===null&&z===r(c)&&(m?(y(I),I=-1):m=!0,K($,J-oe))):(z.sortIndex=we,e(l,z),g||p||(g=!0,B(P))),z},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(z){var W=f;return function(){var J=f;f=W;try{return z.apply(this,arguments)}finally{f=J}}}})(aH);sH.exports=aH;var Bhe=sH.exports;/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Uhe=x,po=Bhe;function Z(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r<arguments.length;r++)e+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var lH=new Set,Vp={};function Qc(t,e){zd(t,e),zd(t+"Capture",e)}function zd(t,e){for(Vp[t]=e,t=0;t<e.length;t++)lH.add(e[t])}var ea=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),FC=Object.prototype.hasOwnProperty,zhe=/^[: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]*$/,RD={},jD={};function Hhe(t){return FC.call(jD,t)?!0:FC.call(RD,t)?!1:zhe.test(t)?jD[t]=!0:(RD[t]=!0,!1)}function Whe(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Khe(t,e,r,n){if(e===null||typeof e>"u"||Whe(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function vn(t,e,r,n,o,i,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=o,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=s}var jr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){jr[t]=new vn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];jr[e]=new vn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){jr[t]=new vn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){jr[t]=new vn(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){jr[t]=new vn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){jr[t]=new vn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){jr[t]=new vn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){jr[t]=new vn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){jr[t]=new vn(t,5,!1,t.toLowerCase(),null,!1,!1)});var _A=/[\-:]([a-z])/g;function TA(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(_A,TA);jr[e]=new vn(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(_A,TA);jr[e]=new vn(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(_A,TA);jr[e]=new vn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){jr[t]=new vn(t,1,!1,t.toLowerCase(),null,!1,!1)});jr.xlinkHref=new vn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){jr[t]=new vn(t,1,!1,t.toLowerCase(),null,!0,!0)});function AA(t,e,r,n){var o=jr.hasOwnProperty(e)?jr[e]:null;(o!==null?o.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(Khe(e,r,o,n)&&(r=null),n||o===null?Hhe(e)&&(r===null?t.removeAttribute(e):t.setAttribute(e,""+r)):o.mustUseProperty?t[o.propertyName]=r===null?o.type===3?!1:"":r:(e=o.attributeName,n=o.attributeNamespace,r===null?t.removeAttribute(e):(o=o.type,r=o===3||o===4&&r===!0?"":""+r,n?t.setAttributeNS(n,e,r):t.setAttribute(e,r))))}var fa=Uhe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ev=Symbol.for("react.element"),Xu=Symbol.for("react.portal"),qu=Symbol.for("react.fragment"),kA=Symbol.for("react.strict_mode"),BC=Symbol.for("react.profiler"),cH=Symbol.for("react.provider"),uH=Symbol.for("react.context"),OA=Symbol.for("react.forward_ref"),UC=Symbol.for("react.suspense"),zC=Symbol.for("react.suspense_list"),MA=Symbol.for("react.memo"),Na=Symbol.for("react.lazy"),dH=Symbol.for("react.offscreen"),DD=Symbol.iterator;function rf(t){return t===null||typeof t!="object"?null:(t=DD&&t[DD]||t["@@iterator"],typeof t=="function"?t:null)}var Ft=Object.assign,t$;function Yf(t){if(t$===void 0)try{throw Error()}catch(r){var e=r.stack.trim().match(/\n( *(at )?)/);t$=e&&e[1]||""}return`
|
|
34
|
-
`+t$+t}var r$=!1;function n$(t,e){if(!t||r$)return"";r$=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var n=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){n=c}t.call(e.prototype)}else{try{throw Error()}catch(c){n=c}t()}}catch(c){if(c&&n&&typeof c.stack=="string"){for(var o=c.stack.split(`
|
|
35
|
-
`),i=n.stack.split(`
|
|
36
|
-
`),s=o.length-1,a=i.length-1;1<=s&&0<=a&&o[s]!==i[a];)a--;for(;1<=s&&0<=a;s--,a--)if(o[s]!==i[a]){if(s!==1||a!==1)do if(s--,a--,0>a||o[s]!==i[a]){var l=`
|
|
37
|
-
`+o[s].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=s&&0<=a);break}}}finally{r$=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Yf(t):""}function Ghe(t){switch(t.tag){case 5:return Yf(t.type);case 16:return Yf("Lazy");case 13:return Yf("Suspense");case 19:return Yf("SuspenseList");case 0:case 2:case 15:return t=n$(t.type,!1),t;case 11:return t=n$(t.type.render,!1),t;case 1:return t=n$(t.type,!0),t;default:return""}}function HC(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case qu:return"Fragment";case Xu:return"Portal";case BC:return"Profiler";case kA:return"StrictMode";case UC:return"Suspense";case zC:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case uH:return(t.displayName||"Context")+".Consumer";case cH:return(t._context.displayName||"Context")+".Provider";case OA:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case MA:return e=t.displayName||null,e!==null?e:HC(t.type)||"Memo";case Na:e=t._payload,t=t._init;try{return HC(t(e))}catch{}}return null}function Vhe(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return HC(e);case 8:return e===kA?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function vl(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function hH(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Yhe(t){var e=hH(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var o=r.get,i=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return o.call(this)},set:function(s){n=""+s,i.call(this,s)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function tv(t){t._valueTracker||(t._valueTracker=Yhe(t))}function fH(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=hH(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function fw(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function WC(t,e){var r=e.checked;return Ft({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function LD(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=vl(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function pH(t,e){e=e.checked,e!=null&&AA(t,"checked",e,!1)}function KC(t,e){pH(t,e);var r=vl(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?GC(t,e.type,r):e.hasOwnProperty("defaultValue")&&GC(t,e.type,vl(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function ND(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function GC(t,e,r){(e!=="number"||fw(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Xf=Array.isArray;function xd(t,e,r,n){if(t=t.options,e){e={};for(var o=0;o<r.length;o++)e["$"+r[o]]=!0;for(r=0;r<t.length;r++)o=e.hasOwnProperty("$"+t[r].value),t[r].selected!==o&&(t[r].selected=o),o&&n&&(t[r].defaultSelected=!0)}else{for(r=""+vl(r),e=null,o=0;o<t.length;o++){if(t[o].value===r){t[o].selected=!0,n&&(t[o].defaultSelected=!0);return}e!==null||t[o].disabled||(e=t[o])}e!==null&&(e.selected=!0)}}function VC(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(Z(91));return Ft({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function FD(t,e){var r=e.value;if(r==null){if(r=e.children,e=e.defaultValue,r!=null){if(e!=null)throw Error(Z(92));if(Xf(r)){if(1<r.length)throw Error(Z(93));r=r[0]}e=r}e==null&&(e=""),r=e}t._wrapperState={initialValue:vl(r)}}function gH(t,e){var r=vl(e.value),n=vl(e.defaultValue);r!=null&&(r=""+r,r!==t.value&&(t.value=r),e.defaultValue==null&&t.defaultValue!==r&&(t.defaultValue=r)),n!=null&&(t.defaultValue=""+n)}function BD(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function mH(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function YC(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?mH(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var rv,vH=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,r,n,o){MSApp.execUnsafeLocalFunction(function(){return t(e,r,n,o)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(rv=rv||document.createElement("div"),rv.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=rv.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Yp(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var yp={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Xhe=["Webkit","ms","Moz","O"];Object.keys(yp).forEach(function(t){Xhe.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),yp[e]=yp[t]})});function yH(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||yp.hasOwnProperty(t)&&yp[t]?(""+e).trim():e+"px"}function SH(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,o=yH(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,o):t[r]=o}}var qhe=Ft({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function XC(t,e){if(e){if(qhe[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Z(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Z(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Z(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Z(62))}}function qC(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){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 ZC=null;function RA(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var QC=null,bd=null,$d=null;function UD(t){if(t=Fg(t)){if(typeof QC!="function")throw Error(Z(280));var e=t.stateNode;e&&(e=px(e),QC(t.stateNode,t.type,e))}}function wH(t){bd?$d?$d.push(t):$d=[t]:bd=t}function xH(){if(bd){var t=bd,e=$d;if($d=bd=null,UD(t),e)for(t=0;t<e.length;t++)UD(e[t])}}function bH(t,e){return t(e)}function $H(){}var o$=!1;function IH(t,e,r){if(o$)return t(e,r);o$=!0;try{return bH(t,e,r)}finally{o$=!1,(bd!==null||$d!==null)&&($H(),xH())}}function Xp(t,e){var r=t.stateNode;if(r===null)return null;var n=px(r);if(n===null)return null;r=n[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(t=t.type,n=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!n;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(Z(231,e,typeof r));return r}var JC=!1;if(ea)try{var nf={};Object.defineProperty(nf,"passive",{get:function(){JC=!0}}),window.addEventListener("test",nf,nf),window.removeEventListener("test",nf,nf)}catch{JC=!1}function Zhe(t,e,r,n,o,i,s,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(r,c)}catch(u){this.onError(u)}}var Sp=!1,pw=null,gw=!1,e_=null,Qhe={onError:function(t){Sp=!0,pw=t}};function Jhe(t,e,r,n,o,i,s,a,l){Sp=!1,pw=null,Zhe.apply(Qhe,arguments)}function efe(t,e,r,n,o,i,s,a,l){if(Jhe.apply(this,arguments),Sp){if(Sp){var c=pw;Sp=!1,pw=null}else throw Error(Z(198));gw||(gw=!0,e_=c)}}function Jc(t){var e=t,r=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(r=e.return),t=e.return;while(t)}return e.tag===3?r:null}function PH(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function zD(t){if(Jc(t)!==t)throw Error(Z(188))}function tfe(t){var e=t.alternate;if(!e){if(e=Jc(t),e===null)throw Error(Z(188));return e!==t?null:t}for(var r=t,n=e;;){var o=r.return;if(o===null)break;var i=o.alternate;if(i===null){if(n=o.return,n!==null){r=n;continue}break}if(o.child===i.child){for(i=o.child;i;){if(i===r)return zD(o),t;if(i===n)return zD(o),e;i=i.sibling}throw Error(Z(188))}if(r.return!==n.return)r=o,n=i;else{for(var s=!1,a=o.child;a;){if(a===r){s=!0,r=o,n=i;break}if(a===n){s=!0,n=o,r=i;break}a=a.sibling}if(!s){for(a=i.child;a;){if(a===r){s=!0,r=i,n=o;break}if(a===n){s=!0,n=i,r=o;break}a=a.sibling}if(!s)throw Error(Z(189))}}if(r.alternate!==n)throw Error(Z(190))}if(r.tag!==3)throw Error(Z(188));return r.stateNode.current===r?t:e}function EH(t){return t=tfe(t),t!==null?CH(t):null}function CH(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=CH(t);if(e!==null)return e;t=t.sibling}return null}var _H=po.unstable_scheduleCallback,HD=po.unstable_cancelCallback,rfe=po.unstable_shouldYield,nfe=po.unstable_requestPaint,Yt=po.unstable_now,ofe=po.unstable_getCurrentPriorityLevel,jA=po.unstable_ImmediatePriority,TH=po.unstable_UserBlockingPriority,mw=po.unstable_NormalPriority,ife=po.unstable_LowPriority,AH=po.unstable_IdlePriority,ux=null,rs=null;function sfe(t){if(rs&&typeof rs.onCommitFiberRoot=="function")try{rs.onCommitFiberRoot(ux,t,void 0,(t.current.flags&128)===128)}catch{}}var mi=Math.clz32?Math.clz32:cfe,afe=Math.log,lfe=Math.LN2;function cfe(t){return t>>>=0,t===0?32:31-(afe(t)/lfe|0)|0}var nv=64,ov=4194304;function qf(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function vw(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,o=t.suspendedLanes,i=t.pingedLanes,s=r&268435455;if(s!==0){var a=s&~o;a!==0?n=qf(a):(i&=s,i!==0&&(n=qf(i)))}else s=r&~o,s!==0?n=qf(s):i!==0&&(n=qf(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&o)&&(o=n&-n,i=e&-e,o>=i||o===16&&(i&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0<e;)r=31-mi(e),o=1<<r,n|=t[r],e&=~o;return n}function ufe(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function dfe(t,e){for(var r=t.suspendedLanes,n=t.pingedLanes,o=t.expirationTimes,i=t.pendingLanes;0<i;){var s=31-mi(i),a=1<<s,l=o[s];l===-1?(!(a&r)||a&n)&&(o[s]=ufe(a,e)):l<=e&&(t.expiredLanes|=a),i&=~a}}function t_(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function kH(){var t=nv;return nv<<=1,!(nv&4194240)&&(nv=64),t}function i$(t){for(var e=[],r=0;31>r;r++)e.push(t);return e}function Lg(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-mi(e),t[e]=r}function hfe(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0<r;){var o=31-mi(r),i=1<<o;e[o]=0,n[o]=-1,t[o]=-1,r&=~i}}function DA(t,e){var r=t.entangledLanes|=e;for(t=t.entanglements;r;){var n=31-mi(r),o=1<<n;o&e|t[n]&e&&(t[n]|=e),r&=~o}}var it=0;function OH(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var MH,LA,RH,jH,DH,r_=!1,iv=[],rl=null,nl=null,ol=null,qp=new Map,Zp=new Map,za=[],ffe="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function WD(t,e){switch(t){case"focusin":case"focusout":rl=null;break;case"dragenter":case"dragleave":nl=null;break;case"mouseover":case"mouseout":ol=null;break;case"pointerover":case"pointerout":qp.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zp.delete(e.pointerId)}}function of(t,e,r,n,o,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:r,eventSystemFlags:n,nativeEvent:i,targetContainers:[o]},e!==null&&(e=Fg(e),e!==null&&LA(e)),t):(t.eventSystemFlags|=n,e=t.targetContainers,o!==null&&e.indexOf(o)===-1&&e.push(o),t)}function pfe(t,e,r,n,o){switch(e){case"focusin":return rl=of(rl,t,e,r,n,o),!0;case"dragenter":return nl=of(nl,t,e,r,n,o),!0;case"mouseover":return ol=of(ol,t,e,r,n,o),!0;case"pointerover":var i=o.pointerId;return qp.set(i,of(qp.get(i)||null,t,e,r,n,o)),!0;case"gotpointercapture":return i=o.pointerId,Zp.set(i,of(Zp.get(i)||null,t,e,r,n,o)),!0}return!1}function LH(t){var e=vc(t.target);if(e!==null){var r=Jc(e);if(r!==null){if(e=r.tag,e===13){if(e=PH(r),e!==null){t.blockedOn=e,DH(t.priority,function(){RH(r)});return}}else if(e===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function iS(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var r=n_(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(r===null){r=t.nativeEvent;var n=new r.constructor(r.type,r);ZC=n,r.target.dispatchEvent(n),ZC=null}else return e=Fg(r),e!==null&&LA(e),t.blockedOn=r,!1;e.shift()}return!0}function KD(t,e,r){iS(t)&&r.delete(e)}function gfe(){r_=!1,rl!==null&&iS(rl)&&(rl=null),nl!==null&&iS(nl)&&(nl=null),ol!==null&&iS(ol)&&(ol=null),qp.forEach(KD),Zp.forEach(KD)}function sf(t,e){t.blockedOn===e&&(t.blockedOn=null,r_||(r_=!0,po.unstable_scheduleCallback(po.unstable_NormalPriority,gfe)))}function Qp(t){function e(o){return sf(o,t)}if(0<iv.length){sf(iv[0],t);for(var r=1;r<iv.length;r++){var n=iv[r];n.blockedOn===t&&(n.blockedOn=null)}}for(rl!==null&&sf(rl,t),nl!==null&&sf(nl,t),ol!==null&&sf(ol,t),qp.forEach(e),Zp.forEach(e),r=0;r<za.length;r++)n=za[r],n.blockedOn===t&&(n.blockedOn=null);for(;0<za.length&&(r=za[0],r.blockedOn===null);)LH(r),r.blockedOn===null&&za.shift()}var Id=fa.ReactCurrentBatchConfig,yw=!0;function mfe(t,e,r,n){var o=it,i=Id.transition;Id.transition=null;try{it=1,NA(t,e,r,n)}finally{it=o,Id.transition=i}}function vfe(t,e,r,n){var o=it,i=Id.transition;Id.transition=null;try{it=4,NA(t,e,r,n)}finally{it=o,Id.transition=i}}function NA(t,e,r,n){if(yw){var o=n_(t,e,r,n);if(o===null)g$(t,e,n,Sw,r),WD(t,n);else if(pfe(o,t,e,r,n))n.stopPropagation();else if(WD(t,n),e&4&&-1<ffe.indexOf(t)){for(;o!==null;){var i=Fg(o);if(i!==null&&MH(i),i=n_(t,e,r,n),i===null&&g$(t,e,n,Sw,r),i===o)break;o=i}o!==null&&n.stopPropagation()}else g$(t,e,n,null,r)}}var Sw=null;function n_(t,e,r,n){if(Sw=null,t=RA(n),t=vc(t),t!==null)if(e=Jc(t),e===null)t=null;else if(r=e.tag,r===13){if(t=PH(e),t!==null)return t;t=null}else if(r===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return Sw=t,null}function NH(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ofe()){case jA:return 1;case TH:return 4;case mw:case ife:return 16;case AH:return 536870912;default:return 16}default:return 16}}var Va=null,FA=null,sS=null;function FH(){if(sS)return sS;var t,e=FA,r=e.length,n,o="value"in Va?Va.value:Va.textContent,i=o.length;for(t=0;t<r&&e[t]===o[t];t++);var s=r-t;for(n=1;n<=s&&e[r-n]===o[i-n];n++);return sS=o.slice(t,1<n?1-n:void 0)}function aS(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function sv(){return!0}function GD(){return!1}function So(t){function e(r,n,o,i,s){this._reactName=r,this._targetInst=o,this.type=n,this.nativeEvent=i,this.target=s,this.currentTarget=null;for(var a in t)t.hasOwnProperty(a)&&(r=t[a],this[a]=r?r(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?sv:GD,this.isPropagationStopped=GD,this}return Ft(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=sv)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=sv)},persist:function(){},isPersistent:sv}),e}var Sh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},BA=So(Sh),Ng=Ft({},Sh,{view:0,detail:0}),yfe=So(Ng),s$,a$,af,dx=Ft({},Ng,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:UA,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==af&&(af&&t.type==="mousemove"?(s$=t.screenX-af.screenX,a$=t.screenY-af.screenY):a$=s$=0,af=t),s$)},movementY:function(t){return"movementY"in t?t.movementY:a$}}),VD=So(dx),Sfe=Ft({},dx,{dataTransfer:0}),wfe=So(Sfe),xfe=Ft({},Ng,{relatedTarget:0}),l$=So(xfe),bfe=Ft({},Sh,{animationName:0,elapsedTime:0,pseudoElement:0}),$fe=So(bfe),Ife=Ft({},Sh,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Pfe=So(Ife),Efe=Ft({},Sh,{data:0}),YD=So(Efe),Cfe={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},_fe={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"},Tfe={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Afe(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=Tfe[t])?!!e[t]:!1}function UA(){return Afe}var kfe=Ft({},Ng,{key:function(t){if(t.key){var e=Cfe[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=aS(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?_fe[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:UA,charCode:function(t){return t.type==="keypress"?aS(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?aS(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Ofe=So(kfe),Mfe=Ft({},dx,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),XD=So(Mfe),Rfe=Ft({},Ng,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:UA}),jfe=So(Rfe),Dfe=Ft({},Sh,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lfe=So(Dfe),Nfe=Ft({},dx,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Ffe=So(Nfe),Bfe=[9,13,27,32],zA=ea&&"CompositionEvent"in window,wp=null;ea&&"documentMode"in document&&(wp=document.documentMode);var Ufe=ea&&"TextEvent"in window&&!wp,BH=ea&&(!zA||wp&&8<wp&&11>=wp),qD=" ",ZD=!1;function UH(t,e){switch(t){case"keyup":return Bfe.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zH(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Zu=!1;function zfe(t,e){switch(t){case"compositionend":return zH(e);case"keypress":return e.which!==32?null:(ZD=!0,qD);case"textInput":return t=e.data,t===qD&&ZD?null:t;default:return null}}function Hfe(t,e){if(Zu)return t==="compositionend"||!zA&&UH(t,e)?(t=FH(),sS=FA=Va=null,Zu=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return BH&&e.locale!=="ko"?null:e.data;default:return null}}var Wfe={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 QD(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!Wfe[t.type]:e==="textarea"}function HH(t,e,r,n){wH(n),e=ww(e,"onChange"),0<e.length&&(r=new BA("onChange","change",null,r,n),t.push({event:r,listeners:e}))}var xp=null,Jp=null;function Kfe(t){eW(t,0)}function hx(t){var e=ed(t);if(fH(e))return t}function Gfe(t,e){if(t==="change")return e}var WH=!1;if(ea){var c$;if(ea){var u$="oninput"in document;if(!u$){var JD=document.createElement("div");JD.setAttribute("oninput","return;"),u$=typeof JD.oninput=="function"}c$=u$}else c$=!1;WH=c$&&(!document.documentMode||9<document.documentMode)}function e3(){xp&&(xp.detachEvent("onpropertychange",KH),Jp=xp=null)}function KH(t){if(t.propertyName==="value"&&hx(Jp)){var e=[];HH(e,Jp,t,RA(t)),IH(Kfe,e)}}function Vfe(t,e,r){t==="focusin"?(e3(),xp=e,Jp=r,xp.attachEvent("onpropertychange",KH)):t==="focusout"&&e3()}function Yfe(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return hx(Jp)}function Xfe(t,e){if(t==="click")return hx(e)}function qfe(t,e){if(t==="input"||t==="change")return hx(e)}function Zfe(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var wi=typeof Object.is=="function"?Object.is:Zfe;function eg(t,e){if(wi(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++){var o=r[n];if(!FC.call(e,o)||!wi(t[o],e[o]))return!1}return!0}function t3(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function r3(t,e){var r=t3(t);t=0;for(var n;r;){if(r.nodeType===3){if(n=t+r.textContent.length,t<=e&&n>=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=t3(r)}}function GH(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?GH(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function VH(){for(var t=window,e=fw();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=fw(t.document)}return e}function HA(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Qfe(t){var e=VH(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&GH(r.ownerDocument.documentElement,r)){if(n!==null&&HA(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var o=r.textContent.length,i=Math.min(n.start,o);n=n.end===void 0?i:Math.min(n.end,o),!t.extend&&i>n&&(o=n,n=i,i=o),o=r3(r,i);var s=r3(r,n);o&&s&&(t.rangeCount!==1||t.anchorNode!==o.node||t.anchorOffset!==o.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(o.node,o.offset),t.removeAllRanges(),i>n?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<e.length;r++)t=e[r],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Jfe=ea&&"documentMode"in document&&11>=document.documentMode,Qu=null,o_=null,bp=null,i_=!1;function n3(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;i_||Qu==null||Qu!==fw(n)||(n=Qu,"selectionStart"in n&&HA(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),bp&&eg(bp,n)||(bp=n,n=ww(o_,"onSelect"),0<n.length&&(e=new BA("onSelect","select",null,e,r),t.push({event:e,listeners:n}),e.target=Qu)))}function av(t,e){var r={};return r[t.toLowerCase()]=e.toLowerCase(),r["Webkit"+t]="webkit"+e,r["Moz"+t]="moz"+e,r}var Ju={animationend:av("Animation","AnimationEnd"),animationiteration:av("Animation","AnimationIteration"),animationstart:av("Animation","AnimationStart"),transitionend:av("Transition","TransitionEnd")},d$={},YH={};ea&&(YH=document.createElement("div").style,"AnimationEvent"in window||(delete Ju.animationend.animation,delete Ju.animationiteration.animation,delete Ju.animationstart.animation),"TransitionEvent"in window||delete Ju.transitionend.transition);function fx(t){if(d$[t])return d$[t];if(!Ju[t])return t;var e=Ju[t],r;for(r in e)if(e.hasOwnProperty(r)&&r in YH)return d$[t]=e[r];return t}var XH=fx("animationend"),qH=fx("animationiteration"),ZH=fx("animationstart"),QH=fx("transitionend"),JH=new Map,o3="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Tl(t,e){JH.set(t,e),Qc(e,[t])}for(var h$=0;h$<o3.length;h$++){var f$=o3[h$],epe=f$.toLowerCase(),tpe=f$[0].toUpperCase()+f$.slice(1);Tl(epe,"on"+tpe)}Tl(XH,"onAnimationEnd");Tl(qH,"onAnimationIteration");Tl(ZH,"onAnimationStart");Tl("dblclick","onDoubleClick");Tl("focusin","onFocus");Tl("focusout","onBlur");Tl(QH,"onTransitionEnd");zd("onMouseEnter",["mouseout","mouseover"]);zd("onMouseLeave",["mouseout","mouseover"]);zd("onPointerEnter",["pointerout","pointerover"]);zd("onPointerLeave",["pointerout","pointerover"]);Qc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Qc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Qc("onBeforeInput",["compositionend","keypress","textInput","paste"]);Qc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Qc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Qc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zf="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(" "),rpe=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zf));function i3(t,e,r){var n=t.type||"unknown-event";t.currentTarget=r,efe(n,e,void 0,t),t.currentTarget=null}function eW(t,e){e=(e&4)!==0;for(var r=0;r<t.length;r++){var n=t[r],o=n.event;n=n.listeners;e:{var i=void 0;if(e)for(var s=n.length-1;0<=s;s--){var a=n[s],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==i&&o.isPropagationStopped())break e;i3(o,a,c),i=l}else for(s=0;s<n.length;s++){if(a=n[s],l=a.instance,c=a.currentTarget,a=a.listener,l!==i&&o.isPropagationStopped())break e;i3(o,a,c),i=l}}}if(gw)throw t=e_,gw=!1,e_=null,t}function bt(t,e){var r=e[u_];r===void 0&&(r=e[u_]=new Set);var n=t+"__bubble";r.has(n)||(tW(e,t,2,!1),r.add(n))}function p$(t,e,r){var n=0;e&&(n|=4),tW(r,t,n,e)}var lv="_reactListening"+Math.random().toString(36).slice(2);function tg(t){if(!t[lv]){t[lv]=!0,lH.forEach(function(r){r!=="selectionchange"&&(rpe.has(r)||p$(r,!1,t),p$(r,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[lv]||(e[lv]=!0,p$("selectionchange",!1,e))}}function tW(t,e,r,n){switch(NH(e)){case 1:var o=mfe;break;case 4:o=vfe;break;default:o=NA}r=o.bind(null,e,r,t),o=void 0,!JC||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(o=!0),n?o!==void 0?t.addEventListener(e,r,{capture:!0,passive:o}):t.addEventListener(e,r,!0):o!==void 0?t.addEventListener(e,r,{passive:o}):t.addEventListener(e,r,!1)}function g$(t,e,r,n,o){var i=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var s=n.tag;if(s===3||s===4){var a=n.stateNode.containerInfo;if(a===o||a.nodeType===8&&a.parentNode===o)break;if(s===4)for(s=n.return;s!==null;){var l=s.tag;if((l===3||l===4)&&(l=s.stateNode.containerInfo,l===o||l.nodeType===8&&l.parentNode===o))return;s=s.return}for(;a!==null;){if(s=vc(a),s===null)return;if(l=s.tag,l===5||l===6){n=i=s;continue e}a=a.parentNode}}n=n.return}IH(function(){var c=i,u=RA(r),d=[];e:{var f=JH.get(t);if(f!==void 0){var p=BA,g=t;switch(t){case"keypress":if(aS(r)===0)break e;case"keydown":case"keyup":p=Ofe;break;case"focusin":g="focus",p=l$;break;case"focusout":g="blur",p=l$;break;case"beforeblur":case"afterblur":p=l$;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=VD;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=wfe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=jfe;break;case XH:case qH:case ZH:p=$fe;break;case QH:p=Lfe;break;case"scroll":p=yfe;break;case"wheel":p=Ffe;break;case"copy":case"cut":case"paste":p=Pfe;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=XD}var m=(e&4)!==0,S=!m&&t==="scroll",y=m?f!==null?f+"Capture":null:f;m=[];for(var v=c,b;v!==null;){b=v;var $=b.stateNode;if(b.tag===5&&$!==null&&(b=$,y!==null&&($=Xp(v,y),$!=null&&m.push(rg(v,$,b)))),S)break;v=v.return}0<m.length&&(f=new p(f,g,null,r,u),d.push({event:f,listeners:m}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",p=t==="mouseout"||t==="pointerout",f&&r!==ZC&&(g=r.relatedTarget||r.fromElement)&&(vc(g)||g[ta]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(g=r.relatedTarget||r.toElement,p=c,g=g?vc(g):null,g!==null&&(S=Jc(g),g!==S||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=c),p!==g)){if(m=VD,$="onMouseLeave",y="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(m=XD,$="onPointerLeave",y="onPointerEnter",v="pointer"),S=p==null?f:ed(p),b=g==null?f:ed(g),f=new m($,v+"leave",p,r,u),f.target=S,f.relatedTarget=b,$=null,vc(u)===c&&(m=new m(y,v+"enter",g,r,u),m.target=b,m.relatedTarget=S,$=m),S=$,p&&g)t:{for(m=p,y=g,v=0,b=m;b;b=wu(b))v++;for(b=0,$=y;$;$=wu($))b++;for(;0<v-b;)m=wu(m),v--;for(;0<b-v;)y=wu(y),b--;for(;v--;){if(m===y||y!==null&&m===y.alternate)break t;m=wu(m),y=wu(y)}m=null}else m=null;p!==null&&s3(d,f,p,m,!1),g!==null&&S!==null&&s3(d,S,g,m,!0)}}e:{if(f=c?ed(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var P=Gfe;else if(QD(f))if(WH)P=qfe;else{P=Yfe;var E=Vfe}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(P=Xfe);if(P&&(P=P(t,c))){HH(d,P,r,u);break e}E&&E(t,f,c),t==="focusout"&&(E=f._wrapperState)&&E.controlled&&f.type==="number"&&GC(f,"number",f.value)}switch(E=c?ed(c):window,t){case"focusin":(QD(E)||E.contentEditable==="true")&&(Qu=E,o_=c,bp=null);break;case"focusout":bp=o_=Qu=null;break;case"mousedown":i_=!0;break;case"contextmenu":case"mouseup":case"dragend":i_=!1,n3(d,r,u);break;case"selectionchange":if(Jfe)break;case"keydown":case"keyup":n3(d,r,u)}var T;if(zA)e:{switch(t){case"compositionstart":var I="onCompositionStart";break e;case"compositionend":I="onCompositionEnd";break e;case"compositionupdate":I="onCompositionUpdate";break e}I=void 0}else Zu?UH(t,r)&&(I="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(I="onCompositionStart");I&&(BH&&r.locale!=="ko"&&(Zu||I!=="onCompositionStart"?I==="onCompositionEnd"&&Zu&&(T=FH()):(Va=u,FA="value"in Va?Va.value:Va.textContent,Zu=!0)),E=ww(c,I),0<E.length&&(I=new YD(I,t,null,r,u),d.push({event:I,listeners:E}),T?I.data=T:(T=zH(r),T!==null&&(I.data=T)))),(T=Ufe?zfe(t,r):Hfe(t,r))&&(c=ww(c,"onBeforeInput"),0<c.length&&(u=new YD("onBeforeInput","beforeinput",null,r,u),d.push({event:u,listeners:c}),u.data=T))}eW(d,e)})}function rg(t,e,r){return{instance:t,listener:e,currentTarget:r}}function ww(t,e){for(var r=e+"Capture",n=[];t!==null;){var o=t,i=o.stateNode;o.tag===5&&i!==null&&(o=i,i=Xp(t,r),i!=null&&n.unshift(rg(t,i,o)),i=Xp(t,e),i!=null&&n.push(rg(t,i,o))),t=t.return}return n}function wu(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function s3(t,e,r,n,o){for(var i=e._reactName,s=[];r!==null&&r!==n;){var a=r,l=a.alternate,c=a.stateNode;if(l!==null&&l===n)break;a.tag===5&&c!==null&&(a=c,o?(l=Xp(r,i),l!=null&&s.unshift(rg(r,l,a))):o||(l=Xp(r,i),l!=null&&s.push(rg(r,l,a)))),r=r.return}s.length!==0&&t.push({event:e,listeners:s})}var npe=/\r\n?/g,ope=/\u0000|\uFFFD/g;function a3(t){return(typeof t=="string"?t:""+t).replace(npe,`
|
|
38
|
-
`).replace(ope,"")}function cv(t,e,r){if(e=a3(e),a3(t)!==e&&r)throw Error(Z(425))}function xw(){}var s_=null,a_=null;function l_(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var c_=typeof setTimeout=="function"?setTimeout:void 0,ipe=typeof clearTimeout=="function"?clearTimeout:void 0,l3=typeof Promise=="function"?Promise:void 0,spe=typeof queueMicrotask=="function"?queueMicrotask:typeof l3<"u"?function(t){return l3.resolve(null).then(t).catch(ape)}:c_;function ape(t){setTimeout(function(){throw t})}function m$(t,e){var r=e,n=0;do{var o=r.nextSibling;if(t.removeChild(r),o&&o.nodeType===8)if(r=o.data,r==="/$"){if(n===0){t.removeChild(o),Qp(e);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=o}while(r);Qp(e)}function il(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function c3(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"){if(e===0)return t;e--}else r==="/$"&&e++}t=t.previousSibling}return null}var wh=Math.random().toString(36).slice(2),Gi="__reactFiber$"+wh,ng="__reactProps$"+wh,ta="__reactContainer$"+wh,u_="__reactEvents$"+wh,lpe="__reactListeners$"+wh,cpe="__reactHandles$"+wh;function vc(t){var e=t[Gi];if(e)return e;for(var r=t.parentNode;r;){if(e=r[ta]||r[Gi]){if(r=e.alternate,e.child!==null||r!==null&&r.child!==null)for(t=c3(t);t!==null;){if(r=t[Gi])return r;t=c3(t)}return e}t=r,r=t.parentNode}return null}function Fg(t){return t=t[Gi]||t[ta],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function ed(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(Z(33))}function px(t){return t[ng]||null}var d_=[],td=-1;function Al(t){return{current:t}}function It(t){0>td||(t.current=d_[td],d_[td]=null,td--)}function mt(t,e){td++,d_[td]=t.current,t.current=e}var yl={},Jr=Al(yl),Bn=Al(!1),Ac=yl;function Hd(t,e){var r=t.type.contextTypes;if(!r)return yl;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in r)o[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=o),o}function Un(t){return t=t.childContextTypes,t!=null}function bw(){It(Bn),It(Jr)}function u3(t,e,r){if(Jr.current!==yl)throw Error(Z(168));mt(Jr,e),mt(Bn,r)}function rW(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var o in n)if(!(o in e))throw Error(Z(108,Vhe(t)||"Unknown",o));return Ft({},r,n)}function $w(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||yl,Ac=Jr.current,mt(Jr,t),mt(Bn,Bn.current),!0}function d3(t,e,r){var n=t.stateNode;if(!n)throw Error(Z(169));r?(t=rW(t,e,Ac),n.__reactInternalMemoizedMergedChildContext=t,It(Bn),It(Jr),mt(Jr,t)):It(Bn),mt(Bn,r)}var Bs=null,gx=!1,v$=!1;function nW(t){Bs===null?Bs=[t]:Bs.push(t)}function upe(t){gx=!0,nW(t)}function kl(){if(!v$&&Bs!==null){v$=!0;var t=0,e=it;try{var r=Bs;for(it=1;t<r.length;t++){var n=r[t];do n=n(!0);while(n!==null)}Bs=null,gx=!1}catch(o){throw Bs!==null&&(Bs=Bs.slice(t+1)),_H(jA,kl),o}finally{it=e,v$=!1}}return null}var rd=[],nd=0,Iw=null,Pw=0,Fo=[],Bo=0,kc=null,zs=1,Hs="";function hc(t,e){rd[nd++]=Pw,rd[nd++]=Iw,Iw=t,Pw=e}function oW(t,e,r){Fo[Bo++]=zs,Fo[Bo++]=Hs,Fo[Bo++]=kc,kc=t;var n=zs;t=Hs;var o=32-mi(n)-1;n&=~(1<<o),r+=1;var i=32-mi(e)+o;if(30<i){var s=o-o%5;i=(n&(1<<s)-1).toString(32),n>>=s,o-=s,zs=1<<32-mi(e)+o|r<<o|n,Hs=i+t}else zs=1<<i|r<<o|n,Hs=t}function WA(t){t.return!==null&&(hc(t,1),oW(t,1,0))}function KA(t){for(;t===Iw;)Iw=rd[--nd],rd[nd]=null,Pw=rd[--nd],rd[nd]=null;for(;t===kc;)kc=Fo[--Bo],Fo[Bo]=null,Hs=Fo[--Bo],Fo[Bo]=null,zs=Fo[--Bo],Fo[Bo]=null}var ao=null,oo=null,At=!1,ci=null;function iW(t,e){var r=Ho(5,null,null,0);r.elementType="DELETED",r.stateNode=e,r.return=t,e=t.deletions,e===null?(t.deletions=[r],t.flags|=16):e.push(r)}function h3(t,e){switch(t.tag){case 5:var r=t.type;return e=e.nodeType!==1||r.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,ao=t,oo=il(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,ao=t,oo=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(r=kc!==null?{id:zs,overflow:Hs}:null,t.memoizedState={dehydrated:e,treeContext:r,retryLane:1073741824},r=Ho(18,null,null,0),r.stateNode=e,r.return=t,t.child=r,ao=t,oo=null,!0):!1;default:return!1}}function h_(t){return(t.mode&1)!==0&&(t.flags&128)===0}function f_(t){if(At){var e=oo;if(e){var r=e;if(!h3(t,e)){if(h_(t))throw Error(Z(418));e=il(r.nextSibling);var n=ao;e&&h3(t,e)?iW(n,r):(t.flags=t.flags&-4097|2,At=!1,ao=t)}}else{if(h_(t))throw Error(Z(418));t.flags=t.flags&-4097|2,At=!1,ao=t}}}function f3(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;ao=t}function uv(t){if(t!==ao)return!1;if(!At)return f3(t),At=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!l_(t.type,t.memoizedProps)),e&&(e=oo)){if(h_(t))throw sW(),Error(Z(418));for(;e;)iW(t,e),e=il(e.nextSibling)}if(f3(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Z(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"){if(e===0){oo=il(t.nextSibling);break e}e--}else r!=="$"&&r!=="$!"&&r!=="$?"||e++}t=t.nextSibling}oo=null}}else oo=ao?il(t.stateNode.nextSibling):null;return!0}function sW(){for(var t=oo;t;)t=il(t.nextSibling)}function Wd(){oo=ao=null,At=!1}function GA(t){ci===null?ci=[t]:ci.push(t)}var dpe=fa.ReactCurrentBatchConfig;function lf(t,e,r){if(t=r.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(Z(309));var n=r.stateNode}if(!n)throw Error(Z(147,t));var o=n,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(s){var a=o.refs;s===null?delete a[i]:a[i]=s},e._stringRef=i,e)}if(typeof t!="string")throw Error(Z(284));if(!r._owner)throw Error(Z(290,t))}return t}function dv(t,e){throw t=Object.prototype.toString.call(e),Error(Z(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function p3(t){var e=t._init;return e(t._payload)}function aW(t){function e(y,v){if(t){var b=y.deletions;b===null?(y.deletions=[v],y.flags|=16):b.push(v)}}function r(y,v){if(!t)return null;for(;v!==null;)e(y,v),v=v.sibling;return null}function n(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function o(y,v){return y=cl(y,v),y.index=0,y.sibling=null,y}function i(y,v,b){return y.index=b,t?(b=y.alternate,b!==null?(b=b.index,b<v?(y.flags|=2,v):b):(y.flags|=2,v)):(y.flags|=1048576,v)}function s(y){return t&&y.alternate===null&&(y.flags|=2),y}function a(y,v,b,$){return v===null||v.tag!==6?(v=I$(b,y.mode,$),v.return=y,v):(v=o(v,b),v.return=y,v)}function l(y,v,b,$){var P=b.type;return P===qu?u(y,v,b.props.children,$,b.key):v!==null&&(v.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Na&&p3(P)===v.type)?($=o(v,b.props),$.ref=lf(y,v,b),$.return=y,$):($=pS(b.type,b.key,b.props,null,y.mode,$),$.ref=lf(y,v,b),$.return=y,$)}function c(y,v,b,$){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=P$(b,y.mode,$),v.return=y,v):(v=o(v,b.children||[]),v.return=y,v)}function u(y,v,b,$,P){return v===null||v.tag!==7?(v=$c(b,y.mode,$,P),v.return=y,v):(v=o(v,b),v.return=y,v)}function d(y,v,b){if(typeof v=="string"&&v!==""||typeof v=="number")return v=I$(""+v,y.mode,b),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case ev:return b=pS(v.type,v.key,v.props,null,y.mode,b),b.ref=lf(y,null,v),b.return=y,b;case Xu:return v=P$(v,y.mode,b),v.return=y,v;case Na:var $=v._init;return d(y,$(v._payload),b)}if(Xf(v)||rf(v))return v=$c(v,y.mode,b,null),v.return=y,v;dv(y,v)}return null}function f(y,v,b,$){var P=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return P!==null?null:a(y,v,""+b,$);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case ev:return b.key===P?l(y,v,b,$):null;case Xu:return b.key===P?c(y,v,b,$):null;case Na:return P=b._init,f(y,v,P(b._payload),$)}if(Xf(b)||rf(b))return P!==null?null:u(y,v,b,$,null);dv(y,b)}return null}function p(y,v,b,$,P){if(typeof $=="string"&&$!==""||typeof $=="number")return y=y.get(b)||null,a(v,y,""+$,P);if(typeof $=="object"&&$!==null){switch($.$$typeof){case ev:return y=y.get($.key===null?b:$.key)||null,l(v,y,$,P);case Xu:return y=y.get($.key===null?b:$.key)||null,c(v,y,$,P);case Na:var E=$._init;return p(y,v,b,E($._payload),P)}if(Xf($)||rf($))return y=y.get(b)||null,u(v,y,$,P,null);dv(v,$)}return null}function g(y,v,b,$){for(var P=null,E=null,T=v,I=v=0,_=null;T!==null&&I<b.length;I++){T.index>I?(_=T,T=null):_=T.sibling;var k=f(y,T,b[I],$);if(k===null){T===null&&(T=_);break}t&&T&&k.alternate===null&&e(y,T),v=i(k,v,I),E===null?P=k:E.sibling=k,E=k,T=_}if(I===b.length)return r(y,T),At&&hc(y,I),P;if(T===null){for(;I<b.length;I++)T=d(y,b[I],$),T!==null&&(v=i(T,v,I),E===null?P=T:E.sibling=T,E=T);return At&&hc(y,I),P}for(T=n(y,T);I<b.length;I++)_=p(T,y,I,b[I],$),_!==null&&(t&&_.alternate!==null&&T.delete(_.key===null?I:_.key),v=i(_,v,I),E===null?P=_:E.sibling=_,E=_);return t&&T.forEach(function(D){return e(y,D)}),At&&hc(y,I),P}function m(y,v,b,$){var P=rf(b);if(typeof P!="function")throw Error(Z(150));if(b=P.call(b),b==null)throw Error(Z(151));for(var E=P=null,T=v,I=v=0,_=null,k=b.next();T!==null&&!k.done;I++,k=b.next()){T.index>I?(_=T,T=null):_=T.sibling;var D=f(y,T,k.value,$);if(D===null){T===null&&(T=_);break}t&&T&&D.alternate===null&&e(y,T),v=i(D,v,I),E===null?P=D:E.sibling=D,E=D,T=_}if(k.done)return r(y,T),At&&hc(y,I),P;if(T===null){for(;!k.done;I++,k=b.next())k=d(y,k.value,$),k!==null&&(v=i(k,v,I),E===null?P=k:E.sibling=k,E=k);return At&&hc(y,I),P}for(T=n(y,T);!k.done;I++,k=b.next())k=p(T,y,I,k.value,$),k!==null&&(t&&k.alternate!==null&&T.delete(k.key===null?I:k.key),v=i(k,v,I),E===null?P=k:E.sibling=k,E=k);return t&&T.forEach(function(R){return e(y,R)}),At&&hc(y,I),P}function S(y,v,b,$){if(typeof b=="object"&&b!==null&&b.type===qu&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case ev:e:{for(var P=b.key,E=v;E!==null;){if(E.key===P){if(P=b.type,P===qu){if(E.tag===7){r(y,E.sibling),v=o(E,b.props.children),v.return=y,y=v;break e}}else if(E.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Na&&p3(P)===E.type){r(y,E.sibling),v=o(E,b.props),v.ref=lf(y,E,b),v.return=y,y=v;break e}r(y,E);break}else e(y,E);E=E.sibling}b.type===qu?(v=$c(b.props.children,y.mode,$,b.key),v.return=y,y=v):($=pS(b.type,b.key,b.props,null,y.mode,$),$.ref=lf(y,v,b),$.return=y,y=$)}return s(y);case Xu:e:{for(E=b.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){r(y,v.sibling),v=o(v,b.children||[]),v.return=y,y=v;break e}else{r(y,v);break}else e(y,v);v=v.sibling}v=P$(b,y.mode,$),v.return=y,y=v}return s(y);case Na:return E=b._init,S(y,v,E(b._payload),$)}if(Xf(b))return g(y,v,b,$);if(rf(b))return m(y,v,b,$);dv(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,v!==null&&v.tag===6?(r(y,v.sibling),v=o(v,b),v.return=y,y=v):(r(y,v),v=I$(b,y.mode,$),v.return=y,y=v),s(y)):r(y,v)}return S}var Kd=aW(!0),lW=aW(!1),Ew=Al(null),Cw=null,od=null,VA=null;function YA(){VA=od=Cw=null}function XA(t){var e=Ew.current;It(Ew),t._currentValue=e}function p_(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function Pd(t,e){Cw=t,VA=od=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(jn=!0),t.firstContext=null)}function Yo(t){var e=t._currentValue;if(VA!==t)if(t={context:t,memoizedValue:e,next:null},od===null){if(Cw===null)throw Error(Z(308));od=t,Cw.dependencies={lanes:0,firstContext:t}}else od=od.next=t;return e}var yc=null;function qA(t){yc===null?yc=[t]:yc.push(t)}function cW(t,e,r,n){var o=e.interleaved;return o===null?(r.next=r,qA(e)):(r.next=o.next,o.next=r),e.interleaved=r,ra(t,n)}function ra(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Fa=!1;function ZA(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function uW(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Vs(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function sl(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,qe&2){var o=n.pending;return o===null?e.next=e:(e.next=o.next,o.next=e),n.pending=e,ra(t,r)}return o=n.interleaved,o===null?(e.next=e,qA(n)):(e.next=o.next,o.next=e),n.interleaved=e,ra(t,r)}function lS(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,DA(t,r)}}function g3(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var o=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var s={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?o=i=s:i=i.next=s,r=r.next}while(r!==null);i===null?o=i=e:i=i.next=e}else o=i=e;r={baseState:n.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function _w(t,e,r,n){var o=t.updateQueue;Fa=!1;var i=o.firstBaseUpdate,s=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var l=a,c=l.next;l.next=null,s===null?i=c:s.next=c,s=l;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==s&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(i!==null){var d=o.baseState;s=0,u=c=l=null,a=i;do{var f=a.lane,p=a.eventTime;if((n&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=t,m=a;switch(f=e,p=r,m.tag){case 1:if(g=m.payload,typeof g=="function"){d=g.call(p,d,f);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=m.payload,f=typeof g=="function"?g.call(p,d,f):g,f==null)break e;d=Ft({},d,f);break e;case 2:Fa=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,f=o.effects,f===null?o.effects=[a]:f.push(a))}else p={eventTime:p,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,s|=f;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;f=a,a=f.next,f.next=null,o.lastBaseUpdate=f,o.shared.pending=null}}while(!0);if(u===null&&(l=d),o.baseState=l,o.firstBaseUpdate=c,o.lastBaseUpdate=u,e=o.shared.interleaved,e!==null){o=e;do s|=o.lane,o=o.next;while(o!==e)}else i===null&&(o.shared.lanes=0);Mc|=s,t.lanes=s,t.memoizedState=d}}function m3(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var n=t[e],o=n.callback;if(o!==null){if(n.callback=null,n=r,typeof o!="function")throw Error(Z(191,o));o.call(n)}}}var Bg={},ns=Al(Bg),og=Al(Bg),ig=Al(Bg);function Sc(t){if(t===Bg)throw Error(Z(174));return t}function QA(t,e){switch(mt(ig,e),mt(og,t),mt(ns,Bg),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:YC(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=YC(e,t)}It(ns),mt(ns,e)}function Gd(){It(ns),It(og),It(ig)}function dW(t){Sc(ig.current);var e=Sc(ns.current),r=YC(e,t.type);e!==r&&(mt(og,t),mt(ns,r))}function JA(t){og.current===t&&(It(ns),It(og))}var jt=Al(0);function Tw(t){for(var e=t;e!==null;){if(e.tag===13){var r=e.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var y$=[];function ek(){for(var t=0;t<y$.length;t++)y$[t]._workInProgressVersionPrimary=null;y$.length=0}var cS=fa.ReactCurrentDispatcher,S$=fa.ReactCurrentBatchConfig,Oc=0,Nt=null,tr=null,ur=null,Aw=!1,$p=!1,sg=0,hpe=0;function Hr(){throw Error(Z(321))}function tk(t,e){if(e===null)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!wi(t[r],e[r]))return!1;return!0}function rk(t,e,r,n,o,i){if(Oc=i,Nt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,cS.current=t===null||t.memoizedState===null?mpe:vpe,t=r(n,o),$p){i=0;do{if($p=!1,sg=0,25<=i)throw Error(Z(301));i+=1,ur=tr=null,e.updateQueue=null,cS.current=ype,t=r(n,o)}while($p)}if(cS.current=kw,e=tr!==null&&tr.next!==null,Oc=0,ur=tr=Nt=null,Aw=!1,e)throw Error(Z(300));return t}function nk(){var t=sg!==0;return sg=0,t}function Hi(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ur===null?Nt.memoizedState=ur=t:ur=ur.next=t,ur}function Xo(){if(tr===null){var t=Nt.alternate;t=t!==null?t.memoizedState:null}else t=tr.next;var e=ur===null?Nt.memoizedState:ur.next;if(e!==null)ur=e,tr=t;else{if(t===null)throw Error(Z(310));tr=t,t={memoizedState:tr.memoizedState,baseState:tr.baseState,baseQueue:tr.baseQueue,queue:tr.queue,next:null},ur===null?Nt.memoizedState=ur=t:ur=ur.next=t}return ur}function ag(t,e){return typeof e=="function"?e(t):e}function w$(t){var e=Xo(),r=e.queue;if(r===null)throw Error(Z(311));r.lastRenderedReducer=t;var n=tr,o=n.baseQueue,i=r.pending;if(i!==null){if(o!==null){var s=o.next;o.next=i.next,i.next=s}n.baseQueue=o=i,r.pending=null}if(o!==null){i=o.next,n=n.baseState;var a=s=null,l=null,c=i;do{var u=c.lane;if((Oc&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),n=c.hasEagerState?c.eagerState:t(n,c.action);else{var d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,s=n):l=l.next=d,Nt.lanes|=u,Mc|=u}c=c.next}while(c!==null&&c!==i);l===null?s=n:l.next=a,wi(n,e.memoizedState)||(jn=!0),e.memoizedState=n,e.baseState=s,e.baseQueue=l,r.lastRenderedState=n}if(t=r.interleaved,t!==null){o=t;do i=o.lane,Nt.lanes|=i,Mc|=i,o=o.next;while(o!==t)}else o===null&&(r.lanes=0);return[e.memoizedState,r.dispatch]}function x$(t){var e=Xo(),r=e.queue;if(r===null)throw Error(Z(311));r.lastRenderedReducer=t;var n=r.dispatch,o=r.pending,i=e.memoizedState;if(o!==null){r.pending=null;var s=o=o.next;do i=t(i,s.action),s=s.next;while(s!==o);wi(i,e.memoizedState)||(jn=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),r.lastRenderedState=i}return[i,n]}function hW(){}function fW(t,e){var r=Nt,n=Xo(),o=e(),i=!wi(n.memoizedState,o);if(i&&(n.memoizedState=o,jn=!0),n=n.queue,ok(mW.bind(null,r,n,t),[t]),n.getSnapshot!==e||i||ur!==null&&ur.memoizedState.tag&1){if(r.flags|=2048,lg(9,gW.bind(null,r,n,o,e),void 0,null),gr===null)throw Error(Z(349));Oc&30||pW(r,e,o)}return o}function pW(t,e,r){t.flags|=16384,t={getSnapshot:e,value:r},e=Nt.updateQueue,e===null?(e={lastEffect:null,stores:null},Nt.updateQueue=e,e.stores=[t]):(r=e.stores,r===null?e.stores=[t]:r.push(t))}function gW(t,e,r,n){e.value=r,e.getSnapshot=n,vW(e)&&yW(t)}function mW(t,e,r){return r(function(){vW(e)&&yW(t)})}function vW(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!wi(t,r)}catch{return!0}}function yW(t){var e=ra(t,1);e!==null&&vi(e,t,1,-1)}function v3(t){var e=Hi();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ag,lastRenderedState:t},e.queue=t,t=t.dispatch=gpe.bind(null,Nt,t),[e.memoizedState,t]}function lg(t,e,r,n){return t={tag:t,create:e,destroy:r,deps:n,next:null},e=Nt.updateQueue,e===null?(e={lastEffect:null,stores:null},Nt.updateQueue=e,e.lastEffect=t.next=t):(r=e.lastEffect,r===null?e.lastEffect=t.next=t:(n=r.next,r.next=t,t.next=n,e.lastEffect=t)),t}function SW(){return Xo().memoizedState}function uS(t,e,r,n){var o=Hi();Nt.flags|=t,o.memoizedState=lg(1|e,r,void 0,n===void 0?null:n)}function mx(t,e,r,n){var o=Xo();n=n===void 0?null:n;var i=void 0;if(tr!==null){var s=tr.memoizedState;if(i=s.destroy,n!==null&&tk(n,s.deps)){o.memoizedState=lg(e,r,i,n);return}}Nt.flags|=t,o.memoizedState=lg(1|e,r,i,n)}function y3(t,e){return uS(8390656,8,t,e)}function ok(t,e){return mx(2048,8,t,e)}function wW(t,e){return mx(4,2,t,e)}function xW(t,e){return mx(4,4,t,e)}function bW(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function $W(t,e,r){return r=r!=null?r.concat([t]):null,mx(4,4,bW.bind(null,e,t),r)}function ik(){}function IW(t,e){var r=Xo();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&tk(e,n[1])?n[0]:(r.memoizedState=[t,e],t)}function PW(t,e){var r=Xo();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&tk(e,n[1])?n[0]:(t=t(),r.memoizedState=[t,e],t)}function EW(t,e,r){return Oc&21?(wi(r,e)||(r=kH(),Nt.lanes|=r,Mc|=r,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,jn=!0),t.memoizedState=r)}function fpe(t,e){var r=it;it=r!==0&&4>r?r:4,t(!0);var n=S$.transition;S$.transition={};try{t(!1),e()}finally{it=r,S$.transition=n}}function CW(){return Xo().memoizedState}function ppe(t,e,r){var n=ll(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},_W(t))TW(e,r);else if(r=cW(t,e,r,n),r!==null){var o=pn();vi(r,t,n,o),AW(r,e,n)}}function gpe(t,e,r){var n=ll(t),o={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(_W(t))TW(e,o);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var s=e.lastRenderedState,a=i(s,r);if(o.hasEagerState=!0,o.eagerState=a,wi(a,s)){var l=e.interleaved;l===null?(o.next=o,qA(e)):(o.next=l.next,l.next=o),e.interleaved=o;return}}catch{}finally{}r=cW(t,e,o,n),r!==null&&(o=pn(),vi(r,t,n,o),AW(r,e,n))}}function _W(t){var e=t.alternate;return t===Nt||e!==null&&e===Nt}function TW(t,e){$p=Aw=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function AW(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,DA(t,r)}}var kw={readContext:Yo,useCallback:Hr,useContext:Hr,useEffect:Hr,useImperativeHandle:Hr,useInsertionEffect:Hr,useLayoutEffect:Hr,useMemo:Hr,useReducer:Hr,useRef:Hr,useState:Hr,useDebugValue:Hr,useDeferredValue:Hr,useTransition:Hr,useMutableSource:Hr,useSyncExternalStore:Hr,useId:Hr,unstable_isNewReconciler:!1},mpe={readContext:Yo,useCallback:function(t,e){return Hi().memoizedState=[t,e===void 0?null:e],t},useContext:Yo,useEffect:y3,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,uS(4194308,4,bW.bind(null,e,t),r)},useLayoutEffect:function(t,e){return uS(4194308,4,t,e)},useInsertionEffect:function(t,e){return uS(4,2,t,e)},useMemo:function(t,e){var r=Hi();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Hi();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=ppe.bind(null,Nt,t),[n.memoizedState,t]},useRef:function(t){var e=Hi();return t={current:t},e.memoizedState=t},useState:v3,useDebugValue:ik,useDeferredValue:function(t){return Hi().memoizedState=t},useTransition:function(){var t=v3(!1),e=t[0];return t=fpe.bind(null,t[1]),Hi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=Nt,o=Hi();if(At){if(r===void 0)throw Error(Z(407));r=r()}else{if(r=e(),gr===null)throw Error(Z(349));Oc&30||pW(n,e,r)}o.memoizedState=r;var i={value:r,getSnapshot:e};return o.queue=i,y3(mW.bind(null,n,i,t),[t]),n.flags|=2048,lg(9,gW.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=Hi(),e=gr.identifierPrefix;if(At){var r=Hs,n=zs;r=(n&~(1<<32-mi(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=sg++,0<r&&(e+="H"+r.toString(32)),e+=":"}else r=hpe++,e=":"+e+"r"+r.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},vpe={readContext:Yo,useCallback:IW,useContext:Yo,useEffect:ok,useImperativeHandle:$W,useInsertionEffect:wW,useLayoutEffect:xW,useMemo:PW,useReducer:w$,useRef:SW,useState:function(){return w$(ag)},useDebugValue:ik,useDeferredValue:function(t){var e=Xo();return EW(e,tr.memoizedState,t)},useTransition:function(){var t=w$(ag)[0],e=Xo().memoizedState;return[t,e]},useMutableSource:hW,useSyncExternalStore:fW,useId:CW,unstable_isNewReconciler:!1},ype={readContext:Yo,useCallback:IW,useContext:Yo,useEffect:ok,useImperativeHandle:$W,useInsertionEffect:wW,useLayoutEffect:xW,useMemo:PW,useReducer:x$,useRef:SW,useState:function(){return x$(ag)},useDebugValue:ik,useDeferredValue:function(t){var e=Xo();return tr===null?e.memoizedState=t:EW(e,tr.memoizedState,t)},useTransition:function(){var t=x$(ag)[0],e=Xo().memoizedState;return[t,e]},useMutableSource:hW,useSyncExternalStore:fW,useId:CW,unstable_isNewReconciler:!1};function si(t,e){if(t&&t.defaultProps){e=Ft({},e),t=t.defaultProps;for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}return e}function g_(t,e,r,n){e=t.memoizedState,r=r(n,e),r=r==null?e:Ft({},e,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var vx={isMounted:function(t){return(t=t._reactInternals)?Jc(t)===t:!1},enqueueSetState:function(t,e,r){t=t._reactInternals;var n=pn(),o=ll(t),i=Vs(n,o);i.payload=e,r!=null&&(i.callback=r),e=sl(t,i,o),e!==null&&(vi(e,t,o,n),lS(e,t,o))},enqueueReplaceState:function(t,e,r){t=t._reactInternals;var n=pn(),o=ll(t),i=Vs(n,o);i.tag=1,i.payload=e,r!=null&&(i.callback=r),e=sl(t,i,o),e!==null&&(vi(e,t,o,n),lS(e,t,o))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var r=pn(),n=ll(t),o=Vs(r,n);o.tag=2,e!=null&&(o.callback=e),e=sl(t,o,n),e!==null&&(vi(e,t,n,r),lS(e,t,n))}};function S3(t,e,r,n,o,i,s){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(n,i,s):e.prototype&&e.prototype.isPureReactComponent?!eg(r,n)||!eg(o,i):!0}function kW(t,e,r){var n=!1,o=yl,i=e.contextType;return typeof i=="object"&&i!==null?i=Yo(i):(o=Un(e)?Ac:Jr.current,n=e.contextTypes,i=(n=n!=null)?Hd(t,o):yl),e=new e(r,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=vx,t.stateNode=e,e._reactInternals=t,n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=o,t.__reactInternalMemoizedMaskedChildContext=i),e}function w3(t,e,r,n){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(r,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(r,n),e.state!==t&&vx.enqueueReplaceState(e,e.state,null)}function m_(t,e,r,n){var o=t.stateNode;o.props=r,o.state=t.memoizedState,o.refs={},ZA(t);var i=e.contextType;typeof i=="object"&&i!==null?o.context=Yo(i):(i=Un(e)?Ac:Jr.current,o.context=Hd(t,i)),o.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(g_(t,e,i,r),o.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(e=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),e!==o.state&&vx.enqueueReplaceState(o,o.state,null),_w(t,r,o,n),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308)}function Vd(t,e){try{var r="",n=e;do r+=Ghe(n),n=n.return;while(n);var o=r}catch(i){o=`
|
|
39
|
-
Error generating stack: `+i.message+`
|
|
40
|
-
`+i.stack}return{value:t,source:e,stack:o,digest:null}}function b$(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function v_(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var Spe=typeof WeakMap=="function"?WeakMap:Map;function OW(t,e,r){r=Vs(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){Mw||(Mw=!0,C_=n),v_(t,e)},r}function MW(t,e,r){r=Vs(-1,r),r.tag=3;var n=t.type.getDerivedStateFromError;if(typeof n=="function"){var o=e.value;r.payload=function(){return n(o)},r.callback=function(){v_(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){v_(t,e),typeof n!="function"&&(al===null?al=new Set([this]):al.add(this));var s=e.stack;this.componentDidCatch(e.value,{componentStack:s!==null?s:""})}),r}function x3(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new Spe;var o=new Set;n.set(e,o)}else o=n.get(e),o===void 0&&(o=new Set,n.set(e,o));o.has(r)||(o.add(r),t=Mpe.bind(null,t,e,r),e.then(t,t))}function b3(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function $3(t,e,r,n,o){return t.mode&1?(t.flags|=65536,t.lanes=o,t):(t===e?t.flags|=65536:(t.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(e=Vs(-1,1),e.tag=2,sl(r,e,1))),r.lanes|=1),t)}var wpe=fa.ReactCurrentOwner,jn=!1;function dn(t,e,r,n){e.child=t===null?lW(e,null,r,n):Kd(e,t.child,r,n)}function I3(t,e,r,n,o){r=r.render;var i=e.ref;return Pd(e,o),n=rk(t,e,r,n,i,o),r=nk(),t!==null&&!jn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~o,na(t,e,o)):(At&&r&&WA(e),e.flags|=1,dn(t,e,n,o),e.child)}function P3(t,e,r,n,o){if(t===null){var i=r.type;return typeof i=="function"&&!fk(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=i,RW(t,e,i,n,o)):(t=pS(r.type,null,n,e,e.mode,o),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&o)){var s=i.memoizedProps;if(r=r.compare,r=r!==null?r:eg,r(s,n)&&t.ref===e.ref)return na(t,e,o)}return e.flags|=1,t=cl(i,n),t.ref=e.ref,t.return=e,e.child=t}function RW(t,e,r,n,o){if(t!==null){var i=t.memoizedProps;if(eg(i,n)&&t.ref===e.ref)if(jn=!1,e.pendingProps=n=i,(t.lanes&o)!==0)t.flags&131072&&(jn=!0);else return e.lanes=t.lanes,na(t,e,o)}return y_(t,e,r,n,o)}function jW(t,e,r){var n=e.pendingProps,o=n.children,i=t!==null?t.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},mt(sd,to),to|=r;else{if(!(r&1073741824))return t=i!==null?i.baseLanes|r:r,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,mt(sd,to),to|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,mt(sd,to),to|=n}else i!==null?(n=i.baseLanes|r,e.memoizedState=null):n=r,mt(sd,to),to|=n;return dn(t,e,o,r),e.child}function DW(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function y_(t,e,r,n,o){var i=Un(r)?Ac:Jr.current;return i=Hd(e,i),Pd(e,o),r=rk(t,e,r,n,i,o),n=nk(),t!==null&&!jn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~o,na(t,e,o)):(At&&n&&WA(e),e.flags|=1,dn(t,e,r,o),e.child)}function E3(t,e,r,n,o){if(Un(r)){var i=!0;$w(e)}else i=!1;if(Pd(e,o),e.stateNode===null)dS(t,e),kW(e,r,n),m_(e,r,n,o),n=!0;else if(t===null){var s=e.stateNode,a=e.memoizedProps;s.props=a;var l=s.context,c=r.contextType;typeof c=="object"&&c!==null?c=Yo(c):(c=Un(r)?Ac:Jr.current,c=Hd(e,c));var u=r.getDerivedStateFromProps,d=typeof u=="function"||typeof s.getSnapshotBeforeUpdate=="function";d||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==n||l!==c)&&w3(e,s,n,c),Fa=!1;var f=e.memoizedState;s.state=f,_w(e,n,s,o),l=e.memoizedState,a!==n||f!==l||Bn.current||Fa?(typeof u=="function"&&(g_(e,r,u,n),l=e.memoizedState),(a=Fa||S3(e,r,a,n,f,l,c))?(d||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(e.flags|=4194308)):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=l),s.props=n,s.state=l,s.context=c,n=a):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{s=e.stateNode,uW(t,e),a=e.memoizedProps,c=e.type===e.elementType?a:si(e.type,a),s.props=c,d=e.pendingProps,f=s.context,l=r.contextType,typeof l=="object"&&l!==null?l=Yo(l):(l=Un(r)?Ac:Jr.current,l=Hd(e,l));var p=r.getDerivedStateFromProps;(u=typeof p=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==d||f!==l)&&w3(e,s,n,l),Fa=!1,f=e.memoizedState,s.state=f,_w(e,n,s,o);var g=e.memoizedState;a!==d||f!==g||Bn.current||Fa?(typeof p=="function"&&(g_(e,r,p,n),g=e.memoizedState),(c=Fa||S3(e,r,c,n,f,g,l)||!1)?(u||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(n,g,l),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(n,g,l)),typeof s.componentDidUpdate=="function"&&(e.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof s.componentDidUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=g),s.props=n,s.state=g,s.context=l,n=c):(typeof s.componentDidUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),n=!1)}return S_(t,e,r,n,i,o)}function S_(t,e,r,n,o,i){DW(t,e);var s=(e.flags&128)!==0;if(!n&&!s)return o&&d3(e,r,!1),na(t,e,i);n=e.stateNode,wpe.current=e;var a=s&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&s?(e.child=Kd(e,t.child,null,i),e.child=Kd(e,null,a,i)):dn(t,e,a,i),e.memoizedState=n.state,o&&d3(e,r,!0),e.child}function LW(t){var e=t.stateNode;e.pendingContext?u3(t,e.pendingContext,e.pendingContext!==e.context):e.context&&u3(t,e.context,!1),QA(t,e.containerInfo)}function C3(t,e,r,n,o){return Wd(),GA(o),e.flags|=256,dn(t,e,r,n),e.child}var w_={dehydrated:null,treeContext:null,retryLane:0};function x_(t){return{baseLanes:t,cachePool:null,transitions:null}}function NW(t,e,r){var n=e.pendingProps,o=jt.current,i=!1,s=(e.flags&128)!==0,a;if((a=s)||(a=t!==null&&t.memoizedState===null?!1:(o&2)!==0),a?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(o|=1),mt(jt,o&1),t===null)return f_(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(s=n.children,t=n.fallback,i?(n=e.mode,i=e.child,s={mode:"hidden",children:s},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=s):i=wx(s,n,0,null),t=$c(t,n,r,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=x_(r),e.memoizedState=w_,t):sk(e,s));if(o=t.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return xpe(t,e,s,n,a,o,r);if(i){i=n.fallback,s=e.mode,o=t.child,a=o.sibling;var l={mode:"hidden",children:n.children};return!(s&1)&&e.child!==o?(n=e.child,n.childLanes=0,n.pendingProps=l,e.deletions=null):(n=cl(o,l),n.subtreeFlags=o.subtreeFlags&14680064),a!==null?i=cl(a,i):(i=$c(i,s,r,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,s=t.child.memoizedState,s=s===null?x_(r):{baseLanes:s.baseLanes|r,cachePool:null,transitions:s.transitions},i.memoizedState=s,i.childLanes=t.childLanes&~r,e.memoizedState=w_,n}return i=t.child,t=i.sibling,n=cl(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=r),n.return=e,n.sibling=null,t!==null&&(r=e.deletions,r===null?(e.deletions=[t],e.flags|=16):r.push(t)),e.child=n,e.memoizedState=null,n}function sk(t,e){return e=wx({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function hv(t,e,r,n){return n!==null&&GA(n),Kd(e,t.child,null,r),t=sk(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function xpe(t,e,r,n,o,i,s){if(r)return e.flags&256?(e.flags&=-257,n=b$(Error(Z(422))),hv(t,e,s,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=n.fallback,o=e.mode,n=wx({mode:"visible",children:n.children},o,0,null),i=$c(i,o,s,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&Kd(e,t.child,null,s),e.child.memoizedState=x_(s),e.memoizedState=w_,i);if(!(e.mode&1))return hv(t,e,s,null);if(o.data==="$!"){if(n=o.nextSibling&&o.nextSibling.dataset,n)var a=n.dgst;return n=a,i=Error(Z(419)),n=b$(i,n,void 0),hv(t,e,s,n)}if(a=(s&t.childLanes)!==0,jn||a){if(n=gr,n!==null){switch(s&-s){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(n.suspendedLanes|s)?0:o,o!==0&&o!==i.retryLane&&(i.retryLane=o,ra(t,o),vi(n,t,o,-1))}return hk(),n=b$(Error(Z(421))),hv(t,e,s,n)}return o.data==="$?"?(e.flags|=128,e.child=t.child,e=Rpe.bind(null,t),o._reactRetry=e,null):(t=i.treeContext,oo=il(o.nextSibling),ao=e,At=!0,ci=null,t!==null&&(Fo[Bo++]=zs,Fo[Bo++]=Hs,Fo[Bo++]=kc,zs=t.id,Hs=t.overflow,kc=e),e=sk(e,n.children),e.flags|=4096,e)}function _3(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),p_(t.return,e,r)}function $$(t,e,r,n,o){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:o}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=o)}function FW(t,e,r){var n=e.pendingProps,o=n.revealOrder,i=n.tail;if(dn(t,e,n.children,r),n=jt.current,n&2)n=n&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&_3(t,r,e);else if(t.tag===19)_3(t,r,e);else if(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;t=t.return}t.sibling.return=t.return,t=t.sibling}n&=1}if(mt(jt,n),!(e.mode&1))e.memoizedState=null;else switch(o){case"forwards":for(r=e.child,o=null;r!==null;)t=r.alternate,t!==null&&Tw(t)===null&&(o=r),r=r.sibling;r=o,r===null?(o=e.child,e.child=null):(o=r.sibling,r.sibling=null),$$(e,!1,o,r,i);break;case"backwards":for(r=null,o=e.child,e.child=null;o!==null;){if(t=o.alternate,t!==null&&Tw(t)===null){e.child=o;break}t=o.sibling,o.sibling=r,r=o,o=t}$$(e,!0,r,null,i);break;case"together":$$(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function dS(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function na(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),Mc|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(Z(153));if(e.child!==null){for(t=e.child,r=cl(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=cl(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function bpe(t,e,r){switch(e.tag){case 3:LW(e),Wd();break;case 5:dW(e);break;case 1:Un(e.type)&&$w(e);break;case 4:QA(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,o=e.memoizedProps.value;mt(Ew,n._currentValue),n._currentValue=o;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(mt(jt,jt.current&1),e.flags|=128,null):r&e.child.childLanes?NW(t,e,r):(mt(jt,jt.current&1),t=na(t,e,r),t!==null?t.sibling:null);mt(jt,jt.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return FW(t,e,r);e.flags|=128}if(o=e.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),mt(jt,jt.current),n)break;return null;case 22:case 23:return e.lanes=0,jW(t,e,r)}return na(t,e,r)}var BW,b_,UW,zW;BW=function(t,e){for(var r=e.child;r!==null;){if(r.tag===5||r.tag===6)t.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};b_=function(){};UW=function(t,e,r,n){var o=t.memoizedProps;if(o!==n){t=e.stateNode,Sc(ns.current);var i=null;switch(r){case"input":o=WC(t,o),n=WC(t,n),i=[];break;case"select":o=Ft({},o,{value:void 0}),n=Ft({},n,{value:void 0}),i=[];break;case"textarea":o=VC(t,o),n=VC(t,n),i=[];break;default:typeof o.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=xw)}XC(r,n);var s;r=null;for(c in o)if(!n.hasOwnProperty(c)&&o.hasOwnProperty(c)&&o[c]!=null)if(c==="style"){var a=o[c];for(s in a)a.hasOwnProperty(s)&&(r||(r={}),r[s]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Vp.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in n){var l=n[c];if(a=o!=null?o[c]:void 0,n.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(s in a)!a.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(r||(r={}),r[s]="");for(s in l)l.hasOwnProperty(s)&&a[s]!==l[s]&&(r||(r={}),r[s]=l[s])}else r||(i||(i=[]),i.push(c,r)),r=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Vp.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&bt("scroll",t),i||a===l||(i=[])):(i=i||[]).push(c,l))}r&&(i=i||[]).push("style",r);var c=i;(e.updateQueue=c)&&(e.flags|=4)}};zW=function(t,e,r,n){r!==n&&(e.flags|=4)};function cf(t,e){if(!At)switch(t.tailMode){case"hidden":e=t.tail;for(var r=null;e!==null;)e.alternate!==null&&(r=e),e=e.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:n.sibling=null}}function Wr(t){var e=t.alternate!==null&&t.alternate.child===t.child,r=0,n=0;if(e)for(var o=t.child;o!==null;)r|=o.lanes|o.childLanes,n|=o.subtreeFlags&14680064,n|=o.flags&14680064,o.return=t,o=o.sibling;else for(o=t.child;o!==null;)r|=o.lanes|o.childLanes,n|=o.subtreeFlags,n|=o.flags,o.return=t,o=o.sibling;return t.subtreeFlags|=n,t.childLanes=r,e}function $pe(t,e,r){var n=e.pendingProps;switch(KA(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wr(e),null;case 1:return Un(e.type)&&bw(),Wr(e),null;case 3:return n=e.stateNode,Gd(),It(Bn),It(Jr),ek(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(uv(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,ci!==null&&(A_(ci),ci=null))),b_(t,e),Wr(e),null;case 5:JA(e);var o=Sc(ig.current);if(r=e.type,t!==null&&e.stateNode!=null)UW(t,e,r,n,o),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(Z(166));return Wr(e),null}if(t=Sc(ns.current),uv(e)){n=e.stateNode,r=e.type;var i=e.memoizedProps;switch(n[Gi]=e,n[ng]=i,t=(e.mode&1)!==0,r){case"dialog":bt("cancel",n),bt("close",n);break;case"iframe":case"object":case"embed":bt("load",n);break;case"video":case"audio":for(o=0;o<Zf.length;o++)bt(Zf[o],n);break;case"source":bt("error",n);break;case"img":case"image":case"link":bt("error",n),bt("load",n);break;case"details":bt("toggle",n);break;case"input":LD(n,i),bt("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},bt("invalid",n);break;case"textarea":FD(n,i),bt("invalid",n)}XC(r,i),o=null;for(var s in i)if(i.hasOwnProperty(s)){var a=i[s];s==="children"?typeof a=="string"?n.textContent!==a&&(i.suppressHydrationWarning!==!0&&cv(n.textContent,a,t),o=["children",a]):typeof a=="number"&&n.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&cv(n.textContent,a,t),o=["children",""+a]):Vp.hasOwnProperty(s)&&a!=null&&s==="onScroll"&&bt("scroll",n)}switch(r){case"input":tv(n),ND(n,i,!0);break;case"textarea":tv(n),BD(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=xw)}n=o,e.updateQueue=n,n!==null&&(e.flags|=4)}else{s=o.nodeType===9?o:o.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=mH(r)),t==="http://www.w3.org/1999/xhtml"?r==="script"?(t=s.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=s.createElement(r,{is:n.is}):(t=s.createElement(r),r==="select"&&(s=t,n.multiple?s.multiple=!0:n.size&&(s.size=n.size))):t=s.createElementNS(t,r),t[Gi]=e,t[ng]=n,BW(t,e,!1,!1),e.stateNode=t;e:{switch(s=qC(r,n),r){case"dialog":bt("cancel",t),bt("close",t),o=n;break;case"iframe":case"object":case"embed":bt("load",t),o=n;break;case"video":case"audio":for(o=0;o<Zf.length;o++)bt(Zf[o],t);o=n;break;case"source":bt("error",t),o=n;break;case"img":case"image":case"link":bt("error",t),bt("load",t),o=n;break;case"details":bt("toggle",t),o=n;break;case"input":LD(t,n),o=WC(t,n),bt("invalid",t);break;case"option":o=n;break;case"select":t._wrapperState={wasMultiple:!!n.multiple},o=Ft({},n,{value:void 0}),bt("invalid",t);break;case"textarea":FD(t,n),o=VC(t,n),bt("invalid",t);break;default:o=n}XC(r,o),a=o;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?SH(t,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&vH(t,l)):i==="children"?typeof l=="string"?(r!=="textarea"||l!=="")&&Yp(t,l):typeof l=="number"&&Yp(t,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Vp.hasOwnProperty(i)?l!=null&&i==="onScroll"&&bt("scroll",t):l!=null&&AA(t,i,l,s))}switch(r){case"input":tv(t),ND(t,n,!1);break;case"textarea":tv(t),BD(t);break;case"option":n.value!=null&&t.setAttribute("value",""+vl(n.value));break;case"select":t.multiple=!!n.multiple,i=n.value,i!=null?xd(t,!!n.multiple,i,!1):n.defaultValue!=null&&xd(t,!!n.multiple,n.defaultValue,!0);break;default:typeof o.onClick=="function"&&(t.onclick=xw)}switch(r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Wr(e),null;case 6:if(t&&e.stateNode!=null)zW(t,e,t.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(Z(166));if(r=Sc(ig.current),Sc(ns.current),uv(e)){if(n=e.stateNode,r=e.memoizedProps,n[Gi]=e,(i=n.nodeValue!==r)&&(t=ao,t!==null))switch(t.tag){case 3:cv(n.nodeValue,r,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&cv(n.nodeValue,r,(t.mode&1)!==0)}i&&(e.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[Gi]=e,e.stateNode=n}return Wr(e),null;case 13:if(It(jt),n=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(At&&oo!==null&&e.mode&1&&!(e.flags&128))sW(),Wd(),e.flags|=98560,i=!1;else if(i=uv(e),n!==null&&n.dehydrated!==null){if(t===null){if(!i)throw Error(Z(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Z(317));i[Gi]=e}else Wd(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Wr(e),i=!1}else ci!==null&&(A_(ci),ci=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=r,e):(n=n!==null,n!==(t!==null&&t.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(t===null||jt.current&1?rr===0&&(rr=3):hk())),e.updateQueue!==null&&(e.flags|=4),Wr(e),null);case 4:return Gd(),b_(t,e),t===null&&tg(e.stateNode.containerInfo),Wr(e),null;case 10:return XA(e.type._context),Wr(e),null;case 17:return Un(e.type)&&bw(),Wr(e),null;case 19:if(It(jt),i=e.memoizedState,i===null)return Wr(e),null;if(n=(e.flags&128)!==0,s=i.rendering,s===null)if(n)cf(i,!1);else{if(rr!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(s=Tw(t),s!==null){for(e.flags|=128,cf(i,!1),n=s.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=r,r=e.child;r!==null;)i=r,t=n,i.flags&=14680066,s=i.alternate,s===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,i.type=s.type,t=s.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return mt(jt,jt.current&1|2),e.child}t=t.sibling}i.tail!==null&&Yt()>Yd&&(e.flags|=128,n=!0,cf(i,!1),e.lanes=4194304)}else{if(!n)if(t=Tw(s),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),cf(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!At)return Wr(e),null}else 2*Yt()-i.renderingStartTime>Yd&&r!==1073741824&&(e.flags|=128,n=!0,cf(i,!1),e.lanes=4194304);i.isBackwards?(s.sibling=e.child,e.child=s):(r=i.last,r!==null?r.sibling=s:e.child=s,i.last=s)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Yt(),e.sibling=null,r=jt.current,mt(jt,n?r&1|2:r&1),e):(Wr(e),null);case 22:case 23:return dk(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?to&1073741824&&(Wr(e),e.subtreeFlags&6&&(e.flags|=8192)):Wr(e),null;case 24:return null;case 25:return null}throw Error(Z(156,e.tag))}function Ipe(t,e){switch(KA(e),e.tag){case 1:return Un(e.type)&&bw(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Gd(),It(Bn),It(Jr),ek(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return JA(e),null;case 13:if(It(jt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Z(340));Wd()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return It(jt),null;case 4:return Gd(),null;case 10:return XA(e.type._context),null;case 22:case 23:return dk(),null;case 24:return null;default:return null}}var fv=!1,Xr=!1,Ppe=typeof WeakSet=="function"?WeakSet:Set,ce=null;function id(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Wt(t,e,n)}else r.current=null}function $_(t,e,r){try{r()}catch(n){Wt(t,e,n)}}var T3=!1;function Epe(t,e){if(s_=yw,t=VH(),HA(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var o=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var s=0,a=-1,l=-1,c=0,u=0,d=t,f=null;t:for(;;){for(var p;d!==r||o!==0&&d.nodeType!==3||(a=s+o),d!==i||n!==0&&d.nodeType!==3||(l=s+n),d.nodeType===3&&(s+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===t)break t;if(f===r&&++c===o&&(a=s),f===i&&++u===n&&(l=s),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}r=a===-1||l===-1?null:{start:a,end:l}}else r=null}r=r||{start:0,end:0}}else r=null;for(a_={focusedElem:t,selectionRange:r},yw=!1,ce=e;ce!==null;)if(e=ce,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,ce=t;else for(;ce!==null;){e=ce;try{var g=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var m=g.memoizedProps,S=g.memoizedState,y=e.stateNode,v=y.getSnapshotBeforeUpdate(e.elementType===e.type?m:si(e.type,m),S);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var b=e.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Z(163))}}catch($){Wt(e,e.return,$)}if(t=e.sibling,t!==null){t.return=e.return,ce=t;break}ce=e.return}return g=T3,T3=!1,g}function Ip(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var o=n=n.next;do{if((o.tag&t)===t){var i=o.destroy;o.destroy=void 0,i!==void 0&&$_(e,r,i)}o=o.next}while(o!==n)}}function yx(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function I_(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function HW(t){var e=t.alternate;e!==null&&(t.alternate=null,HW(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Gi],delete e[ng],delete e[u_],delete e[lpe],delete e[cpe])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function WW(t){return t.tag===5||t.tag===3||t.tag===4}function A3(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||WW(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function P_(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=xw));else if(n!==4&&(t=t.child,t!==null))for(P_(t,e,r),t=t.sibling;t!==null;)P_(t,e,r),t=t.sibling}function E_(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(E_(t,e,r),t=t.sibling;t!==null;)E_(t,e,r),t=t.sibling}var Ir=null,ai=!1;function _a(t,e,r){for(r=r.child;r!==null;)KW(t,e,r),r=r.sibling}function KW(t,e,r){if(rs&&typeof rs.onCommitFiberUnmount=="function")try{rs.onCommitFiberUnmount(ux,r)}catch{}switch(r.tag){case 5:Xr||id(r,e);case 6:var n=Ir,o=ai;Ir=null,_a(t,e,r),Ir=n,ai=o,Ir!==null&&(ai?(t=Ir,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Ir.removeChild(r.stateNode));break;case 18:Ir!==null&&(ai?(t=Ir,r=r.stateNode,t.nodeType===8?m$(t.parentNode,r):t.nodeType===1&&m$(t,r),Qp(t)):m$(Ir,r.stateNode));break;case 4:n=Ir,o=ai,Ir=r.stateNode.containerInfo,ai=!0,_a(t,e,r),Ir=n,ai=o;break;case 0:case 11:case 14:case 15:if(!Xr&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){o=n=n.next;do{var i=o,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&$_(r,e,s),o=o.next}while(o!==n)}_a(t,e,r);break;case 1:if(!Xr&&(id(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){Wt(r,e,a)}_a(t,e,r);break;case 21:_a(t,e,r);break;case 22:r.mode&1?(Xr=(n=Xr)||r.memoizedState!==null,_a(t,e,r),Xr=n):_a(t,e,r);break;default:_a(t,e,r)}}function k3(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Ppe),e.forEach(function(n){var o=jpe.bind(null,t,n);r.has(n)||(r.add(n),n.then(o,o))})}}function ni(t,e){var r=e.deletions;if(r!==null)for(var n=0;n<r.length;n++){var o=r[n];try{var i=t,s=e,a=s;e:for(;a!==null;){switch(a.tag){case 5:Ir=a.stateNode,ai=!1;break e;case 3:Ir=a.stateNode.containerInfo,ai=!0;break e;case 4:Ir=a.stateNode.containerInfo,ai=!0;break e}a=a.return}if(Ir===null)throw Error(Z(160));KW(i,s,o),Ir=null,ai=!1;var l=o.alternate;l!==null&&(l.return=null),o.return=null}catch(c){Wt(o,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)GW(e,t),e=e.sibling}function GW(t,e){var r=t.alternate,n=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(ni(e,t),Ni(t),n&4){try{Ip(3,t,t.return),yx(3,t)}catch(m){Wt(t,t.return,m)}try{Ip(5,t,t.return)}catch(m){Wt(t,t.return,m)}}break;case 1:ni(e,t),Ni(t),n&512&&r!==null&&id(r,r.return);break;case 5:if(ni(e,t),Ni(t),n&512&&r!==null&&id(r,r.return),t.flags&32){var o=t.stateNode;try{Yp(o,"")}catch(m){Wt(t,t.return,m)}}if(n&4&&(o=t.stateNode,o!=null)){var i=t.memoizedProps,s=r!==null?r.memoizedProps:i,a=t.type,l=t.updateQueue;if(t.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&pH(o,i),qC(a,s);var c=qC(a,i);for(s=0;s<l.length;s+=2){var u=l[s],d=l[s+1];u==="style"?SH(o,d):u==="dangerouslySetInnerHTML"?vH(o,d):u==="children"?Yp(o,d):AA(o,u,d,c)}switch(a){case"input":KC(o,i);break;case"textarea":gH(o,i);break;case"select":var f=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?xd(o,!!i.multiple,p,!1):f!==!!i.multiple&&(i.defaultValue!=null?xd(o,!!i.multiple,i.defaultValue,!0):xd(o,!!i.multiple,i.multiple?[]:"",!1))}o[ng]=i}catch(m){Wt(t,t.return,m)}}break;case 6:if(ni(e,t),Ni(t),n&4){if(t.stateNode===null)throw Error(Z(162));o=t.stateNode,i=t.memoizedProps;try{o.nodeValue=i}catch(m){Wt(t,t.return,m)}}break;case 3:if(ni(e,t),Ni(t),n&4&&r!==null&&r.memoizedState.isDehydrated)try{Qp(e.containerInfo)}catch(m){Wt(t,t.return,m)}break;case 4:ni(e,t),Ni(t);break;case 13:ni(e,t),Ni(t),o=t.child,o.flags&8192&&(i=o.memoizedState!==null,o.stateNode.isHidden=i,!i||o.alternate!==null&&o.alternate.memoizedState!==null||(ck=Yt())),n&4&&k3(t);break;case 22:if(u=r!==null&&r.memoizedState!==null,t.mode&1?(Xr=(c=Xr)||u,ni(e,t),Xr=c):ni(e,t),Ni(t),n&8192){if(c=t.memoizedState!==null,(t.stateNode.isHidden=c)&&!u&&t.mode&1)for(ce=t,u=t.child;u!==null;){for(d=ce=u;ce!==null;){switch(f=ce,p=f.child,f.tag){case 0:case 11:case 14:case 15:Ip(4,f,f.return);break;case 1:id(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){n=f,r=f.return;try{e=n,g.props=e.memoizedProps,g.state=e.memoizedState,g.componentWillUnmount()}catch(m){Wt(n,r,m)}}break;case 5:id(f,f.return);break;case 22:if(f.memoizedState!==null){M3(d);continue}}p!==null?(p.return=f,ce=p):M3(d)}u=u.sibling}e:for(u=null,d=t;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,c?(i=o.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=d.stateNode,l=d.memoizedProps.style,s=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=yH("display",s))}catch(m){Wt(t,t.return,m)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(m){Wt(t,t.return,m)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===t)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===t)break e;for(;d.sibling===null;){if(d.return===null||d.return===t)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:ni(e,t),Ni(t),n&4&&k3(t);break;case 21:break;default:ni(e,t),Ni(t)}}function Ni(t){var e=t.flags;if(e&2){try{e:{for(var r=t.return;r!==null;){if(WW(r)){var n=r;break e}r=r.return}throw Error(Z(160))}switch(n.tag){case 5:var o=n.stateNode;n.flags&32&&(Yp(o,""),n.flags&=-33);var i=A3(t);E_(t,i,o);break;case 3:case 4:var s=n.stateNode.containerInfo,a=A3(t);P_(t,a,s);break;default:throw Error(Z(161))}}catch(l){Wt(t,t.return,l)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function Cpe(t,e,r){ce=t,VW(t)}function VW(t,e,r){for(var n=(t.mode&1)!==0;ce!==null;){var o=ce,i=o.child;if(o.tag===22&&n){var s=o.memoizedState!==null||fv;if(!s){var a=o.alternate,l=a!==null&&a.memoizedState!==null||Xr;a=fv;var c=Xr;if(fv=s,(Xr=l)&&!c)for(ce=o;ce!==null;)s=ce,l=s.child,s.tag===22&&s.memoizedState!==null?R3(o):l!==null?(l.return=s,ce=l):R3(o);for(;i!==null;)ce=i,VW(i),i=i.sibling;ce=o,fv=a,Xr=c}O3(t)}else o.subtreeFlags&8772&&i!==null?(i.return=o,ce=i):O3(t)}}function O3(t){for(;ce!==null;){var e=ce;if(e.flags&8772){var r=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Xr||yx(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Xr)if(r===null)n.componentDidMount();else{var o=e.elementType===e.type?r.memoizedProps:si(e.type,r.memoizedProps);n.componentDidUpdate(o,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&m3(e,i,n);break;case 3:var s=e.updateQueue;if(s!==null){if(r=null,e.child!==null)switch(e.child.tag){case 5:r=e.child.stateNode;break;case 1:r=e.child.stateNode}m3(e,s,r)}break;case 5:var a=e.stateNode;if(r===null&&e.flags&4){r=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&r.focus();break;case"img":l.src&&(r.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&Qp(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Z(163))}Xr||e.flags&512&&I_(e)}catch(f){Wt(e,e.return,f)}}if(e===t){ce=null;break}if(r=e.sibling,r!==null){r.return=e.return,ce=r;break}ce=e.return}}function M3(t){for(;ce!==null;){var e=ce;if(e===t){ce=null;break}var r=e.sibling;if(r!==null){r.return=e.return,ce=r;break}ce=e.return}}function R3(t){for(;ce!==null;){var e=ce;try{switch(e.tag){case 0:case 11:case 15:var r=e.return;try{yx(4,e)}catch(l){Wt(e,r,l)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var o=e.return;try{n.componentDidMount()}catch(l){Wt(e,o,l)}}var i=e.return;try{I_(e)}catch(l){Wt(e,i,l)}break;case 5:var s=e.return;try{I_(e)}catch(l){Wt(e,s,l)}}}catch(l){Wt(e,e.return,l)}if(e===t){ce=null;break}var a=e.sibling;if(a!==null){a.return=e.return,ce=a;break}ce=e.return}}var _pe=Math.ceil,Ow=fa.ReactCurrentDispatcher,ak=fa.ReactCurrentOwner,Go=fa.ReactCurrentBatchConfig,qe=0,gr=null,er=null,Or=0,to=0,sd=Al(0),rr=0,cg=null,Mc=0,Sx=0,lk=0,Pp=null,kn=null,ck=0,Yd=1/0,Ds=null,Mw=!1,C_=null,al=null,pv=!1,Ya=null,Rw=0,Ep=0,__=null,hS=-1,fS=0;function pn(){return qe&6?Yt():hS!==-1?hS:hS=Yt()}function ll(t){return t.mode&1?qe&2&&Or!==0?Or&-Or:dpe.transition!==null?(fS===0&&(fS=kH()),fS):(t=it,t!==0||(t=window.event,t=t===void 0?16:NH(t.type)),t):1}function vi(t,e,r,n){if(50<Ep)throw Ep=0,__=null,Error(Z(185));Lg(t,r,n),(!(qe&2)||t!==gr)&&(t===gr&&(!(qe&2)&&(Sx|=r),rr===4&&Ha(t,Or)),zn(t,n),r===1&&qe===0&&!(e.mode&1)&&(Yd=Yt()+500,gx&&kl()))}function zn(t,e){var r=t.callbackNode;dfe(t,e);var n=vw(t,t===gr?Or:0);if(n===0)r!==null&&HD(r),t.callbackNode=null,t.callbackPriority=0;else if(e=n&-n,t.callbackPriority!==e){if(r!=null&&HD(r),e===1)t.tag===0?upe(j3.bind(null,t)):nW(j3.bind(null,t)),spe(function(){!(qe&6)&&kl()}),r=null;else{switch(OH(n)){case 1:r=jA;break;case 4:r=TH;break;case 16:r=mw;break;case 536870912:r=AH;break;default:r=mw}r=tK(r,YW.bind(null,t))}t.callbackPriority=e,t.callbackNode=r}}function YW(t,e){if(hS=-1,fS=0,qe&6)throw Error(Z(327));var r=t.callbackNode;if(Ed()&&t.callbackNode!==r)return null;var n=vw(t,t===gr?Or:0);if(n===0)return null;if(n&30||n&t.expiredLanes||e)e=jw(t,n);else{e=n;var o=qe;qe|=2;var i=qW();(gr!==t||Or!==e)&&(Ds=null,Yd=Yt()+500,bc(t,e));do try{kpe();break}catch(a){XW(t,a)}while(!0);YA(),Ow.current=i,qe=o,er!==null?e=0:(gr=null,Or=0,e=rr)}if(e!==0){if(e===2&&(o=t_(t),o!==0&&(n=o,e=T_(t,o))),e===1)throw r=cg,bc(t,0),Ha(t,n),zn(t,Yt()),r;if(e===6)Ha(t,n);else{if(o=t.current.alternate,!(n&30)&&!Tpe(o)&&(e=jw(t,n),e===2&&(i=t_(t),i!==0&&(n=i,e=T_(t,i))),e===1))throw r=cg,bc(t,0),Ha(t,n),zn(t,Yt()),r;switch(t.finishedWork=o,t.finishedLanes=n,e){case 0:case 1:throw Error(Z(345));case 2:fc(t,kn,Ds);break;case 3:if(Ha(t,n),(n&130023424)===n&&(e=ck+500-Yt(),10<e)){if(vw(t,0)!==0)break;if(o=t.suspendedLanes,(o&n)!==n){pn(),t.pingedLanes|=t.suspendedLanes&o;break}t.timeoutHandle=c_(fc.bind(null,t,kn,Ds),e);break}fc(t,kn,Ds);break;case 4:if(Ha(t,n),(n&4194240)===n)break;for(e=t.eventTimes,o=-1;0<n;){var s=31-mi(n);i=1<<s,s=e[s],s>o&&(o=s),n&=~i}if(n=o,n=Yt()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*_pe(n/1960))-n,10<n){t.timeoutHandle=c_(fc.bind(null,t,kn,Ds),n);break}fc(t,kn,Ds);break;case 5:fc(t,kn,Ds);break;default:throw Error(Z(329))}}}return zn(t,Yt()),t.callbackNode===r?YW.bind(null,t):null}function T_(t,e){var r=Pp;return t.current.memoizedState.isDehydrated&&(bc(t,e).flags|=256),t=jw(t,e),t!==2&&(e=kn,kn=r,e!==null&&A_(e)),t}function A_(t){kn===null?kn=t:kn.push.apply(kn,t)}function Tpe(t){for(var e=t;;){if(e.flags&16384){var r=e.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var n=0;n<r.length;n++){var o=r[n],i=o.getSnapshot;o=o.value;try{if(!wi(i(),o))return!1}catch{return!1}}}if(r=e.child,e.subtreeFlags&16384&&r!==null)r.return=e,e=r;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Ha(t,e){for(e&=~lk,e&=~Sx,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var r=31-mi(e),n=1<<r;t[r]=-1,e&=~n}}function j3(t){if(qe&6)throw Error(Z(327));Ed();var e=vw(t,0);if(!(e&1))return zn(t,Yt()),null;var r=jw(t,e);if(t.tag!==0&&r===2){var n=t_(t);n!==0&&(e=n,r=T_(t,n))}if(r===1)throw r=cg,bc(t,0),Ha(t,e),zn(t,Yt()),r;if(r===6)throw Error(Z(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,fc(t,kn,Ds),zn(t,Yt()),null}function uk(t,e){var r=qe;qe|=1;try{return t(e)}finally{qe=r,qe===0&&(Yd=Yt()+500,gx&&kl())}}function Rc(t){Ya!==null&&Ya.tag===0&&!(qe&6)&&Ed();var e=qe;qe|=1;var r=Go.transition,n=it;try{if(Go.transition=null,it=1,t)return t()}finally{it=n,Go.transition=r,qe=e,!(qe&6)&&kl()}}function dk(){to=sd.current,It(sd)}function bc(t,e){t.finishedWork=null,t.finishedLanes=0;var r=t.timeoutHandle;if(r!==-1&&(t.timeoutHandle=-1,ipe(r)),er!==null)for(r=er.return;r!==null;){var n=r;switch(KA(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&bw();break;case 3:Gd(),It(Bn),It(Jr),ek();break;case 5:JA(n);break;case 4:Gd();break;case 13:It(jt);break;case 19:It(jt);break;case 10:XA(n.type._context);break;case 22:case 23:dk()}r=r.return}if(gr=t,er=t=cl(t.current,null),Or=to=e,rr=0,cg=null,lk=Sx=Mc=0,kn=Pp=null,yc!==null){for(e=0;e<yc.length;e++)if(r=yc[e],n=r.interleaved,n!==null){r.interleaved=null;var o=n.next,i=r.pending;if(i!==null){var s=i.next;i.next=o,n.next=s}r.pending=n}yc=null}return t}function XW(t,e){do{var r=er;try{if(YA(),cS.current=kw,Aw){for(var n=Nt.memoizedState;n!==null;){var o=n.queue;o!==null&&(o.pending=null),n=n.next}Aw=!1}if(Oc=0,ur=tr=Nt=null,$p=!1,sg=0,ak.current=null,r===null||r.return===null){rr=1,cg=e,er=null;break}e:{var i=t,s=r.return,a=r,l=e;if(e=Or,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=b3(s);if(p!==null){p.flags&=-257,$3(p,s,a,i,e),p.mode&1&&x3(i,c,e),e=p,l=c;var g=e.updateQueue;if(g===null){var m=new Set;m.add(l),e.updateQueue=m}else g.add(l);break e}else{if(!(e&1)){x3(i,c,e),hk();break e}l=Error(Z(426))}}else if(At&&a.mode&1){var S=b3(s);if(S!==null){!(S.flags&65536)&&(S.flags|=256),$3(S,s,a,i,e),GA(Vd(l,a));break e}}i=l=Vd(l,a),rr!==4&&(rr=2),Pp===null?Pp=[i]:Pp.push(i),i=s;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var y=OW(i,l,e);g3(i,y);break e;case 1:a=l;var v=i.type,b=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(al===null||!al.has(b)))){i.flags|=65536,e&=-e,i.lanes|=e;var $=MW(i,a,e);g3(i,$);break e}}i=i.return}while(i!==null)}QW(r)}catch(P){e=P,er===r&&r!==null&&(er=r=r.return);continue}break}while(!0)}function qW(){var t=Ow.current;return Ow.current=kw,t===null?kw:t}function hk(){(rr===0||rr===3||rr===2)&&(rr=4),gr===null||!(Mc&268435455)&&!(Sx&268435455)||Ha(gr,Or)}function jw(t,e){var r=qe;qe|=2;var n=qW();(gr!==t||Or!==e)&&(Ds=null,bc(t,e));do try{Ape();break}catch(o){XW(t,o)}while(!0);if(YA(),qe=r,Ow.current=n,er!==null)throw Error(Z(261));return gr=null,Or=0,rr}function Ape(){for(;er!==null;)ZW(er)}function kpe(){for(;er!==null&&!rfe();)ZW(er)}function ZW(t){var e=eK(t.alternate,t,to);t.memoizedProps=t.pendingProps,e===null?QW(t):er=e,ak.current=null}function QW(t){var e=t;do{var r=e.alternate;if(t=e.return,e.flags&32768){if(r=Ipe(r,e),r!==null){r.flags&=32767,er=r;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{rr=6,er=null;return}}else if(r=$pe(r,e,to),r!==null){er=r;return}if(e=e.sibling,e!==null){er=e;return}er=e=t}while(e!==null);rr===0&&(rr=5)}function fc(t,e,r){var n=it,o=Go.transition;try{Go.transition=null,it=1,Ope(t,e,r,n)}finally{Go.transition=o,it=n}return null}function Ope(t,e,r,n){do Ed();while(Ya!==null);if(qe&6)throw Error(Z(327));r=t.finishedWork;var o=t.finishedLanes;if(r===null)return null;if(t.finishedWork=null,t.finishedLanes=0,r===t.current)throw Error(Z(177));t.callbackNode=null,t.callbackPriority=0;var i=r.lanes|r.childLanes;if(hfe(t,i),t===gr&&(er=gr=null,Or=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||pv||(pv=!0,tK(mw,function(){return Ed(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=Go.transition,Go.transition=null;var s=it;it=1;var a=qe;qe|=4,ak.current=null,Epe(t,r),GW(r,t),Qfe(a_),yw=!!s_,a_=s_=null,t.current=r,Cpe(r),nfe(),qe=a,it=s,Go.transition=i}else t.current=r;if(pv&&(pv=!1,Ya=t,Rw=o),i=t.pendingLanes,i===0&&(al=null),sfe(r.stateNode),zn(t,Yt()),e!==null)for(n=t.onRecoverableError,r=0;r<e.length;r++)o=e[r],n(o.value,{componentStack:o.stack,digest:o.digest});if(Mw)throw Mw=!1,t=C_,C_=null,t;return Rw&1&&t.tag!==0&&Ed(),i=t.pendingLanes,i&1?t===__?Ep++:(Ep=0,__=t):Ep=0,kl(),null}function Ed(){if(Ya!==null){var t=OH(Rw),e=Go.transition,r=it;try{if(Go.transition=null,it=16>t?16:t,Ya===null)var n=!1;else{if(t=Ya,Ya=null,Rw=0,qe&6)throw Error(Z(331));var o=qe;for(qe|=4,ce=t.current;ce!==null;){var i=ce,s=i.child;if(ce.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(ce=c;ce!==null;){var u=ce;switch(u.tag){case 0:case 11:case 15:Ip(8,u,i)}var d=u.child;if(d!==null)d.return=u,ce=d;else for(;ce!==null;){u=ce;var f=u.sibling,p=u.return;if(HW(u),u===c){ce=null;break}if(f!==null){f.return=p,ce=f;break}ce=p}}}var g=i.alternate;if(g!==null){var m=g.child;if(m!==null){g.child=null;do{var S=m.sibling;m.sibling=null,m=S}while(m!==null)}}ce=i}}if(i.subtreeFlags&2064&&s!==null)s.return=i,ce=s;else e:for(;ce!==null;){if(i=ce,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Ip(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,ce=y;break e}ce=i.return}}var v=t.current;for(ce=v;ce!==null;){s=ce;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,ce=b;else e:for(s=v;ce!==null;){if(a=ce,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:yx(9,a)}}catch(P){Wt(a,a.return,P)}if(a===s){ce=null;break e}var $=a.sibling;if($!==null){$.return=a.return,ce=$;break e}ce=a.return}}if(qe=o,kl(),rs&&typeof rs.onPostCommitFiberRoot=="function")try{rs.onPostCommitFiberRoot(ux,t)}catch{}n=!0}return n}finally{it=r,Go.transition=e}}return!1}function D3(t,e,r){e=Vd(r,e),e=OW(t,e,1),t=sl(t,e,1),e=pn(),t!==null&&(Lg(t,1,e),zn(t,e))}function Wt(t,e,r){if(t.tag===3)D3(t,t,r);else for(;e!==null;){if(e.tag===3){D3(e,t,r);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(al===null||!al.has(n))){t=Vd(r,t),t=MW(e,t,1),e=sl(e,t,1),t=pn(),e!==null&&(Lg(e,1,t),zn(e,t));break}}e=e.return}}function Mpe(t,e,r){var n=t.pingCache;n!==null&&n.delete(e),e=pn(),t.pingedLanes|=t.suspendedLanes&r,gr===t&&(Or&r)===r&&(rr===4||rr===3&&(Or&130023424)===Or&&500>Yt()-ck?bc(t,0):lk|=r),zn(t,e)}function JW(t,e){e===0&&(t.mode&1?(e=ov,ov<<=1,!(ov&130023424)&&(ov=4194304)):e=1);var r=pn();t=ra(t,e),t!==null&&(Lg(t,e,r),zn(t,r))}function Rpe(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),JW(t,r)}function jpe(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,o=t.memoizedState;o!==null&&(r=o.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Z(314))}n!==null&&n.delete(e),JW(t,r)}var eK;eK=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Bn.current)jn=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return jn=!1,bpe(t,e,r);jn=!!(t.flags&131072)}else jn=!1,At&&e.flags&1048576&&oW(e,Pw,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;dS(t,e),t=e.pendingProps;var o=Hd(e,Jr.current);Pd(e,r),o=rk(null,e,n,t,o,r);var i=nk();return e.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Un(n)?(i=!0,$w(e)):i=!1,e.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,ZA(e),o.updater=vx,e.stateNode=o,o._reactInternals=e,m_(e,n,t,r),e=S_(null,e,n,!0,i,r)):(e.tag=0,At&&i&&WA(e),dn(null,e,o,r),e=e.child),e;case 16:n=e.elementType;e:{switch(dS(t,e),t=e.pendingProps,o=n._init,n=o(n._payload),e.type=n,o=e.tag=Lpe(n),t=si(n,t),o){case 0:e=y_(null,e,n,t,r);break e;case 1:e=E3(null,e,n,t,r);break e;case 11:e=I3(null,e,n,t,r);break e;case 14:e=P3(null,e,n,si(n.type,t),r);break e}throw Error(Z(306,n,""))}return e;case 0:return n=e.type,o=e.pendingProps,o=e.elementType===n?o:si(n,o),y_(t,e,n,o,r);case 1:return n=e.type,o=e.pendingProps,o=e.elementType===n?o:si(n,o),E3(t,e,n,o,r);case 3:e:{if(LW(e),t===null)throw Error(Z(387));n=e.pendingProps,i=e.memoizedState,o=i.element,uW(t,e),_w(e,n,null,r);var s=e.memoizedState;if(n=s.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){o=Vd(Error(Z(423)),e),e=C3(t,e,n,r,o);break e}else if(n!==o){o=Vd(Error(Z(424)),e),e=C3(t,e,n,r,o);break e}else for(oo=il(e.stateNode.containerInfo.firstChild),ao=e,At=!0,ci=null,r=lW(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Wd(),n===o){e=na(t,e,r);break e}dn(t,e,n,r)}e=e.child}return e;case 5:return dW(e),t===null&&f_(e),n=e.type,o=e.pendingProps,i=t!==null?t.memoizedProps:null,s=o.children,l_(n,o)?s=null:i!==null&&l_(n,i)&&(e.flags|=32),DW(t,e),dn(t,e,s,r),e.child;case 6:return t===null&&f_(e),null;case 13:return NW(t,e,r);case 4:return QA(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=Kd(e,null,n,r):dn(t,e,n,r),e.child;case 11:return n=e.type,o=e.pendingProps,o=e.elementType===n?o:si(n,o),I3(t,e,n,o,r);case 7:return dn(t,e,e.pendingProps,r),e.child;case 8:return dn(t,e,e.pendingProps.children,r),e.child;case 12:return dn(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,o=e.pendingProps,i=e.memoizedProps,s=o.value,mt(Ew,n._currentValue),n._currentValue=s,i!==null)if(wi(i.value,s)){if(i.children===o.children&&!Bn.current){e=na(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){s=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=Vs(-1,r&-r),l.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}i.lanes|=r,l=i.alternate,l!==null&&(l.lanes|=r),p_(i.return,r,e),a.lanes|=r;break}l=l.next}}else if(i.tag===10)s=i.type===e.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(Z(341));s.lanes|=r,a=s.alternate,a!==null&&(a.lanes|=r),p_(s,r,e),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}dn(t,e,o.children,r),e=e.child}return e;case 9:return o=e.type,n=e.pendingProps.children,Pd(e,r),o=Yo(o),n=n(o),e.flags|=1,dn(t,e,n,r),e.child;case 14:return n=e.type,o=si(n,e.pendingProps),o=si(n.type,o),P3(t,e,n,o,r);case 15:return RW(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,o=e.pendingProps,o=e.elementType===n?o:si(n,o),dS(t,e),e.tag=1,Un(n)?(t=!0,$w(e)):t=!1,Pd(e,r),kW(e,n,o),m_(e,n,o,r),S_(null,e,n,!0,t,r);case 19:return FW(t,e,r);case 22:return jW(t,e,r)}throw Error(Z(156,e.tag))};function tK(t,e){return _H(t,e)}function Dpe(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ho(t,e,r,n){return new Dpe(t,e,r,n)}function fk(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Lpe(t){if(typeof t=="function")return fk(t)?1:0;if(t!=null){if(t=t.$$typeof,t===OA)return 11;if(t===MA)return 14}return 2}function cl(t,e){var r=t.alternate;return r===null?(r=Ho(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function pS(t,e,r,n,o,i){var s=2;if(n=t,typeof t=="function")fk(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case qu:return $c(r.children,o,i,e);case kA:s=8,o|=8;break;case BC:return t=Ho(12,r,e,o|2),t.elementType=BC,t.lanes=i,t;case UC:return t=Ho(13,r,e,o),t.elementType=UC,t.lanes=i,t;case zC:return t=Ho(19,r,e,o),t.elementType=zC,t.lanes=i,t;case dH:return wx(r,o,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case cH:s=10;break e;case uH:s=9;break e;case OA:s=11;break e;case MA:s=14;break e;case Na:s=16,n=null;break e}throw Error(Z(130,t==null?t:typeof t,""))}return e=Ho(s,r,e,o),e.elementType=t,e.type=n,e.lanes=i,e}function $c(t,e,r,n){return t=Ho(7,t,n,e),t.lanes=r,t}function wx(t,e,r,n){return t=Ho(22,t,n,e),t.elementType=dH,t.lanes=r,t.stateNode={isHidden:!1},t}function I$(t,e,r){return t=Ho(6,t,null,e),t.lanes=r,t}function P$(t,e,r){return e=Ho(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Npe(t,e,r,n,o){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=i$(0),this.expirationTimes=i$(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=i$(0),this.identifierPrefix=n,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function pk(t,e,r,n,o,i,s,a,l){return t=new Npe(t,e,r,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=Ho(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},ZA(i),t}function Fpe(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Xu,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}function rK(t){if(!t)return yl;t=t._reactInternals;e:{if(Jc(t)!==t||t.tag!==1)throw Error(Z(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Un(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(Z(171))}if(t.tag===1){var r=t.type;if(Un(r))return rW(t,r,e)}return e}function nK(t,e,r,n,o,i,s,a,l){return t=pk(r,n,!0,t,o,i,s,a,l),t.context=rK(null),r=t.current,n=pn(),o=ll(r),i=Vs(n,o),i.callback=e??null,sl(r,i,o),t.current.lanes=o,Lg(t,o,n),zn(t,n),t}function xx(t,e,r,n){var o=e.current,i=pn(),s=ll(o);return r=rK(r),e.context===null?e.context=r:e.pendingContext=r,e=Vs(i,s),e.payload={element:t},n=n===void 0?null:n,n!==null&&(e.callback=n),t=sl(o,e,s),t!==null&&(vi(t,o,s,i),lS(t,o,s)),s}function Dw(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function L3(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<e?r:e}}function gk(t,e){L3(t,e),(t=t.alternate)&&L3(t,e)}function Bpe(){return null}var oK=typeof reportError=="function"?reportError:function(t){console.error(t)};function mk(t){this._internalRoot=t}bx.prototype.render=mk.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(Z(409));xx(t,e,null,null)};bx.prototype.unmount=mk.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;Rc(function(){xx(null,t,null,null)}),e[ta]=null}};function bx(t){this._internalRoot=t}bx.prototype.unstable_scheduleHydration=function(t){if(t){var e=jH();t={blockedOn:null,target:t,priority:e};for(var r=0;r<za.length&&e!==0&&e<za[r].priority;r++);za.splice(r,0,t),r===0&&LH(t)}};function vk(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function $x(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function N3(){}function Upe(t,e,r,n,o){if(o){if(typeof n=="function"){var i=n;n=function(){var c=Dw(s);i.call(c)}}var s=nK(e,n,t,0,null,!1,!1,"",N3);return t._reactRootContainer=s,t[ta]=s.current,tg(t.nodeType===8?t.parentNode:t),Rc(),s}for(;o=t.lastChild;)t.removeChild(o);if(typeof n=="function"){var a=n;n=function(){var c=Dw(l);a.call(c)}}var l=pk(t,0,!1,null,null,!1,!1,"",N3);return t._reactRootContainer=l,t[ta]=l.current,tg(t.nodeType===8?t.parentNode:t),Rc(function(){xx(e,l,r,n)}),l}function Ix(t,e,r,n,o){var i=r._reactRootContainer;if(i){var s=i;if(typeof o=="function"){var a=o;o=function(){var l=Dw(s);a.call(l)}}xx(e,s,t,o)}else s=Upe(r,e,t,o,n);return Dw(s)}MH=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var r=qf(e.pendingLanes);r!==0&&(DA(e,r|1),zn(e,Yt()),!(qe&6)&&(Yd=Yt()+500,kl()))}break;case 13:Rc(function(){var n=ra(t,1);if(n!==null){var o=pn();vi(n,t,1,o)}}),gk(t,1)}};LA=function(t){if(t.tag===13){var e=ra(t,134217728);if(e!==null){var r=pn();vi(e,t,134217728,r)}gk(t,134217728)}};RH=function(t){if(t.tag===13){var e=ll(t),r=ra(t,e);if(r!==null){var n=pn();vi(r,t,e,n)}gk(t,e)}};jH=function(){return it};DH=function(t,e){var r=it;try{return it=t,e()}finally{it=r}};QC=function(t,e,r){switch(e){case"input":if(KC(t,r),e=r.name,r.type==="radio"&&e!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<r.length;e++){var n=r[e];if(n!==t&&n.form===t.form){var o=px(n);if(!o)throw Error(Z(90));fH(n),KC(n,o)}}}break;case"textarea":gH(t,r);break;case"select":e=r.value,e!=null&&xd(t,!!r.multiple,e,!1)}};bH=uk;$H=Rc;var zpe={usingClientEntryPoint:!1,Events:[Fg,ed,px,wH,xH,uk]},uf={findFiberByHostInstance:vc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Hpe={bundleType:uf.bundleType,version:uf.version,rendererPackageName:uf.rendererPackageName,rendererConfig:uf.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:fa.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=EH(t),t===null?null:t.stateNode},findFiberByHostInstance:uf.findFiberByHostInstance||Bpe,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gv.isDisabled&&gv.supportsFiber)try{ux=gv.inject(Hpe),rs=gv}catch{}}yo.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zpe;yo.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vk(e))throw Error(Z(200));return Fpe(t,e,null,r)};yo.createRoot=function(t,e){if(!vk(t))throw Error(Z(299));var r=!1,n="",o=oK;return e!=null&&(e.unstable_strictMode===!0&&(r=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(o=e.onRecoverableError)),e=pk(t,1,!1,null,null,r,!1,n,o),t[ta]=e.current,tg(t.nodeType===8?t.parentNode:t),new mk(e)};yo.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(Z(188)):(t=Object.keys(t).join(","),Error(Z(268,t)));return t=EH(e),t=t===null?null:t.stateNode,t};yo.flushSync=function(t){return Rc(t)};yo.hydrate=function(t,e,r){if(!$x(e))throw Error(Z(200));return Ix(null,t,e,!0,r)};yo.hydrateRoot=function(t,e,r){if(!vk(t))throw Error(Z(405));var n=r!=null&&r.hydratedSources||null,o=!1,i="",s=oK;if(r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(s=r.onRecoverableError)),e=nK(e,null,t,1,r??null,o,!1,i,s),t[ta]=e.current,tg(t),n)for(t=0;t<n.length;t++)r=n[t],o=r._getVersion,o=o(r._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[r,o]:e.mutableSourceEagerHydrationData.push(r,o);return new bx(e)};yo.render=function(t,e,r){if(!$x(e))throw Error(Z(200));return Ix(null,t,e,!1,r)};yo.unmountComponentAtNode=function(t){if(!$x(t))throw Error(Z(40));return t._reactRootContainer?(Rc(function(){Ix(null,null,t,!1,function(){t._reactRootContainer=null,t[ta]=null})}),!0):!1};yo.unstable_batchedUpdates=uk;yo.unstable_renderSubtreeIntoContainer=function(t,e,r,n){if(!$x(r))throw Error(Z(200));if(t==null||t._reactInternals===void 0)throw Error(Z(38));return Ix(t,e,r,!1,n)};yo.version="18.3.1-next-f1338f8080-20240426";function iK(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(iK)}catch(t){console.error(t)}}iK(),iH.exports=yo;var oa=iH.exports;const Wpe=_l(oa);var sK,F3=oa;sK=NC.createRoot=F3.createRoot,NC.hydrateRoot=F3.hydrateRoot;function fe(t,e={}){const r=typeof t=="string"?t:t.src;if(typeof e=="function")return e(r);const{baseUrl:n=""}=e;return r.startsWith("data:")||r.match(/^https?:\/\//)?r:`${n.replace(/\/$/,"")}/${r.replace(/^\.?\//,"")}`}function Kpe(t){const e=fe("./icons/icon/0_merged.svg",t);return{fonts:{monospace:fe("./fonts/IBMPlexMono-Medium.woff2",t),sansSerif:fe("./fonts/IBMPlexSans-Medium.woff2",t),serif:fe("./fonts/IBMPlexSerif-Medium.woff2",t),draw:fe("./fonts/Shantell_Sans-Tldrawish.woff2",t)},icons:{"align-bottom":e+"#align-bottom","align-center-horizontal":e+"#align-center-horizontal","align-center-vertical":e+"#align-center-vertical","align-left":e+"#align-left","align-right":e+"#align-right","align-top":e+"#align-top","arrow-left":e+"#arrow-left","arrowhead-arrow":e+"#arrowhead-arrow","arrowhead-bar":e+"#arrowhead-bar","arrowhead-diamond":e+"#arrowhead-diamond","arrowhead-dot":e+"#arrowhead-dot","arrowhead-none":e+"#arrowhead-none","arrowhead-square":e+"#arrowhead-square","arrowhead-triangle-inverted":e+"#arrowhead-triangle-inverted","arrowhead-triangle":e+"#arrowhead-triangle",blob:e+"#blob","bring-forward":e+"#bring-forward","bring-to-front":e+"#bring-to-front",broken:e+"#broken","check-circle":e+"#check-circle",check:e+"#check","chevron-down":e+"#chevron-down","chevron-left":e+"#chevron-left","chevron-right":e+"#chevron-right","chevron-up":e+"#chevron-up","chevrons-ne":e+"#chevrons-ne","chevrons-sw":e+"#chevrons-sw","clipboard-copied":e+"#clipboard-copied","clipboard-copy":e+"#clipboard-copy",color:e+"#color","cross-2":e+"#cross-2","cross-circle":e+"#cross-circle","dash-dashed":e+"#dash-dashed","dash-dotted":e+"#dash-dotted","dash-draw":e+"#dash-draw","dash-solid":e+"#dash-solid",disconnected:e+"#disconnected",discord:e+"#discord","distribute-horizontal":e+"#distribute-horizontal","distribute-vertical":e+"#distribute-vertical",dot:e+"#dot","dots-horizontal":e+"#dots-horizontal","dots-vertical":e+"#dots-vertical","drag-handle-dots":e+"#drag-handle-dots",duplicate:e+"#duplicate",edit:e+"#edit","external-link":e+"#external-link","fill-fill":e+"#fill-fill","fill-none":e+"#fill-none","fill-pattern":e+"#fill-pattern","fill-semi":e+"#fill-semi","fill-solid":e+"#fill-solid",follow:e+"#follow",following:e+"#following","font-draw":e+"#font-draw","font-mono":e+"#font-mono","font-sans":e+"#font-sans","font-serif":e+"#font-serif","geo-arrow-down":e+"#geo-arrow-down","geo-arrow-left":e+"#geo-arrow-left","geo-arrow-right":e+"#geo-arrow-right","geo-arrow-up":e+"#geo-arrow-up","geo-check-box":e+"#geo-check-box","geo-cloud":e+"#geo-cloud","geo-diamond":e+"#geo-diamond","geo-ellipse":e+"#geo-ellipse","geo-heart":e+"#geo-heart","geo-hexagon":e+"#geo-hexagon","geo-octagon":e+"#geo-octagon","geo-oval":e+"#geo-oval","geo-pentagon":e+"#geo-pentagon","geo-rectangle":e+"#geo-rectangle","geo-rhombus-2":e+"#geo-rhombus-2","geo-rhombus":e+"#geo-rhombus","geo-star":e+"#geo-star","geo-trapezoid":e+"#geo-trapezoid","geo-triangle":e+"#geo-triangle","geo-x-box":e+"#geo-x-box",github:e+"#github",group:e+"#group","horizontal-align-end":e+"#horizontal-align-end","horizontal-align-middle":e+"#horizontal-align-middle","horizontal-align-start":e+"#horizontal-align-start","info-circle":e+"#info-circle",leading:e+"#leading",link:e+"#link",lock:e+"#lock",menu:e+"#menu",minus:e+"#minus",mixed:e+"#mixed",pack:e+"#pack",plus:e+"#plus","question-mark-circle":e+"#question-mark-circle","question-mark":e+"#question-mark",redo:e+"#redo","reset-zoom":e+"#reset-zoom","rotate-ccw":e+"#rotate-ccw","rotate-cw":e+"#rotate-cw","send-backward":e+"#send-backward","send-to-back":e+"#send-to-back","share-1":e+"#share-1","size-extra-large":e+"#size-extra-large","size-large":e+"#size-large","size-medium":e+"#size-medium","size-small":e+"#size-small","spline-cubic":e+"#spline-cubic","spline-line":e+"#spline-line","stack-horizontal":e+"#stack-horizontal","stack-vertical":e+"#stack-vertical","status-offline":e+"#status-offline","stretch-horizontal":e+"#stretch-horizontal","stretch-vertical":e+"#stretch-vertical","text-align-center":e+"#text-align-center","text-align-left":e+"#text-align-left","text-align-right":e+"#text-align-right","toggle-off":e+"#toggle-off","toggle-on":e+"#toggle-on","tool-arrow":e+"#tool-arrow","tool-eraser":e+"#tool-eraser","tool-frame":e+"#tool-frame","tool-hand":e+"#tool-hand","tool-highlight":e+"#tool-highlight","tool-laser":e+"#tool-laser","tool-line":e+"#tool-line","tool-media":e+"#tool-media","tool-note":e+"#tool-note","tool-pencil":e+"#tool-pencil","tool-pointer":e+"#tool-pointer","tool-screenshot":e+"#tool-screenshot","tool-text":e+"#tool-text",trash:e+"#trash",twitter:e+"#twitter",undo:e+"#undo",ungroup:e+"#ungroup",unlock:e+"#unlock","vertical-align-end":e+"#vertical-align-end","vertical-align-middle":e+"#vertical-align-middle","vertical-align-start":e+"#vertical-align-start","warning-triangle":e+"#warning-triangle","zoom-in":e+"#zoom-in","zoom-out":e+"#zoom-out"},translations:{ar:fe("./translations/ar.json",t),ca:fe("./translations/ca.json",t),cs:fe("./translations/cs.json",t),da:fe("./translations/da.json",t),de:fe("./translations/de.json",t),en:fe("./translations/en.json",t),es:fe("./translations/es.json",t),fa:fe("./translations/fa.json",t),fi:fe("./translations/fi.json",t),fr:fe("./translations/fr.json",t),gl:fe("./translations/gl.json",t),he:fe("./translations/he.json",t),"hi-in":fe("./translations/hi-in.json",t),hr:fe("./translations/hr.json",t),hu:fe("./translations/hu.json",t),id:fe("./translations/id.json",t),it:fe("./translations/it.json",t),ja:fe("./translations/ja.json",t),"ko-kr":fe("./translations/ko-kr.json",t),ku:fe("./translations/ku.json",t),languages:fe("./translations/languages.json",t),main:fe("./translations/main.json",t),my:fe("./translations/my.json",t),ne:fe("./translations/ne.json",t),no:fe("./translations/no.json",t),pl:fe("./translations/pl.json",t),"pt-br":fe("./translations/pt-br.json",t),"pt-pt":fe("./translations/pt-pt.json",t),ro:fe("./translations/ro.json",t),ru:fe("./translations/ru.json",t),sl:fe("./translations/sl.json",t),sv:fe("./translations/sv.json",t),te:fe("./translations/te.json",t),th:fe("./translations/th.json",t),tr:fe("./translations/tr.json",t),uk:fe("./translations/uk.json",t),vi:fe("./translations/vi.json",t),"zh-cn":fe("./translations/zh-cn.json",t),"zh-tw":fe("./translations/zh-tw.json",t)},embedIcons:{codepen:fe("./embed-icons/codepen.png",t),codesandbox:fe("./embed-icons/codesandbox.png",t),desmos:fe("./embed-icons/desmos.png",t),excalidraw:fe("./embed-icons/excalidraw.png",t),felt:fe("./embed-icons/felt.png",t),figma:fe("./embed-icons/figma.png",t),github_gist:fe("./embed-icons/github_gist.png",t),google_calendar:fe("./embed-icons/google_calendar.png",t),google_maps:fe("./embed-icons/google_maps.png",t),google_slides:fe("./embed-icons/google_slides.png",t),observable:fe("./embed-icons/observable.png",t),replit:fe("./embed-icons/replit.png",t),scratch:fe("./embed-icons/scratch.png",t),spotify:fe("./embed-icons/spotify.png",t),tldraw:fe("./embed-icons/tldraw.png",t),val_town:fe("./embed-icons/val_town.png",t),vimeo:fe("./embed-icons/vimeo.png",t),youtube:fe("./embed-icons/youtube.png",t)}}}const E$="__TLDRAW_LIBRARY_VERSIONS__";function Gpe(){if(globalThis[E$])return globalThis[E$];const t={versions:[],didWarn:!1,scheduledNotice:null};return Object.defineProperty(globalThis,E$,{value:t,writable:!1,configurable:!1,enumerable:!1}),t}function Ol(t,e,r){if(!t||!e||!r)throw new Error("Missing name/version/module system in built version of tldraw library");const n=Gpe();n.versions.push({name:t,version:e,modules:r}),n.scheduledNotice||(n.scheduledNotice=setTimeout(()=>{n.scheduledNotice=null,Vpe(n)},100))}function Vpe(t){if(!t.versions.length||t.didWarn)return;const e=t.versions.sort((a,l)=>B3(a.version,l.version)),r=e[e.length-1].version,n=new Set,o=new Map;for(const a of e){if(o.has(a.name)){n.delete(a.name),C$(o,a.name,new Set).add(a.version);continue}a.version===r?n.add(a.name):(n.delete(a.name),C$(o,a.name,new Set).add(a.version))}if(o.size>0){const a=[`${_s("[tldraw]",["bold","bgRed","textWhite"])} ${_s("You have multiple versions of tldraw libraries installed. This can lead to bugs and unexpected behavior.",["textRed","bold"])}`,"",`The latest version you have installed is ${_s(`v${r}`,["bold","textBlue"])}. The following libraries are on the latest version:`,...Array.from(n,l=>` • ✅ ${_s(l,["bold"])}`),"","The following libraries are not on the latest version, or have multiple versions installed:",...Array.from(o,([l,c])=>{const u=Array.from(c).sort(B3).map(d=>_s(`v${d}`,d===r?["textGreen"]:["textRed"]));return` • ❌ ${_s(l,["bold"])} (${u.join(", ")})`})];console.log(a.join(`
|
|
41
|
-
`)),t.didWarn=!0;return}const i=new Map;for(const a of e)C$(i,a.name,{version:a.version,modules:[]}).modules.push(a.modules);const s=new Map;for(const[a,l]of i)l.modules.length>1&&s.set(a,l);if(s.size>0){const a=[`${_s("[tldraw]",["bold","bgRed","textWhite"])} ${_s("You have multiple instances of some tldraw libraries active. This can lead to bugs and unexpected behavior. ",["textRed","bold"])}`,"","This usually means that your bundler is misconfigured, and is importing the same library multiple times - usually once as an ES Module, and once as a CommonJS module.","","The following libraries have been imported multiple times:",...Array.from(s,([l,c])=>{const u=c.modules.map((d,f)=>d==="esm"?` ${f+1}. ES Modules`:` ${f+1}. CommonJS`).join(`
|
|
42
|
-
`);return` • ❌ ${_s(l,["bold"])} v${c.version}:
|
|
43
|
-
${u}`}),"","You should configure your bundler to only import one version of each library."];console.log(a.join(`
|
|
44
|
-
`)),t.didWarn=!0;return}}function B3(t,e){const r=t.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/),n=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/);return!r||!n?t.localeCompare(e):r[1]!==n[1]?Number(r[1])-Number(n[1]):r[2]!==n[2]?Number(r[2])-Number(n[2]):r[3]!==n[3]?Number(r[3])-Number(n[3]):r[4]&&n[4]?r[4].localeCompare(n[4]):r[4]?1:n[4]?-1:0}const Ype={bold:"1",textBlue:"94",textRed:"31",textGreen:"32",bgRed:"41",textWhite:"97"};function _s(t,e=[]){return`\x1B[${e.map(r=>Ype[r]).join(";")}m${t}\x1B[m`}function C$(t,e,r){return t.has(e)?t.get(e):(t.set(e,r),r)}var aK="Expected a function",U3=NaN,Xpe="[object Symbol]",qpe=/^\s+|\s+$/g,Zpe=/^[-+]0x[0-9a-f]+$/i,Qpe=/^0b[01]+$/i,Jpe=/^0o[0-7]+$/i,ege=parseInt,tge=typeof Zr=="object"&&Zr&&Zr.Object===Object&&Zr,rge=typeof self=="object"&&self&&self.Object===Object&&self,nge=tge||rge||Function("return this")(),oge=Object.prototype,ige=oge.toString,sge=Math.max,age=Math.min,_$=function(){return nge.Date.now()};function lge(t,e,r){var n,o,i,s,a,l,c=0,u=!1,d=!1,f=!0;if(typeof t!="function")throw new TypeError(aK);e=z3(e)||0,Lw(r)&&(u=!!r.leading,d="maxWait"in r,i=d?sge(z3(r.maxWait)||0,e):i,f="trailing"in r?!!r.trailing:f);function p(E){var T=n,I=o;return n=o=void 0,c=E,s=t.apply(I,T),s}function g(E){return c=E,a=setTimeout(y,e),u?p(E):s}function m(E){var T=E-l,I=E-c,_=e-T;return d?age(_,i-I):_}function S(E){var T=E-l,I=E-c;return l===void 0||T>=e||T<0||d&&I>=i}function y(){var E=_$();if(S(E))return v(E);a=setTimeout(y,m(E))}function v(E){return a=void 0,f&&n?p(E):(n=o=void 0,s)}function b(){a!==void 0&&clearTimeout(a),c=0,n=l=o=a=void 0}function $(){return a===void 0?s:v(_$())}function P(){var E=_$(),T=S(E);if(n=arguments,o=this,l=E,T){if(a===void 0)return g(l);if(d)return a=setTimeout(y,e),p(l)}return a===void 0&&(a=setTimeout(y,e)),s}return P.cancel=b,P.flush=$,P}function cge(t,e,r){var n=!0,o=!0;if(typeof t!="function")throw new TypeError(aK);return Lw(r)&&(n="leading"in r?!!r.leading:n,o="trailing"in r?!!r.trailing:o),lge(t,e,{leading:n,maxWait:e,trailing:o})}function Lw(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function uge(t){return!!t&&typeof t=="object"}function dge(t){return typeof t=="symbol"||uge(t)&&ige.call(t)==Xpe}function z3(t){if(typeof t=="number")return t;if(dge(t))return U3;if(Lw(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Lw(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=t.replace(qpe,"");var r=Qpe.test(t);return r||Jpe.test(t)?ege(t.slice(2),r?2:8):Zpe.test(t)?U3:+t}var hge=cge;const lK=_l(hge);var fge=200,yk="__lodash_hash_undefined__",pge=1/0,gge="[object Function]",mge="[object GeneratorFunction]",vge=/[\\^$.*+?()[\]{}|]/g,yge=/^\[object .+?Constructor\]$/,Sge=typeof Zr=="object"&&Zr&&Zr.Object===Object&&Zr,wge=typeof self=="object"&&self&&self.Object===Object&&self,Sk=Sge||wge||Function("return this")();function xge(t,e){var r=t?t.length:0;return!!r&&$ge(t,e,0)>-1}function bge(t,e,r,n){for(var o=t.length,i=r+-1;++i<o;)if(e(t[i],i,t))return i;return-1}function $ge(t,e,r){if(e!==e)return bge(t,Ige,r);for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}function Ige(t){return t!==t}function Pge(t,e){return t.has(e)}function Ege(t,e){return t==null?void 0:t[e]}function Cge(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function cK(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var _ge=Array.prototype,Tge=Function.prototype,uK=Object.prototype,T$=Sk["__core-js_shared__"],H3=function(){var t=/[^.]+$/.exec(T$&&T$.keys&&T$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),dK=Tge.toString,wk=uK.hasOwnProperty,Age=uK.toString,kge=RegExp("^"+dK.call(wk).replace(vge,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oge=_ge.splice,Mge=xk(Sk,"Map"),A$=xk(Sk,"Set"),ug=xk(Object,"create");function jc(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Rge(){this.__data__=ug?ug(null):{}}function jge(t){return this.has(t)&&delete this.__data__[t]}function Dge(t){var e=this.__data__;if(ug){var r=e[t];return r===yk?void 0:r}return wk.call(e,t)?e[t]:void 0}function Lge(t){var e=this.__data__;return ug?e[t]!==void 0:wk.call(e,t)}function Nge(t,e){var r=this.__data__;return r[t]=ug&&e===void 0?yk:e,this}jc.prototype.clear=Rge;jc.prototype.delete=jge;jc.prototype.get=Dge;jc.prototype.has=Lge;jc.prototype.set=Nge;function xh(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Fge(){this.__data__=[]}function Bge(t){var e=this.__data__,r=Px(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Oge.call(e,r,1),!0}function Uge(t){var e=this.__data__,r=Px(e,t);return r<0?void 0:e[r][1]}function zge(t){return Px(this.__data__,t)>-1}function Hge(t,e){var r=this.__data__,n=Px(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}xh.prototype.clear=Fge;xh.prototype.delete=Bge;xh.prototype.get=Uge;xh.prototype.has=zge;xh.prototype.set=Hge;function bh(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Wge(){this.__data__={hash:new jc,map:new(Mge||xh),string:new jc}}function Kge(t){return Ex(this,t).delete(t)}function Gge(t){return Ex(this,t).get(t)}function Vge(t){return Ex(this,t).has(t)}function Yge(t,e){return Ex(this,t).set(t,e),this}bh.prototype.clear=Wge;bh.prototype.delete=Kge;bh.prototype.get=Gge;bh.prototype.has=Vge;bh.prototype.set=Yge;function Nw(t){var e=-1,r=t?t.length:0;for(this.__data__=new bh;++e<r;)this.add(t[e])}function Xge(t){return this.__data__.set(t,yk),this}function qge(t){return this.__data__.has(t)}Nw.prototype.add=Nw.prototype.push=Xge;Nw.prototype.has=qge;function Px(t,e){for(var r=t.length;r--;)if(ome(t[r][0],e))return r;return-1}function Zge(t){if(!hK(t)||tme(t))return!1;var e=ime(t)||Cge(t)?kge:yge;return e.test(rme(t))}function Qge(t,e,r){var n=-1,o=xge,i=t.length,s=!0,a=[],l=a;if(i>=fge){var c=Jge(t);if(c)return cK(c);s=!1,o=Pge,l=new Nw}else l=a;e:for(;++n<i;){var u=t[n],d=u;if(u=u!==0?u:0,s&&d===d){for(var f=l.length;f--;)if(l[f]===d)continue e;a.push(u)}else o(l,d,r)||(l!==a&&l.push(d),a.push(u))}return a}var Jge=A$&&1/cK(new A$([,-0]))[1]==pge?function(t){return new A$(t)}:sme;function Ex(t,e){var r=t.__data__;return eme(e)?r[typeof e=="string"?"string":"hash"]:r.map}function xk(t,e){var r=Ege(t,e);return Zge(r)?r:void 0}function eme(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function tme(t){return!!H3&&H3 in t}function rme(t){if(t!=null){try{return dK.call(t)}catch{}try{return t+""}catch{}}return""}function nme(t){return t&&t.length?Qge(t):[]}function ome(t,e){return t===e||t!==t&&e!==e}function ime(t){var e=hK(t)?Age.call(t):"";return e==gge||e==mge}function hK(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function sme(){}var ame=nme;const lme=_l(ame),Qf={Good:"#40C057",Mid:"#FFC078",Poor:"#E03131"},cme=Qf.Good;class fK{constructor(){C(this,"startTime",0);C(this,"name","");C(this,"frames",0);C(this,"started",!1);C(this,"frame",null);C(this,"recordFrame",()=>{this.frames++,this.started&&(this.frame=requestAnimationFrame(this.recordFrame))})}start(e){this.name=e,this.frames=0,this.started=!0,this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(this.recordFrame),this.startTime=performance.now()}stop(){this.started=!1,this.frame!==null&&cancelAnimationFrame(this.frame);const e=(performance.now()-this.startTime)/1e3,r=e===0?0:Math.floor(this.frames/e),n=r>55?Qf.Good:r>30?Qf.Mid:Qf.Poor,o=n===Qf.Mid?"black":"white",i=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${i} %c${r}%c fps`,`color: white; background: ${cme};padding: 2px;border-radius: 3px;`,"font-weight: normal",`font-weight: bold; padding: 2px; background: ${n};color: ${o};`,"font-weight: normal")}isStarted(){return this.started}}function bk(t,e){const r=[];e:for(const n of t){for(const o of r)if(e?e(n,o):n===o)continue e;r.push(n)}return r}function Ae(t){return t.filter(e=>e!=null)}function Cr(t){return t[t.length-1]}function ume(t,e){let r,n=1/0;for(const o of t){const i=e(o);i<n&&(r=o,n=i)}return r}function dme(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!Object.is(t[r],e[r]))return!1;return!0}function pK(t){const e=(...r)=>{try{return t(...r)}catch(n){throw n instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(n,e),n}};return e}const dg=()=>{},hn={ok(t){return{ok:!0,value:t}},err(t){return{ok:!1,error:t}}};function dr(t,e){const r=e&&t&&typeof t=="object"&&e in t?t[e]:t;throw new Error(`Unknown switch case ${r}`)}const Qe=pK((t,e)=>{if(!t)throw new Error(e||"Assertion Error")}),ro=pK((t,e)=>{if(t==null)throw new Error(e??"value must be defined");return t});function $k(){let t,e;const r=new Promise((n,o)=>{t=n,e=o});return Object.assign(r,{resolve:t,reject:e})}function k_(t){return new Promise(e=>setTimeout(e,t))}function lo(...t){if(t.length===2){const[e,r]=t;r.addInitializer(function(){Qe(Reflect.isExtensible(this),"Cannot bind to a non-extensible class.");const o=e.bind(this),i=Reflect.defineProperty(this,r.name,{value:o,writable:!0,configurable:!0});Qe(i,"Cannot bind a non-configurable class method.")})}else{const[e,r,n]=t;if(!n||typeof n.value!="function")throw new TypeError(`Only methods can be decorated with @bind. <${r}> is not a method!`);return{configurable:!0,get(){const o=n.value.bind(this);return Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0}),o}}}}class ls{constructor(){C(this,"items",new WeakMap)}get(e,r){return this.items.has(e)||this.items.set(e,r(e)),this.items.get(e)}}function Ik(t,e){let r;const n=(...o)=>(r||(r={},r.promise=new Promise((i,s)=>{r.resolve=i,r.reject=s})),clearTimeout(r.timeout),r.latestArgs=o,r.timeout=setTimeout(()=>{const i=r;r=void 0;try{i.resolve(t(...i.latestArgs))}catch(s){i.reject(s)}},e),r.promise);return n.cancel=()=>{r&&clearTimeout(r.timeout)},n}const W3=new WeakMap;function Pk(t,e){if(typeof t!="object"||t===null)return;let r=W3.get(t);r||(r={tags:{},extras:{}},W3.set(t,r)),e.tags&&(r.tags={...r.tags,...e.tags}),e.extras&&(r.extras={...r.extras,...e.extras})}async function xi(t,e){return window.fetch(t,{referrerPolicy:"strict-origin-when-cross-origin",...e})}const hg=(t,e)=>{const r=new window.Image(t,e);return r.referrerPolicy="strict-origin-when-cross-origin",r};class Ys{static async dataUrlToArrayBuffer(e){return xi(e).then(function(r){return r.arrayBuffer()})}static async blobToDataUrl(e){return await new Promise((r,n)=>{if(e){const o=new FileReader;o.onload=()=>r(o.result),o.onerror=i=>n(i),o.onabort=i=>n(i),o.readAsDataURL(e)}})}static async blobToText(e){return await new Promise((r,n)=>{if(e){const o=new FileReader;o.onload=()=>r(o.result),o.onerror=i=>n(i),o.onabort=i=>n(i),o.readAsText(e)}})}}function O_(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e+""}function K3(t){const e=new DataView(t);let r=0;for(let n=0;n<e.byteLength;n++)r=(r<<5)-r+e.getUint8(n),r|=0;return r+""}/*!
|
|
45
|
-
* MIT License: https://github.com/ai/nanoid/blob/main/LICENSE
|
|
46
|
-
* Modified code originally from <https://github.com/ai/nanoid>
|
|
47
|
-
* Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
|
48
|
-
*
|
|
49
|
-
* `nanoid` is currently only distributed as an ES module. Some tools (jest, playwright) don't
|
|
50
|
-
* properly support ESM-only code yet, and tldraw itself is distributed as both an ES module and a
|
|
51
|
-
* CommonJS module. By including nanoid here, we can make sure it works well in every environment
|
|
52
|
-
* where tldraw is used. We can also remove some unused features like custom alphabets.
|
|
53
|
-
*/const G3=globalThis.crypto,hme="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",fme=128;let pc,ad;function pme(t){!pc||pc.length<t?(pc=new Uint8Array(t*fme),G3.getRandomValues(pc),ad=0):ad+t>pc.length&&(G3.getRandomValues(pc),ad=0),ad+=t}function gme(t=21){pme(t-=0);let e="";for(let r=ad-t;r<ad;r++)e+=hme[pc[r]&63];return e}let mme=gme;function ct(t){return mme(t)}/*!
|
|
54
|
-
* MIT License: https://github.com/vHeemstra/is-apng/blob/main/license
|
|
55
|
-
* Copyright (c) Philip van Heemstra
|
|
56
|
-
*/function vme(t){const e=new Uint8Array(t);if(!e||!(typeof Buffer<"u"&&Buffer.isBuffer(e)||e instanceof Uint8Array)||e.length<16||!(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10))return!1;function n(i,s,a,l,c=1024){if(!s)return-1;s=new RegExp(s,"g");const u=s.source.length,d=new TextDecoder,f=i.length;if(typeof l>"u"&&(l=f),a>=f||l<=0||a>=l)return-1;i=i.subarray(a,l);let p=-1,g=0,m=0,S="";e:for(;g<i.length;){const y=g+c,v=i.subarray(g,y),b=d.decode(v,{stream:!0}),$=S+b;let P,E=-1;for(;(P=s.exec($))!==null;){E=P.index-S.length,p=m+E;break e}g=y,m+=b.length;const T=E>-1?E+u:b.length-u;S=b.slice(T)}return p>=0&&(p+=a>=0?a:f+a),p}const o=n(e,"IDAT",12);return o>=12?n(e,"acTL",8,o)>=8:!1}const yme=t=>new Uint8Array(t)[3]===44;/*!
|
|
57
|
-
* MIT License
|
|
58
|
-
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
59
|
-
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
60
|
-
*/function V3(t,e){let r=0;for(;t[e+r];)r+=t[e+r]+1;return r+1}function Sme(t){return new TextDecoder("ascii").decode(t.slice(0,3))==="GIF"}function wme(t){const e=new Uint8Array(t);let r,n,o=0,i=0;if(!Sme(t))return!1;for(r=e[10]&128,n=e[10]&7,o+=6,o+=7,o+=r?3*Math.pow(2,n+1):0;i<2&&o<e.length;)switch(e[o]){case 44:i+=1,r=e[o+9]&128,n=e[o+9]&7,o+=10,o+=r?3*Math.pow(2,n+1):0,o+=V3(e,o+1)+1;break;case 33:o+=2,o+=V3(e,o);break;case 59:o=e.length;break;default:o=e.length;break}return i>1}/*!
|
|
61
|
-
* MIT License: https://github.com/alexgorbatchev/crc/blob/master/LICENSE
|
|
62
|
-
* Copyright: 2014 Alex Gorbatchev
|
|
63
|
-
* Code: crc32, https://github.com/alexgorbatchev/crc/blob/master/src/calculators/crc32.ts
|
|
64
|
-
*/let M_=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(M_=new Int32Array(M_));const xme=(t,e)=>{let r=~~e^-1;for(let n=0;n<t.length;n++)r=M_[(r^t[n])&255]^r>>>8;return r^-1},Y3=4,X3=4;class Vi{static isPng(e,r){return e.getUint8(r+0)===137&&e.getUint8(r+1)===80&&e.getUint8(r+2)===78&&e.getUint8(r+3)===71&&e.getUint8(r+4)===13&&e.getUint8(r+5)===10&&e.getUint8(r+6)===26&&e.getUint8(r+7)===10}static getChunkType(e,r){return[String.fromCharCode(e.getUint8(r)),String.fromCharCode(e.getUint8(r+1)),String.fromCharCode(e.getUint8(r+2)),String.fromCharCode(e.getUint8(r+3))].join("")}static readChunks(e,r=0){const n={};if(!Vi.isPng(e,r))throw new Error("Not a PNG");for(r+=8;r<=e.buffer.byteLength;){const o=r,i=e.getInt32(r);r+=4;const s=Vi.getChunkType(e,r);if(s==="IDAT"&&n[s]){r+=i+Y3+X3;continue}if(s==="IEND")break;n[s]={start:o,dataOffset:r+4,size:i},r+=i+Y3+X3}return n}static parsePhys(e,r){return{ppux:e.getUint32(r),ppuy:e.getUint32(r+4),unit:e.getUint8(r+4)}}static findChunk(e,r){return Vi.readChunks(e)[r]}static setPhysChunk(e,r=1,n){let o=46,i=0;const s=Vi.findChunk(e,"pHYs");s&&(o=s.start,i=s.size);const a=Vi.findChunk(e,"IDAT");a&&(o=a.start,i=0);const l=new ArrayBuffer(21),c=new DataView(l);c.setUint32(0,9),c.setUint8(4,112),c.setUint8(5,72),c.setUint8(6,89),c.setUint8(7,115);const u=2835.5;c.setInt32(8,u*r),c.setInt32(12,u*r),c.setInt8(16,1);const d=new Uint8Array(l.slice(4,17));c.setInt32(17,xme(d));const f=e.buffer.slice(0,o),p=e.buffer.slice(o+i);return new Blob([f,l,p],n)}}/*!
|
|
65
|
-
* MIT License: https://github.com/sindresorhus/is-webp/blob/main/license
|
|
66
|
-
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
67
|
-
*/function bme(t){return!t||t.length<12?!1:t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}function $me(t){const e=new Uint8Array(t);return!bme(e)||!e||e.length<21?!1:(e[20]>>1&1)===1}const gK=Object.freeze(["image/svg+xml"]),mK=Object.freeze(["image/jpeg","image/png","image/webp"]),vK=Object.freeze(["image/gif","image/apng","image/avif"]),Cx=Object.freeze([...mK,...gK,...vK]),Ek=Object.freeze(["video/mp4","video/webm","video/quicktime"]),Ime=[...Cx,...Ek].join(",");class io{static loadVideo(e){return new Promise((r,n)=>{const o=document.createElement("video");o.onloadeddata=()=>r(o),o.onerror=i=>{console.error(i),n(new Error("Could not load video"))},o.crossOrigin="anonymous",o.src=e})}static async getVideoFrameAsDataUrl(e,r=0){const n=$k();let o=!1;const i=()=>{if(!o)if(e.readyState>=e.HAVE_METADATA)o=!0,e.currentTime=r;else return;if(e.readyState>=e.HAVE_CURRENT_DATA){const a=document.createElement("canvas");a.width=e.videoWidth,a.height=e.videoHeight;const l=a.getContext("2d");if(!l)throw new Error("Could not get 2d context");l.drawImage(e,0,0),n.resolve(a.toDataURL())}},s=a=>{console.error(a),n.reject(new Error("Could not get video frame"))};e.addEventListener("loadedmetadata",i),e.addEventListener("loadeddata",i),e.addEventListener("canplay",i),e.addEventListener("seeked",i),e.addEventListener("error",s),e.addEventListener("stalled",s),i();try{return await n}finally{e.removeEventListener("loadedmetadata",i),e.removeEventListener("loadeddata",i),e.removeEventListener("canplay",i),e.removeEventListener("seeked",i),e.removeEventListener("error",s),e.removeEventListener("stalled",s)}}static loadImage(e){return new Promise((r,n)=>{const o=hg();o.onload=()=>r(o),o.onerror=i=>{console.error(i),n(new Error("Could not load image"))},o.crossOrigin="anonymous",o.referrerPolicy="strict-origin-when-cross-origin",o.src=e})}static async getVideoSize(e){return io.usingObjectURL(e,async r=>{const n=await io.loadVideo(r);return{w:n.videoWidth,h:n.videoHeight}})}static async getImageSize(e){const r=await io.usingObjectURL(e,io.loadImage);try{if(e.type==="image/png"){const n=new DataView(await e.arrayBuffer());if(Vi.isPng(n,0)){const o=Vi.findChunk(n,"pHYs");if(o){const i=Vi.parsePhys(n,o.dataOffset);if(i.unit===0&&i.ppux===i.ppuy){const s=Math.max(i.ppux/2834.5,1);return{w:Math.round(r.naturalWidth/s),h:Math.round(r.naturalHeight/s)}}}}}}catch(n){return console.error(n),{w:r.naturalWidth,h:r.naturalHeight}}return{w:r.naturalWidth,h:r.naturalHeight}}static async isAnimated(e){return e.type==="image/gif"?wme(await e.arrayBuffer()):e.type==="image/avif"?yme(await e.arrayBuffer()):e.type==="image/webp"?$me(await e.arrayBuffer()):e.type==="image/apng"?vme(await e.arrayBuffer()):!1}static isAnimatedImageType(e){return vK.includes(e||"")}static isStaticImageType(e){return mK.includes(e||"")}static isVectorImageType(e){return gK.includes(e||"")}static isImageType(e){return Cx.includes(e)}static async usingObjectURL(e,r){const n=URL.createObjectURL(e);try{return await r(n)}finally{URL.revokeObjectURL(n)}}}function He(t,e,r){return t+(e-t)*r}function Ei(t=""){let e=0,r=0,n=0,o=0;function i(){const s=e^e<<11;return e=r,r=n,n=o,o^=(o>>>19^s^s>>>8)>>>0,o/4294967296*2}for(let s=0;s<t.length+64;s++)e^=t.charCodeAt(s)|0,i();return i}function Xd(t,e,r,n=!1){const[o,i]=e,[s,a]=r,l=s+(t-o)/(i-o)*(a-s);return n?s<a?Math.max(Math.min(l,a),s):Math.max(Math.min(l,s),a):l}function yi(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Dn(t,e){if(yi(t,e))return t[e]}function q3(t){return Object.keys(t)}function Rt(t){return Object.values(t)}function Hn(t){return Object.entries(t)}function yK(t){return Object.fromEntries(t)}function Cp(t,e){const r={};let n=!1;for(const[o,i]of Hn(t))e(o,i)?r[o]=i:n=!0;return n?r:t}function Ug(t,e){const r={};for(const[n,o]of Hn(t)){const i=e(n,o);r[n]=i}return r}function SK(t,e){if(t===e)return!0;const r=new Set(Object.keys(t)),n=new Set(Object.keys(e));if(r.size!==n.size)return!1;for(const o of r)if(!n.has(o)||!Object.is(t[o],e[o]))return!1;return!0}function Pme(t){const e=Eme(t.chars),r=Cme(e,t.firstPositive,t.mostPositive,t.mostNegative),n=t.jitterRange??Math.floor(Math.pow(e.length,3)/5),o=_me(n,e.length);return{chars:t.chars,byChar:e.byChar,byCode:e.byCode,length:e.length,first:e.byCode[0],last:e.byCode[e.length-1],firstPositive:r.firstPositive,mostPositive:r.mostPositive,firstNegative:r.firstNegative,mostNegative:r.mostNegative,jitterRange:n,paddingDict:o}}function Eme(t){const e={},r={},n=t.length;for(let o=0;o<n;o++){const i=t[o];e[o]=i,r[i]=o}return{byCode:e,byChar:r,length:n}}function Cme(t,e,r,n){const o=e?t.byChar[e]:Math.ceil(t.length/2),i=r?t.byChar[r]:t.length-1,s=n?t.byChar[n]:0;if(o===void 0||i===void 0||s===void 0)throw new Error("invalid charSet");if(i-o<3)throw new Error("mostPositive must be at least 3 characters away from neutral");if(o-s<3)throw new Error("mostNegative must be at least 3 characters away from neutral");return{firstPositive:t.byCode[o],mostPositive:t.byCode[i],firstNegative:t.byCode[o-1],mostNegative:t.byCode[s]}}function _me(t,e){const r={};for(let n=0;n<100&&(r[n]=Math.pow(e,n),!(r[n]>t));n++);return r}var k$=null;function Ck(){return k$||(k$=Pme({chars:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",firstPositive:"a",mostPositive:"z",mostNegative:"A"}))}function Xa(t,e,r){const n=r.byChar[t],o=r.byChar[e];return Math.abs(n-o)}function _k(t,e){const r=t[0];if(r>e.mostPositive||r<e.mostNegative)throw new Error("invalid firstChar on key");return r===e.mostPositive?Xa(r,e.firstPositive,e)+1+Fw(t.slice(1),"positive",e):r===e.mostNegative?Xa(r,e.firstNegative,e)+1+Fw(t.slice(1),"negative",e):r>=e.firstPositive?Xa(r,e.firstPositive,e)+2:Xa(r,e.firstNegative,e)+2}function Fw(t,e,r){const n=t[0];if(n>r.mostPositive||n<r.mostNegative)throw new Error("invalid firstChar on key");return n===r.mostPositive&&e==="positive"?Xa(n,r.mostNegative,r)+1+Fw(t.slice(1),e,r):n===r.mostNegative&&e==="negative"?Xa(n,r.mostPositive,r)+1+Fw(t.slice(1),e,r):e==="positive"?Xa(n,r.mostNegative,r)+2:Xa(n,r.mostPositive,r)+2}function _x(t,e,r,n,o){const i=Math.max(t.length,e.length);return r==="start"?[t.padStart(i,n),e.padStart(i,n)]:[t.padEnd(i,n),e.padEnd(i,n)]}function Tme(t,e,r){let[n,o]=_x(t,e,"end",r.first),i=R_(n,o,r);i===1&&(n=n.padEnd(n.length+1,r.first),i=r.length);const s=bK(Math.floor(i/2),r);return Tk(n,s,r)}function R_(t,e,r){const[n,o]=_x(t,e,"end",r.first).sort(),i=wK(o,n,r);return Ame(i,r)}function Tk(t,e,r){const n=r.length,[o,i]=_x(t,e,"start",r.first),s=[];let a=0;for(let l=o.length-1;l>=0;l--){const c=r.byChar[o[l]],u=r.byChar[i[l]],d=c+u+a;a=Math.floor(d/n);const f=d%n;s.unshift(r.byCode[f])}return a>0&&s.unshift(r.byCode[a]),s.join("")}function wK(t,e,r){const n=r.length,[o,i]=_x(t,e,"start",r.first),s=[];let a=0;for(let l=o.length-1;l>=0;l--){let c=r.byChar[o[l]];const u=r.byChar[i[l]]+a;c<u?(a=1,c+=n):a=0;const d=c-u;s.unshift(r.byCode[d])}if(a>0)throw new Error("Subtraction result is negative. Ensure a is greater than or equal to b.");for(;s.length>1&&s[0]===r.byCode[0];)s.shift();return s.join("")}function xK(t,e){return Tk(t,e.byCode[1],e)}function j_(t,e){return wK(t,e.byCode[1],e)}function bK(t,e){if(t===0)return e.byCode[0];let r="";const n=e.length;for(;t>0;)r=e.byCode[t%n]+r,t=Math.floor(t/n);return r}function Ame(t,e){let r=0;const n=t.length,o=e.length;for(let i=0;i<n;i++)r+=e.byChar[t[i]]*Math.pow(o,n-i-1);return r}function kme(t){return t.firstPositive+t.byCode[0]}function Ome(t,e){return _k(t,e)===t.length}function Z3(t,e){Bw(t,e)}function Bw(t,e){const r=PK(t,e),n=_k(r,e);if(n>t.length)throw new Error("invalid order key length: "+t);return t.slice(0,n)}function $K(t,e){if(!Ome(t,e))throw new Error("invalid integer length: "+t)}function IK(t,e){$K(t,e);const[r,n]=EK(t,e);if(n.split("").some(s=>s!==e.byCode[e.length-1])){const s=xK(n,e);return r+s}const i=Rme(r,e);return CK(i,"lower",e)}function Mme(t,e){$K(t,e);const[r,n]=EK(t,e);if(n.split("").some(s=>s!==e.byCode[0])){const s=j_(n,e);return r+s}const i=jme(r,e);return CK(i,"upper",e)}function PK(t,e){let r=0;if(t[0]===e.mostPositive)for(;t[r]===e.mostPositive;)r=r+1;if(t[0]===e.mostNegative)for(;t[r]===e.mostNegative;)r=r+1;return t.slice(0,r+1)}function EK(t,e){const r=PK(t,e),n=t.slice(r.length);return[r,n]}function Rme(t,e){const r=t>=e.firstPositive,n=xK(t,e),o=t[t.length-1]===e.mostPositive,i=n[n.length-1]===e.mostPositive;return r&&i?n+e.mostNegative:!r&&o?t.slice(0,t.length-1):n}function jme(t,e){const r=t>=e.firstPositive,n=t[t.length-1]===e.mostNegative;if(r&&n){const o=t.slice(0,t.length-1);return j_(o,e)}return!r&&n?t+e.mostPositive:j_(t,e)}function CK(t,e,r){const n=_k(t,r),o=e==="upper"?r.byCode[r.length-1]:r.byCode[0];return t+o.repeat(n-t.length)}function _K(t,e){const r=bK(Math.floor(Math.random()*e.jitterRange),e);return Tk(t,r,e)}function Dme(t,e,r){const n=t.padEnd(t.length+e,r.first);return _K(n,r)}function Lme(t,e,r){const n=Bw(t,r),o=IK(n,r);let i=0;if(e!==null){const a=R_(t,e,r);a<r.jitterRange+1&&(i=Math.max(i,Q3(a,r)))}const s=R_(t,o,r);return s<r.jitterRange+1&&(i=Math.max(i,Q3(s,r))),i}function Q3(t,e){const r=e.jitterRange-t,n=Object.entries(e.paddingDict).find(([o,i])=>i>r);return n?parseInt(n[0]):0}function Nme(t,e,r=Ck()){if(t!==null&&Z3(t,r),e!==null&&Z3(e,r),t===null&&e===null)return kme(r);if(t===null){const n=Bw(e,r);return Mme(n,r)}if(e===null){const n=Bw(t,r);return IK(n,r)}if(t>=e)throw new Error(t+" >= "+e);return Tme(t,e,r)}function TK(t,e,r=Ck()){const n=Nme(t,e,r),o=Lme(n,e,r);return o?Dme(n,o,r):_K(n,r)}function AK(t,e,r,n=Ck()){return Fme(t,e,r,n,TK,AK)}function Fme(t,e,r,n,o,i){if(r===0)return[];if(r===1)return[o(t,e,n)];if(e==null){let l=o(t,e,n);const c=[l];for(let u=0;u<r-1;u++)l=o(l,e,n),c.push(l);return c}if(t==null){let l=o(t,e,n);const c=[l];for(let u=0;u<r-1;u++)l=o(t,l,n),c.push(l);return c.reverse(),c}const s=Math.floor(r/2),a=o(t,e,n);return[...i(t,a,s,n),a,...i(a,e,r-s-1,n)]}const $h=AK,kK="a0";function Bme(t){try{TK(t,null)}catch{throw new Error("invalid index: "+t)}}function qd(t,e,r){return $h(t??null,e??null,r)}function O$(t,e){return $h(t??null,null,e)}function fg(t,e){return $h(t??null,e??null,1)[0]}function Xi(t=null){return $h(t,null,1)[0]}function Ume(t=null){return $h(null,t,1)[0]}function pg(t,e="a1"){return[e,...$h(e,null,t)]}function qr(t,e){return t.index<e.index?-1:t.index>e.index?1:0}function zme(t,e){return t.id>e.id?1:-1}function Ak(t){try{return localStorage.getItem(t)}catch{return null}}function kk(t,e){try{localStorage.setItem(t,e)}catch{}}function Hme(){try{localStorage.clear()}catch{}}function OK(t){try{return sessionStorage.getItem(t)}catch{return null}}function Ok(t,e){try{sessionStorage.setItem(t,e)}catch{}}function MK(t){try{sessionStorage.removeItem(t)}catch{}}function Wme(){try{sessionStorage.clear()}catch{}}const Kme=()=>typeof process<"u"&&!1,ld=[],Gme=60,gS=Math.ceil(1e3/Gme);let df,M$=0,D_=0;const Vme=()=>{const t=ld.splice(0,ld.length);for(const e of t)e()};function RK(){if(df)return;const t=Date.now(),e=t-D_;if(M$+e<gS){df=requestAnimationFrame(()=>{df=void 0,RK()});return}df=requestAnimationFrame(()=>{df=void 0,D_=t,M$=Math.min(M$+e-gS,gS*10),Vme()})}let J3=!1;function jK(t){return Kme()?(t(),()=>{}):(ld.includes(t)||(ld.push(t),J3||(J3=!0,D_=Date.now()-gS-1),RK()),()=>{const e=ld.indexOf(t);e>-1&&ld.splice(e,1)})}class Yme{constructor(){C(this,"timeouts",[]);C(this,"intervals",[]);C(this,"rafs",[])}setTimeout(e,r,...n){const o=window.setTimeout(e,r,n);return this.timeouts.push(o),o}setInterval(e,r,...n){const o=window.setInterval(e,r,n);return this.intervals.push(o),o}requestAnimationFrame(e){const r=window.requestAnimationFrame(e);return this.rafs.push(r),r}dispose(){this.timeouts.forEach(e=>clearTimeout(e)),this.intervals.forEach(e=>clearInterval(e)),this.rafs.forEach(e=>cancelAnimationFrame(e)),this.timeouts.length=0,this.intervals.length=0,this.rafs.length=0}}const $e=(t,e)=>{try{return new URL(t,e)}catch{return}};function Xme(t){return t!==void 0}function qme(){return typeof globalThis<"u"&&globalThis.structuredClone?[globalThis.structuredClone,!0]:typeof global<"u"&&global.structuredClone?[global.structuredClone,!0]:typeof window<"u"&&window.structuredClone?[window.structuredClone,!0]:[t=>t&&JSON.parse(JSON.stringify(t)),!1]}const DK=qme(),$t=DK[0];DK[1];const Zme=Object.getPrototypeOf($t({}));Ol("@tldraw/utils","3.0.0","esm");var hf=function(t){return t&&t.Math===Math&&t},te=hf(typeof globalThis=="object"&&globalThis)||hf(typeof window=="object"&&window)||hf(typeof self=="object"&&self)||hf(typeof Zr=="object"&&Zr)||hf(typeof Zr=="object"&&Zr)||function(){return this}()||Function("return this")(),vr={},q=function(t){try{return!!t()}catch{return!0}},Qme=q,ge=!Qme(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Jme=q,zg=!Jme(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),eve=zg,mv=Function.prototype.call,ne=eve?mv.bind(mv):function(){return mv.apply(mv,arguments)},Hg={},LK={}.propertyIsEnumerable,NK=Object.getOwnPropertyDescriptor,tve=NK&&!LK.call({1:2},1);Hg.f=tve?function(e){var r=NK(this,e);return!!r&&r.enumerable}:LK;var wo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},FK=zg,BK=Function.prototype,L_=BK.call,rve=FK&&BK.bind.bind(L_,L_),V=FK?rve:function(t){return function(){return L_.apply(t,arguments)}},UK=V,nve=UK({}.toString),ove=UK("".slice),tn=function(t){return ove(nve(t),8,-1)},ive=V,sve=q,ave=tn,R$=Object,lve=ive("".split),Ml=sve(function(){return!R$("z").propertyIsEnumerable(0)})?function(t){return ave(t)==="String"?lve(t,""):R$(t)}:R$,nr=function(t){return t==null},cve=nr,uve=TypeError,St=function(t){if(cve(t))throw new uve("Can't call method on "+t);return t},dve=Ml,hve=St,or=function(t){return dve(hve(t))},j$=typeof document=="object"&&document.all,Ce=typeof j$>"u"&&j$!==void 0?function(t){return typeof t=="function"||t===j$}:function(t){return typeof t=="function"},fve=Ce,Ie=function(t){return typeof t=="object"?t!==null:fve(t)},D$=te,pve=Ce,gve=function(t){return pve(t)?t:void 0},be=function(t,e){return arguments.length<2?gve(D$[t]):D$[t]&&D$[t][e]},mve=V,rn=mve({}.isPrototypeOf),vve=te,eL=vve.navigator,tL=eL&&eL.userAgent,gs=tL?String(tL):"",zK=te,L$=gs,rL=zK.process,nL=zK.Deno,oL=rL&&rL.versions||nL&&nL.version,iL=oL&&oL.v8,ui,Uw;iL&&(ui=iL.split("."),Uw=ui[0]>0&&ui[0]<4?1:+(ui[0]+ui[1]));!Uw&&L$&&(ui=L$.match(/Edge\/(\d+)/),(!ui||ui[1]>=74)&&(ui=L$.match(/Chrome\/(\d+)/),ui&&(Uw=+ui[1])));var pa=Uw,sL=pa,yve=q,Sve=te,wve=Sve.String,eu=!!Object.getOwnPropertySymbols&&!yve(function(){var t=Symbol("symbol detection");return!wve(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&sL&&sL<41}),xve=eu,HK=xve&&!Symbol.sham&&typeof Symbol.iterator=="symbol",bve=be,$ve=Ce,Ive=rn,Pve=HK,Eve=Object,Rl=Pve?function(t){return typeof t=="symbol"}:function(t){var e=bve("Symbol");return $ve(e)&&Ive(e.prototype,Eve(t))},Cve=String,tu=function(t){try{return Cve(t)}catch{return"Object"}},_ve=Ce,Tve=tu,Ave=TypeError,Pe=function(t){if(_ve(t))return t;throw new Ave(Tve(t)+" is not a function")},kve=Pe,Ove=nr,Qt=function(t,e){var r=t[e];return Ove(r)?void 0:kve(r)},N$=ne,F$=Ce,B$=Ie,Mve=TypeError,WK=function(t,e){var r,n;if(e==="string"&&F$(r=t.toString)&&!B$(n=N$(r,t))||F$(r=t.valueOf)&&!B$(n=N$(r,t))||e!=="string"&&F$(r=t.toString)&&!B$(n=N$(r,t)))return n;throw new Mve("Can't convert object to primitive value")},KK={exports:{}},ir=!1,aL=te,Rve=Object.defineProperty,Mk=function(t,e){try{Rve(aL,t,{value:e,configurable:!0,writable:!0})}catch{aL[t]=e}return e},jve=te,Dve=Mk,lL="__core-js_shared__",cL=KK.exports=jve[lL]||Dve(lL,{});(cL.versions||(cL.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Tx=KK.exports,uL=Tx,jl=function(t,e){return uL[t]||(uL[t]=e||{})},Lve=St,Nve=Object,je=function(t){return Nve(Lve(t))},Fve=V,Bve=je,Uve=Fve({}.hasOwnProperty),ke=Object.hasOwn||function(e,r){return Uve(Bve(e),r)},zve=V,Hve=0,Wve=Math.random(),Kve=zve(1 .toString),ru=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Kve(++Hve+Wve,36)},Gve=te,Vve=jl,dL=ke,Yve=ru,Xve=eu,qve=HK,cd=Gve.Symbol,U$=Vve("wks"),Zve=qve?cd.for||cd:cd&&cd.withoutSetter||Yve,ve=function(t){return dL(U$,t)||(U$[t]=Xve&&dL(cd,t)?cd[t]:Zve("Symbol."+t)),U$[t]},Qve=ne,hL=Ie,fL=Rl,Jve=Qt,eye=WK,tye=ve,rye=TypeError,nye=tye("toPrimitive"),Ax=function(t,e){if(!hL(t)||fL(t))return t;var r=Jve(t,nye),n;if(r){if(e===void 0&&(e="default"),n=Qve(r,t,e),!hL(n)||fL(n))return n;throw new rye("Can't convert object to primitive value")}return e===void 0&&(e="number"),eye(t,e)},oye=Ax,iye=Rl,ga=function(t){var e=oye(t,"string");return iye(e)?e:e+""},sye=te,pL=Ie,N_=sye.document,aye=pL(N_)&&pL(N_.createElement),kx=function(t){return aye?N_.createElement(t):{}},lye=ge,cye=q,uye=kx,GK=!lye&&!cye(function(){return Object.defineProperty(uye("div"),"a",{get:function(){return 7}}).a!==7}),dye=ge,hye=ne,fye=Hg,pye=wo,gye=or,mye=ga,vye=ke,yye=GK,gL=Object.getOwnPropertyDescriptor;vr.f=dye?gL:function(e,r){if(e=gye(e),r=mye(r),yye)try{return gL(e,r)}catch{}if(vye(e,r))return pye(!hye(fye.f,e,r),e[r])};var ut={},Sye=ge,wye=q,VK=Sye&&wye(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),xye=Ie,bye=String,$ye=TypeError,re=function(t){if(xye(t))return t;throw new $ye(bye(t)+" is not an object")},Iye=ge,Pye=GK,Eye=VK,vv=re,mL=ga,Cye=TypeError,z$=Object.defineProperty,_ye=Object.getOwnPropertyDescriptor,H$="enumerable",W$="configurable",K$="writable";ut.f=Iye?Eye?function(e,r,n){if(vv(e),r=mL(r),vv(n),typeof e=="function"&&r==="prototype"&&"value"in n&&K$ in n&&!n[K$]){var o=_ye(e,r);o&&o[K$]&&(e[r]=n.value,n={configurable:W$ in n?n[W$]:o[W$],enumerable:H$ in n?n[H$]:o[H$],writable:!1})}return z$(e,r,n)}:z$:function(e,r,n){if(vv(e),r=mL(r),vv(n),Pye)try{return z$(e,r,n)}catch{}if("get"in n||"set"in n)throw new Cye("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var Tye=ge,Aye=ut,kye=wo,sr=Tye?function(t,e,r){return Aye.f(t,e,kye(1,r))}:function(t,e,r){return t[e]=r,t},YK={exports:{}},F_=ge,Oye=ke,XK=Function.prototype,Mye=F_&&Object.getOwnPropertyDescriptor,Rk=Oye(XK,"name"),Rye=Rk&&(function(){}).name==="something",jye=Rk&&(!F_||F_&&Mye(XK,"name").configurable),Ih={EXISTS:Rk,PROPER:Rye,CONFIGURABLE:jye},Dye=V,Lye=Ce,B_=Tx,Nye=Dye(Function.toString);Lye(B_.inspectSource)||(B_.inspectSource=function(t){return Nye(t)});var Ox=B_.inspectSource,Fye=te,Bye=Ce,vL=Fye.WeakMap,qK=Bye(vL)&&/native code/.test(String(vL)),Uye=jl,zye=ru,yL=Uye("keys"),Mx=function(t){return yL[t]||(yL[t]=zye(t))},Wg={},Hye=qK,ZK=te,Wye=Ie,Kye=sr,G$=ke,V$=Tx,Gye=Mx,Vye=Wg,SL="Object already initialized",U_=ZK.TypeError,Yye=ZK.WeakMap,zw,gg,Hw,Xye=function(t){return Hw(t)?gg(t):zw(t,{})},qye=function(t){return function(e){var r;if(!Wye(e)||(r=gg(e)).type!==t)throw new U_("Incompatible receiver, "+t+" required");return r}};if(Hye||V$.state){var Fi=V$.state||(V$.state=new Yye);Fi.get=Fi.get,Fi.has=Fi.has,Fi.set=Fi.set,zw=function(t,e){if(Fi.has(t))throw new U_(SL);return e.facade=t,Fi.set(t,e),e},gg=function(t){return Fi.get(t)||{}},Hw=function(t){return Fi.has(t)}}else{var xu=Gye("state");Vye[xu]=!0,zw=function(t,e){if(G$(t,xu))throw new U_(SL);return e.facade=t,Kye(t,xu,e),e},gg=function(t){return G$(t,xu)?t[xu]:{}},Hw=function(t){return G$(t,xu)}}var et={set:zw,get:gg,has:Hw,enforce:Xye,getterFor:qye},jk=V,Zye=q,Qye=Ce,yv=ke,z_=ge,Jye=Ih.CONFIGURABLE,eSe=Ox,QK=et,tSe=QK.enforce,rSe=QK.get,wL=String,mS=Object.defineProperty,nSe=jk("".slice),oSe=jk("".replace),iSe=jk([].join),sSe=z_&&!Zye(function(){return mS(function(){},"length",{value:8}).length!==8}),aSe=String(String).split("String"),lSe=YK.exports=function(t,e,r){nSe(wL(e),0,7)==="Symbol("&&(e="["+oSe(wL(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!yv(t,"name")||Jye&&t.name!==e)&&(z_?mS(t,"name",{value:e,configurable:!0}):t.name=e),sSe&&r&&yv(r,"arity")&&t.length!==r.arity&&mS(t,"length",{value:r.arity});try{r&&yv(r,"constructor")&&r.constructor?z_&&mS(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=tSe(t);return yv(n,"source")||(n.source=iSe(aSe,typeof e=="string"?e:"")),t};Function.prototype.toString=lSe(function(){return Qye(this)&&rSe(this).source||eSe(this)},"toString");var Rx=YK.exports,cSe=Ce,uSe=ut,dSe=Rx,hSe=Mk,nt=function(t,e,r,n){n||(n={});var o=n.enumerable,i=n.name!==void 0?n.name:e;if(cSe(r)&&dSe(r,i,n),n.global)o?t[e]=r:hSe(e,r);else{try{n.unsafe?t[e]&&(o=!0):delete t[e]}catch{}o?t[e]=r:uSe.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},Dl={},fSe=Math.ceil,pSe=Math.floor,JK=Math.trunc||function(e){var r=+e;return(r>0?pSe:fSe)(r)},gSe=JK,Et=function(t){var e=+t;return e!==e||e===0?0:gSe(e)},mSe=Et,vSe=Math.max,ySe=Math.min,ms=function(t,e){var r=mSe(t);return r<0?vSe(r+e,0):ySe(r,e)},SSe=Et,wSe=Math.min,xo=function(t){var e=SSe(t);return e>0?wSe(e,9007199254740991):0},xSe=xo,Ke=function(t){return xSe(t.length)},bSe=or,$Se=ms,ISe=Ke,xL=function(t){return function(e,r,n){var o=bSe(e),i=ISe(o);if(i===0)return!t&&-1;var s=$Se(n,i),a;if(t&&r!==r){for(;i>s;)if(a=o[s++],a!==a)return!0}else for(;i>s;s++)if((t||s in o)&&o[s]===r)return t||s||0;return!t&&-1}},Kg={includes:xL(!0),indexOf:xL(!1)},PSe=V,Y$=ke,ESe=or,CSe=Kg.indexOf,_Se=Wg,bL=PSe([].push),eG=function(t,e){var r=ESe(t),n=0,o=[],i;for(i in r)!Y$(_Se,i)&&Y$(r,i)&&bL(o,i);for(;e.length>n;)Y$(r,i=e[n++])&&(~CSe(o,i)||bL(o,i));return o},Dk=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],TSe=eG,ASe=Dk,kSe=ASe.concat("length","prototype");Dl.f=Object.getOwnPropertyNames||function(e){return TSe(e,kSe)};var Gg={};Gg.f=Object.getOwnPropertySymbols;var OSe=be,MSe=V,RSe=Dl,jSe=Gg,DSe=re,LSe=MSe([].concat),Lk=OSe("Reflect","ownKeys")||function(e){var r=RSe.f(DSe(e)),n=jSe.f;return n?LSe(r,n(e)):r},$L=ke,NSe=Lk,FSe=vr,BSe=ut,Ph=function(t,e,r){for(var n=NSe(e),o=BSe.f,i=FSe.f,s=0;s<n.length;s++){var a=n[s];!$L(t,a)&&!(r&&$L(r,a))&&o(t,a,i(e,a))}},USe=q,zSe=Ce,HSe=/#|\.prototype\./,Vg=function(t,e){var r=KSe[WSe(t)];return r===VSe?!0:r===GSe?!1:zSe(e)?USe(e):!!e},WSe=Vg.normalize=function(t){return String(t).replace(HSe,".").toLowerCase()},KSe=Vg.data={},GSe=Vg.NATIVE="N",VSe=Vg.POLYFILL="P",Yg=Vg,Sv=te,YSe=vr.f,XSe=sr,qSe=nt,ZSe=Mk,QSe=Ph,JSe=Yg,A=function(t,e){var r=t.target,n=t.global,o=t.stat,i,s,a,l,c,u;if(n?s=Sv:o?s=Sv[r]||ZSe(r,{}):s=Sv[r]&&Sv[r].prototype,s)for(a in e){if(c=e[a],t.dontCallGetSet?(u=YSe(s,a),l=u&&u.value):l=s[a],i=JSe(n?a:r+(o?".":"#")+a,t.forced),!i&&l!==void 0){if(typeof c==typeof l)continue;QSe(c,l)}(t.sham||l&&l.sham)&&XSe(c,"sham",!0),qSe(s,a,c,t)}},jx={},ewe=eG,twe=Dk,Eh=Object.keys||function(e){return ewe(e,twe)},rwe=ge,nwe=VK,owe=ut,iwe=re,swe=or,awe=Eh;jx.f=rwe&&!nwe?Object.defineProperties:function(e,r){iwe(e);for(var n=swe(r),o=awe(r),i=o.length,s=0,a;i>s;)owe.f(e,a=o[s++],n[a]);return e};var lwe=be,tG=lwe("document","documentElement"),cwe=re,uwe=jx,IL=Dk,dwe=Wg,hwe=tG,fwe=kx,pwe=Mx,PL=">",EL="<",H_="prototype",W_="script",rG=pwe("IE_PROTO"),X$=function(){},nG=function(t){return EL+W_+PL+t+EL+"/"+W_+PL},CL=function(t){t.write(nG("")),t.close();var e=t.parentWindow.Object;return t=null,e},gwe=function(){var t=fwe("iframe"),e="java"+W_+":",r;return t.style.display="none",hwe.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(nG("document.F=Object")),r.close(),r.F},wv,vS=function(){try{wv=new ActiveXObject("htmlfile")}catch{}vS=typeof document<"u"?document.domain&&wv?CL(wv):gwe():CL(wv);for(var t=IL.length;t--;)delete vS[H_][IL[t]];return vS()};dwe[rG]=!0;var ar=Object.create||function(e,r){var n;return e!==null?(X$[H_]=cwe(e),n=new X$,X$[H_]=null,n[rG]=e):n=vS(),r===void 0?n:uwe.f(n,r)},mwe=ve,vwe=ar,ywe=ut.f,K_=mwe("unscopables"),G_=Array.prototype;G_[K_]===void 0&&ywe(G_,K_,{configurable:!0,value:vwe(null)});var Bt=function(t){G_[K_][t]=!0},Swe=A,wwe=je,xwe=Ke,bwe=Et,$we=Bt;Swe({target:"Array",proto:!0},{at:function(e){var r=wwe(this),n=xwe(r),o=bwe(e),i=o>=0?o:n+o;return i<0||i>=n?void 0:r[i]}});$we("at");var Iwe=te,Pwe=V,Xg=function(t,e){return Pwe(Iwe[t].prototype[e])},Ewe=Xg;Ewe("Array","at");var Cwe=tn,vs=Array.isArray||function(e){return Cwe(e)==="Array"},_we=TypeError,Twe=9007199254740991,nu=function(t){if(t>Twe)throw _we("Maximum allowed index exceeded");return t},Awe=tn,kwe=V,Ll=function(t){if(Awe(t)==="Function")return kwe(t)},_L=Ll,Owe=Pe,Mwe=zg,Rwe=_L(_L.bind),dt=function(t,e){return Owe(t),e===void 0?t:Mwe?Rwe(t,e):function(){return t.apply(e,arguments)}},jwe=vs,Dwe=Ke,Lwe=nu,Nwe=dt,oG=function(t,e,r,n,o,i,s,a){for(var l=o,c=0,u=s?Nwe(s,a):!1,d,f;c<n;)c in r&&(d=u?u(r[c],c,e):r[c],i>0&&jwe(d)?(f=Dwe(d),l=oG(t,e,d,f,l,i-1)-1):(Lwe(l+1),t[l]=d),l++),c++;return l},iG=oG,Fwe=ve,Bwe=Fwe("toStringTag"),sG={};sG[Bwe]="z";var Nk=String(sG)==="[object z]",Uwe=Nk,zwe=Ce,yS=tn,Hwe=ve,Wwe=Hwe("toStringTag"),Kwe=Object,Gwe=yS(function(){return arguments}())==="Arguments",Vwe=function(t,e){try{return t[e]}catch{}},bo=Uwe?yS:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=Vwe(e=Kwe(t),Wwe))=="string"?r:Gwe?yS(e):(n=yS(e))==="Object"&&zwe(e.callee)?"Arguments":n},Ywe=V,Xwe=q,aG=Ce,qwe=bo,Zwe=be,Qwe=Ox,lG=function(){},cG=Zwe("Reflect","construct"),Fk=/^\s*(?:class|function)\b/,Jwe=Ywe(Fk.exec),e0e=!Fk.test(lG),ff=function(e){if(!aG(e))return!1;try{return cG(lG,[],e),!0}catch{return!1}},uG=function(e){if(!aG(e))return!1;switch(qwe(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return e0e||!!Jwe(Fk,Qwe(e))}catch{return!0}};uG.sham=!0;var ys=!cG||Xwe(function(){var t;return ff(ff.call)||!ff(Object)||!ff(function(){t=!0})||t})?uG:ff,TL=vs,t0e=ys,r0e=Ie,n0e=ve,o0e=n0e("species"),AL=Array,i0e=function(t){var e;return TL(t)&&(e=t.constructor,t0e(e)&&(e===AL||TL(e.prototype))?e=void 0:r0e(e)&&(e=e[o0e],e===null&&(e=void 0))),e===void 0?AL:e},s0e=i0e,qg=function(t,e){return new(s0e(t))(e===0?0:e)},a0e=A,l0e=iG,c0e=Pe,u0e=je,d0e=Ke,h0e=qg;a0e({target:"Array",proto:!0},{flatMap:function(e){var r=u0e(this),n=d0e(r),o;return c0e(e),o=h0e(r,0),o.length=l0e(o,r,r,n,0,1,e,arguments.length>1?arguments[1]:void 0),o}});var f0e=Bt;f0e("flatMap");var p0e=Xg;p0e("Array","flatMap");var g0e=A,m0e=iG,v0e=je,y0e=Ke,S0e=Et,w0e=qg;g0e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=v0e(this),n=y0e(r),o=w0e(r,0);return o.length=m0e(o,r,r,n,0,e===void 0?1:S0e(e)),o}});var x0e=Bt;x0e("flat");var b0e=Xg;b0e("Array","flat");var $0e=bo,I0e=String,Ee=function(t){if($0e(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return I0e(t)},P0e=A,E0e=V,C0e=St,_0e=Et,T0e=Ee,A0e=q,k0e=E0e("".charAt),O0e=A0e(function(){return"𠮷".at(-2)!=="\uD842"});P0e({target:"String",proto:!0,forced:O0e},{at:function(e){var r=T0e(C0e(this)),n=r.length,o=_0e(e),i=o>=0?o:n+o;return i<0||i>=n?void 0:k0e(r,i)}});var M0e=Xg;M0e("String","at");var R0e=re,Bk=function(){var t=R0e(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},Uk=q,j0e=te,zk=j0e.RegExp,Hk=Uk(function(){var t=zk("a","y");return t.lastIndex=2,t.exec("abcd")!==null}),D0e=Hk||Uk(function(){return!zk("a","y").sticky}),L0e=Hk||Uk(function(){var t=zk("^r","gy");return t.lastIndex=2,t.exec("str")!==null}),Dx={BROKEN_CARET:L0e,MISSED_STICKY:D0e,UNSUPPORTED_Y:Hk},N0e=q,F0e=te,B0e=F0e.RegExp,Wk=N0e(function(){var t=B0e(".","s");return!(t.dotAll&&t.test(`
|
|
68
|
-
`)&&t.flags==="s")}),U0e=q,z0e=te,H0e=z0e.RegExp,dG=U0e(function(){var t=H0e("(?<a>b)","g");return t.exec("b").groups.a!=="b"||"b".replace(t,"$<a>c")!=="bc"}),ud=ne,Lx=V,W0e=Ee,K0e=Bk,G0e=Dx,V0e=jl,Y0e=ar,X0e=et.get,q0e=Wk,Z0e=dG,Q0e=V0e("native-string-replace",String.prototype.replace),Ww=RegExp.prototype.exec,V_=Ww,J0e=Lx("".charAt),exe=Lx("".indexOf),txe=Lx("".replace),q$=Lx("".slice),Y_=function(){var t=/a/,e=/b*/g;return ud(Ww,t,"a"),ud(Ww,e,"a"),t.lastIndex!==0||e.lastIndex!==0}(),hG=G0e.BROKEN_CARET,X_=/()??/.exec("")[1]!==void 0,rxe=Y_||X_||hG||q0e||Z0e;rxe&&(V_=function(e){var r=this,n=X0e(r),o=W0e(e),i=n.raw,s,a,l,c,u,d,f;if(i)return i.lastIndex=r.lastIndex,s=ud(V_,i,o),r.lastIndex=i.lastIndex,s;var p=n.groups,g=hG&&r.sticky,m=ud(K0e,r),S=r.source,y=0,v=o;if(g&&(m=txe(m,"y",""),exe(m,"g")===-1&&(m+="g"),v=q$(o,r.lastIndex),r.lastIndex>0&&(!r.multiline||r.multiline&&J0e(o,r.lastIndex-1)!==`
|
|
69
|
-
`)&&(S="(?: "+S+")",v=" "+v,y++),a=new RegExp("^(?:"+S+")",m)),X_&&(a=new RegExp("^"+S+"$(?!\\s)",m)),Y_&&(l=r.lastIndex),c=ud(Ww,g?a:r,v),g?c?(c.input=q$(c.input,y),c[0]=q$(c[0],y),c.index=r.lastIndex,r.lastIndex+=c[0].length):r.lastIndex=0:Y_&&c&&(r.lastIndex=r.global?c.index+c[0].length:l),X_&&c&&c.length>1&&ud(Q0e,c[0],a,function(){for(u=1;u<arguments.length-2;u++)arguments[u]===void 0&&(c[u]=void 0)}),c&&p)for(c.groups=d=Y0e(null),u=0;u<p.length;u++)f=p[u],d[f[0]]=c[f[1]];return c});var Kk=V_,nxe=A,kL=Kk;nxe({target:"RegExp",proto:!0,forced:/./.exec!==kL},{exec:kL});var oxe=zg,fG=Function.prototype,OL=fG.apply,ML=fG.call,yn=typeof Reflect=="object"&&Reflect.apply||(oxe?ML.bind(OL):function(){return ML.apply(OL,arguments)}),RL=ne,jL=nt,ixe=Kk,DL=q,pG=ve,sxe=sr,axe=pG("species"),Z$=RegExp.prototype,Nx=function(t,e,r,n){var o=pG(t),i=!DL(function(){var c={};return c[o]=function(){return 7},""[t](c)!==7}),s=i&&!DL(function(){var c=!1,u=/a/;return t==="split"&&(u={},u.constructor={},u.constructor[axe]=function(){return u},u.flags="",u[o]=/./[o]),u.exec=function(){return c=!0,null},u[o](""),!c});if(!i||!s||r){var a=/./[o],l=e(o,""[t],function(c,u,d,f,p){var g=u.exec;return g===ixe||g===Z$.exec?i&&!p?{done:!0,value:RL(a,u,d,f)}:{done:!0,value:RL(c,d,u,f)}:{done:!1}});jL(String.prototype,t,l[0]),jL(Z$,o,l[1])}n&&sxe(Z$[o],"sham",!0)},Gk=V,lxe=Et,cxe=Ee,uxe=St,dxe=Gk("".charAt),LL=Gk("".charCodeAt),hxe=Gk("".slice),NL=function(t){return function(e,r){var n=cxe(uxe(e)),o=lxe(r),i=n.length,s,a;return o<0||o>=i?t?"":void 0:(s=LL(n,o),s<55296||s>56319||o+1===i||(a=LL(n,o+1))<56320||a>57343?t?dxe(n,o):s:t?hxe(n,o,o+2):(s-55296<<10)+(a-56320)+65536)}},Ch={codeAt:NL(!1),charAt:NL(!0)},fxe=Ch.charAt,Fx=function(t,e,r){return e+(r?fxe(t,e).length:1)},Vk=V,pxe=je,gxe=Math.floor,Q$=Vk("".charAt),mxe=Vk("".replace),J$=Vk("".slice),vxe=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,yxe=/\$([$&'`]|\d{1,2})/g,gG=function(t,e,r,n,o,i){var s=r+t.length,a=n.length,l=yxe;return o!==void 0&&(o=pxe(o),l=vxe),mxe(i,l,function(c,u){var d;switch(Q$(u,0)){case"$":return"$";case"&":return t;case"`":return J$(e,0,r);case"'":return J$(e,s);case"<":d=o[J$(u,1,-1)];break;default:var f=+u;if(f===0)return c;if(f>a){var p=gxe(f/10);return p===0?c:p<=a?n[p-1]===void 0?Q$(u,1):n[p-1]+Q$(u,1):c}d=n[f-1]}return d===void 0?"":d})},FL=ne,Sxe=re,wxe=Ce,xxe=tn,bxe=Kk,$xe=TypeError,Zg=function(t,e){var r=t.exec;if(wxe(r)){var n=FL(r,t,e);return n!==null&&Sxe(n),n}if(xxe(t)==="RegExp")return FL(bxe,t,e);throw new $xe("RegExp#exec called on incompatible receiver")},Ixe=yn,BL=ne,Bx=V,Pxe=Nx,Exe=q,Cxe=re,_xe=Ce,Txe=nr,Axe=Et,kxe=xo,bu=Ee,Oxe=St,Mxe=Fx,Rxe=Qt,jxe=gG,Dxe=Zg,Lxe=ve,q_=Lxe("replace"),Nxe=Math.max,Fxe=Math.min,Bxe=Bx([].concat),eI=Bx([].push),UL=Bx("".indexOf),zL=Bx("".slice),Uxe=function(t){return t===void 0?t:String(t)},zxe=function(){return"a".replace(/./,"$0")==="$0"}(),HL=function(){return/./[q_]?/./[q_]("a","$0")==="":!1}(),Hxe=!Exe(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});Pxe("replace",function(t,e,r){var n=HL?"$":"$0";return[function(i,s){var a=Oxe(this),l=Txe(i)?void 0:Rxe(i,q_);return l?BL(l,i,a,s):BL(e,bu(a),i,s)},function(o,i){var s=Cxe(this),a=bu(o);if(typeof i=="string"&&UL(i,n)===-1&&UL(i,"$<")===-1){var l=r(e,s,a,i);if(l.done)return l.value}var c=_xe(i);c||(i=bu(i));var u=s.global,d;u&&(d=s.unicode,s.lastIndex=0);for(var f=[],p;p=Dxe(s,a),!(p===null||(eI(f,p),!u));){var g=bu(p[0]);g===""&&(s.lastIndex=Mxe(a,kxe(s.lastIndex),d))}for(var m="",S=0,y=0;y<f.length;y++){p=f[y];for(var v=bu(p[0]),b=Nxe(Fxe(Axe(p.index),a.length),0),$=[],P,E=1;E<p.length;E++)eI($,Uxe(p[E]));var T=p.groups;if(c){var I=Bxe([v],$,b,a);T!==void 0&&eI(I,T),P=bu(Ixe(i,void 0,I))}else P=jxe(v,a,b,$,T,i);b>=S&&(m+=zL(a,S,b)+P,S=b+v.length)}return m+zL(a,S)}]},!Hxe||!zxe||HL);var Wxe=Ie,Kxe=tn,Gxe=ve,Vxe=Gxe("match"),Ux=function(t){var e;return Wxe(t)&&((e=t[Vxe])!==void 0?!!e:Kxe(t)==="RegExp")},Yxe=ne,Xxe=ke,qxe=rn,Zxe=Bk,WL=RegExp.prototype,Qg=function(t){var e=t.flags;return e===void 0&&!("flags"in WL)&&!Xxe(t,"flags")&&qxe(WL,t)?Yxe(Zxe,t):e},Qxe=A,Jxe=ne,Yk=V,KL=St,e1e=Ce,t1e=nr,r1e=Ux,pf=Ee,n1e=Qt,o1e=Qg,i1e=gG,s1e=ve,a1e=s1e("replace"),l1e=TypeError,tI=Yk("".indexOf);Yk("".replace);var GL=Yk("".slice),c1e=Math.max;Qxe({target:"String",proto:!0},{replaceAll:function(e,r){var n=KL(this),o,i,s,a,l,c,u,d,f,p,g=0,m="";if(!t1e(e)){if(o=r1e(e),o&&(i=pf(KL(o1e(e))),!~tI(i,"g")))throw new l1e("`.replaceAll` does not allow non-global regexes");if(s=n1e(e,a1e),s)return Jxe(s,e,n,r)}for(a=pf(n),l=pf(e),c=e1e(r),c||(r=pf(r)),u=l.length,d=c1e(1,u),f=tI(a,l);f!==-1;)p=c?pf(r(l,f,a)):i1e(l,a,f,[],void 0,r),m+=GL(a,g,f)+p,g=f+u,f=f+d>a.length?-1:tI(a,l,f+d);return g<a.length&&(m+=GL(a,g)),m}});var u1e=Xg;u1e("String","replaceAll");class SS{constructor(e){C(this,"nextValue");C(this,"diff");this.previousValue=e}get(){var n,o,i,s;const e=((o=(n=this.diff)==null?void 0:n.removed)==null?void 0:o.size)??0,r=((s=(i=this.diff)==null?void 0:i.added)==null?void 0:s.size)??0;if(!(e===0&&r===0))return{value:this.nextValue,diff:this.diff}}_add(e,r){var n,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(e),this.diff??(this.diff={}),r?(n=this.diff.removed)==null||n.delete(e):((o=this.diff).added??(o.added=new Set),this.diff.added.add(e))}add(e){var o,i,s;const r=this.previousValue.has(e);if(r)return((i=(o=this.diff)==null?void 0:o.removed)==null?void 0:i.has(e))?this._add(e,r):void 0;(s=this.nextValue)!=null&&s.has(e)||this._add(e,r)}_remove(e,r){var n,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(e),this.diff??(this.diff={}),r?((n=this.diff).removed??(n.removed=new Set),this.diff.removed.add(e)):(o=this.diff.added)==null||o.delete(e)}remove(e){var o,i,s,a;const r=this.previousValue.has(e);if(!r)return((i=(o=this.diff)==null?void 0:o.added)==null?void 0:i.has(e))?this._remove(e,r):void 0;(a=(s=this.diff)==null?void 0:s.removed)!=null&&a.has(e)||this._remove(e,r)}}class zx{constructor(e,r){C(this,"createDefaultProperties");C(this,"validator");C(this,"ephemeralKeys");C(this,"ephemeralKeySet");C(this,"scope");this.typeName=e,this.createDefaultProperties=r.createDefaultProperties,this.validator=r.validator??{validate:o=>o},this.scope=r.scope??"document",this.ephemeralKeys=r.ephemeralKeys;const n=new Set;if(r.ephemeralKeys)for(const[o,i]of Hn(r.ephemeralKeys))i&&n.add(o);this.ephemeralKeySet=n}create(e){const r={...this.createDefaultProperties(),id:this.createId()};for(const[n,o]of Object.entries(e))o!==void 0&&(r[n]=o);return r.typeName=this.typeName,r}clone(e){return{...$t(e),id:this.createId()}}createId(e){return this.typeName+":"+(e??ct())}createCustomId(e){return this.typeName+":"+e}parseId(e){if(!this.isId(e))throw new Error(`ID "${e}" is not a valid ID for type "${this.typeName}"`);return e.slice(this.typeName.length+1)}isInstance(e){return(e==null?void 0:e.typeName)===this.typeName}isId(e){if(!e)return!1;for(let r=0;r<this.typeName.length;r++)if(e[r]!==this.typeName[r])return!1;return e[this.typeName.length]===":"}withDefaultProperties(e){return new zx(this.typeName,{createDefaultProperties:e,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(e,r){return r&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(r,e):this.validator.validate(e)}}function Ss(t,e){return new zx(t,{createDefaultProperties:()=>({}),validator:e.validator,scope:e.scope,ephemeralKeys:e.ephemeralKeys})}function Kw(){return{added:{},updated:{},removed:{}}}function Z_(t){const e={added:t.removed,removed:t.added,updated:{}};for(const[r,n]of Object.values(t.updated))e.updated[r.id]=[n,r];return e}function mG(t){return Object.keys(t.added).length===0&&Object.keys(t.updated).length===0&&Object.keys(t.removed).length===0}function Xk(t){const e={added:{},removed:{},updated:{}};return _p(e,t),e}function _p(t,e){for(const r of e){for(const[n,o]of Hn(r.added))if(t.removed[n]){const i=t.removed[n];delete t.removed[n],i!==o&&(t.updated[n]=[i,o])}else t.added[n]=o;for(const[n,[o,i]]of Hn(r.updated)){if(t.added[n]){t.added[n]=i,delete t.updated[n],delete t.removed[n];continue}if(t.updated[n]){t.updated[n]=[t.updated[n][0],i],delete t.removed[n];continue}t.updated[n]=r.updated[n],delete t.removed[n]}for(const[n,o]of Hn(r.removed))t.added[n]?delete t.added[n]:t.updated[n]?(t.removed[n]=t.updated[n][0],delete t.updated[n]):t.removed[n]=o}}function vG(t){return t&&typeof t=="object"&&"parents"in t}function yG(t){for(let e=0,r=t.parents.length;e<r;e++)if(t.parents[e].__unsafe__getWithoutCapture(!0),t.parents[e].lastChangedEpoch!==t.parentEpochs[e])return!0;return!1}function Gw(t,e){if(t.children.remove(e)&&t.children.isEmpty&&vG(t))for(let r=0,n=t.parents.length;r<n;r++)Gw(t.parents[r],t)}function qk(t,e){if(t.children.add(e)&&vG(t))for(let r=0,n=t.parents.length;r<n;r++)qk(t.parents[r],t)}function SG(t,e){return t===e||Object.is(t,e)||!!(t&&e&&typeof t.equals=="function"&&t.equals(e))}function Nl(t,e){const r=Symbol.for(`com.tldraw.state/${t}`),n=globalThis;return n[r]??(n[r]=e()),n[r]}const Xs=Nl("empty_array",()=>Object.freeze([])),VL=8;class Vw{constructor(){C(this,"arraySize",0);C(this,"array",Array(VL));C(this,"set",null)}get isEmpty(){if(this.array)return this.arraySize===0;if(this.set)return this.set.size===0;throw new Error("no set or array")}add(e){if(this.array)return this.array.indexOf(e)!==-1?!1:this.arraySize<VL?(this.array[this.arraySize]=e,this.arraySize++,!0):(this.set=new Set(this.array),this.array=null,this.set.add(e),!0);if(this.set)return this.set.has(e)?!1:(this.set.add(e),!0);throw new Error("no set or array")}remove(e){if(this.array){const r=this.array.indexOf(e);return r===-1?!1:(this.array[r]=void 0,this.arraySize--,r!==this.arraySize&&(this.array[r]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return this.set.has(e)?(this.set.delete(e),!0):!1;throw new Error("no set or array")}visit(e){if(this.array){for(let r=0;r<this.arraySize;r++){const n=this.array[r];typeof n<"u"&&e(n)}return}if(this.set){this.set.forEach(e);return}throw new Error("no set or array")}has(e){return this.array?this.array.indexOf(e)!==-1:this.set.has(e)}clear(){this.set?this.set.clear():(this.arraySize=0,this.array=[])}size(){return this.set?this.set.size:this.arraySize}}const co=Symbol.for("com.tldraw.state/RESET_VALUE");class wG{constructor(e){C(this,"index",0);C(this,"buffer");this.capacity=e,this.buffer=new Array(e)}pushEntry(e,r,n){if(n!==void 0){if(n===co){this.clear();return}this.buffer[this.index]=[e,r,n],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(e){const{index:r,capacity:n,buffer:o}=this;for(let i=0;i<n;i++){const s=(r-1+n-i)%n,a=o[s];if(!a)return co;const[l,c]=a;if(i===0&&e>=c)return[];if(l<=e&&e<c){const u=i+1,d=new Array(u);for(let f=0;f<u;f++)d[f]=o[(s+f)%n][2];return d}}return co}}class d1e{constructor(e,r){C(this,"offset",0);C(this,"maybeRemoved");this.below=e,this.child=r}}const Tt=Nl("capture",()=>({stack:null}));function xv(t){const e=Tt.stack;Tt.stack=null;try{return t()}finally{Tt.stack=e}}function xG(t){Tt.stack=new d1e(Tt.stack,t),t.parentSet.clear()}function bG(){const t=Tt.stack;if(Tt.stack=t.below,t.offset<t.child.parents.length){for(let e=t.offset;e<t.child.parents.length;e++){const r=t.child.parents[e];t.child.parentSet.has(r)||Gw(r,t.child)}t.child.parents.length=t.offset,t.child.parentEpochs.length=t.offset}if(t.maybeRemoved)for(let e=0;e<t.maybeRemoved.length;e++){const r=t.maybeRemoved[e];t.child.parentSet.has(r)||Gw(r,t.child)}}function Yw(t){if(Tt.stack){if(Tt.stack.child.parentSet.has(t))return;if(Tt.stack.child.parentSet.add(t),Tt.stack.child.isActivelyListening&&qk(t,Tt.stack.child),Tt.stack.offset<Tt.stack.child.parents.length){const r=Tt.stack.child.parents[Tt.stack.offset];r!==t&&(Tt.stack.maybeRemoved?Tt.stack.maybeRemoved.push(r):Tt.stack.maybeRemoved=[r])}Tt.stack.child.parents[Tt.stack.offset]=t,Tt.stack.child.parentEpochs[Tt.stack.offset]=t.lastChangedEpoch,Tt.stack.offset++}}const qa=-1;class h1e{constructor(e,r,n){C(this,"_isActivelyListening",!1);C(this,"lastTraversedEpoch",qa);C(this,"lastReactedEpoch",qa);C(this,"_scheduleCount",0);C(this,"parentSet",new Vw);C(this,"parentEpochs",[]);C(this,"parents",[]);C(this,"_scheduleEffect");C(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=e,this.runEffect=r,this._scheduleEffect=n==null?void 0:n.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==_n()){if(this.parents.length&&!yG(this)){this.lastReactedEpoch=_n();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let e=0,r=this.parents.length;e<r;e++)qk(this.parents[e],this)}detach(){this._isActivelyListening=!1;for(let e=0,r=this.parents.length;e<r;e++)Gw(this.parents[e],this)}execute(){try{xG(this);const e=_n(),r=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=e,r}finally{bG()}}}const _h=Nl("EffectScheduler",()=>h1e);function Sl(t,e,r){const n=new _h(t,e,r);return n.attach(),n.scheduleEffect(),()=>{n.detach()}}function f1e(t,e,r){const n=new _h(t,e,r);return{scheduler:n,start:o=>{const i=(o==null?void 0:o.force)??!1;n.attach(),i?n.scheduleEffect():n.maybeScheduleEffect()},stop:()=>{n.detach()}}}class p1e{constructor(e){C(this,"initialAtomValues",new Map);this.parent=e}get isRoot(){return this.parent===null}commit(){this.isRoot?$G(this.initialAtomValues.keys()):this.initialAtomValues.forEach((e,r)=>{this.parent.initialAtomValues.has(r)||this.parent.initialAtomValues.set(r,e)})}abort(){at.globalEpoch++,this.initialAtomValues.forEach((e,r)=>{var n;r.set(e),(n=r.historyBuffer)==null||n.clear()}),this.commit()}}const at=Nl("transactions",()=>({globalEpoch:qa+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:qa+1}));function g1e(){return at.reactionEpoch}function _n(){return at.globalEpoch}function m1e(){return at.globalIsReacting}function Zk(t,e){e.lastTraversedEpoch!==at.globalEpoch&&(e.lastTraversedEpoch=at.globalEpoch,e instanceof _h?t.add(e):e.children.visit(r=>Zk(t,r)))}function $G(t){var e;if(at.globalIsReacting)throw new Error("cannot change atoms during reaction cycle");try{at.globalIsReacting=!0,at.reactionEpoch=at.globalEpoch;const r=new Set;for(const o of t)o.children.visit(i=>Zk(r,i));for(const o of r)o.maybeScheduleEffect();let n=0;for(;(e=at.cleanupReactors)!=null&&e.size;){if(n++>1e3)throw new Error("Reaction update depth limit exceeded");const o=at.cleanupReactors;at.cleanupReactors=null;for(const i of o)i.maybeScheduleEffect()}}finally{at.cleanupReactors=null,at.globalIsReacting=!1}}function v1e(t,e){if(at.globalIsReacting){const r=at.cleanupReactors??(at.cleanupReactors=new Set);t.children.visit(n=>Zk(r,n))}else at.currentTransaction?at.currentTransaction.initialAtomValues.has(t)||at.currentTransaction.initialAtomValues.set(t,e):$G([t])}function y1e(){at.globalEpoch++}function S1e(t){const e=new p1e(at.currentTransaction);at.currentTransaction=e;try{let r,n=!1;try{r=t(()=>n=!0)}catch(o){throw e.abort(),o}return n?e.abort():e.commit(),r}finally{at.currentTransaction=at.currentTransaction.parent}}function os(t){return at.currentTransaction?t():S1e(t)}class w1e{constructor(e,r,n){C(this,"isEqual");C(this,"computeDiff");C(this,"lastChangedEpoch",_n());C(this,"children",new Vw);C(this,"historyBuffer");this.name=e,this.current=r,this.isEqual=(n==null?void 0:n.isEqual)??null,n&&(n.historyLength&&(this.historyBuffer=new wG(n.historyLength)),this.computeDiff=n.computeDiff)}__unsafe__getWithoutCapture(e){return this.current}get(){return Yw(this),this.current}set(e,r){var o,i;if(((o=this.isEqual)==null?void 0:o.call(this,this.current,e))??SG(this.current,e))return this.current;y1e(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,_n(),r??((i=this.computeDiff)==null?void 0:i.call(this,this.current,e,this.lastChangedEpoch,_n()))??co),this.lastChangedEpoch=_n();const n=this.current;return this.current=e,v1e(this,n),e}update(e){return this.set(e(this.current))}getDiffSince(e){var r;return Yw(this),e>=this.lastChangedEpoch?Xs:((r=this.historyBuffer)==null?void 0:r.getChangesSince(e))??co}}const x1e=Nl("Atom",()=>w1e);function fr(t,e,r){return new x1e(t,e,r)}let YL=!1;function b1e(){YL||(YL=!0,console.warn(`Using \`@computed\` as a decorator for getters is deprecated and will be removed in the near future. Please refactor to use \`@computed\` as a decorator for methods.
|
|
70
|
-
|
|
71
|
-
// Before
|
|
72
|
-
@computed
|
|
73
|
-
get foo() {
|
|
74
|
-
return 'foo'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// After
|
|
78
|
-
@computed
|
|
79
|
-
getFoo() {
|
|
80
|
-
return 'foo'
|
|
81
|
-
}
|
|
82
|
-
`))}const Jf=Symbol.for("com.tldraw.state/UNINITIALIZED");function Ic(t){return t===Jf}const Q_=Nl("WithDiff",()=>class{constructor(e,r){this.value=e,this.diff=r}});function ep(t,e){return new Q_(t,e)}class $1e{constructor(e,r,n){C(this,"lastChangedEpoch",qa);C(this,"lastTraversedEpoch",qa);C(this,"lastCheckedEpoch",qa);C(this,"parentSet",new Vw);C(this,"parents",[]);C(this,"parentEpochs",[]);C(this,"children",new Vw);C(this,"historyBuffer");C(this,"state",Jf);C(this,"error",null);C(this,"computeDiff");C(this,"isEqual");this.name=e,this.derive=r,n!=null&&n.historyLength&&(this.historyBuffer=new wG(n.historyLength)),this.computeDiff=n==null?void 0:n.computeDiff,this.isEqual=(n==null?void 0:n.isEqual)??SG}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(e){var o;const r=this.lastChangedEpoch===qa,n=_n();if(!r&&(this.lastCheckedEpoch===n||this.isActivelyListening&&m1e()&&this.lastTraversedEpoch<g1e()||!yG(this)))if(this.lastCheckedEpoch=n,this.error){if(e)return this.state;throw this.error.thrownValue}else return this.state;try{xG(this);const i=this.derive(this.state,this.lastCheckedEpoch),s=i instanceof Q_?i.value:i,a=this.state===Jf;if(a||!this.isEqual(s,this.state)){if(this.historyBuffer&&!a){const l=i instanceof Q_?i.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,_n(),l??((o=this.computeDiff)==null?void 0:o.call(this,this.state,s,this.lastCheckedEpoch,_n()))??co)}this.lastChangedEpoch=_n(),this.state=s}return this.error=null,this.lastCheckedEpoch=_n(),this.state}catch(i){if(this.state!==Jf&&(this.state=Jf,this.lastChangedEpoch=_n()),this.lastCheckedEpoch=_n(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:i},!e)throw i;return this.state}finally{bG()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Yw(this)}}getDiffSince(e){var r;return this.__unsafe__getWithoutCapture(!0),Yw(this),e>=this.lastChangedEpoch?Xs:((r=this.historyBuffer)==null?void 0:r.getChangesSince(e))??co}}const Hx=Nl("Computed",()=>$1e);function I1e(t={},e,r,n){const o=n.value,i=Symbol.for("__@tldraw/state__computed__"+r);return n.value=function(){let s=this[i];return s||(s=new Hx(r,o.bind(this),t),Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:s})),s.get()},n.value[IG]=!0,n}function P1e(t={},e,r,n){const o=n.get,i=Symbol.for("__@tldraw/state__computed__"+r);return n.get=function(){let s=this[i];return s||(s=new Hx(r,o.bind(this),t),Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:s})),s.get()},n}function E1e(t,e,r){Qe(r.kind==="method","@computed can only be used on methods");const n=Symbol.for("__@tldraw/state__computed__"+String(r.name)),o=function(){let i=this[n];return i||(i=new Hx(String(r.name),e.bind(this),t),Object.defineProperty(this,n,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()};return o[IG]=!0,o}function XL(t={},e){if(e.length===2){const[r,n]=e;return E1e(t,r,n)}else{const[r,n,o]=e;return o.get?(b1e(),P1e(t,r,n,o)):I1e(t,r,n,o)}}const IG="@@__isComputedMethod__@@";function Y(){if(arguments.length===1){const t=arguments[0];return(...e)=>XL(t,e)}else return typeof arguments[0]=="string"?new Hx(arguments[0],arguments[1],arguments[2]):XL(void 0,arguments)}const PG=1,C1e=Nl("apiVersion",()=>PG);if(C1e!==PG)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");Ol("@tldraw/state","3.0.0","esm");var Xw={exports:{}};Xw.exports;(function(t,e){var r=200,n="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",f="[object Error]",p="[object Function]",g="[object GeneratorFunction]",m="[object Map]",S="[object Number]",y="[object Null]",v="[object Object]",b="[object Promise]",$="[object Proxy]",P="[object RegExp]",E="[object Set]",T="[object String]",I="[object Symbol]",_="[object Undefined]",k="[object WeakMap]",D="[object ArrayBuffer]",R="[object DataView]",j="[object Float32Array]",M="[object Float64Array]",U="[object Int8Array]",B="[object Int16Array]",K="[object Int32Array]",z="[object Uint8Array]",W="[object Uint8ClampedArray]",J="[object Uint16Array]",oe="[object Uint32Array]",we=/[\\^$.*+?()[\]{}|]/g,_e=/^\[object .+?Constructor\]$/,Ge=/^(?:0|[1-9]\d*)$/,de={};de[j]=de[M]=de[U]=de[B]=de[K]=de[z]=de[W]=de[J]=de[oe]=!0,de[a]=de[l]=de[D]=de[u]=de[R]=de[d]=de[f]=de[p]=de[m]=de[S]=de[v]=de[P]=de[E]=de[T]=de[k]=!1;var ht=typeof Zr=="object"&&Zr&&Zr.Object===Object&&Zr,tt=typeof self=="object"&&self&&self.Object===Object&&self,_t=ht||tt||Function("return this")(),Je=e&&!e.nodeType&&e,Ot=Je&&!0&&t&&!t.nodeType&&t,st=Ot&&Ot.exports===Je,qn=st&&ht.process,wr=function(){try{return qn&&qn.binding&&qn.binding("util")}catch{}}(),In=wr&&wr.isTypedArray;function Gt(O,L){for(var X=-1,le=O==null?0:O.length,wt=0,Me=[];++X<le;){var Ht=O[X];L(Ht,X,O)&&(Me[wt++]=Ht)}return Me}function Ur(O,L){for(var X=-1,le=L.length,wt=O.length;++X<le;)O[wt+X]=L[X];return O}function Ps(O,L){for(var X=-1,le=O==null?0:O.length;++X<le;)if(L(O[X],X,O))return!0;return!1}function Zh(O,L){for(var X=-1,le=Array(O);++X<O;)le[X]=L(X);return le}function Ia(O){return function(L){return O(L)}}function ude(O,L){return O.has(L)}function dde(O,L){return O==null?void 0:O[L]}function hde(O){var L=-1,X=Array(O.size);return O.forEach(function(le,wt){X[++L]=[wt,le]}),X}function fde(O,L){return function(X){return O(L(X))}}function pde(O){var L=-1,X=Array(O.size);return O.forEach(function(le){X[++L]=le}),X}var gde=Array.prototype,mde=Function.prototype,Km=Object.prototype,Vb=_t["__core-js_shared__"],fD=mde.toString,Li=Km.hasOwnProperty,pD=function(){var O=/[^.]+$/.exec(Vb&&Vb.keys&&Vb.keys.IE_PROTO||"");return O?"Symbol(src)_1."+O:""}(),gD=Km.toString,vde=RegExp("^"+fD.call(Li).replace(we,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mD=st?_t.Buffer:void 0,Gm=_t.Symbol,vD=_t.Uint8Array,yD=Km.propertyIsEnumerable,yde=gde.splice,ql=Gm?Gm.toStringTag:void 0,SD=Object.getOwnPropertySymbols,Sde=mD?mD.isBuffer:void 0,wde=fde(Object.keys,Object),Yb=Su(_t,"DataView"),Qh=Su(_t,"Map"),Xb=Su(_t,"Promise"),qb=Su(_t,"Set"),Zb=Su(_t,"WeakMap"),Jh=Su(Object,"create"),xde=Jl(Yb),bde=Jl(Qh),$de=Jl(Xb),Ide=Jl(qb),Pde=Jl(Zb),wD=Gm?Gm.prototype:void 0,Qb=wD?wD.valueOf:void 0;function Zl(O){var L=-1,X=O==null?0:O.length;for(this.clear();++L<X;){var le=O[L];this.set(le[0],le[1])}}function Ede(){this.__data__=Jh?Jh(null):{},this.size=0}function Cde(O){var L=this.has(O)&&delete this.__data__[O];return this.size-=L?1:0,L}function _de(O){var L=this.__data__;if(Jh){var X=L[O];return X===n?void 0:X}return Li.call(L,O)?L[O]:void 0}function Tde(O){var L=this.__data__;return Jh?L[O]!==void 0:Li.call(L,O)}function Ade(O,L){var X=this.__data__;return this.size+=this.has(O)?0:1,X[O]=Jh&&L===void 0?n:L,this}Zl.prototype.clear=Ede,Zl.prototype.delete=Cde,Zl.prototype.get=_de,Zl.prototype.has=Tde,Zl.prototype.set=Ade;function Es(O){var L=-1,X=O==null?0:O.length;for(this.clear();++L<X;){var le=O[L];this.set(le[0],le[1])}}function kde(){this.__data__=[],this.size=0}function Ode(O){var L=this.__data__,X=Ym(L,O);if(X<0)return!1;var le=L.length-1;return X==le?L.pop():yde.call(L,X,1),--this.size,!0}function Mde(O){var L=this.__data__,X=Ym(L,O);return X<0?void 0:L[X][1]}function Rde(O){return Ym(this.__data__,O)>-1}function jde(O,L){var X=this.__data__,le=Ym(X,O);return le<0?(++this.size,X.push([O,L])):X[le][1]=L,this}Es.prototype.clear=kde,Es.prototype.delete=Ode,Es.prototype.get=Mde,Es.prototype.has=Rde,Es.prototype.set=jde;function Ql(O){var L=-1,X=O==null?0:O.length;for(this.clear();++L<X;){var le=O[L];this.set(le[0],le[1])}}function Dde(){this.size=0,this.__data__={hash:new Zl,map:new(Qh||Es),string:new Zl}}function Lde(O){var L=Xm(this,O).delete(O);return this.size-=L?1:0,L}function Nde(O){return Xm(this,O).get(O)}function Fde(O){return Xm(this,O).has(O)}function Bde(O,L){var X=Xm(this,O),le=X.size;return X.set(O,L),this.size+=X.size==le?0:1,this}Ql.prototype.clear=Dde,Ql.prototype.delete=Lde,Ql.prototype.get=Nde,Ql.prototype.has=Fde,Ql.prototype.set=Bde;function Vm(O){var L=-1,X=O==null?0:O.length;for(this.__data__=new Ql;++L<X;)this.add(O[L])}function Ude(O){return this.__data__.set(O,n),this}function zde(O){return this.__data__.has(O)}Vm.prototype.add=Vm.prototype.push=Ude,Vm.prototype.has=zde;function Pa(O){var L=this.__data__=new Es(O);this.size=L.size}function Hde(){this.__data__=new Es,this.size=0}function Wde(O){var L=this.__data__,X=L.delete(O);return this.size=L.size,X}function Kde(O){return this.__data__.get(O)}function Gde(O){return this.__data__.has(O)}function Vde(O,L){var X=this.__data__;if(X instanceof Es){var le=X.__data__;if(!Qh||le.length<r-1)return le.push([O,L]),this.size=++X.size,this;X=this.__data__=new Ql(le)}return X.set(O,L),this.size=X.size,this}Pa.prototype.clear=Hde,Pa.prototype.delete=Wde,Pa.prototype.get=Kde,Pa.prototype.has=Gde,Pa.prototype.set=Vde;function Yde(O,L){var X=qm(O),le=!X&&che(O),wt=!X&&!le&&Jb(O),Me=!X&&!le&&!wt&&TD(O),Ht=X||le||wt||Me,cr=Ht?Zh(O.length,String):[],xr=cr.length;for(var Mt in O)Li.call(O,Mt)&&!(Ht&&(Mt=="length"||wt&&(Mt=="offset"||Mt=="parent")||Me&&(Mt=="buffer"||Mt=="byteLength"||Mt=="byteOffset")||ohe(Mt,xr)))&&cr.push(Mt);return cr}function Ym(O,L){for(var X=O.length;X--;)if(PD(O[X][0],L))return X;return-1}function Xde(O,L,X){var le=L(O);return qm(O)?le:Ur(le,X(O))}function ef(O){return O==null?O===void 0?_:y:ql&&ql in Object(O)?rhe(O):lhe(O)}function xD(O){return tf(O)&&ef(O)==a}function bD(O,L,X,le,wt){return O===L?!0:O==null||L==null||!tf(O)&&!tf(L)?O!==O&&L!==L:qde(O,L,X,le,bD,wt)}function qde(O,L,X,le,wt,Me){var Ht=qm(O),cr=qm(L),xr=Ht?l:Ea(O),Mt=cr?l:Ea(L);xr=xr==a?v:xr,Mt=Mt==a?v:Mt;var Zn=xr==v,ri=Mt==v,zr=xr==Mt;if(zr&&Jb(O)){if(!Jb(L))return!1;Ht=!0,Zn=!1}if(zr&&!Zn)return Me||(Me=new Pa),Ht||TD(O)?$D(O,L,X,le,wt,Me):ehe(O,L,xr,X,le,wt,Me);if(!(X&o)){var To=Zn&&Li.call(O,"__wrapped__"),Ao=ri&&Li.call(L,"__wrapped__");if(To||Ao){var Ca=To?O.value():O,Cs=Ao?L.value():L;return Me||(Me=new Pa),wt(Ca,Cs,X,le,Me)}}return zr?(Me||(Me=new Pa),the(O,L,X,le,wt,Me)):!1}function Zde(O){if(!_D(O)||she(O))return!1;var L=ED(O)?vde:_e;return L.test(Jl(O))}function Qde(O){return tf(O)&&CD(O.length)&&!!de[ef(O)]}function Jde(O){if(!ahe(O))return wde(O);var L=[];for(var X in Object(O))Li.call(O,X)&&X!="constructor"&&L.push(X);return L}function $D(O,L,X,le,wt,Me){var Ht=X&o,cr=O.length,xr=L.length;if(cr!=xr&&!(Ht&&xr>cr))return!1;var Mt=Me.get(O);if(Mt&&Me.get(L))return Mt==L;var Zn=-1,ri=!0,zr=X&i?new Vm:void 0;for(Me.set(O,L),Me.set(L,O);++Zn<cr;){var To=O[Zn],Ao=L[Zn];if(le)var Ca=Ht?le(Ao,To,Zn,L,O,Me):le(To,Ao,Zn,O,L,Me);if(Ca!==void 0){if(Ca)continue;ri=!1;break}if(zr){if(!Ps(L,function(Cs,ec){if(!ude(zr,ec)&&(To===Cs||wt(To,Cs,X,le,Me)))return zr.push(ec)})){ri=!1;break}}else if(!(To===Ao||wt(To,Ao,X,le,Me))){ri=!1;break}}return Me.delete(O),Me.delete(L),ri}function ehe(O,L,X,le,wt,Me,Ht){switch(X){case R:if(O.byteLength!=L.byteLength||O.byteOffset!=L.byteOffset)return!1;O=O.buffer,L=L.buffer;case D:return!(O.byteLength!=L.byteLength||!Me(new vD(O),new vD(L)));case u:case d:case S:return PD(+O,+L);case f:return O.name==L.name&&O.message==L.message;case P:case T:return O==L+"";case m:var cr=hde;case E:var xr=le&o;if(cr||(cr=pde),O.size!=L.size&&!xr)return!1;var Mt=Ht.get(O);if(Mt)return Mt==L;le|=i,Ht.set(O,L);var Zn=$D(cr(O),cr(L),le,wt,Me,Ht);return Ht.delete(O),Zn;case I:if(Qb)return Qb.call(O)==Qb.call(L)}return!1}function the(O,L,X,le,wt,Me){var Ht=X&o,cr=ID(O),xr=cr.length,Mt=ID(L),Zn=Mt.length;if(xr!=Zn&&!Ht)return!1;for(var ri=xr;ri--;){var zr=cr[ri];if(!(Ht?zr in L:Li.call(L,zr)))return!1}var To=Me.get(O);if(To&&Me.get(L))return To==L;var Ao=!0;Me.set(O,L),Me.set(L,O);for(var Ca=Ht;++ri<xr;){zr=cr[ri];var Cs=O[zr],ec=L[zr];if(le)var AD=Ht?le(ec,Cs,zr,L,O,Me):le(Cs,ec,zr,O,L,Me);if(!(AD===void 0?Cs===ec||wt(Cs,ec,X,le,Me):AD)){Ao=!1;break}Ca||(Ca=zr=="constructor")}if(Ao&&!Ca){var Zm=O.constructor,Qm=L.constructor;Zm!=Qm&&"constructor"in O&&"constructor"in L&&!(typeof Zm=="function"&&Zm instanceof Zm&&typeof Qm=="function"&&Qm instanceof Qm)&&(Ao=!1)}return Me.delete(O),Me.delete(L),Ao}function ID(O){return Xde(O,hhe,nhe)}function Xm(O,L){var X=O.__data__;return ihe(L)?X[typeof L=="string"?"string":"hash"]:X.map}function Su(O,L){var X=dde(O,L);return Zde(X)?X:void 0}function rhe(O){var L=Li.call(O,ql),X=O[ql];try{O[ql]=void 0;var le=!0}catch{}var wt=gD.call(O);return le&&(L?O[ql]=X:delete O[ql]),wt}var nhe=SD?function(O){return O==null?[]:(O=Object(O),Gt(SD(O),function(L){return yD.call(O,L)}))}:fhe,Ea=ef;(Yb&&Ea(new Yb(new ArrayBuffer(1)))!=R||Qh&&Ea(new Qh)!=m||Xb&&Ea(Xb.resolve())!=b||qb&&Ea(new qb)!=E||Zb&&Ea(new Zb)!=k)&&(Ea=function(O){var L=ef(O),X=L==v?O.constructor:void 0,le=X?Jl(X):"";if(le)switch(le){case xde:return R;case bde:return m;case $de:return b;case Ide:return E;case Pde:return k}return L});function ohe(O,L){return L=L??s,!!L&&(typeof O=="number"||Ge.test(O))&&O>-1&&O%1==0&&O<L}function ihe(O){var L=typeof O;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?O!=="__proto__":O===null}function she(O){return!!pD&&pD in O}function ahe(O){var L=O&&O.constructor,X=typeof L=="function"&&L.prototype||Km;return O===X}function lhe(O){return gD.call(O)}function Jl(O){if(O!=null){try{return fD.call(O)}catch{}try{return O+""}catch{}}return""}function PD(O,L){return O===L||O!==O&&L!==L}var che=xD(function(){return arguments}())?xD:function(O){return tf(O)&&Li.call(O,"callee")&&!yD.call(O,"callee")},qm=Array.isArray;function uhe(O){return O!=null&&CD(O.length)&&!ED(O)}var Jb=Sde||phe;function dhe(O,L){return bD(O,L)}function ED(O){if(!_D(O))return!1;var L=ef(O);return L==p||L==g||L==c||L==$}function CD(O){return typeof O=="number"&&O>-1&&O%1==0&&O<=s}function _D(O){var L=typeof O;return O!=null&&(L=="object"||L=="function")}function tf(O){return O!=null&&typeof O=="object"}var TD=In?Ia(In):Qde;function hhe(O){return uhe(O)?Yde(O):Jde(O)}function fhe(){return[]}function phe(){return!1}t.exports=dhe})(Xw,Xw.exports);var _1e=Xw.exports;const T1e=_l(_1e);function A1e(t){if(t.length===0)return new Set;const e=t[0],r=t.slice(1),n=new Set;for(const o of e)r.every(i=>i.has(o))&&n.add(o);return n}function k1e(t,e){const r={};for(const n of e)t.has(n)||(r.added??(r.added=new Set),r.added.add(n));for(const n of t)e.has(n)||(r.removed??(r.removed=new Set),r.removed.add(n));return r.added||r.removed?r:void 0}function qL(t,e){for(const[r,n]of Object.entries(t)){const o=n,i=e[r];if("eq"in o&&i!==o.eq||"neq"in o&&i===o.neq||"gt"in o&&(typeof i!="number"||i<=o.gt))return!1}return!0}function ZL(t,e,r){const n=Object.fromEntries(Object.keys(r).map(o=>[o,new Set]));for(const[o,i]of Object.entries(r))if("eq"in i){const a=t.index(e,o).get().get(i.eq);if(a)for(const l of a)n[o].add(l)}else if("neq"in i){const s=t.index(e,o);for(const[a,l]of s.get())if(a!==i.neq)for(const c of l)n[o].add(c)}else if("gt"in i){const s=t.index(e,o);for(const[a,l]of s.get())if(a>i.gt)for(const c of l)n[o].add(c)}return A1e(Object.values(n))}class O1e{constructor(e,r){C(this,"indexCache",new Map);C(this,"historyCache",new Map);this.atoms=e,this.history=r}filterHistory(e){if(this.historyCache.has(e))return this.historyCache.get(e);const r=Y("filterHistory:"+e,(n,o)=>{if(Ic(n))return this.history.get();const i=this.history.getDiffSince(o);if(i===co)return this.history.get();const s={added:{},removed:{},updated:{}};let a=0,l=0,c=0;for(const u of i){for(const d of Rt(u.added))if(d.typeName===e)if(s.removed[d.id]){const f=s.removed[d.id];delete s.removed[d.id],l--,f!==d&&(s.updated[d.id]=[f,d],c++)}else s.added[d.id]=d,a++;for(const[d,f]of Rt(u.updated))f.typeName===e&&(s.added[f.id]?s.added[f.id]=f:s.updated[f.id]?s.updated[f.id]=[s.updated[f.id][0],f]:(s.updated[f.id]=[d,f],c++));for(const d of Rt(u.removed))d.typeName===e&&(s.added[d.id]?(delete s.added[d.id],a--):s.updated[d.id]?(s.removed[d.id]=s.updated[d.id][0],delete s.updated[d.id],c--,l++):(s.removed[d.id]=d,l++))}return a||l||c?ep(this.history.get(),s):n},{historyLength:100});return this.historyCache.set(e,r),r}index(e,r){const n=e+":"+r;if(this.indexCache.has(n))return this.indexCache.get(n);const o=this.__uncached_createIndex(e,r);return this.indexCache.set(n,o),o}__uncached_createIndex(e,r){const n=this.filterHistory(e),o=()=>{n.get();const i=new Map;for(const s of Rt(this.atoms.get())){const a=s.get();if(a.typeName===e){const l=a[r];i.has(l)||i.set(l,new Set),i.get(l).add(a.id)}}return i};return Y("index:"+e+":"+r,(i,s)=>{if(Ic(i))return o();const a=n.getDiffSince(s);if(a===co)return o();const l=new Map,c=(p,g)=>{let m=l.get(p);m||(m=new SS(i.get(p)??new Set)),m.add(g),l.set(p,m)},u=(p,g)=>{let m=l.get(p);m||(m=new SS(i.get(p)??new Set)),m.remove(g),l.set(p,m)};for(const p of a){for(const g of Rt(p.added))if(g.typeName===e){const m=g[r];c(m,g.id)}for(const[g,m]of Rt(p.updated))if(m.typeName===e){const S=g[r],y=m[r];S!==y&&(u(S,m.id),c(y,m.id))}for(const g of Rt(p.removed))if(g.typeName===e){const m=g[r];u(m,g.id)}}let d,f;for(const[p,g]of l){const m=g.get();m&&(d||(d=new Map(i)),f||(f=new Map),m.value.size===0?d.delete(p):d.set(p,m.value),f.set(p,m.diff))}return d&&f?ep(d,f):i},{historyLength:100})}record(e,r=()=>({}),n="record:"+e+(r?":"+r.toString():"")){const o=this.ids(e,r,n);return Y(n,()=>{var i;for(const s of o.get())return(i=this.atoms.get()[s])==null?void 0:i.get()})}records(e,r=()=>({}),n="records:"+e+(r?":"+r.toString():"")){const o=this.ids(e,r,"ids:"+n);return Y(n,()=>[...o.get()].map(i=>{const s=this.atoms.get()[i];if(!s)throw new Error("no atom found for record id: "+i);return s.get()}))}ids(e,r=()=>({}),n="ids:"+e+(r?":"+r.toString():"")){const o=this.filterHistory(e),i=()=>{o.get();const l=r();return Object.keys(l).length===0?new Set(Rt(this.atoms.get()).flatMap(c=>{const u=c.get();return u.typeName===e?u.id:[]})):ZL(this,e,l)},s=l=>{const c=i(),u=k1e(l,c);return u?ep(c,u):l},a=Y("ids_query:"+n,r,{isEqual:T1e});return Y("query:"+n,(l,c)=>{const u=a.get();if(Ic(l))return i();if(c<a.lastChangedEpoch)return s(l);const d=o.getDiffSince(c);if(d===co)return s(l);const f=new SS(l);for(const g of d){for(const m of Rt(g.added))m.typeName===e&&qL(u,m)&&f.add(m.id);for(const[m,S]of Rt(g.updated))S.typeName===e&&(qL(u,S)?f.add(S.id):f.remove(S.id));for(const m of Rt(g.removed))m.typeName===e&&f.remove(m.id)}const p=f.get();return p?ep(p.value,p.diff):l},{historyLength:50})}exec(e,r){const n=ZL(this,e,r);if(n.size===0)return Xs;const o=this.atoms.get();return[...n].map(i=>o[i].get())}}class M1e{constructor(e){C(this,"_beforeCreateHandlers",{});C(this,"_afterCreateHandlers",{});C(this,"_beforeChangeHandlers",{});C(this,"_afterChangeHandlers",{});C(this,"_beforeDeleteHandlers",{});C(this,"_afterDeleteHandlers",{});C(this,"_operationCompleteHandlers",[]);C(this,"_isEnabled",!0);this.store=e}isEnabled(){return this._isEnabled}setIsEnabled(e){this._isEnabled=e}handleBeforeCreate(e,r){if(!this._isEnabled)return e;const n=this._beforeCreateHandlers[e.typeName];if(n){let o=e;for(const i of n)o=i(o,r);return o}return e}handleAfterCreate(e,r){if(!this._isEnabled)return;const n=this._afterCreateHandlers[e.typeName];if(n)for(const o of n)o(e,r)}handleBeforeChange(e,r,n){if(!this._isEnabled)return r;const o=this._beforeChangeHandlers[r.typeName];if(o){let i=r;for(const s of o)i=s(e,i,n);return i}return r}handleAfterChange(e,r,n){if(!this._isEnabled)return;const o=this._afterChangeHandlers[r.typeName];if(o)for(const i of o)i(e,r,n)}handleBeforeDelete(e,r){if(!this._isEnabled)return!0;const n=this._beforeDeleteHandlers[e.typeName];if(n){for(const o of n)if(o(e,r)===!1)return!1}return!0}handleAfterDelete(e,r){if(!this._isEnabled)return;const n=this._afterDeleteHandlers[e.typeName];if(n)for(const o of n)o(e,r)}handleOperationComplete(e){if(this._isEnabled)for(const r of this._operationCompleteHandlers)r(e)}register(e){const r=[];for(const[n,o]of Object.entries(e))o!=null&&o.beforeCreate&&r.push(this.registerBeforeCreateHandler(n,o.beforeCreate)),o!=null&&o.afterCreate&&r.push(this.registerAfterCreateHandler(n,o.afterCreate)),o!=null&&o.beforeChange&&r.push(this.registerBeforeChangeHandler(n,o.beforeChange)),o!=null&&o.afterChange&&r.push(this.registerAfterChangeHandler(n,o.afterChange)),o!=null&&o.beforeDelete&&r.push(this.registerBeforeDeleteHandler(n,o.beforeDelete)),o!=null&&o.afterDelete&&r.push(this.registerAfterDeleteHandler(n,o.afterDelete));return()=>{for(const n of r)n()}}registerBeforeCreateHandler(e,r){return this._beforeCreateHandlers[e]||(this._beforeCreateHandlers[e]=[]),this._beforeCreateHandlers[e].push(r),()=>tc(this._beforeCreateHandlers[e],r)}registerAfterCreateHandler(e,r){return this._afterCreateHandlers[e]||(this._afterCreateHandlers[e]=[]),this._afterCreateHandlers[e].push(r),()=>tc(this._afterCreateHandlers[e],r)}registerBeforeChangeHandler(e,r){return this._beforeChangeHandlers[e]||(this._beforeChangeHandlers[e]=[]),this._beforeChangeHandlers[e].push(r),()=>tc(this._beforeChangeHandlers[e],r)}registerAfterChangeHandler(e,r){return this._afterChangeHandlers[e]||(this._afterChangeHandlers[e]=[]),this._afterChangeHandlers[e].push(r),()=>tc(this._afterChangeHandlers[e],r)}registerBeforeDeleteHandler(e,r){return this._beforeDeleteHandlers[e]||(this._beforeDeleteHandlers[e]=[]),this._beforeDeleteHandlers[e].push(r),()=>tc(this._beforeDeleteHandlers[e],r)}registerAfterDeleteHandler(e,r){return this._afterDeleteHandlers[e]||(this._afterDeleteHandlers[e]=[]),this._afterDeleteHandlers[e].push(r),()=>tc(this._afterDeleteHandlers[e],r)}registerOperationCompleteHandler(e){return this._operationCompleteHandlers.push(e),()=>tc(this._operationCompleteHandlers,e)}}function tc(t,e){const r=t.indexOf(e);r>=0&&t.splice(r,1)}class Qk{constructor(e){C(this,"id");C(this,"atoms",fr("store_atoms",{}));C(this,"history",fr("history",0,{historyLength:1e3}));C(this,"query",new O1e(this.atoms,this.history));C(this,"listeners",new Set);C(this,"historyAccumulator",new j1e);C(this,"historyReactor");C(this,"schema");C(this,"props");C(this,"scopedTypes");C(this,"sideEffects",new M1e(this));C(this,"isMergingRemoteChanges",!1);C(this,"_integrityChecker");C(this,"_isPossiblyCorrupted",!1);C(this,"pendingAfterEvents",null);C(this,"_isInAtomicOp",!1);const{initialData:r,schema:n,id:o}=e;this.id=o??ct(),this.schema=n,this.props=e.props,r&&this.atoms.set(yK(Hn(r).map(([i,s])=>[i,fr("atom:"+i,this.schema.validateRecord(this,s,"initialize",null))]))),this.historyReactor=f1e("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:i=>this.cancelHistoryReactor=jK(i)}),this.scopedTypes={document:new Set(Rt(this.schema.types).filter(i=>i.scope==="document").map(i=>i.typeName)),session:new Set(Rt(this.schema.types).filter(i=>i.scope==="session").map(i=>i.typeName)),presence:new Set(Rt(this.schema.types).filter(i=>i.scope==="presence").map(i=>i.typeName))}}cancelHistoryReactor(){}_flushHistory(){if(this.historyAccumulator.hasChanges()){const e=this.historyAccumulator.flush();for(const{changes:r,source:n}of e){let o=null,i=null,s=null;for(const{onHistory:a,filters:l}of this.listeners)if(!(l.source!=="all"&&l.source!==n))if(l.scope!=="all")if(l.scope==="document"){if(i??(i=this.filterChangesByScope(r,"document")),!i)continue;a({changes:i,source:n})}else if(l.scope==="session"){if(o??(o=this.filterChangesByScope(r,"session")),!o)continue;a({changes:o,source:n})}else{if(s??(s=this.filterChangesByScope(r,"presence")),!s)continue;a({changes:s,source:n})}else a({changes:r,source:n})}}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(e,r){const n={added:Cp(e.added,(o,i)=>this.scopedTypes[r].has(i.typeName)),updated:Cp(e.updated,(o,i)=>this.scopedTypes[r].has(i[1].typeName)),removed:Cp(e.removed,(o,i)=>this.scopedTypes[r].has(i.typeName))};return Object.keys(n.added).length===0&&Object.keys(n.updated).length===0&&Object.keys(n.removed).length===0?null:n}updateHistory(e){this.historyAccumulator.add({changes:e,source:this.isMergingRemoteChanges?"remote":"user"}),this.listeners.size===0&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,e)}validate(e){this.allRecords().forEach(r=>this.schema.validateRecord(this,r,e,null))}put(e,r){this.atomic(()=>{const n={},o={},i=this.atoms.__unsafe__getWithoutCapture();let s=null,a,l=!1;const c=this.isMergingRemoteChanges?"remote":"user";for(let u=0,d=e.length;u<d;u++){a=e[u];const f=(s??i)[a.id];if(f){const p=f.__unsafe__getWithoutCapture();if(a=this.sideEffects.handleBeforeChange(p,a,c),this.schema.validateRecord(this,a,r??"updateRecord",p)===p)continue;f.set(a),l=!0;const m=f.__unsafe__getWithoutCapture();n[a.id]=[p,m],this.addDiffForAfterEvent(p,m)}else a=this.sideEffects.handleBeforeCreate(a,c),l=!0,a=this.schema.validateRecord(this,a,r??"createRecord",null),o[a.id]=a,this.addDiffForAfterEvent(null,a),s||(s={...i}),s[a.id]=fr("atom:"+a.id,a)}s&&this.atoms.set(s),l&&this.updateHistory({added:o,updated:n,removed:{}})})}remove(e){this.atomic(()=>{const r=new Set,n=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(const i of e){const s=this.atoms.__unsafe__getWithoutCapture()[i];s&&this.sideEffects.handleBeforeDelete(s.get(),n)===!1&&r.add(i)}let o;this.atoms.update(i=>{let s;for(const a of e){if(r.has(a)||!(a in i))continue;s||(s={...i}),o||(o={}),delete s[a];const l=i[a].get();o[a]=l,this.addDiffForAfterEvent(l,null)}return s??i}),o&&this.updateHistory({added:{},updated:{},removed:o})})}get(e){var r;return(r=this.atoms.get()[e])==null?void 0:r.get()}unsafeGetWithoutCapture(e){var r;return(r=this.atoms.__unsafe__getWithoutCapture()[e])==null?void 0:r.__unsafe__getWithoutCapture()}serialize(e="document"){const r={};for(const[n,o]of Hn(this.atoms.get())){const i=o.get();(e==="all"||this.scopedTypes[e].has(i.typeName))&&(r[n]=i)}return r}getStoreSnapshot(e="document"){return{store:this.serialize(e),schema:this.schema.serialize()}}getSnapshot(e="document"){return console.warn("[tldraw] `Store.getSnapshot` is deprecated and will be removed in a future release. Use `getSnapshot` from the `tldraw` package instead."),this.getStoreSnapshot(e)}migrateSnapshot(e){const r=this.schema.migrateStoreSnapshot(e);if(r.type==="error")throw new Error(`Failed to migrate snapshot: ${r.reason}`);return{store:r.value,schema:this.schema.serialize()}}loadStoreSnapshot(e){const r=this.schema.migrateStoreSnapshot(e);if(r.type==="error")throw new Error(`Failed to migrate snapshot: ${r.reason}`);const n=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(r.value)),this.ensureStoreIsUsable()})}finally{this.sideEffects.setIsEnabled(n)}}loadSnapshot(e){console.warn("[tldraw] `Store.loadSnapshot` is deprecated and will be removed in a future release. Use `loadSnapshot` from the 'tldraw' package instead."),this.loadStoreSnapshot(e)}allRecords(){return Rt(this.atoms.get()).map(e=>e.get())}clear(){this.remove(q3(this.atoms.get()))}update(e,r){const n=this.atoms.get()[e];if(!n){console.error(`Record ${e} not found. This is probably an error`);return}this.put([r(n.__unsafe__getWithoutCapture())])}has(e){return!!this.atoms.get()[e]}listen(e,r){this._flushHistory();const n={onHistory:e,filters:{source:(r==null?void 0:r.source)??"all",scope:(r==null?void 0:r.scope)??"all"}};return this.listeners.add(n),this.historyReactor.scheduler.isActivelyListening||this.historyReactor.start(),()=>{this.listeners.delete(n),this.listeners.size===0&&this.historyReactor.stop()}}mergeRemoteChanges(e){if(this.isMergingRemoteChanges)return e();if(this._isInAtomicOp)throw new Error("Cannot merge remote changes while in atomic operation");try{this.isMergingRemoteChanges=!0,os(e)}finally{this.isMergingRemoteChanges=!1}}extractingChanges(e){const r=[],n=this.historyAccumulator.addInterceptor(o=>r.push(o.changes));try{return os(e),Xk(r)}finally{n()}}applyDiff(e,{runCallbacks:r=!0,ignoreEphemeralKeys:n=!1}={}){this.atomic(()=>{const o=Rt(e.added);for(const[s,a]of Rt(e.updated)){const l=this.schema.getType(a.typeName);if(n&&l.ephemeralKeySet.size){const c=this.get(a.id);if(!c){o.push(a);continue}let u=null;for(const[d,f]of Object.entries(a))l.ephemeralKeySet.has(d)||Object.is(f,Dn(c,d))||(u||(u={...c}),u[d]=f);u&&o.push(u)}else o.push(a)}const i=q3(e.removed);o.length&&this.put(o),i.length&&this.remove(i)},r)}createComputedCache(e,r,n){const o=new ls;return{get:i=>{const s=this.atoms.get()[i];if(s)return o.get(s,()=>{const a=n?Y(s.name+":equals",()=>s.get(),{isEqual:n}):s;return Y(e+":"+i,()=>r(a.get()))}).get()}}}createSelectedComputedCache(e,r,n){const o=new ls;return{get:i=>{const s=this.atoms.get()[i];if(s)return o.get(s,()=>{const a=Y(e+":"+i+":selector",()=>r(s.get()));return Y(e+":"+i,()=>n(a.get()))}).get()}}}ensureStoreIsUsable(){this.atomic(()=>{var e;this._integrityChecker??(this._integrityChecker=this.schema.createIntegrityChecker(this)),(e=this._integrityChecker)==null||e.call(this)})}markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}addDiffForAfterEvent(e,r){if(Qe(this.pendingAfterEvents,"must be in event operation"),e===r||(e&&r&&Qe(e.id===r.id),!e&&!r))return;const n=(e||r).id,o=this.pendingAfterEvents.get(n);o?o.after=r:this.pendingAfterEvents.set(n,{before:e,after:r})}flushAtomicCallbacks(){let e=0;const r=this.isMergingRemoteChanges?"remote":"user";for(;this.pendingAfterEvents;){const n=this.pendingAfterEvents;if(this.pendingAfterEvents=null,!!this.sideEffects.isEnabled()){if(e++,e>100)throw new Error("Maximum store update depth exceeded, bailing out");for(const{before:o,after:i}of n.values())o&&i?this.sideEffects.handleAfterChange(o,i,r):o&&!i?this.sideEffects.handleAfterDelete(o,r):!o&&i&&this.sideEffects.handleAfterCreate(i,r);this.pendingAfterEvents||this.sideEffects.handleOperationComplete(r)}}}atomic(e,r=!0){return os(()=>{if(this._isInAtomicOp)return this.pendingAfterEvents||(this.pendingAfterEvents=new Map),e();this.pendingAfterEvents=new Map;const n=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(r??n),this._isInAtomicOp=!0;try{const o=e();return this.flushAtomicCallbacks(),o}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(n),this._isInAtomicOp=!1}})}addHistoryInterceptor(e){return this.historyAccumulator.addInterceptor(r=>e(r,this.isMergingRemoteChanges?"remote":"user"))}}function R1e(t){if(t.length===0)return[];const e=[];let r=[t[0]],n;for(let o=1,i=t.length;o<i;o++)n=t[o],r[0].source!==n.source&&(e.push(r),r=[]),r.push(n);return e.push(r),e.map(o=>({source:o[0].source,changes:Xk(o.map(i=>i.changes))}))}class j1e{constructor(){C(this,"_history",[]);C(this,"_interceptors",new Set)}addInterceptor(e){return this._interceptors.add(e),()=>{this._interceptors.delete(e)}}add(e){this._history.push(e);for(const r of this._interceptors)r(e)}flush(){const e=R1e(this._history);return this._history=[],e}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function D1e(t,e,r){const n=new ls;return{get(o,i){return n.get(o,()=>(o instanceof Qk?o:o.store).createComputedCache(t,l=>e(o,l),r)).get(i)}}}function L1e(t){const e=[];for(let r=t.length-1;r>=0;r--){const n=t[r];if("id"in n)e.unshift(n);else{const o=n.dependsOn,i=e[0];i&&(e[0]={...i,dependsOn:o.concat(i.dependsOn??[])})}}return e}function Cd({sequence:t,sequenceId:e,retroactive:r=!0}){const n={sequenceId:e,retroactive:r,sequence:L1e(t)};return EG(n),n}function Kn(t,e){return Object.fromEntries(Hn(e).map(([r,n])=>[r,`${t}/${n}`]))}function $o(t){const e=t.sequenceId;return Cd({sequenceId:e,retroactive:t.retroactive??!0,sequence:t.sequence.map(r=>"id"in r?{...r,scope:"record",filter:n=>{var o,i;return n.typeName===t.recordType&&(((o=r.filter)==null?void 0:o.call(r,n))??!0)&&(((i=t.filter)==null?void 0:i.call(t,n))??!0)}}:r)})}function N1e(t){const e=new Map(t.map(i=>[i.id,i])),r=new Set,n=[];function o(i){Qe(!r.has(i.id),`Circular dependency in migrations: ${i.id}`),r.add(i.id);const{version:s,sequenceId:a}=qw(i.id),l=e.get(`${a}/${s-1}`);if(l&&o(l),i.dependsOn)for(const c of i.dependsOn){const u=e.get(c);u&&o(u)}e.delete(i.id),n.push(i)}for(const i of e.values())o(i);return n}function qw(t){const[e,r]=t.split("/");return{sequenceId:e,version:parseInt(r)}}function QL(t,e){e&&Qe(t.startsWith(e+"/"),`Every migration in sequence '${e}' must have an id starting with '${e}/'. Got invalid id: '${t}'`),Qe(t.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${t}'`)}function EG(t){if(Qe(!t.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${t.sequenceId}`),Qe(t.sequenceId.length,"sequenceId must be a non-empty string"),t.sequence.length===0)return;QL(t.sequence[0].id,t.sequenceId);let e=qw(t.sequence[0].id).version;Qe(e===1,`Expected the first migrationId to be '${t.sequenceId}/1' but got '${t.sequence[0].id}'`);for(let r=1;r<t.sequence.length;r++){const n=t.sequence[r].id;QL(n,t.sequenceId);const o=qw(n).version;Qe(o===e+1,`Migration id numbers must increase in increments of 1, expected ${t.sequenceId}/${e+1} but got '${t.sequence[r].id}'`),e=o}}var ja=(t=>(t.IncompatibleSubtype="incompatible-subtype",t.UnknownType="unknown-type",t.TargetVersionTooNew="target-version-too-new",t.TargetVersionTooOld="target-version-too-old",t.MigrationError="migration-error",t.UnrecognizedSubtype="unrecognized-subtype",t))(ja||{});function F1e(t){if(t.schemaVersion>2||t.schemaVersion<1)return hn.err("Bad schema version");if(t.schemaVersion===2)return hn.ok(t);const e={schemaVersion:2,sequences:{"com.tldraw.store":t.storeVersion}};for(const[r,n]of Object.entries(t.recordVersions))if(e.sequences[`com.tldraw.${r}`]=n.version,"subTypeKey"in n)for(const[o,i]of Object.entries(n.subTypeVersions))e.sequences[`com.tldraw.${r}.${o}`]=i;return hn.ok(e)}class Jk{constructor(e,r){C(this,"migrations",{});C(this,"sortedMigrations");var o;this.types=e,this.options=r;for(const i of r.migrations??[])Qe(!this.migrations[i.sequenceId],`Duplicate migration sequenceId ${i.sequenceId}`),EG(i),this.migrations[i.sequenceId]=i;const n=Object.values(this.migrations).flatMap(i=>i.sequence);this.sortedMigrations=N1e(n);for(const i of this.sortedMigrations)if((o=i.dependsOn)!=null&&o.length)for(const s of i.dependsOn){const a=n.find(l=>l.id===s);Qe(a,`Migration '${i.id}' depends on missing migration '${s}'`)}}static create(e,r){return new Jk(e,r??{})}validateRecord(e,r,n,o){try{const i=Dn(this.types,r.typeName);if(!i)throw new Error(`Missing definition for record type ${r.typeName}`);return i.validate(r,o??void 0)}catch(i){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:e,record:r,phase:n,recordBefore:o,error:i});throw i}}getMigrationsSince(e){const r=F1e(e);if(!r.ok)return r;const n=r.value,o=new Set(Object.keys(n.sequences).filter(s=>this.migrations[s]));for(const s in this.migrations)n.sequences[s]===void 0&&this.migrations[s].retroactive&&o.add(s);if(o.size===0)return hn.ok([]);const i=new Set;for(const s of o){const a=n.sequences[s];if(typeof a!="number"&&this.migrations[s].retroactive||a===0){for(const u of this.migrations[s].sequence)i.add(u.id);continue}const l=`${s}/${a}`,c=this.migrations[s].sequence.findIndex(u=>u.id===l);if(c===-1)return hn.err("Incompatible schema?");for(const u of this.migrations[s].sequence.slice(c+1))i.add(u.id)}return hn.ok(this.sortedMigrations.filter(({id:s})=>i.has(s)))}migratePersistedRecord(e,r,n="up"){const o=this.getMigrationsSince(r);if(!o.ok)return console.error("Error migrating record",o.error),{type:"error",reason:ja.MigrationError};let i=o.value;if(i.length===0)return{type:"success",value:e};if(i.some(s=>s.scope==="store"))return{type:"error",reason:n==="down"?ja.TargetVersionTooOld:ja.TargetVersionTooNew};if(n==="down"){if(!i.every(s=>s.down))return{type:"error",reason:ja.TargetVersionTooOld};i=i.slice().reverse()}e=$t(e);try{for(const s of i){if(s.scope==="store")throw new Error;if(!(s.filter?s.filter(e):!0))continue;const l=s[n](e);l&&(e=$t(l))}}catch(s){return console.error("Error migrating record",s),{type:"error",reason:ja.MigrationError}}return{type:"success",value:e}}migrateStoreSnapshot(e){let{store:r}=e;const n=this.getMigrationsSince(e.schema);if(!n.ok)return console.error("Error migrating store",n.error),{type:"error",reason:ja.MigrationError};const o=n.value;if(o.length===0)return{type:"success",value:r};r=$t(r);try{for(const i of o)if(i.scope==="record")for(const[s,a]of Object.entries(r)){if(!(i.filter?i.filter(a):!0))continue;const c=i.up(a);c&&(r[s]=$t(c))}else if(i.scope==="store"){const s=i.up(r);s&&(r=$t(s))}else dr(i)}catch(i){return console.error("Error migrating store",i),{type:"error",reason:ja.MigrationError}}return{type:"success",value:r}}createIntegrityChecker(e){var r,n;return((n=(r=this.options).createIntegrityChecker)==null?void 0:n.call(r,e))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e,sequence:r})=>[e,r.length?qw(r.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e})=>[e,0]))}}getType(e){const r=Dn(this.types,e);return Qe(r,"record type does not exists"),r}}Ol("@tldraw/store","3.0.0","esm");function B1e(t){if(!t.length)return null;let e="";for(const r of t)typeof r=="number"?e+=`.${r}`:r.startsWith("(")?e.endsWith(")")?e=`${e.slice(0,-1)}, ${r.slice(1)}`:e+=r:e+=`.${r}`;return e=e.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),e.startsWith(".")?e.slice(1):e}class Ve extends Error{constructor(r,n=[]){const o=B1e(n),i=r.split(`
|
|
83
|
-
`).map((s,a)=>a===0?s:` ${s}`).join(`
|
|
84
|
-
`);super(n?`At ${o}: ${i}`:i);C(this,"name","ValidationError");this.rawMessage=r,this.path=n}}function Wn(t,e){try{return e()}catch(r){throw r instanceof Ve?new Ve(r.rawMessage,[t,...r.path]):new Ve(r.toString(),[t])}}function wl(t){if(t===null)return"null";if(Array.isArray(t))return"an array";const e=typeof t;switch(e){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${e}`;case"object":return`an ${e}`;case"undefined":return"undefined";default:dr(e)}}class Sn{constructor(e,r){this.validationFn=e,this.validateUsingKnownGoodVersionFn=r}validate(e){return this.validationFn(e)}validateUsingKnownGoodVersion(e,r){return Object.is(e,r)?e:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(e,r):this.validate(r)}isValid(e){try{return this.validate(e),!0}catch{return!1}}nullable(){return G1e(this)}optional(){return _G(this)}refine(e){return new Sn(r=>e(this.validate(r)),(r,n)=>{const o=this.validateUsingKnownGoodVersion(r,n);return Object.is(r,o)?r:e(o)})}check(e,r){return typeof e=="string"?this.refine(n=>(Wn(`(check ${e})`,()=>r(n)),n)):this.refine(n=>(e(n),n))}}class U1e extends Sn{constructor(e){super(r=>{const n=JL.validate(r);for(let o=0;o<n.length;o++)Wn(o,()=>e.validate(n[o]));return n},(r,n)=>{if(!e.validateUsingKnownGoodVersion)return this.validate(n);const o=JL.validate(n);let i=r.length!==o.length;for(let s=0;s<o.length;s++){const a=o[s];if(s>=r.length){i=!0,Wn(s,()=>e.validate(a));continue}if(Object.is(r[s],a))continue;const l=Wn(s,()=>e.validateUsingKnownGoodVersion(r[s],a));Object.is(l,r[s])||(i=!0)}return i?n:r}),this.itemValidator=e}nonEmpty(){return this.check(e=>{if(e.length===0)throw new Ve("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(e=>{if(e.length<=1)throw new Ve("Expected an array with length greater than 1")})}}class Zw extends Sn{constructor(e,r=!1){super(n=>{if(typeof n!="object"||n===null)throw new Ve(`Expected object, got ${wl(n)}`);for(const[o,i]of Object.entries(e))Wn(o,()=>{i.validate(Dn(n,o))});if(!r){for(const o of Object.keys(n))if(!yi(e,o))throw new Ve("Unexpected property",[o])}return n},(n,o)=>{if(typeof o!="object"||o===null)throw new Ve(`Expected object, got ${wl(o)}`);let i=!1;for(const[s,a]of Object.entries(e)){const l=Dn(n,s),c=Dn(o,s);if(Object.is(l,c))continue;const u=Wn(s,()=>{const d=a;return d.validateUsingKnownGoodVersion?d.validateUsingKnownGoodVersion(l,c):d.validate(c)});Object.is(u,l)||(i=!0)}if(!r){for(const s of Object.keys(o))if(!yi(e,s))throw new Ve("Unexpected property",[s])}for(const s of Object.keys(n))if(!yi(o,s)){i=!0;break}return i?o:n}),this.config=e,this.shouldAllowUnknownProperties=r}allowUnknownProperties(){return new Zw(this.config,!0)}extend(e){return new Zw({...this.config,...e})}}class Wx extends Sn{constructor(e,r,n,o){super(i=>{this.expectObject(i);const{matchingSchema:s,variant:a}=this.getMatchingSchemaAndVariant(i);return s===void 0?this.unknownValueValidation(i,a):Wn(`(${e} = ${a})`,()=>s.validate(i))},(i,s)=>{this.expectObject(s),this.expectObject(i);const{matchingSchema:a,variant:l}=this.getMatchingSchemaAndVariant(s);return a===void 0?this.unknownValueValidation(s,l):Dn(i,e)!==Dn(s,e)?Wn(`(${e} = ${l})`,()=>a.validate(s)):Wn(`(${e} = ${l})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(i,s):a.validate(s))}),this.key=e,this.config=r,this.unknownValueValidation=n,this.useNumberKeys=o}expectObject(e){if(typeof e!="object"||e===null)throw new Ve(`Expected an object, got ${wl(e)}`,[])}getMatchingSchemaAndVariant(e){const r=Dn(e,this.key);if(!this.useNumberKeys&&typeof r!="string")throw new Ve(`Expected a string for key "${this.key}", got ${wl(r)}`);if(this.useNumberKeys&&!Number.isFinite(Number(r)))throw new Ve(`Expected a number for key "${this.key}", got "${r}"`);return{matchingSchema:yi(this.config,r)?this.config[r]:void 0,variant:r}}validateUnknownVariants(e){return new Wx(this.key,this.config,e,this.useNumberKeys)}}class z1e extends Sn{constructor(e,r){super(n=>{if(typeof n!="object"||n===null)throw new Ve(`Expected object, got ${wl(n)}`);for(const[o,i]of Object.entries(n))Wn(o,()=>{e.validate(o),r.validate(i)});return n},(n,o)=>{if(typeof o!="object"||o===null)throw new Ve(`Expected object, got ${wl(o)}`);let i=!1;for(const[s,a]of Object.entries(o)){if(!yi(n,s)){i=!0,Wn(s,()=>{e.validate(s),r.validate(a)});continue}const l=Dn(n,s),c=a;if(Object.is(l,c))continue;const u=Wn(s,()=>r.validateUsingKnownGoodVersion?r.validateUsingKnownGoodVersion(l,c):r.validate(c));Object.is(u,l)||(i=!0)}for(const s of Object.keys(n))if(!yi(o,s)){i=!0;break}return i?o:n}),this.keyValidator=e,this.valueValidator=r}}function eO(t){return new Sn(e=>{if(typeof e!==t)throw new Ve(`Expected ${t}, got ${wl(e)}`);return e})}const H1e=new Sn(t=>t),Te=eO("string"),Se=eO("number").check(t=>{if(Number.isNaN(t))throw new Ve("Expected a number, got NaN");if(!Number.isFinite(t))throw new Ve(`Expected a finite number, got ${t}`)}),Qw=Se.check(t=>{if(t<0)throw new Ve(`Expected a positive number, got ${t}`)}),Zt=Se.check(t=>{if(t<=0)throw new Ve(`Expected a non-zero positive number, got ${t}`)}),CG=Se.check(t=>{if(!Number.isInteger(t))throw new Ve(`Expected an integer, got ${t}`)}),wS=CG.check(t=>{if(t<0)throw new Ve(`Expected a positive integer, got ${t}`)}),W1e=CG.check(t=>{if(t<=0)throw new Ve(`Expected a non-zero positive integer, got ${t}`)}),De=eO("boolean");function en(t){return new Sn(e=>{if(e!==t)throw new Ve(`Expected ${t}, got ${JSON.stringify(e)}`);return t})}const JL=new Sn(t=>{if(!Array.isArray(t))throw new Ve(`Expected an array, got ${wl(t)}`);return t});function Tr(t){return new U1e(t)}function Ne(t){return new Zw(t)}function J_(t){return typeof t=="object"&&t!==null&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null||Object.getPrototypeOf(t)===Zme)}function eT(t){return t===null||typeof t=="number"||typeof t=="string"||typeof t=="boolean"?!0:Array.isArray(t)?t.every(eT):J_(t)?Object.values(t).every(eT):!1}const Ar=new Sn(t=>{if(eT(t))return t;throw new Ve(`Expected json serializable value, got ${typeof t}`)},(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){let r=t.length!==e.length;for(let n=0;n<e.length;n++){if(n>=t.length){r=!0,Ar.validate(e[n]);continue}const o=t[n],i=e[n];if(Object.is(o,i))continue;const s=Ar.validateUsingKnownGoodVersion(o,i);Object.is(s,o)||(r=!0)}return r?e:t}else if(J_(t)&&J_(e)){let r=!1;for(const n of Object.keys(e)){if(!yi(t,n)){r=!0,Ar.validate(e[n]);continue}const o=t[n],i=e[n];if(Object.is(o,i))continue;const s=Ar.validateUsingKnownGoodVersion(o,i);Object.is(s,o)||(r=!0)}for(const n of Object.keys(t))if(!yi(e,n)){r=!0;break}return r?e:t}else return Ar.validate(e)});function Jw(t,e){return new z1e(t,e)}function tO(t,e){return new Wx(t,e,(r,n)=>{throw new Ve(`Expected one of ${Object.keys(e).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(n)}`,[t])},!1)}function K1e(t,e){return new Wx(t,e,(r,n)=>{throw new Ve(`Expected one of ${Object.keys(e).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(n)}`,[t])},!0)}function ws(t,e){return new Sn(r=>Wn(t,()=>e.validate(r)),(r,n)=>Wn(t,()=>e.validateUsingKnownGoodVersion?e.validateUsingKnownGoodVersion(r,n):e.validate(n)))}function Kx(t){return new Sn(e=>{if(!t.has(e)){const r=Array.from(t,n=>JSON.stringify(n)).join(" or ");throw new Ve(`Expected ${r}, got ${e}`)}return e})}function _G(t){return new Sn(e=>{if(e!==void 0)return t.validate(e)},(e,r)=>{if(!(e===void 0&&r===void 0)&&r!==void 0)return t.validateUsingKnownGoodVersion&&e!==void 0?t.validateUsingKnownGoodVersion(e,r):t.validate(r)})}function G1e(t){return new Sn(e=>e===null?null:t.validate(e),(e,r)=>r===null?null:t.validateUsingKnownGoodVersion&&e!==null?t.validateUsingKnownGoodVersion(e,r):t.validate(r))}function Gx(...t){return Kx(new Set(t))}function rO(t){try{return new URL(t)}catch{if(t.startsWith("/")||t.startsWith("./"))try{return new URL(t,"http://example.com")}catch{throw new Ve(`Expected a valid url, got ${JSON.stringify(t)}`)}throw new Ve(`Expected a valid url, got ${JSON.stringify(t)}`)}}const V1e=new Set(["http:","https:","mailto:"]),go=Te.check(t=>{if(t==="")return;const e=rO(t);if(!V1e.has(e.protocol.toLowerCase()))throw new Ve(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)}),Y1e=new Set(["http:","https:","data:","asset:"]),Dc=Te.check(t=>{if(t==="")return;const e=rO(t);if(!Y1e.has(e.protocol.toLowerCase()))throw new Ve(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)});Te.check(t=>{if(t==="")return;if(!rO(t).protocol.toLowerCase().match(/^https?:$/))throw new Ve(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)});const nO=Te.refine(t=>{try{return Bme(t),t}catch{throw new Ve(`Expected an index key, got ${JSON.stringify(t)}`)}});Ol("@tldraw/validate","3.0.0","esm");function uo(t){return Te.refine(e=>{if(!e.startsWith(`${t}:`))throw new Error(`${t} ID must start with "${t}:"`);return e})}const Vx=uo("asset");function oO(t,e){return Ne({id:Vx,typeName:en("asset"),type:en(t),props:e,meta:Ar})}const Lc=Ne({x:Se,y:Se,z:Se.optional()}),Tp=Ne({x:Se,y:Se,w:Se,h:Se}),TG=Se.check(t=>{if(t<0||t>1)throw new Ve("Opacity must be between 0 and 1")}),X1e=Te.refine(t=>{if(!t.startsWith("page:")&&!t.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return t}),Lo=uo("shape");function q1e(t,e,r){return Ne({id:Lo,typeName:en("shape"),x:Se,y:Se,rotation:Se,index:nO,parentId:X1e,type:en(t),isLocked:De,opacity:TG,props:e?Ne(e):Ar,meta:r?Ne(r):Ar})}const Z1e=uo("binding");function Q1e(t,e,r){return Ne({id:Z1e,typeName:en("binding"),type:en(t),fromId:Lo,toId:Lo,props:e?Ne(e):Ar,meta:r?Ne(r):Ar})}Kn("com.tldraw.binding",{});$o({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});function Pc(t){return`binding:${ct()}`}function J1e(t){return Ss("binding",{scope:"document",validator:ws("binding",tO("type",Ug(t,(e,{props:r,meta:n})=>Q1e(e,r,n))))}).withDefaultProperties(()=>({meta:{}}))}class Lr{constructor(e,r,n){this.id=e,this.defaultValue=r,this.type=n}static define(e,r){const{defaultValue:n,type:o=H1e}=r;return new Lr(e,n,o)}static defineEnum(e,r){const{defaultValue:n,values:o}=r;return new ebe(e,n,o)}setDefaultValue(e){this.defaultValue=e}validate(e){return this.type.validate(e)}validateUsingKnownGoodVersion(e,r){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(e,r):this.validate(r)}}class ebe extends Lr{constructor(e,r,n){super(e,r,Gx(...n)),this.values=n}}const bv=Kn("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),tbe=$o({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:bv.AddIsLocked,up:t=>{t.isLocked=!1},down:t=>{delete t.isLocked}},{id:bv.HoistOpacity,up:t=>{t.opacity=Number(t.props.opacity??"1"),delete t.props.opacity},down:t=>{const e=t.opacity;delete t.opacity,t.props.opacity=e<.175?"0.1":e<.375?"0.25":e<.625?"0.5":e<.875?"0.75":"1"}},{id:bv.AddMeta,up:t=>{t.meta={}}},{id:bv.AddWhite,up:t=>{},down:t=>{t.props.color==="white"&&(t.props.color="black")}}]});function dd(t){return t?t.typeName==="shape":!1}function Tn(t){return t?t.startsWith("shape:"):!1}function ot(t){return`shape:${t??ct()}`}function AG(t){const e=new Map;for(const[r,n]of Object.entries(t))if(n instanceof Lr){if(e.has(n))throw new Error(`Duplicate style prop ${n.id}. Each style prop can only be used once within a shape.`);e.set(n,r)}return e}function Ci(t,e){return Ug(e,(r,n)=>`com.tldraw.shape.${t}/${n}`)}function rbe(t){return Ss("shape",{scope:"document",validator:ws("shape",tO("type",Ug(t,(e,{props:r,meta:n})=>q1e(e,r,n))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}function eN(t,e){const r=[];for(const[n,{migrations:o}]of Object.entries(e)){const i=`com.tldraw.${t}.${n}`;o?"sequenceId"in o?(Qe(i===o.sequenceId,`sequenceId mismatch for ${n} ${zx} migrations. Expected '${i}', got '${o.sequenceId}'`),r.push(o)):"sequence"in o?r.push(Cd({sequenceId:i,retroactive:!1,sequence:o.sequence.map(s=>"id"in s?kG(t,n,s):s)})):r.push(Cd({sequenceId:i,retroactive:!1,sequence:Object.keys(o.migrators).map(s=>Number(s)).sort((s,a)=>s-a).map(s=>({id:`${i}/${s}`,scope:"record",filter:a=>a.typeName===t&&a.type===n,up:a=>{const l=o.migrators[s].up(a);if(l)return l},down:a=>{const l=o.migrators[s].down(a);if(l)return l}}))})):r.push(Cd({sequenceId:i,retroactive:!1,sequence:[]}))}return r}function kG(t,e,r){return{id:r.id,dependsOn:r.dependsOn,scope:"record",filter:n=>n.typeName===t&&n.type===e,up:n=>{const o=r.up(n.props);o&&(n.props=o)},down:typeof r.down=="function"?n=>{const o=r.down(n.props);o&&(n.props=o)}:void 0}}const OG=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],e0={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#1d1d1d",fill:"#1d1d1d",note:{fill:"#FCE19C",text:"#000000"},semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},blue:{solid:"#4465e9",fill:"#4465e9",note:{fill:"#8AA3FF",text:"#000000"},semi:"#dce1f8",pattern:"#6681ee",highlight:{srgb:"#10acff",p3:"color(display-p3 0.308 0.6632 0.9996)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#6FC896",text:"#000000"},semi:"#d3e9e3",pattern:"#39a785",highlight:{srgb:"#00ffc8",p3:"color(display-p3 0.2536 0.984 0.7981)"}},grey:{solid:"#9fa8b2",fill:"#9fa8b2",note:{fill:"#C0CAD3",text:"#000000"},semi:"#eceef0",pattern:"#bcc3c9",highlight:{srgb:"#cbe7f1",p3:"color(display-p3 0.8163 0.9023 0.9416)"}},"light-blue":{solid:"#4ba1f1",fill:"#4ba1f1",note:{fill:"#9BC4FD",text:"#000000"},semi:"#ddedfa",pattern:"#6fbbf8",highlight:{srgb:"#00f4ff",p3:"color(display-p3 0.1512 0.9414 0.9996)"}},"light-green":{solid:"#4cb05e",fill:"#4cb05e",note:{fill:"#98D08A",text:"#000000"},semi:"#dbf0e0",pattern:"#65cb78",highlight:{srgb:"#65f641",p3:"color(display-p3 0.563 0.9495 0.3857)"}},"light-red":{solid:"#f87777",fill:"#f87777",note:{fill:"#F7A5A1",text:"#000000"},semi:"#f4dadb",pattern:"#fe9e9e",highlight:{srgb:"#ff7fa3",p3:"color(display-p3 0.9988 0.5301 0.6397)"}},"light-violet":{solid:"#e085f4",fill:"#e085f4",note:{fill:"#DFB0F9",text:"#000000"},semi:"#f5eafa",pattern:"#e9acf8",highlight:{srgb:"#ff88ff",p3:"color(display-p3 0.9676 0.5652 0.9999)"}},orange:{solid:"#e16919",fill:"#e16919",note:{fill:"#FAA475",text:"#000000"},semi:"#f8e2d4",pattern:"#f78438",highlight:{srgb:"#ffa500",p3:"color(display-p3 0.9988 0.6905 0.266)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#FC8282",text:"#000000"},semi:"#f4dadb",pattern:"#e55959",highlight:{srgb:"#ff636e",p3:"color(display-p3 0.9992 0.4376 0.45)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#DB91FD",text:"#000000"},semi:"#ecdcf2",pattern:"#bd63d3",highlight:{srgb:"#c77cff",p3:"color(display-p3 0.7469 0.5089 0.9995)"}},yellow:{solid:"#f1ac4b",fill:"#f1ac4b",note:{fill:"#FED49A",text:"#000000"},semi:"#f9f0e6",pattern:"#fecb92",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},white:{solid:"#FFFFFF",fill:"#FFFFFF",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#FFFFFF",text:"#000000"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}},darkMode:{id:"dark",text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 6.5%)",solid:"#010403",black:{solid:"#f2f2f2",fill:"#f2f2f2",note:{fill:"#2c2c2c",text:"#f2f2f2"},semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},blue:{solid:"#4f72fc",fill:"#4f72fc",note:{fill:"#2A3F98",text:"#f2f2f2"},semi:"#262d40",pattern:"#3a4b9e",highlight:{srgb:"#0079d2",p3:"color(display-p3 0.0032 0.4655 0.7991)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#014429",text:"#f2f2f2"},semi:"#253231",pattern:"#366a53",highlight:{srgb:"#009774",p3:"color(display-p3 0.0085 0.582 0.4604)"}},grey:{solid:"#9398b0",fill:"#9398b0",note:{fill:"#56595F",text:"#f2f2f2"},semi:"#33373c",pattern:"#7c8187",highlight:{srgb:"#9cb4cb",p3:"color(display-p3 0.6299 0.7012 0.7856)"}},"light-blue":{solid:"#4dabf7",fill:"#4dabf7",note:{fill:"#1F5495",text:"#f2f2f2"},semi:"#2a3642",pattern:"#4d7aa9",highlight:{srgb:"#00bdc8",p3:"color(display-p3 0.0023 0.7259 0.7735)"}},"light-green":{solid:"#40c057",fill:"#40c057",note:{fill:"#21581D",text:"#f2f2f2"},semi:"#2a3830",pattern:"#4e874e",highlight:{srgb:"#00a000",p3:"color(display-p3 0.2711 0.6172 0.0195)"}},"light-red":{solid:"#ff8787",fill:"#ff8787",note:{fill:"#923632",text:"#f2f2f2"},semi:"#3b3235",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",fill:"#e599f7",note:{fill:"#762F8E",text:"#f2f2f2"},semi:"#383442",pattern:"#9770a9",highlight:{srgb:"#c400c7",p3:"color(display-p3 0.7024 0.0403 0.753)"}},orange:{solid:"#f76707",fill:"#f76707",note:{fill:"#843906",text:"#f2f2f2"},semi:"#3a2e2a",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#89231A",text:"#f2f2f2"},semi:"#36292b",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#681683",text:"#f2f2f2"},semi:"#31293c",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",fill:"#ffc034",note:{fill:"#98571B",text:"#f2f2f2"},semi:"#3c3934",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},white:{solid:"#f3f3f3",fill:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function ma(t){return t.isDarkMode?e0.darkMode:e0.lightMode}const mo=Lr.defineEnum("tldraw:color",{defaultValue:"black",values:OG}),MG=Lr.defineEnum("tldraw:labelColor",{defaultValue:"black",values:OG}),Nc=Lr.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),Fc=Lr.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill"]}),cs=Lr.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),RG={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},us=Lr.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),jG=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],t0=Lr.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:jG}),r0=Lr.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:jG}),DG={labelColor:MG,color:mo,fill:Fc,dash:Nc,size:us,arrowheadStart:t0,arrowheadEnd:r0,font:cs,start:Lc,end:Lc,bend:Se,text:Te,labelPosition:Se,scale:Zt},Bu=Ci("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5});function $v(t){return kG("shape","arrow",t)}const LG=Cd({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[$v({id:Bu.AddLabelColor,up:t=>{t.labelColor="black"},down:"retired"}),$v({id:Bu.AddIsPrecise,up:({start:t,end:e})=>{t.type==="binding"&&(t.isPrecise=!(t.normalizedAnchor.x===.5&&t.normalizedAnchor.y===.5)),e.type==="binding"&&(e.isPrecise=!(e.normalizedAnchor.x===.5&&e.normalizedAnchor.y===.5))},down:({start:t,end:e})=>{t.type==="binding"&&(t.isPrecise||(t.normalizedAnchor={x:.5,y:.5}),delete t.isPrecise),e.type==="binding"&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise)}}),$v({id:Bu.AddLabelPosition,up:t=>{t.labelPosition=.5},down:t=>{delete t.labelPosition}}),{id:Bu.ExtractBindings,scope:"store",up:t=>{const e=Object.values(t).filter(r=>r.typeName==="shape"&&r.type==="arrow");for(const r of e){const{start:n,end:o}=r.props;if(n.type==="binding"){const i=Pc(),s={typeName:"binding",id:i,type:"arrow",fromId:r.id,toId:n.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:n.normalizedAnchor,isExact:n.isExact,isPrecise:n.isPrecise}};t[i]=s,r.props.start={x:0,y:0}}else delete r.props.start.type;if(o.type==="binding"){const i=Pc(),s={typeName:"binding",id:i,type:"arrow",fromId:r.id,toId:o.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:o.normalizedAnchor,isExact:o.isExact,isPrecise:o.isPrecise}};t[i]=s,r.props.end={x:0,y:0}}else delete r.props.end.type}}},$v({id:Bu.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}})]}),NG={terminal:Gx("start","end"),normalizedAnchor:Lc,isExact:De,isPrecise:De},FG={sequence:[{dependsOn:[Bu.ExtractBindings]}]},nbe=ws("camera",Ne({typeName:en("camera"),id:uo("camera"),x:Se,y:Se,z:Se,meta:Ar})),obe=Kn("com.tldraw.camera",{AddMeta:1}),ibe=$o({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:obe.AddMeta,up:t=>{t.meta={}}}]}),qi=Ss("camera",{validator:nbe,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),sbe=new Set(["none","default","pointer","cross","grab","rotate","grabbing","resize-edge","resize-corner","text","move","ew-resize","ns-resize","nesw-resize","nwse-resize","nesw-rotate","nwse-rotate","swne-rotate","senw-rotate","zoom-in","zoom-out"]),BG=Kx(sbe),abe=Ne({type:BG,rotation:Se}),lbe=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),cbe=Kx(lbe),ube=new Set(["starting","paused","active","stopping"]),UG=Ne({id:Te,points:Tr(Lc),size:Qw,color:cbe,opacity:Se,state:Kx(ube),delay:Se,shrink:Se,taper:De}),mg=uo("page"),dbe=ws("page",Ne({typeName:en("page"),id:mg,name:Te,index:nO,meta:Ar})),hbe=Kn("com.tldraw.page",{AddMeta:1}),fbe=$o({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:hbe.AddMeta,up:t=>{t.meta={}}}]}),vo=Ss("page",{validator:dbe,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function En(t){return vo.isId(t)}const pbe={id:!1,typeName:!1,currentPageId:!1,opacityForNextShape:!1,stylesForNextShape:!1,followingUserId:!1,highlightedUserIds:!1,brush:!1,cursor:!1,scribbles:!1,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!1,chatMessage:!1,isChatting:!1,isPenMode:!1,isGridMode:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!1,openMenus:!1,isChangingStyle:!1,isReadonly:!0,meta:!1,duplicateProps:!1};function zG(t){return t?Cp(t,e=>pbe[e]):null}uo("instance");function gbe(t){const e={};for(const[n,o]of t)e[n]=_G(o);const r=ws("instance",Ne({typeName:en("instance"),id:uo("instance"),currentPageId:mg,followingUserId:Te.nullable(),brush:Tp.nullable(),opacityForNextShape:TG,stylesForNextShape:Ne(e),cursor:abe,scribbles:Tr(UG),isFocusMode:De,isDebugMode:De,isToolLocked:De,exportBackground:De,screenBounds:Tp,insets:Tr(De),zoomBrush:Tp.nullable(),isPenMode:De,isGridMode:De,chatMessage:Te,isChatting:De,highlightedUserIds:Tr(Te),isFocused:De,devicePixelRatio:Se,isCoarsePointer:De,isHoveringCanvas:De.nullable(),openMenus:Tr(Te),isChangingStyle:De,isReadonly:De,meta:Ar,duplicateProps:Ne({shapeIds:Tr(uo("shape")),offset:Ne({x:Se,y:Se})}).nullable()}));return Ss("instance",{validator:r,scope:"session",ephemeralKeys:{currentPageId:!1,meta:!1,followingUserId:!0,opacityForNextShape:!0,stylesForNextShape:!0,brush:!0,cursor:!0,scribbles:!0,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!0,isPenMode:!0,isGridMode:!0,chatMessage:!0,isChatting:!0,highlightedUserIds:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!0,openMenus:!0,isChangingStyle:!0,isReadonly:!0,duplicateProps:!0}}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const xt=Kn("com.tldraw.instance",{AddTransparentExportBgs:1,RemoveDialog:2,AddToolLockMode:3,RemoveExtraPropsForNextShape:4,AddLabelColor:5,AddFollowingUserId:6,RemoveAlignJustify:7,AddZoom:8,AddVerticalAlign:9,AddScribbleDelay:10,RemoveUserId:11,AddIsPenModeAndIsGridMode:12,HoistOpacity:13,AddChat:14,AddHighlightedUserIds:15,ReplacePropsForNextShapeWithStylesForNextShape:16,AddMeta:17,RemoveCursorColor:18,AddLonelyProperties:19,ReadOnlyReadonly:20,AddHoveringCanvas:21,AddScribbles:22,AddInset:23,AddDuplicateProps:24,RemoveCanMoveCamera:25}),mbe=$o({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:xt.AddTransparentExportBgs,up:t=>({...t,exportBackground:!0})},{id:xt.RemoveDialog,up:({dialog:t,...e})=>e},{id:xt.AddToolLockMode,up:t=>({...t,isToolLocked:!1})},{id:xt.RemoveExtraPropsForNextShape,up:({propsForNextShape:t,...e})=>({...e,propsForNextShape:Object.fromEntries(Object.entries(t).filter(([r])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(r)))})},{id:xt.AddLabelColor,up:({propsForNextShape:t,...e})=>({...e,propsForNextShape:{...t,labelColor:"black"}})},{id:xt.AddFollowingUserId,up:t=>({...t,followingUserId:null})},{id:xt.RemoveAlignJustify,up:t=>{let e=t.propsForNextShape.align;return e==="justify"&&(e="start"),{...t,propsForNextShape:{...t.propsForNextShape,align:e}}}},{id:xt.AddZoom,up:t=>({...t,zoomBrush:null})},{id:xt.AddVerticalAlign,up:t=>({...t,propsForNextShape:{...t.propsForNextShape,verticalAlign:"middle"}})},{id:xt.AddScribbleDelay,up:t=>t.scribble!==null?{...t,scribble:{...t.scribble,delay:0}}:{...t}},{id:xt.RemoveUserId,up:({userId:t,...e})=>e},{id:xt.AddIsPenModeAndIsGridMode,up:t=>({...t,isPenMode:!1,isGridMode:!1})},{id:xt.HoistOpacity,up:({propsForNextShape:{opacity:t,...e},...r})=>({...r,opacityForNextShape:Number(t??"1"),propsForNextShape:e})},{id:xt.AddChat,up:t=>({...t,chatMessage:"",isChatting:!1})},{id:xt.AddHighlightedUserIds,up:t=>({...t,highlightedUserIds:[]})},{id:xt.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:t,...e})=>({...e,stylesForNextShape:{}})},{id:xt.AddMeta,up:t=>({...t,meta:{}})},{id:xt.RemoveCursorColor,up:t=>{const{color:e,...r}=t.cursor;return{...t,cursor:r}}},{id:xt.AddLonelyProperties,up:t=>({...t,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:xt.ReadOnlyReadonly,up:({isReadOnly:t,...e})=>({...e,isReadonly:t})},{id:xt.AddHoveringCanvas,up:t=>({...t,isHoveringCanvas:null})},{id:xt.AddScribbles,up:({scribble:t,...e})=>({...e,scribbles:[]})},{id:xt.AddInset,up:t=>({...t,insets:[!1,!1,!1,!1]}),down:({insets:t,...e})=>({...e})},{id:xt.AddDuplicateProps,up:t=>({...t,duplicateProps:null}),down:({duplicateProps:t,...e})=>({...e})},{id:xt.RemoveCanMoveCamera,up:({canMoveCamera:t,...e})=>({...e}),down:t=>({...t,canMoveCamera:!0})}]}),fn="instance:instance",vbe=ws("instance_page_state",Ne({typeName:en("instance_page_state"),id:uo("instance_page_state"),pageId:mg,selectedShapeIds:Tr(Lo),hintingShapeIds:Tr(Lo),erasingShapeIds:Tr(Lo),hoveredShapeId:Lo.nullable(),editingShapeId:Lo.nullable(),croppingShapeId:Lo.nullable(),focusedGroupId:Lo.nullable(),meta:Ar})),gf=Kn("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),ybe=$o({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:gf.AddCroppingId,up(t){t.croppingShapeId=null}},{id:gf.RemoveInstanceIdAndCameraId,up(t){delete t.instanceId,delete t.cameraId}},{id:gf.AddMeta,up:t=>{t.meta={}}},{id:gf.RenameProperties,up:t=>{},down:t=>{}},{id:gf.RenamePropertiesAgain,up:t=>{t.selectedShapeIds=t.selectedIds,delete t.selectedIds,t.hintingShapeIds=t.hintingIds,delete t.hintingIds,t.erasingShapeIds=t.erasingIds,delete t.erasingIds,t.hoveredShapeId=t.hoveredId,delete t.hoveredId,t.editingShapeId=t.editingId,delete t.editingId,t.croppingShapeId=t.croppingShapeId??t.croppingId??null,delete t.croppingId,t.focusedGroupId=t.focusLayerId,delete t.focusLayerId},down:t=>{t.selectedIds=t.selectedShapeIds,delete t.selectedShapeIds,t.hintingIds=t.hintingShapeIds,delete t.hintingShapeIds,t.erasingIds=t.erasingShapeIds,delete t.erasingShapeIds,t.hoveredId=t.hoveredShapeId,delete t.hoveredShapeId,t.editingId=t.editingShapeId,delete t.editingShapeId,t.croppingId=t.croppingShapeId,delete t.croppingShapeId,t.focusLayerId=t.focusedGroupId,delete t.focusedGroupId}}]}),fi=Ss("instance_page_state",{validator:vbe,scope:"session",ephemeralKeys:{pageId:!1,selectedShapeIds:!1,editingShapeId:!1,croppingShapeId:!1,meta:!1,hintingShapeIds:!0,erasingShapeIds:!0,hoveredShapeId:!0,focusedGroupId:!0}}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),Sbe=ws("pointer",Ne({typeName:en("pointer"),id:uo("pointer"),x:Se,y:Se,lastActivityTimestamp:Se,meta:Ar})),wbe=Kn("com.tldraw.pointer",{AddMeta:1}),xbe=$o({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:wbe.AddMeta,up:t=>{t.meta={}}}]}),iO=Ss("pointer",{validator:Sbe,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),n0=iO.createId("pointer"),bbe=ws("instance_presence",Ne({typeName:en("instance_presence"),id:uo("instance_presence"),userId:Te,userName:Te,lastActivityTimestamp:Se,followingUserId:Te.nullable(),cursor:Ne({x:Se,y:Se,type:BG,rotation:Se}),color:Te,camera:Ne({x:Se,y:Se,z:Se}),screenBounds:Tp,selectedShapeIds:Tr(uo("shape")),currentPageId:uo("page"),brush:Tp.nullable(),scribbles:Tr(UG),chatMessage:Te,meta:Ar})),mf=Kn("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5}),$be=$o({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:mf.AddScribbleDelay,up:t=>{t.scribble!==null&&(t.scribble.delay=0)}},{id:mf.RemoveInstanceId,up:t=>{delete t.instanceId}},{id:mf.AddChatMessage,up:t=>{t.chatMessage=""}},{id:mf.AddMeta,up:t=>{t.meta={}}},{id:mf.RenameSelectedShapeIds,up:t=>{}}]}),Ibe=Ss("instance_presence",{validator:bbe,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:0,followingUserId:null,color:"#FF0000",camera:{x:0,y:0,z:1},cursor:{x:0,y:0,type:"default",rotation:0},screenBounds:{x:0,y:0,w:1,h:1},selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),Pbe=ws("document",Ne({typeName:en("document"),id:en("document:document"),gridSize:Se,name:Te,meta:Ar})),tN=Kn("com.tldraw.document",{AddName:1,AddMeta:2}),Ebe=$o({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:tN.AddName,up:t=>{t.name=""},down:t=>{delete t.name}},{id:tN.AddMeta,up:t=>{t.meta={}}}]}),sO=Ss("document",{validator:Pbe,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),tT=sO.createId("document");function Cbe(t,e){return t.index<e.index?-1:t.index>e.index?1:0}function rN(t){t.typeName==="asset"&&("src"in t&&(t.src="<redacted>"),"src"in t.props&&(t.props.src="<redacted>"))}function _be({error:t,phase:e,record:r,recordBefore:n}){throw Pk(t,{tags:{origin:"store.validateRecord",storePhase:e,isExistingValidationIssue:e==="initialize"},extras:{recordBefore:n?rN($t(n)):void 0,recordAfter:rN($t(r))}}),t}function Tbe(){return[vo.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function Abe(t){const e=t.query.ids("page"),r=t.query.records("instance_page_state"),n=()=>{if(!t.has(tT))return t.put([sO.create({id:tT,name:t.props.defaultName})]),n();if(!t.has(n0))return t.put([iO.create({id:n0})]),n();const o=e.get();if(o.size===0)return t.put(Tbe()),n();const i=()=>[...o].map(u=>t.get(u)).sort(Cbe)[0].id,s=t.get(fn);if(s){if(!o.has(s.currentPageId))return t.put([{...s,currentPageId:i()}]),n()}else return t.put([t.schema.types.instance.create({id:fn,currentPageId:i(),exportBackground:!0})]),n();const a=new Set,l=new Set;for(const u of o){const d=fi.createId(u);t.get(d)||a.add(d);const p=qi.createId(u);t.has(p)||l.add(p)}a.size>0&&t.put([...a].map(u=>fi.create({id:u,pageId:fi.parseId(u)}))),l.size>0&&t.put([...l].map(u=>qi.create({id:u})));const c=r.get();for(const u of c){if(!o.has(u.pageId)){t.remove([u.id]);continue}if(u.croppingShapeId&&!t.has(u.croppingShapeId))return t.put([{...u,croppingShapeId:null}]),n();if(u.focusedGroupId&&!t.has(u.focusedGroupId))return t.put([{...u,focusedGroupId:null}]),n();if(u.hoveredShapeId&&!t.has(u.hoveredShapeId))return t.put([{...u,hoveredShapeId:null}]),n();const d=u.selectedShapeIds.filter(g=>t.has(g));if(d.length!==u.selectedShapeIds.length)return t.put([{...u,selectedShapeIds:d}]),n();const f=u.hintingShapeIds.filter(g=>t.has(g));if(f.length!==u.hintingShapeIds.length)return t.put([{...u,hintingShapeIds:f}]),n();const p=u.erasingShapeIds.filter(g=>t.has(g));if(p.length!==u.erasingShapeIds.length)return t.put([{...u,erasingShapeIds:p}]),n()}};return n}const kbe=oO("bookmark",Ne({title:Te,description:Te,image:Te,favicon:Te,src:Dc.nullable()})),nN=Kn("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),Obe=$o({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:t=>t.type==="bookmark",sequence:[{id:nN.MakeUrlsValid,up:t=>{Dc.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:nN.AddFavicon,up:t=>{Dc.isValid(t.props.favicon)||(t.props.favicon="")},down:t=>{delete t.props.favicon}}]}),Mbe=oO("image",Ne({w:Se,h:Se,name:Te,isAnimated:De,mimeType:Te.nullable(),src:Dc.nullable(),fileSize:Zt.optional()})),vf=Kn("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),Rbe=$o({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:t=>t.type==="image",sequence:[{id:vf.AddIsAnimated,up:t=>{t.props.isAnimated=!1},down:t=>{delete t.props.isAnimated}},{id:vf.RenameWidthHeight,up:t=>{t.props.w=t.props.width,t.props.h=t.props.height,delete t.props.width,delete t.props.height},down:t=>{t.props.width=t.props.w,t.props.height=t.props.h,delete t.props.w,delete t.props.h}},{id:vf.MakeUrlsValid,up:t=>{Dc.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:vf.AddFileSize,up:t=>{t.props.fileSize=-1},down:t=>{delete t.props.fileSize}},{id:vf.MakeFileSizeOptional,up:t=>{t.props.fileSize===-1&&(t.props.fileSize=void 0)},down:t=>{t.props.fileSize===void 0&&(t.props.fileSize=-1)}}]}),jbe=oO("video",Ne({w:Se,h:Se,name:Te,isAnimated:De,mimeType:Te.nullable(),src:Dc.nullable(),fileSize:Se.optional()})),yf=Kn("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),Dbe=$o({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:t=>t.type==="video",sequence:[{id:yf.AddIsAnimated,up:t=>{t.props.isAnimated=!1},down:t=>{delete t.props.isAnimated}},{id:yf.RenameWidthHeight,up:t=>{t.props.w=t.props.width,t.props.h=t.props.height,delete t.props.width,delete t.props.height},down:t=>{t.props.width=t.props.w,t.props.height=t.props.h,delete t.props.w,delete t.props.h}},{id:yf.MakeUrlsValid,up:t=>{Dc.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:yf.AddFileSize,up:t=>{t.props.fileSize=-1},down:t=>{delete t.props.fileSize}},{id:yf.MakeFileSizeOptional,up:t=>{t.props.fileSize===-1&&(t.props.fileSize=void 0)},down:t=>{t.props.fileSize===void 0&&(t.props.fileSize=-1)}}]}),Lbe=ws("asset",tO("type",{image:Mbe,video:jbe,bookmark:kbe})),Nbe=Kn("com.tldraw.asset",{AddMeta:1}),Fbe=$o({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:Nbe.AddMeta,up:t=>{t.meta={}}}]}),Wa=Ss("asset",{validator:Lbe,scope:"document"}).withDefaultProperties(()=>({meta:{}})),HG={w:Zt,h:Zt,assetId:Vx.nullable(),url:go},oN=Ci("bookmark",{NullAssetId:1,MakeUrlsValid:2}),WG={sequence:[{id:oN.NullAssetId,up:t=>{t.assetId===void 0&&(t.assetId=null)},down:"retired"},{id:oN.MakeUrlsValid,up:t=>{go.isValid(t.url)||(t.url="")},down:t=>{}}]},KG=Ne({type:Gx("free","straight"),points:Tr(Lc)}),GG={color:mo,fill:Fc,dash:Nc,size:us,segments:Tr(KG),isComplete:De,isClosed:De,isPen:De,scale:Zt},iN=Ci("draw",{AddInPen:1,AddScale:2}),VG={sequence:[{id:iN.AddInPen,up:t=>{const{points:e}=t.segments[0];if(e.length===0){t.isPen=!1;return}let r=!(e[0].z===0||e[0].z===.5);e[1]&&(r=r&&!(e[1].z===0||e[1].z===.5)),t.isPen=r},down:"retired"},{id:iN.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},Bbe=/(^\/r\/[^/]+\/?$)/,Ube=[{hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(Bbe))return t}},{hostnames:["figma.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/?$/)){const r=e.searchParams.get("url");if(r)return r}}},{hostnames:["google.*"],fromEmbedUrl:t=>{const e=$e(t);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const n=e.searchParams.get("zoom"),[o,i]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${o},${i},${n}z`}}},{hostnames:["val.town"],fromEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(r)return`https://www.val.town/v/${r[1]}`}},{hostnames:["codesandbox.io"],fromEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(r)return`https://codesandbox.io/s/${r[1]}`}},{hostnames:["codepen.io"],fromEmbedUrl:t=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,r=t.match(e);if(r){const[n,o,i]=r;return`https://codepen.io/${o}/pen/${i}`}}},{hostnames:["scratch.mit.edu"],fromEmbedUrl:t=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,r=t.match(e);if(r){const[n,o]=r;return`https://scratch.mit.edu/projects/${o}`}}},{hostnames:["*.youtube.com","youtube.com","youtu.be"],fromEmbedUrl:t=>{const e=$e(t);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const n=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(n)return`https://www.youtube.com/watch?v=${n[1]}`}}},{hostnames:["calendar.google.*"],fromEmbedUrl:t=>{const e=$e(t),r=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&r){e.pathname="/calendar/u/0";const n=Array.from(e.searchParams.keys());for(const o of n)e.searchParams.delete(o);return e.searchParams.set("cid",r),e.href}}},{hostnames:["docs.google.*"],fromEmbedUrl:t=>{const e=$e(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const r=Array.from(e.searchParams.keys());for(const n of r)e.searchParams.delete(n);return e.href}}},{hostnames:["gist.github.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return t.split("/").pop()?t:void 0}},{hostnames:["replit.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{hostnames:["felt.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/map\//))return e.pathname=e.pathname.replace(/^\/embed/,""),e.href}},{hostnames:["open.spotify.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/(artist|album)\//))return e.origin+e.pathname.replace(/^\/embed/,"")}},{hostnames:["vimeo.com","player.vimeo.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="player.vimeo.com"){const r=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(r)return"https://vimeo.com/"+r[1]}}},{hostnames:["excalidraw.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hash.match(/#room=/))return t}},{hostnames:["observablehq.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","")}#cell-*`;if(e&&e.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","/d")}#cell-*`}},{hostnames:["desmos.com"],fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return t.replace("?embed","")}}],YG={w:Zt,h:Zt,url:Te},Iv=Ci("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),XG={sequence:[{id:Iv.GenOriginalUrlInEmbed,up:t=>{try{const e=t.url,r=new URL(e).host.replace("www.","");let n;for(const o of Ube)if(o.hostnames.includes(r))try{n=o.fromEmbedUrl(e)}catch(i){console.warn(i)}t.tmpOldUrl=t.url,t.url=n??""}catch{t.url="",t.tmpOldUrl=t.url}},down:"retired"},{id:Iv.RemoveDoesResize,up:t=>{delete t.doesResize},down:"retired"},{id:Iv.RemoveTmpOldUrl,up:t=>{delete t.tmpOldUrl},down:"retired"},{id:Iv.RemovePermissionOverrides,up:t=>{delete t.overridePermissions},down:"retired"}]},qG={w:Zt,h:Zt,name:Te},ZG={sequence:[]},o0=Lr.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),i0=Lr.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),pi=Lr.defineEnum("tldraw:geo",{defaultValue:"rectangle",values:["cloud","rectangle","ellipse","triangle","diamond","pentagon","hexagon","octagon","star","rhombus","rhombus-2","oval","trapezoid","arrow-right","arrow-left","arrow-up","arrow-down","x-box","check-box","heart"]}),QG={geo:pi,labelColor:MG,color:mo,fill:Fc,dash:Nc,size:us,font:cs,align:o0,verticalAlign:i0,url:go,w:Zt,h:Zt,growY:Qw,text:Te,scale:Zt},Ts=Ci("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9}),JG={sequence:[{id:Ts.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:Ts.AddLabelColor,up:t=>{t.labelColor="black"},down:"retired"},{id:Ts.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:Ts.AddCheckBox,up:t=>{},down:"retired"},{id:Ts.AddVerticalAlign,up:t=>{t.verticalAlign="middle"},down:"retired"},{id:Ts.MigrateLegacyAlign,up:t=>{let e;switch(t.align){case"start":e="start-legacy";break;case"end":e="end-legacy";break;default:e="middle-legacy";break}t.align=e},down:"retired"},{id:Ts.AddCloud,up:t=>{},down:"retired"},{id:Ts.MakeUrlsValid,up:t=>{go.isValid(t.url)||(t.url="")},down:t=>{}},{id:Ts.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},eV={},tV={sequence:[]},rV={color:mo,size:us,segments:Tr(KG),isComplete:De,isPen:De,scale:Zt},zbe=Ci("highlight",{AddScale:1}),nV={sequence:[{id:zbe.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},Hbe=Ne({topLeft:Lc,bottomRight:Lc}),oV={w:Zt,h:Zt,playing:De,url:go,assetId:Vx.nullable(),crop:Hbe.nullable(),flipX:De,flipY:De},Pv=Ci("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4}),iV={sequence:[{id:Pv.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:Pv.AddCropProp,up:t=>{t.crop=null},down:t=>{delete t.crop}},{id:Pv.MakeUrlsValid,up:t=>{go.isValid(t.url)||(t.url="")},down:t=>{}},{id:Pv.AddFlipProps,up:t=>{t.flipX=!1,t.flipY=!1},down:t=>{delete t.flipX,delete t.flipY}}]},s0=Lr.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),Wbe=Ne({id:Te,index:nO,x:Se,y:Se}),sV={color:mo,dash:Nc,size:us,spline:s0,points:Jw(Te,Wbe),scale:Zt},Sf=Ci("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),aV={sequence:[{id:Sf.AddSnapHandles,up:t=>{for(const e of Object.values(t.handles))e.canSnap=!0},down:"retired"},{id:Sf.RemoveExtraHandleProps,up:t=>{t.handles=yK(Object.values(t.handles).map(e=>[e.index,{x:e.x,y:e.y}]))},down:t=>{const e=Object.entries(t.handles).map(([r,n])=>({index:r,...n})).sort(qr);t.handles=Object.fromEntries(e.map((r,n)=>{const o=n===0?"start":n===e.length-1?"end":`handle:${r.index}`;return[o,{id:o,type:"vertex",canBind:!1,canSnap:!0,index:r.index,x:r.x,y:r.y}]}))}},{id:Sf.HandlesToPoints,up:t=>{const e=Object.entries(t.handles).map(([r,{x:n,y:o}])=>({x:n,y:o,index:r})).sort(qr);t.points=e.map(({x:r,y:n})=>({x:r,y:n})),delete t.handles},down:t=>{const e=pg(t.points.length);t.handles=Object.fromEntries(t.points.map((r,n)=>[e[n],{x:r.x,y:r.y}])),delete t.points}},{id:Sf.PointIndexIds,up:t=>{const e=pg(t.points.length);t.points=Object.fromEntries(t.points.map((r,n)=>{const o=e[n];return[o,{id:o,index:o,x:r.x,y:r.y}]}))},down:t=>{const e=Object.values(t.points).sort(qr);t.points=e.map(({x:r,y:n})=>({x:r,y:n}))}},{id:Sf.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},lV={color:mo,size:us,font:cs,fontSizeAdjustment:Qw,align:o0,verticalAlign:i0,growY:Qw,url:go,text:Te,scale:Zt},rc=Ci("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7}),cV={sequence:[{id:rc.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:rc.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:rc.MigrateLegacyAlign,up:t=>{switch(t.align){case"start":t.align="start-legacy";return;case"end":t.align="end-legacy";return;default:t.align="middle-legacy";return}},down:"retired"},{id:rc.AddVerticalAlign,up:t=>{t.verticalAlign="middle"},down:"retired"},{id:rc.MakeUrlsValid,up:t=>{go.isValid(t.url)||(t.url="")},down:t=>{}},{id:rc.AddFontSizeAdjustment,up:t=>{t.fontSizeAdjustment=0},down:t=>{delete t.fontSizeAdjustment}},{id:rc.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},rT=Lr.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),uV={color:mo,size:us,font:cs,textAlign:rT,w:Zt,text:Te,scale:Zt,autoSize:De},sN=Ci("text",{RemoveJustify:1,AddTextAlign:2}),dV={sequence:[{id:sN.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:sN.AddTextAlign,up:t=>{t.textAlign=t.align,delete t.align},down:t=>{t.align=t.textAlign,delete t.textAlign}}]},hV={w:Zt,h:Zt,time:Se,playing:De,url:go,assetId:Vx.nullable()},aN=Ci("video",{AddUrlProp:1,MakeUrlsValid:2}),fV={sequence:[{id:aN.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:aN.MakeUrlsValid,up:t=>{go.isValid(t.url)||(t.url="")},down:t=>{}}]},Ev=Kn("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),Kbe=Cd({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:Ev.RemoveCodeAndIconShapeTypes,scope:"store",up:t=>{for(const[e,r]of Hn(t))r.typeName==="shape"&&(r.type==="icon"||r.type==="code")&&delete t[e]}},{id:Ev.AddInstancePresenceType,scope:"store",up(t){}},{id:Ev.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:t=>{for(const[e,r]of Hn(t))r.typeName.match(/^(user|user_presence)$/)&&delete t[e]}},{id:Ev.RemoveUserDocument,scope:"store",up:t=>{for(const[e,r]of Hn(t))r.typeName.match("user_document")&&delete t[e]}}]}),Gbe={arrow:{migrations:LG,props:DG},bookmark:{migrations:WG,props:HG},draw:{migrations:VG,props:GG},embed:{migrations:XG,props:YG},frame:{migrations:ZG,props:qG},geo:{migrations:JG,props:QG},group:{migrations:tV,props:eV},highlight:{migrations:nV,props:rV},image:{migrations:iV,props:oV},line:{migrations:aV,props:sV},note:{migrations:cV,props:lV},text:{migrations:dV,props:uV},video:{migrations:fV,props:hV}},Vbe={arrow:{migrations:FG,props:NG}};function Ybe({shapes:t=Gbe,bindings:e=Vbe,migrations:r}={}){const n=new Map;for(const a of Rt(t))for(const l of AG(a.props??{}).keys()){if(n.has(l.id)&&n.get(l.id)!==l)throw new Error(`Multiple StyleProp instances with the same id: ${l.id}`);n.set(l.id,l)}const o=rbe(t),i=J1e(e),s=gbe(n);return Jk.create({asset:Wa,binding:i,camera:qi,document:sO,instance:s,instance_page_state:fi,page:vo,instance_presence:Ibe,pointer:iO,shape:o},{migrations:[Kbe,Fbe,ibe,Ebe,mbe,ybe,fbe,$be,xbe,tbe,Obe,Rbe,Dbe,...eN("shape",t),...eN("binding",e),...r??[]],onValidationFailure:_be,createIntegrityChecker:Abe})}const vg=[{locale:"id",label:"Bahasa Indonesia"},{locale:"ca",label:"Català"},{locale:"cs",label:"Čeština"},{locale:"da",label:"Danish"},{locale:"de",label:"Deutsch"},{locale:"en",label:"English"},{locale:"es",label:"Español"},{locale:"fr",label:"Français"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{locale:"no",label:"Norwegian"},{locale:"pl",label:"Polski"},{locale:"pt-br",label:"Português - Brasil"},{locale:"pt-pt",label:"Português - Europeu"},{locale:"ro",label:"Română"},{locale:"ru",label:"Russian"},{locale:"sl",label:"Slovenščina"},{locale:"fi",label:"Suomi"},{locale:"sv",label:"Svenska"},{locale:"vi",label:"Tiếng Việt"},{locale:"tr",label:"Türkçe"},{locale:"uk",label:"Ukrainian"},{locale:"he",label:"עברית"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ku",label:"کوردی"},{locale:"ne",label:"नेपाली"},{locale:"hi-in",label:"हिन्दी"},{locale:"te",label:"తెలుగు"},{locale:"th",label:"ภาษาไทย"},{locale:"my",label:"မြန်မာစာ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function Xbe(){const t=typeof window<"u"?window.navigator.languages??["en"]:["en"];return qbe(t)}function qbe(t){for(const e of t){const r=Zbe(e);if(r)return r}return"en"}const lN={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function Zbe(t){const e=vg.find(o=>o.locale===t.toLowerCase());if(e)return e.locale;const[r,n]=t.split(/[-_]/).map(o=>o.toLowerCase());if(n){const o=vg.find(i=>i.locale===r);if(o)return o.locale}return r in lN?lN[r]:null}Ol("@tldraw/tlschema","3.0.0","esm");function Yx(t,e){const r=ze.useRef(e);r.current=e;const[n,o,i]=ze.useMemo(()=>{let s=null;const a=u=>(s=u,()=>{s=null}),l=new _h(`useStateTracking(${t})`,()=>{var u;return(u=r.current)==null?void 0:u.call(r)},{scheduleEffect(){s==null||s()}});return[l,a,()=>l.scheduleCount]},[t]);return ze.useSyncExternalStore(o,i,i),ze.useEffect(()=>(n.attach(),n.maybeScheduleEffect(),()=>{n.detach()}),[n]),n.execute()}const cN={apply(t,e,r){return Yx(t.displayName??t.name??"tracked(???)",()=>t.apply(e,r))}},Qbe=Symbol.for("react.memo"),Jbe=Symbol.for("react.forward_ref");function yr(t){let e=null;const r=t.$$typeof;return r===Qbe&&(t=t.type,e=t.compare),r===Jbe?x.memo(x.forwardRef(new Proxy(t.render,cN))):x.memo(new Proxy(t,cN),e)}function e$e(){const t=arguments[0],e=arguments[1],r=arguments.length===3?void 0:arguments[2],n=arguments.length===3?arguments[2]:arguments[3];return x.useMemo(()=>Y(`useComputed(${t})`,e,r),n)}function qs(t,e,r=Xs){x.useEffect(()=>{const n=new _h(t,e);return n.attach(),n.execute(),()=>{n.detach()}},r)}function H(){const t=arguments,e=t.length===3?t[2]:[t[0]],r=t.length===3?t[0]:`useValue(${t[0].name})`,n=x.useRef(!0);n.current=!0;const o=x.useMemo(()=>t.length===1?t[0]:Y(r,()=>{if(n.current)return t[1]();try{return t[1]()}catch{return{}}}),e);try{const{subscribe:i,getSnapshot:s}=x.useMemo(()=>({subscribe:a=>Sl(`useValue(${r})`,()=>{o.get(),a()}),getSnapshot:()=>o.get()}),[o]);return x.useSyncExternalStore(i,s,s)}finally{n.current=!1}}Ol("@tldraw/state-react","3.0.0","esm");var pV={exports:{}};/*!
|
|
85
|
-
Copyright (c) 2018 Jed Watson.
|
|
86
|
-
Licensed under the MIT License (MIT), see
|
|
87
|
-
http://jedwatson.github.io/classnames
|
|
88
|
-
*/(function(t){(function(){var e={}.hasOwnProperty;function r(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,n(a)))}return i}function n(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return r.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)e.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}t.exports?(r.default=r,t.exports=r):window.classNames=r})()})(pV);var t$e=pV.exports;const pe=_l(t$e),gV="3.0.1",uN={major:"2024-09-13T14:36:29.063Z",minor:"2024-09-13T14:36:29.063Z",patch:"2024-09-14T07:22:17.269Z"},r$e={error:null};class aO extends x.Component{constructor(){super(...arguments);C(this,"state",r$e)}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r){var n,o;(o=(n=this.props).onError)==null||o.call(n,r)}render(){const{error:r}=this.state;if(r!==null){const{fallback:n}=this.props;return h.jsx(n,{error:r})}return this.props.children}}function yg({children:t,fallback:e,...r}){return e===null?t:h.jsx(aO,{fallback:e,...r,children:t})}const Xx=x.createContext(null);function F(){const t=ze.useContext(Xx);if(!t)throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return t}function n$e(){return h.jsx("div",{className:"tl-background"})}function Th(t,e,r,n,o,i){x.useLayoutEffect(()=>{const s=t.current;if(!s||e===void 0)return;let a=`translate(${e}px, ${r}px)`;n!==void 0&&(a+=` scale(${n})`),o!==void 0&&(a+=` rotate(${o}rad)`),i&&(a+=` translate(${i.x}px, ${i.y}px)`),s.style.transform=a})}const pr={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>1+--t*t*t*t*t,easeInOutQuint:t=>t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t,easeInSine:t=>1-Math.cos(t*Math.PI/2),easeOutSine:t=>Math.sin(t*Math.PI/2),easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,easeInExpo:t=>t<=0?0:Math.pow(2,10*t-10),easeOutExpo:t=>t>=1?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>t<=0?0:t>=1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2};class w{constructor(e=0,r=0,n=1){this.x=e,this.y=r,this.z=n}get pressure(){return this.z}set(e=this.x,r=this.y,n=this.z){return this.x=e,this.y=r,this.z=n,this}setTo({x:e=0,y:r=0,z:n=1}){return this.x=e,this.y=r,this.z=n,this}rot(e){if(e===0)return this;const{x:r,y:n}=this,o=Math.sin(e),i=Math.cos(e);return this.x=r*i-n*o,this.y=r*o+n*i,this}rotWith(e,r){if(r===0)return this;const n=this.x-e.x,o=this.y-e.y,i=Math.sin(r),s=Math.cos(r);return this.x=e.x+(n*s-o*i),this.y=e.y+(n*i+o*s),this}clone(){const{x:e,y:r,z:n}=this;return new w(e,r,n)}sub(e){return this.x-=e.x,this.y-=e.y,this}subXY(e,r){return this.x-=e,this.y-=r,this}subScalar(e){return this.x-=e,this.y-=e,this}add(e){return this.x+=e.x,this.y+=e.y,this}addXY(e,r){return this.x+=e,this.y+=r,this}addScalar(e){return this.x+=e,this.y+=e,this}clamp(e,r){return this.x=Math.max(this.x,e),this.y=Math.max(this.y,e),r!==void 0&&(this.x=Math.min(this.x,r),this.y=Math.min(this.y,r)),this}div(e){return this.x/=e,this.y/=e,this}divV(e){return this.x/=e.x,this.y/=e.y,this}mul(e){return this.x*=e,this.y*=e,this}mulV(e){return this.x*=e.x,this.y*=e.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(e,r){const n=w.Tan(e,this);return this.add(n.mul(r))}neg(){return this.x*=-1,this.y*=-1,this}cross(e){return this.x=this.y*e.z-this.z*e.y,this.y=this.z*e.x-this.x*e.z,this}dpr(e){return w.Dpr(this,e)}cpr(e){return w.Cpr(this,e)}len2(){return w.Len2(this)}len(){return w.Len(this)}pry(e){return w.Pry(this,e)}per(){const{x:e,y:r}=this;return this.x=r,this.y=-e,this}uni(){return w.Uni(this)}tan(e){return w.Tan(this,e)}dist(e){return w.Dist(this,e)}distanceToLineSegment(e,r){return w.DistanceToLineSegment(e,r,this)}slope(e){return w.Slope(this,e)}snapToGrid(e){return this.x=Math.round(this.x/e)*e,this.y=Math.round(this.y/e)*e,this}angle(e){return w.Angle(this,e)}toAngle(){return w.ToAngle(this)}lrp(e,r){return this.x=this.x+(e.x-this.x)*r,this.y=this.y+(e.y-this.y)*r,this}equals(e){return w.Equals(this,e)}equalsXY(e,r){return w.EqualsXY(this,e,r)}norm(){const e=this.len();return this.x=e===0?0:this.x/e,this.y=e===0?0:this.y/e,this}toFixed(){return w.ToFixed(this)}toString(){return w.ToString(w.ToFixed(this))}toJson(){return w.ToJson(this)}toArray(){return w.ToArray(this)}static Add(e,r){return new w(e.x+r.x,e.y+r.y)}static AddXY(e,r,n){return new w(e.x+r,e.y+n)}static Sub(e,r){return new w(e.x-r.x,e.y-r.y)}static SubXY(e,r,n){return new w(e.x-r,e.y-n)}static AddScalar(e,r){return new w(e.x+r,e.y+r)}static SubScalar(e,r){return new w(e.x-r,e.y-r)}static Div(e,r){return new w(e.x/r,e.y/r)}static Mul(e,r){return new w(e.x*r,e.y*r)}static DivV(e,r){return new w(e.x/r.x,e.y/r.y)}static MulV(e,r){return new w(e.x*r.x,e.y*r.y)}static Neg(e){return new w(-e.x,-e.y)}static Per(e){return new w(e.y,-e.x)}static Abs(e){return new w(Math.abs(e.x),Math.abs(e.y))}static Dist(e,r){return((e.y-r.y)**2+(e.x-r.x)**2)**.5}static DistMin(e,r,n){return(e.x-r.x)*(e.x-r.x)+(e.y-r.y)*(e.y-r.y)<n**2}static Dist2(e,r){return(e.x-r.x)*(e.x-r.x)+(e.y-r.y)*(e.y-r.y)}static Dpr(e,r){return e.x*r.x+e.y*r.y}static Cross(e,r){return new w(e.y*r.z-e.z*r.y,e.z*r.x-e.x*r.z)}static Cpr(e,r){return e.x*r.y-r.x*e.y}static Len2(e){return e.x*e.x+e.y*e.y}static Len(e){return(e.x*e.x+e.y*e.y)**.5}static Pry(e,r){return w.Dpr(e,r)/w.Len(r)}static Uni(e){return w.Div(e,w.Len(e))}static Tan(e,r){return w.Uni(w.Sub(e,r))}static Min(e,r){return new w(Math.min(e.x,r.x),Math.min(e.y,r.y))}static Max(e,r){return new w(Math.max(e.x,r.x),Math.max(e.y,r.y))}static From({x:e,y:r,z:n=1}){return new w(e,r,n)}static FromArray(e){return new w(e[0],e[1])}static Rot(e,r=0){const n=Math.sin(r),o=Math.cos(r);return new w(e.x*o-e.y*n,e.x*n+e.y*o)}static RotWith(e,r,n){const o=e.x-r.x,i=e.y-r.y,s=Math.sin(n),a=Math.cos(n);return new w(r.x+(o*a-i*s),r.y+(o*s+i*a))}static NearestPointOnLineThroughPoint(e,r,n){return w.Mul(r,w.Sub(n,e).pry(r)).add(e)}static NearestPointOnLineSegment(e,r,n,o=!0){if(w.Equals(e,n)||w.Equals(r,n))return w.From(n);const i=w.Tan(r,e),s=w.Add(e,w.Mul(i,w.Sub(n,e).pry(i)));if(o){if(s.x<Math.min(e.x,r.x))return w.Cast(e.x<r.x?e:r);if(s.x>Math.max(e.x,r.x))return w.Cast(e.x>r.x?e:r);if(s.y<Math.min(e.y,r.y))return w.Cast(e.y<r.y?e:r);if(s.y>Math.max(e.y,r.y))return w.Cast(e.y>r.y?e:r)}return s}static DistanceToLineThroughPoint(e,r,n){return w.Dist(n,w.NearestPointOnLineThroughPoint(e,r,n))}static DistanceToLineSegment(e,r,n,o=!0){return w.Dist(n,w.NearestPointOnLineSegment(e,r,n,o))}static Snap(e,r=1){return new w(Math.round(e.x/r)*r,Math.round(e.y/r)*r)}static Cast(e){return e instanceof w?e:w.From(e)}static Slope(e,r){return e.x===r.y?NaN:(e.y-r.y)/(e.x-r.x)}static IsNaN(e){return isNaN(e.x)||isNaN(e.y)}static Angle(e,r){return Math.atan2(r.y-e.y,r.x-e.x)}static Lrp(e,r,n){return w.Sub(r,e).mul(n).add(e)}static Med(e,r){return new w((e.x+r.x)/2,(e.y+r.y)/2)}static Equals(e,r){return Math.abs(e.x-r.x)<1e-4&&Math.abs(e.y-r.y)<1e-4}static EqualsXY(e,r,n){return e.x===r&&e.y===n}static Clockwise(e,r,n){return(n.x-e.x)*(r.y-e.y)-(r.x-e.x)*(n.y-e.y)<0}static Rescale(e,r){const n=w.Len(e);return new w(r*e.x/n,r*e.y/n)}static ScaleWithOrigin(e,r,n){return w.Sub(e,n).mul(r).add(n)}static ToFixed(e){return new w(Us(e.x),Us(e.y))}static ToInt(e){return new w(parseInt(e.x.toFixed(0)),parseInt(e.y.toFixed(0)),parseInt((e.z??0).toFixed(0)))}static ToCss(e){return`${e.x},${e.y}`}static Nudge(e,r,n){return w.Add(e,w.Tan(r,e).mul(n))}static ToString(e){return`${e.x}, ${e.y}`}static ToAngle(e){let r=Math.atan2(e.y,e.x);return r<0&&(r+=Math.PI*2),r}static FromAngle(e,r=1){return new w(Math.cos(e)*r,Math.sin(e)*r)}static ToArray(e){return[e.x,e.y,e.z]}static ToJson(e){const{x:r,y:n,z:o}=e;return{x:r,y:n,z:o}}static Average(e){const r=e.length,n=new w(0,0);if(r===0)return n;for(let o=0;o<r;o++)n.add(e[o]);return n.div(r)}static Clamp(e,r,n){return n===void 0?new w(Math.min(Math.max(e.x,r)),Math.min(Math.max(e.y,r))):new w(Math.min(Math.max(e.x,r),n),Math.min(Math.max(e.y,r),n))}static PointsBetween(e,r,n=6){const o=[];for(let i=0;i<n;i++){const s=pr.easeInQuad(i/(n-1)),a=w.Lrp(e,r,s);a.z=Math.min(1,.5+Math.abs(.5-o$e(s))*.65),o.push(a)}return o}static SnapToGrid(e,r=8){return new w(Math.round(e.x/r)*r,Math.round(e.y/r)*r)}}const o$e=t=>t<.5?2*t*t:-1+(4-2*t)*t;function Xe(t){return`${N(t.x)},${N(t.y)} `}function On(t,e){return`${N((t.x+e.x)/2)},${N((t.y+e.y)/2)} `}const Ze=Math.PI,vt=Ze/2,rt=Ze*2,i$e=Math.sin;function Pr(t,e,r){return Math.max(e,typeof r<"u"?Math.min(t,r):t)}function Cv(t,e=1e10){return t?Math.round(t*e)/e:0}function ul(t,e,r=1e-6){return Math.abs(t-e)<=r}function mV(t,e){const r=Math.pow(t-e,2)/Math.pow(t+e,2);return Ze*(t+e)*(1+3*r/(10+Math.sqrt(4-3*r)))}function dl(t){return t=t%rt,t<0?t=t+rt:t===0&&(t=0),t}function Jg(t,e){return t=dl(t),e=dl(e),t>e&&(e+=rt),e-t}function vV(t,e){return rt-Jg(t,e)}function xS(t,e){const r=(e-t)%rt;return 2*r%rt-r}function nT(t){return(rt+t)%rt}function a0(t,e){const r=rt/e;let n=Math.floor((nT(t)+r/2)/r)*r%rt;return n<Ze&&(n+=rt),n>Ze&&(n-=rt),n}function yV(t,e){return t===e||ul(t%(Math.PI/2)-e%(Math.PI/2),0)}function s$e(t){return t*Ze/180}function a$e(t){return t*180/Ze}function Bc(t,e,r){return new w(t.x,t.y).add(w.FromAngle(r,e))}function rI(t,e,r){const n=t/2,o=e/2,i=[];let s=1/0,a=-1/0,l=1/0,c=-1/0;for(let g=0;g<r;g++){const m=rt/r,S=-vt+g*m,y=n+n*Math.cos(S),v=o+o*Math.sin(S);y<s&&(s=y),v<l&&(l=v),y>a&&(a=y),v>c&&(c=v),i.push(new w(y,v))}const u=a-s,d=c-l,f=t-u,p=e-d;if(f!==0||p!==0)for(let g=0;g<i.length;g++){const m=i[g];m.x=(m.x-s)/u*t,m.y=(m.y-l)/d*e}return i}function wf(t,e,r,n){return t<n&&r<e}function li(t,e,r,n){const o=Math.max(t,r),i=Math.min(e,n);return o<=i?[o,i]:null}function dN(t,e,r){return(e.x-t.x)*(r.y-t.y)-(r.x-t.x)*(e.y-t.y)}function ho(t,e){let r=0,n,o;for(let i=0;i<e.length;i++){if(n=e[i],n.x===t.x&&n.y===t.y||(o=e[(i+1)%e.length],w.Dist(t,n)+w.Dist(t,o)===w.Dist(n,o)))return!0;n.y<=t.y?o.y>t.y&&dN(n,o,t)>0&&(r+=1):o.y<=t.y&&dN(n,o,t)<0&&(r-=1)}return r!==0}function N(t){return Math.round(t*1e4)/1e4}function Us(t){return Math.round(t*100)/100}const hN=t=>Math.abs(t)<Number.MAX_SAFE_INTEGER;function Ka(t,e,r){return r<0?Jg(t,e):vV(t,e)}function oT(t,e,r,n){let o;if(Math.abs(t)>Ze){o=xS(e,n);const i=xS(n,r);return Math.abs(o)<Math.abs(i)?o/t:(t-i)/t}else{o=xS(e,n);const i=o/t;return Math.sign(o)!==Math.sign(t)?Math.abs(i)>.5?1:0:i}}function l$e(t,e,r,n){const o=2*((e-t)%rt)%rt-(e-t)%rt;return n?(rt-Math.abs(o))*(r?1:-1):o}function lO(t,e,r){const n=-2*(t.x*(e.y-r.y)-t.y*(e.x-r.x)+e.x*r.y-r.x*e.y),o=((t.x*t.x+t.y*t.y)*(r.y-e.y)+(e.x*e.x+e.y*e.y)*(t.y-r.y)+(r.x*r.x+r.y*r.y)*(e.y-t.y))/n,i=((t.x*t.x+t.y*t.y)*(e.x-r.x)+(e.x*e.x+e.y*e.y)*(r.x-t.x)+(r.x*r.x+r.y*r.y)*(t.x-e.x))/n;return!Number.isFinite(o)||!Number.isFinite(i)?null:new w(o,i)}function c$e(t,e,r,n,o){if(r===null)return[w.From(t),w.From(e)];const i=[],s=w.Angle(r,t),a=w.Angle(r,e),l=Jg(s,a);for(let c=0;c<o;c++){const u=c/(o-1),d=s+l*u,f=Bc(r,n,d);i.push(f)}return i}const nI=({brush:t,color:e,opacity:r,className:n})=>{const o=x.useRef(null);Th(o,t.x,t.y);const i=N(Math.max(1,t.w)),s=N(Math.max(1,t.h));return h.jsx("svg",{className:"tl-overlays__item",ref:o,children:e?h.jsxs("g",{className:"tl-brush",opacity:r,children:[h.jsx("rect",{width:i,height:s,fill:e,opacity:.75}),h.jsx("rect",{width:i,height:s,fill:"none",stroke:e,opacity:.1})]}):h.jsx("rect",{className:`tl-brush tl-brush__default ${n}`,width:i,height:s})})},fN={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.1,.25,.5,1,2,4,8]},oI={duration:0,easing:pr.easeInOutCubic},pN={CAMERA_MOVE:-10},u$e=["top","right","bottom","left"],gN=0,cO=2,_v=1,mN=5,d$e=128;var iI={};const h$e={},SV=Pn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),Xt={logPreventDefaults:Pn("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:Pn("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:Pn("logElementRemoves",{defaults:{all:!1}}),debugSvg:Pn("debugSvg",{defaults:{all:!1}}),showFps:Pn("showFps",{defaults:{all:!1}}),measurePerformance:Pn("measurePerformance",{defaults:{all:!1}}),throwToBlob:Pn("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:Pn("reconnectOnPing",{defaults:{all:!1}}),debugCursors:Pn("debugCursors",{defaults:{all:!1}}),forceSrgb:Pn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:Pn("debugGeometry",{defaults:{all:!1}}),hideShapes:Pn("hideShapes",{defaults:{all:!1}}),editOnType:Pn("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const t=Element.prototype.removeChild;Sl("element removal logging",()=>{Xt.logElementRemoves.get()?Element.prototype.removeChild=function(e){return console.warn("[tldraw] removing child:",e),t.call(this,e)}:Element.prototype.removeChild=t})}function Pn(t,{defaults:e,shouldStoreForSession:r=!0}){return f$e({name:t,defaults:e,shouldStoreForSession:r})}function f$e(t){const e=g$e(t),r=t.shouldStoreForSession?p$e(t.name):null,n=fr(`debug:${t.name}`,r??e);return typeof window<"u"&&(t.shouldStoreForSession&&Sl(`debug:${t.name}`,()=>{const o=n.get();o===e?MK(`tldraw_debug:${t.name}`):Ok(`tldraw_debug:${t.name}`,JSON.stringify(o))}),Object.defineProperty(window,`tldraw${t.name.replace(/^[a-z]/,o=>o.toUpperCase())}`,{get(){return n.get()},set(o){n.set(o)},configurable:!0})),Object.assign(n,t)}function p$e(t){try{return JSON.parse(OK(`tldraw_debug:${t}`)??"null")}catch{return null}}function sI(t){try{return t()}catch{return null}}function g$e(t){switch(sI(()=>iI.TLDRAW_ENV)??sI(()=>iI.VERCEL_PUBLIC_TLDRAW_ENV)??sI(()=>iI.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return t.defaults.production??t.defaults.all;case"preview":case"staging":return t.defaults.staging??t.defaults.all;default:return t.defaults.development??t.defaults.all}}function l0(t){if(t instanceof HTMLElement)return t;if(t.parentElement)return l0(t.parentElement);throw Error("Could not find a parent element of an HTML type!")}function Ue(t){t.preventDefault(),Xt.logPreventDefaults.get()&&console.warn("preventDefault called on event:",t)}function em(t,e){if(t.setPointerCapture(e.pointerId),Xt.logPointerCaptures.get()){const r=SV.get();r.set(t,(r.get(t)??0)+1),console.warn("setPointerCapture called on element:",t,e)}}function tm(t,e){if(t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),Xt.logPointerCaptures.get())){const r=SV.get();r.get(t)===1?r.delete(t):r.has(t)?r.set(t,r.get(t)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",t,e)}}const mr=t=>t.stopPropagation(),Kr=(t,e,r)=>{t&&t.style.setProperty(e,r)};function Ln(t){return t.isKilled=!0,{point:{x:t.clientX,y:t.clientY,z:t.pressure},shiftKey:t.shiftKey,altKey:t.altKey,ctrlKey:t.metaKey||t.ctrlKey,pointerId:t.pointerId,button:t.button,isPen:t.pointerType==="pen"}}function wV(){const t=F();return x.useMemo(function(){let n,o;function i(m){if(!m.isKilled){if(m.button===cO){t.dispatch({type:"pointer",target:"canvas",name:"right_click",...Ln(m)});return}m.button!==0&&m.button!==1&&m.button!==5||(em(m.currentTarget,m),t.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...Ln(m)}))}}function s(m){m.isKilled||m.clientX===n&&m.clientY===o||(n=m.clientX,o=m.clientY,t.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...Ln(m)}))}function a(m){m.isKilled||m.button!==0&&m.button!==1&&m.button!==2&&m.button!==5||(n=m.clientX,o=m.clientY,tm(m.currentTarget,m),t.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...Ln(m)}))}function l(m){if(m.isKilled||t.getInstanceState().isPenMode&&m.pointerType!=="pen")return;const S=m.pointerType==="mouse"||m.pointerType==="pen";t.updateInstanceState({isHoveringCanvas:S?!0:null})}function c(m){if(m.isKilled||t.getInstanceState().isPenMode&&m.pointerType!=="pen")return;const S=m.pointerType==="mouse"||m.pointerType==="pen";t.updateInstanceState({isHoveringCanvas:S?!1:null})}function u(m){m.isKilled=!0,Ue(m)}function d(m){m.isKilled=!0,m.target instanceof HTMLElement&&m.target.tagName!=="A"&&m.target.tagName!=="TEXTAREA"&&!(t.getEditingShape()&&m.target.className.includes("tl-text-content"))&&Ue(m)}function f(m){Ue(m)}async function p(m){var y,v;if(Ue(m),!((v=(y=m.dataTransfer)==null?void 0:y.files)!=null&&v.length))return;const S=Array.from(m.dataTransfer.files);await t.putExternalContent({type:"files",files:S,point:t.screenToPage({x:m.clientX,y:m.clientY}),ignoreParent:!1})}function g(m){mr(m)}return{onPointerDown:i,onPointerMove:s,onPointerUp:a,onPointerEnter:l,onPointerLeave:c,onDragOver:f,onDrop:p,onTouchStart:u,onTouchEnd:d,onClick:g}},[t])}function m$e(){const t=F();x.useEffect(()=>{let e=t.getInstanceState().isCoarsePointer;const r=s=>{const a=s.pointerType!=="mouse";e!==a&&(e=a,t.updateInstanceState({isCoarsePointer:a}))};window.addEventListener("pointerdown",r,{capture:!0});const n=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),o=t.environment.isFirefox&&!t.environment.isAndroid&&!t.environment.isIos,i=()=>{const s=o?!1:n.matches;e===s&&(e=s,t.updateInstanceState({isCoarsePointer:s}))};return n&&(n.addEventListener("change",i),i()),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),n&&n.removeEventListener("change",i)}},[t])}const xV=x.createContext(null);function v$e({container:t,children:e}){return h.jsx(xV.Provider,{value:t,children:e})}function Sr(){return ro(x.useContext(xV),"useContainer used outside of <Tldraw />")}function y$e(){const t=F(),e=Sr(),r=H("isFocused",()=>t.getIsFocused(),[t]);x.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;let n=null;const o=()=>{n!=null&&n();const i=`(resolution: ${window.devicePixelRatio}dppx)`,s=matchMedia(i),a=l=>{l.type==="change"&&o()};s.addEventListener?s.addEventListener("change",o):s.addListener&&s.addListener(a),n=()=>{s.removeEventListener?s.removeEventListener("change",o):s.removeListener&&s.removeListener(a)},t.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return o(),()=>{n==null||n()}},[t]),x.useEffect(()=>{if(!r)return;const n=a=>{if(a.altKey&&(t.isIn("zoom")||!t.getPath().endsWith(".idle"))&&!Tv()&&Ue(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){Ue(a);return}break}case"Tab":{if(Tv()||t.getIsMenuOpen())return;break}case",":return;case"Escape":{if((t.getEditingShape()||t.getSelectedShapeIds().length>0)&&Ue(a),t.getOpenMenus().length>0)return;t.inputs.keys.has("Escape")||(t.inputs.keys.add("Escape"),t.cancel(),e.focus());return}default:if(Tv()||t.getIsMenuOpen())return}const l={type:"keyboard",name:a.repeat?"key_repeat":"key_down",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey};t.dispatch(l)},o=a=>{if(a.isKilled||(a.isKilled=!0,Tv()||t.getIsMenuOpen())||a.key===",")return;const l={type:"keyboard",name:"key_up",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey};t.dispatch(l)};function i(a){var l,c;if(e.contains(a.target)){const u=a.touches[0].pageX,d=a.touches[0].radiusX||0;(u-d<10||u+d>t.getViewportScreenBounds().width-10)&&(((l=a.target)==null?void 0:l.tagName)==="BUTTON"&&((c=a.target)==null||c.click()),Ue(a))}}const s=a=>{e.contains(a.target)&&(a.ctrlKey||a.metaKey)&&Ue(a)};return e.addEventListener("touchstart",i,{passive:!1}),e.addEventListener("wheel",s,{passive:!1}),document.addEventListener("gesturestart",Ue),document.addEventListener("gesturechange",Ue),document.addEventListener("gestureend",Ue),e.addEventListener("keydown",n),e.addEventListener("keyup",o),()=>{e.removeEventListener("touchstart",i),e.removeEventListener("wheel",s),document.removeEventListener("gesturestart",Ue),document.removeEventListener("gesturechange",Ue),document.removeEventListener("gestureend",Ue),e.removeEventListener("keydown",n),e.removeEventListener("keyup",o)}},[t,e,r])}const S$e=["input","select","button","textarea"];function Tv(){const{activeElement:t}=document;return!!(t&&(t.getAttribute("contenteditable")||S$e.indexOf(t.tagName.toLowerCase())>-1))}const w$e=["textarea","input"];function x$e(t){const e=F();x.useEffect(()=>{const r=t.current;if(!r)return;const n=o=>{var i;if(o instanceof PointerEvent&&o.pointerType==="pen"){o.isKilled=!0;const{target:s}=o;if(w$e.includes((i=s.tagName)==null?void 0:i.toLocaleLowerCase())||e.isIn("select.editing_shape"))return;Ue(o)}};return r.addEventListener("touchstart",n),r.addEventListener("touchend",n),()=>{r.removeEventListener("touchstart",n),r.removeEventListener("touchend",n)}},[e,t])}function b$e(t,e,r){return Math.max(e,Math.min(t,r))}const kr={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function vN(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function yN(t,e,r,n=.15){return n===0?b$e(t,e,r):t<e?-vN(e-t,r-e,n)+e:t>r?+vN(t-r,r-e,n)+r:t}function $$e(t,[e,r],[n,o]){const[[i,s],[a,l]]=t;return[yN(e,i,s,n),yN(r,a,l,o)]}function I$e(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function P$e(t){var e=I$e(t,"string");return typeof e=="symbol"?e:String(e)}function Vr(t,e,r){return e=P$e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function SN(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function Dt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?SN(Object(r),!0).forEach(function(n){Vr(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):SN(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const bV={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function wN(t){return t?t[0].toUpperCase()+t.slice(1):""}const E$e=["enter","leave"];function C$e(t=!1,e){return t&&!E$e.includes(e)}function _$e(t,e="",r=!1){const n=bV[t],o=n&&n[e]||e;return"on"+wN(t)+wN(o)+(C$e(r,o)?"Capture":"")}const T$e=["gotpointercapture","lostpointercapture"];function A$e(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=T$e.includes(e)?"capturecapture":"capture",o=!!~e.indexOf(n);return o&&(e=e.replace("capture","")),{device:e,capture:o,passive:r}}function k$e(t,e=""){const r=bV[t],n=r&&r[e]||e;return t+n}function $V(t){return"touches"in t}function O$e(t){return $V(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function M$e(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function iT(t,e){try{const r=e.clientX-t.clientX,n=e.clientY-t.clientY,o=(e.clientX+t.clientX)/2,i=(e.clientY+t.clientY)/2,s=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:s,origin:[o,i]}}catch{}return null}function R$e(t){return M$e(t).map(e=>e.identifier)}function xN(t,e){const[r,n]=Array.from(t.touches).filter(o=>e.includes(o.identifier));return iT(r,n)}const bN=40,$N=800;function IV(t){let{deltaX:e,deltaY:r,deltaMode:n}=t;return n===1?(e*=bN,r*=bN):n===2&&(e*=$N,r*=$N),[e,r]}function j$e(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:o,ctrlKey:i}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:o,ctrlKey:i})}return e}function c0(t,...e){return typeof t=="function"?t(...e):t}function D$e(){}function L$e(...t){return t.length===0?D$e:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function IN(t,e){return Object.assign({},e,t||{})}const N$e=32;class PV{constructor(e,r,n){this.ctrl=e,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:n,args:o}=this;r[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=o,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?c0(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:o}=this;r.args=this.args;let i=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,o.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,o.locked=!!document.pointerLockElement,Object.assign(o,j$e(e)),o.down=o.pressed=o.buttons%2===1||o.touches>0,i=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const E=r._delta.map(Math.abs);kr.addTo(r._distance,E)}this.axisIntent&&this.axisIntent(e);const[s,a]=r._movement,[l,c]=n.threshold,{_step:u,values:d}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(s)>=l&&d[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&d[1])):(u[0]===!1&&(u[0]=Math.abs(s)>=l&&Math.sign(s)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const f=[0,0];if(n.hasCustomTransform){const[E,T]=d;f[0]=u[0]!==!1?E-u[0]:0,f[1]=u[1]!==!1?T-u[1]:0}else f[0]=u[0]!==!1?s-u[0]:0,f[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(f);const p=r.offset,g=r._active&&!r._blocked||r.active;g&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=o[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=c0(n.bounds,r)),this.setup&&this.setup()),r.movement=f,this.computeOffset()));const[m,S]=r.offset,[[y,v],[b,$]]=r._bounds;r.overflow=[m<y?-1:m>v?1:0,S<b?-1:S>$?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const P=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=$$e(r._bounds,r.offset,P),r.delta=kr.sub(r.offset,p),this.computeMovement(),g&&(!r.last||i>N$e)){r.delta=kr.sub(r.offset,p);const E=r.delta.map(Math.abs);kr.addTo(r.distance,E),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&i>0&&(r.velocity=[E[0]/i,E[1]/i],r.timeDelta=i)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const o=this.handler(Dt(Dt(Dt({},r),e),{},{[this.aliasKey]:e.values}));o!==void 0&&(e.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function F$e([t,e],r){const n=Math.abs(t),o=Math.abs(e);if(n>o&&n>r)return"x";if(o>n&&o>r)return"y"}class B$e extends PV{constructor(...e){super(...e),Vr(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=kr.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=kr.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const o=typeof n.axisThreshold=="object"?n.axisThreshold[O$e(e)]:n.axisThreshold;r.axis=F$e(r._movement,o)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const U$e=t=>t,PN=.15,EV={enabled(t=!0){return t},eventOptions(t,e,r){return Dt(Dt({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[PN,PN];case!1:return[0,0];default:return kr.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return kr.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;return this.hasCustomTransform=!!n,n||U$e},threshold(t){return kr.toVector(t,0)}},z$e=0,rm=Dt(Dt({},EV),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=z$e){return t},bounds(t={}){if(typeof t=="function")return i=>rm.bounds(t(i));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:o=1/0}=t;return[[e,r],[n,o]]}}),nm=typeof window<"u"&&window.document&&window.document.createElement;function CV(){return nm&&"ontouchstart"in window}function H$e(){return CV()||nm&&window.navigator.maxTouchPoints>1}function W$e(){return nm&&"onpointerdown"in window}function K$e(){return nm&&"exitPointerLock"in window.document}function G$e(){try{return"constructor"in GestureEvent}catch{return!1}}const Uo={isBrowser:nm,gesture:G$e(),touch:CV(),touchscreen:H$e(),pointer:W$e(),pointerLock:K$e()},V$e=250,Y$e=180,X$e=.5,q$e=50,Z$e=250,Q$e=10,EN={mouse:0,touch:0,pen:8};Dt(Dt({},rm),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:o=!1}={}}){return this.pointerLock=n&&Uo.pointerLock,Uo.touch&&r?"touch":this.pointerLock?"mouse":Uo.pointer&&!o?"pointer":Uo.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?V$e:void 0,!(!Uo.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:o=!0}={}}){return this.pointerButtons=n,this.keys=o,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:o=void 0}){const i=kr.toVector(t,r?n:o?1:0);return this.filterTaps=r,this.tapsThreshold=n,i},swipe({velocity:t=X$e,distance:e=q$e,duration:r=Z$e}={}){return{velocity:this.transform(kr.toVector(t)),distance:this.transform(kr.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return Y$e;case!1:return 0;default:return t}},axisThreshold(t){return t?Dt(Dt({},EN),t):EN},keyboardDisplacement(t=Q$e){return t}});function _V(t){const[e,r]=t.overflow,[n,o]=t._delta,[i,s]=t._direction;(e<0&&n>0&&i<0||e>0&&n<0&&i>0)&&(t._movement[0]=t._movementBound[0]),(r<0&&o>0&&s<0||r>0&&o<0&&s>0)&&(t._movement[1]=t._movementBound[1])}const J$e=30,eIe=100;class tIe extends PV{constructor(...e){super(...e),Vr(this,"ingKey","pinching"),Vr(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:r,lastOffset:n}=this.state;e==="wheel"?this.state.offset=kr.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:r}=this.state;this.state.movement=[e[0]/r[0],e[1]-r[1]]}axisIntent(){const e=this.state,[r,n]=e._movement;if(!e.axis){const o=Math.abs(r)*J$e-Math.abs(n);o<0?e.axis="angle":o>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(i=>n.has(i))||n.size<2)return;this.start(e),r._touchIds=Array.from(n).slice(0,2);const o=xN(e,r._touchIds);o&&this.pinchStart(e,o)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const r=this.state,n=r._pointerEvents,o=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(s=>o.has(s))||(n.size<2&&n.set(e.pointerId,e),r._pointerEvents.size<2))return;this.start(e);const i=iT(...Array.from(n.values()));i&&this.pinchStart(e,i)}pinchStart(e,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const r=xN(e,this.state._touchIds);r&&this.pinchMove(e,r)}pointerMove(e){const r=this.state._pointerEvents;if(r.has(e.pointerId)&&r.set(e.pointerId,e),!this.state._active)return;const n=iT(...Array.from(r.values()));n&&this.pinchMove(e,n)}pinchMove(e,r){const n=this.state,o=n._values[1],i=r.angle-o;let s=0;Math.abs(i)>270&&(s+=Math.sign(i)),this.computeValues([r.distance,r.angle-360*s]),n.origin=r.origin,n.turns=s,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const r=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}r._pointerEvents.has(e.pointerId)&&r._pointerEvents.delete(e.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const r=this.state;r._active||(this.start(e),this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY];const n=r._movement;r._movement=[e.scale-1,e.rotation],r._delta=kr.sub(r._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>e[n]):!e[r])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-IV(e)[1]/eIe*n.offset[0],0],kr.addTo(n._movement,n._delta),_V(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const r=this.config.device;r&&(e(r,"start",this[r+"Start"].bind(this)),e(r,"change",this[r+"Move"].bind(this)),e(r,"end",this[r+"End"].bind(this)),e(r,"cancel",this[r+"End"].bind(this)),e("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const rIe=Dt(Dt({},EV),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!Uo.touch&&Uo.gesture)return"gesture";if(Uo.touch&&n)return"touch";if(Uo.touchscreen){if(Uo.pointer)return"pointer";if(Uo.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const o=s=>{const a=IN(c0(r,s),{min:-1/0,max:1/0});return[a.min,a.max]},i=s=>{const a=IN(c0(n,s),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof r!="function"&&typeof n!="function"?[o(),i()]:s=>[o(s),i(s)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",kr.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});Dt(Dt({},rm),{},{mouseOnly:(t=!0)=>t});class nIe extends B$e{constructor(...e){super(...e),Vr(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const r=this.state;r._delta=IV(e),kr.addTo(r._movement,r._delta),_V(r),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const oIe=rm;Dt(Dt({},rm),{},{mouseOnly:(t=!0)=>t});const uO=new Map,sT=new Map;function iIe(t){uO.set(t.key,t.engine),sT.set(t.key,t.resolver)}const sIe={key:"pinch",engine:tIe,resolver:rIe},aIe={key:"wheel",engine:nIe,resolver:oIe};function lIe(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function cIe(t,e){if(t==null)return{};var r=lIe(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const uIe={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=Uo.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dIe=["target","eventOptions","window","enabled","transform"];function bS(t={},e){const r={};for(const[n,o]of Object.entries(e))switch(typeof o){case"function":r[n]=o.call(r,t[n],n,t);break;case"object":r[n]=bS(t[n],o);break;case"boolean":o&&(r[n]=t[n]);break}return r}function hIe(t,e,r={}){const n=t,{target:o,eventOptions:i,window:s,enabled:a,transform:l}=n,c=cIe(n,dIe);if(r.shared=bS({target:o,eventOptions:i,window:s,enabled:a,transform:l},uIe),e){const u=sT.get(e);r[e]=bS(Dt({shared:r.shared},c),u)}else for(const u in c){const d=sT.get(u);d&&(r[u]=bS(Dt({shared:r.shared},c[u]),d))}return r}class TV{constructor(e,r){Vr(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,o,i){const s=this._listeners,a=k$e(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=Dt(Dt({},l),i);e.addEventListener(a,o,c);const u=()=>{e.removeEventListener(a,o,c),s.delete(u)};return s.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class fIe{constructor(){Vr(this,"_timeouts",new Map)}add(e,r,n=140,...o){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...o))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class pIe{constructor(e){Vr(this,"gestures",new Set),Vr(this,"_targetEventStore",new TV(this)),Vr(this,"gestureEventStores",{}),Vr(this,"gestureTimeoutStores",{}),Vr(this,"handlers",{}),Vr(this,"config",{}),Vr(this,"pointerIds",new Set),Vr(this,"touchIds",new Set),Vr(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gIe(this,e)}setEventIds(e){if($V(e))return this.touchIds=new Set(R$e(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=hIe(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,n={};let o;if(!(r.target&&(o=r.target(),!o))){if(r.enabled){for(const s of this.gestures){const a=this.config[s],l=CN(n,a.eventOptions,!!o);if(a.enabled){const c=uO.get(s);new c(this,e,s).bind(l)}}const i=CN(n,r.eventOptions,!!o);for(const s in this.nativeHandlers)i(s,"",a=>this.nativeHandlers[s](Dt(Dt({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=L$e(...n[i]);if(!o)return n;for(const i in n){const{device:s,capture:a,passive:l}=A$e(i);this._targetEventStore.add(o,s,"",n[i],{capture:a,passive:l})}}}}function $u(t,e){t.gestures.add(e),t.gestureEventStores[e]=new TV(t,e),t.gestureTimeoutStores[e]=new fIe}function gIe(t,e){e.drag&&$u(t,"drag"),e.wheel&&$u(t,"wheel"),e.scroll&&$u(t,"scroll"),e.move&&$u(t,"move"),e.pinch&&$u(t,"pinch"),e.hover&&$u(t,"hover")}const CN=(t,e,r)=>(n,o,i,s={},a=!1)=>{var l,c;const u=(l=s.capture)!==null&&l!==void 0?l:e.capture,d=(c=s.passive)!==null&&c!==void 0?c:e.passive;let f=a?n:_$e(n,o,u);r&&d&&(f+="Passive"),t[f]=t[f]||[],t[f].push(i)},mIe=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function vIe(t){const e={},r={},n=new Set;for(let o in t)mIe.test(o)?(n.add(RegExp.lastMatch),r[o]=t[o]):e[o]=t[o];return[r,e,n]}function Iu(t,e,r,n,o,i){if(!t.has(r)||!uO.has(n))return;const s=r+"Start",a=r+"End",l=c=>{let u;return c.first&&s in e&&e[s](c),r in e&&(u=e[r](c)),c.last&&a in e&&e[a](c),u};o[n]=l,i[n]=i[n]||{}}function yIe(t,e){const[r,n,o]=vIe(t),i={};return Iu(o,r,"onDrag","drag",i,e),Iu(o,r,"onWheel","wheel",i,e),Iu(o,r,"onScroll","scroll",i,e),Iu(o,r,"onPinch","pinch",i,e),Iu(o,r,"onMove","move",i,e),Iu(o,r,"onHover","hover",i,e),{handlers:i,config:e,nativeHandlers:n}}function SIe(t,e={},r,n){const o=ze.useMemo(()=>new pIe(t),[]);if(o.applyHandlers(t,n),o.applyConfig(e,r),ze.useEffect(o.effect.bind(o)),ze.useEffect(()=>o.clean.bind(o),[]),e.target===void 0)return o.bind.bind(o)}function wIe(t){return t.forEach(iIe),function(r,n){const{handlers:o,nativeHandlers:i,config:s}=yIe(r,n||{});return SIe(o,s,void 0,i)}}const _N=10,xIe=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function AV(t){let{deltaY:e,deltaX:r}=t,n=0;return t.ctrlKey||t.altKey||t.metaKey?n=(Math.abs(e)>_N?_N*Math.sign(e):e)/100:t.shiftKey&&!xIe&&(r=e,e=0),{x:-r,y:-e,z:-n}}const bIe=wIe([aIe,sIe]);let Pu;const $Ie=t=>Pu===void 0?(Pu=t,!1):t-Pu>120&&t-Pu<160?(Pu=t,!0):(Pu=t,!1);function IIe(t){const e=F(),r=x.useMemo(()=>{let n="not sure";const o=({event:m})=>{if(!e.getInstanceState().isFocused||(n="not sure",$Ie(Date.now())))return;const S=e.getEditingShapeId();if(S){const b=e.getShape(S);if(b&&e.getShapeUtil(b).canScroll(b)){const P=e.getShapePageBounds(S);if(P!=null&&P.containsPoint(e.inputs.currentPagePoint))return}}Ue(m),mr(m);const y=AV(m);if(y.x===0&&y.y===0)return;const v={type:"wheel",name:"wheel",delta:y,point:new w(m.clientX,m.clientY),shiftKey:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey};e.dispatch(v)};let i=1,s=1,a=1,l=0;const c=new w,u=new w,d=m=>{const S=t.current;n="not sure";const{event:y,origin:v,da:b}=m;y instanceof WheelEvent||(y.target===S||S!=null&&S.contains(y.target))&&(u.x=v[0],u.y=v[1],c.x=v[0],c.y=v[1],i=b[0],s=e.getZoomLevel(),e.dispatch({type:"pinch",name:"pinch_start",point:{x:v[0],y:v[1],z:e.getZoomLevel()},delta:{x:0,y:0},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey}))},f=m=>{if(m&&(n="zooming"),n==="zooming")return;const S=Math.abs(l-i),y=w.Dist(c,u);switch(n){case"not sure":{S>24?n="zooming":y>16&&(n="panning");break}case"panning":{S>64&&(n="zooming");break}}};return{onWheel:o,onPinchStart:d,onPinchEnd:m=>{const S=t.current,{event:y,origin:v,offset:b}=m;if(y instanceof WheelEvent||!(y.target===S||S!=null&&S.contains(y.target)))return;const $=b[0];n="not sure",e.timers.requestAnimationFrame(()=>{e.dispatch({type:"pinch",name:"pinch_end",point:{x:v[0],y:v[1],z:$},delta:{x:v[0],y:v[1]},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey})})},onPinch:m=>{const S=t.current,{event:y,origin:v,offset:b,da:$}=m;if(y instanceof WheelEvent||!(y.target===S||S!=null&&S.contains(y.target)))return;const P=m.type==="gesturechange"||m.type==="gestureend";l=$[0];const E=v[0]-u.x,T=v[1]-u.y;switch(u.x=v[0],u.y=v[1],f(P),n){case"zooming":{a=b[0],e.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:a},delta:{x:E,y:T},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey});break}case"panning":{e.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:s},delta:{x:E,y:T},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey});break}}}}},[e,t]);bIe(r,{target:t,eventOptions:{passive:!1},pinch:{from:()=>[e.getZoomLevel(),0],scaleBounds:()=>{const n=e.getBaseZoom(),o=e.getCameraOptions().zoomSteps,i=o[0]*n,s=o[o.length-1]*n;return{from:e.getZoomLevel(),max:s,min:i}}}})}function aI(t,e,r){const n=t.getShape(e),o=t.getShapeHandles(n);return{shape:n,handle:o.find(i=>i.id===r)}}function PIe(t,e){const r=F();return x.useMemo(()=>{const n=l=>{if(l.isKilled)return;const c=l0(l.currentTarget);em(c,l);const{shape:u,handle:d}=aI(r,t,e);d&&r.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_down",...Ln(l)})};let o,i;return{onPointerDown:n,onPointerMove:l=>{if(l.isKilled||l.clientX===o&&l.clientY===i)return;o=l.clientX,i=l.clientY;const{shape:c,handle:u}=aI(r,t,e);u&&r.dispatch({type:"pointer",target:"handle",handle:u,shape:c,name:"pointer_move",...Ln(l)})},onPointerUp:l=>{if(l.isKilled)return;const c=l0(l.currentTarget);tm(c,l);const{shape:u,handle:d}=aI(r,t,e);d&&r.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_up",...Ln(l)})}}},[r,t,e])}function EIe(t){const e=F();x.useLayoutEffect(()=>{const r=lK(()=>{t.current&&e.updateViewportScreenBounds(t.current)},200,{trailing:!0}),n=e.timers.setInterval(r,1e3);window.addEventListener("resize",r);const o=new ResizeObserver(a=>{a[0].contentRect&&r()}),i=t.current;let s=null;return i&&(o.observe(i),s=CIe(i),s.addEventListener("scroll",r)),()=>{clearInterval(n),window.removeEventListener("resize",r),o.disconnect(),s==null||s.removeEventListener("scroll",r),r.cancel()}},[e,t])}/*!
|
|
89
|
-
* Author: excalidraw
|
|
90
|
-
* MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
|
|
91
|
-
* https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
|
|
92
|
-
*/const CIe=t=>{let e=t.parentElement;for(;e;){if(e===document.body)return document;const{overflowY:r}=window.getComputedStyle(e);if(e.scrollHeight>e.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return e;e=e.parentElement}return document};class ee{constructor(e=0,r=0,n=0,o=0){C(this,"x",0);C(this,"y",0);C(this,"w",0);C(this,"h",0);this.x=e,this.y=r,this.w=n,this.h=o}get point(){return new w(this.x,this.y)}set point(e){this.x=e.x,this.y=e.y}get minX(){return this.x}set minX(e){this.x=e}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get minY(){return this.y}set minY(e){this.y=e}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get width(){return this.w}set width(e){this.w=e}get height(){return this.h}set height(e){this.h=e}get aspectRatio(){return this.width/this.height}get center(){return new w(this.midX,this.midY)}set center(e){this.minX=e.x-this.width/2,this.minY=e.y-this.height/2}get corners(){return[new w(this.minX,this.minY),new w(this.maxX,this.minY),new w(this.maxX,this.maxY),new w(this.minX,this.maxY)]}get cornersAndCenter(){return[new w(this.minX,this.minY),new w(this.maxX,this.minY),new w(this.maxX,this.maxY),new w(this.minX,this.maxY),this.center]}get sides(){const{corners:e}=this;return[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]]}get size(){return new w(this.w,this.h)}toFixed(){return this.x=Cv(this.x),this.y=Cv(this.y),this.w=Cv(this.w),this.h=Cv(this.h),this}setTo(e){return this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this}set(e=0,r=0,n=0,o=0){return this.x=e,this.y=r,this.w=n,this.h=o,this}expand(e){const r=Math.min(this.minX,e.minX),n=Math.min(this.minY,e.minY),o=Math.max(this.maxX,e.maxX),i=Math.max(this.maxY,e.maxY);return this.x=r,this.y=n,this.w=o-r,this.h=i-n,this}expandBy(e){return this.x-=e,this.y-=e,this.w+=e*2,this.h+=e*2,this}scale(e){return this.x/=e,this.y/=e,this.w/=e,this.h/=e,this}clone(){const{x:e,y:r,w:n,h:o}=this;return new ee(e,r,n,o)}translate(e){return this.x+=e.x,this.y+=e.y,this}snapToGrid(e){const r=Math.round(this.minX/e)*e,n=Math.round(this.minY/e)*e,o=Math.round(this.maxX/e)*e,i=Math.round(this.maxY/e)*e;this.minX=r,this.minY=n,this.width=Math.max(1,o-r),this.height=Math.max(1,i-n)}collides(e){return ee.Collides(this,e)}contains(e){return ee.Contains(this,e)}includes(e){return ee.Includes(this,e)}containsPoint(e,r=0){return ee.ContainsPoint(this,e,r)}getHandlePoint(e){switch(e){case"top_left":return new w(this.minX,this.minY);case"top_right":return new w(this.maxX,this.minY);case"bottom_left":return new w(this.minX,this.maxY);case"bottom_right":return new w(this.maxX,this.maxY);case"top":return new w(this.midX,this.minY);case"right":return new w(this.maxX,this.midY);case"bottom":return new w(this.midX,this.maxY);case"left":return new w(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(e,r,n){const{minX:o,minY:i,maxX:s,maxY:a}=this;let{minX:l,minY:c,maxX:u,maxY:d}=this;switch(e){case"left":case"top_left":case"bottom_left":{l+=r;break}case"right":case"top_right":case"bottom_right":{u+=r;break}}switch(e){case"top":case"top_left":case"top_right":{c+=n;break}case"bottom":case"bottom_left":case"bottom_right":{d+=n;break}}const f=(u-l)/(s-o),p=(d-c)/(a-i),g=f<0,m=p<0;if(g){const S=u;u=l,l=S}if(m){const S=d;d=c,c=S}this.minX=l,this.minY=c,this.width=Math.abs(u-l),this.height=Math.abs(d-c)}union(e){const r=Math.min(this.minX,e.x),n=Math.min(this.minY,e.y),o=Math.max(this.maxX,e.w+e.x),i=Math.max(this.maxY,e.h+e.y);return this.x=r,this.y=n,this.width=o-r,this.height=i-n,this}static From(e){return new ee(e.x,e.y,e.w,e.h)}static FromCenter(e,r){return new ee(e.x-r.x/2,e.y-r.y/2,r.x,r.y)}static FromPoints(e){if(e.length===0)return new ee;let r=1/0,n=1/0,o=-1/0,i=-1/0,s;for(let a=0,l=e.length;a<l;a++)s=e[a],r=Math.min(s.x,r),n=Math.min(s.y,n),o=Math.max(s.x,o),i=Math.max(s.y,i);return new ee(r,n,o-r,i-n)}static Expand(e,r){const n=Math.min(r.minX,e.minX),o=Math.min(r.minY,e.minY),i=Math.max(r.maxX,e.maxX),s=Math.max(r.maxY,e.maxY);return new ee(n,o,i-n,s-o)}static ExpandBy(e,r){return new ee(e.minX-r,e.minY-r,e.width+r*2,e.height+r*2)}static Collides(e,r){return!(e.maxX<r.minX||e.minX>r.maxX||e.maxY<r.minY||e.minY>r.maxY)}static Contains(e,r){return e.minX<r.minX&&e.minY<r.minY&&e.maxY>r.maxY&&e.maxX>r.maxX}static Includes(e,r){return ee.Collides(e,r)||ee.Contains(e,r)}static ContainsPoint(e,r,n=0){return!(r.x<e.minX-n||r.y<e.minY-n||r.x>e.maxX+n||r.y>e.maxY+n)}static Common(e){let r=1/0,n=1/0,o=-1/0,i=-1/0;for(let s=0;s<e.length;s++){const a=e[s];r=Math.min(r,a.minX),n=Math.min(n,a.minY),o=Math.max(o,a.maxX),i=Math.max(i,a.maxY)}return new ee(r,n,o-r,i-n)}static Sides(e,r=0){const{corners:n}=e;return[[n[0],n[1]],[n[1],n[2]],[n[2],n[3]],[n[3],n[0]]]}static Resize(e,r,n,o,i=!1){const{minX:s,minY:a,maxX:l,maxY:c}=e;let{minX:u,minY:d,maxX:f,maxY:p}=e;switch(r){case"left":case"top_left":case"bottom_left":{u+=n;break}case"right":case"top_right":case"bottom_right":{f+=n;break}}switch(r){case"top":case"top_left":case"top_right":{d+=o;break}case"bottom":case"bottom_left":case"bottom_right":{p+=o;break}}const g=(f-u)/(l-s),m=(p-d)/(c-a),S=g<0,y=m<0;if(i){const b=(l-s)/(c-a),$=Math.abs(f-u),P=Math.abs(p-d),E=$*(m<0?1:-1)*(1/b),T=P*(g<0?1:-1)*b,I=b<$/P;switch(r){case"top_left":{I?d=p+E:u=f+T;break}case"top_right":{I?d=p+E:f=u-T;break}case"bottom_right":{I?p=d-E:f=u-T;break}case"bottom_left":{I?p=d-E:u=f+T;break}case"bottom":case"top":{const _=(u+f)/2,k=P*b;u=_-k/2,f=_+k/2;break}case"left":case"right":{const _=(d+p)/2,k=$/b;d=_-k/2,p=_+k/2;break}}}if(S){const b=f;f=u,u=b}if(y){const b=p;p=d,d=b}const v=new ee(u,d,Math.abs(f-u),Math.abs(p-d));return{box:v,scaleX:+(v.width/e.width*(g>0?1:-1)).toFixed(5),scaleY:+(v.height/e.height*(m>0?1:-1)).toFixed(5)}}equals(e){return ee.Equals(this,e)}static Equals(e,r){return r.x===e.x&&r.y===e.y&&r.w===e.w&&r.h===e.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(e){return new ee(e.x,e.y,Math.max(1,e.w),Math.max(1,e.h))}}function _Ie(t){switch(t){case"top":return"bottom";case"bottom":return"top";case"top_left":return"bottom_left";case"top_right":return"bottom_right";case"bottom_left":return"top_left";case"bottom_right":return"top_right";default:return t}}function TIe(t){switch(t){case"left":return"right";case"right":return"left";case"top_left":return"top_right";case"top_right":return"top_left";case"bottom_left":return"bottom_right";case"bottom_right":return"bottom_left";default:return t}}function AIe(t){return t==="top_left"||t==="top_right"||t==="bottom_right"||t==="bottom_left"}class Q{constructor(e,r,n,o,i,s){C(this,"a",1);C(this,"b",0);C(this,"c",0);C(this,"d",1);C(this,"e",0);C(this,"f",0);this.a=e,this.b=r,this.c=n,this.d=o,this.e=i,this.f=s}equals(e){return this===e||this.a===e.a&&this.b===e.b&&this.c===e.c&&this.d===e.d&&this.e===e.e&&this.f===e.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(e){const r=e,{a:n,b:o,c:i,d:s,e:a,f:l}=this;return this.a=n*r.a+i*r.b,this.c=n*r.c+i*r.d,this.e=n*r.e+i*r.f+a,this.b=o*r.a+s*r.b,this.d=o*r.c+s*r.d,this.f=o*r.e+s*r.f+l,this}rotate(e,r,n){return e===0?this:r===void 0?this.multiply(Q.Rotate(e)):this.translate(r,n).multiply(Q.Rotate(e)).translate(-r,-n)}translate(e,r){return this.multiply(Q.Translate(e,r))}scale(e,r){return this.multiply(Q.Scale(e,r))}invert(){const{a:e,b:r,c:n,d:o,e:i,f:s}=this,a=e*o-r*n;return this.a=o/a,this.b=r/-a,this.c=n/-a,this.d=e/a,this.e=(o*i-n*s)/-a,this.f=(r*i-e*s)/a,this}applyToPoint(e){return Q.applyToPoint(this,e)}applyToPoints(e){return Q.applyToPoints(this,e)}rotation(){return Q.Rotation(this)}point(){return Q.Point(this)}decomposed(){return Q.Decompose(this)}toCssString(){return Q.toCssString(this)}setTo(e){return Object.assign(this,e),this}decompose(){return Q.Decompose(this)}clone(){return new Q(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new Q(1,0,0,1,0,0)}static Translate(e,r){return new Q(1,0,0,1,e,r)}static Rotate(e,r,n){if(e===0)return Q.Identity();const o=Math.cos(e),i=Math.sin(e),s=new Q(o,i,-i,o,0,0);return r===void 0?s:Q.Compose(Q.Translate(r,n),s,Q.Translate(-r,-n))}static Scale(e,r,n,o){const i=new Q(e,0,0,r,0,0);return n===void 0?i:Q.Compose(Q.Translate(n,o),i,Q.Translate(-n,-o))}static Multiply(e,r){return{a:e.a*r.a+e.c*r.b,c:e.a*r.c+e.c*r.d,e:e.a*r.e+e.c*r.f+e.e,b:e.b*r.a+e.d*r.b,d:e.b*r.c+e.d*r.d,f:e.b*r.e+e.d*r.f+e.f}}static Inverse(e){const r=e.a*e.d-e.b*e.c;return{a:e.d/r,b:e.b/-r,c:e.c/-r,d:e.a/r,e:(e.d*e.e-e.c*e.f)/-r,f:(e.b*e.e-e.a*e.f)/r}}static Absolute(e){const r=e.a*e.d-e.b*e.c;return{a:e.d/r,b:e.b/-r,c:e.c/-r,d:e.a/r,e:(e.d*e.e-e.c*e.f)/r,f:(e.b*e.e-e.a*e.f)/-r}}static Compose(...e){const r=Q.Identity();for(let n=0,o=e.length;n<o;n++)r.multiply(e[n]);return r}static Point(e){return new w(e.e,e.f)}static Rotation(e){let r;if(e.a!==0||e.c!==0){const n=(e.a*e.a+e.c*e.c)**.5;r=Math.acos(e.a/n)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const n=(e.b*e.b+e.d*e.d)**.5;r=vt+Math.acos(e.b/n)*(e.d>0?-1:1)}else r=0;return nT(r)}static Decompose(e){let r,n,o;if(e.a!==0||e.c!==0){const i=(e.a*e.a+e.c*e.c)**.5;r=i,n=(e.a*e.d-e.b*e.c)/i,o=Math.acos(e.a/i)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const i=(e.b*e.b+e.d*e.d)**.5;r=(e.a*e.d-e.b*e.c)/i,n=i,o=vt+Math.acos(e.b/i)*(e.d>0?-1:1)}else r=0,n=0,o=0;return{x:e.e,y:e.f,scaleX:r,scaleY:n,rotation:nT(o)}}static Smooth(e,r=1e10){return e.a=Math.round(e.a*r)/r,e.b=Math.round(e.b*r)/r,e.c=Math.round(e.c*r)/r,e.d=Math.round(e.d*r)/r,e.e=Math.round(e.e*r)/r,e.f=Math.round(e.f*r)/r,e}static toCssString(e){return`matrix(${N(e.a)}, ${N(e.b)}, ${N(e.c)}, ${N(e.d)}, ${N(e.e)}, ${N(e.f)})`}static applyToPoint(e,r){return new w(e.a*r.x+e.c*r.y+e.e,e.b*r.x+e.d*r.y+e.f,r.z)}static applyToXY(e,r,n){return[e.a*r+e.c*n+e.e,e.b*r+e.d*n+e.f]}static applyToPoints(e,r){return r.map(n=>new w(e.a*n.x+e.c*n.y+e.e,e.b*n.x+e.d*n.y+e.f,n.z))}static applyToBounds(e,r){return new ee(e.e+r.minX,e.f+r.minY,r.width,r.height)}static From(e){return new Q(e.a,e.b,e.c,e.d,e.e,e.f)}static Cast(e){return e instanceof Q?e:Q.From(e)}}class Fl{constructor(e){C(this,"isFilled",!1);C(this,"isClosed",!0);C(this,"isLabel",!1);C(this,"debugColor");C(this,"ignore");C(this,"_vertices");C(this,"_bounds");C(this,"_area");C(this,"_length");this.isFilled=e.isFilled,this.isClosed=e.isClosed,this.isLabel=e.isLabel??!1,this.debugColor=e.debugColor,this.ignore=e.ignore}hitTestPoint(e,r=0,n=!1){return this.isClosed&&(this.isFilled||n)&&ho(e,this.vertices)?!0:w.Dist2(e,this.nearestPoint(e))<=r*r}distanceToPoint(e,r=!1){return e.dist(this.nearestPoint(e))*(this.isClosed&&(this.isFilled||r)&&ho(e,this.vertices)?-1:1)}distanceToLineSegment(e,r){if(e.equals(r))return this.distanceToPoint(e);const{vertices:n}=this;let o,i=1/0,s,a,l;for(let c=0;c<n.length;c++)a=n[c],l=w.NearestPointOnLineSegment(e,r,a,!0),s=w.Dist2(a,l),s<i&&(i=s,o=l);if(!o)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&ho(o,this.vertices)?-i:i}hitTestLineSegment(e,r,n=0){return this.distanceToLineSegment(e,r)<=n}nearestPointOnLineSegment(e,r){const{vertices:n}=this;let o,i=1/0,s,a,l;for(let c=0;c<n.length;c++)a=n[c],l=w.NearestPointOnLineSegment(e,r,a,!0),s=w.Dist2(a,l),s<i&&(i=s,o=l);if(!o)throw Error("nearest point not found");return o}isPointInBounds(e,r=0){const{bounds:n}=this;return!(e.x<n.minX-r||e.y<n.minY-r||e.x>n.maxX+r||e.y>n.maxY+r)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return ee.FromPoints(this.vertices)}get bounds(){return this._bounds||(this._bounds=this.getBounds()),this._bounds}get center(){return this.bounds.center}get area(){return this._area||(this._area=this.getArea()),this._area}getArea(){if(!this.isClosed)return 0;const{vertices:e}=this;let r=0;for(let n=0,o=e.length;n<o;n++){const i=e[n],s=e[(n+1)%o];r+=i.x*s.y-s.x*i.y}return r/2}toSimpleSvgPath(){let e="";const{vertices:r}=this,n=r.length;if(n===0)return e;e+=`M${r[0].x},${r[0].y}`;for(let o=1;o<n;o++)e+=`L${r[o].x},${r[o].y}`;return this.isClosed&&(e+="Z"),e}get length(){return this._length?this._length:(this._length=this.getLength(),this._length)}getLength(){const{vertices:e}=this;let r,n=e[0],o=0;for(let i=1;i<e.length;i++)r=e[i],o+=w.Dist2(n,r),n=r;return Math.sqrt(o)}}class bi extends Fl{constructor(r){super({...r,isClosed:!0,isFilled:!1});C(this,"children",[]);C(this,"ignoredChildren",[]);for(const n of r.children)n.ignore?this.ignoredChildren.push(n):this.children.push(n);if(this.children.length===0)throw Error("Group2d must have at least one child")}getVertices(){return this.children.filter(r=>!r.isLabel).flatMap(r=>r.vertices)}nearestPoint(r){let n=1/0,o;const{children:i}=this;if(i.length===0)throw Error("no children");let s,a;for(const l of i)s=l.nearestPoint(r),a=w.Dist2(s,r),a<n&&(n=a,o=s);if(!o)throw Error("nearest point not found");return o}distanceToPoint(r,n=!1){return Math.min(...this.children.map((o,i)=>o.distanceToPoint(r,n||i>0)))}hitTestPoint(r,n,o){return!!this.children.filter(i=>!i.isLabel).find(i=>i.hitTestPoint(r,n,o))}hitTestLineSegment(r,n,o){return!!this.children.filter(i=>!i.isLabel).find(i=>i.hitTestLineSegment(r,n,o))}getArea(){return this.children[0].area}toSimpleSvgPath(){let r="";for(const o of this.children)r+=o.toSimpleSvgPath();const n=ee.FromPoints(this.vertices).corners;for(let o=0,i=n.length;o<i;o++){const s=n[o],a=n[(o-1+i)%i],l=s.dist(a),c=n[(o+1)%i],u=s.dist(c),d=s.clone().lrp(a,4/l),f=s,p=s.clone().lrp(c,4/u);r+=`M${d.x},${d.y} L${f.x},${f.y} L${p.x},${p.y} `}return r}getLength(){return this.children.reduce((r,n)=>n.isLabel?r:r+n.length,0)}getSvgPathData(){return this.children.map((r,n)=>r.isLabel?"":r.getSvgPathData(n===0)).join(" ")}}function kIe(t=!0){const[e,r]=x.useState(0),n=F();x.useEffect(()=>{if(!t)return;const o=()=>r(i=>i+1);return n.on("tick",o),()=>{n.off("tick",o)}},[n,t])}const OIe=yr(function({showStroke:e=!0,showVertices:r=!0,showClosestPointOnOutline:n=!0}){const o=F();kIe(n);const i=o.getZoomLevel(),s=o.getRenderingShapes(),{inputs:{currentPagePoint:a}}=o;return h.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:s.map(l=>{const c=o.getShape(l.id);if(c.type==="group")return null;const u=o.getShapeGeometry(c),d=o.getShapePageTransform(c),f=o.getPointInShapeSpace(c,a),p=u.nearestPoint(f),g=u.distanceToPoint(f,!0),m=Math.abs(g)*i,S=g<0,{vertices:y}=u;return h.jsxs("g",{transform:d.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[e&&h.jsx("g",{stroke:u.debugColor??"red",opacity:"1",strokeWidth:2/i,fill:"none",children:h.jsx(kV,{geometry:u})}),r&&y.map((v,b)=>h.jsx("circle",{cx:v.x,cy:v.y,r:2/i,fill:`hsl(${Xd(b,[0,y.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:1/i},`v${b}`)),n&&m<150&&h.jsx("line",{x1:p.x,y1:p.y,x2:f.x,y2:f.y,opacity:1-m/150,stroke:S?"goldenrod":"dodgerblue",strokeWidth:2/i})]},l.id+"_outline")})})});function kV({geometry:t}){return t instanceof bi?h.jsx(h.Fragment,{children:[...t.children,...t.ignoredChildren].map((e,r)=>h.jsx(kV,{geometry:e},r))}):h.jsx("path",{d:t.toSimpleSvgPath()})}function OV(t){return lme(t)}function MV(){const t=F(),e=e$e("userIds",()=>OV(t.getCollaborators().map(r=>r.userId)).sort(),{isEqual:(r,n)=>{var o;return r.join(",")===((o=n.join)==null?void 0:o.call(n,","))}},[t]);return H(e)}function qx(t){const e=F();return H(`latestPresence:${t}`,()=>e.getCollaborators().find(n=>n.userId===t),[e,t])??null}const MIe=yr(function(){return MV().map(r=>h.jsx(RIe,{collaboratorId:r},r))}),RIe=yr(function({collaboratorId:e}){const r=F(),n=qx(e),o=DIe(r,n);if(!(n&&n.currentPageId===r.getCurrentPageId()))return null;switch(o){case"inactive":{const{followingUserId:i,highlightedUserIds:s}=r.getInstanceState();if(!(i===n.userId||s.includes(n.userId)))return null;break}case"idle":{const{highlightedUserIds:i}=r.getInstanceState();if(n.followingUserId===r.user.getId()&&!(n.chatMessage||i.includes(n.userId)))return null;break}}return h.jsx(jIe,{latestPresence:n})}),jIe=yr(function({latestPresence:e}){const r=F(),{CollaboratorBrush:n,CollaboratorScribble:o,CollaboratorCursor:i,CollaboratorHint:s,CollaboratorShapeIndicator:a}=Pt(),l=r.getZoomLevel(),c=r.getViewportPageBounds(),{userId:u,chatMessage:d,brush:f,scribbles:p,selectedShapeIds:g,userName:m,cursor:S,color:y}=e,v=!(S.x<c.minX-12/l||S.y<c.minY-16/l||S.x>c.maxX-12/l||S.y>c.maxY-16/l);return h.jsxs(h.Fragment,{children:[f&&n?h.jsx(n,{className:"tl-collaborator__brush",brush:f,color:y,opacity:.1},u+"_brush"):null,v&&i?h.jsx(i,{className:"tl-collaborator__cursor",point:S,color:y,zoom:l,name:m!=="New User"?m:null,chatMessage:d},u+"_cursor"):s?h.jsx(s,{className:"tl-collaborator__cursor-hint",point:S,color:y,zoom:l,viewport:c},u+"_cursor_hint"):null,o&&p.length?h.jsx(h.Fragment,{children:p.map(b=>h.jsx(o,{className:"tl-collaborator__scribble",scribble:b,color:y,zoom:l,opacity:b.color==="laser"?.5:.1},u+"_scribble_"+b.id))}):null,a&&g.map(b=>h.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:b,color:y,opacity:.5},u+"_"+b))]})});function TN(t,e){return e>t.options.collaboratorInactiveTimeoutMs?"inactive":e>t.options.collaboratorIdleTimeoutMs?"idle":"active"}function DIe(t,e){const r=x.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[n,o]=x.useState(()=>TN(t,Date.now()-r.current));return x.useEffect(()=>{const i=t.timers.setInterval(()=>{o(TN(t,Date.now()-r.current))},t.options.collaboratorCheckIntervalMs);return()=>clearInterval(i)},[t]),e&&(r.current=e.lastActivityTimestamp),n}const RV=x.memo(function({id:e,shape:r,util:n,index:o,backgroundIndex:i,opacity:s}){const a=F(),{ShapeErrorFallback:l}=Pt(),c=x.useRef(null),u=x.useRef(null),d=x.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});qs("set shape stuff",()=>{const g=a.getShape(e);if(!g)return;const m=d.current,S=a.getShapeClipPath(e)??"none";S!==m.clipPath&&(Kr(c.current,"clip-path",S),Kr(u.current,"clip-path",S),m.clipPath=S);const y=a.getShapePageTransform(e),v=Q.toCssString(y),b=a.getShapeGeometry(g).bounds;v!==m.transform&&(Kr(c.current,"transform",v),Kr(u.current,"transform",v),m.transform=v);const $=Math.max(b.width,1),P=Math.max(b.height,1);($!==m.width||P!==m.height)&&(Kr(c.current,"width",$+"px"),Kr(c.current,"height",P+"px"),Kr(u.current,"width",$+"px"),Kr(u.current,"height",P+"px"),m.width=$,m.height=P)},[a]),qs("set opacity and z-index",()=>{const g=c.current,m=u.current;Kr(g,"opacity",s),Kr(m,"opacity",s),Kr(g,"z-index",o),Kr(m,"z-index",i)},[s,o,i]),qs("set display",()=>{if(!a.getShape(e))return;const S=a.getCulledShapes().has(e);S!==d.current.isCulled&&(Kr(c.current,"display",S?"none":"block"),Kr(u.current,"display",S?"none":"block"),d.current.isCulled=S)},[a]);const f=x.useCallback(g=>a.annotateError(g,{origin:"shape",willCrashApp:!1}),[a]);if(!r)return null;const p="fill"in r.props&&r.props.fill!=="none";return h.jsxs(h.Fragment,{children:[n.backgroundComponent&&h.jsx("div",{ref:u,className:"tl-shape tl-shape-background","data-shape-type":r.type,draggable:!1,children:h.jsx(yg,{fallback:l,onError:f,children:h.jsx(DV,{shape:r,util:n})})}),h.jsx("div",{ref:c,className:"tl-shape","data-shape-type":r.type,"data-shape-is-filled":p,draggable:!1,children:h.jsx(yg,{fallback:l,onError:f,children:h.jsx(jV,{shape:r,util:n})})})]})}),jV=x.memo(function({shape:e,util:r}){return Yx("InnerShape:"+e.type,()=>r.component(r.editor.store.unsafeGetWithoutCapture(e.id)))},(t,e)=>t.shape.props===e.shape.props&&t.shape.meta===e.shape.meta),DV=x.memo(function({shape:e,util:r}){return Yx("InnerShape:"+e.type,()=>{var n;return(n=r.backgroundComponent)==null?void 0:n.call(r,r.editor.store.unsafeGetWithoutCapture(e.id))})},(t,e)=>t.shape.props===e.shape.props&&t.shape.meta===e.shape.meta);function LIe({className:t}){const e=F(),{Background:r,SvgDefs:n,ShapeIndicators:o}=Pt(),i=x.useRef(null),s=x.useRef(null),a=x.useRef(null),l=Sr();EIe(i),y$e(),m$e(),IIe(i),x$e(i);const c=x.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});qs("position layers",function(){const{x:v,y:b,z:$}=e.getCamera();if(c.current.allowTextOutline&&e.environment.isSafari&&(l.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&$<e.options.textShadowLod!==c.current.lodDisableTextOutline){const T=$<e.options.textShadowLod;l.style.setProperty("--tl-text-outline",T?"none":"var(--tl-text-outline-reference)"),c.current.lodDisableTextOutline=T}const P=$>=1?Xd($,[1,8],[.125,.5],!0):Xd($,[.1,1],[-2,.125],!0),E=`scale(${N($)}) translate(${N(v+P)}px,${N(b+P)}px)`;Kr(s.current,"transform",E),Kr(a.current,"transform",E)},[e,l]);const u=wV(),d=H("shapeSvgDefs",()=>{const y=new Map;for(const v of Rt(e.shapeUtils)){if(!v)return;const b=v.getCanvasSvgDefs();for(const{key:$,component:P}of b)y.has($)||y.set($,h.jsx(P,{},$))}return[...y.values()]},[e]),f=H("debug_shapes",()=>Xt.hideShapes.get(),[Xt]),p=H("debug_svg",()=>Xt.debugSvg.get(),[Xt]),g=H("debug_geometry",()=>Xt.debugGeometry.get(),[Xt]),m=H("isEditingAnything",()=>e.getEditingShapeId()!==null,[e]),S=H("isSelectingAnything",()=>!!e.getSelectedShapeIds().length,[e]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{ref:i,draggable:!1,"data-iseditinganything":m,"data-isselectinganything":S,className:pe("tl-canvas",t),"data-testid":"canvas",...u,children:[h.jsx("svg",{className:"tl-svg-context",children:h.jsxs("defs",{children:[d,h.jsx(ZIe,{}),h.jsx(QIe,{}),n&&h.jsx(n,{})]})}),r&&h.jsx("div",{className:"tl-background__wrapper",children:h.jsx(r,{})}),h.jsx(FIe,{}),h.jsxs("div",{ref:s,className:"tl-html-layer tl-shapes",draggable:!1,children:[h.jsx(rPe,{}),h.jsx(tPe,{}),f?null:p?h.jsx(VIe,{}):h.jsx(XIe,{})]}),h.jsx("div",{className:"tl-overlays",children:h.jsxs("div",{ref:a,className:"tl-html-layer",children:[g?h.jsx(OIe,{}):null,h.jsx(WIe,{}),h.jsx(UIe,{}),h.jsx(BIe,{}),h.jsx(zIe,{}),o&&h.jsx(o,{}),h.jsx(qIe,{}),h.jsx(HIe,{}),h.jsx(ePe,{}),h.jsx(MIe,{})]})}),h.jsx(nPe,{})]}),h.jsx(NIe,{})]})}function NIe(){const{InFrontOfTheCanvas:t}=Pt();return t?h.jsx(t,{}):null}function FIe(){const t=F(),e=H("gridSize",()=>t.getDocumentSettings().gridSize,[t]),{x:r,y:n,z:o}=H("camera",()=>t.getCamera(),[t]),i=H("isGridMode",()=>t.getInstanceState().isGridMode,[t]),{Grid:s}=Pt();return s&&i?h.jsx(s,{x:r,y:n,z:o,size:e}):null}function BIe(){const t=F(),e=H("scribbles",()=>t.getInstanceState().scribbles,[t]),r=H("zoomLevel",()=>t.getZoomLevel(),[t]),{Scribble:n}=Pt();return n&&e.length?e.map(o=>h.jsx(n,{className:"tl-user-scribble",scribble:o,zoom:r},o.id)):null}function UIe(){const t=F(),e=H("brush",()=>t.getInstanceState().brush,[t]),{Brush:r}=Pt();return r&&e?h.jsx(r,{className:"tl-user-brush",brush:e}):null}function zIe(){const t=F(),e=H("zoomBrush",()=>t.getInstanceState().zoomBrush,[t]),{ZoomBrush:r}=Pt();return r&&e?h.jsx(r,{className:"tl-user-brush tl-zoom-brush",brush:e}):null}function HIe(){const t=F(),e=H("snapLines",()=>t.snaps.getIndicators(),[t]),r=H("zoomLevel",()=>t.getZoomLevel(),[t]),{SnapIndicator:n}=Pt();return n&&e.length>0?e.map(o=>h.jsx(n,{className:"tl-user-snapline",line:o,zoom:r},o.id)):null}function WIe(){const t=F(),e=H("handles shapeIdWithHandles",()=>{const{isReadonly:r,isChangingStyle:n}=t.getInstanceState();if(r||n)return!1;const o=t.getOnlySelectedShape();return!o||!t.getShapeHandles(o)?!1:o.id},[t]);return e?h.jsx(KIe,{shapeId:e}):null}function KIe({shapeId:t}){const e=F(),{Handles:r}=Pt(),n=H("zoomLevel",()=>e.getZoomLevel(),[e]),o=H("coarse pointer",()=>e.getInstanceState().isCoarsePointer,[e]),i=H("handles transform",()=>e.getShapePageTransform(t),[e,t]),s=H("handles",()=>{const a=e.getShapeHandles(t);if(!a)return null;const l=(o?e.options.coarseHandleRadius:e.options.handleRadius)/n*2;return a.filter(c=>c.type!=="virtual"||!a.some(u=>u!==c&&u.type==="vertex"&&w.Dist(c,u)<l)).sort(c=>c.type==="vertex"?1:-1)},[e,n,o,t]);return!r||!s||!i?null:h.jsx(r,{children:h.jsx("g",{transform:Q.toCssString(i),children:s.map(a=>h.jsx(GIe,{shapeId:t,handle:a,zoom:n,isCoarse:o},a.id))})})}function GIe({shapeId:t,handle:e,zoom:r,isCoarse:n}){const o=PIe(t,e.id),{Handle:i}=Pt();return i?h.jsx("g",{"aria-label":"handle",transform:`translate(${e.x}, ${e.y})`,...o,children:h.jsx(i,{shapeId:t,handle:e,zoom:r,isCoarse:n})}):null}function VIe(){const t=F();return H("rendering shapes",()=>t.getRenderingShapes(),[t]).map(r=>h.jsxs(x.Fragment,{children:[h.jsx(RV,{...r}),h.jsx(JIe,{id:r.id,mode:"iframe"})]},r.id+"_fragment"))}function YIe(){const t=F(),e=x.useRef(new Set);return qs("reflow for culled shapes",()=>{const r=t.getCulledShapes();if(e.current.size===r.size&&[...r].every(o=>e.current.has(o)))return;e.current=r;const n=document.getElementsByClassName("tl-canvas");n.length!==0&&n[0].offsetHeight},[t]),null}function XIe(){const t=F(),e=H("rendering shapes",()=>t.getRenderingShapes(),[t]);return h.jsxs(h.Fragment,{children:[e.map(r=>h.jsx(RV,{...r},r.id+"_shape")),t.environment.isSafari&&h.jsx(YIe,{})]})}function qIe(){const t=F(),{ShapeIndicator:e}=Pt(),r=H("hinting shape ids",()=>bk(t.getHintingShapeIds()),[t]);return!r.length||!e?null:r.map(n=>h.jsx(e,{className:"tl-user-indicator__hint",shapeId:n},n+"_hinting"))}function ZIe(){return h.jsxs("g",{id:"cursor",children:[h.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),h.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function QIe(){return h.jsx("path",{id:"cursor_hint",fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function JIe({id:t,mode:e}){const r=F(),[n,o]=x.useState(null),i=H("is in root",()=>{const s=r.getShape(t);return(s==null?void 0:s.parentId)===r.getCurrentPageId()},[r,t]);return x.useEffect(()=>{if(!i)return;let s=null;const a=Sl("shape to svg",async()=>{const l=Math.random();s=l;const u=r.isShapeOfType(t,"frame")?0:10;let d=r.getShapePageBounds(t);if(!d)return;d=d.clone().expandBy(u);const f=await r.getSvgString([t],{padding:u,background:r.getInstanceState().exportBackground});if(s!==l||!f)return;const p=`data:image/svg+xml;utf8,${encodeURIComponent(f.svg)}`;o({src:p,bounds:d})});return()=>{s=null,a()}},[r,t,i]),!i||!n?null:e==="iframe"?h.jsx("iframe",{src:n.src,width:n.bounds.width,height:n.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,border:"none",transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}}):h.jsx("img",{src:n.src,width:n.bounds.width,height:n.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}})}function ePe(){const t=F(),e=H("selection rotation",()=>t.getSelectionRotation(),[t]),r=H("selection bounds",()=>t.getSelectionRotatedPageBounds(),[t]),{SelectionForeground:n}=Pt();return!r||!n?null:h.jsx(n,{bounds:r,rotation:e})}function tPe(){const t=F(),e=H("selection rotation",()=>t.getSelectionRotation(),[t]),r=H("selection bounds",()=>t.getSelectionRotatedPageBounds(),[t]),{SelectionBackground:n}=Pt();return!r||!n?null:h.jsx(n,{bounds:r,rotation:e})}function rPe(){const{OnTheCanvas:t}=Pt();return t?h.jsx(t,{}):null}function nPe(){const t=F(),e=H("camera state",()=>t.getCameraState(),[t]);return h.jsx("div",{className:pe("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":e==="idle"})})}function oPe({className:t,zoom:e,point:r,color:n,viewport:o,opacity:i=1}){const s=x.useRef(null);return Th(s,Pr(r.x,o.minX+5/e,o.maxX-5/e),Pr(r.y,o.minY+5/e,o.maxY-5/e),1/e,w.Angle(o.center,r)),h.jsxs("svg",{ref:s,className:pe("tl-overlays__item",t),children:[h.jsx("use",{href:"#cursor_hint",color:n,strokeWidth:3,stroke:"var(--color-background)"}),h.jsx("use",{href:"#cursor_hint",color:n,opacity:i})]})}const AN=x.memo(function({className:e,zoom:r,point:n,color:o,name:i,chatMessage:s}){const a=x.useRef(null);return Th(a,n==null?void 0:n.x,n==null?void 0:n.y,1/r),n?h.jsxs("div",{ref:a,className:pe("tl-overlays__item",e),children:[h.jsx("svg",{className:"tl-cursor",children:h.jsx("use",{href:"#cursor",color:o})}),s?h.jsxs(h.Fragment,{children:[i&&h.jsx("div",{className:"tl-nametag-title",style:{color:o},children:i}),h.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:o},children:s})]}):i&&h.jsx("div",{className:"tl-nametag",style:{backgroundColor:o},children:i})]}):null});function LV(){return x.useId().replace(/:/g,"_")}function iPe({x:t,y:e,z:r,size:n}){const o=`grid_${LV()}`,i=F(),{gridSteps:s}=i.options;return h.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("defs",{children:s.map(({min:a,mid:l,step:c},u)=>{const d=c*n*r,f=.5+t*r,p=.5+e*r,g=f>0?f%d:d+f%d,m=p>0?p%d:d+p%d,S=r<l?Xd(r,[a,l],[0,1]):1;return h.jsx("pattern",{id:`${o}_${c}`,width:d,height:d,patternUnits:"userSpaceOnUse",children:h.jsx("circle",{className:"tl-grid-dot",cx:g,cy:m,r:1,opacity:S})},u)})}),s.map(({step:a},l)=>h.jsx("rect",{width:"100%",height:"100%",fill:`url(#${o}_${a})`},l))]})}function sPe({handle:t,isCoarse:e,className:r,zoom:n}){const o=F(),i=(e?o.options.coarseHandleRadius:o.options.handleRadius)/n;if(t.type==="clone"){const a=3/n,l=`M0,${-a} A${a},${a} 0 0,1 0,${a}`,c=u$e.indexOf(t.id);return h.jsxs("g",{className:pe(`tl-handle tl-handle__${t.type}`,r),children:[h.jsx("circle",{className:"tl-handle__bg",r:i}),h.jsx("path",{className:"tl-handle__fg",d:l,transform:`rotate(${-90+90*c})`})]})}const s=(t.type==="create"&&e?3:4)/Math.max(n,.25);return h.jsxs("g",{className:pe(`tl-handle tl-handle__${t.type}`,r),children:[h.jsx("circle",{className:"tl-handle__bg",r:i}),h.jsx("circle",{className:"tl-handle__fg",r:s})]})}const aPe=({children:t})=>h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:t}),lPe=()=>{const{Spinner:t}=Pt();return h.jsx(QR,{children:t?h.jsx(t,{}):null})};function dO(t,e=!0){const r=t.length;if(r<2)return"";let n=t[0],o=t[1];if(r===2)return`M${Xe(n)}L${Xe(o)}`;let i="";for(let s=2,a=r-1;s<a;s++)n=t[s],o=t[s+1],i+=On(n,o);return e?`M${On(t[0],t[1])}Q${Xe(t[1])}${On(t[1],t[2])}T${i}${On(t[r-1],t[0])}${On(t[0],t[1])}Z`:`M${Xe(t[0])}Q${Xe(t[1])}${On(t[1],t[2])}${t.length>3?"T":""}${i}L${Xe(t[r-1])}`}function kN({scribble:t,zoom:e,color:r,opacity:n,className:o}){return t.points.length?h.jsx("svg",{className:o&&pe("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:dO(t.points,!1),stroke:r??`var(--color-${t.color})`,fill:"none",strokeWidth:8/e,opacity:n??t.opacity})}):null}function NV({bounds:t,rotation:e}){const r=x.useRef(null);return Th(r,t.x,t.y,1,e),x.useLayoutEffect(()=>{const n=r.current;n&&(n.style.width=N(Math.max(1,t.width))+"px",n.style.height=N(Math.max(1,t.height))+"px")},[t.width,t.height]),h.jsx("div",{ref:r,className:"tl-selection__bg",draggable:!1})}function cPe({bounds:t,rotation:e}){const r=F(),n=x.useRef(null),o=H("only selected shape",()=>r.getOnlySelectedShape(),[r]),i=o?r.getShapeUtil(o).expandSelectionOutlinePx(o):0;return Th(n,t==null?void 0:t.x,t==null?void 0:t.y,1,e,{x:-i,y:-i}),t=t.clone().expandBy(i).zeroFix(),h.jsx("svg",{ref:n,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsx("rect",{className:pe("tl-selection__fg__outline"),width:N(t.width),height:N(t.height)})})}const uPe=()=>h.jsx("div",{className:"tl-shape-error-boundary"}),dPe=({shape:t,util:e})=>Yx("Indicator: "+t.type,()=>e.indicator(e.editor.store.unsafeGetWithoutCapture(t.id))),hPe=({editor:t,id:e})=>{const r=H("shape for indicator",()=>t.store.get(e),[t,e]),{ShapeIndicatorErrorFallback:n}=Pt();return!r||r.isLocked?null:h.jsx(yg,{fallback:n,onError:o=>t.annotateError(o,{origin:"react.shapeIndicator",willCrashApp:!1}),children:h.jsx(dPe,{shape:r,util:t.getShapeUtil(r)},r.id)})},ON=x.memo(function({shapeId:e,className:r,color:n,hidden:o,opacity:i}){const s=F(),a=x.useRef(null);return qs("indicator transform",()=>{const l=a.current;if(!l)return;const c=s.getShapePageTransform(e);c&&l.style.setProperty("transform",c.toCssString())},[s,e]),x.useLayoutEffect(()=>{const l=a.current;l&&l.style.setProperty("display",o?"none":"block")},[o]),h.jsx("svg",{ref:a,className:pe("tl-overlays__item",r),children:h.jsx("g",{className:"tl-shape-indicator",stroke:n??"var(--color-selected)",opacity:i,children:h.jsx(hPe,{editor:s,id:e})})})}),fPe=()=>h.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"}),FV=x.memo(function(){const e=F(),r=x.useRef(new Set),n=H("should display selected ids",()=>{const s=r.current,a=new Set;if(e.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle")&&!e.getInstanceState().isChangingStyle){const l=e.getSelectedShapeIds();for(const c of l)a.add(c);if(e.isInAny("select.idle","select.editing_shape")){const c=e.getInstanceState();if(c.isHoveringCanvas&&!c.isCoarsePointer){const u=e.getHoveredShapeId();u&&a.add(u)}}}if(s.size!==a.size)return r.current=a,a;for(const l of a)if(!s.has(l))return r.current=a,a;return s},[e]),o=H("rendering shapes",()=>e.getRenderingShapes(),[e]),{ShapeIndicator:i}=Pt();return i?o.map(({id:s})=>h.jsx(i,{shapeId:s,hidden:!n.has(s)},s+"_indicator")):null});function pPe({points:t,zoom:e}){const r=2.5/e,n=t.reduce((f,p)=>Math.min(f,p.x),1/0),o=t.reduce((f,p)=>Math.max(f,p.x),-1/0),i=t.reduce((f,p)=>Math.min(f,p.y),1/0),s=t.reduce((f,p)=>Math.max(f,p.y),-1/0),a=t.some(f=>f.x===n&&f.y===i);let l,c,u,d;return a?(l=n,c=i,u=o,d=s):(l=n,c=s,u=o,d=i),h.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[h.jsx("line",{x1:l,y1:c,x2:u,y2:d}),t.map((f,p)=>h.jsx("g",{transform:`translate(${f.x},${f.y})`,children:h.jsx("path",{className:"tl-snap-point",d:`M ${-r},${-r} L ${r},${r} M ${-r},${r} L ${r},${-r}`})},p))]})}function gPe({gaps:t,direction:e,zoom:r}){const n=3.5/r;let o=[-1/0,1/0],i=null;const s=e==="horizontal";for(const l of t){if(i=li(o[0],o[1],s?l.startEdge[0].y:l.startEdge[0].x,s?l.startEdge[1].y:l.startEdge[1].x),i)o=i;else continue;if(i=li(o[0],o[1],s?l.endEdge[0].y:l.endEdge[0].x,s?l.endEdge[1].y:l.endEdge[1].x),i)o=i;else continue}if(o===null)return null;const a=(o[0]+o[1])/2;return h.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:t.map(({startEdge:l,endEdge:c},u)=>h.jsx(x.Fragment,{children:s?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:l[0].x,y1:a-2*n,x2:l[1].x,y2:a+2*n}),h.jsx("line",{x1:c[0].x,y1:a-2*n,x2:c[1].x,y2:a+2*n}),h.jsx("line",{x1:l[0].x,y1:a,x2:c[0].x,y2:a}),h.jsx("line",{x1:(l[0].x+c[0].x)/2,y1:a-n,x2:(l[0].x+c[0].x)/2,y2:a+n})]}):h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:a-2*n,y1:l[0].y,x2:a+2*n,y2:l[1].y}),h.jsx("line",{x1:a-2*n,y1:c[0].y,x2:a+2*n,y2:c[1].y}),h.jsx("line",{x1:a,y1:l[0].y,x2:a,y2:c[0].y}),h.jsx("line",{x1:a-n,y1:(l[0].y+c[0].y)/2,x2:a+n,y2:(l[0].y+c[0].y)/2})]})},u))})}function mPe({className:t,line:e,zoom:r}){return h.jsx("svg",{className:pe("tl-overlays__item",t),children:e.type==="points"?h.jsx(pPe,{...e,zoom:r}):e.type==="gaps"?h.jsx(gPe,{...e,zoom:r}):null})}function hO(){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const vPe=()=>null;function BV(t,e){const r=x.useRef(t);return e(t,r.current)?r.current:(r.current=t,t)}const yPe=(t,e)=>(t??(t=null),e??(e=null),t===e?!0:!t||!e?!1:dme(t,e));function Ga(t){return BV(t,yPe)}const SPe=(t,e)=>(t??(t=null),e??(e=null),t===e?!0:!t||!e?!1:SK(t,e));function om(t){return BV(t,SPe)}const UV=x.createContext(null);function wPe({overrides:t={},children:e}){const r=om(t),n=x.useMemo(()=>({Background:n$e,SvgDefs:vPe,Brush:nI,ZoomBrush:nI,CollaboratorBrush:nI,Cursor:AN,CollaboratorCursor:AN,CollaboratorHint:oPe,CollaboratorShapeIndicator:ON,Grid:iPe,Scribble:kN,SnapIndicator:mPe,Handles:aPe,Handle:sPe,CollaboratorScribble:kN,ErrorFallback:HV,ShapeErrorFallback:uPe,ShapeIndicatorErrorFallback:fPe,Spinner:hO,SelectionBackground:NV,SelectionForeground:cPe,ShapeIndicators:FV,ShapeIndicator:ON,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:LIe,LoadingScreen:lPe,...r}),[r]);return h.jsx(UV.Provider,{value:n,children:e})}function Pt(){const t=x.useContext(UV);if(!t)throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return t}const fO={openWindow(t,e){window.open(t,e,"noopener noreferrer")},refreshPage(){window.location.reload()},async hardReset(){var t;return await((t=window.__tldraw__hardReset)==null?void 0:t.call(window))}};function zV(){fO.hardReset()}function xPe(){fO.refreshPage()}const bPe="https://github.com/tldraw/tldraw/issues/new",HV=({error:t,editor:e})=>{const r=x.useRef(null),[n,o]=x.useState(!1),[i,s]=x.useState(!1),[a,l]=x.useState(!1);let c=null;try{c=Pt().Canvas??null}catch{}const u=t instanceof Error?t.message:String(t),d=t instanceof Error?t.stack:null,f=H("isDarkMode",()=>{try{if(e)return e.user.getIsDarkMode()}catch{}return null},[e]),[p,g]=x.useState(null);x.useLayoutEffect(()=>{var P;f!==null&&g(f);let b=(P=r.current)==null?void 0:P.parentElement,$=!1;for(;b;){if(b.classList.contains("tl-theme__dark")||b.classList.contains("tl-theme__light")){$=!0;break}b=b.parentElement}if($){g(null);return}typeof window<"u"&&"matchMedia"in window&&g(window.matchMedia("(prefers-color-scheme: dark)").matches)},[f]),x.useEffect(()=>{if(i){const b=e==null?void 0:e.timers.setTimeout(()=>{s(!1)},2e3);return()=>clearTimeout(b)}},[i,e]);const m=()=>{const b=document.createElement("textarea");b.value=d??u,document.body.appendChild(b),b.select(),document.execCommand("copy"),b.remove(),s(!0)},S=()=>{xPe()},y=async()=>{zV()},v=new URL(bPe);return v.searchParams.set("title",u),v.searchParams.set("labels","bug"),v.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
93
|
-
|
|
94
|
-
\`\`\`js
|
|
95
|
-
${d??u}
|
|
96
|
-
\`\`\`
|
|
97
|
-
|
|
98
|
-
My browser: ${navigator.userAgent}`),h.jsxs("div",{ref:r,className:pe("tl-container tl-error-boundary",p===null?"":p?"tl-theme__dark":"tl-theme__light"),children:[h.jsx("div",{className:"tl-error-boundary__overlay"}),e&&h.jsx(aO,{onError:dg,fallback:()=>null,children:h.jsx(Xx.Provider,{value:e,children:h.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:c?h.jsx(c,{}):null})})}),h.jsx("div",{className:pe("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":n&&!a}),children:a?h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Are you sure?"}),h.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>l(!1),children:"Cancel"}),h.jsx("button",{className:"tl-error-boundary__reset",onClick:y,children:"Reset data"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Something's gone wrong."}),h.jsxs("p",{children:["Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",h.jsx("a",{href:v.toString(),children:"create a GitHub issue"})," or"," ",h.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"ask for help on Discord"}),"."]}),n&&h.jsxs(h.Fragment,{children:["Message:",h.jsx("h4",{children:h.jsx("code",{children:u})}),"Stack trace:",h.jsxs("div",{className:"tl-error-boundary__content__error",children:[h.jsx("pre",{children:h.jsx("code",{children:d??u})}),h.jsx("button",{onClick:m,children:i?"Copied!":"Copy"})]})]}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>o(!n),children:n?"Hide details":"Show details"}),h.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[h.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>l(!0),children:"Reset data"}),h.jsx("button",{className:"tl-error-boundary__refresh",onClick:S,children:"Refresh Page"})]})]})]})})]})},WV="TLDRAW_USER_DATA_v3",KV=Ne({id:Te,name:Te.nullable().optional(),locale:Te.nullable().optional(),color:Te.nullable().optional(),colorScheme:Gx("light","dark","system").optional(),animationSpeed:Se.nullable().optional(),edgeScrollSpeed:Se.nullable().optional(),isSnapMode:De.nullable().optional(),isWrapMode:De.nullable().optional(),isDynamicSizeMode:De.nullable().optional(),isPasteAtCursorMode:De.nullable().optional()}),Ms={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8},pO=Math.max(...Object.values(Ms));function $Pe(t){t.version<Ms.AddAnimationSpeed&&(t.user.animationSpeed=1),t.version<Ms.AddIsSnapMode&&(t.user.isSnapMode=!1),t.version<Ms.MakeFieldsNullable,t.version<Ms.AddEdgeScrollSpeed&&(t.user.edgeScrollSpeed=1),t.version<Ms.AddExcalidrawSelectMode&&(t.user.isWrapMode=!1),t.version<Ms.AllowSystemColorScheme&&(t.user.isDarkMode===!0?t.user.colorScheme="dark":t.user.isDarkMode===!1&&(t.user.colorScheme="light"),delete t.user.isDarkMode),t.version<Ms.AddDynamicSizeMode&&(t.user.isDynamicSizeMode=!1),t.version<Ms.AddPasteAtCursor&&(t.user.isPasteAtCursorMode=!1),t.version=pO}const aT=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function GV(){return aT[Math.floor(Math.random()*aT.length)]}function IPe(){var t,e;return typeof window<"u"&&"matchMedia"in window?((e=(t=window.matchMedia)==null?void 0:t.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:e.matches)??!1:!1}const As=Object.freeze({name:"New User",locale:Xbe(),color:GV(),edgeScrollSpeed:1,animationSpeed:IPe()?0:1,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,colorScheme:"system"});function lI(){return{id:ct(),color:GV()}}function VV(t){if(t===null||typeof t!="object"||!("version"in t)||!("user"in t)||typeof t.version!="number")return lI();const e=$t(t);$Pe(e);try{return KV.validate(e.user)}catch{return lI()}}function PPe(){const t=JSON.parse(Ak(WV)||"null")??null;return VV(t)}const Zx=fr("globalUserData",null);function EPe(){kk(WV,JSON.stringify({version:pO,user:Zx.get()}))}function YV(t){KV.validate(t),Zx.set(t),EPe(),_Pe()}const CPe=typeof process<"u"&&!1,_d=typeof BroadcastChannel<"u"&&!CPe?new BroadcastChannel("tldraw-user-sync"):null;_d==null||_d.addEventListener("message",t=>{const e=t.data;(e==null?void 0:e.type)===qV&&(e==null?void 0:e.origin)!==XV()&&Zx.set(VV(e.data))});let cI=null;function XV(){return cI===null&&(cI=ct()),cI}const qV="tldraw-user-preferences-change";function _Pe(){_d==null||_d.postMessage({type:qV,origin:XV(),data:{user:ZV(),version:pO}})}function ZV(){let t=Zx.get();return t||(t=PPe(),YV(t)),t}const TPe=Y("defaultLocalStorageUserPrefs",()=>ZV());function QV(t={}){return{userPreferences:t.userPreferences??TPe,setUserPreferences:t.setUserPreferences??YV}}var JV={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function o(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function i(l,c,u,d,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new o(u,d||l,f),g=r?r+c:c;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],p]:l._events[g].push(p):(l._events[g]=p,l._eventsCount++),l}function s(l,c){--l._eventsCount===0?l._events=new n:delete l._events[c]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,d;if(this._eventsCount===0)return c;for(d in u=this._events)e.call(u,d)&&c.push(r?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=r?r+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,p=d.length,g=new Array(p);f<p;f++)g[f]=d[f].fn;return g},a.prototype.listenerCount=function(c){var u=r?r+c:c,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(c,u,d,f,p,g){var m=r?r+c:c;if(!this._events[m])return!1;var S=this._events[m],y=arguments.length,v,b;if(S.fn){switch(S.once&&this.removeListener(c,S.fn,void 0,!0),y){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,u),!0;case 3:return S.fn.call(S.context,u,d),!0;case 4:return S.fn.call(S.context,u,d,f),!0;case 5:return S.fn.call(S.context,u,d,f,p),!0;case 6:return S.fn.call(S.context,u,d,f,p,g),!0}for(b=1,v=new Array(y-1);b<y;b++)v[b-1]=arguments[b];S.fn.apply(S.context,v)}else{var $=S.length,P;for(b=0;b<$;b++)switch(S[b].once&&this.removeListener(c,S[b].fn,void 0,!0),y){case 1:S[b].fn.call(S[b].context);break;case 2:S[b].fn.call(S[b].context,u);break;case 3:S[b].fn.call(S[b].context,u,d);break;case 4:S[b].fn.call(S[b].context,u,d,f);break;default:if(!v)for(P=1,v=new Array(y-1);P<y;P++)v[P-1]=arguments[P];S[b].fn.apply(S[b].context,v)}}return!0},a.prototype.on=function(c,u,d){return i(this,c,u,d,!1)},a.prototype.once=function(c,u,d){return i(this,c,u,d,!0)},a.prototype.removeListener=function(c,u,d,f){var p=r?r+c:c;if(!this._events[p])return this;if(!u)return s(this,p),this;var g=this._events[p];if(g.fn)g.fn===u&&(!f||g.once)&&(!d||g.context===d)&&s(this,p);else{for(var m=0,S=[],y=g.length;m<y;m++)(g[m].fn!==u||f&&!g[m].once||d&&g[m].context!==d)&&S.push(g[m]);S.length?this._events[p]=S.length===1?S[0]:S:s(this,p)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=r?r+c:c,this._events[u]&&s(this,u)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a})(JV);var APe=JV.exports;const kPe=_l(APe),Td="TLDRAW_TAB_ID_v2",is=globalThis.window;function OPe(){return is?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(is.navigator.platform)||is.navigator.userAgent.includes("Mac")&&"ontouchend"in document:!1}const u0=is?is[Td]??OK(Td)??"TLDRAW_INSTANCE_STATE_V1_"+ct():"<error>";is&&(is[Td]=u0,OPe()?Ok(Td,u0):MK(Td));is==null||is.addEventListener("beforeunload",()=>{Ok(Td,u0)});const eY={Initial:0},Qx=Math.max(...Object.values(eY));function MPe(t){t.version<eY.Initial,t.version=Qx}const tY=Ne({version:Se,currentPageId:mg.optional(),isFocusMode:De.optional(),exportBackground:De.optional(),isDebugMode:De.optional(),isToolLocked:De.optional(),isGridMode:De.optional(),pageStates:Tr(Ne({pageId:mg,camera:Ne({x:Se,y:Se,z:Se}).optional(),selectedShapeIds:Tr(Lo).optional(),focusedGroupId:Lo.nullable().optional()})).optional()});function RPe(t){if(!t||typeof t!="object")return console.warn("Invalid instance state"),null;if(!("version"in t)||typeof t.version!="number")return console.warn("No version in instance state"),null;t.version!==Qx&&(t=$t(t),MPe(t));try{return tY.validate(t)}catch(e){return console.warn(e),null}}function gO(t){const e=t.query.ids("page");return Y("sessionStateSnapshot",()=>{const r=t.get(fn);if(!r)return null;const n=[...e.get()];return{version:Qx,currentPageId:r.currentPageId,exportBackground:r.exportBackground,isFocusMode:r.isFocusMode,isDebugMode:r.isDebugMode,isToolLocked:r.isToolLocked,isGridMode:r.isGridMode,pageStates:n.map(o=>{const i=t.get(fi.createId(o)),s=t.get(qi.createId(o));return{pageId:o,camera:{x:(s==null?void 0:s.x)??0,y:(s==null?void 0:s.y)??0,z:(s==null?void 0:s.z)??1},selectedShapeIds:(i==null?void 0:i.selectedShapeIds)??[],focusedGroupId:(i==null?void 0:i.focusedGroupId)??null}})}})}function lT(t,e,r){const n=RPe(e);if(!n)return;const o=zG(t.get(fn)),i=r!=null&&r.forceOverwrite?n:o,s=r!=null&&r.forceOverwrite?o:n,a=t.schema.types.instance.create({id:fn,...o,currentPageId:n.currentPageId,isDebugMode:(i==null?void 0:i.isDebugMode)??(s==null?void 0:s.isDebugMode),isFocusMode:(i==null?void 0:i.isFocusMode)??(s==null?void 0:s.isFocusMode),isToolLocked:(i==null?void 0:i.isToolLocked)??(s==null?void 0:s.isToolLocked),isGridMode:(i==null?void 0:i.isGridMode)??(s==null?void 0:s.isGridMode),exportBackground:(i==null?void 0:i.exportBackground)??(s==null?void 0:s.exportBackground)});t.atomic(()=>{var l,c,u;for(const d of n.pageStates??[]){if(!t.has(d.pageId))continue;const f=qi.createId(d.pageId),p=fi.createId(d.pageId),g=t.get(f),m=t.get(p);t.put([qi.create({id:f,x:((l=d.camera)==null?void 0:l.x)??(g==null?void 0:g.x),y:((c=d.camera)==null?void 0:c.y)??(g==null?void 0:g.y),z:((u=d.camera)==null?void 0:u.z)??(g==null?void 0:g.z)}),fi.create({id:p,pageId:d.pageId,selectedShapeIds:d.selectedShapeIds??(m==null?void 0:m.selectedShapeIds),focusedGroupId:d.focusedGroupId??(m==null?void 0:m.focusedGroupId)})])}t.put([a]),t.ensureStoreIsUsable()})}function jPe(t){var o;const e=[];for(const i of Object.values(t))(o=i.typeName)!=null&&o.match(/^(instance.*|pointer|camera)$/)&&e.push(i);const r=e.filter(i=>i.typeName==="instance"&&i.id!==fn)[0];if(!r)return null;const n={version:Qx,currentPageId:r.currentPageId,exportBackground:!!r.exportBackground,isFocusMode:!!r.isFocusMode,isDebugMode:!!r.isDebugMode,isToolLocked:!!r.isToolLocked,isGridMode:!1,pageStates:e.filter(i=>i.typeName==="instance_page_state"&&i.instanceId===r.id).map(i=>{const s=t[i.cameraId]??{x:0,y:0,z:1};return{pageId:i.pageId,camera:{x:s.x,y:s.y,z:s.z},selectedShapeIds:i.selectedShapeIds,focusedGroupId:i.focusedGroupId}})};try{return tY.validate(n),n}catch{return null}}function rY(t,e,r){let n={};if("store"in e){const s=t.schema.migrateStoreSnapshot(e);if(s.type!=="success")throw new Error("Failed to migrate store snapshot: "+s.reason);n.document={schema:t.schema.serialize(),store:Cp(s.value,(a,{typeName:l})=>t.scopedTypes.document.has(l))}}else n=e;const o=zG(t.get(fn)),i=nY.get(t,gO).get();t.atomic(()=>{n.document&&t.loadStoreSnapshot(n.document),o&&t.update(fn,s=>({...s,...o})),i&&lT(t,i),n.session&&lT(t,n.session,{forceOverwrite:r==null?void 0:r.forceOverwriteSessionState})})}const nY=new ls;function DPe(t){const r=nY.get(t,gO).get();if(!r)throw new Error("Session state is not ready yet");return{document:t.getStoreSnapshot(),session:r}}function oY(t){const e=[],r=new Set;for(const n of t){if(r.has(n.type))throw new Error(`Binding type "${n.type}" is defined more than once`);e.push(n),r.add(n.type)}return e}function xl({children:t,className:e="",...r}){return h.jsx("svg",{...r,className:pe("tl-svg-container",e),children:t})}function mO(t,e,r,n){const o=t.x-r.x,i=t.y-r.y,s=n.x-r.x,a=n.y-r.y,l=e.x-t.x,c=e.y-t.y,u=s*i-a*o,d=l*i-c*o,f=a*l-s*c;if(u===0||d===0||f===0)return null;if(f!==0){const p=u/f,g=d/f;if(0<=p&&p<=1&&0<=g&&g<=1)return w.AddXY(t,p*l,p*c)}return null}function im(t,e,r,n){const o=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y),i=2*((e.x-t.x)*(t.x-r.x)+(e.y-t.y)*(t.y-r.y)),s=r.x*r.x+r.y*r.y+t.x*t.x+t.y*t.y-2*(r.x*t.x+r.y*t.y)-n*n,a=i*i-4*o*s;if(a<0||a===0)return null;const l=Math.sqrt(a),c=(-i+l)/(2*o),u=(-i-l)/(2*o);if((c<0||c>1)&&(u<0||u>1))return null;const d=[];return 0<=c&&c<=1&&d.push(w.Lrp(t,e,c)),0<=u&&u<=1&&d.push(w.Lrp(t,e,u)),d.length===0?null:d}function LPe(t,e,r){const n=[];let o;for(let i=0,s=r.length-1;i<s;i++)o=mO(t,e,r[i],r[i+1]),o&&n.push(o);return n.length===0?null:n}function vO(t,e,r){const n=[];let o;for(let i=1,s=r.length;i<s+1;i++)o=mO(t,e,r[i-1],r[i%r.length]),o&&n.push(o);return n.length===0?null:n}function NPe(t,e,r,n){let o=r.x-t.x,i=r.y-t.y;const s=Math.sqrt(o*o+i*i),a=(s*s-n*n+e*e)/(2*s),l=Math.sqrt(e*e-a*a);return o/=s,i/=s,[new w(t.x+o*a-i*l,t.y+i*a+o*l),new w(t.x+o*a+i*l,t.y+i*a-o*l)]}function cT(t,e,r){const n=[];let o,i,s;for(let a=0,l=r.length;a<l;a++)o=r[a],i=r[(a+1)%r.length],s=im(o,i,t,e),s&&n.push(...s);return n.length===0?null:n}function MN(t,e,r){const n=[];let o,i,s;for(let a=1,l=r.length;a<l;a++)o=r[a-1],i=r[a],s=im(o,i,t,e),s&&n.push(...s);return n.length===0?null:n}function Av(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function yO(t,e,r,n){return Av(t,r,n)!==Av(e,r,n)&&Av(t,e,r)!==Av(t,e,n)}function RN(t,e){const r=new Map;let n,o,i,s;for(let a=0,l=t.length;a<l;a++)if(n=t[a],ho(n,e)){const c=uI(n);r.has(c)||r.set(c,n)}for(let a=0,l=e.length;a<l;a++)if(n=e[a],ho(n,t)){const c=uI(n);r.has(c)||r.set(c,n)}for(let a=0,l=t.length;a<l;a++){n=t[a],o=t[(a+1)%t.length];for(let c=0,u=e.length;c<u;c++){i=e[c],s=e[(c+1)%e.length];const d=mO(n,o,i,s);if(d!==null){const f=uI(d);r.has(f)||r.set(f,d)}}}return r.size===0?null:FPe([...r.values()])}function uI(t){return`${t.x},${t.y}`}function FPe(t){const e=w.Average(t);return t.sort((r,n)=>w.Angle(e,r)-w.Angle(e,n))}function iY(t,e){let r,n,o,i;for(let s=0,a=t.length;s<a;s++){r=t[s],n=t[(s+1)%a];for(let l=0,c=e.length;l<c;l++)if(o=e[l],i=e[(l+1)%c],yO(r,n,o,i))return!0}return!1}function BPe(t,e){let r,n,o,i;for(let s=0,a=t.length;s<a;s++){r=t[s],n=t[(s+1)%a];for(let l=1,c=e.length;l<c;l++)if(o=e[l-1],i=e[l],yO(r,n,o,i))return!0}return!1}class Ws extends Fl{constructor(r){super({...r,isClosed:!1,isFilled:!1});C(this,"start");C(this,"end");C(this,"d");C(this,"u");C(this,"ul");const{start:n,end:o}=r;this.start=n,this.end=o,this.d=n.clone().sub(o),this.u=this.d.clone().uni(),this.ul=this.u.len()}getLength(){return this.d.len()}midPoint(){return this.start.lrp(this.end,.5)}getVertices(){return[this.start,this.end]}nearestPoint(r){const{start:n,end:o,u:i,ul:s}=this;if(s===0)return n;const a=w.Sub(r,n).dpr(i)/s,l=n.x+i.x*a;if(l<Math.min(n.x,o.x))return n.x<o.x?n:o;if(l>Math.max(n.x,o.x))return n.x>o.x?n:o;const c=n.y+i.y*a;return c<Math.min(n.y,o.y)?n.y<o.y?n:o:c>Math.max(n.y,o.y)?n.y>o.y?n:o:new w(l,c)}hitTestLineSegment(r,n,o=0){return yO(r,n,this.start,this.end)||this.distanceToLineSegment(r,n)<=o}getSvgPathData(r=!0){const{start:n,end:o}=this;return`${r?`M${n.toFixed()}`:""} L${o.toFixed()}`}}class Ah extends Fl{constructor(r){super({isClosed:!1,isFilled:!1,...r});C(this,"points");C(this,"_segments");const{points:n}=r;this.points=n}get segments(){if(!this._segments){this._segments=[];const{vertices:r}=this;for(let n=0,o=r.length-1;n<o;n++){const i=r[n],s=r[n+1];this._segments.push(new Ws({start:i,end:s}))}this.isClosed&&this._segments.push(new Ws({start:r[r.length-1],end:r[0]}))}return this._segments}getLength(){return this.segments.reduce((r,n)=>r+n.length,0)}getVertices(){return this.points}nearestPoint(r){const{segments:n}=this;let o=this.points[0],i=1/0,s,a;for(let l=0;l<n.length;l++)s=n[l].nearestPoint(r),a=w.Dist2(s,r),a<i&&(o=s,i=a);if(!o)throw Error("nearest point not found");return o}hitTestLineSegment(r,n,o=0){const{segments:i}=this;for(let s=0,a=i.length;s<a;s++)if(i[s].hitTestLineSegment(r,n,o))return!0;return!1}getSvgPathData(){const{vertices:r}=this;return r.length<2?"":r.reduce((n,o,i)=>i===0?`M ${o.x} ${o.y}`:`${n} L ${o.x} ${o.y}`,"")}}class Vt extends Ah{constructor(e){super({...e}),this.isClosed=!0}}class ia extends Vt{constructor(r){const{x:n=0,y:o=0,width:i,height:s}=r;super({...r,points:[new w(n,o),new w(n+i,o),new w(n+i,o+s),new w(n,o+s)]});C(this,"x");C(this,"y");C(this,"w");C(this,"h");this.x=n,this.y=o,this.w=i,this.h=s}getBounds(){return new ee(this.x,this.y,this.w,this.h)}getSvgPathData(){const{x:r,y:n,w:o,h:i}=this;return`M${r},${n} h${o} v${i} h-${o}z`}}class Si{constructor(e){this.editor=e}canSnap(e){return!0}canScroll(e){return!1}canBind(e){return!0}canEdit(e){return!1}canResize(e){return!0}canEditInReadOnly(e){return!1}canCrop(e){return!1}canBeLaidOut(e){return!0}providesBackgroundForChildren(e){return!1}hideResizeHandles(e){return!1}hideRotateHandle(e){return!1}hideSelectionBoundsBg(e){return!1}hideSelectionBoundsFg(e){return!1}isAspectRatioLocked(e){return!1}canReceiveNewChildrenOfType(e,r){return!1}canDropShapes(e,r){return!1}expandSelectionOutlinePx(e){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(e){return{}}getHandleSnapGeometry(e){return{}}getText(e){}}C(Si,"props"),C(Si,"migrations"),C(Si,"type");function di(t,e,r={}){const{closed:n=!1,snap:o=1,start:i="outset",end:s="outset",lengthRatio:a=2,style:l="dashed",forceSolid:c=!1}=r;let u=0,d=0,f=1,p=0,g=0;if(c)return{strokeDasharray:"none",strokeDashoffset:"none"};switch(l){case"dashed":{f=1,u=Math.min(e*a,t/4);break}case"dotted":{f=100,u=e/f;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return n||(i==="outset"?(t+=u/2,g+=u/2):i==="skip"&&(t-=u,g-=u),s==="outset"?t+=u/2:s==="skip"&&(t-=u)),d=Math.floor(t/u/(2*f)),d-=d%o,d<3&&l==="dashed"?t/e<4?(u=t,d=1,p=0):(u=t*(1/3),p=t*(1/3)):(u=t/d/(2*f),n?(g=u/2,p=(t-d*u)/d):p=(t-d*u)/Math.max(1,d-1)),{strokeDasharray:[u,p].join(" "),strokeDashoffset:g.toString()}}function jN({bounds:t,className:e}){const r=F(),n=H("zoom level",()=>r.getZoomLevel(),[r]);return h.jsx("g",{className:e,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:t.sides.map((o,i)=>{const{strokeDasharray:s,strokeDashoffset:a}=di(o[0].dist(o[1]),1/n,{style:"dashed",lengthRatio:4});return h.jsx("line",{x1:o[0].x,y1:o[0].y,x2:o[1].x,y2:o[1].y,strokeDasharray:s,strokeDashoffset:a},i)})})}class $S extends Si{hideSelectionBoundsFg(){return!0}canBind(){return!1}getDefaultProps(){return{}}getGeometry(e){const r=this.editor.getSortedChildIdsForParent(e.id);return r.length===0?new ia({width:1,height:1,isFilled:!1}):new bi({children:r.map(n=>{const o=this.editor.getShape(n),i=this.editor.getShapeGeometry(n),s=this.editor.getShapeLocalTransform(o).applyToPoints(i.vertices);return i.isClosed?new Vt({points:s,isFilled:!0}):new Ah({points:s})})})}component(e){const r=this.editor.getErasingShapeIds().includes(e.id),{hintingShapeIds:n}=this.editor.getCurrentPageState(),o=n.length>0&&n.some(a=>a!==e.id&&this.editor.isShapeOfType(this.editor.getShape(a),"group")),i=this.editor.getCurrentPageState().focusedGroupId!==e.id;if(!r&&(i||o))return null;const s=this.editor.getShapeGeometry(e).bounds;return h.jsx(xl,{id:e.id,children:h.jsx(jN,{className:"tl-group",bounds:s})})}indicator(e){const r=this.editor.getShapeGeometry(e).bounds;return h.jsx(jN,{className:"",bounds:r})}onChildrenChange(e){const r=this.editor.getSortedChildIdsForParent(e.id);if(r.length===0){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([e.id]);return}else if(r.length===1){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(r,e.parentId),this.editor.deleteShapes([e.id]);return}}}C($S,"type","group"),C($S,"props",eV),C($S,"migrations",tV);const sY=[$S],UPe=new Set(sY.map(t=>t.type));function aY(t){const e=[...sY],r=new Set;for(const n of t){if(UPe.has(n.type))throw new Error(`Shape type "${n.type}" is a core shapes type and cannot be overridden`);if(r.has(n.type))throw new Error(`Shape type "${n.type}" is defined more than once`);e.push(n),r.add(n.type)}return e}var Jx={},zPe=V,Io=zPe([].slice),HPe=tn,WPe=or,lY=Dl.f,KPe=Io,cY=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],GPe=function(t){try{return lY(t)}catch{return KPe(cY)}};Jx.f=function(e){return cY&&HPe(e)==="Window"?GPe(e):lY(WPe(e))};var DN=Rx,VPe=ut,Ct=function(t,e,r){return r.get&&DN(r.get,e,{getter:!0}),r.set&&DN(r.set,e,{setter:!0}),VPe.f(t,e,r)},SO={},YPe=ve;SO.f=YPe;var XPe=te,wO=XPe,LN=wO,qPe=ke,ZPe=SO,QPe=ut.f,Ut=function(t){var e=LN.Symbol||(LN.Symbol={});qPe(e,t)||QPe(e,t,{value:ZPe.f(t)})},JPe=ne,eEe=be,tEe=ve,rEe=nt,uY=function(){var t=eEe("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=tEe("toPrimitive");e&&!e[n]&&rEe(e,n,function(o){return JPe(r,this)},{arity:1})},nEe=ut.f,oEe=ke,iEe=ve,NN=iEe("toStringTag"),Gn=function(t,e,r){t&&!r&&(t=t.prototype),t&&!oEe(t,NN)&&nEe(t,NN,{configurable:!0,value:e})},sEe=dt,aEe=V,lEe=Ml,cEe=je,uEe=Ke,dEe=qg,FN=aEe([].push),Ta=function(t){var e=t===1,r=t===2,n=t===3,o=t===4,i=t===6,s=t===7,a=t===5||i;return function(l,c,u,d){for(var f=cEe(l),p=lEe(f),g=uEe(p),m=sEe(c,u),S=0,y=d||dEe,v=e?y(l,g):r||s?y(l,0):void 0,b,$;g>S;S++)if((a||S in p)&&(b=p[S],$=m(b,S,f),t))if(e)v[S]=$;else if($)switch(t){case 3:return!0;case 5:return b;case 6:return S;case 2:FN(v,b)}else switch(t){case 4:return!1;case 7:FN(v,b)}return i?-1:n||o?o:v}},Jt={forEach:Ta(0),map:Ta(1),filter:Ta(2),some:Ta(3),every:Ta(4),find:Ta(5),findIndex:Ta(6),filterReject:Ta(7)},e1=A,sm=te,xO=ne,hEe=V,Zd=ge,Qd=eu,fEe=q,hr=ke,pEe=rn,uT=re,t1=or,bO=ga,gEe=Ee,dT=wo,Jd=ar,dY=Eh,mEe=Dl,hY=Jx,vEe=Gg,fY=vr,pY=ut,yEe=jx,gY=Hg,dI=nt,SEe=Ct,$O=jl,wEe=Mx,mY=Wg,BN=ru,xEe=ve,bEe=SO,$Ee=Ut,IEe=uY,PEe=Gn,vY=et,r1=Jt.forEach,Mn=wEe("hidden"),n1="Symbol",Sg="prototype",EEe=vY.set,UN=vY.getterFor(n1),Wo=Object[Sg],Ec=sm.Symbol,tp=Ec&&Ec[Sg],CEe=sm.RangeError,_Ee=sm.TypeError,hI=sm.QObject,yY=fY.f,Cc=pY.f,SY=hY.f,TEe=gY.f,wY=hEe([].push),sa=$O("symbols"),am=$O("op-symbols"),AEe=$O("wks"),hT=!hI||!hI[Sg]||!hI[Sg].findChild,xY=function(t,e,r){var n=yY(Wo,e);n&&delete Wo[e],Cc(t,e,r),n&&t!==Wo&&Cc(Wo,e,n)},fT=Zd&&fEe(function(){return Jd(Cc({},"a",{get:function(){return Cc(this,"a",{value:7}).a}})).a!==7})?xY:Cc,fI=function(t,e){var r=sa[t]=Jd(tp);return EEe(r,{type:n1,tag:t,description:e}),Zd||(r.description=e),r},o1=function(e,r,n){e===Wo&&o1(am,r,n),uT(e);var o=bO(r);return uT(n),hr(sa,o)?(n.enumerable?(hr(e,Mn)&&e[Mn][o]&&(e[Mn][o]=!1),n=Jd(n,{enumerable:dT(0,!1)})):(hr(e,Mn)||Cc(e,Mn,dT(1,Jd(null))),e[Mn][o]=!0),fT(e,o,n)):Cc(e,o,n)},IO=function(e,r){uT(e);var n=t1(r),o=dY(n).concat(IY(n));return r1(o,function(i){(!Zd||xO(pT,n,i))&&o1(e,i,n[i])}),e},kEe=function(e,r){return r===void 0?Jd(e):IO(Jd(e),r)},pT=function(e){var r=bO(e),n=xO(TEe,this,r);return this===Wo&&hr(sa,r)&&!hr(am,r)?!1:n||!hr(this,r)||!hr(sa,r)||hr(this,Mn)&&this[Mn][r]?n:!0},bY=function(e,r){var n=t1(e),o=bO(r);if(!(n===Wo&&hr(sa,o)&&!hr(am,o))){var i=yY(n,o);return i&&hr(sa,o)&&!(hr(n,Mn)&&n[Mn][o])&&(i.enumerable=!0),i}},$Y=function(e){var r=SY(t1(e)),n=[];return r1(r,function(o){!hr(sa,o)&&!hr(mY,o)&&wY(n,o)}),n},IY=function(t){var e=t===Wo,r=SY(e?am:t1(t)),n=[];return r1(r,function(o){hr(sa,o)&&(!e||hr(Wo,o))&&wY(n,sa[o])}),n};Qd||(Ec=function(){if(pEe(tp,this))throw new _Ee("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:gEe(arguments[0]),r=BN(e),n=function(o){var i=this===void 0?sm:this;i===Wo&&xO(n,am,o),hr(i,Mn)&&hr(i[Mn],r)&&(i[Mn][r]=!1);var s=dT(1,o);try{fT(i,r,s)}catch(a){if(!(a instanceof CEe))throw a;xY(i,r,s)}};return Zd&&hT&&fT(Wo,r,{configurable:!0,set:n}),fI(r,e)},tp=Ec[Sg],dI(tp,"toString",function(){return UN(this).tag}),dI(Ec,"withoutSetter",function(t){return fI(BN(t),t)}),gY.f=pT,pY.f=o1,yEe.f=IO,fY.f=bY,mEe.f=hY.f=$Y,vEe.f=IY,bEe.f=function(t){return fI(xEe(t),t)},Zd&&(SEe(tp,"description",{configurable:!0,get:function(){return UN(this).description}}),dI(Wo,"propertyIsEnumerable",pT,{unsafe:!0})));e1({global:!0,constructor:!0,wrap:!0,forced:!Qd,sham:!Qd},{Symbol:Ec});r1(dY(AEe),function(t){$Ee(t)});e1({target:n1,stat:!0,forced:!Qd},{useSetter:function(){hT=!0},useSimple:function(){hT=!1}});e1({target:"Object",stat:!0,forced:!Qd,sham:!Zd},{create:kEe,defineProperty:o1,defineProperties:IO,getOwnPropertyDescriptor:bY});e1({target:"Object",stat:!0,forced:!Qd},{getOwnPropertyNames:$Y});IEe();PEe(Ec,n1);mY[Mn]=!0;var OEe=eu,PY=OEe&&!!Symbol.for&&!!Symbol.keyFor,MEe=A,REe=be,jEe=ke,DEe=Ee,EY=jl,LEe=PY,pI=EY("string-to-symbol-registry"),NEe=EY("symbol-to-string-registry");MEe({target:"Symbol",stat:!0,forced:!LEe},{for:function(t){var e=DEe(t);if(jEe(pI,e))return pI[e];var r=REe("Symbol")(e);return pI[e]=r,NEe[r]=e,r}});var FEe=A,BEe=ke,UEe=Rl,zEe=tu,HEe=jl,WEe=PY,zN=HEe("symbol-to-string-registry");FEe({target:"Symbol",stat:!0,forced:!WEe},{keyFor:function(e){if(!UEe(e))throw new TypeError(zEe(e)+" is not a symbol");if(BEe(zN,e))return zN[e]}});var KEe=V,HN=vs,GEe=Ce,WN=tn,VEe=Ee,KN=KEe([].push),CY=function(t){if(GEe(t))return t;if(HN(t)){for(var e=t.length,r=[],n=0;n<e;n++){var o=t[n];typeof o=="string"?KN(r,o):(typeof o=="number"||WN(o)==="Number"||WN(o)==="String")&&KN(r,VEe(o))}var i=r.length,s=!0;return function(a,l){if(s)return s=!1,l;if(HN(this))return l;for(var c=0;c<i;c++)if(r[c]===a)return l}}},YEe=A,_Y=be,TY=yn,XEe=ne,lm=V,AY=q,GN=Ce,VN=Rl,kY=Io,qEe=CY,ZEe=eu,QEe=String,hl=_Y("JSON","stringify"),kv=lm(/./.exec),YN=lm("".charAt),JEe=lm("".charCodeAt),eCe=lm("".replace),tCe=lm(1 .toString),rCe=/[\uD800-\uDFFF]/g,XN=/^[\uD800-\uDBFF]$/,qN=/^[\uDC00-\uDFFF]$/,ZN=!ZEe||AY(function(){var t=_Y("Symbol")("stringify detection");return hl([t])!=="[null]"||hl({a:t})!=="{}"||hl(Object(t))!=="{}"}),QN=AY(function(){return hl("\uDF06\uD834")!=='"\\udf06\\ud834"'||hl("\uDEAD")!=='"\\udead"'}),nCe=function(t,e){var r=kY(arguments),n=qEe(e);if(!(!GN(n)&&(t===void 0||VN(t))))return r[1]=function(o,i){if(GN(n)&&(i=XEe(n,this,QEe(o),i)),!VN(i))return i},TY(hl,null,r)},oCe=function(t,e,r){var n=YN(r,e-1),o=YN(r,e+1);return kv(XN,t)&&!kv(qN,o)||kv(qN,t)&&!kv(XN,n)?"\\u"+tCe(JEe(t,0),16):t};hl&&YEe({target:"JSON",stat:!0,arity:3,forced:ZN||QN},{stringify:function(e,r,n){var o=kY(arguments),i=TY(ZN?nCe:hl,null,o);return QN&&typeof i=="string"?eCe(i,rCe,oCe):i}});var iCe=A,sCe=eu,aCe=q,OY=Gg,lCe=je,cCe=!sCe||aCe(function(){OY.f(1)});iCe({target:"Object",stat:!0,forced:cCe},{getOwnPropertySymbols:function(e){var r=OY.f;return r?r(lCe(e)):[]}});var uCe=A,dCe=ge,hCe=te,Ov=V,fCe=ke,pCe=Ce,gCe=rn,mCe=Ee,vCe=Ct,yCe=Ph,Ls=hCe.Symbol,nc=Ls&&Ls.prototype;if(dCe&&pCe(Ls)&&(!("description"in nc)||Ls().description!==void 0)){var JN={},Mv=function(){var e=arguments.length<1||arguments[0]===void 0?void 0:mCe(arguments[0]),r=gCe(nc,this)?new Ls(e):e===void 0?Ls():Ls(e);return e===""&&(JN[r]=!0),r};yCe(Mv,Ls),Mv.prototype=nc,nc.constructor=Mv;var SCe=String(Ls("description detection"))==="Symbol(description detection)",wCe=Ov(nc.valueOf),xCe=Ov(nc.toString),bCe=/^Symbol\((.*)\)[^)]+$/,$Ce=Ov("".replace),ICe=Ov("".slice);vCe(nc,"description",{configurable:!0,get:function(){var e=wCe(this);if(fCe(JN,e))return"";var r=xCe(e),n=SCe?ICe(r,7,-1):$Ce(r,bCe,"$1");return n===""?void 0:n}}),uCe({global:!0,constructor:!0,forced:!0},{Symbol:Mv})}var PCe=Ut;PCe("asyncIterator");var ECe=Ut;ECe("hasInstance");var CCe=Ut;CCe("isConcatSpreadable");var _Ce=Ut;_Ce("iterator");var TCe=Ut;TCe("match");var ACe=Ut;ACe("matchAll");var kCe=Ut;kCe("replace");var OCe=Ut;OCe("search");var MCe=Ut;MCe("species");var RCe=Ut;RCe("split");var jCe=Ut,DCe=uY;jCe("toPrimitive");DCe();var LCe=be,NCe=Ut,FCe=Gn;NCe("toStringTag");FCe(LCe("Symbol"),"Symbol");var BCe=Ut;BCe("unscopables");var UCe=V,zCe=Pe,i1=function(t,e,r){try{return UCe(zCe(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},HCe=Ie,MY=function(t){return HCe(t)||t===null},WCe=MY,KCe=String,GCe=TypeError,RY=function(t){if(WCe(t))return t;throw new GCe("Can't set "+KCe(t)+" as a prototype")},VCe=i1,YCe=Ie,XCe=St,qCe=RY,_i=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=VCe(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(o,i){return XCe(o),qCe(i),YCe(o)&&(t?r(o,i):o.__proto__=i),o}}():void 0),ZCe=ut.f,jY=function(t,e,r){r in t||ZCe(t,r,{configurable:!0,get:function(){return e[r]},set:function(n){e[r]=n}})},QCe=Ce,JCe=Ie,eF=_i,ou=function(t,e,r){var n,o;return eF&&QCe(n=e.constructor)&&n!==r&&JCe(o=n.prototype)&&o!==r.prototype&&eF(t,o),t},e_e=Ee,kh=function(t,e){return t===void 0?arguments.length<2?"":e:e_e(t)},t_e=Ie,r_e=sr,DY=function(t,e){t_e(e)&&"cause"in e&&r_e(t,"cause",e.cause)},n_e=V,LY=Error,o_e=n_e("".replace),i_e=function(t){return String(new LY(t).stack)}("zxcasd"),NY=/\n\s*at [^:]*:[^\n]*/,s_e=NY.test(i_e),PO=function(t,e){if(s_e&&typeof t=="string"&&!LY.prepareStackTrace)for(;e--;)t=o_e(t,NY,"");return t},a_e=q,l_e=wo,FY=!a_e(function(){var t=new Error("a");return"stack"in t?(Object.defineProperty(t,"stack",l_e(1,7)),t.stack!==7):!0}),c_e=sr,u_e=PO,d_e=FY,tF=Error.captureStackTrace,EO=function(t,e,r,n){d_e&&(tF?tF(t,e):c_e(t,"stack",u_e(r,n)))},rF=be,h_e=ke,nF=sr,f_e=rn,oF=_i,iF=Ph,sF=jY,p_e=ou,g_e=kh,m_e=DY,v_e=EO,y_e=ge,BY=function(t,e,r,n){var o="stackTraceLimit",i=n?2:1,s=t.split("."),a=s[s.length-1],l=rF.apply(null,s);if(l){var c=l.prototype;if(h_e(c,"cause")&&delete c.cause,!r)return l;var u=rF("Error"),d=e(function(f,p){var g=g_e(n?p:f,void 0),m=n?new l(f):new l;return g!==void 0&&nF(m,"message",g),v_e(m,d,m.stack,2),this&&f_e(c,this)&&p_e(m,this,d),arguments.length>i&&m_e(m,arguments[i]),m});d.prototype=c,a!=="Error"?oF?oF(d,u):iF(d,u,{name:!0}):y_e&&o in l&&(sF(d,l,o),sF(d,l,"prepareStackTrace")),iF(d,l);try{c.name!==a&&nF(c,"name",a),c.constructor=d}catch{}return d}},UY=A,S_e=te,xs=yn,zY=BY,gT="WebAssembly",aF=S_e[gT],d0=new Error("e",{cause:7}).cause!==7,iu=function(t,e){var r={};r[t]=zY(t,e,d0),UY({global:!0,constructor:!0,arity:1,forced:d0},r)},CO=function(t,e){if(aF&&aF[t]){var r={};r[t]=zY(gT+"."+t,e,d0),UY({target:gT,stat:!0,constructor:!0,arity:1,forced:d0},r)}};iu("Error",function(t){return function(r){return xs(t,this,arguments)}});iu("EvalError",function(t){return function(r){return xs(t,this,arguments)}});iu("RangeError",function(t){return function(r){return xs(t,this,arguments)}});iu("ReferenceError",function(t){return function(r){return xs(t,this,arguments)}});iu("SyntaxError",function(t){return function(r){return xs(t,this,arguments)}});iu("TypeError",function(t){return function(r){return xs(t,this,arguments)}});iu("URIError",function(t){return function(r){return xs(t,this,arguments)}});CO("CompileError",function(t){return function(r){return xs(t,this,arguments)}});CO("LinkError",function(t){return function(r){return xs(t,this,arguments)}});CO("RuntimeError",function(t){return function(r){return xs(t,this,arguments)}});var w_e=ge,x_e=q,b_e=re,lF=kh,IS=Error.prototype.toString,$_e=x_e(function(){if(w_e){var t=Object.create(Object.defineProperty({},"name",{get:function(){return this===t}}));if(IS.call(t)!=="true")return!0}return IS.call({message:1,name:2})!=="2: 1"||IS.call({})!=="Error"}),HY=$_e?function(){var e=b_e(this),r=lF(e.name,"Error"),n=lF(e.message);return r?n?r+": "+n:r:n}:IS,I_e=nt,cF=HY,uF=Error.prototype;uF.toString!==cF&&I_e(uF,"toString",cF);var P_e=q,_O=!P_e(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),E_e=ke,C_e=Ce,__e=je,T_e=Mx,A_e=_O,dF=T_e("IE_PROTO"),mT=Object,k_e=mT.prototype,lr=A_e?mT.getPrototypeOf:function(t){var e=__e(t);if(E_e(e,dF))return e[dF];var r=e.constructor;return C_e(r)&&e instanceof r?r.prototype:e instanceof mT?k_e:null},Oh={},O_e=ve,M_e=Oh,R_e=O_e("iterator"),j_e=Array.prototype,TO=function(t){return t!==void 0&&(M_e.Array===t||j_e[R_e]===t)},D_e=bo,hF=Qt,L_e=nr,N_e=Oh,F_e=ve,B_e=F_e("iterator"),Bl=function(t){if(!L_e(t))return hF(t,B_e)||hF(t,"@@iterator")||N_e[D_e(t)]},U_e=ne,z_e=Pe,H_e=re,W_e=tu,K_e=Bl,G_e=TypeError,su=function(t,e){var r=arguments.length<2?K_e(t):e;if(z_e(r))return H_e(U_e(r,t));throw new G_e(W_e(t)+" is not iterable")},V_e=ne,fF=re,Y_e=Qt,Ul=function(t,e,r){var n,o;fF(t);try{if(n=Y_e(t,"return"),!n){if(e==="throw")throw r;return r}n=V_e(n,t)}catch(i){o=!0,n=i}if(e==="throw")throw r;if(o)throw n;return fF(n),r},X_e=dt,q_e=ne,Z_e=re,Q_e=tu,J_e=TO,eTe=Ke,pF=rn,tTe=su,rTe=Bl,gF=Ul,nTe=TypeError,PS=function(t,e){this.stopped=t,this.result=e},mF=PS.prototype,zt=function(t,e,r){var n=r&&r.that,o=!!(r&&r.AS_ENTRIES),i=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),a=!!(r&&r.INTERRUPTED),l=X_e(e,n),c,u,d,f,p,g,m,S=function(v){return c&&gF(c,"normal",v),new PS(!0,v)},y=function(v){return o?(Z_e(v),a?l(v[0],v[1],S):l(v[0],v[1])):a?l(v,S):l(v)};if(i)c=t.iterator;else if(s)c=t;else{if(u=rTe(t),!u)throw new nTe(Q_e(t)+" is not iterable");if(J_e(u)){for(d=0,f=eTe(t);f>d;d++)if(p=y(t[d]),p&&pF(mF,p))return p;return new PS(!1)}c=tTe(t,u)}for(g=i?t.next:c.next;!(m=q_e(g,c)).done;){try{p=y(m.value)}catch(v){gF(c,"throw",v)}if(typeof p=="object"&&p&&pF(mF,p))return p}return new PS(!1)},oTe=A,iTe=rn,sTe=lr,h0=_i,aTe=Ph,WY=ar,gI=sr,mI=wo,lTe=DY,cTe=EO,uTe=zt,dTe=kh,hTe=ve,fTe=hTe("toStringTag"),f0=Error,pTe=[].push,eh=function(e,r){var n=iTe(vI,this),o;h0?o=h0(new f0,n?sTe(this):vI):(o=n?this:WY(vI),gI(o,fTe,"Error")),r!==void 0&&gI(o,"message",dTe(r)),cTe(o,eh,o.stack,1),arguments.length>2&&lTe(o,arguments[2]);var i=[];return uTe(e,pTe,{that:i}),gI(o,"errors",i),o};h0?h0(eh,f0):aTe(eh,f0,{name:!0});var vI=eh.prototype=WY(f0.prototype,{constructor:mI(1,eh),message:mI(1,""),name:mI(1,"AggregateError")});oTe({global:!0,constructor:!0,arity:2},{AggregateError:eh});var gTe=A,mTe=be,vTe=yn,vF=q,yTe=BY,AO="AggregateError",yF=mTe(AO),SF=!vF(function(){return yF([1]).errors[0]!==1})&&vF(function(){return yF([1],AO,{cause:7}).cause!==7});gTe({global:!0,constructor:!0,arity:2,forced:SF},{AggregateError:yTe(AO,function(t){return function(r,n){return vTe(t,this,arguments)}},SF,!0)});var STe=ge,wTe=ut,xTe=wo,Ti=function(t,e,r){STe?wTe.f(t,e,xTe(0,r)):t[e]=r},bTe=q,$Te=ve,ITe=pa,PTe=$Te("species"),cm=function(t){return ITe>=51||!bTe(function(){var e=[],r=e.constructor={};return r[PTe]=function(){return{foo:1}},e[t](Boolean).foo!==1})},ETe=A,CTe=q,_Te=vs,TTe=Ie,ATe=je,kTe=Ke,wF=nu,xF=Ti,OTe=qg,MTe=cm,RTe=ve,jTe=pa,KY=RTe("isConcatSpreadable"),DTe=jTe>=51||!CTe(function(){var t=[];return t[KY]=!1,t.concat()[0]!==t}),LTe=function(t){if(!TTe(t))return!1;var e=t[KY];return e!==void 0?!!e:_Te(t)},NTe=!DTe||!MTe("concat");ETe({target:"Array",proto:!0,arity:1,forced:NTe},{concat:function(e){var r=ATe(this),n=OTe(r,0),o=0,i,s,a,l,c;for(i=-1,a=arguments.length;i<a;i++)if(c=i===-1?r:arguments[i],LTe(c))for(l=kTe(c),wF(o+l),s=0;s<l;s++,o++)s in c&&xF(n,o,c[s]);else wF(o+1),xF(n,o++,c);return n.length=o,n}});var bF=tu,FTe=TypeError,s1=function(t,e){if(!delete t[e])throw new FTe("Cannot delete property "+bF(e)+" of "+bF(t))},BTe=je,yI=ms,UTe=Ke,zTe=s1,HTe=Math.min,GY=[].copyWithin||function(e,r){var n=BTe(this),o=UTe(n),i=yI(e,o),s=yI(r,o),a=arguments.length>2?arguments[2]:void 0,l=HTe((a===void 0?o:yI(a,o))-s,o-i),c=1;for(s<i&&i<s+l&&(c=-1,s+=l-1,i+=l-1);l-- >0;)s in n?n[i]=n[s]:zTe(n,i),i+=c,s+=c;return n},WTe=A,KTe=GY,GTe=Bt;WTe({target:"Array",proto:!0},{copyWithin:KTe});GTe("copyWithin");var VTe=q,Ai=function(t,e){var r=[][t];return!!r&&VTe(function(){r.call(null,e||function(){return 1},1)})},YTe=A,XTe=Jt.every,qTe=Ai,ZTe=qTe("every");YTe({target:"Array",proto:!0,forced:!ZTe},{every:function(e){return XTe(this,e,arguments.length>1?arguments[1]:void 0)}});var QTe=je,$F=ms,JTe=Ke,kO=function(e){for(var r=QTe(this),n=JTe(r),o=arguments.length,i=$F(o>1?arguments[1]:void 0,n),s=o>2?arguments[2]:void 0,a=s===void 0?n:$F(s,n);a>i;)r[i++]=e;return r},e2e=A,t2e=kO,r2e=Bt;e2e({target:"Array",proto:!0},{fill:t2e});r2e("fill");var n2e=A,o2e=Jt.filter,i2e=cm,s2e=i2e("filter");n2e({target:"Array",proto:!0,forced:!s2e},{filter:function(e){return o2e(this,e,arguments.length>1?arguments[1]:void 0)}});var a2e=A,l2e=Jt.find,c2e=Bt,vT="find",VY=!0;vT in[]&&Array(1)[vT](function(){VY=!1});a2e({target:"Array",proto:!0,forced:VY},{find:function(e){return l2e(this,e,arguments.length>1?arguments[1]:void 0)}});c2e(vT);var u2e=A,d2e=Jt.findIndex,h2e=Bt,yT="findIndex",YY=!0;yT in[]&&Array(1)[yT](function(){YY=!1});u2e({target:"Array",proto:!0,forced:YY},{findIndex:function(e){return d2e(this,e,arguments.length>1?arguments[1]:void 0)}});h2e(yT);var f2e=dt,p2e=Ml,g2e=je,m2e=Ke,IF=function(t){var e=t===1;return function(r,n,o){for(var i=g2e(r),s=p2e(i),a=m2e(s),l=f2e(n,o),c,u;a-- >0;)if(c=s[a],u=l(c,a,i),u)switch(t){case 0:return c;case 1:return a}return e?-1:void 0}},a1={findLast:IF(0),findLastIndex:IF(1)},v2e=A,y2e=a1.findLast,S2e=Bt;v2e({target:"Array",proto:!0},{findLast:function(e){return y2e(this,e,arguments.length>1?arguments[1]:void 0)}});S2e("findLast");var w2e=A,x2e=a1.findLastIndex,b2e=Bt;w2e({target:"Array",proto:!0},{findLastIndex:function(e){return x2e(this,e,arguments.length>1?arguments[1]:void 0)}});b2e("findLastIndex");var $2e=Jt.forEach,I2e=Ai,P2e=I2e("forEach"),XY=P2e?[].forEach:function(e){return $2e(this,e,arguments.length>1?arguments[1]:void 0)},E2e=A,PF=XY;E2e({target:"Array",proto:!0,forced:[].forEach!==PF},{forEach:PF});var C2e=re,_2e=Ul,OO=function(t,e,r,n){try{return n?e(C2e(r)[0],r[1]):e(r)}catch(o){_2e(t,"throw",o)}},T2e=dt,A2e=ne,k2e=je,O2e=OO,M2e=TO,R2e=ys,j2e=Ke,EF=Ti,D2e=su,L2e=Bl,CF=Array,qY=function(e){var r=k2e(e),n=R2e(this),o=arguments.length,i=o>1?arguments[1]:void 0,s=i!==void 0;s&&(i=T2e(i,o>2?arguments[2]:void 0));var a=L2e(r),l=0,c,u,d,f,p,g;if(a&&!(this===CF&&M2e(a)))for(u=n?new this:[],f=D2e(r,a),p=f.next;!(d=A2e(p,f)).done;l++)g=s?O2e(f,i,[d.value,l],!0):d.value,EF(u,l,g);else for(c=j2e(r),u=n?new this(c):CF(c);c>l;l++)g=s?i(r[l],l):r[l],EF(u,l,g);return u.length=l,u},N2e=ve,ZY=N2e("iterator"),QY=!1;try{var F2e=0,_F={next:function(){return{done:!!F2e++}},return:function(){QY=!0}};_F[ZY]=function(){return this},Array.from(_F,function(){throw 2})}catch{}var l1=function(t,e){try{if(!e&&!QY)return!1}catch{return!1}var r=!1;try{var n={};n[ZY]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},B2e=A,U2e=qY,z2e=l1,H2e=!z2e(function(t){Array.from(t)});B2e({target:"Array",stat:!0,forced:H2e},{from:U2e});var W2e=A,K2e=Kg.includes,G2e=q,V2e=Bt,Y2e=G2e(function(){return!Array(1).includes()});W2e({target:"Array",proto:!0,forced:Y2e},{includes:function(e){return K2e(this,e,arguments.length>1?arguments[1]:void 0)}});V2e("includes");var X2e=A,q2e=Ll,Z2e=Kg.indexOf,Q2e=Ai,ST=q2e([].indexOf),JY=!!ST&&1/ST([1],1,-0)<0,J2e=JY||!Q2e("indexOf");X2e({target:"Array",proto:!0,forced:J2e},{indexOf:function(e){var r=arguments.length>1?arguments[1]:void 0;return JY?ST(this,e,r)||0:Z2e(this,e,r)}});var eAe=A,tAe=vs;eAe({target:"Array",stat:!0},{isArray:tAe});var rAe=q,nAe=Ce,oAe=Ie,TF=lr,iAe=nt,sAe=ve,wT=sAe("iterator"),eX=!1,Uc,SI,wI;[].keys&&(wI=[].keys(),"next"in wI?(SI=TF(TF(wI)),SI!==Object.prototype&&(Uc=SI)):eX=!0);var aAe=!oAe(Uc)||rAe(function(){var t={};return Uc[wT].call(t)!==t});aAe&&(Uc={});nAe(Uc[wT])||iAe(Uc,wT,function(){return this});var Mh={IteratorPrototype:Uc,BUGGY_SAFARI_ITERATORS:eX},lAe=Mh.IteratorPrototype,cAe=ar,uAe=wo,dAe=Gn,hAe=Oh,fAe=function(){return this},au=function(t,e,r,n){var o=e+" Iterator";return t.prototype=cAe(lAe,{next:uAe(+!n,r)}),dAe(t,o,!1),hAe[o]=fAe,t},pAe=A,gAe=ne,tX=Ih,mAe=Ce,vAe=au,AF=lr,kF=_i,yAe=Gn,SAe=sr,xI=nt,wAe=ve,xAe=Oh,rX=Mh,bAe=tX.PROPER,$Ae=tX.CONFIGURABLE,OF=rX.IteratorPrototype,Rv=rX.BUGGY_SAFARI_ITERATORS,xf=wAe("iterator"),MF="keys",bf="values",RF="entries",IAe=function(){return this},MO=function(t,e,r,n,o,i,s){vAe(r,e,n);var a=function(y){if(y===o&&f)return f;if(!Rv&&y&&y in u)return u[y];switch(y){case MF:return function(){return new r(this,y)};case bf:return function(){return new r(this,y)};case RF:return function(){return new r(this,y)}}return function(){return new r(this)}},l=e+" Iterator",c=!1,u=t.prototype,d=u[xf]||u["@@iterator"]||o&&u[o],f=!Rv&&d||a(o),p=e==="Array"&&u.entries||d,g,m,S;if(p&&(g=AF(p.call(new t)),g!==Object.prototype&&g.next&&(AF(g)!==OF&&(kF?kF(g,OF):mAe(g[xf])||xI(g,xf,IAe)),yAe(g,l,!0))),bAe&&o===bf&&d&&d.name!==bf&&($Ae?SAe(u,"name",bf):(c=!0,f=function(){return gAe(d,this)})),o)if(m={values:a(bf),keys:i?f:a(MF),entries:a(RF)},s)for(S in m)(Rv||c||!(S in u))&&xI(u,S,m[S]);else pAe({target:e,proto:!0,forced:Rv||c},m);return u[xf]!==f&&xI(u,xf,f,{name:o}),xAe[e]=f,m},Nr=function(t,e){return{value:t,done:e}},PAe=or,RO=Bt,jF=Oh,nX=et,EAe=ut.f,CAe=MO,jv=Nr,_Ae=ge,oX="Array Iterator",TAe=nX.set,AAe=nX.getterFor(oX),iX=CAe(Array,"Array",function(t,e){TAe(this,{type:oX,target:PAe(t),index:0,kind:e})},function(){var t=AAe(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=null,jv(void 0,!0);switch(t.kind){case"keys":return jv(r,!1);case"values":return jv(e[r],!1)}return jv([r,e[r]],!1)},"values"),DF=jF.Arguments=jF.Array;RO("keys");RO("values");RO("entries");if(_Ae&&DF.name!=="values")try{EAe(DF,"name",{value:"values"})}catch{}var kAe=A,OAe=V,MAe=Ml,RAe=or,jAe=Ai,DAe=OAe([].join),LAe=MAe!==Object,NAe=LAe||!jAe("join",",");kAe({target:"Array",proto:!0,forced:NAe},{join:function(e){return DAe(RAe(this),e===void 0?",":e)}});var FAe=yn,BAe=or,UAe=Et,zAe=Ke,HAe=Ai,WAe=Math.min,xT=[].lastIndexOf,sX=!!xT&&1/[1].lastIndexOf(1,-0)<0,KAe=HAe("lastIndexOf"),GAe=sX||!KAe,aX=GAe?function(e){if(sX)return FAe(xT,this,arguments)||0;var r=BAe(this),n=zAe(r);if(n===0)return-1;var o=n-1;for(arguments.length>1&&(o=WAe(o,UAe(arguments[1]))),o<0&&(o=n+o);o>=0;o--)if(o in r&&r[o]===e)return o||0;return-1}:xT,VAe=A,LF=aX;VAe({target:"Array",proto:!0,forced:LF!==[].lastIndexOf},{lastIndexOf:LF});var YAe=A,XAe=Jt.map,qAe=cm,ZAe=qAe("map");YAe({target:"Array",proto:!0,forced:!ZAe},{map:function(e){return XAe(this,e,arguments.length>1?arguments[1]:void 0)}});var QAe=A,JAe=q,eke=ys,tke=Ti,lX=Array,rke=JAe(function(){function t(){}return!(lX.of.call(t)instanceof t)});QAe({target:"Array",stat:!0,forced:rke},{of:function(){for(var e=0,r=arguments.length,n=new(eke(this)?this:lX)(r);r>e;)tke(n,e,arguments[e++]);return n.length=r,n}});var nke=ge,oke=vs,ike=TypeError,ske=Object.getOwnPropertyDescriptor,ake=nke&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),jO=ake?function(t,e){if(oke(t)&&!ske(t,"length").writable)throw new ike("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},lke=A,cke=je,uke=Ke,dke=jO,hke=nu,fke=q,pke=fke(function(){return[].push.call({length:4294967296},1)!==4294967297}),gke=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}},mke=pke||!gke();lke({target:"Array",proto:!0,arity:1,forced:mke},{push:function(e){var r=cke(this),n=uke(r),o=arguments.length;hke(n+o);for(var i=0;i<o;i++)r[n]=arguments[i],n++;return dke(r,n),n}});var vke=Pe,yke=je,Ske=Ml,wke=Ke,NF=TypeError,FF="Reduce of empty array with no initial value",BF=function(t){return function(e,r,n,o){var i=yke(e),s=Ske(i),a=wke(i);if(vke(r),a===0&&n<2)throw new NF(FF);var l=t?a-1:0,c=t?-1:1;if(n<2)for(;;){if(l in s){o=s[l],l+=c;break}if(l+=c,t?l<0:a<=l)throw new NF(FF)}for(;t?l>=0:a>l;l+=c)l in s&&(o=r(o,s[l],l,i));return o}},c1={left:BF(!1),right:BF(!0)},$f=te,xke=gs,bke=tn,Dv=function(t){return xke.slice(0,t.length)===t},u1=function(){return Dv("Bun/")?"BUN":Dv("Cloudflare-Workers")?"CLOUDFLARE":Dv("Deno/")?"DENO":Dv("Node.js/")?"NODE":$f.Bun&&typeof Bun.version=="string"?"BUN":$f.Deno&&typeof Deno.version=="object"?"DENO":bke($f.process)==="process"?"NODE":$f.window&&$f.document?"BROWSER":"REST"}(),$ke=u1,Rh=$ke==="NODE",Ike=A,Pke=c1.left,Eke=Ai,UF=pa,Cke=Rh,_ke=!Cke&&UF>79&&UF<83,Tke=_ke||!Eke("reduce");Ike({target:"Array",proto:!0,forced:Tke},{reduce:function(e){var r=arguments.length;return Pke(this,e,r,r>1?arguments[1]:void 0)}});var Ake=A,kke=c1.right,Oke=Ai,zF=pa,Mke=Rh,Rke=!Mke&&zF>79&&zF<83,jke=Rke||!Oke("reduceRight");Ake({target:"Array",proto:!0,forced:jke},{reduceRight:function(e){return kke(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Dke=A,Lke=V,Nke=vs,Fke=Lke([].reverse),HF=[1,2];Dke({target:"Array",proto:!0,forced:String(HF)===String(HF.reverse())},{reverse:function(){return Nke(this)&&(this.length=this.length),Fke(this)}});var Bke=A,WF=vs,Uke=ys,zke=Ie,KF=ms,Hke=Ke,Wke=or,Kke=Ti,Gke=ve,Vke=cm,Yke=Io,Xke=Vke("slice"),qke=Gke("species"),bI=Array,Zke=Math.max;Bke({target:"Array",proto:!0,forced:!Xke},{slice:function(e,r){var n=Wke(this),o=Hke(n),i=KF(e,o),s=KF(r===void 0?o:r,o),a,l,c;if(WF(n)&&(a=n.constructor,Uke(a)&&(a===bI||WF(a.prototype))?a=void 0:zke(a)&&(a=a[qke],a===null&&(a=void 0)),a===bI||a===void 0))return Yke(n,i,s);for(l=new(a===void 0?bI:a)(Zke(s-i,0)),c=0;i<s;i++,c++)i in n&&Kke(l,c,n[i]);return l.length=c,l}});var Qke=A,Jke=Jt.some,eOe=Ai,tOe=eOe("some");Qke({target:"Array",proto:!0,forced:!tOe},{some:function(e){return Jke(this,e,arguments.length>1?arguments[1]:void 0)}});var GF=Io,rOe=Math.floor,bT=function(t,e){var r=t.length;if(r<8)for(var n=1,o,i;n<r;){for(i=n,o=t[n];i&&e(t[i-1],o)>0;)t[i]=t[--i];i!==n++&&(t[i]=o)}else for(var s=rOe(r/2),a=bT(GF(t,0,s),e),l=bT(GF(t,s),e),c=a.length,u=l.length,d=0,f=0;d<c||f<u;)t[d+f]=d<c&&f<u?e(a[d],l[f])<=0?a[d++]:l[f++]:d<c?a[d++]:l[f++];return t},DO=bT,nOe=gs,VF=nOe.match(/firefox\/(\d+)/i),cX=!!VF&&+VF[1],oOe=gs,uX=/MSIE|Trident/.test(oOe),iOe=gs,YF=iOe.match(/AppleWebKit\/(\d+)\./),LO=!!YF&&+YF[1],sOe=A,dX=V,aOe=Pe,lOe=je,XF=Ke,cOe=s1,qF=Ee,NO=q,uOe=DO,dOe=Ai,ZF=cX,hOe=uX,QF=pa,JF=LO,Za=[],e5=dX(Za.sort),fOe=dX(Za.push),pOe=NO(function(){Za.sort(void 0)}),gOe=NO(function(){Za.sort(null)}),mOe=dOe("sort"),hX=!NO(function(){if(QF)return QF<70;if(!(ZF&&ZF>3)){if(hOe)return!0;if(JF)return JF<603;var t="",e,r,n,o;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(o=0;o<47;o++)Za.push({k:r+o,v:n})}for(Za.sort(function(i,s){return s.v-i.v}),o=0;o<Za.length;o++)r=Za[o].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),vOe=pOe||!gOe||!mOe||!hX,yOe=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:qF(e)>qF(r)?1:-1}};sOe({target:"Array",proto:!0,forced:vOe},{sort:function(e){e!==void 0&&aOe(e);var r=lOe(this);if(hX)return e===void 0?e5(r):e5(r,e);var n=[],o=XF(r),i,s;for(s=0;s<o;s++)s in r&&fOe(n,r[s]);for(uOe(n,yOe(e)),i=XF(n),s=0;s<i;)r[s]=n[s++];for(;s<o;)cOe(r,s++);return r}});var SOe=be,wOe=Ct,xOe=ve,bOe=ge,t5=xOe("species"),lu=function(t){var e=SOe(t);bOe&&e&&!e[t5]&&wOe(e,t5,{configurable:!0,get:function(){return this}})},$Oe=lu;$Oe("Array");var IOe=A,POe=je,EOe=ms,COe=Et,_Oe=Ke,TOe=jO,AOe=nu,kOe=qg,OOe=Ti,$I=s1,MOe=cm,ROe=MOe("splice"),jOe=Math.max,DOe=Math.min;IOe({target:"Array",proto:!0,forced:!ROe},{splice:function(e,r){var n=POe(this),o=_Oe(n),i=EOe(e,o),s=arguments.length,a,l,c,u,d,f;for(s===0?a=l=0:s===1?(a=0,l=o-i):(a=s-2,l=DOe(jOe(COe(r),0),o-i)),AOe(o+a-l),c=kOe(n,l),u=0;u<l;u++)d=i+u,d in n&&OOe(c,u,n[d]);if(c.length=l,a<l){for(u=i;u<o-l;u++)d=u+l,f=u+a,d in n?n[f]=n[d]:$I(n,f);for(u=o;u>o-l+a;u--)$I(n,u-1)}else if(a>l)for(u=o-l;u>i;u--)d=u+l-1,f=u+a-1,d in n?n[f]=n[d]:$I(n,f);for(u=0;u<a;u++)n[u+i]=arguments[u+2];return TOe(n,o-l+a),c}});var LOe=Ke,fX=function(t,e){for(var r=LOe(t),n=new e(r),o=0;o<r;o++)n[o]=t[r-o-1];return n},NOe=A,FOe=fX,BOe=or,UOe=Bt,zOe=Array;NOe({target:"Array",proto:!0},{toReversed:function(){return FOe(BOe(this),zOe)}});UOe("toReversed");var HOe=Ke,zl=function(t,e,r){for(var n=0,o=arguments.length>2?r:HOe(e),i=new t(o);o>n;)i[n]=e[n++];return i},WOe=te,pX=function(t,e){var r=WOe[t],n=r&&r.prototype;return n&&n[e]},KOe=A,GOe=V,VOe=Pe,YOe=or,XOe=zl,qOe=pX,ZOe=Bt,QOe=Array,JOe=GOe(qOe("Array","sort"));KOe({target:"Array",proto:!0},{toSorted:function(e){e!==void 0&&VOe(e);var r=YOe(this),n=XOe(QOe,r);return JOe(n,e)}});ZOe("toSorted");var eMe=A,tMe=Bt,rMe=nu,nMe=Ke,oMe=ms,iMe=or,sMe=Et,aMe=Array,lMe=Math.max,cMe=Math.min;eMe({target:"Array",proto:!0},{toSpliced:function(e,r){var n=iMe(this),o=nMe(n),i=oMe(e,o),s=arguments.length,a=0,l,c,u,d;for(s===0?l=c=0:s===1?(l=0,c=o-i):(l=s-2,c=cMe(lMe(sMe(r),0),o-i)),u=rMe(o+l-c),d=aMe(u);a<i;a++)d[a]=n[a];for(;a<i+l;a++)d[a]=arguments[a-i+2];for(;a<u;a++)d[a]=n[a+c-l];return d}});tMe("toSpliced");var uMe=A,dMe=je,hMe=Ke,fMe=jO,pMe=s1,gMe=nu,mMe=[].unshift(0)!==1,vMe=function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(t){return t instanceof TypeError}},yMe=mMe||!vMe();uMe({target:"Array",proto:!0,arity:1,forced:yMe},{unshift:function(e){var r=dMe(this),n=hMe(r),o=arguments.length;if(o){gMe(n+o);for(var i=n;i--;){var s=i+o;i in r?r[s]=r[i]:pMe(r,s)}for(var a=0;a<o;a++)r[a]=arguments[a]}return fMe(r,n+o)}});var SMe=Ke,wMe=Et,xMe=RangeError,gX=function(t,e,r,n){var o=SMe(t),i=wMe(r),s=i<0?o+i:i;if(s>=o||s<0)throw new xMe("Incorrect index");for(var a=new e(o),l=0;l<o;l++)a[l]=l===s?n:t[l];return a},bMe=A,$Me=gX,IMe=or,PMe=Array;bMe({target:"Array",proto:!0},{with:function(t,e){return $Me(IMe(this),PMe,t,e)}});var FO=typeof ArrayBuffer<"u"&&typeof DataView<"u",EMe=nt,ki=function(t,e,r){for(var n in e)EMe(t,n,e[n],r);return t},CMe=rn,_Me=TypeError,wn=function(t,e){if(CMe(e,t))return t;throw new _Me("Incorrect invocation")},TMe=Et,AMe=xo,kMe=RangeError,um=function(t){if(t===void 0)return 0;var e=TMe(t),r=AMe(e);if(e!==r)throw new kMe("Wrong length or index");return r},BO=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},OMe=BO,MMe=Math.abs,mX=2220446049250313e-31,r5=1/mX,RMe=function(t){return t+r5-r5},vX=function(t,e,r,n){var o=+t,i=MMe(o),s=OMe(o);if(i<n)return s*RMe(i/n/e)*n*e;var a=(1+e/mX)*i,l=a-(a-i);return l>r||l!==l?s*(1/0):s*l},jMe=vX,DMe=11920928955078125e-23,LMe=34028234663852886e22,NMe=11754943508222875e-54,UO=Math.fround||function(e){return jMe(e,DMe,LMe,NMe)},FMe=Array,BMe=Math.abs,Ns=Math.pow,UMe=Math.floor,zMe=Math.log,HMe=Math.LN2,WMe=function(t,e,r){var n=FMe(r),o=r*8-e-1,i=(1<<o)-1,s=i>>1,a=e===23?Ns(2,-24)-Ns(2,-77):0,l=t<0||t===0&&1/t<0?1:0,c=0,u,d,f;for(t=BMe(t),t!==t||t===1/0?(d=t!==t?1:0,u=i):(u=UMe(zMe(t)/HMe),f=Ns(2,-u),t*f<1&&(u--,f*=2),u+s>=1?t+=a/f:t+=a*Ns(2,1-s),t*f>=2&&(u++,f/=2),u+s>=i?(d=0,u=i):u+s>=1?(d=(t*f-1)*Ns(2,e),u+=s):(d=t*Ns(2,s-1)*Ns(2,e),u=0));e>=8;)n[c++]=d&255,d/=256,e-=8;for(u=u<<e|d,o+=e;o>0;)n[c++]=u&255,u/=256,o-=8;return n[c-1]|=l*128,n},KMe=function(t,e){var r=t.length,n=r*8-e-1,o=(1<<n)-1,i=o>>1,s=n-7,a=r-1,l=t[a--],c=l&127,u;for(l>>=7;s>0;)c=c*256+t[a--],s-=8;for(u=c&(1<<-s)-1,c>>=-s,s+=e;s>0;)u=u*256+t[a--],s-=8;if(c===0)c=1-i;else{if(c===o)return u?NaN:l?-1/0:1/0;u+=Ns(2,e),c-=i}return(l?-1:1)*u*Ns(2,c-e)},zO={pack:WMe,unpack:KMe},d1=te,HO=V,II=ge,GMe=FO,yX=Ih,VMe=sr,YMe=Ct,n5=ki,PI=q,Lv=wn,XMe=Et,qMe=xo,p0=um,ZMe=UO,SX=zO,QMe=lr,o5=_i,JMe=kO,eRe=Io,tRe=ou,rRe=Ph,wX=Gn,WO=et,nRe=yX.PROPER,i5=yX.CONFIGURABLE,Ad="ArrayBuffer",h1="DataView",kd="prototype",oRe="Wrong length",xX="Wrong index",s5=WO.getterFor(Ad),Ap=WO.getterFor(h1),a5=WO.set,ii=d1[Ad],eo=ii,Eu=eo&&eo[kd],Ki=d1[h1],oc=Ki&&Ki[kd],l5=Object.prototype,iRe=d1.Array,g0=d1.RangeError,sRe=HO(JMe),aRe=HO([].reverse),bX=SX.pack,c5=SX.unpack,u5=function(t){return[t&255]},d5=function(t){return[t&255,t>>8&255]},h5=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},f5=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},lRe=function(t){return bX(ZMe(t),23,4)},cRe=function(t){return bX(t,52,8)},Nv=function(t,e,r){YMe(t[kd],e,{configurable:!0,get:function(){return r(this)[e]}})},Aa=function(t,e,r,n){var o=Ap(t),i=p0(r),s=!!n;if(i+e>o.byteLength)throw new g0(xX);var a=o.bytes,l=i+o.byteOffset,c=eRe(a,l,l+e);return s?c:aRe(c)},ka=function(t,e,r,n,o,i){var s=Ap(t),a=p0(r),l=n(+o),c=!!i;if(a+e>s.byteLength)throw new g0(xX);for(var u=s.bytes,d=a+s.byteOffset,f=0;f<e;f++)u[d+f]=l[c?f:e-f-1]};if(!GMe)eo=function(e){Lv(this,Eu);var r=p0(e);a5(this,{type:Ad,bytes:sRe(iRe(r),0),byteLength:r}),II||(this.byteLength=r,this.detached=!1)},Eu=eo[kd],Ki=function(e,r,n){Lv(this,oc),Lv(e,Eu);var o=s5(e),i=o.byteLength,s=XMe(r);if(s<0||s>i)throw new g0("Wrong offset");if(n=n===void 0?i-s:qMe(n),s+n>i)throw new g0(oRe);a5(this,{type:h1,buffer:e,byteLength:n,byteOffset:s,bytes:o.bytes}),II||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},oc=Ki[kd],II&&(Nv(eo,"byteLength",s5),Nv(Ki,"buffer",Ap),Nv(Ki,"byteLength",Ap),Nv(Ki,"byteOffset",Ap)),n5(oc,{getInt8:function(e){return Aa(this,1,e)[0]<<24>>24},getUint8:function(e){return Aa(this,1,e)[0]},getInt16:function(e){var r=Aa(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=Aa(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return f5(Aa(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return f5(Aa(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return c5(Aa(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return c5(Aa(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){ka(this,1,e,u5,r)},setUint8:function(e,r){ka(this,1,e,u5,r)},setInt16:function(e,r){ka(this,2,e,d5,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){ka(this,2,e,d5,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){ka(this,4,e,h5,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){ka(this,4,e,h5,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){ka(this,4,e,lRe,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){ka(this,8,e,cRe,r,arguments.length>2?arguments[2]:!1)}});else{var p5=nRe&&ii.name!==Ad;!PI(function(){ii(1)})||!PI(function(){new ii(-1)})||PI(function(){return new ii,new ii(1.5),new ii(NaN),ii.length!==1||p5&&!i5})?(eo=function(e){return Lv(this,Eu),tRe(new ii(p0(e)),this,eo)},eo[kd]=Eu,Eu.constructor=eo,rRe(eo,ii)):p5&&i5&&VMe(ii,"name",Ad),o5&&QMe(oc)!==l5&&o5(oc,l5);var Fv=new Ki(new eo(2)),g5=HO(oc.setInt8);Fv.setInt8(0,2147483648),Fv.setInt8(1,2147483649),(Fv.getInt8(0)||!Fv.getInt8(1))&&n5(oc,{setInt8:function(e,r){g5(this,e,r<<24>>24)},setUint8:function(e,r){g5(this,e,r<<24>>24)}},{unsafe:!0})}wX(eo,Ad);wX(Ki,h1);var f1={ArrayBuffer:eo,DataView:Ki},uRe=A,dRe=te,hRe=f1,fRe=lu,KO="ArrayBuffer",m5=hRe[KO],pRe=dRe[KO];uRe({global:!0,constructor:!0,forced:pRe!==m5},{ArrayBuffer:m5});fRe(KO);var gRe=FO,GO=ge,gn=te,$X=Ce,p1=Ie,bl=ke,VO=bo,mRe=tu,vRe=sr,$T=nt,yRe=Ct,SRe=rn,g1=lr,jh=_i,wRe=ve,xRe=ru,IX=et,PX=IX.enforce,bRe=IX.get,m0=gn.Int8Array,IT=m0&&m0.prototype,v5=gn.Uint8ClampedArray,y5=v5&&v5.prototype,Zi=m0&&g1(m0),gi=IT&&g1(IT),$Re=Object.prototype,YO=gn.TypeError,S5=wRe("toStringTag"),PT=xRe("TYPED_ARRAY_TAG"),v0="TypedArrayConstructor",aa=gRe&&!!jh&&VO(gn.opera)!=="Opera",EX=!1,Nn,Qa,Od,la={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},XO={BigInt64Array:8,BigUint64Array:8},IRe=function(e){if(!p1(e))return!1;var r=VO(e);return r==="DataView"||bl(la,r)||bl(XO,r)},CX=function(t){var e=g1(t);if(p1(e)){var r=bRe(e);return r&&bl(r,v0)?r[v0]:CX(e)}},_X=function(t){if(!p1(t))return!1;var e=VO(t);return bl(la,e)||bl(XO,e)},PRe=function(t){if(_X(t))return t;throw new YO("Target is not a typed array")},ERe=function(t){if($X(t)&&(!jh||SRe(Zi,t)))return t;throw new YO(mRe(t)+" is not a typed array constructor")},CRe=function(t,e,r,n){if(GO){if(r)for(var o in la){var i=gn[o];if(i&&bl(i.prototype,t))try{delete i.prototype[t]}catch{try{i.prototype[t]=e}catch{}}}(!gi[t]||r)&&$T(gi,t,r?e:aa&&IT[t]||e,n)}},_Re=function(t,e,r){var n,o;if(GO){if(jh){if(r){for(n in la)if(o=gn[n],o&&bl(o,t))try{delete o[t]}catch{}}if(!Zi[t]||r)try{return $T(Zi,t,r?e:aa&&Zi[t]||e)}catch{}else return}for(n in la)o=gn[n],o&&(!o[t]||r)&&$T(o,t,e)}};for(Nn in la)Qa=gn[Nn],Od=Qa&&Qa.prototype,Od?PX(Od)[v0]=Qa:aa=!1;for(Nn in XO)Qa=gn[Nn],Od=Qa&&Qa.prototype,Od&&(PX(Od)[v0]=Qa);if((!aa||!$X(Zi)||Zi===Function.prototype)&&(Zi=function(){throw new YO("Incorrect invocation")},aa))for(Nn in la)gn[Nn]&&jh(gn[Nn],Zi);if((!aa||!gi||gi===$Re)&&(gi=Zi.prototype,aa))for(Nn in la)gn[Nn]&&jh(gn[Nn].prototype,gi);aa&&g1(y5)!==gi&&jh(y5,gi);if(GO&&!bl(gi,S5)){EX=!0,yRe(gi,S5,{configurable:!0,get:function(){return p1(this)?this[PT]:void 0}});for(Nn in la)gn[Nn]&&vRe(gn[Nn],PT,Nn)}var Oe={NATIVE_ARRAY_BUFFER_VIEWS:aa,TYPED_ARRAY_TAG:EX&&PT,aTypedArray:PRe,aTypedArrayConstructor:ERe,exportTypedArrayMethod:CRe,exportTypedArrayStaticMethod:_Re,getTypedArrayConstructor:CX,isView:IRe,isTypedArray:_X,TypedArray:Zi,TypedArrayPrototype:gi},TRe=A,TX=Oe,ARe=TX.NATIVE_ARRAY_BUFFER_VIEWS;TRe({target:"ArrayBuffer",stat:!0,forced:!ARe},{isView:TX.isView});var kRe=ys,ORe=tu,MRe=TypeError,m1=function(t){if(kRe(t))return t;throw new MRe(ORe(t)+" is not a constructor")},w5=re,RRe=m1,jRe=nr,DRe=ve,LRe=DRe("species"),Dh=function(t,e){var r=w5(t).constructor,n;return r===void 0||jRe(n=w5(r)[LRe])?e:RRe(n)},NRe=A,qO=Ll,FRe=q,AX=f1,x5=re,b5=ms,BRe=xo,URe=Dh,ZO=AX.ArrayBuffer,ET=AX.DataView,kX=ET.prototype,$5=qO(ZO.prototype.slice),zRe=qO(kX.getUint8),HRe=qO(kX.setUint8),WRe=FRe(function(){return!new ZO(2).slice(1,void 0).byteLength});NRe({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:WRe},{slice:function(e,r){if($5&&r===void 0)return $5(x5(this),e);for(var n=x5(this).byteLength,o=b5(e,n),i=b5(r===void 0?n:r,n),s=new(URe(this,ZO))(BRe(i-o)),a=new ET(this),l=new ET(s),c=0;o<i;)HRe(l,c++,zRe(a,o++));return s}});var KRe=A,GRe=f1,VRe=FO;KRe({global:!0,constructor:!0,forced:!VRe},{DataView:GRe.DataView});var OX=te,YRe=i1,XRe=tn,I5=OX.ArrayBuffer,qRe=OX.TypeError,MX=I5&&YRe(I5.prototype,"byteLength","get")||function(t){if(XRe(t)!=="ArrayBuffer")throw new qRe("ArrayBuffer expected");return t.byteLength},ZRe=te,QRe=Ll,JRe=MX,P5=ZRe.ArrayBuffer,E5=P5&&P5.prototype,C5=E5&&QRe(E5.slice),RX=function(t){if(JRe(t)!==0||!C5)return!1;try{return C5(t,0,0),!1}catch{return!0}},eje=ge,tje=Ct,rje=RX,_5=ArrayBuffer.prototype;eje&&!("detached"in _5)&&tje(_5,"detached",{configurable:!0,get:function(){return rje(this)}});var nje=RX,oje=TypeError,dm=function(t){if(nje(t))throw new oje("ArrayBuffer is detached");return t},ije=te,sje=Rh,jX=function(t){if(sje){try{return ije.process.getBuiltinModule(t)}catch{}try{return Function('return require("'+t+'")')()}catch{}}},aje=te,lje=q,EI=pa,CI=u1,T5=aje.structuredClone,QO=!!T5&&!lje(function(){if(CI==="DENO"&&EI>92||CI==="NODE"&&EI>94||CI==="BROWSER"&&EI>97)return!1;var t=new ArrayBuffer(8),e=T5(t,{transfer:[t]});return t.byteLength!==0||e.byteLength!==8}),JO=te,cje=jX,uje=QO,dje=JO.structuredClone,A5=JO.ArrayBuffer,Bv=JO.MessageChannel,CT=!1,_I,k5,Uv,TI;if(uje)CT=function(t){dje(t,{transfer:[t]})};else if(A5)try{Bv||(_I=cje("worker_threads"),_I&&(Bv=_I.MessageChannel)),Bv&&(k5=new Bv,Uv=new A5(2),TI=function(t){k5.port1.postMessage(null,[t])},Uv.byteLength===2&&(TI(Uv),Uv.byteLength===0&&(CT=TI)))}catch{}var DX=CT,eM=te,tM=V,LX=i1,hje=um,fje=dm,pje=MX,O5=DX,AI=QO,gje=eM.structuredClone,NX=eM.ArrayBuffer,_T=eM.DataView,mje=Math.min,rM=NX.prototype,FX=_T.prototype,vje=tM(rM.slice),M5=LX(rM,"resizable","get"),R5=LX(rM,"maxByteLength","get"),yje=tM(FX.getInt8),Sje=tM(FX.setInt8),BX=(AI||O5)&&function(t,e,r){var n=pje(t),o=e===void 0?n:hje(e),i=!M5||!M5(t),s;if(fje(t),AI&&(t=gje(t,{transfer:[t]}),n===o&&(r||i)))return t;if(n>=o&&(!r||i))s=vje(t,0,o);else{var a=r&&!i&&R5?{maxByteLength:R5(t)}:void 0;s=new NX(o,a);for(var l=new _T(t),c=new _T(s),u=mje(o,n),d=0;d<u;d++)Sje(c,d,yje(l,d))}return AI||O5(t),s},wje=A,j5=BX;j5&&wje({target:"ArrayBuffer",proto:!0},{transfer:function(){return j5(this,arguments.length?arguments[0]:void 0,!0)}});var xje=A,D5=BX;D5&&xje({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return D5(this,arguments.length?arguments[0]:void 0,!1)}});var bje=A,$je=V,Ije=q,Pje=Ije(function(){return new Date(16e11).getYear()!==120}),Eje=$je(Date.prototype.getFullYear);bje({target:"Date",proto:!0,forced:Pje},{getYear:function(){return Eje(this)-1900}});var Cje=A,_je=V,UX=Date,Tje=_je(UX.prototype.getTime);Cje({target:"Date",stat:!0},{now:function(){return Tje(new UX)}});var Aje=A,zX=V,kje=Et,HX=Date.prototype,Oje=zX(HX.getTime),Mje=zX(HX.setFullYear);Aje({target:"Date",proto:!0},{setYear:function(e){Oje(this);var r=kje(e),n=r>=0&&r<=99?r+1900:r;return Mje(this,n)}});var Rje=A;Rje({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString});var jje=Et,Dje=Ee,Lje=St,Nje=RangeError,v1=function(e){var r=Dje(Lje(this)),n="",o=jje(e);if(o<0||o===1/0)throw new Nje("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(r+=r))o&1&&(n+=r);return n},WX=V,Fje=xo,L5=Ee,Bje=v1,Uje=St,zje=WX(Bje),Hje=WX("".slice),Wje=Math.ceil,N5=function(t){return function(e,r,n){var o=L5(Uje(e)),i=Fje(r),s=o.length,a=n===void 0?" ":L5(n),l,c;return i<=s||a===""?o:(l=i-s,c=zje(a,Wje(l/a.length)),c.length>l&&(c=Hje(c,0,l)),t?o+c:c+o)}},y1={start:N5(!1),end:N5(!0)},Hl=V,F5=q,ic=y1.start,Kje=RangeError,Gje=isFinite,Vje=Math.abs,va=Date.prototype,kI=va.toISOString,Yje=Hl(va.getTime),Xje=Hl(va.getUTCDate),qje=Hl(va.getUTCFullYear),Zje=Hl(va.getUTCHours),Qje=Hl(va.getUTCMilliseconds),Jje=Hl(va.getUTCMinutes),eDe=Hl(va.getUTCMonth),tDe=Hl(va.getUTCSeconds),rDe=F5(function(){return kI.call(new Date(-5e13-1))!=="0385-07-25T07:06:39.999Z"})||!F5(function(){kI.call(new Date(NaN))})?function(){if(!Gje(Yje(this)))throw new Kje("Invalid time value");var e=this,r=qje(e),n=Qje(e),o=r<0?"-":r>9999?"+":"";return o+ic(Vje(r),o?6:4,0)+"-"+ic(eDe(e)+1,2,0)+"-"+ic(Xje(e),2,0)+"T"+ic(Zje(e),2,0)+":"+ic(Jje(e),2,0)+":"+ic(tDe(e),2,0)+"."+ic(n,3,0)+"Z"}:kI,nDe=A,B5=rDe;nDe({target:"Date",proto:!0,forced:Date.prototype.toISOString!==B5},{toISOString:B5});var oDe=A,iDe=q,sDe=je,aDe=Ax,lDe=iDe(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1});oDe({target:"Date",proto:!0,arity:1,forced:lDe},{toJSON:function(e){var r=sDe(this),n=aDe(r,"number");return typeof n=="number"&&!isFinite(n)?null:r.toISOString()}});var cDe=re,uDe=WK,dDe=TypeError,hDe=function(t){if(cDe(this),t==="string"||t==="default")t="string";else if(t!=="number")throw new dDe("Incorrect hint");return uDe(this,t)},fDe=ke,pDe=nt,gDe=hDe,mDe=ve,U5=mDe("toPrimitive"),z5=Date.prototype;fDe(z5,U5)||pDe(z5,U5,gDe);var KX=V,vDe=nt,nM=Date.prototype,H5="Invalid Date",GX="toString",yDe=KX(nM[GX]),SDe=KX(nM.getTime);String(new Date(NaN))!==H5&&vDe(nM,GX,function(){var e=SDe(this);return e===e?yDe(this):H5});var wDe=A,hm=V,xDe=Ee,bDe=hm("".charAt),$De=hm("".charCodeAt),IDe=hm(/./.exec),PDe=hm(1 .toString),EDe=hm("".toUpperCase),CDe=/[\w*+\-./@]/,W5=function(t,e){for(var r=PDe(t,16);r.length<e;)r="0"+r;return r};wDe({global:!0},{escape:function(e){for(var r=xDe(e),n="",o=r.length,i=0,s,a;i<o;)s=bDe(r,i++),IDe(CDe,s)?n+=s:(a=$De(s,0),a<256?n+="%"+W5(a,2):n+="%u"+EDe(W5(a,4)));return n}});var VX=V,_De=Pe,TDe=Ie,ADe=ke,K5=Io,kDe=zg,YX=Function,ODe=VX([].concat),MDe=VX([].join),OI={},RDe=function(t,e,r){if(!ADe(OI,e)){for(var n=[],o=0;o<e;o++)n[o]="a["+o+"]";OI[e]=YX("C,a","return new C("+MDe(n,",")+")")}return OI[e](t,r)},XX=kDe?YX.bind:function(e){var r=_De(this),n=r.prototype,o=K5(arguments,1),i=function(){var a=ODe(o,K5(arguments));return this instanceof i?RDe(r,a.length,a):r.apply(e,a)};return TDe(n)&&(i.prototype=n),i},jDe=A,G5=XX;jDe({target:"Function",proto:!0,forced:Function.bind!==G5},{bind:G5});var DDe=Ce,V5=Ie,LDe=ut,NDe=rn,FDe=ve,BDe=Rx,MI=FDe("hasInstance"),Y5=Function.prototype;MI in Y5||LDe.f(Y5,MI,{value:BDe(function(t){if(!DDe(this)||!V5(t))return!1;var e=this.prototype;return V5(e)?NDe(e,t):t instanceof this},MI)});var UDe=ge,zDe=Ih.EXISTS,qX=V,HDe=Ct,ZX=Function.prototype,WDe=qX(ZX.toString),QX=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,KDe=qX(QX.exec),GDe="name";UDe&&!zDe&&HDe(ZX,GDe,{configurable:!0,get:function(){try{return KDe(QX,WDe(this))[1]}catch{return""}}});var VDe=A,RI=te;VDe({global:!0,forced:RI.globalThis!==RI},{globalThis:RI});var YDe=te,XDe=Gn;XDe(YDe.JSON,"JSON",!0);var JX={exports:{}},qDe=q,oM=qDe(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),ZDe=q,QDe=Ie,JDe=tn,X5=oM,ES=Object.isExtensible,e3e=ZDe(function(){ES(1)}),iM=e3e||X5?function(e){return!QDe(e)||X5&&JDe(e)==="ArrayBuffer"?!1:ES?ES(e):!0}:ES,t3e=q,Wl=!t3e(function(){return Object.isExtensible(Object.preventExtensions({}))}),r3e=A,n3e=V,o3e=Wg,i3e=Ie,sM=ke,s3e=ut.f,q5=Dl,a3e=Jx,aM=iM,l3e=ru,c3e=Wl,eq=!1,ca=l3e("meta"),u3e=0,lM=function(t){s3e(t,ca,{value:{objectID:"O"+u3e++,weakData:{}}})},d3e=function(t,e){if(!i3e(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!sM(t,ca)){if(!aM(t))return"F";if(!e)return"E";lM(t)}return t[ca].objectID},h3e=function(t,e){if(!sM(t,ca)){if(!aM(t))return!0;if(!e)return!1;lM(t)}return t[ca].weakData},f3e=function(t){return c3e&&eq&&aM(t)&&!sM(t,ca)&&lM(t),t},p3e=function(){g3e.enable=function(){},eq=!0;var t=q5.f,e=n3e([].splice),r={};r[ca]=1,t(r).length&&(q5.f=function(n){for(var o=t(n),i=0,s=o.length;i<s;i++)if(o[i]===ca){e(o,i,1);break}return o},r3e({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:a3e.f}))},g3e=JX.exports={enable:p3e,fastKey:d3e,getWeakData:h3e,onFreeze:f3e};o3e[ca]=!0;var cu=JX.exports,m3e=A,v3e=te,y3e=V,Z5=Yg,S3e=nt,w3e=cu,x3e=zt,b3e=wn,$3e=Ce,I3e=nr,jI=Ie,DI=q,P3e=l1,E3e=Gn,C3e=ou,S1=function(t,e,r){var n=t.indexOf("Map")!==-1,o=t.indexOf("Weak")!==-1,i=n?"set":"add",s=v3e[t],a=s&&s.prototype,l=s,c={},u=function(y){var v=y3e(a[y]);S3e(a,y,y==="add"?function($){return v(this,$===0?0:$),this}:y==="delete"?function(b){return o&&!jI(b)?!1:v(this,b===0?0:b)}:y==="get"?function($){return o&&!jI($)?void 0:v(this,$===0?0:$)}:y==="has"?function($){return o&&!jI($)?!1:v(this,$===0?0:$)}:function($,P){return v(this,$===0?0:$,P),this})},d=Z5(t,!$3e(s)||!(o||a.forEach&&!DI(function(){new s().entries().next()})));if(d)l=r.getConstructor(e,t,n,i),w3e.enable();else if(Z5(t,!0)){var f=new l,p=f[i](o?{}:-0,1)!==f,g=DI(function(){f.has(1)}),m=P3e(function(y){new s(y)}),S=!o&&DI(function(){for(var y=new s,v=5;v--;)y[i](v,v);return!y.has(-0)});m||(l=e(function(y,v){b3e(y,a);var b=C3e(new s,y,l);return I3e(v)||x3e(v,b[i],{that:b,AS_ENTRIES:n}),b}),l.prototype=a,a.constructor=l),(g||S)&&(u("delete"),u("has"),n&&u("get")),(S||p)&&u(i),o&&a.clear&&delete a.clear}return c[t]=l,m3e({global:!0,constructor:!0,forced:l!==s},c),E3e(l,t),o||r.setStrong(l,t,n),l},Q5=ar,_3e=Ct,J5=ki,T3e=dt,A3e=wn,k3e=nr,O3e=zt,M3e=MO,zv=Nr,R3e=lu,If=ge,e4=cu.fastKey,tq=et,t4=tq.set,LI=tq.getterFor,rq={getConstructor:function(t,e,r,n){var o=t(function(c,u){A3e(c,i),t4(c,{type:e,index:Q5(null),first:null,last:null,size:0}),If||(c.size=0),k3e(u)||O3e(u,c[n],{that:c,AS_ENTRIES:r})}),i=o.prototype,s=LI(e),a=function(c,u,d){var f=s(c),p=l(c,u),g,m;return p?p.value=d:(f.last=p={index:m=e4(u,!0),key:u,value:d,previous:g=f.last,next:null,removed:!1},f.first||(f.first=p),g&&(g.next=p),If?f.size++:c.size++,m!=="F"&&(f.index[m]=p)),c},l=function(c,u){var d=s(c),f=e4(u),p;if(f!=="F")return d.index[f];for(p=d.first;p;p=p.next)if(p.key===u)return p};return J5(i,{clear:function(){for(var u=this,d=s(u),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=null),f=f.next;d.first=d.last=null,d.index=Q5(null),If?d.size=0:u.size=0},delete:function(c){var u=this,d=s(u),f=l(u,c);if(f){var p=f.next,g=f.previous;delete d.index[f.index],f.removed=!0,g&&(g.next=p),p&&(p.previous=g),d.first===f&&(d.first=p),d.last===f&&(d.last=g),If?d.size--:u.size--}return!!f},forEach:function(u){for(var d=s(this),f=T3e(u,arguments.length>1?arguments[1]:void 0),p;p=p?p.next:d.first;)for(f(p.value,p.key,this);p&&p.removed;)p=p.previous},has:function(u){return!!l(this,u)}}),J5(i,r?{get:function(u){var d=l(this,u);return d&&d.value},set:function(u,d){return a(this,u===0?0:u,d)}}:{add:function(u){return a(this,u=u===0?0:u,u)}}),If&&_3e(i,"size",{configurable:!0,get:function(){return s(this).size}}),o},setStrong:function(t,e,r){var n=e+" Iterator",o=LI(e),i=LI(n);M3e(t,e,function(s,a){t4(this,{type:n,target:s,state:o(s),kind:a,last:null})},function(){for(var s=i(this),a=s.kind,l=s.last;l&&l.removed;)l=l.previous;return!s.target||!(s.last=l=l?l.next:s.state.first)?(s.target=null,zv(void 0,!0)):zv(a==="keys"?l.key:a==="values"?l.value:[l.key,l.value],!1)},r?"entries":"values",!r,!0),R3e(e)}},j3e=S1,D3e=rq;j3e("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},D3e);var Hv=V,Pf=Map.prototype,nn={Map,set:Hv(Pf.set),get:Hv(Pf.get),has:Hv(Pf.has),remove:Hv(Pf.delete),proto:Pf},L3e=A,N3e=V,F3e=Pe,B3e=St,U3e=zt,w1=nn,z3e=q,nq=w1.Map,H3e=w1.has,W3e=w1.get,K3e=w1.set,G3e=N3e([].push),V3e=z3e(function(){return nq.groupBy("ab",function(t){return t}).get("a").length!==1});L3e({target:"Map",stat:!0,forced:V3e},{groupBy:function(e,r){B3e(e),F3e(r);var n=new nq,o=0;return U3e(e,function(i){var s=r(i,o++);H3e(n,s)?G3e(W3e(n,s),i):K3e(n,s,[i])}),n}});var Y3e=Math.log,oq=Math.log1p||function(e){var r=+e;return r>-1e-8&&r<1e-8?r-r*r/2:Y3e(1+r)},X3e=A,q3e=oq,NI=Math.acosh,Z3e=Math.log,r4=Math.sqrt,Q3e=Math.LN2,J3e=!NI||Math.floor(NI(Number.MAX_VALUE))!==710||NI(1/0)!==1/0;X3e({target:"Math",stat:!0,forced:J3e},{acosh:function(e){var r=+e;return r<1?NaN:r>9490626562425156e-8?Z3e(r)+Q3e:q3e(r-1+r4(r-1)*r4(r+1))}});var eLe=A,n4=Math.asinh,tLe=Math.log,rLe=Math.sqrt;function iq(t){var e=+t;return!isFinite(e)||e===0?e:e<0?-iq(-e):tLe(e+rLe(e*e+1))}var nLe=!(n4&&1/n4(0)>0);eLe({target:"Math",stat:!0,forced:nLe},{asinh:iq});var oLe=A,o4=Math.atanh,iLe=Math.log,sLe=!(o4&&1/o4(-0)<0);oLe({target:"Math",stat:!0,forced:sLe},{atanh:function(e){var r=+e;return r===0?r:iLe((1+r)/(1-r))/2}});var aLe=A,lLe=BO,cLe=Math.abs,uLe=Math.pow;aLe({target:"Math",stat:!0},{cbrt:function(e){var r=+e;return lLe(r)*uLe(cLe(r),1/3)}});var dLe=A,hLe=Math.floor,fLe=Math.log,pLe=Math.LOG2E;dLe({target:"Math",stat:!0},{clz32:function(e){var r=e>>>0;return r?31-hLe(fLe(r+.5)*pLe):32}});var Ef=Math.expm1,gLe=Math.exp,x1=!Ef||Ef(10)>22025.465794806718||Ef(10)<22025.465794806718||Ef(-2e-17)!==-2e-17?function(e){var r=+e;return r===0?r:r>-1e-6&&r<1e-6?r+r*r/2:gLe(r)-1}:Ef,mLe=A,vLe=x1,i4=Math.cosh,yLe=Math.abs,FI=Math.E,SLe=!i4||i4(710)===1/0;mLe({target:"Math",stat:!0,forced:SLe},{cosh:function(e){var r=vLe(yLe(e)-1)+1;return(r+1/(r*FI*FI))*(FI/2)}});var wLe=A,s4=x1;wLe({target:"Math",stat:!0,forced:s4!==Math.expm1},{expm1:s4});var xLe=A,bLe=UO;xLe({target:"Math",stat:!0},{fround:bLe});var $Le=A,a4=Math.hypot,ILe=Math.abs,PLe=Math.sqrt,ELe=!!a4&&a4(1/0,NaN)!==1/0;$Le({target:"Math",stat:!0,arity:2,forced:ELe},{hypot:function(e,r){for(var n=0,o=0,i=arguments.length,s=0,a,l;o<i;)a=ILe(arguments[o++]),s<a?(l=s/a,n=n*l*l+1,s=a):a>0?(l=a/s,n+=l*l):n+=a;return s===1/0?1/0:s*PLe(n)}});var CLe=A,_Le=q,l4=Math.imul,TLe=_Le(function(){return l4(4294967295,5)!==-5||l4.length!==2});CLe({target:"Math",stat:!0,forced:TLe},{imul:function(e,r){var n=65535,o=+e,i=+r,s=n&o,a=n&i;return 0|s*a+((n&o>>>16)*a+s*(n&i>>>16)<<16>>>0)}});var ALe=Math.log,kLe=Math.LOG10E,sq=Math.log10||function(e){return ALe(e)*kLe},OLe=A,MLe=sq;OLe({target:"Math",stat:!0},{log10:MLe});var RLe=A,jLe=oq;RLe({target:"Math",stat:!0},{log1p:jLe});var DLe=A,LLe=Math.log,NLe=Math.LN2;DLe({target:"Math",stat:!0},{log2:function(e){return LLe(e)/NLe}});var FLe=A,BLe=BO;FLe({target:"Math",stat:!0},{sign:BLe});var ULe=A,zLe=q,c4=x1,HLe=Math.abs,u4=Math.exp,WLe=Math.E,KLe=zLe(function(){return Math.sinh(-2e-17)!==-2e-17});ULe({target:"Math",stat:!0,forced:KLe},{sinh:function(e){var r=+e;return HLe(r)<1?(c4(r)-c4(-r))/2:(u4(r-1)-u4(-r-1))*(WLe/2)}});var GLe=A,d4=x1,h4=Math.exp;GLe({target:"Math",stat:!0},{tanh:function(e){var r=+e,n=d4(r),o=d4(-r);return n===1/0?1:o===1/0?-1:(n-o)/(h4(r)+h4(-r))}});var VLe=Gn;VLe(Math,"Math",!0);var YLe=A,XLe=JK;YLe({target:"Math",stat:!0},{trunc:XLe});var qLe=V,b1=qLe(1 .valueOf),Lh=`
|
|
99
|
-
\v\f\r \u2028\u2029\uFEFF`,ZLe=V,QLe=St,JLe=Ee,TT=Lh,f4=ZLe("".replace),eNe=RegExp("^["+TT+"]+"),tNe=RegExp("(^|[^"+TT+"])["+TT+"]+$"),BI=function(t){return function(e){var r=JLe(QLe(e));return t&1&&(r=f4(r,eNe,"")),t&2&&(r=f4(r,tNe,"$1")),r}},Nh={start:BI(1),end:BI(2),trim:BI(3)},rNe=A,aq=ir,nNe=ge,lq=te,cq=wO,uq=V,oNe=Yg,p4=ke,iNe=ou,sNe=rn,aNe=Rl,dq=Ax,lNe=q,cNe=Dl.f,uNe=vr.f,dNe=ut.f,hNe=b1,fNe=Nh.trim,$1="Number",Md=lq[$1];cq[$1];var cM=Md.prototype,pNe=lq.TypeError,gNe=uq("".slice),Wv=uq("".charCodeAt),mNe=function(t){var e=dq(t,"number");return typeof e=="bigint"?e:vNe(e)},vNe=function(t){var e=dq(t,"number"),r,n,o,i,s,a,l,c;if(aNe(e))throw new pNe("Cannot convert a Symbol value to a number");if(typeof e=="string"&&e.length>2){if(e=fNe(e),r=Wv(e,0),r===43||r===45){if(n=Wv(e,2),n===88||n===120)return NaN}else if(r===48){switch(Wv(e,1)){case 66:case 98:o=2,i=49;break;case 79:case 111:o=8,i=55;break;default:return+e}for(s=gNe(e,2),a=s.length,l=0;l<a;l++)if(c=Wv(s,l),c<48||c>i)return NaN;return parseInt(s,o)}}return+e},uM=oNe($1,!Md(" 0o1")||!Md("0b1")||Md("+0x1")),yNe=function(t){return sNe(cM,t)&&lNe(function(){hNe(t)})},I1=function(e){var r=arguments.length<1?0:Md(mNe(e));return yNe(this)?iNe(Object(r),this,I1):r};I1.prototype=cM;uM&&!aq&&(cM.constructor=I1);rNe({global:!0,constructor:!0,wrap:!0,forced:uM},{Number:I1});var SNe=function(t,e){for(var r=nNe?cNe(e):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0,o;r.length>n;n++)p4(e,o=r[n])&&!p4(t,o)&&dNe(t,o,uNe(e,o))};(uM||aq)&&SNe(cq[$1],Md);var wNe=A;wNe({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var xNe=te,bNe=xNe.isFinite,hq=Number.isFinite||function(e){return typeof e=="number"&&bNe(e)},$Ne=A,INe=hq;$Ne({target:"Number",stat:!0},{isFinite:INe});var PNe=Ie,ENe=Math.floor,dM=Number.isInteger||function(e){return!PNe(e)&&isFinite(e)&&ENe(e)===e},CNe=A,_Ne=dM;CNe({target:"Number",stat:!0},{isInteger:_Ne});var TNe=A;TNe({target:"Number",stat:!0},{isNaN:function(e){return e!==e}});var ANe=A,kNe=dM,ONe=Math.abs;ANe({target:"Number",stat:!0},{isSafeInteger:function(e){return kNe(e)&&ONe(e)<=9007199254740991}});var MNe=A;MNe({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var RNe=A;RNe({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991});var fq=te,jNe=q,DNe=V,LNe=Ee,NNe=Nh.trim,FNe=Lh,BNe=DNe("".charAt),y0=fq.parseFloat,g4=fq.Symbol,m4=g4&&g4.iterator,UNe=1/y0(FNe+"-0")!==-1/0||m4&&!jNe(function(){y0(Object(m4))}),pq=UNe?function(e){var r=NNe(LNe(e)),n=y0(r);return n===0&&BNe(r,0)==="-"?-0:n}:y0,zNe=A,v4=pq;zNe({target:"Number",stat:!0,forced:Number.parseFloat!==v4},{parseFloat:v4});var gq=te,HNe=q,WNe=V,KNe=Ee,GNe=Nh.trim,y4=Lh,kp=gq.parseInt,S4=gq.Symbol,w4=S4&&S4.iterator,mq=/^[+-]?0x/i,VNe=WNe(mq.exec),YNe=kp(y4+"08")!==8||kp(y4+"0x16")!==22||w4&&!HNe(function(){kp(Object(w4))}),vq=YNe?function(e,r){var n=GNe(KNe(e));return kp(n,r>>>0||(VNe(mq,n)?16:10))}:kp,XNe=A,x4=vq;XNe({target:"Number",stat:!0,forced:Number.parseInt!==x4},{parseInt:x4});var qNe=A,hM=V,ZNe=Et,QNe=b1,JNe=v1,eFe=sq,AT=q,tFe=RangeError,b4=String,rFe=isFinite,nFe=Math.abs,oFe=Math.floor,$4=Math.pow,iFe=Math.round,Qi=hM(1 .toExponential),sFe=hM(JNe),I4=hM("".slice),yq=Qi(-69e-12,4)==="-6.9000e-11"&&Qi(1.255,2)==="1.25e+0"&&Qi(12345,3)==="1.235e+4"&&Qi(25,0)==="3e+1",aFe=function(){return AT(function(){Qi(1,1/0)})&&AT(function(){Qi(1,-1/0)})},lFe=function(){return!AT(function(){Qi(1/0,1/0),Qi(NaN,1/0)})},cFe=!yq||!aFe()||!lFe();qNe({target:"Number",proto:!0,forced:cFe},{toExponential:function(e){var r=QNe(this);if(e===void 0)return Qi(r);var n=ZNe(e);if(!rFe(r))return String(r);if(n<0||n>20)throw new tFe("Incorrect fraction digits");if(yq)return Qi(r,n);var o="",i,s,a,l;if(r<0&&(o="-",r=-r),r===0)s=0,i=sFe("0",n+1);else{var c=eFe(r);s=oFe(c);var u=$4(10,s-n),d=iFe(r/u);2*r>=(2*d+1)*u&&(d+=1),d>=$4(10,n+1)&&(d/=10,s+=1),i=b4(d)}return n!==0&&(i=I4(i,0,1)+"."+I4(i,1)),s===0?(a="+",l="0"):(a=s>0?"+":"-",l=b4(nFe(s))),i+="e"+a+l,o+i}});var uFe=A,fM=V,dFe=Et,hFe=b1,fFe=v1,P4=q,pFe=RangeError,Sq=String,wq=Math.floor,kT=fM(fFe),E4=fM("".slice),Cf=fM(1 .toFixed),hd=function(t,e,r){return e===0?r:e%2===1?hd(t,e-1,r*t):hd(t*t,e/2,r)},gFe=function(t){for(var e=0,r=t;r>=4096;)e+=12,r/=4096;for(;r>=2;)e+=1,r/=2;return e},Cu=function(t,e,r){for(var n=-1,o=r;++n<6;)o+=e*t[n],t[n]=o%1e7,o=wq(o/1e7)},UI=function(t,e){for(var r=6,n=0;--r>=0;)n+=t[r],t[r]=wq(n/e),n=n%e*1e7},C4=function(t){for(var e=6,r="";--e>=0;)if(r!==""||e===0||t[e]!==0){var n=Sq(t[e]);r=r===""?n:r+kT("0",7-n.length)+n}return r},mFe=P4(function(){return Cf(8e-5,3)!=="0.000"||Cf(.9,0)!=="1"||Cf(1.255,2)!=="1.25"||Cf(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!P4(function(){Cf({})});uFe({target:"Number",proto:!0,forced:mFe},{toFixed:function(e){var r=hFe(this),n=dFe(e),o=[0,0,0,0,0,0],i="",s="0",a,l,c,u;if(n<0||n>20)throw new pFe("Incorrect fraction digits");if(r!==r)return"NaN";if(r<=-1e21||r>=1e21)return Sq(r);if(r<0&&(i="-",r=-r),r>1e-21)if(a=gFe(r*hd(2,69,1))-69,l=a<0?r*hd(2,-a,1):r/hd(2,a,1),l*=4503599627370496,a=52-a,a>0){for(Cu(o,0,l),c=n;c>=7;)Cu(o,1e7,0),c-=7;for(Cu(o,hd(10,c,1),0),c=a-1;c>=23;)UI(o,1<<23),c-=23;UI(o,1<<c),Cu(o,1,1),UI(o,2),s=C4(o)}else Cu(o,0,l),Cu(o,1<<-a,0),s=C4(o)+kT("0",n);return n>0?(u=s.length,s=i+(u<=n?"0."+kT("0",n-u)+s:E4(s,0,u-n)+"."+E4(s,u-n))):s=i+s,s}});var vFe=A,yFe=V,_4=q,T4=b1,S0=yFe(1 .toPrecision),SFe=_4(function(){return S0(1,void 0)!=="1"})||!_4(function(){S0({})});vFe({target:"Number",proto:!0,forced:SFe},{toPrecision:function(e){return e===void 0?S0(T4(this)):S0(T4(this),e)}});var A4=ge,wFe=V,xFe=ne,bFe=q,zI=Eh,$Fe=Gg,IFe=Hg,PFe=je,EFe=Ml,_u=Object.assign,k4=Object.defineProperty,CFe=wFe([].concat),xq=!_u||bFe(function(){if(A4&&_u({b:1},_u(k4({},"a",{enumerable:!0,get:function(){k4(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(o){e[o]=o}),_u({},t)[r]!==7||zI(_u({},e)).join("")!==n})?function(e,r){for(var n=PFe(e),o=arguments.length,i=1,s=$Fe.f,a=IFe.f;o>i;)for(var l=EFe(arguments[i++]),c=s?CFe(zI(l),s(l)):zI(l),u=c.length,d=0,f;u>d;)f=c[d++],(!A4||xFe(a,l,f))&&(n[f]=l[f]);return n}:_u,_Fe=A,O4=xq;_Fe({target:"Object",stat:!0,arity:2,forced:Object.assign!==O4},{assign:O4});var TFe=A,AFe=ge,kFe=ar;TFe({target:"Object",stat:!0,sham:!AFe},{create:kFe});var OFe=te,MFe=q,M4=LO,P1=!MFe(function(){if(!(M4&&M4<535)){var t=Math.random();__defineSetter__.call(null,t,function(){}),delete OFe[t]}}),RFe=A,jFe=ge,DFe=P1,LFe=Pe,NFe=je,FFe=ut;jFe&&RFe({target:"Object",proto:!0,forced:DFe},{__defineGetter__:function(e,r){FFe.f(NFe(this),e,{get:LFe(r),enumerable:!0,configurable:!0})}});var BFe=A,UFe=ge,R4=jx.f;BFe({target:"Object",stat:!0,forced:Object.defineProperties!==R4,sham:!UFe},{defineProperties:R4});var zFe=A,HFe=ge,j4=ut.f;zFe({target:"Object",stat:!0,forced:Object.defineProperty!==j4,sham:!HFe},{defineProperty:j4});var WFe=A,KFe=ge,GFe=P1,VFe=Pe,YFe=je,XFe=ut;KFe&&WFe({target:"Object",proto:!0,forced:GFe},{__defineSetter__:function(e,r){XFe.f(YFe(this),e,{set:VFe(r),enumerable:!0,configurable:!0})}});var bq=ge,qFe=q,$q=V,ZFe=lr,QFe=Eh,JFe=or,e5e=Hg.f,Iq=$q(e5e),t5e=$q([].push),r5e=bq&&qFe(function(){var t=Object.create(null);return t[2]=2,!Iq(t,2)}),D4=function(t){return function(e){for(var r=JFe(e),n=QFe(r),o=r5e&&ZFe(r)===null,i=n.length,s=0,a=[],l;i>s;)l=n[s++],(!bq||(o?l in r:Iq(r,l)))&&t5e(a,t?[l,r[l]]:r[l]);return a}},Pq={entries:D4(!0),values:D4(!1)},n5e=A,o5e=Pq.entries;n5e({target:"Object",stat:!0},{entries:function(e){return o5e(e)}});var i5e=A,s5e=Wl,a5e=q,l5e=Ie,c5e=cu.onFreeze,OT=Object.freeze,u5e=a5e(function(){OT(1)});i5e({target:"Object",stat:!0,forced:u5e,sham:!s5e},{freeze:function(e){return OT&&l5e(e)?OT(c5e(e)):e}});var d5e=A,h5e=zt,f5e=Ti;d5e({target:"Object",stat:!0},{fromEntries:function(e){var r={};return h5e(e,function(n,o){f5e(r,n,o)},{AS_ENTRIES:!0}),r}});var p5e=A,g5e=q,m5e=or,Eq=vr.f,Cq=ge,v5e=!Cq||g5e(function(){Eq(1)});p5e({target:"Object",stat:!0,forced:v5e,sham:!Cq},{getOwnPropertyDescriptor:function(e,r){return Eq(m5e(e),r)}});var y5e=A,S5e=ge,w5e=Lk,x5e=or,b5e=vr,$5e=Ti;y5e({target:"Object",stat:!0,sham:!S5e},{getOwnPropertyDescriptors:function(e){for(var r=x5e(e),n=b5e.f,o=w5e(r),i={},s=0,a,l;o.length>s;)l=n(r,a=o[s++]),l!==void 0&&$5e(i,a,l);return i}});var I5e=A,P5e=q,E5e=Jx.f,C5e=P5e(function(){return!Object.getOwnPropertyNames(1)});I5e({target:"Object",stat:!0,forced:C5e},{getOwnPropertyNames:E5e});var _5e=A,T5e=q,A5e=je,_q=lr,k5e=_O,O5e=T5e(function(){_q(1)});_5e({target:"Object",stat:!0,forced:O5e,sham:!k5e},{getPrototypeOf:function(e){return _q(A5e(e))}});var M5e=A,R5e=be,j5e=V,D5e=Pe,L5e=St,N5e=ga,F5e=zt,B5e=q,L4=Object.groupBy,U5e=R5e("Object","create"),z5e=j5e([].push),H5e=!L4||B5e(function(){return L4("ab",function(t){return t}).a.length!==1});M5e({target:"Object",stat:!0,forced:H5e},{groupBy:function(e,r){L5e(e),D5e(r);var n=U5e(null),o=0;return F5e(e,function(i){var s=N5e(r(i,o++));s in n?z5e(n[s],i):n[s]=[i]}),n}});var W5e=A,K5e=ke;W5e({target:"Object",stat:!0},{hasOwn:K5e});var Tq=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},G5e=A,V5e=Tq;G5e({target:"Object",stat:!0},{is:V5e});var Y5e=A,N4=iM;Y5e({target:"Object",stat:!0,forced:Object.isExtensible!==N4},{isExtensible:N4});var X5e=A,q5e=q,Z5e=Ie,Q5e=tn,Aq=oM,MT=Object.isFrozen,J5e=Aq||q5e(function(){MT(1)});X5e({target:"Object",stat:!0,forced:J5e},{isFrozen:function(e){return!Z5e(e)||Aq&&Q5e(e)==="ArrayBuffer"?!0:MT?MT(e):!1}});var e4e=A,t4e=q,r4e=Ie,n4e=tn,kq=oM,RT=Object.isSealed,o4e=kq||t4e(function(){RT(1)});e4e({target:"Object",stat:!0,forced:o4e},{isSealed:function(e){return!r4e(e)||kq&&n4e(e)==="ArrayBuffer"?!0:RT?RT(e):!1}});var i4e=A,s4e=je,Oq=Eh,a4e=q,l4e=a4e(function(){Oq(1)});i4e({target:"Object",stat:!0,forced:l4e},{keys:function(e){return Oq(s4e(e))}});var c4e=A,u4e=ge,d4e=P1,h4e=je,f4e=ga,p4e=lr,g4e=vr.f;u4e&&c4e({target:"Object",proto:!0,forced:d4e},{__lookupGetter__:function(e){var r=h4e(this),n=f4e(e),o;do if(o=g4e(r,n))return o.get;while(r=p4e(r))}});var m4e=A,v4e=ge,y4e=P1,S4e=je,w4e=ga,x4e=lr,b4e=vr.f;v4e&&m4e({target:"Object",proto:!0,forced:y4e},{__lookupSetter__:function(e){var r=S4e(this),n=w4e(e),o;do if(o=b4e(r,n))return o.set;while(r=x4e(r))}});var $4e=A,I4e=Ie,P4e=cu.onFreeze,E4e=Wl,C4e=q,jT=Object.preventExtensions,_4e=C4e(function(){jT(1)});$4e({target:"Object",stat:!0,forced:_4e,sham:!E4e},{preventExtensions:function(e){return jT&&I4e(e)?jT(P4e(e)):e}});var T4e=ge,A4e=Ct,k4e=Ie,O4e=MY,M4e=je,R4e=St,F4=Object.getPrototypeOf,B4=Object.setPrototypeOf,U4=Object.prototype,z4="__proto__";if(T4e&&F4&&B4&&!(z4 in U4))try{A4e(U4,z4,{configurable:!0,get:function(){return F4(M4e(this))},set:function(e){var r=R4e(this);O4e(e)&&k4e(r)&&B4(r,e)}})}catch{}var j4e=A,D4e=Ie,L4e=cu.onFreeze,N4e=Wl,F4e=q,DT=Object.seal,B4e=F4e(function(){DT(1)});j4e({target:"Object",stat:!0,forced:B4e,sham:!N4e},{seal:function(e){return DT&&D4e(e)?DT(L4e(e)):e}});var U4e=A,z4e=_i;U4e({target:"Object",stat:!0},{setPrototypeOf:z4e});var H4e=Nk,W4e=bo,K4e=H4e?{}.toString:function(){return"[object "+W4e(this)+"]"},G4e=Nk,V4e=nt,Y4e=K4e;G4e||V4e(Object.prototype,"toString",Y4e,{unsafe:!0});var X4e=A,q4e=Pq.values;X4e({target:"Object",stat:!0},{values:function(e){return q4e(e)}});var Z4e=A,H4=pq;Z4e({global:!0,forced:parseFloat!==H4},{parseFloat:H4});var Q4e=A,W4=vq;Q4e({global:!0,forced:parseInt!==W4},{parseInt:W4});var J4e=TypeError,Zo=function(t,e){if(t<e)throw new J4e("Not enough arguments");return t},e6e=gs,Mq=/(?:ipad|iphone|ipod).*applewebkit/i.test(e6e),so=te,t6e=yn,r6e=dt,K4=Ce,n6e=ke,Rq=q,G4=tG,o6e=Io,V4=kx,i6e=Zo,s6e=Mq,a6e=Rh,LT=so.setImmediate,NT=so.clearImmediate,l6e=so.process,HI=so.Dispatch,c6e=so.Function,Y4=so.MessageChannel,u6e=so.String,WI=0,Op={},X4="onreadystatechange",wg,sc,KI,GI;Rq(function(){wg=so.location});var pM=function(t){if(n6e(Op,t)){var e=Op[t];delete Op[t],e()}},VI=function(t){return function(){pM(t)}},q4=function(t){pM(t.data)},Z4=function(t){so.postMessage(u6e(t),wg.protocol+"//"+wg.host)};(!LT||!NT)&&(LT=function(e){i6e(arguments.length,1);var r=K4(e)?e:c6e(e),n=o6e(arguments,1);return Op[++WI]=function(){t6e(r,void 0,n)},sc(WI),WI},NT=function(e){delete Op[e]},a6e?sc=function(t){l6e.nextTick(VI(t))}:HI&&HI.now?sc=function(t){HI.now(VI(t))}:Y4&&!s6e?(KI=new Y4,GI=KI.port2,KI.port1.onmessage=q4,sc=r6e(GI.postMessage,GI)):so.addEventListener&&K4(so.postMessage)&&!so.importScripts&&wg&&wg.protocol!=="file:"&&!Rq(Z4)?(sc=Z4,so.addEventListener("message",q4,!1)):X4 in V4("script")?sc=function(t){G4.appendChild(V4("script"))[X4]=function(){G4.removeChild(this),pM(t)}}:sc=function(t){setTimeout(VI(t),0)});var E1={set:LT,clear:NT},Q4=te,d6e=ge,h6e=Object.getOwnPropertyDescriptor,jq=function(t){if(!d6e)return Q4[t];var e=h6e(Q4,t);return e&&e.value},Dq=function(){this.head=null,this.tail=null};Dq.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var Lq=Dq,f6e=gs,p6e=/ipad|iphone|ipod/i.test(f6e)&&typeof Pebble<"u",g6e=gs,m6e=/web0s(?!.*chrome)/i.test(g6e),th=te,v6e=jq,J4=dt,YI=E1.set,y6e=Lq,S6e=Mq,w6e=p6e,x6e=m6e,XI=Rh,e6=th.MutationObserver||th.WebKitMutationObserver,t6=th.document,r6=th.process,Kv=th.Promise,FT=v6e("queueMicrotask"),Tu,qI,ZI,Gv,n6;if(!FT){var Vv=new y6e,Yv=function(){var t,e;for(XI&&(t=r6.domain)&&t.exit();e=Vv.get();)try{e()}catch(r){throw Vv.head&&Tu(),r}t&&t.enter()};!S6e&&!XI&&!x6e&&e6&&t6?(qI=!0,ZI=t6.createTextNode(""),new e6(Yv).observe(ZI,{characterData:!0}),Tu=function(){ZI.data=qI=!qI}):!w6e&&Kv&&Kv.resolve?(Gv=Kv.resolve(void 0),Gv.constructor=Kv,n6=J4(Gv.then,Gv),Tu=function(){n6(Yv)}):XI?Tu=function(){r6.nextTick(Yv)}:(YI=J4(YI,th),Tu=function(){YI(Yv)}),FT=function(t){Vv.head||Tu(),Vv.add(t)}}var Nq=FT,Fq=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},uu=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},b6e=te,fm=b6e.Promise,$6e=te,Mp=fm,I6e=Ce,P6e=Yg,E6e=Ox,C6e=ve,o6=u1,QI=pa;Mp&&Mp.prototype;var _6e=C6e("species"),BT=!1,Bq=I6e($6e.PromiseRejectionEvent),T6e=P6e("Promise",function(){var t=E6e(Mp),e=t!==String(Mp);if(!e&&QI===66)return!0;if(!QI||QI<51||!/native code/.test(t)){var r=new Mp(function(i){i(1)}),n=function(i){i(function(){},function(){})},o=r.constructor={};if(o[_6e]=n,BT=r.then(function(){})instanceof n,!BT)return!0}return!e&&(o6==="BROWSER"||o6==="DENO")&&!Bq}),pm={CONSTRUCTOR:T6e,REJECTION_EVENT:Bq,SUBCLASSING:BT},bs={},i6=Pe,A6e=TypeError,k6e=function(t){var e,r;this.promise=new t(function(n,o){if(e!==void 0||r!==void 0)throw new A6e("Bad Promise constructor");e=n,r=o}),this.resolve=i6(e),this.reject=i6(r)};bs.f=function(t){return new k6e(t)};var O6e=A,w0=Rh,$l=te,rh=ne,s6=nt,a6=_i,M6e=Gn,R6e=lu,j6e=Pe,CS=Ce,D6e=Ie,L6e=wn,N6e=Dh,Uq=E1.set,gM=Nq,F6e=Fq,B6e=uu,U6e=Lq,zq=et,x0=fm,mM=pm,Hq=bs,C1="Promise",Wq=mM.CONSTRUCTOR,z6e=mM.REJECTION_EVENT,H6e=mM.SUBCLASSING,JI=zq.getterFor(C1),W6e=zq.set,Uu=x0&&x0.prototype,mc=x0,Xv=Uu,Kq=$l.TypeError,UT=$l.document,vM=$l.process,zT=Hq.f,K6e=zT,G6e=!!(UT&&UT.createEvent&&$l.dispatchEvent),Gq="unhandledrejection",V6e="rejectionhandled",l6=0,Vq=1,Y6e=2,yM=1,Yq=2,qv,c6,X6e,u6,Xq=function(t){var e;return D6e(t)&&CS(e=t.then)?e:!1},qq=function(t,e){var r=e.value,n=e.state===Vq,o=n?t.ok:t.fail,i=t.resolve,s=t.reject,a=t.domain,l,c,u;try{o?(n||(e.rejection===Yq&&Z6e(e),e.rejection=yM),o===!0?l=r:(a&&a.enter(),l=o(r),a&&(a.exit(),u=!0)),l===t.promise?s(new Kq("Promise-chain cycle")):(c=Xq(l))?rh(c,l,i,s):i(l)):s(r)}catch(d){a&&!u&&a.exit(),s(d)}},Zq=function(t,e){t.notified||(t.notified=!0,gM(function(){for(var r=t.reactions,n;n=r.get();)qq(n,t);t.notified=!1,e&&!t.rejection&&q6e(t)}))},Qq=function(t,e,r){var n,o;G6e?(n=UT.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),$l.dispatchEvent(n)):n={promise:e,reason:r},!z6e&&(o=$l["on"+t])?o(n):t===Gq&&F6e("Unhandled promise rejection",r)},q6e=function(t){rh(Uq,$l,function(){var e=t.facade,r=t.value,n=d6(t),o;if(n&&(o=B6e(function(){w0?vM.emit("unhandledRejection",r,e):Qq(Gq,e,r)}),t.rejection=w0||d6(t)?Yq:yM,o.error))throw o.value})},d6=function(t){return t.rejection!==yM&&!t.parent},Z6e=function(t){rh(Uq,$l,function(){var e=t.facade;w0?vM.emit("rejectionHandled",e):Qq(V6e,e,t.value)})},fd=function(t,e,r){return function(n){t(e,n,r)}},Rd=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=Y6e,Zq(t,!0))},HT=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new Kq("Promise can't be resolved itself");var n=Xq(e);n?gM(function(){var o={done:!1};try{rh(n,e,fd(HT,o,t),fd(Rd,o,t))}catch(i){Rd(o,i,t)}}):(t.value=e,t.state=Vq,Zq(t,!1))}catch(o){Rd({done:!1},o,t)}}};if(Wq&&(mc=function(e){L6e(this,Xv),j6e(e),rh(qv,this);var r=JI(this);try{e(fd(HT,r),fd(Rd,r))}catch(n){Rd(r,n)}},Xv=mc.prototype,qv=function(e){W6e(this,{type:C1,done:!1,notified:!1,parent:!1,reactions:new U6e,rejection:!1,state:l6,value:null})},qv.prototype=s6(Xv,"then",function(e,r){var n=JI(this),o=zT(N6e(this,mc));return n.parent=!0,o.ok=CS(e)?e:!0,o.fail=CS(r)&&r,o.domain=w0?vM.domain:void 0,n.state===l6?n.reactions.add(o):gM(function(){qq(o,n)}),o.promise}),c6=function(){var t=new qv,e=JI(t);this.promise=t,this.resolve=fd(HT,e),this.reject=fd(Rd,e)},Hq.f=zT=function(t){return t===mc||t===X6e?new c6(t):K6e(t)},CS(x0)&&Uu!==Object.prototype)){u6=Uu.then,H6e||s6(Uu,"then",function(e,r){var n=this;return new mc(function(o,i){rh(u6,n,o,i)}).then(e,r)},{unsafe:!0});try{delete Uu.constructor}catch{}a6&&a6(Uu,Xv)}O6e({global:!0,constructor:!0,wrap:!0,forced:Wq},{Promise:mc});M6e(mc,C1,!1);R6e(C1);var Q6e=fm,J6e=l1,e8e=pm.CONSTRUCTOR,_1=e8e||!J6e(function(t){Q6e.all(t).then(void 0,function(){})}),t8e=A,r8e=ne,n8e=Pe,o8e=bs,i8e=uu,s8e=zt,a8e=_1;t8e({target:"Promise",stat:!0,forced:a8e},{all:function(e){var r=this,n=o8e.f(r),o=n.resolve,i=n.reject,s=i8e(function(){var a=n8e(r.resolve),l=[],c=0,u=1;s8e(e,function(d){var f=c++,p=!1;u++,r8e(a,r,d).then(function(g){p||(p=!0,l[f]=g,--u||o(l))},i)}),--u||o(l)});return s.error&&i(s.value),n.promise}});var l8e=A,c8e=pm.CONSTRUCTOR,WT=fm,u8e=be,d8e=Ce,h8e=nt,h6=WT&&WT.prototype;l8e({target:"Promise",proto:!0,forced:c8e,real:!0},{catch:function(t){return this.then(void 0,t)}});if(d8e(WT)){var f6=u8e("Promise").prototype.catch;h6.catch!==f6&&h8e(h6,"catch",f6,{unsafe:!0})}var f8e=A,p8e=ne,g8e=Pe,m8e=bs,v8e=uu,y8e=zt,S8e=_1;f8e({target:"Promise",stat:!0,forced:S8e},{race:function(e){var r=this,n=m8e.f(r),o=n.reject,i=v8e(function(){var s=g8e(r.resolve);y8e(e,function(a){p8e(s,r,a).then(n.resolve,o)})});return i.error&&o(i.value),n.promise}});var w8e=A,x8e=bs,b8e=pm.CONSTRUCTOR;w8e({target:"Promise",stat:!0,forced:b8e},{reject:function(e){var r=x8e.f(this),n=r.reject;return n(e),r.promise}});var $8e=re,I8e=Ie,P8e=bs,Jq=function(t,e){if($8e(t),I8e(e)&&e.constructor===t)return e;var r=P8e.f(t),n=r.resolve;return n(e),r.promise},E8e=A,C8e=be,_8e=pm.CONSTRUCTOR,T8e=Jq;C8e("Promise");E8e({target:"Promise",stat:!0,forced:_8e},{resolve:function(e){return T8e(this,e)}});var A8e=A,k8e=ne,O8e=Pe,M8e=bs,R8e=uu,j8e=zt,D8e=_1;A8e({target:"Promise",stat:!0,forced:D8e},{allSettled:function(e){var r=this,n=M8e.f(r),o=n.resolve,i=n.reject,s=R8e(function(){var a=O8e(r.resolve),l=[],c=0,u=1;j8e(e,function(d){var f=c++,p=!1;u++,k8e(a,r,d).then(function(g){p||(p=!0,l[f]={status:"fulfilled",value:g},--u||o(l))},function(g){p||(p=!0,l[f]={status:"rejected",reason:g},--u||o(l))})}),--u||o(l)});return s.error&&i(s.value),n.promise}});var L8e=A,N8e=ne,F8e=Pe,B8e=be,U8e=bs,z8e=uu,H8e=zt,W8e=_1,p6="No one promise resolved";L8e({target:"Promise",stat:!0,forced:W8e},{any:function(e){var r=this,n=B8e("AggregateError"),o=U8e.f(r),i=o.resolve,s=o.reject,a=z8e(function(){var l=F8e(r.resolve),c=[],u=0,d=1,f=!1;H8e(e,function(p){var g=u++,m=!1;d++,N8e(l,r,p).then(function(S){m||f||(f=!0,i(S))},function(S){m||f||(m=!0,c[g]=S,--d||s(new n(c,p6)))})}),--d||s(new n(c,p6))});return a.error&&s(a.value),o.promise}});var K8e=A,b0=fm,G8e=q,eZ=be,tZ=Ce,V8e=Dh,g6=Jq,Y8e=nt,KT=b0&&b0.prototype,X8e=!!b0&&G8e(function(){KT.finally.call({then:function(){}},function(){})});K8e({target:"Promise",proto:!0,real:!0,forced:X8e},{finally:function(t){var e=V8e(this,eZ("Promise")),r=tZ(t);return this.then(r?function(n){return g6(e,t()).then(function(){return n})}:t,r?function(n){return g6(e,t()).then(function(){throw n})}:t)}});if(tZ(b0)){var m6=eZ("Promise").prototype.finally;KT.finally!==m6&&Y8e(KT,"finally",m6,{unsafe:!0})}var q8e=A,Z8e=bs;q8e({target:"Promise",stat:!0},{withResolvers:function(){var e=Z8e.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var Q8e=A,J8e=yn,eBe=Pe,tBe=re,rBe=q,nBe=!rBe(function(){Reflect.apply(function(){})});Q8e({target:"Reflect",stat:!0,forced:nBe},{apply:function(e,r,n){return J8e(eBe(e),r,tBe(n))}});var oBe=A,iBe=be,eP=yn,sBe=XX,v6=m1,aBe=re,y6=Ie,lBe=ar,rZ=q,SM=iBe("Reflect","construct"),cBe=Object.prototype,uBe=[].push,nZ=rZ(function(){function t(){}return!(SM(function(){},[],t)instanceof t)}),oZ=!rZ(function(){SM(function(){})}),S6=nZ||oZ;oBe({target:"Reflect",stat:!0,forced:S6,sham:S6},{construct:function(e,r){v6(e),aBe(r);var n=arguments.length<3?e:v6(arguments[2]);if(oZ&&!nZ)return SM(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var o=[null];return eP(uBe,o,r),new(eP(sBe,e,o))}var i=n.prototype,s=lBe(y6(i)?i:cBe),a=eP(e,s,r);return y6(a)?a:s}});var dBe=A,hBe=ge,w6=re,fBe=ga,iZ=ut,pBe=q,gBe=pBe(function(){Reflect.defineProperty(iZ.f({},1,{value:1}),1,{value:2})});dBe({target:"Reflect",stat:!0,forced:gBe,sham:!hBe},{defineProperty:function(e,r,n){w6(e);var o=fBe(r);w6(n);try{return iZ.f(e,o,n),!0}catch{return!1}}});var mBe=A,vBe=re,yBe=vr.f;mBe({target:"Reflect",stat:!0},{deleteProperty:function(e,r){var n=yBe(vBe(e),r);return n&&!n.configurable?!1:delete e[r]}});var x6=ke,sZ=function(t){return t!==void 0&&(x6(t,"value")||x6(t,"writable"))},SBe=A,wBe=ne,xBe=Ie,bBe=re,$Be=sZ,IBe=vr,PBe=lr;function aZ(t,e){var r=arguments.length<3?t:arguments[2],n,o;if(bBe(t)===r)return t[e];if(n=IBe.f(t,e),n)return $Be(n)?n.value:n.get===void 0?void 0:wBe(n.get,r);if(xBe(o=PBe(t)))return aZ(o,e,r)}SBe({target:"Reflect",stat:!0},{get:aZ});var EBe=A,CBe=ge,_Be=re,TBe=vr;EBe({target:"Reflect",stat:!0,sham:!CBe},{getOwnPropertyDescriptor:function(e,r){return TBe.f(_Be(e),r)}});var ABe=A,kBe=re,OBe=lr,MBe=_O;ABe({target:"Reflect",stat:!0,sham:!MBe},{getPrototypeOf:function(e){return OBe(kBe(e))}});var RBe=A;RBe({target:"Reflect",stat:!0},{has:function(e,r){return r in e}});var jBe=A,DBe=re,LBe=iM;jBe({target:"Reflect",stat:!0},{isExtensible:function(e){return DBe(e),LBe(e)}});var NBe=A,FBe=Lk;NBe({target:"Reflect",stat:!0},{ownKeys:FBe});var BBe=A,UBe=be,zBe=re,HBe=Wl;BBe({target:"Reflect",stat:!0,sham:!HBe},{preventExtensions:function(e){zBe(e);try{var r=UBe("Object","preventExtensions");return r&&r(e),!0}catch{return!1}}});var WBe=A,KBe=ne,GBe=re,b6=Ie,VBe=sZ,YBe=q,GT=ut,$6=vr,XBe=lr,I6=wo;function lZ(t,e,r){var n=arguments.length<4?t:arguments[3],o=$6.f(GBe(t),e),i,s,a;if(!o){if(b6(s=XBe(t)))return lZ(s,e,r,n);o=I6(0)}if(VBe(o)){if(o.writable===!1||!b6(n))return!1;if(i=$6.f(n,e)){if(i.get||i.set||i.writable===!1)return!1;i.value=r,GT.f(n,e,i)}else GT.f(n,e,I6(0,r))}else{if(a=o.set,a===void 0)return!1;KBe(a,n,r)}return!0}var qBe=YBe(function(){var t=function(){},e=GT.f(new t,"a",{configurable:!0});return Reflect.set(t.prototype,"a",1,e)!==!1});WBe({target:"Reflect",stat:!0,forced:qBe},{set:lZ});var ZBe=A,QBe=re,JBe=RY,P6=_i;P6&&ZBe({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){QBe(e),JBe(r);try{return P6(e,r),!0}catch{return!1}}});var eUe=A,tUe=te,rUe=Gn;eUe({global:!0},{Reflect:{}});rUe(tUe.Reflect,"Reflect",!0);var nUe=ge,wM=te,gm=V,oUe=Yg,iUe=ou,sUe=sr,aUe=ar,lUe=Dl.f,E6=rn,cUe=Ux,C6=Ee,uUe=Qg,cZ=Dx,dUe=jY,hUe=nt,fUe=q,pUe=ke,gUe=et.enforce,mUe=lu,vUe=ve,uZ=Wk,dZ=dG,yUe=vUe("match"),fl=wM.RegExp,zu=fl.prototype,SUe=wM.SyntaxError,wUe=gm(zu.exec),$0=gm("".charAt),_6=gm("".replace),T6=gm("".indexOf),A6=gm("".slice),xUe=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,_c=/a/g,tP=/a/g,bUe=new fl(_c)!==_c,hZ=cZ.MISSED_STICKY,$Ue=cZ.UNSUPPORTED_Y,IUe=nUe&&(!bUe||hZ||uZ||dZ||fUe(function(){return tP[yUe]=!1,fl(_c)!==_c||fl(tP)===tP||String(fl(_c,"i"))!=="/a/i"})),PUe=function(t){for(var e=t.length,r=0,n="",o=!1,i;r<=e;r++){if(i=$0(t,r),i==="\\"){n+=i+$0(t,++r);continue}!o&&i==="."?n+="[\\s\\S]":(i==="["?o=!0:i==="]"&&(o=!1),n+=i)}return n},EUe=function(t){for(var e=t.length,r=0,n="",o=[],i=aUe(null),s=!1,a=!1,l=0,c="",u;r<=e;r++){if(u=$0(t,r),u==="\\")u+=$0(t,++r);else if(u==="]")s=!1;else if(!s)switch(!0){case u==="[":s=!0;break;case u==="(":if(n+=u,A6(t,r+1,r+3)==="?:")continue;wUe(xUe,A6(t,r+1))&&(r+=2,a=!0),l++;continue;case(u===">"&&a):if(c===""||pUe(i,c))throw new SUe("Invalid capture group name");i[c]=!0,o[o.length]=[c,l],a=!1,c="";continue}a?c+=u:n+=u}return[n,o]};if(oUe("RegExp",IUe)){for(var ac=function(e,r){var n=E6(zu,this),o=cUe(e),i=r===void 0,s=[],a=e,l,c,u,d,f,p;if(!n&&o&&i&&e.constructor===ac)return e;if((o||E6(zu,e))&&(e=e.source,i&&(r=uUe(a))),e=e===void 0?"":C6(e),r=r===void 0?"":C6(r),a=e,uZ&&"dotAll"in _c&&(c=!!r&&T6(r,"s")>-1,c&&(r=_6(r,/s/g,""))),l=r,hZ&&"sticky"in _c&&(u=!!r&&T6(r,"y")>-1,u&&$Ue&&(r=_6(r,/y/g,""))),dZ&&(d=EUe(e),e=d[0],s=d[1]),f=iUe(fl(e,r),n?this:zu,ac),(c||u||s.length)&&(p=gUe(f),c&&(p.dotAll=!0,p.raw=ac(PUe(e),l)),u&&(p.sticky=!0),s.length&&(p.groups=s)),e!==a)try{sUe(f,"source",a===""?"(?:)":a)}catch{}return f},k6=lUe(fl),O6=0;k6.length>O6;)dUe(ac,fl,k6[O6++]);zu.constructor=ac,ac.prototype=zu,hUe(wM,"RegExp",ac,{constructor:!0})}mUe("RegExp");var CUe=ge,_Ue=Wk,TUe=tn,AUe=Ct,kUe=et.get,M6=RegExp.prototype,OUe=TypeError;CUe&&_Ue&&AUe(M6,"dotAll",{configurable:!0,get:function(){if(this!==M6){if(TUe(this)==="RegExp")return!!kUe(this).dotAll;throw new OUe("Incompatible receiver, RegExp required")}}});var MUe=te,RUe=ge,jUe=Ct,DUe=Bk,LUe=q,fZ=MUe.RegExp,pZ=fZ.prototype,NUe=RUe&&LUe(function(){var t=!0;try{fZ(".","d")}catch{t=!1}var e={},r="",n=t?"dgimsy":"gimsy",o=function(l,c){Object.defineProperty(e,l,{get:function(){return r+=c,!0}})},i={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};t&&(i.hasIndices="d");for(var s in i)o(s,i[s]);var a=Object.getOwnPropertyDescriptor(pZ,"flags").get.call(e);return a!==n||r!==n});NUe&&jUe(pZ,"flags",{configurable:!0,get:DUe});var FUe=ge,BUe=Dx.MISSED_STICKY,UUe=tn,zUe=Ct,HUe=et.get,R6=RegExp.prototype,WUe=TypeError;FUe&&BUe&&zUe(R6,"sticky",{configurable:!0,get:function(){if(this!==R6){if(UUe(this)==="RegExp")return!!HUe(this).sticky;throw new WUe("Incompatible receiver, RegExp required")}}});var KUe=A,j6=ne,GUe=Ce,D6=re,VUe=Ee,YUe=function(){var t=!1,e=/[ac]/;return e.exec=function(){return t=!0,/./.exec.apply(this,arguments)},e.test("abc")===!0&&t}(),XUe=/./.test;KUe({target:"RegExp",proto:!0,forced:!YUe},{test:function(t){var e=D6(this),r=VUe(t),n=e.exec;if(!GUe(n))return j6(XUe,e,r);var o=j6(n,e,r);return o===null?!1:(D6(o),!0)}});var qUe=Ih.PROPER,ZUe=nt,QUe=re,L6=Ee,JUe=q,eze=Qg,xM="toString",gZ=RegExp.prototype,mZ=gZ[xM],tze=JUe(function(){return mZ.call({source:"a",flags:"b"})!=="/a/b"}),rze=qUe&&mZ.name!==xM;(tze||rze)&&ZUe(gZ,xM,function(){var e=QUe(this),r=L6(e.source),n=L6(eze(e));return"/"+r+"/"+n},{unsafe:!0});var nze=S1,oze=rq;nze("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},oze);var rP=V,Zv=Set.prototype,Fr={Set,add:rP(Zv.add),has:rP(Zv.has),remove:rP(Zv.delete),proto:Zv},ize=Fr.has,on=function(t){return ize(t),t},sze=ne,Kl=function(t,e,r){for(var n=r?t:t.iterator,o=t.next,i,s;!(i=sze(o,n)).done;)if(s=e(i.value),s!==void 0)return s},vZ=V,aze=Kl,yZ=Fr,lze=yZ.Set,SZ=yZ.proto,cze=vZ(SZ.forEach),wZ=vZ(SZ.keys),uze=wZ(new lze).next,Po=function(t,e,r){return r?aze({iterator:wZ(t),next:uze},e):cze(t,e)},xZ=Fr,dze=Po,hze=xZ.Set,fze=xZ.add,bM=function(t){var e=new hze;return dze(t,function(r){fze(e,r)}),e},pze=i1,gze=Fr,mm=pze(gze.proto,"size","get")||function(t){return t.size},kt=function(t){return{iterator:t,next:t.next,done:!1}},N6=Pe,bZ=re,F6=ne,mze=Et,vze=kt,B6="Invalid size",yze=RangeError,Sze=TypeError,wze=Math.max,$Z=function(t,e){this.set=t,this.size=wze(e,0),this.has=N6(t.has),this.keys=N6(t.keys)};$Z.prototype={getIterator:function(){return vze(bZ(F6(this.keys,this.set)))},includes:function(t){return F6(this.has,this.set,t)}};var du=function(t){bZ(t);var e=+t.size;if(e!==e)throw new Sze(B6);var r=mze(e);if(r<0)throw new yze(B6);return new $Z(t,r)},xze=on,IZ=Fr,bze=bM,$ze=mm,Ize=du,Pze=Po,Eze=Kl,Cze=IZ.has,U6=IZ.remove,PZ=function(e){var r=xze(this),n=Ize(e),o=bze(r);return $ze(r)<=n.size?Pze(r,function(i){n.includes(i)&&U6(o,i)}):Eze(n.getIterator(),function(i){Cze(r,i)&&U6(o,i)}),o},_ze=be,z6=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},hu=function(t){var e=_ze("Set");try{new e()[t](z6(0));try{return new e()[t](z6(-1)),!1}catch{return!0}}catch{return!1}},Tze=A,Aze=PZ,kze=hu;Tze({target:"Set",proto:!0,real:!0,forced:!kze("difference")},{difference:Aze});var Oze=on,$M=Fr,Mze=mm,Rze=du,jze=Po,Dze=Kl,Lze=$M.Set,H6=$M.add,Nze=$M.has,EZ=function(e){var r=Oze(this),n=Rze(e),o=new Lze;return Mze(r)>n.size?Dze(n.getIterator(),function(i){Nze(r,i)&&H6(o,i)}):jze(r,function(i){n.includes(i)&&H6(o,i)}),o},Fze=A,Bze=q,Uze=EZ,zze=hu,Hze=!zze("intersection")||Bze(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});Fze({target:"Set",proto:!0,real:!0,forced:Hze},{intersection:Uze});var Wze=on,Kze=Fr.has,Gze=mm,Vze=du,Yze=Po,Xze=Kl,qze=Ul,CZ=function(e){var r=Wze(this),n=Vze(e);if(Gze(r)<=n.size)return Yze(r,function(i){if(n.includes(i))return!1},!0)!==!1;var o=n.getIterator();return Xze(o,function(i){if(Kze(r,i))return qze(o,"normal",!1)})!==!1},Zze=A,Qze=CZ,Jze=hu;Zze({target:"Set",proto:!0,real:!0,forced:!Jze("isDisjointFrom")},{isDisjointFrom:Qze});var e7e=on,t7e=mm,r7e=Po,n7e=du,_Z=function(e){var r=e7e(this),n=n7e(e);return t7e(r)>n.size?!1:r7e(r,function(o){if(!n.includes(o))return!1},!0)!==!1},o7e=A,i7e=_Z,s7e=hu;o7e({target:"Set",proto:!0,real:!0,forced:!s7e("isSubsetOf")},{isSubsetOf:i7e});var a7e=on,l7e=Fr.has,c7e=mm,u7e=du,d7e=Kl,h7e=Ul,TZ=function(e){var r=a7e(this),n=u7e(e);if(c7e(r)<n.size)return!1;var o=n.getIterator();return d7e(o,function(i){if(!l7e(r,i))return h7e(o,"normal",!1)})!==!1},f7e=A,p7e=TZ,g7e=hu;f7e({target:"Set",proto:!0,real:!0,forced:!g7e("isSupersetOf")},{isSupersetOf:p7e});var m7e=on,IM=Fr,v7e=bM,y7e=du,S7e=Kl,w7e=IM.add,x7e=IM.has,b7e=IM.remove,AZ=function(e){var r=m7e(this),n=y7e(e).getIterator(),o=v7e(r);return S7e(n,function(i){x7e(r,i)?b7e(o,i):w7e(o,i)}),o},$7e=A,I7e=AZ,P7e=hu;$7e({target:"Set",proto:!0,real:!0,forced:!P7e("symmetricDifference")},{symmetricDifference:I7e});var E7e=on,C7e=Fr.add,_7e=bM,T7e=du,A7e=Kl,kZ=function(e){var r=E7e(this),n=T7e(e).getIterator(),o=_7e(r);return A7e(n,function(i){C7e(o,i)}),o},k7e=A,O7e=kZ,M7e=hu;k7e({target:"Set",proto:!0,real:!0,forced:!M7e("union")},{union:O7e});var R7e=A,j7e=Ch.codeAt;R7e({target:"String",proto:!0},{codePointAt:function(e){return j7e(this,e)}});var D7e=Ux,L7e=TypeError,PM=function(t){if(D7e(t))throw new L7e("The method doesn't accept regular expressions");return t},N7e=ve,F7e=N7e("match"),EM=function(t){var e=/./;try{"/./"[t](e)}catch{try{return e[F7e]=!1,"/./"[t](e)}catch{}}return!1},B7e=A,U7e=Ll,z7e=vr.f,H7e=xo,W6=Ee,W7e=PM,K7e=St,G7e=EM,V7e=U7e("".slice),Y7e=Math.min,OZ=G7e("endsWith"),X7e=!OZ&&!!function(){var t=z7e(String.prototype,"endsWith");return t&&!t.writable}();B7e({target:"String",proto:!0,forced:!X7e&&!OZ},{endsWith:function(e){var r=W6(K7e(this));W7e(e);var n=arguments.length>1?arguments[1]:void 0,o=r.length,i=n===void 0?o:Y7e(H7e(n),o),s=W6(e);return V7e(r,i-s.length,i)===s}});var q7e=A,Z7e=V,Q7e=ms,J7e=RangeError,K6=String.fromCharCode,G6=String.fromCodePoint,e9e=Z7e([].join),t9e=!!G6&&G6.length!==1;q7e({target:"String",stat:!0,arity:1,forced:t9e},{fromCodePoint:function(e){for(var r=[],n=arguments.length,o=0,i;n>o;){if(i=+arguments[o++],Q7e(i,1114111)!==i)throw new J7e(i+" is not a valid code point");r[o]=i<65536?K6(i):K6(((i-=65536)>>10)+55296,i%1024+56320)}return e9e(r,"")}});var r9e=A,n9e=V,o9e=PM,i9e=St,V6=Ee,s9e=EM,a9e=n9e("".indexOf);r9e({target:"String",proto:!0,forced:!s9e("includes")},{includes:function(e){return!!~a9e(V6(i9e(this)),V6(o9e(e)),arguments.length>1?arguments[1]:void 0)}});var l9e=A,c9e=V,u9e=St,d9e=Ee,Y6=c9e("".charCodeAt);l9e({target:"String",proto:!0},{isWellFormed:function(){for(var e=d9e(u9e(this)),r=e.length,n=0;n<r;n++){var o=Y6(e,n);if((o&63488)===55296&&(o>=56320||++n>=r||(Y6(e,n)&64512)!==56320))return!1}return!0}});var h9e=Ch.charAt,f9e=Ee,MZ=et,p9e=MO,X6=Nr,RZ="String Iterator",g9e=MZ.set,m9e=MZ.getterFor(RZ);p9e(String,"String",function(t){g9e(this,{type:RZ,string:f9e(t),index:0})},function(){var e=m9e(this),r=e.string,n=e.index,o;return n>=r.length?X6(void 0,!0):(o=h9e(r,n),e.index+=o.length,X6(o,!1))});var v9e=ne,y9e=Nx,S9e=re,w9e=nr,x9e=xo,nP=Ee,b9e=St,$9e=Qt,I9e=Fx,q6=Zg;y9e("match",function(t,e,r){return[function(o){var i=b9e(this),s=w9e(o)?void 0:$9e(o,t);return s?v9e(s,o,i):new RegExp(o)[t](nP(i))},function(n){var o=S9e(this),i=nP(n),s=r(e,o,i);if(s.done)return s.value;if(!o.global)return q6(o,i);var a=o.unicode;o.lastIndex=0;for(var l=[],c=0,u;(u=q6(o,i))!==null;){var d=nP(u[0]);l[c]=d,d===""&&(o.lastIndex=I9e(i,x9e(o.lastIndex),a)),c++}return c===0?null:l}]});var P9e=A,E9e=ne,jZ=Ll,C9e=au,Qv=Nr,Z6=St,DZ=xo,xg=Ee,_9e=re,T9e=nr,A9e=tn,k9e=Ux,LZ=Qg,O9e=Qt,M9e=nt,R9e=q,j9e=ve,D9e=Dh,L9e=Fx,N9e=Zg,NZ=et,F9e=ir,I0=j9e("matchAll"),FZ="RegExp String",BZ=FZ+" Iterator",B9e=NZ.set,U9e=NZ.getterFor(BZ),Q6=RegExp.prototype,z9e=TypeError,VT=jZ("".indexOf),P0=jZ("".matchAll),oP=!!P0&&!R9e(function(){P0("a",/./)}),H9e=C9e(function(e,r,n,o){B9e(this,{type:BZ,regexp:e,string:r,global:n,unicode:o,done:!1})},FZ,function(){var e=U9e(this);if(e.done)return Qv(void 0,!0);var r=e.regexp,n=e.string,o=N9e(r,n);return o===null?(e.done=!0,Qv(void 0,!0)):e.global?(xg(o[0])===""&&(r.lastIndex=L9e(n,DZ(r.lastIndex),e.unicode)),Qv(o,!1)):(e.done=!0,Qv(o,!1))}),UZ=function(t){var e=_9e(this),r=xg(t),n=D9e(e,RegExp),o=xg(LZ(e)),i,s,a;return i=new n(n===RegExp?e.source:e,o),s=!!~VT(o,"g"),a=!!~VT(o,"u"),i.lastIndex=DZ(e.lastIndex),new H9e(i,r,s,a)};P9e({target:"String",proto:!0,forced:oP},{matchAll:function(e){var r=Z6(this),n,o,i,s;if(T9e(e)){if(oP)return P0(r,e)}else{if(k9e(e)&&(n=xg(Z6(LZ(e))),!~VT(n,"g")))throw new z9e("`.matchAll` does not allow non-global regexes");if(oP)return P0(r,e);if(i=O9e(e,I0),i===void 0&&F9e&&A9e(e)==="RegExp"&&(i=UZ),i)return E9e(i,e,r)}return o=xg(r),s=new RegExp(e,"g"),s[I0](o)}});I0 in Q6||M9e(Q6,I0,UZ);var W9e=gs,zZ=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(W9e),K9e=A,G9e=y1.end,V9e=zZ;K9e({target:"String",proto:!0,forced:V9e},{padEnd:function(e){return G9e(this,e,arguments.length>1?arguments[1]:void 0)}});var Y9e=A,X9e=y1.start,q9e=zZ;Y9e({target:"String",proto:!0,forced:q9e},{padStart:function(e){return X9e(this,e,arguments.length>1?arguments[1]:void 0)}});var Z9e=A,HZ=V,Q9e=or,J9e=je,J6=Ee,eHe=Ke,e8=HZ([].push),tHe=HZ([].join);Z9e({target:"String",stat:!0},{raw:function(e){var r=Q9e(J9e(e).raw),n=eHe(r);if(!n)return"";for(var o=arguments.length,i=[],s=0;;){if(e8(i,J6(r[s++])),s===n)return tHe(i,"");s<o&&e8(i,J6(arguments[s]))}}});var rHe=A,nHe=v1;rHe({target:"String",proto:!0},{repeat:nHe});var oHe=ne,iHe=Nx,sHe=re,aHe=nr,lHe=St,t8=Tq,r8=Ee,cHe=Qt,uHe=Zg;iHe("search",function(t,e,r){return[function(o){var i=lHe(this),s=aHe(o)?void 0:cHe(o,t);return s?oHe(s,o,i):new RegExp(o)[t](r8(i))},function(n){var o=sHe(this),i=r8(n),s=r(e,o,i);if(s.done)return s.value;var a=o.lastIndex;t8(a,0)||(o.lastIndex=0);var l=uHe(o,i);return t8(o.lastIndex,a)||(o.lastIndex=a),l===null?-1:l.index}]});var iP=ne,WZ=V,dHe=Nx,hHe=re,fHe=nr,pHe=St,gHe=Dh,mHe=Fx,vHe=xo,n8=Ee,yHe=Qt,o8=Zg,SHe=Dx,wHe=q,Au=SHe.UNSUPPORTED_Y,xHe=4294967295,bHe=Math.min,sP=WZ([].push),aP=WZ("".slice),$He=!wHe(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),i8="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;dHe("split",function(t,e,r){var n="0".split(void 0,0).length?function(o,i){return o===void 0&&i===0?[]:iP(e,this,o,i)}:e;return[function(i,s){var a=pHe(this),l=fHe(i)?void 0:yHe(i,t);return l?iP(l,i,a,s):iP(n,n8(a),i,s)},function(o,i){var s=hHe(this),a=n8(o);if(!i8){var l=r(n,s,a,i,n!==e);if(l.done)return l.value}var c=gHe(s,RegExp),u=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(Au?"g":"y"),f=new c(Au?"^(?:"+s.source+")":s,d),p=i===void 0?xHe:i>>>0;if(p===0)return[];if(a.length===0)return o8(f,a)===null?[a]:[];for(var g=0,m=0,S=[];m<a.length;){f.lastIndex=Au?0:m;var y=o8(f,Au?aP(a,m):a),v;if(y===null||(v=bHe(vHe(f.lastIndex+(Au?m:0)),a.length))===g)m=mHe(a,m,u);else{if(sP(S,aP(a,g,m)),S.length===p)return S;for(var b=1;b<=y.length-1;b++)if(sP(S,y[b]),S.length===p)return S;m=g=v}}return sP(S,aP(a,g)),S}]},i8||!$He,Au);var IHe=A,PHe=Ll,EHe=vr.f,CHe=xo,s8=Ee,_He=PM,THe=St,AHe=EM,kHe=PHe("".slice),OHe=Math.min,KZ=AHe("startsWith"),MHe=!KZ&&!!function(){var t=EHe(String.prototype,"startsWith");return t&&!t.writable}();IHe({target:"String",proto:!0,forced:!MHe&&!KZ},{startsWith:function(e){var r=s8(THe(this));_He(e);var n=CHe(OHe(arguments.length>1?arguments[1]:void 0,r.length)),o=s8(e);return kHe(r,n,n+o.length)===o}});var RHe=A,jHe=V,DHe=St,a8=Et,LHe=Ee,NHe=jHe("".slice),FHe=Math.max,BHe=Math.min,UHe=!"".substr||"ab".substr(-1)!=="b";RHe({target:"String",proto:!0,forced:UHe},{substr:function(e,r){var n=LHe(DHe(this)),o=n.length,i=a8(e),s,a;return i===1/0&&(i=0),i<0&&(i=FHe(o+i,0)),s=r===void 0?o:a8(r),s<=0||s===1/0?"":(a=BHe(i+s,o),i>=a?"":NHe(n,i,a))}});var zHe=A,GZ=ne,CM=V,HHe=St,WHe=Ee,KHe=q,GHe=Array,lP=CM("".charAt),l8=CM("".charCodeAt),VHe=CM([].join),YT="".toWellFormed,YHe="�",c8=YT&&KHe(function(){return GZ(YT,1)!=="1"});zHe({target:"String",proto:!0,forced:c8},{toWellFormed:function(){var e=WHe(HHe(this));if(c8)return GZ(YT,e);for(var r=e.length,n=GHe(r),o=0;o<r;o++){var i=l8(e,o);(i&63488)!==55296?n[o]=lP(e,o):i>=56320||o+1>=r||(l8(e,o+1)&64512)!==56320?n[o]=YHe:(n[o]=lP(e,o),n[++o]=lP(e,o))}return VHe(n,"")}});var XHe=Ih.PROPER,qHe=q,u8=Lh,d8="
",_M=function(t){return qHe(function(){return!!u8[t]()||d8[t]()!==d8||XHe&&u8[t].name!==t})},ZHe=A,QHe=Nh.trim,JHe=_M;ZHe({target:"String",proto:!0,forced:JHe("trim")},{trim:function(){return QHe(this)}});var eWe=Nh.end,tWe=_M,VZ=tWe("trimEnd")?function(){return eWe(this)}:"".trimEnd,rWe=A,h8=VZ;rWe({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==h8},{trimRight:h8});var nWe=A,f8=VZ;nWe({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==f8},{trimEnd:f8});var oWe=Nh.start,iWe=_M,YZ=iWe("trimStart")?function(){return oWe(this)}:"".trimStart,sWe=A,p8=YZ;sWe({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==p8},{trimLeft:p8});var aWe=A,g8=YZ;aWe({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==g8},{trimStart:g8});var lWe=V,cWe=St,m8=Ee,uWe=/"/g,dWe=lWe("".replace),Eo=function(t,e,r,n){var o=m8(cWe(t)),i="<"+e;return r!==""&&(i+=" "+r+'="'+dWe(m8(n),uWe,""")+'"'),i+">"+o+"</"+e+">"},hWe=q,Co=function(t){return hWe(function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3})},fWe=A,pWe=Eo,gWe=Co;fWe({target:"String",proto:!0,forced:gWe("anchor")},{anchor:function(e){return pWe(this,"a","name",e)}});var mWe=A,vWe=Eo,yWe=Co;mWe({target:"String",proto:!0,forced:yWe("big")},{big:function(){return vWe(this,"big","","")}});var SWe=A,wWe=Eo,xWe=Co;SWe({target:"String",proto:!0,forced:xWe("blink")},{blink:function(){return wWe(this,"blink","","")}});var bWe=A,$We=Eo,IWe=Co;bWe({target:"String",proto:!0,forced:IWe("bold")},{bold:function(){return $We(this,"b","","")}});var PWe=A,EWe=Eo,CWe=Co;PWe({target:"String",proto:!0,forced:CWe("fixed")},{fixed:function(){return EWe(this,"tt","","")}});var _We=A,TWe=Eo,AWe=Co;_We({target:"String",proto:!0,forced:AWe("fontcolor")},{fontcolor:function(e){return TWe(this,"font","color",e)}});var kWe=A,OWe=Eo,MWe=Co;kWe({target:"String",proto:!0,forced:MWe("fontsize")},{fontsize:function(e){return OWe(this,"font","size",e)}});var RWe=A,jWe=Eo,DWe=Co;RWe({target:"String",proto:!0,forced:DWe("italics")},{italics:function(){return jWe(this,"i","","")}});var LWe=A,NWe=Eo,FWe=Co;LWe({target:"String",proto:!0,forced:FWe("link")},{link:function(e){return NWe(this,"a","href",e)}});var BWe=A,UWe=Eo,zWe=Co;BWe({target:"String",proto:!0,forced:zWe("small")},{small:function(){return UWe(this,"small","","")}});var HWe=A,WWe=Eo,KWe=Co;HWe({target:"String",proto:!0,forced:KWe("strike")},{strike:function(){return WWe(this,"strike","","")}});var GWe=A,VWe=Eo,YWe=Co;GWe({target:"String",proto:!0,forced:YWe("sub")},{sub:function(){return VWe(this,"sub","","")}});var XWe=A,qWe=Eo,ZWe=Co;XWe({target:"String",proto:!0,forced:ZWe("sup")},{sup:function(){return qWe(this,"sup","","")}});var XT={exports:{}},XZ=te,cP=q,QWe=l1,JWe=Oe.NATIVE_ARRAY_BUFFER_VIEWS,eKe=XZ.ArrayBuffer,lc=XZ.Int8Array,TM=!JWe||!cP(function(){lc(1)})||!cP(function(){new lc(-1)})||!QWe(function(t){new lc,new lc(null),new lc(1.5),new lc(t)},!0)||cP(function(){return new lc(new eKe(2),1,void 0).length!==1}),tKe=Et,rKe=RangeError,vm=function(t){var e=tKe(t);if(e<0)throw new rKe("The argument can't be less than 0");return e},nKe=vm,oKe=RangeError,qZ=function(t,e){var r=nKe(t);if(r%e)throw new oKe("Wrong offset");return r},iKe=Math.round,ZZ=function(t){var e=iKe(t);return e<0?0:e>255?255:e&255},sKe=bo,AM=function(t){var e=sKe(t);return e==="BigInt64Array"||e==="BigUint64Array"},aKe=Ax,lKe=TypeError,T1=function(t){var e=aKe(t,"number");if(typeof e=="number")throw new lKe("Can't convert number to bigint");return BigInt(e)},cKe=dt,uKe=ne,dKe=m1,hKe=je,fKe=Ke,pKe=su,gKe=Bl,mKe=TO,vKe=AM,yKe=Oe.aTypedArrayConstructor,SKe=T1,QZ=function(e){var r=dKe(this),n=hKe(e),o=arguments.length,i=o>1?arguments[1]:void 0,s=i!==void 0,a=gKe(n),l,c,u,d,f,p,g,m;if(a&&!mKe(a))for(g=pKe(n,a),m=g.next,n=[];!(p=uKe(m,g)).done;)n.push(p.value);for(s&&o>2&&(i=cKe(i,arguments[2])),c=fKe(n),u=new(yKe(r))(c),d=vKe(u),l=0;c>l;l++)f=s?i(n[l],l):n[l],u[l]=d?SKe(f):+f;return u},v8=A,JZ=te,y8=ne,wKe=ge,xKe=TM,ym=Oe,eQ=f1,S8=wn,bKe=wo,_f=sr,$Ke=dM,IKe=xo,w8=um,uP=qZ,PKe=ZZ,tQ=ga,Tf=ke,EKe=bo,qT=Ie,CKe=Rl,_Ke=ar,TKe=rn,Jv=_i,AKe=Dl.f,x8=QZ,kKe=Jt.forEach,OKe=lu,MKe=Ct,rQ=ut,nQ=vr,b8=zl,kM=et,RKe=ou,ZT=kM.get,jKe=kM.set,DKe=kM.enforce,oQ=rQ.f,LKe=nQ.f,dP=JZ.RangeError,iQ=eQ.ArrayBuffer,NKe=iQ.prototype,FKe=eQ.DataView,ey=ym.NATIVE_ARRAY_BUFFER_VIEWS,$8=ym.TYPED_ARRAY_TAG,I8=ym.TypedArray,Af=ym.TypedArrayPrototype,QT=ym.isTypedArray,ty="BYTES_PER_ELEMENT",hP="Wrong length",ry=function(t,e){MKe(t,e,{configurable:!0,get:function(){return ZT(this)[e]}})},P8=function(t){var e;return TKe(NKe,t)||(e=EKe(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},sQ=function(t,e){return QT(t)&&!CKe(e)&&e in t&&$Ke(+e)&&e>=0},E8=function(e,r){return r=tQ(r),sQ(e,r)?bKe(2,e[r]):LKe(e,r)},C8=function(e,r,n){return r=tQ(r),sQ(e,r)&&qT(n)&&Tf(n,"value")&&!Tf(n,"get")&&!Tf(n,"set")&&!n.configurable&&(!Tf(n,"writable")||n.writable)&&(!Tf(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):oQ(e,r,n)};wKe?(ey||(nQ.f=E8,rQ.f=C8,ry(Af,"buffer"),ry(Af,"byteOffset"),ry(Af,"byteLength"),ry(Af,"length")),v8({target:"Object",stat:!0,forced:!ey},{getOwnPropertyDescriptor:E8,defineProperty:C8}),XT.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,o=t+(r?"Clamped":"")+"Array",i="get"+t,s="set"+t,a=JZ[o],l=a,c=l&&l.prototype,u={},d=function(m,S){var y=ZT(m);return y.view[i](S*n+y.byteOffset,!0)},f=function(m,S,y){var v=ZT(m);v.view[s](S*n+v.byteOffset,r?PKe(y):y,!0)},p=function(m,S){oQ(m,S,{get:function(){return d(this,S)},set:function(y){return f(this,S,y)},enumerable:!0})};ey?xKe&&(l=e(function(m,S,y,v){return S8(m,c),RKe(function(){return qT(S)?P8(S)?v!==void 0?new a(S,uP(y,n),v):y!==void 0?new a(S,uP(y,n)):new a(S):QT(S)?b8(l,S):y8(x8,l,S):new a(w8(S))}(),m,l)}),Jv&&Jv(l,I8),kKe(AKe(a),function(m){m in l||_f(l,m,a[m])}),l.prototype=c):(l=e(function(m,S,y,v){S8(m,c);var b=0,$=0,P,E,T;if(!qT(S))T=w8(S),E=T*n,P=new iQ(E);else if(P8(S)){P=S,$=uP(y,n);var I=S.byteLength;if(v===void 0){if(I%n)throw new dP(hP);if(E=I-$,E<0)throw new dP(hP)}else if(E=IKe(v)*n,E+$>I)throw new dP(hP);T=E/n}else return QT(S)?b8(l,S):y8(x8,l,S);for(jKe(m,{buffer:P,byteOffset:$,byteLength:E,length:T,view:new FKe(P)});b<T;)p(m,b++)}),Jv&&Jv(l,I8),c=l.prototype=_Ke(Af)),c.constructor!==l&&_f(c,"constructor",l),DKe(c).TypedArrayConstructor=l,$8&&_f(c,$8,o);var g=l!==a;u[o]=l,v8({global:!0,constructor:!0,forced:g,sham:!ey},u),ty in l||_f(l,ty,n),ty in c||_f(c,ty,n),OKe(o)}):XT.exports=function(){};var ya=XT.exports,BKe=ya;BKe("Float32",function(t){return function(r,n,o){return t(this,r,n,o)}});var UKe=ya;UKe("Float64",function(t){return function(r,n,o){return t(this,r,n,o)}});var zKe=ya;zKe("Int8",function(t){return function(r,n,o){return t(this,r,n,o)}});var HKe=ya;HKe("Int16",function(t){return function(r,n,o){return t(this,r,n,o)}});var WKe=ya;WKe("Int32",function(t){return function(r,n,o){return t(this,r,n,o)}});var KKe=ya;KKe("Uint8",function(t){return function(r,n,o){return t(this,r,n,o)}});var GKe=ya;GKe("Uint8",function(t){return function(r,n,o){return t(this,r,n,o)}},!0);var VKe=ya;VKe("Uint16",function(t){return function(r,n,o){return t(this,r,n,o)}});var YKe=ya;YKe("Uint32",function(t){return function(r,n,o){return t(this,r,n,o)}});var aQ=Oe,XKe=Ke,qKe=Et,ZKe=aQ.aTypedArray,QKe=aQ.exportTypedArrayMethod;QKe("at",function(e){var r=ZKe(this),n=XKe(r),o=qKe(e),i=o>=0?o:n+o;return i<0||i>=n?void 0:r[i]});var JKe=V,lQ=Oe,eGe=GY,tGe=JKe(eGe),rGe=lQ.aTypedArray,nGe=lQ.exportTypedArrayMethod;nGe("copyWithin",function(e,r){return tGe(rGe(this),e,r,arguments.length>2?arguments[2]:void 0)});var cQ=Oe,oGe=Jt.every,iGe=cQ.aTypedArray,sGe=cQ.exportTypedArrayMethod;sGe("every",function(e){return oGe(iGe(this),e,arguments.length>1?arguments[1]:void 0)});var uQ=Oe,aGe=kO,lGe=T1,cGe=bo,uGe=ne,dGe=V,hGe=q,fGe=uQ.aTypedArray,pGe=uQ.exportTypedArrayMethod,gGe=dGe("".slice),mGe=hGe(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});pGe("fill",function(e){var r=arguments.length;fGe(this);var n=gGe(cGe(this),0,3)==="Big"?lGe(e):+e;return uGe(aGe,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},mGe);var dQ=Oe,vGe=Dh,yGe=dQ.aTypedArrayConstructor,SGe=dQ.getTypedArrayConstructor,Sm=function(t){return yGe(vGe(t,SGe(t)))},wGe=zl,xGe=Sm,OM=function(t,e){return wGe(xGe(t),e)},hQ=Oe,bGe=Jt.filter,$Ge=OM,IGe=hQ.aTypedArray,PGe=hQ.exportTypedArrayMethod;PGe("filter",function(e){var r=bGe(IGe(this),e,arguments.length>1?arguments[1]:void 0);return $Ge(this,r)});var fQ=Oe,EGe=Jt.find,CGe=fQ.aTypedArray,_Ge=fQ.exportTypedArrayMethod;_Ge("find",function(e){return EGe(CGe(this),e,arguments.length>1?arguments[1]:void 0)});var pQ=Oe,TGe=Jt.findIndex,AGe=pQ.aTypedArray,kGe=pQ.exportTypedArrayMethod;kGe("findIndex",function(e){return TGe(AGe(this),e,arguments.length>1?arguments[1]:void 0)});var gQ=Oe,OGe=a1.findLast,MGe=gQ.aTypedArray,RGe=gQ.exportTypedArrayMethod;RGe("findLast",function(e){return OGe(MGe(this),e,arguments.length>1?arguments[1]:void 0)});var mQ=Oe,jGe=a1.findLastIndex,DGe=mQ.aTypedArray,LGe=mQ.exportTypedArrayMethod;LGe("findLastIndex",function(e){return jGe(DGe(this),e,arguments.length>1?arguments[1]:void 0)});var vQ=Oe,NGe=Jt.forEach,FGe=vQ.aTypedArray,BGe=vQ.exportTypedArrayMethod;BGe("forEach",function(e){NGe(FGe(this),e,arguments.length>1?arguments[1]:void 0)});var UGe=TM,zGe=Oe.exportTypedArrayStaticMethod,HGe=QZ;zGe("from",HGe,UGe);var yQ=Oe,WGe=Kg.includes,KGe=yQ.aTypedArray,GGe=yQ.exportTypedArrayMethod;GGe("includes",function(e){return WGe(KGe(this),e,arguments.length>1?arguments[1]:void 0)});var SQ=Oe,VGe=Kg.indexOf,YGe=SQ.aTypedArray,XGe=SQ.exportTypedArrayMethod;XGe("indexOf",function(e){return VGe(YGe(this),e,arguments.length>1?arguments[1]:void 0)});var qGe=te,ZGe=q,MM=V,wQ=Oe,RM=iX,QGe=ve,jM=QGe("iterator"),_8=qGe.Uint8Array,JGe=MM(RM.values),eVe=MM(RM.keys),tVe=MM(RM.entries),DM=wQ.aTypedArray,A1=wQ.exportTypedArrayMethod,Hu=_8&&_8.prototype,k1=!ZGe(function(){Hu[jM].call([1])}),xQ=!!Hu&&Hu.values&&Hu[jM]===Hu.values&&Hu.values.name==="values",bQ=function(){return JGe(DM(this))};A1("entries",function(){return tVe(DM(this))},k1);A1("keys",function(){return eVe(DM(this))},k1);A1("values",bQ,k1||!xQ,{name:"values"});A1(jM,bQ,k1||!xQ,{name:"values"});var $Q=Oe,rVe=V,nVe=$Q.aTypedArray,oVe=$Q.exportTypedArrayMethod,iVe=rVe([].join);oVe("join",function(e){return iVe(nVe(this),e)});var IQ=Oe,sVe=yn,aVe=aX,lVe=IQ.aTypedArray,cVe=IQ.exportTypedArrayMethod;cVe("lastIndexOf",function(e){var r=arguments.length;return sVe(aVe,lVe(this),r>1?[e,arguments[1]]:[e])});var PQ=Oe,uVe=Jt.map,dVe=Sm,hVe=PQ.aTypedArray,fVe=PQ.exportTypedArrayMethod;fVe("map",function(e){return uVe(hVe(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(dVe(r))(n)})});var EQ=Oe,pVe=TM,gVe=EQ.aTypedArrayConstructor,mVe=EQ.exportTypedArrayStaticMethod;mVe("of",function(){for(var e=0,r=arguments.length,n=new(gVe(this))(r);r>e;)n[e]=arguments[e++];return n},pVe);var CQ=Oe,vVe=c1.left,yVe=CQ.aTypedArray,SVe=CQ.exportTypedArrayMethod;SVe("reduce",function(e){var r=arguments.length;return vVe(yVe(this),e,r,r>1?arguments[1]:void 0)});var _Q=Oe,wVe=c1.right,xVe=_Q.aTypedArray,bVe=_Q.exportTypedArrayMethod;bVe("reduceRight",function(e){var r=arguments.length;return wVe(xVe(this),e,r,r>1?arguments[1]:void 0)});var TQ=Oe,$Ve=TQ.aTypedArray,IVe=TQ.exportTypedArrayMethod,PVe=Math.floor;IVe("reverse",function(){for(var e=this,r=$Ve(e).length,n=PVe(r/2),o=0,i;o<n;)i=e[o],e[o++]=e[--r],e[r]=i;return e});var AQ=te,kQ=ne,LM=Oe,EVe=Ke,CVe=qZ,_Ve=je,OQ=q,TVe=AQ.RangeError,JT=AQ.Int8Array,T8=JT&&JT.prototype,MQ=T8&&T8.set,AVe=LM.aTypedArray,kVe=LM.exportTypedArrayMethod,e2=!OQ(function(){var t=new Uint8ClampedArray(2);return kQ(MQ,t,{length:1,0:3},1),t[1]!==3}),OVe=e2&&LM.NATIVE_ARRAY_BUFFER_VIEWS&&OQ(function(){var t=new JT(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});kVe("set",function(e){AVe(this);var r=CVe(arguments.length>1?arguments[1]:void 0,1),n=_Ve(e);if(e2)return kQ(MQ,this,n,r);var o=this.length,i=EVe(n),s=0;if(i+r>o)throw new TVe("Wrong length");for(;s<i;)this[r+s]=n[s++]},!e2||OVe);var RQ=Oe,MVe=Sm,RVe=q,jVe=Io,DVe=RQ.aTypedArray,LVe=RQ.exportTypedArrayMethod,NVe=RVe(function(){new Int8Array(1).slice()});LVe("slice",function(e,r){for(var n=jVe(DVe(this),e,r),o=MVe(this),i=0,s=n.length,a=new o(s);s>i;)a[i]=n[i++];return a},NVe);var jQ=Oe,FVe=Jt.some,BVe=jQ.aTypedArray,UVe=jQ.exportTypedArrayMethod;UVe("some",function(e){return FVe(BVe(this),e,arguments.length>1?arguments[1]:void 0)});var zVe=te,HVe=Ll,t2=q,WVe=Pe,KVe=DO,DQ=Oe,A8=cX,GVe=uX,k8=pa,O8=LO,VVe=DQ.aTypedArray,YVe=DQ.exportTypedArrayMethod,bg=zVe.Uint16Array,jd=bg&&HVe(bg.prototype.sort),XVe=!!jd&&!(t2(function(){jd(new bg(2),null)})&&t2(function(){jd(new bg(2),{})})),M8=!!jd&&!t2(function(){if(k8)return k8<74;if(A8)return A8<67;if(GVe)return!0;if(O8)return O8<602;var t=new bg(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(jd(t,function(o,i){return(o/4|0)-(i/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),qVe=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};YVe("sort",function(e){return e!==void 0&&WVe(e),M8?jd(this,e):KVe(VVe(this),qVe(e))},!M8||XVe);var LQ=Oe,ZVe=xo,R8=ms,QVe=Sm,JVe=LQ.aTypedArray,eYe=LQ.exportTypedArrayMethod;eYe("subarray",function(e,r){var n=JVe(this),o=n.length,i=R8(e,o),s=QVe(n);return new s(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,ZVe((r===void 0?o:R8(r,o))-i))});var tYe=te,rYe=yn,NQ=Oe,r2=q,j8=Io,E0=tYe.Int8Array,D8=NQ.aTypedArray,nYe=NQ.exportTypedArrayMethod,FQ=[].toLocaleString,oYe=!!E0&&r2(function(){FQ.call(new E0(1))}),iYe=r2(function(){return[1,2].toLocaleString()!==new E0([1,2]).toLocaleString()})||!r2(function(){E0.prototype.toLocaleString.call([1,2])});nYe("toLocaleString",function(){return rYe(FQ,oYe?j8(D8(this)):D8(this),j8(arguments))},iYe);var sYe=fX,NM=Oe,aYe=NM.aTypedArray,lYe=NM.exportTypedArrayMethod,cYe=NM.getTypedArrayConstructor;lYe("toReversed",function(){return sYe(aYe(this),cYe(this))});var O1=Oe,uYe=V,dYe=Pe,hYe=zl,fYe=O1.aTypedArray,pYe=O1.getTypedArrayConstructor,gYe=O1.exportTypedArrayMethod,mYe=uYe(O1.TypedArrayPrototype.sort);gYe("toSorted",function(e){e!==void 0&&dYe(e);var r=fYe(this),n=hYe(pYe(r),r);return mYe(n,e)});var vYe=Oe.exportTypedArrayMethod,yYe=q,SYe=te,wYe=V,L8=SYe.Uint8Array,xYe=L8&&L8.prototype||{},C0=[].toString,bYe=wYe([].join);yYe(function(){C0.call({})})&&(C0=function(){return bYe(this)});var $Ye=xYe.toString!==C0;vYe("toString",C0,$Ye);var IYe=gX,FM=Oe,PYe=AM,EYe=Et,CYe=T1,_Ye=FM.aTypedArray,TYe=FM.getTypedArrayConstructor,AYe=FM.exportTypedArrayMethod,kYe=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return t===8}}();AYe("with",function(t,e){var r=_Ye(this),n=EYe(t),o=PYe(r)?CYe(e):+e;return IYe(r,TYe(r),n,o)},!kYe);var OYe=A,BM=V,MYe=Ee,N8=String.fromCharCode,F8=BM("".charAt),B8=BM(/./.exec),U8=BM("".slice),RYe=/^[\da-f]{2}$/i,jYe=/^[\da-f]{4}$/i;OYe({global:!0},{unescape:function(e){for(var r=MYe(e),n="",o=r.length,i=0,s,a;i<o;){if(s=F8(r,i++),s==="%"){if(F8(r,i)==="u"){if(a=U8(r,i+1,i+5),B8(jYe,a)){n+=N8(parseInt(a,16)),i+=5;continue}}else if(a=U8(r,i,i+2),B8(RYe,a)){n+=N8(parseInt(a,16)),i+=2;continue}}n+=s}return n}});var DYe=V,z8=ki,ny=cu.getWeakData,LYe=wn,NYe=re,FYe=nr,fP=Ie,BYe=zt,BQ=Jt,H8=ke,UQ=et,UYe=UQ.set,zYe=UQ.getterFor,HYe=BQ.find,WYe=BQ.findIndex,KYe=DYe([].splice),GYe=0,oy=function(t){return t.frozen||(t.frozen=new zQ)},zQ=function(){this.entries=[]},pP=function(t,e){return HYe(t.entries,function(r){return r[0]===e})};zQ.prototype={get:function(t){var e=pP(this,t);if(e)return e[1]},has:function(t){return!!pP(this,t)},set:function(t,e){var r=pP(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=WYe(this.entries,function(r){return r[0]===t});return~e&&KYe(this.entries,e,1),!!~e}};var HQ={getConstructor:function(t,e,r,n){var o=t(function(l,c){LYe(l,i),UYe(l,{type:e,id:GYe++,frozen:null}),FYe(c)||BYe(c,l[n],{that:l,AS_ENTRIES:r})}),i=o.prototype,s=zYe(e),a=function(l,c,u){var d=s(l),f=ny(NYe(c),!0);return f===!0?oy(d).set(c,u):f[d.id]=u,l};return z8(i,{delete:function(l){var c=s(this);if(!fP(l))return!1;var u=ny(l);return u===!0?oy(c).delete(l):u&&H8(u,c.id)&&delete u[c.id]},has:function(c){var u=s(this);if(!fP(c))return!1;var d=ny(c);return d===!0?oy(u).has(c):d&&H8(d,u.id)}}),z8(i,r?{get:function(c){var u=s(this);if(fP(c)){var d=ny(c);if(d===!0)return oy(u).get(c);if(d)return d[u.id]}},set:function(c,u){return a(this,c,u)}}:{add:function(c){return a(this,c,!0)}}),o}},VYe=Wl,W8=te,_S=V,K8=ki,YYe=cu,XYe=S1,WQ=HQ,iy=Ie,sy=et.enforce,qYe=q,ZYe=qK,wm=Object,QYe=Array.isArray,ay=wm.isExtensible,KQ=wm.isFrozen,JYe=wm.isSealed,GQ=wm.freeze,eXe=wm.seal,tXe=!W8.ActiveXObject&&"ActiveXObject"in W8,kf,VQ=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},YQ=XYe("WeakMap",VQ,WQ),Wu=YQ.prototype,TS=_S(Wu.set),rXe=function(){return VYe&&qYe(function(){var t=GQ([]);return TS(new YQ,t,1),!KQ(t)})};if(ZYe)if(tXe){kf=WQ.getConstructor(VQ,"WeakMap",!0),YYe.enable();var G8=_S(Wu.delete),ly=_S(Wu.has),V8=_S(Wu.get);K8(Wu,{delete:function(t){if(iy(t)&&!ay(t)){var e=sy(this);return e.frozen||(e.frozen=new kf),G8(this,t)||e.frozen.delete(t)}return G8(this,t)},has:function(e){if(iy(e)&&!ay(e)){var r=sy(this);return r.frozen||(r.frozen=new kf),ly(this,e)||r.frozen.has(e)}return ly(this,e)},get:function(e){if(iy(e)&&!ay(e)){var r=sy(this);return r.frozen||(r.frozen=new kf),ly(this,e)?V8(this,e):r.frozen.get(e)}return V8(this,e)},set:function(e,r){if(iy(e)&&!ay(e)){var n=sy(this);n.frozen||(n.frozen=new kf),ly(this,e)?TS(this,e,r):n.frozen.set(e,r)}else TS(this,e,r);return this}})}else rXe()&&K8(Wu,{set:function(e,r){var n;return QYe(e)&&(KQ(e)?n=GQ:JYe(e)&&(n=eXe)),TS(this,e,r),n&&n(e),this}});var nXe=S1,oXe=HQ;nXe("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},oXe);var iXe=A,sXe=te,aXe=rn,Y8=lr,_0=_i,lXe=Ph,XQ=ar,cy=sr,gP=wo,cXe=EO,uXe=kh,dXe=ve,hXe=q,fXe=ir,nh=sXe.SuppressedError,pXe=dXe("toStringTag"),T0=Error,gXe=!!nh&&nh.length!==3,mXe=!!nh&&hXe(function(){return new nh(1,2,3,{cause:4}).cause===4}),M1=gXe||mXe,zc=function(e,r,n){var o=aXe(rp,this),i;return _0?i=M1&&(!o||Y8(this)===rp)?new nh:_0(new T0,o?Y8(this):rp):(i=o?this:XQ(rp),cy(i,pXe,"Error")),n!==void 0&&cy(i,"message",uXe(n)),cXe(i,zc,i.stack,1),cy(i,"error",e),cy(i,"suppressed",r),i};_0?_0(zc,T0):lXe(zc,T0,{name:!0});var rp=zc.prototype=M1?nh.prototype:XQ(T0.prototype,{constructor:gP(1,zc),message:gP(1,""),name:gP(1,"SuppressedError")});M1&&!fXe&&(rp.constructor=zc);iXe({global:!0,constructor:!0,arity:3,forced:M1},{SuppressedError:zc});var qQ=te,ZQ=Tx,QQ=Ce,uy=lr,vXe=nt,yXe=ve,X8="USE_FUNCTION_CONSTRUCTOR",q8=yXe("asyncIterator"),Z8=qQ.AsyncIterator,Q8=ZQ.AsyncIteratorPrototype,pl,mP;if(Q8)pl=Q8;else if(QQ(Z8))pl=Z8.prototype;else if(ZQ[X8]||qQ[X8])try{mP=uy(uy(uy(Function("return async function*(){}()")()))),uy(mP)===Object.prototype&&(pl=mP)}catch{}pl||(pl={});QQ(pl[q8])||vXe(pl,q8,function(){return this});var xm=pl,J8=ne,eB=re,SXe=ar,wXe=Qt,xXe=ki,JQ=et,bXe=be,$Xe=xm,eJ=Nr,n2=bXe("Promise"),tJ="AsyncFromSyncIterator",IXe=JQ.set,tB=JQ.getterFor(tJ),rB=function(t,e,r){var n=t.done;n2.resolve(t.value).then(function(o){e(eJ(o,n))},r)},rJ=function(e){e.type=tJ,IXe(this,e)};rJ.prototype=xXe(SXe($Xe),{next:function(){var e=tB(this);return new n2(function(r,n){var o=eB(J8(e.next,e.iterator));rB(o,r,n)})},return:function(){var t=tB(this).iterator;return new n2(function(e,r){var n=wXe(t,"return");if(n===void 0)return e(eJ(void 0,!0));var o=eB(J8(n,t));rB(o,e,r)})}});var R1=rJ,PXe=ne,EXe=R1,CXe=re,_Xe=su,TXe=kt,AXe=Qt,kXe=ve,OXe=kXe("asyncIterator"),MXe=function(t,e){var r=arguments.length<2?AXe(t,OXe):e;return r?CXe(PXe(r,t)):new EXe(TXe(_Xe(t)))},RXe=ne,jXe=be,DXe=Qt,bm=function(t,e,r,n){try{var o=DXe(t,"return");if(o)return jXe("Promise").resolve(RXe(o,t)).then(function(){e(r)},function(i){n(i)})}catch(i){return n(i)}e(r)},LXe=ne,NXe=Pe,vP=re,FXe=Ie,BXe=nu,UXe=be,zXe=kt,yP=bm,Of=function(t){var e=t===0,r=t===1,n=t===2,o=t===3;return function(i,s,a){vP(i);var l=s!==void 0;(l||!e)&&NXe(s);var c=zXe(i),u=UXe("Promise"),d=c.iterator,f=c.next,p=0;return new u(function(g,m){var S=function(v){yP(d,m,v,m)},y=function(){try{if(l)try{BXe(p)}catch(v){S(v)}u.resolve(vP(LXe(f,d))).then(function(v){try{if(vP(v).done)e?(a.length=p,g(a)):g(o?!1:n||void 0);else{var b=v.value;try{if(l){var $=s(b,p),P=function(E){if(r)y();else if(n)E?y():yP(d,g,!1,m);else if(e)try{a[p++]=E,y()}catch(T){S(T)}else E?yP(d,g,o||b,m):y()};FXe($)?u.resolve($).then(P,S):P($)}else a[p++]=b,y()}catch(E){S(E)}}}catch(E){m(E)}},m)}catch(v){m(v)}};y()})}},Fh={toArray:Of(0),forEach:Of(1),every:Of(2),some:Of(3),find:Of(4)},HXe=dt,nJ=V,WXe=je,KXe=ys,GXe=MXe,VXe=su,YXe=kt,XXe=Bl,qXe=Qt,ZXe=be,QXe=pX,JXe=ve,eqe=R1,tqe=Fh.toArray,rqe=JXe("asyncIterator"),oJ=nJ(QXe("Array","values")),nqe=nJ(oJ([]).next),oqe=function(){return new iJ(this)},iJ=function(t){this.iterator=oJ(t)};iJ.prototype.next=function(){return nqe(this.iterator)};var sJ=function(e){var r=this,n=arguments.length,o=n>1?arguments[1]:void 0,i=n>2?arguments[2]:void 0;return new(ZXe("Promise"))(function(s){var a=WXe(e);o!==void 0&&(o=HXe(o,i));var l=qXe(a,rqe),c=l?void 0:XXe(a)||oqe,u=KXe(r)?new r:[],d=l?GXe(a,l):new eqe(YXe(VXe(a,c)));s(tqe(d,o,u))})},iqe=A,sqe=sJ,aqe=q,nB=Array.fromAsync,lqe=!nB||aqe(function(){var t=0;return nB.call(function(){return t++,[]},{length:0}),t!==1});iqe({target:"Array",stat:!0,forced:lqe},{fromAsync:sqe});var cqe=A,uqe=Jt.filterReject,dqe=Bt;cqe({target:"Array",proto:!0,forced:!0},{filterOut:function(e){return uqe(this,e,arguments.length>1?arguments[1]:void 0)}});dqe("filterOut");var hqe=A,fqe=Jt.filterReject,pqe=Bt;hqe({target:"Array",proto:!0,forced:!0},{filterReject:function(e){return fqe(this,e,arguments.length>1?arguments[1]:void 0)}});pqe("filterReject");var gqe=dt,mqe=V,vqe=Ml,yqe=je,Sqe=ga,wqe=Ke,xqe=ar,bqe=zl,$qe=Array,Iqe=mqe([].push),UM=function(t,e,r,n){for(var o=yqe(t),i=vqe(o),s=gqe(e,r),a=xqe(null),l=wqe(i),c=0,u,d,f;l>c;c++)f=i[c],d=Sqe(s(f,c,o)),d in a?Iqe(a[d],f):a[d]=[f];if(n&&(u=n(o),u!==$qe))for(d in a)a[d]=bqe(u,a[d]);return a},Pqe=A,Eqe=UM,Cqe=Bt;Pqe({target:"Array",proto:!0},{group:function(e){var r=arguments.length>1?arguments[1]:void 0;return Eqe(this,e,r)}});Cqe("group");var _qe=A,Tqe=UM,Aqe=Ai,kqe=Bt;_qe({target:"Array",proto:!0,forced:!Aqe("groupBy")},{groupBy:function(e){var r=arguments.length>1?arguments[1]:void 0;return Tqe(this,e,r)}});kqe("groupBy");var Oqe=dt,Mqe=V,Rqe=Ml,jqe=je,Dqe=Ke,j1=nn,Lqe=j1.Map,Nqe=j1.get,Fqe=j1.has,Bqe=j1.set,Uqe=Mqe([].push),aJ=function(e){for(var r=jqe(this),n=Rqe(r),o=Oqe(e,arguments.length>1?arguments[1]:void 0),i=new Lqe,s=Dqe(n),a=0,l,c;s>a;a++)c=n[a],l=o(c,a,r),Fqe(i,l)?Uqe(Nqe(i,l),c):Bqe(i,l,[c]);return i},zqe=A,Hqe=Ai,Wqe=Bt,Kqe=aJ;zqe({target:"Array",proto:!0,name:"groupToMap",forced:!Hqe("groupByToMap")},{groupByToMap:Kqe});Wqe("groupByToMap");var Gqe=A,Vqe=Bt,Yqe=aJ,Xqe=ir;Gqe({target:"Array",proto:!0,forced:Xqe},{groupToMap:Yqe});Vqe("groupToMap");var qqe=A,Zqe=vs,oB=Object.isFrozen,iB=function(t,e){if(!oB||!Zqe(t)||!oB(t))return!1;for(var r=0,n=t.length,o;r<n;)if(o=t[r++],!(typeof o=="string"||e&&o===void 0))return!1;return n!==0};qqe({target:"Array",stat:!0,sham:!0,forced:!0},{isTemplateObject:function(e){if(!iB(e,!0))return!1;var r=e.raw;return r.length===e.length&&iB(r,!1)}});var Qqe=ge,Jqe=Bt,eZe=je,tZe=Ke,rZe=Ct;Qqe&&(rZe(Array.prototype,"lastIndex",{configurable:!0,get:function(){var e=eZe(this),r=tZe(e);return r===0?0:r-1}}),Jqe("lastIndex"));var nZe=ge,oZe=Bt,sB=je,aB=Ke,iZe=Ct;nZe&&(iZe(Array.prototype,"lastItem",{configurable:!0,get:function(){var e=sB(this),r=aB(e);return r===0?void 0:e[r-1]},set:function(e){var r=sB(this),n=aB(r);return r[n===0?0:n-1]=e}}),oZe("lastItem"));var lJ=V,sZe=Kl,cJ=nn,aZe=cJ.Map,uJ=cJ.proto,lZe=lJ(uJ.forEach),dJ=lJ(uJ.entries),cZe=dJ(new aZe).next,Oi=function(t,e,r){return r?sZe({iterator:dJ(t),next:cZe},function(n){return e(n[1],n[0])}):lZe(t,e)},uZe=V,dZe=Pe,hZe=nr,fZe=Ke,pZe=je,zM=nn,gZe=Oi,mZe=zM.Map,vZe=zM.has,yZe=zM.set,SZe=uZe([].push),HM=function(e){var r=pZe(this),n=fZe(r),o=[],i=new mZe,s=hZe(e)?function(u){return u}:dZe(e),a,l,c;for(a=0;a<n;a++)l=r[a],c=s(l),vZe(i,c)||yZe(i,c,l);return gZe(i,function(u){SZe(o,u)}),o},wZe=A,xZe=Bt,bZe=HM;wZe({target:"Array",proto:!0,forced:!0},{uniqueBy:bZe});xZe("uniqueBy");var $Ze=ne,IZe=V,PZe=dt,EZe=re,CZe=Pe,hJ=nr,SP=Qt,fJ=ve,_Ze=fJ("asyncDispose"),lB=fJ("dispose"),TZe=IZe([].push),AZe=function(t,e){if(e==="async-dispose"){var r=SP(t,_Ze);return r!==void 0||(r=SP(t,lB),r===void 0)?r:function(){$Ze(r,this)}}return SP(t,lB)},cB=function(t,e,r){return arguments.length<3&&!hJ(t)&&(r=CZe(AZe(EZe(t),e))),r===void 0?function(){}:PZe(r,t)},pJ=function(t,e,r,n){var o;if(arguments.length<4){if(hJ(e)&&r==="sync-dispose")return;o=cB(e,r)}else o=cB(void 0,r,n);TZe(t.stack,o)},kZe=A,A0=ge,gJ=be,uB=Pe,OZe=wn,mJ=nt,MZe=ki,RZe=Ct,vJ=ve,yJ=et,wP=pJ,dB=gJ("Promise"),jZe=gJ("SuppressedError"),DZe=ReferenceError,LZe=vJ("asyncDispose"),NZe=vJ("toStringTag"),D1="AsyncDisposableStack",FZe=yJ.set,k0=yJ.getterFor(D1),xP="async-dispose",Rp="disposed",BZe="pending",dy=function(t){var e=k0(t);if(e.state===Rp)throw new DZe(D1+" already disposed");return e},WM=function(){FZe(OZe(this,oh),{type:D1,state:BZe,stack:[]}),A0||(this.disposed=!1)},oh=WM.prototype;MZe(oh,{disposeAsync:function(){var e=this;return new dB(function(r,n){var o=k0(e);if(o.state===Rp)return r(void 0);o.state=Rp,A0||(e.disposed=!0);var i=o.stack,s=i.length,a=!1,l,c=function(d){a?l=new jZe(d,l):(a=!0,l=d),u()},u=function(){if(s){var d=i[--s];i[s]=null;try{dB.resolve(d()).then(u,c)}catch(f){c(f)}}else o.stack=null,a?n(l):r(void 0)};u()})},use:function(e){return wP(dy(this),e,xP),e},adopt:function(e,r){var n=dy(this);return uB(r),wP(n,void 0,xP,function(){return r(e)}),e},defer:function(e){var r=dy(this);uB(e),wP(r,void 0,xP,e)},move:function(){var e=dy(this),r=new WM;return k0(r).stack=e.stack,e.stack=[],e.state=Rp,A0||(this.disposed=!0),r}});A0&&RZe(oh,"disposed",{configurable:!0,get:function(){return k0(this).state===Rp}});mJ(oh,LZe,oh.disposeAsync,{name:"disposeAsync"});mJ(oh,NZe,D1,{nonWritable:!0});kZe({global:!0,constructor:!0},{AsyncDisposableStack:WM});var UZe=A,zZe=wn,HZe=lr,SJ=sr,wJ=ke,WZe=ve,gl=xm,KZe=ir,hB=WZe("toStringTag"),GZe=TypeError,KM=function(){if(zZe(this,gl),HZe(this)===gl)throw new GZe("Abstract class AsyncIterator not directly constructable")};KM.prototype=gl;wJ(gl,hB)||SJ(gl,hB,"AsyncIterator");(!wJ(gl,"constructor")||gl.constructor===Object)&&SJ(gl,"constructor",KM);UZe({global:!0,constructor:!0,forced:KZe},{AsyncIterator:KM});var VZe=ne,hy=uu,fB=re,YZe=ar,XZe=sr,qZe=ki,ZZe=ve,xJ=et,QZe=be,JZe=Qt,eQe=xm,bP=Nr,pB=Ul,Bi=QZe("Promise"),tQe=ZZe("toStringTag"),bJ="AsyncIteratorHelper",$J="WrapForValidAsyncIterator",rQe=xJ.set,IJ=function(t){var e=!t,r=xJ.getterFor(t?$J:bJ),n=function(o){var i=hy(function(){return r(o)}),s=i.error,a=i.value;return s||e&&a.done?{exit:!0,value:s?Bi.reject(a):Bi.resolve(bP(void 0,!0))}:{exit:!1,value:a}};return qZe(YZe(eQe),{next:function(){var i=n(this),s=i.value;if(i.exit)return s;var a=hy(function(){return fB(s.nextHandler(Bi))}),l=a.error,c=a.value;return l&&(s.done=!0),l?Bi.reject(c):Bi.resolve(c)},return:function(){var o=n(this),i=o.value;if(o.exit)return i;i.done=!0;var s=i.iterator,a,l,c=hy(function(){if(i.inner)try{pB(i.inner.iterator,"normal")}catch(u){return pB(s,"throw",u)}return JZe(s,"return")});return a=l=c.value,c.error?Bi.reject(l):a===void 0?Bi.resolve(bP(void 0,!0)):(c=hy(function(){return VZe(a,s)}),l=c.value,c.error?Bi.reject(l):t?Bi.resolve(l):Bi.resolve(l).then(function(u){return fB(u),bP(void 0,!0)}))}})},nQe=IJ(!0),PJ=IJ(!1);XZe(PJ,tQe,"Async Iterator Helper");var Bh=function(t,e){var r=function(o,i){i?(i.iterator=o.iterator,i.next=o.next):i=o,i.type=e?$J:bJ,i.nextHandler=t,i.counter=0,i.done=!1,rQe(this,i)};return r.prototype=e?nQe:PJ,r},oQe=ne,iQe=Pe,o2=re,sQe=Ie,aQe=kt,lQe=Bh,gB=Nr,cQe=bm,uQe=lQe(function(t){var e=this,r=e.iterator,n=e.mapper;return new t(function(o,i){var s=function(l){e.done=!0,i(l)},a=function(l){cQe(r,s,l,s)};t.resolve(o2(oQe(e.next,r))).then(function(l){try{if(o2(l).done)e.done=!0,o(gB(void 0,!0));else{var c=l.value;try{var u=n(c,e.counter++),d=function(f){o(gB(f,!1))};sQe(u)?t.resolve(u).then(d,a):d(u)}catch(f){a(f)}}}catch(f){s(f)}},s)})}),EJ=function(e){return o2(this),iQe(e),new uQe(aQe(this),{mapper:e})},dQe=ne,hQe=EJ,fQe=function(t,e){return[e,t]},CJ=function(){return dQe(hQe,this,fQe)},pQe=A,gQe=CJ;pQe({target:"AsyncIterator",name:"indexed",proto:!0,real:!0,forced:!0},{asIndexedPairs:gQe});var mQe=ne,vQe=nt,yQe=be,SQe=Qt,wQe=ke,xQe=ve,mB=xm,vB=xQe("asyncDispose"),yB=yQe("Promise");wQe(mB,vB)||vQe(mB,vB,function(){var t=this;return new yB(function(e,r){var n=SQe(t,"return");n?yB.resolve(mQe(n,t)).then(function(){e(void 0)},r):e(void 0)})});var bQe=RangeError,L1=function(t){if(t===t)return t;throw new bQe("NaN is not allowed")},$Qe=A,IQe=ne,i2=re,PQe=kt,EQe=L1,CQe=vm,_Qe=Bh,SB=Nr,TQe=ir,AQe=_Qe(function(t){var e=this;return new t(function(r,n){var o=function(s){e.done=!0,n(s)},i=function(){try{t.resolve(i2(IQe(e.next,e.iterator))).then(function(s){try{i2(s).done?(e.done=!0,r(SB(void 0,!0))):e.remaining?(e.remaining--,i()):r(SB(s.value,!1))}catch(a){o(a)}},o)}catch(s){o(s)}};i()})});$Qe({target:"AsyncIterator",proto:!0,real:!0,forced:TQe},{drop:function(e){i2(this);var r=CQe(EQe(+e));return new AQe(PQe(this),{remaining:r})}});var kQe=A,OQe=Fh.every;kQe({target:"AsyncIterator",proto:!0,real:!0},{every:function(e){return OQe(this,e)}});var MQe=A,RQe=ne,jQe=Pe,s2=re,DQe=Ie,LQe=kt,NQe=Bh,wB=Nr,FQe=bm,BQe=ir,UQe=NQe(function(t){var e=this,r=e.iterator,n=e.predicate;return new t(function(o,i){var s=function(c){e.done=!0,i(c)},a=function(c){FQe(r,s,c,s)},l=function(){try{t.resolve(s2(RQe(e.next,r))).then(function(c){try{if(s2(c).done)e.done=!0,o(wB(void 0,!0));else{var u=c.value;try{var d=n(u,e.counter++),f=function(p){p?o(wB(u,!1)):l()};DQe(d)?t.resolve(d).then(f,a):f(d)}catch(p){a(p)}}}catch(p){s(p)}},s)}catch(c){s(c)}};l()})});MQe({target:"AsyncIterator",proto:!0,real:!0,forced:BQe},{filter:function(e){return s2(this),jQe(e),new UQe(LQe(this),{predicate:e})}});var zQe=A,HQe=Fh.find;zQe({target:"AsyncIterator",proto:!0,real:!0},{find:function(e){return HQe(this,e)}});var WQe=ne,KQe=Ce,xB=re,bB=kt,GQe=Bl,VQe=Qt,YQe=ve,XQe=R1,qQe=YQe("asyncIterator"),_J=function(t){var e=xB(t),r=!0,n=VQe(e,qQe),o;return KQe(n)||(n=GQe(e),r=!1),n!==void 0?o=WQe(n,e):(o=e,r=!0),xB(o),bB(r?o:new XQe(bB(o)))},ZQe=A,$B=ne,QQe=Pe,np=re,JQe=Ie,eJe=kt,tJe=Bh,IB=Nr,rJe=_J,nJe=bm,oJe=ir,iJe=tJe(function(t){var e=this,r=e.iterator,n=e.mapper;return new t(function(o,i){var s=function(u){e.done=!0,i(u)},a=function(u){nJe(r,s,u,s)},l=function(){try{t.resolve(np($B(e.next,r))).then(function(u){try{if(np(u).done)e.done=!0,o(IB(void 0,!0));else{var d=u.value;try{var f=n(d,e.counter++),p=function(g){try{e.inner=rJe(g),c()}catch(m){a(m)}};JQe(f)?t.resolve(f).then(p,a):p(f)}catch(g){a(g)}}}catch(g){s(g)}},s)}catch(u){s(u)}},c=function(){var u=e.inner;if(u)try{t.resolve(np($B(u.next,u.iterator))).then(function(d){try{np(d).done?(e.inner=null,l()):o(IB(d.value,!1))}catch(f){a(f)}},a)}catch(d){a(d)}else l()};c()})});ZQe({target:"AsyncIterator",proto:!0,real:!0,forced:oJe},{flatMap:function(e){return np(this),QQe(e),new iJe(eJe(this),{mapper:e,inner:null})}});var sJe=A,aJe=Fh.forEach;sJe({target:"AsyncIterator",proto:!0,real:!0},{forEach:function(e){return aJe(this,e)}});var lJe=ne,cJe=Bh,TJ=cJe(function(){return lJe(this.next,this.iterator)},!0),uJe=A,dJe=je,hJe=rn,fJe=_J,pJe=xm,gJe=TJ,mJe=ir;uJe({target:"AsyncIterator",stat:!0,forced:mJe},{from:function(e){var r=fJe(typeof e=="string"?dJe(e):e);return hJe(pJe,r.iterator)?r.iterator:new gJe(r)}});var vJe=A,yJe=CJ;vJe({target:"AsyncIterator",proto:!0,real:!0,forced:!0},{indexed:yJe});var SJe=A,wJe=EJ,xJe=ir;SJe({target:"AsyncIterator",proto:!0,real:!0,forced:xJe},{map:wJe});var bJe=A,$Je=ne,IJe=Pe,$P=re,PJe=Ie,EJe=be,CJe=kt,_Je=bm,IP=EJe("Promise"),TJe=TypeError;bJe({target:"AsyncIterator",proto:!0,real:!0},{reduce:function(e){$P(this),IJe(e);var r=CJe(this),n=r.iterator,o=r.next,i=arguments.length<2,s=i?void 0:arguments[1],a=0;return new IP(function(l,c){var u=function(f){_Je(n,c,f,c)},d=function(){try{IP.resolve($P($Je(o,n))).then(function(f){try{if($P(f).done)i?c(new TJe("Reduce of empty iterator with no initial value")):l(s);else{var p=f.value;if(i)i=!1,s=p,d();else try{var g=e(s,p,a),m=function(S){s=S,d()};PJe(g)?IP.resolve(g).then(m,u):m(g)}catch(S){u(S)}}a++}catch(S){c(S)}},c)}catch(f){c(f)}};d()})}});var AJe=A,kJe=Fh.some;AJe({target:"AsyncIterator",proto:!0,real:!0},{some:function(e){return kJe(this,e)}});var OJe=A,PB=ne,AJ=re,MJe=kt,RJe=L1,jJe=vm,DJe=Bh,PP=Nr,LJe=ir,NJe=DJe(function(t){var e=this,r=e.iterator,n;if(!e.remaining--){var o=PP(void 0,!0);return e.done=!0,n=r.return,n!==void 0?t.resolve(PB(n,r,void 0)).then(function(){return o}):o}return t.resolve(PB(e.next,r)).then(function(i){return AJ(i).done?(e.done=!0,PP(void 0,!0)):PP(i.value,!1)}).then(null,function(i){throw e.done=!0,i})});OJe({target:"AsyncIterator",proto:!0,real:!0,forced:LJe},{take:function(e){AJ(this);var r=jJe(RJe(+e));return new NJe(MJe(this),{remaining:r})}});var FJe=A,BJe=Fh.toArray;FJe({target:"AsyncIterator",proto:!0,real:!0},{toArray:function(){return BJe(this,void 0,[])}});var kJ=et,UJe=au,EP=Nr,zJe=nr,HJe=Ie,WJe=Ct,OJ=ge,Mf="Incorrect Iterator.range arguments",a2="NumericRangeIterator",KJe=kJ.set,MJ=kJ.getterFor(a2),EB=RangeError,CP=TypeError,RJ=UJe(function(e,r,n,o,i,s){if(typeof e!=o||r!==1/0&&r!==-1/0&&typeof r!=o)throw new CP(Mf);if(e===1/0||e===-1/0)throw new EB(Mf);var a=r>e,l=!1,c;if(n===void 0)c=void 0;else if(HJe(n))c=n.step,l=!!n.inclusive;else if(typeof n==o)c=n;else throw new CP(Mf);if(zJe(c)&&(c=a?s:-s),typeof c!=o)throw new CP(Mf);if(c===1/0||c===-1/0||c===i&&e!==r)throw new EB(Mf);var u=e!==e||r!==r||c!==c||r>e!=c>i;KJe(this,{type:a2,start:e,end:r,step:c,inclusive:l,hitsEnd:u,currentCount:i,zero:i}),OJ||(this.start=e,this.end=r,this.step=c,this.inclusive=l)},a2,function(){var e=MJ(this);if(e.hitsEnd)return EP(void 0,!0);var r=e.start,n=e.end,o=e.step,i=r+o*e.currentCount++;i===n&&(e.hitsEnd=!0);var s=e.inclusive,a;return n>r?a=s?i>n:i>=n:a=s?n>i:n>=i,a?(e.hitsEnd=!0,EP(void 0,!0)):EP(i,!1)}),fy=function(t){WJe(RJ.prototype,t,{get:function(){return MJ(this)[t]},set:function(){},configurable:!0,enumerable:!1})};OJ&&(fy("start"),fy("end"),fy("inclusive"),fy("step"));var GM=RJ,GJe=A,VJe=GM;typeof BigInt=="function"&&GJe({target:"BigInt",stat:!0,forced:!0},{range:function(e,r,n){return new VJe(e,r,n,"bigint",BigInt(0),BigInt(1))}});var jJ=be,YJe=ar,CB=Ie,XJe=Object,qJe=TypeError,ZJe=jJ("Map"),QJe=jJ("WeakMap"),O0=function(){this.object=null,this.symbol=null,this.primitives=null,this.objectsByIndex=YJe(null)};O0.prototype.get=function(t,e){return this[t]||(this[t]=e())};O0.prototype.next=function(t,e,r){var n=r?this.objectsByIndex[t]||(this.objectsByIndex[t]=new QJe):this.primitives||(this.primitives=new ZJe),o=n.get(e);return o||n.set(e,o=new O0),o};var _B=new O0,DJ=function(){var t=_B,e=arguments.length,r,n;for(r=0;r<e;r++)CB(n=arguments[r])&&(t=t.next(r,n,!0));if(this===XJe&&t===_B)throw new qJe("Composite keys must contain a non-primitive component");for(r=0;r<e;r++)CB(n=arguments[r])||(t=t.next(r,n,!1));return t},JJe=A,eet=yn,tet=DJ,ret=be,TB=ar,net=Object,oet=function(){var t=ret("Object","freeze");return t?t(TB(null)):TB(null)};JJe({global:!0,forced:!0},{compositeKey:function(){return eet(tet,net,arguments).get("object",oet)}});var iet=A,set=DJ,AB=be,aet=yn;iet({global:!0,forced:!0},{compositeSymbol:function(){return arguments.length===1&&typeof arguments[0]=="string"?AB("Symbol").for(arguments[0]):aet(set,null,arguments).get("symbol",AB("Symbol"))}});var cet=A,uet=V,det=zO.unpack,het=uet(DataView.prototype.getUint16);cet({target:"DataView",proto:!0},{getFloat16:function(e){var r=het(this,e,arguments.length>1?arguments[1]:!1);return det([r&255,r>>8&255],10)}});var fet=A,pet=V,get=pet(DataView.prototype.getUint8);fet({target:"DataView",proto:!0,forced:!0},{getUint8Clamped:function(e){return get(this,e)}});var met=bo,vet=TypeError,LJ=function(t){if(met(t)==="DataView")return t;throw new vet("Argument is not a DataView")},yet=vX,wet=.0009765625,xet=65504,bet=6103515625e-14,NJ=Math.f16round||function(e){return yet(e,wet,xet,bet)},$et=A,Iet=V,Pet=LJ,Eet=um,Cet=zO.pack,_et=NJ,Tet=Iet(DataView.prototype.setUint16);$et({target:"DataView",proto:!0},{setFloat16:function(e,r){Pet(this);var n=Eet(e),o=Cet(_et(r),10,2);return Tet(this,n,o[1]<<8|o[0],arguments.length>2?arguments[2]:!1)}});var Aet=A,ket=V,Oet=LJ,Met=um,Ret=ZZ,jet=ket(DataView.prototype.setUint8);Aet({target:"DataView",proto:!0,forced:!0},{setUint8Clamped:function(e,r){Oet(this);var n=Met(e);return jet(this,n,Ret(r))}});var Det=A,M0=ge,Let=be,kB=Pe,Net=wn,FJ=nt,Fet=ki,Bet=Ct,BJ=ve,UJ=et,_P=pJ,Uet=Let("SuppressedError"),zet=ReferenceError,Het=BJ("dispose"),Wet=BJ("toStringTag"),N1="DisposableStack",Ket=UJ.set,R0=UJ.getterFor(N1),TP="sync-dispose",jp="disposed",Get="pending",py=function(t){var e=R0(t);if(e.state===jp)throw new zet(N1+" already disposed");return e},VM=function(){Ket(Net(this,ih),{type:N1,state:Get,stack:[]}),M0||(this.disposed=!1)},ih=VM.prototype;Fet(ih,{dispose:function(){var e=R0(this);if(e.state!==jp){e.state=jp,M0||(this.disposed=!0);for(var r=e.stack,n=r.length,o=!1,i;n;){var s=r[--n];r[n]=null;try{s()}catch(a){o?i=new Uet(a,i):(o=!0,i=a)}}if(e.stack=null,o)throw i}},use:function(e){return _P(py(this),e,TP),e},adopt:function(e,r){var n=py(this);return kB(r),_P(n,void 0,TP,function(){r(e)}),e},defer:function(e){var r=py(this);kB(e),_P(r,void 0,TP,e)},move:function(){var e=py(this),r=new VM;return R0(r).stack=e.stack,e.stack=[],e.state=jp,M0||(this.disposed=!0),r}});M0&&Bet(ih,"disposed",{configurable:!0,get:function(){return R0(this).state===jp}});FJ(ih,Het,ih.dispose,{name:"dispose"});FJ(ih,Wet,N1,{nonWritable:!0});Det({global:!0,constructor:!0},{DisposableStack:VM});var Vet=V,Yet=Pe,zJ=function(){return Vet(Yet(this))},Xet=A,qet=zJ;Xet({target:"Function",proto:!0,forced:!0},{demethodize:qet});var Zet=A,Qet=V,Jet=Ce,ett=Ox,ttt=ke,rtt=ge,ntt=Object.getOwnPropertyDescriptor,HJ=/^\s*class\b/,ott=Qet(HJ.exec),itt=function(t){try{if(!rtt||!ott(HJ,ett(t)))return!1}catch{}var e=ntt(t,"prototype");return!!e&&ttt(e,"writable")&&!e.writable};Zet({target:"Function",stat:!0,sham:!0,forced:!0},{isCallable:function(e){return Jet(e)&&!itt(e)}});var stt=A,att=ys;stt({target:"Function",stat:!0,forced:!0},{isConstructor:att});var ltt=ve,ctt=ut.f,OB=ltt("metadata"),MB=Function.prototype;MB[OB]===void 0&&ctt(MB,OB,{value:null});var utt=A,dtt=zJ;utt({target:"Function",proto:!0,forced:!0,name:"demethodize"},{unThis:dtt});var htt=A,ftt=te,ptt=wn,gtt=re,mtt=Ce,vtt=lr,ytt=Ct,Stt=Ti,wtt=q,YM=ke,xtt=ve,ss=Mh.IteratorPrototype,btt=ge,AP="constructor",WJ="Iterator",RB=xtt("toStringTag"),KJ=TypeError,kP=ftt[WJ],GJ=!mtt(kP)||kP.prototype!==ss||!wtt(function(){kP({})}),XM=function(){if(ptt(this,ss),vtt(this)===ss)throw new KJ("Abstract class Iterator not directly constructable")},VJ=function(t,e){btt?ytt(ss,t,{configurable:!0,get:function(){return e},set:function(r){if(gtt(this),this===ss)throw new KJ("You can't redefine this property");YM(this,t)?this[t]=r:Stt(this,t,r)}}):ss[t]=e};YM(ss,RB)||VJ(RB,WJ);(GJ||!YM(ss,AP)||ss[AP]===Object)&&VJ(AP,XM);XM.prototype=ss;htt({global:!0,constructor:!0,forced:GJ},{Iterator:XM});var $tt=ne,Itt=ar,Ptt=sr,Ett=ki,Ctt=ve,YJ=et,_tt=Qt,Ttt=Mh.IteratorPrototype,OP=Nr,MP=Ul,Att=Ctt("toStringTag"),XJ="IteratorHelper",qJ="WrapForValidIterator",ktt=YJ.set,ZJ=function(t){var e=YJ.getterFor(t?qJ:XJ);return Ett(Itt(Ttt),{next:function(){var n=e(this);if(t)return n.nextHandler();try{var o=n.done?void 0:n.nextHandler();return OP(o,n.done)}catch(i){throw n.done=!0,i}},return:function(){var r=e(this),n=r.iterator;if(r.done=!0,t){var o=_tt(n,"return");return o?$tt(o,n):OP(void 0,!0)}if(r.inner)try{MP(r.inner.iterator,"normal")}catch(i){return MP(n,"throw",i)}return MP(n,"normal"),OP(void 0,!0)}})},Ott=ZJ(!0),QJ=ZJ(!1);Ptt(QJ,Att,"Iterator Helper");var Uh=function(t,e){var r=function(o,i){i?(i.iterator=o.iterator,i.next=o.next):i=o,i.type=e?qJ:XJ,i.nextHandler=t,i.counter=0,i.done=!1,ktt(this,i)};return r.prototype=e?Ott:QJ,r},Mtt=ne,Rtt=Pe,JJ=re,jtt=kt,Dtt=Uh,Ltt=OO,Ntt=Dtt(function(){var t=this.iterator,e=JJ(Mtt(this.next,t)),r=this.done=!!e.done;if(!r)return Ltt(t,this.mapper,[e.value,this.counter++],!0)}),eee=function(e){return JJ(this),Rtt(e),new Ntt(jtt(this),{mapper:e})},Ftt=ne,Btt=eee,Utt=function(t,e){return[e,t]},tee=function(){return Ftt(Btt,this,Utt)},ztt=A,Htt=tee;ztt({target:"Iterator",name:"indexed",proto:!0,real:!0,forced:!0},{asIndexedPairs:Htt});var Wtt=ne,Ktt=nt,Gtt=Qt,Vtt=ke,Ytt=ve,jB=Mh.IteratorPrototype,DB=Ytt("dispose");Vtt(jB,DB)||Ktt(jB,DB,function(){var t=Gtt(this,"return");t&&Wtt(t,this)});var Xtt=A,LB=ne,l2=re,qtt=kt,Ztt=L1,Qtt=vm,Jtt=Uh,ert=ir,trt=Jtt(function(){for(var t=this.iterator,e=this.next,r,n;this.remaining;)if(this.remaining--,r=l2(LB(e,t)),n=this.done=!!r.done,n)return;if(r=l2(LB(e,t)),n=this.done=!!r.done,!n)return r.value});Xtt({target:"Iterator",proto:!0,real:!0,forced:ert},{drop:function(e){l2(this);var r=Qtt(Ztt(+e));return new trt(qtt(this),{remaining:r})}});var rrt=A,nrt=zt,ort=Pe,irt=re,srt=kt;rrt({target:"Iterator",proto:!0,real:!0},{every:function(e){irt(this),ort(e);var r=srt(this),n=0;return!nrt(r,function(o,i){if(!e(o,n++))return i()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}});var art=A,lrt=ne,crt=Pe,ree=re,urt=kt,drt=Uh,hrt=OO,frt=ir,prt=drt(function(){for(var t=this.iterator,e=this.predicate,r=this.next,n,o,i;;){if(n=ree(lrt(r,t)),o=this.done=!!n.done,o)return;if(i=n.value,hrt(t,e,[i,this.counter++],!0))return i}});art({target:"Iterator",proto:!0,real:!0,forced:frt},{filter:function(e){return ree(this),crt(e),new prt(urt(this),{predicate:e})}});var grt=A,mrt=zt,vrt=Pe,yrt=re,Srt=kt;grt({target:"Iterator",proto:!0,real:!0},{find:function(e){yrt(this),vrt(e);var r=Srt(this),n=0;return mrt(r,function(o,i){if(e(o,n++))return i(o)},{IS_RECORD:!0,INTERRUPTED:!0}).result}});var wrt=ne,NB=re,xrt=kt,brt=Bl,nee=function(t,e){(!e||typeof t!="string")&&NB(t);var r=brt(t);return xrt(NB(r!==void 0?wrt(r,t):t))},$rt=A,FB=ne,Irt=Pe,c2=re,Prt=kt,Ert=nee,Crt=Uh,BB=Ul,_rt=ir,Trt=Crt(function(){for(var t=this.iterator,e=this.mapper,r,n;;){if(n=this.inner)try{if(r=c2(FB(n.next,n.iterator)),!r.done)return r.value;this.inner=null}catch(o){BB(t,"throw",o)}if(r=c2(FB(this.next,t)),this.done=!!r.done)return;try{this.inner=Ert(e(r.value,this.counter++),!1)}catch(o){BB(t,"throw",o)}}});$rt({target:"Iterator",proto:!0,real:!0,forced:_rt},{flatMap:function(e){return c2(this),Irt(e),new Trt(Prt(this),{mapper:e,inner:null})}});var Art=A,krt=zt,Ort=Pe,Mrt=re,Rrt=kt;Art({target:"Iterator",proto:!0,real:!0},{forEach:function(e){Mrt(this),Ort(e);var r=Rrt(this),n=0;krt(r,function(o){e(o,n++)},{IS_RECORD:!0})}});var jrt=A,Drt=ne,Lrt=je,Nrt=rn,Frt=Mh.IteratorPrototype,Brt=Uh,Urt=nee,zrt=ir,Hrt=Brt(function(){return Drt(this.next,this.iterator)},!0);jrt({target:"Iterator",stat:!0,forced:zrt},{from:function(e){var r=Urt(typeof e=="string"?Lrt(e):e,!0);return Nrt(Frt,r.iterator)?r.iterator:new Hrt(r)}});var Wrt=A,Krt=tee;Wrt({target:"Iterator",proto:!0,real:!0,forced:!0},{indexed:Krt});var Grt=A,Vrt=eee,Yrt=ir;Grt({target:"Iterator",proto:!0,real:!0,forced:Yrt},{map:Vrt});var Xrt=A,UB=GM,qrt=TypeError;Xrt({target:"Iterator",stat:!0,forced:!0},{range:function(e,r,n){if(typeof e=="number")return new UB(e,r,n,"number",0,1);if(typeof e=="bigint")return new UB(e,r,n,"bigint",BigInt(0),BigInt(1));throw new qrt("Incorrect Iterator.range arguments")}});var Zrt=A,Qrt=zt,Jrt=Pe,ent=re,tnt=kt,rnt=TypeError;Zrt({target:"Iterator",proto:!0,real:!0},{reduce:function(e){ent(this),Jrt(e);var r=tnt(this),n=arguments.length<2,o=n?void 0:arguments[1],i=0;if(Qrt(r,function(s){n?(n=!1,o=s):o=e(o,s,i),i++},{IS_RECORD:!0}),n)throw new rnt("Reduce of empty iterator with no initial value");return o}});var nnt=A,ont=zt,int=Pe,snt=re,ant=kt;nnt({target:"Iterator",proto:!0,real:!0},{some:function(e){snt(this),int(e);var r=ant(this),n=0;return ont(r,function(o,i){if(e(o,n++))return i()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}});var lnt=A,cnt=ne,oee=re,unt=kt,dnt=L1,hnt=vm,fnt=Uh,pnt=Ul,gnt=ir,mnt=fnt(function(){var t=this.iterator;if(!this.remaining--)return this.done=!0,pnt(t,"normal",void 0);var e=oee(cnt(this.next,t)),r=this.done=!!e.done;if(!r)return e.value});lnt({target:"Iterator",proto:!0,real:!0,forced:gnt},{take:function(e){oee(this);var r=hnt(dnt(+e));return new mnt(unt(this),{remaining:r})}});var vnt=A,ynt=re,Snt=zt,wnt=kt,xnt=[].push;vnt({target:"Iterator",proto:!0,real:!0},{toArray:function(){var e=[];return Snt(wnt(ynt(this)),xnt,{that:e,IS_RECORD:!0}),e}});var bnt=A,$nt=re,Int=R1,Pnt=TJ,zB=kt,Ent=ir;bnt({target:"Iterator",proto:!0,real:!0,forced:Ent},{toAsync:function(){return new Pnt(zB(new Int(zB($nt(this)))))}});var Cnt=q,iee=!Cnt(function(){var t="9007199254740993",e=JSON.rawJSON(t);return!JSON.isRawJSON(e)||JSON.stringify(e)!==t}),_nt=Ie,Tnt=et.get,see=function(e){if(!_nt(e))return!1;var r=Tnt(e);return!!r&&r.type==="RawJSON"},Ant=A,knt=iee,Ont=see;Ant({target:"JSON",stat:!0,forced:!knt},{isRawJSON:Ont});var qM=V,Mnt=ke,gy=SyntaxError,Rnt=parseInt,jnt=String.fromCharCode,Dnt=qM("".charAt),HB=qM("".slice),WB=qM(/./.exec),KB={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
|
|
100
|
-
`,"\\r":"\r","\\t":" "},Lnt=/^[\da-f]{4}$/i,Nnt=/^[\u0000-\u001F]$/,aee=function(t,e){for(var r=!0,n="";e<t.length;){var o=Dnt(t,e);if(o==="\\"){var i=HB(t,e,e+2);if(Mnt(KB,i))n+=KB[i],e+=2;else if(i==="\\u"){e+=2;var s=HB(t,e,e+4);if(!WB(Lnt,s))throw new gy("Bad Unicode escape at: "+e);n+=jnt(Rnt(s,16)),e+=4}else throw new gy('Unknown escape sequence: "'+i+'"')}else if(o==='"'){r=!1,e++;break}else{if(WB(Nnt,o))throw new gy("Bad control character in string literal at: "+e);n+=o,e++}}if(r)throw new gy("Unterminated string at: "+e);return{value:n,end:e}},Fnt=A,Bnt=ge,ZM=te,Unt=be,F1=V,znt=ne,lee=Ce,Hnt=Ie,Wnt=vs,Knt=ke,Gnt=Ee,GB=Ke,u2=Ti,cee=q,Vnt=aee,Ynt=eu,VB=ZM.JSON,Xnt=ZM.Number,Ku=ZM.SyntaxError,QM=VB&&VB.parse,qnt=Unt("Object","keys"),Znt=Object.getOwnPropertyDescriptor,br=F1("".charAt),RP=F1("".slice),jP=F1(/./.exec),YB=F1([].push),DP=/^\d$/,Qnt=/^[1-9]$/,Jnt=/^[\d-]$/,op=/^[\t\n\r ]$/,LP=0,XB=1,eot=function(t,e){t=Gnt(t);var r=new h2(t,0),n=r.parse(),o=n.value,i=r.skip(op,n.end);if(i<t.length)throw new Ku('Unexpected extra character: "'+br(t,i)+'" after the parsed data at: '+i);return lee(e)?d2({"":o},"",e,n):o},d2=function(t,e,r,n){var o=t[e],i=n&&o===n.value,s=i&&typeof n.source=="string"?{source:n.source}:{},a,l,c,u,d;if(Hnt(o)){var f=Wnt(o),p=i?n.nodes:f?[]:{};if(f)for(a=p.length,c=GB(o),u=0;u<c;u++)qB(o,u,d2(o,""+u,r,u<a?p[u]:void 0));else for(l=qnt(o),c=GB(l),u=0;u<c;u++)d=l[u],qB(o,d,d2(o,d,r,Knt(p,d)?p[d]:void 0))}return znt(r,t,e,o,s)},qB=function(t,e,r){if(Bnt){var n=Znt(t,e);if(n&&!n.configurable)return}r===void 0?delete t[e]:u2(t,e,r)},tot=function(t,e,r,n){this.value=t,this.end=e,this.source=r,this.nodes=n},h2=function(t,e){this.source=t,this.index=e};h2.prototype={fork:function(t){return new h2(this.source,t)},parse:function(){var t=this.source,e=this.skip(op,this.index),r=this.fork(e),n=br(t,e);if(jP(Jnt,n))return r.number();switch(n){case"{":return r.object();case"[":return r.array();case'"':return r.string();case"t":return r.keyword(!0);case"f":return r.keyword(!1);case"n":return r.keyword(null)}throw new Ku('Unexpected character: "'+n+'" at: '+e)},node:function(t,e,r,n,o){return new tot(e,n,t?null:RP(this.source,r,n),o)},object:function(){for(var t=this.source,e=this.index+1,r=!1,n={},o={};e<t.length;){if(e=this.until(['"',"}"],e),br(t,e)==="}"&&!r){e++;break}var i=this.fork(e).string(),s=i.value;e=i.end,e=this.until([":"],e)+1,e=this.skip(op,e),i=this.fork(e).parse(),u2(o,s,i),u2(n,s,i.value),e=this.until([",","}"],i.end);var a=br(t,e);if(a===",")r=!0,e++;else if(a==="}"){e++;break}}return this.node(XB,n,this.index,e,o)},array:function(){for(var t=this.source,e=this.index+1,r=!1,n=[],o=[];e<t.length;){if(e=this.skip(op,e),br(t,e)==="]"&&!r){e++;break}var i=this.fork(e).parse();if(YB(o,i),YB(n,i.value),e=this.until([",","]"],i.end),br(t,e)===",")r=!0,e++;else if(br(t,e)==="]"){e++;break}}return this.node(XB,n,this.index,e,o)},string:function(){var t=this.index,e=Vnt(this.source,this.index+1);return this.node(LP,e.value,t,e.end)},number:function(){var t=this.source,e=this.index,r=e;if(br(t,r)==="-"&&r++,br(t,r)==="0")r++;else if(jP(Qnt,br(t,r)))r=this.skip(DP,r+1);else throw new Ku("Failed to parse number at: "+r);if(br(t,r)==="."&&(r=this.skip(DP,r+1)),br(t,r)==="e"||br(t,r)==="E"){r++,(br(t,r)==="+"||br(t,r)==="-")&&r++;var n=r;if(r=this.skip(DP,r),n===r)throw new Ku("Failed to parse number's exponent value at: "+r)}return this.node(LP,Xnt(RP(t,e,r)),e,r)},keyword:function(t){var e=""+t,r=this.index,n=r+e.length;if(RP(this.source,r,n)!==e)throw new Ku("Failed to parse value at: "+r);return this.node(LP,t,r,n)},skip:function(t,e){for(var r=this.source;e<r.length&&jP(t,br(r,e));e++);return e},until:function(t,e){e=this.skip(op,e);for(var r=br(this.source,e),n=0;n<t.length;n++)if(t[n]===r)return e;throw new Ku('Unexpected character: "'+r+'" at: '+e)}};var rot=cee(function(){var t="9007199254740993",e;return QM(t,function(r,n,o){e=o.source}),e!==t}),not=Ynt&&!cee(function(){return 1/QM("-0 ")!==-1/0});Fnt({target:"JSON",stat:!0,forced:rot},{parse:function(e,r){return not&&!lee(r)?QM(e):eot(e,r)}});var uee=A,oot=Wl,dee=iee,B1=be,iot=ne,JM=V,sot=Ce,aot=see,lot=Ee,cot=Ti,uot=aee,dot=CY,hot=ru,fot=et.set,pot=String,ZB=SyntaxError,got=B1("JSON","parse"),QB=B1("JSON","stringify"),mot=B1("Object","create"),vot=B1("Object","freeze"),f2=JM("".charAt),NP=JM("".slice),yot=JM([].push),p2=hot(),JB=p2.length,eU="Unacceptable as raw JSON",tU=function(t){return t===" "||t===" "||t===`
|
|
101
|
-
`||t==="\r"};uee({target:"JSON",stat:!0,forced:!dee},{rawJSON:function(e){var r=lot(e);if(r===""||tU(f2(r,0))||tU(f2(r,r.length-1)))throw new ZB(eU);var n=got(r);if(typeof n=="object"&&n!==null)throw new ZB(eU);var o=mot(null);return fot(o,{type:"RawJSON"}),cot(o,"rawJSON",r),oot?vot(o):o}});QB&&uee({target:"JSON",stat:!0,arity:3,forced:!dee},{stringify:function(e,r,n){var o=dot(r),i=[],s=QB(e,function(p,g){var m=sot(o)?iot(o,this,pot(p),g):g;return aot(m)?p2+(yot(i,m.rawJSON)-1):m},n);if(typeof s!="string")return s;for(var a="",l=s.length,c=0;c<l;c++){var u=f2(s,c);if(u==='"'){var d=uot(s,++c).end-1,f=NP(s,c,d);a+=NP(f,0,JB)===p2?i[NP(f,JB)]:'"'+f+'"',c=d}else a+=u}return a}});var Sot=nn.has,Vn=function(t){return Sot(t),t},wot=A,xot=Vn,bot=nn.remove;wot({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e=xot(this),r=!0,n,o=0,i=arguments.length;o<i;o++)n=bot(e,arguments[o]),r=r&&n;return!!r}});var $ot=A,Iot=Vn,eR=nn,Pot=eR.get,Eot=eR.has,rU=eR.set;$ot({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,r){var n=Iot(this),o,i;return Eot(n,e)?(o=Pot(n,e),"update"in r&&(o=r.update(o,e,n),rU(n,e,o)),o):(i=r.insert(e,n),rU(n,e,i),i)}});var Cot=A,_ot=dt,Tot=Vn,Aot=Oi;Cot({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var r=Tot(this),n=_ot(e,arguments.length>1?arguments[1]:void 0);return Aot(r,function(o,i){if(!n(o,i,r))return!1},!0)!==!1}});var kot=A,Oot=dt,Mot=Vn,hee=nn,Rot=Oi,jot=hee.Map,Dot=hee.set;kot({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var r=Mot(this),n=Oot(e,arguments.length>1?arguments[1]:void 0),o=new jot;return Rot(r,function(i,s){n(i,s,r)&&Dot(o,s,i)}),o}});var Lot=A,Not=dt,Fot=Vn,Bot=Oi;Lot({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var r=Fot(this),n=Not(e,arguments.length>1?arguments[1]:void 0),o=Bot(r,function(i,s){if(n(i,s,r))return{value:i}},!0);return o&&o.value}});var Uot=A,zot=dt,Hot=Vn,Wot=Oi;Uot({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var r=Hot(this),n=zot(e,arguments.length>1?arguments[1]:void 0),o=Wot(r,function(i,s){if(n(i,s,r))return{key:s}},!0);return o&&o.key}});var Kot=dt,Got=re,Vot=je,Yot=zt,U1=function(t,e,r){return function(o){var i=Vot(o),s=arguments.length,a=s>1?arguments[1]:void 0,l=a!==void 0,c=l?Kot(a,s>2?arguments[2]:void 0):void 0,u=new t,d=0;return Yot(i,function(f){var p=l?c(f,d++):f;r?e(u,Got(p)[0],p[1]):e(u,p)}),u}},Xot=A,nU=nn,qot=U1;Xot({target:"Map",stat:!0,forced:!0},{from:qot(nU.Map,nU.set,!0)});var Zot=function(t,e){return t===e||t!==t&&e!==e},Qot=A,Jot=Zot,eit=Vn,tit=Oi;Qot({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return tit(eit(this),function(r){if(Jot(r,e))return!0},!0)===!0}});var rit=A,nit=ne,oit=zt,iit=Ce,oU=Pe,sit=nn.Map;rit({target:"Map",stat:!0,forced:!0},{keyBy:function(e,r){var n=iit(this)?this:sit,o=new n;oU(r);var i=oU(o.set);return oit(e,function(s){nit(i,o,r(s),s)}),o}});var ait=A,lit=Vn,cit=Oi;ait({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var r=cit(lit(this),function(n,o){if(n===e)return{key:o}},!0);return r&&r.key}});var uit=A,dit=dt,hit=Vn,fee=nn,fit=Oi,pit=fee.Map,git=fee.set;uit({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var r=hit(this),n=dit(e,arguments.length>1?arguments[1]:void 0),o=new pit;return fit(r,function(i,s){git(o,n(i,s,r),i)}),o}});var mit=A,vit=dt,yit=Vn,pee=nn,Sit=Oi,wit=pee.Map,xit=pee.set;mit({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var r=yit(this),n=vit(e,arguments.length>1?arguments[1]:void 0),o=new wit;return Sit(r,function(i,s){xit(o,s,n(i,s,r))}),o}});var bit=A,$it=Vn,Iit=zt,Pit=nn.set;bit({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var r=$it(this),n=arguments.length,o=0;o<n;)Iit(arguments[o++],function(i,s){Pit(r,i,s)},{AS_ENTRIES:!0});return r}});var Eit=re,z1=function(t,e,r){return function(){for(var o=new t,i=arguments.length,s=0;s<i;s++){var a=arguments[s];r?e(o,Eit(a)[0],a[1]):e(o,a)}return o}},Cit=A,iU=nn,_it=z1;Cit({target:"Map",stat:!0,forced:!0},{of:_it(iU.Map,iU.set,!0)});var Tit=A,Ait=Pe,kit=Vn,Oit=Oi,Mit=TypeError;Tit({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var r=kit(this),n=arguments.length<2,o=n?void 0:arguments[1];if(Ait(e),Oit(r,function(i,s){n?(n=!1,o=i):o=e(o,i,s,r)}),n)throw new Mit("Reduce of empty map with no initial value");return o}});var Rit=A,jit=dt,Dit=Vn,Lit=Oi;Rit({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var r=Dit(this),n=jit(e,arguments.length>1?arguments[1]:void 0);return Lit(r,function(o,i){if(n(o,i,r))return!0},!0)===!0}});var Nit=A,sU=Pe,Fit=Vn,tR=nn,Bit=TypeError,Uit=tR.get,zit=tR.has,Hit=tR.set;Nit({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,r){var n=Fit(this),o=arguments.length;sU(r);var i=zit(n,e);if(!i&&o<3)throw new Bit("Updating absent value");var s=i?Uit(n,e):sU(o>2?arguments[2]:void 0)(e,n);return Hit(n,e,r(s,e,n)),n}});var my=ne,FP=Pe,vy=Ce,Wit=re,Kit=TypeError,rR=function(e,r){var n=Wit(this),o=FP(n.get),i=FP(n.has),s=FP(n.set),a=arguments.length>2?arguments[2]:void 0,l;if(!vy(r)&&!vy(a))throw new Kit("At least one callback required");return my(i,n,e)?(l=my(o,n,e),vy(r)&&(l=r(l),my(s,n,e,l))):vy(a)&&(l=a(),my(s,n,e,l)),l},Git=A,Vit=rR;Git({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:Vit});var Yit=A,Xit=rR;Yit({target:"Map",proto:!0,real:!0,forced:!0},{upsert:Xit});var qit=A,Zit=Math.min,Qit=Math.max;qit({target:"Math",stat:!0,forced:!0},{clamp:function(e,r,n){return Zit(n,Qit(r,e))}});var Jit=A;Jit({target:"Math",stat:!0,nonConfigurable:!0,nonWritable:!0},{DEG_PER_RAD:Math.PI/180});var est=A,tst=180/Math.PI;est({target:"Math",stat:!0,forced:!0},{degrees:function(e){return e*tst}});var gee=Math.scale||function(e,r,n,o,i){var s=+e,a=+r,l=+n,c=+o,u=+i;return s!==s||a!==a||l!==l||c!==c||u!==u?NaN:s===1/0||s===-1/0?s:(s-a)*(u-c)/(l-a)+c},rst=A,nst=gee,ost=UO;rst({target:"Math",stat:!0,forced:!0},{fscale:function(e,r,n,o,i){return ost(nst(e,r,n,o,i))}});var ist=A,sst=NJ;ist({target:"Math",stat:!0},{f16round:sst});var ast=A;ast({target:"Math",stat:!0,forced:!0},{iaddh:function(e,r,n,o){var i=e>>>0,s=r>>>0,a=n>>>0;return s+(o>>>0)+((i&a|(i|a)&~(i+a>>>0))>>>31)|0}});var lst=A;lst({target:"Math",stat:!0,forced:!0},{imulh:function(e,r){var n=65535,o=+e,i=+r,s=o&n,a=i&n,l=o>>16,c=i>>16,u=(l*a>>>0)+(s*a>>>16);return l*c+(u>>16)+((s*c>>>0)+(u&n)>>16)}});var cst=A;cst({target:"Math",stat:!0,forced:!0},{isubh:function(e,r,n,o){var i=e>>>0,s=r>>>0,a=n>>>0;return s-(o>>>0)-((~i&a|~(i^a)&i-a>>>0)>>>31)|0}});var ust=A;ust({target:"Math",stat:!0,nonConfigurable:!0,nonWritable:!0},{RAD_PER_DEG:180/Math.PI});var dst=A,hst=Math.PI/180;dst({target:"Math",stat:!0,forced:!0},{radians:function(e){return e*hst}});var fst=A,pst=gee;fst({target:"Math",stat:!0,forced:!0},{scale:pst});var gst=A,mst=re,vst=hq,yst=au,Sst=Nr,mee=et,vee="Seeded Random",yee=vee+" Generator",wst='Math.seededPRNG() argument should have a "seed" field with a finite value.',xst=mee.set,bst=mee.getterFor(yee),$st=TypeError,Ist=yst(function(e){xst(this,{type:yee,seed:e%2147483647})},vee,function(){var e=bst(this),r=e.seed=(e.seed*1103515245+12345)%2147483647;return Sst((r&1073741823)/1073741823,!1)});gst({target:"Math",stat:!0,forced:!0},{seededPRNG:function(e){var r=mst(e).seed;if(!vst(r))throw new $st(wst);return new Ist(r)}});var Pst=A;Pst({target:"Math",stat:!0,forced:!0},{signbit:function(e){var r=+e;return r===r&&r===0?1/r===-1/0:r<0}});var Est=A,Cst=V,_st=zt,Tst=RangeError,Ast=TypeError,ko=1/0,kst=NaN,cc=Math.abs,nR=Math.pow,aU=Cst([].push),Rf=nR(2,1023),Ost=nR(2,53)-1,lU=Number.MAX_VALUE,cU=nR(2,971),jf={},BP={},UP={},zP={},uU={},yy=function(t,e){var r=t+e,n=e-(r-t);return{hi:r,lo:n}};Est({target:"Math",stat:!0,forced:!0},{sumPrecise:function(e){var r=[],n=0,o=zP;switch(_st(e,function(b){if(++n>=Ost)throw new Tst("Maximum allowed index exceeded");if(typeof b!="number")throw new Ast("Value is not a number");o!==jf&&(b!==b?o=jf:b===ko?o=o===BP?jf:UP:b===-ko?o=o===UP?jf:BP:(b!==0||1/b===ko)&&(o===zP||o===uU)&&(o=uU,aU(r,b)))}),o){case jf:return kst;case BP:return-ko;case UP:return ko;case zP:return-0}for(var i=[],s=0,a,l,c,u,d,f,p=0;p<r.length;p++){a=r[p];for(var g=0,m=0;m<i.length;m++){if(l=i[m],cc(a)<cc(l)&&(f=a,a=l,l=f),c=yy(a,l),u=c.hi,d=c.lo,cc(u)===ko){var S=u===ko?1:-1;s+=S,a=a-S*Rf-S*Rf,cc(a)<cc(l)&&(f=a,a=l,l=f),c=yy(a,l),u=c.hi,d=c.lo}d!==0&&(i[g++]=d),a=u}i.length=g,a!==0&&aU(i,a)}var y=i.length-1;if(u=0,d=0,s!==0){var v=y>=0?i[y]:0;if(y--,cc(s)>1||s>0&&v>0||s<0&&v<0)return s>0?ko:-ko;if(c=yy(s*Rf,v/2),u=c.hi,d=c.lo,d*=2,cc(2*u)===ko)return u>0?u===Rf&&d===-(cU/2)&&y>=0&&i[y]<0?lU:ko:u===-Rf&&d===cU/2&&y>=0&&i[y]>0?-lU:-ko;d!==0&&(i[++y]=d,d=0),u*=2}for(;y>=0&&(c=yy(u,i[y--]),u=c.hi,d=c.lo,d===0););return y>=0&&(d<0&&i[y]<0||d>0&&i[y]>0)&&(l=d*2,a=u+l,l===a-u&&(u=a)),u}});var Mst=A;Mst({target:"Math",stat:!0,forced:!0},{umulh:function(e,r){var n=65535,o=+e,i=+r,s=o&n,a=i&n,l=o>>>16,c=i>>>16,u=(l*a>>>0)+(s*a>>>16);return l*c+(u>>>16)+((s*c>>>0)+(u&n)>>>16)}});var Rst=A,$m=V,jst=Et,Df="Invalid number representation",Dst="Invalid radix",Lst=RangeError,Sy=SyntaxError,Nst=TypeError,dU=parseInt,Fst=Math.pow,See=/^[\d.a-z]+$/,Bst=$m("".charAt),Ust=$m(See.exec),zst=$m(1 .toString),Hst=$m("".slice),Wst=$m("".split);Rst({target:"Number",stat:!0,forced:!0},{fromString:function(e,r){var n=1;if(typeof e!="string")throw new Nst(Df);if(!e.length)throw new Sy(Df);if(Bst(e,0)==="-"&&(n=-1,e=Hst(e,1),!e.length))throw new Sy(Df);var o=r===void 0?10:jst(r);if(o<2||o>36)throw new Lst(Dst);if(!Ust(See,e))throw new Sy(Df);var i=Wst(e,"."),s=dU(i[0],o);if(i.length>1&&(s+=dU(i[1],o)/Fst(o,i[1].length)),o===10&&zst(s,o)!==e)throw new Sy(Df);return n*s}});var Kst=A,Gst=GM;Kst({target:"Number",stat:!0,forced:!0},{range:function(e,r,n){return new Gst(e,r,n,"number",0,1)}});var wee=et,Vst=au,wy=Nr,Yst=ke,Xst=Eh,qst=je,xee="Object Iterator",Zst=wee.set,Qst=wee.getterFor(xee),oR=Vst(function(e,r){var n=qst(e);Zst(this,{type:xee,mode:r,object:n,keys:Xst(n),index:0})},"Object",function(){for(var e=Qst(this),r=e.keys;;){if(r===null||e.index>=r.length)return e.object=e.keys=null,wy(void 0,!0);var n=r[e.index++],o=e.object;if(Yst(o,n)){switch(e.mode){case"keys":return wy(n,!1);case"values":return wy(o[n],!1)}return wy([n,o[n]],!1)}}}),Jst=A,eat=oR;Jst({target:"Object",stat:!0,forced:!0},{iterateEntries:function(e){return new eat(e,"entries")}});var tat=A,rat=oR;tat({target:"Object",stat:!0,forced:!0},{iterateKeys:function(e){return new rat(e,"keys")}});var nat=A,oat=oR;nat({target:"Object",stat:!0,forced:!0},{iterateValues:function(e){return new oat(e,"values")}});var iat=A,AS=ne,Im=ge,sat=lu,bee=Pe,aat=re,lat=wn,$ee=Ce,cat=nr,uat=Ie,kS=Qt,dat=nt,iR=ki,Iee=Ct,pd=Fq,hat=ve,Pee=et,fat=hat("observable"),sR="Observable",Eee="Subscription",Cee="SubscriptionObserver",aR=Pee.getterFor,lR=Pee.set,pat=aR(sR),_ee=aR(Eee),OS=aR(Cee),Tee=function(t){this.observer=aat(t),this.cleanup=null,this.subscriptionObserver=null};Tee.prototype={type:Eee,clean:function(){var t=this.cleanup;if(t){this.cleanup=null;try{t()}catch(e){pd(e)}}},close:function(){if(!Im){var t=this.facade,e=this.subscriptionObserver;t.closed=!0,e&&(e.closed=!0)}this.observer=null},isClosed:function(){return this.observer===null}};var cR=function(t,e){var r=lR(this,new Tee(t)),n;Im||(this.closed=!1);try{(n=kS(t,"start"))&&AS(n,t,this)}catch(a){pd(a)}if(!r.isClosed()){var o=r.subscriptionObserver=new uR(r);try{var i=e(o),s=i;cat(i)||(r.cleanup=$ee(i.unsubscribe)?function(){s.unsubscribe()}:bee(i))}catch(a){o.error(a);return}r.isClosed()&&r.clean()}};cR.prototype=iR({},{unsubscribe:function(){var e=_ee(this);e.isClosed()||(e.close(),e.clean())}});Im&&Iee(cR.prototype,"closed",{configurable:!0,get:function(){return _ee(this).isClosed()}});var uR=function(t){lR(this,{type:Cee,subscriptionState:t}),Im||(this.closed=!1)};uR.prototype=iR({},{next:function(e){var r=OS(this).subscriptionState;if(!r.isClosed()){var n=r.observer;try{var o=kS(n,"next");o&&AS(o,n,e)}catch(i){pd(i)}}},error:function(e){var r=OS(this).subscriptionState;if(!r.isClosed()){var n=r.observer;r.close();try{var o=kS(n,"error");o?AS(o,n,e):pd(e)}catch(i){pd(i)}r.clean()}},complete:function(){var e=OS(this).subscriptionState;if(!e.isClosed()){var r=e.observer;e.close();try{var n=kS(r,"complete");n&&AS(n,r)}catch(o){pd(o)}e.clean()}}});Im&&Iee(uR.prototype,"closed",{configurable:!0,get:function(){return OS(this).subscriptionState.isClosed()}});var Aee=function(e){lat(this,dR),lR(this,{type:sR,subscriber:bee(e)})},dR=Aee.prototype;iR(dR,{subscribe:function(e){var r=arguments.length;return new cR($ee(e)?{next:e,error:r>1?arguments[1]:void 0,complete:r>2?arguments[2]:void 0}:uat(e)?e:{},pat(this).subscriber)}});dat(dR,fat,function(){return this});iat({global:!0,constructor:!0,forced:!0},{Observable:Aee});sat(sR);var gat=A,mat=be,vat=ne,hU=re,yat=ys,Sat=su,wat=Qt,xat=zt,bat=ve,$at=bat("observable");gat({target:"Observable",stat:!0,forced:!0},{from:function(e){var r=yat(this)?this:mat("Observable"),n=wat(hU(e),$at);if(n){var o=hU(vat(n,e));return o.constructor===r?o:new r(function(s){return o.subscribe(s)})}var i=Sat(e);return new r(function(s){xat(i,function(a,l){if(s.next(a),s.closed)return l()},{IS_ITERATOR:!0,INTERRUPTED:!0}),s.complete()})}});var Iat=A,kee=be,Pat=ys,Eat=kee("Array");Iat({target:"Observable",stat:!0,forced:!0},{of:function(){for(var e=Pat(this)?this:kee("Observable"),r=arguments.length,n=Eat(r),o=0;o<r;)n[o]=arguments[o++];return new e(function(i){for(var s=0;s<r;s++)if(i.next(n[s]),i.closed)return;i.complete()})}});var Cat=A,_at=te,Tat=yn,Aat=Io,kat=bs,Oat=Pe,Oee=uu,HP=_at.Promise,fU=!1,Mat=!HP||!HP.try||Oee(function(){HP.try(function(t){fU=t===8},8)}).error||!fU;Cat({target:"Promise",stat:!0,forced:Mat},{try:function(t){var e=arguments.length>1?Aat(arguments,1):[],r=kat.f(this),n=Oee(function(){return Tat(Oat(t),void 0,e)});return(n.error?r.reject:r.resolve)(n.value),r.promise}});var Mee=be,Rat=V,jat=jl,pU=Mee("Map"),Dat=Mee("WeakMap"),Lat=Rat([].push),gU=jat("metadata"),g2=gU.store||(gU.store=new Dat),Pm=function(t,e,r){var n=g2.get(t);if(!n){if(!r)return;g2.set(t,n=new pU)}var o=n.get(e);if(!o){if(!r)return;n.set(e,o=new pU)}return o},Nat=function(t,e,r){var n=Pm(e,r,!1);return n===void 0?!1:n.has(t)},Fat=function(t,e,r){var n=Pm(e,r,!1);return n===void 0?void 0:n.get(t)},Bat=function(t,e,r,n){Pm(r,n,!0).set(t,e)},Uat=function(t,e){var r=Pm(t,e,!1),n=[];return r&&r.forEach(function(o,i){Lat(n,i)}),n},zat=function(t){return t===void 0||typeof t=="symbol"?t:String(t)},Sa={store:g2,getMap:Pm,has:Nat,get:Fat,set:Bat,keys:Uat,toKey:zat},Hat=A,Ree=Sa,Wat=re,Kat=Ree.toKey,Gat=Ree.set;Hat({target:"Reflect",stat:!0},{defineMetadata:function(e,r,n){var o=arguments.length<4?void 0:Kat(arguments[3]);Gat(e,r,Wat(n),o)}});var Vat=A,hR=Sa,Yat=re,Xat=hR.toKey,qat=hR.getMap,mU=hR.store;Vat({target:"Reflect",stat:!0},{deleteMetadata:function(e,r){var n=arguments.length<3?void 0:Xat(arguments[2]),o=qat(Yat(r),n,!1);if(o===void 0||!o.delete(e))return!1;if(o.size)return!0;var i=mU.get(r);return i.delete(n),!!i.size||mU.delete(r)}});var Zat=A,fR=Sa,Qat=re,Jat=lr,elt=fR.has,tlt=fR.get,rlt=fR.toKey,jee=function(t,e,r){var n=elt(t,e,r);if(n)return tlt(t,e,r);var o=Jat(e);return o!==null?jee(t,o,r):void 0};Zat({target:"Reflect",stat:!0},{getMetadata:function(e,r){var n=arguments.length<3?void 0:rlt(arguments[2]);return jee(e,Qat(r),n)}});var nlt=A,Dee=V,Lee=Sa,olt=re,ilt=lr,slt=HM,alt=Dee(slt),llt=Dee([].concat),clt=Lee.keys,ult=Lee.toKey,Nee=function(t,e){var r=clt(t,e),n=ilt(t);if(n===null)return r;var o=Nee(n,e);return o.length?r.length?alt(llt(r,o)):o:r};nlt({target:"Reflect",stat:!0},{getMetadataKeys:function(e){var r=arguments.length<2?void 0:ult(arguments[1]);return Nee(olt(e),r)}});var dlt=A,Fee=Sa,hlt=re,flt=Fee.get,plt=Fee.toKey;dlt({target:"Reflect",stat:!0},{getOwnMetadata:function(e,r){var n=arguments.length<3?void 0:plt(arguments[2]);return flt(e,hlt(r),n)}});var glt=A,Bee=Sa,mlt=re,vlt=Bee.keys,ylt=Bee.toKey;glt({target:"Reflect",stat:!0},{getOwnMetadataKeys:function(e){var r=arguments.length<2?void 0:ylt(arguments[1]);return vlt(mlt(e),r)}});var Slt=A,Uee=Sa,wlt=re,xlt=lr,blt=Uee.has,$lt=Uee.toKey,zee=function(t,e,r){var n=blt(t,e,r);if(n)return!0;var o=xlt(e);return o!==null?zee(t,o,r):!1};Slt({target:"Reflect",stat:!0},{hasMetadata:function(e,r){var n=arguments.length<3?void 0:$lt(arguments[2]);return zee(e,wlt(r),n)}});var Ilt=A,Hee=Sa,Plt=re,Elt=Hee.has,Clt=Hee.toKey;Ilt({target:"Reflect",stat:!0},{hasOwnMetadata:function(e,r){var n=arguments.length<3?void 0:Clt(arguments[2]);return Elt(e,Plt(r),n)}});var _lt=A,Wee=Sa,Tlt=re,Alt=Wee.toKey,klt=Wee.set;_lt({target:"Reflect",stat:!0},{metadata:function(e,r){return function(o,i){klt(e,r,Tlt(o),Alt(i))}}});var Olt=TypeError,H1=function(t){if(typeof t=="string")return t;throw new Olt("Argument is not a string")},Mlt=A,Em=V,Rlt=H1,jlt=ke,vU=y1.start,Dlt=Lh,Llt=Array,yU=RegExp.escape,SU=Em("".charAt),m2=Em("".charCodeAt),Nlt=Em(1.1.toString),Flt=Em([].join),Kee=/^[0-9a-z]/i,Blt=/^[$()*+./?[\\\]^{|}]/,Ult=RegExp("^[!\"#%&',\\-:;<=>@`~"+Dlt+"]"),WP=Em(Kee.exec),wU={" ":"t","\n":"n","\v":"v","\f":"f","\r":"r"},KP=function(t){var e=Nlt(m2(t,0),16);return e.length<3?"\\x"+vU(e,2,"0"):"\\u"+vU(e,4,"0")},zlt=!yU||yU("ab")!=="\\x61b";Mlt({target:"RegExp",stat:!0,forced:zlt},{escape:function(e){Rlt(e);for(var r=e.length,n=Llt(r),o=0;o<r;o++){var i=SU(e,o);if(o===0&&WP(Kee,i))n[o]=KP(i);else if(jlt(wU,i))n[o]="\\"+wU[i];else if(WP(Blt,i))n[o]="\\"+i;else if(WP(Ult,i))n[o]=KP(i);else{var s=m2(i,0);(s&63488)!==55296?n[o]=i:s>=56320||o+1>=r||(m2(e,o+1)&64512)!==56320?n[o]=KP(i):(n[o]=i,n[++o]=SU(e,o))}}return Flt(n,"")}});var Hlt=A,Wlt=on,Klt=Fr.add;Hlt({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=Wlt(this),r=0,n=arguments.length;r<n;r++)Klt(e,arguments[r]);return e}});var Glt=A,Vlt=on,Ylt=Fr.remove;Glt({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e=Vlt(this),r=!0,n,o=0,i=arguments.length;o<i;o++)n=Ylt(e,arguments[o]),r=r&&n;return!!r}});var Xlt=bo,qlt=ke,Zlt=nr,Qlt=ve,Jlt=Oh,ect=Qlt("iterator"),tct=Object,rct=function(t){if(Zlt(t))return!1;var e=tct(t);return e[ect]!==void 0||"@@iterator"in e||qlt(Jlt,Xlt(e))},nct=be,xU=Ce,oct=rct,ict=Ie,sct=nct("Set"),act=function(t){return ict(t)&&typeof t.size=="number"&&xU(t.has)&&xU(t.keys)},fu=function(t){return act(t)?t:oct(t)?new sct(t):t},lct=A,cct=ne,uct=fu,dct=PZ;lct({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return cct(dct,this,uct(e))}});var hct=A,fct=dt,pct=on,gct=Po;hct({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var r=pct(this),n=fct(e,arguments.length>1?arguments[1]:void 0);return gct(r,function(o){if(!n(o,o,r))return!1},!0)!==!1}});var mct=A,vct=dt,yct=on,Gee=Fr,Sct=Po,wct=Gee.Set,xct=Gee.add;mct({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var r=yct(this),n=vct(e,arguments.length>1?arguments[1]:void 0),o=new wct;return Sct(r,function(i){n(i,i,r)&&xct(o,i)}),o}});var bct=A,$ct=dt,Ict=on,Pct=Po;bct({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var r=Ict(this),n=$ct(e,arguments.length>1?arguments[1]:void 0),o=Pct(r,function(i){if(n(i,i,r))return{value:i}},!0);return o&&o.value}});var Ect=A,bU=Fr,Cct=U1;Ect({target:"Set",stat:!0,forced:!0},{from:Cct(bU.Set,bU.add,!1)});var _ct=A,Tct=ne,Act=fu,kct=EZ;_ct({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return Tct(kct,this,Act(e))}});var Oct=A,Mct=ne,Rct=fu,jct=CZ;Oct({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return Mct(jct,this,Rct(e))}});var Dct=A,Lct=ne,Nct=fu,Fct=_Z;Dct({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return Lct(Fct,this,Nct(e))}});var Bct=A,Uct=ne,zct=fu,Hct=TZ;Bct({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return Uct(Hct,this,zct(e))}});var Wct=A,Vee=V,Kct=on,Gct=Po,Vct=Ee,Yct=Vee([].join),Xct=Vee([].push);Wct({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var r=Kct(this),n=e===void 0?",":Vct(e),o=[];return Gct(r,function(i){Xct(o,i)}),Yct(o,n)}});var qct=A,Zct=dt,Qct=on,Yee=Fr,Jct=Po,eut=Yee.Set,tut=Yee.add;qct({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var r=Qct(this),n=Zct(e,arguments.length>1?arguments[1]:void 0),o=new eut;return Jct(r,function(i){tut(o,n(i,i,r))}),o}});var rut=A,$U=Fr,nut=z1;rut({target:"Set",stat:!0,forced:!0},{of:nut($U.Set,$U.add,!1)});var out=A,iut=Pe,sut=on,aut=Po,lut=TypeError;out({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var r=sut(this),n=arguments.length<2,o=n?void 0:arguments[1];if(iut(e),aut(r,function(i){n?(n=!1,o=i):o=e(o,i,i,r)}),n)throw new lut("Reduce of empty set with no initial value");return o}});var cut=A,uut=dt,dut=on,hut=Po;cut({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var r=dut(this),n=uut(e,arguments.length>1?arguments[1]:void 0);return hut(r,function(o){if(n(o,o,r))return!0},!0)===!0}});var fut=A,put=ne,gut=fu,mut=AZ;fut({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return put(mut,this,gut(e))}});var vut=A,yut=ne,Sut=fu,wut=kZ;vut({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return yut(wut,this,Sut(e))}});var xut=A,but=Ch.charAt,$ut=St,Iut=Et,Put=Ee;xut({target:"String",proto:!0,forced:!0},{at:function(e){var r=Put($ut(this)),n=r.length,o=Iut(e),i=o>=0?o:n+o;return i<0||i>=n?void 0:but(r,i)}});var Xee=V,Eut=or,IU=Ee,Cut=Ke,_ut=TypeError,PU=Xee([].push),Tut=Xee([].join),qee=function(e){var r=Eut(e),n=Cut(r);if(!n)return"";for(var o=arguments.length,i=[],s=0;;){var a=r[s++];if(a===void 0)throw new _ut("Incorrect template");if(PU(i,IU(a)),s===n)return Tut(i,"");s<o&&PU(i,IU(arguments[s]))}},Aut=A,kut=qee;Aut({target:"String",stat:!0,forced:!0},{cooked:kut});var Out=A,Mut=au,EU=Nr,Rut=St,jut=Ee,Zee=et,Qee=Ch,Dut=Qee.codeAt,Lut=Qee.charAt,Jee="String Iterator",Nut=Zee.set,Fut=Zee.getterFor(Jee),But=Mut(function(e){Nut(this,{type:Jee,string:e,index:0})},"String",function(){var e=Fut(this),r=e.string,n=e.index,o;return n>=r.length?EU(void 0,!0):(o=Lut(r,n),e.index+=o.length,EU({codePoint:Dut(o,0),position:n},!1))});Out({target:"String",proto:!0,forced:!0},{codePoints:function(){return new But(jut(Rut(this)))}});var xy=V,by=WeakMap.prototype,zh={WeakMap,set:xy(by.set),get:xy(by.get),has:xy(by.has),remove:xy(by.delete)},Uut=be,W1=V,zut=String.fromCharCode,Hut=Uut("String","fromCodePoint"),GP=W1("".charAt),ete=W1("".charCodeAt),CU=W1("".indexOf),_U=W1("".slice),v2=48,tte=57,TU=97,Wut=102,AU=65,Kut=70,kU=function(t,e){var r=ete(t,e);return r>=v2&&r<=tte},VP=function(t,e,r){if(r>=t.length)return-1;for(var n=0;e<r;e++){var o=Gut(ete(t,e));if(o===-1)return-1;n=n*16+o}return n},Gut=function(t){return t>=v2&&t<=tte?t-v2:t>=TU&&t<=Wut?t-TU+10:t>=AU&&t<=Kut?t-AU+10:-1},Vut=function(t){for(var e="",r=0,n=0,o;(n=CU(t,"\\",n))>-1;){if(e+=_U(t,r,n),++n===t.length)return;var i=GP(t,n++);switch(i){case"b":e+="\b";break;case"t":e+=" ";break;case"n":e+=`
|
|
102
|
-
`;break;case"v":e+="\v";break;case"f":e+="\f";break;case"r":e+="\r";break;case"\r":n<t.length&&GP(t,n)===`
|
|
103
|
-
`&&++n;case`
|
|
104
|
-
`:case"\u2028":case"\u2029":break;case"0":if(kU(t,n))return;e+="\0";break;case"x":if(o=VP(t,n,n+2),o===-1)return;n+=2,e+=zut(o);break;case"u":if(n<t.length&&GP(t,n)==="{"){var s=CU(t,"}",++n);if(s===-1)return;o=VP(t,n,s),n=s+1}else o=VP(t,n,n+4),n+=4;if(o===-1||o>1114111)return;e+=Hut(o);break;default:if(kU(i,0))return;e+=i}r=n}return e+_U(t,r)},Yut=Wl,Xut=A,qut=Rx,K1=V,rte=yn,nte=re,Zut=je,Qut=Ce,Jut=Ke,edt=ut.f,tdt=Io,G1=zh,rdt=qee,ndt=Vut,ote=Lh,YP=new G1.WeakMap,odt=G1.get,idt=G1.has,sdt=G1.set,y2=Array,ip=TypeError,OU=Object.freeze||Object,adt=Object.isFrozen,ldt=Math.min,MU=K1("".charAt),ite=K1("".slice),cdt=K1("".split),RU=K1(/./.exec),udt=/([\n\u2028\u2029]|\r\n?)/g,ddt=RegExp("^["+ote+"]*"),hdt=RegExp("[^"+ote+"]"),jU="Invalid tag",fdt="Invalid opening line",pdt="Invalid closing line",gdt=function(t){var e=t.raw;if(Yut&&!adt(e))throw new ip("Raw template should be frozen");if(idt(YP,e))return odt(YP,e);var r=mdt(e),n=ydt(r);return edt(n,"raw",{value:OU(r)}),OU(n),sdt(YP,e,n),n},mdt=function(t){var e=Zut(t),r=Jut(e),n=y2(r),o=y2(r),i=0,s,a,l,c;if(!r)throw new ip(jU);for(;i<r;i++){var u=e[i];if(typeof u=="string")n[i]=cdt(u,udt);else throw new ip(jU)}for(i=0;i<r;i++){var d=i+1===r;if(s=n[i],i===0){if(s.length===1||s[0].length>0)throw new ip(fdt);s[1]=""}if(d){if(s.length===1||RU(hdt,s[s.length-1]))throw new ip(pdt);s[s.length-2]="",s[s.length-1]=""}for(var f=2;f<s.length;f+=2){var p=s[f],g=f+1===s.length&&!d,m=RU(ddt,p)[0];if(!g&&m.length===p.length){s[f]="";continue}a=vdt(m,a)}}var S=a?a.length:0;for(i=0;i<r;i++){for(s=n[i],l=s[0],c=1;c<s.length;c+=2)l+=s[c]+ite(s[c+1],S);o[i]=l}return o},vdt=function(t,e){if(e===void 0||t===e)return t;for(var r=0,n=ldt(t.length,e.length);r<n&&MU(t,r)===MU(e,r);r++);return ite(t,0,r)},ydt=function(t){for(var e=0,r=t.length,n=y2(r);e<r;e++)n[e]=ndt(t[e]);return n},ste=function(t){return qut(function(e){var r=tdt(arguments);return r[0]=gdt(nte(e)),rte(t,this,r)},"")},Sdt=ste(rdt);Xut({target:"String",stat:!0,forced:!0},{dedent:function(e){return nte(e),Qut(e)?ste(e):rte(Sdt,this,arguments)}});var wdt=te,xdt=Ut,bdt=ut.f,$dt=vr.f,XP=wdt.Symbol;xdt("asyncDispose");if(XP){var $y=$dt(XP,"asyncDispose");$y.enumerable&&$y.configurable&&$y.writable&&bdt(XP,"asyncDispose",{value:$y.value,enumerable:!1,configurable:!1,writable:!1})}var Idt=Ut;Idt("customMatcher");var Pdt=te,Edt=Ut,Cdt=ut.f,_dt=vr.f,qP=Pdt.Symbol;Edt("dispose");if(qP){var Iy=_dt(qP,"dispose");Iy.enumerable&&Iy.configurable&&Iy.writable&&Cdt(qP,"dispose",{value:Iy.value,enumerable:!1,configurable:!1,writable:!1})}var Tdt=be,Adt=V,pR=Tdt("Symbol"),kdt=pR.keyFor,Odt=Adt(pR.prototype.valueOf),ate=pR.isRegisteredSymbol||function(e){try{return kdt(Odt(e))!==void 0}catch{return!1}},Mdt=A,Rdt=ate;Mdt({target:"Symbol",stat:!0},{isRegisteredSymbol:Rdt});var jdt=A,Ddt=ate;jdt({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:Ddt});var Ldt=jl,lte=be,Ndt=V,Fdt=Rl,Bdt=ve,j0=lte("Symbol"),DU=j0.isWellKnownSymbol,cte=lte("Object","getOwnPropertyNames"),Udt=Ndt(j0.prototype.valueOf),LU=Ldt("wks");for(var ZP=0,NU=cte(j0),zdt=NU.length;ZP<zdt;ZP++)try{var FU=NU[ZP];Fdt(j0[FU])&&Bdt(FU)}catch{}var ute=function(e){if(DU&&DU(e))return!0;try{for(var r=Udt(e),n=0,o=cte(LU),i=o.length;n<i;n++)if(LU[o[n]]==r)return!0}catch{}return!1},Hdt=A,Wdt=ute;Hdt({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Wdt});var Kdt=A,Gdt=ute;Kdt({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Gdt});var Vdt=Ut;Vdt("matcher");var Ydt=Ut;Ydt("metadata");var Xdt=Ut;Xdt("metadataKey");var qdt=Ut;qdt("observable");var Zdt=Ut;Zdt("patternMatch");var Qdt=Ut;Qdt("replaceAll");var Jdt=be,eht=m1,tht=sJ,dte=Oe,rht=zl,nht=dte.aTypedArrayConstructor,oht=dte.exportTypedArrayStaticMethod;oht("fromAsync",function(e){var r=this,n=arguments.length,o=n>1?arguments[1]:void 0,i=n>2?arguments[2]:void 0;return new(Jdt("Promise"))(function(s){eht(r),s(tht(e,o,i))}).then(function(s){return rht(nht(r),s)})},!0);var hte=Oe,iht=Jt.filterReject,sht=OM,aht=hte.aTypedArray,lht=hte.exportTypedArrayMethod;lht("filterOut",function(e){var r=iht(aht(this),e,arguments.length>1?arguments[1]:void 0);return sht(this,r)},!0);var fte=Oe,cht=Jt.filterReject,uht=OM,dht=fte.aTypedArray,hht=fte.exportTypedArrayMethod;hht("filterReject",function(e){var r=cht(dht(this),e,arguments.length>1?arguments[1]:void 0);return uht(this,r)},!0);var pte=Oe,fht=UM,pht=Sm,ght=pte.aTypedArray,mht=pte.exportTypedArrayMethod;mht("groupBy",function(e){var r=arguments.length>1?arguments[1]:void 0;return fht(ght(this),e,r,pht)},!0);var gR=Oe,vht=Ke,yht=AM,Sht=ms,wht=T1,xht=Et,bht=q,$ht=gR.aTypedArray,Iht=gR.getTypedArrayConstructor,Pht=gR.exportTypedArrayMethod,Eht=Math.max,Cht=Math.min,_ht=!bht(function(){var t=new Int8Array([1]),e=t.toSpliced(1,0,{valueOf:function(){return t[0]=2,3}});return e[0]!==2||e[1]!==3});Pht("toSpliced",function(e,r){var n=$ht(this),o=Iht(n),i=vht(n),s=Sht(e,i),a=arguments.length,l=0,c,u,d,f,p,g,m;if(a===0)c=u=0;else if(a===1)c=0,u=i-s;else if(u=Cht(Eht(xht(r),0),i-s),c=a-2,c){f=new o(c),d=yht(f);for(var S=2;S<a;S++)p=arguments[S],f[S-2]=d?wht(p):+p}for(g=i+c-u,m=new o(g);l<s;l++)m[l]=n[l];for(;l<s+c;l++)m[l]=f[l-s];for(;l<g;l++)m[l]=n[l+u-c];return m},!_ht);var Tht=V,mR=Oe,Aht=zl,kht=HM,Oht=mR.aTypedArray,Mht=mR.getTypedArrayConstructor,Rht=mR.exportTypedArrayMethod,jht=Tht(kht);Rht("uniqueBy",function(e){return Oht(this),Aht(Mht(this),jht(this,e))},!0);var Dht=Ie,Lht=String,Nht=TypeError,gte=function(t){if(t===void 0||Dht(t))return t;throw new Nht(Lht(t)+" is not an object or undefined")},mte="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",BU=mte+"+/",UU=mte+"-_",zU=function(t){for(var e={},r=0;r<64;r++)e[t.charAt(r)]=r;return e},V1={i2c:BU,c2i:zU(BU),i2cUrl:UU,c2iUrl:zU(UU)},Fht=TypeError,vte=function(t){var e=t&&t.alphabet;if(e===void 0||e==="base64"||e==="base64url")return e||"base64";throw new Fht("Incorrect `alphabet` option")},yte=te,Bht=V,Uht=gte,zht=H1,Hht=ke,Ste=V1,Wht=vte,Kht=dm,Ght=Ste.c2i,Vht=Ste.c2iUrl,Ba=yte.SyntaxError,Yht=yte.TypeError,wc=Bht("".charAt),QP=function(t,e){for(var r=t.length;e<r;e++){var n=wc(t,e);if(n!==" "&&n!==" "&&n!==`
|
|
105
|
-
`&&n!=="\f"&&n!=="\r")break}return e},JP=function(t,e,r){var n=t.length;n<4&&(t+=n===2?"AA":"A");var o=(e[wc(t,0)]<<18)+(e[wc(t,1)]<<12)+(e[wc(t,2)]<<6)+e[wc(t,3)],i=[o>>16&255,o>>8&255,o&255];if(n===2){if(r&&i[1]!==0)throw new Ba("Extra bits");return[i[0]]}if(n===3){if(r&&i[2]!==0)throw new Ba("Extra bits");return[i[0],i[1]]}return i},eE=function(t,e,r){for(var n=e.length,o=0;o<n;o++)t[r+o]=e[o];return r+n},wte=function(t,e,r,n){zht(t),Uht(e);var o=Wht(e)==="base64"?Ght:Vht,i=e?e.lastChunkHandling:void 0;if(i===void 0&&(i="loose"),i!=="loose"&&i!=="strict"&&i!=="stop-before-partial")throw new Yht("Incorrect `lastChunkHandling` option");r&&Kht(r.buffer);var s=r||[],a=0,l=0,c="",u=0;if(n)for(;;){if(u=QP(t,u),u===t.length){if(c.length>0){if(i==="stop-before-partial")break;if(i==="loose"){if(c.length===1)throw new Ba("Malformed padding: exactly one additional character");a=eE(s,JP(c,o,!1),a)}else throw new Ba("Missing padding")}l=t.length;break}var d=wc(t,u);if(++u,d==="="){if(c.length<2)throw new Ba("Padding is too early");if(u=QP(t,u),c.length===2){if(u===t.length){if(i==="stop-before-partial")break;throw new Ba("Malformed padding: only one =")}wc(t,u)==="="&&(++u,u=QP(t,u))}if(u<t.length)throw new Ba("Unexpected character after padding");a=eE(s,JP(c,o,i==="strict"),a),l=t.length;break}if(!Hht(o,d))throw new Ba("Unexpected character");var f=n-a;if(f===1&&c.length===2||f===2&&c.length===3||(c+=d,c.length===4&&(a=eE(s,JP(c,o,!1),a),c="",l=u,a===n)))break}return{bytes:s,read:l,written:a}},Xht=A,qht=te,Zht=zl,Qht=wte,HU=qht.Uint8Array;HU&&Xht({target:"Uint8Array",stat:!0},{fromBase64:function(e){var r=Qht(e,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return Zht(HU,r.bytes)}});var vR=te,xte=V,Jht=vR.Uint8Array,WU=vR.SyntaxError,eft=vR.parseInt,tft=Math.min,bte=/[^\da-f]/i,rft=xte(bte.exec),nft=xte("".slice),$te=function(t,e){var r=t.length;if(r%2!==0)throw new WU("String should be an even number of characters");for(var n=e?tft(e.length,r/2):r/2,o=e||new Jht(n),i=0,s=0;s<n;){var a=nft(t,i,i+=2);if(rft(bte,a))throw new WU("String should only contain hex characters");o[s++]=eft(a,16)}return{bytes:o,read:i}},oft=A,ift=te,sft=H1,aft=$te;ift.Uint8Array&&oft({target:"Uint8Array",stat:!0},{fromHex:function(e){return aft(sft(e)).bytes}});var lft=bo,cft=TypeError,Y1=function(t){if(lft(t)==="Uint8Array")return t;throw new cft("Argument is not an Uint8Array")},uft=A,dft=te,hft=wte,fft=Y1,pft=dft.Uint8Array;pft&&uft({target:"Uint8Array",proto:!0},{setFromBase64:function(e){fft(this);var r=hft(e,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:r.read,written:r.written}}});var gft=A,mft=te,vft=H1,yft=Y1,Sft=dm,wft=$te;mft.Uint8Array&&gft({target:"Uint8Array",proto:!0},{setFromHex:function(e){yft(this),vft(e),Sft(this.buffer);var r=wft(e,this).read;return{read:r,written:r/2}}});var xft=A,bft=te,$ft=V,Ift=gte,Pft=Y1,Eft=dm,Ite=V1,Cft=vte,_ft=Ite.i2c,Tft=Ite.i2cUrl,Aft=$ft("".charAt);bft.Uint8Array&&xft({target:"Uint8Array",proto:!0},{toBase64:function(){var e=Pft(this),r=arguments.length?Ift(arguments[0]):void 0,n=Cft(r)==="base64"?_ft:Tft,o=!!r&&!!r.omitPadding;Eft(this.buffer);for(var i="",s=0,a=e.length,l,c=function(u){return Aft(n,l>>6*u&63)};s+2<a;s+=3)l=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i+=c(3)+c(2)+c(1)+c(0);return s+2===a?(l=(e[s]<<16)+(e[s+1]<<8),i+=c(3)+c(2)+c(1)+(o?"":"=")):s+1===a&&(l=e[s]<<16,i+=c(3)+c(2)+(o?"":"==")),i}});var kft=A,Oft=te,Mft=V,Rft=Y1,jft=dm,Dft=Mft(1 .toString);Oft.Uint8Array&&kft({target:"Uint8Array",proto:!0},{toHex:function(){Rft(this),jft(this.buffer);for(var e="",r=0,n=this.length;r<n;r++){var o=Dft(this[r],16);e+=o.length===1?"0"+o:o}return e}});var Lft=zh.has,Pte=function(t){return Lft(t),t},Nft=A,Fft=Pte,Bft=zh.remove;Nft({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e=Fft(this),r=!0,n,o=0,i=arguments.length;o<i;o++)n=Bft(e,arguments[o]),r=r&&n;return!!r}});var Uft=A,KU=zh,zft=U1;Uft({target:"WeakMap",stat:!0,forced:!0},{from:zft(KU.WeakMap,KU.set,!0)});var Hft=A,GU=zh,Wft=z1;Hft({target:"WeakMap",stat:!0,forced:!0},{of:Wft(GU.WeakMap,GU.set,!0)});var Kft=A,Gft=Pte,yR=zh,Vft=yR.get,Yft=yR.has,VU=yR.set;Kft({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:function(e,r){var n=Gft(this),o,i;return Yft(n,e)?(o=Vft(n,e),"update"in r&&(o=r.update(o,e,n),VU(n,e,o)),o):(i=r.insert(e,n),VU(n,e,i),i)}});var Xft=A,qft=rR;Xft({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:qft});var tE=V,rE=WeakSet.prototype,Cm={WeakSet,add:tE(rE.add),has:tE(rE.has),remove:tE(rE.delete)},Zft=Cm.has,Ete=function(t){return Zft(t),t},Qft=A,Jft=Ete,ept=Cm.add;Qft({target:"WeakSet",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=Jft(this),r=0,n=arguments.length;r<n;r++)ept(e,arguments[r]);return e}});var tpt=A,rpt=Ete,npt=Cm.remove;tpt({target:"WeakSet",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e=rpt(this),r=!0,n,o=0,i=arguments.length;o<i;o++)n=npt(e,arguments[o]),r=r&&n;return!!r}});var opt=A,YU=Cm,ipt=U1;opt({target:"WeakSet",stat:!0,forced:!0},{from:ipt(YU.WeakSet,YU.add,!1)});var spt=A,XU=Cm,apt=z1;spt({target:"WeakSet",stat:!0,forced:!0},{of:apt(XU.WeakSet,XU.add,!1)});var lpt=A,cpt=te,Cte=be,SR=V,upt=ne,X1=q,dpt=Ee,hpt=Zo,qU=V1.c2i,_te=/[^\d+/a-z]/i,fpt=/[\t\n\f\r ]+/g,ppt=/[=]{1,2}$/,Hc=Cte("atob"),gpt=String.fromCharCode,mpt=SR("".charAt),ZU=SR("".replace),vpt=SR(_te.exec),Hh=!!Hc&&!X1(function(){return Hc("aGk=")!=="hi"}),Tte=Hh&&X1(function(){return Hc(" ")!==""}),Ate=Hh&&!X1(function(){Hc("a")}),ypt=Hh&&!X1(function(){Hc()}),Spt=Hh&&Hc.length!==1,wpt=!Hh||Tte||Ate||ypt||Spt;lpt({global:!0,bind:!0,enumerable:!0,forced:wpt},{atob:function(e){if(hpt(arguments.length,1),Hh&&!Tte&&!Ate)return upt(Hc,cpt,e);var r=ZU(dpt(e),fpt,""),n="",o=0,i=0,s,a,l;if(r.length%4===0&&(r=ZU(r,ppt,"")),s=r.length,s%4===1||vpt(_te,r))throw new(Cte("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;o<s;)a=mpt(r,o++),l=i%4?l*64+qU[a]:qU[a],i++%4&&(n+=gpt(255&l>>(-2*i&6)));return n}});var xpt=A,bpt=te,kte=be,Ote=V,$pt=ne,wR=q,QU=Ee,Ipt=Zo,Ppt=V1.i2c,sh=kte("btoa"),JU=Ote("".charAt),Ept=Ote("".charCodeAt),$g=!!sh&&!wR(function(){return sh("hi")!=="aGk="}),Cpt=$g&&!wR(function(){sh()}),_pt=$g&&wR(function(){return sh(null)!=="bnVsbA=="}),Tpt=$g&&sh.length!==1;xpt({global:!0,bind:!0,enumerable:!0,forced:!$g||Cpt||_pt||Tpt},{btoa:function(e){if(Ipt(arguments.length,1),$g)return $pt(sh,bpt,QU(e));for(var r=QU(e),n="",o=0,i=Ppt,s,a;JU(r,o)||(i="=",o%1);){if(a=Ept(r,o+=3/4),a>255)throw new(kte("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");s=s<<8|a,n+=JU(i,63&s>>8-o%1*8)}return n}});var Mte={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Apt=kx,nE=Apt("span").classList,ez=nE&&nE.constructor&&nE.constructor.prototype,Rte=ez===Object.prototype?void 0:ez,tz=te,rz=Mte,kpt=Rte,oE=XY,Opt=sr,jte=function(t){if(t&&t.forEach!==oE)try{Opt(t,"forEach",oE)}catch{t.forEach=oE}};for(var iE in rz)rz[iE]&&jte(tz[iE]&&tz[iE].prototype);jte(kpt);var nz=te,Dte=Mte,Mpt=Rte,sp=iX,oz=sr,Rpt=Gn,jpt=ve,sE=jpt("iterator"),aE=sp.values,Lte=function(t,e){if(t){if(t[sE]!==aE)try{oz(t,sE,aE)}catch{t[sE]=aE}if(Rpt(t,e,!0),Dte[e]){for(var r in sp)if(t[r]!==sp[r])try{oz(t,r,sp[r])}catch{t[r]=sp[r]}}}};for(var lE in Dte)Lte(nz[lE]&&nz[lE].prototype,lE);Lte(Mpt,"DOMTokenList");var Nte={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}},Dpt=A,D0=be,Lpt=jX,xR=q,Npt=ar,bR=wo,L0=ut.f,Fpt=nt,MS=Ct,RS=ke,Bpt=wn,Upt=re,Fte=HY,iz=kh,Dd=Nte,zpt=PO,Bte=et,$R=ge,ah="DOMException",S2="DATA_CLONE_ERR",q1=D0("Error"),ua=D0(ah)||function(){try{var t=D0("MessageChannel")||Lpt("worker_threads").MessageChannel;new t().port1.postMessage(new WeakMap)}catch(e){if(e.name===S2&&e.code===25)return e.constructor}}(),Hpt=ua&&ua.prototype,Ute=q1.prototype,Wpt=Bte.set,Kpt=Bte.getterFor(ah),Gpt="stack"in new q1(ah),zte=function(t){return RS(Dd,t)&&Dd[t].m?Dd[t].c:0},IR=function(){Bpt(this,Dp);var e=arguments.length,r=iz(e<1?void 0:arguments[0]),n=iz(e<2?void 0:arguments[1],"Error"),o=zte(n);if(Wpt(this,{type:ah,name:n,message:r,code:o}),$R||(this.name=n,this.message=r,this.code=o),Gpt){var i=new q1(r);i.name=ah,L0(this,"stack",bR(1,zpt(i.stack,1)))}},Dp=IR.prototype=Npt(Ute),Hte=function(t){return{enumerable:!0,configurable:!0,get:t}},cE=function(t){return Hte(function(){return Kpt(this)[t]})};$R&&(MS(Dp,"code",cE("code")),MS(Dp,"message",cE("message")),MS(Dp,"name",cE("name")));L0(Dp,"constructor",bR(1,IR));var Z1=xR(function(){return!(new ua instanceof q1)}),Vpt=Z1||xR(function(){return Ute.toString!==Fte||String(new ua(1,2))!=="2: 1"}),Ypt=Z1||xR(function(){return new ua(1,"DataCloneError").code!==25});Z1||ua[S2]!==25||Hpt[S2];var sz=Z1;Dpt({global:!0,constructor:!0,forced:sz},{DOMException:sz?IR:ua});var Ig=D0(ah),N0=Ig.prototype;Vpt&&ua===Ig&&Fpt(N0,"toString",Fte);Ypt&&$R&&ua===Ig&&MS(N0,"code",Hte(function(){return zte(Upt(this).name)}));for(var az in Dd)if(RS(Dd,az)){var lz=Dd[az],Py=lz.s,cz=bR(6,lz.c);RS(Ig,Py)||L0(Ig,Py,cz),RS(N0,Py)||L0(N0,Py,cz)}var Xpt=A,qpt=te,PR=be,w2=wo,x2=ut.f,uz=ke,Zpt=wn,Qpt=ou,dz=kh,uE=Nte,Jpt=PO,egt=ge,_m="DOMException",Wte=PR("Error"),Tm=PR(_m),ER=function(){Zpt(this,tgt);var e=arguments.length,r=dz(e<1?void 0:arguments[0]),n=dz(e<2?void 0:arguments[1],"Error"),o=new Tm(r,n),i=new Wte(r);return i.name=_m,x2(o,"stack",w2(1,Jpt(i.stack,1))),Qpt(o,this,ER),o},tgt=ER.prototype=Tm.prototype,rgt="stack"in new Wte(_m),ngt="stack"in new Tm(1,2),dE=Tm&&egt&&Object.getOwnPropertyDescriptor(qpt,_m),ogt=!!dE&&!(dE.writable&&dE.configurable),hz=rgt&&!ogt&&!ngt;Xpt({global:!0,constructor:!0,forced:hz},{DOMException:hz?ER:Tm});var ap=PR(_m),fz=ap.prototype;if(fz.constructor!==ap){x2(fz,"constructor",w2(1,ap));for(var pz in uE)if(uz(uE,pz)){var gz=uE[pz],mz=gz.s;uz(ap,mz)||x2(ap,mz,w2(6,gz.c))}}var igt=be,sgt=Gn,vz="DOMException";sgt(igt(vz),vz);var agt=A,lgt=te,yz=E1.clear;agt({global:!0,bind:!0,enumerable:!0,forced:lgt.clearImmediate!==yz},{clearImmediate:yz});var Kte=te,cgt=yn,ugt=Ce,dgt=u1,hgt=gs,fgt=Io,pgt=Zo,ggt=Kte.Function,mgt=/MSIE .\./.test(hgt)||dgt==="BUN"&&function(){var t=Kte.Bun.version.split(".");return t.length<3||t[0]==="0"&&(t[1]<3||t[1]==="3"&&t[2]==="0")}(),CR=function(t,e){var r=e?2:1;return mgt?function(n,o){var i=pgt(arguments.length,1)>r,s=ugt(n)?n:ggt(n),a=i?fgt(arguments,r):[],l=i?function(){cgt(s,this,a)}:s;return e?t(l,o):t(l)}:t},vgt=A,Gte=te,Sz=E1.set,ygt=CR,wz=Gte.setImmediate?ygt(Sz,!1):Sz;vgt({global:!0,bind:!0,enumerable:!0,forced:Gte.setImmediate!==wz},{setImmediate:wz});var Sgt=A,wgt=te,xgt=Nq,bgt=Pe,$gt=Zo,Igt=q,Pgt=ge,Egt=Igt(function(){return Pgt&&Object.getOwnPropertyDescriptor(wgt,"queueMicrotask").value.length!==1});Sgt({global:!0,enumerable:!0,dontCallGetSet:!0,forced:Egt},{queueMicrotask:function(e){$gt(arguments.length,1),xgt(bgt(e))}});var Cgt=A,Ua=te,_gt=Ct,Tgt=ge,Agt=TypeError,kgt=Object.defineProperty,xz=Ua.self!==Ua;try{if(Tgt){var hE=Object.getOwnPropertyDescriptor(Ua,"self");(xz||!hE||!hE.get||!hE.enumerable)&&_gt(Ua,"self",{get:function(){return Ua},set:function(e){if(this!==Ua)throw new Agt("Illegal invocation");kgt(Ua,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else Cgt({global:!0,simple:!0,forced:xz},{self:Ua})}catch{}var Ogt=A,Mr=te,Lp=be,Am=V,_R=q,Mgt=ru,lh=Ce,Rgt=ys,jgt=nr,Q1=Ie,Dgt=Rl,Lgt=zt,Vte=re,F0=bo,Ngt=ke,Fgt=Ti,fE=sr,jS=Ke,Bgt=Zo,Ugt=Qg,J1=nn,TR=Fr,zgt=Po,bz=DX,Hgt=FY,AR=QO,lp=Mr.Object,Wgt=Mr.Array,Yte=Mr.Date,Xte=Mr.Error,Kgt=Mr.TypeError,Ggt=Mr.PerformanceMark,Wc=Lp("DOMException"),b2=J1.Map,kR=J1.has,qte=J1.get,B0=J1.set,Zte=TR.Set,Qte=TR.add,Vgt=TR.has,Ygt=Lp("Object","keys"),Xgt=Am([].push),qgt=Am((!0).valueOf),Zgt=Am(1 .valueOf),Qgt=Am("".valueOf),Jgt=Am(Yte.prototype.getTime),$2=Mgt("structuredClone"),Pg="DataCloneError",DS="Transferring",Jte=function(t){return!_R(function(){var e=new Mr.Set([7]),r=t(e),n=t(lp(7));return r===e||!r.has(7)||!Q1(n)||+n!=7})&&t},$z=function(t,e){return!_R(function(){var r=new e,n=t({a:r,b:r});return!(n&&n.a===n.b&&n.a instanceof e&&n.a.stack===r.stack)})},emt=function(t){return!_R(function(){var e=t(new Mr.AggregateError([1],$2,{cause:3}));return e.name!=="AggregateError"||e.errors[0]!==1||e.message!==$2||e.cause!==3})},Ld=Mr.structuredClone,tmt=!$z(Ld,Xte)||!$z(Ld,Wc)||!emt(Ld),rmt=!Ld&&Jte(function(t){return new Ggt($2,{detail:t}).detail}),Ks=Jte(Ld)||rmt,pE=function(t){throw new Wc("Uncloneable type: "+t,Pg)},An=function(t,e){throw new Wc((e||"Cloning")+" of "+t+" cannot be properly polyfilled in this engine",Pg)},gE=function(t,e){return Ks||An(e),Ks(t)},nmt=function(){var t;try{t=new Mr.DataTransfer}catch{try{t=new Mr.ClipboardEvent("").clipboardData}catch{}}return t&&t.items&&t.files?t:null},ere=function(t,e,r){if(kR(e,t))return qte(e,t);var n=r||F0(t),o,i,s,a,l,c;if(n==="SharedArrayBuffer")Ks?o=Ks(t):o=t;else{var u=Mr.DataView;!u&&!lh(t.slice)&&An("ArrayBuffer");try{if(lh(t.slice)&&!t.resizable)o=t.slice(0);else for(i=t.byteLength,s=("maxByteLength"in t)?{maxByteLength:t.maxByteLength}:void 0,o=new ArrayBuffer(i,s),a=new u(t),l=new u(o),c=0;c<i;c++)l.setUint8(c,a.getUint8(c))}catch{throw new Wc("ArrayBuffer is detached",Pg)}}return B0(e,t,o),o},omt=function(t,e,r,n,o){var i=Mr[e];return Q1(i)||An(e),new i(ere(t.buffer,o),r,n)},$r=function(t,e){if(Dgt(t)&&pE("Symbol"),!Q1(t))return t;if(e){if(kR(e,t))return qte(e,t)}else e=new b2;var r=F0(t),n,o,i,s,a,l,c,u;switch(r){case"Array":i=Wgt(jS(t));break;case"Object":i={};break;case"Map":i=new b2;break;case"Set":i=new Zte;break;case"RegExp":i=new RegExp(t.source,Ugt(t));break;case"Error":switch(o=t.name,o){case"AggregateError":i=new(Lp(o))([]);break;case"EvalError":case"RangeError":case"ReferenceError":case"SuppressedError":case"SyntaxError":case"TypeError":case"URIError":i=new(Lp(o));break;case"CompileError":case"LinkError":case"RuntimeError":i=new(Lp("WebAssembly",o));break;default:i=new Xte}break;case"DOMException":i=new Wc(t.message,t.name);break;case"ArrayBuffer":case"SharedArrayBuffer":i=ere(t,e,r);break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float16Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":l=r==="DataView"?t.byteLength:t.length,i=omt(t,r,t.byteOffset,l,e);break;case"DOMQuad":try{i=new DOMQuad($r(t.p1,e),$r(t.p2,e),$r(t.p3,e),$r(t.p4,e))}catch{i=gE(t,r)}break;case"File":if(Ks)try{i=Ks(t),F0(i)!==r&&(i=void 0)}catch{}if(!i)try{i=new File([t],t.name,t)}catch{}i||An(r);break;case"FileList":if(s=nmt(),s){for(a=0,l=jS(t);a<l;a++)s.items.add($r(t[a],e));i=s.files}else i=gE(t,r);break;case"ImageData":try{i=new ImageData($r(t.data,e),t.width,t.height,{colorSpace:t.colorSpace})}catch{i=gE(t,r)}break;default:if(Ks)i=Ks(t);else switch(r){case"BigInt":i=lp(t.valueOf());break;case"Boolean":i=lp(qgt(t));break;case"Number":i=lp(Zgt(t));break;case"String":i=lp(Qgt(t));break;case"Date":i=new Yte(Jgt(t));break;case"Blob":try{i=t.slice(0,t.size,t.type)}catch{An(r)}break;case"DOMPoint":case"DOMPointReadOnly":n=Mr[r];try{i=n.fromPoint?n.fromPoint(t):new n(t.x,t.y,t.z,t.w)}catch{An(r)}break;case"DOMRect":case"DOMRectReadOnly":n=Mr[r];try{i=n.fromRect?n.fromRect(t):new n(t.x,t.y,t.width,t.height)}catch{An(r)}break;case"DOMMatrix":case"DOMMatrixReadOnly":n=Mr[r];try{i=n.fromMatrix?n.fromMatrix(t):new n(t)}catch{An(r)}break;case"AudioData":case"VideoFrame":lh(t.clone)||An(r);try{i=t.clone()}catch{pE(r)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":An(r);default:pE(r)}}switch(B0(e,t,i),r){case"Array":case"Object":for(c=Ygt(t),a=0,l=jS(c);a<l;a++)u=c[a],Fgt(i,u,$r(t[u],e));break;case"Map":t.forEach(function(d,f){B0(i,$r(f,e),$r(d,e))});break;case"Set":t.forEach(function(d){Qte(i,$r(d,e))});break;case"Error":fE(i,"message",$r(t.message,e)),Ngt(t,"cause")&&fE(i,"cause",$r(t.cause,e)),o==="AggregateError"?i.errors=$r(t.errors,e):o==="SuppressedError"&&(i.error=$r(t.error,e),i.suppressed=$r(t.suppressed,e));case"DOMException":Hgt&&fE(i,"stack",$r(t.stack,e))}return i},imt=function(t,e){if(!Q1(t))throw new Kgt("Transfer option cannot be converted to a sequence");var r=[];Lgt(t,function(f){Xgt(r,Vte(f))});for(var n=0,o=jS(r),i=new Zte,s,a,l,c,u,d;n<o;){if(s=r[n++],a=F0(s),a==="ArrayBuffer"?Vgt(i,s):kR(e,s))throw new Wc("Duplicate transferable",Pg);if(a==="ArrayBuffer"){Qte(i,s);continue}if(AR)c=Ld(s,{transfer:[s]});else switch(a){case"ImageBitmap":l=Mr.OffscreenCanvas,Rgt(l)||An(a,DS);try{u=new l(s.width,s.height),d=u.getContext("bitmaprenderer"),d.transferFromImageBitmap(s),c=u.transferToImageBitmap()}catch{}break;case"AudioData":case"VideoFrame":(!lh(s.clone)||!lh(s.close))&&An(a,DS);try{c=s.clone(),s.close()}catch{}break;case"MediaSourceHandle":case"MessagePort":case"OffscreenCanvas":case"ReadableStream":case"TransformStream":case"WritableStream":An(a,DS)}if(c===void 0)throw new Wc("This object cannot be transferred: "+a,Pg);B0(e,s,c)}return i},smt=function(t){zgt(t,function(e){AR?Ks(e,{transfer:[e]}):lh(e.transfer)?e.transfer():bz?bz(e):An("ArrayBuffer",DS)})};Ogt({global:!0,enumerable:!0,sham:!AR,forced:tmt},{structuredClone:function(e){var r=Bgt(arguments.length,1)>1&&!jgt(arguments[1])?Vte(arguments[1]):void 0,n=r?r.transfer:void 0,o,i;n!==void 0&&(o=new b2,i=imt(n,o));var s=$r(e,o);return i&&smt(i),s}});var amt=A,tre=te,lmt=CR,Iz=lmt(tre.setInterval,!0);amt({global:!0,bind:!0,forced:tre.setInterval!==Iz},{setInterval:Iz});var cmt=A,rre=te,umt=CR,Pz=umt(rre.setTimeout,!0);cmt({global:!0,bind:!0,forced:rre.setTimeout!==Pz},{setTimeout:Pz});var dmt=q,hmt=ve,fmt=ge,Ez=ir,pmt=hmt("iterator"),eb=!dmt(function(){var t=new URL("b?a=1&b=2&c=3","https://a"),e=t.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return t.pathname="c%20d",e.forEach(function(o,i){e.delete("b"),n+=i+o}),r.delete("a",2),r.delete("b",void 0),Ez&&(!t.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b"))||!e.size&&(Ez||!fmt)||!e.sort||t.href!=="https://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[pmt]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("https://x",void 0).host!=="x"}),pu=V,mE=2147483647,Np=36,nre=1,I2=26,gmt=38,mmt=700,vmt=72,ymt=128,Smt="-",wmt=/[^\0-\u007E]/,ore=/[.\u3002\uFF0E\uFF61]/g,Cz="Overflow: input needs wider integers to process",vE=Np-nre,_z=RangeError,xmt=pu(ore.exec),gd=Math.floor,yE=String.fromCharCode,Tz=pu("".charCodeAt),ire=pu([].join),Ja=pu([].push),bmt=pu("".replace),$mt=pu("".split),Imt=pu("".toLowerCase),Pmt=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=Tz(t,r++);if(o>=55296&&o<=56319&&r<n){var i=Tz(t,r++);(i&64512)===56320?Ja(e,((o&1023)<<10)+(i&1023)+65536):(Ja(e,o),r--)}else Ja(e,o)}return e},Az=function(t){return t+22+75*(t<26)},Emt=function(t,e,r){var n=0;for(t=r?gd(t/mmt):t>>1,t+=gd(t/e);t>vE*I2>>1;)t=gd(t/vE),n+=Np;return gd(n+(vE+1)*t/(t+gmt))},Cmt=function(t){var e=[];t=Pmt(t);var r=t.length,n=ymt,o=0,i=vmt,s,a;for(s=0;s<t.length;s++)a=t[s],a<128&&Ja(e,yE(a));var l=e.length,c=l;for(l&&Ja(e,Smt);c<r;){var u=mE;for(s=0;s<t.length;s++)a=t[s],a>=n&&a<u&&(u=a);var d=c+1;if(u-n>gd((mE-o)/d))throw new _z(Cz);for(o+=(u-n)*d,n=u,s=0;s<t.length;s++){if(a=t[s],a<n&&++o>mE)throw new _z(Cz);if(a===n){for(var f=o,p=Np;;){var g=p<=i?nre:p>=i+I2?I2:p-i;if(f<g)break;var m=f-g,S=Np-g;Ja(e,yE(Az(g+m%S))),f=gd(m/S),p+=Np}Ja(e,yE(Az(f))),i=Emt(o,d,c===l),o=0,c++}}o++,n++}return ire(e,"")},_mt=function(t){var e=[],r=$mt(bmt(Imt(t),ore,"."),"."),n,o;for(n=0;n<r.length;n++)o=r[n],Ja(e,xmt(wmt,o)?"xn--"+Cmt(o):o);return ire(e,".")},P2=A,sre=te,OR=jq,Tmt=be,Ey=ne,$i=V,Fp=ge,are=eb,lre=nt,Amt=Ct,kmt=ki,Omt=Gn,Mmt=au,MR=et,cre=wn,SE=Ce,Rmt=ke,jmt=dt,Dmt=bo,Lmt=re,ure=Ie,un=Ee,Nmt=ar,kz=wo,Oz=su,Fmt=Bl,Cy=Nr,ku=Zo,Bmt=ve,Umt=DO,zmt=Bmt("iterator"),Wh="URLSearchParams",dre=Wh+"Iterator",hre=MR.set,Do=MR.getterFor(Wh),Hmt=MR.getterFor(dre),Mz=OR("fetch"),U0=OR("Request"),Bp=OR("Headers"),wE=U0&&U0.prototype,Rz=Bp&&Bp.prototype,Wmt=sre.TypeError,Kmt=sre.encodeURIComponent,Gmt=String.fromCharCode,Vmt=Tmt("String","fromCodePoint"),Ymt=parseInt,LS=$i("".charAt),jz=$i([].join),el=$i([].push),fre=$i("".replace),Xmt=$i([].shift),Dz=$i([].splice),Lz=$i("".split),pre=$i("".slice),qmt=$i(/./.exec),Zmt=/\+/g,xE="�",Qmt=/^[0-9a-f]+$/i,Nz=function(t,e){var r=pre(t,e,e+2);return qmt(Qmt,r)?Ymt(r,16):NaN},Jmt=function(t){for(var e=0,r=128;r>0&&t&r;r>>=1)e++;return e},evt=function(t){var e=null;switch(t.length){case 1:e=t[0];break;case 2:e=(t[0]&31)<<6|t[1]&63;break;case 3:e=(t[0]&15)<<12|(t[1]&63)<<6|t[2]&63;break;case 4:e=(t[0]&7)<<18|(t[1]&63)<<12|(t[2]&63)<<6|t[3]&63;break}return e>1114111?null:e},Fz=function(t){t=fre(t,Zmt," ");for(var e=t.length,r="",n=0;n<e;){var o=LS(t,n);if(o==="%"){if(LS(t,n+1)==="%"||n+3>e){r+="%",n++;continue}var i=Nz(t,n+1);if(i!==i){r+=o,n++;continue}n+=2;var s=Jmt(i);if(s===0)o=Gmt(i);else{if(s===1||s>4){r+=xE,n++;continue}for(var a=[i],l=1;l<s&&(n++,!(n+3>e||LS(t,n)!=="%"));){var c=Nz(t,n+1);if(c!==c){n+=3;break}if(c>191||c<128)break;el(a,c),n+=2,l++}if(a.length!==s){r+=xE;continue}var u=evt(a);u===null?r+=xE:o=Vmt(u)}}r+=o,n++}return r},tvt=/[!'()~]|%20/g,rvt={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},nvt=function(t){return rvt[t]},Bz=function(t){return fre(Kmt(t),tvt,nvt)},bE=Mmt(function(e,r){hre(this,{type:dre,target:Do(e).entries,index:0,kind:r})},Wh,function(){var e=Hmt(this),r=e.target,n=e.index++;if(!r||n>=r.length)return e.target=null,Cy(void 0,!0);var o=r[n];switch(e.kind){case"keys":return Cy(o.key,!1);case"values":return Cy(o.value,!1)}return Cy([o.key,o.value],!1)},!0),gre=function(t){this.entries=[],this.url=null,t!==void 0&&(ure(t)?this.parseObject(t):this.parseQuery(typeof t=="string"?LS(t,0)==="?"?pre(t,1):t:un(t)))};gre.prototype={type:Wh,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var e=this.entries,r=Fmt(t),n,o,i,s,a,l,c;if(r)for(n=Oz(t,r),o=n.next;!(i=Ey(o,n)).done;){if(s=Oz(Lmt(i.value)),a=s.next,(l=Ey(a,s)).done||(c=Ey(a,s)).done||!Ey(a,s).done)throw new Wmt("Expected sequence with length 2");el(e,{key:un(l.value),value:un(c.value)})}else for(var u in t)Rmt(t,u)&&el(e,{key:u,value:un(t[u])})},parseQuery:function(t){if(t)for(var e=this.entries,r=Lz(t,"&"),n=0,o,i;n<r.length;)o=r[n++],o.length&&(i=Lz(o,"="),el(e,{key:Fz(Xmt(i)),value:Fz(jz(i,"="))}))},serialize:function(){for(var t=this.entries,e=[],r=0,n;r<t.length;)n=t[r++],el(e,Bz(n.key)+"="+Bz(n.value));return jz(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var tb=function(){cre(this,ch);var e=arguments.length>0?arguments[0]:void 0,r=hre(this,new gre(e));Fp||(this.size=r.entries.length)},ch=tb.prototype;kmt(ch,{append:function(e,r){var n=Do(this);ku(arguments.length,2),el(n.entries,{key:un(e),value:un(r)}),Fp||this.length++,n.updateURL()},delete:function(t){for(var e=Do(this),r=ku(arguments.length,1),n=e.entries,o=un(t),i=r<2?void 0:arguments[1],s=i===void 0?i:un(i),a=0;a<n.length;){var l=n[a];if(l.key===o&&(s===void 0||l.value===s)){if(Dz(n,a,1),s!==void 0)break}else a++}Fp||(this.size=n.length),e.updateURL()},get:function(e){var r=Do(this).entries;ku(arguments.length,1);for(var n=un(e),o=0;o<r.length;o++)if(r[o].key===n)return r[o].value;return null},getAll:function(e){var r=Do(this).entries;ku(arguments.length,1);for(var n=un(e),o=[],i=0;i<r.length;i++)r[i].key===n&&el(o,r[i].value);return o},has:function(e){for(var r=Do(this).entries,n=ku(arguments.length,1),o=un(e),i=n<2?void 0:arguments[1],s=i===void 0?i:un(i),a=0;a<r.length;){var l=r[a++];if(l.key===o&&(s===void 0||l.value===s))return!0}return!1},set:function(e,r){var n=Do(this);ku(arguments.length,1);for(var o=n.entries,i=!1,s=un(e),a=un(r),l=0,c;l<o.length;l++)c=o[l],c.key===s&&(i?Dz(o,l--,1):(i=!0,c.value=a));i||el(o,{key:s,value:a}),Fp||(this.size=o.length),n.updateURL()},sort:function(){var e=Do(this);Umt(e.entries,function(r,n){return r.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var r=Do(this).entries,n=jmt(e,arguments.length>1?arguments[1]:void 0),o=0,i;o<r.length;)i=r[o++],n(i.value,i.key,this)},keys:function(){return new bE(this,"keys")},values:function(){return new bE(this,"values")},entries:function(){return new bE(this,"entries")}},{enumerable:!0});lre(ch,zmt,ch.entries,{name:"entries"});lre(ch,"toString",function(){return Do(this).serialize()},{enumerable:!0});Fp&&Amt(ch,"size",{get:function(){return Do(this).entries.length},configurable:!0,enumerable:!0});Omt(tb,Wh);P2({global:!0,constructor:!0,forced:!are},{URLSearchParams:tb});if(!are&&SE(Bp)){var ovt=$i(Rz.has),ivt=$i(Rz.set),Uz=function(t){if(ure(t)){var e=t.body,r;if(Dmt(e)===Wh)return r=t.headers?new Bp(t.headers):new Bp,ovt(r,"content-type")||ivt(r,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Nmt(t,{body:kz(0,un(e)),headers:kz(0,r)})}return t};if(SE(Mz)&&P2({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Mz(e,arguments.length>1?Uz(arguments[1]):{})}}),SE(U0)){var $E=function(e){return cre(this,wE),new U0(e,arguments.length>1?Uz(arguments[1]):{})};wE.constructor=$E,$E.prototype=wE,P2({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:$E})}}var svt={URLSearchParams:tb,getState:Do},avt=A,RR=ge,lvt=eb,jR=te,zz=dt,Qo=V,z0=nt,Oo=Ct,cvt=wn,E2=ke,DR=xq,Ou=qY,oi=Io,uvt=Ch.codeAt,dvt=_mt,Rs=Ee,hvt=Gn,fvt=Zo,mre=svt,vre=et,pvt=vre.set,H0=vre.getterFor("URL"),gvt=mre.URLSearchParams,mvt=mre.getState,Lf=jR.URL,C2=jR.TypeError,W0=jR.parseInt,vvt=Math.floor,Hz=Math.pow,zo=Qo("".charAt),hi=Qo(/./.exec),cp=Qo([].join),yvt=Qo(1 .toString),Svt=Qo([].pop),Gu=Qo([].push),IE=Qo("".replace),wvt=Qo([].shift),xvt=Qo("".split),Up=Qo("".slice),K0=Qo("".toLowerCase),bvt=Qo([].unshift),$vt="Invalid authority",PE="Invalid scheme",uc="Invalid host",Wz="Invalid port",yre=/[a-z]/i,Ivt=/[\d+-.a-z]/i,_2=/\d/,Pvt=/^0x/i,Evt=/^[0-7]+$/,Cvt=/^\d+$/,Sre=/^[\da-f]+$/i,_vt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Tvt=/[\0\t\n\r #/:<>?@[\\\]^|]/,Avt=/^[\u0000-\u0020]+/,kvt=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Ovt=/[\t\n\r]/g,Mo,Mvt=function(t){var e=xvt(t,"."),r,n,o,i,s,a,l;if(e.length&&e[e.length-1]===""&&e.length--,r=e.length,r>4)return t;for(n=[],o=0;o<r;o++){if(i=e[o],i==="")return t;if(s=10,i.length>1&&zo(i,0)==="0"&&(s=hi(Pvt,i)?16:8,i=Up(i,s===8?1:2)),i==="")a=0;else{if(!hi(s===10?Cvt:s===8?Evt:Sre,i))return t;a=W0(i,s)}Gu(n,a)}for(o=0;o<r;o++)if(a=n[o],o===r-1){if(a>=Hz(256,5-r))return null}else if(a>255)return null;for(l=Svt(n),o=0;o<n.length;o++)l+=n[o]*Hz(256,3-o);return l},Rvt=function(t){var e=[0,0,0,0,0,0,0,0],r=0,n=null,o=0,i,s,a,l,c,u,d,f=function(){return zo(t,o)};if(f()===":"){if(zo(t,1)!==":")return;o+=2,r++,n=r}for(;f();){if(r===8)return;if(f()===":"){if(n!==null)return;o++,r++,n=r;continue}for(i=s=0;s<4&&hi(Sre,f());)i=i*16+W0(f(),16),o++,s++;if(f()==="."){if(s===0||(o-=s,r>6))return;for(a=0;f();){if(l=null,a>0)if(f()==="."&&a<4)o++;else return;if(!hi(_2,f()))return;for(;hi(_2,f());){if(c=W0(f(),10),l===null)l=c;else{if(l===0)return;l=l*10+c}if(l>255)return;o++}e[r]=e[r]*256+l,a++,(a===2||a===4)&&r++}if(a!==4)return;break}else if(f()===":"){if(o++,!f())return}else if(f())return;e[r++]=i}if(n!==null)for(u=r-n,r=7;r!==0&&u>0;)d=e[r],e[r--]=e[n+u-1],e[n+--u]=d;else if(r!==8)return;return e},jvt=function(t){for(var e=null,r=1,n=null,o=0,i=0;i<8;i++)t[i]!==0?(o>r&&(e=n,r=o),n=null,o=0):(n===null&&(n=i),++o);return o>r?n:e},Nf=function(t){var e,r,n,o;if(typeof t=="number"){for(e=[],r=0;r<4;r++)bvt(e,t%256),t=vvt(t/256);return cp(e,".")}if(typeof t=="object"){for(e="",n=jvt(t),r=0;r<8;r++)o&&t[r]===0||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=yvt(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},NS={},wre=DR({},NS,{" ":1,'"':1,"<":1,">":1,"`":1}),xre=DR({},wre,{"#":1,"?":1,"{":1,"}":1}),EE=DR({},xre,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Oa=function(t,e){var r=uvt(t,0);return r>32&&r<127&&!E2(e,t)?t:encodeURIComponent(t)},_y={ftp:21,file:null,http:80,https:443,ws:80,wss:443},up=function(t,e){var r;return t.length===2&&hi(yre,zo(t,0))&&((r=zo(t,1))===":"||!e&&r==="|")},Kz=function(t){var e;return t.length>1&&up(Up(t,0,2))&&(t.length===2||(e=zo(t,2))==="/"||e==="\\"||e==="?"||e==="#")},Dvt=function(t){return t==="."||K0(t)==="%2e"},Lvt=function(t){return t=K0(t),t===".."||t==="%2e."||t===".%2e"||t==="%2e%2e"},CE={},Gz={},_E={},Vz={},Yz={},TE={},Xz={},qz={},Ty={},Ay={},AE={},kE={},OE={},ME={},Zz={},RE={},Mu={},Ui={},Qz={},dc={},ks={},LR=function(t,e,r){var n=Rs(t),o,i,s;if(e){if(i=this.parse(n),i)throw new C2(i);this.searchParams=null}else{if(r!==void 0&&(o=new LR(r,!0)),i=this.parse(n,null,o),i)throw new C2(i);s=mvt(new gvt),s.bindURL(this),this.searchParams=s}};LR.prototype={type:"URL",parse:function(t,e,r){var n=this,o=e||CE,i=0,s="",a=!1,l=!1,c=!1,u,d,f,p;for(t=Rs(t),e||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,t=IE(t,Avt,""),t=IE(t,kvt,"$1")),t=IE(t,Ovt,""),u=Ou(t);i<=u.length;){switch(d=u[i],o){case CE:if(d&&hi(yre,d))s+=K0(d),o=Gz;else{if(e)return PE;o=_E;continue}break;case Gz:if(d&&(hi(Ivt,d)||d==="+"||d==="-"||d==="."))s+=K0(d);else if(d===":"){if(e&&(n.isSpecial()!==E2(_y,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,e){n.isSpecial()&&_y[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?o=ME:n.isSpecial()&&r&&r.scheme===n.scheme?o=Vz:n.isSpecial()?o=qz:u[i+1]==="/"?(o=Yz,i++):(n.cannotBeABaseURL=!0,Gu(n.path,""),o=Qz)}else{if(e)return PE;s="",o=_E,i=0;continue}break;case _E:if(!r||r.cannotBeABaseURL&&d!=="#")return PE;if(r.cannotBeABaseURL&&d==="#"){n.scheme=r.scheme,n.path=oi(r.path),n.query=r.query,n.fragment="",n.cannotBeABaseURL=!0,o=ks;break}o=r.scheme==="file"?ME:TE;continue;case Vz:if(d==="/"&&u[i+1]==="/")o=Ty,i++;else{o=TE;continue}break;case Yz:if(d==="/"){o=Ay;break}else{o=Ui;continue}case TE:if(n.scheme=r.scheme,d===Mo)n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=oi(r.path),n.query=r.query;else if(d==="/"||d==="\\"&&n.isSpecial())o=Xz;else if(d==="?")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=oi(r.path),n.query="",o=dc;else if(d==="#")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=oi(r.path),n.query=r.query,n.fragment="",o=ks;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=oi(r.path),n.path.length--,o=Ui;continue}break;case Xz:if(n.isSpecial()&&(d==="/"||d==="\\"))o=Ty;else if(d==="/")o=Ay;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,o=Ui;continue}break;case qz:if(o=Ty,d!=="/"||zo(s,i+1)!=="/")continue;i++;break;case Ty:if(d!=="/"&&d!=="\\"){o=Ay;continue}break;case Ay:if(d==="@"){a&&(s="%40"+s),a=!0,f=Ou(s);for(var g=0;g<f.length;g++){var m=f[g];if(m===":"&&!c){c=!0;continue}var S=Oa(m,EE);c?n.password+=S:n.username+=S}s=""}else if(d===Mo||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(a&&s==="")return $vt;i-=Ou(s).length+1,s="",o=AE}else s+=d;break;case AE:case kE:if(e&&n.scheme==="file"){o=RE;continue}else if(d===":"&&!l){if(s==="")return uc;if(p=n.parseHost(s),p)return p;if(s="",o=OE,e===kE)return}else if(d===Mo||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return uc;if(e&&s===""&&(n.includesCredentials()||n.port!==null))return;if(p=n.parseHost(s),p)return p;if(s="",o=Mu,e)return;continue}else d==="["?l=!0:d==="]"&&(l=!1),s+=d;break;case OE:if(hi(_2,d))s+=d;else if(d===Mo||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()||e){if(s!==""){var y=W0(s,10);if(y>65535)return Wz;n.port=n.isSpecial()&&y===_y[n.scheme]?null:y,s=""}if(e)return;o=Mu;continue}else return Wz;break;case ME:if(n.scheme="file",d==="/"||d==="\\")o=Zz;else if(r&&r.scheme==="file")switch(d){case Mo:n.host=r.host,n.path=oi(r.path),n.query=r.query;break;case"?":n.host=r.host,n.path=oi(r.path),n.query="",o=dc;break;case"#":n.host=r.host,n.path=oi(r.path),n.query=r.query,n.fragment="",o=ks;break;default:Kz(cp(oi(u,i),""))||(n.host=r.host,n.path=oi(r.path),n.shortenPath()),o=Ui;continue}else{o=Ui;continue}break;case Zz:if(d==="/"||d==="\\"){o=RE;break}r&&r.scheme==="file"&&!Kz(cp(oi(u,i),""))&&(up(r.path[0],!0)?Gu(n.path,r.path[0]):n.host=r.host),o=Ui;continue;case RE:if(d===Mo||d==="/"||d==="\\"||d==="?"||d==="#"){if(!e&&up(s))o=Ui;else if(s===""){if(n.host="",e)return;o=Mu}else{if(p=n.parseHost(s),p)return p;if(n.host==="localhost"&&(n.host=""),e)return;s="",o=Mu}continue}else s+=d;break;case Mu:if(n.isSpecial()){if(o=Ui,d!=="/"&&d!=="\\")continue}else if(!e&&d==="?")n.query="",o=dc;else if(!e&&d==="#")n.fragment="",o=ks;else if(d!==Mo&&(o=Ui,d!=="/"))continue;break;case Ui:if(d===Mo||d==="/"||d==="\\"&&n.isSpecial()||!e&&(d==="?"||d==="#")){if(Lvt(s)?(n.shortenPath(),d!=="/"&&!(d==="\\"&&n.isSpecial())&&Gu(n.path,"")):Dvt(s)?d!=="/"&&!(d==="\\"&&n.isSpecial())&&Gu(n.path,""):(n.scheme==="file"&&!n.path.length&&up(s)&&(n.host&&(n.host=""),s=zo(s,0)+":"),Gu(n.path,s)),s="",n.scheme==="file"&&(d===Mo||d==="?"||d==="#"))for(;n.path.length>1&&n.path[0]==="";)wvt(n.path);d==="?"?(n.query="",o=dc):d==="#"&&(n.fragment="",o=ks)}else s+=Oa(d,xre);break;case Qz:d==="?"?(n.query="",o=dc):d==="#"?(n.fragment="",o=ks):d!==Mo&&(n.path[0]+=Oa(d,NS));break;case dc:!e&&d==="#"?(n.fragment="",o=ks):d!==Mo&&(d==="'"&&n.isSpecial()?n.query+="%27":d==="#"?n.query+="%23":n.query+=Oa(d,NS));break;case ks:d!==Mo&&(n.fragment+=Oa(d,wre));break}i++}},parseHost:function(t){var e,r,n;if(zo(t,0)==="["){if(zo(t,t.length-1)!=="]"||(e=Rvt(Up(t,1,-1)),!e))return uc;this.host=e}else if(this.isSpecial()){if(t=dvt(t),hi(_vt,t)||(e=Mvt(t),e===null))return uc;this.host=e}else{if(hi(Tvt,t))return uc;for(e="",r=Ou(t),n=0;n<r.length;n++)e+=Oa(r[n],NS);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return E2(_y,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;e&&(this.scheme!=="file"||e!==1||!up(t[0],!0))&&t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,i=t.port,s=t.path,a=t.query,l=t.fragment,c=e+":";return o!==null?(c+="//",t.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=Nf(o),i!==null&&(c+=":"+i)):e==="file"&&(c+="//"),c+=t.cannotBeABaseURL?s[0]:s.length?"/"+cp(s,"/"):"",a!==null&&(c+="?"+a),l!==null&&(c+="#"+l),c},setHref:function(t){var e=this.parse(t);if(e)throw new C2(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if(t==="blob")try{return new uh(t.path[0]).origin}catch{return"null"}return t==="file"||!this.isSpecial()?"null":t+"://"+Nf(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(Rs(t)+":",CE)},getUsername:function(){return this.username},setUsername:function(t){var e=Ou(Rs(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=Oa(e[r],EE)}},getPassword:function(){return this.password},setPassword:function(t){var e=Ou(Rs(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=Oa(e[r],EE)}},getHost:function(){var t=this.host,e=this.port;return t===null?"":e===null?Nf(t):Nf(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,AE)},getHostname:function(){var t=this.host;return t===null?"":Nf(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,kE)},getPort:function(){var t=this.port;return t===null?"":Rs(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(t=Rs(t),t===""?this.port=null:this.parse(t,OE))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+cp(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,Mu))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){t=Rs(t),t===""?this.query=null:(zo(t,0)==="?"&&(t=Up(t,1)),this.query="",this.parse(t,dc)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){if(t=Rs(t),t===""){this.fragment=null;return}zo(t,0)==="#"&&(t=Up(t,1)),this.fragment="",this.parse(t,ks)},update:function(){this.query=this.searchParams.serialize()||null}};var uh=function(e){var r=cvt(this,cn),n=fvt(arguments.length,1)>1?arguments[1]:void 0,o=pvt(r,new LR(e,!1,n));RR||(r.href=o.serialize(),r.origin=o.getOrigin(),r.protocol=o.getProtocol(),r.username=o.getUsername(),r.password=o.getPassword(),r.host=o.getHost(),r.hostname=o.getHostname(),r.port=o.getPort(),r.pathname=o.getPathname(),r.search=o.getSearch(),r.searchParams=o.getSearchParams(),r.hash=o.getHash())},cn=uh.prototype,Ro=function(t,e){return{get:function(){return H0(this)[t]()},set:e&&function(r){return H0(this)[e](r)},configurable:!0,enumerable:!0}};RR&&(Oo(cn,"href",Ro("serialize","setHref")),Oo(cn,"origin",Ro("getOrigin")),Oo(cn,"protocol",Ro("getProtocol","setProtocol")),Oo(cn,"username",Ro("getUsername","setUsername")),Oo(cn,"password",Ro("getPassword","setPassword")),Oo(cn,"host",Ro("getHost","setHost")),Oo(cn,"hostname",Ro("getHostname","setHostname")),Oo(cn,"port",Ro("getPort","setPort")),Oo(cn,"pathname",Ro("getPathname","setPathname")),Oo(cn,"search",Ro("getSearch","setSearch")),Oo(cn,"searchParams",Ro("getSearchParams")),Oo(cn,"hash",Ro("getHash","setHash")));z0(cn,"toJSON",function(){return H0(this).serialize()},{enumerable:!0});z0(cn,"toString",function(){return H0(this).serialize()},{enumerable:!0});if(Lf){var Jz=Lf.createObjectURL,e7=Lf.revokeObjectURL;Jz&&z0(uh,"createObjectURL",zz(Jz,Lf)),e7&&z0(uh,"revokeObjectURL",zz(e7,Lf))}hvt(uh,"URL");avt({global:!0,constructor:!0,forced:!lvt,sham:!RR},{URL:uh});var Nvt=A,Fvt=be,bre=q,Bvt=Zo,t7=Ee,Uvt=eb,NR=Fvt("URL"),zvt=Uvt&&bre(function(){NR.canParse()}),Hvt=bre(function(){return NR.canParse.length!==1});Nvt({target:"URL",stat:!0,forced:!zvt||Hvt},{canParse:function(e){var r=Bvt(arguments.length,1),n=t7(e),o=r<2||arguments[1]===void 0?void 0:t7(arguments[1]);try{return!!new NR(n,o)}catch{return!1}}});var Wvt=A,Kvt=be,Gvt=Zo,r7=Ee,Vvt=eb,Yvt=Kvt("URL");Wvt({target:"URL",stat:!0,forced:!Vvt},{parse:function(e){var r=Gvt(arguments.length,1),n=r7(e),o=r<2||arguments[1]===void 0?void 0:r7(arguments[1]);try{return new Yvt(n,o)}catch{return null}}});var Xvt=A,qvt=ne;Xvt({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return qvt(URL.prototype.toString,this)}});var Zvt=nt,rb=V,n7=Ee,Qvt=Zo,$re=URLSearchParams,nb=$re.prototype,Jvt=rb(nb.append),o7=rb(nb.delete),eyt=rb(nb.forEach),tyt=rb([].push),FR=new $re("a=1&a=2&b=3");FR.delete("a",1);FR.delete("b",void 0);FR+""!="a=2"&&Zvt(nb,"delete",function(t){var e=arguments.length,r=e<2?void 0:arguments[1];if(e&&r===void 0)return o7(this,t);var n=[];eyt(this,function(d,f){tyt(n,{key:f,value:d})}),Qvt(e,1);for(var o=n7(t),i=n7(r),s=0,a=0,l=!1,c=n.length,u;s<c;)u=n[s++],l||u.key===o?(l=!0,o7(this,u.key)):a++;for(;a<c;)u=n[a++],u.key===o&&u.value===i||Jvt(this,u.key,u.value)},{enumerable:!0,unsafe:!0});var ryt=nt,Ire=V,nyt=Ee,oyt=Zo,Pre=URLSearchParams,BR=Pre.prototype,iyt=Ire(BR.getAll),syt=Ire(BR.has),i7=new Pre("a=1");(i7.has("a",2)||!i7.has("a",void 0))&&ryt(BR,"has",function(e){var r=arguments.length,n=r<2?void 0:arguments[1];if(r&&n===void 0)return syt(this,e);var o=iyt(this,e);oyt(r,1);for(var i=nyt(n),s=0;s<o.length;)if(o[s++]===i)return!0;return!1},{enumerable:!0,unsafe:!0});var ayt=ge,lyt=V,cyt=Ct,T2=URLSearchParams.prototype,uyt=lyt(T2.forEach);ayt&&!("size"in T2)&&cyt(T2,"size",{get:function(){var e=0;return uyt(this,function(){e++}),e},configurable:!0,enumerable:!0});var dyt=wO,UR=dyt;function Ere(t,e){const r=new Map;return async function(o){const i=r.get(o);if(i)return i;const s=(async()=>{try{const a=await xi(o,e);return Qe(a.ok),await t(a)}catch(a){return console.error(a),null}})();return r.set(o,s),s}}const ob=Ere(async t=>await Ys.blobToDataUrl(await t.blob())),hyt=/@import\s+(?:"([^"]+)"|'([^']+)'|url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\))([^;]+);/gi,fyt=/@font-face\s*{([^}]+)}/gi,Cre=/url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\)/gi,pyt=/(?:^|;)\s*font-family\s*:\s*(?:([^'"][^;\n]+)|"([^"]+)"|'([^']+)')\s*(?:;|$)/gi;function gyt(t){return Array.from(t.matchAll(hyt),e=>({url:e[1]||e[2]||e[3]||e[4]||e[5],extras:e[6]}))}function _re(t,e){return Array.from(t.matchAll(fyt),r=>{const n=r[1],o=Array.from(n.matchAll(Cre),s=>{var l;const a=s[1]||s[2]||s[3];return{original:a,resolved:((l=$e(a,e))==null?void 0:l.href)??null}}),i=new Set(Array.from(n.matchAll(pyt),s=>(s[1]||s[2]||s[3]).toLowerCase()));return{fontFace:n,urls:o,fontFamilies:i}})}function myt(t){const e=/\s*(?:([^'"][^;\n\s,]+)|"([^"]+)"|'([^']+)')\s*/gi,r=/\s*,\s*/gi,n=new Set;for(;;){const o=e.exec(t);if(!o)break;const i=o[1]||o[2]||o[3];if(n.add(i.toLowerCase()),r.lastIndex=e.lastIndex,!r.exec(t))break;e.lastIndex=r.lastIndex}return n}function Tre(t){return!(t.startsWith("-")||t.startsWith("animation")||t.startsWith("transition")||t==="cursor"||t==="pointer-events"||t==="user-select"||t==="touch-action")}function vyt(t,e){return{imports:gyt(t),fontFaces:_re(t,e)}}function yyt(t){return Array.from(t.matchAll(Cre),e=>({original:e[0],url:e[1]||e[2]||e[3]}))}const Syt=new Set(["border-collapse","border-spacing","caption-side","color","cursor","direction","empty-cells","font-family","font-size","font-style","font-variant","font-weight","font-size-adjust","font-stretch","font","letter-spacing","line-height","list-style-image","list-style-position","list-style-type","list-style","orphans","quotes","tab-size","text-align","text-align-last","text-decoration-color","text-indent","text-justify","text-shadow","text-transform","visibility","white-space","widows","word-break","word-spacing","word-wrap"]);function Are(t){return Syt.has(t)}var wyt=Object.create,kre=Object.defineProperty,xyt=Object.getOwnPropertyDescriptor,byt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ore=t=>{throw TypeError(t)},Mre=(t,e,r)=>e in t?kre(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$yt=t=>[,,,wyt(null)],Rre=["class","method","getter","setter","accessor","field","value","get","set"],jre=t=>t!==void 0&&typeof t!="function"?Ore("Function expected"):t,Iyt=(t,e,r,n,o)=>({kind:Rre[t],name:e,metadata:n,addInitializer:i=>r._?Ore("Already initialized"):o.push(jre(i||null))}),Pyt=(t,e)=>Mre(e,byt("metadata"),t[3]),Eyt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Cyt=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Rre[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,xyt(o,r)),y=n.length-1;y>=0;y--)l=Iyt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,jre(s)&&(S[g]=s);return S&&kre(o,r,S),o},ky=(t,e,r)=>Mre(t,typeof e!="symbol"?e+"":e,r),Dre,ib;Dre=[lo];class zR{constructor(){Eyt(ib,5,this),ky(this,"fontFacesPromise",null),ky(this,"foundFontNames",new Set),ky(this,"fontFacesToEmbed",new Set),ky(this,"pendingPromises",[])}startFindingCurrentDocumentFontFaces(){Qe(!this.fontFacesPromise,"FontEmbedder already started"),this.fontFacesPromise=_yt()}onFontFamilyValue(e){Qe(this.fontFacesPromise,"FontEmbedder not started");const r=myt(e);for(const n of r){if(this.foundFontNames.has(n))return;this.foundFontNames.add(n),this.pendingPromises.push(this.fontFacesPromise.then(o=>{const i=o.filter(s=>s.fontFamilies.has(n));for(const s of i)if(!this.fontFacesToEmbed.has(s)){this.fontFacesToEmbed.add(s);for(const a of s.urls)!a.resolved||a.embedded||(a.embedded=ob(a.resolved))}}))}}async createCss(){await UR.Promise.all(this.pendingPromises);let e="";for(const r of this.fontFacesToEmbed){let n=`@font-face {${r.fontFace}}`;for(const o of r.urls){if(!o.embedded)continue;const i=await o.embedded;i&&(n=n.replace(o.original,i))}e+=n}return e}}ib=$yt();Cyt(ib,1,"onFontFamilyValue",Dre,zR);Pyt(ib,zR);async function _yt(){const t=[];for(const e of document.styleSheets){let r;try{r=e.cssRules}catch{}if(r)for(const n of e.cssRules)n instanceof CSSFontFaceRule?t.push(_re(n.cssText,e.href??document.baseURI)):n instanceof CSSImportRule&&t.push(A2(n.href));else e.href&&t.push(A2(e.href))}return Ae(await UR.Promise.all(t)).flat()}const A2=Ere(async t=>{const e=vyt(await t.text(),t.url),r=await UR.Promise.all(e.imports.map(({url:n})=>A2(new URL(n,t.url).href)));return[...e.fontFaces,...Ae(r).flat()]});function Lre(t){if(t.shadowRoot)return t.shadowRoot.childNodes;if(Oyt(t)){const e=t.assignedNodes();if(e!=null&&e.length)return e}return t.childNodes}function*k2(t){for(const e of Lre(t))Tyt(e)&&(yield e)}function sb(t){var e;return((e=t.ownerDocument)==null?void 0:e.defaultView)??globalThis}function Tyt(t){return t instanceof sb(t).Element}function Ayt(t){return t instanceof sb(t).ShadowRoot}function kyt(t){return"getRootNode"in t&&Ayt(t.getRootNode())}function Oyt(t){return kyt(t)&&t instanceof sb(t).HTMLSlotElement}function Myt(t){return t.style}function HR(t,e){return sb(t).getComputedStyle(t,e)}const Tc={};class Ryt{constructor(e){C(this,"styles",new Map);C(this,"fonts",new zR);this.root=e}readRootElementStyles(e){this.readElementStyles(e,{shouldRespectDefaults:!1,shouldSkipInheritedParentStyles:!1});const r=Array.from(k2(e));for(;r.length;){const n=r.pop();r.push(...k2(n)),this.readElementStyles(n,{shouldRespectDefaults:!0,shouldSkipInheritedParentStyles:!0})}}readElementStyles(e,{shouldRespectDefaults:r=!0,shouldSkipInheritedParentStyles:n=!0}){var a;const o=r?Nyt(e.tagName.toLowerCase()):Tc,i=n?((a=this.styles.get(e.parentElement))==null?void 0:a.self)??Tc:Tc,s={self:jyt(e,{defaultStyles:o,parentStyles:i}),before:s7(e,"::before"),after:s7(e,"::after")};this.styles.set(e,s)}fetchResources(){const e=[];for(const r of this.styles.values())for(const n of Rt(r))if(n)for(const[o,i]of Object.entries(n)){if(!i)continue;o==="font-family"&&this.fonts.onFontFamilyValue(i);const s=yyt(i);s.length!==0&&e.push(...s.map(async({url:a,original:l})=>{const c=await ob(a)??"data:";n[o]=i.replace(l,`url("${c}")`)}))}return Promise.all(e)}unwrapCustomElements(){const e=new Set,r=(n,o)=>{if(e.has(n))return;e.add(n);const i=n.shadowRoot;if(i){const s=document.createElement("div");this.styles.set(s,this.styles.get(n)),s.setAttribute("data-tl-custom-element",n.tagName),(o??n.parentElement).appendChild(s);for(const a of i.childNodes)a instanceof Element?r(a,s):s.appendChild(a.cloneNode(!0));n.remove()}else if(o){if(n.tagName.toLowerCase()==="style")return;const s=n.cloneNode(!1);this.styles.set(s,this.styles.get(n)),o.appendChild(s);for(const a of Lre(n))a instanceof Element?r(a,s):s.appendChild(a.cloneNode(!0))}};for(const n of this.styles.keys())r(n,null)}embedStyles(){let e="";for(const[r,n]of this.styles){if(n.after||n.before){const i=`pseudo-${ct()}`;r.classList.add(i),n.before&&(e+=`.${i}::before {${a7(n.before)}}
|
|
106
|
-
`),n.after&&(e+=`.${i}::after {${a7(n.after)}}
|
|
107
|
-
`)}const o=Myt(r);for(const[i,s]of Object.entries(n.self))s&&o.setProperty(i,s);o.fontKerning==="auto"&&(o.fontKerning="normal")}return e}async getFontFaceCss(){return await this.fonts.createCss()}dispose(){Lyt()}}function jyt(t,{defaultStyles:e,parentStyles:r}){return t.computedStyleMap?Nre(t.computedStyleMap(),{defaultStyles:e,parentStyles:r}):WR(HR(t),{defaultStyles:e,parentStyles:r})}function s7(t,e){const r=HR(t,e),n=r.getPropertyValue("content");if(!(n===""||n==="none"))return WR(r,{defaultStyles:Tc,parentStyles:Tc})}function Nre(t,{defaultStyles:e,parentStyles:r}){const n={};for(const o of t.keys()){if(!Tre(o))continue;const i=t.get(o).toString();e[o]!==i&&(r[o]===i&&Are(o)||(n[o]=i))}return n}function WR(t,{defaultStyles:e,parentStyles:r}){const n={};for(const o of t){if(!Tre(o))continue;const i=t.getPropertyValue(o);e[o]!==i&&(r[o]===i&&Are(o)||(n[o]=i))}return n}function a7(t){let e="";for(const[r,n]of Object.entries(t))e+=`${r}: ${n};`;return e}let Nd;const l7={};function Dyt(){if(!Nd){const t=document.createElement("iframe");t.style.display="none",document.body.appendChild(t);const e=ro(t.contentDocument,"frame must have a document"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");r.appendChild(n),e.body.appendChild(r),Nd={iframe:t,foreignObject:n,document:e}}return Nd}function Lyt(){Nd&&(document.body.removeChild(Nd.iframe),Nd=void 0)}const c7={defaultStyles:Tc,parentStyles:Tc};function Nyt(t){let e=l7[t];if(!e){const{foreignObject:r,document:n}=Dyt(),o=n.createElement(t);r.appendChild(o),e=o.computedStyleMap?Nre(o.computedStyleMap(),c7):WR(HR(o),c7),r.removeChild(o),l7[t]=e}return e}function Fyt(t,e){Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)})}function u7(t,e){return t.replaceWith(e),e}async function zp(t,e){const r=document.createElement("img");e&&Fyt(e,r),r.setAttribute("src",t??"data:"),r.setAttribute("decoding","sync"),r.setAttribute("loading","eager");try{await r.decode()}catch{}return r}async function Byt(t){try{const e=t.toDataURL();return await zp(e,t)}catch{return await zp(null,t)}}async function Uyt(t){try{const e=await io.getVideoFrameAsDataUrl(t);return zp(e,t)}catch(e){console.error("Could not get video frame",e)}if(t.poster){const e=await ob(t.poster);return zp(e,t)}return zp(null,t)}async function Fre(t){if(t instanceof HTMLCanvasElement)return u7(t,await Byt(t));if(t instanceof HTMLVideoElement)return u7(t,await Uyt(t));if(t instanceof HTMLImageElement){const e=t.currentSrc||t.src,r=await ob(e);t.setAttribute("src",r??"data:"),t.setAttribute("decoding","sync"),t.setAttribute("loading","eager");try{await t.decode()}catch{}return t}else t instanceof HTMLInputElement?t.setAttribute("value",t.value):t instanceof HTMLTextAreaElement&&(t.textContent=t.value);await Promise.all(Array.from(k2(t),e=>Fre(e)))}function ab(t){const e=x.useRef();return x.useLayoutEffect(()=>{e.current=t}),x.useDebugValue(t),x.useCallback((...r)=>{const n=e.current;return Qe(n,"fn does not exist"),n(...r)},[])}const KR=x.createContext(null);function zyt({context:t,editor:e,children:r}){return h.jsx(Xx.Provider,{value:e,children:h.jsx(KR.Provider,{value:t,children:r})})}function km(){return x.useContext(KR)}function Hyt(){const t=x.useContext(KR),[e]=x.useState($k);return x.useEffect(()=>(t==null||t.waitUntil(e),()=>{e.resolve()}),[e,t]),ab(()=>{e.resolve()})}var Wyt=Object.create,Bre=Object.defineProperty,Kyt=Object.getOwnPropertyDescriptor,Gyt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ure=t=>{throw TypeError(t)},zre=(t,e,r)=>e in t?Bre(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vyt=t=>[,,,Wyt(null)],Hre=["class","method","getter","setter","accessor","field","value","get","set"],Wre=t=>t!==void 0&&typeof t!="function"?Ure("Function expected"):t,Yyt=(t,e,r,n,o)=>({kind:Hre[t],name:e,metadata:n,addInitializer:i=>r._?Ure("Already initialized"):o.push(Wre(i||null))}),Xyt=(t,e)=>zre(e,Gyt("metadata"),t[3]),qyt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Zyt=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Hre[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,Kyt(o,r)),y=n.length-1;y>=0;y--)l=Yyt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,Wre(s)&&(S[g]=s);return S&&Bre(o,r,S),o},d7=(t,e,r)=>zre(t,typeof e!="symbol"?e+"":e,r),Kre,lb;Kre=[lo];class GR{constructor(e){this.maxDelayTimeMs=e,qyt(lb,5,this),d7(this,"isResolved",!1),d7(this,"promisesToWaitFor",[])}waitUntil(e){if(this.isResolved)throw new Error("Cannot `waitUntil` - the export has already been resolved. Make sure to call `waitUntil` as soon as possible during an export - ie within the first react effect after rendering.");this.promisesToWaitFor.push(e.catch(r=>console.error("Error whilst waiting for export:",r)))}async resolvePromises(){let e=null;for(;this.promisesToWaitFor.length!==e;)e=this.promisesToWaitFor.length,await Promise.allSettled(this.promisesToWaitFor),await k_(0)}async resolve(){const e=k_(this.maxDelayTimeMs).then(()=>"timeout"),r=this.resolvePromises().then(()=>"resolved");await Promise.race([e,r])==="timeout"&&console.warn("[tldraw] Export delay timed out after ${this.maxDelayTimeMs}ms"),this.isResolved=!0}}lb=Vyt();Zyt(lb,1,"waitUntil",Kre,GR);Xyt(lb,GR);function Qyt(t,e,r={}){var y,v;if(!window.document)throw Error("No document");const{scale:n=1,background:o=!1,padding:i=t.options.defaultSvgPadding,preserveAspectRatio:s}=r,a=r.darkMode??t.user.getIsDarkMode(),l=t.getShapeAndDescendantIds(e),c=t.getUnorderedRenderingShapes(!1).filter(({id:b})=>l.has(b));let u=null;if(r.bounds)u=r.bounds;else for(const{id:b}of c){const $=t.getShapeMaskedPageBounds(b);$&&(u?u.union($):u=$.clone())}if(!u)return;const d=e.length===1&&t.isShapeOfType(t.getShape(e[0]),"frame")?e[0]:null;d||u.expandBy(i);const f=u.width*n,p=u.height*n;try{(v=(y=document.body).focus)==null||v.call(y)}catch{}const g=new GR(t.options.maxExportDelayMs),m=$k();return g.waitUntil(m),{jsx:h.jsx(Jyt,{editor:t,preserveAspectRatio:s,scale:n,bbox:u,background:o,singleFrameShapeId:d,isDarkMode:a,renderingShapes:c,onMount:m.resolve,waitUntil:g.waitUntil}),width:f,height:p,exportDelay:g}}function Jyt({editor:t,preserveAspectRatio:e,scale:r,bbox:n,background:o,singleFrameShapeId:i,isDarkMode:s,renderingShapes:a,onMount:l,waitUntil:c}){const u=ma({isDarkMode:s}),[d,f]=x.useState({}),p=ab(v=>{yi(d,v.key)||c((async()=>{const b=await v.getElement();b&&oa.flushSync(()=>f($=>({...$,[v.key]:b})))})())}),g=x.useMemo(()=>({isDarkMode:s,waitUntil:c,addExportDef:p}),[s,c,p]),[m,S]=x.useState(null),y=x.useRef(!1);return x.useLayoutEffect(()=>{if(y.current)throw new Error("SvgExport should only render once - do not use with react strict mode");y.current=!0,(async()=>{const v={},b=a.map(async({id:P,opacity:E,index:T,backgroundIndex:I})=>{var R,j;if(P===i)return[];const _=t.getShape(P);if(t.isShapeOfType(_,"group"))return[];const k=[],D=t.getShapeUtil(_);if(D.toSvg||D.toBackgroundSvg){const[M,U]=await Promise.all([(R=D.toSvg)==null?void 0:R.call(D,_,g),(j=D.toBackgroundSvg)==null?void 0:j.call(D,_,g)]),B=t.getShapePageTransform(_);let K=B.toCssString();"scale"in _.props&&_.props.scale!==1&&(K=`${K} scale(${_.props.scale}, ${_.props.scale})`);const z=t.getShapeMask(_.id),W=z?Q.From(Q.Inverse(B)).applyToPoints(z):null,J=`mask_${_.id.replace(":","_")}`;W&&(v[J]=h.jsx("clipPath",{id:J,children:h.jsx("path",{d:`M${W.map(({x:oe,y:we})=>`${oe},${we}`).join("L")}Z`})})),M&&k.push({zIndex:T,element:h.jsx("g",{transform:K,opacity:E,clipPath:z?`url(#${J})`:void 0,children:M},`fg_${_.id}`)}),U&&k.push({zIndex:I,element:h.jsx("g",{transform:K,opacity:E,clipPath:z?`url(#${J})`:void 0,children:U},`bg_${_.id}`)})}else k.push({zIndex:T,element:h.jsx(h7,{shape:_,util:D,component:jV,className:"tl-shape",bbox:n,opacity:E},`fg_${_.id}`)}),D.backgroundComponent&&k.push({zIndex:I,element:h.jsx(h7,{shape:_,util:D,component:DV,className:"tl-shape tl-shape-background",bbox:n,opacity:E},`bg_${_.id}`)});return k}),$=(await Promise.all(b)).flat();oa.flushSync(()=>{S($.sort((P,E)=>P.zIndex-E.zIndex).map(({element:P})=>P)),f(P=>({...P,...v}))})})()},[n,t,g,a,i]),x.useEffect(()=>{m!==null&&l()},[l,m]),h.jsx(zyt,{editor:t,context:g,children:h.jsxs("svg",{preserveAspectRatio:e,direction:"ltr",width:n.width*r,height:n.height*r,viewBox:`${n.minX} ${n.minY} ${n.width} ${n.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:o?i?u.solid:u.background:"transparent"},"data-color-mode":s?"dark":"light",className:`tl-container tl-theme__force-sRGB ${s?"tl-theme__dark":"tl-theme__light"}`,children:[h.jsx("defs",{children:Object.entries(d).map(([v,b])=>h.jsx(x.Fragment,{children:b},v))}),m]})})}function h7({shape:t,util:e,className:r,component:n,bbox:o,opacity:i}){const s=F(),a=Q.Translate(-o.minX,-o.minY).multiply(s.getShapePageTransform(t.id)),l=s.getShapeGeometry(t.id).bounds,c=Math.max(l.width,1),u=Math.max(l.height,1);return h.jsx(aO,{fallback:()=>null,children:h.jsx("foreignObject",{x:o.minX,y:o.minY,width:o.w,height:o.h,className:"tl-shape-foreign-object",children:h.jsx("div",{className:r,"data-shape-type":t.type,style:{clipPath:s.getShapeClipPath(t.id),transform:a.toCssString(),width:c,height:u,opacity:i},children:h.jsx(n,{shape:t,util:e})})})})}async function eSt(t,e,r={}){const n=Qyt(t,e,r);if(!n)return;const o=t.getContainer(),i=document.createElement("div");i.className="tldraw-svg-export",i.inert=!0,i.tabIndex=-1,Object.assign(i.style,{position:"absolute",top:"0px",left:"0px",width:n.width+"px",height:n.height+"px",pointerEvents:"none",opacity:0}),o.appendChild(i);const s=sK(i);try{oa.flushSync(()=>{s.render(n.jsx)}),await n.exportDelay.resolve();const a=i.firstElementChild;return Qe(a instanceof SVGSVGElement,"Expected an SVG element"),await tSt(a),{svg:a,width:n.width,height:n.height}}finally{setTimeout(()=>{s.unmount(),o.removeChild(i)},0)}}async function tSt(t){const e=[...t.querySelectorAll("foreignObject.tl-shape-foreign-object > *")];if(!e.length)return;const r=new Ryt(t);try{r.fonts.startFindingCurrentDocumentFontFaces(),await Promise.all(e.map(i=>Fre(i)));for(const i of e)r.readRootElementStyles(i);await r.fetchResources();const n=await r.getFontFaceCss();r.unwrapCustomElements();const o=r.embedStyles();if(n||o){const i=document.createElementNS("http://www.w3.org/2000/svg","style");i.textContent=`${n}
|
|
108
|
-
${o}`,t.prepend(i)}}finally{r.dispose()}}const rSt={maxShapesPerPage:4e3,maxFilesAtOnce:100,maxPages:40,animationMediumMs:320,followChaseViewportSnap:2,doubleClickDurationMs:450,multiClickDurationMs:200,coarseDragDistanceSquared:36,dragDistanceSquared:16,defaultSvgPadding:32,cameraSlideFriction:.09,maxPointsPerDrawShape:500,gridSteps:[{min:-1,mid:.15,step:64},{min:.05,mid:.375,step:16},{min:.15,mid:1,step:4},{min:.7,mid:2.5,step:1}],collaboratorInactiveTimeoutMs:6e4,collaboratorIdleTimeoutMs:3e3,collaboratorCheckIntervalMs:1200,cameraMovingTimeoutMs:64,hitTestMargin:8,edgeScrollDelay:200,edgeScrollEaseDuration:200,edgeScrollSpeed:25,edgeScrollDistance:8,coarsePointerWidth:12,coarseHandleRadius:20,handleRadius:12,longPressDurationMs:500,textShadowLod:.35,adjacentShapeMargin:10,flattenImageBoundsExpand:64,flattenImageBoundsPadding:16,laserDelayMs:1200,maxExportDelayMs:5e3};function f7(t,e){if(!e)return!1;switch(t.type){case"mixed":return e.type==="mixed";case"shared":return e.type==="shared"&&t.value===e.value;default:throw dr(t)}}class nSt{constructor(e){C(this,"map");this.map=new Map(e)}get(e){return this.map.get(e)}getAsKnownValue(e){const r=this.get(e);if(r&&r.type!=="mixed")return r.value}get size(){return this.map.size}equals(e){if(this.size!==e.size)return!1;const r=new Set;for(const[n,o]of this){if(!f7(o,e.get(n)))return!1;r.add(n)}for(const[n,o]of e)if(!r.has(n)&&!f7(o,this.get(n)))return!1;return!0}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}class O2 extends nSt{set(e,r){this.map.set(e,r)}applyValue(e,r){const n=this.get(e);if(!n){this.set(e,{type:"shared",value:r});return}switch(n.type){case"mixed":return;case"shared":n.value!==r&&this.set(e,{type:"mixed"});return;default:dr(n,"type")}}}function oSt(t,e,r){return xi(t).then(function(n){return n.arrayBuffer()}).then(function(n){return new File([n],e,{type:r})})}const iSt="https://cdn.tldraw.com";function tl(){return`${iSt}/${gV}`}function sSt(t){switch(t.type){case"shapes":return`s${t.shapeIds.map(r=>jE(r.slice(6))).join(".")}`;case"page":return"p"+jE(vo.parseId(t.pageId));case"viewport":{const{bounds:e,pageId:r}=t;let n=`v${Math.round(e.x)}.${Math.round(e.y)}.${Math.round(e.w)}.${Math.round(e.h)}`;return r&&(n+="."+jE(vo.parseId(r))),n}default:dr(t)}}function aSt(t){switch(t[0]){case"s":return{type:"shapes",shapeIds:t.slice(1).split(".").filter(Boolean).map(n=>ot(decodeURIComponent(n)))};case"p":return{type:"page",pageId:vo.createId(decodeURIComponent(t.slice(1)))};case"v":{const[r,n,o,i,s]=t.slice(1).split(".");return{type:"viewport",bounds:new ee(Number(r),Number(n),Number(o),Number(i)),pageId:s?vo.createId(decodeURIComponent(s)):void 0}}default:throw Error("Invalid deep link string")}}function jE(t){return encodeURIComponent(t).replace(/\./g,"%2E")}function lSt(t,e){var o;let r=t;const n=new Set(e);for(;n.has(r);)r=(o=/^.*(\d+)$/.exec(r))!=null&&o[1]?r.replace(/(\d+)(?=\D?)$/,i=>(+i+1).toString()):`${r} 1`;return r}function Oy(t,e,r){if(r.length===0)return[];const n=new Map;for(const i of Ae(r.map(s=>t.getShape(s)))){const{parentId:s}=i;n.has(s)||n.set(s,{children:Ae(t.getSortedChildIdsForParent(s).map(a=>t.getShape(a))),moving:new Set}),n.get(s).moving.add(i)}const o=[];switch(e){case"toBack":{n.forEach(({moving:i,children:s})=>cSt(i,s,o));break}case"toFront":{n.forEach(({moving:i,children:s})=>uSt(i,s,o));break}case"forward":{n.forEach(({moving:i,children:s})=>dSt(i,s,o));break}case"backward":{n.forEach(({moving:i,children:s})=>hSt(i,s,o));break}}return o}function cSt(t,e,r){const n=e.length;if(t.size===n)return;let o,i;for(let s=0;s<n;s++){const a=e[s];if(t.has(a))o=a.index,t.delete(a);else{i=a.index;break}}if(t.size!==0){const s=qd(o,i,t.size);r.push(...Array.from(t.values()).sort(qr).map((a,l)=>({...a,index:s[l]})))}}function uSt(t,e,r){const n=e.length;if(t.size===n)return;let o,i;for(let s=n-1;s>-1;s--){const a=e[s];if(t.has(a))i=a.index,t.delete(a);else{o=a.index;break}}if(t.size!==0){const s=qd(o,i,t.size);r.push(...Array.from(t.values()).sort(qr).map((a,l)=>({...a,index:s[l]})))}}function dSt(t,e,r){var i;const n=e.length;if(t.size===n)return;let o={name:"skipping"};for(let s=0;s<n;s++){const a=t.has(e[s]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:s};break}case"selecting":{if(a)continue;const{selectIndex:l}=o;qd(e[s].index,(i=e[s+1])==null?void 0:i.index,s-l).forEach((c,u)=>r.push({...e[l+u],index:c})),o={name:"skipping"};break}}}}function hSt(t,e,r){var i;const n=e.length;if(t.size===n)return;let o={name:"skipping"};for(let s=n-1;s>-1;s--){const a=t.has(e[s]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:s};break}case"selecting":{if(a)continue;qd((i=e[s-1])==null?void 0:i.index,e[s].index,o.selectIndex-s).forEach((l,c)=>{r.push({...e[s+c+1],index:l})}),o={name:"skipping"};break}}}}function Gre({editor:t,ids:e}){const r=Ae(e.map(s=>t.getShape(s))),n=t.getShapesSharedRotation(e),o=t.getShapesRotatedPageBounds(e);if(!o)return null;const i=o.center.clone().rotWith(o.point,n);return{pageCenter:i,initialCursorAngle:i.angle(t.inputs.originPagePoint),initialShapesRotation:n,shapeSnapshots:r.map(s=>({shape:s,initialPagePoint:t.getShapePageTransform(s.id).point()}))}}function FS({delta:t,editor:e,snapshot:r,stage:n}){const{pageCenter:o,shapeSnapshots:i}=r;e.updateShapes(i.map(({shape:a,initialPagePoint:l})=>{const c=Tn(a.parentId)?e.getShapePageTransform(a.parentId):Q.Identity(),u=w.RotWith(l,o,t),d=Q.applyToPoint(Q.Inverse(c),u),f=dl(a.rotation+t);return{id:a.id,type:a.type,x:d.x,y:d.y,rotation:f}}));const s=[];i.forEach(({shape:a})=>{var d,f,p;const l=e.getShape(a.id);if(!l)return;const c=e.getShapeUtil(a);if(n==="start"||n==="one-off"){const g=(d=c.onRotateStart)==null?void 0:d.call(c,a);g&&s.push(g)}const u=(f=c.onRotate)==null?void 0:f.call(c,a,l);if(u&&s.push(u),n==="end"||n==="one-off"){const g=(p=c.onRotateEnd)==null?void 0:p.call(c,a,l);g&&s.push(g)}}),s.length>0&&e.updateShapes(s)}const fSt=t=>{const{store:e}=t,r=e.query.filterHistory("binding"),n=e.query.records("binding");function o(){const i=n.get(),s=new Map;for(const a of i){const{fromId:l,toId:c}=a,u=s.get(l);u?u.push(a):s.set(l,[a]);const d=s.get(c);d?d.push(a):s.set(c,[a])}return s}return Y("arrowBindingsIndex",(i,s)=>{if(Ic(i))return o();const a=i,l=r.getDiffSince(s);if(l===co)return o();let c;function u(p){c??(c=new Map(a));const g=c.get(p.fromId),m=g==null?void 0:g.filter(v=>v.id!==p.id);m!=null&&m.length?c.set(p.fromId,m):c.delete(p.fromId);const S=c.get(p.toId),y=S==null?void 0:S.filter(v=>v.id!==p.id);y!=null&&y.length?c.set(p.toId,y):c.delete(p.toId)}function d(p){c??(c=new Map(a));let g=c.get(p);return g?g===a.get(p)&&(g=g.slice(0),c.set(p,g)):(g=[],c.set(p,g)),g}function f(p){d(p.fromId).push(p),d(p.toId).push(p)}for(const p of l){for(const g of Rt(p.added))f(g);for(const[g,m]of Rt(p.updated))u(g),f(m);for(const g of Rt(p.removed))u(g)}return c??a})};function pSt(t,e,r){const n=t.getShapeMaskedPageBounds(e);return n===void 0?!0:!r.includes(n)}const gSt=t=>{function e(r){const n=r.getCurrentPageShapeIds(),o=r.getViewportPageBounds(),i=new Set;return n.forEach(s=>{pSt(r,s,o)&&i.add(s)}),i}return Y("getCulledShapes",r=>{if(Ic(r))return e(t);const n=e(t);if(r.size!==n.size)return n;for(const o of r)if(!n.has(o))return n;return r})},mSt=t=>{const e=t.query.ids("shape"),r=t.query.filterHistory("shape");function n(){const o={},i=e.get(),s=Array(i.size);return i.forEach(a=>s.push(t.get(a))),s.sort(qr),s.forEach(a=>{o[a.parentId]||(o[a.parentId]=[]),o[a.parentId].push(a.id)}),o}return Y("parentsToChildrenWithIndexes",(o,i)=>{if(Ic(o))return n();const s=r.getDiffSince(i);if(s===co)return n();if(s.length===0)return o;let a=null;const l=d=>{a||(a={...o}),a[d]?a[d]===o[d]&&(a[d]=[...a[d]]):a[d]=[]},c=new Set;let u;for(let d=0,f=s.length;d<f;d++){u=s[d];for(const p of Object.values(u.added))dd(p)&&(l(p.parentId),a[p.parentId].push(p.id),c.add(a[p.parentId]));for(const[p,g]of Object.values(u.updated))if(dd(g)&&dd(p)){if(p.parentId!==g.parentId)l(p.parentId),l(g.parentId),a[p.parentId].splice(a[p.parentId].indexOf(g.id),1),a[g.parentId].push(g.id),c.add(a[g.parentId]);else if(p.index!==g.index){l(g.parentId);const m=a[g.parentId].indexOf(g.id);a[g.parentId][m]=g.id,c.add(a[g.parentId])}}for(const p of Object.values(u.removed))dd(p)&&(l(p.parentId),a[p.parentId].splice(a[p.parentId].indexOf(p.id),1))}for(const d of c){const f=Ae(d.map(p=>t.get(p)));f.sort(qr),d.splice(0,d.length,...f.map(p=>p.id))}return a??o})},DE=(t,e,r)=>{for(;!En(r.parentId);){const n=t.get(r.parentId);if(!n)return!1;r=n}return r.parentId===e},vSt=(t,e)=>{const r=t.query.ids("shape");let n=null;function o(){const i=e();return n=i,new Set([...r.get()].filter(s=>DE(t,i,t.get(s))))}return Y("_shapeIdsInCurrentPage",(i,s)=>{if(Ic(i))return o();const a=e();if(a!==n)return o();const l=t.history.getDiffSince(s);if(l===co)return o();const c=new SS(i);for(const d of l){for(const f of Object.values(d.added))dd(f)&&DE(t,a,f)&&c.add(f.id);for(const[f,p]of Object.values(d.updated))dd(p)&&(DE(t,a,p)?c.add(p.id):c.remove(p.id));for(const f of Object.keys(d.removed))Tn(f)&&c.remove(f)}const u=c.get();return u?ep(u.value,u.diff):i})};var ySt=Object.create,Vre=Object.defineProperty,SSt=Object.getOwnPropertyDescriptor,wSt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Yre=t=>{throw TypeError(t)},Xre=(t,e,r)=>e in t?Vre(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xSt=t=>[,,,ySt(null)],qre=["class","method","getter","setter","accessor","field","value","get","set"],Zre=t=>t!==void 0&&typeof t!="function"?Yre("Function expected"):t,bSt=(t,e,r,n,o)=>({kind:qre[t],name:e,metadata:n,addInitializer:i=>r._?Yre("Already initialized"):o.push(Zre(i||null))}),$St=(t,e)=>Xre(e,wSt("metadata"),t[3]),ISt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Qre=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=qre[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,SSt(o,r)),y=n.length-1;y>=0;y--)l=bSt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,Zre(s)&&(S[g]=s);return S&&Vre(o,r,S),o},Ru=(t,e,r)=>Xre(t,typeof e!="symbol"?e+"":e,r),Jre,ene,Om;const PSt=40;ene=[lo],Jre=[lo];class cb{constructor(e){this.editor=e,ISt(Om,5,this),Ru(this,"_clickId",""),Ru(this,"_clickTimeout"),Ru(this,"_clickScreenPoint"),Ru(this,"_previousScreenPoint"),Ru(this,"_clickState","idle"),Ru(this,"lastPointerInfo",{})}_getClickTimeout(e,r=ct()){this._clickId=r,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.setTimeout(()=>{if(this._clickState===e&&this._clickId===r){switch(this._clickState){case"pendingTriple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"double_click",phase:"settle"});break}case"pendingQuadruple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"triple_click",phase:"settle"});break}case"pendingOverflow":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"settle"});break}}this._clickState="idle"}},e==="idle"||e==="pendingDouble"?this.editor.options.doubleClickDurationMs:this.editor.options.multiClickDurationMs)}get clickState(){return this._clickState}handlePointerEvent(e){switch(e.name){case"pointer_down":{if(!this._clickState)return e;switch(this._clickScreenPoint=w.From(e.point),this._previousScreenPoint&&w.Dist2(this._previousScreenPoint,this._clickScreenPoint)>PSt**2&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=e,this._clickState){case"pendingDouble":return this._clickState="pendingTriple",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"double_click",phase:"down"};case"pendingTriple":return this._clickState="pendingQuadruple",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"triple_click",phase:"down"};case"pendingQuadruple":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"quadruple_click",phase:"down"};case"idle":{this._clickState="pendingDouble";break}case"pendingOverflow":{this._clickState="overflow";break}}return this._clickTimeout=this._getClickTimeout(this._clickState),e}case"pointer_up":{if(!this._clickState)return e;switch(this._clickScreenPoint=w.From(e.point),this._clickState){case"pendingTriple":return{...this.lastPointerInfo,type:"click",name:"double_click",phase:"up"};case"pendingQuadruple":return{...this.lastPointerInfo,type:"click",name:"triple_click",phase:"up"};case"pendingOverflow":return{...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"up"}}return e}case"pointer_move":return this._clickState!=="idle"&&this._clickScreenPoint&&w.Dist2(this._clickScreenPoint,this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?this.editor.options.coarseDragDistanceSquared:this.editor.options.dragDistanceSquared)&&this.cancelDoubleClickTimeout(),e}return e}cancelDoubleClickTimeout(){this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"}}Om=xSt();Qre(Om,1,"_getClickTimeout",ene,cb);Qre(Om,1,"cancelDoubleClickTimeout",Jre,cb);$St(Om,cb);class ESt{constructor(e){C(this,"_isEdgeScrolling",!1);C(this,"_edgeScrollDuration",-1);this.editor=e}updateEdgeScrolling(e){const{editor:r}=this,n=this.getEdgeScroll();if(n.x===0&&n.y===0)this._isEdgeScrolling&&(this._isEdgeScrolling=!1,this._edgeScrollDuration=0);else if(this._isEdgeScrolling||(this._isEdgeScrolling=!0,this._edgeScrollDuration=0),this._edgeScrollDuration+=e,this._edgeScrollDuration>r.options.edgeScrollDelay){const o=r.options.edgeScrollEaseDuration>0?pr.easeInCubic(Math.min(1,this._edgeScrollDuration/(r.options.edgeScrollDelay+r.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:n.x*o,y:n.y*o})}}getEdgeProximityFactors(e,r,n,o,i){const{editor:s}=this,a=s.options.edgeScrollDistance,l=n?s.options.coarsePointerWidth:0,c=e-l,u=e+l,d=o?0:a,f=i?r:r-a;return c<d?Math.min(1,(d-c)/a):u>f?-Math.min(1,(u-f)/a):0}getEdgeScroll(){const{editor:e}=this,{inputs:{currentScreenPoint:{x:r,y:n}}}=e,o=e.getViewportScreenBounds(),{isCoarsePointer:i,insets:[s,a,l,c]}=e.getInstanceState(),u=this.getEdgeProximityFactors(r,o.w,i,c,a),d=this.getEdgeProximityFactors(n,o.h,i,s,l);return{x:u,y:d}}moveCameraWhenCloseToEdge(e){const{editor:r}=this;if(!r.inputs.isDragging||r.inputs.isPanning||r.getCameraOptions().isLocked||e.x===0&&e.y===0)return;const n=r.getViewportScreenBounds(),o=n.w<1e3?.612:1,i=n.h<1e3?.612:1,s=r.getZoomLevel(),a=r.user.getEdgeScrollSpeed()*r.options.edgeScrollSpeed,l=a*e.x*o/s,c=a*e.y*i/s,{x:u,y:d,z:f}=r.getCamera();r.setCamera(new w(u+l,d+c,f))}}class CSt{constructor(e){C(this,"isSafari");C(this,"isIos");C(this,"isChromeForIos");C(this,"isFirefox");C(this,"isAndroid");this.editor=e,typeof window<"u"&&"navigator"in window?(this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),this.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),this.isFirefox=/firefox/i.test(navigator.userAgent),this.isAndroid=/android/i.test(navigator.userAgent)):(this.isSafari=!1,this.isIos=!1,this.isChromeForIos=!1,this.isFirefox=!1,this.isAndroid=!1)}}class _St{constructor(e,r){C(this,"disposeSideEffectListener");this.editor=e,this.disposeSideEffectListener=e.sideEffects.registerAfterChangeHandler("instance",(o,i)=>{o.isFocused!==i.isFocused&&this.updateContainerClass()});const n=e.getInstanceState().isFocused;r!==n&&e.updateInstanceState({isFocused:!!r}),this.updateContainerClass()}updateContainerClass(){const e=this.editor.getContainer();this.editor.getInstanceState().isFocused?e.classList.add("tl-container__focused"):e.classList.remove("tl-container__focused")}focus(){this.editor.getContainer().focus()}blur(){this.editor.complete(),this.editor.getContainer().blur()}dispose(){var e;(e=this.disposeSideEffectListener)==null||e.call(this)}}function Ff(t){return ASt}class TSt{constructor(){C(this,"length",0);C(this,"head",null);C(this,"tail",this)}push(e){return new VR(e,this)}toArray(){return Xs}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const ASt=new TSt;class VR{constructor(e,r){C(this,"length");this.head=e,this.tail=r,this.length=r.length+1}push(e){return new VR(e,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let e=this;return{next(){if(e.length){const r=e.head;return e=e.tail,{value:r,done:!1}}else return{value:void 0,done:!0}}}}}class kSt{constructor(e){C(this,"store");C(this,"dispose");C(this,"state","recording");C(this,"pendingDiff",new MSt);C(this,"stacks",fr("HistoryManager.stacks",{undos:Ff(),redos:Ff()},{isEqual:(e,r)=>e.undos===r.undos&&e.redos===r.redos}));C(this,"annotateError");C(this,"_isInBatch",!1);this.store=e.store,this.annotateError=e.annotateError??dg,this.dispose=this.store.addHistoryInterceptor((r,n)=>{if(n==="user")switch(this.state){case"recording":this.pendingDiff.apply(r.changes),this.stacks.update(({undos:o})=>({undos:o,redos:Ff()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(r.changes);break;case"paused":break;default:dr(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const e=this.pendingDiff.clear();this.stacks.update(({undos:r,redos:n})=>({undos:r.push({type:"diff",diff:e}),redos:n}))}getNumUndos(){return this.stacks.get().undos.length+(this.pendingDiff.isEmpty()?0:1)}getNumRedos(){return this.stacks.get().redos.length}batch(e,r){const n=this.state;n!=="paused"&&(r!=null&&r.history)&&(this.state=OSt[r.history]);try{if(this._isInBatch)return os(e),this;this._isInBatch=!0;try{os(e)}catch(o){throw this.annotateError(o),o}finally{this._isInBatch=!1}return this}finally{this.state=n}}_undo({pushToRedoStack:e,toMark:r=void 0}){var o;const n=this.state;this.state="paused";try{let{undos:i,redos:s}=this.stacks.get();const a=this.pendingDiff.clear(),l=mG(a),c=Z_(a);e&&!l&&(s=s.push({type:"diff",diff:a}));let u=!1;if(l)for(;((o=i.head)==null?void 0:o.type)==="stop";){const d=i.head;if(i=i.tail,e&&(s=s.push(d)),d.id===r){u=!0;break}}if(!u)e:for(;i.head;){const d=i.head;switch(i=i.tail,e&&(s=s.push(d)),d.type){case"diff":_p(c,[Z_(d.diff)]);break;case"stop":if(!r)break e;if(d.id===r){u=!0;break e}break;default:dr(d)}}if(!u&&r)return this;this.store.applyDiff(c,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:i,redos:s})}finally{this.state=n}return this}undo(){return this._undo({pushToRedoStack:!0}),this}redo(){var r;const e=this.state;this.state="paused";try{this.flushPendingDiff();let{undos:n,redos:o}=this.stacks.get();if(o.length===0)return this;for(;((r=o.head)==null?void 0:r.type)==="stop";)n=n.push(o.head),o=o.tail;const i=Kw();for(;o.head;){const s=o.head;if(n=n.push(s),o=o.tail,s.type==="diff")_p(i,[s.diff]);else break}this.store.applyDiff(i,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:n,redos:o})}finally{this.state=e}return this}bail(){return this._undo({pushToRedoStack:!1}),this}bailToMark(e){return this._undo({pushToRedoStack:!1,toMark:e}),this}squashToMark(e){var i;let r=this.stacks.get().undos;const n=[];for(;r.head&&!(r.head.type==="stop"&&r.head.id===e);)r.head.type==="diff"&&n.push(r.head.diff),r=r.tail;if(!r.head||((i=r.head)==null?void 0:i.id)!==e)return console.error("Could not find mark to squash to: ",e),this;if(n.length===0)return this;const o=Kw();return _p(o,n.reverse()),this.stacks.update(({redos:s})=>({undos:r.push({type:"diff",diff:o}),redos:s})),this}_mark(e){os(()=>{this.flushPendingDiff(),this.stacks.update(({undos:r,redos:n})=>({undos:r.push({type:"stop",id:e}),redos:n}))})}clear(){this.stacks.set({undos:Ff(),redos:Ff()}),this.pendingDiff.clear()}getMarkIdMatching(e){let r=this.stacks.get().undos;for(;r.head;){if(r.head.type==="stop"&&r.head.id.includes(e))return r.head.id;r=r.tail}return null}debug(){const{undos:e,redos:r}=this.stacks.get();return{undos:e.toArray(),redos:r.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const OSt={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class MSt{constructor(){C(this,"diff",Kw());C(this,"isEmptyAtom",fr("PendingDiff.isEmpty",!0))}clear(){const e=this.diff;return this.diff=Kw(),this.isEmptyAtom.set(!0),e}isEmpty(){return this.isEmptyAtom.get()}apply(e){_p(this.diff,[e]),this.isEmptyAtom.set(mG(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class RSt{constructor(e){C(this,"scribbleItems",new Map);C(this,"state","paused");this.editor=e}addScribble(e,r=ct()){const n={id:r,scribble:{id:r,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...e,state:"starting"},timeoutMs:0,delayRemaining:e.delay??0,prev:null,next:null};return this.scribbleItems.set(r,n),n}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}stop(e){const r=this.scribbleItems.get(e);if(!r)throw Error(`Scribble with id ${e} not found`);return r.delayRemaining=Math.min(r.delayRemaining,200),r.scribble.state="stopping",r}addPoint(e,r,n,o=.5){const i=this.scribbleItems.get(e);if(!i)throw Error(`Scribble with id ${e} not found`);const{prev:s}=i,a={x:r,y:n,z:o};return(!s||w.Dist(s,a)>=1)&&(i.next=a),i}tick(e){this.scribbleItems.size!==0&&this.editor.run(()=>{this.scribbleItems.forEach(r=>{if(r.scribble.state==="starting"){const{next:l,prev:c}=r;l&&l!==c&&(r.prev=l,r.scribble.points.push(l)),r.scribble.points.length>8&&(r.scribble.state="active");return}r.delayRemaining>0&&(r.delayRemaining=Math.max(0,r.delayRemaining-e)),r.timeoutMs+=e,r.timeoutMs>=16&&(r.timeoutMs=0);const{delayRemaining:n,timeoutMs:o,prev:i,next:s,scribble:a}=r;switch(a.state){case"active":{s&&s!==i?(r.prev=s,a.points.push(s),n===0&&a.points.length>8&&a.points.shift()):o===0&&(a.points.length>1?a.points.shift():r.delayRemaining=a.delay);break}case"stopping":{if(r.delayRemaining===0&&o===0){if(a.points.length===1){this.scribbleItems.delete(r.id);return}a.shrink&&(a.size=Math.max(1,a.size*(1-a.shrink))),a.points.shift()}break}}}),this.editor.updateInstanceState({scribbles:Array.from(this.scribbleItems.values()).map(({scribble:r})=>({...r,points:[...r.points]})).slice(-5)})})}}var jSt=Object.create,tne=Object.defineProperty,DSt=Object.getOwnPropertyDescriptor,LSt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),rne=t=>{throw TypeError(t)},nne=(t,e,r)=>e in t?tne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,NSt=t=>[,,,jSt(null)],one=["class","method","getter","setter","accessor","field","value","get","set"],ine=t=>t!==void 0&&typeof t!="function"?rne("Function expected"):t,FSt=(t,e,r,n,o)=>({kind:one[t],name:e,metadata:n,addInitializer:i=>r._?rne("Already initialized"):o.push(ine(i||null))}),BSt=(t,e)=>nne(e,LSt("metadata"),t[3]),USt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},ub=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=one[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,DSt(o,r)),y=n.length-1;y>=0;y--)l=FSt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,ine(s)&&(S[g]=s);return S&&tne(o,r,S),o},zSt=(t,e,r)=>nne(t,e+"",r),sne,ane,lne,cne,gu;const ye=t=>Math.round(t*10**8)/10**8;function js(t,e,r,n,o){const i=t.filter(a=>(n==="forward"?a.startNode.id===e:a.endNode.id===e)&&ye(a.length)===ye(r)&&li(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));if(i.length===0)return[];const s=new Set;return i.forEach(a=>{const l=n==="forward"?a.endNode.id:a.startNode.id;if(!s.has(l)){s.add(l);const c=js(t,l,r,n,li(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));i.push(...c)}}),i}function HSt(t){t.sort((e,r)=>r.gaps.length-e.gaps.length);for(let e=t.length-1;e>0;e--){const r=t[e];for(let n=e-1;n>=0;n--){const o=t[n];if(o.direction===r.direction&&r.gaps.every(i=>o.gaps.some(s=>ye(i.startEdge[0].x)===ye(s.startEdge[0].x)&&ye(i.startEdge[0].y)===ye(s.startEdge[0].y)&&ye(i.startEdge[1].x)===ye(s.startEdge[1].x)&&ye(i.startEdge[1].y)===ye(s.startEdge[1].y))&&o.gaps.some(s=>ye(i.endEdge[0].x)===ye(s.endEdge[0].x)&&ye(i.endEdge[0].y)===ye(s.endEdge[0].y)&&ye(i.endEdge[1].x)===ye(s.endEdge[1].x)&&ye(i.endEdge[1].y)===ye(s.endEdge[1].y)))){t.splice(e,1);break}}}}cne=[Y],lne=[Y],ane=[Y],sne=[Y];class Kh{constructor(e){this.manager=e,USt(gu,5,this),zSt(this,"editor"),this.editor=e.editor}getSnapPointsCache(){const{editor:e}=this;return e.store.createComputedCache("snapPoints",r=>{const n=e.getShapePageTransform(r.id);if(!n)return;const i=e.getShapeUtil(r).getBoundsSnapGeometry(r).points??e.getShapeGeometry(r).bounds.cornersAndCenter;if(!(!n||!i))return i.map((s,a)=>{const{x:l,y:c}=Q.applyToPoint(n,s);return{x:l,y:c,id:`${r.id}:${a}`}})})}getSnapPoints(e){return this.getSnapPointsCache().get(e)??[]}getSnappablePoints(){const e=this.getSnapPointsCache(),r=this.manager.getSnappableShapes(),n=[];for(const o of r){const i=e.get(o);i&&n.push(...i)}return n}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),e=>({id:e,pageBounds:ro(this.editor.getShapePageBounds(e))}))}getVisibleGaps(){const e=[],r=[];let n,o;const i=this.getSnappableGapNodes().sort((a,l)=>a.pageBounds.minX-l.pageBounds.minX);for(let a=0;a<i.length;a++){n=i[a];for(let l=a+1;l<i.length;l++)o=i[l],n.pageBounds.maxX<o.pageBounds.minX&&wf(n.pageBounds.minY,n.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)&&e.push({startNode:n,endNode:o,startEdge:[new w(n.pageBounds.maxX,n.pageBounds.minY),new w(n.pageBounds.maxX,n.pageBounds.maxY)],endEdge:[new w(o.pageBounds.minX,o.pageBounds.minY),new w(o.pageBounds.minX,o.pageBounds.maxY)],length:o.pageBounds.minX-n.pageBounds.maxX,breadthIntersection:li(n.pageBounds.minY,n.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)})}const s=i.sort((a,l)=>a.pageBounds.minY-l.pageBounds.minY);for(let a=0;a<s.length;a++){n=s[a];for(let l=a+1;l<s.length;l++)o=s[l],n.pageBounds.maxY<o.pageBounds.minY&&wf(n.pageBounds.minX,n.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)&&r.push({startNode:n,endNode:o,startEdge:[new w(n.pageBounds.minX,n.pageBounds.maxY),new w(n.pageBounds.maxX,n.pageBounds.maxY)],endEdge:[new w(o.pageBounds.minX,o.pageBounds.minY),new w(o.pageBounds.maxX,o.pageBounds.minY)],length:o.pageBounds.minY-n.pageBounds.maxY,breadthIntersection:li(n.pageBounds.minX,n.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)})}return{horizontal:e,vertical:r}}snapTranslateShapes({lockedAxis:e,initialSelectionPageBounds:r,initialSelectionSnapPoints:n,dragDelta:o}){var S,y;const i=this.manager.getSnapThreshold(),s=this.getSnappablePoints(),a=r.clone().translate(o),l=n.map(({x:v,y:b},$)=>({id:"selection:"+$,x:v+o.x,y:b+o.y})),c=s,u=[],d=[],f=new w(i,i);this.collectPointSnaps({minOffset:f,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:f});const p=new w(e==="x"?0:((S=u[0])==null?void 0:S.nudge)??0,e==="y"?0:((y=d[0])==null?void 0:y.nudge)??0);f.x=0,f.y=0,u.length=0,d.length=0,l.forEach(v=>{v.x+=p.x,v.y+=p.y}),a.translate(p),this.collectPointSnaps({minOffset:f,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:f});const g=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:d}),m=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d});return this.manager.setIndicators([...m,...g]),{nudge:p}}snapResizeShapes({initialSelectionPageBounds:e,dragDelta:r,handle:n,isAspectRatioLocked:o,isResizingFromCenter:i}){var T,I;const s=this.manager.getSnapThreshold(),{box:a,scaleX:l,scaleY:c}=ee.Resize(e,n,i?r.x*2:r.x,i?r.y*2:r.y,o);let u=n;l<0&&(u=TIe(u)),c<0&&(u=_Ie(u)),i&&(a.center=e.center);const d=u==="top"||u==="bottom",f=u==="left"||u==="right",p=p7(u,a),g=this.getSnappablePoints(),m=[],S=[],y=new w(s,s);this.collectPointSnaps({minOffset:y,nearestSnapsX:m,nearestSnapsY:S,otherNodeSnapPoints:g,selectionSnapPoints:p});const v=new w(d?0:((T=m[0])==null?void 0:T.nudge)??0,f?0:((I=S[0])==null?void 0:I.nudge)??0);if(o&&AIe(u)&&v.len()!==0){const _=m.length&&S.length?Math.abs(v.x)<Math.abs(v.y)?"x":"y":m.length?"x":"y",k=e.aspectRatio;_==="x"?(S.length=0,v.y=v.x/k,(u==="bottom_left"||u==="top_right")&&(v.y=-v.y)):(m.length=0,v.x=v.y*k,(u==="bottom_left"||u==="top_right")&&(v.x=-v.x))}const b=w.Add(r,v),{box:$}=ee.Resize(e,n,i?b.x*2:b.x,i?b.y*2:b.y,o);i&&($.center=e.center);const P=p7("any",$);m.length=0,S.length=0,y.x=0,y.y=0,this.collectPointSnaps({minOffset:y,nearestSnapsX:m,nearestSnapsY:S,otherNodeSnapPoints:g,selectionSnapPoints:P});const E=this.getPointSnapLines({nearestSnapsX:m,nearestSnapsY:S});return this.manager.setIndicators([...E]),{nudge:v}}collectPointSnaps({selectionSnapPoints:e,otherNodeSnapPoints:r,minOffset:n,nearestSnapsX:o,nearestSnapsY:i}){for(const s of e)for(const a of r){const l=w.Sub(s,a),c=Math.abs(l.x),u=Math.abs(l.y);ye(c)<=ye(n.x)&&(ye(c)<ye(n.x)&&(o.length=0),o.push({type:"points",points:{thisPoint:s,otherPoint:a},nudge:a.x-s.x}),n.x=c),ye(u)<=ye(n.y)&&(ye(u)<ye(n.y)&&(i.length=0),i.push({type:"points",points:{thisPoint:s,otherPoint:a},nudge:a.y-s.y}),n.y=u)}}collectGapSnaps({selectionPageBounds:e,minOffset:r,nearestSnapsX:n,nearestSnapsY:o}){const{horizontal:i,vertical:s}=this.getVisibleGaps();for(const a of i){if(!wf(a.breadthIntersection[0],a.breadthIntersection[1],e.minY,e.maxY))continue;const c=a.startEdge[0].x+a.length/2-e.center.x;if(a.length>e.width&&ye(Math.abs(c))<=ye(r.x)){ye(Math.abs(c))<ye(r.x)&&(n.length=0),r.x=Math.abs(c);const y={type:"gap_center",gap:a,nudge:c},v=n.find(({type:$})=>$==="gap_center"),b=v&&li(a.breadthIntersection[0],a.breadthIntersection[1],v.gap.breadthIntersection[0],v.gap.breadthIntersection[1]);v&&v.gap.length>a.length&&b?n[n.indexOf(v)]=y:(!v||!b)&&n.push(y)}const d=a.startNode.pageBounds.minX-a.length,f=e.maxX,p=d-f;ye(Math.abs(p))<=ye(r.x)&&(ye(Math.abs(p))<ye(r.x)&&(n.length=0),r.x=Math.abs(p),n.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:p}));const g=a.endNode.pageBounds.maxX+a.length,m=e.minX,S=g-m;ye(Math.abs(S))<=ye(r.x)&&(ye(Math.abs(S))<ye(r.x)&&(n.length=0),r.x=Math.abs(S),n.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:S}))}for(const a of s){if(!wf(a.breadthIntersection[0],a.breadthIntersection[1],e.minX,e.maxX))continue;const c=a.startEdge[0].y+a.length/2-e.center.y;if(a.length>e.height&&ye(Math.abs(c))<=ye(r.y)){ye(Math.abs(c))<ye(r.y)&&(o.length=0),r.y=Math.abs(c);const y={type:"gap_center",gap:a,nudge:c},v=o.find(({type:$})=>$==="gap_center"),b=v&&wf(v.gap.breadthIntersection[0],v.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);v&&v.gap.length>a.length&&b?o[o.indexOf(v)]=y:(!v||!b)&&o.push(y);continue}const d=a.startNode.pageBounds.minY-a.length,f=e.maxY,p=d-f;ye(Math.abs(p))<=ye(r.y)&&(ye(Math.abs(p))<ye(r.y)&&(o.length=0),r.y=Math.abs(p),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:p}));const g=a.endNode.pageBounds.maxY+a.length,m=e.minY,S=g-m;ye(Math.abs(S))<=ye(r.y)&&(ye(Math.abs(S))<ye(r.y)&&(o.length=0),r.y=Math.abs(S),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:S}))}}getPointSnapLines({nearestSnapsX:e,nearestSnapsY:r}){const n={},o={};if(e.length>0){for(const i of e)if(i.type==="points"){const s=ye(i.points.otherPoint.x);n[s]||(n[s]=[]),n[s].push(i.points)}}if(r.length>0){for(const i of r)if(i.type==="points"){const s=ye(i.points.otherPoint.y);o[s]||(o[s]=[]),o[s].push(i.points)}}return Object.values(n).concat(Object.values(o)).map(i=>({id:ct(),type:"points",points:bk(i.map(s=>w.From(s.otherPoint)).concat(i.map(s=>w.From(s.thisPoint))),(s,a)=>s.equals(a))}))}getGapSnapLines({selectionPageBounds:e,nearestSnapsX:r,nearestSnapsY:n}){const{vertical:o,horizontal:i}=this.getVisibleGaps(),s={top:e.sides[0],right:e.sides[1],bottom:[e.corners[3],e.corners[2]],left:[e.corners[0],e.corners[3]]},a=[];if(r.length>0)for(const l of r){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:d,endNode:f,length:p,endEdge:g}}=l;switch(l.type){case"gap_center":{const m=(p-e.width)/2,S=li(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:ct(),gaps:[...js(i,d.id,m,"backward",S),{startEdge:u,endEdge:s.left},{startEdge:s.right,endEdge:g},...js(i,f.id,m,"forward",S)]});break}case"gap_duplicate":{const m=li(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:ct(),gaps:l.protrusionDirection==="left"?[{startEdge:s.right,endEdge:u.map(S=>S.clone().addXY(-d.pageBounds.width,0))},{startEdge:u,endEdge:g},...js(i,f.id,p,"forward",m)]:[...js(i,d.id,p,"backward",m),{startEdge:u,endEdge:g},{startEdge:g.map(S=>S.clone().addXY(l.gap.endNode.pageBounds.width,0)),endEdge:s.left}]});break}}}if(n.length>0)for(const l of n){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:d,endNode:f,length:p,endEdge:g}}=l;switch(l.type){case"gap_center":{const m=(p-e.height)/2,S=li(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:ct(),gaps:[...js(o,d.id,m,"backward",S),{startEdge:u,endEdge:s.top},{startEdge:s.bottom,endEdge:g},...js(o,l.gap.endNode.id,m,"forward",S)]});break}case"gap_duplicate":{const m=li(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:ct(),gaps:l.protrusionDirection==="top"?[{startEdge:s.bottom,endEdge:u.map(S=>S.clone().addXY(0,-d.pageBounds.height))},{startEdge:u,endEdge:g},...js(o,f.id,p,"forward",m)]:[...js(o,d.id,p,"backward",m),{startEdge:u,endEdge:g},{startEdge:g.map(S=>S.clone().addXY(0,f.pageBounds.height)),endEdge:s.top}]})}break}}return HSt(a),a}}gu=NSt();ub(gu,1,"getSnapPointsCache",cne,Kh);ub(gu,1,"getSnappablePoints",lne,Kh);ub(gu,1,"getSnappableGapNodes",ane,Kh);ub(gu,1,"getVisibleGaps",sne,Kh);BSt(gu,Kh);function p7(t,e){const{minX:r,maxX:n,minY:o,maxY:i}=e,s=[];switch(t){case"top":case"left":case"top_left":case"any":s.push({id:"top_left",handle:"top_left",x:r,y:o})}switch(t){case"top":case"right":case"top_right":case"any":s.push({id:"top_right",handle:"top_right",x:n,y:o})}switch(t){case"bottom":case"right":case"bottom_right":case"any":s.push({id:"bottom_right",handle:"bottom_right",x:n,y:i})}switch(t){case"bottom":case"left":case"bottom_left":case"any":s.push({id:"bottom_left",handle:"bottom_left",x:r,y:i})}return s}var WSt=Object.create,une=Object.defineProperty,KSt=Object.getOwnPropertyDescriptor,GSt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),dne=t=>{throw TypeError(t)},hne=(t,e,r)=>e in t?une(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,VSt=t=>[,,,WSt(null)],fne=["class","method","getter","setter","accessor","field","value","get","set"],pne=t=>t!==void 0&&typeof t!="function"?dne("Function expected"):t,YSt=(t,e,r,n,o)=>({kind:fne[t],name:e,metadata:n,addInitializer:i=>r._?dne("Already initialized"):o.push(pne(i||null))}),XSt=(t,e)=>hne(e,GSt("metadata"),t[3]),qSt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},ZSt=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=fne[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,KSt(o,r)),y=n.length-1;y>=0;y--)l=YSt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,pne(s)&&(S[g]=s);return S&&une(o,r,S),o},QSt=(t,e,r)=>hne(t,e+"",r),gne,db;const JSt=()=>null,ewt=()=>[];gne=[Y];class YR{constructor(e){this.manager=e,qSt(db,5,this),QSt(this,"editor"),this.editor=e.editor}getSnapGeometryCache(){const{editor:e}=this;return e.store.createComputedCache("handle snap geometry",r=>{const n=e.getShapeUtil(r).getHandleSnapGeometry(r),o=n.getSelfSnapOutline?n.getSelfSnapOutline.bind(n):JSt,i=n.getSelfSnapPoints?n.getSelfSnapPoints.bind(n):ewt;return{outline:n.outline===void 0?e.getShapeGeometry(r):n.outline,points:n.points??[],getSelfSnapOutline:o,getSelfSnapPoints:i}})}*iterateSnapPointsInPageSpace(e,r){var o,i;const n=(o=this.getSnapGeometryCache().get(e))==null?void 0:o.getSelfSnapPoints(r);if(n&&n.length){const s=ro(this.editor.getShapePageTransform(e));for(const a of n)yield s.applyToPoint(a)}for(const s of this.manager.getSnappableShapes()){if(s===e)continue;const a=(i=this.getSnapGeometryCache().get(s))==null?void 0:i.points;if(!a||!a.length)continue;const l=ro(this.editor.getShapePageTransform(s));for(const c of a)yield l.applyToPoint(c)}}*iterateSnapOutlines(e,r){var o,i;const n=(o=this.getSnapGeometryCache().get(e))==null?void 0:o.getSelfSnapOutline(r);n&&(yield{shapeId:e,outline:n});for(const s of this.manager.getSnappableShapes()){if(s===e)continue;const a=(i=this.getSnapGeometryCache().get(s))==null?void 0:i.outline;a&&(yield{shapeId:s,outline:a})}}getHandleSnapPosition({currentShapeId:e,handle:r,handleInPageSpace:n}){const o=this.manager.getSnapThreshold();let i=o,s=null;for(const c of this.iterateSnapPointsInPageSpace(e,r))w.DistMin(n,c,i)&&(i=w.Dist(n,c),s=c);if(s)return s;let a=o,l=null;for(const{shapeId:c,outline:u}of this.iterateSnapOutlines(e,r)){const d=ro(this.editor.getShapePageTransform(c)),f=this.editor.getPointInShapeSpace(c,n),p=u.nearestPoint(f),g=d.applyToPoint(p);w.DistMin(n,g,a)&&(a=w.Dist(n,g),l=g)}return l||null}snapHandle({currentShapeId:e,handle:r}){const o=ro(this.editor.getShapePageTransform(e)).applyToPoint(r),i=this.getHandleSnapPosition({currentShapeId:e,handle:r,handleInPageSpace:o});return i?(this.manager.setIndicators([{id:ct(),type:"points",points:[i]}]),{nudge:w.Sub(i,o)}):null}}db=VSt();ZSt(db,1,"getSnapGeometryCache",gne,YR);XSt(db,YR);var twt=Object.create,mne=Object.defineProperty,rwt=Object.getOwnPropertyDescriptor,nwt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),vne=t=>{throw TypeError(t)},yne=(t,e,r)=>e in t?mne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,owt=t=>[,,,twt(null)],Sne=["class","method","getter","setter","accessor","field","value","get","set"],wne=t=>t!==void 0&&typeof t!="function"?vne("Function expected"):t,iwt=(t,e,r,n,o)=>({kind:Sne[t],name:e,metadata:n,addInitializer:i=>r._?vne("Already initialized"):o.push(wne(i||null))}),swt=(t,e)=>yne(e,nwt("metadata"),t[3]),awt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},XR=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Sne[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,rwt(o,r)),y=n.length-1;y>=0;y--)l=iwt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,wne(s)&&(S[g]=s);return S&&mne(o,r,S),o},LE=(t,e,r)=>yne(t,typeof e!="symbol"?e+"":e,r),xne,bne,$ne,Gh;$ne=[Y],bne=[Y],xne=[Y];class Mm{constructor(e){this.editor=e,awt(Gh,5,this),LE(this,"shapeBounds"),LE(this,"handles"),LE(this,"_snapIndicators",fr("snapLines",void 0)),this.shapeBounds=new Kh(this),this.handles=new YR(this)}getIndicators(){return this._snapIndicators.get()??Xs}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(e){this._snapIndicators.set(e)}getSnapThreshold(){return 8/this.editor.getZoomLevel()}getSnappableShapes(){const{editor:e}=this,r=e.getViewportPageBounds(),n=e.getSelectedShapeIds(),o=new Set,i=s=>{if(Tn(s)){const l=e.getShape(s);l&&e.isShapeOfType(l,"frame")&&o.add(s)}const a=e.getSortedChildIdsForParent(s);for(const l of a){if(n.includes(l))continue;const c=e.getShape(l);if(!c||!e.getShapeUtil(c).canSnap(c))continue;const d=e.getShapePageBounds(l);if(d&&r.includes(d)){if(e.isShapeOfType(c,"group")){i(l);continue}o.add(l)}}};return i(this.getCurrentCommonAncestor()??e.getCurrentPageId()),o}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}Gh=owt();XR(Gh,1,"getSnapThreshold",$ne,Mm);XR(Gh,1,"getSnappableShapes",bne,Mm);XR(Gh,1,"getCurrentCommonAncestor",xne,Mm);swt(Gh,Mm);const lwt=/\r?\n|\r/g;function g7(t){return t.replace(lwt,`
|
|
109
|
-
`).split(`
|
|
110
|
-
`).map(e=>e||" ").join(`
|
|
111
|
-
`)}const cwt={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},uwt=/\s/;class dwt{constructor(e){C(this,"baseElm");this.editor=e;const r=this.editor.getContainer(),n=document.createElement("div");n.classList.add("tl-text"),n.classList.add("tl-text-measure"),n.tabIndex=-1,r.appendChild(n),this.baseElm=n,e.disposables.add(()=>{n.remove()})}measureText(e,r){var s;const n=(s=this.baseElm)==null?void 0:s.cloneNode();this.baseElm.insertAdjacentElement("afterend",n),n.setAttribute("dir","auto"),n.style.setProperty("unicode-bidi","plaintext"),n.style.setProperty("font-family",r.fontFamily),n.style.setProperty("font-style",r.fontStyle),n.style.setProperty("font-weight",r.fontWeight),n.style.setProperty("font-size",r.fontSize+"px"),n.style.setProperty("line-height",r.lineHeight*r.fontSize+"px"),n.style.setProperty("max-width",r.maxWidth===null?null:r.maxWidth+"px"),n.style.setProperty("min-width",r.minWidth===null?null:r.minWidth+"px"),n.style.setProperty("padding",r.padding),n.style.setProperty("overflow-wrap",r.disableOverflowWrapBreaking?"normal":"break-word"),n.textContent=g7(e);const o=n.scrollWidth,i=n.getBoundingClientRect();return n.remove(),{x:0,y:0,w:i.width,h:i.height,scrollWidth:o}}measureElementTextNodeSpans(e,{shouldTruncateToFirstLine:r=!1}={}){const n=[],o=e.getBoundingClientRect(),i=-o.left,s=-o.top,a=new Range,l=e.childNodes[0];let c=0,u=null,d=null,f=0,p=0,g=!1;for(const m of e.childNodes)if(m.nodeType===Node.TEXT_NODE)for(const S of m.textContent??""){a.setStart(l,c),a.setEnd(l,c+S.length);const y=a.getClientRects(),v=y[y.length-1],b=v.top+s,$=v.left+i,P=v.right+i,E=$<p,T=uwt.test(S);if(T!==d||b!==f||!u){if(u){if(r&&b!==f){g=!0;break}n.push(u)}u={box:{x:$,y:b,w:v.width,h:v.height},text:S},p=$}else E&&(u.box.x=$),u.box.w=E?u.box.w+v.width:P-u.box.x,u.text+=S;S===`
|
|
112
|
-
`&&(p=0),d=T,f=b,c+=S.length}return u&&n.push(u),{spans:n,didTruncate:g}}measureTextSpans(e,r){var c;if(e==="")return[];const n=(c=this.baseElm)==null?void 0:c.cloneNode();this.baseElm.insertAdjacentElement("afterend",n);const o=Math.ceil(r.width-r.padding*2);n.setAttribute("dir","auto"),n.style.setProperty("unicode-bidi","plaintext"),n.style.setProperty("width",`${o}px`),n.style.setProperty("height","min-content"),n.style.setProperty("font-size",`${r.fontSize}px`),n.style.setProperty("font-family",r.fontFamily),n.style.setProperty("font-weight",r.fontWeight),n.style.setProperty("line-height",`${r.lineHeight*r.fontSize}px`),n.style.setProperty("text-align",cwt[r.textAlign]);const i=r.overflow==="truncate-ellipsis"||r.overflow==="truncate-clip";i&&(n.style.setProperty("overflow-wrap","anywhere"),n.style.setProperty("word-break","break-all"));const s=g7(e);n.textContent=s;const{spans:a,didTruncate:l}=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:i});if(r.overflow==="truncate-ellipsis"&&l){n.textContent="…";const u=Math.ceil(this.measureElementTextNodeSpans(n).spans[0].box.w);n.style.setProperty("width",`${o-u}px`),n.textContent=s;const d=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:!0}).spans,f=d[d.length-1];return d.push({text:"…",box:{x:Math.min(f.box.x+f.box.w,r.width-r.padding-u),y:f.box.y,w:u,h:f.box.h}}),d}return n.remove(),a}}var hwt=Object.create,Ine=Object.defineProperty,fwt=Object.getOwnPropertyDescriptor,pwt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Pne=t=>{throw TypeError(t)},Ene=(t,e,r)=>e in t?Ine(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gwt=t=>[,,,hwt(null)],Cne=["class","method","getter","setter","accessor","field","value","get","set"],_ne=t=>t!==void 0&&typeof t!="function"?Pne("Function expected"):t,mwt=(t,e,r,n,o)=>({kind:Cne[t],name:e,metadata:n,addInitializer:i=>r._?Pne("Already initialized"):o.push(_ne(i||null))}),vwt=(t,e)=>Ene(e,pwt("metadata"),t[3]),ywt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Tne=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Cne[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,fwt(o,r)),y=n.length-1;y>=0;y--)l=mwt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,_ne(s)&&(S[g]=s);return S&&Ine(o,r,S),o},My=(t,e,r)=>Ene(t,typeof e!="symbol"?e+"":e,r),Ane,kne,Rm;const m7=(typeof process<"u",jK);kne=[lo],Ane=[lo];class hb{constructor(e){this.editor=e,ywt(Rm,5,this),My(this,"cancelRaf"),My(this,"isPaused",!0),My(this,"now",0),My(this,"prevPoint",new w),this.editor.disposables.add(this.dispose),this.start()}start(){var e;this.isPaused=!1,(e=this.cancelRaf)==null||e.call(this),this.cancelRaf=m7(this.tick),this.now=Date.now()}tick(){if(this.isPaused)return;const e=Date.now(),r=e-this.now;this.now=e,this.updatePointerVelocity(r),this.editor.emit("frame",r),this.editor.emit("tick",r),this.cancelRaf=m7(this.tick)}dispose(){var e;this.isPaused=!0,(e=this.cancelRaf)==null||e.call(this)}updatePointerVelocity(e){const{prevPoint:r,editor:{inputs:{currentScreenPoint:n,pointerVelocity:o}}}=this;if(e===0)return;const i=w.Sub(n,r);this.prevPoint=n.clone();const s=i.len(),a=s?i.div(s):new w(0,0),l=o.clone().lrp(a.mul(s/e),.5);Math.abs(l.x)<.01&&(l.x=0),Math.abs(l.y)<.01&&(l.y=0),o.equals(l)||(this.editor.inputs.pointerVelocity=l)}}Rm=gwt();Tne(Rm,1,"tick",kne,hb);Tne(Rm,1,"dispose",Ane,hb);vwt(Rm,hb);var Swt=Object.create,One=Object.defineProperty,wwt=Object.getOwnPropertyDescriptor,xwt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Mne=t=>{throw TypeError(t)},Rne=(t,e,r)=>e in t?One(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bwt=t=>[,,,Swt(null)],jne=["class","method","getter","setter","accessor","field","value","get","set"],Dne=t=>t!==void 0&&typeof t!="function"?Mne("Function expected"):t,$wt=(t,e,r,n,o)=>({kind:jne[t],name:e,metadata:n,addInitializer:i=>r._?Mne("Already initialized"):o.push(Dne(i||null))}),Iwt=(t,e)=>Rne(e,xwt("metadata"),t[3]),Pwt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Jo=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=jne[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,wwt(o,r)),y=n.length-1;y>=0;y--)l=$wt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,Dne(s)&&(S[g]=s);return S&&One(o,r,S),o},Ewt=(t,e,r)=>Rne(t,e+"",r),Lne,Nne,Fne,Bne,Une,zne,Hne,Wne,Kne,Gne,Vne,Yne,xn;Yne=[Y],Vne=[Y],Gne=[Y],Kne=[Y],Wne=[Y],Hne=[Y],zne=[Y],Une=[Y],Bne=[Y],Fne=[Y],Nne=[Y],Lne=[Y];class Yn{constructor(e,r){if(this.user=e,this.inferDarkMode=r,Pwt(xn,5,this),Ewt(this,"systemColorScheme",fr("systemColorScheme","light")),typeof window>"u"||!("matchMedia"in window))return;const n=window.matchMedia("(prefers-color-scheme: dark)");n!=null&&n.matches&&this.systemColorScheme.set("dark"),n==null||n.addEventListener("change",o=>{o.matches?this.systemColorScheme.set("dark"):this.systemColorScheme.set("light")})}updateUserPreferences(e){this.user.setUserPreferences({...this.user.userPreferences.get(),...e})}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),colorScheme:this.user.userPreferences.get().colorScheme,isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode(),isDynamicResizeMode:this.getIsDynamicResizeMode()}}getIsDarkMode(){switch(this.user.userPreferences.get().colorScheme){case"dark":return!0;case"light":return!1;case"system":return this.systemColorScheme.get()==="dark";default:return this.inferDarkMode?this.systemColorScheme.get()==="dark":!1}}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??As.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??As.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??As.name}getLocale(){return this.user.userPreferences.get().locale??As.locale}getColor(){return this.user.userPreferences.get().color??As.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??As.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??As.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??As.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??As.isPasteAtCursorMode}}xn=bwt();Jo(xn,1,"getUserPreferences",Yne,Yn);Jo(xn,1,"getIsDarkMode",Vne,Yn);Jo(xn,1,"getEdgeScrollSpeed",Gne,Yn);Jo(xn,1,"getAnimationSpeed",Kne,Yn);Jo(xn,1,"getId",Wne,Yn);Jo(xn,1,"getName",Hne,Yn);Jo(xn,1,"getLocale",zne,Yn);Jo(xn,1,"getColor",Une,Yn);Jo(xn,1,"getIsSnapMode",Bne,Yn);Jo(xn,1,"getIsWrapMode",Fne,Yn);Jo(xn,1,"getIsDynamicResizeMode",Nne,Yn);Jo(xn,1,"getIsPasteAtCursorMode",Lne,Yn);Iwt(xn,Yn);const Cwt={wheel:"onWheel",pointer_down:"onPointerDown",pointer_move:"onPointerMove",long_press:"onLongPress",pointer_up:"onPointerUp",right_click:"onRightClick",middle_click:"onMiddleClick",key_down:"onKeyDown",key_up:"onKeyUp",key_repeat:"onKeyRepeat",cancel:"onCancel",complete:"onComplete",interrupt:"onInterrupt",double_click:"onDoubleClick",triple_click:"onTripleClick",quadruple_click:"onQuadrupleClick",tick:"onTick"},_wt=["brushing","cropping","dragging","dragging_handle","drawing","erasing","lasering","resizing","rotating","scribble_brushing","translating"];class he{constructor(e,r){C(this,"performanceTracker");C(this,"id");C(this,"type");C(this,"shapeType");C(this,"initial");C(this,"children");C(this,"isLockable");C(this,"parent");C(this,"_path");C(this,"_current");C(this,"_isActive");C(this,"_currentToolIdMask",fr("curent tool id mask",void 0));this.editor=e;const{id:n,children:o,initial:i,isLockable:s}=this.constructor;this.id=n,this._isActive=fr("toolIsActive"+this.id,!1),this._current=fr("toolState"+this.id,void 0),this._path=Y("toolPath"+this.id,()=>{const a=this.getCurrent();return this.id+(a?`.${a.getPath()}`:"")}),this.parent=r??{},this.parent?o&&i?(this.type="branch",this.initial=i,this.children=Object.fromEntries(o().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",o&&i&&(this.initial=i,this.children=Object.fromEntries(o().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=s,this.performanceTracker=new fK}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}transition(e,r={}){var i;const n=e.split(".");let o=this;for(let s=0;s<n.length;s++){const a=n[s],l=o.getCurrent(),c=(i=o.children)==null?void 0:i[a];if(!c)throw Error(`${o.id} - no child state exists with the id ${a}.`);if((l==null?void 0:l.id)!==c.id&&(l==null||l.exit(r,a),o._current.set(c),c.enter(r,(l==null?void 0:l.id)||"initial"),!c.getIsActive()))break;o=c}return this}handleEvent(e){var o;const r=Cwt[e.name],n=this._current.__unsafe__getWithoutCapture();(o=this[r])==null||o.call(this,e),this._isActive.__unsafe__getWithoutCapture()&&n&&n===this._current.__unsafe__getWithoutCapture()&&n.handleEvent(e)}enter(e,r){var n;if(Xt.measurePerformance.get()&&_wt.includes(this.id)&&this.performanceTracker.start(this.id),this._isActive.set(!0),(n=this.onEnter)==null||n.call(this,e,r),this.children&&this.initial&&this.getIsActive()){const o=this.children[this.initial];this._current.set(o),o.enter(e,r)}}exit(e,r){var n,o;Xt.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this._isActive.set(!1),(n=this.onExit)==null||n.call(this,e,r),this.getIsActive()||(o=this.getCurrent())==null||o.exit(e,r)}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(e){this._currentToolIdMask.set(e)}}C(he,"id"),C(he,"initial"),C(he,"children"),C(he,"isLockable",!0);class M2 extends he{static children(){return[]}onKeyDown(e){var r;switch(e.code){case"KeyZ":{if(!(e.shiftKey||e.ctrlKey)){const n=this.getCurrent();n&&((r=n.getCurrent())==null?void 0:r.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...e,onInteractionEnd:n.id})}break}}}}C(M2,"id","root"),C(M2,"initial","");var Twt=Object.create,Xne=Object.defineProperty,Awt=Object.getOwnPropertyDescriptor,qne=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Zne=t=>{throw TypeError(t)},Qne=(t,e,r)=>e in t?Xne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kwt=t=>[,,,Twt((t==null?void 0:t[qne("metadata")])??null)],Jne=["class","method","getter","setter","accessor","field","value","get","set"],eoe=t=>t!==void 0&&typeof t!="function"?Zne("Function expected"):t,Owt=(t,e,r,n,o)=>({kind:Jne[t],name:e,metadata:n,addInitializer:i=>r._?Zne("Already initialized"):o.push(eoe(i||null))}),Mwt=(t,e)=>Qne(e,qne("metadata"),t[3]),Rwt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},ae=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Jne[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,Awt(o,r)),y=n.length-1;y>=0;y--)l=Owt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,eoe(s)&&(S[g]=s);return S&&Xne(o,r,S),o},xe=(t,e,r)=>Qne(t,typeof e!="symbol"?e+"":e,r),toe,roe,noe,ooe,ioe,soe,aoe,loe,coe,uoe,doe,hoe,foe,poe,goe,moe,voe,yoe,Soe,woe,xoe,boe,$oe,Ioe,Poe,Eoe,Coe,_oe,Toe,Aoe,koe,Ooe,Moe,Roe,joe,Doe,Loe,Noe,Foe,Boe,Uoe,zoe,Hoe,Woe,Koe,Goe,Voe,Yoe,Xoe,qoe,Zoe,Qoe,Joe,eie,tie,rie,nie,oie,iie,sie,aie,lie,cie,uie,die,hie,fie,pie,gie,R2,se;class ie extends(R2=kPe,gie=[Y],pie=[Y],fie=[Y],hie=[Y],die=[Y],uie=[Y],cie=[Y],lie=[Y],aie=[Y],sie=[Y],iie=[Y],oie=[Y],nie=[Y],rie=[Y],tie=[Y],eie=[Y],Joe=[Y],Qoe=[Y],Zoe=[Y],qoe=[Y],Xoe=[Y],Yoe=[Y],Voe=[Y],Goe=[Y],Koe=[Y],Woe=[Y],Hoe=[Y],zoe=[Y],Uoe=[Y],Boe=[Y],Foe=[Y],Noe=[Y],Loe=[Y],Doe=[Y],joe=[Y],Roe=[Y],Moe=[Y],Ooe=[Y],koe=[Y],Aoe=[Y],Toe=[Y],_oe=[Y],Coe=[Y],Eoe=[Y],Poe=[Y],Ioe=[Y],$oe=[Y],boe=[Y],xoe=[Y],woe=[Y],Soe=[Y],yoe=[Y],voe=[Y],moe=[Y],goe=[Y],poe=[Y],foe=[Y],hoe=[Y],doe=[Y],uoe=[Y],coe=[Y],loe=[Y],aoe=[Y],soe=[Y({isEqual:(e,r)=>e.equals(r)})],ioe=[Y],ooe=[Y],noe=[lo],roe=[lo],toe=[lo],R2){constructor({store:e,user:r,shapeUtils:n,bindingUtils:o,tools:i,getContainer:s,cameraOptions:a,initialState:l,autoFocus:c,inferDarkMode:u,options:d}){super(),Rwt(se,5,this),xe(this,"options"),xe(this,"store"),xe(this,"root"),xe(this,"disposables",new Set),xe(this,"isDisposed",!1),xe(this,"_tickManager"),xe(this,"snaps"),xe(this,"timers"),xe(this,"user"),xe(this,"textMeasure"),xe(this,"environment"),xe(this,"scribbles"),xe(this,"sideEffects"),xe(this,"edgeScrollManager"),xe(this,"focusManager"),xe(this,"getContainer"),xe(this,"shapeUtils"),xe(this,"styleProps"),xe(this,"bindingUtils"),xe(this,"history"),xe(this,"_shouldIgnoreShapeLock",!1),xe(this,"_crashingError",null),xe(this,"_isChangingStyleTimeout",-1),xe(this,"_cameraOptions",fr("camera options",fN)),xe(this,"_viewportAnimation",null),xe(this,"_willSetInitialBounds",!0),xe(this,"_isLockedOnFollowingUser",fr("isLockedOnFollowingUser",!1)),xe(this,"_cameraState",fr("camera state","idle")),xe(this,"_cameraStateTimeoutRemaining",0),xe(this,"_currentPageShapeIds"),xe(this,"_parentIdsToChildIds"),xe(this,"animatingShapes",new Map),xe(this,"externalAssetContentHandlers",{file:null,url:null}),xe(this,"temporaryAssetPreview",new Map),xe(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null}),xe(this,"inputs",{originPagePoint:new w,originScreenPoint:new w,previousPagePoint:new w,previousScreenPoint:new w,currentPagePoint:new w,currentScreenPoint:new w,keys:new Set,buttons:new Set,isPen:!1,shiftKey:!1,ctrlKey:!1,altKey:!1,isDragging:!1,isPointing:!1,isPinching:!1,isEditing:!1,isPanning:!1,isSpacebarPanning:!1,pointerVelocity:new w}),xe(this,"_clickManager",new cb(this)),xe(this,"_prevCursor","default"),xe(this,"_shiftKeyTimeout",-1),xe(this,"_altKeyTimeout",-1),xe(this,"_ctrlKeyTimeout",-1),xe(this,"_restoreToolId","select"),xe(this,"_pinchStart",1),xe(this,"_didPinch",!1),xe(this,"_selectedShapeIdsAtPointerDown",[]),xe(this,"_longPressTimeout",-1),xe(this,"capturedPointerId",null),xe(this,"performanceTracker"),xe(this,"performanceTrackerTimeout",-1),xe(this,"_pendingEventsForNextTick",[]),this.options={...rSt,...d},this.store=e,this.disposables.add(this.store.dispose.bind(this.store)),this.history=new kSt({store:e,annotateError:I=>{this.annotateError(I,{origin:"history.batch",willCrashApp:!0}),this.crash(I)}}),this.snaps=new Mm(this),this.timers=new Yme,this.disposables.add(this.timers.dispose.bind(this.timers)),this._cameraOptions.set({...fN,...a}),this.user=new Yn(r??QV(),u??!1),this.getContainer=s,this.textMeasure=new dwt(this),this._tickManager=new hb(this);class f extends M2{}C(f,"initial",l??""),this.root=new f(this),this.root.children={};const p=aY(n),g={},m={},S=new Map;for(const I of p){const _=new I(this);g[I.type]=_;const k=AG(I.props??{});m[I.type]=k;for(const D of k.keys())if(!S.has(D.id))S.set(D.id,D);else if(S.get(D.id)!==D)throw Error(`Multiple style props with id "${D.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=g,this.styleProps=m;const y=oY(o),v={};for(const I of y){const _=new I(this);v[I.type]=_}this.bindingUtils=v;for(const I of[...i]){if(yi(this.root.children,I.id))throw Error(`Can't override tool with id "${I.id}"`);this.root.children[I.id]=new I(this,this.root)}this.environment=new CSt(this),this.scribbles=new RSt(this);const b=(I,_)=>{let k=null;const D=I.selectedShapeIds.filter(M=>!_.has(M));D.length!==I.selectedShapeIds.length&&(k||(k={...I}),k.selectedShapeIds=D);const R=I.erasingShapeIds.filter(M=>!_.has(M));R.length!==I.erasingShapeIds.length&&(k||(k={...I}),k.erasingShapeIds=R),I.hoveredShapeId&&_.has(I.hoveredShapeId)&&(k||(k={...I}),k.hoveredShapeId=null),I.editingShapeId&&_.has(I.editingShapeId)&&(k||(k={...I}),k.editingShapeId=null);const j=I.hintingShapeIds.filter(M=>!_.has(M));return j.length!==I.hintingShapeIds.length&&(k||(k={...I}),k.hintingShapeIds=j),I.focusedGroupId&&_.has(I.focusedGroupId)&&(k||(k={...I}),k.focusedGroupId=null),k};this.sideEffects=this.store.sideEffects;let $=new Map;const P=new Set,E=new Set;let T=new Set;if(this.disposables.add(this.sideEffects.registerOperationCompleteHandler(()=>{var I,_,k,D;P.clear();for(const R of E){E.delete(R);const j=this.getShape(R);if(!j)continue;const M=this.getShapeUtil(j),U=(I=M.onChildrenChange)==null?void 0:I.call(M,j);U!=null&&U.length&&this.updateShapes(U)}if(T.size){const R=T;T=new Set;for(const j of R){const M=this.getBindingUtil(j);(_=M.onOperationComplete)==null||_.call(M)}}if($.size){const R=$;$=new Map;for(const j of R.values())(D=(k=this.getBindingUtil(j.binding)).onAfterDelete)==null||D.call(k,j)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterChange:(I,_)=>{var k,D,R,j;for(const M of this.getBindingsInvolvingShape(_))T.add(M.type),M.fromId===_.id&&((D=(k=this.getBindingUtil(M)).onAfterChangeFromShape)==null||D.call(k,{binding:M,shapeBefore:I,shapeAfter:_})),M.toId===_.id&&((j=(R=this.getBindingUtil(M)).onAfterChangeToShape)==null||j.call(R,{binding:M,shapeBefore:I,shapeAfter:_}));if(I.parentId!==_.parentId){const M=U=>{var K,z,W,J;const B=this.getShape(U);if(B)for(const oe of this.getBindingsInvolvingShape(B))T.add(oe.type),oe.fromId===B.id&&((z=(K=this.getBindingUtil(oe)).onAfterChangeFromShape)==null||z.call(K,{binding:oe,shapeBefore:B,shapeAfter:B})),oe.toId===B.id&&((J=(W=this.getBindingUtil(oe)).onAfterChangeToShape)==null||J.call(W,{binding:oe,shapeBefore:B,shapeAfter:B}))};M(_.id),this.visitDescendants(_.id,M)}if(I.parentId!==_.parentId&&En(_.parentId)){const M=new Set([I.id]);this.visitDescendants(I.id,U=>{M.add(U)});for(const U of this.getPageStates()){if(U.pageId===_.parentId)continue;const B=b(U,M);B&&this.store.put([B])}}I.parentId&&Tn(I.parentId)&&E.add(I.parentId),_.parentId!==I.parentId&&Tn(_.parentId)&&E.add(_.parentId)},beforeDelete:I=>{var R,j,M,U;if(P.has(I.id))return;I.parentId&&Tn(I.parentId)&&E.add(I.parentId),P.add(I.id);const _=[];for(const B of this.getBindingsInvolvingShape(I)){T.add(B.type),_.push(B.id);const K=this.getBindingUtil(B);B.fromId===I.id?((R=K.onBeforeIsolateToShape)==null||R.call(K,{binding:B,removedShape:I}),(j=K.onBeforeDeleteFromShape)==null||j.call(K,{binding:B,shape:I})):((M=K.onBeforeIsolateFromShape)==null||M.call(K,{binding:B,removedShape:I}),(U=K.onBeforeDeleteToShape)==null||U.call(K,{binding:B,shape:I}))}_.length&&this.deleteBindings(_);const k=new Set([I.id]),D=Ae(this.getPageStates().map(B=>b(B,k)));D.length&&this.store.put(D)}},binding:{beforeCreate:I=>{var k,D;const _=(D=(k=this.getBindingUtil(I)).onBeforeCreate)==null?void 0:D.call(k,{binding:I});return _||I},afterCreate:I=>{var _,k;T.add(I.type),(k=(_=this.getBindingUtil(I)).onAfterCreate)==null||k.call(_,{binding:I})},beforeChange:(I,_)=>{var D,R;const k=(R=(D=this.getBindingUtil(_)).onBeforeChange)==null?void 0:R.call(D,{bindingBefore:I,bindingAfter:_});return k||_},afterChange:(I,_)=>{var k,D;T.add(_.type),(D=(k=this.getBindingUtil(_)).onAfterChange)==null||D.call(k,{bindingBefore:I,bindingAfter:_})},beforeDelete:I=>{var _,k;(k=(_=this.getBindingUtil(I)).onBeforeDelete)==null||k.call(_,{binding:I})},afterDelete:I=>{var _,k;(k=(_=this.getBindingUtil(I)).onAfterDelete)==null||k.call(_,{binding:I}),T.add(I.type)}},page:{afterCreate:I=>{const _=qi.createId(I.id),k=fi.createId(I.id);this.store.has(_)||this.store.put([qi.create({id:_})]),this.store.has(k)||this.store.put([fi.create({id:k,pageId:I.id})])},afterDelete:(I,_)=>{var R,j;if(((R=this.getInstanceState())==null?void 0:R.currentPageId)===I.id){const M=(j=this.getPages().find(U=>U.id!==I.id))==null?void 0:j.id;M?this.store.put([{...this.getInstanceState(),currentPageId:M}]):_==="user"&&this.store.ensureStoreIsUsable()}const k=qi.createId(I.id),D=fi.createId(I.id);this.store.remove([k,D])}},instance:{afterChange:(I,_,k)=>{var D;if(!this.store.has(_.currentPageId)){const R=this.store.has(I.currentPageId)?I.currentPageId:(D=this.getPages()[0])==null?void 0:D.id;R?this.store.update(_.id,j=>({...j,currentPageId:R})):k==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(I,_)=>{if((I==null?void 0:I.selectedShapeIds)!==(_==null?void 0:_.selectedShapeIds)){const k=_.selectedShapeIds.filter(R=>{var M,U;let j=(M=this.getShape(R))==null?void 0:M.parentId;for(;Tn(j);){if(_.selectedShapeIds.includes(j))return!1;j=(U=this.getShape(j))==null?void 0:U.parentId}return!0});let D=null;if(k.length>0){const R=this.findCommonAncestor(Ae(k.map(j=>this.getShape(j))),j=>this.isShapeOfType(j,"group"));R&&(D=R)}else _!=null&&_.focusedGroupId&&(D=_.focusedGroupId);(k.length!==_.selectedShapeIds.length||D!==_.focusedGroupId)&&this.store.put([{..._,selectedShapeIds:k,focusedGroupId:D??null}])}}}})),this._currentPageShapeIds=vSt(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=mSt(this.store),this.disposables.add(this.store.listen(I=>{this.emit("change",I)})),this.disposables.add(this.history.dispose),this.run(()=>{this.store.ensureStoreIsUsable(),this._updateCurrentPageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]})},{history:"ignore"}),l&&this.root.children[l]===void 0)throw Error(`No state found for initialState "${l}".`);this.root.enter(void 0,"initial"),this.edgeScrollManager=new ESt(this),this.focusManager=new _St(this,c),this.disposables.add(this.focusManager.dispose.bind(this.focusManager)),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.on("tick",this._flushEventsForTick),this.timers.requestAnimationFrame(()=>{this._tickManager.start()}),this.performanceTracker=new fK}dispose(){this.disposables.forEach(e=>e()),this.disposables.clear(),this.isDisposed=!0}getShapeUtil(e){const r=typeof e=="string"?e:e.type,n=Dn(this.shapeUtils,r);return Qe(n,`No shape util found for type "${r}"`),n}getBindingUtil(e){const r=typeof e=="string"?e:e.type,n=Dn(this.bindingUtils,r);return Qe(n,`No binding util found for type "${r}"`),n}undo(){return this._flushEventsForTick(0),this.complete(),this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this._flushEventsForTick(0),this.complete(),this.history.redo(),this}clearHistory(){return this.history.clear(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(e){return console.warn(typeof e=="string"?`[tldraw] \`editor.history.mark("${e}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`:"[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead."),this.history._mark(e??ct()),this}markHistoryStoppingPoint(e){const r=`[${e??"stop"}]_${ct()}`;return this.history._mark(r),r}getMarkIdMatching(e){return this.history.getMarkIdMatching(e)}squashToMark(e){return this.history.squashToMark(e),this}bail(){return this.history.bail(),this}bailToMark(e){return this.history.bailToMark(e),this}run(e,r){const n=this._shouldIgnoreShapeLock;this._shouldIgnoreShapeLock=(r==null?void 0:r.ignoreShapeLock)??n;try{this.history.batch(e,r)}finally{this._shouldIgnoreShapeLock=n}return this}batch(e,r){return this.run(e,r)}annotateError(e,{origin:r,willCrashApp:n,tags:o,extras:i}){const s=this.createErrorAnnotations(r,n);return Pk(e,{tags:{...s.tags,...o},extras:{...s.extras,...i}}),n&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(e,r){try{const n=this.getEditingShapeId();return{tags:{origin:e,willCrashApp:r},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes(),editingShape:n?this.getShape(n):void 0,inputs:this.inputs}}}catch{return{tags:{origin:e,willCrashApp:r},extras:{}}}}getCrashingError(){return this._crashingError}crash(e){return this._crashingError=e,this.store.markAsPossiblyCorrupted(),this.emit("crash",{error:e}),this}getPath(){return this.root.getPath().split("root.")[1]}isIn(e){const r=e.split(".").reverse();let n=this.root;for(;r.length>0;){const o=r.pop();if(!o)return!0;const i=n.getCurrent();if((i==null?void 0:i.id)===o){if(r.length===0)return!0;n=i;continue}else return!1}return!1}isInAny(...e){return e.some(r=>this.isIn(r))}setCurrentTool(e,r={}){return this.root.transition(e,r),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const e=this.getCurrentTool();return e?e.getCurrentToolIdMask()??e.id:""}getStateDescendant(e){var o;const r=e.split(".").reverse();let n=this.root;for(;r.length>0;){const i=r.pop();if(!i)return n;const s=(o=n.children)==null?void 0:o[i];if(!s)return;n=s}return n}getDocumentSettings(){return this.store.get(tT)}updateDocumentSettings(e){return this.run(()=>{this.store.put([{...this.getDocumentSettings(),...e}])},{history:"ignore"}),this}getInstanceState(){return this.store.get(fn)}updateInstanceState(e,r){return this._updateInstanceState(e,{history:"ignore",...r}),e.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),e.isChangingStyle===!0&&(this._isChangingStyleTimeout=this.timers.setTimeout(()=>{this._updateInstanceState({isChangingStyle:!1},{history:"ignore"})},2e3))),this}_updateInstanceState(e,r){this.run(()=>{this.store.put([{...this.getInstanceState(),...e}])},r)}getOpenMenus(){return this.getInstanceState().openMenus}addOpenMenu(e){const r=new Set(this.getOpenMenus());return r.has(e)||(r.add(e),this.updateInstanceState({openMenus:[...r]})),this}deleteOpenMenu(e){const r=new Set(this.getOpenMenus());return r.has(e)&&(r.delete(e),this.updateInstanceState({openMenus:[...r]})),this}clearOpenMenus(){return this.getOpenMenus().length&&this.updateInstanceState({openMenus:[]}),this}getIsMenuOpen(){return this.getOpenMenus().length>0}setCursor(e){return this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...e}}),this}getPageStates(){return this._getPageStatesQuery().get()}_getPageStatesQuery(){return this.store.query.records("instance_page_state")}getCurrentPageState(){return this.store.get(this._getCurrentPageStateId())}_getCurrentPageStateId(){return fi.createId(this.getCurrentPageId())}updateCurrentPageState(e){return this._updateCurrentPageState(e),this}_updateCurrentPageState(e){this.store.update(e.id??this.getCurrentPageState().id,r=>({...r,...e}))}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:e}=this.getCurrentPageState();return Ae(e.map(r=>this.store.get(r)))}setSelectedShapes(e){return this.run(()=>{const r=e.map(i=>typeof i=="string"?i:i.id),{selectedShapeIds:n}=this.getCurrentPageState(),o=new Set(n);if(r.length===o.size&&r.every(i=>o.has(i)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:r}])},{history:"record-preserveRedoStack"})}isAncestorSelected(e){const r=typeof e=="string"?e:(e==null?void 0:e.id)??null,n=this.getShape(r);if(!n)return!1;const o=this.getSelectedShapeIds();return!!this.findShapeAncestor(n,i=>o.includes(i.id))}select(...e){const r=typeof e[0]=="string"?e:e.map(n=>n.id);return this.setSelectedShapes(r),this}deselect(...e){const r=typeof e[0]=="string"?e:e.map(o=>o.id),n=this.getSelectedShapeIds();return n.length>0&&r.length>0&&this.setSelectedShapes(n.filter(o=>!r.includes(o))),this}selectAll(){const e=this.getSortedChildIdsForParent(this.getCurrentPageId());return e.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(e)),this)}selectNone(){return this.getSelectedShapeIds().length>0&&this.setSelectedShapes([]),this}getOnlySelectedShapeId(){var e;return((e=this.getOnlySelectedShape())==null?void 0:e.id)??null}getOnlySelectedShape(){const e=this.getSelectedShapes();return e.length===1?e[0]:null}getShapesPageBounds(e){const r=Ae(e.map(n=>this.getShapePageBounds(n)));return r.length===0?null:ee.Common(r)}getSelectionPageBounds(){return this.getShapesPageBounds(this.getSelectedShapeIds())}getShapesSharedRotation(e){let r=!1,n=0;for(let o=0,i=e.length;o<i;o++){const s=this.getShapePageTransform(e[o]);if(s)if(r){if(s.rotation()!==n)return 0}else r=!0,n=s.rotation()}return n}getSelectionRotation(){return this.getShapesSharedRotation(this.getSelectedShapeIds())}getShapesRotatedPageBounds(e){if(e.length===0)return;const r=this.getShapesSharedRotation(e);if(r===0)return this.getShapesPageBounds(e)??void 0;if(e.length===1){const o=this.getShapeGeometry(e[0]).bounds.clone(),i=this.getShapePageTransform(e[0]);return o.point=i.applyToPoint(o.point),o}const n=ee.FromPoints(e.flatMap(o=>{const i=this.getShapePageTransform(o);return i?i.applyToPoints(this.getShapeGeometry(o).bounds.corners):[]}).map(o=>o.rot(-r)));return n.point=n.point.rot(r),n}getSelectionRotatedPageBounds(){return this.getShapesRotatedPageBounds(this.getSelectedShapeIds())}getSelectionRotatedScreenBounds(){const e=this.getSelectionRotatedPageBounds();if(!e)return;const{x:r,y:n}=this.pageToScreen(e.point),o=this.getZoomLevel();return new ee(r,n,e.width*o,e.height*o)}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const e=this.getFocusedGroupId();return e?this.getShape(e):void 0}setFocusedGroup(e){const r=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(r!==null){const n=this.getShape(r);if(!n)throw Error(`Editor.setFocusedGroup: Shape with id ${r} does not exist`);if(!this.isShapeOfType(n,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${n.type}`)}return r===this.getFocusedGroupId()?this:this.run(()=>{this.store.update(this.getCurrentPageState().id,n=>({...n,focusedGroupId:r}))},{history:"record-preserveRedoStack"})}popFocusedGroupId(){const e=this.getFocusedGroup();if(e){const r=this.findShapeAncestor(e,n=>this.isShapeOfType(n,"group"));this.setFocusedGroup((r==null?void 0:r.id)??null),this.select(e.id)}else this.setFocusedGroup(null),this.selectNone();return this}getEditingShapeId(){return this.getCurrentPageState().editingShapeId}getEditingShape(){const e=this.getEditingShapeId();return e?this.getShape(e):void 0}setEditingShape(e){const r=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(r!==this.getEditingShapeId()){if(r){const n=this.getShape(r);if(n&&this.getShapeUtil(n).canEdit(n))return this.run(()=>{this._updateCurrentPageState({editingShapeId:r})},{history:"ignore"}),this}this.run(()=>{this._updateCurrentPageState({editingShapeId:null})},{history:"ignore"})}return this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const e=this.getHoveredShapeId();return e?this.getShape(e):void 0}setHoveredShape(e){const r=typeof e=="string"?e:(e==null?void 0:e.id)??null;return r===this.getHoveredShapeId()?this:(this.run(()=>{this.updateCurrentPageState({hoveredShapeId:r})},{history:"ignore"}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const e=this.getHintingShapeIds();return Ae(e.map(r=>this.getShape(r)))}setHintingShapes(e){const r=typeof e[0]=="string"?e:e.map(n=>n.id);return this.run(()=>{this._updateCurrentPageState({hintingShapeIds:bk(r)})},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const e=this.getErasingShapeIds();return Ae(e.map(r=>this.getShape(r)))}setErasingShapes(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id);r.sort();const n=this.getErasingShapeIds();return this.run(()=>{if(r.length===n.length){for(let o=0;o<r.length;o++)if(r[o]!==n[o]){this._updateCurrentPageState({erasingShapeIds:r});break}}else this._updateCurrentPageState({erasingShapeIds:r})},{history:"ignore"}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(e){const r=typeof e=="string"?e:(e==null?void 0:e.id)??null;return r!==this.getCroppingShapeId()&&this.run(()=>{if(!r)this.updateCurrentPageState({croppingShapeId:null});else{const n=this.getShape(r),o=this.getShapeUtil(n);n&&o.canCrop(n)&&this.updateCurrentPageState({croppingShapeId:r})}},{history:"ignore"}),this}_unsafe_getCameraId(){return qi.createId(this.getCurrentPageId())}getCamera(){const e=this.store.get(this._unsafe_getCameraId());if(this._isLockedOnFollowingUser.get()){const r=this.getCameraForFollowing();if(r)return{...e,...r}}return e}getViewportPageBoundsForFollowing(){const e=this.getInstanceState().followingUserId;if(!e)return null;const r=this.getCollaborators().find(d=>d.userId===e);if(!r)return null;const{w:n,h:o}=r.screenBounds,{x:i,y:s,z:a}=r.camera,l=new ee(-i,-s,n/a,o/a),c=this.getViewportScreenBounds().clone(),u=c.width/c.height;return c.width=l.width,c.height=c.width/u,c.height<l.height&&(c.height=l.height,c.width=c.height*u),c.center=l.center,c}getCameraForFollowing(){const e=this.getViewportPageBoundsForFollowing();return e?{x:-e.x,y:-e.y,z:this.getViewportScreenBounds().w/e.width}:null}getZoomLevel(){return this.getCamera().z}getInitialZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.initialZoom==="default")return 1;const{zx:r,zy:n}=y7(this,e);switch(e.constraints.initialZoom){case"fit-min":return Math.max(r,n);case"fit-max":return Math.min(r,n);case"fit-x":return r;case"fit-y":return n;case"fit-min-100":return Math.min(1,Math.max(r,n));case"fit-max-100":return Math.min(1,Math.min(r,n));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,n);default:throw dr(e.constraints.initialZoom)}}getBaseZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.baseZoom==="default")return 1;const{zx:r,zy:n}=y7(this,e);switch(e.constraints.baseZoom){case"fit-min":return Math.max(r,n);case"fit-max":return Math.min(r,n);case"fit-x":return r;case"fit-y":return n;case"fit-min-100":return Math.min(1,Math.max(r,n));case"fit-max-100":return Math.min(1,Math.min(r,n));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,n);default:throw dr(e.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(e){var n;const r=$t({...this._cameraOptions.__unsafe__getWithoutCapture(),...e});return((n=r.zoomSteps)==null?void 0:n.length)<1&&(r.zoomSteps=[1]),this._cameraOptions.set(r),this}getConstrainedCamera(e,r){const n=this.getCamera();let{x:o,y:i,z:s=n.z}=e;if(!(r!=null&&r.force)){const a=this.getCameraOptions(),l=a.zoomSteps[0],c=Cr(a.zoomSteps),u=this.getViewportScreenBounds();if(a.constraints){const{constraints:d}=a,f=Math.min(d.padding.y,u.w/2),p=Math.min(d.padding.x,u.h/2),g=ee.From(a.constraints.bounds),m=(u.w-p*2)/g.w,S=(u.h-f*2)/g.h,y=this.getBaseZoom(),v=c*y,b=l*y;if(r!=null&&r.reset&&(s=this.getInitialZoom()),s<b||s>v){const{x:R,y:j,z:M}=n,U=-R+u.w/M/2,B=-j+u.h/M/2;s=Pr(s,b,v);const K=-R+u.w/s/2,z=-j+u.h/s/2;o=R+K-U,i=j+z-B}const $=p/s-g.x,P=f/s-g.y,E=(u.w-p*2)/s-g.w,T=(u.h-f*2)/s-g.h,I=$+E*d.origin.x,_=P+T*d.origin.y,k=typeof d.behavior=="string"?d.behavior:d.behavior.x,D=typeof d.behavior=="string"?d.behavior:d.behavior.y;if(r!=null&&r.reset)o=I,i=_;else{switch(k){case"fixed":{o=I;break}case"contain":{s<m?o=I:o=Pr(o,$+E,$);break}case"inside":{s<m?o=Pr(o,$,(u.w-p)/s-g.w):o=Pr(o,$+E,$);break}case"outside":{o=Pr(o,p/s-g.w,(u.w-p)/s);break}case"free":break;default:throw dr(k)}switch(D){case"fixed":{i=_;break}case"contain":{s<S?i=_:i=Pr(i,P+T,P);break}case"inside":{s<S?i=Pr(i,P,(u.h-f)/s-g.h):i=Pr(i,P+T,P);break}case"outside":{i=Pr(i,f/s-g.h,(u.h-f)/s);break}case"free":break;default:throw dr(D)}}}else if(s>c||s<l){const{x:d,y:f,z:p}=n;s=Pr(s,l,c),o=d+(-d+u.w/s/2)-(-d+u.w/p/2),i=f+(-f+u.h/s/2)-(-f+u.h/p/2)}}return{x:o,y:i,z:s}}_setCamera(e,r){const n=this.getCamera(),{x:o,y:i,z:s}=this.getConstrainedCamera(e,r);return n.x===o&&n.y===i&&n.z===s?this:(os(()=>{const a={...n,x:o,y:i,z:s};this.run(()=>{this.store.put([a])},{history:"ignore"});const{currentScreenPoint:l,currentPagePoint:c}=this.inputs,{screenBounds:u}=this.store.unsafeGetWithoutCapture(fn);if(l.x/s-o!==c.x||l.y/s-i!==c.y){const d={type:"pointer",target:"canvas",name:"pointer_move",point:w.AddXY(l,u.x,u.y),pointerId:pN.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,button:0,isPen:this.getInstanceState().isPenMode??!1};r!=null&&r.immediate?this._flushEventForTick(d):this.dispatch(d)}this._tickCameraState()}),this)}setCamera(e,r){const{isLocked:n}=this._cameraOptions.__unsafe__getWithoutCapture();if(n&&!(r!=null&&r.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const o=w.Cast(e);Number.isFinite(o.x)||(o.x=0),Number.isFinite(o.y)||(o.y=0),(o.z===void 0||!Number.isFinite(o.z))&&(e.z=this.getZoomLevel());const i=this.getConstrainedCamera(o,r);if(r!=null&&r.animation){const{width:s,height:a}=this.getViewportScreenBounds();this._animateToViewport(new ee(-i.x,-i.y,s/i.z,a/i.z),r)}else this._setCamera(i,{...r,force:!0});return this}centerOnPoint(e,r){const{isLocked:n}=this.getCameraOptions();if(n&&!(r!=null&&r.force))return this;const{width:o,height:i}=this.getViewportPageBounds();return this.setCamera(new w(-(e.x-o/2),-(e.y-i/2),this.getCamera().z),r),this}zoomToFit(e){const r=[...this.getCurrentPageShapeIds()];if(r.length<=0)return this;const n=ee.Common(Ae(r.map(o=>this.getShapePageBounds(o))));return this.zoomToBounds(n,e),this}resetZoom(e=this.getViewportScreenCenter(),r){const{isLocked:n,constraints:o}=this.getCameraOptions();if(n&&!(r!=null&&r.force))return this;const i=this.getCamera(),{x:s,y:a,z:l}=i,{x:c,y:u}=e;let d=1;if(o){const f=this.getInitialZoom();l!==f&&(d=f)}return this.setCamera(new w(s+(c/d-c)-(c/l-c),a+(u/d-u)-(u/l-u),d),r),this}zoomIn(e=this.getViewportScreenCenter(),r){const{isLocked:n}=this.getCameraOptions();if(n&&!(r!=null&&r.force))return this;const{x:o,y:i,z:s}=this.getCamera(),{zoomSteps:a}=this.getCameraOptions();if(a!==null&&a.length>1){const l=this.getBaseZoom();let c=Cr(a)*l;for(let u=1;u<a.length;u++){const d=a[u-1]*l,f=a[u]*l;if(!(f-s<=(f-d)/2)){c=f;break}}this.setCamera(new w(o+(e.x/c-e.x)-(e.x/s-e.x),i+(e.y/c-e.y)-(e.y/s-e.y),c),r)}return this}zoomOut(e=this.getViewportScreenCenter(),r){const{isLocked:n}=this.getCameraOptions();if(n&&!(r!=null&&r.force))return this;const{zoomSteps:o}=this.getCameraOptions();if(o!==null&&o.length>1){const i=this.getBaseZoom(),{x:s,y:a,z:l}=this.getCamera();let c=o[0]*i;for(let u=o.length-1;u>0;u--){const d=o[u-1]*i,f=o[u]*i;if(!(f-l>=(f-d)/2)){c=d;break}}this.setCamera(new w(s+(e.x/c-e.x)-(e.x/l-e.x),a+(e.y/c-e.y)-(e.y/l-e.y),c),r)}return this}zoomToSelection(e){const{isLocked:r}=this.getCameraOptions();if(r&&!(e!=null&&e.force))return this;const n=this.getSelectionPageBounds();return n&&this.zoomToBounds(n,{targetZoom:Math.max(1,this.getZoomLevel()),...e}),this}zoomToBounds(e,r){const n=this._cameraOptions.__unsafe__getWithoutCapture();if(n.isLocked&&!(r!=null&&r.force))return this;const o=this.getViewportScreenBounds(),i=(r==null?void 0:r.inset)??Math.min(d$e,o.width*.28),s=this.getBaseZoom(),a=n.zoomSteps[0],l=Cr(n.zoomSteps);let c=Pr(Math.min((o.width-i)/e.w,(o.height-i)/e.h),a*s,l*s);return(r==null?void 0:r.targetZoom)!==void 0&&(c=Math.min(r.targetZoom,c)),this.setCamera(new w(-e.x+(o.width-e.w*c)/2/c,-e.y+(o.height-e.h*c)/2/c,c),r),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(e){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=e;const{elapsed:r,easing:n,duration:o,start:i,end:s}=this._viewportAnimation;if(r>o){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new w(-s.x,-s.y,this.getViewportScreenBounds().width/s.width));return}const a=o-r,l=n(1-a/o),c=i.minX+(s.minX-i.minX)*l,u=i.minY+(s.minY-i.minY)*l,d=i.maxX+(s.maxX-i.maxX)*l;this._setCamera(new w(-c,-u,this.getViewportScreenBounds().width/(d-c)),{force:!0})}_animateToViewport(e,r={animation:oI}){const{animation:n,...o}=r;if(!n)return;const{duration:i=0,easing:s=pr.easeInOutCubic}=n,a=this.user.getAnimationSpeed(),l=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),i===0||a===0?this._setCamera(new w(-e.x,-e.y,this.getViewportScreenBounds().width/e.width),{...o}):(this._viewportAnimation={elapsed:0,duration:i/a,easing:s,start:l.clone(),end:e.clone()},this.once("stop-camera-animation",()=>{this.off("tick",this._animateViewport),this._viewportAnimation=null}),this.on("tick",this._animateViewport),this)}slideCamera(e={}){const{isLocked:r}=this.getCameraOptions();if(r&&!(e!=null&&e.force))return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:o,friction:i=this.options.cameraSlideFriction,direction:s,speedThreshold:a=.01}=e;let l=Math.min(o,1);const c=()=>{this.off("tick",u),this.off("stop-camera-animation",c)};this.once("stop-camera-animation",c);const u=d=>{const{x:f,y:p,z:g}=this.getCamera(),m=w.Mul(s,l*d/g);l*=1-i,l<a?c():this._setCamera(new w(f+m.x,p+m.y,g))};return this.on("tick",u),this}zoomToUser(e,r={animation:{duration:500}}){const n=this.getCollaborators().find(o=>o.userId===e);return n?(this.run(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const o=n.currentPageId===this.getCurrentPageId();o||this.setCurrentPage(n.currentPageId),r&&r.animation&&!o&&(r.animation=void 0),this.centerOnPoint(n.cursor,r);const{highlightedUserIds:i}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...i,e]}),this.timers.setTimeout(()=>{const s=[...this.getInstanceState().highlightedUserIds],a=s.indexOf(e);a<0||(s.splice(a,1),this.updateInstanceState({highlightedUserIds:s}))},this.options.collaboratorIdleTimeoutMs)}),this):this}updateViewportScreenBounds(e,r=!1){if(e instanceof HTMLElement){const a=e.getBoundingClientRect();e=new ee(a.left||a.x,a.top||a.y,Math.max(a.width,1),Math.max(a.height,1))}else e.width=Math.max(e.width,1),e.height=Math.max(e.height,1);const n=[e.minY!==0,!ul(document.body.scrollWidth,e.maxX,1),!ul(document.body.scrollHeight,e.maxY,1),e.minX!==0],{_willSetInitialBounds:o}=this;this._willSetInitialBounds=!1;const{screenBounds:i,insets:s}=this.getInstanceState();if(e.equals(i)&&n.every((a,l)=>a===s[l]))return this;if(o)this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this.setCamera(this.getCamera());else if(r&&!this.getInstanceState().followingUserId){const a=this.getViewportPageBounds().center;this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this._setCamera(w.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:e,y:r,w:n,h:o}=this.getInstanceState().screenBounds;return new ee(e,r,n,o)}getViewportScreenCenter(){const e=this.getViewportScreenBounds();return new w(e.midX-e.minX,e.midY-e.minY)}getViewportPageBounds(){const{w:e,h:r}=this.getViewportScreenBounds(),{x:n,y:o,z:i}=this.getCamera();return new ee(-n,-o,e/i,r/i)}screenToPage(e){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(fn),{x:n,y:o,z:i=1}=this.getCamera();return new w((e.x-r.x)/i-n,(e.y-r.y)/i-o,e.z??.5)}pageToScreen(e){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(fn),{x:n,y:o,z:i=1}=this.getCamera();return new w((e.x+n)*i+r.x,(e.y+o)*i+r.y,e.z??.5)}pageToViewport(e){const{x:r,y:n,z:o=1}=this.getCamera();return new w((e.x+r)*o,(e.y+n)*o,e.z??.5)}_getCollaboratorsQuery(){return this.store.query.records("instance_presence",()=>({userId:{neq:this.user.getId()}}))}getCollaborators(){const e=this._getCollaboratorsQuery().get();return e.length?[...new Set(e.map(n=>n.userId))].sort().map(n=>e.filter(i=>i.userId===n).sort((i,s)=>s.lastActivityTimestamp-i.lastActivityTimestamp)[0]):Xs}getCollaboratorsOnCurrentPage(){const e=this.getCurrentPageId();return this.getCollaborators().filter(r=>r.currentPageId===e)}startFollowingUser(e){this.stopFollowingUser();const r=this._getCollaboratorsQuery().get().filter(i=>i.userId===e);if(!r.length)return console.warn("User not found"),this;const n=this.user.getId();if(n||console.warn("You should set the userId for the current instance before following a user"),r.some(i=>i.followingUserId===n))return this;const o=Y("latestLeaderPresence",()=>this.getCollaborators().find(i=>i.userId===e));return os(()=>{this.updateInstanceState({followingUserId:e},{history:"ignore"});const i=Sl("update current page",()=>{const l=o.get();if(!l){this.stopFollowingUser();return}l.currentPageId!==this.getCurrentPageId()&&this.getPage(l.currentPageId)&&this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:l.currentPageId}]),this._isLockedOnFollowingUser.set(!0)},{history:"ignore"})}),s=()=>{i(),this._isLockedOnFollowingUser.set(!1),this.off("frame",a),this.off("stop-following",s)},a=()=>{if(!o.get()){this.stopFollowingUser();return}if(this._isLockedOnFollowingUser.get())return;const c=this.user.getAnimationSpeed();if(c===0){this._isLockedOnFollowingUser.set(!0);return}const u=this.getViewportPageBoundsForFollowing();if(!u){this.stopFollowingUser();return}const d=this.getViewportPageBounds(),f=Math.abs(u.minX-d.minX)+Math.abs(u.maxX-d.maxX),p=Math.abs(u.minY-d.minY)+Math.abs(u.maxY-d.maxY);if(f<this.options.followChaseViewportSnap&&p<this.options.followChaseViewportSnap){this._isLockedOnFollowingUser.set(!0);return}const g=Pr(c*.5,.1,.8),m=new ee(He(d.minX,u.minX,g),He(d.minY,u.minY,g),He(d.width,u.width,g),He(d.height,u.height,g)),S=new w(-m.x,-m.y,this.getViewportScreenBounds().width/m.width);this.stopCameraAnimation(),this._setCamera(S)};this.once("stop-following",s),this.addListener("frame",a),a()}),this}stopFollowingUser(){return this.run(()=>{this.store.put([this.getCamera()]),this._isLockedOnFollowingUser.set(!1),this.updateInstanceState({followingUserId:null}),this.emit("stop-following")},{history:"ignore"}),this}getUnorderedRenderingShapes(e){const r=[];let n=this.options.maxShapesPerPage*2,o=this.options.maxShapesPerPage;const i=this.getErasingShapeIds(),s=(l,c,u)=>{const d=this.getShape(l);if(!d)return;c*=d.opacity;let f=!1;const p=this.getShapeUtil(d);e&&(f=!u&&i.includes(l),f&&(c*=.32)),r.push({id:l,shape:d,util:p,index:n,backgroundIndex:o,opacity:c}),n+=1,o+=1;const g=this.getSortedChildIdsForParent(l);if(!g.length)return;let m=null;p.providesBackgroundForChildren(d)&&(m=o,o=n,n+=this.options.maxShapesPerPage);for(const S of g)s(S,c,u||f);m!==null&&(o=m)},a=e?[this.getCurrentPage()]:this.getPages();for(const l of a)for(const c of this.getSortedChildIdsForParent(l.id))s(c,1,!1);return r}_decayCameraStateTimeout(e){this._cameraStateTimeoutRemaining-=e,!(this._cameraStateTimeoutRemaining>0)&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"))}_tickCameraState(){this._cameraStateTimeoutRemaining=this.options.cameraMovingTimeoutMs,this._cameraState.__unsafe__getWithoutCapture()==="idle"&&(this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout))}getCameraState(){return this._cameraState.get()}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(zme)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return this._getAllPagesQuery().get().sort(qr)}getCurrentPage(){return this.getPage(this.getCurrentPageId())}getCurrentPageId(){return this.getInstanceState().currentPageId}getPage(e){return this.store.get(typeof e=="string"?e:e.id)}getCurrentPageShapeIds(){return this._currentPageShapeIds.get()}getCurrentPageShapeIdsSorted(){return Array.from(this.getCurrentPageShapeIds()).sort()}getPageShapeIds(e){const r=typeof e=="string"?e:e.id,n=this.store.query.exec("shape",{parentId:{eq:r}});return this.getShapeAndDescendantIds(n.map(o=>o.id))}setCurrentPage(e){const r=typeof e=="string"?e:e.id;return this.store.has(r)?(this.stopFollowingUser(),this.complete(),this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:r}])},{history:"record-preserveRedoStack"})):(console.error("Tried to set the current page id to a page that doesn't exist."),this)}updatePage(e){return this.getInstanceState().isReadonly?this:this.getPage(e.id)?this.run(()=>this.store.update(e.id,n=>({...n,...e}))):this}createPage(e){return this.run(()=>{if(this.getInstanceState().isReadonly||this.getPages().length>=this.options.maxPages)return;const r=this.getPages(),n=lSt(e.name??"Page 1",r.map(s=>s.name));let o=e.index;(!o||r.some(s=>s.index===o))&&(o=Xi(r[r.length-1].index));const i=vo.create({meta:{},...e,name:n,index:o});this.store.put([i])}),this}deletePage(e){const r=typeof e=="string"?e:e.id;return this.run(()=>{if(this.getInstanceState().isReadonly)return;const n=this.getPages();if(n.length===1)return;const o=this.getPage(r);if(o){if(r===this.getCurrentPageId()){const i=n.findIndex(a=>a.id===r),s=n[i-1]??n[i+1];this.setCurrentPage(s.id)}this.store.remove([o.id])}}),this}duplicatePage(e,r=vo.createId()){if(this.getPages().length>=this.options.maxPages)return this;const n=typeof e=="string"?e:e.id,o=this.getPage(n);if(!o)return this;const i={...this.getCamera()},s=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(o.id));return this.run(()=>{var c;const a=this.getPages(),l=fg(o.index,(c=a[a.indexOf(o)+1])==null?void 0:c.index);if(this.createPage({name:o.name+" Copy",id:r,index:l}),this.setCurrentPage(r),this.setCamera(i),s)return this.putContentOntoCurrentPage(s)}),this}renamePage(e,r){const n=typeof e=="string"?e:e.id;return this.getInstanceState().isReadonly?this:(this.updatePage({id:n,name:r}),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(e){return this.getInstanceState().isReadonly?this:e.length<=0?this:(this.run(()=>this.store.put(e),{history:"ignore"}),this)}updateAssets(e){return this.getInstanceState().isReadonly?this:e.length<=0?this:(this.run(()=>{this.store.put(e.map(r=>({...this.store.get(r.id),...r})))},{history:"ignore"}),this)}deleteAssets(e){if(this.getInstanceState().isReadonly)return this;const r=typeof e[0]=="string"?e:e.map(n=>n.id);return r.length<=0?this:(this.run(()=>this.store.remove(r),{history:"ignore"}),this)}getAsset(e){return this.store.get(typeof e=="string"?e:e.id)}async resolveAssetUrl(e,r){if(!e)return null;const n=this.getAsset(e);if(!n)return null;const{screenScale:o=1,shouldResolveToOriginal:i=!1}=r,a=Math.max(.125,(u=>Math.pow(2,Math.ceil(Math.log2(u))))(o)),l="connection"in navigator?navigator.connection.effectiveType:null,c=this.getInstanceState().devicePixelRatio;return await this.store.props.assets.resolve(n,{screenScale:o||1,steppedScreenScale:a,dpr:c,networkEffectiveType:l,shouldResolveToOriginal:i})}async uploadAsset(e,r){return await this.store.props.assets.upload(e,r)}_getShapeGeometryCache(){return this.store.createComputedCache("bounds",e=>this.getShapeUtil(e).getGeometry(e),(e,r)=>e.props===r.props)}getShapeGeometry(e){return this._getShapeGeometryCache().get(typeof e=="string"?e:e.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",e=>{var r,n;return(n=(r=this.getShapeUtil(e)).getHandles)==null?void 0:n.call(r,e)})}getShapeHandles(e){return this._getShapeHandlesCache().get(typeof e=="string"?e:e.id)}getShapeLocalTransform(e){const r=typeof e=="string"?e:e.id,n=this.getShape(r);if(!n)throw Error("Editor.getTransform: shape not found");return Q.Identity().translate(n.x,n.y).rotate(n.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",e=>{if(En(e.parentId))return this.getShapeLocalTransform(e);const r=this._getShapePageTransformCache().get(e.parentId)??Q.Identity();return Q.Compose(r,this.getShapeLocalTransform(e))})}getShapeParentTransform(e){const r=typeof e=="string"?e:e.id,n=this.getShape(r);return!n||En(n.parentId)?Q.Identity():this._getShapePageTransformCache().get(n.parentId)??Q.Identity()}getShapePageTransform(e){const r=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(r)??Q.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",e=>{const r=this._getShapePageTransformCache().get(e.id);return r?ee.FromPoints(Q.applyToPoints(r,this.getShapeGeometry(e).vertices)):new ee})}getShapePageBounds(e){return this._getShapePageBoundsCache().get(typeof e=="string"?e:e.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",e=>{const r=this._getShapeMaskCache().get(e.id);if(!r)return;if(r.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const n=this._getShapePageTransformCache().get(e.id);return n?`polygon(${Q.applyToPoints(Q.Inverse(n),r).map(i=>`${i.x}px ${i.y}px`).join(",")})`:void 0})}getShapeClipPath(e){return this._getShapeClipPathCache().get(typeof e=="string"?e:e.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",e=>{if(En(e.parentId))return;const r=this.getShapeAncestors(e.id).filter(o=>this.isShapeOfType(o,"frame"));return r.length===0?void 0:r.map(o=>this._getShapePageTransformCache().get(o.id).applyToPoints(this.getShapeGeometry(o).vertices)).reduce((o,i)=>{if(!(i&&o))return;const s=RN(o,i);return s?s.map(w.Cast):[]})})}getShapeMask(e){return this._getShapeMaskCache().get(typeof e=="string"?e:e.id)}getShapeMaskedPageBounds(e){return typeof e!="string"&&(e=e.id),this._getShapeMaskedPageBoundsCache().get(e)}_getShapeMaskedPageBoundsCache(){return this.store.createComputedCache("shapeMaskedPageBoundsCache",e=>{const r=this._getShapePageBoundsCache().get(e.id);if(!r)return;const n=this._getShapeMaskCache().get(e.id);if(n){if(n.length===0)return;const{corners:o}=r;if(o.every((s,a)=>s&&w.Equals(s,n[a])))return r.clone();const i=RN(n,o);return i?ee.FromPoints(i):void 0}return r})}getShapeAncestors(e,r=[]){const n=typeof e=="string"?e:e.id,o=this.getShape(n);if(!o)return r;const i=o.parentId;if(En(i))return r.reverse(),r;const s=this.store.get(i);return s?(r.push(s),this.getShapeAncestors(s,r)):r}findShapeAncestor(e,r){const n=typeof e=="string"?e:e.id,o=this.getShape(n);if(!o)return;const i=o.parentId;if(En(i))return;const s=this.getShape(i);if(s)return r(s)?s:this.findShapeAncestor(s,r)}hasAncestor(e,r){const n=typeof e=="string"?e:e==null?void 0:e.id,o=n&&this.getShape(n);return o?o.parentId===r?!0:this.hasAncestor(this.getShapeParent(o),r):!1}findCommonAncestor(e,r){var l;if(e.length===0)return;const n=typeof e[0]=="string"?e:e.map(c=>c.id),o=Ae(n.map(c=>this.getShape(c)));if(o.length===1){const c=o[0].parentId;return En(c)?void 0:r?(l=this.findShapeAncestor(o[0],r))==null?void 0:l.id:c}const[i,...s]=o;let a=this.getShapeParent(i);for(;a;){if(r&&!r(a)){a=this.getShapeParent(a);continue}if(s.every(c=>this.hasAncestor(c,a.id)))return a.id;a=this.getShapeParent(a)}}isShapeOrAncestorLocked(e){const r=typeof e=="string"?this.getShape(e):e;return r===void 0?!1:r.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(r))}_notVisibleShapes(){return gSt(this)}getCulledShapes(){const e=this._notVisibleShapes().get(),r=this.getSelectedShapeIds(),n=this.getEditingShapeId(),o=new Set(e);return n&&o.delete(n),r.forEach(i=>{o.delete(i)}),o}getCurrentPageBounds(){let e;return this.getCurrentPageShapeIdsSorted().forEach(r=>{const n=this.getShapeMaskedPageBounds(r);n&&(e?e=e.expand(n):e=n.clone())}),e}getSelectedShapeAtPoint(e){const r=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(n=>n.type!=="group"&&r.includes(n.id)).reverse().find(n=>this.isPointInShape(n,e,{hitInside:!0,margin:0}))}getShapeAtPoint(e,r={}){const n=this.getZoomLevel(),o=this.getViewportPageBounds(),{filter:i,margin:s=0,hitLocked:a=!1,hitLabels:l=!1,hitInside:c=!1,hitFrameInside:u=!1}=r;let d=1/0,f=null,p=1/0,g=null;const m=(r.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(S=>{if(S.isLocked&&!a||this.isShapeOfType(S,"group"))return!1;const y=this.getShapeMask(S);return y&&!ho(e,y)?!1:i?i(S):!0});for(let S=m.length-1;S>=0;S--){const y=m[S],v=this.getShapeGeometry(y),b=v instanceof bi,$=this.getPointInShapeSpace(y,e);if((this.isShapeOfType(y,"arrow")||this.isShapeOfType(y,"geo")&&y.props.fill==="none")&&y.props.text.trim()){for(const E of v.children)if(E.isLabel&&E.isPointInBounds($))return y}if(this.isShapeOfType(y,"frame")){const E=v.distanceToPoint($,c);if(Math.abs(E)<=s)return g||y;if(v.hitTestPoint($,0,!0))return g||f||(u?y:void 0);continue}let P;if(b){let E=1/0;for(const T of v.children){if(T.isLabel&&!l)continue;const I=T.distanceToPoint($,c);I<E&&(E=I)}P=E}else s===0&&(v.bounds.w<1||v.bounds.h<1)||v.bounds.containsPoint($,s)?P=v.distanceToPoint($,c):P=1/0;if(v.isClosed){if(P<=s){if(v.isFilled||b&&v.children[0].isFilled)return g||y;if(this.getShapePageBounds(y).contains(o))continue;if(Math.abs(P)<s)Math.abs(P)<p&&(p=Math.abs(P),g=y);else if(!g){const{area:E}=v;E<d&&(d=E,f=y)}}}else if(P<this.options.hitTestMargin/n)return y}return g||f||void 0}getShapesAtPoint(e,r={}){return this.getCurrentPageShapes().filter(n=>this.isPointInShape(n,e,r))}isPointInShape(e,r,n={}){const{hitInside:o=!1,margin:i=0}=n,s=typeof e=="string"?e:e.id,a=this.getShapeMask(s);return a&&!ho(r,a)?!1:this.getShapeGeometry(s).hitTestPoint(this.getPointInShapeSpace(e,r),i,o)}getPointInShapeSpace(e,r){const n=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(n).clone().invert().applyToPoint(r)}getPointInParentSpace(e,r){const n=typeof e=="string"?e:e.id,o=this.getShape(n);if(!o)return new w(0,0);if(En(o.parentId))return w.From(r);const i=this.getShapePageTransform(o.parentId);return i?i.clone().invert().applyToPoint(r):w.From(r)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),e=>this.store.get(e))}getCurrentPageShapesSorted(){const e=[],r=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let n=0,o=r.length;n<o;n++)mie(this,r[n],e);return e}getCurrentPageRenderingShapesSorted(){const e=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:r})=>!e.has(r))}isShapeOfType(e,r){const n=typeof e=="string"?this.getShape(e):e;return n?n.type===r:!1}getShape(e){const r=typeof e=="string"?e:e.id;if(Tn(r))return this.store.get(r)}getShapeParent(e){const r=typeof e=="string"?e:e==null?void 0:e.id;if(!r)return;const n=this.getShape(r);if(!(n===void 0||!Tn(n.parentId)))return this.store.get(n.parentId)}getShapeNearestSibling(e,r){return r?r.parentId===e.parentId?r:this.findShapeAncestor(r,o=>o.parentId===e.parentId):void 0}isShapeInPage(e,r=this.getCurrentPageId()){const n=typeof e=="string"?e:e.id,o=this.getShape(n);if(!o)return!1;let i=!1;if(o.parentId===r)i=!0;else{let s=this.getShape(o.parentId);e:for(;s;){if(s.parentId===r){i=!0;break e}s=this.getShape(s.parentId)}}return i}getAncestorPageId(e){const r=typeof e=="string"?e:e==null?void 0:e.id,n=r&&this.getShape(r);if(n)return En(n.parentId)?n.parentId:this.getAncestorPageId(this.getShape(n.parentId))}reparentShapes(e,r,n){const o=typeof e[0]=="string"?e:e.map(f=>f.id);if(o.length===0)return this;const i=[],s=En(r)?Q.Identity():this.getShapePageTransform(r),a=s.rotation();let l=[];const c=Ae(this.getSortedChildIdsForParent(r).map(f=>this.getShape(f)));if(n){const f=c.find(p=>p.index===n);if(f){const p=c[c.indexOf(f)+1];p?l=qd(n,p.index,o.length):l=O$(n,o.length)}else{const p=c.sort(qr).find(g=>g.index>n);p?l=qd(n,p.index,o.length):l=O$(n,o.length)}}else{const f=c.length&&c[c.length-1];l=f?O$(f.index,o.length):pg(o.length)}const u=s.clone().invert(),d=Ae(o.map(f=>this.getShape(f)));return this.run(()=>{for(let f=0;f<d.length;f++){const p=d[f],g=this.getShapePageTransform(p);if(!g)continue;const m=g.point();if(!m)continue;const S=u.applyToPoint(m),y=g.rotation()-a;i.push({id:p.id,type:p.type,parentId:r,x:S.x,y:S.y,rotation:y,index:l[f]})}this.updateShapes(i)},{ignoreShapeLock:!0}),this}getHighestIndexForParent(e){const r=typeof e=="string"?e:e.id,n=this._parentIdsToChildIds.get()[r];if(!n||n.length===0)return"a1";const o=this.getShape(n[n.length-1]);return Xi(o.index)}getSortedChildIdsForParent(e){const r=typeof e=="string"?e:e.id,n=this._parentIdsToChildIds.get()[r];return n||Xs}visitDescendants(e,r){const n=typeof e=="string"?e:e.id,o=this.getSortedChildIdsForParent(n);for(const i of o)r(i)!==!1&&this.visitDescendants(i,r);return this}getShapeAndDescendantIds(e){const r=new Set;for(const n of e.map(o=>this.getShape(o)).sort(qr))r.add(n.id),this.visitDescendants(n,o=>{r.add(o)});return r}getDroppingOverShape(e,r=[]){const n=this.getCurrentPageShapesSorted();for(let o=n.length-1;o>=0;o--){const i=n[o];if(this.getSelectedShapeIds().includes(i.id)||!this.getShapeUtil(i).canDropShapes(i,r)||r.find(a=>a.id===i.id||this.hasAncestor(i,a.id)))continue;const s=this.getShapeMaskedPageBounds(i.id);if(s&&s.containsPoint(e)&&this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(i,e),0,!0))return i}}getOutermostSelectableShape(e,r){const n=typeof e=="string"?e:e.id,o=this.getShape(n);let i=o,s=o;const a=this.getFocusedGroup();for(;s;){if(this.isShapeOfType(s,"group")&&(a==null?void 0:a.id)!==s.id&&!this.hasAncestor(a,s.id)&&((r==null?void 0:r(s))??!0))i=s;else if((a==null?void 0:a.id)===s.id)break;s=this.getShapeParent(s)}return i}_getBindingsIndexCache(){const e=fSt(this);return this.store.createComputedCache("bindingsIndex",r=>e.get().get(r.id))}getBinding(e){return this.store.get(e)}getBindingsFromShape(e,r){const n=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(n).filter(o=>o.fromId===n&&o.type===r)}getBindingsToShape(e,r){const n=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(n).filter(o=>o.toId===n&&o.type===r)}getBindingsInvolvingShape(e,r){const n=typeof e=="string"?e:e.id,o=this._getBindingsIndexCache().get(n)??Xs;return r?o.filter(i=>i.type===r):o}createBindings(e){const r=[];for(const n of e){const o=this.getShape(n.fromId),i=this.getShape(n.toId);if(!o||!i||!this.canBindShapes({fromShape:o,toShape:i,binding:n}))continue;const a=this.getBindingUtil(n.type).getDefaultProps(),l=this.store.schema.types.binding.create({...n,id:n.id??Pc(),props:{...a,...n.props}});r.push(l)}return this.store.put(r),this}createBinding(e){return this.createBindings([e])}updateBindings(e){const r=[];for(const n of e){if(!n)continue;const o=this.getBinding(n.id);if(!o)continue;const i=zi(o,n);if(i===o)continue;const s=this.getShape(i.fromId),a=this.getShape(i.toId);!s||!a||this.canBindShapes({fromShape:s,toShape:a,binding:i})&&r.push(i)}return this.store.put(r),this}updateBinding(e){return this.updateBindings([e])}deleteBindings(e,{isolateShapes:r=!1}={}){const n=e.map(o=>typeof o=="string"?o:o.id);return r?this.store.atomic(()=>{var o,i;for(const s of n){const a=this.getBinding(s);if(!a)continue;const l=this.getBindingUtil(a);(o=l.onBeforeIsolateFromShape)==null||o.call(l,{binding:a,removedShape:this.getShape(a.toId)}),(i=l.onBeforeIsolateToShape)==null||i.call(l,{binding:a,removedShape:this.getShape(a.fromId)}),this.store.remove([s])}}):this.store.remove(n),this}deleteBinding(e,r){return this.deleteBindings([e],r)}canBindShapes({fromShape:e,toShape:r,binding:n}){const o=typeof e=="string"?e:e.type,i=typeof r=="string"?r:r.type,s=typeof n=="string"?n:n.type,a={fromShapeType:o,toShapeType:i,bindingType:s};return o===i?this.getShapeUtil(o).canBind(a):this.getShapeUtil(o).canBind(a)&&this.getShapeUtil(i).canBind(a)}rotateShapesBy(e,r){const n=typeof e[0]=="string"?e:e.map(i=>i.id);if(n.length<=0)return this;const o=Gre({editor:this,ids:n});return o?(FS({delta:r,snapshot:o,editor:this,stage:"one-off"}),this):this}getChangesToTranslateShape(e,r){var i,s,a;let n=e;const o=this.getShapeUtil(e);return n=zi(n,((i=o.onTranslateStart)==null?void 0:i.call(o,n))??void 0),n=zi(n,{id:e.id,type:e.type,x:r.x,y:r.y}),n=zi(n,((s=o.onTranslate)==null?void 0:s.call(o,e,n))??void 0),n=zi(n,((a=o.onTranslateEnd)==null?void 0:a.call(o,e,n))??void 0),n}nudgeShapes(e,r){const n=typeof e[0]=="string"?e:e.map(i=>i.id);if(n.length<=0)return this;const o=[];for(const i of n){const s=this.getShape(i),a=w.From(r),l=this.getShapeParentTransform(s);l&&a.rot(-l.rotation()),o.push(this.getChangesToTranslateShape(s,a.add(s)))}return this.updateShapes(o),this}duplicateShapes(e,r){return this.run(()=>{const n=typeof e[0]=="string"?e:e.map(f=>f.id);if(n.length<=0)return this;const o=new Set(n),i=this.getShapeAndDescendantIds(n),s=[...i].reverse(),a=new Map;for(const f of i)a.set(f,ot());const{shapesToCreateWithOriginals:l,bindingsToCreate:c}=v7(this,i,f=>{const p=[];for(const m of f){const S=this.getBinding(m);if(!S)continue;const y=Pc();p.push({...S,id:y,fromId:ro(a.get(S.fromId)),toId:ro(a.get(S.toId))})}const g=[];for(const m of s){const S=ro(a.get(m)),y=this.getShape(m);if(!y)continue;let v=0,b=0;if(r&&o.has(m)){const $=this.getShapeParentTransform(y),P=new w(r.x,r.y).rot(-$.rotation());v=P.x,b=P.y}g.push({shape:{...y,id:S,x:y.x+v,y:y.y+b,index:"a1",parentId:a.get(y.parentId)??y.parentId},originalShape:y})}return{shapesToCreateWithOriginals:g,bindingsToCreate:p}});l.forEach(({shape:f,originalShape:p})=>{const g=p.parentId,m=this.getSortedChildIdsForParent(g),S=m.indexOf(p.id),y=m[S+1],v=y?this.getShape(y):void 0,b=fg(p.index,v==null?void 0:v.index);f.index=b});const u=l.map(({shape:f})=>f);if(u.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage){Ry(this);return}if(this.createShapes(u),this.createBindings(c),this.setSelectedShapes(Ae(n.map(f=>a.get(f)))),r!==void 0){const f=this.getSelectionPageBounds(),p=this.getViewportPageBounds();f&&!p.contains(f)&&this.centerOnPoint(f.center,{animation:{duration:this.options.animationMediumMs}})}}),this}moveShapesToPage(e,r){const n=typeof e[0]=="string"?e:e.map(a=>a.id);if(n.length===0)return this;if(this.getInstanceState().isReadonly)return this;const o=this.getCurrentPageId();if(r===o)return this;if(!this.store.has(r))return this;const i=this.getContentFromCurrentPage(n);if(!i)return this;if(this.getPageShapeIds(r).size+i.shapes.length>this.options.maxShapesPerPage)return Ry(this,r),this;const s=this.getCamera().z;return this.run(()=>{this.deleteShapes(n),this.setCurrentPage(r),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(i,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:s}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(e){const r=typeof e[0]=="string"?e:e.map(s=>s.id);if(this.getInstanceState().isReadonly||r.length===0)return this;let n=!0,o=!0;const i=[];for(const s of r){const a=this.getShape(s);a&&(i.push(a),a.isLocked?o=!1:n=!1)}return this.run(()=>{o?(this.updateShapes(i.map(s=>({id:s.id,type:s.type,isLocked:!0}))),this.setSelectedShapes([])):n?this.updateShapes(i.map(s=>({id:s.id,type:s.type,isLocked:!1}))):this.updateShapes(i.map(s=>({id:s.id,type:s.type,isLocked:!0})))}),this}sendToBack(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id),n=Oy(this,"toBack",r);return n&&this.updateShapes(n),this}sendBackward(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id),n=Oy(this,"backward",r);return n&&this.updateShapes(n),this}bringForward(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id),n=Oy(this,"forward",r);return n&&this.updateShapes(n),this}bringToFront(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id),n=Oy(this,"toFront",r);return n&&this.updateShapes(n),this}flipShapes(e,r){const n=typeof e[0]=="string"?e:e.map(s=>s.id);if(this.getInstanceState().isReadonly)return this;let o=Ae(n.map(s=>this.getShape(s)));if(!o.length)return this;o=Ae(o.map(s=>this.isShapeOfType(s,"group")?this.getSortedChildIdsForParent(s.id).map(a=>this.getShape(a)):s).flat());const i=ee.Common(Ae(o.map(s=>this.getShapePageBounds(s)))).center;return this.run(()=>{for(const s of o){const a=this.getShapeGeometry(s).bounds,l=this.getShapePageTransform(s.id);l&&this.resizeShape(s.id,{x:r==="horizontal"?-1:1,y:r==="vertical"?-1:1},{initialBounds:a,initialPageTransform:l,initialShape:s,mode:"scale_shape",isAspectRatioLocked:this.getShapeUtil(s).isAspectRatioLocked(s),scaleOrigin:i,scaleAxisRotation:0})}}),this}stackShapes(e,r,n){const o=typeof e[0]=="string"?e:e.map(m=>m.id);if(this.getInstanceState().isReadonly)return this;const i=o.map(m=>this.getShape(m)).filter(m=>m?this.getShapeUtil(m).canBeLaidOut(m):!1),s=i.length;if(n===0&&s<3||s<2)return this;const a=Object.fromEntries(i.map(m=>[m.id,this.getShapePageBounds(m)]));let l,c,u,d;r==="horizontal"?(l="x",c="minX",u="maxX",d="width"):(l="y",c="minY",u="maxY",d="height");let f;if(n===0){const m=[];i.sort((y,v)=>a[y.id][c]-a[v.id][c]);for(let y=0;y<s-1;y++){const v=i[y],b=i[y+1],$=a[v.id],E=a[b.id][c]-$[u],T=m.find(I=>I.gap===E);T?T.count++:m.push({gap:E,count:1})}let S=0;m.forEach(y=>{y.count>S&&(S=y.count,f=y.gap)}),S===1&&(f=Math.max(0,m.reduce((y,v)=>y+v.gap*v.count,0)/(s-1)))}else f=n;const p=[];let g=a[i[0].id][u];return i.forEach((m,S)=>{var P,E;if(S===0)return;const y={x:0,y:0};y[l]=g+f-a[m.id][l];const v=this.getShapeParent(m),b=v?w.Rot(y,-this.getShapePageTransform(v).decompose().rotation):y,$=(E=(P=this.getShapeUtil(m)).onTranslateStart)==null?void 0:E.call(P,m);p.push($?{...$,[l]:m[l]+b[l]}:{id:m.id,type:m.type,[l]:m[l]+b[l]}),g+=a[m.id][d]+f}),this.updateShapes(p),this}packShapes(e,r){var E,T;const n=typeof e[0]=="string"?e:e.map(I=>I.id);if(this.getInstanceState().isReadonly)return this;if(n.length<2)return this;const o=n.map(I=>this.getShape(I)).filter(I=>I?this.getShapeUtil(I).canBeLaidOut(I):!1),i={},s={};let a,l,c=0;for(let I=0;I<o.length;I++)a=o[I],l=this.getShapePageBounds(a),i[a.id]=l,s[a.id]=l.clone(),c+=l.width*l.height;const u=ee.Common(Ae(Object.values(i))),d=u.width;o.sort((I,_)=>i[_.id].height-i[I.id].height);const f=Math.max(Math.ceil(Math.sqrt(c/.95)),d),p=[new ee(u.x,u.y,f,1/0)];let g=0,m=0,S,y;for(let I=0;I<o.length;I++){a=o[I],l=s[a.id];for(let _=p.length-1;_>=0;_--)if(S=p[_],!(l.width>S.width||l.height>S.height)){l.x=S.x,l.y=S.y,m=Math.max(m,l.maxY),g=Math.max(g,l.maxX),l.width===S.width&&l.height===S.height?(y=p.pop(),_<p.length&&(p[_]=y)):l.height===S.height?(S.x+=l.width+r,S.width-=l.width+r):l.width===S.width?(S.y+=l.height+r,S.height-=l.height+r):(p.push(new ee(S.x+(l.width+r),S.y,S.width-(l.width+r),l.height)),S.y+=l.height+r,S.height-=l.height+r);break}}const v=ee.Common(Object.values(s)),b=w.Sub(u.center,v.center);let $;const P=[];for(let I=0;I<o.length;I++){a=o[I],l=i[a.id],$=s[a.id];const _=w.Sub($.point,l.point).add(b),k=this.getShapeParentTransform(a);k&&_.rot(-k.rotation());const D={id:a.id,type:a.type,x:a.x+_.x,y:a.y+_.y},R=(T=(E=this.getShapeUtil(a)).onTranslateStart)==null?void 0:T.call(E,{...a,...D});R?P.push({...D,...R}):P.push(D)}return P.length&&this.updateShapes(P),this}alignShapes(e,r){const n=typeof e[0]=="string"?e:e.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(n.length<2)return this;const o=Ae(n.map(l=>this.getShape(l))),i=Object.fromEntries(o.map(l=>[l.id,this.getShapePageBounds(l)])),s=ee.Common(Ae(Object.values(i))),a=[];return o.forEach(l=>{const c=i[l.id];if(!c)return;const u={x:0,y:0};switch(r){case"top":{u.y=s.minY-c.minY;break}case"center-vertical":{u.y=s.midY-c.minY-c.height/2;break}case"bottom":{u.y=s.maxY-c.minY-c.height;break}case"left":{u.x=s.minX-c.minX;break}case"center-horizontal":{u.x=s.midX-c.minX-c.width/2;break}case"right":{u.x=s.maxX-c.minX-c.width;break}}const d=this.getShapeParent(l),f=d?w.Rot(u,-this.getShapePageTransform(d).decompose().rotation):u;a.push(this.getChangesToTranslateShape(l,w.Add(l,f)))}),this.updateShapes(a),this}distributeShapes(e,r){const n=typeof e[0]=="string"?e:e.map(v=>v.id);if(this.getInstanceState().isReadonly)return this;if(n.length<3)return this;const o=n.length,i=Ae(n.map(v=>this.getShape(v))),s=Object.fromEntries(i.map(v=>[v.id,this.getShapePageBounds(v)]));let a,l,c,u,d;r==="horizontal"?(a="x",l="minX",c="maxX",u="midX",d="width"):(a="y",l="minY",c="maxY",u="midY",d="height");const f=[],p=i.sort((v,b)=>s[v.id][l]-s[b.id][l])[0],g=i.sort((v,b)=>s[b.id][c]-s[v.id][c])[0],m=s[p.id][u],S=(s[g.id][u]-m)/(o-1),y=m+S;return i.filter(v=>v!==p&&v!==g).sort((v,b)=>s[v.id][u]-s[b.id][u]).forEach((v,b)=>{const $={x:0,y:0};$[a]=y+S*b-s[v.id][d]/2-s[v.id][a];const P=this.getShapeParent(v),E=P?w.Rot($,-this.getShapePageTransform(P).rotation()):$;f.push(this.getChangesToTranslateShape(v,w.Add(v,E)))}),this.updateShapes(f),this}stretchShapes(e,r){const n=typeof e[0]=="string"?e:e.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(n.length<2)return this;const o=Ae(n.map(l=>this.getShape(l))),i=Object.fromEntries(n.map(l=>[l,this.getShapeGeometry(l).bounds])),s=Object.fromEntries(n.map(l=>[l,this.getShapePageBounds(l)])),a=ee.Common(Ae(Object.values(s)));switch(r){case"vertical":{this.run(()=>{for(const l of o){if(this.getShapePageTransform(l).rotation()%rt)continue;const u=i[l.id],d=s[l.id],f=new w(0,a.minY-d.minY),p=this.getShapeParentTransform(l);p&&f.rot(-p.rotation());const{x:g,y:m}=w.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:m}]);const S=new w(1,a.height/d.height);this.resizeShape(l.id,S,{initialBounds:u,scaleOrigin:new w(d.center.x,a.minY),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}case"horizontal":{this.run(()=>{for(const l of o){const c=i[l.id],u=s[l.id];if(this.getShapePageTransform(l).rotation()%rt)continue;const f=new w(a.minX-u.minX,0),p=this.getShapeParentTransform(l);p&&f.rot(-p.rotation());const{x:g,y:m}=w.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:m}]);const S=new w(a.width/u.width,1);this.resizeShape(l.id,S,{initialBounds:c,scaleOrigin:new w(a.minX,u.center.y),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}}return this}resizeShape(e,r,n={}){var p,g,m;const o=typeof e=="string"?e:e.id;if(this.getInstanceState().isReadonly)return this;Number.isFinite(r.x)||(r=new w(1,r.y)),Number.isFinite(r.y)||(r=new w(r.x,1));const i=n.initialShape??this.getShape(o);if(!i)return this;const s=n.scaleOrigin??((p=this.getShapePageBounds(o))==null?void 0:p.center);if(!s)return this;const a=n.initialPageTransform?Q.Cast(n.initialPageTransform):this.getShapePageTransform(o);if(!a)return this;const l=a.rotation();if(l==null)return this;const c=n.scaleAxisRotation??l,u=n.initialBounds??this.getShapeGeometry(o).bounds;if(!u)return this;const d=n.isAspectRatioLocked??this.getShapeUtil(i).isAspectRatioLocked(i);if(!yV(l,c))return this._resizeUnalignedShape(o,r,{...n,initialBounds:u,scaleOrigin:s,scaleAxisRotation:c,initialPageTransform:a,isAspectRatioLocked:d,initialShape:i});const f=this.getShapeUtil(i);if(d&&(Math.abs(r.x)>Math.abs(r.y)?r=new w(r.x,Math.sign(r.y)*Math.abs(r.x)):r=new w(Math.sign(r.x)*Math.abs(r.y),r.y)),f.onResize&&f.canResize(i)){const S=this._scalePagePoint(Q.applyToPoint(a,new w(0,0)),s,r,c),y=this.getPointInParentSpace(i.id,S),v=new w(r.x,r.y),b=ul((l-c)%Math.PI,0);v.x=b?r.x:r.y,v.y=b?r.y:r.x;const $=Q.applyToPoint(a,new w),{x:P,y:E}=this.getPointInParentSpace(i.id,$);let T=i;n.skipStartAndEndCallbacks||(T=zi(i,((g=f.onResizeStart)==null?void 0:g.call(f,i))??void 0)),T=zi(T,{id:o,type:i.type,x:y.x,y:y.y,...f.onResize({...i,x:P,y:E},{newPoint:y,handle:n.dragHandle??"bottom_right",mode:n.mode??"scale_shape",scaleX:v.x,scaleY:v.y,initialBounds:u,initialShape:i})}),n.skipStartAndEndCallbacks||(T=zi(T,((m=f.onResizeEnd)==null?void 0:m.call(f,i,T))??void 0)),this.updateShapes([T])}else{const S=Q.applyToPoint(a,u.center),y=this._scalePagePoint(S,s,r,c),v=this.getPointInParentSpace(i.id,S),b=this.getPointInParentSpace(i.id,y),$=w.Sub(b,v);this.updateShapes([{id:o,type:i.type,x:i.x+$.x,y:i.y+$.y}])}return this}_scalePagePoint(e,r,n,o){const i=w.RotWith(e,r,-o).sub(r),s=w.MulV(i,n);return w.Add(s,r).rotWith(r,o)}_resizeUnalignedShape(e,r,n){const{type:o}=n.initialShape,i=new w(r.x,r.y);if(Math.abs(r.x)>Math.abs(r.y)?i.x=Math.sign(r.x)*Math.abs(r.y):i.y=Math.sign(r.y)*Math.abs(r.x),this.resizeShape(e,i,{initialShape:n.initialShape,initialBounds:n.initialBounds,isAspectRatioLocked:n.isAspectRatioLocked}),Math.sign(r.x)*Math.sign(r.y)<0){let{rotation:S}=Q.Decompose(n.initialPageTransform);S-=2*S,this.updateShapes([{id:e,type:o,rotation:S}])}const s=Q.applyToPoint(n.initialPageTransform,n.initialBounds.center),a=this._scalePagePoint(s,n.scaleOrigin,r,n.scaleAxisRotation),l=this.getShapePageBounds(e),c=this.getShapePageTransform(e),u=l.center,d=c.point();if(!u||!d)return this;const f=w.Sub(a,u),p=w.Add(d,f),{x:g,y:m}=this.getPointInParentSpace(e,p);return this.updateShapes([{id:e,type:o,x:g,y:m}]),this}getInitialMetaForShape(e){return{}}createShape(e){return this.createShapes([e]),this}createShapes(e){if(!Array.isArray(e))throw Error("Editor.createShapes: must provide an array of shapes or shape partials");if(this.getInstanceState().isReadonly)return this;if(e.length<=0)return this;const r=this.getCurrentPageShapeIds();if(e.length+r.size>this.options.maxShapesPerPage)return Ry(this),this;const o=this.getFocusedGroupId();return this.run(()=>{var u,d;const i=this.getCurrentPageShapesSorted(),s=e.map(f=>{if(f.id||(f={id:ot(),...f}),!f.parentId||!(this.store.has(f.parentId)||e.some(p=>p.id===f.parentId))){let p=this.getFocusedGroupId();for(let m=i.length-1;m>=0;m--){const S=i[m];if(this.getShapeUtil(S).canReceiveNewChildrenOfType(S,f.type)&&this.isPointInShape(S,{x:f.x??0,y:f.y??0},{margin:0,hitInside:!0})){p=S.id;break}}const g=f.parentId;if(p===f.id&&(p=o),p!==g&&(f={...f},f.parentId=p,Tn(p))){const m=this.getPointInShapeSpace(this.getShape(p),{x:f.x??0,y:f.y??0});f.x=m.x,f.y=m.y,f.rotation=-this.getShapePageTransform(p).rotation()+(f.rotation??0)}}return f}),a=new Map,l=[],{opacityForNextShape:c}=this.getInstanceState();for(const f of s){const p=this.getShapeUtil(f);let g=f.index;if(!g){const v=f.parentId??o;a.has(v)||a.set(v,this.getHighestIndexForParent(v)),g=a.get(v),a.set(v,Xi(g))}const m=p.getDefaultProps();for(const[v,b]of this.styleProps[f.type])m[b]=this.getStyleForNextShape(v);let S=this.store.schema.types.shape.create({...f,index:g,opacity:f.opacity??c,parentId:f.parentId??o,props:"props"in f?{...m,...f.props}:m});if(S.index===void 0)throw Error("no index!");const y=(d=(u=this.getShapeUtil(S)).onBeforeCreate)==null?void 0:d.call(u,S);y&&(S=y),l.push(S)}l.forEach(f=>{f.meta={...this.getInitialMetaForShape(f),...f.meta}}),this.store.put(l)}),this}animateShape(e,r={animation:oI}){return this.animateShapes([e],r)}animateShapes(e,r={animation:oI}){if(!r.animation)return this;const{duration:n=500,easing:o=pr.linear}=r.animation,i=ct();let s=n,a;const l=[];let c,u;for(let f=0,p=e.length;f<p;f++){if(c=e[f],!c)continue;const g=this.getShape(c.id);g&&(u={start:$t(g),end:zi($t(g),c)},l.push(u),this.animatingShapes.set(g.id,i))}const d=f=>{var S,y;if(s-=f,s<0){const{animatingShapes:v}=this,b=e.filter($=>$&&v.get($.id)===i);b.length&&this.updateShapes(b),this.off("tick",d);return}a=o(1-s/n);const{animatingShapes:p}=this,g=[];let m;for(let v=0,b=l.length;v<b;v++){const{start:$,end:P}=l[v];m=p.get($.id),m===i&&g.push({...P,x:$.x+(P.x-$.x)*a,y:$.y+(P.y-$.y)*a,opacity:$.opacity+(P.opacity-$.opacity)*a,rotation:$.rotation+(P.rotation-$.rotation)*a,props:((y=(S=this.getShapeUtil(P)).getInterpolatedProps)==null?void 0:y.call(S,$,P,a))??P.props})}this._updateShapes(g)};return this.on("tick",d),this}groupShapes(e,r={}){var g;const{groupId:n=ot(),select:o=!0}=r;if(!Array.isArray(e))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getInstanceState().isReadonly)return this;const i=typeof e[0]=="string"?e:e.map(m=>m.id);if(i.length<=1)return this;const s=Ae((this._shouldIgnoreShapeLock?i:this._getUnlockedShapeIds(i)).map(m=>this.getShape(m))),a=s.sort(qr).map(m=>m.id),l=ee.Common(Ae(s.map(m=>this.getShapePageBounds(m)))),{x:c,y:u}=l.point,d=this.findCommonAncestor(s)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const f=s.filter(m=>m.parentId===d).sort(qr),p=(g=f[f.length-1])==null?void 0:g.index;return this.run(()=>{this.createShapes([{id:n,type:"group",parentId:d,index:p,x:c,y:u,opacity:1,props:{}}]),this.reparentShapes(a,n),o&&this.select(n)}),this}ungroupShapes(e,r={}){if(this.getInstanceState().isReadonly)return this;const{select:n=!0}=r,o=typeof e[0]=="string"?e:e.map(l=>l.id),i=Ae((this._shouldIgnoreShapeLock?o:this._getUnlockedShapeIds(o)).map(l=>this.getShape(l)));if(i.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const s=new Set,a=[];return i.forEach(l=>{this.isShapeOfType(l,"group")?a.push(l):s.add(l.id)}),a.length===0?this:(this.run(()=>{let l;for(let c=0,u=a.length;c<u;c++){l=a[c];const d=this.getSortedChildIdsForParent(l.id);for(let f=0,p=d.length;f<p;f++)s.add(d[f]);this.reparentShapes(d,l.parentId,l.index)}this.deleteShapes(a.map(c=>c.id)),n&&this.select(...s)}),this)}updateShape(e){return this.updateShapes([e]),this}updateShapes(e){const r=Array(e.length);for(let n=0,o=e.length;n<o;n++){const i=e[n];if(!i)continue;const s=this.getShape(i.id);if(s){if(!this._shouldIgnoreShapeLock){if(s.isLocked){if(!(Object.hasOwn(i,"isLocked")&&!i.isLocked))continue}else if(this.isShapeOrAncestorLocked(s))continue}this.animatingShapes.delete(i.id),r.push(i)}}return this._updateShapes(r),this}_updateShapes(e){this.getInstanceState().isReadonly||this.run(()=>{var i,s;const r=[];let n,o;for(let a=0,l=e.length;a<l;a++){const c=e[a];c&&(n=this.getShape(c.id),n&&(o=zi(n,c),o!==n&&(o=((s=(i=this.getShapeUtil(n)).onBeforeUpdate)==null?void 0:s.call(i,n,o))??o,r.push(o))))}this.store.put(r)})}_getUnlockedShapeIds(e){return e.filter(r=>{var n;return!((n=this.getShape(r))!=null&&n.isLocked)})}deleteShapes(e){if(this.getInstanceState().isReadonly)return this;if(!Array.isArray(e))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");const r=typeof e[0]=="string"?e:e.map(i=>i.id),n=this._shouldIgnoreShapeLock?r:this._getUnlockedShapeIds(r);if(n.length===0)return this;const o=new Set(n);for(const i of n)this.visitDescendants(i,s=>{o.add(s)});return this.run(()=>this.store.remove([...o]))}deleteShape(e){return this.deleteShapes([typeof e=="string"?e:e.id]),this}_extractSharedStyles(e,r){if(this.isShapeOfType(e,"group")){const n=this._parentIdsToChildIds.get()[e.id];if(!n)return;for(let o=0,i=n.length;o<i;o++)this._extractSharedStyles(this.getShape(n[o]),r)}else for(const[n,o]of this.styleProps[e.type])r.applyValue(n,Dn(e.props,o))}_getSelectionSharedStyles(){const e=this.getSelectedShapes(),r=new O2;for(const n of e)this._extractSharedStyles(n,r);return r}getStyleForNextShape(e){const r=this.getInstanceState().stylesForNextShape[e.id];return r===void 0?e.defaultValue:r}getShapeStyleIfExists(e,r){const n=this.styleProps[e.type].get(r);if(n!==void 0)return Dn(e.props,n)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const e=this.root.getCurrent(),r=new O2;if(!e)return r;if(e.shapeType)for(const n of this.styleProps[e.shapeType].keys())r.applyValue(n,this.getStyleForNextShape(n));return r}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const e=[],r=o=>{const i=this.getShape(o);if(i)if(this.isShapeOfType(i,"group"))for(const s of this.getSortedChildIdsForParent(i.id))r(s);else e.push(i)};for(const o of this.getSelectedShapeIds())r(o);let n=null;for(const o of e)if(n===null)n=o.opacity;else if(n!==o.opacity)return{type:"mixed"};if(n!==null)return{type:"shared",value:n}}return{type:"shared",value:this.getInstanceState().opacityForNextShape}}setOpacityForNextShapes(e,r){return this.updateInstanceState({opacityForNextShape:e},r),this}setOpacityForSelectedShapes(e){const r=this.getSelectedShapes();if(r.length>0){const n=[],o=i=>{if(this.isShapeOfType(i,"group")){const s=this.getSortedChildIdsForParent(i);for(const a of s)o(this.getShape(a))}else n.push(i)};for(const i of r)o(i);this.updateShapes(n.map(i=>({id:i.id,type:i.type,opacity:e})))}return this}setStyleForNextShapes(e,r,n){const o=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...o,[e.id]:r}},n),this}setStyleForSelectedShapes(e,r){const n=this.getSelectedShapes();if(n.length>0){const o=[],i=s=>{if(this.isShapeOfType(s,"group")){const a=this.getSortedChildIdsForParent(s.id);for(const l of a)i(this.getShape(l))}else{const a=this.getShapeUtil(s),l=this.styleProps[s.type].get(e);if(l){const c={id:s.id,type:s.type,props:{[l]:r}};o.push({util:a,originalShape:s,updatePartial:c})}}};for(const s of n)i(s);this.updateShapes(o.map(({updatePartial:s})=>s))}return this}registerExternalAssetHandler(e,r){return this.externalAssetContentHandlers[e]=r,this}createTemporaryAssetPreview(e,r){if(this.temporaryAssetPreview.has(e))return this.temporaryAssetPreview.get(e);const n=URL.createObjectURL(r);return this.temporaryAssetPreview.set(e,n),setTimeout(()=>{this.temporaryAssetPreview.delete(e),URL.revokeObjectURL(n)},3*60*1e3),n}getTemporaryAssetPreview(e){return this.temporaryAssetPreview.get(e)}async getAssetForExternalContent(e){var r,n;return await((n=(r=this.externalAssetContentHandlers)[e.type])==null?void 0:n.call(r,e))}hasExternalAssetHandler(e){return!!this.externalAssetContentHandlers[e]}registerExternalContentHandler(e,r){return this.externalContentHandlers[e]=r,this}async putExternalContent(e){var r,n;return(n=(r=this.externalContentHandlers)[e.type])==null?void 0:n.call(r,e)}getContentFromCurrentPage(e){const r=typeof e[0]=="string"?e:e.map(o=>o.id);if(!r||r.length===0)return;const n=this.getShapeAndDescendantIds(r);return v7(this,n,o=>{const i=[];for(const u of o){const d=this.getBinding(u);d&&i.push(d)}const s=[],a=[];for(const u of n){const d=this.getShape(u);if(!d)continue;if(!n.has(d.parentId)){const p=this.getShapePageTransform(d.id),g=p.point();a.push({...d,x:g.x,y:g.y,rotation:p.rotation(),parentId:this.getCurrentPageId()}),s.push(d.id)}else a.push(d)}const l=[],c=new Set;for(const u of a){if(!("assetId"in u.props))continue;const d=u.props.assetId;if(!d||c.has(d))continue;c.add(d);const f=this.getAsset(d);f&&l.push(f)}return{schema:this.store.schema.serialize(),shapes:a,rootShapeIds:s,bindings:i,assets:l}})}async resolveAssetsInContent(e){if(!e)return;const r=[];return await Promise.allSettled(e.assets.map(async n=>{var o,i;if((n.type==="image"||n.type==="video")&&!((o=n.props.src)!=null&&o.startsWith("data:image"))&&!((i=n.props.src)!=null&&i.startsWith("http"))){const s=$t(n),a=await this.store.props.assets.resolve(n,{screenScale:1,steppedScreenScale:1,dpr:1,networkEffectiveType:null,shouldResolveToOriginal:!0});s.props.src=await Ys.blobToDataUrl(await xi(a).then(l=>l.blob())),r.push(s)}else r.push(n)})),e.assets=r,e}putContentOntoCurrentPage(e,r={}){var k,D;if(this.getInstanceState().isReadonly)return this;if(!e.schema)throw Error(`Could not put content:
|
|
113
|
-
content is missing a schema.`);const{select:n=!1,preserveIds:o=!1,preservePosition:i=!1}=r;let{point:s=void 0}=r;const a=this.getCurrentPageId(),{rootShapeIds:l}=e,c=[],u=[],d=[],f={store:{...Object.fromEntries(e.assets.map(R=>[R.id,R])),...Object.fromEntries(e.shapes.map(R=>[R.id,R])),...Object.fromEntries(((k=e.bindings)==null?void 0:k.map(R=>[R.id,R]))??[])},schema:e.schema},p=this.store.schema.migrateStoreSnapshot(f);if(p.type==="error")throw Error("Could not put content: could not migrate content");for(const R of Object.values(p.value))switch(R.typeName){case"asset":{c.push(R);break}case"shape":{u.push(R);break}case"binding":{d.push(R);break}}const g=new Map(o?u.map(R=>[R.id,R.id]):u.map(R=>[R.id,ot()])),m=new Map(o?d.map(R=>[R.id,R.id]):d.map(R=>[R.id,Pc()]));let S=this.getCurrentPageId(),y=1/0,v=[];for(const R of this.getSelectedShapes()){if(y===0)break;const j=this.isShapeOfType(R,"frame"),M=this.getShapeAncestors(R);j&&M.push(R);const U=j?M.length+1:M.length;if(U<y)y=U,v=M,S=j?R.id:R.parentId;else if(U===y){if(v.length!==M.length)throw Error(`Ancestors: ${v.length} !== ${M.length}`);if(v.length===0){S=a;break}else{S=a;for(let B=0;B<v.length&&M[B]===v[B];B++)S=M[B].id}}}let b=!1;if(!En(S)){const R=this.getShape(S);if(R){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(R)))S=a;else if(l.length===1){const j=u.find(M=>M.id===l[0]);this.isShapeOfType(R,"frame")&&this.isShapeOfType(j,"frame")&&j.props.w===(R==null?void 0:R.props.w)&&j.props.h===(R==null?void 0:R.props.h)&&(b=!0)}}else S=a}b||(b=g.has(S)),b&&(S=this.getShape(S).parentId);let $=this.getHighestIndexForParent(S);const P=[],E=u.map(R=>{const j=g.get(R.id),M={...R,id:j};return l.includes(R.id)&&(M.parentId=a,P.push(M)),g.has(M.parentId)?M.parentId=g.get(R.parentId):(l.push(M.id),M.index=$,$=Xi($)),M});if(E.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage)return Ry(this),this;const T=d.map(R=>({...R,id:ro(m.get(R.id)),fromId:ro(g.get(R.fromId)),toId:ro(g.get(R.toId))})),I=[],_=[];for(const R of c)this.store.has(R.id)||((R.type==="image"||R.type==="video")&&((D=R.props.src)!=null&&D.startsWith("data:image"))&&(_.push($t(R)),R.props.src=null),I.push(R));return Promise.allSettled(_.map(async R=>{const j=await oSt(R.props.src,R.props.name,R.props.mimeType??"image/png"),M=await this.getAssetForExternalContent({type:"file",file:j,assetId:R.id});if(!M){this.deleteAssets([R.id]);return}this.updateAssets([{...M,id:R.id}])})),this.run(()=>{I.length>0&&this.createAssets(I),this.createShapes(E),this.createBindings(T),n&&this.select(...P.map(B=>B.id)),S!==a&&this.reparentShapes(P.map(B=>B.id),S);const R=E.map(B=>this.getShape(B.id)),j=ee.Common(R.map(B=>this.getShapePageBounds(B)));if(s===void 0)if(En(S)){const B=this.getViewportPageBounds();i||B.includes(ee.From(j))?s=j.center:s=B.center}else{const B=this.getShape(S);s=Q.applyToPoint(this.getShapePageTransform(B),this.getShapeGeometry(B).bounds.center)}if(P.length===1){const B=P[0];if(this.isShapeOfType(B,"frame"))for(;this.getShapesAtPoint(s).some(K=>this.isShapeOfType(K,"frame")&&K.props.w===B.props.w&&K.props.h===B.props.h);)s.x+=j.w+16}const M=ee.Common(Ae(P.map(({id:B})=>this.getShapePageBounds(B)))).center,U=w.Sub(s,M);this.updateShapes(P.map(({id:B})=>{const K=this.getShape(B),z=this.getShapeParentTransform(B).decompose().rotation,W=w.Rot(U,-z);return{id:K.id,type:K.type,x:K.x+W.x,y:K.y+W.y}}))}),this}async getSvgElement(e,r={}){const n=typeof e[0]=="string"?e:e.map(o=>o.id);if(n.length!==0)return eSt(this,n,r)}async getSvgString(e,r={}){const n=await this.getSvgElement(e,r);return n?{svg:new XMLSerializer().serializeToString(n.svg),width:n.width,height:n.height}:void 0}async getSvg(e,r={}){const n=await this.getSvgElement(e,r);if(n)return n.svg}_updateInputsFromEvent(e){const{pointerVelocity:r,previousScreenPoint:n,previousPagePoint:o,currentScreenPoint:i,currentPagePoint:s}=this.inputs,{screenBounds:a}=this.store.unsafeGetWithoutCapture(fn),{x:l,y:c,z:u}=xv(()=>this.getCamera()),d=e.point.x-a.x,f=e.point.y-a.y,p=e.point.z??.5;n.setTo(i),o.setTo(s),i.set(d,f);const g=d/u-l,m=f/u-c;isFinite(g)&&isFinite(m)&&s.set(g,m,p),this.inputs.isPen=e.type==="pointer"&&e.isPen,(e.name==="pointer_down"||this.inputs.isPinching)&&(r.set(0,0),this.inputs.originScreenPoint.setTo(i),this.inputs.originPagePoint.setTo(s)),this.run(()=>{var S;this.store.put([{id:n0,typeName:"pointer",x:s.x,y:s.y,lastActivityTimestamp:e.type==="pointer"&&e.pointerId===pN.CAMERA_MOVE?((S=this.store.unsafeGetWithoutCapture(n0))==null?void 0:S.lastActivityTimestamp)??this._tickManager.now:this._tickManager.now,meta:{}}])},{history:"ignore"})}cancel(){return this.dispatch({type:"misc",name:"cancel"}),this}interrupt(){return this.dispatch({type:"misc",name:"interrupt"}),this}complete(){return this.dispatch({type:"misc",name:"complete"}),this}focus({focusContainer:e=!0}={}){return this.getIsFocused()?this:(e&&this.focusManager.focus(),this.updateInstanceState({isFocused:!0}),this)}blur({blurContainer:e=!0}={}){return this.getIsFocused()?(e?this.focusManager.blur():this.complete(),this.updateInstanceState({isFocused:!1}),this):this}getIsFocused(){return this.getInstanceState().isFocused}getSnapshot(){return DPe(this.store)}loadSnapshot(e,r){return rY(this.store,e,r),this}_zoomToFitPageContentAt100Percent(){const e=this.getCurrentPageBounds();e&&this.zoomToBounds(e,{immediate:!0,targetZoom:this.getBaseZoom()})}_navigateToDeepLink(e){this.run(()=>{switch(e.type){case"page":{const r=this.getPage(e.pageId);r&&this.setCurrentPage(r),this._zoomToFitPageContentAt100Percent();return}case"shapes":{const r=Ae(e.shapeIds.map(s=>this.getShape(s))),n={};for(const s of r){const a=this.getAncestorPageId(s);a&&(n[a]??(n[a]=[]),n[a].push(s))}const[o,i]=Object.entries(n).sort(([s,a],[l,c])=>c.length-a.length)[0]??["",[]];if(!o||!i.length)this._zoomToFitPageContentAt100Percent();else{this.setCurrentPage(o);const s=ee.Common(i.map(a=>this.getShapePageBounds(a)));this.zoomToBounds(s,{immediate:!0,targetZoom:this.getBaseZoom()})}return}case"viewport":{if(e.pageId){if(!this.getPage(e.pageId)){this._zoomToFitPageContentAt100Percent();return}this.setCurrentPage(e.pageId)}this.zoomToBounds(e.bounds,{immediate:!0,inset:0});return}default:dr(e)}})}navigateToDeepLink(e){if(e&&"type"in e)return this._navigateToDeepLink(e),this;const n=new URL((e==null?void 0:e.url)??window.location.href).searchParams.get((e==null?void 0:e.param)??"d");if(!n)return this._zoomToFitPageContentAt100Percent(),this;try{this._navigateToDeepLink(aSt(n))}catch(o){console.warn(o),this._zoomToFitPageContentAt100Percent()}return this}createDeepLink(e){const r=new URL((e==null?void 0:e.url)??window.location.href);return r.searchParams.set((e==null?void 0:e.param)??"d",sSt((e==null?void 0:e.to)??{type:"viewport",pageId:this.options.maxPages===1?void 0:this.getCurrentPageId(),bounds:this.getViewportPageBounds()})),r}registerDeepLinkListener(e){if(e!=null&&e.getUrl&&!(e!=null&&e.onChange))throw Error("[tldraw:urlStateSync] If you specify getUrl, you must also specify the onChange callback.");const r=Y("url with state",()=>{var l,c;const s=((l=e==null?void 0:e.getUrl)==null?void 0:l.call(e,this))??window.location.href;return this.createDeepLink({param:e==null?void 0:e.param,url:s,to:(c=e==null?void 0:e.getTarget)==null?void 0:c.call(e,this)}).toString()}),n=(e==null?void 0:e.onChange)??(()=>{var a;const s=this.createDeepLink({param:e==null?void 0:e.param,to:(a=e==null?void 0:e.getTarget)==null?void 0:a.call(e,this)});window.history.replaceState({},document.title,s.toString())}),o=Ik(s=>s(),(e==null?void 0:e.debounceMs)??500),i=Sl("update url on state change",()=>n(new URL(r.get()),this),{scheduleEffect:o});return()=>{i(),o.cancel()}}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}_setShiftKeyTimeout(){this.inputs.shiftKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Shift",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ShiftLeft"})}_setAltKeyTimeout(){this.inputs.altKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Alt",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"AltLeft"})}_setCtrlKeyTimeout(){this.inputs.ctrlKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Ctrl",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ControlLeft"})}dispatch(e){return this._pendingEventsForNextTick.push(e),e.type==="pointer"&&e.name==="pointer_move"||e.type==="wheel"||e.type==="pinch"||this._flushEventsForTick(0),this}_flushEventsForTick(e){this.run(()=>{if(this._pendingEventsForNextTick.length>0){const r=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const n of r)this._flushEventForTick(n)}e>0&&this.root.handleEvent({type:"misc",name:"tick",elapsed:e}),this.scribbles.tick(e)})}_flushEventForTick(e){if(this.getCrashingError())return this;const{inputs:r}=this,{type:n}=e;if(e.type==="misc"){(e.name==="cancel"||e.name==="complete")&&(this.inputs.isDragging=!1,this.inputs.isPanning&&(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0}))),this.root.handleEvent(e);return}e.shiftKey?(clearTimeout(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,r.shiftKey=!0):!e.shiftKey&&r.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=this.timers.setTimeout(this._setShiftKeyTimeout,150)),e.altKey?(clearTimeout(this._altKeyTimeout),this._altKeyTimeout=-1,r.altKey=!0):!e.altKey&&r.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=this.timers.setTimeout(this._setAltKeyTimeout,150)),e.ctrlKey?(clearTimeout(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,r.ctrlKey=!0):!e.ctrlKey&&r.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=this.timers.setTimeout(this._setCtrlKeyTimeout,150));const{originPagePoint:o,currentPagePoint:i}=r;r.isPointing||(r.isDragging=!1);const s=this.store.unsafeGetWithoutCapture(fn),a=this.store.get(this._getCurrentPageStateId()),l=this._cameraOptions.__unsafe__getWithoutCapture();switch(n){case"pinch":{if(l.isLocked)return;switch(clearTimeout(this._longPressTimeout),this._updateInputsFromEvent(e),e.name){case"pinch_start":{if(r.isPinching)return;r.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=[...a.selectedShapeIds]),this._didPinch=!0,r.isPinching=!0,this.interrupt());return}case"pinch":{if(!r.isPinching)return;const{point:{z:c=1},delta:{x:u,y:d}}=e,{x:f,y:p}=w.SubXY(e.point,s.screenBounds.x,s.screenBounds.y);this.stopCameraAnimation(),s.followingUserId&&this.stopFollowingUser();const{x:g,y:m,z:S}=xv(()=>this.getCamera()),{panSpeed:y,zoomSpeed:v}=l;this._setCamera(new w(g+u*y/S-f/S+f/(c*v),m+d*y/S-p/S+p/(c*v),c*v),{immediate:!0});return}case"pinch_end":{if(!r.isPinching)return this;r.isPinching=!1;const{_selectedShapeIdsAtPointerDown:c}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,c.length>0&&this.once("tick",()=>{this._didPinch||this.setSelectedShapes(c)}));return}}}case"wheel":{if(l.isLocked)return;if(this._updateInputsFromEvent(e),!this.getIsMenuOpen()){const{panSpeed:c,zoomSpeed:u,wheelBehavior:d}=l;if(d!=="none"){this.stopCameraAnimation(),s.followingUserId&&this.stopFollowingUser();const{x:f,y:p,z:g}=xv(()=>this.getCamera()),{x:m,y:S,z:y=0}=e.delta;let v=d;switch(r.ctrlKey&&(v=d==="pan"?"zoom":"pan"),v){case"zoom":{const{x:b,y:$}=this.inputs.currentScreenPoint;let P=y;d==="zoom"&&(Math.abs(S)>10?P=10*Math.sign(S)/100:P=S/100);const E=g+(P??0)*u*g;this._setCamera(new w(f+(b/E-b)-(b/g-b),p+($/E-$)-($/g-$),E),{immediate:!0}),this.maybeTrackPerformance("Zooming");return}case"pan":{this._setCamera(new w(f+m*c/g,p+S*c/g,g),{immediate:!0}),this.maybeTrackPerformance("Panning");return}}}}break}case"pointer":{if(r.isPinching)return;this._updateInputsFromEvent(e);const{isPen:c}=e,{isPenMode:u}=s;switch(e.name){case"pointer_down":{if(u&&!c)return;if(this.inputs.isPanning||(this._longPressTimeout=this.timers.setTimeout(()=>{this.dispatch({...e,point:this.inputs.currentScreenPoint,name:"long_press"})},this.options.longPressDurationMs)),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),e.button===gN&&(this.capturedPointerId=e.pointerId),r.buttons.add(e.button),r.isPointing=!0,r.isDragging=!1,!u&&c&&this.updateInstanceState({isPenMode:!0}),e.button===mN?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):e.button===_v&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout)),this.inputs.isPanning)return this.stopCameraAnimation(),this.setCursor({type:"grabbing",rotation:0}),this;break}case"pointer_move":{if(!c&&u)return;const{x:d,y:f,z:p}=xv(()=>this.getCamera());if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:g,previousScreenPoint:m}=this.inputs,{panSpeed:S}=l,y=w.Sub(g,m);this.setCamera(new w(d+y.x*S/p,f+y.y*S/p,p),{immediate:!0}),this.maybeTrackPerformance("Panning");return}r.isPointing&&!r.isDragging&&w.Dist2(o,i)*this.getZoomLevel()>(s.isCoarsePointer?this.options.coarseDragDistanceSquared:this.options.dragDistanceSquared)/p&&(r.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(r.isDragging=!1,r.isPointing=!1,clearTimeout(this._longPressTimeout),r.buttons.delete(e.button),this.getIsMenuOpen()||s.isPenMode&&!c)return;if(this.capturedPointerId===e.pointerId&&(this.capturedPointerId=null,e.button=0),r.isPanning){r.keys.has("Space")||(r.isPanning=!1,r.isSpacebarPanning=!1);const d=this.inputs.pointerVelocity,f=Math.min(2,d.len());switch(e.button){case gN:{this.setCursor({type:"grab",rotation:0});break}case _v:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}f>0&&this.slideCamera({speed:f,direction:d})}else e.button===mN&&(this.complete(),this.setCurrentTool(this._restoreToolId));break}}break}case"keyboard":{switch(e.key==="ShiftRight"&&(e.key="ShiftLeft"),e.key==="AltRight"&&(e.key="AltLeft"),e.code==="ControlRight"&&(e.code="ControlLeft"),e.name){case"key_down":{if(r.keys.add(e.code),e.code==="Space"&&!e.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=s.cursor.type),this.inputs.isPanning=!0,this.inputs.isSpacebarPanning=!0,clearTimeout(this._longPressTimeout),this.setCursor({type:this.inputs.isPointing?"grabbing":"grab",rotation:0})),this.inputs.isSpacebarPanning){let c;switch(e.code){case"ArrowUp":{c=new w(0,-1);break}case"ArrowRight":{c=new w(1,0);break}case"ArrowDown":{c=new w(0,1);break}case"ArrowLeft":{c=new w(-1,0);break}}if(c){const u=this.getViewportPageBounds(),d=u.clone().translate(c.mulV({x:u.w,y:u.h}));this._animateToViewport(d,{animation:{duration:320}})}}break}case"key_up":{r.keys.delete(e.code),e.code==="Space"&&(this.inputs.buttons.has(_v)||(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(e.type==="pointer"){e.button===_v?e.name="middle_click":e.button===cO&&(e.name="right_click");const{isPenMode:c}=this.store.unsafeGetWithoutCapture(fn);if(e.isPen===c){const u=this._clickManager.handlePointerEvent(e);if(e.name!==u.name){this.root.handleEvent(e),this.emit("event",e),this.root.handleEvent(u),this.emit("event",u);return}}}return this.root.handleEvent(e),this.emit("event",e),e.type==="pointer"&&e.name==="pointer_down"&&this.clearOpenMenus(),this}maybeTrackPerformance(e){Xt.measurePerformance.get()&&(this.performanceTracker.isStarted()?clearTimeout(this.performanceTrackerTimeout):this.performanceTracker.start(e),this.performanceTrackerTimeout=this.timers.setTimeout(()=>{this.performanceTracker.stop()},50))}}se=kwt(R2);ae(se,1,"getCanUndo",gie,ie);ae(se,1,"getCanRedo",pie,ie);ae(se,1,"getPath",fie,ie);ae(se,1,"getCurrentTool",hie,ie);ae(se,1,"getCurrentToolId",die,ie);ae(se,1,"getDocumentSettings",uie,ie);ae(se,1,"getInstanceState",cie,ie);ae(se,1,"getOpenMenus",lie,ie);ae(se,1,"getIsMenuOpen",aie,ie);ae(se,1,"getPageStates",sie,ie);ae(se,1,"_getPageStatesQuery",iie,ie);ae(se,1,"getCurrentPageState",oie,ie);ae(se,1,"_getCurrentPageStateId",nie,ie);ae(se,1,"getSelectedShapeIds",rie,ie);ae(se,1,"getSelectedShapes",tie,ie);ae(se,1,"getOnlySelectedShapeId",eie,ie);ae(se,1,"getOnlySelectedShape",Joe,ie);ae(se,1,"getSelectionPageBounds",Qoe,ie);ae(se,1,"getSelectionRotation",Zoe,ie);ae(se,1,"getSelectionRotatedPageBounds",qoe,ie);ae(se,1,"getSelectionRotatedScreenBounds",Xoe,ie);ae(se,1,"getFocusedGroupId",Yoe,ie);ae(se,1,"getFocusedGroup",Voe,ie);ae(se,1,"getEditingShapeId",Goe,ie);ae(se,1,"getEditingShape",Koe,ie);ae(se,1,"getHoveredShapeId",Woe,ie);ae(se,1,"getHoveredShape",Hoe,ie);ae(se,1,"getHintingShapeIds",zoe,ie);ae(se,1,"getHintingShape",Uoe,ie);ae(se,1,"getErasingShapeIds",Boe,ie);ae(se,1,"getErasingShapes",Foe,ie);ae(se,1,"_unsafe_getCameraId",Noe,ie);ae(se,1,"getCamera",Loe,ie);ae(se,1,"getViewportPageBoundsForFollowing",Doe,ie);ae(se,1,"getCameraForFollowing",joe,ie);ae(se,1,"getZoomLevel",Roe,ie);ae(se,1,"getViewportScreenBounds",Moe,ie);ae(se,1,"getViewportScreenCenter",Ooe,ie);ae(se,1,"getViewportPageBounds",koe,ie);ae(se,1,"_getCollaboratorsQuery",Aoe,ie);ae(se,1,"getCollaborators",Toe,ie);ae(se,1,"getCollaboratorsOnCurrentPage",_oe,ie);ae(se,1,"getRenderingShapes",Coe,ie);ae(se,1,"_getAllPagesQuery",Eoe,ie);ae(se,1,"getPages",Poe,ie);ae(se,1,"getCurrentPageId",Ioe,ie);ae(se,1,"getCurrentPageShapeIdsSorted",$oe,ie);ae(se,1,"_getAllAssetsQuery",boe,ie);ae(se,1,"_getShapeGeometryCache",xoe,ie);ae(se,1,"_getShapeHandlesCache",woe,ie);ae(se,1,"_getShapePageTransformCache",Soe,ie);ae(se,1,"_getShapePageBoundsCache",yoe,ie);ae(se,1,"_getShapeClipPathCache",voe,ie);ae(se,1,"_getShapeMaskCache",moe,ie);ae(se,1,"_getShapeMaskedPageBoundsCache",goe,ie);ae(se,1,"_notVisibleShapes",poe,ie);ae(se,1,"getCulledShapes",foe,ie);ae(se,1,"getCurrentPageBounds",hoe,ie);ae(se,1,"getCurrentPageShapes",doe,ie);ae(se,1,"getCurrentPageShapesSorted",uoe,ie);ae(se,1,"getCurrentPageRenderingShapesSorted",coe,ie);ae(se,1,"_getBindingsIndexCache",loe,ie);ae(se,1,"_getSelectionSharedStyles",aoe,ie);ae(se,1,"getSharedStyles",soe,ie);ae(se,1,"getSharedOpacity",ioe,ie);ae(se,1,"getIsFocused",ooe,ie);ae(se,1,"_setShiftKeyTimeout",noe,ie);ae(se,1,"_setAltKeyTimeout",roe,ie);ae(se,1,"_setCtrlKeyTimeout",toe,ie);Mwt(se,ie);function Ry(t,e=t.getCurrentPageId()){const r=t.getPage(e).name;t.emit("max-shapes",{name:r,pageId:e,count:t.options.maxShapesPerPage})}function zi(t,e){if(!e)return t;let r=null;const n=Object.entries(e);for(let o=0,i=n.length;o<i;o++){const[s,a]=n[o];if(a!==void 0&&!(s==="id"||s==="type"||s==="typeName")&&a!==t[s]){if(r||(r={...t}),s==="props"||s==="meta"){r[s]={...t[s]};for(const[l,c]of Object.entries(a))c!==void 0&&(r[s][l]=c);continue}r[s]=a}}return r||t}function mie(t,e,r){const n=t.getShape(e);if(!n)return;r.push(n);const o=t.getSortedChildIdsForParent(e);for(let i=0,s=o.length;i<s;i++)mie(t,o[i],r)}function v7(t,e,r){let n;if(t.run(()=>{const o=t.store.extractingChanges(()=>{const i=new Set,s=new Set;for(const a of e)if(t.getShape(a))for(const c of t.getBindingsInvolvingShape(a)){const u=e.has(c.fromId),d=e.has(c.toId);if(u&&d){i.add(c.id);continue}(!u||!d)&&s.add(c.id)}t.deleteBindings([...s],{isolateShapes:!0});try{n=hn.ok(r(i))}catch(a){n=hn.err(a)}});t.store.applyDiff(Z_(o))},{history:"ignore"}),n.ok)return n.value;throw n.error}function y7(t,e){if(!e.constraints)throw Error("Should have constraints here");const{padding:{x:r,y:n}}=e.constraints,o=t.getViewportScreenBounds(),i=ee.From(e.constraints.bounds),s=(o.w-r*2)/i.w,a=(o.h-n*2)/i.h;return{zx:s,zy:a}}function jm(){const t=F(),e=km();return H("isDarkMode",()=>(e==null?void 0:e.isDarkMode)??t.user.getIsDarkMode(),[e,t])}const S7="<path d='m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z' fill='%23fff'/><path d='m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z' fill='%23000'/>",w7="<path d='m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z' fill='%23fff'/><path d='m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z' fill='%23000'/>",jy='<path d="M22.4789 9.45728L25.9935 12.9942L22.4789 16.5283V14.1032C18.126 14.1502 14.6071 17.6737 14.5675 22.0283H17.05L13.513 25.543L9.97889 22.0283H12.5674C12.6071 16.5691 17.0214 12.1503 22.4789 12.1031L22.4789 9.45728Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21.4789 7.03223L27.4035 12.9945L21.4789 18.9521V15.1868C18.4798 15.6549 16.1113 18.0273 15.649 21.0284H19.475L13.5128 26.953L7.55519 21.0284H11.6189C12.1243 15.8155 16.2679 11.6677 21.4789 11.1559L21.4789 7.03223ZM22.4789 12.1031C17.0214 12.1503 12.6071 16.5691 12.5674 22.0284H9.97889L13.513 25.543L17.05 22.0284H14.5675C14.5705 21.6896 14.5947 21.3558 14.6386 21.0284C15.1157 17.4741 17.9266 14.6592 21.4789 14.1761C21.8063 14.1316 22.1401 14.1069 22.4789 14.1032V16.5284L25.9935 12.9942L22.4789 9.45729L22.4789 12.1031Z" fill="white"/>';function Ma(t,e,r,n,o,i=16,s=16){const a=(-r-e)*(Ze/180),l=Math.sin(a),c=Math.cos(a),u=1*c-1*l,d=1*l+1*c;return`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${o};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${u}' dy='${d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${e+r} 16 16)${n?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+t.replaceAll('"',"'")+`</g></svg>") ${i} ${s}, pointer`}const jwt=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],Dwt={none:()=>"none","ew-resize":(t,e,r)=>Ma(w7,t,0,e,r),"ns-resize":(t,e,r)=>Ma(w7,t,90,e,r),"nesw-resize":(t,e,r)=>Ma(S7,t,0,e,r),"nwse-resize":(t,e,r)=>Ma(S7,t,90,e,r),"nwse-rotate":(t,e,r)=>Ma(jy,t,0,e,r),"nesw-rotate":(t,e,r)=>Ma(jy,t,90,e,r),"senw-rotate":(t,e,r)=>Ma(jy,t,180,e,r),"swne-rotate":(t,e,r)=>Ma(jy,t,270,e,r)};function Qn(t,e=0,r="black"){return Dwt[t](a$e(e),!1,r)}function Lwt(){const t=F(),e=Sr(),r=jm();qs("useCursor",()=>{const{type:n,rotation:o}=t.getInstanceState().cursor;if(jwt.includes(n)){e.style.setProperty("--tl-cursor",`var(--tl-cursor-${n})`);return}e.style.setProperty("--tl-cursor",Qn(n,o,r?"white":"black"))},[t,e,r])}function Nwt(){const t=F(),e=Sr(),r=jm(),n=H(Xt.forceSrgb);ze.useEffect(()=>{r?(e.setAttribute("data-color-mode","dark"),e.classList.remove("tl-theme__light"),e.classList.add("tl-theme__dark")):(e.setAttribute("data-color-mode","light"),e.classList.remove("tl-theme__dark"),e.classList.add("tl-theme__light")),n?e.classList.add("tl-theme__force-sRGB"):e.classList.remove("tl-theme__force-sRGB")},[t,e,n,r])}function Fwt(){const[t,e]=x.useState(0);x.useEffect(()=>e(r=>r+1),[])}const Bwt=t=>t.props.src,Uwt={upload:(t,e)=>Ys.blobToDataUrl(e)};function zwt(t){return"schema"in t&&t.schema?t.schema:Ybe({shapes:"shapeUtils"in t&&t.shapeUtils?x7(aY(t.shapeUtils)):void 0,bindings:"bindingUtils"in t&&t.bindingUtils?x7(oY(t.bindingUtils)):void 0,migrations:"migrations"in t?t.migrations:void 0})}function Eg({initialData:t,defaultName:e="",id:r,assets:n=Uwt,onMount:o,collaboration:i,...s}={}){const a=zwt(s),l=new Qk({id:r,schema:a,initialData:t,props:{defaultName:e,assets:{upload:n.upload,resolve:n.resolve??Bwt},onMount:c=>{Qe(c instanceof ie),o==null||o(c)},collaboration:i}});if(s.snapshot){if(t)throw new Error("Cannot provide both initialData and snapshot");rY(l,s.snapshot)}return l}function x7(t){return Object.fromEntries(t.map(e=>[e.type,{props:e.props,migrations:e.migrations}]))}const Hwt=(t,e)=>e.some(r=>t instanceof r);let b7,$7;function Wwt(){return b7||(b7=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Kwt(){return $7||($7=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const vie=new WeakMap,j2=new WeakMap,yie=new WeakMap,NE=new WeakMap,qR=new WeakMap;function Gwt(t){const e=new Promise((r,n)=>{const o=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{r(Zs(t.result)),o()},s=()=>{n(t.error),o()};t.addEventListener("success",i),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&vie.set(r,t)}).catch(()=>{}),qR.set(e,t),e}function Vwt(t){if(j2.has(t))return;const e=new Promise((r,n)=>{const o=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{r(),o()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});j2.set(t,e)}let D2={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return j2.get(t);if(e==="objectStoreNames")return t.objectStoreNames||yie.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Zs(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Ywt(t){D2=t(D2)}function Xwt(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){const n=t.call(FE(this),e,...r);return yie.set(n,e.sort?e.sort():[e]),Zs(n)}:Kwt().includes(t)?function(...e){return t.apply(FE(this),e),Zs(vie.get(this))}:function(...e){return Zs(t.apply(FE(this),e))}}function qwt(t){return typeof t=="function"?Xwt(t):(t instanceof IDBTransaction&&Vwt(t),Hwt(t,Wwt())?new Proxy(t,D2):t)}function Zs(t){if(t instanceof IDBRequest)return Gwt(t);if(NE.has(t))return NE.get(t);const e=qwt(t);return e!==t&&(NE.set(t,e),qR.set(e,t)),e}const FE=t=>qR.get(t);function Sie(t,e,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){const s=indexedDB.open(t,e),a=Zs(s);return n&&s.addEventListener("upgradeneeded",l=>{n(Zs(s.result),l.oldVersion,l.newVersion,Zs(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{i&&l.addEventListener("close",()=>i()),o&&l.addEventListener("versionchange",c=>o(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}function wie(t,{blocked:e}={}){const r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),Zs(r).then(()=>{})}const Zwt=["get","getKey","getAll","getAllKeys","count"],Qwt=["put","add","delete","clear"],BE=new Map;function I7(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(BE.get(e))return BE.get(e);const r=e.replace(/FromIndex$/,""),n=e!==r,o=Qwt.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||Zwt.includes(r)))return;const i=async function(s,...a){const l=this.transaction(s,o?"readwrite":"readonly");let c=l.store;return n&&(c=c.index(a.shift())),(await Promise.all([c[r](...a),o&&l.done]))[0]};return BE.set(e,i),i}Ywt(t=>({...t,get:(e,r,n)=>I7(e,r)||t.get(e,r,n),has:(e,r)=>!!I7(e,r)||t.has(e,r)}));const Jwt="TLDRAW_DOCUMENT_v2",e0t="TLDRAW_ASSET_STORE_v1",xie="TLDRAW_DB_NAME_INDEX_v2",Be={Records:"records",Schema:"schema",SessionState:"session_state",Assets:"assets"};async function bie(t){const e=Jwt+t;return r0t(e),await Sie(e,4,{upgrade(r){r.objectStoreNames.contains(Be.Records)||r.createObjectStore(Be.Records),r.objectStoreNames.contains(Be.Schema)||r.createObjectStore(Be.Schema),r.objectStoreNames.contains(Be.SessionState)||r.createObjectStore(Be.SessionState),r.objectStoreNames.contains(Be.Assets)||r.createObjectStore(Be.Assets)}})}async function t0t(t){const e=window.indexedDB.databases?(await window.indexedDB.databases()).map(f=>f.name):ZR(),r=e0t+t;if(!e.find(f=>f===r))return;const o=await Sie(r,1,{upgrade(f){f.objectStoreNames.contains("assets")||f.createObjectStore("assets")}});if(!o.objectStoreNames.contains("assets"))return;const i=o.transaction(["assets"],"readonly"),s=i.objectStore("assets"),a=await s.getAllKeys(),l=await Promise.all(a.map(async f=>[f,await s.get(f)]));await i.done;const c=await bie(t),u=c.transaction([Be.Assets],"readwrite"),d=u.objectStore(Be.Assets);for(const[f,p]of l)d.put(p,f);await u.done,o.close(),c.close(),await wie(r)}const Gp=class Gp{constructor(e){C(this,"getDbPromise");C(this,"isClosed",!1);C(this,"pendingTransactionSet",new Set);Gp.connectedInstances.add(this),this.getDbPromise=(async()=>(await t0t(e),await bie(e)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(dg)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),Gp.connectedInstances.delete(this))}tx(e,r,n){const o=(async()=>{Qe(!this.isClosed,"db is closed");const s=(await this.getDb()).transaction(r,e),a=s.done.catch(l=>{if(!this.isClosed)throw l});try{return await n(s)}finally{this.isClosed?s.abort():await a}})();return this.pendingTransactionSet.add(o),o.finally(()=>this.pendingTransactionSet.delete(o)),o}async load({sessionId:e}={}){return await this.tx("readonly",[Be.Records,Be.Schema,Be.SessionState],async r=>{var l,c;const n=r.objectStore(Be.Records),o=r.objectStore(Be.Schema),i=r.objectStore(Be.SessionState);let s=e?(l=await i.get(e))==null?void 0:l.snapshot:null;return s||(s=(c=(await i.getAll()).sort((d,f)=>d.updatedAt-f.updatedAt).pop())==null?void 0:c.snapshot),{records:await n.getAll(),schema:await o.get(Be.Schema),sessionStateSnapshot:s}})}async storeChanges({schema:e,changes:r,sessionId:n,sessionStateSnapshot:o}){await this.tx("readwrite",[Be.Records,Be.Schema,Be.SessionState],async i=>{const s=i.objectStore(Be.Records),a=i.objectStore(Be.Schema),l=i.objectStore(Be.SessionState);for(const[c,u]of Object.entries(r.added))await s.put(u,c);for(const[c,u]of Object.values(r.updated))await s.put(u,u.id);for(const c of Object.keys(r.removed))await s.delete(c);a.put(e.serialize(),Be.Schema),o&&n?l.put({snapshot:o,updatedAt:Date.now(),id:n},n):(o||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async storeSnapshot({schema:e,snapshot:r,sessionId:n,sessionStateSnapshot:o}){await this.tx("readwrite",[Be.Records,Be.Schema,Be.SessionState],async i=>{const s=i.objectStore(Be.Records),a=i.objectStore(Be.Schema),l=i.objectStore(Be.SessionState);await s.clear();for(const[c,u]of Object.entries(r))await s.put(u,c);a.put(e.serialize(),Be.Schema),o&&n?l.put({snapshot:o,updatedAt:Date.now(),id:n},n):(o||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async pruneSessions(){await this.tx("readwrite",[Be.SessionState],async e=>{const r=e.objectStore(Be.SessionState),n=(await r.getAll()).sort((i,s)=>i.updatedAt-s.updatedAt);if(n.length<10){await e.done;return}const o=n.slice(0,n.length-10);for(const{id:i}of o)await r.delete(i)})}async getAsset(e){return await this.tx("readonly",[Be.Assets],async r=>await r.objectStore(Be.Assets).get(e))}async storeAsset(e,r){await this.tx("readwrite",[Be.Assets],async n=>{await n.objectStore(Be.Assets).put(r,e)})}};C(Gp,"connectedInstances",new Set);let G0=Gp;function ZR(){const t=JSON.parse(Ak(xie)||"[]")??[];return Array.isArray(t)?t:[]}function r0t(t){const e=new Set(ZR());e.add(t),kk(xie,JSON.stringify([...e]))}function n0t(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
114
|
-
|
|
115
|
-
Keep seeing this message?
|
|
116
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
117
|
-
• If your hard disk is full, try clearing up some space and then reload the page.`)}function o0t(){window.alert(`Oops! We could not access your browser's storage—and the app won't work correctly without that. We now need to reload the page and try again.
|
|
118
|
-
|
|
119
|
-
Keep seeing this message?
|
|
120
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const i0t=350,s0t=1e4,P7=Symbol("UPDATE_INSTANCE_STATE"),a0t=t=>t;class l0t{constructor(e){C(this,"onmessage")}postMessage(e){}close(){}}const c0t=typeof BroadcastChannel>"u"?l0t:BroadcastChannel;class u0t{constructor(e,{persistenceKey:r,sessionId:n=u0,onLoad:o,onLoadError:i},s=new c0t(`tldraw-tab-sync-${r}`)){C(this,"disposables",new Set);C(this,"diffQueue",[]);C(this,"didDispose",!1);C(this,"shouldDoFullDBWrite",!0);C(this,"isReloading",!1);C(this,"persistenceKey");C(this,"sessionId");C(this,"serializedSchema");C(this,"isDebugging",!1);C(this,"documentTypes");C(this,"$sessionStateSnapshot");C(this,"db");C(this,"initTime",Date.now());C(this,"isPersisting",!1);C(this,"didLastWriteError",!1);C(this,"scheduledPersistTimeout",null);this.store=e,this.channel=s,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=r,this.sessionId=n,this.db=new G0(r),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=gO(this.store),this.disposables.add(e.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(a0t({type:"diff",storeId:this.store.id,changes:a,schema:this.serializedSchema})),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(e.listen(()=>{this.diffQueue.push(P7),this.schedulePersist()},{scope:"session"})),this.connect(o,i),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(a=>a.scope==="document").map(a=>a.typeName))}debug(...e){this.isDebugging&&console.debug(...e)}async connect(e,r){this.debug("connecting");let n;try{n=await this.db.load({sessionId:this.sessionId})}catch(o){r(o),o0t();return}if(this.debug("loaded data from store",n,"didDispose",this.didDispose),!this.didDispose)try{if(n){const o=Object.fromEntries(n.records.map(a=>[a.id,a])),i=n.sessionStateSnapshot??jPe(o),s=this.store.schema.migrateStoreSnapshot({store:o,schema:n.schema??this.store.schema.serializeEarliestVersion()});if(s.type==="error"){console.error("failed to migrate store",s),r(new Error(`Failed to migrate store: ${s.reason}`));return}this.store.mergeRemoteChanges(()=>{this.store.put(Object.values(s.value).filter(a=>this.documentTypes.has(a.typeName)),"initialize")}),i&&lT(this.store,i)}this.channel.onmessage=({data:o})=>{var a,l;this.debug("got message",o);const i=o,s=this.store.schema.getMigrationsSince(i.schema);if(s.ok){if(s.value.length>0){this.debug("telling them to reload"),this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.shouldDoFullDBWrite=!0,this.persistIfNeeded();return}}else{if(Date.now()-this.initTime<5e3){r(new Error("Schema mismatch, please close other tabs and reload the page"));return}this.debug("reloading"),this.isReloading=!0,(l=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||l.call(a);return}i.type==="diff"&&(this.debug("applying diff"),os(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(i.changes),this.store.ensureStoreIsUsable()})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),e(this)}catch(o){if(this.debug("error loading data from store",o),this.didDispose)return;r(o);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(e=>e())}schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),!this.scheduledPersistTimeout&&(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?s0t:i0t))}persistIfNeeded(){this.debug("persistIfNeeded",{isPersisting:this.isPersisting,isReloading:this.isReloading,shouldDoFullDBWrite:this.shouldDoFullDBWrite,diffQueueLength:this.diffQueue.length,storeIsPossiblyCorrupt:this.store.isPossiblyCorrupted()}),this.scheduledPersistTimeout&&(clearTimeout(this.scheduledPersistTimeout),this.scheduledPersistTimeout=null),!this.isPersisting&&(this.isReloading||this.store.isPossiblyCorrupted()||(this.shouldDoFullDBWrite||this.diffQueue.length>0)&&this.doPersist())}async doPersist(){if(Qe(!this.isPersisting,"persist already in progress"),this.didDispose)return;this.isPersisting=!0,this.debug("doPersist start");const e=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await this.db.storeSnapshot({schema:this.store.schema,snapshot:this.store.serialize(),sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const r=Xk(e.filter(n=>n!==P7));await this.db.storeChanges({changes:r,schema:this.store.schema,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(r){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",r),n0t(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function $ie(t){const e=x.useRef(t),[r,n]=x.useState(t);r!==e.current&&n(e.current);const o=x.useCallback(i=>{typeof i=="function"?e.current=i(e.current):e.current=i,n(e.current)},[]);return[r,o]}function d0t(t){const[e,r]=$ie({status:"loading"});return t=om(t),x.useEffect(()=>{const{persistenceKey:n,sessionId:o,...i}=t;if(!n){r({status:"not-synced",store:Eg(i)});return}r({status:"loading"});const s=new ls,a={upload:async(d,f)=>(await u.db.storeAsset(d.id,f),d.id),resolve:async d=>d.props.src?d.props.src.startsWith("asset:")?await s.get(d,async()=>{const f=await u.db.getAsset(d.id);return f?URL.createObjectURL(f):null}):d.props.src:null,...i.assets},l=Eg({...i,assets:a});let c=!1;const u=new u0t(l,{sessionId:o,persistenceKey:n,onLoad(){c||r({store:l,status:"synced-local"})},onLoadError(d){c||r({status:"error",error:d})}});return()=>{c=!0,u.close()}},[t,r]),e}function h0t(){const t=F(),e=Sr();x.useEffect(()=>{const r=i=>e.style.setProperty("--tl-zoom",i.toString()),n=Ik(r,100),o=new _h("useZoomCss",()=>{t.getCurrentPageShapeIds().size<300?r(t.getZoomLevel()):n(t.getZoomLevel())});return o.attach(),o.execute(),()=>{o.detach(),n.cancel()}},[t,e])}function L2(t){const e=new ArrayBuffer(t.length),r=new Uint8Array(e);for(let n=0,o=t.length;n<o;n++)r[n]=t.charCodeAt(n);return e}function f0t(t){const e=atob(t),r=L2(e);return crypto.subtle.importKey("spki",new Uint8Array(r),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}const p0t=5,dp={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8},g0t=Math.max(...Object.values(dp)),hp={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},m0t=Object.keys(hp).length,UE="sales@tldraw.com",v0t=`${tl()}/watermarks/watermark-track.svg`;class fb{constructor(e,r,n){C(this,"publicKey","MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ");C(this,"isDevelopment");C(this,"isTest");C(this,"isCryptoAvailable");C(this,"state",fr("license state","pending"));C(this,"verbose",!0);this.isTest=!1,this.isDevelopment=this.getIsDevelopment(n),this.publicKey=r||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(e).then(o=>{const i=y0t(o);!this.isDevelopment&&i&&xi(v0t),i?this.state.set("unlicensed"):o.isLicensedWithWatermark?this.state.set("licensed-with-watermark"):this.state.set("licensed")})}getIsDevelopment(e){return e==="development"?!0:e==="production"?!1:window.location.protocol!=="https:"}async extractLicenseKey(e){const[r,n]=e.split("."),[o,i]=r.split("/");if(!o.startsWith("tldraw-"))throw new Error(`Unsupported prefix '${o}'`);const s=await f0t(this.publicKey);let a;try{a=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},s,new Uint8Array(L2(atob(n))),new Uint8Array(L2(atob(i))))}catch(c){throw console.error(c),new Error("Could not perform signature validation")}if(!a)throw new Error("Invalid signature");let l;try{l=JSON.parse(atob(i))}catch{throw new Error("Could not parse object")}return l.length>m0t&&this.outputMessages(["License key contains some unknown properties.","You may want to update tldraw packages to a newer version to get access to new functionality."]),{id:l[hp.ID],hosts:l[hp.HOSTS],flags:l[hp.FLAGS],expiryDate:l[hp.EXPIRY_DATE]}}async getLicenseFromKey(e){if(!e)return this.isDevelopment||this.outputNoLicenseKeyProvided(),{isLicenseParseable:!1,reason:"no-key-provided"};if(this.isDevelopment&&!this.isCryptoAvailable)return this.verbose&&(console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."),console.log("You should check that this works in production separately.")),{isLicenseParseable:!1,reason:"has-key-development-mode"};let r=e.replace(/[\u200B-\u200D\uFEFF]/g,"");r=r.replace(/\r?\n|\r/g,"");try{const n=await this.extractLicenseKey(r),o=new Date(n.expiryDate),i=this.isFlagEnabled(n.flags,dp.ANNUAL_LICENSE),s=this.isFlagEnabled(n.flags,dp.PERPETUAL_LICENSE),a={license:n,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(n),expiryDate:o,isAnnualLicense:i,isAnnualLicenseExpired:i&&this.isAnnualLicenseExpired(o),isPerpetualLicense:s,isPerpetualLicenseExpired:s&&this.isPerpetualLicenseExpired(o),isInternalLicense:this.isFlagEnabled(n.flags,dp.INTERNAL_LICENSE),isLicensedWithWatermark:this.isFlagEnabled(n.flags,dp.WITH_WATERMARK)};return this.outputLicenseInfoIfNeeded(a),a}catch(n){return this.outputInvalidLicenseKey(n.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(e){const r=window.location.hostname.toLowerCase();return e.hosts.some(n=>{const o=n.toLowerCase().trim();if(o===r||`www.${o}`===r||o===`www.${r}`||n==="*")return!0;if(n.includes("*")){const i=new RegExp(n.replace(/\*/g,".*?"));return i.test(r)||i.test(`www.${r}`)}return!1})}getExpirationDateWithoutGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}getExpirationDateWithGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+p0t+1)}isAnnualLicenseExpired(e){const r=this.getExpirationDateWithGracePeriod(e),n=new Date>=r;return!n&&new Date>=this.getExpirationDateWithoutGracePeriod(e)&&this.outputMessages(["tldraw license is about to expire, you are in a grace period.",`Please reach out to ${UE} if you would like to renew your license.`]),n}isPerpetualLicenseExpired(e){const r=this.getExpirationDateWithGracePeriod(e),n={major:new Date(uN.major),minor:new Date(uN.minor)};return n.major>=r||n.minor>=r}isFlagEnabled(e,r){return(e&r)===r}outputNoLicenseKeyProvided(){}outputInvalidLicenseKey(e){this.outputMessages(["Invalid tldraw license key",`Reason: ${e}`])}outputLicenseInfoIfNeeded(e){e.isAnnualLicenseExpired&&this.outputMessages(["Your tldraw license has expired!",`Please reach out to ${UE} to renew.`]),!e.isDomainValid&&!e.isDevelopment&&this.outputMessages(["This tldraw license key is not valid for this domain!",`Please reach out to ${UE} if you would like to use tldraw on other domains.`]),e.license.flags>=g0t*2&&this.outputMessages(["This tldraw license contains some unknown flags.","You may want to update tldraw packages to a newer version to get access to new functionality."])}outputMessages(e){if(!this.isTest&&this.verbose){this.outputDelimiter();for(const r of e)console.log(`%c${r}`,"color: white; background: crimson; padding: 2px; border-radius: 3px;");this.outputDelimiter()}}outputDelimiter(){console.log("%c-------------------------------------------------------------------","color: white; background: crimson; padding: 2px; border-radius: 3px;")}}C(fb,"className","tl-watermark_SEE-LICENSE");function y0t(t){if(!t.isLicenseParseable||!t.isDomainValid&&!t.isDevelopment)return!0;if(t.isPerpetualLicenseExpired||t.isAnnualLicenseExpired){if(t.isInternalLicense)throw new Error("License: Internal license expired.");return!0}return!1}const Iie=x.createContext({}),S0t=()=>x.useContext(Iie);function w0t({licenseKey:t,children:e}){const[r]=x.useState(()=>new fb(t));return h.jsx(Iie.Provider,{value:r,children:e})}const x0t='<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>',b0t='<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1601" fill="none"><path fill="#000" d="M72 1319.8c0-10.73 7.071-20.18 17.372-23.22l215.823-63.62c15.519-4.57 31.078 7.05 31.078 23.22v28.26c0 11.31-7.824 21.1-18.85 23.61l-109.636 24.94c-9.254 2.1-9.487 15.2-.313 17.63l110.784 29.37a24.21 24.21 0 0 1 18.015 23.4v25.64c0 11-7.423 20.62-18.071 23.41l-109.659 28.79c-9.162 2.41-8.986 15.47.236 17.63l108.792 25.46c10.955 2.56 18.702 12.33 18.702 23.57v28.39c0 16.17-15.559 27.79-31.078 23.22l-215.823-63.62c-10.3-3.04-17.372-12.49-17.372-23.22v-32.72c0-10.59 6.883-19.95 16.994-23.11l104.523-32.67c8.547-2.67 8.479-14.79-.096-17.36l-104.17-31.3C79.01 1372.42 72 1363 72 1352.31zM72 572.638V495.43c0-13.336 10.846-24.147 24.225-24.147h215.823c13.379 0 24.225 10.811 24.225 24.147v76.179q0 40.645-15.872 70.228-15.743 29.712-45.422 45.79-29.55 16.206-70.843 16.206-41.292 0-70.971-16.078-29.55-16.077-45.422-45.532Q72 612.767 72 572.638m85.132-29.84c-13.379 0-24.225 10.81-24.225 24.146v3.122q0 19.55 6.323 33.313 6.323 13.89 21.807 21.094 15.485 7.332 43.099 7.331t43.1-7.46q15.484-7.33 21.807-21.608 6.323-14.15 6.323-34.728v-1.064c0-13.336-10.846-24.146-24.225-24.146zM72 285.858c0-13.363 10.846-24.197 24.225-24.197h215.823c13.379 0 24.225 10.834 24.225 24.197v23.27c0 13.364-10.846 24.197-24.225 24.197H154.035c-13.379 0-24.225 10.834-24.225 24.197v58.328c0 13.364-10.846 24.197-24.225 24.197h-9.36C82.845 440.047 72 429.214 72 415.85zM278.463 24.72c0-13.374 10.846-24.216 24.225-24.216h9.36c13.379 0 24.225 10.842 24.225 24.216v181.174c0 13.374-10.846 24.216-24.225 24.216h-9.36c-13.379 0-24.225-10.842-24.225-24.216v-40.108c0-8.359-6.779-15.135-15.141-15.135H96.225c-13.38 0-24.225-10.842-24.225-24.216v-22.256c0-13.374 10.846-24.216 24.225-24.216h167.097c8.362 0 15.141-6.776 15.141-15.135z"/><path fill="#000" fill-rule="evenodd" d="M89.224 1062.13C78.997 1059.04 72 1049.63 72 1038.96v-25.9c0-16.486 16.145-28.147 31.818-22.979l215.823 71.169a24.19 24.19 0 0 1 16.632 22.98v62.97c0 10.45-6.706 19.71-16.632 22.98l-215.823 71.17C88.145 1246.51 72 1234.86 72 1218.37v-25.9c0-10.67 6.997-20.08 17.224-23.17l22.595-6.81a15.13 15.13 0 0 0 10.765-14.48v-64.59a15.13 15.13 0 0 0-10.765-14.48zm98.672 77.53 49.299-14.39c8.601-2.51 8.755-14.62.22-17.35l-49.299-15.75c-5.861-1.88-11.852 2.49-11.852 8.64v30.14c0 6.05 5.817 10.41 11.632 8.71" clip-rule="evenodd"/><path fill="#000" d="M72 773.439c0-13.367 10.846-24.203 24.225-24.203h215.823c13.379 0 24.225 10.836 24.225 24.203v89.762q0 29.395-10.711 51.439-10.71 22.046-30.84 34.293t-48.261 12.248q-28.388 0-47.873-12.635-18.187-11.672-28.056-32.218c-8.303-17.289-11.301-36.661-11.301-55.705v-43.867c0-77.976 138.26 4.16 86.215 4.16h-8.138c-12.334 0-22.332 9.989-22.332 22.311 0 8.269.351 16.6 3.097 24.487q3.225 9.024 10.194 13.794 6.968 4.899 18.194 4.899 11.356 0 18.453-4.899 7.226-4.77 10.581-13.794c2.815-7.188 3.484-14.944 3.484-22.596 0-13.366-10.846-24.202-24.225-24.202h-48.56c-12.036 0-16.288 11.345-21.122 20.272-6.79 12.539-25.841 7.72-25.841-6.536 0-7.586-6.156-13.736-13.749-13.736H96.225C82.845 820.916 72 810.08 72 796.714zm108.66 137.378-10.128 5.511-62.72 34.131C91.67 959.243 72 947.569 72 929.205V906.52a24.2 24.2 0 0 1 12.719-21.299l66.199-35.696a15.82 15.82 0 0 0 8.313-13.921c0-43.012 83.618 41.371 21.429 75.213"/></svg>',$0t=`data:image/svg+xml;utf8,${encodeURIComponent(x0t)}`,I0t=`data:image/svg+xml;utf8,${encodeURIComponent(b0t)}`,P0t=x.memo(function(){const e=S0t(),r=F(),n=H("is mobile",()=>r.getViewportScreenBounds().width<700,[r]),[o,i]=x.useState(null);return qs("set watermark src",async()=>{["licensed-with-watermark","unlicensed"].includes(e.state.get())&&i(n?I0t:$0t)},[e,n]),o?h.jsxs(h.Fragment,{children:[h.jsx(C0t,{}),h.jsx(E0t,{src:o})]}):null}),E0t=x.memo(function({src:e}){const r=F(),n=H("debug mode",()=>r.getInstanceState().isDebugMode,[r]),o=H("is menu open",()=>r.getIsMenuOpen(),[r]),i=H("is mobile",()=>r.getViewportScreenBounds().width<700,[r]),s=wV(),a=`url('${e}') center 100% / 100% no-repeat`;return h.jsx("div",{className:fb.className,"data-debug":n,"data-menu":o,"data-mobile":i,draggable:!1,...s,children:h.jsx("a",{href:"https://tldraw.dev",target:"_blank",rel:"noreferrer",draggable:!1,onPointerDown:mr,style:{mask:a,WebkitMask:a}})})}),C0t=x.memo(function(){const e=fb.className,r=`/* ------------------- SEE LICENSE -------------------
|
|
121
|
-
The tldraw watermark is part of tldraw's license. It is shown for unlicensed
|
|
122
|
-
or "licensed-with-watermark" users. By using this library, you agree to
|
|
123
|
-
preserve the watermark's behavior, keeping it visible, unobscured, and
|
|
124
|
-
available to user-interaction.
|
|
125
|
-
|
|
126
|
-
To remove the watermark, please purchase a license at tldraw.dev.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
.${e} {
|
|
130
|
-
position: absolute;
|
|
131
|
-
bottom: var(--space-2);
|
|
132
|
-
right: var(--space-2);
|
|
133
|
-
width: 96px;
|
|
134
|
-
height: 32px;
|
|
135
|
-
display: flex;
|
|
136
|
-
align-items: center;
|
|
137
|
-
justify-content: center;
|
|
138
|
-
z-index: 2147483647 !important;
|
|
139
|
-
background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
|
|
140
|
-
opacity: .5;
|
|
141
|
-
border-radius: 5px;
|
|
142
|
-
pointer-events: all;
|
|
143
|
-
padding: 2px;
|
|
144
|
-
box-sizing: content-box;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.${e} > a {
|
|
148
|
-
position: absolute;
|
|
149
|
-
width: 96px;
|
|
150
|
-
height: 32px;
|
|
151
|
-
pointer-events: all;
|
|
152
|
-
cursor: inherit;
|
|
153
|
-
color: var(--color-text);
|
|
154
|
-
background-color: currentColor;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
.${e}[data-menu='true'] {
|
|
159
|
-
pointer-events: none;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.${e}[data-debug='true'] {
|
|
163
|
-
bottom: 46px;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.${e}[data-mobile='true'] {
|
|
167
|
-
border-radius: 4px 0px 0px 4px;
|
|
168
|
-
right: -2px;
|
|
169
|
-
width: 8px;
|
|
170
|
-
height: 48px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.${e}[data-mobile='true'] > a {
|
|
174
|
-
width: 8px;
|
|
175
|
-
height: 32px;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@media (hover: hover) {
|
|
179
|
-
.${e}[data-mobile='true'] > a {
|
|
180
|
-
opacity: .62;
|
|
181
|
-
pointer-events: none;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.${e} > a {
|
|
185
|
-
opacity: .28;
|
|
186
|
-
pointer-events: none;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.${e}:hover {
|
|
190
|
-
background-color: var(--color-background);
|
|
191
|
-
transition: background-color 0.2s ease-in-out;
|
|
192
|
-
transition-delay: 0.32s;
|
|
193
|
-
}
|
|
194
|
-
.${e}:hover > a {
|
|
195
|
-
animation: delayed_link 0.2s forwards ease-in-out;
|
|
196
|
-
animation-delay: 0.32s;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
@keyframes delayed_link {
|
|
201
|
-
0% {
|
|
202
|
-
cursor: inherit;
|
|
203
|
-
opacity: .38;
|
|
204
|
-
pointer-events: none;
|
|
205
|
-
}
|
|
206
|
-
100% {
|
|
207
|
-
cursor: pointer;
|
|
208
|
-
opacity: 1;
|
|
209
|
-
pointer-events: all;
|
|
210
|
-
}
|
|
211
|
-
}`;return h.jsx("style",{children:r})}),_0t=[],T0t=[],A0t=[],k0t="tl-container",O0t=x.memo(function({store:e,components:r,className:n,user:o,...i}){const[s,a]=x.useState(),l=x.useMemo(()=>o??QV(),[o]),c=(r==null?void 0:r.ErrorFallback)===void 0?HV:r==null?void 0:r.ErrorFallback,u={...i,shapeUtils:i.shapeUtils??_0t,bindingUtils:i.bindingUtils??T0t,tools:i.tools??A0t,components:r};return h.jsx("div",{ref:a,"data-tldraw":gV,draggable:!1,className:pe(`${k0t} tl-theme__light`,n),onPointerDown:mr,tabIndex:-1,children:h.jsx(yg,{fallback:c,onError:d=>Pk(d,{tags:{origin:"react.tldraw-before-app"}}),children:s&&h.jsx(w0t,{licenseKey:i.licenseKey,children:h.jsx(v$e,{container:s,children:h.jsx(wPe,{overrides:r,children:e?e instanceof Qk?h.jsx(Eie,{...u,store:e,user:l}):h.jsx(Pie,{...u,store:e,user:l}):h.jsx(M0t,{...u,store:e,user:l})})})})})})});function M0t(t){const{defaultName:e,snapshot:r,initialData:n,shapeUtils:o,bindingUtils:i,persistenceKey:s,sessionId:a,user:l,assets:c}=t,u=d0t({shapeUtils:o,bindingUtils:i,initialData:n,persistenceKey:s,sessionId:a,defaultName:e,snapshot:r,assets:c});return h.jsx(Pie,{...t,store:u,user:l})}const Pie=x.memo(function({store:e,user:r,...n}){const o=Sr();x.useLayoutEffect(()=>{r.userPreferences.get().colorScheme==="dark"&&(o.classList.remove("tl-theme__light"),o.classList.add("tl-theme__dark"))},[o,r]);const{LoadingScreen:i}=Pt();switch(e.status){case"error":throw e.error;case"loading":return i?h.jsx(i,{}):null}return h.jsx(Eie,{...n,store:e.store,user:r})}),zE=()=>document.location.search.includes("tldraw_preserve_focus");function Eie({onMount:t,children:e,store:r,tools:n,shapeUtils:o,bindingUtils:i,user:s,initialState:a,autoFocus:l=!0,inferDarkMode:c,cameraOptions:u,options:d,licenseKey:f,deepLinks:p}){const{ErrorFallback:g}=Pt(),m=Sr(),[S,y]=$ie(null),v=x.useRef(null),b=om(p===!0?{}:p),$=x.useRef({autoFocus:l&&!zE(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:b});x.useLayoutEffect(()=>{$.current={autoFocus:l&&!zE(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:b}},[l,c,a,u,b]),x.useLayoutEffect(()=>{const{autoFocus:T,inferDarkMode:I,initialState:_,cameraOptions:k,deepLinks:D}=$.current,R=new ie({store:r,shapeUtils:o,bindingUtils:i,tools:n,getContainer:()=>m,user:s,initialState:_,autoFocus:T,inferDarkMode:I,cameraOptions:k,options:d,licenseKey:f});return R.updateViewportScreenBounds(v.current??m),D&&(D!=null&&D.getUrl?R.navigateToDeepLink({...D,url:D.getUrl(R)}):R.navigateToDeepLink(D)),y(R),()=>{R.dispose()}},[i,m,d,o,r,n,s,y,f]),x.useLayoutEffect(()=>{if(S&&b)return S.registerDeepLinkListener(b)},[S,b]),x.useLayoutEffect(()=>{S&&u&&S.setCameraOptions(u)},[S,u]);const P=x.useSyncExternalStore(x.useCallback(T=>S?(S.on("crash",T),()=>S.off("crash",T)):()=>{},[S]),()=>(S==null?void 0:S.getCrashingError())??null);x.useEffect(function(){if(!S)return;function I(){S&&S.focus()}function _(){S&&S.blur()}if(l&&zE())return S.getContainer().addEventListener("pointerdown",I),document.body.addEventListener("pointerdown",_),()=>{var k;(k=S.getContainer())==null||k.removeEventListener("pointerdown",I),document.body.removeEventListener("pointerdown",_)}},[S,l]);const{Canvas:E}=Pt();return S?h.jsx(yg,{fallback:g,onError:T=>S.annotateError(T,{origin:"react.tldraw",willCrashApp:!0}),children:P?h.jsx(j0t,{crashingError:P}):h.jsx(Xx.Provider,{value:S,children:h.jsxs(R0t,{onMount:t,children:[e??(E?h.jsx(E,{}):null),h.jsx(P0t,{})]})})}):h.jsx("div",{className:"tl-canvas",ref:v})}function R0t({children:t,onMount:e}){return h0t(),Lwt(),Nwt(),Fwt(),_ie(r=>{const n=r.store.props.onMount(r),o=e==null?void 0:e(r);return()=>{n==null||n(),o==null||o()}}),t}function j0t({crashingError:t}){throw t}function QR({children:t}){return h.jsx("div",{className:"tl-loading",children:t})}function Cie({children:t}){return h.jsx("div",{className:"tl-loading",children:t})}function _ie(t){const e=F(),r=ab(n=>{let o;return n.run(()=>{o=t==null?void 0:t(n),n.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,o});ze.useLayoutEffect(()=>{if(e)return r==null?void 0:r(e)},[e,r])}function ml({children:t,className:e="",...r}){return h.jsx("div",{...r,className:pe("tl-html-container",e),children:t})}class BS{constructor(e){this.editor=e}}C(BS,"props"),C(BS,"migrations"),C(BS,"type");function pb(t,e,r={}){const{newPoint:n,handle:o,scaleX:i,scaleY:s}=e,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=r;let d=t.props.w*i,f=t.props.h*s;const p=new w(0,0);if(d>0){if(d<a){switch(o){case"top_left":case"left":case"bottom_left":{p.x=d-a;break}case"top":case"bottom":{p.x=(d-a)/2;break}default:p.x=0}d=a}}else if(p.x=d,d=-d,d<a){switch(o){case"top_left":case"left":case"bottom_left":{p.x=-d;break}default:p.x=-a}d=a}if(f>0){if(f<c){switch(o){case"top_left":case"top":case"top_right":{p.y=f-c;break}case"right":case"left":{p.y=(f-c)/2;break}default:p.y=0}f=c}}else if(p.y=f,f=-f,f<c){switch(o){case"top_left":case"top":case"top_right":{p.y=-f;break}default:p.y=-c}f=c}const{x:g,y:m}=p.rot(t.rotation).add(n);return{...t,x:g,y:m,props:{w:Math.min(l,d),h:Math.min(u,f)}}}class Vh extends Si{getGeometry(e){return new ia({width:e.props.w,height:e.props.h,isFilled:!0})}onResize(e,r){return pb(e,r)}getHandleSnapGeometry(e){return{points:this.getGeometry(e).bounds.cornersAndCenter}}getInterpolatedProps(e,r,n){return{...r.props,w:He(e.props.w,r.props.w,n),h:He(e.props.h,r.props.h,n)}}}var yC;let D0t=(yC=class extends he{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},C(yC,"id","idle"),yC);var SC;let L0t=(SC=class extends he{constructor(){super(...arguments);C(this,"wasFocusedOnEnter",!1)}onEnter(){this.wasFocusedOnEnter=!this.editor.getIsMenuOpen()}onPointerMove(r){if(this.editor.inputs.isDragging){const{originPagePoint:n}=this.editor.inputs,o=this.parent.shapeType,i=ot(),s=this.editor.markHistoryStoppingPoint(`creating_box:${i}`);this.editor.createShapes([{id:i,type:o,x:n.x,y:n.y,props:{w:1,h:1}}]).select(i);const a=this.parent;this.editor.setCurrentTool("select.resizing",{...r,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:s,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:a.onCreate?l=>{var c;return(c=a.onCreate)==null?void 0:c.call(a,l)}:void 0})}}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){const{originPagePoint:r}=this.editor.inputs;if(!this.wasFocusedOnEnter)return;const n=this.parent.shapeType,o=ot();this.editor.markHistoryStoppingPoint(`creating_box:${o}`),this.editor.createShapes([{id:o,type:n,x:r.x,y:r.y}]);const i=this.editor.getShape(o);if(!i){this.cancel();return}let{w:s,h:a}=i.props;const l=new w(s/2,a/2),c=this.editor.getShapeParentTransform(i);c&&l.rot(-c.rotation());let u=1;this.editor.user.getIsDynamicResizeMode()&&(u=1/this.editor.getZoomLevel(),s*=u,a*=u,l.mul(u));const d=$t(i);d.x=i.x-l.x,d.y=i.y-l.y,d.props.w=s,d.props.h=a,"scale"in i.props&&(d.props.scale=u),this.editor.updateShape(d),this.editor.setSelectedShapes([o]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},C(SC,"id","pointing"),SC);class N2 extends he{static children(){return[D0t,L0t]}}C(N2,"id","box"),C(N2,"initial","idle");function gb(t){const e=F();return H("isEditing",()=>e.getEditingShapeId()===t,[e,t])}function Wi(t){const e=F();return x.useMemo(function(){const o=c=>{if(c.isKilled)return;if(c.button===cO){e.dispatch({type:"pointer",target:"selection",handle:t,name:"right_click",...Ln(c)});return}if(c.button!==0)return;const u=l0(c.currentTarget);function d(){u.removeEventListener("pointerup",d),tm(u,c)}em(u,c),u.addEventListener("pointerup",d),e.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:t,...Ln(c)}),mr(c)};let i,s;function a(c){c.isKilled||c.button===0&&(c.clientX===i&&c.clientY===s||(i=c.clientX,s=c.clientY,e.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:t,...Ln(c)})))}return{onPointerDown:o,onPointerMove:a,onPointerUp:c=>{c.isKilled||c.button===0&&e.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:t,...Ln(c)})}}},[e,t])}function N0t(t){const[e,r]=x.useState(()=>({store:Eg(t),opts:t}));if(!SK(e.opts,t)){const n={store:Eg(t),opts:t};return r(n),n.store}return e.store}const F0t=20,B0t=8;function JR(t,e=F0t){return Math.max(B0t,Math.ceil(t/e))}class md extends Fl{constructor(r){super({...r,isFilled:!1,isClosed:!1});C(this,"_center");C(this,"radius");C(this,"start");C(this,"end");C(this,"largeArcFlag");C(this,"sweepFlag");C(this,"measure");C(this,"angleStart");C(this,"angleEnd");const{center:n,sweepFlag:o,largeArcFlag:i,start:s,end:a}=r;if(s.equals(a))throw Error("Arc must have different start and end points.");this.angleStart=w.Angle(n,s),this.angleEnd=w.Angle(n,a),this.radius=w.Dist(n,s),this.measure=l$e(this.angleStart,this.angleEnd,o,i),this.start=s,this.end=a,this.sweepFlag=o,this.largeArcFlag=i,this._center=n}nearestPoint(r){const{_center:n,measure:o,radius:i,angleEnd:s,angleStart:a,start:l,end:c}=this,u=oT(o,a,s,n.angle(r));if(u<=0)return l;if(u>=1)return c;const d=n.clone().add(r.clone().sub(n).uni().mul(i));let f,p=1/0,g;for(const m of[l,c,d])g=w.Dist2(r,m),g<p&&(f=m,p=g);if(!f)throw Error("nearest point not found");return f}hitTestLineSegment(r,n){const{_center:o,radius:i,measure:s,angleStart:a,angleEnd:l}=this,c=im(r,n,o,i);return c===null?!1:c.some(u=>{const d=oT(s,a,l,o.angle(u));return d>=0&&d<=1})}getVertices(){const{_center:r,measure:n,length:o,radius:i,angleStart:s}=this,a=[];for(let l=0,c=JR(Math.abs(o));l<c+1;l++){const u=l/c*n,d=s+u;a.push(Bc(r,i,d))}return a}getSvgPathData(r=!0){const{start:n,end:o,radius:i,largeArcFlag:s,sweepFlag:a}=this;return`${r?`M${n.toFixed()}`:""} A${i} ${i} 0 ${s} ${a} ${o.toFixed()}`}getLength(){return this.measure*this.radius}}class ej extends Fl{constructor(r){super({isClosed:!0,...r});C(this,"_center");C(this,"radius");C(this,"x");C(this,"y");this.config=r;const{x:n=0,y:o=0,radius:i}=r;this.x=n,this.y=o,this._center=new w(i+n,i+o),this.radius=i}getBounds(){return new ee(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:r,radius:n}=this,o=rt*n,i=[];for(let s=0,a=JR(o);s<a;s++){const l=s/a*rt;i.push(Bc(r,n,l))}return i}nearestPoint(r){const{_center:n,radius:o}=this;return n.equals(r)?w.AddXY(n,o,0):n.clone().add(r.clone().sub(n).uni().mul(o))}hitTestLineSegment(r,n,o=0){const{_center:i,radius:s}=this;return im(r,n,i,s+o)!==null}getSvgPathData(){const{_center:r,radius:n}=this;return`M${r.x+n},${r.y} a${n},${n} 0 1,0 ${n*2},0a${n},${n} 0 1,0 -${n*2},0`}}class Yr extends Ah{constructor(r){const{start:n,cp1:o,cp2:i,end:s}=r;super({...r,points:[n,s]});C(this,"a");C(this,"b");C(this,"c");C(this,"d");this.a=n,this.b=o,this.c=i,this.d=s}getVertices(){const r=[],{a:n,b:o,c:i,d:s}=this;for(let a=0,l=10;a<=l;a++){const c=a/l;r.push(new w((1-c)*(1-c)*(1-c)*n.x+3*((1-c)*(1-c))*c*o.x+3*(1-c)*(c*c)*i.x+c*c*c*s.x,(1-c)*(1-c)*(1-c)*n.y+3*((1-c)*(1-c))*c*o.y+3*(1-c)*(c*c)*i.y+c*c*c*s.y))}return r}midPoint(){return Yr.GetAtT(this,.5)}nearestPoint(r){let n,o=1/0,i,s;for(const a of this.segments)s=a.nearestPoint(r),i=w.Dist2(s,r),i<o&&(n=s,o=i);if(!n)throw Error("nearest point not found");return n}getSvgPathData(r=!0){const{a:n,b:o,c:i,d:s}=this;return`${r?`M ${n.toFixed()} `:""} C${o.toFixed()} ${i.toFixed()} ${s.toFixed()}`}static GetAtT(r,n){const{a:o,b:i,c:s,d:a}=r;return new w((1-n)*(1-n)*(1-n)*o.x+3*((1-n)*(1-n))*n*i.x+3*(1-n)*(n*n)*s.x+n*n*n*a.x,(1-n)*(1-n)*(1-n)*o.y+3*((1-n)*(1-n))*n*i.y+3*(1-n)*(n*n)*s.y+n*n*n*a.y)}getLength(r=32){let n,o=this.a,i=0;for(let s=1;s<=r;s++)n=Yr.GetAtT(this,s/r),i+=w.Dist(o,n),o=n;return i}}class U0t extends Fl{constructor(r){super({...r,isClosed:!1,isFilled:!1});C(this,"points");C(this,"_segments");const{points:n}=r;this.points=n}get segments(){if(!this._segments){this._segments=[];const{points:r}=this,n=r.length,o=n-2,i=1.25;for(let s=0;s<n-1;s++){const a=s===0?r[0]:r[s-1],l=r[s],c=r[s+1],u=s===o?c:r[s+2],d=l,f=s===0?a:new w(l.x+(c.x-a.x)/6*i,l.y+(c.y-a.y)/6*i),p=s===o?c:new w(c.x-(u.x-l.x)/6*i,c.y-(u.y-l.y)/6*i),g=c;this._segments.push(new Yr({start:d,cp1:f,cp2:p,end:g}))}}return this._segments}getLength(){return this.segments.reduce((r,n)=>r+n.length,0)}getVertices(){const r=this.segments.reduce((n,o)=>n.concat(o.vertices),[]);return r.push(this.points[this.points.length-1]),r}nearestPoint(r){let n,o=1/0,i,s;for(const a of this.segments)s=a.nearestPoint(r),i=w.Dist2(s,r),i<o&&(n=s,o=i);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(r,n){return this.segments.some(o=>o.hitTestLineSegment(r,n))}getSvgPathData(){let r=this.segments.reduce((n,o,i)=>n+o.getSvgPathData(i===0),"");return this.isClosed&&(r+="Z"),r}}class z0t extends Fl{constructor(r){super({...r,isClosed:!0});C(this,"w");C(this,"h");C(this,"_edges");this.config=r;const{width:n,height:o}=r;this.w=n,this.h=o}get edges(){if(!this._edges){const{vertices:r}=this;this._edges=[];for(let n=0,o=r.length;n<o;n++){const i=r[n],s=r[(n+1)%o];this._edges.push(new Ws({start:i,end:s}))}}return this._edges}getVertices(){const r=Math.max(1,this.w),n=Math.max(1,this.h),o=r/2,i=n/2,s=Math.pow(o-i,2)/Math.pow(o+i,2),a=Ze*(o+i)*(1+3*s/(10+Math.sqrt(4-3*s))),l=JR(a),c=rt/l,u=Math.cos(c),d=Math.sin(c);let f=0,p=1,g=0,m=1;const S=Array(l);for(let y=0;y<l;y++)S[y]=new w(o+o*p,i+i*f),g=d*p+u*f,m=u*p-d*f,f=g,p=m;return S}nearestPoint(r){let n,o=1/0,i,s;for(const a of this.edges)s=a.nearestPoint(r),i=w.Dist2(s,r),i<o&&(n=s,o=i);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(r,n){return this.edges.some(o=>o.hitTestLineSegment(r,n))}getBounds(){return new ee(0,0,this.w,this.h)}getLength(){const{w:r,h:n}=this,o=r/2,i=n/2,s=Math.max(0,o),a=Math.max(0,i);return mV(s,a)}getSvgPathData(r=!1){const{w:n,h:o}=this,i=n/2,s=o/2,a=Math.max(0,i),l=Math.max(0,s);return`${r?`M${i-a},${s}`:""} a${a},${l},0,1,1,${a*2},0a${a},${l},0,1,1,-${a*2},0`}}class H0t extends Fl{constructor(r){super({...r,isClosed:!0});C(this,"w");C(this,"h");C(this,"a");C(this,"b");C(this,"c");C(this,"d");this.config=r;const{width:n,height:o}=r;if(this.w=n,this.h=o,o>n){const i=n/2;this.a=new md({start:new w(0,i),end:new w(n,i),center:new w(n/2,i),sweepFlag:1,largeArcFlag:1}),this.b=new Ws({start:new w(n,i),end:new w(n,o-i)}),this.c=new md({start:new w(n,o-i),end:new w(0,o-i),center:new w(n/2,o-i),sweepFlag:1,largeArcFlag:1}),this.d=new Ws({start:new w(0,o-i),end:new w(0,i)})}else{const i=o/2;this.a=new md({start:new w(i,o),end:new w(i,0),center:new w(i,i),sweepFlag:1,largeArcFlag:1}),this.b=new Ws({start:new w(i,0),end:new w(n-i,0)}),this.c=new md({start:new w(n-i,0),end:new w(n-i,o),center:new w(n-i,i),sweepFlag:1,largeArcFlag:1}),this.d=new Ws({start:new w(n-i,o),end:new w(i,o)})}}nearestPoint(r){let n,o=1/0,i,s;const{a,b:l,c,d:u}=this;for(const d of[a,l,c,u])s=d.nearestPoint(r),i=w.Dist2(s,r),i<o&&(n=s,o=i);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(r,n){const{a:o,b:i,c:s,d:a}=this;return[o,i,s,a].some(l=>l.hitTestLineSegment(r,n))}getVertices(){const{a:r,b:n,c:o,d:i}=this;return[r,n,o,i].reduce((s,a)=>(s.push(...a.vertices),s),[])}getBounds(){return new ee(0,0,this.w,this.h)}getLength(){const{h:r,w:n}=this;return r>n?(Ze*(n/2)+(r-n))*2:(Ze*(r/2)+(n-r))*2}getSvgPathData(){const{a:r,b:n,c:o,d:i}=this;return[r,n,o,i].map((s,a)=>s.getSvgPathData(a===0)).join(" ")+" Z"}}async function W0t({shouldReload:t=!0}={}){Wme();for(const e of G0.connectedInstances)await e.close();await Promise.all(ZR().map(e=>wie(e))),Hme(),t&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=W0t);function K0t(t,e="_blank"){fO.openWindow(t,e)}Ol("@tldraw/editor","3.0.1","esm");function pt(t,e){var o;const r=new Set;for(const i of e){const s=t.getShape(i);if(!s)continue;t.getShapeUtil(s).onDragShapesOut&&r.add(s);const a=t.getShape(s.parentId);a&&t.getShapeUtil(a).onDragShapesOut&&r.add(a)}const n=new Map;for(const i of r){const s=Tie(t,i);s.length&&n.set(i,s)}for(const[i,s]of n){const a=t.getShapeUtil(i),l=Ae(s.map(c=>t.getShape(c)));(o=a.onDragShapesOut)==null||o.call(a,i,l)}}function Tie(t,e){const r=t.getSortedChildIdsForParent(e.id);if(r.length===0)return[];const n=t.getShapePageBounds(e);if(!n)return[];let o,i,s;const a=[];for(const l of r){const c=t.getShapePageBounds(l);if(!c)continue;if(!n.includes(c)){a.push(l);continue}o??(o=t.getShapeGeometry(e)),i??(i=t.getShapePageTransform(e)),s??(s=i.applyToPoints(o.vertices));const u=t.getShapePageTransform(l).clone().invert().applyToPoints(s),{vertices:d,isClosed:f}=t.getShapeGeometry(l);if(!d.some(p=>ho(p,u))){if(f){if(iY(u,d))continue}else if(BPe(u,d))continue;a.push(l)}}return a}function V0(t,e,r=!1){t.select(e),t.setEditingShape(e),t.setCurrentTool("select.editing_shape",{target:"shape",shape:e}),r&&t.emit("select-all-text",{shapeId:e.id}),Aie(t)}const G0t=16;function Aie(t){const e=t.getSelectionPageBounds(),r=t.getViewportPageBounds();if(e&&!r.contains(e)){const n=e.clone().expandBy(G0t/t.getZoomLevel()).expand(r),o=r.clone().translate({x:(n.center.x-r.center.x)*2,y:(n.center.y-r.center.y)*2});t.zoomToBounds(o,{animation:{duration:t.options.animationMediumMs},inset:0})}}function V0t(t,e){const r=Ae(e.map(o=>t.getShape(o)).filter(o=>o&&t.isShapeOfType(o,"frame")));if(!r.length)return;const n=[];t.run(()=>{r.map(o=>{const i=t.getSortedChildIdsForParent(o.id);i.length&&(t.reparentShapes(i,o.parentId,o.index),n.push(...i))}),t.setSelectedShapes(n),t.deleteShapes(e)})}const Y0t=50;function X0t(t,e,r={}){const n=t.getShape(e);if(!n)return;const o=t.getSortedChildIdsForParent(n.id),i=Ae(o.map(p=>t.getShape(p)));if(!i.length)return;const s=ee.FromPoints(i.flatMap(p=>{const g=t.getShapeGeometry(p.id);return t.getShapeLocalTransform(p).applyToPoints(g.vertices)})),{padding:a=Y0t}=r,l=s.w+2*a,c=s.h+2*a,u=a-s.minX,d=a-s.minY;if(u===0&&d===0&&n.props.w===l&&n.props.h===c)return;const f=new w(u,d).rot(n.rotation);t.run(()=>{const p=o.map(g=>{const m=t.getShape(g);return{id:m.id,type:m.type,x:m.x+u,y:m.y+d}});p.push({id:n.id,type:n.type,x:n.x-f.x,y:n.y-f.y,props:{w:l,h:c}}),t.updateShapes(p)})}const kie=x.createContext(null);function q0t({assetUrls:t,children:e}){return x.useEffect(()=>{for(const r of Object.values(t.icons)){const n=hg();n.src=r,n.decode()}for(const r of Object.values(t.embedIcons)){const n=hg();n.src=r,n.decode()}},[t]),h.jsx(kie.Provider,{value:t,children:e})}function tj(){const t=x.useContext(kie);if(!t)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return t}const F2={"action.convert-to-bookmark":"Convert to Bookmark","action.convert-to-embed":"Convert to Embed","action.open-embed-link":"Open link","action.align-bottom":"Align bottom","action.align-center-horizontal":"Align horizontally","action.align-center-vertical":"Align vertically","action.align-center-horizontal.short":"Align H","action.align-center-vertical.short":"Align V","action.align-left":"Align left","action.align-right":"Align right","action.align-top":"Align top","action.back-to-content":"Back to content","action.bring-forward":"Bring forward","action.bring-to-front":"Bring to front","action.copy-as-json.short":"JSON","action.copy-as-json":"Copy as JSON","action.copy-as-png.short":"PNG","action.copy-as-png":"Copy as PNG","action.copy-as-svg.short":"SVG","action.copy-as-svg":"Copy as SVG","action.copy":"Copy","action.cut":"Cut","action.delete":"Delete","action.unlock-all":"Unlock all","action.distribute-horizontal":"Distribute horizontally","action.distribute-vertical":"Distribute vertically","action.distribute-horizontal.short":"Distribute H","action.distribute-vertical.short":"Distribute V","action.duplicate":"Duplicate","action.edit-link":"Edit link","action.exit-pen-mode":"Exit pen mode","action.export-as-json.short":"JSON","action.export-as-json":"Export as JSON","action.export-as-png.short":"PNG","action.export-as-png":"Export as PNG","action.export-as-svg.short":"SVG","action.export-as-svg":"Export as SVG","action.export-all-as-json.short":"JSON","action.export-all-as-json":"Export as JSON","action.export-all-as-png.short":"PNG","action.export-all-as-png":"Export as PNG","action.export-all-as-svg.short":"SVG","action.export-all-as-svg":"Export as SVG","action.fit-frame-to-content":"Fit to content","action.flip-horizontal":"Flip horizontally","action.flip-vertical":"Flip vertically","action.flip-horizontal.short":"Flip H","action.flip-vertical.short":"Flip V","action.fork-project":"Fork this project","action.fork-project-on-tldraw":"Fork project on tldraw","action.group":"Group","action.insert-embed":"Insert embed","action.insert-media":"Upload media","action.leave-shared-project":"Leave shared project","action.new-project":"New project","action.new-shared-project":"New shared project","action.open-cursor-chat":"Cursor chat","action.open-file":"Open file","action.pack":"Pack","action.paste":"Paste","action.paste-error-title":"Pasting failed","action.paste-error-description":"Could not paste due to missing clipboard permissions. Please enable the permissions and try again.","action.print":"Print","action.redo":"Redo","action.remove-frame":"Remove frame","action.rename":"Rename","action.rotate-ccw":"Rotate counterclockwise","action.rotate-cw":"Rotate clockwise","action.save-copy":"Save a copy","action.select-all":"Select all","action.select-none":"Select none","action.send-backward":"Send backward","action.send-to-back":"Send to back","action.share-project":"Share this project","action.stack-horizontal":"Stack horizontally","action.stack-vertical":"Stack vertically","action.stack-horizontal.short":"Stack H","action.stack-vertical.short":"Stack V","action.stop-following":"Stop following","action.stretch-horizontal":"Stretch horizontally","action.stretch-vertical":"Stretch vertically","action.stretch-horizontal.short":"Stretch H","action.stretch-vertical.short":"Stretch V","action.toggle-auto-size":"Toggle auto size","action.toggle-dark-mode.menu":"Dark mode","action.toggle-dark-mode":"Toggle dark mode","action.toggle-paste-at-cursor.menu":"Paste at cursor","action.toggle-paste-at-cursor":"Toggle paste at cursor","action.toggle-wrap-mode.menu":"Select on wrap","action.toggle-wrap-mode":"Toggle Select on wrap","action.toggle-reduce-motion.menu":"Reduce motion","action.toggle-reduce-motion":"Toggle reduce motion","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-debug-mode.menu":"Debug mode","action.toggle-debug-mode":"Toggle debug mode","action.toggle-focus-mode.menu":"Focus mode","action.toggle-focus-mode":"Toggle focus mode","action.toggle-dynamic-size-mode.menu":"Dynamic size","action.toggle-dynamic-size-mode":"Toggle dynamic size","action.toggle-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","action.flatten-to-image":"Flatten","action.toggle-snap-mode.menu":"Always snap","action.toggle-snap-mode":"Toggle always snap","action.toggle-tool-lock.menu":"Tool lock","action.toggle-tool-lock":"Toggle tool lock","action.toggle-transparent.context-menu":"Transparent","action.toggle-transparent.menu":"Transparent","action.toggle-transparent":"Toggle transparent background","action.undo":"Undo","action.ungroup":"Ungroup","action.zoom-in":"Zoom in","action.zoom-out":"Zoom out","action.zoom-to-100":"Zoom to 100%","action.zoom-to-fit":"Zoom to fit","action.zoom-to-selection":"Zoom to selection","assets.files.size-too-big":"File size is too big","assets.files.type-not-allowed":"File type is not allowed","assets.files.upload-failed":"Upload failed","assets.url.failed":"Couldn't load URL preview","theme.dark":"Dark","theme.light":"Light","theme.system":"System","color-style.white":"White","color-style.black":"Black","color-style.blue":"Blue","color-style.green":"Green","color-style.grey":"Grey","color-style.light-blue":"Light blue","color-style.light-green":"Light green","color-style.light-red":"Light red","color-style.light-violet":"Light violet","color-style.orange":"Orange","color-style.red":"Red","color-style.violet":"Violet","color-style.yellow":"Yellow","fill-style.none":"None","document.default-name":"Untitled","fill-style.semi":"Semi","fill-style.solid":"Solid","fill-style.pattern":"Pattern","fill-style.fill":"Fill","dash-style.dashed":"Dashed","dash-style.dotted":"Dotted","dash-style.draw":"Draw","dash-style.solid":"Solid","size-style.s":"Small","size-style.m":"Medium","size-style.l":"Large","size-style.xl":"Extra large","opacity-style.0.1":"10%","opacity-style.0.25":"25%","opacity-style.0.5":"50%","opacity-style.0.75":"75%","opacity-style.1":"100%","font-style.draw":"Draw","font-style.sans":"Sans","font-style.serif":"Serif","font-style.mono":"Mono","align-style.start":"Start","align-style.middle":"Middle","align-style.end":"End","align-style.justify":"Justify","verticalAlign-style.start":"Top","verticalAlign-style.middle":"Middle","verticalAlign-style.end":"Bottom","geo-style.arrow-down":"Arrow down","geo-style.arrow-left":"Arrow left","geo-style.arrow-right":"Arrow right","geo-style.arrow-up":"Arrow up","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.cloud":"Cloud","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus-2":"Rhombus 2","geo-style.rhombus":"Rhombus","geo-style.star":"Star","geo-style.trapezoid":"Trapezoid","geo-style.triangle":"Triangle","geo-style.x-box":"X box","geo-style.check-box":"Check box","arrowheadStart-style.none":"None","arrowheadStart-style.arrow":"Arrow","arrowheadStart-style.bar":"Bar","arrowheadStart-style.diamond":"Diamond","arrowheadStart-style.dot":"Dot","arrowheadStart-style.inverted":"Inverted","arrowheadStart-style.pipe":"Pipe","arrowheadStart-style.square":"Square","arrowheadStart-style.triangle":"Triangle","arrowheadEnd-style.none":"None","arrowheadEnd-style.arrow":"Arrow","arrowheadEnd-style.bar":"Bar","arrowheadEnd-style.diamond":"Diamond","arrowheadEnd-style.dot":"Dot","arrowheadEnd-style.inverted":"Inverted","arrowheadEnd-style.pipe":"Pipe","arrowheadEnd-style.square":"Square","arrowheadEnd-style.triangle":"Triangle","spline-style.line":"Line","spline-style.cubic":"Cubic","tool.select":"Select","tool.hand":"Hand","tool.draw":"Draw","tool.eraser":"Eraser","tool.arrow-down":"Arrow down","tool.arrow-left":"Arrow left","tool.arrow-right":"Arrow right","tool.arrow-up":"Arrow up","tool.arrow":"Arrow","tool.cloud":"Cloud","tool.diamond":"Diamond","tool.ellipse":"Ellipse","tool.hexagon":"Hexagon","tool.highlight":"Highlight","tool.line":"Line","tool.octagon":"Octagon","tool.oval":"Oval","tool.pentagon":"Pentagon","tool.rectangle":"Rectangle","tool.rhombus":"Rhombus","tool.star":"Star","tool.trapezoid":"Trapezoid","tool.triangle":"Triangle","tool.x-box":"X box","tool.check-box":"Check box","tool.asset":"Asset","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","tool.pointer-down":"Pointer down","menu.title":"Menu","menu.theme":"Theme","menu.copy-as":"Copy as","menu.edit":"Edit","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.help":"Help","menu.view":"View","context-menu.edit":"Edit","context-menu.arrange":"Arrange","context-menu.copy-as":"Copy as","context-menu.export-as":"Export as","context-menu.export-all-as":"Export","context-menu.move-to-page":"Move to page","context-menu.reorder":"Reorder","page-menu.title":"Pages","page-menu.create-new-page":"Create new page","page-menu.max-page-count-reached":"Max pages reached","page-menu.new-page-initial-name":"Page 1","page-menu.edit-start":"Edit","page-menu.edit-done":"Done","page-menu.go-to-page":"Go to page","page-menu.submenu.rename":"Rename","page-menu.submenu.duplicate-page":"Duplicate","page-menu.submenu.title":"Menu","page-menu.submenu.move-down":"Move down","page-menu.submenu.move-up":"Move up","page-menu.submenu.delete":"Delete","share-menu.title":"Share","share-menu.save-note":"Download this project to your computer as a .tldr file.","share-menu.fork-note":"Create a new shared project based on this snapshot.","share-menu.share-project":"Share this project","share-menu.default-project-name":"Shared Project","share-menu.copy-link":"Copy editor link","share-menu.readonly-link":"Read-only","share-menu.create-snapshot-link":"Copy snapshot link","share-menu.snapshot-link-note":"Capture and share this project as a read-only snapshot link.","share-menu.copy-readonly-link":"Copy viewer link","share-menu.offline-note":"Create a new shared project based on your current project.","share-menu.copy-link-note":"Anyone with the link will be able to view and edit this project.","share-menu.copy-readonly-link-note":"Anyone with the link will be able to access this project.","share-menu.project-too-large":"Sorry, this project can't be shared because it's too large. We're working on it!","share-menu.upload-failed":"Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.","share-menu.creating-project":"Creating the new project…","share-menu.copied":"Copied link","document-name-menu.copy-link":"Copy link","status.offline":"Offline","status.online":"Online","people-menu.title":"People","people-menu.change-name":"Change name","people-menu.change-color":"Change color","people-menu.follow":"Following","people-menu.following":"Following","people-menu.leading":"Following You","people-menu.user":"(You)","people-menu.invite":"Invite others","help-menu.title":"Help and resources","help-menu.about":"About tldraw","help-menu.docs":"Documentation & API","help-menu.discord":"Discord","help-menu.github":"GitHub","help-menu.keyboard-shortcuts":"Keyboard shortcuts","help-menu.twitter":"Twitter","help-menu.terms":"Terms of service","help-menu.privacy":"Privacy policy","actions-menu.title":"Actions","edit-link-dialog.title":"Edit link","edit-link-dialog.invalid-url":"A link must be a valid URL.","edit-link-dialog.detail":"Links will open in a new tab.","edit-link-dialog.url":"URL","edit-link-dialog.clear":"Clear","edit-link-dialog.save":"Continue","edit-link-dialog.cancel":"Cancel","embed-dialog.title":"Insert embed","embed-dialog.back":"Back","embed-dialog.create":"Create","embed-dialog.cancel":"Cancel","embed-dialog.url":"URL","embed-dialog.instruction":"Paste in the site's URL to create the embed.","embed-dialog.invalid-url":"We could not create an embed from that URL.","edit-pages-dialog.move-down":"Move down","edit-pages-dialog.move-up":"Move up","shortcuts-dialog.title":"Keyboard shortcuts","shortcuts-dialog.edit":"Edit","shortcuts-dialog.file":"File","shortcuts-dialog.preferences":"Preferences","shortcuts-dialog.tools":"Tools","shortcuts-dialog.transform":"Transform","shortcuts-dialog.view":"View","shortcuts-dialog.collaboration":"Collaboration","home-project-dialog.title":"Home project","home-project-dialog.description":"This is your local home project. It's just for you!","rename-project-dialog.title":"Rename project","rename-project-dialog.cancel":"Cancel","rename-project-dialog.rename":"Rename","home-project-dialog.ok":"Ok","style-panel.title":"Styles","style-panel.align":"Align","style-panel.vertical-align":"Vertical align","style-panel.position":"Position","style-panel.arrowheads":"Arrows","style-panel.arrowhead-start":"Start","style-panel.arrowhead-end":"End","style-panel.color":"Color","style-panel.dash":"Dash","style-panel.fill":"Fill","style-panel.font":"Font","style-panel.geo":"Shape","style-panel.mixed":"Mixed","style-panel.opacity":"Opacity","style-panel.size":"Size","style-panel.spline":"Spline","tool-panel.drawing":"Drawing","tool-panel.shapes":"Shapes","tool-panel.more":"More","debug-panel.more":"More","navigation-zone.toggle-minimap":"Toggle minimap","navigation-zone.zoom":"Zoom","focus-mode.toggle-focus-mode":"Toggle focus mode","toast.close":"Close","file-system.file-open-error.title":"Could not open file","file-system.file-open-error.not-a-tldraw-file":"The file you tried to open doesn't look like a tldraw file.","file-system.file-open-error.file-format-version-too-new":"The file you tried to open is from a newer version of tldraw. Please reload the page and try again.","file-system.file-open-error.generic-corrupted-file":"The file you tried to open is corrupted.","file-system.confirm-open.title":"Overwrite current project?","file-system.confirm-open.description":"Opening a file will replace your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-open.cancel":"Cancel","file-system.confirm-open.open":"Open file","file-system.confirm-open.dont-show-again":"Don't ask again","file-system.confirm-clear.title":"Clear current project?","file-system.confirm-clear.description":"Creating a new project will clear your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-clear.cancel":"Cancel","file-system.confirm-clear.continue":"Continue","file-system.confirm-clear.dont-show-again":"Don't ask again","file-system.shared-document-file-open-error.title":"Could not open file","file-system.shared-document-file-open-error.description":"Opening files from shared projects is not supported.","sharing.confirm-leave.title":"Leave current project?","sharing.confirm-leave.description":"Are you sure you want to leave this shared project? You can return to it by navigating to its URL.","sharing.confirm-leave.cancel":"Cancel","sharing.confirm-leave.leave":"Leave","sharing.confirm-leave.dont-show-again":"Don't ask again","toast.error.export-fail.title":"Failed export","toast.error.export-fail.desc":"Failed to export image","toast.error.copy-fail.title":"Failed copy","toast.error.copy-fail.desc":"Failed to copy image","context.pages.new-page":"New page","vscode.file-open.desc":"We've updated this document to work with the current version of tldraw. If you'd like to keep the original version (which will work on old.tldraw.com), click below to create a backup.","vscode.file-open.open":"Continue","vscode.file-open.backup":"Backup","vscode.file-open.backup-saved":"Backup saved","vscode.file-open.backup-failed":"Backup failed: this is not a .tldr file.","vscode.file-open.dont-show-again":"Don't ask again","cursor-chat.type-to-chat":"Type to chat..."},Z0t=new Set(["ar","fa","he","ur","ku"]),ju={locale:"en",label:"English",messages:F2,dir:"ltr"};async function Q0t(t,e){if(!(await xi(e.translations.en)).ok)return console.warn("No main translations found."),ju;if(t==="en")return ju;const n=vg.find(a=>a.locale===t);if(!n)return console.warn(`No translation found for locale ${t}`),ju;const i=await(await xi(e.translations[n.locale])).json();if(!i)return console.warn(`No messages found for locale ${t}`),ju;const s=[];for(const a in ju.messages)i[a]||s.push(a);return s.length>0,{locale:t,label:n.label,dir:Z0t.has(n.locale)?"rtl":"ltr",messages:{...ju.messages,...i}}}const Oie=x.createContext(null);function Mie(){const t=x.useContext(Oie);if(!t)throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />");return t}const J0t=yr(function({overrides:e,children:r}){const o=F().user.getLocale(),i=tj(),[s,a]=x.useState(()=>e&&e.en?{locale:"en",label:"English",dir:"ltr",messages:{...F2,...e.en}}:{locale:"en",label:"English",dir:"ltr",messages:F2});return x.useEffect(()=>{let l=!1;async function c(){const u=await Q0t(o,i);u&&!l&&(e&&e[o]?a({...u,messages:{...u.messages,...e[o]}}):a(u))}return c(),()=>{l=!0}},[i,o,e]),h.jsx(Oie.Provider,{value:s,children:r})});function Fe(){const t=Mie();return x.useCallback(function(r){return t.messages[r]??r},[t])}const me=x.forwardRef(function({children:e,disabled:r,type:n,...o},i){return h.jsx("button",{ref:i,type:"button",draggable:!1,disabled:r,...o,className:pe("tlui-button",`tlui-button__${n}`,o.className),children:e})});function qt({children:t}){return h.jsx("span",{className:"tlui-button__label",children:t})}function ue(t,e,{checkForDefaultPrevented:r=!0}={}){return function(o){if(t==null||t(o),r===!1||!o.defaultPrevented)return e==null?void 0:e(o)}}function ext(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function mb(...t){return e=>t.forEach(r=>ext(r,e))}function yt(...t){return x.useCallback(mb(...t),t)}function txt(t,e){const r=x.createContext(e);function n(i){const{children:s,...a}=i,l=x.useMemo(()=>a,Object.values(a));return h.jsx(r.Provider,{value:l,children:s})}function o(i){const s=x.useContext(r);if(s)return s;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return n.displayName=t+"Provider",[n,o]}function $s(t,e=[]){let r=[];function n(i,s){const a=x.createContext(s),l=r.length;r=[...r,s];function c(d){const{scope:f,children:p,...g}=d,m=(f==null?void 0:f[t][l])||a,S=x.useMemo(()=>g,Object.values(g));return h.jsx(m.Provider,{value:S,children:p})}function u(d,f){const p=(f==null?void 0:f[t][l])||a,g=x.useContext(p);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=r.map(s=>x.createContext(s));return function(a){const l=(a==null?void 0:a[t])||i;return x.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[n,rxt(o,...e)]}function rxt(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=n.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return x.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return r.scopeName=e.scopeName,r}var Il=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{},nxt=Mhe.useId||(()=>{}),oxt=0;function Qs(t){const[e,r]=x.useState(nxt());return Il(()=>{t||r(n=>n??String(oxt++))},[t]),t||(e?`radix-${e}`:"")}function Dr(t){const e=x.useRef(t);return x.useEffect(()=>{e.current=t}),x.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function Gl({prop:t,defaultProp:e,onChange:r=()=>{}}){const[n,o]=ixt({defaultProp:e,onChange:r}),i=t!==void 0,s=i?t:n,a=Dr(r),l=x.useCallback(c=>{if(i){const d=typeof c=="function"?c(t):c;d!==t&&a(d)}else o(c)},[i,t,o,a]);return[s,l]}function ixt({defaultProp:t,onChange:e}){const r=x.useState(t),[n]=r,o=x.useRef(n),i=Dr(e);return x.useEffect(()=>{o.current!==n&&(i(n),o.current=n)},[n,o,i]),r}var Kc=x.forwardRef((t,e)=>{const{children:r,...n}=t,o=x.Children.toArray(r),i=o.find(axt);if(i){const s=i.props.children,a=o.map(l=>l===i?x.Children.count(s)>1?x.Children.only(null):x.isValidElement(s)?s.props.children:null:l);return h.jsx(B2,{...n,ref:e,children:x.isValidElement(s)?x.cloneElement(s,void 0,a):null})}return h.jsx(B2,{...n,ref:e,children:r})});Kc.displayName="Slot";var B2=x.forwardRef((t,e)=>{const{children:r,...n}=t;if(x.isValidElement(r)){const o=cxt(r);return x.cloneElement(r,{...lxt(n,r.props),ref:e?mb(e,o):o})}return x.Children.count(r)>1?x.Children.only(null):null});B2.displayName="SlotClone";var sxt=({children:t})=>h.jsx(h.Fragment,{children:t});function axt(t){return x.isValidElement(t)&&t.type===sxt}function lxt(t,e){const r={...e};for(const n in e){const o=t[n],i=e[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{i(...a),o(...a)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...t,...r}}function cxt(t){var n,o;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var uxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ye=uxt.reduce((t,e)=>{const r=x.forwardRef((n,o)=>{const{asChild:i,...s}=n,a=i?Kc:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(a,{...s,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function rj(t,e){t&&oa.flushSync(()=>t.dispatchEvent(e))}function dxt(t,e=globalThis==null?void 0:globalThis.document){const r=Dr(t);x.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[r,e])}var hxt="DismissableLayer",U2="dismissableLayer.update",fxt="dismissableLayer.pointerDownOutside",pxt="dismissableLayer.focusOutside",E7,Rie=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Dm=x.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=t,c=x.useContext(Rie),[u,d]=x.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=x.useState({}),g=yt(e,T=>d(T)),m=Array.from(c.layers),[S]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(S),v=u?m.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,$=v>=y,P=mxt(T=>{const I=T.target,_=[...c.branches].some(k=>k.contains(I));!$||_||(o==null||o(T),s==null||s(T),T.defaultPrevented||a==null||a())},f),E=vxt(T=>{const I=T.target;[...c.branches].some(k=>k.contains(I))||(i==null||i(T),s==null||s(T),T.defaultPrevented||a==null||a())},f);return dxt(T=>{v===c.layers.size-1&&(n==null||n(T),!T.defaultPrevented&&a&&(T.preventDefault(),a()))},f),x.useEffect(()=>{if(u)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(E7=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),C7(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=E7)}},[u,f,r,c]),x.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),C7())},[u,c]),x.useEffect(()=>{const T=()=>p({});return document.addEventListener(U2,T),()=>document.removeEventListener(U2,T)},[]),h.jsx(Ye.div,{...l,ref:g,style:{pointerEvents:b?$?"auto":"none":void 0,...t.style},onFocusCapture:ue(t.onFocusCapture,E.onFocusCapture),onBlurCapture:ue(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:ue(t.onPointerDownCapture,P.onPointerDownCapture)})});Dm.displayName=hxt;var gxt="DismissableLayerBranch",jie=x.forwardRef((t,e)=>{const r=x.useContext(Rie),n=x.useRef(null),o=yt(e,n);return x.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),h.jsx(Ye.div,{...t,ref:o})});jie.displayName=gxt;function mxt(t,e=globalThis==null?void 0:globalThis.document){const r=Dr(t),n=x.useRef(!1),o=x.useRef(()=>{});return x.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let l=function(){Die(fxt,r,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=l,e.addEventListener("click",o.current,{once:!0})):l()}else e.removeEventListener("click",o.current);n.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",i),e.removeEventListener("click",o.current)}},[e,r]),{onPointerDownCapture:()=>n.current=!0}}function vxt(t,e=globalThis==null?void 0:globalThis.document){const r=Dr(t),n=x.useRef(!1);return x.useEffect(()=>{const o=i=>{i.target&&!n.current&&Die(pxt,r,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function C7(){const t=new CustomEvent(U2);document.dispatchEvent(t)}function Die(t,e,r,{discrete:n}){const o=r.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&o.addEventListener(t,e,{once:!0}),n?rj(o,i):o.dispatchEvent(i)}var yxt=Dm,Sxt=jie,HE="focusScope.autoFocusOnMount",WE="focusScope.autoFocusOnUnmount",_7={bubbles:!1,cancelable:!0},wxt="FocusScope",vb=x.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=t,[a,l]=x.useState(null),c=Dr(o),u=Dr(i),d=x.useRef(null),f=yt(e,m=>l(m)),p=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(n){let m=function(b){if(p.paused||!a)return;const $=b.target;a.contains($)?d.current=$:Da(d.current,{select:!0})},S=function(b){if(p.paused||!a)return;const $=b.relatedTarget;$!==null&&(a.contains($)||Da(d.current,{select:!0}))},y=function(b){if(document.activeElement===document.body)for(const P of b)P.removedNodes.length>0&&Da(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",S);const v=new MutationObserver(y);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",S),v.disconnect()}}},[n,a,p.paused]),x.useEffect(()=>{if(a){A7.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(HE,_7);a.addEventListener(HE,c),a.dispatchEvent(y),y.defaultPrevented||(xxt(Ext(Lie(a)),{select:!0}),document.activeElement===m&&Da(a))}return()=>{a.removeEventListener(HE,c),setTimeout(()=>{const y=new CustomEvent(WE,_7);a.addEventListener(WE,u),a.dispatchEvent(y),y.defaultPrevented||Da(m??document.body,{select:!0}),a.removeEventListener(WE,u),A7.remove(p)},0)}}},[a,c,u,p]);const g=x.useCallback(m=>{if(!r&&!n||p.paused)return;const S=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(S&&y){const v=m.currentTarget,[b,$]=bxt(v);b&&$?!m.shiftKey&&y===$?(m.preventDefault(),r&&Da(b,{select:!0})):m.shiftKey&&y===b&&(m.preventDefault(),r&&Da($,{select:!0})):y===v&&m.preventDefault()}},[r,n,p.paused]);return h.jsx(Ye.div,{tabIndex:-1,...s,ref:f,onKeyDown:g})});vb.displayName=wxt;function xxt(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(Da(n,{select:e}),document.activeElement!==r)return}function bxt(t){const e=Lie(t),r=T7(e,t),n=T7(e.reverse(),t);return[r,n]}function Lie(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function T7(t,e){for(const r of t)if(!$xt(r,{upTo:e}))return r}function $xt(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Ixt(t){return t instanceof HTMLInputElement&&"select"in t}function Da(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&Ixt(t)&&e&&t.select()}}var A7=Pxt();function Pxt(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=k7(t,e),t.unshift(e)},remove(e){var r;t=k7(t,e),(r=t[0])==null||r.resume()}}}function k7(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function Ext(t){return t.filter(e=>e.tagName!=="A")}var Cxt="Portal",Lm=x.forwardRef((t,e)=>{var a;const{container:r,...n}=t,[o,i]=x.useState(!1);Il(()=>i(!0),[]);const s=r||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?Wpe.createPortal(h.jsx(Ye.div,{...n,ref:e}),s):null});Lm.displayName=Cxt;function _xt(t,e){return x.useReducer((r,n)=>e[r][n]??r,t)}var Mi=t=>{const{present:e,children:r}=t,n=Txt(e),o=typeof r=="function"?r({present:n.isPresent}):x.Children.only(r),i=yt(n.ref,Axt(o));return typeof r=="function"||n.isPresent?x.cloneElement(o,{ref:i}):null};Mi.displayName="Presence";function Txt(t){const[e,r]=x.useState(),n=x.useRef({}),o=x.useRef(t),i=x.useRef("none"),s=t?"mounted":"unmounted",[a,l]=_xt(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const c=Dy(n.current);i.current=a==="mounted"?c:"none"},[a]),Il(()=>{const c=n.current,u=o.current;if(u!==t){const f=i.current,p=Dy(c);t?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Il(()=>{if(e){const c=d=>{const p=Dy(n.current).includes(d.animationName);d.target===e&&p&&oa.flushSync(()=>l("ANIMATION_END"))},u=d=>{d.target===e&&(i.current=Dy(n.current))};return e.addEventListener("animationstart",u),e.addEventListener("animationcancel",c),e.addEventListener("animationend",c),()=>{e.removeEventListener("animationstart",u),e.removeEventListener("animationcancel",c),e.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:x.useCallback(c=>{c&&(n.current=getComputedStyle(c)),r(c)},[])}}function Dy(t){return(t==null?void 0:t.animationName)||"none"}function Axt(t){var n,o;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var KE=0;function nj(){x.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??O7()),document.body.insertAdjacentElement("beforeend",t[1]??O7()),KE++,()=>{KE===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),KE--}},[])}function O7(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",t}var Yi=function(){return Yi=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Yi.apply(this,arguments)};function Nie(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r}function kxt(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}var US="right-scroll-bar-position",zS="width-before-scroll-bar",Oxt="with-scroll-bars-hidden",Mxt="--removed-body-scroll-bar-size";function GE(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function Rxt(t,e){var r=x.useState(function(){return{value:t,callback:e,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=e,r.facade}var jxt=typeof window<"u"?x.useLayoutEffect:x.useEffect,M7=new WeakMap;function Dxt(t,e){var r=Rxt(null,function(n){return t.forEach(function(o){return GE(o,n)})});return jxt(function(){var n=M7.get(r);if(n){var o=new Set(n),i=new Set(t),s=r.current;o.forEach(function(a){i.has(a)||GE(a,null)}),i.forEach(function(a){o.has(a)||GE(a,s)})}M7.set(r,t)},[t]),r}function Lxt(t){return t}function Nxt(t,e){e===void 0&&(e=Lxt);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(i){var s=e(i,n);return r.push(s),function(){r=r.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(n=!0;r.length;){var s=r;r=[],s.forEach(i)}r={push:function(a){return i(a)},filter:function(){return r}}},assignMedium:function(i){n=!0;var s=[];if(r.length){var a=r;r=[],a.forEach(i),s=r}var l=function(){var u=s;s=[],u.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),r={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),r}}}};return o}function Fxt(t){t===void 0&&(t={});var e=Nxt(null);return e.options=Yi({async:!0,ssr:!1},t),e}var Fie=function(t){var e=t.sideCar,r=Nie(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=e.read();if(!n)throw new Error("Sidecar medium not found");return x.createElement(n,Yi({},r))};Fie.isSideCarExport=!0;function Bxt(t,e){return t.useMedium(e),Fie}var Bie=Fxt(),VE=function(){},yb=x.forwardRef(function(t,e){var r=x.useRef(null),n=x.useState({onScrollCapture:VE,onWheelCapture:VE,onTouchMoveCapture:VE}),o=n[0],i=n[1],s=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,p=t.noIsolation,g=t.inert,m=t.allowPinchZoom,S=t.as,y=S===void 0?"div":S,v=t.gapMode,b=Nie(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),$=f,P=Dxt([r,e]),E=Yi(Yi({},b),o);return x.createElement(x.Fragment,null,u&&x.createElement($,{sideCar:Bie,removeScrollBar:c,shards:d,noIsolation:p,inert:g,setCallbacks:i,allowPinchZoom:!!m,lockRef:r,gapMode:v}),s?x.cloneElement(x.Children.only(a),Yi(Yi({},E),{ref:P})):x.createElement(y,Yi({},E,{className:l,ref:P}),a))});yb.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};yb.classNames={fullWidth:zS,zeroRight:US};var Uxt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zxt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Uxt();return e&&t.setAttribute("nonce",e),t}function Hxt(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function Wxt(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Kxt=function(){var t=0,e=null;return{add:function(r){t==0&&(e=zxt())&&(Hxt(e,r),Wxt(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Gxt=function(){var t=Kxt();return function(e,r){x.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&r])}},Uie=function(){var t=Gxt(),e=function(r){var n=r.styles,o=r.dynamic;return t(n,o),null};return e},Vxt={left:0,top:0,right:0,gap:0},YE=function(t){return parseInt(t||"",10)||0},Yxt=function(t){var e=window.getComputedStyle(document.body),r=e[t==="padding"?"paddingLeft":"marginLeft"],n=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[YE(r),YE(n),YE(o)]},Xxt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Vxt;var e=Yxt(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-r+e[2]-e[0])}},qxt=Uie(),Fd="data-scroll-locked",Zxt=function(t,e,r,n){var o=t.left,i=t.top,s=t.right,a=t.gap;return r===void 0&&(r="margin"),`
|
|
212
|
-
.`.concat(Oxt,` {
|
|
213
|
-
overflow: hidden `).concat(n,`;
|
|
214
|
-
padding-right: `).concat(a,"px ").concat(n,`;
|
|
215
|
-
}
|
|
216
|
-
body[`).concat(Fd,`] {
|
|
217
|
-
overflow: hidden `).concat(n,`;
|
|
218
|
-
overscroll-behavior: contain;
|
|
219
|
-
`).concat([e&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
220
|
-
padding-left: `.concat(o,`px;
|
|
221
|
-
padding-top: `).concat(i,`px;
|
|
222
|
-
padding-right: `).concat(s,`px;
|
|
223
|
-
margin-left:0;
|
|
224
|
-
margin-top:0;
|
|
225
|
-
margin-right: `).concat(a,"px ").concat(n,`;
|
|
226
|
-
`),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.`).concat(US,` {
|
|
230
|
-
right: `).concat(a,"px ").concat(n,`;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.`).concat(zS,` {
|
|
234
|
-
margin-right: `).concat(a,"px ").concat(n,`;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.`).concat(US," .").concat(US,` {
|
|
238
|
-
right: 0 `).concat(n,`;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.`).concat(zS," .").concat(zS,` {
|
|
242
|
-
margin-right: 0 `).concat(n,`;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
body[`).concat(Fd,`] {
|
|
246
|
-
`).concat(Mxt,": ").concat(a,`px;
|
|
247
|
-
}
|
|
248
|
-
`)},R7=function(){var t=parseInt(document.body.getAttribute(Fd)||"0",10);return isFinite(t)?t:0},Qxt=function(){x.useEffect(function(){return document.body.setAttribute(Fd,(R7()+1).toString()),function(){var t=R7()-1;t<=0?document.body.removeAttribute(Fd):document.body.setAttribute(Fd,t.toString())}},[])},Jxt=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,o=n===void 0?"margin":n;Qxt();var i=x.useMemo(function(){return Xxt(o)},[o]);return x.createElement(qxt,{styles:Zxt(i,!e,o,r?"":"!important")})},z2=!1;if(typeof window<"u")try{var Ly=Object.defineProperty({},"passive",{get:function(){return z2=!0,!0}});window.addEventListener("test",Ly,Ly),window.removeEventListener("test",Ly,Ly)}catch{z2=!1}var Du=z2?{passive:!1}:!1,e1t=function(t){return t.tagName==="TEXTAREA"},zie=function(t,e){var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!e1t(t)&&r[e]==="visible")},t1t=function(t){return zie(t,"overflowY")},r1t=function(t){return zie(t,"overflowX")},j7=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=Hie(t,n);if(o){var i=Wie(t,n),s=i[1],a=i[2];if(s>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},n1t=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},o1t=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Hie=function(t,e){return t==="v"?t1t(e):r1t(e)},Wie=function(t,e){return t==="v"?n1t(e):o1t(e)},i1t=function(t,e){return t==="h"&&e==="rtl"?-1:1},s1t=function(t,e,r,n,o){var i=i1t(t,window.getComputedStyle(e).direction),s=i*n,a=r.target,l=e.contains(a),c=!1,u=s>0,d=0,f=0;do{var p=Wie(t,a),g=p[0],m=p[1],S=p[2],y=m-S-i*g;(g||y)&&Hie(t,a)&&(d+=y,f+=g),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(u&&(Math.abs(d)<1||!o)||!u&&(Math.abs(f)<1||!o))&&(c=!0),c},Ny=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},D7=function(t){return[t.deltaX,t.deltaY]},L7=function(t){return t&&"current"in t?t.current:t},a1t=function(t,e){return t[0]===e[0]&&t[1]===e[1]},l1t=function(t){return`
|
|
249
|
-
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
250
|
-
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
251
|
-
`)},c1t=0,Lu=[];function u1t(t){var e=x.useRef([]),r=x.useRef([0,0]),n=x.useRef(),o=x.useState(c1t++)[0],i=x.useState(Uie)[0],s=x.useRef(t);x.useEffect(function(){s.current=t},[t]),x.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=kxt([t.lockRef.current],(t.shards||[]).map(L7),!0).filter(Boolean);return m.forEach(function(S){return S.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var a=x.useCallback(function(m,S){if("touches"in m&&m.touches.length===2)return!s.current.allowPinchZoom;var y=Ny(m),v=r.current,b="deltaX"in m?m.deltaX:v[0]-y[0],$="deltaY"in m?m.deltaY:v[1]-y[1],P,E=m.target,T=Math.abs(b)>Math.abs($)?"h":"v";if("touches"in m&&T==="h"&&E.type==="range")return!1;var I=j7(T,E);if(!I)return!0;if(I?P=T:(P=T==="v"?"h":"v",I=j7(T,E)),!I)return!1;if(!n.current&&"changedTouches"in m&&(b||$)&&(n.current=P),!P)return!0;var _=n.current||P;return s1t(_,S,m,_==="h"?b:$,!0)},[]),l=x.useCallback(function(m){var S=m;if(!(!Lu.length||Lu[Lu.length-1]!==i)){var y="deltaY"in S?D7(S):Ny(S),v=e.current.filter(function(P){return P.name===S.type&&(P.target===S.target||S.target===P.shadowParent)&&a1t(P.delta,y)})[0];if(v&&v.should){S.cancelable&&S.preventDefault();return}if(!v){var b=(s.current.shards||[]).map(L7).filter(Boolean).filter(function(P){return P.contains(S.target)}),$=b.length>0?a(S,b[0]):!s.current.noIsolation;$&&S.cancelable&&S.preventDefault()}}},[]),c=x.useCallback(function(m,S,y,v){var b={name:m,delta:S,target:y,should:v,shadowParent:d1t(y)};e.current.push(b),setTimeout(function(){e.current=e.current.filter(function($){return $!==b})},1)},[]),u=x.useCallback(function(m){r.current=Ny(m),n.current=void 0},[]),d=x.useCallback(function(m){c(m.type,D7(m),m.target,a(m,t.lockRef.current))},[]),f=x.useCallback(function(m){c(m.type,Ny(m),m.target,a(m,t.lockRef.current))},[]);x.useEffect(function(){return Lu.push(i),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Du),document.addEventListener("touchmove",l,Du),document.addEventListener("touchstart",u,Du),function(){Lu=Lu.filter(function(m){return m!==i}),document.removeEventListener("wheel",l,Du),document.removeEventListener("touchmove",l,Du),document.removeEventListener("touchstart",u,Du)}},[]);var p=t.removeScrollBar,g=t.inert;return x.createElement(x.Fragment,null,g?x.createElement(i,{styles:l1t(o)}):null,p?x.createElement(Jxt,{gapMode:t.gapMode}):null)}function d1t(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const h1t=Bxt(Bie,u1t);var Sb=x.forwardRef(function(t,e){return x.createElement(yb,Yi({},t,{ref:e,sideCar:h1t}))});Sb.classNames=yb.classNames;var f1t=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Nu=new WeakMap,Fy=new WeakMap,By={},XE=0,Kie=function(t){return t&&(t.host||Kie(t.parentNode))},p1t=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=Kie(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},g1t=function(t,e,r,n){var o=p1t(e,Array.isArray(t)?t:[t]);By[r]||(By[r]=new WeakMap);var i=By[r],s=[],a=new Set,l=new Set(o),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(n),g=p!==null&&p!=="false",m=(Nu.get(f)||0)+1,S=(i.get(f)||0)+1;Nu.set(f,m),i.set(f,S),s.push(f),m===1&&g&&Fy.set(f,!0),S===1&&f.setAttribute(r,"true"),g||f.setAttribute(n,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return u(e),a.clear(),XE++,function(){s.forEach(function(d){var f=Nu.get(d)-1,p=i.get(d)-1;Nu.set(d,f),i.set(d,p),f||(Fy.has(d)||d.removeAttribute(n),Fy.delete(d)),p||d.removeAttribute(r)}),XE--,XE||(Nu=new WeakMap,Nu=new WeakMap,Fy=new WeakMap,By={})}},oj=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),o=f1t(t);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live]"))),g1t(n,o,r,"aria-hidden")):function(){return null}},ij="Dialog",[Gie,EOt]=$s(ij),[m1t,Ri]=Gie(ij),Vie=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!0}=t,a=x.useRef(null),l=x.useRef(null),[c=!1,u]=Gl({prop:n,defaultProp:o,onChange:i});return h.jsx(m1t,{scope:e,triggerRef:a,contentRef:l,contentId:Qs(),titleId:Qs(),descriptionId:Qs(),open:c,onOpenChange:u,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),modal:s,children:r})};Vie.displayName=ij;var Yie="DialogTrigger",v1t=x.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Ri(Yie,r),i=yt(e,o.triggerRef);return h.jsx(Ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":lj(o.open),...n,ref:i,onClick:ue(t.onClick,o.onOpenToggle)})});v1t.displayName=Yie;var sj="DialogPortal",[y1t,Xie]=Gie(sj,{forceMount:void 0}),qie=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:o}=t,i=Ri(sj,e);return h.jsx(y1t,{scope:e,forceMount:r,children:x.Children.map(n,s=>h.jsx(Mi,{present:r||i.open,children:h.jsx(Lm,{asChild:!0,container:o,children:s})}))})};qie.displayName=sj;var Y0="DialogOverlay",Zie=x.forwardRef((t,e)=>{const r=Xie(Y0,t.__scopeDialog),{forceMount:n=r.forceMount,...o}=t,i=Ri(Y0,t.__scopeDialog);return i.modal?h.jsx(Mi,{present:n||i.open,children:h.jsx(S1t,{...o,ref:e})}):null});Zie.displayName=Y0;var S1t=x.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Ri(Y0,r);return h.jsx(Sb,{as:Kc,allowPinchZoom:!0,shards:[o.contentRef],children:h.jsx(Ye.div,{"data-state":lj(o.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),Gc="DialogContent",Qie=x.forwardRef((t,e)=>{const r=Xie(Gc,t.__scopeDialog),{forceMount:n=r.forceMount,...o}=t,i=Ri(Gc,t.__scopeDialog);return h.jsx(Mi,{present:n||i.open,children:i.modal?h.jsx(w1t,{...o,ref:e}):h.jsx(x1t,{...o,ref:e})})});Qie.displayName=Gc;var w1t=x.forwardRef((t,e)=>{const r=Ri(Gc,t.__scopeDialog),n=x.useRef(null),o=yt(e,r.contentRef,n);return x.useEffect(()=>{const i=n.current;if(i)return oj(i)},[]),h.jsx(Jie,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ue(t.onCloseAutoFocus,i=>{var s;i.preventDefault(),(s=r.triggerRef.current)==null||s.focus()}),onPointerDownOutside:ue(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:ue(t.onFocusOutside,i=>i.preventDefault())})}),x1t=x.forwardRef((t,e)=>{const r=Ri(Gc,t.__scopeDialog),n=x.useRef(!1),o=x.useRef(!1);return h.jsx(Jie,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=t.onCloseAutoFocus)==null||s.call(t,i),i.defaultPrevented||(n.current||(a=r.triggerRef.current)==null||a.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=t.onInteractOutside)==null||l.call(t,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=r.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Jie=x.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=t,a=Ri(Gc,r),l=x.useRef(null),c=yt(e,l);return nj(),h.jsxs(h.Fragment,{children:[h.jsx(vb,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:h.jsx(Dm,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":lj(a.open),...s,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx($1t,{titleId:a.titleId}),h.jsx(P1t,{contentRef:l,descriptionId:a.descriptionId})]})]})}),aj="DialogTitle",ese=x.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Ri(aj,r);return h.jsx(Ye.h2,{id:o.titleId,...n,ref:e})});ese.displayName=aj;var tse="DialogDescription",b1t=x.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Ri(tse,r);return h.jsx(Ye.p,{id:o.descriptionId,...n,ref:e})});b1t.displayName=tse;var rse="DialogClose",nse=x.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Ri(rse,r);return h.jsx(Ye.button,{type:"button",...n,ref:e,onClick:ue(t.onClick,()=>o.onOpenChange(!1))})});nse.displayName=rse;function lj(t){return t?"open":"closed"}var ose="DialogTitleWarning",[COt,ise]=txt(ose,{contentName:Gc,titleName:aj,docsSlug:"dialog"}),$1t=({titleId:t})=>{const e=ise(ose),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
252
|
-
|
|
253
|
-
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
254
|
-
|
|
255
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return x.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},I1t="DialogDescriptionWarning",P1t=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ise(I1t).contentName}}.`;return x.useEffect(()=>{var i;const o=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},E1t=Vie,C1t=qie,_1t=Zie,T1t=Qie;const ds=x.memo(function({small:e,invertIcon:r,icon:n,color:o,className:i,...s}){const a=tj(),l=a.icons[n]??a.icons["question-mark-circle"],c=x.useRef(null);return x.useLayoutEffect(()=>{l||console.error(`Icon not found: ${n}. Add it to the assetUrls.icons object.`),c!=null&&c.current&&(c.current.style.webkitMask=`url(${l}) center 100% / 100% no-repeat`)},[c,l,n]),n==="none"?h.jsx("div",{className:pe("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":e},i)}):h.jsx("div",{...s,ref:c,className:pe("tlui-icon",{"tlui-icon__small":e},i),style:{color:o,mask:`url(${l}) center 100% / 100% no-repeat`,transform:r?"scale(-1, 1)":void 0}})});function Le({icon:t,small:e,invertIcon:r}){return h.jsx(ds,{className:"tlui-button__icon",icon:t,small:e,invertIcon:r})}function wb({className:t,children:e}){return h.jsx("div",{className:pe("tlui-dialog__header",t),children:e})}function xb({className:t,children:e}){return h.jsx(ese,{dir:"ltr",className:pe("tlui-dialog__header__title",t),children:e})}function bb(){return h.jsx("div",{className:"tlui-dialog__header__close",children:h.jsx(nse,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:h.jsx(me,{type:"icon","aria-label":"Close",onTouchEnd:t=>t.target.click(),children:h.jsx(Le,{small:!0,icon:"cross-2"})})})})}function Cg({className:t,children:e,style:r}){return h.jsx("div",{className:pe("tlui-dialog__body",t),style:r,children:e})}function cj({className:t,children:e}){return h.jsx("div",{className:pe("tlui-dialog__footer",t),children:e})}const $b=x.forwardRef(function({className:e,label:r,icon:n,iconLeft:o,autoSelect:i=!1,autoFocus:s=!1,defaultValue:a,placeholder:l,onComplete:c,onValueChange:u,onCancel:d,onFocus:f,onBlur:p,shouldManuallyMaintainScrollPositionWhenFocused:g=!1,children:m,value:S},y){const v=F(),b=x.useRef(null);x.useImperativeHandle(y,()=>b.current);const $=Fe(),P=x.useRef(a??""),E=x.useRef(a??""),[T,I]=x.useState(!1),_=x.useCallback(j=>{I(!0);const M=j.currentTarget;E.current=M.value,v.timers.requestAnimationFrame(()=>{i&&M.select()}),f==null||f()},[i,f,v.timers]),k=x.useCallback(j=>{const M=j.currentTarget.value;E.current=M,u==null||u(M)},[u]),D=x.useCallback(j=>{switch(j.key){case"Enter":{j.currentTarget.blur(),mr(j),c==null||c(j.currentTarget.value);break}case"Escape":{j.currentTarget.value=P.current,d==null||d(j.currentTarget.value),j.currentTarget.blur(),mr(j);break}}},[c,d]),R=x.useCallback(j=>{I(!1);const M=j.currentTarget.value;p==null||p(M)},[p]);return x.useEffect(()=>{if(!v.environment.isIos)return;const j=window.visualViewport;if(T&&g&&j){const M=()=>{var U;(U=b.current)==null||U.scrollIntoView({block:"center"})};return j.addEventListener("resize",M),j.addEventListener("scroll",M),v.timers.requestAnimationFrame(()=>{var U;(U=b.current)==null||U.scrollIntoView({block:"center"})}),()=>{j.removeEventListener("resize",M),j.removeEventListener("scroll",M)}}},[v,T,g]),h.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[m,r&&h.jsx("label",{children:$(r)}),o&&h.jsx(ds,{icon:o,className:"tlui-icon-left",small:!0}),h.jsx("input",{ref:b,className:pe("tlui-input",e),type:"text",defaultValue:a,onKeyUp:D,onChange:k,onFocus:_,onBlur:R,autoFocus:s,placeholder:l,value:S}),n&&h.jsx(ds,{icon:n,small:!!r})]})});function N7(t){return go.isValid(t)?{isValid:!0,hasProtocol:!0}:go.isValid("https://"+t)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const A1t=yr(function({onClose:e}){const n=F().getOnlySelectedShape();return n&&"url"in n.props&&typeof n.props.url=="string"?h.jsx(k1t,{onClose:e,selectedShape:n}):null}),k1t=yr(function({onClose:e,selectedShape:r}){const n=F(),o=Fe(),i=x.useRef(null);x.useEffect(()=>{n.timers.requestAnimationFrame(()=>{var g;return(g=i.current)==null?void 0:g.focus()})},[n]);const s=x.useRef(r.props.url),[a,l]=x.useState(()=>{const g=N7(r.props.url),m=g.isValid===!0?g.hasProtocol?r.props.url:"https://"+r.props.url:"https://";return{actual:m,safe:m,valid:!0}}),c=x.useCallback(g=>{const m=g.replace(/https?:\/\/(https?:\/\/)/,(v,b)=>b),S=N7(m),y=S.isValid===!0?S.hasProtocol?m:"https://"+m:"https://";l({actual:m,safe:y,valid:S.isValid})},[]),u=x.useCallback(()=>{const g=n.getOnlySelectedShape();g&&(n.updateShapes([{id:g.id,type:g.type,props:{url:""}}]),e())},[n,e]),d=x.useCallback(()=>{const g=n.getOnlySelectedShape();g&&(g&&"url"in g.props&&g.props.url!==a.safe&&n.updateShapes([{id:g.id,type:g.type,props:{url:a.safe}}]),e())},[n,e,a]),f=x.useCallback(()=>{e()},[e]);if(!r)return e(),null;const p=s.current&&!a.valid;return h.jsxs(h.Fragment,{children:[h.jsxs(wb,{children:[h.jsx(xb,{children:o("edit-link-dialog.title")}),h.jsx(bb,{})]}),h.jsx(Cg,{children:h.jsxs("div",{className:"tlui-edit-link-dialog",children:[h.jsx($b,{ref:i,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,value:a.actual,onValueChange:c,onComplete:d,onCancel:f}),h.jsx("div",{children:a.valid?o("edit-link-dialog.detail"):o("edit-link-dialog.invalid-url")})]})}),h.jsxs(cj,{className:"tlui-dialog__footer__actions",children:[h.jsx(me,{type:"normal",onClick:f,onTouchEnd:f,children:h.jsx(qt,{children:o("edit-link-dialog.cancel")})}),p?h.jsx(me,{type:"danger",onTouchEnd:u,onClick:u,children:h.jsx(qt,{children:o("edit-link-dialog.clear")})}):h.jsx(me,{type:"primary",disabled:!a.valid,onTouchEnd:d,onClick:d,children:h.jsx(qt,{children:o("edit-link-dialog.save")})})]})]})});var O1t={};const F7=/(^\/r\/[^/]+\/?$)/,uj=[{type:"tldraw",title:"tldraw",hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,overridePermissions:{"allow-top-navigation":!0},toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(F7))return t},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(F7))return t}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{if(t.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!t.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${t}`},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/?$/)){const r=e.searchParams.get("url");if(r)return r}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:t=>{if(t.includes("/maps/")){const e=t.match(/@(.*),(.*),(.*)z/);let r;if(e){const[,n,o,i]=e;r=`https://${new URL(t).host.replace("www.","")}/maps/embed/v1/view?key=${O1t.NEXT_PUBLIC_GC_API_KEY}¢er=${n},${o}&zoom=${i}`}else r="";return r}},fromEmbedUrl:t=>{const e=$e(t);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const n=e.searchParams.get("zoom"),[o,i]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${o},${i},${n}z`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/v\/(.+)\/?/);if(r)return`https://www.val.town/embed/${r[1]}`},fromEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(r)return`https://www.val.town/v/${r[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/s\/([^/]+)\/?/);if(r)return`https://codesandbox.io/embed/${r[1]}`},fromEmbedUrl:t=>{const e=$e(t),r=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(r)return`https://codesandbox.io/s/${r[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:t=>{const e=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,r=t.match(e);if(r){const[n,o,i]=r;return`https://codepen.io/${o}/embed/${i}`}},fromEmbedUrl:t=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,r=t.match(e);if(r){const[n,o,i]=r;return`https://codepen.io/${o}/pen/${i}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:t=>{const e=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,r=t.match(e);if(r){const[n,o]=r;return`https://scratch.mit.edu/projects/embed/${o}`}},fromEmbedUrl:t=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,r=t.match(e);if(r){const[n,o]=r;return`https://scratch.mit.edu/projects/${o}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,overridePermissions:{"allow-presentation":!0,"allow-popups-to-escape-sandbox":!0},isAspectRatioLocked:!0,toEmbedUrl:t=>{const e=$e(t);if(!e)return;const r=e.hostname.replace(/^www./,"");if(r==="youtu.be")return`https://www.youtube.com/embed/${e.pathname.split("/").filter(Boolean)[0]}`;if((r==="youtube.com"||r==="m.youtube.com")&&e.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${e.searchParams.get("v")}`},fromEmbedUrl:t=>{const e=$e(t);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const n=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(n)return`https://www.youtube.com/watch?v=${n[1]}`}}},{type:"google_calendar",title:"Google Calendar",hostnames:["calendar.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,instructionLink:"https://support.google.com/calendar/answer/41207?hl=en",overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:t=>{const e=$e(t),r=e==null?void 0:e.searchParams.get("cid");if(e!=null&&e.pathname.match(/\/calendar\/u\/0/)&&r){e.pathname="/calendar/embed";const n=Array.from(e.searchParams.keys());for(const o of n)e.searchParams.delete(o);return e.searchParams.set("src",r),e.href}},fromEmbedUrl:t=>{const e=$e(t),r=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&r){e.pathname="/calendar/u/0";const n=Array.from(e.searchParams.keys());for(const o of n)e.searchParams.delete(o);return e.searchParams.set("cid",r),e.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:t=>{const e=$e(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/pub\/?$/))){e.pathname=e.pathname.replace(/\/pub$/,"/embed");const r=Array.from(e.searchParams.keys());for(const n of r)e.searchParams.delete(n);return e.href}},fromEmbedUrl:t=>{const e=$e(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const r=Array.from(e.searchParams.keys());for(const n of r)e.searchParams.delete(n);return e.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return t.split("/").pop()?t:void 0},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return t.split("/").pop()?t:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${t}?embed=true`},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/map\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/map\//))return e.pathname=e.pathname.replace(/^\/embed/,""),e.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/(artist|album)\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/(artist|album)\//))return e.origin+e.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="vimeo.com"&&e.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+e.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="player.vimeo.com"){const r=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(r)return"https://vimeo.com/"+r[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.hash.match(/#room=/))return t},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hash.match(/#room=/))return t}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}/embed${e.pathname}?cell=*`;if(e&&e.pathname.match(/^\/d\/([^/]+)\/?$/)){const r=e.pathname.replace(/^\/d/,"");return`${e.origin}/embed${r}?cell=*`}},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","")}#cell-*`;if(e&&e.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","/d")}#cell-*`}},{type:"desmos",title:"Desmos",hostnames:["desmos.com"],width:700,height:450,doesResize:!0,toEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search===""&&e.hash==="")return`${t}?embed`},fromEmbedUrl:t=>{const e=$e(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return t.replace("?embed","")}}],M1t={"allow-downloads-without-user-activation":!1,"allow-downloads":!1,"allow-modals":!1,"allow-orientation-lock":!1,"allow-pointer-lock":!1,"allow-popups":!0,"allow-popups-to-escape-sandbox":!1,"allow-presentation":!1,"allow-storage-access-by-user-activation":!1,"allow-top-navigation":!1,"allow-top-navigation-by-user-activation":!1,"allow-scripts":!0,"allow-same-origin":!0,"allow-forms":!0},R1t=uj.map(t=>t.type);function j1t(t){return R1t.includes(t)}function D1t(t){return"icon"in t}function sse(){return F().getShapeUtil("embed")}function dj(){const t=sse();return e=>t?t.getEmbedDefinition(e):void 0}function L1t(){const t=sse();return t?t.getEmbedDefinitions():[]}const ase=yr(function({onClose:e}){const r=F(),n=Fe(),o=tj(),[i,s]=x.useState(null),[a,l]=x.useState(""),[c,u]=x.useState(null),[d,f]=x.useState(!1),p=x.useRef(-1),g=L1t(),m=dj();return h.jsxs(h.Fragment,{children:[h.jsxs(wb,{children:[h.jsx(xb,{children:i?`${n("embed-dialog.title")} — ${i.title}`:n("embed-dialog.title")}),h.jsx(bb,{})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs(Cg,{className:"tlui-embed-dialog__enter",children:[h.jsx($b,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"http://example.com",autoFocus:!0,onValueChange:S=>{l(S);const y=m(a);u(y&&y.definition.type===i.type?y:null),f(!1),clearTimeout(p.current),p.current=r.timers.setTimeout(()=>f(!y),320)}}),a===""?h.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[h.jsx("span",{children:n("embed-dialog.instruction")})," ",i.instructionLink&&h.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:i.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",h.jsx(ds,{icon:"external-link",small:!0})]})]}):h.jsx("div",{className:"tlui-embed-dialog__warning",children:d?n("embed-dialog.invalid-url"):" "})]}),h.jsxs(cj,{className:"tlui-dialog__footer__actions",children:[h.jsx(me,{type:"normal",onClick:()=>{s(null),u(null),l("")},children:h.jsx(qt,{children:n("embed-dialog.back")})}),h.jsx("div",{className:"tlui-embed__spacer"}),h.jsx(me,{type:"normal",onClick:e,children:h.jsx(qt,{children:n("embed-dialog.cancel")})}),h.jsx(me,{type:"primary",disabled:!c,onClick:()=>{c&&(r.putExternalContent({type:"embed",url:a,point:r.getViewportPageBounds().center,embed:c.definition}),e())},children:h.jsx(qt,{children:n("embed-dialog.create")})})]})]}):h.jsx(h.Fragment,{children:h.jsx(Cg,{className:"tlui-embed-dialog__list",children:g.map(S=>{const y=j1t(S.type)?o.embedIcons[S.type]:D1t(S)?S.icon:void 0;return h.jsxs(me,{type:"menu",onClick:()=>s(S),children:[h.jsx(qt,{children:S.title}),y&&h.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${y})`}})]},S.type)})})})]})});var hj={exports:{}};hj.exports;(function(t){var e=function(){var r=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function s(l,c){if(!i[l]){i[l]={};for(var u=0;u<l.length;u++)i[l][l.charAt(u)]=u}return i[l][c]}var a={compressToBase64:function(l){if(l==null)return"";var c=a._compress(l,6,function(u){return n.charAt(u)});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"="}},decompressFromBase64:function(l){return l==null?"":l==""?null:a._decompress(l.length,32,function(c){return s(n,l.charAt(c))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(c){return r(c+32)})+" "},decompressFromUTF16:function(l){return l==null?"":l==""?null:a._decompress(l.length,16384,function(c){return l.charCodeAt(c)-32})},compressToUint8Array:function(l){for(var c=a.compress(l),u=new Uint8Array(c.length*2),d=0,f=c.length;d<f;d++){var p=c.charCodeAt(d);u[d*2]=p>>>8,u[d*2+1]=p%256}return u},decompressFromUint8Array:function(l){if(l==null)return a.decompress(l);for(var c=new Array(l.length/2),u=0,d=c.length;u<d;u++)c[u]=l[u*2]*256+l[u*2+1];var f=[];return c.forEach(function(p){f.push(r(p))}),a.decompress(f.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(c){return o.charAt(c)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(c){return s(o,l.charAt(c))}))},compress:function(l){return a._compress(l,16,function(c){return r(c)})},_compress:function(l,c,u){if(l==null)return"";var d,f,p={},g={},m="",S="",y="",v=2,b=3,$=2,P=[],E=0,T=0,I;for(I=0;I<l.length;I+=1)if(m=l.charAt(I),Object.prototype.hasOwnProperty.call(p,m)||(p[m]=b++,g[m]=!0),S=y+m,Object.prototype.hasOwnProperty.call(p,S))y=S;else{if(Object.prototype.hasOwnProperty.call(g,y)){if(y.charCodeAt(0)<256){for(d=0;d<$;d++)E=E<<1,T==c-1?(T=0,P.push(u(E)),E=0):T++;for(f=y.charCodeAt(0),d=0;d<8;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1}else{for(f=1,d=0;d<$;d++)E=E<<1|f,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=0;for(f=y.charCodeAt(0),d=0;d<16;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1}v--,v==0&&(v=Math.pow(2,$),$++),delete g[y]}else for(f=p[y],d=0;d<$;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1;v--,v==0&&(v=Math.pow(2,$),$++),p[S]=b++,y=String(m)}if(y!==""){if(Object.prototype.hasOwnProperty.call(g,y)){if(y.charCodeAt(0)<256){for(d=0;d<$;d++)E=E<<1,T==c-1?(T=0,P.push(u(E)),E=0):T++;for(f=y.charCodeAt(0),d=0;d<8;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1}else{for(f=1,d=0;d<$;d++)E=E<<1|f,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=0;for(f=y.charCodeAt(0),d=0;d<16;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1}v--,v==0&&(v=Math.pow(2,$),$++),delete g[y]}else for(f=p[y],d=0;d<$;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1;v--,v==0&&(v=Math.pow(2,$),$++)}for(f=2,d=0;d<$;d++)E=E<<1|f&1,T==c-1?(T=0,P.push(u(E)),E=0):T++,f=f>>1;for(;;)if(E=E<<1,T==c-1){P.push(u(E));break}else T++;return P.join("")},decompress:function(l){return l==null?"":l==""?null:a._decompress(l.length,32768,function(c){return l.charCodeAt(c)})},_decompress:function(l,c,u){var d=[],f=4,p=4,g=3,m="",S=[],y,v,b,$,P,E,T,I={val:u(0),position:c,index:1};for(y=0;y<3;y+=1)d[y]=y;for(b=0,P=Math.pow(2,2),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;switch(b){case 0:for(b=0,P=Math.pow(2,8),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;T=r(b);break;case 1:for(b=0,P=Math.pow(2,16),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;T=r(b);break;case 2:return""}for(d[3]=T,v=T,S.push(T);;){if(I.index>l)return"";for(b=0,P=Math.pow(2,g),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;switch(T=b){case 0:for(b=0,P=Math.pow(2,8),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;d[p++]=r(b),T=p-1,f--;break;case 1:for(b=0,P=Math.pow(2,16),E=1;E!=P;)$=I.val&I.position,I.position>>=1,I.position==0&&(I.position=c,I.val=u(I.index++)),b|=($>0?1:0)*E,E<<=1;d[p++]=r(b),T=p-1,f--;break;case 2:return S.join("")}if(f==0&&(f=Math.pow(2,g),g++),d[T])m=d[T];else if(T===p)m=v+v.charAt(0);else return null;S.push(m),d[p++]=v+m.charAt(0),f--,v=m,f==0&&(f=Math.pow(2,g),g++)}}};return a}();t!=null?t.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})})(hj);var N1t=hj.exports;const lse=_l(N1t),cse=()=>{},use=x.createContext(null);function F1t({onEvent:t,children:e}){return h.jsx(use.Provider,{value:t??cse,children:e})}function Br(){return x.useContext(use)??cse}async function B1t(t,e,r){var y,v,b;const{elements:n,files:o}=e,i={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:t.store.schema.serialize()},s=new Map,a=new Map,l=t.getCurrentPageId(),c=new Map,u=[],d=new Set;n.forEach($=>{if(c.set($.id,ot()),$.boundElements!==null)for(const P of $.boundElements)P.type==="text"&&d.add(P.id)});let f=kK;for(const $ of n){if(d.has($.id))continue;const P=c.get($.id),E={id:P,typeName:"shape",parentId:l,index:f,x:$.x,y:$.y,rotation:0,isLocked:$.locked,opacity:U1t($.opacity),meta:{}};switch($.angle!==0&&a.set(P,$.angle),$.groupIds&&$.groupIds.length>0?s.has($.groupIds[0])?(y=s.get($.groupIds[0]))==null||y.push(P):s.set($.groupIds[0],[P]):u.push(P),$.type){case"rectangle":case"ellipse":case"diamond":{let T="",I="middle";if($.boundElements!==null){for(const k of $.boundElements)if(k.type==="text"){const D=n.find(R=>R.id===k.id);D&&(T=D.text,I=V1t[D.textAlign])}}const _=$.backgroundColor==="transparent"?$.strokeColor:$.backgroundColor;i.shapes.push({...E,type:"geo",props:{geo:$.type,url:$.link??"",w:$.width,h:$.height,size:Uy[$.strokeWidth]??"draw",color:Bf[_]??"black",text:T,align:I,dash:zy($),fill:q1t($)}});break}case"freedraw":{i.shapes.push({...E,type:"draw",props:{dash:zy($),size:Uy[$.strokeWidth],color:Bf[$.strokeColor]??"black",segments:[{type:"free",points:$.points.map(([T,I,_=.5])=>({x:T,y:I,z:_}))}]}});break}case"line":{if($.points.slice().length<2)break;const I=pg($.points.length);i.shapes.push({...E,type:"line",props:{dash:zy($),size:Uy[$.strokeWidth],color:Bf[$.strokeColor]??"black",spline:$.roundness?"cubic":"line",points:{...Object.fromEntries($.points.map(([_,k],D)=>{const R=I[D];return[R,{id:R,index:R,x:_,y:k}]}))}}});break}case"arrow":{let T="";if($.boundElements!==null){for(const R of $.boundElements)if(R.type==="text"){const j=n.find(M=>M.id===R.id);j&&(T=j.text)}}const I=$.points[0],_=$.points[$.points.length-1],k=c.get((v=$.startBinding)==null?void 0:v.elementId),D=c.get((b=$.endBinding)==null?void 0:b.elementId);i.shapes.push({...E,type:"arrow",props:{text:T,bend:X1t($,I,_),dash:zy($),size:Uy[$.strokeWidth]??"m",color:Bf[$.strokeColor]??"black",start:{x:I[0],y:I[1]},end:{x:_[0],y:_[1]},arrowheadEnd:B7[$.endArrowhead]??"none",arrowheadStart:B7[$.startArrowhead]??"none"}}),k&&i.bindings.push({id:Pc(),typeName:"binding",type:"arrow",fromId:P,toId:k,props:{terminal:"start",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),D&&i.bindings.push({id:Pc(),typeName:"binding",type:"arrow",fromId:P,toId:D,props:{terminal:"end",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{const{size:T,scale:I}=H1t($.fontSize);i.shapes.push({...E,type:"text",props:{size:T,scale:I,font:W1t[$.fontFamily]??"draw",color:Bf[$.strokeColor]??"black",text:$.text,textAlign:Y1t[$.textAlign]}});break}case"image":{const T=o[$.fileId];if(!T)break;const I=Wa.createId();i.assets.push({id:I,typeName:"asset",type:"image",props:{w:$.width,h:$.height,fileSize:T.size,name:$.id??"Untitled",isAnimated:!1,mimeType:T.mimeType,src:T.dataURL},meta:{}}),i.shapes.push({...E,type:"image",props:{w:$.width,h:$.height,assetId:I}})}}f=Xi(f)}const p=r??(t.inputs.shiftKey?t.inputs.currentPagePoint:void 0);t.markHistoryStoppingPoint("paste"),t.putContentOntoCurrentPage(i,{point:p,select:!1,preserveIds:!0});for(const $ of s.values())if($.length>1){t.groupShapes($);const P=t.getShape($[0]);P!=null&&P.parentId&&Tn(P.parentId)&&u.push(P.parentId)}for(const[$,P]of a)t.select($),t.rotateShapesBy([$],P);const g=Ae(u.map($=>t.getShape($))),m=ee.Common(g.map($=>t.getShapePageBounds($))),S=t.getViewportPageBounds().center;t.updateShapes(g.map($=>{const P={x:($.x??0)-(m.x+m.w/2),y:($.y??0)-(m.y+m.h/2)};return{id:$.id,type:$.type,x:S.x+P.x,y:S.y+P.y}})),t.setSelectedShapes(u)}const U1t=t=>{const e=t/100;return e<.2?.1:e<.4?.25:e<.6?.5:e<.8?.75:1},Uy={1:"s",2:"m",3:"l",4:"xl"},z1t={16:"s",20:"m",28:"l",36:"xl"};function H1t(t){const e=z1t[t];return e?{size:e,scale:1}:t<16?{size:"s",scale:t/16}:t>36?{size:"xl",scale:t/36}:{size:"m",scale:1}}const W1t={1:"draw",2:"sans",3:"mono"},Bf={"#ffffff":"grey","#000000":"black","#343a40":"black","#495057":"grey","#c92a2a":"red","#a61e4d":"light-red","#862e9c":"violet","#5f3dc4":"light-violet","#364fc7":"blue","#1864ab":"light-blue","#0b7285":"light-green","#087f5b":"light-green","#2b8a3e":"green","#5c940d":"light-green","#e67700":"yellow","#d9480f":"orange","#ced4da":"grey","#868e96":"grey","#fa5252":"light-red","#e64980":"red","#be4bdb":"light-violet","#7950f2":"violet","#4c6ef5":"blue","#228be6":"light-blue","#15aabf":"light-green","#12b886":"green","#40c057":"green","#82c91e":"light-green","#fab005":"yellow","#fd7e14":"orange","#212529":"grey"},K1t={solid:"draw",dashed:"dashed",dotted:"dotted"},G1t={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},V1t={left:"start",center:"middle",right:"end"},Y1t={left:"start",center:"middle",right:"end"},B7={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function X1t(t,e,r){let n=0;if(t.points.length>2){const o=new w(e[0],e[1]),i=new w(r[0],r[1]),s=new w(t.points[1][0],t.points[1][1]),a=w.Sub(i,o),l=w.Per(a),c=w.Med(i,o),u=w.Sub(c,l),d=w.Add(c,l),f=w.NearestPointOnLineSegment(u,d,s,!1);n=w.Dist(f,c),w.Clockwise(f,i,c)&&(n*=-1)}return n}const zy=t=>{let e=K1t[t.strokeStyle]??"draw";return e==="draw"&&t.roughness===0&&(e="solid"),e},q1t=t=>t.backgroundColor==="transparent"?"none":G1t[t.fillStyle]??"solid";async function Z1t(t,e,r,n){const i=(await Promise.all(e.map(async s=>await(await xi(s)).blob()))).map(s=>new File([s],"tldrawFile",{type:s.type}));t.markHistoryStoppingPoint("paste"),await t.putExternalContent({type:"files",files:i,point:r,ignoreParent:!1,sources:n}),e.forEach(s=>URL.revokeObjectURL(s))}function Q1t(t,e,r){const n=t.getSelectionPageBounds();t.markHistoryStoppingPoint("paste"),t.putContentOntoCurrentPage(e,{point:r,select:!0});const o=t.getSelectionPageBounds();n&&o&&(n!=null&&n.collides(o))&&(t.updateInstanceState({isChangingStyle:!0}),t.timers.setTimeout(()=>{t.updateInstanceState({isChangingStyle:!1})},150))}async function H2(t,e,r,n){return t.markHistoryStoppingPoint("paste"),await t.putExternalContent({type:"url",point:r,url:e,sources:n})}function J1t(t){const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=t.trim(),e.body.textContent||e.body.innerText||""}const ebt=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},tbt=t=>{const e=t.split(/[\n\s]/);for(const r of e)try{const n=new URL(r);if(!(n.protocol==="http:"||n.protocol==="https:"))return}catch{return}return OV(e)},rbt=t=>/^<svg/.test(t),nbt=["input","select","textarea"];function qE(t){const{activeElement:e}=document;return t.getIsMenuOpen()||e&&(e.getAttribute("contenteditable")||nbt.indexOf(e.tagName.toLowerCase())>-1)}const obt=t=>t.types.find(e=>e.match(/^image\//)),ZE=(t,e,r,n)=>{const o=tbt(e);if(o)for(const i of o)H2(t,i,r);else ebt(e)?H2(t,e,r):rbt(e)?(t.markHistoryStoppingPoint("paste"),t.putExternalContent({type:"svg-text",text:e,point:r,sources:n})):(t.markHistoryStoppingPoint("paste"),t.putExternalContent({type:"text",text:e,point:r,sources:n}))},ibt=async(t,e,r)=>{if(t.getEditingShapeId()!==null)return;if(!e)throw Error("No clipboard data");const n=[];for(const o of Object.values(e.items))switch(o.kind){case"file":{n.push({type:"file",source:new Promise(i=>i(o.getAsFile()))});break}case"string":{o.type==="text/html"?n.push({type:"html",source:new Promise(i=>o.getAsString(i))}):o.type==="text/plain"?n.push({type:"text",source:new Promise(i=>o.getAsString(i))}):n.push({type:o.type,source:new Promise(i=>o.getAsString(i))});break}}hse(t,n,r)},dse=async(t,e,r)=>{const n=[];for(const o of e){if(obt(o))for(const i of o.types)i.match(/^image\//)&&n.push({type:"blob",source:o.getType(i)});o.types.includes("text/html")&&n.push({type:"html",source:(async()=>{const i=await o.getType("text/html");return await Ys.blobToText(i)})()}),o.types.includes("text/uri-list")&&n.push({type:"url",source:(async()=>{const i=await o.getType("text/uri-list");return await Ys.blobToText(i)})()}),o.types.includes("text/plain")&&n.push({type:"text",source:(async()=>{const i=await o.getType("text/plain");return await Ys.blobToText(i)})()})}return await hse(t,n,r)};async function hse(t,e,r){const n=e.filter(i=>(i.type==="file"||i.type==="blob")&&i.source!==null);if(n.length){if(n.length>t.options.maxFilesAtOnce)throw Error("Too many files");const s=(await Promise.all(n.map(a=>a.source))).filter(Boolean).map(a=>URL.createObjectURL(a));return await Z1t(t,s,r)}const o=await Promise.all(e.filter(i=>i.type!=="file").map(i=>new Promise(s=>{const a=i;if(a.type==="file"){s({type:"error",data:null,reason:"unexpected file"});return}a.source.then(l=>{var u;const c=(u=l.match(/<div data-tldraw[^>]*>(.*)<\/div>/))==null?void 0:u[1];if(c)try{const d=lse.decompressFromBase64(c);if(d===null){s({type:"error",data:d,reason:"found tldraw data comment but could not parse base64"});return}else{const f=JSON.parse(d);if(f.type!=="application/tldraw"&&s({type:"error",data:f,reason:`found tldraw data comment but JSON was of a different type: ${f.type}`}),typeof f.data=="string"){s({type:"error",data:f,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}s({type:"tldraw",data:f.data});return}}catch{s({type:"error",data:c,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){s({type:"text",data:l,subtype:"html"});return}if(a.type==="url"){s({type:"text",data:l,subtype:"url"});return}try{const d=JSON.parse(l);if(d.type==="excalidraw/clipboard"){s({type:"excalidraw",data:d});return}else{s({type:"text",data:l,subtype:"json"});return}}catch{s({type:"text",data:l,subtype:"text"});return}}s({type:"error",data:l,reason:"unhandled case"})})})));for(const i of o)if(i.type==="tldraw"){Q1t(t,i.data,r);return}for(const i of o)if(i.type==="excalidraw"){B1t(t,i.data,r);return}for(const i of o)if(i.type==="text"&&i.subtype==="html"){const a=new DOMParser().parseFromString(i.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(c=>c.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="A"&&a.firstElementChild.hasAttribute("href")&&a.firstElementChild.getAttribute("href")!==""){const c=a.firstElementChild.getAttribute("href");ZE(t,c,r,o);return}if(!o.some(c=>c.type==="text"&&c.subtype!=="html")&&i.data.trim()){ZE(t,J1t(i.data),r,o);return}}for(const i of o)if(i.type==="text"&&i.subtype==="url"){H2(t,i.data,r,o);return}for(const i of o)if(i.type==="text"&&i.subtype==="text"&&i.data.trim()){ZE(t,i.data,r,o);return}}const X0=async t=>{var n;const e=await t.resolveAssetsInContent(t.getContentFromCurrentPage(t.getSelectedShapeIds()));if(!e){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const r=lse.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:e}));if(!(typeof navigator>"u")){const o=e.shapes.map(i=>t.getShapeUtil(i).getText(i)).filter(Xme);if((n=navigator.clipboard)!=null&&n.write){const i=new Blob([`<div data-tldraw>${r}</div>`],{type:"text/html"});let s=o.join(" ");s===""&&(s=" "),navigator.clipboard.write([new ClipboardItem({"text/html":i,"text/plain":new Blob([s],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<div data-tldraw>${r}</div>`)}};function sbt(){const t=F(),e=Br(),r=x.useCallback(async function(s){t.getSelectedShapeIds().length!==0&&(await X0(t),e("copy",{source:s}))},[t,e]),n=x.useCallback(async function(s){t.getSelectedShapeIds().length!==0&&(await X0(t),t.deleteShapes(t.getSelectedShapeIds()),e("cut",{source:s}))},[t,e]),o=x.useCallback(async function(s,a,l){t.getEditingShapeId()===null&&(Array.isArray(s)&&s[0]instanceof ClipboardItem?(dse(t,s,l),e("paste",{source:"menu"})):navigator.clipboard.read().then(c=>{o(c,a,l)}))},[t,e]);return{copy:r,cut:n,paste:o}}function abt(){const t=F(),e=Br(),r=H("editor.isFocused",()=>t.getInstanceState().isFocused,[t]);x.useEffect(()=>{if(!r)return;const n=async l=>{t.getSelectedShapeIds().length===0||t.getEditingShapeId()!==null||qE(t)||(Ue(l),await X0(t),e("copy",{source:"kbd"}))};async function o(l){t.getSelectedShapeIds().length===0||t.getEditingShapeId()!==null||qE(t)||(Ue(l),await X0(t),t.deleteShapes(t.getSelectedShapeIds()),e("cut",{source:"kbd"}))}let i=!1;const s=l=>{l.button===1&&(i=!0,t.timers.requestAnimationFrame(()=>{i=!1}))},a=l=>{if(i){mr(l);return}if(t.getEditingShapeId()!==null||qE(t))return;let c,u=!1;t.inputs.shiftKey&&(u=!0),t.user.getIsPasteAtCursorMode()&&(u=!u),u&&(c=t.inputs.currentPagePoint),l.clipboardData&&!t.inputs.shiftKey?ibt(t,l.clipboardData,c):navigator.clipboard.read().then(d=>{Array.isArray(d)&&d[0]instanceof ClipboardItem&&dse(t,d,c)}),Ue(l),e("paste",{source:"kbd"})};return document.addEventListener("copy",n),document.addEventListener("cut",o),document.addEventListener("paste",a),document.addEventListener("pointerup",s),()=>{document.removeEventListener("copy",n),document.removeEventListener("cut",o),document.removeEventListener("paste",a),document.removeEventListener("pointerup",s)}},[t,e,r])}/*!
|
|
256
|
-
* canvas-size
|
|
257
|
-
* v1.2.6
|
|
258
|
-
* https://github.com/jhildenbiddle/canvas-size
|
|
259
|
-
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
260
|
-
* MIT license
|
|
261
|
-
*/function lbt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,o,i,s,a=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(u){c=!0,o=u}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function U7(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function Jn(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?U7(Object(r),!0).forEach(function(n){cbt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):U7(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function cbt(t,e,r){return e=ybt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ubt(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function dbt(t,e){if(t==null)return{};var r=ubt(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function z7(t,e){return fbt(t)||lbt(t,e)||fse(t,e)||mbt()}function Hy(t){return hbt(t)||pbt(t)||fse(t)||gbt()}function hbt(t){if(Array.isArray(t))return W2(t)}function fbt(t){if(Array.isArray(t))return t}function pbt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function fse(t,e){if(t){if(typeof t=="string")return W2(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return W2(t,e)}}function W2(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function gbt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
262
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mbt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
263
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vbt(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ybt(t){var e=vbt(t,"string");return typeof e=="symbol"?e:String(e)}function Hp(t){var e=t.sizes.shift(),r=Math.max(Math.ceil(e[0]),1),n=Math.max(Math.ceil(e[1]),1),o=[r-1,n-1,1,1],i=Date.now(),s=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,a,l;s?(a=new OffscreenCanvas(1,1),l=new OffscreenCanvas(r,n)):(a=document.createElement("canvas"),a.width=1,a.height=1,l=document.createElement("canvas"),l.width=r,l.height=n);var c=a.getContext("2d"),u=l.getContext("2d");u&&(u.fillRect.apply(u,o),c.drawImage(l,r-1,n-1,1,1,0,0,1,1));var d=c&&c.getImageData(0,0,1,1).data[3]!==0,f=Date.now()-i;return[a,l].forEach(function(p){p.height=0,p.width=0}),s?(postMessage({width:r,height:n,benchmark:f,isTestPass:d}),!d&&t.sizes.length&&Hp(t)):d?t.onSuccess(r,n,f):(t.onError(r,n,f),t.sizes.length&&Hp(t)),d}var QE={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},Sbt=["onError","onSuccess"],vd={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},Uf={};function JE(t){var e=t.width===t.height,r=t.height===1,n=t.width===1,o=[];if(!t.width||!t.height)t.sizes.forEach(function(u){var d=e||r?u:1,f=e||n?u:1;o.push([d,f])});else for(var i=t.min||vd.min,s=t.step||vd.step,a=Math.max(t.width,t.height);a>=i;){var l=e||r?a:1,c=e||n?a:1;o.push([l,c]),a-=s}return o}function Wy(t){var e=window&&"HTMLCanvasElement"in window,r=window&&"OffscreenCanvas"in window,n=Date.now(),o=t.onError,i=t.onSuccess,s=dbt(t,Sbt),a=null;if(!e)return!1;if(t.useWorker&&r){var l=`
|
|
264
|
-
var canvasTest = `.concat(Hp.toString(),`;
|
|
265
|
-
onmessage = function(e) {
|
|
266
|
-
canvasTest(e.data);
|
|
267
|
-
};
|
|
268
|
-
`),c=new Blob([l],{type:"application/javascript"}),u=URL.createObjectURL(c);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(d){var f=d.data,p=f.width,g=f.height,m=f.benchmark,S=f.isTestPass;S?(Uf[n].onSuccess(p,g,m),delete Uf[n]):Uf[n].onError(p,g,m)}}if(t.usePromise)return new Promise(function(d,f){var p=Jn(Jn({},t),{},{onError:function(y,v,b){var $;if(t.sizes.length===0)$=!0;else{var P=t.sizes.slice(-1),E=z7(P,1),T=z7(E[0],2),I=T[0],_=T[1];$=y===I&&v===_}o(y,v,b),$&&f({width:y,height:v,benchmark:b})},onSuccess:function(y,v,b){i(y,v,b),d({width:y,height:v,benchmark:b})}});if(a){var g=p.onError,m=p.onSuccess;Uf[n]={onError:g,onSuccess:m},a.postMessage(s)}else Hp(p)});if(a)Uf[n]={onError:o,onSuccess:i},a.postMessage(s);else return Hp(t)}var eC={maxArea:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=JE({width:e.max,height:e.max,min:e.min,step:e.step,sizes:Hy(QE.area)}),n=Jn(Jn(Jn({},vd),e),{},{sizes:r});return Wy(n)},maxHeight:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=JE({width:1,height:e.max,min:e.min,step:e.step,sizes:Hy(QE.height)}),n=Jn(Jn(Jn({},vd),e),{},{sizes:r});return Wy(n)},maxWidth:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=JE({width:e.max,height:1,min:e.min,step:e.step,sizes:Hy(QE.width)}),n=Jn(Jn(Jn({},vd),e),{},{sizes:r});return Wy(n)},test:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Jn(Jn({},vd),e);return r.sizes=Hy(r.sizes),r.width&&r.height&&(r.sizes=[[r.width,r.height]]),Wy(r)}};let tC=null;function wbt(){return tC||(tC=xbt()),tC}async function xbt(){const t=await eC.maxWidth({usePromise:!0}),e=await eC.maxHeight({usePromise:!0}),r=await eC.maxArea({usePromise:!0});return{maxWidth:t.width,maxHeight:e.height,maxArea:r.width*r.height}}const H7=8192,bbt=4096*4096;async function $bt(t,e){if(t<=H7&&e<=H7&&t*e<=bbt)return[t,e];const{maxWidth:r,maxHeight:n,maxArea:o}=await wbt(),i=t/e;if(t>r&&(t=r,e=t/i),e>n&&(e=n,t=e*i),t*e>o){const s=Math.sqrt(o/(t*e));t*=s,e*=s}return[t,e]}async function pse(t,e,r){const{type:n,quality:o,scale:i,width:s,height:a}=r;let[l,c]=await $bt(s*i,a*i);l=Math.floor(l),c=Math.floor(c);const u=l/s,d=await Ys.blobToDataUrl(new Blob([e],{type:"image/svg+xml"})),f=await new Promise(g=>{const m=hg();m.crossOrigin="anonymous",m.onload=async()=>{t.environment.isSafari&&await k_(250);const S=document.createElement("canvas"),y=S.getContext("2d");S.width=l,S.height=c,y.imageSmoothingEnabled=!0,y.imageSmoothingQuality="high",y.drawImage(m,0,0,l,c),URL.revokeObjectURL(d),g(S)},m.onerror=()=>{g(null)},m.src=d});if(!f)return null;const p=await new Promise(g=>f.toBlob(m=>{(!m||Xt.throwToBlob.get())&&g(null),g(m)},"image/"+n,o));if(!p)return null;if(n==="png"){const g=new DataView(await p.arrayBuffer());return Vi.setPhysChunk(g,u,{type:"image/"+n})}else return p}async function gse(t,e,r){const n=await t.getSvgString(e!=null&&e.length?e:[...t.getCurrentPageShapeIds()],{scale:1,background:t.getInstanceState().exportBackground,...r});if(!n)throw new Error("Could not construct SVG.");return n}async function K2(t,e,r,n={}){var o;switch(r){case"svg":return(o=await gse(t,e,n))==null?void 0:o.svg;case"json":{const i=await t.resolveAssetsInContent(t.getContentFromCurrentPage(e));return JSON.stringify(i)}default:dr(r)}}async function mse({editor:t,ids:e,format:r,opts:n={}}){switch(r){case"svg":return new Blob([await K2(t,e,"svg",n)],{type:"text/plain"});case"json":return new Blob([await K2(t,e,"json",n)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const o=await gse(t,e,n);if(!o)throw new Error("Could not construct image.");const i=await pse(t,o.svg,{type:r,quality:1,scale:2,width:o.width,height:o.height});if(!i)throw new Error("Could not construct image.");return i}default:dr(r)}}const Ibt={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function Pbt(t,e,r,n={}){return{blobPromise:mse({editor:t,ids:e,format:r,opts:n}),mimeType:Ibt[r]}}function Ebt(t,e,r="svg",n={}){if(!window.navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(window.navigator.clipboard.write){const{blobPromise:o,mimeType:i}=Pbt(t,e,r,n);return o.catch(s=>{console.error(s)}),window.navigator.clipboard.write([new ClipboardItem({[i]:o})]).catch(s=>(console.error(s),o.then(a=>window.navigator.clipboard.write([new ClipboardItem({[i]:a})]))))}switch(r){case"json":case"svg":return Cbt(async()=>K2(t,e,r,n));case"jpeg":case"png":throw new Error("Copy not supported");default:dr(r)}}async function Cbt(t){var e,r;await((r=(e=navigator.clipboard)==null?void 0:e.writeText)==null?void 0:r.call(e,await t()))}function Ib(t){const e=t+"CollectionProvider",[r,n]=$s(e),[o,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:g,children:m}=p,S=ze.useRef(null),y=ze.useRef(new Map).current;return h.jsx(o,{scope:g,itemMap:y,collectionRef:S,children:m})};s.displayName=e;const a=t+"CollectionSlot",l=ze.forwardRef((p,g)=>{const{scope:m,children:S}=p,y=i(a,m),v=yt(g,y.collectionRef);return h.jsx(Kc,{ref:v,children:S})});l.displayName=a;const c=t+"CollectionItemSlot",u="data-radix-collection-item",d=ze.forwardRef((p,g)=>{const{scope:m,children:S,...y}=p,v=ze.useRef(null),b=yt(g,v),$=i(c,m);return ze.useEffect(()=>($.itemMap.set(v,{ref:v,...y}),()=>void $.itemMap.delete(v))),h.jsx(Kc,{[u]:"",ref:b,children:S})});d.displayName=c;function f(p){const g=i(t+"CollectionConsumer",p);return ze.useCallback(()=>{const S=g.collectionRef.current;if(!S)return[];const y=Array.from(S.querySelectorAll(`[${u}]`));return Array.from(g.itemMap.values()).sort(($,P)=>y.indexOf($.ref.current)-y.indexOf(P.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},f,n]}var _bt="VisuallyHidden",fj=x.forwardRef((t,e)=>h.jsx(Ye.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));fj.displayName=_bt;var pj="ToastProvider",[gj,Tbt,Abt]=Ib("Toast"),[vse,_Ot]=$s("Toast",[Abt]),[kbt,Pb]=vse(pj),yse=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:o="right",swipeThreshold:i=50,children:s}=t,[a,l]=x.useState(null),[c,u]=x.useState(0),d=x.useRef(!1),f=x.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${pj}\`. Expected non-empty \`string\`.`),h.jsx(gj.Provider,{scope:e,children:h.jsx(kbt,{scope:e,label:r,duration:n,swipeDirection:o,swipeThreshold:i,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:x.useCallback(()=>u(p=>p+1),[]),onToastRemove:x.useCallback(()=>u(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:s})})};yse.displayName=pj;var Sse="ToastViewport",Obt=["F8"],G2="toast.viewportPause",V2="toast.viewportResume",wse=x.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=Obt,label:o="Notifications ({hotkey})",...i}=t,s=Pb(Sse,r),a=Tbt(r),l=x.useRef(null),c=x.useRef(null),u=x.useRef(null),d=x.useRef(null),f=yt(e,d,s.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=s.toastCount>0;x.useEffect(()=>{const S=y=>{var b;n.every($=>y[$]||y.code===$)&&((b=d.current)==null||b.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[n]),x.useEffect(()=>{const S=l.current,y=d.current;if(g&&S&&y){const v=()=>{if(!s.isClosePausedRef.current){const E=new CustomEvent(G2);y.dispatchEvent(E),s.isClosePausedRef.current=!0}},b=()=>{if(s.isClosePausedRef.current){const E=new CustomEvent(V2);y.dispatchEvent(E),s.isClosePausedRef.current=!1}},$=E=>{!S.contains(E.relatedTarget)&&b()},P=()=>{S.contains(document.activeElement)||b()};return S.addEventListener("focusin",v),S.addEventListener("focusout",$),S.addEventListener("pointermove",v),S.addEventListener("pointerleave",P),window.addEventListener("blur",v),window.addEventListener("focus",b),()=>{S.removeEventListener("focusin",v),S.removeEventListener("focusout",$),S.removeEventListener("pointermove",v),S.removeEventListener("pointerleave",P),window.removeEventListener("blur",v),window.removeEventListener("focus",b)}}},[g,s.isClosePausedRef]);const m=x.useCallback(({tabbingDirection:S})=>{const v=a().map(b=>{const $=b.ref.current,P=[$,...Kbt($)];return S==="forwards"?P:P.reverse()});return(S==="forwards"?v.reverse():v).flat()},[a]);return x.useEffect(()=>{const S=d.current;if(S){const y=v=>{var P,E,T;const b=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!b){const I=document.activeElement,_=v.shiftKey;if(v.target===S&&_){(P=c.current)==null||P.focus();return}const R=m({tabbingDirection:_?"backwards":"forwards"}),j=R.findIndex(M=>M===I);rC(R.slice(j+1))?v.preventDefault():_?(E=c.current)==null||E.focus():(T=u.current)==null||T.focus()}};return S.addEventListener("keydown",y),()=>S.removeEventListener("keydown",y)}},[a,m]),h.jsxs(Sxt,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&h.jsx(Y2,{ref:c,onFocusFromOutsideViewport:()=>{const S=m({tabbingDirection:"forwards"});rC(S)}}),h.jsx(gj.Slot,{scope:r,children:h.jsx(Ye.ol,{tabIndex:-1,...i,ref:f})}),g&&h.jsx(Y2,{ref:u,onFocusFromOutsideViewport:()=>{const S=m({tabbingDirection:"backwards"});rC(S)}})]})});wse.displayName=Sse;var xse="ToastFocusProxy",Y2=x.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...o}=t,i=Pb(xse,r);return h.jsx(fj,{"aria-hidden":!0,tabIndex:0,...o,ref:e,style:{position:"fixed"},onFocus:s=>{var c;const a=s.relatedTarget;!((c=i.viewport)!=null&&c.contains(a))&&n()}})});Y2.displayName=xse;var Eb="Toast",Mbt="toast.swipeStart",Rbt="toast.swipeMove",jbt="toast.swipeCancel",Dbt="toast.swipeEnd",bse=x.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:o,onOpenChange:i,...s}=t,[a=!0,l]=Gl({prop:n,defaultProp:o,onChange:i});return h.jsx(Mi,{present:r||a,children:h.jsx(Fbt,{open:a,...s,ref:e,onClose:()=>l(!1),onPause:Dr(t.onPause),onResume:Dr(t.onResume),onSwipeStart:ue(t.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ue(t.onSwipeMove,c=>{const{x:u,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:ue(t.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ue(t.onSwipeEnd,c=>{const{x:u,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),l(!1)})})})});bse.displayName=Eb;var[Lbt,Nbt]=vse(Eb,{onClose(){}}),Fbt=x.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:o,open:i,onClose:s,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:p,...g}=t,m=Pb(Eb,r),[S,y]=x.useState(null),v=yt(e,M=>y(M)),b=x.useRef(null),$=x.useRef(null),P=o||m.duration,E=x.useRef(0),T=x.useRef(P),I=x.useRef(0),{onToastAdd:_,onToastRemove:k}=m,D=Dr(()=>{var U;(S==null?void 0:S.contains(document.activeElement))&&((U=m.viewport)==null||U.focus()),s()}),R=x.useCallback(M=>{!M||M===1/0||(window.clearTimeout(I.current),E.current=new Date().getTime(),I.current=window.setTimeout(D,M))},[D]);x.useEffect(()=>{const M=m.viewport;if(M){const U=()=>{R(T.current),c==null||c()},B=()=>{const K=new Date().getTime()-E.current;T.current=T.current-K,window.clearTimeout(I.current),l==null||l()};return M.addEventListener(G2,B),M.addEventListener(V2,U),()=>{M.removeEventListener(G2,B),M.removeEventListener(V2,U)}}},[m.viewport,P,l,c,R]),x.useEffect(()=>{i&&!m.isClosePausedRef.current&&R(P)},[i,P,m.isClosePausedRef,R]),x.useEffect(()=>(_(),()=>k()),[_,k]);const j=x.useMemo(()=>S?Tse(S):null,[S]);return m.viewport?h.jsxs(h.Fragment,{children:[j&&h.jsx(Bbt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:j}),h.jsx(Lbt,{scope:r,onClose:D,children:oa.createPortal(h.jsx(gj.ItemSlot,{scope:r,children:h.jsx(yxt,{asChild:!0,onEscapeKeyDown:ue(a,()=>{m.isFocusedToastEscapeKeyDownRef.current||D(),m.isFocusedToastEscapeKeyDownRef.current=!1}),children:h.jsx(Ye.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":m.swipeDirection,...g,ref:v,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:ue(t.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(m.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:ue(t.onPointerDown,M=>{M.button===0&&(b.current={x:M.clientX,y:M.clientY})}),onPointerMove:ue(t.onPointerMove,M=>{if(!b.current)return;const U=M.clientX-b.current.x,B=M.clientY-b.current.y,K=!!$.current,z=["left","right"].includes(m.swipeDirection),W=["left","up"].includes(m.swipeDirection)?Math.min:Math.max,J=z?W(0,U):0,oe=z?0:W(0,B),we=M.pointerType==="touch"?10:2,_e={x:J,y:oe},Ge={originalEvent:M,delta:_e};K?($.current=_e,Ky(Rbt,d,Ge,{discrete:!1})):W7(_e,m.swipeDirection,we)?($.current=_e,Ky(Mbt,u,Ge,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(U)>we||Math.abs(B)>we)&&(b.current=null)}),onPointerUp:ue(t.onPointerUp,M=>{const U=$.current,B=M.target;if(B.hasPointerCapture(M.pointerId)&&B.releasePointerCapture(M.pointerId),$.current=null,b.current=null,U){const K=M.currentTarget,z={originalEvent:M,delta:U};W7(U,m.swipeDirection,m.swipeThreshold)?Ky(Dbt,p,z,{discrete:!0}):Ky(jbt,f,z,{discrete:!0}),K.addEventListener("click",W=>W.preventDefault(),{once:!0})}})})})}),m.viewport)})]}):null}),Bbt=t=>{const{__scopeToast:e,children:r,...n}=t,o=Pb(Eb,e),[i,s]=x.useState(!1),[a,l]=x.useState(!1);return Hbt(()=>s(!0)),x.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:h.jsx(Lm,{asChild:!0,children:h.jsx(fj,{...n,children:i&&h.jsxs(h.Fragment,{children:[o.label," ",r]})})})},Ubt="ToastTitle",$se=x.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return h.jsx(Ye.div,{...n,ref:e})});$se.displayName=Ubt;var zbt="ToastDescription",Ise=x.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return h.jsx(Ye.div,{...n,ref:e})});Ise.displayName=zbt;var Pse="ToastAction",Ese=x.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?h.jsx(_se,{altText:r,asChild:!0,children:h.jsx(mj,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${Pse}\`. Expected non-empty \`string\`.`),null)});Ese.displayName=Pse;var Cse="ToastClose",mj=x.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,o=Nbt(Cse,r);return h.jsx(_se,{asChild:!0,children:h.jsx(Ye.button,{type:"button",...n,ref:e,onClick:ue(t.onClick,o.onClose)})})});mj.displayName=Cse;var _se=x.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...o}=t;return h.jsx(Ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...o,ref:e})});function Tse(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),Wbt(n)){const o=n.ariaHidden||n.hidden||n.style.display==="none",i=n.dataset.radixToastAnnounceExclude==="";if(!o)if(i){const s=n.dataset.radixToastAnnounceAlt;s&&e.push(s)}else e.push(...Tse(n))}}),e}function Ky(t,e,r,{discrete:n}){const o=r.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});e&&o.addEventListener(t,e,{once:!0}),n?rj(o,i):o.dispatchEvent(i)}var W7=(t,e,r=0)=>{const n=Math.abs(t.x),o=Math.abs(t.y),i=n>o;return e==="left"||e==="right"?i&&n>r:!i&&o>r};function Hbt(t=()=>{}){const e=Dr(t);Il(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function Wbt(t){return t.nodeType===t.ELEMENT_NODE}function Kbt(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function rC(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var Gbt=bse,Vbt=$se,Ybt=Ise,Xbt=Ese,K7=mj;const Ase=x.createContext(null);function qbt({children:t}){const[e,r]=x.useState([]),n=x.useCallback(s=>{const a=s.id??ct();return r(l=>[...l.filter(c=>c.id!==s.id),{...s,id:a}]),a},[]),o=x.useCallback(s=>(r(a=>a.filter(l=>l.id!==s)),s),[]),i=x.useCallback(()=>{r(()=>[])},[]);return h.jsx(yse,{children:h.jsx(Ase.Provider,{value:{toasts:e,addToast:n,removeToast:o,clearToasts:i},children:t})})}function ji(){const t=x.useContext(Ase);if(!t)throw new Error("useToasts must be used within a ToastsProvider");return t}function Zbt(){const t=F(),{addToast:e}=ji(),r=Fe();return x.useCallback((n,o="svg")=>{Ebt(t,n,o).catch(()=>{e({id:"copy-fail",severity:"warning",title:r("toast.error.copy-fail.title"),description:r("toast.error.copy-fail.desc")})})},[t,e,r])}async function Qbt(t,e,r="png",n,o={}){if(!n&&(n=`shapes at ${G7()}`,e.length===1)){const a=t.getShape(e[0]);t.isShapeOfType(a,"frame")?n=a.props.name??"frame":n=`${a.id.replace(/:/,"_")} at ${G7()}`}n+=`.${r}`;const i=await mse({editor:t,ids:e,format:r,opts:o}),s=new File([i],n,{type:i.type});Jbt(s)}function G7(){const t=new Date,e=String(t.getFullYear()).slice(2),r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0");return`${e}-${r}-${n} ${o}.${i}.${s}`}function Jbt(t){const e=document.createElement("a"),r=URL.createObjectURL(t);e.href=r,e.download=t.name,e.click(),URL.revokeObjectURL(r)}function e$t(){const t=F(),{addToast:e}=ji(),r=Fe();return x.useCallback((n,o="png",i)=>{Qbt(t,n,o,i,{scale:1,background:t.getInstanceState().exportBackground}).catch(s=>{console.error(s.message),e({id:"export-fail",title:r("toast.error.export-fail.title"),description:r("toast.error.export-fail.desc"),severity:"error"})})},[t,e,r])}async function t$t(t,e,r){const n=Ae(e.map(a=>{const l=t.getShape(a);if(!(!l||t.getShapeUtil(l.type).toSvg===void 0))return l}));if(n.length===0)return;if(n.length===1){const a=n[0];if(!a||t.isShapeOfType(a,"image"))return}const o=[];if(r!==void 0){const a=n.map(l=>({shape:l,bounds:t.getShapeMaskedPageBounds(l).clone().expandBy(r)}));for(let l=0;l<a.length;l++){const c=a[l];if(l===0){o[0]={shapes:[c.shape],bounds:c.bounds};continue}let u=!1;for(const d of o)if(d.bounds.includes(c.bounds)){d.shapes.push(c.shape),d.bounds.expand(c.bounds),u=!0;break}u||o.push({shapes:[c.shape],bounds:c.bounds})}}else{const a=ee.Common(n.map(l=>t.getShapeMaskedPageBounds(l)));o.push({shapes:n,bounds:a})}const i=t.options.flattenImageBoundsPadding;for(const a of o){r!==void 0&&a.bounds.expandBy(-r);const l=await t.getSvgString(a.shapes,{padding:i});if(!(l!=null&&l.svg))continue;const c=new Blob([l.svg],{type:"image/svg+xml"}),u=await t.getAssetForExternalContent({type:"file",file:new File([c],"asset.svg",{type:"image/svg+xml"})});u&&(a.asset=u)}const s=[];return os(()=>{for(const a of o){const{asset:l,bounds:c,shapes:u}=a;if(!l)continue;const d=t.findCommonAncestor(u)??t.getCurrentPageId();if(!d)continue;let f="a1";for(const y of u)if(y.parentId===d){y.index>f&&(f=y.index);break}let p,g,m;if(Tn(d)){const y=t.getShape(d);if(!y)continue;const v=t.getPointInShapeSpace(y,{x:c.x,y:c.y});m=t.getShapePageTransform(d).rotation(),v.sub(new w(i,i).rot(-m)),p=v.x,g=v.y}else p=c.x-i,g=c.y-i,m=0;t.deleteShapes(u),t.createAssets([{...l,id:l.id}]);const S=ot();t.createShape({id:S,type:"image",index:f,parentId:d,x:p,y:g,rotation:-m,props:{assetId:l.id,w:c.w+i*2,h:c.h+i*2}}),s.push(S)}}),s}const kse=ze.createContext([]);function Ose(){const t=F(),e=x.useRef(),r=Ga(ze.useContext(kse));return x.useEffect(()=>{const n=window.document.createElement("input");n.type="file",n.accept=(r==null?void 0:r.join(","))??Ime,n.multiple=!0,e.current=n;async function o(i){const s=i.target.files;!s||s.length===0||(t.markHistoryStoppingPoint("insert media"),await t.putExternalContent({type:"files",files:Array.from(s),point:t.getViewportPageBounds().center,ignoreParent:!1}),n.value="")}return n.addEventListener("change",o),()=>{e.current=void 0,n.removeEventListener("change",o)}},[t,r]),x.useCallback(()=>{var n;(n=e.current)==null||n.click()},[e])}function Cb(){return F().store.props.collaboration!==void 0}function r$t(){const t=F();return H("sync status",()=>{var e;return(e=t.store.props.collaboration)!=null&&e.status?t.store.props.collaboration.status.get():null},[t])}function n$t(){const t=F(),e=x.useRef(null),r=x.useRef(null);return x.useCallback(async function(){const o=document.createElement("div"),i=document.createElement("style"),s=(y,v)=>{y&&(y.innerHTML=""),v&&document.head.contains(v)&&document.head.removeChild(v),y&&document.body.contains(y)&&document.body.removeChild(y)};s(e.current,r.current),e.current=o,r.current=i;const a=`tl-print-surface-${ct()}`;o.className=a,i.innerHTML=`
|
|
269
|
-
.${a} {
|
|
270
|
-
display: none;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.${a} svg {
|
|
274
|
-
max-width: 100%;
|
|
275
|
-
height: 100%;
|
|
276
|
-
display: block;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
@media print {
|
|
280
|
-
html, body {
|
|
281
|
-
min-height: 100%;
|
|
282
|
-
height: 100%;
|
|
283
|
-
margin: 0;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
body {
|
|
287
|
-
position: relative;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
body > * {
|
|
291
|
-
display: none;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.tldraw__editor {
|
|
295
|
-
display: none;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.${a} {
|
|
299
|
-
display: block !important;
|
|
300
|
-
background: white;
|
|
301
|
-
min-height: 100%;
|
|
302
|
-
height: 100%;
|
|
303
|
-
max-width: 100%;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
.${a}__item {
|
|
307
|
-
padding: 10mm;
|
|
308
|
-
display: flex;
|
|
309
|
-
min-height: 100%;
|
|
310
|
-
flex-direction: column;
|
|
311
|
-
page-break-after: always;
|
|
312
|
-
position: relative;
|
|
313
|
-
overflow: hidden;
|
|
314
|
-
height: 100%;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
.${a}__item__main {
|
|
318
|
-
flex: 1;
|
|
319
|
-
display: flex;
|
|
320
|
-
align-items: center;
|
|
321
|
-
justify-content: center;
|
|
322
|
-
max-height: 100%;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.${a}__item__header {
|
|
326
|
-
display: none;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.${a}__item__footer {
|
|
330
|
-
display: none;
|
|
331
|
-
text-align: right;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.${a}__item__footer__hide {
|
|
335
|
-
display: none;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
`;const l=()=>{document.head.appendChild(i),document.body.appendChild(o)},c=()=>{t.once("tick",()=>{s(o,i)})};window.addEventListener("beforeprint",l),window.addEventListener("afterprint",c);function u(y,v,b){try{o.innerHTML+=`<div class="${a}__item">
|
|
342
|
-
<div class="${a}__item__header">
|
|
343
|
-
${y.replace(/</g,"<").replace(/>/g,">")}
|
|
344
|
-
</div>
|
|
345
|
-
<div class="${a}__item__main">
|
|
346
|
-
${b}
|
|
347
|
-
</div>
|
|
348
|
-
<div class="${a}__item__footer ${a}__item__footer__${v?"":"hide"}">
|
|
349
|
-
${v??""}
|
|
350
|
-
</div>
|
|
351
|
-
</div>`}catch($){console.error($)}}function d(){t.environment.isChromeForIos?(l(),window.print()):t.environment.isSafari?(l(),document.execCommand("print",!1)):window.print()}const f=t.getSelectedShapeIds(),p=t.getCurrentPageId(),g=t.getPages(),S={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(t.getSelectedShapeIds().length>0){const y=await t.getSvgString(f,S);if(y){const v=g.find(b=>b.id===p);u(`tldraw — ${v==null?void 0:v.name}`,null,y.svg),d()}}else{const y=t.getCurrentPage(),v=await t.getSvgString(t.getSortedChildIdsForParent(y.id),S);v&&(u(`tldraw — ${y.name}`,null,v.svg),d())}window.removeEventListener("beforeprint",l),window.removeEventListener("afterprint",c)},[t])}const Mse=x.createContext(null);function o$t({children:t}){const e=F(),r=Br(),[n,o]=x.useState([]),i=x.useCallback(c=>{const u=c.id??ct();return o(d=>[...d.filter(f=>f.id!==c.id),{...c,id:u}]),r("open-menu",{source:"dialog",id:u}),e.addOpenMenu(u),u},[e,r]),s=x.useCallback((c,u)=>(o(d=>d.map(f=>f.id===c?{...f,...u}:f)),r("open-menu",{source:"dialog",id:c}),e.addOpenMenu(c),c),[e,r]),a=x.useCallback(c=>(o(u=>u.filter(d=>{var f;return d.id===c?((f=d.onClose)==null||f.call(d),!1):!0})),r("close-menu",{source:"dialog",id:c}),e.deleteOpenMenu(c),c),[e,r]),l=x.useCallback(()=>{o(c=>(c.forEach(u=>{var d;(d=u.onClose)==null||d.call(u),r("close-menu",{source:"dialog",id:u.id}),e.deleteOpenMenu(u.id)}),[]))},[e,r]);return h.jsx(Mse.Provider,{value:{dialogs:n,addDialog:i,removeDialog:a,clearDialogs:l,updateDialog:s},children:t})}function mu(){const t=x.useContext(Mse);if(!t)throw new Error("useDialogs must be used within a DialogsProvider");return t}const Rse=x.createContext(null);function i$t(t){return Object.fromEntries(t.map(e=>[e.id,e]))}function Fu(t,e){if(t.getSelectedShapes().length===0)return t.getDocumentSettings().name||e}function s$t({overrides:t,children:e}){const r=F(),n=Cb(),{addDialog:o,clearDialogs:i}=mu(),{clearToasts:s,addToast:a}=ji(),l=Fe(),c=Ose(),u=n$t(),{cut:d,copy:f,paste:p}=sbt(),g=Zbt(),m=e$t(),S=l("document.default-name"),y=dj(),v=Br(),b=x.useMemo(()=>{function $(){return r.isIn("select")||(r.complete(),r.setCurrentTool("select")),!1}function P(){return r.isIn("select")&&r.getSelectedShapeIds().length>0}const E=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(I){P()&&($()||(v("edit-link",{source:I}),r.markHistoryStoppingPoint("edit-link"),o({component:A1t})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(I){v("insert-embed",{source:I}),o({component:ase})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(I){v("insert-media",{source:I}),c()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(I){v("undo",{source:I}),r.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(I){v("redo",{source:I}),r.redo()}},{id:"export-as-svg",label:{default:"action.export-as-svg",menu:"action.export-as-svg.short","context-menu":"action.export-as-svg.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("export-as",{format:"svg",source:I}),m(_,"svg",Fu(r,S)))}},{id:"export-as-png",label:{default:"action.export-as-png",menu:"action.export-as-png.short","context-menu":"action.export-as-png.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("export-as",{format:"png",source:I}),m(_,"png",Fu(r,S)))}},{id:"export-as-json",label:{default:"action.export-as-json",menu:"action.export-as-json.short","context-menu":"action.export-as-json.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("export-as",{format:"json",source:I}),m(_,"json",Fu(r,S)))}},{id:"export-all-as-svg",label:{default:"action.export-all-as-svg",menu:"action.export-all-as-svg.short","context-menu":"action.export-all-as-svg.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("export-all-as",{format:"svg",source:I}),m(Array.from(r.getCurrentPageShapeIds()),"svg",Fu(r,S)))}},{id:"export-all-as-png",label:{default:"action.export-all-as-png",menu:"action.export-all-as-png.short","context-menu":"action.export-all-as-png.short"},readonlyOk:!0,onSelect(I){const _=Array.from(r.getCurrentPageShapeIds().values());_.length!==0&&(v("export-all-as",{format:"png",source:I}),m(_,"png",Fu(r,S)))}},{id:"export-all-as-json",label:{default:"action.export-all-as-json",menu:"action.export-all-as-json.short","context-menu":"action.export-all-as-json.short"},readonlyOk:!0,onSelect(I){const _=Array.from(r.getCurrentPageShapeIds().values());_.length!==0&&(v("export-all-as",{format:"json",source:I}),m(_,"json",Fu(r,S)))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},kbd:"$!c",readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("copy-as",{format:"svg",source:I}),g(_,"svg"))}},{id:"copy-as-png",label:{default:"action.copy-as-png",menu:"action.copy-as-png.short","context-menu":"action.copy-as-png.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("copy-as",{format:"png",source:I}),g(_,"png"))}},{id:"copy-as-json",label:{default:"action.copy-as-json",menu:"action.copy-as-json.short","context-menu":"action.copy-as-json.short"},readonlyOk:!0,onSelect(I){let _=r.getSelectedShapeIds();_.length===0&&(_=Array.from(r.getCurrentPageShapeIds().values())),_.length!==0&&(v("copy-as",{format:"json",source:I}),g(_,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(I){if(!P()||$())return;v("toggle-auto-size",{source:I}),r.markHistoryStoppingPoint("toggling auto size");const _=r.getSelectedShapes().filter(k=>r.isShapeOfType(k,"text")&&k.props.autoSize===!1);r.updateShapes(_.map(k=>({id:k.id,type:k.type,props:{...k.props,w:8,autoSize:!0}}))),pt(r,_.map(k=>k.id))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(I){v("open-embed-link",{source:I});const _=r.getSelectedShapeIds(),k="No embed shapes selected";if(_.length!==1){console.error(k);return}const D=r.getShape(_[0]);if(!D||!r.isShapeOfType(D,"embed")){console.error(k);return}K0t(D.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(I){var _,k;if(((_=r.root.getCurrent())==null?void 0:_.id)!=="zoom"&&(v("zoom-tool",{source:I}),!(r.inputs.shiftKey||r.inputs.ctrlKey))){const D=r.root.getCurrent();D&&((k=D.getCurrent())==null?void 0:k.id)==="idle"&&r.setCurrentTool("zoom",{onInteractionEnd:D.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(I){P()&&($()||r.run(()=>{v("convert-to-bookmark",{source:I});const _=r.getSelectedShapes(),k=[],D=[];for(const R of _){if(!R||!r.isShapeOfType(R,"embed")||!R.props.url)continue;const j=new w(R.x,R.y);j.rot(-R.rotation),j.add(new w(R.props.w/2-300/2,R.props.h/2-320/2)),j.rot(R.rotation);const M={id:ot(),type:"bookmark",rotation:R.rotation,x:j.x,y:j.y,opacity:1,props:{url:R.props.url}};k.push(M),D.push(R.id)}r.markHistoryStoppingPoint("convert shapes to bookmark"),r.deleteShapes(D),r.createShapes(k)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(I){P()&&($()||(v("convert-to-embed",{source:I}),r.run(()=>{const _=r.getSelectedShapeIds(),k=Ae(_.map(j=>r.getShape(j))),D=[],R=[];for(const j of k){if(!r.isShapeOfType(j,"bookmark"))continue;const{url:M}=j.props,U=y(M);if(!U||!U.definition)continue;const{width:B,height:K}=U.definition,z=new w(j.x,j.y);z.rot(-j.rotation),z.add(new w(j.props.w/2-B/2,j.props.h/2-K/2)),z.rot(j.rotation);const W={id:ot(),type:"embed",x:z.x,y:z.y,rotation:j.rotation,props:{url:M,w:B,h:K}};D.push(W),R.push(j.id)}r.markHistoryStoppingPoint("convert shapes to embed"),r.deleteShapes(R),r.createShapes(D)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(I){if(!P()||$())return;v("duplicate-shapes",{source:I});const _=r.getInstanceState();let k,D;if(_.duplicateProps)k=_.duplicateProps.shapeIds,D=_.duplicateProps.offset;else{k=r.getSelectedShapeIds();const R=ee.Common(Ae(k.map(j=>r.getShapePageBounds(j))));D=r.getCameraOptions().isLocked?{x:r.options.adjacentShapeMargin,y:r.options.adjacentShapeMargin}:{x:R.width+r.options.adjacentShapeMargin,y:0}}r.markHistoryStoppingPoint("duplicate shapes"),r.duplicateShapes(k,D),_.duplicateProps&&r.updateInstanceState({duplicateProps:{..._.duplicateProps,shapeIds:r.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(I){P()&&($()||(v("ungroup-shapes",{source:I}),r.markHistoryStoppingPoint("ungroup"),r.ungroupShapes(r.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(I){if(!P()||$())return;v("group-shapes",{source:I});const _=r.getOnlySelectedShape();_&&r.isShapeOfType(_,"group")?(r.markHistoryStoppingPoint("ungroup"),r.ungroupShapes(r.getSelectedShapeIds())):(r.markHistoryStoppingPoint("group"),r.groupShapes(r.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(I){if(!P())return;v("remove-frame",{source:I});const _=r.getSelectedShapes();_.length>0&&_.every(k=>r.isShapeOfType(k,"frame"))&&(r.markHistoryStoppingPoint("remove-frame"),V0t(r,_.map(k=>k.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(I){if(!P())return;v("fit-frame-to-content",{source:I});const _=r.getOnlySelectedShape();_&&r.isShapeOfType(_,"frame")&&(r.markHistoryStoppingPoint("fit-frame-to-content"),X0t(r,_.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"left",source:I}),r.markHistoryStoppingPoint("align left");const _=r.getSelectedShapeIds();r.alignShapes(_,"left"),pt(r,_)}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"center-horizontal",source:I}),r.markHistoryStoppingPoint("align center horizontal");const _=r.getSelectedShapeIds();r.alignShapes(_,"center-horizontal"),pt(r,_)}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"right",source:I}),r.markHistoryStoppingPoint("align right");const _=r.getSelectedShapeIds();r.alignShapes(_,"right"),pt(r,_)}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"center-vertical",source:I}),r.markHistoryStoppingPoint("align center vertical");const _=r.getSelectedShapeIds();r.alignShapes(_,"center-vertical"),pt(r,_)}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"top",source:I}),r.markHistoryStoppingPoint("align top");const _=r.getSelectedShapeIds();r.alignShapes(_,"top"),pt(r,_)}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(I){if(!P()||$())return;v("align-shapes",{operation:"bottom",source:I}),r.markHistoryStoppingPoint("align bottom");const _=r.getSelectedShapeIds();r.alignShapes(_,"bottom"),pt(r,_)}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(I){if(!P()||$())return;v("distribute-shapes",{operation:"horizontal",source:I}),r.markHistoryStoppingPoint("distribute horizontal");const _=r.getSelectedShapeIds();r.distributeShapes(_,"horizontal"),pt(r,_)}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(I){if(!P()||$())return;v("distribute-shapes",{operation:"vertical",source:I}),r.markHistoryStoppingPoint("distribute vertical");const _=r.getSelectedShapeIds();r.distributeShapes(_,"vertical"),pt(r,_)}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(I){if(!P()||$())return;v("stretch-shapes",{operation:"horizontal",source:I}),r.markHistoryStoppingPoint("stretch horizontal");const _=r.getSelectedShapeIds();r.stretchShapes(_,"horizontal"),pt(r,_)}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(I){if(!P()||$())return;v("stretch-shapes",{operation:"vertical",source:I}),r.markHistoryStoppingPoint("stretch vertical");const _=r.getSelectedShapeIds();r.stretchShapes(_,"vertical"),pt(r,_)}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(I){if(!P()||$())return;v("flip-shapes",{operation:"horizontal",source:I}),r.markHistoryStoppingPoint("flip horizontal");const _=r.getSelectedShapeIds();r.flipShapes(_,"horizontal"),pt(r,_)}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(I){if(!P()||$())return;v("flip-shapes",{operation:"vertical",source:I}),r.markHistoryStoppingPoint("flip vertical");const _=r.getSelectedShapeIds();r.flipShapes(_,"vertical"),pt(r,_)}},{id:"pack",label:"action.pack",icon:"pack",onSelect(I){if(!P()||$())return;v("pack-shapes",{source:I}),r.markHistoryStoppingPoint("pack");const _=r.getSelectedShapeIds();r.packShapes(_,r.options.adjacentShapeMargin),pt(r,_)}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(I){if(!P()||$())return;v("stack-shapes",{operation:"vertical",source:I}),r.markHistoryStoppingPoint("stack-vertical");const _=r.getSelectedShapeIds();r.stackShapes(_,"vertical",16),pt(r,_)}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(I){if(!P()||$())return;v("stack-shapes",{operation:"horizontal",source:I}),r.markHistoryStoppingPoint("stack-horizontal");const _=r.getSelectedShapeIds();r.stackShapes(_,"horizontal",16),pt(r,_)}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(I){P()&&($()||(v("reorder-shapes",{operation:"toFront",source:I}),r.markHistoryStoppingPoint("bring to front"),r.bringToFront(r.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(I){P()&&($()||(v("reorder-shapes",{operation:"forward",source:I}),r.markHistoryStoppingPoint("bring forward"),r.bringForward(r.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(I){P()&&($()||(v("reorder-shapes",{operation:"backward",source:I}),r.markHistoryStoppingPoint("send backward"),r.sendBackward(r.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(I){P()&&($()||(v("reorder-shapes",{operation:"toBack",source:I}),r.markHistoryStoppingPoint("send to back"),r.sendToBack(r.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(I){P()&&($()||(r.markHistoryStoppingPoint("cut"),d(I)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(I){P()&&($()||f(I))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(I){var _;(_=navigator.clipboard)==null||_.read().then(k=>{p(k,I,I==="context-menu"?r.inputs.currentPagePoint:void 0)}).catch(()=>{a({title:l("action.paste-error-title"),description:l("action.paste-error-description"),severity:"error"})})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(I){r.run(()=>{$()||(v("select-all-shapes",{source:I}),r.markHistoryStoppingPoint("select all kbd"),r.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(I){P()&&($()||(v("select-none-shapes",{source:I}),r.markHistoryStoppingPoint("select none"),r.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(I){P()&&($()||(v("delete-shapes",{source:I}),r.markHistoryStoppingPoint("delete"),r.deleteShapes(r.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(I){if(!P()||$())return;v("rotate-cw",{source:I}),r.markHistoryStoppingPoint("rotate-cw");const _=r.getSelectionRotation()%(vt/2),k=ul(_,0)||ul(_,vt/2),D=r.getSelectedShapeIds();r.rotateShapesBy(D,vt/2-(k?0:_)),pt(r,D)}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(I){if(!P()||$())return;v("rotate-ccw",{source:I}),r.markHistoryStoppingPoint("rotate-ccw");const _=r.getSelectionRotation()%(vt/2),k=ul(_,0),D=r.getSelectedShapeIds();r.rotateShapesBy(D,k?-(vt/2):-_),pt(r,D)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(I){v("zoom-in",{source:I}),r.zoomIn(void 0,{animation:{duration:r.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(I){v("zoom-out",{source:I}),r.zoomOut(void 0,{animation:{duration:r.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(I){v("reset-zoom",{source:I}),r.resetZoom(void 0,{animation:{duration:r.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(I){v("zoom-to-fit",{source:I}),r.zoomToFit({animation:{duration:r.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(I){P()&&($()||(v("zoom-to-selection",{source:I}),r.zoomToSelection({animation:{duration:r.options.animationMediumMs}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(I){v("toggle-snap-mode",{source:I}),r.user.updateUserPreferences({isSnapMode:!r.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(I){const _=r.user.getIsDarkMode()?"light":"dark";v("color-scheme",{source:I,value:_}),r.user.updateUserPreferences({colorScheme:_})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(I){v("toggle-wrap-mode",{source:I}),r.user.updateUserPreferences({isWrapMode:!r.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-dynamic-size-mode",label:{default:"action.toggle-dynamic-size-mode",menu:"action.toggle-dynamic-size-mode.menu"},readonlyOk:!1,onSelect(I){v("toggle-dynamic-size-mode",{source:I}),r.user.updateUserPreferences({isDynamicSizeMode:!r.user.getIsDynamicResizeMode()})},checkbox:!0},{id:"toggle-paste-at-cursor",label:{default:"action.toggle-paste-at-cursor",menu:"action.toggle-paste-at-cursor.menu"},readonlyOk:!1,onSelect(I){v("toggle-paste-at-cursor",{source:I}),r.user.updateUserPreferences({isPasteAtCursorMode:!r.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(I){v("toggle-reduce-motion",{source:I}),r.user.updateUserPreferences({animationSpeed:r.user.getAnimationSpeed()===0?1:0})},checkbox:!0},{id:"toggle-edge-scrolling",label:{default:"action.toggle-edge-scrolling",menu:"action.toggle-edge-scrolling.menu"},readonlyOk:!0,onSelect(I){v("toggle-edge-scrolling",{source:I}),r.user.updateUserPreferences({edgeScrollSpeed:r.user.getEdgeScrollSpeed()===0?1:0})},checkbox:!0},{id:"toggle-transparent",label:{default:"action.toggle-transparent",menu:"action.toggle-transparent.menu","context-menu":"action.toggle-transparent.context-menu"},readonlyOk:!0,onSelect(I){v("toggle-transparent",{source:I}),r.updateInstanceState({exportBackground:!r.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(I){v("toggle-tool-lock",{source:I}),r.updateInstanceState({isToolLocked:!r.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(I){v("unlock-all",{source:I});const _=[];for(const k of r.getCurrentPageShapes())k.isLocked&&_.push({id:k.id,type:k.type,isLocked:!1});_.length>0&&r.updateShapes(_)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(I){r.timers.requestAnimationFrame(()=>{r.run(()=>{v("toggle-focus-mode",{source:I}),i(),s(),r.updateInstanceState({isFocusMode:!r.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(I){v("toggle-grid-mode",{source:I}),r.updateInstanceState({isGridMode:!r.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(I){v("toggle-debug-mode",{source:I}),r.updateInstanceState({isDebugMode:!r.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(I){v("print",{source:I}),u()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(I){v("exit-pen-mode",{source:I}),r.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(I){v("stop-following",{source:I}),r.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(I){v("zoom-to-content",{source:I});const _=r.getSelectionPageBounds()??r.getCurrentPageBounds();_&&r.zoomToBounds(_,{targetZoom:Math.min(1,r.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(I){r.markHistoryStoppingPoint("locking"),v("toggle-lock",{source:I}),r.toggleLock(r.getSelectedShapeIds())}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(I){const _=vo.createId(),k=r.getSelectedShapeIds();r.run(()=>{r.markHistoryStoppingPoint("move_shapes_to_page"),r.createPage({name:l("page-menu.new-page-initial-name"),id:_}),r.moveShapesToPage(k,_)}),v("move-to-new-page",{source:I})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(I){const _=mo;r.run(()=>{r.markHistoryStoppingPoint("change-color"),r.isIn("select")&&r.setStyleForSelectedShapes(_,"white"),r.setStyleForNextShapes(_,"white")}),v("set-style",{source:I,id:_.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"?f",onSelect(I){const _=Fc;r.run(()=>{r.markHistoryStoppingPoint("change-fill"),r.isIn("select")&&r.setStyleForSelectedShapes(_,"fill"),r.setStyleForNextShapes(_,"fill")}),v("set-style",{source:I,id:_.id,value:"fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"!f",onSelect:async I=>{const _=r.getSelectedShapeIds();if(_.length===0)return;r.markHistoryStoppingPoint("flattening to image"),v("flatten-to-image",{source:I});const k=await t$t(r,_,r.options.flattenImageBoundsExpand);k!=null&&k.length&&r.setSelectedShapes(k)}}];n&&E.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(I){v("open-cursor-chat",{source:I}),!r.getInstanceState().isCoarsePointer&&r.timers.requestAnimationFrame(()=>{r.updateInstanceState({isChatting:!0})})}});const T=i$t(E);return t?t(r,T,void 0):T},[r,v,t,o,a,c,m,g,d,f,p,i,s,u,l,S,n,y]);return h.jsx(Rse.Provider,{value:b,children:e})}function vu(){const t=x.useContext(Rse);if(!t)throw new Error("useTools must be used within a ToolProvider");return t}function _g(t,e){return t?typeof t=="string"?t:e?t[e]??t.default:void 0:void 0}var a$t=x.createContext(void 0);function vj(t){const e=x.useContext(a$t);return t||e||"ltr"}const l$t=["top","right","bottom","left"],Ji=Math.min,no=Math.max,q0=Math.round,Gy=Math.floor,Pl=t=>({x:t,y:t}),c$t={left:"right",right:"left",bottom:"top",top:"bottom"},u$t={start:"end",end:"start"};function X2(t,e,r){return no(t,Ji(e,r))}function da(t,e){return typeof t=="function"?t(e):t}function ha(t){return t.split("-")[0]}function Yh(t){return t.split("-")[1]}function yj(t){return t==="x"?"y":"x"}function Sj(t){return t==="y"?"height":"width"}function El(t){return["top","bottom"].includes(ha(t))?"y":"x"}function wj(t){return yj(El(t))}function d$t(t,e,r){r===void 0&&(r=!1);const n=Yh(t),o=wj(t),i=Sj(o);let s=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Z0(s)),[s,Z0(s)]}function h$t(t){const e=Z0(t);return[q2(t),e,q2(e)]}function q2(t){return t.replace(/start|end/g,e=>u$t[e])}function f$t(t,e,r){const n=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return r?e?o:n:e?n:o;case"left":case"right":return e?i:s;default:return[]}}function p$t(t,e,r,n){const o=Yh(t);let i=f$t(ha(t),r==="start",n);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(q2)))),i}function Z0(t){return t.replace(/left|right|bottom|top/g,e=>c$t[e])}function g$t(t){return{top:0,right:0,bottom:0,left:0,...t}}function jse(t){return typeof t!="number"?g$t(t):{top:t,right:t,bottom:t,left:t}}function Q0(t){const{x:e,y:r,width:n,height:o}=t;return{width:n,height:o,top:r,left:e,right:e+n,bottom:r+o,x:e,y:r}}function V7(t,e,r){let{reference:n,floating:o}=t;const i=El(e),s=wj(e),a=Sj(s),l=ha(e),c=i==="y",u=n.x+n.width/2-o.width/2,d=n.y+n.height/2-o.height/2,f=n[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:n.y-o.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-o.width,y:d};break;default:p={x:n.x,y:n.y}}switch(Yh(e)){case"start":p[s]-=f*(r&&c?-1:1);break;case"end":p[s]+=f*(r&&c?-1:1);break}return p}const m$t=async(t,e,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:i=[],platform:s}=r,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e));let c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:d}=V7(c,n,l),f=n,p={},g=0;for(let m=0;m<a.length;m++){const{name:S,fn:y}=a[m],{x:v,y:b,data:$,reset:P}=await y({x:u,y:d,initialPlacement:n,placement:f,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:t,floating:e}});u=v??u,d=b??d,p={...p,[S]:{...p[S],...$}},P&&g<=50&&(g++,typeof P=="object"&&(P.placement&&(f=P.placement),P.rects&&(c=P.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):P.rects),{x:u,y:d}=V7(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:p}};async function Tg(t,e){var r;e===void 0&&(e={});const{x:n,y:o,platform:i,rects:s,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=da(e,t),g=jse(p),S=a[f?d==="floating"?"reference":"floating":d],y=Q0(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(S)))==null||r?S:S.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:n,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),$=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},P=Q0(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(y.top-P.top+g.top)/$.y,bottom:(P.bottom-y.bottom+g.bottom)/$.y,left:(y.left-P.left+g.left)/$.x,right:(P.right-y.right+g.right)/$.x}}const v$t=t=>({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=da(t,e)||{};if(c==null)return{};const d=jse(u),f={x:r,y:n},p=wj(o),g=Sj(p),m=await s.getDimensions(c),S=p==="y",y=S?"top":"left",v=S?"bottom":"right",b=S?"clientHeight":"clientWidth",$=i.reference[g]+i.reference[p]-f[p]-i.floating[g],P=f[p]-i.reference[p],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let T=E?E[b]:0;(!T||!await(s.isElement==null?void 0:s.isElement(E)))&&(T=a.floating[b]||i.floating[g]);const I=$/2-P/2,_=T/2-m[g]/2-1,k=Ji(d[y],_),D=Ji(d[v],_),R=k,j=T-m[g]-D,M=T/2-m[g]/2+I,U=X2(R,M,j),B=!l.arrow&&Yh(o)!=null&&M!==U&&i.reference[g]/2-(M<R?k:D)-m[g]/2<0,K=B?M<R?M-R:M-j:0;return{[p]:f[p]+K,data:{[p]:U,centerOffset:M-U-K,...B&&{alignmentOffset:K}},reset:B}}}),y$t=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,n;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...S}=da(t,e);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=ha(o),v=El(a),b=ha(a)===a,$=await(l.isRTL==null?void 0:l.isRTL(c.floating)),P=f||(b||!m?[Z0(a)]:h$t(a)),E=g!=="none";!f&&E&&P.push(...p$t(a,m,g,$));const T=[a,...P],I=await Tg(e,S),_=[];let k=((n=i.flip)==null?void 0:n.overflows)||[];if(u&&_.push(I[y]),d){const M=d$t(o,s,$);_.push(I[M[0]],I[M[1]])}if(k=[...k,{placement:o,overflows:_}],!_.every(M=>M<=0)){var D,R;const M=(((D=i.flip)==null?void 0:D.index)||0)+1,U=T[M];if(U)return{data:{index:M,overflows:k},reset:{placement:U}};let B=(R=k.filter(K=>K.overflows[0]<=0).sort((K,z)=>K.overflows[1]-z.overflows[1])[0])==null?void 0:R.placement;if(!B)switch(p){case"bestFit":{var j;const K=(j=k.filter(z=>{if(E){const W=El(z.placement);return W===v||W==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(W=>W>0).reduce((W,J)=>W+J,0)]).sort((z,W)=>z[1]-W[1])[0])==null?void 0:j[0];K&&(B=K);break}case"initialPlacement":B=a;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Y7(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function X7(t){return l$t.some(e=>t[e]>=0)}const S$t=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...o}=da(t,e);switch(n){case"referenceHidden":{const i=await Tg(e,{...o,elementContext:"reference"}),s=Y7(i,r.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:X7(s)}}}case"escaped":{const i=await Tg(e,{...o,altBoundary:!0}),s=Y7(i,r.floating);return{data:{escapedOffsets:s,escaped:X7(s)}}}default:return{}}}}};async function w$t(t,e){const{placement:r,platform:n,elements:o}=t,i=await(n.isRTL==null?void 0:n.isRTL(o.floating)),s=ha(r),a=Yh(r),l=El(r)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=da(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const x$t=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:o,y:i,placement:s,middlewareData:a}=e,l=await w$t(e,t);return s===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},b$t=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:S=>{let{x:y,y:v}=S;return{x:y,y:v}}},...l}=da(t,e),c={x:r,y:n},u=await Tg(e,l),d=El(ha(o)),f=yj(d);let p=c[f],g=c[d];if(i){const S=f==="y"?"top":"left",y=f==="y"?"bottom":"right",v=p+u[S],b=p-u[y];p=X2(v,p,b)}if(s){const S=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=g+u[S],b=g-u[y];g=X2(v,g,b)}const m=a.fn({...e,[f]:p,[d]:g});return{...m,data:{x:m.x-r,y:m.y-n}}}}},$$t=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:o,rects:i,middlewareData:s}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=da(t,e),u={x:r,y:n},d=El(o),f=yj(d);let p=u[f],g=u[d];const m=da(a,e),S=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const b=f==="y"?"height":"width",$=i.reference[f]-i.floating[b]+S.mainAxis,P=i.reference[f]+i.reference[b]-S.mainAxis;p<$?p=$:p>P&&(p=P)}if(c){var y,v;const b=f==="y"?"width":"height",$=["top","left"].includes(ha(o)),P=i.reference[d]-i.floating[b]+($&&((y=s.offset)==null?void 0:y[d])||0)+($?0:S.crossAxis),E=i.reference[d]+i.reference[b]+($?0:((v=s.offset)==null?void 0:v[d])||0)-($?S.crossAxis:0);g<P?g=P:g>E&&(g=E)}return{[f]:p,[d]:g}}}},I$t=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:r,rects:n,platform:o,elements:i}=e,{apply:s=()=>{},...a}=da(t,e),l=await Tg(e,a),c=ha(r),u=Yh(r),d=El(r)==="y",{width:f,height:p}=n.floating;let g,m;c==="top"||c==="bottom"?(g=c,m=u===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(m=c,g=u==="end"?"top":"bottom");const S=p-l.top-l.bottom,y=f-l.left-l.right,v=Ji(p-l[g],S),b=Ji(f-l[m],y),$=!e.middlewareData.shift;let P=v,E=b;if(d?E=u||$?Ji(b,y):y:P=u||$?Ji(v,S):S,$&&!u){const I=no(l.left,0),_=no(l.right,0),k=no(l.top,0),D=no(l.bottom,0);d?E=f-2*(I!==0||_!==0?I+_:no(l.left,l.right)):P=p-2*(k!==0||D!==0?k+D:no(l.top,l.bottom))}await s({...e,availableWidth:E,availableHeight:P});const T=await o.getDimensions(i.floating);return f!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function Xh(t){return Dse(t)?(t.nodeName||"").toLowerCase():"#document"}function fo(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function wa(t){var e;return(e=(Dse(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Dse(t){return t instanceof Node||t instanceof fo(t).Node}function Ii(t){return t instanceof Element||t instanceof fo(t).Element}function hs(t){return t instanceof HTMLElement||t instanceof fo(t).HTMLElement}function q7(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fo(t).ShadowRoot}function Nm(t){const{overflow:e,overflowX:r,overflowY:n,display:o}=Pi(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!["inline","contents"].includes(o)}function P$t(t){return["table","td","th"].includes(Xh(t))}function _b(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function xj(t){const e=bj(),r=Ii(t)?Pi(t):t;return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function E$t(t){let e=Cl(t);for(;hs(e)&&!dh(e);){if(xj(e))return e;if(_b(e))return null;e=Cl(e)}return null}function bj(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function dh(t){return["html","body","#document"].includes(Xh(t))}function Pi(t){return fo(t).getComputedStyle(t)}function Tb(t){return Ii(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Cl(t){if(Xh(t)==="html")return t;const e=t.assignedSlot||t.parentNode||q7(t)&&t.host||wa(t);return q7(e)?e.host:e}function Lse(t){const e=Cl(t);return dh(e)?t.ownerDocument?t.ownerDocument.body:t.body:hs(e)&&Nm(e)?e:Lse(e)}function Ag(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const o=Lse(t),i=o===((n=t.ownerDocument)==null?void 0:n.body),s=fo(o);if(i){const a=Z2(s);return e.concat(s,s.visualViewport||[],Nm(o)?o:[],a&&r?Ag(a):[])}return e.concat(o,Ag(o,[],r))}function Z2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Nse(t){const e=Pi(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const o=hs(t),i=o?t.offsetWidth:r,s=o?t.offsetHeight:n,a=q0(r)!==i||q0(n)!==s;return a&&(r=i,n=s),{width:r,height:n,$:a}}function $j(t){return Ii(t)?t:t.contextElement}function Bd(t){const e=$j(t);if(!hs(e))return Pl(1);const r=e.getBoundingClientRect(),{width:n,height:o,$:i}=Nse(e);let s=(i?q0(r.width):r.width)/n,a=(i?q0(r.height):r.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const C$t=Pl(0);function Fse(t){const e=fo(t);return!bj()||!e.visualViewport?C$t:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function _$t(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==fo(t)?!1:e}function Vc(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const o=t.getBoundingClientRect(),i=$j(t);let s=Pl(1);e&&(n?Ii(n)&&(s=Bd(n)):s=Bd(t));const a=_$t(i,r,n)?Fse(i):Pl(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const f=fo(i),p=n&&Ii(n)?fo(n):n;let g=f,m=Z2(g);for(;m&&n&&p!==g;){const S=Bd(m),y=m.getBoundingClientRect(),v=Pi(m),b=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*S.x,$=y.top+(m.clientTop+parseFloat(v.paddingTop))*S.y;l*=S.x,c*=S.y,u*=S.x,d*=S.y,l+=b,c+=$,g=fo(m),m=Z2(g)}}return Q0({width:u,height:d,x:l,y:c})}function T$t(t){let{elements:e,rect:r,offsetParent:n,strategy:o}=t;const i=o==="fixed",s=wa(n),a=e?_b(e.floating):!1;if(n===s||a&&i)return r;let l={scrollLeft:0,scrollTop:0},c=Pl(1);const u=Pl(0),d=hs(n);if((d||!d&&!i)&&((Xh(n)!=="body"||Nm(s))&&(l=Tb(n)),hs(n))){const f=Vc(n);c=Bd(n),u.x=f.x+n.clientLeft,u.y=f.y+n.clientTop}return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-l.scrollLeft*c.x+u.x,y:r.y*c.y-l.scrollTop*c.y+u.y}}function A$t(t){return Array.from(t.getClientRects())}function Bse(t){return Vc(wa(t)).left+Tb(t).scrollLeft}function k$t(t){const e=wa(t),r=Tb(t),n=t.ownerDocument.body,o=no(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=no(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+Bse(t);const a=-r.scrollTop;return Pi(n).direction==="rtl"&&(s+=no(e.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:a}}function O$t(t,e){const r=fo(t),n=wa(t),o=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=bj();(!c||c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function M$t(t,e){const r=Vc(t,!0,e==="fixed"),n=r.top+t.clientTop,o=r.left+t.clientLeft,i=hs(t)?Bd(t):Pl(1),s=t.clientWidth*i.x,a=t.clientHeight*i.y,l=o*i.x,c=n*i.y;return{width:s,height:a,x:l,y:c}}function Z7(t,e,r){let n;if(e==="viewport")n=O$t(t,r);else if(e==="document")n=k$t(wa(t));else if(Ii(e))n=M$t(e,r);else{const o=Fse(t);n={...e,x:e.x-o.x,y:e.y-o.y}}return Q0(n)}function Use(t,e){const r=Cl(t);return r===e||!Ii(r)||dh(r)?!1:Pi(r).position==="fixed"||Use(r,e)}function R$t(t,e){const r=e.get(t);if(r)return r;let n=Ag(t,[],!1).filter(a=>Ii(a)&&Xh(a)!=="body"),o=null;const i=Pi(t).position==="fixed";let s=i?Cl(t):t;for(;Ii(s)&&!dh(s);){const a=Pi(s),l=xj(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Nm(s)&&!l&&Use(t,s))?n=n.filter(u=>u!==s):o=a,s=Cl(s)}return e.set(t,n),n}function j$t(t){let{element:e,boundary:r,rootBoundary:n,strategy:o}=t;const s=[...r==="clippingAncestors"?_b(e)?[]:R$t(e,this._c):[].concat(r),n],a=s[0],l=s.reduce((c,u)=>{const d=Z7(e,u,o);return c.top=no(d.top,c.top),c.right=Ji(d.right,c.right),c.bottom=Ji(d.bottom,c.bottom),c.left=no(d.left,c.left),c},Z7(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function D$t(t){const{width:e,height:r}=Nse(t);return{width:e,height:r}}function L$t(t,e,r){const n=hs(e),o=wa(e),i=r==="fixed",s=Vc(t,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=Pl(0);if(n||!n&&!i)if((Xh(e)!=="body"||Nm(o))&&(a=Tb(e)),n){const d=Vc(e,!0,i,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}else o&&(l.x=Bse(o));const c=s.left+a.scrollLeft-l.x,u=s.top+a.scrollTop-l.y;return{x:c,y:u,width:s.width,height:s.height}}function nC(t){return Pi(t).position==="static"}function Q7(t,e){return!hs(t)||Pi(t).position==="fixed"?null:e?e(t):t.offsetParent}function zse(t,e){const r=fo(t);if(_b(t))return r;if(!hs(t)){let o=Cl(t);for(;o&&!dh(o);){if(Ii(o)&&!nC(o))return o;o=Cl(o)}return r}let n=Q7(t,e);for(;n&&P$t(n)&&nC(n);)n=Q7(n,e);return n&&dh(n)&&nC(n)&&!xj(n)?r:n||E$t(t)||r}const N$t=async function(t){const e=this.getOffsetParent||zse,r=this.getDimensions,n=await r(t.floating);return{reference:L$t(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function F$t(t){return Pi(t).direction==="rtl"}const B$t={convertOffsetParentRelativeRectToViewportRelativeRect:T$t,getDocumentElement:wa,getClippingRect:j$t,getOffsetParent:zse,getElementRects:N$t,getClientRects:A$t,getDimensions:D$t,getScale:Bd,isElement:Ii,isRTL:F$t};function U$t(t,e){let r=null,n;const o=wa(t);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:d,height:f}=t.getBoundingClientRect();if(a||e(),!d||!f)return;const p=Gy(u),g=Gy(o.clientWidth-(c+d)),m=Gy(o.clientHeight-(u+f)),S=Gy(c),v={rootMargin:-p+"px "+-g+"px "+-m+"px "+-S+"px",threshold:no(0,Ji(1,l))||1};let b=!0;function $(P){const E=P[0].intersectionRatio;if(E!==l){if(!b)return s();E?s(!1,E):n=setTimeout(()=>{s(!1,1e-7)},1e3)}b=!1}try{r=new IntersectionObserver($,{...v,root:o.ownerDocument})}catch{r=new IntersectionObserver($,v)}r.observe(t)}return s(!0),i}function z$t(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,c=$j(t),u=o||i?[...c?Ag(c):[],...Ag(e)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=c&&a?U$t(c,r):null;let f=-1,p=null;s&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),r()}),c&&!l&&p.observe(c),p.observe(e));let g,m=l?Vc(t):null;l&&S();function S(){const y=Vc(t);m&&(y.x!==m.x||y.y!==m.y||y.width!==m.width||y.height!==m.height)&&r(),m=y,g=requestAnimationFrame(S)}return r(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),d==null||d(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const H$t=x$t,W$t=b$t,K$t=y$t,G$t=I$t,V$t=S$t,J7=v$t,Y$t=$$t,X$t=(t,e,r)=>{const n=new Map,o={platform:B$t,...r},i={...o.platform,_c:n};return m$t(t,e,{...o,platform:i})};var HS=typeof document<"u"?x.useLayoutEffect:x.useEffect;function J0(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let r,n,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==e.length)return!1;for(n=r;n--!==0;)if(!J0(t[n],e[n]))return!1;return!0}if(o=Object.keys(t),r=o.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(e,o[n]))return!1;for(n=r;n--!==0;){const i=o[n];if(!(i==="_owner"&&t.$$typeof)&&!J0(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Hse(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function e9(t,e){const r=Hse(t);return Math.round(e*r)/r}function t9(t){const e=x.useRef(t);return HS(()=>{e.current=t}),e}function q$t(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,d]=x.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=x.useState(n);J0(f,n)||p(n);const[g,m]=x.useState(null),[S,y]=x.useState(null),v=x.useCallback(K=>{K!==E.current&&(E.current=K,m(K))},[]),b=x.useCallback(K=>{K!==T.current&&(T.current=K,y(K))},[]),$=i||g,P=s||S,E=x.useRef(null),T=x.useRef(null),I=x.useRef(u),_=l!=null,k=t9(l),D=t9(o),R=x.useCallback(()=>{if(!E.current||!T.current)return;const K={placement:e,strategy:r,middleware:f};D.current&&(K.platform=D.current),X$t(E.current,T.current,K).then(z=>{const W={...z,isPositioned:!0};j.current&&!J0(I.current,W)&&(I.current=W,oa.flushSync(()=>{d(W)}))})},[f,e,r,D]);HS(()=>{c===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[c]);const j=x.useRef(!1);HS(()=>(j.current=!0,()=>{j.current=!1}),[]),HS(()=>{if($&&(E.current=$),P&&(T.current=P),$&&P){if(k.current)return k.current($,P,R);R()}},[$,P,R,k,_]);const M=x.useMemo(()=>({reference:E,floating:T,setReference:v,setFloating:b}),[v,b]),U=x.useMemo(()=>({reference:$,floating:P}),[$,P]),B=x.useMemo(()=>{const K={position:r,left:0,top:0};if(!U.floating)return K;const z=e9(U.floating,u.x),W=e9(U.floating,u.y);return a?{...K,transform:"translate("+z+"px, "+W+"px)",...Hse(U.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:z,top:W}},[r,a,U.floating,u.x,u.y]);return x.useMemo(()=>({...u,update:R,refs:M,elements:U,floatingStyles:B}),[u,R,M,U,B])}const Z$t=t=>{function e(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:o}=typeof t=="function"?t(r):t;return n&&e(n)?n.current!=null?J7({element:n.current,padding:o}).fn(r):{}:n?J7({element:n,padding:o}).fn(r):{}}}},Q$t=(t,e)=>({...H$t(t),options:[t,e]}),J$t=(t,e)=>({...W$t(t),options:[t,e]}),eIt=(t,e)=>({...Y$t(t),options:[t,e]}),tIt=(t,e)=>({...K$t(t),options:[t,e]}),rIt=(t,e)=>({...G$t(t),options:[t,e]}),nIt=(t,e)=>({...V$t(t),options:[t,e]}),oIt=(t,e)=>({...Z$t(t),options:[t,e]});var iIt="Arrow",Wse=x.forwardRef((t,e)=>{const{children:r,width:n=10,height:o=5,...i}=t;return h.jsx(Ye.svg,{...i,ref:e,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});Wse.displayName=iIt;var sIt=Wse;function Kse(t){const[e,r]=x.useState(void 0);return Il(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=t.offsetWidth,a=t.offsetHeight;r({width:s,height:a})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var Ij="Popper",[Gse,Ab]=$s(Ij),[aIt,Vse]=Gse(Ij),Yse=t=>{const{__scopePopper:e,children:r}=t,[n,o]=x.useState(null);return h.jsx(aIt,{scope:e,anchor:n,onAnchorChange:o,children:r})};Yse.displayName=Ij;var Xse="PopperAnchor",qse=x.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...o}=t,i=Vse(Xse,r),s=x.useRef(null),a=yt(e,s);return x.useEffect(()=>{i.onAnchorChange((n==null?void 0:n.current)||s.current)}),n?null:h.jsx(Ye.div,{...o,ref:a})});qse.displayName=Xse;var Pj="PopperContent",[lIt,cIt]=Gse(Pj),Zse=x.forwardRef((t,e)=>{var tt,_t,Je,Ot,st,qn;const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...m}=t,S=Vse(Pj,r),[y,v]=x.useState(null),b=yt(e,wr=>v(wr)),[$,P]=x.useState(null),E=Kse($),T=(E==null?void 0:E.width)??0,I=(E==null?void 0:E.height)??0,_=n+(i!=="center"?"-"+i:""),k=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],R=D.length>0,j={padding:k,boundary:D.filter(dIt),altBoundary:R},{refs:M,floatingStyles:U,placement:B,isPositioned:K,middlewareData:z}=q$t({strategy:"fixed",placement:_,whileElementsMounted:(...wr)=>z$t(...wr,{animationFrame:p==="always"}),elements:{reference:S.anchor},middleware:[Q$t({mainAxis:o+I,alignmentAxis:s}),l&&J$t({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?eIt():void 0,...j}),l&&tIt({...j}),rIt({...j,apply:({elements:wr,rects:In,availableWidth:Gt,availableHeight:Ur})=>{const{width:Ps,height:Zh}=In.reference,Ia=wr.floating.style;Ia.setProperty("--radix-popper-available-width",`${Gt}px`),Ia.setProperty("--radix-popper-available-height",`${Ur}px`),Ia.setProperty("--radix-popper-anchor-width",`${Ps}px`),Ia.setProperty("--radix-popper-anchor-height",`${Zh}px`)}}),$&&oIt({element:$,padding:a}),hIt({arrowWidth:T,arrowHeight:I}),f&&nIt({strategy:"referenceHidden",...j})]}),[W,J]=eae(B),oe=Dr(g);Il(()=>{K&&(oe==null||oe())},[K,oe]);const we=(tt=z.arrow)==null?void 0:tt.x,_e=(_t=z.arrow)==null?void 0:_t.y,Ge=((Je=z.arrow)==null?void 0:Je.centerOffset)!==0,[de,ht]=x.useState();return Il(()=>{y&&ht(window.getComputedStyle(y).zIndex)},[y]),h.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:K?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(Ot=z.transformOrigin)==null?void 0:Ot.x,(st=z.transformOrigin)==null?void 0:st.y].join(" "),...((qn=z.hide)==null?void 0:qn.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:h.jsx(lIt,{scope:r,placedSide:W,onArrowChange:P,arrowX:we,arrowY:_e,shouldHideArrow:Ge,children:h.jsx(Ye.div,{"data-side":W,"data-align":J,...m,ref:b,style:{...m.style,animation:K?void 0:"none"}})})})});Zse.displayName=Pj;var Qse="PopperArrow",uIt={top:"bottom",right:"left",bottom:"top",left:"right"},Jse=x.forwardRef(function(e,r){const{__scopePopper:n,...o}=e,i=cIt(Qse,n),s=uIt[i.placedSide];return h.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:h.jsx(sIt,{...o,ref:r,style:{...o.style,display:"block"}})})});Jse.displayName=Qse;function dIt(t){return t!==null}var hIt=t=>({name:"transformOrigin",options:t,fn(e){var S,y,v;const{placement:r,rects:n,middlewareData:o}=e,s=((S=o.arrow)==null?void 0:S.centerOffset)!==0,a=s?0:t.arrowWidth,l=s?0:t.arrowHeight,[c,u]=eae(r),d={start:"0%",center:"50%",end:"100%"}[u],f=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=s?d:`${f}px`,m=`${-l}px`):c==="top"?(g=s?d:`${f}px`,m=`${n.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=s?d:`${p}px`):c==="left"&&(g=`${n.floating.width+l}px`,m=s?d:`${p}px`),{data:{x:g,y:m}}}});function eae(t){const[e,r="center"]=t.split("-");return[e,r]}var Ej=Yse,Cj=qse,tae=Zse,rae=Jse,oC="rovingFocusGroup.onEntryFocus",fIt={bubbles:!1,cancelable:!0},kb="RovingFocusGroup",[Q2,nae,pIt]=Ib(kb),[gIt,oae]=$s(kb,[pIt]),[mIt,vIt]=gIt(kb),iae=x.forwardRef((t,e)=>h.jsx(Q2.Provider,{scope:t.__scopeRovingFocusGroup,children:h.jsx(Q2.Slot,{scope:t.__scopeRovingFocusGroup,children:h.jsx(yIt,{...t,ref:e})})}));iae.displayName=kb;var yIt=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=t,f=x.useRef(null),p=yt(e,f),g=vj(i),[m=null,S]=Gl({prop:s,defaultProp:a,onChange:l}),[y,v]=x.useState(!1),b=Dr(c),$=nae(r),P=x.useRef(!1),[E,T]=x.useState(0);return x.useEffect(()=>{const I=f.current;if(I)return I.addEventListener(oC,b),()=>I.removeEventListener(oC,b)},[b]),h.jsx(mIt,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:m,onItemFocus:x.useCallback(I=>S(I),[S]),onItemShiftTab:x.useCallback(()=>v(!0),[]),onFocusableItemAdd:x.useCallback(()=>T(I=>I+1),[]),onFocusableItemRemove:x.useCallback(()=>T(I=>I-1),[]),children:h.jsx(Ye.div,{tabIndex:y||E===0?-1:0,"data-orientation":n,...d,ref:p,style:{outline:"none",...t.style},onMouseDown:ue(t.onMouseDown,()=>{P.current=!0}),onFocus:ue(t.onFocus,I=>{const _=!P.current;if(I.target===I.currentTarget&&_&&!y){const k=new CustomEvent(oC,fIt);if(I.currentTarget.dispatchEvent(k),!k.defaultPrevented){const D=$().filter(B=>B.focusable),R=D.find(B=>B.active),j=D.find(B=>B.id===m),U=[R,j,...D].filter(Boolean).map(B=>B.ref.current);lae(U,u)}}P.current=!1}),onBlur:ue(t.onBlur,()=>v(!1))})})}),sae="RovingFocusGroupItem",aae=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,...s}=t,a=Qs(),l=i||a,c=vIt(sae,r),u=c.currentTabStopId===l,d=nae(r),{onFocusableItemAdd:f,onFocusableItemRemove:p}=c;return x.useEffect(()=>{if(n)return f(),()=>p()},[n,f,p]),h.jsx(Q2.ItemSlot,{scope:r,id:l,focusable:n,active:o,children:h.jsx(Ye.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...s,ref:e,onMouseDown:ue(t.onMouseDown,g=>{n?c.onItemFocus(l):g.preventDefault()}),onFocus:ue(t.onFocus,()=>c.onItemFocus(l)),onKeyDown:ue(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){c.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const m=xIt(g,c.orientation,c.dir);if(m!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=d().filter(v=>v.focusable).map(v=>v.ref.current);if(m==="last")y.reverse();else if(m==="prev"||m==="next"){m==="prev"&&y.reverse();const v=y.indexOf(g.currentTarget);y=c.loop?bIt(y,v+1):y.slice(v+1)}setTimeout(()=>lae(y))}})})})});aae.displayName=sae;var SIt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function wIt(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function xIt(t,e,r){const n=wIt(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return SIt[n]}function lae(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function bIt(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var $It=iae,IIt=aae,J2=["Enter"," "],PIt=["ArrowDown","PageUp","Home"],cae=["ArrowUp","PageDown","End"],EIt=[...PIt,...cae],CIt={ltr:[...J2,"ArrowRight"],rtl:[...J2,"ArrowLeft"]},_It={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Fm="Menu",[kg,TIt,AIt]=Ib(Fm),[yu,Ob]=$s(Fm,[AIt,Ab,oae]),Bm=Ab(),uae=oae(),[dae,Vl]=yu(Fm),[kIt,Um]=yu(Fm),hae=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:o,onOpenChange:i,modal:s=!0}=t,a=Bm(e),[l,c]=x.useState(null),u=x.useRef(!1),d=Dr(i),f=vj(o);return x.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),h.jsx(Ej,{...a,children:h.jsx(dae,{scope:e,open:r,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(kIt,{scope:e,onClose:x.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:s,children:n})})})};hae.displayName=Fm;var OIt="MenuAnchor",_j=x.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,o=Bm(r);return h.jsx(Cj,{...o,...n,ref:e})});_j.displayName=OIt;var Tj="MenuPortal",[MIt,fae]=yu(Tj,{forceMount:void 0}),pae=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:o}=t,i=Vl(Tj,e);return h.jsx(MIt,{scope:e,forceMount:r,children:h.jsx(Mi,{present:r||i.open,children:h.jsx(Lm,{asChild:!0,container:o,children:n})})})};pae.displayName=Tj;var Vo="MenuContent",[RIt,Aj]=yu(Vo),gae=x.forwardRef((t,e)=>{const r=fae(Vo,t.__scopeMenu),{forceMount:n=r.forceMount,...o}=t,i=Vl(Vo,t.__scopeMenu),s=Um(Vo,t.__scopeMenu);return h.jsx(kg.Provider,{scope:t.__scopeMenu,children:h.jsx(Mi,{present:n||i.open,children:h.jsx(kg.Slot,{scope:t.__scopeMenu,children:s.modal?h.jsx(jIt,{...o,ref:e}):h.jsx(DIt,{...o,ref:e})})})})}),jIt=x.forwardRef((t,e)=>{const r=Vl(Vo,t.__scopeMenu),n=x.useRef(null),o=yt(e,n);return x.useEffect(()=>{const i=n.current;if(i)return oj(i)},[]),h.jsx(kj,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ue(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),DIt=x.forwardRef((t,e)=>{const r=Vl(Vo,t.__scopeMenu);return h.jsx(kj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),kj=x.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,...m}=t,S=Vl(Vo,r),y=Um(Vo,r),v=Bm(r),b=uae(r),$=TIt(r),[P,E]=x.useState(null),T=x.useRef(null),I=yt(e,T,S.onContentChange),_=x.useRef(0),k=x.useRef(""),D=x.useRef(0),R=x.useRef(null),j=x.useRef("right"),M=x.useRef(0),U=g?Sb:x.Fragment,B=g?{as:Kc,allowPinchZoom:!0}:void 0,K=W=>{var tt,_t;const J=k.current+W,oe=$().filter(Je=>!Je.disabled),we=document.activeElement,_e=(tt=oe.find(Je=>Je.ref.current===we))==null?void 0:tt.textValue,Ge=oe.map(Je=>Je.textValue),de=YIt(Ge,J,_e),ht=(_t=oe.find(Je=>Je.textValue===de))==null?void 0:_t.ref.current;(function Je(Ot){k.current=Ot,window.clearTimeout(_.current),Ot!==""&&(_.current=window.setTimeout(()=>Je(""),1e3))})(J),ht&&setTimeout(()=>ht.focus())};x.useEffect(()=>()=>window.clearTimeout(_.current),[]),nj();const z=x.useCallback(W=>{var oe,we;return j.current===((oe=R.current)==null?void 0:oe.side)&&qIt(W,(we=R.current)==null?void 0:we.area)},[]);return h.jsx(RIt,{scope:r,searchRef:k,onItemEnter:x.useCallback(W=>{z(W)&&W.preventDefault()},[z]),onItemLeave:x.useCallback(W=>{var J;z(W)||((J=T.current)==null||J.focus(),E(null))},[z]),onTriggerLeave:x.useCallback(W=>{z(W)&&W.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:x.useCallback(W=>{R.current=W},[]),children:h.jsx(U,{...B,children:h.jsx(vb,{asChild:!0,trapped:o,onMountAutoFocus:ue(i,W=>{var J;W.preventDefault(),(J=T.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:h.jsx(Dm,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx($It,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:n,currentTabStopId:P,onCurrentTabStopIdChange:E,onEntryFocus:ue(l,W=>{y.isUsingKeyboardRef.current||W.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(tae,{role:"menu","aria-orientation":"vertical","data-state":Oae(S.open),"data-radix-menu-content":"",dir:y.dir,...v,...m,ref:I,style:{outline:"none",...m.style},onKeyDown:ue(m.onKeyDown,W=>{const oe=W.target.closest("[data-radix-menu-content]")===W.currentTarget,we=W.ctrlKey||W.altKey||W.metaKey,_e=W.key.length===1;oe&&(W.key==="Tab"&&W.preventDefault(),!we&&_e&&K(W.key));const Ge=T.current;if(W.target!==Ge||!EIt.includes(W.key))return;W.preventDefault();const ht=$().filter(tt=>!tt.disabled).map(tt=>tt.ref.current);cae.includes(W.key)&&ht.reverse(),GIt(ht)}),onBlur:ue(t.onBlur,W=>{W.currentTarget.contains(W.target)||(window.clearTimeout(_.current),k.current="")}),onPointerMove:ue(t.onPointerMove,Og(W=>{const J=W.target,oe=M.current!==W.clientX;if(W.currentTarget.contains(J)&&oe){const we=W.clientX>M.current?"right":"left";j.current=we,M.current=W.clientX}}))})})})})})})});gae.displayName=Vo;var LIt="MenuGroup",Oj=x.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return h.jsx(Ye.div,{role:"group",...n,ref:e})});Oj.displayName=LIt;var NIt="MenuLabel",mae=x.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return h.jsx(Ye.div,{...n,ref:e})});mae.displayName=NIt;var ex="MenuItem",r9="menu.itemSelect",Mb=x.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...o}=t,i=x.useRef(null),s=Um(ex,t.__scopeMenu),a=Aj(ex,t.__scopeMenu),l=yt(e,i),c=x.useRef(!1),u=()=>{const d=i.current;if(!r&&d){const f=new CustomEvent(r9,{bubbles:!0,cancelable:!0});d.addEventListener(r9,p=>n==null?void 0:n(p),{once:!0}),rj(d,f),f.defaultPrevented?c.current=!1:s.onClose()}};return h.jsx(vae,{...o,ref:l,disabled:r,onClick:ue(t.onClick,u),onPointerDown:d=>{var f;(f=t.onPointerDown)==null||f.call(t,d),c.current=!0},onPointerUp:ue(t.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:ue(t.onKeyDown,d=>{const f=a.searchRef.current!=="";r||f&&d.key===" "||J2.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Mb.displayName=ex;var vae=x.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:o,...i}=t,s=Aj(ex,r),a=uae(r),l=x.useRef(null),c=yt(e,l),[u,d]=x.useState(!1),[f,p]=x.useState("");return x.useEffect(()=>{const g=l.current;g&&p((g.textContent??"").trim())},[i.children]),h.jsx(kg.ItemSlot,{scope:r,disabled:n,textValue:o??f,children:h.jsx(IIt,{asChild:!0,...a,focusable:!n,children:h.jsx(Ye.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:c,onPointerMove:ue(t.onPointerMove,Og(g=>{n?s.onItemLeave(g):(s.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ue(t.onPointerLeave,Og(g=>s.onItemLeave(g))),onFocus:ue(t.onFocus,()=>d(!0)),onBlur:ue(t.onBlur,()=>d(!1))})})})}),FIt="MenuCheckboxItem",yae=x.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...o}=t;return h.jsx($ae,{scope:t.__scopeMenu,checked:r,children:h.jsx(Mb,{role:"menuitemcheckbox","aria-checked":tx(r)?"mixed":r,...o,ref:e,"data-state":jj(r),onSelect:ue(o.onSelect,()=>n==null?void 0:n(tx(r)?!0:!r),{checkForDefaultPrevented:!1})})})});yae.displayName=FIt;var Sae="MenuRadioGroup",[BIt,UIt]=yu(Sae,{value:void 0,onValueChange:()=>{}}),wae=x.forwardRef((t,e)=>{const{value:r,onValueChange:n,...o}=t,i=Dr(n);return h.jsx(BIt,{scope:t.__scopeMenu,value:r,onValueChange:i,children:h.jsx(Oj,{...o,ref:e})})});wae.displayName=Sae;var xae="MenuRadioItem",bae=x.forwardRef((t,e)=>{const{value:r,...n}=t,o=UIt(xae,t.__scopeMenu),i=r===o.value;return h.jsx($ae,{scope:t.__scopeMenu,checked:i,children:h.jsx(Mb,{role:"menuitemradio","aria-checked":i,...n,ref:e,"data-state":jj(i),onSelect:ue(n.onSelect,()=>{var s;return(s=o.onValueChange)==null?void 0:s.call(o,r)},{checkForDefaultPrevented:!1})})})});bae.displayName=xae;var Mj="MenuItemIndicator",[$ae,zIt]=yu(Mj,{checked:!1}),Iae=x.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...o}=t,i=zIt(Mj,r);return h.jsx(Mi,{present:n||tx(i.checked)||i.checked===!0,children:h.jsx(Ye.span,{...o,ref:e,"data-state":jj(i.checked)})})});Iae.displayName=Mj;var HIt="MenuSeparator",Pae=x.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return h.jsx(Ye.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});Pae.displayName=HIt;var WIt="MenuArrow",Eae=x.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,o=Bm(r);return h.jsx(rae,{...o,...n,ref:e})});Eae.displayName=WIt;var Rj="MenuSub",[KIt,Cae]=yu(Rj),_ae=t=>{const{__scopeMenu:e,children:r,open:n=!1,onOpenChange:o}=t,i=Vl(Rj,e),s=Bm(e),[a,l]=x.useState(null),[c,u]=x.useState(null),d=Dr(o);return x.useEffect(()=>(i.open===!1&&d(!1),()=>d(!1)),[i.open,d]),h.jsx(Ej,{...s,children:h.jsx(dae,{scope:e,open:n,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(KIt,{scope:e,contentId:Qs(),triggerId:Qs(),trigger:a,onTriggerChange:l,children:r})})})};_ae.displayName=Rj;var fp="MenuSubTrigger",Tae=x.forwardRef((t,e)=>{const r=Vl(fp,t.__scopeMenu),n=Um(fp,t.__scopeMenu),o=Cae(fp,t.__scopeMenu),i=Aj(fp,t.__scopeMenu),s=x.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=i,c={__scopeMenu:t.__scopeMenu},u=x.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return x.useEffect(()=>u,[u]),x.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(_j,{asChild:!0,...c,children:h.jsx(vae,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":Oae(r.open),...t,ref:mb(e,o.onTriggerChange),onClick:d=>{var f;(f=t.onClick)==null||f.call(t,d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ue(t.onPointerMove,Og(d=>{i.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!r.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:ue(t.onPointerLeave,Og(d=>{var p,g;u();const f=(p=r.content)==null?void 0:p.getBoundingClientRect();if(f){const m=(g=r.content)==null?void 0:g.dataset.side,S=m==="right",y=S?-5:5,v=f[S?"left":"right"],b=f[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+y,y:d.clientY},{x:v,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:v,y:f.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ue(t.onKeyDown,d=>{var p;const f=i.searchRef.current!=="";t.disabled||f&&d.key===" "||CIt[n.dir].includes(d.key)&&(r.onOpenChange(!0),(p=r.content)==null||p.focus(),d.preventDefault())})})})});Tae.displayName=fp;var Aae="MenuSubContent",kae=x.forwardRef((t,e)=>{const r=fae(Vo,t.__scopeMenu),{forceMount:n=r.forceMount,...o}=t,i=Vl(Vo,t.__scopeMenu),s=Um(Vo,t.__scopeMenu),a=Cae(Aae,t.__scopeMenu),l=x.useRef(null),c=yt(e,l);return h.jsx(kg.Provider,{scope:t.__scopeMenu,children:h.jsx(Mi,{present:n||i.open,children:h.jsx(kg.Slot,{scope:t.__scopeMenu,children:h.jsx(kj,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;s.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ue(t.onFocusOutside,u=>{u.target!==a.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ue(t.onEscapeKeyDown,u=>{s.onClose(),u.preventDefault()}),onKeyDown:ue(t.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=_It[s.dir].includes(u.key);d&&f&&(i.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});kae.displayName=Aae;function Oae(t){return t?"open":"closed"}function tx(t){return t==="indeterminate"}function jj(t){return tx(t)?"indeterminate":t?"checked":"unchecked"}function GIt(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function VIt(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function YIt(t,e,r){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=r?t.indexOf(r):-1;let s=VIt(t,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==r));const l=s.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==r?l:void 0}function XIt(t,e){const{x:r,y:n}=t;let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const a=e[i].x,l=e[i].y,c=e[s].x,u=e[s].y;l>n!=u>n&&r<(c-a)*(n-l)/(u-l)+a&&(o=!o)}return o}function qIt(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return XIt(r,e)}function Og(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Mae=hae,Rae=_j,jae=pae,Dae=gae,Lae=Oj,Nae=mae,Fae=Mb,Bae=yae,Uae=wae,zae=bae,Hae=Iae,Wae=Pae,Kae=Eae,Gae=_ae,Vae=Tae,Yae=kae,Dj="ContextMenu",[ZIt,TOt]=$s(Dj,[Ob]),sn=Ob(),[QIt,Xae]=ZIt(Dj),qae=t=>{const{__scopeContextMenu:e,children:r,onOpenChange:n,dir:o,modal:i=!0}=t,[s,a]=x.useState(!1),l=sn(e),c=Dr(n),u=x.useCallback(d=>{a(d),c(d)},[c]);return h.jsx(QIt,{scope:e,open:s,onOpenChange:u,modal:i,children:h.jsx(Mae,{...l,dir:o,open:s,onOpenChange:u,modal:i,children:r})})};qae.displayName=Dj;var Zae="ContextMenuTrigger",Qae=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,disabled:n=!1,...o}=t,i=Xae(Zae,r),s=sn(r),a=x.useRef({x:0,y:0}),l=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=x.useRef(0),u=x.useCallback(()=>window.clearTimeout(c.current),[]),d=f=>{a.current={x:f.clientX,y:f.clientY},i.onOpenChange(!0)};return x.useEffect(()=>u,[u]),x.useEffect(()=>void(n&&u()),[n,u]),h.jsxs(h.Fragment,{children:[h.jsx(Rae,{...s,virtualRef:l}),h.jsx(Ye.span,{"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,...o,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:n?t.onContextMenu:ue(t.onContextMenu,f=>{u(),d(f),f.preventDefault()}),onPointerDown:n?t.onPointerDown:ue(t.onPointerDown,Vy(f=>{u(),c.current=window.setTimeout(()=>d(f),700)})),onPointerMove:n?t.onPointerMove:ue(t.onPointerMove,Vy(u)),onPointerCancel:n?t.onPointerCancel:ue(t.onPointerCancel,Vy(u)),onPointerUp:n?t.onPointerUp:ue(t.onPointerUp,Vy(u))})]})});Qae.displayName=Zae;var JIt="ContextMenuPortal",Lj=t=>{const{__scopeContextMenu:e,...r}=t,n=sn(e);return h.jsx(jae,{...n,...r})};Lj.displayName=JIt;var Jae="ContextMenuContent",ele=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=Xae(Jae,r),i=sn(r),s=x.useRef(!1);return h.jsx(Dae,{...i,...n,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=t.onCloseAutoFocus)==null||l.call(t,a),!a.defaultPrevented&&s.current&&a.preventDefault(),s.current=!1},onInteractOutside:a=>{var l;(l=t.onInteractOutside)==null||l.call(t,a),!a.defaultPrevented&&!o.modal&&(s.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ele.displayName=Jae;var ePt="ContextMenuGroup",tle=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Lae,{...o,...n,ref:e})});tle.displayName=ePt;var tPt="ContextMenuLabel",rPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Nae,{...o,...n,ref:e})});rPt.displayName=tPt;var nPt="ContextMenuItem",rle=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Fae,{...o,...n,ref:e})});rle.displayName=nPt;var oPt="ContextMenuCheckboxItem",nle=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Bae,{...o,...n,ref:e})});nle.displayName=oPt;var iPt="ContextMenuRadioGroup",sPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Uae,{...o,...n,ref:e})});sPt.displayName=iPt;var aPt="ContextMenuRadioItem",lPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(zae,{...o,...n,ref:e})});lPt.displayName=aPt;var cPt="ContextMenuItemIndicator",uPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Hae,{...o,...n,ref:e})});uPt.displayName=cPt;var dPt="ContextMenuSeparator",hPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Wae,{...o,...n,ref:e})});hPt.displayName=dPt;var fPt="ContextMenuArrow",pPt=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Kae,{...o,...n,ref:e})});pPt.displayName=fPt;var gPt="ContextMenuSub",ole=t=>{const{__scopeContextMenu:e,children:r,onOpenChange:n,open:o,defaultOpen:i}=t,s=sn(e),[a,l]=Gl({prop:o,defaultProp:i,onChange:n});return h.jsx(Gae,{...s,open:a,onOpenChange:l,children:r})};ole.displayName=gPt;var mPt="ContextMenuSubTrigger",ile=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Vae,{...o,...n,ref:e})});ile.displayName=mPt;var vPt="ContextMenuSubContent",sle=x.forwardRef((t,e)=>{const{__scopeContextMenu:r,...n}=t,o=sn(r);return h.jsx(Yae,{...o,...n,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sle.displayName=vPt;function Vy(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var yPt=qae,SPt=Qae,wPt=Lj,xPt=ele,bPt=nle,Nj="DropdownMenu",[$Pt,AOt]=$s(Nj,[Ob]),an=Ob(),[IPt,ale]=$Pt(Nj),lle=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:o,defaultOpen:i,onOpenChange:s,modal:a=!0}=t,l=an(e),c=x.useRef(null),[u=!1,d]=Gl({prop:o,defaultProp:i,onChange:s});return h.jsx(IPt,{scope:e,triggerId:Qs(),triggerRef:c,contentId:Qs(),open:u,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(Mae,{...l,open:u,onOpenChange:d,dir:n,modal:a,children:r})})};lle.displayName=Nj;var cle="DropdownMenuTrigger",ule=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...o}=t,i=ale(cle,r),s=an(r);return h.jsx(Rae,{asChild:!0,...s,children:h.jsx(Ye.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:mb(e,i.triggerRef),onPointerDown:ue(t.onPointerDown,a=>{!n&&a.button===0&&a.ctrlKey===!1&&(i.onOpenToggle(),i.open||a.preventDefault())}),onKeyDown:ue(t.onKeyDown,a=>{n||(["Enter"," "].includes(a.key)&&i.onOpenToggle(),a.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});ule.displayName=cle;var PPt="DropdownMenuPortal",dle=t=>{const{__scopeDropdownMenu:e,...r}=t,n=an(e);return h.jsx(jae,{...n,...r})};dle.displayName=PPt;var hle="DropdownMenuContent",fle=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=ale(hle,r),i=an(r),s=x.useRef(!1);return h.jsx(Dae,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...n,ref:e,onCloseAutoFocus:ue(t.onCloseAutoFocus,a=>{var l;s.current||(l=o.triggerRef.current)==null||l.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:ue(t.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(s.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fle.displayName=hle;var EPt="DropdownMenuGroup",ple=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Lae,{...o,...n,ref:e})});ple.displayName=EPt;var CPt="DropdownMenuLabel",_Pt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Nae,{...o,...n,ref:e})});_Pt.displayName=CPt;var TPt="DropdownMenuItem",gle=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Fae,{...o,...n,ref:e})});gle.displayName=TPt;var APt="DropdownMenuCheckboxItem",mle=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Bae,{...o,...n,ref:e})});mle.displayName=APt;var kPt="DropdownMenuRadioGroup",OPt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Uae,{...o,...n,ref:e})});OPt.displayName=kPt;var MPt="DropdownMenuRadioItem",RPt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(zae,{...o,...n,ref:e})});RPt.displayName=MPt;var jPt="DropdownMenuItemIndicator",DPt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Hae,{...o,...n,ref:e})});DPt.displayName=jPt;var LPt="DropdownMenuSeparator",NPt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Wae,{...o,...n,ref:e})});NPt.displayName=LPt;var FPt="DropdownMenuArrow",BPt=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Kae,{...o,...n,ref:e})});BPt.displayName=FPt;var UPt=t=>{const{__scopeDropdownMenu:e,children:r,open:n,onOpenChange:o,defaultOpen:i}=t,s=an(e),[a=!1,l]=Gl({prop:n,defaultProp:i,onChange:o});return h.jsx(Gae,{...s,open:a,onOpenChange:l,children:r})},zPt="DropdownMenuSubTrigger",vle=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Vae,{...o,...n,ref:e})});vle.displayName=zPt;var HPt="DropdownMenuSubContent",yle=x.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,o=an(r);return h.jsx(Yae,{...o,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yle.displayName=HPt;var Fj=lle,Bj=ule,Rb=dle,Uj=fle,WPt=ple,KPt=gle,GPt=mle,VPt=UPt,YPt=vle,XPt=yle;function xa(){const t=F();return H("isReadonlyMode",()=>t.getInstanceState().isReadonly,[t])}const iC=[0,389,436,476,580,640,840,1023];var Kt=(t=>(t[t.ZERO=0]="ZERO",t[t.MOBILE_XXS=1]="MOBILE_XXS",t[t.MOBILE_XS=2]="MOBILE_XS",t[t.MOBILE_SM=3]="MOBILE_SM",t[t.MOBILE=4]="MOBILE",t[t.TABLET_SM=5]="TABLET_SM",t[t.TABLET=6]="TABLET",t[t.DESKTOP=7]="DESKTOP",t))(Kt||{});const Sle=ze.createContext(null);function qPt({forceMobile:t=!1,children:e}){const r=F(),n=H("breakpoint",()=>{const{width:o}=r.getViewportScreenBounds(),i=t?Kt.MOBILE_SM:iC.length-1;for(let s=0;s<i;s++)if(o>iC[s]&&o<=iC[s+1])return s;return i},[r]);return h.jsx(Sle.Provider,{value:n,children:e})}function bn(){const t=x.useContext(Sle);if(t===null)throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return t}const wle=typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,ZPt=wle?"⌘":"Ctrl",QPt=wle?"⌥":"Alt";function xle(t){return t===","?[","]:t.split(",")[0].split("").map(e=>{const r=e.replace(/\$/g,ZPt).replace(/\?/g,QPt).replace(/!/g,"⇧");return r[0].toUpperCase()+r.slice(1)})}function eA(t){return"— "+xle(t).join(" ")}function Wp({children:t,visibleOnMobileLayout:e=!1}){const r=bn();return!e&&r<Kt.MOBILE?null:h.jsx("kbd",{className:"tlui-kbd",children:xle(t).map((n,o)=>h.jsx("span",{children:n},o))})}const ble=x.createContext(null);function jb(){const t=x.useContext(ble);if(!t)throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return t}function qo({type:t,sourceId:e,children:r}){return h.jsx(ble.Provider,{value:{type:t,sourceId:e},children:r})}function Db({id:t,kbd:e,label:r,readonlyOk:n,onSelect:o,toggle:i=!1,disabled:s=!1,checked:a=!1}){const{type:l,sourceId:c}=jb(),u=xa(),d=Fe();if(u&&!n)return null;const f=_g(r,l),p=f?d(f):void 0;switch(l){case"menu":return h.jsxs(GPt,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:p,onSelect:g=>{o==null||o(c),Ue(g)},disabled:s,checked:a,children:[h.jsx(ds,{small:!0,icon:i?a?"toggle-on":"toggle-off":a?"check":"none"}),p&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),e&&h.jsx(Wp,{children:e})]});case"context-menu":return h.jsxs(bPt,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:p,onSelect:g=>{o(c),Ue(g)},disabled:s,checked:a,children:[h.jsx(ds,{small:!0,icon:i?a?"toggle-on":"toggle-off":a?"check":"none"}),p&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),e&&h.jsx(Wp,{children:e})]},t);default:return null}}function Di({actionId:t="",...e}){const n=vu()[t];return n?h.jsx(Db,{...n,...e}):null}function JPt(t){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...t,children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}function ba(t,e){const r=F(),n=x.useRef(!1),o=Br(),i=x.useCallback(a=>{n.current=a,r.run(()=>{a?(r.complete(),r.addOpenMenu(t)):r.updateInstanceState({openMenus:r.getOpenMenus().filter(l=>!l.startsWith(t))}),e==null||e(a)})},[r,t,e]),s=H("is menu open",()=>r.getOpenMenus().includes(t),[r,t]);return x.useEffect(()=>(n.current&&(o("open-menu",{source:"unknown",id:t}),r.addOpenMenu(t)),()=>{n.current&&(r.deleteOpenMenu(t),r.getOpenMenus().forEach(a=>{a.startsWith(t)&&(o("close-menu",{source:"unknown",id:t}),r.deleteOpenMenu(a))}),n.current=!1)}),[r,t,o]),[s,i]}function Yc({id:t,children:e,modal:r=!1,debugOpen:n=!1}){const[o,i]=ba(t);return h.jsx(Fj,{open:n||o,dir:"ltr",modal:r,onOpenChange:i,children:e})}function Xc({children:t,...e}){return h.jsx(Bj,{dir:"ltr",asChild:!0,onTouchEnd:r=>Ue(r),...e,children:t})}function qc({side:t="bottom",align:e="start",sideOffset:r=8,alignOffset:n=8,children:o}){const i=Sr();return h.jsx(Rb,{container:i,children:h.jsx(Uj,{className:"tlui-menu",side:t,sideOffset:r,align:e,alignOffset:n,collisionPadding:4,children:o})})}function eEt({id:t,children:e}){const[r,n]=ba(t);return h.jsx(VPt,{open:r,onOpenChange:n,children:e})}function tEt({id:t,label:e,title:r,disabled:n}){return h.jsx(YPt,{dir:"ltr",asChild:!0,disabled:n,children:h.jsxs(me,{"data-testid":t,type:"menu",className:"tlui-menu__submenu__trigger",disabled:n,title:r,children:[h.jsx(qt,{children:e}),h.jsx(Le,{icon:"chevron-right",small:!0})]})})}function rEt({id:t,alignOffset:e=-1,sideOffset:r=-4,size:n="small",children:o}){const i=Sr();return h.jsx(Rb,{container:i,children:h.jsx(XPt,{"data-testid":t,className:"tlui-menu tlui-menu__submenu__content",alignOffset:e,sideOffset:r,collisionPadding:4,"data-size":n,children:o})})}function nEt({children:t}){return h.jsx(WPt,{dir:"ltr",className:"tlui-menu__group",children:t})}function Mg({noClose:t,children:e}){return h.jsx(KPt,{dir:"ltr",asChild:!0,onClick:t?Ue:void 0,children:e})}function _r({disabled:t=!1,spinner:e=!1,readonlyOk:r=!1,id:n,kbd:o,label:i,icon:s,onSelect:a,noClose:l,isSelected:c}){const{type:u,sourceId:d}=jb(),f=Fe(),[p,g]=x.useState(!1);if(xa()&&!r)return null;const S=_g(i,u),y=o?eA(o):void 0,v=S?f(S):void 0,b=v&&y?`${v} ${y}`:v;switch(u){case"menu":return h.jsx(Mg,{children:h.jsxs(me,{type:"menu","data-testid":`${d}.${n}`,disabled:t,title:b,onClick:$=>{l&&Ue($),p?g(!1):a(d)},children:[h.jsx(qt,{children:v}),o&&h.jsx(Wp,{children:o})]})});case"context-menu":return t?null:h.jsxs(rle,{dir:"ltr",title:b,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${d}.${n}`,onSelect:$=>{l&&Ue($),p?g(!1):a(d)},children:[h.jsx("span",{className:"tlui-button__label",draggable:!1,children:v}),o&&h.jsx(Wp,{children:o}),e&&h.jsx(JPt,{})]});case"panel":return h.jsxs(me,{"data-testid":`${d}.${n}`,type:"menu",title:b,disabled:t,onClick:()=>a(d),children:[h.jsx(qt,{children:v}),s&&h.jsx(Le,{icon:s})]});case"small-icons":case"icons":return h.jsx(me,{"data-testid":`${d}.${n}`,type:"icon",title:b,disabled:t,onClick:()=>a(d),children:h.jsx(Le,{icon:s,small:u==="small-icons"})});case"keyboard-shortcuts":return o?h.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${d}.${n}`,children:[h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:v}),h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:h.jsx(Wp,{visibleOnMobileLayout:!0,children:o})})]}):(console.warn(`Menu item '${i}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return h.jsxs(me,{type:"low",onClick:()=>a(d),children:[h.jsx(Le,{icon:s}),h.jsx(qt,{children:v})]});case"toolbar":return h.jsx(me,{type:"tool","data-testid":`tools.${n}`,"aria-label":S,"data-value":n,onClick:()=>a("toolbar"),title:b,disabled:t,onTouchStart:$=>{Ue($),a("toolbar")},role:"radio","aria-checked":c?"true":"false",children:h.jsx(Le,{icon:s})});case"toolbar-overflow":return h.jsx(Mg,{"aria-label":i,children:h.jsx(me,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${n}`,title:b,disabled:t,role:"radio","aria-checked":c?"true":"false","data-value":n,children:h.jsx(Le,{icon:s})})});default:throw dr(u)}}function G({actionId:t="",...e}){const n=vu()[t];return n?h.jsx(_r,{...n,...e}):null}const $le=x.createContext(null);function oEt({overrides:t,children:e}){const r=F(),n=Br(),{addDialog:o}=mu(),i=Ose(),s=x.useMemo(()=>{const a=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(c){r.setCurrentTool("select"),n("select-tool",{source:c,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(c){r.setCurrentTool("hand"),n("select-tool",{source:c,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(c){r.setCurrentTool("eraser"),n("select-tool",{source:c,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(c){r.setCurrentTool("draw"),n("select-tool",{source:c,id:"draw"})}},...[...pi.values].map(c=>({id:c,label:`tool.${c}`,meta:{geo:c},kbd:c==="rectangle"?"r":c==="ellipse"?"o":void 0,icon:"geo-"+c,onSelect(u){r.run(()=>{r.setStyleForNextShapes(pi,c),r.setCurrentTool("geo"),n("select-tool",{source:u,id:`geo-${c}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(c){r.setCurrentTool("arrow"),n("select-tool",{source:c,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(c){r.setCurrentTool("line"),n("select-tool",{source:c,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(c){r.setCurrentTool("frame"),n("select-tool",{source:c,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(c){r.setCurrentTool("text"),n("select-tool",{source:c,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(c){i(),n("select-tool",{source:c,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(c){r.setCurrentTool("note"),n("select-tool",{source:c,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(c){r.setCurrentTool("laser"),n("select-tool",{source:c,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(c){o({component:ase}),n("select-tool",{source:c,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(c){r.setCurrentTool("highlight"),n("select-tool",{source:c,id:"highlight"})}}];a.push();const l=Object.fromEntries(a.map(c=>[c.id,c]));return t?t(r,l,{insertMedia:i}):l},[t,r,n,i,o]);return h.jsx($le.Provider,{value:s,children:e})}function zj(){const t=x.useContext($le);if(!t)throw new Error("useTools must be used within a ToolProvider");return t}function Cn({toolId:t="",...e}){const n=zj()[t];return n?h.jsx(_r,{...n,...e}):null}function iEt({children:t}){const e=F();return H("shouldDisplayHandles",()=>{if(e.isInAny("select.idle","select.pointing_handle","select.pointing_shape"))return!0;if(e.isInAny("select.editing_shape")){const n=e.getOnlySelectedShape();return n&&e.isShapeOfType(n,"note")}return!1},[e])?h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:t}):null}const{PI:sEt}=Math,Ud=sEt+1e-4;function Ile(t,e={}){const{size:r=16,smoothing:n=.5}=e;if(t.length===0||r<=0)return{left:[],right:[]};const o=t[0],i=t[t.length-1],s=i.runningLength,a=Math.pow(r*n,2),l=[],c=[];let u=t[0].vector,d=t[0].point,f=d,p=d,g=f,m=!1,S;for(let y=0;y<t.length;y++){S=t[y];const{point:v,vector:b}=t[y],$=S.vector.dpr(u),P=(y<t.length-1?t[y+1]:t[y]).vector,E=y<t.length-1?P.dpr(S.vector):1,T=$<0&&!m,I=E!==null&&E<.2;if(T||I){if(E>-.62&&s-S.runningLength>S.radius){const k=u.clone().mul(S.radius);u.clone().cpr(P)<0?(p=w.Add(v,k),g=w.Sub(v,k)):(p=w.Sub(v,k),g=w.Add(v,k)),l.push(p),c.push(g)}else{const k=u.clone().mul(S.radius).per(),D=w.Sub(S.input,k);for(let R=1/13,j=0;j<1;j+=R)p=w.RotWith(D,S.input,Ud*j),l.push(p),g=w.RotWith(D,S.input,Ud+Ud*-j),c.push(g)}d=p,f=g,I&&(m=!0);continue}if(m=!1,S===o||S===i){const k=w.Per(b).mul(S.radius);l.push(w.Sub(v,k)),c.push(w.Add(v,k));continue}const _=w.Lrp(P,b,E).per().mul(S.radius);p=w.Sub(v,_),(y<=1||w.Dist2(d,p)>a)&&(l.push(p),d=p),g=w.Add(v,_),(y<=1||w.Dist2(f,g)>a)&&(c.push(g),f=g),u=b}return{left:l,right:c}}function Hj(t,e={}){const{size:r=16,start:n={},end:o={},last:i=!1}=e,{cap:s=!0}=n,{cap:a=!0}=o;if(t.length===0||r<=0)return[];const l=t[0],c=t[t.length-1],u=c.runningLength,d=n.taper===!1?0:n.taper===!0?Math.max(r,u):n.taper,f=o.taper===!1?0:o.taper===!0?Math.max(r,u):o.taper,{left:p,right:g}=Ile(t,e),m=l.point,S=t.length>1?t[t.length-1].point:w.AddXY(l.point,1,1);if(t.length===1&&(!(d||f)||i)){const $=w.Add(m,w.Sub(m,S).uni().per().mul(-l.radius)),P=[];for(let E=1/13,T=E;T<=1;T+=E)P.push(w.RotWith($,m,Ud*2*T));return P}const y=[];if(!(d||f&&t.length===1))if(s)for(let $=1/8,P=$;P<=1;P+=$){const E=w.RotWith(g[0],m,Ud*P);y.push(E)}else{const $=w.Sub(p[0],g[0]),P=w.Mul($,.5),E=w.Mul($,.51);y.push(w.Sub(m,P),w.Sub(m,E),w.Add(m,E),w.Add(m,P))}const v=[],b=c.vector.clone().per().neg();if(f||d&&t.length===1)v.push(S);else if(a){const $=w.Add(S,w.Mul(b,c.radius));for(let P=1/29,E=P;E<1;E+=P)v.push(w.RotWith($,S,Ud*3*E))}else v.push(w.Add(S,w.Mul(b,c.radius)),w.Add(S,w.Mul(b,c.radius*.99)),w.Sub(S,w.Mul(b,c.radius*.99)),w.Sub(S,w.Mul(b,c.radius)));return p.concat(v,g.reverse(),y)}const aEt=.025,lEt=.01;function fs(t,e={}){var S;const{streamline:r=.5,size:n=16,simulatePressure:o=!1}=e;if(t.length===0)return[];const i=.15+(1-r)*.85;let s=t.map(w.From),a=0;if(!o){let y=s[0];for(;y&&!(y.z>=aEt);)s.shift(),y=s[0]}if(!o){let y=s[s.length-1];for(;y&&!(y.z>=lEt);)s.pop(),y=s[s.length-1]}if(s.length===0)return[{point:w.From(t[0]),input:w.From(t[0]),pressure:o?.5:.15,vector:new w(1,1),distance:0,runningLength:0,radius:1}];let l=s[1];for(;l&&!(w.Dist2(l,s[0])>(n/3)**2);)s[0].z=Math.max(s[0].z,l.z),s.splice(1,1),l=s[1];const c=s.pop();for(l=s[s.length-1];l&&!(w.Dist2(l,c)>(n/3)**2);)s.pop(),l=s[s.length-1],a++;s.push(c);const u=e.last||!e.simulatePressure||s.length>1&&w.Dist2(s[s.length-1],s[s.length-2])<n**2||a>0;if(s.length===2&&e.simulatePressure){const y=s[1];s=s.slice(0,-1);for(let v=1;v<5;v++){const b=w.Lrp(s[0],y,v/4);b.z=(s[0].z+(y.z-s[0].z))*v/4,s.push(b)}}const d=[{point:s[0],input:s[0],pressure:o?.5:s[0].z,vector:new w(1,1),distance:0,runningLength:0,radius:1}];let f=0,p=d[0],g,m;u&&r>0&&s.push(s[s.length-1].clone());for(let y=1,v=s.length;y<v;y++)g=!i||e.last&&y===v-1?s[y].clone():s[y].clone().lrp(p.point,1-i),!p.point.equals(g)&&(m=w.Dist(g,p.point),f+=m,!(y<4&&f<n)&&(p={input:s[y],point:g,pressure:o?.5:s[y].z,vector:w.Sub(p.point,g).uni(),distance:m,runningLength:f,radius:1},d.push(p)));if((S=d[1])!=null&&S.vector&&(d[0].vector=d[1].vector.clone()),f<1){const y=Math.max(.5,...d.map(v=>v.pressure));d.forEach(v=>v.pressure=y)}return d}const{min:Ra}=Math,sC=.275;function Lb(t,e){const{size:r=16,thinning:n=.5,simulatePressure:o=!0,easing:i=S=>S,start:s={},end:a={}}=e,{easing:l=pr.easeOutQuad}=s,{easing:c=pr.easeOutCubic}=a,u=t[t.length-1].runningLength;let d,f=t[0].pressure,p;if(!o&&u<r){const S=t.reduce((y,v)=>Math.max(y,v.pressure),.5);return t.forEach(y=>{y.pressure=S,y.radius=r*i(.5-n*(.5-y.pressure))}),t}else{let S;for(let y=0,v=t.length;y<v&&(p=t[y],!(p.runningLength>r*5));y++){const b=Ra(1,p.distance/r);if(o){const $=Ra(1,1-b);S=Ra(1,f+($-f)*(b*sC))}else S=Ra(1,f+(p.pressure-f)*.5);f=f+(S-f)*.5}for(let y=0;y<t.length;y++){if(p=t[y],n){let{pressure:v}=p;const b=Ra(1,p.distance/r);if(o){const $=Ra(1,1-b);v=Ra(1,f+($-f)*(b*sC))}else v=Ra(1,f+(v-f)*(b*sC));p.radius=r*i(.5-n*(.5-v)),f=v}else p.radius=r/2;d===void 0&&(d=p.radius)}}const g=s.taper===!1?0:s.taper===!0?Math.max(r,u):s.taper,m=a.taper===!1?0:a.taper===!0?Math.max(r,u):a.taper;if(g||m)for(let S=0;S<t.length;S++){p=t[S];const{runningLength:y}=p,v=y<g?l(y/g):1,b=u-y<m?c((u-y)/m):1;p.radius=Math.max(.01,p.radius*Math.min(v,b))}return t}function cEt(t,e={}){return Hj(Lb(fs(t,e),e),e)}function n9({scribble:t,zoom:e,color:r,opacity:n,className:o}){if(!t.points.length)return null;const i=cEt(t.points,{size:t.size/e,start:{taper:t.taper,easing:pr.linear},last:t.state==="stopping",simulatePressure:!1,streamline:.32});let s;if(i.length<4){const a=t.size/e/2,{x:l,y:c}=t.points[t.points.length-1];s=`M ${l-a},${c} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else s=dO(i);return h.jsx("svg",{className:o&&pe("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:s,fill:r??`var(--color-${t.color})`,opacity:n??t.opacity})})}const uEt=({bounds:t,rotation:e})=>{const r=F();return H("should display",()=>r.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[r])?h.jsx(NV,{bounds:t,rotation:e}):null};function dEt({size:t,width:e,height:r,hideAlternateHandles:n}){const o=N(t/3),i=o/2;return h.jsxs("svg",{className:"tl-overlays__item",children:[h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
352
|
-
${N(0-i)},${N(t)}
|
|
353
|
-
${N(0-i)},${N(0-i)}
|
|
354
|
-
${N(t)},${N(0-i)}`,strokeWidth:o,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),h.jsx("line",{className:pe("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:N(e/2-t),y1:N(0-i),x2:N(e/2+t),y2:N(0-i),strokeWidth:o,"data-testid":"selection.crop.top","aria-label":"top handle"}),h.jsx("polyline",{className:pe("tl-corner-crop-handle",{"tl-hidden":n}),points:`
|
|
355
|
-
${N(e-t)},${N(0-i)}
|
|
356
|
-
${N(e+i)},${N(0-i)}
|
|
357
|
-
${N(e+i)},${N(t)}`,strokeWidth:o,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),h.jsx("line",{className:pe("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:N(e+i),y1:N(r/2-t),x2:N(e+i),y2:N(r/2+t),strokeWidth:o,"data-testid":"selection.crop.right","aria-label":"right handle"}),h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
358
|
-
${N(e+i)},${N(r-t)}
|
|
359
|
-
${N(e+i)},${N(r+i)}
|
|
360
|
-
${N(e-t)},${N(r+i)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),h.jsx("line",{className:pe("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:N(e/2-t),y1:N(r+i),x2:N(e/2+t),y2:N(r+i),strokeWidth:o,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),h.jsx("polyline",{className:pe("tl-corner-crop-handle",{"tl-hidden":n}),points:`
|
|
361
|
-
${N(0+t)},${N(r+i)}
|
|
362
|
-
${N(0-i)},${N(r+i)}
|
|
363
|
-
${N(0-i)},${N(r-t)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),h.jsx("line",{className:pe("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:N(0-i),y1:N(r/2-t),x2:N(0-i),y2:N(r/2+t),strokeWidth:o,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const hEt=yr(function({bounds:e,rotation:r}){const n=F(),o=x.useRef(null),i=xa(),s=Wi("top"),a=Wi("right"),l=Wi("bottom"),c=Wi("left"),u=Wi("top_left"),d=Wi("top_right"),f=Wi("bottom_right"),p=Wi("bottom_left"),g=!n.getIsMenuOpen()&&n.getInstanceState().cursor.type==="default",m=n.getInstanceState().isCoarsePointer,S=n.getOnlySelectedShape(),y=S&&n.isShapeOrAncestorLocked(S),v=S?n.getShapeUtil(S).expandSelectionOutlinePx(S):0;if(Th(o,e==null?void 0:e.x,e==null?void 0:e.y,1,n.getSelectionRotation(),{x:-v,y:-v}),!e)return null;e=e.clone().expandBy(v).zeroFix();const b=n.getZoomLevel(),$=n.getInstanceState().isChangingStyle,P=e.width,E=e.height,T=8/b,I=P<T*2,_=E<T*2,k=P<T*4,D=E<T*4,R=P<T*5,j=E<T*5,M=m?1.75:1,U=6/b*M,B=(k?U/2:U)*(M*.75),K=(D?U/2:U)*(M*.75),z=(S?!n.getShapeUtil(S).hideSelectionBoundsFg(S):!0)&&!$;let W=z&&n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_canvas","select.pointing_selection","select.pointing_shape","select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle","select.pointing_resize_handle")||z&&n.isIn("select.resizing")&&S&&n.isShapeOfType(S,"text");S&&W&&n.environment.isFirefox&&n.isShapeOfType(S,"embed")&&(W=!1);const J=n.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!$&&!i,oe=n.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!$&&!i,we=!m&&!(I||_)&&(oe||J)&&(S?!n.getShapeUtil(S).hideRotateHandle(S):!0)&&!y,_e=m&&(!k||!D)&&(oe||J)&&(S?!n.getShapeUtil(S).hideRotateHandle(S):!0)&&!y,Ge=oe&&(S?n.getShapeUtil(S).canResize(S)&&!n.getShapeUtil(S).hideResizeHandles(S):!0)&&!J&&!y,de=I||_,ht=I&&_,tt=R||j,_t=Ge||J,Je=!we,Ot=!oe||!_e,st=!oe||!_t,qn=!oe||!_t||de,wr=!oe||!_t||de,In=!oe||!_t||ht&&!J;let Gt=!0,Ur=!0;if(J)Gt=tt,Ur=tt;else if(Ge){Gt=de||ht||m;const Ia=m&&S&&S.type==="text";Ur=Gt&&!Ia}const Ps=Math.min(24/b,E-K*3),Zh=oe&&m&&S&&n.isShapeOfType(S,"text")&&Ps*b>=4;return h.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsxs("g",{ref:o,children:[W&&h.jsx("rect",{className:"tl-selection__fg__outline",width:N(P),height:N(E)}),h.jsx(Yy,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:U,corner:"top_left_rotate",cursor:g?Qn("nwse-rotate",r):void 0,isHidden:Je}),h.jsx(Yy,{"data-testid":"selection.rotate.top-right",cx:P+U*3,cy:0,targetSize:U,corner:"top_right_rotate",cursor:g?Qn("nesw-rotate",r):void 0,isHidden:Je}),h.jsx(Yy,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:E+U*3,targetSize:U,corner:"bottom_left_rotate",cursor:g?Qn("swne-rotate",r):void 0,isHidden:Je}),h.jsx(Yy,{"data-testid":"selection.rotate.bottom-right",cx:P+U*3,cy:E+U*3,targetSize:U,corner:"bottom_right_rotate",cursor:g?Qn("senw-rotate",r):void 0,isHidden:Je}),h.jsx(pEt,{"data-testid":"selection.rotate.mobile",cx:k?-U*1.5:P/2,cy:k?E/2:-U*1.5,size:T,isHidden:Ot}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":Gt}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:N(0-(D?K*2:K)),width:N(P),height:N(Math.max(1,K*2)),style:g?{cursor:Qn("ns-resize",r)}:void 0,...s}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":Ur}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:N(P-(k?0:B)),y:0,height:N(E),width:N(Math.max(1,B*2)),style:g?{cursor:Qn("ew-resize",r)}:void 0,...a}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":Gt}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:N(E-(D?0:K)),width:N(P),height:N(Math.max(1,K*2)),style:g?{cursor:Qn("ns-resize",r)}:void 0,...l}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":Ur}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:N(0-(k?B*2:B)),y:0,height:N(E),width:N(Math.max(1,B*2)),style:g?{cursor:Qn("ew-resize",r)}:void 0,...c}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":st}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:N(0-(k?B*2:B*1.5)),y:N(0-(D?K*2:K*1.5)),width:N(B*3),height:N(K*3),style:g?{cursor:Qn("nwse-resize",r)}:void 0,...u}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":qn}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:N(P-(k?0:B*1.5)),y:N(0-(D?K*2:K*1.5)),width:N(B*3),height:N(K*3),style:g?{cursor:Qn("nesw-resize",r)}:void 0,...d}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":In}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:N(P-(k?B:B*1.5)),y:N(E-(D?K:K*1.5)),width:N(B*3),height:N(K*3),style:g?{cursor:Qn("nwse-resize",r)}:void 0,...f}),h.jsx("rect",{className:pe("tl-transparent",{"tl-hidden":wr}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:N(0-(k?B*3:B*1.5)),y:N(E-(D?0:K*1.5)),width:N(B*3),height:N(K*3),style:g?{cursor:Qn("nesw-resize",r)}:void 0,...p}),Ge&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.resize.top-left",className:pe("tl-corner-handle",{"tl-hidden":st}),"aria-label":"top_left handle",x:N(0-T/2),y:N(0-T/2),width:N(T),height:N(T)}),h.jsx("rect",{"data-testid":"selection.resize.top-right",className:pe("tl-corner-handle",{"tl-hidden":qn}),"aria-label":"top_right handle",x:N(P-T/2),y:N(0-T/2),width:N(T),height:N(T)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:pe("tl-corner-handle",{"tl-hidden":In}),"aria-label":"bottom_right handle",x:N(P-T/2),y:N(E-T/2),width:N(T),height:N(T)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:pe("tl-corner-handle",{"tl-hidden":wr}),"aria-label":"bottom_left handle",x:N(0-T/2),y:N(E-T/2),width:N(T),height:N(T)})]}),Zh&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:N(0-T/4),y:N(E/2-Ps/2),rx:T/4,width:N(T/2),height:N(Ps)}),h.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:T/4,x:N(P-T/4),y:N(E/2-Ps/2),width:N(T/2),height:N(Ps)})]}),J&&h.jsx(dEt,{size:T,width:P,height:E,hideAlternateHandles:tt})]})})}),Yy=function({cx:e,cy:r,targetSize:n,corner:o,cursor:i,isHidden:s,"data-testid":a}){const l=Wi(o);return h.jsx("rect",{className:pe("tl-transparent","tl-rotate-corner",{"tl-hidden":s}),"data-testid":a,"aria-label":`${o} target`,pointerEvents:"all",x:N(e-n*3),y:N(r-n*3),width:N(Math.max(1,n*3)),height:N(Math.max(1,n*3)),cursor:i,...l})},fEt=Math.sqrt(Math.PI),pEt=function({cx:e,cy:r,size:n,isHidden:o,"data-testid":i}){const s=Wi("mobile_rotate"),a=F(),l=H("zoom level",()=>a.getZoomLevel(),[a]),c=Math.max(14*(1/l),20/Math.max(1,l));return h.jsxs("g",{children:[h.jsx("circle",{"data-testid":i,pointerEvents:"all",className:pe("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":o}),cx:e,cy:r,r:c,...s}),h.jsx("circle",{className:pe("tl-mobile-rotate__fg",{"tl-hidden":o}),cx:e,cy:r,r:n/fEt})]})};function gEt(){const t=F();return H("is in a valid select state",()=>t.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle"),[t])?h.jsx(FV,{}):null}function tA(t,e,r){const{arrowheadStart:n,arrowheadEnd:o}=e.props,i=yd(t,e,r),s=i.start.clone(),a=i.end.clone(),l=w.Med(s,a);if(w.Equals(s,a))return{bindings:r,isStraight:!0,start:{handle:s,point:s,arrowhead:e.props.arrowheadStart},end:{handle:a,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:!1,length:0};const c=w.Sub(a,s).uni(),u=rx(t,e,"start"),d=rx(t,e,"end"),f=t.getShapePageTransform(e);o9(a,i.start,f,d),o9(s,i.end,f,u);let p=0,g=0,m=0,S=0,y=Sd*e.props.scale;const v=u&&d&&u.shape===d.shape,b=u&&d?Wj(t,u.shape.id,d.shape.id):"safe";b==="safe"&&u&&d&&!v&&!u.isExact&&!d.isExact&&(d.didIntersect&&!u.didIntersect?u.isClosed&&s.setTo(a.clone().add(c.clone().mul(Sd*e.props.scale))):d.didIntersect||d.isClosed&&a.setTo(s.clone().sub(c.clone().mul(Sd*e.props.scale))));const $=w.Sub(a,s),P=w.Len($)?$.uni():w.From($),E=!w.Equals(P,c);v||(b!=="start-contains-end"&&u&&n!=="none"&&!u.isExact&&(m=ts[e.props.size]/2+("size"in u.shape.props?ts[u.shape.props.size]/2:0),p=(nx+m)*e.props.scale,y+=m*e.props.scale),b!=="end-contains-start"&&d&&o!=="none"&&!d.isExact&&(S=ts[e.props.size]/2+("size"in d.shape.props?ts[d.shape.props.size]/2:0),g=(nx+S)*e.props.scale,y+=S*e.props.scale));const T=s.clone().add(P.clone().mul(p*(E?-1:1))),I=a.clone().sub(P.clone().mul(g*(E?-1:1)));w.DistMin(T,I,y)&&(p!==0&&g!==0?(p*=-1.5,g*=-1.5):p!==0?p*=-1:g!==0&&(g*=-1)),s.add(P.clone().mul(p*(E?-1:1))),a.sub(P.clone().mul(g*(E?-1:1))),E?(u&&d&&a.setTo(w.Add(s,P.clone().mul(-Sd*e.props.scale))),l.setTo(w.Med(i.start,i.end))):l.setTo(w.Med(s,a));const _=w.Dist(s,a);return{bindings:r,isStraight:!0,start:{handle:i.start,point:s,arrowhead:e.props.arrowheadStart},end:{handle:i.end,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:_>0,length:_}}function o9(t,e,r,n){if(n===void 0||n.isExact)return;const o=Q.applyToPoint(r,e),i=Q.applyToPoint(r,t),s=Q.applyToPoint(Q.Inverse(n.transform),o),a=Q.applyToPoint(Q.Inverse(n.transform),i),l=n.isClosed,u=(l?vO:LPe)(s,a,n.outline);let d;if(u!==null&&(d=u.sort((g,m)=>w.Dist2(g,s)-w.Dist2(m,s))[0]??(l?void 0:a)),d===void 0)return;const f=Q.applyToPoint(n.transform,d),p=Q.applyToPoint(Q.Inverse(r),f);t.setTo(p),n.didIntersect=!0}function mEt(t,e,r){const{arrowheadEnd:n,arrowheadStart:o}=e.props,i=e.props.bend;if(Math.abs(i)>Math.abs(e.props.bend*(xEt*e.props.scale)))return tA(t,e,r);const s=yd(t,e,r),a=w.Med(s.start,s.end),l=w.Sub(s.end,s.start),c=w.Len(l)?l.uni():w.From(l),u=w.Add(a,c.per().mul(-i)),d=rx(t,e,"start"),f=rx(t,e,"end"),p=s.start.clone(),g=s.end.clone(),m=u.clone();if(w.Equals(p,g))return{bindings:r,isStraight:!0,start:{handle:p,point:p,arrowhead:e.props.arrowheadStart},end:{handle:g,point:g,arrowhead:e.props.arrowheadEnd},middle:m,isValid:!1,length:0};const S=e.props.bend<0,y=S?Jg:vV,v=i9(p,g,m),b=w.Angle(v.center,p),$=w.Angle(v.center,g),P=y(b,$);if(v.length===0||v.size===0||!hN(v.length)||!hN(v.size))return tA(t,e,r);const E=p.clone(),T=g.clone(),I=m.clone(),_=t.getShapePageTransform(e);let k=0,D=0,R=Sd*e.props.scale;if(d&&!d.isExact){const J=Q.applyToPoint(_,E),oe=Q.applyToPoint(_,v.center),we=Q.applyToPoint(_,T),_e=Q.Inverse(d.transform),Ge=Q.applyToPoint(_e,J),de=Q.applyToPoint(_e,oe),ht=Q.applyToPoint(_e,we),{isClosed:tt}=d,_t=tt?cT:MN;let Je,Ot=_t(de,v.radius,d.outline);if(Ot){const st=de.angle(Ge),qn=de.angle(ht),wr=y(st,qn);Ot=Ot.filter(Gt=>y(st,de.angle(Gt))<=wr);const In=wr*.25;Ot.sort(tt?(Gt,Ur)=>Math.abs(y(st,de.angle(Gt))-In)<Math.abs(y(st,de.angle(Ur))-In)?-1:1:(Gt,Ur)=>y(st,de.angle(Gt))<y(st,de.angle(Ur))?-1:1),Je=Ot[0]??(tt?void 0:Ge)}else Je=tt?void 0:Ge;if(Je&&(E.setTo(t.getPointInShapeSpace(e,Q.applyToPoint(d.transform,Je))),d.didIntersect=!0,o!=="none")){const st=ts[e.props.size]/2+("size"in d.shape.props?ts[d.shape.props.size]/2:0);k=(nx+st)*e.props.scale,R+=st*e.props.scale}}if(f&&!f.isExact){const J=Q.applyToPoint(_,E),oe=Q.applyToPoint(_,T),we=Q.applyToPoint(_,v.center),_e=Q.Inverse(f.transform),Ge=Q.applyToPoint(_e,J),de=Q.applyToPoint(_e,we),ht=Q.applyToPoint(_e,oe),tt=f.isClosed,_t=tt?cT:MN;let Je,Ot=_t(de,v.radius,f.outline);if(Ot){const st=de.angle(Ge),qn=de.angle(ht),wr=y(st,qn),In=wr*.75;Ot=Ot.filter(Gt=>y(st,de.angle(Gt))<=wr),Ot.sort(tt?(Gt,Ur)=>Math.abs(y(st,de.angle(Gt))-In)<Math.abs(y(st,de.angle(Ur))-In)?-1:1:(Gt,Ur)=>y(st,de.angle(Gt))<y(st,de.angle(Ur))?-1:1),Ot[0]?Je=Ot[0]:Je=tt?void 0:ht}else Je=tt?void 0:ht;if(Je&&(T.setTo(t.getPointInShapeSpace(e,Q.applyToPoint(f.transform,Je))),f.didIntersect=!0,n!=="none")){const st=ts[e.props.size]/2+("size"in f.shape.props?ts[f.shape.props.size]/2:0);D=(nx+st)*e.props.scale,R+=st*e.props.scale}}let j=w.Angle(v.center,E),M=w.Angle(v.center,T),U=y(j,M),B=U*v.radius;const K=E.clone(),z=T.clone();if(k!==0&&K.setTo(v.center).add(w.FromAngle(j+U*(k/B*(S?1:-1))).mul(v.radius)),D!==0&&z.setTo(v.center).add(w.FromAngle(M+U*(D/B*(S?-1:1))).mul(v.radius)),w.DistMin(K,z,R)&&(k!==0&&D!==0?(k*=-1.5,D*=-1.5):k!==0?k*=-2:D!==0&&(D*=-2)),k!==0&&E.setTo(v.center).add(w.FromAngle(j+U*(k/B*(S?1:-1))).mul(v.radius)),D!==0&&T.setTo(v.center).add(w.FromAngle(M+U*(D/B*(S?-1:1))).mul(v.radius)),d&&f&&!d.isExact&&!f.isExact){j=w.Angle(v.center,E),M=w.Angle(v.center,T),U=y(j,M),B=U*v.radius;const J=Wj(t,d.shape.id,f.shape.id);J==="double-bound"&&B<30?(E.setTo(p),T.setTo(g),I.setTo(m)):J==="safe"&&(d&&!d.didIntersect&&E.setTo(p),(f&&!f.didIntersect||y(b,j)>y(b,M))&&T.setTo(v.center).add(w.FromAngle(j+U*(Math.min(.9,Sd*e.props.scale/B)*(S?1:-1))).mul(v.radius)))}vEt(v.center,v.radius,E,T,I,P,S),E.equals(T)&&(E.setTo(I.clone().addXY(1,1)),T.setTo(I.clone().subXY(1,1))),p.setTo(E),g.setTo(T),m.setTo(I);const W=i9(p,g,m);return{bindings:r,isStraight:!1,start:{point:p,handle:s.start,arrowhead:e.props.arrowheadStart},end:{point:g,handle:s.end,arrowhead:e.props.arrowheadEnd},middle:m,handleArc:v,bodyArc:W,isValid:W.length!==0&&isFinite(W.center.x)&&isFinite(W.center.y)}}function i9(t,e,r){const n=lO(t,e,r)??w.Med(t,e),o=w.Dist(n,t),i=+w.Clockwise(t,r,e),s=((t.y-e.y)**2+(t.x-e.x)**2)**.5,a=((e.y-r.y)**2+(e.x-r.x)**2)**.5,l=((r.y-t.y)**2+(r.x-t.x)**2)**.5,c=Math.acos((a*a+l*l-s*s)/(2*a*l))*2,u=+(Ze>c),d=(rt-c)*(i?1:-1),f=d*o;return{center:n,radius:o,size:d,length:f,largeArcFlag:u,sweepFlag:i}}function vEt(t,e,r,n,o,i,s){const a=w.Angle(t,r),l=w.Angle(t,n);let c=Jg(a,l);if(s||(c=rt-c),o.setTo(t).add(w.FromAngle(a+c*(.5*(s?1:-1))).mul(e)),c>i){o.rotWith(t,Ze);const u=n.clone();n.setTo(r),r.setTo(u)}}const yEt=8;function SEt(t){return Math.abs(t.props.bend)<yEt*t.props.scale}function rx(t,e,r){const n=t.getBindingsFromShape(e,"arrow").find(l=>l.props.terminal===r);if(!n)return;const o=t.getShape(n.toId);if(!o)return;const i=t.getShapePageTransform(o),s=t.getShapeGeometry(o),a=s instanceof bi?s.children[0].vertices:s.vertices;return{shape:o,transform:i,isClosed:s.isClosed,isExact:n.props.isExact,didIntersect:!1,outline:a}}function s9(t,e,r,n){const o=t.getShape(r.toId);if(o){const{point:i,size:s}=t.getShapeGeometry(o).bounds,a=w.Add(i,w.MulV(r.props.isPrecise||n?r.props.normalizedAnchor:{x:.5,y:.5},s)),l=Q.applyToPoint(t.getShapePageTransform(o),a);return Q.applyToPoint(Q.Inverse(e),l)}else return new w(0,0)}function Rn(t,e){const r=t.getBindingsFromShape(e,"arrow");return{start:r.find(n=>n.props.terminal==="start"),end:r.find(n=>n.props.terminal==="end")}}const wEt=D1e("arrow info",(t,e)=>{const r=Rn(t,e);return SEt(e)?tA(t,e,r):mEt(t,e,r)});function es(t,e){const r=typeof e=="string"?e:e.id;return wEt.get(t,r)}function yd(t,e,r){var a,l;const n=t.getShapePageTransform(e),o=Wj(t,(a=r.start)==null?void 0:a.toId,(l=r.end)==null?void 0:l.toId),i=r.start?s9(t,n,r.start,o==="double-bound"||o==="start-contains-end"):w.From(e.props.start),s=r.end?s9(t,n,r.end,o==="double-bound"||o==="end-contains-start"):w.From(e.props.end);return{start:i,end:s}}function zf(t,e,r,n){const o=typeof e=="string"?e:e.id,i=typeof r=="string"?r:r.id,s=t.getBindingsFromShape(o,"arrow").filter(l=>l.props.terminal===n.terminal);s.length>1&&t.deleteBindings(s.slice(1));const a=s[0];a?t.updateBinding({...a,toId:i,props:n}):t.createBinding({type:"arrow",fromId:o,toId:i,props:n})}function WS(t,e,r){const n=t.getBindingsFromShape(e,"arrow").filter(o=>o.props.terminal===r);t.deleteBindings(n)}const Sd=10,nx=10,xEt=10,ts={s:2,m:3.5,l:5,xl:10};function Wj(t,e,r){if(!e||!r)return"safe";if(e===r)return"double-bound";const n=t.getShapePageBounds(e),o=t.getShapePageBounds(r);if(n&&o){if(n.contains(o))return"start-contains-end";if(o.contains(n))return"end-contains-start"}return"safe"}class KS extends BS{getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5}}}onAfterCreate({binding:e}){aC(this.editor,this.editor.getShape(e.fromId))}onAfterChange({bindingAfter:e}){aC(this.editor,this.editor.getShape(e.fromId))}onAfterChangeFromShape({shapeAfter:e}){aC(this.editor,e)}onAfterChangeToShape({binding:e}){Ple(this.editor,e.fromId)}onBeforeIsolateFromShape({binding:e}){const r=this.editor.getShape(e.fromId);r&&ox({editor:this.editor,arrow:r,terminal:e.props.terminal})}}C(KS,"type","arrow"),C(KS,"props",NG),C(KS,"migrations",FG);function Ple(t,e){var S;const r=t.getShape(e);if(!r)return;const n=Rn(t,r),{start:o,end:i}=n,s=o?t.getShape(o.toId):void 0,a=i?t.getShape(i.toId):void 0,l=t.getAncestorPageId(r);if(!l)return;let c;if(s&&a)c=t.findCommonAncestor([s,a])??l;else if(s||a){const y=(S=s||a)==null?void 0:S.parentId;y&&y===r.parentId?c=r.parentId:c=l}else return;c&&c!==r.parentId&&t.reparentShapes([e],c);const u=t.getShape(e);if(!u)throw Error("no reparented arrow");const d=t.getShapeNearestSibling(u,s),f=t.getShapeNearestSibling(u,a);let p;if(d&&f)p=d.index>f.index?d:f;else if(d&&!f)p=d;else if(f&&!d)p=f;else return;let g;const m=t.getSortedChildIdsForParent(p.parentId).map(y=>t.getShape(y)).filter(y=>y.index>p.index);if(m.length){const y=m.find(v=>v.type!=="arrow");if(u.index>p.index&&(!y||u.index<y.index))return;g=fg(p.index,m[0].index)}else g=Xi(p.index);g!==u.index&&t.updateShapes([{id:e,type:"arrow",index:g}])}function aC(t,e){const r=Rn(t,e);for(const n of["start","end"]){const o=r[n];if(!o)continue;const i=t.getShape(o.toId),s=t.getAncestorPageId(e)===t.getAncestorPageId(i);(!i||!s)&&ox({editor:t,arrow:e,terminal:n,unbind:!0})}Ple(t,e.id)}function ox({editor:t,arrow:e,terminal:r,unbind:n=!1,useHandle:o=!1}){const i=es(t,e);if(!i)throw new Error("expected arrow info");const s=o?i.start.handle:i.start.point,a=o?i.end.handle:i.end.point,l=r==="start"?s:a,c={id:e.id,type:"arrow",props:{[r]:{x:l.x,y:l.y},bend:e.props.bend}};if(!i.isStraight){const u=r==="start"?s:i.start.handle,d=r==="end"?a:i.end.handle,f=w.Med(u,d),p=w.Sub(u,d).per().uni().mul(i.handleArc.radius*2*Math.sign(e.props.bend)),g=im(i.handleArc.center,w.Add(f,p),i.handleArc.center,i.handleArc.radius);Qe((g==null?void 0:g.length)===1);const m=w.Dist(f,g[0])*Math.sign(e.props.bend);ul(m,c.props.bend)||(c.props.bend=m)}t.updateShape(c),n&&WS(t,e,r)}const Ele=[KS],Rr={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Qr={s:2,m:3.5,l:5,xl:10},hh={s:18,m:24,l:36,xl:44},Js={s:18,m:22,l:26,xl:32},bEt={s:18,m:20,l:24,xl:28},as={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},$Et=20,Cle=4.25,No=16;function IEt(t,e){const r=t.w/e.w,n=t.h/e.h;return r<=1&&n<=1?t:r>n?{w:t.w/r,h:t.h/r}:{w:t.w/n,h:t.h/n}}/*!
|
|
364
|
-
* MIT License
|
|
365
|
-
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
366
|
-
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
367
|
-
*/const wd=" ",ln=class ln{static insertTextFirefox(e,r){e.setRangeText(r,e.selectionStart||0,e.selectionEnd||0,"end"),e.dispatchEvent(new InputEvent("input",{data:r,inputType:"insertText",isComposing:!1}))}static insert(e,r){const n=e.ownerDocument,o=n.activeElement;o!==e&&e.focus(),n.execCommand("insertText",!1,r)||ln.insertTextFirefox(e,r),o===n.body?e.blur():o instanceof HTMLElement&&o!==e&&o.focus()}static set(e,r){e.select(),ln.insert(e,r)}static getSelection(e){const{selectionStart:r,selectionEnd:n}=e;return e.value.slice(r||void 0,n||void 0)}static wrapSelection(e,r,n){const{selectionStart:o,selectionEnd:i}=e,s=ln.getSelection(e);ln.insert(e,r+s+(n??r)),e.selectionStart=(o||0)+r.length,e.selectionEnd=(i||0)+r.length}static replace(e,r,n){let o=0;e.value.replace(r,(...i)=>{const s=o+i[i.length-2],a=i[0].length;e.selectionStart=s,e.selectionEnd=s+a;const l=typeof n=="string"?n:n(...i);return ln.insert(e,l),e.selectionStart=s,o+=l.length-a,l})}static findLineEnd(e,r){const n=e.lastIndexOf(`
|
|
368
|
-
`,r-1)+1;return e.charAt(n)!==" "?r:n+1}static indent(e){var a;const{selectionStart:r,selectionEnd:n,value:o}=e,i=o.slice(r,n),s=(a=/\n/g.exec(i))==null?void 0:a.length;if(s&&s>0){const l=o.lastIndexOf(`
|
|
369
|
-
`,r-1)+1,c=e.value.slice(l,n-1),u=c.replace(/^|\n/g,`$&${wd}`),d=u.length-c.length;e.setSelectionRange(l,n-1),ln.insert(e,u),e.setSelectionRange(r+1,n+d)}else ln.insert(e,wd)}static unindent(e){const{selectionStart:r,selectionEnd:n,value:o}=e,i=o.lastIndexOf(`
|
|
370
|
-
`,r-1)+1,s=ln.findLineEnd(o,n),a=e.value.slice(i,s),l=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),c=a.length-l.length;e.setSelectionRange(i,s),ln.insert(e,l);const u=/\t| {1,2}/.exec(o.slice(i,r)),d=u?u[0].length:0,f=r-d;e.setSelectionRange(r-d,Math.max(f,n-c))}static indentCE(e){var l;const r=window.getSelection(),n=e.innerText,o=Xy(e)??0,i=Xy(e)??0,s=n.slice(o,i),a=(l=/\n/g.exec(s))==null?void 0:l.length;if(a&&a>0){const c=n.lastIndexOf(`
|
|
371
|
-
`,o-1)+1,u=n.slice(c,i-1),f=u.replace(/^|\n/g,`$&${wd}`).length-u.length;r&&r.setBaseAndExtent(e,o+1,e,i+f)}else{const c=window.getSelection();e.innerText=n.slice(0,o)+wd+n.slice(o),c==null||c.setBaseAndExtent(e,o+1,e,o+2)}}static unindentCE(e){const r=window.getSelection(),n=e.innerText,o=Xy(e)??0,i=Xy(e)??0,s=n.lastIndexOf(`
|
|
372
|
-
`,o-1)+1,a=ln.findLineEnd(n,i),l=n.slice(s,a),c=l.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=l.length-c.length;if(r){r.setBaseAndExtent(e,s,e,a);const d=/\t| {1,2}/.exec(n.slice(s,o)),f=d?d[0].length:0,p=o-f;r.setBaseAndExtent(e,o-f,e,Math.max(p,i-u))}}static normalizeText(e){return e.replace(ln.fixNewLines,`
|
|
373
|
-
`)}static normalizeTextForDom(e){return e.replace(ln.fixNewLines,`
|
|
374
|
-
`).split(`
|
|
375
|
-
`).map(r=>r||" ").join(`
|
|
376
|
-
`)}};C(ln,"fixNewLines",/\r?\n|\r/g);let fh=ln;function Xy(t){if(typeof window.getSelection>"u")return;const e=window.getSelection();if(!e)return;let r=0;if(e.rangeCount!==0){const n=e.getRangeAt(0),o=n.cloneRange();o.selectNodeContents(t),o.setEnd(n.endContainer,n.endOffset),r=o.toString().length}return r}const PEt=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function _le(t){return PEt.test(t)}function EEt(t){return t.replace(/\t/g,wd)}function CEt(t){const e=t.split(`
|
|
377
|
-
`);for(;e[0]&&e[0].trim().length===0;)e.shift();let r=1/0;for(const n of e)if(n.trim().length>0){const o=n.length-n.trimStart().length;r=Math.min(r,o)}return e.map(n=>n.slice(r)).join(`
|
|
378
|
-
`)}const Tle={"&":"&",""":'"',"'":"'",""":'"',"&":"&","'":"'","–":"–","—":"—","‘":"‘","’":"’","“":"“","”":"”","…":"…"},_Et=new RegExp(Object.keys(Tle).join("|"),"g");function TEt(t){return t.replace(_Et,e=>Tle[e])}function AEt(t){return t.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function kEt(t){return AEt(CEt(EEt(t)))}function OEt(t,{maxImageDimension:e,maxAssetSize:r,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:o},{toasts:i,msg:s}){t.registerExternalAssetHandler("file",async({file:a,assetId:l})=>{const c=n.includes(a.type),u=o.includes(a.type);!c&&!u&&i.addToast({title:s("assets.files.type-not-allowed"),severity:"error"}),Qe(c||u,`File type not allowed: ${a.type}`),a.size>r&&i.addToast({title:s("assets.files.size-too-big"),severity:"error"}),Qe(a.size<=r,`File size too big: ${(a.size/1024).toFixed()}kb > ${(r/1024).toFixed()}kb`);const d=K3(await a.arrayBuffer());l=l??Wa.createId(d);const f=await a9(a,l,c,u);if(isFinite(e)){const p={w:f.props.w,h:f.props.h},g=IEt(p,{w:e,h:e});p!==g&&io.isStaticImageType(a.type)&&(f.props.w=g.w,f.props.h=g.h)}return f.props.src=await t.uploadAsset(f,a),Wa.create(f)}),t.registerExternalAssetHandler("url",async({url:a})=>{var c,u,d,f,p;let l;try{const m=await(await xi(a,{method:"GET",mode:"no-cors"})).text(),S=new DOMParser().parseFromString(m,"text/html");l={image:((c=S.head.querySelector('meta[property="og:image"]'))==null?void 0:c.getAttribute("content"))??"",favicon:((u=S.head.querySelector('link[rel="apple-touch-icon"]'))==null?void 0:u.getAttribute("href"))??((d=S.head.querySelector('link[rel="icon"]'))==null?void 0:d.getAttribute("href"))??"",title:((f=S.head.querySelector('meta[property="og:title"]'))==null?void 0:f.getAttribute("content"))??a,description:((p=S.head.querySelector('meta[property="og:description"]'))==null?void 0:p.getAttribute("content"))??""},l.image.startsWith("http")||(l.image=new URL(l.image,a).href),l.favicon.startsWith("http")||(l.favicon=new URL(l.favicon,a).href)}catch(g){console.error(g),i.addToast({title:s("assets.url.failed"),severity:"error"}),l={image:"",favicon:"",title:"",description:""}}return{id:Wa.createId(O_(a)),typeName:"asset",type:"bookmark",props:{src:a,description:l.description,image:l.image,favicon:l.favicon,title:l.title},meta:{}}}),t.registerExternalContentHandler("svg-text",async({point:a,text:l})=>{const c=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),u=new DOMParser().parseFromString(l,"image/svg+xml").querySelector("svg");if(!u)throw new Error("No <svg/> element present");let d=parseFloat(u.getAttribute("width")||"0"),f=parseFloat(u.getAttribute("height")||"0");if(!(d&&f)){document.body.appendChild(u);const g=u.getBoundingClientRect();document.body.removeChild(u),d=g.width,f=g.height}const p=await t.getAssetForExternalContent({type:"file",file:new File([l],"asset.svg",{type:"image/svg+xml"})});if(!p)throw Error("Could not create an asset");l9(t,[p],c)}),t.registerExternalContentHandler("embed",({point:a,url:l,embed:c})=>{const u=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),{width:d,height:f}=c,p=ot(),g={id:p,type:"embed",x:u.x-(d||450)/2,y:u.y-(f||450)/2,props:{w:d,h:f,url:l}};t.createShapes([g]).select(p)}),t.registerExternalContentHandler("files",async({point:a,files:l})=>{if(l.length>t.options.maxFilesAtOnce)throw Error("Too many files");const c=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),u=new w(c.x,c.y),d=[],f=[];for(const p of l){if(p.size>r){i.addToast({title:s("assets.files.size-too-big"),severity:"error"}),console.warn(`File size too big: ${(p.size/1024).toFixed()}kb > ${(r/1024).toFixed()}kb`);continue}if(!p.type){i.addToast({title:s("assets.files.upload-failed"),severity:"error"}),console.error("No mime type");continue}if(!n.concat(o).includes(p.type)){i.addToast({title:s("assets.files.type-not-allowed"),severity:"error"}),console.warn(`${p.name} not loaded - Mime type not allowed ${p.type}.`);continue}const g=n.includes(p.type),m=o.includes(p.type),S=K3(await p.arrayBuffer()),y=Wa.createId(S),v=await a9(p,y,g,m);let b;g&&(b=t.createTemporaryAssetPreview(y,p)),d.push(v),f.push({asset:v,file:p,temporaryAssetPreview:b})}Promise.allSettled(f.map(async p=>{try{const g=await t.getAssetForExternalContent({type:"file",file:p.file});if(!g)throw Error("Could not create an asset");t.updateAssets([{...g,id:p.asset.id}])}catch(g){i.addToast({title:s("assets.files.upload-failed"),severity:"error"}),console.error(g);return}})),l9(t,d,u)}),t.registerExternalContentHandler("text",async({point:a,text:l})=>{const c=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),u=t.getShapeUtil("text").getDefaultProps(),d=kEt(l),f=t.getOnlySelectedShape();if(f&&"text"in f.props){t.updateShapes([{id:f.id,type:f.type,props:{text:d}}]);return}let p,g,m,S="middle";const y=d.split(`
|
|
379
|
-
`).length>1,v=_le(d);y&&(S=y?v?"end":"start":"middle");const b=t.textMeasure.measureText(d,{...Rr,fontFamily:as[u.font],fontSize:hh[u.size],maxWidth:null}),$=Math.min(y?t.getViewportPageBounds().width*.9:920,Math.max(200,t.getViewportPageBounds().width*.9));if(b.w>$){const P=t.textMeasure.measureText(d,{...Rr,fontFamily:as[u.font],fontSize:hh[u.size],maxWidth:$});p=P.w,g=P.h,m=!1,S=v?"end":"start"}else p=b.w,g=b.h,m=!0;c.y-g/2<t.getViewportPageBounds().minY+40&&(c.y=t.getViewportPageBounds().minY+40+g/2),t.createShapes([{id:ot(),type:"text",x:c.x-p/2,y:c.y-g/2,props:{text:d,textAlign:S,autoSize:m,w:p}}])}),t.registerExternalContentHandler("url",async({point:a,url:l})=>{const c=t.getShapeUtil("embed"),u=c==null?void 0:c.getEmbedDefinition(l);if(u)return t.putExternalContent({type:"embed",url:u.url,point:a,embed:u.definition});const d=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),f=Wa.createId(O_(l)),p=MEt(t,l,d);let g=t.getAsset(f),m=!1;if(!g){m=!0;try{const S=await t.getAssetForExternalContent({type:"url",url:l});if(!S)throw Error("Could not create an asset");g=S}catch{i.addToast({title:s("assets.url.failed"),severity:"error"});return}}t.run(()=>{m&&t.createAssets([g]),t.updateShapes([{id:p.id,type:p.type,props:{assetId:g.id}}])})})}async function a9(t,e,r,n){let o=t.type;t.type==="video/quicktime"&&(o="video/mp4");const i=r?await io.getImageSize(t):await io.getVideoSize(t),s=await io.isAnimated(t)||n;return{id:e,type:r?"image":"video",typeName:"asset",props:{name:t.name,src:"",w:i.w,h:i.h,fileSize:t.size,mimeType:o,isAnimated:s},meta:{}}}async function l9(t,e,r){if(!e.length)return[];const n=w.From(r),o=[];for(let i=0;i<e.length;i++){const s=e[i];switch(s.type){case"image":{o.push({id:ot(),type:"image",x:n.x,y:n.y,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),n.x+=s.props.w;break}case"video":o.push({id:ot(),type:"video",x:n.x,y:n.y,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),n.x+=s.props.w}}return t.run(()=>{const i=e.filter(s=>!t.getAsset(s.id));i.length&&t.createAssets(i),t.createShapes(o).select(...o.map(s=>s.id)),Ale(t,r)}),o.map(i=>i.id)}function Ale(t,e){const r=t.getViewportPageBounds();let n=t.getSelectionPageBounds();if(n){const o=n.center.sub(e);t.updateShapes(t.getSelectedShapes().map(i=>{const s=t.getShapeParentTransform(i).decompose().rotation,a=w.Rot(o,-s);return{id:i.id,type:i.type,x:i.x-a.x,y:i.y-a.y}}))}n=t.getSelectionPageBounds(),n&&!r.contains(n)&&t.zoomToSelection()}function MEt(t,e,r){const n={id:ot(),type:"bookmark",x:r.x-150,y:r.y-160,opacity:1,props:{assetId:null,url:e}};return t.run(()=>{t.createShapes([n]).select(n.id),Ale(t,r)}),t.getShape(n.id)}var wC;let REt=(wC=class extends he{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}onKeyUp(e){var r;if(e.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...e,target:"shape",shape:n}))}}},C(wC,"id","idle"),wC);var xC;let jEt=(xC=class extends he{constructor(){super(...arguments);C(this,"shape");C(this,"markId","");C(this,"preciseTimeout",-1);C(this,"didTimeout",!1)}onEnter(){this.markId="",this.didTimeout=!1;const r=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:n=>!n.isLocked&&this.editor.canBindShapes({fromShape:"arrow",toShape:n,binding:"arrow"}),margin:0,hitInside:!0,renderingOnly:!0});r?this.editor.setHintingShapes([r.id]):this.createArrowShape(),this.startPreciseTimeout()}onExit(){this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()}onPointerMove(){if(this.editor.inputs.isDragging){if(this.shape||this.createArrowShape(),!this.shape)throw Error("expected shape");this.updateArrowShapeEndHandle(),this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,handle:{id:"end",type:"vertex",index:"a3",x:0,y:0},isCreating:!0,creatingMarkId:this.markId||void 0,onInteractionEnd:"arrow"})}}onPointerUp(){this.cancel()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var u;const{originPagePoint:r}=this.editor.inputs,n=ot();this.markId=this.editor.markHistoryStoppingPoint(`creating_arrow:${n}`),this.editor.createShape({id:n,type:"arrow",x:r.x,y:r.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const o=this.editor.getShape(n);if(!o)throw Error("expected shape");const i=this.editor.getShapeHandles(o);if(!i)throw Error("expected handles for arrow");const s=this.editor.getShapeUtil("arrow"),a=this.shape,l=i.find(d=>d.id==="start"),c=(u=s.onHandleDrag)==null?void 0:u.call(s,o,{handle:{...l,x:0,y:0},isPrecise:!0,initial:a});c&&this.editor.updateShapes([c]),this.shape=this.editor.getShape(n),this.editor.select(n)}updateArrowShapeEndHandle(){var o,i;const r=this.shape;if(!r)throw Error("expected shape");const n=this.editor.getShapeHandles(r);if(!n)throw Error("expected handles for arrow");{const s=this.editor.getShapeUtil("arrow"),a=this.shape,l=n.find(u=>u.id==="start"),c=(o=s.onHandleDrag)==null?void 0:o.call(s,r,{handle:{...l,x:0,y:0},isPrecise:this.didTimeout,initial:a});c&&this.editor.updateShapes([c])}{const s=this.editor.getShapeUtil("arrow"),a=this.shape,l=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),c=n.find(d=>d.id==="end"),u=(i=s.onHandleDrag)==null?void 0:i.call(s,this.editor.getShape(r),{handle:{...c,x:l.x,y:l.y},isPrecise:!1,initial:a});u&&this.editor.updateShapes([u])}this.shape=this.editor.getShape(r.id)}startPreciseTimeout(){this.preciseTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},C(xC,"id","pointing"),xC);class rA extends he{constructor(){super(...arguments);C(this,"shapeType","arrow")}static children(){return[REt,jEt]}}C(rA,"id","arrow"),C(rA,"initial","idle");class Kj extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"initialShape");C(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");C(this,"util",this.editor.getShapeUtil(this.shapeType));C(this,"isPen",!1);C(this,"isPenOrStylus",!1);C(this,"segmentMode","free");C(this,"didJustShiftClickToExtendPreviousShapeLine",!1);C(this,"pagePointWhereCurrentSegmentChanged",{});C(this,"pagePointWhereNextSegmentChanged",null);C(this,"lastRecordedPoint",{});C(this,"mergeNextPoint",!1);C(this,"currentLineLength",0);C(this,"canDraw",!1);C(this,"markId",null)}onEnter(r){this.markId=null,this.info=r,this.canDraw=!this.editor.getIsMenuOpen(),this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.canDraw&&this.startShape()}onPointerMove(){const{inputs:r}=this.editor;if(this.isPen&&!r.isPen){if(this.markId){this.editor.bailToMark(this.markId),this.startShape();return}}else!this.canDraw&&r.isDragging&&(this.startShape(),this.canDraw=!0);this.canDraw&&(this.isPenOrStylus?w.Dist(r.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=r.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape())}onKeyDown(r){if(r.key==="Shift")switch(this.segmentMode){case"free":{this.segmentMode="starting_straight",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_free":this.segmentMode="starting_straight"}this.updateDrawingShape()}onKeyUp(r){if(r.key==="Shift")switch(this.editor.snaps.clearIndicators(),this.segmentMode){case"straight":{this.segmentMode="starting_free",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_straight":{this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";break}}this.updateDrawingShape()}onExit(){this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()}canClose(){return this.shapeType!=="highlight"}getIsClosed(r,n,o){if(!this.canClose())return!1;const i=Qr[n],s=r[0].points[0],a=r[r.length-1],l=a.points[a.points.length-1];return s!==l&&this.currentLineLength>i*4*o&&w.DistMin(s,l,i*2*o)}startShape(){const{inputs:{originPagePoint:r,isPen:n}}=this.editor;this.markId=this.editor.markHistoryStoppingPoint("draw start");const{z:o=.5}=this.info.point;this.isPen=n,this.isPenOrStylus=n||o>0&&o<.5||o>.5&&o<1;const i=this.isPenOrStylus?o*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=r.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const l=Cr(a.props.segments);if(!l)throw Error("Expected a previous segment!");const c=Cr(l.points);if(!c)throw Error("Expected a previous point!");const{x:u,y:d}=this.editor.getPointInShapeSpace(a,r).toFixed(),f={type:this.segmentMode,points:[{x:c.x,y:c.y,z:+i.toFixed(2)},{x:u,y:d,z:+i.toFixed(2)}]},p=Q.applyToPoint(this.editor.getShapePageTransform(a.id),c);this.pagePointWhereCurrentSegmentChanged=p,this.pagePointWhereNextSegmentChanged=null;const g=[...a.props.segments,f];this.currentLineLength<Qr[a.props.size]*4&&(this.currentLineLength=this.getLineLength(g));const m={id:a.id,type:this.shapeType,props:{segments:g}};this.canClose()&&(m.props.isClosed=this.getIsClosed(g,a.props.size,a.props.scale)),this.editor.updateShapes([m]);return}}this.pagePointWhereCurrentSegmentChanged=r.clone();const s=ot();this.editor.createShapes([{id:s,type:this.shapeType,x:r.x,y:r.y,props:{isPen:this.isPenOrStylus,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+i.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(s)}updateDrawingShape(){const{initialShape:r}=this,{inputs:n}=this.editor;if(!r)return;const{id:o,props:{size:i,scale:s}}=r,a=this.editor.getShape(o);if(!a)return;const{segments:l}=a.props,{x:c,y:u,z:d}=this.editor.getPointInShapeSpace(a,n.currentPagePoint).toFixed(),f=this.isPenOrStylus?+(n.currentPagePoint.z*1.25).toFixed(2):.5,p={x:c,y:u,z:f};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:g}=this;if(g===null)throw Error("We should have a point where the segment changed");if(w.Dist2(g,n.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const S=Cr(l);if(!S)throw Error("Expected a previous segment!");const y=Cr(S.points);if(!y)throw Error("Expected a previous last point!");let v;const b=this.editor.getPointInShapeSpace(a,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(S.type==="straight"){this.currentLineLength+=w.Dist(y,b),v={type:"straight",points:[{...y},b]};const P=this.editor.getShapePageTransform(a);this.pagePointWhereCurrentSegmentChanged=Q.applyToPoint(P,y)}else v={type:"straight",points:[b,p]};const $={id:o,type:this.shapeType,props:{segments:[...l,v]}};this.canClose()&&($.props.isClosed=this.getIsClosed(l,i,s)),this.editor.updateShapes([$])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:g}=this;if(g===null)throw Error("We should have a point where the segment changed");if(w.Dist2(g,n.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const S=l.slice(),y=S[S.length-1],v=Cr(y.points);if(!v)throw Error("No previous point!");const b={type:"free",points:[...w.PointsBetween(v,p,6).map(E=>({x:Us(E.x),y:Us(E.y),z:Us(E.z)}))]},$=[...S,b];this.currentLineLength<Qr[a.props.size]*4&&(this.currentLineLength=this.getLineLength($));const P={id:o,type:this.shapeType,props:{segments:$}};this.canClose()&&(P.props.isClosed=this.getIsClosed($,i,s)),this.editor.updateShapes([P])}break}case"straight":{const g=l.slice(),m=g[g.length-1],{pagePointWhereCurrentSegmentChanged:S}=this,{ctrlKey:y,currentPagePoint:v}=this.editor.inputs;if(!S)throw Error("We should have a point where the segment changed");let b,$=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&($=!y,this.didJustShiftClickToExtendPreviousShapeLine=!1):$=!y;let P=this.editor.getPointInShapeSpace(a,v).toFixed().toJson(),E=!1,T;if((this.editor.user.getIsSnapMode()?!y:y)&&g.length>2){let k,D=8/this.editor.getZoomLevel();for(let R=0,j=l.length-2;R<j;R++){const M=l[R];if(!M)break;if(M.type==="free")continue;const U=M.points[0],B=Cr(M.points);if(!(U&&B))continue;const K=w.NearestPointOnLineSegment(U,B,P);if(w.DistMin(K,P,D)){k=K.toFixed().toJson(),D=w.Dist(K,P),T=M;break}}k&&(E=!0,P=k)}if(E&&T){const k=this.editor.getShapePageTransform(a),D=T.points[0],R=Cr(T.points);if(!R)throw Error("Expected a last point!");const j=Q.applyToPoint(k,D),M=Q.applyToPoint(k,R),U=Q.applyToPoint(k,P);this.editor.snaps.setIndicators([{id:ct(),type:"points",points:[j,U,M]}])}else{if(this.editor.snaps.clearIndicators(),$){const k=w.Angle(S,v),R=a0(k,24)-k;b=w.RotWith(v,S,R)}else b=v;P=this.editor.getPointInShapeSpace(a,b).toFixed().toJson()}this.currentLineLength+=w.Dist(m.points[0],P),g[g.length-1]={...m,type:"straight",points:[m.points[0],P]};const _={id:o,type:this.shapeType,props:{segments:g}};this.canClose()&&(_.props.isClosed=this.getIsClosed(l,i,s)),this.editor.updateShapes([_]);break}case"free":{const g=l.slice(),m=g[g.length-1],S=[...m.points];if(S.length&&this.mergeNextPoint){const{z:v}=S[S.length-1];S[S.length-1]={x:p.x,y:p.y,z:v?Math.max(v,p.z):p.z}}else this.currentLineLength+=w.Dist(S[S.length-1],p),S.push(p);g[g.length-1]={...m,points:S},this.currentLineLength<Qr[a.props.size]*4&&(this.currentLineLength=this.getLineLength(g));const y={id:o,type:this.shapeType,props:{segments:g}};if(this.canClose()&&(y.props.isClosed=this.getIsClosed(g,i,s)),this.editor.updateShapes([y]),S.length>this.editor.options.maxPointsPerDrawShape){this.editor.updateShapes([{id:o,type:this.shapeType,props:{isComplete:!0}}]);const v=ot(),b=this.editor.getShape(o).props;this.editor.createShapes([{id:v,type:this.shapeType,x:Us(n.currentPagePoint.x),y:Us(n.currentPagePoint.y),props:{isPen:this.isPenOrStylus,scale:b.scale,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(d*1.25).toFixed():.5}]}]}}]),this.initialShape=$t(this.editor.getShape(v)),this.mergeNextPoint=!1,this.lastRecordedPoint=n.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(r){let n=0;for(const o of r)for(let i=0;i<o.points.length-1;i++){const s=o.points[i],a=o.points[i+1];n+=w.Dist2(a,s)}return Math.sqrt(n)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())}complete(){if(!this.canDraw){this.cancel();return}const{initialShape:r}=this;r&&(this.editor.updateShapes([{id:r.id,type:r.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}C(Kj,"id","drawing");var bC;let kle=(bC=class extends he{onPointerDown(e){this.parent.transition("drawing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},C(bC,"id","idle"),bC);class GS extends he{constructor(){super(...arguments);C(this,"shapeType","draw")}static children(){return[kle,Kj]}onExit(){const r=this.children.drawing;r.initialShape=void 0}}C(GS,"id","draw"),C(GS,"initial","idle"),C(GS,"isLockable",!1);class nA extends N2{constructor(){super(...arguments);C(this,"shapeType","frame")}onCreate(r){if(!r)return;const n=this.editor.getShapePageBounds(r),o=[],i=this.editor.getShapeAncestors(r).map(s=>s.id);this.editor.getSortedChildIdsForParent(r.parentId).map(s=>{const a=this.editor.getShape(s);if(!a||a.id===r.id||a.isLocked)return;const l=this.editor.getShapePageBounds(a);l&&n.contains(l)&&DEt(a,i,r)&&o.push(a.id)}),this.editor.reparentShapes(o,r.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")}}C(nA,"id","frame"),C(nA,"initial","idle");function DEt(t,e,r){return e.includes(t.id)?!1:t.parentId===r.parentId}var $C;let LEt=($C=class extends he{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onKeyUp(e){var r;if(e.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...e,target:"shape",shape:n}))}}onCancel(){this.editor.setCurrentTool("select")}},C($C,"id","idle"),$C);var IC;let NEt=(IC=class extends he{onPointerUp(){this.complete()}onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,n=ot(),o=this.editor.markHistoryStoppingPoint(`creating_geo:${n}`);this.editor.createShapes([{id:n,type:"geo",x:r.x,y:r.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(pi),scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]).select(n).setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:o,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){const{originPagePoint:e}=this.editor.inputs,r=ot();this.editor.markHistoryStoppingPoint(`creating_geo:${r}`);const n=this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,o=this.editor.getStyleForNextShape(pi),i=o==="star"?{w:200,h:190}:o==="cloud"?{w:300,h:180}:{w:200,h:200};this.editor.createShapes([{id:r,type:"geo",x:e.x,y:e.y,props:{geo:this.editor.getStyleForNextShape(pi),scale:n,...i}}]);const s=this.editor.getShape(r);if(!s)return;const{w:a,h:l}=s.props,c=new w(a/2,l/2).mul(n),u=this.editor.getShapeParentTransform(s);u&&c.rot(-u.rotation()),this.editor.select(r),this.editor.updateShape({id:s.id,type:"geo",x:s.x-c.x,y:s.y-c.y,props:{geo:this.editor.getStyleForNextShape(pi),w:a*n,h:l*n}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},C(IC,"id","pointing"),IC);class oA extends he{constructor(){super(...arguments);C(this,"shapeType","geo")}static children(){return[LEt,NEt]}}C(oA,"id","geo"),C(oA,"initial","idle");class VS extends he{constructor(){super(...arguments);C(this,"shapeType","highlight")}static children(){return[kle,Kj]}onExit(){const r=this.children.drawing;r.initialShape=void 0}}C(VS,"id","highlight"),C(VS,"initial","idle"),C(VS,"isLockable",!1);var PC;let FEt=(PC=class extends he{constructor(){super(...arguments);C(this,"shapeId","")}onEnter(r){this.shapeId=r.shapeId,this.editor.setCursor({type:"cross",rotation:0})}onPointerDown(){this.parent.transition("pointing",{shapeId:this.shapeId})}onCancel(){this.editor.setCurrentTool("select")}},C(PC,"id","idle"),PC);const c9=2;var EC;let BEt=(EC=class extends he{constructor(){super(...arguments);C(this,"shape",{});C(this,"markId")}onEnter(r){const{inputs:n}=this.editor,{currentPagePoint:o}=n;this.markId=void 0;const i=r.shapeId&&this.editor.getShape(r.shapeId);if(i&&n.shiftKey){this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${i.id}`),this.shape=i;const s=this.editor.getShapeHandles(this.shape);if(!s)return;const a=s.filter(p=>p.type==="vertex").sort(qr),l=a[a.length-1],c=a[a.length-2],u=Q.applyToPoint(this.editor.getShapeParentTransform(this.shape),new w(this.shape.x,this.shape.y)),d=w.Sub(o,u).addXY(.1,.1),f=$t(this.shape.props.points);if(w.DistMin(l,c,c9)||w.DistMin(d,l,c9))f[l.id]={id:l.id,index:l.index,x:d.x,y:d.y};else{const p=Xi(l.index);f[p]={id:p,index:p,x:d.x,y:d.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:f}}])}else{const s=ot();this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${s}`),this.editor.createShapes([{id:s,type:"line",x:o.x,y:o.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]),this.editor.select(s),this.shape=this.editor.getShape(s)}}onPointerMove(){if(this.shape&&this.editor.inputs.isDragging){const r=this.editor.getShapeHandles(this.shape);if(!r)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const n=Cr(r);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,creatingMarkId:this.markId,handle:{...n,x:n.x-.1,y:n.y-.1},onInteractionEnd:"line"})}}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle"),this.markId&&this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators()}complete(){this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}cancel(){this.markId&&this.editor.bailToMark(this.markId),this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}},C(EC,"id","pointing"),EC);class iA extends he{constructor(){super(...arguments);C(this,"shapeType","line")}static children(){return[FEt,BEt]}}C(iA,"id","line"),C(iA,"initial","idle");var CC;let UEt=(CC=class extends he{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},C(CC,"id","idle"),CC);const zEt=0,lt=200,Nb=new w(lt/2,lt/2),Ole=10,HEt=t=>[[["a1"],new w(lt*.5,lt*-.5-t.options.adjacentShapeMargin)],[["a2"],new w(lt*1.5+t.options.adjacentShapeMargin,lt*.5)],[["a3"],new w(lt*.5,lt*1.5+t.options.adjacentShapeMargin)],[["a4"],new w(lt*-.5-t.options.adjacentShapeMargin,lt*.5)]];function WEt(t,e){if(e===1)return HEt(t);const r=lt*e,n=t.options.adjacentShapeMargin*e;return[[["a1"],new w(r*.5,r*-.5-n)],[["a2"],new w(r*1.5+n,r*.5)],[["a3"],new w(r*.5,r*1.5+n)],[["a4"],new w(r*-.5-n,r*.5)]]}function Mle(t,e,r,n,o,i){return Object.fromEntries(WEt(t,i).map(([s,a],l)=>{const c=a.clone();return l===0&&o?c.y-=o:l===2&&n&&(c.y+=n),[s,c.rot(r).add(e)]}))}function Rle(t,e,r,n){const o=new Set(t.getSelectedShapeIds()),i=(lt+t.options.adjacentShapeMargin+n)**2,s=new Map,a=[];for(const u of t.getCurrentPageShapes()){if(!t.isShapeOfType(u,"note")||r!==u.props.scale||o.has(u.id))continue;const d=t.getShapePageTransform(u.id);e===d.rotation()&&(s.set(u,t.getShapePageBounds(u).center),a.push(...Object.values(Mle(t,d.point(),e,u.props.growY,n,r))))}const l=a.length;let c;for(const[u,d]of s)for(let f=0;f<l;f++)c=a[f],c&&(w.Dist2(d,c)>i||t.isPointInShape(u,c)&&(a[f]=void 0));return Ae(a)}function jle(t,e,r,n,o=!1){let i;const s=t.getCurrentPageShapesSorted(),a=(lt+t.options.adjacentShapeMargin**2)**e.props.scale;for(let l=s.length-1;l>=0;l--){const c=s[l];if(c.type==="note"&&c.id!==e.id){const u=t.getShapePageBounds(c);if(u&&w.Dist2(u.center,r)<a&&t.isPointInShape(c,r)){i=c;break}}}if(t.complete(),!i||o){t.markHistoryStoppingPoint("creating note shape");const l=ot();t.createShape({id:l,type:"note",x:r.x,y:r.y,rotation:n,opacity:e.opacity,props:{...e.props,text:"",growY:0,fontSizeAdjustment:0,url:""}});const c=t.getShape(l);if(!c)return;const u=t.getPointInParentSpace(c,w.Sub(r,w.Rot(Nb.clone().mul(c.props.scale),n)));t.updateShape({id:l,type:"note",x:u.x,y:u.y}),i=t.getShape(l)}return Aie(t),i}var _C;let KEt=(_C=class extends he{constructor(){super(...arguments);C(this,"dragged",!1);C(this,"info",{});C(this,"wasFocusedOnEnter",!1);C(this,"markId","");C(this,"shape",{})}onEnter(){const{editor:r}=this;if(this.wasFocusedOnEnter=!r.getIsMenuOpen(),this.wasFocusedOnEnter){const n=ot();this.markId=r.markHistoryStoppingPoint(`creating_note:${n}`);const o=this.editor.inputs.originPagePoint.clone(),i=u9(this.editor,o,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);i&&o.sub(i),this.shape=d9(this.editor,n,o)}}onPointerMove(r){if(this.editor.inputs.isDragging){if(!this.wasFocusedOnEnter){const n=ot(),o=this.editor.inputs.originPagePoint.clone(),i=u9(this.editor,o,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);i&&o.sub(i),this.shape=d9(this.editor,n,o)}this.editor.setCurrentTool("select.translating",{...r,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,creatingMarkId:this.markId,onCreate:()=>{this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape")}})}}onPointerUp(){this.complete()}onInterrupt(){this.cancel()}onComplete(){this.complete()}onCancel(){this.cancel()}complete(){this.wasFocusedOnEnter&&(this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):(this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape",{...this.info,target:"shape",shape:this.shape})))}cancel(){this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}},C(_C,"id","pointing"),_C);function u9(t,e,r){let n=Ole/t.getZoomLevel(),o;for(const i of Rle(t,0,r,0)){const s=w.Sub(e,i),a=s.len();a<n&&(n=a,o=s)}return o}function d9(t,e,r){t.createShape({id:e,type:"note",x:r.x,y:r.y,props:{scale:t.user.getIsDynamicResizeMode()?1/t.getZoomLevel():1}}).select(e);const n=t.getShape(e),o=t.getShapeGeometry(n).bounds;return t.updateShapes([{id:e,type:"note",x:n.x-o.width/2,y:n.y-o.height/2}]),t.getShape(e)}class sA extends he{constructor(){super(...arguments);C(this,"shapeType","note")}static children(){return[UEt,KEt]}}C(sA,"id","note"),C(sA,"initial","idle");function GEt(t){const e=t.getShapeAtPoint(t.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:t.options.hitTestMargin/t.getZoomLevel(),renderingOnly:!0});if(!e)return t.setHoveredShape(null);let r;const n=t.getOutermostSelectableShape(e);return n===e||n.id===t.getFocusedGroupId()||t.getSelectedShapeIds().includes(n.id)?r=e:r=n,t.setHoveredShape(r.id)}const Gs=lK(GEt,32);var TC;let VEt=(TC=class extends he{onPointerMove(e){switch(e.target){case"shape":case"canvas":Gs(this.editor)}}onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){Gs.cancel()}onKeyDown(e){var r;if(e.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...e,target:"shape",shape:n}))}}onCancel(){this.editor.setCurrentTool("select")}},C(TC,"id","idle"),TC);var AC;let YEt=(AC=class extends he{constructor(){super(...arguments);C(this,"shape");C(this,"markId","");C(this,"enterTime",0)}onEnter(){this.enterTime=Date.now()}onExit(){this.editor.setHintingShapes([])}onPointerMove(r){if(Date.now()-this.enterTime<150)return;const{editor:n}=this,{isPointing:o}=n.inputs;if(!o)return;const{originPagePoint:i,currentPagePoint:s}=n.inputs,a=Math.abs(i.x-s.x),c=Math.sqrt(n.getInstanceState().isCoarsePointer?n.options.coarseDragDistanceSquared:n.options.dragDistanceSquared)*6/n.getZoomLevel();if(a>c){const u=ot();this.markId=n.markHistoryStoppingPoint(`creating_text:${u}`);const d=this.createTextShape(u,i,!1,a);if(!d){this.cancel();return}this.shape=n.getShape(d),n.select(u),n.setCurrentTool("select.resizing",{...r,target:"selection",handle:"right",isCreating:!0,creatingMarkId:this.markId,creationCursorOffset:{x:a,y:1},onInteractionEnd:"text",onCreate:()=>{n.setEditingShape(d.id),n.setCurrentTool("select.editing_shape")}})}}onPointerUp(){this.complete()}onComplete(){this.cancel()}onCancel(){this.cancel()}onInterrupt(){this.cancel()}complete(){var i;this.editor.markHistoryStoppingPoint("creating text shape");const r=ot(),{originPagePoint:n}=this.editor.inputs;this.createTextShape(r,n,!0,20)&&(this.editor.select(r),this.editor.setEditingShape(r),this.editor.setCurrentTool("select"),(i=this.editor.root.getCurrent())==null||i.transition("editing_shape"))}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}createTextShape(r,n,o,i){this.editor.createShape({id:r,type:"text",x:n.x,y:n.y,props:{text:"",autoSize:o,w:i,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const s=this.editor.getShape(r);if(!s){this.cancel();return}const a=this.editor.getShapePageBounds(s),l=new w;if(o)switch(s.props.textAlign){case"start":{l.x=0;break}case"middle":{l.x=-a.width/2;break}case"end":{l.x=-a.width;break}}else l.x=0;if(l.y=-a.height/2,Tn(s.parentId)){const c=this.editor.getShapeParentTransform(s);l.rot(-c.rotation())}return this.editor.updateShape({...s,x:s.x+l.x,y:s.y+l.y}),s}},C(AC,"id","pointing"),AC);class YS extends he{constructor(){super(...arguments);C(this,"shapeType","text")}static children(){return[VEt,YEt]}}C(YS,"id","text"),C(YS,"initial","idle"),C(YS,"isLockable",!1);const XEt=[YS,GS,oA,sA,iA,nA,rA,VS];function ei(){return ma({isDarkMode:jm()})}function Fb(t){return{key:`${cs.id}:${t}`,async getElement(){const e=qEt(t);if(!e)return null;const r=e.$$_url,n=e.$$_fontface;if(!r||!n)return null;const o=await(await xi(r)).blob(),i=await Ys.blobToDataUrl(o),s=n.replace(r,i);return h.jsx("style",{children:s})}}}function qEt(t){const e=RG[t];for(const r of document.fonts)if(e.includes(r.family))return r;return null}function Gj(t){return{key:`${cs.id}:${t}`,async getElement(){return t!=="pattern"?null:h.jsx(ZEt,{})}}}function ZEt(){const t=ei(),e=8/12;return h.jsxs(h.Fragment,{children:[h.jsxs("mask",{id:"hash_pattern_mask",children:[h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),h.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[h.jsx("line",{x1:e*1,y1:e*3,x2:e*3,y2:e*1}),h.jsx("line",{x1:e*5,y1:e*7,x2:e*7,y2:e*5}),h.jsx("line",{x1:e*9,y1:e*11,x2:e*11,y2:e*9})]})]}),h.jsx("pattern",{id:ix(1,t.id),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:t.solid,mask:"url(#hash_pattern_mask)"})})]})}function Vj(){return{key:`${cs.id}:pattern`,component:tCt}}const pp=8,h9=(t,e,r)=>new Promise((n,o)=>{const i=pp*e*t,s=document.createElement("canvas");s.width=i,s.height=i;const a=s.getContext("2d");if(!a)return;a.fillStyle=r?e0.darkMode.solid:e0.lightMode.solid,a.fillRect(0,0,i,i),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*e*t;const l=8/12,c=u=>u*e*t;a.beginPath(),a.moveTo(c(l*1),c(l*3)),a.lineTo(c(l*3),c(l*1)),a.moveTo(c(l*5),c(l*7)),a.lineTo(c(l*7),c(l*5)),a.moveTo(c(l*9),c(l*11)),a.lineTo(c(l*11),c(l*9)),a.stroke(),s.toBlob(u=>{!u||Xt.throwToBlob.get()?o():n(u)})}),f9=(t,e)=>{const r=document.createElement("canvas");r.width=t[0],r.height=t[1];const n=r.getContext("2d");return n?(e(n),r.toDataURL()):""};let lC=null;function QEt(){return lC||(lC={white:f9([1,1],t=>{t.fillStyle="#f8f9fa",t.fillRect(0,0,1,1)}),black:f9([1,1],t=>{t.fillStyle="#212529",t.fillRect(0,0,1,1)})}),lC}function Dle(t){return Math.ceil(Math.log2(Math.max(1,t)))}function ix(t,e){const r=Dle(t);return`tldraw_hash_pattern_${e}_${r}`}function Lle(t){const e=[],n=Dle(t);for(let o=0;o<=n;o++)e.push(Math.pow(2,o));return e}function JEt(t){const e=QEt();return Lle(t).flatMap(r=>[{zoom:r,url:e.white,theme:"light"},{zoom:r,url:e.black,theme:"dark"}])}function eCt(){const t=F(),e=H("devicePixelRatio",()=>t.getInstanceState().devicePixelRatio,[t]),r=H("maxZoom",()=>Math.ceil(Cr(t.getCameraOptions().zoomSteps)),[t]),[n,o]=x.useState(!1),[i,s]=x.useState(()=>JEt(r));return x.useEffect(()=>{const l=Promise.all(Lle(r).flatMap(u=>[h9(e,u,!1).then(d=>({zoom:u,theme:"light",url:URL.createObjectURL(d)})),h9(e,u,!0).then(d=>({zoom:u,theme:"dark",url:URL.createObjectURL(d)}))]));let c=!1;return l.then(u=>{c||(s(u),o(!0))}),()=>{c=!0,o(!1),l.then(u=>{for(const{url:d}of u)URL.revokeObjectURL(d)})}},[e,r]),{defs:h.jsx(h.Fragment,{children:i.map(l=>{const c=ix(l.zoom,l.theme);return h.jsx("pattern",{id:c,width:pp,height:pp,patternUnits:"userSpaceOnUse",children:h.jsx("image",{href:l.url,width:pp,height:pp})},c)})}),isReady:n}}function tCt(){const t=F(),e=x.useRef(null),{defs:r,isReady:n}=eCt();return x.useEffect(()=>{if(n&&t.environment.isSafari){const o=Nle(e.current);o&&t.timers.requestAnimationFrame(()=>{o.style.display="none",t.timers.requestAnimationFrame(()=>{o.style.display=""})})}},[t,n]),h.jsx("g",{ref:e,"data-testid":n?"ready-pattern-fill-defs":void 0,children:r})}function Nle(t){return t.classList.contains("tl-html-layer")?t:t.parentElement?Nle(t.parentElement):null}const Gr=ze.memo(function({theme:e,d:r,color:n,fill:o,scale:i}){switch(o){case"none":return null;case"solid":return h.jsx("path",{fill:e[n].semi,d:r});case"semi":return h.jsx("path",{fill:e.solid,d:r});case"fill":return h.jsx("path",{fill:e[n].fill,d:r});case"pattern":return h.jsx(rCt,{theme:e,color:n,fill:o,d:r,scale:i})}});function rCt({d:t,color:e,theme:r}){const n=F(),o=km(),i=H("zoomLevel",()=>n.getZoomLevel(),[n]),s=n.getZoomLevel()<=.18;return h.jsxs(h.Fragment,{children:[h.jsx("path",{fill:r[e].pattern,d:t}),h.jsx("path",{fill:o?`url(#${ix(1,r.id)})`:s?r[e].semi:`url(#${ix(i,r.id)})`,d:t})]})}function nCt(t){return t.replace(/\s/g," ")}function aA(t,e,r){const{padding:n=0}=r;if(e.length===0)return null;const o=ee.From(e[0].box);for(const{box:c}of e)o.union(c);const i=n+(r.offsetX??0),s=(r.offsetY??0)+r.fontSize/2+(r.verticalTextAlign==="start"?n:r.verticalTextAlign==="end"?r.height-n-o.height:(Math.ceil(r.height)-o.height)/2);let a=null;const l=[];for(const{text:c,box:u}of e)a!==null&&u.y>a&&l.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:i,y:u.y+s,children:`
|
|
380
|
-
`},l.length)),l.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+i,y:u.y+s,unicodeBidi:"plaintext",children:nCt(c)},l.length)),a=u.y;return h.jsx("text",{fontSize:r.fontSize,fontFamily:r.fontFamily,fontStyle:r.fontStyle,fontWeight:r.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,children:l})}function oCt(t,e,r,n){if((t==="start-legacy"||t==="end-legacy")&&r.length!==0){const o=ee.From(r[0].box);for(const{box:i}of r)o.union(i);if(t==="start-legacy")return(n-2*e-o.width)/2;if(t==="end-legacy")return-(n-2*e-o.width)/2}}function iCt(t){return t==="start-legacy"||t==="middle-legacy"||t==="end-legacy"}function Bb({fontSize:t,font:e,align:r,verticalAlign:n,text:o,labelColor:i,bounds:s,padding:a=16,stroke:l=!0}){const c=F(),u=ei(),d={fontSize:t,fontFamily:RG[e],textAlign:r,verticalTextAlign:n,width:Math.ceil(s.width),height:Math.ceil(s.height),padding:a,lineHeight:Rr.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:i,stroke:void 0,strokeWidth:void 0},f=c.textMeasure.measureTextSpans(o,d),p=oCt(r,a,f,s.width);p&&(d.offsetX=p),d.offsetX+=s.x,d.offsetY+=s.y;const g=aA(c,f,d);let m=null;return l&&(d.fill=u.background,d.stroke=u.background,d.strokeWidth=2,m=aA(c,f,d)),h.jsxs(h.Fragment,{children:[m,g]})}const sCt=x.forwardRef(function({isEditing:e,text:r,handleFocus:n,handleChange:o,handleKeyDown:i,handleBlur:s,handleInputPointerDown:a,handleDoubleClick:l},c){return h.jsx("textarea",{ref:c,className:"tl-text tl-text-input",name:"text",tabIndex:-1,readOnly:!e,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:r,onFocus:n,onChange:o,onKeyDown:i,onBlur:s,onTouchEnd:mr,onContextMenu:e?mr:void 0,onPointerDown:a,onDoubleClick:l,onDragStart:Ue})});function aCt(t,e,r){const n=F(),o=x.useRef(null),i=H("isEditing",()=>n.getEditingShapeId()===t,[n]),s=H("isEditingAnything",()=>!!n.getEditingShapeId(),[n]);x.useEffect(()=>{function u({shapeId:d}){var f;d===t&&((f=o.current)==null||f.select())}return n.on("select-all-text",u),()=>{n.off("select-all-text",u)}},[n,t,i]),x.useEffect(()=>{var u,d,f,p;i&&(document.activeElement!==o.current&&((u=o.current)==null||u.focus()),n.getInstanceState().isCoarsePointer&&((d=o.current)==null||d.select()),n.environment.isSafari&&((f=o.current)==null||f.blur(),(p=o.current)==null||p.focus()))},[n,i]);const a=x.useCallback(u=>{if(n.getEditingShapeId()===t)switch(u.key){case"Enter":{(u.ctrlKey||u.metaKey)&&n.complete();break}}},[n,t]),l=x.useCallback(u=>{if(n.getEditingShapeId()!==t)return;let d=fh.normalizeText(u.currentTarget.value);const f=d.replace(/\t/g,wd);if(f!==d){const p=u.currentTarget.selectionStart;u.currentTarget.value=f,u.currentTarget.selectionStart=p+(f.length-d.length),u.currentTarget.selectionEnd=p+(f.length-d.length),d=f}n.updateShape({id:t,type:e,props:{text:d}})},[n,t,e]),c=x.useCallback(u=>{n.dispatch({...Ln(u),type:"pointer",name:"pointer_down",target:"shape",shape:n.getShape(t)}),mr(u)},[n,t]);return{rInput:o,handleFocus:dg,handleBlur:dg,handleKeyDown:a,handleChange:l,handleInputPointerDown:c,handleDoubleClick:mr,isEmpty:r.trim().length===0,isEditing:i,isEditingAnything:s}}const Ub=ze.memo(function({id:e,type:r,text:n,labelColor:o,font:i,fontSize:s,lineHeight:a,align:l,verticalAlign:c,wrap:u,isSelected:d,padding:f=0,onKeyDown:p,classNamePrefix:g,style:m,textWidth:S,textHeight:y}){const{rInput:v,isEmpty:b,isEditing:$,isEditingAnything:P,...E}=aCt(e,r,n),[T,I]=x.useState(n);x.useEffect(()=>{$||I(n)},[$,n]);const _=fh.normalizeTextForDom(n),k=_.length>0,D=iCt(l);if(!$&&!k)return null;const R=g||"tl-text";return h.jsx("div",{className:`${R}-label tl-text-wrapper`,"data-font":i,"data-align":l,"data-hastext":!b,"data-isediting":$,"data-iseditinganything":P,"data-textwrap":!!u,"data-isselected":d,style:{justifyContent:l==="middle"||D?"center":l,alignItems:c==="middle"?"center":c,padding:f,...m},children:h.jsxs("div",{className:`${R}-label__inner tl-text-content__wrapper`,style:{fontSize:s,lineHeight:Math.floor(s*a)+"px",minHeight:Math.floor(s*a)+"px",minWidth:Math.ceil(S||0),color:o,width:S?Math.ceil(S):void 0,height:y?Math.ceil(y):void 0},children:[h.jsx("div",{className:`${R} tl-text tl-text-content`,dir:"auto",children:_.split(`
|
|
381
|
-
`).map((j,M)=>h.jsx("div",{dir:"auto",children:j},M))}),(P||d)&&h.jsx(sCt,{ref:v,text:n,isEditing:$,...E,handleKeyDown:p??E.handleKeyDown},T)]})})}),lCt=new ls;function cCt(t){return lCt.get(t,()=>t.store.createComputedCache("arrowLabelSize",e=>{const r=es(t,e);let n=0,o=0;const i=r.isStraight?new Ws({start:w.From(r.start.point),end:w.From(r.end.point)}):new md({center:w.Cast(r.handleArc.center),start:w.Cast(r.start.point),end:w.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});if(e.props.text.trim()){const s=i.bounds,a=lA(e),{w:l,h:c}=t.textMeasure.measureText(e.props.text,{...Rr,fontFamily:as[e.props.font],fontSize:a,maxWidth:null});if(n=l,o=c,s.width>s.height){n=Math.max(Math.min(l,64),Math.min(s.width-64,l));const{w:u,h:d}=t.textMeasure.measureText(e.props.text,{...Rr,fontFamily:as[e.props.font],fontSize:a,maxWidth:n});n=u,o=d}if(n>16*a){n=16*a;const{w:u,h:d}=t.textMeasure.measureText(e.props.text,{...Rr,fontFamily:as[e.props.font],fontSize:a,maxWidth:n});n=u,o=d}}return new w(n,o).addScalar(Cle*2*e.props.scale)}))}function Yj(t,e){return e.props.text.trim()===""?new w(0,0).addScalar(Cle*2*e.props.scale):cCt(t).get(e.id)??new w(0,0)}function Fle(t){const e=Qr[t.props.size];return($Et+(e-Qr.s)*2+(e===Qr.xl?20:0))*t.props.scale}function uCt(t,e,r){const n=Yj(t,e),o=Fle(e),i=w.Nudge(r.start.point,r.end.point,o),s=w.Nudge(r.end.point,r.start.point,o),a=vO(i,s,ee.FromCenter(r.middle,n).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[l,c]=a;w.Dist2(l,i)>w.Dist2(c,i)&&([c,l]=a);const u=i.add(w.Sub(r.middle,l)),d=s.add(w.Sub(r.middle,c)),f=w.Dist(r.start.point,u)/r.length,p=w.Dist(r.start.point,d)/r.length;return{start:f,end:p}}function dCt(t,e,r){const n=Yj(t,e),o=Fle(e),i=Math.sign(e.props.bend),s=o/r.handleArc.radius*i,a=w.Angle(r.bodyArc.center,r.start.point)-s,l=w.Angle(r.bodyArc.center,r.end.point)+s,c=Bc(r.bodyArc.center,r.bodyArc.radius,a),u=Bc(r.bodyArc.center,r.bodyArc.radius,l),d=[],f=g9(r.bodyArc.center,r.bodyArc.radius,a,l,i,ee.FromCenter(c,n).corners);d.push(new Vt({points:ee.FromCenter(c,n).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const p=g9(r.bodyArc.center,r.bodyArc.radius,a,l,i,ee.FromCenter(u,n).corners);d.push(new Vt({points:ee.FromCenter(u,n).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const T of[...f??[],...p??[],c,u])d.push(new ej({x:T.x-3,y:T.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const g=(f&&m9(r.start.point,f))??r.middle,m=(p&&m9(r.end.point,p))??r.middle,S=w.Angle(r.bodyArc.center,r.start.point),y=w.Angle(r.bodyArc.center,r.end.point),v=w.Angle(r.bodyArc.center,g),b=w.Angle(r.bodyArc.center,m);if(Ka(S,v,i)>Ka(S,b,i))return{start:.5,end:.5,dbg:d};const $=Ka(S,y,i),P=Ka(S,v,i)/$,E=Ka(S,b,i)/$;return{start:P,end:E,dbg:d}}function XS(t,e){let r;const n=[],o=es(t,e),i={hasStartBinding:!!o.bindings.start,hasEndBinding:!!o.bindings.end,hasStartArrowhead:o.start.arrowhead!=="none",hasEndArrowhead:o.end.arrowhead!=="none"};if(o.isStraight){const a=uCt(t,e,o),l=p9(t,e,a,i);r=w.Lrp(o.start.point,o.end.point,l)}else{const a=dCt(t,e,o);a.dbg&&n.push(...a.dbg);const l=p9(t,e,a,i),c=hCt(w.Angle(o.bodyArc.center,o.start.point),w.Angle(o.bodyArc.center,o.end.point),Math.sign(e.props.bend),l);r=Bc(o.bodyArc.center,o.bodyArc.radius,c)}const s=Yj(t,e);return{box:ee.FromCenter(r,s),debugGeom:n}}function p9(t,e,r,n){const{hasEndArrowhead:o,hasEndBinding:i,hasStartBinding:s,hasStartArrowhead:a}=n,l=Hle(t,e);let c=Pr(e.props.labelPosition,a||s?r.start:0,o||i?r.end:1);const u=Math.min(.02,500/l*.02);return c=c>=.5-u&&c<=.5+u?.5:c,c}function g9(t,e,r,n,o,i){const s=cT(t,e,i),a=Ka(r,n,o);return s==null?void 0:s.filter(l=>{const c=Ka(r,w.Angle(t,l),o);return c>=0&&c<=a})}function m9(t,e){let r=null,n=-1/0;for(const o of e){const i=w.Dist2(t,o);i>n&&(r=o,n=i)}return r}function hCt(t,e,r,n){const o=Ka(t,e,r);return t+o*n*r*-1}function lA(t){return bEt[t.props.size]*t.props.scale}function fCt(t,e,r){const n=e==="end"?t.end.point:t.start.point,o=e==="end"?t.start.point:t.end.point,i=t.isStraight?w.Dist(o,n):Math.abs(t.bodyArc.length),s=Math.max(Math.min(i/5,r*3),r);let a;if(t.isStraight)a=w.Nudge(n,o,s);else{const l=NPe(n,s,t.handleArc.center,t.handleArc.radius);a=e==="end"?t.handleArc.sweepFlag?l[0]:l[1]:t.handleArc.sweepFlag?l[1]:l[0]}return w.IsNaN(a)&&(a=t.start.point),{point:n,int:a}}function pCt({point:t,int:e}){const r=w.RotWith(e,t,Ze/6),n=w.RotWith(e,t,-Ze/6);return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${n.x} ${n.y}`}function gCt({point:t,int:e}){const r=w.RotWith(e,t,Ze/6),n=w.RotWith(e,t,-Ze/6);return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${n.x} ${n.y} Z`}function mCt({point:t,int:e}){const r=w.Sub(e,t).div(2),n=w.Add(t,w.Rot(r,vt)),o=w.Sub(t,w.Rot(r,vt));return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${o.x} ${o.y} Z`}function vCt({point:t,int:e}){const r=w.Lrp(t,e,.45),n=w.Dist(r,t);return`M ${r.x-n},${r.y}
|
|
382
|
-
a ${n},${n} 0 1,0 ${n*2},0
|
|
383
|
-
a ${n},${n} 0 1,0 -${n*2},0 `}function yCt({point:t,int:e}){const r=w.Lrp(t,e,.75),n=w.RotWith(r,t,Ze/4),o=w.RotWith(r,t,-Ze/4),i=w.Lrp(n,o,.5);return i.add(w.Sub(i,t)),`M ${i.x} ${i.y} L ${n.x} ${n.y} ${t.x} ${t.y} L ${o.x} ${o.y} Z`}function SCt({int:t,point:e}){const r=w.Lrp(e,t,.85),n=w.Sub(r,e).div(2),o=w.Add(e,w.Rot(n,vt)),i=w.Sub(e,w.Rot(n,vt)),s=w.Add(r,w.Rot(n,vt)),a=w.Sub(r,w.Rot(n,vt));return`M ${o.x} ${o.y} L ${s.x} ${s.y} L ${a.x} ${a.y} L ${i.x} ${i.y} Z`}function wCt({int:t,point:e}){const r=w.Sub(t,e).div(2),n=w.Add(e,w.Rot(r,vt)),o=w.Sub(e,w.Rot(r,vt));return`M ${n.x} ${n.y} L ${o.x} ${o.y}`}function sx(t,e,r){const n=e==="end"?t.end.arrowhead:t.start.arrowhead;if(n==="none")return;const o=fCt(t,e,r);if(o){switch(n){case"bar":return wCt(o);case"square":return SCt(o);case"diamond":return yCt(o);case"dot":return vCt(o);case"inverted":return mCt(o);case"arrow":return pCt(o);case"triangle":return gCt(o)}return""}}function xCt(t){const{start:e,end:r,handleArc:{radius:n,largeArcFlag:o,sweepFlag:i}}=t;return`M${e.handle.x},${e.handle.y} A${n} ${n} 0 ${o} ${i} ${r.handle.x},${r.handle.y}`}function Ble(t){const{start:e,end:r,bodyArc:{radius:n,largeArcFlag:o,sweepFlag:i}}=t;return`M${e.point.x},${e.point.y} A${n} ${n} 0 ${o} ${i} ${r.point.x},${r.point.y}`}function Ule(t,e){return`M${t.x},${t.y}L${e.x},${e.y}`}function bCt(t){return Ule(t.start.handle,t.end.handle)}function zle(t){return Ule(t.start.point,t.end.point)}let $Ct=0;class qS extends Si{constructor(){super(...arguments);C(this,"_resizeInitialBindings",new ls)}canEdit(){return!0}canBind({toShapeType:r}){return r!=="arrow"}canSnap(){return!1}hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsBg(){return!0}hideSelectionBoundsFg(){return!0}canBeLaidOut(r){const n=Rn(this.editor,r);return!n.start&&!n.end}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{x:0,y:0},end:{x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw",scale:1}}getGeometry(r){const n=es(this.editor,r),o=[],i=n.isStraight?new Ws({start:w.From(n.start.point),end:w.From(n.end.point)}):new md({center:w.Cast(n.handleArc.center),start:w.Cast(n.start.point),end:w.Cast(n.end.point),sweepFlag:n.bodyArc.sweepFlag,largeArcFlag:n.bodyArc.largeArcFlag});let s;if(r.props.text.trim()){const a=XS(this.editor,r);o.push(...a.debugGeom),s=new ia({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new bi({children:[...s?[i,s]:[i],...o]})}getHandles(r){const n=es(this.editor,r);return[{id:"start",type:"vertex",index:"a0",x:n.start.handle.x,y:n.start.handle.y},{id:"middle",type:"virtual",index:"a2",x:n.middle.x,y:n.middle.y},{id:"end",type:"vertex",index:"a3",x:n.end.handle.x,y:n.end.handle.y}].filter(Boolean)}getText(r){return r.props.text}onHandleDrag(r,{handle:n,isPrecise:o}){const i=n.id,s=Rn(this.editor,r);if(i==="middle"){const{start:E,end:T}=yd(this.editor,r,s),I=w.Sub(T,E),_=w.Per(I),k=w.Med(T,E),D=w.Sub(k,_),R=w.Add(k,_),j=w.NearestPointOnLineSegment(D,R,n,!1);let M=w.Dist(j,k);return w.Clockwise(j,T,k)&&(M*=-1),{id:r.id,type:r.type,props:{bend:M}}}const a={id:r.id,type:"arrow",props:{}},l=s[i],u=s[i==="start"?"end":"start"];if(this.editor.inputs.ctrlKey)return WS(this.editor,r,i),a.props[i]={x:n.x,y:n.y},a;const d=this.editor.getShapePageTransform(r.id).applyToPoint(n),f=this.editor.getShapeAtPoint(d,{hitInside:!0,hitFrameInside:!0,margin:0,filter:E=>!E.isLocked&&this.editor.canBindShapes({fromShape:r,toShape:E,binding:"arrow"})});if(!f)return WS(this.editor,r,i),a.props[i]={x:n.x,y:n.y},a;const p=this.editor.getShapeGeometry(f),g=ee.ZeroFix(p.bounds),S=this.editor.getShapePageTransform(a.id).applyToPoint(n),y=this.editor.getPointInShapeSpace(f,S);let v=o;v||(!l||l&&f.id!==l.toId)&&(v=this.editor.inputs.pointerVelocity.len()<.5),o||(p.isClosed||(v=!0),u&&f.id===u.toId&&u.props.isPrecise&&(v=!0));const b={x:(y.x-g.minX)/g.width,y:(y.y-g.minY)/g.height};v&&w.Dist(y,g.center)<Math.max(4,Math.min(Math.min(g.width,g.height)*.15,16))/this.editor.getZoomLevel()&&(b.x=.5,b.y=.5);const $={terminal:i,normalizedAnchor:b,isPrecise:v,isExact:this.editor.inputs.altKey};zf(this.editor,r,f.id,$),this.editor.setHintingShapes([f.id]);const P=Rn(this.editor,r);return P.start&&P.end&&P.start.toId===P.end.toId&&w.Equals(P.start.props.normalizedAnchor,P.end.props.normalizedAnchor)&&zf(this.editor,r,P.end.toId,{...P.end.props,normalizedAnchor:{x:P.end.props.normalizedAnchor.x+.05,y:P.end.props.normalizedAnchor.y}}),a}onTranslateStart(r){const n=Rn(this.editor,r),o=yd(this.editor,r,n),i=this.editor.getShapePageTransform(r.id),s=this.editor.getSelectedShapeIds();if(!(n.start&&(s.includes(n.start.toId)||this.editor.isAncestorSelected(n.start.toId))||n.end&&(s.includes(n.end.toId)||this.editor.isAncestorSelected(n.end.toId)))){y9.set(r,{pagePosition:i.applyToPoint(r),terminalBindings:Ug(o,(a,l)=>{const c=n[a];return c?{binding:c,shapePosition:l,pagePosition:i.applyToPoint(l)}:null})}),n.start&&(ox({editor:this.editor,arrow:r,terminal:"start",useHandle:!0}),r=this.editor.getShape(r.id)),n.end&&ox({editor:this.editor,arrow:r,terminal:"end",useHandle:!0});for(const a of["start","end"]){const l=n[a];l&&this.editor.updateBinding({...l,props:{...l.props,isPrecise:!0}})}}}onTranslate(r,n){const o=y9.get(r);if(!o)return;const i=this.editor.getShapePageTransform(n.id),s=w.Sub(i.applyToPoint(n),o.pagePosition);for(const a of Object.values(o.terminalBindings)){if(!a)continue;const l=w.Add(a.pagePosition,w.Mul(s,.5)),c=this.editor.getShapeAtPoint(l,{hitInside:!0,hitFrameInside:!0,margin:0,filter:u=>!u.isLocked&&this.editor.canBindShapes({fromShape:n,toShape:u,binding:"arrow"})});if((c==null?void 0:c.id)===a.binding.toId){const u=ee.ZeroFix(this.editor.getShapeGeometry(c).bounds),d=this.editor.getPointInShapeSpace(c,l),f={x:(d.x-u.minX)/u.width,y:(d.y-u.minY)/u.height};zf(this.editor,n,c.id,{...a.binding.props,normalizedAnchor:f,isPrecise:!0})}else WS(this.editor,n,a.binding.props.terminal)}}onResize(r,n){const{scaleX:o,scaleY:i}=n,s=this._resizeInitialBindings.get(r,()=>Rn(this.editor,r)),a=yd(this.editor,r,s),{start:l,end:c}=$t(r.props);let{bend:u}=r.props;s.start||(l.x=a.start.x*o,l.y=a.start.y*i),s.end||(c.x=a.end.x*o,c.y=a.end.y*i);const d=Math.abs(o),f=Math.abs(i),p=s!=null&&s.start?w.From(s.start.props.normalizedAnchor):null,g=s!=null&&s.end?w.From(s.end.props.normalizedAnchor):null;return o<0&&i>=0?(u!==0&&(u*=-1,u*=Math.max(d,f)),p&&(p.x=1-p.x),g&&(g.x=1-g.x)):o>=0&&i<0?(u!==0&&(u*=-1,u*=Math.max(d,f)),p&&(p.y=1-p.y),g&&(g.y=1-g.y)):o>=0&&i>=0?u!==0&&(u*=Math.max(d,f)):o<0&&i<0&&(u!==0&&(u*=Math.max(d,f)),p&&(p.x=1-p.x,p.y=1-p.y),g&&(g.x=1-g.x,g.y=1-g.y)),s.start&&p&&zf(this.editor,r,s.start.toId,{...s.start.props,normalizedAnchor:p.toJson()}),s.end&&g&&zf(this.editor,r,s.end.toId,{...s.end.props,normalizedAnchor:g.toJson()}),{props:{start:l,end:c,bend:u}}}onDoubleClickHandle(r,n){switch(n.id){case"start":return{id:r.id,type:r.type,props:{...r.props,arrowheadStart:r.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:r.id,type:r.type,props:{...r.props,arrowheadEnd:r.props.arrowheadEnd==="none"?"arrow":"none"}}}}component(r){const n=ei(),o=this.editor.getOnlySelectedShape(),i=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getInstanceState().isReadonly,s=es(this.editor,r);if(!(s!=null&&s.isValid))return null;const a=XS(this.editor,r),l=r.id===this.editor.getOnlySelectedShapeId(),u=this.editor.getEditingShapeId()===r.id||r.props.text;return h.jsxs(h.Fragment,{children:[h.jsx(xl,{id:r.id,style:{minWidth:50,minHeight:50},children:h.jsx(v9,{shape:r,shouldDisplayHandles:i&&(o==null?void 0:o.id)===r.id})}),u&&h.jsx(Ub,{id:r.id,classNamePrefix:"tl-arrow",type:"arrow",font:r.props.font,fontSize:lA(r),lineHeight:Rr.lineHeight,align:"middle",verticalAlign:"middle",text:r.props.text,labelColor:n[r.props.labelColor].solid,textWidth:a.box.w,isSelected:l,padding:0,style:{transform:`translate(${a.box.center.x}px, ${a.box.center.y}px)`}})]})}indicator(r){const n=gb(r.id),o=es(this.editor,r);if(!o)return null;const{start:i,end:s}=yd(this.editor,r,o==null?void 0:o.bindings),a=this.editor.getShapeGeometry(r),l=a.bounds,c=r.props.text.trim()?a.children[1]:null;if(w.Equals(i,s))return null;const u=Qr[r.props.size]*r.props.scale,d=o.start.arrowhead&&sx(o,"start",u),f=o.end.arrowhead&&sx(o,"end",u),p=o.isStraight?zle(o):Ble(o),g=d&&o.start.arrowhead!=="arrow"||f&&o.end.arrowhead!=="arrow"||!!c,m=(r.id+"_clip").replace(":","_");return n&&c?h.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,rx:3.5*r.props.scale,ry:3.5*r.props.scale}):h.jsxs("g",{children:[g&&h.jsx("defs",{children:h.jsxs("mask",{id:m,children:[h.jsx("rect",{x:l.minX-100,y:l.minY-100,width:l.w+200,height:l.h+200,fill:"white"}),c&&h.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,fill:"black",rx:3.5*r.props.scale,ry:3.5*r.props.scale}),d&&h.jsx("path",{d,fill:o.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),f&&h.jsx("path",{d:f,fill:o.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{...g?{mask:`url(#${m})`}:void 0,children:[g&&h.jsx("rect",{x:l.minX-100,y:l.minY-100,width:l.width+200,height:l.height+200,opacity:0}),h.jsx("path",{d:p})]}),d&&h.jsx("path",{d}),f&&h.jsx("path",{d:f}),c&&h.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5})]})}onEditEnd(r){const{id:n,type:o,props:{text:i}}=r;i.trimEnd()!==r.props.text&&this.editor.updateShapes([{id:n,type:o,props:{text:i.trimEnd()}}])}toSvg(r,n){n.addExportDef(Gj(r.props.fill)),r.props.text&&n.addExportDef(Fb(r.props.font));const o=ma(n),i=1/r.props.scale;return h.jsxs("g",{transform:`scale(${i})`,children:[h.jsx(v9,{shape:r,shouldDisplayHandles:!1}),h.jsx(Bb,{fontSize:lA(r),font:r.props.font,align:"middle",verticalAlign:"middle",text:r.props.text,labelColor:o[r.props.labelColor].solid,bounds:XS(this.editor,r).box,padding:4*r.props.scale})]})}getCanvasSvgDefs(){return[Vj(),{key:"arrow:dot",component:ICt},{key:"arrow:cross",component:PCt}]}getInterpolatedProps(r,n,o){return{...o>.5?n.props:r.props,scale:He(r.props.scale,n.props.scale,o),start:{x:He(r.props.start.x,n.props.start.x,o),y:He(r.props.start.y,n.props.start.y,o)},end:{x:He(r.props.end.x,n.props.end.x,o),y:He(r.props.end.y,n.props.end.y,o)},bend:He(r.props.bend,n.props.bend,o),labelPosition:He(r.props.labelPosition,n.props.labelPosition,o)}}}C(qS,"type","arrow"),C(qS,"props",DG),C(qS,"migrations",LG);function Hle(t,e){const r=es(t,e);return r.isStraight?w.Dist(r.start.handle,r.end.handle):Math.abs(r.handleArc.length)}const v9=yr(function({shape:e,shouldDisplayHandles:r}){const n=F(),o=ei(),i=es(n,e),s=ee.ZeroFix(n.getShapeGeometry(e).bounds),a=Rn(n,e),l=H("force solid",()=>n.getZoomLevel()<.2,[n]),c=ze.useMemo(()=>n.environment.isSafari?$Ct+=1:0,[e]);if(!(i!=null&&i.isValid))return null;const u=Qr[e.props.size]*e.props.scale,d=i.start.arrowhead&&sx(i,"start",u),f=i.end.arrowhead&&sx(i,"end",u),p=i.isStraight?zle(i):Ble(i);let g=null;if(r){const P=2/n.getZoomLevel(),{strokeDasharray:E,strokeDashoffset:T}=di(Hle(n,e),P,{end:"skip",start:"skip",lengthRatio:2.5});g=a.start||a.end?h.jsx("path",{className:"tl-arrow-hint",d:i.isStraight?bCt(i):xCt(i),strokeDasharray:E,strokeDashoffset:T,strokeWidth:P,markerStart:a.start?a.start.props.isExact?"":a.start.props.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",markerEnd:a.end?a.end.props.isExact?"":a.end.props.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",opacity:.16}):null}const{strokeDasharray:m,strokeDashoffset:S}=di(i.isStraight?i.length:Math.abs(i.bodyArc.length),u,{style:e.props.dash,forceSolid:l}),y=XS(n,e),v=!(i.start.arrowhead==="none"||i.start.arrowhead==="arrow"),b=!(i.end.arrowhead==="none"||i.end.arrowhead==="arrow"),$=(e.id+"_clip_"+c).replace(":","_");return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsxs("mask",{id:$,children:[h.jsx("rect",{x:N(-100+s.minX),y:N(-100+s.minY),width:N(s.width+200),height:N(s.height+200),fill:"white"}),e.props.text.trim()&&h.jsx("rect",{x:y.box.x,y:y.box.y,width:y.box.w,height:y.box.h,fill:"black",rx:4,ry:4}),d&&v&&h.jsx("path",{d,fill:i.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),f&&b&&h.jsx("path",{d:f,fill:i.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{fill:"none",stroke:o[e.props.color].solid,strokeWidth:u,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[g,h.jsxs("g",{mask:`url(#${$})`,children:[h.jsx("rect",{x:N(s.minX-100),y:N(s.minY-100),width:N(s.width+200),height:N(s.height+200),opacity:0}),h.jsx("path",{d:p,strokeDasharray:m,strokeDashoffset:S})]}),d&&v&&e.props.fill!=="none"&&h.jsx(Gr,{theme:o,d,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),f&&b&&e.props.fill!=="none"&&h.jsx(Gr,{theme:o,d:f,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),d&&h.jsx("path",{d}),f&&h.jsx("path",{d:f})]})]})}),y9=new WeakMap;function ICt(){return h.jsx("marker",{id:"arrowhead-dot",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:h.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function PCt(){return h.jsxs("marker",{id:"arrowhead-cross",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[h.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),h.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const S9="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E";function ph({url:t,zoomLevel:e}){return h.jsx("a",{className:pe("tl-hyperlink-button",{"tl-hyperlink-button__hidden":e<.32}),href:t,target:"_blank",rel:"noopener noreferrer",onPointerDown:mr,onPointerUp:mr,title:t,draggable:!1,children:h.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${S9}") center 100% / 100% no-repeat`,WebkitMask:`url("${S9}") center 100% / 100% no-repeat`}})})}const w9="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E",ECt=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function ax(t){return ECt.map(r=>{const{offsetX:n,offsetY:o,blur:i,spread:s,color:a}=r,l=new w(n,o),{x:c,y:u}=l.rot(-t);return`${c}px ${u}px ${i}px ${s}px ${a}`}).join(", ")}const CCt=300,Wle=320,_Ct=46,TCt=101;class ZS extends Vh{canResize(){return!1}hideSelectionBoundsFg(){return!0}getText(e){return e.props.url}getDefaultProps(){return{url:"",w:CCt,h:Wle,assetId:null}}component(e){return h.jsx(ACt,{shape:e,util:this})}indicator(e){return h.jsx("rect",{width:N(e.props.w),height:N(e.props.h),rx:"6",ry:"6"})}onBeforeCreate(e){return x9(this.editor,e)}onBeforeUpdate(e,r){if(e.props.url!==r.props.url)if(go.isValid(r.props.url))OCt(this.editor,r);else return{...r,props:{...r.props,url:e.props.url}};if(e.props.assetId!==r.props.assetId)return x9(this.editor,r)}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,w:He(e.props.w,r.props.w,n),h:He(e.props.h,r.props.h,n)}}}C(ZS,"type","bookmark"),C(ZS,"props",HG),C(ZS,"migrations",WG);function ACt({shape:t,util:e}){const r=t.props.assetId?e.editor.getAsset(t.props.assetId):null,n=!!km()&&e.editor.environment.isSafari,o=e.editor.getShapePageTransform(t).rotation(),i=kCt(t),[s,a]=x.useState(!0),l=()=>a(!1);return h.jsx(ml,{children:h.jsxs("div",{className:pe("tl-bookmark__container",n&&"tl-bookmark__container--safariExport"),style:{boxShadow:n?void 0:ax(o),maxHeight:t.props.h},children:[(!r||r.props.image)&&h.jsxs("div",{className:"tl-bookmark__image_container",children:[r?h.jsx("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:r==null?void 0:r.props.image,alt:(r==null?void 0:r.props.title)||""}):h.jsx("div",{className:"tl-bookmark__placeholder"}),(r==null?void 0:r.props.image)&&h.jsx(ph,{url:t.props.url,zoomLevel:e.editor.getZoomLevel()})]}),h.jsxs("div",{className:"tl-bookmark__copy_container",children:[r!=null&&r.props.title?h.jsx("h2",{className:"tl-bookmark__heading",children:TEt(r.props.title)}):null,r!=null&&r.props.description&&(r!=null&&r.props.image)?h.jsx("p",{className:"tl-bookmark__description",children:r.props.description}):null,h.jsxs("a",{className:"tl-bookmark__link",href:t.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:mr,onPointerUp:mr,onClick:mr,children:[s&&(r!=null&&r.props.favicon)?h.jsx("img",{className:"tl-bookmark__favicon",src:r==null?void 0:r.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",onError:l,alt:`favicon of ${i}`}):h.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${w9}") center 100% / 100% no-repeat`,WebkitMask:`url("${w9}") center 100% / 100% no-repeat`}}),h.jsx("span",{children:i})]})]})]})})}function x9(t,e){const r=e.props.assetId?t.getAsset(e.props.assetId):null;let n=Wle;return r&&(r.props.image||(r.props.title?n=TCt:n=_Ct)),{...e,props:{...e.props,h:n}}}const kCt=t=>{try{return new URL(t.props.url).hostname.replace(/^www\./,"")}catch{return t.props.url}};function OCt(t,e){const{url:r}=e.props,n=Wa.createId(O_(r));t.getAsset(n)?e.props.assetId!==n&&t.updateShapes([{id:e.id,type:e.type,props:{assetId:n}}]):(t.updateShapes([{id:e.id,type:e.type,props:{assetId:null}}]),MCt(t,e))}const MCt=Ik(async(t,e)=>{if(t.isDisposed)return;const{url:r}=e.props,n=await t.getAssetForExternalContent({type:"url",url:r});n&&t.run(()=>{t.createAssets([n]),t.updateShapes([{id:e.id,type:e.type,props:{assetId:n.id}}])})},500);function Zc(t,e=!1){const r=t.length;if(r<2)return"";let n=t[0].point,o=t[1].point;if(r===2)return`M${Xe(n)}L${Xe(o)}`;let i="";for(let s=2,a=r-1;s<a;s++)n=t[s].point,o=t[s+1].point,i+=On(n,o);return e?`M${On(t[0].point,t[1].point)}Q${Xe(t[1].point)}${On(t[1].point,t[2].point)}T${i}${On(t[r-1].point,t[0].point)}${On(t[0].point,t[1].point)}Z`:`M${Xe(t[0].point)}Q${Xe(t[1].point)}${On(t[1].point,t[2].point)}${t.length>3?"T":""}${i}L${Xe(t[r-1].point)}`}function RCt(t,e={}){const{start:r={},end:n={}}=e,{cap:o=!0}=r,{cap:i=!0}=n;Qe(!r.taper&&!n.taper,"cap taper not supported here"),Qe(!r.easing&&!n.easing,"cap easing not supported here"),Qe(o&&i,"cap must be true");const s=fs(t,e);Lb(s,e);const a=jCt(s);let l="";for(const c of a)l+=LCt(c,e);return l}function jCt(t){if(t.length<=2)return[t];const e=[];let r=[t[0]],n=w.Sub(t[1].point,t[0].point).uni(),o,i,s,a,l;for(let c=1,u=t.length;c<u-1;c++){if(s=t[c-1],a=t[c],l=t[c+1],o=w.Sub(l.point,a.point).uni(),i=w.Dpr(n,o),n=o,i<-.8){const d={...a,point:a.input};r.push(d),e.push(cC(r)),r=[d];continue}if(r.push(a),!(i>.7)&&(w.Dist2(s.point,a.point)+w.Dist2(a.point,l.point))/((s.radius+a.radius+l.radius)/3)**2<1.5){r.push(a),e.push(cC(r)),r=[a];continue}}return r.push(t[t.length-1]),e.push(cC(r)),e}function cC(t){const e=t[0];let r;for(;t.length>2&&(r=t[1],w.Dist2(e.point,r.point)<((e.radius+r.radius)/2*.5)**2);)t.splice(1,1);const n=t[t.length-1];let o;for(;t.length>2&&(o=t[t.length-2],w.Dist2(n.point,o.point)<((n.radius+o.radius)/2*.5)**2);)t.splice(t.length-2,1);return t.length>1&&(t[0]={...t[0],vector:w.Sub(t[0].point,t[1].point).uni()},t[t.length-1]={...t[t.length-1],vector:w.Sub(t[t.length-2].point,t[t.length-1].point).uni()}),t}function DCt(t,e,r){return"M "+t+" "+e+" m -"+r+", 0 a "+r+","+r+" 0 1,1 "+r*2+",0 a "+r+","+r+" 0 1,1 -"+r*2+",0"}function LCt(t,e={}){if(t.length===0)return"";if(t.length===1)return DCt(t[0].point.x,t[0].point.y,t[0].radius);const{left:r,right:n}=Ile(t,e);n.reverse();let o=`M${Xe(r[0])}T`;for(let i=1;i<r.length;i++)o+=On(r[i-1],r[i]);{const i=t[t.length-1],s=i.radius,a=i.vector.clone().per().neg(),l=w.Add(i.point,w.Mul(a,s)),c=w.Add(i.point,w.Mul(a,-s));o+=`${Xe(l)}A${N(s)},${N(s)} 0 0 1 ${Xe(c)}T`}for(let i=1;i<n.length;i++)o+=On(n[i-1],n[i]);{const i=t[0],s=i.radius,a=i.vector.clone().per(),l=w.Add(i.point,w.Mul(a,s)),c=w.Add(i.point,w.Mul(a,-s));o+=`${Xe(l)}A${N(s)},${N(s)} 0 0 1 ${Xe(c)}Z`}return o}const Kle=(t,e,r)=>{const n=[],o=[];t.forEach(c=>n.push(...c.points)),e.forEach(c=>o.push(...c.points));const i=Math.max(n.length,o.length),s=[],a=[];for(let c=0;c<i;c++)s.push(n[c]||n[n.length-1]),a.push(o[c]||o[o.length-1]);return[{type:"free",points:s.map((c,u)=>{let d=.5;return a[u].z!==void 0&&c.z!==void 0&&(d=He(c.z,a[u].z,r)),{x:He(c.x,a[u].x,r),y:He(c.y,a[u].y,r),z:d}})}]},NCt=t=>t*.65+i$e(t*Ze/2)*.35,FCt=t=>({size:t,thinning:.5,streamline:Xd(t,[9,16],[.64,.74],!0),smoothing:.62,easing:pr.easeOutSine,simulatePressure:!0}),BCt=t=>({size:1+t*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:NCt}),b9=t=>({size:t,thinning:0,streamline:Xd(t,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:pr.linear}),UCt=t=>({size:t,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:pr.linear});function Xj({strokeWidth:t,showAsComplete:e}){return{size:1+t,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:pr.easeOutSine,last:e}}function cA(t,e,r,n){const o=t.isComplete||r;return n?t.isPen?{...UCt(e),last:o}:{...b9(e),last:o}:t.dash==="draw"?t.isPen?{...BCt(e),last:o}:{...FCt(e),last:o}:{...b9(e),last:o}}function gh(t){const e=[];for(const r of t)if(r.type==="free"||r.points.length<2)e.push(...r.points.map(w.Cast));else{const n=Math.max(4,Math.floor(w.Dist(r.points[0],r.points[1])/16));e.push(...w.PointsBetween(r.points[0],r.points[1],n))}return e}function zCt(t,e,r){return{draw:"none",solid:"none",dotted:`${r<.2?0:.1} ${e*2}`,dashed:`${e*2} ${e*2}`}[t.props.dash]}class QS extends Si{hideResizeHandles(e){return uC(e)}hideRotateHandle(e){return uC(e)}hideSelectionBoundsFg(e){return uC(e)}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1}}getGeometry(e){const r=gh(e.props.segments),n=(Qr[e.props.size]+1)*e.props.scale;if(e.props.segments.length===1){const i=ee.FromPoints(r);if(i.width<n*2&&i.height<n*2)return new ej({x:-n,y:-n,radius:n,isFilled:!0})}const o=fs(r,cA(e.props,n,e.props.isPen,!0)).map(i=>i.point);return e.props.isClosed?new Vt({points:o,isFilled:e.props.fill!=="none"}):new Ah({points:o})}component(e){return h.jsx(xl,{id:e.id,children:h.jsx($9,{shape:e,zoomLevel:this.editor.getZoomLevel()})})}indicator(e){var u;const r=gh(e.props.segments);let n=(Qr[e.props.size]+1)*e.props.scale;const o=this.editor.getZoomLevel();!(o<.5&&o<1.5/n)&&!e.props.isPen&&e.props.dash==="draw"&&r.length===1&&(n+=Ei(e.id)()*(n/6));const s=e.props.isComplete||((u=Cr(e.props.segments))==null?void 0:u.type)==="straight",a=cA(e.props,n,s,!0),l=fs(r,a),c=l.length>1?Zc(l,e.props.isClosed):Gle(r[0],n);return h.jsx("path",{d:c})}toSvg(e,r){r.addExportDef(Gj(e.props.fill));const n=1/e.props.scale;return h.jsx("g",{transform:`scale(${n})`,children:h.jsx($9,{shape:e,zoomLevel:1})})}getCanvasSvgDefs(){return[Vj()]}onResize(e,r){const{scaleX:n,scaleY:o}=r,i=[];for(const s of e.props.segments)i.push({...s,points:s.points.map(({x:a,y:l,z:c})=>({x:Us(n*a),y:Us(o*l),z:c}))});return{props:{segments:i}}}expandSelectionOutlinePx(e){const r=e.props.dash==="draw"?1.6:1;return Qr[e.props.size]*r/2*e.props.scale}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,segments:Kle(e.props.segments,r.props.segments,n),scale:He(e.props.scale,r.props.scale,n)}}}C(QS,"type","draw"),C(QS,"props",GG),C(QS,"migrations",VG);function Gle(t,e){const r=(e+1)*.5;return`M ${t.x} ${t.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r*2},0 a ${r},${r} 0 1,0 -${r*2},0`}function uC(t){return t.props.segments.length===1&&t.props.segments[0].points.length<2}function $9({shape:t,zoomLevel:e}){var d;const r=ei(),n=gh(t.props.segments),o=t.props.isComplete||((d=Cr(t.props.segments))==null?void 0:d.type)==="straight";let i=(Qr[t.props.size]+1)*t.props.scale;const s=e<.5&&e<1.5/i;!s&&!t.props.isPen&&t.props.dash==="draw"&&n.length===1&&(i+=Ei(t.id)()*(i/6));const a=cA(t.props,i,o,s);if(!s&&t.props.dash==="draw")return h.jsxs(h.Fragment,{children:[t.props.isClosed&&t.props.fill&&n.length>1?h.jsx(Gr,{d:Zc(fs(n,a),t.props.isClosed),theme:r,color:t.props.color,fill:t.props.isClosed?t.props.fill:"none",scale:t.props.scale}):null,h.jsx("path",{d:RCt(n,a),strokeLinecap:"round",fill:r[t.props.color].solid})]});const l=fs(n,a),c=l.length<2,u=c?Gle(n[0],0):Zc(l,t.props.isClosed);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{d:u,theme:r,color:t.props.color,fill:c||t.props.isClosed?t.props.fill:"none",scale:t.props.scale}),h.jsx("path",{d:u,strokeLinecap:"round",fill:c?r[t.props.color].solid:"none",stroke:r[t.props.color].solid,strokeWidth:i,strokeDasharray:c?"none":zCt(t,i,e),strokeDashoffset:"0"})]})}function HCt(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function WCt(t,e){const r=$e(e);if(!r)return;const n=r.host.replace("www.","");for(const o of t)if(Vle(o.hostnames,n)){const i=o.fromEmbedUrl(e);if(i)return{definition:o,url:i,embedUrl:e}}}const KCt=t=>t.split("*").map(e=>HCt(e)).join(".+"),Vle=(t,e)=>!!t.find(r=>{const n=new RegExp(KCt(r));return e.match(n)});function GCt(t,e){const r=$e(e);if(!r)return;const n=r.host.replace("www.","");for(const o of t)if(Vle(o.hostnames,n)){const i=o.toEmbedUrl(e);if(i)return{definition:o,embedUrl:i,url:e}}}function VCt(t,e){try{return GCt(t,e)??WCt(t,e)}catch{return}}const YCt=t=>Object.entries(t).filter(([e,r])=>r).map(([e])=>e).join(" ");class JS extends Vh{constructor(){super(...arguments);C(this,"embedDefinitions",uj)}setEmbedDefinitions(r){this.embedDefinitions=r}getEmbedDefinitions(){return this.embedDefinitions}getEmbedDefinition(r){return VCt(this.embedDefinitions,r)}getText(r){return r.props.url}hideSelectionBoundsFg(r){return!this.canResize(r)}canEdit(){return!0}canResize(r){var n,o;return!!((o=(n=this.getEmbedDefinition(r.props.url))==null?void 0:n.definition)!=null&&o.doesResize)}canEditInReadOnly(){return!0}getDefaultProps(){return{w:300,h:300,url:""}}isAspectRatioLocked(r){const n=this.getEmbedDefinition(r.props.url);return(n==null?void 0:n.definition.isAspectRatioLocked)??!1}onResize(r,n){const o=this.isAspectRatioLocked(r),i=this.getEmbedDefinition(r.props.url);let s=(i==null?void 0:i.definition.minWidth)??200,a=(i==null?void 0:i.definition.minHeight)??200;if(o){const l=r.props.w/r.props.h;l>1?s*=l:a/=l}return pb(r,n,{minWidth:s,minHeight:a})}component(r){const n=km(),{w:o,h:i,url:s}=r.props,a=gb(r.id),l=this.getEmbedDefinition(s),c=H("is hovering",()=>{const{editingShapeId:g,hoveredShapeId:m}=this.editor.getCurrentPageState();if(g&&m!==g){const S=this.editor.getShape(g);if(S&&this.editor.isShapeOfType(S,"embed"))return!0}return!1},[]),u=this.editor.getShapePageTransform(r).rotation();if(n)return h.jsx(ml,{className:"tl-embed-container",id:r.id,children:h.jsx("div",{className:"tl-embed",style:{border:0,boxShadow:ax(u),borderRadius:(l==null?void 0:l.definition.overrideOutlineRadius)??8,background:(l==null?void 0:l.definition.backgroundColor)??"var(--color-background)",width:o,height:i}})});const d=a||c;if(typeof window<"u"&&(window!==window.top||window.self!==window.parent)&&(l==null?void 0:l.definition.type)==="tldraw")return null;if((l==null?void 0:l.definition.type)==="github_gist"){const g=l.url.split("/").pop();if(!g)throw Error("No gist id!");return h.jsx(ml,{className:"tl-embed-container",id:r.id,children:h.jsx(XCt,{id:g,width:N(o),height:N(i),isInteractive:d,pageRotation:u})})}const p=YCt({...M1t,...(l==null?void 0:l.definition.overridePermissions)??{}});return h.jsx(ml,{className:"tl-embed-container",id:r.id,children:l!=null&&l.definition?h.jsx("iframe",{className:"tl-embed",sandbox:p,src:l.embedUrl,width:N(o),height:N(i),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:d?"auto":"none",zIndex:d?"":"-1",boxShadow:ax(u),borderRadius:(l==null?void 0:l.definition.overrideOutlineRadius)??8,background:l==null?void 0:l.definition.backgroundColor}}):null})}indicator(r){const n=this.getEmbedDefinition(r.props.url);return h.jsx("rect",{width:N(r.props.w),height:N(r.props.h),rx:(n==null?void 0:n.definition.overrideOutlineRadius)??8,ry:(n==null?void 0:n.definition.overrideOutlineRadius)??8})}getInterpolatedProps(r,n,o){return{...o>.5?n.props:r.props,w:He(r.props.w,n.props.w,o),h:He(r.props.h,n.props.h,o)}}}C(JS,"type","embed"),C(JS,"props",YG),C(JS,"migrations",XG);function XCt({id:t,file:e,isInteractive:r,width:n,height:o,style:i,pageRotation:s}){return h.jsx("iframe",{className:"tl-embed",draggable:!1,width:N(n),height:N(o),frameBorder:"0",scrolling:"no",seamless:!0,referrerPolicy:"no-referrer-when-downgrade",style:{...i,pointerEvents:r?"all":"none",zIndex:r?"":"-1",boxShadow:ax(s)},srcDoc:`
|
|
384
|
-
<html>
|
|
385
|
-
<head>
|
|
386
|
-
<base target="_blank">
|
|
387
|
-
</head>
|
|
388
|
-
<body>
|
|
389
|
-
<script src=${`https://gist.github.com/${t}.js${e?`?file=${e}`:""}`}><\/script>
|
|
390
|
-
<style type="text/css">
|
|
391
|
-
* { margin: 0px; }
|
|
392
|
-
table { height: 100%; background-color: red; }
|
|
393
|
-
.gist { background-color: none; height: 100%; }
|
|
394
|
-
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
395
|
-
</style>
|
|
396
|
-
</body>
|
|
397
|
-
</html>`})}const qCt=x.forwardRef(({id:t,name:e,isEditing:r},n)=>{const o=F(),i=x.useCallback(l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(mr(l),l.currentTarget.blur(),o.setEditingShape(null))},[o]),s=x.useCallback(l=>{const c=o.getShape(t);if(!c)return;const u=c.props.name,d=l.currentTarget.value.trim();u!==d&&o.updateShapes([{id:t,type:"frame",props:{name:d}}])},[t,o]),a=x.useCallback(l=>{const c=o.getShape(t);if(!c)return;const u=c.props.name,d=l.currentTarget.value;u!==d&&o.updateShapes([{id:t,type:"frame",props:{name:d}}])},[t,o]);return h.jsxs("div",{className:`tl-frame-label ${r?"tl-frame-label__editing":""}`,children:[h.jsx("input",{className:"tl-frame-name-input",ref:n,style:{display:r?void 0:"none"},value:e,autoFocus:!0,onKeyDown:i,onBlur:s,onChange:a}),Yle(e,"Frame")+""]})}),ZCt=function({id:e,name:r,width:n,height:o}){const i=F(),s=H("shape rotation",()=>dl(i.getShapePageTransform(e).rotation()),[i,e]),a=gb(e),l=x.useRef(null),c=x.useCallback(g=>{const m=Ln(g);g.preventDefault(),i.getEditingShapeId()!==e&&i.dispatch({type:"pointer",name:"pointer_down",target:"shape",shape:i.getShape(e),...m})},[i,e]);x.useEffect(()=>{const g=l.current;g&&a&&(g.focus(),g.select())},[l,a]);const d=((s+Math.PI/4)*(2/Math.PI)+4)%4,f=["top","left","bottom","right"][Math.floor(d)];let p;switch(f){case"top":p="";break;case"right":p=`translate(${N(n)}px, 0px) rotate(90deg)`;break;case"bottom":p=`translate(${N(n)}px, ${N(o)}px) rotate(180deg)`;break;case"left":p=`translate(0px, ${N(o)}px) rotate(270deg)`;break}return h.jsx("div",{className:"tl-frame-heading",style:{overflow:a?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(f==="top"||f==="bottom"?n:o)}px + var(--space-5))`,bottom:"100%",transform:`${p} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},onPointerDown:c,children:h.jsx("div",{className:"tl-frame-heading-hit-area",children:h.jsx(qCt,{ref:l,id:e,name:r,isEditing:a})})})};function Yle(t,e){return t.match(/^\s*$/)?e:t}class ew extends Vh{canEdit(){return!0}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(e){return new ia({width:e.props.w,height:e.props.h,isFilled:!1})}getText(e){return e.props.name}component(e){const r=this.editor.getShapeGeometry(e).bounds,n=ei(),o=H("is creating this shape",()=>{const i=this.editor.getStateDescendant("select.resizing");if(!i||!i.getIsActive())return!1;const s=i==null?void 0:i.info;return s?s.isCreating&&this.editor.getOnlySelectedShapeId()===e.id:!1},[e.id]);return h.jsxs(h.Fragment,{children:[h.jsx(xl,{children:h.jsx("rect",{className:pe("tl-frame__body",{"tl-frame__creating":o}),width:r.width,height:r.height,fill:n.solid,stroke:n.text})}),o?null:h.jsx(ZCt,{id:e.id,name:e.props.name,width:r.width,height:r.height})]})}toSvg(e,r){const n=ma({isDarkMode:r.isDarkMode}),s=((dl(this.editor.getShapePageTransform(e.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4,a=Math.floor(s);let l;switch(a){case 0:l="";break;case 3:l=`translate(${N(e.props.w)}, 0) rotate(90)`;break;case 2:l=`translate(${N(e.props.w)}, ${N(e.props.h)}) rotate(180)`;break;case 1:l=`translate(0, ${N(e.props.h)}) rotate(270)`;break;default:throw Error("labelSide out of bounds")}const c={fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:e.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle",fill:n.text},u=this.editor.textMeasure.measureTextSpans(Yle(e.props.name,"Frame")+"",c),d=u[0],f=Cr(u),p=f.box.w+f.box.x-d.box.x,g=aA(this.editor,u,{offsetY:-c.height-2,...c});return h.jsxs(h.Fragment,{children:[h.jsx("rect",{width:e.props.w,height:e.props.h,fill:n.solid,stroke:n.black.solid,strokeWidth:1,rx:1,ry:1}),h.jsxs("g",{transform:l,children:[h.jsx("rect",{x:-8,y:-c.height-4,width:p+16,height:c.height,fill:n.background,rx:4,ry:4}),g]})]})}indicator(e){const r=this.editor.getShapeGeometry(e).bounds;return h.jsx("rect",{width:N(r.width),height:N(r.height),className:"tl-frame-indicator"})}canReceiveNewChildrenOfType(e,r){return!e.isLocked}providesBackgroundForChildren(){return!0}canDropShapes(e,r){return!e.isLocked}onDragShapesOver(e,r){r.every(n=>n.parentId===e.id)||this.editor.reparentShapes(r,e.id)}onDragShapesOut(e,r){const n=this.editor.getShape(e.parentId);n&&this.editor.isShapeOfType(n,"group")?this.editor.reparentShapes(r,n.id):this.editor.reparentShapes(r,this.editor.getCurrentPageId())}onResize(e,r){return pb(e,r)}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,w:He(e.props.w,r.props.w,n),h:He(e.props.h,r.props.h,n)}}}C(ew,"type","frame"),C(ew,"props",qG),C(ew,"migrations",ZG);function I9(t,e){return t>e?(Ze*(e/2)+(t-e))*2:(Ze*(t/2)+(e-t))*2}function Xle(t,e){return qj(t,e).map((r,n)=>r.getSvgPathData(n===0)).join(" ")+" Z"}function QCt(t,e,r,n){const o=t/4,i=e/4,s=Ei(n),a=r*.75,l=v=>v.addXY(s()*a,s()*a),c=new w(t/2,e),u=new w(0,i*1.2),d=new w(t/2,i*.9),f=new w(t,i*1.2),p=l(new w(t/2,e)),g=l(new w(0,i*1.2)),m=l(new w(t/2,i*.9)),S=l(new w(t,i*1.2));return[new Yr({start:c,cp1:new w(o*1.5,i*3),cp2:new w(0,i*2.5),end:u}),new Yr({start:u,cp1:new w(0,-i*.32),cp2:new w(o*1.85,-i*.32),end:d}),new Yr({start:d,cp1:new w(o*2.15,-i*.32),cp2:new w(t,-i*.32),end:f}),new Yr({start:f,cp1:new w(t,i*2.5),cp2:new w(o*2.5,i*3),end:p}),new Yr({start:p,cp1:new w(o*1.5,i*3),cp2:new w(0,i*2.5),end:g}),new Yr({start:g,cp1:new w(0,-i*.32),cp2:new w(o*1.85,-i*.32),end:m}),new Yr({start:m,cp1:new w(o*2.15,-i*.32),cp2:new w(t,-i*.32),end:S}),new Yr({start:S,cp1:new w(t,i*2.5),cp2:new w(o*2.5,i*3),end:c})].map((v,b)=>v.getSvgPathData(b===0)).join(" ")+" Z"}function qj(t,e){const r=t/4,n=e/4;return[new Yr({start:new w(t/2,e),cp1:new w(r*1.5,n*3),cp2:new w(0,n*2.5),end:new w(0,n*1.2)}),new Yr({start:new w(0,n*1.2),cp1:new w(0,-n*.32),cp2:new w(r*1.85,-n*.32),end:new w(t/2,n*.9)}),new Yr({start:new w(t/2,n*.9),cp1:new w(r*2.15,-n*.32),cp2:new w(t,-n*.32),end:new w(t,n*1.2)}),new Yr({start:new w(t,n*1.2),cp1:new w(t,n*2.5),cp2:new w(r*2.5,n*3),end:new w(t/2,e)})]}function JCt(t){return{size:1+t,thinning:.25,end:{taper:t},start:{taper:t},streamline:0,smoothing:1,simulatePressure:!1}}function e_t(t,e,r,n){const o=Ei(t),i=e/2,s=r/2,a=mV(i,s),l=[],c=rt*o(),u=rt+vt/2+Math.abs(o())*vt,d=Math.max(16,a/10);for(let f=0;f<d;f++){const p=f/(d-1),g=c+p*u,m=Math.cos(g),S=Math.sin(g);l.push(new w(i*m+e*.5+.05*o(),s*S+r/2+.05*o(),Math.min(1,.5+Math.abs(.5-(o()>0?pr.easeInOutSine(p):pr.easeInExpo(p)))/2)))}return fs(l,JCt(n))}function t_t(t,e,r,n){return Zc(e_t(t,e,r,n))}function uA(t){let e="M";const r=t.length;let n,o,i;for(let s=0,a=r;s<a;s+=3)n=t[s],o=t[s+1],i=t[s+2],e+=`${Xe(n)}L${Xe(o)}Q${Xe(i)}`;return e+=`${Xe(t[0])}`,e}function dA(t,e,r,n,o){const i=[],s=Ei(t);let a=e[0],l;const c=e.length;for(let u=0,d=c*o;u<d;u++){l=w.AddXY(e[(u+1)%c],s()*r,s()*r);const f=w.Sub(l,a),p=w.Len(f),g=w.Div(f,p).mul(Math.min(p/4,n));i.push(w.Add(a,g),w.Add(l,g.neg()),l),a=l}return i}function r_t(t,e,r){const n=Math.min(t,e)/2,o=Math.max(t,e)-n*2,s=(Math.PI*(n*2)+2*o)/r,a=t>e?[{type:"straight",start:new w(n,0),delta:new w(1,0)},{type:"arc",center:new w(t-n,n),startAngle:-Ze/2},{type:"straight",start:new w(t-n,e),delta:new w(-1,0)},{type:"arc",center:new w(n,n),startAngle:Ze/2}]:[{type:"straight",start:new w(t,n),delta:new w(0,1)},{type:"arc",center:new w(n,e-n),startAngle:0},{type:"straight",start:new w(0,e-n),delta:new w(0,-1)},{type:"arc",center:new w(n,n),startAngle:Ze}];let l=0;const c=[];for(let u=0;u<r;u++){const d=a[0];d.type==="straight"?c.push(w.Add(d.start,w.Mul(d.delta,l))):c.push(Bc(d.center,n,d.startAngle+l/n)),l+=s;let f=d.type==="straight"?o:Ze*n;for(;l>f;)l-=f,a.push(a.shift()),f=a[0].type==="straight"?o:Ze*n}return c}const n_t={s:50,m:70,l:100,xl:130},o_t=.2;function zb(t,e,r,n,o){const i=Ei(r),s=I9(t,e),a=Math.max(Math.ceil(s/n_t[n]),6,Math.ceil(s/Math.min(t,e))),l=s/a*o_t,c=Math.max(t-l*2,1),u=Math.max(e-l*2,1),f=I9(c,u)/a,p=(t-c)/2,g=(e-u)/2,m=r_t(c,u,a).map($=>$.addXY(p,g)),S=t<20?0:l*.3,y=e<20?0:l*.3,v=m.slice(0);for(let $=0;$<Math.floor(a/2);$++)v[$]=w.AddXY(v[$],i()*S*o,i()*y*o),v[a-$-1]=w.AddXY(v[a-$-1],i()*S*o,i()*y*o);const b=[];for(let $=0;$<v.length;$++){const P=$===v.length-1?0:$+1,E=v[$],T=v[P],I=m[$],_=m[P],k=w.Dist(I,_),D=f-k,j=w.Dist(E,T)/k,M=(Math.max(p,g)+D)*j,U=w.Lrp(I,_,.5).add(w.Sub(_,I).uni().per().mul(M));U.x<0?U.x=0:U.x>t&&(U.x=t),U.y<0?U.y=0:U.y>e&&(U.y=e);const B=lO(E,T,U),K=w.Dist(B||w.Average([E,T]),E);b.push({leftPoint:E,rightPoint:T,arcPoint:U,center:B,radius:K})}return b}function i_t(t,e,r,n,o){const i=[],s=zb(t,e,r,n,o);for(const{center:a,radius:l,leftPoint:c,rightPoint:u}of s)i.push(...c$e(c,u,a,l,10));return i}function hA(t,e,r,n,o){const i=zb(t,e,r,n,o);let s=`M${i[0].leftPoint.toFixed()}`;for(const{leftPoint:a,rightPoint:l,radius:c,center:u}of i){if(u===null){s+=` L${l.toFixed()}`;continue}const d=w.Clockwise(a,l,u)?"0":"1";s+=` A${N(c)},${N(c)} 0 ${d},1 ${l.toFixed()}`}return s+=" Z",s}const s_t={s:.5,m:.7,l:.9,xl:1.6};function a_t(t,e,r,n,o){const i=Ei(r),s=s_t[n]*o,a=zb(t,e,r,n,o),u=a.reduce((g,m)=>g+w.Dist2(m.leftPoint,m.rightPoint),0)/a.length>(s*15)**2?g=>w.AddXY(g,i()*s*2,i()*s*2):g=>g;let d=`M${a[0].leftPoint.toFixed()}`,f=u(a[0].leftPoint),p=`M${f.toFixed()}`;for(const{leftPoint:g,center:m,rightPoint:S,radius:y,arcPoint:v}of a){if(m===null){d+=` L${S.toFixed()}`;const I=u(S);p+=` L${I.toFixed()}`,f=I;continue}const b=w.Clockwise(g,S,m)?"0":"1";d+=` A${N(y)},${N(y)} 0 ${b},1 ${S.toFixed()}`;const $=u(S),P=u(v),E=lO(f,$,P);if(!E){p+=` L${$.toFixed()}`,f=$;continue}const T=Math.abs(w.Dist(E,f));p+=` A${N(T)},${N(T)} 0 ${b},1 ${$.toFixed()}`,f=$}return d+p+" Z"}function fA(t,e){switch(t.geo){case"x-box":return l_t(t.w,t.h,e,t.dash);case"check-box":return c_t(t.w,t.h);default:return}}function l_t(t,e,r,n){const o=n==="draw"?.62:0;if(n==="dashed")return[[new w(0,0),new w(t/2,e/2)],[new w(t,e),new w(t/2,e/2)],[new w(0,e),new w(t/2,e/2)],[new w(t,0),new w(t/2,e/2)]];const i=a=>Math.max(0,Math.min(t,a)),s=a=>Math.max(0,Math.min(e,a));return[[new w(i(r*o),s(r*o)),new w(i(t-r*o),s(e-r*o))],[new w(i(r*o),s(e-r*o)),new w(i(t-r*o),s(r*o))]]}function c_t(t,e){const r=Math.min(t,e)*.82,n=(t-r)/2,o=(e-r)/2,i=a=>Math.max(0,Math.min(t,a)),s=a=>Math.max(0,Math.min(e,a));return[[new w(i(n+r*.25),s(o+r*.52)),new w(i(n+r*.45),s(o+r*.82))],[new w(i(n+r*.45),s(o+r*.82)),new w(i(n+r*.82),s(o+r*.22))]]}function P9({shape:t,shouldScale:e,forceSolid:r}){const n=e?t.props.scale:1,o=F(),i=ei(),{id:s,props:a}=t,{w:l,color:c,fill:u,dash:d,growY:f,size:p,scale:g}=a,m=Qr[p]*n,S=a.h+f;switch(a.geo){case"cloud":if(d==="solid"){const y=hA(l,S,s,p,g);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:y,color:c,fill:u,scale:n}),h.jsx("path",{d:y,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}else if(d==="draw"){const y=a_t(l,S,s,p,g);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:y,color:c,fill:u,scale:n}),h.jsx("path",{d:y,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}else{const y=hA(l,S,s,p,g),v=zb(l,S,s,p,g);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:y,color:c,fill:u,scale:n}),h.jsx("g",{strokeWidth:m,stroke:i[c].solid,fill:"none",pointerEvents:"all",children:v.map(({leftPoint:b,rightPoint:$,center:P,radius:E},T)=>{const I=P?E*dl(dl(w.Angle(P,$))-dl(w.Angle(P,b))):w.Dist(b,$),{strokeDasharray:_,strokeDashoffset:k}=di(I,m,{style:d,start:"outset",end:"outset",forceSolid:r});return h.jsx("path",{d:P?`M${b.x},${b.y}A${E},${E},0,0,1,${$.x},${$.y}`:`M${b.x},${b.y}L${$.x},${$.y}`,strokeDasharray:_,strokeDashoffset:k},T)})})]})}case"ellipse":{const y=e?o.getShapeGeometry(t):o.getShapeUtil(t).getGeometry(t),v=y.getSvgPathData(!0);if(d==="dashed"||d==="dotted"){const b=y.length,{strokeDasharray:$,strokeDashoffset:P}=di(b<64?b*2:b,m,{style:d,snap:4,closed:!0,forceSolid:r});return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:v,color:c,fill:u,scale:n}),h.jsx("path",{d:v,strokeWidth:m,fill:"none",stroke:i[c].solid,strokeDasharray:$,strokeDashoffset:P})]})}else{const $=(e?o.getShapeGeometry(t):o.getShapeUtil(t).getGeometry(t)).getSvgPathData(!0);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:$,color:c,fill:u,scale:n}),h.jsx("path",{d:$,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}}case"oval":{const y=e?o.getShapeGeometry(t):o.getShapeUtil(t).getGeometry(t),v=y.getSvgPathData(!0);if(d==="dashed"||d==="dotted"){const b=y.getLength(),{strokeDasharray:$,strokeDashoffset:P}=di(b<64?b*2:b,m,{style:d,snap:4,start:"outset",end:"outset",closed:!0,forceSolid:r});return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:v,color:c,fill:u,scale:n}),h.jsx("path",{d:v,strokeWidth:m,fill:"none",stroke:i[c].solid,strokeDasharray:$,strokeDashoffset:P})]})}else return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:v,color:c,fill:u,scale:n}),h.jsx("path",{d:v,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}case"heart":if(d==="dashed"||d==="dotted"||d==="solid"){const y=Xle(l,S),v=qj(l,S);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:y,color:c,fill:u,scale:n}),v.map((b,$)=>{const{strokeDasharray:P,strokeDashoffset:E}=di(b.length,m,{style:d,snap:1,start:"outset",end:"outset",closed:!0,forceSolid:r});return h.jsx("path",{d:b.getSvgPathData(),strokeWidth:m,fill:"none",stroke:i[c].solid,strokeDasharray:P,strokeDashoffset:E,pointerEvents:"all"},`curve_${$}`)})]})}else{const y=QCt(l,S,m,t.id);return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:y,color:c,fill:u,scale:n}),h.jsx("path",{d:y,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}default:{const y=e?o.getShapeGeometry(t):o.getShapeUtil(t).getGeometry(t),v=y instanceof bi?y.children[0].vertices:y.vertices,b=fA(t.props,m);if(d==="solid"){let $="M"+v[0]+"L"+v.slice(1)+"Z";if(b)for(const[P,E]of b)$+=`M${P.x},${P.y}L${E.x},${E.y}`;return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:$,color:c,fill:u,scale:n}),h.jsx("path",{d:$,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}else if(d==="dashed"||d==="dotted"){const $="M"+v[0]+"L"+v.slice(1)+"Z";return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:$,color:c,fill:u,scale:n}),h.jsxs("g",{strokeWidth:m,stroke:i[c].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(v.length)).map((P,E)=>{const T=w.ToFixed(v[E]),I=w.ToFixed(v[(E+1)%v.length]),_=w.Dist(T,I),{strokeDasharray:k,strokeDashoffset:D}=di(_,m,{style:d,start:"outset",end:"outset",forceSolid:r});return h.jsx("line",{x1:T.x,y1:T.y,x2:I.x,y2:I.y,strokeDasharray:k,strokeDashoffset:D},E)}),b&&b.map(([P,E],T)=>{const I=w.Dist(P,E),{strokeDasharray:_,strokeDashoffset:k}=di(I,m,{style:d,start:"skip",end:"skip",snap:d==="dotted"?4:void 0,forceSolid:r});return h.jsx("path",{d:`M${P.x},${P.y}L${E.x},${E.y}`,stroke:i[c].solid,strokeWidth:m,fill:"none",strokeDasharray:_,strokeDashoffset:k},`line_fg_${T}`)})]})]})}else if(d==="draw"){let $=uA(dA(s,v,m/3,m*2,2));if(b)for(const[E,T]of b)$+=`M${E.toFixed()}L${T.toFixed()}`;const P=uA(dA(s,v,0,m*2,1));return h.jsxs(h.Fragment,{children:[h.jsx(Gr,{theme:i,d:P,color:c,fill:u,scale:n}),h.jsx("path",{d:$,stroke:i[c].solid,strokeWidth:m,fill:"none"})]})}}}}const E9=17*3;class tw extends Vh{canEdit(){return!0}getDefaultProps(){return{w:100,h:100,geo:"rectangle",color:"black",labelColor:"black",fill:"none",dash:"draw",size:"m",font:"draw",text:"",align:"middle",verticalAlign:"middle",growY:0,url:"",scale:1}}getGeometry(e){const r=Math.max(1,e.props.w),n=Math.max(1,e.props.h+e.props.growY),o=r/2,i=n/2,s=e.props.fill!=="none";let a;switch(e.props.geo){case"cloud":{a=new Vt({points:i_t(r,n,e.id,e.props.size,e.props.scale),isFilled:s});break}case"triangle":{a=new Vt({points:[new w(o,0),new w(r,n),new w(0,n)],isFilled:s});break}case"diamond":{a=new Vt({points:[new w(o,0),new w(r,i),new w(o,n),new w(0,i)],isFilled:s});break}case"pentagon":{a=new Vt({points:rI(r,n,5),isFilled:s});break}case"hexagon":{a=new Vt({points:rI(r,n,6),isFilled:s});break}case"octagon":{a=new Vt({points:rI(r,n,8),isFilled:s});break}case"ellipse":{a=new z0t({width:r,height:n,isFilled:s});break}case"oval":{a=new H0t({width:r,height:n,isFilled:s});break}case"star":{const v=rt/5/2,b=Math.floor(5/4)*2,$=5*2-b,P=0,E=Math.floor(5/2)*2,T=Math.cos(-vt+b*v)*r/2,I=Math.cos(-vt+$*v)*r/2,_=Math.sin(-vt+P*v)*n/2,k=Math.sin(-vt+E*v)*n/2,D=r-Math.abs(T-I),R=n-Math.abs(k-_),j=r/2+I-(r/2-T),M=n/2+_-(n/2-k),U=1,B=(r-j)/2,K=(n-M)/2,z=(r+D)/2,W=(n+R)/2,J=z*U/2,oe=W*U/2;a=new Vt({points:Array.from(Array(5*2)).map((we,_e)=>{const Ge=-vt+_e*v;return new w(B+(_e%2?J:z)*Math.cos(Ge),K+(_e%2?oe:W)*Math.sin(Ge))}),isFilled:s});break}case"rhombus":{const y=Math.min(r*.38,n*.38);a=new Vt({points:[new w(y,0),new w(r,0),new w(r-y,n),new w(0,n)],isFilled:s});break}case"rhombus-2":{const y=Math.min(r*.38,n*.38);a=new Vt({points:[new w(0,0),new w(r-y,0),new w(r,n),new w(y,n)],isFilled:s});break}case"trapezoid":{const y=Math.min(r*.38,n*.38);a=new Vt({points:[new w(y,0),new w(r-y,0),new w(r,n),new w(0,n)],isFilled:s});break}case"arrow-right":{const y=Math.min(r,n)*.38,v=n*.16;a=new Vt({points:[new w(0,v),new w(r-y,v),new w(r-y,0),new w(r,n/2),new w(r-y,n),new w(r-y,n-v),new w(0,n-v)],isFilled:s});break}case"arrow-left":{const y=Math.min(r,n)*.38,v=n*.16;a=new Vt({points:[new w(y,0),new w(y,v),new w(r,v),new w(r,n-v),new w(y,n-v),new w(y,n),new w(0,n/2)],isFilled:s});break}case"arrow-up":{const y=r*.16,v=Math.min(r,n)*.38;a=new Vt({points:[new w(r/2,0),new w(r,v),new w(r-y,v),new w(r-y,n),new w(y,n),new w(y,v),new w(0,v)],isFilled:s});break}case"arrow-down":{const y=r*.16,v=Math.min(r,n)*.38;a=new Vt({points:[new w(y,0),new w(r-y,0),new w(r-y,n-v),new w(r,n-v),new w(r/2,n),new w(0,n-v),new w(y,n-v)],isFilled:s});break}case"check-box":case"x-box":case"rectangle":{a=new ia({width:r,height:n,isFilled:s});break}case"heart":{const v=qj(r,n).reduce((b,$)=>(b.push(...$.vertices),b),[]);a=new Vt({points:v,isFilled:s});break}default:dr(e.props.geo)}const l=qy(this.editor,e),c=r/e.props.scale,u=n/e.props.scale,d=Math.min(100,c/2),f=Math.min(Js[e.props.size]*Rr.lineHeight+No*2,u/2),p=Math.min(c,Math.max(l.w,Math.min(d,Math.max(1,c-8)))),g=Math.min(u,Math.max(l.h,Math.min(f,Math.max(1,u-8)))),m=fA(e.props,Qr[e.props.size]*e.props.scale),S=m?m.map(y=>new Ah({points:y})):[];return new bi({children:[a,new ia({x:e.props.align==="start"?0:e.props.align==="end"?(c-p)*e.props.scale:(c-p)/2*e.props.scale,y:e.props.verticalAlign==="start"?0:e.props.verticalAlign==="end"?(u-g)*e.props.scale:(u-g)/2*e.props.scale,width:p*e.props.scale,height:g*e.props.scale,isFilled:!0,isLabel:!0}),...S]})}getHandleSnapGeometry(e){const r=this.getGeometry(e),n=r.children[0];switch(e.props.geo){case"arrow-down":case"arrow-left":case"arrow-right":case"arrow-up":case"check-box":case"diamond":case"hexagon":case"octagon":case"pentagon":case"rectangle":case"rhombus":case"rhombus-2":case"star":case"trapezoid":case"triangle":case"x-box":return{outline:n,points:[...n.getVertices(),r.bounds.center]};case"cloud":case"ellipse":case"heart":case"oval":return{outline:n,points:[r.bounds.center]};default:dr(e.props.geo)}}getText(e){return e.props.text}onEditEnd(e){const{id:r,type:n,props:{text:o}}=e;o.trimEnd()!==e.props.text&&this.editor.updateShapes([{id:r,type:n,props:{text:o.trimEnd()}}])}component(e){const{id:r,type:n,props:o}=e,{fill:i,font:s,align:a,verticalAlign:l,size:c,text:u}=o,d=ei(),{editor:f}=this,p=H("isGeoOnlySelected",()=>e.id===f.getOnlySelectedShapeId(),[]),m=f.getEditingShapeId()!==null||e.props.text,S=H("force solid",()=>f.getZoomLevel()<.2,[f]);return h.jsxs(h.Fragment,{children:[h.jsx(xl,{id:r,children:h.jsx(P9,{shape:e,shouldScale:!0,forceSolid:S})}),m&&h.jsx(ml,{style:{overflow:"hidden",width:e.props.w,height:e.props.h+o.growY},children:h.jsx(Ub,{id:r,type:n,font:s,fontSize:Js[c]*e.props.scale,lineHeight:Rr.lineHeight,padding:No*e.props.scale,fill:i,align:a,verticalAlign:l,text:u,isSelected:p,labelColor:d[o.labelColor].solid,wrap:!0})}),e.props.url&&h.jsx(ph,{url:e.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(e){const{id:r,props:n}=e,{w:o,size:i}=n,s=n.h+n.growY,a=Qr[i],l=this.editor.getShapeGeometry(e);switch(n.geo){case"ellipse":return n.dash==="draw"?h.jsx("path",{d:t_t(r,o,s,a)}):h.jsx("path",{d:l.getSvgPathData(!0)});case"heart":return h.jsx("path",{d:Xle(o,s)});case"oval":return h.jsx("path",{d:l.getSvgPathData(!0)});case"cloud":return h.jsx("path",{d:hA(o,s,r,i,e.props.scale)});default:{const c=this.editor.getShapeGeometry(e),u=c instanceof bi?c.children[0].vertices:c.vertices;let d;if(n.dash==="draw"){const p=dA(r,u,0,a*2*e.props.scale,1);d=uA(p)}else d="M"+u[0]+"L"+u.slice(1)+"Z";const f=fA(e.props,a);if(f)for(const[p,g]of f)d+=`M${p.x},${p.y}L${g.x},${g.y}`;return h.jsx("path",{d})}}}toSvg(e,r){const n={...e,props:{...e.props,w:e.props.w/e.props.scale,h:e.props.h/e.props.scale}},o=n.props;r.addExportDef(Gj(o.fill));let i;if(o.text){r.addExportDef(Fb(o.font));const s=ma(r),a=new ee(0,0,o.w,o.h+o.growY);i=h.jsx(Bb,{fontSize:Js[o.size],font:o.font,align:o.align,verticalAlign:o.verticalAlign,text:o.text,labelColor:s[o.labelColor].solid,bounds:a,padding:16})}return h.jsxs(h.Fragment,{children:[h.jsx(P9,{shouldScale:!1,shape:n,forceSolid:!1}),i]})}getCanvasSvgDefs(){return[Vj()]}onResize(e,{handle:r,newPoint:n,scaleX:o,scaleY:i,initialShape:s}){const a=s.props.w/s.props.scale,l=s.props.h/s.props.scale,c=s.props.growY/s.props.scale;let u=a*o,d=(l+c)*i,f=0,p=0;const g=E9;if(e.props.text.trim()){let $=Math.max(Math.abs(u),g),P=Math.max(Math.abs(d),g);$<g&&P===g&&($=g),$===g&&P<g&&(P=g);const E=qy(this.editor,{...e,props:{...e.props,w:$*e.props.scale,h:P*e.props.scale}}),T=Math.max(Math.abs(u),E.w)*Math.sign(u),I=Math.max(Math.abs(d),E.h)*Math.sign(d);f=Math.abs(T)-Math.abs(u),p=Math.abs(I)-Math.abs(d),u=T,d=I}const m=u*e.props.scale,S=d*e.props.scale,y=new w(0,0);o<0&&(y.x+=m),(r==="left"||r==="top_left"||r==="bottom_left")&&(y.x+=o<0?f:-f),i<0&&(y.y+=S),(r==="top"||r==="top_left"||r==="top_right")&&(y.y+=i<0?p:-p);const{x:v,y:b}=y.rot(e.rotation).add(n);return{x:v,y:b,props:{w:Math.max(Math.abs(m),1),h:Math.max(Math.abs(S),1),growY:0}}}onBeforeCreate(e){if(!e.props.text)return e.props.growY?{...e,props:{...e.props,growY:0}}:void 0;const r=e.props.h/e.props.scale,n=qy(this.editor,e).h;let o=null;if(n>r?o=n-r:e.props.growY&&(o=0),o!==null)return{...e,props:{...e.props,growY:o*e.props.scale}}}onBeforeUpdate(e,r){const n=e.props.text,o=r.props.text;if(n===o&&e.props.font===r.props.font&&e.props.size===r.props.size)return;if(n&&!o)return{...r,props:{...r.props,growY:0}};const i=e.props.w/e.props.scale,s=e.props.h/e.props.scale,a=e.props.growY/e.props.scale,l=qy(this.editor,r);if(!n&&o&&o.length===1){let u=Math.max(i,l.w),d=Math.max(s,l.h);const f=E9;return i<f&&s<f&&(u=Math.max(u,f),d=Math.max(d,f),u=Math.max(u,d),d=Math.max(u,d)),{...r,props:{...r.props,w:u*r.props.scale,h:d*r.props.scale,growY:0}}}let c=null;if(l.h>s?c=l.h-s:a&&(c=0),c!==null){const u=r.props.w/r.props.scale;return{...r,props:{...r.props,growY:c*r.props.scale,w:Math.max(u,l.w)*r.props.scale}}}if(l.w>i)return{...r,props:{...r.props,w:l.w*r.props.scale}}}onDoubleClick(e){if(this.editor.inputs.altKey)switch(e.props.geo){case"rectangle":return{...e,props:{geo:"check-box"}};case"check-box":return{...e,props:{geo:"rectangle"}}}}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,w:He(e.props.w,r.props.w,n),h:He(e.props.h,r.props.h,n),scale:He(e.props.scale,r.props.scale,n)}}}C(tw,"type","geo"),C(tw,"props",QG),C(tw,"migrations",JG);function qy(t,e){const{text:r,font:n,size:o,w:i}=e.props;if(!r)return{w:0,h:0};const s=t.textMeasure.measureText("w",{...Rr,fontFamily:as[n],fontSize:Js[o],maxWidth:100}),a={s:2,m:3.5,l:5,xl:10},l=t.textMeasure.measureText(r,{...Rr,fontFamily:as[n],fontSize:Js[o],minWidth:s.w,maxWidth:Math.max(0,Math.ceil(s.w+a[o]),Math.ceil(i/e.props.scale-No*2))});return{w:l.w+No*2,h:l.h+No*2}}function u_t(){const[t,e]=x.useState(!1);return x.useEffect(()=>{const n=CSS.supports("color","color(display-p3 1 1 1)"),o=matchMedia("(color-gamut: p3)");e(n&&o.matches);const i=()=>e(n&&o.matches);return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[]),H(Xt.forceSrgb)||!t?"srgb":"p3"}const C9=.35,_9=.82;class rw extends Si{hideResizeHandles(e){return Zy(e)}hideRotateHandle(e){return Zy(e)}hideSelectionBoundsFg(e){return Zy(e)}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1}}getGeometry(e){const r=gc(e);if(Zy(e))return new ej({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:n,sw:o}=T9(e,r,!0),i=Xj({strokeWidth:o,showAsComplete:!0});return Lb(n,i),new Vt({points:Hj(n,i),isFilled:!0})}component(e){const r=dC(this.editor,e),n=gc(e);return h.jsx(xl,{id:e.id,children:h.jsx(Qy,{shape:e,forceSolid:r,strokeWidth:n,opacity:C9})})}backgroundComponent(e){const r=dC(this.editor,e),n=gc(e);return h.jsx(xl,{id:e.id,children:h.jsx(Qy,{shape:e,forceSolid:r,strokeWidth:n,opacity:_9})})}indicator(e){const r=dC(this.editor,e),n=gc(e),{strokePoints:o,sw:i}=T9(e,n,r),s=gh(e.props.segments);let a;return o.length<2?a=h_t(s[0],i):a=Zc(o,!1),h.jsx("path",{d:a})}toSvg(e){const r=gc(e),n=r<1.5,o=1/e.props.scale;return h.jsx("g",{transform:`scale(${o})`,children:h.jsx(Qy,{forceSolid:n,strokeWidth:r,shape:e,opacity:C9})})}toBackgroundSvg(e){const r=gc(e),n=r<1.5,o=1/e.props.scale;return h.jsx("g",{transform:`scale(${o})`,children:h.jsx(Qy,{forceSolid:n,strokeWidth:r,shape:e,opacity:_9})})}onResize(e,r){const{scaleX:n,scaleY:o}=r,i=[];for(const s of e.props.segments)i.push({...s,points:s.points.map(({x:a,y:l,z:c})=>({x:n*a,y:o*l,z:c}))});return{props:{segments:i}}}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,...r.props,segments:Kle(e.props.segments,r.props.segments,n),scale:He(e.props.scale,r.props.scale,n)}}}C(rw,"type","highlight"),C(rw,"props",rV),C(rw,"migrations",nV);function d_t(t){return`M ${t.x} ${t.y} m -${.1}, 0 a ${.1},${.1} 0 1,0 ${.1*2},0 a ${.1},${.1} 0 1,0 -${.1*2},0`}function h_t(t,e){const r=e/2;return`M ${t.x} ${t.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r*2},0 a ${r},${r} 0 1,0 -${r*2},0`}function T9(t,e,r){var l;const n=gh(t.props.segments),o=t.props.isComplete||((l=Cr(t.props.segments))==null?void 0:l.type)==="straight";let i=e;!r&&!t.props.isPen&&n.length===1&&(i+=Ei(t.id)()*(e/6));const s=Xj({strokeWidth:i,showAsComplete:o});return{strokePoints:fs(n,s),sw:i}}function gc(t){return hh[t.props.size]*1.12*t.props.scale}function Zy(t){return t.props.segments.length===1&&t.props.segments[0].points.length<2}function Qy({strokeWidth:t,forceSolid:e,shape:r,opacity:n}){var f;const o=ei(),i=gh(r.props.segments);let s=t;!e&&!r.props.isPen&&i.length===1&&(s+=Ei(r.id)()*(s/6));const a=Xj({strokeWidth:s,showAsComplete:r.props.isComplete||((f=Cr(r.props.segments))==null?void 0:f.type)==="straight"}),l=fs(i,a),c=l.length>1?Zc(l,!1):d_t(r.props.segments[0].points[0]),u=u_t(),d=o[r.props.color].highlight[u];return h.jsx("path",{d:c,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:d,strokeWidth:s,opacity:n})}function dC(t,e){return H("forceSolid",()=>{const r=gc(e),n=t.getZoomLevel();return r/n<1.5},[t])}function qle(){return h.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),h.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),h.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function Zle(t,e,r){const n=F(),[o,i]=x.useState(null),[s,a]=x.useState(!1),l=!!km(),c=e?n.getAsset(e):null,d=n.getCulledShapes().has(t),f=x.useRef(!1),p=Hyt();x.useEffect(()=>{o&&(f.current=!0)},[o]);const g=c&&"w"in c.props?r/c.props.w:1,m=H("zoom level",()=>n.getZoomLevel()*g,[n,g]);return x.useEffect(()=>{o&&(f.current=!0)},[o]),x.useEffect(()=>{if(!l&&d)return;if(e&&!(c!=null&&c.props.src)){const v=n.getTemporaryAssetPreview(e);if(v){i(v),a(!0),p();return}}let S=!1;async function y(){const v=await n.resolveAssetUrl(e,{screenScale:m,shouldResolveToOriginal:l});S||(i(v),a(!1),p())}if(f.current){const v=n.timers.setTimeout(y,500);return()=>{clearTimeout(v),S=!0}}else return y(),()=>{S=!0}},[e,c==null?void 0:c.props.src,d,m,n,l,p]),{asset:c,url:o,isPlaceholder:s}}function Qle(){const[t,e]=x.useState(!1);return x.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const r=window.matchMedia("(prefers-reduced-motion: reduce)"),n=()=>{e(r.matches)};return n(),r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[]),t}async function f_t(t){const r=await(await xi(t)).blob();return Ys.blobToDataUrl(r)}class nw extends Vh{isAspectRatioLocked(){return!0}canCrop(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null,flipX:!1,flipY:!1}}onResize(e,r){let n=pb(e,r);const{flipX:o,flipY:i}=r.initialShape.props,{scaleX:s,scaleY:a,mode:l}=r;if(n={...n,props:{...n.props,flipX:s<0!==o,flipY:a<0!==i}},!e.props.crop)return n;const c=l==="scale_shape"&&s===-1||l==="resize_bounds"&&o!==n.props.flipX,u=l==="scale_shape"&&a===-1||l==="resize_bounds"&&i!==n.props.flipY,{topLeft:d,bottomRight:f}=e.props.crop;return n.props.crop={topLeft:{x:c?1-f.x:d.x,y:u?1-f.y:d.y},bottomRight:{x:c?1-d.x:f.x,y:u?1-d.y:f.y}},n}isAnimated(e){const r=e.props.assetId?this.editor.getAsset(e.props.assetId):void 0;return r?"mimeType"in r.props&&io.isAnimatedImageType(r==null?void 0:r.props.mimeType)||"isAnimated"in r.props&&r.props.isAnimated:!1}component(e){var y;const r=this.editor.getCroppingShapeId()===e.id,n=Qle(),[o,i]=x.useState(""),[s,a]=x.useState(null),l=e.id===this.editor.getOnlySelectedShapeId(),{asset:c,url:u}=Zle(e.id,e.props.assetId,e.props.w);if(x.useEffect(()=>{if(u&&this.isAnimated(e)){let v=!1;const b=hg();return b.onload=()=>{if(v)return;const $=document.createElement("canvas");$.width=b.width,$.height=b.height;const P=$.getContext("2d");P&&(P.drawImage(b,0,0),i($.toDataURL()),a(u))},b.crossOrigin="anonymous",b.src=u,()=>{v=!0}}},[n,u,e]),(c==null?void 0:c.type)==="bookmark")throw Error("Bookmark assets can't be rendered as images");const d=l&&r&&this.editor.isIn("select.crop"),f=n&&(((y=c==null?void 0:c.props.mimeType)==null?void 0:y.includes("video"))||this.isAnimated(e)),p=A9(e),g=u===s?null:u,m=f?o:s;if(!u&&!(c!=null&&c.props.src))return h.jsxs(ml,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h,color:"var(--color-text-3)",backgroundColor:"var(--color-low)",border:"1px solid var(--color-low-border)"},children:[h.jsx("div",{className:pe("tl-image-container",c&&"tl-image-container-loading"),style:p,children:c?null:h.jsx(qle,{})}),"url"in e.props&&e.props.url&&h.jsx(ph,{url:e.props.url,zoomLevel:this.editor.getZoomLevel()})]});const S=this.isAnimated(e)?"anonymous":void 0;return h.jsxs(h.Fragment,{children:[d&&m&&h.jsx("div",{style:p,children:h.jsx("img",{className:"tl-image",style:{...Hf(e),opacity:.1},crossOrigin:S,src:m,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1})}),h.jsxs(ml,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h},children:[h.jsxs("div",{className:pe("tl-image-container"),style:p,children:[m&&h.jsx("img",{className:"tl-image",style:Hf(e),crossOrigin:S,src:m,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1},m),g&&h.jsx("img",{className:"tl-image",style:Hf(e),crossOrigin:S,src:g,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,onLoad:()=>a(g)},g)]}),e.props.url&&h.jsx(ph,{url:e.props.url,zoomLevel:this.editor.getZoomLevel()})]})]})}indicator(e){return this.editor.getCroppingShapeId()===e.id?null:h.jsx("rect",{width:N(e.props.w),height:N(e.props.h)})}async toSvg(e){if(!e.props.assetId||!this.editor.getAsset(e.props.assetId))return null;let n=await this.editor.resolveAssetUrl(e.props.assetId,{shouldResolveToOriginal:!0});if(!n)return null;(n.startsWith("blob:")||n.startsWith("http")||n.startsWith("/")||n.startsWith("./"))&&(n=await f_t(n)||"");const o=A9(e),i=e.props.crop;if(o.transform&&i){const{transform:s,width:a,height:l}=o,c=(i.bottomRight.x-i.topLeft.x)*a,u=(i.bottomRight.y-i.topLeft.y)*l,d=[new w(0,0),new w(c,0),new w(c,u),new w(0,u)],f=`cropClipPath_${e.id.replace(":","_")}`,p=Hf(e,{width:a,height:l});return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("clipPath",{id:f,children:h.jsx("polygon",{points:d.map(g=>`${g.x},${g.y}`).join(" ")})})}),h.jsx("g",{clipPath:`url(#${f})`,children:h.jsx("image",{href:n,width:a,height:l,style:p?{...p,transform:`${s} ${p.transform}`}:{transform:s}})})]})}else return h.jsx("image",{href:n,width:e.props.w,height:e.props.h,style:Hf(e,{width:e.props.w,height:e.props.h})})}onDoubleClickEdge(e){const r=e.props;if(!r||this.editor.getCroppingShapeId()!==e.id)return;const n=$t(r.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},o=1/(n.bottomRight.x-n.topLeft.x)*e.props.w,i=1/(n.bottomRight.y-n.topLeft.y)*e.props.h,s=new w(n.topLeft.x*o,n.topLeft.y*i).rot(e.rotation),a={id:e.id,type:e.type,x:e.x-s.x,y:e.y-s.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:o,h:i}};this.editor.updateShapes([a])}getInterpolatedProps(e,r,n){function o(i,s){var d,f,p,g;if(i.props.crop===null&&s.props.crop===null)return null;const a=((d=i.props.crop)==null?void 0:d.topLeft)||{x:0,y:0},l=((f=i.props.crop)==null?void 0:f.bottomRight)||{x:1,y:1},c=((p=s.props.crop)==null?void 0:p.topLeft)||{x:0,y:0},u=((g=s.props.crop)==null?void 0:g.bottomRight)||{x:1,y:1};return{topLeft:{x:He(a.x,c.x,n),y:He(a.y,c.y,n)},bottomRight:{x:He(l.x,u.x,n),y:He(l.y,u.y,n)}}}return{...n>.5?r.props:e.props,w:He(e.props.w,r.props.w,n),h:He(e.props.h,r.props.h,n),crop:o(e,r)}}}C(nw,"type","image"),C(nw,"props",oV),C(nw,"migrations",iV);function A9(t){const e=t.props.crop,r=e==null?void 0:e.topLeft;if(!r)return{width:t.props.w,height:t.props.h};const n=1/(e.bottomRight.x-e.topLeft.x)*t.props.w,o=1/(e.bottomRight.y-e.topLeft.y)*t.props.h,i=-r.x*n,s=-r.y*o;return{transform:`translate(${i}px, ${s}px)`,width:n,height:o}}function Hf(t,e){const{flipX:r,flipY:n}=t.props;if(!r&&!n)return;const o=`scale(${r?-1:1}, ${n?-1:1})`;return{transform:`${e?`translate(${r?e.width:0}px, ${n?e.height:0}px)`:""} ${o}`,transformOrigin:e?"0 0":"center center"}}function Jle(t){return{size:t,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function ece(t,e,r){const n=e.vertices,o=Jle(r);return fs(n,o)}function p_t(t,e,r){const n=Jle(r);return Hj(Lb(ece(t,e,r),n),n)}function g_t(t,e,r){const n=p_t(t,e,r);return dO(n)}function m_t(t,e,r){if(t.props.dash==="draw"){const n=ece(t,e,r);return Zc(n)}return e.getSvgPathData()}function tce(t,e,r){let n=`M ${Xe(e[0])}L`,o=`M ${Xe(e[0])}L`;const i=r/3,s=r*2,a=Ei(t);let l=e[0],c,u=e[0],d;const f=e.length;for(let p=0,g=f-1;p<g;p++){c=e[p+1],d=w.AddXY(e[p+1],a()*i,a()*i);const m=w.Sub(c,l),S=w.Len(m),y=w.Div(m,S).mul(Math.min(S/4,s)),v=w.Add(l,y),b=w.Add(c,y.neg()),$=w.Sub(d,u),P=w.Len($),E=w.Div($,P).mul(Math.min(P/4,s)),T=w.Add(u,E),I=w.Add(d,E.neg());p===g-1?(n+=`${Xe(v)}L ${Xe(c)}`,o+=`${Xe(T)}L ${Xe(d)}`):(n+=`${Xe(v)}L ${Xe(b)}Q ${Xe(c)}`,o+=`${Xe(T)}L ${Xe(I)}Q ${Xe(d)}`,l=c,u=d)}return[n,n+o]}const v_t=new ls;class ow extends Si{hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsFg(){return!0}hideSelectionBoundsBg(){return!0}getDefaultProps(){const[e,r]=pg(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[r]:{id:r,index:r,x:.1,y:.1}},scale:1}}getGeometry(e){return mp(e)}getHandles(e){return v_t.get(e.props,()=>{const r=mp(e),n=gp(e),o=n.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<n.length-1;i++){const s=fg(n[i].index,n[i+1].index),l=r.segments[i].midPoint();o.push({id:s,type:"create",index:s,x:l.x,y:l.y,canSnap:!0})}return o.sort(qr)})}onResize(e,r){const{scaleX:n,scaleY:o}=r;return{props:{points:Ug(e.props.points,(i,{id:s,index:a,x:l,y:c})=>({id:s,index:a,x:l*n,y:c*o}))}}}onHandleDrag(e,{handle:r}){if(r.type==="vertex")return{...e,props:{...e.props,points:{...e.props.points,[r.id]:{id:r.id,index:r.index,x:r.x,y:r.y}}}}}component(e){return h.jsx(xl,{id:e.id,children:h.jsx(k9,{shape:e})})}indicator(e){const r=ts[e.props.size]*e.props.scale,n=mp(e),{dash:o}=e.props;let i;if(e.props.spline==="line"){const s=n.points;if(o==="solid"||o==="dotted"||o==="dashed")i="M"+s[0]+"L"+s.slice(1);else{const[a]=tce(e.id,s,r);i=a}}else i=m_t(e,n,r);return h.jsx("path",{d:i})}toSvg(e){return h.jsx(k9,{shouldScale:!0,shape:e})}getHandleSnapGeometry(e){const r=gp(e);return{points:r,getSelfSnapPoints:n=>{const o=this.getHandles(e).filter(i=>i.type==="vertex").findIndex(i=>i.id===n.id);return r.filter((i,s)=>Math.abs(s-o)>1).map(w.From)},getSelfSnapOutline:n=>{const o=this.getHandles(e).filter(s=>s.type==="vertex").findIndex(s=>s.id===n.id),i=mp(e).segments.filter((s,a)=>a!==o-1&&a!==o);return i.length?new bi({children:i}):null}}}getInterpolatedProps(e,r,n){const o=gp(e),i=gp(r),s=[],a=[];let l=kK;if(o.length>i.length)for(let c=0;c<o.length;c++)s[c]={...o[c]},i[c]===void 0?a[c]={...i[i.length-1],id:l}:a[c]={...i[c],id:l},l=Xi(l);else if(i.length>o.length)for(let c=0;c<i.length;c++)a[c]={...i[c]},o[c]===void 0?s[c]={...o[o.length-1],id:l}:s[c]={...o[c],id:l},l=Xi(l);else for(let c=0;c<i.length;c++)s[c]=o[c],a[c]=i[c];return{...n>.5?r.props:e.props,points:Object.fromEntries(s.map((c,u)=>{const d=a[u];return[c.id,{...c,x:He(c.x,d.x,n),y:He(c.y,d.y,n)}]})),scale:He(e.props.scale,r.props.scale,n)}}}C(ow,"type","line"),C(ow,"props",sV),C(ow,"migrations",aV);function gp(t){return Object.values(t.props.points).sort(qr)}function mp(t){const e=gp(t).map(w.From);switch(t.props.spline){case"cubic":return new U0t({points:e});case"line":return new Ah({points:e})}}function k9({shape:t,shouldScale:e=!1,forceSolid:r=!1}){const n=ei(),o=mp(t),{dash:i,color:s,size:a}=t.props,l=1/t.props.scale,c=e?l:1,u=ts[a]*t.props.scale;if(t.props.spline==="line"){if(i==="solid"){const d=o.points,f="M"+d[0]+"L"+d.slice(1);return h.jsx("path",{d:f,stroke:n[s].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}if(i==="dashed"||i==="dotted")return h.jsx("g",{stroke:n[s].solid,strokeWidth:u,transform:`scale(${c})`,children:o.segments.map((d,f)=>{const{strokeDasharray:p,strokeDashoffset:g}=r?{strokeDasharray:"none",strokeDashoffset:"none"}:di(d.length,u,{style:i,start:f>0?"outset":"none",end:f<o.segments.length-1?"outset":"none"});return h.jsx("path",{strokeDasharray:p,strokeDashoffset:g,d:d.getSvgPathData(!0),fill:"none"},f)})});if(i==="draw"){const d=o.points,[f,p]=tce(t.id,d,u);return h.jsx("path",{d:p,stroke:n[s].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}}if(t.props.spline==="cubic"){const d=o.getSvgPathData();if(i==="solid")return h.jsx("path",{strokeWidth:u,stroke:n[s].solid,fill:"none",d,transform:`scale(${c})`});if(i==="dashed"||i==="dotted")return h.jsx("g",{stroke:n[s].solid,strokeWidth:u,transform:`scale(${c})`,children:o.segments.map((f,p)=>{const{strokeDasharray:g,strokeDashoffset:m}=di(f.length,u,{style:i,start:p>0?"outset":"none",end:p<o.segments.length-1?"outset":"none",forceSolid:r});return h.jsx("path",{strokeDasharray:g,strokeDashoffset:m,d:f.getSvgPathData(),fill:"none"},p)})});if(i==="draw")return h.jsx("path",{d:g_t(t,o,u),strokeWidth:1,stroke:n[s].solid,fill:n[s].solid,transform:`scale(${c})`})}}class iw extends Si{canEdit(){return!0}hideResizeHandles(){return!0}hideSelectionBoundsFg(){return!1}getDefaultProps(){return{color:"black",size:"m",text:"",font:"draw",align:"middle",verticalAlign:"middle",growY:0,fontSizeAdjustment:0,url:"",scale:1}}getGeometry(e){const{labelHeight:r,labelWidth:n}=rce(this.editor,e),{scale:o}=e.props,i=r*o,s=n*o,a=lt*o,l=Jy(e);return new bi({children:[new ia({width:a,height:l,isFilled:!0}),new ia({x:e.props.align==="start"?0:e.props.align==="end"?a-s:(a-s)/2,y:e.props.verticalAlign==="start"?0:e.props.verticalAlign==="end"?l-i:(l-i)/2,width:s,height:i,isFilled:!0,isLabel:!0})]})}getHandles(e){const{scale:r}=e.props;if(this.editor.getInstanceState().isCoarsePointer)return[];const o=this.editor.getZoomLevel();if(o*r<.25)return[];const i=Jy(e),s=lt*r,a=zEt/o*r;return o*r<.5?[{id:"bottom",index:"a3",type:"clone",x:s/2,y:i+a}]:[{id:"top",index:"a1",type:"clone",x:s/2,y:-a},{id:"right",index:"a2",type:"clone",x:s+a,y:i/2},{id:"bottom",index:"a3",type:"clone",x:s/2,y:i+a},{id:"left",index:"a4",type:"clone",x:-a,y:i/2}]}getText(e){return e.props.text}component(e){const{id:r,type:n,props:{scale:o,color:i,font:s,size:a,align:l,text:c,verticalAlign:u,fontSizeAdjustment:d}}=e,f=w_t(r),p=ei(),g=lt*o,m=Jy(e),S=H("shape rotation",()=>{var b;return((b=this.editor.getShapePageTransform(r))==null?void 0:b.rotation())??0},[this.editor]),y=H("zoom",()=>this.editor.getZoomLevel()<.35/o,[o,this.editor]),v=e.id===this.editor.getOnlySelectedShapeId();return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:r,className:"tl-note__container",style:{width:g,height:m,backgroundColor:p[i].note.fill,borderBottom:y?`${3*o}px solid rgb(15, 23, 31, .2)`:"none",boxShadow:y?"none":x_t(e.id,S,o)},children:h.jsx(Ub,{id:r,type:n,font:s,fontSize:(d||Js[a])*o,lineHeight:Rr.lineHeight,align:l,verticalAlign:u,text:c,isNote:!0,isSelected:v,labelColor:p[i].note.text,wrap:!0,padding:16*o,onKeyDown:f})}),"url"in e.props&&e.props.url&&h.jsx(ph,{url:e.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(e){const{scale:r}=e.props;return h.jsx("rect",{rx:r,width:N(lt*r),height:N(Jy(e))})}toSvg(e,r){e.props.text&&r.addExportDef(Fb(e.props.font));const n=ma({isDarkMode:r.isDarkMode}),o=b_t(e);return h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:5,y:5,rx:1,width:lt-10,height:o.h,fill:"rgba(0,0,0,.1)"}),h.jsx("rect",{rx:1,width:lt,height:o.h,fill:n[e.props.color].note.fill}),h.jsx(Bb,{fontSize:e.props.fontSizeAdjustment||Js[e.props.size],font:e.props.font,align:e.props.align,verticalAlign:e.props.verticalAlign,text:e.props.text,labelColor:n[e.props.color].note.text,bounds:o,stroke:!1})]})}onBeforeCreate(e){return O9(this.editor,e)}onBeforeUpdate(e,r){if(!(e.props.text===r.props.text&&e.props.font===r.props.font&&e.props.size===r.props.size))return O9(this.editor,r)}onEditEnd(e){const{id:r,type:n,props:{text:o}}=e;o.trimEnd()!==e.props.text&&this.editor.updateShapes([{id:r,type:n,props:{text:o.trimEnd()}}])}getInterpolatedProps(e,r,n){return{...n>.5?r.props:e.props,scale:He(e.props.scale,r.props.scale,n)}}}C(iw,"type","note"),C(iw,"props",lV),C(iw,"migrations",cV);function O9(t,e){const{labelHeight:r,fontSizeAdjustment:n}=rce(t,e),o=Math.max(0,r-lt);if(o!==e.props.growY||n!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:o,fontSizeAdjustment:n}}}function y_t(t,e){const{text:r}=e.props;if(!r)return{labelHeight:Js[e.props.size]*Rr.lineHeight+No*2,labelWidth:100,fontSizeAdjustment:0};const n=Js[e.props.size];let o=0,i=0,s=lt,a=lt;const l=1;do{o=Math.min(n,n-i);const c=t.textMeasure.measureText(r,{...Rr,fontFamily:as[e.props.font],fontSize:o,maxWidth:lt-No*2-l,disableOverflowWrapBreaking:!0});if(s=c.h+No*2,a=c.w+No*2,o<=14){const u=t.textMeasure.measureText(r,{...Rr,fontFamily:as[e.props.font],fontSize:o,maxWidth:lt-No*2-l});s=u.h+No*2,a=u.w+No*2;break}if(c.scrollWidth.toFixed(0)===c.w.toFixed(0))break}while(i++<50);return{labelHeight:s,labelWidth:a,fontSizeAdjustment:o}}const S_t=new ls;function rce(t,e){return S_t.get(e,()=>y_t(t,e))}function w_t(t){const e=F(),r=Mie();return x.useCallback(n=>{const o=e.getShape(t);if(!o)return;const i=n.key==="Tab",s=(n.metaKey||n.ctrlKey)&&n.key==="Enter";if(i||s){n.preventDefault();const a=e.getShapePageTransform(t),l=a.rotation(),c=!!(r.dir==="rtl"||_le(o.props.text)),u=(lt+e.options.adjacentShapeMargin+(s&&!n.shiftKey?o.props.growY:0))*o.props.scale,d=new w(i?n.shiftKey!=c?-1:1:0,s?n.shiftKey?-1:1:0).mul(u).add(Nb.clone().mul(o.props.scale)).rot(l).add(a.point()),f=jle(e,o,d,l);f&&(e.markHistoryStoppingPoint("editing adjacent shape"),V0(e,f,!0))}},[t,e,r.dir])}function Jy(t){return(lt+t.props.growY)*t.props.scale}function x_t(t,e,r){const n=Ei(t),o=Math.abs(n())+.5,i=Math.cos(e),s=5*r,a=4*r,l=6*r,c=7*r;return`0px ${s-o}px ${s}px -${s}px rgba(15, 23, 31, .6),
|
|
398
|
-
0px ${(a+o*c)*Math.max(0,i)}px ${l+o*c}px -${a+o*l}px rgba(15, 23, 31, ${(.3+o*.1).toFixed(2)}),
|
|
399
|
-
0px ${48*r}px ${10*r}px -${10*r}px inset rgba(15, 23, 44, ${((.022+n()*.005)*((1+i)/2)).toFixed(2)})`}function b_t(t){return new ee(0,0,lt,lt+t.props.growY)}function $_t(t,{initialBounds:e,scaleX:r,scaleY:n,newPoint:o}){const i=Math.max(.01,Math.min(Math.abs(r),Math.abs(n))),s=new w(0,0);r<0&&(s.x=-(e.width*i)),n<0&&(s.y=-(e.height*i));const{x:a,y:l}=w.Add(o,s.rot(t.rotation));return{x:a,y:l,props:{scale:i*t.props.scale}}}const I_t=new ls;class sw extends Si{getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",textAlign:"start",autoSize:!0,scale:1}}getMinDimensions(e){return I_t.get(e.props,r=>M9(this.editor,r))}getGeometry(e){const{scale:r}=e.props,{width:n,height:o}=this.getMinDimensions(e);return new ia({width:n*r,height:o*r,isFilled:!0,isLabel:!0})}getText(e){return e.props.text}canEdit(){return!0}isAspectRatioLocked(){return!0}component(e){const{id:r,props:{font:n,size:o,text:i,color:s,scale:a,textAlign:l}}=e,{width:c,height:u}=this.getMinDimensions(e),d=e.id===this.editor.getOnlySelectedShapeId(),f=ei(),p=P_t(r);return h.jsx(Ub,{id:r,classNamePrefix:"tl-text-shape",type:"text",font:n,fontSize:hh[o],lineHeight:Rr.lineHeight,align:l,verticalAlign:"middle",text:i,labelColor:f[s].solid,isSelected:d,textWidth:c,textHeight:u,style:{transform:`scale(${a})`,transformOrigin:"top left"},wrap:!0,onKeyDown:p})}indicator(e){const r=this.editor.getShapeGeometry(e).bounds,n=F();return e.props.autoSize&&n.getEditingShapeId()===e.id?null:h.jsx("rect",{width:N(r.width),height:N(r.height)})}toSvg(e,r){e.props.text&&r.addExportDef(Fb(e.props.font));const n=this.editor.getShapeGeometry(e).bounds,o=n.width/(e.props.scale??1),i=n.height/(e.props.scale??1),s=ma(r);return h.jsx(Bb,{fontSize:hh[e.props.size],font:e.props.font,align:e.props.textAlign,verticalAlign:"middle",text:e.props.text,labelColor:s[e.props.color].solid,bounds:new ee(0,0,o,i),padding:0})}onResize(e,r){const{newPoint:n,initialBounds:o,initialShape:i,scaleX:s,handle:a}=r;if(r.mode==="scale_shape"||a!=="right"&&a!=="left")return{id:e.id,type:e.type,...$_t(e,r)};{const l=Math.max(1,Math.abs(o.width*s)),{x:c,y:u}=s<0?w.Sub(n,w.FromAngle(e.rotation).mul(l)):n;return{id:e.id,type:e.type,x:c,y:u,props:{w:l/i.props.scale,autoSize:!1}}}}onEditEnd(e){const{id:r,type:n,props:{text:o}}=e,i=e.props.text.trimEnd();i.length===0?this.editor.deleteShapes([e.id]):i!==e.props.text&&this.editor.updateShapes([{id:r,type:n,props:{text:o.trimEnd()}}])}onBeforeUpdate(e,r){if(!r.props.autoSize)return;const n=e.props.size!==r.props.size||e.props.textAlign!==r.props.textAlign||e.props.font!==r.props.font||e.props.scale!==1&&r.props.scale===1,o=e.props.text!==r.props.text;if(!n&&!o)return;const i=this.getMinDimensions(e),s=M9(this.editor,r.props),a=i.width*e.props.scale,l=i.height*e.props.scale,c=s.width*r.props.scale,u=s.height*r.props.scale;let d;switch(r.props.textAlign){case"middle":{d=new w((c-a)/2,o?0:(u-l)/2);break}case"end":{d=new w(c-a,o?0:(u-l)/2);break}default:{if(o)break;d=new w(0,(u-l)/2);break}}if(d){d.rot(r.rotation);const{x:f,y:p}=r;return{...r,x:f-d.x,y:p-d.y,props:{...r.props,w:c}}}else return{...r,props:{...r.props,w:c}}}}C(sw,"type","text"),C(sw,"props",uV),C(sw,"migrations",dV);function M9(t,e){const{font:r,text:n,autoSize:o,size:i,w:s}=e,a=o?16:Math.max(16,s),l=hh[i],c=o?null:Math.floor(Math.max(a,s)),u=t.textMeasure.measureText(n,{...Rr,fontFamily:as[r],fontSize:l,maxWidth:c});return o&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(l,u.h)}}function P_t(t){const e=F();return x.useCallback(r=>{if(e.getEditingShapeId()===t)switch(r.key){case"Enter":{(r.ctrlKey||r.metaKey)&&e.complete();break}case"Tab":{Ue(r),r.shiftKey?fh.unindent(r.currentTarget):fh.indent(r.currentTarget);break}}},[e,t])}class aw extends Vh{canEdit(){return!0}isAspectRatioLocked(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(e){const{editor:r}=this,n=r.getShapeGeometry(e).bounds.w*r.getZoomLevel()>=110,{asset:o,url:i}=Zle(e.id,e.props.assetId,e.props.w),s=gb(e.id),a=Qle(),{Spinner:l}=Pt(),c=x.useRef(null),[u,d]=x.useState(!1),[f,p]=x.useState(!1);x.useEffect(()=>{const m=()=>p(document.fullscreenElement===c.current);return document.addEventListener("fullscreenchange",m),()=>document.removeEventListener("fullscreenchange",m)});const g=x.useCallback(m=>{m.currentTarget&&d(!0)},[]);return x.useEffect(()=>{const m=c.current;m&&s&&document.activeElement!==m&&m.focus()},[s,u]),x.useEffect(()=>{if(a){const m=c.current;if(!m)return;m.pause(),m.currentTime=0}},[c,a]),h.jsxs(h.Fragment,{children:[h.jsx(ml,{id:e.id,style:{color:"var(--color-text-3)",backgroundColor:o?"transparent":"var(--color-low)",border:o?"none":"1px solid var(--color-low-border)"},children:h.jsx("div",{className:"tl-counter-scaled",children:h.jsx("div",{className:"tl-video-container",children:o?l&&!o.props.src?h.jsx(l,{}):i?h.jsxs(h.Fragment,{children:[h.jsx("video",{ref:c,style:s?{pointerEvents:"all"}:u?void 0:{display:"none"},className:pe("tl-video",`tl-video-shape-${e.id.split(":")[1]}`,{"tl-video-is-fullscreen":f}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:s&&n,onLoadedData:g,hidden:!u,children:h.jsx("source",{src:i})}),!u&&l&&h.jsx(l,{})]}):null:h.jsx(qle,{})})})}),"url"in e.props&&e.props.url&&h.jsx(ph,{url:e.props.url,zoomLevel:r.getZoomLevel()})]})}indicator(e){return h.jsx("rect",{width:N(e.props.w),height:N(e.props.h)})}async toSvg(e){const r=await E_t(this.editor,e);return r?h.jsx("image",{href:r,width:e.props.w,height:e.props.h}):null}}C(aw,"type","video"),C(aw,"props",hV),C(aw,"migrations",fV);async function E_t(t,e){const r=await t.resolveAssetUrl(e.props.assetId,{shouldResolveToOriginal:!0});if(!r)return null;const n=await io.loadVideo(r);return io.getVideoFrameAsDataUrl(n,0)}const nce=[sw,ZS,QS,tw,iw,ow,ew,qS,rw,JS,nw,aw];function C_t(t){return t.sideEffects.register({instance_page_state:{afterChange:(e,r)=>{if(e.croppingShapeId!==r.croppingShapeId){const n=t.isIn("select.crop");!e.croppingShapeId&&r.croppingShapeId?n||t.setCurrentTool("select.crop.idle"):e.croppingShapeId&&!r.croppingShapeId&&n&&t.setCurrentTool("select.idle")}e.editingShapeId!==r.editingShapeId&&(!e.editingShapeId&&r.editingShapeId?t.isIn("select.editing_shape")||t.setCurrentTool("select.editing_shape"):e.editingShapeId&&!r.editingShapeId&&t.isIn("select.editing_shape")&&t.setCurrentTool("select.idle"))}}})}class oce extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"scribbleId","id");C(this,"markId","");C(this,"excludedShapeIds",new Set)}onEnter(r){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=r;const{originPagePoint:n}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(i=>{if(this.editor.isShapeOrAncestorLocked(i))return!0;if(this.editor.isShapeOfType(i,"group")||this.editor.isShapeOfType(i,"frame")){const s=this.editor.getPointInShapeSpace(i,n);return this.editor.getShapeGeometry(i).bounds.containsPoint(s)}return!1}).map(i=>i.id));const o=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=o.id,this.update()}pushPointToScribble(){const{x:r,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,r,n)}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}update(){const{editor:r,excludedShapeIds:n}=this,o=r.getErasingShapeIds(),i=r.getZoomLevel(),s=r.getCurrentPageShapes(),{inputs:{currentPagePoint:a,previousPagePoint:l}}=r;this.pushPointToScribble();const c=new Set(o),u=this.editor.options.hitTestMargin/i;for(const d of s){if(r.isShapeOfType(d,"group"))continue;const f=r.getShapeMask(d.id);if(f&&!ho(a,f))continue;const p=r.getShapeGeometry(d),g=r.getShapePageTransform(d);if(!p||!g)continue;const m=g.clone().invert(),S=m.applyToPoint(l),y=m.applyToPoint(a),{bounds:v}=p;v.minX-u>Math.max(S.x,y.x)||v.minY-u>Math.max(S.y,y.y)||v.maxX+u<Math.min(S.x,y.x)||v.maxY+u<Math.min(S.y,y.y)||p.hitTestLineSegment(S,y,u)&&c.add(r.getOutermostSelectableShape(d).id)}this.editor.setErasingShapes([...c].filter(d=>!n.has(d)))}complete(){const{editor:r}=this;r.deleteShapes(r.getCurrentPageState().erasingShapeIds),r.setErasingShapes([]),this.parent.transition("idle")}cancel(){const{editor:r}=this;r.setErasingShapes([]),r.bailToMark(this.markId),this.parent.transition("idle",this.info)}}C(oce,"id","erasing");var kC;let __t=(kC=class extends he{onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},C(kC,"id","idle"),kC);var OC;let T_t=(OC=class extends he{onEnter(){const e=this.editor.getZoomLevel(),r=this.editor.getCurrentPageShapesSorted(),{inputs:{currentPagePoint:n}}=this.editor,o=new Set,i=o.size;for(let s=r.length,a=s-1;a>=0;a--){const l=r[a];if(!(this.editor.isShapeOrAncestorLocked(l)||this.editor.isShapeOfType(l,"group"))&&this.editor.isPointInShape(l,n,{hitInside:!1,margin:this.editor.options.hitTestMargin/e})){const c=this.editor.getOutermostSelectableShape(l);if(this.editor.isShapeOfType(c,"frame")&&o.size>i)break;o.add(c.id)}}this.editor.setErasingShapes([...o])}onLongPress(e){this.startErasing(e)}onPointerMove(e){this.editor.inputs.isDragging&&this.startErasing(e)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}startErasing(e){this.parent.transition("erasing",e)}complete(){const e=this.editor.getErasingShapeIds();e.length&&(this.editor.markHistoryStoppingPoint("erase end"),this.editor.deleteShapes(e)),this.editor.setErasingShapes([]),this.parent.transition("idle")}cancel(){this.editor.setErasingShapes([]),this.parent.transition("idle")}},C(OC,"id","pointing"),OC);class lw extends he{static children(){return[__t,T_t,oce]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}C(lw,"id","eraser"),C(lw,"initial","idle"),C(lw,"isLockable",!1);class ice extends he{constructor(){super(...arguments);C(this,"initialCamera",new w)}onEnter(){this.initialCamera=w.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){const{initialCamera:r,editor:n}=this,{currentScreenPoint:o,originScreenPoint:i}=n.inputs,s=w.Sub(o,i).div(n.getZoomLevel());s.len2()!==0&&n.setCamera(r.clone().add(s))}complete(){const{editor:r}=this,{pointerVelocity:n}=r.inputs,o=Math.min(n.len(),2);o>.1&&this.editor.slideCamera({speed:o,direction:n}),this.parent.transition("idle")}}C(ice,"id","dragging");var MC;let A_t=(MC=class extends he{onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},C(MC,"id","idle"),MC);var RC;let k_t=(RC=class extends he{onEnter(){this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})}onLongPress(){this.startDragging()}onPointerMove(){this.editor.inputs.isDragging&&this.startDragging()}startDragging(){this.parent.transition("dragging")}onPointerUp(){this.complete()}onCancel(){this.complete()}onComplete(){this.complete()}onInterrupt(){this.complete()}complete(){this.parent.transition("idle")}},C(RC,"id","pointing"),RC);class pA extends he{static children(){return[A_t,k_t,ice]}onDoubleClick(e){if(e.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomIn(r,{animation:{duration:220,easing:pr.easeOutQuint}})}}onTripleClick(e){if(e.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomOut(r,{animation:{duration:320,easing:pr.easeOutQuint}})}}onQuadrupleClick(e){if(e.phase==="settle"){const r=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:n}}=this.editor;r===1?this.editor.zoomToFit({animation:{duration:400,easing:pr.easeOutQuint}}):this.editor.resetZoom(n,{animation:{duration:320,easing:pr.easeOutQuint}})}}}C(pA,"id","hand"),C(pA,"initial","idle");var jC;let O_t=(jC=class extends he{onPointerDown(e){this.parent.transition("lasering",e)}},C(jC,"id","idle"),jC);class sce extends he{constructor(){super(...arguments);C(this,"scribbleId","id")}onEnter(){const r=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:this.editor.options.laserDelayMs,shrink:.05,taper:!0});this.scribbleId=r.id,this.pushPointToScribble()}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.pushPointToScribble()}onPointerUp(){this.complete()}pushPointToScribble(){const{x:r,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,r,n)}onCancel(){this.cancel()}onComplete(){this.complete()}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}C(sce,"id","lasering");class cw extends he{static children(){return[O_t,sce]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}C(cw,"id","laser"),C(cw,"initial","idle"),C(cw,"isLockable",!1);class ace extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"initialSelectedShapeIds",[]);C(this,"excludedShapeIds",new Set);C(this,"isWrapMode",!1);C(this,"initialStartShape",null)}onEnter(r){const{altKey:n,currentPagePoint:o}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),n){this.parent.transition("scribble_brushing",r);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(i=>this.editor.isShapeOfType(i,"group")||this.editor.isShapeOrAncestorLocked(i)).map(i=>i.id)),this.info=r,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(o)[0],this.hitTestShapes()}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})}onTick({elapsed:r}){const{editor:n}=this;n.edgeScrollManager.updateEdgeScrolling(r)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(r){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",r)}onKeyDown(r){this.editor.inputs.altKey?this.parent.transition("scribble_brushing",r):this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:r,excludedShapeIds:n,isWrapMode:o}=this,{inputs:{originPagePoint:i,currentPagePoint:s,shiftKey:a,ctrlKey:l}}=r,c=new Set(a?this.initialSelectedShapeIds:[]),u=o?!l:l,d=ee.FromPoints([i,s]),{corners:f}=d;let p,g,m,S,y,v;const b=r.getCurrentPageShapes(),$=r.getCurrentPageId();e:for(let T=0,I=b.length;T<I;T++){if(m=b[T],n.has(m.id)||c.has(m.id)||(S=r.getShapePageBounds(m),!S))continue e;if(d.contains(S)){this.handleHit(m,s,$,c,f);continue e}if(u||r.isShapeOfType(m,"frame"))continue e;if(d.collides(S)){if(y=r.getShapePageTransform(m),!y)continue e;v=y.clone().invert().applyToPoints(f);const _=r.getShapeGeometry(m);t:for(let k=0;k<4;k++)if(p=v[k],g=v[(k+1)%4],_.hitTestLineSegment(p,g,0)){this.handleHit(m,s,$,c,f);break t}}}r.getInstanceState().isCoarsePointer;const P=r.getInstanceState().brush;(!P||!d.equals(P))&&r.updateInstanceState({brush:{...d.toJson()}});const E=r.getSelectedShapeIds();(E.length!==c.size||E.some(T=>!c.has(T)))&&r.setSelectedShapes(Array.from(c))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(r,n,o,i,s){if(r.parentId===o){i.add(r.id);return}const a=this.editor.getOutermostSelectableShape(r),l=this.editor.getShapeMask(a.id);l&&!iY(l,s)&&!ho(n,l)||i.add(a.id)}}C(ace,"id","brushing");const mh={bottom:"ns-resize",top:"ns-resize",left:"ew-resize",right:"ew-resize",bottom_left:"nesw-resize",bottom_right:"nwse-resize",top_left:"nwse-resize",top_right:"nesw-resize",bottom_left_rotate:"swne-rotate",bottom_right_rotate:"senw-rotate",top_left_rotate:"nwse-rotate",top_right_rotate:"nesw-rotate",mobile_rotate:"grabbing"};class lce extends he{constructor(){super(...arguments);C(this,"info",{})}updateCursor(){const r=this.editor.getSelectedShapes(),n=mh[this.info.handle];this.editor.setCursor({type:n,rotation:r.length===1?this.editor.getSelectionRotation():0})}onEnter(r){this.info=r,this.updateCursor()}onPointerMove(){this.editor.inputs.isDragging&&this.startResizing()}onLongPress(){this.startResizing()}startResizing(){this.editor.getInstanceState().isReadonly||this.parent.transition("resizing",this.info)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}C(lce,"id","pointing_resize_handle");const jo=8;class Zj extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"markId","");C(this,"snapshot",{})}onEnter(r){this.info=r,this.markId=this.editor.markHistoryStoppingPoint("cropping"),this.snapshot=this.createSnapshot(),this.updateShapes()}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;const n=mh[this.info.handle];this.editor.setCursor({type:n,rotation:this.editor.getSelectionRotation()})}getDefaultCrop(){return{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}}updateShapes(){const{shape:r,cursorHandleOffset:n}=this.snapshot;if(!r||!this.editor.getShapeUtil("image"))return;const i=r.props,s=this.editor.inputs.currentPagePoint.clone().sub(n),a=this.editor.inputs.originPagePoint.clone().sub(n),l=s.clone().sub(a).rot(-r.rotation),c=i.crop??this.getDefaultCrop(),u=$t(c),d=new w(r.x,r.y),f=new w(0,0),p=1/(c.bottomRight.x-c.topLeft.x)*i.w,g=1/(c.bottomRight.y-c.topLeft.y)*i.h;let m=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(g<jo)break;m=!0,u.topLeft.y=u.topLeft.y+l.y/g,g*(u.bottomRight.y-u.topLeft.y)<jo?(u.topLeft.y=u.bottomRight.y-jo/g,f.y=(u.topLeft.y-c.topLeft.y)*g):u.topLeft.y<=0?(u.topLeft.y=0,f.y=(u.topLeft.y-c.topLeft.y)*g):f.y=l.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(g<jo)break;m=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+l.y/g),g*(u.bottomRight.y-u.topLeft.y)<jo&&(u.bottomRight.y=u.topLeft.y+jo/g);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(p<jo)break;m=!0,u.topLeft.x=u.topLeft.x+l.x/p,p*(u.bottomRight.x-u.topLeft.x)<jo?(u.topLeft.x=u.bottomRight.x-jo/p,f.x=(u.topLeft.x-c.topLeft.x)*p):u.topLeft.x<=0?(u.topLeft.x=0,f.x=(u.topLeft.x-c.topLeft.x)*p):f.x=l.x;break}case"right":case"top_right":case"bottom_right":{if(p<jo)break;m=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+l.x/p),p*(u.bottomRight.x-u.topLeft.x)<jo&&(u.bottomRight.x=u.topLeft.x+jo/p);break}}if(!m)return;d.add(f.rot(r.rotation));const S={id:r.id,type:r.type,x:d.x,y:d.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*p,h:(u.bottomRight.y-u.topLeft.y)*g}};this.editor.updateShapes([S]),this.updateCursor()}complete(){this.updateShapes(),pt(this.editor,[this.snapshot.shape.id]),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}createSnapshot(){const r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:n}}=this.editor,o=this.editor.getOnlySelectedShape(),i=this.editor.getSelectionRotatedPageBounds(),s=w.RotWith(i.getHandlePoint(this.info.handle),i.point,r),a=w.Sub(n,s);return{shape:o,cursorHandleOffset:a}}}C(Zj,"id","cropping");function cce(t,e=!1){const r=t.getZoomLevel(),{inputs:{currentPagePoint:n}}=t;return t.getShapeAtPoint(n,{hitInside:!1,hitLabels:e,margin:t.options.hitTestMargin/r,renderingOnly:!0})??t.getSelectedShapeAtPoint(n)}function uce(t,e,r){if(!e)throw Error("Needs to translate a cropped shape!");const{crop:n}=e.props;if(!n)return;const o=t.inputs.shiftKey?Math.abs(r.x)<Math.abs(r.y)?"x":"y":null;o==="x"?r.x=0:o==="y"&&(r.y=0),r.rot(-e.rotation);const i=1/(n.bottomRight.x-n.topLeft.x)*e.props.w,s=1/(n.bottomRight.y-n.topLeft.y)*e.props.h,a=n.bottomRight.y-n.topLeft.y,l=n.bottomRight.x-n.topLeft.x,c=$t(n);return c.topLeft.x=Math.min(1-l,Math.max(0,c.topLeft.x-r.x/i)),c.topLeft.y=Math.min(1-a,Math.max(0,c.topLeft.y-r.y/s)),c.bottomRight.x=c.topLeft.x+l,c.bottomRight.y=c.topLeft.y+a,{id:e.id,type:e.type,props:{crop:c}}}var DC;let M_t=(DC=class extends he{onEnter(){this.editor.setCursor({type:"default",rotation:0});const e=this.editor.getOnlySelectedShape();e&&this.editor.setCroppingShape(e.id)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onCancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}onPointerDown(e){var r;if(!this.editor.getIsMenuOpen()){if(e.ctrlKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{const n=cce(this.editor);if(n&&!this.editor.isShapeOfType(n,"group")){this.onPointerDown({...e,shape:n,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(e);break}case"shape":{if(e.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",e);return}else(r=this.editor.getShapeUtil(e.shape))!=null&&r.canCrop(e.shape)?(this.editor.setCroppingShape(e.shape.id),this.editor.setSelectedShapes([e.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",e)):(this.cancel(),this.editor.root.handleEvent(e));break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...e,onInteractionEnd:"select.crop.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...e,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}}onDoubleClick(e){var i;if(this.editor.inputs.shiftKey||e.phase!=="up")return;const r=this.editor.getCroppingShapeId();if(!r)return;const n=this.editor.getShape(r);if(!n)return;const o=this.editor.getShapeUtil(n);if(o){if(e.target==="selection"){(i=o.onDoubleClickEdge)==null||i.call(o,n);return}this.cancel(),this.editor.root.handleEvent(e)}}onKeyDown(){this.nudgeCroppingImage(!1)}onKeyRepeat(){this.nudgeCroppingImage(!0)}onKeyUp(e){switch(e.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(e=!1){const{editor:{inputs:{keys:r}}}=this,n=r.has("ShiftLeft"),o=new w(0,0);if(r.has("ArrowLeft")&&(o.x+=1),r.has("ArrowRight")&&(o.x-=1),r.has("ArrowUp")&&(o.y+=1),r.has("ArrowDown")&&(o.y-=1),o.equals(new w(0,0)))return;n&&o.mul(10);const i=this.editor.getShape(this.editor.getCroppingShapeId());if(!i)return;const s=uce(this.editor,i,o);s&&(e||this.editor.markHistoryStoppingPoint("translate crop"),this.editor.updateShapes([s]))}},C(DC,"id","idle"),DC);class dce extends he{onCancel(){this.editor.setCurrentTool("select.crop.idle",{})}onPointerMove(e){this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",e)}onPointerUp(e){this.editor.setCurrentTool("select.crop.idle",e)}}C(dce,"id","pointing_crop");class Qj extends he{constructor(){super(...arguments);C(this,"info",{})}onEnter(r){this.info=r,this.parent.setCurrentToolIdMask(r.onInteractionEnd);const n=this.editor.getSelectedShapes()[0];if(!n)return;const o=mh[this.info.handle];this.editor.setCursor({type:o,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(n.id)}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){this.editor.inputs.isDragging&&this.startCropping()}onLongPress(){this.startCropping()}startCropping(){this.editor.getInstanceState().isReadonly||this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}onPointerUp(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}}C(Qj,"id","pointing_crop_handle");class hce extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"markId","");C(this,"snapshot",{})}onEnter(r){this.info=r,this.snapshot=this.createSnapshot(),this.markId=this.editor.markHistoryStoppingPoint("translating_crop"),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onKeyDown(r){switch(r.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(r){switch(r.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){const r=this.snapshot.shape;if(!r)return;const{originPagePoint:n,currentPagePoint:o}=this.editor.inputs,i=o.clone().sub(n),s=uce(this.editor,r,i);s&&this.editor.updateShapes([s])}}C(hce,"id","translating_crop");class gA extends he{constructor(){super(...arguments);C(this,"markId","");C(this,"didExit",!1)}static children(){return[M_t,hce,dce,Qj,Zj]}onEnter(){this.didExit=!1,this.markId=this.editor.markHistoryStoppingPoint("crop")}onExit(){this.didExit||(this.didExit=!0,this.editor.squashToMark(this.markId))}onCancel(){this.didExit||(this.didExit=!0,this.editor.bailToMark(this.markId))}}C(gA,"id","crop"),C(gA,"initial","idle");class fce extends he{constructor(){super(...arguments);C(this,"shapeId","");C(this,"initialHandle",{});C(this,"initialAdjacentHandle",null);C(this,"initialPagePoint",{});C(this,"markId","");C(this,"initialPageTransform");C(this,"initialPageRotation");C(this,"info",{});C(this,"isPrecise",!1);C(this,"isPreciseId",null);C(this,"pointingId",null);C(this,"exactTimeout",-1)}onEnter(r){const{shape:n,isCreating:o,creatingMarkId:i,handle:s}=r;if(this.info=r,this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.shapeId=n.id,this.markId="",o)if(i)this.markId=i;else{const c=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);c&&(this.markId=c)}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");if(this.initialHandle=$t(s),this.editor.isShapeOfType(n,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...n,props:{points:{...n.props.points,[s.index]:{id:s.index,index:s.index,x:s.x,y:s.y}}}});const u=this.editor.getShapeHandles(n).find(d=>d.index===s.index);this.initialHandle=$t(u)}this.initialPageTransform=this.editor.getShapePageTransform(n),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.setCursor({type:o?"cross":"grabbing",rotation:0});const a=this.editor.getShapeHandles(n).sort(qr),l=a.findIndex(c=>c.id===r.handle.id);this.initialAdjacentHandle=null;for(let c=l+1;c<a.length;c++){const u=a[c];if(u.type==="vertex"&&u.id!=="middle"&&u.id!==r.handle.id){this.initialAdjacentHandle=u;break}}if(!this.initialAdjacentHandle)for(let c=a.length-1;c>=0;c--){const u=a[c];if(u.type==="vertex"&&u.id!=="middle"&&u.id!==r.handle.id){this.initialAdjacentHandle=u;break}}if(this.editor.isShapeOfType(n,"arrow")){const c=Rn(this.editor,n)[r.handle.id];this.isPrecise=!1,c?(this.editor.setHintingShapes([c.toId]),this.isPrecise=c.props.isPrecise,this.isPrecise?this.isPreciseId=c.toId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)}resetExactTimeout(){this.exactTimeout!==-1&&this.clearExactTimeout(),this.exactTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&!this.isPrecise&&(this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update()),this.exactTimeout=-1},750)}clearExactTimeout(){this.exactTimeout!==-1&&(clearTimeout(this.exactTimeout),this.exactTimeout=-1)}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.update(),this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})}complete(){this.editor.snaps.clearIndicators(),pt(this.editor,[this.shapeId]);const{onInteractionEnd:r}=this.info;if(this.editor.getInstanceState().isToolLocked&&r){this.editor.setCurrentTool(r,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:r}=this.info;if(r){this.editor.setCurrentTool(r,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var T;const{editor:r,shapeId:n,initialPagePoint:o}=this,{initialHandle:i,initialPageRotation:s,initialAdjacentHandle:a}=this,l=this.editor.getHintingShapeIds(),c=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:d,shiftKey:f,ctrlKey:p,altKey:g,pointerVelocity:m}}=r,S=this.info.shape,y=r.getShape(n);if(!y)return;const v=r.getShapeUtil(y);let b=d.clone().sub(o).rot(-s).add(i);if(f&&a&&i.id!=="middle"){const I=w.Angle(a,b),k=a0(I,24)-I;b=w.RotWith(b,a,k)}r.snaps.clearIndicators();let $={...i,x:b.x,y:b.y};if(i.canSnap&&(c?!p:p)){if(!r.getShapePageTransform(y.id))throw Error("Expected a page transform");const _=u.handles.snapHandle({currentShapeId:n,handle:$});_&&(_.nudge.rot(-r.getShapeParentTransform(y).rotation()),b.add(_.nudge),$={...i,x:b.x,y:b.y})}const P=(T=v.onHandleDrag)==null?void 0:T.call(v,y,{handle:$,isPrecise:this.isPrecise||g,initial:S}),E={id:y.id,type:y.type,...P};if(i.type==="vertex"&&this.editor.isShapeOfType(y,"arrow")){const I=Rn(r,y)[i.id];I?l[0]!==I.toId&&(r.setHintingShapes([I.toId]),this.pointingId=I.toId,this.isPrecise=m.len()<.5||g,this.isPreciseId=this.isPrecise?I.toId:null,this.resetExactTimeout()):l.length>0&&(r.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}P&&r.updateShapes([E])}}C(fce,"id","dragging_handle");function pce(t){return t.isLabel?[t]:t instanceof bi?t.children.filter(e=>e.isLabel):[]}class gce extends he{constructor(){super(...arguments);C(this,"hitShapeForPointerUp",null)}onEnter(){const r=this.editor.getEditingShape();if(!r)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,Gs(this.editor),this.editor.select(r)}onExit(){var i;const{editingShapeId:r}=this.editor.getCurrentPageState();if(!r)return;this.editor.setEditingShape(null),Gs.cancel();const n=this.editor.getShape(r),o=this.editor.getShapeUtil(n);(i=o.onEditEnd)==null||i.call(o,n)}onPointerMove(r){if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly||this.hitShapeForPointerUp.isLocked)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",r),this.hitShapeForPointerUp=null;return}switch(r.target){case"shape":case"canvas":{Gs(this.editor);return}}}onPointerDown(r){switch(this.hitShapeForPointerUp=null,r.target){case"shape":{const{shape:n}=r,o=this.editor.getEditingShape();if(!o)throw Error("Expected an editing shape!");const i=this.editor.getShapeUtil(n).getGeometry(n),s=pce(i),a=s.length===1?s[0]:void 0,l=this.editor.isShapeOfType(o,"text")&&o.props.text.trim()==="";if(a&&!l){const c=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(c,0)&&a.hitTestPoint(c)){if(n.id===o.id)return;this.hitShapeForPointerUp=n,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(n.id);return}}else{if(n.id===o.id)this.editor.isShapeOfType(n,"frame")&&(this.editor.setEditingShape(null),this.parent.transition("idle",r));else{this.parent.transition("pointing_shape",r);return}return}break}}this.parent.transition("idle",r),this.editor.root.handleEvent(r)}onPointerUp(r){const n=this.hitShapeForPointerUp;if(!n)return;this.hitShapeForPointerUp=null;const o=this.editor.getShapeUtil(n);if(!n.isLocked){if(this.editor.getInstanceState().isReadonly&&!o.canEditInReadOnly(n)){this.parent.transition("pointing_shape",r);return}this.editor.select(n.id),this.editor.setEditingShape(n.id),Gs(this.editor)}}onComplete(r){this.parent.transition("idle",r)}onCancel(r){this.parent.transition("idle",r)}}C(gce,"id","editing_shape");function R9(t){const e=t.getOnlySelectedShape();return!!(e&&!t.isShapeOrAncestorLocked(e)&&t.getShapeUtil(e).canCrop(e))}function lx(t){const e=t.getSelectedShapeIds(),{shiftKey:r,altKey:n,currentPagePoint:o}=t.inputs,i=t.getShapeAtPoint(o,{hitInside:!1,margin:t.options.hitTestMargin/t.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:s=>!s.isLocked});if(i){const s=t.getOutermostSelectableShape(i);if(r&&!n)t.cancelDoubleClick(),e.includes(s.id)?(t.markHistoryStoppingPoint("deselecting shape"),t.deselect(s)):(t.markHistoryStoppingPoint("shift selecting shape"),t.setSelectedShapes([...e,s.id]));else{let a;s===i||s.id===t.getFocusedGroupId()||e.includes(s.id)?a=i:a=s,a&&!e.includes(a.id)&&(t.markHistoryStoppingPoint("selecting shape"),t.select(a.id))}}else{if(r)return;{e.length>0&&(t.markHistoryStoppingPoint("selecting none"),t.selectNone());const s=t.getFocusedGroupId();if(Tn(s)){const a=t.getShape(s);t.isPointInShape(a,o,{margin:0,hitInside:!0})||t.setFocusedGroup(null)}}}}const R_t=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var LC;let j_t=(LC=class extends he{constructor(){super(...arguments);C(this,"isDarwin",window.navigator.userAgent.toLowerCase().indexOf("mac")>-1)}onEnter(){this.parent.setCurrentToolIdMask(void 0),Gs(this.editor),this.editor.setCursor({type:"default",rotation:0})}onExit(){Gs.cancel()}onPointerMove(){Gs(this.editor)}onPointerDown(r){if(this.editor.getIsMenuOpen())return;const n=r.ctrlKey&&R9(this.editor);if(r.ctrlKey&&!n){if(r.target==="shape"&&this.isDarwin&&this.editor.inputs.keys.has("ControlLeft")&&!this.editor.isShapeOrAncestorLocked(r.shape)){this.parent.transition("pointing_shape",r);return}this.parent.transition("brushing",r);return}switch(r.target){case"canvas":{const o=cce(this.editor);if(o&&!o.isLocked){this.onPointerDown({...r,shape:o,target:"shape"});return}const i=this.editor.getSelectedShapeIds(),s=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((i.length>1||s&&!this.editor.getShapeUtil(s).hideSelectionBoundsBg(s))&&j9(this.editor,a)){this.onPointerDown({...r,target:"selection"});return}this.parent.transition("pointing_canvas",r);break}case"shape":{const{shape:o}=r;if(this.isOverArrowLabelTest(o)){this.parent.transition("pointing_arrow_label",r);break}if(this.editor.isShapeOrAncestorLocked(o)){this.parent.transition("pointing_canvas",r);break}this.parent.transition("pointing_shape",r);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",r):this.parent.transition("pointing_handle",r);break}case"selection":{switch(r.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.parent.transition("pointing_rotate_handle",r);break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{n?this.parent.transition("crop.pointing_crop_handle",r):this.parent.transition("pointing_resize_handle",r);break}default:{const o=this.editor.getHoveredShape();if(o&&!this.editor.getSelectedShapeIds().includes(o.id)&&!o.isLocked){this.onPointerDown({...r,shape:o,target:"shape"});return}this.parent.transition("pointing_selection",r)}}break}}}onDoubleClick(r){var n,o,i,s;if(!(this.editor.inputs.shiftKey||r.phase!=="up"))switch(r.target){case"canvas":{const a=this.editor.getHoveredShape(),l=a&&!this.editor.isShapeOfType(a,"group")?a:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1}),c=this.editor.getFocusedGroupId();if(l){if(this.editor.isShapeOfType(l,"group")){lx(this.editor);return}else{const u=this.editor.getShape(l.parentId);if(u&&this.editor.isShapeOfType(u,"group")&&!(c&&u.id===c)){lx(this.editor);return}}this.onDoubleClick({...r,shape:l,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(r);break}case"selection":{if(this.editor.getInstanceState().isReadonly)break;const a=this.editor.getOnlySelectedShape();if(a){const l=this.editor.getShapeUtil(a);if(!this.canInteractWithShapeInReadOnly(a))return;if(r.handle==="right"||r.handle==="left"||r.handle==="top"||r.handle==="bottom"){const c=(n=l.onDoubleClickEdge)==null?void 0:n.call(l,a);if(c){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([c]),pt(this.editor,[a.id]);return}}if(l.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.parent.transition("crop",r);return}this.shouldStartEditingShape(a)&&this.startEditingShape(a,r,!0)}break}case"shape":{const{shape:a}=r,l=this.editor.getShapeUtil(a);if(a.type!=="video"&&a.type!=="embed"&&this.editor.getInstanceState().isReadonly)break;if(l.onDoubleClick){const c=(o=l.onDoubleClick)==null?void 0:o.call(l,a);if(c){this.editor.updateShapes([c]);return}}if(l.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select((i=r.shape)==null?void 0:i.id),this.parent.transition("crop",r);return}this.shouldStartEditingShape(a)?this.startEditingShape(a,r,!0):this.handleDoubleClickOnCanvas(r);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;const{shape:a,handle:l}=r,c=this.editor.getShapeUtil(a),u=(s=c.onDoubleClickHandle)==null?void 0:s.call(c,a,l);u?this.editor.updateShapes([u]):this.shouldStartEditingShape(a)&&this.startEditingShape(a,r,!0)}}}onRightClick(r){switch(r.target){case"canvas":{const n=this.editor.getHoveredShape(),o=n&&!this.editor.isShapeOfType(n,"group")?n:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!1,renderingOnly:!0});if(o){this.onRightClick({...r,shape:o,target:"shape"});return}const i=this.editor.getSelectedShapeIds(),s=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((i.length>1||s&&!this.editor.getShapeUtil(s).hideSelectionBoundsBg(s))&&j9(this.editor,a)){this.onRightClick({...r,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:n}=this.editor.getCurrentPageState(),{shape:o}=r,i=this.editor.getOutermostSelectableShape(o,s=>!n.includes(s.id));!n.includes(i.id)&&!this.editor.findShapeAncestor(i,s=>n.includes(s.id))&&(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([i.id]));break}}}onCancel(){this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.markHistoryStoppingPoint("clearing selection"),this.editor.selectNone())}onKeyDown(r){switch(r.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if(Xt.editOnType.get()&&!R_t.includes(r.key)&&!r.altKey&&!r.ctrlKey){const n=this.editor.getOnlySelectedShape();if(n&&this.editor.isShapeOfType(n,"note")&&this.shouldStartEditingShape(n)){this.startEditingShape(n,{...r,target:"shape",shape:n},!0);return}}}onKeyRepeat(r){switch(r.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}}onKeyUp(r){switch(r.code){case"Enter":{const n=this.editor.getSelectedShapes();if(n.every(i=>this.editor.isShapeOfType(i,"group"))){this.editor.setSelectedShapes(n.flatMap(i=>this.editor.getSortedChildIdsForParent(i.id)));return}const o=this.editor.getOnlySelectedShape();if(o&&this.shouldStartEditingShape(o)){this.startEditingShape(o,{...r,target:"shape",shape:o},!0);return}R9(this.editor)&&this.parent.transition("crop",r);break}}}shouldStartEditingShape(r=this.editor.getOnlySelectedShape()){return!r||this.editor.isShapeOrAncestorLocked(r)&&r.type!=="embed"||!this.canInteractWithShapeInReadOnly(r)?!1:this.editor.getShapeUtil(r).canEdit(r)}startEditingShape(r,n,o){this.editor.isShapeOrAncestorLocked(r)&&r.type!=="embed"||(this.editor.markHistoryStoppingPoint("editing shape"),V0(this.editor,r,o),this.parent.transition("editing_shape",n))}isOverArrowLabelTest(r){if(!r)return!1;const n=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(r,"arrow")){const o=this.editor.getShapeGeometry(r).children[1];if(o&&ho(n,o.vertices))return!0}return!1}handleDoubleClickOnCanvas(r){if(this.editor.getInstanceState().isReadonly)return;this.editor.markHistoryStoppingPoint("creating text shape");const n=ot(),{x:o,y:i}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:n,type:"text",x:o,y:i,props:{text:"",autoSize:!0}}]);const s=this.editor.getShape(n);if(!s)return;const a=this.editor.getShapeUtil(s);this.editor.getInstanceState().isReadonly&&!a.canEditInReadOnly(s)||(this.editor.setEditingShape(n),this.editor.select(n),this.parent.transition("editing_shape",r))}nudgeSelectedShapes(r=!1){const{editor:{inputs:{keys:n}}}=this,o=n.has("ShiftLeft"),i=new w(0,0);if(n.has("ArrowLeft")&&(i.x-=1),n.has("ArrowRight")&&(i.x+=1),n.has("ArrowUp")&&(i.y-=1),n.has("ArrowDown")&&(i.y+=1),i.equals(new w(0,0)))return;r||this.editor.markHistoryStoppingPoint("nudge shapes");const{gridSize:s}=this.editor.getDocumentSettings(),a=this.editor.getInstanceState().isGridMode?o?s*N_t:s:o?D_t:L_t,l=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(l,i.mul(a)),pt(this.editor,l)}canInteractWithShapeInReadOnly(r){return!!(!this.editor.getInstanceState().isReadonly||this.editor.getShapeUtil(r).canEditInReadOnly(r))}},C(LC,"id","idle"),LC);const D_t=10,L_t=1,N_t=5;function j9(t,e){const r=t.getSelectionRotatedPageBounds();if(!r)return!1;const n=t.getSelectionRotation();return n?ho(e,r.corners.map(o=>w.RotWith(o,r.point,n))):r.containsPoint(e)}class mce extends he{constructor(){super(...arguments);C(this,"shapeId","");C(this,"markId","");C(this,"wasAlreadySelected",!1);C(this,"didDrag",!1);C(this,"info",{});C(this,"_labelDragOffset",new w(0,0))}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(r){const{shape:n}=r;this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.info=r,this.shapeId=n.id,this.didDrag=!1,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===n.id,this.updateCursor();const i=this.editor.getShapeGeometry(n).children[1];if(!i)throw Error(`Expected to find an arrow label geometry for shape: ${n.id}`);const{currentPagePoint:s}=this.editor.inputs,a=this.editor.getPointInShapeSpace(n,s);this._labelDragOffset=w.Sub(i.center,a),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){const{isDragging:r}=this.editor.inputs;if(!r)return;const n=this.editor.getShape(this.shapeId);if(!n)return;const o=es(this.editor,n),i=this.editor.getShapeGeometry(n),s=i.children[0],a=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),l=s.nearestPoint(w.Add(a,this._labelDragOffset));let c;if(o.isStraight){const u=w.Dist(o.start.point,o.end.point);c=1-w.Dist(o.end.point,l)/u}else{const{_center:u,measure:d,angleEnd:f,angleStart:p}=i.children[0];c=oT(d,p,f,u.angle(l))}isNaN(c)&&(c=.5),this.didDrag=!0,this.editor.updateShape({id:n.id,type:n.type,props:{labelPosition:c}})}onPointerUp(){const r=this.editor.getShape(this.shapeId);r&&(this.didDrag||!this.wasAlreadySelected?this.complete():(this.editor.setEditingShape(r.id),this.editor.setCurrentTool("select.editing_shape")))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}C(mce,"id","pointing_arrow_label");class vce extends he{onEnter(){const{inputs:e}=this.editor;e.shiftKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.markHistoryStoppingPoint("selecting none"),this.editor.selectNone())}onPointerMove(e){this.editor.inputs.isDragging&&this.parent.transition("brushing",e)}onPointerUp(){lx(this.editor),this.complete()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}C(vce,"id","pointing_canvas");class yce extends he{constructor(){super(...arguments);C(this,"info",{})}onEnter(r){this.info=r;const{shape:n}=r;if(this.editor.isShapeOfType(n,"arrow")){const o=Rn(this.editor,n)[r.handle.id];o&&this.editor.setHintingShapes([o.toId])}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){const{shape:r,handle:n}=this.info;if(this.editor.isShapeOfType(r,"note")){const{editor:o}=this,i=D9(o,r,n,!1);if(i){V0(o,i,!0);return}}this.parent.transition("idle",this.info)}onPointerMove(){const{editor:r}=this;r.inputs.isDragging&&this.startDraggingHandle()}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){const{editor:r}=this;if(r.getInstanceState().isReadonly)return;const{shape:n,handle:o}=this.info;if(r.isShapeOfType(n,"note")){const i=D9(r,n,o,!0);if(i){const s=r.getPointInParentSpace(i,r.inputs.originPagePoint).sub(w.Rot(Nb.clone().mul(n.props.scale),i.rotation));r.updateShape({...i,x:s.x,y:s.y}),r.setHoveredShape(i.id).select(i.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:r.getShape(i),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{V0(r,i,!0)}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}C(yce,"id","pointing_handle");function D9(t,e,r,n){const o=t.getShapePageTransform(e.id),i=o.point(),s=o.rotation(),l=Mle(t,i,s,e.props.growY,0,e.props.scale)[r.index];if(l)return jle(t,e,l,s,n)}class Sce extends he{constructor(){super(...arguments);C(this,"info",{})}updateCursor(){this.editor.setCursor({type:mh[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(r){this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.info=r,this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.editor.inputs.isDragging&&this.startRotating()}onLongPress(){this.startRotating()}startRotating(){this.editor.getInstanceState().isReadonly||this.parent.transition("rotating",this.info)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}C(Sce,"id","pointing_rotate_handle");class wce extends he{constructor(){super(...arguments);C(this,"info",{})}onEnter(r){this.info=r}onPointerUp(r){lx(this.editor),this.parent.transition("idle",r)}onPointerMove(r){this.editor.inputs.isDragging&&this.startTranslating(r)}onLongPress(r){this.startTranslating(r)}startTranslating(r){this.editor.getInstanceState().isReadonly||this.parent.transition("translating",r)}onDoubleClick(r){var i,s;const n=this.editor.getHoveredShape(),o=n&&!this.editor.isShapeOfType(n,"group")?n:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{hitInside:!0,margin:0,renderingOnly:!0});if(o){this.parent.transition("idle"),(s=(i=this.parent).onDoubleClick)==null||s.call(i,{...r,target:"shape",shape:this.editor.getShape(o)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}C(wce,"id","pointing_selection");class xce extends he{constructor(){super(...arguments);C(this,"hitShape",{});C(this,"hitShapeForPointerUp",{});C(this,"isDoubleClick",!1);C(this,"didSelectOnEnter",!1)}onEnter(r){const n=this.editor.getSelectedShapeIds(),o=this.editor.getSelectionRotatedPageBounds(),i=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:s,shiftKey:a,altKey:l}}=this.editor;this.hitShape=r.shape,this.isDoubleClick=!1;const c=this.editor.getOutermostSelectableShape(r.shape),u=this.editor.findShapeAncestor(c,d=>n.includes(d.id));if(this.editor.getShapeUtil(r.shape).onClick||c.id===i||n.includes(c.id)||u||n.length>1&&(o!=null&&o.containsPoint(s))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=c;return}this.didSelectOnEnter=!0,a&&!l?(this.editor.cancelDoubleClick(),n.includes(c.id)||(this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...n,c.id]))):(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([c.id]))}onPointerUp(r){var u;const n=this.editor.getSelectedShapeIds(),o=this.editor.getFocusedGroupId(),i=this.editor.getZoomLevel(),{inputs:{currentPagePoint:s,shiftKey:a}}=this.editor,l=this.editor.getShapeAtPoint(s,{margin:this.editor.options.hitTestMargin/i,hitInside:!0,renderingOnly:!0})??this.hitShape,c=l?this.editor.getOutermostSelectableShape(l):this.hitShapeForPointerUp;if(c){const d=this.editor.getShapeUtil(c);if(d.onClick){const f=(u=d.onClick)==null?void 0:u.call(d,c);if(f){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([f]),this.parent.transition("idle",r);return}}if(c.id===o){n.length>0?(this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",r);return}}if(!this.didSelectOnEnter){const d=this.editor.getOutermostSelectableShape(l,f=>!n.includes(f.id));if(n.includes(d.id))if(a)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(c);else if(n.includes(c.id)){if(n.length===1){const f=this.editor.getShapeUtil(c).getGeometry(c),p=pce(f),g=p.length===1?p[0]:void 0;if(g){const m=this.editor.getPointInShapeSpace(c,s);if(g.bounds.containsPoint(m,0)&&g.hitTestPoint(m)){this.editor.run(()=>{this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(c.id);const S=this.editor.getShapeUtil(c);this.editor.getInstanceState().isReadonly&&!S.canEditInReadOnly(c)||(this.editor.setEditingShape(c.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick&&this.editor.emit("select-all-text",{shapeId:c.id}))});return}}}this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(c.id)}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(c);else if(a){const f=this.editor.getShapeAncestors(d);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(p=>!f.find(g=>g.id===p)),d.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([d.id])}this.parent.transition("idle",r)}onDoubleClick(){this.isDoubleClick=!0}onPointerMove(r){this.editor.inputs.isDragging&&this.startTranslating(r)}onLongPress(r){this.startTranslating(r)}startTranslating(r){this.editor.getInstanceState().isReadonly||(this.editor.focus(),this.parent.transition("translating",r))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}C(xce,"id","pointing_shape");class bce extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"markId","");C(this,"didHoldCommand",!1);C(this,"creationCursorOffset",{x:0,y:0});C(this,"snapshot",{})}onEnter(r){const{isCreating:n=!1,creatingMarkId:o,creationCursorOffset:i={x:0,y:0}}=r;if(this.info=r,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.creationCursorOffset=i,this.snapshot=this._createSnapshot(),this.markId="",n)if(o)this.markId=o;else{const s=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);s&&(this.markId=s)}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");n&&this.editor.setCursor({type:"cross",rotation:0}),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:r}){const{editor:n}=this;n.edgeScrollManager.updateEdgeScrolling(r)}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}complete(){var r,n;if(pt(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(n=(r=this.info).onCreate)==null||n.call(r,this.editor.getOnlySelectedShape());return}if(this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd){this.editor.setCurrentTool(this.info.onInteractionEnd,{});return}this.parent.transition("idle")}handleResizeStart(){const{shapeSnapshots:r}=this.snapshot,n=[];r.forEach(({shape:o})=>{var a;const i=this.editor.getShapeUtil(o),s=(a=i.onResizeStart)==null?void 0:a.call(i,o);s&&n.push(s)}),n.length>0&&this.editor.updateShapes(n)}handleResizeEnd(){const{shapeSnapshots:r}=this.snapshot,n=[];r.forEach(({shape:o})=>{var l;const i=this.editor.getShape(o.id),s=this.editor.getShapeUtil(o),a=(l=s.onResizeEnd)==null?void 0:l.call(s,o,i);a&&n.push(a)}),n.length>0&&this.editor.updateShapes(n)}updateShapes(){const{altKey:r,shiftKey:n}=this.editor.inputs,{frames:o,shapeSnapshots:i,selectionBounds:s,cursorHandleOffset:a,selectedShapeIds:l,selectionRotation:c,canShapesDeform:u}=this.snapshot;let d=n||!u;if(i.size===1){const I=[...i.values()][0];this.editor.isShapeOfType(I.shape,"text")&&(d=!(this.info.handle==="left"||this.info.handle==="right"))}const{ctrlKey:f}=this.editor.inputs,p=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),g=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!f){const{gridSize:I}=this.editor.getDocumentSettings();p.snapToGrid(I)}const m=this.info.handle,S=L9(m,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!f:f)&&c%vt===0){const{nudge:I}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:w.Sub(p,g),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:L9(m,c),isAspectRatioLocked:d,isResizingFromCenter:r});p.add(I)}const v=w.RotWith(r?s.center:s.getHandlePoint(S),s.point,c),b=w.Sub(p,v).rot(-c),$=w.Sub(g,v).rot(-c),P=w.DivV(b,$);Number.isFinite(P.x)||(P.x=1),Number.isFinite(P.y)||(P.y=1);const E=m==="top"||m==="bottom",T=m==="left"||m==="right";d?T?P.y=Math.abs(P.x):E?P.x=Math.abs(P.y):Math.abs(P.x)>Math.abs(P.y)?P.y=Math.abs(P.x)*(P.y<0?-1:1):P.x=Math.abs(P.y)*(P.x<0?-1:1):(E&&(P.x=1),T&&(P.y=1)),this.info.isCreating||this.updateCursor({dragHandle:m,isFlippedX:P.x<0,isFlippedY:P.y<0,rotation:c});for(const I of i.keys()){const _=i.get(I);this.editor.resizeShape(I,P,{initialShape:_.shape,initialBounds:_.bounds,initialPageTransform:_.pageTransform,dragHandle:m,mode:l.length===1&&I===l[0]?"resize_bounds":"scale_shape",scaleOrigin:v,isAspectRatioLocked:d,scaleAxisRotation:c,skipStartAndEndCallbacks:!0})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:I,children:_}of o){if(!_.length)continue;const k=i.get(I).shape,D=this.editor.getShape(I);if(!(k&&D))continue;const R=D.x-k.x,j=D.y-k.y,M=new w(R,j).rot(-k.rotation);if(M.x!==0||M.y!==0)for(const U of _)this.editor.updateShape({id:U.id,type:U.type,x:U.x-M.x,y:U.y-M.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:I}of o)if(I.length)for(const _ of I)this.editor.updateShape({id:_.id,type:_.type,x:_.x,y:_.y})}}updateCursor({dragHandle:r,isFlippedX:n,isFlippedY:o,rotation:i}){const s={...this.editor.getInstanceState().cursor};switch(r){case"top_left":case"bottom_right":{s.type="nwse-resize",n!==o&&(s.type="nesw-resize");break}case"top_right":case"bottom_left":{s.type="nesw-resize",n!==o&&(s.type="nwse-resize");break}}s.rotation=i,this.editor.setCursor(s)}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()}_createSnapshot(){const r=this.editor.getSelectedShapeIds(),n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:o}}=this.editor,i=this.editor.getSelectionRotatedPageBounds(),s=w.RotWith(i.getHandlePoint(this.info.handle),i.point,n),a=w.Sub(o,s),l=new Map,c=[];r.forEach(d=>{const f=this.editor.getShape(d);if(f){if(f.type==="frame"&&c.push({id:d,children:Ae(this.editor.getSortedChildIdsForParent(f).map(p=>this.editor.getShape(p)))}),l.set(f.id,this._createShapeSnapshot(f)),this.editor.isShapeOfType(f,"frame")&&r.length===1)return;this.editor.visitDescendants(f.id,p=>{const g=this.editor.getShape(p);if(g&&(l.set(g.id,this._createShapeSnapshot(g)),this.editor.isShapeOfType(g,"frame")))return!1})}});const u=![...l.values()].some(d=>!yV(d.pageRotation,n)||d.isAspectRatioLocked);return{shapeSnapshots:l,selectionBounds:i,cursorHandleOffset:a,selectionRotation:n,selectedShapeIds:r,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:c}}_createShapeSnapshot(r){const n=this.editor.getShapePageTransform(r),o=this.editor.getShapeUtil(r);return{shape:r,bounds:this.editor.getShapeGeometry(r).bounds,pageTransform:n,pageRotation:Q.Decompose(n).rotation,isAspectRatioLocked:o.isAspectRatioLocked(r)}}}C(bce,"id","resizing");const hC=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function L9(t,e){e=e%rt;const r=Math.round(e/(Ze/4)),n=hC.indexOf(t);return hC[(n+r)%hC.length]}const N9=Math.PI/180;class $ce extends he{constructor(){super(...arguments);C(this,"snapshot",{});C(this,"info",{});C(this,"markId","")}onEnter(r){this.info=r,this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("rotate start");const n=Gre({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!n)return this.parent.transition("idle",this.info);this.snapshot=n;const o=this._getRotationFromPointerPosition({snapToNearestDegree:!1});FS({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:mh[this.info.handle],rotation:o+this.snapshot.initialShapesRotation})}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}update(){const r=this._getRotationFromPointerPosition({snapToNearestDegree:!1});FS({editor:this.editor,delta:r,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:mh[this.info.handle],rotation:r+this.snapshot.initialShapesRotation})}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}complete(){FS({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),pt(this.editor,this.snapshot.shapeSnapshots.map(r=>r.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:r}){const n=this.editor.getSelectionRotation(),o=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:i,currentPagePoint:s}}=this.editor,{initialCursorAngle:a,initialShapesRotation:l}=this.snapshot;if(!o)return l;const u=o.center.clone().rotWith(o.point,n).angle(s)-a;let d=l+u;if(i)d=a0(d,24);else if(r&&(d=Math.round(d/N9)*N9,this.editor.getInstanceState().isCoarsePointer)){const f=a0(d,4),p=xS(d,f);Math.abs(p)<s$e(5)&&(d=f)}return d-l}}C($ce,"id","rotating");class Ice extends he{constructor(){super(...arguments);C(this,"hits",new Set);C(this,"size",0);C(this,"scribbleId","id");C(this,"initialSelectedShapeIds",new Set);C(this,"newlySelectedShapeIds",new Set)}onEnter(){this.initialSelectedShapeIds=new Set(this.editor.inputs.shiftKey?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();const r=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=r.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.updateScribbleSelection(!0)}onPointerUp(){this.complete()}onKeyDown(){this.updateScribbleSelection(!1)}onKeyUp(){this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")}onCancel(){this.cancel()}onComplete(){this.complete()}pushPointToScribble(){const{x:r,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,r,n)}updateScribbleSelection(r){const{editor:n}=this,o=this.editor.getCurrentPageShapes(),{inputs:{shiftKey:i,originPagePoint:s,previousPagePoint:a,currentPagePoint:l}}=this.editor,{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;r&&this.pushPointToScribble();const d=o;let f,p,g,m;const S=0;for(let b=0,$=d.length;b<$;b++){if(f=d[b],n.isShapeOfType(f,"group")||c.has(f.id)||n.isShapeOrAncestorLocked(f)||(p=n.getShapeGeometry(f),n.isShapeOfType(f,"frame")&&p.bounds.containsPoint(n.getPointInShapeSpace(f,s))))continue;const P=n.getShapePageTransform(f);if(!p||!P)continue;const E=P.clone().invert();g=E.applyToPoint(a),m=E.applyToPoint(l);const{bounds:T}=p;if(!(T.minX-S>Math.max(g.x,m.x)||T.minY-S>Math.max(g.y,m.y)||T.maxX+S<Math.min(g.x,m.x)||T.maxY+S<Math.min(g.y,m.y))&&p.hitTestLineSegment(g,m,S)){const I=this.editor.getOutermostSelectableShape(f),_=this.editor.getShapeMask(I.id);if(_&&vO(a,l,_)!==null&&!ho(l,_))continue;c.add(I.id)}}const y=n.getSelectedShapeIds(),v=new Set(i?[...c,...u]:[...c]);(y.length!==v.size||y.some(b=>!v.has(b)))&&this.editor.setSelectedShapes(Array.from(v))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}C(Ice,"id","scribble_brushing");var F_t=Object.create,Pce=Object.defineProperty,B_t=Object.getOwnPropertyDescriptor,U_t=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ece=t=>{throw TypeError(t)},Cce=(t,e,r)=>e in t?Pce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,z_t=t=>[,,,F_t(null)],_ce=["class","method","getter","setter","accessor","field","value","get","set"],Tce=t=>t!==void 0&&typeof t!="function"?Ece("Function expected"):t,H_t=(t,e,r,n,o)=>({kind:_ce[t],name:e,metadata:n,addInitializer:i=>r._?Ece("Already initialized"):o.push(Tce(i||null))}),W_t=(t,e)=>Cce(e,U_t("metadata"),t[3]),K_t=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},G_t=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=_ce[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,B_t(o,r)),y=n.length-1;y>=0;y--)l=H_t(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,Tce(s)&&(S[g]=s);return S&&Pce(o,r,S),o},fC=(t,e,r)=>Cce(t,typeof e!="symbol"?e+"":e,r),Ace,Hb;const V_t=20,Y_t=100;Ace=[lo];class Jj{constructor(e){this.editor=e,K_t(Hb,5,this),fC(this,"prevDroppingShapeId",null),fC(this,"droppingNodeTimer",null),fC(this,"first",!0),e.disposables.add(this.dispose)}updateDroppingNode(e,r){var n;this.first&&(this.editor.setHintingShapes(e.map(o=>this.editor.findShapeAncestor(o,i=>i.type!=="group")).filter(o=>o)),this.prevDroppingShapeId=((n=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,e))==null?void 0:n.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(e,V_t,r):this.editor.inputs.pointerVelocity.len()>.5&&(clearTimeout(this.droppingNodeTimer),this.setDragTimer(e,Y_t,r))}setDragTimer(e,r,n){this.droppingNodeTimer=this.editor.timers.setTimeout(()=>{this.editor.run(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,e,n)}),this.droppingNodeTimer=null},r)}handleDrag(e,r,n){var l,c,u,d,f;r=Ae(r.map(p=>this.editor.getShape(p.id)));const o=((l=this.editor.getDroppingOverShape(e,r))==null?void 0:l.id)??null;if(o===this.prevDroppingShapeId){this.hintParents(r);return}const{prevDroppingShapeId:i}=this,s=i&&this.editor.getShape(i),a=o&&this.editor.getShape(o);s&&((u=(c=this.editor.getShapeUtil(s)).onDragShapesOut)==null||u.call(c,s,r)),a&&((f=(d=this.editor.getShapeUtil(a)).onDragShapesOver)==null||f.call(d,a,r)),this.hintParents(r),n==null||n(),this.prevDroppingShapeId=o}hintParents(e){const r=new Map;for(const o of e){const i=this.editor.findShapeAncestor(o,s=>s.type!=="group");i&&(r.has(i.id)||r.set(i.id,[]),r.get(i.id).push(o.id))}const n=[];for(const[o,i]of r){const s=this.editor.getShape(o);s&&Tie(this.editor,s).length<i.length&&n.push(s.id)}this.editor.setHintingShapes(n)}dropShapes(e){var n,o;const{prevDroppingShapeId:r}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,e),r){const i=this.editor.getShape(r);if(!i)return;(o=(n=this.editor.getShapeUtil(i)).onDropShapesOver)==null||o.call(n,i,e)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearTimeout(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}dispose(){this.clear()}}Hb=z_t();G_t(Hb,1,"dispose",Ace,Jj);W_t(Hb,Jj);var X_t=Object.create,kce=Object.defineProperty,q_t=Object.getOwnPropertyDescriptor,Oce=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Mce=t=>{throw TypeError(t)},Rce=(t,e,r)=>e in t?kce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Z_t=t=>[,,,X_t((t==null?void 0:t[Oce("metadata")])??null)],jce=["class","method","getter","setter","accessor","field","value","get","set"],Dce=t=>t!==void 0&&typeof t!="function"?Mce("Function expected"):t,Q_t=(t,e,r,n,o)=>({kind:jce[t],name:e,metadata:n,addInitializer:i=>r._?Mce("Already initialized"):o.push(Dce(i||null))}),J_t=(t,e)=>Rce(e,Oce("metadata"),t[3]),eTt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},tTt=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=jce[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,q_t(o,r)),y=n.length-1;y>=0;y--)l=Q_t(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,Dce(s)&&(S[g]=s);return S&&kce(o,r,S),o},La=(t,e,r)=>Rce(t,typeof e!="symbol"?e+"":e,r),Lce,mA,Wb;class Kb extends(mA=he,Lce=[lo],mA){constructor(){super(...arguments),eTt(Wb,5,this),La(this,"info",{}),La(this,"selectionSnapshot",{}),La(this,"snapshot",{}),La(this,"markId",""),La(this,"isCloning",!1),La(this,"isCreating",!1),La(this,"dragAndDropManager",new Jj(this.editor))}onCreate(e){}onEnter(e){var i;const{isCreating:r=!1,creatingMarkId:n,onCreate:o=()=>{}}=e;if(!((i=this.editor.getSelectedShapeIds())!=null&&i.length)){this.parent.transition("idle");return}if(this.info=e,this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.isCreating=r,this.markId="",r)if(n)this.markId=n;else{const s=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);s&&(this.markId=s)}else this.markId=this.editor.markHistoryStoppingPoint("translating");if(this.onCreate=o,this.isCloning=!1,this.info=e,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=F9(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()}onTick({elapsed:e}){const{editor:r}=this;this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),r.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()}onKeyUp(){if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}startCloning(){this.isCreating||(this.isCloning=!0,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate cloning"),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=F9(this.editor),this.handleStart(),this.updateShapes())}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate"),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){var e;this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),pt(this.editor,this.snapshot.movingShapes.map(r=>r.id)),this.handleEnd(),this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.isCreating?(e=this.onCreate)==null||e.call(this,this.editor.getOnlySelectedShape()):this.parent.transition("idle")}cancel(){this.reset(),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.parent.transition("idle",this.info)}handleStart(){const{movingShapes:e}=this.snapshot,r=[];e.forEach(n=>{var s;const o=this.editor.getShapeUtil(n),i=(s=o.onTranslateStart)==null?void 0:s.call(o,n);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){const n=w.Average(e.map(i=>this.editor.getShapePageTransform(i.id).point())),o=w.Sub(n,this.selectionSnapshot.averagePagePoint);w.IsNaN(o)||this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map(i=>i.id),offset:{x:o.x,y:o.y}}})}const r=[];e.forEach(n=>{var a;const o=this.editor.getShape(n.id),i=this.editor.getShapeUtil(n),s=(a=i.onTranslateEnd)==null?void 0:a.call(i,n,o);s&&r.push(s)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{snapshot:e}=this;this.dragAndDropManager.updateDroppingNode(e.movingShapes,this.updateParentTransforms),rTt({editor:this.editor,snapshot:e});const{movingShapes:r}=e,n=[];r.forEach(o=>{var l;const i=this.editor.getShape(o.id),s=this.editor.getShapeUtil(o),a=(l=s.onTranslate)==null?void 0:l.call(s,o,i);a&&n.push(a)}),n.length>0&&this.editor.updateShapes(n)}updateParentTransforms(){const{editor:e,snapshot:{shapeSnapshots:r}}=this;r.forEach(n=>{const o=e.getShape(n.shape.id);if(!o)return null;const i=En(o.parentId)?null:Q.Inverse(e.getShapePageTransform(o.parentId));n.parentTransform=i})}}Wb=Z_t(mA);tTt(Wb,1,"updateParentTransforms",Lce,Kb);J_t(Wb,Kb);La(Kb,"id","translating");function F9(t){var d;const e=[],r=[],n=t.getSelectedShapeIds(),o=Ae(n.map(f=>{const p=t.getShape(f);if(!p)return null;e.push(p);const g=t.getShapePageTransform(f),m=g.point(),S=g.rotation();r.push(m);const y=vo.isId(p.parentId)?null:Q.Inverse(t.getShapePageTransform(p.parentId));return{shape:p,pagePoint:m,pageRotation:S,parentTransform:y}})),i=t.getOnlySelectedShape();let s=[];if(i)s=t.snaps.shapeBounds.getSnapPoints(i.id);else{const f=t.getSelectionPageBounds();f&&(s=f.cornersAndCenter.map((p,g)=>({id:"selection:"+g,x:p.x,y:p.y})))}let a,l;const{originPagePoint:c}=t.inputs,u=o.filter(f=>t.isShapeOfType(f.shape,"note")&&t.isPointInShape(f.shape,c));if(u.length!==0)if(u.length===1)l=u[0];else{const f=t.getCurrentPageShapesSorted();l=(d=u.map(p=>({snapshot:p,index:f.findIndex(g=>g.id===p.shape.id)})).sort((p,g)=>g.index-p.index)[0])==null?void 0:d.snapshot}return l&&(a=Rle(t,l.pageRotation,l.shape.props.scale,l.shape.props.growY??0)),{averagePagePoint:w.Average(r),movingShapes:e,shapeSnapshots:o,initialPageBounds:t.getSelectionPageBounds(),initialSnapPoints:s,noteAdjacentPositions:a,noteSnapshot:l}}function rTt({editor:t,snapshot:e}){const{inputs:r}=t,{noteSnapshot:n,noteAdjacentPositions:o,initialPageBounds:i,initialSnapPoints:s,shapeSnapshots:a,averagePagePoint:l}=e,c=t.getInstanceState().isGridMode,u=t.getDocumentSettings().gridSize,d=w.Sub(r.currentPagePoint,r.originPagePoint),f=t.inputs.shiftKey?Math.abs(d.x)<Math.abs(d.y)?"x":"y":null;if(f==="x"?d.x=0:f==="y"&&(d.y=0),t.snaps.clearIndicators(),(t.user.getIsSnapMode()?!r.ctrlKey:r.ctrlKey)&&t.inputs.pointerVelocity.len()<.5){const{nudge:S}=t.snaps.shapeBounds.snapTranslateShapes({dragDelta:d,initialSelectionPageBounds:i,lockedAxis:f,initialSelectionSnapPoints:s});d.add(S)}else if(n&&o){const{scale:S}=n.shape.props,y=n.pagePoint.clone().add(d).add(Nb.clone().mul(S).rot(n.pageRotation));let v=Ole/t.getZoomLevel(),b=new w(0,0);for(const $ of o){const P=w.Sub(y,$),E=P.len();E<v&&(v=E,b=P)}d.sub(b)}const g=w.Add(l,d);c&&!r.ctrlKey&&g.snapToGrid(u);const m=w.Sub(g,l);t.updateShapes(Ae(a.map(({shape:S,pagePoint:y,parentTransform:v})=>{const b=w.Add(y,m),$=v?Q.applyToPoint(v,b):b;return{id:S.id,type:S.type,x:$.x,y:$.y}})))}class uw extends he{constructor(){super(...arguments);C(this,"reactor")}static children(){return[gA,Zj,j_t,vce,xce,Kb,ace,Ice,Qj,wce,lce,gce,bce,$ce,Sce,mce,yce,fce]}cleanUpDuplicateProps(){const r=this.editor.getSelectedShapeIds(),n=this.editor.getInstanceState();if(!n.duplicateProps)return;const o=new Set(n.duplicateProps.shapeIds);r.length===o.size&&r.every(i=>o.has(i))||this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=Sl("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(r){typeof process<"u",console.error(r)}})}onExit(){var r;(r=this.reactor)==null||r.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)}}C(uw,"id","select"),C(uw,"initial","idle"),C(uw,"isLockable",!1);class Nce extends he{constructor(){super(...arguments);C(this,"info",{})}onEnter(r){this.info=r}onPointerDown(){this.parent.transition("pointing",this.info)}}C(Nce,"id","idle");class Fce extends he{constructor(){super(...arguments);C(this,"info",{})}onEnter(r){this.info=r}onPointerUp(){this.complete()}onPointerMove(){this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){const{currentScreenPoint:r}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(r,{animation:{duration:220}}):this.editor.zoomIn(r,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}C(Fce,"id","pointing");class Bce extends he{constructor(){super(...arguments);C(this,"info",{});C(this,"zoomBrush",new ee)}onEnter(r){this.info=r,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){const{inputs:{originPagePoint:r,currentPagePoint:n}}=this.editor;this.zoomBrush.setTo(ee.FromPoints([r,n])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:r}=this,n=8/this.editor.getZoomLevel();if(r.width<n&&r.height<n){const o=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(o,{animation:{duration:220}}):this.editor.zoomIn(o,{animation:{duration:220}})}else{const o=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(r,{targetZoom:o,animation:{duration:220}})}this.parent.transition("idle",this.info)}}C(Bce,"id","zoom_brushing");class dw extends he{constructor(){super(...arguments);C(this,"info",{})}static children(){return[Nce,Bce,Fce]}onEnter(r){this.info=r,this.parent.setCurrentToolIdMask(r.onInteractionEnd),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}}),this.parent.setCurrentToolIdMask(void 0)}onKeyDown(){this.updateCursor()}onKeyUp(r){this.updateCursor(),r.code==="KeyZ"&&this.complete()}onInterrupt(){this.complete()}complete(){this.info.onInteractionEnd&&this.info.onInteractionEnd!=="select"?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("select")}updateCursor(){this.editor.inputs.altKey?this.editor.setCursor({type:"zoom-out",rotation:0}):this.editor.setCursor({type:"zoom-in",rotation:0})}}C(dw,"id","zoom"),C(dw,"initial","idle"),C(dw,"isLockable",!1);const nTt=[lw,pA,cw,dw,uw],oTt=({id:t,component:e,onClose:r})=>{const{removeDialog:n}=mu(),o=Sr(),i=x.useCallback(s=>{if(!s){if(r)try{r()}catch(a){console.warn(a)}n(t)}},[t,r,n]);return h.jsx(E1t,{onOpenChange:i,defaultOpen:!0,children:h.jsx(C1t,{container:o,children:h.jsx(_1t,{dir:"ltr",className:"tlui-dialog__overlay",onClick:s=>{s.target===s.currentTarget&&i(!1)},children:h.jsx(T1t,{dir:"ltr",className:"tlui-dialog__content",children:h.jsx(e,{onClose:()=>i(!1)})})})})})};function iTt(){const{dialogs:t}=mu();return t.map(e=>h.jsx(oTt,{...e},e.id))}const sTt=ze.memo(iTt);function aTt(){const t=F(),e=H("follow",()=>t.getInstanceState().followingUserId,[t]);return e?h.jsx(lTt,{userId:e}):null}function lTt({userId:t}){const e=qx(t);return e?h.jsx("div",{className:"tlui-following-indicator",style:{borderColor:e.color}}):null}const cTt={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function uTt({toast:t}){const{removeToast:e}=ji(),r=Fe(),n=s=>{s||e(t.id)},o=t.actions&&t.actions.length>0,i=t.icon||t.severity&&cTt[t.severity];return h.jsxs(Gbt,{onOpenChange:n,className:"tlui-toast__container",duration:t.keepOpen?1/0:5e3,"data-severity":t.severity,children:[i&&h.jsx("div",{className:"tlui-toast__icon",children:h.jsx(ds,{icon:i})}),h.jsxs("div",{className:"tlui-toast__main",children:[h.jsxs("div",{className:"tlui-toast__content",children:[t.title&&h.jsx(Vbt,{className:"tlui-toast__title",children:t.title}),t.description&&h.jsx(Ybt,{className:"tlui-toast__description",children:t.description})]}),t.actions&&h.jsxs("div",{className:"tlui-toast__actions",children:[t.actions.map((s,a)=>h.jsx(Xbt,{altText:s.label,asChild:!0,onClick:s.onClick,children:h.jsx(me,{type:s.type,children:h.jsx(qt,{children:s.label})})},a)),h.jsx(K7,{asChild:!0,children:h.jsx(me,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:h.jsx(qt,{children:t.closeLabel??r("toast.close")})})})]})]}),!o&&h.jsx(K7,{asChild:!0,children:h.jsx(me,{type:"normal",className:"tlui-toast__close",children:h.jsx(qt,{children:t.closeLabel??r("toast.close")})})})]})}function dTt(){const{toasts:t}=ji();return t.map(e=>h.jsx(uTt,{toast:e},e.id))}const hTt=x.memo(dTt);function fTt(){const t=F(),{toasts:e}=ji(),[r,n]=x.useState(!1);return x.useEffect(()=>{let o=-1;return e.length?n(!0):o=t.timers.setTimeout(()=>{n(!1)},1e3),()=>{clearTimeout(o)}},[e.length,n,t]),r?h.jsx(wse,{className:"tlui-toast__viewport"}):null}let vA={fonts:{draw:`${tl()}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`${tl()}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`${tl()}/fonts/IBMPlexSans-Medium.woff2`,monospace:`${tl()}/fonts/IBMPlexMono-Medium.woff2`}};function Uce(t){return x.useMemo(()=>t?{fonts:{...vA.fonts,...t==null?void 0:t.fonts}}:vA,[t])}const pTt=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bring-forward","bring-to-front","broken","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","color","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","leading","link","lock","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];let Wf={...vA,icons:Object.fromEntries(pTt.map(t=>[t,`${tl()}/icons/icon/0_merged.svg#${t}`])),translations:Object.fromEntries(vg.map(t=>[t.locale,`${tl()}/translations/${t.locale}.json`])),embedIcons:Object.fromEntries(uj.map(t=>[t.type,`${tl()}/embed-icons/${t.type}.png`]))};function gTt(t){return t?{fonts:Object.assign({...Wf.fonts},{...t==null?void 0:t.fonts}),icons:Object.assign({...Wf.icons},{...t==null?void 0:t.icons}),embedIcons:Object.assign({...Wf.embedIcons},{...t==null?void 0:t.embedIcons}),translations:Object.assign({...Wf.translations},{...t==null?void 0:t.translations})}:Wf}function mTt(){const{addToast:t,removeToast:e,clearToasts:r}=ji(),{addDialog:n,clearDialogs:o,removeDialog:i,updateDialog:s}=mu(),l=bn()<Kt.TABLET_SM,c=Fe();return x.useMemo(()=>({addToast:t,removeToast:e,clearToasts:r,addDialog:n,clearDialogs:o,removeDialog:i,updateDialog:s,msg:c,isMobile:l}),[n,t,o,r,c,i,e,s,l])}function vTt(t,e){const r={};for(const n of t)if(n.translations)for(const[o,i]of Hn(n.translations)){let s=r[o];s||(s=r[o]={}),Object.assign(s,i)}return{actions:(n,o)=>{for(const i of t)i.actions&&(o=i.actions(n,o,e));return o},tools:(n,o,i)=>{for(const s of t)s.tools&&(o=s.tools(n,o,{...e,...i}));return o},translations:r}}function zce(t){return x.useMemo(()=>t,t)}function yTt(t){const e=zce(t==null?[]:Array.isArray(t)?t:[t]);return x.useMemo(()=>{const r={};for(const n of e)if(n.translations)for(const[o,i]of Hn(n.translations)){let s=r[o];s||(s=r[o]={}),Object.assign(s,i)}return r},[e])}function STt(t){const e=mTt(),r=zce(t==null?[]:Array.isArray(t)?t:[t]);return x.useMemo(()=>vTt(r,e),[r,e])}var eD="Popover",[Hce,XOt]=$s(eD,[Ab]),zm=Ab(),[wTt,Yl]=Hce(eD),Wce=t=>{const{__scopePopover:e,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!1}=t,a=zm(e),l=x.useRef(null),[c,u]=x.useState(!1),[d=!1,f]=Gl({prop:n,defaultProp:o,onChange:i});return h.jsx(Ej,{...a,children:h.jsx(wTt,{scope:e,contentId:Qs(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:x.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:x.useCallback(()=>u(!0),[]),onCustomAnchorRemove:x.useCallback(()=>u(!1),[]),modal:s,children:r})})};Wce.displayName=eD;var Kce="PopoverAnchor",xTt=x.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Yl(Kce,r),i=zm(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return x.useEffect(()=>(s(),()=>a()),[s,a]),h.jsx(Cj,{...i,...n,ref:e})});xTt.displayName=Kce;var Gce="PopoverTrigger",Vce=x.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Yl(Gce,r),i=zm(r),s=yt(e,o.triggerRef),a=h.jsx(Ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Qce(o.open),...n,ref:s,onClick:ue(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:h.jsx(Cj,{asChild:!0,...i,children:a})});Vce.displayName=Gce;var tD="PopoverPortal",[bTt,$Tt]=Hce(tD,{forceMount:void 0}),Yce=t=>{const{__scopePopover:e,forceMount:r,children:n,container:o}=t,i=Yl(tD,e);return h.jsx(bTt,{scope:e,forceMount:r,children:h.jsx(Mi,{present:r||i.open,children:h.jsx(Lm,{asChild:!0,container:o,children:n})})})};Yce.displayName=tD;var vh="PopoverContent",Xce=x.forwardRef((t,e)=>{const r=$Tt(vh,t.__scopePopover),{forceMount:n=r.forceMount,...o}=t,i=Yl(vh,t.__scopePopover);return h.jsx(Mi,{present:n||i.open,children:i.modal?h.jsx(ITt,{...o,ref:e}):h.jsx(PTt,{...o,ref:e})})});Xce.displayName=vh;var ITt=x.forwardRef((t,e)=>{const r=Yl(vh,t.__scopePopover),n=x.useRef(null),o=yt(e,n),i=x.useRef(!1);return x.useEffect(()=>{const s=n.current;if(s)return oj(s)},[]),h.jsx(Sb,{as:Kc,allowPinchZoom:!0,children:h.jsx(qce,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ue(t.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ue(t.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ue(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),PTt=x.forwardRef((t,e)=>{const r=Yl(vh,t.__scopePopover),n=x.useRef(!1),o=x.useRef(!1);return h.jsx(qce,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=t.onCloseAutoFocus)==null||s.call(t,i),i.defaultPrevented||(n.current||(a=r.triggerRef.current)==null||a.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=t.onInteractOutside)==null||l.call(t,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=r.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),qce=x.forwardRef((t,e)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=t,f=Yl(vh,r),p=zm(r);return nj(),h.jsx(vb,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:h.jsx(Dm,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:h.jsx(tae,{"data-state":Qce(f.open),role:"dialog",id:f.contentId,...p,...d,ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Zce="PopoverClose",ETt=x.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Yl(Zce,r);return h.jsx(Ye.button,{type:"button",...n,ref:e,onClick:ue(t.onClick,()=>o.onOpenChange(!1))})});ETt.displayName=Zce;var CTt="PopoverArrow",_Tt=x.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=zm(r);return h.jsx(rae,{...o,...n,ref:e})});_Tt.displayName=CTt;function Qce(t){return t?"open":"closed"}var rD=Wce,nD=Vce,oD=Yce,iD=Xce;function sD({id:t,children:e,onOpenChange:r,open:n}){const[o,i]=ba(t,r);return h.jsx(rD,{onOpenChange:i,open:n||o,children:h.jsx("div",{className:"tlui-popover",children:e})})}function aD({children:t}){return h.jsx(nD,{asChild:!0,dir:"ltr",children:t})}function lD({side:t,children:e,align:r="center",sideOffset:n=8,alignOffset:o=0,disableEscapeKeyDown:i=!1}){const s=Sr();return h.jsx(oD,{container:s,children:h.jsx(iD,{className:"tlui-popover__content",side:t,sideOffset:n,align:r,alignOffset:o,dir:"ltr",onEscapeKeyDown:a=>i&&a.preventDefault(),children:e})})}function TTt(t){return t.getSelectedShapeIds().map(n=>t.getShape(n)).filter(n=>{if(!n)return!1;if(t.isShapeOfType(n,"arrow")){const o=Rn(t,n);if(o.start||o.end)return!1}return!0})}const Jce=()=>{const t=F();return H("threeStackableItems",()=>TTt(t).length>2,[t])},$a=()=>{const t=F();return H("isInSelectState",()=>t.isIn("select"),[t])},eue=()=>{const t=F();return H("allow group",()=>{const e=t.getSelectedShapes();if(e.length<2)return!1;for(const r of e)if(t.isShapeOfType(r,"arrow")){const n=Rn(t,r);if(n.start&&!e.some(o=>o.id===n.start.toId)||n.end&&!e.some(o=>o.id===n.end.toId))return!1}return!0},[t])},tue=()=>{const t=F();return H("allowUngroup",()=>t.getSelectedShapeIds().some(e=>{var r;return((r=t.getShape(e))==null?void 0:r.type)==="group"}),[t])},ATt=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function rue(t,e){const r=F();return H("selectedShapes",()=>r.getSelectedShapes().length>=t,[r,t,e])}function $n(t,e){const r=F();return H("selectedShapes",()=>{const n=r.getSelectedShapes().filter(o=>!r.isShapeOrAncestorLocked(o)).length;return t===void 0?n:n>=t},[r])}function kTt(){const t=F();return H("showAutoSizeToggle",()=>{const e=t.getSelectedShapes();return e.length===1&&t.isShapeOfType(e[0],"text")&&e[0].props.autoSize===!1},[t])}function nue(){const t=F();return H("hasLinkShapeSelected",()=>{const e=t.getOnlySelectedShape();return!!(e&&e.type!=="embed"&&"url"in e.props&&!e.isLocked)},[t])}function OTt(){const t=F();return H("onlyFlippableShape",()=>{const e=t.getOnlySelectedShape();return e&&(t.isShapeOfType(e,"group")||t.isShapeOfType(e,"image")||t.isShapeOfType(e,"arrow")||t.isShapeOfType(e,"line")||t.isShapeOfType(e,"draw"))},[t])}function oue(){const t=F();return H("useCanRedo",()=>t.getCanRedo(),[t])}function iue(){const t=F();return H("useCanUndo",()=>t.getCanUndo(),[t])}function MTt(){return h.jsxs(h.Fragment,{children:[h.jsx(RTt,{}),h.jsx(jTt,{}),h.jsx(DTt,{}),h.jsx(LTt,{}),h.jsx(NTt,{}),h.jsx(UTt,{}),h.jsx(zTt,{}),h.jsx(HTt,{})]})}function RTt(){const t=$n(2),e=$a(),r=t&&e;return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"align-left",disabled:!r}),h.jsx(G,{actionId:"align-center-horizontal",disabled:!r}),h.jsx(G,{actionId:"align-right",disabled:!r}),h.jsx(G,{actionId:"stretch-horizontal",disabled:!r}),h.jsx(G,{actionId:"align-top",disabled:!r}),h.jsx(G,{actionId:"align-center-vertical",disabled:!r}),h.jsx(G,{actionId:"align-bottom",disabled:!r}),h.jsx(G,{actionId:"stretch-vertical",disabled:!r})]})}function jTt(){const t=$n(3),e=$a(),r=t&&e;return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"distribute-horizontal",disabled:!r}),h.jsx(G,{actionId:"distribute-vertical",disabled:!r})]})}function DTt(){const t=Jce(),e=$a(),r=t&&e;return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"stack-horizontal",disabled:!r}),h.jsx(G,{actionId:"stack-vertical",disabled:!r})]})}function LTt(){const t=$n(1),e=$a(),r=t&&e;return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"send-to-back",disabled:!r}),h.jsx(G,{actionId:"send-backward",disabled:!r}),h.jsx(G,{actionId:"bring-forward",disabled:!r}),h.jsx(G,{actionId:"bring-to-front",disabled:!r})]})}function NTt(){return bn()<Kt.TABLET_SM?h.jsx(FTt,{}):h.jsx(BTt,{})}function FTt(){const t=F(),e=H("zoom is 1",()=>t.getZoomLevel()===1,[t]);return h.jsx(G,{actionId:"zoom-to-100",disabled:e})}function BTt(){const t=$n(1),e=$a(),r=t&&e;return h.jsx(G,{actionId:"rotate-ccw",disabled:!r})}function UTt(){const t=$n(1),e=$a(),r=t&&e;return h.jsx(G,{actionId:"rotate-cw",disabled:!r})}function zTt(){const t=nue(),e=$a(),r=t&&e;return h.jsx(G,{actionId:"edit-link",disabled:!r})}function HTt(){const t=eue(),e=tue();return t?h.jsx(B9,{}):e?h.jsx(WTt,{}):h.jsx(B9,{})}function B9(){const t=$n(2),e=$a(),r=t&&e;return h.jsx(G,{actionId:"group",disabled:!r})}function WTt(){return h.jsx(G,{actionId:"ungroup"})}const KTt=x.memo(function({children:e}){const r=Fe(),n=bn(),o=xa(),i=F(),s=H("should display quick actions when in readonly",()=>i.isInAny("hand","zoom"),[i]),a=e??h.jsx(MTt,{});if(!(o&&!s))return h.jsxs(sD,{id:"actions-menu",children:[h.jsx(aD,{children:h.jsx(me,{type:"icon","data-testid":"actions-menu.button",title:r("actions-menu.title"),children:h.jsx(Le,{icon:"dots-vertical",small:!0})})}),h.jsx(lD,{side:n>=Kt.TABLET?"bottom":"top",sideOffset:6,children:h.jsx("div",{className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:h.jsx(qo,{type:"icons",sourceId:"actions-menu",children:a})})})]})});function Re({id:t,label:e,children:r}){const{type:n,sourceId:o}=jb(),i=Fe(),s=_g(e,n),a=s?i(s):void 0;switch(n){case"panel":return h.jsx("div",{className:"tlui-menu__group","data-testid":`${o}-group.${t}`,children:r});case"menu":return h.jsx(nEt,{"data-testid":`${o}-group.${t}`,children:r});case"context-menu":return h.jsx(tle,{dir:"ltr",className:"tlui-menu__group","data-testid":`${o}-group.${t}`,children:r});case"keyboard-shortcuts":return h.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${o}-group.${t}`,children:[h.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),h.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:r})]});default:return r}}function Xn({id:t,disabled:e=!1,label:r,size:n="small",children:o}){const{type:i,sourceId:s}=jb(),a=Sr(),l=Fe(),c=r?typeof r=="string"?r:r[i]??r.default:void 0,u=c?l(c):void 0;switch(i){case"menu":return h.jsxs(eEt,{id:`${s}-sub.${t}`,children:[h.jsx(tEt,{id:`${s}-sub.${u?u.toLowerCase()+"-button":""}`,disabled:e,label:u,title:u}),h.jsx(rEt,{id:`${s}-sub.${u?u.toLowerCase()+"-content":""}`,size:n,children:o})]});case"context-menu":return e?null:h.jsxs(GTt,{id:`${s}-sub.${t}`,children:[h.jsx(ile,{dir:"ltr",disabled:e,asChild:!0,children:h.jsxs(me,{"data-testid":`${s}-sub-trigger.${t}`,type:"menu",className:"tlui-menu__submenu__trigger",children:[h.jsx(qt,{children:u}),h.jsx(Le,{icon:"chevron-right",small:!0})]})}),h.jsx(Lj,{container:a,children:h.jsx(sle,{"data-testid":`${s}-sub-content.${t}`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":n,children:o})})]});default:return o}}function GTt({id:t,children:e}){const[r,n]=ba(t);return h.jsx(ole,{open:r,onOpenChange:n,children:e})}function sue(){return kTt()?h.jsx(G,{actionId:"toggle-auto-size"}):null}function aue(){return nue()?h.jsx(G,{actionId:"edit-link"}):null}function VTt(){return $n(1)?h.jsx(G,{actionId:"duplicate"}):null}function lue(){const t=F();return H("should display flatten option",()=>{if(t.getSelectedShapeIds().length===0)return!1;const n=t.getOnlySelectedShape();return!(n&&t.isShapeOfType(n,"image"))},[t])?h.jsx(G,{actionId:"flatten-to-image"}):null}function cue(){return eue()?h.jsx(G,{actionId:"group"}):null}function uue(){return tue()?h.jsx(G,{actionId:"ungroup"}):null}function due(){const t=F();return H("allow unframe",()=>{const r=t.getSelectedShapes();return r.length===0?!1:r.every(n=>t.isShapeOfType(n,"frame"))},[t])?h.jsx(G,{actionId:"remove-frame"}):null}function hue(){const t=F();return H("allow fit frame to content",()=>{const r=t.getOnlySelectedShape();return r?t.isShapeOfType(r,"frame")&&t.getSortedChildIdsForParent(r).length>0:!1},[t])?h.jsx(G,{actionId:"fit-frame-to-content"}):null}function fue(){const t=F();return H("selected shapes",()=>t.getSelectedShapes().length>0,[t])?h.jsx(G,{actionId:"toggle-lock"}):null}function cD(){const t=F(),e=H("isTransparentBg",()=>!t.getInstanceState().exportBackground,[t]);return h.jsx(Di,{actionId:"toggle-transparent",checked:e,toggle:!0})}function YTt(){const t=F(),e=H("any shapes",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsx(G,{actionId:"unlock-all",disabled:!e})}function pue(){const t=F(),e=H("zoomed to 100",()=>t.getZoomLevel()===1,[t]);return h.jsx(G,{actionId:"zoom-to-100",noClose:!0,disabled:e})}function gue(){const t=F(),e=H("has shapes",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsx(G,{actionId:"zoom-to-fit",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function mue(){const t=F(),e=H("has shapes",()=>t.getSelectedShapeIds().length>0,[t]);return h.jsx(G,{actionId:"zoom-to-selection",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function vue(){return h.jsxs(Re,{id:"clipboard",children:[h.jsx(qTt,{}),h.jsx(ZTt,{}),h.jsx(QTt,{}),h.jsx(VTt,{}),h.jsx(JTt,{})]})}function XTt(){var r;const t=F(),e=H("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsxs(Xn,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!e,children:[h.jsxs(Re,{id:"copy-as-group",children:[h.jsx(G,{actionId:"copy-as-svg"}),!!((r=window.navigator.clipboard)!=null&&r.write)&&h.jsx(G,{actionId:"copy-as-png"}),h.jsx(G,{actionId:"copy-as-json"})]}),h.jsx(Re,{id:"copy-as-bg",children:h.jsx(cD,{})})]})}function qTt(){const t=$n(1);return h.jsx(G,{actionId:"cut",disabled:!t})}function ZTt(){const t=rue(1);return h.jsx(G,{actionId:"copy",disabled:!t})}function QTt(){const t=ATt;return h.jsx(G,{actionId:"paste",disabled:!t})}function yue(){const t=F();return H("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t])?h.jsxs(Re,{id:"conversions",children:[h.jsx(XTt,{}),h.jsxs(Xn,{id:"export-as",label:"context-menu.export-as",size:"small",children:[h.jsxs(Re,{id:"export-as-group",children:[h.jsx(G,{actionId:"export-as-svg"}),h.jsx(G,{actionId:"export-as-png"}),h.jsx(G,{actionId:"export-as-json"})]}),h.jsx(Re,{id:"export-as-bg",children:h.jsx(cD,{})})]})]}):null}function Sue(){const t=F(),e=H("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsx(G,{actionId:"select-all",disabled:!e})}function JTt(){const t=$n(1);return h.jsx(G,{actionId:"delete",disabled:!t})}function e2t(){return rue(1)?h.jsxs(Xn,{id:"edit",label:"context-menu.edit",size:"small",children:[h.jsx(cue,{}),h.jsx(uue,{}),h.jsx(lue,{}),h.jsx(aue,{}),h.jsx(hue,{}),h.jsx(due,{}),h.jsx(xue,{}),h.jsx(wue,{}),h.jsx(sue,{}),h.jsx(fue,{})]}):null}function t2t(){const t=$n(2),e=OTt();return t||e?h.jsxs(Xn,{id:"arrange",label:"context-menu.arrange",size:"small",children:[t&&h.jsxs(Re,{id:"align",children:[h.jsx(G,{actionId:"align-left"}),h.jsx(G,{actionId:"align-center-horizontal"}),h.jsx(G,{actionId:"align-right"}),h.jsx(G,{actionId:"align-top"}),h.jsx(G,{actionId:"align-center-vertical"}),h.jsx(G,{actionId:"align-bottom"})]}),h.jsx(r2t,{}),t&&h.jsxs(Re,{id:"stretch",children:[h.jsx(G,{actionId:"stretch-horizontal"}),h.jsx(G,{actionId:"stretch-vertical"})]}),(t||e)&&h.jsxs(Re,{id:"flip",children:[h.jsx(G,{actionId:"flip-horizontal"}),h.jsx(G,{actionId:"flip-vertical"})]}),h.jsx(n2t,{})]}):null}function r2t(){return $n(3)?h.jsxs(Re,{id:"distribute",children:[h.jsx(G,{actionId:"distribute-horizontal"}),h.jsx(G,{actionId:"distribute-vertical"})]}):null}function n2t(){const t=$n(2),e=Jce();return t?h.jsxs(Re,{id:"order",children:[h.jsx(G,{actionId:"pack"}),e&&h.jsx(G,{actionId:"stack-horizontal"}),e&&h.jsx(G,{actionId:"stack-vertical"})]}):null}function o2t(){return $n(1)?h.jsx(Xn,{id:"reorder",label:"context-menu.reorder",size:"small",children:h.jsxs(Re,{id:"reorder",children:[h.jsx(G,{actionId:"bring-to-front"}),h.jsx(G,{actionId:"bring-forward"}),h.jsx(G,{actionId:"send-backward"}),h.jsx(G,{actionId:"send-to-back"})]})}):null}function i2t(){const t=F(),e=H("pages",()=>t.getPages(),[t]),r=H("current page id",()=>t.getCurrentPageId(),[t]),{addToast:n}=ji(),o=Br();return $n(1)?h.jsxs(Xn,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[h.jsx(Re,{id:"pages",children:e.map(s=>h.jsx(_r,{id:s.id,disabled:r===s.id,label:s.name,onSelect:()=>{t.markHistoryStoppingPoint("move_shapes_to_page"),t.moveShapesToPage(t.getSelectedShapeIds(),s.id);const a=t.getPage(s.id);a&&n({title:"Changed Page",description:`Moved to ${a.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{t.markHistoryStoppingPoint("change-page"),t.setCurrentPage(r)}}]}),o("move-to-page",{source:"context-menu"})}},s.id))}),h.jsx(Re,{id:"new-page",children:h.jsx(G,{actionId:"move-to-new-page"})})]}):null}function wue(){const t=F();return H("oneEmbedSelected",()=>{const r=t.getOnlySelectedShape();return r?!!(t.isShapeOfType(r,"embed")&&r.props.url&&!t.isShapeOrAncestorLocked(r)):!1},[t])?h.jsx(G,{actionId:"convert-to-bookmark"}):null}function xue(){const t=F(),e=dj();return H("oneEmbeddableBookmarkSelected",()=>{const n=t.getOnlySelectedShape();return n?!!(t.isShapeOfType(n,"bookmark")&&n.props.url&&e(n.props.url)&&!t.isShapeOrAncestorLocked(n)):!1},[t])?h.jsx(G,{actionId:"convert-to-embed"}):null}function s2t(){const t=F(),e=H("isSnapMode",()=>t.user.getIsSnapMode(),[t]);return h.jsx(Di,{actionId:"toggle-snap-mode",checked:e})}function a2t(){const t=F(),e=H("isToolLock",()=>t.getInstanceState().isToolLocked,[t]);return h.jsx(Di,{actionId:"toggle-tool-lock",checked:e})}function l2t(){const t=F(),e=H("isGridMode",()=>t.getInstanceState().isGridMode,[t]);return h.jsx(Di,{actionId:"toggle-grid",checked:e})}function c2t(){const t=F(),e=H("isWrapMode",()=>t.user.getIsWrapMode(),[t]);return h.jsx(Di,{actionId:"toggle-wrap-mode",checked:e})}function u2t(){const t=F(),e=H("isFocusMode",()=>t.getInstanceState().isFocusMode,[t]);return h.jsx(Di,{actionId:"toggle-focus-mode",checked:e})}function d2t(){const t=F(),e=H("edgeScrollSpeed",()=>t.user.getEdgeScrollSpeed(),[t]);return h.jsx(Di,{actionId:"toggle-edge-scrolling",checked:e===1})}function h2t(){const t=F(),e=H("animationSpeed",()=>t.user.getAnimationSpeed(),[t]);return h.jsx(Di,{actionId:"toggle-reduce-motion",checked:e===0})}function f2t(){const t=F(),e=H("isDebugMode",()=>t.getInstanceState().isDebugMode,[t]);return h.jsx(Di,{actionId:"toggle-debug-mode",checked:e})}function p2t(){const t=F(),e=H("dynamic resize",()=>t.user.getIsDynamicResizeMode(),[t]);return h.jsx(Di,{actionId:"toggle-dynamic-size-mode",checked:e})}function g2t(){const t=F(),e=H("paste at cursor",()=>t.user.getIsPasteAtCursorMode(),[t]);return h.jsx(Di,{actionId:"toggle-paste-at-cursor",checked:e})}function m2t(){const t=F();return H("show cursor chat",()=>t.getCurrentToolId()==="select"&&!t.getInstanceState().isCoarsePointer,[t])?h.jsx(G,{actionId:"open-cursor-chat"}):null}function v2t(){const t=F(),e=Cb(),r=H("isSelectToolActive",()=>t.getCurrentToolId()==="select",[t]),n=H("isSinglePageMode",()=>t.options.maxPages<=1,[t]);return r?h.jsxs(h.Fragment,{children:[e&&h.jsx(m2t,{}),h.jsxs(Re,{id:"modify",children:[h.jsx(e2t,{}),h.jsx(t2t,{}),h.jsx(o2t,{}),!n&&h.jsx(i2t,{})]}),h.jsx(vue,{}),h.jsx(yue,{}),h.jsx(Re,{id:"select-all",children:h.jsx(Sue,{})})]}):null}const y2t=x.memo(function({children:e,disabled:r=!1}){const n=F(),{Canvas:o}=Pt(),i=x.useCallback(u=>{if(u){if(n.getInstanceState().isCoarsePointer){const d=n.getSelectedShapes(),{inputs:{currentPagePoint:f}}=n,p=n.getShapesAtPoint(f);if(!n.getSelectedShapes().length||!p.some(g=>d.includes(g))){const g=p.filter(m=>n.isShapeOrAncestorLocked(m));g.length&&n.select(...g.map(m=>m.id))}}}else{const d=n.getOnlySelectedShape();d&&n.isShapeOrAncestorLocked(d)&&n.setSelectedShapes([])}},[n]),s=Sr(),[a,l]=ba("context menu",i),c=e??h.jsx(v2t,{});return h.jsxs(yPt,{dir:"ltr",onOpenChange:l,modal:!1,children:[h.jsx(SPt,{onContextMenu:void 0,dir:"ltr",disabled:r,children:o?h.jsx(o,{}):null}),a&&h.jsx(wPt,{container:s,children:h.jsx(xPt,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:Ue,children:h.jsx(qo,{type:"context-menu",sourceId:"context-menu",children:c})})})]})}),S2t=2e3,w2t=5e3,x2t=yr(function(){const e=F(),{isChatting:r,chatMessage:n}=e.getInstanceState(),o=x.useRef(-1),[i,s]=x.useState("");return x.useEffect(()=>{if(!r&&n||r){const l=r?w2t:S2t;o.current=e.timers.setTimeout(()=>{e.updateInstanceState({chatMessage:"",isChatting:!1}),s(""),e.focus()},l)}return()=>{clearTimeout(o.current)}},[e,n,r]),r?h.jsx($2t,{value:i,setValue:s,chatMessage:n}):n.trim()?h.jsx(b2t,{chatMessage:n}):null});function bue(t){const e=F();x.useLayoutEffect(()=>{var s;if(!t.current)return;const{x:n,y:o}=e.inputs.currentScreenPoint;(s=t.current)==null||s.style.setProperty("transform",`translate(${n}px, ${o}px)`);function i(a){var u;const{minX:l,minY:c}=e.getViewportScreenBounds();(u=t.current)==null||u.style.setProperty("transform",`translate(${a.clientX-l}px, ${a.clientY-c}px)`)}return window.addEventListener("pointermove",i),()=>{window.removeEventListener("pointermove",i)}},[t,e])}const b2t=({chatMessage:t})=>{const e=F(),r=x.useRef(null);return bue(r),h.jsx("div",{ref:r,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:e.user.getColor()},children:t})},$2t=yr(function({chatMessage:e,value:r,setValue:n}){const o=F(),i=Fe(),s=x.useRef(null),a=e||i("cursor-chat.type-to-chat");bue(s),x.useLayoutEffect(()=>{const f=s.current;if(!f)return;const p=o.textMeasure.measureText(r||a,{fontFamily:"var(--font-body)",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});f.style.setProperty("width",p.w+"px")},[o,r,a]),x.useLayoutEffect(()=>{const f=o.timers.requestAnimationFrame(()=>{var p;(p=s.current)==null||p.focus()});return()=>{cancelAnimationFrame(f)}},[o]);const l=x.useCallback(()=>{o.updateInstanceState({isChatting:!1}),o.focus()},[o]),c=x.useCallback(f=>{const{value:p}=f.target;n(p.slice(0,64)),o.updateInstanceState({chatMessage:p})},[o,n]),u=x.useCallback(f=>{const p=s.current;if(!p)return;const{value:g}=p;switch(f.key){case"Enter":{if(Ue(f),f.stopPropagation(),!g){l();return}n("");break}case"Escape":{Ue(f),f.stopPropagation(),l();break}}},[l,n]),d=x.useCallback(f=>{f.stopPropagation()},[]);return h.jsx("input",{ref:s,className:"tl-cursor-chat",style:{backgroundColor:o.user.getColor()},onBlur:l,onChange:c,onKeyDown:u,onPaste:d,value:r,placeholder:a,spellCheck:!1})});function yA({checked:t}){return h.jsx(ds,{icon:t?"check":"none",className:"tlui-button__icon",small:!0})}function I2t(){const t=F(),{addToast:e}=ji(),{addDialog:r}=mu(),[n,o]=ze.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(Re,{id:"items",children:[h.jsx(_r,{id:"add-toast",onSelect:()=>{e({id:ct(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),e({id:ct(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"info",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),e({id:ct(),title:"Something maybe bad happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"warning",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),e({id:ct(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),h.jsx(_r,{id:"show-dialog",label:"Show dialog",onSelect:()=>{r({component:({onClose:i})=>h.jsx(C2t,{displayDontShowAgain:!0,onCancel:()=>i(),onContinue:()=>i()}),onClose:()=>{}})}}),h.jsx(_r,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>_2t(t,100)}),h.jsx(_r,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const i=t.getSelectedShapes(),s=i.length===0?t.getRenderingShapes():i;window.alert(`Shapes ${s.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(n)throw Error("oh no!");return null})(),h.jsx(_r,{id:"throw-error",onSelect:()=>o(!0),label:"Throw error"}),h.jsx(_r,{id:"hard-reset",onSelect:zV,label:"Hard reset"})]}),h.jsxs(Re,{id:"flags",children:[h.jsx(P2t,{}),h.jsx(E2t,{})]})]})}function P2t(){const t=Object.values(Xt);return t.length?h.jsx(Xn,{id:"debug flags",label:"Debug Flags",children:h.jsx(Re,{id:"debug flags",children:t.map(e=>h.jsx($ue,{flag:e},e.name))})}):null}function E2t(){const t=Object.values(h$e);return t.length?h.jsx(Xn,{id:"feature flags",label:"Feature Flags",children:h.jsx(Re,{id:"feature flags",children:t.map(e=>h.jsx($ue,{flag:e},e.name))})}):null}function C2t({title:t="title",body:e="hello hello hello",cancel:r="Cancel",confirm:n="Continue",displayDontShowAgain:o=!1,onCancel:i,onContinue:s}){const[a,l]=ze.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(wb,{children:[h.jsx(xb,{children:t}),h.jsx(bb,{})]}),h.jsx(Cg,{style:{maxWidth:350},children:e}),h.jsxs(cj,{className:"tlui-dialog__footer__actions",children:[o&&h.jsxs(me,{type:"normal",onClick:()=>l(!a),style:{marginRight:"auto"},children:[h.jsx(yA,{checked:a}),h.jsx(qt,{children:"Don’t show again"})]}),h.jsx(me,{type:"normal",onClick:i,children:h.jsx(qt,{children:r})}),h.jsx(me,{type:"primary",onClick:async()=>s(),children:h.jsx(qt,{children:n})})]})]})}const $ue=yr(function({flag:e,onChange:r}){const n=e.get();return h.jsx(Db,{id:e.name,title:e.name,label:e.name.replace(/([a-z0-9])([A-Z])/g,o=>`${o[0]} ${o[1].toLowerCase()}`).replace(/^[a-z]/,o=>o.toUpperCase()),checked:n,onSelect:()=>{e.set(!n),r==null||r(!n)}})});let U9=0;function _2t(t,e){const r=Array(e),n=Math.floor(Math.sqrt(e));for(let o=0;o<e;o++)U9++,r[o]={id:ot("box"+U9),type:"geo",x:o%n*132,y:Math.floor(o/n)*132};t.run(()=>{t.createShapes(r).setSelectedShapes(r.map(o=>o.id))})}function T2t({children:t}){const e=t??h.jsx(I2t,{});return h.jsxs(Yc,{id:"debug",children:[h.jsx(Xc,{children:h.jsx(me,{type:"icon",title:"Debug menu",children:h.jsx(Le,{icon:"dots-horizontal"})})}),h.jsx(qc,{side:"top",align:"end",alignOffset:0,children:h.jsx(qo,{type:"menu",sourceId:"debug-panel",children:e})})]})}const A2t=x.memo(function(){const{DebugMenu:e}=Xl();return h.jsxs("div",{className:"tlui-debug-panel",children:[h.jsx(O2t,{}),h.jsx(M2t,{}),e&&h.jsx(e,{})]})});function k2t(t=!0){const[e,r]=x.useState(0),n=F();x.useEffect(()=>{if(!t)return;const o=()=>r(i=>i+1);return n.on("tick",o),()=>{n.off("tick",o)}},[n,t])}const O2t=yr(function(){k2t();const e=F(),r=e.getPath(),n=e.getHoveredShape(),o=e.getOnlySelectedShape(),i=r==="select.idle"||!r.includes("select.")?n:o,s=i&&r.includes("select.")?` / ${i.type||""}${"geo"in i.props?" / "+i.props.geo:""} / [${w.ToInt(e.getPointInShapeSpace(i,e.inputs.currentPagePoint))}]`:"",a=r.startsWith("select.")&&!r.includes(".idle")?` / [${w.ToInt(e.inputs.originPagePoint)}] → [${w.ToInt(e.inputs.currentPagePoint)}] = ${w.Dist(e.inputs.originPagePoint,e.inputs.currentPagePoint).toFixed(0)}`:"";return h.jsx("div",{className:"tlui-debug-panel__current-state",children:`${r}${s}${a}`})});function M2t(){const t=F(),e=H("show_fps",()=>Xt.showFps.get(),[Xt]),r=x.useRef(null);return x.useEffect(()=>{if(!e)return;const n=250;let o=0,i=-1,s=performance.now(),a=0,l=0,c=!1;function u(){if(l++,a=performance.now()-s,a>n){const d=Math.round(l*(n/a)*(1e3/n));d>o&&(o=d);const f=o*.75;(d<f&&!c||d>=f&&c)&&(c=!c),r.current.innerHTML=`FPS ${d.toString()}`,r.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),a-=n,l=0,s=performance.now()}i=t.timers.requestAnimationFrame(u)}return u(),()=>{cancelAnimationFrame(i)}},[e,t]),e?h.jsx("div",{ref:r}):null}const R2t=x.memo(function(){const e=bn(),{MainMenu:r,QuickActions:n,ActionsMenu:o,PageMenu:i}=Xl(),s=F(),a=H("isSinglePageMode",()=>s.options.maxPages<=1,[s]);return!r&&!i&&e<6?null:h.jsx("div",{className:"tlui-menu-zone",children:h.jsxs("div",{className:"tlui-buttons__horizontal",children:[r&&h.jsx(r,{}),i&&!a&&h.jsx(i,{}),e<6?null:h.jsxs(h.Fragment,{children:[n&&h.jsx(n,{}),o&&h.jsx(o,{})]})]})})});function j2t(){const t=F(),e=vu(),[r,n]=x.useState(!1),o=x.useRef(!1);return qs("toggle showback to content",()=>{const i=o.current,s=t.getCurrentPageShapeIds();let a=!1;s.size&&(a=s.size===t.getCulledShapes().size),i!==a&&(n(a),o.current=a)},[t]),r?h.jsx(G,{actionId:"back-to-content",onSelect:()=>{e["back-to-content"].onSelect("helper-buttons"),n(!1)}}):null}function D2t(){const t=F();return H("is pen mode",()=>t.getInstanceState().isPenMode,[t])?h.jsx(G,{actionId:"exit-pen-mode"}):null}function L2t(){const t=F(),e=vu();return H("is following user",()=>!!t.getInstanceState().followingUserId,[t])?h.jsx(_r,{...e["stop-following"]}):null}function N2t(){return h.jsxs(h.Fragment,{children:[h.jsx(D2t,{}),h.jsx(j2t,{}),h.jsx(L2t,{})]})}function F2t({children:t}){const e=t??h.jsx(N2t,{});return h.jsx("div",{className:"tlui-helper-buttons",children:h.jsx(qo,{type:"helper-buttons",sourceId:"helper-buttons",children:e})})}function B2t(){const t=Cb();return h.jsxs(h.Fragment,{children:[h.jsxs(Re,{label:"shortcuts-dialog.tools",id:"tools",children:[h.jsx(G,{actionId:"toggle-tool-lock"}),h.jsx(G,{actionId:"insert-media"}),h.jsx(Cn,{toolId:"select"}),h.jsx(Cn,{toolId:"draw"}),h.jsx(Cn,{toolId:"eraser"}),h.jsx(Cn,{toolId:"hand"}),h.jsx(Cn,{toolId:"rectangle"}),h.jsx(Cn,{toolId:"ellipse"}),h.jsx(Cn,{toolId:"arrow"}),h.jsx(Cn,{toolId:"line"}),h.jsx(Cn,{toolId:"text"}),h.jsx(Cn,{toolId:"frame"}),h.jsx(Cn,{toolId:"note"}),h.jsx(Cn,{toolId:"laser"}),h.jsx(_r,{id:"pointer-down",label:"tool.pointer-down",kbd:",",onSelect:()=>{}})]}),h.jsxs(Re,{label:"shortcuts-dialog.preferences",id:"preferences",children:[h.jsx(G,{actionId:"toggle-dark-mode"}),h.jsx(G,{actionId:"toggle-focus-mode"}),h.jsx(G,{actionId:"toggle-grid"})]}),h.jsxs(Re,{label:"shortcuts-dialog.edit",id:"edit",children:[h.jsx(G,{actionId:"undo"}),h.jsx(G,{actionId:"redo"}),h.jsx(G,{actionId:"cut"}),h.jsx(G,{actionId:"copy"}),h.jsx(G,{actionId:"paste"}),h.jsx(G,{actionId:"select-all"}),h.jsx(G,{actionId:"delete"}),h.jsx(G,{actionId:"duplicate"})]}),h.jsxs(Re,{label:"shortcuts-dialog.view",id:"view",children:[h.jsx(G,{actionId:"zoom-in"}),h.jsx(G,{actionId:"zoom-out"}),h.jsx(G,{actionId:"zoom-to-100"}),h.jsx(G,{actionId:"zoom-to-fit"}),h.jsx(G,{actionId:"zoom-to-selection"})]}),h.jsxs(Re,{label:"shortcuts-dialog.transform",id:"transform",children:[h.jsx(G,{actionId:"bring-to-front"}),h.jsx(G,{actionId:"bring-forward"}),h.jsx(G,{actionId:"send-backward"}),h.jsx(G,{actionId:"send-to-back"}),h.jsx(G,{actionId:"group"}),h.jsx(G,{actionId:"ungroup"}),h.jsx(G,{actionId:"flip-horizontal"}),h.jsx(G,{actionId:"flip-vertical"}),h.jsx(G,{actionId:"align-top"}),h.jsx(G,{actionId:"align-center-vertical"}),h.jsx(G,{actionId:"align-bottom"}),h.jsx(G,{actionId:"align-left"}),h.jsx(G,{actionId:"align-center-horizontal"}),h.jsx(G,{actionId:"align-right"})]}),t&&h.jsx(Re,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:h.jsx(G,{actionId:"open-cursor-chat"})})]})}const U2t=x.memo(function({children:e}){const r=Fe(),n=bn(),o=e??h.jsx(B2t,{});return h.jsxs(h.Fragment,{children:[h.jsxs(wb,{className:"tlui-shortcuts-dialog__header",children:[h.jsx(xb,{children:r("shortcuts-dialog.title")}),h.jsx(bb,{})]}),h.jsx(Cg,{className:pe("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":n<=Kt.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":n<=Kt.TABLET}),children:h.jsx(qo,{type:"keyboard-shortcuts",sourceId:"kbd",children:o})}),h.jsx("div",{className:"tlui-dialog__scrim"})]})}),z2t=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function H2t(){const t=F(),e=Br(),r=H("colorScheme",()=>t.user.getUserPreferences().colorScheme??(t.user.getIsDarkMode()?"dark":"light"),[t]);return h.jsx(Xn,{id:"help menu color-scheme",label:"menu.theme",children:h.jsx(Re,{id:"languages",children:z2t.map(({colorScheme:n,label:o})=>h.jsx(Db,{id:`color-scheme-${n}`,label:o,checked:n===r,onSelect:()=>{t.user.updateUserPreferences({colorScheme:n}),e("color-scheme",{source:"menu",value:n})}},n))})})}function Iue(){const t=F(),e=Br(),r=H("locale",()=>t.user.getLocale(),[t]);return h.jsx(Xn,{id:"help menu language",label:"menu.language",children:h.jsx(Re,{id:"languages",children:vg.map(({locale:n,label:o})=>h.jsx(Db,{id:`language-${n}`,title:n,label:o,checked:n===r,onSelect:()=>{t.user.updateUserPreferences({locale:n}),e("change-language",{source:"menu",locale:n})}},n))})})}function W2t(){return h.jsxs(h.Fragment,{children:[h.jsx(Iue,{}),h.jsx(Pue,{})]})}function Pue(){const{KeyboardShortcutsDialog:t}=Xl(),{addDialog:e}=mu(),r=x.useCallback(()=>{t&&e({component:t})},[e,t]);return t?h.jsx(_r,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:r}):null}function K2t(){return h.jsxs(h.Fragment,{children:[h.jsx(V2t,{}),h.jsx(Z2t,{}),h.jsx(G2t,{}),h.jsx(Q2t,{}),h.jsx(J2t,{})]})}function G2t(){return h.jsxs(Xn,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[h.jsxs(Re,{id:"export-all-as-group",children:[h.jsx(G,{actionId:"export-all-as-svg"}),h.jsx(G,{actionId:"export-all-as-png"}),h.jsx(G,{actionId:"export-all-as-json"})]}),h.jsx(Re,{id:"export-all-as-bg",children:h.jsx(cD,{})})]})}function V2t(){const t=F(),e=H("isSelectToolActive",()=>t.getCurrentToolId()==="select",[t]);return h.jsxs(Xn,{id:"edit",label:"menu.edit",disabled:!e,children:[h.jsx(q2t,{}),h.jsx(vue,{}),h.jsx(yue,{}),h.jsx(Y2t,{}),h.jsx(X2t,{}),h.jsx(Re,{id:"select-all",children:h.jsx(Sue,{})})]})}function Y2t(){return h.jsxs(Re,{id:"misc",children:[h.jsx(cue,{}),h.jsx(uue,{}),h.jsx(aue,{}),h.jsx(sue,{}),h.jsx(due,{}),h.jsx(hue,{}),h.jsx(xue,{}),h.jsx(wue,{}),h.jsx(lue,{})]})}function X2t(){return h.jsxs(Re,{id:"lock",children:[h.jsx(fue,{}),h.jsx(YTt,{})]})}function q2t(){const t=iue(),e=oue();return h.jsxs(Re,{id:"undo-redo",children:[h.jsx(G,{actionId:"undo",disabled:!t}),h.jsx(G,{actionId:"redo",disabled:!e})]})}function Z2t(){return h.jsx(Xn,{id:"view",label:"menu.view",children:h.jsxs(Re,{id:"view-actions",children:[h.jsx(G,{actionId:"zoom-in"}),h.jsx(G,{actionId:"zoom-out"}),h.jsx(pue,{}),h.jsx(gue,{}),h.jsx(mue,{})]})})}function Q2t(){return h.jsxs(Re,{id:"extras",children:[h.jsx(G,{actionId:"insert-embed"}),h.jsx(G,{actionId:"insert-media"})]})}function J2t(){return h.jsxs(Re,{id:"preferences",children:[h.jsxs(Xn,{id:"preferences",label:"menu.preferences",children:[h.jsxs(Re,{id:"preferences-actions",children:[h.jsx(s2t,{}),h.jsx(a2t,{}),h.jsx(l2t,{}),h.jsx(c2t,{}),h.jsx(u2t,{}),h.jsx(d2t,{}),h.jsx(h2t,{}),h.jsx(p2t,{}),h.jsx(g2t,{}),h.jsx(f2t,{})]}),h.jsx(Re,{id:"color-scheme",children:h.jsx(H2t,{})})]}),h.jsx(Iue,{}),h.jsx(Pue,{})]})}const eAt=x.memo(function({children:e}){const r=Sr(),[n,o]=ba("main menu"),i=Fe(),s=e??h.jsx(K2t,{});return h.jsxs(Fj,{dir:"ltr",open:n,onOpenChange:o,modal:!1,children:[h.jsx(Bj,{asChild:!0,dir:"ltr",children:h.jsx(me,{type:"icon","data-testid":"main-menu.button",title:i("menu.title"),children:h.jsx(Le,{icon:"menu",small:!0})})}),h.jsx(Rb,{container:r,children:h.jsx(Uj,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:h.jsx(qo,{type:"menu",sourceId:"main-menu",children:s})})})]})}),pC={};function Kf(t){if(pC[t])return pC[t];const r=document.createElement("canvas").getContext("2d");r.fillStyle=t,r.fillRect(0,0,1,1);const[n,o,i,s]=r.getImageData(0,0,1,1).data,a=new Float32Array([n/255,o/255,i/255,s/255]);return pC[t]=a,a}const hw=10,Eue=4*6*hw+12+4*12;function Vu(t,{center:e,radius:r,numArcSegments:n=20,startAngle:o=0,endAngle:i=rt,offset:s=0}){const a=(i-o)/n;let l=s;for(let c=o;c<i;c+=a)t[l++]=e.x,t[l++]=e.y,t[l++]=e.x+Math.cos(c)*r,t[l++]=e.y+Math.sin(c)*r,t[l++]=e.x+Math.cos(c+a)*r,t[l++]=e.y+Math.sin(c+a)*r;return t}function Yu(t,e,r,n,o,i){t[e++]=r,t[e++]=n,t[e++]=r,t[e++]=n+i,t[e++]=r+o,t[e++]=n,t[e++]=r+o,t[e++]=n,t[e++]=r,t[e++]=n+i,t[e++]=r+o,t[e++]=n+i}function tAt(t,e,r){const n=hw;r=Math.min(r,Math.min(e.w,e.h)/2);const o=ee.ExpandBy(e,-r);if(o.w<=0||o.h<=0)return Vu(t,{center:e.center,radius:r,numArcSegments:hw*4}),hw*4*6;let i=0;return Yu(t,i,o.minX,o.minY,o.w,o.h),i+=12,Yu(t,i,o.minX,e.minY,o.w,r),i+=12,Yu(t,i,o.maxX,o.minY,r,o.h),i+=12,Yu(t,i,o.minX,o.maxY,o.w,r),i+=12,Yu(t,i,e.minX,o.minY,r,o.h),i+=12,Vu(t,{numArcSegments:n,offset:i,center:o.point,radius:r,startAngle:Ze,endAngle:Ze*1.5}),i+=n*6,Vu(t,{numArcSegments:n,offset:i,center:w.Add(o.point,new w(o.w,0)),radius:r,startAngle:Ze*1.5,endAngle:rt}),i+=n*6,Vu(t,{numArcSegments:n,offset:i,center:w.Add(o.point,o.size),radius:r,startAngle:0,endAngle:vt}),i+=n*6,Vu(t,{numArcSegments:n,offset:i,center:w.Add(o.point,new w(0,o.h)),radius:r,startAngle:vt,endAngle:Ze}),Eue}function rAt(t){if(!t)throw new Error("Canvas element not found");const e=t.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Failed to get webgl2 context");const r=`#version 300 es
|
|
400
|
-
precision mediump float;
|
|
401
|
-
|
|
402
|
-
in vec2 shapeVertexPosition;
|
|
403
|
-
|
|
404
|
-
uniform vec4 canvasPageBounds;
|
|
405
|
-
|
|
406
|
-
// taken (with thanks) from
|
|
407
|
-
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
408
|
-
void main() {
|
|
409
|
-
// convert the position from pixels to 0.0 to 1.0
|
|
410
|
-
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
411
|
-
|
|
412
|
-
// convert from 0->1 to 0->2
|
|
413
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
414
|
-
|
|
415
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
416
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
417
|
-
|
|
418
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
419
|
-
}`,n=e.createShader(e.VERTEX_SHADER);if(!n)throw new Error("Failed to create vertex shader");if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const o=`#version 300 es
|
|
420
|
-
precision mediump float;
|
|
421
|
-
|
|
422
|
-
uniform vec4 fillColor;
|
|
423
|
-
out vec4 outputColor;
|
|
424
|
-
|
|
425
|
-
void main() {
|
|
426
|
-
outputColor = fillColor;
|
|
427
|
-
}`,i=e.createShader(e.FRAGMENT_SHADER);if(!i)throw new Error("Failed to create fragment shader");if(e.shaderSource(i,o),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const s=e.createProgram();if(!s)throw new Error("Failed to create program");if(e.attachShader(s,n),e.attachShader(s,i),e.linkProgram(s),!e.getProgramParameter(s,e.LINK_STATUS))throw new Error("Failed to link program");e.useProgram(s);const a=e.getAttribLocation(s,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");e.enableVertexAttribArray(a);const l=e.getUniformLocation(s,"canvasPageBounds"),c=e.getUniformLocation(s,"fillColor");if(!e.createBuffer())throw new Error("Failed to create buffer");if(!e.createBuffer())throw new Error("Failed to create buffer");return{context:e,selectedShapes:eS(e,1024),unselectedShapes:eS(e,4096),viewport:eS(e,Eue),collaborators:eS(e,1024),prepareTriangles(f,p){e.bindBuffer(e.ARRAY_BUFFER,f.buffer),e.bufferData(e.ARRAY_BUFFER,f.vertices,e.STATIC_DRAW,0,p),e.enableVertexAttribArray(a),e.vertexAttribPointer(a,2,e.FLOAT,!1,0,0)},drawTrianglesTransparently(f){e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLES,0,f/2),e.disable(e.BLEND)},drawTriangles(f){e.drawArrays(e.TRIANGLES,0,f/2)},setFillColor(f){e.uniform4fv(c,f)},setCanvasPageBounds(f){e.uniform4fv(l,f)}}}function eS(t,e){const r=t.createBuffer();if(!r)throw new Error("Failed to create buffer");return{buffer:r,vertices:new Float32Array(e)}}function z9(t,e,r){let n=t.vertices.length;for(;n<e+r.length;)n*=2;if(n!=t.vertices.length){const o=new Float32Array(n);o.set(t.vertices),t.vertices=o}t.vertices.set(r,e)}var nAt=Object.create,Cue=Object.defineProperty,oAt=Object.getOwnPropertyDescriptor,iAt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),_ue=t=>{throw TypeError(t)},Tue=(t,e,r)=>e in t?Cue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sAt=t=>[,,,nAt(null)],Aue=["class","method","getter","setter","accessor","field","value","get","set"],kue=t=>t!==void 0&&typeof t!="function"?_ue("Function expected"):t,aAt=(t,e,r,n,o)=>({kind:Aue[t],name:e,metadata:n,addInitializer:i=>r._?_ue("Already initialized"):o.push(kue(i||null))}),lAt=(t,e)=>Tue(e,iAt("metadata"),t[3]),cAt=(t,e,r,n)=>{for(var o=0,i=t[e>>1],s=i&&i.length;o<s;o++)i[o].call(r);return n},Is=(t,e,r,n,o,i)=>{for(var s,a,l,c,u=e&7,d=!!(e&8),f=!!(e&16),p=2,g=Aue[u+5],m=t[p]||(t[p]=[]),S=(o=o.prototype,oAt(o,r)),y=n.length-1;y>=0;y--)l=aAt(u,r,a={},t[3],m),l.static=d,l.private=f,c=l.access={has:v=>r in v},c.get=v=>v[r],s=(0,n[y])(S[g],l),a._=1,kue(s)&&(S[g]=s);return S&&Cue(o,r,S),o},Os=(t,e,r)=>Tue(t,typeof e!="symbol"?e+"":e,r),Oue,Mue,Rue,jue,Due,Lue,Nue,Fue,Bue,Uue,_o;Uue=[lo],Bue=[Y],Fue=[Y],Nue=[Y],Lue=[Y],Due=[Y],jue=[Y],Rue=[Y],Mue=[Y],Oue=[lo];class ti{constructor(e,r,n){this.editor=e,this.elem=r,this.container=n,cAt(_o,5,this),Os(this,"disposables",[]),Os(this,"gl"),Os(this,"shapeGeometryCache"),Os(this,"colors"),Os(this,"id",ct()),Os(this,"canvasBoundingClientRect",fr("canvasBoundingClientRect",new ee)),Os(this,"originPagePoint",new w),Os(this,"originPageCenter",new w),Os(this,"isInViewport",!1),this.gl=rAt(r),this.shapeGeometryCache=e.store.createComputedCache("webgl-geometry",o=>{const i=e.getShapeMaskedPageBounds(o.id);if(!i)return null;const s=new Float32Array(12);return Yu(s,0,i.x,i.y,i.w,i.h),s}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),Sl("minimap render",this.render))}close(){return this.disposables.forEach(e=>e())}_getColors(){const e=getComputedStyle(this.editor.getContainer());return{shapeFill:Kf(e.getPropertyValue("--color-text-3").trim()),selectFill:Kf(e.getPropertyValue("--color-selected").trim()),viewportFill:Kf(e.getPropertyValue("--color-muted-1").trim()),background:Kf(e.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const e=this.editor.getViewportPageBounds(),r=this.editor.getCurrentPageBounds();return r?ee.Expand(r,e):e}getContentScreenBounds(){const e=this.getContentPageBounds(),r=this.editor.pageToScreen(e.point),n=this.editor.pageToScreen(new w(e.maxX,e.maxY));return new ee(r.x,r.y,n.x-r.x,n.y-r.y)}_getCanvasBoundingRect(){const{x:e,y:r,width:n,height:o}=this.elem.getBoundingClientRect();return new ee(e,r,n,o)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const e=new ResizeObserver(()=>{const r=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(r)});return e.observe(this.elem),e.observe(this.container),()=>e.disconnect()}getCanvasSize(){const e=this.canvasBoundingClientRect.get(),r=this.getDpr();return new w(e.width*r,e.height*r)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const e=this.getCanvasScreenBounds(),r=this.getContentPageBounds(),n=e.width/e.height;let o=r.width,i=o/n;i<r.height&&(i=r.height,o=i*n);const s=new ee(0,0,o,i);return s.center=r.center,s}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:e,y:r,w:n,h:o}=this.getCanvasPageBounds();return new Float32Array([e,r,n,o])}getMinimapPagePoint(e,r){const n=this.getCanvasPageBounds(),o=this.getCanvasScreenBounds();let i=e-o.x,s=r-o.y;return i*=n.width/o.width,s*=n.height/o.height,i+=n.minX,s+=n.minY,new w(i,s,1)}minimapScreenPointToPagePoint(e,r,n=!1,o=!1){const{editor:i}=this,s=i.getViewportPageBounds();let{x:a,y:l}=this.getMinimapPagePoint(e,r);if(o){const c=this.editor.getCurrentPageBounds()??new ee,u=c.minX-s.width/2,d=c.maxX+s.width/2,f=c.minY-s.height/2,p=c.maxY+s.height/2,g=Math.max(0,u+s.width-a),m=Math.max(0,-(d-s.width-a)),S=Math.max(0,f+s.height-l),y=Math.max(0,-(p-s.height-l));a+=(g-m)/2,l+=(S-y)/2,a=Pr(a,u,d),l=Pr(l,f,p)}if(n){const{originPagePoint:c}=this,u=Math.abs(a-c.x),d=Math.abs(l-c.y);u>d?l=c.y:a=c.x}return new w(a,l)}render(){const e=this.gl.context,r=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=r.x,this.elem.height=r.y,e.viewport(0,0,r.x,r.y),e.clearColor(this.colors.background[0],this.colors.background[1],this.colors.background[2],1),e.clear(e.COLOR_BUFFER_BIT);const n=new Set(this.editor.getSelectedShapeIds()),o=this.colors;let i=0,s=0;const a=this.editor.getCurrentPageShapeIdsSorted();for(let l=0,c=a.length;l<c;l++){const u=a[l],d=this.shapeGeometryCache.get(u);if(!d)continue;const f=d.length;n.has(u)?(z9(this.gl.selectedShapes,i,d),i+=f):(z9(this.gl.unselectedShapes,s,d),s+=f)}this.drawShapes(this.gl.unselectedShapes,s,o.shapeFill),this.drawShapes(this.gl.selectedShapes,i,o.selectFill),this.drawViewport(),this.drawCollaborators()}drawShapes(e,r,n){this.gl.prepareTriangles(e,r),this.gl.setFillColor(n),this.gl.drawTriangles(r)}drawViewport(){const e=this.editor.getViewportPageBounds(),r=tAt(this.gl.viewport.vertices,e,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,r),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(r),this.editor.environment.isSafari&&(this.gl.drawTrianglesTransparently(r),this.gl.drawTrianglesTransparently(r),this.gl.drawTrianglesTransparently(r))}drawCollaborators(){const e=this.editor.getCollaboratorsOnCurrentPage();if(!e.length)return;const r=20,n=r*6,o=n*e.length;this.gl.collaborators.vertices.length<o&&(this.gl.collaborators.vertices=new Float32Array(o));const i=this.gl.collaborators.vertices;let s=0;const a=this.getZoom();for(const{cursor:l}of e)Vu(i,{center:w.From(l),radius:3*a,offset:s,numArcSegments:r}),s+=n;this.gl.prepareTriangles(this.gl.collaborators,o),s=0;for(const{color:l}of e)this.gl.setFillColor(Kf(l)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,s/2,n/2),s+=n}}_o=sAt();Is(_o,1,"close",Uue,ti);Is(_o,1,"getDpr",Bue,ti);Is(_o,1,"getContentPageBounds",Fue,ti);Is(_o,1,"getContentScreenBounds",Nue,ti);Is(_o,1,"getCanvasSize",Lue,ti);Is(_o,1,"getCanvasClientPosition",Due,ti);Is(_o,1,"getCanvasPageBounds",jue,ti);Is(_o,1,"getZoom",Rue,ti);Is(_o,1,"getCanvasPageBoundsArray",Mue,ti);Is(_o,1,"render",Oue,ti);lAt(_o,ti);function uAt(){const t=F(),e=Sr(),r=x.useRef(null),n=x.useRef(!1),o=x.useRef();x.useEffect(()=>{try{const u=new ti(t,r.current,e);return o.current=u,o.current.close}catch(u){t.annotateError(u,{origin:"minimap",willCrashApp:!1}),t.timers.setTimeout(()=>{throw u})}},[t,e]);const i=x.useCallback(u=>{if(!t.getCurrentPageShapeIds().size||!o.current)return;const d=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),f=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.originPagePoint.setTo(f),o.current.originPageCenter.setTo(t.getViewportPageBounds().center),t.centerOnPoint(d,{animation:{duration:t.options.animationMediumMs}})},[t]),s=x.useCallback(u=>{if(!o.current)return;const d=u.currentTarget;if(em(d,u),!t.getCurrentPageShapeIds().size)return;n.current=!0,o.current.isInViewport=!1;const f=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),p=t.getViewportPageBounds(),g=o.current.getContentPageBounds();if(new ee(g.x-p.width/2,g.y-p.height/2,g.width+p.width,g.height+p.height).containsPoint(f)&&!p.containsPoint(f)){o.current.isInViewport=p.containsPoint(f);const y=w.Sub(p.center,p.point),v=w.Add(f,y);o.current.originPagePoint.setTo(v),o.current.originPageCenter.setTo(f),t.centerOnPoint(f,{animation:{duration:t.options.animationMediumMs}})}else{const y=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.isInViewport=p.containsPoint(y),o.current.originPagePoint.setTo(y),o.current.originPageCenter.setTo(p.center)}function S(y){d&&tm(d,y),n.current=!1,document.body.removeEventListener("pointerup",S)}document.body.addEventListener("pointerup",S)},[t]),a=x.useCallback(u=>{if(!o.current)return;const d=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,u.shiftKey,!0);if(n.current){if(o.current.isInViewport){const m=o.current.originPagePoint.clone().sub(o.current.originPageCenter);t.centerOnPoint(w.Sub(d,m));return}t.centerOnPoint(d)}const f=o.current.getMinimapPagePoint(u.clientX,u.clientY),p=t.pageToScreen(f),g={type:"pointer",target:"canvas",name:"pointer_move",...Ln(u),point:p,isPen:t.getInstanceState().isPenMode};t.dispatch(g)},[t]),l=x.useCallback(u=>{const d=AV(u);t.dispatch({type:"wheel",name:"wheel",delta:d,point:new w(u.clientX,u.clientY),shiftKey:u.shiftKey,altKey:u.altKey,ctrlKey:u.metaKey||u.ctrlKey})},[t]),c=jm();return x.useEffect(()=>{t.timers.setTimeout(()=>{var u,d;(u=o.current)==null||u.updateColors(),(d=o.current)==null||d.render()})},[c,t]),h.jsx("div",{className:"tlui-minimap",children:h.jsx("canvas",{role:"img","aria-label":"minimap",ref:r,className:"tlui-minimap__canvas",onDoubleClick:i,onPointerMove:a,onPointerDown:s,onWheel:l})})}function dAt(t,e){const[r,n]=ze.useState(e);ze.useLayoutEffect(()=>{const i=Ak(t);if(i)try{n(JSON.parse(i))}catch{console.error(`Could not restore value ${t} from local storage.`)}},[t]);const o=ze.useCallback(i=>{n(s=>{const a=typeof i=="function"?i(s):i;return kk(t,JSON.stringify(a)),a})},[t]);return[r,o]}const hAt=x.memo(function(){const e=vu(),r=Fe(),n=bn(),[o,i]=dAt("minimap",!0),s=x.useCallback(()=>{i(c=>!c)},[i]),{ZoomMenu:a,Minimap:l}=Xl();return n<Kt.MOBILE?null:h.jsxs("div",{className:"tlui-navigation-panel",children:[h.jsx("div",{className:"tlui-buttons__horizontal",children:a&&n<Kt.TABLET?h.jsx(a,{}):o?h.jsxs(h.Fragment,{children:[a&&h.jsx(a,{}),l&&h.jsx(me,{type:"icon","data-testid":"minimap.toggle-button",title:r("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:s,children:h.jsx(Le,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):h.jsxs(h.Fragment,{children:[h.jsx(me,{type:"icon","data-testid":"minimap.zoom-out",title:`${r(_g(e["zoom-out"].label))} ${eA(e["zoom-out"].kbd)}`,onClick:()=>e["zoom-out"].onSelect("navigation-zone"),children:h.jsx(Le,{icon:"minus"})}),a&&h.jsx(a,{}),h.jsx(me,{type:"icon","data-testid":"minimap.zoom-in",title:`${r(_g(e["zoom-in"].label))} ${eA(e["zoom-in"].kbd)}`,onClick:()=>e["zoom-in"].onSelect("navigation-zone"),children:h.jsx(Le,{icon:"plus"})}),l&&h.jsx(me,{type:"icon","data-testid":"minimap.toggle-button",title:r("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:s,children:h.jsx(Le,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),l&&n>=Kt.TABLET&&!o&&h.jsx(l,{})]})}),fAt=function({name:e,id:r,isCurrentPage:n,onCancel:o}){const i=F(),s=Br(),a=x.useRef(null),l=x.useRef(null),c=x.useCallback(()=>{l.current=i.markHistoryStoppingPoint("rename page")},[i]),u=x.useCallback(f=>{i.renamePage(r,f||"New Page"),s("rename-page",{source:"page-menu"})},[i,r,s]),d=x.useCallback(()=>{l.current&&i.bailToMark(l.current),o()},[i,o]);return h.jsx($b,{className:"tlui-page-menu__item__input",ref:f=>a.current=f,defaultValue:e,onValueChange:u,onCancel:d,onFocus:c,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:n,autoSelect:!0})},SA=(t,e,r,n,o)=>{let i;const s=t.getPages(),a=r>n?s[n-1]:s[n],l=r>n?s[n]:s[n+1];a&&!l?i=Xi(a.index):!a&&l?i=Ume(s[0].index):i=fg(a.index,l.index),i!==s[r].index&&(t.markHistoryStoppingPoint("moving page"),t.updatePage({id:e,index:i}),o("move-page",{source:"page-menu"}))},H9=yr(function({index:e,listSize:r,item:n,onRename:o}){const i=F(),s=Fe(),a=i.getPages(),l=Br(),c=x.useCallback(()=>{i.markHistoryStoppingPoint("creating page");const p=vo.createId();i.duplicatePage(n.id,p),l("duplicate-page",{source:"page-menu"})},[i,n,l]),u=x.useCallback(()=>{SA(i,n.id,e,e-1,l)},[i,n,e,l]),d=x.useCallback(()=>{SA(i,n.id,e,e+1,l)},[i,n,e,l]),f=x.useCallback(()=>{i.markHistoryStoppingPoint("deleting page"),i.deletePage(n.id),l("delete-page",{source:"page-menu"})},[i,n,l]);return h.jsxs(Yc,{id:`page item submenu ${e}`,children:[h.jsx(Xc,{children:h.jsx(me,{type:"icon",title:s("page-menu.submenu.title"),children:h.jsx(Le,{icon:"dots-vertical"})})}),h.jsx(qc,{alignOffset:0,side:"right",sideOffset:-4,children:h.jsxs(qo,{type:"menu",sourceId:"page-menu",children:[h.jsxs(Re,{id:"modify",children:[o&&h.jsx(_r,{id:"rename",label:"page-menu.submenu.rename",onSelect:o}),h.jsx(_r,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=i.options.maxPages}),e>0&&h.jsx(_r,{id:"move-up",onSelect:u,label:"page-menu.submenu.move-up"}),e<r-1&&h.jsx(_r,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:d})]}),r>1&&h.jsx(Re,{id:"delete",children:h.jsx(_r,{id:"delete",onSelect:f,label:"page-menu.submenu.delete"})})]})})]})}),pAt=x.memo(function(){const e=F(),r=Br(),n=Fe(),o=bn(),i=x.useCallback(()=>y(!1),[]),[s,a]=ba("page-menu",i),l=36,c=x.useRef(null),u=H("pages",()=>e.getPages(),[e]),d=H("currentPage",()=>e.getCurrentPage(),[e]),f=H("currentPageId",()=>e.getCurrentPageId(),[e]),p=xa(),g=H("maxPageCountReached",()=>e.getPages().length>=e.options.maxPages,[e]),m=H("isCoarsePointer",()=>e.getInstanceState().isCoarsePointer,[e]),[S,y]=x.useState(!1),v=x.useCallback(()=>{p||y(j=>!j)},[p]),b=x.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[$,P]=x.useState(Object.fromEntries(u.map((j,M)=>[j.id,{y:M*l,offsetY:0,isSelected:!1}])));x.useLayoutEffect(()=>{P(Object.fromEntries(u.map((j,M)=>[j.id,{y:M*l,offsetY:0,isSelected:!1}])))},[l,u]),x.useEffect(()=>{s&&e.timers.requestAnimationFrame(()=>{const j=document.querySelector(`[data-testid="page-menu-item-${f}"]`);if(j){const M=c.current;if(!M)return;const U=j.offsetTop,B=M.scrollTop;U<B&&M.scrollTo({top:U});const K=U+l,z=M.scrollTop+M.offsetHeight;K>z&&M.scrollTo({top:K-M.offsetHeight})}})},[l,f,s,e]);const E=x.useCallback(j=>{const{clientY:M,currentTarget:U}=j,{dataset:{id:B,index:K}}=U;if(!B||!K)return;const z=b.current;em(j.currentTarget,j),z.status="pointing",z.pointing={id:B,index:+K};const J=$[B].y;z.startY=M,z.startIndex=Math.max(0,Math.min(Math.round(J/l),u.length-1))},[l,u.length,$]),T=x.useCallback(j=>{const M=b.current;if(M.status==="pointing"){const{clientY:U}=j,B=U-M.startY;Math.abs(B)>5&&(M.status="dragging")}if(M.status==="dragging"){const{clientY:U}=j,B=U-M.startY,K=$[M.pointing.id],{startIndex:z,pointing:W}=M,J=K.y+B,oe=Math.max(0,Math.min(Math.round(J/l),u.length-1)),we={...$};if(we[W.id]={y:K.y,offsetY:B,isSelected:!0},oe!==M.dragIndex){M.dragIndex=oe;for(let _e=0;_e<u.length;_e++){const Ge=u[_e];if(Ge.id===M.pointing.id)continue;let{y:de}=we[Ge.id];oe===z?de=_e*l:oe<z?oe<=_e&&_e<z?de=(_e+1)*l:de=_e*l:oe>z&&(oe>=_e&&_e>z?de=(_e-1)*l:de=_e*l),de!==we[Ge.id].y&&(we[Ge.id]={y:de,offsetY:0,isSelected:!0})}}P(we)}},[l,u,$]),I=x.useCallback(j=>{const M=b.current;if(M.status==="dragging"){const{id:U,index:B}=M.pointing;SA(e,U,B,M.dragIndex,r)}tm(j.currentTarget,j),M.status="idle"},[e,r]),_=x.useCallback(j=>{const M=b.current;j.key==="Escape"&&(M.status==="dragging"&&P(Object.fromEntries(u.map((U,B)=>[U.id,{y:B*l,offsetY:0,isSelected:!1}]))),M.status="idle")},[l,u]),k=x.useCallback(()=>{p||(e.run(()=>{e.markHistoryStoppingPoint("creating page");const j=vo.createId();e.createPage({name:n("page-menu.new-page-initial-name"),id:j}),e.setCurrentPage(j),y(!0)}),r("new-page",{source:"page-menu"}))},[e,n,p,r]),D=x.useCallback(j=>{e.setCurrentPage(j),r("change-page",{source:"page-menu"})},[e,r]),R=x.useCallback((j,M)=>{e.renamePage(j,M),r("rename-page",{source:"page-menu"})},[e,r]);return h.jsxs(sD,{id:"pages",onOpenChange:a,open:s,children:[h.jsx(aD,{"data-testid":"main.page-menu",children:h.jsxs(me,{type:"menu",title:d.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[h.jsx("div",{className:"tlui-page-menu__name",children:d.name}),h.jsx(Le,{icon:"chevron-down",small:!0})]})}),h.jsx(lD,{side:"bottom",align:"start",sideOffset:6,disableEscapeKeyDown:S,children:h.jsxs("div",{className:"tlui-page-menu__wrapper",children:[h.jsxs("div",{className:"tlui-page-menu__header",children:[h.jsx("div",{className:"tlui-page-menu__header__title",children:n("page-menu.title")}),!p&&h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsx(me,{type:"icon","data-testid":"page-menu.edit",title:n(S?"page-menu.edit-done":"page-menu.edit-start"),onClick:v,children:h.jsx(Le,{icon:S?"check":"edit"})}),h.jsx(me,{type:"icon","data-testid":"page-menu.create",title:n(g?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:g,onClick:k,children:h.jsx(Le,{icon:"plus"})})]})]}),h.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:l*u.length+4},ref:c,children:u.map((j,M)=>{const U=$[j.id]??{position:M*40,offsetY:0};return S?h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:j.id===d.id?888:M,transform:`translate(0px, ${U.y+U.offsetY}px)`},children:[h.jsx(me,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:E,onPointerUp:I,onPointerMove:T,onKeyDown:_,"data-id":j.id,"data-index":M,children:h.jsx(Le,{icon:"drag-handle-dots"})}),o<Kt.TABLET_SM&&m?h.jsxs(me,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const B=window.prompt("Rename page",j.name);B&&B!==j.name&&R(j.id,B)},onDoubleClick:v,children:[h.jsx(yA,{checked:j.id===d.id}),h.jsx(qt,{children:j.name})]}):h.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:l},children:h.jsx(fAt,{id:j.id,name:j.name,isCurrentPage:j.id===d.id,onCancel:()=>{y(!1),e.clearOpenMenus()}})}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":S,children:h.jsx(H9,{index:M,item:j,listSize:u.length})})]},j.id+"_editing"):h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[h.jsxs(me,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>D(j.id),onDoubleClick:v,title:n("page-menu.go-to-page"),children:[h.jsx(yA,{checked:j.id===d.id}),h.jsx(qt,{children:j.name})]}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu",children:h.jsx(H9,{index:M,item:j,listSize:u.length,onRename:()=>{if(e.environment.isIos){const B=window.prompt("Rename page",j.name);B&&B!==j.name&&R(j.id,B)}else y(!0),f!==j.id&&D(j.id)}})})]},j.id)})})]})})]})});function gAt(){const t=F(),e=iue(),r=oue(),n=$n(1),o=xa(),i=H("should display quick actions",()=>t.isInAny("select","hand","zoom"),[t]),s=$a(),a=n&&s;if(!(o&&!i))return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"undo",disabled:!e}),h.jsx(G,{actionId:"redo",disabled:!r}),h.jsx(G,{actionId:"delete",disabled:!a}),h.jsx(G,{actionId:"duplicate",disabled:!a})]})}const mAt=x.memo(function({children:e}){const r=e??h.jsx(gAt,{});return h.jsx(qo,{type:"small-icons",sourceId:"quick-actions",children:r})});function vAt({userId:t}){const e=qx(t);return e?h.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:e.color},children:e.userName==="New User"?"":e.userName[0]??""},t):null}const yAt=yr(function({userId:e}){const r=F(),n=Fe(),o=Br(),i=qx(e),s=x.useCallback(()=>{r.getInstanceState().followingUserId===e?(r.stopFollowingUser(),o("stop-following",{source:"people-menu"})):(r.startFollowingUser(e),o("start-following",{source:"people-menu"}))},[r,e,o]),a=(i==null?void 0:i.followingUserId)===r.user.getId(),l=r.getInstanceState().followingUserId===e;return i?h.jsxs("div",{className:"tlui-people-menu__item tlui-buttons__horizontal",children:[h.jsxs(me,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>r.zoomToUser(e),onDoubleClick:s,children:[h.jsx(ds,{icon:"color",color:i.color}),h.jsx("div",{className:"tlui-people-menu__name",children:i.userName??"New User"})]}),h.jsx(me,{type:"icon",className:"tlui-people-menu__item__follow",title:n(a?"people-menu.leading":l?"people-menu.following":"people-menu.follow"),onClick:s,disabled:a,"data-active":l||a,children:h.jsx(Le,{icon:a?"leading":l?"following":"follow"})})]}):null});function SAt({count:t}){return h.jsx("div",{className:"tlui-people-menu__more",children:"+"+Math.abs(t)})}const wAt=yr(function(){const e=F(),r=Sr(),n=Fe(),o=Br(),i=x.useRef(!1),[s,a]=x.useState(!1),l=x.useCallback(m=>{a(m)},[]),c=e.user.getColor(),u=x.useCallback(m=>{e.user.updateUserPreferences({color:m}),o("set-color",{source:"people-menu"})},[e,o]),{handleButtonClick:d,handleButtonPointerDown:f,handleButtonPointerEnter:p,handleButtonPointerUp:g}=ze.useMemo(()=>{const m=()=>{i.current=!1,window.removeEventListener("pointerup",m)};return{handleButtonClick:$=>{const{id:P}=$.currentTarget.dataset;P&&c!==P&&u(P)},handleButtonPointerDown:$=>{const{id:P}=$.currentTarget.dataset;P&&(u(P),i.current=!0,window.addEventListener("pointerup",m))},handleButtonPointerEnter:$=>{if(!i.current)return;const{id:P}=$.currentTarget.dataset;P&&u(P)},handleButtonPointerUp:$=>{const{id:P}=$.currentTarget.dataset;P&&u(P)}}},[c,u]);return h.jsxs(rD,{onOpenChange:l,open:s,children:[h.jsx(nD,{dir:"ltr",asChild:!0,children:h.jsx(me,{type:"icon",className:"tlui-people-menu__user__color",style:{color:e.user.getColor()},title:n("people-menu.change-color"),children:h.jsx(Le,{icon:"color"})})}),h.jsx(oD,{container:r,children:h.jsx(iD,{dir:"ltr",className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:h.jsx("div",{className:"tlui-buttons__grid",children:aT.map(m=>h.jsx(me,{type:"icon","data-id":m,"data-testid":m,"aria-label":m,"data-state":c===m?"hinted":void 0,title:m,className:"tlui-button-grid__button",style:{color:m},onPointerEnter:p,onPointerDown:f,onPointerUp:g,onClick:d,children:h.jsx(Le,{icon:"color"})},m))})})})]})});function xAt(){const t=F(),e=Br(),r=H("userName",()=>t.user.getName(),[]),n=Fe(),o=x.useRef(r),i=x.useRef(r),[s,a]=x.useState(!1),l=x.useCallback(()=>{a(f=>!f)},[]),c=x.useCallback(f=>{i.current=f,t.user.updateUserPreferences({name:f})},[t]),u=x.useCallback(()=>{o.current!==i.current&&(e("change-user-name",{source:"people-menu"}),o.current=i.current)},[e]),d=x.useCallback(()=>{a(!1),t.user.updateUserPreferences({name:o.current}),t.clearOpenMenus()},[t]);return h.jsxs("div",{className:"tlui-people-menu__user",children:[h.jsx(wAt,{}),s?h.jsx($b,{className:"tlui-people-menu__user__input",defaultValue:r,onValueChange:c,onComplete:l,onCancel:d,onBlur:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{s||a(!0)},children:r}),r==="New User"?h.jsx("div",{className:"tlui-people-menu__user__label",children:n("people-menu.user")}):null]}),h.jsx(me,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:n("people-menu.change-name"),onClick:l,children:h.jsx(Le,{icon:s?"check":"edit"})})]})}const bAt=yr(function({children:e}){const r=Fe(),n=Sr(),o=F(),i=MV(),s=H("user",()=>o.user.getColor(),[o]),a=H("user",()=>o.user.getName(),[o]),[l,c]=ba("people menu");return h.jsxs(rD,{onOpenChange:c,open:l,children:[h.jsx(nD,{dir:"ltr",asChild:!0,children:h.jsxs("button",{className:"tlui-people-menu__avatars-button",title:r("people-menu.title"),children:[i.length>5&&h.jsx(SAt,{count:i.length-5}),h.jsxs("div",{className:"tlui-people-menu__avatars",children:[i.slice(-5).map(u=>h.jsx(vAt,{userId:u},u)),h.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:s},children:a==="New User"?"":a[0]??""})]})]})}),h.jsx(oD,{container:n,children:h.jsx(iD,{dir:"ltr",className:"tlui-menu",align:"end",side:"bottom",sideOffset:2,alignOffset:-5,onEscapeKeyDown:Ue,children:h.jsxs("div",{className:"tlui-people-menu__wrapper",children:[h.jsx("div",{className:"tlui-people-menu__section",children:h.jsx(xAt,{})}),i.length>0&&h.jsx("div",{className:"tlui-people-menu__section",children:i.map(u=>h.jsx(yAt,{userId:u},u+"_presence"))}),e]})})})]})});function $At(){return h.jsx("div",{className:"tlui-share-zone",draggable:!1,children:h.jsx(bAt,{})})}const IAt=Object.freeze([mo,Nc,Fc,us]);function zue(t=IAt){const e=F();return H("getRelevantStyles",()=>{var i;const r=new O2(e.getSharedStyles()),n=!!((i=e.root.getCurrent())!=null&&i.shapeType),o=e.isIn("select")&&e.getSelectedShapeIds().length>0;if(r.size===0&&e.isIn("select")&&e.getSelectedShapeIds().length===0)for(const s of t)r.applyValue(s,e.getStyleForNextShape(s));return n||o||r.size>0?r:null},[e])}const Ko={color:[{value:"black",icon:"color"},{value:"grey",icon:"color"},{value:"light-violet",icon:"color"},{value:"violet",icon:"color"},{value:"blue",icon:"color"},{value:"light-blue",icon:"color"},{value:"yellow",icon:"color"},{value:"orange",icon:"color"},{value:"green",icon:"color"},{value:"light-green",icon:"color"},{value:"light-red",icon:"color"},{value:"red",icon:"color"}],fill:[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"},{value:"pattern",icon:"fill-pattern"}],dash:[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],size:[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],font:[{value:"draw",icon:"font-draw"},{value:"sans",icon:"font-sans"},{value:"serif",icon:"font-serif"},{value:"mono",icon:"font-mono"}],textAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],horizontalAlign:[{value:"start",icon:"horizontal-align-start"},{value:"middle",icon:"horizontal-align-middle"},{value:"end",icon:"horizontal-align-end"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-middle"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"triangle",icon:"geo-triangle"},{value:"diamond",icon:"geo-diamond"},{value:"star",icon:"geo-star"},{value:"pentagon",icon:"geo-pentagon"},{value:"hexagon",icon:"geo-hexagon"},{value:"octagon",icon:"geo-octagon"},{value:"rhombus",icon:"geo-rhombus"},{value:"rhombus-2",icon:"geo-rhombus-2"},{value:"oval",icon:"geo-oval"},{value:"trapezoid",icon:"geo-trapezoid"},{value:"arrow-left",icon:"geo-arrow-left"},{value:"arrow-up",icon:"geo-arrow-up"},{value:"arrow-down",icon:"geo-arrow-down"},{value:"arrow-right",icon:"geo-arrow-right"},{value:"cloud",icon:"geo-cloud"},{value:"x-box",icon:"geo-x-box"},{value:"check-box",icon:"geo-check-box"},{value:"heart",icon:"geo-heart"}],arrowheadStart:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],arrowheadEnd:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],spline:[{value:"line",icon:"spline-line"},{value:"cubic",icon:"spline-cubic"}]},xc=x.memo(function(e){const{uiType:r,items:n,title:o,style:i,value:s,onValueChange:a,theme:l}=e,c=F(),u=Fe(),d=x.useRef(!1),f=x.useRef(null),{handleButtonClick:p,handleButtonPointerDown:g,handleButtonPointerEnter:m,handleButtonPointerUp:S}=x.useMemo(()=>{const y=()=>{d.current=!1,window.removeEventListener("pointerup",y);const E=f.current;E&&["TEXTAREA","INPUT"].includes(E.nodeName)&&E.focus(),f.current=null};return{handleButtonClick:E=>{const{id:T}=E.currentTarget.dataset;s.type==="shared"&&s.value===T||(c.markHistoryStoppingPoint("point picker item"),a(i,T))},handleButtonPointerDown:E=>{const{id:T}=E.currentTarget.dataset;c.markHistoryStoppingPoint("point picker item"),a(i,T),d.current=!0,f.current=document.activeElement,window.addEventListener("pointerup",y)},handleButtonPointerEnter:E=>{if(!d.current)return;const{id:T}=E.currentTarget.dataset;a(i,T)},handleButtonPointerUp:E=>{const{id:T}=E.currentTarget.dataset;s.type==="shared"&&s.value===T||a(i,T)}}},[s,c,a,i]);return h.jsx("div",{"data-testid":`style.${r}`,className:pe("tlui-buttons__grid"),children:n.map(y=>h.jsx(me,{type:"icon","data-id":y.value,"data-testid":`style.${r}.${y.value}`,"aria-label":y.value,"data-state":s.type==="shared"&&s.value===y.value?"hinted":void 0,title:o+" — "+u(`${r}-style.${y.value}`),className:pe("tlui-button-grid__button"),style:i===mo?{color:l[y.value].solid}:void 0,onPointerEnter:m,onPointerDown:g,onPointerUp:S,onClick:p,children:h.jsx(Le,{icon:y.icon})},y.value))})});function Hue(t,[e,r]){return Math.min(r,Math.max(e,t))}function PAt(t){const e=x.useRef({value:t,previous:t});return x.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Wue=["PageUp","PageDown"],Kue=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Gue={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},qh="Slider",[wA,EAt,CAt]=Ib(qh),[Vue,qOt]=$s(qh,[CAt]),[_At,Gb]=Vue(qh),Yue=x.forwardRef((t,e)=>{const{name:r,min:n=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[n],value:u,onValueChange:d=()=>{},onValueCommit:f=()=>{},inverted:p=!1,...g}=t,m=x.useRef(new Set),S=x.useRef(0),v=s==="horizontal"?TAt:AAt,[b=[],$]=Gl({prop:u,defaultProp:c,onChange:k=>{var R;(R=[...m.current][S.current])==null||R.focus(),d(k)}}),P=x.useRef(b);function E(k){const D=jAt(b,k);_(k,D)}function T(k){_(k,S.current)}function I(){const k=P.current[S.current];b[S.current]!==k&&f(b)}function _(k,D,{commit:R}={commit:!1}){const j=FAt(i),M=BAt(Math.round((k-n)/i)*i+n,j),U=Hue(M,[n,o]);$((B=[])=>{const K=MAt(B,U,D);if(NAt(K,l*i)){S.current=K.indexOf(U);const z=String(K)!==String(B);return z&&R&&f(K),z?K:B}else return B})}return h.jsx(_At,{scope:t.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:m.current,values:b,orientation:s,children:h.jsx(wA.Provider,{scope:t.__scopeSlider,children:h.jsx(wA.Slot,{scope:t.__scopeSlider,children:h.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...g,ref:e,onPointerDown:ue(g.onPointerDown,()=>{a||(P.current=b)}),min:n,max:o,inverted:p,onSlideStart:a?void 0:E,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:I,onHomeKeyDown:()=>!a&&_(n,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,b.length-1,{commit:!0}),onStepKeyDown:({event:k,direction:D})=>{if(!a){const M=Wue.includes(k.key)||k.shiftKey&&Kue.includes(k.key)?10:1,U=S.current,B=b[U],K=i*M*D;_(B+K,U,{commit:!0})}}})})})})});Yue.displayName=qh;var[Xue,que]=Vue(qh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),TAt=x.forwardRef((t,e)=>{const{min:r,max:n,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=t,[d,f]=x.useState(null),p=yt(e,b=>f(b)),g=x.useRef(),m=vj(o),S=m==="ltr",y=S&&!i||!S&&i;function v(b){const $=g.current||d.getBoundingClientRect(),P=[0,$.width],T=uD(P,y?[r,n]:[n,r]);return g.current=$,T(b-$.left)}return h.jsx(Xue,{scope:t.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:h.jsx(Zue,{dir:m,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const $=v(b.clientX);s==null||s($)},onSlideMove:b=>{const $=v(b.clientX);a==null||a($)},onSlideEnd:()=>{g.current=void 0,l==null||l()},onStepKeyDown:b=>{const P=Gue[y?"from-left":"from-right"].includes(b.key);c==null||c({event:b,direction:P?-1:1})}})})}),AAt=x.forwardRef((t,e)=>{const{min:r,max:n,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:l,...c}=t,u=x.useRef(null),d=yt(e,u),f=x.useRef(),p=!o;function g(m){const S=f.current||u.current.getBoundingClientRect(),y=[0,S.height],b=uD(y,p?[n,r]:[r,n]);return f.current=S,b(m-S.top)}return h.jsx(Xue,{scope:t.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:h.jsx(Zue,{"data-orientation":"vertical",...c,ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:m=>{const S=g(m.clientY);i==null||i(S)},onSlideMove:m=>{const S=g(m.clientY);s==null||s(S)},onSlideEnd:()=>{f.current=void 0,a==null||a()},onStepKeyDown:m=>{const y=Gue[p?"from-bottom":"from-top"].includes(m.key);l==null||l({event:m,direction:y?-1:1})}})})}),Zue=x.forwardRef((t,e)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:l,...c}=t,u=Gb(qh,r);return h.jsx(Ye.span,{...c,ref:e,onKeyDown:ue(t.onKeyDown,d=>{d.key==="Home"?(s(d),d.preventDefault()):d.key==="End"?(a(d),d.preventDefault()):Wue.concat(Kue).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:ue(t.onPointerDown,d=>{const f=d.target;f.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(f)?f.focus():n(d)}),onPointerMove:ue(t.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:ue(t.onPointerUp,d=>{const f=d.target;f.hasPointerCapture(d.pointerId)&&(f.releasePointerCapture(d.pointerId),i(d))})})}),Que="SliderTrack",Jue=x.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,o=Gb(Que,r);return h.jsx(Ye.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:e})});Jue.displayName=Que;var xA="SliderRange",ede=x.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,o=Gb(xA,r),i=que(xA,r),s=x.useRef(null),a=yt(e,s),l=o.values.length,c=o.values.map(f=>rde(f,o.min,o.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return h.jsx(Ye.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...t.style,[i.startEdge]:u+"%",[i.endEdge]:d+"%"}})});ede.displayName=xA;var bA="SliderThumb",tde=x.forwardRef((t,e)=>{const r=EAt(t.__scopeSlider),[n,o]=x.useState(null),i=yt(e,a=>o(a)),s=x.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return h.jsx(kAt,{...t,ref:i,index:s})}),kAt=x.forwardRef((t,e)=>{const{__scopeSlider:r,index:n,name:o,...i}=t,s=Gb(bA,r),a=que(bA,r),[l,c]=x.useState(null),u=yt(e,v=>c(v)),d=l?!!l.closest("form"):!0,f=Kse(l),p=s.values[n],g=p===void 0?0:rde(p,s.min,s.max),m=RAt(n,s.values.length),S=f==null?void 0:f[a.size],y=S?DAt(S,g,a.direction):0;return x.useEffect(()=>{if(l)return s.thumbs.add(l),()=>{s.thumbs.delete(l)}},[l,s.thumbs]),h.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[h.jsx(wA.ItemSlot,{scope:t.__scopeSlider,children:h.jsx(Ye.span,{role:"slider","aria-label":t["aria-label"]||m,"aria-valuemin":s.min,"aria-valuenow":p,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0,...i,ref:u,style:p===void 0?{display:"none"}:t.style,onFocus:ue(t.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),d&&h.jsx(OAt,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),value:p},n)]})});tde.displayName=bA;var OAt=t=>{const{value:e,...r}=t,n=x.useRef(null),o=PAt(e);return x.useEffect(()=>{const i=n.current,s=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(s,"value").set;if(o!==e&&l){const c=new Event("input",{bubbles:!0});l.call(i,e),i.dispatchEvent(c)}},[o,e]),h.jsx("input",{style:{display:"none"},...r,ref:n,defaultValue:e})};function MAt(t=[],e,r){const n=[...t];return n[r]=e,n.sort((o,i)=>o-i)}function rde(t,e,r){const i=100/(r-e)*(t-e);return Hue(i,[0,100])}function RAt(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function jAt(t,e){if(t.length===1)return 0;const r=t.map(o=>Math.abs(o-e)),n=Math.min(...r);return r.indexOf(n)}function DAt(t,e,r){const n=t/2,i=uD([0,50],[0,n]);return(n-i(e)*r)*r}function LAt(t){return t.slice(0,-1).map((e,r)=>t[r+1]-e)}function NAt(t,e){if(e>0){const r=LAt(t);return Math.min(...r)>=e}return!0}function uD(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function FAt(t){return(String(t).split(".")[1]||"").length}function BAt(t,e){const r=Math.pow(10,e);return Math.round(t*r)/r}var UAt=Yue,zAt=Jue,HAt=ede,WAt=tde;const KAt=x.memo(function(e){const{title:r,steps:n,value:o,label:i,onValueChange:s}=e,a=F(),l=Fe(),c=x.useCallback(f=>{s(f[0])},[s]),u=x.useCallback(()=>{a.markHistoryStoppingPoint("click slider")},[a]),d=x.useCallback(()=>{o&&s(o)},[o,s]);return h.jsx("div",{className:"tlui-slider__container",children:h.jsxs(UAt,{"data-testid":e["data-testid"],className:"tlui-slider","area-label":"Opacity",dir:"ltr",min:0,max:n,step:1,value:o?[o]:void 0,onPointerDown:u,onValueChange:c,onPointerUp:d,title:r+" — "+l(i),children:[h.jsx(zAt,{className:"tlui-slider__track",dir:"ltr",children:o!==null&&h.jsx(HAt,{className:"tlui-slider__range",dir:"ltr"})}),o!==null&&h.jsx(WAt,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function GAt({label:t,uiTypeA:e,uiTypeB:r,labelA:n,labelB:o,itemsA:i,itemsB:s,styleA:a,styleB:l,valueA:c,valueB:u,onValueChange:d}){const f=Fe(),p=x.useMemo(()=>{var m;return((m=i.find(S=>c.type==="shared"&&c.value===S.value))==null?void 0:m.icon)??"mixed"},[i,c]),g=x.useMemo(()=>{var m;return((m=s.find(S=>u.type==="shared"&&u.value===S.value))==null?void 0:m.icon)??"mixed"},[s,u]);return c===void 0&&u===void 0?null:h.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[h.jsx("div",{title:f(t),className:"tlui-style-panel__double-select-picker-label",children:f(t)}),h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsxs(Yc,{id:`style panel ${e} A`,children:[h.jsx(Xc,{children:h.jsx(me,{type:"icon","data-testid":`style.${e}`,title:f(n)+" — "+(c===null||c.type==="mixed"?f("style-panel.mixed"):f(`${e}-style.${c.value}`)),children:h.jsx(Le,{icon:p,small:!0,invertIcon:!0})})}),h.jsx(qc,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:i.map((m,S)=>h.jsx(Mg,{"data-testid":`style.${e}.${m.value}`,children:h.jsx(me,{type:"icon",onClick:()=>d(a,m.value),title:`${f(n)} — ${f(`${e}-style.${m.value}`)}`,children:h.jsx(Le,{icon:m.icon,invertIcon:!0})},m.value)},S))})})]}),h.jsxs(Yc,{id:`style panel ${r}`,children:[h.jsx(Xc,{children:h.jsx(me,{type:"icon","data-testid":`style.${r}`,title:f(o)+" — "+(u===null||u.type==="mixed"?f("style-panel.mixed"):f(`${r}-style.${u.value}`)),children:h.jsx(Le,{icon:g,small:!0})})}),h.jsx(qc,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:s.map(m=>h.jsx(Mg,{children:h.jsx(me,{type:"icon",title:`${f(o)} — ${f(`${r}-style.${m.value}`)}`,"data-testid":`style.${r}.${m.value}`,onClick:()=>d(l,m.value),children:h.jsx(Le,{icon:m.icon})})},m.value))})})]})]})]})}const VAt=x.memo(GAt);function YAt({id:t,label:e,uiType:r,style:n,items:o,type:i,value:s,onValueChange:a}){const l=Fe(),c=F(),u=x.useMemo(()=>{var p;return(p=o.find(g=>s.type==="shared"&&g.value===s.value))==null?void 0:p.icon},[o,s]),d=s.type==="mixed"?l("style-panel.mixed"):l(`${r}-style.${s.value}`),f=e?l(e):"";return h.jsxs(Yc,{id:`style panel ${t}`,children:[h.jsx(Xc,{children:h.jsxs(me,{type:i,"data-testid":`style.${r}`,title:d,children:[h.jsx(qt,{children:f}),h.jsx(Le,{icon:u??"mixed"})]})}),h.jsx(qc,{side:"left",align:"center",alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:o.map(p=>h.jsx(Mg,{children:h.jsx(me,{type:"icon","data-testid":`style.${r}.${p.value}`,title:l(`${r}-style.${p.value}`),onClick:()=>{c.markHistoryStoppingPoint("select style dropdown item"),a(n,p.value)},children:h.jsx(Le,{icon:p.icon})})},p.value))})})]})}const dD=x.memo(YAt);function XAt({styles:t}){const e=jm();if(!t)return null;const r=t.get(pi),n=t.get(r0),o=t.get(t0),i=t.get(s0),s=t.get(cs),a=r===void 0,l=n===void 0&&o===void 0,c=i===void 0,u=s===void 0,d=ma({isDarkMode:e});return h.jsxs(h.Fragment,{children:[h.jsx(qAt,{theme:d,styles:t}),!u&&h.jsx(ZAt,{theme:d,styles:t}),!(a&&l&&c)&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[h.jsx(QAt,{styles:t}),h.jsx(ekt,{styles:t}),h.jsx(JAt,{styles:t})]})]})}function Hm(){const t=F(),e=Br();return ze.useMemo(()=>function(n,o){t.run(()=>{t.isIn("select")&&t.setStyleForSelectedShapes(n,o),t.setStyleForNextShapes(n,o),t.updateInstanceState({isChangingStyle:!0})}),e("set-style",{source:"style-panel",id:n.id,value:o})},[t,e])}function qAt({styles:t,theme:e}){const r=Fe(),n=F(),o=Hm(),i=t.get(mo),s=t.get(Fc),a=t.get(Nc),l=t.get(us),c=s!==void 0||a!==void 0||l!==void 0;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[i===void 0?null:h.jsx(xc,{title:r("style-panel.color"),uiType:"color",style:mo,items:Ko.color,value:i,onValueChange:o,theme:e}),h.jsx(tkt,{})]}),c&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[s===void 0?null:h.jsx(xc,{title:r("style-panel.fill"),uiType:"fill",style:Fc,items:Ko.fill,value:s,onValueChange:o,theme:e}),a===void 0?null:h.jsx(xc,{title:r("style-panel.dash"),uiType:"dash",style:Nc,items:Ko.dash,value:a,onValueChange:o,theme:e}),l===void 0?null:h.jsx(xc,{title:r("style-panel.size"),uiType:"size",style:us,items:Ko.size,value:l,onValueChange:(u,d)=>{o(u,d);const f=n.getSelectedShapeIds();f.length>0&&pt(n,f)},theme:e})]})]})}function ZAt({theme:t,styles:e}){const r=Fe(),n=Hm(),o=e.get(cs),i=e.get(rT),s=e.get(o0),a=e.get(i0);return o===void 0&&s===void 0?null:h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[o===void 0?null:h.jsx(xc,{title:r("style-panel.font"),uiType:"font",style:cs,items:Ko.font,value:o,onValueChange:n,theme:t}),i===void 0?null:h.jsxs("div",{className:"tlui-style-panel__row",children:[h.jsx(xc,{title:r("style-panel.align"),uiType:"align",style:rT,items:Ko.textAlign,value:i,onValueChange:n,theme:t}),h.jsx("div",{className:"tlui-style-panel__row__extra-button",children:h.jsx(me,{type:"icon",title:r("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:h.jsx(Le,{icon:"vertical-align-middle"})})})]}),s===void 0?null:h.jsxs("div",{className:"tlui-style-panel__row",children:[h.jsx(xc,{title:r("style-panel.align"),uiType:"align",style:o0,items:Ko.horizontalAlign,value:s,onValueChange:n,theme:t}),h.jsx("div",{className:"tlui-style-panel__row__extra-button",children:a===void 0?h.jsx(me,{type:"icon",title:r("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:h.jsx(Le,{icon:"vertical-align-middle"})}):h.jsx(dD,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",style:i0,items:Ko.verticalAlign,value:a,onValueChange:n})})]})]})}function QAt({styles:t}){const e=Hm(),r=t.get(pi);return r===void 0?null:h.jsx(dD,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",style:pi,items:Ko.geo,value:r,onValueChange:e})}function JAt({styles:t}){const e=Hm(),r=t.get(s0);return r===void 0?null:h.jsx(dD,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",style:s0,items:Ko.spline,value:r,onValueChange:e})}function ekt({styles:t}){const e=Hm(),r=t.get(r0),n=t.get(t0);return!r||!n?null:h.jsx(VAt,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:t0,itemsA:Ko.arrowheadStart,valueA:n,uiTypeB:"arrowheadEnd",styleB:r0,itemsB:Ko.arrowheadEnd,valueB:r,onValueChange:e,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const Gf=[.1,.25,.5,.75,1];function tkt(){const t=F(),e=H("opacity",()=>t.getSharedOpacity(),[t]),r=Br(),n=Fe(),o=ze.useCallback(s=>{const a=Gf[s];t.run(()=>{t.isIn("select")&&t.setOpacityForSelectedShapes(a),t.setOpacityForNextShapes(a),t.updateInstanceState({isChangingStyle:!0})}),r("set-style",{source:"style-panel",id:"opacity",value:s})},[t,r]);if(e===void 0)return null;const i=e.type==="mixed"?-1:Gf.indexOf(ume(Gf,s=>Math.abs(s-e.value)));return h.jsx(KAt,{"data-testid":"style.opacity",value:i>=0?i:Gf.length-1,label:e.type==="mixed"?"style-panel.mixed":`opacity-style.${e.value}`,onValueChange:o,steps:Gf.length-1,title:n("style-panel.opacity")})}const rkt=x.memo(function({isMobile:e,children:r}){const n=F(),o=zue(),i=x.useCallback(()=>{e||n.updateInstanceState({isChangingStyle:!1})},[n,e]),s=r??h.jsx(XAt,{styles:o});return h.jsx("div",{className:pe("tlui-style-panel",{"tlui-style-panel__wrapper":!e}),"data-ismobile":e,onPointerLeave:i,children:s})});function nkt(){const t=F(),e=Fe(),r=zue(),n=r==null?void 0:r.get(mo),o=ma({isDarkMode:t.user.getIsDarkMode()}),i=((n==null?void 0:n.type)==="shared"?o[n.value]:o.black).solid,s=H("disable style panel",()=>t.isInAny("hand","zoom","eraser","laser"),[t]),a=x.useCallback(c=>{c||t.updateInstanceState({isChangingStyle:!1})},[t]),{StylePanel:l}=Xl();return l?h.jsxs(sD,{id:"mobile style menu",onOpenChange:a,children:[h.jsx(aD,{children:h.jsx(me,{type:"tool","data-testid":"mobile-styles.button",style:{color:s?"var(--color-muted-1)":i},title:e("style-panel.title"),disabled:s,children:h.jsx(Le,{icon:s?"blob":(n==null?void 0:n.type)==="mixed"?"mixed":"blob"})})}),h.jsx(lD,{side:"top",align:"end",children:l&&h.jsx(l,{isMobile:!0})})]}):null}function okt(){return h.jsxs(h.Fragment,{children:[h.jsx(skt,{}),h.jsx(akt,{}),h.jsx(lkt,{}),h.jsx(ckt,{}),h.jsx(ukt,{}),h.jsx(dkt,{}),h.jsx(hkt,{}),h.jsx(fkt,{}),h.jsx(pkt,{}),h.jsx(gkt,{}),h.jsx(vkt,{}),h.jsx(mkt,{}),h.jsx(wkt,{}),h.jsx($kt,{}),h.jsx(ykt,{}),h.jsx(bkt,{}),h.jsx(xkt,{}),h.jsx(Skt,{}),h.jsx(Ikt,{}),h.jsx(Pkt,{}),h.jsx(Ekt,{}),h.jsx(Ckt,{}),h.jsx(_kt,{}),h.jsx(Tkt,{}),h.jsx(Akt,{}),h.jsx(kkt,{}),h.jsx(Mkt,{}),h.jsx(Okt,{})]})}function ikt(t){var n;const e=F(),r=(n=t.meta)==null?void 0:n.geo;return H("is tool selected",()=>{const o=e.getCurrentToolId(),i=e.getSharedStyles().getAsKnownValue(pi);return r?o==="geo"&&i===r:o===t.id},[e,t.id,r])}function ft({tool:t}){const e=zj(),r=ikt(e[t]);return h.jsx(Cn,{toolId:t,isSelected:r})}function skt(){return h.jsx(ft,{tool:"select"})}function akt(){return h.jsx(ft,{tool:"hand"})}function lkt(){return h.jsx(ft,{tool:"draw"})}function ckt(){return h.jsx(ft,{tool:"eraser"})}function ukt(){return h.jsx(ft,{tool:"arrow"})}function dkt(){return h.jsx(ft,{tool:"text"})}function hkt(){return h.jsx(ft,{tool:"note"})}function fkt(){return h.jsx(Cn,{toolId:"asset"})}function pkt(){return h.jsx(ft,{tool:"rectangle"})}function gkt(){return h.jsx(ft,{tool:"ellipse"})}function mkt(){return h.jsx(ft,{tool:"diamond"})}function vkt(){return h.jsx(ft,{tool:"triangle"})}function ykt(){return h.jsx(ft,{tool:"rhombus"})}function Skt(){return h.jsx(ft,{tool:"heart"})}function wkt(){return h.jsx(ft,{tool:"hexagon"})}function xkt(){return h.jsx(ft,{tool:"cloud"})}function bkt(){return h.jsx(ft,{tool:"star"})}function $kt(){return h.jsx(ft,{tool:"oval"})}function Ikt(){return h.jsx(ft,{tool:"x-box"})}function Pkt(){return h.jsx(ft,{tool:"check-box"})}function Ekt(){return h.jsx(ft,{tool:"arrow-left"})}function Ckt(){return h.jsx(ft,{tool:"arrow-up"})}function _kt(){return h.jsx(ft,{tool:"arrow-down"})}function Tkt(){return h.jsx(ft,{tool:"arrow-right"})}function Akt(){return h.jsx(ft,{tool:"line"})}function kkt(){return h.jsx(ft,{tool:"highlight"})}function Okt(){return h.jsx(ft,{tool:"frame"})}function Mkt(){return h.jsx(ft,{tool:"laser"})}const gC=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function mC(t,e,r,n){t.addEventListener?t.addEventListener(e,r,n):t.attachEvent&&t.attachEvent("on".concat(e),r)}function Vf(t,e,r,n){t.removeEventListener?t.removeEventListener(e,r,n):t.detachEvent&&t.detachEvent("on".concat(e),r)}function nde(t,e){const r=e.slice(0,e.length-1);for(let n=0;n<r.length;n++)r[n]=t[r[n].toLowerCase()];return r}function ode(t){typeof t!="string"&&(t=""),t=t.replace(/\s/g,"");const e=t.split(",");let r=e.lastIndexOf("");for(;r>=0;)e[r-1]+=",",e.splice(r,1),r=e.lastIndexOf("");return e}function Rkt(t,e){const r=t.length>=e.length?t:e,n=t.length>=e.length?e:t;let o=!0;for(let i=0;i<r.length;i++)n.indexOf(r[i])===-1&&(o=!1);return o}const Rg={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":gC?173:189,"=":gC?61:187,";":gC?59:186,"'":222,"[":219,"]":221,"\\":220},ps={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},$A={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Er={16:!1,18:!1,17:!1,91:!1},Lt={};for(let t=1;t<20;t++)Rg["f".concat(t)]=111+t;let gt=[],Kp=null,ide="all";const Fs=new Map,Wm=t=>Rg[t.toLowerCase()]||ps[t.toLowerCase()]||t.toUpperCase().charCodeAt(0),jkt=t=>Object.keys(Rg).find(e=>Rg[e]===t),Dkt=t=>Object.keys(ps).find(e=>ps[e]===t);function sde(t){ide=t||"all"}function jg(){return ide||"all"}function Lkt(){return gt.slice(0)}function Nkt(){return gt.map(t=>jkt(t)||Dkt(t)||String.fromCharCode(t))}function Fkt(){const t=[];return Object.keys(Lt).forEach(e=>{Lt[e].forEach(r=>{let{key:n,scope:o,mods:i,shortcut:s}=r;t.push({scope:o,shortcut:s,mods:i,keys:n.split("+").map(a=>Wm(a))})})}),t}function Bkt(t){const e=t.target||t.srcElement,{tagName:r}=e;let n=!0;const o=r==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return(e.isContentEditable||(o||r==="TEXTAREA"||r==="SELECT")&&!e.readOnly)&&(n=!1),n}function Ukt(t){return typeof t=="string"&&(t=Wm(t)),gt.indexOf(t)!==-1}function zkt(t,e){let r,n;t||(t=jg());for(const o in Lt)if(Object.prototype.hasOwnProperty.call(Lt,o))for(r=Lt[o],n=0;n<r.length;)r[n].scope===t?r.splice(n,1).forEach(s=>{let{element:a}=s;return hD(a)}):n++;jg()===t&&sde(e||"all")}function Hkt(t){let e=t.keyCode||t.which||t.charCode;const r=gt.indexOf(e);if(r>=0&>.splice(r,1),t.key&&t.key.toLowerCase()==="meta"&>.splice(0,gt.length),(e===93||e===224)&&(e=91),e in Er){Er[e]=!1;for(const n in ps)ps[n]===e&&(Fn[n]=!1)}}function ade(t){if(typeof t>"u")Object.keys(Lt).forEach(o=>{Array.isArray(Lt[o])&&Lt[o].forEach(i=>tS(i)),delete Lt[o]}),hD(null);else if(Array.isArray(t))t.forEach(o=>{o.key&&tS(o)});else if(typeof t=="object")t.key&&tS(t);else if(typeof t=="string"){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];let[o,i]=r;typeof o=="function"&&(i=o,o=""),tS({key:t,scope:o,method:i,splitKey:"+"})}}const tS=t=>{let{key:e,scope:r,method:n,splitKey:o="+"}=t;ode(e).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Wm(c);if(!Lt[u])return;r||(r=jg());const d=l>1?nde(ps,a):[],f=[];Lt[u]=Lt[u].filter(p=>{const m=(n?p.method===n:!0)&&p.scope===r&&Rkt(p.mods,d);return m&&f.push(p.element),!m}),f.forEach(p=>hD(p))})};function W9(t,e,r,n){if(e.element!==n)return;let o;if(e.scope===r||e.scope==="all"){o=e.mods.length>0;for(const i in Er)Object.prototype.hasOwnProperty.call(Er,i)&&(!Er[i]&&e.mods.indexOf(+i)>-1||Er[i]&&e.mods.indexOf(+i)===-1)&&(o=!1);(e.mods.length===0&&!Er[16]&&!Er[18]&&!Er[17]&&!Er[91]||o||e.shortcut==="*")&&(e.keys=[],e.keys=e.keys.concat(gt),e.method(t,e)===!1&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0)))}}function K9(t,e){const r=Lt["*"];let n=t.keyCode||t.which||t.charCode;if(!Fn.filter.call(this,t))return;if((n===93||n===224)&&(n=91),gt.indexOf(n)===-1&&n!==229&>.push(n),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const l=$A[a];t[a]&>.indexOf(l)===-1?gt.push(l):!t[a]&>.indexOf(l)>-1?gt.splice(gt.indexOf(l),1):a==="metaKey"&&t[a]&>.length===3&&(t.ctrlKey||t.shiftKey||t.altKey||(gt=gt.slice(gt.indexOf(l))))}),n in Er){Er[n]=!0;for(const a in ps)ps[a]===n&&(Fn[a]=!0);if(!r)return}for(const a in Er)Object.prototype.hasOwnProperty.call(Er,a)&&(Er[a]=t[$A[a]]);t.getModifierState&&!(t.altKey&&!t.ctrlKey)&&t.getModifierState("AltGraph")&&(gt.indexOf(17)===-1&>.push(17),gt.indexOf(18)===-1&>.push(18),Er[17]=!0,Er[18]=!0);const o=jg();if(r)for(let a=0;a<r.length;a++)r[a].scope===o&&(t.type==="keydown"&&r[a].keydown||t.type==="keyup"&&r[a].keyup)&&W9(t,r[a],o,e);if(!(n in Lt))return;const i=Lt[n],s=i.length;for(let a=0;a<s;a++)if((t.type==="keydown"&&i[a].keydown||t.type==="keyup"&&i[a].keyup)&&i[a].key){const l=i[a],{splitKey:c}=l,u=l.key.split(c),d=[];for(let f=0;f<u.length;f++)d.push(Wm(u[f]));d.sort().join("")===gt.sort().join("")&&W9(t,l,o,e)}}function Fn(t,e,r){gt=[];const n=ode(t);let o=[],i="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,f=!1;for(r===void 0&&typeof e=="function"&&(r=e),Object.prototype.toString.call(e)==="[object Object]"&&(e.scope&&(i=e.scope),e.element&&(s=e.element),e.keyup&&(l=e.keyup),e.keydown!==void 0&&(c=e.keydown),e.capture!==void 0&&(d=e.capture),typeof e.splitKey=="string"&&(u=e.splitKey),e.single===!0&&(f=!0)),typeof e=="string"&&(i=e),f&&ade(t,i);a<n.length;a++)t=n[a].split(u),o=[],t.length>1&&(o=nde(ps,t)),t=t[t.length-1],t=t==="*"?"*":Wm(t),t in Lt||(Lt[t]=[]),Lt[t].push({keyup:l,keydown:c,scope:i,mods:o,shortcut:n[a],method:r,key:n[a],splitKey:u,element:s});if(typeof s<"u"&&window){if(!Fs.has(s)){const p=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return K9(m,s)},g=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;K9(m,s),Hkt(m)};Fs.set(s,{keydownListener:p,keyupListenr:g,capture:d}),mC(s,"keydown",p,d),mC(s,"keyup",g,d)}if(!Kp){const p=()=>{gt=[]};Kp={listener:p,capture:d},mC(window,"focus",p,d)}}}function Wkt(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(Lt).forEach(r=>{Lt[r].filter(o=>o.scope===e&&o.shortcut===t).forEach(o=>{o&&o.method&&o.method()})})}function hD(t){const e=Object.values(Lt).flat();if(e.findIndex(n=>{let{element:o}=n;return o===t})<0){const{keydownListener:n,keyupListenr:o,capture:i}=Fs.get(t)||{};n&&o&&(Vf(t,"keyup",o,i),Vf(t,"keydown",n,i),Fs.delete(t))}if((e.length<=0||Fs.size<=0)&&(Object.keys(Fs).forEach(o=>{const{keydownListener:i,keyupListenr:s,capture:a}=Fs.get(o)||{};i&&s&&(Vf(o,"keyup",s,a),Vf(o,"keydown",i,a),Fs.delete(o))}),Fs.clear(),Object.keys(Lt).forEach(o=>delete Lt[o]),Kp)){const{listener:o,capture:i}=Kp;Vf(window,"focus",o,i),Kp=null}}const vC={getPressedKeyString:Nkt,setScope:sde,getScope:jg,deleteScope:zkt,getPressedKeyCodes:Lkt,getAllKeyCodes:Fkt,isPressed:Ukt,filter:Bkt,trigger:Wkt,unbind:ade,keyMap:Rg,modifier:ps,modifierMap:$A};for(const t in vC)Object.prototype.hasOwnProperty.call(vC,t)&&(Fn[t]=vC[t]);if(typeof window<"u"){const t=window.hotkeys;Fn.noConflict=e=>(e&&window.hotkeys===Fn&&(window.hotkeys=t),Fn),window.hotkeys=Fn}const G9=["copy","cut","paste","asset"];function Kkt(){const t=F(),e=xa(),r=vu(),n=zj(),o=H("is focused",()=>t.getInstanceState().isFocused,[t]);x.useEffect(()=>{if(!o)return;const i=new Array,s=(l,c)=>{Fn(l,{element:document.body},c),i.push(()=>{Fn.unbind(l,c)})},a=(l,c)=>{Fn(l,{element:document.body,keyup:!0,keydown:!1},c),i.push(()=>{Fn.unbind(l,c)})};for(const l of Object.values(r))l.kbd&&(e&&!l.readonlyOk||G9.includes(l.id)||s(V9(l.kbd),c=>{vp(t)||(Ue(c),l.onSelect("kbd"))}));for(const l of Object.values(n))!l.kbd||!l.readonlyOk&&t.getInstanceState().isReadonly||G9.includes(l.id)||s(V9(l.kbd),c=>{vp(t)||(Ue(c),l.onSelect("kbd"))});return s(",",l=>{if(vp(t)||t.inputs.keys.has("Comma"))return;Ue(l),t.focus(),t.inputs.keys.add("Comma");const{x:c,y:u,z:d}=t.inputs.currentPagePoint,f=t.pageToScreen({x:c,y:u}),p={type:"pointer",name:"pointer_down",point:{x:f.x,y:f.y,z:d},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,pointerId:0,button:0,isPen:t.getInstanceState().isPenMode,target:"canvas"};t.dispatch(p)}),a(",",l=>{if(vp(t)||!t.inputs.keys.has("Comma"))return;t.inputs.keys.delete("Comma");const{x:c,y:u,z:d}=t.inputs.currentScreenPoint,f={type:"pointer",name:"pointer_up",point:{x:c,y:u,z:d},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,pointerId:0,button:0,isPen:t.getInstanceState().isPenMode,target:"canvas"};t.dispatch(f)}),()=>{i.forEach(l=>l())}},[r,n,e,t,o])}function V9(t){return Gkt(t).map(e=>{let r="";const n=e.split("");return n.length===1?r=n[0]:n[0]==="!"?r=`shift+${n[1]}`:n[0]==="?"?n.length===3&&n[1]==="!"?r=`alt+shift+${n[2]}`:r=`alt+${n[1]}`:n[0]==="$"?n[1]==="!"?r=`cmd+shift+${n[2]},ctrl+shift+${n[2]}`:n[1]==="?"?r=`cmd+⌥+${n[2]},ctrl+alt+${n[2]}`:r=`cmd+${n[1]},ctrl+${n[1]}`:r=e,r}).join(",")}function Gkt(t){typeof t!="string"&&(t=""),t=t.replace(/\s/g,"");const e=t.split(",");let r=e.lastIndexOf("");for(;r>=0;)e[r-1]+=",",e.splice(r,1),r=e.lastIndexOf("");return e}function vp(t){return t.getIsMenuOpen()||t.getEditingShapeId()!==null||t.getCrashingError()}const Vkt=x.createContext(!1);function Ykt({children:t}){const e=F(),r=LV(),n=bn(),o=Fe(),i=Math.min(8,5+n),[s,a]=x.useState(0),l=x.useRef(null),[c,u]=x.useState(null),d=x.useMemo(()=>{const p=c?`:not([data-value="${c}"])`:"";return`
|
|
428
|
-
#${r}_main > *:nth-child(n + ${i+(c?1:2)})${p} {
|
|
429
|
-
display: none;
|
|
430
|
-
}
|
|
431
|
-
#${r}_more > *:nth-child(-n + ${i}) {
|
|
432
|
-
display: none;
|
|
433
|
-
}
|
|
434
|
-
`},[c,r,i]),f=ab(()=>{if(!l.current)return;const p=Array.from(l.current.children);a(p.length),p.findIndex(S=>S.getAttribute("data-value")===c)<=i&&u(null);const m=Array.from(l.current.children).findIndex(S=>S.getAttribute("aria-checked")==="true");m!==-1&&m>=i&&u(p[m].getAttribute("data-value"))});return x.useLayoutEffect(()=>{f()}),x.useLayoutEffect(()=>{if(!l.current)return;const p=new MutationObserver(f);return p.observe(l.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{p.disconnect()}},[f]),x.useEffect(()=>{const p=[["1",0],["2",1],["3",2],["4",3],["5",4],["6",5],["7",6],["8",7],["9",8],["0",9]];for(const[g,m]of p)Fn(g,S=>{var b;if(vp(e))return;Ue(S);const v=Array.from(((b=l.current)==null?void 0:b.children)??[]).filter($=>!($ instanceof HTMLElement)||$.tagName.toLowerCase()!=="button"?!1:!!($.offsetWidth||$.offsetHeight))[m];v&&v.click()});return()=>{Fn.unbind("1,2,3,4,5,6,7,8,9,0")}},[e]),h.jsxs(h.Fragment,{children:[h.jsx("style",{children:d}),h.jsxs("div",{className:pe("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":n<Kt.TABLET_SM}),role:"radiogroup",children:[h.jsx("div",{id:`${r}_main`,ref:l,className:"tlui-toolbar__tools__list",children:h.jsx(qo,{type:"toolbar",sourceId:"toolbar",children:t})}),s>i+1&&h.jsx(Vkt.Provider,{value:!0,children:h.jsxs(Yc,{id:"toolbar overflow",modal:!1,children:[h.jsx(Xc,{children:h.jsx(me,{title:o("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:h.jsx(Le,{icon:"chevron-up"})})}),h.jsx(qc,{side:"top",align:"center",children:h.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${r}_more`,children:h.jsx(qo,{type:"toolbar-overflow",sourceId:"toolbar",children:t})})})]})})]})]})}function Xkt({activeToolId:t}){const e=F(),r=bn(),n=Fe(),o=H("is tool locked",()=>e.getInstanceState().isToolLocked,[e]),i=H("current tool",()=>e.getCurrentTool(),[e]);return!t||!i.isLockable?null:h.jsx(me,{type:"normal",title:n("action.toggle-tool-lock"),"data-testid":"tool-lock",className:pe("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":r<Kt.TABLET_SM}),onClick:()=>e.updateInstanceState({isToolLocked:!o}),children:h.jsx(Le,{icon:o?"lock":"unlock",small:!0})})}const qkt=x.memo(function({children:e}){const r=F(),n=bn(),o=xa(),i=H("current tool id",()=>r.getCurrentToolId(),[r]),{ActionsMenu:s,QuickActions:a}=Xl();return h.jsx("div",{className:"tlui-toolbar",children:h.jsxs("div",{className:"tlui-toolbar__inner",children:[h.jsxs("div",{className:"tlui-toolbar__left",children:[!o&&h.jsxs("div",{className:"tlui-toolbar__extras",children:[n<Kt.TABLET&&h.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[a&&h.jsx(a,{}),s&&h.jsx(s,{})]}),h.jsx(Xkt,{activeToolId:i})]}),h.jsx(Ykt,{children:e??h.jsx(okt,{})})]}),n<Kt.TABLET_SM&&!o&&h.jsx("div",{className:"tlui-toolbar__tools",children:h.jsx(nkt,{})})]})})});function Zkt(){const t=Fe();return h.jsxs("div",{className:pe("tlui-offline-indicator"),children:[t("status.offline"),h.jsx(ds,{"aria-label":"offline",icon:"status-offline",small:!0})]})}function Qkt({maxWidth:t=420,ignoreRightWidth:e=0,stylePanelWidth:r=148,marginBetweenZones:n=12,squeezeAmount:o=52,children:i}){const s=x.useRef(null),a=bn(),l=x.useCallback(()=>{const c=s.current;if(!c)return;const u=c.parentElement.parentElement,d=u.querySelector(".tlui-layout__top__left"),f=u.querySelector(".tlui-layout__top__right"),p=u.offsetWidth,g=d.offsetWidth,m=f.offsetWidth,S=c.offsetWidth-e;let y=(p-S)/2;p%2!==0&&(y-=.5);const v=g+n,b=c.offsetLeft,$=Math.min(p-m-g-2*n,t),P=Math.max(y,v)-b;f.offsetWidth>r&&a<=6?c.style.setProperty("max-width",$-o+"px"):c.style.setProperty("max-width",$+"px"),c.style.setProperty("transform",`translate(${P}px, 0px)`)},[a,e,n,t,o,r]);return x.useLayoutEffect(()=>{const c=s.current;if(!c)return;const u=c.parentElement.parentElement,d=u.querySelector(".tlui-layout__top__left"),f=u.querySelector(".tlui-layout__top__right"),p=new ResizeObserver(l);return p.observe(d),p.observe(f),p.observe(u),p.observe(c),l(),()=>{p.disconnect()}},[l]),x.useLayoutEffect(()=>{l()}),h.jsx("div",{ref:s,className:"tlui-top-panel__container",children:i})}function Jkt(){const t=r$t()==="offline";return h.jsx(Qkt,{children:t&&h.jsx(Zkt,{})})}function eOt(){return h.jsxs(h.Fragment,{children:[h.jsx(G,{actionId:"zoom-in",noClose:!0}),h.jsx(G,{actionId:"zoom-out",noClose:!0}),h.jsx(pue,{}),h.jsx(gue,{}),h.jsx(mue,{})]})}const tOt=x.memo(function({children:e}){const r=Sr(),[n,o]=ba("zoom menu"),i=e??h.jsx(eOt,{});return h.jsxs(Fj,{dir:"ltr",open:n,onOpenChange:o,modal:!1,children:[h.jsx(Bj,{asChild:!0,dir:"ltr",children:h.jsx(rOt,{})}),h.jsx(Rb,{container:r,children:h.jsx(Uj,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:h.jsx(qo,{type:"menu",sourceId:"zoom-menu",children:i})})})]})}),rOt=x.forwardRef(function(e,r){const n=F(),o=bn(),i=H("zoom",()=>n.getZoomLevel(),[n]),s=Fe(),a=x.useCallback(()=>{n.resetZoom(n.getViewportScreenCenter(),{animation:{duration:n.options.animationMediumMs}})},[n]);return h.jsx(me,{ref:r,...e,type:"icon",title:`${s("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:o<Kt.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,icon:o<Kt.MOBILE?"zoom-in":void 0,children:o<Kt.MOBILE?null:h.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(i*100),"%"]})})}),lde=x.createContext(null);function nOt({overrides:t={},children:e}){const r=om(t),n=Cb();return h.jsx(lde.Provider,{value:x.useMemo(()=>({ContextMenu:y2t,ActionsMenu:KTt,HelpMenu:null,ZoomMenu:tOt,MainMenu:eAt,Minimap:uAt,StylePanel:rkt,PageMenu:pAt,NavigationPanel:hAt,Toolbar:qkt,KeyboardShortcutsDialog:U2t,QuickActions:mAt,HelperButtons:F2t,DebugPanel:A2t,DebugMenu:T2t,MenuPanel:R2t,SharePanel:n?$At:null,CursorChatBubble:n?x2t:null,TopPanel:n?Jkt:null,...r}),[r,n]),children:e})}function Xl(){const t=x.useContext(lde);if(!t)throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return t}function oOt({overrides:t,components:e,assetUrls:r,onUiEvent:n,forceMobile:o,mediaMimeTypes:i,children:s}){return h.jsx(kse.Provider,{value:i,children:h.jsx(q0t,{assetUrls:gTt(r),children:h.jsx(J0t,{overrides:yTt(t),children:h.jsx(F1t,{onEvent:n,children:h.jsx(qbt,{children:h.jsx(o$t,{children:h.jsx(qPt,{forceMobile:o,children:h.jsx(nOt,{overrides:e,children:h.jsx(iOt,{overrides:t,children:s})})})})})})})})})}function iOt({overrides:t,children:e}){const r=STt(t);return h.jsx(s$t,{overrides:r.actions,children:h.jsx(oEt,{overrides:r.tools,children:e})})}function sOt(){const t=F(),{addToast:e}=ji();x.useEffect(()=>{function r({name:n,count:o}){e({title:"Maximum Shapes Reached",description:`You've reached the maximum number of shapes allowed on ${n} (${o}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return t.addListener("max-shapes",r),()=>{t.removeListener("max-shapes",r)}},[t,e])}const aOt=ze.memo(function({renderDebugMenuItems:e,children:r,hideUi:n,components:o,...i}){return h.jsx(oOt,{...i,components:o,children:h.jsx(lOt,{hideUi:n,renderDebugMenuItems:e,children:r})})}),lOt=ze.memo(function({children:e,hideUi:r,...n}){return h.jsxs(h.Fragment,{children:[e,r?null:h.jsx(cOt,{...n})]})}),cOt=ze.memo(function(){const e=F(),r=Fe(),n=bn(),o=xa(),i=H("focus",()=>e.getInstanceState().isFocusMode,[e]),s=H("debug",()=>e.getInstanceState().isDebugMode,[e]),{SharePanel:a,TopPanel:l,MenuPanel:c,StylePanel:u,Toolbar:d,HelpMenu:f,NavigationPanel:p,HelperButtons:g,DebugPanel:m,CursorChatBubble:S}=Xl();Kkt(),abt(),sOt();const{"toggle-focus-mode":y}=vu();return h.jsxs("div",{className:pe("tlui-layout",{"tlui-layout__mobile":n<Kt.TABLET_SM}),"data-breakpoint":n,children:[i?h.jsx("div",{className:"tlui-layout__top",children:h.jsx(me,{type:"icon",className:"tlui-focus-button",title:r("focus-mode.toggle-focus-mode"),onClick:()=>y.onSelect("menu"),children:h.jsx(Le,{icon:"dot"})})}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"tlui-layout__top",children:[h.jsxs("div",{className:"tlui-layout__top__left",children:[c&&h.jsx(c,{}),g&&h.jsx(g,{})]}),h.jsx("div",{className:"tlui-layout__top__center",children:l&&h.jsx(l,{})}),h.jsxs("div",{className:"tlui-layout__top__right",children:[a&&h.jsx(a,{}),u&&n>=Kt.TABLET_SM&&!o&&h.jsx(u,{})]})]}),h.jsxs("div",{className:"tlui-layout__bottom",children:[h.jsxs("div",{className:"tlui-layout__bottom__main",children:[p&&h.jsx(p,{}),d&&h.jsx(d,{}),f&&h.jsx(f,{})]}),s&&m&&h.jsx(m,{})]})]}),h.jsx(hTt,{}),h.jsx(sTt,{}),h.jsx(fTt,{}),h.jsx(aTt,{}),S&&h.jsx(S,{})]})});async function uOt(t,e){const{url:r,style:n="normal",weight:o="500",display:i,featureSettings:s,stretch:a,unicodeRange:l,variant:c,format:u}=e,d={style:n,weight:o,display:i,featureSettings:s,stretch:a,unicodeRange:l,variant:c},f=new FontFace(t,`url(${r})`,d);return await f.load(),document.fonts.add(f),f.$$_url=r,f.$$_fontface=`
|
|
435
|
-
@font-face {
|
|
436
|
-
font-family: ${f.family};
|
|
437
|
-
font-stretch: ${f.stretch};
|
|
438
|
-
font-weight: ${f.weight};
|
|
439
|
-
font-style: ${f.style};
|
|
440
|
-
src: url("${r}") format("${u}")
|
|
441
|
-
}`,f}const rS=(t,e)=>{const[r,n]=x.useState(2);return x.useEffect(()=>{let o=!1;return n(2),uOt(t,e).then(()=>{o||n(0)}).catch(i=>{o||(console.error(i),n(1))}),()=>{o=!0}},[t,e]),r};function dOt(t){return{draw:{url:t.fonts.draw,format:t.fonts.draw.split(".").pop()},serif:{url:t.fonts.serif,format:t.fonts.serif.split(".").pop()},sansSerif:{url:t.fonts.sansSerif,format:t.fonts.sansSerif.split(".").pop()},monospace:{url:t.fonts.monospace,format:t.fonts.monospace.split(".").pop()}}}function cde(t){const e=x.useMemo(()=>dOt(t),[t]),r=[rS("tldraw_draw",e.draw),rS("tldraw_serif",e.serif),rS("tldraw_sans",e.sansSerif),rS("tldraw_mono",e.monospace)];return{error:r.some(n=>n===1),done:!r.some(n=>n===2)}}function hOt(t){const{children:e,maxImageDimension:r,maxAssetSize:n,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:i,onMount:s,components:a={},shapeUtils:l=[],bindingUtils:c=[],tools:u=[],embeds:d,...f}=t,p=om(a),g=x.useMemo(()=>({Scribble:n9,ShapeIndicators:gEt,CollaboratorScribble:n9,SelectionForeground:hEt,SelectionBackground:uEt,Handles:iEt,...p}),[p]),m=Ga(l),S=x.useMemo(()=>[...nce,...m],[m]),y=Ga(c),v=x.useMemo(()=>[...Ele,...y],[y]),b=Ga(u),$=x.useMemo(()=>[...nTt,...XEt,...b],[b]),P=Ga(o??Cx),E=Ga(i??Ek),T=x.useMemo(()=>[...P,...E],[P,E]),I=Uce(f.assetUrls),{done:_,error:k}=cde(I);return k?h.jsx(Cie,{children:"Could not load assets. Please refresh the page."}):_?h.jsx(O0t,{initialState:"select",...f,components:g,shapeUtils:S,bindingUtils:v,tools:$,children:h.jsxs(aOt,{...f,components:g,mediaMimeTypes:T,children:[h.jsx(fOt,{maxImageDimension:r,maxAssetSize:n,acceptedImageMimeTypes:P,acceptedVideoMimeTypes:E,onMount:s,embeds:d}),e]})}):h.jsx(QR,{children:h.jsx(hO,{})})}function fOt({maxImageDimension:t=5e3,maxAssetSize:e=10*1024*1024,acceptedImageMimeTypes:r=Cx,acceptedVideoMimeTypes:n=Ek,onMount:o,embeds:i}){const s=F(),a=ji(),l=Fe();_ie(()=>{const d=s.getShapeUtil("embed");d&&i&&d.setEmbedDefinitions(i);const f=[];return f.push(C_t(s)),OEt(s,{maxImageDimension:t,maxAssetSize:e,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:n},{toasts:a,msg:l}),f.push(s.store.props.onMount(s)),f.push(o==null?void 0:o(s)),()=>{f.forEach(p=>p==null?void 0:p())}});const{Canvas:c}=Pt(),{ContextMenu:u}=Xl();return u?h.jsx(u,{}):c?h.jsx(c,{}):null}x.memo(function(e){const[r,n]=x.useState(null),[o,i]=x.useState(null),s=Ga(e.shapeUtils??[]),a=x.useMemo(()=>[...nce,...s],[s]),l=Ga(e.bindingUtils??[]),c=x.useMemo(()=>[...Ele,...l],[l]),u=N0t({snapshot:e.snapshot,shapeUtils:a}),d=Uce(e.assetUrls),{done:f,error:p}=cde(d),{pageId:g,bounds:m,scale:S,background:y,padding:v,darkMode:b,preserveAspectRatio:$,format:P="svg",licenseKey:E}=e;return x.useLayoutEffect(()=>{if(!o||!u||!f)return;let T=!1;const I=document.createElement("div");o.appendChild(I),o.classList.add("tl-container","tl-theme__light");const _=new ie({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>I,licenseKey:E});g&&_.setCurrentPage(g);const k=_.getCurrentPageShapeIds();async function D(){const R=await _.getSvgString([...k],{bounds:m,scale:S,background:y,padding:v,darkMode:b,preserveAspectRatio:$});if(R&&!T){if(P==="svg"){if(!T){const j=new Blob([R.svg],{type:"image/svg+xml"}),M=URL.createObjectURL(j);n(M)}}else if(P==="png"){const j=await pse(_,R.svg,{type:P,quality:1,scale:2,width:R.width,height:R.height});if(j&&!T){const M=URL.createObjectURL(j);n(M)}}}_.dispose()}return D(),()=>{T=!0}},[P,o,u,a,c,g,m,S,y,v,b,$,f,p,E]),p?h.jsx(Cie,{children:"Could not load assets."}):f?h.jsx("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:r&&h.jsx("img",{src:r,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})}):h.jsx(QR,{children:h.jsx(hO,{})})});x.memo(function({children:e}){const r=Fe(),n=bn(),o=e??h.jsx(W2t,{});return n<Kt.MOBILE?null:h.jsx("div",{className:"tlui-help-menu",children:h.jsxs(Yc,{id:"help menu",children:[h.jsx(Xc,{children:h.jsx(me,{type:"help",title:r("help-menu.title"),"data-testid":"help-menu.button",children:h.jsx(Le,{icon:"question-mark",small:!0})})}),h.jsx(qc,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:h.jsx(qo,{type:"menu",sourceId:"help-menu",children:o})})]})})});const pOt=1,gOt=Ne({schemaVersion:en(1),storeVersion:wS,recordVersions:Jw(Te,Ne({version:wS,subTypeVersions:Jw(Te,wS).optional(),subTypeKey:Te.optional()}))}),mOt=Ne({schemaVersion:en(2),sequences:Jw(Te,wS)}),vOt=Ne({tldrawFileFormatVersion:W1e,schema:K1e("schemaVersion",{1:gOt,2:mOt}),records:Tr(Ne({id:Te,typeName:Te}).allowUnknownProperties())});function yOt(t){var e;try{return!!((e=t.document)!=null&&e.version)}catch{return!1}}function SOt({json:t,schema:e}){let r;try{r=vOt.validate(JSON.parse(t))}catch(i){try{if(r=JSON.parse(t),yOt(r))return hn.err({type:"v1File",data:r})}catch{}return hn.err({type:"notATldrawFile",cause:i})}if(r.tldrawFileFormatVersion>pOt)return hn.err({type:"fileFormatVersionTooNew",version:r.tldrawFileFormatVersion});let n,o;try{const i=wOt(r.records);o=Object.fromEntries(i.map(s=>[s.id,s])),n=e.migrateStoreSnapshot({store:o,schema:r.schema})}catch(i){return hn.err({type:"invalidRecords",cause:i})}if(n.type==="error")return hn.err({type:"migrationFailed",reason:n.reason});try{return hn.ok(Eg({snapshot:{store:o,schema:r.schema},schema:e}))}catch(i){return hn.err({type:"invalidRecords",cause:i})}}function wOt(t){const e=new Set;for(const r of t)r.typeName==="shape"&&"assetId"in r.props&&r.props.assetId&&e.add(r.props.assetId);return t.filter(r=>r.typeName!=="asset"||e.has(r.id))}Ol("tldraw","3.0.1","esm");function xOt(){const[t,e]=x.useState();function r(n){window.editor=n,t===void 0?fetch("/tldr-data").then(async o=>{if(!o.ok){console.log(`No tldr data to load from local endpoint (${o.status})`);return}return o.text()}).then(o=>{if(o===void 0)return;const i=SOt({json:o,schema:n.store.schema});i.ok?(console.log("Loaded tldr file from local endpoint"),e(i.value)):console.error(`Couldn't parse tldr file: ${String(i.error.type)}`)}).catch(o=>{console.error("Couldn't fetch data:",o)}):(n.zoomToFit(),n.clearOpenMenus())}return h.jsx("div",{style:{inset:0,position:"fixed"},children:h.jsx(hOt,{assetUrls:Kpe(),onMount:r,store:t})})}NC.createRoot(document.querySelector("#root")).render(h.jsx(ze.StrictMode,{children:h.jsx(xOt,{})}));
|