@kitschpatrol/tldraw-cli 4.6.28 → 4.6.30
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 +118 -152
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +108 -148
- package/dist/lib/inline/get-image.d.ts +1 -1
- package/dist/lib/local-tldraw-server.d.ts +1 -1
- package/dist/lib/tldraw-controller.d.ts +9 -11
- package/dist/lib/tldraw-open.d.ts +3 -0
- package/dist/lib/tldraw-to-image.d.ts +4 -1
- package/dist/lib/validation.d.ts +3 -0
- package/dist/tldraw/assets/index-BkIYKf7d.css +1 -0
- package/dist/tldraw/assets/index-CLFDDK9V.js +423 -0
- package/dist/tldraw/index.html +2 -2
- package/dist/tldraw/translations/ar.json +91 -10
- package/dist/tldraw/translations/bn.json +376 -0
- package/dist/tldraw/translations/ca.json +91 -10
- package/dist/tldraw/translations/cs.json +65 -41
- package/dist/tldraw/translations/da.json +15 -36
- package/dist/tldraw/translations/de.json +80 -14
- package/dist/tldraw/translations/el.json +376 -0
- package/dist/tldraw/translations/es.json +87 -10
- package/dist/tldraw/translations/fa.json +13 -21
- package/dist/tldraw/translations/fi.json +84 -20
- package/dist/tldraw/translations/fr.json +25 -21
- package/dist/tldraw/translations/gl.json +45 -18
- package/dist/tldraw/translations/gu-in.json +376 -0
- package/dist/tldraw/translations/he.json +348 -58
- package/dist/tldraw/translations/hi-in.json +96 -10
- package/dist/tldraw/translations/hr.json +36 -18
- package/dist/tldraw/translations/hu.json +31 -20
- package/dist/tldraw/translations/id.json +117 -114
- package/dist/tldraw/translations/it.json +56 -10
- package/dist/tldraw/translations/ja.json +43 -18
- package/dist/tldraw/translations/km-kh.json +376 -0
- package/dist/tldraw/translations/kn.json +376 -0
- package/dist/tldraw/translations/ko-kr.json +3 -24
- package/dist/tldraw/translations/languages.json +56 -12
- package/dist/tldraw/translations/main.json +13 -34
- package/dist/tldraw/translations/ml.json +376 -0
- package/dist/tldraw/translations/mr.json +376 -0
- package/dist/tldraw/translations/ms.json +376 -0
- package/dist/tldraw/translations/ne.json +91 -10
- package/dist/tldraw/translations/nl.json +376 -0
- package/dist/tldraw/translations/no.json +334 -20
- package/dist/tldraw/translations/pa.json +376 -0
- package/dist/tldraw/translations/pl.json +36 -57
- package/dist/tldraw/translations/pt-br.json +279 -236
- package/dist/tldraw/translations/pt-pt.json +320 -30
- package/dist/tldraw/translations/ro.json +26 -21
- package/dist/tldraw/translations/ru.json +27 -26
- package/dist/tldraw/translations/sl.json +24 -21
- package/dist/tldraw/translations/so.json +14 -35
- package/dist/tldraw/translations/sv.json +330 -50
- package/dist/tldraw/translations/ta.json +376 -0
- package/dist/tldraw/translations/te.json +302 -38
- package/dist/tldraw/translations/th.json +95 -14
- package/dist/tldraw/translations/tl.json +376 -0
- package/dist/tldraw/translations/tr.json +44 -23
- package/dist/tldraw/translations/uk.json +25 -24
- package/dist/tldraw/translations/ur.json +376 -0
- package/dist/tldraw/translations/vi.json +101 -20
- package/dist/tldraw/translations/zh-cn.json +13 -23
- package/dist/tldraw/translations/zh-tw.json +53 -17
- package/license.txt +1 -1
- package/package.json +47 -37
- package/readme.md +36 -42
- package/dist/lib/tldraw-to-share-url.d.ts +0 -1
- package/dist/tldraw/assets/index-Cg19E2b-.js +0 -425
- package/dist/tldraw/assets/index-DZaxLi12.css +0 -1
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
var $4=Object.defineProperty;var F4=(t,e,n)=>e in t?$4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var I=(t,e,n)=>F4(t,typeof e!="symbol"?e+"":e,n);function N4(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}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 s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var g2={exports:{}},tg={},m2={exports:{}},Ie={};/**
|
|
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 Ju=Symbol.for("react.element"),z4=Symbol.for("react.portal"),B4=Symbol.for("react.fragment"),U4=Symbol.for("react.strict_mode"),H4=Symbol.for("react.profiler"),K4=Symbol.for("react.provider"),W4=Symbol.for("react.context"),G4=Symbol.for("react.forward_ref"),V4=Symbol.for("react.suspense"),Y4=Symbol.for("react.memo"),X4=Symbol.for("react.lazy"),SP=Symbol.iterator;function q4(t){return t===null||typeof t!="object"?null:(t=SP&&t[SP]||t["@@iterator"],typeof t=="function"?t:null)}var y2={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S2=Object.assign,v2={};function Ul(t,e,n){this.props=t,this.context=e,this.refs=v2,this.updater=n||y2}Ul.prototype.isReactComponent={};Ul.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")};Ul.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function x2(){}x2.prototype=Ul.prototype;function vw(t,e,n){this.props=t,this.context=e,this.refs=v2,this.updater=n||y2}var xw=vw.prototype=new x2;xw.constructor=vw;S2(xw,Ul.prototype);xw.isPureReactComponent=!0;var vP=Array.isArray,w2=Object.prototype.hasOwnProperty,ww={current:null},b2={key:!0,ref:!0,__self:!0,__source:!0};function P2(t,e,n){var r,s={},o=null,i=null;if(e!=null)for(r in e.ref!==void 0&&(i=e.ref),e.key!==void 0&&(o=""+e.key),e)w2.call(e,r)&&!b2.hasOwnProperty(r)&&(s[r]=e[r]);var a=arguments.length-2;if(a===1)s.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];s.children=l}if(t&&t.defaultProps)for(r in a=t.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:Ju,type:t,key:o,ref:i,props:s,_owner:ww.current}}function Z4(t,e){return{$$typeof:Ju,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function bw(t){return typeof t=="object"&&t!==null&&t.$$typeof===Ju}function Q4(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var xP=/\/+/g;function Fm(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Q4(""+t.key):e.toString(36)}function Kh(t,e,n,r,s){var o=typeof t;(o==="undefined"||o==="boolean")&&(t=null);var i=!1;if(t===null)i=!0;else switch(o){case"string":case"number":i=!0;break;case"object":switch(t.$$typeof){case Ju:case z4:i=!0}}if(i)return i=t,s=s(i),t=r===""?"."+Fm(i,0):r,vP(s)?(n="",t!=null&&(n=t.replace(xP,"$&/")+"/"),Kh(s,e,n,"",function(c){return c})):s!=null&&(bw(s)&&(s=Z4(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(xP,"$&/")+"/")+t)),e.push(s)),1;if(i=0,r=r===""?".":r+":",vP(t))for(var a=0;a<t.length;a++){o=t[a];var l=r+Fm(o,a);i+=Kh(o,e,n,l,s)}else if(l=q4(t),typeof l=="function")for(t=l.call(t),a=0;!(o=t.next()).done;)o=o.value,l=r+Fm(o,a++),i+=Kh(o,e,n,l,s);else if(o==="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 i}function Nd(t,e,n){if(t==null)return t;var r=[],s=0;return Kh(t,r,"","",function(o){return e.call(n,o,s++)}),r}function J4(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Cn={current:null},Wh={transition:null},e6={ReactCurrentDispatcher:Cn,ReactCurrentBatchConfig:Wh,ReactCurrentOwner:ww};function C2(){throw Error("act(...) is not supported in production builds of React.")}Ie.Children={map:Nd,forEach:function(t,e,n){Nd(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Nd(t,function(){e++}),e},toArray:function(t){return Nd(t,function(e){return e})||[]},only:function(t){if(!bw(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};Ie.Component=Ul;Ie.Fragment=B4;Ie.Profiler=H4;Ie.PureComponent=vw;Ie.StrictMode=U4;Ie.Suspense=V4;Ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=e6;Ie.act=C2;Ie.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=S2({},t.props),s=t.key,o=t.ref,i=t._owner;if(e!=null){if(e.ref!==void 0&&(o=e.ref,i=ww.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var a=t.type.defaultProps;for(l in e)w2.call(e,l)&&!b2.hasOwnProperty(l)&&(r[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:Ju,type:t.type,key:s,ref:o,props:r,_owner:i}};Ie.createContext=function(t){return t={$$typeof:W4,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:K4,_context:t},t.Consumer=t};Ie.createElement=P2;Ie.createFactory=function(t){var e=P2.bind(null,t);return e.type=t,e};Ie.createRef=function(){return{current:null}};Ie.forwardRef=function(t){return{$$typeof:G4,render:t}};Ie.isValidElement=bw;Ie.lazy=function(t){return{$$typeof:X4,_payload:{_status:-1,_result:t},_init:J4}};Ie.memo=function(t,e){return{$$typeof:Y4,type:t,compare:e===void 0?null:e}};Ie.startTransition=function(t){var e=Wh.transition;Wh.transition={};try{t()}finally{Wh.transition=e}};Ie.unstable_act=C2;Ie.useCallback=function(t,e){return Cn.current.useCallback(t,e)};Ie.useContext=function(t){return Cn.current.useContext(t)};Ie.useDebugValue=function(){};Ie.useDeferredValue=function(t){return Cn.current.useDeferredValue(t)};Ie.useEffect=function(t,e){return Cn.current.useEffect(t,e)};Ie.useId=function(){return Cn.current.useId()};Ie.useImperativeHandle=function(t,e,n){return Cn.current.useImperativeHandle(t,e,n)};Ie.useInsertionEffect=function(t,e){return Cn.current.useInsertionEffect(t,e)};Ie.useLayoutEffect=function(t,e){return Cn.current.useLayoutEffect(t,e)};Ie.useMemo=function(t,e){return Cn.current.useMemo(t,e)};Ie.useReducer=function(t,e,n){return Cn.current.useReducer(t,e,n)};Ie.useRef=function(t){return Cn.current.useRef(t)};Ie.useState=function(t){return Cn.current.useState(t)};Ie.useSyncExternalStore=function(t,e,n){return Cn.current.useSyncExternalStore(t,e,n)};Ie.useTransition=function(){return Cn.current.useTransition()};Ie.version="18.3.1";m2.exports=Ie;var w=m2.exports;const ke=wi(w),t6=N4({__proto__:null,default:ke},[w]);/**
|
|
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 n6=w,r6=Symbol.for("react.element"),s6=Symbol.for("react.fragment"),o6=Object.prototype.hasOwnProperty,i6=n6.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a6={key:!0,ref:!0,__self:!0,__source:!0};function _2(t,e,n){var r,s={},o=null,i=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(i=e.ref);for(r in e)o6.call(e,r)&&!a6.hasOwnProperty(r)&&(s[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)s[r]===void 0&&(s[r]=e[r]);return{$$typeof:r6,type:t,key:o,ref:i,props:s,_owner:i6.current}}tg.Fragment=s6;tg.jsx=_2;tg.jsxs=_2;g2.exports=tg;var d=g2.exports,QS={},I2={exports:{}},Sr={},E2={exports:{}},k2={};/**
|
|
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(R,H){var X=R.length;R.push(H);e:for(;0<X;){var te=X-1>>>1,le=R[te];if(0<s(le,H))R[te]=H,R[X]=le,X=te;else break e}}function n(R){return R.length===0?null:R[0]}function r(R){if(R.length===0)return null;var H=R[0],X=R.pop();if(X!==H){R[0]=X;e:for(var te=0,le=R.length,de=le>>>1;te<de;){var Me=2*(te+1)-1,oe=R[Me],Ue=Me+1,Ne=R[Ue];if(0>s(oe,X))Ue<le&&0>s(Ne,oe)?(R[te]=Ne,R[Ue]=X,te=Ue):(R[te]=oe,R[Me]=X,te=Me);else if(Ue<le&&0>s(Ne,X))R[te]=Ne,R[Ue]=X,te=Ue;else break e}}return H}function s(R,H){var X=R.sortIndex-H.sortIndex;return X!==0?X:R.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var i=Date,a=i.now();t.unstable_now=function(){return i.now()-a}}var l=[],c=[],u=1,h=null,f=3,p=!1,g=!1,m=!1,v=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,S=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(R){for(var H=n(c);H!==null;){if(H.callback===null)r(c);else if(H.startTime<=R)r(c),H.sortIndex=H.expirationTime,e(l,H);else break;H=n(c)}}function P(R){if(m=!1,b(R),!g)if(n(l)!==null)g=!0,B(C);else{var H=n(c);H!==null&&K(P,H.startTime-R)}}function C(R,H){g=!1,m&&(m=!1,y(k),k=-1),p=!0;var X=f;try{for(b(H),h=n(l);h!==null&&(!(h.expirationTime>H)||R&&!j());){var te=h.callback;if(typeof te=="function"){h.callback=null,f=h.priorityLevel;var le=te(h.expirationTime<=H);H=t.unstable_now(),typeof le=="function"?h.callback=le:h===n(l)&&r(l),b(H)}else r(l);h=n(l)}if(h!==null)var de=!0;else{var Me=n(c);Me!==null&&K(P,Me.startTime-H),de=!1}return de}finally{h=null,f=X,p=!1}}var _=!1,E=null,k=-1,D=5,T=-1;function j(){return!(t.unstable_now()-T<D)}function L(){if(E!==null){var R=t.unstable_now();T=R;var H=!0;try{H=E(!0,R)}finally{H?M():(_=!1,E=null)}}else _=!1}var M;if(typeof S=="function")M=function(){S(L)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,F=O.port2;O.port1.onmessage=L,M=function(){F.postMessage(null)}}else M=function(){v(L,0)};function B(R){E=R,_||(_=!0,M())}function K(R,H){k=v(function(){R(t.unstable_now())},H)}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(R){R.callback=null},t.unstable_continueExecution=function(){g||p||(g=!0,B(C))},t.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<R?Math.floor(1e3/R):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(R){switch(f){case 1:case 2:case 3:var H=3;break;default:H=f}var X=f;f=H;try{return R()}finally{f=X}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(R,H){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var X=f;f=R;try{return H()}finally{f=X}},t.unstable_scheduleCallback=function(R,H,X){var te=t.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?te+X:te):X=te,R){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=X+le,R={id:u++,callback:H,priorityLevel:R,startTime:X,expirationTime:le,sortIndex:-1},X>te?(R.sortIndex=X,e(c,R),n(l)===null&&R===n(c)&&(m?(y(k),k=-1):m=!0,K(P,X-te))):(R.sortIndex=le,e(l,R),g||p||(g=!0,B(C))),R},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(R){var H=f;return function(){var X=f;f=H;try{return R.apply(this,arguments)}finally{f=X}}}})(k2);E2.exports=k2;var l6=E2.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 c6=w,pr=l6;function Y(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);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 T2=new Set,yu={};function xa(t,e){Il(t,e),Il(t+"Capture",e)}function Il(t,e){for(yu[t]=e,t=0;t<e.length;t++)T2.add(e[t])}var So=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),JS=Object.prototype.hasOwnProperty,u6=/^[: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]*$/,wP={},bP={};function d6(t){return JS.call(bP,t)?!0:JS.call(wP,t)?!1:u6.test(t)?bP[t]=!0:(wP[t]=!0,!1)}function h6(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function f6(t,e,n,r){if(e===null||typeof e>"u"||h6(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 _n(t,e,n,r,s,o,i){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=i}var Xt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Xt[t]=new _n(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Xt[e]=new _n(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Xt[t]=new _n(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Xt[t]=new _n(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){Xt[t]=new _n(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Xt[t]=new _n(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Xt[t]=new _n(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Xt[t]=new _n(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Xt[t]=new _n(t,5,!1,t.toLowerCase(),null,!1,!1)});var Pw=/[\-:]([a-z])/g;function Cw(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(Pw,Cw);Xt[e]=new _n(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(Pw,Cw);Xt[e]=new _n(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(Pw,Cw);Xt[e]=new _n(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Xt[t]=new _n(t,1,!1,t.toLowerCase(),null,!1,!1)});Xt.xlinkHref=new _n("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Xt[t]=new _n(t,1,!1,t.toLowerCase(),null,!0,!0)});function _w(t,e,n,r){var s=Xt.hasOwnProperty(e)?Xt[e]:null;(s!==null?s.type!==0:r||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(f6(e,n,s,r)&&(n=null),r||s===null?d6(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):s.mustUseProperty?t[s.propertyName]=n===null?s.type===3?!1:"":n:(e=s.attributeName,r=s.attributeNamespace,n===null?t.removeAttribute(e):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?t.setAttributeNS(r,e,n):t.setAttribute(e,n))))}var _o=c6.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,zd=Symbol.for("react.element"),Ga=Symbol.for("react.portal"),Va=Symbol.for("react.fragment"),Iw=Symbol.for("react.strict_mode"),ev=Symbol.for("react.profiler"),M2=Symbol.for("react.provider"),A2=Symbol.for("react.context"),Ew=Symbol.for("react.forward_ref"),tv=Symbol.for("react.suspense"),nv=Symbol.for("react.suspense_list"),kw=Symbol.for("react.memo"),Ko=Symbol.for("react.lazy"),j2=Symbol.for("react.offscreen"),PP=Symbol.iterator;function fc(t){return t===null||typeof t!="object"?null:(t=PP&&t[PP]||t["@@iterator"],typeof t=="function"?t:null)}var gt=Object.assign,Nm;function Fc(t){if(Nm===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);Nm=e&&e[1]||""}return`
|
|
34
|
-
`+Nm+t}var zm=!1;function Bm(t,e){if(!t||zm)return"";zm=!0;var n=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 r=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){r=c}t.call(e.prototype)}else{try{throw Error()}catch(c){r=c}t()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var s=c.stack.split(`
|
|
35
|
-
`),o=r.stack.split(`
|
|
36
|
-
`),i=s.length-1,a=o.length-1;1<=i&&0<=a&&s[i]!==o[a];)a--;for(;1<=i&&0<=a;i--,a--)if(s[i]!==o[a]){if(i!==1||a!==1)do if(i--,a--,0>a||s[i]!==o[a]){var l=`
|
|
37
|
-
`+s[i].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=i&&0<=a);break}}}finally{zm=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Fc(t):""}function p6(t){switch(t.tag){case 5:return Fc(t.type);case 16:return Fc("Lazy");case 13:return Fc("Suspense");case 19:return Fc("SuspenseList");case 0:case 2:case 15:return t=Bm(t.type,!1),t;case 11:return t=Bm(t.type.render,!1),t;case 1:return t=Bm(t.type,!0),t;default:return""}}function rv(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 Va:return"Fragment";case Ga:return"Portal";case ev:return"Profiler";case Iw:return"StrictMode";case tv:return"Suspense";case nv:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case A2:return(t.displayName||"Context")+".Consumer";case M2:return(t._context.displayName||"Context")+".Provider";case Ew:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case kw:return e=t.displayName||null,e!==null?e:rv(t.type)||"Memo";case Ko:e=t._payload,t=t._init;try{return rv(t(e))}catch{}}return null}function g6(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 rv(e);case 8:return e===Iw?"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 fi(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function O2(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function m6(t){var e=O2(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Bd(t){t._valueTracker||(t._valueTracker=m6(t))}function D2(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=O2(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function zf(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 sv(t,e){var n=e.checked;return gt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function CP(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=fi(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function R2(t,e){e=e.checked,e!=null&&_w(t,"checked",e,!1)}function ov(t,e){R2(t,e);var n=fi(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?iv(t,e.type,n):e.hasOwnProperty("defaultValue")&&iv(t,e.type,fi(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function _P(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function iv(t,e,n){(e!=="number"||zf(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Nc=Array.isArray;function fl(t,e,n,r){if(t=t.options,e){e={};for(var s=0;s<n.length;s++)e["$"+n[s]]=!0;for(n=0;n<t.length;n++)s=e.hasOwnProperty("$"+t[n].value),t[n].selected!==s&&(t[n].selected=s),s&&r&&(t[n].defaultSelected=!0)}else{for(n=""+fi(n),e=null,s=0;s<t.length;s++){if(t[s].value===n){t[s].selected=!0,r&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function av(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(Y(91));return gt({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function IP(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(Y(92));if(Nc(n)){if(1<n.length)throw Error(Y(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:fi(n)}}function L2(t,e){var n=fi(e.value),r=fi(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),r!=null&&(t.defaultValue=""+r)}function EP(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function $2(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 lv(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?$2(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Ud,F2=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,s){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Ud=Ud||document.createElement("div"),Ud.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Ud.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Su(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Qc={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},y6=["Webkit","ms","Moz","O"];Object.keys(Qc).forEach(function(t){y6.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Qc[e]=Qc[t]})});function N2(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Qc.hasOwnProperty(t)&&Qc[t]?(""+e).trim():e+"px"}function z2(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=N2(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,s):t[n]=s}}var S6=gt({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 cv(t,e){if(e){if(S6[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Y(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Y(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Y(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Y(62))}}function uv(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 dv=null;function Tw(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var hv=null,pl=null,gl=null;function kP(t){if(t=nd(t)){if(typeof hv!="function")throw Error(Y(280));var e=t.stateNode;e&&(e=ig(e),hv(t.stateNode,t.type,e))}}function B2(t){pl?gl?gl.push(t):gl=[t]:pl=t}function U2(){if(pl){var t=pl,e=gl;if(gl=pl=null,kP(t),e)for(t=0;t<e.length;t++)kP(e[t])}}function H2(t,e){return t(e)}function K2(){}var Um=!1;function W2(t,e,n){if(Um)return t(e,n);Um=!0;try{return H2(t,e,n)}finally{Um=!1,(pl!==null||gl!==null)&&(K2(),U2())}}function vu(t,e){var n=t.stateNode;if(n===null)return null;var r=ig(n);if(r===null)return null;n=r[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":(r=!r.disabled)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(Y(231,e,typeof n));return n}var fv=!1;if(So)try{var pc={};Object.defineProperty(pc,"passive",{get:function(){fv=!0}}),window.addEventListener("test",pc,pc),window.removeEventListener("test",pc,pc)}catch{fv=!1}function v6(t,e,n,r,s,o,i,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(n,c)}catch(u){this.onError(u)}}var Jc=!1,Bf=null,Uf=!1,pv=null,x6={onError:function(t){Jc=!0,Bf=t}};function w6(t,e,n,r,s,o,i,a,l){Jc=!1,Bf=null,v6.apply(x6,arguments)}function b6(t,e,n,r,s,o,i,a,l){if(w6.apply(this,arguments),Jc){if(Jc){var c=Bf;Jc=!1,Bf=null}else throw Error(Y(198));Uf||(Uf=!0,pv=c)}}function wa(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function G2(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 TP(t){if(wa(t)!==t)throw Error(Y(188))}function P6(t){var e=t.alternate;if(!e){if(e=wa(t),e===null)throw Error(Y(188));return e!==t?null:t}for(var n=t,r=e;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return TP(s),t;if(o===r)return TP(s),e;o=o.sibling}throw Error(Y(188))}if(n.return!==r.return)n=s,r=o;else{for(var i=!1,a=s.child;a;){if(a===n){i=!0,n=s,r=o;break}if(a===r){i=!0,r=s,n=o;break}a=a.sibling}if(!i){for(a=o.child;a;){if(a===n){i=!0,n=o,r=s;break}if(a===r){i=!0,r=o,n=s;break}a=a.sibling}if(!i)throw Error(Y(189))}}if(n.alternate!==r)throw Error(Y(190))}if(n.tag!==3)throw Error(Y(188));return n.stateNode.current===n?t:e}function V2(t){return t=P6(t),t!==null?Y2(t):null}function Y2(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=Y2(t);if(e!==null)return e;t=t.sibling}return null}var X2=pr.unstable_scheduleCallback,MP=pr.unstable_cancelCallback,C6=pr.unstable_shouldYield,_6=pr.unstable_requestPaint,xt=pr.unstable_now,I6=pr.unstable_getCurrentPriorityLevel,Mw=pr.unstable_ImmediatePriority,q2=pr.unstable_UserBlockingPriority,Hf=pr.unstable_NormalPriority,E6=pr.unstable_LowPriority,Z2=pr.unstable_IdlePriority,ng=null,Ts=null;function k6(t){if(Ts&&typeof Ts.onCommitFiberRoot=="function")try{Ts.onCommitFiberRoot(ng,t,void 0,(t.current.flags&128)===128)}catch{}}var es=Math.clz32?Math.clz32:A6,T6=Math.log,M6=Math.LN2;function A6(t){return t>>>=0,t===0?32:31-(T6(t)/M6|0)|0}var Hd=64,Kd=4194304;function zc(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 Kf(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,s=t.suspendedLanes,o=t.pingedLanes,i=n&268435455;if(i!==0){var a=i&~s;a!==0?r=zc(a):(o&=i,o!==0&&(r=zc(o)))}else i=n&~s,i!==0?r=zc(i):o!==0&&(r=zc(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,o=e&-e,s>=o||s===16&&(o&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0<e;)n=31-es(e),s=1<<n,r|=t[n],e&=~s;return r}function j6(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 O6(t,e){for(var n=t.suspendedLanes,r=t.pingedLanes,s=t.expirationTimes,o=t.pendingLanes;0<o;){var i=31-es(o),a=1<<i,l=s[i];l===-1?(!(a&n)||a&r)&&(s[i]=j6(a,e)):l<=e&&(t.expiredLanes|=a),o&=~a}}function gv(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Q2(){var t=Hd;return Hd<<=1,!(Hd&4194240)&&(Hd=64),t}function Hm(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function ed(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-es(e),t[e]=n}function D6(t,e){var n=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 r=t.eventTimes;for(t=t.expirationTimes;0<n;){var s=31-es(n),o=1<<s;e[s]=0,r[s]=-1,t[s]=-1,n&=~o}}function Aw(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var r=31-es(n),s=1<<r;s&e|t[r]&e&&(t[r]|=e),n&=~s}}var Be=0;function J2(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var ek,jw,tk,nk,rk,mv=!1,Wd=[],ni=null,ri=null,si=null,xu=new Map,wu=new Map,Go=[],R6="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 AP(t,e){switch(t){case"focusin":case"focusout":ni=null;break;case"dragenter":case"dragleave":ri=null;break;case"mouseover":case"mouseout":si=null;break;case"pointerover":case"pointerout":xu.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":wu.delete(e.pointerId)}}function gc(t,e,n,r,s,o){return t===null||t.nativeEvent!==o?(t={blockedOn:e,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},e!==null&&(e=nd(e),e!==null&&jw(e)),t):(t.eventSystemFlags|=r,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function L6(t,e,n,r,s){switch(e){case"focusin":return ni=gc(ni,t,e,n,r,s),!0;case"dragenter":return ri=gc(ri,t,e,n,r,s),!0;case"mouseover":return si=gc(si,t,e,n,r,s),!0;case"pointerover":var o=s.pointerId;return xu.set(o,gc(xu.get(o)||null,t,e,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,wu.set(o,gc(wu.get(o)||null,t,e,n,r,s)),!0}return!1}function sk(t){var e=Gi(t.target);if(e!==null){var n=wa(e);if(n!==null){if(e=n.tag,e===13){if(e=G2(n),e!==null){t.blockedOn=e,rk(t.priority,function(){tk(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Gh(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=yv(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);dv=r,n.target.dispatchEvent(r),dv=null}else return e=nd(n),e!==null&&jw(e),t.blockedOn=n,!1;e.shift()}return!0}function jP(t,e,n){Gh(t)&&n.delete(e)}function $6(){mv=!1,ni!==null&&Gh(ni)&&(ni=null),ri!==null&&Gh(ri)&&(ri=null),si!==null&&Gh(si)&&(si=null),xu.forEach(jP),wu.forEach(jP)}function mc(t,e){t.blockedOn===e&&(t.blockedOn=null,mv||(mv=!0,pr.unstable_scheduleCallback(pr.unstable_NormalPriority,$6)))}function bu(t){function e(s){return mc(s,t)}if(0<Wd.length){mc(Wd[0],t);for(var n=1;n<Wd.length;n++){var r=Wd[n];r.blockedOn===t&&(r.blockedOn=null)}}for(ni!==null&&mc(ni,t),ri!==null&&mc(ri,t),si!==null&&mc(si,t),xu.forEach(e),wu.forEach(e),n=0;n<Go.length;n++)r=Go[n],r.blockedOn===t&&(r.blockedOn=null);for(;0<Go.length&&(n=Go[0],n.blockedOn===null);)sk(n),n.blockedOn===null&&Go.shift()}var ml=_o.ReactCurrentBatchConfig,Wf=!0;function F6(t,e,n,r){var s=Be,o=ml.transition;ml.transition=null;try{Be=1,Ow(t,e,n,r)}finally{Be=s,ml.transition=o}}function N6(t,e,n,r){var s=Be,o=ml.transition;ml.transition=null;try{Be=4,Ow(t,e,n,r)}finally{Be=s,ml.transition=o}}function Ow(t,e,n,r){if(Wf){var s=yv(t,e,n,r);if(s===null)Jm(t,e,r,Gf,n),AP(t,r);else if(L6(s,t,e,n,r))r.stopPropagation();else if(AP(t,r),e&4&&-1<R6.indexOf(t)){for(;s!==null;){var o=nd(s);if(o!==null&&ek(o),o=yv(t,e,n,r),o===null&&Jm(t,e,r,Gf,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else Jm(t,e,r,null,n)}}var Gf=null;function yv(t,e,n,r){if(Gf=null,t=Tw(r),t=Gi(t),t!==null)if(e=wa(t),e===null)t=null;else if(n=e.tag,n===13){if(t=G2(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return Gf=t,null}function ok(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(I6()){case Mw:return 1;case q2:return 4;case Hf:case E6:return 16;case Z2:return 536870912;default:return 16}default:return 16}}var Zo=null,Dw=null,Vh=null;function ik(){if(Vh)return Vh;var t,e=Dw,n=e.length,r,s="value"in Zo?Zo.value:Zo.textContent,o=s.length;for(t=0;t<n&&e[t]===s[t];t++);var i=n-t;for(r=1;r<=i&&e[n-r]===s[o-r];r++);return Vh=s.slice(t,1<r?1-r:void 0)}function Yh(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 Gd(){return!0}function OP(){return!1}function vr(t){function e(n,r,s,o,i){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=i,this.currentTarget=null;for(var a in t)t.hasOwnProperty(a)&&(n=t[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Gd:OP,this.isPropagationStopped=OP,this}return gt(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Gd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Gd)},persist:function(){},isPersistent:Gd}),e}var Hl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Rw=vr(Hl),td=gt({},Hl,{view:0,detail:0}),z6=vr(td),Km,Wm,yc,rg=gt({},td,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lw,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!==yc&&(yc&&t.type==="mousemove"?(Km=t.screenX-yc.screenX,Wm=t.screenY-yc.screenY):Wm=Km=0,yc=t),Km)},movementY:function(t){return"movementY"in t?t.movementY:Wm}}),DP=vr(rg),B6=gt({},rg,{dataTransfer:0}),U6=vr(B6),H6=gt({},td,{relatedTarget:0}),Gm=vr(H6),K6=gt({},Hl,{animationName:0,elapsedTime:0,pseudoElement:0}),W6=vr(K6),G6=gt({},Hl,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),V6=vr(G6),Y6=gt({},Hl,{data:0}),RP=vr(Y6),X6={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},q6={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"},Z6={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Q6(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=Z6[t])?!!e[t]:!1}function Lw(){return Q6}var J6=gt({},td,{key:function(t){if(t.key){var e=X6[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Yh(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?q6[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lw,charCode:function(t){return t.type==="keypress"?Yh(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Yh(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),ez=vr(J6),tz=gt({},rg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),LP=vr(tz),nz=gt({},td,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lw}),rz=vr(nz),sz=gt({},Hl,{propertyName:0,elapsedTime:0,pseudoElement:0}),oz=vr(sz),iz=gt({},rg,{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}),az=vr(iz),lz=[9,13,27,32],$w=So&&"CompositionEvent"in window,eu=null;So&&"documentMode"in document&&(eu=document.documentMode);var cz=So&&"TextEvent"in window&&!eu,ak=So&&(!$w||eu&&8<eu&&11>=eu),$P=" ",FP=!1;function lk(t,e){switch(t){case"keyup":return lz.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ck(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ya=!1;function uz(t,e){switch(t){case"compositionend":return ck(e);case"keypress":return e.which!==32?null:(FP=!0,$P);case"textInput":return t=e.data,t===$P&&FP?null:t;default:return null}}function dz(t,e){if(Ya)return t==="compositionend"||!$w&&lk(t,e)?(t=ik(),Vh=Dw=Zo=null,Ya=!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 ak&&e.locale!=="ko"?null:e.data;default:return null}}var hz={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 NP(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!hz[t.type]:e==="textarea"}function uk(t,e,n,r){B2(r),e=Vf(e,"onChange"),0<e.length&&(n=new Rw("onChange","change",null,n,r),t.push({event:n,listeners:e}))}var tu=null,Pu=null;function fz(t){wk(t,0)}function sg(t){var e=Za(t);if(D2(e))return t}function pz(t,e){if(t==="change")return e}var dk=!1;if(So){var Vm;if(So){var Ym="oninput"in document;if(!Ym){var zP=document.createElement("div");zP.setAttribute("oninput","return;"),Ym=typeof zP.oninput=="function"}Vm=Ym}else Vm=!1;dk=Vm&&(!document.documentMode||9<document.documentMode)}function BP(){tu&&(tu.detachEvent("onpropertychange",hk),Pu=tu=null)}function hk(t){if(t.propertyName==="value"&&sg(Pu)){var e=[];uk(e,Pu,t,Tw(t)),W2(fz,e)}}function gz(t,e,n){t==="focusin"?(BP(),tu=e,Pu=n,tu.attachEvent("onpropertychange",hk)):t==="focusout"&&BP()}function mz(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return sg(Pu)}function yz(t,e){if(t==="click")return sg(e)}function Sz(t,e){if(t==="input"||t==="change")return sg(e)}function vz(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var os=typeof Object.is=="function"?Object.is:vz;function Cu(t,e){if(os(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!JS.call(e,s)||!os(t[s],e[s]))return!1}return!0}function UP(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function HP(t,e){var n=UP(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=e&&r>=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=UP(n)}}function fk(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?fk(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function pk(){for(var t=window,e=zf();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=zf(t.document)}return e}function Fw(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 xz(t){var e=pk(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&fk(n.ownerDocument.documentElement,n)){if(r!==null&&Fw(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!t.extend&&o>r&&(s=r,r=o,o=s),s=HP(n,o);var i=HP(n,r);s&&i&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==i.node||t.focusOffset!==i.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),o>r?(t.addRange(e),t.extend(i.node,i.offset)):(e.setEnd(i.node,i.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var wz=So&&"documentMode"in document&&11>=document.documentMode,Xa=null,Sv=null,nu=null,vv=!1;function KP(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;vv||Xa==null||Xa!==zf(r)||(r=Xa,"selectionStart"in r&&Fw(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),nu&&Cu(nu,r)||(nu=r,r=Vf(Sv,"onSelect"),0<r.length&&(e=new Rw("onSelect","select",null,e,n),t.push({event:e,listeners:r}),e.target=Xa)))}function Vd(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var qa={animationend:Vd("Animation","AnimationEnd"),animationiteration:Vd("Animation","AnimationIteration"),animationstart:Vd("Animation","AnimationStart"),transitionend:Vd("Transition","TransitionEnd")},Xm={},gk={};So&&(gk=document.createElement("div").style,"AnimationEvent"in window||(delete qa.animationend.animation,delete qa.animationiteration.animation,delete qa.animationstart.animation),"TransitionEvent"in window||delete qa.transitionend.transition);function og(t){if(Xm[t])return Xm[t];if(!qa[t])return t;var e=qa[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in gk)return Xm[t]=e[n];return t}var mk=og("animationend"),yk=og("animationiteration"),Sk=og("animationstart"),vk=og("transitionend"),xk=new Map,WP="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 bi(t,e){xk.set(t,e),xa(e,[t])}for(var qm=0;qm<WP.length;qm++){var Zm=WP[qm],bz=Zm.toLowerCase(),Pz=Zm[0].toUpperCase()+Zm.slice(1);bi(bz,"on"+Pz)}bi(mk,"onAnimationEnd");bi(yk,"onAnimationIteration");bi(Sk,"onAnimationStart");bi("dblclick","onDoubleClick");bi("focusin","onFocus");bi("focusout","onBlur");bi(vk,"onTransitionEnd");Il("onMouseEnter",["mouseout","mouseover"]);Il("onMouseLeave",["mouseout","mouseover"]);Il("onPointerEnter",["pointerout","pointerover"]);Il("onPointerLeave",["pointerout","pointerover"]);xa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));xa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));xa("onBeforeInput",["compositionend","keypress","textInput","paste"]);xa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));xa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));xa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bc="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(" "),Cz=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bc));function GP(t,e,n){var r=t.type||"unknown-event";t.currentTarget=n,b6(r,e,void 0,t),t.currentTarget=null}function wk(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],s=r.event;r=r.listeners;e:{var o=void 0;if(e)for(var i=r.length-1;0<=i;i--){var a=r[i],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==o&&s.isPropagationStopped())break e;GP(s,a,c),o=l}else for(i=0;i<r.length;i++){if(a=r[i],l=a.instance,c=a.currentTarget,a=a.listener,l!==o&&s.isPropagationStopped())break e;GP(s,a,c),o=l}}}if(Uf)throw t=pv,Uf=!1,pv=null,t}function tt(t,e){var n=e[Cv];n===void 0&&(n=e[Cv]=new Set);var r=t+"__bubble";n.has(r)||(bk(e,t,2,!1),n.add(r))}function Qm(t,e,n){var r=0;e&&(r|=4),bk(n,t,r,e)}var Yd="_reactListening"+Math.random().toString(36).slice(2);function _u(t){if(!t[Yd]){t[Yd]=!0,T2.forEach(function(n){n!=="selectionchange"&&(Cz.has(n)||Qm(n,!1,t),Qm(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[Yd]||(e[Yd]=!0,Qm("selectionchange",!1,e))}}function bk(t,e,n,r){switch(ok(e)){case 1:var s=F6;break;case 4:s=N6;break;default:s=Ow}n=s.bind(null,e,n,t),s=void 0,!fv||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),r?s!==void 0?t.addEventListener(e,n,{capture:!0,passive:s}):t.addEventListener(e,n,!0):s!==void 0?t.addEventListener(e,n,{passive:s}):t.addEventListener(e,n,!1)}function Jm(t,e,n,r,s){var o=r;if(!(e&1)&&!(e&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var a=r.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(i===4)for(i=r.return;i!==null;){var l=i.tag;if((l===3||l===4)&&(l=i.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;i=i.return}for(;a!==null;){if(i=Gi(a),i===null)return;if(l=i.tag,l===5||l===6){r=o=i;continue e}a=a.parentNode}}r=r.return}W2(function(){var c=o,u=Tw(n),h=[];e:{var f=xk.get(t);if(f!==void 0){var p=Rw,g=t;switch(t){case"keypress":if(Yh(n)===0)break e;case"keydown":case"keyup":p=ez;break;case"focusin":g="focus",p=Gm;break;case"focusout":g="blur",p=Gm;break;case"beforeblur":case"afterblur":p=Gm;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=DP;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=U6;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=rz;break;case mk:case yk:case Sk:p=W6;break;case vk:p=oz;break;case"scroll":p=z6;break;case"wheel":p=az;break;case"copy":case"cut":case"paste":p=V6;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=LP}var m=(e&4)!==0,v=!m&&t==="scroll",y=m?f!==null?f+"Capture":null:f;m=[];for(var S=c,b;S!==null;){b=S;var P=b.stateNode;if(b.tag===5&&P!==null&&(b=P,y!==null&&(P=vu(S,y),P!=null&&m.push(Iu(S,P,b)))),v)break;S=S.return}0<m.length&&(f=new p(f,g,null,n,u),h.push({event:f,listeners:m}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",p=t==="mouseout"||t==="pointerout",f&&n!==dv&&(g=n.relatedTarget||n.fromElement)&&(Gi(g)||g[vo]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(g=n.relatedTarget||n.toElement,p=c,g=g?Gi(g):null,g!==null&&(v=wa(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=c),p!==g)){if(m=DP,P="onMouseLeave",y="onMouseEnter",S="mouse",(t==="pointerout"||t==="pointerover")&&(m=LP,P="onPointerLeave",y="onPointerEnter",S="pointer"),v=p==null?f:Za(p),b=g==null?f:Za(g),f=new m(P,S+"leave",p,n,u),f.target=v,f.relatedTarget=b,P=null,Gi(u)===c&&(m=new m(y,S+"enter",g,n,u),m.target=b,m.relatedTarget=v,P=m),v=P,p&&g)t:{for(m=p,y=g,S=0,b=m;b;b=Ma(b))S++;for(b=0,P=y;P;P=Ma(P))b++;for(;0<S-b;)m=Ma(m),S--;for(;0<b-S;)y=Ma(y),b--;for(;S--;){if(m===y||y!==null&&m===y.alternate)break t;m=Ma(m),y=Ma(y)}m=null}else m=null;p!==null&&VP(h,f,p,m,!1),g!==null&&v!==null&&VP(h,v,g,m,!0)}}e:{if(f=c?Za(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var C=pz;else if(NP(f))if(dk)C=Sz;else{C=mz;var _=gz}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(C=yz);if(C&&(C=C(t,c))){uk(h,C,n,u);break e}_&&_(t,f,c),t==="focusout"&&(_=f._wrapperState)&&_.controlled&&f.type==="number"&&iv(f,"number",f.value)}switch(_=c?Za(c):window,t){case"focusin":(NP(_)||_.contentEditable==="true")&&(Xa=_,Sv=c,nu=null);break;case"focusout":nu=Sv=Xa=null;break;case"mousedown":vv=!0;break;case"contextmenu":case"mouseup":case"dragend":vv=!1,KP(h,n,u);break;case"selectionchange":if(wz)break;case"keydown":case"keyup":KP(h,n,u)}var E;if($w)e:{switch(t){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Ya?lk(t,n)&&(k="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(ak&&n.locale!=="ko"&&(Ya||k!=="onCompositionStart"?k==="onCompositionEnd"&&Ya&&(E=ik()):(Zo=u,Dw="value"in Zo?Zo.value:Zo.textContent,Ya=!0)),_=Vf(c,k),0<_.length&&(k=new RP(k,t,null,n,u),h.push({event:k,listeners:_}),E?k.data=E:(E=ck(n),E!==null&&(k.data=E)))),(E=cz?uz(t,n):dz(t,n))&&(c=Vf(c,"onBeforeInput"),0<c.length&&(u=new RP("onBeforeInput","beforeinput",null,n,u),h.push({event:u,listeners:c}),u.data=E))}wk(h,e)})}function Iu(t,e,n){return{instance:t,listener:e,currentTarget:n}}function Vf(t,e){for(var n=e+"Capture",r=[];t!==null;){var s=t,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=vu(t,n),o!=null&&r.unshift(Iu(t,o,s)),o=vu(t,e),o!=null&&r.push(Iu(t,o,s))),t=t.return}return r}function Ma(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function VP(t,e,n,r,s){for(var o=e._reactName,i=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,s?(l=vu(n,o),l!=null&&i.unshift(Iu(n,l,a))):s||(l=vu(n,o),l!=null&&i.push(Iu(n,l,a)))),n=n.return}i.length!==0&&t.push({event:e,listeners:i})}var _z=/\r\n?/g,Iz=/\u0000|\uFFFD/g;function YP(t){return(typeof t=="string"?t:""+t).replace(_z,`
|
|
38
|
-
`).replace(Iz,"")}function Xd(t,e,n){if(e=YP(e),YP(t)!==e&&n)throw Error(Y(425))}function Yf(){}var xv=null,wv=null;function bv(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 Pv=typeof setTimeout=="function"?setTimeout:void 0,Ez=typeof clearTimeout=="function"?clearTimeout:void 0,XP=typeof Promise=="function"?Promise:void 0,kz=typeof queueMicrotask=="function"?queueMicrotask:typeof XP<"u"?function(t){return XP.resolve(null).then(t).catch(Tz)}:Pv;function Tz(t){setTimeout(function(){throw t})}function ey(t,e){var n=e,r=0;do{var s=n.nextSibling;if(t.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){t.removeChild(s),bu(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);bu(e)}function oi(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 qP(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var Kl=Math.random().toString(36).slice(2),bs="__reactFiber$"+Kl,Eu="__reactProps$"+Kl,vo="__reactContainer$"+Kl,Cv="__reactEvents$"+Kl,Mz="__reactListeners$"+Kl,Az="__reactHandles$"+Kl;function Gi(t){var e=t[bs];if(e)return e;for(var n=t.parentNode;n;){if(e=n[vo]||n[bs]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=qP(t);t!==null;){if(n=t[bs])return n;t=qP(t)}return e}t=n,n=t.parentNode}return null}function nd(t){return t=t[bs]||t[vo],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Za(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(Y(33))}function ig(t){return t[Eu]||null}var _v=[],Qa=-1;function Pi(t){return{current:t}}function rt(t){0>Qa||(t.current=_v[Qa],_v[Qa]=null,Qa--)}function qe(t,e){Qa++,_v[Qa]=t.current,t.current=e}var pi={},gn=Pi(pi),Gn=Pi(!1),na=pi;function El(t,e){var n=t.type.contextTypes;if(!n)return pi;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=e[o];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Vn(t){return t=t.childContextTypes,t!=null}function Xf(){rt(Gn),rt(gn)}function ZP(t,e,n){if(gn.current!==pi)throw Error(Y(168));qe(gn,e),qe(Gn,n)}function Pk(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(Y(108,g6(t)||"Unknown",s));return gt({},n,r)}function qf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||pi,na=gn.current,qe(gn,t),qe(Gn,Gn.current),!0}function QP(t,e,n){var r=t.stateNode;if(!r)throw Error(Y(169));n?(t=Pk(t,e,na),r.__reactInternalMemoizedMergedChildContext=t,rt(Gn),rt(gn),qe(gn,t)):rt(Gn),qe(Gn,n)}var oo=null,ag=!1,ty=!1;function Ck(t){oo===null?oo=[t]:oo.push(t)}function jz(t){ag=!0,Ck(t)}function Ci(){if(!ty&&oo!==null){ty=!0;var t=0,e=Be;try{var n=oo;for(Be=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}oo=null,ag=!1}catch(s){throw oo!==null&&(oo=oo.slice(t+1)),X2(Mw,Ci),s}finally{Be=e,ty=!1}}return null}var Ja=[],el=0,Zf=null,Qf=0,kr=[],Tr=0,ra=null,ao=1,lo="";function Ui(t,e){Ja[el++]=Qf,Ja[el++]=Zf,Zf=t,Qf=e}function _k(t,e,n){kr[Tr++]=ao,kr[Tr++]=lo,kr[Tr++]=ra,ra=t;var r=ao;t=lo;var s=32-es(r)-1;r&=~(1<<s),n+=1;var o=32-es(e)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,ao=1<<32-es(e)+s|n<<s|r,lo=o+t}else ao=1<<o|n<<s|r,lo=t}function Nw(t){t.return!==null&&(Ui(t,1),_k(t,1,0))}function zw(t){for(;t===Zf;)Zf=Ja[--el],Ja[el]=null,Qf=Ja[--el],Ja[el]=null;for(;t===ra;)ra=kr[--Tr],kr[Tr]=null,lo=kr[--Tr],kr[Tr]=null,ao=kr[--Tr],kr[Tr]=null}var cr=null,ir=null,at=!1,Yr=null;function Ik(t,e){var n=Ar(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function JP(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,cr=t,ir=oi(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,cr=t,ir=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=ra!==null?{id:ao,overflow:lo}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Ar(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,cr=t,ir=null,!0):!1;default:return!1}}function Iv(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Ev(t){if(at){var e=ir;if(e){var n=e;if(!JP(t,e)){if(Iv(t))throw Error(Y(418));e=oi(n.nextSibling);var r=cr;e&&JP(t,e)?Ik(r,n):(t.flags=t.flags&-4097|2,at=!1,cr=t)}}else{if(Iv(t))throw Error(Y(418));t.flags=t.flags&-4097|2,at=!1,cr=t}}}function eC(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;cr=t}function qd(t){if(t!==cr)return!1;if(!at)return eC(t),at=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!bv(t.type,t.memoizedProps)),e&&(e=ir)){if(Iv(t))throw Ek(),Error(Y(418));for(;e;)Ik(t,e),e=oi(e.nextSibling)}if(eC(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Y(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){ir=oi(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}ir=null}}else ir=cr?oi(t.stateNode.nextSibling):null;return!0}function Ek(){for(var t=ir;t;)t=oi(t.nextSibling)}function kl(){ir=cr=null,at=!1}function Bw(t){Yr===null?Yr=[t]:Yr.push(t)}var Oz=_o.ReactCurrentBatchConfig;function Sc(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Y(309));var r=n.stateNode}if(!r)throw Error(Y(147,t));var s=r,o=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===o?e.ref:(e=function(i){var a=s.refs;i===null?delete a[o]:a[o]=i},e._stringRef=o,e)}if(typeof t!="string")throw Error(Y(284));if(!n._owner)throw Error(Y(290,t))}return t}function Zd(t,e){throw t=Object.prototype.toString.call(e),Error(Y(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function tC(t){var e=t._init;return e(t._payload)}function kk(t){function e(y,S){if(t){var b=y.deletions;b===null?(y.deletions=[S],y.flags|=16):b.push(S)}}function n(y,S){if(!t)return null;for(;S!==null;)e(y,S),S=S.sibling;return null}function r(y,S){for(y=new Map;S!==null;)S.key!==null?y.set(S.key,S):y.set(S.index,S),S=S.sibling;return y}function s(y,S){return y=ci(y,S),y.index=0,y.sibling=null,y}function o(y,S,b){return y.index=b,t?(b=y.alternate,b!==null?(b=b.index,b<S?(y.flags|=2,S):b):(y.flags|=2,S)):(y.flags|=1048576,S)}function i(y){return t&&y.alternate===null&&(y.flags|=2),y}function a(y,S,b,P){return S===null||S.tag!==6?(S=ly(b,y.mode,P),S.return=y,S):(S=s(S,b),S.return=y,S)}function l(y,S,b,P){var C=b.type;return C===Va?u(y,S,b.props.children,P,b.key):S!==null&&(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Ko&&tC(C)===S.type)?(P=s(S,b.props),P.ref=Sc(y,S,b),P.return=y,P):(P=tf(b.type,b.key,b.props,null,y.mode,P),P.ref=Sc(y,S,b),P.return=y,P)}function c(y,S,b,P){return S===null||S.tag!==4||S.stateNode.containerInfo!==b.containerInfo||S.stateNode.implementation!==b.implementation?(S=cy(b,y.mode,P),S.return=y,S):(S=s(S,b.children||[]),S.return=y,S)}function u(y,S,b,P,C){return S===null||S.tag!==7?(S=Zi(b,y.mode,P,C),S.return=y,S):(S=s(S,b),S.return=y,S)}function h(y,S,b){if(typeof S=="string"&&S!==""||typeof S=="number")return S=ly(""+S,y.mode,b),S.return=y,S;if(typeof S=="object"&&S!==null){switch(S.$$typeof){case zd:return b=tf(S.type,S.key,S.props,null,y.mode,b),b.ref=Sc(y,null,S),b.return=y,b;case Ga:return S=cy(S,y.mode,b),S.return=y,S;case Ko:var P=S._init;return h(y,P(S._payload),b)}if(Nc(S)||fc(S))return S=Zi(S,y.mode,b,null),S.return=y,S;Zd(y,S)}return null}function f(y,S,b,P){var C=S!==null?S.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return C!==null?null:a(y,S,""+b,P);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case zd:return b.key===C?l(y,S,b,P):null;case Ga:return b.key===C?c(y,S,b,P):null;case Ko:return C=b._init,f(y,S,C(b._payload),P)}if(Nc(b)||fc(b))return C!==null?null:u(y,S,b,P,null);Zd(y,b)}return null}function p(y,S,b,P,C){if(typeof P=="string"&&P!==""||typeof P=="number")return y=y.get(b)||null,a(S,y,""+P,C);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case zd:return y=y.get(P.key===null?b:P.key)||null,l(S,y,P,C);case Ga:return y=y.get(P.key===null?b:P.key)||null,c(S,y,P,C);case Ko:var _=P._init;return p(y,S,b,_(P._payload),C)}if(Nc(P)||fc(P))return y=y.get(b)||null,u(S,y,P,C,null);Zd(S,P)}return null}function g(y,S,b,P){for(var C=null,_=null,E=S,k=S=0,D=null;E!==null&&k<b.length;k++){E.index>k?(D=E,E=null):D=E.sibling;var T=f(y,E,b[k],P);if(T===null){E===null&&(E=D);break}t&&E&&T.alternate===null&&e(y,E),S=o(T,S,k),_===null?C=T:_.sibling=T,_=T,E=D}if(k===b.length)return n(y,E),at&&Ui(y,k),C;if(E===null){for(;k<b.length;k++)E=h(y,b[k],P),E!==null&&(S=o(E,S,k),_===null?C=E:_.sibling=E,_=E);return at&&Ui(y,k),C}for(E=r(y,E);k<b.length;k++)D=p(E,y,k,b[k],P),D!==null&&(t&&D.alternate!==null&&E.delete(D.key===null?k:D.key),S=o(D,S,k),_===null?C=D:_.sibling=D,_=D);return t&&E.forEach(function(j){return e(y,j)}),at&&Ui(y,k),C}function m(y,S,b,P){var C=fc(b);if(typeof C!="function")throw Error(Y(150));if(b=C.call(b),b==null)throw Error(Y(151));for(var _=C=null,E=S,k=S=0,D=null,T=b.next();E!==null&&!T.done;k++,T=b.next()){E.index>k?(D=E,E=null):D=E.sibling;var j=f(y,E,T.value,P);if(j===null){E===null&&(E=D);break}t&&E&&j.alternate===null&&e(y,E),S=o(j,S,k),_===null?C=j:_.sibling=j,_=j,E=D}if(T.done)return n(y,E),at&&Ui(y,k),C;if(E===null){for(;!T.done;k++,T=b.next())T=h(y,T.value,P),T!==null&&(S=o(T,S,k),_===null?C=T:_.sibling=T,_=T);return at&&Ui(y,k),C}for(E=r(y,E);!T.done;k++,T=b.next())T=p(E,y,k,T.value,P),T!==null&&(t&&T.alternate!==null&&E.delete(T.key===null?k:T.key),S=o(T,S,k),_===null?C=T:_.sibling=T,_=T);return t&&E.forEach(function(L){return e(y,L)}),at&&Ui(y,k),C}function v(y,S,b,P){if(typeof b=="object"&&b!==null&&b.type===Va&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case zd:e:{for(var C=b.key,_=S;_!==null;){if(_.key===C){if(C=b.type,C===Va){if(_.tag===7){n(y,_.sibling),S=s(_,b.props.children),S.return=y,y=S;break e}}else if(_.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Ko&&tC(C)===_.type){n(y,_.sibling),S=s(_,b.props),S.ref=Sc(y,_,b),S.return=y,y=S;break e}n(y,_);break}else e(y,_);_=_.sibling}b.type===Va?(S=Zi(b.props.children,y.mode,P,b.key),S.return=y,y=S):(P=tf(b.type,b.key,b.props,null,y.mode,P),P.ref=Sc(y,S,b),P.return=y,y=P)}return i(y);case Ga:e:{for(_=b.key;S!==null;){if(S.key===_)if(S.tag===4&&S.stateNode.containerInfo===b.containerInfo&&S.stateNode.implementation===b.implementation){n(y,S.sibling),S=s(S,b.children||[]),S.return=y,y=S;break e}else{n(y,S);break}else e(y,S);S=S.sibling}S=cy(b,y.mode,P),S.return=y,y=S}return i(y);case Ko:return _=b._init,v(y,S,_(b._payload),P)}if(Nc(b))return g(y,S,b,P);if(fc(b))return m(y,S,b,P);Zd(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,S!==null&&S.tag===6?(n(y,S.sibling),S=s(S,b),S.return=y,y=S):(n(y,S),S=ly(b,y.mode,P),S.return=y,y=S),i(y)):n(y,S)}return v}var Tl=kk(!0),Tk=kk(!1),Jf=Pi(null),ep=null,tl=null,Uw=null;function Hw(){Uw=tl=ep=null}function Kw(t){var e=Jf.current;rt(Jf),t._currentValue=e}function kv(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function yl(t,e){ep=t,Uw=tl=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Hn=!0),t.firstContext=null)}function Rr(t){var e=t._currentValue;if(Uw!==t)if(t={context:t,memoizedValue:e,next:null},tl===null){if(ep===null)throw Error(Y(308));tl=t,ep.dependencies={lanes:0,firstContext:t}}else tl=tl.next=t;return e}var Vi=null;function Ww(t){Vi===null?Vi=[t]:Vi.push(t)}function Mk(t,e,n,r){var s=e.interleaved;return s===null?(n.next=n,Ww(e)):(n.next=s.next,s.next=n),e.interleaved=n,xo(t,r)}function xo(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Wo=!1;function Gw(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ak(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 ho(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ii(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Oe&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,xo(t,n)}return s=r.interleaved,s===null?(e.next=e,Ww(r)):(e.next=s.next,s.next=e),r.interleaved=e,xo(t,n)}function Xh(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Aw(t,n)}}function nC(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?s=o=e:o=o.next=e}else s=o=e;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function tp(t,e,n,r){var s=t.updateQueue;Wo=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,c=l.next;l.next=null,i===null?o=c:i.next=c,i=l;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(o!==null){var h=s.baseState;i=0,u=c=l=null,a=o;do{var f=a.lane,p=a.eventTime;if((r&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=n,m.tag){case 1:if(g=m.payload,typeof g=="function"){h=g.call(p,h,f);break e}h=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=m.payload,f=typeof g=="function"?g.call(p,h,f):g,f==null)break e;h=gt({},h,f);break e;case 2:Wo=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.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=h):u=u.next=p,i|=f;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;f=a,a=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(u===null&&(l=h),s.baseState=l,s.firstBaseUpdate=c,s.lastBaseUpdate=u,e=s.shared.interleaved,e!==null){s=e;do i|=s.lane,s=s.next;while(s!==e)}else o===null&&(s.shared.lanes=0);oa|=i,t.lanes=i,t.memoizedState=h}}function rC(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var r=t[e],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(Y(191,s));s.call(r)}}}var rd={},Ms=Pi(rd),ku=Pi(rd),Tu=Pi(rd);function Yi(t){if(t===rd)throw Error(Y(174));return t}function Vw(t,e){switch(qe(Tu,e),qe(ku,t),qe(Ms,rd),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:lv(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=lv(e,t)}rt(Ms),qe(Ms,e)}function Ml(){rt(Ms),rt(ku),rt(Tu)}function jk(t){Yi(Tu.current);var e=Yi(Ms.current),n=lv(e,t.type);e!==n&&(qe(ku,t),qe(Ms,n))}function Yw(t){ku.current===t&&(rt(Ms),rt(ku))}var dt=Pi(0);function np(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.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 ny=[];function Xw(){for(var t=0;t<ny.length;t++)ny[t]._workInProgressVersionPrimary=null;ny.length=0}var qh=_o.ReactCurrentDispatcher,ry=_o.ReactCurrentBatchConfig,sa=0,pt=null,Et=null,jt=null,rp=!1,ru=!1,Mu=0,Dz=0;function tn(){throw Error(Y(321))}function qw(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!os(t[n],e[n]))return!1;return!0}function Zw(t,e,n,r,s,o){if(sa=o,pt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,qh.current=t===null||t.memoizedState===null?Fz:Nz,t=n(r,s),ru){o=0;do{if(ru=!1,Mu=0,25<=o)throw Error(Y(301));o+=1,jt=Et=null,e.updateQueue=null,qh.current=zz,t=n(r,s)}while(ru)}if(qh.current=sp,e=Et!==null&&Et.next!==null,sa=0,jt=Et=pt=null,rp=!1,e)throw Error(Y(300));return t}function Qw(){var t=Mu!==0;return Mu=0,t}function xs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?pt.memoizedState=jt=t:jt=jt.next=t,jt}function Lr(){if(Et===null){var t=pt.alternate;t=t!==null?t.memoizedState:null}else t=Et.next;var e=jt===null?pt.memoizedState:jt.next;if(e!==null)jt=e,Et=t;else{if(t===null)throw Error(Y(310));Et=t,t={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},jt===null?pt.memoizedState=jt=t:jt=jt.next=t}return jt}function Au(t,e){return typeof e=="function"?e(t):e}function sy(t){var e=Lr(),n=e.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=t;var r=Et,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var i=s.next;s.next=o.next,o.next=i}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var a=i=null,l=null,c=o;do{var u=c.lane;if((sa&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:t(r,c.action);else{var h={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=h,i=r):l=l.next=h,pt.lanes|=u,oa|=u}c=c.next}while(c!==null&&c!==o);l===null?i=r:l.next=a,os(r,e.memoizedState)||(Hn=!0),e.memoizedState=r,e.baseState=i,e.baseQueue=l,n.lastRenderedState=r}if(t=n.interleaved,t!==null){s=t;do o=s.lane,pt.lanes|=o,oa|=o,s=s.next;while(s!==t)}else s===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function oy(t){var e=Lr(),n=e.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=t;var r=n.dispatch,s=n.pending,o=e.memoizedState;if(s!==null){n.pending=null;var i=s=s.next;do o=t(o,i.action),i=i.next;while(i!==s);os(o,e.memoizedState)||(Hn=!0),e.memoizedState=o,e.baseQueue===null&&(e.baseState=o),n.lastRenderedState=o}return[o,r]}function Ok(){}function Dk(t,e){var n=pt,r=Lr(),s=e(),o=!os(r.memoizedState,s);if(o&&(r.memoizedState=s,Hn=!0),r=r.queue,Jw($k.bind(null,n,r,t),[t]),r.getSnapshot!==e||o||jt!==null&&jt.memoizedState.tag&1){if(n.flags|=2048,ju(9,Lk.bind(null,n,r,s,e),void 0,null),Rt===null)throw Error(Y(349));sa&30||Rk(n,e,s)}return s}function Rk(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=pt.updateQueue,e===null?(e={lastEffect:null,stores:null},pt.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function Lk(t,e,n,r){e.value=n,e.getSnapshot=r,Fk(e)&&Nk(t)}function $k(t,e,n){return n(function(){Fk(e)&&Nk(t)})}function Fk(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!os(t,n)}catch{return!0}}function Nk(t){var e=xo(t,1);e!==null&&ts(e,t,1,-1)}function sC(t){var e=xs();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Au,lastRenderedState:t},e.queue=t,t=t.dispatch=$z.bind(null,pt,t),[e.memoizedState,t]}function ju(t,e,n,r){return t={tag:t,create:e,destroy:n,deps:r,next:null},e=pt.updateQueue,e===null?(e={lastEffect:null,stores:null},pt.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,e.lastEffect=t)),t}function zk(){return Lr().memoizedState}function Zh(t,e,n,r){var s=xs();pt.flags|=t,s.memoizedState=ju(1|e,n,void 0,r===void 0?null:r)}function lg(t,e,n,r){var s=Lr();r=r===void 0?null:r;var o=void 0;if(Et!==null){var i=Et.memoizedState;if(o=i.destroy,r!==null&&qw(r,i.deps)){s.memoizedState=ju(e,n,o,r);return}}pt.flags|=t,s.memoizedState=ju(1|e,n,o,r)}function oC(t,e){return Zh(8390656,8,t,e)}function Jw(t,e){return lg(2048,8,t,e)}function Bk(t,e){return lg(4,2,t,e)}function Uk(t,e){return lg(4,4,t,e)}function Hk(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 Kk(t,e,n){return n=n!=null?n.concat([t]):null,lg(4,4,Hk.bind(null,e,t),n)}function e0(){}function Wk(t,e){var n=Lr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&qw(e,r[1])?r[0]:(n.memoizedState=[t,e],t)}function Gk(t,e){var n=Lr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&qw(e,r[1])?r[0]:(t=t(),n.memoizedState=[t,e],t)}function Vk(t,e,n){return sa&21?(os(n,e)||(n=Q2(),pt.lanes|=n,oa|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,Hn=!0),t.memoizedState=n)}function Rz(t,e){var n=Be;Be=n!==0&&4>n?n:4,t(!0);var r=ry.transition;ry.transition={};try{t(!1),e()}finally{Be=n,ry.transition=r}}function Yk(){return Lr().memoizedState}function Lz(t,e,n){var r=li(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Xk(t))qk(e,n);else if(n=Mk(t,e,n,r),n!==null){var s=Pn();ts(n,t,r,s),Zk(n,e,r)}}function $z(t,e,n){var r=li(t),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Xk(t))qk(e,s);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var i=e.lastRenderedState,a=o(i,n);if(s.hasEagerState=!0,s.eagerState=a,os(a,i)){var l=e.interleaved;l===null?(s.next=s,Ww(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}n=Mk(t,e,s,r),n!==null&&(s=Pn(),ts(n,t,r,s),Zk(n,e,r))}}function Xk(t){var e=t.alternate;return t===pt||e!==null&&e===pt}function qk(t,e){ru=rp=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Zk(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Aw(t,n)}}var sp={readContext:Rr,useCallback:tn,useContext:tn,useEffect:tn,useImperativeHandle:tn,useInsertionEffect:tn,useLayoutEffect:tn,useMemo:tn,useReducer:tn,useRef:tn,useState:tn,useDebugValue:tn,useDeferredValue:tn,useTransition:tn,useMutableSource:tn,useSyncExternalStore:tn,useId:tn,unstable_isNewReconciler:!1},Fz={readContext:Rr,useCallback:function(t,e){return xs().memoizedState=[t,e===void 0?null:e],t},useContext:Rr,useEffect:oC,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Zh(4194308,4,Hk.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Zh(4194308,4,t,e)},useInsertionEffect:function(t,e){return Zh(4,2,t,e)},useMemo:function(t,e){var n=xs();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=xs();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Lz.bind(null,pt,t),[r.memoizedState,t]},useRef:function(t){var e=xs();return t={current:t},e.memoizedState=t},useState:sC,useDebugValue:e0,useDeferredValue:function(t){return xs().memoizedState=t},useTransition:function(){var t=sC(!1),e=t[0];return t=Rz.bind(null,t[1]),xs().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=pt,s=xs();if(at){if(n===void 0)throw Error(Y(407));n=n()}else{if(n=e(),Rt===null)throw Error(Y(349));sa&30||Rk(r,e,n)}s.memoizedState=n;var o={value:n,getSnapshot:e};return s.queue=o,oC($k.bind(null,r,o,t),[t]),r.flags|=2048,ju(9,Lk.bind(null,r,o,n,e),void 0,null),n},useId:function(){var t=xs(),e=Rt.identifierPrefix;if(at){var n=lo,r=ao;n=(r&~(1<<32-es(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Mu++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=Dz++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},Nz={readContext:Rr,useCallback:Wk,useContext:Rr,useEffect:Jw,useImperativeHandle:Kk,useInsertionEffect:Bk,useLayoutEffect:Uk,useMemo:Gk,useReducer:sy,useRef:zk,useState:function(){return sy(Au)},useDebugValue:e0,useDeferredValue:function(t){var e=Lr();return Vk(e,Et.memoizedState,t)},useTransition:function(){var t=sy(Au)[0],e=Lr().memoizedState;return[t,e]},useMutableSource:Ok,useSyncExternalStore:Dk,useId:Yk,unstable_isNewReconciler:!1},zz={readContext:Rr,useCallback:Wk,useContext:Rr,useEffect:Jw,useImperativeHandle:Kk,useInsertionEffect:Bk,useLayoutEffect:Uk,useMemo:Gk,useReducer:oy,useRef:zk,useState:function(){return oy(Au)},useDebugValue:e0,useDeferredValue:function(t){var e=Lr();return Et===null?e.memoizedState=t:Vk(e,Et.memoizedState,t)},useTransition:function(){var t=oy(Au)[0],e=Lr().memoizedState;return[t,e]},useMutableSource:Ok,useSyncExternalStore:Dk,useId:Yk,unstable_isNewReconciler:!1};function Kr(t,e){if(t&&t.defaultProps){e=gt({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function Tv(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:gt({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var cg={isMounted:function(t){return(t=t._reactInternals)?wa(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var r=Pn(),s=li(t),o=ho(r,s);o.payload=e,n!=null&&(o.callback=n),e=ii(t,o,s),e!==null&&(ts(e,t,s,r),Xh(e,t,s))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var r=Pn(),s=li(t),o=ho(r,s);o.tag=1,o.payload=e,n!=null&&(o.callback=n),e=ii(t,o,s),e!==null&&(ts(e,t,s,r),Xh(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=Pn(),r=li(t),s=ho(n,r);s.tag=2,e!=null&&(s.callback=e),e=ii(t,s,r),e!==null&&(ts(e,t,r,n),Xh(e,t,r))}};function iC(t,e,n,r,s,o,i){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,o,i):e.prototype&&e.prototype.isPureReactComponent?!Cu(n,r)||!Cu(s,o):!0}function Qk(t,e,n){var r=!1,s=pi,o=e.contextType;return typeof o=="object"&&o!==null?o=Rr(o):(s=Vn(e)?na:gn.current,r=e.contextTypes,o=(r=r!=null)?El(t,s):pi),e=new e(n,o),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=cg,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=o),e}function aC(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&cg.enqueueReplaceState(e,e.state,null)}function Mv(t,e,n,r){var s=t.stateNode;s.props=n,s.state=t.memoizedState,s.refs={},Gw(t);var o=e.contextType;typeof o=="object"&&o!==null?s.context=Rr(o):(o=Vn(e)?na:gn.current,s.context=El(t,o)),s.state=t.memoizedState,o=e.getDerivedStateFromProps,typeof o=="function"&&(Tv(t,e,o,n),s.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&cg.enqueueReplaceState(s,s.state,null),tp(t,n,s,r),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function Al(t,e){try{var n="",r=e;do n+=p6(r),r=r.return;while(r);var s=n}catch(o){s=`
|
|
39
|
-
Error generating stack: `+o.message+`
|
|
40
|
-
`+o.stack}return{value:t,source:e,stack:s,digest:null}}function iy(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Av(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var Bz=typeof WeakMap=="function"?WeakMap:Map;function Jk(t,e,n){n=ho(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){ip||(ip=!0,Bv=r),Av(t,e)},n}function eT(t,e,n){n=ho(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var s=e.value;n.payload=function(){return r(s)},n.callback=function(){Av(t,e)}}var o=t.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Av(t,e),typeof r!="function"&&(ai===null?ai=new Set([this]):ai.add(this));var i=e.stack;this.componentDidCatch(e.value,{componentStack:i!==null?i:""})}),n}function lC(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new Bz;var s=new Set;r.set(e,s)}else s=r.get(e),s===void 0&&(s=new Set,r.set(e,s));s.has(n)||(s.add(n),t=t8.bind(null,t,e,n),e.then(t,t))}function cC(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 uC(t,e,n,r,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=ho(-1,1),e.tag=2,ii(n,e,1))),n.lanes|=1),t)}var Uz=_o.ReactCurrentOwner,Hn=!1;function xn(t,e,n,r){e.child=t===null?Tk(e,null,n,r):Tl(e,t.child,n,r)}function dC(t,e,n,r,s){n=n.render;var o=e.ref;return yl(e,s),r=Zw(t,e,n,r,o,s),n=Qw(),t!==null&&!Hn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,wo(t,e,s)):(at&&n&&Nw(e),e.flags|=1,xn(t,e,r,s),e.child)}function hC(t,e,n,r,s){if(t===null){var o=n.type;return typeof o=="function"&&!l0(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=o,tT(t,e,o,r,s)):(t=tf(n.type,null,r,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(o=t.child,!(t.lanes&s)){var i=o.memoizedProps;if(n=n.compare,n=n!==null?n:Cu,n(i,r)&&t.ref===e.ref)return wo(t,e,s)}return e.flags|=1,t=ci(o,r),t.ref=e.ref,t.return=e,e.child=t}function tT(t,e,n,r,s){if(t!==null){var o=t.memoizedProps;if(Cu(o,r)&&t.ref===e.ref)if(Hn=!1,e.pendingProps=r=o,(t.lanes&s)!==0)t.flags&131072&&(Hn=!0);else return e.lanes=t.lanes,wo(t,e,s)}return jv(t,e,n,r,s)}function nT(t,e,n){var r=e.pendingProps,s=r.children,o=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(rl,sr),sr|=n;else{if(!(n&1073741824))return t=o!==null?o.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,qe(rl,sr),sr|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,qe(rl,sr),sr|=r}else o!==null?(r=o.baseLanes|n,e.memoizedState=null):r=n,qe(rl,sr),sr|=r;return xn(t,e,s,n),e.child}function rT(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function jv(t,e,n,r,s){var o=Vn(n)?na:gn.current;return o=El(e,o),yl(e,s),n=Zw(t,e,n,r,o,s),r=Qw(),t!==null&&!Hn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,wo(t,e,s)):(at&&r&&Nw(e),e.flags|=1,xn(t,e,n,s),e.child)}function fC(t,e,n,r,s){if(Vn(n)){var o=!0;qf(e)}else o=!1;if(yl(e,s),e.stateNode===null)Qh(t,e),Qk(e,n,r),Mv(e,n,r,s),r=!0;else if(t===null){var i=e.stateNode,a=e.memoizedProps;i.props=a;var l=i.context,c=n.contextType;typeof c=="object"&&c!==null?c=Rr(c):(c=Vn(n)?na:gn.current,c=El(e,c));var u=n.getDerivedStateFromProps,h=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==r||l!==c)&&aC(e,i,r,c),Wo=!1;var f=e.memoizedState;i.state=f,tp(e,r,i,s),l=e.memoizedState,a!==r||f!==l||Gn.current||Wo?(typeof u=="function"&&(Tv(e,n,u,r),l=e.memoizedState),(a=Wo||iC(e,n,a,r,f,l,c))?(h||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(e.flags|=4194308)):(typeof i.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),i.props=r,i.state=l,i.context=c,r=a):(typeof i.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{i=e.stateNode,Ak(t,e),a=e.memoizedProps,c=e.type===e.elementType?a:Kr(e.type,a),i.props=c,h=e.pendingProps,f=i.context,l=n.contextType,typeof l=="object"&&l!==null?l=Rr(l):(l=Vn(n)?na:gn.current,l=El(e,l));var p=n.getDerivedStateFromProps;(u=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==h||f!==l)&&aC(e,i,r,l),Wo=!1,f=e.memoizedState,i.state=f,tp(e,r,i,s);var g=e.memoizedState;a!==h||f!==g||Gn.current||Wo?(typeof p=="function"&&(Tv(e,n,p,r),g=e.memoizedState),(c=Wo||iC(e,n,c,r,f,g,l)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,g,l),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,g,l)),typeof i.componentDidUpdate=="function"&&(e.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof i.componentDidUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=g),i.props=r,i.state=g,i.context=l,r=c):(typeof i.componentDidUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),r=!1)}return Ov(t,e,n,r,o,s)}function Ov(t,e,n,r,s,o){rT(t,e);var i=(e.flags&128)!==0;if(!r&&!i)return s&&QP(e,n,!1),wo(t,e,o);r=e.stateNode,Uz.current=e;var a=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&i?(e.child=Tl(e,t.child,null,o),e.child=Tl(e,null,a,o)):xn(t,e,a,o),e.memoizedState=r.state,s&&QP(e,n,!0),e.child}function sT(t){var e=t.stateNode;e.pendingContext?ZP(t,e.pendingContext,e.pendingContext!==e.context):e.context&&ZP(t,e.context,!1),Vw(t,e.containerInfo)}function pC(t,e,n,r,s){return kl(),Bw(s),e.flags|=256,xn(t,e,n,r),e.child}var Dv={dehydrated:null,treeContext:null,retryLane:0};function Rv(t){return{baseLanes:t,cachePool:null,transitions:null}}function oT(t,e,n){var r=e.pendingProps,s=dt.current,o=!1,i=(e.flags&128)!==0,a;if((a=i)||(a=t!==null&&t.memoizedState===null?!1:(s&2)!==0),a?(o=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),qe(dt,s&1),t===null)return Ev(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):(i=r.children,t=r.fallback,o?(r=e.mode,o=e.child,i={mode:"hidden",children:i},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=i):o=hg(i,r,0,null),t=Zi(t,r,n,null),o.return=e,t.return=e,o.sibling=t,e.child=o,e.child.memoizedState=Rv(n),e.memoizedState=Dv,t):t0(e,i));if(s=t.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return Hz(t,e,i,r,a,s,n);if(o){o=r.fallback,i=e.mode,s=t.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(i&1)&&e.child!==s?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=ci(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?o=ci(a,o):(o=Zi(o,i,n,null),o.flags|=2),o.return=e,r.return=e,r.sibling=o,e.child=r,r=o,o=e.child,i=t.child.memoizedState,i=i===null?Rv(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=t.childLanes&~n,e.memoizedState=Dv,r}return o=t.child,t=o.sibling,r=ci(o,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function t0(t,e){return e=hg({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Qd(t,e,n,r){return r!==null&&Bw(r),Tl(e,t.child,null,n),t=t0(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function Hz(t,e,n,r,s,o,i){if(n)return e.flags&256?(e.flags&=-257,r=iy(Error(Y(422))),Qd(t,e,i,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(o=r.fallback,s=e.mode,r=hg({mode:"visible",children:r.children},s,0,null),o=Zi(o,s,i,null),o.flags|=2,r.return=e,o.return=e,r.sibling=o,e.child=r,e.mode&1&&Tl(e,t.child,null,i),e.child.memoizedState=Rv(i),e.memoizedState=Dv,o);if(!(e.mode&1))return Qd(t,e,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,o=Error(Y(419)),r=iy(o,r,void 0),Qd(t,e,i,r)}if(a=(i&t.childLanes)!==0,Hn||a){if(r=Rt,r!==null){switch(i&-i){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|i)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,xo(t,s),ts(r,t,s,-1))}return a0(),r=iy(Error(Y(421))),Qd(t,e,i,r)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=n8.bind(null,t),s._reactRetry=e,null):(t=o.treeContext,ir=oi(s.nextSibling),cr=e,at=!0,Yr=null,t!==null&&(kr[Tr++]=ao,kr[Tr++]=lo,kr[Tr++]=ra,ao=t.id,lo=t.overflow,ra=e),e=t0(e,r.children),e.flags|=4096,e)}function gC(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),kv(t.return,e,n)}function ay(t,e,n,r,s){var o=t.memoizedState;o===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=e,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function iT(t,e,n){var r=e.pendingProps,s=r.revealOrder,o=r.tail;if(xn(t,e,r.children,n),r=dt.current,r&2)r=r&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&&gC(t,n,e);else if(t.tag===19)gC(t,n,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}r&=1}if(qe(dt,r),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(n=e.child,s=null;n!==null;)t=n.alternate,t!==null&&np(t)===null&&(s=n),n=n.sibling;n=s,n===null?(s=e.child,e.child=null):(s=n.sibling,n.sibling=null),ay(e,!1,s,n,o);break;case"backwards":for(n=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&np(t)===null){e.child=s;break}t=s.sibling,s.sibling=n,n=s,s=t}ay(e,!0,n,null,o);break;case"together":ay(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Qh(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function wo(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),oa|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(Y(153));if(e.child!==null){for(t=e.child,n=ci(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ci(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function Kz(t,e,n){switch(e.tag){case 3:sT(e),kl();break;case 5:jk(e);break;case 1:Vn(e.type)&&qf(e);break;case 4:Vw(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,s=e.memoizedProps.value;qe(Jf,r._currentValue),r._currentValue=s;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(qe(dt,dt.current&1),e.flags|=128,null):n&e.child.childLanes?oT(t,e,n):(qe(dt,dt.current&1),t=wo(t,e,n),t!==null?t.sibling:null);qe(dt,dt.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return iT(t,e,n);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),qe(dt,dt.current),r)break;return null;case 22:case 23:return e.lanes=0,nT(t,e,n)}return wo(t,e,n)}var aT,Lv,lT,cT;aT=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Lv=function(){};lT=function(t,e,n,r){var s=t.memoizedProps;if(s!==r){t=e.stateNode,Yi(Ms.current);var o=null;switch(n){case"input":s=sv(t,s),r=sv(t,r),o=[];break;case"select":s=gt({},s,{value:void 0}),r=gt({},r,{value:void 0}),o=[];break;case"textarea":s=av(t,s),r=av(t,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Yf)}cv(n,r);var i;n=null;for(c in s)if(!r.hasOwnProperty(c)&&s.hasOwnProperty(c)&&s[c]!=null)if(c==="style"){var a=s[c];for(i in a)a.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(yu.hasOwnProperty(c)?o||(o=[]):(o=o||[]).push(c,null));for(c in r){var l=r[c];if(a=s!=null?s[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(i in a)!a.hasOwnProperty(i)||l&&l.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in l)l.hasOwnProperty(i)&&a[i]!==l[i]&&(n||(n={}),n[i]=l[i])}else n||(o||(o=[]),o.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(o=o||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(o=o||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(yu.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&tt("scroll",t),o||a===l||(o=[])):(o=o||[]).push(c,l))}n&&(o=o||[]).push("style",n);var c=o;(e.updateQueue=c)&&(e.flags|=4)}};cT=function(t,e,n,r){n!==r&&(e.flags|=4)};function vc(t,e){if(!at)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function nn(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function Wz(t,e,n){var r=e.pendingProps;switch(zw(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nn(e),null;case 1:return Vn(e.type)&&Xf(),nn(e),null;case 3:return r=e.stateNode,Ml(),rt(Gn),rt(gn),Xw(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(qd(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Yr!==null&&(Kv(Yr),Yr=null))),Lv(t,e),nn(e),null;case 5:Yw(e);var s=Yi(Tu.current);if(n=e.type,t!==null&&e.stateNode!=null)lT(t,e,n,r,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(Y(166));return nn(e),null}if(t=Yi(Ms.current),qd(e)){r=e.stateNode,n=e.type;var o=e.memoizedProps;switch(r[bs]=e,r[Eu]=o,t=(e.mode&1)!==0,n){case"dialog":tt("cancel",r),tt("close",r);break;case"iframe":case"object":case"embed":tt("load",r);break;case"video":case"audio":for(s=0;s<Bc.length;s++)tt(Bc[s],r);break;case"source":tt("error",r);break;case"img":case"image":case"link":tt("error",r),tt("load",r);break;case"details":tt("toggle",r);break;case"input":CP(r,o),tt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},tt("invalid",r);break;case"textarea":IP(r,o),tt("invalid",r)}cv(n,o),s=null;for(var i in o)if(o.hasOwnProperty(i)){var a=o[i];i==="children"?typeof a=="string"?r.textContent!==a&&(o.suppressHydrationWarning!==!0&&Xd(r.textContent,a,t),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(o.suppressHydrationWarning!==!0&&Xd(r.textContent,a,t),s=["children",""+a]):yu.hasOwnProperty(i)&&a!=null&&i==="onScroll"&&tt("scroll",r)}switch(n){case"input":Bd(r),_P(r,o,!0);break;case"textarea":Bd(r),EP(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Yf)}r=s,e.updateQueue=r,r!==null&&(e.flags|=4)}else{i=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=$2(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=i.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=i.createElement(n,{is:r.is}):(t=i.createElement(n),n==="select"&&(i=t,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):t=i.createElementNS(t,n),t[bs]=e,t[Eu]=r,aT(t,e,!1,!1),e.stateNode=t;e:{switch(i=uv(n,r),n){case"dialog":tt("cancel",t),tt("close",t),s=r;break;case"iframe":case"object":case"embed":tt("load",t),s=r;break;case"video":case"audio":for(s=0;s<Bc.length;s++)tt(Bc[s],t);s=r;break;case"source":tt("error",t),s=r;break;case"img":case"image":case"link":tt("error",t),tt("load",t),s=r;break;case"details":tt("toggle",t),s=r;break;case"input":CP(t,r),s=sv(t,r),tt("invalid",t);break;case"option":s=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},s=gt({},r,{value:void 0}),tt("invalid",t);break;case"textarea":IP(t,r),s=av(t,r),tt("invalid",t);break;default:s=r}cv(n,s),a=s;for(o in a)if(a.hasOwnProperty(o)){var l=a[o];o==="style"?z2(t,l):o==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&F2(t,l)):o==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Su(t,l):typeof l=="number"&&Su(t,""+l):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(yu.hasOwnProperty(o)?l!=null&&o==="onScroll"&&tt("scroll",t):l!=null&&_w(t,o,l,i))}switch(n){case"input":Bd(t),_P(t,r,!1);break;case"textarea":Bd(t),EP(t);break;case"option":r.value!=null&&t.setAttribute("value",""+fi(r.value));break;case"select":t.multiple=!!r.multiple,o=r.value,o!=null?fl(t,!!r.multiple,o,!1):r.defaultValue!=null&&fl(t,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=Yf)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return nn(e),null;case 6:if(t&&e.stateNode!=null)cT(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(Y(166));if(n=Yi(Tu.current),Yi(Ms.current),qd(e)){if(r=e.stateNode,n=e.memoizedProps,r[bs]=e,(o=r.nodeValue!==n)&&(t=cr,t!==null))switch(t.tag){case 3:Xd(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Xd(r.nodeValue,n,(t.mode&1)!==0)}o&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[bs]=e,e.stateNode=r}return nn(e),null;case 13:if(rt(dt),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(at&&ir!==null&&e.mode&1&&!(e.flags&128))Ek(),kl(),e.flags|=98560,o=!1;else if(o=qd(e),r!==null&&r.dehydrated!==null){if(t===null){if(!o)throw Error(Y(318));if(o=e.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Y(317));o[bs]=e}else kl(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;nn(e),o=!1}else Yr!==null&&(Kv(Yr),Yr=null),o=!0;if(!o)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||dt.current&1?kt===0&&(kt=3):a0())),e.updateQueue!==null&&(e.flags|=4),nn(e),null);case 4:return Ml(),Lv(t,e),t===null&&_u(e.stateNode.containerInfo),nn(e),null;case 10:return Kw(e.type._context),nn(e),null;case 17:return Vn(e.type)&&Xf(),nn(e),null;case 19:if(rt(dt),o=e.memoizedState,o===null)return nn(e),null;if(r=(e.flags&128)!==0,i=o.rendering,i===null)if(r)vc(o,!1);else{if(kt!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(i=np(t),i!==null){for(e.flags|=128,vc(o,!1),r=i.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)o=n,t=r,o.flags&=14680066,i=o.alternate,i===null?(o.childLanes=0,o.lanes=t,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,o.type=i.type,t=i.dependencies,o.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return qe(dt,dt.current&1|2),e.child}t=t.sibling}o.tail!==null&&xt()>jl&&(e.flags|=128,r=!0,vc(o,!1),e.lanes=4194304)}else{if(!r)if(t=np(i),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),vc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!at)return nn(e),null}else 2*xt()-o.renderingStartTime>jl&&n!==1073741824&&(e.flags|=128,r=!0,vc(o,!1),e.lanes=4194304);o.isBackwards?(i.sibling=e.child,e.child=i):(n=o.last,n!==null?n.sibling=i:e.child=i,o.last=i)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=xt(),e.sibling=null,n=dt.current,qe(dt,r?n&1|2:n&1),e):(nn(e),null);case 22:case 23:return i0(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?sr&1073741824&&(nn(e),e.subtreeFlags&6&&(e.flags|=8192)):nn(e),null;case 24:return null;case 25:return null}throw Error(Y(156,e.tag))}function Gz(t,e){switch(zw(e),e.tag){case 1:return Vn(e.type)&&Xf(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ml(),rt(Gn),rt(gn),Xw(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Yw(e),null;case 13:if(rt(dt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Y(340));kl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return rt(dt),null;case 4:return Ml(),null;case 10:return Kw(e.type._context),null;case 22:case 23:return i0(),null;case 24:return null;default:return null}}var Jd=!1,ln=!1,Vz=typeof WeakSet=="function"?WeakSet:Set,re=null;function nl(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){yt(t,e,r)}else n.current=null}function $v(t,e,n){try{n()}catch(r){yt(t,e,r)}}var mC=!1;function Yz(t,e){if(xv=Wf,t=pk(),Fw(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,a=-1,l=-1,c=0,u=0,h=t,f=null;t:for(;;){for(var p;h!==n||s!==0&&h.nodeType!==3||(a=i+s),h!==o||r!==0&&h.nodeType!==3||(l=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(p=h.firstChild)!==null;)f=h,h=p;for(;;){if(h===t)break t;if(f===n&&++c===s&&(a=i),f===o&&++u===r&&(l=i),(p=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(wv={focusedElem:t,selectionRange:n},Wf=!1,re=e;re!==null;)if(e=re,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,re=t;else for(;re!==null;){e=re;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,v=g.memoizedState,y=e.stateNode,S=y.getSnapshotBeforeUpdate(e.elementType===e.type?m:Kr(e.type,m),v);y.__reactInternalSnapshotBeforeUpdate=S}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(Y(163))}}catch(P){yt(e,e.return,P)}if(t=e.sibling,t!==null){t.return=e.return,re=t;break}re=e.return}return g=mC,mC=!1,g}function su(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var o=s.destroy;s.destroy=void 0,o!==void 0&&$v(e,n,o)}s=s.next}while(s!==r)}}function ug(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function Fv(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function uT(t){var e=t.alternate;e!==null&&(t.alternate=null,uT(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[bs],delete e[Eu],delete e[Cv],delete e[Mz],delete e[Az])),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 dT(t){return t.tag===5||t.tag===3||t.tag===4}function yC(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||dT(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 Nv(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Yf));else if(r!==4&&(t=t.child,t!==null))for(Nv(t,e,n),t=t.sibling;t!==null;)Nv(t,e,n),t=t.sibling}function zv(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(zv(t,e,n),t=t.sibling;t!==null;)zv(t,e,n),t=t.sibling}var zt=null,Wr=!1;function $o(t,e,n){for(n=n.child;n!==null;)hT(t,e,n),n=n.sibling}function hT(t,e,n){if(Ts&&typeof Ts.onCommitFiberUnmount=="function")try{Ts.onCommitFiberUnmount(ng,n)}catch{}switch(n.tag){case 5:ln||nl(n,e);case 6:var r=zt,s=Wr;zt=null,$o(t,e,n),zt=r,Wr=s,zt!==null&&(Wr?(t=zt,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):zt.removeChild(n.stateNode));break;case 18:zt!==null&&(Wr?(t=zt,n=n.stateNode,t.nodeType===8?ey(t.parentNode,n):t.nodeType===1&&ey(t,n),bu(t)):ey(zt,n.stateNode));break;case 4:r=zt,s=Wr,zt=n.stateNode.containerInfo,Wr=!0,$o(t,e,n),zt=r,Wr=s;break;case 0:case 11:case 14:case 15:if(!ln&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&$v(n,e,i),s=s.next}while(s!==r)}$o(t,e,n);break;case 1:if(!ln&&(nl(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){yt(n,e,a)}$o(t,e,n);break;case 21:$o(t,e,n);break;case 22:n.mode&1?(ln=(r=ln)||n.memoizedState!==null,$o(t,e,n),ln=r):$o(t,e,n);break;default:$o(t,e,n)}}function SC(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Vz),e.forEach(function(r){var s=r8.bind(null,t,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Hr(t,e){var n=e.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=t,i=e,a=i;e:for(;a!==null;){switch(a.tag){case 5:zt=a.stateNode,Wr=!1;break e;case 3:zt=a.stateNode.containerInfo,Wr=!0;break e;case 4:zt=a.stateNode.containerInfo,Wr=!0;break e}a=a.return}if(zt===null)throw Error(Y(160));hT(o,i,s),zt=null,Wr=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(c){yt(s,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)fT(e,t),e=e.sibling}function fT(t,e){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Hr(e,t),gs(t),r&4){try{su(3,t,t.return),ug(3,t)}catch(m){yt(t,t.return,m)}try{su(5,t,t.return)}catch(m){yt(t,t.return,m)}}break;case 1:Hr(e,t),gs(t),r&512&&n!==null&&nl(n,n.return);break;case 5:if(Hr(e,t),gs(t),r&512&&n!==null&&nl(n,n.return),t.flags&32){var s=t.stateNode;try{Su(s,"")}catch(m){yt(t,t.return,m)}}if(r&4&&(s=t.stateNode,s!=null)){var o=t.memoizedProps,i=n!==null?n.memoizedProps:o,a=t.type,l=t.updateQueue;if(t.updateQueue=null,l!==null)try{a==="input"&&o.type==="radio"&&o.name!=null&&R2(s,o),uv(a,i);var c=uv(a,o);for(i=0;i<l.length;i+=2){var u=l[i],h=l[i+1];u==="style"?z2(s,h):u==="dangerouslySetInnerHTML"?F2(s,h):u==="children"?Su(s,h):_w(s,u,h,c)}switch(a){case"input":ov(s,o);break;case"textarea":L2(s,o);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var p=o.value;p!=null?fl(s,!!o.multiple,p,!1):f!==!!o.multiple&&(o.defaultValue!=null?fl(s,!!o.multiple,o.defaultValue,!0):fl(s,!!o.multiple,o.multiple?[]:"",!1))}s[Eu]=o}catch(m){yt(t,t.return,m)}}break;case 6:if(Hr(e,t),gs(t),r&4){if(t.stateNode===null)throw Error(Y(162));s=t.stateNode,o=t.memoizedProps;try{s.nodeValue=o}catch(m){yt(t,t.return,m)}}break;case 3:if(Hr(e,t),gs(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{bu(e.containerInfo)}catch(m){yt(t,t.return,m)}break;case 4:Hr(e,t),gs(t);break;case 13:Hr(e,t),gs(t),s=t.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(s0=xt())),r&4&&SC(t);break;case 22:if(u=n!==null&&n.memoizedState!==null,t.mode&1?(ln=(c=ln)||u,Hr(e,t),ln=c):Hr(e,t),gs(t),r&8192){if(c=t.memoizedState!==null,(t.stateNode.isHidden=c)&&!u&&t.mode&1)for(re=t,u=t.child;u!==null;){for(h=re=u;re!==null;){switch(f=re,p=f.child,f.tag){case 0:case 11:case 14:case 15:su(4,f,f.return);break;case 1:nl(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){r=f,n=f.return;try{e=r,g.props=e.memoizedProps,g.state=e.memoizedState,g.componentWillUnmount()}catch(m){yt(r,n,m)}}break;case 5:nl(f,f.return);break;case 22:if(f.memoizedState!==null){xC(h);continue}}p!==null?(p.return=f,re=p):xC(h)}u=u.sibling}e:for(u=null,h=t;;){if(h.tag===5){if(u===null){u=h;try{s=h.stateNode,c?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(a=h.stateNode,l=h.memoizedProps.style,i=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=N2("display",i))}catch(m){yt(t,t.return,m)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(m){yt(t,t.return,m)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===t)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Hr(e,t),gs(t),r&4&&SC(t);break;case 21:break;default:Hr(e,t),gs(t)}}function gs(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(dT(n)){var r=n;break e}n=n.return}throw Error(Y(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Su(s,""),r.flags&=-33);var o=yC(t);zv(t,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,a=yC(t);Nv(t,a,i);break;default:throw Error(Y(161))}}catch(l){yt(t,t.return,l)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function Xz(t,e,n){re=t,pT(t)}function pT(t,e,n){for(var r=(t.mode&1)!==0;re!==null;){var s=re,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||Jd;if(!i){var a=s.alternate,l=a!==null&&a.memoizedState!==null||ln;a=Jd;var c=ln;if(Jd=i,(ln=l)&&!c)for(re=s;re!==null;)i=re,l=i.child,i.tag===22&&i.memoizedState!==null?wC(s):l!==null?(l.return=i,re=l):wC(s);for(;o!==null;)re=o,pT(o),o=o.sibling;re=s,Jd=a,ln=c}vC(t)}else s.subtreeFlags&8772&&o!==null?(o.return=s,re=o):vC(t)}}function vC(t){for(;re!==null;){var e=re;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:ln||ug(5,e);break;case 1:var r=e.stateNode;if(e.flags&4&&!ln)if(n===null)r.componentDidMount();else{var s=e.elementType===e.type?n.memoizedProps:Kr(e.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=e.updateQueue;o!==null&&rC(e,o,r);break;case 3:var i=e.updateQueue;if(i!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}rC(e,i,n)}break;case 5:var a=e.stateNode;if(n===null&&e.flags&4){n=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&bu(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Y(163))}ln||e.flags&512&&Fv(e)}catch(f){yt(e,e.return,f)}}if(e===t){re=null;break}if(n=e.sibling,n!==null){n.return=e.return,re=n;break}re=e.return}}function xC(t){for(;re!==null;){var e=re;if(e===t){re=null;break}var n=e.sibling;if(n!==null){n.return=e.return,re=n;break}re=e.return}}function wC(t){for(;re!==null;){var e=re;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{ug(4,e)}catch(l){yt(e,n,l)}break;case 1:var r=e.stateNode;if(typeof r.componentDidMount=="function"){var s=e.return;try{r.componentDidMount()}catch(l){yt(e,s,l)}}var o=e.return;try{Fv(e)}catch(l){yt(e,o,l)}break;case 5:var i=e.return;try{Fv(e)}catch(l){yt(e,i,l)}}}catch(l){yt(e,e.return,l)}if(e===t){re=null;break}var a=e.sibling;if(a!==null){a.return=e.return,re=a;break}re=e.return}}var qz=Math.ceil,op=_o.ReactCurrentDispatcher,n0=_o.ReactCurrentOwner,Or=_o.ReactCurrentBatchConfig,Oe=0,Rt=null,_t=null,Yt=0,sr=0,rl=Pi(0),kt=0,Ou=null,oa=0,dg=0,r0=0,ou=null,Nn=null,s0=0,jl=1/0,no=null,ip=!1,Bv=null,ai=null,eh=!1,Qo=null,ap=0,iu=0,Uv=null,Jh=-1,ef=0;function Pn(){return Oe&6?xt():Jh!==-1?Jh:Jh=xt()}function li(t){return t.mode&1?Oe&2&&Yt!==0?Yt&-Yt:Oz.transition!==null?(ef===0&&(ef=Q2()),ef):(t=Be,t!==0||(t=window.event,t=t===void 0?16:ok(t.type)),t):1}function ts(t,e,n,r){if(50<iu)throw iu=0,Uv=null,Error(Y(185));ed(t,n,r),(!(Oe&2)||t!==Rt)&&(t===Rt&&(!(Oe&2)&&(dg|=n),kt===4&&Vo(t,Yt)),Yn(t,r),n===1&&Oe===0&&!(e.mode&1)&&(jl=xt()+500,ag&&Ci()))}function Yn(t,e){var n=t.callbackNode;O6(t,e);var r=Kf(t,t===Rt?Yt:0);if(r===0)n!==null&&MP(n),t.callbackNode=null,t.callbackPriority=0;else if(e=r&-r,t.callbackPriority!==e){if(n!=null&&MP(n),e===1)t.tag===0?jz(bC.bind(null,t)):Ck(bC.bind(null,t)),kz(function(){!(Oe&6)&&Ci()}),n=null;else{switch(J2(r)){case 1:n=Mw;break;case 4:n=q2;break;case 16:n=Hf;break;case 536870912:n=Z2;break;default:n=Hf}n=bT(n,gT.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function gT(t,e){if(Jh=-1,ef=0,Oe&6)throw Error(Y(327));var n=t.callbackNode;if(Sl()&&t.callbackNode!==n)return null;var r=Kf(t,t===Rt?Yt:0);if(r===0)return null;if(r&30||r&t.expiredLanes||e)e=lp(t,r);else{e=r;var s=Oe;Oe|=2;var o=yT();(Rt!==t||Yt!==e)&&(no=null,jl=xt()+500,qi(t,e));do try{Jz();break}catch(a){mT(t,a)}while(!0);Hw(),op.current=o,Oe=s,_t!==null?e=0:(Rt=null,Yt=0,e=kt)}if(e!==0){if(e===2&&(s=gv(t),s!==0&&(r=s,e=Hv(t,s))),e===1)throw n=Ou,qi(t,0),Vo(t,r),Yn(t,xt()),n;if(e===6)Vo(t,r);else{if(s=t.current.alternate,!(r&30)&&!Zz(s)&&(e=lp(t,r),e===2&&(o=gv(t),o!==0&&(r=o,e=Hv(t,o))),e===1))throw n=Ou,qi(t,0),Vo(t,r),Yn(t,xt()),n;switch(t.finishedWork=s,t.finishedLanes=r,e){case 0:case 1:throw Error(Y(345));case 2:Hi(t,Nn,no);break;case 3:if(Vo(t,r),(r&130023424)===r&&(e=s0+500-xt(),10<e)){if(Kf(t,0)!==0)break;if(s=t.suspendedLanes,(s&r)!==r){Pn(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=Pv(Hi.bind(null,t,Nn,no),e);break}Hi(t,Nn,no);break;case 4:if(Vo(t,r),(r&4194240)===r)break;for(e=t.eventTimes,s=-1;0<r;){var i=31-es(r);o=1<<i,i=e[i],i>s&&(s=i),r&=~o}if(r=s,r=xt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*qz(r/1960))-r,10<r){t.timeoutHandle=Pv(Hi.bind(null,t,Nn,no),r);break}Hi(t,Nn,no);break;case 5:Hi(t,Nn,no);break;default:throw Error(Y(329))}}}return Yn(t,xt()),t.callbackNode===n?gT.bind(null,t):null}function Hv(t,e){var n=ou;return t.current.memoizedState.isDehydrated&&(qi(t,e).flags|=256),t=lp(t,e),t!==2&&(e=Nn,Nn=n,e!==null&&Kv(e)),t}function Kv(t){Nn===null?Nn=t:Nn.push.apply(Nn,t)}function Zz(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],o=s.getSnapshot;s=s.value;try{if(!os(o(),s))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;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 Vo(t,e){for(e&=~r0,e&=~dg,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-es(e),r=1<<n;t[n]=-1,e&=~r}}function bC(t){if(Oe&6)throw Error(Y(327));Sl();var e=Kf(t,0);if(!(e&1))return Yn(t,xt()),null;var n=lp(t,e);if(t.tag!==0&&n===2){var r=gv(t);r!==0&&(e=r,n=Hv(t,r))}if(n===1)throw n=Ou,qi(t,0),Vo(t,e),Yn(t,xt()),n;if(n===6)throw Error(Y(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,Hi(t,Nn,no),Yn(t,xt()),null}function o0(t,e){var n=Oe;Oe|=1;try{return t(e)}finally{Oe=n,Oe===0&&(jl=xt()+500,ag&&Ci())}}function ia(t){Qo!==null&&Qo.tag===0&&!(Oe&6)&&Sl();var e=Oe;Oe|=1;var n=Or.transition,r=Be;try{if(Or.transition=null,Be=1,t)return t()}finally{Be=r,Or.transition=n,Oe=e,!(Oe&6)&&Ci()}}function i0(){sr=rl.current,rt(rl)}function qi(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,Ez(n)),_t!==null)for(n=_t.return;n!==null;){var r=n;switch(zw(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Xf();break;case 3:Ml(),rt(Gn),rt(gn),Xw();break;case 5:Yw(r);break;case 4:Ml();break;case 13:rt(dt);break;case 19:rt(dt);break;case 10:Kw(r.type._context);break;case 22:case 23:i0()}n=n.return}if(Rt=t,_t=t=ci(t.current,null),Yt=sr=e,kt=0,Ou=null,r0=dg=oa=0,Nn=ou=null,Vi!==null){for(e=0;e<Vi.length;e++)if(n=Vi[e],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var i=o.next;o.next=s,r.next=i}n.pending=r}Vi=null}return t}function mT(t,e){do{var n=_t;try{if(Hw(),qh.current=sp,rp){for(var r=pt.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}rp=!1}if(sa=0,jt=Et=pt=null,ru=!1,Mu=0,n0.current=null,n===null||n.return===null){kt=1,Ou=e,_t=null;break}e:{var o=t,i=n.return,a=n,l=e;if(e=Yt,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=cC(i);if(p!==null){p.flags&=-257,uC(p,i,a,o,e),p.mode&1&&lC(o,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)){lC(o,c,e),a0();break e}l=Error(Y(426))}}else if(at&&a.mode&1){var v=cC(i);if(v!==null){!(v.flags&65536)&&(v.flags|=256),uC(v,i,a,o,e),Bw(Al(l,a));break e}}o=l=Al(l,a),kt!==4&&(kt=2),ou===null?ou=[o]:ou.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,e&=-e,o.lanes|=e;var y=Jk(o,l,e);nC(o,y);break e;case 1:a=l;var S=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof S.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(ai===null||!ai.has(b)))){o.flags|=65536,e&=-e,o.lanes|=e;var P=eT(o,a,e);nC(o,P);break e}}o=o.return}while(o!==null)}vT(n)}catch(C){e=C,_t===n&&n!==null&&(_t=n=n.return);continue}break}while(!0)}function yT(){var t=op.current;return op.current=sp,t===null?sp:t}function a0(){(kt===0||kt===3||kt===2)&&(kt=4),Rt===null||!(oa&268435455)&&!(dg&268435455)||Vo(Rt,Yt)}function lp(t,e){var n=Oe;Oe|=2;var r=yT();(Rt!==t||Yt!==e)&&(no=null,qi(t,e));do try{Qz();break}catch(s){mT(t,s)}while(!0);if(Hw(),Oe=n,op.current=r,_t!==null)throw Error(Y(261));return Rt=null,Yt=0,kt}function Qz(){for(;_t!==null;)ST(_t)}function Jz(){for(;_t!==null&&!C6();)ST(_t)}function ST(t){var e=wT(t.alternate,t,sr);t.memoizedProps=t.pendingProps,e===null?vT(t):_t=e,n0.current=null}function vT(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=Gz(n,e),n!==null){n.flags&=32767,_t=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{kt=6,_t=null;return}}else if(n=Wz(n,e,sr),n!==null){_t=n;return}if(e=e.sibling,e!==null){_t=e;return}_t=e=t}while(e!==null);kt===0&&(kt=5)}function Hi(t,e,n){var r=Be,s=Or.transition;try{Or.transition=null,Be=1,e8(t,e,n,r)}finally{Or.transition=s,Be=r}return null}function e8(t,e,n,r){do Sl();while(Qo!==null);if(Oe&6)throw Error(Y(327));n=t.finishedWork;var s=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(Y(177));t.callbackNode=null,t.callbackPriority=0;var o=n.lanes|n.childLanes;if(D6(t,o),t===Rt&&(_t=Rt=null,Yt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||eh||(eh=!0,bT(Hf,function(){return Sl(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Or.transition,Or.transition=null;var i=Be;Be=1;var a=Oe;Oe|=4,n0.current=null,Yz(t,n),fT(n,t),xz(wv),Wf=!!xv,wv=xv=null,t.current=n,Xz(n),_6(),Oe=a,Be=i,Or.transition=o}else t.current=n;if(eh&&(eh=!1,Qo=t,ap=s),o=t.pendingLanes,o===0&&(ai=null),k6(n.stateNode),Yn(t,xt()),e!==null)for(r=t.onRecoverableError,n=0;n<e.length;n++)s=e[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(ip)throw ip=!1,t=Bv,Bv=null,t;return ap&1&&t.tag!==0&&Sl(),o=t.pendingLanes,o&1?t===Uv?iu++:(iu=0,Uv=t):iu=0,Ci(),null}function Sl(){if(Qo!==null){var t=J2(ap),e=Or.transition,n=Be;try{if(Or.transition=null,Be=16>t?16:t,Qo===null)var r=!1;else{if(t=Qo,Qo=null,ap=0,Oe&6)throw Error(Y(331));var s=Oe;for(Oe|=4,re=t.current;re!==null;){var o=re,i=o.child;if(re.flags&16){var a=o.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(re=c;re!==null;){var u=re;switch(u.tag){case 0:case 11:case 15:su(8,u,o)}var h=u.child;if(h!==null)h.return=u,re=h;else for(;re!==null;){u=re;var f=u.sibling,p=u.return;if(uT(u),u===c){re=null;break}if(f!==null){f.return=p,re=f;break}re=p}}}var g=o.alternate;if(g!==null){var m=g.child;if(m!==null){g.child=null;do{var v=m.sibling;m.sibling=null,m=v}while(m!==null)}}re=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,re=i;else e:for(;re!==null;){if(o=re,o.flags&2048)switch(o.tag){case 0:case 11:case 15:su(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,re=y;break e}re=o.return}}var S=t.current;for(re=S;re!==null;){i=re;var b=i.child;if(i.subtreeFlags&2064&&b!==null)b.return=i,re=b;else e:for(i=S;re!==null;){if(a=re,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:ug(9,a)}}catch(C){yt(a,a.return,C)}if(a===i){re=null;break e}var P=a.sibling;if(P!==null){P.return=a.return,re=P;break e}re=a.return}}if(Oe=s,Ci(),Ts&&typeof Ts.onPostCommitFiberRoot=="function")try{Ts.onPostCommitFiberRoot(ng,t)}catch{}r=!0}return r}finally{Be=n,Or.transition=e}}return!1}function PC(t,e,n){e=Al(n,e),e=Jk(t,e,1),t=ii(t,e,1),e=Pn(),t!==null&&(ed(t,1,e),Yn(t,e))}function yt(t,e,n){if(t.tag===3)PC(t,t,n);else for(;e!==null;){if(e.tag===3){PC(e,t,n);break}else if(e.tag===1){var r=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ai===null||!ai.has(r))){t=Al(n,t),t=eT(e,t,1),e=ii(e,t,1),t=Pn(),e!==null&&(ed(e,1,t),Yn(e,t));break}}e=e.return}}function t8(t,e,n){var r=t.pingCache;r!==null&&r.delete(e),e=Pn(),t.pingedLanes|=t.suspendedLanes&n,Rt===t&&(Yt&n)===n&&(kt===4||kt===3&&(Yt&130023424)===Yt&&500>xt()-s0?qi(t,0):r0|=n),Yn(t,e)}function xT(t,e){e===0&&(t.mode&1?(e=Kd,Kd<<=1,!(Kd&130023424)&&(Kd=4194304)):e=1);var n=Pn();t=xo(t,e),t!==null&&(ed(t,e,n),Yn(t,n))}function n8(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),xT(t,n)}function r8(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(Y(314))}r!==null&&r.delete(e),xT(t,n)}var wT;wT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Gn.current)Hn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Hn=!1,Kz(t,e,n);Hn=!!(t.flags&131072)}else Hn=!1,at&&e.flags&1048576&&_k(e,Qf,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Qh(t,e),t=e.pendingProps;var s=El(e,gn.current);yl(e,n),s=Zw(null,e,r,t,s,n);var o=Qw();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Vn(r)?(o=!0,qf(e)):o=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Gw(e),s.updater=cg,e.stateNode=s,s._reactInternals=e,Mv(e,r,t,n),e=Ov(null,e,r,!0,o,n)):(e.tag=0,at&&o&&Nw(e),xn(null,e,s,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Qh(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=o8(r),t=Kr(r,t),s){case 0:e=jv(null,e,r,t,n);break e;case 1:e=fC(null,e,r,t,n);break e;case 11:e=dC(null,e,r,t,n);break e;case 14:e=hC(null,e,r,Kr(r.type,t),n);break e}throw Error(Y(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Kr(r,s),jv(t,e,r,s,n);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Kr(r,s),fC(t,e,r,s,n);case 3:e:{if(sT(e),t===null)throw Error(Y(387));r=e.pendingProps,o=e.memoizedState,s=o.element,Ak(t,e),tp(e,r,null,n);var i=e.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){s=Al(Error(Y(423)),e),e=pC(t,e,r,n,s);break e}else if(r!==s){s=Al(Error(Y(424)),e),e=pC(t,e,r,n,s);break e}else for(ir=oi(e.stateNode.containerInfo.firstChild),cr=e,at=!0,Yr=null,n=Tk(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(kl(),r===s){e=wo(t,e,n);break e}xn(t,e,r,n)}e=e.child}return e;case 5:return jk(e),t===null&&Ev(e),r=e.type,s=e.pendingProps,o=t!==null?t.memoizedProps:null,i=s.children,bv(r,s)?i=null:o!==null&&bv(r,o)&&(e.flags|=32),rT(t,e),xn(t,e,i,n),e.child;case 6:return t===null&&Ev(e),null;case 13:return oT(t,e,n);case 4:return Vw(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Tl(e,null,r,n):xn(t,e,r,n),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Kr(r,s),dC(t,e,r,s,n);case 7:return xn(t,e,e.pendingProps,n),e.child;case 8:return xn(t,e,e.pendingProps.children,n),e.child;case 12:return xn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,o=e.memoizedProps,i=s.value,qe(Jf,r._currentValue),r._currentValue=i,o!==null)if(os(o.value,i)){if(o.children===s.children&&!Gn.current){e=wo(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var a=o.dependencies;if(a!==null){i=o.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=ho(-1,n&-n),l.tag=2;var c=o.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}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),kv(o.return,n,e),a.lanes|=n;break}l=l.next}}else if(o.tag===10)i=o.type===e.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(Y(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),kv(i,n,e),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===e){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}xn(t,e,s.children,n),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,yl(e,n),s=Rr(s),r=r(s),e.flags|=1,xn(t,e,r,n),e.child;case 14:return r=e.type,s=Kr(r,e.pendingProps),s=Kr(r.type,s),hC(t,e,r,s,n);case 15:return tT(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Kr(r,s),Qh(t,e),e.tag=1,Vn(r)?(t=!0,qf(e)):t=!1,yl(e,n),Qk(e,r,s),Mv(e,r,s,n),Ov(null,e,r,!0,t,n);case 19:return iT(t,e,n);case 22:return nT(t,e,n)}throw Error(Y(156,e.tag))};function bT(t,e){return X2(t,e)}function s8(t,e,n,r){this.tag=t,this.key=n,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=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ar(t,e,n,r){return new s8(t,e,n,r)}function l0(t){return t=t.prototype,!(!t||!t.isReactComponent)}function o8(t){if(typeof t=="function")return l0(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Ew)return 11;if(t===kw)return 14}return 2}function ci(t,e){var n=t.alternate;return n===null?(n=Ar(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tf(t,e,n,r,s,o){var i=2;if(r=t,typeof t=="function")l0(t)&&(i=1);else if(typeof t=="string")i=5;else e:switch(t){case Va:return Zi(n.children,s,o,e);case Iw:i=8,s|=8;break;case ev:return t=Ar(12,n,e,s|2),t.elementType=ev,t.lanes=o,t;case tv:return t=Ar(13,n,e,s),t.elementType=tv,t.lanes=o,t;case nv:return t=Ar(19,n,e,s),t.elementType=nv,t.lanes=o,t;case j2:return hg(n,s,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case M2:i=10;break e;case A2:i=9;break e;case Ew:i=11;break e;case kw:i=14;break e;case Ko:i=16,r=null;break e}throw Error(Y(130,t==null?t:typeof t,""))}return e=Ar(i,n,e,s),e.elementType=t,e.type=r,e.lanes=o,e}function Zi(t,e,n,r){return t=Ar(7,t,r,e),t.lanes=n,t}function hg(t,e,n,r){return t=Ar(22,t,r,e),t.elementType=j2,t.lanes=n,t.stateNode={isHidden:!1},t}function ly(t,e,n){return t=Ar(6,t,null,e),t.lanes=n,t}function cy(t,e,n){return e=Ar(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function i8(t,e,n,r,s){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=Hm(0),this.expirationTimes=Hm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hm(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function c0(t,e,n,r,s,o,i,a,l){return t=new i8(t,e,n,a,l),e===1?(e=1,o===!0&&(e|=8)):e=0,o=Ar(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gw(o),t}function a8(t,e,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ga,key:r==null?null:""+r,children:t,containerInfo:e,implementation:n}}function PT(t){if(!t)return pi;t=t._reactInternals;e:{if(wa(t)!==t||t.tag!==1)throw Error(Y(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Vn(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(Y(171))}if(t.tag===1){var n=t.type;if(Vn(n))return Pk(t,n,e)}return e}function CT(t,e,n,r,s,o,i,a,l){return t=c0(n,r,!0,t,s,o,i,a,l),t.context=PT(null),n=t.current,r=Pn(),s=li(n),o=ho(r,s),o.callback=e??null,ii(n,o,s),t.current.lanes=s,ed(t,s,r),Yn(t,r),t}function fg(t,e,n,r){var s=e.current,o=Pn(),i=li(s);return n=PT(n),e.context===null?e.context=n:e.pendingContext=n,e=ho(o,i),e.payload={element:t},r=r===void 0?null:r,r!==null&&(e.callback=r),t=ii(s,e,i),t!==null&&(ts(t,s,i,o),Xh(t,s,i)),i}function cp(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 CC(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function u0(t,e){CC(t,e),(t=t.alternate)&&CC(t,e)}var _T=typeof reportError=="function"?reportError:function(t){console.error(t)};function d0(t){this._internalRoot=t}pg.prototype.render=d0.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(Y(409));fg(t,e,null,null)};pg.prototype.unmount=d0.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;ia(function(){fg(null,t,null,null)}),e[vo]=null}};function pg(t){this._internalRoot=t}pg.prototype.unstable_scheduleHydration=function(t){if(t){var e=nk();t={blockedOn:null,target:t,priority:e};for(var n=0;n<Go.length&&e!==0&&e<Go[n].priority;n++);Go.splice(n,0,t),n===0&&sk(t)}};function h0(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function gg(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function _C(){}function l8(t,e,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var c=cp(i);o.call(c)}}var i=CT(e,r,t,0,null,!1,!1,"",_C);return t._reactRootContainer=i,t[vo]=i.current,_u(t.nodeType===8?t.parentNode:t),ia(),i}for(;s=t.lastChild;)t.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var c=cp(l);a.call(c)}}var l=c0(t,0,!1,null,null,!1,!1,"",_C);return t._reactRootContainer=l,t[vo]=l.current,_u(t.nodeType===8?t.parentNode:t),ia(function(){fg(e,l,n,r)}),l}function mg(t,e,n,r,s){var o=n._reactRootContainer;if(o){var i=o;if(typeof s=="function"){var a=s;s=function(){var l=cp(i);a.call(l)}}fg(e,i,t,s)}else i=l8(n,e,t,s,r);return cp(i)}ek=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=zc(e.pendingLanes);n!==0&&(Aw(e,n|1),Yn(e,xt()),!(Oe&6)&&(jl=xt()+500,Ci()))}break;case 13:ia(function(){var r=xo(t,1);if(r!==null){var s=Pn();ts(r,t,1,s)}}),u0(t,1)}};jw=function(t){if(t.tag===13){var e=xo(t,134217728);if(e!==null){var n=Pn();ts(e,t,134217728,n)}u0(t,134217728)}};tk=function(t){if(t.tag===13){var e=li(t),n=xo(t,e);if(n!==null){var r=Pn();ts(n,t,e,r)}u0(t,e)}};nk=function(){return Be};rk=function(t,e){var n=Be;try{return Be=t,e()}finally{Be=n}};hv=function(t,e,n){switch(e){case"input":if(ov(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var r=n[e];if(r!==t&&r.form===t.form){var s=ig(r);if(!s)throw Error(Y(90));D2(r),ov(r,s)}}}break;case"textarea":L2(t,n);break;case"select":e=n.value,e!=null&&fl(t,!!n.multiple,e,!1)}};H2=o0;K2=ia;var c8={usingClientEntryPoint:!1,Events:[nd,Za,ig,B2,U2,o0]},xc={findFiberByHostInstance:Gi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},u8={bundleType:xc.bundleType,version:xc.version,rendererPackageName:xc.rendererPackageName,rendererConfig:xc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_o.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=V2(t),t===null?null:t.stateNode},findFiberByHostInstance:xc.findFiberByHostInstance,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 th=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!th.isDisabled&&th.supportsFiber)try{ng=th.inject(u8),Ts=th}catch{}}Sr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=c8;Sr.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h0(e))throw Error(Y(200));return a8(t,e,null,n)};Sr.createRoot=function(t,e){if(!h0(t))throw Error(Y(299));var n=!1,r="",s=_T;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(r=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=c0(t,1,!1,null,null,n,!1,r,s),t[vo]=e.current,_u(t.nodeType===8?t.parentNode:t),new d0(e)};Sr.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(Y(188)):(t=Object.keys(t).join(","),Error(Y(268,t)));return t=V2(e),t=t===null?null:t.stateNode,t};Sr.flushSync=function(t){return ia(t)};Sr.hydrate=function(t,e,n){if(!gg(e))throw Error(Y(200));return mg(null,t,e,!0,n)};Sr.hydrateRoot=function(t,e,n){if(!h0(t))throw Error(Y(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",i=_T;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),e=CT(e,null,t,1,n??null,s,!1,o,i),t[vo]=e.current,_u(t),r)for(t=0;t<r.length;t++)n=r[t],s=n._getVersion,s=s(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,s]:e.mutableSourceEagerHydrationData.push(n,s);return new pg(e)};Sr.render=function(t,e,n){if(!gg(e))throw Error(Y(200));return mg(null,t,e,!1,n)};Sr.unmountComponentAtNode=function(t){if(!gg(t))throw Error(Y(40));return t._reactRootContainer?(ia(function(){mg(null,null,t,!1,function(){t._reactRootContainer=null,t[vo]=null})}),!0):!1};Sr.unstable_batchedUpdates=o0;Sr.unstable_renderSubtreeIntoContainer=function(t,e,n,r){if(!gg(n))throw Error(Y(200));if(t==null||t._reactInternals===void 0)throw Error(Y(38));return mg(t,e,n,!1,r)};Sr.version="18.3.1-next-f1338f8080-20240426";function IT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(IT)}catch(t){console.error(t)}}IT(),I2.exports=Sr;var ba=I2.exports;const d8=wi(ba);var ET,IC=ba;ET=QS.createRoot=IC.createRoot,QS.hydrateRoot=IC.hydrateRoot;function ae(t,e={}){const n=typeof t=="string"?t:t.src;if(typeof e=="function")return e(n);const{baseUrl:r=""}=e;return n.startsWith("data:")||n.match(/^https?:\/\//)?n:`${r.replace(/\/$/,"")}/${n.replace(/^\.?\//,"")}`}function h8(t){const e=ae("./icons/icon/0_merged.svg",t);return{fonts:{monospace:ae("./fonts/IBMPlexMono-Medium.woff2",t),sansSerif:ae("./fonts/IBMPlexSans-Medium.woff2",t),serif:ae("./fonts/IBMPlexSerif-Medium.woff2",t),draw:ae("./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:ae("./translations/ar.json",t),ca:ae("./translations/ca.json",t),cs:ae("./translations/cs.json",t),da:ae("./translations/da.json",t),de:ae("./translations/de.json",t),en:ae("./translations/en.json",t),es:ae("./translations/es.json",t),fa:ae("./translations/fa.json",t),fi:ae("./translations/fi.json",t),fr:ae("./translations/fr.json",t),gl:ae("./translations/gl.json",t),he:ae("./translations/he.json",t),"hi-in":ae("./translations/hi-in.json",t),hr:ae("./translations/hr.json",t),hu:ae("./translations/hu.json",t),id:ae("./translations/id.json",t),it:ae("./translations/it.json",t),ja:ae("./translations/ja.json",t),"ko-kr":ae("./translations/ko-kr.json",t),ku:ae("./translations/ku.json",t),languages:ae("./translations/languages.json",t),main:ae("./translations/main.json",t),my:ae("./translations/my.json",t),ne:ae("./translations/ne.json",t),no:ae("./translations/no.json",t),pl:ae("./translations/pl.json",t),"pt-br":ae("./translations/pt-br.json",t),"pt-pt":ae("./translations/pt-pt.json",t),ro:ae("./translations/ro.json",t),ru:ae("./translations/ru.json",t),sl:ae("./translations/sl.json",t),so:ae("./translations/so.json",t),sv:ae("./translations/sv.json",t),te:ae("./translations/te.json",t),th:ae("./translations/th.json",t),tr:ae("./translations/tr.json",t),uk:ae("./translations/uk.json",t),vi:ae("./translations/vi.json",t),"zh-cn":ae("./translations/zh-cn.json",t),"zh-tw":ae("./translations/zh-tw.json",t)},embedIcons:{codepen:ae("./embed-icons/codepen.png",t),codesandbox:ae("./embed-icons/codesandbox.png",t),desmos:ae("./embed-icons/desmos.png",t),excalidraw:ae("./embed-icons/excalidraw.png",t),felt:ae("./embed-icons/felt.png",t),figma:ae("./embed-icons/figma.png",t),github_gist:ae("./embed-icons/github_gist.png",t),google_calendar:ae("./embed-icons/google_calendar.png",t),google_maps:ae("./embed-icons/google_maps.png",t),google_slides:ae("./embed-icons/google_slides.png",t),observable:ae("./embed-icons/observable.png",t),replit:ae("./embed-icons/replit.png",t),scratch:ae("./embed-icons/scratch.png",t),spotify:ae("./embed-icons/spotify.png",t),tldraw:ae("./embed-icons/tldraw.png",t),val_town:ae("./embed-icons/val_town.png",t),vimeo:ae("./embed-icons/vimeo.png",t),youtube:ae("./embed-icons/youtube.png",t)}}}const uy="__TLDRAW_LIBRARY_VERSIONS__";function f8(){if(globalThis[uy])return globalThis[uy];const t={versions:[],didWarn:!1,scheduledNotice:null};return Object.defineProperty(globalThis,uy,{value:t,writable:!1,configurable:!1,enumerable:!1}),t}function _i(t,e,n){if(!t)throw new Error("Missing name/version/module system in built version of tldraw library");const r=f8();if(r.versions.push({name:t,version:e,modules:n}),!r.scheduledNotice)try{r.scheduledNotice=setTimeout(()=>{r.scheduledNotice=null,EC(r)},100)}catch{EC(r)}}function EC(t){if(!t.versions.length||t.didWarn)return;const e=t.versions.sort((a,l)=>kC(a.version,l.version)),n=e[e.length-1].version,r=new Set,s=new Map;for(const a of e){if(s.has(a.name)){r.delete(a.name),dy(s,a.name,new Set).add(a.version);continue}a.version===n?r.add(a.name):(r.delete(a.name),dy(s,a.name,new Set).add(a.version))}if(s.size>0){const a=[`${Zs("[tldraw]",["bold","bgRed","textWhite"])} ${Zs("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 ${Zs(`v${n}`,["bold","textBlue"])}. The following libraries are on the latest version:`,...Array.from(r,l=>` • ✅ ${Zs(l,["bold"])}`),"","The following libraries are not on the latest version, or have multiple versions installed:",...Array.from(s,([l,c])=>{const u=Array.from(c).sort(kC).map(h=>Zs(`v${h}`,h===n?["textGreen"]:["textRed"]));return` • ❌ ${Zs(l,["bold"])} (${u.join(", ")})`})];console.log(a.join(`
|
|
41
|
-
`)),t.didWarn=!0;return}const o=new Map;for(const a of e)dy(o,a.name,{version:a.version,modules:[]}).modules.push(a.modules);const i=new Map;for(const[a,l]of o)l.modules.length>1&&i.set(a,l);if(i.size>0){const a=[`${Zs("[tldraw]",["bold","bgRed","textWhite"])} ${Zs("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(i,([l,c])=>{const u=c.modules.map((h,f)=>h==="esm"?` ${f+1}. ES Modules`:` ${f+1}. CommonJS`).join(`
|
|
42
|
-
`);return` • ❌ ${Zs(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 kC(t,e){const n=t.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/),r=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/);return!n||!r?t.localeCompare(e):n[1]!==r[1]?Number(n[1])-Number(r[1]):n[2]!==r[2]?Number(n[2])-Number(r[2]):n[3]!==r[3]?Number(n[3])-Number(r[3]):n[4]&&r[4]?n[4].localeCompare(r[4]):n[4]?1:r[4]?-1:0}const p8={bold:"1",textBlue:"94",textRed:"31",textGreen:"32",bgRed:"41",textWhite:"97"};function Zs(t,e=[]){return`\x1B[${e.map(n=>p8[n]).join(";")}m${t}\x1B[m`}function dy(t,e,n){return t.has(e)?t.get(e):(t.set(e,n),n)}var kT="Expected a function",TC=NaN,g8="[object Symbol]",m8=/^\s+|\s+$/g,y8=/^[-+]0x[0-9a-f]+$/i,S8=/^0b[01]+$/i,v8=/^0o[0-7]+$/i,x8=parseInt,w8=typeof dn=="object"&&dn&&dn.Object===Object&&dn,b8=typeof self=="object"&&self&&self.Object===Object&&self,P8=w8||b8||Function("return this")(),C8=Object.prototype,_8=C8.toString,I8=Math.max,E8=Math.min,hy=function(){return P8.Date.now()};function k8(t,e,n){var r,s,o,i,a,l,c=0,u=!1,h=!1,f=!0;if(typeof t!="function")throw new TypeError(kT);e=MC(e)||0,up(n)&&(u=!!n.leading,h="maxWait"in n,o=h?I8(MC(n.maxWait)||0,e):o,f="trailing"in n?!!n.trailing:f);function p(_){var E=r,k=s;return r=s=void 0,c=_,i=t.apply(k,E),i}function g(_){return c=_,a=setTimeout(y,e),u?p(_):i}function m(_){var E=_-l,k=_-c,D=e-E;return h?E8(D,o-k):D}function v(_){var E=_-l,k=_-c;return l===void 0||E>=e||E<0||h&&k>=o}function y(){var _=hy();if(v(_))return S(_);a=setTimeout(y,m(_))}function S(_){return a=void 0,f&&r?p(_):(r=s=void 0,i)}function b(){a!==void 0&&clearTimeout(a),c=0,r=l=s=a=void 0}function P(){return a===void 0?i:S(hy())}function C(){var _=hy(),E=v(_);if(r=arguments,s=this,l=_,E){if(a===void 0)return g(l);if(h)return a=setTimeout(y,e),p(l)}return a===void 0&&(a=setTimeout(y,e)),i}return C.cancel=b,C.flush=P,C}function T8(t,e,n){var r=!0,s=!0;if(typeof t!="function")throw new TypeError(kT);return up(n)&&(r="leading"in n?!!n.leading:r,s="trailing"in n?!!n.trailing:s),k8(t,e,{leading:r,maxWait:e,trailing:s})}function up(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function M8(t){return!!t&&typeof t=="object"}function A8(t){return typeof t=="symbol"||M8(t)&&_8.call(t)==g8}function MC(t){if(typeof t=="number")return t;if(A8(t))return TC;if(up(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=up(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=t.replace(m8,"");var n=S8.test(t);return n||v8.test(t)?x8(t.slice(2),n?2:8):y8.test(t)?TC:+t}var j8=T8;const TT=wi(j8);var O8=200,f0="__lodash_hash_undefined__",D8=1/0,R8="[object Function]",L8="[object GeneratorFunction]",$8=/[\\^$.*+?()[\]{}|]/g,F8=/^\[object .+?Constructor\]$/,N8=typeof dn=="object"&&dn&&dn.Object===Object&&dn,z8=typeof self=="object"&&self&&self.Object===Object&&self,p0=N8||z8||Function("return this")();function B8(t,e){var n=t?t.length:0;return!!n&&H8(t,e,0)>-1}function U8(t,e,n,r){for(var s=t.length,o=n+-1;++o<s;)if(e(t[o],o,t))return o;return-1}function H8(t,e,n){if(e!==e)return U8(t,K8,n);for(var r=n-1,s=t.length;++r<s;)if(t[r]===e)return r;return-1}function K8(t){return t!==t}function W8(t,e){return t.has(e)}function G8(t,e){return t==null?void 0:t[e]}function V8(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function MT(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var Y8=Array.prototype,X8=Function.prototype,AT=Object.prototype,fy=p0["__core-js_shared__"],AC=function(){var t=/[^.]+$/.exec(fy&&fy.keys&&fy.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),jT=X8.toString,g0=AT.hasOwnProperty,q8=AT.toString,Z8=RegExp("^"+jT.call(g0).replace($8,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Q8=Y8.splice,J8=m0(p0,"Map"),py=m0(p0,"Set"),Du=m0(Object,"create");function aa(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function e9(){this.__data__=Du?Du(null):{}}function t9(t){return this.has(t)&&delete this.__data__[t]}function n9(t){var e=this.__data__;if(Du){var n=e[t];return n===f0?void 0:n}return g0.call(e,t)?e[t]:void 0}function r9(t){var e=this.__data__;return Du?e[t]!==void 0:g0.call(e,t)}function s9(t,e){var n=this.__data__;return n[t]=Du&&e===void 0?f0:e,this}aa.prototype.clear=e9;aa.prototype.delete=t9;aa.prototype.get=n9;aa.prototype.has=r9;aa.prototype.set=s9;function Wl(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function o9(){this.__data__=[]}function i9(t){var e=this.__data__,n=yg(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Q8.call(e,n,1),!0}function a9(t){var e=this.__data__,n=yg(e,t);return n<0?void 0:e[n][1]}function l9(t){return yg(this.__data__,t)>-1}function c9(t,e){var n=this.__data__,r=yg(n,t);return r<0?n.push([t,e]):n[r][1]=e,this}Wl.prototype.clear=o9;Wl.prototype.delete=i9;Wl.prototype.get=a9;Wl.prototype.has=l9;Wl.prototype.set=c9;function Gl(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function u9(){this.__data__={hash:new aa,map:new(J8||Wl),string:new aa}}function d9(t){return Sg(this,t).delete(t)}function h9(t){return Sg(this,t).get(t)}function f9(t){return Sg(this,t).has(t)}function p9(t,e){return Sg(this,t).set(t,e),this}Gl.prototype.clear=u9;Gl.prototype.delete=d9;Gl.prototype.get=h9;Gl.prototype.has=f9;Gl.prototype.set=p9;function dp(t){var e=-1,n=t?t.length:0;for(this.__data__=new Gl;++e<n;)this.add(t[e])}function g9(t){return this.__data__.set(t,f0),this}function m9(t){return this.__data__.has(t)}dp.prototype.add=dp.prototype.push=g9;dp.prototype.has=m9;function yg(t,e){for(var n=t.length;n--;)if(C9(t[n][0],e))return n;return-1}function y9(t){if(!OT(t)||w9(t))return!1;var e=_9(t)||V8(t)?Z8:F8;return e.test(b9(t))}function S9(t,e,n){var r=-1,s=B8,o=t.length,i=!0,a=[],l=a;if(o>=O8){var c=v9(t);if(c)return MT(c);i=!1,s=W8,l=new dp}else l=a;e:for(;++r<o;){var u=t[r],h=u;if(u=u!==0?u:0,i&&h===h){for(var f=l.length;f--;)if(l[f]===h)continue e;a.push(u)}else s(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}var v9=py&&1/MT(new py([,-0]))[1]==D8?function(t){return new py(t)}:I9;function Sg(t,e){var n=t.__data__;return x9(e)?n[typeof e=="string"?"string":"hash"]:n.map}function m0(t,e){var n=G8(t,e);return y9(n)?n:void 0}function x9(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function w9(t){return!!AC&&AC in t}function b9(t){if(t!=null){try{return jT.call(t)}catch{}try{return t+""}catch{}}return""}function P9(t){return t&&t.length?S9(t):[]}function C9(t,e){return t===e||t!==t&&e!==e}function _9(t){var e=OT(t)?q8.call(t):"";return e==R8||e==L8}function OT(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function I9(){}var E9=P9;const k9=wi(E9);function DT(t){const e=(...n)=>{try{return t(...n)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,e),r}};return e}const Ru=()=>{},wn={ok(t){return{ok:!0,value:t}},err(t){return{ok:!1,error:t}}};function Ot(t,e){const n=e&&t&&typeof t=="object"&&e in t?t[e]:t;throw new Error(`Unknown switch case ${n}`)}const Le=DT((t,e)=>{if(!t)throw new Error(e||"Assertion Error")}),zn=DT((t,e)=>{if(t==null)throw new Error(e??"value must be defined");return t});function y0(){let t,e;const n=new Promise((r,s)=>{t=r,e=s});return Object.assign(n,{resolve:t,reject:e})}function Wv(t){return new Promise(e=>setTimeout(e,t))}const Uc={Good:"#40C057",Mid:"#FFC078",Poor:"#E03131"},T9=Uc.Good;class RT{constructor(){I(this,"startTime",0);I(this,"name","");I(this,"frames",0);I(this,"started",!1);I(this,"frame",null);I(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,n=e===0?0:Math.floor(this.frames/e),r=n>55?Uc.Good:n>30?Uc.Mid:Uc.Poor,s=r===Uc.Mid?"black":"white",o=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${o} %c${n}%c fps`,`color: white; background: ${T9};padding: 2px;border-radius: 3px;`,"font-weight: normal",`font-weight: bold; padding: 2px; background: ${r};color: ${s};`,"font-weight: normal")}isStarted(){return this.started}}function S0(t,e){const n=[];e:for(const r of t){for(const s of n)if(e?e(r,s):r===s)continue e;n.push(r)}return n}function me(t){return t.filter(e=>e!=null)}function Ht(t){return t[t.length-1]}function M9(t,e){let n,r=1/0;for(const s of t){const o=e(s);o<r&&(n=s,r=o)}return n}function A9(t,e){let n,r=-1/0;for(const s of t){const o=e(s);o>r&&(n=s,r=o)}return n}function LT(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Kn(...t){if(t.length===2){const[e,n]=t;n.addInitializer(function(){Le(Reflect.isExtensible(this),"Cannot bind to a non-extensible class.");const s=e.bind(this),o=Reflect.defineProperty(this,n.name,{value:s,writable:!0,configurable:!0});Le(o,"Cannot bind a non-configurable class method.")})}else{const[e,n,r]=t;if(!r||typeof r.value!="function")throw new TypeError(`Only methods can be decorated with @bind. <${n}> is not a method!`);return{configurable:!0,get(){const s=r.value.bind(this);return Object.defineProperty(this,n,{value:s,configurable:!0,writable:!0}),s}}}}class Ds{constructor(){I(this,"items",new WeakMap)}get(e,n){return this.items.has(e)||this.items.set(e,n(e)),this.items.get(e)}}function vg(t,e){let n;const r=(...s)=>(n||(n={},n.promise=new Promise((o,i)=>{n.resolve=o,n.reject=i})),clearTimeout(n.timeout),n.latestArgs=s,n.timeout=setTimeout(()=>{const o=n;n=void 0;try{o.resolve(t(...o.latestArgs))}catch(i){o.reject(i)}},e),n.promise);return r.cancel=()=>{n&&clearTimeout(n.timeout)},r}const jC=new WeakMap;function v0(t,e){if(typeof t!="object"||t===null)return;let n=jC.get(t);n||(n={tags:{},extras:{}},jC.set(t,n)),e.tags&&(n.tags={...n.tags,...e.tags}),e.extras&&(n.extras={...n.extras,...e.extras})}async function Rs(t,e){return window.fetch(t,{referrerPolicy:"strict-origin-when-cross-origin",...e})}const Lu=(t,e)=>{const n=new window.Image(t,e);return n.referrerPolicy="strict-origin-when-cross-origin",n};class Zr{static async dataUrlToArrayBuffer(e){return Rs(e).then(function(n){return n.arrayBuffer()})}static async blobToDataUrl(e){return await new Promise((n,r)=>{if(e){const s=new FileReader;s.onload=()=>n(s.result),s.onerror=o=>r(o),s.onabort=o=>r(o),s.readAsDataURL(e)}})}static async blobToText(e){return await new Promise((n,r)=>{if(e){const s=new FileReader;s.onload=()=>n(s.result),s.onerror=o=>r(o),s.onabort=o=>r(o),s.readAsText(e)}})}static rewriteMimeType(e,n){return e.type===n?e:e instanceof File?new File([e],e.name,{type:n}):new Blob([e],{type:n})}}function Gv(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e+""}function OC(t){const e=new DataView(t);let n=0;for(let r=0;r<e.byteLength;r++)n=(n<<5)-n+e.getUint8(r),n|=0;return n+""}/*!
|
|
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 DC=globalThis.crypto,j9="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",O9=128;let Ki,sl;function D9(t){!Ki||Ki.length<t?(Ki=new Uint8Array(t*O9),DC.getRandomValues(Ki),sl=0):sl+t>Ki.length&&(DC.getRandomValues(Ki),sl=0),sl+=t}function R9(t=21){D9(t-=0);let e="";for(let n=sl-t;n<sl;n++)e+=j9[Ki[n]&63];return e}let L9=R9;function ze(t){return L9(t)}/*!
|
|
54
|
-
* MIT License: https://github.com/vHeemstra/is-apng/blob/main/license
|
|
55
|
-
* Copyright (c) Philip van Heemstra
|
|
56
|
-
*/function $9(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 r(o,i,a,l,c=1024){if(!i)return-1;i=new RegExp(i,"g");const u=i.source.length,h=new TextDecoder,f=o.length;if(typeof l>"u"&&(l=f),a>=f||l<=0||a>=l)return-1;o=o.subarray(a,l);let p=-1,g=0,m=0,v="";e:for(;g<o.length;){const y=g+c,S=o.subarray(g,y),b=h.decode(S,{stream:!0}),P=v+b;let C,_=-1;for(;(C=i.exec(P))!==null;){_=C.index-v.length,p=m+_;break e}g=y,m+=b.length;const E=_>-1?_+u:b.length-u;v=b.slice(E)}return p>=0&&(p+=a>=0?a:f+a),p}const s=r(e,"IDAT",12);return s>=12?r(e,"acTL",8,s)>=8:!1}const F9=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 RC(t,e){let n=0;for(;t[e+n];)n+=t[e+n]+1;return n+1}function N9(t){return new TextDecoder("ascii").decode(t.slice(0,3))==="GIF"}function z9(t){const e=new Uint8Array(t);let n,r,s=0,o=0;if(!N9(t))return!1;for(n=e[10]&128,r=e[10]&7,s+=6,s+=7,s+=n?3*Math.pow(2,r+1):0;o<2&&s<e.length;)switch(e[s]){case 44:o+=1,n=e[s+9]&128,r=e[s+9]&7,s+=10,s+=n?3*Math.pow(2,r+1):0,s+=RC(e,s+1)+1;break;case 33:s+=2,s+=RC(e,s);break;case 59:s=e.length;break;default:s=e.length;break}return o>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 Vv=[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"&&(Vv=new Int32Array(Vv));const B9=(t,e)=>{let n=-1;for(let r=0;r<t.length;r++)n=Vv[(n^t[r])&255]^n>>>8;return n^-1},LC=4,$C=4;class Ps{static isPng(e,n){return e.getUint8(n+0)===137&&e.getUint8(n+1)===80&&e.getUint8(n+2)===78&&e.getUint8(n+3)===71&&e.getUint8(n+4)===13&&e.getUint8(n+5)===10&&e.getUint8(n+6)===26&&e.getUint8(n+7)===10}static getChunkType(e,n){return[String.fromCharCode(e.getUint8(n)),String.fromCharCode(e.getUint8(n+1)),String.fromCharCode(e.getUint8(n+2)),String.fromCharCode(e.getUint8(n+3))].join("")}static readChunks(e,n=0){const r={};if(!Ps.isPng(e,n))throw new Error("Not a PNG");for(n+=8;n<=e.buffer.byteLength;){const s=n,o=e.getInt32(n);n+=4;const i=Ps.getChunkType(e,n);if(i==="IDAT"&&r[i]){n+=o+LC+$C;continue}if(i==="IEND")break;r[i]={start:s,dataOffset:n+4,size:o},n+=o+LC+$C}return r}static parsePhys(e,n){return{ppux:e.getUint32(n),ppuy:e.getUint32(n+4),unit:e.getUint8(n+4)}}static findChunk(e,n){return Ps.readChunks(e)[n]}static setPhysChunk(e,n=1,r){let s=46,o=0;const i=Ps.findChunk(e,"pHYs");i&&(s=i.start,o=i.size);const a=Ps.findChunk(e,"IDAT");a&&(s=a.start,o=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*n),c.setInt32(12,u*n),c.setInt8(16,1);const h=new Uint8Array(l.slice(4,17));c.setInt32(17,B9(h));const f=e.buffer.slice(0,s),p=e.buffer.slice(s+o);return new Blob([f,l,p],r)}}/*!
|
|
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 U9(t){return!t||t.length<12?!1:t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}function H9(t){const e=new Uint8Array(t);return!U9(e)||!e||e.length<21?!1:(e[20]>>1&1)===1}const $T=Object.freeze(["image/svg+xml"]),FT=Object.freeze(["image/jpeg","image/png","image/webp"]),NT=Object.freeze(["image/gif","image/apng","image/avif"]),xg=Object.freeze([...FT,...$T,...NT]),x0=Object.freeze(["video/mp4","video/webm","video/quicktime"]),K9=[...xg,...x0].join(",");class ar{static loadVideo(e){return new Promise((n,r)=>{const s=document.createElement("video");s.onloadeddata=()=>n(s),s.onerror=o=>{console.error(o),r(new Error("Could not load video"))},s.crossOrigin="anonymous",s.src=e})}static async getVideoFrameAsDataUrl(e,n=0){const r=y0();let s=!1;const o=()=>{if(!s)if(e.readyState>=e.HAVE_METADATA)s=!0,e.currentTime=n;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),r.resolve(a.toDataURL())}},i=a=>{console.error(a),r.reject(new Error("Could not get video frame"))};e.addEventListener("loadedmetadata",o),e.addEventListener("loadeddata",o),e.addEventListener("canplay",o),e.addEventListener("seeked",o),e.addEventListener("error",i),e.addEventListener("stalled",i),o();try{return await r}finally{e.removeEventListener("loadedmetadata",o),e.removeEventListener("loadeddata",o),e.removeEventListener("canplay",o),e.removeEventListener("seeked",o),e.removeEventListener("error",i),e.removeEventListener("stalled",i)}}static loadImage(e){return new Promise((n,r)=>{const s=Lu();s.onload=()=>n(s),s.onerror=o=>{console.error(o),r(new Error("Could not load image"))},s.crossOrigin="anonymous",s.referrerPolicy="strict-origin-when-cross-origin",s.src=e})}static async getVideoSize(e){return ar.usingObjectURL(e,async n=>{const r=await ar.loadVideo(n);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(e){const n=await ar.usingObjectURL(e,ar.loadImage);try{if(e.type==="image/png"){const r=new DataView(await e.arrayBuffer());if(Ps.isPng(r,0)){const s=Ps.findChunk(r,"pHYs");if(s){const o=Ps.parsePhys(r,s.dataOffset);if(o.unit===0&&o.ppux===o.ppuy){const i=Math.max(o.ppux/2834.5,1);return{w:Math.round(n.naturalWidth/i),h:Math.round(n.naturalHeight/i)}}}}}}catch(r){return console.error(r),{w:n.naturalWidth,h:n.naturalHeight}}return{w:n.naturalWidth,h:n.naturalHeight}}static async isAnimated(e){return e.type==="image/gif"?z9(await e.arrayBuffer()):e.type==="image/avif"?F9(await e.arrayBuffer()):e.type==="image/webp"?H9(await e.arrayBuffer()):e.type==="image/apng"?$9(await e.arrayBuffer()):!1}static isAnimatedImageType(e){return NT.includes(e||"")}static isStaticImageType(e){return FT.includes(e||"")}static isVectorImageType(e){return $T.includes(e||"")}static isImageType(e){return xg.includes(e)}static async usingObjectURL(e,n){const r=URL.createObjectURL(e);try{return await n(r)}finally{URL.revokeObjectURL(r)}}}function _e(t,e,n){return t+(e-t)*n}function cs(t=""){let e=0,n=0,r=0,s=0;function o(){const i=e^e<<11;return e=n,n=r,r=s,s^=(s>>>19^i^i>>>8)>>>0,s/4294967296*2}for(let i=0;i<t.length+64;i++)e^=t.charCodeAt(i)|0,o();return o}function Ol(t,e,n,r=!1){const[s,o]=e,[i,a]=n,l=i+(t-s)/(o-s)*(a-i);return r?i<a?Math.max(Math.min(l,a),i):Math.max(Math.min(l,i),a):l}function ns(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function hn(t,e){if(ns(t,e))return t[e]}function FC(t){return Object.keys(t)}function ut(t){return Object.values(t)}function Xn(t){return Object.entries(t)}function w0(t){return Object.fromEntries(t)}function au(t,e){const n={};let r=!1;for(const[s,o]of Xn(t))e(s,o)?n[s]=o:r=!0;return r?n:t}function sd(t,e){const n={};for(const[r,s]of Xn(t)){const o=e(r,s);n[r]=o}return n}function zT(t,e){if(t===e)return!0;const n=new Set(Object.keys(t)),r=new Set(Object.keys(e));if(n.size!==r.size)return!1;for(const s of n)if(!r.has(s)||!Object.is(t[s],e[s]))return!1;return!0}function W9(t){const e=G9(t.chars),n=V9(e,t.firstPositive,t.mostPositive,t.mostNegative),r=t.jitterRange??Math.floor(Math.pow(e.length,3)/5),s=Y9(r,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:n.firstPositive,mostPositive:n.mostPositive,firstNegative:n.firstNegative,mostNegative:n.mostNegative,jitterRange:r,paddingDict:s}}function G9(t){const e={},n={},r=t.length;for(let s=0;s<r;s++){const o=t[s];e[s]=o,n[o]=s}return{byCode:e,byChar:n,length:r}}function V9(t,e,n,r){const s=e?t.byChar[e]:Math.ceil(t.length/2),o=n?t.byChar[n]:t.length-1,i=r?t.byChar[r]:0;if(s===void 0||o===void 0||i===void 0)throw new Error("invalid charSet");if(o-s<3)throw new Error("mostPositive must be at least 3 characters away from neutral");if(s-i<3)throw new Error("mostNegative must be at least 3 characters away from neutral");return{firstPositive:t.byCode[s],mostPositive:t.byCode[o],firstNegative:t.byCode[s-1],mostNegative:t.byCode[i]}}function Y9(t,e){const n={};for(let r=0;r<100&&(n[r]=Math.pow(e,r),!(n[r]>t));r++);return n}var gy=null;function b0(){return gy||(gy=W9({chars:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",firstPositive:"a",mostPositive:"z",mostNegative:"A"}))}function Jo(t,e,n){const r=n.byChar[t],s=n.byChar[e];return Math.abs(r-s)}function P0(t,e){const n=t[0];if(n>e.mostPositive||n<e.mostNegative)throw new Error("invalid firstChar on key");return n===e.mostPositive?Jo(n,e.firstPositive,e)+1+hp(t.slice(1),"positive",e):n===e.mostNegative?Jo(n,e.firstNegative,e)+1+hp(t.slice(1),"negative",e):n>=e.firstPositive?Jo(n,e.firstPositive,e)+2:Jo(n,e.firstNegative,e)+2}function hp(t,e,n){const r=t[0];if(r>n.mostPositive||r<n.mostNegative)throw new Error("invalid firstChar on key");return r===n.mostPositive&&e==="positive"?Jo(r,n.mostNegative,n)+1+hp(t.slice(1),e,n):r===n.mostNegative&&e==="negative"?Jo(r,n.mostPositive,n)+1+hp(t.slice(1),e,n):e==="positive"?Jo(r,n.mostNegative,n)+2:Jo(r,n.mostPositive,n)+2}function wg(t,e,n,r,s){const o=Math.max(t.length,e.length);return n==="start"?[t.padStart(o,r),e.padStart(o,r)]:[t.padEnd(o,r),e.padEnd(o,r)]}function X9(t,e,n){let[r,s]=wg(t,e,"end",n.first),o=Yv(r,s,n);o===1&&(r=r.padEnd(r.length+1,n.first),o=n.length);const i=HT(Math.floor(o/2),n);return C0(r,i,n)}function Yv(t,e,n){const[r,s]=wg(t,e,"end",n.first).sort(),o=BT(s,r,n);return q9(o,n)}function C0(t,e,n){const r=n.length,[s,o]=wg(t,e,"start",n.first),i=[];let a=0;for(let l=s.length-1;l>=0;l--){const c=n.byChar[s[l]],u=n.byChar[o[l]],h=c+u+a;a=Math.floor(h/r);const f=h%r;i.unshift(n.byCode[f])}return a>0&&i.unshift(n.byCode[a]),i.join("")}function BT(t,e,n){const r=n.length,[s,o]=wg(t,e,"start",n.first),i=[];let a=0;for(let l=s.length-1;l>=0;l--){let c=n.byChar[s[l]];const u=n.byChar[o[l]]+a;c<u?(a=1,c+=r):a=0;const h=c-u;i.unshift(n.byCode[h])}if(a>0)throw new Error("Subtraction result is negative. Ensure a is greater than or equal to b.");for(;i.length>1&&i[0]===n.byCode[0];)i.shift();return i.join("")}function UT(t,e){return C0(t,e.byCode[1],e)}function Xv(t,e){return BT(t,e.byCode[1],e)}function HT(t,e){if(t===0)return e.byCode[0];let n="";const r=e.length;for(;t>0;)n=e.byCode[t%r]+n,t=Math.floor(t/r);return n}function q9(t,e){let n=0;const r=t.length,s=e.length;for(let o=0;o<r;o++)n+=e.byChar[t[o]]*Math.pow(s,r-o-1);return n}function Z9(t){return t.firstPositive+t.byCode[0]}function Q9(t,e){return P0(t,e)===t.length}function NC(t,e){fp(t,e)}function fp(t,e){const n=GT(t,e),r=P0(n,e);if(r>t.length)throw new Error("invalid order key length: "+t);return t.slice(0,r)}function KT(t,e){if(!Q9(t,e))throw new Error("invalid integer length: "+t)}function WT(t,e){KT(t,e);const[n,r]=VT(t,e);if(r.split("").some(i=>i!==e.byCode[e.length-1])){const i=UT(r,e);return n+i}const o=eB(n,e);return YT(o,"lower",e)}function J9(t,e){KT(t,e);const[n,r]=VT(t,e);if(r.split("").some(i=>i!==e.byCode[0])){const i=Xv(r,e);return n+i}const o=tB(n,e);return YT(o,"upper",e)}function GT(t,e){let n=0;if(t[0]===e.mostPositive)for(;t[n]===e.mostPositive;)n=n+1;if(t[0]===e.mostNegative)for(;t[n]===e.mostNegative;)n=n+1;return t.slice(0,n+1)}function VT(t,e){const n=GT(t,e),r=t.slice(n.length);return[n,r]}function eB(t,e){const n=t>=e.firstPositive,r=UT(t,e),s=t[t.length-1]===e.mostPositive,o=r[r.length-1]===e.mostPositive;return n&&o?r+e.mostNegative:!n&&s?t.slice(0,t.length-1):r}function tB(t,e){const n=t>=e.firstPositive,r=t[t.length-1]===e.mostNegative;if(n&&r){const s=t.slice(0,t.length-1);return Xv(s,e)}return!n&&r?t+e.mostPositive:Xv(t,e)}function YT(t,e,n){const r=P0(t,n),s=e==="upper"?n.byCode[n.length-1]:n.byCode[0];return t+s.repeat(r-t.length)}function XT(t,e){const n=HT(Math.floor(Math.random()*e.jitterRange),e);return C0(t,n,e)}function nB(t,e,n){const r=t.padEnd(t.length+e,n.first);return XT(r,n)}function rB(t,e,n){const r=fp(t,n),s=WT(r,n);let o=0;if(e!==null){const a=Yv(t,e,n);a<n.jitterRange+1&&(o=Math.max(o,zC(a,n)))}const i=Yv(t,s,n);return i<n.jitterRange+1&&(o=Math.max(o,zC(i,n))),o}function zC(t,e){const n=e.jitterRange-t,r=Object.entries(e.paddingDict).find(([s,o])=>o>n);return r?parseInt(r[0]):0}function sB(t,e,n=b0()){if(t!==null&&NC(t,n),e!==null&&NC(e,n),t===null&&e===null)return Z9(n);if(t===null){const r=fp(e,n);return J9(r,n)}if(e===null){const r=fp(t,n);return WT(r,n)}if(t>=e)throw new Error(t+" >= "+e);return X9(t,e,n)}function qT(t,e,n=b0()){const r=sB(t,e,n),s=rB(r,e,n);return s?nB(r,s,n):XT(r,n)}function ZT(t,e,n,r=b0()){return oB(t,e,n,r,qT,ZT)}function oB(t,e,n,r,s,o){if(n===0)return[];if(n===1)return[s(t,e,r)];if(e==null){let l=s(t,e,r);const c=[l];for(let u=0;u<n-1;u++)l=s(l,e,r),c.push(l);return c}if(t==null){let l=s(t,e,r);const c=[l];for(let u=0;u<n-1;u++)l=s(t,l,r),c.push(l);return c.reverse(),c}const i=Math.floor(n/2),a=s(t,e,r);return[...o(t,a,i,r),a,...o(a,e,n-i-1,r)]}const Vl=ZT,QT="a0";function iB(t){try{qT(t,null)}catch{throw new Error("invalid index: "+t)}}function Dl(t,e,n){return Vl(t??null,e??null,n)}function my(t,e){return Vl(t??null,null,e)}function $u(t,e){return Vl(t??null,e??null,1)[0]}function _s(t=null){return Vl(t,null,1)[0]}function aB(t=null){return Vl(null,t,1)[0]}function Fu(t,e="a1"){return[e,...Vl(e,null,t)]}function cn(t,e){return t.index<e.index?-1:t.index>e.index?1:0}function lB(t,e){return t.id>e.id?1:-1}function _0(t){try{return localStorage.getItem(t)}catch{return null}}function I0(t,e){try{localStorage.setItem(t,e)}catch{}}function cB(){try{localStorage.clear()}catch{}}function JT(t){try{return sessionStorage.getItem(t)}catch{return null}}function E0(t,e){try{sessionStorage.setItem(t,e)}catch{}}function eM(t){try{sessionStorage.removeItem(t)}catch{}}function uB(){try{sessionStorage.clear()}catch{}}const ol=[],dB=60,nf=Math.ceil(1e3/dB);let wc,yy=0,qv=0;const hB=()=>{const t=ol.splice(0,ol.length);for(const e of t)e()};function tM(){if(wc)return;const t=Date.now(),e=t-qv;if(yy+e<nf){wc=requestAnimationFrame(()=>{wc=void 0,tM()});return}wc=requestAnimationFrame(()=>{wc=void 0,qv=t,yy=Math.min(yy+e-nf,nf*10),hB()})}let BC=!1;function nM(t){return ol.includes(t)||(ol.push(t),BC||(BC=!0,qv=Date.now()-nf-1),tM()),()=>{const e=ol.indexOf(t);e>-1&&ol.splice(e,1)}}class fB{constructor(){I(this,"timeouts",new Map);I(this,"intervals",new Map);I(this,"rafs",new Map);this.setTimeout=this.setTimeout.bind(this),this.setInterval=this.setInterval.bind(this),this.requestAnimationFrame=this.requestAnimationFrame.bind(this),this.dispose=this.dispose.bind(this)}setTimeout(e,n,r,...s){const o=window.setTimeout(n,r,s),i=this.timeouts.get(e)??[];return this.timeouts.set(e,[...i,o]),o}setInterval(e,n,r,...s){const o=window.setInterval(n,r,s),i=this.intervals.get(e)??[];return this.intervals.set(e,[...i,o]),o}requestAnimationFrame(e,n){const r=window.requestAnimationFrame(n),s=this.rafs.get(e)??[];return this.rafs.set(e,[...s,r]),r}dispose(e){var n,r,s;(n=this.timeouts.get(e))==null||n.forEach(o=>clearTimeout(o)),(r=this.intervals.get(e))==null||r.forEach(o=>clearInterval(o)),(s=this.rafs.get(e))==null||s.forEach(o=>cancelAnimationFrame(o)),this.timeouts.delete(e),this.intervals.delete(e),this.rafs.delete(e)}disposeAll(){for(const e of this.timeouts.keys())this.dispose(e)}forContext(e){return{setTimeout:(n,r,...s)=>this.setTimeout(e,n,r,s),setInterval:(n,r,...s)=>this.setInterval(e,n,r,s),requestAnimationFrame:n=>this.requestAnimationFrame(e,n),dispose:()=>this.dispose(e)}}}const ge=(t,e)=>{try{return new URL(t,e)}catch{return}};function pB(t){return t!==void 0}function gB(){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 rM=gB(),nt=rM[0];rM[1];const mB=Object.getPrototypeOf(nt({}));_i("@tldraw/utils","3.7.2","esm");var bc=function(t){return t&&t.Math===Math&&t},In=bc(typeof globalThis=="object"&&globalThis)||bc(typeof window=="object"&&window)||bc(typeof self=="object"&&self)||bc(typeof dn=="object"&&dn)||bc(typeof dn=="object"&&dn)||function(){return this}()||Function("return this")(),k0={},En=function(t){try{return!!t()}catch{return!0}},yB=En,Ii=!yB(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),SB=En,bg=!SB(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),vB=bg,nh=Function.prototype.call,Io=vB?nh.bind(nh):function(){return nh.apply(nh,arguments)},sM={},oM={}.propertyIsEnumerable,iM=Object.getOwnPropertyDescriptor,xB=iM&&!oM.call({1:2},1);sM.f=xB?function(e){var n=iM(this,e);return!!n&&n.enumerable}:oM;var aM=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},lM=bg,cM=Function.prototype,Zv=cM.call,wB=lM&&cM.bind.bind(Zv,Zv),Lt=lM?wB:function(t){return function(){return Zv.apply(t,arguments)}},uM=Lt,bB=uM({}.toString),PB=uM("".slice),Yl=function(t){return PB(bB(t),8,-1)},CB=Lt,_B=En,IB=Yl,Sy=Object,EB=CB("".split),kB=_B(function(){return!Sy("z").propertyIsEnumerable(0)})?function(t){return IB(t)==="String"?EB(t,""):Sy(t)}:Sy,Pg=function(t){return t==null},TB=Pg,MB=TypeError,Xl=function(t){if(TB(t))throw new MB("Can't call method on "+t);return t},AB=kB,jB=Xl,Cg=function(t){return AB(jB(t))},vy=typeof document=="object"&&document.all,kn=typeof vy>"u"&&vy!==void 0?function(t){return typeof t=="function"||t===vy}:function(t){return typeof t=="function"},OB=kn,Pa=function(t){return typeof t=="object"?t!==null:OB(t)},xy=In,DB=kn,RB=function(t){return DB(t)?t:void 0},_g=function(t,e){return arguments.length<2?RB(xy[t]):xy[t]&&xy[t][e]},LB=Lt,dM=LB({}.isPrototypeOf),$B=In,UC=$B.navigator,HC=UC&&UC.userAgent,FB=HC?String(HC):"",hM=In,wy=FB,KC=hM.process,WC=hM.Deno,GC=KC&&KC.versions||WC&&WC.version,VC=GC&&GC.v8,Xr,pp;VC&&(Xr=VC.split("."),pp=Xr[0]>0&&Xr[0]<4?1:+(Xr[0]+Xr[1]));!pp&&wy&&(Xr=wy.match(/Edge\/(\d+)/),(!Xr||Xr[1]>=74)&&(Xr=wy.match(/Chrome\/(\d+)/),Xr&&(pp=+Xr[1])));var NB=pp,YC=NB,zB=En,BB=In,UB=BB.String,fM=!!Object.getOwnPropertySymbols&&!zB(function(){var t=Symbol("symbol detection");return!UB(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&YC&&YC<41}),HB=fM,pM=HB&&!Symbol.sham&&typeof Symbol.iterator=="symbol",KB=_g,WB=kn,GB=dM,VB=pM,YB=Object,gM=VB?function(t){return typeof t=="symbol"}:function(t){var e=KB("Symbol");return WB(e)&&GB(e.prototype,YB(t))},XB=String,qB=function(t){try{return XB(t)}catch{return"Object"}},ZB=kn,QB=qB,JB=TypeError,T0=function(t){if(ZB(t))return t;throw new JB(QB(t)+" is not a function")},e7=T0,t7=Pg,M0=function(t,e){var n=t[e];return t7(n)?void 0:e7(n)},by=Io,Py=kn,Cy=Pa,n7=TypeError,r7=function(t,e){var n,r;if(e==="string"&&Py(n=t.toString)&&!Cy(r=by(n,t))||Py(n=t.valueOf)&&!Cy(r=by(n,t))||e!=="string"&&Py(n=t.toString)&&!Cy(r=by(n,t)))return r;throw new n7("Can't convert object to primitive value")},mM={exports:{}},XC=In,s7=Object.defineProperty,A0=function(t,e){try{s7(XC,t,{value:e,configurable:!0,writable:!0})}catch{XC[t]=e}return e},o7=In,i7=A0,qC="__core-js_shared__",ZC=mM.exports=o7[qC]||i7(qC,{});(ZC.versions||(ZC.versions=[])).push({version:"3.40.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"});var j0=mM.exports,QC=j0,O0=function(t,e){return QC[t]||(QC[t]=e||{})},a7=Xl,l7=Object,od=function(t){return l7(a7(t))},c7=Lt,u7=od,d7=c7({}.hasOwnProperty),Ei=Object.hasOwn||function(e,n){return d7(u7(e),n)},h7=Lt,f7=0,p7=Math.random(),g7=h7(1 .toString),yM=function(t){return"Symbol("+(t===void 0?"":t)+")_"+g7(++f7+p7,36)},m7=In,y7=O0,JC=Ei,S7=yM,v7=fM,x7=pM,il=m7.Symbol,_y=y7("wks"),w7=x7?il.for||il:il&&il.withoutSetter||S7,Eo=function(t){return JC(_y,t)||(_y[t]=v7&&JC(il,t)?il[t]:w7("Symbol."+t)),_y[t]},b7=Io,e_=Pa,t_=gM,P7=M0,C7=r7,_7=Eo,I7=TypeError,E7=_7("toPrimitive"),k7=function(t,e){if(!e_(t)||t_(t))return t;var n=P7(t,E7),r;if(n){if(e===void 0&&(e="default"),r=b7(n,t,e),!e_(r)||t_(r))return r;throw new I7("Can't convert object to primitive value")}return e===void 0&&(e="number"),C7(t,e)},T7=k7,M7=gM,SM=function(t){var e=T7(t,"string");return M7(e)?e:e+""},A7=In,n_=Pa,Qv=A7.document,j7=n_(Qv)&&n_(Qv.createElement),vM=function(t){return j7?Qv.createElement(t):{}},O7=Ii,D7=En,R7=vM,xM=!O7&&!D7(function(){return Object.defineProperty(R7("div"),"a",{get:function(){return 7}}).a!==7}),L7=Ii,$7=Io,F7=sM,N7=aM,z7=Cg,B7=SM,U7=Ei,H7=xM,r_=Object.getOwnPropertyDescriptor;k0.f=L7?r_:function(e,n){if(e=z7(e),n=B7(n),H7)try{return r_(e,n)}catch{}if(U7(e,n))return N7(!$7(F7.f,e,n),e[n])};var ql={},K7=Ii,W7=En,wM=K7&&W7(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),G7=Pa,V7=String,Y7=TypeError,Ca=function(t){if(G7(t))return t;throw new Y7(V7(t)+" is not an object")},X7=Ii,q7=xM,Z7=wM,rh=Ca,s_=SM,Q7=TypeError,Iy=Object.defineProperty,J7=Object.getOwnPropertyDescriptor,Ey="enumerable",ky="configurable",Ty="writable";ql.f=X7?Z7?function(e,n,r){if(rh(e),n=s_(n),rh(r),typeof e=="function"&&n==="prototype"&&"value"in r&&Ty in r&&!r[Ty]){var s=J7(e,n);s&&s[Ty]&&(e[n]=r.value,r={configurable:ky in r?r[ky]:s[ky],enumerable:Ey in r?r[Ey]:s[Ey],writable:!1})}return Iy(e,n,r)}:Iy:function(e,n,r){if(rh(e),n=s_(n),rh(r),q7)try{return Iy(e,n,r)}catch{}if("get"in r||"set"in r)throw new Q7("Accessors not supported");return"value"in r&&(e[n]=r.value),e};var eU=Ii,tU=ql,nU=aM,D0=eU?function(t,e,n){return tU.f(t,e,nU(1,n))}:function(t,e,n){return t[e]=n,t},bM={exports:{}},Jv=Ii,rU=Ei,PM=Function.prototype,sU=Jv&&Object.getOwnPropertyDescriptor,R0=rU(PM,"name"),oU=R0&&(function(){}).name==="something",iU=R0&&(!Jv||Jv&&sU(PM,"name").configurable),aU={EXISTS:R0,PROPER:oU,CONFIGURABLE:iU},lU=Lt,cU=kn,ex=j0,uU=lU(Function.toString);cU(ex.inspectSource)||(ex.inspectSource=function(t){return uU(t)});var CM=ex.inspectSource,dU=In,hU=kn,o_=dU.WeakMap,fU=hU(o_)&&/native code/.test(String(o_)),pU=O0,gU=yM,i_=pU("keys"),_M=function(t){return i_[t]||(i_[t]=gU(t))},L0={},mU=fU,IM=In,yU=Pa,SU=D0,My=Ei,Ay=j0,vU=_M,xU=L0,a_="Object already initialized",tx=IM.TypeError,wU=IM.WeakMap,gp,Nu,mp,bU=function(t){return mp(t)?Nu(t):gp(t,{})},PU=function(t){return function(e){var n;if(!yU(e)||(n=Nu(e)).type!==t)throw new tx("Incompatible receiver, "+t+" required");return n}};if(mU||Ay.state){var ms=Ay.state||(Ay.state=new wU);ms.get=ms.get,ms.has=ms.has,ms.set=ms.set,gp=function(t,e){if(ms.has(t))throw new tx(a_);return e.facade=t,ms.set(t,e),e},Nu=function(t){return ms.get(t)||{}},mp=function(t){return ms.has(t)}}else{var Aa=vU("state");xU[Aa]=!0,gp=function(t,e){if(My(t,Aa))throw new tx(a_);return e.facade=t,SU(t,Aa,e),e},Nu=function(t){return My(t,Aa)?t[Aa]:{}},mp=function(t){return My(t,Aa)}}var EM={set:gp,get:Nu,has:mp,enforce:bU,getterFor:PU},$0=Lt,CU=En,_U=kn,sh=Ei,nx=Ii,IU=aU.CONFIGURABLE,EU=CM,kM=EM,kU=kM.enforce,TU=kM.get,l_=String,rf=Object.defineProperty,MU=$0("".slice),AU=$0("".replace),jU=$0([].join),OU=nx&&!CU(function(){return rf(function(){},"length",{value:8}).length!==8}),DU=String(String).split("String"),RU=bM.exports=function(t,e,n){MU(l_(e),0,7)==="Symbol("&&(e="["+AU(l_(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!sh(t,"name")||IU&&t.name!==e)&&(nx?rf(t,"name",{value:e,configurable:!0}):t.name=e),OU&&n&&sh(n,"arity")&&t.length!==n.arity&&rf(t,"length",{value:n.arity});try{n&&sh(n,"constructor")&&n.constructor?nx&&rf(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var r=kU(t);return sh(r,"source")||(r.source=jU(DU,typeof e=="string"?e:"")),t};Function.prototype.toString=RU(function(){return _U(this)&&TU(this).source||EU(this)},"toString");var LU=bM.exports,$U=kn,FU=ql,NU=LU,zU=A0,TM=function(t,e,n,r){r||(r={});var s=r.enumerable,o=r.name!==void 0?r.name:e;if($U(n)&&NU(n,o,r),r.global)s?t[e]=n:zU(e,n);else{try{r.unsafe?t[e]&&(s=!0):delete t[e]}catch{}s?t[e]=n:FU.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},MM={},BU=Math.ceil,UU=Math.floor,HU=Math.trunc||function(e){var n=+e;return(n>0?UU:BU)(n)},KU=HU,_a=function(t){var e=+t;return e!==e||e===0?0:KU(e)},WU=_a,GU=Math.max,VU=Math.min,YU=function(t,e){var n=WU(t);return n<0?GU(n+e,0):VU(n,e)},XU=_a,qU=Math.min,AM=function(t){var e=XU(t);return e>0?qU(e,9007199254740991):0},ZU=AM,id=function(t){return ZU(t.length)},QU=Cg,JU=YU,eH=id,c_=function(t){return function(e,n,r){var s=QU(e),o=eH(s);if(o===0)return!t&&-1;var i=JU(r,o),a;if(t&&n!==n){for(;o>i;)if(a=s[i++],a!==a)return!0}else for(;o>i;i++)if((t||i in s)&&s[i]===n)return t||i||0;return!t&&-1}},tH={includes:c_(!0),indexOf:c_(!1)},nH=Lt,jy=Ei,rH=Cg,sH=tH.indexOf,oH=L0,u_=nH([].push),jM=function(t,e){var n=rH(t),r=0,s=[],o;for(o in n)!jy(oH,o)&&jy(n,o)&&u_(s,o);for(;e.length>r;)jy(n,o=e[r++])&&(~sH(s,o)||u_(s,o));return s},F0=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],iH=jM,aH=F0,lH=aH.concat("length","prototype");MM.f=Object.getOwnPropertyNames||function(e){return iH(e,lH)};var OM={};OM.f=Object.getOwnPropertySymbols;var cH=_g,uH=Lt,dH=MM,hH=OM,fH=Ca,pH=uH([].concat),gH=cH("Reflect","ownKeys")||function(e){var n=dH.f(fH(e)),r=hH.f;return r?pH(n,r(e)):n},d_=Ei,mH=gH,yH=k0,SH=ql,vH=function(t,e,n){for(var r=mH(e),s=SH.f,o=yH.f,i=0;i<r.length;i++){var a=r[i];!d_(t,a)&&!(n&&d_(n,a))&&s(t,a,o(e,a))}},xH=En,wH=kn,bH=/#|\.prototype\./,ad=function(t,e){var n=CH[PH(t)];return n===IH?!0:n===_H?!1:wH(e)?xH(e):!!e},PH=ad.normalize=function(t){return String(t).replace(bH,".").toLowerCase()},CH=ad.data={},_H=ad.NATIVE="N",IH=ad.POLYFILL="P",EH=ad,oh=In,kH=k0.f,TH=D0,MH=TM,AH=A0,jH=vH,OH=EH,Zl=function(t,e){var n=t.target,r=t.global,s=t.stat,o,i,a,l,c,u;if(r?i=oh:s?i=oh[n]||AH(n,{}):i=oh[n]&&oh[n].prototype,i)for(a in e){if(c=e[a],t.dontCallGetSet?(u=kH(i,a),l=u&&u.value):l=i[a],o=OH(r?a:n+(s?".":"#")+a,t.forced),!o&&l!==void 0){if(typeof c==typeof l)continue;jH(c,l)}(t.sham||l&&l.sham)&&TH(c,"sham",!0),MH(i,a,c,t)}},DM={},DH=jM,RH=F0,LH=Object.keys||function(e){return DH(e,RH)},$H=Ii,FH=wM,NH=ql,zH=Ca,BH=Cg,UH=LH;DM.f=$H&&!FH?Object.defineProperties:function(e,n){zH(e);for(var r=BH(n),s=UH(n),o=s.length,i=0,a;o>i;)NH.f(e,a=s[i++],r[a]);return e};var HH=_g,KH=HH("document","documentElement"),WH=Ca,GH=DM,h_=F0,VH=L0,YH=KH,XH=vM,qH=_M,f_=">",p_="<",rx="prototype",sx="script",RM=qH("IE_PROTO"),Oy=function(){},LM=function(t){return p_+sx+f_+t+p_+"/"+sx+f_},g_=function(t){t.write(LM("")),t.close();var e=t.parentWindow.Object;return t=null,e},ZH=function(){var t=XH("iframe"),e="java"+sx+":",n;return t.style.display="none",YH.appendChild(t),t.src=String(e),n=t.contentWindow.document,n.open(),n.write(LM("document.F=Object")),n.close(),n.F},ih,sf=function(){try{ih=new ActiveXObject("htmlfile")}catch{}sf=typeof document<"u"?document.domain&&ih?g_(ih):ZH():g_(ih);for(var t=h_.length;t--;)delete sf[rx][h_[t]];return sf()};VH[RM]=!0;var $M=Object.create||function(e,n){var r;return e!==null?(Oy[rx]=WH(e),r=new Oy,Oy[rx]=null,r[RM]=e):r=sf(),n===void 0?r:GH.f(r,n)},QH=Eo,JH=$M,eK=ql.f,ox=QH("unscopables"),ix=Array.prototype;ix[ox]===void 0&&eK(ix,ox,{configurable:!0,value:JH(null)});var N0=function(t){ix[ox][t]=!0},tK=Zl,nK=od,rK=id,sK=_a,oK=N0;tK({target:"Array",proto:!0},{at:function(e){var n=nK(this),r=rK(n),s=sK(e),o=s>=0?s:r+s;return o<0||o>=r?void 0:n[o]}});oK("at");var iK=In,aK=Lt,ld=function(t,e){return aK(iK[t].prototype[e])},lK=ld;lK("Array","at");var cK=Yl,FM=Array.isArray||function(e){return cK(e)==="Array"},uK=TypeError,dK=9007199254740991,hK=function(t){if(t>dK)throw uK("Maximum allowed index exceeded");return t},fK=Yl,pK=Lt,gK=function(t){if(fK(t)==="Function")return pK(t)},m_=gK,mK=T0,yK=bg,SK=m_(m_.bind),vK=function(t,e){return mK(t),e===void 0?t:yK?SK(t,e):function(){return t.apply(e,arguments)}},xK=FM,wK=id,bK=hK,PK=vK,NM=function(t,e,n,r,s,o,i,a){for(var l=s,c=0,u=i?PK(i,a):!1,h,f;c<r;)c in n&&(h=u?u(n[c],c,e):n[c],o>0&&xK(h)?(f=wK(h),l=NM(t,e,h,f,l,o-1)-1):(bK(l+1),t[l]=h),l++),c++;return l},zM=NM,CK=Eo,_K=CK("toStringTag"),BM={};BM[_K]="z";var IK=String(BM)==="[object z]",EK=IK,kK=kn,of=Yl,TK=Eo,MK=TK("toStringTag"),AK=Object,jK=of(function(){return arguments}())==="Arguments",OK=function(t,e){try{return t[e]}catch{}},UM=EK?of:function(t){var e,n,r;return t===void 0?"Undefined":t===null?"Null":typeof(n=OK(e=AK(t),MK))=="string"?n:jK?of(e):(r=of(e))==="Object"&&kK(e.callee)?"Arguments":r},DK=Lt,RK=En,HM=kn,LK=UM,$K=_g,FK=CM,KM=function(){},WM=$K("Reflect","construct"),z0=/^\s*(?:class|function)\b/,NK=DK(z0.exec),zK=!z0.test(KM),Pc=function(e){if(!HM(e))return!1;try{return WM(KM,[],e),!0}catch{return!1}},GM=function(e){if(!HM(e))return!1;switch(LK(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return zK||!!NK(z0,FK(e))}catch{return!0}};GM.sham=!0;var BK=!WM||RK(function(){var t;return Pc(Pc.call)||!Pc(Object)||!Pc(function(){t=!0})||t})?GM:Pc,y_=FM,UK=BK,HK=Pa,KK=Eo,WK=KK("species"),S_=Array,GK=function(t){var e;return y_(t)&&(e=t.constructor,UK(e)&&(e===S_||y_(e.prototype))?e=void 0:HK(e)&&(e=e[WK],e===null&&(e=void 0))),e===void 0?S_:e},VK=GK,VM=function(t,e){return new(VK(t))(e===0?0:e)},YK=Zl,XK=zM,qK=T0,ZK=od,QK=id,JK=VM;YK({target:"Array",proto:!0},{flatMap:function(e){var n=ZK(this),r=QK(n),s;return qK(e),s=JK(n,0),s.length=XK(s,n,n,r,0,1,e,arguments.length>1?arguments[1]:void 0),s}});var eW=N0;eW("flatMap");var tW=ld;tW("Array","flatMap");var nW=Zl,rW=zM,sW=od,oW=id,iW=_a,aW=VM;nW({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,n=sW(this),r=oW(n),s=aW(n,0);return s.length=rW(s,n,n,r,0,e===void 0?1:iW(e)),s}});var lW=N0;lW("flat");var cW=ld;cW("Array","flat");var uW=UM,dW=String,cd=function(t){if(uW(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return dW(t)},hW=Zl,fW=Lt,pW=Xl,gW=_a,mW=cd,yW=En,SW=fW("".charAt),vW=yW(function(){return"𠮷".at(-2)!=="\uD842"});hW({target:"String",proto:!0,forced:vW},{at:function(e){var n=mW(pW(this)),r=n.length,s=gW(e),o=s>=0?s:r+s;return o<0||o>=r?void 0:SW(n,o)}});var xW=ld;xW("String","at");var wW=Ca,YM=function(){var t=wW(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},B0=En,bW=In,U0=bW.RegExp,H0=B0(function(){var t=U0("a","y");return t.lastIndex=2,t.exec("abcd")!==null}),PW=H0||B0(function(){return!U0("a","y").sticky}),CW=H0||B0(function(){var t=U0("^r","gy");return t.lastIndex=2,t.exec("str")!==null}),_W={BROKEN_CARET:CW,MISSED_STICKY:PW,UNSUPPORTED_Y:H0},IW=En,EW=In,kW=EW.RegExp,TW=IW(function(){var t=kW(".","s");return!(t.dotAll&&t.test(`
|
|
68
|
-
`)&&t.flags==="s")}),MW=En,AW=In,jW=AW.RegExp,OW=MW(function(){var t=jW("(?<a>b)","g");return t.exec("b").groups.a!=="b"||"b".replace(t,"$<a>c")!=="bc"}),al=Io,Ig=Lt,DW=cd,RW=YM,LW=_W,$W=O0,FW=$M,NW=EM.get,zW=TW,BW=OW,UW=$W("native-string-replace",String.prototype.replace),yp=RegExp.prototype.exec,ax=yp,HW=Ig("".charAt),KW=Ig("".indexOf),WW=Ig("".replace),Dy=Ig("".slice),lx=function(){var t=/a/,e=/b*/g;return al(yp,t,"a"),al(yp,e,"a"),t.lastIndex!==0||e.lastIndex!==0}(),XM=LW.BROKEN_CARET,cx=/()??/.exec("")[1]!==void 0,GW=lx||cx||XM||zW||BW;GW&&(ax=function(e){var n=this,r=NW(n),s=DW(e),o=r.raw,i,a,l,c,u,h,f;if(o)return o.lastIndex=n.lastIndex,i=al(ax,o,s),n.lastIndex=o.lastIndex,i;var p=r.groups,g=XM&&n.sticky,m=al(RW,n),v=n.source,y=0,S=s;if(g&&(m=WW(m,"y",""),KW(m,"g")===-1&&(m+="g"),S=Dy(s,n.lastIndex),n.lastIndex>0&&(!n.multiline||n.multiline&&HW(s,n.lastIndex-1)!==`
|
|
69
|
-
`)&&(v="(?: "+v+")",S=" "+S,y++),a=new RegExp("^(?:"+v+")",m)),cx&&(a=new RegExp("^"+v+"$(?!\\s)",m)),lx&&(l=n.lastIndex),c=al(yp,g?a:n,S),g?c?(c.input=Dy(c.input,y),c[0]=Dy(c[0],y),c.index=n.lastIndex,n.lastIndex+=c[0].length):n.lastIndex=0:lx&&c&&(n.lastIndex=n.global?c.index+c[0].length:l),cx&&c&&c.length>1&&al(UW,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=h=FW(null),u=0;u<p.length;u++)f=p[u],h[f[0]]=c[f[1]];return c});var K0=ax,VW=Zl,v_=K0;VW({target:"RegExp",proto:!0,forced:/./.exec!==v_},{exec:v_});var YW=bg,qM=Function.prototype,x_=qM.apply,w_=qM.call,XW=typeof Reflect=="object"&&Reflect.apply||(YW?w_.bind(x_):function(){return w_.apply(x_,arguments)}),b_=Io,P_=TM,qW=K0,C_=En,ZM=Eo,ZW=D0,QW=ZM("species"),Ry=RegExp.prototype,JW=function(t,e,n,r){var s=ZM(t),o=!C_(function(){var c={};return c[s]=function(){return 7},""[t](c)!==7}),i=o&&!C_(function(){var c=!1,u=/a/;return t==="split"&&(u={},u.constructor={},u.constructor[QW]=function(){return u},u.flags="",u[s]=/./[s]),u.exec=function(){return c=!0,null},u[s](""),!c});if(!o||!i||n){var a=/./[s],l=e(s,""[t],function(c,u,h,f,p){var g=u.exec;return g===qW||g===Ry.exec?o&&!p?{done:!0,value:b_(a,u,h,f)}:{done:!0,value:b_(c,h,u,f)}:{done:!1}});P_(String.prototype,t,l[0]),P_(Ry,s,l[1])}r&&ZW(Ry[s],"sham",!0)},W0=Lt,eG=_a,tG=cd,nG=Xl,rG=W0("".charAt),__=W0("".charCodeAt),sG=W0("".slice),I_=function(t){return function(e,n){var r=tG(nG(e)),s=eG(n),o=r.length,i,a;return s<0||s>=o?t?"":void 0:(i=__(r,s),i<55296||i>56319||s+1===o||(a=__(r,s+1))<56320||a>57343?t?rG(r,s):i:t?sG(r,s,s+2):(i-55296<<10)+(a-56320)+65536)}},oG={codeAt:I_(!1),charAt:I_(!0)},iG=oG.charAt,aG=function(t,e,n){return e+(n?iG(t,e).length:1)},G0=Lt,lG=od,cG=Math.floor,Ly=G0("".charAt),uG=G0("".replace),$y=G0("".slice),dG=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,hG=/\$([$&'`]|\d{1,2})/g,QM=function(t,e,n,r,s,o){var i=n+t.length,a=r.length,l=hG;return s!==void 0&&(s=lG(s),l=dG),uG(o,l,function(c,u){var h;switch(Ly(u,0)){case"$":return"$";case"&":return t;case"`":return $y(e,0,n);case"'":return $y(e,i);case"<":h=s[$y(u,1,-1)];break;default:var f=+u;if(f===0)return c;if(f>a){var p=cG(f/10);return p===0?c:p<=a?r[p-1]===void 0?Ly(u,1):r[p-1]+Ly(u,1):c}h=r[f-1]}return h===void 0?"":h})},E_=Io,fG=Ca,pG=kn,gG=Yl,mG=K0,yG=TypeError,SG=function(t,e){var n=t.exec;if(pG(n)){var r=E_(n,t,e);return r!==null&&fG(r),r}if(gG(t)==="RegExp")return E_(mG,t,e);throw new yG("RegExp#exec called on incompatible receiver")},vG=XW,k_=Io,Eg=Lt,xG=JW,wG=En,bG=Ca,PG=kn,CG=Pg,_G=_a,IG=AM,ja=cd,EG=Xl,kG=aG,TG=M0,MG=QM,AG=SG,jG=Eo,ux=jG("replace"),OG=Math.max,DG=Math.min,RG=Eg([].concat),Fy=Eg([].push),T_=Eg("".indexOf),M_=Eg("".slice),LG=function(t){return t===void 0?t:String(t)},$G=function(){return"a".replace(/./,"$0")==="$0"}(),A_=function(){return/./[ux]?/./[ux]("a","$0")==="":!1}(),FG=!wG(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});xG("replace",function(t,e,n){var r=A_?"$":"$0";return[function(o,i){var a=EG(this),l=CG(o)?void 0:TG(o,ux);return l?k_(l,o,a,i):k_(e,ja(a),o,i)},function(s,o){var i=bG(this),a=ja(s);if(typeof o=="string"&&T_(o,r)===-1&&T_(o,"$<")===-1){var l=n(e,i,a,o);if(l.done)return l.value}var c=PG(o);c||(o=ja(o));var u=i.global,h;u&&(h=i.unicode,i.lastIndex=0);for(var f=[],p;p=AG(i,a),!(p===null||(Fy(f,p),!u));){var g=ja(p[0]);g===""&&(i.lastIndex=kG(a,IG(i.lastIndex),h))}for(var m="",v=0,y=0;y<f.length;y++){p=f[y];for(var S=ja(p[0]),b=OG(DG(_G(p.index),a.length),0),P=[],C,_=1;_<p.length;_++)Fy(P,LG(p[_]));var E=p.groups;if(c){var k=RG([S],P,b,a);E!==void 0&&Fy(k,E),C=ja(vG(o,void 0,k))}else C=MG(S,a,b,P,E,o);b>=v&&(m+=M_(a,v,b)+C,v=b+S.length)}return m+M_(a,v)}]},!FG||!$G||A_);var NG=Pa,zG=Yl,BG=Eo,UG=BG("match"),HG=function(t){var e;return NG(t)&&((e=t[UG])!==void 0?!!e:zG(t)==="RegExp")},KG=Io,WG=Ei,GG=dM,VG=YM,j_=RegExp.prototype,YG=function(t){var e=t.flags;return e===void 0&&!("flags"in j_)&&!WG(t,"flags")&&GG(j_,t)?KG(VG,t):e},XG=Zl,qG=Io,V0=Lt,O_=Xl,ZG=kn,QG=Pg,JG=HG,Cc=cd,eV=M0,tV=YG,nV=QM,rV=Eo,sV=rV("replace"),oV=TypeError,Ny=V0("".indexOf);V0("".replace);var D_=V0("".slice),iV=Math.max;XG({target:"String",proto:!0},{replaceAll:function(e,n){var r=O_(this),s,o,i,a,l,c,u,h,f,p,g=0,m="";if(!QG(e)){if(s=JG(e),s&&(o=Cc(O_(tV(e))),!~Ny(o,"g")))throw new oV("`.replaceAll` does not allow non-global regexes");if(i=eV(e,sV),i)return qG(i,e,r,n)}for(a=Cc(r),l=Cc(e),c=ZG(n),c||(n=Cc(n)),u=l.length,h=iV(1,u),f=Ny(a,l);f!==-1;)p=c?Cc(n(l,f,a)):nV(l,a,f,[],void 0,n),m+=D_(a,g,f)+p,g=f+u,f=f+h>a.length?-1:Ny(a,l,f+h);return g<a.length&&(m+=D_(a,g)),m}});var aV=ld;aV("String","replaceAll");function JM(t){return t&&typeof t=="object"&&"parents"in t}function eA(t){for(let e=0,n=t.parents.length;e<n;e++)if(t.parents[e].__unsafe__getWithoutCapture(!0),t.parents[e].lastChangedEpoch!==t.parentEpochs[e])return!0;return!1}function Sp(t,e){if(t.children.remove(e)&&t.children.isEmpty&&JM(t))for(let n=0,r=t.parents.length;n<r;n++)Sp(t.parents[n],t)}function Y0(t,e){if(t.children.add(e)&&JM(t))for(let n=0,r=t.parents.length;n<r;n++)Y0(t.parents[n],t)}function tA(t,e){return t===e||Object.is(t,e)||!!(t&&e&&typeof t.equals=="function"&&t.equals(e))}function ki(t,e){const n=Symbol.for(`com.tldraw.state/${t}`),r=globalThis;return r[n]??(r[n]=e()),r[n]}const fo=ki("empty_array",()=>Object.freeze([])),R_=8;class vp{constructor(){I(this,"arraySize",0);I(this,"array",Array(R_));I(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<R_?(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 n=this.array.indexOf(e);return n===-1?!1:(this.array[n]=void 0,this.arraySize--,n!==this.arraySize&&(this.array[n]=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 n=0;n<this.arraySize;n++){const r=this.array[n];typeof r<"u"&&e(r)}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 ur=Symbol.for("com.tldraw.state/RESET_VALUE");class nA{constructor(e){I(this,"index",0);I(this,"buffer");this.capacity=e,this.buffer=new Array(e)}pushEntry(e,n,r){if(r!==void 0){if(r===ur){this.clear();return}this.buffer[this.index]=[e,n,r],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(e){const{index:n,capacity:r,buffer:s}=this;for(let o=0;o<r;o++){const i=(n-1+r-o)%r,a=s[i];if(!a)return ur;const[l,c]=a;if(o===0&&e>=c)return[];if(l<=e&&e<c){const u=o+1,h=new Array(u);for(let f=0;f<u;f++)h[f]=s[(i+f)%r][2];return h}}return ur}}class lV{constructor(e,n){I(this,"offset",0);I(this,"maybeRemoved");this.below=e,this.child=n}}const ot=ki("capture",()=>({stack:null}));function ah(t){const e=ot.stack;ot.stack=null;try{return t()}finally{ot.stack=e}}function rA(t){ot.stack=new lV(ot.stack,t),t.parentSet.clear()}function sA(){const t=ot.stack;if(ot.stack=t.below,t.offset<t.child.parents.length){for(let e=t.offset;e<t.child.parents.length;e++){const n=t.child.parents[e];t.child.parentSet.has(n)||Sp(n,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 n=t.maybeRemoved[e];t.child.parentSet.has(n)||Sp(n,t.child)}}function xp(t){if(ot.stack){if(ot.stack.child.parentSet.has(t))return;if(ot.stack.child.parentSet.add(t),ot.stack.child.isActivelyListening&&Y0(t,ot.stack.child),ot.stack.offset<ot.stack.child.parents.length){const n=ot.stack.child.parents[ot.stack.offset];n!==t&&(ot.stack.maybeRemoved?ot.stack.maybeRemoved.push(n):ot.stack.maybeRemoved=[n])}ot.stack.child.parents[ot.stack.offset]=t,ot.stack.child.parentEpochs[ot.stack.offset]=t.lastChangedEpoch,ot.stack.offset++}}const ei=-1;class cV{constructor(e,n,r){I(this,"_isActivelyListening",!1);I(this,"lastTraversedEpoch",ei);I(this,"lastReactedEpoch",ei);I(this,"_scheduleCount",0);I(this,"parentSet",new vp);I(this,"parentEpochs",[]);I(this,"parents",[]);I(this,"_scheduleEffect");I(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=e,this.runEffect=n,this._scheduleEffect=r==null?void 0:r.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==$n()){if(this.parents.length&&!eA(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,n=this.parents.length;e<n;e++)Y0(this.parents[e],this)}detach(){this._isActivelyListening=!1;for(let e=0,n=this.parents.length;e<n;e++)Sp(this.parents[e],this)}execute(){try{rA(this);const e=$n(),n=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=e,n}finally{sA()}}}const Ql=ki("EffectScheduler",()=>cV);function As(t,e,n){const r=new Ql(t,e,n);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function uV(t,e,n){const r=new Ql(t,e,n);return{scheduler:r,start:s=>{const o=(s==null?void 0:s.force)??!1;r.attach(),o?r.scheduleEffect():r.maybeScheduleEffect()},stop:()=>{r.detach()}}}class dV{constructor(e){I(this,"initialAtomValues",new Map);this.parent=e}get isRoot(){return this.parent===null}commit(){if(Re.globalIsReacting)for(const e of this.initialAtomValues.keys())iA(e);else this.isRoot?oA(this.initialAtomValues.keys()):this.initialAtomValues.forEach((e,n)=>{this.parent.initialAtomValues.has(n)||this.parent.initialAtomValues.set(n,e)})}abort(){Re.globalEpoch++,this.initialAtomValues.forEach((e,n)=>{var r;n.set(e),(r=n.historyBuffer)==null||r.clear()}),this.commit()}}const Re=ki("transactions",()=>({globalEpoch:ei+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:ei+1}));function hV(){return Re.reactionEpoch}function $n(){return Re.globalEpoch}function fV(){return Re.globalIsReacting}function X0(t,e){e.lastTraversedEpoch!==Re.globalEpoch&&(e.lastTraversedEpoch=Re.globalEpoch,e instanceof Ql?t.add(e):e.children.visit(n=>X0(t,n)))}function oA(t){var n;if(Re.globalIsReacting)throw new Error("flushChanges cannot be called during a reaction");const e=Re.currentTransaction;try{Re.currentTransaction=null,Re.globalIsReacting=!0,Re.reactionEpoch=Re.globalEpoch;const r=new Set;for(const o of t)o.children.visit(i=>X0(r,i));for(const o of r)o.maybeScheduleEffect();let s=0;for(;(n=Re.cleanupReactors)!=null&&n.size;){if(s++>1e3)throw new Error("Reaction update depth limit exceeded");const o=Re.cleanupReactors;Re.cleanupReactors=null;for(const i of o)i.maybeScheduleEffect()}}finally{Re.cleanupReactors=null,Re.globalIsReacting=!1,Re.currentTransaction=e}}function pV(t,e){Re.currentTransaction?Re.currentTransaction.initialAtomValues.has(t)||Re.currentTransaction.initialAtomValues.set(t,e):Re.globalIsReacting?iA(t):oA([t])}function iA(t){const e=Re.cleanupReactors??(Re.cleanupReactors=new Set);t.children.visit(n=>X0(e,n))}function gV(){Re.globalEpoch++}function mV(t){const e=new dV(Re.currentTransaction);Re.currentTransaction=e;try{let n,r=!1;try{n=t(()=>r=!0)}catch(s){throw e.abort(),s}return r?e.abort():e.commit(),n}finally{Re.currentTransaction=Re.currentTransaction.parent}}function js(t){return Re.currentTransaction?t():mV(t)}class yV{constructor(e,n,r){I(this,"isEqual");I(this,"computeDiff");I(this,"lastChangedEpoch",$n());I(this,"children",new vp);I(this,"historyBuffer");this.name=e,this.current=n,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new nA(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(e){return this.current}get(){return xp(this),this.current}set(e,n){var s,o;if(((s=this.isEqual)==null?void 0:s.call(this,this.current,e))??tA(this.current,e))return this.current;gV(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,$n(),n??((o=this.computeDiff)==null?void 0:o.call(this,this.current,e,this.lastChangedEpoch,$n()))??ur),this.lastChangedEpoch=$n();const r=this.current;return this.current=e,pV(this,r),e}update(e){return this.set(e(this.current))}getDiffSince(e){var n;return xp(this),e>=this.lastChangedEpoch?fo:((n=this.historyBuffer)==null?void 0:n.getChangesSince(e))??ur}}const SV=ki("Atom",()=>yV);function It(t,e,n){return new SV(t,e,n)}let L_=!1;function vV(){L_||(L_=!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 Hc=Symbol.for("com.tldraw.state/UNINITIALIZED");function Qi(t){return t===Hc}const dx=ki("WithDiff",()=>class{constructor(e,n){this.value=e,this.diff=n}});function Kc(t,e){return new dx(t,e)}class xV{constructor(e,n,r){I(this,"lastChangedEpoch",ei);I(this,"lastTraversedEpoch",ei);I(this,"lastCheckedEpoch",ei);I(this,"parentSet",new vp);I(this,"parents",[]);I(this,"parentEpochs",[]);I(this,"children",new vp);I(this,"historyBuffer");I(this,"state",Hc);I(this,"error",null);I(this,"computeDiff");I(this,"isEqual");this.name=e,this.derive=n,r!=null&&r.historyLength&&(this.historyBuffer=new nA(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??tA}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(e){var s;const n=this.lastChangedEpoch===ei,r=$n();if(!n&&(this.lastCheckedEpoch===r||this.isActivelyListening&&fV()&&this.lastTraversedEpoch<hV()||!eA(this)))if(this.lastCheckedEpoch=r,this.error){if(e)return this.state;throw this.error.thrownValue}else return this.state;try{rA(this);const o=this.derive(this.state,this.lastCheckedEpoch),i=o instanceof dx?o.value:o,a=this.state===Hc;if(a||!this.isEqual(i,this.state)){if(this.historyBuffer&&!a){const l=o instanceof dx?o.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,$n(),l??((s=this.computeDiff)==null?void 0:s.call(this,this.state,i,this.lastCheckedEpoch,$n()))??ur)}this.lastChangedEpoch=$n(),this.state=i}return this.error=null,this.lastCheckedEpoch=$n(),this.state}catch(o){if(this.state!==Hc&&(this.state=Hc,this.lastChangedEpoch=$n()),this.lastCheckedEpoch=$n(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:o},!e)throw o;return this.state}finally{sA()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{xp(this)}}getDiffSince(e){var n;return this.__unsafe__getWithoutCapture(!0),xp(this),e>=this.lastChangedEpoch?fo:((n=this.historyBuffer)==null?void 0:n.getChangesSince(e))??ur}}const kg=ki("Computed",()=>xV);function wV(t={},e,n,r){const s=r.value,o=Symbol.for("__@tldraw/state__computed__"+n);return r.value=function(){let i=this[o];return i||(i=new kg(n,s.bind(this),t),Object.defineProperty(this,o,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r.value[aA]=!0,r}function bV(t={},e,n,r){const s=r.get,o=Symbol.for("__@tldraw/state__computed__"+n);return r.get=function(){let i=this[o];return i||(i=new kg(n,s.bind(this),t),Object.defineProperty(this,o,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r}function PV(t,e,n){Le(n.kind==="method","@computed can only be used on methods");const r=Symbol.for("__@tldraw/state__computed__"+String(n.name)),s=function(){let o=this[r];return o||(o=new kg(String(n.name),e.bind(this),t),Object.defineProperty(this,r,{enumerable:!1,configurable:!1,writable:!1,value:o})),o.get()};return s[aA]=!0,s}function $_(t={},e){if(e.length===2){const[n,r]=e;return PV(t,n,r)}else{const[n,r,s]=e;return s.get?(vV(),bV(t,n,r,s)):wV(t,n,r,s)}}const aA="@@__isComputedMethod__@@";function G(){if(arguments.length===1){const t=arguments[0];return(...e)=>$_(t,e)}else return typeof arguments[0]=="string"?new kg(arguments[0],arguments[1],arguments[2]):$_(void 0,arguments)}const lA=1,CV=ki("apiVersion",()=>lA);if(CV!==lA)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");_i("@tldraw/state","3.7.2","esm");function Tg(t,e,n=[]){const r=ke.useRef(e);r.current=e;const[s,o,i]=ke.useMemo(()=>{let a=null;const l=h=>(a=h,()=>{a=null}),c=new Ql(`useStateTracking(${t})`,()=>{var h;return(h=r.current)==null?void 0:h.call(r)},{scheduleEffect(){a==null||a()}});return[c,l,()=>c.scheduleCount]},[t,...n]);return ke.useSyncExternalStore(o,i,i),ke.useEffect(()=>(s.attach(),s.maybeScheduleEffect(),()=>{s.detach()}),[s]),s.execute()}const F_={apply(t,e,n){return Tg(t.displayName??t.name??"tracked(???)",()=>t.apply(e,n))}},_V=Symbol.for("react.memo"),IV=Symbol.for("react.forward_ref");function Zt(t){let e=null;const n=t.$$typeof;return n===_V&&(t=t.type,e=t.compare),n===IV?w.memo(w.forwardRef(new Proxy(t.render,F_))):w.memo(new Proxy(t,F_),e)}function q0(t,e,n){return w.useState(()=>{const r=typeof e=="function"?e():e;return It(`useAtom(${t})`,r,n)})[0]}function EV(){const t=arguments[0],e=arguments[1],n=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return w.useMemo(()=>G(`useComputed(${t})`,e,n),r)}function ui(t,e,n=fo){w.useEffect(()=>{const r=new Ql(t,e);return r.attach(),r.execute(),()=>{r.detach()}},n)}function U(){const t=arguments,e=t.length===3?t[2]:[t[0]],n=t.length===3?t[0]:`useValue(${t[0].name})`,r=w.useRef(!0);r.current=!0;const s=w.useMemo(()=>t.length===1?t[0]:G(n,()=>{if(r.current)return t[1]();try{return t[1]()}catch{return{}}}),e);try{const{subscribe:o,getSnapshot:i}=w.useMemo(()=>({subscribe:a=>As(`useValue(${n})`,()=>{s.get(),a()}),getSnapshot:()=>s.get()}),[s]);return w.useSyncExternalStore(o,i,i)}finally{r.current=!1}}_i("@tldraw/state-react","3.7.2","esm");const kV=(t,e)=>e.some(n=>t instanceof n);let N_,z_;function TV(){return N_||(N_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function MV(){return z_||(z_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const cA=new WeakMap,hx=new WeakMap,uA=new WeakMap,zy=new WeakMap,Z0=new WeakMap;function AV(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",o),t.removeEventListener("error",i)},o=()=>{n(po(t.result)),s()},i=()=>{r(t.error),s()};t.addEventListener("success",o),t.addEventListener("error",i)});return e.then(n=>{n instanceof IDBCursor&&cA.set(n,t)}).catch(()=>{}),Z0.set(e,t),e}function jV(t){if(hx.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",i),t.removeEventListener("abort",i)},o=()=>{n(),s()},i=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",o),t.addEventListener("error",i),t.addEventListener("abort",i)});hx.set(t,e)}let fx={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return hx.get(t);if(e==="objectStoreNames")return t.objectStoreNames||uA.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return po(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function OV(t){fx=t(fx)}function DV(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(By(this),e,...n);return uA.set(r,e.sort?e.sort():[e]),po(r)}:MV().includes(t)?function(...e){return t.apply(By(this),e),po(cA.get(this))}:function(...e){return po(t.apply(By(this),e))}}function RV(t){return typeof t=="function"?DV(t):(t instanceof IDBTransaction&&jV(t),kV(t,TV())?new Proxy(t,fx):t)}function po(t){if(t instanceof IDBRequest)return AV(t);if(zy.has(t))return zy.get(t);const e=RV(t);return e!==t&&(zy.set(t,e),Z0.set(e,t)),e}const By=t=>Z0.get(t);function dA(t,e,{blocked:n,upgrade:r,blocking:s,terminated:o}={}){const i=indexedDB.open(t,e),a=po(i);return r&&i.addEventListener("upgradeneeded",l=>{r(po(i.result),l.oldVersion,l.newVersion,po(i.transaction),l)}),n&&i.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}function hA(t,{blocked:e}={}){const n=indexedDB.deleteDatabase(t);return e&&n.addEventListener("blocked",r=>e(r.oldVersion,r)),po(n).then(()=>{})}const LV=["get","getKey","getAll","getAllKeys","count"],$V=["put","add","delete","clear"],Uy=new Map;function B_(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Uy.get(e))return Uy.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=$V.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||LV.includes(n)))return;const o=async function(i,...a){const l=this.transaction(i,s?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),s&&l.done]))[0]};return Uy.set(e,o),o}OV(t=>({...t,get:(e,n,r)=>B_(e,n)||t.get(e,n,r),has:(e,n)=>!!B_(e,n)||t.has(e,n)}));const FV="TLDRAW_DOCUMENT_v2",NV="TLDRAW_ASSET_STORE_v1",fA="TLDRAW_DB_NAME_INDEX_v2",Ce={Records:"records",Schema:"schema",SessionState:"session_state",Assets:"assets"};async function pA(t){const e=FV+t;return BV(e),await dA(e,4,{upgrade(n){n.objectStoreNames.contains(Ce.Records)||n.createObjectStore(Ce.Records),n.objectStoreNames.contains(Ce.Schema)||n.createObjectStore(Ce.Schema),n.objectStoreNames.contains(Ce.SessionState)||n.createObjectStore(Ce.SessionState),n.objectStoreNames.contains(Ce.Assets)||n.createObjectStore(Ce.Assets)}})}async function zV(t){const e=window.indexedDB.databases?(await window.indexedDB.databases()).map(f=>f.name):Q0(),n=NV+t;if(!e.find(f=>f===n))return;const s=await dA(n,1,{upgrade(f){f.objectStoreNames.contains("assets")||f.createObjectStore("assets")}});if(!s.objectStoreNames.contains("assets"))return;const o=s.transaction(["assets"],"readonly"),i=o.objectStore("assets"),a=await i.getAllKeys(),l=await Promise.all(a.map(async f=>[f,await i.get(f)]));await o.done;const c=await pA(t),u=c.transaction([Ce.Assets],"readwrite"),h=u.objectStore(Ce.Assets);for(const[f,p]of l)h.put(p,f);await u.done,s.close(),c.close(),await hA(n)}const mu=class mu{constructor(e){I(this,"getDbPromise");I(this,"isClosed",!1);I(this,"pendingTransactionSet",new Set);mu.connectedInstances.add(this),this.getDbPromise=(async()=>(await zV(e),await pA(e)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(Ru)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),mu.connectedInstances.delete(this))}tx(e,n,r){const s=(async()=>{Le(!this.isClosed,"db is closed");const i=(await this.getDb()).transaction(n,e),a=i.done.catch(l=>{if(!this.isClosed)throw l});try{return await r(i)}finally{this.isClosed?i.abort():await a}})();return this.pendingTransactionSet.add(s),s.finally(()=>this.pendingTransactionSet.delete(s)),s}async load({sessionId:e}={}){return await this.tx("readonly",[Ce.Records,Ce.Schema,Ce.SessionState],async n=>{var l,c;const r=n.objectStore(Ce.Records),s=n.objectStore(Ce.Schema),o=n.objectStore(Ce.SessionState);let i=e?(l=await o.get(e))==null?void 0:l.snapshot:null;return i||(i=(c=(await o.getAll()).sort((h,f)=>h.updatedAt-f.updatedAt).pop())==null?void 0:c.snapshot),{records:await r.getAll(),schema:await s.get(Ce.Schema),sessionStateSnapshot:i}})}async storeChanges({schema:e,changes:n,sessionId:r,sessionStateSnapshot:s}){await this.tx("readwrite",[Ce.Records,Ce.Schema,Ce.SessionState],async o=>{const i=o.objectStore(Ce.Records),a=o.objectStore(Ce.Schema),l=o.objectStore(Ce.SessionState);for(const[c,u]of Object.entries(n.added))await i.put(u,c);for(const[c,u]of Object.values(n.updated))await i.put(u,u.id);for(const c of Object.keys(n.removed))await i.delete(c);a.put(e.serialize(),Ce.Schema),s&&r?l.put({snapshot:s,updatedAt:Date.now(),id:r},r):(s||r)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async storeSnapshot({schema:e,snapshot:n,sessionId:r,sessionStateSnapshot:s}){await this.tx("readwrite",[Ce.Records,Ce.Schema,Ce.SessionState],async o=>{const i=o.objectStore(Ce.Records),a=o.objectStore(Ce.Schema),l=o.objectStore(Ce.SessionState);await i.clear();for(const[c,u]of Object.entries(n))await i.put(u,c);a.put(e.serialize(),Ce.Schema),s&&r?l.put({snapshot:s,updatedAt:Date.now(),id:r},r):(s||r)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async pruneSessions(){await this.tx("readwrite",[Ce.SessionState],async e=>{const n=e.objectStore(Ce.SessionState),r=(await n.getAll()).sort((o,i)=>o.updatedAt-i.updatedAt);if(r.length<10){await e.done;return}const s=r.slice(0,r.length-10);for(const{id:o}of s)await n.delete(o)})}async getAsset(e){return await this.tx("readonly",[Ce.Assets],async n=>await n.objectStore(Ce.Assets).get(e))}async storeAsset(e,n){await this.tx("readwrite",[Ce.Assets],async r=>{await r.objectStore(Ce.Assets).put(n,e)})}};I(mu,"connectedInstances",new Set);let wp=mu;function Q0(){const t=JSON.parse(_0(fA)||"[]")??[];return Array.isArray(t)?t:[]}function BV(t){const e=new Set(Q0());e.add(t),I0(fA,JSON.stringify([...e]))}class af{constructor(e){I(this,"nextValue");I(this,"diff");this.previousValue=e}get(){var r,s,o,i;const e=((s=(r=this.diff)==null?void 0:r.removed)==null?void 0:s.size)??0,n=((i=(o=this.diff)==null?void 0:o.added)==null?void 0:i.size)??0;if(!(e===0&&n===0))return{value:this.nextValue,diff:this.diff}}_add(e,n){var r,s;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(e),this.diff??(this.diff={}),n?(r=this.diff.removed)==null||r.delete(e):((s=this.diff).added??(s.added=new Set),this.diff.added.add(e))}add(e){var s,o,i;const n=this.previousValue.has(e);if(n)return((o=(s=this.diff)==null?void 0:s.removed)==null?void 0:o.has(e))?this._add(e,n):void 0;(i=this.nextValue)!=null&&i.has(e)||this._add(e,n)}_remove(e,n){var r,s;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(e),this.diff??(this.diff={}),n?((r=this.diff).removed??(r.removed=new Set),this.diff.removed.add(e)):(s=this.diff.added)==null||s.delete(e)}remove(e){var s,o,i,a;const n=this.previousValue.has(e);if(!n)return((o=(s=this.diff)==null?void 0:s.added)==null?void 0:o.has(e))?this._remove(e,n):void 0;(a=(i=this.diff)==null?void 0:i.removed)!=null&&a.has(e)||this._remove(e,n)}}class Mg{constructor(e,n){I(this,"createDefaultProperties");I(this,"validator");I(this,"ephemeralKeys");I(this,"ephemeralKeySet");I(this,"scope");this.typeName=e,this.createDefaultProperties=n.createDefaultProperties,this.validator=n.validator??{validate:s=>s},this.scope=n.scope??"document",this.ephemeralKeys=n.ephemeralKeys;const r=new Set;if(n.ephemeralKeys)for(const[s,o]of Xn(n.ephemeralKeys))o&&r.add(s);this.ephemeralKeySet=r}create(e){const n={...this.createDefaultProperties(),id:this.createId()};for(const[r,s]of Object.entries(e))s!==void 0&&(n[r]=s);return n.typeName=this.typeName,n}clone(e){return{...nt(e),id:this.createId()}}createId(e){return this.typeName+":"+(e??ze())}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 n=0;n<this.typeName.length;n++)if(e[n]!==this.typeName[n])return!1;return e[this.typeName.length]===":"}withDefaultProperties(e){return new Mg(this.typeName,{createDefaultProperties:e,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(e,n){return n&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(n,e):this.validator.validate(e)}}function Hs(t,e){return new Mg(t,{createDefaultProperties:()=>({}),validator:e.validator,scope:e.scope,ephemeralKeys:e.ephemeralKeys})}function bp(){return{added:{},updated:{},removed:{}}}function px(t){const e={added:t.removed,removed:t.added,updated:{}};for(const[n,r]of Object.values(t.updated))e.updated[n.id]=[r,n];return e}function gA(t){return Object.keys(t.added).length===0&&Object.keys(t.updated).length===0&&Object.keys(t.removed).length===0}function J0(t){const e={added:{},removed:{},updated:{}};return lu(e,t),e}function lu(t,e){for(const n of e){for(const[r,s]of Xn(n.added))if(t.removed[r]){const o=t.removed[r];delete t.removed[r],o!==s&&(t.updated[r]=[o,s])}else t.added[r]=s;for(const[r,[s,o]]of Xn(n.updated)){if(t.added[r]){t.added[r]=o,delete t.updated[r],delete t.removed[r];continue}if(t.updated[r]){t.updated[r]=[t.updated[r][0],o],delete t.removed[r];continue}t.updated[r]=n.updated[r],delete t.removed[r]}for(const[r,s]of Xn(n.removed))t.added[r]?delete t.added[r]:t.updated[r]?(t.removed[r]=t.updated[r][0],delete t.updated[r]):t.removed[r]=s}}var Pp={exports:{}};Pp.exports;(function(t,e){var n=200,r="__lodash_hash_undefined__",s=1,o=2,i=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Function]",g="[object GeneratorFunction]",m="[object Map]",v="[object Number]",y="[object Null]",S="[object Object]",b="[object Promise]",P="[object Proxy]",C="[object RegExp]",_="[object Set]",E="[object String]",k="[object Symbol]",D="[object Undefined]",T="[object WeakMap]",j="[object ArrayBuffer]",L="[object DataView]",M="[object Float32Array]",O="[object Float64Array]",F="[object Int8Array]",B="[object Int16Array]",K="[object Int32Array]",R="[object Uint8Array]",H="[object Uint8ClampedArray]",X="[object Uint16Array]",te="[object Uint32Array]",le=/[\\^$.*+?()[\]{}|]/g,de=/^\[object .+?Constructor\]$/,Me=/^(?:0|[1-9]\d*)$/,oe={};oe[M]=oe[O]=oe[F]=oe[B]=oe[K]=oe[R]=oe[H]=oe[X]=oe[te]=!0,oe[a]=oe[l]=oe[j]=oe[u]=oe[L]=oe[h]=oe[f]=oe[p]=oe[m]=oe[v]=oe[S]=oe[C]=oe[_]=oe[E]=oe[T]=!1;var Ue=typeof dn=="object"&&dn&&dn.Object===Object&&dn,Ne=typeof self=="object"&&self&&self.Object===Object&&self,lt=Ue||Ne||Function("return this")(),$e=e&&!e.nodeType&&e,Ye=$e&&!0&&t&&!t.nodeType&&t,We=Ye&&Ye.exports===$e,er=We&&Ue.process,$t=function(){try{return er&&er.binding&&er.binding("util")}catch{}}(),On=$t&&$t.isTypedArray;function Mt(A,$){for(var V=-1,ne=A==null?0:A.length,Je=0,Se=[];++V<ne;){var mt=A[V];$(mt,V,A)&&(Se[Je++]=mt)}return Se}function Ft(A,$){for(var V=-1,ne=$.length,Je=A.length;++V<ne;)A[Je+V]=$[V];return A}function jo(A,$){for(var V=-1,ne=A==null?0:A.length;++V<ne;)if($(A[V],V,A))return!0;return!1}function Ys(A,$){for(var V=-1,ne=Array(A);++V<A;)ne[V]=$(V);return ne}function Oo(A){return function($){return A($)}}function Mm(A,$){return A.has($)}function ON(A,$){return A==null?void 0:A[$]}function DN(A){var $=-1,V=Array(A.size);return A.forEach(function(ne,Je){V[++$]=[Je,ne]}),V}function RN(A,$){return function(V){return A($(V))}}function LN(A){var $=-1,V=Array(A.size);return A.forEach(function(ne){V[++$]=ne}),V}var $N=Array.prototype,FN=Function.prototype,Ad=Object.prototype,Am=lt["__core-js_shared__"],eP=FN.toString,ps=Ad.hasOwnProperty,tP=function(){var A=/[^.]+$/.exec(Am&&Am.keys&&Am.keys.IE_PROTO||"");return A?"Symbol(src)_1."+A:""}(),nP=Ad.toString,NN=RegExp("^"+eP.call(ps).replace(le,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rP=We?lt.Buffer:void 0,jd=lt.Symbol,sP=lt.Uint8Array,oP=Ad.propertyIsEnumerable,zN=$N.splice,Li=jd?jd.toStringTag:void 0,iP=Object.getOwnPropertySymbols,BN=rP?rP.isBuffer:void 0,UN=RN(Object.keys,Object),jm=Ta(lt,"DataView"),cc=Ta(lt,"Map"),Om=Ta(lt,"Promise"),Dm=Ta(lt,"Set"),Rm=Ta(lt,"WeakMap"),uc=Ta(Object,"create"),HN=Ni(jm),KN=Ni(cc),WN=Ni(Om),GN=Ni(Dm),VN=Ni(Rm),aP=jd?jd.prototype:void 0,Lm=aP?aP.valueOf:void 0;function $i(A){var $=-1,V=A==null?0:A.length;for(this.clear();++$<V;){var ne=A[$];this.set(ne[0],ne[1])}}function YN(){this.__data__=uc?uc(null):{},this.size=0}function XN(A){var $=this.has(A)&&delete this.__data__[A];return this.size-=$?1:0,$}function qN(A){var $=this.__data__;if(uc){var V=$[A];return V===r?void 0:V}return ps.call($,A)?$[A]:void 0}function ZN(A){var $=this.__data__;return uc?$[A]!==void 0:ps.call($,A)}function QN(A,$){var V=this.__data__;return this.size+=this.has(A)?0:1,V[A]=uc&&$===void 0?r:$,this}$i.prototype.clear=YN,$i.prototype.delete=XN,$i.prototype.get=qN,$i.prototype.has=ZN,$i.prototype.set=QN;function Xs(A){var $=-1,V=A==null?0:A.length;for(this.clear();++$<V;){var ne=A[$];this.set(ne[0],ne[1])}}function JN(){this.__data__=[],this.size=0}function e4(A){var $=this.__data__,V=Dd($,A);if(V<0)return!1;var ne=$.length-1;return V==ne?$.pop():zN.call($,V,1),--this.size,!0}function t4(A){var $=this.__data__,V=Dd($,A);return V<0?void 0:$[V][1]}function n4(A){return Dd(this.__data__,A)>-1}function r4(A,$){var V=this.__data__,ne=Dd(V,A);return ne<0?(++this.size,V.push([A,$])):V[ne][1]=$,this}Xs.prototype.clear=JN,Xs.prototype.delete=e4,Xs.prototype.get=t4,Xs.prototype.has=n4,Xs.prototype.set=r4;function Fi(A){var $=-1,V=A==null?0:A.length;for(this.clear();++$<V;){var ne=A[$];this.set(ne[0],ne[1])}}function s4(){this.size=0,this.__data__={hash:new $i,map:new(cc||Xs),string:new $i}}function o4(A){var $=Rd(this,A).delete(A);return this.size-=$?1:0,$}function i4(A){return Rd(this,A).get(A)}function a4(A){return Rd(this,A).has(A)}function l4(A,$){var V=Rd(this,A),ne=V.size;return V.set(A,$),this.size+=V.size==ne?0:1,this}Fi.prototype.clear=s4,Fi.prototype.delete=o4,Fi.prototype.get=i4,Fi.prototype.has=a4,Fi.prototype.set=l4;function Od(A){var $=-1,V=A==null?0:A.length;for(this.__data__=new Fi;++$<V;)this.add(A[$])}function c4(A){return this.__data__.set(A,r),this}function u4(A){return this.__data__.has(A)}Od.prototype.add=Od.prototype.push=c4,Od.prototype.has=u4;function Do(A){var $=this.__data__=new Xs(A);this.size=$.size}function d4(){this.__data__=new Xs,this.size=0}function h4(A){var $=this.__data__,V=$.delete(A);return this.size=$.size,V}function f4(A){return this.__data__.get(A)}function p4(A){return this.__data__.has(A)}function g4(A,$){var V=this.__data__;if(V instanceof Xs){var ne=V.__data__;if(!cc||ne.length<n-1)return ne.push([A,$]),this.size=++V.size,this;V=this.__data__=new Fi(ne)}return V.set(A,$),this.size=V.size,this}Do.prototype.clear=d4,Do.prototype.delete=h4,Do.prototype.get=f4,Do.prototype.has=p4,Do.prototype.set=g4;function m4(A,$){var V=Ld(A),ne=!V&&A4(A),Je=!V&&!ne&&$m(A),Se=!V&&!ne&&!Je&&mP(A),mt=V||ne||Je||Se,At=mt?Ys(A.length,String):[],Nt=At.length;for(var ct in A)ps.call(A,ct)&&!(mt&&(ct=="length"||Je&&(ct=="offset"||ct=="parent")||Se&&(ct=="buffer"||ct=="byteLength"||ct=="byteOffset")||I4(ct,Nt)))&&At.push(ct);return At}function Dd(A,$){for(var V=A.length;V--;)if(hP(A[V][0],$))return V;return-1}function y4(A,$,V){var ne=$(A);return Ld(A)?ne:Ft(ne,V(A))}function dc(A){return A==null?A===void 0?D:y:Li&&Li in Object(A)?C4(A):M4(A)}function lP(A){return hc(A)&&dc(A)==a}function cP(A,$,V,ne,Je){return A===$?!0:A==null||$==null||!hc(A)&&!hc($)?A!==A&&$!==$:S4(A,$,V,ne,cP,Je)}function S4(A,$,V,ne,Je,Se){var mt=Ld(A),At=Ld($),Nt=mt?l:Ro(A),ct=At?l:Ro($);Nt=Nt==a?S:Nt,ct=ct==a?S:ct;var tr=Nt==S,Ur=ct==S,en=Nt==ct;if(en&&$m(A)){if(!$m($))return!1;mt=!0,tr=!1}if(en&&!tr)return Se||(Se=new Do),mt||mP(A)?uP(A,$,V,ne,Je,Se):b4(A,$,Nt,V,ne,Je,Se);if(!(V&s)){var Pr=tr&&ps.call(A,"__wrapped__"),Cr=Ur&&ps.call($,"__wrapped__");if(Pr||Cr){var Lo=Pr?A.value():A,qs=Cr?$.value():$;return Se||(Se=new Do),Je(Lo,qs,V,ne,Se)}}return en?(Se||(Se=new Do),P4(A,$,V,ne,Je,Se)):!1}function v4(A){if(!gP(A)||k4(A))return!1;var $=fP(A)?NN:de;return $.test(Ni(A))}function x4(A){return hc(A)&&pP(A.length)&&!!oe[dc(A)]}function w4(A){if(!T4(A))return UN(A);var $=[];for(var V in Object(A))ps.call(A,V)&&V!="constructor"&&$.push(V);return $}function uP(A,$,V,ne,Je,Se){var mt=V&s,At=A.length,Nt=$.length;if(At!=Nt&&!(mt&&Nt>At))return!1;var ct=Se.get(A);if(ct&&Se.get($))return ct==$;var tr=-1,Ur=!0,en=V&o?new Od:void 0;for(Se.set(A,$),Se.set($,A);++tr<At;){var Pr=A[tr],Cr=$[tr];if(ne)var Lo=mt?ne(Cr,Pr,tr,$,A,Se):ne(Pr,Cr,tr,A,$,Se);if(Lo!==void 0){if(Lo)continue;Ur=!1;break}if(en){if(!jo($,function(qs,zi){if(!Mm(en,zi)&&(Pr===qs||Je(Pr,qs,V,ne,Se)))return en.push(zi)})){Ur=!1;break}}else if(!(Pr===Cr||Je(Pr,Cr,V,ne,Se))){Ur=!1;break}}return Se.delete(A),Se.delete($),Ur}function b4(A,$,V,ne,Je,Se,mt){switch(V){case L:if(A.byteLength!=$.byteLength||A.byteOffset!=$.byteOffset)return!1;A=A.buffer,$=$.buffer;case j:return!(A.byteLength!=$.byteLength||!Se(new sP(A),new sP($)));case u:case h:case v:return hP(+A,+$);case f:return A.name==$.name&&A.message==$.message;case C:case E:return A==$+"";case m:var At=DN;case _:var Nt=ne&s;if(At||(At=LN),A.size!=$.size&&!Nt)return!1;var ct=mt.get(A);if(ct)return ct==$;ne|=o,mt.set(A,$);var tr=uP(At(A),At($),ne,Je,Se,mt);return mt.delete(A),tr;case k:if(Lm)return Lm.call(A)==Lm.call($)}return!1}function P4(A,$,V,ne,Je,Se){var mt=V&s,At=dP(A),Nt=At.length,ct=dP($),tr=ct.length;if(Nt!=tr&&!mt)return!1;for(var Ur=Nt;Ur--;){var en=At[Ur];if(!(mt?en in $:ps.call($,en)))return!1}var Pr=Se.get(A);if(Pr&&Se.get($))return Pr==$;var Cr=!0;Se.set(A,$),Se.set($,A);for(var Lo=mt;++Ur<Nt;){en=At[Ur];var qs=A[en],zi=$[en];if(ne)var yP=mt?ne(zi,qs,en,$,A,Se):ne(qs,zi,en,A,$,Se);if(!(yP===void 0?qs===zi||Je(qs,zi,V,ne,Se):yP)){Cr=!1;break}Lo||(Lo=en=="constructor")}if(Cr&&!Lo){var $d=A.constructor,Fd=$.constructor;$d!=Fd&&"constructor"in A&&"constructor"in $&&!(typeof $d=="function"&&$d instanceof $d&&typeof Fd=="function"&&Fd instanceof Fd)&&(Cr=!1)}return Se.delete(A),Se.delete($),Cr}function dP(A){return y4(A,D4,_4)}function Rd(A,$){var V=A.__data__;return E4($)?V[typeof $=="string"?"string":"hash"]:V.map}function Ta(A,$){var V=ON(A,$);return v4(V)?V:void 0}function C4(A){var $=ps.call(A,Li),V=A[Li];try{A[Li]=void 0;var ne=!0}catch{}var Je=nP.call(A);return ne&&($?A[Li]=V:delete A[Li]),Je}var _4=iP?function(A){return A==null?[]:(A=Object(A),Mt(iP(A),function($){return oP.call(A,$)}))}:R4,Ro=dc;(jm&&Ro(new jm(new ArrayBuffer(1)))!=L||cc&&Ro(new cc)!=m||Om&&Ro(Om.resolve())!=b||Dm&&Ro(new Dm)!=_||Rm&&Ro(new Rm)!=T)&&(Ro=function(A){var $=dc(A),V=$==S?A.constructor:void 0,ne=V?Ni(V):"";if(ne)switch(ne){case HN:return L;case KN:return m;case WN:return b;case GN:return _;case VN:return T}return $});function I4(A,$){return $=$??i,!!$&&(typeof A=="number"||Me.test(A))&&A>-1&&A%1==0&&A<$}function E4(A){var $=typeof A;return $=="string"||$=="number"||$=="symbol"||$=="boolean"?A!=="__proto__":A===null}function k4(A){return!!tP&&tP in A}function T4(A){var $=A&&A.constructor,V=typeof $=="function"&&$.prototype||Ad;return A===V}function M4(A){return nP.call(A)}function Ni(A){if(A!=null){try{return eP.call(A)}catch{}try{return A+""}catch{}}return""}function hP(A,$){return A===$||A!==A&&$!==$}var A4=lP(function(){return arguments}())?lP:function(A){return hc(A)&&ps.call(A,"callee")&&!oP.call(A,"callee")},Ld=Array.isArray;function j4(A){return A!=null&&pP(A.length)&&!fP(A)}var $m=BN||L4;function O4(A,$){return cP(A,$)}function fP(A){if(!gP(A))return!1;var $=dc(A);return $==p||$==g||$==c||$==P}function pP(A){return typeof A=="number"&&A>-1&&A%1==0&&A<=i}function gP(A){var $=typeof A;return A!=null&&($=="object"||$=="function")}function hc(A){return A!=null&&typeof A=="object"}var mP=On?Oo(On):x4;function D4(A){return j4(A)?m4(A):w4(A)}function R4(){return[]}function L4(){return!1}t.exports=O4})(Pp,Pp.exports);var UV=Pp.exports;const mA=wi(UV);function HV(t){if(t.length===0)return new Set;const e=t[0],n=t.slice(1),r=new Set;for(const s of e)n.every(o=>o.has(s))&&r.add(s);return r}function KV(t,e){const n={};for(const r of e)t.has(r)||(n.added??(n.added=new Set),n.added.add(r));for(const r of t)e.has(r)||(n.removed??(n.removed=new Set),n.removed.add(r));return n.added||n.removed?n:void 0}function U_(t,e){for(const[n,r]of Object.entries(t)){const s=r,o=e[n];if("eq"in s&&o!==s.eq||"neq"in s&&o===s.neq||"gt"in s&&(typeof o!="number"||o<=s.gt))return!1}return!0}function H_(t,e,n){const r=Object.fromEntries(Object.keys(n).map(s=>[s,new Set]));for(const[s,o]of Object.entries(n))if("eq"in o){const a=t.index(e,s).get().get(o.eq);if(a)for(const l of a)r[s].add(l)}else if("neq"in o){const i=t.index(e,s);for(const[a,l]of i.get())if(a!==o.neq)for(const c of l)r[s].add(c)}else if("gt"in o){const i=t.index(e,s);for(const[a,l]of i.get())if(a>o.gt)for(const c of l)r[s].add(c)}return HV(Object.values(r))}class WV{constructor(e,n){I(this,"indexCache",new Map);I(this,"historyCache",new Map);this.atoms=e,this.history=n}filterHistory(e){if(this.historyCache.has(e))return this.historyCache.get(e);const n=G("filterHistory:"+e,(r,s)=>{if(Qi(r))return this.history.get();const o=this.history.getDiffSince(s);if(o===ur)return this.history.get();const i={added:{},removed:{},updated:{}};let a=0,l=0,c=0;for(const u of o){for(const h of ut(u.added))if(h.typeName===e)if(i.removed[h.id]){const f=i.removed[h.id];delete i.removed[h.id],l--,f!==h&&(i.updated[h.id]=[f,h],c++)}else i.added[h.id]=h,a++;for(const[h,f]of ut(u.updated))f.typeName===e&&(i.added[f.id]?i.added[f.id]=f:i.updated[f.id]?i.updated[f.id]=[i.updated[f.id][0],f]:(i.updated[f.id]=[h,f],c++));for(const h of ut(u.removed))h.typeName===e&&(i.added[h.id]?(delete i.added[h.id],a--):i.updated[h.id]?(i.removed[h.id]=i.updated[h.id][0],delete i.updated[h.id],c--,l++):(i.removed[h.id]=h,l++))}return a||l||c?Kc(this.history.get(),i):r},{historyLength:100});return this.historyCache.set(e,n),n}index(e,n){const r=e+":"+n;if(this.indexCache.has(r))return this.indexCache.get(r);const s=this.__uncached_createIndex(e,n);return this.indexCache.set(r,s),s}__uncached_createIndex(e,n){const r=this.filterHistory(e),s=()=>{r.get();const o=new Map;for(const i of ut(this.atoms.get())){const a=i.get();if(a.typeName===e){const l=a[n];o.has(l)||o.set(l,new Set),o.get(l).add(a.id)}}return o};return G("index:"+e+":"+n,(o,i)=>{if(Qi(o))return s();const a=r.getDiffSince(i);if(a===ur)return s();const l=new Map,c=(p,g)=>{let m=l.get(p);m||(m=new af(o.get(p)??new Set)),m.add(g),l.set(p,m)},u=(p,g)=>{let m=l.get(p);m||(m=new af(o.get(p)??new Set)),m.remove(g),l.set(p,m)};for(const p of a){for(const g of ut(p.added))if(g.typeName===e){const m=g[n];c(m,g.id)}for(const[g,m]of ut(p.updated))if(m.typeName===e){const v=g[n],y=m[n];v!==y&&(u(v,m.id),c(y,m.id))}for(const g of ut(p.removed))if(g.typeName===e){const m=g[n];u(m,g.id)}}let h,f;for(const[p,g]of l){const m=g.get();m&&(h||(h=new Map(o)),f||(f=new Map),m.value.size===0?h.delete(p):h.set(p,m.value),f.set(p,m.diff))}return h&&f?Kc(h,f):o},{historyLength:100})}record(e,n=()=>({}),r="record:"+e+(n?":"+n.toString():"")){const s=this.ids(e,n,r);return G(r,()=>{var o;for(const i of s.get())return(o=this.atoms.get()[i])==null?void 0:o.get()})}records(e,n=()=>({}),r="records:"+e+(n?":"+n.toString():"")){const s=this.ids(e,n,"ids:"+r);return G(r,()=>{const o=this.atoms.get();return[...s.get()].map(i=>{const a=o[i];if(!a)throw new Error("no atom found for record id: "+i);return a.get()})},{isEqual:LT})}ids(e,n=()=>({}),r="ids:"+e+(n?":"+n.toString():"")){const s=this.filterHistory(e),o=()=>{s.get();const l=n();return Object.keys(l).length===0?new Set(ut(this.atoms.get()).flatMap(c=>{const u=c.get();return u.typeName===e?u.id:[]})):H_(this,e,l)},i=l=>{const c=o(),u=KV(l,c);return u?Kc(c,u):l},a=G("ids_query:"+r,n,{isEqual:mA});return G("query:"+r,(l,c)=>{const u=a.get();if(Qi(l))return o();if(c<a.lastChangedEpoch)return i(l);const h=s.getDiffSince(c);if(h===ur)return i(l);const f=new af(l);for(const g of h){for(const m of ut(g.added))m.typeName===e&&U_(u,m)&&f.add(m.id);for(const[m,v]of ut(g.updated))v.typeName===e&&(U_(u,v)?f.add(v.id):f.remove(v.id));for(const m of ut(g.removed))m.typeName===e&&f.remove(m.id)}const p=f.get();return p?Kc(p.value,p.diff):l},{historyLength:50})}exec(e,n){const r=H_(this,e,n);if(r.size===0)return fo;const s=this.atoms.get();return[...r].map(o=>s[o].get())}}class GV{constructor(e){I(this,"_beforeCreateHandlers",{});I(this,"_afterCreateHandlers",{});I(this,"_beforeChangeHandlers",{});I(this,"_afterChangeHandlers",{});I(this,"_beforeDeleteHandlers",{});I(this,"_afterDeleteHandlers",{});I(this,"_operationCompleteHandlers",[]);I(this,"_isEnabled",!0);this.store=e}isEnabled(){return this._isEnabled}setIsEnabled(e){this._isEnabled=e}handleBeforeCreate(e,n){if(!this._isEnabled)return e;const r=this._beforeCreateHandlers[e.typeName];if(r){let s=e;for(const o of r)s=o(s,n);return s}return e}handleAfterCreate(e,n){if(!this._isEnabled)return;const r=this._afterCreateHandlers[e.typeName];if(r)for(const s of r)s(e,n)}handleBeforeChange(e,n,r){if(!this._isEnabled)return n;const s=this._beforeChangeHandlers[n.typeName];if(s){let o=n;for(const i of s)o=i(e,o,r);return o}return n}handleAfterChange(e,n,r){if(!this._isEnabled)return;const s=this._afterChangeHandlers[n.typeName];if(s)for(const o of s)o(e,n,r)}handleBeforeDelete(e,n){if(!this._isEnabled)return!0;const r=this._beforeDeleteHandlers[e.typeName];if(r){for(const s of r)if(s(e,n)===!1)return!1}return!0}handleAfterDelete(e,n){if(!this._isEnabled)return;const r=this._afterDeleteHandlers[e.typeName];if(r)for(const s of r)s(e,n)}handleOperationComplete(e){if(this._isEnabled)for(const n of this._operationCompleteHandlers)n(e)}register(e){const n=[];for(const[r,s]of Object.entries(e))s!=null&&s.beforeCreate&&n.push(this.registerBeforeCreateHandler(r,s.beforeCreate)),s!=null&&s.afterCreate&&n.push(this.registerAfterCreateHandler(r,s.afterCreate)),s!=null&&s.beforeChange&&n.push(this.registerBeforeChangeHandler(r,s.beforeChange)),s!=null&&s.afterChange&&n.push(this.registerAfterChangeHandler(r,s.afterChange)),s!=null&&s.beforeDelete&&n.push(this.registerBeforeDeleteHandler(r,s.beforeDelete)),s!=null&&s.afterDelete&&n.push(this.registerAfterDeleteHandler(r,s.afterDelete));return()=>{for(const r of n)r()}}registerBeforeCreateHandler(e,n){return this._beforeCreateHandlers[e]||(this._beforeCreateHandlers[e]=[]),this._beforeCreateHandlers[e].push(n),()=>Bi(this._beforeCreateHandlers[e],n)}registerAfterCreateHandler(e,n){return this._afterCreateHandlers[e]||(this._afterCreateHandlers[e]=[]),this._afterCreateHandlers[e].push(n),()=>Bi(this._afterCreateHandlers[e],n)}registerBeforeChangeHandler(e,n){return this._beforeChangeHandlers[e]||(this._beforeChangeHandlers[e]=[]),this._beforeChangeHandlers[e].push(n),()=>Bi(this._beforeChangeHandlers[e],n)}registerAfterChangeHandler(e,n){return this._afterChangeHandlers[e]||(this._afterChangeHandlers[e]=[]),this._afterChangeHandlers[e].push(n),()=>Bi(this._afterChangeHandlers[e],n)}registerBeforeDeleteHandler(e,n){return this._beforeDeleteHandlers[e]||(this._beforeDeleteHandlers[e]=[]),this._beforeDeleteHandlers[e].push(n),()=>Bi(this._beforeDeleteHandlers[e],n)}registerAfterDeleteHandler(e,n){return this._afterDeleteHandlers[e]||(this._afterDeleteHandlers[e]=[]),this._afterDeleteHandlers[e].push(n),()=>Bi(this._afterDeleteHandlers[e],n)}registerOperationCompleteHandler(e){return this._operationCompleteHandlers.push(e),()=>Bi(this._operationCompleteHandlers,e)}}function Bi(t,e){const n=t.indexOf(e);n>=0&&t.splice(n,1)}class eb{constructor(e){I(this,"id");I(this,"atoms",It("store_atoms",{}));I(this,"history",It("history",0,{historyLength:1e3}));I(this,"query",new WV(this.atoms,this.history));I(this,"listeners",new Set);I(this,"historyAccumulator",new YV);I(this,"historyReactor");I(this,"schema");I(this,"props");I(this,"scopedTypes");I(this,"sideEffects",new GV(this));I(this,"isMergingRemoteChanges",!1);I(this,"_integrityChecker");I(this,"_isPossiblyCorrupted",!1);I(this,"pendingAfterEvents",null);I(this,"_isInAtomicOp",!1);const{initialData:n,schema:r,id:s}=e;this.id=s??ze(),this.schema=r,this.props=e.props,n&&this.atoms.set(w0(Xn(n).map(([o,i])=>[o,It("atom:"+o,this.schema.validateRecord(this,i,"initialize",null))]))),this.historyReactor=uV("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:o=>this.cancelHistoryReactor=nM(o)}),this.scopedTypes={document:new Set(ut(this.schema.types).filter(o=>o.scope==="document").map(o=>o.typeName)),session:new Set(ut(this.schema.types).filter(o=>o.scope==="session").map(o=>o.typeName)),presence:new Set(ut(this.schema.types).filter(o=>o.scope==="presence").map(o=>o.typeName))}}cancelHistoryReactor(){}_flushHistory(){if(this.historyAccumulator.hasChanges()){const e=this.historyAccumulator.flush();for(const{changes:n,source:r}of e){let s=null,o=null,i=null;for(const{onHistory:a,filters:l}of this.listeners)if(!(l.source!=="all"&&l.source!==r))if(l.scope!=="all")if(l.scope==="document"){if(o??(o=this.filterChangesByScope(n,"document")),!o)continue;a({changes:o,source:r})}else if(l.scope==="session"){if(s??(s=this.filterChangesByScope(n,"session")),!s)continue;a({changes:s,source:r})}else{if(i??(i=this.filterChangesByScope(n,"presence")),!i)continue;a({changes:i,source:r})}else a({changes:n,source:r})}}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(e,n){const r={added:au(e.added,(s,o)=>this.scopedTypes[n].has(o.typeName)),updated:au(e.updated,(s,o)=>this.scopedTypes[n].has(o[1].typeName)),removed:au(e.removed,(s,o)=>this.scopedTypes[n].has(o.typeName))};return Object.keys(r.added).length===0&&Object.keys(r.updated).length===0&&Object.keys(r.removed).length===0?null:r}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(n=>this.schema.validateRecord(this,n,e,null))}put(e,n){this.atomic(()=>{const r={},s={},o=this.atoms.__unsafe__getWithoutCapture();let i=null,a,l=!1;const c=this.isMergingRemoteChanges?"remote":"user";for(let u=0,h=e.length;u<h;u++){a=e[u];const f=(i??o)[a.id];if(f){const p=f.__unsafe__getWithoutCapture();if(a=this.sideEffects.handleBeforeChange(p,a,c),this.schema.validateRecord(this,a,n??"updateRecord",p)===p)continue;f.set(a),l=!0;const m=f.__unsafe__getWithoutCapture();r[a.id]=[p,m],this.addDiffForAfterEvent(p,m)}else a=this.sideEffects.handleBeforeCreate(a,c),l=!0,a=this.schema.validateRecord(this,a,n??"createRecord",null),s[a.id]=a,this.addDiffForAfterEvent(null,a),i||(i={...o}),i[a.id]=It("atom:"+a.id,a)}i&&this.atoms.set(i),l&&this.updateHistory({added:s,updated:r,removed:{}})})}remove(e){this.atomic(()=>{const n=new Set,r=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(const o of e){const i=this.atoms.__unsafe__getWithoutCapture()[o];i&&this.sideEffects.handleBeforeDelete(i.get(),r)===!1&&n.add(o)}let s;this.atoms.update(o=>{let i;for(const a of e){if(n.has(a)||!(a in o))continue;i||(i={...o}),s||(s={}),delete i[a];const l=o[a].get();s[a]=l,this.addDiffForAfterEvent(l,null)}return i??o}),s&&this.updateHistory({added:{},updated:{},removed:s})})}get(e){var n;return(n=this.atoms.get()[e])==null?void 0:n.get()}unsafeGetWithoutCapture(e){var n;return(n=this.atoms.__unsafe__getWithoutCapture()[e])==null?void 0:n.__unsafe__getWithoutCapture()}serialize(e="document"){const n={};for(const[r,s]of Xn(this.atoms.get())){const o=s.get();(e==="all"||this.scopedTypes[e].has(o.typeName))&&(n[r]=o)}return n}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 n=this.schema.migrateStoreSnapshot(e);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);return{store:n.value,schema:this.schema.serialize()}}loadStoreSnapshot(e){const n=this.schema.migrateStoreSnapshot(e);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);const r=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(n.value)),this.ensureStoreIsUsable()})}finally{this.sideEffects.setIsEnabled(r)}}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 ut(this.atoms.get()).map(e=>e.get())}clear(){this.remove(FC(this.atoms.get()))}update(e,n){const r=this.atoms.get()[e];if(!r){console.error(`Record ${e} not found. This is probably an error`);return}this.put([n(r.__unsafe__getWithoutCapture())])}has(e){return!!this.atoms.get()[e]}listen(e,n){this._flushHistory();const r={onHistory:e,filters:{source:(n==null?void 0:n.source)??"all",scope:(n==null?void 0:n.scope)??"all"}};return this.historyReactor.scheduler.isActivelyListening||(this.historyReactor.start(),this.historyReactor.scheduler.execute()),this.listeners.add(r),()=>{this.listeners.delete(r),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,js(e)}finally{this.isMergingRemoteChanges=!1,this.ensureStoreIsUsable()}}extractingChanges(e){const n=[],r=this.historyAccumulator.addInterceptor(s=>n.push(s.changes));try{return js(e),J0(n)}finally{r()}}applyDiff(e,{runCallbacks:n=!0,ignoreEphemeralKeys:r=!1}={}){this.atomic(()=>{const s=ut(e.added);for(const[i,a]of ut(e.updated)){const l=this.schema.getType(a.typeName);if(r&&l.ephemeralKeySet.size){const c=this.get(a.id);if(!c){s.push(a);continue}let u=null;for(const[h,f]of Object.entries(a))l.ephemeralKeySet.has(h)||Object.is(f,hn(c,h))||(u||(u={...c}),u[h]=f);u&&s.push(u)}else s.push(a)}const o=FC(e.removed);s.length&&this.put(s),o.length&&this.remove(o)},n)}createComputedCache(e,n,r){const s=new Ds;return{get:o=>{const i=this.atoms.get()[o];if(i)return s.get(i,()=>{const a=r?G(i.name+":equals",()=>i.get(),{isEqual:r}):i;return G(e+":"+o,()=>n(a.get()))}).get()}}}createSelectedComputedCache(e,n,r){const s=new Ds;return{get:o=>{const i=this.atoms.get()[o];if(i)return s.get(i,()=>{const a=G(e+":"+o+":selector",()=>n(i.get()));return G(e+":"+o,()=>r(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,n){if(Le(this.pendingAfterEvents,"must be in event operation"),e===n||(e&&n&&Le(e.id===n.id),!e&&!n))return;const r=(e||n).id,s=this.pendingAfterEvents.get(r);s?s.after=n:this.pendingAfterEvents.set(r,{before:e,after:n})}flushAtomicCallbacks(){let e=0;const n=this.isMergingRemoteChanges?"remote":"user";for(;this.pendingAfterEvents;){const r=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:s,after:o}of r.values())s&&o?this.sideEffects.handleAfterChange(s,o,n):s&&!o?this.sideEffects.handleAfterDelete(s,n):!s&&o&&this.sideEffects.handleAfterCreate(o,n);this.pendingAfterEvents||this.sideEffects.handleOperationComplete(n)}}}atomic(e,n=!0){return js(()=>{if(this._isInAtomicOp)return this.pendingAfterEvents||(this.pendingAfterEvents=new Map),e();this.pendingAfterEvents=new Map;const r=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(n??r),this._isInAtomicOp=!0;try{const s=e();return this.flushAtomicCallbacks(),s}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(r),this._isInAtomicOp=!1}})}addHistoryInterceptor(e){return this.historyAccumulator.addInterceptor(n=>e(n,this.isMergingRemoteChanges?"remote":"user"))}}function VV(t){if(t.length===0)return[];const e=[];let n=[t[0]],r;for(let s=1,o=t.length;s<o;s++)r=t[s],n[0].source!==r.source&&(e.push(n),n=[]),n.push(r);return e.push(n),e.map(s=>({source:s[0].source,changes:J0(s.map(o=>o.changes))}))}class YV{constructor(){I(this,"_history",[]);I(this,"_interceptors",new Set)}addInterceptor(e){return this._interceptors.add(e),()=>{this._interceptors.delete(e)}}add(e){this._history.push(e);for(const n of this._interceptors)n(e)}flush(){const e=VV(this._history);return this._history=[],e}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function XV(t,e,n){const r=new Ds;return{get(s,o){return r.get(s,()=>(s instanceof eb?s:s.store).createComputedCache(t,l=>e(s,l),n)).get(o)}}}function qV(t){const e=[];for(let n=t.length-1;n>=0;n--){const r=t[n];if("id"in r)e.unshift(r);else{const s=r.dependsOn,o=e[0];o&&(e[0]={...o,dependsOn:s.concat(o.dependsOn??[])})}}return e}function vl({sequence:t,sequenceId:e,retroactive:n=!0}){const r={sequenceId:e,retroactive:n,sequence:qV(t)};return yA(r),r}function Zn(t,e){return Object.fromEntries(Xn(e).map(([n,r])=>[n,`${t}/${r}`]))}function xr(t){const e=t.sequenceId;return vl({sequenceId:e,retroactive:t.retroactive??!0,sequence:t.sequence.map(n=>"id"in n?{...n,scope:"record",filter:r=>{var s,o;return r.typeName===t.recordType&&(((s=n.filter)==null?void 0:s.call(n,r))??!0)&&(((o=t.filter)==null?void 0:o.call(t,r))??!0)}}:n)})}function ZV(t){const e=new Map(t.map(o=>[o.id,o])),n=new Set,r=[];function s(o){Le(!n.has(o.id),`Circular dependency in migrations: ${o.id}`),n.add(o.id);const{version:i,sequenceId:a}=Cp(o.id),l=e.get(`${a}/${i-1}`);if(l&&s(l),o.dependsOn)for(const c of o.dependsOn){const u=e.get(c);u&&s(u)}e.delete(o.id),r.push(o)}for(const o of e.values())s(o);return r}function Cp(t){const[e,n]=t.split("/");return{sequenceId:e,version:parseInt(n)}}function K_(t,e){e&&Le(t.startsWith(e+"/"),`Every migration in sequence '${e}' must have an id starting with '${e}/'. Got invalid id: '${t}'`),Le(t.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${t}'`)}function yA(t){if(Le(!t.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${t.sequenceId}`),Le(t.sequenceId.length,"sequenceId must be a non-empty string"),t.sequence.length===0)return;K_(t.sequence[0].id,t.sequenceId);let e=Cp(t.sequence[0].id).version;Le(e===1,`Expected the first migrationId to be '${t.sequenceId}/1' but got '${t.sequence[0].id}'`);for(let n=1;n<t.sequence.length;n++){const r=t.sequence[n].id;K_(r,t.sequenceId);const s=Cp(r).version;Le(s===e+1,`Migration id numbers must increase in increments of 1, expected ${t.sequenceId}/${e+1} but got '${t.sequence[n].id}'`),e=s}}var Bo=(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))(Bo||{});function QV(t){if(t.schemaVersion>2||t.schemaVersion<1)return wn.err("Bad schema version");if(t.schemaVersion===2)return wn.ok(t);const e={schemaVersion:2,sequences:{"com.tldraw.store":t.storeVersion}};for(const[n,r]of Object.entries(t.recordVersions))if(e.sequences[`com.tldraw.${n}`]=r.version,"subTypeKey"in r)for(const[s,o]of Object.entries(r.subTypeVersions))e.sequences[`com.tldraw.${n}.${s}`]=o;return wn.ok(e)}class tb{constructor(e,n){I(this,"migrations",{});I(this,"sortedMigrations");var s;this.types=e,this.options=n;for(const o of n.migrations??[])Le(!this.migrations[o.sequenceId],`Duplicate migration sequenceId ${o.sequenceId}`),yA(o),this.migrations[o.sequenceId]=o;const r=Object.values(this.migrations).flatMap(o=>o.sequence);this.sortedMigrations=ZV(r);for(const o of this.sortedMigrations)if((s=o.dependsOn)!=null&&s.length)for(const i of o.dependsOn){const a=r.find(l=>l.id===i);Le(a,`Migration '${o.id}' depends on missing migration '${i}'`)}}static create(e,n){return new tb(e,n??{})}validateRecord(e,n,r,s){try{const o=hn(this.types,n.typeName);if(!o)throw new Error(`Missing definition for record type ${n.typeName}`);return o.validate(n,s??void 0)}catch(o){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:e,record:n,phase:r,recordBefore:s,error:o});throw o}}getMigrationsSince(e){const n=QV(e);if(!n.ok)return n;const r=n.value,s=new Set(Object.keys(r.sequences).filter(i=>this.migrations[i]));for(const i in this.migrations)r.sequences[i]===void 0&&this.migrations[i].retroactive&&s.add(i);if(s.size===0)return wn.ok([]);const o=new Set;for(const i of s){const a=r.sequences[i];if(typeof a!="number"&&this.migrations[i].retroactive||a===0){for(const u of this.migrations[i].sequence)o.add(u.id);continue}const l=`${i}/${a}`,c=this.migrations[i].sequence.findIndex(u=>u.id===l);if(c===-1)return wn.err("Incompatible schema?");for(const u of this.migrations[i].sequence.slice(c+1))o.add(u.id)}return wn.ok(this.sortedMigrations.filter(({id:i})=>o.has(i)))}migratePersistedRecord(e,n,r="up"){const s=this.getMigrationsSince(n);if(!s.ok)return console.error("Error migrating record",s.error),{type:"error",reason:Bo.MigrationError};let o=s.value;if(o.length===0)return{type:"success",value:e};if(o.some(i=>i.scope==="store"))return{type:"error",reason:r==="down"?Bo.TargetVersionTooOld:Bo.TargetVersionTooNew};if(r==="down"){if(!o.every(i=>i.down))return{type:"error",reason:Bo.TargetVersionTooOld};o=o.slice().reverse()}e=nt(e);try{for(const i of o){if(i.scope==="store")throw new Error;if(!(i.filter?i.filter(e):!0))continue;const l=i[r](e);l&&(e=nt(l))}}catch(i){return console.error("Error migrating record",i),{type:"error",reason:Bo.MigrationError}}return{type:"success",value:e}}migrateStoreSnapshot(e){let{store:n}=e;const r=this.getMigrationsSince(e.schema);if(!r.ok)return console.error("Error migrating store",r.error),{type:"error",reason:Bo.MigrationError};const s=r.value;if(s.length===0)return{type:"success",value:n};n=nt(n);try{for(const o of s)if(o.scope==="record")for(const[i,a]of Object.entries(n)){if(!(o.filter?o.filter(a):!0))continue;const c=o.up(a);c&&(n[i]=nt(c))}else if(o.scope==="store"){const i=o.up(n);i&&(n=nt(i))}else Ot(o)}catch(o){return console.error("Error migrating store",o),{type:"error",reason:Bo.MigrationError}}return{type:"success",value:n}}createIntegrityChecker(e){var n,r;return((r=(n=this.options).createIntegrityChecker)==null?void 0:r.call(n,e))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e,sequence:n})=>[e,n.length?Cp(n.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e})=>[e,0]))}}getType(e){const n=hn(this.types,e);return Le(n,"record type does not exists"),n}}_i("@tldraw/store","3.7.2","esm");function JV(t){if(!t.length)return null;let e="";for(const n of t)typeof n=="number"?e+=`.${n}`:n.startsWith("(")?e.endsWith(")")?e=`${e.slice(0,-1)}, ${n.slice(1)}`:e+=n:e+=`.${n}`;return e=e.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),e.startsWith(".")?e.slice(1):e}class Te extends Error{constructor(n,r=[]){const s=JV(r),o=n.split(`
|
|
83
|
-
`).map((i,a)=>a===0?i:` ${i}`).join(`
|
|
84
|
-
`);super(r?`At ${s}: ${o}`:o);I(this,"name","ValidationError");this.rawMessage=n,this.path=r}}function qn(t,e){try{return e()}catch(n){throw n instanceof Te?new Te(n.rawMessage,[t,...n.path]):new Te(n.toString(),[t])}}function gi(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:Ot(e)}}class Tn{constructor(e,n){this.validationFn=e,this.validateUsingKnownGoodVersionFn=n}validate(e){return this.validationFn(e)}validateUsingKnownGoodVersion(e,n){return Object.is(e,n)?e:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(e,n):this.validate(n)}isValid(e){try{return this.validate(e),!0}catch{return!1}}nullable(){return oY(this)}optional(){return vA(this)}refine(e){return new Tn(n=>e(this.validate(n)),(n,r)=>{const s=this.validateUsingKnownGoodVersion(n,r);return Object.is(n,s)?n:e(s)})}check(e,n){return typeof e=="string"?this.refine(r=>(qn(`(check ${e})`,()=>n(r)),r)):this.refine(r=>(e(r),r))}}class eY extends Tn{constructor(e){super(n=>{const r=W_.validate(n);for(let s=0;s<r.length;s++)qn(s,()=>e.validate(r[s]));return r},(n,r)=>{if(!e.validateUsingKnownGoodVersion)return this.validate(r);const s=W_.validate(r);let o=n.length!==s.length;for(let i=0;i<s.length;i++){const a=s[i];if(i>=n.length){o=!0,qn(i,()=>e.validate(a));continue}if(Object.is(n[i],a))continue;const l=qn(i,()=>e.validateUsingKnownGoodVersion(n[i],a));Object.is(l,n[i])||(o=!0)}return o?r:n}),this.itemValidator=e}nonEmpty(){return this.check(e=>{if(e.length===0)throw new Te("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(e=>{if(e.length<=1)throw new Te("Expected an array with length greater than 1")})}}class _p extends Tn{constructor(e,n=!1){super(r=>{if(typeof r!="object"||r===null)throw new Te(`Expected object, got ${gi(r)}`);for(const[s,o]of Object.entries(e))qn(s,()=>{o.validate(hn(r,s))});if(!n){for(const s of Object.keys(r))if(!ns(e,s))throw new Te("Unexpected property",[s])}return r},(r,s)=>{if(typeof s!="object"||s===null)throw new Te(`Expected object, got ${gi(s)}`);let o=!1;for(const[i,a]of Object.entries(e)){const l=hn(r,i),c=hn(s,i);if(Object.is(l,c))continue;const u=qn(i,()=>{const h=a;return h.validateUsingKnownGoodVersion?h.validateUsingKnownGoodVersion(l,c):h.validate(c)});Object.is(u,l)||(o=!0)}if(!n){for(const i of Object.keys(s))if(!ns(e,i))throw new Te("Unexpected property",[i])}for(const i of Object.keys(r))if(!ns(s,i)){o=!0;break}return o?s:r}),this.config=e,this.shouldAllowUnknownProperties=n}allowUnknownProperties(){return new _p(this.config,!0)}extend(e){return new _p({...this.config,...e})}}class Ag extends Tn{constructor(e,n,r,s){super(o=>{this.expectObject(o);const{matchingSchema:i,variant:a}=this.getMatchingSchemaAndVariant(o);return i===void 0?this.unknownValueValidation(o,a):qn(`(${e} = ${a})`,()=>i.validate(o))},(o,i)=>{this.expectObject(i),this.expectObject(o);const{matchingSchema:a,variant:l}=this.getMatchingSchemaAndVariant(i);return a===void 0?this.unknownValueValidation(i,l):hn(o,e)!==hn(i,e)?qn(`(${e} = ${l})`,()=>a.validate(i)):qn(`(${e} = ${l})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(o,i):a.validate(i))}),this.key=e,this.config=n,this.unknownValueValidation=r,this.useNumberKeys=s}expectObject(e){if(typeof e!="object"||e===null)throw new Te(`Expected an object, got ${gi(e)}`,[])}getMatchingSchemaAndVariant(e){const n=hn(e,this.key);if(!this.useNumberKeys&&typeof n!="string")throw new Te(`Expected a string for key "${this.key}", got ${gi(n)}`);if(this.useNumberKeys&&!Number.isFinite(Number(n)))throw new Te(`Expected a number for key "${this.key}", got "${n}"`);return{matchingSchema:ns(this.config,n)?this.config[n]:void 0,variant:n}}validateUnknownVariants(e){return new Ag(this.key,this.config,e,this.useNumberKeys)}}class tY extends Tn{constructor(e,n){super(r=>{if(typeof r!="object"||r===null)throw new Te(`Expected object, got ${gi(r)}`);for(const[s,o]of Object.entries(r))qn(s,()=>{e.validate(s),n.validate(o)});return r},(r,s)=>{if(typeof s!="object"||s===null)throw new Te(`Expected object, got ${gi(s)}`);let o=!1;for(const[i,a]of Object.entries(s)){if(!ns(r,i)){o=!0,qn(i,()=>{e.validate(i),n.validate(a)});continue}const l=hn(r,i),c=a;if(Object.is(l,c))continue;const u=qn(i,()=>n.validateUsingKnownGoodVersion?n.validateUsingKnownGoodVersion(l,c):n.validate(c));Object.is(u,l)||(o=!0)}for(const i of Object.keys(r))if(!ns(s,i)){o=!0;break}return o?s:r}),this.keyValidator=e,this.valueValidator=n}}function nb(t){return new Tn(e=>{if(typeof e!==t)throw new Te(`Expected ${t}, got ${gi(e)}`);return e})}const nY=new Tn(t=>t),ye=nb("string"),pe=nb("number").check(t=>{if(Number.isNaN(t))throw new Te("Expected a number, got NaN");if(!Number.isFinite(t))throw new Te(`Expected a finite number, got ${t}`)}),Ip=pe.check(t=>{if(t<0)throw new Te(`Expected a positive number, got ${t}`)}),Pt=pe.check(t=>{if(t<=0)throw new Te(`Expected a non-zero positive number, got ${t}`)}),SA=pe.check(t=>{if(!Number.isInteger(t))throw new Te(`Expected an integer, got ${t}`)}),lf=SA.check(t=>{if(t<0)throw new Te(`Expected a positive integer, got ${t}`)}),rY=SA.check(t=>{if(t<=0)throw new Te(`Expected a non-zero positive integer, got ${t}`)}),we=nb("boolean");function mn(t){return new Tn(e=>{if(e!==t)throw new Te(`Expected ${t}, got ${JSON.stringify(e)}`);return t})}const W_=new Tn(t=>{if(!Array.isArray(t))throw new Te(`Expected an array, got ${gi(t)}`);return t});function Wt(t){return new eY(t)}function Pe(t){return new _p(t)}function gx(t){return typeof t=="object"&&t!==null&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null||Object.getPrototypeOf(t)===mB)}function mx(t){return t===null||typeof t=="number"||typeof t=="string"||typeof t=="boolean"?!0:Array.isArray(t)?t.every(mx):gx(t)?Object.values(t).every(mx):!1}const Gt=new Tn(t=>{if(mx(t))return t;throw new Te(`Expected json serializable value, got ${typeof t}`)},(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){let n=t.length!==e.length;for(let r=0;r<e.length;r++){if(r>=t.length){n=!0,Gt.validate(e[r]);continue}const s=t[r],o=e[r];if(Object.is(s,o))continue;const i=Gt.validateUsingKnownGoodVersion(s,o);Object.is(i,s)||(n=!0)}return n?e:t}else if(gx(t)&&gx(e)){let n=!1;for(const r of Object.keys(e)){if(!ns(t,r)){n=!0,Gt.validate(e[r]);continue}const s=t[r],o=e[r];if(Object.is(s,o))continue;const i=Gt.validateUsingKnownGoodVersion(s,o);Object.is(i,s)||(n=!0)}for(const r of Object.keys(t))if(!ns(e,r)){n=!0;break}return n?e:t}else return Gt.validate(e)});function Ep(t,e){return new tY(t,e)}function rb(t,e){return new Ag(t,e,(n,r)=>{throw new Te(`Expected one of ${Object.keys(e).map(s=>JSON.stringify(s)).join(" or ")}, got ${JSON.stringify(r)}`,[t])},!1)}function sY(t,e){return new Ag(t,e,(n,r)=>{throw new Te(`Expected one of ${Object.keys(e).map(s=>JSON.stringify(s)).join(" or ")}, got ${JSON.stringify(r)}`,[t])},!0)}function Ks(t,e){return new Tn(n=>qn(t,()=>e.validate(n)),(n,r)=>qn(t,()=>e.validateUsingKnownGoodVersion?e.validateUsingKnownGoodVersion(n,r):e.validate(r)))}function jg(t){return new Tn(e=>{if(!t.has(e)){const n=Array.from(t,r=>JSON.stringify(r)).join(" or ");throw new Te(`Expected ${n}, got ${e}`)}return e})}function vA(t){return new Tn(e=>{if(e!==void 0)return t.validate(e)},(e,n)=>{if(!(e===void 0&&n===void 0)&&n!==void 0)return t.validateUsingKnownGoodVersion&&e!==void 0?t.validateUsingKnownGoodVersion(e,n):t.validate(n)})}function oY(t){return new Tn(e=>e===null?null:t.validate(e),(e,n)=>n===null?null:t.validateUsingKnownGoodVersion&&e!==null?t.validateUsingKnownGoodVersion(e,n):t.validate(n))}function Og(...t){return jg(new Set(t))}function sb(t){try{return new URL(t)}catch{if(t.startsWith("/")||t.startsWith("./"))try{return new URL(t,"http://example.com")}catch{throw new Te(`Expected a valid url, got ${JSON.stringify(t)}`)}throw new Te(`Expected a valid url, got ${JSON.stringify(t)}`)}}const iY=new Set(["http:","https:","mailto:"]),gr=ye.check(t=>{if(t==="")return;const e=sb(t);if(!iY.has(e.protocol.toLowerCase()))throw new Te(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)}),aY=new Set(["http:","https:","data:","asset:"]),la=ye.check(t=>{if(t==="")return;const e=sb(t);if(!aY.has(e.protocol.toLowerCase()))throw new Te(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)});ye.check(t=>{if(t==="")return;if(!sb(t).protocol.toLowerCase().match(/^https?:$/))throw new Te(`Expected a valid url, got ${JSON.stringify(t)} (invalid protocol)`)});const ob=ye.refine(t=>{try{return iB(t),t}catch{throw new Te(`Expected an index key, got ${JSON.stringify(t)}`)}});_i("@tldraw/validate","3.7.2","esm");function dr(t){return ye.refine(e=>{if(!e.startsWith(`${t}:`))throw new Error(`${t} ID must start with "${t}:"`);return e})}const Dg=dr("asset");function ib(t,e){return Pe({id:Dg,typeName:mn("asset"),type:mn(t),props:e,meta:Gt})}const ca=Pe({x:pe,y:pe,z:pe.optional()}),cu=Pe({x:pe,y:pe,w:pe,h:pe}),xA=pe.check(t=>{if(t<0||t>1)throw new Te("Opacity must be between 0 and 1")}),lY=ye.refine(t=>{if(!t.startsWith("page:")&&!t.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return t}),Ir=dr("shape");function cY(t,e,n){return Pe({id:Ir,typeName:mn("shape"),x:pe,y:pe,rotation:pe,index:ob,parentId:lY,type:mn(t),isLocked:we,opacity:xA,props:e?Pe(e):Gt,meta:n?Pe(n):Gt})}const uY=dr("binding");function dY(t,e,n){return Pe({id:uY,typeName:mn("binding"),type:mn(t),fromId:Ir,toId:Ir,props:e?Pe(e):Gt,meta:n?Pe(n):Gt})}Zn("com.tldraw.binding",{});xr({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});function Ji(t){return`binding:${ze()}`}function hY(t){return Hs("binding",{scope:"document",validator:Ks("binding",rb("type",sd(t,(e,{props:n,meta:r})=>dY(e,n,r))))}).withDefaultProperties(()=>({meta:{}}))}class Qt{constructor(e,n,r){this.id=e,this.defaultValue=n,this.type=r}static define(e,n){const{defaultValue:r,type:s=nY}=n;return new Qt(e,r,s)}static defineEnum(e,n){const{defaultValue:r,values:s}=n;return new fY(e,r,s)}setDefaultValue(e){this.defaultValue=e}validate(e){return this.type.validate(e)}validateUsingKnownGoodVersion(e,n){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(e,n):this.validate(n)}}class fY extends Qt{constructor(e,n,r){super(e,n,Og(...r)),this.values=r}}const lh=Zn("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),pY=xr({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:lh.AddIsLocked,up:t=>{t.isLocked=!1},down:t=>{delete t.isLocked}},{id:lh.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:lh.AddMeta,up:t=>{t.meta={}}},{id:lh.AddWhite,up:t=>{},down:t=>{t.props.color==="white"&&(t.props.color="black")}}]});function ll(t){return t?t.typeName==="shape":!1}function Fn(t){return t?t.startsWith("shape:"):!1}function Ke(t){return`shape:${t??ze()}`}function wA(t){const e=new Map;for(const[n,r]of Object.entries(t))if(r instanceof Qt){if(e.has(r))throw new Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);e.set(r,n)}return e}function us(t,e){return sd(e,(n,r)=>`com.tldraw.shape.${t}/${r}`)}function gY(t){return Hs("shape",{scope:"document",validator:Ks("shape",rb("type",sd(t,(e,{props:n,meta:r})=>cY(e,n,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}function G_(t,e){const n=[];for(const[r,{migrations:s}]of Object.entries(e)){const o=`com.tldraw.${t}.${r}`;s?"sequenceId"in s?(Le(o===s.sequenceId,`sequenceId mismatch for ${r} ${Mg} migrations. Expected '${o}', got '${s.sequenceId}'`),n.push(s)):"sequence"in s?n.push(vl({sequenceId:o,retroactive:!1,sequence:s.sequence.map(i=>"id"in i?bA(t,r,i):i)})):n.push(vl({sequenceId:o,retroactive:!1,sequence:Object.keys(s.migrators).map(i=>Number(i)).sort((i,a)=>i-a).map(i=>({id:`${o}/${i}`,scope:"record",filter:a=>a.typeName===t&&a.type===r,up:a=>{const l=s.migrators[i].up(a);if(l)return l},down:a=>{const l=s.migrators[i].down(a);if(l)return l}}))})):n.push(vl({sequenceId:o,retroactive:!1,sequence:[]}))}return n}function bA(t,e,n){return{id:n.id,dependsOn:n.dependsOn,scope:"record",filter:r=>r.typeName===t&&r.type===e,up:r=>{const s=n.up(r.props);s&&(r.props=s)},down:typeof n.down=="function"?r=>{const s=n.down(r.props);s&&(r.props=s)}:void 0}}const PA=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],kp={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 ko(t){return t.isDarkMode?kp.darkMode:kp.lightMode}const mr=Qt.defineEnum("tldraw:color",{defaultValue:"black",values:PA}),ab=Qt.defineEnum("tldraw:labelColor",{defaultValue:"black",values:PA}),ua=Qt.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),da=Qt.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill"]}),Ls=Qt.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),CA={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},$s=Qt.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),_A=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],Tp=Qt.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:_A}),Mp=Qt.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:_A}),IA={labelColor:ab,color:mr,fill:da,dash:ua,size:$s,arrowheadStart:Tp,arrowheadEnd:Mp,font:Ls,start:ca,end:ca,bend:pe,text:ye,labelPosition:pe,scale:Pt},Ha=us("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5});function ch(t){return bA("shape","arrow",t)}const EA=vl({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[ch({id:Ha.AddLabelColor,up:t=>{t.labelColor="black"},down:"retired"}),ch({id:Ha.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)}}),ch({id:Ha.AddLabelPosition,up:t=>{t.labelPosition=.5},down:t=>{delete t.labelPosition}}),{id:Ha.ExtractBindings,scope:"store",up:t=>{const e=Object.values(t).filter(n=>n.typeName==="shape"&&n.type==="arrow");for(const n of e){const{start:r,end:s}=n.props;if(r.type==="binding"){const o=Ji(),i={typeName:"binding",id:o,type:"arrow",fromId:n.id,toId:r.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:r.normalizedAnchor,isExact:r.isExact,isPrecise:r.isPrecise}};t[o]=i,n.props.start={x:0,y:0}}else delete n.props.start.type;if(s.type==="binding"){const o=Ji(),i={typeName:"binding",id:o,type:"arrow",fromId:n.id,toId:s.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:s.normalizedAnchor,isExact:s.isExact,isPrecise:s.isPrecise}};t[o]=i,n.props.end={x:0,y:0}}else delete n.props.end.type}}},ch({id:Ha.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}})]}),kA={terminal:Og("start","end"),normalizedAnchor:ca,isExact:we,isPrecise:we},TA={sequence:[{dependsOn:[Ha.ExtractBindings]}]},mY=Ks("camera",Pe({typeName:mn("camera"),id:dr("camera"),x:pe,y:pe,z:pe,meta:Gt})),yY=Zn("com.tldraw.camera",{AddMeta:1}),SY=xr({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:yY.AddMeta,up:t=>{t.meta={}}}]}),Is=Hs("camera",{validator:mY,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),vY=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"]),MA=jg(vY),xY=Pe({type:MA,rotation:pe}),wY=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),bY=jg(wY),PY=new Set(["starting","paused","active","stopping"]),AA=Pe({id:ye,points:Wt(ca),size:Ip,color:bY,opacity:pe,state:jg(PY),delay:pe,shrink:pe,taper:we}),zu=dr("page"),CY=Ks("page",Pe({typeName:mn("page"),id:zu,name:ye,index:ob,meta:Gt})),_Y=Zn("com.tldraw.page",{AddMeta:1}),IY=xr({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:_Y.AddMeta,up:t=>{t.meta={}}}]}),yr=Hs("page",{validator:CY,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function Rn(t){return yr.isId(t)}const EY={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 jA(t){return t?au(t,e=>EY[e]):null}dr("instance");function kY(t){const e={};for(const[r,s]of t)e[r]=vA(s);const n=Ks("instance",Pe({typeName:mn("instance"),id:dr("instance"),currentPageId:zu,followingUserId:ye.nullable(),brush:cu.nullable(),opacityForNextShape:xA,stylesForNextShape:Pe(e),cursor:xY,scribbles:Wt(AA),isFocusMode:we,isDebugMode:we,isToolLocked:we,exportBackground:we,screenBounds:cu,insets:Wt(we),zoomBrush:cu.nullable(),isPenMode:we,isGridMode:we,chatMessage:ye,isChatting:we,highlightedUserIds:Wt(ye),isFocused:we,devicePixelRatio:pe,isCoarsePointer:we,isHoveringCanvas:we.nullable(),openMenus:Wt(ye),isChangingStyle:we,isReadonly:we,meta:Gt,duplicateProps:Pe({shapeIds:Wt(dr("shape")),offset:Pe({x:pe,y:pe})}).nullable()}));return Hs("instance",{validator:n,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 et=Zn("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}),TY=xr({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:et.AddTransparentExportBgs,up:t=>({...t,exportBackground:!0})},{id:et.RemoveDialog,up:({dialog:t,...e})=>e},{id:et.AddToolLockMode,up:t=>({...t,isToolLocked:!1})},{id:et.RemoveExtraPropsForNextShape,up:({propsForNextShape:t,...e})=>({...e,propsForNextShape:Object.fromEntries(Object.entries(t).filter(([n])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(n)))})},{id:et.AddLabelColor,up:({propsForNextShape:t,...e})=>({...e,propsForNextShape:{...t,labelColor:"black"}})},{id:et.AddFollowingUserId,up:t=>({...t,followingUserId:null})},{id:et.RemoveAlignJustify,up:t=>{let e=t.propsForNextShape.align;return e==="justify"&&(e="start"),{...t,propsForNextShape:{...t.propsForNextShape,align:e}}}},{id:et.AddZoom,up:t=>({...t,zoomBrush:null})},{id:et.AddVerticalAlign,up:t=>({...t,propsForNextShape:{...t.propsForNextShape,verticalAlign:"middle"}})},{id:et.AddScribbleDelay,up:t=>t.scribble!==null?{...t,scribble:{...t.scribble,delay:0}}:{...t}},{id:et.RemoveUserId,up:({userId:t,...e})=>e},{id:et.AddIsPenModeAndIsGridMode,up:t=>({...t,isPenMode:!1,isGridMode:!1})},{id:et.HoistOpacity,up:({propsForNextShape:{opacity:t,...e},...n})=>({...n,opacityForNextShape:Number(t??"1"),propsForNextShape:e})},{id:et.AddChat,up:t=>({...t,chatMessage:"",isChatting:!1})},{id:et.AddHighlightedUserIds,up:t=>({...t,highlightedUserIds:[]})},{id:et.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:t,...e})=>({...e,stylesForNextShape:{}})},{id:et.AddMeta,up:t=>({...t,meta:{}})},{id:et.RemoveCursorColor,up:t=>{const{color:e,...n}=t.cursor;return{...t,cursor:n}}},{id:et.AddLonelyProperties,up:t=>({...t,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:et.ReadOnlyReadonly,up:({isReadOnly:t,...e})=>({...e,isReadonly:t})},{id:et.AddHoveringCanvas,up:t=>({...t,isHoveringCanvas:null})},{id:et.AddScribbles,up:({scribble:t,...e})=>({...e,scribbles:[]})},{id:et.AddInset,up:t=>({...t,insets:[!1,!1,!1,!1]}),down:({insets:t,...e})=>({...e})},{id:et.AddDuplicateProps,up:t=>({...t,duplicateProps:null}),down:({duplicateProps:t,...e})=>({...e})},{id:et.RemoveCanMoveCamera,up:({canMoveCamera:t,...e})=>({...e}),down:t=>({...t,canMoveCamera:!0})}]}),bn="instance:instance",MY=Ks("instance_page_state",Pe({typeName:mn("instance_page_state"),id:dr("instance_page_state"),pageId:zu,selectedShapeIds:Wt(Ir),hintingShapeIds:Wt(Ir),erasingShapeIds:Wt(Ir),hoveredShapeId:Ir.nullable(),editingShapeId:Ir.nullable(),croppingShapeId:Ir.nullable(),focusedGroupId:Ir.nullable(),meta:Gt})),_c=Zn("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),AY=xr({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:_c.AddCroppingId,up(t){t.croppingShapeId=null}},{id:_c.RemoveInstanceIdAndCameraId,up(t){delete t.instanceId,delete t.cameraId}},{id:_c.AddMeta,up:t=>{t.meta={}}},{id:_c.RenameProperties,up:t=>{},down:t=>{}},{id:_c.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}}]}),Qr=Hs("instance_page_state",{validator:MY,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:{}})),jY=Ks("pointer",Pe({typeName:mn("pointer"),id:dr("pointer"),x:pe,y:pe,lastActivityTimestamp:pe,meta:Gt})),OY=Zn("com.tldraw.pointer",{AddMeta:1}),DY=xr({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:OY.AddMeta,up:t=>{t.meta={}}}]}),lb=Hs("pointer",{validator:jY,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),Ap=lb.createId("pointer"),RY=Ks("instance_presence",Pe({typeName:mn("instance_presence"),id:dr("instance_presence"),userId:ye,userName:ye,lastActivityTimestamp:pe.nullable(),followingUserId:ye.nullable(),cursor:Pe({x:pe,y:pe,type:MA,rotation:pe}).nullable(),color:ye,camera:Pe({x:pe,y:pe,z:pe}).nullable(),screenBounds:cu.nullable(),selectedShapeIds:Wt(dr("shape")),currentPageId:dr("page"),brush:cu.nullable(),scribbles:Wt(AA),chatMessage:ye,meta:Gt})),Oa=Zn("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5,NullableCameraCursor:6}),LY=xr({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:Oa.AddScribbleDelay,up:t=>{t.scribble!==null&&(t.scribble.delay=0)}},{id:Oa.RemoveInstanceId,up:t=>{delete t.instanceId}},{id:Oa.AddChatMessage,up:t=>{t.chatMessage=""}},{id:Oa.AddMeta,up:t=>{t.meta={}}},{id:Oa.RenameSelectedShapeIds,up:t=>{}},{id:Oa.NullableCameraCursor,up:t=>{},down:t=>{t.camera===null&&(t.camera={x:0,y:0,z:1}),t.lastActivityTimestamp===null&&(t.lastActivityTimestamp=0),t.cursor===null&&(t.cursor={type:"default",x:0,y:0,rotation:0}),t.screenBounds===null&&(t.screenBounds={x:0,y:0,w:1,h:1})}}]}),$Y=Hs("instance_presence",{validator:RY,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:null,followingUserId:null,color:"#FF0000",camera:null,cursor:null,screenBounds:null,selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),FY=Ks("document",Pe({typeName:mn("document"),id:mn("document:document"),gridSize:pe,name:ye,meta:Gt})),V_=Zn("com.tldraw.document",{AddName:1,AddMeta:2}),NY=xr({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:V_.AddName,up:t=>{t.name=""},down:t=>{delete t.name}},{id:V_.AddMeta,up:t=>{t.meta={}}}]}),cb=Hs("document",{validator:FY,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),yx=cb.createId("document");function zY(t,e){return t.index<e.index?-1:t.index>e.index?1:0}function Y_(t){t.typeName==="asset"&&("src"in t&&(t.src="<redacted>"),"src"in t.props&&(t.props.src="<redacted>"))}function BY({error:t,phase:e,record:n,recordBefore:r}){throw v0(t,{tags:{origin:"store.validateRecord",storePhase:e,isExistingValidationIssue:e==="initialize"},extras:{recordBefore:r?Y_(nt(r)):void 0,recordAfter:Y_(nt(n))}}),t}function UY(){return[yr.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function HY(t){const e=t.query.ids("page"),n=t.query.records("instance_page_state"),r=()=>{if(!t.has(yx))return t.put([cb.create({id:yx,name:t.props.defaultName})]),r();if(!t.has(Ap))return t.put([lb.create({id:Ap})]),r();const s=e.get();if(s.size===0)return t.put(UY()),r();const o=()=>[...s].map(u=>t.get(u)).sort(zY)[0].id,i=t.get(bn);if(i){if(!s.has(i.currentPageId))return t.put([{...i,currentPageId:o()}]),r()}else return t.put([t.schema.types.instance.create({id:bn,currentPageId:o(),exportBackground:!0})]),r();const a=new Set,l=new Set;for(const u of s){const h=Qr.createId(u);t.get(h)||a.add(h);const p=Is.createId(u);t.has(p)||l.add(p)}a.size>0&&t.put([...a].map(u=>Qr.create({id:u,pageId:Qr.parseId(u)}))),l.size>0&&t.put([...l].map(u=>Is.create({id:u})));const c=n.get();for(const u of c){if(!s.has(u.pageId)){t.remove([u.id]);continue}if(u.croppingShapeId&&!t.has(u.croppingShapeId))return t.put([{...u,croppingShapeId:null}]),r();if(u.focusedGroupId&&!t.has(u.focusedGroupId))return t.put([{...u,focusedGroupId:null}]),r();if(u.hoveredShapeId&&!t.has(u.hoveredShapeId))return t.put([{...u,hoveredShapeId:null}]),r();const h=u.selectedShapeIds.filter(g=>t.has(g));if(h.length!==u.selectedShapeIds.length)return t.put([{...u,selectedShapeIds:h}]),r();const f=u.hintingShapeIds.filter(g=>t.has(g));if(f.length!==u.hintingShapeIds.length)return t.put([{...u,hintingShapeIds:f}]),r();const p=u.erasingShapeIds.filter(g=>t.has(g));if(p.length!==u.erasingShapeIds.length)return t.put([{...u,erasingShapeIds:p}]),r()}};return r}const KY=ib("bookmark",Pe({title:ye,description:ye,image:ye,favicon:ye,src:la.nullable()})),X_=Zn("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),WY=xr({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:t=>t.type==="bookmark",sequence:[{id:X_.MakeUrlsValid,up:t=>{la.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:X_.AddFavicon,up:t=>{la.isValid(t.props.favicon)||(t.props.favicon="")},down:t=>{delete t.props.favicon}}]}),GY=ib("image",Pe({w:pe,h:pe,name:ye,isAnimated:we,mimeType:ye.nullable(),src:la.nullable(),fileSize:Pt.optional()})),Ic=Zn("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),VY=xr({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:t=>t.type==="image",sequence:[{id:Ic.AddIsAnimated,up:t=>{t.props.isAnimated=!1},down:t=>{delete t.props.isAnimated}},{id:Ic.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:Ic.MakeUrlsValid,up:t=>{la.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:Ic.AddFileSize,up:t=>{t.props.fileSize=-1},down:t=>{delete t.props.fileSize}},{id:Ic.MakeFileSizeOptional,up:t=>{t.props.fileSize===-1&&(t.props.fileSize=void 0)},down:t=>{t.props.fileSize===void 0&&(t.props.fileSize=-1)}}]}),YY=ib("video",Pe({w:pe,h:pe,name:ye,isAnimated:we,mimeType:ye.nullable(),src:la.nullable(),fileSize:pe.optional()})),Ec=Zn("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),XY=xr({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:t=>t.type==="video",sequence:[{id:Ec.AddIsAnimated,up:t=>{t.props.isAnimated=!1},down:t=>{delete t.props.isAnimated}},{id:Ec.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:Ec.MakeUrlsValid,up:t=>{la.isValid(t.props.src)||(t.props.src="")},down:t=>{}},{id:Ec.AddFileSize,up:t=>{t.props.fileSize=-1},down:t=>{delete t.props.fileSize}},{id:Ec.MakeFileSizeOptional,up:t=>{t.props.fileSize===-1&&(t.props.fileSize=void 0)},down:t=>{t.props.fileSize===void 0&&(t.props.fileSize=-1)}}]}),qY=Ks("asset",rb("type",{image:GY,video:YY,bookmark:KY})),ZY=Zn("com.tldraw.asset",{AddMeta:1}),QY=xr({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:ZY.AddMeta,up:t=>{t.meta={}}}]}),Yo=Hs("asset",{validator:qY,scope:"document"}).withDefaultProperties(()=>({meta:{}})),OA={w:Pt,h:Pt,assetId:Dg.nullable(),url:gr},q_=us("bookmark",{NullAssetId:1,MakeUrlsValid:2}),DA={sequence:[{id:q_.NullAssetId,up:t=>{t.assetId===void 0&&(t.assetId=null)},down:"retired"},{id:q_.MakeUrlsValid,up:t=>{gr.isValid(t.url)||(t.url="")},down:t=>{}}]},RA=Pe({type:Og("free","straight"),points:Wt(ca)}),LA={color:mr,fill:da,dash:ua,size:$s,segments:Wt(RA),isComplete:we,isClosed:we,isPen:we,scale:Pt},Z_=us("draw",{AddInPen:1,AddScale:2}),$A={sequence:[{id:Z_.AddInPen,up:t=>{const{points:e}=t.segments[0];if(e.length===0){t.isPen=!1;return}let n=!(e[0].z===0||e[0].z===.5);e[1]&&(n=n&&!(e[1].z===0||e[1].z===.5)),t.isPen=n},down:"retired"},{id:Z_.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},JY=/(^\/r\/[^/]+\/?$)/,eX=[{hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(JY))return t}},{hostnames:["figma.com"],fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/^\/embed\/?$/)){const n=e.searchParams.get("url");if(n)return n}}},{hostnames:["google.*"],fromEmbedUrl:t=>{const e=ge(t);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const r=e.searchParams.get("zoom"),[s,o]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${s},${o},${r}z`}}},{hostnames:["val.town"],fromEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`}},{hostnames:["codesandbox.io"],fromEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[1]}`}},{hostnames:["codepen.io"],fromEmbedUrl:t=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,n=t.match(e);if(n){const[r,s,o]=n;return`https://codepen.io/${s}/pen/${o}`}}},{hostnames:["scratch.mit.edu"],fromEmbedUrl:t=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,n=t.match(e);if(n){const[r,s]=n;return`https://scratch.mit.edu/projects/${s}`}}},{hostnames:["*.youtube.com","youtube.com","youtu.be"],fromEmbedUrl:t=>{const e=ge(t);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const r=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(r)return`https://www.youtube.com/watch?v=${r[1]}`}}},{hostnames:["calendar.google.*"],fromEmbedUrl:t=>{const e=ge(t),n=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&n){e.pathname="/calendar/u/0";const r=Array.from(e.searchParams.keys());for(const s of r)e.searchParams.delete(s);return e.searchParams.set("cid",n),e.href}}},{hostnames:["docs.google.*"],fromEmbedUrl:t=>{const e=ge(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const n=Array.from(e.searchParams.keys());for(const r of n)e.searchParams.delete(r);return e.href}}},{hostnames:["gist.github.com"],fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return t.split("/").pop()?t:void 0}},{hostnames:["replit.com"],fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{hostnames:["felt.com"],fromEmbedUrl:t=>{const e=ge(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=ge(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=ge(t);if(e&&e.hostname==="player.vimeo.com"){const n=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(n)return"https://vimeo.com/"+n[1]}}},{hostnames:["excalidraw.com"],fromEmbedUrl:t=>{const e=ge(t);if(e&&e.hash.match(/#room=/))return t}},{hostnames:["observablehq.com"],fromEmbedUrl:t=>{const e=ge(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=ge(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return t.replace("?embed","")}}],FA={w:Pt,h:Pt,url:ye},uh=us("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),NA={sequence:[{id:uh.GenOriginalUrlInEmbed,up:t=>{try{const e=t.url,n=new URL(e).host.replace("www.","");let r;for(const s of eX)if(s.hostnames.includes(n))try{r=s.fromEmbedUrl(e)}catch(o){console.warn(o)}t.tmpOldUrl=t.url,t.url=r??""}catch{t.url="",t.tmpOldUrl=t.url}},down:"retired"},{id:uh.RemoveDoesResize,up:t=>{delete t.doesResize},down:"retired"},{id:uh.RemoveTmpOldUrl,up:t=>{delete t.tmpOldUrl},down:"retired"},{id:uh.RemovePermissionOverrides,up:t=>{delete t.overridePermissions},down:"retired"}]},zA={w:Pt,h:Pt,name:ye},BA={sequence:[]},jp=Qt.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),Op=Qt.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),Jr=Qt.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"]}),UA={geo:Jr,labelColor:ab,color:mr,fill:da,dash:ua,size:$s,font:Ls,align:jp,verticalAlign:Op,url:gr,w:Pt,h:Pt,growY:Ip,text:ye,scale:Pt},Qs=us("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9}),HA={sequence:[{id:Qs.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:Qs.AddLabelColor,up:t=>{t.labelColor="black"},down:"retired"},{id:Qs.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:Qs.AddCheckBox,up:t=>{},down:"retired"},{id:Qs.AddVerticalAlign,up:t=>{t.verticalAlign="middle"},down:"retired"},{id:Qs.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:Qs.AddCloud,up:t=>{},down:"retired"},{id:Qs.MakeUrlsValid,up:t=>{gr.isValid(t.url)||(t.url="")},down:t=>{}},{id:Qs.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},KA={},WA={sequence:[]},GA={color:mr,size:$s,segments:Wt(RA),isComplete:we,isPen:we,scale:Pt},tX=us("highlight",{AddScale:1}),VA={sequence:[{id:tX.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},nX=Pe({topLeft:ca,bottomRight:ca}),YA={w:Pt,h:Pt,playing:we,url:gr,assetId:Dg.nullable(),crop:nX.nullable(),flipX:we,flipY:we},dh=us("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4}),XA={sequence:[{id:dh.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:dh.AddCropProp,up:t=>{t.crop=null},down:t=>{delete t.crop}},{id:dh.MakeUrlsValid,up:t=>{gr.isValid(t.url)||(t.url="")},down:t=>{}},{id:dh.AddFlipProps,up:t=>{t.flipX=!1,t.flipY=!1},down:t=>{delete t.flipX,delete t.flipY}}]},Dp=Qt.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),rX=Pe({id:ye,index:ob,x:pe,y:pe}),qA={color:mr,dash:ua,size:$s,spline:Dp,points:Ep(ye,rX),scale:Pt},kc=us("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),ZA={sequence:[{id:kc.AddSnapHandles,up:t=>{for(const e of Object.values(t.handles))e.canSnap=!0},down:"retired"},{id:kc.RemoveExtraHandleProps,up:t=>{t.handles=w0(Object.values(t.handles).map(e=>[e.index,{x:e.x,y:e.y}]))},down:t=>{const e=Object.entries(t.handles).map(([n,r])=>({index:n,...r})).sort(cn);t.handles=Object.fromEntries(e.map((n,r)=>{const s=r===0?"start":r===e.length-1?"end":`handle:${n.index}`;return[s,{id:s,type:"vertex",canBind:!1,canSnap:!0,index:n.index,x:n.x,y:n.y}]}))}},{id:kc.HandlesToPoints,up:t=>{const e=Object.entries(t.handles).map(([n,{x:r,y:s}])=>({x:r,y:s,index:n})).sort(cn);t.points=e.map(({x:n,y:r})=>({x:n,y:r})),delete t.handles},down:t=>{const e=Fu(t.points.length);t.handles=Object.fromEntries(t.points.map((n,r)=>[e[r],{x:n.x,y:n.y}])),delete t.points}},{id:kc.PointIndexIds,up:t=>{const e=Fu(t.points.length);t.points=Object.fromEntries(t.points.map((n,r)=>{const s=e[r];return[s,{id:s,index:s,x:n.x,y:n.y}]}))},down:t=>{const e=Object.values(t.points).sort(cn);t.points=e.map(({x:n,y:r})=>({x:n,y:r}))}},{id:kc.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}}]},QA={color:mr,labelColor:ab,size:$s,font:Ls,fontSizeAdjustment:Ip,align:jp,verticalAlign:Op,growY:Ip,url:gr,text:ye,scale:Pt},Fo=us("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7,AddLabelColor:8}),JA={sequence:[{id:Fo.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:Fo.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:Fo.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:Fo.AddVerticalAlign,up:t=>{t.verticalAlign="middle"},down:"retired"},{id:Fo.MakeUrlsValid,up:t=>{gr.isValid(t.url)||(t.url="")},down:t=>{}},{id:Fo.AddFontSizeAdjustment,up:t=>{t.fontSizeAdjustment=0},down:t=>{delete t.fontSizeAdjustment}},{id:Fo.AddScale,up:t=>{t.scale=1},down:t=>{delete t.scale}},{id:Fo.AddLabelColor,up:t=>{t.labelColor="black"},down:t=>{delete t.labelColor}}]},Sx=Qt.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),ej={color:mr,size:$s,font:Ls,textAlign:Sx,w:Pt,text:ye,scale:Pt,autoSize:we},Q_=us("text",{RemoveJustify:1,AddTextAlign:2}),tj={sequence:[{id:Q_.RemoveJustify,up:t=>{t.align==="justify"&&(t.align="start")},down:"retired"},{id:Q_.AddTextAlign,up:t=>{t.textAlign=t.align,delete t.align},down:t=>{t.align=t.textAlign,delete t.textAlign}}]},nj={w:Pt,h:Pt,time:pe,playing:we,url:gr,assetId:Dg.nullable()},J_=us("video",{AddUrlProp:1,MakeUrlsValid:2}),rj={sequence:[{id:J_.AddUrlProp,up:t=>{t.url=""},down:"retired"},{id:J_.MakeUrlsValid,up:t=>{gr.isValid(t.url)||(t.url="")},down:t=>{}}]},hh=Zn("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),sX=vl({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:hh.RemoveCodeAndIconShapeTypes,scope:"store",up:t=>{for(const[e,n]of Xn(t))n.typeName==="shape"&&(n.type==="icon"||n.type==="code")&&delete t[e]}},{id:hh.AddInstancePresenceType,scope:"store",up(t){}},{id:hh.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:t=>{for(const[e,n]of Xn(t))n.typeName.match(/^(user|user_presence)$/)&&delete t[e]}},{id:hh.RemoveUserDocument,scope:"store",up:t=>{for(const[e,n]of Xn(t))n.typeName.match("user_document")&&delete t[e]}}]}),oX={arrow:{migrations:EA,props:IA},bookmark:{migrations:DA,props:OA},draw:{migrations:$A,props:LA},embed:{migrations:NA,props:FA},frame:{migrations:BA,props:zA},geo:{migrations:HA,props:UA},group:{migrations:WA,props:KA},highlight:{migrations:VA,props:GA},image:{migrations:XA,props:YA},line:{migrations:ZA,props:qA},note:{migrations:JA,props:QA},text:{migrations:tj,props:ej},video:{migrations:rj,props:nj}},iX={arrow:{migrations:TA,props:kA}};function aX({shapes:t=oX,bindings:e=iX,migrations:n}={}){const r=new Map;for(const a of ut(t))for(const l of wA(a.props??{}).keys()){if(r.has(l.id)&&r.get(l.id)!==l)throw new Error(`Multiple StyleProp instances with the same id: ${l.id}`);r.set(l.id,l)}const s=gY(t),o=hY(e),i=kY(r);return tb.create({asset:Yo,binding:o,camera:Is,document:cb,instance:i,instance_page_state:Qr,page:yr,instance_presence:$Y,pointer:lb,shape:s},{migrations:[sX,QY,SY,NY,TY,AY,IY,LY,DY,pY,WY,VY,XY,...G_("shape",t),...G_("binding",e),...n??[]],onValidationFailure:BY,createIntegrityChecker:HY})}const Bu=[{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:"so",label:"Somali"},{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 lX(){const t=typeof window<"u"?window.navigator.languages??["en"]:["en"];return cX(t)}function cX(t){for(const e of t){const n=uX(e);if(n)return n}return"en"}const eI={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function uX(t){const e=Bu.find(s=>s.locale===t.toLowerCase());if(e)return e.locale;const[n,r]=t.split(/[-_]/).map(s=>s.toLowerCase());if(r){const s=Bu.find(o=>o.locale===n);if(s)return s.locale}return n in eI?eI[n]:null}_i("@tldraw/tlschema","3.7.2","esm");var sj={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 n(){for(var o="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(o=s(o,r(a)))}return o}function r(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var a in o)e.call(o,a)&&o[a]&&(i=s(i,a));return i}function s(o,i){return i?o?o+" "+i:o+i:o}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(sj);var dX=sj.exports;const ce=wi(dX),oj="3.7.2",tI={major:"2024-09-13T14:36:29.063Z",minor:"2025-01-07T15:59:09.453Z",patch:"2025-01-16T12:44:39.524Z"},hX={error:null};class ub extends w.Component{constructor(){super(...arguments);I(this,"state",hX)}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n){var r,s;(s=(r=this.props).onError)==null||s.call(r,n)}render(){const{error:n}=this.state;if(n!==null){const{fallback:r}=this.props;return d.jsx(r,{error:n})}return this.props.children}}function Uu({children:t,fallback:e,...n}){return e===null?t:d.jsx(ub,{fallback:e,...n,children:t})}function db(t,e){return Rg(`${t}_${e}`)}function Jl(t){return Rg(`${w.useId()}${t??""}`)}function rs(t){const e=zn(w.useContext(ij));return Rg(`${e}_${t}`)}function Rg(t){return t.replace(/:/g,"_")}const ij=w.createContext(null);function fX({children:t}){const e=Jl();return d.jsx(ij.Provider,{value:e,children:t})}const hb=w.createContext(null);function z(){const t=ke.useContext(hb);if(!t)throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return t}function Ti(){return ke.useContext(hb)}function fb({editor:t,children:e}){return d.jsx(hb.Provider,{value:t,children:d.jsx(fX,{children:e})})}function pX(){return d.jsx("div",{className:"tl-background"})}function ec(t,e,n,r,s,o){w.useLayoutEffect(()=>{const i=t.current;if(!i||e===void 0)return;let a=`translate(${e}px, ${n}px)`;r!==void 0&&(a+=` scale(${r})`),s!==void 0&&(a+=` rotate(${s}rad)`),o&&(a+=` translate(${o.x}px, ${o.y}px)`),i.style.transform=a})}const Dt={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 x{constructor(e=0,n=0,r=1){this.x=e,this.y=n,this.z=r}get pressure(){return this.z}set(e=this.x,n=this.y,r=this.z){return this.x=e,this.y=n,this.z=r,this}setTo({x:e=0,y:n=0,z:r=1}){return this.x=e,this.y=n,this.z=r,this}rot(e){if(e===0)return this;const{x:n,y:r}=this,s=Math.sin(e),o=Math.cos(e);return this.x=n*o-r*s,this.y=n*s+r*o,this}rotWith(e,n){if(n===0)return this;const r=this.x-e.x,s=this.y-e.y,o=Math.sin(n),i=Math.cos(n);return this.x=e.x+(r*i-s*o),this.y=e.y+(r*o+s*i),this}clone(){const{x:e,y:n,z:r}=this;return new x(e,n,r)}sub(e){return this.x-=e.x,this.y-=e.y,this}subXY(e,n){return this.x-=e,this.y-=n,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,n){return this.x+=e,this.y+=n,this}addScalar(e){return this.x+=e,this.y+=e,this}clamp(e,n){return this.x=Math.max(this.x,e),this.y=Math.max(this.y,e),n!==void 0&&(this.x=Math.min(this.x,n),this.y=Math.min(this.y,n)),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,n){const r=x.Tan(e,this);return this.add(r.mul(n))}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 x.Dpr(this,e)}cpr(e){return x.Cpr(this,e)}len2(){return x.Len2(this)}len(){return x.Len(this)}pry(e){return x.Pry(this,e)}per(){const{x:e,y:n}=this;return this.x=n,this.y=-e,this}uni(){return x.Uni(this)}tan(e){return x.Tan(this,e)}dist(e){return x.Dist(this,e)}distanceToLineSegment(e,n){return x.DistanceToLineSegment(e,n,this)}slope(e){return x.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 x.Angle(this,e)}toAngle(){return x.ToAngle(this)}lrp(e,n){return this.x=this.x+(e.x-this.x)*n,this.y=this.y+(e.y-this.y)*n,this}equals(e){return x.Equals(this,e)}equalsXY(e,n){return x.EqualsXY(this,e,n)}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 x.ToFixed(this)}toString(){return x.ToString(x.ToFixed(this))}toJson(){return x.ToJson(this)}toArray(){return x.ToArray(this)}static Add(e,n){return new x(e.x+n.x,e.y+n.y)}static AddXY(e,n,r){return new x(e.x+n,e.y+r)}static Sub(e,n){return new x(e.x-n.x,e.y-n.y)}static SubXY(e,n,r){return new x(e.x-n,e.y-r)}static AddScalar(e,n){return new x(e.x+n,e.y+n)}static SubScalar(e,n){return new x(e.x-n,e.y-n)}static Div(e,n){return new x(e.x/n,e.y/n)}static Mul(e,n){return new x(e.x*n,e.y*n)}static DivV(e,n){return new x(e.x/n.x,e.y/n.y)}static MulV(e,n){return new x(e.x*n.x,e.y*n.y)}static Neg(e){return new x(-e.x,-e.y)}static Per(e){return new x(e.y,-e.x)}static Abs(e){return new x(Math.abs(e.x),Math.abs(e.y))}static Dist(e,n){return((e.y-n.y)**2+(e.x-n.x)**2)**.5}static DistMin(e,n,r){return(e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y)<r**2}static Dist2(e,n){return(e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y)}static Dpr(e,n){return e.x*n.x+e.y*n.y}static Cross(e,n){return new x(e.y*n.z-e.z*n.y,e.z*n.x-e.x*n.z)}static Cpr(e,n){return e.x*n.y-n.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,n){return x.Dpr(e,n)/x.Len(n)}static Uni(e){return x.Div(e,x.Len(e))}static Tan(e,n){return x.Uni(x.Sub(e,n))}static Min(e,n){return new x(Math.min(e.x,n.x),Math.min(e.y,n.y))}static Max(e,n){return new x(Math.max(e.x,n.x),Math.max(e.y,n.y))}static From({x:e,y:n,z:r=1}){return new x(e,n,r)}static FromArray(e){return new x(e[0],e[1])}static Rot(e,n=0){const r=Math.sin(n),s=Math.cos(n);return new x(e.x*s-e.y*r,e.x*r+e.y*s)}static RotWith(e,n,r){const s=e.x-n.x,o=e.y-n.y,i=Math.sin(r),a=Math.cos(r);return new x(n.x+(s*a-o*i),n.y+(s*i+o*a))}static NearestPointOnLineThroughPoint(e,n,r){return x.Mul(n,x.Sub(r,e).pry(n)).add(e)}static NearestPointOnLineSegment(e,n,r,s=!0){if(x.Equals(e,r)||x.Equals(n,r))return x.From(r);const o=x.Tan(n,e),i=x.Add(e,x.Mul(o,x.Sub(r,e).pry(o)));if(s){if(i.x<Math.min(e.x,n.x))return x.Cast(e.x<n.x?e:n);if(i.x>Math.max(e.x,n.x))return x.Cast(e.x>n.x?e:n);if(i.y<Math.min(e.y,n.y))return x.Cast(e.y<n.y?e:n);if(i.y>Math.max(e.y,n.y))return x.Cast(e.y>n.y?e:n)}return i}static DistanceToLineThroughPoint(e,n,r){return x.Dist(r,x.NearestPointOnLineThroughPoint(e,n,r))}static DistanceToLineSegment(e,n,r,s=!0){return x.Dist(r,x.NearestPointOnLineSegment(e,n,r,s))}static Snap(e,n=1){return new x(Math.round(e.x/n)*n,Math.round(e.y/n)*n)}static Cast(e){return e instanceof x?e:x.From(e)}static Slope(e,n){return e.x===n.y?NaN:(e.y-n.y)/(e.x-n.x)}static IsNaN(e){return isNaN(e.x)||isNaN(e.y)}static Angle(e,n){return Math.atan2(n.y-e.y,n.x-e.x)}static Lrp(e,n,r){return x.Sub(n,e).mul(r).add(e)}static Med(e,n){return new x((e.x+n.x)/2,(e.y+n.y)/2)}static Equals(e,n){return Math.abs(e.x-n.x)<1e-4&&Math.abs(e.y-n.y)<1e-4}static EqualsXY(e,n,r){return e.x===n&&e.y===r}static Clockwise(e,n,r){return(r.x-e.x)*(n.y-e.y)-(n.x-e.x)*(r.y-e.y)<0}static Rescale(e,n){const r=x.Len(e);return new x(n*e.x/r,n*e.y/r)}static ScaleWithOrigin(e,n,r){return x.Sub(e,r).mul(n).add(r)}static ToFixed(e){return new x(io(e.x),io(e.y))}static ToInt(e){return new x(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,n,r){return x.Add(e,x.Tan(n,e).mul(r))}static ToString(e){return`${e.x}, ${e.y}`}static ToAngle(e){let n=Math.atan2(e.y,e.x);return n<0&&(n+=Math.PI*2),n}static FromAngle(e,n=1){return new x(Math.cos(e)*n,Math.sin(e)*n)}static ToArray(e){return[e.x,e.y,e.z]}static ToJson(e){const{x:n,y:r,z:s}=e;return{x:n,y:r,z:s}}static Average(e){const n=e.length,r=new x(0,0);if(n===0)return r;for(let s=0;s<n;s++)r.add(e[s]);return r.div(n)}static Clamp(e,n,r){return r===void 0?new x(Math.min(Math.max(e.x,n)),Math.min(Math.max(e.y,n))):new x(Math.min(Math.max(e.x,n),r),Math.min(Math.max(e.y,n),r))}static PointsBetween(e,n,r=6){const s=[];for(let o=0;o<r;o++){const i=Dt.easeInQuad(o/(r-1)),a=x.Lrp(e,n,i);a.z=Math.min(1,.5+Math.abs(.5-gX(i))*.65),s.push(a)}return s}static SnapToGrid(e,n=8){return new x(Math.round(e.x/n)*n,Math.round(e.y/n)*n)}}const gX=t=>t<.5?2*t*t:-1+(4-2*t)*t;function je(t){return`${N(t.x)},${N(t.y)} `}function Bn(t,e){return`${N((t.x+e.x)/2)},${N((t.y+e.y)/2)} `}const De=Math.PI,Ze=De/2,Fe=De*2,mX=Math.sin;function Bt(t,e,n){return Math.max(e,typeof n<"u"?Math.min(t,n):t)}function fh(t,e=1e10){return t?Math.round(t*e)/e:0}function di(t,e,n=1e-6){return Math.abs(t-e)<=n}function aj(t,e){const n=Math.pow(t-e,2)/Math.pow(t+e,2);return De*(t+e)*(1+3*n/(10+Math.sqrt(4-3*n)))}function ea(t){return t=t%Fe,t<0?t=t+Fe:t===0&&(t=0),t}function ud(t,e){return t=ea(t),e=ea(e),t>e&&(e+=Fe),e-t}function lj(t,e){return Fe-ud(t,e)}function cf(t,e){const n=(e-t)%Fe;return 2*n%Fe-n}function vx(t){return(Fe+t)%Fe}function Rp(t,e){const n=Fe/e;let r=Math.floor((vx(t)+n/2)/n)*n%Fe;return r<De&&(r+=Fe),r>De&&(r-=Fe),r}function cj(t,e){return t===e||di(t%(Math.PI/2)-e%(Math.PI/2),0)}function yX(t){return t*De/180}function SX(t){return t*180/De}function ha(t,e,n){return new x(t.x,t.y).add(x.FromAngle(n,e))}function Hy(t,e,n){const r=t/2,s=e/2,o=[];let i=1/0,a=-1/0,l=1/0,c=-1/0;for(let g=0;g<n;g++){const m=Fe/n,v=-Ze+g*m,y=r+r*Math.cos(v),S=s+s*Math.sin(v);y<i&&(i=y),S<l&&(l=S),y>a&&(a=y),S>c&&(c=S),o.push(new x(y,S))}const u=a-i,h=c-l,f=t-u,p=e-h;if(f!==0||p!==0)for(let g=0;g<o.length;g++){const m=o[g];m.x=(m.x-i)/u*t,m.y=(m.y-l)/h*e}return o}function Tc(t,e,n,r){return t<r&&n<e}function Gr(t,e,n,r){const s=Math.max(t,n),o=Math.min(e,r);return s<=o?[s,o]:null}function nI(t,e,n){return(e.x-t.x)*(n.y-t.y)-(n.x-t.x)*(e.y-t.y)}function hr(t,e){let n=0,r,s;for(let o=0;o<e.length;o++){if(r=e[o],r.x===t.x&&r.y===t.y||(s=e[(o+1)%e.length],x.Dist(t,r)+x.Dist(t,s)===x.Dist(r,s)))return!0;r.y<=t.y?s.y>t.y&&nI(r,s,t)>0&&(n+=1):s.y<=t.y&&nI(r,s,t)<0&&(n-=1)}return n!==0}function N(t){return Math.round(t*1e4)/1e4}function io(t){return Math.round(t*100)/100}const rI=t=>Math.abs(t)<Number.MAX_SAFE_INTEGER;function Xo(t,e,n){return n<0?ud(t,e):lj(t,e)}function xx(t,e,n,r){let s;if(Math.abs(t)>De){s=cf(e,r);const o=cf(r,n);return Math.abs(s)<Math.abs(o)?s/t:(t-o)/t}else{s=cf(e,r);const o=s/t;return Math.sign(s)!==Math.sign(t)?Math.abs(o)>.5?1:0:o}}function vX(t,e,n,r){const s=2*((e-t)%Fe)%Fe-(e-t)%Fe;return r?(Fe-Math.abs(s))*(n?1:-1):s}function pb(t,e,n){const r=-2*(t.x*(e.y-n.y)-t.y*(e.x-n.x)+e.x*n.y-n.x*e.y),s=((t.x*t.x+t.y*t.y)*(n.y-e.y)+(e.x*e.x+e.y*e.y)*(t.y-n.y)+(n.x*n.x+n.y*n.y)*(e.y-t.y))/r,o=((t.x*t.x+t.y*t.y)*(e.x-n.x)+(e.x*e.x+e.y*e.y)*(n.x-t.x)+(n.x*n.x+n.y*n.y)*(t.x-e.x))/r;return!Number.isFinite(s)||!Number.isFinite(o)?null:new x(s,o)}function xX(t,e,n,r,s){if(n===null)return[x.From(t),x.From(e)];const o=[],i=x.Angle(n,t),a=x.Angle(n,e),l=ud(i,a);for(let c=0;c<s;c++){const u=c/(s-1),h=i+l*u,f=ha(n,r,h);o.push(f)}return o}const Ky=({brush:t,color:e,opacity:n,className:r})=>{const s=w.useRef(null);ec(s,t.x,t.y);const o=N(Math.max(1,t.w)),i=N(Math.max(1,t.h));return d.jsx("svg",{className:"tl-overlays__item",ref:s,children:e?d.jsxs("g",{className:"tl-brush",opacity:n,children:[d.jsx("rect",{width:o,height:i,fill:e,opacity:.75}),d.jsx("rect",{width:o,height:i,fill:"none",stroke:e,opacity:.1})]}):d.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:o,height:i})})},Ge={isSafari:!1,isIos:!1,isChromeForIos:!1,isFirefox:!1,isAndroid:!1,isWebview:!1,isDarwin:!1};typeof window<"u"&&"navigator"in window&&(Ge.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Ge.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),Ge.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),Ge.isFirefox=/firefox/i.test(navigator.userAgent),Ge.isAndroid=/android/i.test(navigator.userAgent),Ge.isDarwin=window.navigator.userAgent.toLowerCase().indexOf("mac")>-1);const sI={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.1,.25,.5,1,2,4,8]},Wy={duration:0,easing:Dt.easeInOutCubic},oI={CAMERA_MOVE:-10},wX=["top","right","bottom","left"],iI=0,gb=2,ph=1,aI=5,bX=128;var Gy={};const PX={},uj=Dn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),wt={logPreventDefaults:Dn("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:Dn("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:Dn("logElementRemoves",{defaults:{all:!1}}),debugSvg:Dn("debugSvg",{defaults:{all:!1}}),showFps:Dn("showFps",{defaults:{all:!1}}),measurePerformance:Dn("measurePerformance",{defaults:{all:!1}}),throwToBlob:Dn("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:Dn("reconnectOnPing",{defaults:{all:!1}}),debugCursors:Dn("debugCursors",{defaults:{all:!1}}),forceSrgb:Dn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:Dn("debugGeometry",{defaults:{all:!1}}),hideShapes:Dn("hideShapes",{defaults:{all:!1}}),editOnType:Dn("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const t=Element.prototype.removeChild;As("element removal logging",()=>{wt.logElementRemoves.get()?Element.prototype.removeChild=function(e){return console.warn("[tldraw] removing child:",e),t.call(this,e)}:Element.prototype.removeChild=t})}function Dn(t,{defaults:e,shouldStoreForSession:n=!0}){return CX({name:t,defaults:e,shouldStoreForSession:n})}function CX(t){const e=IX(t),n=t.shouldStoreForSession?_X(t.name):null,r=It(`debug:${t.name}`,n??e);return typeof window<"u"&&(t.shouldStoreForSession&&As(`debug:${t.name}`,()=>{const s=r.get();s===e?eM(`tldraw_debug:${t.name}`):E0(`tldraw_debug:${t.name}`,JSON.stringify(s))}),Object.defineProperty(window,`tldraw${t.name.replace(/^[a-z]/,s=>s.toUpperCase())}`,{get(){return r.get()},set(s){r.set(s)},configurable:!0})),Object.assign(r,t)}function _X(t){try{return JSON.parse(JT(`tldraw_debug:${t}`)??"null")}catch{return null}}function Vy(t){try{return t()}catch{return null}}function IX(t){switch(Vy(()=>Gy.TLDRAW_ENV)??Vy(()=>Gy.VERCEL_PUBLIC_TLDRAW_ENV)??Vy(()=>Gy.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 Lp(t){if(t instanceof HTMLElement)return t;if(t.parentElement)return Lp(t.parentElement);throw Error("Could not find a parent element of an HTML type!")}function xe(t){t.preventDefault(),wt.logPreventDefaults.get()&&console.warn("preventDefault called on event:",t)}function dd(t,e){if(t.setPointerCapture(e.pointerId),wt.logPointerCaptures.get()){const n=uj.get();n.set(t,(n.get(t)??0)+1),console.warn("setPointerCapture called on element:",t,e)}}function hd(t,e){if(t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),wt.logPointerCaptures.get())){const n=uj.get();n.get(t)===1?n.delete(t):n.has(t)?n.set(t,n.get(t)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",t,e)}}const Ct=t=>t.stopPropagation(),rn=(t,e,n)=>{t&&t.style.setProperty(e,n)},un=t=>Ge.isDarwin?t.metaKey:t.ctrlKey||t.metaKey;function lr(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,metaKey:t.metaKey,accelKey:un(t),pointerId:t.pointerId,button:t.button,isPen:t.pointerType==="pen"}}function mb(){const t=z();return w.useMemo(function(){let r,s;function o(m){if(!m.isKilled){if(m.button===gb){t.dispatch({type:"pointer",target:"canvas",name:"right_click",...lr(m)});return}m.button!==0&&m.button!==1&&m.button!==5||(dd(m.currentTarget,m),t.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...lr(m)}))}}function i(m){m.isKilled||m.clientX===r&&m.clientY===s||(r=m.clientX,s=m.clientY,t.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...lr(m)}))}function a(m){m.isKilled||m.button!==0&&m.button!==1&&m.button!==2&&m.button!==5||(r=m.clientX,s=m.clientY,hd(m.currentTarget,m),t.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...lr(m)}))}function l(m){if(m.isKilled||t.getInstanceState().isPenMode&&m.pointerType!=="pen")return;const v=m.pointerType==="mouse"||m.pointerType==="pen";t.updateInstanceState({isHoveringCanvas:v?!0:null})}function c(m){if(m.isKilled||t.getInstanceState().isPenMode&&m.pointerType!=="pen")return;const v=m.pointerType==="mouse"||m.pointerType==="pen";t.updateInstanceState({isHoveringCanvas:v?!1:null})}function u(m){m.isKilled=!0,xe(m)}function h(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"))&&xe(m)}function f(m){xe(m)}async function p(m){var y,S;if(xe(m),Ct(m),!((S=(y=m.dataTransfer)==null?void 0:y.files)!=null&&S.length))return;const v=Array.from(m.dataTransfer.files);await t.putExternalContent({type:"files",files:v,point:t.screenToPage({x:m.clientX,y:m.clientY}),ignoreParent:!1})}function g(m){Ct(m)}return{onPointerDown:o,onPointerMove:i,onPointerUp:a,onPointerEnter:l,onPointerLeave:c,onDragOver:f,onDrop:p,onTouchStart:u,onTouchEnd:h,onClick:g}},[t])}function EX(){const t=z();w.useEffect(()=>{let e=t.getInstanceState().isCoarsePointer;const n=i=>{const a=i.pointerType!=="mouse";e!==a&&(e=a,t.updateInstanceState({isCoarsePointer:a}))};window.addEventListener("pointerdown",n,{capture:!0});const r=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),s=Ge.isFirefox&&!Ge.isAndroid&&!Ge.isIos,o=()=>{const i=s?!1:r.matches;e===i&&(e=i,t.updateInstanceState({isCoarsePointer:i}))};return r&&(r.addEventListener("change",o),o()),()=>{window.removeEventListener("pointerdown",n,{capture:!0}),r&&r.removeEventListener("change",o)}},[t])}const dj=w.createContext(null);function hj({container:t,children:e}){return d.jsx(dj.Provider,{value:t,children:e})}function Tt(){return zn(w.useContext(dj),"useContainer used outside of <Tldraw />")}function kX(){const t=z(),e=Tt(),n=U("isFocused",()=>t.getIsFocused(),[t]);w.useEffect(()=>{if(!e)return;function r(s){if(s.isSpecialRedispatchedEvent)return;xe(s),Ct(s);const o=e.querySelector(".tl-canvas");if(!o)return;const i=new DragEvent(s.type,s);i.isSpecialRedispatchedEvent=!0,o.dispatchEvent(i)}return e.addEventListener("dragover",r),e.addEventListener("drop",r),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",r)}},[e]),w.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;let r=null;const s=()=>{r!=null&&r();const o=`(resolution: ${window.devicePixelRatio}dppx)`,i=matchMedia(o),a=l=>{l.type==="change"&&s()};i.addEventListener?i.addEventListener("change",s):i.addListener&&i.addListener(a),r=()=>{i.removeEventListener?i.removeEventListener("change",s):i.removeListener&&i.removeListener(a)},t.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return s(),()=>{r==null||r()}},[t]),w.useEffect(()=>{if(!n)return;const r=a=>{if(a.altKey&&(t.isIn("zoom")||!t.getPath().endsWith(".idle"))&&!gh(t)&&xe(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){xe(a);return}break}case"Tab":{if(gh(t))return;break}case",":return;case"Escape":{if((t.getEditingShape()||t.getSelectedShapeIds().length>0)&&xe(a),t.menus.getOpenMenus().length>0)return;t.inputs.keys.has("Escape")||(t.inputs.keys.add("Escape"),t.cancel(),e.focus());return}default:if(gh(t))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,metaKey:a.metaKey,accelKey:un(a)};t.dispatch(l)},s=a=>{if(a.isKilled||(a.isKilled=!0,gh(t))||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,metaKey:a.metaKey,accelKey:un(a)};t.dispatch(l)};function o(a){var l,c;if(e.contains(a.target)){const u=a.touches[0].pageX,h=a.touches[0].radiusX||0;(u-h<10||u+h>t.getViewportScreenBounds().width-10)&&(((l=a.target)==null?void 0:l.tagName)==="BUTTON"&&((c=a.target)==null||c.click()),xe(a))}}const i=a=>{e.contains(a.target)&&(a.ctrlKey||a.metaKey)&&xe(a)};return e.addEventListener("touchstart",o,{passive:!1}),e.addEventListener("wheel",i,{passive:!1}),document.addEventListener("gesturestart",xe),document.addEventListener("gesturechange",xe),document.addEventListener("gestureend",xe),e.addEventListener("keydown",r),e.addEventListener("keyup",s),()=>{e.removeEventListener("touchstart",o),e.removeEventListener("wheel",i),document.removeEventListener("gesturestart",xe),document.removeEventListener("gesturechange",xe),document.removeEventListener("gestureend",xe),e.removeEventListener("keydown",r),e.removeEventListener("keyup",s)}},[t,e,n])}const TX=["input","select","button","textarea"];function gh(t){const{activeElement:e}=document;return t.menus.hasOpenMenus()||e&&(e.getAttribute("contenteditable")||TX.indexOf(e.tagName.toLowerCase())>-1)}const MX=["textarea","input"];function AX(t){const e=z();w.useEffect(()=>{const n=t.current;if(!n)return;const r=s=>{var o;if(s instanceof PointerEvent&&s.pointerType==="pen"){s.isKilled=!0;const{target:i}=s;if(MX.includes((o=i.tagName)==null?void 0:o.toLocaleLowerCase())||e.isIn("select.editing_shape"))return;xe(s)}};return n.addEventListener("touchstart",r),n.addEventListener("touchend",r),()=>{n.removeEventListener("touchstart",r),n.removeEventListener("touchend",r)}},[e,t])}function jX(t,e,n){return Math.max(e,Math.min(t,n))}const Vt={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 lI(t,e,n){return e===0||Math.abs(e)===1/0?Math.pow(t,n*5):t*e*n/(e+n*t)}function cI(t,e,n,r=.15){return r===0?jX(t,e,n):t<e?-lI(e-t,n-e,r)+e:t>n?+lI(t-n,n-e,r)+n:t}function OX(t,[e,n],[r,s]){const[[o,i],[a,l]]=t;return[cI(e,o,i,r),cI(n,a,l,s)]}function DX(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function RX(t){var e=DX(t,"string");return typeof e=="symbol"?e:String(e)}function on(t,e,n){return e=RX(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uI(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function ht(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uI(Object(n),!0).forEach(function(r){on(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uI(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const fj={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 dI(t){return t?t[0].toUpperCase()+t.slice(1):""}const LX=["enter","leave"];function $X(t=!1,e){return t&&!LX.includes(e)}function FX(t,e="",n=!1){const r=fj[t],s=r&&r[e]||e;return"on"+dI(t)+dI(s)+($X(n,s)?"Capture":"")}const NX=["gotpointercapture","lostpointercapture"];function zX(t){let e=t.substring(2).toLowerCase();const n=!!~e.indexOf("passive");n&&(e=e.replace("passive",""));const r=NX.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(r);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:n}}function BX(t,e=""){const n=fj[t],r=n&&n[e]||e;return t+r}function pj(t){return"touches"in t}function UX(t){return pj(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function HX(t){return Array.from(t.touches).filter(e=>{var n,r;return e.target===t.currentTarget||((n=t.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,e.target))})}function wx(t,e){try{const n=e.clientX-t.clientX,r=e.clientY-t.clientY,s=(e.clientX+t.clientX)/2,o=(e.clientY+t.clientY)/2,i=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:i,origin:[s,o]}}catch{}return null}function KX(t){return HX(t).map(e=>e.identifier)}function hI(t,e){const[n,r]=Array.from(t.touches).filter(s=>e.includes(s.identifier));return wx(n,r)}const fI=40,pI=800;function gj(t){let{deltaX:e,deltaY:n,deltaMode:r}=t;return r===1?(e*=fI,n*=fI):r===2&&(e*=pI,n*=pI),[e,n]}function WX(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:o})}return e}function $p(t,...e){return typeof t=="function"?t(...e):t}function GX(){}function VX(...t){return t.length===0?GX:t.length===1?t[0]:function(){let e;for(const n of t)e=n.apply(this,arguments)||e;return e}}function gI(t,e){return Object.assign({},e,t||{})}const YX=32;class mj{constructor(e,n,r){this.ctrl=e,this.args=n,this.key=r,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:n,ingKey:r,args:s}=this;n[r]=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=s,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 n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=e.target,n.currentTarget=e.currentTarget,n.lastOffset=r.from?$p(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=e.timeStamp)}computeValues(e){const n=this.state;n._values=e,n.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:n,config:r,shared:s}=this;n.args=this.args;let o=0;if(e&&(n.event=e,r.preventDefault&&e.cancelable&&n.event.preventDefault(),n.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,WX(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-n.timeStamp,n.timeStamp=e.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const _=n._delta.map(Math.abs);Vt.addTo(n._distance,_)}this.axisIntent&&this.axisIntent(e);const[i,a]=n._movement,[l,c]=r.threshold,{_step:u,values:h}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=l&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&h[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=l&&Math.sign(i)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const f=[0,0];if(r.hasCustomTransform){const[_,E]=h;f[0]=u[0]!==!1?_-u[0]:0,f[1]=u[1]!==!1?E-u[1]:0}else f[0]=u[0]!==!1?i-u[0]:0,f[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(f);const p=n.offset,g=n._active&&!n._blocked||n.active;g&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,e&&(n.first&&("bounds"in r&&(n._bounds=$p(r.bounds,n)),this.setup&&this.setup()),n.movement=f,this.computeOffset()));const[m,v]=n.offset,[[y,S],[b,P]]=n._bounds;n.overflow=[m<y?-1:m>S?1:0,v<b?-1:v>P?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const C=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=OX(n._bounds,n.offset,C),n.delta=Vt.sub(n.offset,p),this.computeMovement(),g&&(!n.last||o>YX)){n.delta=Vt.sub(n.offset,p);const _=n.delta.map(Math.abs);Vt.addTo(n.distance,_),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[_[0]/o,_[1]/o],n.timeDelta=o)}}emit(){const e=this.state,n=this.shared,r=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!r.triggerAllEvents)return;const s=this.handler(ht(ht(ht({},n),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function XX([t,e],n){const r=Math.abs(t),s=Math.abs(e);if(r>s&&r>n)return"x";if(s>r&&s>n)return"y"}class qX extends mj{constructor(...e){super(...e),on(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=Vt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Vt.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const n=this.state,r=this.config;if(!n.axis&&e){const s=typeof r.axisThreshold=="object"?r.axisThreshold[UX(e)]:r.axisThreshold;n.axis=XX(n._movement,s)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.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 ZX=t=>t,mI=.15,yj={enabled(t=!0){return t},eventOptions(t,e,n){return ht(ht({},n.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[mI,mI];case!1:return[0,0];default:return Vt.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return Vt.toVector(t)},transform(t,e,n){const r=t||n.shared.transform;return this.hasCustomTransform=!!r,r||ZX},threshold(t){return Vt.toVector(t,0)}},QX=0,fd=ht(ht({},yj),{},{axis(t,e,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(t=QX){return t},bounds(t={}){if(typeof t=="function")return o=>fd.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=t;return[[e,n],[r,s]]}}),pd=typeof window<"u"&&window.document&&window.document.createElement;function Sj(){return pd&&"ontouchstart"in window}function JX(){return Sj()||pd&&window.navigator.maxTouchPoints>1}function eq(){return pd&&"onpointerdown"in window}function tq(){return pd&&"exitPointerLock"in window.document}function nq(){try{return"constructor"in GestureEvent}catch{return!1}}const Mr={isBrowser:pd,gesture:nq(),touch:Sj(),touchscreen:JX(),pointer:eq(),pointerLock:tq()},rq=250,sq=180,oq=.5,iq=50,aq=250,lq=10,yI={mouse:0,touch:0,pen:8};ht(ht({},fd),{},{device(t,e,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&Mr.pointerLock,Mr.touch&&n?"touch":this.pointerLock?"mouse":Mr.pointer&&!s?"pointer":Mr.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&t?rq:void 0,!(!Mr.touchscreen||n===!1))return t||(n!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:n=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&n},threshold(t,e,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const o=Vt.toVector(t,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:t=oq,distance:e=iq,duration:n=aq}={}){return{velocity:this.transform(Vt.toVector(t)),distance:this.transform(Vt.toVector(e)),duration:n}},delay(t=0){switch(t){case!0:return sq;case!1:return 0;default:return t}},axisThreshold(t){return t?ht(ht({},yI),t):yI},keyboardDisplacement(t=lq){return t}});function vj(t){const[e,n]=t.overflow,[r,s]=t._delta,[o,i]=t._direction;(e<0&&r>0&&o<0||e>0&&r<0&&o>0)&&(t._movement[0]=t._movementBound[0]),(n<0&&s>0&&i<0||n>0&&s<0&&i>0)&&(t._movement[1]=t._movementBound[1])}const cq=30,uq=100;class dq extends mj{constructor(...e){super(...e),on(this,"ingKey","pinching"),on(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:n,lastOffset:r}=this.state;e==="wheel"?this.state.offset=Vt.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:e,lastOffset:n}=this.state;this.state.movement=[e[0]/n[0],e[1]-n[1]]}axisIntent(){const e=this.state,[n,r]=e._movement;if(!e.axis){const s=Math.abs(n)*cq-Math.abs(r);s<0?e.axis="angle":s>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 n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(o=>r.has(o))||r.size<2)return;this.start(e),n._touchIds=Array.from(r).slice(0,2);const s=hI(e,n._touchIds);s&&this.pinchStart(e,s)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const n=this.state,r=n._pointerEvents,s=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(i=>s.has(i))||(r.size<2&&r.set(e.pointerId,e),n._pointerEvents.size<2))return;this.start(e);const o=wx(...Array.from(r.values()));o&&this.pinchStart(e,o)}pinchStart(e,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const n=hI(e,this.state._touchIds);n&&this.pinchMove(e,n)}pointerMove(e){const n=this.state._pointerEvents;if(n.has(e.pointerId)&&n.set(e.pointerId,e),!this.state._active)return;const r=wx(...Array.from(n.values()));r&&this.pinchMove(e,r)}pinchMove(e,n){const r=this.state,s=r._values[1],o=n.angle-s;let i=0;Math.abs(o)>270&&(i+=Math.sign(o)),this.computeValues([n.distance,n.angle-360*i]),r.origin=n.origin,r.turns=i,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const n=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}n._pointerEvents.has(e.pointerId)&&n._pointerEvents.delete(e.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const n=this.state;n._active||(this.start(e),this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY];const r=n._movement;n._movement=[e.scale-1,e.rotation],n._delta=Vt.sub(n._movement,r),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>e[r]):!e[n])||(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 r=this.state;r._delta=[-gj(e)[1]/uq*r.offset[0],0],Vt.addTo(r._movement,r._delta),vj(r),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 n=this.config.device;n&&(e(n,"start",this[n+"Start"].bind(this)),e(n,"change",this[n+"Move"].bind(this)),e(n,"end",this[n+"End"].bind(this)),e(n,"cancel",this[n+"End"].bind(this)),e("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const hq=ht(ht({},yj),{},{device(t,e,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!Mr.touch&&Mr.gesture)return"gesture";if(Mr.touch&&r)return"touch";if(Mr.touchscreen){if(Mr.pointer)return"pointer";if(Mr.touch)return"touch"}},bounds(t,e,{scaleBounds:n={},angleBounds:r={}}){const s=i=>{const a=gI($p(n,i),{min:-1/0,max:1/0});return[a.min,a.max]},o=i=>{const a=gI($p(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[s(),o()]:i=>[s(i),o(i)]},threshold(t,e,n){return this.lockDirection=n.axis==="lock",Vt.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});ht(ht({},fd),{},{mouseOnly:(t=!0)=>t});class fq extends qX{constructor(...e){super(...e),on(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 n=this.state;n._delta=gj(e),Vt.addTo(n._movement,n._delta),vj(n),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 pq=fd;ht(ht({},fd),{},{mouseOnly:(t=!0)=>t});const yb=new Map,bx=new Map;function gq(t){yb.set(t.key,t.engine),bx.set(t.key,t.resolver)}const mq={key:"pinch",engine:dq,resolver:hq},yq={key:"wheel",engine:fq,resolver:pq};function Sq(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,o;for(o=0;o<r.length;o++)s=r[o],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function vq(t,e){if(t==null)return{};var n=Sq(t,e),r,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}const xq={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=Mr.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},wq=["target","eventOptions","window","enabled","transform"];function uf(t={},e){const n={};for(const[r,s]of Object.entries(e))switch(typeof s){case"function":n[r]=s.call(n,t[r],r,t);break;case"object":n[r]=uf(t[r],s);break;case"boolean":s&&(n[r]=t[r]);break}return n}function bq(t,e,n={}){const r=t,{target:s,eventOptions:o,window:i,enabled:a,transform:l}=r,c=vq(r,wq);if(n.shared=uf({target:s,eventOptions:o,window:i,enabled:a,transform:l},xq),e){const u=bx.get(e);n[e]=uf(ht({shared:n.shared},c),u)}else for(const u in c){const h=bx.get(u);h&&(n[u]=uf(ht({shared:n.shared},c[u]),h))}return n}class xj{constructor(e,n){on(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=n}add(e,n,r,s,o){const i=this._listeners,a=BX(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=ht(ht({},l),o);e.addEventListener(a,s,c);const u=()=>{e.removeEventListener(a,s,c),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Pq{constructor(){on(this,"_timeouts",new Map)}add(e,n,r=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(n,r,...s))}remove(e){const n=this._timeouts.get(e);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class Cq{constructor(e){on(this,"gestures",new Set),on(this,"_targetEventStore",new xj(this)),on(this,"gestureEventStores",{}),on(this,"gestureTimeoutStores",{}),on(this,"handlers",{}),on(this,"config",{}),on(this,"pointerIds",new Set),on(this,"touchIds",new Set),on(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),_q(this,e)}setEventIds(e){if(pj(e))return this.touchIds=new Set(KX(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,n){this.handlers=e,this.nativeHandlers=n}applyConfig(e,n){this.config=bq(e,n,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 n=this.config.shared,r={};let s;if(!(n.target&&(s=n.target(),!s))){if(n.enabled){for(const i of this.gestures){const a=this.config[i],l=SI(r,a.eventOptions,!!s);if(a.enabled){const c=yb.get(i);new c(this,e,i).bind(l)}}const o=SI(r,n.eventOptions,!!s);for(const i in this.nativeHandlers)o(i,"",a=>this.nativeHandlers[i](ht(ht({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in r)r[o]=VX(...r[o]);if(!s)return r;for(const o in r){const{device:i,capture:a,passive:l}=zX(o);this._targetEventStore.add(s,i,"",r[o],{capture:a,passive:l})}}}}function Da(t,e){t.gestures.add(e),t.gestureEventStores[e]=new xj(t,e),t.gestureTimeoutStores[e]=new Pq}function _q(t,e){e.drag&&Da(t,"drag"),e.wheel&&Da(t,"wheel"),e.scroll&&Da(t,"scroll"),e.move&&Da(t,"move"),e.pinch&&Da(t,"pinch"),e.hover&&Da(t,"hover")}const SI=(t,e,n)=>(r,s,o,i={},a=!1)=>{var l,c;const u=(l=i.capture)!==null&&l!==void 0?l:e.capture,h=(c=i.passive)!==null&&c!==void 0?c:e.passive;let f=a?r:FX(r,s,u);n&&h&&(f+="Passive"),t[f]=t[f]||[],t[f].push(o)},Iq=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Eq(t){const e={},n={},r=new Set;for(let s in t)Iq.test(s)?(r.add(RegExp.lastMatch),n[s]=t[s]):e[s]=t[s];return[n,e,r]}function Ra(t,e,n,r,s,o){if(!t.has(n)||!yb.has(r))return;const i=n+"Start",a=n+"End",l=c=>{let u;return c.first&&i in e&&e[i](c),n in e&&(u=e[n](c)),c.last&&a in e&&e[a](c),u};s[r]=l,o[r]=o[r]||{}}function kq(t,e){const[n,r,s]=Eq(t),o={};return Ra(s,n,"onDrag","drag",o,e),Ra(s,n,"onWheel","wheel",o,e),Ra(s,n,"onScroll","scroll",o,e),Ra(s,n,"onPinch","pinch",o,e),Ra(s,n,"onMove","move",o,e),Ra(s,n,"onHover","hover",o,e),{handlers:o,config:e,nativeHandlers:r}}function Tq(t,e={},n,r){const s=ke.useMemo(()=>new Cq(t),[]);if(s.applyHandlers(t,r),s.applyConfig(e,n),ke.useEffect(s.effect.bind(s)),ke.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function Mq(t){return t.forEach(gq),function(n,r){const{handlers:s,nativeHandlers:o,config:i}=kq(n,r||{});return Tq(s,i,void 0,o)}}const vI=10,Aq=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function wj(t){let{deltaY:e,deltaX:n}=t,r=0;return t.ctrlKey||t.altKey||t.metaKey?r=(Math.abs(e)>vI?vI*Math.sign(e):e)/100:t.shiftKey&&!Aq&&(n=e,e=0),{x:-n,y:-e,z:-r}}const jq=Mq([yq,mq]);let La;const Oq=t=>La===void 0?(La=t,!1):t-La>120&&t-La<160?(La=t,!0):(La=t,!1);function Dq(t){const e=z(),n=w.useMemo(()=>{let r="not sure";const s=({event:m})=>{if(!e.getInstanceState().isFocused||(r="not sure",Oq(Date.now())))return;const v=e.getEditingShapeId();if(v){const b=e.getShape(v);if(b&&e.getShapeUtil(b).canScroll(b)){const C=e.getShapePageBounds(v);if(C!=null&&C.containsPoint(e.inputs.currentPagePoint))return}}xe(m),Ct(m);const y=wj(m);if(y.x===0&&y.y===0)return;const S={type:"wheel",name:"wheel",delta:y,point:new x(m.clientX,m.clientY),shiftKey:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey,metaKey:m.metaKey,accelKey:un(m)};e.dispatch(S)};let o=1,i=1,a=1,l=0;const c=new x,u=new x,h=m=>{const v=t.current;r="not sure";const{event:y,origin:S,da:b}=m;y instanceof WheelEvent||(y.target===v||v!=null&&v.contains(y.target))&&(u.x=S[0],u.y=S[1],c.x=S[0],c.y=S[1],o=b[0],i=e.getZoomLevel(),e.dispatch({type:"pinch",name:"pinch_start",point:{x:S[0],y:S[1],z:e.getZoomLevel()},delta:{x:0,y:0},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey,metaKey:y.metaKey,accelKey:un(y)}))},f=m=>{if(m&&(r="zooming"),r==="zooming")return;const v=Math.abs(l-o),y=x.Dist(c,u);switch(r){case"not sure":{v>24?r="zooming":y>16&&(r="panning");break}case"panning":{v>64&&(r="zooming");break}}};return{onWheel:s,onPinchStart:h,onPinchEnd:m=>{const v=t.current,{event:y,origin:S,offset:b}=m;if(y instanceof WheelEvent||!(y.target===v||v!=null&&v.contains(y.target)))return;const P=b[0];r="not sure",e.timers.requestAnimationFrame(()=>{e.dispatch({type:"pinch",name:"pinch_end",point:{x:S[0],y:S[1],z:P},delta:{x:S[0],y:S[1]},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey,metaKey:y.metaKey,accelKey:un(y)})})},onPinch:m=>{const v=t.current,{event:y,origin:S,offset:b,da:P}=m;if(y instanceof WheelEvent||!(y.target===v||v!=null&&v.contains(y.target)))return;const C=m.type==="gesturechange"||m.type==="gestureend";l=P[0];const _=S[0]-u.x,E=S[1]-u.y;switch(u.x=S[0],u.y=S[1],f(C),r){case"zooming":{a=b[0],e.dispatch({type:"pinch",name:"pinch",point:{x:S[0],y:S[1],z:a},delta:{x:_,y:E},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey,metaKey:y.metaKey,accelKey:un(y)});break}case"panning":{e.dispatch({type:"pinch",name:"pinch",point:{x:S[0],y:S[1],z:i},delta:{x:_,y:E},shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey,metaKey:y.metaKey,accelKey:un(y)});break}}}}},[e,t]);jq(n,{target:t,eventOptions:{passive:!1},pinch:{from:()=>[e.getZoomLevel(),0],scaleBounds:()=>{const r=e.getBaseZoom(),s=e.getCameraOptions().zoomSteps,o=s[0]*r,i=s[s.length-1]*r;return{from:e.getZoomLevel(),max:i,min:o}}}})}function Yy(t,e,n){const r=t.getShape(e),s=t.getShapeHandles(r);return{shape:r,handle:s.find(o=>o.id===n)}}function Rq(t,e){const n=z();return w.useMemo(()=>{const r=l=>{if(l.isKilled)return;const c=Lp(l.currentTarget);dd(c,l);const{shape:u,handle:h}=Yy(n,t,e);h&&n.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_down",...lr(l)})};let s,o;return{onPointerDown:r,onPointerMove:l=>{if(l.isKilled||l.clientX===s&&l.clientY===o)return;s=l.clientX,o=l.clientY;const{shape:c,handle:u}=Yy(n,t,e);u&&n.dispatch({type:"pointer",target:"handle",handle:u,shape:c,name:"pointer_move",...lr(l)})},onPointerUp:l=>{if(l.isKilled)return;const c=Lp(l.currentTarget);hd(c,l);const{shape:u,handle:h}=Yy(n,t,e);h&&n.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_up",...lr(l)})}}},[n,t,e])}function Lq(t){const e=z();w.useLayoutEffect(()=>{const n=TT(()=>{t.current&&e.updateViewportScreenBounds(t.current)},200,{trailing:!0}),r=e.timers.setInterval(n,1e3);window.addEventListener("resize",n);const s=new ResizeObserver(a=>{a[0].contentRect&&n()}),o=t.current;let i=null;return o&&(s.observe(o),i=$q(o),i.addEventListener("scroll",n)),()=>{clearInterval(r),window.removeEventListener("resize",n),s.disconnect(),i==null||i.removeEventListener("scroll",n),n.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 $q=t=>{let e=t.parentElement;for(;e;){if(e===document.body)return document;const{overflowY:n}=window.getComputedStyle(e);if(e.scrollHeight>e.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return e;e=e.parentElement}return document};class Z{constructor(e=0,n=0,r=0,s=0){I(this,"x",0);I(this,"y",0);I(this,"w",0);I(this,"h",0);this.x=e,this.y=n,this.w=r,this.h=s}get point(){return new x(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 x(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 x(this.minX,this.minY),new x(this.maxX,this.minY),new x(this.maxX,this.maxY),new x(this.minX,this.maxY)]}get cornersAndCenter(){return[new x(this.minX,this.minY),new x(this.maxX,this.minY),new x(this.maxX,this.maxY),new x(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 x(this.w,this.h)}toFixed(){return this.x=fh(this.x),this.y=fh(this.y),this.w=fh(this.w),this.h=fh(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,n=0,r=0,s=0){return this.x=e,this.y=n,this.w=r,this.h=s,this}expand(e){const n=Math.min(this.minX,e.minX),r=Math.min(this.minY,e.minY),s=Math.max(this.maxX,e.maxX),o=Math.max(this.maxY,e.maxY);return this.x=n,this.y=r,this.w=s-n,this.h=o-r,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:n,w:r,h:s}=this;return new Z(e,n,r,s)}translate(e){return this.x+=e.x,this.y+=e.y,this}snapToGrid(e){const n=Math.round(this.minX/e)*e,r=Math.round(this.minY/e)*e,s=Math.round(this.maxX/e)*e,o=Math.round(this.maxY/e)*e;this.minX=n,this.minY=r,this.width=Math.max(1,s-n),this.height=Math.max(1,o-r)}collides(e){return Z.Collides(this,e)}contains(e){return Z.Contains(this,e)}includes(e){return Z.Includes(this,e)}containsPoint(e,n=0){return Z.ContainsPoint(this,e,n)}getHandlePoint(e){switch(e){case"top_left":return new x(this.minX,this.minY);case"top_right":return new x(this.maxX,this.minY);case"bottom_left":return new x(this.minX,this.maxY);case"bottom_right":return new x(this.maxX,this.maxY);case"top":return new x(this.midX,this.minY);case"right":return new x(this.maxX,this.midY);case"bottom":return new x(this.midX,this.maxY);case"left":return new x(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(e,n,r){const{minX:s,minY:o,maxX:i,maxY:a}=this;let{minX:l,minY:c,maxX:u,maxY:h}=this;switch(e){case"left":case"top_left":case"bottom_left":{l+=n;break}case"right":case"top_right":case"bottom_right":{u+=n;break}}switch(e){case"top":case"top_left":case"top_right":{c+=r;break}case"bottom":case"bottom_left":case"bottom_right":{h+=r;break}}const f=(u-l)/(i-s),p=(h-c)/(a-o),g=f<0,m=p<0;if(g){const v=u;u=l,l=v}if(m){const v=h;h=c,c=v}this.minX=l,this.minY=c,this.width=Math.abs(u-l),this.height=Math.abs(h-c)}union(e){const n=Math.min(this.minX,e.x),r=Math.min(this.minY,e.y),s=Math.max(this.maxX,e.w+e.x),o=Math.max(this.maxY,e.h+e.y);return this.x=n,this.y=r,this.width=s-n,this.height=o-r,this}static From(e){return new Z(e.x,e.y,e.w,e.h)}static FromCenter(e,n){return new Z(e.x-n.x/2,e.y-n.y/2,n.x,n.y)}static FromPoints(e){if(e.length===0)return new Z;let n=1/0,r=1/0,s=-1/0,o=-1/0,i;for(let a=0,l=e.length;a<l;a++)i=e[a],n=Math.min(i.x,n),r=Math.min(i.y,r),s=Math.max(i.x,s),o=Math.max(i.y,o);return new Z(n,r,s-n,o-r)}static Expand(e,n){const r=Math.min(n.minX,e.minX),s=Math.min(n.minY,e.minY),o=Math.max(n.maxX,e.maxX),i=Math.max(n.maxY,e.maxY);return new Z(r,s,o-r,i-s)}static ExpandBy(e,n){return new Z(e.minX-n,e.minY-n,e.width+n*2,e.height+n*2)}static Collides(e,n){return!(e.maxX<n.minX||e.minX>n.maxX||e.maxY<n.minY||e.minY>n.maxY)}static Contains(e,n){return e.minX<n.minX&&e.minY<n.minY&&e.maxY>n.maxY&&e.maxX>n.maxX}static Includes(e,n){return Z.Collides(e,n)||Z.Contains(e,n)}static ContainsPoint(e,n,r=0){return!(n.x<e.minX-r||n.y<e.minY-r||n.x>e.maxX+r||n.y>e.maxY+r)}static Common(e){let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let i=0;i<e.length;i++){const a=e[i];n=Math.min(n,a.minX),r=Math.min(r,a.minY),s=Math.max(s,a.maxX),o=Math.max(o,a.maxY)}return new Z(n,r,s-n,o-r)}static Sides(e,n=0){const{corners:r}=e;return[[r[0],r[1]],[r[1],r[2]],[r[2],r[3]],[r[3],r[0]]]}static Resize(e,n,r,s,o=!1){const{minX:i,minY:a,maxX:l,maxY:c}=e;let{minX:u,minY:h,maxX:f,maxY:p}=e;switch(n){case"left":case"top_left":case"bottom_left":{u+=r;break}case"right":case"top_right":case"bottom_right":{f+=r;break}}switch(n){case"top":case"top_left":case"top_right":{h+=s;break}case"bottom":case"bottom_left":case"bottom_right":{p+=s;break}}const g=(f-u)/(l-i),m=(p-h)/(c-a),v=g<0,y=m<0;if(o){const b=(l-i)/(c-a),P=Math.abs(f-u),C=Math.abs(p-h),_=P*(m<0?1:-1)*(1/b),E=C*(g<0?1:-1)*b,k=b<P/C;switch(n){case"top_left":{k?h=p+_:u=f+E;break}case"top_right":{k?h=p+_:f=u-E;break}case"bottom_right":{k?p=h-_:f=u-E;break}case"bottom_left":{k?p=h-_:u=f+E;break}case"bottom":case"top":{const D=(u+f)/2,T=C*b;u=D-T/2,f=D+T/2;break}case"left":case"right":{const D=(h+p)/2,T=P/b;h=D-T/2,p=D+T/2;break}}}if(v){const b=f;f=u,u=b}if(y){const b=p;p=h,h=b}const S=new Z(u,h,Math.abs(f-u),Math.abs(p-h));return{box:S,scaleX:+(S.width/e.width*(g>0?1:-1)).toFixed(5),scaleY:+(S.height/e.height*(m>0?1:-1)).toFixed(5)}}equals(e){return Z.Equals(this,e)}static Equals(e,n){return n.x===e.x&&n.y===e.y&&n.w===e.w&&n.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 Z(e.x,e.y,Math.max(1,e.w),Math.max(1,e.h))}}function Fq(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 Nq(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 zq(t){return t==="top_left"||t==="top_right"||t==="bottom_right"||t==="bottom_left"}class q{constructor(e,n,r,s,o,i){I(this,"a",1);I(this,"b",0);I(this,"c",0);I(this,"d",1);I(this,"e",0);I(this,"f",0);this.a=e,this.b=n,this.c=r,this.d=s,this.e=o,this.f=i}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 n=e,{a:r,b:s,c:o,d:i,e:a,f:l}=this;return this.a=r*n.a+o*n.b,this.c=r*n.c+o*n.d,this.e=r*n.e+o*n.f+a,this.b=s*n.a+i*n.b,this.d=s*n.c+i*n.d,this.f=s*n.e+i*n.f+l,this}rotate(e,n,r){return e===0?this:n===void 0?this.multiply(q.Rotate(e)):this.translate(n,r).multiply(q.Rotate(e)).translate(-n,-r)}translate(e,n){return this.multiply(q.Translate(e,n))}scale(e,n){return this.multiply(q.Scale(e,n))}invert(){const{a:e,b:n,c:r,d:s,e:o,f:i}=this,a=e*s-n*r;return this.a=s/a,this.b=n/-a,this.c=r/-a,this.d=e/a,this.e=(s*o-r*i)/-a,this.f=(n*o-e*i)/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,n){return new q(1,0,0,1,e,n)}static Rotate(e,n,r){if(e===0)return q.Identity();const s=Math.cos(e),o=Math.sin(e),i=new q(s,o,-o,s,0,0);return n===void 0?i:q.Compose(q.Translate(n,r),i,q.Translate(-n,-r))}static Scale(e,n,r,s){const o=new q(e,0,0,n,0,0);return r===void 0?o:q.Compose(q.Translate(r,s),o,q.Translate(-r,-s))}static Multiply(e,n){return{a:e.a*n.a+e.c*n.b,c:e.a*n.c+e.c*n.d,e:e.a*n.e+e.c*n.f+e.e,b:e.b*n.a+e.d*n.b,d:e.b*n.c+e.d*n.d,f:e.b*n.e+e.d*n.f+e.f}}static Inverse(e){const n=e.a*e.d-e.b*e.c;return{a:e.d/n,b:e.b/-n,c:e.c/-n,d:e.a/n,e:(e.d*e.e-e.c*e.f)/-n,f:(e.b*e.e-e.a*e.f)/n}}static Absolute(e){const n=e.a*e.d-e.b*e.c;return{a:e.d/n,b:e.b/-n,c:e.c/-n,d:e.a/n,e:(e.d*e.e-e.c*e.f)/n,f:(e.b*e.e-e.a*e.f)/-n}}static Compose(...e){const n=q.Identity();for(let r=0,s=e.length;r<s;r++)n.multiply(e[r]);return n}static Point(e){return new x(e.e,e.f)}static Rotation(e){let n;if(e.a!==0||e.c!==0){const r=(e.a*e.a+e.c*e.c)**.5;n=Math.acos(e.a/r)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const r=(e.b*e.b+e.d*e.d)**.5;n=Ze+Math.acos(e.b/r)*(e.d>0?-1:1)}else n=0;return vx(n)}static Decompose(e){let n,r,s;if(e.a!==0||e.c!==0){const o=(e.a*e.a+e.c*e.c)**.5;n=o,r=(e.a*e.d-e.b*e.c)/o,s=Math.acos(e.a/o)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const o=(e.b*e.b+e.d*e.d)**.5;n=(e.a*e.d-e.b*e.c)/o,r=o,s=Ze+Math.acos(e.b/o)*(e.d>0?-1:1)}else n=0,r=0,s=0;return{x:e.e,y:e.f,scaleX:n,scaleY:r,rotation:vx(s)}}static Smooth(e,n=1e10){return e.a=Math.round(e.a*n)/n,e.b=Math.round(e.b*n)/n,e.c=Math.round(e.c*n)/n,e.d=Math.round(e.d*n)/n,e.e=Math.round(e.e*n)/n,e.f=Math.round(e.f*n)/n,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,n){return new x(e.a*n.x+e.c*n.y+e.e,e.b*n.x+e.d*n.y+e.f,n.z)}static applyToXY(e,n,r){return[e.a*n+e.c*r+e.e,e.b*n+e.d*r+e.f]}static applyToPoints(e,n){return n.map(r=>new x(e.a*r.x+e.c*r.y+e.e,e.b*r.x+e.d*r.y+e.f,r.z))}static applyToBounds(e,n){return new Z(e.e+n.minX,e.f+n.minY,n.width,n.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 Mi{constructor(e){I(this,"isFilled",!1);I(this,"isClosed",!0);I(this,"isLabel",!1);I(this,"debugColor");I(this,"ignore");I(this,"_vertices");I(this,"_bounds");I(this,"_area");I(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,n=0,r=!1){return this.isClosed&&(this.isFilled||r)&&hr(e,this.vertices)?!0:x.Dist2(e,this.nearestPoint(e))<=n*n}distanceToPoint(e,n=!1){return e.dist(this.nearestPoint(e))*(this.isClosed&&(this.isFilled||n)&&hr(e,this.vertices)?-1:1)}distanceToLineSegment(e,n){if(e.equals(n))return this.distanceToPoint(e);const{vertices:r}=this;let s,o=1/0,i,a,l;for(let c=0;c<r.length;c++)a=r[c],l=x.NearestPointOnLineSegment(e,n,a,!0),i=x.Dist2(a,l),i<o&&(o=i,s=l);if(!s)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&hr(s,this.vertices)?-o:o}hitTestLineSegment(e,n,r=0){return this.distanceToLineSegment(e,n)<=r}nearestPointOnLineSegment(e,n){const{vertices:r}=this;let s,o=1/0,i,a,l;for(let c=0;c<r.length;c++)a=r[c],l=x.NearestPointOnLineSegment(e,n,a,!0),i=x.Dist2(a,l),i<o&&(o=i,s=l);if(!s)throw Error("nearest point not found");return s}isPointInBounds(e,n=0){const{bounds:r}=this;return!(e.x<r.minX-n||e.y<r.minY-n||e.x>r.maxX+n||e.y>r.maxY+n)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return Z.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 n=0;for(let r=0,s=e.length;r<s;r++){const o=e[r],i=e[(r+1)%s];n+=o.x*i.y-i.x*o.y}return n/2}toSimpleSvgPath(){let e="";const{vertices:n}=this,r=n.length;if(r===0)return e;e+=`M${n[0].x},${n[0].y}`;for(let s=1;s<r;s++)e+=`L${n[s].x},${n[s].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 n,r=e[0],s=0;for(let o=1;o<e.length;o++)n=e[o],s+=x.Dist2(r,n),r=n;return Math.sqrt(s)}}class $r extends Mi{constructor(n){super({...n,isClosed:!0,isFilled:!1});I(this,"children",[]);I(this,"ignoredChildren",[]);for(const r of n.children)r.ignore?this.ignoredChildren.push(r):this.children.push(r);if(this.children.length===0)throw Error("Group2d must have at least one child")}getVertices(){return this.children.filter(n=>!n.isLabel).flatMap(n=>n.vertices)}nearestPoint(n){let r=1/0,s;const{children:o}=this;if(o.length===0)throw Error("no children");let i,a;for(const l of o)i=l.nearestPoint(n),a=x.Dist2(i,n),a<r&&(r=a,s=i);if(!s)throw Error("nearest point not found");return s}distanceToPoint(n,r=!1){return Math.min(...this.children.map((s,o)=>s.distanceToPoint(n,r||o>0)))}hitTestPoint(n,r,s){return!!this.children.filter(o=>!o.isLabel).find(o=>o.hitTestPoint(n,r,s))}hitTestLineSegment(n,r,s){return!!this.children.filter(o=>!o.isLabel).find(o=>o.hitTestLineSegment(n,r,s))}getArea(){return this.children[0].area}toSimpleSvgPath(){let n="";for(const s of this.children)n+=s.toSimpleSvgPath();const r=Z.FromPoints(this.vertices).corners;for(let s=0,o=r.length;s<o;s++){const i=r[s],a=r[(s-1+o)%o],l=i.dist(a),c=r[(s+1)%o],u=i.dist(c),h=i.clone().lrp(a,4/l),f=i,p=i.clone().lrp(c,4/u);n+=`M${h.x},${h.y} L${f.x},${f.y} L${p.x},${p.y} `}return n}getLength(){return this.children.reduce((n,r)=>r.isLabel?n:n+r.length,0)}getSvgPathData(){return this.children.map((n,r)=>n.isLabel?"":n.getSvgPathData(r===0)).join(" ")}}function Bq(t=!0){const[e,n]=w.useState(0),r=z();w.useEffect(()=>{if(!t)return;const s=()=>n(o=>o+1);return r.on("tick",s),()=>{r.off("tick",s)}},[r,t])}const Uq=Zt(function({showStroke:e=!0,showVertices:n=!0,showClosestPointOnOutline:r=!0}){const s=z();Bq(r);const o=s.getZoomLevel(),i=s.getRenderingShapes(),{inputs:{currentPagePoint:a}}=s;return d.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:i.map(l=>{const c=s.getShape(l.id);if(c.type==="group")return null;const u=s.getShapeGeometry(c),h=s.getShapePageTransform(c),f=s.getPointInShapeSpace(c,a),p=u.nearestPoint(f),g=u.distanceToPoint(f,!0),m=Math.abs(g)*o,v=g<0,{vertices:y}=u;return d.jsxs("g",{transform:h.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[e&&d.jsx("g",{stroke:u.debugColor??"red",opacity:"1",strokeWidth:2/o,fill:"none",children:d.jsx(bj,{geometry:u})}),n&&y.map((S,b)=>d.jsx("circle",{cx:S.x,cy:S.y,r:2/o,fill:`hsl(${Ol(b,[0,y.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:1/o},`v${b}`)),r&&m<150&&d.jsx("line",{x1:p.x,y1:p.y,x2:f.x,y2:f.y,opacity:1-m/150,stroke:v?"goldenrod":"dodgerblue",strokeWidth:2/o})]},l.id+"_outline")})})});function bj({geometry:t}){return t instanceof $r?d.jsx(d.Fragment,{children:[...t.children,...t.ignoredChildren].map((e,n)=>d.jsx(bj,{geometry:e},n))}):d.jsx("path",{d:t.toSimpleSvgPath()})}function Pj(t){return k9(t)}function Cj(){const t=z(),e=EV("userIds",()=>Pj(t.getCollaborators().map(n=>n.userId)).sort(),{isEqual:(n,r)=>{var s;return n.join(",")===((s=r.join)==null?void 0:s.call(r,","))}},[t]);return U(e)}function Lg(t){const e=z();return U(`latestPresence:${t}`,()=>e.getCollaborators().find(r=>r.userId===t),[e,t])??null}const Hq=Zt(function(){return Cj().map(n=>d.jsx(Kq,{collaboratorId:n},n))}),Kq=Zt(function({collaboratorId:e}){const n=z(),r=Lg(e),s=Gq(n,r);if(!(r&&r.currentPageId===n.getCurrentPageId()))return null;switch(s){case"inactive":{const{followingUserId:o,highlightedUserIds:i}=n.getInstanceState();if(!(o===r.userId||i.includes(r.userId)))return null;break}case"idle":{const{highlightedUserIds:o}=n.getInstanceState();if(r.followingUserId===n.user.getId()&&!(r.chatMessage||o.includes(r.userId)))return null;break}}return d.jsx(Wq,{latestPresence:r})}),Wq=Zt(function({latestPresence:e}){const n=z(),{CollaboratorBrush:r,CollaboratorScribble:s,CollaboratorCursor:o,CollaboratorHint:i,CollaboratorShapeIndicator:a}=st(),l=n.getZoomLevel(),c=n.getViewportPageBounds(),{userId:u,chatMessage:h,brush:f,scribbles:p,selectedShapeIds:g,userName:m,cursor:v,color:y}=e;if(!v)return null;const S=!(v.x<c.minX-12/l||v.y<c.minY-16/l||v.x>c.maxX-12/l||v.y>c.maxY-16/l);return d.jsxs(d.Fragment,{children:[f&&r?d.jsx(r,{className:"tl-collaborator__brush",brush:f,color:y,opacity:.1},u+"_brush"):null,S&&o?d.jsx(o,{className:"tl-collaborator__cursor",point:v,color:y,zoom:l,name:m!=="New User"?m:null,chatMessage:h??""},u+"_cursor"):i?d.jsx(i,{className:"tl-collaborator__cursor-hint",point:v,color:y,zoom:l,viewport:c},u+"_cursor_hint"):null,s&&p.length?d.jsx(d.Fragment,{children:p.map(b=>d.jsx(s,{className:"tl-collaborator__scribble",scribble:b,color:y,zoom:l,opacity:b.color==="laser"?.5:.1},u+"_scribble_"+b.id))}):null,a&&g.filter(b=>!n.isShapeHidden(b)).map(b=>d.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:b,color:y,opacity:.5},u+"_"+b))]})});function xI(t,e){return e>t.options.collaboratorInactiveTimeoutMs?"inactive":e>t.options.collaboratorIdleTimeoutMs?"idle":"active"}function Gq(t,e){const n=w.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[r,s]=w.useState(()=>xI(t,Date.now()-n.current));return w.useEffect(()=>{const o=t.timers.setInterval(()=>{s(xI(t,Date.now()-n.current))},t.options.collaboratorCheckIntervalMs);return()=>clearInterval(o)},[t]),e&&(n.current=e.lastActivityTimestamp??1/0),r}function Vq(){const t=z(),e=U("is menu open",()=>t.menus.hasAnyOpenMenus(),[t]),[n,r]=w.useState(!1),s=e||n,o=mb(),i=w.useRef({isDown:!1,isDragging:!1,start:new x}),a=w.useCallback(u=>{u.button===0&&(r(!0),i.current={isDown:!0,isDragging:!1,start:new x(u.clientX,u.clientY)}),t.menus.clearOpenMenus()},[t]),l=w.useCallback(u=>{var h,f,p;if(i.current.isDown){if(i.current.isDragging){(h=o.onPointerMove)==null||h.call(o,u);return}if(x.Dist2(i.current.start,new x(u.clientX,u.clientY))>t.options.dragDistanceSquared){i.current={...i.current,isDown:!0,isDragging:!0};const{x:g,y:m}=i.current.start;(f=o.onPointerDown)==null||f.call(o,{...u,clientX:g,clientY:m,button:0}),(p=o.onPointerMove)==null||p.call(o,u)}}},[o,t]),c=w.useCallback(u=>{var h;(h=o.onPointerUp)==null||h.call(o,u),r(!1),i.current={isDown:!1,isDragging:!1,start:new x(u.clientX,u.clientY)}},[o]);return s&&d.jsx("div",{className:"tlui-menu-click-capture","data-testid":"menu-click-capture.content",...o,onPointerDown:a,onPointerMove:l,onPointerUp:c})}const _j=w.memo(function({id:e,shape:n,util:r,index:s,backgroundIndex:o,opacity:i}){const a=z(),{ShapeErrorFallback:l}=st(),c=w.useRef(null),u=w.useRef(null),h=w.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});ui("set shape stuff",()=>{const g=a.getShape(e);if(!g)return;const m=h.current,v=a.getShapeClipPath(e)??"none";v!==m.clipPath&&(rn(c.current,"clip-path",v),rn(u.current,"clip-path",v),m.clipPath=v);const y=a.getShapePageTransform(e),S=q.toCssString(y),b=a.getShapeGeometry(g).bounds;S!==m.transform&&(rn(c.current,"transform",S),rn(u.current,"transform",S),m.transform=S);const P=Math.max(b.width,1),C=Math.max(b.height,1);(P!==m.width||C!==m.height)&&(rn(c.current,"width",P+"px"),rn(c.current,"height",C+"px"),rn(u.current,"width",P+"px"),rn(u.current,"height",C+"px"),m.width=P,m.height=C)},[a]),ui("set opacity and z-index",()=>{const g=c.current,m=u.current;rn(g,"opacity",i),rn(m,"opacity",i),rn(g,"z-index",s),rn(m,"z-index",o)},[i,s,o]),ui("set display",()=>{if(!a.getShape(e))return;const v=a.getCulledShapes().has(e);v!==h.current.isCulled&&(rn(c.current,"display",v?"none":"block"),rn(u.current,"display",v?"none":"block"),h.current.isCulled=v)},[a]);const f=w.useCallback(g=>a.annotateError(g,{origin:"shape",willCrashApp:!1}),[a]);if(!n)return null;const p="fill"in n.props&&n.props.fill!=="none";return d.jsxs(d.Fragment,{children:[r.backgroundComponent&&d.jsx("div",{ref:u,className:"tl-shape tl-shape-background","data-shape-type":n.type,"data-shape-id":n.id,draggable:!1,children:d.jsx(Uu,{fallback:l,onError:f,children:d.jsx(Ej,{shape:n,util:r})})}),d.jsx("div",{ref:c,className:"tl-shape","data-shape-type":n.type,"data-shape-is-filled":p,"data-shape-id":n.id,draggable:!1,children:d.jsx(Uu,{fallback:l,onError:f,children:d.jsx(Ij,{shape:n,util:r})})})]})}),Ij=w.memo(function({shape:e,util:n}){return Tg("InnerShape:"+e.type,()=>n.component(n.editor.store.unsafeGetWithoutCapture(e.id)),[n,e.id])},(t,e)=>t.shape.props===e.shape.props&&t.shape.meta===e.shape.meta&&t.util===e.util),Ej=w.memo(function({shape:e,util:n}){return Tg("InnerShape:"+e.type,()=>{var r;return(r=n.backgroundComponent)==null?void 0:r.call(n,n.editor.store.unsafeGetWithoutCapture(e.id))},[n,e.id])},(t,e)=>t.shape.props===e.shape.props&&t.shape.meta===e.shape.meta&&t.util===e.util);function Yq({className:t}){const e=z(),{Background:n,SvgDefs:r,ShapeIndicators:s}=st(),o=w.useRef(null),i=w.useRef(null),a=w.useRef(null),l=Tt();Lq(o),kX(),EX(),Dq(o),AX(o);const c=w.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});ui("position layers",function(){const{x:S,y:b,z:P}=e.getCamera();if(c.current.allowTextOutline&&Ge.isSafari&&(l.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&P<e.options.textShadowLod!==c.current.lodDisableTextOutline){const E=P<e.options.textShadowLod;l.style.setProperty("--tl-text-outline",E?"none":"var(--tl-text-outline-reference)"),c.current.lodDisableTextOutline=E}const C=P>=1?Ol(P,[1,8],[.125,.5],!0):Ol(P,[.1,1],[-2,.125],!0),_=`scale(${N(P)}) translate(${N(S+C)}px,${N(b+C)}px)`;rn(i.current,"transform",_),rn(a.current,"transform",_)},[e,l]);const u=mb(),h=U("shapeSvgDefs",()=>{const y=new Map;for(const S of ut(e.shapeUtils)){if(!S)return;const b=S.getCanvasSvgDefs();for(const{key:P,component:C}of b)y.has(P)||y.set(P,d.jsx(C,{},P))}return[...y.values()]},[e]),f=U("debug_shapes",()=>wt.hideShapes.get(),[wt]),p=U("debug_svg",()=>wt.debugSvg.get(),[wt]),g=U("debug_geometry",()=>wt.debugGeometry.get(),[wt]),m=U("isEditingAnything",()=>e.getEditingShapeId()!==null,[e]),v=U("isSelectingAnything",()=>!!e.getSelectedShapeIds().length,[e]);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:o,draggable:!1,"data-iseditinganything":m,"data-isselectinganything":v,className:ce("tl-canvas",t),"data-testid":"canvas",...u,children:[d.jsx("svg",{className:"tl-svg-context",children:d.jsxs("defs",{children:[h,d.jsx(lZ,{}),d.jsx(cZ,{}),r&&d.jsx(r,{})]})}),n&&d.jsx("div",{className:"tl-background__wrapper",children:d.jsx(n,{})}),d.jsx(qq,{}),d.jsxs("div",{ref:i,className:"tl-html-layer tl-shapes",draggable:!1,children:[d.jsx(fZ,{}),d.jsx(hZ,{}),f?null:p?d.jsx(sZ,{}):d.jsx(iZ,{})]}),d.jsx("div",{className:"tl-overlays",children:d.jsxs("div",{ref:a,className:"tl-html-layer",children:[g?d.jsx(Uq,{}):null,d.jsx(tZ,{}),d.jsx(Qq,{}),d.jsx(Zq,{}),d.jsx(Jq,{}),s&&d.jsx(s,{}),d.jsx(aZ,{}),d.jsx(eZ,{}),d.jsx(dZ,{}),d.jsx(Hq,{})]})}),d.jsx(pZ,{})]}),d.jsx(Vq,{}),d.jsx(Xq,{})]})}function Xq(){const{InFrontOfTheCanvas:t}=st();return t?d.jsx(t,{}):null}function qq(){const t=z(),e=U("gridSize",()=>t.getDocumentSettings().gridSize,[t]),{x:n,y:r,z:s}=U("camera",()=>t.getCamera(),[t]),o=U("isGridMode",()=>t.getInstanceState().isGridMode,[t]),{Grid:i}=st();return i&&o?d.jsx(i,{x:n,y:r,z:s,size:e}):null}function Zq(){const t=z(),e=U("scribbles",()=>t.getInstanceState().scribbles,[t]),n=U("zoomLevel",()=>t.getZoomLevel(),[t]),{Scribble:r}=st();return r&&e.length?e.map(s=>d.jsx(r,{className:"tl-user-scribble",scribble:s,zoom:n},s.id)):null}function Qq(){const t=z(),e=U("brush",()=>t.getInstanceState().brush,[t]),{Brush:n}=st();return n&&e?d.jsx(n,{className:"tl-user-brush",brush:e}):null}function Jq(){const t=z(),e=U("zoomBrush",()=>t.getInstanceState().zoomBrush,[t]),{ZoomBrush:n}=st();return n&&e?d.jsx(n,{className:"tl-user-brush tl-zoom-brush",brush:e}):null}function eZ(){const t=z(),e=U("snapLines",()=>t.snaps.getIndicators(),[t]),n=U("zoomLevel",()=>t.getZoomLevel(),[t]),{SnapIndicator:r}=st();return r&&e.length>0?e.map(s=>d.jsx(r,{className:"tl-user-snapline",line:s,zoom:n},s.id)):null}function tZ(){const t=z(),e=U("handles shapeIdWithHandles",()=>{const{isReadonly:n,isChangingStyle:r}=t.getInstanceState();if(n||r)return!1;const s=t.getOnlySelectedShape();return!s||!t.getShapeHandles(s)?!1:s.id},[t]);return e?d.jsx(nZ,{shapeId:e}):null}function nZ({shapeId:t}){const e=z(),{Handles:n}=st(),r=U("zoomLevel",()=>e.getZoomLevel(),[e]),s=U("coarse pointer",()=>e.getInstanceState().isCoarsePointer,[e]),o=U("handles transform",()=>e.getShapePageTransform(t),[e,t]),i=U("handles",()=>{const l=e.getShapeHandles(t);if(!l)return null;const c=(s?e.options.coarseHandleRadius:e.options.handleRadius)/r*2;return l.filter(u=>u.type!=="virtual"||!l.some(h=>h!==u&&h.type==="vertex"&&x.Dist(u,h)<c)).sort(u=>u.type==="vertex"?1:-1)},[e,r,s,t]),a=U("isHidden",()=>e.isShapeHidden(t),[e,t]);return!n||!i||!o||a?null:d.jsx(n,{children:d.jsx("g",{transform:q.toCssString(o),children:i.map(l=>d.jsx(rZ,{shapeId:t,handle:l,zoom:r,isCoarse:s},l.id))})})}function rZ({shapeId:t,handle:e,zoom:n,isCoarse:r}){const s=Rq(t,e.id),{Handle:o}=st();return o?d.jsx("g",{"aria-label":"handle",transform:`translate(${e.x}, ${e.y})`,...s,children:d.jsx(o,{shapeId:t,handle:e,zoom:n,isCoarse:r})}):null}function sZ(){const t=z();return U("rendering shapes",()=>t.getRenderingShapes(),[t]).map(n=>d.jsxs(w.Fragment,{children:[d.jsx(_j,{...n}),d.jsx(uZ,{id:n.id,mode:"iframe"})]},n.id+"_fragment"))}function oZ(){const t=z(),e=w.useRef(new Set);return ui("reflow for culled shapes",()=>{const n=t.getCulledShapes();if(e.current.size===n.size&&[...n].every(s=>e.current.has(s)))return;e.current=n;const r=document.getElementsByClassName("tl-canvas");r.length!==0&&r[0].offsetHeight},[t]),null}function iZ(){const t=z(),e=U("rendering shapes",()=>t.getRenderingShapes(),[t]);return d.jsxs(d.Fragment,{children:[e.map(n=>d.jsx(_j,{...n},n.id+"_shape")),Ge.isSafari&&d.jsx(oZ,{})]})}function aZ(){const t=z(),{ShapeIndicator:e}=st(),n=U("hinting shape ids",()=>S0(t.getHintingShapeIds()),[t]);return!n.length||!e?null:n.map(r=>d.jsx(e,{className:"tl-user-indicator__hint",shapeId:r},r+"_hinting"))}function lZ(){return d.jsxs("g",{id:rs("cursor"),children:[d.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[d.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),d.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),d.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[d.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),d.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),d.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[d.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),d.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function cZ(){const t=rs("cursor_hint");return d.jsx("path",{id:t,fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function uZ({id:t,mode:e}){const n=z(),[r,s]=w.useState(null),o=U("is in root",()=>{const i=n.getShape(t);return(i==null?void 0:i.parentId)===n.getCurrentPageId()},[n,t]);return w.useEffect(()=>{if(!o)return;let i=null;const a=As("shape to svg",async()=>{const l=Math.random();i=l;const u=n.isShapeOfType(t,"frame")?0:10;let h=n.getShapePageBounds(t);if(!h)return;h=h.clone().expandBy(u);const f=await n.getSvgString([t],{padding:u,background:n.getInstanceState().exportBackground});if(i!==l||!f)return;const p=`data:image/svg+xml;utf8,${encodeURIComponent(f.svg)}`;s({src:p,bounds:h})});return()=>{i=null,a()}},[n,t,o]),!o||!r?null:e==="iframe"?d.jsx("iframe",{src:r.src,width:r.bounds.width,height:r.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,border:"none",transform:`translate(${r.bounds.x}px, ${r.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}}):d.jsx("img",{src:r.src,width:r.bounds.width,height:r.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,transform:`translate(${r.bounds.x}px, ${r.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}})}function dZ(){const t=z(),e=U("selection rotation",()=>t.getSelectionRotation(),[t]),n=U("selection bounds",()=>t.getSelectionRotatedPageBounds(),[t]),{SelectionForeground:r}=st();return!n||!r?null:d.jsx(r,{bounds:n,rotation:e})}function hZ(){const t=z(),e=U("selection rotation",()=>t.getSelectionRotation(),[t]),n=U("selection bounds",()=>t.getSelectionRotatedPageBounds(),[t]),{SelectionBackground:r}=st();return!n||!r?null:d.jsx(r,{bounds:n,rotation:e})}function fZ(){const{OnTheCanvas:t}=st();return t?d.jsx(t,{}):null}function pZ(){const t=z(),e=U("camera state",()=>t.getCameraState(),[t]);return d.jsx("div",{className:ce("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":e==="idle"})})}function gZ({className:t,zoom:e,point:n,color:r,viewport:s,opacity:o=1}){const i=w.useRef(null);ec(i,Bt(n.x,s.minX+5/e,s.maxX-5/e),Bt(n.y,s.minY+5/e,s.maxY-5/e),1/e,x.Angle(s.center,n));const a=rs("cursor_hint");return d.jsxs("svg",{ref:i,className:ce("tl-overlays__item",t),children:[d.jsx("use",{href:`#${a}`,color:r,strokeWidth:3,stroke:"var(--color-background)"}),d.jsx("use",{href:`#${a}`,color:r,opacity:o})]})}const wI=w.memo(function({className:e,zoom:n,point:r,color:s,name:o,chatMessage:i}){const a=w.useRef(null);ec(a,r==null?void 0:r.x,r==null?void 0:r.y,1/n);const l=rs("cursor");return r?d.jsxs("div",{ref:a,className:ce("tl-overlays__item",e),children:[d.jsx("svg",{className:"tl-cursor",children:d.jsx("use",{href:`#${l}`,color:s})}),i?d.jsxs(d.Fragment,{children:[o&&d.jsx("div",{className:"tl-nametag-title",style:{color:s},children:o}),d.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:s},children:i})]}):o&&d.jsx("div",{className:"tl-nametag",style:{backgroundColor:s},children:o})]}):null});function mZ({x:t,y:e,z:n,size:r}){const s=Jl("grid"),o=z(),{gridSteps:i}=o.options;return d.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:i.map(({min:a,mid:l,step:c},u)=>{const h=c*r*n,f=.5+t*n,p=.5+e*n,g=f>0?f%h:h+f%h,m=p>0?p%h:h+p%h,v=n<l?Ol(n,[a,l],[0,1]):1;return d.jsx("pattern",{id:db(s,`${c}`),width:h,height:h,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{className:"tl-grid-dot",cx:g,cy:m,r:1,opacity:v})},u)})}),i.map(({step:a},l)=>d.jsx("rect",{width:"100%",height:"100%",fill:`url(#${s}_${a})`},l))]})}function yZ({handle:t,isCoarse:e,className:n,zoom:r}){const s=z(),o=(e?s.options.coarseHandleRadius:s.options.handleRadius)/r;if(t.type==="clone"){const a=3/r,l=`M0,${-a} A${a},${a} 0 0,1 0,${a}`,c=wX.indexOf(t.id);return d.jsxs("g",{className:ce(`tl-handle tl-handle__${t.type}`,n),children:[d.jsx("circle",{className:"tl-handle__bg",r:o}),d.jsx("path",{className:"tl-handle__fg",d:l,transform:`rotate(${-90+90*c})`})]})}const i=(t.type==="create"&&e?3:4)/Math.max(r,.25);return d.jsxs("g",{className:ce(`tl-handle tl-handle__${t.type}`,n),children:[d.jsx("circle",{className:"tl-handle__bg",r:o}),d.jsx("circle",{className:"tl-handle__fg",r:i})]})}const SZ=({children:t})=>d.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:t}),vZ=()=>{const{Spinner:t}=st();return d.jsx(Db,{children:t?d.jsx(t,{}):null})};function Sb(t,e=!0){const n=t.length;if(n<2)return"";let r=t[0],s=t[1];if(n===2)return`M${je(r)}L${je(s)}`;let o="";for(let i=2,a=n-1;i<a;i++)r=t[i],s=t[i+1],o+=Bn(r,s);return e?`M${Bn(t[0],t[1])}Q${je(t[1])}${Bn(t[1],t[2])}T${o}${Bn(t[n-1],t[0])}${Bn(t[0],t[1])}Z`:`M${je(t[0])}Q${je(t[1])}${Bn(t[1],t[2])}${t.length>3?"T":""}${o}L${je(t[n-1])}`}function bI({scribble:t,zoom:e,color:n,opacity:r,className:s}){return t.points.length?d.jsx("svg",{className:s&&ce("tl-overlays__item",s),children:d.jsx("path",{className:"tl-scribble",d:Sb(t.points,!1),stroke:n??`var(--color-${t.color})`,fill:"none",strokeWidth:8/e,opacity:r??t.opacity})}):null}function kj({bounds:t,rotation:e}){const n=w.useRef(null);return ec(n,t.x,t.y,1,e),w.useLayoutEffect(()=>{const r=n.current;r&&(r.style.width=N(Math.max(1,t.width))+"px",r.style.height=N(Math.max(1,t.height))+"px")},[t.width,t.height]),d.jsx("div",{ref:n,className:"tl-selection__bg",draggable:!1})}function xZ({bounds:t,rotation:e}){const n=z(),r=w.useRef(null),s=U("only selected shape",()=>n.getOnlySelectedShape(),[n]),o=s?n.getShapeUtil(s).expandSelectionOutlinePx(s):0;return ec(r,t==null?void 0:t.x,t==null?void 0:t.y,1,e,{x:-o,y:-o}),t=o instanceof Z?t.clone().expand(o).zeroFix():t.clone().expandBy(o).zeroFix(),d.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:d.jsx("rect",{className:ce("tl-selection__fg__outline"),width:N(t.width),height:N(t.height)})})}const wZ=()=>d.jsx("div",{className:"tl-shape-error-boundary"}),bZ=({shape:t,util:e})=>Tg("Indicator: "+t.type,()=>e.indicator(e.editor.store.unsafeGetWithoutCapture(t.id))),PZ=({editor:t,id:e})=>{const n=U("shape for indicator",()=>t.store.get(e),[t,e]),{ShapeIndicatorErrorFallback:r}=st();return!n||n.isLocked?null:d.jsx(Uu,{fallback:r,onError:s=>t.annotateError(s,{origin:"react.shapeIndicator",willCrashApp:!1}),children:d.jsx(bZ,{shape:n,util:t.getShapeUtil(n)},n.id)})},PI=w.memo(function({shapeId:e,className:n,color:r,hidden:s,opacity:o}){const i=z(),a=w.useRef(null);return ui("indicator transform",()=>{const l=a.current;if(!l)return;const c=i.getShapePageTransform(e);c&&l.style.setProperty("transform",c.toCssString())},[i,e]),w.useLayoutEffect(()=>{const l=a.current;l&&l.style.setProperty("display",s?"none":"block")},[s]),d.jsx("svg",{ref:a,className:ce("tl-overlays__item",n),children:d.jsx("g",{className:"tl-shape-indicator",stroke:r??"var(--color-selected)",opacity:o,children:d.jsx(PZ,{editor:i,id:e})})})}),CZ=()=>d.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"}),Tj=w.memo(function(){const e=z(),n=w.useRef(new Set),r=U("should display selected ids",()=>{const i=n.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(i.size!==a.size)return n.current=a,a;for(const l of a)if(!i.has(l))return n.current=a,a;return i},[e]),s=U("rendering shapes",()=>e.getRenderingShapes(),[e]),{ShapeIndicator:o}=st();return o?s.map(({id:i})=>d.jsx(o,{shapeId:i,hidden:!r.has(i)},i+"_indicator")):null});function _Z({points:t,zoom:e}){const n=2.5/e,r=t.reduce((f,p)=>Math.min(f,p.x),1/0),s=t.reduce((f,p)=>Math.max(f,p.x),-1/0),o=t.reduce((f,p)=>Math.min(f,p.y),1/0),i=t.reduce((f,p)=>Math.max(f,p.y),-1/0),a=t.some(f=>f.x===r&&f.y===o);let l,c,u,h;return a?(l=r,c=o,u=s,h=i):(l=r,c=i,u=s,h=o),d.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[d.jsx("line",{x1:l,y1:c,x2:u,y2:h}),t.map((f,p)=>d.jsx("g",{transform:`translate(${f.x},${f.y})`,children:d.jsx("path",{className:"tl-snap-point",d:`M ${-n},${-n} L ${n},${n} M ${-n},${n} L ${n},${-n}`})},p))]})}function IZ({gaps:t,direction:e,zoom:n}){const r=3.5/n;let s=[-1/0,1/0],o=null;const i=e==="horizontal";for(const l of t){if(o=Gr(s[0],s[1],i?l.startEdge[0].y:l.startEdge[0].x,i?l.startEdge[1].y:l.startEdge[1].x),o)s=o;else continue;if(o=Gr(s[0],s[1],i?l.endEdge[0].y:l.endEdge[0].x,i?l.endEdge[1].y:l.endEdge[1].x),o)s=o;else continue}if(s===null)return null;const a=(s[0]+s[1])/2;return d.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:t.map(({startEdge:l,endEdge:c},u)=>d.jsx(w.Fragment,{children:i?d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),d.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),d.jsx("line",{x1:l[0].x,y1:a,x2:c[0].x,y2:a}),d.jsx("line",{x1:(l[0].x+c[0].x)/2,y1:a-r,x2:(l[0].x+c[0].x)/2,y2:a+r})]}):d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),d.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),d.jsx("line",{x1:a,y1:l[0].y,x2:a,y2:c[0].y}),d.jsx("line",{x1:a-r,y1:(l[0].y+c[0].y)/2,x2:a+r,y2:(l[0].y+c[0].y)/2})]})},u))})}function EZ({className:t,line:e,zoom:n}){return d.jsx("svg",{className:ce("tl-overlays__item",t),children:e.type==="points"?d.jsx(_Z,{...e,zoom:n}):e.type==="gaps"?d.jsx(IZ,{...e,zoom:n}):null})}function vb(){return d.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:d.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[d.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),d.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:d.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const kZ=()=>null;function Mj(t,e){const n=w.useRef(t);return e(t,n.current)?n.current:(n.current=t,t)}const TZ=(t,e)=>(t??(t=null),e??(e=null),t===e?!0:!t||!e?!1:LT(t,e));function qo(t){return Mj(t,TZ)}const MZ=(t,e)=>(t??(t=null),e??(e=null),t===e?!0:!t||!e?!1:zT(t,e));function tc(t){return Mj(t,MZ)}const Aj=w.createContext(null);function AZ({overrides:t={},children:e}){const n=tc(t),r=w.useMemo(()=>({Background:pX,SvgDefs:kZ,Brush:Ky,ZoomBrush:Ky,CollaboratorBrush:Ky,Cursor:wI,CollaboratorCursor:wI,CollaboratorHint:gZ,CollaboratorShapeIndicator:PI,Grid:mZ,Scribble:bI,SnapIndicator:EZ,Handles:SZ,Handle:yZ,CollaboratorScribble:bI,ErrorFallback:Oj,ShapeErrorFallback:wZ,ShapeIndicatorErrorFallback:CZ,Spinner:vb,SelectionBackground:kj,SelectionForeground:xZ,ShapeIndicators:Tj,ShapeIndicator:PI,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:Yq,LoadingScreen:vZ,...n}),[n]);return d.jsx(Aj.Provider,{value:r,children:e})}function st(){const t=w.useContext(Aj);if(!t)throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return t}const $g={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 jj(){$g.hardReset()}function jZ(){$g.refreshPage()}const OZ="https://github.com/tldraw/tldraw/issues/new",Oj=({error:t,editor:e})=>{const n=w.useRef(null),[r,s]=w.useState(!1),[o,i]=w.useState(!1),[a,l]=w.useState(!1);let c=null;try{c=st().Canvas??null}catch{}const u=t instanceof Error?t.message:String(t),h=t instanceof Error?t.stack:null,f=U("isDarkMode",()=>{try{if(e)return e.user.getIsDarkMode()}catch{}return null},[e]),[p,g]=w.useState(null);w.useLayoutEffect(()=>{var C;f!==null&&g(f);let b=(C=n.current)==null?void 0:C.parentElement,P=!1;for(;b;){if(b.classList.contains("tl-theme__dark")||b.classList.contains("tl-theme__light")){P=!0;break}b=b.parentElement}if(P){g(null);return}typeof window<"u"&&"matchMedia"in window&&g(window.matchMedia("(prefers-color-scheme: dark)").matches)},[f]),w.useEffect(()=>{if(o){const b=e==null?void 0:e.timers.setTimeout(()=>{i(!1)},2e3);return()=>clearTimeout(b)}},[o,e]);const m=()=>{const b=document.createElement("textarea");b.value=h??u,document.body.appendChild(b),b.select(),document.execCommand("copy"),b.remove(),i(!0)},v=()=>{jZ()},y=async()=>{jj()},S=new URL(OZ);return S.searchParams.set("title",u),S.searchParams.set("labels","bug"),S.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
93
|
-
|
|
94
|
-
\`\`\`js
|
|
95
|
-
${h??u}
|
|
96
|
-
\`\`\`
|
|
97
|
-
|
|
98
|
-
My browser: ${navigator.userAgent}`),d.jsxs("div",{ref:n,className:ce("tl-container tl-error-boundary",p===null?"":p?"tl-theme__dark":"tl-theme__light"),children:[d.jsx("div",{className:"tl-error-boundary__overlay"}),e&&d.jsx(ub,{onError:Ru,fallback:()=>null,children:d.jsx(fb,{editor:e,children:d.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:c?d.jsx(c,{}):null})})}),d.jsx("div",{className:ce("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Are you sure?"}),d.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),d.jsxs("div",{className:"tl-error-boundary__content__actions",children:[d.jsx("button",{onClick:()=>l(!1),children:"Cancel"}),d.jsx("button",{className:"tl-error-boundary__reset",onClick:y,children:"Reset data"})]})]}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Something went wrong"}),d.jsx("p",{children:"Please refresh the page to continue."}),d.jsxs("p",{children:["If you keep seeing this screen, you can create a"," ",d.jsx("a",{href:S.toString(),children:"GitHub issue"})," or ask for help on"," ",d.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"Discord"}),". If you are still stuck, you can reset the tldraw data on your machine. This may erase the project you were working on, so try to get help first."]}),r&&d.jsxs(d.Fragment,{children:["Message:",d.jsx("h4",{children:d.jsx("code",{children:u})}),"Stack trace:",d.jsxs("div",{className:"tl-error-boundary__content__error",children:[d.jsx("pre",{children:d.jsx("code",{children:h??u})}),d.jsx("button",{onClick:m,children:o?"Copied!":"Copy"})]})]}),d.jsxs("div",{className:"tl-error-boundary__content__actions",children:[d.jsx("button",{onClick:()=>s(!r),children:r?"Hide details":"Show details"}),d.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[d.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>l(!0),children:"Reset data"}),d.jsx("button",{className:"tl-error-boundary__refresh",onClick:v,children:"Refresh Page"})]})]})]})})]})},Dj="TLDRAW_USER_DATA_v3",Rj=Pe({id:ye,name:ye.nullable().optional(),color:ye.nullable().optional(),locale:ye.nullable().optional(),animationSpeed:pe.nullable().optional(),edgeScrollSpeed:pe.nullable().optional(),colorScheme:Og("light","dark","system").optional(),isSnapMode:we.nullable().optional(),isWrapMode:we.nullable().optional(),isDynamicSizeMode:we.nullable().optional(),isPasteAtCursorMode:we.nullable().optional()}),eo={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8},xb=Math.max(...Object.values(eo));function DZ(t){t.version<eo.AddAnimationSpeed&&(t.user.animationSpeed=1),t.version<eo.AddIsSnapMode&&(t.user.isSnapMode=!1),t.version<eo.MakeFieldsNullable,t.version<eo.AddEdgeScrollSpeed&&(t.user.edgeScrollSpeed=1),t.version<eo.AddExcalidrawSelectMode&&(t.user.isWrapMode=!1),t.version<eo.AllowSystemColorScheme&&(t.user.isDarkMode===!0?t.user.colorScheme="dark":t.user.isDarkMode===!1&&(t.user.colorScheme="light"),delete t.user.isDarkMode),t.version<eo.AddDynamicSizeMode&&(t.user.isDynamicSizeMode=!1),t.version<eo.AddPasteAtCursor&&(t.user.isPasteAtCursorMode=!1),t.version=xb}const Px=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function Lj(){return Px[Math.floor(Math.random()*Px.length)]}function RZ(){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 vs=Object.freeze({name:"New User",locale:lX(),color:Lj(),edgeScrollSpeed:1,animationSpeed:RZ()?0:1,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,colorScheme:"light"});function Xy(){return{id:ze(),color:Lj()}}function $j(t){if(t===null||typeof t!="object"||!("version"in t)||!("user"in t)||typeof t.version!="number")return Xy();const e=nt(t);DZ(e);try{return Rj.validate(e.user)}catch{return Xy()}}function LZ(){const t=JSON.parse(_0(Dj)||"null")??null;return $j(t)}const Fg=It("globalUserData",null);function $Z(){I0(Dj,JSON.stringify({version:xb,user:Fg.get()}))}function Fj(t){Rj.validate(t),Fg.set(t),$Z(),NZ()}const FZ=typeof process<"u"&&!1,xl=typeof BroadcastChannel<"u"&&!FZ?new BroadcastChannel("tldraw-user-sync"):null;xl==null||xl.addEventListener("message",t=>{const e=t.data;(e==null?void 0:e.type)===zj&&(e==null?void 0:e.origin)!==Nj()&&Fg.set($j(e.data))});let qy=null;function Nj(){return qy===null&&(qy=ze()),qy}const zj="tldraw-user-preferences-change";function NZ(){xl==null||xl.postMessage({type:zj,origin:Nj(),data:{user:Bj(),version:xb}})}function Bj(){let t=Fg.get();return t||(t=LZ(),Fj(t)),t}const zZ=G("defaultLocalStorageUserPrefs",()=>Bj());function Uj(t={}){return{userPreferences:t.userPreferences??zZ,setUserPreferences:t.setUserPreferences??Fj}}var Hj={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function o(l,c,u,h,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,h||l,f),g=n?n+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 i(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)e.call(u,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=n?n+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,p=h.length,g=new Array(p);f<p;f++)g[f]=h[f].fn;return g},a.prototype.listenerCount=function(c){var u=n?n+c:c,h=this._events[u];return h?h.fn?1:h.length:0},a.prototype.emit=function(c,u,h,f,p,g){var m=n?n+c:c;if(!this._events[m])return!1;var v=this._events[m],y=arguments.length,S,b;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),y){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,u),!0;case 3:return v.fn.call(v.context,u,h),!0;case 4:return v.fn.call(v.context,u,h,f),!0;case 5:return v.fn.call(v.context,u,h,f,p),!0;case 6:return v.fn.call(v.context,u,h,f,p,g),!0}for(b=1,S=new Array(y-1);b<y;b++)S[b-1]=arguments[b];v.fn.apply(v.context,S)}else{var P=v.length,C;for(b=0;b<P;b++)switch(v[b].once&&this.removeListener(c,v[b].fn,void 0,!0),y){case 1:v[b].fn.call(v[b].context);break;case 2:v[b].fn.call(v[b].context,u);break;case 3:v[b].fn.call(v[b].context,u,h);break;case 4:v[b].fn.call(v[b].context,u,h,f);break;default:if(!S)for(C=1,S=new Array(y-1);C<y;C++)S[C-1]=arguments[C];v[b].fn.apply(v[b].context,S)}}return!0},a.prototype.on=function(c,u,h){return o(this,c,u,h,!1)},a.prototype.once=function(c,u,h){return o(this,c,u,h,!0)},a.prototype.removeListener=function(c,u,h,f){var p=n?n+c:c;if(!this._events[p])return this;if(!u)return i(this,p),this;var g=this._events[p];if(g.fn)g.fn===u&&(!f||g.once)&&(!h||g.context===h)&&i(this,p);else{for(var m=0,v=[],y=g.length;m<y;m++)(g[m].fn!==u||f&&!g[m].once||h&&g[m].context!==h)&&v.push(g[m]);v.length?this._events[p]=v.length===1?v[0]:v:i(this,p)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&i(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Hj);var BZ=Hj.exports;const UZ=wi(BZ),wl="TLDRAW_TAB_ID_v2",go=globalThis.window;function HZ(){return go?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(go.navigator.platform)||Ge.isDarwin&&"ontouchend"in document:!1}const Fp=go?go[wl]??JT(wl)??"TLDRAW_INSTANCE_STATE_V1_"+ze():"<error>";go&&(go[wl]=Fp,HZ()?E0(wl,Fp):eM(wl));go==null||go.addEventListener("beforeunload",()=>{E0(wl,Fp)});const Kj={Initial:0},Ng=Math.max(...Object.values(Kj));function KZ(t){t.version<Kj.Initial,t.version=Ng}const Wj=Pe({version:pe,currentPageId:zu.optional(),isFocusMode:we.optional(),exportBackground:we.optional(),isDebugMode:we.optional(),isToolLocked:we.optional(),isGridMode:we.optional(),pageStates:Wt(Pe({pageId:zu,camera:Pe({x:pe,y:pe,z:pe}).optional(),selectedShapeIds:Wt(Ir).optional(),focusedGroupId:Ir.nullable().optional()})).optional()});function WZ(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!==Ng&&(t=nt(t),KZ(t));try{return Wj.validate(t)}catch(e){return console.warn(e),null}}function wb(t){const e=t.query.ids("page");return G("sessionStateSnapshot",()=>{const n=t.get(bn);if(!n)return null;const r=[...e.get()];return{version:Ng,currentPageId:n.currentPageId,exportBackground:n.exportBackground,isFocusMode:n.isFocusMode,isDebugMode:n.isDebugMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,pageStates:r.map(s=>{const o=t.get(Qr.createId(s)),i=t.get(Is.createId(s));return{pageId:s,camera:{x:(i==null?void 0:i.x)??0,y:(i==null?void 0:i.y)??0,z:(i==null?void 0:i.z)??1},selectedShapeIds:(o==null?void 0:o.selectedShapeIds)??[],focusedGroupId:(o==null?void 0:o.focusedGroupId)??null}})}},{isEqual:mA})}function Cx(t,e,n){const r=WZ(e);if(!r)return;const s=jA(t.get(bn)),o=n!=null&&n.forceOverwrite?r:s,i=n!=null&&n.forceOverwrite?s:r,a=t.schema.types.instance.create({id:bn,...s,currentPageId:r.currentPageId,isDebugMode:(o==null?void 0:o.isDebugMode)??(i==null?void 0:i.isDebugMode),isFocusMode:(o==null?void 0:o.isFocusMode)??(i==null?void 0:i.isFocusMode),isToolLocked:(o==null?void 0:o.isToolLocked)??(i==null?void 0:i.isToolLocked),isGridMode:(o==null?void 0:o.isGridMode)??(i==null?void 0:i.isGridMode),exportBackground:(o==null?void 0:o.exportBackground)??(i==null?void 0:i.exportBackground)});t.atomic(()=>{var l,c,u;for(const h of r.pageStates??[]){if(!t.has(h.pageId))continue;const f=Is.createId(h.pageId),p=Qr.createId(h.pageId),g=t.get(f),m=t.get(p);t.put([Is.create({id:f,x:((l=h.camera)==null?void 0:l.x)??(g==null?void 0:g.x),y:((c=h.camera)==null?void 0:c.y)??(g==null?void 0:g.y),z:((u=h.camera)==null?void 0:u.z)??(g==null?void 0:g.z)}),Qr.create({id:p,pageId:h.pageId,selectedShapeIds:h.selectedShapeIds??(m==null?void 0:m.selectedShapeIds),focusedGroupId:h.focusedGroupId??(m==null?void 0:m.focusedGroupId)})])}t.put([a]),t.ensureStoreIsUsable()})}function GZ(t){var s;const e=[];for(const o of Object.values(t))(s=o.typeName)!=null&&s.match(/^(instance.*|pointer|camera)$/)&&e.push(o);const n=e.filter(o=>o.typeName==="instance"&&o.id!==bn)[0];if(!n)return null;const r={version:Ng,currentPageId:n.currentPageId,exportBackground:!!n.exportBackground,isFocusMode:!!n.isFocusMode,isDebugMode:!!n.isDebugMode,isToolLocked:!!n.isToolLocked,isGridMode:!1,pageStates:e.filter(o=>o.typeName==="instance_page_state"&&o.instanceId===n.id).map(o=>{const i=t[o.cameraId]??{x:0,y:0,z:1};return{pageId:o.pageId,camera:{x:i.x,y:i.y,z:i.z},selectedShapeIds:o.selectedShapeIds,focusedGroupId:o.focusedGroupId}})};try{return Wj.validate(r),r}catch{return null}}function Gj(t,e,n){let r={};if("store"in e){const i=t.schema.migrateStoreSnapshot(e);if(i.type!=="success")throw new Error("Failed to migrate store snapshot: "+i.reason);r.document={schema:t.schema.serialize(),store:au(i.value,(a,{typeName:l})=>t.scopedTypes.document.has(l))}}else r=e;const s=jA(t.get(bn)),o=Vj.get(t,wb).get();t.atomic(()=>{r.document&&t.loadStoreSnapshot(r.document),s&&t.update(bn,i=>({...i,...s})),o&&Cx(t,o),r.session&&Cx(t,r.session,{forceOverwrite:n==null?void 0:n.forceOverwriteSessionState})})}const Vj=new Ds;function VZ(t){const n=Vj.get(t,wb).get();if(!n)throw new Error("Session state is not ready yet");return{document:t.getStoreSnapshot(),session:n}}function Yj(t){const e=[],n=new Set;for(const r of t){if(n.has(r.type))throw new Error(`Binding type "${r.type}" is defined more than once`);e.push(r),n.add(r.type)}return e}function mi({children:t,className:e="",...n}){return d.jsx("svg",{...n,className:ce("tl-svg-container",e),children:t})}function bb(t,e,n,r){const s=t.x-n.x,o=t.y-n.y,i=r.x-n.x,a=r.y-n.y,l=e.x-t.x,c=e.y-t.y,u=i*o-a*s,h=l*o-c*s,f=a*l-i*c;if(u===0||h===0||f===0)return null;if(f!==0){const p=u/f,g=h/f;if(0<=p&&p<=1&&0<=g&&g<=1)return x.AddXY(t,p*l,p*c)}return null}function gd(t,e,n,r){const s=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y),o=2*((e.x-t.x)*(t.x-n.x)+(e.y-t.y)*(t.y-n.y)),i=n.x*n.x+n.y*n.y+t.x*t.x+t.y*t.y-2*(n.x*t.x+n.y*t.y)-r*r,a=o*o-4*s*i;if(a<0||a===0)return null;const l=Math.sqrt(a),c=(-o+l)/(2*s),u=(-o-l)/(2*s);if((c<0||c>1)&&(u<0||u>1))return null;const h=[];return 0<=c&&c<=1&&h.push(x.Lrp(t,e,c)),0<=u&&u<=1&&h.push(x.Lrp(t,e,u)),h.length===0?null:h}function YZ(t,e,n){const r=[];let s;for(let o=0,i=n.length-1;o<i;o++)s=bb(t,e,n[o],n[o+1]),s&&r.push(s);return r.length===0?null:r}function Pb(t,e,n){const r=[];let s;for(let o=1,i=n.length;o<i+1;o++)s=bb(t,e,n[o-1],n[o%n.length]),s&&r.push(s);return r.length===0?null:r}function XZ(t,e,n,r){let s=n.x-t.x,o=n.y-t.y;const i=Math.sqrt(s*s+o*o),a=(i*i-r*r+e*e)/(2*i),l=Math.sqrt(e*e-a*a);return s/=i,o/=i,[new x(t.x+s*a-o*l,t.y+o*a+s*l),new x(t.x+s*a+o*l,t.y+o*a-s*l)]}function _x(t,e,n){const r=[];let s,o,i;for(let a=0,l=n.length;a<l;a++)s=n[a],o=n[(a+1)%n.length],i=gd(s,o,t,e),i&&r.push(...i);return r.length===0?null:r}function CI(t,e,n){const r=[];let s,o,i;for(let a=1,l=n.length;a<l;a++)s=n[a-1],o=n[a],i=gd(s,o,t,e),i&&r.push(...i);return r.length===0?null:r}function mh(t,e,n){return(n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function Cb(t,e,n,r){return mh(t,n,r)!==mh(e,n,r)&&mh(t,e,n)!==mh(t,e,r)}function _I(t,e){const n=new Map;let r,s,o,i;for(let a=0,l=t.length;a<l;a++)if(r=t[a],hr(r,e)){const c=Zy(r);n.has(c)||n.set(c,r)}for(let a=0,l=e.length;a<l;a++)if(r=e[a],hr(r,t)){const c=Zy(r);n.has(c)||n.set(c,r)}for(let a=0,l=t.length;a<l;a++){r=t[a],s=t[(a+1)%t.length];for(let c=0,u=e.length;c<u;c++){o=e[c],i=e[(c+1)%e.length];const h=bb(r,s,o,i);if(h!==null){const f=Zy(h);n.has(f)||n.set(f,h)}}}return n.size===0?null:qZ([...n.values()])}function Zy(t){return`${t.x},${t.y}`}function qZ(t){const e=x.Average(t);return t.sort((n,r)=>x.Angle(e,n)-x.Angle(e,r))}function _b(t,e){let n,r,s,o;for(let i=0,a=t.length;i<a;i++){n=t[i],r=t[(i+1)%a];for(let l=0,c=e.length;l<c;l++)if(s=e[l],o=e[(l+1)%c],Cb(n,r,s,o))return!0}return!1}function ZZ(t,e){let n,r,s,o;for(let i=0,a=t.length;i<a;i++){n=t[i],r=t[(i+1)%a];for(let l=1,c=e.length;l<c;l++)if(s=e[l-1],o=e[l],Cb(n,r,s,o))return!0}return!1}class co extends Mi{constructor(n){super({...n,isClosed:!1,isFilled:!1});I(this,"start");I(this,"end");I(this,"d");I(this,"u");I(this,"ul");const{start:r,end:s}=n;this.start=r,this.end=s,this.d=r.clone().sub(s),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(n){const{start:r,end:s,d:o,u:i,ul:a}=this;if(o.len()===0||a===0)return r;const l=x.Sub(n,r).dpr(i)/a,c=r.x+i.x*l;if(c<Math.min(r.x,s.x))return r.x<s.x?r:s;if(c>Math.max(r.x,s.x))return r.x>s.x?r:s;const u=r.y+i.y*l;return u<Math.min(r.y,s.y)?r.y<s.y?r:s:u>Math.max(r.y,s.y)?r.y>s.y?r:s:new x(c,u)}hitTestLineSegment(n,r,s=0){return Cb(n,r,this.start,this.end)||this.distanceToLineSegment(n,r)<=s}getSvgPathData(n=!0){const{start:r,end:s}=this;return`${n?`M${r.toFixed()}`:""} L${s.toFixed()}`}}class nc extends Mi{constructor(n){super({isClosed:!1,isFilled:!1,...n});I(this,"points");I(this,"_segments");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{vertices:n}=this;for(let r=0,s=n.length-1;r<s;r++){const o=n[r],i=n[r+1];this._segments.push(new co({start:o,end:i}))}this.isClosed&&this._segments.push(new co({start:n[n.length-1],end:n[0]}))}return this._segments}getLength(){return this.segments.reduce((n,r)=>n+r.length,0)}getVertices(){return this.points}nearestPoint(n){const{segments:r}=this;let s=this.points[0],o=1/0,i,a;for(let l=0;l<r.length;l++)i=r[l].nearestPoint(n),a=x.Dist2(i,n),a<o&&(s=i,o=a);if(!s)throw Error("nearest point not found");return s}hitTestLineSegment(n,r,s=0){const{segments:o}=this;for(let i=0,a=o.length;i<a;i++)if(o[i].hitTestLineSegment(n,r,s))return!0;return!1}getSvgPathData(){const{vertices:n}=this;return n.length<2?"":n.reduce((r,s,o)=>o===0?`M ${s.x} ${s.y}`:`${r} L ${s.x} ${s.y}`,"")}}class vt extends nc{constructor(e){super({...e}),this.isClosed=!0}}class Fs extends vt{constructor(n){const{x:r=0,y:s=0,width:o,height:i}=n;super({...n,points:[new x(r,s),new x(r+o,s),new x(r+o,s+i),new x(r,s+i)]});I(this,"x");I(this,"y");I(this,"w");I(this,"h");this.x=r,this.y=s,this.w=o,this.h=i}getBounds(){return new Z(this.x,this.y,this.w,this.h)}getSvgPathData(){const{x:n,y:r,w:s,h:o}=this;return`M${n},${r} h${s} v${o} h-${s}z`}}class ss{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,n){return!1}canDropShapes(e,n){return!1}expandSelectionOutlinePx(e){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(e){return{}}getHandleSnapGeometry(e){return{}}getText(e){}}I(ss,"props"),I(ss,"migrations"),I(ss,"type");function qr(t,e,n={}){const{closed:r=!1,snap:s=1,start:o="outset",end:i="outset",lengthRatio:a=2,style:l="dashed",forceSolid:c=!1}=n;let u=0,h=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 r||(o==="outset"?(t+=u/2,g+=u/2):o==="skip"&&(t-=u,g-=u),i==="outset"?t+=u/2:i==="skip"&&(t-=u)),h=Math.floor(t/u/(2*f)),h-=h%s,h<3&&l==="dashed"?t/e<4?(u=t,h=1,p=0):(u=t*(1/3),p=t*(1/3)):(u=t/h/(2*f),r?(g=u/2,p=(t-h*u)/h):p=(t-h*u)/Math.max(1,h-1)),{strokeDasharray:[u,p].join(" "),strokeDashoffset:g.toString()}}function II({bounds:t,className:e}){const n=z(),r=U("zoom level",()=>n.getZoomLevel(),[n]);return d.jsx("g",{className:e,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:t.sides.map((s,o)=>{const{strokeDasharray:i,strokeDashoffset:a}=qr(s[0].dist(s[1]),1/r,{style:"dashed",lengthRatio:4});return d.jsx("line",{x1:s[0].x,y1:s[0].y,x2:s[1].x,y2:s[1].y,strokeDasharray:i,strokeDashoffset:a},o)})})}class df extends ss{hideSelectionBoundsFg(){return!0}canBind(){return!1}getDefaultProps(){return{}}getGeometry(e){const n=this.editor.getSortedChildIdsForParent(e.id);return n.length===0?new Fs({width:1,height:1,isFilled:!1}):new $r({children:n.map(r=>{const s=this.editor.getShape(r),o=this.editor.getShapeGeometry(r),i=this.editor.getShapeLocalTransform(s).applyToPoints(o.vertices);return o.isClosed?new vt({points:i,isFilled:!0}):new nc({points:i})})})}component(e){const n=this.editor.getErasingShapeIds().includes(e.id),{hintingShapeIds:r}=this.editor.getCurrentPageState(),s=r.length>0&&r.some(a=>a!==e.id&&this.editor.isShapeOfType(this.editor.getShape(a),"group")),o=this.editor.getCurrentPageState().focusedGroupId!==e.id;if(!n&&(o||s))return null;const i=this.editor.getShapeGeometry(e).bounds;return d.jsx(mi,{children:d.jsx(II,{className:"tl-group",bounds:i})})}indicator(e){const n=this.editor.getShapeGeometry(e).bounds;return d.jsx(II,{className:"",bounds:n})}onChildrenChange(e){const n=this.editor.getSortedChildIdsForParent(e.id);if(n.length===0){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([e.id]);return}else if(n.length===1){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(n,e.parentId),this.editor.deleteShapes([e.id]);return}}}I(df,"type","group"),I(df,"props",KA),I(df,"migrations",WA);const Xj=[df],QZ=new Set(Xj.map(t=>t.type));function qj(t){const e=[...Xj],n=new Set;for(const r of t){if(QZ.has(r.type))throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(n.has(r.type))throw new Error(`Shape type "${r.type}" is defined more than once`);e.push(r),n.add(r.type)}return e}function Zj(t,e){const n=new Map;return async function(s){const o=n.get(s);if(o)return o;const i=(async()=>{try{const a=await Rs(s,e);return Le(a.ok),await t(a)}catch(a){return console.error(a),null}})();return n.set(s,i),i}}const zg=Zj(async t=>await Zr.blobToDataUrl(await t.blob())),JZ=/@import\s+(?:"([^"]+)"|'([^']+)'|url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\))([^;]+);/gi,eQ=/@font-face\s*{([^}]+)}/gi,Qj=/url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\)/gi,tQ=/(?:^|;)\s*font-family\s*:\s*(?:([^'"][^;\n]+)|"([^"]+)"|'([^']+)')\s*(?:;|$)/gi;function nQ(t){return Array.from(t.matchAll(JZ),e=>({url:e[1]||e[2]||e[3]||e[4]||e[5],extras:e[6]}))}function Jj(t,e){return Array.from(t.matchAll(eQ),n=>{const r=n[1],s=Array.from(r.matchAll(Qj),i=>{var l;const a=i[1]||i[2]||i[3];return{original:a,resolved:((l=ge(a,e))==null?void 0:l.href)??null}}),o=new Set(Array.from(r.matchAll(tQ),i=>(i[1]||i[2]||i[3]).toLowerCase()));return{fontFace:r,urls:s,fontFamilies:o}})}function rQ(t){const e=/\s*(?:([^'"][^;\n\s,]+)|"([^"]+)"|'([^']+)')\s*/gi,n=/\s*,\s*/gi,r=new Set;for(;;){const s=e.exec(t);if(!s)break;const o=s[1]||s[2]||s[3];if(r.add(o.toLowerCase()),n.lastIndex=e.lastIndex,!n.exec(t))break;e.lastIndex=n.lastIndex}return r}function eO(t){return!(t.startsWith("-")||t.startsWith("animation")||t.startsWith("transition")||t==="cursor"||t==="pointer-events"||t==="user-select"||t==="touch-action")}function sQ(t,e){return{imports:nQ(t),fontFaces:Jj(t,e)}}function oQ(t){return Array.from(t.matchAll(Qj),e=>({original:e[0],url:e[1]||e[2]||e[3]}))}const iQ=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 tO(t){return iQ.has(t)}var aQ=Object.create,nO=Object.defineProperty,lQ=Object.getOwnPropertyDescriptor,cQ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),rO=t=>{throw TypeError(t)},sO=(t,e,n)=>e in t?nO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,uQ=t=>[,,,aQ(null)],oO=["class","method","getter","setter","accessor","field","value","get","set"],iO=t=>t!==void 0&&typeof t!="function"?rO("Function expected"):t,dQ=(t,e,n,r,s)=>({kind:oO[t],name:e,metadata:r,addInitializer:o=>n._?rO("Already initialized"):s.push(iO(o||null))}),hQ=(t,e)=>sO(e,cQ("metadata"),t[3]),fQ=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},pQ=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=oO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,lQ(s,n)),y=r.length-1;y>=0;y--)l=dQ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,iO(i)&&(v[g]=i);return v&&nO(s,n,v),s},yh=(t,e,n)=>sO(t,typeof e!="symbol"?e+"":e,n),aO,Bg;aO=[Kn];class Ib{constructor(){fQ(Bg,5,this),yh(this,"fontFacesPromise",null),yh(this,"foundFontNames",new Set),yh(this,"fontFacesToEmbed",new Set),yh(this,"pendingPromises",[])}startFindingCurrentDocumentFontFaces(){Le(!this.fontFacesPromise,"FontEmbedder already started"),this.fontFacesPromise=gQ()}onFontFamilyValue(e){Le(this.fontFacesPromise,"FontEmbedder not started");const n=rQ(e);for(const r of n){if(this.foundFontNames.has(r))return;this.foundFontNames.add(r),this.pendingPromises.push(this.fontFacesPromise.then(s=>{const o=s.filter(i=>i.fontFamilies.has(r));for(const i of o)if(!this.fontFacesToEmbed.has(i)){this.fontFacesToEmbed.add(i);for(const a of i.urls)!a.resolved||a.embedded||(a.embedded=zg(a.resolved))}}))}}async createCss(){await Promise.all(this.pendingPromises);let e="";for(const n of this.fontFacesToEmbed){let r=`@font-face {${n.fontFace}}`;for(const s of n.urls){if(!s.embedded)continue;const o=await s.embedded;o&&(r=r.replace(s.original,o))}e+=r}return e}}Bg=uQ();pQ(Bg,1,"onFontFamilyValue",aO,Ib);hQ(Bg,Ib);async function gQ(){var e;const t=[];for(const n of document.styleSheets){let r;try{r=n.cssRules}catch{}if(r){for(const s of n.cssRules)if(s instanceof CSSFontFaceRule)t.push(Jj(s.cssText,n.href??document.baseURI));else if(s instanceof CSSImportRule){const o=new URL(s.href,((e=s.parentStyleSheet)==null?void 0:e.href)??document.baseURI);t.push(Ix(o.href))}}else n.href&&t.push(Ix(n.href))}return me(await Promise.all(t)).flat()}const Ix=Zj(async t=>{const e=sQ(await t.text(),t.url),n=await Promise.all(e.imports.map(({url:r})=>Ix(new URL(r,t.url).href)));return[...e.fontFaces,...me(n).flat()]});function lO(t){if(t.shadowRoot)return t.shadowRoot.childNodes;if(vQ(t)){const e=t.assignedNodes();if(e!=null&&e.length)return e}return t.childNodes}function*Ex(t){for(const e of lO(t))mQ(e)&&(yield e)}function Ug(t){var e;return((e=t.ownerDocument)==null?void 0:e.defaultView)??globalThis}function mQ(t){return t instanceof Ug(t).Element}function yQ(t){return t instanceof Ug(t).ShadowRoot}function SQ(t){return"getRootNode"in t&&yQ(t.getRootNode())}function vQ(t){return SQ(t)&&t instanceof Ug(t).HTMLSlotElement}function xQ(t){return t.style}function Eb(t,e){return Ug(t).getComputedStyle(t,e)}const ta={};class wQ{constructor(e){I(this,"styles",new Map);I(this,"fonts",new Ib);this.root=e}readRootElementStyles(e){this.readElementStyles(e,{shouldRespectDefaults:!1,shouldSkipInheritedParentStyles:!1});const n=Array.from(Ex(e));for(;n.length;){const r=n.pop();n.push(...Ex(r)),this.readElementStyles(r,{shouldRespectDefaults:!0,shouldSkipInheritedParentStyles:!0})}}readElementStyles(e,{shouldRespectDefaults:n=!0,shouldSkipInheritedParentStyles:r=!0}){var a;const s=n?_Q(e.tagName.toLowerCase()):ta,o=r?((a=this.styles.get(e.parentElement))==null?void 0:a.self)??ta:ta,i={self:bQ(e,{defaultStyles:s,parentStyles:o}),before:EI(e,"::before"),after:EI(e,"::after")};this.styles.set(e,i)}fetchResources(){const e=[];for(const n of this.styles.values())for(const r of ut(n))if(r)for(const[s,o]of Object.entries(r)){if(!o)continue;s==="font-family"&&this.fonts.onFontFamilyValue(o);const i=oQ(o);i.length!==0&&e.push(...i.map(async({url:a,original:l})=>{const c=await zg(a)??"data:";r[s]=o.replace(l,`url("${c}")`)}))}return Promise.all(e)}unwrapCustomElements(){const e=new Set,n=(r,s)=>{if(e.has(r))return;e.add(r);const o=r.shadowRoot;if(o){const i=document.createElement("div");this.styles.set(i,this.styles.get(r)),i.setAttribute("data-tl-custom-element",r.tagName),(s??r.parentElement).appendChild(i);for(const a of o.childNodes)a instanceof Element?n(a,i):i.appendChild(a.cloneNode(!0));r.remove()}else if(s){if(r.tagName.toLowerCase()==="style")return;const i=r.cloneNode(!1);this.styles.set(i,this.styles.get(r)),s.appendChild(i);for(const a of lO(r))a instanceof Element?n(a,i):i.appendChild(a.cloneNode(!0))}};for(const r of this.styles.keys())n(r,null)}embedStyles(){let e="";for(const[n,r]of this.styles){if(r.after||r.before){const o=`pseudo-${ze()}`;n.classList.add(o),r.before&&(e+=`.${o}::before {${kI(r.before)}}
|
|
99
|
-
`),r.after&&(e+=`.${o}::after {${kI(r.after)}}
|
|
100
|
-
`)}const s=xQ(n);for(const[o,i]of Object.entries(r.self))i&&s.setProperty(o,i);s.fontKerning==="auto"&&(s.fontKerning="normal")}return e}async getFontFaceCss(){return await this.fonts.createCss()}dispose(){CQ()}}function bQ(t,{defaultStyles:e,parentStyles:n}){return t.computedStyleMap?cO(t.computedStyleMap(),{defaultStyles:e,parentStyles:n}):kb(Eb(t),{defaultStyles:e,parentStyles:n})}function EI(t,e){const n=Eb(t,e),r=n.getPropertyValue("content");if(!(r===""||r==="none"))return kb(n,{defaultStyles:ta,parentStyles:ta})}function cO(t,{defaultStyles:e,parentStyles:n}){const r={};for(const s of t.keys()){if(!eO(s))continue;const o=t.get(s).toString();e[s]!==o&&(n[s]===o&&tO(s)||(r[s]=o))}return r}function kb(t,{defaultStyles:e,parentStyles:n}){const r={};for(const s of t){if(!eO(s))continue;const o=t.getPropertyValue(s);e[s]!==o&&(n[s]===o&&tO(s)||(r[s]=o))}return r}function kI(t){let e="";for(const[n,r]of Object.entries(t))e+=`${n}: ${r};`;return e}let bl;const TI={};function PQ(){if(!bl){const t=document.createElement("iframe");t.style.display="none",document.body.appendChild(t);const e=zn(t.contentDocument,"frame must have a document"),n=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");n.appendChild(r),e.body.appendChild(n),bl={iframe:t,foreignObject:r,document:e}}return bl}function CQ(){bl&&(document.body.removeChild(bl.iframe),bl=void 0)}const MI={defaultStyles:ta,parentStyles:ta};function _Q(t){let e=TI[t];if(!e){const{foreignObject:n,document:r}=PQ(),s=r.createElement(t);n.appendChild(s),e=s.computedStyleMap?cO(s.computedStyleMap(),MI):kb(Eb(s),MI),n.removeChild(s),TI[t]=e}return e}function IQ(t,e){Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)})}function AI(t,e){return t.replaceWith(e),e}async function uu(t,e){const n=document.createElement("img");e&&IQ(e,n),n.setAttribute("src",t??"data:"),n.setAttribute("decoding","sync"),n.setAttribute("loading","eager");try{await n.decode()}catch{}return n}async function EQ(t){try{const e=t.toDataURL();return await uu(e,t)}catch{return await uu(null,t)}}async function kQ(t){try{const e=await ar.getVideoFrameAsDataUrl(t);return uu(e,t)}catch(e){console.error("Could not get video frame",e)}if(t.poster){const e=await zg(t.poster);return uu(e,t)}return uu(null,t)}async function uO(t){if(t instanceof HTMLCanvasElement)return AI(t,await EQ(t));if(t instanceof HTMLVideoElement)return AI(t,await kQ(t));if(t instanceof HTMLImageElement){const e=t.currentSrc||t.src,n=await zg(e);t.setAttribute("src",n??"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(Ex(t),e=>uO(e)))}function Hg(t){const e=w.useRef();return w.useLayoutEffect(()=>{e.current=t}),w.useDebugValue(t),w.useCallback((...n)=>{const r=e.current;return Le(r,"fn does not exist"),r(...n)},[])}const Tb=w.createContext(null);function TQ({context:t,editor:e,children:n}){const r=e.options.exportProvider;return d.jsx(fb,{editor:e,children:d.jsx(hj,{container:e.getContainer(),children:d.jsx(Tb.Provider,{value:t,children:d.jsx(r,{children:n})})})})}function md(){return w.useContext(Tb)}function MQ(){const t=w.useContext(Tb),[e]=w.useState(y0);return w.useEffect(()=>(t==null||t.waitUntil(e),()=>{e.resolve()}),[e,t]),Hg(()=>{e.resolve()})}var AQ=Object.create,dO=Object.defineProperty,jQ=Object.getOwnPropertyDescriptor,OQ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hO=t=>{throw TypeError(t)},fO=(t,e,n)=>e in t?dO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,DQ=t=>[,,,AQ(null)],pO=["class","method","getter","setter","accessor","field","value","get","set"],gO=t=>t!==void 0&&typeof t!="function"?hO("Function expected"):t,RQ=(t,e,n,r,s)=>({kind:pO[t],name:e,metadata:r,addInitializer:o=>n._?hO("Already initialized"):s.push(gO(o||null))}),LQ=(t,e)=>fO(e,OQ("metadata"),t[3]),$Q=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},FQ=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=pO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,jQ(s,n)),y=r.length-1;y>=0;y--)l=RQ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,gO(i)&&(v[g]=i);return v&&dO(s,n,v),s},jI=(t,e,n)=>fO(t,typeof e!="symbol"?e+"":e,n),mO,Kg;mO=[Kn];class Mb{constructor(e){this.maxDelayTimeMs=e,$Q(Kg,5,this),jI(this,"isResolved",!1),jI(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(n=>console.error("Error whilst waiting for export:",n)))}async resolvePromises(){let e=null;for(;this.promisesToWaitFor.length!==e;)e=this.promisesToWaitFor.length,await Promise.allSettled(this.promisesToWaitFor),await Wv(0)}async resolve(){const e=Wv(this.maxDelayTimeMs).then(()=>"timeout"),n=this.resolvePromises().then(()=>"resolved");await Promise.race([e,n])==="timeout"&&console.warn("[tldraw] Export delay timed out after ${this.maxDelayTimeMs}ms"),this.isResolved=!0}}Kg=DQ();FQ(Kg,1,"waitUntil",mO,Mb);LQ(Kg,Mb);function NQ(t,e,n={}){var y,S;if(!window.document)throw Error("No document");const{scale:r=1,background:s=!1,padding:o=t.options.defaultSvgPadding,preserveAspectRatio:i}=n,a=n.darkMode??t.user.getIsDarkMode(),l=t.getShapeAndDescendantIds(e),c=t.getUnorderedRenderingShapes(!1).filter(({id:b})=>l.has(b));let u=null;if(n.bounds)u=n.bounds;else for(const{id:b}of c){const P=t.getShapeMaskedPageBounds(b);P&&(u?u.union(P):u=P.clone())}if(!u)return;const h=e.length===1&&t.isShapeOfType(t.getShape(e[0]),"frame")?e[0]:null;h||u.expandBy(o);const f=u.width*r,p=u.height*r;try{(S=(y=document.body).focus)==null||S.call(y)}catch{}const g=new Mb(t.options.maxExportDelayMs),m=y0();return g.waitUntil(m),{jsx:d.jsx(zQ,{editor:t,preserveAspectRatio:i,scale:r,bbox:u,background:s,singleFrameShapeId:h,isDarkMode:a,renderingShapes:c,onMount:m.resolve,waitUntil:g.waitUntil}),width:f,height:p,exportDelay:g}}function zQ({editor:t,preserveAspectRatio:e,scale:n,bbox:r,background:s,singleFrameShapeId:o,isDarkMode:i,renderingShapes:a,onMount:l,waitUntil:c}){const u=Jl(),h=ko({isDarkMode:i}),f=q0("export state",{defsById:{},shapeElements:null}),{defsById:p,shapeElements:g}=U(f),m=Hg(S=>{f.update(b=>{if(ns(b.defsById,S.key))return b;const P=Promise.resolve(S.getElement());return c(P.then(C=>{f.update(_=>({..._,defsById:{..._.defsById,[S.key]:{pending:!1,element:C}}}))})),{...b,defsById:{...b.defsById,[S.key]:{pending:!0,element:P}}}})}),v=w.useMemo(()=>({isDarkMode:i,waitUntil:c,addExportDef:m}),[i,c,m]),y=w.useRef(!1);return w.useLayoutEffect(()=>{if(y.current)throw new Error("SvgExport should only render once - do not use with react strict mode");y.current=!0,(async()=>{const S={},b=a.map(async({id:C,opacity:_,index:E,backgroundIndex:k})=>{var L,M;if(C===o)return[];const D=t.getShape(C);if(t.isShapeOfType(D,"group"))return[];const T=[],j=t.getShapeUtil(D);if(j.toSvg||j.toBackgroundSvg){const[O,F]=await Promise.all([(L=j.toSvg)==null?void 0:L.call(j,D,v),(M=j.toBackgroundSvg)==null?void 0:M.call(j,D,v)]),B=t.getShapePageTransform(D);let K=B.toCssString(),R=1;"scale"in D.props&&D.props.scale!==1&&(R=D.props.scale,K=`${K} scale(${D.props.scale}, ${D.props.scale})`);const H=t.getShapeMask(D.id),X=H?q.From(q.Inverse(B)).applyToPoints(H):null,te=db(u,D.id);X&&(S[te]={pending:!1,element:d.jsx("clipPath",{id:te,children:d.jsx("path",{d:`M${X.map(({x:le,y:de})=>`${le/R},${de/R}`).join("L")}Z`})})}),O&&T.push({zIndex:E,element:d.jsx("g",{transform:K,opacity:_,clipPath:H?`url(#${te})`:void 0,children:O},`fg_${D.id}`)}),F&&T.push({zIndex:k,element:d.jsx("g",{transform:K,opacity:_,clipPath:H?`url(#${te})`:void 0,children:F},`bg_${D.id}`)})}else T.push({zIndex:E,element:d.jsx(OI,{shape:D,util:j,component:Ij,className:"tl-shape",bbox:r,opacity:_},`fg_${D.id}`)}),j.backgroundComponent&&T.push({zIndex:k,element:d.jsx(OI,{shape:D,util:j,component:Ej,className:"tl-shape tl-shape-background",bbox:r,opacity:_},`bg_${D.id}`)});return T}),P=(await Promise.all(b)).flat();ba.flushSync(()=>{f.update(C=>({...C,shapeElements:P.sort((_,E)=>_.zIndex-E.zIndex).map(({element:_})=>_),defsById:{...C.defsById,...S}}))})})()},[r,t,v,u,a,o,f]),w.useEffect(()=>{g!==null&&l()},[l,g]),d.jsx(TQ,{editor:t,context:v,children:d.jsxs("svg",{preserveAspectRatio:e,direction:"ltr",width:r.width*n,height:r.height*n,viewBox:`${r.minX} ${r.minY} ${r.width} ${r.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:s?o?h.solid:h.background:"transparent"},"data-color-mode":i?"dark":"light",className:`tl-container tl-theme__force-sRGB ${i?"tl-theme__dark":"tl-theme__light"}`,children:[d.jsx("defs",{children:Object.entries(p).map(([S,b])=>b.pending?null:d.jsx(w.Fragment,{children:b.element},S))}),g]})})}function OI({shape:t,util:e,className:n,component:r,bbox:s,opacity:o}){const i=z(),a=q.Translate(-s.minX,-s.minY).multiply(i.getShapePageTransform(t.id)),l=i.getShapeGeometry(t.id).bounds,c=Math.max(l.width,1),u=Math.max(l.height,1);return d.jsx(ub,{fallback:()=>null,children:d.jsx("foreignObject",{x:s.minX,y:s.minY,width:s.w,height:s.h,className:"tl-shape-foreign-object",children:d.jsx("div",{className:n,"data-shape-type":t.type,style:{clipPath:i.getShapeClipPath(t.id),transform:a.toCssString(),width:c,height:u,opacity:o},children:d.jsx(r,{shape:t,util:e})})})})}let BQ=1;async function UQ(t,e,n={}){const r=NQ(t,e,n);if(!r)return;const s=t.getContainer(),o=document.createElement("div");o.className="tldraw-svg-export",o.inert=!0,o.tabIndex=-1,Object.assign(o.style,{position:"absolute",top:"0px",left:"0px",width:r.width+"px",height:r.height+"px",pointerEvents:"none",opacity:0}),s.appendChild(o);const i=ET(o,{identifierPrefix:`export_${BQ++}_`});try{await Promise.resolve(),ba.flushSync(()=>{i.render(r.jsx)}),await r.exportDelay.resolve();const a=o.firstElementChild;return Le(a instanceof SVGSVGElement,"Expected an SVG element"),await HQ(a),{svg:a,width:r.width,height:r.height}}finally{setTimeout(()=>{i.unmount(),s.removeChild(o)},0)}}async function HQ(t){const e=[...t.querySelectorAll("foreignObject.tl-shape-foreign-object > *")];if(!e.length)return;const n=new wQ(t);try{n.fonts.startFindingCurrentDocumentFontFaces(),await Promise.all(e.map(o=>uO(o)));for(const o of e)n.readRootElementStyles(o);await n.fetchResources();const r=await n.getFontFaceCss();n.unwrapCustomElements();const s=n.embedStyles();if(r||s){const o=document.createElementNS("http://www.w3.org/2000/svg","style");o.textContent=`${r}
|
|
101
|
-
${s}`,t.prepend(o)}}finally{n.dispose()}}const Vr={menus:It("open menus",[]),getOpenMenus(t){return t?this.menus.get().filter(e=>e.endsWith("-"+t)):this.menus.get()},addOpenMenu(t,e=""){const n=e?`${t}-${e}`:t,r=new Set(this.menus.get());r.has(n)||(r.add(n),this.menus.set([...r]))},deleteOpenMenu(t,e=""){const n=e?`${t}-${e}`:t,r=new Set(this.menus.get());r.has(n)&&(r.delete(n),this.menus.set([...r]))},clearOpenMenus(t){this.menus.set(t?this.menus.get().filter(e=>!e.endsWith("-"+t)):[])},_hiddenMenus:[],hideOpenMenus(t){if(this._hiddenMenus=[...this.getOpenMenus(t)],this._hiddenMenus.length!==0)for(const e of this._hiddenMenus)this.deleteOpenMenu(e,t)},showOpenMenus(t){if(this._hiddenMenus.length!==0){for(const e of this._hiddenMenus)this.addOpenMenu(e,t);this._hiddenMenus=[]}},isMenuOpen(t,e){return this.getOpenMenus(e).includes(t)},hasOpenMenus(t){return this.getOpenMenus(t).length>0},hasAnyOpenMenus(){return this.getOpenMenus().length>0},forContext(t){return{getOpenMenus:()=>this.getOpenMenus(t),addOpenMenu:e=>this.addOpenMenu(e,t),deleteOpenMenu:e=>this.deleteOpenMenu(e,t),clearOpenMenus:()=>this.clearOpenMenus(t),isMenuOpen:e=>this.isMenuOpen(e,t),hasOpenMenus:()=>this.hasOpenMenus(t),hasAnyOpenMenus:()=>this.hasAnyOpenMenus()}}},kx=new fB,KQ={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,temporaryAssetPreviewLifetimeMs:18e4,actionShortcutsLocation:"swap",createTextOnCanvasDoubleClick:!0,exportProvider:w.Fragment};function DI(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 Ot(t)}}class WQ{constructor(e){I(this,"map");this.map=new Map(e)}get(e){return this.map.get(e)}getAsKnownValue(e){const n=this.get(e);if(n&&n.type!=="mixed")return n.value}get size(){return this.map.size}equals(e){if(this.size!==e.size)return!1;const n=new Set;for(const[r,s]of this){if(!DI(s,e.get(r)))return!1;n.add(r)}for(const[r,s]of e)if(!n.has(r)&&!DI(s,this.get(r)))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 Tx extends WQ{set(e,n){this.map.set(e,n)}applyValue(e,n){const r=this.get(e);if(!r){this.set(e,{type:"shared",value:n});return}switch(r.type){case"mixed":return;case"shared":r.value!==n&&this.set(e,{type:"mixed"});return;default:Ot(r,"type")}}}function GQ(t,e,n){return Rs(t).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],e,{type:n})})}const VQ="https://cdn.tldraw.com";function ti(){return`${VQ}/${oj}`}function YQ(t){switch(t.type){case"shapes":return`s${t.shapeIds.map(n=>Qy(n.slice(6))).join(".")}`;case"page":return"p"+Qy(yr.parseId(t.pageId));case"viewport":{const{bounds:e,pageId:n}=t;let r=`v${Math.round(e.x)}.${Math.round(e.y)}.${Math.round(e.w)}.${Math.round(e.h)}`;return n&&(r+="."+Qy(yr.parseId(n))),r}default:Ot(t)}}function XQ(t){switch(t[0]){case"s":return{type:"shapes",shapeIds:t.slice(1).split(".").filter(Boolean).map(r=>Ke(decodeURIComponent(r)))};case"p":return{type:"page",pageId:yr.createId(decodeURIComponent(t.slice(1)))};case"v":{const[n,r,s,o,i]=t.slice(1).split(".");return{type:"viewport",bounds:new Z(Number(n),Number(r),Number(s),Number(o)),pageId:i?yr.createId(decodeURIComponent(i)):void 0}}default:throw Error("Invalid deep link string")}}function Qy(t){return encodeURIComponent(t).replace(/\./g,"%2E")}function qQ(t,e){var s;let n=t;const r=new Set(e);for(;r.has(n);)n=(s=/^.*(\d+)$/.exec(n))!=null&&s[1]?n.replace(/(\d+)(?=\D?)$/,o=>(+o+1).toString()):`${n} 1`;return n}function Sh(t,e,n,r){if(n.length===0)return[];const s=new Map;for(const i of me(n.map(a=>t.getShape(a)))){const{parentId:a}=i;s.has(a)||s.set(a,{children:me(t.getSortedChildIdsForParent(a).map(l=>t.getShape(l))),moving:new Set}),s.get(a).moving.add(i)}const o=[];switch(e){case"toBack":{s.forEach(({moving:i,children:a})=>ZQ(i,a,o));break}case"toFront":{s.forEach(({moving:i,children:a})=>QQ(i,a,o));break}case"forward":{s.forEach(({moving:i,children:a})=>JQ(t,i,a,o,r));break}case"backward":{s.forEach(({moving:i,children:a})=>eJ(t,i,a,o,r));break}}return o}function ZQ(t,e,n){const r=e.length;if(t.size===r)return;let s,o;for(let i=0;i<r;i++){const a=e[i];if(t.has(a))s=a.index,t.delete(a);else{o=a.index;break}}if(t.size!==0){const i=Dl(s,o,t.size);n.push(...Array.from(t.values()).sort(cn).map((a,l)=>({...a,index:i[l]})))}}function QQ(t,e,n){const r=e.length;if(t.size===r)return;let s,o;for(let i=r-1;i>-1;i--){const a=e[i];if(t.has(a))o=a.index,t.delete(a);else{s=a.index;break}}if(t.size!==0){const i=Dl(s,o,t.size);n.push(...Array.from(t.values()).sort(cn).map((a,l)=>({...a,index:i[l]})))}}function RI(t,e){const n=t.getShapeGeometry(e),r=t.getShapePageTransform(e);return!n||!r?null:r.applyToPoints(n.vertices)}function yO(t,e){const n=Array.from(e).map(s=>{const o=RI(t,s);return o?{shape:s,vertices:o}:null}).filter(Boolean);return s=>{const o=RI(t,s);return o?n.some(i=>_b(i.vertices,o)):!1}}function JQ(t,e,n,r,s){var l;const o=yO(t,e),i=n.length;if(e.size===i)return;let a={name:"skipping"};for(let c=0;c<i;c++){const u=e.has(n[c]);switch(a.name){case"skipping":{if(!u)continue;a={name:"selecting",selectIndex:c};break}case"selecting":{if(u||!(s!=null&&s.considerAllShapes)&&!o(n[c]))continue;const{selectIndex:h}=a;Dl(n[c].index,(l=n[c+1])==null?void 0:l.index,c-h).forEach((f,p)=>{const g=n[h+p];e.has(g)&&r.push({...g,index:f})}),a={name:"skipping"};break}}}}function eJ(t,e,n,r,s){var l;const o=yO(t,e),i=n.length;if(e.size===i)return;let a={name:"skipping"};for(let c=i-1;c>-1;c--){const u=e.has(n[c]);switch(a.name){case"skipping":{if(!u)continue;a={name:"selecting",selectIndex:c};break}case"selecting":{if(u||!(s!=null&&s.considerAllShapes)&&!o(n[c]))continue;Dl((l=n[c-1])==null?void 0:l.index,n[c].index,a.selectIndex-c).forEach((h,f)=>{const p=n[c+f+1];e.has(p)&&r.push({...p,index:h})}),a={name:"skipping"};break}}}}function SO({editor:t,ids:e}){const n=me(e.map(i=>t.getShape(i))),r=t.getShapesSharedRotation(e),s=t.getShapesRotatedPageBounds(e);if(!s)return null;const o=s.center.clone().rotWith(s.point,r);return{pageCenter:o,initialCursorAngle:o.angle(t.inputs.originPagePoint),initialShapesRotation:r,shapeSnapshots:n.map(i=>({shape:i,initialPagePoint:t.getShapePageTransform(i.id).point()}))}}function hf({delta:t,editor:e,snapshot:n,stage:r,centerOverride:s}){const{pageCenter:o,shapeSnapshots:i}=n;e.updateShapes(i.map(({shape:l,initialPagePoint:c})=>{const u=Fn(l.parentId)?e.getShapePageTransform(l.parentId):q.Identity(),h=x.RotWith(c,s??o,t),f=q.applyToPoint(q.Inverse(u),h),p=ea(l.rotation+t);return{id:l.id,type:l.type,x:f.x,y:f.y,rotation:p}}));const a=[];i.forEach(({shape:l})=>{var f,p,g;const c=e.getShape(l.id);if(!c)return;const u=e.getShapeUtil(l);if(r==="start"||r==="one-off"){const m=(f=u.onRotateStart)==null?void 0:f.call(u,l);m&&a.push(m)}const h=(p=u.onRotate)==null?void 0:p.call(u,l,c);if(h&&a.push(h),r==="end"||r==="one-off"){const m=(g=u.onRotateEnd)==null?void 0:g.call(u,l,c);m&&a.push(m)}}),a.length>0&&e.updateShapes(a)}const tJ=t=>{const{store:e}=t,n=e.query.filterHistory("binding"),r=e.query.records("binding");function s(){const o=r.get(),i=new Map;for(const a of o){const{fromId:l,toId:c}=a,u=i.get(l);u?u.push(a):i.set(l,[a]);const h=i.get(c);h?h.push(a):i.set(c,[a])}return i}return G("arrowBindingsIndex",(o,i)=>{if(Qi(o))return s();const a=o,l=n.getDiffSince(i);if(l===ur)return s();let c;function u(p){c??(c=new Map(a));const g=c.get(p.fromId),m=g==null?void 0:g.filter(S=>S.id!==p.id);m!=null&&m.length?c.set(p.fromId,m):c.delete(p.fromId);const v=c.get(p.toId),y=v==null?void 0:v.filter(S=>S.id!==p.id);y!=null&&y.length?c.set(p.toId,y):c.delete(p.toId)}function h(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){h(p.fromId).push(p),h(p.toId).push(p)}for(const p of l){for(const g of ut(p.added))f(g);for(const[g,m]of ut(p.updated))u(g),f(m);for(const g of ut(p.removed))u(g)}return c??a})};function nJ(t,e,n){const r=t.getShapeMaskedPageBounds(e);return r===void 0?!0:!n.includes(r)}const rJ=t=>{function e(n){const r=n.getCurrentPageShapeIds(),s=n.getViewportPageBounds(),o=new Set;return r.forEach(i=>{nJ(n,i,s)&&o.add(i)}),o}return G("getCulledShapes",n=>{if(Qi(n))return e(t);const r=e(t);if(n.size!==r.size)return r;for(const s of n)if(!r.has(s))return r;return n})},sJ=t=>{const e=t.query.ids("shape"),n=t.query.filterHistory("shape");function r(){const s={},o=e.get(),i=Array(o.size);return o.forEach(a=>i.push(t.get(a))),i.sort(cn),i.forEach(a=>{s[a.parentId]||(s[a.parentId]=[]),s[a.parentId].push(a.id)}),s}return G("parentsToChildrenWithIndexes",(s,o)=>{if(Qi(s))return r();const i=n.getDiffSince(o);if(i===ur)return r();if(i.length===0)return s;let a=null;const l=h=>{a||(a={...s}),a[h]?a[h]===s[h]&&(a[h]=[...a[h]]):a[h]=[]},c=new Set;let u;for(let h=0,f=i.length;h<f;h++){u=i[h];for(const p of Object.values(u.added))ll(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(ll(g)&&ll(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))ll(p)&&(l(p.parentId),a[p.parentId].splice(a[p.parentId].indexOf(p.id),1))}for(const h of c){const f=me(h.map(p=>t.get(p)));f.sort(cn),h.splice(0,h.length,...f.map(p=>p.id))}return a??s})},Jy=(t,e,n)=>{for(;!Rn(n.parentId);){const r=t.get(n.parentId);if(!r)return!1;n=r}return n.parentId===e},oJ=(t,e)=>{const n=t.query.ids("shape");let r=null;function s(){const o=e();return r=o,new Set([...n.get()].filter(i=>Jy(t,o,t.get(i))))}return G("_shapeIdsInCurrentPage",(o,i)=>{if(Qi(o))return s();const a=e();if(a!==r)return s();const l=t.history.getDiffSince(i);if(l===ur)return s();const c=new af(o);for(const h of l){for(const f of Object.values(h.added))ll(f)&&Jy(t,a,f)&&c.add(f.id);for(const[f,p]of Object.values(h.updated))ll(p)&&(Jy(t,a,p)?c.add(p.id):c.remove(p.id));for(const f of Object.keys(h.removed))Fn(f)&&c.remove(f)}const u=c.get();return u?Kc(u.value,u.diff):o})};var iJ=Object.create,vO=Object.defineProperty,aJ=Object.getOwnPropertyDescriptor,lJ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),xO=t=>{throw TypeError(t)},wO=(t,e,n)=>e in t?vO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,cJ=t=>[,,,iJ(null)],bO=["class","method","getter","setter","accessor","field","value","get","set"],PO=t=>t!==void 0&&typeof t!="function"?xO("Function expected"):t,uJ=(t,e,n,r,s)=>({kind:bO[t],name:e,metadata:r,addInitializer:o=>n._?xO("Already initialized"):s.push(PO(o||null))}),dJ=(t,e)=>wO(e,lJ("metadata"),t[3]),hJ=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},CO=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=bO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,aJ(s,n)),y=r.length-1;y>=0;y--)l=uJ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,PO(i)&&(v[g]=i);return v&&vO(s,n,v),s},$a=(t,e,n)=>wO(t,typeof e!="symbol"?e+"":e,n),_O,IO,yd;const fJ=40;IO=[Kn],_O=[Kn];class Wg{constructor(e){this.editor=e,hJ(yd,5,this),$a(this,"_clickId",""),$a(this,"_clickTimeout"),$a(this,"_clickScreenPoint"),$a(this,"_previousScreenPoint"),$a(this,"_clickState","idle"),$a(this,"lastPointerInfo",{})}_getClickTimeout(e,n=ze()){this._clickId=n,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.setTimeout(()=>{if(this._clickState===e&&this._clickId===n){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=x.From(e.point),this._previousScreenPoint&&x.Dist2(this._previousScreenPoint,this._clickScreenPoint)>fJ**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=x.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&&x.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"}}yd=cJ();CO(yd,1,"_getClickTimeout",IO,Wg);CO(yd,1,"cancelDoubleClickTimeout",_O,Wg);dJ(yd,Wg);class pJ{constructor(e){I(this,"_isEdgeScrolling",!1);I(this,"_edgeScrollDuration",-1);this.editor=e}updateEdgeScrolling(e){const{editor:n}=this,r=this.getEdgeScroll();if(r.x===0&&r.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>n.options.edgeScrollDelay){const s=n.options.edgeScrollEaseDuration>0?Dt.easeInCubic(Math.min(1,this._edgeScrollDuration/(n.options.edgeScrollDelay+n.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:r.x*s,y:r.y*s})}}getEdgeProximityFactors(e,n,r,s,o){const{editor:i}=this,a=i.options.edgeScrollDistance,l=r?i.options.coarsePointerWidth:0,c=e-l,u=e+l,h=s?0:a,f=o?n:n-a;return c<h?Math.min(1,(h-c)/a):u>f?-Math.min(1,(u-f)/a):0}getEdgeScroll(){const{editor:e}=this,{inputs:{currentScreenPoint:{x:n,y:r}}}=e,s=e.getViewportScreenBounds(),{isCoarsePointer:o,insets:[i,a,l,c]}=e.getInstanceState(),u=this.getEdgeProximityFactors(n,s.w,o,c,a),h=this.getEdgeProximityFactors(r,s.h,o,i,l);return{x:u,y:h}}moveCameraWhenCloseToEdge(e){const{editor:n}=this;if(!n.inputs.isDragging||n.inputs.isPanning||n.getCameraOptions().isLocked||e.x===0&&e.y===0)return;const r=n.getViewportScreenBounds(),s=r.w<1e3?.612:1,o=r.h<1e3?.612:1,i=n.getZoomLevel(),a=n.user.getEdgeScrollSpeed()*n.options.edgeScrollSpeed,l=a*e.x*s/i,c=a*e.y*o/i,{x:u,y:h,z:f}=n.getCamera();n.setCamera(new x(u+l,h+c,f))}}class gJ{constructor(e,n){I(this,"disposeSideEffectListener");this.editor=e,this.disposeSideEffectListener=e.sideEffects.registerAfterChangeHandler("instance",(s,o)=>{s.isFocused!==o.isFocused&&this.updateContainerClass()});const r=e.getInstanceState().isFocused;n!==r&&e.updateInstanceState({isFocused:!!n}),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 Mc(t){return yJ}class mJ{constructor(){I(this,"length",0);I(this,"head",null);I(this,"tail",this)}push(e){return new Ab(e,this)}toArray(){return fo}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const yJ=new mJ;class Ab{constructor(e,n){I(this,"length");this.head=e,this.tail=n,this.length=n.length+1}push(e){return new Ab(e,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let e=this;return{next(){if(e.length){const n=e.head;return e=e.tail,{value:n,done:!1}}else return{value:void 0,done:!0}}}}}class SJ{constructor(e){I(this,"store");I(this,"dispose");I(this,"state","recording");I(this,"pendingDiff",new xJ);I(this,"stacks",It("HistoryManager.stacks",{undos:Mc(),redos:Mc()},{isEqual:(e,n)=>e.undos===n.undos&&e.redos===n.redos}));I(this,"annotateError");I(this,"_isInBatch",!1);this.store=e.store,this.annotateError=e.annotateError??Ru,this.dispose=this.store.addHistoryInterceptor((n,r)=>{if(r==="user")switch(this.state){case"recording":this.pendingDiff.apply(n.changes),this.stacks.update(({undos:s})=>({undos:s,redos:Mc()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(n.changes);break;case"paused":break;default:Ot(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const e=this.pendingDiff.clear();this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"diff",diff:e}),redos:r}))}getNumUndos(){return this.stacks.get().undos.length+(this.pendingDiff.isEmpty()?0:1)}getNumRedos(){return this.stacks.get().redos.length}batch(e,n){const r=this.state;r!=="paused"&&(n!=null&&n.history)&&(this.state=vJ[n.history]);try{if(this._isInBatch)return js(e),this;this._isInBatch=!0;try{js(e)}catch(s){throw this.annotateError(s),s}finally{this._isInBatch=!1}return this}finally{this.state=r}}_undo({pushToRedoStack:e,toMark:n=void 0}){var s;const r=this.state;this.state="paused";try{let{undos:o,redos:i}=this.stacks.get();const a=this.pendingDiff.clear(),l=gA(a),c=px(a);e&&!l&&(i=i.push({type:"diff",diff:a}));let u=!1;if(l)for(;((s=o.head)==null?void 0:s.type)==="stop";){const h=o.head;if(o=o.tail,e&&(i=i.push(h)),h.id===n){u=!0;break}}if(!u)e:for(;o.head;){const h=o.head;switch(o=o.tail,e&&(i=i.push(h)),h.type){case"diff":lu(c,[px(h.diff)]);break;case"stop":if(!n)break e;if(h.id===n){u=!0;break e}break;default:Ot(h)}}if(!u&&n)return this;this.store.applyDiff(c,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:o,redos:i})}finally{this.state=r}return this}undo(){return this._undo({pushToRedoStack:!0}),this}redo(){var n;const e=this.state;this.state="paused";try{this.flushPendingDiff();let{undos:r,redos:s}=this.stacks.get();if(s.length===0)return this;for(;((n=s.head)==null?void 0:n.type)==="stop";)r=r.push(s.head),s=s.tail;const o=bp();for(;s.head;){const i=s.head;if(r=r.push(i),s=s.tail,i.type==="diff")lu(o,[i.diff]);else break}this.store.applyDiff(o,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:r,redos:s})}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 o;let n=this.stacks.get().undos;const r=[];for(;n.head&&!(n.head.type==="stop"&&n.head.id===e);)n.head.type==="diff"&&r.push(n.head.diff),n=n.tail;if(!n.head||((o=n.head)==null?void 0:o.id)!==e)return console.error("Could not find mark to squash to: ",e),this;if(r.length===0)return this;const s=bp();return lu(s,r.reverse()),this.stacks.update(({redos:i})=>({undos:n.push({type:"diff",diff:s}),redos:i})),this}_mark(e){js(()=>{this.flushPendingDiff(),this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"stop",id:e}),redos:r}))})}clear(){this.stacks.set({undos:Mc(),redos:Mc()}),this.pendingDiff.clear()}getMarkIdMatching(e){let n=this.stacks.get().undos;for(;n.head;){if(n.head.type==="stop"&&n.head.id.includes(e))return n.head.id;n=n.tail}return null}debug(){const{undos:e,redos:n}=this.stacks.get();return{undos:e.toArray(),redos:n.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const vJ={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class xJ{constructor(){I(this,"diff",bp());I(this,"isEmptyAtom",It("PendingDiff.isEmpty",!0))}clear(){const e=this.diff;return this.diff=bp(),this.isEmptyAtom.set(!0),e}isEmpty(){return this.isEmptyAtom.get()}apply(e){lu(this.diff,[e]),this.isEmptyAtom.set(gA(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class wJ{constructor(e){I(this,"scribbleItems",new Map);I(this,"state","paused");this.editor=e}addScribble(e,n=ze()){const r={id:n,scribble:{id:n,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(n,r),r}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}stop(e){const n=this.scribbleItems.get(e);if(!n)throw Error(`Scribble with id ${e} not found`);return n.delayRemaining=Math.min(n.delayRemaining,200),n.scribble.state="stopping",n}addPoint(e,n,r,s=.5){const o=this.scribbleItems.get(e);if(!o)throw Error(`Scribble with id ${e} not found`);const{prev:i}=o,a={x:n,y:r,z:s};return(!i||x.Dist(i,a)>=1)&&(o.next=a),o}tick(e){this.scribbleItems.size!==0&&this.editor.run(()=>{this.scribbleItems.forEach(n=>{if(n.scribble.state==="starting"){const{next:l,prev:c}=n;l&&l!==c&&(n.prev=l,n.scribble.points.push(l)),n.scribble.points.length>8&&(n.scribble.state="active");return}n.delayRemaining>0&&(n.delayRemaining=Math.max(0,n.delayRemaining-e)),n.timeoutMs+=e,n.timeoutMs>=16&&(n.timeoutMs=0);const{delayRemaining:r,timeoutMs:s,prev:o,next:i,scribble:a}=n;switch(a.state){case"active":{i&&i!==o?(n.prev=i,a.points.push(i),r===0&&a.points.length>8&&a.points.shift()):s===0&&(a.points.length>1?a.points.shift():n.delayRemaining=a.delay);break}case"stopping":{if(n.delayRemaining===0&&s===0){if(a.points.length===1){this.scribbleItems.delete(n.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:n})=>({...n,points:[...n.points]})).slice(-5)})})}}var bJ=Object.create,EO=Object.defineProperty,PJ=Object.getOwnPropertyDescriptor,CJ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),kO=t=>{throw TypeError(t)},TO=(t,e,n)=>e in t?EO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_J=t=>[,,,bJ(null)],MO=["class","method","getter","setter","accessor","field","value","get","set"],AO=t=>t!==void 0&&typeof t!="function"?kO("Function expected"):t,IJ=(t,e,n,r,s)=>({kind:MO[t],name:e,metadata:r,addInitializer:o=>n._?kO("Already initialized"):s.push(AO(o||null))}),EJ=(t,e)=>TO(e,CJ("metadata"),t[3]),kJ=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Gg=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=MO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,PJ(s,n)),y=r.length-1;y>=0;y--)l=IJ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,AO(i)&&(v[g]=i);return v&&EO(s,n,v),s},TJ=(t,e,n)=>TO(t,e+"",n),jO,OO,DO,RO,Ia;const fe=t=>Math.round(t*10**8)/10**8;function to(t,e,n,r,s){const o=t.filter(a=>(r==="forward"?a.startNode.id===e:a.endNode.id===e)&&fe(a.length)===fe(n)&&Gr(a.breadthIntersection[0],a.breadthIntersection[1],s[0],s[1]));if(o.length===0)return[];const i=new Set;return o.forEach(a=>{const l=r==="forward"?a.endNode.id:a.startNode.id;if(!i.has(l)){i.add(l);const c=to(t,l,n,r,Gr(a.breadthIntersection[0],a.breadthIntersection[1],s[0],s[1]));o.push(...c)}}),o}function MJ(t){t.sort((e,n)=>n.gaps.length-e.gaps.length);for(let e=t.length-1;e>0;e--){const n=t[e];for(let r=e-1;r>=0;r--){const s=t[r];if(s.direction===n.direction&&n.gaps.every(o=>s.gaps.some(i=>fe(o.startEdge[0].x)===fe(i.startEdge[0].x)&&fe(o.startEdge[0].y)===fe(i.startEdge[0].y)&&fe(o.startEdge[1].x)===fe(i.startEdge[1].x)&&fe(o.startEdge[1].y)===fe(i.startEdge[1].y))&&s.gaps.some(i=>fe(o.endEdge[0].x)===fe(i.endEdge[0].x)&&fe(o.endEdge[0].y)===fe(i.endEdge[0].y)&&fe(o.endEdge[1].x)===fe(i.endEdge[1].x)&&fe(o.endEdge[1].y)===fe(i.endEdge[1].y)))){t.splice(e,1);break}}}}RO=[G],DO=[G],OO=[G],jO=[G];class rc{constructor(e){this.manager=e,kJ(Ia,5,this),TJ(this,"editor"),this.editor=e.editor}getSnapPointsCache(){const{editor:e}=this;return e.store.createComputedCache("snapPoints",n=>{const r=e.getShapePageTransform(n.id);if(!r)return;const o=e.getShapeUtil(n).getBoundsSnapGeometry(n).points??e.getShapeGeometry(n).bounds.cornersAndCenter;if(!(!r||!o))return o.map((i,a)=>{const{x:l,y:c}=q.applyToPoint(r,i);return{x:l,y:c,id:`${n.id}:${a}`}})})}getSnapPoints(e){return this.getSnapPointsCache().get(e)??[]}getSnappablePoints(){const e=this.getSnapPointsCache(),n=this.manager.getSnappableShapes(),r=[];for(const s of n){const o=e.get(s);o&&r.push(...o)}return r}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),e=>({id:e,pageBounds:zn(this.editor.getShapePageBounds(e))}))}getVisibleGaps(){const e=[],n=[];let r,s;const o=this.getSnappableGapNodes().sort((a,l)=>a.pageBounds.minX-l.pageBounds.minX);for(let a=0;a<o.length;a++){r=o[a];for(let l=a+1;l<o.length;l++)s=o[l],r.pageBounds.maxX<s.pageBounds.minX&&Tc(r.pageBounds.minY,r.pageBounds.maxY,s.pageBounds.minY,s.pageBounds.maxY)&&e.push({startNode:r,endNode:s,startEdge:[new x(r.pageBounds.maxX,r.pageBounds.minY),new x(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new x(s.pageBounds.minX,s.pageBounds.minY),new x(s.pageBounds.minX,s.pageBounds.maxY)],length:s.pageBounds.minX-r.pageBounds.maxX,breadthIntersection:Gr(r.pageBounds.minY,r.pageBounds.maxY,s.pageBounds.minY,s.pageBounds.maxY)})}const i=o.sort((a,l)=>a.pageBounds.minY-l.pageBounds.minY);for(let a=0;a<i.length;a++){r=i[a];for(let l=a+1;l<i.length;l++)s=i[l],r.pageBounds.maxY<s.pageBounds.minY&&Tc(r.pageBounds.minX,r.pageBounds.maxX,s.pageBounds.minX,s.pageBounds.maxX)&&n.push({startNode:r,endNode:s,startEdge:[new x(r.pageBounds.minX,r.pageBounds.maxY),new x(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new x(s.pageBounds.minX,s.pageBounds.minY),new x(s.pageBounds.maxX,s.pageBounds.minY)],length:s.pageBounds.minY-r.pageBounds.maxY,breadthIntersection:Gr(r.pageBounds.minX,r.pageBounds.maxX,s.pageBounds.minX,s.pageBounds.maxX)})}return{horizontal:e,vertical:n}}snapTranslateShapes({lockedAxis:e,initialSelectionPageBounds:n,initialSelectionSnapPoints:r,dragDelta:s}){var v,y;const o=this.manager.getSnapThreshold(),i=this.getSnappablePoints(),a=n.clone().translate(s),l=r.map(({x:S,y:b},P)=>({id:"selection:"+P,x:S+s.x,y:b+s.y})),c=i,u=[],h=[],f=new x(o,o);this.collectPointSnaps({minOffset:f,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:f});const p=new x(e==="x"?0:((v=u[0])==null?void 0:v.nudge)??0,e==="y"?0:((y=h[0])==null?void 0:y.nudge)??0);f.x=0,f.y=0,u.length=0,h.length=0,l.forEach(S=>{S.x+=p.x,S.y+=p.y}),a.translate(p),this.collectPointSnaps({minOffset:f,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:f});const g=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:h}),m=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h});return this.manager.setIndicators([...m,...g]),{nudge:p}}snapResizeShapes({initialSelectionPageBounds:e,dragDelta:n,handle:r,isAspectRatioLocked:s,isResizingFromCenter:o}){var E,k;const i=this.manager.getSnapThreshold(),{box:a,scaleX:l,scaleY:c}=Z.Resize(e,r,o?n.x*2:n.x,o?n.y*2:n.y,s);let u=r;l<0&&(u=Nq(u)),c<0&&(u=Fq(u)),o&&(a.center=e.center);const h=u==="top"||u==="bottom",f=u==="left"||u==="right",p=LI(u,a),g=this.getSnappablePoints(),m=[],v=[],y=new x(i,i);this.collectPointSnaps({minOffset:y,nearestSnapsX:m,nearestSnapsY:v,otherNodeSnapPoints:g,selectionSnapPoints:p});const S=new x(h?0:((E=m[0])==null?void 0:E.nudge)??0,f?0:((k=v[0])==null?void 0:k.nudge)??0);if(s&&zq(u)&&S.len()!==0){const D=m.length&&v.length?Math.abs(S.x)<Math.abs(S.y)?"x":"y":m.length?"x":"y",T=e.aspectRatio;D==="x"?(v.length=0,S.y=S.x/T,(u==="bottom_left"||u==="top_right")&&(S.y=-S.y)):(m.length=0,S.x=S.y*T,(u==="bottom_left"||u==="top_right")&&(S.x=-S.x))}const b=x.Add(n,S),{box:P}=Z.Resize(e,r,o?b.x*2:b.x,o?b.y*2:b.y,s);o&&(P.center=e.center);const C=LI("any",P);m.length=0,v.length=0,y.x=0,y.y=0,this.collectPointSnaps({minOffset:y,nearestSnapsX:m,nearestSnapsY:v,otherNodeSnapPoints:g,selectionSnapPoints:C});const _=this.getPointSnapLines({nearestSnapsX:m,nearestSnapsY:v});return this.manager.setIndicators([..._]),{nudge:S}}collectPointSnaps({selectionSnapPoints:e,otherNodeSnapPoints:n,minOffset:r,nearestSnapsX:s,nearestSnapsY:o}){for(const i of e)for(const a of n){const l=x.Sub(i,a),c=Math.abs(l.x),u=Math.abs(l.y);fe(c)<=fe(r.x)&&(fe(c)<fe(r.x)&&(s.length=0),s.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.x-i.x}),r.x=c),fe(u)<=fe(r.y)&&(fe(u)<fe(r.y)&&(o.length=0),o.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.y-i.y}),r.y=u)}}collectGapSnaps({selectionPageBounds:e,minOffset:n,nearestSnapsX:r,nearestSnapsY:s}){const{horizontal:o,vertical:i}=this.getVisibleGaps();for(const a of o){if(!Tc(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&&fe(Math.abs(c))<=fe(n.x)){fe(Math.abs(c))<fe(n.x)&&(r.length=0),n.x=Math.abs(c);const y={type:"gap_center",gap:a,nudge:c},S=r.find(({type:P})=>P==="gap_center"),b=S&&Gr(a.breadthIntersection[0],a.breadthIntersection[1],S.gap.breadthIntersection[0],S.gap.breadthIntersection[1]);S&&S.gap.length>a.length&&b?r[r.indexOf(S)]=y:(!S||!b)&&r.push(y)}const h=a.startNode.pageBounds.minX-a.length,f=e.maxX,p=h-f;fe(Math.abs(p))<=fe(n.x)&&(fe(Math.abs(p))<fe(n.x)&&(r.length=0),n.x=Math.abs(p),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:p}));const g=a.endNode.pageBounds.maxX+a.length,m=e.minX,v=g-m;fe(Math.abs(v))<=fe(n.x)&&(fe(Math.abs(v))<fe(n.x)&&(r.length=0),n.x=Math.abs(v),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:v}))}for(const a of i){if(!Tc(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&&fe(Math.abs(c))<=fe(n.y)){fe(Math.abs(c))<fe(n.y)&&(s.length=0),n.y=Math.abs(c);const y={type:"gap_center",gap:a,nudge:c},S=s.find(({type:P})=>P==="gap_center"),b=S&&Tc(S.gap.breadthIntersection[0],S.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);S&&S.gap.length>a.length&&b?s[s.indexOf(S)]=y:(!S||!b)&&s.push(y);continue}const h=a.startNode.pageBounds.minY-a.length,f=e.maxY,p=h-f;fe(Math.abs(p))<=fe(n.y)&&(fe(Math.abs(p))<fe(n.y)&&(s.length=0),n.y=Math.abs(p),s.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:p}));const g=a.endNode.pageBounds.maxY+a.length,m=e.minY,v=g-m;fe(Math.abs(v))<=fe(n.y)&&(fe(Math.abs(v))<fe(n.y)&&(s.length=0),n.y=Math.abs(v),s.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:v}))}}getPointSnapLines({nearestSnapsX:e,nearestSnapsY:n}){const r={},s={};if(e.length>0){for(const o of e)if(o.type==="points"){const i=fe(o.points.otherPoint.x);r[i]||(r[i]=[]),r[i].push(o.points)}}if(n.length>0){for(const o of n)if(o.type==="points"){const i=fe(o.points.otherPoint.y);s[i]||(s[i]=[]),s[i].push(o.points)}}return Object.values(r).concat(Object.values(s)).map(o=>({id:ze(),type:"points",points:S0(o.map(i=>x.From(i.otherPoint)).concat(o.map(i=>x.From(i.thisPoint))),(i,a)=>i.equals(a))}))}getGapSnapLines({selectionPageBounds:e,nearestSnapsX:n,nearestSnapsY:r}){const{vertical:s,horizontal:o}=this.getVisibleGaps(),i={top:e.sides[0],right:e.sides[1],bottom:[e.corners[3],e.corners[2]],left:[e.corners[0],e.corners[3]]},a=[];if(n.length>0)for(const l of n){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:h,endNode:f,length:p,endEdge:g}}=l;switch(l.type){case"gap_center":{const m=(p-e.width)/2,v=Gr(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:ze(),gaps:[...to(o,h.id,m,"backward",v),{startEdge:u,endEdge:i.left},{startEdge:i.right,endEdge:g},...to(o,f.id,m,"forward",v)]});break}case"gap_duplicate":{const m=Gr(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:ze(),gaps:l.protrusionDirection==="left"?[{startEdge:i.right,endEdge:u.map(v=>v.clone().addXY(-h.pageBounds.width,0))},{startEdge:u,endEdge:g},...to(o,f.id,p,"forward",m)]:[...to(o,h.id,p,"backward",m),{startEdge:u,endEdge:g},{startEdge:g.map(v=>v.clone().addXY(l.gap.endNode.pageBounds.width,0)),endEdge:i.left}]});break}}}if(r.length>0)for(const l of r){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:h,endNode:f,length:p,endEdge:g}}=l;switch(l.type){case"gap_center":{const m=(p-e.height)/2,v=Gr(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:ze(),gaps:[...to(s,h.id,m,"backward",v),{startEdge:u,endEdge:i.top},{startEdge:i.bottom,endEdge:g},...to(s,l.gap.endNode.id,m,"forward",v)]});break}case"gap_duplicate":{const m=Gr(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:ze(),gaps:l.protrusionDirection==="top"?[{startEdge:i.bottom,endEdge:u.map(v=>v.clone().addXY(0,-h.pageBounds.height))},{startEdge:u,endEdge:g},...to(s,f.id,p,"forward",m)]:[...to(s,h.id,p,"backward",m),{startEdge:u,endEdge:g},{startEdge:g.map(v=>v.clone().addXY(0,f.pageBounds.height)),endEdge:i.top}]})}break}}return MJ(a),a}}Ia=_J();Gg(Ia,1,"getSnapPointsCache",RO,rc);Gg(Ia,1,"getSnappablePoints",DO,rc);Gg(Ia,1,"getSnappableGapNodes",OO,rc);Gg(Ia,1,"getVisibleGaps",jO,rc);EJ(Ia,rc);function LI(t,e){const{minX:n,maxX:r,minY:s,maxY:o}=e,i=[];switch(t){case"top":case"left":case"top_left":case"any":i.push({id:"top_left",handle:"top_left",x:n,y:s})}switch(t){case"top":case"right":case"top_right":case"any":i.push({id:"top_right",handle:"top_right",x:r,y:s})}switch(t){case"bottom":case"right":case"bottom_right":case"any":i.push({id:"bottom_right",handle:"bottom_right",x:r,y:o})}switch(t){case"bottom":case"left":case"bottom_left":case"any":i.push({id:"bottom_left",handle:"bottom_left",x:n,y:o})}return i}var AJ=Object.create,LO=Object.defineProperty,jJ=Object.getOwnPropertyDescriptor,OJ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),$O=t=>{throw TypeError(t)},FO=(t,e,n)=>e in t?LO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,DJ=t=>[,,,AJ(null)],NO=["class","method","getter","setter","accessor","field","value","get","set"],zO=t=>t!==void 0&&typeof t!="function"?$O("Function expected"):t,RJ=(t,e,n,r,s)=>({kind:NO[t],name:e,metadata:r,addInitializer:o=>n._?$O("Already initialized"):s.push(zO(o||null))}),LJ=(t,e)=>FO(e,OJ("metadata"),t[3]),$J=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},FJ=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=NO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,jJ(s,n)),y=r.length-1;y>=0;y--)l=RJ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,zO(i)&&(v[g]=i);return v&&LO(s,n,v),s},NJ=(t,e,n)=>FO(t,e+"",n),BO,Vg;const zJ=()=>null,BJ=()=>[];BO=[G];class jb{constructor(e){this.manager=e,$J(Vg,5,this),NJ(this,"editor"),this.editor=e.editor}getSnapGeometryCache(){const{editor:e}=this;return e.store.createComputedCache("handle snap geometry",n=>{const r=e.getShapeUtil(n).getHandleSnapGeometry(n),s=r.getSelfSnapOutline?r.getSelfSnapOutline.bind(r):zJ,o=r.getSelfSnapPoints?r.getSelfSnapPoints.bind(r):BJ;return{outline:r.outline===void 0?e.getShapeGeometry(n):r.outline,points:r.points??[],getSelfSnapOutline:s,getSelfSnapPoints:o}})}*iterateSnapPointsInPageSpace(e,n){var s,o;const r=(s=this.getSnapGeometryCache().get(e))==null?void 0:s.getSelfSnapPoints(n);if(r&&r.length){const i=zn(this.editor.getShapePageTransform(e));for(const a of r)yield i.applyToPoint(a)}for(const i of this.manager.getSnappableShapes()){if(i===e)continue;const a=(o=this.getSnapGeometryCache().get(i))==null?void 0:o.points;if(!a||!a.length)continue;const l=zn(this.editor.getShapePageTransform(i));for(const c of a)yield l.applyToPoint(c)}}*iterateSnapOutlines(e,n){var s,o;const r=(s=this.getSnapGeometryCache().get(e))==null?void 0:s.getSelfSnapOutline(n);r&&(yield{shapeId:e,outline:r});for(const i of this.manager.getSnappableShapes()){if(i===e)continue;const a=(o=this.getSnapGeometryCache().get(i))==null?void 0:o.outline;a&&(yield{shapeId:i,outline:a})}}getHandleSnapPosition({currentShapeId:e,handle:n,handleInPageSpace:r}){const s=this.manager.getSnapThreshold();let o=s,i=null;for(const c of this.iterateSnapPointsInPageSpace(e,n))x.DistMin(r,c,o)&&(o=x.Dist(r,c),i=c);if(i)return i;let a=s,l=null;for(const{shapeId:c,outline:u}of this.iterateSnapOutlines(e,n)){const h=zn(this.editor.getShapePageTransform(c)),f=this.editor.getPointInShapeSpace(c,r),p=u.nearestPoint(f),g=h.applyToPoint(p);x.DistMin(r,g,a)&&(a=x.Dist(r,g),l=g)}return l||null}snapHandle({currentShapeId:e,handle:n}){const s=zn(this.editor.getShapePageTransform(e)).applyToPoint(n),o=this.getHandleSnapPosition({currentShapeId:e,handle:n,handleInPageSpace:s});return o?(this.manager.setIndicators([{id:ze(),type:"points",points:[o]}]),{nudge:x.Sub(o,s)}):null}}Vg=DJ();FJ(Vg,1,"getSnapGeometryCache",BO,jb);LJ(Vg,jb);var UJ=Object.create,UO=Object.defineProperty,HJ=Object.getOwnPropertyDescriptor,KJ=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),HO=t=>{throw TypeError(t)},KO=(t,e,n)=>e in t?UO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,WJ=t=>[,,,UJ(null)],WO=["class","method","getter","setter","accessor","field","value","get","set"],GO=t=>t!==void 0&&typeof t!="function"?HO("Function expected"):t,GJ=(t,e,n,r,s)=>({kind:WO[t],name:e,metadata:r,addInitializer:o=>n._?HO("Already initialized"):s.push(GO(o||null))}),VJ=(t,e)=>KO(e,KJ("metadata"),t[3]),YJ=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Ob=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=WO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,HJ(s,n)),y=r.length-1;y>=0;y--)l=GJ(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,GO(i)&&(v[g]=i);return v&&UO(s,n,v),s},eS=(t,e,n)=>KO(t,typeof e!="symbol"?e+"":e,n),VO,YO,XO,sc;XO=[G],YO=[G],VO=[G];class Sd{constructor(e){this.editor=e,YJ(sc,5,this),eS(this,"shapeBounds"),eS(this,"handles"),eS(this,"_snapIndicators",It("snapLines",void 0)),this.shapeBounds=new rc(this),this.handles=new jb(this)}getIndicators(){return this._snapIndicators.get()??fo}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,n=e.getViewportPageBounds(),r=e.getSelectedShapeIds(),s=new Set,o=i=>{if(Fn(i)){const l=e.getShape(i);l&&e.isShapeOfType(l,"frame")&&s.add(i)}const a=e.getSortedChildIdsForParent(i);for(const l of a){if(r.includes(l))continue;const c=e.getShape(l);if(!c||!e.getShapeUtil(c).canSnap(c))continue;const h=e.getShapePageBounds(l);if(h&&n.includes(h)){if(e.isShapeOfType(c,"group")){o(l);continue}s.add(l)}}};return o(this.getCurrentCommonAncestor()??e.getCurrentPageId()),s}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}sc=WJ();Ob(sc,1,"getSnapThreshold",XO,Sd);Ob(sc,1,"getSnappableShapes",YO,Sd);Ob(sc,1,"getCurrentCommonAncestor",VO,Sd);VJ(sc,Sd);const XJ=/\r?\n|\r/g;function $I(t){return t.replace(XJ,`
|
|
102
|
-
`).split(`
|
|
103
|
-
`).map(e=>e||" ").join(`
|
|
104
|
-
`)}const qJ={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},ZJ=/\s/;class QJ{constructor(e){I(this,"baseElem");this.editor=e,this.baseElem=document.createElement("div"),this.baseElem.classList.add("tl-text"),this.baseElem.classList.add("tl-text-measure"),this.baseElem.tabIndex=-1}measureText(e,n){const r=this.baseElem.cloneNode();this.editor.getContainer().appendChild(r),r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-style",n.fontStyle),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("font-size",n.fontSize+"px"),r.style.setProperty("line-height",n.lineHeight*n.fontSize+"px"),r.style.setProperty("max-width",n.maxWidth===null?null:n.maxWidth+"px"),r.style.setProperty("min-width",n.minWidth===null?null:n.minWidth+"px"),r.style.setProperty("padding",n.padding),r.style.setProperty("overflow-wrap",n.disableOverflowWrapBreaking?"normal":"break-word"),r.textContent=$I(e);const s=r.scrollWidth,o=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:o.width,h:o.height,scrollWidth:s}}measureElementTextNodeSpans(e,{shouldTruncateToFirstLine:n=!1}={}){const r=[],s=e.getBoundingClientRect(),o=-s.left,i=-s.top,a=new Range,l=e.childNodes[0];let c=0,u=null,h=null,f=0,p=0,g=!1;for(const m of e.childNodes)if(m.nodeType===Node.TEXT_NODE)for(const v of m.textContent??""){a.setStart(l,c),a.setEnd(l,c+v.length);const y=a.getClientRects(),S=y[y.length-1],b=S.top+i,P=S.left+o,C=S.right+o,_=P<p,E=ZJ.test(v);if(E!==h||b!==f||!u){if(u){if(n&&b!==f){g=!0;break}r.push(u)}u={box:{x:P,y:b,w:S.width,h:S.height},text:v},p=P}else _&&(u.box.x=P),u.box.w=_?u.box.w+S.width:C-u.box.x,u.text+=v;v===`
|
|
105
|
-
`&&(p=0),h=E,f=b,c+=v.length}return u&&r.push(u),{spans:r,didTruncate:g}}measureTextSpans(e,n){if(e==="")return[];const r=this.baseElem.cloneNode();this.editor.getContainer().appendChild(r);const s=Math.ceil(n.width-n.padding*2);r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("width",`${s}px`),r.style.setProperty("height","min-content"),r.style.setProperty("font-size",`${n.fontSize}px`),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("line-height",`${n.lineHeight*n.fontSize}px`),r.style.setProperty("text-align",qJ[n.textAlign]);const o=n.overflow==="truncate-ellipsis"||n.overflow==="truncate-clip";o&&(r.style.setProperty("overflow-wrap","anywhere"),r.style.setProperty("word-break","break-all"));const i=$I(e);r.textContent=i;const{spans:a,didTruncate:l}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:o});if(n.overflow==="truncate-ellipsis"&&l){r.textContent="…";const c=Math.ceil(this.measureElementTextNodeSpans(r).spans[0].box.w);r.style.setProperty("width",`${s-c}px`),r.textContent=i;const u=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:!0}).spans,h=u[u.length-1];return u.push({text:"…",box:{x:Math.min(h.box.x+h.box.w,n.width-n.padding-c),y:h.box.y,w:c,h:h.box.h}}),u}return r.remove(),a}}var JJ=Object.create,qO=Object.defineProperty,eee=Object.getOwnPropertyDescriptor,tee=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ZO=t=>{throw TypeError(t)},QO=(t,e,n)=>e in t?qO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,nee=t=>[,,,JJ(null)],JO=["class","method","getter","setter","accessor","field","value","get","set"],eD=t=>t!==void 0&&typeof t!="function"?ZO("Function expected"):t,ree=(t,e,n,r,s)=>({kind:JO[t],name:e,metadata:r,addInitializer:o=>n._?ZO("Already initialized"):s.push(eD(o||null))}),see=(t,e)=>QO(e,tee("metadata"),t[3]),oee=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},tD=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=JO[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,eee(s,n)),y=r.length-1;y>=0;y--)l=ree(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,eD(i)&&(v[g]=i);return v&&qO(s,n,v),s},vh=(t,e,n)=>QO(t,typeof e!="symbol"?e+"":e,n),nD,rD,vd;const FI=nM;rD=[Kn],nD=[Kn];class Yg{constructor(e){this.editor=e,oee(vd,5,this),vh(this,"cancelRaf"),vh(this,"isPaused",!0),vh(this,"now",0),vh(this,"prevPoint",new x),this.editor.disposables.add(this.dispose),this.start()}start(){var e;this.isPaused=!1,(e=this.cancelRaf)==null||e.call(this),this.cancelRaf=FI(this.tick),this.now=Date.now()}tick(){if(this.isPaused)return;const e=Date.now(),n=e-this.now;this.now=e,this.updatePointerVelocity(n),this.editor.emit("frame",n),this.editor.emit("tick",n),this.cancelRaf=FI(this.tick)}dispose(){var e;this.isPaused=!0,(e=this.cancelRaf)==null||e.call(this)}updatePointerVelocity(e){const{prevPoint:n,editor:{inputs:{currentScreenPoint:r,pointerVelocity:s}}}=this;if(e===0)return;const o=x.Sub(r,n);this.prevPoint=r.clone();const i=o.len(),a=i?o.div(i):new x(0,0),l=s.clone().lrp(a.mul(i/e),.5);Math.abs(l.x)<.01&&(l.x=0),Math.abs(l.y)<.01&&(l.y=0),s.equals(l)||(this.editor.inputs.pointerVelocity=l)}}vd=nee();tD(vd,1,"tick",rD,Yg);tD(vd,1,"dispose",nD,Yg);see(vd,Yg);var iee=Object.create,sD=Object.defineProperty,aee=Object.getOwnPropertyDescriptor,lee=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),oD=t=>{throw TypeError(t)},iD=(t,e,n)=>e in t?sD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,cee=t=>[,,,iee(null)],aD=["class","method","getter","setter","accessor","field","value","get","set"],lD=t=>t!==void 0&&typeof t!="function"?oD("Function expected"):t,uee=(t,e,n,r,s)=>({kind:aD[t],name:e,metadata:r,addInitializer:o=>n._?oD("Already initialized"):s.push(lD(o||null))}),dee=(t,e)=>iD(e,lee("metadata"),t[3]),hee=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Nr=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=aD[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,aee(s,n)),y=r.length-1;y>=0;y--)l=uee(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,lD(i)&&(v[g]=i);return v&&sD(s,n,v),s},NI=(t,e,n)=>iD(t,typeof e!="symbol"?e+"":e,n),cD,uD,dD,hD,fD,pD,gD,mD,yD,SD,vD,xD,Mn;xD=[G],vD=[G],SD=[G],yD=[G],mD=[G],gD=[G],pD=[G],fD=[G],hD=[G],dD=[G],uD=[G],cD=[G];class Qn{constructor(e,n){if(this.user=e,this.inferDarkMode=n,hee(Mn,5,this),NI(this,"systemColorScheme",It("systemColorScheme","light")),NI(this,"disposables",new Set),typeof window>"u"||!("matchMedia"in window))return;const r=window.matchMedia("(prefers-color-scheme: dark)");r!=null&&r.matches&&this.systemColorScheme.set("dark");const s=o=>{o.matches?this.systemColorScheme.set("dark"):this.systemColorScheme.set("light")};r==null||r.addEventListener("change",s),this.disposables.add(()=>r==null?void 0:r.removeEventListener("change",s))}dispose(){this.disposables.forEach(e=>e())}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??vs.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??vs.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??vs.name}getLocale(){return this.user.userPreferences.get().locale??vs.locale}getColor(){return this.user.userPreferences.get().color??vs.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??vs.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??vs.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??vs.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??vs.isPasteAtCursorMode}}Mn=cee();Nr(Mn,1,"getUserPreferences",xD,Qn);Nr(Mn,1,"getIsDarkMode",vD,Qn);Nr(Mn,1,"getEdgeScrollSpeed",SD,Qn);Nr(Mn,1,"getAnimationSpeed",yD,Qn);Nr(Mn,1,"getId",mD,Qn);Nr(Mn,1,"getName",gD,Qn);Nr(Mn,1,"getLocale",pD,Qn);Nr(Mn,1,"getColor",fD,Qn);Nr(Mn,1,"getIsSnapMode",hD,Qn);Nr(Mn,1,"getIsWrapMode",dD,Qn);Nr(Mn,1,"getIsDynamicResizeMode",uD,Qn);Nr(Mn,1,"getIsPasteAtCursorMode",cD,Qn);dee(Mn,Qn);const fee={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"},pee=["brushing","cropping","dragging","dragging_handle","drawing","erasing","lasering","resizing","rotating","scribble_brushing","translating"];class ie{constructor(e,n){I(this,"performanceTracker");I(this,"id");I(this,"type");I(this,"shapeType");I(this,"initial");I(this,"children");I(this,"isLockable");I(this,"parent");I(this,"_path");I(this,"_current");I(this,"_isActive");I(this,"_currentToolIdMask",It("curent tool id mask",void 0));this.editor=e;const{id:r,children:s,initial:o,isLockable:i}=this.constructor;this.id=r,this._isActive=It("toolIsActive"+this.id,!1),this._current=It("toolState"+this.id,void 0),this._path=G("toolPath"+this.id,()=>{const a=this.getCurrent();return this.id+(a?`.${a.getPath()}`:"")}),this.parent=n??{},this.parent?s&&o?(this.type="branch",this.initial=o,this.children=Object.fromEntries(s().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",s&&o&&(this.initial=o,this.children=Object.fromEntries(s().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=i,this.performanceTracker=new RT}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}transition(e,n={}){var o;const r=e.split(".");let s=this;for(let i=0;i<r.length;i++){const a=r[i],l=s.getCurrent(),c=(o=s.children)==null?void 0:o[a];if(!c)throw Error(`${s.id} - no child state exists with the id ${a}.`);if((l==null?void 0:l.id)!==c.id&&(l==null||l.exit(n,a),s._current.set(c),c.enter(n,(l==null?void 0:l.id)||"initial"),!c.getIsActive()))break;s=c}return this}handleEvent(e){var s;const n=fee[e.name],r=this._current.__unsafe__getWithoutCapture();(s=this[n])==null||s.call(this,e),this._isActive.__unsafe__getWithoutCapture()&&r&&r===this._current.__unsafe__getWithoutCapture()&&r.handleEvent(e)}enter(e,n){var r;if(wt.measurePerformance.get()&&pee.includes(this.id)&&this.performanceTracker.start(this.id),this._isActive.set(!0),(r=this.onEnter)==null||r.call(this,e,n),this.children&&this.initial&&this.getIsActive()){const s=this.children[this.initial];this._current.set(s),s.enter(e,n)}}exit(e,n){var r,s;wt.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this._isActive.set(!1),(r=this.onExit)==null||r.call(this,e,n),this.getIsActive()||(s=this.getCurrent())==null||s.exit(e,n)}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(e){this._currentToolIdMask.set(e)}}I(ie,"id"),I(ie,"initial"),I(ie,"children"),I(ie,"isLockable",!0);class Mx extends ie{static children(){return[]}onKeyDown(e){var n;switch(e.code){case"KeyZ":{if(!(e.shiftKey||e.ctrlKey)){const r=this.getCurrent();r&&((n=r.getCurrent())==null?void 0:n.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...e,onInteractionEnd:r.id})}break}}}}I(Mx,"id","root"),I(Mx,"initial","");var gee=Object.create,wD=Object.defineProperty,mee=Object.getOwnPropertyDescriptor,bD=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),PD=t=>{throw TypeError(t)},CD=(t,e,n)=>e in t?wD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,yee=t=>[,,,gee((t==null?void 0:t[bD("metadata")])??null)],_D=["class","method","getter","setter","accessor","field","value","get","set"],ID=t=>t!==void 0&&typeof t!="function"?PD("Function expected"):t,See=(t,e,n,r,s)=>({kind:_D[t],name:e,metadata:r,addInitializer:o=>n._?PD("Already initialized"):s.push(ID(o||null))}),vee=(t,e)=>CD(e,bD("metadata"),t[3]),xee=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},ee=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=_D[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,mee(s,n)),y=r.length-1;y>=0;y--)l=See(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,ID(i)&&(v[g]=i);return v&&wD(s,n,v),s},he=(t,e,n)=>CD(t,typeof e!="symbol"?e+"":e,n),ED,kD,TD,MD,AD,jD,OD,DD,RD,LD,$D,FD,ND,zD,BD,UD,HD,KD,WD,GD,VD,YD,XD,qD,ZD,QD,JD,eR,tR,nR,rR,sR,oR,iR,aR,lR,cR,uR,dR,hR,fR,pR,gR,mR,yR,SR,vR,xR,wR,bR,PR,CR,_R,IR,ER,kR,TR,MR,AR,jR,OR,DR,RR,LR,$R,FR,NR,zR,BR,UR,HR,KR,Ax,J;class Q extends(Ax=UZ,KR=[G],HR=[G],UR=[G],BR=[G],zR=[G],NR=[G],FR=[G],$R=[G],LR=[G],RR=[G],DR=[G],OR=[G],jR=[G],AR=[G],MR=[G],TR=[G],kR=[G],ER=[G],IR=[G],_R=[G],CR=[G],PR=[G],bR=[G],wR=[G],xR=[G],vR=[G],SR=[G],yR=[G],mR=[G],gR=[G],pR=[G],fR=[G],hR=[G],dR=[G],uR=[G],cR=[G],lR=[G],aR=[G],iR=[G],oR=[G],sR=[G],rR=[G],nR=[G],tR=[G],eR=[G],JD=[G],QD=[G],ZD=[G],qD=[G],XD=[G],YD=[G],VD=[G],GD=[G],WD=[G],KD=[G],HD=[G],UD=[G],BD=[G],zD=[G],ND=[G],FD=[G],$D=[G],LD=[G],RD=[G],DD=[G({isEqual:(e,n)=>e.equals(n)})],OD=[G],jD=[G],AD=[G],MD=[Kn],TD=[Kn],kD=[Kn],ED=[Kn],Ax){constructor({store:e,user:n,shapeUtils:r,bindingUtils:s,tools:o,getContainer:i,cameraOptions:a,initialState:l,autoFocus:c,inferDarkMode:u,options:h,isShapeHidden:f}){var D;super(),xee(J,5,this),he(this,"_isShapeHiddenPredicate"),he(this,"options"),he(this,"contextId",ze()),he(this,"store"),he(this,"root"),he(this,"disposables",new Set),he(this,"isDisposed",!1),he(this,"_tickManager"),he(this,"snaps"),he(this,"timers",kx.forContext(this.contextId)),he(this,"user"),he(this,"textMeasure"),he(this,"environment",Ge),he(this,"scribbles"),he(this,"sideEffects"),he(this,"edgeScrollManager"),he(this,"focusManager"),he(this,"getContainer"),he(this,"shapeUtils"),he(this,"styleProps"),he(this,"bindingUtils"),he(this,"history"),he(this,"_shouldIgnoreShapeLock",!1),he(this,"_crashingError",null),he(this,"_isChangingStyleTimeout",-1),he(this,"menus",Vr.forContext(this.contextId)),he(this,"_cameraOptions",It("camera options",sI)),he(this,"_viewportAnimation",null),he(this,"_willSetInitialBounds",!0),he(this,"_isLockedOnFollowingUser",It("isLockedOnFollowingUser",!1)),he(this,"_cameraState",It("camera state","idle")),he(this,"_cameraStateTimeoutRemaining",0),he(this,"_currentPageShapeIds"),he(this,"_parentIdsToChildIds"),he(this,"animatingShapes",new Map),he(this,"externalAssetContentHandlers",{file:null,url:null}),he(this,"temporaryAssetPreview",new Map),he(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null}),he(this,"inputs",{originPagePoint:new x,originScreenPoint:new x,previousPagePoint:new x,previousScreenPoint:new x,currentPagePoint:new x,currentScreenPoint:new x,keys:new Set,buttons:new Set,isPen:!1,shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1,isDragging:!1,isPointing:!1,isPinching:!1,isEditing:!1,isPanning:!1,isSpacebarPanning:!1,pointerVelocity:new x}),he(this,"_clickManager",new Wg(this)),he(this,"_prevCursor","default"),he(this,"_shiftKeyTimeout",-1),he(this,"_altKeyTimeout",-1),he(this,"_ctrlKeyTimeout",-1),he(this,"_metaKeyTimeout",-1),he(this,"_restoreToolId","select"),he(this,"_pinchStart",1),he(this,"_didPinch",!1),he(this,"_selectedShapeIdsAtPointerDown",[]),he(this,"_longPressTimeout",-1),he(this,"capturedPointerId",null),he(this,"performanceTracker"),he(this,"performanceTrackerTimeout",-1),he(this,"_pendingEventsForNextTick",[]),this._isShapeHiddenPredicate=f,this.options={...KQ,...h},this.store=e,this.disposables.add(this.store.dispose.bind(this.store)),this.history=new SJ({store:e,annotateError:T=>{this.annotateError(T,{origin:"history.batch",willCrashApp:!0}),this.crash(T)}}),this.snaps=new Sd(this),this.disposables.add(this.timers.dispose),this._cameraOptions.set({...sI,...a}),this.user=new Qn(n??Uj(),u??!1),this.disposables.add(()=>this.user.dispose()),this.getContainer=i,this.textMeasure=new QJ(this),this._tickManager=new Yg(this);class p extends Mx{}I(p,"initial",l??""),this.root=new p(this),this.root.children={};const g=qj(r),m={},v={},y=new Map;for(const T of g){const j=new T(this);m[T.type]=j;const L=wA(T.props??{});v[T.type]=L;for(const M of L.keys())if(!y.has(M.id))y.set(M.id,M);else if(y.get(M.id)!==M)throw Error(`Multiple style props with id "${M.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=m,this.styleProps=v;const S=Yj(s),b={};for(const T of S){const j=new T(this);b[T.type]=j}this.bindingUtils=b;for(const T of[...o]){if(ns(this.root.children,T.id))throw Error(`Can't override tool with id "${T.id}"`);this.root.children[T.id]=new T(this,this.root)}this.scribbles=new wJ(this);const P=(T,j)=>{let L=null;const M=T.selectedShapeIds.filter(B=>!j.has(B));M.length!==T.selectedShapeIds.length&&(L||(L={...T}),L.selectedShapeIds=M);const O=T.erasingShapeIds.filter(B=>!j.has(B));O.length!==T.erasingShapeIds.length&&(L||(L={...T}),L.erasingShapeIds=O),T.hoveredShapeId&&j.has(T.hoveredShapeId)&&(L||(L={...T}),L.hoveredShapeId=null),T.editingShapeId&&j.has(T.editingShapeId)&&(L||(L={...T}),L.editingShapeId=null);const F=T.hintingShapeIds.filter(B=>!j.has(B));return F.length!==T.hintingShapeIds.length&&(L||(L={...T}),L.hintingShapeIds=F),T.focusedGroupId&&j.has(T.focusedGroupId)&&(L||(L={...T}),L.focusedGroupId=null),L};this.sideEffects=this.store.sideEffects;let C=new Map;const _=new Set,E=new Set;let k=new Set;if(this.disposables.add(this.sideEffects.registerOperationCompleteHandler(()=>{var T,j,L,M;_.clear();for(const O of E){E.delete(O);const F=this.getShape(O);if(!F)continue;const B=this.getShapeUtil(F),K=(T=B.onChildrenChange)==null?void 0:T.call(B,F);K!=null&&K.length&&this.updateShapes(K)}if(k.size){const O=k;k=new Set;for(const F of O){const B=this.getBindingUtil(F);(j=B.onOperationComplete)==null||j.call(B)}}if(C.size){const O=C;C=new Map;for(const F of O.values())(M=(L=this.getBindingUtil(F.binding)).onAfterDelete)==null||M.call(L,F)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterChange:(T,j)=>{var L,M,O,F;for(const B of this.getBindingsInvolvingShape(j))k.add(B.type),B.fromId===j.id&&((M=(L=this.getBindingUtil(B)).onAfterChangeFromShape)==null||M.call(L,{binding:B,shapeBefore:T,shapeAfter:j})),B.toId===j.id&&((F=(O=this.getBindingUtil(B)).onAfterChangeToShape)==null||F.call(O,{binding:B,shapeBefore:T,shapeAfter:j}));if(T.parentId!==j.parentId){const B=K=>{var H,X,te,le;const R=this.getShape(K);if(R)for(const de of this.getBindingsInvolvingShape(R))k.add(de.type),de.fromId===R.id&&((X=(H=this.getBindingUtil(de)).onAfterChangeFromShape)==null||X.call(H,{binding:de,shapeBefore:R,shapeAfter:R})),de.toId===R.id&&((le=(te=this.getBindingUtil(de)).onAfterChangeToShape)==null||le.call(te,{binding:de,shapeBefore:R,shapeAfter:R}))};B(j.id),this.visitDescendants(j.id,B)}if(T.parentId!==j.parentId&&Rn(j.parentId)){const B=new Set([T.id]);this.visitDescendants(T.id,K=>{B.add(K)});for(const K of this.getPageStates()){if(K.pageId===j.parentId)continue;const R=P(K,B);R&&this.store.put([R])}}T.parentId&&Fn(T.parentId)&&E.add(T.parentId),j.parentId!==T.parentId&&Fn(j.parentId)&&E.add(j.parentId)},beforeDelete:T=>{var O,F,B,K;if(_.has(T.id))return;T.parentId&&Fn(T.parentId)&&E.add(T.parentId),_.add(T.id);const j=[];for(const R of this.getBindingsInvolvingShape(T)){k.add(R.type),j.push(R.id);const H=this.getBindingUtil(R);R.fromId===T.id?((O=H.onBeforeIsolateToShape)==null||O.call(H,{binding:R,removedShape:T}),(F=H.onBeforeDeleteFromShape)==null||F.call(H,{binding:R,shape:T})):((B=H.onBeforeIsolateFromShape)==null||B.call(H,{binding:R,removedShape:T}),(K=H.onBeforeDeleteToShape)==null||K.call(H,{binding:R,shape:T}))}j.length&&this.deleteBindings(j);const L=new Set([T.id]),M=me(this.getPageStates().map(R=>P(R,L)));M.length&&this.store.put(M)}},binding:{beforeCreate:T=>{var L,M;const j=(M=(L=this.getBindingUtil(T)).onBeforeCreate)==null?void 0:M.call(L,{binding:T});return j||T},afterCreate:T=>{var j,L;k.add(T.type),(L=(j=this.getBindingUtil(T)).onAfterCreate)==null||L.call(j,{binding:T})},beforeChange:(T,j)=>{var M,O;const L=(O=(M=this.getBindingUtil(j)).onBeforeChange)==null?void 0:O.call(M,{bindingBefore:T,bindingAfter:j});return L||j},afterChange:(T,j)=>{var L,M;k.add(j.type),(M=(L=this.getBindingUtil(j)).onAfterChange)==null||M.call(L,{bindingBefore:T,bindingAfter:j})},beforeDelete:T=>{var j,L;(L=(j=this.getBindingUtil(T)).onBeforeDelete)==null||L.call(j,{binding:T})},afterDelete:T=>{var j,L;(L=(j=this.getBindingUtil(T)).onAfterDelete)==null||L.call(j,{binding:T}),k.add(T.type)}},page:{afterCreate:T=>{const j=Is.createId(T.id),L=Qr.createId(T.id);this.store.has(j)||this.store.put([Is.create({id:j})]),this.store.has(L)||this.store.put([Qr.create({id:L,pageId:T.id})])},afterDelete:(T,j)=>{var O,F;if(((O=this.getInstanceState())==null?void 0:O.currentPageId)===T.id){const B=(F=this.getPages().find(K=>K.id!==T.id))==null?void 0:F.id;B?this.store.put([{...this.getInstanceState(),currentPageId:B}]):j==="user"&&this.store.ensureStoreIsUsable()}const L=Is.createId(T.id),M=Qr.createId(T.id);this.store.remove([L,M])}},instance:{afterChange:(T,j,L)=>{var M;if(!this.store.has(j.currentPageId)){const O=this.store.has(T.currentPageId)?T.currentPageId:(M=this.getPages()[0])==null?void 0:M.id;O?this.store.update(j.id,F=>({...F,currentPageId:O})):L==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(T,j)=>{if((T==null?void 0:T.selectedShapeIds)!==(j==null?void 0:j.selectedShapeIds)){const L=j.selectedShapeIds.filter(O=>{var B,K;let F=(B=this.getShape(O))==null?void 0:B.parentId;for(;Fn(F);){if(j.selectedShapeIds.includes(F))return!1;F=(K=this.getShape(F))==null?void 0:K.parentId}return!0});let M=null;if(L.length>0){const O=this.findCommonAncestor(me(L.map(F=>this.getShape(F))),F=>this.isShapeOfType(F,"group"));O&&(M=O)}else j!=null&&j.focusedGroupId&&(M=j.focusedGroupId);(L.length!==j.selectedShapeIds.length||M!==j.focusedGroupId)&&this.store.put([{...j,selectedShapeIds:L,focusedGroupId:M??null}])}}}})),this._currentPageShapeIds=oJ(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=sJ(this.store),this.disposables.add(this.store.listen(T=>{this.emit("change",T)})),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}".`);if(this.root.enter(void 0,"initial"),this.edgeScrollManager=new pJ(this),this.focusManager=new gJ(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 RT,(D=this.store.props.collaboration)!=null&&D.mode){const T=this.store.props.collaboration.mode;this.disposables.add(As("update collaboration mode",()=>{this.store.put([{...this.getInstanceState(),isReadonly:T.get()==="readonly"}])}))}}getIsShapeHiddenCache(){return this._isShapeHiddenPredicate?this.store.createComputedCache("isShapeHidden",e=>this.findShapeAncestor(e,r=>this.isShapeHidden(r))?!0:this._isShapeHiddenPredicate(e,this)??!1):null}isShapeHidden(e){return this._isShapeHiddenPredicate?!!this.getIsShapeHiddenCache().get(typeof e=="string"?e:e.id):!1}dispose(){this.disposables.forEach(e=>e()),this.disposables.clear(),this.isDisposed=!0}getShapeUtil(e){const n=typeof e=="string"?e:e.type,r=hn(this.shapeUtils,n);return Le(r,`No shape util found for type "${n}"`),r}getBindingUtil(e){const n=typeof e=="string"?e:e.type,r=hn(this.bindingUtils,n);return Le(r,`No binding util found for type "${n}"`),r}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??ze()),this}markHistoryStoppingPoint(e){const n=`[${e??"stop"}]_${ze()}`;return this.history._mark(n),n}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,n){const r=this._shouldIgnoreShapeLock;this._shouldIgnoreShapeLock=(n==null?void 0:n.ignoreShapeLock)??r;try{this.history.batch(e,n)}finally{this._shouldIgnoreShapeLock=r}return this}batch(e,n){return this.run(e,n)}annotateError(e,{origin:n,willCrashApp:r,tags:s,extras:o}){const i=this.createErrorAnnotations(n,r);return v0(e,{tags:{...i.tags,...s},extras:{...i.extras,...o}}),r&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(e,n){try{const r=this.getEditingShapeId();return{tags:{origin:e,willCrashApp:n},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes(),editingShape:r?this.getShape(r):void 0,inputs:this.inputs}}}catch{return{tags:{origin:e,willCrashApp:n},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 n=e.split(".").reverse();let r=this.root;for(;n.length>0;){const s=n.pop();if(!s)return!0;const o=r.getCurrent();if((o==null?void 0:o.id)===s){if(n.length===0)return!0;r=o;continue}else return!1}return!1}isInAny(...e){return e.some(n=>this.isIn(n))}setCurrentTool(e,n={}){return this.root.transition(e,n),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const e=this.getCurrentTool();return e?e.getCurrentToolIdMask()??e.id:""}getStateDescendant(e){var s;const n=e.split(".").reverse();let r=this.root;for(;n.length>0;){const o=n.pop();if(!o)return r;const i=(s=r.children)==null?void 0:s[o];if(!i)return;r=i}return r}getDocumentSettings(){return this.store.get(yx)}updateDocumentSettings(e){return this.run(()=>{this.store.put([{...this.getDocumentSettings(),...e}])},{history:"ignore"}),this}getInstanceState(){return this.store.get(bn)}updateInstanceState(e,n){return this._updateInstanceState(e,{history:"ignore",...n}),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,n){this.run(()=>{this.store.put([{...this.getInstanceState(),...e}])},n)}getOpenMenus(){return this.menus.getOpenMenus()}addOpenMenu(e){return this.menus.addOpenMenu(e),this}deleteOpenMenu(e){return this.menus.deleteOpenMenu(e),this}clearOpenMenus(){return this.menus.clearOpenMenus(),this}getIsMenuOpen(){return this.menus.hasAnyOpenMenus()}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 Qr.createId(this.getCurrentPageId())}updateCurrentPageState(e){return this._updateCurrentPageState(e),this}_updateCurrentPageState(e){this.store.update(e.id??this.getCurrentPageState().id,n=>({...n,...e}))}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:e}=this.getCurrentPageState();return me(e.map(n=>this.store.get(n)))}setSelectedShapes(e){return this.run(()=>{const n=e.map(o=>typeof o=="string"?o:o.id),{selectedShapeIds:r}=this.getCurrentPageState(),s=new Set(r);if(n.length===s.size&&n.every(o=>s.has(o)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:n}])},{history:"record-preserveRedoStack"})}isAncestorSelected(e){const n=typeof e=="string"?e:(e==null?void 0:e.id)??null,r=this.getShape(n);if(!r)return!1;const s=this.getSelectedShapeIds();return!!this.findShapeAncestor(r,o=>s.includes(o.id))}select(...e){const n=typeof e[0]=="string"?e:e.map(r=>r.id);return this.setSelectedShapes(n),this}deselect(...e){const n=typeof e[0]=="string"?e:e.map(s=>s.id),r=this.getSelectedShapeIds();return r.length>0&&n.length>0&&this.setSelectedShapes(r.filter(s=>!n.includes(s))),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 n=me(e.map(r=>this.getShapePageBounds(r)));return n.length===0?null:Z.Common(n)}getSelectionPageBounds(){return this.getShapesPageBounds(this.getSelectedShapeIds())}getShapesSharedRotation(e){let n=!1,r=0;for(let s=0,o=e.length;s<o;s++){const i=this.getShapePageTransform(e[s]);if(i)if(n){if(i.rotation()!==r)return 0}else n=!0,r=i.rotation()}return r}getSelectionRotation(){return this.getShapesSharedRotation(this.getSelectedShapeIds())}getShapesRotatedPageBounds(e){if(e.length===0)return;const n=this.getShapesSharedRotation(e);if(n===0)return this.getShapesPageBounds(e)??void 0;if(e.length===1){const s=this.getShapeGeometry(e[0]).bounds.clone(),o=this.getShapePageTransform(e[0]);return s.point=o.applyToPoint(s.point),s}const r=Z.FromPoints(e.flatMap(s=>{const o=this.getShapePageTransform(s);return o?o.applyToPoints(this.getShapeGeometry(s).bounds.corners):[]}).map(s=>s.rot(-n)));return r.point=r.point.rot(n),r}getSelectionRotatedPageBounds(){return this.getShapesRotatedPageBounds(this.getSelectedShapeIds())}getSelectionRotatedScreenBounds(){const e=this.getSelectionRotatedPageBounds();if(!e)return;const{x:n,y:r}=this.pageToScreen(e.point),s=this.getZoomLevel();return new Z(n,r,e.width*s,e.height*s)}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const e=this.getFocusedGroupId();return e?this.getShape(e):void 0}setFocusedGroup(e){const n=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(n!==null){const r=this.getShape(n);if(!r)throw Error(`Editor.setFocusedGroup: Shape with id ${n} does not exist`);if(!this.isShapeOfType(r,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${r.type}`)}return n===this.getFocusedGroupId()?this:this.run(()=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:n}))},{history:"record-preserveRedoStack"})}popFocusedGroupId(){const e=this.getFocusedGroup();if(e){const n=this.findShapeAncestor(e,r=>this.isShapeOfType(r,"group"));this.setFocusedGroup((n==null?void 0:n.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 n=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(n!==this.getEditingShapeId()){if(n){const r=this.getShape(n);if(r&&this.getShapeUtil(r).canEdit(r))return this.run(()=>{this._updateCurrentPageState({editingShapeId:n})},{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 n=typeof e=="string"?e:(e==null?void 0:e.id)??null;return n===this.getHoveredShapeId()?this:(this.run(()=>{this.updateCurrentPageState({hoveredShapeId:n})},{history:"ignore"}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const e=this.getHintingShapeIds();return me(e.map(n=>this.getShape(n)))}setHintingShapes(e){const n=typeof e[0]=="string"?e:e.map(r=>r.id);return this.run(()=>{this._updateCurrentPageState({hintingShapeIds:S0(n)})},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const e=this.getErasingShapeIds();return me(e.map(n=>this.getShape(n)))}setErasingShapes(e){const n=typeof e[0]=="string"?e:e.map(s=>s.id);n.sort();const r=this.getErasingShapeIds();return this.run(()=>{if(n.length===r.length){for(let s=0;s<n.length;s++)if(n[s]!==r[s]){this._updateCurrentPageState({erasingShapeIds:n});break}}else this._updateCurrentPageState({erasingShapeIds:n})},{history:"ignore"}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(e){const n=typeof e=="string"?e:(e==null?void 0:e.id)??null;return n!==this.getCroppingShapeId()&&this.run(()=>{if(!n)this.updateCurrentPageState({croppingShapeId:null});else{const r=this.getShape(n),s=this.getShapeUtil(r);r&&s.canCrop(r)&&this.updateCurrentPageState({croppingShapeId:n})}},{history:"ignore"}),this}_unsafe_getCameraId(){return Is.createId(this.getCurrentPageId())}getCamera(){const e=this.store.get(this._unsafe_getCameraId());if(this._isLockedOnFollowingUser.get()){const n=this.getCameraForFollowing();if(n)return{...e,...n}}return e}getViewportPageBoundsForFollowing(){const e=this.getInstanceState().followingUserId;if(!e)return null;const n=this.getCollaborators().find(h=>h.userId===e);if(!n||!n.camera||!n.screenBounds)return null;const{w:r,h:s}=n.screenBounds,{x:o,y:i,z:a}=n.camera,l=new Z(-o,-i,r/a,s/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:n,zy:r}=BI(this,e);switch(e.constraints.initialZoom){case"fit-min":return Math.max(n,r);case"fit-max":return Math.min(n,r);case"fit-x":return n;case"fit-y":return r;case"fit-min-100":return Math.min(1,Math.max(n,r));case"fit-max-100":return Math.min(1,Math.min(n,r));case"fit-x-100":return Math.min(1,n);case"fit-y-100":return Math.min(1,r);default:throw Ot(e.constraints.initialZoom)}}getBaseZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.baseZoom==="default")return 1;const{zx:n,zy:r}=BI(this,e);switch(e.constraints.baseZoom){case"fit-min":return Math.max(n,r);case"fit-max":return Math.min(n,r);case"fit-x":return n;case"fit-y":return r;case"fit-min-100":return Math.min(1,Math.max(n,r));case"fit-max-100":return Math.min(1,Math.min(n,r));case"fit-x-100":return Math.min(1,n);case"fit-y-100":return Math.min(1,r);default:throw Ot(e.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(e){var r;const n=nt({...this._cameraOptions.__unsafe__getWithoutCapture(),...e});return((r=n.zoomSteps)==null?void 0:r.length)<1&&(n.zoomSteps=[1]),this._cameraOptions.set(n),this.setCamera(this.getCamera()),this}getConstrainedCamera(e,n){const r=this.getCamera();let{x:s,y:o,z:i=r.z}=e;if(!(n!=null&&n.force)){const a=this.getCameraOptions(),l=a.zoomSteps[0],c=Ht(a.zoomSteps),u=this.getViewportScreenBounds();if(a.constraints){const{constraints:h}=a,f=Math.min(h.padding.y,u.w/2),p=Math.min(h.padding.x,u.h/2),g=Z.From(a.constraints.bounds),m=(u.w-p*2)/g.w,v=(u.h-f*2)/g.h,y=this.getBaseZoom(),S=c*y,b=l*y;if(n!=null&&n.reset&&(i=this.getInitialZoom()),i<b||i>S){const{x:L,y:M,z:O}=r,F=-L+u.w/O/2,B=-M+u.h/O/2;i=Bt(i,b,S);const K=-L+u.w/i/2,R=-M+u.h/i/2;s=L+K-F,o=M+R-B}const P=p/i-g.x,C=f/i-g.y,_=(u.w-p*2)/i-g.w,E=(u.h-f*2)/i-g.h,k=P+_*h.origin.x,D=C+E*h.origin.y,T=typeof h.behavior=="string"?h.behavior:h.behavior.x,j=typeof h.behavior=="string"?h.behavior:h.behavior.y;if(n!=null&&n.reset)s=k,o=D;else{switch(T){case"fixed":{s=k;break}case"contain":{i<m?s=k:s=Bt(s,P+_,P);break}case"inside":{i<m?s=Bt(s,P,(u.w-p)/i-g.w):s=Bt(s,P+_,P);break}case"outside":{s=Bt(s,p/i-g.w,(u.w-p)/i);break}case"free":break;default:throw Ot(T)}switch(j){case"fixed":{o=D;break}case"contain":{i<v?o=D:o=Bt(o,C+E,C);break}case"inside":{i<v?o=Bt(o,C,(u.h-f)/i-g.h):o=Bt(o,C+E,C);break}case"outside":{o=Bt(o,f/i-g.h,(u.h-f)/i);break}case"free":break;default:throw Ot(j)}}}else if(i>c||i<l){const{x:h,y:f,z:p}=r;i=Bt(i,l,c),s=h+(-h+u.w/i/2)-(-h+u.w/p/2),o=f+(-f+u.h/i/2)-(-f+u.h/p/2)}}return{x:s,y:o,z:i}}_setCamera(e,n){const r=this.getCamera(),{x:s,y:o,z:i}=this.getConstrainedCamera(e,n);return r.x===s&&r.y===o&&r.z===i?this:(js(()=>{const a={...r,x:s,y:o,z:i};this.run(()=>{this.store.put([a])},{history:"ignore"});const{currentScreenPoint:l,currentPagePoint:c}=this.inputs,{screenBounds:u}=this.store.unsafeGetWithoutCapture(bn);if(l.x/i-s!==c.x||l.y/i-o!==c.y){const h={type:"pointer",target:"canvas",name:"pointer_move",point:x.AddXY(l,u.x,u.y),pointerId:oI.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,metaKey:this.inputs.metaKey,accelKey:un(this.inputs),button:0,isPen:this.getInstanceState().isPenMode??!1};n!=null&&n.immediate?this._flushEventForTick(h):this.dispatch(h)}this._tickCameraState()}),this)}setCamera(e,n){const{isLocked:r}=this._cameraOptions.__unsafe__getWithoutCapture();if(r&&!(n!=null&&n.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const s=x.Cast(e);Number.isFinite(s.x)||(s.x=0),Number.isFinite(s.y)||(s.y=0),(s.z===void 0||!Number.isFinite(s.z))&&(e.z=this.getZoomLevel());const o=this.getConstrainedCamera(s,n);if(n!=null&&n.animation){const{width:i,height:a}=this.getViewportScreenBounds();this._animateToViewport(new Z(-o.x,-o.y,i/o.z,a/o.z),n)}else this._setCamera(o,{...n,force:!0});return this}centerOnPoint(e,n){const{isLocked:r}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;const{width:s,height:o}=this.getViewportPageBounds();return this.setCamera(new x(-(e.x-s/2),-(e.y-o/2),this.getCamera().z),n),this}zoomToFit(e){const n=[...this.getCurrentPageShapeIds()];if(n.length<=0)return this;const r=Z.Common(me(n.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(r,e),this}resetZoom(e=this.getViewportScreenCenter(),n){const{isLocked:r,constraints:s}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;const o=this.getCamera(),{x:i,y:a,z:l}=o,{x:c,y:u}=e;let h=1;if(s){const f=this.getInitialZoom();l!==f&&(h=f)}return this.setCamera(new x(i+(c/h-c)-(c/l-c),a+(u/h-u)-(u/l-u),h),n),this}zoomIn(e=this.getViewportScreenCenter(),n){const{isLocked:r}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;const{x:s,y:o,z:i}=this.getCamera(),{zoomSteps:a}=this.getCameraOptions();if(a!==null&&a.length>1){const l=this.getBaseZoom();let c=Ht(a)*l;for(let u=1;u<a.length;u++){const h=a[u-1]*l,f=a[u]*l;if(!(f-i<=(f-h)/2)){c=f;break}}this.setCamera(new x(s+(e.x/c-e.x)-(e.x/i-e.x),o+(e.y/c-e.y)-(e.y/i-e.y),c),n)}return this}zoomOut(e=this.getViewportScreenCenter(),n){const{isLocked:r}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;const{zoomSteps:s}=this.getCameraOptions();if(s!==null&&s.length>1){const o=this.getBaseZoom(),{x:i,y:a,z:l}=this.getCamera();let c=s[0]*o;for(let u=s.length-1;u>0;u--){const h=s[u-1]*o,f=s[u]*o;if(!(f-l>=(f-h)/2)){c=h;break}}this.setCamera(new x(i+(e.x/c-e.x)-(e.x/l-e.x),a+(e.y/c-e.y)-(e.y/l-e.y),c),n)}return this}zoomToSelection(e){const{isLocked:n}=this.getCameraOptions();if(n&&!(e!=null&&e.force))return this;const r=this.getSelectionPageBounds();return r&&this.zoomToBounds(r,{targetZoom:Math.max(1,this.getZoomLevel()),...e}),this}zoomToBounds(e,n){const r=this._cameraOptions.__unsafe__getWithoutCapture();if(r.isLocked&&!(n!=null&&n.force))return this;const s=this.getViewportScreenBounds(),o=(n==null?void 0:n.inset)??Math.min(bX,s.width*.28),i=this.getBaseZoom(),a=r.zoomSteps[0],l=Ht(r.zoomSteps);let c=Bt(Math.min((s.width-o)/e.w,(s.height-o)/e.h),a*i,l*i);return(n==null?void 0:n.targetZoom)!==void 0&&(c=Math.min(n.targetZoom,c)),this.setCamera(new x(-e.x+(s.width-e.w*c)/2/c,-e.y+(s.height-e.h*c)/2/c,c),n),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(e){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=e;const{elapsed:n,easing:r,duration:s,start:o,end:i}=this._viewportAnimation;if(n>s){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new x(-i.x,-i.y,this.getViewportScreenBounds().width/i.width));return}const a=s-n,l=r(1-a/s),c=o.minX+(i.minX-o.minX)*l,u=o.minY+(i.minY-o.minY)*l,h=o.maxX+(i.maxX-o.maxX)*l;this._setCamera(new x(-c,-u,this.getViewportScreenBounds().width/(h-c)),{force:!0})}_animateToViewport(e,n={animation:Wy}){const{animation:r,...s}=n;if(!r)return;const{duration:o=0,easing:i=Dt.easeInOutCubic}=r,a=this.user.getAnimationSpeed(),l=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),o===0||a===0?this._setCamera(new x(-e.x,-e.y,this.getViewportScreenBounds().width/e.width),{...s}):(this._viewportAnimation={elapsed:0,duration:o/a,easing:i,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:n}=this.getCameraOptions();if(n&&!(e!=null&&e.force))return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:s,friction:o=this.options.cameraSlideFriction,direction:i,speedThreshold:a=.01}=e;let l=Math.min(s,1);const c=()=>{this.off("tick",u),this.off("stop-camera-animation",c)};this.once("stop-camera-animation",c);const u=h=>{const{x:f,y:p,z:g}=this.getCamera(),m=x.Mul(i,l*h/g);l*=1-o,l<a?c():this._setCamera(new x(f+m.x,p+m.y,g))};return this.on("tick",u),this}zoomToUser(e,n={animation:{duration:500}}){const r=this.getCollaborators().find(o=>o.userId===e);if(!r)return this;const s=r.cursor;return s?(this.run(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const o=r.currentPageId===this.getCurrentPageId();o||this.setCurrentPage(r.currentPageId),n&&n.animation&&!o&&(n.animation=void 0),this.centerOnPoint(s,n);const{highlightedUserIds:i}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...i,e]}),this.timers.setTimeout(()=>{const a=[...this.getInstanceState().highlightedUserIds],l=a.indexOf(e);l<0||(a.splice(l,1),this.updateInstanceState({highlightedUserIds:a}))},this.options.collaboratorIdleTimeoutMs)}),this):this}updateViewportScreenBounds(e,n=!1){if(e instanceof HTMLElement){const a=e.getBoundingClientRect();e=new Z(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 r=[e.minY!==0,!di(document.body.scrollWidth,e.maxX,1),!di(document.body.scrollHeight,e.maxY,1),e.minX!==0],{_willSetInitialBounds:s}=this;this._willSetInitialBounds=!1;const{screenBounds:o,insets:i}=this.getInstanceState();if(e.equals(o)&&r.every((a,l)=>a===i[l]))return this;if(s)this.updateInstanceState({screenBounds:e.toJson(),insets:r}),this.setCamera(this.getCamera());else if(n&&!this.getInstanceState().followingUserId){const a=this.getViewportPageBounds().center;this.updateInstanceState({screenBounds:e.toJson(),insets:r}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:e.toJson(),insets:r}),this._setCamera(x.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:e,y:n,w:r,h:s}=this.getInstanceState().screenBounds;return new Z(e,n,r,s)}getViewportScreenCenter(){const e=this.getViewportScreenBounds();return new x(e.midX-e.minX,e.midY-e.minY)}getViewportPageBounds(){const{w:e,h:n}=this.getViewportScreenBounds(),{x:r,y:s,z:o}=this.getCamera();return new Z(-r,-s,e/o,n/o)}screenToPage(e){const{screenBounds:n}=this.store.unsafeGetWithoutCapture(bn),{x:r,y:s,z:o=1}=this.getCamera();return new x((e.x-n.x)/o-r,(e.y-n.y)/o-s,e.z??.5)}pageToScreen(e){const{screenBounds:n}=this.store.unsafeGetWithoutCapture(bn),{x:r,y:s,z:o=1}=this.getCamera();return new x((e.x+r)*o+n.x,(e.y+s)*o+n.y,e.z??.5)}pageToViewport(e){const{x:n,y:r,z:s=1}=this.getCamera();return new x((e.x+n)*s,(e.y+r)*s,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(r=>r.userId))].sort().map(r=>A9(e.filter(o=>o.userId===r),o=>o.lastActivityTimestamp??0)):fo}getCollaboratorsOnCurrentPage(){const e=this.getCurrentPageId();return this.getCollaborators().filter(n=>n.currentPageId===e)}startFollowingUser(e){this.stopFollowingUser();const n=this._getCollaboratorsQuery().get().filter(o=>o.userId===e);if(!n.length)return console.warn("User not found"),this;const r=this.user.getId();if(r||console.warn("You should set the userId for the current instance before following a user"),n.some(o=>o.followingUserId===r))return this;const s=G("latestLeaderPresence",()=>this.getCollaborators().find(o=>o.userId===e));return js(()=>{this.updateInstanceState({followingUserId:e},{history:"ignore"});const o=As("update current page",()=>{const l=s.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"})}),i=()=>{o(),this._isLockedOnFollowingUser.set(!1),this.off("frame",a),this.off("stop-following",i)},a=()=>{if(!s.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 h=this.getViewportPageBounds(),f=Math.abs(u.minX-h.minX)+Math.abs(u.maxX-h.maxX),p=Math.abs(u.minY-h.minY)+Math.abs(u.maxY-h.maxY);if(f<this.options.followChaseViewportSnap&&p<this.options.followChaseViewportSnap){this._isLockedOnFollowingUser.set(!0);return}const g=Bt(c*.5,.1,.8),m=new Z(_e(h.minX,u.minX,g),_e(h.minY,u.minY,g),_e(h.width,u.width,g),_e(h.height,u.height,g)),v=new x(-m.x,-m.y,this.getViewportScreenBounds().width/m.width);this.stopCameraAnimation(),this._setCamera(v)};this.once("stop-following",i),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 n=[];let r=this.options.maxShapesPerPage*2,s=this.options.maxShapesPerPage;const o=this.getErasingShapeIds(),i=(l,c,u)=>{const h=this.getShape(l);if(!h||this.isShapeHidden(h))return;c*=h.opacity;let f=!1;const p=this.getShapeUtil(h);e&&(f=!u&&o.includes(l),f&&(c*=.32)),n.push({id:l,shape:h,util:p,index:r,backgroundIndex:s,opacity:c}),r+=1,s+=1;const g=this.getSortedChildIdsForParent(l);if(!g.length)return;let m=null;p.providesBackgroundForChildren(h)&&(m=s,s=r,r+=this.options.maxShapesPerPage);for(const v of g)i(v,c,u||f);m!==null&&(s=m)},a=e?[this.getCurrentPage()]:this.getPages();for(const l of a)for(const c of this.getSortedChildIdsForParent(l.id))i(c,1,!1);return n}_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(lB)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return Array.from(this._getAllPagesQuery().get()).sort(cn)}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 n=typeof e=="string"?e:e.id,r=this.store.query.exec("shape",{parentId:{eq:n}});return this.getShapeAndDescendantIds(r.map(s=>s.id))}setCurrentPage(e){const n=typeof e=="string"?e:e.id;return this.store.has(n)?(this.stopFollowingUser(),this.complete(),this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:n}]),this.setCamera(this.getCamera())},{history:"record-preserveRedoStack"})):(console.error("Tried to set the current page id to a page that doesn't exist."),this)}updatePage(e){return this.getIsReadonly()?this:this.getPage(e.id)?this.run(()=>this.store.update(e.id,r=>({...r,...e}))):this}createPage(e){return this.run(()=>{if(this.getIsReadonly()||this.getPages().length>=this.options.maxPages)return;const n=this.getPages(),r=qQ(e.name??"Page 1",n.map(i=>i.name));let s=e.index;(!s||n.some(i=>i.index===s))&&(s=_s(n[n.length-1].index));const o=yr.create({meta:{},...e,name:r,index:s});this.store.put([o])}),this}deletePage(e){const n=typeof e=="string"?e:e.id;return this.run(()=>{if(this.getIsReadonly())return;const r=this.getPages();if(r.length===1)return;const s=this.getPage(n);if(s){if(n===this.getCurrentPageId()){const o=r.findIndex(a=>a.id===n),i=r[o-1]??r[o+1];this.setCurrentPage(i.id)}this.store.remove([s.id])}}),this}duplicatePage(e,n=yr.createId()){if(this.getPages().length>=this.options.maxPages)return this;const r=typeof e=="string"?e:e.id,s=this.getPage(r);if(!s)return this;const o={...this.getCamera()},i=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(s.id));return this.run(()=>{var c;const a=this.getPages(),l=$u(s.index,(c=a[a.indexOf(s)+1])==null?void 0:c.index);if(this.createPage({name:s.name+" Copy",id:n,index:l}),this.setCurrentPage(n),this.setCamera(o),i)return this.putContentOntoCurrentPage(i)}),this}renamePage(e,n){const r=typeof e=="string"?e:e.id;return this.getIsReadonly()?this:(this.updatePage({id:r,name:n}),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(e){return this.getIsReadonly()?this:e.length<=0?this:(this.run(()=>this.store.put(e),{history:"ignore"}),this)}updateAssets(e){return this.getIsReadonly()?this:e.length<=0?this:(this.run(()=>{this.store.put(e.map(n=>({...this.store.get(n.id),...n})))},{history:"ignore"}),this)}deleteAssets(e){if(this.getIsReadonly())return this;const n=typeof e[0]=="string"?e:e.map(r=>r.id);return n.length<=0?this:(this.run(()=>this.store.remove(n),{history:"ignore"}),this)}getAsset(e){return this.store.get(typeof e=="string"?e:e.id)}async resolveAssetUrl(e,n){if(!e)return null;const r=this.getAsset(e);if(!r)return null;const{screenScale:s=1,shouldResolveToOriginal:o=!1}=n,a=Math.max(.125,(u=>Math.pow(2,Math.ceil(Math.log2(u))))(s)),l="connection"in navigator?navigator.connection.effectiveType:null,c=this.getInstanceState().devicePixelRatio;return await this.store.props.assets.resolve(r,{screenScale:s||1,steppedScreenScale:a,dpr:c,networkEffectiveType:l,shouldResolveToOriginal:o})}async uploadAsset(e,n,r){return await this.store.props.assets.upload(e,n,r)}_getShapeGeometryCache(){return this.store.createComputedCache("bounds",e=>this.getShapeUtil(e).getGeometry(e),(e,n)=>e.props===n.props)}getShapeGeometry(e){return this._getShapeGeometryCache().get(typeof e=="string"?e:e.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",e=>{var n,r;return(r=(n=this.getShapeUtil(e)).getHandles)==null?void 0:r.call(n,e)})}getShapeHandles(e){return this._getShapeHandlesCache().get(typeof e=="string"?e:e.id)}getShapeLocalTransform(e){const n=typeof e=="string"?e:e.id,r=this.getShape(n);if(!r)throw Error("Editor.getTransform: shape not found");return q.Identity().translate(r.x,r.y).rotate(r.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",e=>{if(Rn(e.parentId))return this.getShapeLocalTransform(e);const n=this._getShapePageTransformCache().get(e.parentId)??q.Identity();return q.Compose(n,this.getShapeLocalTransform(e))})}getShapeParentTransform(e){const n=typeof e=="string"?e:e.id,r=this.getShape(n);return!r||Rn(r.parentId)?q.Identity():this._getShapePageTransformCache().get(r.parentId)??q.Identity()}getShapePageTransform(e){const n=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(n)??q.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",e=>{const n=this._getShapePageTransformCache().get(e.id);return n?Z.FromPoints(q.applyToPoints(n,this.getShapeGeometry(e).vertices)):new Z})}getShapePageBounds(e){return this._getShapePageBoundsCache().get(typeof e=="string"?e:e.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",e=>{const n=this._getShapeMaskCache().get(e.id);if(!n)return;if(n.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const r=this._getShapePageTransformCache().get(e.id);return r?`polygon(${q.applyToPoints(q.Inverse(r),n).map(o=>`${o.x}px ${o.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(Rn(e.parentId))return;const n=this.getShapeAncestors(e.id).filter(s=>this.isShapeOfType(s,"frame"));return n.length===0?void 0:n.map(s=>this._getShapePageTransformCache().get(s.id).applyToPoints(this.getShapeGeometry(s).vertices)).reduce((s,o)=>{if(!(o&&s))return;const i=_I(s,o);return i?i.map(x.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 n=this._getShapePageBoundsCache().get(e.id);if(!n)return;const r=this._getShapeMaskCache().get(e.id);if(r){if(r.length===0)return;const{corners:s}=n;if(s.every((i,a)=>i&&x.Equals(i,r[a])))return n.clone();const o=_I(r,s);return o?Z.FromPoints(o):void 0}return n})}getShapeAncestors(e,n=[]){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return n;const o=s.parentId;if(Rn(o))return n.reverse(),n;const i=this.store.get(o);return i?(n.push(i),this.getShapeAncestors(i,n)):n}findShapeAncestor(e,n){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return;const o=s.parentId;if(Rn(o))return;const i=this.getShape(o);if(i)return n(i)?i:this.findShapeAncestor(i,n)}hasAncestor(e,n){const r=typeof e=="string"?e:e==null?void 0:e.id,s=r&&this.getShape(r);return s?s.parentId===n?!0:this.hasAncestor(this.getShapeParent(s),n):!1}findCommonAncestor(e,n){var l;if(e.length===0)return;const r=typeof e[0]=="string"?e:e.map(c=>c.id),s=me(r.map(c=>this.getShape(c)));if(s.length===1){const c=s[0].parentId;return Rn(c)?void 0:n?(l=this.findShapeAncestor(s[0],n))==null?void 0:l.id:c}const[o,...i]=s;let a=this.getShapeParent(o);for(;a;){if(n&&!n(a)){a=this.getShapeParent(a);continue}if(i.every(c=>this.hasAncestor(c,a.id)))return a.id;a=this.getShapeParent(a)}}isShapeOrAncestorLocked(e){const n=typeof e=="string"?this.getShape(e):e;return n===void 0?!1:n.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(n))}_notVisibleShapes(){return rJ(this)}getCulledShapes(){const e=this._notVisibleShapes().get(),n=this.getSelectedShapeIds(),r=this.getEditingShapeId(),s=new Set(e);return r&&s.delete(r),n.forEach(o=>{s.delete(o)}),s}getCurrentPageBounds(){let e;return this.getCurrentPageShapeIdsSorted().forEach(n=>{const r=this.getShapeMaskedPageBounds(n);r&&(e?e=e.expand(r):e=r.clone())}),e}getSelectedShapeAtPoint(e){const n=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(r=>r.type!=="group"&&n.includes(r.id)).reverse().find(r=>this.isPointInShape(r,e,{hitInside:!0,margin:0}))}getShapeAtPoint(e,n={}){const r=this.getZoomLevel(),s=this.getViewportPageBounds(),{filter:o,margin:i=0,hitLocked:a=!1,hitLabels:l=!1,hitInside:c=!1,hitFrameInside:u=!1}=n;let h=1/0,f=null,p=1/0,g=null;const m=(n.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(v=>{if(v.isLocked&&!a||this.isShapeHidden(v)||this.isShapeOfType(v,"group"))return!1;const y=this.getShapeMask(v);return y&&!hr(e,y)?!1:o?o(v):!0});for(let v=m.length-1;v>=0;v--){const y=m[v],S=this.getShapeGeometry(y),b=S instanceof $r,P=this.getPointInShapeSpace(y,e);if(this.isShapeOfType(y,"frame")||(this.isShapeOfType(y,"arrow")||this.isShapeOfType(y,"geo")&&y.props.fill==="none")&&y.props.text.trim()){for(const _ of S.children)if(_.isLabel&&_.isPointInBounds(P))return y}if(this.isShapeOfType(y,"frame")){const _=S.distanceToPoint(P,c);if(Math.abs(_)<=i)return g||y;if(S.hitTestPoint(P,0,!0))return g||f||(u?y:void 0);continue}let C;if(b){let _=1/0;for(const E of S.children){if(E.isLabel&&!l)continue;const k=E.distanceToPoint(P,c);k<_&&(_=k)}C=_}else i===0&&(S.bounds.w<1||S.bounds.h<1)||S.bounds.containsPoint(P,i)?C=S.distanceToPoint(P,c):C=1/0;if(S.isClosed){if(C<=i){if(S.isFilled||b&&S.children[0].isFilled)return g||y;if(this.getShapePageBounds(y).contains(s))continue;if(Math.abs(C)<i)Math.abs(C)<p&&(p=Math.abs(C),g=y);else if(!g){const{area:_}=S;_<h&&(h=_,f=y)}}}else if(C<this.options.hitTestMargin/r)return y}return g||f||void 0}getShapesAtPoint(e,n={}){return this.getCurrentPageShapes().filter(r=>!this.isShapeHidden(r)&&this.isPointInShape(r,e,n))}isPointInShape(e,n,r={}){const{hitInside:s=!1,margin:o=0}=r,i=typeof e=="string"?e:e.id,a=this.getShapeMask(i);return a&&!hr(n,a)?!1:this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(e,n),o,s)}getPointInShapeSpace(e,n){const r=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(r).clone().invert().applyToPoint(n)}getPointInParentSpace(e,n){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return new x(0,0);if(Rn(s.parentId))return x.From(n);const o=this.getShapePageTransform(s.parentId);return o?o.clone().invert().applyToPoint(n):x.From(n)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),e=>this.store.get(e))}getCurrentPageShapesSorted(){const e=[],n=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let r=0,s=n.length;r<s;r++)WR(this,n[r],e);return e}getCurrentPageRenderingShapesSorted(){const e=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:n})=>!e.has(n)&&!this.isShapeHidden(n))}isShapeOfType(e,n){const r=typeof e=="string"?this.getShape(e):e;return r?r.type===n:!1}getShape(e){const n=typeof e=="string"?e:e.id;if(Fn(n))return this.store.get(n)}getShapeParent(e){const n=typeof e=="string"?e:e==null?void 0:e.id;if(!n)return;const r=this.getShape(n);if(!(r===void 0||!Fn(r.parentId)))return this.store.get(r.parentId)}getShapeNearestSibling(e,n){return n?n.parentId===e.parentId?n:this.findShapeAncestor(n,s=>s.parentId===e.parentId):void 0}isShapeInPage(e,n=this.getCurrentPageId()){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return!1;let o=!1;if(s.parentId===n)o=!0;else{let i=this.getShape(s.parentId);e:for(;i;){if(i.parentId===n){o=!0;break e}i=this.getShape(i.parentId)}}return o}getAncestorPageId(e){const n=typeof e=="string"?e:e==null?void 0:e.id,r=n&&this.getShape(n);if(r)return Rn(r.parentId)?r.parentId:this.getAncestorPageId(this.getShape(r.parentId))}reparentShapes(e,n,r){const s=typeof e[0]=="string"?e:e.map(f=>f.id);if(s.length===0)return this;const o=[],i=Rn(n)?q.Identity():this.getShapePageTransform(n),a=i.rotation();let l=[];const c=me(this.getSortedChildIdsForParent(n).map(f=>this.getShape(f)));if(r){const f=c.find(p=>p.index===r);if(f){const p=c[c.indexOf(f)+1];p?l=Dl(r,p.index,s.length):l=my(r,s.length)}else{const p=c.sort(cn).find(g=>g.index>r);p?l=Dl(r,p.index,s.length):l=my(r,s.length)}}else{const f=c.length&&c[c.length-1];l=f?my(f.index,s.length):Fu(s.length)}const u=i.clone().invert(),h=me(s.map(f=>this.getShape(f)));return this.run(()=>{for(let f=0;f<h.length;f++){const p=h[f],g=this.getShapePageTransform(p);if(!g)continue;const m=g.point();if(!m)continue;const v=u.applyToPoint(m),y=g.rotation()-a;o.push({id:p.id,type:p.type,parentId:n,x:v.x,y:v.y,rotation:y,index:l[f]})}this.updateShapes(o)},{ignoreShapeLock:!0}),this}getHighestIndexForParent(e){const n=typeof e=="string"?e:e.id,r=this._parentIdsToChildIds.get()[n];if(!r||r.length===0)return"a1";const s=this.getShape(r[r.length-1]);return _s(s.index)}getSortedChildIdsForParent(e){const n=typeof e=="string"?e:e.id,r=this._parentIdsToChildIds.get()[n];return r||fo}visitDescendants(e,n){const r=typeof e=="string"?e:e.id,s=this.getSortedChildIdsForParent(r);for(const o of s)n(o)!==!1&&this.visitDescendants(o,n);return this}getShapeAndDescendantIds(e){const n=new Set;for(const r of e.map(s=>this.getShape(s)).sort(cn))n.add(r.id),this.visitDescendants(r,s=>{n.add(s)});return n}getDroppingOverShape(e,n=[]){const r=this.getCurrentPageShapesSorted();for(let s=r.length-1;s>=0;s--){const o=r[s];if(this.isShapeHidden(o)||this.getSelectedShapeIds().includes(o.id)||!this.getShapeUtil(o).canDropShapes(o,n)||n.find(a=>a.id===o.id||this.hasAncestor(o,a.id)))continue;const i=this.getShapeMaskedPageBounds(o.id);if(i&&i.containsPoint(e)&&this.getShapeGeometry(o).hitTestPoint(this.getPointInShapeSpace(o,e),0,!0))return o}}getOutermostSelectableShape(e,n){const r=typeof e=="string"?e:e.id,s=this.getShape(r);let o=s,i=s;const a=this.getFocusedGroup();for(;i;){if(this.isShapeOfType(i,"group")&&(a==null?void 0:a.id)!==i.id&&!this.hasAncestor(a,i.id)&&((n==null?void 0:n(i))??!0))o=i;else if((a==null?void 0:a.id)===i.id)break;i=this.getShapeParent(i)}return o}_getBindingsIndexCache(){const e=tJ(this);return this.store.createComputedCache("bindingsIndex",n=>e.get().get(n.id))}getBinding(e){return this.store.get(e)}getBindingsFromShape(e,n){const r=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(r).filter(s=>s.fromId===r&&s.type===n)}getBindingsToShape(e,n){const r=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(r).filter(s=>s.toId===r&&s.type===n)}getBindingsInvolvingShape(e,n){const r=typeof e=="string"?e:e.id,s=this._getBindingsIndexCache().get(r)??fo;return n?s.filter(o=>o.type===n):s}createBindings(e){const n=[];for(const r of e){const s=this.getShape(r.fromId),o=this.getShape(r.toId);if(!s||!o||!this.canBindShapes({fromShape:s,toShape:o,binding:r}))continue;const a=this.getBindingUtil(r.type).getDefaultProps(),l=this.store.schema.types.binding.create({...r,id:r.id??Ji(),props:{...a,...r.props}});n.push(l)}return this.store.put(n),this}createBinding(e){return this.createBindings([e])}updateBindings(e){const n=[];for(const r of e){if(!r)continue;const s=this.getBinding(r.id);if(!s)continue;const o=ys(s,r);if(o===s)continue;const i=this.getShape(o.fromId),a=this.getShape(o.toId);!i||!a||this.canBindShapes({fromShape:i,toShape:a,binding:o})&&n.push(o)}return this.store.put(n),this}updateBinding(e){return this.updateBindings([e])}deleteBindings(e,{isolateShapes:n=!1}={}){const r=e.map(s=>typeof s=="string"?s:s.id);return n?this.store.atomic(()=>{var s,o;for(const i of r){const a=this.getBinding(i);if(!a)continue;const l=this.getBindingUtil(a);(s=l.onBeforeIsolateFromShape)==null||s.call(l,{binding:a,removedShape:this.getShape(a.toId)}),(o=l.onBeforeIsolateToShape)==null||o.call(l,{binding:a,removedShape:this.getShape(a.fromId)}),this.store.remove([i])}}):this.store.remove(r),this}deleteBinding(e,n){return this.deleteBindings([e],n)}canBindShapes({fromShape:e,toShape:n,binding:r}){const s=typeof e=="string"?e:e.type,o=typeof n=="string"?n:n.type,i=typeof r=="string"?r:r.type,a={fromShapeType:s,toShapeType:o,bindingType:i};return s===o?this.getShapeUtil(s).canBind(a):this.getShapeUtil(s).canBind(a)&&this.getShapeUtil(o).canBind(a)}rotateShapesBy(e,n,r){const s=typeof e[0]=="string"?e:e.map(i=>i.id);if(s.length<=0)return this;const o=SO({editor:this,ids:s});return o?(hf({delta:n,snapshot:o,editor:this,stage:"one-off",centerOverride:r==null?void 0:r.center}),this):this}getChangesToTranslateShape(e,n){var o,i,a;let r=e;const s=this.getShapeUtil(e);return r=ys(r,((o=s.onTranslateStart)==null?void 0:o.call(s,r))??void 0),r=ys(r,{id:e.id,type:e.type,x:n.x,y:n.y}),r=ys(r,((i=s.onTranslate)==null?void 0:i.call(s,e,r))??void 0),r=ys(r,((a=s.onTranslateEnd)==null?void 0:a.call(s,e,r))??void 0),r}nudgeShapes(e,n){const r=typeof e[0]=="string"?e:e.map(o=>o.id);if(r.length<=0)return this;const s=[];for(const o of r){const i=this.getShape(o),a=x.From(n),l=this.getShapeParentTransform(i);l&&a.rot(-l.rotation()),s.push(this.getChangesToTranslateShape(i,a.add(i)))}return this.updateShapes(s),this}duplicateShapes(e,n){return this.run(()=>{const r=typeof e[0]=="string"?e:e.map(f=>f.id);if(r.length<=0)return this;const s=new Set(r),o=this.getShapeAndDescendantIds(r),i=[...o].reverse(),a=new Map;for(const f of o)a.set(f,Ke());const{shapesToCreateWithOriginals:l,bindingsToCreate:c}=zI(this,o,f=>{const p=[];for(const m of f){const v=this.getBinding(m);if(!v)continue;const y=Ji();p.push({...v,id:y,fromId:zn(a.get(v.fromId)),toId:zn(a.get(v.toId))})}const g=[];for(const m of i){const v=zn(a.get(m)),y=this.getShape(m);if(!y)continue;let S=0,b=0;if(n&&s.has(m)){const P=this.getShapeParentTransform(y),C=new x(n.x,n.y).rot(-P.rotation());S=C.x,b=C.y}g.push({shape:{...y,id:v,x:y.x+S,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),v=m.indexOf(p.id),y=m[v+1],S=y?this.getShape(y):void 0,b=$u(p.index,S==null?void 0:S.index);f.index=b});const u=l.map(({shape:f})=>f);if(u.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage){xh(this);return}if(this.createShapes(u),this.createBindings(c),this.setSelectedShapes(me(r.map(f=>a.get(f)))),n!==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,n){const r=typeof e[0]=="string"?e:e.map(a=>a.id);if(r.length===0)return this;if(this.getIsReadonly())return this;const s=this.getCurrentPageId();if(n===s)return this;if(!this.store.has(n))return this;const o=this.getContentFromCurrentPage(r);if(!o)return this;if(this.getPageShapeIds(n).size+o.shapes.length>this.options.maxShapesPerPage)return xh(this,n),this;const i=this.getCamera().z;return this.run(()=>{this.deleteShapes(r),this.setCurrentPage(n),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(o,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:i}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(e){const n=typeof e[0]=="string"?e:e.map(i=>i.id);if(this.getIsReadonly()||n.length===0)return this;let r=!0,s=!0;const o=[];for(const i of n){const a=this.getShape(i);a&&(o.push(a),a.isLocked?s=!1:r=!1)}return this.run(()=>{s?(this.updateShapes(o.map(i=>({id:i.id,type:i.type,isLocked:!0}))),this.setSelectedShapes([])):r?this.updateShapes(o.map(i=>({id:i.id,type:i.type,isLocked:!1}))):this.updateShapes(o.map(i=>({id:i.id,type:i.type,isLocked:!0})))}),this}sendToBack(e){const n=typeof e[0]=="string"?e:e.map(s=>s.id),r=Sh(this,"toBack",n,{considerAllShapes:!0});return r&&this.updateShapes(r),this}sendBackward(e,n={}){const r=typeof e[0]=="string"?e:e.map(o=>o.id),s=Sh(this,"backward",r,n);return s&&this.updateShapes(s),this}bringForward(e,n={}){const r=typeof e[0]=="string"?e:e.map(o=>o.id),s=Sh(this,"forward",r,n);return s&&this.updateShapes(s),this}bringToFront(e){const n=typeof e[0]=="string"?e:e.map(s=>s.id),r=Sh(this,"toFront",n);return r&&this.updateShapes(r),this}flipShapes(e,n){const r=typeof e[0]=="string"?e:e.map(i=>i.id);if(this.getIsReadonly())return this;let s=me(r.map(i=>this.getShape(i)));if(!s.length)return this;s=me(s.map(i=>this.isShapeOfType(i,"group")?this.getSortedChildIdsForParent(i.id).map(a=>this.getShape(a)):i).flat());const o=Z.Common(me(s.map(i=>this.getShapePageBounds(i)))).center;return this.run(()=>{for(const i of s){const a=this.getShapeGeometry(i).bounds,l=this.getShapePageTransform(i.id);l&&this.resizeShape(i.id,{x:n==="horizontal"?-1:1,y:n==="vertical"?-1:1},{initialBounds:a,initialPageTransform:l,initialShape:i,mode:"scale_shape",isAspectRatioLocked:this.getShapeUtil(i).isAspectRatioLocked(i),scaleOrigin:o,scaleAxisRotation:0})}}),this}stackShapes(e,n,r){const s=typeof e[0]=="string"?e:e.map(m=>m.id);if(this.getIsReadonly())return this;const o=s.map(m=>this.getShape(m)).filter(m=>m?this.getShapeUtil(m).canBeLaidOut(m):!1),i=o.length;if(r===0&&i<3||i<2)return this;const a=Object.fromEntries(o.map(m=>[m.id,this.getShapePageBounds(m)]));let l,c,u,h;n==="horizontal"?(l="x",c="minX",u="maxX",h="width"):(l="y",c="minY",u="maxY",h="height");let f;if(r===0){const m=[];o.sort((y,S)=>a[y.id][c]-a[S.id][c]);for(let y=0;y<i-1;y++){const S=o[y],b=o[y+1],P=a[S.id],_=a[b.id][c]-P[u],E=m.find(k=>k.gap===_);E?E.count++:m.push({gap:_,count:1})}let v=0;m.forEach(y=>{y.count>v&&(v=y.count,f=y.gap)}),v===1&&(f=Math.max(0,m.reduce((y,S)=>y+S.gap*S.count,0)/(i-1)))}else f=r;const p=[];let g=a[o[0].id][u];return o.forEach((m,v)=>{var C,_;if(v===0)return;const y={x:0,y:0};y[l]=g+f-a[m.id][l];const S=this.getShapeParent(m),b=S?x.Rot(y,-this.getShapePageTransform(S).decompose().rotation):y,P=(_=(C=this.getShapeUtil(m)).onTranslateStart)==null?void 0:_.call(C,m);p.push(P?{...P,[l]:m[l]+b[l]}:{id:m.id,type:m.type,[l]:m[l]+b[l]}),g+=a[m.id][h]+f}),this.updateShapes(p),this}packShapes(e,n){var _,E;const r=typeof e[0]=="string"?e:e.map(k=>k.id);if(this.getIsReadonly())return this;if(r.length<2)return this;const s=r.map(k=>this.getShape(k)).filter(k=>k?this.getShapeUtil(k).canBeLaidOut(k):!1),o={},i={};let a,l,c=0;for(let k=0;k<s.length;k++)a=s[k],l=this.getShapePageBounds(a),o[a.id]=l,i[a.id]=l.clone(),c+=l.width*l.height;const u=Z.Common(me(Object.values(o))),h=u.width;s.sort((k,D)=>o[D.id].height-o[k.id].height);const f=Math.max(Math.ceil(Math.sqrt(c/.95)),h),p=[new Z(u.x,u.y,f,1/0)];let g=0,m=0,v,y;for(let k=0;k<s.length;k++){a=s[k],l=i[a.id];for(let D=p.length-1;D>=0;D--)if(v=p[D],!(l.width>v.width||l.height>v.height)){l.x=v.x,l.y=v.y,m=Math.max(m,l.maxY),g=Math.max(g,l.maxX),l.width===v.width&&l.height===v.height?(y=p.pop(),D<p.length&&(p[D]=y)):l.height===v.height?(v.x+=l.width+n,v.width-=l.width+n):l.width===v.width?(v.y+=l.height+n,v.height-=l.height+n):(p.push(new Z(v.x+(l.width+n),v.y,v.width-(l.width+n),l.height)),v.y+=l.height+n,v.height-=l.height+n);break}}const S=Z.Common(Object.values(i)),b=x.Sub(u.center,S.center);let P;const C=[];for(let k=0;k<s.length;k++){a=s[k],l=o[a.id],P=i[a.id];const D=x.Sub(P.point,l.point).add(b),T=this.getShapeParentTransform(a);T&&D.rot(-T.rotation());const j={id:a.id,type:a.type,x:a.x+D.x,y:a.y+D.y},L=(E=(_=this.getShapeUtil(a)).onTranslateStart)==null?void 0:E.call(_,{...a,...j});L?C.push({...j,...L}):C.push(j)}return C.length&&this.updateShapes(C),this}alignShapes(e,n){const r=typeof e[0]=="string"?e:e.map(l=>l.id);if(this.getIsReadonly())return this;if(r.length<2)return this;const s=me(r.map(l=>this.getShape(l))),o=Object.fromEntries(s.map(l=>[l.id,this.getShapePageBounds(l)])),i=Z.Common(me(Object.values(o))),a=[];return s.forEach(l=>{const c=o[l.id];if(!c)return;const u={x:0,y:0};switch(n){case"top":{u.y=i.minY-c.minY;break}case"center-vertical":{u.y=i.midY-c.minY-c.height/2;break}case"bottom":{u.y=i.maxY-c.minY-c.height;break}case"left":{u.x=i.minX-c.minX;break}case"center-horizontal":{u.x=i.midX-c.minX-c.width/2;break}case"right":{u.x=i.maxX-c.minX-c.width;break}}const h=this.getShapeParent(l),f=h?x.Rot(u,-this.getShapePageTransform(h).decompose().rotation):u;a.push(this.getChangesToTranslateShape(l,x.Add(l,f)))}),this.updateShapes(a),this}distributeShapes(e,n){const r=typeof e[0]=="string"?e:e.map(S=>S.id);if(this.getIsReadonly())return this;if(r.length<3)return this;const s=r.length,o=me(r.map(S=>this.getShape(S))),i=Object.fromEntries(o.map(S=>[S.id,this.getShapePageBounds(S)]));let a,l,c,u,h;n==="horizontal"?(a="x",l="minX",c="maxX",u="midX",h="width"):(a="y",l="minY",c="maxY",u="midY",h="height");const f=[],p=o.sort((S,b)=>i[S.id][l]-i[b.id][l])[0],g=o.sort((S,b)=>i[b.id][c]-i[S.id][c])[0],m=i[p.id][u],v=(i[g.id][u]-m)/(s-1),y=m+v;return o.filter(S=>S!==p&&S!==g).sort((S,b)=>i[S.id][u]-i[b.id][u]).forEach((S,b)=>{const P={x:0,y:0};P[a]=y+v*b-i[S.id][h]/2-i[S.id][a];const C=this.getShapeParent(S),_=C?x.Rot(P,-this.getShapePageTransform(C).rotation()):P;f.push(this.getChangesToTranslateShape(S,x.Add(S,_)))}),this.updateShapes(f),this}stretchShapes(e,n){const r=typeof e[0]=="string"?e:e.map(l=>l.id);if(this.getIsReadonly())return this;if(r.length<2)return this;const s=me(r.map(l=>this.getShape(l))),o=Object.fromEntries(r.map(l=>[l,this.getShapeGeometry(l).bounds])),i=Object.fromEntries(r.map(l=>[l,this.getShapePageBounds(l)])),a=Z.Common(me(Object.values(i)));switch(n){case"vertical":{this.run(()=>{for(const l of s){if(this.getShapePageTransform(l).rotation()%Fe)continue;const u=o[l.id],h=i[l.id],f=new x(0,a.minY-h.minY),p=this.getShapeParentTransform(l);p&&f.rot(-p.rotation());const{x:g,y:m}=x.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:m}]);const v=new x(1,a.height/h.height);this.resizeShape(l.id,v,{initialBounds:u,scaleOrigin:new x(h.center.x,a.minY),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}case"horizontal":{this.run(()=>{for(const l of s){const c=o[l.id],u=i[l.id];if(this.getShapePageTransform(l).rotation()%Fe)continue;const f=new x(a.minX-u.minX,0),p=this.getShapeParentTransform(l);p&&f.rot(-p.rotation());const{x:g,y:m}=x.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:m}]);const v=new x(a.width/u.width,1);this.resizeShape(l.id,v,{initialBounds:c,scaleOrigin:new x(a.minX,u.center.y),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}}return this}resizeShape(e,n,r={}){var p,g,m;const s=typeof e=="string"?e:e.id;if(this.getIsReadonly())return this;Number.isFinite(n.x)||(n=new x(1,n.y)),Number.isFinite(n.y)||(n=new x(n.x,1));const o=r.initialShape??this.getShape(s);if(!o)return this;const i=r.scaleOrigin??((p=this.getShapePageBounds(s))==null?void 0:p.center);if(!i)return this;const a=r.initialPageTransform?q.Cast(r.initialPageTransform):this.getShapePageTransform(s);if(!a)return this;const l=a.rotation();if(l==null)return this;const c=r.scaleAxisRotation??l,u=r.initialBounds??this.getShapeGeometry(s).bounds;if(!u)return this;const h=r.isAspectRatioLocked??this.getShapeUtil(o).isAspectRatioLocked(o);if(!cj(l,c))return this._resizeUnalignedShape(s,n,{...r,initialBounds:u,scaleOrigin:i,scaleAxisRotation:c,initialPageTransform:a,isAspectRatioLocked:h,initialShape:o});const f=this.getShapeUtil(o);if(h&&(Math.abs(n.x)>Math.abs(n.y)?n=new x(n.x,Math.sign(n.y)*Math.abs(n.x)):n=new x(Math.sign(n.x)*Math.abs(n.y),n.y)),f.onResize&&f.canResize(o)){const v=this._scalePagePoint(q.applyToPoint(a,new x(0,0)),i,n,c),y=this.getPointInParentSpace(o.id,v),S=new x(n.x,n.y),b=di((l-c)%Math.PI,0);S.x=b?n.x:n.y,S.y=b?n.y:n.x;const P=q.applyToPoint(a,new x),{x:C,y:_}=this.getPointInParentSpace(o.id,P);let E=o;r.skipStartAndEndCallbacks||(E=ys(o,((g=f.onResizeStart)==null?void 0:g.call(f,o))??void 0)),E=ys(E,{id:s,type:o.type,x:y.x,y:y.y,...f.onResize({...o,x:C,y:_},{newPoint:y,handle:r.dragHandle??"bottom_right",mode:r.mode??"scale_shape",scaleX:S.x,scaleY:S.y,initialBounds:u,initialShape:o})}),r.skipStartAndEndCallbacks||(E=ys(E,((m=f.onResizeEnd)==null?void 0:m.call(f,o,E))??void 0)),this.updateShapes([E])}else{const v=q.applyToPoint(a,u.center),y=this._scalePagePoint(v,i,n,c),S=this.getPointInParentSpace(o.id,v),b=this.getPointInParentSpace(o.id,y),P=x.Sub(b,S);this.updateShapes([{id:s,type:o.type,x:o.x+P.x,y:o.y+P.y}])}return this}_scalePagePoint(e,n,r,s){const o=x.RotWith(e,n,-s).sub(n),i=x.MulV(o,r);return x.Add(i,n).rotWith(n,s)}_resizeUnalignedShape(e,n,r){const{type:s}=r.initialShape,o=new x(n.x,n.y);if(Math.abs(n.x)>Math.abs(n.y)?o.x=Math.sign(n.x)*Math.abs(n.y):o.y=Math.sign(n.y)*Math.abs(n.x),this.resizeShape(e,o,{initialShape:r.initialShape,initialBounds:r.initialBounds,isAspectRatioLocked:r.isAspectRatioLocked}),Math.sign(n.x)*Math.sign(n.y)<0){let{rotation:v}=q.Decompose(r.initialPageTransform);v-=2*v,this.updateShapes([{id:e,type:s,rotation:v}])}const i=q.applyToPoint(r.initialPageTransform,r.initialBounds.center),a=this._scalePagePoint(i,r.scaleOrigin,n,r.scaleAxisRotation),l=this.getShapePageBounds(e),c=this.getShapePageTransform(e),u=l.center,h=c.point();if(!u||!h)return this;const f=x.Sub(a,u),p=x.Add(h,f),{x:g,y:m}=this.getPointInParentSpace(e,p);return this.updateShapes([{id:e,type:s,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.getIsReadonly())return this;if(e.length<=0)return this;const n=this.getCurrentPageShapeIds();if(e.length+n.size>this.options.maxShapesPerPage)return xh(this),this;const s=this.getFocusedGroupId();return this.run(()=>{var u,h;const o=this.getCurrentPageShapesSorted(),i=e.map(f=>{if(f.id||(f={id:Ke(),...f}),!f.parentId||!(this.store.has(f.parentId)||e.some(p=>p.id===f.parentId))){let p=this.getFocusedGroupId();for(let m=o.length-1;m>=0;m--){const v=o[m];if(!this.isShapeHidden(v)&&this.getShapeUtil(v).canReceiveNewChildrenOfType(v,f.type)&&this.isPointInShape(v,{x:f.x??0,y:f.y??0},{margin:0,hitInside:!0})){p=v.id;break}}const g=f.parentId;if(p===f.id&&(p=s),p!==g&&(f={...f},f.parentId=p,Fn(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 i){const p=this.getShapeUtil(f);let g=f.index;if(!g){const S=f.parentId??s;a.has(S)||a.set(S,this.getHighestIndexForParent(S)),g=a.get(S),a.set(S,_s(g))}const m=p.getDefaultProps();for(const[S,b]of this.styleProps[f.type])m[b]=this.getStyleForNextShape(S);let v=this.store.schema.types.shape.create({...f,index:g,opacity:f.opacity??c,parentId:f.parentId??s,props:"props"in f?{...m,...f.props}:m});if(v.index===void 0)throw Error("no index!");const y=(h=(u=this.getShapeUtil(v)).onBeforeCreate)==null?void 0:h.call(u,v);y&&(v=y),l.push(v)}l.forEach(f=>{f.meta={...this.getInitialMetaForShape(f),...f.meta}}),this.store.put(l)}),this}animateShape(e,n={animation:Wy}){return this.animateShapes([e],n)}animateShapes(e,n={animation:Wy}){if(!n.animation)return this;const{duration:r=500,easing:s=Dt.linear}=n.animation,o=ze();let i=r,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:nt(g),end:ys(nt(g),c)},l.push(u),this.animatingShapes.set(g.id,o))}const h=f=>{var v,y;if(i-=f,i<0){const{animatingShapes:S}=this,b=e.filter(P=>P&&S.get(P.id)===o);b.length&&this.updateShapes(b),this.off("tick",h);return}a=s(1-i/r);const{animatingShapes:p}=this,g=[];let m;for(let S=0,b=l.length;S<b;S++){const{start:P,end:C}=l[S];m=p.get(P.id),m===o&&g.push({...C,x:P.x+(C.x-P.x)*a,y:P.y+(C.y-P.y)*a,opacity:P.opacity+(C.opacity-P.opacity)*a,rotation:P.rotation+(C.rotation-P.rotation)*a,props:((y=(v=this.getShapeUtil(C)).getInterpolatedProps)==null?void 0:y.call(v,P,C,a))??C.props})}this._updateShapes(g)};return this.on("tick",h),this}groupShapes(e,n={}){var g;const{groupId:r=Ke(),select:s=!0}=n;if(!Array.isArray(e))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getIsReadonly())return this;const o=typeof e[0]=="string"?e:e.map(m=>m.id);if(o.length<=1)return this;const i=me((this._shouldIgnoreShapeLock?o:this._getUnlockedShapeIds(o)).map(m=>this.getShape(m))),a=i.sort(cn).map(m=>m.id),l=Z.Common(me(i.map(m=>this.getShapePageBounds(m)))),{x:c,y:u}=l.point,h=this.findCommonAncestor(i)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const f=i.filter(m=>m.parentId===h).sort(cn),p=(g=f[f.length-1])==null?void 0:g.index;return this.run(()=>{this.createShapes([{id:r,type:"group",parentId:h,index:p,x:c,y:u,opacity:1,props:{}}]),this.reparentShapes(a,r),s&&this.select(r)}),this}ungroupShapes(e,n={}){if(this.getIsReadonly())return this;const{select:r=!0}=n,s=typeof e[0]=="string"?e:e.map(l=>l.id),o=me((this._shouldIgnoreShapeLock?s:this._getUnlockedShapeIds(s)).map(l=>this.getShape(l)));if(o.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const i=new Set,a=[];return o.forEach(l=>{this.isShapeOfType(l,"group")?a.push(l):i.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 h=this.getSortedChildIdsForParent(l.id);for(let f=0,p=h.length;f<p;f++)i.add(h[f]);this.reparentShapes(h,l.parentId,l.index)}this.deleteShapes(a.map(c=>c.id)),r&&this.select(...i)}),this)}updateShape(e){return this.updateShapes([e]),this}updateShapes(e){const n=Array(e.length);for(let r=0,s=e.length;r<s;r++){const o=e[r];if(!o)continue;const i=this.getShape(o.id);if(i){if(!this._shouldIgnoreShapeLock){if(i.isLocked){if(!(Object.hasOwn(o,"isLocked")&&!o.isLocked))continue}else if(this.isShapeOrAncestorLocked(i))continue}this.animatingShapes.delete(o.id),n.push(o)}}return this._updateShapes(n),this}_updateShapes(e){this.getIsReadonly()||this.run(()=>{var o,i;const n=[];let r,s;for(let a=0,l=e.length;a<l;a++){const c=e[a];c&&(r=this.getShape(c.id),r&&(s=ys(r,c),s!==r&&(s=((i=(o=this.getShapeUtil(r)).onBeforeUpdate)==null?void 0:i.call(o,r,s))??s,n.push(s))))}this.store.put(n)})}_getUnlockedShapeIds(e){return e.filter(n=>{var r;return!((r=this.getShape(n))!=null&&r.isLocked)})}deleteShapes(e){if(this.getIsReadonly())return this;if(!Array.isArray(e))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");const n=typeof e[0]=="string"?e:e.map(o=>o.id),r=this._shouldIgnoreShapeLock?n:this._getUnlockedShapeIds(n);if(r.length===0)return this;const s=new Set(r);for(const o of r)this.visitDescendants(o,i=>{s.add(i)});return this.run(()=>this.store.remove([...s]))}deleteShape(e){return this.deleteShapes([typeof e=="string"?e:e.id]),this}_extractSharedStyles(e,n){if(this.isShapeOfType(e,"group")){const r=this._parentIdsToChildIds.get()[e.id];if(!r)return;for(let s=0,o=r.length;s<o;s++)this._extractSharedStyles(this.getShape(r[s]),n)}else for(const[r,s]of this.styleProps[e.type])n.applyValue(r,hn(e.props,s))}_getSelectionSharedStyles(){const e=this.getSelectedShapes(),n=new Tx;for(const r of e)this._extractSharedStyles(r,n);return n}getStyleForNextShape(e){const n=this.getInstanceState().stylesForNextShape[e.id];return n===void 0?e.defaultValue:n}getShapeStyleIfExists(e,n){const r=this.styleProps[e.type].get(n);if(r!==void 0)return hn(e.props,r)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const e=this.root.getCurrent(),n=new Tx;if(!e)return n;if(e.shapeType)for(const r of this.styleProps[e.shapeType].keys())n.applyValue(r,this.getStyleForNextShape(r));return n}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const e=[],n=s=>{const o=this.getShape(s);if(o)if(this.isShapeOfType(o,"group"))for(const i of this.getSortedChildIdsForParent(o.id))n(i);else e.push(o)};for(const s of this.getSelectedShapeIds())n(s);let r=null;for(const s of e)if(r===null)r=s.opacity;else if(r!==s.opacity)return{type:"mixed"};if(r!==null)return{type:"shared",value:r}}return{type:"shared",value:this.getInstanceState().opacityForNextShape}}setOpacityForNextShapes(e,n){return this.updateInstanceState({opacityForNextShape:e},n),this}setOpacityForSelectedShapes(e){const n=this.getSelectedShapes();if(n.length>0){const r=[],s=o=>{if(this.isShapeOfType(o,"group")){const i=this.getSortedChildIdsForParent(o);for(const a of i)s(this.getShape(a))}else r.push(o)};for(const o of n)s(o);this.updateShapes(r.map(o=>({id:o.id,type:o.type,opacity:e})))}return this}setStyleForNextShapes(e,n,r){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[e.id]:n}},r),this}setStyleForSelectedShapes(e,n){const r=this.getSelectedShapes();if(r.length>0){const s=[],o=i=>{if(this.isShapeOfType(i,"group")){const a=this.getSortedChildIdsForParent(i.id);for(const l of a)o(this.getShape(l))}else{const a=this.getShapeUtil(i),l=this.styleProps[i.type].get(e);if(l){const c={id:i.id,type:i.type,props:{[l]:n}};s.push({util:a,originalShape:i,updatePartial:c})}}};for(const i of r)o(i);this.updateShapes(s.map(({updatePartial:i})=>i))}return this}registerExternalAssetHandler(e,n){return this.externalAssetContentHandlers[e]=n,this}createTemporaryAssetPreview(e,n){if(this.temporaryAssetPreview.has(e))return this.temporaryAssetPreview.get(e);const r=URL.createObjectURL(n);return this.temporaryAssetPreview.set(e,r),setTimeout(()=>{this.temporaryAssetPreview.delete(e),URL.revokeObjectURL(r)},this.options.temporaryAssetPreviewLifetimeMs),r}getTemporaryAssetPreview(e){return this.temporaryAssetPreview.get(e)}async getAssetForExternalContent(e){var n,r;return await((r=(n=this.externalAssetContentHandlers)[e.type])==null?void 0:r.call(n,e))}hasExternalAssetHandler(e){return!!this.externalAssetContentHandlers[e]}registerExternalContentHandler(e,n){return this.externalContentHandlers[e]=n,this}async putExternalContent(e){var n,r;return(r=(n=this.externalContentHandlers)[e.type])==null?void 0:r.call(n,e)}getContentFromCurrentPage(e){const n=typeof e[0]=="string"?e:e.map(s=>s.id);if(!n||n.length===0)return;const r=this.getShapeAndDescendantIds(n);return zI(this,r,s=>{const o=[];for(const u of s){const h=this.getBinding(u);h&&o.push(h)}const i=[],a=[];for(const u of r){const h=this.getShape(u);if(!h)continue;if(!r.has(h.parentId)){const p=this.getShapePageTransform(h.id),g=p.point();a.push({...h,x:g.x,y:g.y,rotation:p.rotation(),parentId:this.getCurrentPageId()}),i.push(h.id)}else a.push(h)}const l=[],c=new Set;for(const u of a){if(!("assetId"in u.props))continue;const h=u.props.assetId;if(!h||c.has(h))continue;c.add(h);const f=this.getAsset(h);f&&l.push(f)}return{schema:this.store.schema.serialize(),shapes:a,rootShapeIds:i,bindings:o,assets:l}})}async resolveAssetsInContent(e){if(!e)return;const n=[];return await Promise.allSettled(e.assets.map(async r=>{var s,o,i;if((r.type==="image"||r.type==="video")&&!((s=r.props.src)!=null&&s.startsWith("data:image"))&&!((o=r.props.src)!=null&&o.startsWith("data:video"))&&!((i=r.props.src)!=null&&i.startsWith("http"))){const a=nt(r),l=await this.store.props.assets.resolve(r,{screenScale:1,steppedScreenScale:1,dpr:1,networkEffectiveType:null,shouldResolveToOriginal:!0});a.props.src=await Zr.blobToDataUrl(await Rs(l).then(c=>c.blob())),n.push(a)}else n.push(r)})),e.assets=n,e}putContentOntoCurrentPage(e,n={}){var T,j,L;if(this.getIsReadonly())return this;if(!e.schema)throw Error(`Could not put content:
|
|
106
|
-
content is missing a schema.`);const{select:r=!1,preserveIds:s=!1,preservePosition:o=!1}=n;let{point:i=void 0}=n;const a=this.getCurrentPageId(),{rootShapeIds:l}=e,c=[],u=[],h=[],f={store:{...Object.fromEntries(e.assets.map(M=>[M.id,M])),...Object.fromEntries(e.shapes.map(M=>[M.id,M])),...Object.fromEntries(((T=e.bindings)==null?void 0:T.map(M=>[M.id,M]))??[])},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 M of Object.values(p.value))switch(M.typeName){case"asset":{c.push(M);break}case"shape":{u.push(M);break}case"binding":{h.push(M);break}}const g=new Map(s?u.map(M=>[M.id,M.id]):u.map(M=>[M.id,Ke()])),m=new Map(s?h.map(M=>[M.id,M.id]):h.map(M=>[M.id,Ji()]));let v=this.getCurrentPageId(),y=1/0,S=[];for(const M of this.getSelectedShapes()){if(y===0)break;const O=this.isShapeOfType(M,"frame"),F=this.getShapeAncestors(M);O&&F.push(M);const B=O?F.length+1:F.length;if(B<y)y=B,S=F,v=O?M.id:M.parentId;else if(B===y){if(S.length!==F.length)throw Error(`Ancestors: ${S.length} !== ${F.length}`);if(S.length===0){v=a;break}else{v=a;for(let K=0;K<S.length&&F[K]===S[K];K++)v=F[K].id}}}let b=!1;if(!Rn(v)){const M=this.getShape(v);if(M){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(M)))v=a;else if(l.length===1){const O=u.find(F=>F.id===l[0]);this.isShapeOfType(M,"frame")&&this.isShapeOfType(O,"frame")&&O.props.w===(M==null?void 0:M.props.w)&&O.props.h===(M==null?void 0:M.props.h)&&(b=!0)}}else v=a}b||(b=g.has(v)),b&&(v=this.getShape(v).parentId);let P=this.getHighestIndexForParent(v);const C=[],_=u.map(M=>{const O=g.get(M.id),F={...M,id:O};return l.includes(M.id)&&(F.parentId=a,C.push(F)),g.has(F.parentId)?F.parentId=g.get(M.parentId):(l.push(F.id),F.index=P,P=_s(P)),F});if(_.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage)return xh(this),this;const E=h.map(M=>({...M,id:zn(m.get(M.id)),fromId:zn(g.get(M.fromId)),toId:zn(g.get(M.toId))})),k=[],D=[];for(const M of c)this.store.has(M.id)||((M.type==="image"&&((j=M.props.src)!=null&&j.startsWith("data:image"))||M.type==="video"&&((L=M.props.src)!=null&&L.startsWith("data:video")))&&(D.push(nt(M)),M.props.src=null),k.push(M));return Promise.allSettled(D.map(async M=>{const O=await GQ(M.props.src,M.props.name,M.props.mimeType??"image/png"),F=await this.getAssetForExternalContent({type:"file",file:O,assetId:M.id});if(!F){this.deleteAssets([M.id]);return}this.updateAssets([{...F,id:M.id}])})),this.run(()=>{k.length>0&&this.createAssets(k),this.createShapes(_),this.createBindings(E),r&&this.select(...C.map(K=>K.id)),v!==a&&this.reparentShapes(C.map(K=>K.id),v);const M=_.map(K=>this.getShape(K.id)),O=Z.Common(M.map(K=>this.getShapePageBounds(K)));if(i===void 0)if(Rn(v)){const K=this.getViewportPageBounds();o||K.includes(Z.From(O))?i=O.center:i=K.center}else{const K=this.getShape(v);i=q.applyToPoint(this.getShapePageTransform(K),this.getShapeGeometry(K).bounds.center)}if(C.length===1){const K=C[0];if(this.isShapeOfType(K,"frame"))for(;this.getShapesAtPoint(i).some(R=>this.isShapeOfType(R,"frame")&&R.props.w===K.props.w&&R.props.h===K.props.h);)i.x+=O.w+16}const F=Z.Common(me(C.map(({id:K})=>this.getShapePageBounds(K)))).center,B=x.Sub(i,F);this.updateShapes(C.map(({id:K})=>{const R=this.getShape(K),H=this.getShapeParentTransform(K).decompose().rotation,X=x.Rot(B,-H);return{id:R.id,type:R.type,x:R.x+X.x,y:R.y+X.y}}))}),this}async getSvgElement(e,n={}){const r=typeof e[0]=="string"?e:e.map(s=>s.id);if(r.length!==0)return UQ(this,r,n)}async getSvgString(e,n={}){const r=await this.getSvgElement(e,n);return r?{svg:new XMLSerializer().serializeToString(r.svg),width:r.width,height:r.height}:void 0}async getSvg(e,n={}){const r=await this.getSvgElement(e,n);if(r)return r.svg}_updateInputsFromEvent(e){const{pointerVelocity:n,previousScreenPoint:r,previousPagePoint:s,currentScreenPoint:o,currentPagePoint:i}=this.inputs,{screenBounds:a}=this.store.unsafeGetWithoutCapture(bn),{x:l,y:c,z:u}=ah(()=>this.getCamera()),h=e.point.x-a.x,f=e.point.y-a.y,p=e.point.z??.5;r.setTo(o),s.setTo(i),o.set(h,f);const g=h/u-l,m=f/u-c;isFinite(g)&&isFinite(m)&&i.set(g,m,p),this.inputs.isPen=e.type==="pointer"&&e.isPen,(e.name==="pointer_down"||this.inputs.isPinching)&&(n.set(0,0),this.inputs.originScreenPoint.setTo(o),this.inputs.originPagePoint.setTo(i)),this.run(()=>{var v;this.store.put([{id:Ap,typeName:"pointer",x:i.x,y:i.y,lastActivityTimestamp:e.type==="pointer"&&e.pointerId===oI.CAMERA_MOVE?((v=this.store.unsafeGetWithoutCapture(Ap))==null?void 0:v.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}getIsReadonly(){return this.getInstanceState().isReadonly}getSnapshot(){return VZ(this.store)}loadSnapshot(e,n){return Gj(this.store,e,n),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 n=this.getPage(e.pageId);n&&this.setCurrentPage(n),this._zoomToFitPageContentAt100Percent();return}case"shapes":{const n=me(e.shapeIds.map(i=>this.getShape(i))),r={};for(const i of n){const a=this.getAncestorPageId(i);a&&(r[a]??(r[a]=[]),r[a].push(i))}const[s,o]=Object.entries(r).sort(([i,a],[l,c])=>c.length-a.length)[0]??["",[]];if(!s||!o.length)this._zoomToFitPageContentAt100Percent();else{this.setCurrentPage(s);const i=Z.Common(o.map(a=>this.getShapePageBounds(a)));this.zoomToBounds(i,{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:Ot(e)}})}navigateToDeepLink(e){if(e&&"type"in e)return this._navigateToDeepLink(e),this;const r=new URL((e==null?void 0:e.url)??window.location.href).searchParams.get((e==null?void 0:e.param)??"d");if(!r)return this._zoomToFitPageContentAt100Percent(),this;try{this._navigateToDeepLink(XQ(r))}catch(s){console.warn(s),this._zoomToFitPageContentAt100Percent()}return this}createDeepLink(e){const n=new URL((e==null?void 0:e.url)??window.location.href);return n.searchParams.set((e==null?void 0:e.param)??"d",YQ((e==null?void 0:e.to)??{type:"viewport",pageId:this.options.maxPages===1?void 0:this.getCurrentPageId(),bounds:this.getViewportPageBounds()})),n}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 n=G("url with state",()=>{var l,c;const i=((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:i,to:(c=e==null?void 0:e.getTarget)==null?void 0:c.call(e,this)}).toString()}),r=(e==null?void 0:e.onChange)??(()=>{var a;const i=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,i.toString())}),s=vg(i=>i(),(e==null?void 0:e.debounceMs)??500),o=As("update url on state change",()=>r(new URL(n.get()),this),{scheduleEffect:s});return()=>{o(),s.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,metaKey:this.inputs.metaKey,accelKey:un(this.inputs),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,metaKey:this.inputs.metaKey,accelKey:un(this.inputs),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,metaKey:this.inputs.metaKey,accelKey:un(this.inputs),code:"ControlLeft"})}_setMetaKeyTimeout(){this.inputs.metaKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Meta",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,metaKey:this.inputs.metaKey,accelKey:un(this.inputs),code:"MetaLeft"})}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 n=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const r of n)this._flushEventForTick(r)}e>0&&this.root.handleEvent({type:"misc",name:"tick",elapsed:e}),this.scribbles.tick(e)})}_flushEventForTick(e){if(this.getCrashingError())return this;const{inputs:n}=this,{type:r}=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,n.shiftKey=!0):!e.shiftKey&&n.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=this.timers.setTimeout(this._setShiftKeyTimeout,150)),e.altKey?(clearTimeout(this._altKeyTimeout),this._altKeyTimeout=-1,n.altKey=!0):!e.altKey&&n.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=this.timers.setTimeout(this._setAltKeyTimeout,150)),e.ctrlKey?(clearTimeout(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,n.ctrlKey=!0):!e.ctrlKey&&n.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=this.timers.setTimeout(this._setCtrlKeyTimeout,150)),e.metaKey?(clearTimeout(this._metaKeyTimeout),this._metaKeyTimeout=-1,n.metaKey=!0):!e.metaKey&&n.metaKey&&this._metaKeyTimeout===-1&&(this._metaKeyTimeout=this.timers.setTimeout(this._setMetaKeyTimeout,150));const{originPagePoint:s,currentPagePoint:o}=n;n.isPointing||(n.isDragging=!1);const i=this.store.unsafeGetWithoutCapture(bn),a=this.store.get(this._getCurrentPageStateId()),l=this._cameraOptions.__unsafe__getWithoutCapture();switch(r){case"pinch":{if(l.isLocked)return;switch(clearTimeout(this._longPressTimeout),this._updateInputsFromEvent(e),e.name){case"pinch_start":{if(n.isPinching)return;n.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=[...a.selectedShapeIds]),this._didPinch=!0,n.isPinching=!0,this.interrupt());return}case"pinch":{if(!n.isPinching)return;const{point:{z:c=1},delta:{x:u,y:h}}=e,{x:f,y:p}=x.SubXY(e.point,i.screenBounds.x,i.screenBounds.y);this.stopCameraAnimation(),i.followingUserId&&this.stopFollowingUser();const{x:g,y:m,z:v}=ah(()=>this.getCamera()),{panSpeed:y,zoomSpeed:S}=l;this._setCamera(new x(g+u*y/v-f/v+f/(c*S),m+h*y/v-p/v+p/(c*S),c*S),{immediate:!0});return}case"pinch_end":{if(!n.isPinching)return this;n.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;this._updateInputsFromEvent(e);const{panSpeed:c,zoomSpeed:u,wheelBehavior:h}=l;if(h!=="none"){this.stopCameraAnimation(),i.followingUserId&&this.stopFollowingUser();const{x:f,y:p,z:g}=ah(()=>this.getCamera()),{x:m,y:v,z:y=0}=e.delta;let S=h;switch(n.ctrlKey&&(S=h==="pan"?"zoom":"pan"),S){case"zoom":{const{x:b,y:P}=this.inputs.currentScreenPoint;let C=y;h==="zoom"&&(Math.abs(v)>10?C=10*Math.sign(v)/100:C=v/100);const _=g+(C??0)*u*g;this._setCamera(new x(f+(b/_-b)-(b/g-b),p+(P/_-P)-(P/g-P),_),{immediate:!0}),this.maybeTrackPerformance("Zooming");return}case"pan":{this._setCamera(new x(f+m*c/g,p+v*c/g,g),{immediate:!0}),this.maybeTrackPerformance("Panning");return}}}break}case"pointer":{if(n.isPinching)return;this._updateInputsFromEvent(e);const{isPen:c}=e,{isPenMode:u}=i;switch(e.name){case"pointer_down":{if(u&&!c)return;if(this.inputs.isPanning||(this._longPressTimeout=this.timers.setTimeout(()=>{const h=this.getViewportScreenBounds();this.dispatch({...e,point:this.inputs.originScreenPoint.clone().addXY(h.x,h.y),name:"long_press"})},this.options.longPressDurationMs)),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),e.button===iI&&(this.capturedPointerId=e.pointerId),n.buttons.add(e.button),n.isPointing=!0,n.isDragging=!1,!u&&c&&this.updateInstanceState({isPenMode:!0}),e.button===aI?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):e.button===ph&&(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:h,y:f,z:p}=ah(()=>this.getCamera());if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:g,previousScreenPoint:m}=this.inputs,{panSpeed:v}=l,y=x.Sub(g,m);this.setCamera(new x(h+y.x*v/p,f+y.y*v/p,p),{immediate:!0}),this.maybeTrackPerformance("Panning");return}n.isPointing&&!n.isDragging&&x.Dist2(s,o)*this.getZoomLevel()>(i.isCoarsePointer?this.options.coarseDragDistanceSquared:this.options.dragDistanceSquared)/p&&(n.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(n.isDragging=!1,n.isPointing=!1,clearTimeout(this._longPressTimeout),n.buttons.delete(e.button),i.isPenMode&&!c)return;if(this.capturedPointerId===e.pointerId&&(this.capturedPointerId=null,e.button=0),n.isPanning){n.keys.has("Space")||(n.isPanning=!1,n.isSpacebarPanning=!1);const h=this.inputs.pointerVelocity,f=Math.min(2,h.len());switch(e.button){case iI:{this.setCursor({type:"grab",rotation:0});break}case ph:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}f>0&&this.slideCamera({speed:f,direction:h})}else e.button===aI&&(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.code==="MetaRight"&&(e.code="MetaLeft"),e.name){case"key_down":{if(n.keys.add(e.code),e.code==="Space"&&!e.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=i.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 x(0,-1);break}case"ArrowRight":{c=new x(1,0);break}case"ArrowDown":{c=new x(0,1);break}case"ArrowLeft":{c=new x(-1,0);break}}if(c){const u=this.getViewportPageBounds(),h=u.clone().translate(c.mulV({x:u.w,y:u.h}));this._animateToViewport(h,{animation:{duration:320}})}}break}case"key_up":{n.keys.delete(e.code),e.code==="Space"&&(this.inputs.buttons.has(ph)||(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(e.type==="pointer"){e.button===ph?e.name="middle_click":e.button===gb&&(e.name="right_click");const{isPenMode:c}=this.store.unsafeGetWithoutCapture(bn);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.menus.clearOpenMenus(),this}maybeTrackPerformance(e){wt.measurePerformance.get()&&(this.performanceTracker.isStarted()?clearTimeout(this.performanceTrackerTimeout):this.performanceTracker.start(e),this.performanceTrackerTimeout=this.timers.setTimeout(()=>{this.performanceTracker.stop()},50))}}J=yee(Ax);ee(J,1,"getIsShapeHiddenCache",KR,Q);ee(J,1,"getCanUndo",HR,Q);ee(J,1,"getCanRedo",UR,Q);ee(J,1,"getPath",BR,Q);ee(J,1,"getCurrentTool",zR,Q);ee(J,1,"getCurrentToolId",NR,Q);ee(J,1,"getDocumentSettings",FR,Q);ee(J,1,"getInstanceState",$R,Q);ee(J,1,"getOpenMenus",LR,Q);ee(J,1,"getIsMenuOpen",RR,Q);ee(J,1,"getPageStates",DR,Q);ee(J,1,"_getPageStatesQuery",OR,Q);ee(J,1,"getCurrentPageState",jR,Q);ee(J,1,"_getCurrentPageStateId",AR,Q);ee(J,1,"getSelectedShapeIds",MR,Q);ee(J,1,"getSelectedShapes",TR,Q);ee(J,1,"getOnlySelectedShapeId",kR,Q);ee(J,1,"getOnlySelectedShape",ER,Q);ee(J,1,"getSelectionPageBounds",IR,Q);ee(J,1,"getSelectionRotation",_R,Q);ee(J,1,"getSelectionRotatedPageBounds",CR,Q);ee(J,1,"getSelectionRotatedScreenBounds",PR,Q);ee(J,1,"getFocusedGroupId",bR,Q);ee(J,1,"getFocusedGroup",wR,Q);ee(J,1,"getEditingShapeId",xR,Q);ee(J,1,"getEditingShape",vR,Q);ee(J,1,"getHoveredShapeId",SR,Q);ee(J,1,"getHoveredShape",yR,Q);ee(J,1,"getHintingShapeIds",mR,Q);ee(J,1,"getHintingShape",gR,Q);ee(J,1,"getErasingShapeIds",pR,Q);ee(J,1,"getErasingShapes",fR,Q);ee(J,1,"_unsafe_getCameraId",hR,Q);ee(J,1,"getCamera",dR,Q);ee(J,1,"getViewportPageBoundsForFollowing",uR,Q);ee(J,1,"getCameraForFollowing",cR,Q);ee(J,1,"getZoomLevel",lR,Q);ee(J,1,"getViewportScreenBounds",aR,Q);ee(J,1,"getViewportScreenCenter",iR,Q);ee(J,1,"getViewportPageBounds",oR,Q);ee(J,1,"_getCollaboratorsQuery",sR,Q);ee(J,1,"getCollaborators",rR,Q);ee(J,1,"getCollaboratorsOnCurrentPage",nR,Q);ee(J,1,"getRenderingShapes",tR,Q);ee(J,1,"_getAllPagesQuery",eR,Q);ee(J,1,"getPages",JD,Q);ee(J,1,"getCurrentPageId",QD,Q);ee(J,1,"getCurrentPageShapeIdsSorted",ZD,Q);ee(J,1,"_getAllAssetsQuery",qD,Q);ee(J,1,"_getShapeGeometryCache",XD,Q);ee(J,1,"_getShapeHandlesCache",YD,Q);ee(J,1,"_getShapePageTransformCache",VD,Q);ee(J,1,"_getShapePageBoundsCache",GD,Q);ee(J,1,"_getShapeClipPathCache",WD,Q);ee(J,1,"_getShapeMaskCache",KD,Q);ee(J,1,"_getShapeMaskedPageBoundsCache",HD,Q);ee(J,1,"_notVisibleShapes",UD,Q);ee(J,1,"getCulledShapes",BD,Q);ee(J,1,"getCurrentPageBounds",zD,Q);ee(J,1,"getCurrentPageShapes",ND,Q);ee(J,1,"getCurrentPageShapesSorted",FD,Q);ee(J,1,"getCurrentPageRenderingShapesSorted",$D,Q);ee(J,1,"_getBindingsIndexCache",LD,Q);ee(J,1,"_getSelectionSharedStyles",RD,Q);ee(J,1,"getSharedStyles",DD,Q);ee(J,1,"getSharedOpacity",OD,Q);ee(J,1,"getIsFocused",jD,Q);ee(J,1,"getIsReadonly",AD,Q);ee(J,1,"_setShiftKeyTimeout",MD,Q);ee(J,1,"_setAltKeyTimeout",TD,Q);ee(J,1,"_setCtrlKeyTimeout",kD,Q);ee(J,1,"_setMetaKeyTimeout",ED,Q);vee(J,Q);function xh(t,e=t.getCurrentPageId()){const n=t.getPage(e).name;t.emit("max-shapes",{name:n,pageId:e,count:t.options.maxShapesPerPage})}function ys(t,e){if(!e)return t;let n=null;const r=Object.entries(e);for(let s=0,o=r.length;s<o;s++){const[i,a]=r[s];if(a!==void 0&&!(i==="id"||i==="type"||i==="typeName")&&a!==t[i]){if(n||(n={...t}),i==="props"||i==="meta"){n[i]={...t[i]};for(const[l,c]of Object.entries(a))n[i][l]=c;continue}n[i]=a}}return n||t}function WR(t,e,n){const r=t.getShape(e);if(!r)return;n.push(r);const s=t.getSortedChildIdsForParent(e);for(let o=0,i=s.length;o<i;o++)WR(t,s[o],n)}function zI(t,e,n){let r;if(t.run(()=>{const s=t.store.extractingChanges(()=>{const o=new Set,i=new Set;for(const a of e)if(t.getShape(a))for(const c of t.getBindingsInvolvingShape(a)){const u=e.has(c.fromId),h=e.has(c.toId);if(u&&h){o.add(c.id);continue}(!u||!h)&&i.add(c.id)}t.deleteBindings([...i],{isolateShapes:!0});try{r=wn.ok(n(o))}catch(a){r=wn.err(a)}});t.store.applyDiff(px(s))},{history:"ignore"}),r.ok)return r.value;throw r.error}function BI(t,e){if(!e.constraints)throw Error("Should have constraints here");const{padding:{x:n,y:r}}=e.constraints,s=t.getViewportScreenBounds(),o=Z.From(e.constraints.bounds),i=(s.w-n*2)/o.w,a=(s.h-r*2)/o.h;return{zx:i,zy:a}}function xd(){const t=z(),e=md();return U("isDarkMode",()=>(e==null?void 0:e.isDarkMode)??t.user.getIsDarkMode(),[e,t])}const UI="<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'/>",HI="<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'/>",wh='<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 No(t,e,n,r,s,o=16,i=16){const a=(-n-e)*(De/180),l=Math.sin(a),c=Math.cos(a),u=1*c-1*l,h=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: ${s};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${u}' dy='${h}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${e+n} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+t.replaceAll('"',"'")+`</g></svg>") ${o} ${i}, pointer`}const wee=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],bee={none:()=>"none","ew-resize":(t,e,n)=>No(HI,t,0,e,n),"ns-resize":(t,e,n)=>No(HI,t,90,e,n),"nesw-resize":(t,e,n)=>No(UI,t,0,e,n),"nwse-resize":(t,e,n)=>No(UI,t,90,e,n),"nwse-rotate":(t,e,n)=>No(wh,t,0,e,n),"nesw-rotate":(t,e,n)=>No(wh,t,90,e,n),"senw-rotate":(t,e,n)=>No(wh,t,180,e,n),"swne-rotate":(t,e,n)=>No(wh,t,270,e,n)};function nr(t,e=0,n="black"){return bee[t](SX(e),!1,n)}function Pee(){const t=z(),e=Tt(),n=xd();ui("useCursor",()=>{const{type:r,rotation:s}=t.getInstanceState().cursor;if(wee.includes(r)){e.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}e.style.setProperty("--tl-cursor",nr(r,s,n?"white":"black"))},[t,e,n])}function Cee(){const t=z(),e=Tt(),n=xd(),r=U(wt.forceSrgb);ke.useEffect(()=>{n?(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")),r?e.classList.add("tl-theme__force-sRGB"):e.classList.remove("tl-theme__force-sRGB")},[t,e,r,n])}function _ee(){const[t,e]=w.useState(0);w.useEffect(()=>e(n=>n+1),[])}const Iee=t=>t.props.src,Eee={upload:(t,e)=>Zr.blobToDataUrl(e)};function kee(t){return"schema"in t&&t.schema?t.schema:aX({shapes:"shapeUtils"in t&&t.shapeUtils?KI(qj(t.shapeUtils)):void 0,bindings:"bindingUtils"in t&&t.bindingUtils?KI(Yj(t.bindingUtils)):void 0,migrations:"migrations"in t?t.migrations:void 0})}function Hu({initialData:t,defaultName:e="",id:n,assets:r=Eee,onMount:s,collaboration:o,...i}={}){const a=kee(i),l=new eb({id:n,schema:a,initialData:t,props:{defaultName:e,assets:{upload:r.upload,resolve:r.resolve??Iee},onMount:c=>{Le(c instanceof Q),s==null||s(c)},collaboration:o}});if(i.snapshot){if(t)throw new Error("Cannot provide both initialData and snapshot");Gj(l,i.snapshot)}return l}function KI(t){return Object.fromEntries(t.map(e=>[e.type,{props:e.props,migrations:e.migrations}]))}function Tee(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
107
|
-
|
|
108
|
-
Keep seeing this message?
|
|
109
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
110
|
-
• If your hard disk is full, try clearing up some space and then reload the page.`)}function Mee(){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.
|
|
111
|
-
|
|
112
|
-
Keep seeing this message?
|
|
113
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const Aee=350,jee=1e4,WI=Symbol("UPDATE_INSTANCE_STATE"),Oee=t=>t;class Dee{constructor(e){I(this,"onmessage")}postMessage(e){}close(){}}const Ree=typeof BroadcastChannel>"u"?Dee:BroadcastChannel;class Lee{constructor(e,{persistenceKey:n,sessionId:r=Fp,onLoad:s,onLoadError:o},i=new Ree(`tldraw-tab-sync-${n}`)){I(this,"disposables",new Set);I(this,"diffQueue",[]);I(this,"didDispose",!1);I(this,"shouldDoFullDBWrite",!0);I(this,"isReloading",!1);I(this,"persistenceKey");I(this,"sessionId");I(this,"serializedSchema");I(this,"isDebugging",!1);I(this,"documentTypes");I(this,"$sessionStateSnapshot");I(this,"db");I(this,"initTime",Date.now());I(this,"isPersisting",!1);I(this,"didLastWriteError",!1);I(this,"scheduledPersistTimeout",null);this.store=e,this.channel=i,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=n,this.sessionId=r,this.db=new wp(n),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=wb(this.store),this.disposables.add(e.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(Oee({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(WI),this.schedulePersist()},{scope:"session"})),this.connect(s,o),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,n){this.debug("connecting");let r;try{r=await this.db.load({sessionId:this.sessionId})}catch(s){n(s),Mee();return}if(this.debug("loaded data from store",r,"didDispose",this.didDispose),!this.didDispose)try{if(r){const s=Object.fromEntries(r.records.map(l=>[l.id,l])),o=r.sessionStateSnapshot??GZ(s),i=this.store.schema.migrateStoreSnapshot({store:s,schema:r.schema??this.store.schema.serializeEarliestVersion()});if(i.type==="error"){console.error("failed to migrate store",i),n(new Error(`Failed to migrate store: ${i.reason}`));return}const a=Object.values(i.value).filter(l=>this.documentTypes.has(l.typeName));a.length>0&&this.store.mergeRemoteChanges(()=>{this.store.put(a,"initialize")}),o&&Cx(this.store,o)}this.channel.onmessage=({data:s})=>{var a,l;this.debug("got message",s);const o=s,i=this.store.schema.getMigrationsSince(o.schema);if(i.ok){if(i.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){n(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}o.type==="diff"&&(this.debug("applying diff"),js(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(o.changes)})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),e(this)}catch(s){if(this.debug("error loading data from store",s),this.didDispose)return;n(s);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?jee:Aee))}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(Le(!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 n=J0(e.filter(r=>r!==WI));await this.db.storeChanges({changes:n,schema:this.store.schema,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(n){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",n),Tee(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function GR(t){const e=w.useRef(t),[n,r]=w.useState(t);n!==e.current&&r(e.current);const s=w.useCallback(o=>{typeof o=="function"?e.current=o(e.current):e.current=o,r(e.current)},[]);return[n,s]}function $ee(t){const[e,n]=GR({status:"loading"});return t=tc(t),w.useEffect(()=>{const{persistenceKey:r,sessionId:s,...o}=t;if(!r){n({status:"not-synced",store:Hu(o)});return}n({status:"loading"});const i=new Ds,a={upload:async(h,f)=>(await u.db.storeAsset(h.id,f),h.id),resolve:async h=>h.props.src?h.props.src.startsWith("asset:")?await i.get(h,async()=>{const f=await u.db.getAsset(h.id);return f?URL.createObjectURL(f):null}):h.props.src:null,...o.assets},l=Hu({...o,assets:a});let c=!1;const u=new Lee(l,{sessionId:s,persistenceKey:r,onLoad(){c||n({store:l,status:"synced-local"})},onLoadError(h){c||n({status:"error",error:h})}});return()=>{c=!0,u.close()}},[t,n]),e}function Fee(){const t=z(),e=Tt();w.useEffect(()=>{const n=o=>e.style.setProperty("--tl-zoom",o.toString()),r=vg(n,100),s=new Ql("useZoomCss",()=>{t.getCurrentPageShapeIds().size<300?n(t.getZoomLevel()):r(t.getZoomLevel())});return s.attach(),s.execute(),()=>{s.detach(),r.cancel()}},[t,e])}function jx(t){const e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let r=0,s=t.length;r<s;r++)n[r]=t.charCodeAt(r);return e}function Nee(t){const e=atob(t),n=jx(e);return crypto.subtle.importKey("spki",new Uint8Array(n),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}const zee=5,Wc={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8},Bee=Math.max(...Object.values(Wc)),Gc={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},Uee=Object.keys(Gc).length,tS="sales@tldraw.com",Hee=`${ti()}/watermarks/watermark-track.svg`;class Xg{constructor(e,n,r){I(this,"publicKey","MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ");I(this,"isDevelopment");I(this,"isTest");I(this,"isCryptoAvailable");I(this,"state",It("license state","pending"));I(this,"verbose",!0);this.isTest=!1,this.isDevelopment=this.getIsDevelopment(r),this.publicKey=n||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(e).then(s=>{const o=Kee(s);!this.isDevelopment&&o&&Rs(Hee),o?this.state.set("unlicensed"):s.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[n,r]=e.split("."),[s,o]=n.split("/");if(!s.startsWith("tldraw-"))throw new Error(`Unsupported prefix '${s}'`);const i=await Nee(this.publicKey);let a;try{a=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},i,new Uint8Array(jx(atob(r))),new Uint8Array(jx(atob(o))))}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(o))}catch{throw new Error("Could not parse object")}return l.length>Uee&&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[Gc.ID],hosts:l[Gc.HOSTS],flags:l[Gc.FLAGS],expiryDate:l[Gc.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 n=e.replace(/[\u200B-\u200D\uFEFF]/g,"");n=n.replace(/\r?\n|\r/g,"");try{const r=await this.extractLicenseKey(n),s=new Date(r.expiryDate),o=this.isFlagEnabled(r.flags,Wc.ANNUAL_LICENSE),i=this.isFlagEnabled(r.flags,Wc.PERPETUAL_LICENSE),a={license:r,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(r),expiryDate:s,isAnnualLicense:o,isAnnualLicenseExpired:o&&this.isAnnualLicenseExpired(s),isPerpetualLicense:i,isPerpetualLicenseExpired:i&&this.isPerpetualLicenseExpired(s),isInternalLicense:this.isFlagEnabled(r.flags,Wc.INTERNAL_LICENSE),isLicensedWithWatermark:this.isFlagEnabled(r.flags,Wc.WITH_WATERMARK)};return this.outputLicenseInfoIfNeeded(a),a}catch(r){return this.outputInvalidLicenseKey(r.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(e){const n=window.location.hostname.toLowerCase();return e.hosts.some(r=>{const s=r.toLowerCase().trim();if(s===n||`www.${s}`===n||s===`www.${n}`||r==="*")return!0;if(r.includes("*")){const o=new RegExp(r.replace(/\*/g,".*?"));return o.test(n)||o.test(`www.${n}`)}return!1})}getExpirationDateWithoutGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}getExpirationDateWithGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+zee+1)}isAnnualLicenseExpired(e){const n=this.getExpirationDateWithGracePeriod(e),r=new Date>=n;return!r&&new Date>=this.getExpirationDateWithoutGracePeriod(e)&&this.outputMessages(["tldraw license is about to expire, you are in a grace period.",`Please reach out to ${tS} if you would like to renew your license.`]),r}isPerpetualLicenseExpired(e){const n=this.getExpirationDateWithGracePeriod(e),r={major:new Date(tI.major),minor:new Date(tI.minor)};return r.major>=n||r.minor>=n}isFlagEnabled(e,n){return(e&n)===n}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 ${tS} to renew.`]),!e.isDomainValid&&!e.isDevelopment&&this.outputMessages(["This tldraw license key is not valid for this domain!",`Please reach out to ${tS} if you would like to use tldraw on other domains.`]),e.license.flags>=Bee*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 n of e)console.log(`%c${n}`,"color: white; background: crimson; padding: 2px; border-radius: 3px;");this.outputDelimiter()}}outputDelimiter(){console.log("%c-------------------------------------------------------------------","color: white; background: crimson; padding: 2px; border-radius: 3px;")}}I(Xg,"className","tl-watermark_SEE-LICENSE");function Kee(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 VR=w.createContext({}),Wee=()=>w.useContext(VR);function Gee({licenseKey:t,children:e}){const[n]=w.useState(()=>new Xg(t));return d.jsx(VR.Provider,{value:n,children:e})}function Ai(t){if(!t)throw Error("usePassThroughWheelEvents must be passed a ref");const e=Tt();w.useEffect(()=>{function n(s){if(s.isSpecialRedispatchedEvent)return;xe(s);const o=e.querySelector(".tl-canvas");if(!o)return;const i=new WheelEvent("wheel",s);i.isSpecialRedispatchedEvent=!0,o.dispatchEvent(i)}const r=t.current;if(r)return r.addEventListener("wheel",n,{passive:!1}),()=>{r.removeEventListener("wheel",n)}},[e,t])}const Vee='<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>',Yee='<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>';function Xee(t){return U("watermarkState",()=>t.state.get(),[t])}const qee=`data:image/svg+xml;utf8,${encodeURIComponent(Vee)}`,Zee=`data:image/svg+xml;utf8,${encodeURIComponent(Yee)}`,Qee=w.memo(function(){const e=Wee(),n=z(),r=U("is mobile",()=>n.getViewportScreenBounds().width<700,[n]),s=Xee(e);return["licensed-with-watermark","unlicensed"].includes(s)?d.jsxs(d.Fragment,{children:[d.jsx(ete,{}),d.jsx(Jee,{src:r?Zee:qee})]}):null}),Jee=w.memo(function({src:e}){const n=z(),r=U("debug mode",()=>n.getInstanceState().isDebugMode,[n]),s=U("is mobile",()=>n.getViewportScreenBounds().width<700,[n]),o=mb(),i=w.useRef(null);Ai(i);const a=`url('${e}') center 100% / 100% no-repeat`,l="https://tldraw.dev";return d.jsx("div",{ref:i,className:Xg.className,"data-debug":r,"data-mobile":s,draggable:!1,...o,children:Ge.isWebview?d.jsx("a",{draggable:!1,role:"button",onPointerDown:c=>{Ct(c),xe(c)},onClick:()=>$g.openWindow(l,"_blank"),style:{mask:a,WebkitMask:a}}):d.jsx("a",{href:l,target:"_blank",rel:"noreferrer",draggable:!1,onPointerDown:c=>{Ct(c)},style:{mask:a,WebkitMask:a}})})}),ete=w.memo(function(){const e=Xg.className,n=`/* ------------------- SEE LICENSE -------------------
|
|
114
|
-
The tldraw watermark is part of tldraw's license. It is shown for unlicensed
|
|
115
|
-
or "licensed-with-watermark" users. By using this library, you agree to
|
|
116
|
-
preserve the watermark's behavior, keeping it visible, unobscured, and
|
|
117
|
-
available to user-interaction.
|
|
118
|
-
|
|
119
|
-
To remove the watermark, please purchase a license at tldraw.dev.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
.${e} {
|
|
123
|
-
position: absolute;
|
|
124
|
-
bottom: var(--space-2);
|
|
125
|
-
right: var(--space-2);
|
|
126
|
-
width: 96px;
|
|
127
|
-
height: 32px;
|
|
128
|
-
display: flex;
|
|
129
|
-
align-items: center;
|
|
130
|
-
justify-content: center;
|
|
131
|
-
z-index: var(--layer-watermark) !important;
|
|
132
|
-
background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
|
|
133
|
-
opacity: 1;
|
|
134
|
-
border-radius: 5px;
|
|
135
|
-
pointer-events: all;
|
|
136
|
-
padding: 2px;
|
|
137
|
-
box-sizing: content-box;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.${e} > a {
|
|
141
|
-
position: absolute;
|
|
142
|
-
width: 96px;
|
|
143
|
-
height: 32px;
|
|
144
|
-
pointer-events: all;
|
|
145
|
-
cursor: inherit;
|
|
146
|
-
color: var(--color-text);
|
|
147
|
-
opacity: .38;
|
|
148
|
-
background-color: currentColor;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.${e}[data-debug='true'] {
|
|
152
|
-
bottom: 46px;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.${e}[data-mobile='true'] {
|
|
156
|
-
border-radius: 4px 0px 0px 4px;
|
|
157
|
-
right: -2px;
|
|
158
|
-
width: 8px;
|
|
159
|
-
height: 48px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.${e}[data-mobile='true'] > a {
|
|
163
|
-
width: 8px;
|
|
164
|
-
height: 32px;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@media (hover: hover) {
|
|
168
|
-
.${e} > a {
|
|
169
|
-
pointer-events: none;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.${e}:hover {
|
|
173
|
-
background-color: var(--color-background);
|
|
174
|
-
transition: background-color 0.2s ease-in-out;
|
|
175
|
-
transition-delay: 0.32s;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.${e}:hover > a {
|
|
179
|
-
animation: delayed_link 0.2s forwards ease-in-out;
|
|
180
|
-
animation-delay: 0.32s;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@keyframes delayed_link {
|
|
185
|
-
0% {
|
|
186
|
-
cursor: inherit;
|
|
187
|
-
opacity: .38;
|
|
188
|
-
pointer-events: none;
|
|
189
|
-
}
|
|
190
|
-
100% {
|
|
191
|
-
cursor: pointer;
|
|
192
|
-
opacity: 1;
|
|
193
|
-
pointer-events: all;
|
|
194
|
-
}
|
|
195
|
-
}`;return d.jsx("style",{children:n})}),tte=[],nte=[],rte=[],ste="tl-container",ote=w.memo(function({store:e,components:n,className:r,user:s,options:o,...i}){const[a,l]=w.useState(null),c=w.useMemo(()=>s??Uj(),[s]),u=(n==null?void 0:n.ErrorFallback)===void 0?Oj:n==null?void 0:n.ErrorFallback,h={...i,shapeUtils:i.shapeUtils??tte,bindingUtils:i.bindingUtils??nte,tools:i.tools??rte,components:n,options:tc(o)};return d.jsx("div",{ref:l,"data-tldraw":oj,draggable:!1,className:ce(`${ste} tl-theme__light`,r),onPointerDown:Ct,tabIndex:-1,children:d.jsx(Uu,{fallback:u,onError:f=>v0(f,{tags:{origin:"react.tldraw-before-app"}}),children:a&&d.jsx(Gee,{licenseKey:i.licenseKey,children:d.jsx(hj,{container:a,children:d.jsx(AZ,{overrides:n,children:e?e instanceof eb?d.jsx(XR,{...h,store:e,user:c}):d.jsx(YR,{...h,store:e,user:c}):d.jsx(ite,{...h,store:e,user:c})})})})})})});function ite(t){const{defaultName:e,snapshot:n,initialData:r,shapeUtils:s,bindingUtils:o,persistenceKey:i,sessionId:a,user:l,assets:c,migrations:u}=t,h=$ee({shapeUtils:s,bindingUtils:o,initialData:r,persistenceKey:i,sessionId:a,defaultName:e,snapshot:n,assets:c,migrations:u});return d.jsx(YR,{...t,store:h,user:l})}const YR=w.memo(function({store:e,user:n,...r}){const s=Tt();w.useLayoutEffect(()=>{n.userPreferences.get().colorScheme==="dark"&&(s.classList.remove("tl-theme__light"),s.classList.add("tl-theme__dark"))},[s,n]);const{LoadingScreen:o}=st();switch(e.status){case"error":throw e.error;case"loading":return o?d.jsx(o,{}):null}return d.jsx(XR,{...r,store:e.store,user:n})}),nS=()=>document.location.search.includes("tldraw_preserve_focus");function XR({onMount:t,children:e,store:n,tools:r,shapeUtils:s,bindingUtils:o,user:i,initialState:a,autoFocus:l=!0,inferDarkMode:c,cameraOptions:u,options:h,licenseKey:f,deepLinks:p,isShapeHidden:g}){const{ErrorFallback:m}=st(),v=Tt(),[y,S]=GR(null),b=w.useRef(null),P=tc(p===!0?{}:p),C=w.useRef({autoFocus:l&&!nS(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:P});w.useLayoutEffect(()=>{C.current={autoFocus:l&&!nS(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:P}},[l,c,a,u,P]),w.useLayoutEffect(()=>{const{autoFocus:k,inferDarkMode:D,initialState:T,cameraOptions:j,deepLinks:L}=C.current,M=new Q({store:n,shapeUtils:s,bindingUtils:o,tools:r,getContainer:()=>v,user:i,initialState:T,autoFocus:k,inferDarkMode:D,cameraOptions:j,options:h,licenseKey:f,isShapeHidden:g});return M.updateViewportScreenBounds(b.current??v),L&&(L!=null&&L.getUrl?M.navigateToDeepLink({...L,url:L.getUrl(M)}):M.navigateToDeepLink(L)),S(M),()=>{M.dispose()}},[o,v,h,s,n,r,i,S,f,g]),w.useLayoutEffect(()=>{if(y&&P)return y.registerDeepLinkListener(P)},[y,P]),w.useLayoutEffect(()=>{y&&u&&y.setCameraOptions(u)},[y,u]);const _=w.useSyncExternalStore(w.useCallback(k=>y?(y.on("crash",k),()=>y.off("crash",k)):()=>{},[y]),()=>(y==null?void 0:y.getCrashingError())??null);w.useEffect(function(){if(!y)return;function D(){y&&y.focus()}function T(){y&&y.blur()}if(l&&nS())return y.getContainer().addEventListener("pointerdown",D),document.body.addEventListener("pointerdown",T),()=>{var j;(j=y.getContainer())==null||j.removeEventListener("pointerdown",D),document.body.removeEventListener("pointerdown",T)}},[y,l]);const{Canvas:E}=st();return y?d.jsx(Uu,{fallback:m,onError:k=>y.annotateError(k,{origin:"react.tldraw",willCrashApp:!0}),children:_?d.jsx(lte,{crashingError:_}):d.jsx(fb,{editor:y,children:d.jsxs(ate,{onMount:t,children:[e??(E?d.jsx(E,{},y.contextId):null),d.jsx(Qee,{})]})})}):d.jsx("div",{className:"tl-canvas",ref:b})}function ate({children:t,onMount:e}){return Fee(),Pee(),Cee(),_ee(),ZR(n=>{const r=n.store.props.onMount(n),s=e==null?void 0:e(n);return()=>{r==null||r(),s==null||s()}}),t}function lte({crashingError:t}){throw t}function Db({children:t}){return d.jsx("div",{className:"tl-loading",children:t})}function qR({children:t}){return d.jsx("div",{className:"tl-loading",children:t})}function ZR(t){const e=z(),n=Hg(r=>{let s;return r.run(()=>{s=t==null?void 0:t(r),r.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,s});ke.useLayoutEffect(()=>{if(e)return n==null?void 0:n(e)},[e,n])}function hi({children:t,className:e="",...n}){return d.jsx("div",{...n,className:ce("tl-html-container",e),children:t})}class ff{constructor(e){this.editor=e}}I(ff,"props"),I(ff,"migrations"),I(ff,"type");function qg(t,e,n={}){const{newPoint:r,handle:s,scaleX:o,scaleY:i}=e,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=n;let h=t.props.w*o,f=t.props.h*i;const p=new x(0,0);if(h>0){if(h<a){switch(s){case"top_left":case"left":case"bottom_left":{p.x=h-a;break}case"top":case"bottom":{p.x=(h-a)/2;break}default:p.x=0}h=a}}else if(p.x=h,h=-h,h<a){switch(s){case"top_left":case"left":case"bottom_left":{p.x=-h;break}default:p.x=-a}h=a}if(f>0){if(f<c){switch(s){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(s){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(r);return{...t,x:g,y:m,props:{w:Math.min(l,h),h:Math.min(u,f)}}}class oc extends ss{getGeometry(e){return new Fs({width:e.props.w,height:e.props.h,isFilled:!0})}onResize(e,n){return qg(e,n)}getHandleSnapGeometry(e){return{points:this.getGeometry(e).bounds.cornersAndCenter}}getInterpolatedProps(e,n,r){return{...n.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r)}}}var jS;let cte=(jS=class extends ie{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},I(jS,"id","idle"),jS);var OS;let ute=(OS=class extends ie{onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:n}=this.editor.inputs,r=this.parent.shapeType,s=Ke(),o=this.editor.markHistoryStoppingPoint(`creating_box:${s}`),i=is(n,this.editor);this.editor.createShapes([{id:s,type:r,x:i.x,y:i.y,props:{w:1,h:1}}]).select(s);const a=this.parent;this.editor.setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:o,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:e}=this.editor.inputs,n=this.parent.shapeType,r=Ke();this.editor.markHistoryStoppingPoint(`creating_box:${r}`),this.editor.createShapes([{id:r,type:n,x:e.x,y:e.y}]);const s=this.editor.getShape(r);if(!s){this.cancel();return}let{w:o,h:i}=s.props;const a=new x(o/2,i/2),l=this.editor.getShapeParentTransform(s);l&&a.rot(-l.rotation());let c=1;this.editor.user.getIsDynamicResizeMode()&&(c=1/this.editor.getZoomLevel(),o*=c,i*=c,a.mul(c));const u=nt(s),h=is(new x(s.x-a.x,s.y-a.y),this.editor);u.x=h.x,u.y=h.y,u.props.w=o,u.props.h=i,"scale"in s.props&&(u.props.scale=c),this.editor.updateShape(u),this.editor.setSelectedShapes([r]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},I(OS,"id","pointing"),OS);function is(t,e){const n=e.getInstanceState().isGridMode,r=e.getDocumentSettings().gridSize;return n?t.clone().snapToGrid(r):t.clone()}class Ox extends ie{static children(){return[cte,ute]}}I(Ox,"id","box"),I(Ox,"initial","idle");function dte(t,e,n){const r=w.useRef(!1),s=w.useCallback(i=>{r.current=i,i?Vr.addOpenMenu(t):Vr.deleteOpenMenu(t),e==null||e(i)},[t,e]),o=U("is menu open",()=>Vr.getOpenMenus().includes(t),[t]);return w.useEffect(()=>(r.current&&(n==null||n("open-menu"),Vr.addOpenMenu(t)),()=>{r.current&&(Vr.deleteOpenMenu(t),Vr.getOpenMenus().forEach(i=>{i.startsWith(t)&&(n==null||n("close-menu"),Vr.deleteOpenMenu(i))}),r.current=!1)}),[t,n]),[o,s]}function Zg(t){const e=z();return U("isEditing",()=>e.getEditingShapeId()===t,[e,t])}function ws(t){const e=z();return w.useMemo(function(){const s=c=>{if(c.isKilled)return;if(c.button===gb){e.dispatch({type:"pointer",target:"selection",handle:t,name:"right_click",...lr(c)});return}if(c.button!==0)return;const u=Lp(c.currentTarget);function h(){u.removeEventListener("pointerup",h),hd(u,c)}dd(u,c),u.addEventListener("pointerup",h),e.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:t,...lr(c)}),Ct(c)};let o,i;function a(c){c.isKilled||c.button===0&&(c.clientX===o&&c.clientY===i||(o=c.clientX,i=c.clientY,e.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:t,...lr(c)})))}return{onPointerDown:s,onPointerMove:a,onPointerUp:c=>{c.isKilled||c.button===0&&e.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:t,...lr(c)})}}},[e,t])}function hte(t){const[e,n]=w.useState(()=>({store:Hu(t),opts:t}));if(!zT(e.opts,t)){const r={store:Hu(t),opts:t};return n(r),r.store}return e.store}const fte=20,pte=8;function Rb(t,e=fte){return Math.max(pte,Math.ceil(t/e))}class cl extends Mi{constructor(n){super({...n,isFilled:!1,isClosed:!1});I(this,"_center");I(this,"radius");I(this,"start");I(this,"end");I(this,"largeArcFlag");I(this,"sweepFlag");I(this,"measure");I(this,"angleStart");I(this,"angleEnd");const{center:r,sweepFlag:s,largeArcFlag:o,start:i,end:a}=n;if(i.equals(a))throw Error("Arc must have different start and end points.");this.angleStart=x.Angle(r,i),this.angleEnd=x.Angle(r,a),this.radius=x.Dist(r,i),this.measure=vX(this.angleStart,this.angleEnd,s,o),this.start=i,this.end=a,this.sweepFlag=s,this.largeArcFlag=o,this._center=r}nearestPoint(n){const{_center:r,measure:s,radius:o,angleEnd:i,angleStart:a,start:l,end:c}=this,u=xx(s,a,i,r.angle(n));if(u<=0)return l;if(u>=1)return c;const h=r.clone().add(n.clone().sub(r).uni().mul(o));let f,p=1/0,g;for(const m of[l,c,h])g=x.Dist2(n,m),g<p&&(f=m,p=g);if(!f)throw Error("nearest point not found");return f}hitTestLineSegment(n,r){const{_center:s,radius:o,measure:i,angleStart:a,angleEnd:l}=this,c=gd(n,r,s,o);return c===null?!1:c.some(u=>{const h=xx(i,a,l,s.angle(u));return h>=0&&h<=1})}getVertices(){const{_center:n,measure:r,length:s,radius:o,angleStart:i}=this,a=[];for(let l=0,c=Rb(Math.abs(s));l<c+1;l++){const u=l/c*r,h=i+u;a.push(ha(n,o,h))}return a}getSvgPathData(n=!0){const{start:r,end:s,radius:o,largeArcFlag:i,sweepFlag:a}=this;return`${n?`M${r.toFixed()}`:""} A${o} ${o} 0 ${i} ${a} ${s.toFixed()}`}getLength(){return this.measure*this.radius}}class Lb extends Mi{constructor(n){super({isClosed:!0,...n});I(this,"_center");I(this,"radius");I(this,"x");I(this,"y");this.config=n;const{x:r=0,y:s=0,radius:o}=n;this.x=r,this.y=s,this._center=new x(o+r,o+s),this.radius=o}getBounds(){return new Z(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:n,radius:r}=this,s=Fe*r,o=[];for(let i=0,a=Rb(s);i<a;i++){const l=i/a*Fe;o.push(ha(n,r,l))}return o}nearestPoint(n){const{_center:r,radius:s}=this;return r.equals(n)?x.AddXY(r,s,0):r.clone().add(n.clone().sub(r).uni().mul(s))}hitTestLineSegment(n,r,s=0){const{_center:o,radius:i}=this;return gd(n,r,o,i+s)!==null}getSvgPathData(){const{_center:n,radius:r}=this;return`M${n.x+r},${n.y} a${r},${r} 0 1,0 ${r*2},0a${r},${r} 0 1,0 -${r*2},0`}}class an extends nc{constructor(n){const{start:r,cp1:s,cp2:o,end:i}=n;super({...n,points:[r,i]});I(this,"a");I(this,"b");I(this,"c");I(this,"d");this.a=r,this.b=s,this.c=o,this.d=i}getVertices(){const n=[],{a:r,b:s,c:o,d:i}=this;for(let a=0,l=10;a<=l;a++){const c=a/l;n.push(new x((1-c)*(1-c)*(1-c)*r.x+3*((1-c)*(1-c))*c*s.x+3*(1-c)*(c*c)*o.x+c*c*c*i.x,(1-c)*(1-c)*(1-c)*r.y+3*((1-c)*(1-c))*c*s.y+3*(1-c)*(c*c)*o.y+c*c*c*i.y))}return n}midPoint(){return an.GetAtT(this,.5)}nearestPoint(n){let r,s=1/0,o,i;for(const a of this.segments)i=a.nearestPoint(n),o=x.Dist2(i,n),o<s&&(r=i,s=o);if(!r)throw Error("nearest point not found");return r}getSvgPathData(n=!0){const{a:r,b:s,c:o,d:i}=this;return`${n?`M ${r.toFixed()} `:""} C${s.toFixed()} ${o.toFixed()} ${i.toFixed()}`}static GetAtT(n,r){const{a:s,b:o,c:i,d:a}=n;return new x((1-r)*(1-r)*(1-r)*s.x+3*((1-r)*(1-r))*r*o.x+3*(1-r)*(r*r)*i.x+r*r*r*a.x,(1-r)*(1-r)*(1-r)*s.y+3*((1-r)*(1-r))*r*o.y+3*(1-r)*(r*r)*i.y+r*r*r*a.y)}getLength(n=32){let r,s=this.a,o=0;for(let i=1;i<=n;i++)r=an.GetAtT(this,i/n),o+=x.Dist(s,r),s=r;return o}}class gte extends Mi{constructor(n){super({...n,isClosed:!1,isFilled:!1});I(this,"points");I(this,"_segments");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{points:n}=this,r=n.length,s=r-2,o=1.25;for(let i=0;i<r-1;i++){const a=i===0?n[0]:n[i-1],l=n[i],c=n[i+1],u=i===s?c:n[i+2],h=l,f=i===0?a:new x(l.x+(c.x-a.x)/6*o,l.y+(c.y-a.y)/6*o),p=i===s?c:new x(c.x-(u.x-l.x)/6*o,c.y-(u.y-l.y)/6*o),g=c;this._segments.push(new an({start:h,cp1:f,cp2:p,end:g}))}}return this._segments}getLength(){return this.segments.reduce((n,r)=>n+r.length,0)}getVertices(){const n=this.segments.reduce((r,s)=>r.concat(s.vertices),[]);return n.push(this.points[this.points.length-1]),n}nearestPoint(n){let r,s=1/0,o,i;for(const a of this.segments)i=a.nearestPoint(n),o=x.Dist2(i,n),o<s&&(r=i,s=o);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.segments.some(s=>s.hitTestLineSegment(n,r))}getSvgPathData(){let n=this.segments.reduce((r,s,o)=>r+s.getSvgPathData(o===0),"");return this.isClosed&&(n+="Z"),n}}class mte extends Mi{constructor(n){super({...n,isClosed:!0});I(this,"w");I(this,"h");I(this,"_edges");this.config=n;const{width:r,height:s}=n;this.w=r,this.h=s}get edges(){if(!this._edges){const{vertices:n}=this;this._edges=[];for(let r=0,s=n.length;r<s;r++){const o=n[r],i=n[(r+1)%s];this._edges.push(new co({start:o,end:i}))}}return this._edges}getVertices(){const n=Math.max(1,this.w),r=Math.max(1,this.h),s=n/2,o=r/2,i=Math.pow(s-o,2)/Math.pow(s+o,2),a=De*(s+o)*(1+3*i/(10+Math.sqrt(4-3*i))),l=Rb(a),c=Fe/l,u=Math.cos(c),h=Math.sin(c);let f=0,p=1,g=0,m=1;const v=Array(l);for(let y=0;y<l;y++)v[y]=new x(s+s*p,o+o*f),g=h*p+u*f,m=u*p-h*f,f=g,p=m;return v}nearestPoint(n){let r,s=1/0,o,i;for(const a of this.edges)i=a.nearestPoint(n),o=x.Dist2(i,n),o<s&&(r=i,s=o);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.edges.some(s=>s.hitTestLineSegment(n,r))}getBounds(){return new Z(0,0,this.w,this.h)}getLength(){const{w:n,h:r}=this,s=n/2,o=r/2,i=Math.max(0,s),a=Math.max(0,o);return aj(i,a)}getSvgPathData(n=!1){const{w:r,h:s}=this,o=r/2,i=s/2,a=Math.max(0,o),l=Math.max(0,i);return`${n?`M${o-a},${i}`:""} a${a},${l},0,1,1,${a*2},0a${a},${l},0,1,1,-${a*2},0`}}class yte extends Mi{constructor(n){super({...n,isClosed:!0});I(this,"w");I(this,"h");I(this,"a");I(this,"b");I(this,"c");I(this,"d");this.config=n;const{width:r,height:s}=n;if(this.w=r,this.h=s,s>r){const o=r/2;this.a=new cl({start:new x(0,o),end:new x(r,o),center:new x(r/2,o),sweepFlag:1,largeArcFlag:1}),this.b=new co({start:new x(r,o),end:new x(r,s-o)}),this.c=new cl({start:new x(r,s-o),end:new x(0,s-o),center:new x(r/2,s-o),sweepFlag:1,largeArcFlag:1}),this.d=new co({start:new x(0,s-o),end:new x(0,o)})}else{const o=s/2;this.a=new cl({start:new x(o,s),end:new x(o,0),center:new x(o,o),sweepFlag:1,largeArcFlag:1}),this.b=new co({start:new x(o,0),end:new x(r-o,0)}),this.c=new cl({start:new x(r-o,0),end:new x(r-o,s),center:new x(r-o,o),sweepFlag:1,largeArcFlag:1}),this.d=new co({start:new x(r-o,s),end:new x(o,s)})}}nearestPoint(n){let r,s=1/0,o,i;const{a,b:l,c,d:u}=this;for(const h of[a,l,c,u])i=h.nearestPoint(n),o=x.Dist2(i,n),o<s&&(r=i,s=o);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){const{a:s,b:o,c:i,d:a}=this;return[s,o,i,a].some(l=>l.hitTestLineSegment(n,r))}getVertices(){const{a:n,b:r,c:s,d:o}=this;return[n,r,s,o].reduce((i,a)=>(i.push(...a.vertices),i),[])}getBounds(){return new Z(0,0,this.w,this.h)}getLength(){const{h:n,w:r}=this;return n>r?(De*(r/2)+(n-r))*2:(De*(n/2)+(r-n))*2}getSvgPathData(){const{a:n,b:r,c:s,d:o}=this;return[n,r,s,o].map((i,a)=>i.getSvgPathData(a===0)).join(" ")+" Z"}}async function Ste({shouldReload:t=!0}={}){uB();for(const e of wp.connectedInstances)await e.close();await Promise.all(Q0().map(e=>hA(e))),cB(),t&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=Ste);function vte(t,e="_blank"){$g.openWindow(t,e)}_i("@tldraw/editor","3.7.2","esm");function QR(){const[t,e]=w.useState(!1);return w.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{e(n.matches)};return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const JR=()=>{},e3=w.createContext(null);function xte({onEvent:t,children:e}){return d.jsx(e3.Provider,{value:t??JR,children:e})}function Jt(){return w.useContext(e3)??JR}function se(t,e,{checkForDefaultPrevented:n=!0}={}){return function(s){if(t==null||t(s),n===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function wte(t,e){const n=w.createContext(e),r=o=>{const{children:i,...a}=o,l=w.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:l,children:i})};r.displayName=t+"Provider";function s(o){const i=w.useContext(n);if(i)return i;if(e!==void 0)return e;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[r,s]}function Ws(t,e=[]){let n=[];function r(o,i){const a=w.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:f,children:p,...g}=h,m=((y=f==null?void 0:f[t])==null?void 0:y[l])||a,v=w.useMemo(()=>g,Object.values(g));return d.jsx(m.Provider,{value:v,children:p})};c.displayName=o+"Provider";function u(h,f){var m;const p=((m=f==null?void 0:f[t])==null?void 0:m[l])||a,g=w.useContext(p);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[c,u]}const s=()=>{const o=n.map(i=>w.createContext(i));return function(a){const l=(a==null?void 0:a[t])||o;return w.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return s.scopeName=t,[r,bte(s,...e)]}function bte(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(o)[`__scope${c}`];return{...a,...h}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}function GI(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Qg(...t){return e=>{let n=!1;const r=t.map(s=>{const o=GI(s,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let s=0;s<r.length;s++){const o=r[s];typeof o=="function"?o():GI(t[s],null)}}}}function Qe(...t){return w.useCallback(Qg(...t),t)}var fa=w.forwardRef((t,e)=>{const{children:n,...r}=t,s=w.Children.toArray(n),o=s.find(Cte);if(o){const i=o.props.children,a=s.map(l=>l===o?w.Children.count(i)>1?w.Children.only(null):w.isValidElement(i)?i.props.children:null:l);return d.jsx(Dx,{...r,ref:e,children:w.isValidElement(i)?w.cloneElement(i,void 0,a):null})}return d.jsx(Dx,{...r,ref:e,children:n})});fa.displayName="Slot";var Dx=w.forwardRef((t,e)=>{const{children:n,...r}=t;if(w.isValidElement(n)){const s=Ite(n);return w.cloneElement(n,{..._te(r,n.props),ref:e?Qg(e,s):s})}return w.Children.count(n)>1?w.Children.only(null):null});Dx.displayName="SlotClone";var Pte=({children:t})=>d.jsx(d.Fragment,{children:t});function Cte(t){return w.isValidElement(t)&&t.type===Pte}function _te(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...a)=>{o(...a),s(...a)}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...t,...n}}function Ite(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Ete=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ae=Ete.reduce((t,e)=>{const n=w.forwardRef((r,s)=>{const{asChild:o,...i}=r,a=o?fa:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(a,{...i,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function $b(t,e){t&&ba.flushSync(()=>t.dispatchEvent(e))}function Jg(t){const e=t+"CollectionProvider",[n,r]=Ws(e),[s,o]=n(e,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:g,children:m}=p,v=ke.useRef(null),y=ke.useRef(new Map).current;return d.jsx(s,{scope:g,itemMap:y,collectionRef:v,children:m})};i.displayName=e;const a=t+"CollectionSlot",l=ke.forwardRef((p,g)=>{const{scope:m,children:v}=p,y=o(a,m),S=Qe(g,y.collectionRef);return d.jsx(fa,{ref:S,children:v})});l.displayName=a;const c=t+"CollectionItemSlot",u="data-radix-collection-item",h=ke.forwardRef((p,g)=>{const{scope:m,children:v,...y}=p,S=ke.useRef(null),b=Qe(g,S),P=o(c,m);return ke.useEffect(()=>(P.itemMap.set(S,{ref:S,...y}),()=>void P.itemMap.delete(S))),d.jsx(fa,{[u]:"",ref:b,children:v})});h.displayName=c;function f(p){const g=o(t+"CollectionConsumer",p);return ke.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${u}]`));return Array.from(g.itemMap.values()).sort((P,C)=>y.indexOf(P.ref.current)-y.indexOf(C.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:l,ItemSlot:h},f,r]}var kte=w.createContext(void 0);function Fb(t){const e=w.useContext(kte);return t||e||"ltr"}function qt(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),w.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function Tte(t,e=globalThis==null?void 0:globalThis.document){const n=qt(t);w.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var Mte="DismissableLayer",Rx="dismissableLayer.update",Ate="dismissableLayer.pointerDownOutside",jte="dismissableLayer.focusOutside",VI,t3=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wd=w.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,onDismiss:a,...l}=t,c=w.useContext(t3),[u,h]=w.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),g=Qe(e,E=>h(E)),m=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(v),S=u?m.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,P=S>=y,C=Dte(E=>{const k=E.target,D=[...c.branches].some(T=>T.contains(k));!P||D||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},f),_=Rte(E=>{const k=E.target;[...c.branches].some(T=>T.contains(k))||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},f);return Tte(E=>{S===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},f),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(VI=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),YI(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=VI)}},[u,f,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),YI())},[u,c]),w.useEffect(()=>{const E=()=>p({});return document.addEventListener(Rx,E),()=>document.removeEventListener(Rx,E)},[]),d.jsx(Ae.div,{...l,ref:g,style:{pointerEvents:b?P?"auto":"none":void 0,...t.style},onFocusCapture:se(t.onFocusCapture,_.onFocusCapture),onBlurCapture:se(t.onBlurCapture,_.onBlurCapture),onPointerDownCapture:se(t.onPointerDownCapture,C.onPointerDownCapture)})});wd.displayName=Mte;var Ote="DismissableLayerBranch",n3=w.forwardRef((t,e)=>{const n=w.useContext(t3),r=w.useRef(null),s=Qe(e,r);return w.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),d.jsx(Ae.div,{...t,ref:s})});n3.displayName=Ote;function Dte(t,e=globalThis==null?void 0:globalThis.document){const n=qt(t),r=w.useRef(!1),s=w.useRef(()=>{});return w.useEffect(()=>{const o=a=>{if(a.target&&!r.current){let l=function(){r3(Ate,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=l,e.addEventListener("click",s.current,{once:!0})):l()}else e.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",o),e.removeEventListener("click",s.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function Rte(t,e=globalThis==null?void 0:globalThis.document){const n=qt(t),r=w.useRef(!1);return w.useEffect(()=>{const s=o=>{o.target&&!r.current&&r3(jte,n,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function YI(){const t=new CustomEvent(Rx);document.dispatchEvent(t)}function r3(t,e,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?$b(s,o):s.dispatchEvent(o)}var Lte=wd,$te=n3,rS=0;function Nb(){w.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??XI()),document.body.insertAdjacentElement("beforeend",t[1]??XI()),rS++,()=>{rS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),rS--}},[])}function XI(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var sS="focusScope.autoFocusOnMount",oS="focusScope.autoFocusOnUnmount",qI={bubbles:!1,cancelable:!0},Fte="FocusScope",em=w.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...i}=t,[a,l]=w.useState(null),c=qt(s),u=qt(o),h=w.useRef(null),f=Qe(e,m=>l(m)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let m=function(b){if(p.paused||!a)return;const P=b.target;a.contains(P)?h.current=P:Uo(h.current,{select:!0})},v=function(b){if(p.paused||!a)return;const P=b.relatedTarget;P!==null&&(a.contains(P)||Uo(h.current,{select:!0}))},y=function(b){if(document.activeElement===document.body)for(const C of b)C.removedNodes.length>0&&Uo(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const S=new MutationObserver(y);return a&&S.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),S.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){QI.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(sS,qI);a.addEventListener(sS,c),a.dispatchEvent(y),y.defaultPrevented||(Nte(Kte(s3(a)),{select:!0}),document.activeElement===m&&Uo(a))}return()=>{a.removeEventListener(sS,c),setTimeout(()=>{const y=new CustomEvent(oS,qI);a.addEventListener(oS,u),a.dispatchEvent(y),y.defaultPrevented||Uo(m??document.body,{select:!0}),a.removeEventListener(oS,u),QI.remove(p)},0)}}},[a,c,u,p]);const g=w.useCallback(m=>{if(!n&&!r||p.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(v&&y){const S=m.currentTarget,[b,P]=zte(S);b&&P?!m.shiftKey&&y===P?(m.preventDefault(),n&&Uo(b,{select:!0})):m.shiftKey&&y===b&&(m.preventDefault(),n&&Uo(P,{select:!0})):y===S&&m.preventDefault()}},[n,r,p.paused]);return d.jsx(Ae.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});em.displayName=Fte;function Nte(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Uo(r,{select:e}),document.activeElement!==n)return}function zte(t){const e=s3(t),n=ZI(e,t),r=ZI(e.reverse(),t);return[n,r]}function s3(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function ZI(t,e){for(const n of t)if(!Bte(n,{upTo:e}))return n}function Bte(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 Ute(t){return t instanceof HTMLInputElement&&"select"in t}function Uo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Ute(t)&&e&&t.select()}}var QI=Hte();function Hte(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=JI(t,e),t.unshift(e)},remove(e){var n;t=JI(t,e),(n=t[0])==null||n.resume()}}}function JI(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Kte(t){return t.filter(e=>e.tagName!=="A")}var yi=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Wte=t6.useId||(()=>{}),Gte=0;function mo(t){const[e,n]=w.useState(Wte());return yi(()=>{t||n(r=>r??String(Gte++))},[t]),t||(e?`radix-${e}`:"")}const Vte=["top","right","bottom","left"],Si=Math.min,or=Math.max,Np=Math.round,bh=Math.floor,Os=t=>({x:t,y:t}),Yte={left:"right",right:"left",bottom:"top",top:"bottom"},Xte={start:"end",end:"start"};function Lx(t,e,n){return or(t,Si(e,n))}function bo(t,e){return typeof t=="function"?t(e):t}function Po(t){return t.split("-")[0]}function ic(t){return t.split("-")[1]}function zb(t){return t==="x"?"y":"x"}function Bb(t){return t==="y"?"height":"width"}function vi(t){return["top","bottom"].includes(Po(t))?"y":"x"}function Ub(t){return zb(vi(t))}function qte(t,e,n){n===void 0&&(n=!1);const r=ic(t),s=Ub(t),o=Bb(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=zp(i)),[i,zp(i)]}function Zte(t){const e=zp(t);return[$x(t),e,$x(e)]}function $x(t){return t.replace(/start|end/g,e=>Xte[e])}function Qte(t,e,n){const r=["left","right"],s=["right","left"],o=["top","bottom"],i=["bottom","top"];switch(t){case"top":case"bottom":return n?e?s:r:e?r:s;case"left":case"right":return e?o:i;default:return[]}}function Jte(t,e,n,r){const s=ic(t);let o=Qte(Po(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map($x)))),o}function zp(t){return t.replace(/left|right|bottom|top/g,e=>Yte[e])}function ene(t){return{top:0,right:0,bottom:0,left:0,...t}}function o3(t){return typeof t!="number"?ene(t):{top:t,right:t,bottom:t,left:t}}function Bp(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function eE(t,e,n){let{reference:r,floating:s}=t;const o=vi(e),i=Ub(e),a=Bb(i),l=Po(e),c=o==="y",u=r.x+r.width/2-s.width/2,h=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-s.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:h};break;case"left":p={x:r.x-s.width,y:h};break;default:p={x:r.x,y:r.y}}switch(ic(e)){case"start":p[i]-=f*(n&&c?-1:1);break;case"end":p[i]+=f*(n&&c?-1:1);break}return p}const tne=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=o.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:h}=eE(c,r,l),f=r,p={},g=0;for(let m=0;m<a.length;m++){const{name:v,fn:y}=a[m],{x:S,y:b,data:P,reset:C}=await y({x:u,y:h,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:i,elements:{reference:t,floating:e}});u=S??u,h=b??h,p={...p,[v]:{...p[v],...P}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):C.rects),{x:u,y:h}=eE(c,f,l)),m=-1)}return{x:u,y:h,placement:f,strategy:s,middlewareData:p}};async function Ku(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=bo(e,t),g=o3(p),v=a[f?h==="floating"?"reference":"floating":h],y=Bp(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=h==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),P=await(o.isElement==null?void 0:o.isElement(b))?await(o.getScale==null?void 0:o.getScale(b))||{x:1,y:1}:{x:1,y:1},C=Bp(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:b,strategy:l}):S);return{top:(y.top-C.top+g.top)/P.y,bottom:(C.bottom-y.bottom+g.bottom)/P.y,left:(y.left-C.left+g.left)/P.x,right:(C.right-y.right+g.right)/P.x}}const nne=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=bo(t,e)||{};if(c==null)return{};const h=o3(u),f={x:n,y:r},p=Ub(s),g=Bb(p),m=await i.getDimensions(c),v=p==="y",y=v?"top":"left",S=v?"bottom":"right",b=v?"clientHeight":"clientWidth",P=o.reference[g]+o.reference[p]-f[p]-o.floating[g],C=f[p]-o.reference[p],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=_?_[b]:0;(!E||!await(i.isElement==null?void 0:i.isElement(_)))&&(E=a.floating[b]||o.floating[g]);const k=P/2-C/2,D=E/2-m[g]/2-1,T=Si(h[y],D),j=Si(h[S],D),L=T,M=E-m[g]-j,O=E/2-m[g]/2+k,F=Lx(L,O,M),B=!l.arrow&&ic(s)!=null&&O!==F&&o.reference[g]/2-(O<L?T:j)-m[g]/2<0,K=B?O<L?O-L:O-M:0;return{[p]:f[p]+K,data:{[p]:F,centerOffset:O-F-K,...B&&{alignmentOffset:K}},reset:B}}}),rne=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...v}=bo(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Po(s),S=vi(a),b=Po(a)===a,P=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(b||!m?[zp(a)]:Zte(a)),_=g!=="none";!f&&_&&C.push(...Jte(a,m,g,P));const E=[a,...C],k=await Ku(e,v),D=[];let T=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&D.push(k[y]),h){const O=qte(s,i,P);D.push(k[O[0]],k[O[1]])}if(T=[...T,{placement:s,overflows:D}],!D.every(O=>O<=0)){var j,L;const O=(((j=o.flip)==null?void 0:j.index)||0)+1,F=E[O];if(F)return{data:{index:O,overflows:T},reset:{placement:F}};let B=(L=T.filter(K=>K.overflows[0]<=0).sort((K,R)=>K.overflows[1]-R.overflows[1])[0])==null?void 0:L.placement;if(!B)switch(p){case"bestFit":{var M;const K=(M=T.filter(R=>{if(_){const H=vi(R.placement);return H===S||H==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(H=>H>0).reduce((H,X)=>H+X,0)]).sort((R,H)=>R[1]-H[1])[0])==null?void 0:M[0];K&&(B=K);break}case"initialPlacement":B=a;break}if(s!==B)return{reset:{placement:B}}}return{}}}};function tE(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function nE(t){return Vte.some(e=>t[e]>=0)}const sne=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=bo(t,e);switch(r){case"referenceHidden":{const o=await Ku(e,{...s,elementContext:"reference"}),i=tE(o,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:nE(i)}}}case"escaped":{const o=await Ku(e,{...s,altBoundary:!0}),i=tE(o,n.floating);return{data:{escapedOffsets:i,escaped:nE(i)}}}default:return{}}}}};async function one(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Po(n),a=ic(n),l=vi(n)==="y",c=["left","top"].includes(i)?-1:1,u=o&&l?-1:1,h=bo(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};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 ine=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=e,l=await one(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}},ane=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:y,y:S}=v;return{x:y,y:S}}},...l}=bo(t,e),c={x:n,y:r},u=await Ku(e,l),h=vi(Po(s)),f=zb(h);let p=c[f],g=c[h];if(o){const v=f==="y"?"top":"left",y=f==="y"?"bottom":"right",S=p+u[v],b=p-u[y];p=Lx(S,p,b)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",S=g+u[v],b=g-u[y];g=Lx(S,g,b)}const m=a.fn({...e,[f]:p,[h]:g});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[f]:o,[h]:i}}}}}},lne=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=bo(t,e),u={x:n,y:r},h=vi(s),f=zb(h);let p=u[f],g=u[h];const m=bo(a,e),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const b=f==="y"?"height":"width",P=o.reference[f]-o.floating[b]+v.mainAxis,C=o.reference[f]+o.reference[b]-v.mainAxis;p<P?p=P:p>C&&(p=C)}if(c){var y,S;const b=f==="y"?"width":"height",P=["top","left"].includes(Po(s)),C=o.reference[h]-o.floating[b]+(P&&((y=i.offset)==null?void 0:y[h])||0)+(P?0:v.crossAxis),_=o.reference[h]+o.reference[b]+(P?0:((S=i.offset)==null?void 0:S[h])||0)-(P?v.crossAxis:0);g<C?g=C:g>_&&(g=_)}return{[f]:p,[h]:g}}}},cne=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:o,platform:i,elements:a}=e,{apply:l=()=>{},...c}=bo(t,e),u=await Ku(e,c),h=Po(s),f=ic(s),p=vi(s)==="y",{width:g,height:m}=o.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,v=f==="end"?"top":"bottom");const S=m-u.top-u.bottom,b=g-u.left-u.right,P=Si(m-u[v],S),C=Si(g-u[y],b),_=!e.middlewareData.shift;let E=P,k=C;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(k=b),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(E=S),_&&!f){const T=or(u.left,0),j=or(u.right,0),L=or(u.top,0),M=or(u.bottom,0);p?k=g-2*(T!==0||j!==0?T+j:or(u.left,u.right)):E=m-2*(L!==0||M!==0?L+M:or(u.top,u.bottom))}await l({...e,availableWidth:k,availableHeight:E});const D=await i.getDimensions(a.floating);return g!==D.width||m!==D.height?{reset:{rects:!0}}:{}}}};function tm(){return typeof window<"u"}function ac(t){return i3(t)?(t.nodeName||"").toLowerCase():"#document"}function fr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Gs(t){var e;return(e=(i3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function i3(t){return tm()?t instanceof Node||t instanceof fr(t).Node:!1}function as(t){return tm()?t instanceof Element||t instanceof fr(t).Element:!1}function Ns(t){return tm()?t instanceof HTMLElement||t instanceof fr(t).HTMLElement:!1}function rE(t){return!tm()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fr(t).ShadowRoot}function bd(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=ls(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(s)}function une(t){return["table","td","th"].includes(ac(t))}function nm(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Hb(t){const e=Kb(),n=as(t)?ls(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function dne(t){let e=xi(t);for(;Ns(e)&&!Rl(e);){if(Hb(e))return e;if(nm(e))return null;e=xi(e)}return null}function Kb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Rl(t){return["html","body","#document"].includes(ac(t))}function ls(t){return fr(t).getComputedStyle(t)}function rm(t){return as(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function xi(t){if(ac(t)==="html")return t;const e=t.assignedSlot||t.parentNode||rE(t)&&t.host||Gs(t);return rE(e)?e.host:e}function a3(t){const e=xi(t);return Rl(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ns(e)&&bd(e)?e:a3(e)}function Wu(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=a3(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=fr(s);if(o){const a=Fx(i);return e.concat(i,i.visualViewport||[],bd(s)?s:[],a&&n?Wu(a):[])}return e.concat(s,Wu(s,[],n))}function Fx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function l3(t){const e=ls(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Ns(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,a=Np(n)!==o||Np(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Wb(t){return as(t)?t:t.contextElement}function Pl(t){const e=Wb(t);if(!Ns(e))return Os(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=l3(e);let i=(o?Np(n.width):n.width)/r,a=(o?Np(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hne=Os(0);function c3(t){const e=fr(t);return!Kb()||!e.visualViewport?hne:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function fne(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==fr(t)?!1:e}function pa(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=Wb(t);let i=Os(1);e&&(r?as(r)&&(i=Pl(r)):i=Pl(t));const a=fne(o,n,r)?c3(o):Os(0);let l=(s.left+a.x)/i.x,c=(s.top+a.y)/i.y,u=s.width/i.x,h=s.height/i.y;if(o){const f=fr(o),p=r&&as(r)?fr(r):r;let g=f,m=Fx(g);for(;m&&r&&p!==g;){const v=Pl(m),y=m.getBoundingClientRect(),S=ls(m),b=y.left+(m.clientLeft+parseFloat(S.paddingLeft))*v.x,P=y.top+(m.clientTop+parseFloat(S.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,h*=v.y,l+=b,c+=P,g=fr(m),m=Fx(g)}}return Bp({width:u,height:h,x:l,y:c})}function Gb(t,e){const n=rm(t).scrollLeft;return e?e.left+n:pa(Gs(t)).left+n}function u3(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=r.left+e.scrollLeft-(n?0:Gb(t,r)),o=r.top+e.scrollTop;return{x:s,y:o}}function pne(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Gs(r),a=e?nm(e.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Os(1);const u=Os(0),h=Ns(r);if((h||!h&&!o)&&((ac(r)!=="body"||bd(i))&&(l=rm(r)),Ns(r))){const p=pa(r);c=Pl(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=i&&!h&&!o?u3(i,l,!0):Os(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function gne(t){return Array.from(t.getClientRects())}function mne(t){const e=Gs(t),n=rm(t),r=t.ownerDocument.body,s=or(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=or(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Gb(t);const a=-n.scrollTop;return ls(r).direction==="rtl"&&(i+=or(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}function yne(t,e){const n=fr(t),r=Gs(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,l=0;if(s){o=s.width,i=s.height;const c=Kb();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:o,height:i,x:a,y:l}}function Sne(t,e){const n=pa(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=Ns(t)?Pl(t):Os(1),i=t.clientWidth*o.x,a=t.clientHeight*o.y,l=s*o.x,c=r*o.y;return{width:i,height:a,x:l,y:c}}function sE(t,e,n){let r;if(e==="viewport")r=yne(t,n);else if(e==="document")r=mne(Gs(t));else if(as(e))r=Sne(e,n);else{const s=c3(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Bp(r)}function d3(t,e){const n=xi(t);return n===e||!as(n)||Rl(n)?!1:ls(n).position==="fixed"||d3(n,e)}function vne(t,e){const n=e.get(t);if(n)return n;let r=Wu(t,[],!1).filter(a=>as(a)&&ac(a)!=="body"),s=null;const o=ls(t).position==="fixed";let i=o?xi(t):t;for(;as(i)&&!Rl(i);){const a=ls(i),l=Hb(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||bd(i)&&!l&&d3(t,i))?r=r.filter(u=>u!==i):s=a,i=xi(i)}return e.set(t,r),r}function xne(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?nm(e)?[]:vne(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const h=sE(e,u,s);return c.top=or(h.top,c.top),c.right=Si(h.right,c.right),c.bottom=Si(h.bottom,c.bottom),c.left=or(h.left,c.left),c},sE(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function wne(t){const{width:e,height:n}=l3(t);return{width:e,height:n}}function bne(t,e,n){const r=Ns(e),s=Gs(e),o=n==="fixed",i=pa(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const l=Os(0);if(r||!r&&!o)if((ac(e)!=="body"||bd(s))&&(a=rm(e)),r){const f=pa(e,!0,o,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&(l.x=Gb(s));const c=s&&!r&&!o?u3(s,a):Os(0),u=i.left+a.scrollLeft-l.x-c.x,h=i.top+a.scrollTop-l.y-c.y;return{x:u,y:h,width:i.width,height:i.height}}function iS(t){return ls(t).position==="static"}function oE(t,e){if(!Ns(t)||ls(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Gs(t)===n&&(n=n.ownerDocument.body),n}function h3(t,e){const n=fr(t);if(nm(t))return n;if(!Ns(t)){let s=xi(t);for(;s&&!Rl(s);){if(as(s)&&!iS(s))return s;s=xi(s)}return n}let r=oE(t,e);for(;r&&une(r)&&iS(r);)r=oE(r,e);return r&&Rl(r)&&iS(r)&&!Hb(r)?n:r||dne(t)||n}const Pne=async function(t){const e=this.getOffsetParent||h3,n=this.getDimensions,r=await n(t.floating);return{reference:bne(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Cne(t){return ls(t).direction==="rtl"}const _ne={convertOffsetParentRelativeRectToViewportRelativeRect:pne,getDocumentElement:Gs,getClippingRect:xne,getOffsetParent:h3,getElementRects:Pne,getClientRects:gne,getDimensions:wne,getScale:Pl,isElement:as,isRTL:Cne};function f3(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ine(t,e){let n=null,r;const s=Gs(t);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const c=t.getBoundingClientRect(),{left:u,top:h,width:f,height:p}=c;if(a||e(),!f||!p)return;const g=bh(h),m=bh(s.clientWidth-(u+f)),v=bh(s.clientHeight-(h+p)),y=bh(u),b={rootMargin:-g+"px "+-m+"px "+-v+"px "+-y+"px",threshold:or(0,Si(1,l))||1};let P=!0;function C(_){const E=_[0].intersectionRatio;if(E!==l){if(!P)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!f3(c,t.getBoundingClientRect())&&i(),P=!1}try{n=new IntersectionObserver(C,{...b,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,b)}n.observe(t)}return i(!0),o}function Ene(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Wb(t),u=s||o?[...c?Wu(c):[],...Wu(e)]:[];u.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const h=c&&a?Ine(c,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(y=>{let[S]=y;S&&S.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),n()}),c&&!l&&p.observe(c),p.observe(e));let g,m=l?pa(t):null;l&&v();function v(){const y=pa(t);m&&!f3(m,y)&&n(),m=y,g=requestAnimationFrame(v)}return n(),()=>{var y;u.forEach(S=>{s&&S.removeEventListener("scroll",n),o&&S.removeEventListener("resize",n)}),h==null||h(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const kne=ine,Tne=ane,Mne=rne,Ane=cne,jne=sne,iE=nne,One=lne,Dne=(t,e,n)=>{const r=new Map,s={platform:_ne,...n},o={...s.platform,_c:r};return tne(t,e,{...s,platform:o})};var pf=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Up(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 n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Up(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&t.$$typeof)&&!Up(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function p3(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function aE(t,e){const n=p3(t);return Math.round(e*n)/n}function aS(t){const e=w.useRef(t);return pf(()=>{e.current=t}),e}function Rne(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,h]=w.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=w.useState(r);Up(f,r)||p(r);const[g,m]=w.useState(null),[v,y]=w.useState(null),S=w.useCallback(R=>{R!==_.current&&(_.current=R,m(R))},[]),b=w.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),P=o||g,C=i||v,_=w.useRef(null),E=w.useRef(null),k=w.useRef(u),D=l!=null,T=aS(l),j=aS(s),L=aS(c),M=w.useCallback(()=>{if(!_.current||!E.current)return;const R={placement:e,strategy:n,middleware:f};j.current&&(R.platform=j.current),Dne(_.current,E.current,R).then(H=>{const X={...H,isPositioned:L.current!==!1};O.current&&!Up(k.current,X)&&(k.current=X,ba.flushSync(()=>{h(X)}))})},[f,e,n,j,L]);pf(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,h(R=>({...R,isPositioned:!1})))},[c]);const O=w.useRef(!1);pf(()=>(O.current=!0,()=>{O.current=!1}),[]),pf(()=>{if(P&&(_.current=P),C&&(E.current=C),P&&C){if(T.current)return T.current(P,C,M);M()}},[P,C,M,T,D]);const F=w.useMemo(()=>({reference:_,floating:E,setReference:S,setFloating:b}),[S,b]),B=w.useMemo(()=>({reference:P,floating:C}),[P,C]),K=w.useMemo(()=>{const R={position:n,left:0,top:0};if(!B.floating)return R;const H=aE(B.floating,u.x),X=aE(B.floating,u.y);return a?{...R,transform:"translate("+H+"px, "+X+"px)",...p3(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:X}},[n,a,B.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:M,refs:F,elements:B,floatingStyles:K}),[u,M,F,B,K])}const Lne=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?iE({element:r.current,padding:s}).fn(n):{}:r?iE({element:r,padding:s}).fn(n):{}}}},$ne=(t,e)=>({...kne(t),options:[t,e]}),Fne=(t,e)=>({...Tne(t),options:[t,e]}),Nne=(t,e)=>({...One(t),options:[t,e]}),zne=(t,e)=>({...Mne(t),options:[t,e]}),Bne=(t,e)=>({...Ane(t),options:[t,e]}),Une=(t,e)=>({...jne(t),options:[t,e]}),Hne=(t,e)=>({...Lne(t),options:[t,e]});var Kne="Arrow",g3=w.forwardRef((t,e)=>{const{children:n,width:r=10,height:s=5,...o}=t;return d.jsx(Ae.svg,{...o,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});g3.displayName=Kne;var Wne=g3;function m3(t){const[e,n]=w.useState(void 0);return yi(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let i,a;if("borderBoxSize"in o){const l=o.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=t.offsetWidth,a=t.offsetHeight;n({width:i,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Vb="Popper",[y3,sm]=Ws(Vb),[Gne,S3]=y3(Vb),v3=t=>{const{__scopePopper:e,children:n}=t,[r,s]=w.useState(null);return d.jsx(Gne,{scope:e,anchor:r,onAnchorChange:s,children:n})};v3.displayName=Vb;var x3="PopperAnchor",w3=w.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...s}=t,o=S3(x3,n),i=w.useRef(null),a=Qe(e,i);return w.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:d.jsx(Ae.div,{...s,ref:a})});w3.displayName=x3;var Yb="PopperContent",[Vne,Yne]=y3(Yb),b3=w.forwardRef((t,e)=>{var Ne,lt,$e,Ye,We,er;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...m}=t,v=S3(Yb,n),[y,S]=w.useState(null),b=Qe(e,$t=>S($t)),[P,C]=w.useState(null),_=m3(P),E=(_==null?void 0:_.width)??0,k=(_==null?void 0:_.height)??0,D=r+(o!=="center"?"-"+o:""),T=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},j=Array.isArray(c)?c:[c],L=j.length>0,M={padding:T,boundary:j.filter(qne),altBoundary:L},{refs:O,floatingStyles:F,placement:B,isPositioned:K,middlewareData:R}=Rne({strategy:"fixed",placement:D,whileElementsMounted:(...$t)=>Ene(...$t,{animationFrame:p==="always"}),elements:{reference:v.anchor},middleware:[$ne({mainAxis:s+k,alignmentAxis:i}),l&&Fne({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Nne():void 0,...M}),l&&zne({...M}),Bne({...M,apply:({elements:$t,rects:On,availableWidth:Mt,availableHeight:Ft})=>{const{width:jo,height:Ys}=On.reference,Oo=$t.floating.style;Oo.setProperty("--radix-popper-available-width",`${Mt}px`),Oo.setProperty("--radix-popper-available-height",`${Ft}px`),Oo.setProperty("--radix-popper-anchor-width",`${jo}px`),Oo.setProperty("--radix-popper-anchor-height",`${Ys}px`)}}),P&&Hne({element:P,padding:a}),Zne({arrowWidth:E,arrowHeight:k}),f&&Une({strategy:"referenceHidden",...M})]}),[H,X]=_3(B),te=qt(g);yi(()=>{K&&(te==null||te())},[K,te]);const le=(Ne=R.arrow)==null?void 0:Ne.x,de=(lt=R.arrow)==null?void 0:lt.y,Me=(($e=R.arrow)==null?void 0:$e.centerOffset)!==0,[oe,Ue]=w.useState();return yi(()=>{y&&Ue(window.getComputedStyle(y).zIndex)},[y]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:K?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(Ye=R.transformOrigin)==null?void 0:Ye.x,(We=R.transformOrigin)==null?void 0:We.y].join(" "),...((er=R.hide)==null?void 0:er.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(Vne,{scope:n,placedSide:H,onArrowChange:C,arrowX:le,arrowY:de,shouldHideArrow:Me,children:d.jsx(Ae.div,{"data-side":H,"data-align":X,...m,ref:b,style:{...m.style,animation:K?void 0:"none"}})})})});b3.displayName=Yb;var P3="PopperArrow",Xne={top:"bottom",right:"left",bottom:"top",left:"right"},C3=w.forwardRef(function(e,n){const{__scopePopper:r,...s}=e,o=Yne(P3,r),i=Xne[o.placedSide];return d.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:d.jsx(Wne,{...s,ref:n,style:{...s.style,display:"block"}})})});C3.displayName=P3;function qne(t){return t!==null}var Zne=t=>({name:"transformOrigin",options:t,fn(e){var v,y,S;const{placement:n,rects:r,middlewareData:s}=e,i=((v=s.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:t.arrowWidth,l=i?0:t.arrowHeight,[c,u]=_3(n),h={start:"0%",center:"50%",end:"100%"}[u],f=(((y=s.arrow)==null?void 0:y.x)??0)+a/2,p=(((S=s.arrow)==null?void 0:S.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=i?h:`${f}px`,m=`${-l}px`):c==="top"?(g=i?h:`${f}px`,m=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=i?h:`${p}px`):c==="left"&&(g=`${r.floating.width+l}px`,m=i?h:`${p}px`),{data:{x:g,y:m}}}});function _3(t){const[e,n="center"]=t.split("-");return[e,n]}var Xb=v3,qb=w3,I3=b3,E3=C3,Qne="Portal",Pd=w.forwardRef((t,e)=>{var a;const{container:n,...r}=t,[s,o]=w.useState(!1);yi(()=>o(!0),[]);const i=n||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?d8.createPortal(d.jsx(Ae.div,{...r,ref:e}),i):null});Pd.displayName=Qne;function Jne(t,e){return w.useReducer((n,r)=>e[n][r]??n,t)}var ds=t=>{const{present:e,children:n}=t,r=ere(e),s=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),o=Qe(r.ref,tre(s));return typeof n=="function"||r.isPresent?w.cloneElement(s,{ref:o}):null};ds.displayName="Presence";function ere(t){const[e,n]=w.useState(),r=w.useRef({}),s=w.useRef(t),o=w.useRef("none"),i=t?"mounted":"unmounted",[a,l]=Jne(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{const c=Ph(r.current);o.current=a==="mounted"?c:"none"},[a]),yi(()=>{const c=r.current,u=s.current;if(u!==t){const f=o.current,p=Ph(c);t?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,l]),yi(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,h=p=>{const m=Ph(r.current).includes(p.animationName);if(p.target===e&&m&&(l("ANIMATION_END"),!s.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},f=p=>{p.target===e&&(o.current=Ph(r.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:w.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Ph(t){return(t==null?void 0:t.animationName)||"none"}function tre(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function ji({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,s]=nre({defaultProp:e,onChange:n}),o=t!==void 0,i=o?t:r,a=qt(n),l=w.useCallback(c=>{if(o){const h=typeof c=="function"?c(t):c;h!==t&&a(h)}else s(c)},[o,t,s,a]);return[i,l]}function nre({defaultProp:t,onChange:e}){const n=w.useState(t),[r]=n,s=w.useRef(r),o=qt(e);return w.useEffect(()=>{s.current!==r&&(o(r),s.current=r)},[r,s,o]),n}var lS="rovingFocusGroup.onEntryFocus",rre={bubbles:!1,cancelable:!0},om="RovingFocusGroup",[Nx,k3,sre]=Jg(om),[ore,T3]=Ws(om,[sre]),[ire,are]=ore(om),M3=w.forwardRef((t,e)=>d.jsx(Nx.Provider,{scope:t.__scopeRovingFocusGroup,children:d.jsx(Nx.Slot,{scope:t.__scopeRovingFocusGroup,children:d.jsx(lre,{...t,ref:e})})}));M3.displayName=om;var lre=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...h}=t,f=w.useRef(null),p=Qe(e,f),g=Fb(o),[m=null,v]=ji({prop:i,defaultProp:a,onChange:l}),[y,S]=w.useState(!1),b=qt(c),P=k3(n),C=w.useRef(!1),[_,E]=w.useState(0);return w.useEffect(()=>{const k=f.current;if(k)return k.addEventListener(lS,b),()=>k.removeEventListener(lS,b)},[b]),d.jsx(ire,{scope:n,orientation:r,dir:g,loop:s,currentTabStopId:m,onItemFocus:w.useCallback(k=>v(k),[v]),onItemShiftTab:w.useCallback(()=>S(!0),[]),onFocusableItemAdd:w.useCallback(()=>E(k=>k+1),[]),onFocusableItemRemove:w.useCallback(()=>E(k=>k-1),[]),children:d.jsx(Ae.div,{tabIndex:y||_===0?-1:0,"data-orientation":r,...h,ref:p,style:{outline:"none",...t.style},onMouseDown:se(t.onMouseDown,()=>{C.current=!0}),onFocus:se(t.onFocus,k=>{const D=!C.current;if(k.target===k.currentTarget&&D&&!y){const T=new CustomEvent(lS,rre);if(k.currentTarget.dispatchEvent(T),!T.defaultPrevented){const j=P().filter(B=>B.focusable),L=j.find(B=>B.active),M=j.find(B=>B.id===m),F=[L,M,...j].filter(Boolean).map(B=>B.ref.current);O3(F,u)}}C.current=!1}),onBlur:se(t.onBlur,()=>S(!1))})})}),A3="RovingFocusGroupItem",j3=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:o,...i}=t,a=mo(),l=o||a,c=are(A3,n),u=c.currentTabStopId===l,h=k3(n),{onFocusableItemAdd:f,onFocusableItemRemove:p}=c;return w.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),d.jsx(Nx.ItemSlot,{scope:n,id:l,focusable:r,active:s,children:d.jsx(Ae.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...i,ref:e,onMouseDown:se(t.onMouseDown,g=>{r?c.onItemFocus(l):g.preventDefault()}),onFocus:se(t.onFocus,()=>c.onItemFocus(l)),onKeyDown:se(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){c.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const m=dre(g,c.orientation,c.dir);if(m!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(S=>S.focusable).map(S=>S.ref.current);if(m==="last")y.reverse();else if(m==="prev"||m==="next"){m==="prev"&&y.reverse();const S=y.indexOf(g.currentTarget);y=c.loop?hre(y,S+1):y.slice(S+1)}setTimeout(()=>O3(y))}})})})});j3.displayName=A3;var cre={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ure(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function dre(t,e,n){const r=ure(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return cre[r]}function O3(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function hre(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var fre=M3,pre=j3,gre=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Fa=new WeakMap,Ch=new WeakMap,_h={},cS=0,D3=function(t){return t&&(t.host||D3(t.parentNode))},mre=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=D3(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},yre=function(t,e,n,r){var s=mre(e,Array.isArray(t)?t:[t]);_h[n]||(_h[n]=new WeakMap);var o=_h[n],i=[],a=new Set,l=new Set(s),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};s.forEach(c);var u=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),g=p!==null&&p!=="false",m=(Fa.get(f)||0)+1,v=(o.get(f)||0)+1;Fa.set(f,m),o.set(f,v),i.push(f),m===1&&g&&Ch.set(f,!0),v===1&&f.setAttribute(n,"true"),g||f.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return u(e),a.clear(),cS++,function(){i.forEach(function(h){var f=Fa.get(h)-1,p=o.get(h)-1;Fa.set(h,f),o.set(h,p),f||(Ch.has(h)||h.removeAttribute(r),Ch.delete(h)),p||h.removeAttribute(n)}),cS--,cS||(Fa=new WeakMap,Fa=new WeakMap,Ch=new WeakMap,_h={})}},Zb=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),s=gre(t);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live]"))),yre(r,s,n,"aria-hidden")):function(){return null}},Cs=function(){return Cs=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Cs.apply(this,arguments)};function R3(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function Sre(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}var gf="right-scroll-bar-position",mf="width-before-scroll-bar",vre="with-scroll-bars-hidden",xre="--removed-body-scroll-bar-size";function uS(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function wre(t,e){var n=w.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=e,n.facade}var bre=typeof window<"u"?w.useLayoutEffect:w.useEffect,lE=new WeakMap;function Pre(t,e){var n=wre(null,function(r){return t.forEach(function(s){return uS(s,r)})});return bre(function(){var r=lE.get(n);if(r){var s=new Set(r),o=new Set(t),i=n.current;s.forEach(function(a){o.has(a)||uS(a,null)}),o.forEach(function(a){s.has(a)||uS(a,i)})}lE.set(n,t)},[t]),n}function Cre(t){return t}function _re(t,e){e===void 0&&(e=Cre);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(o){var i=e(o,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(o){for(r=!0;n.length;){var i=n;n=[],i.forEach(o)}n={push:function(a){return o(a)},filter:function(){return n}}},assignMedium:function(o){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(o),i=n}var l=function(){var u=i;i=[],u.forEach(o)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return s}function Ire(t){t===void 0&&(t={});var e=_re(null);return e.options=Cs({async:!0,ssr:!1},t),e}var L3=function(t){var e=t.sideCar,n=R3(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return w.createElement(r,Cs({},n))};L3.isSideCarExport=!0;function Ere(t,e){return t.useMedium(e),L3}var $3=Ire(),dS=function(){},im=w.forwardRef(function(t,e){var n=w.useRef(null),r=w.useState({onScrollCapture:dS,onWheelCapture:dS,onTouchMoveCapture:dS}),s=r[0],o=r[1],i=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,h=t.shards,f=t.sideCar,p=t.noIsolation,g=t.inert,m=t.allowPinchZoom,v=t.as,y=v===void 0?"div":v,S=t.gapMode,b=R3(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=f,C=Pre([n,e]),_=Cs(Cs({},b),s);return w.createElement(w.Fragment,null,u&&w.createElement(P,{sideCar:$3,removeScrollBar:c,shards:h,noIsolation:p,inert:g,setCallbacks:o,allowPinchZoom:!!m,lockRef:n,gapMode:S}),i?w.cloneElement(w.Children.only(a),Cs(Cs({},_),{ref:C})):w.createElement(y,Cs({},_,{className:l,ref:C}),a))});im.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};im.classNames={fullWidth:mf,zeroRight:gf};var kre=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Tre(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=kre();return e&&t.setAttribute("nonce",e),t}function Mre(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function Are(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var jre=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Tre())&&(Mre(e,n),Are(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Ore=function(){var t=jre();return function(e,n){w.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},F3=function(){var t=Ore(),e=function(n){var r=n.styles,s=n.dynamic;return t(r,s),null};return e},Dre={left:0,top:0,right:0,gap:0},hS=function(t){return parseInt(t||"",10)||0},Rre=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[hS(n),hS(r),hS(s)]},Lre=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Dre;var e=Rre(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},$re=F3(),Cl="data-scroll-locked",Fre=function(t,e,n,r){var s=t.left,o=t.top,i=t.right,a=t.gap;return n===void 0&&(n="margin"),`
|
|
196
|
-
.`.concat(vre,` {
|
|
197
|
-
overflow: hidden `).concat(r,`;
|
|
198
|
-
padding-right: `).concat(a,"px ").concat(r,`;
|
|
199
|
-
}
|
|
200
|
-
body[`).concat(Cl,`] {
|
|
201
|
-
overflow: hidden `).concat(r,`;
|
|
202
|
-
overscroll-behavior: contain;
|
|
203
|
-
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
204
|
-
padding-left: `.concat(s,`px;
|
|
205
|
-
padding-top: `).concat(o,`px;
|
|
206
|
-
padding-right: `).concat(i,`px;
|
|
207
|
-
margin-left:0;
|
|
208
|
-
margin-top:0;
|
|
209
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
210
|
-
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.`).concat(gf,` {
|
|
214
|
-
right: `).concat(a,"px ").concat(r,`;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.`).concat(mf,` {
|
|
218
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.`).concat(gf," .").concat(gf,` {
|
|
222
|
-
right: 0 `).concat(r,`;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.`).concat(mf," .").concat(mf,` {
|
|
226
|
-
margin-right: 0 `).concat(r,`;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
body[`).concat(Cl,`] {
|
|
230
|
-
`).concat(xre,": ").concat(a,`px;
|
|
231
|
-
}
|
|
232
|
-
`)},cE=function(){var t=parseInt(document.body.getAttribute(Cl)||"0",10);return isFinite(t)?t:0},Nre=function(){w.useEffect(function(){return document.body.setAttribute(Cl,(cE()+1).toString()),function(){var t=cE()-1;t<=0?document.body.removeAttribute(Cl):document.body.setAttribute(Cl,t.toString())}},[])},zre=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,s=r===void 0?"margin":r;Nre();var o=w.useMemo(function(){return Lre(s)},[s]);return w.createElement($re,{styles:Fre(o,!e,s,n?"":"!important")})},zx=!1;if(typeof window<"u")try{var Ih=Object.defineProperty({},"passive",{get:function(){return zx=!0,!0}});window.addEventListener("test",Ih,Ih),window.removeEventListener("test",Ih,Ih)}catch{zx=!1}var Na=zx?{passive:!1}:!1,Bre=function(t){return t.tagName==="TEXTAREA"},N3=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Bre(t)&&n[e]==="visible")},Ure=function(t){return N3(t,"overflowY")},Hre=function(t){return N3(t,"overflowX")},uE=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=z3(t,r);if(s){var o=B3(t,r),i=o[1],a=o[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Kre=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},Wre=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},z3=function(t,e){return t==="v"?Ure(e):Hre(e)},B3=function(t,e){return t==="v"?Kre(e):Wre(e)},Gre=function(t,e){return t==="h"&&e==="rtl"?-1:1},Vre=function(t,e,n,r,s){var o=Gre(t,window.getComputedStyle(e).direction),i=o*r,a=n.target,l=e.contains(a),c=!1,u=i>0,h=0,f=0;do{var p=B3(t,a),g=p[0],m=p[1],v=p[2],y=m-v-o*g;(g||y)&&z3(t,a)&&(h+=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(h)<1||!u&&Math.abs(f)<1)&&(c=!0),c},Eh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},dE=function(t){return[t.deltaX,t.deltaY]},hE=function(t){return t&&"current"in t?t.current:t},Yre=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Xre=function(t){return`
|
|
233
|
-
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
234
|
-
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
235
|
-
`)},qre=0,za=[];function Zre(t){var e=w.useRef([]),n=w.useRef([0,0]),r=w.useRef(),s=w.useState(qre++)[0],o=w.useState(F3)[0],i=w.useRef(t);w.useEffect(function(){i.current=t},[t]),w.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var m=Sre([t.lockRef.current],(t.shards||[]).map(hE),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var a=w.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var y=Eh(m),S=n.current,b="deltaX"in m?m.deltaX:S[0]-y[0],P="deltaY"in m?m.deltaY:S[1]-y[1],C,_=m.target,E=Math.abs(b)>Math.abs(P)?"h":"v";if("touches"in m&&E==="h"&&_.type==="range")return!1;var k=uE(E,_);if(!k)return!0;if(k?C=E:(C=E==="v"?"h":"v",k=uE(E,_)),!k)return!1;if(!r.current&&"changedTouches"in m&&(b||P)&&(r.current=C),!C)return!0;var D=r.current||C;return Vre(D,v,m,D==="h"?b:P)},[]),l=w.useCallback(function(m){var v=m;if(!(!za.length||za[za.length-1]!==o)){var y="deltaY"in v?dE(v):Eh(v),S=e.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Yre(C.delta,y)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var b=(i.current.shards||[]).map(hE).filter(Boolean).filter(function(C){return C.contains(v.target)}),P=b.length>0?a(v,b[0]):!i.current.noIsolation;P&&v.cancelable&&v.preventDefault()}}},[]),c=w.useCallback(function(m,v,y,S){var b={name:m,delta:v,target:y,should:S,shadowParent:Qre(y)};e.current.push(b),setTimeout(function(){e.current=e.current.filter(function(P){return P!==b})},1)},[]),u=w.useCallback(function(m){n.current=Eh(m),r.current=void 0},[]),h=w.useCallback(function(m){c(m.type,dE(m),m.target,a(m,t.lockRef.current))},[]),f=w.useCallback(function(m){c(m.type,Eh(m),m.target,a(m,t.lockRef.current))},[]);w.useEffect(function(){return za.push(o),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Na),document.addEventListener("touchmove",l,Na),document.addEventListener("touchstart",u,Na),function(){za=za.filter(function(m){return m!==o}),document.removeEventListener("wheel",l,Na),document.removeEventListener("touchmove",l,Na),document.removeEventListener("touchstart",u,Na)}},[]);var p=t.removeScrollBar,g=t.inert;return w.createElement(w.Fragment,null,g?w.createElement(o,{styles:Xre(s)}):null,p?w.createElement(zre,{gapMode:t.gapMode}):null)}function Qre(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Jre=Ere($3,Zre);var am=w.forwardRef(function(t,e){return w.createElement(im,Cs({},t,{ref:e,sideCar:Jre}))});am.classNames=im.classNames;var Bx=["Enter"," "],ese=["ArrowDown","PageUp","Home"],U3=["ArrowUp","PageDown","End"],tse=[...ese,...U3],nse={ltr:[...Bx,"ArrowRight"],rtl:[...Bx,"ArrowLeft"]},rse={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Cd="Menu",[Gu,sse,ose]=Jg(Cd),[Ea,lm]=Ws(Cd,[ose,sm,T3]),_d=sm(),H3=T3(),[K3,Oi]=Ea(Cd),[ise,Id]=Ea(Cd),W3=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:s,onOpenChange:o,modal:i=!0}=t,a=_d(e),[l,c]=w.useState(null),u=w.useRef(!1),h=qt(o),f=Fb(s);return w.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})}},[]),d.jsx(Xb,{...a,children:d.jsx(K3,{scope:e,open:n,onOpenChange:h,content:l,onContentChange:c,children:d.jsx(ise,{scope:e,onClose:w.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};W3.displayName=Cd;var ase="MenuAnchor",Qb=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,s=_d(n);return d.jsx(qb,{...s,...r,ref:e})});Qb.displayName=ase;var Jb="MenuPortal",[lse,G3]=Ea(Jb,{forceMount:void 0}),V3=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:s}=t,o=Oi(Jb,e);return d.jsx(lse,{scope:e,forceMount:n,children:d.jsx(ds,{present:n||o.open,children:d.jsx(Pd,{asChild:!0,container:s,children:r})})})};V3.displayName=Jb;var Dr="MenuContent",[cse,e1]=Ea(Dr),Y3=w.forwardRef((t,e)=>{const n=G3(Dr,t.__scopeMenu),{forceMount:r=n.forceMount,...s}=t,o=Oi(Dr,t.__scopeMenu),i=Id(Dr,t.__scopeMenu);return d.jsx(Gu.Provider,{scope:t.__scopeMenu,children:d.jsx(ds,{present:r||o.open,children:d.jsx(Gu.Slot,{scope:t.__scopeMenu,children:i.modal?d.jsx(use,{...s,ref:e}):d.jsx(dse,{...s,ref:e})})})})}),use=w.forwardRef((t,e)=>{const n=Oi(Dr,t.__scopeMenu),r=w.useRef(null),s=Qe(e,r);return w.useEffect(()=>{const o=r.current;if(o)return Zb(o)},[]),d.jsx(t1,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:se(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dse=w.forwardRef((t,e)=>{const n=Oi(Dr,t.__scopeMenu);return d.jsx(t1,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),t1=w.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,...m}=t,v=Oi(Dr,n),y=Id(Dr,n),S=_d(n),b=H3(n),P=sse(n),[C,_]=w.useState(null),E=w.useRef(null),k=Qe(e,E,v.onContentChange),D=w.useRef(0),T=w.useRef(""),j=w.useRef(0),L=w.useRef(null),M=w.useRef("right"),O=w.useRef(0),F=g?am:w.Fragment,B=g?{as:fa,allowPinchZoom:!0}:void 0,K=H=>{var Ne,lt;const X=T.current+H,te=P().filter($e=>!$e.disabled),le=document.activeElement,de=(Ne=te.find($e=>$e.ref.current===le))==null?void 0:Ne.textValue,Me=te.map($e=>$e.textValue),oe=Pse(Me,X,de),Ue=(lt=te.find($e=>$e.textValue===oe))==null?void 0:lt.ref.current;(function $e(Ye){T.current=Ye,window.clearTimeout(D.current),Ye!==""&&(D.current=window.setTimeout(()=>$e(""),1e3))})(X),Ue&&setTimeout(()=>Ue.focus())};w.useEffect(()=>()=>window.clearTimeout(D.current),[]),Nb();const R=w.useCallback(H=>{var te,le;return M.current===((te=L.current)==null?void 0:te.side)&&_se(H,(le=L.current)==null?void 0:le.area)},[]);return d.jsx(cse,{scope:n,searchRef:T,onItemEnter:w.useCallback(H=>{R(H)&&H.preventDefault()},[R]),onItemLeave:w.useCallback(H=>{var X;R(H)||((X=E.current)==null||X.focus(),_(null))},[R]),onTriggerLeave:w.useCallback(H=>{R(H)&&H.preventDefault()},[R]),pointerGraceTimerRef:j,onPointerGraceIntentChange:w.useCallback(H=>{L.current=H},[]),children:d.jsx(F,{...B,children:d.jsx(em,{asChild:!0,trapped:s,onMountAutoFocus:se(o,H=>{var X;H.preventDefault(),(X=E.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(wd,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:d.jsx(fre,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:_,onEntryFocus:se(l,H=>{y.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(I3,{role:"menu","aria-orientation":"vertical","data-state":dL(v.open),"data-radix-menu-content":"",dir:y.dir,...S,...m,ref:k,style:{outline:"none",...m.style},onKeyDown:se(m.onKeyDown,H=>{const te=H.target.closest("[data-radix-menu-content]")===H.currentTarget,le=H.ctrlKey||H.altKey||H.metaKey,de=H.key.length===1;te&&(H.key==="Tab"&&H.preventDefault(),!le&&de&&K(H.key));const Me=E.current;if(H.target!==Me||!tse.includes(H.key))return;H.preventDefault();const Ue=P().filter(Ne=>!Ne.disabled).map(Ne=>Ne.ref.current);U3.includes(H.key)&&Ue.reverse(),wse(Ue)}),onBlur:se(t.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(D.current),T.current="")}),onPointerMove:se(t.onPointerMove,Vu(H=>{const X=H.target,te=O.current!==H.clientX;if(H.currentTarget.contains(X)&&te){const le=H.clientX>O.current?"right":"left";M.current=le,O.current=H.clientX}}))})})})})})})});Y3.displayName=Dr;var hse="MenuGroup",n1=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return d.jsx(Ae.div,{role:"group",...r,ref:e})});n1.displayName=hse;var fse="MenuLabel",X3=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return d.jsx(Ae.div,{...r,ref:e})});X3.displayName=fse;var Hp="MenuItem",fE="menu.itemSelect",cm=w.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...s}=t,o=w.useRef(null),i=Id(Hp,t.__scopeMenu),a=e1(Hp,t.__scopeMenu),l=Qe(e,o),c=w.useRef(!1),u=()=>{const h=o.current;if(!n&&h){const f=new CustomEvent(fE,{bubbles:!0,cancelable:!0});h.addEventListener(fE,p=>r==null?void 0:r(p),{once:!0}),$b(h,f),f.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(q3,{...s,ref:l,disabled:n,onClick:se(t.onClick,u),onPointerDown:h=>{var f;(f=t.onPointerDown)==null||f.call(t,h),c.current=!0},onPointerUp:se(t.onPointerUp,h=>{var f;c.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:se(t.onKeyDown,h=>{const f=a.searchRef.current!=="";n||f&&h.key===" "||Bx.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});cm.displayName=Hp;var q3=w.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...o}=t,i=e1(Hp,n),a=H3(n),l=w.useRef(null),c=Qe(e,l),[u,h]=w.useState(!1),[f,p]=w.useState("");return w.useEffect(()=>{const g=l.current;g&&p((g.textContent??"").trim())},[o.children]),d.jsx(Gu.ItemSlot,{scope:n,disabled:r,textValue:s??f,children:d.jsx(pre,{asChild:!0,...a,focusable:!r,children:d.jsx(Ae.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:c,onPointerMove:se(t.onPointerMove,Vu(g=>{r?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:se(t.onPointerLeave,Vu(g=>i.onItemLeave(g))),onFocus:se(t.onFocus,()=>h(!0)),onBlur:se(t.onBlur,()=>h(!1))})})})}),pse="MenuCheckboxItem",Z3=w.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...s}=t;return d.jsx(nL,{scope:t.__scopeMenu,checked:n,children:d.jsx(cm,{role:"menuitemcheckbox","aria-checked":Kp(n)?"mixed":n,...s,ref:e,"data-state":o1(n),onSelect:se(s.onSelect,()=>r==null?void 0:r(Kp(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z3.displayName=pse;var Q3="MenuRadioGroup",[gse,mse]=Ea(Q3,{value:void 0,onValueChange:()=>{}}),J3=w.forwardRef((t,e)=>{const{value:n,onValueChange:r,...s}=t,o=qt(r);return d.jsx(gse,{scope:t.__scopeMenu,value:n,onValueChange:o,children:d.jsx(n1,{...s,ref:e})})});J3.displayName=Q3;var eL="MenuRadioItem",tL=w.forwardRef((t,e)=>{const{value:n,...r}=t,s=mse(eL,t.__scopeMenu),o=n===s.value;return d.jsx(nL,{scope:t.__scopeMenu,checked:o,children:d.jsx(cm,{role:"menuitemradio","aria-checked":o,...r,ref:e,"data-state":o1(o),onSelect:se(r.onSelect,()=>{var i;return(i=s.onValueChange)==null?void 0:i.call(s,n)},{checkForDefaultPrevented:!1})})})});tL.displayName=eL;var r1="MenuItemIndicator",[nL,yse]=Ea(r1,{checked:!1}),rL=w.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...s}=t,o=yse(r1,n);return d.jsx(ds,{present:r||Kp(o.checked)||o.checked===!0,children:d.jsx(Ae.span,{...s,ref:e,"data-state":o1(o.checked)})})});rL.displayName=r1;var Sse="MenuSeparator",sL=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return d.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});sL.displayName=Sse;var vse="MenuArrow",oL=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,s=_d(n);return d.jsx(E3,{...s,...r,ref:e})});oL.displayName=vse;var s1="MenuSub",[xse,iL]=Ea(s1),aL=t=>{const{__scopeMenu:e,children:n,open:r=!1,onOpenChange:s}=t,o=Oi(s1,e),i=_d(e),[a,l]=w.useState(null),[c,u]=w.useState(null),h=qt(s);return w.useEffect(()=>(o.open===!1&&h(!1),()=>h(!1)),[o.open,h]),d.jsx(Xb,{...i,children:d.jsx(K3,{scope:e,open:r,onOpenChange:h,content:c,onContentChange:u,children:d.jsx(xse,{scope:e,contentId:mo(),triggerId:mo(),trigger:a,onTriggerChange:l,children:n})})})};aL.displayName=s1;var Vc="MenuSubTrigger",lL=w.forwardRef((t,e)=>{const n=Oi(Vc,t.__scopeMenu),r=Id(Vc,t.__scopeMenu),s=iL(Vc,t.__scopeMenu),o=e1(Vc,t.__scopeMenu),i=w.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,c={__scopeMenu:t.__scopeMenu},u=w.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return w.useEffect(()=>u,[u]),w.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),d.jsx(Qb,{asChild:!0,...c,children:d.jsx(q3,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":dL(n.open),...t,ref:Qg(e,s.onTriggerChange),onClick:h=>{var f;(f=t.onClick)==null||f.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:se(t.onPointerMove,Vu(h=>{o.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:se(t.onPointerLeave,Vu(h=>{var p,g;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const m=(g=n.content)==null?void 0:g.dataset.side,v=m==="right",y=v?-5:5,S=f[v?"left":"right"],b=f[v?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:S,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:S,y:f.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:se(t.onKeyDown,h=>{var p;const f=o.searchRef.current!=="";t.disabled||f&&h.key===" "||nse[r.dir].includes(h.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),h.preventDefault())})})})});lL.displayName=Vc;var cL="MenuSubContent",uL=w.forwardRef((t,e)=>{const n=G3(Dr,t.__scopeMenu),{forceMount:r=n.forceMount,...s}=t,o=Oi(Dr,t.__scopeMenu),i=Id(Dr,t.__scopeMenu),a=iL(cL,t.__scopeMenu),l=w.useRef(null),c=Qe(e,l);return d.jsx(Gu.Provider,{scope:t.__scopeMenu,children:d.jsx(ds,{present:r||o.open,children:d.jsx(Gu.Slot,{scope:t.__scopeMenu,children:d.jsx(t1,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:se(t.onFocusOutside,u=>{u.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:se(t.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:se(t.onKeyDown,u=>{var p;const h=u.currentTarget.contains(u.target),f=rse[i.dir].includes(u.key);h&&f&&(o.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});uL.displayName=cL;function dL(t){return t?"open":"closed"}function Kp(t){return t==="indeterminate"}function o1(t){return Kp(t)?"indeterminate":t?"checked":"unchecked"}function wse(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function bse(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function Pse(t,e,n){const s=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,o=n?t.indexOf(n):-1;let i=bse(t,Math.max(o,0));s.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(s.toLowerCase()));return l!==n?l:void 0}function Cse(t,e){const{x:n,y:r}=t;let s=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const a=e[o].x,l=e[o].y,c=e[i].x,u=e[i].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(s=!s)}return s}function _se(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Cse(n,e)}function Vu(t){return e=>e.pointerType==="mouse"?t(e):void 0}var hL=W3,fL=Qb,pL=V3,gL=Y3,mL=n1,yL=X3,SL=cm,vL=Z3,xL=J3,wL=tL,bL=rL,PL=sL,CL=oL,_L=aL,IL=lL,EL=uL,i1="ContextMenu",[Ise,dge]=Ws(i1,[lm]),yn=lm(),[Ese,kL]=Ise(i1),TL=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:r,dir:s,modal:o=!0}=t,[i,a]=w.useState(!1),l=yn(e),c=qt(r),u=w.useCallback(h=>{a(h),c(h)},[c]);return d.jsx(Ese,{scope:e,open:i,onOpenChange:u,modal:o,children:d.jsx(hL,{...l,dir:s,open:i,onOpenChange:u,modal:o,children:n})})};TL.displayName=i1;var ML="ContextMenuTrigger",AL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:r=!1,...s}=t,o=kL(ML,n),i=yn(n),a=w.useRef({x:0,y:0}),l=w.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=w.useRef(0),u=w.useCallback(()=>window.clearTimeout(c.current),[]),h=f=>{a.current={x:f.clientX,y:f.clientY},o.onOpenChange(!0)};return w.useEffect(()=>u,[u]),w.useEffect(()=>void(r&&u()),[r,u]),d.jsxs(d.Fragment,{children:[d.jsx(fL,{...i,virtualRef:l}),d.jsx(Ae.span,{"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,...s,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:se(t.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:r?t.onPointerDown:se(t.onPointerDown,kh(f=>{u(),c.current=window.setTimeout(()=>h(f),700)})),onPointerMove:r?t.onPointerMove:se(t.onPointerMove,kh(u)),onPointerCancel:r?t.onPointerCancel:se(t.onPointerCancel,kh(u)),onPointerUp:r?t.onPointerUp:se(t.onPointerUp,kh(u))})]})});AL.displayName=ML;var kse="ContextMenuPortal",a1=t=>{const{__scopeContextMenu:e,...n}=t,r=yn(e);return d.jsx(pL,{...r,...n})};a1.displayName=kse;var jL="ContextMenuContent",OL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=kL(jL,n),o=yn(n),i=w.useRef(!1);return d.jsx(gL,{...o,...r,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=t.onCloseAutoFocus)==null||l.call(t,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var l;(l=t.onInteractOutside)==null||l.call(t,a),!a.defaultPrevented&&!s.modal&&(i.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)"}})});OL.displayName=jL;var Tse="ContextMenuGroup",DL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(mL,{...s,...r,ref:e})});DL.displayName=Tse;var Mse="ContextMenuLabel",Ase=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(yL,{...s,...r,ref:e})});Ase.displayName=Mse;var jse="ContextMenuItem",RL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(SL,{...s,...r,ref:e})});RL.displayName=jse;var Ose="ContextMenuCheckboxItem",LL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(vL,{...s,...r,ref:e})});LL.displayName=Ose;var Dse="ContextMenuRadioGroup",Rse=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(xL,{...s,...r,ref:e})});Rse.displayName=Dse;var Lse="ContextMenuRadioItem",$se=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(wL,{...s,...r,ref:e})});$se.displayName=Lse;var Fse="ContextMenuItemIndicator",Nse=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(bL,{...s,...r,ref:e})});Nse.displayName=Fse;var zse="ContextMenuSeparator",Bse=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(PL,{...s,...r,ref:e})});Bse.displayName=zse;var Use="ContextMenuArrow",Hse=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(CL,{...s,...r,ref:e})});Hse.displayName=Use;var Kse="ContextMenuSub",$L=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:r,open:s,defaultOpen:o}=t,i=yn(e),[a,l]=ji({prop:s,defaultProp:o,onChange:r});return d.jsx(_L,{...i,open:a,onOpenChange:l,children:n})};$L.displayName=Kse;var Wse="ContextMenuSubTrigger",FL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(IL,{...s,...r,ref:e})});FL.displayName=Wse;var Gse="ContextMenuSubContent",NL=w.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,s=yn(n);return d.jsx(EL,{...s,...r,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)"}})});NL.displayName=Gse;function kh(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var Vse=TL,Yse=AL,Xse=a1,qse=OL,Zse=LL,l1="DropdownMenu",[Qse,hge]=Ws(l1,[lm]),Sn=lm(),[Jse,zL]=Qse(l1),BL=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=t,l=Sn(e),c=w.useRef(null),[u=!1,h]=ji({prop:s,defaultProp:o,onChange:i});return d.jsx(Jse,{scope:e,triggerId:mo(),triggerRef:c,contentId:mo(),open:u,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(f=>!f),[h]),modal:a,children:d.jsx(hL,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:n})})};BL.displayName=l1;var UL="DropdownMenuTrigger",HL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=t,o=zL(UL,n),i=Sn(n);return d.jsx(fL,{asChild:!0,...i,children:d.jsx(Ae.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:Qg(e,o.triggerRef),onPointerDown:se(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:se(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});HL.displayName=UL;var eoe="DropdownMenuPortal",KL=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Sn(e);return d.jsx(pL,{...r,...n})};KL.displayName=eoe;var WL="DropdownMenuContent",GL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=zL(WL,n),o=Sn(n),i=w.useRef(!1);return d.jsx(gL,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...r,ref:e,onCloseAutoFocus:se(t.onCloseAutoFocus,a=>{var l;i.current||(l=s.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:se(t.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!s.modal||u)&&(i.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)"}})});GL.displayName=WL;var toe="DropdownMenuGroup",VL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(mL,{...s,...r,ref:e})});VL.displayName=toe;var noe="DropdownMenuLabel",roe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(yL,{...s,...r,ref:e})});roe.displayName=noe;var soe="DropdownMenuItem",YL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(SL,{...s,...r,ref:e})});YL.displayName=soe;var ooe="DropdownMenuCheckboxItem",XL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(vL,{...s,...r,ref:e})});XL.displayName=ooe;var ioe="DropdownMenuRadioGroup",aoe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(xL,{...s,...r,ref:e})});aoe.displayName=ioe;var loe="DropdownMenuRadioItem",coe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(wL,{...s,...r,ref:e})});coe.displayName=loe;var uoe="DropdownMenuItemIndicator",doe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(bL,{...s,...r,ref:e})});doe.displayName=uoe;var hoe="DropdownMenuSeparator",foe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(PL,{...s,...r,ref:e})});foe.displayName=hoe;var poe="DropdownMenuArrow",goe=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(CL,{...s,...r,ref:e})});goe.displayName=poe;var moe=t=>{const{__scopeDropdownMenu:e,children:n,open:r,onOpenChange:s,defaultOpen:o}=t,i=Sn(e),[a=!1,l]=ji({prop:r,defaultProp:o,onChange:s});return d.jsx(_L,{...i,open:a,onOpenChange:l,children:n})},yoe="DropdownMenuSubTrigger",qL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(IL,{...s,...r,ref:e})});qL.displayName=yoe;var Soe="DropdownMenuSubContent",ZL=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,s=Sn(n);return d.jsx(EL,{...s,...r,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)"}})});ZL.displayName=Soe;var c1=BL,u1=HL,um=KL,d1=GL,voe=VL,xoe=YL,woe=XL,boe=moe,Poe=qL,Coe=ZL;function Xe(t,e){var s;const n=new Set;for(const o of e){const i=t.getShape(o);if(!i)continue;t.getShapeUtil(i).onDragShapesOut&&n.add(i);const a=t.getShape(i.parentId);a&&t.getShapeUtil(a).onDragShapesOut&&n.add(a)}const r=new Map;for(const o of n){const i=QL(t,o);i.length&&r.set(o,i)}for(const[o,i]of r){const a=t.getShapeUtil(o),l=me(i.map(c=>t.getShape(c)));(s=a.onDragShapesOut)==null||s.call(a,o,l)}}function QL(t,e){const n=t.getSortedChildIdsForParent(e.id);if(n.length===0)return[];const r=t.getShapePageBounds(e);if(!r)return[];let s,o,i;const a=[];for(const l of n){const c=t.getShapePageBounds(l);if(!c)continue;if(!r.includes(c)){a.push(l);continue}s??(s=t.getShapeGeometry(e)),o??(o=t.getShapePageTransform(e)),i??(i=o.applyToPoints(s.vertices));const u=t.getShapePageTransform(l).clone().invert().applyToPoints(i),{vertices:h,isClosed:f}=t.getShapeGeometry(l);if(!h.some(p=>hr(p,u))){if(f){if(_b(u,h))continue}else if(ZZ(u,h))continue;a.push(l)}}return a}function Wp(t,e,n=!1){t.select(e),t.setEditingShape(e),t.setCurrentTool("select.editing_shape",{target:"shape",shape:e}),n&&t.emit("select-all-text",{shapeId:e.id})}function _oe(t,e){const n=me(e.map(s=>t.getShape(s)).filter(s=>s&&t.isShapeOfType(s,"frame")));if(!n.length)return;const r=[];t.run(()=>{n.map(s=>{const o=t.getSortedChildIdsForParent(s.id);o.length&&(t.reparentShapes(o,s.parentId,s.index),r.push(...o))}),t.setSelectedShapes(r),t.deleteShapes(e)})}const Ioe=50;function Eoe(t,e,n={}){const r=t.getShape(e);if(!r)return;const s=t.getSortedChildIdsForParent(r.id),o=me(s.map(p=>t.getShape(p)));if(!o.length)return;const i=Z.FromPoints(o.flatMap(p=>{const g=t.getShapeGeometry(p.id);return t.getShapeLocalTransform(p).applyToPoints(g.vertices)})),{padding:a=Ioe}=n,l=i.w+2*a,c=i.h+2*a,u=a-i.minX,h=a-i.minY;if(u===0&&h===0&&r.props.w===l&&r.props.h===c)return;const f=new x(u,h).rot(r.rotation);t.run(()=>{const p=s.map(g=>{const m=t.getShape(g);return{id:m.id,type:m.type,x:m.x+u,y:m.y+h}});p.push({id:r.id,type:r.type,x:r.x-f.x,y:r.y-f.y,props:{w:l,h:c}}),t.updateShapes(p)})}const JL=w.createContext(null);function koe({assetUrls:t,children:e}){return w.useEffect(()=>{for(const n of Object.values(t.icons)){const r=Lu();r.src=n,r.decode()}for(const n of Object.values(t.embedIcons)){const r=Lu();r.src=n,r.decode()}},[t]),d.jsx(JL.Provider,{value:t,children:e})}function h1(){const t=w.useContext(JL);if(!t)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return t}const Ux={"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.import-tldr-file":"Import file...","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.label-align":"Label 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..."},Toe=new Set(["ar","fa","he","ur","ku"]),Ba={locale:"en",label:"English",messages:Ux,dir:"ltr"};async function Moe(t,e){if(!(await Rs(e.translations.en)).ok)return console.warn("No main translations found."),Ba;if(t==="en")return Ba;const r=Bu.find(i=>i.locale===t);if(!r)return console.warn(`No translation found for locale ${t}`),Ba;const o=await(await Rs(e.translations[r.locale])).json();if(!o)return console.warn(`No messages found for locale ${t}`),Ba;for(const i in Ba.messages)o[i];return{locale:t,label:r.label,dir:Toe.has(r.locale)?"rtl":"ltr",messages:{...Ba.messages,...o}}}const e$=w.createContext(null);function t$(){const t=w.useContext(e$);if(!t)throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />");return t}function Aoe({overrides:t,locale:e,children:n}){const r=h1(),[s,o]=w.useState(()=>t&&t.en?{locale:"en",label:"English",dir:"ltr",messages:{...Ux,...t.en}}:{locale:"en",label:"English",dir:"ltr",messages:Ux});return w.useEffect(()=>{let i=!1;async function a(){const l=await Moe(e,r);l&&!i&&(t&&t[e]?o({...l,messages:{...l.messages,...t[e]}}):o(l))}return a(),()=>{i=!0}},[r,e,t]),d.jsx(e$.Provider,{value:s,children:n})}function Ee(){const t=t$();return w.useCallback(function(n){return t.messages[n]??n},[t])}const ue=w.forwardRef(function({children:e,type:n,...r},s){return d.jsx("button",{ref:s,type:"button",draggable:!1,...r,className:ce("tlui-button",`tlui-button__${n}`,r.className),children:e})});function bt({children:t}){return d.jsx("span",{className:"tlui-button__label",children:t})}var f1="Dialog",[n$,fge]=Ws(f1),[joe,hs]=n$(f1),r$=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!0}=t,a=w.useRef(null),l=w.useRef(null),[c=!1,u]=ji({prop:r,defaultProp:s,onChange:o});return d.jsx(joe,{scope:e,triggerRef:a,contentRef:l,contentId:mo(),titleId:mo(),descriptionId:mo(),open:c,onOpenChange:u,onOpenToggle:w.useCallback(()=>u(h=>!h),[u]),modal:i,children:n})};r$.displayName=f1;var s$="DialogTrigger",Ooe=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=hs(s$,n),o=Qe(e,s.triggerRef);return d.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":m1(s.open),...r,ref:o,onClick:se(t.onClick,s.onOpenToggle)})});Ooe.displayName=s$;var p1="DialogPortal",[Doe,o$]=n$(p1,{forceMount:void 0}),i$=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:s}=t,o=hs(p1,e);return d.jsx(Doe,{scope:e,forceMount:n,children:w.Children.map(r,i=>d.jsx(ds,{present:n||o.open,children:d.jsx(Pd,{asChild:!0,container:s,children:i})}))})};i$.displayName=p1;var Gp="DialogOverlay",a$=w.forwardRef((t,e)=>{const n=o$(Gp,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,o=hs(Gp,t.__scopeDialog);return o.modal?d.jsx(ds,{present:r||o.open,children:d.jsx(Roe,{...s,ref:e})}):null});a$.displayName=Gp;var Roe=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=hs(Gp,n);return d.jsx(am,{as:fa,allowPinchZoom:!0,shards:[s.contentRef],children:d.jsx(Ae.div,{"data-state":m1(s.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),ga="DialogContent",l$=w.forwardRef((t,e)=>{const n=o$(ga,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,o=hs(ga,t.__scopeDialog);return d.jsx(ds,{present:r||o.open,children:o.modal?d.jsx(Loe,{...s,ref:e}):d.jsx($oe,{...s,ref:e})})});l$.displayName=ga;var Loe=w.forwardRef((t,e)=>{const n=hs(ga,t.__scopeDialog),r=w.useRef(null),s=Qe(e,n.contentRef,r);return w.useEffect(()=>{const o=r.current;if(o)return Zb(o)},[]),d.jsx(c$,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(t.onCloseAutoFocus,o=>{var i;o.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:se(t.onPointerDownOutside,o=>{const i=o.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&o.preventDefault()}),onFocusOutside:se(t.onFocusOutside,o=>o.preventDefault())})}),$oe=w.forwardRef((t,e)=>{const n=hs(ga,t.__scopeDialog),r=w.useRef(!1),s=w.useRef(!1);return d.jsx(c$,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,a;(i=t.onCloseAutoFocus)==null||i.call(t,o),o.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),o.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:o=>{var l,c;(l=t.onInteractOutside)==null||l.call(t,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),c$=w.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,...i}=t,a=hs(ga,n),l=w.useRef(null),c=Qe(e,l);return Nb(),d.jsxs(d.Fragment,{children:[d.jsx(em,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:o,children:d.jsx(wd,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":m1(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Noe,{titleId:a.titleId}),d.jsx(Boe,{contentRef:l,descriptionId:a.descriptionId})]})]})}),g1="DialogTitle",u$=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=hs(g1,n);return d.jsx(Ae.h2,{id:s.titleId,...r,ref:e})});u$.displayName=g1;var d$="DialogDescription",Foe=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=hs(d$,n);return d.jsx(Ae.p,{id:s.descriptionId,...r,ref:e})});Foe.displayName=d$;var h$="DialogClose",f$=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=hs(h$,n);return d.jsx(Ae.button,{type:"button",...r,ref:e,onClick:se(t.onClick,()=>s.onOpenChange(!1))})});f$.displayName=h$;function m1(t){return t?"open":"closed"}var p$="DialogTitleWarning",[pge,g$]=wte(p$,{contentName:ga,titleName:g1,docsSlug:"dialog"}),Noe=({titleId:t})=>{const e=g$(p$),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
236
|
-
|
|
237
|
-
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
238
|
-
|
|
239
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return w.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},zoe="DialogDescriptionWarning",Boe=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${g$(zoe).contentName}}.`;return w.useEffect(()=>{var o;const s=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Uoe=r$,Hoe=i$,Koe=a$,Woe=l$;const zs=w.memo(function({small:e,invertIcon:n,icon:r,color:s,className:o,...i}){const a=h1(),l=a.icons[r]??a.icons["question-mark-circle"],c=w.useRef(null);return w.useLayoutEffect(()=>{l||console.error(`Icon not found: ${r}. Add it to the assetUrls.icons object.`),c!=null&&c.current&&(c.current.style.webkitMask=`url(${l}) center 100% / 100% no-repeat`)},[c,l,r]),r==="none"?d.jsx("div",{className:ce("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":e},o)}):d.jsx("div",{...i,ref:c,className:ce("tlui-icon",{"tlui-icon__small":e},o),style:{color:s,mask:`url(${l}) center 100% / 100% no-repeat`,transform:n?"scale(-1, 1)":void 0}})});function be({icon:t,small:e,invertIcon:n}){return d.jsx(zs,{className:"tlui-button__icon",icon:t,small:e,invertIcon:n})}function dm({className:t,children:e}){return d.jsx("div",{className:ce("tlui-dialog__header",t),children:e})}function hm({className:t,children:e}){return d.jsx(u$,{dir:"ltr",className:ce("tlui-dialog__header__title",t),children:e})}function fm(){return d.jsx("div",{className:"tlui-dialog__header__close",children:d.jsx(f$,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:d.jsx(ue,{type:"icon","aria-label":"Close",onTouchEnd:t=>t.target.click(),children:d.jsx(be,{small:!0,icon:"cross-2"})})})})}function Yu({className:t,children:e,style:n}){return d.jsx("div",{className:ce("tlui-dialog__body",t),style:n,children:e})}function y1({className:t,children:e}){return d.jsx("div",{className:ce("tlui-dialog__footer",t),children:e})}const pm=w.forwardRef(function({className:e,label:n,icon:r,iconLeft:s,autoSelect:o=!1,autoFocus:i=!1,defaultValue:a,placeholder:l,onComplete:c,onValueChange:u,onCancel:h,onFocus:f,onBlur:p,shouldManuallyMaintainScrollPositionWhenFocused:g=!1,children:m,value:v},y){const S=Ti(),b=w.useRef(null);w.useImperativeHandle(y,()=>b.current);const P=Ee(),C=w.useRef(a??""),_=w.useRef(a??""),[E,k]=w.useState(!1),D=w.useCallback(M=>{k(!0);const O=M.currentTarget;_.current=O.value,S?S.timers.requestAnimationFrame(()=>{o&&O.select()}):kx.requestAnimationFrame("anon",()=>{o&&O.select()}),f==null||f()},[o,S,f]),T=w.useCallback(M=>{const O=M.currentTarget.value;_.current=O,u==null||u(O)},[u]),j=w.useCallback(M=>{switch(M.key){case"Enter":{M.currentTarget.blur(),Ct(M),c==null||c(M.currentTarget.value);break}case"Escape":{M.currentTarget.value=C.current,h==null||h(M.currentTarget.value),M.currentTarget.blur(),Ct(M);break}}},[c,h]),L=w.useCallback(M=>{k(!1);const O=M.currentTarget.value;p==null||p(O)},[p]);return w.useEffect(()=>{if(!Ge.isIos)return;const M=window.visualViewport;if(E&&g&&M){const O=()=>{var F;(F=b.current)==null||F.scrollIntoView({block:"center"})};return M.addEventListener("resize",O),M.addEventListener("scroll",O),S?S.timers.requestAnimationFrame(()=>{var F;(F=b.current)==null||F.scrollIntoView({block:"center"})}):kx.requestAnimationFrame("anon",()=>{var F;(F=b.current)==null||F.scrollIntoView({block:"center"})}),()=>{M.removeEventListener("resize",O),M.removeEventListener("scroll",O)}}},[E,S,g]),d.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[m,n&&d.jsx("label",{children:P(n)}),s&&d.jsx(zs,{icon:s,className:"tlui-icon-left",small:!0}),d.jsx("input",{ref:b,className:ce("tlui-input",e),type:"text",defaultValue:a,onKeyDownCapture:j,onChange:T,onFocus:D,onBlur:L,autoFocus:i,placeholder:l,value:v}),r&&d.jsx(zs,{icon:r,small:!!n})]})});function pE(t){return gr.isValid(t)?{isValid:!0,hasProtocol:!0}:gr.isValid("https://"+t)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const Goe=Zt(function({onClose:e}){const r=z().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?d.jsx(Voe,{onClose:e,selectedShape:r}):null}),Voe=Zt(function({onClose:e,selectedShape:n}){const r=z(),s=Ee(),o=w.useRef(null);w.useEffect(()=>{r.timers.requestAnimationFrame(()=>{var g;return(g=o.current)==null?void 0:g.focus()})},[r]);const i=w.useRef(n.props.url),[a,l]=w.useState(()=>{const g=pE(n.props.url),m=g.isValid===!0?g.hasProtocol?n.props.url:"https://"+n.props.url:"https://";return{actual:m,safe:m,valid:!0}}),c=w.useCallback(g=>{const m=g.replace(/https?:\/\/(https?:\/\/)/,(S,b)=>b),v=pE(m),y=v.isValid===!0?v.hasProtocol?m:"https://"+m:"https://";l({actual:m,safe:y,valid:v.isValid})},[]),u=w.useCallback(()=>{const g=r.getOnlySelectedShape();g&&(r.updateShapes([{id:g.id,type:g.type,props:{url:""}}]),e())},[r,e]),h=w.useCallback(()=>{const g=r.getOnlySelectedShape();g&&(g&&"url"in g.props&&g.props.url!==a.safe&&r.updateShapes([{id:g.id,type:g.type,props:{url:a.safe}}]),e())},[r,e,a]),f=w.useCallback(()=>{e()},[e]);if(!n)return e(),null;const p=i.current&&!a.valid;return d.jsxs(d.Fragment,{children:[d.jsxs(dm,{children:[d.jsx(hm,{children:s("edit-link-dialog.title")}),d.jsx(fm,{})]}),d.jsx(Yu,{children:d.jsxs("div",{className:"tlui-edit-link-dialog",children:[d.jsx(pm,{ref:o,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,value:a.actual,onValueChange:c,onComplete:h,onCancel:f}),d.jsx("div",{children:a.valid?s("edit-link-dialog.detail"):s("edit-link-dialog.invalid-url")})]})}),d.jsxs(y1,{className:"tlui-dialog__footer__actions",children:[d.jsx(ue,{type:"normal",onClick:f,onTouchEnd:f,children:d.jsx(bt,{children:s("edit-link-dialog.cancel")})}),p?d.jsx(ue,{type:"danger",onTouchEnd:u,onClick:u,children:d.jsx(bt,{children:s("edit-link-dialog.clear")})}):d.jsx(ue,{type:"primary",disabled:!a.valid,onTouchEnd:h,onClick:h,children:d.jsx(bt,{children:s("edit-link-dialog.save")})})]})]})});var Yoe={};const gE=/(^\/r\/[^/]+\/?$)/,S1=[{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=ge(t);if(e&&e.pathname.match(gE))return t},fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(gE))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=ge(t);if(e&&e.pathname.match(/^\/embed\/?$/)){const n=e.searchParams.get("url");if(n)return n}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:t=>{if(t.includes("/maps/embed?"))return t;if(t.includes("/maps/")){const e=t.match(/@(.*?),(.*?),(.*?)z/);let n;if(e){const[,r,s,o]=e;n=`https://${new URL(t).host.replace("www.","")}/maps/embed/v1/view?key=${Yoe.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${s}&zoom=${o}`}else n="";return n}},fromEmbedUrl:t=>{const e=ge(t);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const r=e.searchParams.get("zoom"),[s,o]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${s},${o},${r}z`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/v\/(.+)\/?/);if(n)return`https://www.val.town/embed/${n[1]}`},fromEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/s\/([^/]+)\/?/);if(n)return`https://codesandbox.io/embed/${n[1]}`},fromEmbedUrl:t=>{const e=ge(t),n=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[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\/([^/]+)/,n=t.match(e);if(n){const[r,s,o]=n;return`https://codepen.io/${s}/embed/${o}`}},fromEmbedUrl:t=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,n=t.match(e);if(n){const[r,s,o]=n;return`https://codepen.io/${s}/pen/${o}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:t=>{const e=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,n=t.match(e);if(n){const[r,s]=n;return`https://scratch.mit.edu/projects/embed/${s}`}},fromEmbedUrl:t=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,n=t.match(e);if(n){const[r,s]=n;return`https://scratch.mit.edu/projects/${s}`}}},{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=ge(t);if(!e)return;const n=e.hostname.replace(/^www./,"");if(n==="youtu.be")return`https://www.youtube.com/embed/${e.pathname.split("/").filter(Boolean)[0]}`;if((n==="youtube.com"||n==="m.youtube.com")&&e.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${e.searchParams.get("v")}`},fromEmbedUrl:t=>{const e=ge(t);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const r=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(r)return`https://www.youtube.com/watch?v=${r[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=ge(t),n=e==null?void 0:e.searchParams.get("cid");if(e!=null&&e.pathname.match(/\/calendar\/u\/0/)&&n){e.pathname="/calendar/embed";const r=Array.from(e.searchParams.keys());for(const s of r)e.searchParams.delete(s);return e.searchParams.set("src",n),e.href}},fromEmbedUrl:t=>{const e=ge(t),n=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&n){e.pathname="/calendar/u/0";const r=Array.from(e.searchParams.keys());for(const s of r)e.searchParams.delete(s);return e.searchParams.set("cid",n),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=ge(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/pub\/?$/))){e.pathname=e.pathname.replace(/\/pub$/,"/embed");const n=Array.from(e.searchParams.keys());for(const r of n)e.searchParams.delete(r);return e.href}},fromEmbedUrl:t=>{const e=ge(t);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const n=Array.from(e.searchParams.keys());for(const r of n)e.searchParams.delete(r);return e.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return t.split("/").pop()?t:void 0},fromEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return t.split("/").pop()?t:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:t=>{const e=ge(t);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${t}?embed=true`},fromEmbedUrl:t=>{const e=ge(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=ge(t);if(e&&e.pathname.match(/^\/map\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:t=>{const e=ge(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=ge(t);if(e&&e.pathname.match(/^\/(artist|album)\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:t=>{const e=ge(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=ge(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=ge(t);if(e&&e.hostname==="player.vimeo.com"){const n=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(n)return"https://vimeo.com/"+n[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:t=>{const e=ge(t);if(e&&e.hash.match(/#room=/))return t},fromEmbedUrl:t=>{const e=ge(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=ge(t);if(e&&e.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}/embed${e.pathname}?cell=*`;if(e&&e.pathname.match(/^\/d\/([^/]+)\/?$/)){const n=e.pathname.replace(/^\/d/,"");return`${e.origin}/embed${n}?cell=*`}},fromEmbedUrl:t=>{const e=ge(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=ge(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search===""&&e.hash==="")return`${t}?embed`},fromEmbedUrl:t=>{const e=ge(t);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return t.replace("?embed","")}}],Xoe={"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},qoe=S1.map(t=>t.type);function Zoe(t){return qoe.includes(t)}function Qoe(t){return"icon"in t}function m$(){return z().getShapeUtil("embed")}function v1(){const t=m$();return e=>t?t.getEmbedDefinition(e):void 0}function Joe(){const t=m$();return t?t.getEmbedDefinitions():[]}const y$=Zt(function({onClose:e}){const n=z(),r=Ee(),s=h1(),[o,i]=w.useState(null),[a,l]=w.useState(""),[c,u]=w.useState(null),[h,f]=w.useState(!1),p=w.useRef(-1),g=Joe(),m=v1();return d.jsxs(d.Fragment,{children:[d.jsxs(dm,{children:[d.jsx(hm,{children:o?`${r("embed-dialog.title")} — ${o.title}`:r("embed-dialog.title")}),d.jsx(fm,{})]}),o?d.jsxs(d.Fragment,{children:[d.jsxs(Yu,{className:"tlui-embed-dialog__enter",children:[d.jsx(pm,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"https://example.com",autoFocus:!0,onValueChange:v=>{l(v);const y=m(v);u(y&&y.definition.type===o.type?y:null),f(!1),clearTimeout(p.current),p.current=n.timers.setTimeout(()=>f(!y),320)}}),a===""?d.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[d.jsx("span",{children:r("embed-dialog.instruction")})," ",o.instructionLink&&d.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:o.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",d.jsx(zs,{icon:"external-link",small:!0})]})]}):d.jsx("div",{className:"tlui-embed-dialog__warning",children:h?r("embed-dialog.invalid-url"):" "})]}),d.jsxs(y1,{className:"tlui-dialog__footer__actions",children:[d.jsx(ue,{type:"normal",onClick:()=>{i(null),u(null),l("")},children:d.jsx(bt,{children:r("embed-dialog.back")})}),d.jsx("div",{className:"tlui-embed__spacer"}),d.jsx(ue,{type:"normal",onClick:e,children:d.jsx(bt,{children:r("embed-dialog.cancel")})}),d.jsx(ue,{type:"primary",disabled:!c,onClick:()=>{c&&(n.putExternalContent({type:"embed",url:a,point:n.getViewportPageBounds().center,embed:c.definition}),e())},children:d.jsx(bt,{children:r("embed-dialog.create")})})]})]}):d.jsx(d.Fragment,{children:d.jsx(Yu,{className:"tlui-embed-dialog__list",children:g.map(v=>{const y=Zoe(v.type)?s.embedIcons[v.type]:Qoe(v)?v.icon:void 0;return d.jsxs(ue,{type:"menu",onClick:()=>i(v),children:[d.jsx(bt,{children:v.title}),y&&d.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${y})`}})]},v.type)})})})]})});async function eie(t,e,n){const r=me(e.map(a=>{const l=t.getShape(a);if(!(!l||t.getShapeUtil(l.type).toSvg===void 0))return l}));if(r.length===0)return;if(r.length===1){const a=r[0];if(!a||t.isShapeOfType(a,"image"))return}const s=[];if(n!==void 0){const a=r.map(l=>({shape:l,bounds:t.getShapeMaskedPageBounds(l).clone().expandBy(n)}));for(let l=0;l<a.length;l++){const c=a[l];if(l===0){s[0]={shapes:[c.shape],bounds:c.bounds};continue}let u=!1;for(const h of s)if(h.bounds.includes(c.bounds)){h.shapes.push(c.shape),h.bounds.expand(c.bounds),u=!0;break}u||s.push({shapes:[c.shape],bounds:c.bounds})}}else{const a=Z.Common(r.map(l=>t.getShapeMaskedPageBounds(l)));s.push({shapes:r,bounds:a})}const o=t.options.flattenImageBoundsPadding;for(const a of s){n!==void 0&&a.bounds.expandBy(-n);const l=await t.getSvgString(a.shapes,{padding:o});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 i=[];return js(()=>{for(const a of s){const{asset:l,bounds:c,shapes:u}=a;if(!l)continue;const h=t.findCommonAncestor(u)??t.getCurrentPageId();if(!h)continue;let f="a1";for(const y of u)if(y.parentId===h){y.index>f&&(f=y.index);break}let p,g,m;if(Fn(h)){const y=t.getShape(h);if(!y)continue;const S=t.getPointInShapeSpace(y,{x:c.x,y:c.y});m=t.getShapePageTransform(h).rotation(),S.sub(new x(o,o).rot(-m)),p=S.x,g=S.y}else p=c.x-o,g=c.y-o,m=0;t.deleteShapes(u),t.createAssets([{...l,id:l.id}]);const v=Ke();t.createShape({id:v,type:"image",index:f,parentId:h,x:p,y:g,rotation:-m,props:{assetId:l.id,w:c.w+o*2,h:c.h+o*2}}),i.push(v)}}),i}function gm(){const t=Ti();return(t==null?void 0:t.store.props.collaboration)!==void 0}function tie(){const t=Ti();return U("sync status",()=>{var e;return(e=t==null?void 0:t.store.props.collaboration)!=null&&e.status?t.store.props.collaboration.status.get():null},[t])}const fS=[0,389,436,476,580,640,840,1023];var St=(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))(St||{});const S$=ke.createContext(null);function nie({forceMobile:t=!1,children:e}){const n=Ti(),r=U("breakpoint",()=>{const{width:s}=(n==null?void 0:n.getViewportScreenBounds())??{width:window.innerWidth},o=t?St.MOBILE_SM:fS.length-1;for(let i=0;i<o;i++)if(s>fS[i]&&s<=fS[i+1])return i;return o},[n]);return d.jsx(S$.Provider,{value:r,children:e})}function An(){const t=w.useContext(S$);if(t===null)throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return t}const v$=w.createContext(null);function rie({context:t,children:e}){const n=Jt(),r=q0("dialogs",[]),s=w.useMemo(()=>({dialogs:r,addDialog(o){const i=o.id??ze();return r.update(a=>[...a.filter(l=>l.id!==o.id),{...o,id:i}]),n("open-menu",{source:"dialog",id:i}),Vr.addOpenMenu(i,t),i},removeDialog(o){var a;const i=r.get().find(l=>l.id===o);return i&&((a=i.onClose)==null||a.call(i),n("close-menu",{source:"dialog",id:o}),Vr.deleteOpenMenu(o,t),r.update(l=>l.filter(c=>c!==i))),o},clearDialogs(){const o=r.get();o.length!==0&&(o.forEach(i=>{var a;(a=i.onClose)==null||a.call(i),n("close-menu",{source:"dialog",id:i.id}),Vr.deleteOpenMenu(i.id,t)}),r.set([]))}}),[n,r,t]);return d.jsx(v$.Provider,{value:s,children:e})}function Ed(){const t=w.useContext(v$);if(!t)throw new Error("useDialogs must be used within a DialogsProvider");return t}var sie="VisuallyHidden",x1=w.forwardRef((t,e)=>d.jsx(Ae.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}}));x1.displayName=sie;var w1="ToastProvider",[b1,oie,iie]=Jg("Toast"),[x$,gge]=Ws("Toast",[iie]),[aie,mm]=x$(w1),w$=t=>{const{__scopeToast:e,label:n="Notification",duration:r=5e3,swipeDirection:s="right",swipeThreshold:o=50,children:i}=t,[a,l]=w.useState(null),[c,u]=w.useState(0),h=w.useRef(!1),f=w.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${w1}\`. Expected non-empty \`string\`.`),d.jsx(b1.Provider,{scope:e,children:d.jsx(aie,{scope:e,label:n,duration:r,swipeDirection:s,swipeThreshold:o,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:w.useCallback(()=>u(p=>p+1),[]),onToastRemove:w.useCallback(()=>u(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:i})})};w$.displayName=w1;var b$="ToastViewport",lie=["F8"],Hx="toast.viewportPause",Kx="toast.viewportResume",P$=w.forwardRef((t,e)=>{const{__scopeToast:n,hotkey:r=lie,label:s="Notifications ({hotkey})",...o}=t,i=mm(b$,n),a=oie(n),l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),h=w.useRef(null),f=Qe(e,h,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=i.toastCount>0;w.useEffect(()=>{const v=y=>{var b;r.length!==0&&r.every(P=>y[P]||y.code===P)&&((b=h.current)==null||b.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),w.useEffect(()=>{const v=l.current,y=h.current;if(g&&v&&y){const S=()=>{if(!i.isClosePausedRef.current){const _=new CustomEvent(Hx);y.dispatchEvent(_),i.isClosePausedRef.current=!0}},b=()=>{if(i.isClosePausedRef.current){const _=new CustomEvent(Kx);y.dispatchEvent(_),i.isClosePausedRef.current=!1}},P=_=>{!v.contains(_.relatedTarget)&&b()},C=()=>{v.contains(document.activeElement)||b()};return v.addEventListener("focusin",S),v.addEventListener("focusout",P),v.addEventListener("pointermove",S),v.addEventListener("pointerleave",C),window.addEventListener("blur",S),window.addEventListener("focus",b),()=>{v.removeEventListener("focusin",S),v.removeEventListener("focusout",P),v.removeEventListener("pointermove",S),v.removeEventListener("pointerleave",C),window.removeEventListener("blur",S),window.removeEventListener("focus",b)}}},[g,i.isClosePausedRef]);const m=w.useCallback(({tabbingDirection:v})=>{const S=a().map(b=>{const P=b.ref.current,C=[P,...wie(P)];return v==="forwards"?C:C.reverse()});return(v==="forwards"?S.reverse():S).flat()},[a]);return w.useEffect(()=>{const v=h.current;if(v){const y=S=>{var C,_,E;const b=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!b){const k=document.activeElement,D=S.shiftKey;if(S.target===v&&D){(C=c.current)==null||C.focus();return}const L=m({tabbingDirection:D?"backwards":"forwards"}),M=L.findIndex(O=>O===k);pS(L.slice(M+1))?S.preventDefault():D?(_=c.current)==null||_.focus():(E=u.current)==null||E.focus()}};return v.addEventListener("keydown",y),()=>v.removeEventListener("keydown",y)}},[a,m]),d.jsxs($te,{ref:l,role:"region","aria-label":s.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&d.jsx(Wx,{ref:c,onFocusFromOutsideViewport:()=>{const v=m({tabbingDirection:"forwards"});pS(v)}}),d.jsx(b1.Slot,{scope:n,children:d.jsx(Ae.ol,{tabIndex:-1,...o,ref:f})}),g&&d.jsx(Wx,{ref:u,onFocusFromOutsideViewport:()=>{const v=m({tabbingDirection:"backwards"});pS(v)}})]})});P$.displayName=b$;var C$="ToastFocusProxy",Wx=w.forwardRef((t,e)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...s}=t,o=mm(C$,n);return d.jsx(x1,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=o.viewport)!=null&&c.contains(a))&&r()}})});Wx.displayName=C$;var ym="Toast",cie="toast.swipeStart",uie="toast.swipeMove",die="toast.swipeCancel",hie="toast.swipeEnd",_$=w.forwardRef((t,e)=>{const{forceMount:n,open:r,defaultOpen:s,onOpenChange:o,...i}=t,[a=!0,l]=ji({prop:r,defaultProp:s,onChange:o});return d.jsx(ds,{present:n||a,children:d.jsx(gie,{open:a,...i,ref:e,onClose:()=>l(!1),onPause:qt(t.onPause),onResume:qt(t.onResume),onSwipeStart:se(t.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:se(t.onSwipeMove,c=>{const{x:u,y:h}=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",`${h}px`)}),onSwipeCancel:se(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:se(t.onSwipeEnd,c=>{const{x:u,y:h}=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",`${h}px`),l(!1)})})})});_$.displayName=ym;var[fie,pie]=x$(ym,{onClose(){}}),gie=w.forwardRef((t,e)=>{const{__scopeToast:n,type:r="foreground",duration:s,open:o,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:p,...g}=t,m=mm(ym,n),[v,y]=w.useState(null),S=Qe(e,O=>y(O)),b=w.useRef(null),P=w.useRef(null),C=s||m.duration,_=w.useRef(0),E=w.useRef(C),k=w.useRef(0),{onToastAdd:D,onToastRemove:T}=m,j=qt(()=>{var F;(v==null?void 0:v.contains(document.activeElement))&&((F=m.viewport)==null||F.focus()),i()}),L=w.useCallback(O=>{!O||O===1/0||(window.clearTimeout(k.current),_.current=new Date().getTime(),k.current=window.setTimeout(j,O))},[j]);w.useEffect(()=>{const O=m.viewport;if(O){const F=()=>{L(E.current),c==null||c()},B=()=>{const K=new Date().getTime()-_.current;E.current=E.current-K,window.clearTimeout(k.current),l==null||l()};return O.addEventListener(Hx,B),O.addEventListener(Kx,F),()=>{O.removeEventListener(Hx,B),O.removeEventListener(Kx,F)}}},[m.viewport,C,l,c,L]),w.useEffect(()=>{o&&!m.isClosePausedRef.current&&L(C)},[o,C,m.isClosePausedRef,L]),w.useEffect(()=>(D(),()=>T()),[D,T]);const M=w.useMemo(()=>v?j$(v):null,[v]);return m.viewport?d.jsxs(d.Fragment,{children:[M&&d.jsx(mie,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:M}),d.jsx(fie,{scope:n,onClose:j,children:ba.createPortal(d.jsx(b1.ItemSlot,{scope:n,children:d.jsx(Lte,{asChild:!0,onEscapeKeyDown:se(a,()=>{m.isFocusedToastEscapeKeyDownRef.current||j(),m.isFocusedToastEscapeKeyDownRef.current=!1}),children:d.jsx(Ae.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":m.swipeDirection,...g,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:se(t.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(m.isFocusedToastEscapeKeyDownRef.current=!0,j()))}),onPointerDown:se(t.onPointerDown,O=>{O.button===0&&(b.current={x:O.clientX,y:O.clientY})}),onPointerMove:se(t.onPointerMove,O=>{if(!b.current)return;const F=O.clientX-b.current.x,B=O.clientY-b.current.y,K=!!P.current,R=["left","right"].includes(m.swipeDirection),H=["left","up"].includes(m.swipeDirection)?Math.min:Math.max,X=R?H(0,F):0,te=R?0:H(0,B),le=O.pointerType==="touch"?10:2,de={x:X,y:te},Me={originalEvent:O,delta:de};K?(P.current=de,Th(uie,h,Me,{discrete:!1})):mE(de,m.swipeDirection,le)?(P.current=de,Th(cie,u,Me,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(F)>le||Math.abs(B)>le)&&(b.current=null)}),onPointerUp:se(t.onPointerUp,O=>{const F=P.current,B=O.target;if(B.hasPointerCapture(O.pointerId)&&B.releasePointerCapture(O.pointerId),P.current=null,b.current=null,F){const K=O.currentTarget,R={originalEvent:O,delta:F};mE(F,m.swipeDirection,m.swipeThreshold)?Th(hie,p,R,{discrete:!0}):Th(die,f,R,{discrete:!0}),K.addEventListener("click",H=>H.preventDefault(),{once:!0})}})})})}),m.viewport)})]}):null}),mie=t=>{const{__scopeToast:e,children:n,...r}=t,s=mm(ym,e),[o,i]=w.useState(!1),[a,l]=w.useState(!1);return vie(()=>i(!0)),w.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:d.jsx(Pd,{asChild:!0,children:d.jsx(x1,{...r,children:o&&d.jsxs(d.Fragment,{children:[s.label," ",n]})})})},yie="ToastTitle",I$=w.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(Ae.div,{...r,ref:e})});I$.displayName=yie;var Sie="ToastDescription",E$=w.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(Ae.div,{...r,ref:e})});E$.displayName=Sie;var k$="ToastAction",T$=w.forwardRef((t,e)=>{const{altText:n,...r}=t;return n.trim()?d.jsx(A$,{altText:n,asChild:!0,children:d.jsx(P1,{...r,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${k$}\`. Expected non-empty \`string\`.`),null)});T$.displayName=k$;var M$="ToastClose",P1=w.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t,s=pie(M$,n);return d.jsx(A$,{asChild:!0,children:d.jsx(Ae.button,{type:"button",...r,ref:e,onClick:se(t.onClick,s.onClose)})})});P1.displayName=M$;var A$=w.forwardRef((t,e)=>{const{__scopeToast:n,altText:r,...s}=t;return d.jsx(Ae.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...s,ref:e})});function j$(t){const e=[];return Array.from(t.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&e.push(r.textContent),xie(r)){const s=r.ariaHidden||r.hidden||r.style.display==="none",o=r.dataset.radixToastAnnounceExclude==="";if(!s)if(o){const i=r.dataset.radixToastAnnounceAlt;i&&e.push(i)}else e.push(...j$(r))}}),e}function Th(t,e,n,{discrete:r}){const s=n.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?$b(s,o):s.dispatchEvent(o)}var mE=(t,e,n=0)=>{const r=Math.abs(t.x),s=Math.abs(t.y),o=r>s;return e==="left"||e==="right"?o&&r>n:!o&&s>n};function vie(t=()=>{}){const e=qt(t);yi(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[e])}function xie(t){return t.nodeType===t.ELEMENT_NODE}function wie(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function pS(t){const e=document.activeElement;return t.some(n=>n===e?!0:(n.focus(),document.activeElement!==e))}var bie=_$,Pie=I$,Cie=E$,_ie=T$,yE=P1;const O$=w.createContext(null);function Iie({children:t}){const e=q0("toasts",[]),n=w.useMemo(()=>({toasts:e,addToast(r){const s=r.id??ze();return e.update(o=>[...o.filter(i=>i.id!==r.id),{...r,id:s}]),s},removeToast(r){return e.update(s=>s.filter(o=>o.id!==r)),r},clearToasts(){e.set([])}}),[e]);return d.jsx(w$,{children:d.jsx(O$.Provider,{value:n,children:t})})}function To(){const t=w.useContext(O$);if(!t)throw new Error("useToasts must be used within a ToastsProvider");return t}var C1={exports:{}};C1.exports;(function(t){var e=function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={};function i(l,c){if(!o[l]){o[l]={};for(var u=0;u<l.length;u++)o[l][l.charAt(u)]=u}return o[l][c]}var a={compressToBase64:function(l){if(l==null)return"";var c=a._compress(l,6,function(u){return r.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 i(r,l.charAt(c))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(c){return n(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),h=0,f=c.length;h<f;h++){var p=c.charCodeAt(h);u[h*2]=p>>>8,u[h*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,h=c.length;u<h;u++)c[u]=l[u*2]*256+l[u*2+1];var f=[];return c.forEach(function(p){f.push(n(p))}),a.decompress(f.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(c){return s.charAt(c)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(c){return i(s,l.charAt(c))}))},compress:function(l){return a._compress(l,16,function(c){return n(c)})},_compress:function(l,c,u){if(l==null)return"";var h,f,p={},g={},m="",v="",y="",S=2,b=3,P=2,C=[],_=0,E=0,k;for(k=0;k<l.length;k+=1)if(m=l.charAt(k),Object.prototype.hasOwnProperty.call(p,m)||(p[m]=b++,g[m]=!0),v=y+m,Object.prototype.hasOwnProperty.call(p,v))y=v;else{if(Object.prototype.hasOwnProperty.call(g,y)){if(y.charCodeAt(0)<256){for(h=0;h<P;h++)_=_<<1,E==c-1?(E=0,C.push(u(_)),_=0):E++;for(f=y.charCodeAt(0),h=0;h<8;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1}else{for(f=1,h=0;h<P;h++)_=_<<1|f,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=0;for(f=y.charCodeAt(0),h=0;h<16;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1}S--,S==0&&(S=Math.pow(2,P),P++),delete g[y]}else for(f=p[y],h=0;h<P;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1;S--,S==0&&(S=Math.pow(2,P),P++),p[v]=b++,y=String(m)}if(y!==""){if(Object.prototype.hasOwnProperty.call(g,y)){if(y.charCodeAt(0)<256){for(h=0;h<P;h++)_=_<<1,E==c-1?(E=0,C.push(u(_)),_=0):E++;for(f=y.charCodeAt(0),h=0;h<8;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1}else{for(f=1,h=0;h<P;h++)_=_<<1|f,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=0;for(f=y.charCodeAt(0),h=0;h<16;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1}S--,S==0&&(S=Math.pow(2,P),P++),delete g[y]}else for(f=p[y],h=0;h<P;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1;S--,S==0&&(S=Math.pow(2,P),P++)}for(f=2,h=0;h<P;h++)_=_<<1|f&1,E==c-1?(E=0,C.push(u(_)),_=0):E++,f=f>>1;for(;;)if(_=_<<1,E==c-1){C.push(u(_));break}else E++;return C.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 h=[],f=4,p=4,g=3,m="",v=[],y,S,b,P,C,_,E,k={val:u(0),position:c,index:1};for(y=0;y<3;y+=1)h[y]=y;for(b=0,C=Math.pow(2,2),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;switch(b){case 0:for(b=0,C=Math.pow(2,8),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;E=n(b);break;case 1:for(b=0,C=Math.pow(2,16),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;E=n(b);break;case 2:return""}for(h[3]=E,S=E,v.push(E);;){if(k.index>l)return"";for(b=0,C=Math.pow(2,g),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;switch(E=b){case 0:for(b=0,C=Math.pow(2,8),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;h[p++]=n(b),E=p-1,f--;break;case 1:for(b=0,C=Math.pow(2,16),_=1;_!=C;)P=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),b|=(P>0?1:0)*_,_<<=1;h[p++]=n(b),E=p-1,f--;break;case 2:return v.join("")}if(f==0&&(f=Math.pow(2,g),g++),h[E])m=h[E];else if(E===p)m=S+S.charAt(0);else return null;v.push(m),h[p++]=S+m.charAt(0),f--,S=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})})(C1);var Eie=C1.exports;const D$=wi(Eie),_1="web image/vnd.tldraw+png",kie={"image/png":_1},Tie={[_1]:"image/png"};function Mie(t){return hn(kie,t)??null}function Aie(t){return hn(Tie,t)??t}function jie(t){return typeof ClipboardItem<"u"&&"supports"in ClipboardItem&&ClipboardItem.supports(t)}function Oie(t){const e=Object.entries(t);for(const[n,r]of e)r.catch(s=>console.error(s));return navigator.clipboard.write([new ClipboardItem(t)]).catch(n=>(console.error(n),Promise.all(e.map(async([r,s])=>[r,await s])).then(r=>{const s=w0(r);return navigator.clipboard.write([new ClipboardItem(s)])})))}async function Die(t,e,n){var y,S,b;const{elements:r,files:s}=e,o={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:t.store.schema.serialize()},i=new Map,a=new Map,l=t.getCurrentPageId(),c=new Map,u=[],h=new Set;r.forEach(P=>{if(c.set(P.id,Ke()),P.boundElements!==null)for(const C of P.boundElements)C.type==="text"&&h.add(C.id)});let f=QT;for(const P of r){if(h.has(P.id))continue;const C=c.get(P.id),_={id:C,typeName:"shape",parentId:l,index:f,x:P.x,y:P.y,rotation:0,isLocked:P.locked,opacity:Rie(P.opacity),meta:{}};switch(P.angle!==0&&a.set(C,P.angle),P.groupIds&&P.groupIds.length>0?i.has(P.groupIds[0])?(y=i.get(P.groupIds[0]))==null||y.push(C):i.set(P.groupIds[0],[C]):u.push(C),P.type){case"rectangle":case"ellipse":case"diamond":{let E="",k="middle";if(P.boundElements!==null){for(const T of P.boundElements)if(T.type==="text"){const j=r.find(L=>L.id===T.id);j&&(E=j.text,k=Uie[j.textAlign])}}const D=P.backgroundColor==="transparent"?P.strokeColor:P.backgroundColor;o.shapes.push({..._,type:"geo",props:{geo:P.type,url:P.link??"",w:P.width,h:P.height,size:Mh[P.strokeWidth]??"draw",color:Ac[D]??"black",text:E,align:k,dash:Ah(P),fill:Wie(P)}});break}case"freedraw":{o.shapes.push({..._,type:"draw",props:{dash:Ah(P),size:Mh[P.strokeWidth],color:Ac[P.strokeColor]??"black",segments:[{type:"free",points:P.points.map(([E,k,D=.5])=>({x:E,y:k,z:D}))}]}});break}case"line":{if(P.points.slice().length<2)break;const k=Fu(P.points.length);o.shapes.push({..._,type:"line",props:{dash:Ah(P),size:Mh[P.strokeWidth],color:Ac[P.strokeColor]??"black",spline:P.roundness?"cubic":"line",points:{...Object.fromEntries(P.points.map(([D,T],j)=>{const L=k[j];return[L,{id:L,index:L,x:D,y:T}]}))}}});break}case"arrow":{let E="";if(P.boundElements!==null){for(const L of P.boundElements)if(L.type==="text"){const M=r.find(O=>O.id===L.id);M&&(E=M.text)}}const k=P.points[0],D=P.points[P.points.length-1],T=c.get((S=P.startBinding)==null?void 0:S.elementId),j=c.get((b=P.endBinding)==null?void 0:b.elementId);o.shapes.push({..._,type:"arrow",props:{text:E,bend:Kie(P,k,D),dash:Ah(P),size:Mh[P.strokeWidth]??"m",color:Ac[P.strokeColor]??"black",start:{x:k[0],y:k[1]},end:{x:D[0],y:D[1]},arrowheadEnd:SE[P.endArrowhead]??"none",arrowheadStart:SE[P.startArrowhead]??"none"}}),T&&o.bindings.push({id:Ji(),typeName:"binding",type:"arrow",fromId:C,toId:T,props:{terminal:"start",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),j&&o.bindings.push({id:Ji(),typeName:"binding",type:"arrow",fromId:C,toId:j,props:{terminal:"end",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{const{size:E,scale:k}=$ie(P.fontSize);o.shapes.push({..._,type:"text",props:{size:E,scale:k,font:Fie[P.fontFamily]??"draw",color:Ac[P.strokeColor]??"black",text:P.text,textAlign:Hie[P.textAlign]}});break}case"image":{const E=s[P.fileId];if(!E)break;const k=Yo.createId();o.assets.push({id:k,typeName:"asset",type:"image",props:{w:P.width,h:P.height,fileSize:E.size,name:P.id??"Untitled",isAnimated:!1,mimeType:E.mimeType,src:E.dataURL},meta:{}}),o.shapes.push({..._,type:"image",props:{w:P.width,h:P.height,assetId:k}})}}f=_s(f)}const p=n??(t.inputs.shiftKey?t.inputs.currentPagePoint:void 0);t.markHistoryStoppingPoint("paste"),t.putContentOntoCurrentPage(o,{point:p,select:!1,preserveIds:!0});for(const P of i.values())if(P.length>1){t.groupShapes(P);const C=t.getShape(P[0]);C!=null&&C.parentId&&Fn(C.parentId)&&u.push(C.parentId)}for(const[P,C]of a)t.select(P),t.rotateShapesBy([P],C);const g=me(u.map(P=>t.getShape(P))),m=Z.Common(g.map(P=>t.getShapePageBounds(P))),v=t.getViewportPageBounds().center;t.updateShapes(g.map(P=>{const C={x:(P.x??0)-(m.x+m.w/2),y:(P.y??0)-(m.y+m.h/2)};return{id:P.id,type:P.type,x:v.x+C.x,y:v.y+C.y}})),t.setSelectedShapes(u)}const Rie=t=>{const e=t/100;return e<.2?.1:e<.4?.25:e<.6?.5:e<.8?.75:1},Mh={1:"s",2:"m",3:"l",4:"xl"},Lie={16:"s",20:"m",28:"l",36:"xl"};function $ie(t){const e=Lie[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 Fie={1:"draw",2:"sans",3:"mono"},Nie={gray:["#f8f9fa","#e9ecef","#ced4da","#868e96","#343a40"],red:["#fff5f5","#ffc9c9","#ff8787","#fa5252","#e03131"],pink:["#fff0f6","#fcc2d7","#f783ac","#e64980","#c2255c"],grape:["#f8f0fc","#eebefa","#da77f2","#be4bdb","#9c36b5"],violet:["#f3f0ff","#d0bfff","#9775fa","#7950f2","#6741d9"],indigo:["#edf2ff","#bac8ff","#748ffc","#4c6ef5","#3b5bdb"],blue:["#e7f5ff","#a5d8ff","#4dabf7","#228be6","#1971c2"],cyan:["#e3fafc","#99e9f2","#3bc9db","#15aabf","#0c8599"],teal:["#e6fcf5","#96f2d7","#38d9a9","#12b886","#099268"],green:["#ebfbee","#b2f2bb","#69db7c","#40c057","#2f9e44"],lime:["#f4fce3","#d8f5a2","#a9e34b","#82c91e","#66a80f"],yellow:["#fff9db","#ffec99","#ffd43b","#fab005","#f08c00"],orange:["#fff4e6","#ffd8a8","#ffa94d","#fd7e14","#e8590c"]};function Ss(t,e,n){const r=[0,1,2,3,4].map(s=>Nie[t][s]);return Object.fromEntries(r.map((s,o)=>[s,o<3?e:n]))}const Ac={...Ss("gray","grey","black"),...Ss("red","light-red","red"),...Ss("pink","light-red","red"),...Ss("grape","light-violet","violet"),...Ss("blue","light-blue","blue"),...Ss("cyan","light-blue","blue"),...Ss("teal","light-green","green"),...Ss("green","light-green","green"),...Ss("yellow","yellow","orange"),...Ss("orange","yellow","orange"),"#ffffff":"white","#000000":"black"},zie={solid:"draw",dashed:"dashed",dotted:"dotted"},Bie={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},Uie={left:"start",center:"middle",right:"end"},Hie={left:"start",center:"middle",right:"end"},SE={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function Kie(t,e,n){let r=0;if(t.points.length>2){const s=new x(e[0],e[1]),o=new x(n[0],n[1]),i=new x(t.points[1][0],t.points[1][1]),a=x.Sub(o,s),l=x.Per(a),c=x.Med(o,s),u=x.Sub(c,l),h=x.Add(c,l),f=x.NearestPointOnLineSegment(u,h,i,!1);r=x.Dist(f,c),x.Clockwise(f,o,c)&&(r*=-1)}return r}const Ah=t=>{let e=zie[t.strokeStyle]??"draw";return e==="draw"&&t.roughness===0&&(e="solid"),e},Wie=t=>t.backgroundColor==="transparent"?"none":Bie[t.fillStyle]??"solid";async function Gie(t,e,n,r){const s=e.map(o=>o instanceof File?o:new File([o],"tldrawFile",{type:o.type}));t.markHistoryStoppingPoint("paste"),await t.putExternalContent({type:"files",files:s,point:n,ignoreParent:!1,sources:r})}function Vie(t,e,n){const r=t.getSelectionPageBounds();t.markHistoryStoppingPoint("paste"),t.putContentOntoCurrentPage(e,{point:n,select:!0});const s=t.getSelectionPageBounds();r&&s&&(r!=null&&r.collides(s))&&(t.updateInstanceState({isChangingStyle:!0}),t.timers.setTimeout(()=>{t.updateInstanceState({isChangingStyle:!1})},150))}async function Gx(t,e,n,r){return t.markHistoryStoppingPoint("paste"),await t.putExternalContent({type:"url",point:n,url:e,sources:r})}const Yie=[_1,"image/png","image/jpeg","image/webp","image/svg+xml"];function Xie(t){const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=t.trim(),e.body.textContent||e.body.innerText||""}const qie=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},Zie=t=>{const e=t.split(/[\n\s]/);for(const n of e)try{const r=new URL(n);if(!(r.protocol==="http:"||r.protocol==="https:"))return}catch{return}return Pj(e)},Qie=t=>/^<svg/.test(t),Jie=["input","select","textarea"];function gS(t){const{activeElement:e}=document;return t.menus.hasAnyOpenMenus()||e&&(e.getAttribute("contenteditable")||Jie.indexOf(e.tagName.toLowerCase())>-1)}const jh=(t,e,n,r)=>{const s=Zie(e);if(s)for(const o of s)Gx(t,o,n);else qie(e)?Gx(t,e,n):Qie(e)?(t.markHistoryStoppingPoint("paste"),t.putExternalContent({type:"svg-text",text:e,point:n,sources:r})):(t.markHistoryStoppingPoint("paste"),t.putExternalContent({type:"text",text:e,point:n,sources:r}))},eae=async(t,e,n)=>{if(t.getEditingShapeId()!==null)return;if(!e)throw Error("No clipboard data");const r=[];for(const s of Object.values(e.items))switch(s.kind){case"file":{r.push({type:"file",source:new Promise(o=>o(s.getAsFile()))});break}case"string":{s.type==="text/html"?r.push({type:"html",source:new Promise(o=>s.getAsString(o))}):s.type==="text/plain"?r.push({type:"text",source:new Promise(o=>s.getAsString(o))}):r.push({type:s.type,source:new Promise(o=>s.getAsString(o))});break}}L$(t,r,n)},R$=async({editor:t,clipboardItems:e,point:n,fallbackFiles:r})=>{const s=[];for(const o of e){for(const i of Yie)if(o.types.includes(i)){const a=o.getType(i).then(l=>Zr.rewriteMimeType(l,Aie(i)));s.push({type:"blob",source:a});break}o.types.includes("text/html")&&s.push({type:"html",source:(async()=>{const i=await o.getType("text/html");return await Zr.blobToText(i)})()}),o.types.includes("text/uri-list")&&s.push({type:"url",source:(async()=>{const i=await o.getType("text/uri-list");return await Zr.blobToText(i)})()}),o.types.includes("text/plain")&&s.push({type:"text",source:(async()=>{const i=await o.getType("text/plain");return await Zr.blobToText(i)})()})}return r&&s.length===1&&s[0].type==="text"&&(s.pop(),s.push(...r.map(o=>({type:"file",source:Promise.resolve(o)})))),await L$(t,s,n)};async function L$(t,e,n){const r=e.filter(o=>(o.type==="file"||o.type==="blob")&&o.source!==null);if(r.length){if(r.length>t.options.maxFilesAtOnce)throw Error("Too many files");const o=me(await Promise.all(r.map(i=>i.source)));return await Gie(t,o,n)}const s=await Promise.all(e.filter(o=>o.type!=="file").map(o=>new Promise(i=>{const a=o;if(a.type==="file"){i({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 h=D$.decompressFromBase64(c);if(h===null){i({type:"error",data:h,reason:"found tldraw data comment but could not parse base64"});return}else{const f=JSON.parse(h);if(f.type!=="application/tldraw"&&i({type:"error",data:f,reason:`found tldraw data comment but JSON was of a different type: ${f.type}`}),typeof f.data=="string"){i({type:"error",data:f,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}i({type:"tldraw",data:f.data});return}}catch{i({type:"error",data:c,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){i({type:"text",data:l,subtype:"html"});return}if(a.type==="url"){i({type:"text",data:l,subtype:"url"});return}try{const h=JSON.parse(l);if(h.type==="excalidraw/clipboard"){i({type:"excalidraw",data:h});return}else{i({type:"text",data:l,subtype:"json"});return}}catch{i({type:"text",data:l,subtype:"text"});return}}i({type:"error",data:l,reason:"unhandled case"})})})));for(const o of s)if(o.type==="tldraw"){Vie(t,o.data,n);return}for(const o of s)if(o.type==="excalidraw"){Die(t,o.data,n);return}for(const o of s){if(o.type==="text"&&o.subtype==="html"){const a=new DOMParser().parseFromString(o.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");jh(t,c,n,s);return}if(!s.some(c=>c.type==="text"&&c.subtype!=="html")&&o.data.trim()){jh(t,Xie(o.data),n,s);return}}if(o.type==="text"&&o.subtype==="text"&&o.data.startsWith("<iframe ")){const a=new DOMParser().parseFromString(o.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(c=>c.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="IFRAME"&&a.firstElementChild.hasAttribute("src")&&a.firstElementChild.getAttribute("src")!==""){const c=a.firstElementChild.getAttribute("src");jh(t,c,n,s);return}}}for(const o of s)if(o.type==="text"&&o.subtype==="url"){Gx(t,o.data,n,s);return}for(const o of s)if(o.type==="text"&&o.subtype==="text"&&o.data.trim()){jh(t,o.data,n,s);return}}const Vp=async t=>{var r;const e=await t.resolveAssetsInContent(t.getContentFromCurrentPage(t.getSelectedShapeIds()));if(!e){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const n=D$.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:e}));if(!(typeof navigator>"u")){const s=e.shapes.map(o=>t.getShapeUtil(o).getText(o)).filter(pB);if((r=navigator.clipboard)!=null&&r.write){const o=new Blob([`<div data-tldraw>${n}</div>`],{type:"text/html"});let i=s.join(" ");i===""&&(i=" "),navigator.clipboard.write([new ClipboardItem({"text/html":o,"text/plain":new Blob([i],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<div data-tldraw>${n}</div>`)}};function tae(){const t=z(),e=Jt(),n=w.useCallback(async function(i){t.getSelectedShapeIds().length!==0&&(await Vp(t),e("copy",{source:i}))},[t,e]),r=w.useCallback(async function(i){t.getSelectedShapeIds().length!==0&&(await Vp(t),t.deleteShapes(t.getSelectedShapeIds()),e("cut",{source:i}))},[t,e]),s=w.useCallback(async function(i,a,l){t.getEditingShapeId()===null&&(Array.isArray(i)&&i[0]instanceof ClipboardItem?(R$({editor:t,clipboardItems:i,point:l}),e("paste",{source:"menu"})):navigator.clipboard.read().then(c=>{s(c,a,l)}))},[t,e]);return{copy:n,cut:r,paste:s}}function nae(){const t=z(),e=Jt(),n=U("editor.isFocused",()=>t.getInstanceState().isFocused,[t]);w.useEffect(()=>{if(!n)return;const r=async l=>{t.getSelectedShapeIds().length===0||t.getEditingShapeId()!==null||gS(t)||(xe(l),await Vp(t),e("copy",{source:"kbd"}))};async function s(l){t.getSelectedShapeIds().length===0||t.getEditingShapeId()!==null||gS(t)||(xe(l),await Vp(t),t.deleteShapes(t.getSelectedShapeIds()),e("cut",{source:"kbd"}))}let o=!1;const i=l=>{l.button===1&&(o=!0,t.timers.requestAnimationFrame(()=>{o=!1}))},a=l=>{var f,p;if(o){Ct(l);return}if(t.getEditingShapeId()!==null||gS(t))return;let c,u=!1;t.inputs.shiftKey&&(u=!0),t.user.getIsPasteAtCursorMode()&&(u=!u),u&&(c=t.inputs.currentPagePoint);const h=()=>{l.clipboardData&&eae(t,l.clipboardData,c)};if((f=navigator.clipboard)!=null&&f.read){const g=Array.from(((p=l.clipboardData)==null?void 0:p.files)||[]);navigator.clipboard.read().then(m=>{Array.isArray(m)&&m[0]instanceof ClipboardItem&&R$({editor:t,clipboardItems:m,point:c,fallbackFiles:g})},()=>{h()})}else h();xe(l),e("paste",{source:"kbd"})};return document.addEventListener("copy",r),document.addEventListener("cut",s),document.addEventListener("paste",a),document.addEventListener("pointerup",i),()=>{document.removeEventListener("copy",r),document.removeEventListener("cut",s),document.removeEventListener("paste",a),document.removeEventListener("pointerup",i)}},[t,e,n])}/*!
|
|
240
|
-
* canvas-size
|
|
241
|
-
* v1.2.6
|
|
242
|
-
* https://github.com/jhildenbiddle/canvas-size
|
|
243
|
-
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
244
|
-
* MIT license
|
|
245
|
-
*/function rae(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,s,o,i,a=[],l=!0,c=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(u){c=!0,s=u}finally{try{if(!l&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw s}}return a}}function vE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function rr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vE(Object(n),!0).forEach(function(r){sae(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vE(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sae(t,e,n){return e=fae(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oae(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,o;for(o=0;o<r.length;o++)s=r[o],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function iae(t,e){if(t==null)return{};var n=oae(t,e),r,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function xE(t,e){return lae(t)||rae(t,e)||$$(t,e)||dae()}function Oh(t){return aae(t)||cae(t)||$$(t)||uae()}function aae(t){if(Array.isArray(t))return Vx(t)}function lae(t){if(Array.isArray(t))return t}function cae(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function $$(t,e){if(t){if(typeof t=="string")return Vx(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Vx(t,e)}}function Vx(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function uae(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
246
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dae(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
247
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hae(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function fae(t){var e=hae(t,"string");return typeof e=="symbol"?e:String(e)}function du(t){var e=t.sizes.shift(),n=Math.max(Math.ceil(e[0]),1),r=Math.max(Math.ceil(e[1]),1),s=[n-1,r-1,1,1],o=Date.now(),i=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,a,l;i?(a=new OffscreenCanvas(1,1),l=new OffscreenCanvas(n,r)):(a=document.createElement("canvas"),a.width=1,a.height=1,l=document.createElement("canvas"),l.width=n,l.height=r);var c=a.getContext("2d"),u=l.getContext("2d");u&&(u.fillRect.apply(u,s),c.drawImage(l,n-1,r-1,1,1,0,0,1,1));var h=c&&c.getImageData(0,0,1,1).data[3]!==0,f=Date.now()-o;return[a,l].forEach(function(p){p.height=0,p.width=0}),i?(postMessage({width:n,height:r,benchmark:f,isTestPass:h}),!h&&t.sizes.length&&du(t)):h?t.onSuccess(n,r,f):(t.onError(n,r,f),t.sizes.length&&du(t)),h}var mS={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]},pae=["onError","onSuccess"],ul={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},jc={};function yS(t){var e=t.width===t.height,n=t.height===1,r=t.width===1,s=[];if(!t.width||!t.height)t.sizes.forEach(function(u){var h=e||n?u:1,f=e||r?u:1;s.push([h,f])});else for(var o=t.min||ul.min,i=t.step||ul.step,a=Math.max(t.width,t.height);a>=o;){var l=e||n?a:1,c=e||r?a:1;s.push([l,c]),a-=i}return s}function Dh(t){var e=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),s=t.onError,o=t.onSuccess,i=iae(t,pae),a=null;if(!e)return!1;if(t.useWorker&&n){var l=`
|
|
248
|
-
var canvasTest = `.concat(du.toString(),`;
|
|
249
|
-
onmessage = function(e) {
|
|
250
|
-
canvasTest(e.data);
|
|
251
|
-
};
|
|
252
|
-
`),c=new Blob([l],{type:"application/javascript"}),u=URL.createObjectURL(c);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(h){var f=h.data,p=f.width,g=f.height,m=f.benchmark,v=f.isTestPass;v?(jc[r].onSuccess(p,g,m),delete jc[r]):jc[r].onError(p,g,m)}}if(t.usePromise)return new Promise(function(h,f){var p=rr(rr({},t),{},{onError:function(y,S,b){var P;if(t.sizes.length===0)P=!0;else{var C=t.sizes.slice(-1),_=xE(C,1),E=xE(_[0],2),k=E[0],D=E[1];P=y===k&&S===D}s(y,S,b),P&&f({width:y,height:S,benchmark:b})},onSuccess:function(y,S,b){o(y,S,b),h({width:y,height:S,benchmark:b})}});if(a){var g=p.onError,m=p.onSuccess;jc[r]={onError:g,onSuccess:m},a.postMessage(i)}else du(p)});if(a)jc[r]={onError:s,onSuccess:o},a.postMessage(i);else return du(t)}var SS={maxArea:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=yS({width:e.max,height:e.max,min:e.min,step:e.step,sizes:Oh(mS.area)}),r=rr(rr(rr({},ul),e),{},{sizes:n});return Dh(r)},maxHeight:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=yS({width:1,height:e.max,min:e.min,step:e.step,sizes:Oh(mS.height)}),r=rr(rr(rr({},ul),e),{},{sizes:n});return Dh(r)},maxWidth:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=yS({width:e.max,height:1,min:e.min,step:e.step,sizes:Oh(mS.width)}),r=rr(rr(rr({},ul),e),{},{sizes:n});return Dh(r)},test:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=rr(rr({},ul),e);return n.sizes=Oh(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),Dh(n)}};let vS=null;function gae(){return vS||(vS=mae()),vS}async function mae(){const t=await SS.maxWidth({usePromise:!0}),e=await SS.maxHeight({usePromise:!0}),n=await SS.maxArea({usePromise:!0});return{maxWidth:t.width,maxHeight:e.height,maxArea:n.width*n.height}}const wE=8192,yae=4096*4096;async function Sae(t,e){if(t<=wE&&e<=wE&&t*e<=yae)return[t,e];const{maxWidth:n,maxHeight:r,maxArea:s}=await gae(),o=t/e;if(t>n&&(t=n,e=t/o),e>r&&(e=r,t=e*o),t*e>s){const i=Math.sqrt(s/(t*e));t*=i,e*=i}return[t,e]}async function F$(t,e,n){const{type:r,width:s,height:o,quality:i=1,pixelRatio:a=2}=n;let[l,c]=await Sae(s*a,o*a);l=Math.floor(l),c=Math.floor(c);const u=l/s,h=await Zr.blobToDataUrl(new Blob([e],{type:"image/svg+xml"})),f=await new Promise(g=>{const m=Lu();m.crossOrigin="anonymous",m.onload=async()=>{Ge.isSafari&&await Wv(250);const v=document.createElement("canvas"),y=v.getContext("2d");v.width=l,v.height=c,y.imageSmoothingEnabled=!0,y.imageSmoothingQuality="high",y.drawImage(m,0,0,l,c),URL.revokeObjectURL(h),g(v)},m.onerror=()=>{g(null)},m.src=h});if(!f)return null;const p=await new Promise(g=>f.toBlob(m=>{(!m||wt.throwToBlob.get())&&g(null),g(m)},"image/"+r,i));if(!p)return null;if(r==="png"){const g=new DataView(await p.arrayBuffer());return Ps.setPhysChunk(g,u,{type:"image/"+r})}else return p}async function N$(t,e,n){const r=await t.getSvgString(e!=null&&e.length?e:[...t.getCurrentPageShapeIds()],{scale:n.scale??1,background:t.getInstanceState().exportBackground,...n});if(!r)throw new Error("Could not construct SVG.");return r}async function Yx(t,e,n,r={}){var s;switch(n){case"svg":return(s=await N$(t,e,r))==null?void 0:s.svg;case"json":{const o=await t.resolveAssetsInContent(t.getContentFromCurrentPage(e));return JSON.stringify(o)}default:Ot(n)}}async function z$({editor:t,ids:e,format:n,opts:r={}}){switch(n){case"svg":return new Blob([await Yx(t,e,"svg",r)],{type:"text/plain"});case"json":return new Blob([await Yx(t,e,"json",r)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const s=await N$(t,e,r);if(!s)throw new Error("Could not construct image.");const o=await F$(t,s.svg,{type:n,quality:r.quality,pixelRatio:r.pixelRatio,width:s.width,height:s.height});if(!o)throw new Error("Could not construct image.");return o}default:Ot(n)}}const vae={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function xae(t,e,n,r={}){return{blobPromise:z$({editor:t,ids:e,format:n,opts:r}),mimeType:vae[n]}}function wae(t,e,n="svg",r={}){if(!navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(navigator.clipboard.write){const{blobPromise:s,mimeType:o}=xae(t,e,n,r),i={[o]:s},a=Mie(o);return a&&jie(a)&&(i[a]=s.then(l=>Zr.rewriteMimeType(l,a))),Oie(i)}switch(n){case"json":case"svg":return bae(async()=>Yx(t,e,n,r));case"jpeg":case"png":throw new Error("Copy not supported");default:Ot(n)}}async function bae(t){var e,n;await((n=(e=navigator.clipboard)==null?void 0:e.writeText)==null?void 0:n.call(e,await t()))}function Pae(){const t=z(),{addToast:e}=To(),n=Ee();return w.useCallback((r,s="svg")=>{wae(t,r,s).catch(()=>{e({id:"copy-fail",severity:"warning",title:n("toast.error.copy-fail.title"),description:n("toast.error.copy-fail.desc")})})},[t,e,n])}async function Cae(t,e,n="png",r,s={}){if(!r&&(r=`shapes at ${bE()}`,e.length===1)){const a=t.getShape(e[0]);t.isShapeOfType(a,"frame")?r=a.props.name||"frame":r=`${Rg(a.id)} at ${bE()}`}r+=`.${n}`;const o=await z$({editor:t,ids:e,format:n,opts:s}),i=new File([o],r,{type:o.type});_ae(i)}function bE(){const t=new Date,e=String(t.getFullYear()).slice(2),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return`${e}-${n}-${r} ${s}.${o}.${i}`}function _ae(t){const e=document.createElement("a"),n=URL.createObjectURL(t);e.href=n,e.download=t.name,e.click(),URL.revokeObjectURL(n)}function Iae(){const t=z(),{addToast:e}=To(),n=Ee();return w.useCallback((r,s="png",o)=>{Cae(t,r,s,o,{scale:1,background:t.getInstanceState().exportBackground}).catch(i=>{console.error(i.message),e({id:"export-fail",title:n("toast.error.export-fail.title"),description:n("toast.error.export-fail.desc"),severity:"error"})})},[t,e,n])}const B$=ke.createContext([]);function Eae(){const t=z(),e=w.useRef(),n=qo(ke.useContext(B$));return w.useEffect(()=>{const r=window.document.createElement("input");r.type="file",r.accept=(n==null?void 0:n.join(","))??K9,r.multiple=!0,e.current=r;async function s(o){const i=o.target.files;!i||i.length===0||(t.markHistoryStoppingPoint("insert media"),await t.putExternalContent({type:"files",files:Array.from(i),point:t.getViewportPageBounds().center,ignoreParent:!1}),r.value="")}return r.addEventListener("change",s),()=>{e.current=void 0,r.removeEventListener("change",s)}},[t,n]),w.useCallback(()=>{var r;(r=e.current)==null||r.click()},[e])}function kae(){const t=z(),e=w.useRef(null),n=w.useRef(null);return w.useCallback(async function(){const s=document.createElement("div"),o=document.createElement("style"),i=(y,S)=>{y&&(y.innerHTML=""),S&&document.head.contains(S)&&document.head.removeChild(S),y&&document.body.contains(y)&&document.body.removeChild(y)};i(e.current,n.current),e.current=s,n.current=o;const a=`tl-print-surface-${ze()}`;s.className=a,o.innerHTML=`
|
|
253
|
-
.${a} {
|
|
254
|
-
display: none;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.${a} svg {
|
|
258
|
-
max-width: 100%;
|
|
259
|
-
height: 100%;
|
|
260
|
-
display: block;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
@media print {
|
|
264
|
-
html, body {
|
|
265
|
-
min-height: 100%;
|
|
266
|
-
height: 100%;
|
|
267
|
-
margin: 0;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
body {
|
|
271
|
-
position: relative;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
body > * {
|
|
275
|
-
display: none;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.tldraw__editor {
|
|
279
|
-
display: none;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.${a} {
|
|
283
|
-
display: block !important;
|
|
284
|
-
background: white;
|
|
285
|
-
min-height: 100%;
|
|
286
|
-
height: 100%;
|
|
287
|
-
max-width: 100%;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.${a}__item {
|
|
291
|
-
padding: 10mm;
|
|
292
|
-
display: flex;
|
|
293
|
-
min-height: 100%;
|
|
294
|
-
flex-direction: column;
|
|
295
|
-
page-break-after: always;
|
|
296
|
-
position: relative;
|
|
297
|
-
overflow: hidden;
|
|
298
|
-
height: 100%;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.${a}__item__main {
|
|
302
|
-
flex: 1;
|
|
303
|
-
display: flex;
|
|
304
|
-
align-items: center;
|
|
305
|
-
justify-content: center;
|
|
306
|
-
max-height: 100%;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.${a}__item__header {
|
|
310
|
-
display: none;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.${a}__item__footer {
|
|
314
|
-
display: none;
|
|
315
|
-
text-align: right;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.${a}__item__footer__hide {
|
|
319
|
-
display: none;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
`;const l=()=>{document.head.appendChild(o),document.body.appendChild(s)},c=()=>{t.once("tick",()=>{i(s,o)})};window.addEventListener("beforeprint",l),window.addEventListener("afterprint",c);function u(y,S,b){try{s.innerHTML+=`<div class="${a}__item">
|
|
326
|
-
<div class="${a}__item__header">
|
|
327
|
-
${y.replace(/</g,"<").replace(/>/g,">")}
|
|
328
|
-
</div>
|
|
329
|
-
<div class="${a}__item__main">
|
|
330
|
-
${b}
|
|
331
|
-
</div>
|
|
332
|
-
<div class="${a}__item__footer ${a}__item__footer__${S?"":"hide"}">
|
|
333
|
-
${S??""}
|
|
334
|
-
</div>
|
|
335
|
-
</div>`}catch(P){console.error(P)}}function h(){Ge.isChromeForIos?(l(),window.print()):Ge.isSafari?(l(),document.execCommand("print",!1)):window.print()}const f=t.getSelectedShapeIds(),p=t.getCurrentPageId(),g=t.getPages(),v={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(t.getSelectedShapeIds().length>0){const y=await t.getSvgString(f,v);if(y){const S=g.find(b=>b.id===p);u(`tldraw — ${S==null?void 0:S.name}`,null,y.svg),h()}}else{const y=t.getCurrentPage(),S=await t.getSvgString(t.getSortedChildIdsForParent(y.id),v);S&&(u(`tldraw — ${y.name}`,null,S.svg),h())}window.removeEventListener("beforeprint",l),window.removeEventListener("afterprint",c)},[t])}function I1(){const{addToast:t,removeToast:e,clearToasts:n}=To(),{addDialog:r,clearDialogs:s,removeDialog:o}=Ed(),i=Ee(),a=Eae(),l=kae(),{cut:c,copy:u,paste:h}=tae(),f=Pae(),p=Iae(),g=v1(),v=An()<St.TABLET_SM;return w.useMemo(()=>({addToast:t,removeToast:e,clearToasts:n,addDialog:r,removeDialog:o,clearDialogs:s,msg:i,isMobile:v,insertMedia:a,printSelectionOrPages:l,cut:c,copy:u,paste:h,copyAs:f,exportAs:p,getEmbedDefinition:g}),[t,e,n,r,o,s,i,v,a,l,c,u,h,f,p,g])}function Tae(t,e){const n={};for(const r of t)if(r.translations)for(const[s,o]of Xn(r.translations)){let i=n[s];i||(i=n[s]={}),Object.assign(i,o)}return{actions:(r,s,o)=>{for(const i of t)i.actions&&(s=i.actions(r,s,o));return s},tools:(r,s,o)=>{for(const i of t)i.tools&&(s=i.tools(r,s,{...e,...o}));return s},translations:n}}function U$(t){return w.useMemo(()=>t,t)}function Mae(t){const e=U$(t==null?[]:Array.isArray(t)?t:[t]);return w.useMemo(()=>{const n={};for(const r of e)if(r.translations)for(const[s,o]of Xn(r.translations)){let i=n[s];i||(i=n[s]={}),Object.assign(i,o)}return n},[e])}function Aae(t){const e=I1(),n=U$(t==null?[]:Array.isArray(t)?t:[t]);return w.useMemo(()=>Tae(n,e),[n,e])}const H$=w.createContext(null);function jae(t){return Object.fromEntries(t.map(e=>[e.id,e]))}function Ua(t,e){if(t.getSelectedShapes().length===0)return t.getDocumentSettings().name||e}function Oae({overrides:t,children:e}){const n=z(),r=gm(),s=I1(),o=Jt(),i=s.msg("document.default-name"),a=w.useMemo(()=>{function l(){return n.isIn("select")||(n.complete(),n.setCurrentTool("select")),!1}function c(){return n.isIn("select")&&n.getSelectedShapeIds().length>0}const u=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(f){c()&&(l()||(o("edit-link",{source:f}),n.markHistoryStoppingPoint("edit-link"),s.addDialog({component:Goe})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(f){o("insert-embed",{source:f}),s.addDialog({component:y$})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(f){o("insert-media",{source:f}),s.insertMedia()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(f){o("undo",{source:f}),n.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(f){o("redo",{source:f}),n.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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("export-as",{format:"svg",source:f}),s.exportAs(p,"svg",Ua(n,i)))}},{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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("export-as",{format:"png",source:f}),s.exportAs(p,"png",Ua(n,i)))}},{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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("export-as",{format:"json",source:f}),s.exportAs(p,"json",Ua(n,i)))}},{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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("export-all-as",{format:"svg",source:f}),s.exportAs(Array.from(n.getCurrentPageShapeIds()),"svg",Ua(n,i)))}},{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(f){const p=Array.from(n.getCurrentPageShapeIds().values());p.length!==0&&(o("export-all-as",{format:"png",source:f}),s.exportAs(p,"png",Ua(n,i)))}},{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(f){const p=Array.from(n.getCurrentPageShapeIds().values());p.length!==0&&(o("export-all-as",{format:"json",source:f}),s.exportAs(p,"json",Ua(n,i)))}},{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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("copy-as",{format:"svg",source:f}),s.copyAs(p,"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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("copy-as",{format:"png",source:f}),s.copyAs(p,"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(f){let p=n.getSelectedShapeIds();p.length===0&&(p=Array.from(n.getCurrentPageShapeIds().values())),p.length!==0&&(o("copy-as",{format:"json",source:f}),s.copyAs(p,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(f){if(!c()||l())return;o("toggle-auto-size",{source:f}),n.markHistoryStoppingPoint("toggling auto size");const p=n.getSelectedShapes().filter(g=>n.isShapeOfType(g,"text")&&g.props.autoSize===!1);n.updateShapes(p.map(g=>({id:g.id,type:g.type,props:{...g.props,w:8,autoSize:!0}}))),Xe(n,p.map(g=>g.id))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(f){o("open-embed-link",{source:f});const p=n.getSelectedShapeIds(),g="No embed shapes selected";if(p.length!==1){console.error(g);return}const m=n.getShape(p[0]);if(!m||!n.isShapeOfType(m,"embed")){console.error(g);return}vte(m.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(f){var p,g;if(((p=n.root.getCurrent())==null?void 0:p.id)!=="zoom"&&(o("zoom-tool",{source:f}),!(n.inputs.shiftKey||n.inputs.ctrlKey))){const m=n.root.getCurrent();m&&((g=m.getCurrent())==null?void 0:g.id)==="idle"&&n.setCurrentTool("zoom",{onInteractionEnd:m.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(f){c()&&(l()||n.run(()=>{o("convert-to-bookmark",{source:f});const p=n.getSelectedShapes(),g=[],m=[];for(const v of p){if(!v||!n.isShapeOfType(v,"embed")||!v.props.url)continue;const y=new x(v.x,v.y);y.rot(-v.rotation),y.add(new x(v.props.w/2-300/2,v.props.h/2-320/2)),y.rot(v.rotation);const S={id:Ke(),type:"bookmark",rotation:v.rotation,x:y.x,y:y.y,opacity:1,props:{url:v.props.url}};g.push(S),m.push(v.id)}n.markHistoryStoppingPoint("convert shapes to bookmark"),n.deleteShapes(m),n.createShapes(g)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(f){c()&&(l()||(o("convert-to-embed",{source:f}),n.run(()=>{const p=n.getSelectedShapeIds(),g=me(p.map(y=>n.getShape(y))),m=[],v=[];for(const y of g){if(!n.isShapeOfType(y,"bookmark"))continue;const{url:S}=y.props,b=s.getEmbedDefinition(S);if(!b||!b.definition)continue;const{width:P,height:C}=b.definition,_=new x(y.x,y.y);_.rot(-y.rotation),_.add(new x(y.props.w/2-P/2,y.props.h/2-C/2)),_.rot(y.rotation);const E={id:Ke(),type:"embed",x:_.x,y:_.y,rotation:y.rotation,props:{url:S,w:P,h:C}};m.push(E),v.push(y.id)}n.markHistoryStoppingPoint("convert shapes to embed"),n.deleteShapes(v),n.createShapes(m)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(f){if(!c()||l())return;o("duplicate-shapes",{source:f});const p=n.getInstanceState();let g,m;if(p.duplicateProps)g=p.duplicateProps.shapeIds,m=p.duplicateProps.offset;else{g=n.getSelectedShapeIds();const v=Z.Common(me(g.map(y=>n.getShapePageBounds(y))));m=n.getCameraOptions().isLocked?{x:n.options.adjacentShapeMargin,y:n.options.adjacentShapeMargin}:{x:v.width+n.options.adjacentShapeMargin,y:0}}n.markHistoryStoppingPoint("duplicate shapes"),n.duplicateShapes(g,m),p.duplicateProps&&n.updateInstanceState({duplicateProps:{...p.duplicateProps,shapeIds:n.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(f){c()&&(l()||(o("ungroup-shapes",{source:f}),n.markHistoryStoppingPoint("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(f){if(!c()||l())return;o("group-shapes",{source:f});const p=n.getOnlySelectedShape();p&&n.isShapeOfType(p,"group")?(n.markHistoryStoppingPoint("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())):(n.markHistoryStoppingPoint("group"),n.groupShapes(n.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(f){if(!c())return;o("remove-frame",{source:f});const p=n.getSelectedShapes();p.length>0&&p.every(g=>n.isShapeOfType(g,"frame"))&&(n.markHistoryStoppingPoint("remove-frame"),_oe(n,p.map(g=>g.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(f){if(!c())return;o("fit-frame-to-content",{source:f});const p=n.getOnlySelectedShape();p&&n.isShapeOfType(p,"frame")&&(n.markHistoryStoppingPoint("fit-frame-to-content"),Eoe(n,p.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"left",source:f}),n.markHistoryStoppingPoint("align left");const p=n.getSelectedShapeIds();n.alignShapes(p,"left"),Xe(n,p)}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"center-horizontal",source:f}),n.markHistoryStoppingPoint("align center horizontal");const p=n.getSelectedShapeIds();n.alignShapes(p,"center-horizontal"),Xe(n,p)}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"right",source:f}),n.markHistoryStoppingPoint("align right");const p=n.getSelectedShapeIds();n.alignShapes(p,"right"),Xe(n,p)}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"center-vertical",source:f}),n.markHistoryStoppingPoint("align center vertical");const p=n.getSelectedShapeIds();n.alignShapes(p,"center-vertical"),Xe(n,p)}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"top",source:f}),n.markHistoryStoppingPoint("align top");const p=n.getSelectedShapeIds();n.alignShapes(p,"top"),Xe(n,p)}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(f){if(!c()||l())return;o("align-shapes",{operation:"bottom",source:f}),n.markHistoryStoppingPoint("align bottom");const p=n.getSelectedShapeIds();n.alignShapes(p,"bottom"),Xe(n,p)}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(f){if(!c()||l())return;o("distribute-shapes",{operation:"horizontal",source:f}),n.markHistoryStoppingPoint("distribute horizontal");const p=n.getSelectedShapeIds();n.distributeShapes(p,"horizontal"),Xe(n,p)}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(f){if(!c()||l())return;o("distribute-shapes",{operation:"vertical",source:f}),n.markHistoryStoppingPoint("distribute vertical");const p=n.getSelectedShapeIds();n.distributeShapes(p,"vertical"),Xe(n,p)}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(f){if(!c()||l())return;o("stretch-shapes",{operation:"horizontal",source:f}),n.markHistoryStoppingPoint("stretch horizontal");const p=n.getSelectedShapeIds();n.stretchShapes(p,"horizontal"),Xe(n,p)}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(f){if(!c()||l())return;o("stretch-shapes",{operation:"vertical",source:f}),n.markHistoryStoppingPoint("stretch vertical");const p=n.getSelectedShapeIds();n.stretchShapes(p,"vertical"),Xe(n,p)}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(f){if(!c()||l())return;o("flip-shapes",{operation:"horizontal",source:f}),n.markHistoryStoppingPoint("flip horizontal");const p=n.getSelectedShapeIds();n.flipShapes(p,"horizontal"),Xe(n,p)}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(f){if(!c()||l())return;o("flip-shapes",{operation:"vertical",source:f}),n.markHistoryStoppingPoint("flip vertical");const p=n.getSelectedShapeIds();n.flipShapes(p,"vertical"),Xe(n,p)}},{id:"pack",label:"action.pack",icon:"pack",onSelect(f){if(!c()||l())return;o("pack-shapes",{source:f}),n.markHistoryStoppingPoint("pack");const p=n.getSelectedShapeIds();n.packShapes(p,n.options.adjacentShapeMargin),Xe(n,p)}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(f){if(!c()||l())return;o("stack-shapes",{operation:"vertical",source:f}),n.markHistoryStoppingPoint("stack-vertical");const p=n.getSelectedShapeIds();n.stackShapes(p,"vertical",16),Xe(n,p)}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(f){if(!c()||l())return;o("stack-shapes",{operation:"horizontal",source:f}),n.markHistoryStoppingPoint("stack-horizontal");const p=n.getSelectedShapeIds();n.stackShapes(p,"horizontal",16),Xe(n,p)}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(f){c()&&(l()||(o("reorder-shapes",{operation:"toFront",source:f}),n.markHistoryStoppingPoint("bring to front"),n.bringToFront(n.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(f){c()&&(l()||(o("reorder-shapes",{operation:"forward",source:f}),n.markHistoryStoppingPoint("bring forward"),n.bringForward(n.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(f){c()&&(l()||(o("reorder-shapes",{operation:"backward",source:f}),n.markHistoryStoppingPoint("send backward"),n.sendBackward(n.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(f){c()&&(l()||(o("reorder-shapes",{operation:"toBack",source:f}),n.markHistoryStoppingPoint("send to back"),n.sendToBack(n.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(f){c()&&(l()||(n.markHistoryStoppingPoint("cut"),s.cut(f)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(f){c()&&(l()||s.copy(f))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(f){var p;(p=navigator.clipboard)==null||p.read().then(g=>{s.paste(g,f,f==="context-menu"?n.inputs.currentPagePoint:void 0)}).catch(()=>{s.addToast({title:s.msg("action.paste-error-title"),description:s.msg("action.paste-error-description"),severity:"error"})})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(f){n.run(()=>{l()||(o("select-all-shapes",{source:f}),n.markHistoryStoppingPoint("select all kbd"),n.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(f){c()&&(l()||(o("select-none-shapes",{source:f}),n.markHistoryStoppingPoint("select none"),n.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(f){c()&&(l()||(o("delete-shapes",{source:f}),n.markHistoryStoppingPoint("delete"),n.deleteShapes(n.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(f){if(!c()||l())return;o("rotate-cw",{source:f}),n.markHistoryStoppingPoint("rotate-cw");const p=n.getSelectionRotation()%(Ze/2),g=di(p,0)||di(p,Ze/2),m=n.getSelectedShapeIds();n.rotateShapesBy(m,Ze/2-(g?0:p)),Xe(n,m)}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(f){if(!c()||l())return;o("rotate-ccw",{source:f}),n.markHistoryStoppingPoint("rotate-ccw");const p=n.getSelectionRotation()%(Ze/2),g=di(p,0),m=n.getSelectedShapeIds();n.rotateShapesBy(m,g?-(Ze/2):-p),Xe(n,m)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(f){o("zoom-in",{source:f}),n.zoomIn(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(f){o("zoom-out",{source:f}),n.zoomOut(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(f){o("reset-zoom",{source:f}),n.resetZoom(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(f){o("zoom-to-fit",{source:f}),n.zoomToFit({animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(f){c()&&(l()||(o("zoom-to-selection",{source:f}),n.zoomToSelection({animation:{duration:n.options.animationMediumMs}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(f){o("toggle-snap-mode",{source:f}),n.user.updateUserPreferences({isSnapMode:!n.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(f){const p=n.user.getIsDarkMode()?"light":"dark";o("color-scheme",{source:f,value:p}),n.user.updateUserPreferences({colorScheme:p})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(f){o("toggle-wrap-mode",{source:f}),n.user.updateUserPreferences({isWrapMode:!n.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(f){o("toggle-dynamic-size-mode",{source:f}),n.user.updateUserPreferences({isDynamicSizeMode:!n.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(f){o("toggle-paste-at-cursor",{source:f}),n.user.updateUserPreferences({isPasteAtCursorMode:!n.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(f){o("toggle-reduce-motion",{source:f}),n.user.updateUserPreferences({animationSpeed:n.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(f){o("toggle-edge-scrolling",{source:f}),n.user.updateUserPreferences({edgeScrollSpeed:n.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(f){o("toggle-transparent",{source:f}),n.updateInstanceState({exportBackground:!n.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(f){o("toggle-tool-lock",{source:f}),n.updateInstanceState({isToolLocked:!n.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(f){o("unlock-all",{source:f});const p=[];for(const g of n.getCurrentPageShapes())g.isLocked&&p.push({id:g.id,type:g.type,isLocked:!1});p.length>0&&n.updateShapes(p)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(f){n.timers.requestAnimationFrame(()=>{n.run(()=>{o("toggle-focus-mode",{source:f}),s.clearDialogs(),s.clearToasts(),n.updateInstanceState({isFocusMode:!n.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(f){o("toggle-grid-mode",{source:f}),n.updateInstanceState({isGridMode:!n.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(f){o("toggle-debug-mode",{source:f}),n.updateInstanceState({isDebugMode:!n.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(f){o("print",{source:f}),s.printSelectionOrPages()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(f){o("exit-pen-mode",{source:f}),n.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(f){o("stop-following",{source:f}),n.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(f){o("zoom-to-content",{source:f});const p=n.getSelectionPageBounds()??n.getCurrentPageBounds();p&&n.zoomToBounds(p,{targetZoom:Math.min(1,n.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(f){n.markHistoryStoppingPoint("locking"),o("toggle-lock",{source:f}),n.toggleLock(n.getSelectedShapeIds())}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(f){const p=yr.createId(),g=n.getSelectedShapeIds();n.run(()=>{n.markHistoryStoppingPoint("move_shapes_to_page"),n.createPage({name:s.msg("page-menu.new-page-initial-name"),id:p}),n.moveShapesToPage(g,p)}),o("move-to-new-page",{source:f})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(f){const p=mr;n.run(()=>{n.markHistoryStoppingPoint("change-color"),n.isIn("select")&&n.setStyleForSelectedShapes(p,"white"),n.setStyleForNextShapes(p,"white")}),o("set-style",{source:f,id:p.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"?f",onSelect(f){const p=da;n.run(()=>{n.markHistoryStoppingPoint("change-fill"),n.isIn("select")&&n.setStyleForSelectedShapes(p,"fill"),n.setStyleForNextShapes(p,"fill")}),o("set-style",{source:f,id:p.id,value:"fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"!f",onSelect:async f=>{const p=n.getSelectedShapeIds();if(p.length===0)return;n.markHistoryStoppingPoint("flattening to image"),o("flatten-to-image",{source:f});const g=await eie(n,p,n.options.flattenImageBoundsExpand);g!=null&&g.length&&n.setSelectedShapes(g)}}];r&&u.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(f){o("open-cursor-chat",{source:f}),!n.getInstanceState().isCoarsePointer&&n.timers.requestAnimationFrame(()=>{n.updateInstanceState({isChatting:!0})})}});const h=jae(u);return t?t(n,h,s):h},[s,n,o,t,i,r]);return d.jsx(H$.Provider,{value:a,children:e})}function ka(){const t=w.useContext(H$);if(!t)throw new Error("useTools must be used within a ToolProvider");return t}function Xu(t,e){return t?typeof t=="string"?t:e?t[e]??t.default:void 0:void 0}function wr(){const t=Ti();return U("isReadonlyMode",()=>!!(t!=null&&t.getIsReadonly()),[t])}const Dae=Ge.isDarwin?"⌘":"Ctrl",Rae=Ge.isDarwin?"⌥":"Alt";function K$(t){return t===","?[","]:t.split(",")[0].split("").map(e=>{const n=e.replace(/\$/g,Dae).replace(/\?/g,Rae).replace(/!/g,"⇧");return n[0].toUpperCase()+n.slice(1)})}function Xx(t){return"— "+K$(t).join(" ")}function hu({children:t,visibleOnMobileLayout:e=!1}){const n=An();return!e&&n<St.MOBILE?null:d.jsx("kbd",{className:"tlui-kbd",children:K$(t).map((r,s)=>d.jsx("span",{children:r},s))})}const W$=w.createContext(null);function Sm(){const t=w.useContext(W$);if(!t)throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return t}function Fr({type:t,sourceId:e,children:n}){return d.jsx(W$.Provider,{value:{type:t,sourceId:e},children:n})}function vm({id:t,kbd:e,label:n,readonlyOk:r,onSelect:s,toggle:o=!1,disabled:i=!1,checked:a=!1}){const{type:l,sourceId:c}=Sm(),u=wr(),h=Ee();if(u&&!r)return null;const f=Xu(n,l),p=f?h(f):void 0;switch(l){case"menu":return d.jsxs(woe,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:p,onSelect:g=>{s==null||s(c),xe(g)},disabled:i,checked:a,children:[d.jsx(zs,{small:!0,icon:o?a?"toggle-on":"toggle-off":a?"check":"none"}),p&&d.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),e&&d.jsx(hu,{children:e})]});case"context-menu":return d.jsxs(Zse,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:p,onSelect:g=>{s(c),xe(g)},disabled:i,checked:a,children:[d.jsx(zs,{small:!0,icon:o?a?"toggle-on":"toggle-off":a?"check":"none"}),p&&d.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),e&&d.jsx(hu,{children:e})]},t);default:return null}}function Mo(t,e){const n=Ti(),r=w.useCallback(i=>{i&&(n==null||n.complete()),e==null||e(i)},[n,e]),s=Jt(),o=w.useCallback(i=>{s(i,{source:"unknown",id:t})},[t,s]);return dte(n?`${t}-${n.contextId}`:t,r,o)}function ma({id:t,children:e,modal:n=!1,debugOpen:r=!1}){const[s,o]=Mo(t);return d.jsx(c1,{open:r||s,dir:"ltr",modal:n,onOpenChange:o,children:e})}function ya({children:t,...e}){return d.jsx(u1,{dir:"ltr",asChild:!0,onTouchEnd:n=>xe(n),...e,children:t})}function Sa({className:t,side:e="bottom",align:n="start",sideOffset:r=8,alignOffset:s=8,children:o}){const i=Tt();return d.jsx(um,{container:i,children:d.jsx(d1,{className:ce("tlui-menu",t),side:e,sideOffset:r,align:n,alignOffset:s,collisionPadding:4,children:o})})}function Lae({id:t,children:e}){const[n,r]=Mo(t);return d.jsx(boe,{open:n,onOpenChange:r,children:e})}function $ae({id:t,label:e,title:n,disabled:r}){return d.jsx(Poe,{dir:"ltr",asChild:!0,disabled:r,children:d.jsxs(ue,{"data-testid":t,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:n,children:[d.jsx(bt,{children:e}),d.jsx(be,{icon:"chevron-right",small:!0})]})})}function Fae({id:t,alignOffset:e=-1,sideOffset:n=-6,size:r="small",children:s}){const o=Tt();return d.jsx(um,{container:o,children:d.jsx(Coe,{"data-testid":t,className:"tlui-menu tlui-menu__submenu__content",alignOffset:e,sideOffset:n,collisionPadding:4,"data-size":r,children:s})})}function Nae({children:t}){return d.jsx(voe,{dir:"ltr",className:"tlui-menu__group",children:t})}function qu({noClose:t,children:e}){return d.jsx(xoe,{dir:"ltr",asChild:!0,onClick:t?xe:void 0,children:e})}function ve({id:t,label:e,children:n}){const{type:r,sourceId:s}=Sm(),o=Ee(),i=Xu(e,r),a=i?o(i):void 0;switch(r){case"panel":return d.jsx("div",{className:"tlui-menu__group","data-testid":`${s}-group.${t}`,children:n});case"menu":return d.jsx(Nae,{"data-testid":`${s}-group.${t}`,children:n});case"context-menu":return d.jsx(DL,{dir:"ltr",className:"tlui-menu__group","data-testid":`${s}-group.${t}`,children:n});case"keyboard-shortcuts":return d.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${s}-group.${t}`,children:[d.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),d.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:n})]});default:return n}}function Jn({id:t,disabled:e=!1,label:n,size:r="small",children:s}){const{type:o,sourceId:i}=Sm(),a=Tt(),l=Ee(),c=n?typeof n=="string"?n:n[o]??n.default:void 0,u=c?l(c):void 0;switch(o){case"menu":return d.jsxs(Lae,{id:`${i}-sub.${t}`,children:[d.jsx($ae,{id:`${i}-sub.${t}-button`,disabled:e,label:u,title:u}),d.jsx(Fae,{id:`${i}-sub.${t}-content`,size:r,children:s})]});case"context-menu":return e?null:d.jsxs(zae,{id:`${i}-sub.${t}`,children:[d.jsx(FL,{dir:"ltr",disabled:e,asChild:!0,children:d.jsxs(ue,{"data-testid":`${i}-sub.${t}-button`,type:"menu",className:"tlui-menu__submenu__trigger",children:[d.jsx(bt,{children:u}),d.jsx(be,{icon:"chevron-right",small:!0})]})}),d.jsx(a1,{container:a,children:d.jsx(NL,{"data-testid":`${i}-sub.${t}-content`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":r,children:s})})]});default:return s}}function zae({id:t,children:e}){const[n,r]=Mo(t);return d.jsx($L,{open:n,onOpenChange:r,children:e})}const Bae=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function Uae(){const t=z(),e=Jt(),n=U("colorScheme",()=>t.user.getUserPreferences().colorScheme??(t.user.getIsDarkMode()?"dark":"light"),[t]);return d.jsx(Jn,{id:"help menu color-scheme",label:"menu.theme",children:d.jsx(ve,{id:"theme",children:Bae.map(({colorScheme:r,label:s})=>d.jsx(vm,{id:`color-scheme-${r}`,label:s,checked:r===n,readonlyOk:!0,onSelect:()=>{t.user.updateUserPreferences({colorScheme:r}),e("color-scheme",{source:"menu",value:r})}},r))})})}const Hae=({id:t,component:e,onClose:n})=>{const{removeDialog:r}=Ed(),s=Tt(),o=w.useCallback(i=>{if(!i){if(n)try{n()}catch(a){console.warn(a)}r(t)}},[t,n,r]);return d.jsx(Uoe,{onOpenChange:o,defaultOpen:!0,children:d.jsx(Hoe,{container:s,children:d.jsx(Koe,{dir:"ltr",className:"tlui-dialog__overlay",onClick:i=>{i.target===i.currentTarget&&o(!1)},children:d.jsx(Woe,{dir:"ltr",className:"tlui-dialog__content","aria-describedby":void 0,children:d.jsx(e,{onClose:()=>o(!1)})})})})})},Kae=w.memo(function(){const{dialogs:e}=Ed();return U("dialogs",()=>e.get(),[e]).map(r=>d.jsx(Hae,{...r},r.id))}),Wae=4e3,Gae={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function Vae({toast:t}){const{removeToast:e}=To(),n=Ee(),r=i=>{i||e(t.id)},s=t.actions&&t.actions.length>0,o=t.icon||t.severity&&Gae[t.severity];return d.jsxs(bie,{onOpenChange:r,className:"tlui-toast__container",duration:t.keepOpen?1/0:Wae,"data-severity":t.severity,children:[o&&d.jsx("div",{className:"tlui-toast__icon",children:d.jsx(zs,{icon:o})}),d.jsxs("div",{className:"tlui-toast__main","data-title":!!t.title,"data-description":!!t.description,"data-actions":!!t.actions,children:[d.jsxs("div",{className:"tlui-toast__content",children:[t.title&&d.jsx(Pie,{className:"tlui-toast__title",children:t.title}),t.description&&d.jsx(Cie,{className:"tlui-toast__description",children:t.description})]}),t.actions&&d.jsxs("div",{className:"tlui-toast__actions",children:[t.actions.map((i,a)=>d.jsx(_ie,{altText:i.label,asChild:!0,onClick:i.onClick,children:d.jsx(ue,{type:i.type,children:d.jsx(bt,{children:i.label})})},a)),d.jsx(yE,{asChild:!0,children:d.jsx(ue,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:d.jsx(bt,{children:t.closeLabel??n("toast.close")})})})]})]}),!s&&d.jsx(yE,{asChild:!0,children:d.jsx(ue,{type:"normal",className:"tlui-toast__close",children:d.jsx(bt,{children:t.closeLabel??n("toast.close")})})})]})}const Yae=w.memo(function(){const{toasts:e}=To(),n=U("toasts",()=>e.get(),[]);return d.jsxs(d.Fragment,{children:[n.map(r=>d.jsx(Vae,{toast:r},r.id)),d.jsx(P$,{className:"tlui-toast__viewport"})]})});function fs({actionId:t="",...e}){const r=ka()[t];return r?d.jsx(vm,{...r,...e}):null}function PE(t){return d.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...t,children:d.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[d.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),d.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:d.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}function Kt({disabled:t=!1,spinner:e=!1,readonlyOk:n=!1,id:r,kbd:s,label:o,icon:i,onSelect:a,noClose:l,isSelected:c}){const{type:u,sourceId:h}=Sm(),f=Ee(),[p,g]=w.useState(!1);if(wr()&&!n)return null;const v=Xu(o,u),y=s?Xx(s):void 0,S=v?f(v):void 0,b=S&&y?`${S} ${y}`:S;switch(u){case"menu":return d.jsx(qu,{children:d.jsxs(ue,{type:"menu","data-testid":`${h}.${r}`,disabled:t,title:b,onClick:P=>{l&&xe(P),p?g(!1):a(h)},children:[d.jsx(bt,{children:S}),s&&d.jsx(hu,{children:s})]})});case"context-menu":return t?null:d.jsxs(RL,{dir:"ltr",title:b,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${h}.${r}`,onSelect:P=>{l&&xe(P),p?g(!1):a(h)},children:[d.jsx("span",{className:"tlui-button__label",draggable:!1,children:S}),s&&d.jsx(hu,{children:s}),e&&d.jsx(PE,{})]});case"panel":return d.jsxs(ue,{"data-testid":`${h}.${r}`,type:"menu",title:b,disabled:t,onClick:()=>a(h),children:[d.jsx(bt,{children:S}),e?d.jsx(PE,{}):i&&d.jsx(be,{icon:i})]});case"small-icons":case"icons":return d.jsx(ue,{"data-testid":`${h}.${r}`,type:"icon",title:b,disabled:t,onClick:()=>a(h),children:d.jsx(be,{icon:i,small:u==="small-icons"})});case"keyboard-shortcuts":return s?d.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${h}.${r}`,children:[d.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:S}),d.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:d.jsx(hu,{visibleOnMobileLayout:!0,children:s})})]}):(console.warn(`Menu item '${o}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return d.jsxs(ue,{type:"low",onClick:()=>a(h),children:[d.jsx(be,{icon:i}),d.jsx(bt,{children:S})]});case"toolbar":return d.jsx(ue,{type:"tool","data-testid":`tools.${r}`,"aria-label":v,"data-value":r,onClick:()=>a("toolbar"),title:b,disabled:t,onTouchStart:P=>{xe(P),a("toolbar")},role:"radio","aria-checked":c?"true":"false",children:d.jsx(be,{icon:i})});case"toolbar-overflow":return d.jsx(qu,{"aria-label":o,children:d.jsx(ue,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${r}`,title:b,disabled:t,role:"radio","aria-checked":c?"true":"false","data-value":r,children:d.jsx(be,{icon:i})})});default:throw Ot(u)}}function W({actionId:t="",...e}){const r=ka()[t];return r?d.jsx(Kt,{...r,...e}):null}const G$=w.createContext(null);function Xae({overrides:t,children:e}){const n=z(),r=Jt(),s=I1(),o=w.useMemo(()=>{const i=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(l){if(n.isIn("select")){const c=n.root.getCurrent();c.exit({},c.id),c.enter({},c.id)}n.setCurrentTool("select"),r("select-tool",{source:l,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(l){n.setCurrentTool("hand"),r("select-tool",{source:l,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(l){n.setCurrentTool("eraser"),r("select-tool",{source:l,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(l){n.setCurrentTool("draw"),r("select-tool",{source:l,id:"draw"})}},...[...Jr.values].map(l=>({id:l,label:`tool.${l}`,meta:{geo:l},kbd:l==="rectangle"?"r":l==="ellipse"?"o":void 0,icon:"geo-"+l,onSelect(c){n.run(()=>{n.setStyleForNextShapes(Jr,l),n.setCurrentTool("geo"),r("select-tool",{source:c,id:`geo-${l}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(l){n.setCurrentTool("arrow"),r("select-tool",{source:l,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(l){n.setCurrentTool("line"),r("select-tool",{source:l,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(l){n.setCurrentTool("frame"),r("select-tool",{source:l,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(l){n.setCurrentTool("text"),r("select-tool",{source:l,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(l){s.insertMedia(),r("select-tool",{source:l,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(l){n.setCurrentTool("note"),r("select-tool",{source:l,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(l){n.setCurrentTool("laser"),r("select-tool",{source:l,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(l){s.addDialog({component:y$}),r("select-tool",{source:l,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(l){n.setCurrentTool("highlight"),r("select-tool",{source:l,id:"highlight"})}}];i.push();const a=Object.fromEntries(i.map(l=>[l.id,l]));return t?t(n,a,s):a},[t,n,r,s]);return d.jsx(G$.Provider,{value:o,children:e})}function E1(){const t=w.useContext(G$);if(!t)throw new Error("useTools must be used within a ToolProvider");return t}function Ln({toolId:t="",...e}){const r=E1()[t];return r?d.jsx(Kt,{...r,...e}):null}function qae({children:t}){const e=z();return U("shouldDisplayHandles",()=>{if(e.isInAny("select.idle","select.pointing_handle","select.pointing_shape"))return!0;if(e.isInAny("select.editing_shape")){const r=e.getOnlySelectedShape();return r&&e.isShapeOfType(r,"note")}return!1},[e])?d.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:t}):null}const{PI:Zae}=Math,_l=Zae+1e-4;function V$(t,e={}){const{size:n=16,smoothing:r=.5}=e;if(t.length===0||n<=0)return{left:[],right:[]};const s=t[0],o=t[t.length-1],i=o.runningLength,a=Math.pow(n*r,2),l=[],c=[];let u=t[0].vector,h=t[0].point,f=h,p=h,g=f,m=!1,v;for(let y=0;y<t.length;y++){v=t[y];const{point:S,vector:b}=t[y],P=v.vector.dpr(u),C=(y<t.length-1?t[y+1]:t[y]).vector,_=y<t.length-1?C.dpr(v.vector):1,E=P<0&&!m,k=_!==null&&_<.2;if(E||k){if(_>-.62&&i-v.runningLength>v.radius){const T=u.clone().mul(v.radius);u.clone().cpr(C)<0?(p=x.Add(S,T),g=x.Sub(S,T)):(p=x.Sub(S,T),g=x.Add(S,T)),l.push(p),c.push(g)}else{const T=u.clone().mul(v.radius).per(),j=x.Sub(v.input,T);for(let L=1/13,M=0;M<1;M+=L)p=x.RotWith(j,v.input,_l*M),l.push(p),g=x.RotWith(j,v.input,_l+_l*-M),c.push(g)}h=p,f=g,k&&(m=!0);continue}if(m=!1,v===s||v===o){const T=x.Per(b).mul(v.radius);l.push(x.Sub(S,T)),c.push(x.Add(S,T));continue}const D=x.Lrp(C,b,_).per().mul(v.radius);p=x.Sub(S,D),(y<=1||x.Dist2(h,p)>a)&&(l.push(p),h=p),g=x.Add(S,D),(y<=1||x.Dist2(f,g)>a)&&(c.push(g),f=g),u=b}return{left:l,right:c}}function k1(t,e={}){const{size:n=16,start:r={},end:s={},last:o=!1}=e,{cap:i=!0}=r,{cap:a=!0}=s;if(t.length===0||n<=0)return[];const l=t[0],c=t[t.length-1],u=c.runningLength,h=r.taper===!1?0:r.taper===!0?Math.max(n,u):r.taper,f=s.taper===!1?0:s.taper===!0?Math.max(n,u):s.taper,{left:p,right:g}=V$(t,e),m=l.point,v=t.length>1?t[t.length-1].point:x.AddXY(l.point,1,1);if(t.length===1&&(!(h||f)||o)){const P=x.Add(m,x.Sub(m,v).uni().per().mul(-l.radius)),C=[];for(let _=1/13,E=_;E<=1;E+=_)C.push(x.RotWith(P,m,_l*2*E));return C}const y=[];if(!(h||f&&t.length===1))if(i)for(let P=1/8,C=P;C<=1;C+=P){const _=x.RotWith(g[0],m,_l*C);y.push(_)}else{const P=x.Sub(p[0],g[0]),C=x.Mul(P,.5),_=x.Mul(P,.51);y.push(x.Sub(m,C),x.Sub(m,_),x.Add(m,_),x.Add(m,C))}const S=[],b=c.vector.clone().per().neg();if(f||h&&t.length===1)S.push(v);else if(a){const P=x.Add(v,x.Mul(b,c.radius));for(let C=1/29,_=C;_<1;_+=C)S.push(x.RotWith(P,v,_l*3*_))}else S.push(x.Add(v,x.Mul(b,c.radius)),x.Add(v,x.Mul(b,c.radius*.99)),x.Sub(v,x.Mul(b,c.radius*.99)),x.Sub(v,x.Mul(b,c.radius)));return p.concat(S,g.reverse(),y)}const Qae=.025,Jae=.01;function Bs(t,e={}){var v;const{streamline:n=.5,size:r=16,simulatePressure:s=!1}=e;if(t.length===0)return[];const o=.15+(1-n)*.85;let i=t.map(x.From),a=0;if(!s){let y=i[0];for(;y&&!(y.z>=Qae);)i.shift(),y=i[0]}if(!s){let y=i[i.length-1];for(;y&&!(y.z>=Jae);)i.pop(),y=i[i.length-1]}if(i.length===0)return[{point:x.From(t[0]),input:x.From(t[0]),pressure:s?.5:.15,vector:new x(1,1),distance:0,runningLength:0,radius:1}];let l=i[1];for(;l&&!(x.Dist2(l,i[0])>(r/3)**2);)i[0].z=Math.max(i[0].z,l.z),i.splice(1,1),l=i[1];const c=i.pop();for(l=i[i.length-1];l&&!(x.Dist2(l,c)>(r/3)**2);)i.pop(),l=i[i.length-1],a++;i.push(c);const u=e.last||!e.simulatePressure||i.length>1&&x.Dist2(i[i.length-1],i[i.length-2])<r**2||a>0;if(i.length===2&&e.simulatePressure){const y=i[1];i=i.slice(0,-1);for(let S=1;S<5;S++){const b=x.Lrp(i[0],y,S/4);b.z=(i[0].z+(y.z-i[0].z))*S/4,i.push(b)}}const h=[{point:i[0],input:i[0],pressure:s?.5:i[0].z,vector:new x(1,1),distance:0,runningLength:0,radius:1}];let f=0,p=h[0],g,m;u&&n>0&&i.push(i[i.length-1].clone());for(let y=1,S=i.length;y<S;y++)g=!o||e.last&&y===S-1?i[y].clone():i[y].clone().lrp(p.point,1-o),!p.point.equals(g)&&(m=x.Dist(g,p.point),f+=m,!(y<4&&f<r)&&(p={input:i[y],point:g,pressure:s?.5:i[y].z,vector:x.Sub(p.point,g).uni(),distance:m,runningLength:f,radius:1},h.push(p)));if((v=h[1])!=null&&v.vector&&(h[0].vector=h[1].vector.clone()),f<1){const y=Math.max(.5,...h.map(S=>S.pressure));h.forEach(S=>S.pressure=y)}return h}const{min:zo}=Math,xS=.275;function xm(t,e){const{size:n=16,thinning:r=.5,simulatePressure:s=!0,easing:o=v=>v,start:i={},end:a={}}=e,{easing:l=Dt.easeOutQuad}=i,{easing:c=Dt.easeOutCubic}=a,u=t[t.length-1].runningLength;let h,f=t[0].pressure,p;if(!s&&u<n){const v=t.reduce((y,S)=>Math.max(y,S.pressure),.5);return t.forEach(y=>{y.pressure=v,y.radius=n*o(.5-r*(.5-y.pressure))}),t}else{let v;for(let y=0,S=t.length;y<S&&(p=t[y],!(p.runningLength>n*5));y++){const b=zo(1,p.distance/n);if(s){const P=zo(1,1-b);v=zo(1,f+(P-f)*(b*xS))}else v=zo(1,f+(p.pressure-f)*.5);f=f+(v-f)*.5}for(let y=0;y<t.length;y++){if(p=t[y],r){let{pressure:S}=p;const b=zo(1,p.distance/n);if(s){const P=zo(1,1-b);S=zo(1,f+(P-f)*(b*xS))}else S=zo(1,f+(S-f)*(b*xS));p.radius=n*o(.5-r*(.5-S)),f=S}else p.radius=n/2;h===void 0&&(h=p.radius)}}const g=i.taper===!1?0:i.taper===!0?Math.max(n,u):i.taper,m=a.taper===!1?0:a.taper===!0?Math.max(n,u):a.taper;if(g||m)for(let v=0;v<t.length;v++){p=t[v];const{runningLength:y}=p,S=y<g?l(y/g):1,b=u-y<m?c((u-y)/m):1;p.radius=Math.max(.01,p.radius*Math.min(S,b))}return t}function ele(t,e={}){return k1(xm(Bs(t,e),e),e)}function CE({scribble:t,zoom:e,color:n,opacity:r,className:s}){if(!t.points.length)return null;const o=ele(t.points,{size:t.size/e,start:{taper:t.taper,easing:Dt.linear},last:t.state==="stopping",simulatePressure:!1,streamline:.32});let i;if(o.length<4){const a=t.size/e/2,{x:l,y:c}=t.points[t.points.length-1];i=`M ${l-a},${c} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else i=Sb(o);return d.jsx("svg",{className:s&&ce("tl-overlays__item",s),children:d.jsx("path",{className:"tl-scribble",d:i,fill:n??`var(--color-${t.color})`,opacity:r??t.opacity})})}const tle=({bounds:t,rotation:e})=>{const n=z();return U("should display",()=>n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[n])?d.jsx(kj,{bounds:t,rotation:e}):null};function nle({size:t,width:e,height:n,hideAlternateHandles:r}){const s=N(t/3),o=s/2;return d.jsxs("svg",{className:"tl-overlays__item",children:[d.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
336
|
-
${N(0-o)},${N(t)}
|
|
337
|
-
${N(0-o)},${N(0-o)}
|
|
338
|
-
${N(t)},${N(0-o)}`,strokeWidth:s,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(e/2-t),y1:N(0-o),x2:N(e/2+t),y2:N(0-o),strokeWidth:s,"data-testid":"selection.crop.top","aria-label":"top handle"}),d.jsx("polyline",{className:ce("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
339
|
-
${N(e-t)},${N(0-o)}
|
|
340
|
-
${N(e+o)},${N(0-o)}
|
|
341
|
-
${N(e+o)},${N(t)}`,strokeWidth:s,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(e+o),y1:N(n/2-t),x2:N(e+o),y2:N(n/2+t),strokeWidth:s,"data-testid":"selection.crop.right","aria-label":"right handle"}),d.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
342
|
-
${N(e+o)},${N(n-t)}
|
|
343
|
-
${N(e+o)},${N(n+o)}
|
|
344
|
-
${N(e-t)},${N(n+o)}`,strokeWidth:s,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(e/2-t),y1:N(n+o),x2:N(e/2+t),y2:N(n+o),strokeWidth:s,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),d.jsx("polyline",{className:ce("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
345
|
-
${N(0+t)},${N(n+o)}
|
|
346
|
-
${N(0-o)},${N(n+o)}
|
|
347
|
-
${N(0-o)},${N(n-t)}`,strokeWidth:s,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(0-o),y1:N(n/2-t),x2:N(0-o),y2:N(n/2+t),strokeWidth:s,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const rle=Zt(function({bounds:e,rotation:n}){const r=z(),s=w.useRef(null),o=wr(),i=ws("top"),a=ws("right"),l=ws("bottom"),c=ws("left"),u=ws("top_left"),h=ws("top_right"),f=ws("bottom_right"),p=ws("bottom_left"),g=r.getInstanceState().cursor.type==="default",m=r.getInstanceState().isCoarsePointer,v=r.getOnlySelectedShape(),y=v&&r.isShapeOrAncestorLocked(v),S=v?r.getShapeUtil(v).expandSelectionOutlinePx(v):0,b=S instanceof Z?e.clone().expand(S).zeroFix():e.clone().expandBy(S).zeroFix();if(ec(s,e==null?void 0:e.x,e==null?void 0:e.y,1,r.getSelectionRotation(),{x:b.x-e.x,y:b.y-e.y}),v&&r.isShapeHidden(v))return null;const P=r.getZoomLevel(),C=r.getInstanceState().isChangingStyle,_=b.width,E=b.height,k=8/P,D=_<k*2,T=E<k*2,j=_<k*4,L=E<k*4,M=_<k*5,O=E<k*5,F=m?1.75:1,B=6/P*F,K=(j?B/2:B)*(F*.75),R=(L?B/2:B)*(F*.75),H=(v?!r.getShapeUtil(v).hideSelectionBoundsFg(v):!0)&&!C;let X=H&&r.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")||H&&r.isIn("select.resizing")&&v&&r.isShapeOfType(v,"text");v&&X&&Ge.isFirefox&&r.isShapeOfType(v,"embed")&&(X=!1);const te=r.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!C&&!o,le=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!C&&!o,de=!m&&!(D||T)&&(le||te)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!y,Me=m&&(!j||!L)&&(le||te)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!y,oe=le&&(v?r.getShapeUtil(v).canResize(v)&&!r.getShapeUtil(v).hideResizeHandles(v):!0)&&!te&&!y,Ue=D||T,Ne=D&&T,lt=M||O,$e=oe||te,Ye=!de,We=!le||!Me,er=!le||!$e,$t=!le||!$e||Ue,On=!le||!$e||Ue,Mt=!le||!$e||Ne&&!te;let Ft=!0,jo=!0;if(te)Ft=lt,jo=lt;else if(oe){Ft=Ue||Ne||m;const Mm=m&&v&&v.type==="text";jo=Ft&&!Mm}const Ys=Math.min(24/P,E-R*3),Oo=le&&m&&v&&r.isShapeOfType(v,"text")&&Ys*P>=4;return d.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:d.jsxs("g",{ref:s,children:[X&&d.jsx("rect",{className:"tl-selection__fg__outline",width:N(_),height:N(E)}),d.jsx(Rh,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:B,corner:"top_left_rotate",cursor:g?nr("nwse-rotate",n):void 0,isHidden:Ye}),d.jsx(Rh,{"data-testid":"selection.rotate.top-right",cx:_+B*3,cy:0,targetSize:B,corner:"top_right_rotate",cursor:g?nr("nesw-rotate",n):void 0,isHidden:Ye}),d.jsx(Rh,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:E+B*3,targetSize:B,corner:"bottom_left_rotate",cursor:g?nr("swne-rotate",n):void 0,isHidden:Ye}),d.jsx(Rh,{"data-testid":"selection.rotate.bottom-right",cx:_+B*3,cy:E+B*3,targetSize:B,corner:"bottom_right_rotate",cursor:g?nr("senw-rotate",n):void 0,isHidden:Ye}),d.jsx(ole,{"data-testid":"selection.rotate.mobile",cx:j?-B*1.5:_/2,cy:j?E/2:-B*1.5,size:k,isHidden:We}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Ft}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:N(0-(L?R*2:R)),width:N(_),height:N(Math.max(1,R*2)),style:g?{cursor:nr("ns-resize",n)}:void 0,...i}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":jo}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:N(_-(j?0:K)),y:0,height:N(E),width:N(Math.max(1,K*2)),style:g?{cursor:nr("ew-resize",n)}:void 0,...a}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Ft}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:N(E-(L?0:R)),width:N(_),height:N(Math.max(1,R*2)),style:g?{cursor:nr("ns-resize",n)}:void 0,...l}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":jo}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:N(0-(j?K*2:K)),y:0,height:N(E),width:N(Math.max(1,K*2)),style:g?{cursor:nr("ew-resize",n)}:void 0,...c}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":er}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:N(0-(j?K*2:K*1.5)),y:N(0-(L?R*2:R*1.5)),width:N(K*3),height:N(R*3),style:g?{cursor:nr("nwse-resize",n)}:void 0,...u}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":$t}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:N(_-(j?0:K*1.5)),y:N(0-(L?R*2:R*1.5)),width:N(K*3),height:N(R*3),style:g?{cursor:nr("nesw-resize",n)}:void 0,...h}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Mt}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:N(_-(j?K:K*1.5)),y:N(E-(L?R:R*1.5)),width:N(K*3),height:N(R*3),style:g?{cursor:nr("nwse-resize",n)}:void 0,...f}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":On}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:N(0-(j?K*3:K*1.5)),y:N(E-(L?0:R*1.5)),width:N(K*3),height:N(R*3),style:g?{cursor:nr("nesw-resize",n)}:void 0,...p}),oe&&d.jsxs(d.Fragment,{children:[d.jsx("rect",{"data-testid":"selection.resize.top-left",className:ce("tl-corner-handle",{"tl-hidden":er}),"aria-label":"top_left handle",x:N(0-k/2),y:N(0-k/2),width:N(k),height:N(k)}),d.jsx("rect",{"data-testid":"selection.resize.top-right",className:ce("tl-corner-handle",{"tl-hidden":$t}),"aria-label":"top_right handle",x:N(_-k/2),y:N(0-k/2),width:N(k),height:N(k)}),d.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:ce("tl-corner-handle",{"tl-hidden":Mt}),"aria-label":"bottom_right handle",x:N(_-k/2),y:N(E-k/2),width:N(k),height:N(k)}),d.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:ce("tl-corner-handle",{"tl-hidden":On}),"aria-label":"bottom_left handle",x:N(0-k/2),y:N(E-k/2),width:N(k),height:N(k)})]}),Oo&&d.jsxs(d.Fragment,{children:[d.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:N(0-k/4),y:N(E/2-Ys/2),rx:k/4,width:N(k/2),height:N(Ys)}),d.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:k/4,x:N(_-k/4),y:N(E/2-Ys/2),width:N(k/2),height:N(Ys)})]}),te&&d.jsx(nle,{size:k,width:_,height:E,hideAlternateHandles:lt})]})})}),Rh=function({cx:e,cy:n,targetSize:r,corner:s,cursor:o,isHidden:i,"data-testid":a}){const l=ws(s);return d.jsx("rect",{className:ce("tl-transparent","tl-rotate-corner",{"tl-hidden":i}),"data-testid":a,"aria-label":`${s} target`,pointerEvents:"all",x:N(e-r*3),y:N(n-r*3),width:N(Math.max(1,r*3)),height:N(Math.max(1,r*3)),cursor:o,...l})},sle=Math.sqrt(Math.PI),ole=function({cx:e,cy:n,size:r,isHidden:s,"data-testid":o}){const i=ws("mobile_rotate"),a=z(),l=U("zoom level",()=>a.getZoomLevel(),[a]),c=Math.max(14*(1/l),20/Math.max(1,l));return d.jsxs("g",{children:[d.jsx("circle",{"data-testid":o,pointerEvents:"all",className:ce("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":s}),cx:e,cy:n,r:c,...i}),d.jsx("circle",{className:ce("tl-mobile-rotate__fg",{"tl-hidden":s}),cx:e,cy:n,r:r/sle})]})};function ile(){const t=z();return U("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])?d.jsx(Tj,{}):null}function qx(t,e,n){const{arrowheadStart:r,arrowheadEnd:s}=e.props,o=dl(t,e,n),i=o.start.clone(),a=o.end.clone(),l=x.Med(i,a);if(x.Equals(i,a))return{bindings:n,isStraight:!0,start:{handle:i,point:i,arrowhead:e.props.arrowheadStart},end:{handle:a,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:!1,length:0};const c=x.Sub(a,i).uni(),u=Yp(t,e,"start"),h=Yp(t,e,"end"),f=t.getShapePageTransform(e);_E(a,o.start,f,h),_E(i,o.end,f,u);let p=0,g=0,m=0,v=0,y=fu*e.props.scale;const S=u&&h&&u.shape===h.shape,b=u&&h?T1(t,u.shape.id,h.shape.id):"safe";b==="safe"&&u&&h&&!S&&!u.isExact&&!h.isExact&&(h.didIntersect&&!u.didIntersect?u.isClosed&&i.setTo(a.clone().add(c.clone().mul(fu*e.props.scale))):h.didIntersect||h.isClosed&&a.setTo(i.clone().sub(c.clone().mul(fu*e.props.scale))));const P=x.Sub(a,i),C=x.Len(P)?P.uni():x.From(P),_=!x.Equals(C,c);S||(b!=="start-contains-end"&&u&&r!=="none"&&!u.isExact&&(m=ks[e.props.size]/2+("size"in u.shape.props?ks[u.shape.props.size]/2:0),p=(Xp+m)*e.props.scale,y+=m*e.props.scale),b!=="end-contains-start"&&h&&s!=="none"&&!h.isExact&&(v=ks[e.props.size]/2+("size"in h.shape.props?ks[h.shape.props.size]/2:0),g=(Xp+v)*e.props.scale,y+=v*e.props.scale));const E=i.clone().add(C.clone().mul(p*(_?-1:1))),k=a.clone().sub(C.clone().mul(g*(_?-1:1)));x.DistMin(E,k,y)&&(p!==0&&g!==0?(p*=-1.5,g*=-1.5):p!==0?p*=-1:g!==0&&(g*=-1)),i.add(C.clone().mul(p*(_?-1:1))),a.sub(C.clone().mul(g*(_?-1:1))),_?(u&&h&&a.setTo(x.Add(i,C.clone().mul(-10*e.props.scale))),l.setTo(x.Med(o.start,o.end))):l.setTo(x.Med(i,a));const D=x.Dist(i,a);return{bindings:n,isStraight:!0,start:{handle:o.start,point:i,arrowhead:e.props.arrowheadStart},end:{handle:o.end,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:D>0,length:D}}function _E(t,e,n,r){if(r===void 0||r.isExact)return;const s=q.applyToPoint(n,e),o=q.applyToPoint(n,t),i=q.applyToPoint(q.Inverse(r.transform),s),a=q.applyToPoint(q.Inverse(r.transform),o),l=r.isClosed,u=(l?Pb:YZ)(i,a,r.outline);let h;if(u!==null&&(h=u.sort((g,m)=>x.Dist2(g,i)-x.Dist2(m,i))[0]??(l?void 0:a)),h===void 0)return;const f=q.applyToPoint(r.transform,h),p=q.applyToPoint(q.Inverse(n),f);t.setTo(p),r.didIntersect=!0}function ale(t,e,n){const{arrowheadEnd:r,arrowheadStart:s}=e.props,o=e.props.bend;if(Math.abs(o)>Math.abs(e.props.bend*(hle*e.props.scale)))return qx(t,e,n);const i=dl(t,e,n),a=x.Med(i.start,i.end),l=x.Sub(i.end,i.start),c=x.Len(l)?l.uni():x.From(l),u=x.Add(a,c.per().mul(-o)),h=Yp(t,e,"start"),f=Yp(t,e,"end"),p=i.start.clone(),g=i.end.clone(),m=u.clone();if(x.Equals(p,g))return{bindings:n,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 v=e.props.bend<0,y=v?ud:lj,S=IE(p,g,m),b=x.Angle(S.center,p),P=x.Angle(S.center,g),C=y(b,P);if(S.length===0||S.size===0||!rI(S.length)||!rI(S.size))return qx(t,e,n);const _=p.clone(),E=g.clone(),k=m.clone(),D=t.getShapePageTransform(e);let T=0,j=0,L=fu*e.props.scale;if(h&&!h.isExact){const X=q.applyToPoint(D,_),te=q.applyToPoint(D,S.center),le=q.applyToPoint(D,E),de=q.Inverse(h.transform),Me=q.applyToPoint(de,X),oe=q.applyToPoint(de,te),Ue=q.applyToPoint(de,le),{isClosed:Ne}=h,lt=Ne?_x:CI;let $e,Ye=lt(oe,S.radius,h.outline);if(Ye){const We=oe.angle(Me),er=oe.angle(Ue),$t=y(We,er);Ye=Ye.filter(Mt=>y(We,oe.angle(Mt))<=$t);const On=$t*.25;Ye.sort(Ne?(Mt,Ft)=>Math.abs(y(We,oe.angle(Mt))-On)<Math.abs(y(We,oe.angle(Ft))-On)?-1:1:(Mt,Ft)=>y(We,oe.angle(Mt))<y(We,oe.angle(Ft))?-1:1),$e=Ye[0]??(Ne?void 0:Me)}else $e=Ne?void 0:Me;if($e&&(_.setTo(t.getPointInShapeSpace(e,q.applyToPoint(h.transform,$e))),h.didIntersect=!0,s!=="none")){const We=ks[e.props.size]/2+("size"in h.shape.props?ks[h.shape.props.size]/2:0);T=(Xp+We)*e.props.scale,L+=We*e.props.scale}}if(f&&!f.isExact){const X=q.applyToPoint(D,_),te=q.applyToPoint(D,E),le=q.applyToPoint(D,S.center),de=q.Inverse(f.transform),Me=q.applyToPoint(de,X),oe=q.applyToPoint(de,le),Ue=q.applyToPoint(de,te),Ne=f.isClosed,lt=Ne?_x:CI;let $e,Ye=lt(oe,S.radius,f.outline);if(Ye){const We=oe.angle(Me),er=oe.angle(Ue),$t=y(We,er),On=$t*.75;Ye=Ye.filter(Mt=>y(We,oe.angle(Mt))<=$t),Ye.sort(Ne?(Mt,Ft)=>Math.abs(y(We,oe.angle(Mt))-On)<Math.abs(y(We,oe.angle(Ft))-On)?-1:1:(Mt,Ft)=>y(We,oe.angle(Mt))<y(We,oe.angle(Ft))?-1:1),Ye[0]?$e=Ye[0]:$e=Ne?void 0:Ue}else $e=Ne?void 0:Ue;if($e&&(E.setTo(t.getPointInShapeSpace(e,q.applyToPoint(f.transform,$e))),f.didIntersect=!0,r!=="none")){const We=ks[e.props.size]/2+("size"in f.shape.props?ks[f.shape.props.size]/2:0);j=(Xp+We)*e.props.scale,L+=We*e.props.scale}}let M=x.Angle(S.center,_),O=x.Angle(S.center,E),F=y(M,O),B=F*S.radius;const K=_.clone(),R=E.clone();if(T!==0&&K.setTo(S.center).add(x.FromAngle(M+F*(T/B*(v?1:-1))).mul(S.radius)),j!==0&&R.setTo(S.center).add(x.FromAngle(O+F*(j/B*(v?-1:1))).mul(S.radius)),x.DistMin(K,R,L)&&(T!==0&&j!==0?(T*=-1.5,j*=-1.5):T!==0?T*=-2:j!==0&&(j*=-2)),T!==0&&_.setTo(S.center).add(x.FromAngle(M+F*(T/B*(v?1:-1))).mul(S.radius)),j!==0&&E.setTo(S.center).add(x.FromAngle(O+F*(j/B*(v?-1:1))).mul(S.radius)),h&&f&&!h.isExact&&!f.isExact){M=x.Angle(S.center,_),O=x.Angle(S.center,E),F=y(M,O),B=F*S.radius;const X=T1(t,h.shape.id,f.shape.id);X==="double-bound"&&B<30?(_.setTo(p),E.setTo(g),k.setTo(m)):X==="safe"&&(h&&!h.didIntersect&&_.setTo(p),(f&&!f.didIntersect||y(b,M)>y(b,O))&&E.setTo(S.center).add(x.FromAngle(M+F*(Math.min(.9,fu*e.props.scale/B)*(v?1:-1))).mul(S.radius)))}lle(S.center,S.radius,_,E,k,C,v),_.equals(E)&&(_.setTo(k.clone().addXY(1,1)),E.setTo(k.clone().subXY(1,1))),p.setTo(_),g.setTo(E),m.setTo(k);const H=IE(p,g,m);return{bindings:n,isStraight:!1,start:{point:p,handle:i.start,arrowhead:e.props.arrowheadStart},end:{point:g,handle:i.end,arrowhead:e.props.arrowheadEnd},middle:m,handleArc:S,bodyArc:H,isValid:H.length!==0&&isFinite(H.center.x)&&isFinite(H.center.y)}}function IE(t,e,n){const r=pb(t,e,n)??x.Med(t,e),s=x.Dist(r,t),o=+x.Clockwise(t,n,e),i=((t.y-e.y)**2+(t.x-e.x)**2)**.5,a=((e.y-n.y)**2+(e.x-n.x)**2)**.5,l=((n.y-t.y)**2+(n.x-t.x)**2)**.5,c=Math.acos((a*a+l*l-i*i)/(2*a*l))*2,u=+(De>c),h=(Fe-c)*(o?1:-1),f=h*s;return{center:r,radius:s,size:h,length:f,largeArcFlag:u,sweepFlag:o}}function lle(t,e,n,r,s,o,i){const a=x.Angle(t,n),l=x.Angle(t,r);let c=ud(a,l);if(i||(c=Fe-c),s.setTo(t).add(x.FromAngle(a+c*(.5*(i?1:-1))).mul(e)),c>o){s.rotWith(t,De);const u=r.clone();r.setTo(n),n.setTo(u)}}const cle=8;function ule(t){return Math.abs(t.props.bend)<cle*t.props.scale}function Yp(t,e,n){const r=t.getBindingsFromShape(e,"arrow").find(l=>l.props.terminal===n);if(!r)return;const s=t.getShape(r.toId);if(!s)return;const o=t.getShapePageTransform(s),i=t.getShapeGeometry(s),a=i instanceof $r?i.children[0].vertices:i.vertices;return{shape:s,transform:o,isClosed:i.isClosed,isExact:r.props.isExact,didIntersect:!1,outline:a}}function EE(t,e,n,r){const s=t.getShape(n.toId);if(s){const{point:o,size:i}=t.getShapeGeometry(s).bounds,a=x.Add(o,x.MulV(n.props.isPrecise||r?n.props.normalizedAnchor:{x:.5,y:.5},i)),l=q.applyToPoint(t.getShapePageTransform(s),a);return q.applyToPoint(q.Inverse(e),l)}else return new x(0,0)}function Un(t,e){const n=t.getBindingsFromShape(e,"arrow");return{start:n.find(r=>r.props.terminal==="start"),end:n.find(r=>r.props.terminal==="end")}}const dle=XV("arrow info",(t,e)=>{const n=Un(t,e);return ule(e)?qx(t,e,n):ale(t,e,n)});function Es(t,e){const n=typeof e=="string"?e:e.id;return dle.get(t,n)}function dl(t,e,n){var a,l;const r=t.getShapePageTransform(e),s=T1(t,(a=n.start)==null?void 0:a.toId,(l=n.end)==null?void 0:l.toId),o=n.start?EE(t,r,n.start,s==="double-bound"||s==="start-contains-end"):x.From(e.props.start),i=n.end?EE(t,r,n.end,s==="double-bound"||s==="end-contains-start"):x.From(e.props.end);return{start:o,end:i}}function Oc(t,e,n,r){const s=typeof e=="string"?e:e.id,o=typeof n=="string"?n:n.id,i=t.getBindingsFromShape(s,"arrow").filter(l=>l.props.terminal===r.terminal);i.length>1&&t.deleteBindings(i.slice(1));const a=i[0];a?t.updateBinding({...a,toId:o,props:r}):t.createBinding({type:"arrow",fromId:s,toId:o,props:r})}function yf(t,e,n){const r=t.getBindingsFromShape(e,"arrow").filter(s=>s.props.terminal===n);t.deleteBindings(r)}const fu=10,Xp=10,hle=10,ks={s:2,m:3.5,l:5,xl:10};function T1(t,e,n){if(!e||!n)return"safe";if(e===n)return"double-bound";const r=t.getShapePageBounds(e),s=t.getShapePageBounds(n);if(r&&s){if(r.contains(s))return"start-contains-end";if(s.contains(r))return"end-contains-start"}return"safe"}class Sf extends ff{getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5}}}onAfterCreate({binding:e}){const n=this.editor.getShape(e.fromId);n&&wS(this.editor,n)}onAfterChange({bindingAfter:e}){const n=this.editor.getShape(e.fromId);n&&wS(this.editor,n)}onAfterChangeFromShape({shapeAfter:e}){wS(this.editor,e)}onAfterChangeToShape({binding:e}){Y$(this.editor,e.fromId)}onBeforeIsolateFromShape({binding:e}){const n=this.editor.getShape(e.fromId);n&&qp({editor:this.editor,arrow:n,terminal:e.props.terminal})}}I(Sf,"type","arrow"),I(Sf,"props",kA),I(Sf,"migrations",TA);function Y$(t,e){var v;const n=t.getShape(e);if(!n)return;const r=Un(t,n),{start:s,end:o}=r,i=s?t.getShape(s.toId):void 0,a=o?t.getShape(o.toId):void 0,l=t.getAncestorPageId(n);if(!l)return;let c;if(i&&a)c=t.findCommonAncestor([i,a])??l;else if(i||a){const y=(v=i||a)==null?void 0:v.parentId;y&&y===n.parentId?c=n.parentId:c=l}else return;c&&c!==n.parentId&&t.reparentShapes([e],c);const u=t.getShape(e);if(!u)throw Error("no reparented arrow");const h=t.getShapeNearestSibling(u,i),f=t.getShapeNearestSibling(u,a);let p;if(h&&f)p=h.index>f.index?h:f;else if(h&&!f)p=h;else if(f&&!h)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(S=>S.type!=="arrow");if(u.index>p.index&&(!y||u.index<y.index))return;g=$u(p.index,m[0].index)}else g=_s(p.index);g!==u.index&&t.updateShapes([{id:e,type:"arrow",index:g}])}function wS(t,e){const n=Un(t,e);for(const r of["start","end"]){const s=n[r];if(!s)continue;const o=t.getShape(s.toId),i=t.getAncestorPageId(e)===t.getAncestorPageId(o);(!o||!i)&&qp({editor:t,arrow:e,terminal:r,unbind:!0})}Y$(t,e.id)}function qp({editor:t,arrow:e,terminal:n,unbind:r=!1,useHandle:s=!1}){const o=Es(t,e);if(!o)throw new Error("expected arrow info");const i=s?o.start.handle:o.start.point,a=s?o.end.handle:o.end.point,l=n==="start"?i:a,c={id:e.id,type:"arrow",props:{[n]:{x:l.x,y:l.y},bend:e.props.bend}};if(!o.isStraight){const u=n==="start"?i:o.start.handle,h=n==="end"?a:o.end.handle,f=x.Med(u,h),p=x.Sub(u,h).per().uni().mul(o.handleArc.radius*2*Math.sign(e.props.bend)),g=gd(o.handleArc.center,x.Add(f,p),o.handleArc.center,o.handleArc.radius);Le((g==null?void 0:g.length)===1);const m=x.Dist(f,g[0])*Math.sign(e.props.bend);di(m,c.props.bend)||(c.props.bend=m)}t.updateShape(c),r&&yf(t,e,n)}const X$=[Sf],pn={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},fn={s:2,m:3.5,l:5,xl:10},Ll={s:18,m:24,l:36,xl:44},yo={s:18,m:22,l:26,xl:32},fle={s:18,m:20,l:24,xl:28},Co={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},ple=20,M1=4.25,Er=16;function gle(t,e){const n=t.w/e.w,r=t.h/e.h;return n<=1&&r<=1?t:n>r?{w:t.w/n,h:t.h/n}:{w:t.w/r,h:t.h/r}}/*!
|
|
348
|
-
* MIT License
|
|
349
|
-
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
350
|
-
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
351
|
-
*/const hl=" ",vn=class vn{static insertTextFirefox(e,n){e.setRangeText(n,e.selectionStart||0,e.selectionEnd||0,"end"),e.dispatchEvent(new InputEvent("input",{data:n,inputType:"insertText",isComposing:!1}))}static insert(e,n){const r=e.ownerDocument,s=r.activeElement;s!==e&&e.focus(),r.execCommand("insertText",!1,n)||vn.insertTextFirefox(e,n),s===r.body?e.blur():s instanceof HTMLElement&&s!==e&&s.focus()}static set(e,n){e.select(),vn.insert(e,n)}static getSelection(e){const{selectionStart:n,selectionEnd:r}=e;return e.value.slice(n||void 0,r||void 0)}static wrapSelection(e,n,r){const{selectionStart:s,selectionEnd:o}=e,i=vn.getSelection(e);vn.insert(e,n+i+(r??n)),e.selectionStart=(s||0)+n.length,e.selectionEnd=(o||0)+n.length}static replace(e,n,r){let s=0;e.value.replace(n,(...o)=>{const i=s+o[o.length-2],a=o[0].length;e.selectionStart=i,e.selectionEnd=i+a;const l=typeof r=="string"?r:r(...o);return vn.insert(e,l),e.selectionStart=i,s+=l.length-a,l})}static findLineEnd(e,n){const r=e.lastIndexOf(`
|
|
352
|
-
`,n-1)+1;return e.charAt(r)!==" "?n:r+1}static indent(e){var a;const{selectionStart:n,selectionEnd:r,value:s}=e,o=s.slice(n,r),i=(a=/\n/g.exec(o))==null?void 0:a.length;if(i&&i>0){const l=s.lastIndexOf(`
|
|
353
|
-
`,n-1)+1,c=e.value.slice(l,r-1),u=c.replace(/^|\n/g,`$&${hl}`),h=u.length-c.length;e.setSelectionRange(l,r-1),vn.insert(e,u),e.setSelectionRange(n+1,r+h)}else vn.insert(e,hl)}static unindent(e){const{selectionStart:n,selectionEnd:r,value:s}=e,o=s.lastIndexOf(`
|
|
354
|
-
`,n-1)+1,i=vn.findLineEnd(s,r),a=e.value.slice(o,i),l=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),c=a.length-l.length;e.setSelectionRange(o,i),vn.insert(e,l);const u=/\t| {1,2}/.exec(s.slice(o,n)),h=u?u[0].length:0,f=n-h;e.setSelectionRange(n-h,Math.max(f,r-c))}static indentCE(e){var l;const n=window.getSelection(),r=e.innerText,s=Lh(e)??0,o=Lh(e)??0,i=r.slice(s,o),a=(l=/\n/g.exec(i))==null?void 0:l.length;if(a&&a>0){const c=r.lastIndexOf(`
|
|
355
|
-
`,s-1)+1,u=r.slice(c,o-1),f=u.replace(/^|\n/g,`$&${hl}`).length-u.length;n&&n.setBaseAndExtent(e,s+1,e,o+f)}else{const c=window.getSelection();e.innerText=r.slice(0,s)+hl+r.slice(s),c==null||c.setBaseAndExtent(e,s+1,e,s+2)}}static unindentCE(e){const n=window.getSelection(),r=e.innerText,s=Lh(e)??0,o=Lh(e)??0,i=r.lastIndexOf(`
|
|
356
|
-
`,s-1)+1,a=vn.findLineEnd(r,o),l=r.slice(i,a),c=l.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=l.length-c.length;if(n){n.setBaseAndExtent(e,i,e,a);const h=/\t| {1,2}/.exec(r.slice(i,s)),f=h?h[0].length:0,p=s-f;n.setBaseAndExtent(e,s-f,e,Math.max(p,o-u))}}static normalizeText(e){return e.replace(vn.fixNewLines,`
|
|
357
|
-
`)}static normalizeTextForDom(e){return e.replace(vn.fixNewLines,`
|
|
358
|
-
`).split(`
|
|
359
|
-
`).map(n=>n||" ").join(`
|
|
360
|
-
`)}};I(vn,"fixNewLines",/\r?\n|\r/g);let $l=vn;function Lh(t){if(typeof window.getSelection>"u")return;const e=window.getSelection();if(!e)return;let n=0;if(e.rangeCount!==0){const r=e.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length}return n}const mle=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function q$(t){return mle.test(t)}function yle(t){return t.replace(/\t/g,hl)}function Sle(t){const e=t.split(`
|
|
361
|
-
`);for(;e[0]&&e[0].trim().length===0;)e.shift();let n=1/0;for(const r of e)if(r.trim().length>0){const s=r.length-r.trimStart().length;n=Math.min(n,s)}return e.map(r=>r.slice(n)).join(`
|
|
362
|
-
`)}const Z$={"&":"&",""":'"',"'":"'",""":'"',"&":"&","'":"'","–":"–","—":"—","‘":"‘","’":"’","“":"“","”":"”","…":"…"},vle=new RegExp(Object.keys(Z$).join("|"),"g");function xle(t){return t.replace(vle,e=>Z$[e])}function wle(t){return t.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function ble(t){return wle(Sle(yle(t)))}function Ple(t,{maxImageDimension:e,maxAssetSize:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:s},{toasts:o,msg:i}){t.registerExternalAssetHandler("file",async({file:a,assetId:l})=>{const c=r.includes(a.type),u=s.includes(a.type);!c&&!u&&o.addToast({title:i("assets.files.type-not-allowed"),severity:"error"}),Le(c||u,`File type not allowed: ${a.type}`),a.size>n&&o.addToast({title:i("assets.files.size-too-big"),severity:"error"}),Le(a.size<=n,`File size too big: ${(a.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`);const h=OC(await a.arrayBuffer());l=l??Yo.createId(h);const f=await kE(a,l,c,u);if(isFinite(e)){const p={w:f.props.w,h:f.props.h},g=gle(p,{w:e,h:e});p!==g&&ar.isStaticImageType(a.type)&&(f.props.w=g.w,f.props.h=g.h)}return f.props.src=await t.uploadAsset(f,a),Yo.create(f)}),t.registerExternalAssetHandler("url",async({url:a})=>{var c,u,h,f,p;let l;try{const m=await(await Rs(a,{method:"GET",mode:"no-cors"})).text(),v=new DOMParser().parseFromString(m,"text/html");l={image:((c=v.head.querySelector('meta[property="og:image"]'))==null?void 0:c.getAttribute("content"))??"",favicon:((u=v.head.querySelector('link[rel="apple-touch-icon"]'))==null?void 0:u.getAttribute("href"))??((h=v.head.querySelector('link[rel="icon"]'))==null?void 0:h.getAttribute("href"))??"",title:((f=v.head.querySelector('meta[property="og:title"]'))==null?void 0:f.getAttribute("content"))??a,description:((p=v.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),o.addToast({title:i("assets.url.failed"),severity:"error"}),l={image:"",favicon:"",title:"",description:""}}return{id:Yo.createId(Gv(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 h=parseFloat(u.getAttribute("width")||"0"),f=parseFloat(u.getAttribute("height")||"0");if(!(h&&f)){document.body.appendChild(u);const g=u.getBoundingClientRect();document.body.removeChild(u),h=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");TE(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:h,height:f}=c,p=Ke(),g={id:p,type:"embed",x:u.x-(h||450)/2,y:u.y-(f||450)/2,props:{w:h,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 x(c.x,c.y),h=[];for(const p of l){if(p.size>n){o.addToast({title:i("assets.files.size-too-big"),severity:"error"}),console.warn(`File size too big: ${(p.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`);continue}if(!p.type){o.addToast({title:i("assets.files.upload-failed"),severity:"error"}),console.error("No mime type");continue}if(!r.concat(s).includes(p.type)){o.addToast({title:i("assets.files.type-not-allowed"),severity:"error"}),console.warn(`${p.name} not loaded - Mime type not allowed ${p.type}.`);continue}const g=r.includes(p.type),m=s.includes(p.type),v=OC(await p.arrayBuffer()),y=Yo.createId(v),S=await kE(p,y,g,m);let b;g&&(b=t.createTemporaryAssetPreview(y,p)),h.push({asset:S,file:p,temporaryAssetPreview:b})}const f=[];await Promise.allSettled(h.map(async p=>{try{const g=await t.getAssetForExternalContent({type:"file",file:p.file});if(!g)throw Error("Could not create an asset");const m={...g,id:p.asset.id};f.push(m),t.updateAssets([m])}catch(g){o.addToast({title:i("assets.files.upload-failed"),severity:"error"}),console.error(g);return}})),TE(t,f,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(),h=ble(l),f=t.getOnlySelectedShape();if(f&&"text"in f.props){t.updateShapes([{id:f.id,type:f.type,props:{text:h}}]);return}let p,g,m,v="middle";const y=h.split(`
|
|
363
|
-
`).length>1,S=q$(h);y&&(v=y?S?"end":"start":"middle");const b=t.textMeasure.measureText(h,{...pn,fontFamily:Co[u.font],fontSize:Ll[u.size],maxWidth:null}),P=Math.min(y?t.getViewportPageBounds().width*.9:920,Math.max(200,t.getViewportPageBounds().width*.9));if(b.w>P){const C=t.textMeasure.measureText(h,{...pn,fontFamily:Co[u.font],fontSize:Ll[u.size],maxWidth:P});p=C.w,g=C.h,m=!1,v=S?"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:Ke(),type:"text",x:c.x-p/2,y:c.y-g/2,props:{text:h,textAlign:v,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 h=a??(t.inputs.shiftKey?t.inputs.currentPagePoint:t.getViewportPageBounds().center),f=Yo.createId(Gv(l)),p=Cle(t,l,h);let g=t.getAsset(f),m=!1;if(!g){m=!0;try{const v=await t.getAssetForExternalContent({type:"url",url:l});if(!v)throw Error("Could not create an asset");g=v}catch{o.addToast({title:i("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 kE(t,e,n,r){let s=t.type;t.type==="video/quicktime"&&(s="video/mp4");const o=n?await ar.getImageSize(t):await ar.getVideoSize(t),i=await ar.isAnimated(t)||r;return{id:e,type:n?"image":"video",typeName:"asset",props:{name:t.name,src:"",w:o.w,h:o.h,fileSize:t.size,mimeType:s,isAnimated:i},meta:{}}}async function TE(t,e,n){if(!e.length)return[];const r=x.From(n),s=[];for(let o=0;o<e.length;o++){const i=e[o];switch(i.type){case"image":{s.push({id:Ke(),type:"image",x:r.x,y:r.y,opacity:1,props:{assetId:i.id,w:i.props.w,h:i.props.h}}),r.x+=i.props.w;break}case"video":s.push({id:Ke(),type:"video",x:r.x,y:r.y,opacity:1,props:{assetId:i.id,w:i.props.w,h:i.props.h}}),r.x+=i.props.w}}return t.run(()=>{const o=e.filter(i=>!t.getAsset(i.id));o.length&&t.createAssets(o),t.createShapes(s).select(...s.map(i=>i.id)),Q$(t,n)}),s.map(o=>o.id)}function Q$(t,e){const n=t.getViewportPageBounds();let r=t.getSelectionPageBounds();if(r){const s=r.center.sub(e);t.updateShapes(t.getSelectedShapes().map(o=>{const i=t.getShapeParentTransform(o).decompose().rotation,a=x.Rot(s,-i);return{id:o.id,type:o.type,x:o.x-a.x,y:o.y-a.y}}))}if(r=t.getSelectionPageBounds(),r&&t.getInstanceState().isGridMode){const s=t.getDocumentSettings().gridSize,o=new x(r.minX,r.minY),i=o.clone().snapToGrid(s),a=x.Sub(o,i);t.updateShapes(t.getSelectedShapes().map(l=>{const c={x:l.x-a.x,y:l.y-a.y};return{id:l.id,type:l.type,x:c.x,y:c.y}}))}r=t.getSelectionPageBounds(),r&&!n.contains(r)&&t.zoomToSelection({animation:{duration:t.options.animationMediumMs}})}function Cle(t,e,n){const r={id:Ke(),type:"bookmark",x:n.x-150,y:n.y-160,opacity:1,props:{assetId:null,url:e}};return t.run(()=>{t.createShapes([r]).select(r.id),Q$(t,n)}),t.getShape(r.id)}var DS;let _le=(DS=class extends ie{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}onKeyUp(e){var n;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const r=this.editor.getOnlySelectedShape();r&&this.editor.getShapeUtil(r).canEdit(r)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(r.id),(n=this.editor.root.getCurrent())==null||n.transition("editing_shape",{...e,target:"shape",shape:r}))}}},I(DS,"id","idle"),DS);var RS;let Ile=(RS=class extends ie{constructor(){super(...arguments);I(this,"shape");I(this,"markId","");I(this,"preciseTimeout",-1);I(this,"didTimeout",!1)}onEnter(){this.markId="",this.didTimeout=!1;const n=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:r=>!r.isLocked&&this.editor.canBindShapes({fromShape:"arrow",toShape:r,binding:"arrow"}),margin:0,hitInside:!0,renderingOnly:!0});n?this.editor.setHintingShapes([n.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 h;const{originPagePoint:n}=this.editor.inputs,r=Ke();this.markId=this.editor.markHistoryStoppingPoint(`creating_arrow:${r}`);const s=is(n,this.editor);this.editor.createShape({id:r,type:"arrow",x:s.x,y:s.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const o=this.editor.getShape(r);if(!o)throw Error("expected shape");const i=this.editor.getShapeHandles(o);if(!i)throw Error("expected handles for arrow");const a=this.editor.getShapeUtil("arrow"),l=this.shape,c=i.find(f=>f.id==="start"),u=(h=a.onHandleDrag)==null?void 0:h.call(a,o,{handle:{...c,x:0,y:0},isPrecise:!0,initial:l});u&&this.editor.updateShapes([u]),this.shape=this.editor.getShape(r),this.editor.select(r)}updateArrowShapeEndHandle(){var s,o;const n=this.shape;if(!n)throw Error("expected shape");const r=this.editor.getShapeHandles(n);if(!r)throw Error("expected handles for arrow");{const i=this.editor.getShapeUtil("arrow"),a=this.shape,l=r.find(u=>u.id==="start"),c=(s=i.onHandleDrag)==null?void 0:s.call(i,n,{handle:{...l,x:0,y:0},isPrecise:this.didTimeout,initial:a});c&&this.editor.updateShapes([c])}{const i=this.editor.getShapeUtil("arrow"),a=this.shape,l=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),c=r.find(h=>h.id==="end"),u=(o=i.onHandleDrag)==null?void 0:o.call(i,this.editor.getShape(n),{handle:{...c,x:l.x,y:l.y},isPrecise:!1,initial:a});u&&this.editor.updateShapes([u])}this.shape=this.editor.getShape(n.id)}startPreciseTimeout(){this.preciseTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},I(RS,"id","pointing"),RS);class Zx extends ie{constructor(){super(...arguments);I(this,"shapeType","arrow")}static children(){return[_le,Ile]}}I(Zx,"id","arrow"),I(Zx,"initial","idle");class A1 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"initialShape");I(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");I(this,"util",this.editor.getShapeUtil(this.shapeType));I(this,"isPen",!1);I(this,"isPenOrStylus",!1);I(this,"segmentMode","free");I(this,"didJustShiftClickToExtendPreviousShapeLine",!1);I(this,"pagePointWhereCurrentSegmentChanged",{});I(this,"pagePointWhereNextSegmentChanged",null);I(this,"lastRecordedPoint",{});I(this,"mergeNextPoint",!1);I(this,"currentLineLength",0);I(this,"markId",null)}onEnter(n){this.markId=null,this.info=n,this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.startShape()}onPointerMove(){const{inputs:n}=this.editor;if(this.isPen&&!n.isPen&&this.markId){this.editor.bailToMark(this.markId),this.startShape();return}this.isPenOrStylus?x.Dist(n.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=n.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape()}onKeyDown(n){if(n.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(n){if(n.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(n,r,s){if(!this.canClose())return!1;const o=fn[r],i=n[0].points[0],a=n[n.length-1],l=a.points[a.points.length-1];return i!==l&&this.currentLineLength>o*4*s&&x.DistMin(i,l,o*2*s)}startShape(){const{inputs:{originPagePoint:n,isPen:r}}=this.editor;this.markId=this.editor.markHistoryStoppingPoint("draw start");const{z:s=.5}=this.info.point;this.isPen=r,this.isPenOrStylus=r||s>0&&s<.5||s>.5&&s<1;const o=this.isPenOrStylus?s*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=n.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const l=Ht(a.props.segments);if(!l)throw Error("Expected a previous segment!");const c=Ht(l.points);if(!c)throw Error("Expected a previous point!");const{x:u,y:h}=this.editor.getPointInShapeSpace(a,n).toFixed(),f={type:this.segmentMode,points:[{x:c.x,y:c.y,z:+o.toFixed(2)},{x:u,y:h,z:+o.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<fn[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=n.clone();const i=Ke();this.editor.createShapes([{id:i,type:this.shapeType,x:n.x,y:n.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:+o.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(i)}updateDrawingShape(){const{initialShape:n}=this,{inputs:r}=this.editor;if(!n)return;const{id:s,props:{size:o,scale:i}}=n,a=this.editor.getShape(s);if(!a)return;const{segments:l}=a.props,{x:c,y:u,z:h}=this.editor.getPointInShapeSpace(a,r.currentPagePoint).toFixed(),f=this.isPenOrStylus?+(r.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(x.Dist2(g,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const v=Ht(l);if(!v)throw Error("Expected a previous segment!");const y=Ht(v.points);if(!y)throw Error("Expected a previous last point!");let S;const b=this.editor.getPointInShapeSpace(a,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(v.type==="straight"){this.currentLineLength+=x.Dist(y,b),S={type:"straight",points:[{...y},b]};const C=this.editor.getShapePageTransform(a);this.pagePointWhereCurrentSegmentChanged=q.applyToPoint(C,y)}else S={type:"straight",points:[b,p]};const P={id:s,type:this.shapeType,props:{segments:[...l,S]}};this.canClose()&&(P.props.isClosed=this.getIsClosed(l,o,i)),this.editor.updateShapes([P])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:g}=this;if(g===null)throw Error("We should have a point where the segment changed");if(x.Dist2(g,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const v=l.slice(),y=v[v.length-1],S=Ht(y.points);if(!S)throw Error("No previous point!");const b={type:"free",points:[...x.PointsBetween(S,p,6).map(_=>({x:io(_.x),y:io(_.y),z:io(_.z)}))]},P=[...v,b];this.currentLineLength<fn[a.props.size]*4&&(this.currentLineLength=this.getLineLength(P));const C={id:s,type:this.shapeType,props:{segments:P}};this.canClose()&&(C.props.isClosed=this.getIsClosed(P,o,i)),this.editor.updateShapes([C])}break}case"straight":{const g=l.slice(),m=g[g.length-1],{pagePointWhereCurrentSegmentChanged:v}=this,{ctrlKey:y,currentPagePoint:S}=this.editor.inputs;if(!v)throw Error("We should have a point where the segment changed");let b,P=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(P=!y,this.didJustShiftClickToExtendPreviousShapeLine=!1):P=!y;let C=this.editor.getPointInShapeSpace(a,S).toFixed().toJson(),_=!1,E;if((this.editor.user.getIsSnapMode()?!y:y)&&g.length>2){let T,j=8/this.editor.getZoomLevel();for(let L=0,M=l.length-2;L<M;L++){const O=l[L];if(!O)break;if(O.type==="free")continue;const F=O.points[0],B=Ht(O.points);if(!(F&&B))continue;const K=x.NearestPointOnLineSegment(F,B,C);if(x.DistMin(K,C,j)){T=K.toFixed().toJson(),j=x.Dist(K,C),E=O;break}}T&&(_=!0,C=T)}if(_&&E){const T=this.editor.getShapePageTransform(a),j=E.points[0],L=Ht(E.points);if(!L)throw Error("Expected a last point!");const M=q.applyToPoint(T,j),O=q.applyToPoint(T,L),F=q.applyToPoint(T,C);this.editor.snaps.setIndicators([{id:ze(),type:"points",points:[M,F,O]}])}else{if(this.editor.snaps.clearIndicators(),P){const T=x.Angle(v,S),L=Rp(T,24)-T;b=x.RotWith(S,v,L)}else b=S;C=this.editor.getPointInShapeSpace(a,b).toFixed().toJson()}this.currentLineLength+=x.Dist(m.points[0],C),g[g.length-1]={...m,type:"straight",points:[m.points[0],C]};const D={id:s,type:this.shapeType,props:{segments:g}};this.canClose()&&(D.props.isClosed=this.getIsClosed(l,o,i)),this.editor.updateShapes([D]);break}case"free":{const g=l.slice(),m=g[g.length-1],v=[...m.points];if(v.length&&this.mergeNextPoint){const{z:S}=v[v.length-1];v[v.length-1]={x:p.x,y:p.y,z:S?Math.max(S,p.z):p.z}}else this.currentLineLength+=x.Dist(v[v.length-1],p),v.push(p);g[g.length-1]={...m,points:v},this.currentLineLength<fn[a.props.size]*4&&(this.currentLineLength=this.getLineLength(g));const y={id:s,type:this.shapeType,props:{segments:g}};if(this.canClose()&&(y.props.isClosed=this.getIsClosed(g,o,i)),this.editor.updateShapes([y]),v.length>this.editor.options.maxPointsPerDrawShape){this.editor.updateShapes([{id:s,type:this.shapeType,props:{isComplete:!0}}]);const S=Ke(),b=this.editor.getShape(s).props;this.editor.createShapes([{id:S,type:this.shapeType,x:io(r.currentPagePoint.x),y:io(r.currentPagePoint.y),props:{isPen:this.isPenOrStylus,scale:b.scale,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(h*1.25).toFixed():.5}]}]}}]),this.initialShape=nt(this.editor.getShape(S)),this.mergeNextPoint=!1,this.lastRecordedPoint=r.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(n){let r=0;for(const s of n)for(let o=0;o<s.points.length-1;o++){const i=s.points[o],a=s.points[o+1];r+=x.Dist2(a,i)}return Math.sqrt(r)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())}complete(){const{initialShape:n}=this;n&&(this.editor.updateShapes([{id:n.id,type:n.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}I(A1,"id","drawing");var LS;let J$=(LS=class extends ie{onPointerDown(e){this.parent.transition("drawing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},I(LS,"id","idle"),LS);class vf extends ie{constructor(){super(...arguments);I(this,"shapeType","draw")}static children(){return[J$,A1]}onExit(){const n=this.children.drawing;n.initialShape=void 0}}I(vf,"id","draw"),I(vf,"initial","idle"),I(vf,"isLockable",!1);class Qx extends Ox{constructor(){super(...arguments);I(this,"shapeType","frame")}onCreate(n){if(!n)return;const r=this.editor.getShapePageBounds(n),s=[],o=this.editor.getShapeAncestors(n).map(i=>i.id);this.editor.getSortedChildIdsForParent(n.parentId).map(i=>{const a=this.editor.getShape(i);if(!a||a.id===n.id||a.isLocked)return;const l=this.editor.getShapePageBounds(a);l&&r.contains(l)&&Ele(a,o,n)&&s.push(a.id)}),this.editor.reparentShapes(s,n.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")}}I(Qx,"id","frame"),I(Qx,"initial","idle");function Ele(t,e,n){return e.includes(t.id)?!1:t.parentId===n.parentId}var $S;let kle=($S=class extends ie{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onKeyUp(e){var n;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const r=this.editor.getOnlySelectedShape();r&&this.editor.getShapeUtil(r).canEdit(r)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(r.id),(n=this.editor.root.getCurrent())==null||n.transition("editing_shape",{...e,target:"shape",shape:r}))}}onCancel(){this.editor.setCurrentTool("select")}},I($S,"id","idle"),$S);var FS;let Tle=(FS=class extends ie{onPointerUp(){this.complete()}onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:n}=this.editor.inputs,r=Ke(),s=this.editor.markHistoryStoppingPoint(`creating_geo:${r}`),o=is(n,this.editor);this.editor.createShapes([{id:r,type:"geo",x:o.x,y:o.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(Jr),scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]).select(r).setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:s,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){const{originPagePoint:e}=this.editor.inputs,n=Ke();this.editor.markHistoryStoppingPoint(`creating_geo:${n}`);const r=this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,s=this.editor.getStyleForNextShape(Jr),o=s==="star"?{w:200,h:190}:s==="cloud"?{w:300,h:180}:{w:200,h:200};this.editor.createShapes([{id:n,type:"geo",x:e.x,y:e.y,props:{geo:this.editor.getStyleForNextShape(Jr),scale:r,...o}}]);const i=this.editor.getShape(n);if(!i)return;const{w:a,h:l}=i.props,c=new x(a/2,l/2).mul(r),u=this.editor.getShapeParentTransform(i);u&&c.rot(-u.rotation());const h=is(new x(i.x-c.x,i.y-c.y),this.editor);this.editor.select(n),this.editor.updateShape({id:i.id,type:"geo",x:h.x,y:h.y,props:{geo:this.editor.getStyleForNextShape(Jr),w:a*r,h:l*r}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},I(FS,"id","pointing"),FS);class Jx extends ie{constructor(){super(...arguments);I(this,"shapeType","geo")}static children(){return[kle,Tle]}}I(Jx,"id","geo"),I(Jx,"initial","idle");class xf extends ie{constructor(){super(...arguments);I(this,"shapeType","highlight")}static children(){return[J$,A1]}onExit(){const n=this.children.drawing;n.initialShape=void 0}}I(xf,"id","highlight"),I(xf,"initial","idle"),I(xf,"isLockable",!1);var NS;let Mle=(NS=class extends ie{constructor(){super(...arguments);I(this,"shapeId","")}onEnter(n){this.shapeId=n.shapeId,this.editor.setCursor({type:"cross",rotation:0})}onPointerDown(){this.parent.transition("pointing",{shapeId:this.shapeId})}onCancel(){this.editor.setCurrentTool("select")}},I(NS,"id","idle"),NS);const ME=2;var zS;let Ale=(zS=class extends ie{constructor(){super(...arguments);I(this,"shape",{});I(this,"markId")}onEnter(n){const{inputs:r}=this.editor,{currentPagePoint:s}=r;this.markId=void 0;const o=n.shapeId&&this.editor.getShape(n.shapeId);if(o&&r.shiftKey){this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${o.id}`),this.shape=o;const i=this.editor.getShapeHandles(this.shape);if(!i)return;const a=i.filter(g=>g.type==="vertex").sort(cn),l=a[a.length-1],c=a[a.length-2],u=q.applyToPoint(this.editor.getShapeParentTransform(this.shape),new x(this.shape.x,this.shape.y)),h=x.Sub(s,u).addXY(.1,.1),f=is(h,this.editor),p=nt(this.shape.props.points);if(x.DistMin(l,c,ME)||x.DistMin(f,l,ME))p[l.id]={id:l.id,index:l.index,x:f.x,y:f.y};else{const g=_s(l.index);p[g]={id:g,index:g,x:f.x,y:f.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:p}}])}else{const i=Ke();this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${i}`);const a=is(s,this.editor);this.editor.createShapes([{id:i,type:"line",x:a.x,y:a.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]),this.editor.select(i),this.shape=this.editor.getShape(i)}}onPointerMove(){if(this.shape&&this.editor.inputs.isDragging){const n=this.editor.getShapeHandles(this.shape);if(!n)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const r=Ht(n);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,creatingMarkId:this.markId,handle:{...r,x:r.x-.1,y:r.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()}},I(zS,"id","pointing"),zS);class ew extends ie{constructor(){super(...arguments);I(this,"shapeType","line")}static children(){return[Mle,Ale]}}I(ew,"id","line"),I(ew,"initial","idle");var BS;let jle=(BS=class extends ie{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},I(BS,"id","idle"),BS);const Ole=0,He=200,wm=new x(He/2,He/2),e5=10,Dle=t=>[[["a1"],new x(He*.5,He*-.5-t.options.adjacentShapeMargin)],[["a2"],new x(He*1.5+t.options.adjacentShapeMargin,He*.5)],[["a3"],new x(He*.5,He*1.5+t.options.adjacentShapeMargin)],[["a4"],new x(He*-.5-t.options.adjacentShapeMargin,He*.5)]];function Rle(t,e){if(e===1)return Dle(t);const n=He*e,r=t.options.adjacentShapeMargin*e;return[[["a1"],new x(n*.5,n*-.5-r)],[["a2"],new x(n*1.5+r,n*.5)],[["a3"],new x(n*.5,n*1.5+r)],[["a4"],new x(n*-.5-r,n*.5)]]}function t5(t,e,n,r,s,o){return Object.fromEntries(Rle(t,o).map(([i,a],l)=>{const c=a.clone();return l===0&&s?c.y-=s:l===2&&r&&(c.y+=r),[i,c.rot(n).add(e)]}))}function n5(t,e,n,r){const s=new Set(t.getSelectedShapeIds()),o=(He+t.options.adjacentShapeMargin+r)**2,i=new Map,a=[];for(const u of t.getCurrentPageShapes()){if(!t.isShapeOfType(u,"note")||n!==u.props.scale||s.has(u.id))continue;const h=t.getShapePageTransform(u.id);e===h.rotation()&&(i.set(u,t.getShapePageBounds(u).center),a.push(...Object.values(t5(t,h.point(),e,u.props.growY,r,n))))}const l=a.length;let c;for(const[u,h]of i)for(let f=0;f<l;f++)c=a[f],c&&(x.Dist2(h,c)>o||t.isPointInShape(u,c)&&(a[f]=void 0));return me(a)}function r5(t,e,n,r,s=!1){let o;const i=t.getCurrentPageShapesSorted(),a=(He+t.options.adjacentShapeMargin**2)**e.props.scale;for(let l=i.length-1;l>=0;l--){const c=i[l];if(c.type==="note"&&c.id!==e.id){const u=t.getShapePageBounds(c);if(u&&x.Dist2(u.center,n)<a&&t.isPointInShape(c,n)){o=c;break}}}if(t.complete(),!o||s){t.markHistoryStoppingPoint("creating note shape");const l=Ke();t.createShape({id:l,type:"note",x:n.x,y:n.y,rotation:r,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,x.Sub(n,x.Rot(wm.clone().mul(c.props.scale),r)));t.updateShape({id:l,type:"note",x:u.x,y:u.y}),o=t.getShape(l)}return $le(t),o}const Lle=16;function $le(t){const e=t.getSelectionPageBounds(),n=t.getViewportPageBounds();if(e&&!n.contains(e)){const r=e.clone().expandBy(Lle/t.getZoomLevel()).expand(n),s=n.clone().translate({x:(r.center.x-n.center.x)*2,y:(r.center.y-n.center.y)*2});t.zoomToBounds(s,{animation:{duration:t.options.animationMediumMs},inset:0})}}var US;let Fle=(US=class extends ie{constructor(){super(...arguments);I(this,"dragged",!1);I(this,"info",{});I(this,"markId","");I(this,"shape",{})}onEnter(){const{editor:n}=this,r=Ke();this.markId=n.markHistoryStoppingPoint(`creating_note:${r}`);const s=this.editor.inputs.originPagePoint.clone(),o=Nle(this.editor,s,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);o&&s.sub(o),this.shape=zle(this.editor,r,s)}onPointerMove(n){this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.translating",{...n,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.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)}},I(US,"id","pointing"),US);function Nle(t,e,n){let r=e5/t.getZoomLevel(),s;for(const o of n5(t,0,n,0)){const i=x.Sub(e,o),a=i.len();a<r&&(r=a,s=i)}return s}function zle(t,e,n){t.createShape({id:e,type:"note",x:n.x,y:n.y,props:{scale:t.user.getIsDynamicResizeMode()?1/t.getZoomLevel():1}}).select(e);const r=t.getShape(e),s=t.getShapeGeometry(r).bounds,o=is(new x(r.x-s.width/2,r.y-s.height/2),t);return t.updateShapes([{id:e,type:"note",x:o.x,y:o.y}]),t.getShape(e)}class tw extends ie{constructor(){super(...arguments);I(this,"shapeType","note")}static children(){return[jle,Fle]}}I(tw,"id","note"),I(tw,"initial","idle");function Ble(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 n;const r=t.getOutermostSelectableShape(e);return r===e||r.id===t.getFocusedGroupId()||t.getSelectedShapeIds().includes(r.id)?n=e:n=r,t.setHoveredShape(n.id)}const uo=TT(Ble,32);var HS;let Ule=(HS=class extends ie{onPointerMove(e){switch(e.target){case"shape":case"canvas":uo(this.editor)}}onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){uo.cancel()}onKeyDown(e){var n;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const r=this.editor.getOnlySelectedShape();r&&this.editor.getShapeUtil(r).canEdit(r)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(r.id),(n=this.editor.root.getCurrent())==null||n.transition("editing_shape",{...e,target:"shape",shape:r}))}}onCancel(){this.editor.setCurrentTool("select")}},I(HS,"id","idle"),HS);var KS;let Hle=(KS=class extends ie{constructor(){super(...arguments);I(this,"shape");I(this,"markId","");I(this,"enterTime",0)}onEnter(){this.enterTime=Date.now()}onExit(){this.editor.setHintingShapes([])}onPointerMove(n){if(Date.now()-this.enterTime<150)return;const{editor:r}=this,{isPointing:s}=r.inputs;if(!s)return;const{originPagePoint:o,currentPagePoint:i}=r.inputs,a=Math.abs(o.x-i.x),c=Math.sqrt(r.getInstanceState().isCoarsePointer?r.options.coarseDragDistanceSquared:r.options.dragDistanceSquared)*6/r.getZoomLevel();if(a>c){const u=Ke();this.markId=r.markHistoryStoppingPoint(`creating_text:${u}`);const h=this.createTextShape(u,o,!1,a);if(!h){this.cancel();return}this.shape=r.getShape(h),r.select(u),r.setCurrentTool("select.resizing",{...n,target:"selection",handle:"right",isCreating:!0,creatingMarkId:this.markId,creationCursorOffset:{x:a,y:1},onInteractionEnd:"text",onCreate:()=>{r.setEditingShape(h.id)}})}}onPointerUp(){this.complete()}onComplete(){this.cancel()}onCancel(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.editor.markHistoryStoppingPoint("creating text shape");const n=Ke(),{originPagePoint:r}=this.editor.inputs;this.createTextShape(n,r,!0,20)&&(this.editor.select(n),this.editor.setEditingShape(n))}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}createTextShape(n,r,s,o){this.editor.createShape({id:n,type:"text",x:r.x,y:r.y,props:{text:"",autoSize:s,w:o,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const i=this.editor.getShape(n);if(!i){this.cancel();return}const a=this.editor.getShapePageBounds(i),l=new x;if(s)switch(i.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,Fn(i.parentId)){const h=this.editor.getShapeParentTransform(i);l.rot(-h.rotation())}const c=i.x+l.x,u=i.y+l.y;if(this.editor.getInstanceState().isGridMode){const h=new x(c,u),f=is(h,this.editor),p=x.Sub(h,f);this.editor.updateShape({...i,x:c-p.x,y:u-p.y})}else this.editor.updateShape({...i,x:c,y:u});return i}},I(KS,"id","pointing"),KS);class nw extends ie{constructor(){super(...arguments);I(this,"shapeType","text")}static children(){return[Ule,Hle]}}I(nw,"id","text"),I(nw,"initial","idle");const Kle=[nw,vf,Jx,tw,ew,Qx,Zx,xf];function zr(){return ko({isDarkMode:xd()})}function bm(t){return{key:`${Ls.id}:${t}`,async getElement(){const e=Wle(t);if(!e)return null;const{url:n,fontFaceRule:r}=e,s=await(await Rs(n)).blob(),o=await Zr.blobToDataUrl(s),i=r.replace(n,o);return d.jsx("style",{children:i})}}}function Wle(t){const e=CA[t];for(const n of document.fonts)if(e.includes(n.family)&&"$$_url"in n&&typeof n.$$_url=="string"&&"$$_fontface"in n&&typeof n.$$_fontface=="string")return{url:n.$$_url,fontFaceRule:n.$$_fontface};return null}function j1(t){return{key:`${Ls.id}:${t}`,async getElement(){return t!=="pattern"?null:d.jsx(Gle,{})}}}function Gle(){const t=D1(),e=Jl(),n=zr(),r=8/12;return d.jsxs(d.Fragment,{children:[d.jsxs("mask",{id:e,children:[d.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),d.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[d.jsx("line",{x1:r*1,y1:r*3,x2:r*3,y2:r*1}),d.jsx("line",{x1:r*5,y1:r*7,x2:r*7,y2:r*5}),d.jsx("line",{x1:r*9,y1:r*11,x2:r*11,y2:r*9})]})]}),d.jsx("pattern",{id:t(1,n.id),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:d.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:n.solid,mask:`url(#${e})`})})]})}function O1(){return{key:`${Ls.id}:pattern`,component:qle}}const Yc=8,AE=(t,e,n)=>new Promise((r,s)=>{const o=Yc*e*t,i=document.createElement("canvas");i.width=o,i.height=o;const a=i.getContext("2d");if(!a)return;a.fillStyle=n?kp.darkMode.solid:kp.lightMode.solid,a.fillRect(0,0,o,o),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(),i.toBlob(u=>{!u||wt.throwToBlob.get()?s():r(u)})}),jE=(t,e)=>{const n=document.createElement("canvas");n.width=t[0],n.height=t[1];const r=n.getContext("2d");return r?(e(r),n.toDataURL()):""};let bS=null;function Vle(){return bS||(bS={white:jE([1,1],t=>{t.fillStyle="#f8f9fa",t.fillRect(0,0,1,1)}),black:jE([1,1],t=>{t.fillStyle="#212529",t.fillRect(0,0,1,1)})}),bS}function s5(t){return Math.ceil(Math.log2(Math.max(1,t)))}function D1(){const t=rs("hash_pattern");return w.useCallback((e,n)=>{const r=s5(e);return db(t,`${n}_${r}`)},[t])}function o5(t){const e=[],r=s5(t);for(let s=0;s<=r;s++)e.push(Math.pow(2,s));return e}function Yle(t){const e=Vle();return o5(t).flatMap(n=>[{zoom:n,url:e.white,theme:"light"},{zoom:n,url:e.black,theme:"dark"}])}function Xle(){const t=z(),e=U("devicePixelRatio",()=>t.getInstanceState().devicePixelRatio,[t]),n=U("maxZoom",()=>Math.ceil(Ht(t.getCameraOptions().zoomSteps)),[t]),[r,s]=w.useState(!1),[o,i]=w.useState(()=>Yle(n)),a=D1();return w.useEffect(()=>{const c=Promise.all(o5(n).flatMap(h=>[AE(e,h,!1).then(f=>({zoom:h,theme:"light",url:URL.createObjectURL(f)})),AE(e,h,!0).then(f=>({zoom:h,theme:"dark",url:URL.createObjectURL(f)}))]));let u=!1;return c.then(h=>{u||(i(h),s(!0))}),()=>{u=!0,s(!1),c.then(h=>{for(const{url:f}of h)URL.revokeObjectURL(f)})}},[e,n]),{defs:d.jsx(d.Fragment,{children:o.map(c=>{const u=a(c.zoom,c.theme);return d.jsx("pattern",{id:u,width:Yc,height:Yc,patternUnits:"userSpaceOnUse",children:d.jsx("image",{href:c.url,width:Yc,height:Yc})},u)})}),isReady:r}}function qle(){const t=z(),e=w.useRef(null),{defs:n,isReady:r}=Xle();return w.useEffect(()=>{if(r&&Ge.isSafari){const s=i5(e.current);s&&t.timers.requestAnimationFrame(()=>{s.style.display="none",t.timers.requestAnimationFrame(()=>{s.style.display=""})})}},[t,r]),d.jsx("g",{ref:e,"data-testid":r?"ready-pattern-fill-defs":void 0,children:n})}function i5(t){return t.classList.contains("tl-html-layer")?t:t.parentElement?i5(t.parentElement):null}const sn=ke.memo(function({theme:e,d:n,color:r,fill:s,scale:o}){switch(s){case"none":return null;case"solid":return d.jsx("path",{fill:e[r].semi,d:n});case"semi":return d.jsx("path",{fill:e.solid,d:n});case"fill":return d.jsx("path",{fill:e[r].fill,d:n});case"pattern":return d.jsx(Zle,{theme:e,color:r,fill:s,d:n,scale:o})}});function Zle({d:t,color:e,theme:n}){const r=z(),s=md(),o=U("zoomLevel",()=>r.getZoomLevel(),[r]),i=D1(),a=r.getZoomLevel()<=.18;return d.jsxs(d.Fragment,{children:[d.jsx("path",{fill:n[e].pattern,d:t}),d.jsx("path",{fill:s?`url(#${i(1,n.id)})`:a?n[e].semi:`url(#${i(o,n.id)})`,d:t})]})}function Qle(t){return t.replace(/\s/g," ")}function rw(t,e,n){const{padding:r=0}=n;if(e.length===0)return null;const s=Z.From(e[0].box);for(const{box:c}of e)s.union(c);const o=r+(n.offsetX??0),i=(n.offsetY??0)+n.fontSize/2+(n.verticalTextAlign==="start"?r:n.verticalTextAlign==="end"?n.height-r-s.height:(Math.ceil(n.height)-s.height)/2);let a=null;const l=[];for(const{text:c,box:u}of e)a!==null&&u.y>a&&l.push(d.jsx("tspan",{alignmentBaseline:"mathematical",x:o,y:u.y+i,children:`
|
|
364
|
-
`},l.length)),l.push(d.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+o,y:u.y+i,unicodeBidi:"plaintext",children:Qle(c)},l.length)),a=u.y;return d.jsx("text",{fontSize:n.fontSize,fontFamily:n.fontFamily,fontStyle:n.fontStyle,fontWeight:n.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,children:l})}function Jle(t,e,n,r){if((t==="start-legacy"||t==="end-legacy")&&n.length!==0){const s=Z.From(n[0].box);for(const{box:o}of n)s.union(o);if(t==="start-legacy")return(r-2*e-s.width)/2;if(t==="end-legacy")return-(r-2*e-s.width)/2}}function ece(t){return t==="start-legacy"||t==="middle-legacy"||t==="end-legacy"}function Pm({fontSize:t,font:e,align:n,verticalAlign:r,text:s,labelColor:o,bounds:i,padding:a=16,stroke:l=!0}){const c=z(),u=zr(),h={fontSize:t,fontFamily:CA[e],textAlign:n,verticalTextAlign:r,width:Math.ceil(i.width),height:Math.ceil(i.height),padding:a,lineHeight:pn.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:o,stroke:void 0,strokeWidth:void 0},f=c.textMeasure.measureTextSpans(s,h),p=Jle(n,a,f,i.width);p&&(h.offsetX=p),h.offsetX+=i.x,h.offsetY+=i.y;const g=rw(c,f,h);let m=null;return l&&(h.fill=u.background,h.stroke=u.background,h.strokeWidth=2,m=rw(c,f,h)),d.jsxs(d.Fragment,{children:[m,g]})}const tce=w.forwardRef(function({isEditing:e,text:n,handleFocus:r,handleChange:s,handleKeyDown:o,handleBlur:i,handleInputPointerDown:a,handleDoubleClick:l},c){return d.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:n,onFocus:r,onChange:s,onKeyDown:o,onBlur:i,onTouchEnd:Ct,onContextMenu:e?Ct:void 0,onPointerDown:a,onDoubleClick:l,onDragStart:xe})});function nce(t,e,n){const r=z(),s=w.useRef(null),o=U("isEditing",()=>r.getEditingShapeId()===t,[r]),i=U("isEditingAnything",()=>!!r.getEditingShapeId(),[r]);w.useEffect(()=>{function u(h){var f;h.shapeId===t&&((f=s.current)==null||f.select())}return r.on("select-all-text",u),()=>{r.off("select-all-text",u)}},[r,t,o]),w.useEffect(()=>{var u,h,f,p;o&&(document.activeElement!==s.current&&((u=s.current)==null||u.focus()),r.getInstanceState().isCoarsePointer&&((h=s.current)==null||h.select()),Ge.isSafari&&((f=s.current)==null||f.blur(),(p=s.current)==null||p.focus()))},[r,o]);const a=w.useCallback(u=>{if(r.getEditingShapeId()===t)switch(u.key){case"Enter":{(u.ctrlKey||u.metaKey)&&r.complete();break}}},[r,t]),l=w.useCallback(u=>{if(r.getEditingShapeId()!==t)return;let h=$l.normalizeText(u.currentTarget.value);const f=h.replace(/\t/g,hl);if(f!==h){const p=u.currentTarget.selectionStart;u.currentTarget.value=f,u.currentTarget.selectionStart=p+(f.length-h.length),u.currentTarget.selectionEnd=p+(f.length-h.length),h=f}r.updateShape({id:t,type:e,props:{text:h}})},[r,t,e]),c=w.useCallback(u=>{r.dispatch({...lr(u),type:"pointer",name:"pointer_down",target:"shape",shape:r.getShape(t)}),Ct(u)},[r,t]);return{rInput:s,handleFocus:Ru,handleBlur:Ru,handleKeyDown:a,handleChange:l,handleInputPointerDown:c,handleDoubleClick:Ct,isEmpty:n.trim().length===0,isEditing:o,isEditingAnything:i}}const Cm=ke.memo(function({shapeId:e,type:n,text:r,labelColor:s,font:o,fontSize:i,lineHeight:a,align:l,verticalAlign:c,wrap:u,isSelected:h,padding:f=0,onKeyDown:p,classNamePrefix:g,style:m,textWidth:v,textHeight:y}){const{rInput:S,isEmpty:b,isEditing:P,isEditingAnything:C,..._}=nce(e,n,r),[E,k]=w.useState(r);w.useEffect(()=>{P||k(r)},[P,r]);const D=$l.normalizeTextForDom(r),T=D.length>0,j=ece(l);if(!P&&!T)return null;const L=g||"tl-text";return d.jsx("div",{className:`${L}-label tl-text-wrapper`,"data-font":o,"data-align":l,"data-hastext":!b,"data-isediting":P,"data-iseditinganything":C,"data-textwrap":!!u,"data-isselected":h,style:{justifyContent:l==="middle"||j?"center":l,alignItems:c==="middle"?"center":c,padding:f,...m},children:d.jsxs("div",{className:`${L}-label__inner tl-text-content__wrapper`,style:{fontSize:i,lineHeight:Math.floor(i*a)+"px",minHeight:Math.floor(i*a)+"px",minWidth:Math.ceil(v||0),color:s,width:v?Math.ceil(v):void 0,height:y?Math.ceil(y):void 0},children:[d.jsx("div",{className:`${L} tl-text tl-text-content`,dir:"auto",children:D.split(`
|
|
365
|
-
`).map((M,O)=>d.jsx("div",{dir:"auto",children:M},O))}),(C||h)&&d.jsx(tce,{ref:S,text:r,isEditing:P,..._,handleKeyDown:p??_.handleKeyDown},E)]})})}),rce=new Ds;function sce(t){return rce.get(t,()=>t.store.createComputedCache("arrowLabelSize",e=>{const n=Es(t,e);let r=0,s=0;const o=n.isStraight?new co({start:x.From(n.start.point),end:x.From(n.end.point)}):new cl({center:x.Cast(n.handleArc.center),start:x.Cast(n.start.point),end:x.Cast(n.end.point),sweepFlag:n.bodyArc.sweepFlag,largeArcFlag:n.bodyArc.largeArcFlag});if(e.props.text.trim()){const i=o.bounds,a=sw(e),{w:l,h:c}=t.textMeasure.measureText(e.props.text,{...pn,fontFamily:Co[e.props.font],fontSize:a,maxWidth:null});r=l,s=c;let u=!1;if(i.width>i.height?(r=Math.max(Math.min(l,64),Math.min(i.width-64,l)),u=!0):r>16*a&&(r=16*a,u=!0),u){const{w:h,h:f}=t.textMeasure.measureText(e.props.text,{...pn,fontFamily:Co[e.props.font],fontSize:a,maxWidth:r});r=h,s=f}}return new x(r,s).addScalar(M1*2*e.props.scale)}))}function R1(t,e){return e.props.text.trim()===""?new x(0,0).addScalar(M1*2*e.props.scale):sce(t).get(e.id)??new x(0,0)}function a5(t){const e=fn[t.props.size];return(ple+(e-fn.s)*2+(e===fn.xl?20:0))*t.props.scale}function oce(t,e,n){const r=R1(t,e),s=a5(e),o=x.Nudge(n.start.point,n.end.point,s),i=x.Nudge(n.end.point,n.start.point,s),a=Pb(o,i,Z.FromCenter(n.middle,r).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[l,c]=a;x.Dist2(l,o)>x.Dist2(c,o)&&([c,l]=a);const u=o.add(x.Sub(n.middle,l)),h=i.add(x.Sub(n.middle,c)),f=x.Dist(n.start.point,u)/n.length,p=x.Dist(n.start.point,h)/n.length;return{start:f,end:p}}function ice(t,e,n){const r=R1(t,e),s=a5(e),o=Math.sign(e.props.bend),i=s/n.handleArc.radius*o,a=x.Angle(n.bodyArc.center,n.start.point)-i,l=x.Angle(n.bodyArc.center,n.end.point)+i,c=ha(n.bodyArc.center,n.bodyArc.radius,a),u=ha(n.bodyArc.center,n.bodyArc.radius,l),h=[],f=DE(n.bodyArc.center,n.bodyArc.radius,a,l,o,Z.FromCenter(c,r).corners);h.push(new vt({points:Z.FromCenter(c,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const p=DE(n.bodyArc.center,n.bodyArc.radius,a,l,o,Z.FromCenter(u,r).corners);h.push(new vt({points:Z.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const E of[...f??[],...p??[],c,u])h.push(new Lb({x:E.x-3,y:E.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const g=(f&&RE(n.start.point,f))??n.middle,m=(p&&RE(n.end.point,p))??n.middle,v=x.Angle(n.bodyArc.center,n.start.point),y=x.Angle(n.bodyArc.center,n.end.point),S=x.Angle(n.bodyArc.center,g),b=x.Angle(n.bodyArc.center,m);if(Xo(v,S,o)>Xo(v,b,o))return{start:.5,end:.5,dbg:h};const P=Xo(v,y,o),C=Xo(v,S,o)/P,_=Xo(v,b,o)/P;return{start:C,end:_,dbg:h}}function wf(t,e){let n;const r=[],s=Es(t,e),o={hasStartBinding:!!s.bindings.start,hasEndBinding:!!s.bindings.end,hasStartArrowhead:s.start.arrowhead!=="none",hasEndArrowhead:s.end.arrowhead!=="none"};if(s.isStraight){const a=oce(t,e,s),l=OE(t,e,a,o);n=x.Lrp(s.start.point,s.end.point,l)}else{const a=ice(t,e,s);a.dbg&&r.push(...a.dbg);const l=OE(t,e,a,o),c=ace(x.Angle(s.bodyArc.center,s.start.point),x.Angle(s.bodyArc.center,s.end.point),Math.sign(e.props.bend),l);n=ha(s.bodyArc.center,s.bodyArc.radius,c)}const i=R1(t,e);return{box:Z.FromCenter(n,i),debugGeom:r}}function OE(t,e,n,r){const{hasEndArrowhead:s,hasEndBinding:o,hasStartBinding:i,hasStartArrowhead:a}=r,l=d5(t,e);let c=Bt(e.props.labelPosition,a||i?n.start:0,s||o?n.end:1);const u=Math.min(.02,500/l*.02);return c=c>=.5-u&&c<=.5+u?.5:c,c}function DE(t,e,n,r,s,o){const i=_x(t,e,o),a=Xo(n,r,s);return i==null?void 0:i.filter(l=>{const c=Xo(n,x.Angle(t,l),s);return c>=0&&c<=a})}function RE(t,e){let n=null,r=-1/0;for(const s of e){const o=x.Dist2(t,s);o>r&&(n=s,r=o)}return n}function ace(t,e,n,r){const s=Xo(t,e,n);return t+s*r*n*-1}function sw(t){return fle[t.props.size]*t.props.scale}function lce(t,e,n){const r=e==="end"?t.end.point:t.start.point,s=e==="end"?t.start.point:t.end.point,o=t.isStraight?x.Dist(s,r):Math.abs(t.bodyArc.length),i=Math.max(Math.min(o/5,n*3),n);let a;if(t.isStraight)a=x.Nudge(r,s,i);else{const l=XZ(r,i,t.handleArc.center,t.handleArc.radius);a=e==="end"?t.handleArc.sweepFlag?l[0]:l[1]:t.handleArc.sweepFlag?l[1]:l[0]}return x.IsNaN(a)&&(a=t.start.point),{point:r,int:a}}function cce({point:t,int:e}){const n=x.RotWith(e,t,De/6),r=x.RotWith(e,t,-De/6);return`M ${n.x} ${n.y} L ${t.x} ${t.y} L ${r.x} ${r.y}`}function uce({point:t,int:e}){const n=x.RotWith(e,t,De/6),r=x.RotWith(e,t,-De/6);return`M ${n.x} ${n.y} L ${r.x} ${r.y} L ${t.x} ${t.y} Z`}function dce({point:t,int:e}){const n=x.Sub(e,t).div(2),r=x.Add(t,x.Rot(n,Ze)),s=x.Sub(t,x.Rot(n,Ze));return`M ${r.x} ${r.y} L ${e.x} ${e.y} L ${s.x} ${s.y} Z`}function hce({point:t,int:e}){const n=x.Lrp(t,e,.45),r=x.Dist(n,t);return`M ${n.x-r},${n.y}
|
|
366
|
-
a ${r},${r} 0 1,0 ${r*2},0
|
|
367
|
-
a ${r},${r} 0 1,0 -${r*2},0 `}function fce({point:t,int:e}){const n=x.Lrp(t,e,.75),r=x.RotWith(n,t,De/4),s=x.RotWith(n,t,-De/4),o=x.Lrp(r,s,.5);return o.add(x.Sub(o,t)),`M ${o.x} ${o.y} L ${s.x} ${s.y} ${t.x} ${t.y} L ${r.x} ${r.y} Z`}function pce({int:t,point:e}){const n=x.Lrp(e,t,.85),r=x.Sub(n,e).div(2),s=x.Add(e,x.Rot(r,Ze)),o=x.Sub(e,x.Rot(r,Ze)),i=x.Add(n,x.Rot(r,Ze)),a=x.Sub(n,x.Rot(r,Ze));return`M ${s.x} ${s.y} L ${i.x} ${i.y} L ${a.x} ${a.y} L ${o.x} ${o.y} Z`}function gce({int:t,point:e}){const n=x.Sub(t,e).div(2),r=x.Add(e,x.Rot(n,Ze)),s=x.Sub(e,x.Rot(n,Ze));return`M ${r.x} ${r.y} L ${s.x} ${s.y}`}function Zp(t,e,n){const r=e==="end"?t.end.arrowhead:t.start.arrowhead;if(r==="none")return;const s=lce(t,e,n);if(s){switch(r){case"bar":return gce(s);case"square":return pce(s);case"diamond":return fce(s);case"dot":return hce(s);case"inverted":return dce(s);case"arrow":return cce(s);case"triangle":return uce(s)}return""}}function mce(t){const{start:e,end:n,handleArc:{radius:r,largeArcFlag:s,sweepFlag:o}}=t;return`M${e.handle.x},${e.handle.y} A${r} ${r} 0 ${s} ${o} ${n.handle.x},${n.handle.y}`}function l5(t){const{start:e,end:n,bodyArc:{radius:r,largeArcFlag:s,sweepFlag:o}}=t;return`M${e.point.x},${e.point.y} A${r} ${r} 0 ${s} ${o} ${n.point.x},${n.point.y}`}function c5(t,e){return`M${t.x},${t.y}L${e.x},${e.y}`}function yce(t){return c5(t.start.handle,t.end.handle)}function u5(t){return c5(t.start.point,t.end.point)}class bf extends ss{constructor(){super(...arguments);I(this,"_resizeInitialBindings",new Ds)}canEdit(){return!0}canBind({toShapeType:n}){return n!=="arrow"}canSnap(){return!1}hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsBg(){return!0}hideSelectionBoundsFg(){return!0}canBeLaidOut(n){const r=Un(this.editor,n);return!r.start&&!r.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(n){const r=Es(this.editor,n),s=[],o=r.isStraight?new co({start:x.From(r.start.point),end:x.From(r.end.point)}):new cl({center:x.Cast(r.handleArc.center),start:x.Cast(r.start.point),end:x.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});let i;if(n.props.text.trim()){const a=wf(this.editor,n);s.push(...a.debugGeom),i=new Fs({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new $r({children:[...i?[o,i]:[o],...s]})}getHandles(n){const r=Es(this.editor,n);return[{id:"start",type:"vertex",index:"a0",x:r.start.handle.x,y:r.start.handle.y},{id:"middle",type:"virtual",index:"a2",x:r.middle.x,y:r.middle.y},{id:"end",type:"vertex",index:"a3",x:r.end.handle.x,y:r.end.handle.y}].filter(Boolean)}getText(n){return n.props.text}onHandleDrag(n,{handle:r,isPrecise:s}){const o=r.id,i=Un(this.editor,n);if(o==="middle"){const{start:_,end:E}=dl(this.editor,n,i),k=x.Sub(E,_),D=x.Per(k),T=x.Med(E,_),j=x.Sub(T,D),L=x.Add(T,D),M=x.NearestPointOnLineSegment(j,L,r,!1);let O=x.Dist(M,T);return x.Clockwise(M,E,T)&&(O*=-1),{id:n.id,type:n.type,props:{bend:O}}}const a={id:n.id,type:"arrow",props:{}},l=i[o],u=i[o==="start"?"end":"start"];if(this.editor.inputs.ctrlKey)return yf(this.editor,n,o),a.props[o]={x:r.x,y:r.y},a;const h=this.editor.getShapePageTransform(n.id).applyToPoint(r),f=this.editor.getShapeAtPoint(h,{hitInside:!0,hitFrameInside:!0,margin:0,filter:_=>!_.isLocked&&this.editor.canBindShapes({fromShape:n,toShape:_,binding:"arrow"})});if(!f){yf(this.editor,n,o);const _=is(new x(r.x,r.y),this.editor);return a.props[o]={x:_.x,y:_.y},a}const p=this.editor.getShapeGeometry(f),g=Z.ZeroFix(p.bounds),v=this.editor.getShapePageTransform(a.id).applyToPoint(r),y=this.editor.getPointInShapeSpace(f,v);let S=s;S||(!l||l&&f.id!==l.toId)&&(S=this.editor.inputs.pointerVelocity.len()<.5),s||(p.isClosed||(S=!0),u&&f.id===u.toId&&u.props.isPrecise&&(S=!0));const b={x:(y.x-g.minX)/g.width,y:(y.y-g.minY)/g.height};S&&x.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 P={terminal:o,normalizedAnchor:b,isPrecise:S,isExact:this.editor.inputs.altKey};Oc(this.editor,n,f.id,P),this.editor.setHintingShapes([f.id]);const C=Un(this.editor,n);return C.start&&C.end&&C.start.toId===C.end.toId&&x.Equals(C.start.props.normalizedAnchor,C.end.props.normalizedAnchor)&&Oc(this.editor,n,C.end.toId,{...C.end.props,normalizedAnchor:{x:C.end.props.normalizedAnchor.x+.05,y:C.end.props.normalizedAnchor.y}}),a}onTranslateStart(n){const r=Un(this.editor,n),s=dl(this.editor,n,r),o=this.editor.getShapePageTransform(n.id),i=this.editor.getSelectedShapeIds();if(!(r.start&&(i.includes(r.start.toId)||this.editor.isAncestorSelected(r.start.toId))||r.end&&(i.includes(r.end.toId)||this.editor.isAncestorSelected(r.end.toId)))){$E.set(n,{pagePosition:o.applyToPoint(n),terminalBindings:sd(s,(a,l)=>{const c=r[a];return c?{binding:c,shapePosition:l,pagePosition:o.applyToPoint(l)}:null})}),r.start&&(qp({editor:this.editor,arrow:n,terminal:"start",useHandle:!0}),n=this.editor.getShape(n.id)),r.end&&qp({editor:this.editor,arrow:n,terminal:"end",useHandle:!0});for(const a of["start","end"]){const l=r[a];l&&this.editor.updateBinding({...l,props:{...l.props,isPrecise:!0}})}}}onTranslate(n,r){const s=$E.get(n);if(!s)return;const o=this.editor.getShapePageTransform(r.id),i=x.Sub(o.applyToPoint(r),s.pagePosition);for(const a of Object.values(s.terminalBindings)){if(!a)continue;const l=x.Add(a.pagePosition,x.Mul(i,.5)),c=this.editor.getShapeAtPoint(l,{hitInside:!0,hitFrameInside:!0,margin:0,filter:u=>!u.isLocked&&this.editor.canBindShapes({fromShape:r,toShape:u,binding:"arrow"})});if((c==null?void 0:c.id)===a.binding.toId){const u=Z.ZeroFix(this.editor.getShapeGeometry(c).bounds),h=this.editor.getPointInShapeSpace(c,l),f={x:(h.x-u.minX)/u.width,y:(h.y-u.minY)/u.height};Oc(this.editor,r,c.id,{...a.binding.props,normalizedAnchor:f,isPrecise:!0})}else yf(this.editor,r,a.binding.props.terminal)}}onResize(n,r){const{scaleX:s,scaleY:o}=r,i=this._resizeInitialBindings.get(n,()=>Un(this.editor,n)),a=dl(this.editor,n,i),{start:l,end:c}=nt(n.props);let{bend:u}=n.props;i.start||(l.x=a.start.x*s,l.y=a.start.y*o),i.end||(c.x=a.end.x*s,c.y=a.end.y*o);const h=Math.abs(s),f=Math.abs(o),p=i!=null&&i.start?x.From(i.start.props.normalizedAnchor):null,g=i!=null&&i.end?x.From(i.end.props.normalizedAnchor):null;return s<0&&o>=0?(u!==0&&(u*=-1,u*=Math.max(h,f)),p&&(p.x=1-p.x),g&&(g.x=1-g.x)):s>=0&&o<0?(u!==0&&(u*=-1,u*=Math.max(h,f)),p&&(p.y=1-p.y),g&&(g.y=1-g.y)):s>=0&&o>=0?u!==0&&(u*=Math.max(h,f)):s<0&&o<0&&(u!==0&&(u*=Math.max(h,f)),p&&(p.x=1-p.x,p.y=1-p.y),g&&(g.x=1-g.x,g.y=1-g.y)),i.start&&p&&Oc(this.editor,n,i.start.toId,{...i.start.props,normalizedAnchor:p.toJson()}),i.end&&g&&Oc(this.editor,n,i.end.toId,{...i.end.props,normalizedAnchor:g.toJson()}),{props:{start:l,end:c,bend:u}}}onDoubleClickHandle(n,r){switch(r.id){case"start":return{id:n.id,type:n.type,props:{...n.props,arrowheadStart:n.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:n.id,type:n.type,props:{...n.props,arrowheadEnd:n.props.arrowheadEnd==="none"?"arrow":"none"}}}}component(n){const r=zr(),s=this.editor.getOnlySelectedShape(),o=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getIsReadonly(),i=Es(this.editor,n);if(!(i!=null&&i.isValid))return null;const a=wf(this.editor,n),l=n.id===this.editor.getOnlySelectedShapeId(),u=this.editor.getEditingShapeId()===n.id||n.props.text;return d.jsxs(d.Fragment,{children:[d.jsx(mi,{style:{minWidth:50,minHeight:50},children:d.jsx(LE,{shape:n,shouldDisplayHandles:o&&(s==null?void 0:s.id)===n.id})}),u&&d.jsx(Cm,{shapeId:n.id,classNamePrefix:"tl-arrow",type:"arrow",font:n.props.font,fontSize:sw(n),lineHeight:pn.lineHeight,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:r[n.props.labelColor].solid,textWidth:a.box.w-M1*2*n.props.scale,isSelected:l,padding:0,style:{transform:`translate(${a.box.center.x}px, ${a.box.center.y}px)`}})]})}indicator(n){const r=Zg(n.id),s=rs(n.id+"_clip"),o=Es(this.editor,n);if(!o)return null;const{start:i,end:a}=dl(this.editor,n,o==null?void 0:o.bindings),l=this.editor.getShapeGeometry(n),c=l.bounds,u=n.props.text.trim()?l.children[1]:null;if(x.Equals(i,a))return null;const h=fn[n.props.size]*n.props.scale,f=o.start.arrowhead&&Zp(o,"start",h),p=o.end.arrowhead&&Zp(o,"end",h),g=o.isStraight?u5(o):l5(o),m=f&&o.start.arrowhead!=="arrow"||p&&o.end.arrowhead!=="arrow"||!!u;if(r&&u)return d.jsx("rect",{x:N(u.x),y:N(u.y),width:u.w,height:u.h,rx:3.5*n.props.scale,ry:3.5*n.props.scale});const v=!(o.start.arrowhead==="none"||o.start.arrowhead==="arrow"),y=!(o.end.arrowhead==="none"||o.end.arrowhead==="arrow");return d.jsxs("g",{children:[m&&d.jsx("defs",{children:d.jsx(h5,{hasText:n.props.text.trim().length>0,bounds:c,labelBounds:u?u.getBounds():new Z(0,0,0,0),as:v&&f?f:"",ae:y&&p?p:""})}),d.jsxs("g",{style:{clipPath:m?`url(#${s})`:void 0,WebkitClipPath:m?`url(#${s})`:void 0},children:[m&&d.jsx("rect",{x:c.minX-100,y:c.minY-100,width:c.width+200,height:c.height+200,opacity:0}),d.jsx("path",{d:g})]}),f&&d.jsx("path",{d:f}),p&&d.jsx("path",{d:p}),u&&d.jsx("rect",{x:N(u.x),y:N(u.y),width:u.w,height:u.h,rx:3.5,ry:3.5})]})}onEditEnd(n){const{id:r,type:s,props:{text:o}}=n;o.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:s,props:{text:o.trimEnd()}}])}toSvg(n,r){r.addExportDef(j1(n.props.fill)),n.props.text&&r.addExportDef(bm(n.props.font));const s=ko(r),o=1/n.props.scale;return d.jsxs("g",{transform:`scale(${o})`,children:[d.jsx(LE,{shape:n,shouldDisplayHandles:!1}),d.jsx(Pm,{fontSize:sw(n),font:n.props.font,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:s[n.props.labelColor].solid,bounds:wf(this.editor,n).box.clone().expandBy(-4.25*n.props.scale),padding:0})]})}getCanvasSvgDefs(){return[O1(),{key:"arrow:dot",component:Sce},{key:"arrow:cross",component:vce}]}getInterpolatedProps(n,r,s){return{...s>.5?r.props:n.props,scale:_e(n.props.scale,r.props.scale,s),start:{x:_e(n.props.start.x,r.props.start.x,s),y:_e(n.props.start.y,r.props.start.y,s)},end:{x:_e(n.props.end.x,r.props.end.x,s),y:_e(n.props.end.y,r.props.end.y,s)},bend:_e(n.props.bend,r.props.bend,s),labelPosition:_e(n.props.labelPosition,r.props.labelPosition,s)}}}I(bf,"type","arrow"),I(bf,"props",IA),I(bf,"migrations",EA);function d5(t,e){const n=Es(t,e);return n.isStraight?x.Dist(n.start.handle,n.end.handle):Math.abs(n.handleArc.length)}const LE=Zt(function({shape:e,shouldDisplayHandles:n}){const r=z(),s=zr(),o=Es(r,e),i=Z.ZeroFix(r.getShapeGeometry(e).bounds),a=Un(r,e),l=U("force solid",()=>r.getZoomLevel()<.2,[r]),c=rs(e.id+"_clip"),u=rs("arrowhead-dot"),h=rs("arrowhead-cross");if(!(o!=null&&o.isValid))return null;const f=fn[e.props.size]*e.props.scale,p=o.start.arrowhead&&Zp(o,"start",f),g=o.end.arrowhead&&Zp(o,"end",f),m=o.isStraight?u5(o):l5(o);let v=null;if(n){const _=2/r.getZoomLevel(),{strokeDasharray:E,strokeDashoffset:k}=qr(d5(r,e),_,{end:"skip",start:"skip",lengthRatio:2.5});v=a.start||a.end?d.jsx("path",{className:"tl-arrow-hint",d:o.isStraight?yce(o):mce(o),strokeDasharray:E,strokeDashoffset:k,strokeWidth:_,markerStart:a.start?a.start.props.isExact?"":a.start.props.isPrecise?`url(#${h})`:`url(#${u})`:"",markerEnd:a.end?a.end.props.isExact?"":a.end.props.isPrecise?`url(#${h})`:`url(#${u})`:"",opacity:.16}):null}const{strokeDasharray:y,strokeDashoffset:S}=qr(o.isStraight?o.length:Math.abs(o.bodyArc.length),f,{style:e.props.dash,forceSolid:l}),b=wf(r,e),P=!(o.start.arrowhead==="none"||o.start.arrowhead==="arrow"),C=!(o.end.arrowhead==="none"||o.end.arrowhead==="arrow");return d.jsxs(d.Fragment,{children:[d.jsx("defs",{children:d.jsx("clipPath",{id:c,children:d.jsx(h5,{hasText:e.props.text.trim().length>0,bounds:i,labelBounds:b.box,as:P&&p?p:"",ae:C&&g?g:""})})}),d.jsxs("g",{fill:"none",stroke:s[e.props.color].solid,strokeWidth:f,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[v,d.jsxs("g",{style:{clipPath:`url(#${c})`,WebkitClipPath:`url(#${c})`},children:[d.jsx("rect",{x:N(i.minX-100),y:N(i.minY-100),width:N(i.width+200),height:N(i.height+200),opacity:0}),d.jsx("path",{d:m,strokeDasharray:y,strokeDashoffset:S})]}),p&&P&&e.props.fill!=="none"&&d.jsx(sn,{theme:s,d:p,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),g&&C&&e.props.fill!=="none"&&d.jsx(sn,{theme:s,d:g,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),p&&d.jsx("path",{d:p}),g&&d.jsx("path",{d:g})]})]})});function h5({hasText:t,bounds:e,labelBounds:n,as:r,ae:s}){const o=`M${N(e.minX-100)},${N(e.minY-100)} h${e.width+200} v${e.height+200} h-${e.width+200} Z`,i=`M${N(n.minX)},${N(n.minY)} v${n.height} h${n.width} v-${n.height} Z`;return d.jsx("path",{d:`${o}${t?i:""}${r}${s}`})}const $E=new WeakMap;function Sce(){const t=rs("arrowhead-dot");return d.jsx("marker",{id:t,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:d.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function vce(){const t=rs("arrowhead-cross");return d.jsxs("marker",{id:t,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[d.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),d.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const FE="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 Fl({url:t}){const e=z(),n=U("zoomLevel",()=>e.getZoomLevel()<.32,[e]);return d.jsx("a",{className:ce("tl-hyperlink-button",{"tl-hyperlink-button__hidden":n}),href:t,target:"_blank",rel:"noopener noreferrer",onPointerDown:Ct,onPointerUp:Ct,title:t,draggable:!1,children:d.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${FE}") center 100% / 100% no-repeat`,WebkitMask:`url("${FE}") center 100% / 100% no-repeat`}})})}const NE="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",xce=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function Qp(t){return xce.map(n=>{const{offsetX:r,offsetY:s,blur:o,spread:i,color:a}=n,l=new x(r,s),{x:c,y:u}=l.rot(-t);return`${c}px ${u}px ${o}px ${i}px ${a}`}).join(", ")}const wce=300,f5=320,bce=46,Pce=101;class Pf extends oc{canResize(){return!1}hideSelectionBoundsFg(){return!0}getText(e){return e.props.url}getDefaultProps(){return{url:"",w:wce,h:f5,assetId:null}}component(e){return d.jsx(Cce,{shape:e,util:this})}indicator(e){return d.jsx("rect",{width:N(e.props.w),height:N(e.props.h),rx:"6",ry:"6"})}onBeforeCreate(e){return zE(this.editor,e)}onBeforeUpdate(e,n){if(e.props.url!==n.props.url)if(gr.isValid(n.props.url))Ice(this.editor,n);else return{...n,props:{...n.props,url:e.props.url}};if(e.props.assetId!==n.props.assetId)return zE(this.editor,n)}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r)}}}I(Pf,"type","bookmark"),I(Pf,"props",OA),I(Pf,"migrations",DA);function Cce({shape:t,util:e}){const n=t.props.assetId?e.editor.getAsset(t.props.assetId):null,r=!!md()&&Ge.isSafari,s=e.editor.getShapePageTransform(t).rotation(),o=_ce(t),[i,a]=w.useState(!0),l=()=>a(!1);return d.jsx(hi,{children:d.jsxs("div",{className:ce("tl-bookmark__container",r&&"tl-bookmark__container--safariExport"),style:{boxShadow:r?void 0:Qp(s),maxHeight:t.props.h},children:[(!n||n.props.image)&&d.jsxs("div",{className:"tl-bookmark__image_container",children:[n?d.jsx("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:n==null?void 0:n.props.image,alt:(n==null?void 0:n.props.title)||""}):d.jsx("div",{className:"tl-bookmark__placeholder"}),(n==null?void 0:n.props.image)&&d.jsx(Fl,{url:t.props.url})]}),d.jsxs("div",{className:"tl-bookmark__copy_container",children:[n!=null&&n.props.title?d.jsx("h2",{className:"tl-bookmark__heading",children:xle(n.props.title)}):null,n!=null&&n.props.description&&(n!=null&&n.props.image)?d.jsx("p",{className:"tl-bookmark__description",children:n.props.description}):null,d.jsxs("a",{className:"tl-bookmark__link",href:t.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:Ct,onPointerUp:Ct,onClick:Ct,children:[i&&(n!=null&&n.props.favicon)?d.jsx("img",{className:"tl-bookmark__favicon",src:n==null?void 0:n.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",onError:l,alt:`favicon of ${o}`}):d.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${NE}") center 100% / 100% no-repeat`,WebkitMask:`url("${NE}") center 100% / 100% no-repeat`}}),d.jsx("span",{children:o})]})]})]})})}function zE(t,e){const n=e.props.assetId?t.getAsset(e.props.assetId):null;let r=f5;return n&&(n.props.image||(n.props.title?r=Pce:r=bce)),{...e,props:{...e.props,h:r}}}const _ce=t=>{try{return new URL(t.props.url).hostname.replace(/^www\./,"")}catch{return t.props.url}};function Ice(t,e){const{url:n}=e.props,r=Yo.createId(Gv(n));t.getAsset(r)?e.props.assetId!==r&&t.updateShapes([{id:e.id,type:e.type,props:{assetId:r}}]):(t.updateShapes([{id:e.id,type:e.type,props:{assetId:null}}]),Ece(t,e))}const Ece=vg(async(t,e)=>{if(t.isDisposed)return;const{url:n}=e.props,r=await t.getAssetForExternalContent({type:"url",url:n});r&&t.run(()=>{t.createAssets([r]),t.updateShapes([{id:e.id,type:e.type,props:{assetId:r.id}}])})},500);function va(t,e=!1){const n=t.length;if(n<2)return"";let r=t[0].point,s=t[1].point;if(n===2)return`M${je(r)}L${je(s)}`;let o="";for(let i=2,a=n-1;i<a;i++)r=t[i].point,s=t[i+1].point,o+=Bn(r,s);return e?`M${Bn(t[0].point,t[1].point)}Q${je(t[1].point)}${Bn(t[1].point,t[2].point)}T${o}${Bn(t[n-1].point,t[0].point)}${Bn(t[0].point,t[1].point)}Z`:`M${je(t[0].point)}Q${je(t[1].point)}${Bn(t[1].point,t[2].point)}${t.length>3?"T":""}${o}L${je(t[n-1].point)}`}function kce(t,e={}){const{start:n={},end:r={}}=e,{cap:s=!0}=n,{cap:o=!0}=r;Le(!n.taper&&!r.taper,"cap taper not supported here"),Le(!n.easing&&!r.easing,"cap easing not supported here"),Le(s&&o,"cap must be true");const i=Bs(t,e);xm(i,e);const a=Tce(i);let l="";for(const c of a)l+=Ace(c,e);return l}function Tce(t){if(t.length<=2)return[t];const e=[];let n=[t[0]],r=x.Sub(t[1].point,t[0].point).uni(),s,o,i,a,l;for(let c=1,u=t.length;c<u-1;c++){if(i=t[c-1],a=t[c],l=t[c+1],s=x.Sub(l.point,a.point).uni(),o=x.Dpr(r,s),r=s,o<-.8){const h={...a,point:a.input};n.push(h),e.push(PS(n)),n=[h];continue}if(n.push(a),!(o>.7)&&(x.Dist2(i.point,a.point)+x.Dist2(a.point,l.point))/((i.radius+a.radius+l.radius)/3)**2<1.5){n.push(a),e.push(PS(n)),n=[a];continue}}return n.push(t[t.length-1]),e.push(PS(n)),e}function PS(t){const e=t[0];let n;for(;t.length>2&&(n=t[1],x.Dist2(e.point,n.point)<((e.radius+n.radius)/2*.5)**2);)t.splice(1,1);const r=t[t.length-1];let s;for(;t.length>2&&(s=t[t.length-2],x.Dist2(r.point,s.point)<((r.radius+s.radius)/2*.5)**2);)t.splice(t.length-2,1);return t.length>1&&(t[0]={...t[0],vector:x.Sub(t[0].point,t[1].point).uni()},t[t.length-1]={...t[t.length-1],vector:x.Sub(t[t.length-2].point,t[t.length-1].point).uni()}),t}function Mce(t,e,n){return"M "+t+" "+e+" m -"+n+", 0 a "+n+","+n+" 0 1,1 "+n*2+",0 a "+n+","+n+" 0 1,1 -"+n*2+",0"}function Ace(t,e={}){if(t.length===0)return"";if(t.length===1)return Mce(t[0].point.x,t[0].point.y,t[0].radius);const{left:n,right:r}=V$(t,e);r.reverse();let s=`M${je(n[0])}T`;for(let o=1;o<n.length;o++)s+=Bn(n[o-1],n[o]);{const o=t[t.length-1],i=o.radius,a=o.vector.clone().per().neg(),l=x.Add(o.point,x.Mul(a,i)),c=x.Add(o.point,x.Mul(a,-i));s+=`${je(l)}A${N(i)},${N(i)} 0 0 1 ${je(c)}T`}for(let o=1;o<r.length;o++)s+=Bn(r[o-1],r[o]);{const o=t[0],i=o.radius,a=o.vector.clone().per(),l=x.Add(o.point,x.Mul(a,i)),c=x.Add(o.point,x.Mul(a,-i));s+=`${je(l)}A${N(i)},${N(i)} 0 0 1 ${je(c)}Z`}return s}const p5=(t,e,n)=>{const r=[],s=[];t.forEach(c=>r.push(...c.points)),e.forEach(c=>s.push(...c.points));const o=Math.max(r.length,s.length),i=[],a=[];for(let c=0;c<o;c++)i.push(r[c]||r[r.length-1]),a.push(s[c]||s[s.length-1]);return[{type:"free",points:i.map((c,u)=>{let h=.5;return a[u].z!==void 0&&c.z!==void 0&&(h=_e(c.z,a[u].z,n)),{x:_e(c.x,a[u].x,n),y:_e(c.y,a[u].y,n),z:h}})}]},jce=t=>t*.65+mX(t*De/2)*.35,Oce=t=>({size:t,thinning:.5,streamline:Ol(t,[9,16],[.64,.74],!0),smoothing:.62,easing:Dt.easeOutSine,simulatePressure:!0}),Dce=t=>({size:1+t*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:jce}),BE=t=>({size:t,thinning:0,streamline:Ol(t,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:Dt.linear}),Rce=t=>({size:t,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:Dt.linear});function L1({strokeWidth:t,showAsComplete:e}){return{size:1+t,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:Dt.easeOutSine,last:e}}function ow(t,e,n,r){const s=t.isComplete||n;return r?t.isPen?{...Rce(e),last:s}:{...BE(e),last:s}:t.dash==="draw"?t.isPen?{...Dce(e),last:s}:{...Oce(e),last:s}:{...BE(e),last:s}}function Nl(t){const e=[];for(const n of t)if(n.type==="free"||n.points.length<2)e.push(...n.points.map(x.Cast));else{const r=Math.max(4,Math.floor(x.Dist(n.points[0],n.points[1])/16));e.push(...x.PointsBetween(n.points[0],n.points[1],r))}return e}function Lce(t,e,n){return{draw:"none",solid:"none",dotted:`${n} ${e*2}`,dashed:`${e*2} ${e*2}`}[t.props.dash]}class Cf extends ss{hideResizeHandles(e){return CS(e)}hideRotateHandle(e){return CS(e)}hideSelectionBoundsFg(e){return CS(e)}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1}}getGeometry(e){const n=Nl(e.props.segments),r=(fn[e.props.size]+1)*e.props.scale;if(e.props.segments.length===1){const o=Z.FromPoints(n);if(o.width<r*2&&o.height<r*2)return new Lb({x:-r,y:-r,radius:r,isFilled:!0})}const s=Bs(n,ow(e.props,r,e.props.isPen,!0)).map(o=>o.point);return e.props.isClosed?new vt({points:s,isFilled:e.props.fill!=="none"}):new nc({points:s})}component(e){return d.jsx(mi,{children:d.jsx(UE,{shape:e})})}indicator(e){var u;const n=Nl(e.props.segments);let r=(fn[e.props.size]+1)*e.props.scale;const s=this.editor.getZoomLevel();!(s<.5&&s<1.5/r)&&!e.props.isPen&&e.props.dash==="draw"&&n.length===1&&(r+=cs(e.id)()*(r/6));const i=e.props.isComplete||((u=Ht(e.props.segments))==null?void 0:u.type)==="straight",a=ow(e.props,r,i,!0),l=Bs(n,a),c=l.length>1?va(l,e.props.isClosed):g5(n[0],r);return d.jsx("path",{d:c})}toSvg(e,n){n.addExportDef(j1(e.props.fill));const r=1/e.props.scale;return d.jsx("g",{transform:`scale(${r})`,children:d.jsx(UE,{shape:e,zoomOverride:1})})}getCanvasSvgDefs(){return[O1()]}onResize(e,n){const{scaleX:r,scaleY:s}=n,o=[];for(const i of e.props.segments)o.push({...i,points:i.points.map(({x:a,y:l,z:c})=>({x:io(r*a),y:io(s*l),z:c}))});return{props:{segments:o}}}expandSelectionOutlinePx(e){const n=e.props.dash==="draw"?1.6:1;return fn[e.props.size]*n/2*e.props.scale}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,segments:p5(e.props.segments,n.props.segments,r),scale:_e(e.props.scale,n.props.scale,r)}}}I(Cf,"type","draw"),I(Cf,"props",LA),I(Cf,"migrations",$A);function g5(t,e){const n=(e+1)*.5;return`M ${t.x} ${t.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function CS(t){return t.props.segments.length===1&&t.props.segments[0].points.length<2}function UE({shape:t,zoomOverride:e}){var p;const n=zr(),r=z(),s=Nl(t.props.segments),o=t.props.isComplete||((p=Ht(t.props.segments))==null?void 0:p.type)==="straight";let i=(fn[t.props.size]+1)*t.props.scale;const a=U("force solid",()=>{const g=e??r.getZoomLevel();return g<.5&&g<1.5/i},[r,i,e]),l=U("dot adjustment",()=>(e??r.getZoomLevel())<.2?0:.1,[r,e]);!a&&!t.props.isPen&&t.props.dash==="draw"&&s.length===1&&(i+=cs(t.id)()*(i/6));const c=ow(t.props,i,o,a);if(!a&&t.props.dash==="draw")return d.jsxs(d.Fragment,{children:[t.props.isClosed&&t.props.fill&&s.length>1?d.jsx(sn,{d:va(Bs(s,c),t.props.isClosed),theme:n,color:t.props.color,fill:t.props.isClosed?t.props.fill:"none",scale:t.props.scale}):null,d.jsx("path",{d:kce(s,c),strokeLinecap:"round",fill:n[t.props.color].solid})]});const u=Bs(s,c),h=u.length<2,f=h?g5(s[0],0):va(u,t.props.isClosed);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{d:f,theme:n,color:t.props.color,fill:h||t.props.isClosed?t.props.fill:"none",scale:t.props.scale}),d.jsx("path",{d:f,strokeLinecap:"round",fill:h?n[t.props.color].solid:"none",stroke:n[t.props.color].solid,strokeWidth:i,strokeDasharray:h?"none":Lce(t,i,l),strokeDashoffset:"0"})]})}function $ce(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Fce(t,e){const n=ge(e);if(!n)return;const r=n.host.replace("www.","");for(const s of t)if(m5(s.hostnames,r)){const o=s.fromEmbedUrl(e);if(o)return{definition:s,url:o,embedUrl:e}}}const Nce=t=>t.split("*").map(e=>$ce(e)).join(".+"),m5=(t,e)=>!!t.find(n=>{const r=new RegExp(Nce(n));return e.match(r)});function zce(t,e){const n=ge(e);if(!n)return;const r=n.host.replace("www.","");for(const s of t)if(m5(s.hostnames,r)){const o=s.toEmbedUrl(e);if(o)return{definition:s,embedUrl:o,url:e}}}function Bce(t,e){try{return zce(t,e)??Fce(t,e)}catch{return}}const Uce=t=>Object.entries(t).filter(([e,n])=>n).map(([e])=>e).join(" "),so=class so extends oc{static setEmbedDefinitions(e){so.embedDefinitions=e}getEmbedDefinitions(){return so.embedDefinitions}getEmbedDefinition(e){return Bce(so.embedDefinitions,e)}getText(e){return e.props.url}hideSelectionBoundsFg(e){return!this.canResize(e)}canEdit(){return!0}canResize(e){var n,r;return!!((r=(n=this.getEmbedDefinition(e.props.url))==null?void 0:n.definition)!=null&&r.doesResize)}canEditInReadOnly(){return!0}getDefaultProps(){return{w:300,h:300,url:""}}isAspectRatioLocked(e){const n=this.getEmbedDefinition(e.props.url);return(n==null?void 0:n.definition.isAspectRatioLocked)??!1}onResize(e,n){const r=this.isAspectRatioLocked(e),s=this.getEmbedDefinition(e.props.url);let o=(s==null?void 0:s.definition.minWidth)??200,i=(s==null?void 0:s.definition.minHeight)??200;if(r){const a=e.props.w/e.props.h;a>1?o*=a:i/=a}return qg(e,n,{minWidth:o,minHeight:i})}component(e){const n=md(),{w:r,h:s,url:o}=e.props,i=Zg(e.id),a=this.getEmbedDefinition(o),l=U("is hovering",()=>{const{editingShapeId:p,hoveredShapeId:g}=this.editor.getCurrentPageState();if(p&&g!==p){const m=this.editor.getShape(p);if(m&&this.editor.isShapeOfType(m,"embed"))return!0}return!1},[]),c=this.editor.getShapePageTransform(e).rotation();if(n)return d.jsx(hi,{className:"tl-embed-container",id:e.id,children:d.jsx("div",{className:"tl-embed",style:{border:0,boxShadow:Qp(c),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:(a==null?void 0:a.definition.backgroundColor)??"var(--color-background)",width:r,height:s}})});const u=i||l;if(typeof window<"u"&&(window!==window.top||window.self!==window.parent)&&(a==null?void 0:a.definition.type)==="tldraw")return null;if((a==null?void 0:a.definition.type)==="github_gist"){const p=a.url.split("/").pop();if(!p)throw Error("No gist id!");return d.jsx(hi,{className:"tl-embed-container",id:e.id,children:d.jsx(Hce,{id:p,width:N(r),height:N(s),isInteractive:u,pageRotation:c})})}const f=Uce({...Xoe,...(a==null?void 0:a.definition.overridePermissions)??{}});return d.jsx(hi,{className:"tl-embed-container",id:e.id,children:a!=null&&a.definition?d.jsx("iframe",{className:"tl-embed",sandbox:f,src:a.embedUrl,width:N(r),height:N(s),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:Qp(c),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(e){const n=this.getEmbedDefinition(e.props.url);return d.jsx("rect",{width:N(e.props.w),height:N(e.props.h),rx:(n==null?void 0:n.definition.overrideOutlineRadius)??8,ry:(n==null?void 0:n.definition.overrideOutlineRadius)??8})}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r)}}};I(so,"type","embed"),I(so,"props",FA),I(so,"migrations",NA),I(so,"embedDefinitions",S1);let Jp=so;function Hce({id:t,isInteractive:e,width:n,height:r,style:s,pageRotation:o}){if(!t.match(/^[0-9a-f]+$/))throw Error("No gist id!");return d.jsx("iframe",{className:"tl-embed",draggable:!1,width:N(n),height:N(r),frameBorder:"0",scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:e?"all":"none",zIndex:e?"":"-1",boxShadow:Qp(o)},srcDoc:`
|
|
368
|
-
<html>
|
|
369
|
-
<head>
|
|
370
|
-
<base target="_blank">
|
|
371
|
-
</head>
|
|
372
|
-
<body>
|
|
373
|
-
<script src=${`https://gist.github.com/${t}.js`}><\/script>
|
|
374
|
-
<style type="text/css">
|
|
375
|
-
* { margin: 0px; }
|
|
376
|
-
table { height: 100%; background-color: red; }
|
|
377
|
-
.gist { background-color: none; height: 100%; }
|
|
378
|
-
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
379
|
-
</style>
|
|
380
|
-
</body>
|
|
381
|
-
</html>`})}function iw(t,e){const s=((ea(t.getShapePageTransform(e.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4;return Math.floor(s)}function HE(t,e,n){const r=t.textMeasure.measureTextSpans(S5(e.props.name,"Frame")+"",n),s=r[0],o=Ht(r),i=o.box.w+o.box.x-s.box.x;return{box:new Z(0,-n.height,i,n.height),spans:r}}function KE(t,e){return{fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:t.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle",fill:e,offsetY:-34,offsetX:2}}function y5(t,e,n){const r=n?"":"px",s=n?"":"deg";let o;switch(e){case 0:o="";break;case 3:o=`translate(${N(t.props.w)}${r}, 0${r}) rotate(90${s})`;break;case 2:o=`translate(${N(t.props.w)}${r}, ${N(t.props.h)}${r}) rotate(180${s})`;break;case 1:o=`translate(0${r}, ${N(t.props.h)}${r}) rotate(270${s})`;break;default:throw Error("labelSide out of bounds")}return o}const Kce=w.forwardRef(({id:t,name:e,isEditing:n},r)=>{const s=z(),o=w.useCallback(l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(Ct(l),l.currentTarget.blur(),s.setEditingShape(null))},[s]),i=w.useCallback(l=>{const c=s.getShape(t);if(!c)return;const u=c.props.name,h=l.currentTarget.value.trim();u!==h&&s.updateShapes([{id:t,type:"frame",props:{name:h}}])},[t,s]),a=w.useCallback(l=>{const c=s.getShape(t);if(!c)return;const u=c.props.name,h=l.currentTarget.value;u!==h&&s.updateShapes([{id:t,type:"frame",props:{name:h}}])},[t,s]);return d.jsxs("div",{className:`tl-frame-label ${n?"tl-frame-label__editing":""}`,children:[d.jsx("input",{className:"tl-frame-name-input",ref:r,style:{display:n?void 0:"none"},value:e,autoFocus:!0,onKeyDown:o,onBlur:i,onChange:a}),S5(e,"Frame")+""]})});function Wce({id:t,name:e,width:n,height:r}){const s=z(),{side:o,translation:i}=U("shape rotation",()=>{const c=s.getShape(t);if(!c)return{side:0,translation:"translate(0, 0)"};const u=iw(s,c);return{side:u,translation:y5(c,u,!1)}},[s,t]),a=w.useRef(null),l=Zg(t);return w.useEffect(()=>{const c=a.current;c&&l&&(c.focus(),c.select())},[a,l]),d.jsx("div",{className:"tl-frame-heading",style:{overflow:l?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(o===0||o===2?n:r)}px + var(--space-5))`,bottom:"100%",transform:`${i} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},children:d.jsx("div",{className:"tl-frame-heading-hit-area",children:d.jsx(Kce,{ref:a,id:t,name:e,isEditing:l})})})}function S5(t,e){return t.match(/^\s*$/)?e:t}class _f extends oc{canEdit(){return!0}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(e){const{editor:n}=this,r=n.getZoomLevel(),s=KE(e,"black"),o=HE(n,e,s),i=iw(n,e);let a,l,c,u;const{w:h,h:f}=o.box,p=Math.min(h,e.props.w*r),g=Math.min(f,e.props.h*r);switch(i){case 0:{a=-8/r,l=(-f-4)/r,c=(p+16)/r,u=f/r;break}case 1:{a=(-f-4)/r,u=(g+16)/r,l=e.props.h-u+8/r,c=f/r;break}case 2:{a=e.props.w-(p+8)/r,l=e.props.h+4/r,c=(g+16)/r,u=f/r;break}case 3:{a=e.props.w+4/r,u=(g+16)/r,l=-8/r,c=f/r;break}}return new $r({children:[new Fs({width:e.props.w,height:e.props.h,isFilled:!1}),new Fs({x:a,y:l,width:c,height:u,isFilled:!0,isLabel:!0})]})}getText(e){return e.props.name}component(e){const n=this.editor.getShapeGeometry(e).bounds,r=zr(),s=U("is creating this shape",()=>{const o=this.editor.getStateDescendant("select.resizing");if(!o||!o.getIsActive())return!1;const i=o==null?void 0:o.info;return i?i.isCreating&&this.editor.getOnlySelectedShapeId()===e.id:!1},[e.id]);return d.jsxs(d.Fragment,{children:[d.jsx(mi,{children:d.jsx("rect",{className:ce("tl-frame__body",{"tl-frame__creating":s}),width:n.width,height:n.height,fill:r.solid,stroke:r.text})}),s?null:d.jsx(Wce,{id:e.id,name:e.props.name,width:n.width,height:n.height})]})}toSvg(e,n){const r=ko({isDarkMode:n.isDarkMode}),s=iw(this.editor,e),o=y5(e,s,!0),i=KE(e,r.text),{box:a,spans:l}=HE(this.editor,e,i),c=rw(this.editor,l,i);return d.jsxs(d.Fragment,{children:[d.jsx("rect",{width:e.props.w,height:e.props.h,fill:r.solid,stroke:r.black.solid,strokeWidth:1,rx:1,ry:1}),d.jsxs("g",{transform:o,children:[d.jsx("rect",{x:a.x-8,y:a.y-4,width:a.width+20,height:a.height,fill:r.background,rx:4,ry:4}),c]})]})}indicator(e){const n=this.editor.getShapeGeometry(e).bounds;return d.jsx("rect",{width:N(n.width),height:N(n.height),className:"tl-frame-indicator"})}canReceiveNewChildrenOfType(e,n){return!e.isLocked}providesBackgroundForChildren(){return!0}canDropShapes(e,n){return!e.isLocked}onDragShapesOver(e,n){n.every(r=>r.parentId===e.id)||this.editor.reparentShapes(n,e.id)}onDragShapesOut(e,n){const r=this.editor.getShape(e.parentId);r&&this.editor.isShapeOfType(r,"group")?this.editor.reparentShapes(n,r.id):this.editor.reparentShapes(n,this.editor.getCurrentPageId())}onResize(e,n){return qg(e,n)}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r)}}}I(_f,"type","frame"),I(_f,"props",zA),I(_f,"migrations",BA);function WE(t,e){return t>e?(De*(e/2)+(t-e))*2:(De*(t/2)+(e-t))*2}function v5(t,e){return $1(t,e).map((n,r)=>n.getSvgPathData(r===0)).join(" ")+" Z"}function Gce(t,e,n,r){const s=t/4,o=e/4,i=cs(r),a=n*.75,l=S=>S.addXY(i()*a,i()*a),c=new x(t/2,e),u=new x(0,o*1.2),h=new x(t/2,o*.9),f=new x(t,o*1.2),p=l(new x(t/2,e)),g=l(new x(0,o*1.2)),m=l(new x(t/2,o*.9)),v=l(new x(t,o*1.2));return[new an({start:c,cp1:new x(s*1.5,o*3),cp2:new x(0,o*2.5),end:u}),new an({start:u,cp1:new x(0,-o*.32),cp2:new x(s*1.85,-o*.32),end:h}),new an({start:h,cp1:new x(s*2.15,-o*.32),cp2:new x(t,-o*.32),end:f}),new an({start:f,cp1:new x(t,o*2.5),cp2:new x(s*2.5,o*3),end:p}),new an({start:p,cp1:new x(s*1.5,o*3),cp2:new x(0,o*2.5),end:g}),new an({start:g,cp1:new x(0,-o*.32),cp2:new x(s*1.85,-o*.32),end:m}),new an({start:m,cp1:new x(s*2.15,-o*.32),cp2:new x(t,-o*.32),end:v}),new an({start:v,cp1:new x(t,o*2.5),cp2:new x(s*2.5,o*3),end:c})].map((S,b)=>S.getSvgPathData(b===0)).join(" ")+" Z"}function $1(t,e){const n=t/4,r=e/4;return[new an({start:new x(t/2,e),cp1:new x(n*1.5,r*3),cp2:new x(0,r*2.5),end:new x(0,r*1.2)}),new an({start:new x(0,r*1.2),cp1:new x(0,-r*.32),cp2:new x(n*1.85,-r*.32),end:new x(t/2,r*.9)}),new an({start:new x(t/2,r*.9),cp1:new x(n*2.15,-r*.32),cp2:new x(t,-r*.32),end:new x(t,r*1.2)}),new an({start:new x(t,r*1.2),cp1:new x(t,r*2.5),cp2:new x(n*2.5,r*3),end:new x(t/2,e)})]}function Vce(t){return{size:1+t,thinning:.25,end:{taper:t},start:{taper:t},streamline:0,smoothing:1,simulatePressure:!1}}function Yce(t,e,n,r){const s=cs(t),o=e/2,i=n/2,a=aj(o,i),l=[],c=Fe*s(),u=Fe+Ze/2+Math.abs(s())*Ze,h=Math.max(16,a/10);for(let f=0;f<h;f++){const p=f/(h-1),g=c+p*u,m=Math.cos(g),v=Math.sin(g);l.push(new x(o*m+e*.5+.05*s(),i*v+n/2+.05*s(),Math.min(1,.5+Math.abs(.5-(s()>0?Dt.easeInOutSine(p):Dt.easeInExpo(p)))/2)))}return Bs(l,Vce(r))}function Xce(t,e,n,r){return va(Yce(t,e,n,r))}function aw(t){let e="M";const n=t.length;let r,s,o;for(let i=0,a=n;i<a;i+=3)r=t[i],s=t[i+1],o=t[i+2],e+=`${je(r)}L${je(s)}Q${je(o)}`;return e+=`${je(t[0])}`,e}function lw(t,e,n,r,s){const o=[],i=cs(t);let a=e[0],l;const c=e.length;for(let u=0,h=c*s;u<h;u++){l=x.AddXY(e[(u+1)%c],i()*n,i()*n);const f=x.Sub(l,a),p=x.Len(f),g=x.Div(f,p).mul(Math.min(p/4,r));o.push(x.Add(a,g),x.Add(l,g.neg()),l),a=l}return o}function qce(t,e,n){const r=Math.min(t,e)/2,s=Math.max(t,e)-r*2,i=(Math.PI*(r*2)+2*s)/n,a=t>e?[{type:"straight",start:new x(r,0),delta:new x(1,0)},{type:"arc",center:new x(t-r,r),startAngle:-De/2},{type:"straight",start:new x(t-r,e),delta:new x(-1,0)},{type:"arc",center:new x(r,r),startAngle:De/2}]:[{type:"straight",start:new x(t,r),delta:new x(0,1)},{type:"arc",center:new x(r,e-r),startAngle:0},{type:"straight",start:new x(0,e-r),delta:new x(0,-1)},{type:"arc",center:new x(r,r),startAngle:De}];let l=0;const c=[];for(let u=0;u<n;u++){const h=a[0];h.type==="straight"?c.push(x.Add(h.start,x.Mul(h.delta,l))):c.push(ha(h.center,r,h.startAngle+l/r)),l+=i;let f=h.type==="straight"?s:De*r;for(;l>f;)l-=f,a.push(a.shift()),f=a[0].type==="straight"?s:De*r}return c}const Zce={s:50,m:70,l:100,xl:130},Qce=.2;function _m(t,e,n,r,s){const o=cs(n),i=WE(t,e),a=Math.max(Math.ceil(i/Zce[r]),6,Math.ceil(i/Math.min(t,e))),l=i/a*Qce,c=Math.max(t-l*2,1),u=Math.max(e-l*2,1),f=WE(c,u)/a,p=(t-c)/2,g=(e-u)/2,m=qce(c,u,a).map(P=>P.addXY(p,g)),v=t<20?0:l*.3,y=e<20?0:l*.3,S=m.slice(0);for(let P=0;P<Math.floor(a/2);P++)S[P]=x.AddXY(S[P],o()*v*s,o()*y*s),S[a-P-1]=x.AddXY(S[a-P-1],o()*v*s,o()*y*s);const b=[];for(let P=0;P<S.length;P++){const C=P===S.length-1?0:P+1,_=S[P],E=S[C],k=m[P],D=m[C],T=x.Dist(k,D),j=f-T,M=x.Dist(_,E)/T,O=(Math.max(p,g)+j)*M,F=x.Lrp(k,D,.5).add(x.Sub(D,k).uni().per().mul(O));F.x<0?F.x=0:F.x>t&&(F.x=t),F.y<0?F.y=0:F.y>e&&(F.y=e);const B=pb(_,E,F),K=x.Dist(B||x.Average([_,E]),_);b.push({leftPoint:_,rightPoint:E,arcPoint:F,center:B,radius:K})}return b}function Jce(t,e,n,r,s){const o=[],i=_m(t,e,n,r,s);for(const{center:a,radius:l,leftPoint:c,rightPoint:u}of i)o.push(...xX(c,u,a,l,10));return o}function cw(t,e,n,r,s){const o=_m(t,e,n,r,s);let i=`M${o[0].leftPoint.toFixed()}`;for(const{leftPoint:a,rightPoint:l,radius:c,center:u}of o){if(u===null){i+=` L${l.toFixed()}`;continue}const h=x.Clockwise(a,l,u)?"0":"1";i+=` A${N(c)},${N(c)} 0 ${h},1 ${l.toFixed()}`}return i+=" Z",i}const eue={s:.5,m:.7,l:.9,xl:1.6};function tue(t,e,n,r,s){const o=cs(n),i=eue[r]*s,a=_m(t,e,n,r,s),u=a.reduce((g,m)=>g+x.Dist2(m.leftPoint,m.rightPoint),0)/a.length>(i*15)**2?g=>x.AddXY(g,o()*i*2,o()*i*2):g=>g;let h=`M${a[0].leftPoint.toFixed()}`,f=u(a[0].leftPoint),p=`M${f.toFixed()}`;for(const{leftPoint:g,center:m,rightPoint:v,radius:y,arcPoint:S}of a){if(m===null){h+=` L${v.toFixed()}`;const k=u(v);p+=` L${k.toFixed()}`,f=k;continue}const b=x.Clockwise(g,v,m)?"0":"1";h+=` A${N(y)},${N(y)} 0 ${b},1 ${v.toFixed()}`;const P=u(v),C=u(S),_=pb(f,P,C);if(!_){p+=` L${P.toFixed()}`,f=P;continue}const E=Math.abs(x.Dist(_,f));p+=` A${N(E)},${N(E)} 0 ${b},1 ${P.toFixed()}`,f=P}return h+p+" Z"}function uw(t,e){switch(t.geo){case"x-box":return nue(t.w,t.h,e,t.dash);case"check-box":return rue(t.w,t.h);default:return}}function nue(t,e,n,r){const s=r==="draw"?.62:0;if(r==="dashed")return[[new x(0,0),new x(t/2,e/2)],[new x(t,e),new x(t/2,e/2)],[new x(0,e),new x(t/2,e/2)],[new x(t,0),new x(t/2,e/2)]];const o=a=>Math.max(0,Math.min(t,a)),i=a=>Math.max(0,Math.min(e,a));return[[new x(o(n*s),i(n*s)),new x(o(t-n*s),i(e-n*s))],[new x(o(n*s),i(e-n*s)),new x(o(t-n*s),i(n*s))]]}function rue(t,e){const n=Math.min(t,e)*.82,r=(t-n)/2,s=(e-n)/2,o=a=>Math.max(0,Math.min(t,a)),i=a=>Math.max(0,Math.min(e,a));return[[new x(o(r+n*.25),i(s+n*.52)),new x(o(r+n*.45),i(s+n*.82))],[new x(o(r+n*.45),i(s+n*.82)),new x(o(r+n*.82),i(s+n*.22))]]}function GE({shape:t,shouldScale:e,forceSolid:n}){const r=e?t.props.scale:1,s=z(),o=zr(),{id:i,props:a}=t,{w:l,color:c,fill:u,dash:h,growY:f,size:p,scale:g}=a,m=fn[p]*r,v=a.h+f;switch(a.geo){case"cloud":if(h==="solid"){const y=cw(l,v,i,p,g);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:y,color:c,fill:u,scale:r}),d.jsx("path",{d:y,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}else if(h==="draw"){const y=tue(l,v,i,p,g);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:y,color:c,fill:u,scale:r}),d.jsx("path",{d:y,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}else{const y=cw(l,v,i,p,g),S=_m(l,v,i,p,g);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:y,color:c,fill:u,scale:r}),d.jsx("g",{strokeWidth:m,stroke:o[c].solid,fill:"none",pointerEvents:"all",children:S.map(({leftPoint:b,rightPoint:P,center:C,radius:_},E)=>{const k=C?_*ea(ea(x.Angle(C,P))-ea(x.Angle(C,b))):x.Dist(b,P),{strokeDasharray:D,strokeDashoffset:T}=qr(k,m,{style:h,start:"outset",end:"outset",forceSolid:n});return d.jsx("path",{d:C?`M${b.x},${b.y}A${_},${_},0,0,1,${P.x},${P.y}`:`M${b.x},${b.y}L${P.x},${P.y}`,strokeDasharray:D,strokeDashoffset:T},E)})})]})}case"ellipse":{const y=e?s.getShapeGeometry(t):s.getShapeUtil(t).getGeometry(t),S=y.getSvgPathData(!0);if(h==="dashed"||h==="dotted"){const b=y.length,{strokeDasharray:P,strokeDashoffset:C}=qr(b<64?b*2:b,m,{style:h,snap:4,closed:!0,forceSolid:n});return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:S,color:c,fill:u,scale:r}),d.jsx("path",{d:S,strokeWidth:m,fill:"none",stroke:o[c].solid,strokeDasharray:P,strokeDashoffset:C})]})}else{const P=(e?s.getShapeGeometry(t):s.getShapeUtil(t).getGeometry(t)).getSvgPathData(!0);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:P,color:c,fill:u,scale:r}),d.jsx("path",{d:P,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}}case"oval":{const y=e?s.getShapeGeometry(t):s.getShapeUtil(t).getGeometry(t),S=y.getSvgPathData(!0);if(h==="dashed"||h==="dotted"){const b=y.getLength(),{strokeDasharray:P,strokeDashoffset:C}=qr(b<64?b*2:b,m,{style:h,snap:4,start:"outset",end:"outset",closed:!0,forceSolid:n});return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:S,color:c,fill:u,scale:r}),d.jsx("path",{d:S,strokeWidth:m,fill:"none",stroke:o[c].solid,strokeDasharray:P,strokeDashoffset:C})]})}else return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:S,color:c,fill:u,scale:r}),d.jsx("path",{d:S,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}case"heart":if(h==="dashed"||h==="dotted"||h==="solid"){const y=v5(l,v),S=$1(l,v);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:y,color:c,fill:u,scale:r}),S.map((b,P)=>{const{strokeDasharray:C,strokeDashoffset:_}=qr(b.length,m,{style:h,snap:1,start:"outset",end:"outset",closed:!0,forceSolid:n});return d.jsx("path",{d:b.getSvgPathData(),strokeWidth:m,fill:"none",stroke:o[c].solid,strokeDasharray:C,strokeDashoffset:_,pointerEvents:"all"},`curve_${P}`)})]})}else{const y=Gce(l,v,m,t.id);return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:y,color:c,fill:u,scale:r}),d.jsx("path",{d:y,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}default:{const y=e?s.getShapeGeometry(t):s.getShapeUtil(t).getGeometry(t),S=y instanceof $r?y.children[0].vertices:y.vertices,b=uw(t.props,m);if(h==="solid"){let P="M"+S[0]+"L"+S.slice(1)+"Z";if(b)for(const[C,_]of b)P+=`M${C.x},${C.y}L${_.x},${_.y}`;return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:P,color:c,fill:u,scale:r}),d.jsx("path",{d:P,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}else if(h==="dashed"||h==="dotted"){const P="M"+S[0]+"L"+S.slice(1)+"Z";return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:P,color:c,fill:u,scale:r}),d.jsxs("g",{strokeWidth:m,stroke:o[c].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(S.length)).map((C,_)=>{const E=x.ToFixed(S[_]),k=x.ToFixed(S[(_+1)%S.length]),D=x.Dist(E,k),{strokeDasharray:T,strokeDashoffset:j}=qr(D,m,{style:h,start:"outset",end:"outset",forceSolid:n});return d.jsx("line",{x1:E.x,y1:E.y,x2:k.x,y2:k.y,strokeDasharray:T,strokeDashoffset:j},_)}),b&&b.map(([C,_],E)=>{const k=x.Dist(C,_),{strokeDasharray:D,strokeDashoffset:T}=qr(k,m,{style:h,start:"skip",end:"skip",snap:h==="dotted"?4:void 0,forceSolid:n});return d.jsx("path",{d:`M${C.x},${C.y}L${_.x},${_.y}`,stroke:o[c].solid,strokeWidth:m,fill:"none",strokeDasharray:D,strokeDashoffset:T},`line_fg_${E}`)})]})]})}else if(h==="draw"){let P=aw(lw(i,S,m/3,m*2,2));if(b)for(const[_,E]of b)P+=`M${_.toFixed()}L${E.toFixed()}`;const C=aw(lw(i,S,0,m*2,1));return d.jsxs(d.Fragment,{children:[d.jsx(sn,{theme:o,d:C,color:c,fill:u,scale:r}),d.jsx("path",{d:P,stroke:o[c].solid,strokeWidth:m,fill:"none"})]})}}}}const VE=17*3;class If extends oc{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 n=Math.max(1,e.props.w),r=Math.max(1,e.props.h+e.props.growY),s=n/2,o=r/2,i=e.props.fill!=="none";let a;switch(e.props.geo){case"cloud":{a=new vt({points:Jce(n,r,e.id,e.props.size,e.props.scale),isFilled:i});break}case"triangle":{a=new vt({points:[new x(s,0),new x(n,r),new x(0,r)],isFilled:i});break}case"diamond":{a=new vt({points:[new x(s,0),new x(n,o),new x(s,r),new x(0,o)],isFilled:i});break}case"pentagon":{a=new vt({points:Hy(n,r,5),isFilled:i});break}case"hexagon":{a=new vt({points:Hy(n,r,6),isFilled:i});break}case"octagon":{a=new vt({points:Hy(n,r,8),isFilled:i});break}case"ellipse":{a=new mte({width:n,height:r,isFilled:i});break}case"oval":{a=new yte({width:n,height:r,isFilled:i});break}case"star":{const S=Fe/5/2,b=Math.floor(5/4)*2,P=5*2-b,C=0,_=Math.floor(5/2)*2,E=Math.cos(-Ze+b*S)*n/2,k=Math.cos(-Ze+P*S)*n/2,D=Math.sin(-Ze+C*S)*r/2,T=Math.sin(-Ze+_*S)*r/2,j=n-Math.abs(E-k),L=r-Math.abs(T-D),M=n/2+k-(n/2-E),O=r/2+D-(r/2-T),F=1,B=(n-M)/2,K=(r-O)/2,R=(n+j)/2,H=(r+L)/2,X=R*F/2,te=H*F/2;a=new vt({points:Array.from(Array(5*2)).map((le,de)=>{const Me=-Ze+de*S;return new x(B+(de%2?X:R)*Math.cos(Me),K+(de%2?te:H)*Math.sin(Me))}),isFilled:i});break}case"rhombus":{const y=Math.min(n*.38,r*.38);a=new vt({points:[new x(y,0),new x(n,0),new x(n-y,r),new x(0,r)],isFilled:i});break}case"rhombus-2":{const y=Math.min(n*.38,r*.38);a=new vt({points:[new x(0,0),new x(n-y,0),new x(n,r),new x(y,r)],isFilled:i});break}case"trapezoid":{const y=Math.min(n*.38,r*.38);a=new vt({points:[new x(y,0),new x(n-y,0),new x(n,r),new x(0,r)],isFilled:i});break}case"arrow-right":{const y=Math.min(n,r)*.38,S=r*.16;a=new vt({points:[new x(0,S),new x(n-y,S),new x(n-y,0),new x(n,r/2),new x(n-y,r),new x(n-y,r-S),new x(0,r-S)],isFilled:i});break}case"arrow-left":{const y=Math.min(n,r)*.38,S=r*.16;a=new vt({points:[new x(y,0),new x(y,S),new x(n,S),new x(n,r-S),new x(y,r-S),new x(y,r),new x(0,r/2)],isFilled:i});break}case"arrow-up":{const y=n*.16,S=Math.min(n,r)*.38;a=new vt({points:[new x(n/2,0),new x(n,S),new x(n-y,S),new x(n-y,r),new x(y,r),new x(y,S),new x(0,S)],isFilled:i});break}case"arrow-down":{const y=n*.16,S=Math.min(n,r)*.38;a=new vt({points:[new x(y,0),new x(n-y,0),new x(n-y,r-S),new x(n,r-S),new x(n/2,r),new x(0,r-S),new x(y,r-S)],isFilled:i});break}case"check-box":case"x-box":case"rectangle":{a=new Fs({width:n,height:r,isFilled:i});break}case"heart":{const S=$1(n,r).reduce((b,P)=>(b.push(...P.vertices),b),[]);a=new vt({points:S,isFilled:i});break}default:Ot(e.props.geo)}const l=$h(this.editor,e),c=n/e.props.scale,u=r/e.props.scale,h=Math.min(100,c/2),f=Math.min(yo[e.props.size]*pn.lineHeight+Er*2,u/2),p=Math.min(c,Math.max(l.w,Math.min(h,Math.max(1,c-8)))),g=Math.min(u,Math.max(l.h,Math.min(f,Math.max(1,u-8)))),m=uw(e.props,fn[e.props.size]*e.props.scale),v=m?m.map(y=>new nc({points:y})):[];return new $r({children:[a,new Fs({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}),...v]})}getHandleSnapGeometry(e){const n=this.getGeometry(e),r=n.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:r,points:[...r.getVertices(),n.bounds.center]};case"cloud":case"ellipse":case"heart":case"oval":return{outline:r,points:[n.bounds.center]};default:Ot(e.props.geo)}}getText(e){return e.props.text}onEditEnd(e){const{id:n,type:r,props:{text:s}}=e;s.trimEnd()!==e.props.text&&this.editor.updateShapes([{id:n,type:r,props:{text:s.trimEnd()}}])}component(e){const{id:n,type:r,props:s}=e,{fill:o,font:i,align:a,verticalAlign:l,size:c,text:u}=s,h=zr(),{editor:f}=this,p=U("isGeoOnlySelected",()=>e.id===f.getOnlySelectedShapeId(),[]),m=f.getEditingShapeId()!==null||e.props.text,v=U("force solid",()=>f.getZoomLevel()<.2,[f]);return d.jsxs(d.Fragment,{children:[d.jsx(mi,{children:d.jsx(GE,{shape:e,shouldScale:!0,forceSolid:v})}),m&&d.jsx(hi,{style:{overflow:"hidden",width:e.props.w,height:e.props.h+s.growY},children:d.jsx(Cm,{shapeId:n,type:r,font:i,fontSize:yo[c]*e.props.scale,lineHeight:pn.lineHeight,padding:Er*e.props.scale,fill:o,align:a,verticalAlign:l,text:u,isSelected:p,labelColor:h[s.labelColor].solid,wrap:!0})}),e.props.url&&d.jsx(Fl,{url:e.props.url})]})}indicator(e){const{id:n,props:r}=e,{w:s,size:o}=r,i=r.h+r.growY,a=fn[o],l=this.editor.getShapeGeometry(e);switch(r.geo){case"ellipse":return r.dash==="draw"?d.jsx("path",{d:Xce(n,s,i,a)}):d.jsx("path",{d:l.getSvgPathData(!0)});case"heart":return d.jsx("path",{d:v5(s,i)});case"oval":return d.jsx("path",{d:l.getSvgPathData(!0)});case"cloud":return d.jsx("path",{d:cw(s,i,n,o,e.props.scale)});default:{const c=this.editor.getShapeGeometry(e),u=c instanceof $r?c.children[0].vertices:c.vertices;let h;if(r.dash==="draw"){const p=lw(n,u,0,a*2*e.props.scale,1);h=aw(p)}else h="M"+u[0]+"L"+u.slice(1)+"Z";const f=uw(e.props,a);if(f)for(const[p,g]of f)h+=`M${p.x},${p.y}L${g.x},${g.y}`;return d.jsx("path",{d:h})}}}toSvg(e,n){const r={...e,props:{...e.props,w:e.props.w/e.props.scale,h:e.props.h/e.props.scale}},s=r.props;n.addExportDef(j1(s.fill));let o;if(s.text){n.addExportDef(bm(s.font));const i=ko(n),a=new Z(0,0,s.w,s.h+s.growY);o=d.jsx(Pm,{fontSize:yo[s.size],font:s.font,align:s.align,verticalAlign:s.verticalAlign,text:s.text,labelColor:i[s.labelColor].solid,bounds:a,padding:16})}return d.jsxs(d.Fragment,{children:[d.jsx(GE,{shouldScale:!1,shape:r,forceSolid:!1}),o]})}getCanvasSvgDefs(){return[O1()]}onResize(e,{handle:n,newPoint:r,scaleX:s,scaleY:o,initialShape:i}){const a=i.props.w/i.props.scale,l=i.props.h/i.props.scale,c=i.props.growY/i.props.scale;let u=a*s,h=(l+c)*o,f=0,p=0;const g=VE;if(e.props.text.trim()){let P=Math.max(Math.abs(u),g),C=Math.max(Math.abs(h),g);P<g&&C===g&&(P=g),P===g&&C<g&&(C=g);const _=$h(this.editor,{...e,props:{...e.props,w:P*e.props.scale,h:C*e.props.scale}}),E=Math.max(Math.abs(u),_.w)*Math.sign(u),k=Math.max(Math.abs(h),_.h)*Math.sign(h);f=Math.abs(E)-Math.abs(u),p=Math.abs(k)-Math.abs(h),u=E,h=k}const m=u*e.props.scale,v=h*e.props.scale,y=new x(0,0);s<0&&(y.x+=m),(n==="left"||n==="top_left"||n==="bottom_left")&&(y.x+=s<0?f:-f),o<0&&(y.y+=v),(n==="top"||n==="top_left"||n==="top_right")&&(y.y+=o<0?p:-p);const{x:S,y:b}=y.rot(e.rotation).add(r);return{x:S,y:b,props:{w:Math.max(Math.abs(m),1),h:Math.max(Math.abs(v),1),growY:0}}}onBeforeCreate(e){if(!e.props.text)return e.props.growY?{...e,props:{...e.props,growY:0}}:void 0;const n=e.props.h/e.props.scale,r=$h(this.editor,e).h;let s=null;if(r>n?s=r-n:e.props.growY&&(s=0),s!==null)return{...e,props:{...e.props,growY:s*e.props.scale}}}onBeforeUpdate(e,n){const r=e.props.text,s=n.props.text;if(r===s&&e.props.font===n.props.font&&e.props.size===n.props.size)return;if(r&&!s)return{...n,props:{...n.props,growY:0}};const o=e.props.w/e.props.scale,i=e.props.h/e.props.scale,a=e.props.growY/e.props.scale,l=$h(this.editor,n);if(!r&&s&&s.length===1){let u=Math.max(o,l.w),h=Math.max(i,l.h);const f=VE;return o<f&&i<f&&(u=Math.max(u,f),h=Math.max(h,f),u=Math.max(u,h),h=Math.max(u,h)),{...n,props:{...n.props,w:u*n.props.scale,h:h*n.props.scale,growY:0}}}let c=null;if(l.h>i?c=l.h-i:a&&(c=0),c!==null){const u=n.props.w/n.props.scale;return{...n,props:{...n.props,growY:c*n.props.scale,w:Math.max(u,l.w)*n.props.scale}}}if(l.w>o)return{...n,props:{...n.props,w:l.w*n.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,n,r){return{...r>.5?n.props:e.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r),scale:_e(e.props.scale,n.props.scale,r)}}}I(If,"type","geo"),I(If,"props",UA),I(If,"migrations",HA);function $h(t,e){const{text:n,font:r,size:s,w:o}=e.props;if(!n)return{w:0,h:0};const i=t.textMeasure.measureText("w",{...pn,fontFamily:Co[r],fontSize:yo[s],maxWidth:100}),a={s:2,m:3.5,l:5,xl:10},l=t.textMeasure.measureText(n,{...pn,fontFamily:Co[r],fontSize:yo[s],minWidth:i.w,maxWidth:Math.max(0,Math.ceil(i.w+a[s]),Math.ceil(o/e.props.scale-Er*2))});return{w:l.w+Er*2,h:l.h+Er*2}}function sue(){const[t,e]=w.useState(!1);return w.useEffect(()=>{const r=CSS.supports("color","color(display-p3 1 1 1)"),s=matchMedia("(color-gamut: p3)");e(r&&s.matches);const o=()=>e(r&&s.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),U(wt.forceSrgb)||!t?"srgb":"p3"}const YE=.35,XE=.82;class Ef extends ss{hideResizeHandles(e){return Fh(e)}hideRotateHandle(e){return Fh(e)}hideSelectionBoundsFg(e){return Fh(e)}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1}}getGeometry(e){const n=Wi(e);if(Fh(e))return new Lb({x:-n/2,y:-n/2,radius:n/2,isFilled:!0});const{strokePoints:r,sw:s}=qE(e,n,!0),o=L1({strokeWidth:s,showAsComplete:!0});return xm(r,o),new vt({points:k1(r,o),isFilled:!0})}component(e){const n=_S(this.editor,e),r=Wi(e);return d.jsx(mi,{children:d.jsx(Nh,{shape:e,forceSolid:n,strokeWidth:r,opacity:YE})})}backgroundComponent(e){const n=_S(this.editor,e),r=Wi(e);return d.jsx(mi,{children:d.jsx(Nh,{shape:e,forceSolid:n,strokeWidth:r,opacity:XE})})}indicator(e){const n=_S(this.editor,e),r=Wi(e),{strokePoints:s,sw:o}=qE(e,r,n),i=Nl(e.props.segments);let a;return s.length<2?a=iue(i[0],o):a=va(s,!1),d.jsx("path",{d:a})}toSvg(e){const n=Wi(e),r=n<1.5,s=1/e.props.scale;return d.jsx("g",{transform:`scale(${s})`,children:d.jsx(Nh,{forceSolid:r,strokeWidth:n,shape:e,opacity:YE})})}toBackgroundSvg(e){const n=Wi(e),r=n<1.5,s=1/e.props.scale;return d.jsx("g",{transform:`scale(${s})`,children:d.jsx(Nh,{forceSolid:r,strokeWidth:n,shape:e,opacity:XE})})}onResize(e,n){const{scaleX:r,scaleY:s}=n,o=[];for(const i of e.props.segments)o.push({...i,points:i.points.map(({x:a,y:l,z:c})=>({x:r*a,y:s*l,z:c}))});return{props:{segments:o}}}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,...n.props,segments:p5(e.props.segments,n.props.segments,r),scale:_e(e.props.scale,n.props.scale,r)}}}I(Ef,"type","highlight"),I(Ef,"props",GA),I(Ef,"migrations",VA);function oue(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 iue(t,e){const n=e/2;return`M ${t.x} ${t.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function qE(t,e,n){var l;const r=Nl(t.props.segments),s=t.props.isComplete||((l=Ht(t.props.segments))==null?void 0:l.type)==="straight";let o=e;!n&&!t.props.isPen&&r.length===1&&(o+=cs(t.id)()*(e/6));const i=L1({strokeWidth:o,showAsComplete:s});return{strokePoints:Bs(r,i),sw:o}}function Wi(t){return Ll[t.props.size]*1.12*t.props.scale}function Fh(t){return t.props.segments.length===1&&t.props.segments[0].points.length<2}function Nh({strokeWidth:t,forceSolid:e,shape:n,opacity:r}){var f;const s=zr(),o=Nl(n.props.segments);let i=t;!e&&!n.props.isPen&&o.length===1&&(i+=cs(n.id)()*(i/6));const a=L1({strokeWidth:i,showAsComplete:n.props.isComplete||((f=Ht(n.props.segments))==null?void 0:f.type)==="straight"}),l=Bs(o,a),c=l.length>1?va(l,!1):oue(n.props.segments[0].points[0]),u=sue(),h=s[n.props.color].highlight[u];return d.jsx("path",{d:c,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:h,strokeWidth:i,opacity:r})}function _S(t,e){return U("forceSolid",()=>{const n=Wi(e),r=t.getZoomLevel();return n/r<1.5},[t])}function x5(){return d.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:[d.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),d.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),d.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function w5({shapeId:t,assetId:e}){const n=z(),r=!!md(),s=MQ(),o=w.useMemo(()=>vg(ZE,500),[]),[i,a]=w.useState(()=>({asset:e?n.getAsset(e)??null:null,url:null})),l=w.useRef(!1),c=w.useRef(null);return w.useEffect(()=>{if(!e)return;let u=!1,h;const f=As("update state",()=>{if(!r&&n.getCulledShapes().has(t))return;const p=n.getAsset(e);if(!p)return;const g=n.getShape(t);if(!g)return;if(!p.props.src){const y=n.getTemporaryAssetPreview(p.id);if(y){c.current!==y&&(c.current=y,a(S=>({...S,isPlaceholder:!0,url:y})),s());return}}const m=n.getZoomLevel()*(g.props.w/p.props.w);function v(y,S){u||c.current!==S&&(l.current=!0,c.current=S,a({asset:y,url:S}),s())}l.current?(o(n,e,m,r,y=>v(p,y)),h=o.cancel):ZE(n,e,m,r,y=>v(p,y))});return()=>{f(),h==null||h(),u=!0}},[n,e,r,s,t,o]),i}function ZE(t,e,n,r,s){t.resolveAssetUrl(e,{screenScale:n,shouldResolveToOriginal:r}).then(o=>{s(o)})}async function aue(t){const n=await(await Rs(t)).blob();return Zr.blobToDataUrl(n)}class kf extends oc{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,n){let r=qg(e,n);const{flipX:s,flipY:o}=n.initialShape.props,{scaleX:i,scaleY:a,mode:l}=n;if(r={...r,props:{...r.props,flipX:i<0!==s,flipY:a<0!==o}},!e.props.crop)return r;const c=l==="scale_shape"&&i===-1||l==="resize_bounds"&&s!==r.props.flipX,u=l==="scale_shape"&&a===-1||l==="resize_bounds"&&o!==r.props.flipY,{topLeft:h,bottomRight:f}=e.props.crop;return r.props.crop={topLeft:{x:c?1-f.x:h.x,y:u?1-f.y:h.y},bottomRight:{x:c?1-h.x:f.x,y:u?1-h.y:f.y}},r}component(e){return d.jsx(lue,{shape:e})}indicator(e){return this.editor.getCroppingShapeId()===e.id?null:d.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 r=await this.editor.resolveAssetUrl(e.props.assetId,{shouldResolveToOriginal:!0});return r?((r.startsWith("blob:")||r.startsWith("http")||r.startsWith("/")||r.startsWith("./"))&&(r=await aue(r)||""),d.jsx(uue,{shape:e,src:r})):null}onDoubleClickEdge(e){const n=e.props;if(!n||this.editor.getCroppingShapeId()!==e.id)return;const r=nt(n.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},s=1/(r.bottomRight.x-r.topLeft.x)*e.props.w,o=1/(r.bottomRight.y-r.topLeft.y)*e.props.h,i=new x(r.topLeft.x*s,r.topLeft.y*o).rot(e.rotation),a={id:e.id,type:e.type,x:e.x-i.x,y:e.y-i.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:s,h:o}};this.editor.updateShapes([a])}getInterpolatedProps(e,n,r){function s(o,i){var h,f,p,g;if(o.props.crop===null&&i.props.crop===null)return null;const a=((h=o.props.crop)==null?void 0:h.topLeft)||{x:0,y:0},l=((f=o.props.crop)==null?void 0:f.bottomRight)||{x:1,y:1},c=((p=i.props.crop)==null?void 0:p.topLeft)||{x:0,y:0},u=((g=i.props.crop)==null?void 0:g.bottomRight)||{x:1,y:1};return{topLeft:{x:_e(a.x,c.x,r),y:_e(a.y,c.y,r)},bottomRight:{x:_e(l.x,u.x,r),y:_e(l.y,u.y,r)}}}return{...r>.5?n.props:e.props,w:_e(e.props.w,n.props.w,r),h:_e(e.props.h,n.props.h,r),crop:s(e,n)}}}I(kf,"type","image"),I(kf,"props",YA),I(kf,"migrations",XA);const lue=w.memo(function({shape:e}){var y;const n=z(),{asset:r,url:s}=w5({shapeId:e.id,assetId:e.props.assetId}),o=QR(),[i,a]=w.useState(""),[l,c]=w.useState(null),u=cue(n,e);w.useEffect(()=>{if(s&&u){let S=!1;const b=Lu();return b.onload=()=>{if(S)return;const P=document.createElement("canvas");P.width=b.width,P.height=b.height;const C=P.getContext("2d");C&&(C.drawImage(b,0,0),a(P.toDataURL()),c(s))},b.crossOrigin="anonymous",b.src=s,()=>{S=!0}}},[n,u,o,s]);const h=U("show crop preview",()=>e.id===n.getOnlySelectedShapeId()&&n.getCroppingShapeId()===e.id&&n.isIn("select.crop"),[n,e.id]),f=o&&(((y=r==null?void 0:r.props.mimeType)==null?void 0:y.includes("video"))||u),p=b5(e),g=s===l?null:s,m=f?i:l;if(!s&&!(r!=null&&r.props.src))return d.jsxs(hi,{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:[d.jsx("div",{className:ce("tl-image-container",r&&"tl-image-container-loading"),style:p,children:r?null:d.jsx(x5,{})}),"url"in e.props&&e.props.url&&d.jsx(Fl,{url:e.props.url})]});const v=u?"anonymous":void 0;return d.jsxs(d.Fragment,{children:[h&&m&&d.jsx("div",{style:p,children:d.jsx("img",{className:"tl-image",style:{...pu(e),opacity:.1},crossOrigin:v,src:m,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1})}),d.jsxs(hi,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h},children:[d.jsxs("div",{className:ce("tl-image-container"),style:p,children:[m&&d.jsx("img",{className:"tl-image",style:pu(e),crossOrigin:v,src:m,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1},m),g&&d.jsx("img",{className:"tl-image",style:pu(e),crossOrigin:v,src:g,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,onLoad:()=>c(g)},g)]}),e.props.url&&d.jsx(Fl,{url:e.props.url})]})]})});function cue(t,e){const n=e.props.assetId?t.getAsset(e.props.assetId):void 0;return n?"mimeType"in n.props&&ar.isAnimatedImageType(n==null?void 0:n.props.mimeType)||"isAnimated"in n.props&&n.props.isAnimated:!1}function b5(t){const e=t.props.crop,n=e==null?void 0:e.topLeft;if(!n)return{width:t.props.w,height:t.props.h};const r=1/(e.bottomRight.x-e.topLeft.x)*t.props.w,s=1/(e.bottomRight.y-e.topLeft.y)*t.props.h,o=-n.x*r,i=-n.y*s;return{transform:`translate(${o}px, ${i}px)`,width:r,height:s}}function pu(t,e){const{flipX:n,flipY:r}=t.props;if(!n&&!r)return;const s=`scale(${n?-1:1}, ${r?-1:1})`;return{transform:`${e?`translate(${n?e.width:0}px, ${r?e.height:0}px)`:""} ${s}`,transformOrigin:e?"0 0":"center center"}}function uue({shape:t,src:e}){const n=Jl(),r=b5(t),s=t.props.crop;if(r.transform&&s){const{transform:o,width:i,height:a}=r,l=(s.bottomRight.x-s.topLeft.x)*i,c=(s.bottomRight.y-s.topLeft.y)*a,u=[new x(0,0),new x(l,0),new x(l,c),new x(0,c)],h=pu(t,{width:i,height:a});return d.jsxs(d.Fragment,{children:[d.jsx("defs",{children:d.jsx("clipPath",{id:n,children:d.jsx("polygon",{points:u.map(f=>`${f.x},${f.y}`).join(" ")})})}),d.jsx("g",{clipPath:`url(#${n})`,children:d.jsx("image",{href:e,width:i,height:a,style:h?{...h,transform:`${o} ${h.transform}`}:{transform:o}})})]})}else return d.jsx("image",{href:e,width:t.props.w,height:t.props.h,style:pu(t,{width:t.props.w,height:t.props.h})})}function P5(t){return{size:t,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function C5(t,e,n){const r=e.vertices,s=P5(n);return Bs(r,s)}function due(t,e,n){const r=P5(n);return k1(xm(C5(t,e,n),r),r)}function hue(t,e,n){const r=due(t,e,n);return Sb(r)}function fue(t,e,n){if(t.props.dash==="draw"){const r=C5(t,e,n);return va(r)}return e.getSvgPathData()}function _5(t,e,n){let r=`M ${je(e[0])}L`,s=`M ${je(e[0])}L`;const o=n/3,i=n*2,a=cs(t);let l=e[0],c,u=e[0],h;const f=e.length;for(let p=0,g=f-1;p<g;p++){c=e[p+1],h=x.AddXY(e[p+1],a()*o,a()*o);const m=x.Sub(c,l),v=x.Len(m),y=x.Div(m,v).mul(Math.min(v/4,i)),S=x.Add(l,y),b=x.Add(c,y.neg()),P=x.Sub(h,u),C=x.Len(P),_=x.Div(P,C).mul(Math.min(C/4,i)),E=x.Add(u,_),k=x.Add(h,_.neg());p===g-1?(r+=`${je(S)}L ${je(c)}`,s+=`${je(E)}L ${je(h)}`):(r+=`${je(S)}L ${je(b)}Q ${je(c)}`,s+=`${je(E)}L ${je(k)}Q ${je(h)}`,l=c,u=h)}return[r,r+s]}const pue=new Ds;class Tf extends ss{hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsFg(){return!0}hideSelectionBoundsBg(){return!0}getDefaultProps(){const[e,n]=Fu(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[n]:{id:n,index:n,x:.1,y:.1}},scale:1}}getGeometry(e){return qc(e)}getHandles(e){return pue.get(e.props,()=>{const n=qc(e),r=Xc(e),s=r.map(o=>({...o,id:o.index,type:"vertex",canSnap:!0}));for(let o=0;o<r.length-1;o++){const i=$u(r[o].index,r[o+1].index),l=n.segments[o].midPoint();s.push({id:i,type:"create",index:i,x:l.x,y:l.y,canSnap:!0})}return s.sort(cn)})}onResize(e,n){const{scaleX:r,scaleY:s}=n;return{props:{points:sd(e.props.points,(o,{id:i,index:a,x:l,y:c})=>({id:i,index:a,x:l*r,y:c*s}))}}}onBeforeCreate(e){const{props:{points:n}}=e,r=Object.keys(n);if(r.length<2)return;const s=n[r[0]];if(r.every(i=>{const a=n[i];return a.x===s.x&&a.y===s.y})){const i=r[r.length-1];return n[i]={...n[i],x:n[i].x+.1,y:n[i].y+.1},e}}onHandleDrag(e,{handle:n}){if(n.type!=="vertex")return;const r=is(new x(n.x,n.y),this.editor);return{...e,props:{...e.props,points:{...e.props.points,[n.id]:{id:n.id,index:n.index,x:r.x,y:r.y}}}}}component(e){return d.jsx(mi,{children:d.jsx(QE,{shape:e})})}indicator(e){const n=ks[e.props.size]*e.props.scale,r=qc(e),{dash:s}=e.props;let o;if(e.props.spline==="line"){const i=r.points;if(s==="solid"||s==="dotted"||s==="dashed")o="M"+i[0]+"L"+i.slice(1);else{const[a]=_5(e.id,i,n);o=a}}else o=fue(e,r,n);return d.jsx("path",{d:o})}toSvg(e){return d.jsx(QE,{shouldScale:!0,shape:e})}getHandleSnapGeometry(e){const n=Xc(e);return{points:n,getSelfSnapPoints:r=>{const s=this.getHandles(e).filter(o=>o.type==="vertex").findIndex(o=>o.id===r.id);return n.filter((o,i)=>Math.abs(i-s)>1).map(x.From)},getSelfSnapOutline:r=>{const s=this.getHandles(e).filter(i=>i.type==="vertex").findIndex(i=>i.id===r.id),o=qc(e).segments.filter((i,a)=>a!==s-1&&a!==s);return o.length?new $r({children:o}):null}}}getInterpolatedProps(e,n,r){const s=Xc(e),o=Xc(n),i=[],a=[];let l=QT;if(s.length>o.length)for(let c=0;c<s.length;c++)i[c]={...s[c]},o[c]===void 0?a[c]={...o[o.length-1],id:l}:a[c]={...o[c],id:l},l=_s(l);else if(o.length>s.length)for(let c=0;c<o.length;c++)a[c]={...o[c]},s[c]===void 0?i[c]={...s[s.length-1],id:l}:i[c]={...s[c],id:l},l=_s(l);else for(let c=0;c<o.length;c++)i[c]=s[c],a[c]=o[c];return{...r>.5?n.props:e.props,points:Object.fromEntries(i.map((c,u)=>{const h=a[u];return[c.id,{...c,x:_e(c.x,h.x,r),y:_e(c.y,h.y,r)}]})),scale:_e(e.props.scale,n.props.scale,r)}}}I(Tf,"type","line"),I(Tf,"props",qA),I(Tf,"migrations",ZA);function Xc(t){return Object.values(t.props.points).sort(cn)}function qc(t){const e=Xc(t).map(x.From);switch(t.props.spline){case"cubic":return new gte({points:e});case"line":return new nc({points:e})}}function QE({shape:t,shouldScale:e=!1,forceSolid:n=!1}){const r=zr(),s=qc(t),{dash:o,color:i,size:a}=t.props,l=1/t.props.scale,c=e?l:1,u=ks[a]*t.props.scale;if(t.props.spline==="line"){if(o==="solid"){const h=s.points,f="M"+h[0]+"L"+h.slice(1);return d.jsx("path",{d:f,stroke:r[i].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}if(o==="dashed"||o==="dotted")return d.jsx("g",{stroke:r[i].solid,strokeWidth:u,transform:`scale(${c})`,children:s.segments.map((h,f)=>{const{strokeDasharray:p,strokeDashoffset:g}=n?{strokeDasharray:"none",strokeDashoffset:"none"}:qr(h.length,u,{style:o,start:f>0?"outset":"none",end:f<s.segments.length-1?"outset":"none"});return d.jsx("path",{strokeDasharray:p,strokeDashoffset:g,d:h.getSvgPathData(!0),fill:"none"},f)})});if(o==="draw"){const h=s.points,[f,p]=_5(t.id,h,u);return d.jsx("path",{d:p,stroke:r[i].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}}if(t.props.spline==="cubic"){const h=s.getSvgPathData();if(o==="solid")return d.jsx("path",{strokeWidth:u,stroke:r[i].solid,fill:"none",d:h,transform:`scale(${c})`});if(o==="dashed"||o==="dotted")return d.jsx("g",{stroke:r[i].solid,strokeWidth:u,transform:`scale(${c})`,children:s.segments.map((f,p)=>{const{strokeDasharray:g,strokeDashoffset:m}=qr(f.length,u,{style:o,start:p>0?"outset":"none",end:p<s.segments.length-1?"outset":"none",forceSolid:n});return d.jsx("path",{strokeDasharray:g,strokeDashoffset:m,d:f.getSvgPathData(),fill:"none"},p)})});if(o==="draw")return d.jsx("path",{d:hue(t,s,u),strokeWidth:1,stroke:r[i].solid,fill:r[i].solid,transform:`scale(${c})`})}}class Mf extends ss{canEdit(){return!0}hideResizeHandles(){return!0}hideSelectionBoundsFg(){return!1}getDefaultProps(){return{color:"black",size:"m",text:"",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:0,url:"",scale:1}}getGeometry(e){const{labelHeight:n,labelWidth:r}=I5(this.editor,e),{scale:s}=e.props,o=n*s,i=r*s,a=He*s,l=zh(e);return new $r({children:[new Fs({width:a,height:l,isFilled:!0}),new Fs({x:e.props.align==="start"?0:e.props.align==="end"?a-i:(a-i)/2,y:e.props.verticalAlign==="start"?0:e.props.verticalAlign==="end"?l-o:(l-o)/2,width:i,height:o,isFilled:!0,isLabel:!0})]})}getHandles(e){const{scale:n}=e.props;if(this.editor.getInstanceState().isCoarsePointer)return[];const s=this.editor.getZoomLevel();if(s*n<.25)return[];const o=zh(e),i=He*n,a=Ole/s*n;return s*n<.5?[{id:"bottom",index:"a3",type:"clone",x:i/2,y:o+a}]:[{id:"top",index:"a1",type:"clone",x:i/2,y:-a},{id:"right",index:"a2",type:"clone",x:i+a,y:o/2},{id:"bottom",index:"a3",type:"clone",x:i/2,y:o+a},{id:"left",index:"a4",type:"clone",x:-a,y:o/2}]}getText(e){return e.props.text}component(e){const{id:n,type:r,props:{labelColor:s,scale:o,color:i,font:a,size:l,align:c,text:u,verticalAlign:h,fontSizeAdjustment:f}}=e,p=yue(n),g=zr(),m=He*o,v=zh(e),y=U("shape rotation",()=>{var C;return((C=this.editor.getShapePageTransform(n))==null?void 0:C.rotation())??0},[this.editor]),S=U("zoom",()=>this.editor.getZoomLevel()<.35/o,[o,this.editor]),b=U("dark mode",()=>this.editor.user.getIsDarkMode(),[this.editor]),P=e.id===this.editor.getOnlySelectedShapeId();return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:n,className:"tl-note__container",style:{width:m,height:v,backgroundColor:g[i].note.fill,borderBottom:S?b?`${2*o}px solid rgb(20, 20, 20)`:`${2*o}px solid rgb(144, 144, 144)`:"none",boxShadow:S?"none":Sue(e.id,y,o)},children:d.jsx(Cm,{shapeId:n,type:r,font:a,fontSize:(f||yo[l])*o,lineHeight:pn.lineHeight,align:c,verticalAlign:h,text:u,isNote:!0,isSelected:P,labelColor:s==="black"?g[i].note.text:g[s].fill,wrap:!0,padding:16*o,onKeyDown:p})}),"url"in e.props&&e.props.url&&d.jsx(Fl,{url:e.props.url})]})}indicator(e){const{scale:n}=e.props;return d.jsx("rect",{rx:n,width:N(He*n),height:N(zh(e))})}toSvg(e,n){e.props.text&&n.addExportDef(bm(e.props.font));const r=ko({isDarkMode:n.isDarkMode}),s=vue(e);return d.jsxs(d.Fragment,{children:[d.jsx("rect",{x:5,y:5,rx:1,width:He-10,height:s.h,fill:"rgba(0,0,0,.1)"}),d.jsx("rect",{rx:1,width:He,height:s.h,fill:r[e.props.color].note.fill}),d.jsx(Pm,{fontSize:e.props.fontSizeAdjustment||yo[e.props.size],font:e.props.font,align:e.props.align,verticalAlign:e.props.verticalAlign,text:e.props.text,labelColor:r[e.props.color].note.text,bounds:s,stroke:!1})]})}onBeforeCreate(e){return JE(this.editor,e)}onBeforeUpdate(e,n){if(!(e.props.text===n.props.text&&e.props.font===n.props.font&&e.props.size===n.props.size))return JE(this.editor,n)}onEditEnd(e){const{id:n,type:r,props:{text:s}}=e;s.trimEnd()!==e.props.text&&this.editor.updateShapes([{id:n,type:r,props:{text:s.trimEnd()}}])}getInterpolatedProps(e,n,r){return{...r>.5?n.props:e.props,scale:_e(e.props.scale,n.props.scale,r)}}}I(Mf,"type","note"),I(Mf,"props",QA),I(Mf,"migrations",JA);function JE(t,e){const{labelHeight:n,fontSizeAdjustment:r}=I5(t,e),s=Math.max(0,n-He);if(s!==e.props.growY||r!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:s,fontSizeAdjustment:r}}}function gue(t,e){const{text:n}=e.props;if(!n)return{labelHeight:yo[e.props.size]*pn.lineHeight+Er*2,labelWidth:100,fontSizeAdjustment:0};const r=yo[e.props.size];let s=0,o=0,i=He,a=He;const l=1;do{s=Math.min(r,r-o);const c=t.textMeasure.measureText(n,{...pn,fontFamily:Co[e.props.font],fontSize:s,maxWidth:He-Er*2-l,disableOverflowWrapBreaking:!0});if(i=c.h+Er*2,a=c.w+Er*2,s<=14){const u=t.textMeasure.measureText(n,{...pn,fontFamily:Co[e.props.font],fontSize:s,maxWidth:He-Er*2-l});i=u.h+Er*2,a=u.w+Er*2;break}if(c.scrollWidth.toFixed(0)===c.w.toFixed(0))break}while(o++<50);return{labelHeight:i,labelWidth:a,fontSizeAdjustment:s}}const mue=new Ds;function I5(t,e){return mue.get(e,()=>gue(t,e))}function yue(t){const e=z(),n=t$();return w.useCallback(r=>{const s=e.getShape(t);if(!s)return;const o=r.key==="Tab",i=(r.metaKey||r.ctrlKey)&&r.key==="Enter";if(o||i){r.preventDefault();const a=e.getShapePageTransform(t),l=a.rotation(),c=!!(n.dir==="rtl"||q$(s.props.text)),u=(He+e.options.adjacentShapeMargin+(i&&!r.shiftKey?s.props.growY:0))*s.props.scale,h=new x(o?r.shiftKey!=c?-1:1:0,i?r.shiftKey?-1:1:0).mul(u).add(wm.clone().mul(s.props.scale)).rot(l).add(a.point()),f=r5(e,s,h,l);f&&(e.markHistoryStoppingPoint("editing adjacent shape"),Wp(e,f,!0))}},[t,e,n.dir])}function zh(t){return(He+t.props.growY)*t.props.scale}function Sue(t,e,n){const r=cs(t),s=Math.abs(r())+.5,o=Math.cos(e),i=5*n,a=4*n,l=6*n,c=7*n;return`0px ${i-s}px ${i}px -${i}px rgba(15, 23, 31, .6),
|
|
382
|
-
0px ${(a+s*c)*Math.max(0,o)}px ${l+s*c}px -${a+s*l}px rgba(15, 23, 31, ${(.3+s*.1).toFixed(2)}),
|
|
383
|
-
0px ${48*n}px ${10*n}px -${10*n}px inset rgba(15, 23, 44, ${((.022+r()*.005)*((1+o)/2)).toFixed(2)})`}function vue(t){return new Z(0,0,He,He+t.props.growY)}function xue(t,{initialBounds:e,scaleX:n,scaleY:r,newPoint:s}){const o=Math.max(.01,Math.min(Math.abs(n),Math.abs(r))),i=new x(0,0);n<0&&(i.x=-(e.width*o)),r<0&&(i.y=-(e.height*o));const{x:a,y:l}=x.Add(s,i.rot(t.rotation));return{x:a,y:l,props:{scale:o*t.props.scale}}}const wue=new Ds;class Af extends ss{getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",textAlign:"start",autoSize:!0,scale:1}}getMinDimensions(e){return wue.get(e.props,n=>e2(this.editor,n))}getGeometry(e){const{scale:n}=e.props,{width:r,height:s}=this.getMinDimensions(e);return new Fs({width:r*n,height:s*n,isFilled:!0,isLabel:!0})}getText(e){return e.props.text}canEdit(){return!0}isAspectRatioLocked(){return!0}component(e){const{id:n,props:{font:r,size:s,text:o,color:i,scale:a,textAlign:l}}=e,{width:c,height:u}=this.getMinDimensions(e),h=e.id===this.editor.getOnlySelectedShapeId(),f=zr(),p=bue(n);return d.jsx(Cm,{shapeId:n,classNamePrefix:"tl-text-shape",type:"text",font:r,fontSize:Ll[s],lineHeight:pn.lineHeight,align:l,verticalAlign:"middle",text:o,labelColor:f[i].solid,isSelected:h,textWidth:c,textHeight:u,style:{transform:`scale(${a})`,transformOrigin:"top left"},wrap:!0,onKeyDown:p})}indicator(e){const n=this.editor.getShapeGeometry(e).bounds,r=z();return e.props.autoSize&&r.getEditingShapeId()===e.id?null:d.jsx("rect",{width:N(n.width),height:N(n.height)})}toSvg(e,n){e.props.text&&n.addExportDef(bm(e.props.font));const r=this.editor.getShapeGeometry(e).bounds,s=r.width/(e.props.scale??1),o=r.height/(e.props.scale??1),i=ko(n);return d.jsx(Pm,{fontSize:Ll[e.props.size],font:e.props.font,align:e.props.textAlign,verticalAlign:"middle",text:e.props.text,labelColor:i[e.props.color].solid,bounds:new Z(0,0,s,o),padding:0})}onResize(e,n){const{newPoint:r,initialBounds:s,initialShape:o,scaleX:i,handle:a}=n;if(n.mode==="scale_shape"||a!=="right"&&a!=="left")return{id:e.id,type:e.type,...xue(e,n)};{const l=Math.max(1,Math.abs(s.width*i)),{x:c,y:u}=i<0?x.Sub(r,x.FromAngle(e.rotation).mul(l)):r;return{id:e.id,type:e.type,x:c,y:u,props:{w:l/o.props.scale,autoSize:!1}}}}onEditEnd(e){const{id:n,type:r,props:{text:s}}=e,o=e.props.text.trimEnd();o.length===0?this.editor.deleteShapes([e.id]):o!==e.props.text&&this.editor.updateShapes([{id:n,type:r,props:{text:s.trimEnd()}}])}onBeforeUpdate(e,n){if(!n.props.autoSize)return;const r=e.props.size!==n.props.size||e.props.textAlign!==n.props.textAlign||e.props.font!==n.props.font||e.props.scale!==1&&n.props.scale===1,s=e.props.text!==n.props.text;if(!r&&!s)return;const o=this.getMinDimensions(e),i=e2(this.editor,n.props),a=o.width*e.props.scale,l=o.height*e.props.scale,c=i.width*n.props.scale,u=i.height*n.props.scale;let h;switch(n.props.textAlign){case"middle":{h=new x((c-a)/2,s?0:(u-l)/2);break}case"end":{h=new x(c-a,s?0:(u-l)/2);break}default:{if(s)break;h=new x(0,(u-l)/2);break}}if(h){h.rot(n.rotation);const{x:f,y:p}=n;return{...n,x:f-h.x,y:p-h.y,props:{...n.props,w:c}}}else return{...n,props:{...n.props,w:c}}}}I(Af,"type","text"),I(Af,"props",ej),I(Af,"migrations",tj);function e2(t,e){const{font:n,text:r,autoSize:s,size:o,w:i}=e,a=s?16:Math.max(16,i),l=Ll[o],c=s?null:Math.floor(Math.max(a,i)),u=t.textMeasure.measureText(r,{...pn,fontFamily:Co[n],fontSize:l,maxWidth:c});return s&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(l,u.h)}}function bue(t){const e=z();return w.useCallback(n=>{if(e.getEditingShapeId()===t)switch(n.key){case"Enter":{(n.ctrlKey||n.metaKey)&&e.complete();break}case"Tab":{xe(n),n.shiftKey?$l.unindent(n.currentTarget):$l.indent(n.currentTarget);break}}},[e,t])}class jf extends oc{canEdit(){return!0}isAspectRatioLocked(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(e){return d.jsx(Pue,{shape:e})}indicator(e){return d.jsx("rect",{width:N(e.props.w),height:N(e.props.h)})}async toSvg(e){const n=await Cue(this.editor,e);return n?d.jsx("image",{href:n,width:e.props.w,height:e.props.h}):null}}I(jf,"type","video"),I(jf,"props",nj),I(jf,"migrations",rj);const Pue=w.memo(function({shape:e}){const n=z(),r=n.getShapeGeometry(e).bounds.w*n.getZoomLevel()>=110,s=Zg(e.id),o=QR(),{Spinner:i}=st(),{asset:a,url:l}=w5({shapeId:e.id,assetId:e.props.assetId}),c=w.useRef(null),[u,h]=w.useState(!1),[f,p]=w.useState(!1);w.useEffect(()=>{const m=()=>p(document.fullscreenElement===c.current);return document.addEventListener("fullscreenchange",m),()=>document.removeEventListener("fullscreenchange",m)});const g=w.useCallback(m=>{m.currentTarget&&h(!0)},[]);return w.useEffect(()=>{const m=c.current;m&&s&&document.activeElement!==m&&m.focus()},[s,u]),w.useEffect(()=>{if(o){const m=c.current;if(!m)return;m.pause(),m.currentTime=0}},[c,o]),d.jsxs(d.Fragment,{children:[d.jsx(hi,{id:e.id,style:{color:"var(--color-text-3)",backgroundColor:a?"transparent":"var(--color-low)",border:a?"none":"1px solid var(--color-low-border)"},children:d.jsx("div",{className:"tl-counter-scaled",children:d.jsx("div",{className:"tl-video-container",children:a?i&&!a.props.src?d.jsx(i,{}):l?d.jsxs(d.Fragment,{children:[d.jsx("video",{ref:c,style:s?{pointerEvents:"all"}:u?void 0:{display:"none"},className:ce("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&&r,onLoadedData:g,hidden:!u,children:d.jsx("source",{src:l})}),!u&&i&&d.jsx(i,{})]}):null:d.jsx(x5,{})})})}),"url"in e.props&&e.props.url&&d.jsx(Fl,{url:e.props.url})]})});async function Cue(t,e){const n=await t.resolveAssetUrl(e.props.assetId,{shouldResolveToOriginal:!0});if(!n)return null;const r=await ar.loadVideo(n);return ar.getVideoFrameAsDataUrl(r,0)}const E5=[Af,Pf,Cf,If,Mf,Tf,_f,bf,Ef,Jp,kf,jf];function _ue(t){return t.sideEffects.register({instance_page_state:{afterChange:(e,n)=>{if(e.croppingShapeId!==n.croppingShapeId){const r=t.isIn("select.crop");!e.croppingShapeId&&n.croppingShapeId?r||t.setCurrentTool("select.crop.idle"):e.croppingShapeId&&!n.croppingShapeId&&r&&t.setCurrentTool("select.idle")}if(e.editingShapeId!==n.editingShapeId)if(!e.editingShapeId&&n.editingShapeId){if(!t.isIn("select.editing_shape")){const r=t.getEditingShape();r&&r.type==="text"&&t.isInAny("text.pointing","select.resizing")&&t.getInstanceState().isToolLocked?t.setCurrentTool("select.editing_shape",{isCreatingTextWhileToolLocked:!0}):t.setCurrentTool("select.editing_shape")}}else e.editingShapeId&&!n.editingShapeId&&t.isIn("select.editing_shape")&&t.setCurrentTool("select.idle")}}})}class k5 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"scribbleId","id");I(this,"markId","");I(this,"excludedShapeIds",new Set)}onEnter(n){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=n;const{originPagePoint:r}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(o=>{if(this.editor.isShapeOrAncestorLocked(o))return!0;if(this.editor.isShapeOfType(o,"group")||this.editor.isShapeOfType(o,"frame")){const i=this.editor.getPointInShapeSpace(o,r);return this.editor.getShapeGeometry(o).bounds.containsPoint(i)}return!1}).map(o=>o.id));const s=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=s.id,this.update()}pushPointToScribble(){const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)}onExit(){this.editor.setErasingShapes([]),this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}update(){const{editor:n,excludedShapeIds:r}=this,s=n.getErasingShapeIds(),o=n.getZoomLevel(),i=n.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:a,previousPagePoint:l}}=n;this.pushPointToScribble();const c=new Set(s),u=this.editor.options.hitTestMargin/o;for(const h of i){if(n.isShapeOfType(h,"group"))continue;const f=n.getShapeMask(h.id);if(f&&!hr(a,f))continue;const p=n.getShapeGeometry(h),g=n.getShapePageTransform(h);if(!p||!g)continue;const m=g.clone().invert(),v=m.applyToPoint(l),y=m.applyToPoint(a),{bounds:S}=p;S.minX-u>Math.max(v.x,y.x)||S.minY-u>Math.max(v.y,y.y)||S.maxX+u<Math.min(v.x,y.x)||S.maxY+u<Math.min(v.y,y.y)||p.hitTestLineSegment(v,y,u)&&c.add(n.getOutermostSelectableShape(h).id)}this.editor.setErasingShapes([...c].filter(h=>!r.has(h)))}complete(){const{editor:n}=this;n.deleteShapes(n.getCurrentPageState().erasingShapeIds),this.parent.transition("idle")}cancel(){const{editor:n}=this;n.bailToMark(this.markId),this.parent.transition("idle",this.info)}}I(k5,"id","erasing");var WS;let Iue=(WS=class extends ie{onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},I(WS,"id","idle"),WS);var GS;let Eue=(GS=class extends ie{onEnter(){const e=this.editor.getZoomLevel(),n=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:r}}=this.editor,s=new Set,o=s.size;for(let i=n.length,a=i-1;a>=0;a--){const l=n[a];if(!(this.editor.isShapeOrAncestorLocked(l)||this.editor.isShapeOfType(l,"group"))&&this.editor.isPointInShape(l,r,{hitInside:!1,margin:this.editor.options.hitTestMargin/e})){const c=this.editor.getOutermostSelectableShape(l);if(this.editor.isShapeOfType(c,"frame")&&s.size>o)break;s.add(c.id)}}this.editor.setErasingShapes([...s])}onLongPress(e){this.startErasing(e)}onExit(e,n){n!=="erasing"&&this.editor.setErasingShapes([])}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.parent.transition("idle")}cancel(){this.parent.transition("idle")}},I(GS,"id","pointing"),GS);class Of extends ie{static children(){return[Iue,Eue,k5]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}I(Of,"id","eraser"),I(Of,"initial","idle"),I(Of,"isLockable",!1);class T5 extends ie{constructor(){super(...arguments);I(this,"initialCamera",new x)}onEnter(){this.initialCamera=x.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){const{initialCamera:n,editor:r}=this,{currentScreenPoint:s,originScreenPoint:o}=r.inputs,i=x.Sub(s,o).div(r.getZoomLevel());i.len2()!==0&&r.setCamera(n.clone().add(i))}complete(){const{editor:n}=this,{pointerVelocity:r}=n.inputs,s=Math.min(r.len(),2);s>.1&&this.editor.slideCamera({speed:s,direction:r}),this.parent.transition("idle")}}I(T5,"id","dragging");var VS;let kue=(VS=class extends ie{onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},I(VS,"id","idle"),VS);var YS;let Tue=(YS=class extends ie{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")}},I(YS,"id","pointing"),YS);class Df extends ie{static children(){return[kue,Tue,T5]}onDoubleClick(e){if(e.phase==="settle"){const{currentScreenPoint:n}=this.editor.inputs;this.editor.zoomIn(n,{animation:{duration:220,easing:Dt.easeOutQuint}})}}onTripleClick(e){if(e.phase==="settle"){const{currentScreenPoint:n}=this.editor.inputs;this.editor.zoomOut(n,{animation:{duration:320,easing:Dt.easeOutQuint}})}}onQuadrupleClick(e){if(e.phase==="settle"){const n=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:r}}=this.editor;n===1?this.editor.zoomToFit({animation:{duration:400,easing:Dt.easeOutQuint}}):this.editor.resetZoom(r,{animation:{duration:320,easing:Dt.easeOutQuint}})}}}I(Df,"id","hand"),I(Df,"initial","idle"),I(Df,"isLockable",!1);var XS;let Mue=(XS=class extends ie{onPointerDown(e){this.parent.transition("lasering",e)}},I(XS,"id","idle"),XS);class M5 extends ie{constructor(){super(...arguments);I(this,"scribbleId","id")}onEnter(){const n=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:this.editor.options.laserDelayMs,shrink:.05,taper:!0});this.scribbleId=n.id,this.pushPointToScribble()}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.pushPointToScribble()}onPointerUp(){this.complete()}pushPointToScribble(){const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)}onCancel(){this.cancel()}onComplete(){this.complete()}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}I(M5,"id","lasering");class Rf extends ie{static children(){return[Mue,M5]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}I(Rf,"id","laser"),I(Rf,"initial","idle"),I(Rf,"isLockable",!1);class A5 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"initialSelectedShapeIds",[]);I(this,"excludedShapeIds",new Set);I(this,"isWrapMode",!1);I(this,"initialStartShape",null)}onEnter(n){const{altKey:r,currentPagePoint:s}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),r){this.parent.transition("scribble_brushing",n);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(o=>this.editor.isShapeOfType(o,"group")||this.editor.isShapeOrAncestorLocked(o)).map(o=>o.id)),this.info=n,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(s)[0],this.hitTestShapes()}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})}onTick({elapsed:n}){const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(n)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(n){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",n)}onKeyDown(n){this.editor.inputs.altKey?this.parent.transition("scribble_brushing",n):this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:n,excludedShapeIds:r,isWrapMode:s}=this,{inputs:{originPagePoint:o,currentPagePoint:i,shiftKey:a,ctrlKey:l}}=n,c=new Set(a?this.initialSelectedShapeIds:[]),u=s?!l:l,h=Z.FromPoints([o,i]),{corners:f}=h;let p,g,m,v,y,S;const b=n.getCurrentPageRenderingShapesSorted(),P=n.getCurrentPageId();e:for(let E=0,k=b.length;E<k;E++){if(m=b[E],r.has(m.id)||c.has(m.id)||(v=n.getShapePageBounds(m),!v))continue e;if(h.contains(v)){this.handleHit(m,i,P,c,f);continue e}if(u||n.isShapeOfType(m,"frame"))continue e;if(h.collides(v)){if(y=n.getShapePageTransform(m),!y)continue e;S=y.clone().invert().applyToPoints(f);const D=n.getShapeGeometry(m);t:for(let T=0;T<4;T++)if(p=S[T],g=S[(T+1)%4],D.hitTestLineSegment(p,g,0)){this.handleHit(m,i,P,c,f);break t}}}const C=n.getInstanceState().brush;(!C||!h.equals(C))&&n.updateInstanceState({brush:{...h.toJson()}});const _=n.getSelectedShapeIds();(_.length!==c.size||_.some(E=>!c.has(E)))&&n.setSelectedShapes(Array.from(c))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(n,r,s,o,i){if(n.parentId===s){o.add(n.id);return}const a=this.editor.getOutermostSelectableShape(n),l=this.editor.getShapeMask(a.id);l&&!_b(l,i)&&!hr(r,l)||o.add(a.id)}}I(A5,"id","brushing");const zl={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 j5 extends ie{constructor(){super(...arguments);I(this,"info",{})}updateCursor(){const n=this.editor.getSelectedShapes(),r=zl[this.info.handle];this.editor.setCursor({type:r,rotation:n.length===1?this.editor.getSelectionRotation():0})}onEnter(n){this.info=n,this.updateCursor()}onPointerMove(){this.editor.inputs.isDragging&&this.startResizing()}onLongPress(){this.startResizing()}startResizing(){this.editor.getIsReadonly()||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")}}I(j5,"id","pointing_resize_handle");const _r=8;class F1 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"markId","");I(this,"snapshot",{})}onEnter(n){this.info=n,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 r=zl[this.info.handle];this.editor.setCursor({type:r,rotation:this.editor.getSelectionRotation()})}getDefaultCrop(){return{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}}updateShapes(){const{shape:n,cursorHandleOffset:r}=this.snapshot;if(!n||!this.editor.getShapeUtil("image"))return;const o=n.props,i=this.editor.inputs.currentPagePoint.clone().sub(r),a=this.editor.inputs.originPagePoint.clone().sub(r),l=i.clone().sub(a).rot(-n.rotation),c=o.crop??this.getDefaultCrop(),u=nt(c),h=new x(n.x,n.y),f=new x(0,0),p=1/(c.bottomRight.x-c.topLeft.x)*o.w,g=1/(c.bottomRight.y-c.topLeft.y)*o.h;let m=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(g<_r)break;m=!0,u.topLeft.y=u.topLeft.y+l.y/g,g*(u.bottomRight.y-u.topLeft.y)<_r?(u.topLeft.y=u.bottomRight.y-_r/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<_r)break;m=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+l.y/g),g*(u.bottomRight.y-u.topLeft.y)<_r&&(u.bottomRight.y=u.topLeft.y+_r/g);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(p<_r)break;m=!0,u.topLeft.x=u.topLeft.x+l.x/p,p*(u.bottomRight.x-u.topLeft.x)<_r?(u.topLeft.x=u.bottomRight.x-_r/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<_r)break;m=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+l.x/p),p*(u.bottomRight.x-u.topLeft.x)<_r&&(u.bottomRight.x=u.topLeft.x+_r/p);break}}if(!m)return;h.add(f.rot(n.rotation));const v={id:n.id,type:n.type,x:h.x,y:h.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*p,h:(u.bottomRight.y-u.topLeft.y)*g}};this.editor.updateShapes([v]),this.updateCursor()}complete(){this.updateShapes(),Xe(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 n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:r}}=this.editor,s=this.editor.getOnlySelectedShape(),o=this.editor.getSelectionRotatedPageBounds(),i=x.RotWith(o.getHandlePoint(this.info.handle),o.point,n),a=x.Sub(r,i);return{shape:s,cursorHandleOffset:a}}}I(F1,"id","cropping");function O5(t,e=!1){const n=t.getZoomLevel(),{inputs:{currentPagePoint:r}}=t;return t.getShapeAtPoint(r,{hitInside:!1,hitLabels:e,margin:t.options.hitTestMargin/n,renderingOnly:!0})??t.getSelectedShapeAtPoint(r)}function D5(t,e,n){if(!e)throw Error("Needs to translate a cropped shape!");const{crop:r}=e.props;if(!r)return;const s=t.inputs.shiftKey?Math.abs(n.x)<Math.abs(n.y)?"x":"y":null;s==="x"?n.x=0:s==="y"&&(n.y=0),n.rot(-e.rotation);const o=1/(r.bottomRight.x-r.topLeft.x)*e.props.w,i=1/(r.bottomRight.y-r.topLeft.y)*e.props.h,a=r.bottomRight.y-r.topLeft.y,l=r.bottomRight.x-r.topLeft.x,c=nt(r);return c.topLeft.x=Math.min(1-l,Math.max(0,c.topLeft.x-n.x/o)),c.topLeft.y=Math.min(1-a,Math.max(0,c.topLeft.y-n.y/i)),c.bottomRight.x=c.topLeft.x+l,c.bottomRight.y=c.topLeft.y+a,{id:e.id,type:e.type,props:{crop:c}}}var qS;let Aue=(qS=class extends ie{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 n;if(e.accelKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{const r=O5(this.editor);if(r&&!this.editor.isShapeOfType(r,"group")){this.onPointerDown({...e,shape:r,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(n=this.editor.getShapeUtil(e.shape))!=null&&n.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 o;if(this.editor.inputs.shiftKey||e.phase!=="up")return;const n=this.editor.getCroppingShapeId();if(!n)return;const r=this.editor.getShape(n);if(!r)return;const s=this.editor.getShapeUtil(r);if(s){if(e.target==="selection"){(o=s.onDoubleClickEdge)==null||o.call(s,r);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:n}}}=this,r=n.has("ShiftLeft"),s=new x(0,0);if(n.has("ArrowLeft")&&(s.x+=1),n.has("ArrowRight")&&(s.x-=1),n.has("ArrowUp")&&(s.y+=1),n.has("ArrowDown")&&(s.y-=1),s.equals(new x(0,0)))return;r&&s.mul(10);const o=this.editor.getShape(this.editor.getCroppingShapeId());if(!o)return;const i=D5(this.editor,o,s);i&&(e||this.editor.markHistoryStoppingPoint("translate crop"),this.editor.updateShapes([i]))}},I(qS,"id","idle"),qS);class R5 extends ie{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)}}I(R5,"id","pointing_crop");class N1 extends ie{constructor(){super(...arguments);I(this,"info",{})}onEnter(n){this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];if(!r)return;const s=zl[this.info.handle];this.editor.setCursor({type:s,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(r.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.getIsReadonly()||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"))}}I(N1,"id","pointing_crop_handle");class L5 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"markId","");I(this,"snapshot",{})}onEnter(n){this.info=n,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(n){switch(n.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(n){switch(n.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 n=this.snapshot.shape;if(!n)return;const{originPagePoint:r,currentPagePoint:s}=this.editor.inputs,o=s.clone().sub(r),i=D5(this.editor,n,o);i&&this.editor.updateShapes([i])}}I(L5,"id","translating_crop");class dw extends ie{constructor(){super(...arguments);I(this,"markId","");I(this,"didExit",!1)}static children(){return[Aue,L5,R5,N1,F1]}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))}}I(dw,"id","crop"),I(dw,"initial","idle");class $5 extends ie{constructor(){super(...arguments);I(this,"shapeId","");I(this,"initialHandle",{});I(this,"initialAdjacentHandle",null);I(this,"initialPagePoint",{});I(this,"markId","");I(this,"initialPageTransform");I(this,"initialPageRotation");I(this,"info",{});I(this,"isPrecise",!1);I(this,"isPreciseId",null);I(this,"pointingId",null);I(this,"exactTimeout",-1)}onEnter(n){const{shape:r,isCreating:s,creatingMarkId:o,handle:i}=n;if(this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.shapeId=r.id,this.markId="",s)if(o)this.markId=o;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=nt(i),this.editor.isShapeOfType(r,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...r,props:{points:{...r.props.points,[i.index]:{id:i.index,index:i.index,x:i.x,y:i.y}}}});const u=this.editor.getShapeHandles(r).find(h=>h.index===i.index);this.initialHandle=nt(u)}this.initialPageTransform=this.editor.getShapePageTransform(r),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.setCursor({type:s?"cross":"grabbing",rotation:0});const a=this.editor.getShapeHandles(r).sort(cn),l=a.findIndex(c=>c.id===n.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!==n.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!==n.handle.id){this.initialAdjacentHandle=u;break}}if(this.editor.isShapeOfType(r,"arrow")){const c=Un(this.editor,r)[n.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(),Xe(this.editor,[this.shapeId]);const{onInteractionEnd:n}=this.info;if(this.editor.getInstanceState().isToolLocked&&n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:n}=this.info;if(n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var E;const{editor:n,shapeId:r,initialPagePoint:s}=this,{initialHandle:o,initialPageRotation:i,initialAdjacentHandle:a}=this,l=this.editor.getHintingShapeIds(),c=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:h,shiftKey:f,ctrlKey:p,altKey:g,pointerVelocity:m}}=n,v=this.info.shape,y=n.getShape(r);if(!y)return;const S=n.getShapeUtil(y);let b=h.clone().sub(s).rot(-i).add(o);if(f&&a&&o.id!=="middle"){const k=x.Angle(a,b),T=Rp(k,24)-k;b=x.RotWith(b,a,T)}n.snaps.clearIndicators();let P={...o,x:b.x,y:b.y};if(o.canSnap&&(c?!p:p)){if(!n.getShapePageTransform(y.id))throw Error("Expected a page transform");const D=u.handles.snapHandle({currentShapeId:r,handle:P});D&&(D.nudge.rot(-n.getShapeParentTransform(y).rotation()),b.add(D.nudge),P={...o,x:b.x,y:b.y})}const C=(E=S.onHandleDrag)==null?void 0:E.call(S,y,{handle:P,isPrecise:this.isPrecise||g,initial:v}),_={id:y.id,type:y.type,...C};if(o.type==="vertex"&&this.editor.isShapeOfType(y,"arrow")){const k=Un(n,y)[o.id];k?l[0]!==k.toId&&(n.setHintingShapes([k.toId]),this.pointingId=k.toId,this.isPrecise=m.len()<.5||g,this.isPreciseId=this.isPrecise?k.toId:null,this.resetExactTimeout()):l.length>0&&(n.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}C&&n.updateShapes([_])}}I($5,"id","dragging_handle");function F5(t){return t.isLabel?[t]:t instanceof $r?t.children.filter(e=>e.isLabel):[]}class N5 extends ie{constructor(){super(...arguments);I(this,"hitShapeForPointerUp",null);I(this,"info",{})}onEnter(n){const r=this.editor.getEditingShape();if(!r)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,this.info=n,n.isCreatingTextWhileToolLocked&&this.parent.setCurrentToolIdMask("text"),uo(this.editor),this.editor.select(r)}onExit(){var o;const{editingShapeId:n}=this.editor.getCurrentPageState();if(!n)return;this.editor.setEditingShape(null),uo.cancel();const r=this.editor.getShape(n),s=this.editor.getShapeUtil(r);(o=s.onEditEnd)==null||o.call(s,r),this.info.isCreatingTextWhileToolLocked&&(this.parent.setCurrentToolIdMask(void 0),this.editor.setCurrentTool("text",{}))}onPointerMove(n){if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly()||this.hitShapeForPointerUp.isLocked)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",n),this.hitShapeForPointerUp=null;return}switch(n.target){case"shape":case"canvas":{uo(this.editor);return}}}onPointerDown(n){switch(this.hitShapeForPointerUp=null,n.target){case"shape":{const{shape:r}=n,s=this.editor.getEditingShape();if(!s)throw Error("Expected an editing shape!");const o=this.editor.getShapeUtil(r).getGeometry(r),i=F5(o),a=i.length===1?i[0]:void 0,l=this.editor.isShapeOfType(s,"text")&&s.props.text.trim()==="";if(a&&!l){const c=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(c,0)&&a.hitTestPoint(c)){if(r.id===s.id)return;this.hitShapeForPointerUp=r,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(r.id);return}}else{if(r.id===s.id)this.editor.isShapeOfType(r,"frame")&&(this.editor.setEditingShape(null),this.parent.transition("idle",n));else{this.parent.transition("pointing_shape",n);return}return}break}}this.parent.transition("idle",n),this.editor.root.handleEvent(n)}onPointerUp(n){const r=this.hitShapeForPointerUp;if(!r)return;this.hitShapeForPointerUp=null;const s=this.editor.getShapeUtil(r);if(!r.isLocked){if(this.editor.getIsReadonly()&&!s.canEditInReadOnly(r)){this.parent.transition("pointing_shape",n);return}this.editor.select(r.id),this.editor.setEditingShape(r.id),uo(this.editor)}}onComplete(n){this.parent.transition("idle",n)}onCancel(n){this.parent.transition("idle",n)}}I(N5,"id","editing_shape");function t2(t){const e=t.getOnlySelectedShape();return!!(e&&!t.isShapeOrAncestorLocked(e)&&t.getShapeUtil(e).canCrop(e))}function eg(t,e){const n=t.getSelectedShapeIds(),{currentPagePoint:r}=t.inputs,{shiftKey:s,altKey:o,accelKey:i}=e,a=s||i,l=t.getShapeAtPoint(r,{hitInside:!1,margin:t.options.hitTestMargin/t.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:c=>!c.isLocked});if(l){const c=t.getOutermostSelectableShape(l);if(a&&!o)t.cancelDoubleClick(),n.includes(c.id)?(t.markHistoryStoppingPoint("deselecting shape"),t.deselect(c)):(t.markHistoryStoppingPoint("shift selecting shape"),t.setSelectedShapes([...n,c.id]));else{let u;c===l||c.id===t.getFocusedGroupId()||n.includes(c.id)?u=l:u=c,u&&!n.includes(u.id)&&(t.markHistoryStoppingPoint("selecting shape"),t.select(u.id))}}else{if(a)return;{n.length>0&&(t.markHistoryStoppingPoint("selecting none"),t.selectNone());const c=t.getFocusedGroupId();if(Fn(c)){const u=t.getShape(c);t.isPointInShape(u,r,{margin:0,hitInside:!0})||t.setFocusedGroup(null)}}}}const jue=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var ZS;let Oue=(ZS=class extends ie{onEnter(){this.parent.setCurrentToolIdMask(void 0),uo(this.editor),this.editor.setCursor({type:"default",rotation:0})}onExit(){uo.cancel()}onPointerMove(){uo(this.editor)}onPointerDown(e){const n=e.ctrlKey&&t2(this.editor);switch(e.target){case"canvas":{const r=O5(this.editor);if(r&&!r.isLocked){this.onPointerDown({...e,shape:r,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),o=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:i}}=this.editor;if((s.length>1||o&&!this.editor.getShapeUtil(o).hideSelectionBoundsBg(o))&&n2(this.editor,i)){this.onPointerDown({...e,target:"selection"});return}this.parent.transition("pointing_canvas",e);break}case"shape":{const{shape:r}=e;if(this.isOverArrowLabelTest(r)){this.parent.transition("pointing_arrow_label",e);break}if(this.editor.isShapeOrAncestorLocked(r)){this.parent.transition("pointing_canvas",e);break}this.parent.transition("pointing_shape",e);break}case"handle":{if(this.editor.getIsReadonly())break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",e):this.parent.transition("pointing_handle",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":{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_rotate_handle",e);break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{if(n)this.parent.transition("crop.pointing_crop_handle",e);else{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_resize_handle",e)}break}default:{const r=this.editor.getHoveredShape();if(r&&!this.editor.getSelectedShapeIds().includes(r.id)&&!r.isLocked){this.onPointerDown({...e,shape:r,target:"shape"});return}this.parent.transition("pointing_selection",e)}}break}}}onDoubleClick(e){var n,r,s,o;if(!(this.editor.inputs.shiftKey||e.phase!=="up")&&!(e.ctrlKey||e.shiftKey))switch(e.target){case"canvas":{const i=this.editor.getHoveredShape(),a=i&&!this.editor.isShapeOfType(i,"group")?i:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1}),l=this.editor.getFocusedGroupId();if(a){if(this.editor.isShapeOfType(a,"group")){eg(this.editor,e);return}else{const c=this.editor.getShape(a.parentId);if(c&&this.editor.isShapeOfType(c,"group")&&!(l&&c.id===l)){eg(this.editor,e);return}}this.onDoubleClick({...e,shape:a,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(e);break}case"selection":{if(this.editor.getIsReadonly())break;const i=this.editor.getOnlySelectedShape();if(i){const a=this.editor.getShapeUtil(i);if(!this.canInteractWithShapeInReadOnly(i))return;if(e.handle==="right"||e.handle==="left"||e.handle==="top"||e.handle==="bottom"){const l=(n=a.onDoubleClickEdge)==null?void 0:n.call(a,i);if(l){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([l]),Xe(this.editor,[i.id]);return}}if(a.canCrop(i)&&!this.editor.isShapeOrAncestorLocked(i)){this.parent.transition("crop",e);return}this.shouldStartEditingShape(i)&&this.startEditingShape(i,e,!0)}break}case"shape":{const{shape:i}=e,a=this.editor.getShapeUtil(i);if(i.type!=="video"&&i.type!=="embed"&&this.editor.getIsReadonly())break;if(a.onDoubleClick){const l=(r=a.onDoubleClick)==null?void 0:r.call(a,i);if(l){this.editor.updateShapes([l]);return}}if(a.canCrop(i)&&!this.editor.isShapeOrAncestorLocked(i)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select((s=e.shape)==null?void 0:s.id),this.parent.transition("crop",e);return}this.shouldStartEditingShape(i)?this.startEditingShape(i,e,!0):this.handleDoubleClickOnCanvas(e);break}case"handle":{if(this.editor.getIsReadonly())break;const{shape:i,handle:a}=e,l=this.editor.getShapeUtil(i),c=(o=l.onDoubleClickHandle)==null?void 0:o.call(l,i,a);c?this.editor.updateShapes([c]):this.shouldStartEditingShape(i)&&this.startEditingShape(i,e,!0)}}}onRightClick(e){switch(e.target){case"canvas":{const n=this.editor.getHoveredShape(),r=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:!0,renderingOnly:!0});if(r){this.onRightClick({...e,shape:r,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),o=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:i}}=this.editor;if((s.length>1||o&&!this.editor.getShapeUtil(o).hideSelectionBoundsBg(o))&&n2(this.editor,i)){this.onRightClick({...e,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:n}=this.editor.getCurrentPageState(),{shape:r}=e,s=this.editor.getOutermostSelectableShape(r,o=>!n.includes(o.id));!n.includes(s.id)&&!this.editor.findShapeAncestor(s,o=>n.includes(o.id))&&(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([s.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(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if(wt.editOnType.get()&&!jue.includes(e.key)&&!e.altKey&&!e.ctrlKey){const n=this.editor.getOnlySelectedShape();if(n&&this.editor.isShapeOfType(n,"note")&&this.shouldStartEditingShape(n)){this.startEditingShape(n,{...e,target:"shape",shape:n},!0);return}}}onKeyRepeat(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}}onKeyUp(e){switch(e.code){case"Enter":{const n=this.editor.getSelectedShapes();if(n.every(s=>this.editor.isShapeOfType(s,"group"))){this.editor.setSelectedShapes(n.flatMap(s=>this.editor.getSortedChildIdsForParent(s.id)));return}const r=this.editor.getOnlySelectedShape();if(r&&this.shouldStartEditingShape(r)){this.startEditingShape(r,{...e,target:"shape",shape:r},!0);return}t2(this.editor)&&this.parent.transition("crop",e);break}}}shouldStartEditingShape(e=this.editor.getOnlySelectedShape()){return!e||this.editor.isShapeOrAncestorLocked(e)&&e.type!=="embed"||!this.canInteractWithShapeInReadOnly(e)?!1:this.editor.getShapeUtil(e).canEdit(e)}startEditingShape(e,n,r){this.editor.isShapeOrAncestorLocked(e)&&e.type!=="embed"||(this.editor.markHistoryStoppingPoint("editing shape"),Wp(this.editor,e,r),this.parent.transition("editing_shape",n))}isOverArrowLabelTest(e){if(!e)return!1;const n=this.editor.getPointInShapeSpace(e,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(e,"arrow")){const r=this.editor.getShapeGeometry(e).children[1];if(r&&hr(n,r.vertices))return!0}return!1}handleDoubleClickOnCanvas(e){if(this.editor.getIsReadonly()||!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");const n=Ke(),{x:r,y:s}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:n,type:"text",x:r,y:s,props:{text:"",autoSize:!0}}]);const o=this.editor.getShape(n);if(!o)return;const i=this.editor.getShapeUtil(o);this.editor.getIsReadonly()&&!i.canEditInReadOnly(o)||(this.editor.setEditingShape(n),this.editor.select(n),this.parent.transition("editing_shape",e))}nudgeSelectedShapes(e=!1){const{editor:{inputs:{keys:n}}}=this,r=n.has("ShiftLeft"),s=new x(0,0);if(n.has("ArrowLeft")&&(s.x-=1),n.has("ArrowRight")&&(s.x+=1),n.has("ArrowUp")&&(s.y-=1),n.has("ArrowDown")&&(s.y+=1),s.equals(new x(0,0)))return;e||this.editor.markHistoryStoppingPoint("nudge shapes");const{gridSize:o}=this.editor.getDocumentSettings(),i=this.editor.getInstanceState().isGridMode?r?o*Lue:o:r?Due:Rue,a=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(a,s.mul(i)),Xe(this.editor,a)}canInteractWithShapeInReadOnly(e){return!!(!this.editor.getIsReadonly()||this.editor.getShapeUtil(e).canEditInReadOnly(e))}},I(ZS,"id","idle"),ZS);const Due=10,Rue=1,Lue=5;function n2(t,e){const n=t.getSelectionRotatedPageBounds();if(!n)return!1;const r=t.getSelectionRotation();return r?hr(e,n.corners.map(s=>x.RotWith(s,n.point,r))):n.containsPoint(e)}class z5 extends ie{constructor(){super(...arguments);I(this,"shapeId","");I(this,"markId","");I(this,"wasAlreadySelected",!1);I(this,"didDrag",!1);I(this,"didCtrlOnEnter",!1);I(this,"info",{});I(this,"_labelDragOffset",new x(0,0))}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(n){const{shape:r}=n;this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.shapeId=r.id,this.didDrag=!1,this.didCtrlOnEnter=n.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===r.id,this.updateCursor();const o=this.editor.getShapeGeometry(r).children[1];if(!o)throw Error(`Expected to find an arrow label geometry for shape: ${r.id}`);const{currentPagePoint:i}=this.editor.inputs,a=this.editor.getPointInShapeSpace(r,i);this._labelDragOffset=x.Sub(o.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:n}=this.editor.inputs;if(!n)return;if(this.didCtrlOnEnter){this.parent.transition("brushing",this.info);return}const r=this.editor.getShape(this.shapeId);if(!r)return;const s=Es(this.editor,r),o=this.editor.getShapeGeometry(r),i=o.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),l=i.nearestPoint(x.Add(a,this._labelDragOffset));let c;if(s.isStraight){const u=x.Dist(s.start.point,s.end.point);c=1-x.Dist(s.end.point,l)/u}else{const{_center:u,measure:h,angleEnd:f,angleStart:p}=o.children[0];c=xx(h,p,f,u.angle(l))}isNaN(c)&&(c=.5),this.didDrag=!0,this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:c}})}onPointerUp(){const n=this.editor.getShape(this.shapeId);n&&(this.didDrag||!this.wasAlreadySelected?this.complete():this.editor.getIsReadonly()||(this.editor.setEditingShape(n.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")}}I(z5,"id","pointing_arrow_label");class B5 extends ie{onEnter(e){e.shiftKey||e.accelKey||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(e){eg(this.editor,e),this.complete()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}I(B5,"id","pointing_canvas");class U5 extends ie{constructor(){super(...arguments);I(this,"didCtrlOnEnter",!1);I(this,"info",{})}onEnter(n){this.info=n,this.didCtrlOnEnter=n.accelKey;const{shape:r}=n;if(this.editor.isShapeOfType(r,"arrow")){const s=Un(this.editor,r)[n.handle.id];s&&this.editor.setHintingShapes([s.toId])}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){const{shape:n,handle:r}=this.info;if(this.editor.isShapeOfType(n,"note")){const{editor:s}=this,o=r2(s,n,r,!1);if(o){Wp(s,o,!0);return}}this.parent.transition("idle",this.info)}onPointerMove(n){const{editor:r}=this;r.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",n):this.startDraggingHandle())}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){const{editor:n}=this;if(n.getIsReadonly())return;const{shape:r,handle:s}=this.info;if(n.isShapeOfType(r,"note")){const o=r2(n,r,s,!0);if(o){const i=n.getPointInParentSpace(o,n.inputs.originPagePoint).sub(x.Rot(wm.clone().mul(r.props.scale),o.rotation));n.updateShape({...o,x:i.x,y:i.y}),n.setHoveredShape(o.id).select(o.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:n.getShape(o),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{Wp(n,o,!0)}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}I(U5,"id","pointing_handle");function r2(t,e,n,r){const s=t.getShapePageTransform(e.id),o=s.point(),i=s.rotation(),l=t5(t,o,i,e.props.growY,0,e.props.scale)[n.index];if(l)return r5(t,e,l,i,r)}class H5 extends ie{constructor(){super(...arguments);I(this,"info",{})}updateCursor(){this.editor.setCursor({type:zl[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(n){this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,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.getIsReadonly()||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")}}I(H5,"id","pointing_rotate_handle");class K5 extends ie{constructor(){super(...arguments);I(this,"info",{})}onEnter(n){this.info=n}onPointerUp(n){eg(this.editor,n),this.parent.transition("idle",n)}onPointerMove(n){this.editor.inputs.isDragging&&this.startTranslating(n)}onLongPress(n){this.startTranslating(n)}startTranslating(n){this.editor.getIsReadonly()||this.parent.transition("translating",n)}onDoubleClick(n){var o,i;const r=this.editor.getHoveredShape(),s=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{hitInside:!0,margin:0,renderingOnly:!0});if(s){this.parent.transition("idle"),(i=(o=this.parent).onDoubleClick)==null||i.call(o,{...n,target:"shape",shape:this.editor.getShape(s)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}I(K5,"id","pointing_selection");class W5 extends ie{constructor(){super(...arguments);I(this,"hitShape",{});I(this,"hitShapeForPointerUp",{});I(this,"isDoubleClick",!1);I(this,"didCtrlOnEnter",!1);I(this,"didSelectOnEnter",!1)}onEnter(n){const r=this.editor.getSelectedShapeIds(),s=this.editor.getSelectionRotatedPageBounds(),o=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:i}}=this.editor,{shiftKey:a,altKey:l,accelKey:c}=n;this.hitShape=n.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=c;const u=this.editor.getOutermostSelectableShape(n.shape),h=this.editor.findShapeAncestor(u,f=>r.includes(f.id));if(this.didCtrlOnEnter||this.editor.getShapeUtil(n.shape).onClick||u.id===o||r.includes(u.id)||h||r.length>1&&(s!=null&&s.containsPoint(i))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=u;return}this.didSelectOnEnter=!0,a&&!l?(this.editor.cancelDoubleClick(),r.includes(u.id)||(this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...r,u.id]))):(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([u.id]))}onPointerUp(n){var u;const r=this.editor.getSelectedShapeIds(),s=this.editor.getFocusedGroupId(),o=this.editor.getZoomLevel(),{inputs:{currentPagePoint:i}}=this.editor,a=n.shiftKey||n.accelKey,l=this.editor.getShapeAtPoint(i,{margin:this.editor.options.hitTestMargin/o,hitInside:!0,renderingOnly:!0})??this.hitShape,c=l?this.editor.getOutermostSelectableShape(l):this.hitShapeForPointerUp;if(c){const h=this.editor.getShapeUtil(c);if(h.onClick){const f=(u=h.onClick)==null?void 0:u.call(h,c);if(f){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([f]),this.parent.transition("idle",n);return}}if(c.id===s){r.length>0?(this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",n);return}}if(!this.didSelectOnEnter){const h=this.editor.getOutermostSelectableShape(l,f=>!r.includes(f.id));if(r.includes(h.id))if(a)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(c);else if(r.includes(c.id)){if(r.length===1){const f=this.editor.getShapeUtil(c).getGeometry(c),p=F5(f),g=p.length===1?p[0]:void 0;if(g){const m=this.editor.getPointInShapeSpace(c,i);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 v=this.editor.getShapeUtil(c);this.editor.getIsReadonly()&&!v.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(h);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(p=>!f.find(g=>g.id===p)),h.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([h.id])}this.parent.transition("idle",n)}onDoubleClick(){this.isDoubleClick=!0}onPointerMove(n){this.editor.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",n):this.startTranslating(n))}onLongPress(n){this.startTranslating(n)}startTranslating(n){this.editor.getIsReadonly()||(this.editor.focus(),this.parent.transition("translating",n))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}I(W5,"id","pointing_shape");class G5 extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"markId","");I(this,"didHoldCommand",!1);I(this,"creationCursorOffset",{x:0,y:0});I(this,"snapshot",{})}onEnter(n){const{isCreating:r=!1,creatingMarkId:s,creationCursorOffset:o={x:0,y:0}}=n;if(this.info=n,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.creationCursorOffset=o,this.snapshot=this._createSnapshot(),this.markId="",r)if(s)this.markId=s;else{const i=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);i&&(this.markId=i)}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");r&&this.editor.setCursor({type:"cross",rotation:0}),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:n}){const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(n)}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 n,r;if(Xe(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(r=(n=this.info).onCreate)==null||r.call(n,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:n}=this.snapshot,r=[];n.forEach(({shape:s})=>{var a;const o=this.editor.getShapeUtil(s),i=(a=o.onResizeStart)==null?void 0:a.call(o,s);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r)}handleResizeEnd(){const{shapeSnapshots:n}=this.snapshot,r=[];n.forEach(({shape:s})=>{var l;const o=this.editor.getShape(s.id),i=this.editor.getShapeUtil(s),a=(l=i.onResizeEnd)==null?void 0:l.call(i,s,o);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{altKey:n,shiftKey:r}=this.editor.inputs,{frames:s,shapeSnapshots:o,selectionBounds:i,cursorHandleOffset:a,selectedShapeIds:l,selectionRotation:c,canShapesDeform:u}=this.snapshot;let h=r||!u;if(o.size===1){const k=[...o.values()][0];this.editor.isShapeOfType(k.shape,"text")&&(h=!(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:k}=this.editor.getDocumentSettings();p.snapToGrid(k)}const m=this.info.handle,v=s2(m,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!f:f)&&c%Ze===0){const{nudge:k}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:x.Sub(p,g),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:s2(m,c),isAspectRatioLocked:h,isResizingFromCenter:n});p.add(k)}const S=x.RotWith(n?i.center:i.getHandlePoint(v),i.point,c),b=x.Sub(p,S).rot(-c),P=x.Sub(g,S).rot(-c),C=x.DivV(b,P);Number.isFinite(C.x)||(C.x=1),Number.isFinite(C.y)||(C.y=1);const _=m==="top"||m==="bottom",E=m==="left"||m==="right";h?E?C.y=Math.abs(C.x):_?C.x=Math.abs(C.y):Math.abs(C.x)>Math.abs(C.y)?C.y=Math.abs(C.x)*(C.y<0?-1:1):C.x=Math.abs(C.y)*(C.x<0?-1:1):(_&&(C.x=1),E&&(C.y=1)),this.info.isCreating||this.updateCursor({dragHandle:m,isFlippedX:C.x<0,isFlippedY:C.y<0,rotation:c});for(const k of o.keys()){const D=o.get(k);this.editor.resizeShape(k,C,{initialShape:D.shape,initialBounds:D.bounds,initialPageTransform:D.pageTransform,dragHandle:m,mode:l.length===1&&k===l[0]?"resize_bounds":"scale_shape",scaleOrigin:S,isAspectRatioLocked:h,scaleAxisRotation:c,skipStartAndEndCallbacks:!0})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:k,children:D}of s){if(!D.length)continue;const T=o.get(k).shape,j=this.editor.getShape(k);if(!(T&&j))continue;const L=j.x-T.x,M=j.y-T.y,O=new x(L,M).rot(-T.rotation);if(O.x!==0||O.y!==0)for(const F of D)this.editor.updateShape({id:F.id,type:F.type,x:F.x-O.x,y:F.y-O.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:k}of s)if(k.length)for(const D of k)this.editor.updateShape({id:D.id,type:D.type,x:D.x,y:D.y})}}updateCursor({dragHandle:n,isFlippedX:r,isFlippedY:s,rotation:o}){const i={...this.editor.getInstanceState().cursor};switch(n){case"top_left":case"bottom_right":{i.type="nwse-resize",r!==s&&(i.type="nesw-resize");break}case"top_right":case"bottom_left":{i.type="nesw-resize",r!==s&&(i.type="nwse-resize");break}}i.rotation=o,this.editor.setCursor(i)}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()}_createSnapshot(){const n=this.editor.getSelectedShapeIds(),r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:s}}=this.editor,o=this.editor.getSelectionRotatedPageBounds(),i=x.RotWith(o.getHandlePoint(this.info.handle),o.point,r),a=x.Sub(s,i),l=new Map,c=[];n.forEach(h=>{const f=this.editor.getShape(h);if(f){if(f.type==="frame"&&c.push({id:h,children:me(this.editor.getSortedChildIdsForParent(f).map(p=>this.editor.getShape(p)))}),l.set(f.id,this._createShapeSnapshot(f)),this.editor.isShapeOfType(f,"frame")&&n.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(h=>!cj(h.pageRotation,r)||h.isAspectRatioLocked);return{shapeSnapshots:l,selectionBounds:o,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:n,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:c}}_createShapeSnapshot(n){const r=this.editor.getShapePageTransform(n),s=this.editor.getShapeUtil(n);return{shape:n,bounds:this.editor.getShapeGeometry(n).bounds,pageTransform:r,pageRotation:q.Decompose(r).rotation,isAspectRatioLocked:s.isAspectRatioLocked(n)}}}I(G5,"id","resizing");const IS=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function s2(t,e){e=e%Fe;const n=Math.round(e/(De/4)),r=IS.indexOf(t);return IS[(r+n)%IS.length]}const o2=Math.PI/180;class V5 extends ie{constructor(){super(...arguments);I(this,"snapshot",{});I(this,"info",{});I(this,"markId","")}onEnter(n){this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("rotate start");const r=SO({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!r)return this.parent.transition("idle",this.info);this.snapshot=r;const s=this._getRotationFromPointerPosition({snapToNearestDegree:!1});hf({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:zl[this.info.handle],rotation:s+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 n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});hf({editor:this.editor,delta:n,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:zl[this.info.handle],rotation:n+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(){hf({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),Xe(this.editor,this.snapshot.shapeSnapshots.map(n=>n.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:n}){const r=this.editor.getSelectionRotation(),s=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:o,currentPagePoint:i}}=this.editor,{initialCursorAngle:a,initialShapesRotation:l}=this.snapshot;if(!s)return l;const u=s.center.clone().rotWith(s.point,r).angle(i)-a;let h=l+u;if(o)h=Rp(h,24);else if(n&&(h=Math.round(h/o2)*o2,this.editor.getInstanceState().isCoarsePointer)){const f=Rp(h,4),p=cf(h,f);Math.abs(p)<yX(5)&&(h=f)}return h-l}}I(V5,"id","rotating");class Y5 extends ie{constructor(){super(...arguments);I(this,"hits",new Set);I(this,"size",0);I(this,"scribbleId","id");I(this,"initialSelectedShapeIds",new Set);I(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 n=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=n.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:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)}updateScribbleSelection(n){const{editor:r}=this,s=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{shiftKey:o,originPagePoint:i,previousPagePoint:a,currentPagePoint:l}}=this.editor,{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;n&&this.pushPointToScribble();const h=s;let f,p,g,m;const v=0;for(let b=0,P=h.length;b<P;b++){if(f=h[b],r.isShapeOfType(f,"group")||c.has(f.id)||r.isShapeOrAncestorLocked(f)||(p=r.getShapeGeometry(f),r.isShapeOfType(f,"frame")&&p.bounds.containsPoint(r.getPointInShapeSpace(f,i))))continue;const C=r.getShapePageTransform(f);if(!p||!C)continue;const _=C.clone().invert();g=_.applyToPoint(a),m=_.applyToPoint(l);const{bounds:E}=p;if(!(E.minX-v>Math.max(g.x,m.x)||E.minY-v>Math.max(g.y,m.y)||E.maxX+v<Math.min(g.x,m.x)||E.maxY+v<Math.min(g.y,m.y))&&p.hitTestLineSegment(g,m,v)){const k=this.editor.getOutermostSelectableShape(f),D=this.editor.getShapeMask(k.id);if(D&&Pb(a,l,D)!==null&&!hr(l,D))continue;c.add(k.id)}}const y=r.getSelectedShapeIds(),S=new Set(o?[...c,...u]:[...c]);(y.length!==S.size||y.some(b=>!S.has(b)))&&this.editor.setSelectedShapes(Array.from(S))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}I(Y5,"id","scribble_brushing");var $ue=Object.create,X5=Object.defineProperty,Fue=Object.getOwnPropertyDescriptor,Nue=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),q5=t=>{throw TypeError(t)},Z5=(t,e,n)=>e in t?X5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,zue=t=>[,,,$ue(null)],Q5=["class","method","getter","setter","accessor","field","value","get","set"],J5=t=>t!==void 0&&typeof t!="function"?q5("Function expected"):t,Bue=(t,e,n,r,s)=>({kind:Q5[t],name:e,metadata:r,addInitializer:o=>n._?q5("Already initialized"):s.push(J5(o||null))}),Uue=(t,e)=>Z5(e,Nue("metadata"),t[3]),Hue=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Kue=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=Q5[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,Fue(s,n)),y=r.length-1;y>=0;y--)l=Bue(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,J5(i)&&(v[g]=i);return v&&X5(s,n,v),s},ES=(t,e,n)=>Z5(t,typeof e!="symbol"?e+"":e,n),eF,Im;const Wue=20,Gue=100;eF=[Kn];class z1{constructor(e){this.editor=e,Hue(Im,5,this),ES(this,"prevDroppingShapeId",null),ES(this,"droppingNodeTimer",null),ES(this,"first",!0),e.disposables.add(this.dispose)}updateDroppingNode(e,n){var r;this.first&&(this.editor.setHintingShapes(e.map(s=>this.editor.findShapeAncestor(s,o=>o.type!=="group")).filter(s=>s)),this.prevDroppingShapeId=((r=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,e))==null?void 0:r.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(e,Wue,n):this.editor.inputs.pointerVelocity.len()>.5&&(clearTimeout(this.droppingNodeTimer),this.setDragTimer(e,Gue,n))}setDragTimer(e,n,r){this.droppingNodeTimer=this.editor.timers.setTimeout(()=>{this.editor.run(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,e,r)}),this.droppingNodeTimer=null},n)}handleDrag(e,n,r){var l,c,u,h,f;n=me(n.map(p=>this.editor.getShape(p.id)));const s=((l=this.editor.getDroppingOverShape(e,n))==null?void 0:l.id)??null;if(s===this.prevDroppingShapeId){this.hintParents(n);return}const{prevDroppingShapeId:o}=this,i=o&&this.editor.getShape(o),a=s&&this.editor.getShape(s);i&&((u=(c=this.editor.getShapeUtil(i)).onDragShapesOut)==null||u.call(c,i,n)),a&&((f=(h=this.editor.getShapeUtil(a)).onDragShapesOver)==null||f.call(h,a,n)),this.hintParents(n),r==null||r(),this.prevDroppingShapeId=s}hintParents(e){const n=new Map;for(const s of e){const o=this.editor.findShapeAncestor(s,i=>i.type!=="group");o&&(n.has(o.id)||n.set(o.id,[]),n.get(o.id).push(s.id))}const r=[];for(const[s,o]of n){const i=this.editor.getShape(s);i&&QL(this.editor,i).length<o.length&&r.push(i.id)}this.editor.setHintingShapes(r)}dropShapes(e){var r,s;const{prevDroppingShapeId:n}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,e),n){const o=this.editor.getShape(n);if(!o)return;(s=(r=this.editor.getShapeUtil(o)).onDropShapesOver)==null||s.call(r,o,e)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearTimeout(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}dispose(){this.clear()}}Im=zue();Kue(Im,1,"dispose",eF,z1);Uue(Im,z1);var Vue=Object.create,tF=Object.defineProperty,Yue=Object.getOwnPropertyDescriptor,nF=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),rF=t=>{throw TypeError(t)},sF=(t,e,n)=>e in t?tF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Xue=t=>[,,,Vue((t==null?void 0:t[nF("metadata")])??null)],oF=["class","method","getter","setter","accessor","field","value","get","set"],iF=t=>t!==void 0&&typeof t!="function"?rF("Function expected"):t,que=(t,e,n,r,s)=>({kind:oF[t],name:e,metadata:r,addInitializer:o=>n._?rF("Already initialized"):s.push(iF(o||null))}),Zue=(t,e)=>sF(e,nF("metadata"),t[3]),Que=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Jue=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=oF[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,Yue(s,n)),y=r.length-1;y>=0;y--)l=que(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,iF(i)&&(v[g]=i);return v&&tF(s,n,v),s},Ho=(t,e,n)=>sF(t,typeof e!="symbol"?e+"":e,n),aF,hw,Em;class km extends(hw=ie,aF=[Kn],hw){constructor(){super(...arguments),Que(Em,5,this),Ho(this,"info",{}),Ho(this,"selectionSnapshot",{}),Ho(this,"snapshot",{}),Ho(this,"markId",""),Ho(this,"isCloning",!1),Ho(this,"isCreating",!1),Ho(this,"dragAndDropManager",new z1(this.editor))}onCreate(e){}onEnter(e){var o;const{isCreating:n=!1,creatingMarkId:r,onCreate:s=()=>{}}=e;if(!((o=this.editor.getSelectedShapeIds())!=null&&o.length)){this.parent.transition("idle");return}if(this.info=e,this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.isCreating=n,this.markId="",n)if(r)this.markId=r;else{const i=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);i&&(this.markId=i)}else this.markId=this.editor.markHistoryStoppingPoint("translating");if(this.onCreate=s,this.isCloning=!1,this.info=e,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=i2(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:n}=this;this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),n.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=i2(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),Xe(this.editor,this.snapshot.movingShapes.map(n=>n.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,n=[];e.forEach(r=>{var i;const s=this.editor.getShapeUtil(r),o=(i=s.onTranslateStart)==null?void 0:i.call(s,r);o&&n.push(o)}),n.length>0&&this.editor.updateShapes(n),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){const r=x.Average(e.map(o=>this.editor.getShapePageTransform(o.id).point())),s=x.Sub(r,this.selectionSnapshot.averagePagePoint);x.IsNaN(s)||this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map(o=>o.id),offset:{x:s.x,y:s.y}}})}const n=[];e.forEach(r=>{var a;const s=this.editor.getShape(r.id),o=this.editor.getShapeUtil(r),i=(a=o.onTranslateEnd)==null?void 0:a.call(o,r,s);i&&n.push(i)}),n.length>0&&this.editor.updateShapes(n)}updateShapes(){const{snapshot:e}=this;this.dragAndDropManager.updateDroppingNode(e.movingShapes,this.updateParentTransforms),ede({editor:this.editor,snapshot:e});const{movingShapes:n}=e,r=[];n.forEach(s=>{var l;const o=this.editor.getShape(s.id),i=this.editor.getShapeUtil(s),a=(l=i.onTranslate)==null?void 0:l.call(i,s,o);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateParentTransforms(){const{editor:e,snapshot:{shapeSnapshots:n}}=this;n.forEach(r=>{const s=e.getShape(r.shape.id);if(!s)return null;const o=Rn(s.parentId)?null:q.Inverse(e.getShapePageTransform(s.parentId));r.parentTransform=o})}}Em=Xue(hw);Jue(Em,1,"updateParentTransforms",aF,km);Zue(Em,km);Ho(km,"id","translating");function i2(t){var h;const e=[],n=[],r=t.getSelectedShapeIds(),s=me(r.map(f=>{const p=t.getShape(f);if(!p)return null;e.push(p);const g=t.getShapePageTransform(f),m=g.point(),v=g.rotation();n.push(m);const y=yr.isId(p.parentId)?null:q.Inverse(t.getShapePageTransform(p.parentId));return{shape:p,pagePoint:m,pageRotation:v,parentTransform:y}})),o=t.getOnlySelectedShape();let i=[];if(o)i=t.snaps.shapeBounds.getSnapPoints(o.id);else{const f=t.getSelectionPageBounds();f&&(i=f.cornersAndCenter.map((p,g)=>({id:"selection:"+g,x:p.x,y:p.y})))}let a,l;const{originPagePoint:c}=t.inputs,u=s.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=(h=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:h.snapshot}return l&&(a=n5(t,l.pageRotation,l.shape.props.scale,l.shape.props.growY??0)),{averagePagePoint:x.Average(n),movingShapes:e,shapeSnapshots:s,initialPageBounds:t.getSelectionPageBounds(),initialSnapPoints:i,noteAdjacentPositions:a,noteSnapshot:l}}function ede({editor:t,snapshot:e}){const{inputs:n}=t,{noteSnapshot:r,noteAdjacentPositions:s,initialPageBounds:o,initialSnapPoints:i,shapeSnapshots:a,averagePagePoint:l}=e,c=t.getInstanceState().isGridMode,u=t.getDocumentSettings().gridSize,h=x.Sub(n.currentPagePoint,n.originPagePoint),f=t.inputs.shiftKey?Math.abs(h.x)<Math.abs(h.y)?"x":"y":null;f==="x"?h.x=0:f==="y"&&(h.y=0),t.snaps.clearIndicators();const p=t.user.getIsSnapMode()?!n.ctrlKey:n.ctrlKey;let g=!1;if(p&&t.inputs.pointerVelocity.len()<.5){const{nudge:S}=t.snaps.shapeBounds.snapTranslateShapes({dragDelta:h,initialSelectionPageBounds:o,lockedAxis:f,initialSelectionSnapPoints:i});h.add(S)}else if(r&&s){const{scale:S}=r.shape.props,b=r.pagePoint.clone().add(h).add(wm.clone().mul(S).rot(r.pageRotation));let P=e5/t.getZoomLevel(),C=new x(0,0);for(const _ of s){const E=x.Sub(b,_),k=E.len();k<P&&(g=!0,P=k,C=E)}h.sub(C)}const m=x.Add(l,h),v=t.snaps.getIndicators();c&&!n.ctrlKey&&!g&&v.length===0&&m.snapToGrid(u);const y=x.Sub(m,l);t.updateShapes(me(a.map(({shape:S,pagePoint:b,parentTransform:P})=>{const C=x.Add(b,y),_=P?q.applyToPoint(P,C):C;return{id:S.id,type:S.type,x:_.x,y:_.y}})))}class Lf extends ie{constructor(){super(...arguments);I(this,"reactor")}static children(){return[dw,F1,Oue,B5,W5,km,A5,Y5,N1,K5,j5,N5,G5,V5,H5,z5,U5,$5]}cleanUpDuplicateProps(){const n=this.editor.getSelectedShapeIds(),r=this.editor.getInstanceState();if(!r.duplicateProps)return;const s=new Set(r.duplicateProps.shapeIds);n.length===s.size&&n.every(o=>s.has(o))||this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=As("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(n){console.error(n)}})}onExit(){var n;(n=this.reactor)==null||n.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)}}I(Lf,"id","select"),I(Lf,"initial","idle"),I(Lf,"isLockable",!1);class lF extends ie{constructor(){super(...arguments);I(this,"info",{})}onEnter(n){this.info=n}onPointerDown(){this.parent.transition("pointing",this.info)}}I(lF,"id","idle");class cF extends ie{constructor(){super(...arguments);I(this,"info",{})}onEnter(n){this.info=n}onPointerUp(){this.complete()}onPointerMove(){this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){const{currentScreenPoint:n}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(n,{animation:{duration:220}}):this.editor.zoomIn(n,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}I(cF,"id","pointing");class uF extends ie{constructor(){super(...arguments);I(this,"info",{});I(this,"zoomBrush",new Z)}onEnter(n){this.info=n,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){const{inputs:{originPagePoint:n,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(Z.FromPoints([n,r])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:n}=this,r=8/this.editor.getZoomLevel();if(n.width<r&&n.height<r){const s=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(s,{animation:{duration:220}}):this.editor.zoomIn(s,{animation:{duration:220}})}else{const s=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(n,{targetZoom:s,animation:{duration:220}})}this.parent.transition("idle",this.info)}}I(uF,"id","zoom_brushing");class $f extends ie{constructor(){super(...arguments);I(this,"info",{})}static children(){return[lF,uF,cF]}onEnter(n){this.info=n,this.parent.setCurrentToolIdMask(n.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(n){this.updateCursor(),n.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})}}I($f,"id","zoom"),I($f,"initial","idle"),I($f,"isLockable",!1);const tde=[Of,Df,Rf,$f,Lf];function nde(){const t=z(),e=U("follow",()=>t.getInstanceState().followingUserId,[t]);return e?d.jsx(rde,{userId:e}):null}function rde({userId:t}){const e=Lg(t);return e?d.jsx("div",{className:"tlui-following-indicator",style:{borderColor:e.color}}):null}let fw={fonts:{draw:`${ti()}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`${ti()}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`${ti()}/fonts/IBMPlexSans-Medium.woff2`,monospace:`${ti()}/fonts/IBMPlexMono-Medium.woff2`}};function dF(t){return w.useMemo(()=>t?{fonts:{...fw.fonts,...t==null?void 0:t.fonts}}:fw,[t])}const sde=["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 Dc={...fw,icons:Object.fromEntries(sde.map(t=>[t,`${ti()}/icons/icon/0_merged.svg#${t}`])),translations:Object.fromEntries(Bu.map(t=>[t.locale,`${ti()}/translations/${t.locale}.json`])),embedIcons:Object.fromEntries(S1.map(t=>[t.type,`${ti()}/embed-icons/${t.type}.png`]))};function ode(t){return t?{fonts:Object.assign({...Dc.fonts},{...t==null?void 0:t.fonts}),icons:Object.assign({...Dc.icons},{...t==null?void 0:t.icons}),embedIcons:Object.assign({...Dc.embedIcons},{...t==null?void 0:t.embedIcons}),translations:Object.assign({...Dc.translations},{...t==null?void 0:t.translations})}:Dc}var B1="Popover",[hF,Dge]=Ws(B1,[sm]),kd=sm(),[ide,Di]=hF(B1),fF=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!1}=t,a=kd(e),l=w.useRef(null),[c,u]=w.useState(!1),[h=!1,f]=ji({prop:r,defaultProp:s,onChange:o});return d.jsx(Xb,{...a,children:d.jsx(ide,{scope:e,contentId:mo(),triggerRef:l,open:h,onOpenChange:f,onOpenToggle:w.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:i,children:n})})};fF.displayName=B1;var pF="PopoverAnchor",ade=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=Di(pF,n),o=kd(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=s;return w.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(qb,{...o,...r,ref:e})});ade.displayName=pF;var gF="PopoverTrigger",mF=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=Di(gF,n),o=kd(n),i=Qe(e,s.triggerRef),a=d.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":wF(s.open),...r,ref:i,onClick:se(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:d.jsx(qb,{asChild:!0,...o,children:a})});mF.displayName=gF;var U1="PopoverPortal",[lde,cde]=hF(U1,{forceMount:void 0}),yF=t=>{const{__scopePopover:e,forceMount:n,children:r,container:s}=t,o=Di(U1,e);return d.jsx(lde,{scope:e,forceMount:n,children:d.jsx(ds,{present:n||o.open,children:d.jsx(Pd,{asChild:!0,container:s,children:r})})})};yF.displayName=U1;var Bl="PopoverContent",SF=w.forwardRef((t,e)=>{const n=cde(Bl,t.__scopePopover),{forceMount:r=n.forceMount,...s}=t,o=Di(Bl,t.__scopePopover);return d.jsx(ds,{present:r||o.open,children:o.modal?d.jsx(ude,{...s,ref:e}):d.jsx(dde,{...s,ref:e})})});SF.displayName=Bl;var ude=w.forwardRef((t,e)=>{const n=Di(Bl,t.__scopePopover),r=w.useRef(null),s=Qe(e,r),o=w.useRef(!1);return w.useEffect(()=>{const i=r.current;if(i)return Zb(i)},[]),d.jsx(am,{as:fa,allowPinchZoom:!0,children:d.jsx(vF,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(t.onCloseAutoFocus,i=>{var a;i.preventDefault(),o.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:se(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:se(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),dde=w.forwardRef((t,e)=>{const n=Di(Bl,t.__scopePopover),r=w.useRef(!1),s=w.useRef(!1);return d.jsx(vF,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,a;(i=t.onCloseAutoFocus)==null||i.call(t,o),o.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),o.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:o=>{var l,c;(l=t.onInteractOutside)==null||l.call(t,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),vF=w.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...h}=t,f=Di(Bl,n),p=kd(n);return Nb(),d.jsx(em,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:o,children:d.jsx(wd,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:d.jsx(I3,{"data-state":wF(f.open),role:"dialog",id:f.contentId,...p,...h,ref:e,style:{...h.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)"}})})})}),xF="PopoverClose",hde=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=Di(xF,n);return d.jsx(Ae.button,{type:"button",...r,ref:e,onClick:se(t.onClick,()=>s.onOpenChange(!1))})});hde.displayName=xF;var fde="PopoverArrow",pde=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,s=kd(n);return d.jsx(E3,{...s,...r,ref:e})});pde.displayName=fde;function wF(t){return t?"open":"closed"}var H1=fF,K1=mF,W1=yF,G1=SF;function V1({id:t,children:e,onOpenChange:n,open:r}){const[s,o]=Mo(t,n);return d.jsx(H1,{onOpenChange:o,open:r||s,children:d.jsx("div",{className:"tlui-popover",children:e})})}function Y1({children:t}){return d.jsx(K1,{asChild:!0,dir:"ltr",children:t})}function X1({side:t,children:e,align:n="center",sideOffset:r=8,alignOffset:s=0,disableEscapeKeyDown:o=!1}){const i=Tt();return d.jsx(W1,{container:i,children:d.jsx(G1,{className:"tlui-popover__content",side:t,sideOffset:r,align:n,alignOffset:s,dir:"ltr",onEscapeKeyDown:a=>o&&a.preventDefault(),children:e})})}function gde(t){return t.getSelectedShapeIds().map(r=>t.getShape(r)).filter(r=>{if(!r)return!1;if(t.isShapeOfType(r,"arrow")){const s=Un(t,r);if(s.start||s.end)return!1}return!0})}const bF=()=>{const t=z();return U("threeStackableItems",()=>gde(t).length>2,[t])},Ao=()=>{const t=z();return U("isInSelectState",()=>t.isIn("select"),[t])},PF=()=>{const t=z();return U("allow group",()=>{const e=t.getSelectedShapes();if(e.length<2)return!1;for(const n of e)if(t.isShapeOfType(n,"arrow")){const r=Un(t,n);if(r.start&&!e.some(s=>s.id===r.start.toId)||r.end&&!e.some(s=>s.id===r.end.toId))return!1}return!0},[t])},CF=()=>{const t=z();return U("allowUngroup",()=>t.getSelectedShapeIds().some(e=>{var n;return((n=t.getShape(e))==null?void 0:n.type)==="group"}),[t])},mde=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function _F(t,e){const n=z();return U("selectedShapes",()=>n.getSelectedShapes().length>=t,[n,t,e])}function jn(t,e){const n=z();return U("selectedShapes",()=>{const r=n.getSelectedShapes().filter(s=>!n.isShapeOrAncestorLocked(s)).length;return t===void 0?r:r>=t},[n])}function yde(){const t=z();return U("showAutoSizeToggle",()=>{const e=t.getSelectedShapes();return e.length===1&&t.isShapeOfType(e[0],"text")&&e[0].props.autoSize===!1},[t])}function IF(){const t=z();return U("hasLinkShapeSelected",()=>{const e=t.getOnlySelectedShape();return!!(e&&e.type!=="embed"&&"url"in e.props&&!e.isLocked)},[t])}function Sde(){const t=z();return U("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 EF(){const t=z();return U("useCanRedo",()=>t.getCanRedo(),[t])}function kF(){const t=z();return U("useCanUndo",()=>t.getCanUndo(),[t])}function vde(){return d.jsxs(d.Fragment,{children:[d.jsx(xde,{}),d.jsx(wde,{}),d.jsx(bde,{}),d.jsx(Pde,{}),d.jsx(Cde,{}),d.jsx(Ede,{}),d.jsx(kde,{}),d.jsx(Tde,{})]})}function xde(){const t=jn(2),e=Ao(),n=t&&e;return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"align-left",disabled:!n}),d.jsx(W,{actionId:"align-center-horizontal",disabled:!n}),d.jsx(W,{actionId:"align-right",disabled:!n}),d.jsx(W,{actionId:"stretch-horizontal",disabled:!n}),d.jsx(W,{actionId:"align-top",disabled:!n}),d.jsx(W,{actionId:"align-center-vertical",disabled:!n}),d.jsx(W,{actionId:"align-bottom",disabled:!n}),d.jsx(W,{actionId:"stretch-vertical",disabled:!n})]})}function wde(){const t=jn(3),e=Ao(),n=t&&e;return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"distribute-horizontal",disabled:!n}),d.jsx(W,{actionId:"distribute-vertical",disabled:!n})]})}function bde(){const t=bF(),e=Ao(),n=t&&e;return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"stack-horizontal",disabled:!n}),d.jsx(W,{actionId:"stack-vertical",disabled:!n})]})}function Pde(){const t=jn(1),e=Ao(),n=t&&e;return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"send-to-back",disabled:!n}),d.jsx(W,{actionId:"send-backward",disabled:!n}),d.jsx(W,{actionId:"bring-forward",disabled:!n}),d.jsx(W,{actionId:"bring-to-front",disabled:!n})]})}function Cde(){return An()<St.TABLET_SM?d.jsx(_de,{}):d.jsx(Ide,{})}function _de(){const t=z(),e=U("zoom is 1",()=>t.getZoomLevel()===1,[t]);return d.jsx(W,{actionId:"zoom-to-100",disabled:e})}function Ide(){const t=jn(1),e=Ao(),n=t&&e;return d.jsx(W,{actionId:"rotate-ccw",disabled:!n})}function Ede(){const t=jn(1),e=Ao(),n=t&&e;return d.jsx(W,{actionId:"rotate-cw",disabled:!n})}function kde(){const t=IF(),e=Ao(),n=t&&e;return d.jsx(W,{actionId:"edit-link",disabled:!n})}function Tde(){const t=PF(),e=CF();return t?d.jsx(a2,{}):e?d.jsx(Mde,{}):d.jsx(a2,{})}function a2(){const t=jn(2),e=Ao(),n=t&&e;return d.jsx(W,{actionId:"group",disabled:!n})}function Mde(){return d.jsx(W,{actionId:"ungroup"})}const Ade=w.memo(function({children:e}){const n=Ee(),r=An(),s=wr(),o=w.useRef(null);Ai(o);const i=z(),a=U("should display quick actions when in readonly",()=>i.isInAny("hand","zoom"),[i]),l=e??d.jsx(vde,{});if(!(s&&!a))return d.jsxs(V1,{id:"actions-menu",children:[d.jsx(Y1,{children:d.jsx(ue,{type:"icon","data-testid":"actions-menu.button",title:n("actions-menu.title"),children:d.jsx(be,{icon:"dots-vertical",small:!0})})}),d.jsx(X1,{side:r>=St.TABLET?"bottom":"top",sideOffset:6,children:d.jsx("div",{ref:o,className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:d.jsx(Fr,{type:"icons",sourceId:"actions-menu",children:l})})})]})});function TF(){return yde()?d.jsx(W,{actionId:"toggle-auto-size"}):null}function MF(){return IF()?d.jsx(W,{actionId:"edit-link"}):null}function jde(){return jn(1)?d.jsx(W,{actionId:"duplicate"}):null}function AF(){const t=z();return U("should display flatten option",()=>{if(t.getSelectedShapeIds().length===0)return!1;const r=t.getOnlySelectedShape();return!(r&&t.isShapeOfType(r,"image"))},[t])?d.jsx(W,{actionId:"flatten-to-image"}):null}function jF(){return PF()?d.jsx(W,{actionId:"group"}):null}function OF(){return CF()?d.jsx(W,{actionId:"ungroup"}):null}function DF(){const t=z();return U("allow unframe",()=>{const n=t.getSelectedShapes();return n.length===0?!1:n.every(r=>t.isShapeOfType(r,"frame"))},[t])?d.jsx(W,{actionId:"remove-frame"}):null}function RF(){const t=z();return U("allow fit frame to content",()=>{const n=t.getOnlySelectedShape();return n?t.isShapeOfType(n,"frame")&&t.getSortedChildIdsForParent(n).length>0:!1},[t])?d.jsx(W,{actionId:"fit-frame-to-content"}):null}function LF(){const t=z();return U("selected shapes",()=>t.getSelectedShapes().length>0,[t])?d.jsx(W,{actionId:"toggle-lock"}):null}function q1(){const t=z(),e=U("isTransparentBg",()=>!t.getInstanceState().exportBackground,[t]);return d.jsx(fs,{actionId:"toggle-transparent",checked:e,toggle:!0})}function Ode(){const t=z(),e=U("any shapes",()=>t.getCurrentPageShapeIds().size>0,[t]);return d.jsx(W,{actionId:"unlock-all",disabled:!e})}function $F(){const t=z(),e=U("zoomed to 100",()=>t.getZoomLevel()===1,[t]);return d.jsx(W,{actionId:"zoom-to-100",noClose:!0,disabled:e})}function FF(){const t=z(),e=U("has shapes",()=>t.getCurrentPageShapeIds().size>0,[t]);return d.jsx(W,{actionId:"zoom-to-fit",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function NF(){const t=z(),e=U("has shapes",()=>t.getSelectedShapeIds().length>0,[t]);return d.jsx(W,{actionId:"zoom-to-selection",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function zF(){return d.jsxs(ve,{id:"clipboard",children:[d.jsx(Rde,{}),d.jsx(Lde,{}),d.jsx($de,{}),d.jsx(jde,{}),d.jsx(Fde,{})]})}function Dde(){var n;const t=z(),e=U("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return d.jsxs(Jn,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!e,children:[d.jsxs(ve,{id:"copy-as-group",children:[d.jsx(W,{actionId:"copy-as-svg"}),!!((n=window.navigator.clipboard)!=null&&n.write)&&d.jsx(W,{actionId:"copy-as-png"}),d.jsx(W,{actionId:"copy-as-json"})]}),d.jsx(ve,{id:"copy-as-bg",children:d.jsx(q1,{})})]})}function Rde(){const t=jn(1);return d.jsx(W,{actionId:"cut",disabled:!t})}function Lde(){const t=_F(1);return d.jsx(W,{actionId:"copy",disabled:!t})}function $de(){const t=mde;return d.jsx(W,{actionId:"paste",disabled:!t})}function BF(){const t=z();return U("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t])?d.jsxs(ve,{id:"conversions",children:[d.jsx(Dde,{}),d.jsxs(Jn,{id:"export-as",label:"context-menu.export-as",size:"small",children:[d.jsxs(ve,{id:"export-as-group",children:[d.jsx(W,{actionId:"export-as-svg"}),d.jsx(W,{actionId:"export-as-png"}),d.jsx(W,{actionId:"export-as-json"})]}),d.jsx(ve,{id:"export-as-bg",children:d.jsx(q1,{})})]})]}):null}function UF(){const t=z(),e=U("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return d.jsx(W,{actionId:"select-all",disabled:!e})}function Fde(){const t=jn(1);return d.jsx(W,{actionId:"delete",disabled:!t})}function Nde(){const t=wr();return!_F(1)||t?null:d.jsxs(Jn,{id:"edit",label:"context-menu.edit",size:"small",children:[d.jsx(jF,{}),d.jsx(OF,{}),d.jsx(AF,{}),d.jsx(MF,{}),d.jsx(RF,{}),d.jsx(DF,{}),d.jsx(KF,{}),d.jsx(HF,{}),d.jsx(TF,{}),d.jsx(LF,{})]})}function zde(){const t=jn(2),e=Sde();return wr()||!(t||e)?null:d.jsxs(Jn,{id:"arrange",label:"context-menu.arrange",size:"small",children:[t&&d.jsxs(ve,{id:"align",children:[d.jsx(W,{actionId:"align-left"}),d.jsx(W,{actionId:"align-center-horizontal"}),d.jsx(W,{actionId:"align-right"}),d.jsx(W,{actionId:"align-top"}),d.jsx(W,{actionId:"align-center-vertical"}),d.jsx(W,{actionId:"align-bottom"})]}),d.jsx(Bde,{}),t&&d.jsxs(ve,{id:"stretch",children:[d.jsx(W,{actionId:"stretch-horizontal"}),d.jsx(W,{actionId:"stretch-vertical"})]}),(t||e)&&d.jsxs(ve,{id:"flip",children:[d.jsx(W,{actionId:"flip-horizontal"}),d.jsx(W,{actionId:"flip-vertical"})]}),d.jsx(Ude,{})]})}function Bde(){return jn(3)?d.jsxs(ve,{id:"distribute",children:[d.jsx(W,{actionId:"distribute-horizontal"}),d.jsx(W,{actionId:"distribute-vertical"})]}):null}function Ude(){const t=jn(2),e=bF();return t?d.jsxs(ve,{id:"order",children:[d.jsx(W,{actionId:"pack"}),e&&d.jsx(W,{actionId:"stack-horizontal"}),e&&d.jsx(W,{actionId:"stack-vertical"})]}):null}function Hde(){const t=wr(),e=jn(1);return t||!e?null:d.jsx(Jn,{id:"reorder",label:"context-menu.reorder",size:"small",children:d.jsxs(ve,{id:"reorder",children:[d.jsx(W,{actionId:"bring-to-front"}),d.jsx(W,{actionId:"bring-forward"}),d.jsx(W,{actionId:"send-backward"}),d.jsx(W,{actionId:"send-to-back"})]})})}function Kde(){const t=z(),e=U("pages",()=>t.getPages(),[t]),n=U("current page id",()=>t.getCurrentPageId(),[t]),{addToast:r}=To(),s=Jt(),o=wr();return!jn(1)||o?null:d.jsxs(Jn,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[d.jsx(ve,{id:"pages",children:e.map(a=>d.jsx(Kt,{id:a.id,disabled:n===a.id,label:a.name.length>30?`${a.name.slice(0,30)}…`:a.name,onSelect:()=>{t.markHistoryStoppingPoint("move_shapes_to_page"),t.moveShapesToPage(t.getSelectedShapeIds(),a.id);const l=t.getPage(a.id);l&&r({title:"Changed Page",description:`Moved to ${l.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{t.markHistoryStoppingPoint("change-page"),t.setCurrentPage(n)}}]}),s("move-to-page",{source:"context-menu"})}},a.id))}),d.jsx(ve,{id:"new-page",children:d.jsx(W,{actionId:"move-to-new-page"})})]})}function HF(){const t=z();return U("oneEmbedSelected",()=>{const n=t.getOnlySelectedShape();return n?!!(t.isShapeOfType(n,"embed")&&n.props.url&&!t.isShapeOrAncestorLocked(n)):!1},[t])?d.jsx(W,{actionId:"convert-to-bookmark"}):null}function KF(){const t=z(),e=v1();return U("oneEmbeddableBookmarkSelected",()=>{const r=t.getOnlySelectedShape();return r?!!(t.isShapeOfType(r,"bookmark")&&r.props.url&&e(r.props.url)&&!t.isShapeOrAncestorLocked(r)):!1},[t])?d.jsx(W,{actionId:"convert-to-embed"}):null}function Wde(){const t=z(),e=U("isSnapMode",()=>t.user.getIsSnapMode(),[t]);return d.jsx(fs,{actionId:"toggle-snap-mode",checked:e})}function Gde(){const t=z(),e=U("isToolLock",()=>t.getInstanceState().isToolLocked,[t]);return d.jsx(fs,{actionId:"toggle-tool-lock",checked:e})}function Vde(){const t=z(),e=U("isGridMode",()=>t.getInstanceState().isGridMode,[t]);return d.jsx(fs,{actionId:"toggle-grid",checked:e})}function Yde(){const t=z(),e=U("isWrapMode",()=>t.user.getIsWrapMode(),[t]);return d.jsx(fs,{actionId:"toggle-wrap-mode",checked:e})}function Xde(){const t=z(),e=U("isFocusMode",()=>t.getInstanceState().isFocusMode,[t]);return d.jsx(fs,{actionId:"toggle-focus-mode",checked:e})}function qde(){const t=z(),e=U("edgeScrollSpeed",()=>t.user.getEdgeScrollSpeed(),[t]);return d.jsx(fs,{actionId:"toggle-edge-scrolling",checked:e===1})}function Zde(){const t=z(),e=U("animationSpeed",()=>t.user.getAnimationSpeed(),[t]);return d.jsx(fs,{actionId:"toggle-reduce-motion",checked:e===0})}function Qde(){const t=z(),e=U("isDebugMode",()=>t.getInstanceState().isDebugMode,[t]);return d.jsx(fs,{actionId:"toggle-debug-mode",checked:e})}function Jde(){const t=z(),e=U("dynamic resize",()=>t.user.getIsDynamicResizeMode(),[t]);return d.jsx(fs,{actionId:"toggle-dynamic-size-mode",checked:e})}function ehe(){const t=z(),e=U("paste at cursor",()=>t.user.getIsPasteAtCursorMode(),[t]);return d.jsx(fs,{actionId:"toggle-paste-at-cursor",checked:e})}function the(){const t=z();return U("show cursor chat",()=>t.getCurrentToolId()==="select"&&!t.getInstanceState().isCoarsePointer,[t])?d.jsx(W,{actionId:"open-cursor-chat"}):null}function nhe(){const t=z(),e=gm(),n=U("isSelectToolActive",()=>t.getCurrentToolId()==="select",[t]),r=U("isSinglePageMode",()=>t.options.maxPages<=1,[t]);return n?d.jsxs(d.Fragment,{children:[e&&d.jsx(the,{}),d.jsxs(ve,{id:"modify",children:[d.jsx(Nde,{}),d.jsx(zde,{}),d.jsx(Hde,{}),!r&&d.jsx(Kde,{})]}),d.jsx(zF,{}),d.jsx(BF,{}),d.jsx(ve,{id:"select-all",children:d.jsx(UF,{})})]}):null}const rhe=w.memo(function({children:e,disabled:n=!1}){const r=z(),{Canvas:s}=st(),o=w.useCallback(u=>{if(u){if(r.getInstanceState().isCoarsePointer){const h=r.getSelectedShapes(),{inputs:{currentPagePoint:f}}=r,p=r.getShapesAtPoint(f);if(!r.getSelectedShapes().length||!p.some(g=>h.includes(g))){const g=p.filter(m=>r.isShapeOrAncestorLocked(m));g.length&&r.select(...g.map(m=>m.id))}}}else{const h=r.getOnlySelectedShape();h&&r.isShapeOrAncestorLocked(h)&&r.setSelectedShapes([])}},[r]),i=Tt(),[a,l]=Mo("context menu",o),c=e??d.jsx(nhe,{});return d.jsxs(Vse,{dir:"ltr",onOpenChange:l,modal:!1,children:[d.jsx(Yse,{onContextMenu:void 0,dir:"ltr",disabled:n,children:s?d.jsx(s,{}):null}),a&&d.jsx(Xse,{container:i,children:d.jsx(qse,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:xe,children:d.jsx(Fr,{type:"context-menu",sourceId:"context-menu",children:c})})})]})}),she=2e3,ohe=5e3,ihe=Zt(function(){const e=z(),{isChatting:n,chatMessage:r}=e.getInstanceState(),s=w.useRef(-1),[o,i]=w.useState("");return w.useEffect(()=>{if(!n&&r||n){const l=n?ohe:she;s.current=e.timers.setTimeout(()=>{e.updateInstanceState({chatMessage:"",isChatting:!1}),i(""),e.focus()},l)}return()=>{clearTimeout(s.current)}},[e,r,n]),n?d.jsx(lhe,{value:o,setValue:i,chatMessage:r}):r.trim()?d.jsx(ahe,{chatMessage:r}):null});function WF(t){const e=z();w.useLayoutEffect(()=>{var i;if(!t.current)return;const{x:r,y:s}=e.inputs.currentScreenPoint;(i=t.current)==null||i.style.setProperty("transform",`translate(${r}px, ${s}px)`);function o(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",o),()=>{window.removeEventListener("pointermove",o)}},[t,e])}const ahe=({chatMessage:t})=>{const e=z(),n=w.useRef(null);return WF(n),d.jsx("div",{ref:n,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:e.user.getColor()},children:t})},lhe=Zt(function({chatMessage:e,value:n,setValue:r}){const s=z(),o=Ee(),i=w.useRef(null),a=e||o("cursor-chat.type-to-chat");WF(i),w.useLayoutEffect(()=>{const f=i.current;if(!f)return;const p=s.textMeasure.measureText(n||a,{fontFamily:"var(--font-body)",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});f.style.setProperty("width",p.w+"px")},[s,n,a]),w.useLayoutEffect(()=>{const f=s.timers.requestAnimationFrame(()=>{var p;(p=i.current)==null||p.focus()});return()=>{cancelAnimationFrame(f)}},[s]);const l=w.useCallback(()=>{s.updateInstanceState({isChatting:!1}),s.focus()},[s]),c=w.useCallback(f=>{const{value:p}=f.target;r(p.slice(0,64)),s.updateInstanceState({chatMessage:p})},[s,r]),u=w.useCallback(f=>{const p=i.current;if(!p)return;const{value:g}=p;switch(f.key){case"Enter":{if(xe(f),f.stopPropagation(),!g){l();return}r("");break}case"Escape":{xe(f),f.stopPropagation(),l();break}}},[l,r]),h=w.useCallback(f=>{f.stopPropagation()},[]);return d.jsx("input",{ref:i,className:"tl-cursor-chat",style:{backgroundColor:s.user.getColor()},onBlur:l,onChange:c,onKeyDown:u,onPaste:h,value:n,placeholder:a,spellCheck:!1})});function pw({checked:t}){return d.jsx(zs,{icon:t?"check":"none",className:"tlui-button__icon",small:!0})}function che(){const t=z(),{addToast:e}=To(),{addDialog:n}=Ed(),[r,s]=ke.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(ve,{id:"items",children:[d.jsx(Kt,{id:"add-toast",onSelect:()=>{e({id:ze(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),e({id:ze(),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:ze(),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:ze(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),d.jsx(Kt,{id:"show-dialog",label:"Show dialog",onSelect:()=>{n({component:({onClose:o})=>d.jsx(hhe,{displayDontShowAgain:!0,onCancel:()=>o(),onContinue:()=>o()}),onClose:()=>{}})}}),d.jsx(Kt,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>fhe(t,100)}),d.jsx(Kt,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const o=t.getSelectedShapes(),i=o.length===0?t.getRenderingShapes():o;window.alert(`Shapes ${i.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(r)throw Error("oh no!");return null})(),d.jsx(Kt,{id:"throw-error",onSelect:()=>s(!0),label:"Throw error"}),d.jsx(Kt,{id:"hard-reset",onSelect:jj,label:"Hard reset"})]}),d.jsxs(ve,{id:"flags",children:[d.jsx(uhe,{}),d.jsx(dhe,{})]})]})}function uhe(){const t=Object.values(wt);return t.length?d.jsx(Jn,{id:"debug flags",label:"Debug Flags",children:d.jsx(ve,{id:"debug flags",children:t.map(e=>d.jsx(GF,{flag:e},e.name))})}):null}function dhe(){const t=Object.values(PX);return t.length?d.jsx(Jn,{id:"feature flags",label:"Feature Flags",children:d.jsx(ve,{id:"feature flags",children:t.map(e=>d.jsx(GF,{flag:e},e.name))})}):null}function hhe({title:t="title",body:e="hello hello hello",cancel:n="Cancel",confirm:r="Continue",displayDontShowAgain:s=!1,onCancel:o,onContinue:i}){const[a,l]=ke.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(dm,{children:[d.jsx(hm,{children:t}),d.jsx(fm,{})]}),d.jsx(Yu,{style:{maxWidth:350},children:e}),d.jsxs(y1,{className:"tlui-dialog__footer__actions",children:[s&&d.jsxs(ue,{type:"normal",onClick:()=>l(!a),style:{marginRight:"auto"},children:[d.jsx(pw,{checked:a}),d.jsx(bt,{children:"Don’t show again"})]}),d.jsx(ue,{type:"normal",onClick:o,children:d.jsx(bt,{children:n})}),d.jsx(ue,{type:"primary",onClick:async()=>i(),children:d.jsx(bt,{children:r})})]})]})}const GF=Zt(function({flag:e,onChange:n}){const r=e.get();return d.jsx(vm,{id:e.name,title:e.name,label:e.name.replace(/([a-z0-9])([A-Z])/g,s=>`${s[0]} ${s[1].toLowerCase()}`).replace(/^[a-z]/,s=>s.toUpperCase()),checked:r,onSelect:()=>{e.set(!r),n==null||n(!r)}})});let l2=0;function fhe(t,e){const n=Array(e),r=Math.floor(Math.sqrt(e));for(let s=0;s<e;s++)l2++,n[s]={id:Ke("box"+l2),type:"geo",x:s%r*132,y:Math.floor(s/r)*132};t.run(()=>{t.createShapes(n).setSelectedShapes(n.map(s=>s.id))})}function phe({children:t}){const e=t??d.jsx(che,{});return d.jsxs(ma,{id:"debug",children:[d.jsx(ya,{children:d.jsx(ue,{type:"icon",title:"Debug menu",children:d.jsx(be,{icon:"dots-horizontal"})})}),d.jsx(Sa,{side:"top",align:"end",alignOffset:0,children:d.jsx(Fr,{type:"menu",sourceId:"debug-panel",children:e})})]})}const ghe=w.memo(function(){const{DebugMenu:e}=Ri(),n=w.useRef(null);return Ai(n),d.jsxs("div",{ref:n,className:"tlui-debug-panel",children:[d.jsx(yhe,{}),d.jsx(She,{}),e&&d.jsx(e,{})]})});function mhe(t=!0){const[e,n]=w.useState(0),r=z();w.useEffect(()=>{if(!t)return;const s=()=>n(o=>o+1);return r.on("tick",s),()=>{r.off("tick",s)}},[r,t])}const yhe=Zt(function(){mhe();const e=z(),n=e.getPath(),r=e.getHoveredShape(),s=e.getOnlySelectedShape(),o=n==="select.idle"||!n.includes("select.")?r:s,i=o&&n.includes("select.")?` / ${o.type||""}${"geo"in o.props?" / "+o.props.geo:""} / [${x.ToInt(e.getPointInShapeSpace(o,e.inputs.currentPagePoint))}]`:"",a=n.startsWith("select.")&&!n.includes(".idle")?` / [${x.ToInt(e.inputs.originPagePoint)}] → [${x.ToInt(e.inputs.currentPagePoint)}] = ${x.Dist(e.inputs.originPagePoint,e.inputs.currentPagePoint).toFixed(0)}`:"";return d.jsx("div",{className:"tlui-debug-panel__current-state",children:`${n}${i}${a}`})});function She(){const t=z(),e=U("show_fps",()=>wt.showFps.get(),[wt]),n=w.useRef(null);return w.useEffect(()=>{if(!e)return;const r=250;let s=0,o=-1,i=performance.now(),a=0,l=0,c=!1;function u(){if(l++,a=performance.now()-i,a>r){const h=Math.round(l*(r/a)*(1e3/r));h>s&&(s=h);const f=s*.75;(h<f&&!c||h>=f&&c)&&(c=!c),n.current.innerHTML=`FPS ${h.toString()}`,n.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),a-=r,l=0,i=performance.now()}o=t.timers.requestAnimationFrame(u)}return u(),()=>{cancelAnimationFrame(o)}},[e,t]),e?d.jsx("div",{ref:n}):null}const vhe=w.memo(function(){const e=An(),n=w.useRef(null);Ai(n);const{MainMenu:r,QuickActions:s,ActionsMenu:o,PageMenu:i}=Ri(),a=z(),l=U("isSinglePageMode",()=>a.options.maxPages<=1,[a]),c=a.options.actionShortcutsLocation==="menu"?!0:a.options.actionShortcutsLocation==="toolbar"?!1:e>=St.TABLET;return!r&&!i&&!c?null:d.jsx("div",{ref:n,className:"tlui-menu-zone",children:d.jsxs("div",{className:"tlui-buttons__horizontal",children:[r&&d.jsx(r,{}),i&&!l&&d.jsx(i,{}),c?d.jsxs(d.Fragment,{children:[s&&d.jsx(s,{}),o&&d.jsx(o,{})]}):null]})})});function xhe(){const t=z(),e=ka(),[n,r]=w.useState(!1),s=w.useRef(!1);return ui("toggle showback to content",()=>{const o=s.current,i=t.getCurrentPageShapeIds();let a=!1;i.size&&(a=i.size===t.getCulledShapes().size),o!==a&&(r(a),s.current=a)},[t]),n?d.jsx(W,{actionId:"back-to-content",onSelect:()=>{e["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function whe(){const t=z();return U("is pen mode",()=>t.getInstanceState().isPenMode,[t])?d.jsx(W,{actionId:"exit-pen-mode"}):null}function bhe(){const t=z(),e=ka();return U("is following user",()=>!!t.getInstanceState().followingUserId,[t])?d.jsx(Kt,{...e["stop-following"]}):null}function Phe(){return d.jsxs(d.Fragment,{children:[d.jsx(whe,{}),d.jsx(xhe,{}),d.jsx(bhe,{})]})}function Che({children:t}){const e=t??d.jsx(Phe,{});return d.jsx("div",{className:"tlui-helper-buttons",children:d.jsx(Fr,{type:"helper-buttons",sourceId:"helper-buttons",children:e})})}function _he(){const t=gm();return d.jsxs(d.Fragment,{children:[d.jsxs(ve,{label:"shortcuts-dialog.tools",id:"tools",children:[d.jsx(W,{actionId:"toggle-tool-lock"}),d.jsx(W,{actionId:"insert-media"}),d.jsx(Ln,{toolId:"select"}),d.jsx(Ln,{toolId:"draw"}),d.jsx(Ln,{toolId:"eraser"}),d.jsx(Ln,{toolId:"hand"}),d.jsx(Ln,{toolId:"rectangle"}),d.jsx(Ln,{toolId:"ellipse"}),d.jsx(Ln,{toolId:"arrow"}),d.jsx(Ln,{toolId:"line"}),d.jsx(Ln,{toolId:"text"}),d.jsx(Ln,{toolId:"frame"}),d.jsx(Ln,{toolId:"note"}),d.jsx(Ln,{toolId:"laser"}),d.jsx(Kt,{id:"pointer-down",label:"tool.pointer-down",kbd:",",onSelect:()=>{}})]}),d.jsxs(ve,{label:"shortcuts-dialog.preferences",id:"preferences",children:[d.jsx(W,{actionId:"toggle-dark-mode"}),d.jsx(W,{actionId:"toggle-focus-mode"}),d.jsx(W,{actionId:"toggle-grid"})]}),d.jsxs(ve,{label:"shortcuts-dialog.edit",id:"edit",children:[d.jsx(W,{actionId:"undo"}),d.jsx(W,{actionId:"redo"}),d.jsx(W,{actionId:"cut"}),d.jsx(W,{actionId:"copy"}),d.jsx(W,{actionId:"paste"}),d.jsx(W,{actionId:"select-all"}),d.jsx(W,{actionId:"delete"}),d.jsx(W,{actionId:"duplicate"})]}),d.jsxs(ve,{label:"shortcuts-dialog.view",id:"view",children:[d.jsx(W,{actionId:"zoom-in"}),d.jsx(W,{actionId:"zoom-out"}),d.jsx(W,{actionId:"zoom-to-100"}),d.jsx(W,{actionId:"zoom-to-fit"}),d.jsx(W,{actionId:"zoom-to-selection"})]}),d.jsxs(ve,{label:"shortcuts-dialog.transform",id:"transform",children:[d.jsx(W,{actionId:"bring-to-front"}),d.jsx(W,{actionId:"bring-forward"}),d.jsx(W,{actionId:"send-backward"}),d.jsx(W,{actionId:"send-to-back"}),d.jsx(W,{actionId:"group"}),d.jsx(W,{actionId:"ungroup"}),d.jsx(W,{actionId:"flip-horizontal"}),d.jsx(W,{actionId:"flip-vertical"}),d.jsx(W,{actionId:"align-top"}),d.jsx(W,{actionId:"align-center-vertical"}),d.jsx(W,{actionId:"align-bottom"}),d.jsx(W,{actionId:"align-left"}),d.jsx(W,{actionId:"align-center-horizontal"}),d.jsx(W,{actionId:"align-right"})]}),t&&d.jsx(ve,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:d.jsx(W,{actionId:"open-cursor-chat"})})]})}const Ihe=w.memo(function({children:e}){const n=Ee(),r=An(),s=e??d.jsx(_he,{});return d.jsxs(d.Fragment,{children:[d.jsxs(dm,{className:"tlui-shortcuts-dialog__header",children:[d.jsx(hm,{children:n("shortcuts-dialog.title")}),d.jsx(fm,{})]}),d.jsx(Yu,{className:ce("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=St.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=St.TABLET}),children:d.jsx(Fr,{type:"keyboard-shortcuts",sourceId:"kbd",children:s})}),d.jsx("div",{className:"tlui-dialog__scrim"})]})});function VF(){const t=Ti(),e=Jt(),n=U("locale",()=>t==null?void 0:t.user.getLocale(),[t]);return t?d.jsx(Jn,{id:"help menu language",label:"menu.language",children:d.jsx(ve,{id:"languages",children:Bu.map(({locale:r,label:s})=>d.jsx(vm,{id:`language-${r}`,title:r,label:s,checked:r===n,readonlyOk:!0,onSelect:()=>{t.user.updateUserPreferences({locale:r}),e("change-language",{source:"menu",locale:r})}},r))})}):null}function Ehe(){return d.jsxs(d.Fragment,{children:[d.jsx(VF,{}),d.jsx(YF,{})]})}function YF(){const{KeyboardShortcutsDialog:t}=Ri(),{addDialog:e}=Ed(),n=w.useCallback(()=>{t&&e({component:t})},[e,t]);return t?d.jsx(Kt,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:n}):null}function khe(){return d.jsxs(d.Fragment,{children:[d.jsxs(ve,{id:"basic",children:[d.jsx(Mhe,{}),d.jsx(Dhe,{}),d.jsx(The,{}),d.jsx(Rhe,{})]}),d.jsx(Lhe,{})]})}function The(){return d.jsxs(Jn,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[d.jsxs(ve,{id:"export-all-as-group",children:[d.jsx(W,{actionId:"export-all-as-svg"}),d.jsx(W,{actionId:"export-all-as-png"}),d.jsx(W,{actionId:"export-all-as-json"})]}),d.jsx(ve,{id:"export-all-as-bg",children:d.jsx(q1,{})})]})}function Mhe(){const t=z(),e=U("isSelectToolActive",()=>t.getCurrentToolId()==="select",[t]);return d.jsxs(Jn,{id:"edit",label:"menu.edit",disabled:!e,children:[d.jsx(Ohe,{}),d.jsx(zF,{}),d.jsx(BF,{}),d.jsx(Ahe,{}),d.jsx(jhe,{}),d.jsx(ve,{id:"select-all",children:d.jsx(UF,{})})]})}function Ahe(){return d.jsxs(ve,{id:"misc",children:[d.jsx(jF,{}),d.jsx(OF,{}),d.jsx(MF,{}),d.jsx(TF,{}),d.jsx(DF,{}),d.jsx(RF,{}),d.jsx(KF,{}),d.jsx(HF,{}),d.jsx(AF,{})]})}function jhe(){return d.jsxs(ve,{id:"lock",children:[d.jsx(LF,{}),d.jsx(Ode,{})]})}function Ohe(){const t=kF(),e=EF();return d.jsxs(ve,{id:"undo-redo",children:[d.jsx(W,{actionId:"undo",disabled:!t}),d.jsx(W,{actionId:"redo",disabled:!e})]})}function Dhe(){return d.jsx(Jn,{id:"view",label:"menu.view",children:d.jsxs(ve,{id:"view-actions",children:[d.jsx(W,{actionId:"zoom-in"}),d.jsx(W,{actionId:"zoom-out"}),d.jsx($F,{}),d.jsx(FF,{}),d.jsx(NF,{})]})})}function Rhe(){return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"insert-embed"}),d.jsx(W,{actionId:"insert-media"})]})}function Lhe(){return d.jsxs(ve,{id:"preferences",children:[d.jsxs(Jn,{id:"preferences",label:"menu.preferences",children:[d.jsxs(ve,{id:"preferences-actions",children:[d.jsx(Wde,{}),d.jsx(Gde,{}),d.jsx(Vde,{}),d.jsx(Yde,{}),d.jsx(Xde,{}),d.jsx(qde,{}),d.jsx(Zde,{}),d.jsx(Jde,{}),d.jsx(ehe,{}),d.jsx(Qde,{})]}),d.jsx(ve,{id:"color-scheme",children:d.jsx(Uae,{})})]}),d.jsx(VF,{}),d.jsx(YF,{})]})}const $he=w.memo(function({children:e}){const n=Tt(),[r,s]=Mo("main menu"),o=Ee(),i=e??d.jsx(khe,{});return d.jsxs(c1,{dir:"ltr",open:r,onOpenChange:s,modal:!1,children:[d.jsx(u1,{asChild:!0,dir:"ltr",children:d.jsx(ue,{type:"icon","data-testid":"main-menu.button",title:o("menu.title"),children:d.jsx(be,{icon:"menu",small:!0})})}),d.jsx(um,{container:n,children:d.jsx(d1,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:d.jsx(Fr,{type:"menu",sourceId:"main-menu",children:i})})})]})}),kS={};function Rc(t){if(kS[t])return kS[t];const n=document.createElement("canvas").getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const[r,s,o,i]=n.getImageData(0,0,1,1).data,a=new Float32Array([r/255,s/255,o/255,i/255]);return kS[t]=a,a}const Ff=10,XF=4*6*Ff+12+4*12;function Ka(t,{center:e,radius:n,numArcSegments:r=20,startAngle:s=0,endAngle:o=Fe,offset:i=0}){const a=(o-s)/r;let l=i;for(let c=s;c<o;c+=a)t[l++]=e.x,t[l++]=e.y,t[l++]=e.x+Math.cos(c)*n,t[l++]=e.y+Math.sin(c)*n,t[l++]=e.x+Math.cos(c+a)*n,t[l++]=e.y+Math.sin(c+a)*n;return t}function Wa(t,e,n,r,s,o){t[e++]=n,t[e++]=r,t[e++]=n,t[e++]=r+o,t[e++]=n+s,t[e++]=r,t[e++]=n+s,t[e++]=r,t[e++]=n,t[e++]=r+o,t[e++]=n+s,t[e++]=r+o}function Fhe(t,e,n){const r=Ff;n=Math.min(n,Math.min(e.w,e.h)/2);const s=Z.ExpandBy(e,-n);if(s.w<=0||s.h<=0)return Ka(t,{center:e.center,radius:n,numArcSegments:Ff*4}),Ff*4*6;let o=0;return Wa(t,o,s.minX,s.minY,s.w,s.h),o+=12,Wa(t,o,s.minX,e.minY,s.w,n),o+=12,Wa(t,o,s.maxX,s.minY,n,s.h),o+=12,Wa(t,o,s.minX,s.maxY,s.w,n),o+=12,Wa(t,o,e.minX,s.minY,n,s.h),o+=12,Ka(t,{numArcSegments:r,offset:o,center:s.point,radius:n,startAngle:De,endAngle:De*1.5}),o+=r*6,Ka(t,{numArcSegments:r,offset:o,center:x.Add(s.point,new x(s.w,0)),radius:n,startAngle:De*1.5,endAngle:Fe}),o+=r*6,Ka(t,{numArcSegments:r,offset:o,center:x.Add(s.point,s.size),radius:n,startAngle:0,endAngle:Ze}),o+=r*6,Ka(t,{numArcSegments:r,offset:o,center:x.Add(s.point,new x(0,s.h)),radius:n,startAngle:Ze,endAngle:De}),XF}function Nhe(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 n=`#version 300 es
|
|
384
|
-
precision mediump float;
|
|
385
|
-
|
|
386
|
-
in vec2 shapeVertexPosition;
|
|
387
|
-
|
|
388
|
-
uniform vec4 canvasPageBounds;
|
|
389
|
-
|
|
390
|
-
// taken (with thanks) from
|
|
391
|
-
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
392
|
-
void main() {
|
|
393
|
-
// convert the position from pixels to 0.0 to 1.0
|
|
394
|
-
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
395
|
-
|
|
396
|
-
// convert from 0->1 to 0->2
|
|
397
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
398
|
-
|
|
399
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
400
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
401
|
-
|
|
402
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
403
|
-
}`,r=e.createShader(e.VERTEX_SHADER);if(!r)throw new Error("Failed to create vertex shader");if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const s=`#version 300 es
|
|
404
|
-
precision mediump float;
|
|
405
|
-
|
|
406
|
-
uniform vec4 fillColor;
|
|
407
|
-
out vec4 outputColor;
|
|
408
|
-
|
|
409
|
-
void main() {
|
|
410
|
-
outputColor = fillColor;
|
|
411
|
-
}`,o=e.createShader(e.FRAGMENT_SHADER);if(!o)throw new Error("Failed to create fragment shader");if(e.shaderSource(o,s),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const i=e.createProgram();if(!i)throw new Error("Failed to create program");if(e.attachShader(i,r),e.attachShader(i,o),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("Failed to link program");e.useProgram(i);const a=e.getAttribLocation(i,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");e.enableVertexAttribArray(a);const l=e.getUniformLocation(i,"canvasPageBounds"),c=e.getUniformLocation(i,"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:Bh(e,1024),unselectedShapes:Bh(e,4096),viewport:Bh(e,XF),collaborators:Bh(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 Bh(t,e){const n=t.createBuffer();if(!n)throw new Error("Failed to create buffer");return{buffer:n,vertices:new Float32Array(e)}}function c2(t,e,n){let r=t.vertices.length;for(;r<e+n.length;)r*=2;if(r!=t.vertices.length){const s=new Float32Array(r);s.set(t.vertices),t.vertices=s}t.vertices.set(n,e)}var zhe=Object.create,qF=Object.defineProperty,Bhe=Object.getOwnPropertyDescriptor,Uhe=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ZF=t=>{throw TypeError(t)},QF=(t,e,n)=>e in t?qF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Hhe=t=>[,,,zhe(null)],JF=["class","method","getter","setter","accessor","field","value","get","set"],eN=t=>t!==void 0&&typeof t!="function"?ZF("Function expected"):t,Khe=(t,e,n,r,s)=>({kind:JF[t],name:e,metadata:r,addInitializer:o=>n._?ZF("Already initialized"):s.push(eN(o||null))}),Whe=(t,e)=>QF(e,Uhe("metadata"),t[3]),Ghe=(t,e,n,r)=>{for(var s=0,o=t[e>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Vs=(t,e,n,r,s,o)=>{for(var i,a,l,c,u=e&7,h=!1,f=!1,p=2,g=JF[u+5],m=t[p]||(t[p]=[]),v=(s=s.prototype,Bhe(s,n)),y=r.length-1;y>=0;y--)l=Khe(u,n,a={},t[3],m),l.static=h,l.private=f,c=l.access={has:S=>n in S},c.get=S=>S[n],i=(0,r[y])(v[g],l),a._=1,eN(i)&&(v[g]=i);return v&&qF(s,n,v),s},Js=(t,e,n)=>QF(t,typeof e!="symbol"?e+"":e,n),tN,nN,rN,sN,oN,iN,aN,lN,cN,uN,br;uN=[Kn],cN=[G],lN=[G],aN=[G],iN=[G],oN=[G],sN=[G],rN=[G],nN=[G],tN=[Kn];class Br{constructor(e,n,r){this.editor=e,this.elem=n,this.container=r,Ghe(br,5,this),Js(this,"disposables",[]),Js(this,"gl"),Js(this,"shapeGeometryCache"),Js(this,"colors"),Js(this,"id",ze()),Js(this,"canvasBoundingClientRect",It("canvasBoundingClientRect",new Z)),Js(this,"originPagePoint",new x),Js(this,"originPageCenter",new x),Js(this,"isInViewport",!1),this.gl=Nhe(n),this.shapeGeometryCache=e.store.createComputedCache("webgl-geometry",s=>{const o=e.getShapeMaskedPageBounds(s.id);if(!o)return null;const i=new Float32Array(12);return Wa(i,0,o.x,o.y,o.w,o.h),i}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),As("minimap render",this.render))}close(){return this.disposables.forEach(e=>e())}_getColors(){const e=getComputedStyle(this.editor.getContainer());return{shapeFill:Rc(e.getPropertyValue("--color-text-3").trim()),selectFill:Rc(e.getPropertyValue("--color-selected").trim()),viewportFill:Rc(e.getPropertyValue("--color-muted-1").trim()),background:Rc(e.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const e=this.editor.getViewportPageBounds(),n=this.editor.getCurrentPageBounds();return n?Z.Expand(n,e):e}getContentScreenBounds(){const e=this.getContentPageBounds(),n=this.editor.pageToScreen(e.point),r=this.editor.pageToScreen(new x(e.maxX,e.maxY));return new Z(n.x,n.y,r.x-n.x,r.y-n.y)}_getCanvasBoundingRect(){const{x:e,y:n,width:r,height:s}=this.elem.getBoundingClientRect();return new Z(e,n,r,s)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const e=new ResizeObserver(()=>{const n=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(n)});return e.observe(this.elem),e.observe(this.container),()=>e.disconnect()}getCanvasSize(){const e=this.canvasBoundingClientRect.get(),n=this.getDpr();return new x(e.width*n,e.height*n)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const e=this.getCanvasScreenBounds(),n=this.getContentPageBounds(),r=e.width/e.height;let s=n.width,o=s/r;o<n.height&&(o=n.height,s=o*r);const i=new Z(0,0,s,o);return i.center=n.center,i}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:e,y:n,w:r,h:s}=this.getCanvasPageBounds();return new Float32Array([e,n,r,s])}getMinimapPagePoint(e,n){const r=this.getCanvasPageBounds(),s=this.getCanvasScreenBounds();let o=e-s.x,i=n-s.y;return o*=r.width/s.width,i*=r.height/s.height,o+=r.minX,i+=r.minY,new x(o,i,1)}minimapScreenPointToPagePoint(e,n,r=!1,s=!1){const{editor:o}=this,i=o.getViewportPageBounds();let{x:a,y:l}=this.getMinimapPagePoint(e,n);if(s){const c=this.editor.getCurrentPageBounds()??new Z,u=c.minX-i.width/2,h=c.maxX+i.width/2,f=c.minY-i.height/2,p=c.maxY+i.height/2,g=Math.max(0,u+i.width-a),m=Math.max(0,-(h-i.width-a)),v=Math.max(0,f+i.height-l),y=Math.max(0,-(p-i.height-l));a+=(g-m)/2,l+=(v-y)/2,a=Bt(a,u,h),l=Bt(l,f,p)}if(r){const{originPagePoint:c}=this,u=Math.abs(a-c.x),h=Math.abs(l-c.y);u>h?l=c.y:a=c.x}return new x(a,l)}render(){const e=this.gl.context,n=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=n.x,this.elem.height=n.y,e.viewport(0,0,n.x,n.y),e.clearColor(this.colors.background[0],this.colors.background[1],this.colors.background[2],1),e.clear(e.COLOR_BUFFER_BIT);const r=new Set(this.editor.getSelectedShapeIds()),s=this.colors;let o=0,i=0;const a=this.editor.getCurrentPageShapeIdsSorted();for(let l=0,c=a.length;l<c;l++){const u=a[l],h=this.shapeGeometryCache.get(u);if(!h)continue;const f=h.length;r.has(u)?(c2(this.gl.selectedShapes,o,h),o+=f):(c2(this.gl.unselectedShapes,i,h),i+=f)}this.drawShapes(this.gl.unselectedShapes,i,s.shapeFill),this.drawShapes(this.gl.selectedShapes,o,s.selectFill),this.drawViewport(),this.drawCollaborators()}drawShapes(e,n,r){this.gl.prepareTriangles(e,n),this.gl.setFillColor(r),this.gl.drawTriangles(n)}drawViewport(){const e=this.editor.getViewportPageBounds(),n=Fhe(this.gl.viewport.vertices,e,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,n),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(n),Ge.isSafari&&(this.gl.drawTrianglesTransparently(n),this.gl.drawTrianglesTransparently(n),this.gl.drawTrianglesTransparently(n))}drawCollaborators(){const e=this.editor.getCollaboratorsOnCurrentPage();if(!e.length)return;const n=20,r=n*6,s=r*e.length;this.gl.collaborators.vertices.length<s&&(this.gl.collaborators.vertices=new Float32Array(s));const o=this.gl.collaborators.vertices;let i=0;const a=this.getZoom();for(const{cursor:l}of e)l&&(Ka(o,{center:x.From(l),radius:3*a,offset:i,numArcSegments:n}),i+=r);this.gl.prepareTriangles(this.gl.collaborators,s),i=0;for(const{color:l}of e)this.gl.setFillColor(Rc(l)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,i/2,r/2),i+=r}}br=Hhe();Vs(br,1,"close",uN,Br);Vs(br,1,"getDpr",cN,Br);Vs(br,1,"getContentPageBounds",lN,Br);Vs(br,1,"getContentScreenBounds",aN,Br);Vs(br,1,"getCanvasSize",iN,Br);Vs(br,1,"getCanvasClientPosition",oN,Br);Vs(br,1,"getCanvasPageBounds",sN,Br);Vs(br,1,"getZoom",rN,Br);Vs(br,1,"getCanvasPageBoundsArray",nN,Br);Vs(br,1,"render",tN,Br);Whe(br,Br);function Vhe(){const t=z(),e=Tt(),n=w.useRef(null),r=w.useRef(!1),s=w.useRef();w.useEffect(()=>{try{const u=new Br(t,n.current,e);return s.current=u,s.current.close}catch(u){t.annotateError(u,{origin:"minimap",willCrashApp:!1}),t.timers.setTimeout(()=>{throw u})}},[t,e]);const o=w.useCallback(u=>{if(!t.getCurrentPageShapeIds().size||!s.current)return;const h=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),f=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);s.current.originPagePoint.setTo(f),s.current.originPageCenter.setTo(t.getViewportPageBounds().center),t.centerOnPoint(h,{animation:{duration:t.options.animationMediumMs}})},[t]),i=w.useCallback(u=>{if(!s.current)return;const h=u.currentTarget;if(dd(h,u),!t.getCurrentPageShapeIds().size)return;r.current=!0,s.current.isInViewport=!1;const f=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),p=t.getViewportPageBounds(),g=s.current.getContentPageBounds();if(new Z(g.x-p.width/2,g.y-p.height/2,g.width+p.width,g.height+p.height).containsPoint(f)&&!p.containsPoint(f)){s.current.isInViewport=p.containsPoint(f);const y=x.Sub(p.center,p.point),S=x.Add(f,y);s.current.originPagePoint.setTo(S),s.current.originPageCenter.setTo(f),t.centerOnPoint(f,{animation:{duration:t.options.animationMediumMs}})}else{const y=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);s.current.isInViewport=p.containsPoint(y),s.current.originPagePoint.setTo(y),s.current.originPageCenter.setTo(p.center)}function v(y){h&&hd(h,y),r.current=!1,document.body.removeEventListener("pointerup",v)}document.body.addEventListener("pointerup",v)},[t]),a=w.useCallback(u=>{if(!s.current)return;const h=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,u.shiftKey,!0);if(r.current){if(s.current.isInViewport){const m=s.current.originPagePoint.clone().sub(s.current.originPageCenter);t.centerOnPoint(x.Sub(h,m));return}t.centerOnPoint(h)}const f=s.current.getMinimapPagePoint(u.clientX,u.clientY),p=t.pageToScreen(f),g={type:"pointer",target:"canvas",name:"pointer_move",...lr(u),point:p,isPen:t.getInstanceState().isPenMode};t.dispatch(g)},[t]),l=w.useCallback(u=>{const h=wj(u);t.dispatch({type:"wheel",name:"wheel",delta:h,point:new x(u.clientX,u.clientY),shiftKey:u.shiftKey,altKey:u.altKey,ctrlKey:u.metaKey||u.ctrlKey,metaKey:u.metaKey,accelKey:un(u)})},[t]),c=xd();return w.useEffect(()=>{t.timers.setTimeout(()=>{var u,h;(u=s.current)==null||u.updateColors(),(h=s.current)==null||h.render()})},[c,t]),d.jsx("div",{className:"tlui-minimap",children:d.jsx("canvas",{role:"img","aria-label":"minimap",ref:n,className:"tlui-minimap__canvas",onDoubleClick:o,onPointerMove:a,onPointerDown:i,onWheelCapture:l})})}function Yhe(t,e){const[n,r]=ke.useState(e);ke.useLayoutEffect(()=>{const o=_0(t);if(o)try{r(JSON.parse(o))}catch{console.error(`Could not restore value ${t} from local storage.`)}},[t]);const s=ke.useCallback(o=>{r(i=>{const a=typeof o=="function"?o(i):o;return I0(t,JSON.stringify(a)),a})},[t]);return[n,s]}const Xhe=w.memo(function(){const e=ka(),n=Ee(),r=An(),s=w.useRef(null);Ai(s);const[o,i]=Yhe("minimap",!0),a=w.useCallback(()=>{i(u=>!u)},[i]),{ZoomMenu:l,Minimap:c}=Ri();return r<St.MOBILE?null:d.jsxs("div",{ref:s,className:"tlui-navigation-panel",children:[d.jsx("div",{className:"tlui-buttons__horizontal",children:l&&r<St.TABLET?d.jsx(l,{}):o?d.jsxs(d.Fragment,{children:[l&&d.jsx(l,{}),c&&d.jsx(ue,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:d.jsx(be,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):d.jsxs(d.Fragment,{children:[d.jsx(ue,{type:"icon","data-testid":"minimap.zoom-out",title:`${n(Xu(e["zoom-out"].label))} ${Xx(e["zoom-out"].kbd)}`,onClick:()=>e["zoom-out"].onSelect("navigation-zone"),children:d.jsx(be,{icon:"minus"})}),l&&d.jsx(l,{}),d.jsx(ue,{type:"icon","data-testid":"minimap.zoom-in",title:`${n(Xu(e["zoom-in"].label))} ${Xx(e["zoom-in"].kbd)}`,onClick:()=>e["zoom-in"].onSelect("navigation-zone"),children:d.jsx(be,{icon:"plus"})}),c&&d.jsx(ue,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:d.jsx(be,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),c&&r>=St.TABLET&&!o&&d.jsx(c,{})]})}),qhe=function({name:e,id:n,isCurrentPage:r,onCancel:s}){const o=z(),i=Jt(),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(()=>{l.current=o.markHistoryStoppingPoint("rename page")},[o]),u=w.useCallback(f=>{o.renamePage(n,f||"New Page"),i("rename-page",{source:"page-menu"})},[o,n,i]),h=w.useCallback(()=>{l.current&&o.bailToMark(l.current),s()},[o,s]);return d.jsx(pm,{className:"tlui-page-menu__item__input",ref:f=>a.current=f,defaultValue:e,onValueChange:u,onCancel:h,onFocus:c,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:r,autoSelect:!0})},gw=(t,e,n,r,s)=>{let o;const i=t.getPages(),a=n>r?i[r-1]:i[r],l=n>r?i[r]:i[r+1];a&&!l?o=_s(a.index):!a&&l?o=aB(i[0].index):o=$u(a.index,l.index),o!==i[n].index&&(t.markHistoryStoppingPoint("moving page"),t.updatePage({id:e,index:o}),s("move-page",{source:"page-menu"}))},u2=Zt(function({index:e,listSize:n,item:r,onRename:s}){const o=z(),i=Ee(),a=o.getPages(),l=Jt(),c=w.useCallback(()=>{o.markHistoryStoppingPoint("creating page");const p=yr.createId();o.duplicatePage(r.id,p),l("duplicate-page",{source:"page-menu"})},[o,r,l]),u=w.useCallback(()=>{gw(o,r.id,e,e-1,l)},[o,r,e,l]),h=w.useCallback(()=>{gw(o,r.id,e,e+1,l)},[o,r,e,l]),f=w.useCallback(()=>{o.markHistoryStoppingPoint("deleting page"),o.deletePage(r.id),l("delete-page",{source:"page-menu"})},[o,r,l]);return d.jsxs(ma,{id:`page item submenu ${e}`,children:[d.jsx(ya,{children:d.jsx(ue,{type:"icon",title:i("page-menu.submenu.title"),children:d.jsx(be,{icon:"dots-vertical",small:!0})})}),d.jsx(Sa,{alignOffset:0,side:"right",sideOffset:-4,children:d.jsxs(Fr,{type:"menu",sourceId:"page-menu",children:[d.jsxs(ve,{id:"modify",children:[s&&d.jsx(Kt,{id:"rename",label:"page-menu.submenu.rename",onSelect:s}),d.jsx(Kt,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=o.options.maxPages}),e>0&&d.jsx(Kt,{id:"move-up",onSelect:u,label:"page-menu.submenu.move-up"}),e<n-1&&d.jsx(Kt,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:h})]}),n>1&&d.jsx(ve,{id:"delete",children:d.jsx(Kt,{id:"delete",onSelect:f,label:"page-menu.submenu.delete"})})]})})]})}),Zhe=w.memo(function(){const e=z(),n=Jt(),r=Ee(),s=An(),o=w.useCallback(()=>y(!1),[]),[i,a]=Mo("page-menu",o),l=36,c=w.useRef(null),u=U("pages",()=>e.getPages(),[e]),h=U("currentPage",()=>e.getCurrentPage(),[e]),f=U("currentPageId",()=>e.getCurrentPageId(),[e]),p=wr(),g=U("maxPageCountReached",()=>e.getPages().length>=e.options.maxPages,[e]),m=U("isCoarsePointer",()=>e.getInstanceState().isCoarsePointer,[e]),[v,y]=w.useState(!1),S=w.useCallback(()=>{p||y(M=>!M)},[p]),b=w.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[P,C]=w.useState(Object.fromEntries(u.map((M,O)=>[M.id,{y:O*l,offsetY:0,isSelected:!1}])));w.useLayoutEffect(()=>{C(Object.fromEntries(u.map((M,O)=>[M.id,{y:O*l,offsetY:0,isSelected:!1}])))},[l,u]),w.useEffect(()=>{i&&e.timers.requestAnimationFrame(()=>{const M=document.querySelector(`[data-testid="page-menu-item-${f}"]`);if(M){const O=c.current;if(!O)return;const F=M.offsetTop,B=O.scrollTop;F<B&&O.scrollTo({top:F});const K=F+l,R=O.scrollTop+O.offsetHeight;K>R&&O.scrollTo({top:K-O.offsetHeight})}})},[l,f,i,e]);const _=w.useCallback(M=>{const{clientY:O,currentTarget:F}=M,{dataset:{id:B,index:K}}=F;if(!B||!K)return;const R=b.current;dd(M.currentTarget,M),R.status="pointing",R.pointing={id:B,index:+K};const X=P[B].y;R.startY=O,R.startIndex=Math.max(0,Math.min(Math.round(X/l),u.length-1))},[l,u.length,P]),E=w.useCallback(M=>{const O=b.current;if(O.status==="pointing"){const{clientY:F}=M,B=F-O.startY;Math.abs(B)>5&&(O.status="dragging")}if(O.status==="dragging"){const{clientY:F}=M,B=F-O.startY,K=P[O.pointing.id],{startIndex:R,pointing:H}=O,X=K.y+B,te=Math.max(0,Math.min(Math.round(X/l),u.length-1)),le={...P};if(le[H.id]={y:K.y,offsetY:B,isSelected:!0},te!==O.dragIndex){O.dragIndex=te;for(let de=0;de<u.length;de++){const Me=u[de];if(Me.id===O.pointing.id)continue;let{y:oe}=le[Me.id];te===R?oe=de*l:te<R?te<=de&&de<R?oe=(de+1)*l:oe=de*l:te>R&&(te>=de&&de>R?oe=(de-1)*l:oe=de*l),oe!==le[Me.id].y&&(le[Me.id]={y:oe,offsetY:0,isSelected:!0})}}C(le)}},[l,u,P]),k=w.useCallback(M=>{const O=b.current;if(O.status==="dragging"){const{id:F,index:B}=O.pointing;gw(e,F,B,O.dragIndex,n)}hd(M.currentTarget,M),O.status="idle"},[e,n]),D=w.useCallback(M=>{const O=b.current;M.key==="Escape"&&(O.status==="dragging"&&C(Object.fromEntries(u.map((F,B)=>[F.id,{y:B*l,offsetY:0,isSelected:!1}]))),O.status="idle")},[l,u]),T=w.useCallback(()=>{p||(e.run(()=>{e.markHistoryStoppingPoint("creating page");const M=yr.createId();e.createPage({name:r("page-menu.new-page-initial-name"),id:M}),e.setCurrentPage(M),y(!0)}),n("new-page",{source:"page-menu"}))},[e,r,p,n]),j=w.useCallback(M=>{e.setCurrentPage(M),n("change-page",{source:"page-menu"})},[e,n]),L=w.useCallback((M,O)=>{e.renamePage(M,O),n("rename-page",{source:"page-menu"})},[e,n]);return d.jsxs(V1,{id:"pages",onOpenChange:a,open:i,children:[d.jsx(Y1,{"data-testid":"main.page-menu",children:d.jsxs(ue,{type:"menu",title:h.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[d.jsx("div",{className:"tlui-page-menu__name",children:h.name}),d.jsx(be,{icon:"chevron-down",small:!0})]})}),d.jsx(X1,{side:"bottom",align:"start",sideOffset:6,disableEscapeKeyDown:v,children:d.jsxs("div",{className:"tlui-page-menu__wrapper",children:[d.jsxs("div",{className:"tlui-page-menu__header",children:[d.jsx("div",{className:"tlui-page-menu__header__title",children:r("page-menu.title")}),!p&&d.jsxs("div",{className:"tlui-buttons__horizontal",children:[d.jsx(ue,{type:"icon","data-testid":"page-menu.edit",title:r(v?"page-menu.edit-done":"page-menu.edit-start"),onClick:S,children:d.jsx(be,{icon:v?"check":"edit"})}),d.jsx(ue,{type:"icon","data-testid":"page-menu.create",title:r(g?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:g,onClick:T,children:d.jsx(be,{icon:"plus"})})]})]}),d.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((M,O)=>{const F=P[M.id]??{position:O*40,offsetY:0};return v?d.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:M.id===h.id?888:O,transform:`translate(0px, ${F.y+F.offsetY}px)`},children:[d.jsx(ue,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:_,onPointerUp:k,onPointerMove:E,onKeyDown:D,"data-id":M.id,"data-index":O,children:d.jsx(be,{icon:"drag-handle-dots"})}),s<St.TABLET_SM&&m?d.jsxs(ue,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const B=window.prompt("Rename page",M.name);B&&B!==M.name&&L(M.id,B)},onDoubleClick:S,children:[d.jsx(pw,{checked:M.id===h.id}),d.jsx(bt,{children:M.name})]}):d.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:l},children:d.jsx(qhe,{id:M.id,name:M.name,isCurrentPage:M.id===h.id,onCancel:()=>{y(!1),e.menus.clearOpenMenus()}})}),!p&&d.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":v,children:d.jsx(u2,{index:O,item:M,listSize:u.length})})]},M.id+"_editing"):d.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[d.jsxs(ue,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>j(M.id),onDoubleClick:S,title:r("page-menu.go-to-page"),children:[d.jsx(pw,{checked:M.id===h.id}),d.jsx(bt,{children:M.name})]}),!p&&d.jsx("div",{className:"tlui-page_menu__item__submenu",children:d.jsx(u2,{index:O,item:M,listSize:u.length,onRename:()=>{if(Ge.isIos){const B=window.prompt("Rename page",M.name);B&&B!==M.name&&L(M.id,B)}else y(!0),f!==M.id&&j(M.id)}})})]},M.id)})})]})})]})});function Qhe(){const t=z(),e=wr(),n=U("should display quick actions",()=>t.isInAny("select","hand","zoom"),[t]);if(!(e&&!n))return d.jsxs(d.Fragment,{children:[d.jsx(efe,{}),d.jsx(Jhe,{})]})}function Jhe(){const t=jn(1),e=Ao(),n=t&&e;return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"delete",disabled:!n}),d.jsx(W,{actionId:"duplicate",disabled:!n})]})}function efe(){const t=kF(),e=EF();return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"undo",disabled:!t}),d.jsx(W,{actionId:"redo",disabled:!e})]})}const tfe=w.memo(function({children:e}){const n=e??d.jsx(Qhe,{});return d.jsx(Fr,{type:"small-icons",sourceId:"quick-actions",children:n})});function nfe({userId:t}){const e=Lg(t);return e?d.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:e.color},children:e.userName==="New User"?"":e.userName[0]??""},t):null}const rfe=Zt(function({userId:e}){const n=z(),r=Ee(),s=Jt(),o=Lg(e),i=w.useCallback(()=>{n.getInstanceState().followingUserId===e?(n.stopFollowingUser(),s("stop-following",{source:"people-menu"})):(n.startFollowingUser(e),s("start-following",{source:"people-menu"}))},[n,e,s]),a=(o==null?void 0:o.followingUserId)===n.user.getId(),l=n.getInstanceState().followingUserId===e;return o?d.jsxs("div",{className:"tlui-people-menu__item tlui-buttons__horizontal",children:[d.jsxs(ue,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>n.zoomToUser(e),onDoubleClick:i,children:[d.jsx(zs,{icon:"color",color:o.color}),d.jsx("div",{className:"tlui-people-menu__name",children:o.userName??"New User"})]}),d.jsx(ue,{type:"icon",className:"tlui-people-menu__item__follow",title:r(a?"people-menu.leading":l?"people-menu.following":"people-menu.follow"),onClick:i,disabled:a,"data-active":l||a,children:d.jsx(be,{icon:a?"leading":l?"following":"follow"})})]}):null});function sfe({count:t}){return d.jsx("div",{className:"tlui-people-menu__more",children:"+"+Math.abs(t)})}const ofe=Zt(function(){const e=z(),n=Tt(),r=Ee(),s=Jt(),o=w.useRef(!1),[i,a]=w.useState(!1),l=w.useCallback(m=>{a(m)},[]),c=e.user.getColor(),u=w.useCallback(m=>{e.user.updateUserPreferences({color:m}),s("set-color",{source:"people-menu"})},[e,s]),{handleButtonClick:h,handleButtonPointerDown:f,handleButtonPointerEnter:p,handleButtonPointerUp:g}=ke.useMemo(()=>{const m=()=>{o.current=!1,window.removeEventListener("pointerup",m)};return{handleButtonClick:P=>{const{id:C}=P.currentTarget.dataset;C&&c!==C&&u(C)},handleButtonPointerDown:P=>{const{id:C}=P.currentTarget.dataset;C&&(u(C),o.current=!0,window.addEventListener("pointerup",m))},handleButtonPointerEnter:P=>{if(!o.current)return;const{id:C}=P.currentTarget.dataset;C&&u(C)},handleButtonPointerUp:P=>{const{id:C}=P.currentTarget.dataset;C&&u(C)}}},[c,u]);return d.jsxs(H1,{onOpenChange:l,open:i,children:[d.jsx(K1,{dir:"ltr",asChild:!0,children:d.jsx(ue,{type:"icon",className:"tlui-people-menu__user__color",style:{color:e.user.getColor()},title:r("people-menu.change-color"),children:d.jsx(be,{icon:"color"})})}),d.jsx(W1,{container:n,children:d.jsx(G1,{dir:"ltr",className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:d.jsx("div",{className:"tlui-buttons__grid",children:Px.map(m=>d.jsx(ue,{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:h,children:d.jsx(be,{icon:"color"})},m))})})})]})});function ife(){const t=z(),e=Jt(),n=U("userName",()=>t.user.getName(),[]),r=Ee(),s=w.useRef(n),o=w.useRef(n),[i,a]=w.useState(!1),l=w.useCallback(()=>{a(f=>!f)},[]),c=w.useCallback(f=>{o.current=f,t.user.updateUserPreferences({name:f})},[t]),u=w.useCallback(()=>{s.current!==o.current&&(e("change-user-name",{source:"people-menu"}),s.current=o.current)},[e]),h=w.useCallback(()=>{a(!1),t.user.updateUserPreferences({name:s.current}),t.menus.clearOpenMenus()},[t]);return d.jsxs("div",{className:"tlui-people-menu__user",children:[d.jsx(ofe,{}),i?d.jsx(pm,{className:"tlui-people-menu__user__input",defaultValue:n,onValueChange:c,onComplete:l,onCancel:h,onBlur:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{i||a(!0)},children:n}),n==="New User"?d.jsx("div",{className:"tlui-people-menu__user__label",children:r("people-menu.user")}):null]}),d.jsx(ue,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:r("people-menu.change-name"),onClick:l,children:d.jsx(be,{icon:i?"check":"edit"})})]})}function afe({displayUserWhenAlone:t,children:e}){const n=Ee(),r=Tt(),s=z(),o=Cj(),i=U("user",()=>s.user.getColor(),[s]),a=U("user",()=>s.user.getName(),[s]),[l,c]=Mo("people menu");return d.jsxs(H1,{onOpenChange:c,open:l,children:[d.jsx(K1,{dir:"ltr",asChild:!0,children:d.jsxs("button",{className:"tlui-people-menu__avatars-button",title:n("people-menu.title"),children:[o.length>5&&d.jsx(sfe,{count:o.length-5}),d.jsxs("div",{className:"tlui-people-menu__avatars",children:[o.slice(-5).map(u=>d.jsx(nfe,{userId:u},u)),(t||o.length>0)&&d.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:i},children:a==="New User"?"":a[0]??""})]})]})}),d.jsx(W1,{container:r,children:d.jsx(G1,{dir:"ltr",className:"tlui-menu",side:"bottom",sideOffset:2,collisionPadding:4,onEscapeKeyDown:xe,children:d.jsxs("div",{className:"tlui-people-menu__wrapper",children:[d.jsx("div",{className:"tlui-people-menu__section",children:d.jsx(ife,{})}),o.length>0&&d.jsx("div",{className:"tlui-people-menu__section",children:o.map(u=>d.jsx(rfe,{userId:u},u+"_presence"))}),e]})})})]})}function lfe(){return d.jsx("div",{className:"tlui-share-zone",draggable:!1,children:d.jsx(afe,{displayUserWhenAlone:!0})})}const cfe=Object.freeze([mr,ua,da,$s]);function dN(t=cfe){const e=z();return U("getRelevantStyles",()=>{var o;const n=new Tx(e.getSharedStyles()),r=!!((o=e.root.getCurrent())!=null&&o.shapeType),s=e.isIn("select")&&e.getSelectedShapeIds().length>0;if(n.size===0&&e.isIn("select")&&e.getSelectedShapeIds().length===0)for(const i of t)n.applyValue(i,e.getStyleForNextShape(i));return r||s||n.size>0?n:null},[e])}const jr={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"}]},Xi=w.memo(function(e){const{uiType:n,items:r,title:s,style:o,value:i,onValueChange:a,onHistoryMark:l,theme:c}=e,u=Ee(),h=w.useRef(!1),f=w.useRef(null),{handleButtonClick:p,handleButtonPointerDown:g,handleButtonPointerEnter:m,handleButtonPointerUp:v}=w.useMemo(()=>{const y=()=>{h.current=!1,window.removeEventListener("pointerup",y);const _=f.current;_&&["TEXTAREA","INPUT"].includes(_.nodeName)&&_.focus(),f.current=null};return{handleButtonClick:_=>{const{id:E}=_.currentTarget.dataset;i.type==="shared"&&i.value===E||(l==null||l("point picker item"),a(o,E))},handleButtonPointerDown:_=>{const{id:E}=_.currentTarget.dataset;l==null||l("point picker item"),a(o,E),h.current=!0,f.current=document.activeElement,window.addEventListener("pointerup",y)},handleButtonPointerEnter:_=>{if(!h.current)return;const{id:E}=_.currentTarget.dataset;a(o,E)},handleButtonPointerUp:_=>{const{id:E}=_.currentTarget.dataset;i.type==="shared"&&i.value===E||a(o,E)}}},[i,l,a,o]);return d.jsx("div",{"data-testid":`style.${n}`,className:ce("tlui-buttons__grid"),children:r.map(y=>d.jsx(ue,{type:"icon","data-id":y.value,"data-testid":`style.${n}.${y.value}`,"aria-label":y.value,"data-state":i.type==="shared"&&i.value===y.value?"hinted":void 0,title:s+" — "+u(`${n}-style.${y.value}`),className:ce("tlui-button-grid__button"),style:o===mr?{color:c[y.value].solid}:void 0,onPointerEnter:m,onPointerDown:g,onPointerUp:v,onClick:p,children:d.jsx(be,{icon:y.icon})},y.value))})});function hN(t,[e,n]){return Math.min(n,Math.max(e,t))}function ufe(t){const e=w.useRef({value:t,previous:t});return w.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var fN=["PageUp","PageDown"],pN=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gN={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},lc="Slider",[mw,dfe,hfe]=Jg(lc),[mN,Rge]=Ws(lc,[hfe]),[ffe,Tm]=mN(lc),yN=w.forwardRef((t,e)=>{const{name:n,min:r=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:g,...m}=t,v=w.useRef(new Set),y=w.useRef(0),b=i==="horizontal"?pfe:gfe,[P=[],C]=ji({prop:u,defaultProp:c,onChange:j=>{var M;(M=[...v.current][y.current])==null||M.focus(),h(j)}}),_=w.useRef(P);function E(j){const L=xfe(P,j);T(j,L)}function k(j){T(j,y.current)}function D(){const j=_.current[y.current];P[y.current]!==j&&f(P)}function T(j,L,{commit:M}={commit:!1}){const O=Cfe(o),F=_fe(Math.round((j-r)/o)*o+r,O),B=hN(F,[r,s]);C((K=[])=>{const R=Sfe(K,B,L);if(Pfe(R,l*o)){y.current=R.indexOf(B);const H=String(R)!==String(K);return H&&M&&f(R),H?R:K}else return K})}return d.jsx(ffe,{scope:t.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:v.current,values:P,orientation:i,form:g,children:d.jsx(mw.Provider,{scope:t.__scopeSlider,children:d.jsx(mw.Slot,{scope:t.__scopeSlider,children:d.jsx(b,{"aria-disabled":a,"data-disabled":a?"":void 0,...m,ref:e,onPointerDown:se(m.onPointerDown,()=>{a||(_.current=P)}),min:r,max:s,inverted:p,onSlideStart:a?void 0:E,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:D,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(s,P.length-1,{commit:!0}),onStepKeyDown:({event:j,direction:L})=>{if(!a){const F=fN.includes(j.key)||j.shiftKey&&pN.includes(j.key)?10:1,B=y.current,K=P[B],R=o*F*L;T(K+R,B,{commit:!0})}}})})})})});yN.displayName=lc;var[SN,vN]=mN(lc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),pfe=w.forwardRef((t,e)=>{const{min:n,max:r,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=t,[h,f]=w.useState(null),p=Qe(e,b=>f(b)),g=w.useRef(void 0),m=Fb(s),v=m==="ltr",y=v&&!o||!v&&o;function S(b){const P=g.current||h.getBoundingClientRect(),C=[0,P.width],E=Z1(C,y?[n,r]:[r,n]);return g.current=P,E(b-P.left)}return d.jsx(SN,{scope:t.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:d.jsx(xN,{dir:m,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const P=S(b.clientX);i==null||i(P)},onSlideMove:b=>{const P=S(b.clientX);a==null||a(P)},onSlideEnd:()=>{g.current=void 0,l==null||l()},onStepKeyDown:b=>{const C=gN[y?"from-left":"from-right"].includes(b.key);c==null||c({event:b,direction:C?-1:1})}})})}),gfe=w.forwardRef((t,e)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:l,...c}=t,u=w.useRef(null),h=Qe(e,u),f=w.useRef(void 0),p=!s;function g(m){const v=f.current||u.current.getBoundingClientRect(),y=[0,v.height],b=Z1(y,p?[r,n]:[n,r]);return f.current=v,b(m-v.top)}return d.jsx(SN,{scope:t.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:d.jsx(xN,{"data-orientation":"vertical",...c,ref:h,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:m=>{const v=g(m.clientY);o==null||o(v)},onSlideMove:m=>{const v=g(m.clientY);i==null||i(v)},onSlideEnd:()=>{f.current=void 0,a==null||a()},onStepKeyDown:m=>{const y=gN[p?"from-bottom":"from-top"].includes(m.key);l==null||l({event:m,direction:y?-1:1})}})})}),xN=w.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:l,...c}=t,u=Tm(lc,n);return d.jsx(Ae.span,{...c,ref:e,onKeyDown:se(t.onKeyDown,h=>{h.key==="Home"?(i(h),h.preventDefault()):h.key==="End"?(a(h),h.preventDefault()):fN.concat(pN).includes(h.key)&&(l(h),h.preventDefault())}),onPointerDown:se(t.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(f)?f.focus():r(h)}),onPointerMove:se(t.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&s(h)}),onPointerUp:se(t.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),o(h))})})}),wN="SliderTrack",bN=w.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,s=Tm(wN,n);return d.jsx(Ae.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:e})});bN.displayName=wN;var yw="SliderRange",PN=w.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,s=Tm(yw,n),o=vN(yw,n),i=w.useRef(null),a=Qe(e,i),l=s.values.length,c=s.values.map(f=>_N(f,s.min,s.max)),u=l>1?Math.min(...c):0,h=100-Math.max(...c);return d.jsx(Ae.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...t.style,[o.startEdge]:u+"%",[o.endEdge]:h+"%"}})});PN.displayName=yw;var Sw="SliderThumb",CN=w.forwardRef((t,e)=>{const n=dfe(t.__scopeSlider),[r,s]=w.useState(null),o=Qe(e,a=>s(a)),i=w.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return d.jsx(mfe,{...t,ref:o,index:i})}),mfe=w.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:s,...o}=t,i=Tm(Sw,n),a=vN(Sw,n),[l,c]=w.useState(null),u=Qe(e,S=>c(S)),h=l?i.form||!!l.closest("form"):!0,f=m3(l),p=i.values[r],g=p===void 0?0:_N(p,i.min,i.max),m=vfe(r,i.values.length),v=f==null?void 0:f[a.size],y=v?wfe(v,g,a.direction):0;return w.useEffect(()=>{if(l)return i.thumbs.add(l),()=>{i.thumbs.delete(l)}},[l,i.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[d.jsx(mw.ItemSlot,{scope:t.__scopeSlider,children:d.jsx(Ae.span,{role:"slider","aria-label":t["aria-label"]||m,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:u,style:p===void 0?{display:"none"}:t.style,onFocus:se(t.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),h&&d.jsx(yfe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});CN.displayName=Sw;var yfe=t=>{const{value:e,...n}=t,r=w.useRef(null),s=ufe(e);return w.useEffect(()=>{const o=r.current,i=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(i,"value").set;if(s!==e&&l){const c=new Event("input",{bubbles:!0});l.call(o,e),o.dispatchEvent(c)}},[s,e]),d.jsx("input",{style:{display:"none"},...n,ref:r,defaultValue:e})};function Sfe(t=[],e,n){const r=[...t];return r[n]=e,r.sort((s,o)=>s-o)}function _N(t,e,n){const o=100/(n-e)*(t-e);return hN(o,[0,100])}function vfe(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function xfe(t,e){if(t.length===1)return 0;const n=t.map(s=>Math.abs(s-e)),r=Math.min(...n);return n.indexOf(r)}function wfe(t,e,n){const r=t/2,o=Z1([0,50],[0,r]);return(r-o(e)*n)*n}function bfe(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function Pfe(t,e){if(e>0){const n=bfe(t);return Math.min(...n)>=e}return!0}function Z1(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function Cfe(t){return(String(t).split(".")[1]||"").length}function _fe(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var Ife=yN,Efe=bN,kfe=PN,Tfe=CN;const Mfe=w.memo(function({onHistoryMark:e,title:n,steps:r,value:s,label:o,onValueChange:i,["data-testid"]:a}){const l=Ee(),c=w.useCallback(f=>{i(f[0])},[i]),u=w.useCallback(()=>{e("click slider")},[e]),h=w.useCallback(()=>{s&&i(s)},[s,i]);return d.jsx("div",{className:"tlui-slider__container",children:d.jsxs(Ife,{"data-testid":a,className:"tlui-slider","area-label":"Opacity",dir:"ltr",min:0,max:r,step:1,value:s?[s]:void 0,onPointerDown:u,onValueChange:c,onPointerUp:h,title:n+" — "+l(o),children:[d.jsx(Efe,{className:"tlui-slider__track",dir:"ltr",children:s!==null&&d.jsx(kfe,{className:"tlui-slider__range",dir:"ltr"})}),s!==null&&d.jsx(Tfe,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function Afe({label:t,uiTypeA:e,uiTypeB:n,labelA:r,labelB:s,itemsA:o,itemsB:i,styleA:a,styleB:l,valueA:c,valueB:u,onValueChange:h}){const f=Ee(),p=w.useMemo(()=>{var m;return((m=o.find(v=>c.type==="shared"&&c.value===v.value))==null?void 0:m.icon)??"mixed"},[o,c]),g=w.useMemo(()=>{var m;return((m=i.find(v=>u.type==="shared"&&u.value===v.value))==null?void 0:m.icon)??"mixed"},[i,u]);return c===void 0&&u===void 0?null:d.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[d.jsx("div",{title:f(t),className:"tlui-style-panel__double-select-picker-label",children:f(t)}),d.jsxs("div",{className:"tlui-buttons__horizontal",children:[d.jsxs(ma,{id:`style panel ${e} A`,children:[d.jsx(ya,{children:d.jsx(ue,{type:"icon","data-testid":`style.${e}`,title:f(r)+" — "+(c===null||c.type==="mixed"?f("style-panel.mixed"):f(`${e}-style.${c.value}`)),children:d.jsx(be,{icon:p,small:!0,invertIcon:!0})})}),d.jsx(Sa,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:o.map((m,v)=>d.jsx(qu,{"data-testid":`style.${e}.${m.value}`,children:d.jsx(ue,{type:"icon",onClick:()=>h(a,m.value),title:`${f(r)} — ${f(`${e}-style.${m.value}`)}`,children:d.jsx(be,{icon:m.icon,invertIcon:!0})},m.value)},v))})})]}),d.jsxs(ma,{id:`style panel ${n}`,children:[d.jsx(ya,{children:d.jsx(ue,{type:"icon","data-testid":`style.${n}`,title:f(s)+" — "+(u===null||u.type==="mixed"?f("style-panel.mixed"):f(`${n}-style.${u.value}`)),children:d.jsx(be,{icon:g,small:!0})})}),d.jsx(Sa,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:i.map(m=>d.jsx(qu,{children:d.jsx(ue,{type:"icon",title:`${f(s)} — ${f(`${n}-style.${m.value}`)}`,"data-testid":`style.${n}.${m.value}`,onClick:()=>h(l,m.value),children:d.jsx(be,{icon:m.icon})})},m.value))})})]})]})]})}const jfe=w.memo(Afe);function Ofe({id:t,label:e,uiType:n,stylePanelType:r,style:s,items:o,type:i,value:a,onValueChange:l}){const c=Ee(),u=z(),h=w.useMemo(()=>{var m;return(m=o.find(v=>a.type==="shared"&&v.value===a.value))==null?void 0:m.icon},[o,a]),f=c(`style-panel.${r}`),p=a.type==="mixed"?c("style-panel.mixed"):f+" — "+c(`${n}-style.${a.value}`),g=e?c(e):"";return d.jsxs(ma,{id:`style panel ${t}`,children:[d.jsx(ya,{children:d.jsxs(ue,{type:i,"data-testid":`style.${n}`,title:p,children:[g&&d.jsx(bt,{children:g}),d.jsx(be,{icon:h??"mixed"})]})}),d.jsx(Sa,{side:"left",align:"center",alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:o.map(m=>d.jsx(qu,{children:d.jsx(ue,{type:"icon","data-testid":`style.${n}.${m.value}`,title:f+" — "+c(`${n}-style.${m.value}`),onClick:()=>{u.markHistoryStoppingPoint("select style dropdown item"),l(s,m.value)},children:d.jsx(be,{icon:m.icon})})},m.value))})})]})}const Q1=w.memo(Ofe);function Dfe({styles:t}){const e=xd();if(!t)return null;const n=t.get(Jr),r=t.get(Mp),s=t.get(Tp),o=t.get(Dp),i=t.get(Ls),a=n===void 0,l=r===void 0&&s===void 0,c=o===void 0,u=i===void 0,h=ko({isDarkMode:e});return d.jsxs(d.Fragment,{children:[d.jsx(Rfe,{theme:h,styles:t}),!u&&d.jsx(Lfe,{theme:h,styles:t}),!(a&&l&&c)&&d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[d.jsx($fe,{styles:t}),d.jsx(Nfe,{styles:t}),d.jsx(Ffe,{styles:t})]})]})}function Td(){const t=z(),e=Jt();return ke.useMemo(()=>function(r,s){t.run(()=>{t.isIn("select")&&t.setStyleForSelectedShapes(r,s),t.setStyleForNextShapes(r,s),t.updateInstanceState({isChangingStyle:!0})}),e("set-style",{source:"style-panel",id:r.id,value:s})},[t,e])}function Rfe({styles:t,theme:e}){const n=Ee(),r=z(),s=w.useCallback(h=>r.markHistoryStoppingPoint(h),[r]),o=Td(),i=t.get(mr),a=t.get(da),l=t.get(ua),c=t.get($s),u=a!==void 0||l!==void 0||c!==void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[i===void 0?null:d.jsx(Xi,{title:n("style-panel.color"),uiType:"color",style:mr,items:jr.color,value:i,onValueChange:o,theme:e,onHistoryMark:s}),d.jsx(zfe,{})]}),u&&d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[a===void 0?null:d.jsx(Xi,{title:n("style-panel.fill"),uiType:"fill",style:da,items:jr.fill,value:a,onValueChange:o,theme:e,onHistoryMark:s}),l===void 0?null:d.jsx(Xi,{title:n("style-panel.dash"),uiType:"dash",style:ua,items:jr.dash,value:l,onValueChange:o,theme:e,onHistoryMark:s}),c===void 0?null:d.jsx(Xi,{title:n("style-panel.size"),uiType:"size",style:$s,items:jr.size,value:c,onValueChange:(h,f)=>{o(h,f);const p=r.getSelectedShapeIds();p.length>0&&Xe(r,p)},theme:e,onHistoryMark:s})]})]})}function Lfe({theme:t,styles:e}){const n=Ee(),r=Td(),s=z(),o=w.useCallback(u=>s.markHistoryStoppingPoint(u),[s]),i=e.get(Ls),a=e.get(Sx),l=e.get(jp),c=e.get(Op);return i===void 0&&l===void 0?null:d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[i===void 0?null:d.jsx(Xi,{title:n("style-panel.font"),uiType:"font",style:Ls,items:jr.font,value:i,onValueChange:r,theme:t,onHistoryMark:o}),a===void 0?null:d.jsxs("div",{className:"tlui-style-panel__row",children:[d.jsx(Xi,{title:n("style-panel.align"),uiType:"align",style:Sx,items:jr.textAlign,value:a,onValueChange:r,theme:t,onHistoryMark:o}),d.jsx("div",{className:"tlui-style-panel__row__extra-button",children:d.jsx(ue,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:d.jsx(be,{icon:"vertical-align-middle"})})})]}),l===void 0?null:d.jsxs("div",{className:"tlui-style-panel__row",children:[d.jsx(Xi,{title:n("style-panel.label-align"),uiType:"align",style:jp,items:jr.horizontalAlign,value:l,onValueChange:r,theme:t,onHistoryMark:o}),d.jsx("div",{className:"tlui-style-panel__row__extra-button",children:c===void 0?d.jsx(ue,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:d.jsx(be,{icon:"vertical-align-middle"})}):d.jsx(Q1,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",stylePanelType:"vertical-align",style:Op,items:jr.verticalAlign,value:c,onValueChange:r})})]})]})}function $fe({styles:t}){const e=Td(),n=t.get(Jr);return n===void 0?null:d.jsx(Q1,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",stylePanelType:"geo",style:Jr,items:jr.geo,value:n,onValueChange:e})}function Ffe({styles:t}){const e=Td(),n=t.get(Dp);return n===void 0?null:d.jsx(Q1,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",stylePanelType:"spline",style:Dp,items:jr.spline,value:n,onValueChange:e})}function Nfe({styles:t}){const e=Td(),n=t.get(Mp),r=t.get(Tp);return!n||!r?null:d.jsx(jfe,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:Tp,itemsA:jr.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:Mp,itemsB:jr.arrowheadEnd,valueB:n,onValueChange:e,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const Lc=[.1,.25,.5,.75,1];function zfe(){const t=z(),e=w.useCallback(a=>t.markHistoryStoppingPoint(a),[t]),n=U("opacity",()=>t.getSharedOpacity(),[t]),r=Jt(),s=Ee(),o=ke.useCallback(a=>{const l=Lc[a];t.run(()=>{t.isIn("select")&&t.setOpacityForSelectedShapes(l),t.setOpacityForNextShapes(l),t.updateInstanceState({isChangingStyle:!0})}),r("set-style",{source:"style-panel",id:"opacity",value:a})},[t,r]);if(n===void 0)return null;const i=n.type==="mixed"?-1:Lc.indexOf(M9(Lc,a=>Math.abs(a-n.value)));return d.jsx(Mfe,{"data-testid":"style.opacity",value:i>=0?i:Lc.length-1,label:n.type==="mixed"?"style-panel.mixed":`opacity-style.${n.value}`,onValueChange:o,steps:Lc.length-1,title:s("style-panel.opacity"),onHistoryMark:e})}const Bfe=w.memo(function({isMobile:e,children:n}){const r=z(),s=w.useRef(null);Ai(s);const o=dN(),i=w.useCallback(()=>{e||r.updateInstanceState({isChangingStyle:!1})},[r,e]),a=n??d.jsx(Dfe,{styles:o});return d.jsx("div",{ref:s,className:ce("tlui-style-panel",{"tlui-style-panel__wrapper":!e}),"data-ismobile":e,onPointerLeave:i,children:a})});function Ufe(){const t=z(),e=Ee(),n=dN(),r=n==null?void 0:n.get(mr),s=ko({isDarkMode:t.user.getIsDarkMode()}),o=((r==null?void 0:r.type)==="shared"?s[r.value]:s.black).solid,i=U("disable style panel",()=>t.isInAny("hand","zoom","eraser","laser"),[t]),a=w.useCallback(c=>{c||t.updateInstanceState({isChangingStyle:!1})},[t]),{StylePanel:l}=Ri();return l?d.jsxs(V1,{id:"mobile style menu",onOpenChange:a,children:[d.jsx(Y1,{children:d.jsx(ue,{type:"tool","data-testid":"mobile-styles.button",style:{color:i?"var(--color-muted-1)":o},title:e("style-panel.title"),disabled:i,children:d.jsx(be,{icon:i?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),d.jsx(X1,{side:"top",align:"end",children:l&&d.jsx(l,{isMobile:!0})})]}):null}function Hfe(){return d.jsxs(d.Fragment,{children:[d.jsx(Wfe,{}),d.jsx(Gfe,{}),d.jsx(Vfe,{}),d.jsx(Yfe,{}),d.jsx(Xfe,{}),d.jsx(qfe,{}),d.jsx(Zfe,{}),d.jsx(Qfe,{}),d.jsx(Jfe,{}),d.jsx(epe,{}),d.jsx(npe,{}),d.jsx(tpe,{}),d.jsx(ope,{}),d.jsx(lpe,{}),d.jsx(rpe,{}),d.jsx(ape,{}),d.jsx(ipe,{}),d.jsx(spe,{}),d.jsx(cpe,{}),d.jsx(upe,{}),d.jsx(dpe,{}),d.jsx(hpe,{}),d.jsx(fpe,{}),d.jsx(ppe,{}),d.jsx(gpe,{}),d.jsx(mpe,{}),d.jsx(Spe,{}),d.jsx(ype,{})]})}function Kfe(t){var r;const e=z(),n=(r=t.meta)==null?void 0:r.geo;return U("is tool selected",()=>{const s=e.getCurrentToolId(),o=e.getSharedStyles().getAsKnownValue(Jr);return n?s==="geo"&&o===n:s===t.id},[e,t.id,n])}function Ve({tool:t}){const e=E1(),n=Kfe(e[t]);return d.jsx(Ln,{toolId:t,isSelected:n})}function Wfe(){return d.jsx(Ve,{tool:"select"})}function Gfe(){return d.jsx(Ve,{tool:"hand"})}function Vfe(){return d.jsx(Ve,{tool:"draw"})}function Yfe(){return d.jsx(Ve,{tool:"eraser"})}function Xfe(){return d.jsx(Ve,{tool:"arrow"})}function qfe(){return d.jsx(Ve,{tool:"text"})}function Zfe(){return d.jsx(Ve,{tool:"note"})}function Qfe(){return d.jsx(Ln,{toolId:"asset"})}function Jfe(){return d.jsx(Ve,{tool:"rectangle"})}function epe(){return d.jsx(Ve,{tool:"ellipse"})}function tpe(){return d.jsx(Ve,{tool:"diamond"})}function npe(){return d.jsx(Ve,{tool:"triangle"})}function rpe(){return d.jsx(Ve,{tool:"rhombus"})}function spe(){return d.jsx(Ve,{tool:"heart"})}function ope(){return d.jsx(Ve,{tool:"hexagon"})}function ipe(){return d.jsx(Ve,{tool:"cloud"})}function ape(){return d.jsx(Ve,{tool:"star"})}function lpe(){return d.jsx(Ve,{tool:"oval"})}function cpe(){return d.jsx(Ve,{tool:"x-box"})}function upe(){return d.jsx(Ve,{tool:"check-box"})}function dpe(){return d.jsx(Ve,{tool:"arrow-left"})}function hpe(){return d.jsx(Ve,{tool:"arrow-up"})}function fpe(){return d.jsx(Ve,{tool:"arrow-down"})}function ppe(){return d.jsx(Ve,{tool:"arrow-right"})}function gpe(){return d.jsx(Ve,{tool:"line"})}function mpe(){return d.jsx(Ve,{tool:"highlight"})}function ype(){return d.jsx(Ve,{tool:"frame"})}function Spe(){return d.jsx(Ve,{tool:"laser"})}const TS=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function MS(t,e,n,r){t.addEventListener?t.addEventListener(e,n,r):t.attachEvent&&t.attachEvent("on".concat(e),n)}function $c(t,e,n,r){t.removeEventListener?t.removeEventListener(e,n,r):t.detachEvent&&t.detachEvent("on".concat(e),n)}function IN(t,e){const n=e.slice(0,e.length-1);for(let r=0;r<n.length;r++)n[r]=t[n[r].toLowerCase()];return n}function EN(t){typeof t!="string"&&(t=""),t=t.replace(/\s/g,"");const e=t.split(",");let n=e.lastIndexOf("");for(;n>=0;)e[n-1]+=",",e.splice(n,1),n=e.lastIndexOf("");return e}function vpe(t,e){const n=t.length>=e.length?t:e,r=t.length>=e.length?e:t;let s=!0;for(let o=0;o<n.length;o++)r.indexOf(n[o])===-1&&(s=!1);return s}const Zu={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,"-":TS?173:189,"=":TS?61:187,";":TS?59:186,"'":222,"[":219,"]":221,"\\":220},Us={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Nf={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Ut={16:!1,18:!1,17:!1,91:!1},ft={};for(let t=1;t<20;t++)Zu["f".concat(t)]=111+t;let it=[],gu=null,kN="all";const ro=new Map,Md=t=>Zu[t.toLowerCase()]||Us[t.toLowerCase()]||t.toUpperCase().charCodeAt(0),xpe=t=>Object.keys(Zu).find(e=>Zu[e]===t),wpe=t=>Object.keys(Us).find(e=>Us[e]===t);function TN(t){kN=t||"all"}function Qu(){return kN||"all"}function bpe(){return it.slice(0)}function Ppe(){return it.map(t=>xpe(t)||wpe(t)||String.fromCharCode(t))}function Cpe(){const t=[];return Object.keys(ft).forEach(e=>{ft[e].forEach(n=>{let{key:r,scope:s,mods:o,shortcut:i}=n;t.push({scope:s,shortcut:i,mods:o,keys:r.split("+").map(a=>Md(a))})})}),t}function _pe(t){const e=t.target||t.srcElement,{tagName:n}=e;let r=!0;const s=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return(e.isContentEditable||(s||n==="TEXTAREA"||n==="SELECT")&&!e.readOnly)&&(r=!1),r}function Ipe(t){return typeof t=="string"&&(t=Md(t)),it.indexOf(t)!==-1}function Epe(t,e){let n,r;t||(t=Qu());for(const s in ft)if(Object.prototype.hasOwnProperty.call(ft,s))for(n=ft[s],r=0;r<n.length;)n[r].scope===t?n.splice(r,1).forEach(i=>{let{element:a}=i;return J1(a)}):r++;Qu()===t&&TN(e||"all")}function kpe(t){let e=t.keyCode||t.which||t.charCode;const n=it.indexOf(e);if(n>=0&&it.splice(n,1),t.key&&t.key.toLowerCase()==="meta"&&it.splice(0,it.length),(e===93||e===224)&&(e=91),e in Ut){Ut[e]=!1;for(const r in Us)Us[r]===e&&(Wn[r]=!1)}}function MN(t){if(typeof t>"u")Object.keys(ft).forEach(s=>{Array.isArray(ft[s])&&ft[s].forEach(o=>Uh(o)),delete ft[s]}),J1(null);else if(Array.isArray(t))t.forEach(s=>{s.key&&Uh(s)});else if(typeof t=="object")t.key&&Uh(t);else if(typeof t=="string"){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];let[s,o]=n;typeof s=="function"&&(o=s,s=""),Uh({key:t,scope:s,method:o,splitKey:"+"})}}const Uh=t=>{let{key:e,scope:n,method:r,splitKey:s="+"}=t;EN(e).forEach(i=>{const a=i.split(s),l=a.length,c=a[l-1],u=c==="*"?"*":Md(c);if(!ft[u])return;n||(n=Qu());const h=l>1?IN(Us,a):[],f=[];ft[u]=ft[u].filter(p=>{const m=(r?p.method===r:!0)&&p.scope===n&&vpe(p.mods,h);return m&&f.push(p.element),!m}),f.forEach(p=>J1(p))})};function d2(t,e,n,r){if(e.element!==r)return;let s;if(e.scope===n||e.scope==="all"){s=e.mods.length>0;for(const o in Ut)Object.prototype.hasOwnProperty.call(Ut,o)&&(!Ut[o]&&e.mods.indexOf(+o)>-1||Ut[o]&&e.mods.indexOf(+o)===-1)&&(s=!1);(e.mods.length===0&&!Ut[16]&&!Ut[18]&&!Ut[17]&&!Ut[91]||s||e.shortcut==="*")&&(e.keys=[],e.keys=e.keys.concat(it),e.method(t,e)===!1&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0)))}}function h2(t,e){const n=ft["*"];let r=t.keyCode||t.which||t.charCode;if(!Wn.filter.call(this,t))return;if((r===93||r===224)&&(r=91),it.indexOf(r)===-1&&r!==229&&it.push(r),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=Nf[a];t[a]&&it.indexOf(l)===-1?it.push(l):!t[a]&&it.indexOf(l)>-1?it.splice(it.indexOf(l),1):a==="metaKey"&&t[a]&&(it=it.filter(c=>c in Nf||c===r))}),r in Ut){Ut[r]=!0;for(const a in Us)Us[a]===r&&(Wn[a]=!0);if(!n)return}for(const a in Ut)Object.prototype.hasOwnProperty.call(Ut,a)&&(Ut[a]=t[Nf[a]]);t.getModifierState&&!(t.altKey&&!t.ctrlKey)&&t.getModifierState("AltGraph")&&(it.indexOf(17)===-1&&it.push(17),it.indexOf(18)===-1&&it.push(18),Ut[17]=!0,Ut[18]=!0);const s=Qu();if(n)for(let a=0;a<n.length;a++)n[a].scope===s&&(t.type==="keydown"&&n[a].keydown||t.type==="keyup"&&n[a].keyup)&&d2(t,n[a],s,e);if(!(r in ft))return;const o=ft[r],i=o.length;for(let a=0;a<i;a++)if((t.type==="keydown"&&o[a].keydown||t.type==="keyup"&&o[a].keyup)&&o[a].key){const l=o[a],{splitKey:c}=l,u=l.key.split(c),h=[];for(let f=0;f<u.length;f++)h.push(Md(u[f]));h.sort().join("")===it.sort().join("")&&d2(t,l,s,e)}}function Wn(t,e,n){it=[];const r=EN(t);let s=[],o="all",i=document,a=0,l=!1,c=!0,u="+",h=!1,f=!1;for(n===void 0&&typeof e=="function"&&(n=e),Object.prototype.toString.call(e)==="[object Object]"&&(e.scope&&(o=e.scope),e.element&&(i=e.element),e.keyup&&(l=e.keyup),e.keydown!==void 0&&(c=e.keydown),e.capture!==void 0&&(h=e.capture),typeof e.splitKey=="string"&&(u=e.splitKey),e.single===!0&&(f=!0)),typeof e=="string"&&(o=e),f&&MN(t,o);a<r.length;a++)t=r[a].split(u),s=[],t.length>1&&(s=IN(Us,t)),t=t[t.length-1],t=t==="*"?"*":Md(t),t in ft||(ft[t]=[]),ft[t].push({keyup:l,keydown:c,scope:o,mods:s,shortcut:r[a],method:n,key:r[a],splitKey:u,element:i});if(typeof i<"u"&&window){if(!ro.has(i)){const p=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return h2(m,i)},g=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;h2(m,i),kpe(m)};ro.set(i,{keydownListener:p,keyupListenr:g,capture:h}),MS(i,"keydown",p,h),MS(i,"keyup",g,h)}if(!gu){const p=()=>{it=[]};gu={listener:p,capture:h},MS(window,"focus",p,h)}}}function Tpe(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(ft).forEach(n=>{ft[n].filter(s=>s.scope===e&&s.shortcut===t).forEach(s=>{s&&s.method&&s.method()})})}function J1(t){const e=Object.values(ft).flat();if(e.findIndex(r=>{let{element:s}=r;return s===t})<0){const{keydownListener:r,keyupListenr:s,capture:o}=ro.get(t)||{};r&&s&&($c(t,"keyup",s,o),$c(t,"keydown",r,o),ro.delete(t))}if((e.length<=0||ro.size<=0)&&(Object.keys(ro).forEach(s=>{const{keydownListener:o,keyupListenr:i,capture:a}=ro.get(s)||{};o&&i&&($c(s,"keyup",i,a),$c(s,"keydown",o,a),ro.delete(s))}),ro.clear(),Object.keys(ft).forEach(s=>delete ft[s]),gu)){const{listener:s,capture:o}=gu;$c(window,"focus",s,o),gu=null}}const AS={getPressedKeyString:Ppe,setScope:TN,getScope:Qu,deleteScope:Epe,getPressedKeyCodes:bpe,getAllKeyCodes:Cpe,isPressed:Ipe,filter:_pe,trigger:Tpe,unbind:MN,keyMap:Zu,modifier:Us,modifierMap:Nf};for(const t in AS)Object.prototype.hasOwnProperty.call(AS,t)&&(Wn[t]=AS[t]);if(typeof window<"u"){const t=window.hotkeys;Wn.noConflict=e=>(e&&window.hotkeys===Wn&&(window.hotkeys=t),Wn),window.hotkeys=Wn}const f2=["copy","cut","paste","asset"];function Mpe(){const t=z(),e=wr(),n=ka(),r=E1(),s=U("is focused",()=>t.getInstanceState().isFocused,[t]);w.useEffect(()=>{if(!s)return;const o=new Array,i=(l,c)=>{Wn(l,{element:document.body},c),o.push(()=>{Wn.unbind(l,c)})},a=(l,c)=>{Wn(l,{element:document.body,keyup:!0,keydown:!1},c),o.push(()=>{Wn.unbind(l,c)})};for(const l of Object.values(n))l.kbd&&(e&&!l.readonlyOk||f2.includes(l.id)||i(p2(l.kbd),c=>{Zc(t)||(xe(c),l.onSelect("kbd"))}));for(const l of Object.values(r))!l.kbd||!l.readonlyOk&&t.getIsReadonly()||f2.includes(l.id)||i(p2(l.kbd),c=>{Zc(t)||(xe(c),l.onSelect("kbd"))});return i(",",l=>{if(Zc(t)||t.inputs.keys.has("Comma"))return;xe(l),t.focus(),t.inputs.keys.add("Comma");const{x:c,y:u,z:h}=t.inputs.currentPagePoint,f=t.pageToScreen({x:c,y:u}),p={type:"pointer",name:"pointer_down",point:{x:f.x,y:f.y,z:h},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,metaKey:l.metaKey,accelKey:un(l),pointerId:0,button:0,isPen:t.getInstanceState().isPenMode,target:"canvas"};t.dispatch(p)}),a(",",l=>{if(Zc(t)||!t.inputs.keys.has("Comma"))return;t.inputs.keys.delete("Comma");const{x:c,y:u,z:h}=t.inputs.currentScreenPoint,f={type:"pointer",name:"pointer_up",point:{x:c,y:u,z:h},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,metaKey:l.metaKey,accelKey:un(l),pointerId:0,button:0,isPen:t.getInstanceState().isPenMode,target:"canvas"};t.dispatch(f)}),()=>{o.forEach(l=>l())}},[n,r,e,t,s])}function p2(t){return Ape(t).map(e=>{let n="";const r=e.split("");return r.length===1?n=r[0]:r[0]==="!"?n=`shift+${r[1]}`:r[0]==="?"?r.length===3&&r[1]==="!"?n=`alt+shift+${r[2]}`:n=`alt+${r[1]}`:r[0]==="$"?r[1]==="!"?n=`cmd+shift+${r[2]},ctrl+shift+${r[2]}`:r[1]==="?"?n=`cmd+⌥+${r[2]},ctrl+alt+${r[2]}`:n=`cmd+${r[1]},ctrl+${r[1]}`:n=e,n}).join(",")}function Ape(t){typeof t!="string"&&(t=""),t=t.replace(/\s/g,"");const e=t.split(",");let n=e.lastIndexOf("");for(;n>=0;)e[n-1]+=",",e.splice(n,1),n=e.lastIndexOf("");return e}function Zc(t){return t.menus.hasAnyOpenMenus()||t.getEditingShapeId()!==null||t.getCrashingError()}const jpe=w.createContext(!1);function Ope({children:t}){const e=z(),n=Jl(),r=An(),s=Ee(),o=Math.min(8,5+r),[i,a]=w.useState(0),l=w.useRef(null),[c,u]=w.useState(null),h=w.useMemo(()=>{const p=c?`:not([data-value="${c}"])`:"";return`
|
|
412
|
-
#${n}_main > *:nth-child(n + ${o+(c?1:2)})${p} {
|
|
413
|
-
display: none;
|
|
414
|
-
}
|
|
415
|
-
#${n}_more > *:nth-child(-n + ${o}) {
|
|
416
|
-
display: none;
|
|
417
|
-
}
|
|
418
|
-
`},[c,n,o]),f=Hg(()=>{if(!l.current)return;const p=Array.from(l.current.children);a(p.length),p.findIndex(v=>v.getAttribute("data-value")===c)<=o&&u(null);const m=Array.from(l.current.children).findIndex(v=>v.getAttribute("aria-checked")==="true");m!==-1&&m>=o&&u(p[m].getAttribute("data-value"))});return w.useLayoutEffect(()=>{f()}),w.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]),w.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)Wn(g,v=>{var b;if(Zc(e))return;xe(v);const S=Array.from(((b=l.current)==null?void 0:b.children)??[]).filter(P=>!(P instanceof HTMLElement)||P.tagName.toLowerCase()!=="button"?!1:!!(P.offsetWidth||P.offsetHeight))[m];S&&S.click()});return()=>{Wn.unbind("1,2,3,4,5,6,7,8,9,0")}},[e]),d.jsxs(d.Fragment,{children:[d.jsx("style",{children:h}),d.jsxs("div",{className:ce("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<St.TABLET_SM}),role:"radiogroup",children:[d.jsx("div",{id:`${n}_main`,ref:l,className:"tlui-toolbar__tools__list",children:d.jsx(Fr,{type:"toolbar",sourceId:"toolbar",children:t})}),i>o+1&&d.jsx(jpe.Provider,{value:!0,children:d.jsxs(ma,{id:"toolbar overflow",modal:!1,children:[d.jsx(ya,{children:d.jsx(ue,{title:s("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:d.jsx(be,{icon:"chevron-up"})})}),d.jsx(Sa,{side:"top",align:"center",children:d.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${n}_more`,children:d.jsx(Fr,{type:"toolbar-overflow",sourceId:"toolbar",children:t})})})]})})]})]})}function Dpe({activeToolId:t}){const e=z(),n=An(),r=Ee(),s=U("is tool locked",()=>e.getInstanceState().isToolLocked,[e]),o=U("current tool",()=>e.getCurrentTool(),[e]);return!t||!o.isLockable?null:d.jsx(ue,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:ce("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":n<St.TABLET_SM}),onClick:()=>e.updateInstanceState({isToolLocked:!s}),children:d.jsx(be,{icon:s?"lock":"unlock",small:!0})})}const Rpe=w.memo(function({children:e}){const n=z(),r=An(),s=wr(),o=U("current tool id",()=>n.getCurrentToolId(),[n]),i=w.useRef(null);Ai(i);const{ActionsMenu:a,QuickActions:l}=Ri(),c=n.options.actionShortcutsLocation==="menu"?!1:n.options.actionShortcutsLocation==="toolbar"?!0:r<St.TABLET;return d.jsx("div",{ref:i,className:"tlui-toolbar",children:d.jsxs("div",{className:"tlui-toolbar__inner",children:[d.jsxs("div",{className:"tlui-toolbar__left",children:[!s&&d.jsxs("div",{className:"tlui-toolbar__extras",children:[c&&d.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[l&&d.jsx(l,{}),a&&d.jsx(a,{})]}),d.jsx(Dpe,{activeToolId:o})]}),d.jsx(Ope,{children:e??d.jsx(Hfe,{})})]}),r<St.TABLET_SM&&!s&&d.jsx("div",{className:"tlui-toolbar__tools",children:d.jsx(Ufe,{})})]})})});function Lpe(){const t=Ee();return d.jsxs("div",{className:ce("tlui-offline-indicator"),children:[t("status.offline"),d.jsx(zs,{"aria-label":"offline",icon:"status-offline",small:!0})]})}function $pe({maxWidth:t=420,ignoreRightWidth:e=0,stylePanelWidth:n=148,marginBetweenZones:r=12,squeezeAmount:s=52,children:o}){const i=w.useRef(null),a=An(),l=w.useCallback(()=>{const c=i.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),f=u.querySelector(".tlui-layout__top__right"),p=u.offsetWidth,g=h.offsetWidth,m=f.offsetWidth,v=c.offsetWidth-e;let y=(p-v)/2;p%2!==0&&(y-=.5);const S=g+r,b=c.offsetLeft,P=Math.min(p-m-g-2*r,t),C=Math.max(y,S)-b;f.offsetWidth>n&&a<=6?c.style.setProperty("max-width",P-s+"px"):c.style.setProperty("max-width",P+"px"),c.style.setProperty("transform",`translate(${C}px, 0px)`)},[a,e,r,t,s,n]);return w.useLayoutEffect(()=>{const c=i.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),f=u.querySelector(".tlui-layout__top__right"),p=new ResizeObserver(l);return p.observe(h),p.observe(f),p.observe(u),p.observe(c),l(),()=>{p.disconnect()}},[l]),w.useLayoutEffect(()=>{l()}),d.jsx("div",{ref:i,className:"tlui-top-panel__container",children:o})}function Fpe(){const t=tie()==="offline";return d.jsx($pe,{children:t&&d.jsx(Lpe,{})})}function Npe(){return d.jsxs(d.Fragment,{children:[d.jsx(W,{actionId:"zoom-in",noClose:!0}),d.jsx(W,{actionId:"zoom-out",noClose:!0}),d.jsx($F,{}),d.jsx(FF,{}),d.jsx(NF,{})]})}const zpe=w.memo(function({children:e}){const n=Tt(),[r,s]=Mo("zoom menu"),o=e??d.jsx(Npe,{});return d.jsxs(c1,{dir:"ltr",open:r,onOpenChange:s,modal:!1,children:[d.jsx(u1,{asChild:!0,dir:"ltr",children:d.jsx(Bpe,{})}),d.jsx(um,{container:n,children:d.jsx(d1,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:d.jsx(Fr,{type:"menu",sourceId:"zoom-menu",children:o})})})]})}),Bpe=w.forwardRef(function(e,n){const r=z(),s=An(),o=U("zoom",()=>r.getZoomLevel(),[r]),i=Ee(),a=w.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{animation:{duration:r.options.animationMediumMs}})},[r]);return d.jsx(ue,{ref:n,...e,type:"icon",title:`${i("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:s<St.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,children:s<St.MOBILE?null:d.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(o*100),"%"]})})}),AN=w.createContext(null);function Upe({overrides:t={},children:e}){const n=tc(t),r=gm();return d.jsx(AN.Provider,{value:w.useMemo(()=>({ContextMenu:rhe,ActionsMenu:Ade,HelpMenu:null,ZoomMenu:zpe,MainMenu:$he,Minimap:Vhe,StylePanel:Bfe,PageMenu:Zhe,NavigationPanel:Xhe,Toolbar:Rpe,KeyboardShortcutsDialog:Ihe,QuickActions:tfe,HelperButtons:Che,DebugPanel:ghe,DebugMenu:phe,MenuPanel:vhe,SharePanel:r?lfe:null,CursorChatBubble:r?ihe:null,TopPanel:r?Fpe:null,...n}),[n,r]),children:e})}function Ri(){const t=w.useContext(AN);if(!t)throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return t}const Hpe=Zt(function({overrides:e,components:n,assetUrls:r,onUiEvent:s,forceMobile:o,mediaMimeTypes:i,children:a}){const l=Ti();return d.jsx(B$.Provider,{value:i,children:d.jsx(koe,{assetUrls:ode(r),children:d.jsx(Aoe,{overrides:Mae(e),locale:(l==null?void 0:l.user.getLocale())??vs.locale,children:d.jsx(xte,{onEvent:s,children:d.jsx(Iie,{children:d.jsx(rie,{context:l==null?void 0:l.contextId,children:d.jsx(nie,{forceMobile:o,children:d.jsx(Upe,{overrides:n,children:l?d.jsx(Kpe,{overrides:e,children:a}):a})})})})})})})})});function Kpe({overrides:t,children:e}){const n=Aae(t);return d.jsx(Oae,{overrides:n.actions,children:d.jsx(Xae,{overrides:n.tools,children:e})})}function Wpe(){const t=z(),{addToast:e}=To();w.useEffect(()=>{function n({name:r,count:s}){e({title:"Maximum Shapes Reached",description:`You've reached the maximum number of shapes allowed on ${r} (${s}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return t.addListener("max-shapes",n),()=>{t.removeListener("max-shapes",n)}},[t,e])}const Gpe=ke.memo(function({renderDebugMenuItems:e,children:n,hideUi:r,components:s,...o}){return d.jsx(Hpe,{...o,components:s,children:d.jsx(Vpe,{hideUi:r,renderDebugMenuItems:e,children:n})})}),Vpe=ke.memo(function({children:e,hideUi:n,...r}){return d.jsxs(d.Fragment,{children:[e,n?null:d.jsx(Ype,{...r})]})}),Ype=ke.memo(function(){const e=z(),n=Ee(),r=An(),s=wr(),o=U("focus",()=>e.getInstanceState().isFocusMode,[e]),i=U("debug",()=>e.getInstanceState().isDebugMode,[e]),{SharePanel:a,TopPanel:l,MenuPanel:c,StylePanel:u,Toolbar:h,HelpMenu:f,NavigationPanel:p,HelperButtons:g,DebugPanel:m,CursorChatBubble:v}=Ri();Mpe(),nae(),Wpe();const{"toggle-focus-mode":y}=ka();return d.jsxs("div",{className:ce("tlui-layout",{"tlui-layout__mobile":r<St.TABLET_SM}),"data-breakpoint":r,children:[o?d.jsx("div",{className:"tlui-layout__top",children:d.jsx(ue,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>y.onSelect("menu"),children:d.jsx(be,{icon:"dot"})})}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"tlui-layout__top",children:[d.jsxs("div",{className:"tlui-layout__top__left",children:[c&&d.jsx(c,{}),g&&d.jsx(g,{})]}),d.jsx("div",{className:"tlui-layout__top__center",children:l&&d.jsx(l,{})}),d.jsxs("div",{className:"tlui-layout__top__right",children:[a&&d.jsx(a,{}),u&&r>=St.TABLET_SM&&!s&&d.jsx(u,{})]})]}),d.jsxs("div",{className:"tlui-layout__bottom",children:[d.jsxs("div",{className:"tlui-layout__bottom__main",children:[p&&d.jsx(p,{}),h&&d.jsx(h,{}),f&&d.jsx(f,{})]}),i&&m&&d.jsx(m,{})]})]}),d.jsx(Yae,{}),d.jsx(Kae,{}),d.jsx(nde,{}),v&&d.jsx(v,{})]})});async function Xpe(t,e){const{url:n,style:r="normal",weight:s="500",display:o,featureSettings:i,stretch:a,unicodeRange:l,variant:c,format:u}=e,h={style:r,weight:s,display:o,featureSettings:i,stretch:a,unicodeRange:l,variant:c},f=new FontFace(t,`url(${n})`,h);return await f.load(),document.fonts.add(f),f.$$_url=n,f.$$_fontface=`
|
|
419
|
-
@font-face {
|
|
420
|
-
font-family: ${f.family};
|
|
421
|
-
font-stretch: ${f.stretch};
|
|
422
|
-
font-weight: ${f.weight};
|
|
423
|
-
font-style: ${f.style};
|
|
424
|
-
src: url("${n}") format("${u}")
|
|
425
|
-
}`,f}const Hh=(t,e)=>{const[n,r]=w.useState(2);return w.useEffect(()=>{let s=!1;return r(2),Xpe(t,e).then(()=>{s||r(0)}).catch(o=>{s||(console.error(o),r(1))}),()=>{s=!0}},[t,e]),n};function qpe(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 jN(t){const e=w.useMemo(()=>qpe(t),[t]),n=[Hh("tldraw_draw",e.draw),Hh("tldraw_serif",e.serif),Hh("tldraw_sans",e.sansSerif),Hh("tldraw_mono",e.monospace)];return{error:n.some(r=>r===1),done:!n.some(r=>r===2)}}function Zpe(t){const{children:e,maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:s,acceptedVideoMimeTypes:o,onMount:i,components:a={},shapeUtils:l=[],bindingUtils:c=[],tools:u=[],embeds:h,...f}=t,p=tc(a),g=w.useMemo(()=>({Scribble:CE,ShapeIndicators:ile,CollaboratorScribble:CE,SelectionForeground:rle,SelectionBackground:tle,Handles:qae,...p}),[p]),m=qo(l),v=w.useMemo(()=>[...E5,...m],[m]),y=qo(c),S=w.useMemo(()=>[...X$,...y],[y]),b=qo(u),P=w.useMemo(()=>[...tde,...Kle,...b],[b]),C=qo(s??xg),_=qo(o??x0),E=w.useMemo(()=>[...C,..._],[C,_]),k=dF(f.assetUrls),{done:D,error:T}=jN(k);return T?d.jsx(qR,{children:"Could not load assets. Please refresh the page."}):D?(v.find(L=>L.type==="embed")&&h&&Jp.setEmbedDefinitions(h),d.jsx(ote,{initialState:"select",...f,components:g,shapeUtils:v,bindingUtils:S,tools:P,children:d.jsxs(Gpe,{...f,components:g,mediaMimeTypes:E,children:[d.jsx(Qpe,{maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:C,acceptedVideoMimeTypes:_,onMount:i}),e]})})):d.jsx(Db,{children:d.jsx(vb,{})})}function Qpe({maxImageDimension:t=5e3,maxAssetSize:e=10*1024*1024,acceptedImageMimeTypes:n=xg,acceptedVideoMimeTypes:r=x0,onMount:s}){const o=z(),i=To(),a=Ee();ZR(()=>{const u=[];return u.push(_ue(o)),Ple(o,{maxImageDimension:t,maxAssetSize:e,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r},{toasts:i,msg:a}),u.push(o.store.props.onMount(o)),u.push(s==null?void 0:s(o)),()=>{u.forEach(h=>h==null?void 0:h())}});const{Canvas:l}=st(),{ContextMenu:c}=Ri();return c?d.jsx(c,{}):l?d.jsx(l,{}):null}w.memo(function(e){const[n,r]=w.useState(null),[s,o]=w.useState(null),i=qo(e.shapeUtils??[]),a=w.useMemo(()=>[...E5,...i],[i]),l=qo(e.bindingUtils??[]),c=w.useMemo(()=>[...X$,...l],[l]),u=hte({snapshot:e.snapshot,shapeUtils:a}),h=dF(e.assetUrls),{done:f,error:p}=jN(h),{pageId:g,bounds:m,scale:v,pixelRatio:y,background:S,padding:b,darkMode:P,preserveAspectRatio:C,format:_="svg",licenseKey:E}=e;return w.useLayoutEffect(()=>{if(!s||!u||!f)return;let k=!1;const D=document.createElement("div");s.appendChild(D),s.classList.add("tl-container","tl-theme__light");const T=new Q({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>D,licenseKey:E});g&&T.setCurrentPage(g);const j=T.getCurrentPageShapeIds();async function L(){const M=await T.getSvgString([...j],{bounds:m,scale:v,background:S,padding:b,darkMode:P,preserveAspectRatio:C});if(M&&!k){if(_==="svg"){if(!k){const O=new Blob([M.svg],{type:"image/svg+xml"}),F=URL.createObjectURL(O);r(F)}}else if(_==="png"){const O=await F$(T,M.svg,{type:_,width:M.width,height:M.height,pixelRatio:y});if(O&&!k){const F=URL.createObjectURL(O);r(F)}}}T.dispose()}return L(),()=>{k=!0}},[_,s,u,a,c,g,m,v,S,b,P,C,f,p,E,y]),p?d.jsx(qR,{children:"Could not load assets."}):f?d.jsx("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:n&&d.jsx("img",{src:n,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})}):d.jsx(Db,{children:d.jsx(vb,{})})});w.memo(function({children:e}){const n=Ee(),r=An(),s=w.useRef(null);Ai(s);const o=e??d.jsx(Ehe,{});return r<St.MOBILE?null:d.jsx("div",{ref:s,className:"tlui-help-menu",children:d.jsxs(ma,{id:"help menu",children:[d.jsx(ya,{children:d.jsx(ue,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:d.jsx(be,{icon:"question-mark",small:!0})})}),d.jsx(Sa,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:d.jsx(Fr,{type:"menu",sourceId:"help-menu",children:o})})]})})});const Jpe=1,ege=Pe({schemaVersion:mn(1),storeVersion:lf,recordVersions:Ep(ye,Pe({version:lf,subTypeVersions:Ep(ye,lf).optional(),subTypeKey:ye.optional()}))}),tge=Pe({schemaVersion:mn(2),sequences:Ep(ye,lf)}),nge=Pe({tldrawFileFormatVersion:rY,schema:sY("schemaVersion",{1:ege,2:tge}),records:Wt(Pe({id:ye,typeName:ye}).allowUnknownProperties())});function rge(t){var e;try{return!!((e=t.document)!=null&&e.version)}catch{return!1}}function sge({json:t,schema:e}){let n;try{n=nge.validate(JSON.parse(t))}catch(o){try{if(n=JSON.parse(t),rge(n))return wn.err({type:"v1File",data:n})}catch{}return wn.err({type:"notATldrawFile",cause:o})}if(n.tldrawFileFormatVersion>Jpe)return wn.err({type:"fileFormatVersionTooNew",version:n.tldrawFileFormatVersion});let r,s;try{const o=oge(n.records);s=Object.fromEntries(o.map(i=>[i.id,i])),r=e.migrateStoreSnapshot({store:s,schema:n.schema})}catch(o){return wn.err({type:"invalidRecords",cause:o})}if(r.type==="error")return wn.err({type:"migrationFailed",reason:r.reason});try{return wn.ok(Hu({snapshot:{store:s,schema:n.schema},schema:e}))}catch(o){return wn.err({type:"invalidRecords",cause:o})}}function oge(t){const e=new Set;for(const n of t)n.typeName==="shape"&&"assetId"in n.props&&n.props.assetId&&e.add(n.props.assetId);return t.filter(n=>n.typeName!=="asset"||e.has(n.id))}_i("tldraw","3.7.2","esm");function ige(){const[t,e]=w.useState();function n(r){window.editor=r,t===void 0?fetch("/tldr-data").then(async s=>{if(!s.ok){console.log(`No tldr data to load from local endpoint (${s.status})`);return}return s.text()}).then(s=>{if(s===void 0)return;const o=sge({json:s,schema:r.store.schema});o.ok?(console.log("Loaded tldr file from local endpoint"),e(o.value)):console.error(`Couldn't parse tldr file: ${String(o.error.type)}`)}).catch(s=>{console.error("Couldn't fetch data:",s)}):(r.zoomToFit(),r.clearOpenMenus())}return d.jsx("div",{style:{inset:0,position:"fixed"},children:d.jsx(Zpe,{assetUrls:h8(),onMount:n,store:t})})}QS.createRoot(document.querySelector("#root")).render(d.jsx(ke.StrictMode,{children:d.jsx(ige,{})}));
|