@kitschpatrol/tldraw-cli 4.6.37 → 4.6.39
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 +22875 -21466
- package/dist/lib/index.js +23042 -21637
- package/dist/tldraw/assets/index-C9HKHz4q.js +525 -0
- package/dist/tldraw/assets/index-CKbYE9L-.css +1 -0
- package/dist/tldraw/assets/inter-cyrillic-500-normal-BoeW9iIj.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-700-normal-oWiwobpV.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-ext-500-normal-NrhEyngK.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-ext-700-normal-Cg0zx2i8.woff +0 -0
- package/dist/tldraw/assets/inter-greek-500-normal-CSBZZ4CI.woff +0 -0
- package/dist/tldraw/assets/{inter-greek-700-normal-BRYTaFLL.woff → inter-greek-700-normal-DtGkhywV.woff} +0 -0
- package/dist/tldraw/assets/{inter-greek-ext-500-normal-M2hEX8vc.woff → inter-greek-ext-500-normal-1SJLBQ3N.woff} +0 -0
- package/dist/tldraw/assets/{inter-greek-ext-700-normal-DXvzx4Na.woff → inter-greek-ext-700-normal-D0KHSs-V.woff} +0 -0
- package/dist/tldraw/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
- package/dist/tldraw/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-700-normal-Drs_5D37.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-700-normal-KTwiWvO9.woff +0 -0
- package/dist/tldraw/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
- package/dist/tldraw/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-ext-700-normal-CfWAu3Qq.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-ext-700-normal-Z3s-4e5M.woff +0 -0
- package/dist/tldraw/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
- package/dist/tldraw/assets/inter-vietnamese-700-normal-DL6eWghQ.woff +0 -0
- package/dist/tldraw/icons/icon/0_merged.svg +1 -1
- package/dist/tldraw/icons/icon/arrow-arc.svg +1 -0
- package/dist/tldraw/icons/icon/arrow-elbow.svg +1 -0
- package/dist/tldraw/icons/icon/bookmark.svg +1 -0
- package/dist/tldraw/icons/icon/comment.svg +1 -0
- package/dist/tldraw/icons/icon/help-circle.svg +1 -0
- package/dist/tldraw/icons/icon/icon-names.json +6 -0
- package/dist/tldraw/icons/icon/manual.svg +1 -0
- package/dist/tldraw/icons/icon/question-mark-circle.svg +1 -1
- package/dist/tldraw/index.html +2 -2
- package/dist/tldraw/translations/ar.json +4 -0
- package/dist/tldraw/translations/ca.json +3 -0
- package/dist/tldraw/translations/cs.json +3 -0
- package/dist/tldraw/translations/da.json +3 -0
- package/dist/tldraw/translations/de.json +4 -0
- package/dist/tldraw/translations/es.json +4 -0
- package/dist/tldraw/translations/fa.json +3 -0
- package/dist/tldraw/translations/fi.json +3 -0
- package/dist/tldraw/translations/fr.json +5 -0
- package/dist/tldraw/translations/he.json +4 -0
- package/dist/tldraw/translations/hi-in.json +4 -0
- package/dist/tldraw/translations/hr.json +3 -0
- package/dist/tldraw/translations/hu.json +3 -0
- package/dist/tldraw/translations/id.json +3 -0
- package/dist/tldraw/translations/it.json +5 -0
- package/dist/tldraw/translations/ja.json +4 -0
- package/dist/tldraw/translations/ko-kr.json +55 -3
- package/dist/tldraw/translations/main.json +44 -1
- package/dist/tldraw/translations/ne.json +3 -0
- package/dist/tldraw/translations/no.json +1 -0
- package/dist/tldraw/translations/pl.json +3 -0
- package/dist/tldraw/translations/pt-br.json +4 -0
- package/dist/tldraw/translations/pt-pt.json +4 -0
- package/dist/tldraw/translations/ro.json +3 -0
- package/dist/tldraw/translations/ru.json +4 -0
- package/dist/tldraw/translations/sl.json +3 -0
- package/dist/tldraw/translations/so.json +3 -0
- package/dist/tldraw/translations/sv.json +3 -0
- package/dist/tldraw/translations/te.json +2 -0
- package/dist/tldraw/translations/th.json +4 -0
- package/dist/tldraw/translations/tr.json +4 -0
- package/dist/tldraw/translations/uk.json +3 -0
- package/dist/tldraw/translations/vi.json +4 -0
- package/dist/tldraw/translations/zh-cn.json +5 -0
- package/dist/tldraw/translations/zh-tw.json +6 -2
- package/package.json +17 -17
- package/dist/tldraw/assets/index-CdKDmGuJ.js +0 -521
- package/dist/tldraw/assets/index-DrMsN_Ol.css +0 -1
- package/dist/tldraw/assets/inter-cyrillic-500-normal-DH2hs3aW.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-700-normal-Bc8_fv8J.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-ext-500-normal-CUiC4oBV.woff +0 -0
- package/dist/tldraw/assets/inter-cyrillic-ext-700-normal-Ced3hgUT.woff +0 -0
- package/dist/tldraw/assets/inter-greek-500-normal-d_eO-yCQ.woff +0 -0
- package/dist/tldraw/assets/inter-latin-500-normal-D2bGa7uu.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-500-normal-deR1Tlfd.woff +0 -0
- package/dist/tldraw/assets/inter-latin-700-normal-B8MtJ_2k.woff +0 -0
- package/dist/tldraw/assets/inter-latin-700-normal-Sckx8rpT.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-ext-500-normal-CIS2RHJS.woff2 +0 -0
- package/dist/tldraw/assets/inter-latin-ext-500-normal-UMdmhHu2.woff +0 -0
- package/dist/tldraw/assets/inter-latin-ext-700-normal-6V9MnIL5.woff +0 -0
- package/dist/tldraw/assets/inter-latin-ext-700-normal-CzikT_rs.woff2 +0 -0
- package/dist/tldraw/assets/inter-vietnamese-500-normal-DQPw2Hwd.woff +0 -0
- package/dist/tldraw/assets/inter-vietnamese-700-normal-dAnkLlTo.woff +0 -0
|
@@ -1,521 +0,0 @@
|
|
|
1
|
-
var aV=Object.defineProperty;var lV=(n,e,t)=>e in n?aV(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var R=(n,e,t)=>lV(n,typeof e!="symbol"?e+"":e,t);function cV(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,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 i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();var Ps=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ua(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ew={exports:{}},Qh={},_w={exports:{}},gt={};/**
|
|
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 XM;function uV(){if(XM)return gt;XM=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),h=Symbol.iterator;function p(B){return B===null||typeof B!="object"?null:(B=h&&B[h]||B["@@iterator"],typeof B=="function"?B:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,x={};function v(B,Q,me){this.props=B,this.context=Q,this.refs=x,this.updater=me||m}v.prototype.isReactComponent={},v.prototype.setState=function(B,Q){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,Q,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function w(){}w.prototype=v.prototype;function C(B,Q,me){this.props=B,this.context=Q,this.refs=x,this.updater=me||m}var _=C.prototype=new w;_.constructor=C,S(_,v.prototype),_.isPureReactComponent=!0;var E=Array.isArray,T=Object.prototype.hasOwnProperty,A={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function D(B,Q,me){var Pe,ue={},Oe=null,Ne=null;if(Q!=null)for(Pe in Q.ref!==void 0&&(Ne=Q.ref),Q.key!==void 0&&(Oe=""+Q.key),Q)T.call(Q,Pe)&&!O.hasOwnProperty(Pe)&&(ue[Pe]=Q[Pe]);var be=arguments.length-2;if(be===1)ue.children=me;else if(1<be){for(var Ee=Array(be),Ke=0;Ke<be;Ke++)Ee[Ke]=arguments[Ke+2];ue.children=Ee}if(B&&B.defaultProps)for(Pe in be=B.defaultProps,be)ue[Pe]===void 0&&(ue[Pe]=be[Pe]);return{$$typeof:n,type:B,key:Oe,ref:Ne,props:ue,_owner:A.current}}function $(B,Q){return{$$typeof:n,type:B.type,key:Q,ref:B.ref,props:B.props,_owner:B._owner}}function H(B){return typeof B=="object"&&B!==null&&B.$$typeof===n}function G(B){var Q={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(me){return Q[me]})}var J=/\/+/g;function L(B,Q){return typeof B=="object"&&B!==null&&B.key!=null?G(""+B.key):Q.toString(36)}function N(B,Q,me,Pe,ue){var Oe=typeof B;(Oe==="undefined"||Oe==="boolean")&&(B=null);var Ne=!1;if(B===null)Ne=!0;else switch(Oe){case"string":case"number":Ne=!0;break;case"object":switch(B.$$typeof){case n:case e:Ne=!0}}if(Ne)return Ne=B,ue=ue(Ne),B=Pe===""?"."+L(Ne,0):Pe,E(ue)?(me="",B!=null&&(me=B.replace(J,"$&/")+"/"),N(ue,Q,me,"",function(Ke){return Ke})):ue!=null&&(H(ue)&&(ue=$(ue,me+(!ue.key||Ne&&Ne.key===ue.key?"":(""+ue.key).replace(J,"$&/")+"/")+B)),Q.push(ue)),1;if(Ne=0,Pe=Pe===""?".":Pe+":",E(B))for(var be=0;be<B.length;be++){Oe=B[be];var Ee=Pe+L(Oe,be);Ne+=N(Oe,Q,me,Ee,ue)}else if(Ee=p(B),typeof Ee=="function")for(B=Ee.call(B),be=0;!(Oe=B.next()).done;)Oe=Oe.value,Ee=Pe+L(Oe,be++),Ne+=N(Oe,Q,me,Ee,ue);else if(Oe==="object")throw Q=String(B),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return Ne}function U(B,Q,me){if(B==null)return B;var Pe=[],ue=0;return N(B,Pe,"","",function(Oe){return Q.call(me,Oe,ue++)}),Pe}function Y(B){if(B._status===-1){var Q=B._result;Q=Q(),Q.then(function(me){(B._status===0||B._status===-1)&&(B._status=1,B._result=me)},function(me){(B._status===0||B._status===-1)&&(B._status=2,B._result=me)}),B._status===-1&&(B._status=0,B._result=Q)}if(B._status===1)return B._result.default;throw B._result}var W={current:null},z={transition:null},V={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:z,ReactCurrentOwner:A};function ee(){throw Error("act(...) is not supported in production builds of React.")}return gt.Children={map:U,forEach:function(B,Q,me){U(B,function(){Q.apply(this,arguments)},me)},count:function(B){var Q=0;return U(B,function(){Q++}),Q},toArray:function(B){return U(B,function(Q){return Q})||[]},only:function(B){if(!H(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},gt.Component=v,gt.Fragment=t,gt.Profiler=s,gt.PureComponent=C,gt.StrictMode=r,gt.Suspense=l,gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,gt.act=ee,gt.cloneElement=function(B,Q,me){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var Pe=S({},B.props),ue=B.key,Oe=B.ref,Ne=B._owner;if(Q!=null){if(Q.ref!==void 0&&(Oe=Q.ref,Ne=A.current),Q.key!==void 0&&(ue=""+Q.key),B.type&&B.type.defaultProps)var be=B.type.defaultProps;for(Ee in Q)T.call(Q,Ee)&&!O.hasOwnProperty(Ee)&&(Pe[Ee]=Q[Ee]===void 0&&be!==void 0?be[Ee]:Q[Ee])}var Ee=arguments.length-2;if(Ee===1)Pe.children=me;else if(1<Ee){be=Array(Ee);for(var Ke=0;Ke<Ee;Ke++)be[Ke]=arguments[Ke+2];Pe.children=be}return{$$typeof:n,type:B.type,key:ue,ref:Oe,props:Pe,_owner:Ne}},gt.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:i,_context:B},B.Consumer=B},gt.createElement=D,gt.createFactory=function(B){var Q=D.bind(null,B);return Q.type=B,Q},gt.createRef=function(){return{current:null}},gt.forwardRef=function(B){return{$$typeof:a,render:B}},gt.isValidElement=H,gt.lazy=function(B){return{$$typeof:u,_payload:{_status:-1,_result:B},_init:Y}},gt.memo=function(B,Q){return{$$typeof:c,type:B,compare:Q===void 0?null:Q}},gt.startTransition=function(B){var Q=z.transition;z.transition={};try{B()}finally{z.transition=Q}},gt.unstable_act=ee,gt.useCallback=function(B,Q){return W.current.useCallback(B,Q)},gt.useContext=function(B){return W.current.useContext(B)},gt.useDebugValue=function(){},gt.useDeferredValue=function(B){return W.current.useDeferredValue(B)},gt.useEffect=function(B,Q){return W.current.useEffect(B,Q)},gt.useId=function(){return W.current.useId()},gt.useImperativeHandle=function(B,Q,me){return W.current.useImperativeHandle(B,Q,me)},gt.useInsertionEffect=function(B,Q){return W.current.useInsertionEffect(B,Q)},gt.useLayoutEffect=function(B,Q){return W.current.useLayoutEffect(B,Q)},gt.useMemo=function(B,Q){return W.current.useMemo(B,Q)},gt.useReducer=function(B,Q,me){return W.current.useReducer(B,Q,me)},gt.useRef=function(B){return W.current.useRef(B)},gt.useState=function(B){return W.current.useState(B)},gt.useSyncExternalStore=function(B,Q,me){return W.current.useSyncExternalStore(B,Q,me)},gt.useTransition=function(){return W.current.useTransition()},gt.version="18.3.1",gt}var ZM;function vI(){return ZM||(ZM=1,_w.exports=uV()),_w.exports}/**
|
|
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 JM;function dV(){if(JM)return Qh;JM=1;var n=vI(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(a,l,c){var u,h={},p=null,m=null;c!==void 0&&(p=""+c),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(m=l.ref);for(u in l)r.call(l,u)&&!i.hasOwnProperty(u)&&(h[u]=l[u]);if(a&&a.defaultProps)for(u in l=a.defaultProps,l)h[u]===void 0&&(h[u]=l[u]);return{$$typeof:e,type:a,key:p,ref:m,props:h,_owner:s.current}}return Qh.Fragment=t,Qh.jsx=o,Qh.jsxs=o,Qh}var QM;function hV(){return QM||(QM=1,Ew.exports=dV()),Ew.exports}var g=hV(),P=vI();const at=Ua(P),HN=cV({__proto__:null,default:at},[P]);var vm={},Tw={exports:{}},ys={},Mw={exports:{}},Aw={};/**
|
|
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
|
-
*/var eA;function fV(){return eA||(eA=1,function(n){function e(z,V){var ee=z.length;z.push(V);e:for(;0<ee;){var B=ee-1>>>1,Q=z[B];if(0<s(Q,V))z[B]=V,z[ee]=Q,ee=B;else break e}}function t(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var V=z[0],ee=z.pop();if(ee!==V){z[0]=ee;e:for(var B=0,Q=z.length,me=Q>>>1;B<me;){var Pe=2*(B+1)-1,ue=z[Pe],Oe=Pe+1,Ne=z[Oe];if(0>s(ue,ee))Oe<Q&&0>s(Ne,ue)?(z[B]=Ne,z[Oe]=ee,B=Oe):(z[B]=ue,z[Pe]=ee,B=Pe);else if(Oe<Q&&0>s(Ne,ee))z[B]=Ne,z[Oe]=ee,B=Oe;else break e}}return V}function s(z,V){var ee=z.sortIndex-V.sortIndex;return ee!==0?ee:z.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;n.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,p=3,m=!1,S=!1,x=!1,v=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(z){for(var V=t(c);V!==null;){if(V.callback===null)r(c);else if(V.startTime<=z)r(c),V.sortIndex=V.expirationTime,e(l,V);else break;V=t(c)}}function E(z){if(x=!1,_(z),!S)if(t(l)!==null)S=!0,Y(T);else{var V=t(c);V!==null&&W(E,V.startTime-z)}}function T(z,V){S=!1,x&&(x=!1,w(D),D=-1),m=!0;var ee=p;try{for(_(V),h=t(l);h!==null&&(!(h.expirationTime>V)||z&&!G());){var B=h.callback;if(typeof B=="function"){h.callback=null,p=h.priorityLevel;var Q=B(h.expirationTime<=V);V=n.unstable_now(),typeof Q=="function"?h.callback=Q:h===t(l)&&r(l),_(V)}else r(l);h=t(l)}if(h!==null)var me=!0;else{var Pe=t(c);Pe!==null&&W(E,Pe.startTime-V),me=!1}return me}finally{h=null,p=ee,m=!1}}var A=!1,O=null,D=-1,$=5,H=-1;function G(){return!(n.unstable_now()-H<$)}function J(){if(O!==null){var z=n.unstable_now();H=z;var V=!0;try{V=O(!0,z)}finally{V?L():(A=!1,O=null)}}else A=!1}var L;if(typeof C=="function")L=function(){C(J)};else if(typeof MessageChannel<"u"){var N=new MessageChannel,U=N.port2;N.port1.onmessage=J,L=function(){U.postMessage(null)}}else L=function(){v(J,0)};function Y(z){O=z,A||(A=!0,L())}function W(z,V){D=v(function(){z(n.unstable_now())},V)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(z){z.callback=null},n.unstable_continueExecution=function(){S||m||(S=!0,Y(T))},n.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<z?Math.floor(1e3/z):5},n.unstable_getCurrentPriorityLevel=function(){return p},n.unstable_getFirstCallbackNode=function(){return t(l)},n.unstable_next=function(z){switch(p){case 1:case 2:case 3:var V=3;break;default:V=p}var ee=p;p=V;try{return z()}finally{p=ee}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(z,V){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var ee=p;p=z;try{return V()}finally{p=ee}},n.unstable_scheduleCallback=function(z,V,ee){var B=n.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?B+ee:B):ee=B,z){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=ee+Q,z={id:u++,callback:V,priorityLevel:z,startTime:ee,expirationTime:Q,sortIndex:-1},ee>B?(z.sortIndex=ee,e(c,z),t(l)===null&&z===t(c)&&(x?(w(D),D=-1):x=!0,W(E,ee-B))):(z.sortIndex=Q,e(l,z),S||m||(S=!0,Y(T))),z},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(z){var V=p;return function(){var ee=p;p=V;try{return z.apply(this,arguments)}finally{p=ee}}}}(Aw)),Aw}var tA;function pV(){return tA||(tA=1,Mw.exports=fV()),Mw.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 nA;function gV(){if(nA)return ys;nA=1;var n=vI(),e=pV();function t(d){for(var f="https://reactjs.org/docs/error-decoder.html?invariant="+d,y=1;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y]);return"Minified React error #"+d+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(d,f){o(d,f),o(d+"Capture",f)}function o(d,f){for(s[d]=f,d=0;d<f.length;d++)r.add(f[d])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),l=Object.prototype.hasOwnProperty,c=/^[: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]*$/,u={},h={};function p(d){return l.call(h,d)?!0:l.call(u,d)?!1:c.test(d)?h[d]=!0:(u[d]=!0,!1)}function m(d,f,y,b){if(y!==null&&y.type===0)return!1;switch(typeof f){case"function":case"symbol":return!0;case"boolean":return b?!1:y!==null?!y.acceptsBooleans:(d=d.toLowerCase().slice(0,5),d!=="data-"&&d!=="aria-");default:return!1}}function S(d,f,y,b){if(f===null||typeof f>"u"||m(d,f,y,b))return!0;if(b)return!1;if(y!==null)switch(y.type){case 3:return!f;case 4:return f===!1;case 5:return isNaN(f);case 6:return isNaN(f)||1>f}return!1}function x(d,f,y,b,I,M,j){this.acceptsBooleans=f===2||f===3||f===4,this.attributeName=b,this.attributeNamespace=I,this.mustUseProperty=y,this.propertyName=d,this.type=f,this.sanitizeURL=M,this.removeEmptyString=j}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(d){v[d]=new x(d,0,!1,d,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(d){var f=d[0];v[f]=new x(f,1,!1,d[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(d){v[d]=new x(d,2,!1,d.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(d){v[d]=new x(d,2,!1,d,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(d){v[d]=new x(d,3,!1,d.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(d){v[d]=new x(d,3,!0,d,null,!1,!1)}),["capture","download"].forEach(function(d){v[d]=new x(d,4,!1,d,null,!1,!1)}),["cols","rows","size","span"].forEach(function(d){v[d]=new x(d,6,!1,d,null,!1,!1)}),["rowSpan","start"].forEach(function(d){v[d]=new x(d,5,!1,d.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function C(d){return d[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(d){var f=d.replace(w,C);v[f]=new x(f,1,!1,d,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(d){var f=d.replace(w,C);v[f]=new x(f,1,!1,d,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(d){var f=d.replace(w,C);v[f]=new x(f,1,!1,d,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(d){v[d]=new x(d,1,!1,d.toLowerCase(),null,!1,!1)}),v.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(d){v[d]=new x(d,1,!1,d.toLowerCase(),null,!0,!0)});function _(d,f,y,b){var I=v.hasOwnProperty(f)?v[f]:null;(I!==null?I.type!==0:b||!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(S(f,y,I,b)&&(y=null),b||I===null?p(f)&&(y===null?d.removeAttribute(f):d.setAttribute(f,""+y)):I.mustUseProperty?d[I.propertyName]=y===null?I.type===3?!1:"":y:(f=I.attributeName,b=I.attributeNamespace,y===null?d.removeAttribute(f):(I=I.type,y=I===3||I===4&&y===!0?"":""+y,b?d.setAttributeNS(b,f,y):d.setAttribute(f,y))))}var E=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),A=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),H=Symbol.for("react.provider"),G=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),z=Symbol.iterator;function V(d){return d===null||typeof d!="object"?null:(d=z&&d[z]||d["@@iterator"],typeof d=="function"?d:null)}var ee=Object.assign,B;function Q(d){if(B===void 0)try{throw Error()}catch(y){var f=y.stack.trim().match(/\n( *(at )?)/);B=f&&f[1]||""}return`
|
|
34
|
-
`+B+d}var me=!1;function Pe(d,f){if(!d||me)return"";me=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(f)if(f=function(){throw Error()},Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(oe){var b=oe}Reflect.construct(d,[],f)}else{try{f.call()}catch(oe){b=oe}d.call(f.prototype)}else{try{throw Error()}catch(oe){b=oe}d()}}catch(oe){if(oe&&b&&typeof oe.stack=="string"){for(var I=oe.stack.split(`
|
|
35
|
-
`),M=b.stack.split(`
|
|
36
|
-
`),j=I.length-1,K=M.length-1;1<=j&&0<=K&&I[j]!==M[K];)K--;for(;1<=j&&0<=K;j--,K--)if(I[j]!==M[K]){if(j!==1||K!==1)do if(j--,K--,0>K||I[j]!==M[K]){var q=`
|
|
37
|
-
`+I[j].replace(" at new "," at ");return d.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",d.displayName)),q}while(1<=j&&0<=K);break}}}finally{me=!1,Error.prepareStackTrace=y}return(d=d?d.displayName||d.name:"")?Q(d):""}function ue(d){switch(d.tag){case 5:return Q(d.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return d=Pe(d.type,!1),d;case 11:return d=Pe(d.type.render,!1),d;case 1:return d=Pe(d.type,!0),d;default:return""}}function Oe(d){if(d==null)return null;if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case O:return"Fragment";case A:return"Portal";case $:return"Profiler";case D:return"StrictMode";case L:return"Suspense";case N:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case G:return(d.displayName||"Context")+".Consumer";case H:return(d._context.displayName||"Context")+".Provider";case J:var f=d.render;return d=d.displayName,d||(d=f.displayName||f.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case U:return f=d.displayName||null,f!==null?f:Oe(d.type)||"Memo";case Y:f=d._payload,d=d._init;try{return Oe(d(f))}catch{}}return null}function Ne(d){var f=d.type;switch(d.tag){case 24:return"Cache";case 9:return(f.displayName||"Context")+".Consumer";case 10:return(f._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return d=f.render,d=d.displayName||d.name||"",f.displayName||(d!==""?"ForwardRef("+d+")":"ForwardRef");case 7:return"Fragment";case 5:return f;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Oe(f);case 8:return f===D?"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 f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f}return null}function be(d){switch(typeof d){case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function Ee(d){var f=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function Ke(d){var f=Ee(d)?"checked":"value",y=Object.getOwnPropertyDescriptor(d.constructor.prototype,f),b=""+d[f];if(!d.hasOwnProperty(f)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var I=y.get,M=y.set;return Object.defineProperty(d,f,{configurable:!0,get:function(){return I.call(this)},set:function(j){b=""+j,M.call(this,j)}}),Object.defineProperty(d,f,{enumerable:y.enumerable}),{getValue:function(){return b},setValue:function(j){b=""+j},stopTracking:function(){d._valueTracker=null,delete d[f]}}}}function Lt(d){d._valueTracker||(d._valueTracker=Ke(d))}function Jt(d){if(!d)return!1;var f=d._valueTracker;if(!f)return!0;var y=f.getValue(),b="";return d&&(b=Ee(d)?d.checked?"true":"false":d.value),d=b,d!==y?(f.setValue(d),!0):!1}function Et(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}function Tt(d,f){var y=f.checked;return ee({},f,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??d._wrapperState.initialChecked})}function nn(d,f){var y=f.defaultValue==null?"":f.defaultValue,b=f.checked!=null?f.checked:f.defaultChecked;y=be(f.value!=null?f.value:y),d._wrapperState={initialChecked:b,initialValue:y,controlled:f.type==="checkbox"||f.type==="radio"?f.checked!=null:f.value!=null}}function In(d,f){f=f.checked,f!=null&&_(d,"checked",f,!1)}function rs(d,f){In(d,f);var y=be(f.value),b=f.type;if(y!=null)b==="number"?(y===0&&d.value===""||d.value!=y)&&(d.value=""+y):d.value!==""+y&&(d.value=""+y);else if(b==="submit"||b==="reset"){d.removeAttribute("value");return}f.hasOwnProperty("value")?is(d,f.type,y):f.hasOwnProperty("defaultValue")&&is(d,f.type,be(f.defaultValue)),f.checked==null&&f.defaultChecked!=null&&(d.defaultChecked=!!f.defaultChecked)}function ss(d,f,y){if(f.hasOwnProperty("value")||f.hasOwnProperty("defaultValue")){var b=f.type;if(!(b!=="submit"&&b!=="reset"||f.value!==void 0&&f.value!==null))return;f=""+d._wrapperState.initialValue,y||f===d.value||(d.value=f),d.defaultValue=f}y=d.name,y!==""&&(d.name=""),d.defaultChecked=!!d._wrapperState.initialChecked,y!==""&&(d.name=y)}function is(d,f,y){(f!=="number"||Et(d.ownerDocument)!==d)&&(y==null?d.defaultValue=""+d._wrapperState.initialValue:d.defaultValue!==""+y&&(d.defaultValue=""+y))}var as=Array.isArray;function ri(d,f,y,b){if(d=d.options,f){f={};for(var I=0;I<y.length;I++)f["$"+y[I]]=!0;for(y=0;y<d.length;y++)I=f.hasOwnProperty("$"+d[y].value),d[y].selected!==I&&(d[y].selected=I),I&&b&&(d[y].defaultSelected=!0)}else{for(y=""+be(y),f=null,I=0;I<d.length;I++){if(d[I].value===y){d[I].selected=!0,b&&(d[I].defaultSelected=!0);return}f!==null||d[I].disabled||(f=d[I])}f!==null&&(f.selected=!0)}}function lc(d,f){if(f.dangerouslySetInnerHTML!=null)throw Error(t(91));return ee({},f,{value:void 0,defaultValue:void 0,children:""+d._wrapperState.initialValue})}function Cu(d,f){var y=f.value;if(y==null){if(y=f.children,f=f.defaultValue,y!=null){if(f!=null)throw Error(t(92));if(as(y)){if(1<y.length)throw Error(t(93));y=y[0]}f=y}f==null&&(f=""),y=f}d._wrapperState={initialValue:be(y)}}function Pu(d,f){var y=be(f.value),b=be(f.defaultValue);y!=null&&(y=""+y,y!==d.value&&(d.value=y),f.defaultValue==null&&d.defaultValue!==y&&(d.defaultValue=y)),b!=null&&(d.defaultValue=""+b)}function ku(d){var f=d.textContent;f===d._wrapperState.initialValue&&f!==""&&f!==null&&(d.value=f)}function Iu(d){switch(d){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 ho(d,f){return d==null||d==="http://www.w3.org/1999/xhtml"?Iu(f):d==="http://www.w3.org/2000/svg"&&f==="foreignObject"?"http://www.w3.org/1999/xhtml":d}var Oi,cc=function(d){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(f,y,b,I){MSApp.execUnsafeLocalFunction(function(){return d(f,y,b,I)})}:d}(function(d,f){if(d.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in d)d.innerHTML=f;else{for(Oi=Oi||document.createElement("div"),Oi.innerHTML="<svg>"+f.valueOf().toString()+"</svg>",f=Oi.firstChild;d.firstChild;)d.removeChild(d.firstChild);for(;f.firstChild;)d.appendChild(f.firstChild)}});function ae(d,f){if(f){var y=d.firstChild;if(y&&y===d.lastChild&&y.nodeType===3){y.nodeValue=f;return}}d.textContent=f}var Ce={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},Ye=["Webkit","ms","Moz","O"];Object.keys(Ce).forEach(function(d){Ye.forEach(function(f){f=f+d.charAt(0).toUpperCase()+d.substring(1),Ce[f]=Ce[d]})});function At(d,f,y){return f==null||typeof f=="boolean"||f===""?"":y||typeof f!="number"||f===0||Ce.hasOwnProperty(d)&&Ce[d]?(""+f).trim():f+"px"}function si(d,f){d=d.style;for(var y in f)if(f.hasOwnProperty(y)){var b=y.indexOf("--")===0,I=At(y,f[y],b);y==="float"&&(y="cssFloat"),b?d.setProperty(y,I):d[y]=I}}var ls=ee({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 Qo(d,f){if(f){if(ls[d]&&(f.children!=null||f.dangerouslySetInnerHTML!=null))throw Error(t(137,d));if(f.dangerouslySetInnerHTML!=null){if(f.children!=null)throw Error(t(60));if(typeof f.dangerouslySetInnerHTML!="object"||!("__html"in f.dangerouslySetInnerHTML))throw Error(t(61))}if(f.style!=null&&typeof f.style!="object")throw Error(t(62))}}function Os(d,f){if(d.indexOf("-")===-1)return typeof f.is=="string";switch(d){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 Rs=null;function cs(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var Ds=null,us=null,Ri=null;function Eu(d){if(d=Fh(d)){if(typeof Ds!="function")throw Error(t(280));var f=d.stateNode;f&&(f=Dg(f),Ds(d.stateNode,d.type,f))}}function Ja(d){us?Ri?Ri.push(d):Ri=[d]:us=d}function _u(){if(us){var d=us,f=Ri;if(Ri=us=null,Eu(d),f)for(d=0;d<f.length;d++)Eu(f[d])}}function Tu(d,f){return d(f)}function Mu(){}var ea=!1;function gg(d,f,y){if(ea)return d(f,y);ea=!0;try{return Tu(d,f,y)}finally{ea=!1,(us!==null||Ri!==null)&&(Mu(),_u())}}function uc(d,f){var y=d.stateNode;if(y===null)return null;var b=Dg(y);if(b===null)return null;y=b[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(d=d.type,b=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!b;break e;default:d=!1}if(d)return null;if(y&&typeof y!="function")throw Error(t(231,f,typeof y));return y}var vh=!1;if(a)try{var dc={};Object.defineProperty(dc,"passive",{get:function(){vh=!0}}),window.addEventListener("test",dc,dc),window.removeEventListener("test",dc,dc)}catch{vh=!1}function Uv(d,f,y,b,I,M,j,K,q){var oe=Array.prototype.slice.call(arguments,3);try{f.apply(y,oe)}catch(pe){this.onError(pe)}}var Qa=!1,el=null,ii=!1,xh=null,Hv={onError:function(d){Qa=!0,el=d}};function Kv(d,f,y,b,I,M,j,K,q){Qa=!1,el=null,Uv.apply(Hv,arguments)}function Wv(d,f,y,b,I,M,j,K,q){if(Kv.apply(this,arguments),Qa){if(Qa){var oe=el;Qa=!1,el=null}else throw Error(t(198));ii||(ii=!0,xh=oe)}}function ta(d){var f=d,y=d;if(d.alternate)for(;f.return;)f=f.return;else{d=f;do f=d,(f.flags&4098)!==0&&(y=f.return),d=f.return;while(d)}return f.tag===3?y:null}function oi(d){if(d.tag===13){var f=d.memoizedState;if(f===null&&(d=d.alternate,d!==null&&(f=d.memoizedState)),f!==null)return f.dehydrated}return null}function mg(d){if(ta(d)!==d)throw Error(t(188))}function Vv(d){var f=d.alternate;if(!f){if(f=ta(d),f===null)throw Error(t(188));return f!==d?null:d}for(var y=d,b=f;;){var I=y.return;if(I===null)break;var M=I.alternate;if(M===null){if(b=I.return,b!==null){y=b;continue}break}if(I.child===M.child){for(M=I.child;M;){if(M===y)return mg(I),d;if(M===b)return mg(I),f;M=M.sibling}throw Error(t(188))}if(y.return!==b.return)y=I,b=M;else{for(var j=!1,K=I.child;K;){if(K===y){j=!0,y=I,b=M;break}if(K===b){j=!0,b=I,y=M;break}K=K.sibling}if(!j){for(K=M.child;K;){if(K===y){j=!0,y=M,b=I;break}if(K===b){j=!0,b=M,y=I;break}K=K.sibling}if(!j)throw Error(t(189))}}if(y.alternate!==b)throw Error(t(190))}if(y.tag!==3)throw Error(t(188));return y.stateNode.current===y?d:f}function yg(d){return d=Vv(d),d!==null?Sg(d):null}function Sg(d){if(d.tag===5||d.tag===6)return d;for(d=d.child;d!==null;){var f=Sg(d);if(f!==null)return f;d=d.sibling}return null}var vg=e.unstable_scheduleCallback,fo=e.unstable_cancelCallback,qv=e.unstable_shouldYield,Gv=e.unstable_requestPaint,rn=e.unstable_now,Yv=e.unstable_getCurrentPriorityLevel,wh=e.unstable_ImmediatePriority,hc=e.unstable_UserBlockingPriority,Au=e.unstable_NormalPriority,Xv=e.unstable_LowPriority,Di=e.unstable_IdlePriority,Ou=null,ai=null;function Zv(d){if(ai&&typeof ai.onCommitFiberRoot=="function")try{ai.onCommitFiberRoot(Ou,d,void 0,(d.current.flags&128)===128)}catch{}}var js=Math.clz32?Math.clz32:Ru,Jv=Math.log,Qv=Math.LN2;function Ru(d){return d>>>=0,d===0?32:31-(Jv(d)/Qv|0)|0}var Du=64,po=4194304;function tl(d){switch(d&-d){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 d&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return d&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return d}}function fc(d,f){var y=d.pendingLanes;if(y===0)return 0;var b=0,I=d.suspendedLanes,M=d.pingedLanes,j=y&268435455;if(j!==0){var K=j&~I;K!==0?b=tl(K):(M&=j,M!==0&&(b=tl(M)))}else j=y&~I,j!==0?b=tl(j):M!==0&&(b=tl(M));if(b===0)return 0;if(f!==0&&f!==b&&(f&I)===0&&(I=b&-b,M=f&-f,I>=M||I===16&&(M&4194240)!==0))return f;if((b&4)!==0&&(b|=y&16),f=d.entangledLanes,f!==0)for(d=d.entanglements,f&=b;0<f;)y=31-js(f),I=1<<y,b|=d[y],f&=~I;return b}function ex(d,f){switch(d){case 1:case 2:case 4:return f+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 f+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 tx(d,f){for(var y=d.suspendedLanes,b=d.pingedLanes,I=d.expirationTimes,M=d.pendingLanes;0<M;){var j=31-js(M),K=1<<j,q=I[j];q===-1?((K&y)===0||(K&b)!==0)&&(I[j]=ex(K,f)):q<=f&&(d.expiredLanes|=K),M&=~K}}function bh(d){return d=d.pendingLanes&-1073741825,d!==0?d:d&1073741824?1073741824:0}function xg(){var d=Du;return Du<<=1,(Du&4194240)===0&&(Du=64),d}function ju(d){for(var f=[],y=0;31>y;y++)f.push(d);return f}function pc(d,f,y){d.pendingLanes|=f,f!==536870912&&(d.suspendedLanes=0,d.pingedLanes=0),d=d.eventTimes,f=31-js(f),d[f]=y}function nx(d,f){var y=d.pendingLanes&~f;d.pendingLanes=f,d.suspendedLanes=0,d.pingedLanes=0,d.expiredLanes&=f,d.mutableReadLanes&=f,d.entangledLanes&=f,f=d.entanglements;var b=d.eventTimes;for(d=d.expirationTimes;0<y;){var I=31-js(y),M=1<<I;f[I]=0,b[I]=-1,d[I]=-1,y&=~M}}function Lu(d,f){var y=d.entangledLanes|=f;for(d=d.entanglements;y;){var b=31-js(y),I=1<<b;I&f|d[b]&f&&(d[b]|=f),y&=~I}}var xt=0;function na(d){return d&=-d,1<d?4<d?(d&268435455)!==0?16:536870912:4:1}var wg,Ch,ji,bg,Cg,Ph=!1,Nu=[],go=null,hr=null,Li=null,gc=new Map,mo=new Map,yo=[],kh="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 Pg(d,f){switch(d){case"focusin":case"focusout":go=null;break;case"dragenter":case"dragleave":hr=null;break;case"mouseover":case"mouseout":Li=null;break;case"pointerover":case"pointerout":gc.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":mo.delete(f.pointerId)}}function nl(d,f,y,b,I,M){return d===null||d.nativeEvent!==M?(d={blockedOn:f,domEventName:y,eventSystemFlags:b,nativeEvent:M,targetContainers:[I]},f!==null&&(f=Fh(f),f!==null&&Ch(f)),d):(d.eventSystemFlags|=b,f=d.targetContainers,I!==null&&f.indexOf(I)===-1&&f.push(I),d)}function kg(d,f,y,b,I){switch(f){case"focusin":return go=nl(go,d,f,y,b,I),!0;case"dragenter":return hr=nl(hr,d,f,y,b,I),!0;case"mouseover":return Li=nl(Li,d,f,y,b,I),!0;case"pointerover":var M=I.pointerId;return gc.set(M,nl(gc.get(M)||null,d,f,y,b,I)),!0;case"gotpointercapture":return M=I.pointerId,mo.set(M,nl(mo.get(M)||null,d,f,y,b,I)),!0}return!1}function Ih(d){var f=Sc(d.target);if(f!==null){var y=ta(f);if(y!==null){if(f=y.tag,f===13){if(f=oi(y),f!==null){d.blockedOn=f,Cg(d.priority,function(){ji(y)});return}}else if(f===3&&y.stateNode.current.memoizedState.isDehydrated){d.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}d.blockedOn=null}function So(d){if(d.blockedOn!==null)return!1;for(var f=d.targetContainers;0<f.length;){var y=$t(d.domEventName,d.eventSystemFlags,f[0],d.nativeEvent);if(y===null){y=d.nativeEvent;var b=new y.constructor(y.type,y);Rs=b,y.target.dispatchEvent(b),Rs=null}else return f=Fh(y),f!==null&&Ch(f),d.blockedOn=y,!1;f.shift()}return!0}function Eh(d,f,y){So(d)&&y.delete(f)}function rx(){Ph=!1,go!==null&&So(go)&&(go=null),hr!==null&&So(hr)&&(hr=null),Li!==null&&So(Li)&&(Li=null),gc.forEach(Eh),mo.forEach(Eh)}function mc(d,f){d.blockedOn===f&&(d.blockedOn=null,Ph||(Ph=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rx)))}function yc(d){function f(I){return mc(I,d)}if(0<Nu.length){mc(Nu[0],d);for(var y=1;y<Nu.length;y++){var b=Nu[y];b.blockedOn===d&&(b.blockedOn=null)}}for(go!==null&&mc(go,d),hr!==null&&mc(hr,d),Li!==null&&mc(Li,d),gc.forEach(f),mo.forEach(f),y=0;y<yo.length;y++)b=yo[y],b.blockedOn===d&&(b.blockedOn=null);for(;0<yo.length&&(y=yo[0],y.blockedOn===null);)Ih(y),y.blockedOn===null&&yo.shift()}var F=E.ReactCurrentBatchConfig,Z=!0;function de(d,f,y,b){var I=xt,M=F.transition;F.transition=null;try{xt=1,Mt(d,f,y,b)}finally{xt=I,F.transition=M}}function Ae(d,f,y,b){var I=xt,M=F.transition;F.transition=null;try{xt=4,Mt(d,f,y,b)}finally{xt=I,F.transition=M}}function Mt(d,f,y,b){if(Z){var I=$t(d,f,y,b);if(I===null)yx(d,f,b,et,y),Pg(d,b);else if(kg(I,d,f,y,b))b.stopPropagation();else if(Pg(d,b),f&4&&-1<kh.indexOf(d)){for(;I!==null;){var M=Fh(I);if(M!==null&&wg(M),M=$t(d,f,y,b),M===null&&yx(d,f,b,et,y),M===I)break;I=M}I!==null&&b.stopPropagation()}else yx(d,f,b,null,y)}}var et=null;function $t(d,f,y,b){if(et=null,d=cs(b),d=Sc(d),d!==null)if(f=ta(d),f===null)d=null;else if(y=f.tag,y===13){if(d=oi(f),d!==null)return d;d=null}else if(y===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;d=null}else f!==d&&(d=null);return et=d,null}function vn(d){switch(d){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(Yv()){case wh:return 1;case hc:return 4;case Au:case Xv:return 16;case Di:return 536870912;default:return 16}default:return 16}}var Bt=null,Nt=null,Nn=null;function ds(){if(Nn)return Nn;var d,f=Nt,y=f.length,b,I="value"in Bt?Bt.value:Bt.textContent,M=I.length;for(d=0;d<y&&f[d]===I[d];d++);var j=y-d;for(b=1;b<=j&&f[y-b]===I[M-b];b++);return Nn=I.slice(d,1<b?1-b:void 0)}function xn(d){var f=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&f===13&&(d=13)):d=f,d===10&&(d=13),32<=d||d===13?d:0}function Xn(){return!0}function Dr(){return!1}function hn(d){function f(y,b,I,M,j){this._reactName=y,this._targetInst=I,this.type=b,this.nativeEvent=M,this.target=j,this.currentTarget=null;for(var K in d)d.hasOwnProperty(K)&&(y=d[K],this[K]=y?y(M):M[K]);return this.isDefaultPrevented=(M.defaultPrevented!=null?M.defaultPrevented:M.returnValue===!1)?Xn:Dr,this.isPropagationStopped=Dr,this}return ee(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=Xn)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=Xn)},persist:function(){},isPersistent:Xn}),f}var fr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ni=hn(fr),rl=ee({},fr,{view:0,detail:0}),Fu=hn(rl),sl,sx,_h,Ig=ee({},rl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ox,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==_h&&(_h&&d.type==="mousemove"?(sl=d.screenX-_h.screenX,sx=d.screenY-_h.screenY):sx=sl=0,_h=d),sl)},movementY:function(d){return"movementY"in d?d.movementY:sx}}),zT=hn(Ig),jK=ee({},Ig,{dataTransfer:0}),LK=hn(jK),NK=ee({},rl,{relatedTarget:0}),ix=hn(NK),FK=ee({},fr,{animationName:0,elapsedTime:0,pseudoElement:0}),zK=hn(FK),$K=ee({},fr,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),BK=hn($K),UK=ee({},fr,{data:0}),$T=hn(UK),HK={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},KK={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"},WK={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function VK(d){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(d):(d=WK[d])?!!f[d]:!1}function ox(){return VK}var qK=ee({},rl,{key:function(d){if(d.key){var f=HK[d.key]||d.key;if(f!=="Unidentified")return f}return d.type==="keypress"?(d=xn(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?KK[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ox,charCode:function(d){return d.type==="keypress"?xn(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?xn(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),GK=hn(qK),YK=ee({},Ig,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),BT=hn(YK),XK=ee({},rl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ox}),ZK=hn(XK),JK=ee({},fr,{propertyName:0,elapsedTime:0,pseudoElement:0}),QK=hn(JK),eW=ee({},Ig,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),tW=hn(eW),nW=[9,13,27,32],ax=a&&"CompositionEvent"in window,Th=null;a&&"documentMode"in document&&(Th=document.documentMode);var rW=a&&"TextEvent"in window&&!Th,UT=a&&(!ax||Th&&8<Th&&11>=Th),HT=" ",KT=!1;function WT(d,f){switch(d){case"keyup":return nW.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function VT(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var zu=!1;function sW(d,f){switch(d){case"compositionend":return VT(f);case"keypress":return f.which!==32?null:(KT=!0,HT);case"textInput":return d=f.data,d===HT&&KT?null:d;default:return null}}function iW(d,f){if(zu)return d==="compositionend"||!ax&&WT(d,f)?(d=ds(),Nn=Nt=Bt=null,zu=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return UT&&f.locale!=="ko"?null:f.data;default:return null}}var oW={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 qT(d){var f=d&&d.nodeName&&d.nodeName.toLowerCase();return f==="input"?!!oW[d.type]:f==="textarea"}function GT(d,f,y,b){Ja(b),f=Ag(f,"onChange"),0<f.length&&(y=new Ni("onChange","change",null,y,b),d.push({event:y,listeners:f}))}var Mh=null,Ah=null;function aW(d){h2(d,0)}function Eg(d){var f=Ku(d);if(Jt(f))return d}function lW(d,f){if(d==="change")return f}var YT=!1;if(a){var lx;if(a){var cx="oninput"in document;if(!cx){var XT=document.createElement("div");XT.setAttribute("oninput","return;"),cx=typeof XT.oninput=="function"}lx=cx}else lx=!1;YT=lx&&(!document.documentMode||9<document.documentMode)}function ZT(){Mh&&(Mh.detachEvent("onpropertychange",JT),Ah=Mh=null)}function JT(d){if(d.propertyName==="value"&&Eg(Ah)){var f=[];GT(f,Ah,d,cs(d)),gg(aW,f)}}function cW(d,f,y){d==="focusin"?(ZT(),Mh=f,Ah=y,Mh.attachEvent("onpropertychange",JT)):d==="focusout"&&ZT()}function uW(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return Eg(Ah)}function dW(d,f){if(d==="click")return Eg(f)}function hW(d,f){if(d==="input"||d==="change")return Eg(f)}function fW(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var Fi=typeof Object.is=="function"?Object.is:fW;function Oh(d,f){if(Fi(d,f))return!0;if(typeof d!="object"||d===null||typeof f!="object"||f===null)return!1;var y=Object.keys(d),b=Object.keys(f);if(y.length!==b.length)return!1;for(b=0;b<y.length;b++){var I=y[b];if(!l.call(f,I)||!Fi(d[I],f[I]))return!1}return!0}function QT(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function e2(d,f){var y=QT(d);d=0;for(var b;y;){if(y.nodeType===3){if(b=d+y.textContent.length,d<=f&&b>=f)return{node:y,offset:f-d};d=b}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=QT(y)}}function t2(d,f){return d&&f?d===f?!0:d&&d.nodeType===3?!1:f&&f.nodeType===3?t2(d,f.parentNode):"contains"in d?d.contains(f):d.compareDocumentPosition?!!(d.compareDocumentPosition(f)&16):!1:!1}function n2(){for(var d=window,f=Et();f instanceof d.HTMLIFrameElement;){try{var y=typeof f.contentWindow.location.href=="string"}catch{y=!1}if(y)d=f.contentWindow;else break;f=Et(d.document)}return f}function ux(d){var f=d&&d.nodeName&&d.nodeName.toLowerCase();return f&&(f==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||f==="textarea"||d.contentEditable==="true")}function pW(d){var f=n2(),y=d.focusedElem,b=d.selectionRange;if(f!==y&&y&&y.ownerDocument&&t2(y.ownerDocument.documentElement,y)){if(b!==null&&ux(y)){if(f=b.start,d=b.end,d===void 0&&(d=f),"selectionStart"in y)y.selectionStart=f,y.selectionEnd=Math.min(d,y.value.length);else if(d=(f=y.ownerDocument||document)&&f.defaultView||window,d.getSelection){d=d.getSelection();var I=y.textContent.length,M=Math.min(b.start,I);b=b.end===void 0?M:Math.min(b.end,I),!d.extend&&M>b&&(I=b,b=M,M=I),I=e2(y,M);var j=e2(y,b);I&&j&&(d.rangeCount!==1||d.anchorNode!==I.node||d.anchorOffset!==I.offset||d.focusNode!==j.node||d.focusOffset!==j.offset)&&(f=f.createRange(),f.setStart(I.node,I.offset),d.removeAllRanges(),M>b?(d.addRange(f),d.extend(j.node,j.offset)):(f.setEnd(j.node,j.offset),d.addRange(f)))}}for(f=[],d=y;d=d.parentNode;)d.nodeType===1&&f.push({element:d,left:d.scrollLeft,top:d.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<f.length;y++)d=f[y],d.element.scrollLeft=d.left,d.element.scrollTop=d.top}}var gW=a&&"documentMode"in document&&11>=document.documentMode,$u=null,dx=null,Rh=null,hx=!1;function r2(d,f,y){var b=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;hx||$u==null||$u!==Et(b)||(b=$u,"selectionStart"in b&&ux(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Rh&&Oh(Rh,b)||(Rh=b,b=Ag(dx,"onSelect"),0<b.length&&(f=new Ni("onSelect","select",null,f,y),d.push({event:f,listeners:b}),f.target=$u)))}function _g(d,f){var y={};return y[d.toLowerCase()]=f.toLowerCase(),y["Webkit"+d]="webkit"+f,y["Moz"+d]="moz"+f,y}var Bu={animationend:_g("Animation","AnimationEnd"),animationiteration:_g("Animation","AnimationIteration"),animationstart:_g("Animation","AnimationStart"),transitionend:_g("Transition","TransitionEnd")},fx={},s2={};a&&(s2=document.createElement("div").style,"AnimationEvent"in window||(delete Bu.animationend.animation,delete Bu.animationiteration.animation,delete Bu.animationstart.animation),"TransitionEvent"in window||delete Bu.transitionend.transition);function Tg(d){if(fx[d])return fx[d];if(!Bu[d])return d;var f=Bu[d],y;for(y in f)if(f.hasOwnProperty(y)&&y in s2)return fx[d]=f[y];return d}var i2=Tg("animationend"),o2=Tg("animationiteration"),a2=Tg("animationstart"),l2=Tg("transitionend"),c2=new Map,u2="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 il(d,f){c2.set(d,f),i(f,[d])}for(var px=0;px<u2.length;px++){var gx=u2[px],mW=gx.toLowerCase(),yW=gx[0].toUpperCase()+gx.slice(1);il(mW,"on"+yW)}il(i2,"onAnimationEnd"),il(o2,"onAnimationIteration"),il(a2,"onAnimationStart"),il("dblclick","onDoubleClick"),il("focusin","onFocus"),il("focusout","onBlur"),il(l2,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dh="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(" "),SW=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dh));function d2(d,f,y){var b=d.type||"unknown-event";d.currentTarget=y,Wv(b,f,void 0,d),d.currentTarget=null}function h2(d,f){f=(f&4)!==0;for(var y=0;y<d.length;y++){var b=d[y],I=b.event;b=b.listeners;e:{var M=void 0;if(f)for(var j=b.length-1;0<=j;j--){var K=b[j],q=K.instance,oe=K.currentTarget;if(K=K.listener,q!==M&&I.isPropagationStopped())break e;d2(I,K,oe),M=q}else for(j=0;j<b.length;j++){if(K=b[j],q=K.instance,oe=K.currentTarget,K=K.listener,q!==M&&I.isPropagationStopped())break e;d2(I,K,oe),M=q}}}if(ii)throw d=xh,ii=!1,xh=null,d}function Vt(d,f){var y=f[Cx];y===void 0&&(y=f[Cx]=new Set);var b=d+"__bubble";y.has(b)||(f2(f,d,2,!1),y.add(b))}function mx(d,f,y){var b=0;f&&(b|=4),f2(y,d,b,f)}var Mg="_reactListening"+Math.random().toString(36).slice(2);function jh(d){if(!d[Mg]){d[Mg]=!0,r.forEach(function(y){y!=="selectionchange"&&(SW.has(y)||mx(y,!1,d),mx(y,!0,d))});var f=d.nodeType===9?d:d.ownerDocument;f===null||f[Mg]||(f[Mg]=!0,mx("selectionchange",!1,f))}}function f2(d,f,y,b){switch(vn(f)){case 1:var I=de;break;case 4:I=Ae;break;default:I=Mt}y=I.bind(null,f,y,d),I=void 0,!vh||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(I=!0),b?I!==void 0?d.addEventListener(f,y,{capture:!0,passive:I}):d.addEventListener(f,y,!0):I!==void 0?d.addEventListener(f,y,{passive:I}):d.addEventListener(f,y,!1)}function yx(d,f,y,b,I){var M=b;if((f&1)===0&&(f&2)===0&&b!==null)e:for(;;){if(b===null)return;var j=b.tag;if(j===3||j===4){var K=b.stateNode.containerInfo;if(K===I||K.nodeType===8&&K.parentNode===I)break;if(j===4)for(j=b.return;j!==null;){var q=j.tag;if((q===3||q===4)&&(q=j.stateNode.containerInfo,q===I||q.nodeType===8&&q.parentNode===I))return;j=j.return}for(;K!==null;){if(j=Sc(K),j===null)return;if(q=j.tag,q===5||q===6){b=M=j;continue e}K=K.parentNode}}b=b.return}gg(function(){var oe=M,pe=cs(y),ye=[];e:{var fe=c2.get(d);if(fe!==void 0){var Me=Ni,Le=d;switch(d){case"keypress":if(xn(y)===0)break e;case"keydown":case"keyup":Me=GK;break;case"focusin":Le="focus",Me=ix;break;case"focusout":Le="blur",Me=ix;break;case"beforeblur":case"afterblur":Me=ix;break;case"click":if(y.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Me=zT;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Me=LK;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Me=ZK;break;case i2:case o2:case a2:Me=zK;break;case l2:Me=QK;break;case"scroll":Me=Fu;break;case"wheel":Me=tW;break;case"copy":case"cut":case"paste":Me=BK;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Me=BT}var ze=(f&4)!==0,wn=!ze&&d==="scroll",ne=ze?fe!==null?fe+"Capture":null:fe;ze=[];for(var X=oe,se;X!==null;){se=X;var xe=se.stateNode;if(se.tag===5&&xe!==null&&(se=xe,ne!==null&&(xe=uc(X,ne),xe!=null&&ze.push(Lh(X,xe,se)))),wn)break;X=X.return}0<ze.length&&(fe=new Me(fe,Le,null,y,pe),ye.push({event:fe,listeners:ze}))}}if((f&7)===0){e:{if(fe=d==="mouseover"||d==="pointerover",Me=d==="mouseout"||d==="pointerout",fe&&y!==Rs&&(Le=y.relatedTarget||y.fromElement)&&(Sc(Le)||Le[ra]))break e;if((Me||fe)&&(fe=pe.window===pe?pe:(fe=pe.ownerDocument)?fe.defaultView||fe.parentWindow:window,Me?(Le=y.relatedTarget||y.toElement,Me=oe,Le=Le?Sc(Le):null,Le!==null&&(wn=ta(Le),Le!==wn||Le.tag!==5&&Le.tag!==6)&&(Le=null)):(Me=null,Le=oe),Me!==Le)){if(ze=zT,xe="onMouseLeave",ne="onMouseEnter",X="mouse",(d==="pointerout"||d==="pointerover")&&(ze=BT,xe="onPointerLeave",ne="onPointerEnter",X="pointer"),wn=Me==null?fe:Ku(Me),se=Le==null?fe:Ku(Le),fe=new ze(xe,X+"leave",Me,y,pe),fe.target=wn,fe.relatedTarget=se,xe=null,Sc(pe)===oe&&(ze=new ze(ne,X+"enter",Le,y,pe),ze.target=se,ze.relatedTarget=wn,xe=ze),wn=xe,Me&&Le)t:{for(ze=Me,ne=Le,X=0,se=ze;se;se=Uu(se))X++;for(se=0,xe=ne;xe;xe=Uu(xe))se++;for(;0<X-se;)ze=Uu(ze),X--;for(;0<se-X;)ne=Uu(ne),se--;for(;X--;){if(ze===ne||ne!==null&&ze===ne.alternate)break t;ze=Uu(ze),ne=Uu(ne)}ze=null}else ze=null;Me!==null&&p2(ye,fe,Me,ze,!1),Le!==null&&wn!==null&&p2(ye,wn,Le,ze,!0)}}e:{if(fe=oe?Ku(oe):window,Me=fe.nodeName&&fe.nodeName.toLowerCase(),Me==="select"||Me==="input"&&fe.type==="file")var Be=lW;else if(qT(fe))if(YT)Be=hW;else{Be=uW;var Ve=cW}else(Me=fe.nodeName)&&Me.toLowerCase()==="input"&&(fe.type==="checkbox"||fe.type==="radio")&&(Be=dW);if(Be&&(Be=Be(d,oe))){GT(ye,Be,y,pe);break e}Ve&&Ve(d,fe,oe),d==="focusout"&&(Ve=fe._wrapperState)&&Ve.controlled&&fe.type==="number"&&is(fe,"number",fe.value)}switch(Ve=oe?Ku(oe):window,d){case"focusin":(qT(Ve)||Ve.contentEditable==="true")&&($u=Ve,dx=oe,Rh=null);break;case"focusout":Rh=dx=$u=null;break;case"mousedown":hx=!0;break;case"contextmenu":case"mouseup":case"dragend":hx=!1,r2(ye,y,pe);break;case"selectionchange":if(gW)break;case"keydown":case"keyup":r2(ye,y,pe)}var qe;if(ax)e:{switch(d){case"compositionstart":var Qe="onCompositionStart";break e;case"compositionend":Qe="onCompositionEnd";break e;case"compositionupdate":Qe="onCompositionUpdate";break e}Qe=void 0}else zu?WT(d,y)&&(Qe="onCompositionEnd"):d==="keydown"&&y.keyCode===229&&(Qe="onCompositionStart");Qe&&(UT&&y.locale!=="ko"&&(zu||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&zu&&(qe=ds()):(Bt=pe,Nt="value"in Bt?Bt.value:Bt.textContent,zu=!0)),Ve=Ag(oe,Qe),0<Ve.length&&(Qe=new $T(Qe,d,null,y,pe),ye.push({event:Qe,listeners:Ve}),qe?Qe.data=qe:(qe=VT(y),qe!==null&&(Qe.data=qe)))),(qe=rW?sW(d,y):iW(d,y))&&(oe=Ag(oe,"onBeforeInput"),0<oe.length&&(pe=new $T("onBeforeInput","beforeinput",null,y,pe),ye.push({event:pe,listeners:oe}),pe.data=qe))}h2(ye,f)})}function Lh(d,f,y){return{instance:d,listener:f,currentTarget:y}}function Ag(d,f){for(var y=f+"Capture",b=[];d!==null;){var I=d,M=I.stateNode;I.tag===5&&M!==null&&(I=M,M=uc(d,y),M!=null&&b.unshift(Lh(d,M,I)),M=uc(d,f),M!=null&&b.push(Lh(d,M,I))),d=d.return}return b}function Uu(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5);return d||null}function p2(d,f,y,b,I){for(var M=f._reactName,j=[];y!==null&&y!==b;){var K=y,q=K.alternate,oe=K.stateNode;if(q!==null&&q===b)break;K.tag===5&&oe!==null&&(K=oe,I?(q=uc(y,M),q!=null&&j.unshift(Lh(y,q,K))):I||(q=uc(y,M),q!=null&&j.push(Lh(y,q,K)))),y=y.return}j.length!==0&&d.push({event:f,listeners:j})}var vW=/\r\n?/g,xW=/\u0000|\uFFFD/g;function g2(d){return(typeof d=="string"?d:""+d).replace(vW,`
|
|
38
|
-
`).replace(xW,"")}function Og(d,f,y){if(f=g2(f),g2(d)!==f&&y)throw Error(t(425))}function Rg(){}var Sx=null,vx=null;function xx(d,f){return d==="textarea"||d==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var wx=typeof setTimeout=="function"?setTimeout:void 0,wW=typeof clearTimeout=="function"?clearTimeout:void 0,m2=typeof Promise=="function"?Promise:void 0,bW=typeof queueMicrotask=="function"?queueMicrotask:typeof m2<"u"?function(d){return m2.resolve(null).then(d).catch(CW)}:wx;function CW(d){setTimeout(function(){throw d})}function bx(d,f){var y=f,b=0;do{var I=y.nextSibling;if(d.removeChild(y),I&&I.nodeType===8)if(y=I.data,y==="/$"){if(b===0){d.removeChild(I),yc(f);return}b--}else y!=="$"&&y!=="$?"&&y!=="$!"||b++;y=I}while(y);yc(f)}function ol(d){for(;d!=null;d=d.nextSibling){var f=d.nodeType;if(f===1||f===3)break;if(f===8){if(f=d.data,f==="$"||f==="$!"||f==="$?")break;if(f==="/$")return null}}return d}function y2(d){d=d.previousSibling;for(var f=0;d;){if(d.nodeType===8){var y=d.data;if(y==="$"||y==="$!"||y==="$?"){if(f===0)return d;f--}else y==="/$"&&f++}d=d.previousSibling}return null}var Hu=Math.random().toString(36).slice(2),vo="__reactFiber$"+Hu,Nh="__reactProps$"+Hu,ra="__reactContainer$"+Hu,Cx="__reactEvents$"+Hu,PW="__reactListeners$"+Hu,kW="__reactHandles$"+Hu;function Sc(d){var f=d[vo];if(f)return f;for(var y=d.parentNode;y;){if(f=y[ra]||y[vo]){if(y=f.alternate,f.child!==null||y!==null&&y.child!==null)for(d=y2(d);d!==null;){if(y=d[vo])return y;d=y2(d)}return f}d=y,y=d.parentNode}return null}function Fh(d){return d=d[vo]||d[ra],!d||d.tag!==5&&d.tag!==6&&d.tag!==13&&d.tag!==3?null:d}function Ku(d){if(d.tag===5||d.tag===6)return d.stateNode;throw Error(t(33))}function Dg(d){return d[Nh]||null}var Px=[],Wu=-1;function al(d){return{current:d}}function qt(d){0>Wu||(d.current=Px[Wu],Px[Wu]=null,Wu--)}function Ut(d,f){Wu++,Px[Wu]=d.current,d.current=f}var ll={},pr=al(ll),hs=al(!1),vc=ll;function Vu(d,f){var y=d.type.contextTypes;if(!y)return ll;var b=d.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===f)return b.__reactInternalMemoizedMaskedChildContext;var I={},M;for(M in y)I[M]=f[M];return b&&(d=d.stateNode,d.__reactInternalMemoizedUnmaskedChildContext=f,d.__reactInternalMemoizedMaskedChildContext=I),I}function fs(d){return d=d.childContextTypes,d!=null}function jg(){qt(hs),qt(pr)}function S2(d,f,y){if(pr.current!==ll)throw Error(t(168));Ut(pr,f),Ut(hs,y)}function v2(d,f,y){var b=d.stateNode;if(f=f.childContextTypes,typeof b.getChildContext!="function")return y;b=b.getChildContext();for(var I in b)if(!(I in f))throw Error(t(108,Ne(d)||"Unknown",I));return ee({},y,b)}function Lg(d){return d=(d=d.stateNode)&&d.__reactInternalMemoizedMergedChildContext||ll,vc=pr.current,Ut(pr,d),Ut(hs,hs.current),!0}function x2(d,f,y){var b=d.stateNode;if(!b)throw Error(t(169));y?(d=v2(d,f,vc),b.__reactInternalMemoizedMergedChildContext=d,qt(hs),qt(pr),Ut(pr,d)):qt(hs),Ut(hs,y)}var sa=null,Ng=!1,kx=!1;function w2(d){sa===null?sa=[d]:sa.push(d)}function IW(d){Ng=!0,w2(d)}function cl(){if(!kx&&sa!==null){kx=!0;var d=0,f=xt;try{var y=sa;for(xt=1;d<y.length;d++){var b=y[d];do b=b(!0);while(b!==null)}sa=null,Ng=!1}catch(I){throw sa!==null&&(sa=sa.slice(d+1)),vg(wh,cl),I}finally{xt=f,kx=!1}}return null}var qu=[],Gu=0,Fg=null,zg=0,li=[],ci=0,xc=null,ia=1,oa="";function wc(d,f){qu[Gu++]=zg,qu[Gu++]=Fg,Fg=d,zg=f}function b2(d,f,y){li[ci++]=ia,li[ci++]=oa,li[ci++]=xc,xc=d;var b=ia;d=oa;var I=32-js(b)-1;b&=~(1<<I),y+=1;var M=32-js(f)+I;if(30<M){var j=I-I%5;M=(b&(1<<j)-1).toString(32),b>>=j,I-=j,ia=1<<32-js(f)+I|y<<I|b,oa=M+d}else ia=1<<M|y<<I|b,oa=d}function Ix(d){d.return!==null&&(wc(d,1),b2(d,1,0))}function Ex(d){for(;d===Fg;)Fg=qu[--Gu],qu[Gu]=null,zg=qu[--Gu],qu[Gu]=null;for(;d===xc;)xc=li[--ci],li[ci]=null,oa=li[--ci],li[ci]=null,ia=li[--ci],li[ci]=null}var Ls=null,Ns=null,Qt=!1,zi=null;function C2(d,f){var y=fi(5,null,null,0);y.elementType="DELETED",y.stateNode=f,y.return=d,f=d.deletions,f===null?(d.deletions=[y],d.flags|=16):f.push(y)}function P2(d,f){switch(d.tag){case 5:var y=d.type;return f=f.nodeType!==1||y.toLowerCase()!==f.nodeName.toLowerCase()?null:f,f!==null?(d.stateNode=f,Ls=d,Ns=ol(f.firstChild),!0):!1;case 6:return f=d.pendingProps===""||f.nodeType!==3?null:f,f!==null?(d.stateNode=f,Ls=d,Ns=null,!0):!1;case 13:return f=f.nodeType!==8?null:f,f!==null?(y=xc!==null?{id:ia,overflow:oa}:null,d.memoizedState={dehydrated:f,treeContext:y,retryLane:1073741824},y=fi(18,null,null,0),y.stateNode=f,y.return=d,d.child=y,Ls=d,Ns=null,!0):!1;default:return!1}}function _x(d){return(d.mode&1)!==0&&(d.flags&128)===0}function Tx(d){if(Qt){var f=Ns;if(f){var y=f;if(!P2(d,f)){if(_x(d))throw Error(t(418));f=ol(y.nextSibling);var b=Ls;f&&P2(d,f)?C2(b,y):(d.flags=d.flags&-4097|2,Qt=!1,Ls=d)}}else{if(_x(d))throw Error(t(418));d.flags=d.flags&-4097|2,Qt=!1,Ls=d}}}function k2(d){for(d=d.return;d!==null&&d.tag!==5&&d.tag!==3&&d.tag!==13;)d=d.return;Ls=d}function $g(d){if(d!==Ls)return!1;if(!Qt)return k2(d),Qt=!0,!1;var f;if((f=d.tag!==3)&&!(f=d.tag!==5)&&(f=d.type,f=f!=="head"&&f!=="body"&&!xx(d.type,d.memoizedProps)),f&&(f=Ns)){if(_x(d))throw I2(),Error(t(418));for(;f;)C2(d,f),f=ol(f.nextSibling)}if(k2(d),d.tag===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(t(317));e:{for(d=d.nextSibling,f=0;d;){if(d.nodeType===8){var y=d.data;if(y==="/$"){if(f===0){Ns=ol(d.nextSibling);break e}f--}else y!=="$"&&y!=="$!"&&y!=="$?"||f++}d=d.nextSibling}Ns=null}}else Ns=Ls?ol(d.stateNode.nextSibling):null;return!0}function I2(){for(var d=Ns;d;)d=ol(d.nextSibling)}function Yu(){Ns=Ls=null,Qt=!1}function Mx(d){zi===null?zi=[d]:zi.push(d)}var EW=E.ReactCurrentBatchConfig;function zh(d,f,y){if(d=y.ref,d!==null&&typeof d!="function"&&typeof d!="object"){if(y._owner){if(y=y._owner,y){if(y.tag!==1)throw Error(t(309));var b=y.stateNode}if(!b)throw Error(t(147,d));var I=b,M=""+d;return f!==null&&f.ref!==null&&typeof f.ref=="function"&&f.ref._stringRef===M?f.ref:(f=function(j){var K=I.refs;j===null?delete K[M]:K[M]=j},f._stringRef=M,f)}if(typeof d!="string")throw Error(t(284));if(!y._owner)throw Error(t(290,d))}return d}function Bg(d,f){throw d=Object.prototype.toString.call(f),Error(t(31,d==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":d))}function E2(d){var f=d._init;return f(d._payload)}function _2(d){function f(ne,X){if(d){var se=ne.deletions;se===null?(ne.deletions=[X],ne.flags|=16):se.push(X)}}function y(ne,X){if(!d)return null;for(;X!==null;)f(ne,X),X=X.sibling;return null}function b(ne,X){for(ne=new Map;X!==null;)X.key!==null?ne.set(X.key,X):ne.set(X.index,X),X=X.sibling;return ne}function I(ne,X){return ne=yl(ne,X),ne.index=0,ne.sibling=null,ne}function M(ne,X,se){return ne.index=se,d?(se=ne.alternate,se!==null?(se=se.index,se<X?(ne.flags|=2,X):se):(ne.flags|=2,X)):(ne.flags|=1048576,X)}function j(ne){return d&&ne.alternate===null&&(ne.flags|=2),ne}function K(ne,X,se,xe){return X===null||X.tag!==6?(X=ww(se,ne.mode,xe),X.return=ne,X):(X=I(X,se),X.return=ne,X)}function q(ne,X,se,xe){var Be=se.type;return Be===O?pe(ne,X,se.props.children,xe,se.key):X!==null&&(X.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===Y&&E2(Be)===X.type)?(xe=I(X,se.props),xe.ref=zh(ne,X,se),xe.return=ne,xe):(xe=dm(se.type,se.key,se.props,null,ne.mode,xe),xe.ref=zh(ne,X,se),xe.return=ne,xe)}function oe(ne,X,se,xe){return X===null||X.tag!==4||X.stateNode.containerInfo!==se.containerInfo||X.stateNode.implementation!==se.implementation?(X=bw(se,ne.mode,xe),X.return=ne,X):(X=I(X,se.children||[]),X.return=ne,X)}function pe(ne,X,se,xe,Be){return X===null||X.tag!==7?(X=Tc(se,ne.mode,xe,Be),X.return=ne,X):(X=I(X,se),X.return=ne,X)}function ye(ne,X,se){if(typeof X=="string"&&X!==""||typeof X=="number")return X=ww(""+X,ne.mode,se),X.return=ne,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case T:return se=dm(X.type,X.key,X.props,null,ne.mode,se),se.ref=zh(ne,null,X),se.return=ne,se;case A:return X=bw(X,ne.mode,se),X.return=ne,X;case Y:var xe=X._init;return ye(ne,xe(X._payload),se)}if(as(X)||V(X))return X=Tc(X,ne.mode,se,null),X.return=ne,X;Bg(ne,X)}return null}function fe(ne,X,se,xe){var Be=X!==null?X.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Be!==null?null:K(ne,X,""+se,xe);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case T:return se.key===Be?q(ne,X,se,xe):null;case A:return se.key===Be?oe(ne,X,se,xe):null;case Y:return Be=se._init,fe(ne,X,Be(se._payload),xe)}if(as(se)||V(se))return Be!==null?null:pe(ne,X,se,xe,null);Bg(ne,se)}return null}function Me(ne,X,se,xe,Be){if(typeof xe=="string"&&xe!==""||typeof xe=="number")return ne=ne.get(se)||null,K(X,ne,""+xe,Be);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case T:return ne=ne.get(xe.key===null?se:xe.key)||null,q(X,ne,xe,Be);case A:return ne=ne.get(xe.key===null?se:xe.key)||null,oe(X,ne,xe,Be);case Y:var Ve=xe._init;return Me(ne,X,se,Ve(xe._payload),Be)}if(as(xe)||V(xe))return ne=ne.get(se)||null,pe(X,ne,xe,Be,null);Bg(X,xe)}return null}function Le(ne,X,se,xe){for(var Be=null,Ve=null,qe=X,Qe=X=0,$n=null;qe!==null&&Qe<se.length;Qe++){qe.index>Qe?($n=qe,qe=null):$n=qe.sibling;var Pt=fe(ne,qe,se[Qe],xe);if(Pt===null){qe===null&&(qe=$n);break}d&&qe&&Pt.alternate===null&&f(ne,qe),X=M(Pt,X,Qe),Ve===null?Be=Pt:Ve.sibling=Pt,Ve=Pt,qe=$n}if(Qe===se.length)return y(ne,qe),Qt&&wc(ne,Qe),Be;if(qe===null){for(;Qe<se.length;Qe++)qe=ye(ne,se[Qe],xe),qe!==null&&(X=M(qe,X,Qe),Ve===null?Be=qe:Ve.sibling=qe,Ve=qe);return Qt&&wc(ne,Qe),Be}for(qe=b(ne,qe);Qe<se.length;Qe++)$n=Me(qe,ne,Qe,se[Qe],xe),$n!==null&&(d&&$n.alternate!==null&&qe.delete($n.key===null?Qe:$n.key),X=M($n,X,Qe),Ve===null?Be=$n:Ve.sibling=$n,Ve=$n);return d&&qe.forEach(function(Sl){return f(ne,Sl)}),Qt&&wc(ne,Qe),Be}function ze(ne,X,se,xe){var Be=V(se);if(typeof Be!="function")throw Error(t(150));if(se=Be.call(se),se==null)throw Error(t(151));for(var Ve=Be=null,qe=X,Qe=X=0,$n=null,Pt=se.next();qe!==null&&!Pt.done;Qe++,Pt=se.next()){qe.index>Qe?($n=qe,qe=null):$n=qe.sibling;var Sl=fe(ne,qe,Pt.value,xe);if(Sl===null){qe===null&&(qe=$n);break}d&&qe&&Sl.alternate===null&&f(ne,qe),X=M(Sl,X,Qe),Ve===null?Be=Sl:Ve.sibling=Sl,Ve=Sl,qe=$n}if(Pt.done)return y(ne,qe),Qt&&wc(ne,Qe),Be;if(qe===null){for(;!Pt.done;Qe++,Pt=se.next())Pt=ye(ne,Pt.value,xe),Pt!==null&&(X=M(Pt,X,Qe),Ve===null?Be=Pt:Ve.sibling=Pt,Ve=Pt);return Qt&&wc(ne,Qe),Be}for(qe=b(ne,qe);!Pt.done;Qe++,Pt=se.next())Pt=Me(qe,ne,Qe,Pt.value,xe),Pt!==null&&(d&&Pt.alternate!==null&&qe.delete(Pt.key===null?Qe:Pt.key),X=M(Pt,X,Qe),Ve===null?Be=Pt:Ve.sibling=Pt,Ve=Pt);return d&&qe.forEach(function(oV){return f(ne,oV)}),Qt&&wc(ne,Qe),Be}function wn(ne,X,se,xe){if(typeof se=="object"&&se!==null&&se.type===O&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case T:e:{for(var Be=se.key,Ve=X;Ve!==null;){if(Ve.key===Be){if(Be=se.type,Be===O){if(Ve.tag===7){y(ne,Ve.sibling),X=I(Ve,se.props.children),X.return=ne,ne=X;break e}}else if(Ve.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===Y&&E2(Be)===Ve.type){y(ne,Ve.sibling),X=I(Ve,se.props),X.ref=zh(ne,Ve,se),X.return=ne,ne=X;break e}y(ne,Ve);break}else f(ne,Ve);Ve=Ve.sibling}se.type===O?(X=Tc(se.props.children,ne.mode,xe,se.key),X.return=ne,ne=X):(xe=dm(se.type,se.key,se.props,null,ne.mode,xe),xe.ref=zh(ne,X,se),xe.return=ne,ne=xe)}return j(ne);case A:e:{for(Ve=se.key;X!==null;){if(X.key===Ve)if(X.tag===4&&X.stateNode.containerInfo===se.containerInfo&&X.stateNode.implementation===se.implementation){y(ne,X.sibling),X=I(X,se.children||[]),X.return=ne,ne=X;break e}else{y(ne,X);break}else f(ne,X);X=X.sibling}X=bw(se,ne.mode,xe),X.return=ne,ne=X}return j(ne);case Y:return Ve=se._init,wn(ne,X,Ve(se._payload),xe)}if(as(se))return Le(ne,X,se,xe);if(V(se))return ze(ne,X,se,xe);Bg(ne,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,X!==null&&X.tag===6?(y(ne,X.sibling),X=I(X,se),X.return=ne,ne=X):(y(ne,X),X=ww(se,ne.mode,xe),X.return=ne,ne=X),j(ne)):y(ne,X)}return wn}var Xu=_2(!0),T2=_2(!1),Ug=al(null),Hg=null,Zu=null,Ax=null;function Ox(){Ax=Zu=Hg=null}function Rx(d){var f=Ug.current;qt(Ug),d._currentValue=f}function Dx(d,f,y){for(;d!==null;){var b=d.alternate;if((d.childLanes&f)!==f?(d.childLanes|=f,b!==null&&(b.childLanes|=f)):b!==null&&(b.childLanes&f)!==f&&(b.childLanes|=f),d===y)break;d=d.return}}function Ju(d,f){Hg=d,Ax=Zu=null,d=d.dependencies,d!==null&&d.firstContext!==null&&((d.lanes&f)!==0&&(ps=!0),d.firstContext=null)}function ui(d){var f=d._currentValue;if(Ax!==d)if(d={context:d,memoizedValue:f,next:null},Zu===null){if(Hg===null)throw Error(t(308));Zu=d,Hg.dependencies={lanes:0,firstContext:d}}else Zu=Zu.next=d;return f}var bc=null;function jx(d){bc===null?bc=[d]:bc.push(d)}function M2(d,f,y,b){var I=f.interleaved;return I===null?(y.next=y,jx(f)):(y.next=I.next,I.next=y),f.interleaved=y,aa(d,b)}function aa(d,f){d.lanes|=f;var y=d.alternate;for(y!==null&&(y.lanes|=f),y=d,d=d.return;d!==null;)d.childLanes|=f,y=d.alternate,y!==null&&(y.childLanes|=f),y=d,d=d.return;return y.tag===3?y.stateNode:null}var ul=!1;function Lx(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function A2(d,f){d=d.updateQueue,f.updateQueue===d&&(f.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,effects:d.effects})}function la(d,f){return{eventTime:d,lane:f,tag:0,payload:null,callback:null,next:null}}function dl(d,f,y){var b=d.updateQueue;if(b===null)return null;if(b=b.shared,(bt&2)!==0){var I=b.pending;return I===null?f.next=f:(f.next=I.next,I.next=f),b.pending=f,aa(d,y)}return I=b.interleaved,I===null?(f.next=f,jx(b)):(f.next=I.next,I.next=f),b.interleaved=f,aa(d,y)}function Kg(d,f,y){if(f=f.updateQueue,f!==null&&(f=f.shared,(y&4194240)!==0)){var b=f.lanes;b&=d.pendingLanes,y|=b,f.lanes=y,Lu(d,y)}}function O2(d,f){var y=d.updateQueue,b=d.alternate;if(b!==null&&(b=b.updateQueue,y===b)){var I=null,M=null;if(y=y.firstBaseUpdate,y!==null){do{var j={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};M===null?I=M=j:M=M.next=j,y=y.next}while(y!==null);M===null?I=M=f:M=M.next=f}else I=M=f;y={baseState:b.baseState,firstBaseUpdate:I,lastBaseUpdate:M,shared:b.shared,effects:b.effects},d.updateQueue=y;return}d=y.lastBaseUpdate,d===null?y.firstBaseUpdate=f:d.next=f,y.lastBaseUpdate=f}function Wg(d,f,y,b){var I=d.updateQueue;ul=!1;var M=I.firstBaseUpdate,j=I.lastBaseUpdate,K=I.shared.pending;if(K!==null){I.shared.pending=null;var q=K,oe=q.next;q.next=null,j===null?M=oe:j.next=oe,j=q;var pe=d.alternate;pe!==null&&(pe=pe.updateQueue,K=pe.lastBaseUpdate,K!==j&&(K===null?pe.firstBaseUpdate=oe:K.next=oe,pe.lastBaseUpdate=q))}if(M!==null){var ye=I.baseState;j=0,pe=oe=q=null,K=M;do{var fe=K.lane,Me=K.eventTime;if((b&fe)===fe){pe!==null&&(pe=pe.next={eventTime:Me,lane:0,tag:K.tag,payload:K.payload,callback:K.callback,next:null});e:{var Le=d,ze=K;switch(fe=f,Me=y,ze.tag){case 1:if(Le=ze.payload,typeof Le=="function"){ye=Le.call(Me,ye,fe);break e}ye=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=ze.payload,fe=typeof Le=="function"?Le.call(Me,ye,fe):Le,fe==null)break e;ye=ee({},ye,fe);break e;case 2:ul=!0}}K.callback!==null&&K.lane!==0&&(d.flags|=64,fe=I.effects,fe===null?I.effects=[K]:fe.push(K))}else Me={eventTime:Me,lane:fe,tag:K.tag,payload:K.payload,callback:K.callback,next:null},pe===null?(oe=pe=Me,q=ye):pe=pe.next=Me,j|=fe;if(K=K.next,K===null){if(K=I.shared.pending,K===null)break;fe=K,K=fe.next,fe.next=null,I.lastBaseUpdate=fe,I.shared.pending=null}}while(!0);if(pe===null&&(q=ye),I.baseState=q,I.firstBaseUpdate=oe,I.lastBaseUpdate=pe,f=I.shared.interleaved,f!==null){I=f;do j|=I.lane,I=I.next;while(I!==f)}else M===null&&(I.shared.lanes=0);kc|=j,d.lanes=j,d.memoizedState=ye}}function R2(d,f,y){if(d=f.effects,f.effects=null,d!==null)for(f=0;f<d.length;f++){var b=d[f],I=b.callback;if(I!==null){if(b.callback=null,b=y,typeof I!="function")throw Error(t(191,I));I.call(b)}}}var $h={},xo=al($h),Bh=al($h),Uh=al($h);function Cc(d){if(d===$h)throw Error(t(174));return d}function Nx(d,f){switch(Ut(Uh,f),Ut(Bh,d),Ut(xo,$h),d=f.nodeType,d){case 9:case 11:f=(f=f.documentElement)?f.namespaceURI:ho(null,"");break;default:d=d===8?f.parentNode:f,f=d.namespaceURI||null,d=d.tagName,f=ho(f,d)}qt(xo),Ut(xo,f)}function Qu(){qt(xo),qt(Bh),qt(Uh)}function D2(d){Cc(Uh.current);var f=Cc(xo.current),y=ho(f,d.type);f!==y&&(Ut(Bh,d),Ut(xo,y))}function Fx(d){Bh.current===d&&(qt(xo),qt(Bh))}var sn=al(0);function Vg(d){for(var f=d;f!==null;){if(f.tag===13){var y=f.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||y.data==="$?"||y.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===d)break;for(;f.sibling===null;){if(f.return===null||f.return===d)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var zx=[];function $x(){for(var d=0;d<zx.length;d++)zx[d]._workInProgressVersionPrimary=null;zx.length=0}var qg=E.ReactCurrentDispatcher,Bx=E.ReactCurrentBatchConfig,Pc=0,on=null,Rn=null,Fn=null,Gg=!1,Hh=!1,Kh=0,_W=0;function gr(){throw Error(t(321))}function Ux(d,f){if(f===null)return!1;for(var y=0;y<f.length&&y<d.length;y++)if(!Fi(d[y],f[y]))return!1;return!0}function Hx(d,f,y,b,I,M){if(Pc=M,on=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,qg.current=d===null||d.memoizedState===null?OW:RW,d=y(b,I),Hh){M=0;do{if(Hh=!1,Kh=0,25<=M)throw Error(t(301));M+=1,Fn=Rn=null,f.updateQueue=null,qg.current=DW,d=y(b,I)}while(Hh)}if(qg.current=Zg,f=Rn!==null&&Rn.next!==null,Pc=0,Fn=Rn=on=null,Gg=!1,f)throw Error(t(300));return d}function Kx(){var d=Kh!==0;return Kh=0,d}function wo(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fn===null?on.memoizedState=Fn=d:Fn=Fn.next=d,Fn}function di(){if(Rn===null){var d=on.alternate;d=d!==null?d.memoizedState:null}else d=Rn.next;var f=Fn===null?on.memoizedState:Fn.next;if(f!==null)Fn=f,Rn=d;else{if(d===null)throw Error(t(310));Rn=d,d={memoizedState:Rn.memoizedState,baseState:Rn.baseState,baseQueue:Rn.baseQueue,queue:Rn.queue,next:null},Fn===null?on.memoizedState=Fn=d:Fn=Fn.next=d}return Fn}function Wh(d,f){return typeof f=="function"?f(d):f}function Wx(d){var f=di(),y=f.queue;if(y===null)throw Error(t(311));y.lastRenderedReducer=d;var b=Rn,I=b.baseQueue,M=y.pending;if(M!==null){if(I!==null){var j=I.next;I.next=M.next,M.next=j}b.baseQueue=I=M,y.pending=null}if(I!==null){M=I.next,b=b.baseState;var K=j=null,q=null,oe=M;do{var pe=oe.lane;if((Pc&pe)===pe)q!==null&&(q=q.next={lane:0,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),b=oe.hasEagerState?oe.eagerState:d(b,oe.action);else{var ye={lane:pe,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null};q===null?(K=q=ye,j=b):q=q.next=ye,on.lanes|=pe,kc|=pe}oe=oe.next}while(oe!==null&&oe!==M);q===null?j=b:q.next=K,Fi(b,f.memoizedState)||(ps=!0),f.memoizedState=b,f.baseState=j,f.baseQueue=q,y.lastRenderedState=b}if(d=y.interleaved,d!==null){I=d;do M=I.lane,on.lanes|=M,kc|=M,I=I.next;while(I!==d)}else I===null&&(y.lanes=0);return[f.memoizedState,y.dispatch]}function Vx(d){var f=di(),y=f.queue;if(y===null)throw Error(t(311));y.lastRenderedReducer=d;var b=y.dispatch,I=y.pending,M=f.memoizedState;if(I!==null){y.pending=null;var j=I=I.next;do M=d(M,j.action),j=j.next;while(j!==I);Fi(M,f.memoizedState)||(ps=!0),f.memoizedState=M,f.baseQueue===null&&(f.baseState=M),y.lastRenderedState=M}return[M,b]}function j2(){}function L2(d,f){var y=on,b=di(),I=f(),M=!Fi(b.memoizedState,I);if(M&&(b.memoizedState=I,ps=!0),b=b.queue,qx(z2.bind(null,y,b,d),[d]),b.getSnapshot!==f||M||Fn!==null&&Fn.memoizedState.tag&1){if(y.flags|=2048,Vh(9,F2.bind(null,y,b,I,f),void 0,null),zn===null)throw Error(t(349));(Pc&30)!==0||N2(y,f,I)}return I}function N2(d,f,y){d.flags|=16384,d={getSnapshot:f,value:y},f=on.updateQueue,f===null?(f={lastEffect:null,stores:null},on.updateQueue=f,f.stores=[d]):(y=f.stores,y===null?f.stores=[d]:y.push(d))}function F2(d,f,y,b){f.value=y,f.getSnapshot=b,$2(f)&&B2(d)}function z2(d,f,y){return y(function(){$2(f)&&B2(d)})}function $2(d){var f=d.getSnapshot;d=d.value;try{var y=f();return!Fi(d,y)}catch{return!0}}function B2(d){var f=aa(d,1);f!==null&&Hi(f,d,1,-1)}function U2(d){var f=wo();return typeof d=="function"&&(d=d()),f.memoizedState=f.baseState=d,d={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Wh,lastRenderedState:d},f.queue=d,d=d.dispatch=AW.bind(null,on,d),[f.memoizedState,d]}function Vh(d,f,y,b){return d={tag:d,create:f,destroy:y,deps:b,next:null},f=on.updateQueue,f===null?(f={lastEffect:null,stores:null},on.updateQueue=f,f.lastEffect=d.next=d):(y=f.lastEffect,y===null?f.lastEffect=d.next=d:(b=y.next,y.next=d,d.next=b,f.lastEffect=d)),d}function H2(){return di().memoizedState}function Yg(d,f,y,b){var I=wo();on.flags|=d,I.memoizedState=Vh(1|f,y,void 0,b===void 0?null:b)}function Xg(d,f,y,b){var I=di();b=b===void 0?null:b;var M=void 0;if(Rn!==null){var j=Rn.memoizedState;if(M=j.destroy,b!==null&&Ux(b,j.deps)){I.memoizedState=Vh(f,y,M,b);return}}on.flags|=d,I.memoizedState=Vh(1|f,y,M,b)}function K2(d,f){return Yg(8390656,8,d,f)}function qx(d,f){return Xg(2048,8,d,f)}function W2(d,f){return Xg(4,2,d,f)}function V2(d,f){return Xg(4,4,d,f)}function q2(d,f){if(typeof f=="function")return d=d(),f(d),function(){f(null)};if(f!=null)return d=d(),f.current=d,function(){f.current=null}}function G2(d,f,y){return y=y!=null?y.concat([d]):null,Xg(4,4,q2.bind(null,f,d),y)}function Gx(){}function Y2(d,f){var y=di();f=f===void 0?null:f;var b=y.memoizedState;return b!==null&&f!==null&&Ux(f,b[1])?b[0]:(y.memoizedState=[d,f],d)}function X2(d,f){var y=di();f=f===void 0?null:f;var b=y.memoizedState;return b!==null&&f!==null&&Ux(f,b[1])?b[0]:(d=d(),y.memoizedState=[d,f],d)}function Z2(d,f,y){return(Pc&21)===0?(d.baseState&&(d.baseState=!1,ps=!0),d.memoizedState=y):(Fi(y,f)||(y=xg(),on.lanes|=y,kc|=y,d.baseState=!0),f)}function TW(d,f){var y=xt;xt=y!==0&&4>y?y:4,d(!0);var b=Bx.transition;Bx.transition={};try{d(!1),f()}finally{xt=y,Bx.transition=b}}function J2(){return di().memoizedState}function MW(d,f,y){var b=gl(d);if(y={lane:b,action:y,hasEagerState:!1,eagerState:null,next:null},Q2(d))eM(f,y);else if(y=M2(d,f,y,b),y!==null){var I=Lr();Hi(y,d,b,I),tM(y,f,b)}}function AW(d,f,y){var b=gl(d),I={lane:b,action:y,hasEagerState:!1,eagerState:null,next:null};if(Q2(d))eM(f,I);else{var M=d.alternate;if(d.lanes===0&&(M===null||M.lanes===0)&&(M=f.lastRenderedReducer,M!==null))try{var j=f.lastRenderedState,K=M(j,y);if(I.hasEagerState=!0,I.eagerState=K,Fi(K,j)){var q=f.interleaved;q===null?(I.next=I,jx(f)):(I.next=q.next,q.next=I),f.interleaved=I;return}}catch{}finally{}y=M2(d,f,I,b),y!==null&&(I=Lr(),Hi(y,d,b,I),tM(y,f,b))}}function Q2(d){var f=d.alternate;return d===on||f!==null&&f===on}function eM(d,f){Hh=Gg=!0;var y=d.pending;y===null?f.next=f:(f.next=y.next,y.next=f),d.pending=f}function tM(d,f,y){if((y&4194240)!==0){var b=f.lanes;b&=d.pendingLanes,y|=b,f.lanes=y,Lu(d,y)}}var Zg={readContext:ui,useCallback:gr,useContext:gr,useEffect:gr,useImperativeHandle:gr,useInsertionEffect:gr,useLayoutEffect:gr,useMemo:gr,useReducer:gr,useRef:gr,useState:gr,useDebugValue:gr,useDeferredValue:gr,useTransition:gr,useMutableSource:gr,useSyncExternalStore:gr,useId:gr,unstable_isNewReconciler:!1},OW={readContext:ui,useCallback:function(d,f){return wo().memoizedState=[d,f===void 0?null:f],d},useContext:ui,useEffect:K2,useImperativeHandle:function(d,f,y){return y=y!=null?y.concat([d]):null,Yg(4194308,4,q2.bind(null,f,d),y)},useLayoutEffect:function(d,f){return Yg(4194308,4,d,f)},useInsertionEffect:function(d,f){return Yg(4,2,d,f)},useMemo:function(d,f){var y=wo();return f=f===void 0?null:f,d=d(),y.memoizedState=[d,f],d},useReducer:function(d,f,y){var b=wo();return f=y!==void 0?y(f):f,b.memoizedState=b.baseState=f,d={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:f},b.queue=d,d=d.dispatch=MW.bind(null,on,d),[b.memoizedState,d]},useRef:function(d){var f=wo();return d={current:d},f.memoizedState=d},useState:U2,useDebugValue:Gx,useDeferredValue:function(d){return wo().memoizedState=d},useTransition:function(){var d=U2(!1),f=d[0];return d=TW.bind(null,d[1]),wo().memoizedState=d,[f,d]},useMutableSource:function(){},useSyncExternalStore:function(d,f,y){var b=on,I=wo();if(Qt){if(y===void 0)throw Error(t(407));y=y()}else{if(y=f(),zn===null)throw Error(t(349));(Pc&30)!==0||N2(b,f,y)}I.memoizedState=y;var M={value:y,getSnapshot:f};return I.queue=M,K2(z2.bind(null,b,M,d),[d]),b.flags|=2048,Vh(9,F2.bind(null,b,M,y,f),void 0,null),y},useId:function(){var d=wo(),f=zn.identifierPrefix;if(Qt){var y=oa,b=ia;y=(b&~(1<<32-js(b)-1)).toString(32)+y,f=":"+f+"R"+y,y=Kh++,0<y&&(f+="H"+y.toString(32)),f+=":"}else y=_W++,f=":"+f+"r"+y.toString(32)+":";return d.memoizedState=f},unstable_isNewReconciler:!1},RW={readContext:ui,useCallback:Y2,useContext:ui,useEffect:qx,useImperativeHandle:G2,useInsertionEffect:W2,useLayoutEffect:V2,useMemo:X2,useReducer:Wx,useRef:H2,useState:function(){return Wx(Wh)},useDebugValue:Gx,useDeferredValue:function(d){var f=di();return Z2(f,Rn.memoizedState,d)},useTransition:function(){var d=Wx(Wh)[0],f=di().memoizedState;return[d,f]},useMutableSource:j2,useSyncExternalStore:L2,useId:J2,unstable_isNewReconciler:!1},DW={readContext:ui,useCallback:Y2,useContext:ui,useEffect:qx,useImperativeHandle:G2,useInsertionEffect:W2,useLayoutEffect:V2,useMemo:X2,useReducer:Vx,useRef:H2,useState:function(){return Vx(Wh)},useDebugValue:Gx,useDeferredValue:function(d){var f=di();return Rn===null?f.memoizedState=d:Z2(f,Rn.memoizedState,d)},useTransition:function(){var d=Vx(Wh)[0],f=di().memoizedState;return[d,f]},useMutableSource:j2,useSyncExternalStore:L2,useId:J2,unstable_isNewReconciler:!1};function $i(d,f){if(d&&d.defaultProps){f=ee({},f),d=d.defaultProps;for(var y in d)f[y]===void 0&&(f[y]=d[y]);return f}return f}function Yx(d,f,y,b){f=d.memoizedState,y=y(b,f),y=y==null?f:ee({},f,y),d.memoizedState=y,d.lanes===0&&(d.updateQueue.baseState=y)}var Jg={isMounted:function(d){return(d=d._reactInternals)?ta(d)===d:!1},enqueueSetState:function(d,f,y){d=d._reactInternals;var b=Lr(),I=gl(d),M=la(b,I);M.payload=f,y!=null&&(M.callback=y),f=dl(d,M,I),f!==null&&(Hi(f,d,I,b),Kg(f,d,I))},enqueueReplaceState:function(d,f,y){d=d._reactInternals;var b=Lr(),I=gl(d),M=la(b,I);M.tag=1,M.payload=f,y!=null&&(M.callback=y),f=dl(d,M,I),f!==null&&(Hi(f,d,I,b),Kg(f,d,I))},enqueueForceUpdate:function(d,f){d=d._reactInternals;var y=Lr(),b=gl(d),I=la(y,b);I.tag=2,f!=null&&(I.callback=f),f=dl(d,I,b),f!==null&&(Hi(f,d,b,y),Kg(f,d,b))}};function nM(d,f,y,b,I,M,j){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(b,M,j):f.prototype&&f.prototype.isPureReactComponent?!Oh(y,b)||!Oh(I,M):!0}function rM(d,f,y){var b=!1,I=ll,M=f.contextType;return typeof M=="object"&&M!==null?M=ui(M):(I=fs(f)?vc:pr.current,b=f.contextTypes,M=(b=b!=null)?Vu(d,I):ll),f=new f(y,M),d.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=Jg,d.stateNode=f,f._reactInternals=d,b&&(d=d.stateNode,d.__reactInternalMemoizedUnmaskedChildContext=I,d.__reactInternalMemoizedMaskedChildContext=M),f}function sM(d,f,y,b){d=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(y,b),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(y,b),f.state!==d&&Jg.enqueueReplaceState(f,f.state,null)}function Xx(d,f,y,b){var I=d.stateNode;I.props=y,I.state=d.memoizedState,I.refs={},Lx(d);var M=f.contextType;typeof M=="object"&&M!==null?I.context=ui(M):(M=fs(f)?vc:pr.current,I.context=Vu(d,M)),I.state=d.memoizedState,M=f.getDerivedStateFromProps,typeof M=="function"&&(Yx(d,f,M,y),I.state=d.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(f=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),f!==I.state&&Jg.enqueueReplaceState(I,I.state,null),Wg(d,y,I,b),I.state=d.memoizedState),typeof I.componentDidMount=="function"&&(d.flags|=4194308)}function ed(d,f){try{var y="",b=f;do y+=ue(b),b=b.return;while(b);var I=y}catch(M){I=`
|
|
39
|
-
Error generating stack: `+M.message+`
|
|
40
|
-
`+M.stack}return{value:d,source:f,stack:I,digest:null}}function Zx(d,f,y){return{value:d,source:null,stack:y??null,digest:f??null}}function Jx(d,f){try{console.error(f.value)}catch(y){setTimeout(function(){throw y})}}var jW=typeof WeakMap=="function"?WeakMap:Map;function iM(d,f,y){y=la(-1,y),y.tag=3,y.payload={element:null};var b=f.value;return y.callback=function(){im||(im=!0,fw=b),Jx(d,f)},y}function oM(d,f,y){y=la(-1,y),y.tag=3;var b=d.type.getDerivedStateFromError;if(typeof b=="function"){var I=f.value;y.payload=function(){return b(I)},y.callback=function(){Jx(d,f)}}var M=d.stateNode;return M!==null&&typeof M.componentDidCatch=="function"&&(y.callback=function(){Jx(d,f),typeof b!="function"&&(fl===null?fl=new Set([this]):fl.add(this));var j=f.stack;this.componentDidCatch(f.value,{componentStack:j!==null?j:""})}),y}function aM(d,f,y){var b=d.pingCache;if(b===null){b=d.pingCache=new jW;var I=new Set;b.set(f,I)}else I=b.get(f),I===void 0&&(I=new Set,b.set(f,I));I.has(y)||(I.add(y),d=YW.bind(null,d,f,y),f.then(d,d))}function lM(d){do{var f;if((f=d.tag===13)&&(f=d.memoizedState,f=f!==null?f.dehydrated!==null:!0),f)return d;d=d.return}while(d!==null);return null}function cM(d,f,y,b,I){return(d.mode&1)===0?(d===f?d.flags|=65536:(d.flags|=128,y.flags|=131072,y.flags&=-52805,y.tag===1&&(y.alternate===null?y.tag=17:(f=la(-1,1),f.tag=2,dl(y,f,1))),y.lanes|=1),d):(d.flags|=65536,d.lanes=I,d)}var LW=E.ReactCurrentOwner,ps=!1;function jr(d,f,y,b){f.child=d===null?T2(f,null,y,b):Xu(f,d.child,y,b)}function uM(d,f,y,b,I){y=y.render;var M=f.ref;return Ju(f,I),b=Hx(d,f,y,b,M,I),y=Kx(),d!==null&&!ps?(f.updateQueue=d.updateQueue,f.flags&=-2053,d.lanes&=~I,ca(d,f,I)):(Qt&&y&&Ix(f),f.flags|=1,jr(d,f,b,I),f.child)}function dM(d,f,y,b,I){if(d===null){var M=y.type;return typeof M=="function"&&!xw(M)&&M.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(f.tag=15,f.type=M,hM(d,f,M,b,I)):(d=dm(y.type,null,b,f,f.mode,I),d.ref=f.ref,d.return=f,f.child=d)}if(M=d.child,(d.lanes&I)===0){var j=M.memoizedProps;if(y=y.compare,y=y!==null?y:Oh,y(j,b)&&d.ref===f.ref)return ca(d,f,I)}return f.flags|=1,d=yl(M,b),d.ref=f.ref,d.return=f,f.child=d}function hM(d,f,y,b,I){if(d!==null){var M=d.memoizedProps;if(Oh(M,b)&&d.ref===f.ref)if(ps=!1,f.pendingProps=b=M,(d.lanes&I)!==0)(d.flags&131072)!==0&&(ps=!0);else return f.lanes=d.lanes,ca(d,f,I)}return Qx(d,f,y,b,I)}function fM(d,f,y){var b=f.pendingProps,I=b.children,M=d!==null?d.memoizedState:null;if(b.mode==="hidden")if((f.mode&1)===0)f.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ut(nd,Fs),Fs|=y;else{if((y&1073741824)===0)return d=M!==null?M.baseLanes|y:y,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:d,cachePool:null,transitions:null},f.updateQueue=null,Ut(nd,Fs),Fs|=d,null;f.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=M!==null?M.baseLanes:y,Ut(nd,Fs),Fs|=b}else M!==null?(b=M.baseLanes|y,f.memoizedState=null):b=y,Ut(nd,Fs),Fs|=b;return jr(d,f,I,y),f.child}function pM(d,f){var y=f.ref;(d===null&&y!==null||d!==null&&d.ref!==y)&&(f.flags|=512,f.flags|=2097152)}function Qx(d,f,y,b,I){var M=fs(y)?vc:pr.current;return M=Vu(f,M),Ju(f,I),y=Hx(d,f,y,b,M,I),b=Kx(),d!==null&&!ps?(f.updateQueue=d.updateQueue,f.flags&=-2053,d.lanes&=~I,ca(d,f,I)):(Qt&&b&&Ix(f),f.flags|=1,jr(d,f,y,I),f.child)}function gM(d,f,y,b,I){if(fs(y)){var M=!0;Lg(f)}else M=!1;if(Ju(f,I),f.stateNode===null)em(d,f),rM(f,y,b),Xx(f,y,b,I),b=!0;else if(d===null){var j=f.stateNode,K=f.memoizedProps;j.props=K;var q=j.context,oe=y.contextType;typeof oe=="object"&&oe!==null?oe=ui(oe):(oe=fs(y)?vc:pr.current,oe=Vu(f,oe));var pe=y.getDerivedStateFromProps,ye=typeof pe=="function"||typeof j.getSnapshotBeforeUpdate=="function";ye||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(K!==b||q!==oe)&&sM(f,j,b,oe),ul=!1;var fe=f.memoizedState;j.state=fe,Wg(f,b,j,I),q=f.memoizedState,K!==b||fe!==q||hs.current||ul?(typeof pe=="function"&&(Yx(f,y,pe,b),q=f.memoizedState),(K=ul||nM(f,y,K,b,fe,q,oe))?(ye||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(f.flags|=4194308)):(typeof j.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=b,f.memoizedState=q),j.props=b,j.state=q,j.context=oe,b=K):(typeof j.componentDidMount=="function"&&(f.flags|=4194308),b=!1)}else{j=f.stateNode,A2(d,f),K=f.memoizedProps,oe=f.type===f.elementType?K:$i(f.type,K),j.props=oe,ye=f.pendingProps,fe=j.context,q=y.contextType,typeof q=="object"&&q!==null?q=ui(q):(q=fs(y)?vc:pr.current,q=Vu(f,q));var Me=y.getDerivedStateFromProps;(pe=typeof Me=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(K!==ye||fe!==q)&&sM(f,j,b,q),ul=!1,fe=f.memoizedState,j.state=fe,Wg(f,b,j,I);var Le=f.memoizedState;K!==ye||fe!==Le||hs.current||ul?(typeof Me=="function"&&(Yx(f,y,Me,b),Le=f.memoizedState),(oe=ul||nM(f,y,oe,b,fe,Le,q)||!1)?(pe||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(b,Le,q),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(b,Le,q)),typeof j.componentDidUpdate=="function"&&(f.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof j.componentDidUpdate!="function"||K===d.memoizedProps&&fe===d.memoizedState||(f.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||K===d.memoizedProps&&fe===d.memoizedState||(f.flags|=1024),f.memoizedProps=b,f.memoizedState=Le),j.props=b,j.state=Le,j.context=q,b=oe):(typeof j.componentDidUpdate!="function"||K===d.memoizedProps&&fe===d.memoizedState||(f.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||K===d.memoizedProps&&fe===d.memoizedState||(f.flags|=1024),b=!1)}return ew(d,f,y,b,M,I)}function ew(d,f,y,b,I,M){pM(d,f);var j=(f.flags&128)!==0;if(!b&&!j)return I&&x2(f,y,!1),ca(d,f,M);b=f.stateNode,LW.current=f;var K=j&&typeof y.getDerivedStateFromError!="function"?null:b.render();return f.flags|=1,d!==null&&j?(f.child=Xu(f,d.child,null,M),f.child=Xu(f,null,K,M)):jr(d,f,K,M),f.memoizedState=b.state,I&&x2(f,y,!0),f.child}function mM(d){var f=d.stateNode;f.pendingContext?S2(d,f.pendingContext,f.pendingContext!==f.context):f.context&&S2(d,f.context,!1),Nx(d,f.containerInfo)}function yM(d,f,y,b,I){return Yu(),Mx(I),f.flags|=256,jr(d,f,y,b),f.child}var tw={dehydrated:null,treeContext:null,retryLane:0};function nw(d){return{baseLanes:d,cachePool:null,transitions:null}}function SM(d,f,y){var b=f.pendingProps,I=sn.current,M=!1,j=(f.flags&128)!==0,K;if((K=j)||(K=d!==null&&d.memoizedState===null?!1:(I&2)!==0),K?(M=!0,f.flags&=-129):(d===null||d.memoizedState!==null)&&(I|=1),Ut(sn,I&1),d===null)return Tx(f),d=f.memoizedState,d!==null&&(d=d.dehydrated,d!==null)?((f.mode&1)===0?f.lanes=1:d.data==="$!"?f.lanes=8:f.lanes=1073741824,null):(j=b.children,d=b.fallback,M?(b=f.mode,M=f.child,j={mode:"hidden",children:j},(b&1)===0&&M!==null?(M.childLanes=0,M.pendingProps=j):M=hm(j,b,0,null),d=Tc(d,b,y,null),M.return=f,d.return=f,M.sibling=d,f.child=M,f.child.memoizedState=nw(y),f.memoizedState=tw,d):rw(f,j));if(I=d.memoizedState,I!==null&&(K=I.dehydrated,K!==null))return NW(d,f,j,b,K,I,y);if(M){M=b.fallback,j=f.mode,I=d.child,K=I.sibling;var q={mode:"hidden",children:b.children};return(j&1)===0&&f.child!==I?(b=f.child,b.childLanes=0,b.pendingProps=q,f.deletions=null):(b=yl(I,q),b.subtreeFlags=I.subtreeFlags&14680064),K!==null?M=yl(K,M):(M=Tc(M,j,y,null),M.flags|=2),M.return=f,b.return=f,b.sibling=M,f.child=b,b=M,M=f.child,j=d.child.memoizedState,j=j===null?nw(y):{baseLanes:j.baseLanes|y,cachePool:null,transitions:j.transitions},M.memoizedState=j,M.childLanes=d.childLanes&~y,f.memoizedState=tw,b}return M=d.child,d=M.sibling,b=yl(M,{mode:"visible",children:b.children}),(f.mode&1)===0&&(b.lanes=y),b.return=f,b.sibling=null,d!==null&&(y=f.deletions,y===null?(f.deletions=[d],f.flags|=16):y.push(d)),f.child=b,f.memoizedState=null,b}function rw(d,f){return f=hm({mode:"visible",children:f},d.mode,0,null),f.return=d,d.child=f}function Qg(d,f,y,b){return b!==null&&Mx(b),Xu(f,d.child,null,y),d=rw(f,f.pendingProps.children),d.flags|=2,f.memoizedState=null,d}function NW(d,f,y,b,I,M,j){if(y)return f.flags&256?(f.flags&=-257,b=Zx(Error(t(422))),Qg(d,f,j,b)):f.memoizedState!==null?(f.child=d.child,f.flags|=128,null):(M=b.fallback,I=f.mode,b=hm({mode:"visible",children:b.children},I,0,null),M=Tc(M,I,j,null),M.flags|=2,b.return=f,M.return=f,b.sibling=M,f.child=b,(f.mode&1)!==0&&Xu(f,d.child,null,j),f.child.memoizedState=nw(j),f.memoizedState=tw,M);if((f.mode&1)===0)return Qg(d,f,j,null);if(I.data==="$!"){if(b=I.nextSibling&&I.nextSibling.dataset,b)var K=b.dgst;return b=K,M=Error(t(419)),b=Zx(M,b,void 0),Qg(d,f,j,b)}if(K=(j&d.childLanes)!==0,ps||K){if(b=zn,b!==null){switch(j&-j){case 4:I=2;break;case 16:I=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:I=32;break;case 536870912:I=268435456;break;default:I=0}I=(I&(b.suspendedLanes|j))!==0?0:I,I!==0&&I!==M.retryLane&&(M.retryLane=I,aa(d,I),Hi(b,d,I,-1))}return vw(),b=Zx(Error(t(421))),Qg(d,f,j,b)}return I.data==="$?"?(f.flags|=128,f.child=d.child,f=XW.bind(null,d),I._reactRetry=f,null):(d=M.treeContext,Ns=ol(I.nextSibling),Ls=f,Qt=!0,zi=null,d!==null&&(li[ci++]=ia,li[ci++]=oa,li[ci++]=xc,ia=d.id,oa=d.overflow,xc=f),f=rw(f,b.children),f.flags|=4096,f)}function vM(d,f,y){d.lanes|=f;var b=d.alternate;b!==null&&(b.lanes|=f),Dx(d.return,f,y)}function sw(d,f,y,b,I){var M=d.memoizedState;M===null?d.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:b,tail:y,tailMode:I}:(M.isBackwards=f,M.rendering=null,M.renderingStartTime=0,M.last=b,M.tail=y,M.tailMode=I)}function xM(d,f,y){var b=f.pendingProps,I=b.revealOrder,M=b.tail;if(jr(d,f,b.children,y),b=sn.current,(b&2)!==0)b=b&1|2,f.flags|=128;else{if(d!==null&&(d.flags&128)!==0)e:for(d=f.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&vM(d,y,f);else if(d.tag===19)vM(d,y,f);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===f)break e;for(;d.sibling===null;){if(d.return===null||d.return===f)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}b&=1}if(Ut(sn,b),(f.mode&1)===0)f.memoizedState=null;else switch(I){case"forwards":for(y=f.child,I=null;y!==null;)d=y.alternate,d!==null&&Vg(d)===null&&(I=y),y=y.sibling;y=I,y===null?(I=f.child,f.child=null):(I=y.sibling,y.sibling=null),sw(f,!1,I,y,M);break;case"backwards":for(y=null,I=f.child,f.child=null;I!==null;){if(d=I.alternate,d!==null&&Vg(d)===null){f.child=I;break}d=I.sibling,I.sibling=y,y=I,I=d}sw(f,!0,y,null,M);break;case"together":sw(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function em(d,f){(f.mode&1)===0&&d!==null&&(d.alternate=null,f.alternate=null,f.flags|=2)}function ca(d,f,y){if(d!==null&&(f.dependencies=d.dependencies),kc|=f.lanes,(y&f.childLanes)===0)return null;if(d!==null&&f.child!==d.child)throw Error(t(153));if(f.child!==null){for(d=f.child,y=yl(d,d.pendingProps),f.child=y,y.return=f;d.sibling!==null;)d=d.sibling,y=y.sibling=yl(d,d.pendingProps),y.return=f;y.sibling=null}return f.child}function FW(d,f,y){switch(f.tag){case 3:mM(f),Yu();break;case 5:D2(f);break;case 1:fs(f.type)&&Lg(f);break;case 4:Nx(f,f.stateNode.containerInfo);break;case 10:var b=f.type._context,I=f.memoizedProps.value;Ut(Ug,b._currentValue),b._currentValue=I;break;case 13:if(b=f.memoizedState,b!==null)return b.dehydrated!==null?(Ut(sn,sn.current&1),f.flags|=128,null):(y&f.child.childLanes)!==0?SM(d,f,y):(Ut(sn,sn.current&1),d=ca(d,f,y),d!==null?d.sibling:null);Ut(sn,sn.current&1);break;case 19:if(b=(y&f.childLanes)!==0,(d.flags&128)!==0){if(b)return xM(d,f,y);f.flags|=128}if(I=f.memoizedState,I!==null&&(I.rendering=null,I.tail=null,I.lastEffect=null),Ut(sn,sn.current),b)break;return null;case 22:case 23:return f.lanes=0,fM(d,f,y)}return ca(d,f,y)}var wM,iw,bM,CM;wM=function(d,f){for(var y=f.child;y!==null;){if(y.tag===5||y.tag===6)d.appendChild(y.stateNode);else if(y.tag!==4&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===f)break;for(;y.sibling===null;){if(y.return===null||y.return===f)return;y=y.return}y.sibling.return=y.return,y=y.sibling}},iw=function(){},bM=function(d,f,y,b){var I=d.memoizedProps;if(I!==b){d=f.stateNode,Cc(xo.current);var M=null;switch(y){case"input":I=Tt(d,I),b=Tt(d,b),M=[];break;case"select":I=ee({},I,{value:void 0}),b=ee({},b,{value:void 0}),M=[];break;case"textarea":I=lc(d,I),b=lc(d,b),M=[];break;default:typeof I.onClick!="function"&&typeof b.onClick=="function"&&(d.onclick=Rg)}Qo(y,b);var j;y=null;for(oe in I)if(!b.hasOwnProperty(oe)&&I.hasOwnProperty(oe)&&I[oe]!=null)if(oe==="style"){var K=I[oe];for(j in K)K.hasOwnProperty(j)&&(y||(y={}),y[j]="")}else oe!=="dangerouslySetInnerHTML"&&oe!=="children"&&oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&oe!=="autoFocus"&&(s.hasOwnProperty(oe)?M||(M=[]):(M=M||[]).push(oe,null));for(oe in b){var q=b[oe];if(K=I!=null?I[oe]:void 0,b.hasOwnProperty(oe)&&q!==K&&(q!=null||K!=null))if(oe==="style")if(K){for(j in K)!K.hasOwnProperty(j)||q&&q.hasOwnProperty(j)||(y||(y={}),y[j]="");for(j in q)q.hasOwnProperty(j)&&K[j]!==q[j]&&(y||(y={}),y[j]=q[j])}else y||(M||(M=[]),M.push(oe,y)),y=q;else oe==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,K=K?K.__html:void 0,q!=null&&K!==q&&(M=M||[]).push(oe,q)):oe==="children"?typeof q!="string"&&typeof q!="number"||(M=M||[]).push(oe,""+q):oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&(s.hasOwnProperty(oe)?(q!=null&&oe==="onScroll"&&Vt("scroll",d),M||K===q||(M=[])):(M=M||[]).push(oe,q))}y&&(M=M||[]).push("style",y);var oe=M;(f.updateQueue=oe)&&(f.flags|=4)}},CM=function(d,f,y,b){y!==b&&(f.flags|=4)};function qh(d,f){if(!Qt)switch(d.tailMode){case"hidden":f=d.tail;for(var y=null;f!==null;)f.alternate!==null&&(y=f),f=f.sibling;y===null?d.tail=null:y.sibling=null;break;case"collapsed":y=d.tail;for(var b=null;y!==null;)y.alternate!==null&&(b=y),y=y.sibling;b===null?f||d.tail===null?d.tail=null:d.tail.sibling=null:b.sibling=null}}function mr(d){var f=d.alternate!==null&&d.alternate.child===d.child,y=0,b=0;if(f)for(var I=d.child;I!==null;)y|=I.lanes|I.childLanes,b|=I.subtreeFlags&14680064,b|=I.flags&14680064,I.return=d,I=I.sibling;else for(I=d.child;I!==null;)y|=I.lanes|I.childLanes,b|=I.subtreeFlags,b|=I.flags,I.return=d,I=I.sibling;return d.subtreeFlags|=b,d.childLanes=y,f}function zW(d,f,y){var b=f.pendingProps;switch(Ex(f),f.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mr(f),null;case 1:return fs(f.type)&&jg(),mr(f),null;case 3:return b=f.stateNode,Qu(),qt(hs),qt(pr),$x(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(d===null||d.child===null)&&($g(f)?f.flags|=4:d===null||d.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,zi!==null&&(mw(zi),zi=null))),iw(d,f),mr(f),null;case 5:Fx(f);var I=Cc(Uh.current);if(y=f.type,d!==null&&f.stateNode!=null)bM(d,f,y,b,I),d.ref!==f.ref&&(f.flags|=512,f.flags|=2097152);else{if(!b){if(f.stateNode===null)throw Error(t(166));return mr(f),null}if(d=Cc(xo.current),$g(f)){b=f.stateNode,y=f.type;var M=f.memoizedProps;switch(b[vo]=f,b[Nh]=M,d=(f.mode&1)!==0,y){case"dialog":Vt("cancel",b),Vt("close",b);break;case"iframe":case"object":case"embed":Vt("load",b);break;case"video":case"audio":for(I=0;I<Dh.length;I++)Vt(Dh[I],b);break;case"source":Vt("error",b);break;case"img":case"image":case"link":Vt("error",b),Vt("load",b);break;case"details":Vt("toggle",b);break;case"input":nn(b,M),Vt("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!M.multiple},Vt("invalid",b);break;case"textarea":Cu(b,M),Vt("invalid",b)}Qo(y,M),I=null;for(var j in M)if(M.hasOwnProperty(j)){var K=M[j];j==="children"?typeof K=="string"?b.textContent!==K&&(M.suppressHydrationWarning!==!0&&Og(b.textContent,K,d),I=["children",K]):typeof K=="number"&&b.textContent!==""+K&&(M.suppressHydrationWarning!==!0&&Og(b.textContent,K,d),I=["children",""+K]):s.hasOwnProperty(j)&&K!=null&&j==="onScroll"&&Vt("scroll",b)}switch(y){case"input":Lt(b),ss(b,M,!0);break;case"textarea":Lt(b),ku(b);break;case"select":case"option":break;default:typeof M.onClick=="function"&&(b.onclick=Rg)}b=I,f.updateQueue=b,b!==null&&(f.flags|=4)}else{j=I.nodeType===9?I:I.ownerDocument,d==="http://www.w3.org/1999/xhtml"&&(d=Iu(y)),d==="http://www.w3.org/1999/xhtml"?y==="script"?(d=j.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild)):typeof b.is=="string"?d=j.createElement(y,{is:b.is}):(d=j.createElement(y),y==="select"&&(j=d,b.multiple?j.multiple=!0:b.size&&(j.size=b.size))):d=j.createElementNS(d,y),d[vo]=f,d[Nh]=b,wM(d,f,!1,!1),f.stateNode=d;e:{switch(j=Os(y,b),y){case"dialog":Vt("cancel",d),Vt("close",d),I=b;break;case"iframe":case"object":case"embed":Vt("load",d),I=b;break;case"video":case"audio":for(I=0;I<Dh.length;I++)Vt(Dh[I],d);I=b;break;case"source":Vt("error",d),I=b;break;case"img":case"image":case"link":Vt("error",d),Vt("load",d),I=b;break;case"details":Vt("toggle",d),I=b;break;case"input":nn(d,b),I=Tt(d,b),Vt("invalid",d);break;case"option":I=b;break;case"select":d._wrapperState={wasMultiple:!!b.multiple},I=ee({},b,{value:void 0}),Vt("invalid",d);break;case"textarea":Cu(d,b),I=lc(d,b),Vt("invalid",d);break;default:I=b}Qo(y,I),K=I;for(M in K)if(K.hasOwnProperty(M)){var q=K[M];M==="style"?si(d,q):M==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,q!=null&&cc(d,q)):M==="children"?typeof q=="string"?(y!=="textarea"||q!=="")&&ae(d,q):typeof q=="number"&&ae(d,""+q):M!=="suppressContentEditableWarning"&&M!=="suppressHydrationWarning"&&M!=="autoFocus"&&(s.hasOwnProperty(M)?q!=null&&M==="onScroll"&&Vt("scroll",d):q!=null&&_(d,M,q,j))}switch(y){case"input":Lt(d),ss(d,b,!1);break;case"textarea":Lt(d),ku(d);break;case"option":b.value!=null&&d.setAttribute("value",""+be(b.value));break;case"select":d.multiple=!!b.multiple,M=b.value,M!=null?ri(d,!!b.multiple,M,!1):b.defaultValue!=null&&ri(d,!!b.multiple,b.defaultValue,!0);break;default:typeof I.onClick=="function"&&(d.onclick=Rg)}switch(y){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(f.flags|=4)}f.ref!==null&&(f.flags|=512,f.flags|=2097152)}return mr(f),null;case 6:if(d&&f.stateNode!=null)CM(d,f,d.memoizedProps,b);else{if(typeof b!="string"&&f.stateNode===null)throw Error(t(166));if(y=Cc(Uh.current),Cc(xo.current),$g(f)){if(b=f.stateNode,y=f.memoizedProps,b[vo]=f,(M=b.nodeValue!==y)&&(d=Ls,d!==null))switch(d.tag){case 3:Og(b.nodeValue,y,(d.mode&1)!==0);break;case 5:d.memoizedProps.suppressHydrationWarning!==!0&&Og(b.nodeValue,y,(d.mode&1)!==0)}M&&(f.flags|=4)}else b=(y.nodeType===9?y:y.ownerDocument).createTextNode(b),b[vo]=f,f.stateNode=b}return mr(f),null;case 13:if(qt(sn),b=f.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(Qt&&Ns!==null&&(f.mode&1)!==0&&(f.flags&128)===0)I2(),Yu(),f.flags|=98560,M=!1;else if(M=$g(f),b!==null&&b.dehydrated!==null){if(d===null){if(!M)throw Error(t(318));if(M=f.memoizedState,M=M!==null?M.dehydrated:null,!M)throw Error(t(317));M[vo]=f}else Yu(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;mr(f),M=!1}else zi!==null&&(mw(zi),zi=null),M=!0;if(!M)return f.flags&65536?f:null}return(f.flags&128)!==0?(f.lanes=y,f):(b=b!==null,b!==(d!==null&&d.memoizedState!==null)&&b&&(f.child.flags|=8192,(f.mode&1)!==0&&(d===null||(sn.current&1)!==0?Dn===0&&(Dn=3):vw())),f.updateQueue!==null&&(f.flags|=4),mr(f),null);case 4:return Qu(),iw(d,f),d===null&&jh(f.stateNode.containerInfo),mr(f),null;case 10:return Rx(f.type._context),mr(f),null;case 17:return fs(f.type)&&jg(),mr(f),null;case 19:if(qt(sn),M=f.memoizedState,M===null)return mr(f),null;if(b=(f.flags&128)!==0,j=M.rendering,j===null)if(b)qh(M,!1);else{if(Dn!==0||d!==null&&(d.flags&128)!==0)for(d=f.child;d!==null;){if(j=Vg(d),j!==null){for(f.flags|=128,qh(M,!1),b=j.updateQueue,b!==null&&(f.updateQueue=b,f.flags|=4),f.subtreeFlags=0,b=y,y=f.child;y!==null;)M=y,d=b,M.flags&=14680066,j=M.alternate,j===null?(M.childLanes=0,M.lanes=d,M.child=null,M.subtreeFlags=0,M.memoizedProps=null,M.memoizedState=null,M.updateQueue=null,M.dependencies=null,M.stateNode=null):(M.childLanes=j.childLanes,M.lanes=j.lanes,M.child=j.child,M.subtreeFlags=0,M.deletions=null,M.memoizedProps=j.memoizedProps,M.memoizedState=j.memoizedState,M.updateQueue=j.updateQueue,M.type=j.type,d=j.dependencies,M.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext}),y=y.sibling;return Ut(sn,sn.current&1|2),f.child}d=d.sibling}M.tail!==null&&rn()>rd&&(f.flags|=128,b=!0,qh(M,!1),f.lanes=4194304)}else{if(!b)if(d=Vg(j),d!==null){if(f.flags|=128,b=!0,y=d.updateQueue,y!==null&&(f.updateQueue=y,f.flags|=4),qh(M,!0),M.tail===null&&M.tailMode==="hidden"&&!j.alternate&&!Qt)return mr(f),null}else 2*rn()-M.renderingStartTime>rd&&y!==1073741824&&(f.flags|=128,b=!0,qh(M,!1),f.lanes=4194304);M.isBackwards?(j.sibling=f.child,f.child=j):(y=M.last,y!==null?y.sibling=j:f.child=j,M.last=j)}return M.tail!==null?(f=M.tail,M.rendering=f,M.tail=f.sibling,M.renderingStartTime=rn(),f.sibling=null,y=sn.current,Ut(sn,b?y&1|2:y&1),f):(mr(f),null);case 22:case 23:return Sw(),b=f.memoizedState!==null,d!==null&&d.memoizedState!==null!==b&&(f.flags|=8192),b&&(f.mode&1)!==0?(Fs&1073741824)!==0&&(mr(f),f.subtreeFlags&6&&(f.flags|=8192)):mr(f),null;case 24:return null;case 25:return null}throw Error(t(156,f.tag))}function $W(d,f){switch(Ex(f),f.tag){case 1:return fs(f.type)&&jg(),d=f.flags,d&65536?(f.flags=d&-65537|128,f):null;case 3:return Qu(),qt(hs),qt(pr),$x(),d=f.flags,(d&65536)!==0&&(d&128)===0?(f.flags=d&-65537|128,f):null;case 5:return Fx(f),null;case 13:if(qt(sn),d=f.memoizedState,d!==null&&d.dehydrated!==null){if(f.alternate===null)throw Error(t(340));Yu()}return d=f.flags,d&65536?(f.flags=d&-65537|128,f):null;case 19:return qt(sn),null;case 4:return Qu(),null;case 10:return Rx(f.type._context),null;case 22:case 23:return Sw(),null;case 24:return null;default:return null}}var tm=!1,yr=!1,BW=typeof WeakSet=="function"?WeakSet:Set,Re=null;function td(d,f){var y=d.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(b){fn(d,f,b)}else y.current=null}function ow(d,f,y){try{y()}catch(b){fn(d,f,b)}}var PM=!1;function UW(d,f){if(Sx=Z,d=n2(),ux(d)){if("selectionStart"in d)var y={start:d.selectionStart,end:d.selectionEnd};else e:{y=(y=d.ownerDocument)&&y.defaultView||window;var b=y.getSelection&&y.getSelection();if(b&&b.rangeCount!==0){y=b.anchorNode;var I=b.anchorOffset,M=b.focusNode;b=b.focusOffset;try{y.nodeType,M.nodeType}catch{y=null;break e}var j=0,K=-1,q=-1,oe=0,pe=0,ye=d,fe=null;t:for(;;){for(var Me;ye!==y||I!==0&&ye.nodeType!==3||(K=j+I),ye!==M||b!==0&&ye.nodeType!==3||(q=j+b),ye.nodeType===3&&(j+=ye.nodeValue.length),(Me=ye.firstChild)!==null;)fe=ye,ye=Me;for(;;){if(ye===d)break t;if(fe===y&&++oe===I&&(K=j),fe===M&&++pe===b&&(q=j),(Me=ye.nextSibling)!==null)break;ye=fe,fe=ye.parentNode}ye=Me}y=K===-1||q===-1?null:{start:K,end:q}}else y=null}y=y||{start:0,end:0}}else y=null;for(vx={focusedElem:d,selectionRange:y},Z=!1,Re=f;Re!==null;)if(f=Re,d=f.child,(f.subtreeFlags&1028)!==0&&d!==null)d.return=f,Re=d;else for(;Re!==null;){f=Re;try{var Le=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(Le!==null){var ze=Le.memoizedProps,wn=Le.memoizedState,ne=f.stateNode,X=ne.getSnapshotBeforeUpdate(f.elementType===f.type?ze:$i(f.type,ze),wn);ne.__reactInternalSnapshotBeforeUpdate=X}break;case 3:var se=f.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(xe){fn(f,f.return,xe)}if(d=f.sibling,d!==null){d.return=f.return,Re=d;break}Re=f.return}return Le=PM,PM=!1,Le}function Gh(d,f,y){var b=f.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var I=b=b.next;do{if((I.tag&d)===d){var M=I.destroy;I.destroy=void 0,M!==void 0&&ow(f,y,M)}I=I.next}while(I!==b)}}function nm(d,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var y=f=f.next;do{if((y.tag&d)===d){var b=y.create;y.destroy=b()}y=y.next}while(y!==f)}}function aw(d){var f=d.ref;if(f!==null){var y=d.stateNode;switch(d.tag){case 5:d=y;break;default:d=y}typeof f=="function"?f(d):f.current=d}}function kM(d){var f=d.alternate;f!==null&&(d.alternate=null,kM(f)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(f=d.stateNode,f!==null&&(delete f[vo],delete f[Nh],delete f[Cx],delete f[PW],delete f[kW])),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}function IM(d){return d.tag===5||d.tag===3||d.tag===4}function EM(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||IM(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function lw(d,f,y){var b=d.tag;if(b===5||b===6)d=d.stateNode,f?y.nodeType===8?y.parentNode.insertBefore(d,f):y.insertBefore(d,f):(y.nodeType===8?(f=y.parentNode,f.insertBefore(d,y)):(f=y,f.appendChild(d)),y=y._reactRootContainer,y!=null||f.onclick!==null||(f.onclick=Rg));else if(b!==4&&(d=d.child,d!==null))for(lw(d,f,y),d=d.sibling;d!==null;)lw(d,f,y),d=d.sibling}function cw(d,f,y){var b=d.tag;if(b===5||b===6)d=d.stateNode,f?y.insertBefore(d,f):y.appendChild(d);else if(b!==4&&(d=d.child,d!==null))for(cw(d,f,y),d=d.sibling;d!==null;)cw(d,f,y),d=d.sibling}var Zn=null,Bi=!1;function hl(d,f,y){for(y=y.child;y!==null;)_M(d,f,y),y=y.sibling}function _M(d,f,y){if(ai&&typeof ai.onCommitFiberUnmount=="function")try{ai.onCommitFiberUnmount(Ou,y)}catch{}switch(y.tag){case 5:yr||td(y,f);case 6:var b=Zn,I=Bi;Zn=null,hl(d,f,y),Zn=b,Bi=I,Zn!==null&&(Bi?(d=Zn,y=y.stateNode,d.nodeType===8?d.parentNode.removeChild(y):d.removeChild(y)):Zn.removeChild(y.stateNode));break;case 18:Zn!==null&&(Bi?(d=Zn,y=y.stateNode,d.nodeType===8?bx(d.parentNode,y):d.nodeType===1&&bx(d,y),yc(d)):bx(Zn,y.stateNode));break;case 4:b=Zn,I=Bi,Zn=y.stateNode.containerInfo,Bi=!0,hl(d,f,y),Zn=b,Bi=I;break;case 0:case 11:case 14:case 15:if(!yr&&(b=y.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){I=b=b.next;do{var M=I,j=M.destroy;M=M.tag,j!==void 0&&((M&2)!==0||(M&4)!==0)&&ow(y,f,j),I=I.next}while(I!==b)}hl(d,f,y);break;case 1:if(!yr&&(td(y,f),b=y.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=y.memoizedProps,b.state=y.memoizedState,b.componentWillUnmount()}catch(K){fn(y,f,K)}hl(d,f,y);break;case 21:hl(d,f,y);break;case 22:y.mode&1?(yr=(b=yr)||y.memoizedState!==null,hl(d,f,y),yr=b):hl(d,f,y);break;default:hl(d,f,y)}}function TM(d){var f=d.updateQueue;if(f!==null){d.updateQueue=null;var y=d.stateNode;y===null&&(y=d.stateNode=new BW),f.forEach(function(b){var I=ZW.bind(null,d,b);y.has(b)||(y.add(b),b.then(I,I))})}}function Ui(d,f){var y=f.deletions;if(y!==null)for(var b=0;b<y.length;b++){var I=y[b];try{var M=d,j=f,K=j;e:for(;K!==null;){switch(K.tag){case 5:Zn=K.stateNode,Bi=!1;break e;case 3:Zn=K.stateNode.containerInfo,Bi=!0;break e;case 4:Zn=K.stateNode.containerInfo,Bi=!0;break e}K=K.return}if(Zn===null)throw Error(t(160));_M(M,j,I),Zn=null,Bi=!1;var q=I.alternate;q!==null&&(q.return=null),I.return=null}catch(oe){fn(I,f,oe)}}if(f.subtreeFlags&12854)for(f=f.child;f!==null;)MM(f,d),f=f.sibling}function MM(d,f){var y=d.alternate,b=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:if(Ui(f,d),bo(d),b&4){try{Gh(3,d,d.return),nm(3,d)}catch(ze){fn(d,d.return,ze)}try{Gh(5,d,d.return)}catch(ze){fn(d,d.return,ze)}}break;case 1:Ui(f,d),bo(d),b&512&&y!==null&&td(y,y.return);break;case 5:if(Ui(f,d),bo(d),b&512&&y!==null&&td(y,y.return),d.flags&32){var I=d.stateNode;try{ae(I,"")}catch(ze){fn(d,d.return,ze)}}if(b&4&&(I=d.stateNode,I!=null)){var M=d.memoizedProps,j=y!==null?y.memoizedProps:M,K=d.type,q=d.updateQueue;if(d.updateQueue=null,q!==null)try{K==="input"&&M.type==="radio"&&M.name!=null&&In(I,M),Os(K,j);var oe=Os(K,M);for(j=0;j<q.length;j+=2){var pe=q[j],ye=q[j+1];pe==="style"?si(I,ye):pe==="dangerouslySetInnerHTML"?cc(I,ye):pe==="children"?ae(I,ye):_(I,pe,ye,oe)}switch(K){case"input":rs(I,M);break;case"textarea":Pu(I,M);break;case"select":var fe=I._wrapperState.wasMultiple;I._wrapperState.wasMultiple=!!M.multiple;var Me=M.value;Me!=null?ri(I,!!M.multiple,Me,!1):fe!==!!M.multiple&&(M.defaultValue!=null?ri(I,!!M.multiple,M.defaultValue,!0):ri(I,!!M.multiple,M.multiple?[]:"",!1))}I[Nh]=M}catch(ze){fn(d,d.return,ze)}}break;case 6:if(Ui(f,d),bo(d),b&4){if(d.stateNode===null)throw Error(t(162));I=d.stateNode,M=d.memoizedProps;try{I.nodeValue=M}catch(ze){fn(d,d.return,ze)}}break;case 3:if(Ui(f,d),bo(d),b&4&&y!==null&&y.memoizedState.isDehydrated)try{yc(f.containerInfo)}catch(ze){fn(d,d.return,ze)}break;case 4:Ui(f,d),bo(d);break;case 13:Ui(f,d),bo(d),I=d.child,I.flags&8192&&(M=I.memoizedState!==null,I.stateNode.isHidden=M,!M||I.alternate!==null&&I.alternate.memoizedState!==null||(hw=rn())),b&4&&TM(d);break;case 22:if(pe=y!==null&&y.memoizedState!==null,d.mode&1?(yr=(oe=yr)||pe,Ui(f,d),yr=oe):Ui(f,d),bo(d),b&8192){if(oe=d.memoizedState!==null,(d.stateNode.isHidden=oe)&&!pe&&(d.mode&1)!==0)for(Re=d,pe=d.child;pe!==null;){for(ye=Re=pe;Re!==null;){switch(fe=Re,Me=fe.child,fe.tag){case 0:case 11:case 14:case 15:Gh(4,fe,fe.return);break;case 1:td(fe,fe.return);var Le=fe.stateNode;if(typeof Le.componentWillUnmount=="function"){b=fe,y=fe.return;try{f=b,Le.props=f.memoizedProps,Le.state=f.memoizedState,Le.componentWillUnmount()}catch(ze){fn(b,y,ze)}}break;case 5:td(fe,fe.return);break;case 22:if(fe.memoizedState!==null){RM(ye);continue}}Me!==null?(Me.return=fe,Re=Me):RM(ye)}pe=pe.sibling}e:for(pe=null,ye=d;;){if(ye.tag===5){if(pe===null){pe=ye;try{I=ye.stateNode,oe?(M=I.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none"):(K=ye.stateNode,q=ye.memoizedProps.style,j=q!=null&&q.hasOwnProperty("display")?q.display:null,K.style.display=At("display",j))}catch(ze){fn(d,d.return,ze)}}}else if(ye.tag===6){if(pe===null)try{ye.stateNode.nodeValue=oe?"":ye.memoizedProps}catch(ze){fn(d,d.return,ze)}}else if((ye.tag!==22&&ye.tag!==23||ye.memoizedState===null||ye===d)&&ye.child!==null){ye.child.return=ye,ye=ye.child;continue}if(ye===d)break e;for(;ye.sibling===null;){if(ye.return===null||ye.return===d)break e;pe===ye&&(pe=null),ye=ye.return}pe===ye&&(pe=null),ye.sibling.return=ye.return,ye=ye.sibling}}break;case 19:Ui(f,d),bo(d),b&4&&TM(d);break;case 21:break;default:Ui(f,d),bo(d)}}function bo(d){var f=d.flags;if(f&2){try{e:{for(var y=d.return;y!==null;){if(IM(y)){var b=y;break e}y=y.return}throw Error(t(160))}switch(b.tag){case 5:var I=b.stateNode;b.flags&32&&(ae(I,""),b.flags&=-33);var M=EM(d);cw(d,M,I);break;case 3:case 4:var j=b.stateNode.containerInfo,K=EM(d);lw(d,K,j);break;default:throw Error(t(161))}}catch(q){fn(d,d.return,q)}d.flags&=-3}f&4096&&(d.flags&=-4097)}function HW(d,f,y){Re=d,AM(d)}function AM(d,f,y){for(var b=(d.mode&1)!==0;Re!==null;){var I=Re,M=I.child;if(I.tag===22&&b){var j=I.memoizedState!==null||tm;if(!j){var K=I.alternate,q=K!==null&&K.memoizedState!==null||yr;K=tm;var oe=yr;if(tm=j,(yr=q)&&!oe)for(Re=I;Re!==null;)j=Re,q=j.child,j.tag===22&&j.memoizedState!==null?DM(I):q!==null?(q.return=j,Re=q):DM(I);for(;M!==null;)Re=M,AM(M),M=M.sibling;Re=I,tm=K,yr=oe}OM(d)}else(I.subtreeFlags&8772)!==0&&M!==null?(M.return=I,Re=M):OM(d)}}function OM(d){for(;Re!==null;){var f=Re;if((f.flags&8772)!==0){var y=f.alternate;try{if((f.flags&8772)!==0)switch(f.tag){case 0:case 11:case 15:yr||nm(5,f);break;case 1:var b=f.stateNode;if(f.flags&4&&!yr)if(y===null)b.componentDidMount();else{var I=f.elementType===f.type?y.memoizedProps:$i(f.type,y.memoizedProps);b.componentDidUpdate(I,y.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var M=f.updateQueue;M!==null&&R2(f,M,b);break;case 3:var j=f.updateQueue;if(j!==null){if(y=null,f.child!==null)switch(f.child.tag){case 5:y=f.child.stateNode;break;case 1:y=f.child.stateNode}R2(f,j,y)}break;case 5:var K=f.stateNode;if(y===null&&f.flags&4){y=K;var q=f.memoizedProps;switch(f.type){case"button":case"input":case"select":case"textarea":q.autoFocus&&y.focus();break;case"img":q.src&&(y.src=q.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(f.memoizedState===null){var oe=f.alternate;if(oe!==null){var pe=oe.memoizedState;if(pe!==null){var ye=pe.dehydrated;ye!==null&&yc(ye)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}yr||f.flags&512&&aw(f)}catch(fe){fn(f,f.return,fe)}}if(f===d){Re=null;break}if(y=f.sibling,y!==null){y.return=f.return,Re=y;break}Re=f.return}}function RM(d){for(;Re!==null;){var f=Re;if(f===d){Re=null;break}var y=f.sibling;if(y!==null){y.return=f.return,Re=y;break}Re=f.return}}function DM(d){for(;Re!==null;){var f=Re;try{switch(f.tag){case 0:case 11:case 15:var y=f.return;try{nm(4,f)}catch(q){fn(f,y,q)}break;case 1:var b=f.stateNode;if(typeof b.componentDidMount=="function"){var I=f.return;try{b.componentDidMount()}catch(q){fn(f,I,q)}}var M=f.return;try{aw(f)}catch(q){fn(f,M,q)}break;case 5:var j=f.return;try{aw(f)}catch(q){fn(f,j,q)}}}catch(q){fn(f,f.return,q)}if(f===d){Re=null;break}var K=f.sibling;if(K!==null){K.return=f.return,Re=K;break}Re=f.return}}var KW=Math.ceil,rm=E.ReactCurrentDispatcher,uw=E.ReactCurrentOwner,hi=E.ReactCurrentBatchConfig,bt=0,zn=null,En=null,Jn=0,Fs=0,nd=al(0),Dn=0,Yh=null,kc=0,sm=0,dw=0,Xh=null,gs=null,hw=0,rd=1/0,ua=null,im=!1,fw=null,fl=null,om=!1,pl=null,am=0,Zh=0,pw=null,lm=-1,cm=0;function Lr(){return(bt&6)!==0?rn():lm!==-1?lm:lm=rn()}function gl(d){return(d.mode&1)===0?1:(bt&2)!==0&&Jn!==0?Jn&-Jn:EW.transition!==null?(cm===0&&(cm=xg()),cm):(d=xt,d!==0||(d=window.event,d=d===void 0?16:vn(d.type)),d)}function Hi(d,f,y,b){if(50<Zh)throw Zh=0,pw=null,Error(t(185));pc(d,y,b),((bt&2)===0||d!==zn)&&(d===zn&&((bt&2)===0&&(sm|=y),Dn===4&&ml(d,Jn)),ms(d,b),y===1&&bt===0&&(f.mode&1)===0&&(rd=rn()+500,Ng&&cl()))}function ms(d,f){var y=d.callbackNode;tx(d,f);var b=fc(d,d===zn?Jn:0);if(b===0)y!==null&&fo(y),d.callbackNode=null,d.callbackPriority=0;else if(f=b&-b,d.callbackPriority!==f){if(y!=null&&fo(y),f===1)d.tag===0?IW(LM.bind(null,d)):w2(LM.bind(null,d)),bW(function(){(bt&6)===0&&cl()}),y=null;else{switch(na(b)){case 1:y=wh;break;case 4:y=hc;break;case 16:y=Au;break;case 536870912:y=Di;break;default:y=Au}y=KM(y,jM.bind(null,d))}d.callbackPriority=f,d.callbackNode=y}}function jM(d,f){if(lm=-1,cm=0,(bt&6)!==0)throw Error(t(327));var y=d.callbackNode;if(sd()&&d.callbackNode!==y)return null;var b=fc(d,d===zn?Jn:0);if(b===0)return null;if((b&30)!==0||(b&d.expiredLanes)!==0||f)f=um(d,b);else{f=b;var I=bt;bt|=2;var M=FM();(zn!==d||Jn!==f)&&(ua=null,rd=rn()+500,Ec(d,f));do try{qW();break}catch(K){NM(d,K)}while(!0);Ox(),rm.current=M,bt=I,En!==null?f=0:(zn=null,Jn=0,f=Dn)}if(f!==0){if(f===2&&(I=bh(d),I!==0&&(b=I,f=gw(d,I))),f===1)throw y=Yh,Ec(d,0),ml(d,b),ms(d,rn()),y;if(f===6)ml(d,b);else{if(I=d.current.alternate,(b&30)===0&&!WW(I)&&(f=um(d,b),f===2&&(M=bh(d),M!==0&&(b=M,f=gw(d,M))),f===1))throw y=Yh,Ec(d,0),ml(d,b),ms(d,rn()),y;switch(d.finishedWork=I,d.finishedLanes=b,f){case 0:case 1:throw Error(t(345));case 2:_c(d,gs,ua);break;case 3:if(ml(d,b),(b&130023424)===b&&(f=hw+500-rn(),10<f)){if(fc(d,0)!==0)break;if(I=d.suspendedLanes,(I&b)!==b){Lr(),d.pingedLanes|=d.suspendedLanes&I;break}d.timeoutHandle=wx(_c.bind(null,d,gs,ua),f);break}_c(d,gs,ua);break;case 4:if(ml(d,b),(b&4194240)===b)break;for(f=d.eventTimes,I=-1;0<b;){var j=31-js(b);M=1<<j,j=f[j],j>I&&(I=j),b&=~M}if(b=I,b=rn()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*KW(b/1960))-b,10<b){d.timeoutHandle=wx(_c.bind(null,d,gs,ua),b);break}_c(d,gs,ua);break;case 5:_c(d,gs,ua);break;default:throw Error(t(329))}}}return ms(d,rn()),d.callbackNode===y?jM.bind(null,d):null}function gw(d,f){var y=Xh;return d.current.memoizedState.isDehydrated&&(Ec(d,f).flags|=256),d=um(d,f),d!==2&&(f=gs,gs=y,f!==null&&mw(f)),d}function mw(d){gs===null?gs=d:gs.push.apply(gs,d)}function WW(d){for(var f=d;;){if(f.flags&16384){var y=f.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var b=0;b<y.length;b++){var I=y[b],M=I.getSnapshot;I=I.value;try{if(!Fi(M(),I))return!1}catch{return!1}}}if(y=f.child,f.subtreeFlags&16384&&y!==null)y.return=f,f=y;else{if(f===d)break;for(;f.sibling===null;){if(f.return===null||f.return===d)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function ml(d,f){for(f&=~dw,f&=~sm,d.suspendedLanes|=f,d.pingedLanes&=~f,d=d.expirationTimes;0<f;){var y=31-js(f),b=1<<y;d[y]=-1,f&=~b}}function LM(d){if((bt&6)!==0)throw Error(t(327));sd();var f=fc(d,0);if((f&1)===0)return ms(d,rn()),null;var y=um(d,f);if(d.tag!==0&&y===2){var b=bh(d);b!==0&&(f=b,y=gw(d,b))}if(y===1)throw y=Yh,Ec(d,0),ml(d,f),ms(d,rn()),y;if(y===6)throw Error(t(345));return d.finishedWork=d.current.alternate,d.finishedLanes=f,_c(d,gs,ua),ms(d,rn()),null}function yw(d,f){var y=bt;bt|=1;try{return d(f)}finally{bt=y,bt===0&&(rd=rn()+500,Ng&&cl())}}function Ic(d){pl!==null&&pl.tag===0&&(bt&6)===0&&sd();var f=bt;bt|=1;var y=hi.transition,b=xt;try{if(hi.transition=null,xt=1,d)return d()}finally{xt=b,hi.transition=y,bt=f,(bt&6)===0&&cl()}}function Sw(){Fs=nd.current,qt(nd)}function Ec(d,f){d.finishedWork=null,d.finishedLanes=0;var y=d.timeoutHandle;if(y!==-1&&(d.timeoutHandle=-1,wW(y)),En!==null)for(y=En.return;y!==null;){var b=y;switch(Ex(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&jg();break;case 3:Qu(),qt(hs),qt(pr),$x();break;case 5:Fx(b);break;case 4:Qu();break;case 13:qt(sn);break;case 19:qt(sn);break;case 10:Rx(b.type._context);break;case 22:case 23:Sw()}y=y.return}if(zn=d,En=d=yl(d.current,null),Jn=Fs=f,Dn=0,Yh=null,dw=sm=kc=0,gs=Xh=null,bc!==null){for(f=0;f<bc.length;f++)if(y=bc[f],b=y.interleaved,b!==null){y.interleaved=null;var I=b.next,M=y.pending;if(M!==null){var j=M.next;M.next=I,b.next=j}y.pending=b}bc=null}return d}function NM(d,f){do{var y=En;try{if(Ox(),qg.current=Zg,Gg){for(var b=on.memoizedState;b!==null;){var I=b.queue;I!==null&&(I.pending=null),b=b.next}Gg=!1}if(Pc=0,Fn=Rn=on=null,Hh=!1,Kh=0,uw.current=null,y===null||y.return===null){Dn=1,Yh=f,En=null;break}e:{var M=d,j=y.return,K=y,q=f;if(f=Jn,K.flags|=32768,q!==null&&typeof q=="object"&&typeof q.then=="function"){var oe=q,pe=K,ye=pe.tag;if((pe.mode&1)===0&&(ye===0||ye===11||ye===15)){var fe=pe.alternate;fe?(pe.updateQueue=fe.updateQueue,pe.memoizedState=fe.memoizedState,pe.lanes=fe.lanes):(pe.updateQueue=null,pe.memoizedState=null)}var Me=lM(j);if(Me!==null){Me.flags&=-257,cM(Me,j,K,M,f),Me.mode&1&&aM(M,oe,f),f=Me,q=oe;var Le=f.updateQueue;if(Le===null){var ze=new Set;ze.add(q),f.updateQueue=ze}else Le.add(q);break e}else{if((f&1)===0){aM(M,oe,f),vw();break e}q=Error(t(426))}}else if(Qt&&K.mode&1){var wn=lM(j);if(wn!==null){(wn.flags&65536)===0&&(wn.flags|=256),cM(wn,j,K,M,f),Mx(ed(q,K));break e}}M=q=ed(q,K),Dn!==4&&(Dn=2),Xh===null?Xh=[M]:Xh.push(M),M=j;do{switch(M.tag){case 3:M.flags|=65536,f&=-f,M.lanes|=f;var ne=iM(M,q,f);O2(M,ne);break e;case 1:K=q;var X=M.type,se=M.stateNode;if((M.flags&128)===0&&(typeof X.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(fl===null||!fl.has(se)))){M.flags|=65536,f&=-f,M.lanes|=f;var xe=oM(M,K,f);O2(M,xe);break e}}M=M.return}while(M!==null)}$M(y)}catch(Be){f=Be,En===y&&y!==null&&(En=y=y.return);continue}break}while(!0)}function FM(){var d=rm.current;return rm.current=Zg,d===null?Zg:d}function vw(){(Dn===0||Dn===3||Dn===2)&&(Dn=4),zn===null||(kc&268435455)===0&&(sm&268435455)===0||ml(zn,Jn)}function um(d,f){var y=bt;bt|=2;var b=FM();(zn!==d||Jn!==f)&&(ua=null,Ec(d,f));do try{VW();break}catch(I){NM(d,I)}while(!0);if(Ox(),bt=y,rm.current=b,En!==null)throw Error(t(261));return zn=null,Jn=0,Dn}function VW(){for(;En!==null;)zM(En)}function qW(){for(;En!==null&&!qv();)zM(En)}function zM(d){var f=HM(d.alternate,d,Fs);d.memoizedProps=d.pendingProps,f===null?$M(d):En=f,uw.current=null}function $M(d){var f=d;do{var y=f.alternate;if(d=f.return,(f.flags&32768)===0){if(y=zW(y,f,Fs),y!==null){En=y;return}}else{if(y=$W(y,f),y!==null){y.flags&=32767,En=y;return}if(d!==null)d.flags|=32768,d.subtreeFlags=0,d.deletions=null;else{Dn=6,En=null;return}}if(f=f.sibling,f!==null){En=f;return}En=f=d}while(f!==null);Dn===0&&(Dn=5)}function _c(d,f,y){var b=xt,I=hi.transition;try{hi.transition=null,xt=1,GW(d,f,y,b)}finally{hi.transition=I,xt=b}return null}function GW(d,f,y,b){do sd();while(pl!==null);if((bt&6)!==0)throw Error(t(327));y=d.finishedWork;var I=d.finishedLanes;if(y===null)return null;if(d.finishedWork=null,d.finishedLanes=0,y===d.current)throw Error(t(177));d.callbackNode=null,d.callbackPriority=0;var M=y.lanes|y.childLanes;if(nx(d,M),d===zn&&(En=zn=null,Jn=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||om||(om=!0,KM(Au,function(){return sd(),null})),M=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||M){M=hi.transition,hi.transition=null;var j=xt;xt=1;var K=bt;bt|=4,uw.current=null,UW(d,y),MM(y,d),pW(vx),Z=!!Sx,vx=Sx=null,d.current=y,HW(y),Gv(),bt=K,xt=j,hi.transition=M}else d.current=y;if(om&&(om=!1,pl=d,am=I),M=d.pendingLanes,M===0&&(fl=null),Zv(y.stateNode),ms(d,rn()),f!==null)for(b=d.onRecoverableError,y=0;y<f.length;y++)I=f[y],b(I.value,{componentStack:I.stack,digest:I.digest});if(im)throw im=!1,d=fw,fw=null,d;return(am&1)!==0&&d.tag!==0&&sd(),M=d.pendingLanes,(M&1)!==0?d===pw?Zh++:(Zh=0,pw=d):Zh=0,cl(),null}function sd(){if(pl!==null){var d=na(am),f=hi.transition,y=xt;try{if(hi.transition=null,xt=16>d?16:d,pl===null)var b=!1;else{if(d=pl,pl=null,am=0,(bt&6)!==0)throw Error(t(331));var I=bt;for(bt|=4,Re=d.current;Re!==null;){var M=Re,j=M.child;if((Re.flags&16)!==0){var K=M.deletions;if(K!==null){for(var q=0;q<K.length;q++){var oe=K[q];for(Re=oe;Re!==null;){var pe=Re;switch(pe.tag){case 0:case 11:case 15:Gh(8,pe,M)}var ye=pe.child;if(ye!==null)ye.return=pe,Re=ye;else for(;Re!==null;){pe=Re;var fe=pe.sibling,Me=pe.return;if(kM(pe),pe===oe){Re=null;break}if(fe!==null){fe.return=Me,Re=fe;break}Re=Me}}}var Le=M.alternate;if(Le!==null){var ze=Le.child;if(ze!==null){Le.child=null;do{var wn=ze.sibling;ze.sibling=null,ze=wn}while(ze!==null)}}Re=M}}if((M.subtreeFlags&2064)!==0&&j!==null)j.return=M,Re=j;else e:for(;Re!==null;){if(M=Re,(M.flags&2048)!==0)switch(M.tag){case 0:case 11:case 15:Gh(9,M,M.return)}var ne=M.sibling;if(ne!==null){ne.return=M.return,Re=ne;break e}Re=M.return}}var X=d.current;for(Re=X;Re!==null;){j=Re;var se=j.child;if((j.subtreeFlags&2064)!==0&&se!==null)se.return=j,Re=se;else e:for(j=X;Re!==null;){if(K=Re,(K.flags&2048)!==0)try{switch(K.tag){case 0:case 11:case 15:nm(9,K)}}catch(Be){fn(K,K.return,Be)}if(K===j){Re=null;break e}var xe=K.sibling;if(xe!==null){xe.return=K.return,Re=xe;break e}Re=K.return}}if(bt=I,cl(),ai&&typeof ai.onPostCommitFiberRoot=="function")try{ai.onPostCommitFiberRoot(Ou,d)}catch{}b=!0}return b}finally{xt=y,hi.transition=f}}return!1}function BM(d,f,y){f=ed(y,f),f=iM(d,f,1),d=dl(d,f,1),f=Lr(),d!==null&&(pc(d,1,f),ms(d,f))}function fn(d,f,y){if(d.tag===3)BM(d,d,y);else for(;f!==null;){if(f.tag===3){BM(f,d,y);break}else if(f.tag===1){var b=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(fl===null||!fl.has(b))){d=ed(y,d),d=oM(f,d,1),f=dl(f,d,1),d=Lr(),f!==null&&(pc(f,1,d),ms(f,d));break}}f=f.return}}function YW(d,f,y){var b=d.pingCache;b!==null&&b.delete(f),f=Lr(),d.pingedLanes|=d.suspendedLanes&y,zn===d&&(Jn&y)===y&&(Dn===4||Dn===3&&(Jn&130023424)===Jn&&500>rn()-hw?Ec(d,0):dw|=y),ms(d,f)}function UM(d,f){f===0&&((d.mode&1)===0?f=1:(f=po,po<<=1,(po&130023424)===0&&(po=4194304)));var y=Lr();d=aa(d,f),d!==null&&(pc(d,f,y),ms(d,y))}function XW(d){var f=d.memoizedState,y=0;f!==null&&(y=f.retryLane),UM(d,y)}function ZW(d,f){var y=0;switch(d.tag){case 13:var b=d.stateNode,I=d.memoizedState;I!==null&&(y=I.retryLane);break;case 19:b=d.stateNode;break;default:throw Error(t(314))}b!==null&&b.delete(f),UM(d,y)}var HM;HM=function(d,f,y){if(d!==null)if(d.memoizedProps!==f.pendingProps||hs.current)ps=!0;else{if((d.lanes&y)===0&&(f.flags&128)===0)return ps=!1,FW(d,f,y);ps=(d.flags&131072)!==0}else ps=!1,Qt&&(f.flags&1048576)!==0&&b2(f,zg,f.index);switch(f.lanes=0,f.tag){case 2:var b=f.type;em(d,f),d=f.pendingProps;var I=Vu(f,pr.current);Ju(f,y),I=Hx(null,f,b,d,I,y);var M=Kx();return f.flags|=1,typeof I=="object"&&I!==null&&typeof I.render=="function"&&I.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,fs(b)?(M=!0,Lg(f)):M=!1,f.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,Lx(f),I.updater=Jg,f.stateNode=I,I._reactInternals=f,Xx(f,b,d,y),f=ew(null,f,b,!0,M,y)):(f.tag=0,Qt&&M&&Ix(f),jr(null,f,I,y),f=f.child),f;case 16:b=f.elementType;e:{switch(em(d,f),d=f.pendingProps,I=b._init,b=I(b._payload),f.type=b,I=f.tag=QW(b),d=$i(b,d),I){case 0:f=Qx(null,f,b,d,y);break e;case 1:f=gM(null,f,b,d,y);break e;case 11:f=uM(null,f,b,d,y);break e;case 14:f=dM(null,f,b,$i(b.type,d),y);break e}throw Error(t(306,b,""))}return f;case 0:return b=f.type,I=f.pendingProps,I=f.elementType===b?I:$i(b,I),Qx(d,f,b,I,y);case 1:return b=f.type,I=f.pendingProps,I=f.elementType===b?I:$i(b,I),gM(d,f,b,I,y);case 3:e:{if(mM(f),d===null)throw Error(t(387));b=f.pendingProps,M=f.memoizedState,I=M.element,A2(d,f),Wg(f,b,null,y);var j=f.memoizedState;if(b=j.element,M.isDehydrated)if(M={element:b,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},f.updateQueue.baseState=M,f.memoizedState=M,f.flags&256){I=ed(Error(t(423)),f),f=yM(d,f,b,y,I);break e}else if(b!==I){I=ed(Error(t(424)),f),f=yM(d,f,b,y,I);break e}else for(Ns=ol(f.stateNode.containerInfo.firstChild),Ls=f,Qt=!0,zi=null,y=T2(f,null,b,y),f.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Yu(),b===I){f=ca(d,f,y);break e}jr(d,f,b,y)}f=f.child}return f;case 5:return D2(f),d===null&&Tx(f),b=f.type,I=f.pendingProps,M=d!==null?d.memoizedProps:null,j=I.children,xx(b,I)?j=null:M!==null&&xx(b,M)&&(f.flags|=32),pM(d,f),jr(d,f,j,y),f.child;case 6:return d===null&&Tx(f),null;case 13:return SM(d,f,y);case 4:return Nx(f,f.stateNode.containerInfo),b=f.pendingProps,d===null?f.child=Xu(f,null,b,y):jr(d,f,b,y),f.child;case 11:return b=f.type,I=f.pendingProps,I=f.elementType===b?I:$i(b,I),uM(d,f,b,I,y);case 7:return jr(d,f,f.pendingProps,y),f.child;case 8:return jr(d,f,f.pendingProps.children,y),f.child;case 12:return jr(d,f,f.pendingProps.children,y),f.child;case 10:e:{if(b=f.type._context,I=f.pendingProps,M=f.memoizedProps,j=I.value,Ut(Ug,b._currentValue),b._currentValue=j,M!==null)if(Fi(M.value,j)){if(M.children===I.children&&!hs.current){f=ca(d,f,y);break e}}else for(M=f.child,M!==null&&(M.return=f);M!==null;){var K=M.dependencies;if(K!==null){j=M.child;for(var q=K.firstContext;q!==null;){if(q.context===b){if(M.tag===1){q=la(-1,y&-y),q.tag=2;var oe=M.updateQueue;if(oe!==null){oe=oe.shared;var pe=oe.pending;pe===null?q.next=q:(q.next=pe.next,pe.next=q),oe.pending=q}}M.lanes|=y,q=M.alternate,q!==null&&(q.lanes|=y),Dx(M.return,y,f),K.lanes|=y;break}q=q.next}}else if(M.tag===10)j=M.type===f.type?null:M.child;else if(M.tag===18){if(j=M.return,j===null)throw Error(t(341));j.lanes|=y,K=j.alternate,K!==null&&(K.lanes|=y),Dx(j,y,f),j=M.sibling}else j=M.child;if(j!==null)j.return=M;else for(j=M;j!==null;){if(j===f){j=null;break}if(M=j.sibling,M!==null){M.return=j.return,j=M;break}j=j.return}M=j}jr(d,f,I.children,y),f=f.child}return f;case 9:return I=f.type,b=f.pendingProps.children,Ju(f,y),I=ui(I),b=b(I),f.flags|=1,jr(d,f,b,y),f.child;case 14:return b=f.type,I=$i(b,f.pendingProps),I=$i(b.type,I),dM(d,f,b,I,y);case 15:return hM(d,f,f.type,f.pendingProps,y);case 17:return b=f.type,I=f.pendingProps,I=f.elementType===b?I:$i(b,I),em(d,f),f.tag=1,fs(b)?(d=!0,Lg(f)):d=!1,Ju(f,y),rM(f,b,I),Xx(f,b,I,y),ew(null,f,b,!0,d,y);case 19:return xM(d,f,y);case 22:return fM(d,f,y)}throw Error(t(156,f.tag))};function KM(d,f){return vg(d,f)}function JW(d,f,y,b){this.tag=d,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fi(d,f,y,b){return new JW(d,f,y,b)}function xw(d){return d=d.prototype,!(!d||!d.isReactComponent)}function QW(d){if(typeof d=="function")return xw(d)?1:0;if(d!=null){if(d=d.$$typeof,d===J)return 11;if(d===U)return 14}return 2}function yl(d,f){var y=d.alternate;return y===null?(y=fi(d.tag,f,d.key,d.mode),y.elementType=d.elementType,y.type=d.type,y.stateNode=d.stateNode,y.alternate=d,d.alternate=y):(y.pendingProps=f,y.type=d.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=d.flags&14680064,y.childLanes=d.childLanes,y.lanes=d.lanes,y.child=d.child,y.memoizedProps=d.memoizedProps,y.memoizedState=d.memoizedState,y.updateQueue=d.updateQueue,f=d.dependencies,y.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},y.sibling=d.sibling,y.index=d.index,y.ref=d.ref,y}function dm(d,f,y,b,I,M){var j=2;if(b=d,typeof d=="function")xw(d)&&(j=1);else if(typeof d=="string")j=5;else e:switch(d){case O:return Tc(y.children,I,M,f);case D:j=8,I|=8;break;case $:return d=fi(12,y,f,I|2),d.elementType=$,d.lanes=M,d;case L:return d=fi(13,y,f,I),d.elementType=L,d.lanes=M,d;case N:return d=fi(19,y,f,I),d.elementType=N,d.lanes=M,d;case W:return hm(y,I,M,f);default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case H:j=10;break e;case G:j=9;break e;case J:j=11;break e;case U:j=14;break e;case Y:j=16,b=null;break e}throw Error(t(130,d==null?d:typeof d,""))}return f=fi(j,y,f,I),f.elementType=d,f.type=b,f.lanes=M,f}function Tc(d,f,y,b){return d=fi(7,d,b,f),d.lanes=y,d}function hm(d,f,y,b){return d=fi(22,d,b,f),d.elementType=W,d.lanes=y,d.stateNode={isHidden:!1},d}function ww(d,f,y){return d=fi(6,d,null,f),d.lanes=y,d}function bw(d,f,y){return f=fi(4,d.children!==null?d.children:[],d.key,f),f.lanes=y,f.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},f}function eV(d,f,y,b,I){this.tag=f,this.containerInfo=d,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ju(0),this.expirationTimes=ju(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ju(0),this.identifierPrefix=b,this.onRecoverableError=I,this.mutableSourceEagerHydrationData=null}function Cw(d,f,y,b,I,M,j,K,q){return d=new eV(d,f,y,K,q),f===1?(f=1,M===!0&&(f|=8)):f=0,M=fi(3,null,null,f),d.current=M,M.stateNode=d,M.memoizedState={element:b,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},Lx(M),d}function tV(d,f,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:A,key:b==null?null:""+b,children:d,containerInfo:f,implementation:y}}function WM(d){if(!d)return ll;d=d._reactInternals;e:{if(ta(d)!==d||d.tag!==1)throw Error(t(170));var f=d;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(fs(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(t(171))}if(d.tag===1){var y=d.type;if(fs(y))return v2(d,y,f)}return f}function VM(d,f,y,b,I,M,j,K,q){return d=Cw(y,b,!0,d,I,M,j,K,q),d.context=WM(null),y=d.current,b=Lr(),I=gl(y),M=la(b,I),M.callback=f??null,dl(y,M,I),d.current.lanes=I,pc(d,I,b),ms(d,b),d}function fm(d,f,y,b){var I=f.current,M=Lr(),j=gl(I);return y=WM(y),f.context===null?f.context=y:f.pendingContext=y,f=la(M,j),f.payload={element:d},b=b===void 0?null:b,b!==null&&(f.callback=b),d=dl(I,f,j),d!==null&&(Hi(d,I,j,M),Kg(d,I,j)),j}function pm(d){if(d=d.current,!d.child)return null;switch(d.child.tag){case 5:return d.child.stateNode;default:return d.child.stateNode}}function qM(d,f){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var y=d.retryLane;d.retryLane=y!==0&&y<f?y:f}}function Pw(d,f){qM(d,f),(d=d.alternate)&&qM(d,f)}function nV(){return null}var GM=typeof reportError=="function"?reportError:function(d){console.error(d)};function kw(d){this._internalRoot=d}gm.prototype.render=kw.prototype.render=function(d){var f=this._internalRoot;if(f===null)throw Error(t(409));fm(d,f,null,null)},gm.prototype.unmount=kw.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var f=d.containerInfo;Ic(function(){fm(null,d,null,null)}),f[ra]=null}};function gm(d){this._internalRoot=d}gm.prototype.unstable_scheduleHydration=function(d){if(d){var f=bg();d={blockedOn:null,target:d,priority:f};for(var y=0;y<yo.length&&f!==0&&f<yo[y].priority;y++);yo.splice(y,0,d),y===0&&Ih(d)}};function Iw(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function mm(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11&&(d.nodeType!==8||d.nodeValue!==" react-mount-point-unstable "))}function YM(){}function rV(d,f,y,b,I){if(I){if(typeof b=="function"){var M=b;b=function(){var oe=pm(j);M.call(oe)}}var j=VM(f,b,d,0,null,!1,!1,"",YM);return d._reactRootContainer=j,d[ra]=j.current,jh(d.nodeType===8?d.parentNode:d),Ic(),j}for(;I=d.lastChild;)d.removeChild(I);if(typeof b=="function"){var K=b;b=function(){var oe=pm(q);K.call(oe)}}var q=Cw(d,0,!1,null,null,!1,!1,"",YM);return d._reactRootContainer=q,d[ra]=q.current,jh(d.nodeType===8?d.parentNode:d),Ic(function(){fm(f,q,y,b)}),q}function ym(d,f,y,b,I){var M=y._reactRootContainer;if(M){var j=M;if(typeof I=="function"){var K=I;I=function(){var q=pm(j);K.call(q)}}fm(f,j,d,I)}else j=rV(y,f,d,I,b);return pm(j)}wg=function(d){switch(d.tag){case 3:var f=d.stateNode;if(f.current.memoizedState.isDehydrated){var y=tl(f.pendingLanes);y!==0&&(Lu(f,y|1),ms(f,rn()),(bt&6)===0&&(rd=rn()+500,cl()))}break;case 13:Ic(function(){var b=aa(d,1);if(b!==null){var I=Lr();Hi(b,d,1,I)}}),Pw(d,1)}},Ch=function(d){if(d.tag===13){var f=aa(d,134217728);if(f!==null){var y=Lr();Hi(f,d,134217728,y)}Pw(d,134217728)}},ji=function(d){if(d.tag===13){var f=gl(d),y=aa(d,f);if(y!==null){var b=Lr();Hi(y,d,f,b)}Pw(d,f)}},bg=function(){return xt},Cg=function(d,f){var y=xt;try{return xt=d,f()}finally{xt=y}},Ds=function(d,f,y){switch(f){case"input":if(rs(d,y),f=y.name,y.type==="radio"&&f!=null){for(y=d;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll("input[name="+JSON.stringify(""+f)+'][type="radio"]'),f=0;f<y.length;f++){var b=y[f];if(b!==d&&b.form===d.form){var I=Dg(b);if(!I)throw Error(t(90));Jt(b),rs(b,I)}}}break;case"textarea":Pu(d,y);break;case"select":f=y.value,f!=null&&ri(d,!!y.multiple,f,!1)}},Tu=yw,Mu=Ic;var sV={usingClientEntryPoint:!1,Events:[Fh,Ku,Dg,Ja,_u,yw]},Jh={findFiberByHostInstance:Sc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},iV={bundleType:Jh.bundleType,version:Jh.version,rendererPackageName:Jh.rendererPackageName,rendererConfig:Jh.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(d){return d=yg(d),d===null?null:d.stateNode},findFiberByHostInstance:Jh.findFiberByHostInstance||nV,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 Sm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sm.isDisabled&&Sm.supportsFiber)try{Ou=Sm.inject(iV),ai=Sm}catch{}}return ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sV,ys.createPortal=function(d,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Iw(f))throw Error(t(200));return tV(d,f,null,y)},ys.createRoot=function(d,f){if(!Iw(d))throw Error(t(299));var y=!1,b="",I=GM;return f!=null&&(f.unstable_strictMode===!0&&(y=!0),f.identifierPrefix!==void 0&&(b=f.identifierPrefix),f.onRecoverableError!==void 0&&(I=f.onRecoverableError)),f=Cw(d,1,!1,null,null,y,!1,b,I),d[ra]=f.current,jh(d.nodeType===8?d.parentNode:d),new kw(f)},ys.findDOMNode=function(d){if(d==null)return null;if(d.nodeType===1)return d;var f=d._reactInternals;if(f===void 0)throw typeof d.render=="function"?Error(t(188)):(d=Object.keys(d).join(","),Error(t(268,d)));return d=yg(f),d=d===null?null:d.stateNode,d},ys.flushSync=function(d){return Ic(d)},ys.hydrate=function(d,f,y){if(!mm(f))throw Error(t(200));return ym(null,d,f,!0,y)},ys.hydrateRoot=function(d,f,y){if(!Iw(d))throw Error(t(405));var b=y!=null&&y.hydratedSources||null,I=!1,M="",j=GM;if(y!=null&&(y.unstable_strictMode===!0&&(I=!0),y.identifierPrefix!==void 0&&(M=y.identifierPrefix),y.onRecoverableError!==void 0&&(j=y.onRecoverableError)),f=VM(f,null,d,1,y??null,I,!1,M,j),d[ra]=f.current,jh(d),b)for(d=0;d<b.length;d++)y=b[d],I=y._getVersion,I=I(y._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[y,I]:f.mutableSourceEagerHydrationData.push(y,I);return new gm(f)},ys.render=function(d,f,y){if(!mm(f))throw Error(t(200));return ym(null,d,f,!1,y)},ys.unmountComponentAtNode=function(d){if(!mm(d))throw Error(t(40));return d._reactRootContainer?(Ic(function(){ym(null,null,d,!1,function(){d._reactRootContainer=null,d[ra]=null})}),!0):!1},ys.unstable_batchedUpdates=yw,ys.unstable_renderSubtreeIntoContainer=function(d,f,y,b){if(!mm(y))throw Error(t(200));if(d==null||d._reactInternals===void 0)throw Error(t(38));return ym(d,f,y,!1,b)},ys.version="18.3.1-next-f1338f8080-20240426",ys}var rA;function KN(){if(rA)return Tw.exports;rA=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Tw.exports=gV(),Tw.exports}var sA;function mV(){if(sA)return vm;sA=1;var n=KN();return vm.createRoot=n.createRoot,vm.hydrateRoot=n.hydrateRoot,vm}var WN=mV();const yV=Ua(WN);function we(n,e={}){const t=typeof n=="string"?n:n.src;if(typeof e=="function")return e(t);const{baseUrl:r=""}=e;return t.startsWith("data:")||t.match(/^https?:\/\//)?t:`${r.replace(/\/$/,"")}/${t.replace(/^\.?\//,"")}`}function SV(n){const e=we("./icons/icon/0_merged.svg",n);return{fonts:{tldraw_mono_bold:we("./fonts/IBMPlexMono-Bold.woff2",n),tldraw_mono_italic_bold:we("./fonts/IBMPlexMono-BoldItalic.woff2",n),tldraw_mono:we("./fonts/IBMPlexMono-Medium.woff2",n),tldraw_mono_italic:we("./fonts/IBMPlexMono-MediumItalic.woff2",n),tldraw_sans_bold:we("./fonts/IBMPlexSans-Bold.woff2",n),tldraw_sans_italic_bold:we("./fonts/IBMPlexSans-BoldItalic.woff2",n),tldraw_sans:we("./fonts/IBMPlexSans-Medium.woff2",n),tldraw_sans_italic:we("./fonts/IBMPlexSans-MediumItalic.woff2",n),tldraw_serif_bold:we("./fonts/IBMPlexSerif-Bold.woff2",n),tldraw_serif_italic_bold:we("./fonts/IBMPlexSerif-BoldItalic.woff2",n),tldraw_serif:we("./fonts/IBMPlexSerif-Medium.woff2",n),tldraw_serif_italic:we("./fonts/IBMPlexSerif-MediumItalic.woff2",n),tldraw_draw_bold:we("./fonts/Shantell_Sans-Informal_Bold.woff2",n),tldraw_draw_italic_bold:we("./fonts/Shantell_Sans-Informal_Bold_Italic.woff2",n),tldraw_draw:we("./fonts/Shantell_Sans-Informal_Regular.woff2",n),tldraw_draw_italic:we("./fonts/Shantell_Sans-Informal_Regular_Italic.woff2",n)},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",bold:e+"#bold","bring-forward":e+"#bring-forward","bring-to-front":e+"#bring-to-front",broken:e+"#broken",bulletList:e+"#bulletList","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",code:e+"#code",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",heading:e+"#heading",highlight:e+"#highlight","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",italic:e+"#italic",leading:e+"#leading",link:e+"#link",list:e+"#list",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",strike:e+"#strike","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",underline:e+"#underline",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:we("./translations/ar.json",n),bn:we("./translations/bn.json",n),ca:we("./translations/ca.json",n),cs:we("./translations/cs.json",n),da:we("./translations/da.json",n),de:we("./translations/de.json",n),el:we("./translations/el.json",n),en:we("./translations/en.json",n),es:we("./translations/es.json",n),fa:we("./translations/fa.json",n),fi:we("./translations/fi.json",n),fr:we("./translations/fr.json",n),gl:we("./translations/gl.json",n),"gu-in":we("./translations/gu-in.json",n),he:we("./translations/he.json",n),"hi-in":we("./translations/hi-in.json",n),hr:we("./translations/hr.json",n),hu:we("./translations/hu.json",n),id:we("./translations/id.json",n),it:we("./translations/it.json",n),ja:we("./translations/ja.json",n),"km-kh":we("./translations/km-kh.json",n),kn:we("./translations/kn.json",n),"ko-kr":we("./translations/ko-kr.json",n),ku:we("./translations/ku.json",n),languages:we("./translations/languages.json",n),main:we("./translations/main.json",n),ml:we("./translations/ml.json",n),mr:we("./translations/mr.json",n),ms:we("./translations/ms.json",n),my:we("./translations/my.json",n),ne:we("./translations/ne.json",n),nl:we("./translations/nl.json",n),no:we("./translations/no.json",n),pa:we("./translations/pa.json",n),pl:we("./translations/pl.json",n),"pt-br":we("./translations/pt-br.json",n),"pt-pt":we("./translations/pt-pt.json",n),ro:we("./translations/ro.json",n),ru:we("./translations/ru.json",n),sl:we("./translations/sl.json",n),so:we("./translations/so.json",n),sv:we("./translations/sv.json",n),ta:we("./translations/ta.json",n),te:we("./translations/te.json",n),th:we("./translations/th.json",n),tl:we("./translations/tl.json",n),tr:we("./translations/tr.json",n),uk:we("./translations/uk.json",n),ur:we("./translations/ur.json",n),vi:we("./translations/vi.json",n),"zh-cn":we("./translations/zh-cn.json",n),"zh-tw":we("./translations/zh-tw.json",n)},embedIcons:{codepen:we("./embed-icons/codepen.png",n),codesandbox:we("./embed-icons/codesandbox.png",n),desmos:we("./embed-icons/desmos.png",n),excalidraw:we("./embed-icons/excalidraw.png",n),felt:we("./embed-icons/felt.png",n),figma:we("./embed-icons/figma.png",n),github_gist:we("./embed-icons/github_gist.png",n),google_calendar:we("./embed-icons/google_calendar.png",n),google_maps:we("./embed-icons/google_maps.png",n),google_slides:we("./embed-icons/google_slides.png",n),observable:we("./embed-icons/observable.png",n),replit:we("./embed-icons/replit.png",n),scratch:we("./embed-icons/scratch.png",n),spotify:we("./embed-icons/spotify.png",n),tldraw:we("./embed-icons/tldraw.png",n),val_town:we("./embed-icons/val_town.png",n),vimeo:we("./embed-icons/vimeo.png",n),youtube:we("./embed-icons/youtube.png",n)}}}const Ow="__TLDRAW_LIBRARY_VERSIONS__";function vV(){if(globalThis[Ow])return globalThis[Ow];const n={versions:[],didWarn:!1,scheduledNotice:null};return Object.defineProperty(globalThis,Ow,{value:n,writable:!1,configurable:!1,enumerable:!1}),n}function Zl(n,e,t){if(!n)throw new Error("Missing name/version/module system in built version of tldraw library");const r=vV();if(r.versions.push({name:n,version:e,modules:t}),!r.scheduledNotice)try{r.scheduledNotice=setTimeout(()=>{r.scheduledNotice=null,iA(r)},100)}catch{iA(r)}}function iA(n){if(!n.versions.length||n.didWarn)return;const e=n.versions.sort((a,l)=>oA(a.version,l.version)),t=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),Rw(s,a.name,new Set).add(a.version);continue}a.version===t?r.add(a.name):(r.delete(a.name),Rw(s,a.name,new Set).add(a.version))}if(s.size>0){const a=[`${da("[tldraw]",["bold","bgRed","textWhite"])} ${da("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 ${da(`v${t}`,["bold","textBlue"])}. The following libraries are on the latest version:`,...Array.from(r,l=>` • ✅ ${da(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(oA).map(h=>da(`v${h}`,h===t?["textGreen"]:["textRed"]));return` • ❌ ${da(l,["bold"])} (${u.join(", ")})`})];console.log(a.join(`
|
|
41
|
-
`)),n.didWarn=!0;return}const i=new Map;for(const a of e)Rw(i,a.name,{version:a.version,modules:[]}).modules.push(a.modules);const o=new Map;for(const[a,l]of i)l.modules.length>1&&o.set(a,l);if(o.size>0){const a=[`${da("[tldraw]",["bold","bgRed","textWhite"])} ${da("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(o,([l,c])=>{const u=c.modules.map((h,p)=>h==="esm"?` ${p+1}. ES Modules`:` ${p+1}. CommonJS`).join(`
|
|
42
|
-
`);return` • ❌ ${da(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
|
-
`)),n.didWarn=!0;return}}function oA(n,e){const t=n.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/),r=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/);return!t||!r?n.localeCompare(e):t[1]!==r[1]?Number(t[1])-Number(r[1]):t[2]!==r[2]?Number(t[2])-Number(r[2]):t[3]!==r[3]?Number(t[3])-Number(r[3]):t[4]&&r[4]?t[4].localeCompare(r[4]):t[4]?1:r[4]?-1:0}const xV={bold:"1",textBlue:"94",textRed:"31",textGreen:"32",bgRed:"41",textWhite:"97"};function da(n,e=[]){return`\x1B[${e.map(t=>xV[t]).join(";")}m${n}\x1B[m`}function Rw(n,e,t){return n.has(e)?n.get(e):(n.set(e,t),t)}var Dw,aA;function wV(){if(aA)return Dw;aA=1;var n="Expected a function",e=NaN,t="[object Symbol]",r=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,l=typeof Ps=="object"&&Ps&&Ps.Object===Object&&Ps,c=typeof self=="object"&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),h=Object.prototype,p=h.toString,m=Math.max,S=Math.min,x=function(){return u.Date.now()};function v(A,O,D){var $,H,G,J,L,N,U=0,Y=!1,W=!1,z=!0;if(typeof A!="function")throw new TypeError(n);O=T(O)||0,C(D)&&(Y=!!D.leading,W="maxWait"in D,G=W?m(T(D.maxWait)||0,O):G,z="trailing"in D?!!D.trailing:z);function V(be){var Ee=$,Ke=H;return $=H=void 0,U=be,J=A.apply(Ke,Ee),J}function ee(be){return U=be,L=setTimeout(me,O),Y?V(be):J}function B(be){var Ee=be-N,Ke=be-U,Lt=O-Ee;return W?S(Lt,G-Ke):Lt}function Q(be){var Ee=be-N,Ke=be-U;return N===void 0||Ee>=O||Ee<0||W&&Ke>=G}function me(){var be=x();if(Q(be))return Pe(be);L=setTimeout(me,B(be))}function Pe(be){return L=void 0,z&&$?V(be):($=H=void 0,J)}function ue(){L!==void 0&&clearTimeout(L),U=0,$=N=H=L=void 0}function Oe(){return L===void 0?J:Pe(x())}function Ne(){var be=x(),Ee=Q(be);if($=arguments,H=this,N=be,Ee){if(L===void 0)return ee(N);if(W)return L=setTimeout(me,O),V(N)}return L===void 0&&(L=setTimeout(me,O)),J}return Ne.cancel=ue,Ne.flush=Oe,Ne}function w(A,O,D){var $=!0,H=!0;if(typeof A!="function")throw new TypeError(n);return C(D)&&($="leading"in D?!!D.leading:$,H="trailing"in D?!!D.trailing:H),v(A,O,{leading:$,maxWait:O,trailing:H})}function C(A){var O=typeof A;return!!A&&(O=="object"||O=="function")}function _(A){return!!A&&typeof A=="object"}function E(A){return typeof A=="symbol"||_(A)&&p.call(A)==t}function T(A){if(typeof A=="number")return A;if(E(A))return e;if(C(A)){var O=typeof A.valueOf=="function"?A.valueOf():A;A=C(O)?O+"":O}if(typeof A!="string")return A===0?A:+A;A=A.replace(r,"");var D=i.test(A);return D||o.test(A)?a(A.slice(2),D?2:8):s.test(A)?e:+A}return Dw=w,Dw}var bV=wV();const VN=Ua(bV);var jw,lA;function CV(){if(lA)return jw;lA=1;var n=200,e="__lodash_hash_undefined__",t=1/0,r="[object Function]",s="[object GeneratorFunction]",i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,a=typeof Ps=="object"&&Ps&&Ps.Object===Object&&Ps,l=typeof self=="object"&&self&&self.Object===Object&&self,c=a||l||Function("return this")();function u(ae,Ce){var Ye=ae?ae.length:0;return!!Ye&&p(ae,Ce,0)>-1}function h(ae,Ce,Ye,At){for(var si=ae.length,ls=Ye+-1;++ls<si;)if(Ce(ae[ls],ls,ae))return ls;return-1}function p(ae,Ce,Ye){if(Ce!==Ce)return h(ae,m,Ye);for(var At=Ye-1,si=ae.length;++At<si;)if(ae[At]===Ce)return At;return-1}function m(ae){return ae!==ae}function S(ae,Ce){return ae.has(Ce)}function x(ae,Ce){return ae==null?void 0:ae[Ce]}function v(ae){var Ce=!1;if(ae!=null&&typeof ae.toString!="function")try{Ce=!!(ae+"")}catch{}return Ce}function w(ae){var Ce=-1,Ye=Array(ae.size);return ae.forEach(function(At){Ye[++Ce]=At}),Ye}var C=Array.prototype,_=Function.prototype,E=Object.prototype,T=c["__core-js_shared__"],A=function(){var ae=/[^.]+$/.exec(T&&T.keys&&T.keys.IE_PROTO||"");return ae?"Symbol(src)_1."+ae:""}(),O=_.toString,D=E.hasOwnProperty,$=E.toString,H=RegExp("^"+O.call(D).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),G=C.splice,J=ri(c,"Map"),L=ri(c,"Set"),N=ri(Object,"create");function U(ae){var Ce=-1,Ye=ae?ae.length:0;for(this.clear();++Ce<Ye;){var At=ae[Ce];this.set(At[0],At[1])}}function Y(){this.__data__=N?N(null):{}}function W(ae){return this.has(ae)&&delete this.__data__[ae]}function z(ae){var Ce=this.__data__;if(N){var Ye=Ce[ae];return Ye===e?void 0:Ye}return D.call(Ce,ae)?Ce[ae]:void 0}function V(ae){var Ce=this.__data__;return N?Ce[ae]!==void 0:D.call(Ce,ae)}function ee(ae,Ce){var Ye=this.__data__;return Ye[ae]=N&&Ce===void 0?e:Ce,this}U.prototype.clear=Y,U.prototype.delete=W,U.prototype.get=z,U.prototype.has=V,U.prototype.set=ee;function B(ae){var Ce=-1,Ye=ae?ae.length:0;for(this.clear();++Ce<Ye;){var At=ae[Ce];this.set(At[0],At[1])}}function Q(){this.__data__=[]}function me(ae){var Ce=this.__data__,Ye=In(Ce,ae);if(Ye<0)return!1;var At=Ce.length-1;return Ye==At?Ce.pop():G.call(Ce,Ye,1),!0}function Pe(ae){var Ce=this.__data__,Ye=In(Ce,ae);return Ye<0?void 0:Ce[Ye][1]}function ue(ae){return In(this.__data__,ae)>-1}function Oe(ae,Ce){var Ye=this.__data__,At=In(Ye,ae);return At<0?Ye.push([ae,Ce]):Ye[At][1]=Ce,this}B.prototype.clear=Q,B.prototype.delete=me,B.prototype.get=Pe,B.prototype.has=ue,B.prototype.set=Oe;function Ne(ae){var Ce=-1,Ye=ae?ae.length:0;for(this.clear();++Ce<Ye;){var At=ae[Ce];this.set(At[0],At[1])}}function be(){this.__data__={hash:new U,map:new(J||B),string:new U}}function Ee(ae){return as(this,ae).delete(ae)}function Ke(ae){return as(this,ae).get(ae)}function Lt(ae){return as(this,ae).has(ae)}function Jt(ae,Ce){return as(this,ae).set(ae,Ce),this}Ne.prototype.clear=be,Ne.prototype.delete=Ee,Ne.prototype.get=Ke,Ne.prototype.has=Lt,Ne.prototype.set=Jt;function Et(ae){var Ce=-1,Ye=ae?ae.length:0;for(this.__data__=new Ne;++Ce<Ye;)this.add(ae[Ce])}function Tt(ae){return this.__data__.set(ae,e),this}function nn(ae){return this.__data__.has(ae)}Et.prototype.add=Et.prototype.push=Tt,Et.prototype.has=nn;function In(ae,Ce){for(var Ye=ae.length;Ye--;)if(Iu(ae[Ye][0],Ce))return Ye;return-1}function rs(ae){if(!Oi(ae)||Cu(ae))return!1;var Ce=ho(ae)||v(ae)?H:o;return Ce.test(Pu(ae))}function ss(ae,Ce,Ye){var At=-1,si=u,ls=ae.length,Qo=!0,Os=[],Rs=Os;if(ls>=n){var cs=is(ae);if(cs)return w(cs);Qo=!1,si=S,Rs=new Et}else Rs=Os;e:for(;++At<ls;){var Ds=ae[At],us=Ds;if(Ds=Ds!==0?Ds:0,Qo&&us===us){for(var Ri=Rs.length;Ri--;)if(Rs[Ri]===us)continue e;Os.push(Ds)}else si(Rs,us,Ye)||(Rs!==Os&&Rs.push(us),Os.push(Ds))}return Os}var is=L&&1/w(new L([,-0]))[1]==t?function(ae){return new L(ae)}:cc;function as(ae,Ce){var Ye=ae.__data__;return lc(Ce)?Ye[typeof Ce=="string"?"string":"hash"]:Ye.map}function ri(ae,Ce){var Ye=x(ae,Ce);return rs(Ye)?Ye:void 0}function lc(ae){var Ce=typeof ae;return Ce=="string"||Ce=="number"||Ce=="symbol"||Ce=="boolean"?ae!=="__proto__":ae===null}function Cu(ae){return!!A&&A in ae}function Pu(ae){if(ae!=null){try{return O.call(ae)}catch{}try{return ae+""}catch{}}return""}function ku(ae){return ae&&ae.length?ss(ae):[]}function Iu(ae,Ce){return ae===Ce||ae!==ae&&Ce!==Ce}function ho(ae){var Ce=Oi(ae)?$.call(ae):"";return Ce==r||Ce==s}function Oi(ae){var Ce=typeof ae;return!!ae&&(Ce=="object"||Ce=="function")}function cc(){}return jw=ku,jw}var PV=CV();const kV=Ua(PV);function qN(n){const e=(...t)=>{try{return n(...t)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,e),r}};return e}const np=()=>{},Fr={ok(n){return{ok:!0,value:n}},err(n){return{ok:!1,error:n}}};function An(n,e){const t=e&&n&&typeof n=="object"&&e in n?n[e]:n;throw new Error(`Unknown switch case ${t}`)}const Je=qN((n,e)=>{if(!n)throw new Error(e||"Assertion Error")}),zr=qN((n,e)=>{if(n==null)throw new Error(e??"value must be defined");return n});function xI(){let n,e;const t=new Promise((r,s)=>{n=r,e=s});return Object.assign(t,{resolve:n,reject:e})}function TP(n){return new Promise(e=>setTimeout(e,n))}const vf={Good:"#40C057",Mid:"#FFC078",Poor:"#E03131"},IV=vf.Good;class GN{constructor(){R(this,"startTime",0);R(this,"name","");R(this,"frames",0);R(this,"started",!1);R(this,"frame",null);R(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,t=e===0?0:Math.floor(this.frames/e),r=t>55?vf.Good:t>30?vf.Mid:vf.Poor,s=r===vf.Mid?"black":"white",i=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${i} %c${t}%c fps`,`color: white; background: ${IV};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 wI(n,e){const t=[];e:for(const r of n){for(const s of t)if(e?e(r,s):r===s)continue e;t.push(r)}return t}function rt(n){return n.filter(e=>e!=null)}function tr(n){return n[n.length-1]}function YN(n,e){let t,r=1/0;for(const s of n){const i=e(s);i<r&&(t=s,r=i)}return t}function EV(n,e){let t,r=-1/0;for(const s of n){const i=e(s);i>r&&(t=s,r=i)}return t}function Wy(n,e){if(n===e)return!0;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Object.is(n[t],e[t]))return!1;return!0}function Lw(n,e,t){const r=new Set(e.map(i=>i[n])),s=[];for(const i of t)r.has(i[n])||s.push(i);for(const i of e)s.push(i);return s}/*!
|
|
45
|
-
* MIT License: https://github.com/NoHomey/bind-decorator/blob/master/License
|
|
46
|
-
* Copyright (c) 2016 Ivo Stratev
|
|
47
|
-
*/function ks(...n){if(n.length===2){const[e,t]=n;t.addInitializer(function(){Je(Reflect.isExtensible(this),"Cannot bind to a non-extensible class.");const s=e.bind(this),i=Reflect.defineProperty(this,t.name,{value:s,writable:!0,configurable:!0});Je(i,"Cannot bind a non-configurable class method.")})}else{const[e,t,r]=n;if(!r||typeof r.value!="function")throw new TypeError(`Only methods can be decorated with @bind. <${t}> is not a method!`);return{configurable:!0,get(){const s=r.value.bind(this);return Object.defineProperty(this,t,{value:s,configurable:!0,writable:!0}),s}}}}class qo{constructor(){R(this,"items",new WeakMap)}get(e,t){return this.items.has(e)||this.items.set(e,t(e)),this.items.get(e)}}function x0(n,e){let t;const r=(...s)=>(t||(t={},t.promise=new Promise((i,o)=>{t.resolve=i,t.reject=o})),clearTimeout(t.timeout),t.latestArgs=s,t.timeout=setTimeout(()=>{const i=t;t=void 0;try{i.resolve(n(...i.latestArgs))}catch(o){i.reject(o)}},e),t.promise);return r.cancel=()=>{t&&clearTimeout(t.timeout)},r}const cA=new WeakMap;function bI(n,e){if(typeof n!="object"||n===null)return;let t=cA.get(n);t||(t={tags:{},extras:{}},cA.set(n,t)),e.tags&&(t.tags={...t.tags,...e.tags}),e.extras&&(t.extras={...t.extras,...e.extras})}async function Zi(n,e){return window.fetch(n,{referrerPolicy:"strict-origin-when-cross-origin",...e})}const rp=(n,e)=>{const t=new window.Image(n,e);return t.referrerPolicy="strict-origin-when-cross-origin",t};class Kr{static async dataUrlToArrayBuffer(e){return Zi(e).then(function(t){return t.arrayBuffer()})}static async urlToArrayBuffer(e){return await(await Zi(e)).arrayBuffer()}static async urlToBlob(e){return await(await Zi(e)).blob()}static async urlToDataUrl(e){if(e.startsWith("data:"))return e;const t=await Kr.urlToBlob(e);return await Kr.blobToDataUrl(t)}static async blobToDataUrl(e){return await new Promise((t,r)=>{if(e){const s=new FileReader;s.onload=()=>t(s.result),s.onerror=i=>r(i),s.onabort=i=>r(i),s.readAsDataURL(e)}})}static async blobToText(e){return await new Promise((t,r)=>{if(e){const s=new FileReader;s.onload=()=>t(s.result),s.onerror=i=>r(i),s.onabort=i=>r(i),s.readAsText(e)}})}static rewriteMimeType(e,t){return e.type===t?e:e instanceof File?new File([e],e.name,{type:t}):new Blob([e],{type:t})}}function CI(n){let e=0;for(let t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e|=0;return e+""}function XN(n){const e=new DataView(n);let t=0;for(let r=0;r<e.byteLength;r++)t=(t<<5)-t+e.getUint8(r),t|=0;return t+""}/*!
|
|
48
|
-
* MIT License: https://github.com/ai/nanoid/blob/main/LICENSE
|
|
49
|
-
* Modified code originally from <https://github.com/ai/nanoid>
|
|
50
|
-
* Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
|
51
|
-
*
|
|
52
|
-
* `nanoid` is currently only distributed as an ES module. Some tools (jest, playwright) don't
|
|
53
|
-
* properly support ESM-only code yet, and tldraw itself is distributed as both an ES module and a
|
|
54
|
-
* CommonJS module. By including nanoid here, we can make sure it works well in every environment
|
|
55
|
-
* where tldraw is used. We can also remove some unused features like custom alphabets.
|
|
56
|
-
*/const uA=globalThis.crypto,_V="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",TV=128;let Oc,bd;function MV(n){!Oc||Oc.length<n?(Oc=new Uint8Array(n*TV),uA.getRandomValues(Oc),bd=0):bd+n>Oc.length&&(uA.getRandomValues(Oc),bd=0),bd+=n}function AV(n=21){MV(n-=0);let e="";for(let t=bd-n;t<bd;t++)e+=_V[Oc[t]&63];return e}let OV=AV;function _t(n){return OV(n)}/*!
|
|
57
|
-
* MIT License: https://github.com/vHeemstra/is-apng/blob/main/license
|
|
58
|
-
* Copyright (c) Philip van Heemstra
|
|
59
|
-
*/function RV(n){const e=new Uint8Array(n);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(i,o,a,l,c=1024){if(!o)return-1;o=new RegExp(o,"g");const u=o.source.length,h=new TextDecoder,p=i.length;if(typeof l>"u"&&(l=p),a>=p||l<=0||a>=l)return-1;i=i.subarray(a,l);let m=-1,S=0,x=0,v="";e:for(;S<i.length;){const w=S+c,C=i.subarray(S,w),_=h.decode(C,{stream:!0}),E=v+_;let T,A=-1;for(;(T=o.exec(E))!==null;){A=T.index-v.length,m=x+A;break e}S=w,x+=_.length;const O=A>-1?A+u:_.length-u;v=_.slice(O)}return m>=0&&(m+=a>=0?a:p+a),m}const s=r(e,"IDAT",12);return s>=12?r(e,"acTL",8,s)>=8:!1}const DV=n=>new Uint8Array(n)[3]===44;/*!
|
|
60
|
-
* MIT License
|
|
61
|
-
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
62
|
-
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
63
|
-
*/function dA(n,e){let t=0;for(;n[e+t];)t+=n[e+t]+1;return t+1}function jV(n){return new TextDecoder("ascii").decode(n.slice(0,3))==="GIF"}function LV(n){const e=new Uint8Array(n);let t,r,s=0,i=0;if(!jV(n))return!1;for(t=e[10]&128,r=e[10]&7,s+=6,s+=7,s+=t?3*Math.pow(2,r+1):0;i<2&&s<e.length;)switch(e[s]){case 44:i+=1,t=e[s+9]&128,r=e[s+9]&7,s+=10,s+=t?3*Math.pow(2,r+1):0,s+=dA(e,s+1)+1;break;case 33:s+=2,s+=dA(e,s);break;case 59:s=e.length;break;default:s=e.length;break}return i>1}/*!
|
|
64
|
-
* MIT License: https://github.com/alexgorbatchev/crc/blob/master/LICENSE
|
|
65
|
-
* Copyright: 2014 Alex Gorbatchev
|
|
66
|
-
* Code: crc32, https://github.com/alexgorbatchev/crc/blob/master/src/calculators/crc32.ts
|
|
67
|
-
*/let MP=[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"&&(MP=new Int32Array(MP));const NV=(n,e)=>{let t=-1;for(let r=0;r<n.length;r++)t=MP[(t^n[r])&255]^t>>>8;return t^-1},hA=4,fA=4;class Ao{static isPng(e,t){return e.getUint8(t+0)===137&&e.getUint8(t+1)===80&&e.getUint8(t+2)===78&&e.getUint8(t+3)===71&&e.getUint8(t+4)===13&&e.getUint8(t+5)===10&&e.getUint8(t+6)===26&&e.getUint8(t+7)===10}static getChunkType(e,t){return[String.fromCharCode(e.getUint8(t)),String.fromCharCode(e.getUint8(t+1)),String.fromCharCode(e.getUint8(t+2)),String.fromCharCode(e.getUint8(t+3))].join("")}static readChunks(e,t=0){const r={};if(!Ao.isPng(e,t))throw new Error("Not a PNG");for(t+=8;t<=e.buffer.byteLength;){const s=t,i=e.getInt32(t);t+=4;const o=Ao.getChunkType(e,t);if(o==="IDAT"&&r[o]){t+=i+hA+fA;continue}if(o==="IEND")break;r[o]={start:s,dataOffset:t+4,size:i},t+=i+hA+fA}return r}static parsePhys(e,t){return{ppux:e.getUint32(t),ppuy:e.getUint32(t+4),unit:e.getUint8(t+4)}}static findChunk(e,t){return Ao.readChunks(e)[t]}static setPhysChunk(e,t=1,r){let s=46,i=0;const o=Ao.findChunk(e,"pHYs");o&&(s=o.start,i=o.size);const a=Ao.findChunk(e,"IDAT");a&&(s=a.start,i=0);const l=new ArrayBuffer(21),c=new DataView(l);c.setUint32(0,9),c.setUint8(4,112),c.setUint8(5,72),c.setUint8(6,89),c.setUint8(7,115);const u=2835.5;c.setInt32(8,u*t),c.setInt32(12,u*t),c.setInt8(16,1);const h=new Uint8Array(l.slice(4,17));c.setInt32(17,NV(h));const p=e.buffer.slice(0,s),m=e.buffer.slice(s+i);return new Blob([p,l,m],r)}}/*!
|
|
68
|
-
* MIT License: https://github.com/sindresorhus/is-webp/blob/main/license
|
|
69
|
-
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
70
|
-
*/function FV(n){return!n||n.length<12?!1:n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}function zV(n){const e=new Uint8Array(n);return!FV(e)||!e||e.length<21?!1:(e[20]>>1&1)===1}const ZN=Object.freeze(["image/svg+xml"]),JN=Object.freeze(["image/jpeg","image/png","image/webp"]),QN=Object.freeze(["image/gif","image/apng","image/avif"]),Mp=Object.freeze([...JN,...ZN,...QN]),w0=Object.freeze(["video/mp4","video/webm","video/quicktime"]),$V=[...Mp,...w0].join(",");class Hs{static loadVideo(e){return new Promise((t,r)=>{const s=document.createElement("video");s.onloadeddata=()=>t(s),s.onerror=i=>{console.error(i),r(new Error("Could not load video"))},s.crossOrigin="anonymous",s.src=e})}static async getVideoFrameAsDataUrl(e,t=0){const r=xI();let s=!1;const i=()=>{if(!s)if(e.readyState>=e.HAVE_METADATA)s=!0,e.currentTime=t;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())}},o=a=>{console.error(a),r.reject(new Error("Could not get video frame"))};e.addEventListener("loadedmetadata",i),e.addEventListener("loadeddata",i),e.addEventListener("canplay",i),e.addEventListener("seeked",i),e.addEventListener("error",o),e.addEventListener("stalled",o),i();try{return await r}finally{e.removeEventListener("loadedmetadata",i),e.removeEventListener("loadeddata",i),e.removeEventListener("canplay",i),e.removeEventListener("seeked",i),e.removeEventListener("error",o),e.removeEventListener("stalled",o)}}static getImageAndDimensions(e){return new Promise((t,r)=>{const s=rp();s.onload=()=>{let i;s.naturalWidth?i={w:s.naturalWidth,h:s.naturalHeight}:(document.body.appendChild(s),i={w:s.clientWidth,h:s.clientHeight},document.body.removeChild(s)),t({...i,image:s})},s.onerror=i=>{console.error(i),r(new Error("Could not load image"))},s.crossOrigin="anonymous",s.referrerPolicy="strict-origin-when-cross-origin",s.style.visibility="hidden",s.style.position="absolute",s.style.opacity="0",s.style.zIndex="-9999",s.src=e})}static async getVideoSize(e){return Hs.usingObjectURL(e,async t=>{const r=await Hs.loadVideo(t);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(e){const{w:t,h:r}=await Hs.usingObjectURL(e,Hs.getImageAndDimensions);try{if(e.type==="image/png"){const s=new DataView(await e.arrayBuffer());if(Ao.isPng(s,0)){const i=Ao.findChunk(s,"pHYs");if(i){const o=Ao.parsePhys(s,i.dataOffset);if(o.unit===0&&o.ppux===o.ppuy){const l=Math.max(o.ppux/2834.645669291339,1);return{w:Math.round(t/l),h:Math.round(r/l)}}}}}}catch(s){return console.error(s),{w:t,h:r}}return{w:t,h:r}}static async isAnimated(e){return e.type==="image/gif"?LV(await e.arrayBuffer()):e.type==="image/avif"?DV(await e.arrayBuffer()):e.type==="image/webp"?zV(await e.arrayBuffer()):e.type==="image/apng"?RV(await e.arrayBuffer()):!1}static isAnimatedImageType(e){return QN.includes(e||"")}static isStaticImageType(e){return JN.includes(e||"")}static isVectorImageType(e){return ZN.includes(e||"")}static isImageType(e){return Mp.includes(e)}static async usingObjectURL(e,t){const r=URL.createObjectURL(e);try{return await t(r)}finally{URL.revokeObjectURL(r)}}}function yt(n,e,t){return n+(e-n)*t}function oo(n=""){let e=0,t=0,r=0,s=0;function i(){const o=e^e<<11;return e=t,t=r,r=s,s^=(s>>>19^o^o>>>8)>>>0,s/4294967296*2}for(let o=0;o<n.length+64;o++)e^=n.charCodeAt(o)|0,i();return i}function zd(n,e,t,r=!1){const[s,i]=e,[o,a]=t,l=o+(n-s)/(i-s)*(a-o);return r?o<a?Math.max(Math.min(l,a),o):Math.max(Math.min(l,o),a):l}function Ci(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function bn(n,e){if(Ci(n,e))return n[e]}function BV(n){return Object.keys(n)}function gn(n){return Object.values(n)}function Is(n){return Object.entries(n)}function e3(n){return Object.fromEntries(n)}function Nf(n,e){const t={};let r=!1;for(const[s,i]of Is(n))e(s,i)?t[s]=i:r=!0;return r?t:n}function rh(n,e){const t={};for(const[r,s]of Is(n)){const i=e(r,s);t[r]=i}return t}function t3(n,e){if(n===e)return!0;const t=new Set(Object.keys(n)),r=new Set(Object.keys(e));if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s)||!Object.is(n[s],e[s]))return!1;return!0}function UV(n){const e=HV(n.chars),t=KV(e,n.firstPositive,n.mostPositive,n.mostNegative),r=n.jitterRange??Math.floor(Math.pow(e.length,3)/5),s=WV(r,e.length);return{chars:n.chars,byChar:e.byChar,byCode:e.byCode,length:e.length,first:e.byCode[0],last:e.byCode[e.length-1],firstPositive:t.firstPositive,mostPositive:t.mostPositive,firstNegative:t.firstNegative,mostNegative:t.mostNegative,jitterRange:r,paddingDict:s}}function HV(n){const e={},t={},r=n.length;for(let s=0;s<r;s++){const i=n[s];e[s]=i,t[i]=s}return{byCode:e,byChar:t,length:r}}function KV(n,e,t,r){const s=n.byChar[e],i=n.byChar[t],o=n.byChar[r];if(s===void 0||i===void 0||o===void 0)throw new Error("invalid charSet");if(i-s<3)throw new Error("mostPositive must be at least 3 characters away from neutral");if(s-o<3)throw new Error("mostNegative must be at least 3 characters away from neutral");return{firstPositive:n.byCode[s],mostPositive:n.byCode[i],firstNegative:n.byCode[s-1],mostNegative:n.byCode[o]}}function WV(n,e){const t={};for(let r=0;r<100&&(t[r]=Math.pow(e,r),!(t[r]>n));r++);return t}var Nw=null;function PI(){return Nw||(Nw=UV({chars:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",firstPositive:"a",mostPositive:"z",mostNegative:"A"}))}function Dl(n,e,t){const r=t.byChar[n],s=t.byChar[e];return Math.abs(r-s)}function kI(n,e){const t=n[0];if(t>e.mostPositive||t<e.mostNegative)throw new Error("invalid firstChar on key");return t===e.mostPositive?Dl(t,e.firstPositive,e)+1+Vy(n.slice(1),"positive",e):t===e.mostNegative?Dl(t,e.firstNegative,e)+1+Vy(n.slice(1),"negative",e):t>=e.firstPositive?Dl(t,e.firstPositive,e)+2:Dl(t,e.firstNegative,e)+2}function Vy(n,e,t){const r=n[0];if(r>t.mostPositive||r<t.mostNegative)throw new Error("invalid firstChar on key");return r===t.mostPositive&&e==="positive"?Dl(r,t.mostNegative,t)+1+Vy(n.slice(1),e,t):r===t.mostNegative&&e==="negative"?Dl(r,t.mostPositive,t)+1+Vy(n.slice(1),e,t):e==="positive"?Dl(r,t.mostNegative,t)+2:Dl(r,t.mostPositive,t)+2}function b0(n,e,t,r,s){const i=Math.max(n.length,e.length);return t==="start"?[n.padStart(i,r),e.padStart(i,r)]:[n.padEnd(i,r),e.padEnd(i,r)]}function VV(n,e,t){let[r,s]=b0(n,e,"end",t.first),i=AP(r,s,t);i===1&&(r=r.padEnd(r.length+1,t.first),i=t.length);const o=s3(Math.floor(i/2),t);return II(r,o,t)}function AP(n,e,t){const[r,s]=b0(n,e,"end",t.first).sort(),i=n3(s,r,t);return qV(i,t)}function II(n,e,t){const r=t.length,[s,i]=b0(n,e,"start",t.first),o=[];let a=0;for(let l=s.length-1;l>=0;l--){const c=t.byChar[s[l]],u=t.byChar[i[l]],h=c+u+a;a=Math.floor(h/r);const p=h%r;o.unshift(t.byCode[p])}return a>0&&o.unshift(t.byCode[a]),o.join("")}function n3(n,e,t){const r=t.length,[s,i]=b0(n,e,"start",t.first),o=[];let a=0;for(let l=s.length-1;l>=0;l--){let c=t.byChar[s[l]];const u=t.byChar[i[l]]+a;c<u?(a=1,c+=r):a=0;const h=c-u;o.unshift(t.byCode[h])}if(a>0)throw new Error("Subtraction result is negative. Ensure a is greater than or equal to b.");for(;o.length>1&&o[0]===t.byCode[0];)o.shift();return o.join("")}function r3(n,e){return II(n,e.byCode[1],e)}function OP(n,e){return n3(n,e.byCode[1],e)}function s3(n,e){if(n===0)return e.byCode[0];let t="";const r=e.length;for(;n>0;)t=e.byCode[n%r]+t,n=Math.floor(n/r);return t}function qV(n,e){let t=0;const r=n.length,s=e.length;for(let i=0;i<r;i++)t+=e.byChar[n[i]]*Math.pow(s,r-i-1);return t}function GV(n){return n.firstPositive+n.byCode[0]}function YV(n,e){return kI(n,e)===n.length}function pA(n,e){qy(n,e)}function qy(n,e){const t=a3(n,e),r=kI(t,e);if(r>n.length)throw new Error("invalid order key length: "+n);return n.slice(0,r)}function i3(n,e){if(!YV(n,e))throw new Error("invalid integer length: "+n)}function o3(n,e){i3(n,e);const[t,r]=l3(n,e);if(r.split("").some(o=>o!==e.byCode[e.length-1])){const o=r3(r,e);return t+o}const i=ZV(t,e);return c3(i,"lower",e)}function XV(n,e){i3(n,e);const[t,r]=l3(n,e);if(r.split("").some(o=>o!==e.byCode[0])){const o=OP(r,e);return t+o}const i=JV(t,e);return c3(i,"upper",e)}function a3(n,e){let t=0;if(n[0]===e.mostPositive)for(;n[t]===e.mostPositive;)t=t+1;if(n[0]===e.mostNegative)for(;n[t]===e.mostNegative;)t=t+1;return n.slice(0,t+1)}function l3(n,e){const t=a3(n,e),r=n.slice(t.length);return[t,r]}function ZV(n,e){const t=n>=e.firstPositive,r=r3(n,e),s=n[n.length-1]===e.mostPositive,i=r[r.length-1]===e.mostPositive;return t&&i?r+e.mostNegative:!t&&s?n.slice(0,n.length-1):r}function JV(n,e){const t=n>=e.firstPositive,r=n[n.length-1]===e.mostNegative;if(t&&r){const s=n.slice(0,n.length-1);return OP(s,e)}return!t&&r?n+e.mostPositive:OP(n,e)}function c3(n,e,t){const r=kI(n,t),s=e==="upper"?t.byCode[t.length-1]:t.byCode[0];return n+s.repeat(r-n.length)}function u3(n,e){const t=s3(Math.floor(Math.random()*e.jitterRange),e);return II(n,t,e)}function QV(n,e,t){const r=n.padEnd(n.length+e,t.first);return u3(r,t)}function eq(n,e,t){const r=qy(n,t),s=o3(r,t);let i=0;if(e!==null){const a=AP(n,e,t);a<t.jitterRange+1&&(i=Math.max(i,gA(a,t)))}const o=AP(n,s,t);return o<t.jitterRange+1&&(i=Math.max(i,gA(o,t))),i}function gA(n,e){const t=e.jitterRange-n,r=Object.entries(e.paddingDict).find(([s,i])=>i>t);return r?parseInt(r[0]):0}function tq(n,e,t=PI()){if(n!==null&&pA(n,t),e!==null&&pA(e,t),n===null&&e===null)return GV(t);if(n===null){const r=qy(e,t);return XV(r,t)}if(e===null){const r=qy(n,t);return o3(r,t)}if(n>=e)throw new Error(n+" >= "+e);return VV(n,e,t)}function d3(n,e,t=PI()){const r=tq(n,e,t),s=eq(r,e,t);return s?QV(r,s,t):u3(r,t)}function h3(n,e,t,r=PI()){return nq(n,e,t,r,d3,h3)}function nq(n,e,t,r,s,i){if(t===0)return[];if(t===1)return[s(n,e,r)];if(e==null){let l=s(n,e,r);const c=[l];for(let u=0;u<t-1;u++)l=s(l,e,r),c.push(l);return c}if(n==null){let l=s(n,e,r);const c=[l];for(let u=0;u<t-1;u++)l=s(n,l,r),c.push(l);return c.reverse(),c}const o=Math.floor(t/2),a=s(n,e,r);return[...i(n,a,o,r),a,...i(a,e,t-o-1,r)]}const sh=h3,f3="a0";function rq(n){try{d3(n,null)}catch{throw new Error("invalid index: "+n)}}function $d(n,e,t){return sh(n??null,e??null,t)}function Fw(n,e){return sh(n??null,null,e)}function sp(n,e){return sh(n??null,e??null,1)[0]}function Ro(n=null){return sh(n,null,1)[0]}function sq(n=null){return sh(null,n,1)[0]}function ip(n,e="a1"){return[e,...sh(e,null,n)]}function nr(n,e){return n.index<e.index?-1:n.index>e.index?1:0}function iq(n,e){return n.id>e.id?1:-1}function EI(n){try{return localStorage.getItem(n)}catch{return null}}function _I(n,e){try{localStorage.setItem(n,e)}catch{}}function oq(){try{localStorage.clear()}catch{}}function p3(n){try{return sessionStorage.getItem(n)}catch{return null}}function TI(n,e){try{sessionStorage.setItem(n,e)}catch{}}function g3(n){try{sessionStorage.removeItem(n)}catch{}}function aq(){try{sessionStorage.clear()}catch{}}const Cd=[],lq=60,ay=Math.ceil(1e3/lq);let ef,zw=0,RP=0;const cq=()=>{const n=Cd.splice(0,Cd.length);for(const e of n)e()};function m3(){if(ef)return;const n=Date.now(),e=n-RP;if(zw+e<ay){ef=requestAnimationFrame(()=>{ef=void 0,m3()});return}ef=requestAnimationFrame(()=>{ef=void 0,RP=n,zw=Math.min(zw+e-ay,ay*10),cq()})}let mA=!1;function y3(n){return Cd.includes(n)||(Cd.push(n),mA||(mA=!0,RP=Date.now()-ay-1),m3()),()=>{const e=Cd.indexOf(n);e>-1&&Cd.splice(e,1)}}class uq{constructor(){R(this,"timeouts",new Map);R(this,"intervals",new Map);R(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,t,r,...s){const i=window.setTimeout(t,r,s),o=this.timeouts.get(e)??[];return this.timeouts.set(e,[...o,i]),i}setInterval(e,t,r,...s){const i=window.setInterval(t,r,s),o=this.intervals.get(e)??[];return this.intervals.set(e,[...o,i]),i}requestAnimationFrame(e,t){const r=window.requestAnimationFrame(t),s=this.rafs.get(e)??[];return this.rafs.set(e,[...s,r]),r}dispose(e){var t,r,s;(t=this.timeouts.get(e))==null||t.forEach(i=>clearTimeout(i)),(r=this.intervals.get(e))==null||r.forEach(i=>clearInterval(i)),(s=this.rafs.get(e))==null||s.forEach(i=>cancelAnimationFrame(i)),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:(t,r,...s)=>this.setTimeout(e,t,r,s),setInterval:(t,r,...s)=>this.setInterval(e,t,r,s),requestAnimationFrame:t=>this.requestAnimationFrame(e,t),dispose:()=>this.dispose(e)}}}const Ze=(n,e)=>{try{return new URL(n,e)}catch{return}};function dq(n){return n!==void 0}function hq(){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]:[n=>n&&JSON.parse(JSON.stringify(n)),!1]}const S3=hq(),Xt=S3[0];S3[1];const fq=Object.getPrototypeOf(Xt({}));Zl("@tldraw/utils","3.12.1","esm");var yA={},tf,SA;function Jr(){if(SA)return tf;SA=1;var n=function(e){return e&&e.Math===Math&&e};return tf=n(typeof globalThis=="object"&&globalThis)||n(typeof window=="object"&&window)||n(typeof self=="object"&&self)||n(typeof Ps=="object"&&Ps)||n(typeof tf=="object"&&tf)||function(){return this}()||Function("return this")(),tf}var $w={},Bw,vA;function Qr(){return vA||(vA=1,Bw=function(n){try{return!!n()}catch{return!0}}),Bw}var Uw,xA;function Jl(){if(xA)return Uw;xA=1;var n=Qr();return Uw=!n(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Uw}var Hw,wA;function C0(){if(wA)return Hw;wA=1;var n=Qr();return Hw=!n(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Hw}var Kw,bA;function Ha(){if(bA)return Kw;bA=1;var n=C0(),e=Function.prototype.call;return Kw=n?e.bind(e):function(){return e.apply(e,arguments)},Kw}var Ww={},CA;function pq(){if(CA)return Ww;CA=1;var n={}.propertyIsEnumerable,e=Object.getOwnPropertyDescriptor,t=e&&!n.call({1:2},1);return Ww.f=t?function(s){var i=e(this,s);return!!i&&i.enumerable}:n,Ww}var Vw,PA;function v3(){return PA||(PA=1,Vw=function(n,e){return{enumerable:!(n&1),configurable:!(n&2),writable:!(n&4),value:e}}),Vw}var qw,kA;function Gn(){if(kA)return qw;kA=1;var n=C0(),e=Function.prototype,t=e.call,r=n&&e.bind.bind(t,t);return qw=n?r:function(s){return function(){return t.apply(s,arguments)}},qw}var Gw,IA;function ih(){if(IA)return Gw;IA=1;var n=Gn(),e=n({}.toString),t=n("".slice);return Gw=function(r){return t(e(r),8,-1)},Gw}var Yw,EA;function gq(){if(EA)return Yw;EA=1;var n=Gn(),e=Qr(),t=ih(),r=Object,s=n("".split);return Yw=e(function(){return!r("z").propertyIsEnumerable(0)})?function(i){return t(i)==="String"?s(i,""):r(i)}:r,Yw}var Xw,_A;function x3(){return _A||(_A=1,Xw=function(n){return n==null}),Xw}var Zw,TA;function oh(){if(TA)return Zw;TA=1;var n=x3(),e=TypeError;return Zw=function(t){if(n(t))throw new e("Can't call method on "+t);return t},Zw}var Jw,MA;function P0(){if(MA)return Jw;MA=1;var n=gq(),e=oh();return Jw=function(t){return n(e(t))},Jw}var Qw,AA;function es(){if(AA)return Qw;AA=1;var n=typeof document=="object"&&document.all;return Qw=typeof n>"u"&&n!==void 0?function(e){return typeof e=="function"||e===n}:function(e){return typeof e=="function"},Qw}var eb,OA;function Ka(){if(OA)return eb;OA=1;var n=es();return eb=function(e){return typeof e=="object"?e!==null:n(e)},eb}var tb,RA;function k0(){if(RA)return tb;RA=1;var n=Jr(),e=es(),t=function(r){return e(r)?r:void 0};return tb=function(r,s){return arguments.length<2?t(n[r]):n[r]&&n[r][s]},tb}var nb,DA;function w3(){if(DA)return nb;DA=1;var n=Gn();return nb=n({}.isPrototypeOf),nb}var rb,jA;function mq(){if(jA)return rb;jA=1;var n=Jr(),e=n.navigator,t=e&&e.userAgent;return rb=t?String(t):"",rb}var sb,LA;function yq(){if(LA)return sb;LA=1;var n=Jr(),e=mq(),t=n.process,r=n.Deno,s=t&&t.versions||r&&r.version,i=s&&s.v8,o,a;return i&&(o=i.split("."),a=o[0]>0&&o[0]<4?1:+(o[0]+o[1])),!a&&e&&(o=e.match(/Edge\/(\d+)/),(!o||o[1]>=74)&&(o=e.match(/Chrome\/(\d+)/),o&&(a=+o[1]))),sb=a,sb}var ib,NA;function b3(){if(NA)return ib;NA=1;var n=yq(),e=Qr(),t=Jr(),r=t.String;return ib=!!Object.getOwnPropertySymbols&&!e(function(){var s=Symbol("symbol detection");return!r(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&n&&n<41}),ib}var ob,FA;function C3(){if(FA)return ob;FA=1;var n=b3();return ob=n&&!Symbol.sham&&typeof Symbol.iterator=="symbol",ob}var ab,zA;function P3(){if(zA)return ab;zA=1;var n=k0(),e=es(),t=w3(),r=C3(),s=Object;return ab=r?function(i){return typeof i=="symbol"}:function(i){var o=n("Symbol");return e(o)&&t(o.prototype,s(i))},ab}var lb,$A;function Sq(){if($A)return lb;$A=1;var n=String;return lb=function(e){try{return n(e)}catch{return"Object"}},lb}var cb,BA;function MI(){if(BA)return cb;BA=1;var n=es(),e=Sq(),t=TypeError;return cb=function(r){if(n(r))return r;throw new t(e(r)+" is not a function")},cb}var ub,UA;function AI(){if(UA)return ub;UA=1;var n=MI(),e=x3();return ub=function(t,r){var s=t[r];return e(s)?void 0:n(s)},ub}var db,HA;function vq(){if(HA)return db;HA=1;var n=Ha(),e=es(),t=Ka(),r=TypeError;return db=function(s,i){var o,a;if(i==="string"&&e(o=s.toString)&&!t(a=n(o,s))||e(o=s.valueOf)&&!t(a=n(o,s))||i!=="string"&&e(o=s.toString)&&!t(a=n(o,s)))return a;throw new r("Can't convert object to primitive value")},db}var hb={exports:{}},fb,KA;function k3(){return KA||(KA=1,fb=!1),fb}var pb,WA;function OI(){if(WA)return pb;WA=1;var n=Jr(),e=Object.defineProperty;return pb=function(t,r){try{e(n,t,{value:r,configurable:!0,writable:!0})}catch{n[t]=r}return r},pb}var VA;function RI(){if(VA)return hb.exports;VA=1;var n=k3(),e=Jr(),t=OI(),r="__core-js_shared__",s=hb.exports=e[r]||t(r,{});return(s.versions||(s.versions=[])).push({version:"3.42.0",mode:n?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"}),hb.exports}var gb,qA;function DI(){if(qA)return gb;qA=1;var n=RI();return gb=function(e,t){return n[e]||(n[e]=t||{})},gb}var mb,GA;function Ap(){if(GA)return mb;GA=1;var n=oh(),e=Object;return mb=function(t){return e(n(t))},mb}var yb,YA;function Ql(){if(YA)return yb;YA=1;var n=Gn(),e=Ap(),t=n({}.hasOwnProperty);return yb=Object.hasOwn||function(s,i){return t(e(s),i)},yb}var Sb,XA;function I3(){if(XA)return Sb;XA=1;var n=Gn(),e=0,t=Math.random(),r=n(1 .toString);return Sb=function(s){return"Symbol("+(s===void 0?"":s)+")_"+r(++e+t,36)},Sb}var vb,ZA;function Wa(){if(ZA)return vb;ZA=1;var n=Jr(),e=DI(),t=Ql(),r=I3(),s=b3(),i=C3(),o=n.Symbol,a=e("wks"),l=i?o.for||o:o&&o.withoutSetter||r;return vb=function(c){return t(a,c)||(a[c]=s&&t(o,c)?o[c]:l("Symbol."+c)),a[c]},vb}var xb,JA;function xq(){if(JA)return xb;JA=1;var n=Ha(),e=Ka(),t=P3(),r=AI(),s=vq(),i=Wa(),o=TypeError,a=i("toPrimitive");return xb=function(l,c){if(!e(l)||t(l))return l;var u=r(l,a),h;if(u){if(c===void 0&&(c="default"),h=n(u,l,c),!e(h)||t(h))return h;throw new o("Can't convert object to primitive value")}return c===void 0&&(c="number"),s(l,c)},xb}var wb,QA;function E3(){if(QA)return wb;QA=1;var n=xq(),e=P3();return wb=function(t){var r=n(t,"string");return e(r)?r:r+""},wb}var bb,eO;function _3(){if(eO)return bb;eO=1;var n=Jr(),e=Ka(),t=n.document,r=e(t)&&e(t.createElement);return bb=function(s){return r?t.createElement(s):{}},bb}var Cb,tO;function T3(){if(tO)return Cb;tO=1;var n=Jl(),e=Qr(),t=_3();return Cb=!n&&!e(function(){return Object.defineProperty(t("div"),"a",{get:function(){return 7}}).a!==7}),Cb}var nO;function M3(){if(nO)return $w;nO=1;var n=Jl(),e=Ha(),t=pq(),r=v3(),s=P0(),i=E3(),o=Ql(),a=T3(),l=Object.getOwnPropertyDescriptor;return $w.f=n?l:function(u,h){if(u=s(u),h=i(h),a)try{return l(u,h)}catch{}if(o(u,h))return r(!e(t.f,u,h),u[h])},$w}var Pb={},kb,rO;function A3(){if(rO)return kb;rO=1;var n=Jl(),e=Qr();return kb=n&&e(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),kb}var Ib,sO;function pu(){if(sO)return Ib;sO=1;var n=Ka(),e=String,t=TypeError;return Ib=function(r){if(n(r))return r;throw new t(e(r)+" is not an object")},Ib}var iO;function Op(){if(iO)return Pb;iO=1;var n=Jl(),e=T3(),t=A3(),r=pu(),s=E3(),i=TypeError,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l="enumerable",c="configurable",u="writable";return Pb.f=n?t?function(p,m,S){if(r(p),m=s(m),r(S),typeof p=="function"&&m==="prototype"&&"value"in S&&u in S&&!S[u]){var x=a(p,m);x&&x[u]&&(p[m]=S.value,S={configurable:c in S?S[c]:x[c],enumerable:l in S?S[l]:x[l],writable:!1})}return o(p,m,S)}:o:function(p,m,S){if(r(p),m=s(m),r(S),e)try{return o(p,m,S)}catch{}if("get"in S||"set"in S)throw new i("Accessors not supported");return"value"in S&&(p[m]=S.value),p},Pb}var Eb,oO;function jI(){if(oO)return Eb;oO=1;var n=Jl(),e=Op(),t=v3();return Eb=n?function(r,s,i){return e.f(r,s,t(1,i))}:function(r,s,i){return r[s]=i,r},Eb}var _b={exports:{}},Tb,aO;function wq(){if(aO)return Tb;aO=1;var n=Jl(),e=Ql(),t=Function.prototype,r=n&&Object.getOwnPropertyDescriptor,s=e(t,"name"),i=s&&(function(){}).name==="something",o=s&&(!n||n&&r(t,"name").configurable);return Tb={EXISTS:s,PROPER:i,CONFIGURABLE:o},Tb}var Mb,lO;function O3(){if(lO)return Mb;lO=1;var n=Gn(),e=es(),t=RI(),r=n(Function.toString);return e(t.inspectSource)||(t.inspectSource=function(s){return r(s)}),Mb=t.inspectSource,Mb}var Ab,cO;function bq(){if(cO)return Ab;cO=1;var n=Jr(),e=es(),t=n.WeakMap;return Ab=e(t)&&/native code/.test(String(t)),Ab}var Ob,uO;function R3(){if(uO)return Ob;uO=1;var n=DI(),e=I3(),t=n("keys");return Ob=function(r){return t[r]||(t[r]=e(r))},Ob}var Rb,dO;function LI(){return dO||(dO=1,Rb={}),Rb}var Db,hO;function D3(){if(hO)return Db;hO=1;var n=bq(),e=Jr(),t=Ka(),r=jI(),s=Ql(),i=RI(),o=R3(),a=LI(),l="Object already initialized",c=e.TypeError,u=e.WeakMap,h,p,m,S=function(C){return m(C)?p(C):h(C,{})},x=function(C){return function(_){var E;if(!t(_)||(E=p(_)).type!==C)throw new c("Incompatible receiver, "+C+" required");return E}};if(n||i.state){var v=i.state||(i.state=new u);v.get=v.get,v.has=v.has,v.set=v.set,h=function(C,_){if(v.has(C))throw new c(l);return _.facade=C,v.set(C,_),_},p=function(C){return v.get(C)||{}},m=function(C){return v.has(C)}}else{var w=o("state");a[w]=!0,h=function(C,_){if(s(C,w))throw new c(l);return _.facade=C,r(C,w,_),_},p=function(C){return s(C,w)?C[w]:{}},m=function(C){return s(C,w)}}return Db={set:h,get:p,has:m,enforce:S,getterFor:x},Db}var fO;function Cq(){if(fO)return _b.exports;fO=1;var n=Gn(),e=Qr(),t=es(),r=Ql(),s=Jl(),i=wq().CONFIGURABLE,o=O3(),a=D3(),l=a.enforce,c=a.get,u=String,h=Object.defineProperty,p=n("".slice),m=n("".replace),S=n([].join),x=s&&!e(function(){return h(function(){},"length",{value:8}).length!==8}),v=String(String).split("String"),w=_b.exports=function(C,_,E){p(u(_),0,7)==="Symbol("&&(_="["+m(u(_),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),E&&E.getter&&(_="get "+_),E&&E.setter&&(_="set "+_),(!r(C,"name")||i&&C.name!==_)&&(s?h(C,"name",{value:_,configurable:!0}):C.name=_),x&&E&&r(E,"arity")&&C.length!==E.arity&&h(C,"length",{value:E.arity});try{E&&r(E,"constructor")&&E.constructor?s&&h(C,"prototype",{writable:!1}):C.prototype&&(C.prototype=void 0)}catch{}var T=l(C);return r(T,"source")||(T.source=S(v,typeof _=="string"?_:"")),C};return Function.prototype.toString=w(function(){return t(this)&&c(this).source||o(this)},"toString"),_b.exports}var jb,pO;function j3(){if(pO)return jb;pO=1;var n=es(),e=Op(),t=Cq(),r=OI();return jb=function(s,i,o,a){a||(a={});var l=a.enumerable,c=a.name!==void 0?a.name:i;if(n(o)&&t(o,c,a),a.global)l?s[i]=o:r(i,o);else{try{a.unsafe?s[i]&&(l=!0):delete s[i]}catch{}l?s[i]=o:e.f(s,i,{value:o,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return s},jb}var Lb={},Nb,gO;function Pq(){if(gO)return Nb;gO=1;var n=Math.ceil,e=Math.floor;return Nb=Math.trunc||function(r){var s=+r;return(s>0?e:n)(s)},Nb}var Fb,mO;function gu(){if(mO)return Fb;mO=1;var n=Pq();return Fb=function(e){var t=+e;return t!==t||t===0?0:n(t)},Fb}var zb,yO;function kq(){if(yO)return zb;yO=1;var n=gu(),e=Math.max,t=Math.min;return zb=function(r,s){var i=n(r);return i<0?e(i+s,0):t(i,s)},zb}var $b,SO;function L3(){if(SO)return $b;SO=1;var n=gu(),e=Math.min;return $b=function(t){var r=n(t);return r>0?e(r,9007199254740991):0},$b}var Bb,vO;function Rp(){if(vO)return Bb;vO=1;var n=L3();return Bb=function(e){return n(e.length)},Bb}var Ub,xO;function Iq(){if(xO)return Ub;xO=1;var n=P0(),e=kq(),t=Rp(),r=function(s){return function(i,o,a){var l=n(i),c=t(l);if(c===0)return!s&&-1;var u=e(a,c),h;if(s&&o!==o){for(;c>u;)if(h=l[u++],h!==h)return!0}else for(;c>u;u++)if((s||u in l)&&l[u]===o)return s||u||0;return!s&&-1}};return Ub={includes:r(!0),indexOf:r(!1)},Ub}var Hb,wO;function N3(){if(wO)return Hb;wO=1;var n=Gn(),e=Ql(),t=P0(),r=Iq().indexOf,s=LI(),i=n([].push);return Hb=function(o,a){var l=t(o),c=0,u=[],h;for(h in l)!e(s,h)&&e(l,h)&&i(u,h);for(;a.length>c;)e(l,h=a[c++])&&(~r(u,h)||i(u,h));return u},Hb}var Kb,bO;function NI(){return bO||(bO=1,Kb=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),Kb}var CO;function Eq(){if(CO)return Lb;CO=1;var n=N3(),e=NI(),t=e.concat("length","prototype");return Lb.f=Object.getOwnPropertyNames||function(s){return n(s,t)},Lb}var Wb={},PO;function _q(){return PO||(PO=1,Wb.f=Object.getOwnPropertySymbols),Wb}var Vb,kO;function Tq(){if(kO)return Vb;kO=1;var n=k0(),e=Gn(),t=Eq(),r=_q(),s=pu(),i=e([].concat);return Vb=n("Reflect","ownKeys")||function(a){var l=t.f(s(a)),c=r.f;return c?i(l,c(a)):l},Vb}var qb,IO;function Mq(){if(IO)return qb;IO=1;var n=Ql(),e=Tq(),t=M3(),r=Op();return qb=function(s,i,o){for(var a=e(i),l=r.f,c=t.f,u=0;u<a.length;u++){var h=a[u];!n(s,h)&&!(o&&n(o,h))&&l(s,h,c(i,h))}},qb}var Gb,EO;function Aq(){if(EO)return Gb;EO=1;var n=Qr(),e=es(),t=/#|\.prototype\./,r=function(l,c){var u=i[s(l)];return u===a?!0:u===o?!1:e(c)?n(c):!!c},s=r.normalize=function(l){return String(l).replace(t,".").toLowerCase()},i=r.data={},o=r.NATIVE="N",a=r.POLYFILL="P";return Gb=r,Gb}var Yb,_O;function ah(){if(_O)return Yb;_O=1;var n=Jr(),e=M3().f,t=jI(),r=j3(),s=OI(),i=Mq(),o=Aq();return Yb=function(a,l){var c=a.target,u=a.global,h=a.stat,p,m,S,x,v,w;if(u?m=n:h?m=n[c]||s(c,{}):m=n[c]&&n[c].prototype,m)for(S in l){if(v=l[S],a.dontCallGetSet?(w=e(m,S),x=w&&w.value):x=m[S],p=o(u?S:c+(h?".":"#")+S,a.forced),!p&&x!==void 0){if(typeof v==typeof x)continue;i(v,x)}(a.sham||x&&x.sham)&&t(v,"sham",!0),r(m,S,v,a)}},Yb}var Xb={},Zb,TO;function Oq(){if(TO)return Zb;TO=1;var n=N3(),e=NI();return Zb=Object.keys||function(r){return n(r,e)},Zb}var MO;function Rq(){if(MO)return Xb;MO=1;var n=Jl(),e=A3(),t=Op(),r=pu(),s=P0(),i=Oq();return Xb.f=n&&!e?Object.defineProperties:function(a,l){r(a);for(var c=s(l),u=i(l),h=u.length,p=0,m;h>p;)t.f(a,m=u[p++],c[m]);return a},Xb}var Jb,AO;function Dq(){if(AO)return Jb;AO=1;var n=k0();return Jb=n("document","documentElement"),Jb}var Qb,OO;function F3(){if(OO)return Qb;OO=1;var n=pu(),e=Rq(),t=NI(),r=LI(),s=Dq(),i=_3(),o=R3(),a=">",l="<",c="prototype",u="script",h=o("IE_PROTO"),p=function(){},m=function(C){return l+u+a+C+l+"/"+u+a},S=function(C){C.write(m("")),C.close();var _=C.parentWindow.Object;return C=null,_},x=function(){var C=i("iframe"),_="java"+u+":",E;return C.style.display="none",s.appendChild(C),C.src=String(_),E=C.contentWindow.document,E.open(),E.write(m("document.F=Object")),E.close(),E.F},v,w=function(){try{v=new ActiveXObject("htmlfile")}catch{}w=typeof document<"u"?document.domain&&v?S(v):x():S(v);for(var C=t.length;C--;)delete w[c][t[C]];return w()};return r[h]=!0,Qb=Object.create||function(_,E){var T;return _!==null?(p[c]=n(_),T=new p,p[c]=null,T[h]=_):T=w(),E===void 0?T:e.f(T,E)},Qb}var e1,RO;function FI(){if(RO)return e1;RO=1;var n=Wa(),e=F3(),t=Op().f,r=n("unscopables"),s=Array.prototype;return s[r]===void 0&&t(s,r,{configurable:!0,value:e(null)}),e1=function(i){s[r][i]=!0},e1}var DO;function jq(){if(DO)return yA;DO=1;var n=ah(),e=Ap(),t=Rp(),r=gu(),s=FI();return n({target:"Array",proto:!0},{at:function(o){var a=e(this),l=t(a),c=r(o),u=c>=0?c:l+c;return u<0||u>=l?void 0:a[u]}}),s("at"),yA}var t1,jO;function Dp(){if(jO)return t1;jO=1;var n=Jr(),e=Gn();return t1=function(t,r){return e(n[t].prototype[r])},t1}var n1,LO;function Lq(){if(LO)return n1;LO=1,jq();var n=Dp();return n1=n("Array","at"),n1}var r1,NO;function Nq(){if(NO)return r1;NO=1;var n=Lq();return r1=n,r1}Nq();var FO={},s1,zO;function z3(){if(zO)return s1;zO=1;var n=ih();return s1=Array.isArray||function(t){return n(t)==="Array"},s1}var i1,$O;function Fq(){if($O)return i1;$O=1;var n=TypeError,e=9007199254740991;return i1=function(t){if(t>e)throw n("Maximum allowed index exceeded");return t},i1}var o1,BO;function zq(){if(BO)return o1;BO=1;var n=ih(),e=Gn();return o1=function(t){if(n(t)==="Function")return e(t)},o1}var a1,UO;function $q(){if(UO)return a1;UO=1;var n=zq(),e=MI(),t=C0(),r=n(n.bind);return a1=function(s,i){return e(s),i===void 0?s:t?r(s,i):function(){return s.apply(i,arguments)}},a1}var l1,HO;function $3(){if(HO)return l1;HO=1;var n=z3(),e=Rp(),t=Fq(),r=$q(),s=function(i,o,a,l,c,u,h,p){for(var m=c,S=0,x=h?r(h,p):!1,v,w;S<l;)S in a&&(v=x?x(a[S],S,o):a[S],u>0&&n(v)?(w=e(v),m=s(i,o,v,w,m,u-1)-1):(t(m+1),i[m]=v),m++),S++;return m};return l1=s,l1}var c1,KO;function Bq(){if(KO)return c1;KO=1;var n=Wa(),e=n("toStringTag"),t={};return t[e]="z",c1=String(t)==="[object z]",c1}var u1,WO;function B3(){if(WO)return u1;WO=1;var n=Bq(),e=es(),t=ih(),r=Wa(),s=r("toStringTag"),i=Object,o=t(function(){return arguments}())==="Arguments",a=function(l,c){try{return l[c]}catch{}};return u1=n?t:function(l){var c,u,h;return l===void 0?"Undefined":l===null?"Null":typeof(u=a(c=i(l),s))=="string"?u:o?t(c):(h=t(c))==="Object"&&e(c.callee)?"Arguments":h},u1}var d1,VO;function Uq(){if(VO)return d1;VO=1;var n=Gn(),e=Qr(),t=es(),r=B3(),s=k0(),i=O3(),o=function(){},a=s("Reflect","construct"),l=/^\s*(?:class|function)\b/,c=n(l.exec),u=!l.test(o),h=function(S){if(!t(S))return!1;try{return a(o,[],S),!0}catch{return!1}},p=function(S){if(!t(S))return!1;switch(r(S)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return u||!!c(l,i(S))}catch{return!0}};return p.sham=!0,d1=!a||e(function(){var m;return h(h.call)||!h(Object)||!h(function(){m=!0})||m})?p:h,d1}var h1,qO;function Hq(){if(qO)return h1;qO=1;var n=z3(),e=Uq(),t=Ka(),r=Wa(),s=r("species"),i=Array;return h1=function(o){var a;return n(o)&&(a=o.constructor,e(a)&&(a===i||n(a.prototype))?a=void 0:t(a)&&(a=a[s],a===null&&(a=void 0))),a===void 0?i:a},h1}var f1,GO;function U3(){if(GO)return f1;GO=1;var n=Hq();return f1=function(e,t){return new(n(e))(t===0?0:t)},f1}var YO;function Kq(){if(YO)return FO;YO=1;var n=ah(),e=$3(),t=MI(),r=Ap(),s=Rp(),i=U3();return n({target:"Array",proto:!0},{flatMap:function(a){var l=r(this),c=s(l),u;return t(a),u=i(l,0),u.length=e(u,l,l,c,0,1,a,arguments.length>1?arguments[1]:void 0),u}}),FO}var XO={},ZO;function Wq(){if(ZO)return XO;ZO=1;var n=FI();return n("flatMap"),XO}var p1,JO;function Vq(){if(JO)return p1;JO=1,Kq(),Wq();var n=Dp();return p1=n("Array","flatMap"),p1}var g1,QO;function qq(){if(QO)return g1;QO=1;var n=Vq();return g1=n,g1}qq();var eR={},tR;function Gq(){if(tR)return eR;tR=1;var n=ah(),e=$3(),t=Ap(),r=Rp(),s=gu(),i=U3();return n({target:"Array",proto:!0},{flat:function(){var a=arguments.length?arguments[0]:void 0,l=t(this),c=r(l),u=i(l,0);return u.length=e(u,l,l,c,0,a===void 0?1:s(a)),u}}),eR}var nR={},rR;function Yq(){if(rR)return nR;rR=1;var n=FI();return n("flat"),nR}var m1,sR;function Xq(){if(sR)return m1;sR=1,Gq(),Yq();var n=Dp();return m1=n("Array","flat"),m1}var y1,iR;function Zq(){if(iR)return y1;iR=1;var n=Xq();return y1=n,y1}Zq();var oR={},S1,aR;function jp(){if(aR)return S1;aR=1;var n=B3(),e=String;return S1=function(t){if(n(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return e(t)},S1}var lR;function Jq(){if(lR)return oR;lR=1;var n=ah(),e=Gn(),t=oh(),r=gu(),s=jp(),i=Qr(),o=e("".charAt),a=i(function(){return"𠮷".at(-2)!=="\uD842"});return n({target:"String",proto:!0,forced:a},{at:function(c){var u=s(t(this)),h=u.length,p=r(c),m=p>=0?p:h+p;return m<0||m>=h?void 0:o(u,m)}}),oR}var v1,cR;function Qq(){if(cR)return v1;cR=1,Jq();var n=Dp();return v1=n("String","at"),v1}var x1,uR;function eG(){if(uR)return x1;uR=1;var n=Qq();return x1=n,x1}eG();var dR={},w1,hR;function H3(){if(hR)return w1;hR=1;var n=pu();return w1=function(){var e=n(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},w1}var b1,fR;function tG(){if(fR)return b1;fR=1;var n=Qr(),e=Jr(),t=e.RegExp,r=n(function(){var o=t("a","y");return o.lastIndex=2,o.exec("abcd")!==null}),s=r||n(function(){return!t("a","y").sticky}),i=r||n(function(){var o=t("^r","gy");return o.lastIndex=2,o.exec("str")!==null});return b1={BROKEN_CARET:i,MISSED_STICKY:s,UNSUPPORTED_Y:r},b1}var C1,pR;function nG(){if(pR)return C1;pR=1;var n=Qr(),e=Jr(),t=e.RegExp;return C1=n(function(){var r=t(".","s");return!(r.dotAll&&r.test(`
|
|
71
|
-
`)&&r.flags==="s")}),C1}var P1,gR;function rG(){if(gR)return P1;gR=1;var n=Qr(),e=Jr(),t=e.RegExp;return P1=n(function(){var r=t("(?<a>b)","g");return r.exec("b").groups.a!=="b"||"b".replace(r,"$<a>c")!=="bc"}),P1}var k1,mR;function zI(){if(mR)return k1;mR=1;var n=Ha(),e=Gn(),t=jp(),r=H3(),s=tG(),i=DI(),o=F3(),a=D3().get,l=nG(),c=rG(),u=i("native-string-replace",String.prototype.replace),h=RegExp.prototype.exec,p=h,m=e("".charAt),S=e("".indexOf),x=e("".replace),v=e("".slice),w=function(){var T=/a/,A=/b*/g;return n(h,T,"a"),n(h,A,"a"),T.lastIndex!==0||A.lastIndex!==0}(),C=s.BROKEN_CARET,_=/()??/.exec("")[1]!==void 0,E=w||_||C||l||c;return E&&(p=function(A){var O=this,D=a(O),$=t(A),H=D.raw,G,J,L,N,U,Y,W;if(H)return H.lastIndex=O.lastIndex,G=n(p,H,$),O.lastIndex=H.lastIndex,G;var z=D.groups,V=C&&O.sticky,ee=n(r,O),B=O.source,Q=0,me=$;if(V&&(ee=x(ee,"y",""),S(ee,"g")===-1&&(ee+="g"),me=v($,O.lastIndex),O.lastIndex>0&&(!O.multiline||O.multiline&&m($,O.lastIndex-1)!==`
|
|
72
|
-
`)&&(B="(?: "+B+")",me=" "+me,Q++),J=new RegExp("^(?:"+B+")",ee)),_&&(J=new RegExp("^"+B+"$(?!\\s)",ee)),w&&(L=O.lastIndex),N=n(h,V?J:O,me),V?N?(N.input=v(N.input,Q),N[0]=v(N[0],Q),N.index=O.lastIndex,O.lastIndex+=N[0].length):O.lastIndex=0:w&&N&&(O.lastIndex=O.global?N.index+N[0].length:L),_&&N&&N.length>1&&n(u,N[0],J,function(){for(U=1;U<arguments.length-2;U++)arguments[U]===void 0&&(N[U]=void 0)}),N&&z)for(N.groups=Y=o(null),U=0;U<z.length;U++)W=z[U],Y[W[0]]=N[W[1]];return N}),k1=p,k1}var yR;function K3(){if(yR)return dR;yR=1;var n=ah(),e=zI();return n({target:"RegExp",proto:!0,forced:/./.exec!==e},{exec:e}),dR}var SR={},I1,vR;function sG(){if(vR)return I1;vR=1;var n=C0(),e=Function.prototype,t=e.apply,r=e.call;return I1=typeof Reflect=="object"&&Reflect.apply||(n?r.bind(t):function(){return r.apply(t,arguments)}),I1}var E1,xR;function iG(){if(xR)return E1;xR=1,K3();var n=Ha(),e=j3(),t=zI(),r=Qr(),s=Wa(),i=jI(),o=s("species"),a=RegExp.prototype;return E1=function(l,c,u,h){var p=s(l),m=!r(function(){var w={};return w[p]=function(){return 7},""[l](w)!==7}),S=m&&!r(function(){var w=!1,C=/a/;return l==="split"&&(C={},C.constructor={},C.constructor[o]=function(){return C},C.flags="",C[p]=/./[p]),C.exec=function(){return w=!0,null},C[p](""),!w});if(!m||!S||u){var x=/./[p],v=c(p,""[l],function(w,C,_,E,T){var A=C.exec;return A===t||A===a.exec?m&&!T?{done:!0,value:n(x,C,_,E)}:{done:!0,value:n(w,_,C,E)}:{done:!1}});e(String.prototype,l,v[0]),e(a,p,v[1])}h&&i(a[p],"sham",!0)},E1}var _1,wR;function oG(){if(wR)return _1;wR=1;var n=Gn(),e=gu(),t=jp(),r=oh(),s=n("".charAt),i=n("".charCodeAt),o=n("".slice),a=function(l){return function(c,u){var h=t(r(c)),p=e(u),m=h.length,S,x;return p<0||p>=m?l?"":void 0:(S=i(h,p),S<55296||S>56319||p+1===m||(x=i(h,p+1))<56320||x>57343?l?s(h,p):S:l?o(h,p,p+2):(S-55296<<10)+(x-56320)+65536)}};return _1={codeAt:a(!1),charAt:a(!0)},_1}var T1,bR;function aG(){if(bR)return T1;bR=1;var n=oG().charAt;return T1=function(e,t,r){return t+(r?n(e,t).length:1)},T1}var M1,CR;function W3(){if(CR)return M1;CR=1;var n=Gn(),e=Ap(),t=Math.floor,r=n("".charAt),s=n("".replace),i=n("".slice),o=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,a=/\$([$&'`]|\d{1,2})/g;return M1=function(l,c,u,h,p,m){var S=u+l.length,x=h.length,v=a;return p!==void 0&&(p=e(p),v=o),s(m,v,function(w,C){var _;switch(r(C,0)){case"$":return"$";case"&":return l;case"`":return i(c,0,u);case"'":return i(c,S);case"<":_=p[i(C,1,-1)];break;default:var E=+C;if(E===0)return w;if(E>x){var T=t(E/10);return T===0?w:T<=x?h[T-1]===void 0?r(C,1):h[T-1]+r(C,1):w}_=h[E-1]}return _===void 0?"":_})},M1}var A1,PR;function lG(){if(PR)return A1;PR=1;var n=Ha(),e=pu(),t=es(),r=ih(),s=zI(),i=TypeError;return A1=function(o,a){var l=o.exec;if(t(l)){var c=n(l,o,a);return c!==null&&e(c),c}if(r(o)==="RegExp")return n(s,o,a);throw new i("RegExp#exec called on incompatible receiver")},A1}var kR;function cG(){if(kR)return SR;kR=1;var n=sG(),e=Ha(),t=Gn(),r=iG(),s=Qr(),i=pu(),o=es(),a=Ka(),l=gu(),c=L3(),u=jp(),h=oh(),p=aG(),m=AI(),S=W3(),x=lG(),v=Wa(),w=v("replace"),C=Math.max,_=Math.min,E=t([].concat),T=t([].push),A=t("".indexOf),O=t("".slice),D=function(J){return J===void 0?J:String(J)},$=function(){return"a".replace(/./,"$0")==="$0"}(),H=function(){return/./[w]?/./[w]("a","$0")==="":!1}(),G=!s(function(){var J=/./;return J.exec=function(){var L=[];return L.groups={a:"7"},L},"".replace(J,"$<a>")!=="7"});return r("replace",function(J,L,N){var U=H?"$":"$0";return[function(W,z){var V=h(this),ee=a(W)?m(W,w):void 0;return ee?e(ee,W,V,z):e(L,u(V),W,z)},function(Y,W){var z=i(this),V=u(Y);if(typeof W=="string"&&A(W,U)===-1&&A(W,"$<")===-1){var ee=N(L,z,V,W);if(ee.done)return ee.value}var B=o(W);B||(W=u(W));var Q=z.global,me;Q&&(me=z.unicode,z.lastIndex=0);for(var Pe=[],ue;ue=x(z,V),!(ue===null||(T(Pe,ue),!Q));){var Oe=u(ue[0]);Oe===""&&(z.lastIndex=p(V,c(z.lastIndex),me))}for(var Ne="",be=0,Ee=0;Ee<Pe.length;Ee++){ue=Pe[Ee];for(var Ke=u(ue[0]),Lt=C(_(l(ue.index),V.length),0),Jt=[],Et,Tt=1;Tt<ue.length;Tt++)T(Jt,D(ue[Tt]));var nn=ue.groups;if(B){var In=E([Ke],Jt,Lt,V);nn!==void 0&&T(In,nn),Et=u(n(W,void 0,In))}else Et=S(Ke,V,Lt,Jt,nn,W);Lt>=be&&(Ne+=O(V,be,Lt)+Et,be=Lt+Ke.length)}return Ne+O(V,be)}]},!G||!$||H),SR}var IR={},O1,ER;function uG(){if(ER)return O1;ER=1;var n=Ka(),e=ih(),t=Wa(),r=t("match");return O1=function(s){var i;return n(s)&&((i=s[r])!==void 0?!!i:e(s)==="RegExp")},O1}var R1,_R;function dG(){if(_R)return R1;_R=1;var n=Ha(),e=Ql(),t=w3(),r=H3(),s=RegExp.prototype;return R1=function(i){var o=i.flags;return o===void 0&&!("flags"in s)&&!e(i,"flags")&&t(s,i)?n(r,i):o},R1}var TR;function hG(){if(TR)return IR;TR=1;var n=ah(),e=Ha(),t=Gn(),r=oh(),s=es(),i=Ka(),o=uG(),a=jp(),l=AI(),c=dG(),u=W3(),h=Wa(),p=k3(),m=h("replace"),S=TypeError,x=t("".indexOf),v=t("".replace),w=t("".slice),C=Math.max;return n({target:"String",proto:!0},{replaceAll:function(E,T){var A=r(this),O,D,$,H,G,J,L,N,U,Y,W=0,z="";if(i(E)){if(O=o(E),O&&(D=a(r(c(E))),!~x(D,"g")))throw new S("`.replaceAll` does not allow non-global regexes");if($=l(E,m),$)return e($,E,A,T);if(p&&O)return v(a(A),E,T)}for(H=a(A),G=a(E),J=s(T),J||(T=a(T)),L=G.length,N=C(1,L),U=x(H,G);U!==-1;)Y=J?a(T(G,U,H)):u(G,H,U,[],void 0,T),z+=w(H,W,U)+Y,W=U+L,U=U+N>H.length?-1:x(H,G,U+N);return W<H.length&&(z+=w(H,W)),z}}),IR}var D1,MR;function fG(){if(MR)return D1;MR=1,K3(),cG(),hG();var n=Dp();return D1=n("String","replaceAll"),D1}var j1,AR;function pG(){if(AR)return j1;AR=1;var n=fG();return j1=n,j1}pG();function V3(n){return n&&typeof n=="object"&&"parents"in n}function q3(n){for(let e=0,t=n.parents.length;e<t;e++)if(n.parents[e].__unsafe__getWithoutCapture(!0),n.parents[e].lastChangedEpoch!==n.parentEpochs[e])return!0;return!1}function Gy(n,e){if(n.children.remove(e)&&n.children.isEmpty&&V3(n))for(let t=0,r=n.parents.length;t<r;t++)Gy(n.parents[t],n)}function $I(n,e){if(n.children.add(e)&&V3(n))for(let t=0,r=n.parents.length;t<r;t++)$I(n.parents[t],n)}function G3(n,e){return n===e||Object.is(n,e)||!!(n&&e&&typeof n.equals=="function"&&n.equals(e))}function ec(n,e){const t=Symbol.for(`com.tldraw.state/${n}`),r=globalThis;return r[t]??(r[t]=e()),r[t]}const kr=ec("empty_array",()=>Object.freeze([])),OR=8;class Yy{constructor(){R(this,"arraySize",0);R(this,"array",Array(OR));R(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<OR?(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 t=this.array.indexOf(e);return t===-1?!1:(this.array[t]=void 0,this.arraySize--,t!==this.arraySize&&(this.array[t]=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 t=0;t<this.arraySize;t++){const r=this.array[t];typeof r<"u"&&e(r)}return}if(this.set){this.set.forEach(e);return}throw new Error("no set or array")}*[Symbol.iterator](){if(this.array)for(let e=0;e<this.arraySize;e++){const t=this.array[e];typeof t<"u"&&(yield t)}else if(this.set)yield*this.set;else 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 Ws=Symbol.for("com.tldraw.state/RESET_VALUE");class Y3{constructor(e){R(this,"index",0);R(this,"buffer");this.capacity=e,this.buffer=new Array(e)}pushEntry(e,t,r){if(r!==void 0){if(r===Ws){this.clear();return}this.buffer[this.index]=[e,t,r],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(e){const{index:t,capacity:r,buffer:s}=this;for(let i=0;i<r;i++){const o=(t-1+r-i)%r,a=s[o];if(!a)return Ws;const[l,c]=a;if(i===0&&e>=c)return[];if(l<=e&&e<c){const u=i+1,h=new Array(u);for(let p=0;p<u;p++)h[p]=s[(o+p)%r][2];return h}}return Ws}}const jl=-1;class gG{constructor(e,t,r){R(this,"_isActivelyListening",!1);R(this,"lastTraversedEpoch",jl);R(this,"lastReactedEpoch",jl);R(this,"_scheduleCount",0);R(this,"__debug_ancestor_epochs__",null);R(this,"parentSet",new Yy);R(this,"parentEpochs",[]);R(this,"parents",[]);R(this,"_scheduleEffect");R(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=e,this.runEffect=t,this._scheduleEffect=r==null?void 0:r.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==xs()){if(this.parents.length&&!q3(this)){this.lastReactedEpoch=xs();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let e=0,t=this.parents.length;e<t;e++)$I(this.parents[e],this)}detach(){this._isActivelyListening=!1;for(let e=0,t=this.parents.length;e<t;e++)Gy(this.parents[e],this)}execute(){try{Q3(this);const e=xs(),t=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=e,t}finally{eF()}}}const mu=ec("EffectScheduler",()=>gG);function Pi(n,e,t){const r=new mu(n,e,t);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function mG(n,e,t){const r=new mu(n,e,t);return{scheduler:r,start:s=>{const i=(s==null?void 0:s.force)??!1;r.attach(),i?r.scheduleEffect():r.maybeScheduleEffect()},stop:()=>{r.detach()}}}let yG=class{constructor(e){R(this,"initialAtomValues",new Map);this.parent=e}get isRoot(){return this.parent===null}commit(){if(kt.globalIsReacting)for(const e of this.initialAtomValues.keys())Z3(e);else this.isRoot?X3(this.initialAtomValues.keys()):this.initialAtomValues.forEach((e,t)=>{this.parent.initialAtomValues.has(t)||this.parent.initialAtomValues.set(t,e)})}abort(){kt.globalEpoch++,this.initialAtomValues.forEach((e,t)=>{var r;t.set(e),(r=t.historyBuffer)==null||r.clear()}),this.commit()}};const kt=ec("transactions",()=>({globalEpoch:jl+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:jl+1}));function SG(){return kt.reactionEpoch}function xs(){return kt.globalEpoch}function vG(){return kt.globalIsReacting}function BI(n,e){e.lastTraversedEpoch!==kt.globalEpoch&&(e.lastTraversedEpoch=kt.globalEpoch,e instanceof mu?n.add(e):e.children.visit(t=>BI(n,t)))}function X3(n){var t;if(kt.globalIsReacting)throw new Error("flushChanges cannot be called during a reaction");const e=kt.currentTransaction;try{kt.currentTransaction=null,kt.globalIsReacting=!0,kt.reactionEpoch=kt.globalEpoch;const r=new Set;for(const i of n)i.children.visit(o=>BI(r,o));for(const i of r)i.maybeScheduleEffect();let s=0;for(;(t=kt.cleanupReactors)!=null&&t.size;){if(s++>1e3)throw new Error("Reaction update depth limit exceeded");const i=kt.cleanupReactors;kt.cleanupReactors=null;for(const o of i)o.maybeScheduleEffect()}}finally{kt.cleanupReactors=null,kt.globalIsReacting=!1,kt.currentTransaction=e}}function xG(n,e){kt.currentTransaction?kt.currentTransaction.initialAtomValues.has(n)||kt.currentTransaction.initialAtomValues.set(n,e):kt.globalIsReacting?Z3(n):X3([n])}function Z3(n){const e=kt.cleanupReactors??(kt.cleanupReactors=new Set);n.children.visit(t=>BI(e,t))}function wG(){kt.globalEpoch++}function bG(n){const e=new yG(kt.currentTransaction);kt.currentTransaction=e;try{let t,r=!1;try{t=n(()=>r=!0)}catch(s){throw e.abort(),s}return r?e.abort():e.commit(),t}finally{kt.currentTransaction=kt.currentTransaction.parent}}function Vs(n){return kt.currentTransaction?n():bG(n)}let RR=!1;function CG(){RR||(RR=!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.
|
|
73
|
-
|
|
74
|
-
// Before
|
|
75
|
-
@computed
|
|
76
|
-
get foo() {
|
|
77
|
-
return 'foo'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// After
|
|
81
|
-
@computed
|
|
82
|
-
getFoo() {
|
|
83
|
-
return 'foo'
|
|
84
|
-
}
|
|
85
|
-
`))}const xr=Symbol.for("com.tldraw.state/UNINITIALIZED");function Uc(n){return n===xr}const DP=ec("WithDiff",()=>class{constructor(e,t){this.value=e,this.diff=t}});function xf(n,e){return new DP(n,e)}class PG{constructor(e,t,r){R(this,"lastChangedEpoch",jl);R(this,"lastTraversedEpoch",jl);R(this,"__debug_ancestor_epochs__",null);R(this,"lastCheckedEpoch",jl);R(this,"parentSet",new Yy);R(this,"parents",[]);R(this,"parentEpochs",[]);R(this,"children",new Yy);R(this,"historyBuffer");R(this,"state",xr);R(this,"error",null);R(this,"computeDiff");R(this,"isEqual");this.name=e,this.derive=t,r!=null&&r.historyLength&&(this.historyBuffer=new Y3(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??G3}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(e){var s;const t=this.lastChangedEpoch===jl,r=xs();if(!t&&(this.lastCheckedEpoch===r||this.isActivelyListening&&vG()&&this.lastTraversedEpoch<SG()||!q3(this)))if(this.lastCheckedEpoch=r,this.error){if(e)return this.state;throw this.error.thrownValue}else return this.state;try{Q3(this);const i=this.derive(this.state,this.lastCheckedEpoch),o=i instanceof DP?i.value:i,a=this.state===xr;if(a||!this.isEqual(o,this.state)){if(this.historyBuffer&&!a){const l=i instanceof DP?i.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,xs(),l??((s=this.computeDiff)==null?void 0:s.call(this,this.state,o,this.lastCheckedEpoch,xs()))??Ws)}this.lastChangedEpoch=xs(),this.state=o}return this.error=null,this.lastCheckedEpoch=xs(),this.state}catch(i){if(this.state!==xr&&(this.state=xr,this.lastChangedEpoch=xs()),this.lastCheckedEpoch=xs(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:i},!e)throw i;return this.state}finally{eF()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Xy(this)}}getDiffSince(e){var t;return this.__unsafe__getWithoutCapture(!0),Xy(this),e>=this.lastChangedEpoch?kr:((t=this.historyBuffer)==null?void 0:t.getChangesSince(e))??Ws}}const Lp=ec("Computed",()=>PG);function kG(n={},e,t,r){const s=r.value,i=Symbol.for("__@tldraw/state__computed__"+t);return r.value=function(){let o=this[i];return o||(o=new Lp(t,s.bind(this),n),Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:o})),o.get()},r.value[J3]=!0,r}function IG(n={},e,t,r){const s=r.get,i=Symbol.for("__@tldraw/state__computed__"+t);return r.get=function(){let o=this[i];return o||(o=new Lp(t,s.bind(this),n),Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:o})),o.get()},r}function EG(n,e,t){Je(t.kind==="method","@computed can only be used on methods");const r=Symbol.for("__@tldraw/state__computed__"+String(t.name)),s=function(){let i=this[r];return i||(i=new Lp(String(t.name),e.bind(this),n),Object.defineProperty(this,r,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()};return s[J3]=!0,s}function DR(n={},e){if(e.length===2){const[t,r]=e;return EG(n,t,r)}else{const[t,r,s]=e;return s.get?(CG(),IG(n,t,r,s)):kG(n,t,r,s)}}const J3="@@__isComputedMethod__@@";function ce(){if(arguments.length===1){const n=arguments[0];return(...e)=>DR(n,e)}else return typeof arguments[0]=="string"?new Lp(arguments[0],arguments[1],arguments[2]):DR(void 0,arguments)}function UI(n){return n&&n instanceof Lp}class _G{constructor(e,t){R(this,"offset",0);R(this,"maybeRemoved");this.below=e,this.child=t}}const en=ec("capture",()=>({stack:null}));function xm(n){const e=en.stack;en.stack=null;try{return n()}finally{en.stack=e}}function Q3(n){if(en.stack=new _G(en.stack,n),n.__debug_ancestor_epochs__){const e=n.__debug_ancestor_epochs__;n.__debug_ancestor_epochs__=null;for(const t of n.parents)t.__unsafe__getWithoutCapture(!0);TG(n,e)}n.parentSet.clear()}function eF(){const n=en.stack;if(en.stack=n.below,n.offset<n.child.parents.length){for(let e=n.offset;e<n.child.parents.length;e++){const t=n.child.parents[e];n.child.parentSet.has(t)||Gy(t,n.child)}n.child.parents.length=n.offset,n.child.parentEpochs.length=n.offset}if(n.maybeRemoved)for(let e=0;e<n.maybeRemoved.length;e++){const t=n.maybeRemoved[e];n.child.parentSet.has(t)||Gy(t,n.child)}n.child.__debug_ancestor_epochs__&&tF(n.child,n.child.__debug_ancestor_epochs__)}function Xy(n){if(en.stack){if(en.stack.child.parentSet.has(n))return;if(en.stack.child.parentSet.add(n),en.stack.child.isActivelyListening&&$I(n,en.stack.child),en.stack.offset<en.stack.child.parents.length){const t=en.stack.child.parents[en.stack.offset];t!==n&&(en.stack.maybeRemoved?en.stack.maybeRemoved.push(t):en.stack.maybeRemoved=[t])}en.stack.child.parents[en.stack.offset]=n,en.stack.child.parentEpochs[en.stack.offset]=n.lastChangedEpoch,en.stack.offset++}}function tF(n,e){for(let t=0;t<n.parents.length;t++){const r=n.parents[t],s=n.parentEpochs[t];e.set(r,s),UI(r)&&tF(r,e)}return e}function nF(n,e){const t={};for(let r=0;r<n.parents.length;r++){const s=n.parents[r];if(!e.has(s))continue;const i=e.get(s);s.lastChangedEpoch!==i&&(UI(s)?t[s.name]=nF(s,e):t[s.name]=null)}return t}function TG(n,e){const t=nF(n,e);if(Object.keys(t).length===0){console.log(`Effect(${n.name}) was executed manually.`);return}let r=UI(n)?`Computed(${n.name}) is recomputing because:`:`Effect(${n.name}) is executing because:`;function s(i,o){const a=`
|
|
86
|
-
`+" ".repeat(o)+"↳ ";for(const[l,c]of Object.entries(i))c?(r+=`${a}Computed(${l}) changed`,s(c,o+2)):r+=`${a}Atom(${l}) changed`}s(t,1),console.log(r)}class MG{constructor(e,t,r){R(this,"isEqual");R(this,"computeDiff");R(this,"lastChangedEpoch",xs());R(this,"children",new Yy);R(this,"historyBuffer");this.name=e,this.current=t,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new Y3(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(e){return this.current}get(){return Xy(this),this.current}set(e,t){var s,i;if(((s=this.isEqual)==null?void 0:s.call(this,this.current,e))??G3(this.current,e))return this.current;wG(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,xs(),t??((i=this.computeDiff)==null?void 0:i.call(this,this.current,e,this.lastChangedEpoch,xs()))??Ws),this.lastChangedEpoch=xs();const r=this.current;return this.current=e,xG(this,r),e}update(e){return this.set(e(this.current))}getDiffSince(e){var t;return Xy(this),e>=this.lastChangedEpoch?kr:((t=this.historyBuffer)==null?void 0:t.getChangesSince(e))??Ws}}const AG=ec("Atom",()=>MG);function Sn(n,e,t){return new AG(n,e,t)}const rF=1,OG=ec("apiVersion",()=>rF);if(OG!==rF)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");Zl("@tldraw/state","3.12.1","esm");function I0(n,e,t=[]){const r=at.useRef(e);r.current=e;const[s,i,o]=at.useMemo(()=>{let a=null;const l=h=>(a=h,()=>{a=null}),c=new mu(`useStateTracking(${n})`,()=>{var h;return(h=r.current)==null?void 0:h.call(r)},{scheduleEffect(){a==null||a()}});return[c,l,()=>c.scheduleCount]},[n,...t]);return at.useSyncExternalStore(i,o,o),at.useEffect(()=>(s.attach(),s.maybeScheduleEffect(),()=>{s.detach()}),[s]),s.execute()}const jR={apply(n,e,t){return I0(n.displayName??n.name??"tracked(???)",()=>n.apply(e,t))}},RG=Symbol.for("react.memo"),DG=Symbol.for("react.forward_ref");function Yn(n){let e=null;const t=n.$$typeof;return t===RG&&(n=n.type,e=n.compare),t===DG?P.memo(P.forwardRef(new Proxy(n.render,jR))):P.memo(new Proxy(n,jR),e)}function Np(n,e,t){return P.useState(()=>{const r=typeof e=="function"?e():e;return Sn(`useAtom(${n})`,r,t)})[0]}function jG(){const n=arguments[0],e=arguments[1],t=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return P.useMemo(()=>ce(`useComputed(${n})`,e,t),r)}function Hl(n,e,t=kr){P.useEffect(()=>{const r=new mu(n,e);return r.attach(),r.execute(),()=>{r.detach()}},t)}function HI(n,e,t=[]){const r=P.useRef(-1),s=P.useMemo(()=>new mu(n,e,{scheduleEffect:i=>{const o=requestAnimationFrame(i);return r.current=o,o}}),t);P.useEffect(()=>(s.attach(),s.execute(),()=>{s.detach(),cancelAnimationFrame(r.current)}),[s])}function ie(){const n=arguments,e=n.length===3?n[2]:[n[0]],t=n.length===3?n[0]:`useValue(${n[0].name})`,r=P.useRef(!0);r.current=!0;const s=P.useMemo(()=>n.length===1?n[0]:ce(t,()=>{if(r.current)return n[1]();try{return n[1]()}catch{return{}}}),e);try{const{subscribe:i,getSnapshot:o}=P.useMemo(()=>({subscribe:a=>Pi(`useValue(${t})`,()=>{s.get(),a()}),getSnapshot:()=>s.get()}),[s]);return P.useSyncExternalStore(i,o,o)}finally{r.current=!1}}Zl("@tldraw/state-react","3.12.1","esm");const Hn={linear:n=>n,easeInQuad:n=>n*n,easeOutQuad:n=>n*(2-n),easeInOutQuad:n=>n<.5?2*n*n:-1+(4-2*n)*n,easeInCubic:n=>n*n*n,easeOutCubic:n=>--n*n*n+1,easeInOutCubic:n=>n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1,easeInQuart:n=>n*n*n*n,easeOutQuart:n=>1- --n*n*n*n,easeInOutQuart:n=>n<.5?8*n*n*n*n:1-8*--n*n*n*n,easeInQuint:n=>n*n*n*n*n,easeOutQuint:n=>1+--n*n*n*n*n,easeInOutQuint:n=>n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n,easeInSine:n=>1-Math.cos(n*Math.PI/2),easeOutSine:n=>Math.sin(n*Math.PI/2),easeInOutSine:n=>-(Math.cos(Math.PI*n)-1)/2,easeInExpo:n=>n<=0?0:Math.pow(2,10*n-10),easeOutExpo:n=>n>=1?1:1-Math.pow(2,-10*n),easeInOutExpo:n=>n<=0?0:n>=1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2};function Ct(n){return`${re(n.x)},${re(n.y)} `}function bs(n,e){return`${re((n.x+e.x)/2)},${re((n.y+e.y)/2)} `}const wt=Math.PI,Kt=wt/2,Rt=wt*2,LG=Math.sin;function Mn(n,e,t){return Math.max(e,typeof t<"u"?Math.min(n,t):n)}function wm(n,e=1e10){return n?Math.round(n*e)/e:0}function _a(n,e,t=1e-6){return Math.abs(n-e)<=t}function sF(n,e){const t=Math.pow(n-e,2)/Math.pow(n+e,2);return wt*(n+e)*(1+3*t/(10+Math.sqrt(4-3*t)))}function Hc(n){return n=n%Rt,n<0?n=n+Rt:n===0&&(n=0),n}function Fp(n,e){return n=Hc(n),e=Hc(e),n>e&&(e+=Rt),e-n}function iF(n,e){return Rt-Fp(n,e)}function ly(n,e){const t=(e-n)%Rt;return 2*t%Rt-t}function jP(n){return(Rt+n)%Rt}function Zy(n,e){const t=Rt/e;let r=Math.floor((jP(n)+t/2)/t)*t%Rt;return r<wt&&(r+=Rt),r>wt&&(r-=Rt),r}function oF(n,e){return n===e||_a(n%(Math.PI/2)-e%(Math.PI/2),0)}function NG(n){return n*wt/180}function FG(n){return n*180/wt}function Xc(n,e,t){return new k(n.x,n.y).add(k.FromAngle(t,e))}function L1(n,e,t){const r=n/2,s=e/2,i=[];let o=1/0,a=-1/0,l=1/0,c=-1/0;for(let S=0;S<t;S++){const x=Rt/t,v=-Kt+S*x,w=r+r*Math.cos(v),C=s+s*Math.sin(v);w<o&&(o=w),C<l&&(l=C),w>a&&(a=w),C>c&&(c=C),i.push(new k(w,C))}const u=a-o,h=c-l,p=n-u,m=e-h;if(p!==0||m!==0)for(let S=0;S<i.length;S++){const x=i[S];x.x=(x.x-o)/u*n,x.y=(x.y-l)/h*e}return i}function nf(n,e,t,r){return n<r&&t<e}function Ki(n,e,t,r){const s=Math.max(n,t),i=Math.min(e,r);return s<=i?[s,i]:null}function LR(n,e,t){return(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y)}function qs(n,e){let t=0,r,s;for(let i=0;i<e.length;i++){if(r=e[i],r.x===n.x&&r.y===n.y||(s=e[(i+1)%e.length],k.Dist(n,r)+k.Dist(n,s)===k.Dist(r,s)))return!0;r.y<=n.y?s.y>n.y&&LR(r,s,n)>0&&(t+=1):s.y<=n.y&&LR(r,s,n)<0&&(t-=1)}return t!==0}function re(n){return Math.round(n*1e4)/1e4}function Ca(n){return Math.round(n*100)/100}const NR=n=>Math.abs(n)<Number.MAX_SAFE_INTEGER;function Ml(n,e,t){return t<0?Fp(n,e):iF(n,e)}function LP(n,e,t,r){let s;if(Math.abs(n)>wt){s=ly(e,r);const i=ly(r,t);return Math.abs(s)<Math.abs(i)?s/n:(n-i)/n}else{s=ly(e,r);const i=s/n;return Math.sign(s)!==Math.sign(n)?Math.abs(i)>.5?1:0:i}}function zG(n,e,t,r){const s=2*((e-n)%Rt)%Rt-(e-n)%Rt;return r?(Rt-Math.abs(s))*(t?1:-1):s}function KI(n,e,t){const r=-2*(n.x*(e.y-t.y)-n.y*(e.x-t.x)+e.x*t.y-t.x*e.y),s=((n.x*n.x+n.y*n.y)*(t.y-e.y)+(e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y))/r,i=((n.x*n.x+n.y*n.y)*(e.x-t.x)+(e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x))/r;return!Number.isFinite(s)||!Number.isFinite(i)?null:new k(s,i)}function $G(n,e,t,r,s){if(t===null)return[k.From(n),k.From(e)];const i=[],o=k.Angle(t,n),a=k.Angle(t,e),l=Fp(o,a);for(let c=0;c<s;c++){const u=c/(s-1),h=o+l*u,p=Xc(t,r,h);i.push(p)}return i}class k{constructor(e=0,t=0,r=1){this.x=e,this.y=t,this.z=r}get pressure(){return this.z}set(e=this.x,t=this.y,r=this.z){return this.x=e,this.y=t,this.z=r,this}setTo({x:e=0,y:t=0,z:r=1}){return this.x=e,this.y=t,this.z=r,this}rot(e){if(e===0)return this;const{x:t,y:r}=this,s=Math.sin(e),i=Math.cos(e);return this.x=t*i-r*s,this.y=t*s+r*i,this}rotWith(e,t){if(t===0)return this;const r=this.x-e.x,s=this.y-e.y,i=Math.sin(t),o=Math.cos(t);return this.x=e.x+(r*o-s*i),this.y=e.y+(r*i+s*o),this}clone(){const{x:e,y:t,z:r}=this;return new k(e,t,r)}sub(e){return this.x-=e.x,this.y-=e.y,this}subXY(e,t){return this.x-=e,this.y-=t,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,t){return this.x+=e,this.y+=t,this}addScalar(e){return this.x+=e,this.y+=e,this}clamp(e,t){return this.x=Math.max(this.x,e),this.y=Math.max(this.y,e),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),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,t){const r=k.Tan(e,this);return this.add(r.mul(t))}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 k.Dpr(this,e)}cpr(e){return k.Cpr(this,e)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(e){return k.Pry(this,e)}per(){const{x:e,y:t}=this;return this.x=t,this.y=-e,this}uni(){return k.Uni(this)}tan(e){return k.Tan(this,e)}dist(e){return k.Dist(this,e)}distanceToLineSegment(e,t){return k.DistanceToLineSegment(e,t,this)}slope(e){return k.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 k.Angle(this,e)}toAngle(){return k.ToAngle(this)}lrp(e,t){return this.x=this.x+(e.x-this.x)*t,this.y=this.y+(e.y-this.y)*t,this}equals(e){return k.Equals(this,e)}equalsXY(e,t){return k.EqualsXY(this,e,t)}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 k.ToFixed(this)}toString(){return k.ToString(k.ToFixed(this))}toJson(){return k.ToJson(this)}toArray(){return k.ToArray(this)}static Add(e,t){return new k(e.x+t.x,e.y+t.y)}static AddXY(e,t,r){return new k(e.x+t,e.y+r)}static Sub(e,t){return new k(e.x-t.x,e.y-t.y)}static SubXY(e,t,r){return new k(e.x-t,e.y-r)}static AddScalar(e,t){return new k(e.x+t,e.y+t)}static SubScalar(e,t){return new k(e.x-t,e.y-t)}static Div(e,t){return new k(e.x/t,e.y/t)}static Mul(e,t){return new k(e.x*t,e.y*t)}static DivV(e,t){return new k(e.x/t.x,e.y/t.y)}static MulV(e,t){return new k(e.x*t.x,e.y*t.y)}static Neg(e){return new k(-e.x,-e.y)}static Per(e){return new k(e.y,-e.x)}static Abs(e){return new k(Math.abs(e.x),Math.abs(e.y))}static Dist(e,t){return((e.y-t.y)**2+(e.x-t.x)**2)**.5}static DistMin(e,t,r){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)<r**2}static Dist2(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}static Dpr(e,t){return e.x*t.x+e.y*t.y}static Cross(e,t){return new k(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z)}static Cpr(e,t){return e.x*t.y-t.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,t){return k.Dpr(e,t)/k.Len(t)}static Uni(e){return k.Div(e,k.Len(e))}static Tan(e,t){return k.Uni(k.Sub(e,t))}static Min(e,t){return new k(Math.min(e.x,t.x),Math.min(e.y,t.y))}static Max(e,t){return new k(Math.max(e.x,t.x),Math.max(e.y,t.y))}static From({x:e,y:t,z:r=1}){return new k(e,t,r)}static FromArray(e){return new k(e[0],e[1])}static Rot(e,t=0){const r=Math.sin(t),s=Math.cos(t);return new k(e.x*s-e.y*r,e.x*r+e.y*s)}static RotWith(e,t,r){const s=e.x-t.x,i=e.y-t.y,o=Math.sin(r),a=Math.cos(r);return new k(t.x+(s*a-i*o),t.y+(s*o+i*a))}static NearestPointOnLineThroughPoint(e,t,r){return k.Mul(t,k.Sub(r,e).pry(t)).add(e)}static NearestPointOnLineSegment(e,t,r,s=!0){if(k.Equals(e,r)||k.Equals(t,r))return k.From(r);const i=k.Tan(t,e),o=k.Add(e,k.Mul(i,k.Sub(r,e).pry(i)));if(s){if(o.x<Math.min(e.x,t.x))return k.Cast(e.x<t.x?e:t);if(o.x>Math.max(e.x,t.x))return k.Cast(e.x>t.x?e:t);if(o.y<Math.min(e.y,t.y))return k.Cast(e.y<t.y?e:t);if(o.y>Math.max(e.y,t.y))return k.Cast(e.y>t.y?e:t)}return o}static DistanceToLineThroughPoint(e,t,r){return k.Dist(r,k.NearestPointOnLineThroughPoint(e,t,r))}static DistanceToLineSegment(e,t,r,s=!0){return k.Dist(r,k.NearestPointOnLineSegment(e,t,r,s))}static Snap(e,t=1){return new k(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}static Cast(e){return e instanceof k?e:k.From(e)}static Slope(e,t){return e.x===t.y?NaN:(e.y-t.y)/(e.x-t.x)}static IsNaN(e){return isNaN(e.x)||isNaN(e.y)}static Angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}static Lrp(e,t,r){return k.Sub(t,e).mul(r).add(e)}static Med(e,t){return new k((e.x+t.x)/2,(e.y+t.y)/2)}static Equals(e,t){return Math.abs(e.x-t.x)<1e-4&&Math.abs(e.y-t.y)<1e-4}static EqualsXY(e,t,r){return e.x===t&&e.y===r}static Clockwise(e,t,r){return(r.x-e.x)*(t.y-e.y)-(t.x-e.x)*(r.y-e.y)<0}static Rescale(e,t){const r=k.Len(e);return new k(t*e.x/r,t*e.y/r)}static ScaleWithOrigin(e,t,r){return k.Sub(e,r).mul(t).add(r)}static ToFixed(e){return new k(Ca(e.x),Ca(e.y))}static ToInt(e){return new k(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,t,r){return k.Add(e,k.Tan(t,e).mul(r))}static ToString(e){return`${e.x}, ${e.y}`}static ToAngle(e){let t=Math.atan2(e.y,e.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(e,t=1){return new k(Math.cos(e)*t,Math.sin(e)*t)}static ToArray(e){return[e.x,e.y,e.z]}static ToJson(e){const{x:t,y:r,z:s}=e;return{x:t,y:r,z:s}}static Average(e){const t=e.length,r=new k(0,0);if(t===0)return r;for(let s=0;s<t;s++)r.add(e[s]);return r.div(t)}static Clamp(e,t,r){return r===void 0?new k(Math.min(Math.max(e.x,t)),Math.min(Math.max(e.y,t))):new k(Math.min(Math.max(e.x,t),r),Math.min(Math.max(e.y,t),r))}static PointsBetween(e,t,r=6){const s=[];for(let i=0;i<r;i++){const o=Hn.easeInQuad(i/(r-1)),a=k.Lrp(e,t,o);a.z=Math.min(1,.5+Math.abs(.5-BG(o))*.65),s.push(a)}return s}static SnapToGrid(e,t=8){return new k(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}}const BG=n=>n<.5?2*n*n:-1+(4-2*n)*n;function aF(n,{initialBounds:e,scaleX:t,scaleY:r,newPoint:s,handle:i}){let o;switch(i){case"bottom_left":case"bottom_right":case"top_left":case"top_right":{o=Math.max(.01,Math.max(Math.abs(t),Math.abs(r)));break}case"left":case"right":{o=Math.max(.01,Math.abs(t));break}case"bottom":case"top":{o=Math.max(.01,Math.abs(r));break}default:throw An(i)}const a=new k(0,0);t<0&&(a.x=-(e.width*o)),r<0&&(a.y=-(e.height*o));const{x:l,y:c}=k.Add(s,a.rot(n.rotation));return{x:l,y:c,props:{scale:o*n.props.scale}}}function Qn(n){this.content=n}Qn.prototype={constructor:Qn,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Qn(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Qn(t)},addToStart:function(n,e){return new Qn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Qn(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Qn(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Qn.from(n),n.size?new Qn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Qn.from(n),n.size?new Qn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Qn.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Qn.from=function(n){if(n instanceof Qn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Qn(e)};function lF(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=lF(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function cF(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;c<u&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||a.content.size){let c=cF(o.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class ge{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,a=0;a<t;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),r,s+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ge(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),s+=a.nodeSize),o=l}return new ge(r,s)}cutByIndex(e,t){return e==t?ge.empty:e==0&&t==this.content.length?this:new ge(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new ge(s,i)}addToStart(e){return new ge([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ge(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return lF(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return cF(this,e,t,r)}findIndex(e,t=-1){if(e==0)return bm(0,e);if(e==this.size)return bm(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?bm(r+1,o):bm(r,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ge.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new ge(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ge.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new ge(t||e,r)}static from(e){if(!e)return ge.empty;if(e instanceof ge)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ge([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ge.empty=new ge([],0);const N1={index:0,offset:0};function bm(n,e){return N1.index=n,N1.offset=e,N1}function Jy(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Jy(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Jy(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ft=class NP{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Jy(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return NP.none;if(e instanceof NP)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Ft.none=[];class Qy extends Error{}class Te{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=dF(this.content,e+this.openStart,t);return r&&new Te(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Te(uF(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Te.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Te(ge.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new Te(e,r,s)}}Te.empty=new Te(ge.empty,0,0);function uF(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(s==e||i.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(uF(i.content,e-s-1,t-s-1)))}function dF(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let a=dF(o.content,e-i-1,t);return a&&n.replaceChild(s,o.copy(a))}function UG(n,e,t){if(t.openStart>n.depth)throw new Qy("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Qy("Inconsistent open depths");return hF(n,e,t,0)}function hF(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=hF(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,a=o.content;return Wc(o,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=HG(t,n);return Wc(i,pF(n,o,a,e,r))}else return Wc(i,eS(n,e,r))}function fF(n,e){if(!e.type.compatibleContent(n.type))throw new Qy("Cannot join "+e.type.name+" onto "+n.type.name)}function FP(n,e,t){let r=n.node(t);return fF(r,e.node(t)),r}function Kc(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ff(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Kc(n.nodeAfter,r),i++));for(let a=i;a<o;a++)Kc(s.child(a),r);e&&e.depth==t&&e.textOffset&&Kc(e.nodeBefore,r)}function Wc(n,e){return n.type.checkContent(e),n.copy(e)}function pF(n,e,t,r,s){let i=n.depth>s&&FP(n,e,s+1),o=r.depth>s&&FP(t,r,s+1),a=[];return Ff(null,n,s,a),i&&o&&e.index(s)==t.index(s)?(fF(i,o),Kc(Wc(i,pF(n,e,t,r,s+1)),a)):(i&&Kc(Wc(i,eS(n,e,s+1)),a),Ff(e,t,s,a),o&&Kc(Wc(o,eS(t,r,s+1)),a)),Ff(r,null,s,a),new ge(a)}function eS(n,e,t){let r=[];if(Ff(null,n,t,r),n.depth>t){let s=FP(n,e,t+1);Kc(Wc(s,eS(n,e,t+1)),r)}return Ff(e,null,t,r),new ge(r)}function HG(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(ge.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class op{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ft.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let a=r;r=s,s=a}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new tS(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(i),c=i-l;if(r.push(o,a,s+l),!c||(o=o.child(a),o.isText))break;i=c-1,s+=l+1}return new op(t,r,i)}static resolveCached(e,t){let r=FR.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else FR.set(e,r=new KG);let s=r.elts[r.i]=op.resolve(e,t);return r.i=(r.i+1)%WG,s}}class KG{constructor(){this.elts=[],this.i=0}}const WG=12,FR=new WeakMap;class tS{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const VG=Object.create(null);let Ji=class zP{constructor(e,t,r,s=Ft.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||ge.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Jy(this.attrs,t||e.defaultAttrs||VG)&&Ft.sameSet(this.marks,r||Ft.none)}copy(e=null){return e==this.content?this:new zP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new zP(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Te.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),a=s.start(o),c=s.node(o).content.cut(s.pos-a,i.pos-a);return new Te(c,s.depth-o,i.depth-o)}replace(e,t,r){return UG(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return op.resolveCached(this,e)}resolveNoCache(e){return op.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),gF(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=ge.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=s;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ft.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ft.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=ge.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Ji.prototype.text=void 0;class nS extends Ji{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gF(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new nS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nS(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gF(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Zc{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new qG(e,t);if(r.next==null)return Zc.empty;let s=mF(r);r.next&&r.err("Unexpected trailing text");let i=eY(QG(s));return tY(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!t||l.validEnd))return ge.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:h}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(h)==-1){s.push(h);let p=i(h,a.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let a=s;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:a,next:l}=i.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
87
|
-
`)}}Zc.empty=new Zc(!0);class qG{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function mF(n){let e=[];do e.push(GG(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function GG(n){let e=[];do e.push(YG(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function YG(n){let e=JG(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=XG(n,e);else break;return e}function zR(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function XG(n,e){let t=zR(n),r=t;return n.eat(",")&&(n.next!="}"?r=zR(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function ZG(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function JG(n){if(n.eat("(")){let e=mF(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=ZG(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function QG(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function s(o,a){o.forEach(l=>l.to=a)}function i(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=i(o.exprs[l],a);if(l==o.exprs.length-1)return c;s(c,a=t())}else if(o.type=="star"){let l=t();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=t();return s(i(o.expr,a),l),s(i(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(i(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let u=t();s(i(o.expr,l),u),l=u}if(o.max==-1)s(i(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let u=t();r(l,u),s(i(o.expr,l),u),l=u}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function yF(n,e){return e-n}function $R(n,e){let t=[];return r(e),t.sort(yF);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&t.indexOf(l)==-1&&r(l)}}}function eY(n){let e=Object.create(null);return t($R(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<s.length;u++)s[u][0]==a&&(c=s[u][1]);$R(n,l).forEach(u=>{c||s.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Zc(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(yF);i.next.push({type:s[o][0],next:e[a.join(",")]||t(a)})}return i}}function tY(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];o.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function SF(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function vF(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function xF(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function wF(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new rY(n,r,e[r]);return t}let BR=class bF{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wF(e,r.attrs),this.defaultAttrs=SF(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Zc.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:vF(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ji(this,this.computeAttrs(e),ge.from(t),Ft.setFrom(r))}createChecked(e=null,t,r){return t=ge.from(t),this.checkContent(t),new Ji(this,this.computeAttrs(e),t,Ft.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=ge.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(ge.empty,!0);return i?new Ji(this,e,t.append(i),Ft.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){xF(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ft.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new bF(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function nY(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class rY{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?nY(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class E0{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=wF(e,s.attrs),this.excluded=null;let i=SF(this.attrs);this.instance=i?new Ft(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ft(this,vF(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new E0(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){xF(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class CF{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Qn.from(e.nodes),t.marks=Qn.from(e.marks||{}),this.nodes=BR.compile(this.spec.nodes,this),this.marks=E0.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Zc.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?UR(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:UR(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof BR){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new nS(r,r.defaultAttrs,e,Ft.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ji.fromJSON(this,e)}markFromJSON(e){return Ft.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function UR(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let a in n.marks){let l=n.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function sY(n){return n.tag!=null}function iY(n){return n.style!=null}let _d=class $P{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(sY(s))this.tags.push(s);else if(iY(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new KR(this,t,!1);return r.addAll(e,Ft.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new KR(this,t,!0);return r.addAll(e,Ft.none,t.from,t.to),Te.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(lY(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let a=t[o];if((a.priority==null?50:a.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=WR(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=WR(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $P(e,$P.schemaRules(e)))}};const PF={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},oY={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},kF={ol:!0,ul:!0},ap=1,BP=2,cy=4;function HR(n,e,t){return e!=null?(e?ap:0)|(e==="full"?BP:0):n&&n.whitespace=="pre"?ap|BP:t&-5}class Cm{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ft.none,this.match=i||(o&cy?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(ge.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ap)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=ge.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(ge.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!PF.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class KR{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=HR(null,t.preserveWhitespace,0)|(r?cy:0);s?i=new Cm(s.type,s.attrs,Ft.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new Cm(null,null,Ft.none,!0,null,o):i=new Cm(e.schema.topNodeType,null,Ft.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&BP?"full":this.localPreserveWS||(s.options&ap)>0;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
88
|
-
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],a=e.previousSibling;(!o||a&&a.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;kF.hasOwnProperty(o)&&this.parser.normalizeLists&&aY(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:oY.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(PF.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=l&&l.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
89
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,t.attrs||null,r,t.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!s||s.length>c.length+a)&&(s=c,i=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ft.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):VR(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=HR(e,i,o.options);o.options&cy&&o.content.length==0&&(a|=cy);let l=Ft.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):VR(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Cm(e,t,l,s,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ap)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function aY(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&kF.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function lY(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function WR(n){let e={};for(let t in n)e[t]=n[t];return e}function VR(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class yu{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=F1(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(i[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=uy(F1(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&uy(F1(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return uy(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yu(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=qR(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return qR(e.marks)}}function qR(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function F1(n){return n.document||window.document}const GR=new WeakMap;function cY(n){let e=GR.get(n);return e===void 0&&GR.set(n,e=uY(n)),e}function uY(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function uy(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=cY(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let a,l=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let h in c)if(c[h]!=null){let p=h.indexOf(" ");p>0?l.setAttributeNS(h.slice(0,p),h.slice(p+1),c[h]):l.setAttribute(h,c[h])}}for(let h=u;h<e.length;h++){let p=e[h];if(p===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:S}=uy(n,p,t,r);if(l.appendChild(m),S){if(a)throw new RangeError("Multiple content holes");a=S}}}return{dom:l,contentDOM:a}}const IF=65535,EF=Math.pow(2,16);function dY(n,e){return n+e*EF}function YR(n){return n&IF}function hY(n){return(n-(n&IF))/EF}const _F=1,TF=2,dy=4,MF=8;class UP{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&MF)>0}get deletedBefore(){return(this.delInfo&(_F|dy))>0}get deletedAfter(){return(this.delInfo&(TF|dy))>0}get deletedAcross(){return(this.delInfo&dy)>0}}class Us{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Us.empty)return Us.empty}recover(e){let t=0,r=YR(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+hY(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let c=this.ranges[a+i],u=this.ranges[a+o],h=l+c;if(e<=h){let p=c?e==l?-1:e==h?1:t:t,m=l+s+(p<0?0:u);if(r)return m;let S=e==(t<0?l:h)?null:dY(a/3,e-l),x=e==l?TF:e==h?_F:dy;return(t<0?e!=l:e!=h)&&(x|=MF),new UP(m,x,S)}s+=u-c}return r?e+s:new UP(e+s,0,null)}touches(e,t){let r=0,s=YR(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+i],u=l+c;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(a,a+c,l,l+u),i+=u-c}}invert(){return new Us(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Us.empty:new Us(e<0?[0,-e,0]:[0,0,e])}}Us.empty=new Us([]);class lp{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new lp(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new lp;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new UP(e,s,null)}}const z1=Object.create(null);class Tr{getMap(){return Us.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=z1[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in z1)throw new RangeError("Duplicate use of step JSON ID "+e);return z1[e]=t,t.prototype.jsonID=e,t}}class On{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new On(e,null)}static fail(e){return new On(null,e)}static fromReplace(e,t,r,s){try{return On.ok(e.replace(t,r,s))}catch(i){if(i instanceof Qy)return On.fail(i.message);throw i}}}function WI(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(WI(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return ge.fromArray(r)}class Ll extends Tr{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Te(WI(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return On.fromReplace(e,this.from,this.to,i)}invert(){return new Do(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ll(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ll&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ll(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ll(t.from,t.to,e.markFromJSON(t.mark))}}Tr.jsonID("addMark",Ll);class Do extends Tr{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new Te(WI(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return On.fromReplace(e,this.from,this.to,r)}invert(){return new Ll(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Do(t.pos,r.pos,this.mark)}merge(e){return e instanceof Do&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Do(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Do(t.from,t.to,e.markFromJSON(t.mark))}}Tr.jsonID("removeMark",Do);class Nl extends Tr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return On.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return On.fromReplace(e,this.pos,this.pos+1,new Te(ge.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Nl(this.pos,t.marks[s]);return new Nl(this.pos,this.mark)}}return new Jc(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Nl(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Nl(t.pos,e.markFromJSON(t.mark))}}Tr.jsonID("addNodeMark",Nl);class Jc extends Tr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return On.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return On.fromReplace(e,this.pos,this.pos+1,new Te(ge.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Nl(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Jc(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Jc(t.pos,e.markFromJSON(t.mark))}}Tr.jsonID("removeNodeMark",Jc);class Bn extends Tr{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&HP(e,this.from,this.to)?On.fail("Structure replace would overwrite content"):On.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Us([this.from,this.to-this.from,this.slice.size])}invert(e){return new Bn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Bn(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Bn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?Te.empty:new Te(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Bn(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?Te.empty:new Te(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Bn(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Bn(t.from,t.to,Te.fromJSON(e,t.slice),!!t.structure)}}Tr.jsonID("replace",Bn);class Kn extends Tr{constructor(e,t,r,s,i,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(HP(e,this.from,this.gapFrom)||HP(e,this.gapTo,this.to)))return On.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return On.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?On.fromReplace(e,this.from,this.to,r):On.fail("Content does not fit in gap")}getMap(){return new Us([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Kn(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Kn(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Kn(t.from,t.to,t.gapFrom,t.gapTo,Te.fromJSON(e,t.slice),t.insert,!!t.structure)}}Tr.jsonID("replaceAround",Kn);function HP(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function fY(n,e,t,r){let s=[],i=[],o,a;n.doc.nodesBetween(e,t,(l,c,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let p=Math.max(c,e),m=Math.min(c+l.nodeSize,t),S=r.addToSet(h);for(let x=0;x<h.length;x++)h[x].isInSet(S)||(o&&o.to==p&&o.mark.eq(h[x])?o.to=m:s.push(o=new Do(p,m,h[x])));a&&a.to==p?a.to=m:i.push(a=new Ll(p,m,r))}}),s.forEach(l=>n.step(l)),i.forEach(l=>n.step(l))}function pY(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;i++;let l=null;if(r instanceof E0){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,t);for(let u=0;u<l.length;u++){let h=l[u],p;for(let m=0;m<s.length;m++){let S=s[m];S.step==i-1&&h.eq(s[m].style)&&(p=S)}p?(p.to=c,p.step=i):s.push({style:h,from:Math.max(a,e),to:c,step:i})}}}),s.forEach(o=>n.step(new Do(o.from,o.to,o.style)))}function VI(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),u=a+c.nodeSize,h=r.matchType(c.type);if(!h)o.push(new Bn(a,u,Te.empty));else{r=h;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Do(a,u,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,m=/\r?\n|\r/g,S;for(;p=m.exec(c.text);)S||(S=new Te(ge.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Bn(a+p.index,a+p.index+p[0].length,S))}}a=u}if(!r.validEnd){let l=r.fillBefore(ge.empty,!0);n.replace(a,a,new Te(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function gY(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function lh(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&s.canReplace(i,o,t))return r;if(r==0||s.type.spec.isolating||!gY(s,i,o))break}return null}function mY(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,c=a,u=ge.empty,h=0;for(let S=i,x=!1;S>t;S--)x||r.index(S)>0?(x=!0,u=ge.from(r.node(S).copy(u)),h++):l--;let p=ge.empty,m=0;for(let S=i,x=!1;S>t;S--)x||s.after(S+1)<s.end(S)?(x=!0,p=ge.from(s.node(S).copy(p)),m++):c++;n.step(new Kn(l,c,o,a,new Te(u.append(p),h,m),u.size-h,!0))}function qI(n,e,t=null,r=n){let s=yY(n,e),i=s&&SY(r,e);return i?s.map(XR).concat({type:e,attrs:t}).concat(i.map(XR)):null}function XR(n){return{type:n,attrs:null}}function yY(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function SY(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:o}function vY(n,e,t){let r=ge.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let a=t[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ge.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new Kn(s,i,s,i,new Te(r,0,0),t.length,!0))}function xY(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&wY(n.doc,n.mapping.slice(i).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",S=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!S?c=!1:!m&&S&&(c=!0)}c===!1&&OF(n,o,a,i),VI(n,n.mapping.slice(i).map(a,1),r,void 0,c===null);let u=n.mapping.slice(i),h=u.map(a,1),p=u.map(a+o.nodeSize,1);return n.step(new Kn(h,p,h+1,p-1,new Te(ge.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&AF(n,o,a,i),!1}})}function AF(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function OF(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
90
|
-
`))}})}function wY(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function bY(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Kn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Te(ge.from(o),0,0),1,!0))}function Ta(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>i;c--,u--){let h=s.node(c),p=s.index(c);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(p,h.childCount),S=r&&r[u+1];S&&(m=m.replaceChild(0,S.type.create(S.attrs)));let x=r&&r[u]||h;if(!h.canReplace(p+1,h.childCount)||!x.type.validContent(m))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function CY(n,e,t=1,r){let s=n.doc.resolve(e),i=ge.empty,o=ge.empty;for(let a=s.depth,l=s.depth-t,c=t-1;a>l;a--,c--){i=ge.from(s.node(a).copy(i));let u=r&&r[c];o=ge.from(u?u.type.create(u.attrs,o):s.node(a).copy(o))}n.step(new Bn(e,e,new Te(i.append(o),t,t),!0))}function tc(n,e){let t=n.resolve(e),r=t.index();return RF(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function PY(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function RF(n,e){return!!(n&&e&&!n.isLeaf&&PY(n,e))}function _0(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,a=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),a++,o=r.node(s).maybeChild(a)):(i=r.node(s).maybeChild(a-1),o=r.node(s+1)),i&&!i.isTextblock&&RF(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function kY(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",h=!!o.contentMatch.matchType(s);u&&!h?r=!1:!u&&h&&(r=!0)}let a=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);OF(n,u.node(),u.before(),a)}o.inlineContent&&VI(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new Bn(c,l.map(e+t,-1),Te.empty,!0)),r===!0){let u=n.doc.resolve(c);AF(n,u.node(),u.before(),n.steps.length)}return n}function IY(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function DF(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(l,l,s);else{let h=c.contentMatchAt(l).findWrapping(s.firstChild.type);u=h&&c.canReplaceWith(l,l,h[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function T0(n,e,t=e,r=Te.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return jF(s,i,r)?new Bn(e,t,r):new EY(s,i,r).fit()}function jF(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class EY{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=ge.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=ge.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,a=s.depth;for(;o&&a&&i.childCount==1;)i=i.firstChild.content,o--,a--;let l=new Te(i,o,a);return e>-1?new Kn(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new Bn(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=$1(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,h=null;if(t==1&&(o?c.matchType(o.type)||(h=c.fillBefore(ge.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:h};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=$1(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Te(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=$1(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new Te(wf(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new Te(wf(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let x=0;x<i.length;x++)this.openFrontierNode(i[x]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,u=[],{match:h,type:p}=this.frontier[t];if(s){for(let x=0;x<s.childCount;x++)u.push(s.child(x));h=h.matchFragment(s)}let m=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let x=a.child(c),v=h.matchType(x.type);if(!v)break;c++,(c>1||l==0||x.content.size)&&(h=v,u.push(LF(x.mark(p.allowedMarks(x.marks)),c==1?l:0,c==a.childCount?m:-1)))}let S=c==a.childCount;S||(m=-1),this.placed=bf(this.placed,t,ge.from(u)),this.frontier[t].match=h,S&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let x=0,v=a;x<m;x++){let w=v.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),v=w.content}this.unplaced=S?e==0?Te.empty:new Te(wf(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Te(wf(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!B1(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=B1(e,t,s,r,i);if(o){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=B1(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=bf(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=bf(this.placed,this.depth,ge.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(ge.empty,!0);t.childCount&&(this.placed=bf(this.placed,this.frontier.length,t))}}function wf(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(wf(n.firstChild.content,e-1,t)))}function bf(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(bf(n.lastChild.content,e-1,t)))}function $1(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function LF(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,LF(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(ge.empty,!0)))),n.copy(r)}function B1(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!_Y(t,i.content,o)?a:null}function _Y(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function TY(n){return n.spec.defining||n.spec.definingForContent}function MY(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(jF(s,i,r))return n.step(new Bn(e,t,r));let o=FF(s,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let p=s.depth,m=s.pos-1;p>0;p--,m--){let S=s.node(p).type.spec;if(S.defining||S.definingAsContext||S.isolating)break;o.indexOf(p)>-1?a=p:s.before(p)==m&&o.splice(1,0,-p)}let l=o.indexOf(a),c=[],u=r.openStart;for(let p=r.content,m=0;;m++){let S=p.firstChild;if(c.push(S),m==r.openStart)break;p=S.content}for(let p=u-1;p>=0;p--){let m=c[p],S=TY(m.type);if(S&&!m.sameMarkup(s.node(Math.abs(a)-1)))u=p;else if(S||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+u+1)%(r.openStart+1),S=c[m];if(S)for(let x=0;x<o.length;x++){let v=o[(x+l)%o.length],w=!0;v<0&&(w=!1,v=-v);let C=s.node(v-1),_=s.index(v-1);if(C.canReplaceWith(_,_,S.type,S.marks))return n.replace(s.before(v),w?i.after(v):t,new Te(NF(r.content,0,r.openStart,m),m,r.openEnd))}}let h=n.steps.length;for(let p=o.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>h));p--){let m=o[p];m<0||(e=s.before(m),t=i.after(m))}}function NF(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(NF(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(ge.empty,!0))}return n}function AY(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=IY(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new Te(ge.from(r),0,0))}function OY(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=FF(r,s);for(let o=0;o<i.length;o++){let a=i[o],l=o==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return n.delete(r.before(a),s.after(a))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function FF(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class Td extends Tr{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return On.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return On.fromReplace(e,this.pos,this.pos+1,new Te(ge.from(s),0,t.isLeaf?0:1))}getMap(){return Us.empty}invert(e){return new Td(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Td(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Td(t.pos,t.attr,t.value)}}Tr.jsonID("attr",Td);class cp extends Tr{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return On.ok(r)}getMap(){return Us.empty}invert(e){return new cp(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cp(t.attr,t.value)}}Tr.jsonID("docAttr",cp);let Bd=class extends Error{};Bd=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Bd.prototype=Object.create(Error.prototype);Bd.prototype.constructor=Bd;Bd.prototype.name="TransformError";class zF{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new lp}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bd(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=Te.empty){let s=T0(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new Te(ge.from(r),0,0))}delete(e,t){return this.replace(e,t,Te.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return MY(this,e,t,r),this}replaceRangeWith(e,t,r){return AY(this,e,t,r),this}deleteRange(e,t){return OY(this,e,t),this}lift(e,t){return mY(this,e,t),this}join(e,t=1){return kY(this,e,t),this}wrap(e,t){return vY(this,e,t),this}setBlockType(e,t=e,r,s=null){return xY(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return bY(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new Td(e,t,r)),this}setDocAttribute(e,t){return this.step(new cp(e,t)),this}addNodeMark(e,t){return this.step(new Nl(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Ft)t.isInSet(r.marks)&&this.step(new Jc(e,t));else{let s=r.marks,i,o=[];for(;i=t.isInSet(s);)o.push(new Jc(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,t=1,r){return CY(this,e,t,r),this}addMark(e,t,r){return fY(this,e,t,r),this}removeMark(e,t,r){return pY(this,e,t,r),this}clearIncompatible(e,t,r){return VI(this,e,t,r),this}}const U1=Object.create(null);class lt{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new RY(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Te.empty){let r=t.content.lastChild,s=null;for(let a=0;a<t.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(c.pos),a?Te.empty:t),a==0&&QR(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:a}=s[i],l=e.mapping.slice(r),c=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),QR(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new nt(e):md(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?md(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):md(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Gs(e.node(0))}static atStart(e){return md(e,e,0,0,1)||new Gs(e)}static atEnd(e){return md(e,e,e.content.size,e.childCount,-1)||new Gs(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=U1[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in U1)throw new RangeError("Duplicate use of selection JSON ID "+e);return U1[e]=t,t.prototype.jsonID=e,t}getBookmark(){return nt.between(this.$anchor,this.$head).getBookmark()}}lt.prototype.visible=!0;class RY{constructor(e,t){this.$from=e,this.$to=t}}let ZR=!1;function JR(n){!ZR&&!n.parent.inlineContent&&(ZR=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class nt extends lt{constructor(e,t=e){JR(e),JR(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return lt.near(r);let s=e.resolve(t.map(this.anchor));return new nt(s.parent.inlineContent?s:r,r)}replace(e,t=Te.empty){if(super.replace(e,t),t==Te.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof nt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new M0(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new nt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=lt.findFrom(t,r,!0)||lt.findFrom(t,-r,!0);if(i)t=i.$head;else return lt.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(lt.findFrom(e,-r,!0)||lt.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new nt(e,t)}}lt.jsonID("text",nt);class M0{constructor(e,t){this.anchor=e,this.head=t}map(e){return new M0(e.map(this.anchor),e.map(this.head))}resolve(e){return nt.between(e.resolve(this.anchor),e.resolve(this.head))}}class We extends lt{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?lt.near(i):new We(i)}content(){return new Te(ge.from(this.node),0,0)}eq(e){return e instanceof We&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new GI(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new We(e.resolve(t.anchor))}static create(e,t){return new We(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}We.prototype.visible=!1;lt.jsonID("node",We);class GI{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new M0(r,r):new GI(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&We.isSelectable(r)?new We(t):lt.near(t)}}class Gs extends lt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Te.empty){if(t==Te.empty){e.delete(0,e.doc.content.size);let r=lt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Gs(e)}map(e){return new Gs(e)}eq(e){return e instanceof Gs}getBookmark(){return DY}}lt.jsonID("all",Gs);const DY={map(){return this},resolve(n){return new Gs(n)}};function md(n,e,t,r,s,i=!1){if(e.inlineContent)return nt.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&We.isSelectable(a))return We.create(n,t-(s<0?a.nodeSize:0))}else{let l=md(n,a,t+s,s<0?a.childCount:0,s,i);if(l)return l}t+=a.nodeSize*s}return null}function QR(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof Bn||s instanceof Kn))return;let i=n.mapping.maps[r],o;i.forEach((a,l,c,u)=>{o==null&&(o=u)}),n.setSelection(lt.near(n.doc.resolve(o),t))}const eD=1,tD=2,nD=4;class jY extends zF{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|eD)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&eD)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=tD,this}ensureMarks(e){return Ft.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&tD)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ft.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(lt.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=nD,this}get scrolledIntoView(){return(this.updated&nD)>0}}function rD(n,e){return!e||!n?n:n.bind(e)}class Cf{constructor(e,t,r){this.name=e,this.init=rD(t.init,r),this.apply=rD(t.apply,r)}}const LY=[new Cf("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Cf("selection",{init(n,e){return n.selection||lt.atStart(e.doc)},apply(n){return n.selection}}),new Cf("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Cf("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class H1{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LY.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Cf(r.key,r.spec.state,r))})}}class Pd{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=s?s[o].n:0,c=s?s[o].state:this,u=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let h=0;h<this.config.plugins.length;h++)s.push(h<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Pd(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new jY(this)}static create(e){let t=new H1(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Pd(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new H1(this.schema,e.plugins),r=t.fields,s=new Pd(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new H1(e.schema,e.plugins),i=new Pd(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Ji.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=lt.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){i[o.name]=c.fromJSON.call(l,e,t[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function $F(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=$F(s,e,{})),t[r]=s}return t}class cr{constructor(e){this.spec=e,this.props={},e.props&&$F(e.props,this,this.props),this.key=e.key?e.key.key:BF("plugin")}getState(e){return e[this.key]}}const K1=Object.create(null);function BF(n){return n in K1?n+"$"+ ++K1[n]:(K1[n]=0,n+"$")}class Qs{constructor(e="key"){this.key=BF(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const rr=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ud=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let KP=null;const xa=function(n,e,t){let r=KP||(KP=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},NY=function(){KP=null},Qc=function(n,e,t,r){return t&&(sD(n,e,t,r,-1)||sD(n,e,t,r,1))},FY=/^(img|br|input|textarea|hr)$/i;function sD(n,e,t,r,s){for(;;){if(n==t&&e==r)return!0;if(e==(s<0?0:vi(n))){let i=n.parentNode;if(!i||i.nodeType!=1||zp(n)||FY.test(n.nodeName)||n.contentEditable=="false")return!1;e=rr(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?vi(n):0}else return!1}}function vi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function zY(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=vi(n)}else if(n.parentNode&&!zp(n))e=rr(n),n=n.parentNode;else return null}}function $Y(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!zp(n))e=rr(n)+1,n=n.parentNode;else return null}}function BY(n,e,t){for(let r=e==0,s=e==vi(n);r||s;){if(n==t)return!0;let i=rr(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==vi(n)}}function zp(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const A0=function(n){return n.focusNode&&Qc(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Dc(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function UY(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function HY(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(vi(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(vi(r.startContainer),r.startOffset)}}}const zo=typeof navigator<"u"?navigator:null,iD=typeof document<"u"?document:null,nc=zo&&zo.userAgent||"",WP=/Edge\/(\d+)/.exec(nc),UF=/MSIE \d/.exec(nc),VP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nc),Es=!!(UF||VP||WP),zl=UF?document.documentMode:VP?+VP[1]:WP?+WP[1]:0,no=!Es&&/gecko\/(\d+)/i.test(nc);no&&+(/Firefox\/(\d+)/.exec(nc)||[0,0])[1];const qP=!Es&&/Chrome\/(\d+)/.exec(nc),Ir=!!qP,HF=qP?+qP[1]:0,Vr=!Es&&!!zo&&/Apple Computer/.test(zo.vendor),Hd=Vr&&(/Mobile\/\w+/.test(nc)||!!zo&&zo.maxTouchPoints>2),mi=Hd||(zo?/Mac/.test(zo.platform):!1),KY=zo?/Win/.test(zo.platform):!1,ka=/Android \d/.test(nc),$p=!!iD&&"webkitFontSmoothing"in iD.documentElement.style,WY=$p?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function VY(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ha(n,e){return typeof n=="number"?n:n[e]}function qY(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function oD(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Ud(o);continue}let a=o,l=a==i.body,c=l?VY(i):qY(a),u=0,h=0;if(e.top<c.top+ha(r,"top")?h=-(c.top-e.top+ha(s,"top")):e.bottom>c.bottom-ha(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+ha(s,"top")-c.top:e.bottom-c.bottom+ha(s,"bottom")),e.left<c.left+ha(r,"left")?u=-(c.left-e.left+ha(s,"left")):e.right>c.right-ha(r,"right")&&(u=e.right-c.right+ha(s,"right")),u||h)if(l)i.defaultView.scrollBy(u,h);else{let m=a.scrollLeft,S=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let x=a.scrollLeft-m,v=a.scrollTop-S;e={left:e.left-x,top:e.top-v,right:e.right-x,bottom:e.bottom-v}}let p=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:Ud(o)}}function GY(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=n.root.elementFromPoint(i,o);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:KF(n.dom)}}function KF(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ud(r));return e}function YY({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;WF(t,r==0?0:r-e)}function WF(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let id=null;function XY(n){if(n.setActive)return n.setActive();if(id)return n.focus(id);let e=KF(n);n.focus(id==null?{get preventScroll(){return id={preventScroll:!0},!0}}:void 0),id||(id=!1,WF(e,0))}function VF(n,e){let t,r=2e8,s,i=0,o=e.top,a=e.top,l,c;for(let u=n.firstChild,h=0;u;u=u.nextSibling,h++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=xa(u).getClientRects();else continue;for(let m=0;m<p.length;m++){let S=p[m];if(S.top<=o&&S.bottom>=a){o=Math.max(S.bottom,o),a=Math.min(S.top,a);let x=S.left>e.left?S.left-e.left:S.right<e.left?e.left-S.right:0;if(x<r){t=u,r=x,s=x&&t.nodeType==3?{left:S.right<e.left?S.right:S.left,top:e.top}:e,u.nodeType==1&&x&&(i=h+(e.left>=(S.left+S.right)/2?1:0));continue}}else S.top>e.top&&!l&&S.left<=e.left&&S.right>=e.left&&(l=u,c={left:Math.max(S.left,Math.min(S.right,e.left)),top:S.top});!t&&(e.left>=S.right&&e.top>=S.top||e.left>=S.left&&e.top>=S.bottom)&&(i=h+1)}}return!t&&l&&(t=l,s=c,r=0),t&&t.nodeType==3?ZY(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:VF(t,s)}function ZY(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let i=Cl(r,1);if(i.top!=i.bottom&&YI(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function YI(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function JY(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function QY(n,e,t){let{node:r,offset:s}=VF(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function eX(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let a=n.docView.nearestDesc(i,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&(!o&&l.left>r.left||l.top>r.top?s=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(s=a.posAfter),o=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;i=a.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function qF(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(YI(e,c))return qF(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function tX(n,e){let t=n.dom.ownerDocument,r,s=0,i=HY(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!YI(e,c)||(o=qF(n.dom,e,c),!o))return null}if(Vr)for(let c=o;r&&c;c=Ud(c))c.draggable&&(r=void 0);if(o=JY(o,e),r){if(no&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&s++}let c;$p&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=eX(n,r,s,e))}a==null&&(a=QY(n,o,e));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function aD(n){return n.top<n.bottom||n.left<n.right}function Cl(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(aD(r))return r}return Array.prototype.find.call(t,aD)||n.getBoundingClientRect()}const nX=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function GF(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=$p||no;if(r.nodeType==3)if(o&&(nX.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let l=Cl(xa(r,s,s),t);if(no&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Cl(xa(r,s-1,s-1),-1);if(c.top==l.top){let u=Cl(xa(r,s,s+1),-1);if(u.top!=l.top)return rf(u,u.left<c.left)}}return l}else{let l=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==r.nodeValue.length?(l--,u=1):t<0?l--:c++,rf(Cl(xa(r,l,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==vi(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return W1(l.getBoundingClientRect(),!1)}if(i==null&&s<vi(r)){let l=r.childNodes[s];if(l.nodeType==1)return W1(l.getBoundingClientRect(),!0)}return W1(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==vi(r))){let l=r.childNodes[s-1],c=l.nodeType==3?xa(l,vi(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return rf(Cl(c,1),!1)}if(i==null&&s<vi(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?xa(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return rf(Cl(c,-1),!0)}return rf(Cl(r.nodeType==3?xa(r):r,-t),t>=0)}function rf(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function W1(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function YF(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function rX(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return YF(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=GF(n,s.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=xa(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const sX=/[\u0590-\u08ac]/;function iX(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=n.domSelection();return a?!sX.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?i:o:YF(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:h}=n.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",t,"character");let m=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:S,focusOffset:x}=n.domSelectionRange(),v=S&&!m.contains(S.nodeType==1?S:S.parentNode)||l==S&&c==x;try{a.collapse(u,h),l&&(l!=u||c!=h)&&a.extend&&a.extend(l,c)}catch{}return p!=null&&(a.caretBidiLevel=p),v}):r.pos==r.start()||r.pos==r.end()}let lD=null,cD=null,uD=!1;function oX(n,e,t){return lD==e&&cD==t?uD:(lD=e,cD=t,uD=t=="up"||t=="down"?rX(n,e,t):iX(n,e,t))}const ki=0,dD=1,Lc=2,$o=3;class Bp{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=ki,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>rr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let a=s.children[o];if(a.size){s=a;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],a=i+o.size;if(a>e||o instanceof ZF){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof XF&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?rr(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?rr(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(s==-1&&e<=c){let u=o+l.border;if(e>=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=o;for(let h=a;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=rr(p.dom)+1;break}e-=p.size}s==-1&&(s=0)}if(s>-1&&(c>t||a==this.children.length-1)){t=c;for(let u=a+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=rr(h.dom);break}t+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let m=0,S=0;m<this.children.length;m++){let x=this.children[m],v=S+x.size;if(i>S&&o<v)return x.setSelection(e-S-x.border,t-S-x.border,r,s);S=v}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((no||Vr)&&e==t){let{node:m,offset:S}=a;if(m.nodeType==3){if(h=!!(S&&m.nodeValue[S-1]==`
|
|
91
|
-
`),h&&S==m.nodeValue.length)for(let x=m,v;x;x=x.parentNode){if(v=x.nextSibling){v.nodeName=="BR"&&(a=l={node:v.parentNode,offset:rr(v)+1});break}let w=x.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let x=m.childNodes[S-1];h=x&&(x.nodeName=="BR"||x.contentEditable=="false")}}if(no&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(s=!0)}if(!(s||h&&Vr)&&Qc(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Qc(l.node,l.offset,u.focusNode,u.focusOffset))return;let p=!1;if((c.extend||e==t)&&!h){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>t){let S=a;a=l,l=S}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let a=r+i.border,l=o-i.border;if(e>=a&&t<=l){this.dirty=e==r||t==o?Lc:dD,e==a&&t==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=$o:i.markDirty(e-a,t-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Lc:$o}r=o}this.dirty=Lc}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Lc:dD;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class XF extends Bp{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==ki&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class aX extends Bp{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class eu extends Bp{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=yu.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new eu(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$o||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$o&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ki){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ki}}slice(e,t,r){let s=eu.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=YP(i,t,o,r)),e>0&&(i=YP(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class $l extends Bp{constructor(e,t,r,s,i,o,a,l,c){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(e,t,r,s,i,o){let a=i.nodeViews[t.type.name],l,c=a&&a(t,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),u=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=yu.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=e5(u,r,t),c?l=new lX(e,t,r,s,u,h||null,p,c,i,o+1):t.isText?new O0(e,t,r,s,u,p,i):new $l(e,t,r,s,u,h||null,p,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ge.empty)}return e}matchesNode(e,t,r){return this.dirty==ki&&e.eq(this.node)&&rS(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new uX(this,o&&o.node,e);fX(this.node,this.innerDeco,(c,u,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?Ft.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,s)},(c,u,h,p)=>{l.syncToMarks(c.marks,r,e);let m;l.findNodeMatch(c,u,h,p)||a&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(m=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(c,u,h,m,e)||l.updateNextNode(c,u,h,e,p,s)||l.addNode(c,u,h,e,s),s+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Lc)&&(o&&this.protectLocalComposition(e,o),JF(this.contentDOM,this.children,e),Hd&&pX(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof nt)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,a=gX(this.node.content,o,r-t,s-t);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new aX(this,i,t,s);e.input.compositionNodes.push(o),this.children=YP(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==$o||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=ki}updateOuterDeco(e){if(rS(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=QF(this.dom,this.nodeDOM,GP(this.outerDeco,this.node,t),GP(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function hD(n,e,t,r,s){e5(r,e,n);let i=new $l(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class O0 extends $l{constructor(e,t,r,s,i,o,a){super(e,t,r,s,i,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==$o||this.dirty!=ki&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ki||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=ki,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new O0(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=$o)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ZF extends Bp{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ki&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class lX extends $l{constructor(e,t,r,s,i,o,a,l,c,u){super(e,t,r,s,i,o,a,c,u),this.spec=l}update(e,t,r,s){if(this.dirty==$o)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function JF(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==n){for(;a!=r;)r=fD(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(a,r);if(o instanceof eu){let l=r?r.previousSibling:n.lastChild;JF(o.contentDOM,o.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=fD(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const zf=function(n){n&&(this.nodeName=n)};zf.prototype=Object.create(null);const Nc=[new zf];function GP(n,e,t){if(n.length==0)return Nc;let r=t?Nc[0]:new zf,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new zf(o.nodeName));for(let a in o){let l=o[a];l!=null&&(t&&s.length==1&&s.push(r=new zf(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function QF(n,e,t,r){if(t==Nc&&r==Nc)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=t[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=n&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=Nc[0]),s=l}cX(s,a||Nc[0],o)}return s}function cX(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function e5(n,e,t){return QF(n,n,Nc,GP(e,t,n.nodeType!=1))}function rS(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function fD(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class uX{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dX(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=ki,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=eu.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==$o&&o.dom==o.contentDOM&&(o.dirty=Lc),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof $l){let c=this.preMatch.matched.get(l);if(c!=null&&c!=i)return!1;let u=l.dom,h,p=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=$o&&rS(t,l.outerDeco));if(!p&&l.update(e,t,r,s))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(h=this.recreateWrapper(l,e,t,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Lc,h.updateChildren(s,o+1),h.dirty=ki),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!rS(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=$l.create(this.top,t,r,s,i,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,s,i){let o=$l.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new XF(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof eu;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof O0)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Vr||Ir)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new ZF(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function dX(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof eu)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}function hX(n,e){return n.type.side-e.type.side}function fX(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let u,h;for(;o<s.length&&s[o].to==i;){let v=s[o++];v.widget&&(u?(h||(h=[u])).push(v):u=v)}if(u)if(h){h.sort(hX);for(let v=0;v<h.length;v++)t(h[v],c,!!l)}else t(u,c,!!l);let p,m;if(l)m=-1,p=l,l=null;else if(c<n.childCount)m=c,p=n.child(c++);else break;for(let v=0;v<a.length;v++)a[v].to<=i&&a.splice(v--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let S=i+p.nodeSize;if(p.isText){let v=S;o<s.length&&s[o].from<v&&(v=s[o].from);for(let w=0;w<a.length;w++)a[w].to<v&&(v=a[w].to);v<S&&(l=p.cut(v-i),p=p.cut(0,v-i),S=v,m=-1)}else for(;o<s.length&&s[o].to<S;)o++;let x=p.isInline&&!p.isLeaf?a.filter(v=>!v.inline):a.slice();r(p,x,e.forChild(i,p),m),i=S}}function pX(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function gX(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=t){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function YP(n,e,t,r,s){let i=[];for(let o=0,a=0;o<n.length;o++){let l=n[o],c=a,u=a+=l.size;c>=t||u<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>t&&i.push(l.slice(t-c,l.size,r)))}return i}function XI(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(A0(t)){for(l=o;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&We.isSelectable(h)&&s.parent&&!(h.isInline&&BY(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new We(o==p?a:r.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,p=o;for(let m=0;m<t.rangeCount;m++){let S=t.getRangeAt(m);h=Math.min(h,n.docView.posFromDOM(S.startContainer,S.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(S.endContainer,S.endOffset,-1))}if(h<0)return null;[l,o]=p==n.state.selection.anchor?[p,h]:[h,p],a=r.resolve(o)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let h=e=="pointer"||n.state.selection.head<a.pos&&!i?1:-1;c=ZI(n,u,a,h)}return c}function t5(n){return n.editable?n.hasFocus():r5(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ma(n,e=!1){let t=n.state.selection;if(n5(n,t),!!t5(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ir){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Qc(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)yX(n);else{let{anchor:r,head:s}=t,i,o;pD&&!(t instanceof nt)&&(t.$from.parent.inlineContent||(i=gD(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=gD(n,t.to))),n.docView.setSelection(r,s,n,e),pD&&(i&&mD(i),o&&mD(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&mX(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const pD=Vr||Ir&&HF<63;function gD(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Vr&&s&&s.contentEditable=="false")return V1(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return V1(s);if(i)return V1(i)}}function V1(n){return n.contentEditable="true",Vr&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function mD(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function mX(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!t5(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function yX(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setStart(r.parentNode,rr(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&Es&&zl<=11&&(r.disabled=!0,r.disabled=!1)}function n5(n,e){if(e instanceof We){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(yD(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else yD(n)}function yD(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ZI(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||nt.between(e,t,r)}function SD(n){return n.editable&&!n.hasFocus()?!1:r5(n)}function r5(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function SX(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qc(e.node,e.offset,t.anchorNode,t.anchorOffset)}function XP(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&<.findFrom(i,e)}function El(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function vD(n,e,t){let r=n.state.selection;if(r instanceof nt)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return El(n,new nt(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=XP(n.state,e);return s&&s instanceof We?El(n,s):!1}else if(!(mi&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?We.isSelectable(i)?El(n,new We(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):$p?El(n,new nt(n.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof We&&r.node.isInline)return El(n,new nt(e>0?r.$to:r.$from));{let s=XP(n.state,e);return s?El(n,s):!1}}}function sS(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $f(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function od(n,e){return e<0?vX(n):xX(n)}function vX(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(no&&t.nodeType==1&&r<sS(t)&&$f(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if($f(a,-1))s=t,i=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(s5(t))break;{let a=t.previousSibling;for(;a&&$f(a,-1);)s=t.parentNode,i=rr(a),a=a.previousSibling;if(a)t=a,r=sS(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?ZP(n,t,r):s&&ZP(n,s,i)}function xX(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=sS(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let a=t.childNodes[r];if($f(a,1))i=t,o=++r;else break}else{if(s5(t))break;{let a=t.nextSibling;for(;a&&$f(a,1);)i=a.parentNode,o=rr(a)+1,a=a.nextSibling;if(a)t=a,r=0,s=sS(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&ZP(n,i,o)}function s5(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function wX(n,e){for(;n&&e==n.childNodes.length&&!zp(n);)e=rr(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function bX(n,e){for(;n&&!e&&!zp(n);)e=rr(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function ZP(n,e,t){if(e.nodeType!=3){let i,o;(o=wX(e,t))?(e=o,t=0):(i=bX(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(A0(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Ma(n)},50)}function xD(n,e){let t=n.state.doc.resolve(e);if(!(Ir||KY)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function wD(n,e,t){let r=n.state.selection;if(r instanceof nt&&!r.empty||t.indexOf("s")>-1||mi&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=XP(n.state,e);if(o&&o instanceof We)return El(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof Gs?lt.near(o,e):lt.findFrom(o,e);return a?El(n,a):!1}return!1}function bD(n,e){if(!(n.state.selection instanceof nt))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function CD(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function CX(n){if(!Vr||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;CD(n,r,"true"),setTimeout(()=>CD(n,r,"false"),20)}return!1}function PX(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function kX(n,e){let t=e.keyCode,r=PX(e);if(t==8||mi&&t==72&&r=="c")return bD(n,-1)||od(n,-1);if(t==46&&!e.shiftKey||mi&&t==68&&r=="c")return bD(n,1)||od(n,1);if(t==13||t==27)return!0;if(t==37||mi&&t==66&&r=="c"){let s=t==37?xD(n,n.state.selection.from)=="ltr"?-1:1:-1;return vD(n,s,r)||od(n,s)}else if(t==39||mi&&t==70&&r=="c"){let s=t==39?xD(n,n.state.selection.from)=="ltr"?1:-1:1;return vD(n,s,r)||od(n,s)}else{if(t==38||mi&&t==80&&r=="c")return wD(n,-1,r)||od(n,-1);if(t==40||mi&&t==78&&r=="c")return CX(n)||wD(n,1,r)||od(n,1);if(r==(mi?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function JI(n,e){n.someProp("transformCopied",m=>{e=m(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;t.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=n.someProp("clipboardSerializer")||yu.fromSchema(n.state.schema),a=u5(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,u,h=0;for(;c&&c.nodeType==1&&(u=c5[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let S=a.createElement(u[m]);for(;l.firstChild;)S.appendChild(l.firstChild);l.appendChild(S),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",m=>m(e,n))||e.content.textBetween(0,e.content.size,`
|
|
92
|
-
|
|
93
|
-
`);return{dom:l,text:p,slice:e}}function i5(n,e,t,r,s){let i=s.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=e&&(r||i||!t);if(l){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return e?new Te(ge.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
94
|
-
`))),0,0):Te.empty;let h=n.someProp("clipboardTextParser",p=>p(e,s,r,n));if(h)a=h;else{let p=s.marks(),{schema:m}=n.state,S=yu.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(x=>{let v=o.appendChild(document.createElement("p"));x&&v.appendChild(S.serializeNode(m.text(x,p)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=TX(t),$p&&MX(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||_d.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!IX.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=AX(PD(a,+u[1],+u[2]),u[4]);else if(a=Te.maxOpen(EX(a.content,s),!0),a.openStart||a.openEnd){let h=0,p=0;for(let m=a.content.firstChild;h<a.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=a.content.lastChild;p<a.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);a=PD(a,h,p)}return n.someProp("transformPasted",h=>{a=h(a,n)}),a}const IX=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function EX(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&i.length&&a5(l,i,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=l5(o[o.length-1],i.length));let u=o5(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return ge.from(o)}return n}function o5(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,ge.from(n));return n}function a5(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=a5(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(ge.from(o5(t,n,s+1))))}}function l5(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,l5(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(ge.empty,!0);return n.copy(t.append(r))}function JP(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,a=o.content;return n.childCount>1&&(i=0),s<r-1&&(a=JP(a,e,t,r,s+1,i)),s>=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(ge.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(a))}function PD(n,e,t){return e<n.openStart&&(n=new Te(JP(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new Te(JP(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const c5={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let kD=null;function u5(){return kD||(kD=document.implementation.createHTMLDocument("title"))}let q1=null;function _X(n){let e=window.trustedTypes;return e?(q1||(q1=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),q1.createHTML(n)):n}function TX(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=u5().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&c5[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=_X(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function MX(n){let e=n.querySelectorAll(Ir?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function AX(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=ge.from(l.create(r[a+1],s)),i++,o++}return new Te(s,i,o)}const qr={},Gr={},OX={touchstart:!0,touchmove:!0};class RX{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function DX(n){for(let e in qr){let t=qr[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{LX(n,r)&&!QI(n,r)&&(n.editable||!(r.type in Gr))&&t(n,r)},OX[e]?{passive:!0}:void 0)}Vr&&n.dom.addEventListener("input",()=>null),QP(n)}function Fl(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function jX(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function QP(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>QI(n,r))})}function QI(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function LX(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function NX(n,e){!QI(n,e)&&qr[e.type]&&(n.editable||!(e.type in Gr))&&qr[e.type](n,e)}Gr.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!h5(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ka&&Ir&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Hd&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,Dc(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||kX(n,t)?t.preventDefault():Fl(n,"key")};Gr.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Gr.keypress=(n,e)=>{let t=e;if(h5(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||mi&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof nt)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function R0(n){return{left:n.clientX,top:n.clientY}}function FX(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function eE(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,a=>o>i.depth?a(n,t,i.nodeAfter,i.before(o),s,!0):a(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function Md(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function zX(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&We.isSelectable(r)?(Md(n,new We(t)),!0):!1}function $X(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof We&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(We.isSelectable(a)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(Md(n,We.create(n.state.doc,s)),!0):!1}function BX(n,e,t,r,s){return eE(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?$X(n,t):zX(n,t))}function UX(n,e,t,r){return eE(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function HX(n,e,t,r){return eE(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||KX(n,t,r)}function KX(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Md(n,nt.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),a=s.before(i);if(o.inlineContent)Md(n,nt.create(r,a+1,a+1+o.content.size));else if(We.isSelectable(o))Md(n,We.create(r,a));else continue;return!0}}function tE(n){return iS(n)}const d5=mi?"metaKey":"ctrlKey";qr.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=tE(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&FX(t,n.input.lastClick)&&!t[d5]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let o=n.posAtCoords(R0(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new WX(n,o,t,!!r)):(i=="doubleClick"?UX:HX)(n,o.pos,o.inside,t)?t.preventDefault():Fl(n,"pointer"))};class WX{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[d5],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.dom.nodeType==1?l.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof We&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&no&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Fl(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ma(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(R0(e))),this.updateAllowDefault(e),this.allowDefault||!t?Fl(this.view,"pointer"):BX(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Vr&&this.mightDrag&&!this.mightDrag.node.isAtom||Ir&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Md(this.view,lt.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Fl(this.view,"pointer")}move(e){this.updateAllowDefault(e),Fl(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}qr.touchstart=n=>{n.input.lastTouch=Date.now(),tE(n),Fl(n,"pointer")};qr.touchmove=n=>{n.input.lastTouch=Date.now(),Fl(n,"pointer")};qr.contextmenu=n=>tE(n);function h5(n,e){return n.composing?!0:Vr&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const VX=ka?5e3:-1;Gr.compositionstart=Gr.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof nt&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),iS(n,!0),n.markCursor=null;else if(iS(n,!e.selection.empty),no&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let a=n.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}f5(n,VX)};Gr.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,f5(n,20))};function f5(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>iS(n),e))}function p5(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=GX());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function qX(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=zY(e.focusNode,e.focusOffset),r=$Y(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function GX(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function iS(n,e=!1){if(!(ka&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),p5(n),e||n.docView&&n.docView.dirty){let t=XI(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function YX(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const up=Es&&zl<15||Hd&&WY<604;qr.copy=Gr.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=up?null:t.clipboardData,o=r.content(),{dom:a,text:l}=JI(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):YX(n,a),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function XX(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ZX(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?dp(n,r.value,null,s,e):dp(n,r.textContent,r.innerHTML,s,e)},50)}function dp(n,e,t,r,s){let i=i5(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,s,i||Te.empty)))return!0;if(!i)return!1;let o=XX(i),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function g5(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Gr.paste=(n,e)=>{let t=e;if(n.composing&&!ka)return;let r=up?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&dp(n,g5(r),r.getData("text/html"),s,t)?t.preventDefault():ZX(n,t)};let m5=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const JX=mi?"altKey":"ctrlKey";function y5(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[JX]}qr.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(R0(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof We?s.to-1:s.to))){if(r&&r.mightDrag)o=We.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=We.create(n.state.doc,h.posBefore))}}let a=(o||n.state.selection).content(),{dom:l,text:c,slice:u}=JI(n,a);(!t.dataTransfer.files.length||!Ir||HF>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(up?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",up||t.dataTransfer.setData("text/plain",c),n.dragging=new m5(u,y5(n,t),o)};qr.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Gr.dragover=Gr.dragenter=(n,e)=>e.preventDefault();Gr.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(R0(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",S=>{o=S(o,n)}):o=i5(n,g5(t.dataTransfer),up?null:t.dataTransfer.getData("text/html"),!1,i);let a=!!(r&&y5(n,t));if(n.someProp("handleDrop",S=>S(n,t,o||Te.empty,a))){t.preventDefault();return}if(!o)return;t.preventDefault();let l=o?DF(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(a){let{node:S}=r;S?S.replace(c):c.deleteSelection()}let u=c.mapping.map(l),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=c.doc;if(h?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(p))return;let m=c.doc.resolve(u);if(h&&We.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new We(m));else{let S=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((x,v,w,C)=>S=C),c.setSelection(ZI(n,m,c.doc.resolve(S)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};qr.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ma(n)},20))};qr.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};qr.beforeinput=(n,e)=>{if(Ir&&ka&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Dc(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Gr)qr[n]=Gr[n];function hp(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class oS{constructor(e,t){this.toDOM=e,this.spec=t||Vc,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new xi(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof oS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hp(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Bl{constructor(e,t){this.attrs=e,this.spec=t||Vc}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new xi(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Bl&&hp(this.attrs,e.attrs)&&hp(this.spec,e.spec)}static is(e){return e.type instanceof Bl}destroy(){}}class nE{constructor(e,t){this.attrs=e,this.spec=t||Vc}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new xi(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof nE&&hp(this.attrs,e.attrs)&&hp(this.spec,e.spec)}destroy(){}}class xi{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new xi(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new xi(e,e,new oS(t,r))}static inline(e,t,r,s){return new xi(e,t,new Bl(r,s))}static node(e,t,r,s){return new xi(e,t,new nE(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Bl}get widget(){return this.type instanceof oS}}const yd=[],Vc={};class jn{constructor(e,t){this.local=e.length?e:yd,this.children=t.length?t:yd}static create(e,t){return t.length?aS(t,e,0,Vc):wr}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,r,s+a,i)}}map(e,t,r){return this==wr||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Vc)}mapInner(e,t,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(t,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?QX(this.children,o||[],e,t,r,s,i):o?new jn(o.sort(qc),yd):wr}add(e,t){return t.length?this==wr?jn.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((a,l)=>{let c=l+r,u;if(u=v5(t,a,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,c+1):s.splice(i,0,l,l+a.nodeSize,aS(u,a,c+1,Vc)),i+=3}});let o=S5(i?x5(t):t,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new jn(o.length?this.local.concat(o).sort(qc):this.local,s||this.children)}remove(e){return e.length==0||this==wr?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+t,l=r[i+1]+t;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>a&&h.to<l&&(e[u]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,a+1);c!=wr?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new jn(s,r):wr}forChild(e,t){if(this==wr)return this;if(t.isLeaf)return jn.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof Bl){let c=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;c<u&&(s||(s=[])).push(l.copy(c,u))}}if(s){let a=new jn(s.sort(qc),yd);return r?new Al([a,r]):a}return r||wr}eq(e){if(this==e)return!0;if(!(e instanceof jn)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return rE(this.localsInner(e))}localsInner(e){if(this==wr)return yd;if(e.inlineContent||!this.local.some(Bl.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Bl||t.push(this.local[r]);return t}forEachSet(e){e(this)}}jn.empty=new jn([],[]);jn.removeOverlap=rE;const wr=jn.empty;class Al{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Vc));return Al.from(r)}forChild(e,t){if(t.isLeaf)return jn.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=wr&&(i instanceof Al?r=r.concat(i.members):r.push(i))}return Al.from(r)}eq(e){if(!(e instanceof Al)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?rE(r?t:t.sort(qc)):yd}static from(e){switch(e.length){case 0:return wr;case 1:return e[0];default:return new Al(e.every(t=>t instanceof jn)?e:e.reduce((t,r)=>t.concat(r instanceof jn?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function QX(n,e,t,r,s,i,o){let a=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let h=0;t.maps[c].forEach((p,m,S,x)=>{let v=x-S-(m-p);for(let w=0;w<a.length;w+=3){let C=a[w+1];if(C<0||p>C+u-h)continue;let _=a[w]+u-h;m>=_?a[w+1]=p<=_?-2:-1:p>=u&&v&&(a[w]+=v,a[w+1]+=v)}h+=v}),u=t.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=t.map(n[c]+i),h=u-s;if(h<0||h>=r.content.size){l=!0;continue}let p=t.map(n[c+1]+i,-1),m=p-s,{index:S,offset:x}=r.content.findIndex(h),v=r.maybeChild(S);if(v&&x==h&&x+v.nodeSize==m){let w=a[c+2].mapInner(t,v,u+1,n[c]+i+1,o);w!=wr?(a[c]=h,a[c+1]=m,a[c+2]=w):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=eZ(a,n,e,t,s,i,o),u=aS(c,r,0,o);e=u.local;for(let h=0;h<a.length;h+=3)a[h+1]<0&&(a.splice(h,3),h-=3);for(let h=0,p=0;h<u.children.length;h+=3){let m=u.children[h];for(;p<a.length&&a[p]<m;)p+=3;a.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new jn(e.sort(qc),a)}function S5(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new xi(s.from+e,s.to+e,s.type))}return t}function eZ(n,e,t,r,s,i,o){function a(l,c){for(let u=0;u<l.local.length;u++){let h=l.local[u].map(r,s,c);h?t.push(h):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+i+1);return t}function v5(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function x5(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function aS(n,e,t,r){let s=[],i=!1;e.forEach((a,l)=>{let c=v5(n,a,l+t);if(c){i=!0;let u=aS(c,a,t+l+1,r);u!=wr&&s.push(l,l+a.nodeSize,u)}});let o=S5(i?x5(n):n,-t).sort(qc);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new jn(o,s):wr}function qc(n,e){return n.from-e.from||n.to-e.to}function rE(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),ID(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),ID(e,s,r.copy(i.from,r.to)));break}}}return e}function ID(n,e,t){for(;e<n.length&&qc(t,n[e])>0;)e++;n.splice(e,0,t)}function G1(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=wr&&e.push(r)}),n.cursorWrapper&&e.push(jn.create(n.state.doc,[n.cursorWrapper.deco])),Al.from(e)}const tZ={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},nZ=Es&&zl<=11;class rZ{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class sZ{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new rZ,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Es&&zl<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),nZ&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tZ)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(SD(this.view)){if(this.suppressingSelectionUpdates)return Ma(this.view);if(Es&&zl<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Ud(i))t.add(i);for(let i=e.anchorNode;i;i=Ud(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&SD(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let h=this.registerMutation(t[u],l);h&&(i=i<0?h.from:Math.min(h.from,i),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(a=!0))}if(no&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,p]=u;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of u){let m=p.parentNode;m&&m.nodeName=="LI"&&(!h||aZ(e,h)!=m)&&p.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&A0(r)&&(c=XI(e))&&c.eq(lt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ma(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),iZ(e)),this.handleDOMChange(i,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ma(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Es&&zl<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:p}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p)}let o=s&&s.parentNode==e.target?rr(s)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?rr(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ED=new WeakMap,_D=!1;function iZ(n){if(!ED.has(n)&&(ED.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=no,_D)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),_D=!0}}function TD(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Qc(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function oZ(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return TD(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?TD(n,t):null}function aZ(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function lZ(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,u=l.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],A0(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Ir&&n.input.lastKeyCode===8)for(let v=i;v>s;v--){let w=r.childNodes[v-1],C=w.pmViewDesc;if(w.nodeName=="BR"&&!C){i=v;break}if(!C||C.size)break}let h=n.state.doc,p=n.someProp("domParser")||_d.fromSchema(n.state.schema),m=h.resolve(o),S=null,x=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:s,to:i,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:cZ,context:m});if(c&&c[0].pos!=null){let v=c[0].pos,w=c[1]&&c[1].pos;w==null&&(w=v),S={anchor:v+o,head:w+o}}return{doc:x,sel:S,from:o,to:a}}function cZ(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Vr&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Vr&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const uZ=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function dZ(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let $=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,H=XI(n,$);if(H&&!n.state.selection.eq(H)){if(Ir&&ka&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",J=>J(n,Dc(13,"Enter"))))return;let G=n.state.tr.setSelection(H);$=="pointer"?G.setMeta("pointer",!0):$=="key"&&G.scrollIntoView(),i&&G.setMeta("composition",i),n.dispatch(G)}return}let o=n.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=lZ(n,e,t),u=n.state.doc,h=u.slice(c.from,c.to),p,m;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,m="end"):(p=n.state.selection.from,m="start"),n.input.lastKeyCode=null;let S=pZ(h.content,c.doc.content,c.from,p,m);if(S&&n.input.domChangeCount++,(Hd&&n.input.lastIOSEnter>Date.now()-225||ka)&&s.some($=>$.nodeType==1&&!uZ.test($.nodeName))&&(!S||S.endA>=S.endB)&&n.someProp("handleKeyDown",$=>$(n,Dc(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!S)if(r&&l instanceof nt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))S={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let $=MD(n,n.state.doc,c.sel);if($&&!$.eq(n.state.selection)){let H=n.state.tr.setSelection($);i&&H.setMeta("composition",i),n.dispatch(H)}}return}n.state.selection.from<n.state.selection.to&&S.start==S.endB&&n.state.selection instanceof nt&&(S.start>n.state.selection.from&&S.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?S.start=n.state.selection.from:S.endA<n.state.selection.to&&S.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(S.endB+=n.state.selection.to-S.endA,S.endA=n.state.selection.to)),Es&&zl<=11&&S.endB==S.start+1&&S.endA==S.start&&S.start>c.from&&c.doc.textBetween(S.start-c.from-1,S.start-c.from+1)==" "&&(S.start--,S.endA--,S.endB--);let x=c.doc.resolveNoCache(S.start-c.from),v=c.doc.resolveNoCache(S.endB-c.from),w=u.resolve(S.start),C=x.sameParent(v)&&x.parent.inlineContent&&w.end()>=S.endA,_;if((Hd&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!C&&x.pos<c.doc.content.size&&(!x.sameParent(v)||!x.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(x.pos,v.pos,"",""))&&(_=lt.findFrom(c.doc.resolve(x.pos+1),1,!0))&&_.head>x.pos)&&n.someProp("handleKeyDown",$=>$(n,Dc(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>S.start&&fZ(u,S.start,S.endA,x,v)&&n.someProp("handleKeyDown",$=>$(n,Dc(8,"Backspace")))){ka&&Ir&&n.domObserver.suppressSelectionUpdates();return}Ir&&S.endB==S.start&&(n.input.lastChromeDelete=Date.now()),ka&&!C&&x.start()!=v.start()&&v.parentOffset==0&&x.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==S.endA&&(S.endB-=2,v=c.doc.resolveNoCache(S.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function($){return $(n,Dc(13,"Enter"))})},20));let E=S.start,T=S.endA,A,O,D;if(C){if(x.pos==v.pos)Es&&zl<=11&&x.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ma(n),20)),A=n.state.tr.delete(E,T),O=u.resolve(S.start).marksAcross(u.resolve(S.endA));else if(S.endA==S.endB&&(D=hZ(x.parent.content.cut(x.parentOffset,v.parentOffset),w.parent.content.cut(w.parentOffset,S.endA-w.start()))))A=n.state.tr,D.type=="add"?A.addMark(E,T,D.mark):A.removeMark(E,T,D.mark);else if(x.parent.child(x.index()).isText&&x.index()==v.index()-(v.textOffset?0:1)){let $=x.parent.textBetween(x.parentOffset,v.parentOffset);if(n.someProp("handleTextInput",H=>H(n,E,T,$)))return;A=n.state.tr.insertText($,E,T)}}if(A||(A=n.state.tr.replace(E,T,c.doc.slice(S.start-c.from,S.endB-c.from))),c.sel){let $=MD(n,A.doc,c.sel);$&&!(Ir&&n.composing&&$.empty&&(S.start!=S.endB||n.input.lastChromeDelete<Date.now()-100)&&($.head==E||$.head==A.mapping.map(T)-1)||Es&&$.empty&&$.head==E)&&A.setSelection($)}O&&A.ensureMarks(O),i&&A.setMeta("composition",i),n.dispatch(A.scrollIntoView())}function MD(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ZI(n,e.resolve(t.anchor),e.resolve(t.head))}function hZ(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(s.length==1&&i.length==0)a=s[0],o="add",l=u=>u.mark(a.addToSet(u.marks));else if(s.length==0&&i.length==1)a=i[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(ge.from(c).eq(n))return{mark:a,type:o}}function fZ(n,e,t,r,s){if(t-e<=s.pos-r.pos||Y1(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&t==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(Y1(i,!0,!0));return!o.parent.isTextblock||o.pos>t||Y1(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Y1(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function pZ(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let l=Math.max(0,i-Math.min(o,a));r-=o+l-i}if(o<i&&n.size<e.size){let l=r<=i&&r>=o?i-r:0;i-=l,i&&i<e.size&&AD(e.textBetween(i-1,i+1))&&(i+=l?1:-1),a=i+(a-o),o=i}else if(a<i){let l=r<=i&&r>=a?i-r:0;i-=l,i&&i<n.size&&AD(n.textBetween(i-1,i+1))&&(i+=l?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}function AD(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class gZ{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new RX,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(LD),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=DD(this),RD(this),this.nodeViews=jD(this),this.docView=hD(this.state.doc,OD(this),G1(this),this.dom,this),this.domObserver=new sZ(this,(r,s,i,o)=>dZ(this,r,s,i,o)),this.domObserver.start(),DX(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&QP(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(LD),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(p5(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let m=jD(this);yZ(m,this.nodeViews)&&(this.nodeViews=m,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&QP(this),this.editable=DD(this),RD(this);let l=G1(this),c=OD(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(s.selection))&&(o=!0);let p=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&GY(this);if(o){this.domObserver.stop();let m=h&&(Es||Ir)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&mZ(s.selection,e.selection);if(h){let S=Ir?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qX(this)),(i||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=hD(e.doc,c,l,this.dom,this)),S&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&SX(this))?Ma(this,m):(n5(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&YY(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof We){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&oD(this,t.getBoundingClientRect(),e)}else oD(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new m5(e.slice,e.move,s<0?void 0:We.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=t?t(a):a))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let a=i[o].props[e];if(a!=null&&(s=t?t(a):a))return s}}hasFocus(){if(Es){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&XY(this.dom),Ma(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return tX(this,e)}coordsAtPos(e,t=1){return GF(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return oX(this,t||this.state,e)}pasteHTML(e,t){return dp(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return dp(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return JI(this,e)}destroy(){this.docView&&(jX(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],G1(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,NY())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return NX(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Vr&&this.root.nodeType===11&&UY(this.dom.ownerDocument)==this.dom&&oZ(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function OD(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[xi.node(0,n.state.doc.content.size,e)]}function RD(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:xi.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function DD(n){return!n.someProp("editable",e=>e(n.state)===!1)}function mZ(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function jD(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function yZ(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function LD(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Kl={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},lS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},SZ=typeof navigator<"u"&&/Mac/.test(navigator.platform),vZ=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var sr=0;sr<10;sr++)Kl[48+sr]=Kl[96+sr]=String(sr);for(var sr=1;sr<=24;sr++)Kl[sr+111]="F"+sr;for(var sr=65;sr<=90;sr++)Kl[sr]=String.fromCharCode(sr+32),lS[sr]=String.fromCharCode(sr);for(var X1 in Kl)lS.hasOwnProperty(X1)||(lS[X1]=Kl[X1]);function xZ(n){var e=SZ&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||vZ&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?lS:Kl)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const wZ=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),bZ=typeof navigator<"u"&&/Win/.test(navigator.platform);function CZ(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))wZ?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function PZ(n){let e=Object.create(null);for(let t in n)e[CZ(t)]=n[t];return e}function Z1(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function kZ(n){return new cr({props:{handleKeyDown:w5(n)}})}function w5(n){let e=PZ(n);return function(t,r){let s=xZ(r),i,o=e[Z1(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Z1(s,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(bZ&&r.ctrlKey&&r.altKey)&&(i=Kl[r.keyCode])&&i!=s){let a=e[Z1(i,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const sE=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function b5(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const C5=(n,e,t)=>{let r=b5(n,t);if(!r)return!1;let s=iE(r);if(!s){let o=r.blockRange(),a=o&&lh(o);return a==null?!1:(e&&e(n.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(O5(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Kd(i,"end")||We.isSelectable(i)))for(let o=r.depth;;o--){let a=T0(n.doc,r.before(o),r.after(o),Te.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Kd(i,"end")?lt.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):We.create(l.doc,s.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},IZ=(n,e,t)=>{let r=b5(n,t);if(!r)return!1;let s=iE(r);return s?P5(n,s,e):!1},EZ=(n,e,t)=>{let r=I5(n,t);if(!r)return!1;let s=oE(r);return s?P5(n,s,e):!1};function P5(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=T0(n.doc,i,l,Te.empty);if(!c||c.from!=i||c instanceof Bn&&c.slice.size>=l-i)return!1;if(t){let u=n.tr.step(c);u.setSelection(nt.create(u.doc,i)),t(u.scrollIntoView())}return!0}function Kd(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const k5=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=iE(r)}let o=i&&i.nodeBefore;return!o||!We.isSelectable(o)?!1:(e&&e(n.tr.setSelection(We.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function iE(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function I5(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const E5=(n,e,t)=>{let r=I5(n,t);if(!r)return!1;let s=oE(r);if(!s)return!1;let i=s.nodeAfter;if(O5(n,s,e,1))return!0;if(r.parent.content.size==0&&(Kd(i,"start")||We.isSelectable(i))){let o=T0(n.doc,r.before(),r.after(),Te.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=n.tr.step(o);a.setSelection(Kd(i,"start")?lt.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):We.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},_5=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=oE(r)}let o=i&&i.nodeAfter;return!o||!We.isSelectable(o)?!1:(e&&e(n.tr.setSelection(We.create(n.doc,i.pos)).scrollIntoView()),!0)};function oE(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const _Z=(n,e)=>{let t=n.selection,r=t instanceof We,s;if(r){if(t.node.isTextblock||!tc(n.doc,t.from))return!1;s=t.from}else if(s=_0(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(We.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},TZ=(n,e)=>{let t=n.selection,r;if(t instanceof We){if(t.node.isTextblock||!tc(n.doc,t.to))return!1;r=t.to}else if(r=_0(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},MZ=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&lh(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},T5=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
95
|
-
`).scrollIntoView()),!0)};function aE(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const AZ=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=aE(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(lt.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},M5=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Gs||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=aE(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=n.tr.insert(o,i.createAndFill());a.setSelection(nt.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},A5=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Ta(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&lh(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function OZ(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof We&&e.selection.node.isBlock)return!r.parentOffset||!Ta(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,a,l=!1,c=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),c=r.start(m)==r.pos-(r.depth-m),a=aE(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),i.unshift(l&&a?{type:a}:null),o=m;break}else{if(m==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof nt||e.selection instanceof Gs)&&u.deleteSelection();let h=u.mapping.map(r.pos),p=Ta(u.doc,h,i.length,i);if(p||(i[0]=a?{type:a}:null,p=Ta(u.doc,h,i.length,i)),!p)return!1;if(u.split(h,i.length,i),!l&&c&&r.node(o).type!=a){let m=u.mapping.map(r.before(o)),S=u.doc.resolve(m);a&&r.node(o-1).canReplaceWith(S.index(),S.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return t&&t(u.scrollIntoView()),!0}}const RZ=OZ(),DZ=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(We.create(n.doc,s))),!0)};function jZ(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||tc(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function O5(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&jZ(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&a.matchType(o[0]||i.type).validEnd){if(t){let m=e.pos+i.nodeSize,S=ge.empty;for(let w=o.length-1;w>=0;w--)S=ge.from(o[w].create(null,S));S=ge.from(s.copy(S));let x=n.tr.step(new Kn(e.pos-1,m,e.pos,m,new Te(S,1,0),o.length,!0)),v=x.doc.resolve(m+2*o.length);v.nodeAfter&&v.nodeAfter.type==s.type&&tc(x.doc,v.pos)&&x.join(v.pos),t(x.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&l?null:lt.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),p=h&&lh(h);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(h,p).scrollIntoView()),!0;if(c&&Kd(i,"start",!0)&&Kd(s,"end")){let m=s,S=[];for(;S.push(m),!m.isTextblock;)m=m.lastChild;let x=i,v=1;for(;!x.isTextblock;x=x.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,x.content)){if(t){let w=ge.empty;for(let _=S.length-1;_>=0;_--)w=ge.from(S[_].copy(w));let C=n.tr.step(new Kn(e.pos-S.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Te(w,S.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function R5(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(nt.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const LZ=R5(-1),NZ=R5(1);function FZ(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),a=o&&qI(o,n,e);return a?(r&&r(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function ND(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=t.selection.ranges[i];t.doc.nodesBetween(o,a,(l,c)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)s=!0;else{let u=t.doc.resolve(c),h=u.index();s=u.parent.canReplaceWith(h,h+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[o];i.setBlockType(a,l,n,e)}r(i.scrollIntoView())}return!0}}function lE(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}lE(sE,C5,k5);lE(sE,E5,_5);lE(T5,M5,A5,RZ);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function zZ(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i);if(!o)return!1;let a=r?t.tr:null;return $Z(a,o,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function $Z(n,e,t,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new tS(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new tS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=qI(i,t,r,e);return a?(n&&BZ(n,e,a,s,t),!0):!1}function BZ(n,e,t,r,s){let i=ge.empty;for(let u=t.length-1;u>=0;u--)i=ge.from(t[u].type.create(t[u].attrs,i));n.step(new Kn(e.start-(r?2:0),e.end,e.start,e.end,new Te(i,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==s&&(o=u+1);let a=t.length-o,l=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,h=e.endIndex,p=!0;u<h;u++,p=!1)!p&&Ta(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return n}function UZ(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?HZ(e,t,n,i):KZ(e,t,i):!0:!1}}function HZ(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Kn(i-1,o,i,o,new Te(ge.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new tS(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=lh(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return tc(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function KZ(n,e,t){let r=n.tr,s=t.parent;for(let m=t.end,S=t.endIndex-1,x=t.startIndex;S>x;S--)m-=s.child(S).nodeSize,r.delete(m-1,m+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?ge.empty:ge.from(s))))return!1;let h=i.pos,p=h+o.nodeSize;return r.step(new Kn(h-(a?1:0),p+(l?1:0),h+1,p-1,new Te((a?ge.empty:ge.from(s.copy(ge.empty))).append(l?ge.empty:ge.from(s.copy(ge.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function WZ(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,u=ge.from(c?n.create():null),h=new Te(ge.from(n.create(null,ge.from(a.type.create(null,u)))),c?3:1,0),p=i.start,m=i.end;t(e.tr.step(new Kn(p-(c?3:1),m,p,m,h,1,!0)).scrollIntoView())}return!0}}function D0(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class j0{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const h=l(...u)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a=[],l=!!e,c=e||i.tr,u=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),a.every(p=>p===!0)),h={...Object.fromEntries(Object.entries(r).map(([p,m])=>[p,(...x)=>{const v=this.buildProps(c,t),w=m(...x)(v);return a.push(w),h}])),run:u};return h}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a={tr:e,editor:s,view:o,state:D0({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}let VZ=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function Fe(n,e,t){return n.config[e]===void 0&&n.parent?Fe(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?Fe(n.parent,e,t):null}):n.config[e]}function L0(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function D5(n){const e=[],{nodeExtensions:t,markExtensions:r}=L0(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage,extensions:s},l=Fe(o,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),s.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=Fe(o,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,h])=>{const p={...i,...h};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,e.push({type:o.name,name:u,attribute:p})})}),e}function Vn(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function qn(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(u=>!l.includes(u));r[s]=[...l,...c].join(" ")}else if(s==="style"){const a=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[h,p]=u.split(":").map(m=>m.trim());c.set(h,p)}),a.forEach(u=>{const[h,p]=u.split(":").map(m=>m.trim());c.set(h,p)}),r[s]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[s]=i}),r},{})}function ek(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>qn(t,r),{})}function j5(n){return typeof n=="function"}function ft(n,e=void 0,...t){return j5(n)?e?n.bind(e)(...t):n(...t):n}function qZ(n={}){return Object.keys(n).length===0&&n.constructor===Object}function GZ(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function FD(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):GZ(t.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function zD(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&qZ(t)?!1:t!=null))}function L5(n,e){var t;const r=D5(n),{nodeExtensions:s,markExtensions:i}=L0(n),o=(t=s.find(c=>Fe(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(s.map(c=>{const u=r.filter(w=>w.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},p=n.reduce((w,C)=>{const _=Fe(C,"extendNodeSchema",h);return{...w,..._?_(c):{}}},{}),m=zD({...p,content:ft(Fe(c,"content",h)),marks:ft(Fe(c,"marks",h)),group:ft(Fe(c,"group",h)),inline:ft(Fe(c,"inline",h)),atom:ft(Fe(c,"atom",h)),selectable:ft(Fe(c,"selectable",h)),draggable:ft(Fe(c,"draggable",h)),code:ft(Fe(c,"code",h)),whitespace:ft(Fe(c,"whitespace",h)),linebreakReplacement:ft(Fe(c,"linebreakReplacement",h)),defining:ft(Fe(c,"defining",h)),isolating:ft(Fe(c,"isolating",h)),attrs:Object.fromEntries(u.map(w=>{var C;return[w.name,{default:(C=w==null?void 0:w.attribute)===null||C===void 0?void 0:C.default}]}))}),S=ft(Fe(c,"parseHTML",h));S&&(m.parseDOM=S.map(w=>FD(w,u)));const x=Fe(c,"renderHTML",h);x&&(m.toDOM=w=>x({node:w,HTMLAttributes:ek(w,u)}));const v=Fe(c,"renderText",h);return v&&(m.toText=v),[c.name,m]})),l=Object.fromEntries(i.map(c=>{const u=r.filter(v=>v.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},p=n.reduce((v,w)=>{const C=Fe(w,"extendMarkSchema",h);return{...v,...C?C(c):{}}},{}),m=zD({...p,inclusive:ft(Fe(c,"inclusive",h)),excludes:ft(Fe(c,"excludes",h)),group:ft(Fe(c,"group",h)),spanning:ft(Fe(c,"spanning",h)),code:ft(Fe(c,"code",h)),attrs:Object.fromEntries(u.map(v=>{var w;return[v.name,{default:(w=v==null?void 0:v.attribute)===null||w===void 0?void 0:w.default}]}))}),S=ft(Fe(c,"parseHTML",h));S&&(m.parseDOM=S.map(v=>FD(v,u)));const x=Fe(c,"renderHTML",h);return x&&(m.toDOM=v=>x({mark:v,HTMLAttributes:ek(v,u)})),[c.name,m]}));return new CF({topNode:o,nodes:a,marks:l})}function J1(n,e){return e.nodes[n]||e.marks[n]||null}function $D(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function N0(n,e){const t=yu.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const YZ=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,a)=>{var l,c;const u=((c=(l=s.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),t};function cE(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class F0{constructor(e){this.find=e.find,this.handler=e.handler}}const XZ=(n,e)=>{if(cE(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Pm(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(p=>p.type.spec.code))return!1;let u=!1;const h=YZ(c)+i;return o.forEach(p=>{if(u)return;const m=XZ(h,p.find);if(!m)return;const S=l.state.tr,x=D0({state:l.state,transaction:S}),v={from:r-(m[0].length-i.length),to:s},{commands:w,chain:C,can:_}=new j0({editor:t,state:x});p.handler({state:x,range:v,match:m,commands:w,chain:C,can:_})===null||!S.steps.length||(S.setMeta(a,{transform:S,from:r,to:s,text:i}),l.dispatch(S),u=!0)}),u}function ZZ(n){const{editor:e,rules:t}=n,r=new cr({state:{init(){return null},apply(s,i,o){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=N0(ge.from(u),o.schema);const{from:h}=l,p=h+u.length;Pm({editor:e,from:h,to:p,text:u,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return Pm({editor:e,from:i,to:o,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Pm({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Pm({editor:e,from:o.pos,to:o.pos,text:`
|
|
96
|
-
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function JZ(n){return Object.prototype.toString.call(n).slice(8,-1)}function km(n){return JZ(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function z0(n,e){const t={...n};return km(n)&&km(e)&&Object.keys(e).forEach(r=>{km(e[r])&&km(n[r])?t[r]=z0(n[r],e[r]):t[r]=e[r]}),t}class Bo{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Bo(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>z0(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Bo(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ft(Fe(t,"addOptions",{name:t.name})),t.storage=ft(Fe(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function QZ(n){return typeof n=="number"}class eJ{constructor(e){this.find=e.find,this.handler=e.handler}}const tJ=(n,e,t)=>{if(cE(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function nJ(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:c,can:u}=new j0({editor:e,state:t}),h=[];return t.doc.nodesBetween(r,s,(m,S)=>{if(!m.isTextblock||m.type.spec.code)return;const x=Math.max(r,S),v=Math.min(s,S+m.content.size),w=m.textBetween(x-S,v-S,void 0,"");tJ(w,i.find,o).forEach(_=>{if(_.index===void 0)return;const E=x+_.index+1,T=E+_[0].length,A={from:t.tr.mapping.map(E),to:t.tr.mapping.map(T)},O=i.handler({state:t,range:A,match:_,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});h.push(O)})}),h.every(m=>m!==null)}let Im=null;const rJ=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function sJ(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:h,to:p,rule:m,pasteEvt:S})=>{const x=u.tr,v=D0({state:u,transaction:x});if(!(!nJ({editor:e,state:v,from:Math.max(h-1,0),to:p.b-1,rule:m,pasteEvent:S,dropEvent:a})||!x.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,x}};return t.map(u=>new cr({view(h){const p=S=>{var x;r=!((x=h.dom.parentElement)===null||x===void 0)&&x.contains(S.target)?h.dom.parentElement:null,r&&(Im=e)},m=()=>{Im&&(Im=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(i=r===h.dom.parentElement,a=p,!i){const m=Im;m&&setTimeout(()=>{const S=m.state.selection;S&&m.commands.deleteRange({from:S.from,to:S.to})},10)}return!1},paste:(h,p)=>{var m;const S=(m=p.clipboardData)===null||m===void 0?void 0:m.getData("text/html");return o=p,s=!!(S!=null&&S.includes("data-pm-slice")),!1}}},appendTransaction:(h,p,m)=>{const S=h[0],x=S.getMeta("uiEvent")==="paste"&&!s,v=S.getMeta("uiEvent")==="drop"&&!i,w=S.getMeta("applyPasteRules"),C=!!w;if(!x&&!v&&!C)return;if(C){let{text:T}=w;typeof T=="string"?T=T:T=N0(ge.from(T),m.schema);const{from:A}=w,O=A+T.length,D=rJ(T);return l({rule:u,state:m,from:A,to:{b:O},pasteEvt:D})}const _=p.doc.content.findDiffStart(m.doc.content),E=p.doc.content.findDiffEnd(m.doc.content);if(!(!QZ(_)||!E||_===E.b))return l({rule:u,state:m,from:_,to:E,pasteEvt:o})}}))}function iJ(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Fc{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Fc.resolve(e),this.schema=L5(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Fc.sort(Fc.flatten(e)),r=iJ(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=Fe(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=Fe(r,"priority")||100,o=Fe(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:J1(t.name,this.schema)},s=Fe(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=Fc.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:J1(o.name,this.schema)},l=[],c=Fe(o,"addKeyboardShortcuts",a);let u={};if(o.type==="mark"&&Fe(o,"exitable",a)&&(u.ArrowRight=()=>Bo.handleExit({editor:e,mark:o})),c){const x=Object.fromEntries(Object.entries(c()).map(([v,w])=>[v,()=>w({editor:e})]));u={...u,...x}}const h=kZ(u);l.push(h);const p=Fe(o,"addInputRules",a);$D(o,e.options.enableInputRules)&&p&&r.push(...p());const m=Fe(o,"addPasteRules",a);$D(o,e.options.enablePasteRules)&&m&&s.push(...m());const S=Fe(o,"addProseMirrorPlugins",a);if(S){const x=S();l.push(...x)}return l}).flat();return[ZZ({editor:e,rules:r}),...sJ({editor:e,rules:s}),...i]}get attributes(){return D5(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=L0(this.extensions);return Object.fromEntries(t.filter(r=>!!Fe(r,"addNodeView")).map(r=>{const s=this.attributes.filter(l=>l.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:Vn(r.name,this.schema)},o=Fe(r,"addNodeView",i);if(!o)return[];const a=(l,c,u,h,p)=>{const m=ek(l,s);return o()({node:l,view:c,getPos:u,decorations:h,innerDecorations:p,editor:e,extension:r,HTMLAttributes:m})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:J1(e.name,this.schema)};e.type==="mark"&&(!((t=ft(Fe(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=Fe(e,"onBeforeCreate",r),i=Fe(e,"onCreate",r),o=Fe(e,"onUpdate",r),a=Fe(e,"onSelectionUpdate",r),l=Fe(e,"onTransaction",r),c=Fe(e,"onFocus",r),u=Fe(e,"onBlur",r),h=Fe(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}}class lr{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new lr(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>z0(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new lr({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ft(Fe(t,"addOptions",{name:t.name})),t.storage=ft(Fe(t,"addStorage",{name:t.name,options:t.options})),t}}function N5(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
97
|
-
|
|
98
|
-
`,textSerializers:o={}}=t||{};let a="";return n.nodesBetween(r,s,(l,c,u,h)=>{var p;l.isBlock&&c>r&&(a+=i);const m=o==null?void 0:o[l.type.name];if(m)return u&&(a+=m({node:l,pos:c,parent:u,index:h,range:e})),!1;l.isText&&(a+=(p=l==null?void 0:l.text)===null||p===void 0?void 0:p.slice(Math.max(r,c)-c,s-c))}),a}function uE(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const oJ=lr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new cr({key:new Qs("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),a=Math.max(...i.map(u=>u.$to.pos)),l=uE(t);return N5(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),aJ=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),lJ=(n=!1)=>({commands:e})=>e.setContent("",n),cJ=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,h=c.resolve(u.map(l)),p=c.resolve(u.map(l+a.nodeSize)),m=h.blockRange(p);if(!m)return;const S=lh(m);if(a.type.isTextblock){const{defaultType:x}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,x)}(S||S===0)&&e.lift(m,S)})}),!0},uJ=n=>e=>n(e),dJ=()=>({state:n,dispatch:e})=>M5(n,e),hJ=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new nt(r.doc.resolve(o-1))),!0},fJ=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const a=s.before(i),l=s.after(i);n.delete(a,l).scrollIntoView()}return!0}return!1},pJ=n=>({tr:e,state:t,dispatch:r})=>{const s=Vn(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),c=i.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},gJ=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},mJ=()=>({state:n,dispatch:e})=>sE(n,e),yJ=()=>({commands:n})=>n.keyboardShortcut("Enter"),SJ=()=>({state:n,dispatch:e})=>AZ(n,e);function cS(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:cE(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function F5(n,e,t={}){return n.find(r=>r.type===e&&cS(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function BD(n,e,t={}){return!!F5(n,e,t)}function $0(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!F5([...s.node.marks],e,t)))return;let o=s.index,a=n.start()+s.offset,l=o+1,c=a+s.node.nodeSize;for(;o>0&&BD([...n.parent.child(o-1).marks],e,t);)o-=1,a-=n.parent.child(o).nodeSize;for(;l<n.parent.childCount&&BD([...n.parent.child(l).marks],e,t);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function rc(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const vJ=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=rc(n,r.schema),{doc:o,selection:a}=t,{$from:l,from:c,to:u}=a;if(s){const h=$0(l,i,e);if(h&&h.from<=c&&h.to>=u){const p=nt.create(o,h.from,h.to);t.setSelection(p)}}return!0},xJ=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function z5(n){return n instanceof nt}function zc(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function $5(n,e=null){if(!e)return null;const t=lt.atStart(n),r=lt.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?nt.create(n,zc(0,s,i),zc(n.content.size,s,i)):nt.create(n,zc(e,s,i),zc(e,s,i))}function wJ(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function dE(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const bJ=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(dE()||wJ())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!z5(t.state.selection))return o(),!0;const a=$5(s.doc,n)||t.state.selection,l=t.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},CJ=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),PJ=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),B5=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&B5(r)}return n};function Pf(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return B5(t)}function uS(n,e,t){if(n instanceof Ji||n instanceof ge)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return ge.fromArray(n.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),uS("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,a="";const l=new CF({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?_d.fromSchema(l).parseSlice(Pf(n),t.parseOptions):_d.fromSchema(l).parse(Pf(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=_d.fromSchema(e);return t.slice?i.parseSlice(Pf(n),t.parseOptions).content:i.parse(Pf(n),t.parseOptions)}return uS("",e,t)}function kJ(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof Bn||s instanceof Kn))return;const i=n.mapping.maps[r];let o=0;i.forEach((a,l,c,u)=>{o===0&&(o=u)}),n.setSelection(lt.near(n.doc.resolve(o),t))}const IJ=n=>!("type"in n),EJ=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;try{a=uS(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(S){return i.emit("contentError",{editor:i,error:S,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:l,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,h=!0;if((IJ(a)?a:[a]).forEach(S=>{S.check(),u=u?S.isText&&S.marks.length===0:!1,h=h?S.isBlock:!1}),l===c&&h){const{parent:S}=r.doc.resolve(l);S.isTextblock&&!S.type.spec.code&&!S.childCount&&(l-=1,c+=1)}let m;if(u){if(Array.isArray(e))m=e.map(S=>S.text||"").join("");else if(e instanceof ge){let S="";e.forEach(x=>{x.text&&(S+=x.text)}),m=S}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,l,c)}else m=a,r.replaceWith(l,c,m);t.updateSelection&&kJ(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:m}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:m})}return!0},_J=()=>({state:n,dispatch:e})=>_Z(n,e),TJ=()=>({state:n,dispatch:e})=>TZ(n,e),MJ=()=>({state:n,dispatch:e})=>C5(n,e),AJ=()=>({state:n,dispatch:e})=>E5(n,e),OJ=()=>({state:n,dispatch:e,tr:t})=>{try{const r=_0(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},RJ=()=>({state:n,dispatch:e,tr:t})=>{try{const r=_0(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},DJ=()=>({state:n,dispatch:e})=>IZ(n,e),jJ=()=>({state:n,dispatch:e})=>EZ(n,e);function U5(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function LJ(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))dE()||U5()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const NJ=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=LJ(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function fp(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?Vn(e,n.schema):null,a=[];n.doc.nodesBetween(r,s,(h,p)=>{if(h.isText)return;const m=Math.max(r,p),S=Math.min(s,p+h.nodeSize);a.push({node:h,from:m,to:S})});const l=s-r,c=a.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>cS(h.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((h,p)=>h+p.to-p.from,0)>=l}const FJ=(n,e={})=>({state:t,dispatch:r})=>{const s=Vn(n,t.schema);return fp(t,s,e)?MZ(t,r):!1},zJ=()=>({state:n,dispatch:e})=>A5(n,e),$J=n=>({state:e,dispatch:t})=>{const r=Vn(n,e.schema);return UZ(r)(e,t)},BJ=()=>({state:n,dispatch:e})=>T5(n,e);function B0(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function UD(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const UJ=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=B0(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=Vn(n,r.schema)),a==="mark"&&(o=rc(n,r.schema)),s&&t.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{i&&i===c.type&&t.setNodeMarkup(u,void 0,UD(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(h=>{o===h.type&&t.addMark(u,u+c.nodeSize,o.create(UD(h.attrs,e)))})})}),!0):!1},HJ=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),KJ=()=>({tr:n,dispatch:e})=>{if(e){const t=new Gs(n.doc);n.setSelection(t)}return!0},WJ=()=>({state:n,dispatch:e})=>k5(n,e),VJ=()=>({state:n,dispatch:e})=>_5(n,e),qJ=()=>({state:n,dispatch:e})=>DZ(n,e),GJ=()=>({state:n,dispatch:e})=>NZ(n,e),YJ=()=>({state:n,dispatch:e})=>LZ(n,e);function tk(n,e,t={},r={}){return uS(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const XJ=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{var l,c;const{doc:u}=i;if(t.preserveWhitespace!=="full"){const h=tk(n,s.schema,t,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function H5(n,e){const t=rc(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function ZJ(n,e){const t=new zF(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function JJ(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function QJ(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function eQ(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function hE(n){return e=>eQ(e.$from,n)}function U0(n,e){const t=Fc.resolve(n);return L5(t,e)}function tQ(n,e){const t=U0(e),r=Ji.fromJSON(t,n);return N0(r.content,t)}function nQ(n,e){const t=U0(e),r=Pf(n);return _d.fromSchema(t).parse(r).toJSON()}function K5(n,e){const t={from:0,to:n.content.size};return N5(n,t,e)}function rQ(n,e,t){const{blockSeparator:r=`
|
|
99
|
-
|
|
100
|
-
`,textSerializers:s={}}=t||{},i=U0(e),o=Ji.fromJSON(i,n);return K5(o,{blockSeparator:r,textSerializers:{...uE(i),...s}})}function sQ(n,e){const t=Vn(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function W5(n,e){const t=B0(typeof e=="string"?e:e.name,n.schema);return t==="node"?sQ(n,e):t==="mark"?H5(n,e):{}}function iQ(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function oQ(n){const e=iQ(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function aQ(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=t[i];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(i).map(a,-1),u=e.slice(i).map(l),h=e.invert().map(c,-1),p=e.invert().map(u);r.push({oldRange:{from:h,to:p},newRange:{from:c,to:u}})})}),oQ(r)}function fE(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=$0(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function hy(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function nk(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?rc(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(h=>i?i.name===h.type.name:!0).find(h=>cS(h.attrs,t,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:h,$to:p})=>{const m=h.pos,S=p.pos;n.doc.nodesBetween(m,S,(x,v)=>{if(!x.isText&&!x.marks.length)return;const w=Math.max(m,v),C=Math.min(S,v+x.nodeSize),_=C-w;o+=_,a.push(...x.marks.map(E=>({mark:E,from:w,to:C})))})}),o===0)return!1;const l=a.filter(h=>i?i.name===h.mark.type.name:!0).filter(h=>cS(h.mark.attrs,t,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),c=a.filter(h=>i?h.mark.type!==i&&h.mark.type.excludes(i):!0).reduce((h,p)=>h+p.to-p.from,0);return(l>0?l+c:l)>=o}function lQ(n,e,t={}){if(!e)return fp(n,null,t)||nk(n,null,t);const r=B0(e,n.schema);return r==="node"?fp(n,e,t):r==="mark"?nk(n,e,t):!1}function HD(n,e){const{nodeExtensions:t}=L0(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=ft(Fe(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function pE(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(pE(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function cQ(n){return n instanceof We}function uQ(n,e,t){var r;const{selection:s}=e;let i=null;if(z5(s)&&(i=s.$cursor),i){const a=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(u,h,p)=>{if(c)return!1;if(u.isInline){const m=!p||p.type.allowsMarkType(t),S=!!t.isInSet(u.marks)||!u.marks.some(x=>x.type.excludes(t));c=m&&S}return!c}),c})}const dQ=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:a}=i,l=rc(n,r.schema);if(s)if(o){const c=H5(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(u,h,(p,m)=>{const S=Math.max(m,u),x=Math.min(m+p.nodeSize,h);p.marks.find(w=>w.type===l)?p.marks.forEach(w=>{l===w.type&&t.addMark(S,x,l.create({...w.attrs,...e}))}):t.addMark(S,x,l.create(e))})});return uQ(r,t,l)},hQ=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),fQ=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=Vn(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>ND(i,{...o,...e})(t)?!0:a.clearNodes()).command(({state:a})=>ND(i,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},pQ=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=zc(n,0,r.content.size),i=We.create(r,s);e.setSelection(i)}return!0},gQ=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=nt.atStart(r).from,a=nt.atEnd(r).to,l=zc(s,o,a),c=zc(i,o,a),u=nt.create(r,l,c);e.setSelection(u)}return!0},mQ=n=>({state:e,dispatch:t})=>{const r=Vn(n,e.schema);return WZ(r)(e,t)};function KD(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e==null?void 0:e.includes(s.type.name));n.tr.ensureMarks(r)}}const yQ=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,c=s.extensionManager.attributes,u=hy(c,a.node().type.name,a.node().attrs);if(i instanceof We&&i.node.isBlock)return!a.parentOffset||!Ta(o,a.pos)?!1:(r&&(n&&KD(t,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,p=a.depth===0?void 0:JJ(a.node(-1).contentMatchAt(a.indexAfter(-1)));let m=h&&p?[{type:p,attrs:u}]:void 0,S=Ta(e.doc,e.mapping.map(a.pos),1,m);if(!m&&!S&&Ta(e.doc,e.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(S=!0,m=p?[{type:p,attrs:u}]:void 0),r){if(S&&(i instanceof nt&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,m),p&&!h&&!a.parentOffset&&a.parent.type!==p)){const x=e.mapping.map(a.before()),v=e.doc.resolve(x);a.node(-1).canReplaceWith(v.index(),v.index()+1,p)&&e.setNodeMarkup(e.mapping.map(a.before()),p)}n&&KD(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return S},SQ=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const a=Vn(n,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==a)return!1;const p=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let w=ge.empty;const C=l.index(-1)?1:l.index(-2)?2:3;for(let D=l.depth-C;D>=l.depth-3;D-=1)w=ge.from(l.node(D).copy(w));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...hy(p,l.node().type.name,l.node().attrs),...e},T=((o=a.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(E))||void 0;w=w.append(ge.from(a.createAndFill(null,T)||void 0));const A=l.before(l.depth-(C-1));t.replace(A,l.after(-_),new Te(w,4-C,0));let O=-1;t.doc.nodesBetween(A,t.doc.content.size,(D,$)=>{if(O>-1)return!1;D.isTextblock&&D.content.size===0&&(O=$+1)}),O>-1&&t.setSelection(nt.near(t.doc.resolve(O))),t.scrollIntoView()}return!0}const m=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,S={...hy(p,h.type.name,h.attrs),...e},x={...hy(p,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const v=m?[{type:a,attrs:S},{type:m,attrs:x}]:[{type:a,attrs:S}];if(!Ta(t.doc,l.pos,2))return!1;if(s){const{selection:w,storedMarks:C}=r,{splittableMarks:_}=i.extensionManager,E=C||w.$to.parentOffset&&w.$from.marks();if(t.split(l.pos,2,v).scrollIntoView(),!E||!s)return!0;const T=E.filter(A=>_.includes(A.type.name));t.ensureMarks(T)}return!0},Q1=(n,e)=>{const t=hE(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&tc(n.doc,t.pos)&&n.join(t.pos),!0},eC=(n,e)=>{const t=hE(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&tc(n.doc,r)&&n.join(r),!0},vQ=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:h,splittableMarks:p}=s.extensionManager,m=Vn(n,o.schema),S=Vn(e,o.schema),{selection:x,storedMarks:v}=o,{$from:w,$to:C}=x,_=w.blockRange(C),E=v||x.$to.parentOffset&&x.$from.marks();if(!_)return!1;const T=hE(A=>HD(A.type.name,h))(x);if(_.depth>=1&&T&&_.depth-T.depth<=1){if(T.node.type===m)return c.liftListItem(S);if(HD(T.node.type.name,h)&&m.validContent(T.node.content)&&a)return l().command(()=>(i.setNodeMarkup(T.pos,m),!0)).command(()=>Q1(i,m)).command(()=>eC(i,m)).run()}return!t||!E||!a?l().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>Q1(i,m)).command(()=>eC(i,m)).run():l().command(()=>{const A=u().wrapInList(m,r),O=E.filter(D=>p.includes(D.type.name));return i.ensureMarks(O),A?!0:c.clearNodes()}).wrapInList(m,r).command(()=>Q1(i,m)).command(()=>eC(i,m)).run()},xQ=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=rc(n,r.schema);return nk(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},wQ=(n,e,t={})=>({state:r,commands:s})=>{const i=Vn(n,r.schema),o=Vn(e,r.schema),a=fp(r,i,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...t})},bQ=(n,e={})=>({state:t,commands:r})=>{const s=Vn(n,t.schema);return fp(t,s,e)?r.lift(s):r.wrapIn(s,e)},CQ=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},PQ=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},kQ=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=rc(n,r.schema),{$from:c,empty:u,ranges:h}=a;if(!s)return!0;if(u&&o){let{from:p,to:m}=a;const S=(i=c.marks().find(v=>v.type===l))===null||i===void 0?void 0:i.attrs,x=$0(c,l,S);x&&(p=x.from,m=x.to),t.removeMark(p,m,l)}else h.forEach(p=>{t.removeMark(p.$from.pos,p.$to.pos,l)});return t.removeStoredMark(l),!0},IQ=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=B0(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=Vn(n,r.schema)),a==="mark"&&(o=rc(n,r.schema)),s&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;let h,p,m,S;t.selection.empty?r.doc.nodesBetween(c,u,(x,v)=>{i&&i===x.type&&(m=Math.max(v,c),S=Math.min(v+x.nodeSize,u),h=v,p=x)}):r.doc.nodesBetween(c,u,(x,v)=>{v<c&&i&&i===x.type&&(m=Math.max(v,c),S=Math.min(v+x.nodeSize,u),h=v,p=x),v>=c&&v<=u&&(i&&i===x.type&&t.setNodeMarkup(v,void 0,{...x.attrs,...e}),o&&x.marks.length&&x.marks.forEach(w=>{if(o===w.type){const C=Math.max(v,c),_=Math.min(v+x.nodeSize,u);t.addMark(C,_,o.create({...w.attrs,...e}))}}))}),p&&(h!==void 0&&t.setNodeMarkup(h,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(x=>{o===x.type&&t.addMark(m,S,o.create({...x.attrs,...e}))}))}),!0):!1},EQ=(n,e={})=>({state:t,dispatch:r})=>{const s=Vn(n,t.schema);return FZ(s,e)(t,r)},_Q=(n,e={})=>({state:t,dispatch:r})=>{const s=Vn(n,t.schema);return zZ(s,e)(t,r)};var TQ=Object.freeze({__proto__:null,blur:aJ,clearContent:lJ,clearNodes:cJ,command:uJ,createParagraphNear:dJ,cut:hJ,deleteCurrentNode:fJ,deleteNode:pJ,deleteRange:gJ,deleteSelection:mJ,enter:yJ,exitCode:SJ,extendMarkRange:vJ,first:xJ,focus:bJ,forEach:CJ,insertContent:PJ,insertContentAt:EJ,joinBackward:MJ,joinDown:TJ,joinForward:AJ,joinItemBackward:OJ,joinItemForward:RJ,joinTextblockBackward:DJ,joinTextblockForward:jJ,joinUp:_J,keyboardShortcut:NJ,lift:FJ,liftEmptyBlock:zJ,liftListItem:$J,newlineInCode:BJ,resetAttributes:UJ,scrollIntoView:HJ,selectAll:KJ,selectNodeBackward:WJ,selectNodeForward:VJ,selectParentNode:qJ,selectTextblockEnd:GJ,selectTextblockStart:YJ,setContent:XJ,setMark:dQ,setMeta:hQ,setNode:fQ,setNodeSelection:pQ,setTextSelection:gQ,sinkListItem:mQ,splitBlock:yQ,splitListItem:SQ,toggleList:vQ,toggleMark:xQ,toggleNode:wQ,toggleWrap:bQ,undoInputRule:CQ,unsetAllMarks:PQ,unsetMark:kQ,updateAttributes:IQ,wrapIn:EQ,wrapInList:_Q});const MQ=lr.create({name:"commands",addCommands(){return{...TQ}}}),AQ=lr.create({name:"drop",addProseMirrorPlugins(){return[new cr({key:new Qs("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),OQ=lr.create({name:"editable",addProseMirrorPlugins(){return[new cr({key:new Qs("editable"),props:{editable:()=>this.editor.options.editable}})]}}),RQ=new Qs("focusEvents"),DQ=lr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new cr({key:RQ,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),jQ=lr.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:h}=l,{pos:p,parent:m}=h,S=h.parent.isTextblock&&p>0?a.doc.resolve(p-1):h,x=S.parent.type.spec.isolating,v=h.pos-h.parentOffset,w=x&&S.parent.childCount===1?v===h.pos:lt.atStart(c).from===p;return!u||!m.type.isTextblock||m.textContent.length||!w||w&&h.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return dE()||U5()?i:s},addProseMirrorPlugins(){return[new cr({key:new Qs("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(x=>x.getMeta("composition")))return;const r=n.some(x=>x.docChanged)&&!e.doc.eq(t.doc),s=n.some(x=>x.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=lt.atStart(e.doc).from,c=lt.atEnd(e.doc).to;if(i||!(o===l&&a===c)||!pE(t.doc))return;const p=t.tr,m=D0({state:t,transaction:p}),{commands:S}=new j0({editor:this.editor,state:m});if(S.clearNodes(),!!p.steps.length)return p}})]}}),LQ=lr.create({name:"paste",addProseMirrorPlugins(){return[new cr({key:new Qs("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),NQ=lr.create({name:"tabindex",addProseMirrorPlugins(){return[new cr({key:new Qs("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class jc{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new jc(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new jc(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new jc(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1),a=this.resolvedPos.doc.resolve(o);if(!s&&a.depth<=this.depth)return;const l=new jc(a,this.editor,s,s?t:null);s&&(l.actualDepth=this.depth+1),e.push(new jc(a,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==t[l])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>t[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const FQ=`.ProseMirror {
|
|
101
|
-
position: relative;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.ProseMirror {
|
|
105
|
-
word-wrap: break-word;
|
|
106
|
-
white-space: pre-wrap;
|
|
107
|
-
white-space: break-spaces;
|
|
108
|
-
-webkit-font-variant-ligatures: none;
|
|
109
|
-
font-variant-ligatures: none;
|
|
110
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.ProseMirror [contenteditable="false"] {
|
|
114
|
-
white-space: normal;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
118
|
-
white-space: pre-wrap;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.ProseMirror pre {
|
|
122
|
-
white-space: pre-wrap;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
img.ProseMirror-separator {
|
|
126
|
-
display: inline !important;
|
|
127
|
-
border: none !important;
|
|
128
|
-
margin: 0 !important;
|
|
129
|
-
width: 0 !important;
|
|
130
|
-
height: 0 !important;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.ProseMirror-gapcursor {
|
|
134
|
-
display: none;
|
|
135
|
-
pointer-events: none;
|
|
136
|
-
position: absolute;
|
|
137
|
-
margin: 0;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.ProseMirror-gapcursor:after {
|
|
141
|
-
content: "";
|
|
142
|
-
display: block;
|
|
143
|
-
position: absolute;
|
|
144
|
-
top: -2px;
|
|
145
|
-
width: 20px;
|
|
146
|
-
border-top: 1px solid black;
|
|
147
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@keyframes ProseMirror-cursor-blink {
|
|
151
|
-
to {
|
|
152
|
-
visibility: hidden;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.ProseMirror-hideselection *::selection {
|
|
157
|
-
background: transparent;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
161
|
-
background: transparent;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.ProseMirror-hideselection * {
|
|
165
|
-
caret-color: transparent;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
169
|
-
display: block;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
173
|
-
opacity: 0
|
|
174
|
-
}`;function zQ(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}let $Q=class extends VZ{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=zQ(FQ,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=j5(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(a=>!a.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[OQ,oJ.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),MQ,DQ,jQ,NQ,AQ,LQ].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Fc(s,this)}createCommandManager(){this.commandManager=new j0({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=tk(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),t=tk(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=$5(t,this.options.autofocus);this.view=new gZ(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Pd.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return W5(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return lQ(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return N0(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
175
|
-
|
|
176
|
-
`,textSerializers:r={}}=e||{};return K5(this.state.doc,{blockSeparator:t,textSerializers:{...uE(this.schema),...r}})}get isEmpty(){return pE(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new jc(t,this)}get $doc(){return this.$pos(0)}};function tu(n){return new F0({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ft(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=t.from+a.indexOf(o),u=c+o.length;if(fE(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>c).length)return null;u<t.to&&i.delete(u,t.to),c>t.from&&i.delete(t.from+l,c);const p=t.from+l+o.length;i.addMark(t.from+l,p,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function BQ(n){return new F0({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ft(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let a=t.to;const l=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>a?u=a:a=u+r[1].length;const h=r[0][r[0].length-1];i.insertText(h,o+r[0].length-1),i.replaceWith(u,a,l)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()}})}function rk(n){return new F0({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=ft(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function pp(n){return new F0({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=ft(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&qI(l,n.type,i);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:m}=n.editor.extensionManager,S=p||h.$to.parentOffset&&h.$from.marks();if(S){const x=S.filter(v=>m.includes(v.type.name));o.ensureMarks(x)}}if(n.keepAttributes){const h=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,i).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&tc(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)}})}let ao=class sk{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new sk(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>z0(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new sk(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ft(Fe(t,"addOptions",{name:t.name})),t.storage=ft(Fe(t,"addStorage",{name:t.name,options:t.options})),t}};function Wl(n){return new eJ({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=ft(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const u=l.search(/\S/),h=t.from+l.indexOf(a),p=h+a.length;if(fE(t.from,t.to,e.doc).filter(S=>S.mark.type.excluded.find(v=>v===n.type&&v!==S.mark.type)).filter(S=>S.to>h).length)return null;p<t.to&&o.delete(p,t.to),h>t.from&&o.delete(t.from+u,h),c=t.from+u+a.length,o.addMark(t.from+u,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function gE(n,e,t){const{tipTapConfig:r,addFontsFromNode:s}=n.getTextOptions();Je(r,"textOptions.tipTapConfig must be set to use rich text"),Je(s,"textOptions.addFontsFromNode must be set to use rich text");const i=U0(r.extensions??[]),o=Ji.fromJSON(i,e),a=new Set;function l(u){a.add(u)}function c(u,h){h=s(u,h,l);for(const p of u.children)c(p,h)}return c(o,t),Array.from(a)}const UQ=(n,e)=>e.some(t=>n instanceof t);let WD,VD;function HQ(){return WD||(WD=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function KQ(){return VD||(VD=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const V5=new WeakMap,ik=new WeakMap,q5=new WeakMap,tC=new WeakMap,mE=new WeakMap;function WQ(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",i),n.removeEventListener("error",o)},i=()=>{t(Aa(n.result)),s()},o=()=>{r(n.error),s()};n.addEventListener("success",i),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&V5.set(t,n)}).catch(()=>{}),mE.set(e,n),e}function VQ(n){if(ik.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",o),n.removeEventListener("abort",o)},i=()=>{t(),s()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",i),n.addEventListener("error",o),n.addEventListener("abort",o)});ik.set(n,e)}let ok={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return ik.get(n);if(e==="objectStoreNames")return n.objectStoreNames||q5.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Aa(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function qQ(n){ok=n(ok)}function GQ(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(nC(this),e,...t);return q5.set(r,e.sort?e.sort():[e]),Aa(r)}:KQ().includes(n)?function(...e){return n.apply(nC(this),e),Aa(V5.get(this))}:function(...e){return Aa(n.apply(nC(this),e))}}function YQ(n){return typeof n=="function"?GQ(n):(n instanceof IDBTransaction&&VQ(n),UQ(n,HQ())?new Proxy(n,ok):n)}function Aa(n){if(n instanceof IDBRequest)return WQ(n);if(tC.has(n))return tC.get(n);const e=YQ(n);return e!==n&&(tC.set(n,e),mE.set(e,n)),e}const nC=n=>mE.get(n);function G5(n,e,{blocked:t,upgrade:r,blocking:s,terminated:i}={}){const o=indexedDB.open(n,e),a=Aa(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Aa(o.result),l.oldVersion,l.newVersion,Aa(o.transaction),l)}),t&&o.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),a.then(l=>{i&&l.addEventListener("close",()=>i()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}function Y5(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",r=>e(r.oldVersion,r)),Aa(t).then(()=>{})}const XQ=["get","getKey","getAll","getAllKeys","count"],ZQ=["put","add","delete","clear"],rC=new Map;function qD(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(rC.get(e))return rC.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=ZQ.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||XQ.includes(t)))return;const i=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[t](...a),s&&l.done]))[0]};return rC.set(e,i),i}qQ(n=>({...n,get:(e,t,r)=>qD(e,t)||n.get(e,t,r),has:(e,t)=>!!qD(e,t)||n.has(e,t)}));const JQ="TLDRAW_DOCUMENT_v2",QQ="TLDRAW_ASSET_STORE_v1",X5="TLDRAW_DB_NAME_INDEX_v2",ht={Records:"records",Schema:"schema",SessionState:"session_state",Assets:"assets"};async function Z5(n){const e=JQ+n;return tee(e),await G5(e,4,{upgrade(t){t.objectStoreNames.contains(ht.Records)||t.createObjectStore(ht.Records),t.objectStoreNames.contains(ht.Schema)||t.createObjectStore(ht.Schema),t.objectStoreNames.contains(ht.SessionState)||t.createObjectStore(ht.SessionState),t.objectStoreNames.contains(ht.Assets)||t.createObjectStore(ht.Assets)}})}async function eee(n){const e=window.indexedDB.databases?(await window.indexedDB.databases()).map(p=>p.name):yE(),t=QQ+n;if(!e.find(p=>p===t))return;const s=await G5(t,1,{upgrade(p){p.objectStoreNames.contains("assets")||p.createObjectStore("assets")}});if(!s.objectStoreNames.contains("assets"))return;const i=s.transaction(["assets"],"readonly"),o=i.objectStore("assets"),a=await o.getAllKeys(),l=await Promise.all(a.map(async p=>[p,await o.get(p)]));await i.done;const c=await Z5(n),u=c.transaction([ht.Assets],"readwrite"),h=u.objectStore(ht.Assets);for(const[p,m]of l)h.put(m,p);await u.done,s.close(),c.close(),await Y5(t)}const ep=class ep{constructor(e){R(this,"getDbPromise");R(this,"isClosed",!1);R(this,"pendingTransactionSet",new Set);ep.connectedInstances.add(this),this.getDbPromise=(async()=>(await eee(e),await Z5(e)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(np)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),ep.connectedInstances.delete(this))}tx(e,t,r){const s=(async()=>{Je(!this.isClosed,"db is closed");const o=(await this.getDb()).transaction(t,e),a=o.done.catch(l=>{if(!this.isClosed)throw l});try{return await r(o)}finally{this.isClosed?o.abort():await a}})();return this.pendingTransactionSet.add(s),s.finally(()=>this.pendingTransactionSet.delete(s)),s}async load({sessionId:e}={}){return await this.tx("readonly",[ht.Records,ht.Schema,ht.SessionState],async t=>{var l,c;const r=t.objectStore(ht.Records),s=t.objectStore(ht.Schema),i=t.objectStore(ht.SessionState);let o=e?(l=await i.get(e))==null?void 0:l.snapshot:null;return o||(o=(c=(await i.getAll()).sort((h,p)=>h.updatedAt-p.updatedAt).pop())==null?void 0:c.snapshot),{records:await r.getAll(),schema:await s.get(ht.Schema),sessionStateSnapshot:o}})}async storeChanges({schema:e,changes:t,sessionId:r,sessionStateSnapshot:s}){await this.tx("readwrite",[ht.Records,ht.Schema,ht.SessionState],async i=>{const o=i.objectStore(ht.Records),a=i.objectStore(ht.Schema),l=i.objectStore(ht.SessionState);for(const[c,u]of Object.entries(t.added))await o.put(u,c);for(const[c,u]of Object.values(t.updated))await o.put(u,u.id);for(const c of Object.keys(t.removed))await o.delete(c);a.put(e.serialize(),ht.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:t,sessionId:r,sessionStateSnapshot:s}){await this.tx("readwrite",[ht.Records,ht.Schema,ht.SessionState],async i=>{const o=i.objectStore(ht.Records),a=i.objectStore(ht.Schema),l=i.objectStore(ht.SessionState);await o.clear();for(const[c,u]of Object.entries(t))await o.put(u,c);a.put(e.serialize(),ht.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",[ht.SessionState],async e=>{const t=e.objectStore(ht.SessionState),r=(await t.getAll()).sort((i,o)=>i.updatedAt-o.updatedAt);if(r.length<10){await e.done;return}const s=r.slice(0,r.length-10);for(const{id:i}of s)await t.delete(i)})}async getAsset(e){return await this.tx("readonly",[ht.Assets],async t=>await t.objectStore(ht.Assets).get(e))}async storeAsset(e,t){await this.tx("readwrite",[ht.Assets],async r=>{await r.objectStore(ht.Assets).put(t,e)})}async removeAssets(e){await this.tx("readwrite",[ht.Assets],async t=>{const r=t.objectStore(ht.Assets);for(const s of e)await r.delete(s)})}};R(ep,"connectedInstances",new Set);let dS=ep;function yE(){const n=JSON.parse(EI(X5)||"[]")??[];return Array.isArray(n)?n:[]}function tee(n){const e=new Set(yE());e.add(n),_I(X5,JSON.stringify([...e]))}/*!
|
|
177
|
-
* This file was lovingly and delicately extracted from Immutable.js
|
|
178
|
-
* MIT License: https://github.com/immutable-js/immutable-js/blob/main/LICENSE
|
|
179
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
180
|
-
*/function SE(n){return n>>>1&1073741824|n&3221225471}const nee=Object.prototype.valueOf;function nu(n){if(n==null)return GD(n);if(typeof n.hashCode=="function")return SE(n.hashCode(n));const e=aee(n);if(e==null)return GD(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return ree(e);case"string":return e.length>lee?see(e):ak(e);case"object":case"function":return oee(e);case"symbol":return iee(e);default:if(typeof e.toString=="function")return ak(e.toString());throw new Error("Value type "+typeof e+" cannot be hashed.")}}function GD(n){return n===null?1108378658:1108378659}function ree(n){if(n!==n||n===1/0)return 0;let e=n|0;for(e!==n&&(e^=n*4294967295);n>4294967295;)n/=4294967295,e^=n;return SE(e)}function see(n){let e=oC[n];return e===void 0&&(e=ak(n),iC===cee&&(iC=0,oC={}),iC++,oC[n]=e),e}function ak(n){let e=0;for(let t=0;t<n.length;t++)e=31*e+n.charCodeAt(t)|0;return SE(e)}function iee(n){let e=XD[n];return e!==void 0||(e=J5(),XD[n]=e),e}function oee(n){let e=YD.get(n);return e!==void 0||(e=J5(),YD.set(n,e)),e}function aee(n){return n.valueOf!==nee&&typeof n.valueOf=="function"?n.valueOf(n):n}function J5(){const n=++sC;return sC&1073741824&&(sC=0),n}const YD=new WeakMap,XD=Object.create(null);let sC=0;const lee=16,cee=255;let iC=0,oC={};const Wd=5,Up=1<<Wd,Vd=Up-1,La={};function ZD(){return{value:!1}}function Gi(n){n&&(n.value=!0)}function vE(n,e){e=e||0;const t=Math.max(0,n.length-e),r=new Array(t);for(let s=0;s<t;s++)r[s]=n[s+e];return r}const qd=Object.is;class Q5{}class xE{constructor(e){R(this,"_root");R(this,"size");R(this,"__ownerID");R(this,"__hash");R(this,"__altered");return e==null?Ad():e instanceof xE?e:Ad().withMutations(t=>{for(const[r,s]of e)t.set(r,s)})}get(e,t){return this._root?this._root.get(0,void 0,e,t):t}set(e,t){return ej(this,e,t)}delete(e){return ej(this,e,La)}deleteAll(e){return this.withMutations(t=>{for(const r of e)t.delete(r)})}__ensureOwner(e){return e===this.__ownerID?this:e?CE(this.size,this._root,e,this.__hash):this.size===0?Ad():(this.__ownerID=e,this.__altered=!1,this)}withMutations(e){const t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}wasAltered(){return this.__altered}asMutable(){return this.__ownerID?this:this.__ensureOwner(new Q5)}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}entries(){return new aC(this,uee,!1)}keys(){return new aC(this,e4,!1)}values(){return new aC(this,t4,!1)}}class wE{constructor(e,t){this.ownerID=e,this.entries=t}get(e,t,r,s){const i=this.entries;for(let o=0,a=i.length;o<a;o++)if(qd(r,i[o][0]))return i[o][1];return s}update(e,t,r,s,i,o,a){const l=i===La,c=this.entries;let u=0;const h=c.length;for(;u<h&&!qd(s,c[u][0]);u++);const p=u<h;if(p?c[u][1]===i:l)return this;if(Gi(a),(l||!p)&&Gi(o),l&&c.length===1)return;if(!p&&!l&&c.length>=See)return fee(e,c,s,i);const m=e&&e===this.ownerID,S=m?c:vE(c);return p?l?u===h-1?S.pop():S[u]=S.pop():S[u]=[s,i]:S.push([s,i]),m?(this.entries=S,this):new wE(e,S)}}class H0{constructor(e,t,r){this.ownerID=e,this.bitmap=t,this.nodes=r}get(e,t,r,s){t===void 0&&(t=nu(r));const i=1<<((e===0?t:t>>>e)&Vd),o=this.bitmap;return(o&i)===0?s:this.nodes[nj(o&i-1)].get(e+Wd,t,r,s)}update(e,t,r,s,i,o,a){r===void 0&&(r=nu(s));const l=(t===0?r:r>>>t)&Vd,c=1<<l,u=this.bitmap,h=(u&c)!==0;if(!h&&i===La)return this;const p=nj(u&c-1),m=this.nodes,S=h?m[p]:void 0,x=PE(S,e,t+Wd,r,s,i,o,a);if(x===S)return this;if(!h&&x&&m.length>=vee)return gee(e,m,u,l,x);if(h&&!x&&m.length===2&&tj(m[p^1]))return m[p^1];if(h&&x&&m.length===1&&tj(x))return x;const v=e&&e===this.ownerID,w=h?x?u:u^c:u|c,C=h?x?n4(m,p,x,v):yee(m,p,v):mee(m,p,x,v);return v?(this.bitmap=w,this.nodes=C,this):new H0(e,w,C)}}class bE{constructor(e,t,r){this.ownerID=e,this.count=t,this.nodes=r}get(e,t,r,s){t===void 0&&(t=nu(r));const i=(e===0?t:t>>>e)&Vd,o=this.nodes[i];return o?o.get(e+Wd,t,r,s):s}update(e,t,r,s,i,o,a){r===void 0&&(r=nu(s));const l=(t===0?r:r>>>t)&Vd,c=i===La,u=this.nodes,h=u[l];if(c&&!h)return this;const p=PE(h,e,t+Wd,r,s,i,o,a);if(p===h)return this;let m=this.count;if(!h)m++;else if(!p&&(m--,m<xee))return pee(e,u,m,l);const S=e&&e===this.ownerID,x=n4(u,l,p,S);return S?(this.count=m,this.nodes=x,this):new bE(e,m,x)}}class K0{constructor(e,t,r){this.ownerID=e,this.keyHash=t,this.entries=r}get(e,t,r,s){const i=this.entries;for(let o=0,a=i.length;o<a;o++)if(qd(r,i[o][0]))return i[o][1];return s}update(e,t,r,s,i,o,a){r===void 0&&(r=nu(s));const l=i===La;if(r!==this.keyHash)return l?this:(Gi(a),Gi(o),kE(this,e,t,r,[s,i]));const c=this.entries;let u=0;const h=c.length;for(;u<h&&!qd(s,c[u][0]);u++);const p=u<h;if(p?c[u][1]===i:l)return this;if(Gi(a),(l||!p)&&Gi(o),l&&h===2)return new Su(e,this.keyHash,c[u^1]);const m=e&&e===this.ownerID,S=m?c:vE(c);return p?l?u===h-1?S.pop():S[u]=S.pop():S[u]=[s,i]:S.push([s,i]),m?(this.entries=S,this):new K0(e,this.keyHash,S)}}class Su{constructor(e,t,r){this.ownerID=e,this.keyHash=t,this.entry=r}get(e,t,r,s){return qd(r,this.entry[0])?this.entry[1]:s}update(e,t,r,s,i,o,a){const l=i===La,c=qd(s,this.entry[0]);if(c?i===this.entry[1]:l)return this;if(Gi(a),l){Gi(o);return}return c?e&&e===this.ownerID?(this.entry[1]=i,this):new Su(e,this.keyHash,[s,i]):(Gi(o),kE(this,e,t,nu(s),[s,i]))}}class aC{constructor(e,t,r){R(this,"_stack");this._type=t,this._reverse=r,this._stack=e._root&&JD(e._root)}[Symbol.iterator](){return this}next(){const e=this._type;let t=this._stack;for(;t;){const r=t.node,s=t.index++;let i;if(r.entry){if(s===0)return lC(e,r.entry)}else if("entries"in r&&r.entries){if(i=r.entries.length-1,s<=i)return lC(e,r.entries[this._reverse?i-s:s])}else if(i=r.nodes.length-1,s<=i){const o=r.nodes[this._reverse?i-s:s];if(o){if(o.entry)return lC(e,o.entry);t=this._stack=JD(o,t)}continue}t=this._stack=this._stack.__prev}return hee()}}function lC(n,e){return dee(n,e[0],e[1])}function JD(n,e){return{node:n,index:0,__prev:e}}const e4=0,t4=1,uee=2;function dee(n,e,t,r){const s=n===e4?e:n===t4?t:[e,t];return r?r.value=s:r={value:s,done:!1},r}function hee(){return{value:void 0,done:!0}}function CE(n,e,t,r){const s=Object.create(xE.prototype);return s.size=n,s._root=e,s.__ownerID=t,s.__hash=r,s.__altered=!1,s}let QD;function Ad(){return QD||(QD=CE(0))}function ej(n,e,t){let r,s;if(n._root){const i=ZD(),o=ZD();if(r=PE(n._root,n.__ownerID,0,void 0,e,t,i,o),!o.value)return n;s=n.size+(i.value?t===La?-1:1:0)}else{if(t===La)return n;s=1,r=new wE(n.__ownerID,[[e,t]])}return n.__ownerID?(n.size=s,n._root=r,n.__hash=void 0,n.__altered=!0,n):r?CE(s,r):Ad()}function PE(n,e,t,r,s,i,o,a){return n?n.update(e,t,r,s,i,o,a):i===La?n:(Gi(a),Gi(o),new Su(e,r,[s,i]))}function tj(n){return n.constructor===Su||n.constructor===K0}function kE(n,e,t,r,s){if(n.keyHash===r)return new K0(e,r,[n.entry,s]);const i=(t===0?n.keyHash:n.keyHash>>>t)&Vd,o=(t===0?r:r>>>t)&Vd;let a;const l=i===o?[kE(n,e,t+Wd,r,s)]:(a=new Su(e,r,s),i<o?[n,a]:[a,n]);return new H0(e,1<<i|1<<o,l)}function fee(n,e,t,r){n||(n=new Q5);let s=new Su(n,nu(t),[t,r]);for(let i=0;i<e.length;i++){const o=e[i];s=s.update(n,0,void 0,o[0],o[1])}return s}function pee(n,e,t,r){let s=0,i=0;const o=new Array(t);for(let a=0,l=1,c=e.length;a<c;a++,l<<=1){const u=e[a];u!==void 0&&a!==r&&(s|=l,o[i++]=u)}return new H0(n,s,o)}function gee(n,e,t,r,s){let i=0;const o=new Array(Up);for(let a=0;t!==0;a++,t>>>=1)o[a]=t&1?e[i++]:void 0;return o[r]=s,new bE(n,i+1,o)}function nj(n){return n-=n>>1&1431655765,n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n+=n>>8,n+=n>>16,n&127}function n4(n,e,t,r){const s=r?n:vE(n);return s[e]=t,s}function mee(n,e,t,r){const s=n.length+1;if(r&&e+1===s)return n[e]=t,n;const i=new Array(s);let o=0;for(let a=0;a<s;a++)a===e?(i[a]=t,o=-1):i[a]=n[a+o];return i}function yee(n,e,t){const r=n.length-1;if(t&&e===r)return n.pop(),n;const s=new Array(r);let i=0;for(let o=0;o<r;o++)o===e&&(i=1),s[o]=n[o+i];return s}const See=Up/4,vee=Up/2,xee=Up/4;var BN,UN;class lk{constructor(e,t){R(this,"atoms");R(this,BN,"AtomMap");this.name=e;let r=Ad();t&&(r=r.withMutations(s=>{for(const[i,o]of t)s.set(i,Sn(`${e}:${String(i)}`,o))})),this.atoms=Sn(`${e}:atoms`,r)}getAtom(e){const t=this.atoms.__unsafe__getWithoutCapture().get(e);if(!t){this.atoms.get();return}return t}get(e){var r;const t=(r=this.getAtom(e))==null?void 0:r.get();return Je(t!==xr),t}__unsafe__getWithoutCapture(e){const t=this.atoms.__unsafe__getWithoutCapture().get(e);if(!t)return;const r=t.__unsafe__getWithoutCapture();return Je(r!==xr),r}has(e){const t=this.getAtom(e);return t?t.get()!==xr:!1}__unsafe__hasWithoutCapture(e){const t=this.atoms.__unsafe__getWithoutCapture().get(e);return t?(Je(t.__unsafe__getWithoutCapture()!==xr),!0):!1}set(e,t){const r=this.atoms.__unsafe__getWithoutCapture().get(e);return r?r.set(t):this.atoms.update(s=>s.set(e,Sn(`${this.name}:${String(e)}`,t))),this}update(e,t){const r=this.atoms.__unsafe__getWithoutCapture().get(e);if(!r)throw new Error(`AtomMap: key ${e} not found`);const s=r.__unsafe__getWithoutCapture();Je(s!==xr),r.set(t(s))}delete(e){const t=this.atoms.__unsafe__getWithoutCapture().get(e);return t?(Vs(()=>{t.set(xr),this.atoms.update(r=>r.delete(e))}),!0):!1}deleteMany(e){return Vs(()=>{const t=[],r=this.atoms.get().withMutations(s=>{for(const i of e){const o=s.get(i);if(!o)continue;const a=o.get();Je(a!==xr),t.push([i,a]),s.delete(i),o.set(xr)}});return t.length&&this.atoms.set(r),t})}clear(){return Vs(()=>{for(const e of this.atoms.__unsafe__getWithoutCapture().values())e.set(xr);this.atoms.set(Ad())})}*entries(){for(const[e,t]of this.atoms.get()){const r=t.get();Je(r!==xr),yield[e,r]}}*keys(){for(const e of this.atoms.get().keys())yield e}*values(){for(const e of this.atoms.get().values()){const t=e.get();Je(t!==xr),yield t}}get size(){return this.atoms.get().size}forEach(e,t){for(const[r,s]of this.entries())e.call(t,s,r,this)}[(UN=Symbol.iterator,BN=Symbol.toStringTag,UN)](){return this.entries()}}class fy{constructor(e){R(this,"nextValue");R(this,"diff");this.previousValue=e}get(){var r,s,i,o;const e=((s=(r=this.diff)==null?void 0:r.removed)==null?void 0:s.size)??0,t=((o=(i=this.diff)==null?void 0:i.added)==null?void 0:o.size)??0;if(!(e===0&&t===0))return{value:this.nextValue,diff:this.diff}}_add(e,t){var r,s;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(e),this.diff??(this.diff={}),t?(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,i,o;const t=this.previousValue.has(e);if(t)return((i=(s=this.diff)==null?void 0:s.removed)==null?void 0:i.has(e))?this._add(e,t):void 0;(o=this.nextValue)!=null&&o.has(e)||this._add(e,t)}_remove(e,t){var r,s;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(e),this.diff??(this.diff={}),t?((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,i,o,a;const t=this.previousValue.has(e);if(!t)return((i=(s=this.diff)==null?void 0:s.added)==null?void 0:i.has(e))?this._remove(e,t):void 0;(a=(o=this.diff)==null?void 0:o.removed)!=null&&a.has(e)||this._remove(e,t)}}class W0{constructor(e,t){R(this,"createDefaultProperties");R(this,"validator");R(this,"ephemeralKeys");R(this,"ephemeralKeySet");R(this,"scope");this.typeName=e,this.createDefaultProperties=t.createDefaultProperties,this.validator=t.validator??{validate:s=>s},this.scope=t.scope??"document",this.ephemeralKeys=t.ephemeralKeys;const r=new Set;if(t.ephemeralKeys)for(const[s,i]of Is(t.ephemeralKeys))i&&r.add(s);this.ephemeralKeySet=r}create(e){const t={...this.createDefaultProperties(),id:this.createId()};for(const[r,s]of Object.entries(e))s!==void 0&&(t[r]=s);return t.typeName=this.typeName,t}clone(e){return{...Xt(e),id:this.createId()}}createId(e){return this.typeName+":"+(e??_t())}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 t=0;t<this.typeName.length;t++)if(e[t]!==this.typeName[t])return!1;return e[this.typeName.length]===":"}withDefaultProperties(e){return new W0(this.typeName,{createDefaultProperties:e,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(e,t){return t&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(t,e):this.validator.validate(e)}}function Go(n,e){return new W0(n,{createDefaultProperties:()=>({}),validator:e.validator,scope:e.scope,ephemeralKeys:e.ephemeralKeys})}function hS(){return{added:{},updated:{},removed:{}}}function ck(n){const e={added:n.removed,removed:n.added,updated:{}};for(const[t,r]of Object.values(n.updated))e.updated[t.id]=[r,t];return e}function r4(n){return Object.keys(n.added).length===0&&Object.keys(n.updated).length===0&&Object.keys(n.removed).length===0}function IE(n){const e={added:{},removed:{},updated:{}};return Bf(e,n),e}function Bf(n,e){for(const t of e){for(const[r,s]of Is(t.added))if(n.removed[r]){const i=n.removed[r];delete n.removed[r],i!==s&&(n.updated[r]=[i,s])}else n.added[r]=s;for(const[r,[s,i]]of Is(t.updated)){if(n.added[r]){n.added[r]=i,delete n.updated[r],delete n.removed[r];continue}if(n.updated[r]){n.updated[r]=[n.updated[r][0],i],delete n.removed[r];continue}n.updated[r]=t.updated[r],delete n.removed[r]}for(const[r,s]of Is(t.removed))n.added[r]?delete n.added[r]:n.updated[r]?(n.removed[r]=n.updated[r][0],delete n.updated[r]):n.removed[r]=s}}var kf={exports:{}};kf.exports;var rj;function wee(){return rj||(rj=1,function(n,e){var t=200,r="__lodash_hash_undefined__",s=1,i=2,o=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Function]",S="[object GeneratorFunction]",x="[object Map]",v="[object Number]",w="[object Null]",C="[object Object]",_="[object Promise]",E="[object Proxy]",T="[object RegExp]",A="[object Set]",O="[object String]",D="[object Symbol]",$="[object Undefined]",H="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",L="[object Float32Array]",N="[object Float64Array]",U="[object Int8Array]",Y="[object Int16Array]",W="[object Int32Array]",z="[object Uint8Array]",V="[object Uint8ClampedArray]",ee="[object Uint16Array]",B="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,me=/^\[object .+?Constructor\]$/,Pe=/^(?:0|[1-9]\d*)$/,ue={};ue[L]=ue[N]=ue[U]=ue[Y]=ue[W]=ue[z]=ue[V]=ue[ee]=ue[B]=!0,ue[a]=ue[l]=ue[G]=ue[u]=ue[J]=ue[h]=ue[p]=ue[m]=ue[x]=ue[v]=ue[C]=ue[T]=ue[A]=ue[O]=ue[H]=!1;var Oe=typeof Ps=="object"&&Ps&&Ps.Object===Object&&Ps,Ne=typeof self=="object"&&self&&self.Object===Object&&self,be=Oe||Ne||Function("return this")(),Ee=e&&!e.nodeType&&e,Ke=Ee&&!0&&n&&!n.nodeType&&n,Lt=Ke&&Ke.exports===Ee,Jt=Lt&&Oe.process,Et=function(){try{return Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),Tt=Et&&Et.isTypedArray;function nn(F,Z){for(var de=-1,Ae=F==null?0:F.length,Mt=0,et=[];++de<Ae;){var $t=F[de];Z($t,de,F)&&(et[Mt++]=$t)}return et}function In(F,Z){for(var de=-1,Ae=Z.length,Mt=F.length;++de<Ae;)F[Mt+de]=Z[de];return F}function rs(F,Z){for(var de=-1,Ae=F==null?0:F.length;++de<Ae;)if(Z(F[de],de,F))return!0;return!1}function ss(F,Z){for(var de=-1,Ae=Array(F);++de<F;)Ae[de]=Z(de);return Ae}function is(F){return function(Z){return F(Z)}}function as(F,Z){return F.has(Z)}function ri(F,Z){return F==null?void 0:F[Z]}function lc(F){var Z=-1,de=Array(F.size);return F.forEach(function(Ae,Mt){de[++Z]=[Mt,Ae]}),de}function Cu(F,Z){return function(de){return F(Z(de))}}function Pu(F){var Z=-1,de=Array(F.size);return F.forEach(function(Ae){de[++Z]=Ae}),de}var ku=Array.prototype,Iu=Function.prototype,ho=Object.prototype,Oi=be["__core-js_shared__"],cc=Iu.toString,ae=ho.hasOwnProperty,Ce=function(){var F=/[^.]+$/.exec(Oi&&Oi.keys&&Oi.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),Ye=ho.toString,At=RegExp("^"+cc.call(ae).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),si=Lt?be.Buffer:void 0,ls=be.Symbol,Qo=be.Uint8Array,Os=ho.propertyIsEnumerable,Rs=ku.splice,cs=ls?ls.toStringTag:void 0,Ds=Object.getOwnPropertySymbols,us=si?si.isBuffer:void 0,Ri=Cu(Object.keys,Object),Eu=na(be,"DataView"),Ja=na(be,"Map"),_u=na(be,"Promise"),Tu=na(be,"Set"),Mu=na(be,"WeakMap"),ea=na(Object,"create"),gg=hr(Eu),uc=hr(Ja),vh=hr(_u),dc=hr(Tu),Uv=hr(Mu),Qa=ls?ls.prototype:void 0,el=Qa?Qa.valueOf:void 0;function ii(F){var Z=-1,de=F==null?0:F.length;for(this.clear();++Z<de;){var Ae=F[Z];this.set(Ae[0],Ae[1])}}function xh(){this.__data__=ea?ea(null):{},this.size=0}function Hv(F){var Z=this.has(F)&&delete this.__data__[F];return this.size-=Z?1:0,Z}function Kv(F){var Z=this.__data__;if(ea){var de=Z[F];return de===r?void 0:de}return ae.call(Z,F)?Z[F]:void 0}function Wv(F){var Z=this.__data__;return ea?Z[F]!==void 0:ae.call(Z,F)}function ta(F,Z){var de=this.__data__;return this.size+=this.has(F)?0:1,de[F]=ea&&Z===void 0?r:Z,this}ii.prototype.clear=xh,ii.prototype.delete=Hv,ii.prototype.get=Kv,ii.prototype.has=Wv,ii.prototype.set=ta;function oi(F){var Z=-1,de=F==null?0:F.length;for(this.clear();++Z<de;){var Ae=F[Z];this.set(Ae[0],Ae[1])}}function mg(){this.__data__=[],this.size=0}function Vv(F){var Z=this.__data__,de=Ru(Z,F);if(de<0)return!1;var Ae=Z.length-1;return de==Ae?Z.pop():Rs.call(Z,de,1),--this.size,!0}function yg(F){var Z=this.__data__,de=Ru(Z,F);return de<0?void 0:Z[de][1]}function Sg(F){return Ru(this.__data__,F)>-1}function vg(F,Z){var de=this.__data__,Ae=Ru(de,F);return Ae<0?(++this.size,de.push([F,Z])):de[Ae][1]=Z,this}oi.prototype.clear=mg,oi.prototype.delete=Vv,oi.prototype.get=yg,oi.prototype.has=Sg,oi.prototype.set=vg;function fo(F){var Z=-1,de=F==null?0:F.length;for(this.clear();++Z<de;){var Ae=F[Z];this.set(Ae[0],Ae[1])}}function qv(){this.size=0,this.__data__={hash:new ii,map:new(Ja||oi),string:new ii}}function Gv(F){var Z=xt(this,F).delete(F);return this.size-=Z?1:0,Z}function rn(F){return xt(this,F).get(F)}function Yv(F){return xt(this,F).has(F)}function wh(F,Z){var de=xt(this,F),Ae=de.size;return de.set(F,Z),this.size+=de.size==Ae?0:1,this}fo.prototype.clear=qv,fo.prototype.delete=Gv,fo.prototype.get=rn,fo.prototype.has=Yv,fo.prototype.set=wh;function hc(F){var Z=-1,de=F==null?0:F.length;for(this.__data__=new fo;++Z<de;)this.add(F[Z])}function Au(F){return this.__data__.set(F,r),this}function Xv(F){return this.__data__.has(F)}hc.prototype.add=hc.prototype.push=Au,hc.prototype.has=Xv;function Di(F){var Z=this.__data__=new oi(F);this.size=Z.size}function Ou(){this.__data__=new oi,this.size=0}function ai(F){var Z=this.__data__,de=Z.delete(F);return this.size=Z.size,de}function Zv(F){return this.__data__.get(F)}function js(F){return this.__data__.has(F)}function Jv(F,Z){var de=this.__data__;if(de instanceof oi){var Ae=de.__data__;if(!Ja||Ae.length<t-1)return Ae.push([F,Z]),this.size=++de.size,this;de=this.__data__=new fo(Ae)}return de.set(F,Z),this.size=de.size,this}Di.prototype.clear=Ou,Di.prototype.delete=ai,Di.prototype.get=Zv,Di.prototype.has=js,Di.prototype.set=Jv;function Qv(F,Z){var de=mo(F),Ae=!de&&gc(F),Mt=!de&&!Ae&&kh(F),et=!de&&!Ae&&!Mt&&Eh(F),$t=de||Ae||Mt||et,vn=$t?ss(F.length,String):[],Bt=vn.length;for(var Nt in F)ae.call(F,Nt)&&!($t&&(Nt=="length"||Mt&&(Nt=="offset"||Nt=="parent")||et&&(Nt=="buffer"||Nt=="byteLength"||Nt=="byteOffset")||bg(Nt,Bt)))&&vn.push(Nt);return vn}function Ru(F,Z){for(var de=F.length;de--;)if(Li(F[de][0],Z))return de;return-1}function Du(F,Z,de){var Ae=Z(F);return mo(F)?Ae:In(Ae,de(F))}function po(F){return F==null?F===void 0?$:w:cs&&cs in Object(F)?wg(F):go(F)}function tl(F){return So(F)&&po(F)==a}function fc(F,Z,de,Ae,Mt){return F===Z?!0:F==null||Z==null||!So(F)&&!So(Z)?F!==F&&Z!==Z:ex(F,Z,de,Ae,fc,Mt)}function ex(F,Z,de,Ae,Mt,et){var $t=mo(F),vn=mo(Z),Bt=$t?l:ji(F),Nt=vn?l:ji(Z);Bt=Bt==a?C:Bt,Nt=Nt==a?C:Nt;var Nn=Bt==C,ds=Nt==C,xn=Bt==Nt;if(xn&&kh(F)){if(!kh(Z))return!1;$t=!0,Nn=!1}if(xn&&!Nn)return et||(et=new Di),$t||Eh(F)?ju(F,Z,de,Ae,Mt,et):pc(F,Z,Bt,de,Ae,Mt,et);if(!(de&s)){var Xn=Nn&&ae.call(F,"__wrapped__"),Dr=ds&&ae.call(Z,"__wrapped__");if(Xn||Dr){var hn=Xn?F.value():F,fr=Dr?Z.value():Z;return et||(et=new Di),Mt(hn,fr,de,Ae,et)}}return xn?(et||(et=new Di),nx(F,Z,de,Ae,Mt,et)):!1}function tx(F){if(!Ih(F)||Ph(F))return!1;var Z=nl(F)?At:me;return Z.test(hr(F))}function bh(F){return So(F)&&kg(F.length)&&!!ue[po(F)]}function xg(F){if(!Nu(F))return Ri(F);var Z=[];for(var de in Object(F))ae.call(F,de)&&de!="constructor"&&Z.push(de);return Z}function ju(F,Z,de,Ae,Mt,et){var $t=de&s,vn=F.length,Bt=Z.length;if(vn!=Bt&&!($t&&Bt>vn))return!1;var Nt=et.get(F);if(Nt&&et.get(Z))return Nt==Z;var Nn=-1,ds=!0,xn=de&i?new hc:void 0;for(et.set(F,Z),et.set(Z,F);++Nn<vn;){var Xn=F[Nn],Dr=Z[Nn];if(Ae)var hn=$t?Ae(Dr,Xn,Nn,Z,F,et):Ae(Xn,Dr,Nn,F,Z,et);if(hn!==void 0){if(hn)continue;ds=!1;break}if(xn){if(!rs(Z,function(fr,Ni){if(!as(xn,Ni)&&(Xn===fr||Mt(Xn,fr,de,Ae,et)))return xn.push(Ni)})){ds=!1;break}}else if(!(Xn===Dr||Mt(Xn,Dr,de,Ae,et))){ds=!1;break}}return et.delete(F),et.delete(Z),ds}function pc(F,Z,de,Ae,Mt,et,$t){switch(de){case J:if(F.byteLength!=Z.byteLength||F.byteOffset!=Z.byteOffset)return!1;F=F.buffer,Z=Z.buffer;case G:return!(F.byteLength!=Z.byteLength||!et(new Qo(F),new Qo(Z)));case u:case h:case v:return Li(+F,+Z);case p:return F.name==Z.name&&F.message==Z.message;case T:case O:return F==Z+"";case x:var vn=lc;case A:var Bt=Ae&s;if(vn||(vn=Pu),F.size!=Z.size&&!Bt)return!1;var Nt=$t.get(F);if(Nt)return Nt==Z;Ae|=i,$t.set(F,Z);var Nn=ju(vn(F),vn(Z),Ae,Mt,et,$t);return $t.delete(F),Nn;case D:if(el)return el.call(F)==el.call(Z)}return!1}function nx(F,Z,de,Ae,Mt,et){var $t=de&s,vn=Lu(F),Bt=vn.length,Nt=Lu(Z),Nn=Nt.length;if(Bt!=Nn&&!$t)return!1;for(var ds=Bt;ds--;){var xn=vn[ds];if(!($t?xn in Z:ae.call(Z,xn)))return!1}var Xn=et.get(F);if(Xn&&et.get(Z))return Xn==Z;var Dr=!0;et.set(F,Z),et.set(Z,F);for(var hn=$t;++ds<Bt;){xn=vn[ds];var fr=F[xn],Ni=Z[xn];if(Ae)var rl=$t?Ae(Ni,fr,xn,Z,F,et):Ae(fr,Ni,xn,F,Z,et);if(!(rl===void 0?fr===Ni||Mt(fr,Ni,de,Ae,et):rl)){Dr=!1;break}hn||(hn=xn=="constructor")}if(Dr&&!hn){var Fu=F.constructor,sl=Z.constructor;Fu!=sl&&"constructor"in F&&"constructor"in Z&&!(typeof Fu=="function"&&Fu instanceof Fu&&typeof sl=="function"&&sl instanceof sl)&&(Dr=!1)}return et.delete(F),et.delete(Z),Dr}function Lu(F){return Du(F,rx,Ch)}function xt(F,Z){var de=F.__data__;return Cg(Z)?de[typeof Z=="string"?"string":"hash"]:de.map}function na(F,Z){var de=ri(F,Z);return tx(de)?de:void 0}function wg(F){var Z=ae.call(F,cs),de=F[cs];try{F[cs]=void 0;var Ae=!0}catch{}var Mt=Ye.call(F);return Ae&&(Z?F[cs]=de:delete F[cs]),Mt}var Ch=Ds?function(F){return F==null?[]:(F=Object(F),nn(Ds(F),function(Z){return Os.call(F,Z)}))}:mc,ji=po;(Eu&&ji(new Eu(new ArrayBuffer(1)))!=J||Ja&&ji(new Ja)!=x||_u&&ji(_u.resolve())!=_||Tu&&ji(new Tu)!=A||Mu&&ji(new Mu)!=H)&&(ji=function(F){var Z=po(F),de=Z==C?F.constructor:void 0,Ae=de?hr(de):"";if(Ae)switch(Ae){case gg:return J;case uc:return x;case vh:return _;case dc:return A;case Uv:return H}return Z});function bg(F,Z){return Z=Z??o,!!Z&&(typeof F=="number"||Pe.test(F))&&F>-1&&F%1==0&&F<Z}function Cg(F){var Z=typeof F;return Z=="string"||Z=="number"||Z=="symbol"||Z=="boolean"?F!=="__proto__":F===null}function Ph(F){return!!Ce&&Ce in F}function Nu(F){var Z=F&&F.constructor,de=typeof Z=="function"&&Z.prototype||ho;return F===de}function go(F){return Ye.call(F)}function hr(F){if(F!=null){try{return cc.call(F)}catch{}try{return F+""}catch{}}return""}function Li(F,Z){return F===Z||F!==F&&Z!==Z}var gc=tl(function(){return arguments}())?tl:function(F){return So(F)&&ae.call(F,"callee")&&!Os.call(F,"callee")},mo=Array.isArray;function yo(F){return F!=null&&kg(F.length)&&!nl(F)}var kh=us||yc;function Pg(F,Z){return fc(F,Z)}function nl(F){if(!Ih(F))return!1;var Z=po(F);return Z==m||Z==S||Z==c||Z==E}function kg(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=o}function Ih(F){var Z=typeof F;return F!=null&&(Z=="object"||Z=="function")}function So(F){return F!=null&&typeof F=="object"}var Eh=Tt?is(Tt):bh;function rx(F){return yo(F)?Qv(F):xg(F)}function mc(){return[]}function yc(){return!1}n.exports=Pg}(kf,kf.exports)),kf.exports}var bee=wee();const ch=Ua(bee);function Cee(n){if(n.length===0)return new Set;const e=n[0],t=n.slice(1),r=new Set;for(const s of e)t.every(i=>i.has(s))&&r.add(s);return r}function Pee(n,e){const t={};for(const r of e)n.has(r)||(t.added??(t.added=new Set),t.added.add(r));for(const r of n)e.has(r)||(t.removed??(t.removed=new Set),t.removed.add(r));return t.added||t.removed?t:void 0}function sj(n,e){for(const[t,r]of Object.entries(n)){const s=r,i=e[t];if("eq"in s&&i!==s.eq||"neq"in s&&i===s.neq||"gt"in s&&(typeof i!="number"||i<=s.gt))return!1}return!0}function ij(n,e,t){const r=Object.fromEntries(Object.keys(t).map(s=>[s,new Set]));for(const[s,i]of Object.entries(t))if("eq"in i){const a=n.index(e,s).get().get(i.eq);if(a)for(const l of a)r[s].add(l)}else if("neq"in i){const o=n.index(e,s);for(const[a,l]of o.get())if(a!==i.neq)for(const c of l)r[s].add(c)}else if("gt"in i){const o=n.index(e,s);for(const[a,l]of o.get())if(a>i.gt)for(const c of l)r[s].add(c)}return Cee(Object.values(r))}class kee{constructor(e,t){R(this,"indexCache",new Map);R(this,"historyCache",new Map);this.recordMap=e,this.history=t}filterHistory(e){if(this.historyCache.has(e))return this.historyCache.get(e);const t=ce("filterHistory:"+e,(r,s)=>{if(Uc(r))return this.history.get();const i=this.history.getDiffSince(s);if(i===Ws)return this.history.get();const o={added:{},removed:{},updated:{}};let a=0,l=0,c=0;for(const u of i){for(const h of gn(u.added))if(h.typeName===e)if(o.removed[h.id]){const p=o.removed[h.id];delete o.removed[h.id],l--,p!==h&&(o.updated[h.id]=[p,h],c++)}else o.added[h.id]=h,a++;for(const[h,p]of gn(u.updated))p.typeName===e&&(o.added[p.id]?o.added[p.id]=p:o.updated[p.id]?o.updated[p.id]=[o.updated[p.id][0],p]:(o.updated[p.id]=[h,p],c++));for(const h of gn(u.removed))h.typeName===e&&(o.added[h.id]?(delete o.added[h.id],a--):o.updated[h.id]?(o.removed[h.id]=o.updated[h.id][0],delete o.updated[h.id],c--,l++):(o.removed[h.id]=h,l++))}return a||l||c?xf(this.history.get(),o):r},{historyLength:100});return this.historyCache.set(e,t),t}index(e,t){const r=e+":"+t;if(this.indexCache.has(r))return this.indexCache.get(r);const s=this.__uncached_createIndex(e,t);return this.indexCache.set(r,s),s}__uncached_createIndex(e,t){const r=this.filterHistory(e),s=()=>{r.get();const i=new Map;for(const o of this.recordMap.values())if(o.typeName===e){const a=o[t];i.has(a)||i.set(a,new Set),i.get(a).add(o.id)}return i};return ce("index:"+e+":"+t,(i,o)=>{if(Uc(i))return s();const a=r.getDiffSince(o);if(a===Ws)return s();const l=new Map,c=(m,S)=>{let x=l.get(m);x||(x=new fy(i.get(m)??new Set)),x.add(S),l.set(m,x)},u=(m,S)=>{let x=l.get(m);x||(x=new fy(i.get(m)??new Set)),x.remove(S),l.set(m,x)};for(const m of a){for(const S of gn(m.added))if(S.typeName===e){const x=S[t];c(x,S.id)}for(const[S,x]of gn(m.updated))if(x.typeName===e){const v=S[t],w=x[t];v!==w&&(u(v,x.id),c(w,x.id))}for(const S of gn(m.removed))if(S.typeName===e){const x=S[t];u(x,S.id)}}let h,p;for(const[m,S]of l){const x=S.get();x&&(h||(h=new Map(i)),p||(p=new Map),x.value.size===0?h.delete(m):h.set(m,x.value),p.set(m,x.diff))}return h&&p?xf(h,p):i},{historyLength:100})}record(e,t=()=>({}),r="record:"+e+(t?":"+t.toString():"")){const s=this.ids(e,t,r);return ce(r,()=>{for(const i of s.get())return this.recordMap.get(i)})}records(e,t=()=>({}),r="records:"+e+(t?":"+t.toString():"")){const s=this.ids(e,t,"ids:"+r);return ce(r,()=>Array.from(s.get(),i=>this.recordMap.get(i)),{isEqual:Wy})}ids(e,t=()=>({}),r="ids:"+e+(t?":"+t.toString():"")){const s=this.filterHistory(e),i=()=>{s.get();const l=t();if(Object.keys(l).length===0){const c=new Set;for(const u of this.recordMap.values())u.typeName===e&&c.add(u.id);return c}return ij(this,e,l)},o=l=>{const c=i(),u=Pee(l,c);return u?xf(c,u):l},a=ce("ids_query:"+r,t,{isEqual:ch});return ce("query:"+r,(l,c)=>{const u=a.get();if(Uc(l))return i();if(c<a.lastChangedEpoch)return o(l);const h=s.getDiffSince(c);if(h===Ws)return o(l);const p=new fy(l);for(const S of h){for(const x of gn(S.added))x.typeName===e&&sj(u,x)&&p.add(x.id);for(const[x,v]of gn(S.updated))v.typeName===e&&(sj(u,v)?p.add(v.id):p.remove(v.id));for(const x of gn(S.removed))x.typeName===e&&p.remove(x.id)}const m=p.get();return m?xf(m.value,m.diff):l},{historyLength:50})}exec(e,t){const r=ij(this,e,t);return r.size===0?kr:Array.from(r,s=>this.recordMap.get(s))}}class Iee{constructor(e){R(this,"_beforeCreateHandlers",{});R(this,"_afterCreateHandlers",{});R(this,"_beforeChangeHandlers",{});R(this,"_afterChangeHandlers",{});R(this,"_beforeDeleteHandlers",{});R(this,"_afterDeleteHandlers",{});R(this,"_operationCompleteHandlers",[]);R(this,"_isEnabled",!0);this.store=e}isEnabled(){return this._isEnabled}setIsEnabled(e){this._isEnabled=e}handleBeforeCreate(e,t){if(!this._isEnabled)return e;const r=this._beforeCreateHandlers[e.typeName];if(r){let s=e;for(const i of r)s=i(s,t);return s}return e}handleAfterCreate(e,t){if(!this._isEnabled)return;const r=this._afterCreateHandlers[e.typeName];if(r)for(const s of r)s(e,t)}handleBeforeChange(e,t,r){if(!this._isEnabled)return t;const s=this._beforeChangeHandlers[t.typeName];if(s){let i=t;for(const o of s)i=o(e,i,r);return i}return t}handleAfterChange(e,t,r){if(!this._isEnabled)return;const s=this._afterChangeHandlers[t.typeName];if(s)for(const i of s)i(e,t,r)}handleBeforeDelete(e,t){if(!this._isEnabled)return!0;const r=this._beforeDeleteHandlers[e.typeName];if(r){for(const s of r)if(s(e,t)===!1)return!1}return!0}handleAfterDelete(e,t){if(!this._isEnabled)return;const r=this._afterDeleteHandlers[e.typeName];if(r)for(const s of r)s(e,t)}handleOperationComplete(e){if(this._isEnabled)for(const t of this._operationCompleteHandlers)t(e)}register(e){const t=[];for(const[r,s]of Object.entries(e))s!=null&&s.beforeCreate&&t.push(this.registerBeforeCreateHandler(r,s.beforeCreate)),s!=null&&s.afterCreate&&t.push(this.registerAfterCreateHandler(r,s.afterCreate)),s!=null&&s.beforeChange&&t.push(this.registerBeforeChangeHandler(r,s.beforeChange)),s!=null&&s.afterChange&&t.push(this.registerAfterChangeHandler(r,s.afterChange)),s!=null&&s.beforeDelete&&t.push(this.registerBeforeDeleteHandler(r,s.beforeDelete)),s!=null&&s.afterDelete&&t.push(this.registerAfterDeleteHandler(r,s.afterDelete));return()=>{for(const r of t)r()}}registerBeforeCreateHandler(e,t){return this._beforeCreateHandlers[e]||(this._beforeCreateHandlers[e]=[]),this._beforeCreateHandlers[e].push(t),()=>Mc(this._beforeCreateHandlers[e],t)}registerAfterCreateHandler(e,t){return this._afterCreateHandlers[e]||(this._afterCreateHandlers[e]=[]),this._afterCreateHandlers[e].push(t),()=>Mc(this._afterCreateHandlers[e],t)}registerBeforeChangeHandler(e,t){return this._beforeChangeHandlers[e]||(this._beforeChangeHandlers[e]=[]),this._beforeChangeHandlers[e].push(t),()=>Mc(this._beforeChangeHandlers[e],t)}registerAfterChangeHandler(e,t){return this._afterChangeHandlers[e]||(this._afterChangeHandlers[e]=[]),this._afterChangeHandlers[e].push(t),()=>Mc(this._afterChangeHandlers[e],t)}registerBeforeDeleteHandler(e,t){return this._beforeDeleteHandlers[e]||(this._beforeDeleteHandlers[e]=[]),this._beforeDeleteHandlers[e].push(t),()=>Mc(this._beforeDeleteHandlers[e],t)}registerAfterDeleteHandler(e,t){return this._afterDeleteHandlers[e]||(this._afterDeleteHandlers[e]=[]),this._afterDeleteHandlers[e].push(t),()=>Mc(this._afterDeleteHandlers[e],t)}registerOperationCompleteHandler(e){return this._operationCompleteHandlers.push(e),()=>Mc(this._operationCompleteHandlers,e)}}function Mc(n,e){const t=n.indexOf(e);t>=0&&n.splice(t,1)}class EE{constructor(e){R(this,"id");R(this,"records");R(this,"history",Sn("history",0,{historyLength:1e3}));R(this,"query");R(this,"listeners",new Set);R(this,"historyAccumulator",new _ee);R(this,"historyReactor");R(this,"schema");R(this,"props");R(this,"scopedTypes");R(this,"sideEffects",new Iee(this));R(this,"isMergingRemoteChanges",!1);R(this,"_integrityChecker");R(this,"_isPossiblyCorrupted",!1);R(this,"pendingAfterEvents",null);R(this,"_isInAtomicOp",!1);const{initialData:t,schema:r,id:s}=e;this.id=s??_t(),this.schema=r,this.props=e.props,t?this.records=new lk("store",Is(t).map(([i,o])=>[i,this.schema.validateRecord(this,o,"initialize",null)])):this.records=new lk("store"),this.query=new kee(this.records,this.history),this.historyReactor=mG("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:i=>this.cancelHistoryReactor=y3(i)}),this.scopedTypes={document:new Set(gn(this.schema.types).filter(i=>i.scope==="document").map(i=>i.typeName)),session:new Set(gn(this.schema.types).filter(i=>i.scope==="session").map(i=>i.typeName)),presence:new Set(gn(this.schema.types).filter(i=>i.scope==="presence").map(i=>i.typeName))}}cancelHistoryReactor(){}_flushHistory(){if(this.historyAccumulator.hasChanges()){const e=this.historyAccumulator.flush();for(const{changes:t,source:r}of e){let s=null,i=null,o=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(i??(i=this.filterChangesByScope(t,"document")),!i)continue;a({changes:i,source:r})}else if(l.scope==="session"){if(s??(s=this.filterChangesByScope(t,"session")),!s)continue;a({changes:s,source:r})}else{if(o??(o=this.filterChangesByScope(t,"presence")),!o)continue;a({changes:o,source:r})}else a({changes:t,source:r})}}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(e,t){const r={added:Nf(e.added,(s,i)=>this.scopedTypes[t].has(i.typeName)),updated:Nf(e.updated,(s,i)=>this.scopedTypes[t].has(i[1].typeName)),removed:Nf(e.removed,(s,i)=>this.scopedTypes[t].has(i.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(t=>this.schema.validateRecord(this,t,e,null))}put(e,t){this.atomic(()=>{const r={},s={};let i,o=!1;const a=this.isMergingRemoteChanges?"remote":"user";for(let l=0,c=e.length;l<c;l++){i=e[l];const u=this.records.__unsafe__getWithoutCapture(i.id);if(u){if(i=this.sideEffects.handleBeforeChange(u,i,a),this.schema.validateRecord(this,i,t??"updateRecord",u)===u)continue;i=i,this.records.set(i.id,i),o=!0,r[i.id]=[u,i],this.addDiffForAfterEvent(u,i)}else i=this.sideEffects.handleBeforeCreate(i,a),o=!0,i=this.schema.validateRecord(this,i,t??"createRecord",null),i=i,s[i.id]=i,this.addDiffForAfterEvent(null,i),this.records.set(i.id,i)}o&&this.updateHistory({added:s,updated:r,removed:{}})})}remove(e){this.atomic(()=>{const t=new Set(e),r=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(const o of e){const a=this.records.__unsafe__getWithoutCapture(o);a&&this.sideEffects.handleBeforeDelete(a,r)===!1&&t.delete(o)}const s=this.records.deleteMany(t);if(s.length===0)return;const i={};for(const[o,a]of s)i[o]=a,this.addDiffForAfterEvent(a,null);this.updateHistory({added:{},updated:{},removed:i})})}get(e){return this.records.get(e)}unsafeGetWithoutCapture(e){return this.records.__unsafe__getWithoutCapture(e)}serialize(e="document"){const t={};for(const[r,s]of this.records)(e==="all"||this.scopedTypes[e].has(s.typeName))&&(t[r]=s);return t}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 t=this.schema.migrateStoreSnapshot(e);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);return{store:t.value,schema:this.schema.serialize()}}loadStoreSnapshot(e){const t=this.schema.migrateStoreSnapshot(e);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);const r=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(t.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 Array.from(this.records.values())}clear(){this.remove(Array.from(this.records.keys()))}update(e,t){const r=this.unsafeGetWithoutCapture(e);if(!r){console.error(`Record ${e} not found. This is probably an error`);return}this.put([t(r)])}has(e){return this.records.has(e)}listen(e,t){this._flushHistory();const r={onHistory:e,filters:{source:(t==null?void 0:t.source)??"all",scope:(t==null?void 0:t.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.atomic(e,!0,!0)}finally{this.ensureStoreIsUsable()}}extractingChanges(e){const t=[],r=this.historyAccumulator.addInterceptor(s=>t.push(s.changes));try{return Vs(e),IE(t)}finally{r()}}applyDiff(e,{runCallbacks:t=!0,ignoreEphemeralKeys:r=!1}={}){this.atomic(()=>{const s=gn(e.added);for(const[o,a]of gn(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,p]of Object.entries(a))l.ephemeralKeySet.has(h)||Object.is(p,bn(c,h))||(u||(u={...c}),u[h]=p);u&&s.push(u)}else s.push(a)}const i=BV(e.removed);s.length&&this.put(s),i.length&&this.remove(i)},t)}createCache(e){const t=new qo;return{get:r=>{const s=this.records.getAtom(r);if(s)return t.get(s,()=>e(r,s)).get()}}}createComputedCache(e,t,r){return this.createCache((s,i)=>{const o=r!=null&&r.areRecordsEqual?ce(`${e}:${s}:isEqual`,()=>i.get(),{isEqual:r.areRecordsEqual}):i;return ce(e+":"+s,()=>t(o.get()),{isEqual:r==null?void 0:r.areResultsEqual})})}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,t){if(Je(this.pendingAfterEvents,"must be in event operation"),e===t||(e&&t&&Je(e.id===t.id),!e&&!t))return;const r=(e||t).id,s=this.pendingAfterEvents.get(r);s?s.after=t:this.pendingAfterEvents.set(r,{before:e,after:t})}flushAtomicCallbacks(e){let t=0,r=e?"remote":"user";for(;this.pendingAfterEvents;){const s=this.pendingAfterEvents;if(this.pendingAfterEvents=null,!!this.sideEffects.isEnabled()){if(t++,t>100)throw new Error("Maximum store update depth exceeded, bailing out");for(const{before:i,after:o}of s.values())i&&o&&i!==o&&!ch(i,o)?this.sideEffects.handleAfterChange(i,o,r):i&&!o?this.sideEffects.handleAfterDelete(i,r):!i&&o&&this.sideEffects.handleAfterCreate(o,r);this.pendingAfterEvents?r="user":this.sideEffects.handleOperationComplete(r)}}}atomic(e,t=!0,r=!1){return Vs(()=>{if(this._isInAtomicOp){this.pendingAfterEvents||(this.pendingAfterEvents=new Map);const i=this.sideEffects.isEnabled();Je(!r,"cannot call mergeRemoteChanges while in atomic operation");try{return i&&!t&&this.sideEffects.setIsEnabled(!1),e()}finally{this.sideEffects.setIsEnabled(i)}}this.pendingAfterEvents=new Map;const s=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(t??s),this._isInAtomicOp=!0,r&&(this.isMergingRemoteChanges=!0);try{const i=e();return this.isMergingRemoteChanges=!1,this.flushAtomicCallbacks(r),i}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(s),this._isInAtomicOp=!1,this.isMergingRemoteChanges=!1}})}addHistoryInterceptor(e){return this.historyAccumulator.addInterceptor(t=>e(t,this.isMergingRemoteChanges?"remote":"user"))}}function Eee(n){if(n.length===0)return[];const e=[];let t=[n[0]],r;for(let s=1,i=n.length;s<i;s++)r=n[s],t[0].source!==r.source&&(e.push(t),t=[]),t.push(r);return e.push(t),e.map(s=>({source:s[0].source,changes:IE(s.map(i=>i.changes))}))}class _ee{constructor(){R(this,"_history",[]);R(this,"_interceptors",new Set)}addInterceptor(e){return this._interceptors.add(e),()=>{this._interceptors.delete(e)}}add(e){this._history.push(e);for(const t of this._interceptors)t(e)}flush(){const e=Eee(this._history);return this._history=[],e}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function _E(n,e,t){const r=new qo;return{get(s,i){return r.get(s,()=>(s instanceof EE?s:s.store).createComputedCache(n,l=>e(s,l),t)).get(i)}}}function Tee(n){const e=[];for(let t=n.length-1;t>=0;t--){const r=n[t];if("id"in r)e.unshift(r);else{const s=r.dependsOn,i=e[0];i&&(e[0]={...i,dependsOn:s.concat(i.dependsOn??[])})}}return e}function Od({sequence:n,sequenceId:e,retroactive:t=!0}){const r={sequenceId:e,retroactive:t,sequence:Tee(n)};return s4(r),r}function Ts(n,e){return Object.fromEntries(Is(e).map(([t,r])=>[t,`${n}/${r}`]))}function ei(n){const e=n.sequenceId;return Od({sequenceId:e,retroactive:n.retroactive??!0,sequence:n.sequence.map(t=>"id"in t?{...t,scope:"record",filter:r=>{var s,i;return r.typeName===n.recordType&&(((s=t.filter)==null?void 0:s.call(t,r))??!0)&&(((i=n.filter)==null?void 0:i.call(n,r))??!0)}}:t)})}function Mee(n){const e=new Map(n.map(i=>[i.id,i])),t=new Set,r=[];function s(i){Je(!t.has(i.id),`Circular dependency in migrations: ${i.id}`),t.add(i.id);const{version:o,sequenceId:a}=fS(i.id),l=e.get(`${a}/${o-1}`);if(l&&s(l),i.dependsOn)for(const c of i.dependsOn){const u=e.get(c);u&&s(u)}e.delete(i.id),r.push(i)}for(const i of e.values())s(i);return r}function fS(n){const[e,t]=n.split("/");return{sequenceId:e,version:parseInt(t)}}function oj(n,e){e&&Je(n.startsWith(e+"/"),`Every migration in sequence '${e}' must have an id starting with '${e}/'. Got invalid id: '${n}'`),Je(n.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${n}'`)}function s4(n){if(Je(!n.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${n.sequenceId}`),Je(n.sequenceId.length,"sequenceId must be a non-empty string"),n.sequence.length===0)return;oj(n.sequence[0].id,n.sequenceId);let e=fS(n.sequence[0].id).version;Je(e===1,`Expected the first migrationId to be '${n.sequenceId}/1' but got '${n.sequence[0].id}'`);for(let t=1;t<n.sequence.length;t++){const r=n.sequence[t].id;oj(r,n.sequenceId);const s=fS(r).version;Je(s===e+1,`Migration id numbers must increase in increments of 1, expected ${n.sequenceId}/${e+1} but got '${n.sequence[t].id}'`),e=s}}var Pl=(n=>(n.IncompatibleSubtype="incompatible-subtype",n.UnknownType="unknown-type",n.TargetVersionTooNew="target-version-too-new",n.TargetVersionTooOld="target-version-too-old",n.MigrationError="migration-error",n.UnrecognizedSubtype="unrecognized-subtype",n))(Pl||{});function Aee(n){if(n.schemaVersion>2||n.schemaVersion<1)return Fr.err("Bad schema version");if(n.schemaVersion===2)return Fr.ok(n);const e={schemaVersion:2,sequences:{"com.tldraw.store":n.storeVersion}};for(const[t,r]of Object.entries(n.recordVersions))if(e.sequences[`com.tldraw.${t}`]=r.version,"subTypeKey"in r)for(const[s,i]of Object.entries(r.subTypeVersions))e.sequences[`com.tldraw.${t}.${s}`]=i;return Fr.ok(e)}class TE{constructor(e,t){R(this,"migrations",{});R(this,"sortedMigrations");var s;this.types=e,this.options=t;for(const i of t.migrations??[])Je(!this.migrations[i.sequenceId],`Duplicate migration sequenceId ${i.sequenceId}`),s4(i),this.migrations[i.sequenceId]=i;const r=Object.values(this.migrations).flatMap(i=>i.sequence);this.sortedMigrations=Mee(r);for(const i of this.sortedMigrations)if((s=i.dependsOn)!=null&&s.length)for(const o of i.dependsOn){const a=r.find(l=>l.id===o);Je(a,`Migration '${i.id}' depends on missing migration '${o}'`)}}static create(e,t){return new TE(e,t??{})}validateRecord(e,t,r,s){try{const i=bn(this.types,t.typeName);if(!i)throw new Error(`Missing definition for record type ${t.typeName}`);return i.validate(t,s??void 0)}catch(i){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:e,record:t,phase:r,recordBefore:s,error:i});throw i}}getMigrationsSince(e){const t=Aee(e);if(!t.ok)return t;const r=t.value,s=new Set(Object.keys(r.sequences).filter(o=>this.migrations[o]));for(const o in this.migrations)r.sequences[o]===void 0&&this.migrations[o].retroactive&&s.add(o);if(s.size===0)return Fr.ok([]);const i=new Set;for(const o of s){const a=r.sequences[o];if(typeof a!="number"&&this.migrations[o].retroactive||a===0){for(const u of this.migrations[o].sequence)i.add(u.id);continue}const l=`${o}/${a}`,c=this.migrations[o].sequence.findIndex(u=>u.id===l);if(c===-1)return Fr.err("Incompatible schema?");for(const u of this.migrations[o].sequence.slice(c+1))i.add(u.id)}return Fr.ok(this.sortedMigrations.filter(({id:o})=>i.has(o)))}migratePersistedRecord(e,t,r="up"){const s=this.getMigrationsSince(t);if(!s.ok)return console.error("Error migrating record",s.error),{type:"error",reason:Pl.MigrationError};let i=s.value;if(i.length===0)return{type:"success",value:e};if(i.some(o=>o.scope==="store"))return{type:"error",reason:r==="down"?Pl.TargetVersionTooOld:Pl.TargetVersionTooNew};if(r==="down"){if(!i.every(o=>o.down))return{type:"error",reason:Pl.TargetVersionTooOld};i=i.slice().reverse()}e=Xt(e);try{for(const o of i){if(o.scope==="store")throw new Error;if(!(o.filter?o.filter(e):!0))continue;const l=o[r](e);l&&(e=Xt(l))}}catch(o){return console.error("Error migrating record",o),{type:"error",reason:Pl.MigrationError}}return{type:"success",value:e}}migrateStoreSnapshot(e){let{store:t}=e;const r=this.getMigrationsSince(e.schema);if(!r.ok)return console.error("Error migrating store",r.error),{type:"error",reason:Pl.MigrationError};const s=r.value;if(s.length===0)return{type:"success",value:t};t=Xt(t);try{for(const i of s)if(i.scope==="record")for(const[o,a]of Object.entries(t)){if(!(i.filter?i.filter(a):!0))continue;const c=i.up(a);c&&(t[o]=Xt(c))}else if(i.scope==="store"){const o=i.up(t);o&&(t=Xt(o))}else An(i)}catch(i){return console.error("Error migrating store",i),{type:"error",reason:Pl.MigrationError}}return{type:"success",value:t}}createIntegrityChecker(e){var t,r;return((r=(t=this.options).createIntegrityChecker)==null?void 0:r.call(t,e))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e,sequence:t})=>[e,t.length?fS(t.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e})=>[e,0]))}}getType(e){const t=bn(this.types,e);return Je(t,"record type does not exists"),t}}Zl("@tldraw/store","3.12.1","esm");function Oee(n){if(!n.length)return null;let e="";for(const t of n)typeof t=="number"?e+=`.${t}`:t.startsWith("(")?e.endsWith(")")?e=`${e.slice(0,-1)}, ${t.slice(1)}`:e+=t:e+=`.${t}`;return e=e.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),e.startsWith(".")?e.slice(1):e}class St extends Error{constructor(t,r=[]){const s=Oee(r),i=t.split(`
|
|
181
|
-
`).map((o,a)=>a===0?o:` ${o}`).join(`
|
|
182
|
-
`);super(r?`At ${s}: ${i}`:i);R(this,"name","ValidationError");this.rawMessage=t,this.path=r}}function _s(n,e){try{return e()}catch(t){throw t instanceof St?new St(t.rawMessage,[n,...t.path]):new St(t.toString(),[n])}}function Vl(n){if(n===null)return"null";if(Array.isArray(n))return"an array";const e=typeof n;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:An(e)}}class Mr{constructor(e,t){this.validationFn=e,this.validateUsingKnownGoodVersionFn=t}validate(e){return this.validationFn(e)}validateUsingKnownGoodVersion(e,t){return Object.is(e,t)?e:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(e,t):this.validate(t)}isValid(e){try{return this.validate(e),!0}catch{return!1}}nullable(){return zee(this)}optional(){return o4(this)}refine(e){return new Mr(t=>e(this.validate(t)),(t,r)=>{const s=this.validateUsingKnownGoodVersion(t,r);return Object.is(t,s)?t:e(s)})}check(e,t){return typeof e=="string"?this.refine(r=>(_s(`(check ${e})`,()=>t(r)),r)):this.refine(r=>(e(r),r))}}class Ree extends Mr{constructor(e){super(t=>{const r=aj.validate(t);for(let s=0;s<r.length;s++)_s(s,()=>e.validate(r[s]));return r},(t,r)=>{if(!e.validateUsingKnownGoodVersion)return this.validate(r);const s=aj.validate(r);let i=t.length!==s.length;for(let o=0;o<s.length;o++){const a=s[o];if(o>=t.length){i=!0,_s(o,()=>e.validate(a));continue}if(Object.is(t[o],a))continue;const l=_s(o,()=>e.validateUsingKnownGoodVersion(t[o],a));Object.is(l,t[o])||(i=!0)}return i?r:t}),this.itemValidator=e}nonEmpty(){return this.check(e=>{if(e.length===0)throw new St("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(e=>{if(e.length<=1)throw new St("Expected an array with length greater than 1")})}}class pS extends Mr{constructor(e,t=!1){super(r=>{if(typeof r!="object"||r===null)throw new St(`Expected object, got ${Vl(r)}`);for(const[s,i]of Object.entries(e))_s(s,()=>{i.validate(bn(r,s))});if(!t){for(const s of Object.keys(r))if(!Ci(e,s))throw new St("Unexpected property",[s])}return r},(r,s)=>{if(typeof s!="object"||s===null)throw new St(`Expected object, got ${Vl(s)}`);let i=!1;for(const[o,a]of Object.entries(e)){const l=bn(r,o),c=bn(s,o);if(Object.is(l,c))continue;const u=_s(o,()=>{const h=a;return h.validateUsingKnownGoodVersion?h.validateUsingKnownGoodVersion(l,c):h.validate(c)});Object.is(u,l)||(i=!0)}if(!t){for(const o of Object.keys(s))if(!Ci(e,o))throw new St("Unexpected property",[o])}for(const o of Object.keys(r))if(!Ci(s,o)){i=!0;break}return i?s:r}),this.config=e,this.shouldAllowUnknownProperties=t}allowUnknownProperties(){return new pS(this.config,!0)}extend(e){return new pS({...this.config,...e})}}class V0 extends Mr{constructor(e,t,r,s){super(i=>{this.expectObject(i);const{matchingSchema:o,variant:a}=this.getMatchingSchemaAndVariant(i);return o===void 0?this.unknownValueValidation(i,a):_s(`(${e} = ${a})`,()=>o.validate(i))},(i,o)=>{this.expectObject(o),this.expectObject(i);const{matchingSchema:a,variant:l}=this.getMatchingSchemaAndVariant(o);return a===void 0?this.unknownValueValidation(o,l):bn(i,e)!==bn(o,e)?_s(`(${e} = ${l})`,()=>a.validate(o)):_s(`(${e} = ${l})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(i,o):a.validate(o))}),this.key=e,this.config=t,this.unknownValueValidation=r,this.useNumberKeys=s}expectObject(e){if(typeof e!="object"||e===null)throw new St(`Expected an object, got ${Vl(e)}`,[])}getMatchingSchemaAndVariant(e){const t=bn(e,this.key);if(!this.useNumberKeys&&typeof t!="string")throw new St(`Expected a string for key "${this.key}", got ${Vl(t)}`);if(this.useNumberKeys&&!Number.isFinite(Number(t)))throw new St(`Expected a number for key "${this.key}", got "${t}"`);return{matchingSchema:Ci(this.config,t)?this.config[t]:void 0,variant:t}}validateUnknownVariants(e){return new V0(this.key,this.config,e,this.useNumberKeys)}}class Dee extends Mr{constructor(e,t){super(r=>{if(typeof r!="object"||r===null)throw new St(`Expected object, got ${Vl(r)}`);for(const[s,i]of Object.entries(r))_s(s,()=>{e.validate(s),t.validate(i)});return r},(r,s)=>{if(typeof s!="object"||s===null)throw new St(`Expected object, got ${Vl(s)}`);let i=!1;for(const[o,a]of Object.entries(s)){if(!Ci(r,o)){i=!0,_s(o,()=>{e.validate(o),t.validate(a)});continue}const l=bn(r,o),c=a;if(Object.is(l,c))continue;const u=_s(o,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(l,c):t.validate(c));Object.is(u,l)||(i=!0)}for(const o of Object.keys(r))if(!Ci(s,o)){i=!0;break}return i?s:r}),this.keyValidator=e,this.valueValidator=t}}function ME(n){return new Mr(e=>{if(typeof e!==n)throw new St(`Expected ${n}, got ${Vl(e)}`);return e})}const jee=new Mr(n=>n),Lee=new Mr(n=>n),st=ME("string"),Xe=ME("number").check(n=>{if(Number.isNaN(n))throw new St("Expected a number, got NaN");if(!Number.isFinite(n))throw new St(`Expected a finite number, got ${n}`)}),gS=Xe.check(n=>{if(n<0)throw new St(`Expected a positive number, got ${n}`)}),Pn=Xe.check(n=>{if(n<=0)throw new St(`Expected a non-zero positive number, got ${n}`)}),i4=Xe.check(n=>{if(!Number.isInteger(n))throw new St(`Expected an integer, got ${n}`)}),py=i4.check(n=>{if(n<0)throw new St(`Expected a positive integer, got ${n}`)}),Nee=i4.check(n=>{if(n<=0)throw new St(`Expected a non-zero positive integer, got ${n}`)}),mt=ME("boolean");function _r(n){return new Mr(e=>{if(e!==n)throw new St(`Expected ${n}, got ${JSON.stringify(e)}`);return n})}const aj=new Mr(n=>{if(!Array.isArray(n))throw new St(`Expected an array, got ${Vl(n)}`);return n});function Un(n){return new Ree(n)}function pt(n){return new pS(n)}function uk(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null||Object.getPrototypeOf(n)===fq)}function dk(n){return n===null||typeof n=="number"||typeof n=="string"||typeof n=="boolean"?!0:Array.isArray(n)?n.every(dk):uk(n)?Object.values(n).every(dk):!1}const ir=new Mr(n=>{if(dk(n))return n;throw new St(`Expected json serializable value, got ${typeof n}`)},(n,e)=>{if(Array.isArray(n)&&Array.isArray(e)){let t=n.length!==e.length;for(let r=0;r<e.length;r++){if(r>=n.length){t=!0,ir.validate(e[r]);continue}const s=n[r],i=e[r];if(Object.is(s,i))continue;const o=ir.validateUsingKnownGoodVersion(s,i);Object.is(o,s)||(t=!0)}return t?e:n}else if(uk(n)&&uk(e)){let t=!1;for(const r of Object.keys(e)){if(!Ci(n,r)){t=!0,ir.validate(e[r]);continue}const s=n[r],i=e[r];if(Object.is(s,i))continue;const o=ir.validateUsingKnownGoodVersion(s,i);Object.is(o,s)||(t=!0)}for(const r of Object.keys(n))if(!Ci(e,r)){t=!0;break}return t?e:n}else return ir.validate(e)});function mS(n,e){return new Dee(n,e)}function AE(n,e){return new V0(n,e,(t,r)=>{throw new St(`Expected one of ${Object.keys(e).map(s=>JSON.stringify(s)).join(" or ")}, got ${JSON.stringify(r)}`,[n])},!1)}function Fee(n,e){return new V0(n,e,(t,r)=>{throw new St(`Expected one of ${Object.keys(e).map(s=>JSON.stringify(s)).join(" or ")}, got ${JSON.stringify(r)}`,[n])},!0)}function Yo(n,e){return new Mr(t=>_s(n,()=>e.validate(t)),(t,r)=>_s(n,()=>e.validateUsingKnownGoodVersion?e.validateUsingKnownGoodVersion(t,r):e.validate(r)))}function q0(n){return new Mr(e=>{if(!n.has(e)){const t=Array.from(n,r=>JSON.stringify(r)).join(" or ");throw new St(`Expected ${t}, got ${e}`)}return e})}function o4(n){return new Mr(e=>{if(e!==void 0)return n.validate(e)},(e,t)=>{if(!(e===void 0&&t===void 0)&&t!==void 0)return n.validateUsingKnownGoodVersion&&e!==void 0?n.validateUsingKnownGoodVersion(e,t):n.validate(t)})}function zee(n){return new Mr(e=>e===null?null:n.validate(e),(e,t)=>t===null?null:n.validateUsingKnownGoodVersion&&e!==null?n.validateUsingKnownGoodVersion(e,t):n.validate(t))}function Hp(...n){return q0(new Set(n))}function OE(n){try{return new URL(n)}catch{if(n.startsWith("/")||n.startsWith("./"))try{return new URL(n,"http://example.com")}catch{throw new St(`Expected a valid url, got ${JSON.stringify(n)}`)}throw new St(`Expected a valid url, got ${JSON.stringify(n)}`)}}const $ee=new Set(["http:","https:","mailto:"]),Zs=st.check(n=>{if(n==="")return;const e=OE(n);if(!$ee.has(e.protocol.toLowerCase()))throw new St(`Expected a valid url, got ${JSON.stringify(n)} (invalid protocol)`)}),Bee=new Set(["http:","https:","data:","asset:"]),ru=st.check(n=>{if(n==="")return;const e=OE(n);if(!Bee.has(e.protocol.toLowerCase()))throw new St(`Expected a valid url, got ${JSON.stringify(n)} (invalid protocol)`)});st.check(n=>{if(n==="")return;if(!OE(n).protocol.toLowerCase().match(/^https?:$/))throw new St(`Expected a valid url, got ${JSON.stringify(n)} (invalid protocol)`)});const RE=st.refine(n=>{try{return rq(n),n}catch{throw new St(`Expected an index key, got ${JSON.stringify(n)}`)}});Zl("@tldraw/validate","3.12.1","esm");function Ys(n){return st.refine(e=>{if(!e.startsWith(`${n}:`))throw new Error(`${n} ID must start with "${n}:"`);return e})}const G0=Ys("asset");function DE(n,e){return pt({id:G0,typeName:_r("asset"),type:_r(n),props:e,meta:ir})}const su=pt({x:Xe,y:Xe,z:Xe.optional()}),Uf=pt({x:Xe,y:Xe,w:Xe,h:Xe}),a4=Xe.check(n=>{if(n<0||n>1)throw new St("Opacity must be between 0 and 1")}),Uee=st.refine(n=>{if(!n.startsWith("page:")&&!n.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return n}),yi=Ys("shape");function Hee(n,e,t){return pt({id:yi,typeName:_r("shape"),x:Xe,y:Xe,rotation:Xe,index:RE,parentId:Uee,type:_r(n),isLocked:mt,opacity:a4,props:e?pt(e):ir,meta:t?pt(t):ir})}const Kee=Ys("binding");function Wee(n,e,t){return pt({id:Kee,typeName:_r("binding"),type:_r(n),fromId:yi,toId:yi,props:e?pt(e):ir,meta:t?pt(t):ir})}Ts("com.tldraw.binding",{});ei({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});function Gc(n){return`binding:${_t()}`}function Vee(n){return Go("binding",{scope:"document",validator:Yo("binding",AE("type",rh(n,(e,{props:t,meta:r})=>Wee(e,t,r))))}).withDefaultProperties(()=>({meta:{}}))}class ur{constructor(e,t,r){this.id=e,this.defaultValue=t,this.type=r}static define(e,t){const{defaultValue:r,type:s=Lee}=t;return new ur(e,r,s)}static defineEnum(e,t){const{defaultValue:r,values:s}=t;return new qee(e,r,s)}setDefaultValue(e){this.defaultValue=e}validate(e){return this.type.validate(e)}validateUsingKnownGoodVersion(e,t){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(e,t):this.validate(t)}}class qee extends ur{constructor(e,t,r){super(e,t,Hp(...r)),this.values=r}}const Em=Ts("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),Gee=ei({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:Em.AddIsLocked,up:n=>{n.isLocked=!1},down:n=>{delete n.isLocked}},{id:Em.HoistOpacity,up:n=>{n.opacity=Number(n.props.opacity??"1"),delete n.props.opacity},down:n=>{const e=n.opacity;delete n.opacity,n.props.opacity=e<.175?"0.1":e<.375?"0.25":e<.625?"0.5":e<.875?"0.75":"1"}},{id:Em.AddMeta,up:n=>{n.meta={}}},{id:Em.AddWhite,up:n=>{},down:n=>{n.props.color==="white"&&(n.props.color="black")}}]});function kd(n){return n?n.typeName==="shape":!1}function ws(n){return n?n.startsWith("shape:"):!1}function Dt(n){return`shape:${n??_t()}`}function l4(n){const e=new Map;for(const[t,r]of Object.entries(n))if(r instanceof ur){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,t)}return e}function _i(n,e){return rh(e,(t,r)=>`com.tldraw.shape.${n}/${r}`)}function Yee(n){return Go("shape",{scope:"document",validator:Yo("shape",AE("type",rh(n,(e,{props:t,meta:r})=>Hee(e,t,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}function lj(n,e){const t=[];for(const[r,{migrations:s}]of Object.entries(e)){const i=`com.tldraw.${n}.${r}`;s?"sequenceId"in s?(Je(i===s.sequenceId,`sequenceId mismatch for ${r} ${W0} migrations. Expected '${i}', got '${s.sequenceId}'`),t.push(s)):"sequence"in s?t.push(Od({sequenceId:i,retroactive:!1,sequence:s.sequence.map(o=>"id"in o?c4(n,r,o):o)})):t.push(Od({sequenceId:i,retroactive:!1,sequence:Object.keys(s.migrators).map(o=>Number(o)).sort((o,a)=>o-a).map(o=>({id:`${i}/${o}`,scope:"record",filter:a=>a.typeName===n&&a.type===r,up:a=>{const l=s.migrators[o].up(a);if(l)return l},down:a=>{const l=s.migrators[o].down(a);if(l)return l}}))})):t.push(Od({sequenceId:i,retroactive:!1,sequence:[]}))}return t}function c4(n,e,t){return{id:t.id,dependsOn:t.dependsOn,scope:"record",filter:r=>r.typeName===n&&r.type===e,up:r=>{const s=t.up(r.props);s&&(r.props=s)},down:typeof t.down=="function"?r=>{const s=t.down(r.props);s&&(r.props=s)}:void 0}}const u4=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],yS={lightMode:{id:"light",text:"#000000",background:"#f9fafb",solid:"#fcfffe",black:{solid:"#1d1d1d",fill:"#1d1d1d",frame:{headingStroke:"#717171",headingFill:"#ffffff",stroke:"#717171",fill:"#ffffff",text:"#000000"},note:{fill:"#FCE19C",text:"#000000"},semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8205 0.05)"}},blue:{solid:"#4465e9",fill:"#4465e9",frame:{headingStroke:"#6681ec",headingFill:"#f9fafe",stroke:"#6681ec",fill:"#f9fafe",text:"#000000"},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",frame:{headingStroke:"#37a684",headingFill:"#f8fcfa",stroke:"#37a684",fill:"#f8fcfa",text:"#000000"},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",frame:{headingStroke:"#aaaaab",headingFill:"#fbfcfc",stroke:"#aaaaab",fill:"#fcfcfd",text:"#000000"},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",frame:{headingStroke:"#6cb2f3",headingFill:"#f8fbfe",stroke:"#6cb2f3",fill:"#fafcff",text:"#000000"},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",frame:{headingStroke:"#6dbe7c",headingFill:"#f8fcf9",stroke:"#6dbe7c",fill:"#fafdfa",text:"#000000"},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",frame:{headingStroke:"#f89090",headingFill:"#fffafa",stroke:"#f89090",fill:"#fffbfb",text:"#000000"},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",frame:{headingStroke:"#e59bf5",headingFill:"#fefaff",stroke:"#e59bf5",fill:"#fefbff",text:"#000000"},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",frame:{headingStroke:"#e68544",headingFill:"#fef9f6",stroke:"#e68544",fill:"#fef9f6",text:"#000000"},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",frame:{headingStroke:"#e55757",headingFill:"#fef7f7",stroke:"#e55757",fill:"#fef9f9",text:"#000000"},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",frame:{headingStroke:"#bc62d3",headingFill:"#fcf7fd",stroke:"#bc62d3",fill:"#fdf9fd",text:"#000000"},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",frame:{headingStroke:"#f3bb6c",headingFill:"#fefcf8",stroke:"#f3bb6c",fill:"#fffdfa",text:"#000000"},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",frame:{headingStroke:"#7d7d7d",headingFill:"#ffffff",stroke:"#7d7d7d",fill:"#ffffff",text:"#000000"},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",frame:{headingStroke:"#5c5c5c",headingFill:"#252525",stroke:"#5c5c5c",fill:"#0c0c0c",text:"#f2f2f2"},note:{fill:"#2c2c2c",text:"#f2f2f2"},semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.6225 0.0312)"}},blue:{solid:"#4f72fc",fill:"#4f72fc",frame:{headingStroke:"#384994",headingFill:"#1C2036",stroke:"#384994",fill:"#11141f",text:"#f2f2f2"},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",frame:{headingStroke:"#10513C",headingFill:"#14241f",stroke:"#10513C",fill:"#0E1614",text:"#f2f2f2"},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",frame:{headingStroke:"#42474D",headingFill:"#23262A",stroke:"#42474D",fill:"#151719",text:"#f2f2f2"},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",frame:{headingStroke:"#075797",headingFill:"#142839",stroke:"#075797",fill:"#0B1823",text:"#f2f2f2"},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",frame:{headingStroke:"#1C5427",headingFill:"#18251A",stroke:"#1C5427",fill:"#0F1911",text:"#f2f2f2"},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",frame:{headingStroke:"#6f3232",headingFill:"#341818",stroke:"#6f3232",fill:"#181212",text:"#f2f2f2"},note:{fill:"#7a3333",text:"#f2f2f2"},semi:"#3c2b2b",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",fill:"#e599f7",frame:{headingStroke:"#6c367a",headingFill:"#2D2230",stroke:"#6c367a",fill:"#1C151E",text:"#f2f2f2"},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",frame:{headingStroke:"#773a0e",headingFill:"#2f1d13",stroke:"#773a0e",fill:"#1c1512",text:"#f2f2f2"},note:{fill:"#7c3905",text:"#f2f2f2"},semi:"#3b2e27",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",fill:"#e03131",frame:{headingStroke:"#701e1e",headingFill:"#301616",stroke:"#701e1e",fill:"#1b1313",text:"#f2f2f2"},note:{fill:"#7e201f",text:"#f2f2f2"},semi:"#382726",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",frame:{headingStroke:"#6d1583",headingFill:"#27152e",stroke:"#6d1583",fill:"#1b0f21",text:"#f2f2f2"},note:{fill:"#5f1c70",text:"#f2f2f2"},semi:"#342938",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",fill:"#ffc034",frame:{headingStroke:"#684e12",headingFill:"#2a2113",stroke:"#684e12",fill:"#1e1911",text:"#f2f2f2"},note:{fill:"#8a5e1c",text:"#f2f2f2"},semi:"#3b352b",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},white:{solid:"#f3f3f3",fill:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",frame:{headingStroke:"#ffffff",headingFill:"#ffffff",stroke:"#ffffff",fill:"#ffffff",text:"#000000"},note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function Va(n){return n.isDarkMode?yS.darkMode:yS.lightMode}const Yr=ur.defineEnum("tldraw:color",{defaultValue:"black",values:u4}),jE=ur.defineEnum("tldraw:labelColor",{defaultValue:"black",values:u4}),iu=ur.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),ou=ur.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill"]}),Na=ur.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),d4={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},Uo=ur.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),h4=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],SS=ur.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:h4}),vS=ur.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:h4}),f4={labelColor:jE,color:Yr,fill:ou,dash:iu,size:Uo,arrowheadStart:SS,arrowheadEnd:vS,font:Na,start:su,end:su,bend:Xe,text:st,labelPosition:Xe,scale:Pn},Sd=_i("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5});function _m(n){return c4("shape","arrow",n)}const p4=Od({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[_m({id:Sd.AddLabelColor,up:n=>{n.labelColor="black"},down:"retired"}),_m({id:Sd.AddIsPrecise,up:({start:n,end:e})=>{n.type==="binding"&&(n.isPrecise=!(n.normalizedAnchor.x===.5&&n.normalizedAnchor.y===.5)),e.type==="binding"&&(e.isPrecise=!(e.normalizedAnchor.x===.5&&e.normalizedAnchor.y===.5))},down:({start:n,end:e})=>{n.type==="binding"&&(n.isPrecise||(n.normalizedAnchor={x:.5,y:.5}),delete n.isPrecise),e.type==="binding"&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise)}}),_m({id:Sd.AddLabelPosition,up:n=>{n.labelPosition=.5},down:n=>{delete n.labelPosition}}),{id:Sd.ExtractBindings,scope:"store",up:n=>{const e=Object.values(n).filter(t=>t.typeName==="shape"&&t.type==="arrow");for(const t of e){const{start:r,end:s}=t.props;if(r.type==="binding"){const i=Gc(),o={typeName:"binding",id:i,type:"arrow",fromId:t.id,toId:r.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:r.normalizedAnchor,isExact:r.isExact,isPrecise:r.isPrecise}};n[i]=o,t.props.start={x:0,y:0}}else delete t.props.start.type;if(s.type==="binding"){const i=Gc(),o={typeName:"binding",id:i,type:"arrow",fromId:t.id,toId:s.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:s.normalizedAnchor,isExact:s.isExact,isPrecise:s.isPrecise}};n[i]=o,t.props.end={x:0,y:0}}else delete t.props.end.type}}},_m({id:Sd.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}})]}),g4={terminal:Hp("start","end"),normalizedAnchor:su,isExact:mt,isPrecise:mt},m4={sequence:[{dependsOn:[Sd.ExtractBindings]}]},Xee=Yo("camera",pt({typeName:_r("camera"),id:Ys("camera"),x:Xe,y:Xe,z:Xe,meta:ir})),Zee=Ts("com.tldraw.camera",{AddMeta:1}),Jee=ei({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:Zee.AddMeta,up:n=>{n.meta={}}}]}),jo=Go("camera",{validator:Xee,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),Qee=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"]),y4=q0(Qee),ete=pt({type:y4,rotation:Xe}),tte=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),nte=q0(tte),rte=new Set(["starting","paused","active","stopping"]),S4=pt({id:st,points:Un(su),size:gS,color:nte,opacity:Xe,state:q0(rte),delay:Xe,shrink:Xe,taper:mt}),gp=Ys("page"),ste=Yo("page",pt({typeName:_r("page"),id:gp,name:st,index:RE,meta:ir})),ite=Ts("com.tldraw.page",{AddMeta:1}),ote=ei({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:ite.AddMeta,up:n=>{n.meta={}}}]}),Wr=Go("page",{validator:ste,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function Ss(n){return Wr.isId(n)}const ate={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 v4(n){return n?Nf(n,e=>ate[e]):null}Ys("instance");function lte(n){const e={};for(const[r,s]of n)e[r]=o4(s);const t=Yo("instance",pt({typeName:_r("instance"),id:Ys("instance"),currentPageId:gp,followingUserId:st.nullable(),brush:Uf.nullable(),opacityForNextShape:a4,stylesForNextShape:pt(e),cursor:ete,scribbles:Un(S4),isFocusMode:mt,isDebugMode:mt,isToolLocked:mt,exportBackground:mt,screenBounds:Uf,insets:Un(mt),zoomBrush:Uf.nullable(),isPenMode:mt,isGridMode:mt,chatMessage:st,isChatting:mt,highlightedUserIds:Un(st),isFocused:mt,devicePixelRatio:Xe,isCoarsePointer:mt,isHoveringCanvas:mt.nullable(),openMenus:Un(st),isChangingStyle:mt,isReadonly:mt,meta:ir,duplicateProps:pt({shapeIds:Un(Ys("shape")),offset:pt({x:Xe,y:Xe})}).nullable()}));return Go("instance",{validator:t,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 Gt=Ts("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}),cte=ei({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:Gt.AddTransparentExportBgs,up:n=>({...n,exportBackground:!0})},{id:Gt.RemoveDialog,up:({dialog:n,...e})=>e},{id:Gt.AddToolLockMode,up:n=>({...n,isToolLocked:!1})},{id:Gt.RemoveExtraPropsForNextShape,up:({propsForNextShape:n,...e})=>({...e,propsForNextShape:Object.fromEntries(Object.entries(n).filter(([t])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(t)))})},{id:Gt.AddLabelColor,up:({propsForNextShape:n,...e})=>({...e,propsForNextShape:{...n,labelColor:"black"}})},{id:Gt.AddFollowingUserId,up:n=>({...n,followingUserId:null})},{id:Gt.RemoveAlignJustify,up:n=>{let e=n.propsForNextShape.align;return e==="justify"&&(e="start"),{...n,propsForNextShape:{...n.propsForNextShape,align:e}}}},{id:Gt.AddZoom,up:n=>({...n,zoomBrush:null})},{id:Gt.AddVerticalAlign,up:n=>({...n,propsForNextShape:{...n.propsForNextShape,verticalAlign:"middle"}})},{id:Gt.AddScribbleDelay,up:n=>n.scribble!==null?{...n,scribble:{...n.scribble,delay:0}}:{...n}},{id:Gt.RemoveUserId,up:({userId:n,...e})=>e},{id:Gt.AddIsPenModeAndIsGridMode,up:n=>({...n,isPenMode:!1,isGridMode:!1})},{id:Gt.HoistOpacity,up:({propsForNextShape:{opacity:n,...e},...t})=>({...t,opacityForNextShape:Number(n??"1"),propsForNextShape:e})},{id:Gt.AddChat,up:n=>({...n,chatMessage:"",isChatting:!1})},{id:Gt.AddHighlightedUserIds,up:n=>({...n,highlightedUserIds:[]})},{id:Gt.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:n,...e})=>({...e,stylesForNextShape:{}})},{id:Gt.AddMeta,up:n=>({...n,meta:{}})},{id:Gt.RemoveCursorColor,up:n=>{const{color:e,...t}=n.cursor;return{...n,cursor:t}}},{id:Gt.AddLonelyProperties,up:n=>({...n,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:Gt.ReadOnlyReadonly,up:({isReadOnly:n,...e})=>({...e,isReadonly:n})},{id:Gt.AddHoveringCanvas,up:n=>({...n,isHoveringCanvas:null})},{id:Gt.AddScribbles,up:({scribble:n,...e})=>({...e,scribbles:[]})},{id:Gt.AddInset,up:n=>({...n,insets:[!1,!1,!1,!1]}),down:({insets:n,...e})=>({...e})},{id:Gt.AddDuplicateProps,up:n=>({...n,duplicateProps:null}),down:({duplicateProps:n,...e})=>({...e})},{id:Gt.RemoveCanMoveCamera,up:({canMoveCamera:n,...e})=>({...e}),down:n=>({...n,canMoveCamera:!0})}]}),$r="instance:instance",ute=Yo("instance_page_state",pt({typeName:_r("instance_page_state"),id:Ys("instance_page_state"),pageId:gp,selectedShapeIds:Un(yi),hintingShapeIds:Un(yi),erasingShapeIds:Un(yi),hoveredShapeId:yi.nullable(),editingShapeId:yi.nullable(),croppingShapeId:yi.nullable(),focusedGroupId:yi.nullable(),meta:ir})),sf=Ts("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),dte=ei({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:sf.AddCroppingId,up(n){n.croppingShapeId=null}},{id:sf.RemoveInstanceIdAndCameraId,up(n){delete n.instanceId,delete n.cameraId}},{id:sf.AddMeta,up:n=>{n.meta={}}},{id:sf.RenameProperties,up:n=>{},down:n=>{}},{id:sf.RenamePropertiesAgain,up:n=>{n.selectedShapeIds=n.selectedIds,delete n.selectedIds,n.hintingShapeIds=n.hintingIds,delete n.hintingIds,n.erasingShapeIds=n.erasingIds,delete n.erasingIds,n.hoveredShapeId=n.hoveredId,delete n.hoveredId,n.editingShapeId=n.editingId,delete n.editingId,n.croppingShapeId=n.croppingShapeId??n.croppingId??null,delete n.croppingId,n.focusedGroupId=n.focusLayerId,delete n.focusLayerId},down:n=>{n.selectedIds=n.selectedShapeIds,delete n.selectedShapeIds,n.hintingIds=n.hintingShapeIds,delete n.hintingShapeIds,n.erasingIds=n.erasingShapeIds,delete n.erasingShapeIds,n.hoveredId=n.hoveredShapeId,delete n.hoveredShapeId,n.editingId=n.editingShapeId,delete n.editingShapeId,n.croppingId=n.croppingShapeId,delete n.croppingShapeId,n.focusLayerId=n.focusedGroupId,delete n.focusedGroupId}}]}),Yi=Go("instance_page_state",{validator:ute,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:{}})),hte=Yo("pointer",pt({typeName:_r("pointer"),id:Ys("pointer"),x:Xe,y:Xe,lastActivityTimestamp:Xe,meta:ir})),fte=Ts("com.tldraw.pointer",{AddMeta:1}),pte=ei({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:fte.AddMeta,up:n=>{n.meta={}}}]}),LE=Go("pointer",{validator:hte,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),xS=LE.createId("pointer"),gte=Yo("instance_presence",pt({typeName:_r("instance_presence"),id:Ys("instance_presence"),userId:st,userName:st,lastActivityTimestamp:Xe.nullable(),followingUserId:st.nullable(),cursor:pt({x:Xe,y:Xe,type:y4,rotation:Xe}).nullable(),color:st,camera:pt({x:Xe,y:Xe,z:Xe}).nullable(),screenBounds:Uf.nullable(),selectedShapeIds:Un(Ys("shape")),currentPageId:Ys("page"),brush:Uf.nullable(),scribbles:Un(S4),chatMessage:st,meta:ir})),ad=Ts("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5,NullableCameraCursor:6}),mte=ei({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:ad.AddScribbleDelay,up:n=>{n.scribble!==null&&(n.scribble.delay=0)}},{id:ad.RemoveInstanceId,up:n=>{delete n.instanceId}},{id:ad.AddChatMessage,up:n=>{n.chatMessage=""}},{id:ad.AddMeta,up:n=>{n.meta={}}},{id:ad.RenameSelectedShapeIds,up:n=>{}},{id:ad.NullableCameraCursor,up:n=>{},down:n=>{n.camera===null&&(n.camera={x:0,y:0,z:1}),n.lastActivityTimestamp===null&&(n.lastActivityTimestamp=0),n.cursor===null&&(n.cursor={type:"default",x:0,y:0,rotation:0}),n.screenBounds===null&&(n.screenBounds={x:0,y:0,w:1,h:1})}}]}),yte=Go("instance_presence",{validator:gte,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:null,followingUserId:null,color:"#FF0000",camera:null,cursor:null,screenBounds:null,selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),Ste=Yo("document",pt({typeName:_r("document"),id:_r("document:document"),gridSize:Xe,name:st,meta:ir})),cj=Ts("com.tldraw.document",{AddName:1,AddMeta:2}),vte=ei({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:cj.AddName,up:n=>{n.name=""},down:n=>{delete n.name}},{id:cj.AddMeta,up:n=>{n.meta={}}}]}),NE=Go("document",{validator:Ste,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),hk=NE.createId("document");function xte(n,e){return n.index<e.index?-1:n.index>e.index?1:0}function uj(n){n.typeName==="asset"&&("src"in n&&(n.src="<redacted>"),"src"in n.props&&(n.props.src="<redacted>"))}function wte({error:n,phase:e,record:t,recordBefore:r}){throw bI(n,{tags:{origin:"store.validateRecord",storePhase:e,isExistingValidationIssue:e==="initialize"},extras:{recordBefore:r?uj(Xt(r)):void 0,recordAfter:uj(Xt(t))}}),n}function bte(){return[Wr.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function Cte(n){const e=n.query.ids("page"),t=n.query.records("instance_page_state"),r=()=>{if(!n.has(hk))return n.put([NE.create({id:hk,name:n.props.defaultName})]),r();if(!n.has(xS))return n.put([LE.create({id:xS})]),r();const s=e.get();if(s.size===0)return n.put(bte()),r();const i=()=>[...s].map(u=>n.get(u)).sort(xte)[0].id,o=n.get($r);if(o){if(!s.has(o.currentPageId))return n.put([{...o,currentPageId:i()}]),r()}else return n.put([n.schema.types.instance.create({id:$r,currentPageId:i(),exportBackground:!0})]),r();const a=new Set,l=new Set;for(const u of s){const h=Yi.createId(u);n.get(h)||a.add(h);const m=jo.createId(u);n.has(m)||l.add(m)}a.size>0&&n.put([...a].map(u=>Yi.create({id:u,pageId:Yi.parseId(u)}))),l.size>0&&n.put([...l].map(u=>jo.create({id:u})));const c=t.get();for(const u of c){if(!s.has(u.pageId)){n.remove([u.id]);continue}if(u.croppingShapeId&&!n.has(u.croppingShapeId))return n.put([{...u,croppingShapeId:null}]),r();if(u.focusedGroupId&&!n.has(u.focusedGroupId))return n.put([{...u,focusedGroupId:null}]),r();if(u.hoveredShapeId&&!n.has(u.hoveredShapeId))return n.put([{...u,hoveredShapeId:null}]),r();const h=u.selectedShapeIds.filter(S=>n.has(S));if(h.length!==u.selectedShapeIds.length)return n.put([{...u,selectedShapeIds:h}]),r();const p=u.hintingShapeIds.filter(S=>n.has(S));if(p.length!==u.hintingShapeIds.length)return n.put([{...u,hintingShapeIds:p}]),r();const m=u.erasingShapeIds.filter(S=>n.has(S));if(m.length!==u.erasingShapeIds.length)return n.put([{...u,erasingShapeIds:m}]),r()}};return r}const Pte=DE("bookmark",pt({title:st,description:st,image:st,favicon:st,src:ru.nullable()})),dj=Ts("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),kte=ei({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:n=>n.type==="bookmark",sequence:[{id:dj.MakeUrlsValid,up:n=>{ru.isValid(n.props.src)||(n.props.src="")},down:n=>{}},{id:dj.AddFavicon,up:n=>{ru.isValid(n.props.favicon)||(n.props.favicon="")},down:n=>{delete n.props.favicon}}]}),Ite=DE("image",pt({w:Xe,h:Xe,name:st,isAnimated:mt,mimeType:st.nullable(),src:ru.nullable(),fileSize:Pn.optional()})),of=Ts("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),Ete=ei({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:n=>n.type==="image",sequence:[{id:of.AddIsAnimated,up:n=>{n.props.isAnimated=!1},down:n=>{delete n.props.isAnimated}},{id:of.RenameWidthHeight,up:n=>{n.props.w=n.props.width,n.props.h=n.props.height,delete n.props.width,delete n.props.height},down:n=>{n.props.width=n.props.w,n.props.height=n.props.h,delete n.props.w,delete n.props.h}},{id:of.MakeUrlsValid,up:n=>{ru.isValid(n.props.src)||(n.props.src="")},down:n=>{}},{id:of.AddFileSize,up:n=>{n.props.fileSize=-1},down:n=>{delete n.props.fileSize}},{id:of.MakeFileSizeOptional,up:n=>{n.props.fileSize===-1&&(n.props.fileSize=void 0)},down:n=>{n.props.fileSize===void 0&&(n.props.fileSize=-1)}}]}),_te=DE("video",pt({w:Xe,h:Xe,name:st,isAnimated:mt,mimeType:st.nullable(),src:ru.nullable(),fileSize:Xe.optional()})),af=Ts("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),Tte=ei({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:n=>n.type==="video",sequence:[{id:af.AddIsAnimated,up:n=>{n.props.isAnimated=!1},down:n=>{delete n.props.isAnimated}},{id:af.RenameWidthHeight,up:n=>{n.props.w=n.props.width,n.props.h=n.props.height,delete n.props.width,delete n.props.height},down:n=>{n.props.width=n.props.w,n.props.height=n.props.h,delete n.props.w,delete n.props.h}},{id:af.MakeUrlsValid,up:n=>{ru.isValid(n.props.src)||(n.props.src="")},down:n=>{}},{id:af.AddFileSize,up:n=>{n.props.fileSize=-1},down:n=>{delete n.props.fileSize}},{id:af.MakeFileSizeOptional,up:n=>{n.props.fileSize===-1&&(n.props.fileSize=void 0)},down:n=>{n.props.fileSize===void 0&&(n.props.fileSize=-1)}}]}),Mte=Yo("asset",AE("type",{image:Ite,video:_te,bookmark:Pte})),Ate=Ts("com.tldraw.asset",{AddMeta:1}),Ote=ei({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:Ate.AddMeta,up:n=>{n.meta={}}}]}),ql=Go("asset",{validator:Mte,scope:"document"}).withDefaultProperties(()=>({meta:{}})),x4={w:Pn,h:Pn,assetId:G0.nullable(),url:Zs},hj=_i("bookmark",{NullAssetId:1,MakeUrlsValid:2}),w4={sequence:[{id:hj.NullAssetId,up:n=>{n.assetId===void 0&&(n.assetId=null)},down:"retired"},{id:hj.MakeUrlsValid,up:n=>{Zs.isValid(n.url)||(n.url="")},down:n=>{}}]},b4=pt({type:Hp("free","straight"),points:Un(su)}),C4={color:Yr,fill:ou,dash:iu,size:Uo,segments:Un(b4),isComplete:mt,isClosed:mt,isPen:mt,scale:Pn},fj=_i("draw",{AddInPen:1,AddScale:2}),P4={sequence:[{id:fj.AddInPen,up:n=>{const{points:e}=n.segments[0];if(e.length===0){n.isPen=!1;return}let t=!(e[0].z===0||e[0].z===.5);e[1]&&(t=t&&!(e[1].z===0||e[1].z===.5)),n.isPen=t},down:"retired"},{id:fj.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}}]},Rte=/(^\/r\/[^/]+\/?$)/,Dte=[{hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(Rte))return n}},{hostnames:["figma.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/embed\/?$/)){const t=e.searchParams.get("url");if(t)return t}}},{hostnames:["google.*"],fromEmbedUrl:n=>{const e=Ze(n);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,i]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${s},${i},${r}z`}}},{hostnames:["val.town"],fromEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(t)return`https://www.val.town/v/${t[1]}`}},{hostnames:["codesandbox.io"],fromEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://codesandbox.io/s/${t[1]}`}},{hostnames:["codepen.io"],fromEmbedUrl:n=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,t=n.match(e);if(t){const[r,s,i]=t;return`https://codepen.io/${s}/pen/${i}`}}},{hostnames:["scratch.mit.edu"],fromEmbedUrl:n=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,t=n.match(e);if(t){const[r,s]=t;return`https://scratch.mit.edu/projects/${s}`}}},{hostnames:["*.youtube.com","youtube.com","youtu.be"],fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n),t=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&t){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",t),e.href}}},{hostnames:["docs.google.*"],fromEmbedUrl:n=>{const e=Ze(n);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const t=Array.from(e.searchParams.keys());for(const r of t)e.searchParams.delete(r);return e.href}}},{hostnames:["gist.github.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return n.split("/").pop()?n:void 0}},{hostnames:["replit.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{hostnames:["felt.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/embed\/map\//))return e.pathname=e.pathname.replace(/^\/embed/,""),e.href}},{hostnames:["open.spotify.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/embed\/(artist|album)\//))return e.origin+e.pathname.replace(/^\/embed/,"")}},{hostnames:["vimeo.com","player.vimeo.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.hostname==="player.vimeo.com"){const t=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(t)return"https://vimeo.com/"+t[1]}}},{hostnames:["excalidraw.com"],fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.hash.match(/#room=/))return n}},{hostnames:["observablehq.com"],fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return n.replace("?embed","")}}],k4={w:Pn,h:Pn,url:st},Tm=_i("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),I4={sequence:[{id:Tm.GenOriginalUrlInEmbed,up:n=>{try{const e=n.url,t=new URL(e).host.replace("www.","");let r;for(const s of Dte)if(s.hostnames.includes(t))try{r=s.fromEmbedUrl(e)}catch(i){console.warn(i)}n.tmpOldUrl=n.url,n.url=r??""}catch{n.url="",n.tmpOldUrl=n.url}},down:"retired"},{id:Tm.RemoveDoesResize,up:n=>{delete n.doesResize},down:"retired"},{id:Tm.RemoveTmpOldUrl,up:n=>{delete n.tmpOldUrl},down:"retired"},{id:Tm.RemovePermissionOverrides,up:n=>{delete n.overridePermissions},down:"retired"}]},E4={w:Pn,h:Pn,name:st,color:Hp(...Yr.values)},jte=_i("frame",{AddColorProp:1}),_4={sequence:[{id:jte.AddColorProp,up:n=>{n.color="black"},down:n=>{delete n.color}}]},FE=pt({type:st,content:Un(jee)});function Ei(n){return{type:"doc",content:n.split(`
|
|
183
|
-
`).map(r=>r?{type:"paragraph",content:[{type:"text",text:r}]}:{type:"paragraph"})}}const wS=ur.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),bS=ur.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),Xi=ur.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"]}),T4={geo:Xi,labelColor:jE,color:Yr,fill:ou,dash:iu,size:Uo,font:Na,align:wS,verticalAlign:bS,url:Zs,w:Pn,h:Pn,growY:gS,richText:FE,scale:Pn},Co=_i("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9,AddRichText:10}),M4={sequence:[{id:Co.AddUrlProp,up:n=>{n.url=""},down:"retired"},{id:Co.AddLabelColor,up:n=>{n.labelColor="black"},down:"retired"},{id:Co.RemoveJustify,up:n=>{n.align==="justify"&&(n.align="start")},down:"retired"},{id:Co.AddCheckBox,up:n=>{},down:"retired"},{id:Co.AddVerticalAlign,up:n=>{n.verticalAlign="middle"},down:"retired"},{id:Co.MigrateLegacyAlign,up:n=>{let e;switch(n.align){case"start":e="start-legacy";break;case"end":e="end-legacy";break;default:e="middle-legacy";break}n.align=e},down:"retired"},{id:Co.AddCloud,up:n=>{},down:"retired"},{id:Co.MakeUrlsValid,up:n=>{Zs.isValid(n.url)||(n.url="")},down:n=>{}},{id:Co.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}},{id:Co.AddRichText,up:n=>{n.richText=Ei(n.text),delete n.text}}]},A4={},O4={sequence:[]},R4={color:Yr,size:Uo,segments:Un(b4),isComplete:mt,isPen:mt,scale:Pn},Lte=_i("highlight",{AddScale:1}),D4={sequence:[{id:Lte.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}}]},Nte=pt({topLeft:su,bottomRight:su}),j4={w:Pn,h:Pn,playing:mt,url:Zs,assetId:G0.nullable(),crop:Nte.nullable(),flipX:mt,flipY:mt,altText:st},lf=_i("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4,AddAltText:5}),L4={sequence:[{id:lf.AddUrlProp,up:n=>{n.url=""},down:"retired"},{id:lf.AddCropProp,up:n=>{n.crop=null},down:n=>{delete n.crop}},{id:lf.MakeUrlsValid,up:n=>{Zs.isValid(n.url)||(n.url="")},down:n=>{}},{id:lf.AddFlipProps,up:n=>{n.flipX=!1,n.flipY=!1},down:n=>{delete n.flipX,delete n.flipY}},{id:lf.AddAltText,up:n=>{n.altText=""},down:n=>{delete n.altText}}]},CS=ur.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),Fte=pt({id:st,index:RE,x:Xe,y:Xe}),N4={color:Yr,dash:iu,size:Uo,spline:CS,points:mS(st,Fte),scale:Pn},cf=_i("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),F4={sequence:[{id:cf.AddSnapHandles,up:n=>{for(const e of Object.values(n.handles))e.canSnap=!0},down:"retired"},{id:cf.RemoveExtraHandleProps,up:n=>{n.handles=e3(Object.values(n.handles).map(e=>[e.index,{x:e.x,y:e.y}]))},down:n=>{const e=Object.entries(n.handles).map(([t,r])=>({index:t,...r})).sort(nr);n.handles=Object.fromEntries(e.map((t,r)=>{const s=r===0?"start":r===e.length-1?"end":`handle:${t.index}`;return[s,{id:s,type:"vertex",canBind:!1,canSnap:!0,index:t.index,x:t.x,y:t.y}]}))}},{id:cf.HandlesToPoints,up:n=>{const e=Object.entries(n.handles).map(([t,{x:r,y:s}])=>({x:r,y:s,index:t})).sort(nr);n.points=e.map(({x:t,y:r})=>({x:t,y:r})),delete n.handles},down:n=>{const e=ip(n.points.length);n.handles=Object.fromEntries(n.points.map((t,r)=>[e[r],{x:t.x,y:t.y}])),delete n.points}},{id:cf.PointIndexIds,up:n=>{const e=ip(n.points.length);n.points=Object.fromEntries(n.points.map((t,r)=>{const s=e[r];return[s,{id:s,index:s,x:t.x,y:t.y}]}))},down:n=>{const e=Object.values(n.points).sort(nr);n.points=e.map(({x:t,y:r})=>({x:t,y:r}))}},{id:cf.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}}]},z4={color:Yr,labelColor:jE,size:Uo,font:Na,fontSizeAdjustment:gS,align:wS,verticalAlign:bS,growY:gS,url:Zs,richText:FE,scale:Pn},fa=_i("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7,AddLabelColor:8,AddRichText:9}),$4={sequence:[{id:fa.AddUrlProp,up:n=>{n.url=""},down:"retired"},{id:fa.RemoveJustify,up:n=>{n.align==="justify"&&(n.align="start")},down:"retired"},{id:fa.MigrateLegacyAlign,up:n=>{switch(n.align){case"start":n.align="start-legacy";return;case"end":n.align="end-legacy";return;default:n.align="middle-legacy";return}},down:"retired"},{id:fa.AddVerticalAlign,up:n=>{n.verticalAlign="middle"},down:"retired"},{id:fa.MakeUrlsValid,up:n=>{Zs.isValid(n.url)||(n.url="")},down:n=>{}},{id:fa.AddFontSizeAdjustment,up:n=>{n.fontSizeAdjustment=0},down:n=>{delete n.fontSizeAdjustment}},{id:fa.AddScale,up:n=>{n.scale=1},down:n=>{delete n.scale}},{id:fa.AddLabelColor,up:n=>{n.labelColor="black"},down:n=>{delete n.labelColor}},{id:fa.AddRichText,up:n=>{n.richText=Ei(n.text),delete n.text}}]},fk=ur.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),B4={color:Yr,size:Uo,font:Na,textAlign:fk,w:Pn,richText:FE,scale:Pn,autoSize:mt},cC=_i("text",{RemoveJustify:1,AddTextAlign:2,AddRichText:3}),U4={sequence:[{id:cC.RemoveJustify,up:n=>{n.align==="justify"&&(n.align="start")},down:"retired"},{id:cC.AddTextAlign,up:n=>{n.textAlign=n.align,delete n.align},down:n=>{n.align=n.textAlign,delete n.textAlign}},{id:cC.AddRichText,up:n=>{n.richText=Ei(n.text),delete n.text}}]},H4={w:Pn,h:Pn,time:Xe,playing:mt,url:Zs,assetId:G0.nullable(),altText:st},uC=_i("video",{AddUrlProp:1,MakeUrlsValid:2,AddAltText:3}),K4={sequence:[{id:uC.AddUrlProp,up:n=>{n.url=""},down:"retired"},{id:uC.MakeUrlsValid,up:n=>{Zs.isValid(n.url)||(n.url="")},down:n=>{}},{id:uC.AddAltText,up:n=>{n.altText=""},down:n=>{delete n.altText}}]},Mm=Ts("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),zte=Od({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:Mm.RemoveCodeAndIconShapeTypes,scope:"store",up:n=>{for(const[e,t]of Is(n))t.typeName==="shape"&&(t.type==="icon"||t.type==="code")&&delete n[e]}},{id:Mm.AddInstancePresenceType,scope:"store",up(n){}},{id:Mm.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:n=>{for(const[e,t]of Is(n))t.typeName.match(/^(user|user_presence)$/)&&delete n[e]}},{id:Mm.RemoveUserDocument,scope:"store",up:n=>{for(const[e,t]of Is(n))t.typeName.match("user_document")&&delete n[e]}}]}),$te={arrow:{migrations:p4,props:f4},bookmark:{migrations:w4,props:x4},draw:{migrations:P4,props:C4},embed:{migrations:I4,props:k4},frame:{migrations:_4,props:E4},geo:{migrations:M4,props:T4},group:{migrations:O4,props:A4},highlight:{migrations:D4,props:R4},image:{migrations:L4,props:j4},line:{migrations:F4,props:N4},note:{migrations:$4,props:z4},text:{migrations:U4,props:B4},video:{migrations:K4,props:H4}},Bte={arrow:{migrations:m4,props:g4}};function Ute({shapes:n=$te,bindings:e=Bte,migrations:t}={}){const r=new Map;for(const a of gn(n))for(const l of l4(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=Yee(n),i=Vee(e),o=lte(r);return TE.create({asset:ql,binding:i,camera:jo,document:NE,instance:o,instance_page_state:Yi,page:Wr,instance_presence:yte,pointer:LE,shape:s},{migrations:[zte,Ote,Jee,vte,cte,dte,ote,mte,pte,Gee,kte,Ete,Tte,...lj("shape",n),...lj("binding",e),...t??[]],onValidationFailure:wte,createIntegrityChecker:Cte})}const mp=[{locale:"id",label:"Bahasa Indonesia"},{locale:"ms",label:"Bahasa Melayu"},{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:"tl",label:"Filipino"},{locale:"fr",label:"Français"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{locale:"nl",label:"Nederlands"},{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:"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:"el",label:"Ελληνικά"},{locale:"ru",label:"Русский"},{locale:"uk",label:"Українська"},{locale:"he",label:"עברית"},{locale:"ur",label:"اردو"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ne",label:"नेपाली"},{locale:"mr",label:"मराठी"},{locale:"hi-in",label:"हिन्दी"},{locale:"bn",label:"বাংলা"},{locale:"pa",label:"ਪੰਜਾਬੀ"},{locale:"gu-in",label:"ગુજરાતી"},{locale:"ta",label:"தமிழ்"},{locale:"te",label:"తెలుగు"},{locale:"kn",label:"ಕನ್ನಡ"},{locale:"ml",label:"മലയാളം"},{locale:"th",label:"ภาษาไทย"},{locale:"km-kh",label:"ភាសាខ្មែរ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function Hte(){const n=typeof window<"u"?window.navigator.languages??["en"]:["en"];return Kte(n)}function Kte(n){for(const e of n){const t=Wte(e);if(t)return t}return"en"}const pj={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function Wte(n){const e=mp.find(s=>s.locale===n.toLowerCase());if(e)return e.locale;const[t,r]=n.split(/[-_]/).map(s=>s.toLowerCase());if(r){const s=mp.find(i=>i.locale===t);if(s)return s.locale}return t in pj?pj[t]:null}Zl("@tldraw/tlschema","3.12.1","esm");var dC={exports:{}};/*!
|
|
184
|
-
Copyright (c) 2018 Jed Watson.
|
|
185
|
-
Licensed under the MIT License (MIT), see
|
|
186
|
-
http://jedwatson.github.io/classnames
|
|
187
|
-
*/var gj;function Vte(){return gj||(gj=1,function(n){(function(){var e={}.hasOwnProperty;function t(){for(var i="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(i=s(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return t.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var o="";for(var a in i)e.call(i,a)&&i[a]&&(o=s(o,a));return o}function s(i,o){return o?i?i+" "+o:i+o:i}n.exports?(t.default=t,n.exports=t):window.classNames=t})()}(dC)),dC.exports}var qte=Vte();const $e=Ua(qte),W4="3.12.1",mj={major:"2024-09-13T14:36:29.063Z",minor:"2025-04-15T13:47:42.642Z"},Gte={error:null};class zE extends P.Component{constructor(){super(...arguments);R(this,"state",Gte)}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){var r,s;(s=(r=this.props).onError)==null||s.call(r,t)}render(){const{error:t}=this.state;if(t!==null){const{fallback:r}=this.props;return g.jsx(r,{error:t})}return this.props.children}}function yp({children:n,fallback:e,...t}){return e===null?n:g.jsx(zE,{fallback:e,...t,children:n})}function $E(n,e){return Y0(`${n}_${e}`)}function vu(n){return Y0(`${P.useId()}${n??""}`)}function Qi(n){const e=zr(P.useContext(V4));return Y0(`${e}_${n}`)}function Y0(n){return n.replace(/:/g,"_")}const V4=P.createContext(null);function Yte({children:n}){const e=vu();return g.jsx(V4.Provider,{value:e,children:n})}const BE=P.createContext(null);function te(){const n=at.useContext(BE);if(!n)throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return n}function dr(){return at.useContext(BE)}function UE({editor:n,children:e}){return g.jsx(BE.Provider,{value:n,children:g.jsx(Yte,{children:e})})}function Xte(){return g.jsx("div",{className:"tl-background"})}function uh(n,e,t,r,s,i){P.useLayoutEffect(()=>{const o=n.current;if(!o||e===void 0)return;let a=`translate(${e}px, ${t}px)`;r!==void 0&&(a+=` scale(${r})`),s!==void 0&&(a+=` rotate(${s}rad)`),i&&(a+=` translate(${i.x}px, ${i.y}px)`),o.style.transform=a})}const hC=({brush:n,color:e,opacity:t,className:r})=>{const s=P.useRef(null);uh(s,n.x,n.y);const i=re(Math.max(1,n.w)),o=re(Math.max(1,n.h));return g.jsx("svg",{className:"tl-overlays__item",ref:s,children:e?g.jsxs("g",{className:"tl-brush",opacity:t,children:[g.jsx("rect",{width:i,height:o,fill:e,opacity:.75}),g.jsx("rect",{width:i,height:o,fill:"none",stroke:e,opacity:.1})]}):g.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:i,height:o})})},It={isSafari:!1,isIos:!1,isChromeForIos:!1,isFirefox:!1,isAndroid:!1,isWebview:!1,isDarwin:!1,hasCanvasSupport:!1};typeof window<"u"&&"navigator"in window&&(It.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),It.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),It.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),It.isFirefox=/firefox/i.test(navigator.userAgent),It.isAndroid=/android/i.test(navigator.userAgent),It.isDarwin=window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,It.hasCanvasSupport=typeof window<"u"&&"Promise"in window&&"HTMLCanvasElement"in window);const yj={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.05,.1,.25,.5,1,2,4,8]},fC={duration:0,easing:Hn.easeInOutCubic},Sj={CAMERA_MOVE:-10},Zte=["top","right","bottom","left"],vj=0,HE=2,Am=1,xj=5,Jte=128;var pC={};const Qte={},q4=Nr("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),ln={logPreventDefaults:Nr("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:Nr("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:Nr("logElementRemoves",{defaults:{all:!1}}),debugSvg:Nr("debugSvg",{defaults:{all:!1}}),showFps:Nr("showFps",{defaults:{all:!1}}),measurePerformance:Nr("measurePerformance",{defaults:{all:!1}}),throwToBlob:Nr("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:Nr("reconnectOnPing",{defaults:{all:!1}}),debugCursors:Nr("debugCursors",{defaults:{all:!1}}),forceSrgb:Nr("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:Nr("debugGeometry",{defaults:{all:!1}}),hideShapes:Nr("hideShapes",{defaults:{all:!1}}),editOnType:Nr("editOnType",{defaults:{all:!1}}),a11y:Nr("a11y",{defaults:{all:!1}})};if(typeof Element<"u"){const n=Element.prototype.removeChild;Pi("element removal logging",()=>{ln.logElementRemoves.get()?Element.prototype.removeChild=function(e){return console.warn("[tldraw] removing child:",e),n.call(this,e)}:Element.prototype.removeChild=n})}function Nr(n,{defaults:e,shouldStoreForSession:t=!0}){return ene({name:n,defaults:e,shouldStoreForSession:t})}function ene(n){const e=nne(n),t=n.shouldStoreForSession?tne(n.name):null,r=Sn(`debug:${n.name}`,t??e);return typeof window<"u"&&(n.shouldStoreForSession&&Pi(`debug:${n.name}`,()=>{const s=r.get();s===e?g3(`tldraw_debug:${n.name}`):TI(`tldraw_debug:${n.name}`,JSON.stringify(s))}),Object.defineProperty(window,`tldraw${n.name.replace(/^[a-z]/,s=>s.toUpperCase())}`,{get(){return r.get()},set(s){r.set(s)},configurable:!0})),Object.assign(r,n)}function tne(n){try{return JSON.parse(p3(`tldraw_debug:${n}`)??"null")}catch{return null}}function gC(n){try{return n()}catch{return null}}function nne(n){switch(gC(()=>pC.TLDRAW_ENV)??gC(()=>pC.VERCEL_PUBLIC_TLDRAW_ENV)??gC(()=>pC.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return n.defaults.production??n.defaults.all;case"preview":case"staging":return n.defaults.staging??n.defaults.all;default:return n.defaults.development??n.defaults.all}}function PS(n){if(n instanceof HTMLElement)return n;if(n.parentElement)return PS(n.parentElement);throw Error("Could not find a parent element of an HTML type!")}function tt(n){n.preventDefault(),ln.logPreventDefaults.get()&&console.warn("preventDefault called on event:",n)}function Kp(n,e){if(n.setPointerCapture(e.pointerId),ln.logPointerCaptures.get()){const t=q4.get();t.set(n,(t.get(n)??0)+1),console.warn("setPointerCapture called on element:",n,e)}}function Wp(n,e){if(n.hasPointerCapture(e.pointerId)&&(n.releasePointerCapture(e.pointerId),ln.logPointerCaptures.get())){const t=q4.get();t.get(n)===1?t.delete(n):t.has(n)?t.set(n,t.get(n)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",n,e)}}const Wt=n=>n.stopPropagation(),Sr=(n,e,t)=>{n&&n.style.setProperty(e,t)},rne=["input","select","button","textarea"];function G4(){const{activeElement:n}=document;return!!(n&&(n.isContentEditable||rne.indexOf(n.tagName.toLowerCase())>-1))}const Pr=n=>It.isDarwin?n.metaKey:n.ctrlKey||n.metaKey;function Ks(n){return n.isKilled=!0,{point:{x:n.clientX,y:n.clientY,z:n.pressure},shiftKey:n.shiftKey,altKey:n.altKey,ctrlKey:n.metaKey||n.ctrlKey,metaKey:n.metaKey,accelKey:Pr(n),pointerId:n.pointerId,button:n.button,isPen:n.pointerType==="pen"}}function KE(){const n=te(),e=ie("current tool",()=>n.getCurrentTool(),[n]);return P.useMemo(function(){let s,i;function o(v){if(!v.isKilled){if(v.button===HE){n.dispatch({type:"pointer",target:"canvas",name:"right_click",...Ks(v)});return}v.button!==0&&v.button!==1&&v.button!==5||(Kp(v.currentTarget,v),n.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...Ks(v)}))}}function a(v){if(v.isKilled||v.clientX===s&&v.clientY===i)return;s=v.clientX,i=v.clientY;const w=e.useCoalescedEvents&&v.nativeEvent.getCoalescedEvents?v.nativeEvent.getCoalescedEvents():[v];for(const C of w)n.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...Ks(C)})}function l(v){v.isKilled||v.button!==0&&v.button!==1&&v.button!==2&&v.button!==5||(s=v.clientX,i=v.clientY,Wp(v.currentTarget,v),n.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...Ks(v)}))}function c(v){if(v.isKilled||n.getInstanceState().isPenMode&&v.pointerType!=="pen")return;const w=v.pointerType==="mouse"||v.pointerType==="pen";n.updateInstanceState({isHoveringCanvas:w?!0:null})}function u(v){if(v.isKilled||n.getInstanceState().isPenMode&&v.pointerType!=="pen")return;const w=v.pointerType==="mouse"||v.pointerType==="pen";n.updateInstanceState({isHoveringCanvas:w?!1:null})}function h(v){v.isKilled=!0,tt(v)}function p(v){v.isKilled=!0,v.target instanceof HTMLElement&&v.target.tagName!=="A"&&v.target.tagName!=="TEXTAREA"&&!v.target.isContentEditable&&!(n.getEditingShape()&&v.target.className.includes("tl-text-content"))&&tt(v)}function m(v){tt(v)}async function S(v){var C,_;if(tt(v),Wt(v),(_=(C=v.dataTransfer)==null?void 0:C.files)!=null&&_.length){const E=Array.from(v.dataTransfer.files);await n.putExternalContent({type:"files",files:E,point:n.screenToPage({x:v.clientX,y:v.clientY}),ignoreParent:!1});return}const w=v.dataTransfer.getData("url");if(w){await n.putExternalContent({type:"url",url:w,point:n.screenToPage({x:v.clientX,y:v.clientY})});return}}function x(v){Wt(v)}return{onPointerDown:o,onPointerMove:a,onPointerUp:l,onPointerEnter:c,onPointerLeave:u,onDragOver:m,onDrop:S,onTouchStart:h,onTouchEnd:p,onClick:x}},[n,e])}function sne(){const n=te();P.useEffect(()=>{let e=n.getInstanceState().isCoarsePointer;const t=o=>{const a=o.pointerType!=="mouse";e!==a&&(e=a,n.updateInstanceState({isCoarsePointer:a}))};window.addEventListener("pointerdown",t,{capture:!0});const r=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),s=It.isFirefox&&!It.isAndroid&&!It.isIos,i=()=>{const o=s?!1:r.matches;e===o&&(e=o,n.updateInstanceState({isCoarsePointer:o}))};return r&&(r.addEventListener("change",i),i()),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),r&&r.removeEventListener("change",i)}},[n])}const Y4=P.createContext(null);function X4({container:n,children:e}){return g.jsx(Y4.Provider,{value:n,children:e})}function kn(){return zr(P.useContext(Y4),"useContainer used outside of <Tldraw />")}function ine(){const n=te(),e=kn(),t=ie("isFocused",()=>n.getIsFocused(),[n]);P.useEffect(()=>{if(!e)return;function r(s){if(s.isSpecialRedispatchedEvent)return;tt(s),Wt(s);const i=e.querySelector(".tl-canvas");if(!i)return;const o=new DragEvent(s.type,s);o.isSpecialRedispatchedEvent=!0,i.dispatchEvent(o)}return e.addEventListener("dragover",r),e.addEventListener("drop",r),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",r)}},[e]),P.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;let r=null;const s=()=>{r!=null&&r();const i=`(resolution: ${window.devicePixelRatio}dppx)`,o=matchMedia(i),a=l=>{l.type==="change"&&s()};o.addEventListener?o.addEventListener("change",s):o.addListener&&o.addListener(a),r=()=>{o.removeEventListener?o.removeEventListener("change",s):o.removeListener&&o.removeListener(a)},n.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return s(),()=>{r==null||r()}},[n]),P.useEffect(()=>{if(!t)return;const r=a=>{if(a.altKey&&(n.isIn("zoom")||!n.getPath().endsWith(".idle"))&&!uf(n)&&tt(a),a.isKilled)return;a.isKilled=!0;const l=!!n.getSelectedShapeIds().length;switch(a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){tt(a);return}break}case"Tab":{if(uf(n))return;l&&tt(a);break}case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(uf(n))return;l&&(a.metaKey||a.ctrlKey)&&tt(a);break}case",":return;case"Escape":{if((n.getEditingShape()||n.getSelectedShapeIds().length>0)&&tt(a),n.menus.getOpenMenus().length>0)return;n.inputs.keys.has("Escape")||(n.inputs.keys.add("Escape"),n.cancel(),e.focus());return}default:if(uf(n))return}const c={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:Pr(a)};n.dispatch(c)},s=a=>{if(a.isKilled||(a.isKilled=!0,uf(n))||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:Pr(a)};n.dispatch(l)};function i(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>n.getViewportScreenBounds().width-10)&&(((l=a.target)==null?void 0:l.tagName)==="BUTTON"&&((c=a.target)==null||c.click()),tt(a))}}const o=a=>{e.contains(a.target)&&(a.ctrlKey||a.metaKey)&&tt(a)};return e.addEventListener("touchstart",i,{passive:!1}),e.addEventListener("wheel",o,{passive:!1}),document.addEventListener("gesturestart",tt),document.addEventListener("gesturechange",tt),document.addEventListener("gestureend",tt),e.addEventListener("keydown",r),e.addEventListener("keyup",s),()=>{e.removeEventListener("touchstart",i),e.removeEventListener("wheel",o),document.removeEventListener("gesturestart",tt),document.removeEventListener("gesturechange",tt),document.removeEventListener("gestureend",tt),e.removeEventListener("keydown",r),e.removeEventListener("keyup",s)}},[n,e,t])}function uf(n){return n.menus.hasOpenMenus()||G4()}const one=["textarea","input"];function ane(n){const e=te();P.useEffect(()=>{const t=n.current;if(!t)return;const r=s=>{var i;if(s instanceof PointerEvent&&s.pointerType==="pen"){s.isKilled=!0;const{target:o}=s;if(one.includes((i=o.tagName)==null?void 0:i.toLocaleLowerCase())||o.isContentEditable||e.isIn("select.editing_shape"))return;tt(s)}};return t.addEventListener("touchstart",r),t.addEventListener("touchend",r),()=>{t.removeEventListener("touchstart",r),t.removeEventListener("touchend",r)}},[e,n])}function lne(n,e,t){return Math.max(e,Math.min(n,t))}const or={toVector(n,e){return n===void 0&&(n=e),Array.isArray(n)?n:[n,n]},add(n,e){return[n[0]+e[0],n[1]+e[1]]},sub(n,e){return[n[0]-e[0],n[1]-e[1]]},addTo(n,e){n[0]+=e[0],n[1]+=e[1]},subTo(n,e){n[0]-=e[0],n[1]-=e[1]}};function wj(n,e,t){return e===0||Math.abs(e)===1/0?Math.pow(n,t*5):n*e*t/(e+t*n)}function bj(n,e,t,r=.15){return r===0?lne(n,e,t):n<e?-wj(e-n,t-e,r)+e:n>t?+wj(n-t,t-e,r)+t:n}function cne(n,[e,t],[r,s]){const[[i,o],[a,l]]=n;return[bj(e,i,o,r),bj(t,a,l,s)]}function une(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function dne(n){var e=une(n,"string");return typeof e=="symbol"?e:String(e)}function br(n,e,t){return e=dne(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Cj(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function cn(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Cj(Object(t),!0).forEach(function(r){br(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Cj(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const Z4={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 Pj(n){return n?n[0].toUpperCase()+n.slice(1):""}const hne=["enter","leave"];function fne(n=!1,e){return n&&!hne.includes(e)}function pne(n,e="",t=!1){const r=Z4[n],s=r&&r[e]||e;return"on"+Pj(n)+Pj(s)+(fne(t,s)?"Capture":"")}const gne=["gotpointercapture","lostpointercapture"];function mne(n){let e=n.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const r=gne.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(r);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function yne(n,e=""){const t=Z4[n],r=t&&t[e]||e;return n+r}function J4(n){return"touches"in n}function Sne(n){return J4(n)?"touch":"pointerType"in n?n.pointerType:"mouse"}function vne(n){return Array.from(n.touches).filter(e=>{var t,r;return e.target===n.currentTarget||((t=n.currentTarget)===null||t===void 0||(r=t.contains)===null||r===void 0?void 0:r.call(t,e.target))})}function pk(n,e){try{const t=e.clientX-n.clientX,r=e.clientY-n.clientY,s=(e.clientX+n.clientX)/2,i=(e.clientY+n.clientY)/2,o=Math.hypot(t,r);return{angle:-(Math.atan2(t,r)*180)/Math.PI,distance:o,origin:[s,i]}}catch{}return null}function xne(n){return vne(n).map(e=>e.identifier)}function kj(n,e){const[t,r]=Array.from(n.touches).filter(s=>e.includes(s.identifier));return pk(t,r)}const Ij=40,Ej=800;function Q4(n){let{deltaX:e,deltaY:t,deltaMode:r}=n;return r===1?(e*=Ij,t*=Ij):r===2&&(e*=Ej,t*=Ej),[e,t]}function wne(n){const e={};if("buttons"in n&&(e.buttons=n.buttons),"shiftKey"in n){const{shiftKey:t,altKey:r,metaKey:s,ctrlKey:i}=n;Object.assign(e,{shiftKey:t,altKey:r,metaKey:s,ctrlKey:i})}return e}function kS(n,...e){return typeof n=="function"?n(...e):n}function bne(){}function Cne(...n){return n.length===0?bne:n.length===1?n[0]:function(){let e;for(const t of n)e=t.apply(this,arguments)||e;return e}}function _j(n,e){return Object.assign({},e,n||{})}const Pne=32;class ez{constructor(e,t,r){this.ctrl=e,this.args=t,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:t,ingKey:r,args:s}=this;t[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 t=this.state,r=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=r.from?kS(r.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:r,shared:s}=this;t.args=this.args;let i=0;if(e&&(t.event=e,r.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,wne(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const A=t._delta.map(Math.abs);or.addTo(t._distance,A)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[l,c]=r.threshold,{_step:u,values:h}=t;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=l&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=l&&Math.sign(o)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[A,O]=h;p[0]=u[0]!==!1?A-u[0]:0,p[1]=u[1]!==!1?O-u[1]:0}else p[0]=u[0]!==!1?o-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(p);const m=t.offset,S=t._active&&!t._blocked||t.active;S&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in r&&(t._bounds=kS(r.bounds,t)),this.setup&&this.setup()),t.movement=p,this.computeOffset()));const[x,v]=t.offset,[[w,C],[_,E]]=t._bounds;t.overflow=[x<w?-1:x>C?1:0,v<_?-1:v>E?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const T=t._active?r.rubberband||[0,0]:[0,0];if(t.offset=cne(t._bounds,t.offset,T),t.delta=or.sub(t.offset,m),this.computeMovement(),S&&(!t.last||i>Pne)){t.delta=or.sub(t.offset,m);const A=t.delta.map(Math.abs);or.addTo(t.distance,A),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[A[0]/i,A[1]/i],t.timeDelta=i)}}emit(){const e=this.state,t=this.shared,r=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!r.triggerAllEvents)return;const s=this.handler(cn(cn(cn({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function kne([n,e],t){const r=Math.abs(n),s=Math.abs(e);if(r>s&&r>t)return"x";if(s>r&&s>t)return"y"}class Ine extends ez{constructor(...e){super(...e),br(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=or.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=or.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,r=this.config;if(!t.axis&&e){const s=typeof r.axisThreshold=="object"?r.axisThreshold[Sne(e)]:r.axisThreshold;t.axis=kne(t._movement,s)}t._blocked=(r.lockDirection||!!r.axis)&&!t.axis||!!r.axis&&r.axis!==t.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 Ene=n=>n,Tj=.15,tz={enabled(n=!0){return n},eventOptions(n,e,t){return cn(cn({},t.shared.eventOptions),n)},preventDefault(n=!1){return n},triggerAllEvents(n=!1){return n},rubberband(n=0){switch(n){case!0:return[Tj,Tj];case!1:return[0,0];default:return or.toVector(n)}},from(n){if(typeof n=="function")return n;if(n!=null)return or.toVector(n)},transform(n,e,t){const r=n||t.shared.transform;return this.hasCustomTransform=!!r,r||Ene},threshold(n){return or.toVector(n,0)}},_ne=0,Vp=cn(cn({},tz),{},{axis(n,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(n=_ne){return n},bounds(n={}){if(typeof n=="function")return i=>Vp.bounds(n(i));if("current"in n)return()=>n.current;if(typeof HTMLElement=="function"&&n instanceof HTMLElement)return n;const{left:e=-1/0,right:t=1/0,top:r=-1/0,bottom:s=1/0}=n;return[[e,t],[r,s]]}}),qp=typeof window<"u"&&window.document&&window.document.createElement;function nz(){return qp&&"ontouchstart"in window}function Tne(){return nz()||qp&&window.navigator.maxTouchPoints>1}function Mne(){return qp&&"onpointerdown"in window}function Ane(){return qp&&"exitPointerLock"in window.document}function One(){try{return"constructor"in GestureEvent}catch{return!1}}const Si={isBrowser:qp,gesture:One(),touch:nz(),touchscreen:Tne(),pointer:Mne(),pointerLock:Ane()},Rne=250,Dne=180,jne=.5,Lne=50,Nne=250,Fne=10,Mj={mouse:0,touch:0,pen:8};cn(cn({},Vp),{},{device(n,e,{pointer:{touch:t=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&Si.pointerLock,Si.touch&&t?"touch":this.pointerLock?"mouse":Si.pointer&&!s?"pointer":Si.touch?"touch":"mouse"},preventScrollAxis(n,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&n?Rne:void 0,!(!Si.touchscreen||t===!1))return n||(t!==void 0?"y":void 0)},pointerCapture(n,e,{pointer:{capture:t=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(n,e,{filterTaps:t=!1,tapsThreshold:r=3,axis:s=void 0}){const i=or.toVector(n,t?r:s?1:0);return this.filterTaps=t,this.tapsThreshold=r,i},swipe({velocity:n=jne,distance:e=Lne,duration:t=Nne}={}){return{velocity:this.transform(or.toVector(n)),distance:this.transform(or.toVector(e)),duration:t}},delay(n=0){switch(n){case!0:return Dne;case!1:return 0;default:return n}},axisThreshold(n){return n?cn(cn({},Mj),n):Mj},keyboardDisplacement(n=Fne){return n}});function rz(n){const[e,t]=n.overflow,[r,s]=n._delta,[i,o]=n._direction;(e<0&&r>0&&i<0||e>0&&r<0&&i>0)&&(n._movement[0]=n._movementBound[0]),(t<0&&s>0&&o<0||t>0&&s<0&&o>0)&&(n._movement[1]=n._movementBound[1])}const zne=30,$ne=100;class Bne extends ez{constructor(...e){super(...e),br(this,"ingKey","pinching"),br(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:t,lastOffset:r}=this.state;e==="wheel"?this.state.offset=or.add(t,r):this.state.offset=[(1+t[0])*r[0],t[1]+r[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,r]=e._movement;if(!e.axis){const s=Math.abs(t)*zne-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 t=this.state,r=this.ctrl.touchIds;if(t._active&&t._touchIds.every(i=>r.has(i))||r.size<2)return;this.start(e),t._touchIds=Array.from(r).slice(0,2);const s=kj(e,t._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 t=this.state,r=t._pointerEvents,s=this.ctrl.pointerIds;if(t._active&&Array.from(r.keys()).every(o=>s.has(o))||(r.size<2&&r.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const i=pk(...Array.from(r.values()));i&&this.pinchStart(e,i)}pinchStart(e,t){const r=this.state;r.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=kj(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const r=pk(...Array.from(t.values()));r&&this.pinchMove(e,r)}pinchMove(e,t){const r=this.state,s=r._values[1],i=t.angle-s;let o=0;Math.abs(i)>270&&(o+=Math.sign(i)),this.computeValues([t.distance,t.angle-360*o]),r.origin=t.origin,r.turns=o,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(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const r=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=or.sub(t._movement,r),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(r=>e[r]):!e[t])||(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=[-Q4(e)[1]/$ne*r.offset[0],0],or.addTo(r._movement,r._delta),rz(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 t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const Une=cn(cn({},tz),{},{device(n,e,{shared:t,pointer:{touch:r=!1}={}}){if(t.target&&!Si.touch&&Si.gesture)return"gesture";if(Si.touch&&r)return"touch";if(Si.touchscreen){if(Si.pointer)return"pointer";if(Si.touch)return"touch"}},bounds(n,e,{scaleBounds:t={},angleBounds:r={}}){const s=o=>{const a=_j(kS(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},i=o=>{const a=_j(kS(r,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof r!="function"?[s(),i()]:o=>[s(o),i(o)]},threshold(n,e,t){return this.lockDirection=t.axis==="lock",or.toVector(n,this.lockDirection?[.1,3]:0)},modifierKey(n){return n===void 0?"ctrlKey":n},pinchOnWheel(n=!0){return n}});cn(cn({},Vp),{},{mouseOnly:(n=!0)=>n});class Hne extends Ine{constructor(...e){super(...e),br(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 t=this.state;t._delta=Q4(e),or.addTo(t._movement,t._delta),rz(t),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 Kne=Vp;cn(cn({},Vp),{},{mouseOnly:(n=!0)=>n});const WE=new Map,gk=new Map;function Wne(n){WE.set(n.key,n.engine),gk.set(n.key,n.resolver)}const Vne={key:"pinch",engine:Bne,resolver:Une},qne={key:"wheel",engine:Hne,resolver:Kne};function Gne(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}function Yne(n,e){if(n==null)return{};var t=Gne(n,e),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(s=0;s<i.length;s++)r=i[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(t[r]=n[r])}return t}const Xne={target(n){if(n)return()=>"current"in n?n.current:n},enabled(n=!0){return n},window(n=Si.isBrowser?window:void 0){return n},eventOptions({passive:n=!0,capture:e=!1}={}){return{passive:n,capture:e}},transform(n){return n}},Zne=["target","eventOptions","window","enabled","transform"];function gy(n={},e){const t={};for(const[r,s]of Object.entries(e))switch(typeof s){case"function":t[r]=s.call(t,n[r],r,n);break;case"object":t[r]=gy(n[r],s);break;case"boolean":s&&(t[r]=n[r]);break}return t}function Jne(n,e,t={}){const r=n,{target:s,eventOptions:i,window:o,enabled:a,transform:l}=r,c=Yne(r,Zne);if(t.shared=gy({target:s,eventOptions:i,window:o,enabled:a,transform:l},Xne),e){const u=gk.get(e);t[e]=gy(cn({shared:t.shared},c),u)}else for(const u in c){const h=gk.get(u);h&&(t[u]=gy(cn({shared:t.shared},c[u]),h))}return t}class sz{constructor(e,t){br(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,r,s,i){const o=this._listeners,a=yne(t,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=cn(cn({},l),i);e.addEventListener(a,s,c);const u=()=>{e.removeEventListener(a,s,c),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Qne{constructor(){br(this,"_timeouts",new Map)}add(e,t,r=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,r,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class ere{constructor(e){br(this,"gestures",new Set),br(this,"_targetEventStore",new sz(this)),br(this,"gestureEventStores",{}),br(this,"gestureTimeoutStores",{}),br(this,"handlers",{}),br(this,"config",{}),br(this,"pointerIds",new Set),br(this,"touchIds",new Set),br(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),tre(this,e)}setEventIds(e){if(J4(e))return this.touchIds=new Set(xne(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,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=Jne(e,t,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 t=this.config.shared,r={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],l=Aj(r,a.eventOptions,!!s);if(a.enabled){const c=WE.get(o);new c(this,e,o).bind(l)}}const i=Aj(r,t.eventOptions,!!s);for(const o in this.nativeHandlers)i(o,"",a=>this.nativeHandlers[o](cn(cn({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in r)r[i]=Cne(...r[i]);if(!s)return r;for(const i in r){const{device:o,capture:a,passive:l}=mne(i);this._targetEventStore.add(s,o,"",r[i],{capture:a,passive:l})}}}}function ld(n,e){n.gestures.add(e),n.gestureEventStores[e]=new sz(n,e),n.gestureTimeoutStores[e]=new Qne}function tre(n,e){e.drag&&ld(n,"drag"),e.wheel&&ld(n,"wheel"),e.scroll&&ld(n,"scroll"),e.move&&ld(n,"move"),e.pinch&&ld(n,"pinch"),e.hover&&ld(n,"hover")}const Aj=(n,e,t)=>(r,s,i,o={},a=!1)=>{var l,c;const u=(l=o.capture)!==null&&l!==void 0?l:e.capture,h=(c=o.passive)!==null&&c!==void 0?c:e.passive;let p=a?r:pne(r,s,u);t&&h&&(p+="Passive"),n[p]=n[p]||[],n[p].push(i)},nre=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function rre(n){const e={},t={},r=new Set;for(let s in n)nre.test(s)?(r.add(RegExp.lastMatch),t[s]=n[s]):e[s]=n[s];return[t,e,r]}function cd(n,e,t,r,s,i){if(!n.has(t)||!WE.has(r))return;const o=t+"Start",a=t+"End",l=c=>{let u;return c.first&&o in e&&e[o](c),t in e&&(u=e[t](c)),c.last&&a in e&&e[a](c),u};s[r]=l,i[r]=i[r]||{}}function sre(n,e){const[t,r,s]=rre(n),i={};return cd(s,t,"onDrag","drag",i,e),cd(s,t,"onWheel","wheel",i,e),cd(s,t,"onScroll","scroll",i,e),cd(s,t,"onPinch","pinch",i,e),cd(s,t,"onMove","move",i,e),cd(s,t,"onHover","hover",i,e),{handlers:i,config:e,nativeHandlers:r}}function ire(n,e={},t,r){const s=at.useMemo(()=>new ere(n),[]);if(s.applyHandlers(n,r),s.applyConfig(e,t),at.useEffect(s.effect.bind(s)),at.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function ore(n){return n.forEach(Wne),function(t,r){const{handlers:s,nativeHandlers:i,config:o}=sre(t,r||{});return ire(s,o,void 0,i)}}const Oj=10,are=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function iz(n){let{deltaY:e,deltaX:t}=n,r=0;return n.ctrlKey||n.altKey||n.metaKey?r=(Math.abs(e)>Oj?Oj*Math.sign(e):e)/100:n.shiftKey&&!are&&(t=e,e=0),{x:-t,y:-e,z:-r}}const lre=ore([qne,Vne]);let ud;const cre=n=>ud===void 0?(ud=n,!1):n-ud>120&&n-ud<160?(ud=n,!0):(ud=n,!1);function ure(n){const e=te(),t=P.useMemo(()=>{let r="not sure";const s=({event:S})=>{if(!e.getInstanceState().isFocused||(r="not sure",cre(Date.now())))return;const x=e.getEditingShapeId();if(x){const C=e.getShape(x);if(C&&e.getShapeUtil(C).canScroll(C)){const E=e.getShapePageBounds(x);if(E!=null&&E.containsPoint(e.inputs.currentPagePoint))return}}tt(S),Wt(S);const v=iz(S);if(v.x===0&&v.y===0)return;const w={type:"wheel",name:"wheel",delta:v,point:new k(S.clientX,S.clientY),shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey,metaKey:S.metaKey,accelKey:Pr(S)};e.dispatch(w)};let i=1,o=1,a=0;const l=new k,c=new k,u=S=>{const x=n.current;r="not sure";const{event:v,origin:w,da:C}=S;v instanceof WheelEvent||(v.target===x||x!=null&&x.contains(v.target))&&(c.x=w[0],c.y=w[1],l.x=w[0],l.y=w[1],i=C[0],o=e.getZoomLevel(),e.dispatch({type:"pinch",name:"pinch_start",point:{x:w[0],y:w[1],z:e.getZoomLevel()},delta:{x:0,y:0},shiftKey:v.shiftKey,altKey:v.altKey,ctrlKey:v.metaKey||v.ctrlKey,metaKey:v.metaKey,accelKey:Pr(v)}))},h=S=>{if(S&&(r="zooming"),r==="zooming")return;const x=Math.abs(a-i),v=k.Dist(l,c);switch(r){case"not sure":{x>24?r="zooming":v>16&&(r="panning");break}case"panning":{x>64&&(r="zooming");break}}};return{onWheel:s,onPinchStart:u,onPinchEnd:S=>{const x=n.current,{event:v,origin:w,offset:C}=S;if(v instanceof WheelEvent||!(v.target===x||x!=null&&x.contains(v.target)))return;const _=C[0]**e.getCameraOptions().zoomSpeed;r="not sure",e.timers.requestAnimationFrame(()=>{e.dispatch({type:"pinch",name:"pinch_end",point:{x:w[0],y:w[1],z:_},delta:{x:w[0],y:w[1]},shiftKey:v.shiftKey,altKey:v.altKey,ctrlKey:v.metaKey||v.ctrlKey,metaKey:v.metaKey,accelKey:Pr(v)})})},onPinch:S=>{const x=n.current,{event:v,origin:w,offset:C,da:_}=S;if(v instanceof WheelEvent||!(v.target===x||x!=null&&x.contains(v.target)))return;const E=S.type==="gesturechange"||S.type==="gestureend";a=_[0];const T=w[0]-c.x,A=w[1]-c.y;switch(c.x=w[0],c.y=w[1],h(E),r){case"zooming":{const O=C[0]**e.getCameraOptions().zoomSpeed;e.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:O},delta:{x:T,y:A},shiftKey:v.shiftKey,altKey:v.altKey,ctrlKey:v.metaKey||v.ctrlKey,metaKey:v.metaKey,accelKey:Pr(v)});break}case"panning":{e.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:o},delta:{x:T,y:A},shiftKey:v.shiftKey,altKey:v.altKey,ctrlKey:v.metaKey||v.ctrlKey,metaKey:v.metaKey,accelKey:Pr(v)});break}}}}},[e,n]);lre(t,{target:n,eventOptions:{passive:!1},pinch:{from:()=>{const{zoomSpeed:r}=e.getCameraOptions();return[e.getZoomLevel()**(1/r),0]},scaleBounds:()=>{const r=e.getBaseZoom(),{zoomSteps:s,zoomSpeed:i}=e.getCameraOptions(),o=s[0]*r;return{max:(s[s.length-1]*r)**(1/i),min:o**(1/i)}}}})}function mC(n,e,t){const r=n.getShape(e),s=n.getShapeHandles(r);return{shape:r,handle:s.find(i=>i.id===t)}}function dre(n,e){const t=te();return P.useMemo(()=>{const r=l=>{if(l.isKilled)return;const c=PS(l.currentTarget);Kp(c,l);const{shape:u,handle:h}=mC(t,n,e);h&&t.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_down",...Ks(l)})};let s,i;return{onPointerDown:r,onPointerMove:l=>{if(l.isKilled||l.clientX===s&&l.clientY===i)return;s=l.clientX,i=l.clientY;const{shape:c,handle:u}=mC(t,n,e);u&&t.dispatch({type:"pointer",target:"handle",handle:u,shape:c,name:"pointer_move",...Ks(l)})},onPointerUp:l=>{if(l.isKilled)return;const c=PS(l.currentTarget);Wp(c,l);const{shape:u,handle:h}=mC(t,n,e);h&&t.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_up",...Ks(l)})}}},[t,n,e])}function hre(n){const e=te();P.useLayoutEffect(()=>{const t=VN(()=>{n.current&&e.updateViewportScreenBounds(n.current)},200,{trailing:!0}),r=e.timers.setInterval(t,1e3);window.addEventListener("resize",t);const s=new ResizeObserver(a=>{a[0].contentRect&&t()}),i=n.current;let o=null;return i&&(s.observe(i),o=fre(i),o.addEventListener("scroll",t)),()=>{clearInterval(r),window.removeEventListener("resize",t),s.disconnect(),o==null||o.removeEventListener("scroll",t),t.cancel()}},[e,n])}/*!
|
|
188
|
-
* Author: excalidraw
|
|
189
|
-
* MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
|
|
190
|
-
* https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
|
|
191
|
-
*/const fre=n=>{let e=n.parentElement;for(;e;){if(e===document.body)return document;const{overflowY:t}=window.getComputedStyle(e);if(e.scrollHeight>e.clientHeight&&(t==="auto"||t==="scroll"||t==="overlay"))return e;e=e.parentElement}return document};class Se{constructor(e=0,t=0,r=0,s=0){R(this,"x",0);R(this,"y",0);R(this,"w",0);R(this,"h",0);this.x=e,this.y=t,this.w=r,this.h=s}get point(){return new k(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 k(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 k(this.minX,this.minY),new k(this.maxX,this.minY),new k(this.maxX,this.maxY),new k(this.minX,this.maxY)]}get cornersAndCenter(){return[new k(this.minX,this.minY),new k(this.maxX,this.minY),new k(this.maxX,this.maxY),new k(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 k(this.w,this.h)}toFixed(){return this.x=wm(this.x),this.y=wm(this.y),this.w=wm(this.w),this.h=wm(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,t=0,r=0,s=0){return this.x=e,this.y=t,this.w=r,this.h=s,this}expand(e){const t=Math.min(this.minX,e.minX),r=Math.min(this.minY,e.minY),s=Math.max(this.maxX,e.maxX),i=Math.max(this.maxY,e.maxY);return this.x=t,this.y=r,this.w=s-t,this.h=i-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:t,w:r,h:s}=this;return new Se(e,t,r,s)}translate(e){return this.x+=e.x,this.y+=e.y,this}snapToGrid(e){const t=Math.round(this.minX/e)*e,r=Math.round(this.minY/e)*e,s=Math.round(this.maxX/e)*e,i=Math.round(this.maxY/e)*e;this.minX=t,this.minY=r,this.width=Math.max(1,s-t),this.height=Math.max(1,i-r)}collides(e){return Se.Collides(this,e)}contains(e){return Se.Contains(this,e)}includes(e){return Se.Includes(this,e)}containsPoint(e,t=0){return Se.ContainsPoint(this,e,t)}getHandlePoint(e){switch(e){case"top_left":return new k(this.minX,this.minY);case"top_right":return new k(this.maxX,this.minY);case"bottom_left":return new k(this.minX,this.maxY);case"bottom_right":return new k(this.maxX,this.maxY);case"top":return new k(this.midX,this.minY);case"right":return new k(this.maxX,this.midY);case"bottom":return new k(this.midX,this.maxY);case"left":return new k(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(e,t,r){const{minX:s,minY:i,maxX:o,maxY:a}=this;let{minX:l,minY:c,maxX:u,maxY:h}=this;switch(e){case"left":case"top_left":case"bottom_left":{l+=t;break}case"right":case"top_right":case"bottom_right":{u+=t;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 p=(u-l)/(o-s),m=(h-c)/(a-i),S=p<0,x=m<0;if(S){const v=u;u=l,l=v}if(x){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 t=Math.min(this.minX,e.x),r=Math.min(this.minY,e.y),s=Math.max(this.maxX,e.w+e.x),i=Math.max(this.maxY,e.h+e.y);return this.x=t,this.y=r,this.width=s-t,this.height=i-r,this}static From(e){return new Se(e.x,e.y,e.w,e.h)}static FromCenter(e,t){return new Se(e.x-t.x/2,e.y-t.y/2,t.x,t.y)}static FromPoints(e){if(e.length===0)return new Se;let t=1/0,r=1/0,s=-1/0,i=-1/0,o;for(let a=0,l=e.length;a<l;a++)o=e[a],t=Math.min(o.x,t),r=Math.min(o.y,r),s=Math.max(o.x,s),i=Math.max(o.y,i);return new Se(t,r,s-t,i-r)}static Expand(e,t){const r=Math.min(t.minX,e.minX),s=Math.min(t.minY,e.minY),i=Math.max(t.maxX,e.maxX),o=Math.max(t.maxY,e.maxY);return new Se(r,s,i-r,o-s)}static ExpandBy(e,t){return new Se(e.minX-t,e.minY-t,e.width+t*2,e.height+t*2)}static Collides(e,t){return!(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}static Contains(e,t){return e.minX<t.minX&&e.minY<t.minY&&e.maxY>t.maxY&&e.maxX>t.maxX}static Includes(e,t){return Se.Collides(e,t)||Se.Contains(e,t)}static ContainsPoint(e,t,r=0){return!(t.x<e.minX-r||t.y<e.minY-r||t.x>e.maxX+r||t.y>e.maxY+r)}static Common(e){let t=1/0,r=1/0,s=-1/0,i=-1/0;for(let o=0;o<e.length;o++){const a=e[o];t=Math.min(t,a.minX),r=Math.min(r,a.minY),s=Math.max(s,a.maxX),i=Math.max(i,a.maxY)}return new Se(t,r,s-t,i-r)}static Sides(e,t=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,t,r,s,i=!1){const{minX:o,minY:a,maxX:l,maxY:c}=e;let{minX:u,minY:h,maxX:p,maxY:m}=e;switch(t){case"left":case"top_left":case"bottom_left":{u+=r;break}case"right":case"top_right":case"bottom_right":{p+=r;break}}switch(t){case"top":case"top_left":case"top_right":{h+=s;break}case"bottom":case"bottom_left":case"bottom_right":{m+=s;break}}const S=(p-u)/(l-o),x=(m-h)/(c-a),v=S<0,w=x<0;if(i){const _=(l-o)/(c-a),E=Math.abs(p-u),T=Math.abs(m-h),A=E*(x<0?1:-1)*(1/_),O=T*(S<0?1:-1)*_,D=_<E/T;switch(t){case"top_left":{D?h=m+A:u=p+O;break}case"top_right":{D?h=m+A:p=u-O;break}case"bottom_right":{D?m=h-A:p=u-O;break}case"bottom_left":{D?m=h-A:u=p+O;break}case"bottom":case"top":{const $=(u+p)/2,H=T*_;u=$-H/2,p=$+H/2;break}case"left":case"right":{const $=(h+m)/2,H=E/_;h=$-H/2,m=$+H/2;break}}}if(v){const _=p;p=u,u=_}if(w){const _=m;m=h,h=_}const C=new Se(u,h,Math.abs(p-u),Math.abs(m-h));return{box:C,scaleX:+(C.width/e.width*(S>0?1:-1)).toFixed(5),scaleY:+(C.height/e.height*(x>0?1:-1)).toFixed(5)}}equals(e){return Se.Equals(this,e)}static Equals(e,t){return t.x===e.x&&t.y===e.y&&t.w===e.w&&t.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 Se(e.x,e.y,Math.max(1,e.w),Math.max(1,e.h))}}function pre(n){switch(n){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 n}}function gre(n){switch(n){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 n}}function mre(n){return n==="top_left"||n==="top_right"||n==="bottom_right"||n==="bottom_left"}class he{constructor(e,t,r,s,i,o){R(this,"a",1);R(this,"b",0);R(this,"c",0);R(this,"d",1);R(this,"e",0);R(this,"f",0);this.a=e,this.b=t,this.c=r,this.d=s,this.e=i,this.f=o}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 t=e,{a:r,b:s,c:i,d:o,e:a,f:l}=this;return this.a=r*t.a+i*t.b,this.c=r*t.c+i*t.d,this.e=r*t.e+i*t.f+a,this.b=s*t.a+o*t.b,this.d=s*t.c+o*t.d,this.f=s*t.e+o*t.f+l,this}rotate(e,t,r){return e===0?this:t===void 0?this.multiply(he.Rotate(e)):this.translate(t,r).multiply(he.Rotate(e)).translate(-t,-r)}translate(e,t){return this.multiply(he.Translate(e,t))}scale(e,t){return this.multiply(he.Scale(e,t))}invert(){const{a:e,b:t,c:r,d:s,e:i,f:o}=this,a=e*s-t*r;return this.a=s/a,this.b=t/-a,this.c=r/-a,this.d=e/a,this.e=(s*i-r*o)/-a,this.f=(t*i-e*o)/a,this}applyToPoint(e){return he.applyToPoint(this,e)}applyToPoints(e){return he.applyToPoints(this,e)}rotation(){return he.Rotation(this)}point(){return he.Point(this)}decomposed(){return he.Decompose(this)}toCssString(){return he.toCssString(this)}setTo(e){return Object.assign(this,e),this}decompose(){return he.Decompose(this)}clone(){return new he(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new he(1,0,0,1,0,0)}static Translate(e,t){return new he(1,0,0,1,e,t)}static Rotate(e,t,r){if(e===0)return he.Identity();const s=Math.cos(e),i=Math.sin(e),o=new he(s,i,-i,s,0,0);return t===void 0?o:he.Compose(he.Translate(t,r),o,he.Translate(-t,-r))}static Scale(e,t,r,s){const i=new he(e,0,0,t,0,0);return r===void 0?i:he.Compose(he.Translate(r,s),i,he.Translate(-r,-s))}static Multiply(e,t){return{a:e.a*t.a+e.c*t.b,c:e.a*t.c+e.c*t.d,e:e.a*t.e+e.c*t.f+e.e,b:e.b*t.a+e.d*t.b,d:e.b*t.c+e.d*t.d,f:e.b*t.e+e.d*t.f+e.f}}static Inverse(e){const t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:e.b/-t,c:e.c/-t,d:e.a/t,e:(e.d*e.e-e.c*e.f)/-t,f:(e.b*e.e-e.a*e.f)/t}}static Absolute(e){const t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:e.b/-t,c:e.c/-t,d:e.a/t,e:(e.d*e.e-e.c*e.f)/t,f:(e.b*e.e-e.a*e.f)/-t}}static Compose(...e){const t=he.Identity();for(let r=0,s=e.length;r<s;r++)t.multiply(e[r]);return t}static Point(e){return new k(e.e,e.f)}static Rotation(e){let t;if(e.a!==0||e.c!==0){const r=(e.a*e.a+e.c*e.c)**.5;t=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;t=Kt+Math.acos(e.b/r)*(e.d>0?-1:1)}else t=0;return jP(t)}static Decompose(e){let t,r,s;if(e.a!==0||e.c!==0){const i=(e.a*e.a+e.c*e.c)**.5;t=i,r=(e.a*e.d-e.b*e.c)/i,s=Math.acos(e.a/i)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const i=(e.b*e.b+e.d*e.d)**.5;t=(e.a*e.d-e.b*e.c)/i,r=i,s=Kt+Math.acos(e.b/i)*(e.d>0?-1:1)}else t=0,r=0,s=0;return{x:e.e,y:e.f,scaleX:t,scaleY:r,rotation:jP(s)}}static Smooth(e,t=1e10){return e.a=Math.round(e.a*t)/t,e.b=Math.round(e.b*t)/t,e.c=Math.round(e.c*t)/t,e.d=Math.round(e.d*t)/t,e.e=Math.round(e.e*t)/t,e.f=Math.round(e.f*t)/t,e}static toCssString(e){return`matrix(${re(e.a)}, ${re(e.b)}, ${re(e.c)}, ${re(e.d)}, ${re(e.e)}, ${re(e.f)})`}static applyToPoint(e,t){return new k(e.a*t.x+e.c*t.y+e.e,e.b*t.x+e.d*t.y+e.f,t.z)}static applyToXY(e,t,r){return[e.a*t+e.c*r+e.e,e.b*t+e.d*r+e.f]}static applyToPoints(e,t){return t.map(r=>new k(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,t){return new Se(e.e+t.minX,e.f+t.minY,t.width,t.height)}static From(e){return new he(e.a,e.b,e.c,e.d,e.e,e.f)}static Cast(e){return e instanceof he?e:he.From(e)}}function X0(n,e,t,r){const s=n.x-t.x,i=n.y-t.y,o=r.x-t.x,a=r.y-t.y,l=e.x-n.x,c=e.y-n.y,u=o*i-a*s,h=l*i-c*s,p=a*l-o*c;if(u===0||h===0||p===0)return null;if(p!==0){const m=u/p,S=h/p;if(0<=m&&m<=1&&0<=S&&S<=1)return k.AddXY(n,m*l,m*c)}return null}function Gp(n,e,t,r){const s=(e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y),i=2*((e.x-n.x)*(n.x-t.x)+(e.y-n.y)*(n.y-t.y)),o=t.x*t.x+t.y*t.y+n.x*n.x+n.y*n.y-2*(t.x*n.x+t.y*n.y)-r*r,a=i*i-4*s*o;if(a<0||a===0)return null;const l=Math.sqrt(a),c=(-i+l)/(2*s),u=(-i-l)/(2*s);if((c<0||c>1)&&(u<0||u>1))return null;const h=[];return 0<=c&&c<=1&&h.push(k.Lrp(n,e,c)),0<=u&&u<=1&&h.push(k.Lrp(n,e,u)),h.length===0?null:h}function yre(n,e,t){const r=[];let s;for(let i=0,o=t.length-1;i<o;i++)s=X0(n,e,t[i],t[i+1]),s&&r.push(s);return r.length===0?null:r}function VE(n,e,t){const r=[];let s;for(let i=1,o=t.length;i<o+1;i++)s=X0(n,e,t[i-1],t[i%t.length]),s&&r.push(s);return r.length===0?null:r}function Sre(n,e,t,r){let s=t.x-n.x,i=t.y-n.y;const o=Math.sqrt(s*s+i*i),a=(o*o-r*r+e*e)/(2*o),l=Math.sqrt(e*e-a*a);return s/=o,i/=o,[new k(n.x+s*a-i*l,n.y+i*a+s*l),new k(n.x+s*a+i*l,n.y+i*a-s*l)]}function oz(n,e,t){const r=[];let s,i,o;for(let a=0,l=t.length;a<l;a++)s=t[a],i=t[(a+1)%t.length],o=Gp(s,i,n,e),o&&r.push(...o);return r.length===0?null:r}function vre(n,e,t){const r=[];let s,i,o;for(let a=1,l=t.length;a<l;a++)s=t[a-1],i=t[a],o=Gp(s,i,n,e),o&&r.push(...o);return r.length===0?null:r}function Om(n,e,t){return(t.y-n.y)*(e.x-n.x)>(e.y-n.y)*(t.x-n.x)}function qE(n,e,t,r){return Om(n,t,r)!==Om(e,t,r)&&Om(n,e,t)!==Om(n,e,r)}function Rj(n,e){const t=new Map;let r,s,i,o;for(let a=0,l=n.length;a<l;a++)if(r=n[a],qs(r,e)){const c=my(r);t.has(c)||t.set(c,r)}for(let a=0,l=e.length;a<l;a++)if(r=e[a],qs(r,n)){const c=my(r);t.has(c)||t.set(c,r)}for(let a=0,l=n.length;a<l;a++){r=n[a],s=n[(a+1)%n.length];for(let c=0,u=e.length;c<u;c++){i=e[c],o=e[(c+1)%e.length];const h=X0(r,s,i,o);if(h!==null){const p=my(h);t.has(p)||t.set(p,h)}}}return t.size===0?null:xre([...t.values()])}function Dj(n,e,t,r){const s=new Map;for(let i=0,o=t?n.length:n.length-1;i<o;i++){const a=n[i],l=n[(i+1)%n.length];for(let c=0,u=r?e.length:e.length-1;c<u;c++){const h=e[c],p=e[(c+1)%e.length],m=X0(a,l,h,p);if(m!==null){const S=my(m);s.has(S)||s.set(S,m)}}}return[...s.values()]}function my(n){return`${n.x},${n.y}`}function xre(n){const e=k.Average(n);return n.sort((t,r)=>k.Angle(e,t)-k.Angle(e,r))}function GE(n,e){let t,r,s,i;for(let o=0,a=n.length;o<a;o++){t=n[o],r=n[(o+1)%a];for(let l=0,c=e.length;l<c;l++)if(s=e[l],i=e[(l+1)%c],qE(t,r,s,i))return!0}return!1}function wre(n,e){let t,r,s,i;for(let o=0,a=n.length;o<a;o++){t=n[o],r=n[(o+1)%a];for(let l=1,c=e.length;l<c;l++)if(s=e[l-1],i=e[l],qE(t,r,s,i))return!0}return!1}const mk={EXCLUDE_LABELS:{includeLabels:!1,includeInternal:!0}};class qa{constructor(e){R(this,"isFilled",!1);R(this,"isClosed",!0);R(this,"isLabel",!1);R(this,"isInternal",!1);R(this,"debugColor");R(this,"ignore");R(this,"_vertices");R(this,"_bounds");R(this,"_area");R(this,"_length");this.isFilled=e.isFilled,this.isClosed=e.isClosed,this.isLabel=e.isLabel??!1,this.isInternal=e.isInternal??!1,this.debugColor=e.debugColor,this.ignore=e.ignore}isExcludedByFilter(e){return e?!!(this.isLabel&&!e.includeLabels||this.isInternal&&!e.includeInternal):!1}hitTestPoint(e,t=0,r=!1,s){return this.isClosed&&(this.isFilled||r)&&qs(e,this.vertices)?!0:k.Dist2(e,this.nearestPoint(e))<=t*t}distanceToPoint(e,t=!1,r){return e.dist(this.nearestPoint(e,r))*(this.isClosed&&(this.isFilled||t)&&qs(e,this.vertices)?-1:1)}distanceToLineSegment(e,t,r){if(e.equals(t))return this.distanceToPoint(e,!1,r);const{vertices:s}=this;let i,o=1/0,a,l,c;for(let u=0;u<s.length;u++)l=s[u],c=k.NearestPointOnLineSegment(e,t,l,!0),a=k.Dist2(l,c),a<o&&(o=a,i=c);if(!i)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&qs(i,this.vertices)?-o:o}hitTestLineSegment(e,t,r=0,s){return this.distanceToLineSegment(e,t,s)<=r}intersectLineSegment(e,t,r){return(this.isClosed?VE(e,t,this.vertices):yre(e,t,this.vertices))??[]}intersectCircle(e,t,r){return(this.isClosed?oz(e,t,this.vertices):vre(e,t,this.vertices))??[]}intersectPolygon(e,t){return Dj(e,this.vertices,!0,this.isClosed)}intersectPolyline(e,t){return Dj(e,this.vertices,!1,this.isClosed)}nearestPointOnLineSegment(e,t){const{vertices:r}=this;let s,i=1/0,o,a,l;for(let c=0;c<r.length;c++)a=r[c],l=k.NearestPointOnLineSegment(e,t,a,!0),o=k.Dist2(a,l),o<i&&(i=o,s=l);if(!s)throw Error("nearest point not found");return s}isPointInBounds(e,t=0){const{bounds:r}=this;return!(e.x<r.minX-t||e.y<r.minY-t||e.x>r.maxX+t||e.y>r.maxY+t)}transform(e,t){return new YE(this,e,t)}get vertices(){return this._vertices||(this._vertices=this.getVertices(mk.EXCLUDE_LABELS)),this._vertices}getBounds(){return Se.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 t=0;for(let r=0,s=e.length;r<s;r++){const i=e[r],o=e[(r+1)%s];t+=i.x*o.y-o.x*i.y}return t/2}toSimpleSvgPath(){let e="";const{vertices:t}=this,r=t.length;if(r===0)return e;e+=`M${t[0].x},${t[0].y}`;for(let s=1;s<r;s++)e+=`L${t[s].x},${t[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 t,r=e[0],s=0;for(let i=1;i<e.length;i++)t=e[i],s+=k.Dist2(r,t),r=t;return Math.sqrt(s)}}class YE extends qa{constructor(t,r,s){super(t);R(this,"inverse");R(this,"decomposed");this.geometry=t,this.matrix=r,this.inverse=he.Inverse(r),this.decomposed=he.Decompose(r),s&&(s.isLabel!=null&&(this.isLabel=s.isLabel),s.isInternal!=null&&(this.isInternal=s.isInternal),s.debugColor!=null&&(this.debugColor=s.debugColor),s.ignore!=null&&(this.ignore=s.ignore)),Je(_a(this.decomposed.scaleX,this.decomposed.scaleY),"non-uniform scaling is not yet supported")}getVertices(t){return this.geometry.getVertices(t).map(r=>he.applyToPoint(this.matrix,r))}nearestPoint(t,r){return he.applyToPoint(this.matrix,this.geometry.nearestPoint(he.applyToPoint(this.inverse,t),r))}hitTestPoint(t,r=0,s,i){return this.geometry.hitTestPoint(he.applyToPoint(this.inverse,t),r/this.decomposed.scaleX,s,i)}distanceToPoint(t,r=!1,s){return this.geometry.distanceToPoint(he.applyToPoint(this.inverse,t),r,s)*this.decomposed.scaleX}distanceToLineSegment(t,r,s){return this.geometry.distanceToLineSegment(he.applyToPoint(this.inverse,t),he.applyToPoint(this.inverse,r),s)*this.decomposed.scaleX}hitTestLineSegment(t,r,s=0,i){return this.geometry.hitTestLineSegment(he.applyToPoint(this.inverse,t),he.applyToPoint(this.inverse,r),s/this.decomposed.scaleX,i)}intersectLineSegment(t,r,s){return this.geometry.intersectLineSegment(he.applyToPoint(this.inverse,t),he.applyToPoint(this.inverse,r),s)}intersectCircle(t,r,s){return this.geometry.intersectCircle(he.applyToPoint(this.inverse,t),r/this.decomposed.scaleX,s)}intersectPolygon(t,r){return this.geometry.intersectPolygon(he.applyToPoints(this.inverse,t),r)}intersectPolyline(t,r){return this.geometry.intersectPolyline(he.applyToPoints(this.inverse,t),r)}transform(t,r){return new YE(this.geometry,he.Multiply(t,this.matrix),{isLabel:(r==null?void 0:r.isLabel)??this.isLabel,isInternal:(r==null?void 0:r.isInternal)??this.isInternal,debugColor:(r==null?void 0:r.debugColor)??this.debugColor,ignore:(r==null?void 0:r.ignore)??this.ignore})}getSvgPathData(){throw new Error("Cannot get SVG path data for transformed geometry.")}}class Js extends qa{constructor(t){super({...t,isClosed:!0,isFilled:!1});R(this,"children",[]);R(this,"ignoredChildren",[]);for(const r of t.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(t){return this.isExcludedByFilter(t)?[]:this.children.filter(r=>!r.isExcludedByFilter(t)).flatMap(r=>r.getVertices(t))}nearestPoint(t,r){let s=1/0,i;const{children:o}=this;if(o.length===0)throw Error("no children");let a,l;for(const c of o)c.isExcludedByFilter(r)||(a=c.nearestPoint(t,r),l=k.Dist2(a,t),l<s&&(s=l,i=a));if(!i)throw Error("nearest point not found");return i}distanceToPoint(t,r=!1,s){let i=1/0;for(const o of this.children){if(o.isExcludedByFilter(s))continue;const a=o.distanceToPoint(t,r,s);a<i&&(i=a)}return i}hitTestPoint(t,r,s,i=mk.EXCLUDE_LABELS){return!!this.children.filter(o=>!o.isExcludedByFilter(i)).find(o=>o.hitTestPoint(t,r,s))}hitTestLineSegment(t,r,s,i=mk.EXCLUDE_LABELS){return!!this.children.filter(o=>!o.isExcludedByFilter(i)).find(o=>o.hitTestLineSegment(t,r,s))}intersectLineSegment(t,r,s){return this.children.flatMap(i=>i.isExcludedByFilter(s)?kr:i.intersectLineSegment(t,r,s))}intersectCircle(t,r,s){return this.children.flatMap(i=>i.isExcludedByFilter(s)?kr:i.intersectCircle(t,r,s))}intersectPolygon(t,r){return this.children.flatMap(s=>s.isExcludedByFilter(r)?kr:s.intersectPolygon(t,r))}intersectPolyline(t,r){return this.children.flatMap(s=>s.isExcludedByFilter(r)?kr:s.intersectPolyline(t,r))}transform(t){return new Js({children:this.children.map(r=>r.transform(t)),isLabel:this.isLabel,debugColor:this.debugColor,ignore:this.ignore})}getArea(){return this.children[0].area}toSimpleSvgPath(){let t="";for(const s of this.children)t+=s.toSimpleSvgPath();const r=Se.FromPoints(this.vertices).corners;for(let s=0,i=r.length;s<i;s++){const o=r[s],a=r[(s-1+i)%i],l=o.dist(a),c=r[(s+1)%i],u=o.dist(c),h=o.clone().lrp(a,4/l),p=o,m=o.clone().lrp(c,4/u);t+=`M${h.x},${h.y} L${p.x},${p.y} L${m.x},${m.y} `}return t}getLength(){return this.children.reduce((t,r)=>r.isLabel?t:t+r.length,0)}getSvgPathData(){return this.children.map((t,r)=>t.isLabel?"":t.getSvgPathData(r===0)).join(" ")}}function bre(n=!0){const[e,t]=P.useState(0),r=te();P.useEffect(()=>{if(!n)return;const s=()=>t(i=>i+1);return r.on("tick",s),()=>{r.off("tick",s)}},[r,n])}const Cre=Yn(function({showStroke:e=!0,showVertices:t=!0,showClosestPointOnOutline:r=!0}){const s=te();bre(r);const i=s.getZoomLevel(),o=s.getRenderingShapes(),{inputs:{currentPagePoint:a}}=s;return g.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:o.map(l=>{const c=s.getShape(l.id);if(c.type==="group")return null;const u=s.getShapeGeometry(c),h=s.getShapePageTransform(c),p=s.getPointInShapeSpace(c,a),m=u.nearestPoint(p),S=u.distanceToPoint(p,!0),x=Math.abs(S)*i,v=S<0,{vertices:w}=u;return g.jsxs("g",{transform:h.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[e&&g.jsx("g",{stroke:u.debugColor??"red",opacity:"1",strokeWidth:2/i,fill:"none",children:g.jsx(az,{geometry:u})}),t&&w.map((C,_)=>g.jsx("circle",{cx:C.x,cy:C.y,r:2/i,fill:`hsl(${zd(_,[0,w.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:1/i},`v${_}`)),r&&x<150&&g.jsx("line",{x1:m.x,y1:m.y,x2:p.x,y2:p.y,opacity:1-x/150,stroke:v?"goldenrod":"dodgerblue",strokeWidth:2/i})]},l.id+"_outline")})})});function az({geometry:n}){return n instanceof Js?g.jsx("g",{stroke:n.debugColor,children:[...n.children,...n.ignoredChildren].map((e,t)=>g.jsx(az,{geometry:e},t))}):g.jsx("path",{d:n.toSimpleSvgPath(),stroke:n.debugColor})}function lz(n){return kV(n)}function cz(){const n=te(),e=jG("userIds",()=>lz(n.getCollaborators().map(t=>t.userId)).sort(),{isEqual:(t,r)=>{var s;return t.join(",")===((s=r.join)==null?void 0:s.call(r,","))}},[n]);return ie(e)}function Z0(n){const e=te();return ie(`latestPresence:${n}`,()=>e.getCollaborators().find(r=>r.userId===n),[e,n])??null}const Pre=Yn(function(){return cz().map(t=>g.jsx(kre,{collaboratorId:t},t))}),kre=Yn(function({collaboratorId:e}){const t=te(),r=Z0(e),s=Ere(t,r);if(!(r&&r.currentPageId===t.getCurrentPageId()))return null;switch(s){case"inactive":{const{followingUserId:i,highlightedUserIds:o}=t.getInstanceState();if(!(i===r.userId||o.includes(r.userId)))return null;break}case"idle":{const{highlightedUserIds:i}=t.getInstanceState();if(r.followingUserId===t.user.getId()&&!(r.chatMessage||i.includes(r.userId)))return null;break}}return g.jsx(Ire,{latestPresence:r})}),Ire=Yn(function({latestPresence:e}){const t=te(),{CollaboratorBrush:r,CollaboratorScribble:s,CollaboratorCursor:i,CollaboratorHint:o,CollaboratorShapeIndicator:a}=Zt(),l=t.getZoomLevel(),c=t.getViewportPageBounds(),{userId:u,chatMessage:h,brush:p,scribbles:m,selectedShapeIds:S,userName:x,cursor:v,color:w}=e;if(!v)return null;const C=!(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 g.jsxs(g.Fragment,{children:[p&&r?g.jsx(r,{className:"tl-collaborator__brush",userId:u,brush:p,color:w,opacity:.1},u+"_brush"):null,C&&i?g.jsx(i,{className:"tl-collaborator__cursor",userId:u,point:v,color:w,zoom:l,name:x!=="New User"?x:null,chatMessage:h??""},u+"_cursor"):o?g.jsx(o,{className:"tl-collaborator__cursor-hint",userId:u,point:v,color:w,zoom:l,viewport:c},u+"_cursor_hint"):null,s&&m.length?g.jsx(g.Fragment,{children:m.map(_=>g.jsx(s,{className:"tl-collaborator__scribble",userId:u,scribble:_,color:w,zoom:l,opacity:_.color==="laser"?.5:.1},u+"_scribble_"+_.id))}):null,a&&S.filter(_=>!t.isShapeHidden(_)).map(_=>g.jsx(a,{className:"tl-collaborator__shape-indicator",userId:u,shapeId:_,color:w,opacity:.5},u+"_"+_))]})});function jj(n,e){return e>n.options.collaboratorInactiveTimeoutMs?"inactive":e>n.options.collaboratorIdleTimeoutMs?"idle":"active"}function Ere(n,e){const t=P.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[r,s]=P.useState(()=>jj(n,Date.now()-t.current));return P.useEffect(()=>{const i=n.timers.setInterval(()=>{s(jj(n,Date.now()-t.current))},n.options.collaboratorCheckIntervalMs);return()=>clearInterval(i)},[n]),e&&(t.current=e.lastActivityTimestamp??1/0),r}function _re(){const n=te(),e=ie("is menu open",()=>n.menus.hasAnyOpenMenus(),[n]),[t,r]=P.useState(!1),s=e||t,i=KE(),o=P.useRef({isDown:!1,isDragging:!1,start:new k}),a=P.useCallback(u=>{u.button===0&&(r(!0),o.current={isDown:!0,isDragging:!1,start:new k(u.clientX,u.clientY)}),n.menus.clearOpenMenus()},[n]),l=P.useCallback(u=>{var h,p,m;if(o.current.isDown){if(o.current.isDragging){(h=i.onPointerMove)==null||h.call(i,u);return}if(k.Dist2(o.current.start,new k(u.clientX,u.clientY))>n.options.dragDistanceSquared){o.current={...o.current,isDown:!0,isDragging:!0};const{x:S,y:x}=o.current.start;(p=i.onPointerDown)==null||p.call(i,{...u,clientX:S,clientY:x,button:0}),(m=i.onPointerMove)==null||m.call(i,u)}}},[i,n]),c=P.useCallback(u=>{var h;(h=i.onPointerUp)==null||h.call(i,u),r(!1),o.current={isDown:!1,isDragging:!1,start:new k(u.clientX,u.clientY)}},[i]);return s&&g.jsx("div",{className:"tlui-menu-click-capture","data-testid":"menu-click-capture.content",...i,onPointerDown:a,onPointerMove:l,onPointerUp:c})}const uz=P.memo(function({id:e,shape:t,util:r,index:s,backgroundIndex:i,opacity:o}){const a=te(),{ShapeErrorFallback:l}=Zt(),c=P.useRef(null),u=P.useRef(null);P.useEffect(()=>Pi("load fonts",()=>{const S=a.fonts.getShapeFontFaces(e);a.fonts.requestFonts(S)}),[a,e]);const h=P.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});Hl("set shape stuff",()=>{const S=a.getShape(e);if(!S)return;const x=h.current,v=a.getShapeClipPath(e)??"none";v!==x.clipPath&&(Sr(c.current,"clip-path",v),Sr(u.current,"clip-path",v),x.clipPath=v);const w=a.getShapePageTransform(e),C=he.toCssString(w),_=a.getShapeGeometry(S).bounds;C!==x.transform&&(Sr(c.current,"transform",C),Sr(u.current,"transform",C),x.transform=C);const E=Math.max(_.width,1),T=Math.max(_.height,1);(E!==x.width||T!==x.height)&&(Sr(c.current,"width",E+"px"),Sr(c.current,"height",T+"px"),Sr(u.current,"width",E+"px"),Sr(u.current,"height",T+"px"),x.width=E,x.height=T)},[a]),P.useLayoutEffect(()=>{const S=c.current,x=u.current;Sr(S,"opacity",o),Sr(x,"opacity",o),Sr(S,"z-index",s),Sr(x,"z-index",i)},[o,s,i]),Hl("set display",()=>{if(!a.getShape(e))return;const v=a.getCulledShapes().has(e);v!==h.current.isCulled&&(Sr(c.current,"display",v?"none":"block"),Sr(u.current,"display",v?"none":"block"),h.current.isCulled=v)},[a]);const p=P.useCallback(S=>a.annotateError(S,{origin:"shape",willCrashApp:!1}),[a]);if(!t)return null;const m="fill"in t.props&&t.props.fill!=="none";return g.jsxs(g.Fragment,{children:[r.backgroundComponent&&g.jsx("div",{ref:u,className:"tl-shape tl-shape-background","data-shape-type":t.type,"data-shape-id":t.id,draggable:!1,children:g.jsx(yp,{fallback:l,onError:p,children:g.jsx(hz,{shape:t,util:r})})}),g.jsx("div",{ref:c,className:"tl-shape","data-shape-type":t.type,"data-shape-is-filled":m,"data-shape-id":t.id,draggable:!1,children:g.jsx(yp,{fallback:l,onError:p,children:g.jsx(dz,{shape:t,util:r})})})]})}),dz=P.memo(function({shape:e,util:t}){return I0("InnerShape:"+e.type,()=>t.component(t.editor.store.unsafeGetWithoutCapture(e.id)),[t,e.id])},(n,e)=>n.shape.props===e.shape.props&&n.shape.meta===e.shape.meta&&n.util===e.util),hz=P.memo(function({shape:e,util:t}){return I0("InnerShape:"+e.type,()=>{var r;return(r=t.backgroundComponent)==null?void 0:r.call(t,t.editor.store.unsafeGetWithoutCapture(e.id))},[t,e.id])},(n,e)=>n.shape.props===e.shape.props&&n.shape.meta===e.shape.meta&&n.util===e.util);function Tre({className:n}){const e=te(),{Background:t,SvgDefs:r,ShapeIndicators:s}=Zt(),i=P.useRef(null),o=P.useRef(null),a=P.useRef(null),l=kn();hre(i),ine(),sne(),ure(i),ane(i);const c=P.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});Hl("position layers",function(){const{x:C,y:_,z:E}=e.getCamera();if(c.current.allowTextOutline&&It.isSafari&&(l.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&E<e.options.textShadowLod!==c.current.lodDisableTextOutline){const O=E<e.options.textShadowLod;l.style.setProperty("--tl-text-outline",O?"none":"var(--tl-text-outline-reference)"),c.current.lodDisableTextOutline=O}const T=E>=1?zd(E,[1,8],[.125,.5],!0):zd(E,[.1,1],[-2,.125],!0),A=`scale(${re(E)}) translate(${re(C+T)}px,${re(_+T)}px)`;Sr(o.current,"transform",A),Sr(a.current,"transform",A)},[e,l]);const u=KE(),h=ie("shapeSvgDefs",()=>{const w=new Map;for(const C of gn(e.shapeUtils)){if(!C)return;const _=C.getCanvasSvgDefs();for(const{key:E,component:T}of _)w.has(E)||w.set(E,g.jsx(T,{},E))}return[...w.values()]},[e]),p=ie("debug_shapes",()=>ln.hideShapes.get(),[ln]),m=ie("debug_svg",()=>ln.debugSvg.get(),[ln]),S=ie("debug_geometry",()=>ln.debugGeometry.get(),[ln]),x=ie("isEditingAnything",()=>e.getEditingShapeId()!==null,[e]),v=ie("isSelectingAnything",()=>!!e.getSelectedShapeIds().length,[e]);return g.jsxs(g.Fragment,{children:[g.jsxs("div",{ref:i,draggable:!1,"data-iseditinganything":x,"data-isselectinganything":v,className:$e("tl-canvas",n),"data-testid":"canvas",...u,children:[g.jsx("svg",{className:"tl-svg-context",children:g.jsxs("defs",{children:[h,g.jsx(Hre,{}),g.jsx(Kre,{}),r&&g.jsx(r,{})]})}),t&&g.jsx("div",{className:"tl-background__wrapper",children:g.jsx(t,{})}),g.jsx(Are,{}),g.jsxs("div",{ref:o,className:"tl-html-layer tl-shapes",draggable:!1,children:[g.jsx(Gre,{}),g.jsx(qre,{}),p?null:m?g.jsx(zre,{}):g.jsx(Bre,{})]}),g.jsx("div",{className:"tl-overlays",children:g.jsxs("div",{ref:a,className:"tl-html-layer",children:[S?g.jsx(Cre,{}):null,g.jsx(Rre,{}),g.jsx(Ore,{}),g.jsx(Dre,{}),s&&g.jsx(s,{}),g.jsx(Ure,{}),g.jsx(jre,{}),g.jsx(Vre,{}),g.jsx(Lre,{}),g.jsx(Pre,{})]})}),g.jsx(Yre,{})]}),g.jsx(_re,{}),g.jsx(Mre,{})]})}function Mre(){const{InFrontOfTheCanvas:n}=Zt();return n?g.jsx(n,{}):null}function Are(){const n=te(),e=ie("gridSize",()=>n.getDocumentSettings().gridSize,[n]),{x:t,y:r,z:s}=ie("camera",()=>n.getCamera(),[n]),i=ie("isGridMode",()=>n.getInstanceState().isGridMode,[n]),{Grid:o}=Zt();return o&&i?g.jsx(o,{x:t,y:r,z:s,size:e}):null}function Ore(){const n=te(),e=ie("scribbles",()=>n.getInstanceState().scribbles,[n]),t=ie("zoomLevel",()=>n.getZoomLevel(),[n]),{Scribble:r}=Zt();return r&&e.length?e.map(s=>g.jsx(r,{className:"tl-user-scribble",scribble:s,zoom:t},s.id)):null}function Rre(){const n=te(),e=ie("brush",()=>n.getInstanceState().brush,[n]),{Brush:t}=Zt();return t&&e?g.jsx(t,{className:"tl-user-brush",brush:e}):null}function Dre(){const n=te(),e=ie("zoomBrush",()=>n.getInstanceState().zoomBrush,[n]),{ZoomBrush:t}=Zt();return t&&e?g.jsx(t,{className:"tl-user-brush tl-zoom-brush",brush:e}):null}function jre(){const n=te(),e=ie("snapLines",()=>n.snaps.getIndicators(),[n]),t=ie("zoomLevel",()=>n.getZoomLevel(),[n]),{SnapIndicator:r}=Zt();return r&&e.length>0?e.map(s=>g.jsx(r,{className:"tl-user-snapline",line:s,zoom:t},s.id)):null}function Lre(){const n=te(),e=ie("handles shapeIdWithHandles",()=>{const{isReadonly:t,isChangingStyle:r}=n.getInstanceState();if(t||r)return!1;const s=n.getOnlySelectedShape();return!s||!n.getShapeHandles(s)?!1:s.id},[n]);return e?g.jsx(Nre,{shapeId:e}):null}function Nre({shapeId:n}){const e=te(),{Handles:t}=Zt(),r=ie("zoomLevel",()=>e.getZoomLevel(),[e]),s=ie("coarse pointer",()=>e.getInstanceState().isCoarsePointer,[e]),i=ie("handles transform",()=>e.getShapePageTransform(n),[e,n]),o=ie("handles",()=>{const l=e.getShapeHandles(n);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"&&k.Dist(u,h)<c)).sort(u=>u.type==="vertex"?1:-1)},[e,r,s,n]),a=ie("isHidden",()=>e.isShapeHidden(n),[e,n]);return!t||!o||!i||a?null:g.jsx(t,{children:g.jsx("g",{transform:he.toCssString(i),children:o.map(l=>g.jsx(Fre,{shapeId:n,handle:l,zoom:r,isCoarse:s},l.id))})})}function Fre({shapeId:n,handle:e,zoom:t,isCoarse:r}){const s=dre(n,e.id),{Handle:i}=Zt();return i?g.jsx("g",{role:"button","aria-label":"handle",transform:`translate(${e.x}, ${e.y})`,...s,children:g.jsx(i,{shapeId:n,handle:e,zoom:t,isCoarse:r})}):null}function zre(){const n=te();return ie("rendering shapes",()=>n.getRenderingShapes(),[n]).map(t=>g.jsxs(P.Fragment,{children:[g.jsx(uz,{...t}),g.jsx(Wre,{id:t.id,mode:"iframe"})]},t.id+"_fragment"))}function $re(){const n=te(),e=P.useRef(new Set);return Hl("reflow for culled shapes",()=>{const t=n.getCulledShapes();if(e.current.size===t.size&&[...t].every(s=>e.current.has(s)))return;e.current=t;const r=document.getElementsByClassName("tl-canvas");r.length!==0&&r[0].offsetHeight},[n]),null}function Bre(){const n=te(),e=ie("rendering shapes",()=>n.getRenderingShapes(),[n]);return g.jsxs(g.Fragment,{children:[e.map(t=>g.jsx(uz,{...t},t.id+"_shape")),It.isSafari&&g.jsx($re,{})]})}function Ure(){const n=te(),{ShapeIndicator:e}=Zt(),t=ie("hinting shape ids",()=>wI(n.getHintingShapeIds()),[n]);return!t.length||!e?null:t.map(r=>g.jsx(e,{className:"tl-user-indicator__hint",shapeId:r},r+"_hinting"))}function Hre(){return g.jsxs("g",{id:Qi("cursor"),children:[g.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[g.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),g.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),g.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[g.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),g.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),g.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[g.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),g.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function Kre(){const n=Qi("cursor_hint");return g.jsx("path",{id:n,fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function Wre({id:n,mode:e}){const t=te(),[r,s]=P.useState(null),i=ie("is in root",()=>{const o=t.getShape(n);return(o==null?void 0:o.parentId)===t.getCurrentPageId()},[t,n]);return P.useEffect(()=>{if(!i)return;let o=null;const a=Pi("shape to svg",async()=>{const l=Math.random();o=l;const u=t.isShapeOfType(n,"frame")?0:10;let h=t.getShapePageBounds(n);if(!h)return;h=h.clone().expandBy(u);const p=await t.getSvgString([n],{padding:u});if(o!==l||!p)return;const m=`data:image/svg+xml;utf8,${encodeURIComponent(p.svg)}`;s({src:m,bounds:h})});return()=>{o=null,a()}},[t,n,i]),!i||!r?null:e==="iframe"?g.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"}}):g.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 Vre(){const n=te(),e=ie("selection rotation",()=>n.getSelectionRotation(),[n]),t=ie("selection bounds",()=>n.getSelectionRotatedPageBounds(),[n]),{SelectionForeground:r}=Zt();return!t||!r?null:g.jsx(r,{bounds:t,rotation:e})}function qre(){const n=te(),e=ie("selection rotation",()=>n.getSelectionRotation(),[n]),t=ie("selection bounds",()=>n.getSelectionRotatedPageBounds(),[n]),{SelectionBackground:r}=Zt();return!t||!r?null:g.jsx(r,{bounds:t,rotation:e})}function Gre(){const{OnTheCanvas:n}=Zt();return n?g.jsx(n,{}):null}function Yre(){const n=te(),e=ie("camera state",()=>n.getCameraState(),[n]);return g.jsx("div",{className:$e("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":e==="idle"})})}function Xre({className:n,zoom:e,point:t,color:r,viewport:s,opacity:i=1}){const o=P.useRef(null);uh(o,Mn(t.x,s.minX+5/e,s.maxX-5/e),Mn(t.y,s.minY+5/e,s.maxY-5/e),1/e,k.Angle(s.center,t));const a=Qi("cursor_hint");return g.jsxs("svg",{ref:o,className:$e("tl-overlays__item",n),children:[g.jsx("use",{href:`#${a}`,color:r,strokeWidth:3,stroke:"var(--color-background)"}),g.jsx("use",{href:`#${a}`,color:r,opacity:i})]})}const Lj=P.memo(function({className:e,zoom:t,point:r,color:s,name:i,chatMessage:o}){const a=P.useRef(null);uh(a,r==null?void 0:r.x,r==null?void 0:r.y,1/t);const l=Qi("cursor");return r?g.jsxs("div",{ref:a,className:$e("tl-overlays__item",e),children:[g.jsx("svg",{className:"tl-cursor",children:g.jsx("use",{href:`#${l}`,color:s})}),o?g.jsxs(g.Fragment,{children:[i&&g.jsx("div",{className:"tl-nametag-title",style:{color:s},children:i}),g.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:s},children:o})]}):i&&g.jsx("div",{className:"tl-nametag",style:{backgroundColor:s},children:i})]}):null});function Zre({x:n,y:e,z:t,size:r}){const s=vu("grid"),i=te(),{gridSteps:o}=i.options;return g.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("defs",{children:o.map(({min:a,mid:l,step:c},u)=>{const h=c*r*t,p=.5+n*t,m=.5+e*t,S=p>0?p%h:h+p%h,x=m>0?m%h:h+m%h,v=t<l?zd(t,[a,l],[0,1]):1;return g.jsx("pattern",{id:$E(s,`${c}`),width:h,height:h,patternUnits:"userSpaceOnUse",children:g.jsx("circle",{className:"tl-grid-dot",cx:S,cy:x,r:1,opacity:v})},u)})}),o.map(({step:a},l)=>g.jsx("rect",{width:"100%",height:"100%",fill:`url(#${s}_${a})`},l))]})}function Jre({handle:n,isCoarse:e,className:t,zoom:r}){const s=te(),i=(e?s.options.coarseHandleRadius:s.options.handleRadius)/r;if(n.type==="clone"){const a=3/r,l=`M0,${-a} A${a},${a} 0 0,1 0,${a}`,c=Zte.indexOf(n.id);return g.jsxs("g",{className:$e(`tl-handle tl-handle__${n.type}`,t),children:[g.jsx("circle",{className:"tl-handle__bg",r:i}),g.jsx("path",{className:"tl-handle__fg",d:l,transform:`rotate(${-90+90*c})`})]})}const o=(n.type==="create"&&e?3:4)/Math.max(r,.25);return g.jsxs("g",{className:$e(`tl-handle tl-handle__${n.type}`,t),children:[g.jsx("circle",{className:"tl-handle__bg",r:i}),g.jsx("circle",{className:"tl-handle__fg",r:o})]})}const Qre=({children:n})=>g.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:n}),ese=()=>{const{Spinner:n}=Zt();return g.jsx(qae,{children:n?g.jsx(n,{}):null})};function XE(n,e=!0){const t=n.length;if(t<2)return"";let r=n[0],s=n[1];if(t===2)return`M${Ct(r)}L${Ct(s)}`;let i="";for(let o=2,a=t-1;o<a;o++)r=n[o],s=n[o+1],i+=bs(r,s);return e?`M${bs(n[0],n[1])}Q${Ct(n[1])}${bs(n[1],n[2])}T${i}${bs(n[t-1],n[0])}${bs(n[0],n[1])}Z`:`M${Ct(n[0])}Q${Ct(n[1])}${bs(n[1],n[2])}${n.length>3?"T":""}${i}L${Ct(n[t-1])}`}function Nj({scribble:n,zoom:e,color:t,opacity:r,className:s}){return n.points.length?g.jsx("svg",{className:s&&$e("tl-overlays__item",s),children:g.jsx("path",{className:"tl-scribble",d:XE(n.points,!1),stroke:t??`var(--color-${n.color})`,fill:"none",strokeWidth:8/e,opacity:r??n.opacity})}):null}function fz({bounds:n,rotation:e}){const t=P.useRef(null);return uh(t,n.x,n.y,1,e),P.useLayoutEffect(()=>{const r=t.current;r&&(r.style.width=re(Math.max(1,n.width))+"px",r.style.height=re(Math.max(1,n.height))+"px")},[n.width,n.height]),g.jsx("div",{ref:t,className:"tl-selection__bg",draggable:!1})}function tse({bounds:n,rotation:e}){const t=te(),r=P.useRef(null),s=ie("only selected shape",()=>t.getOnlySelectedShape(),[t]),i=s?t.getShapeUtil(s).expandSelectionOutlinePx(s):0;return uh(r,n==null?void 0:n.x,n==null?void 0:n.y,1,e,{x:-i,y:-i}),n=i instanceof Se?n.clone().expand(i).zeroFix():n.clone().expandBy(i).zeroFix(),g.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:g.jsx("rect",{className:$e("tl-selection__fg__outline"),width:re(n.width),height:re(n.height)})})}const nse=()=>g.jsx("div",{className:"tl-shape-error-boundary"}),rse=P.memo(({shape:n,util:e})=>I0("Indicator: "+n.type,()=>e.indicator(e.editor.store.unsafeGetWithoutCapture(n.id)))),sse=P.memo(({editor:n,id:e})=>{const t=ie("shape for indicator",()=>n.store.get(e),[n,e]),{ShapeIndicatorErrorFallback:r}=Zt();return!t||t.isLocked?null:g.jsx(yp,{fallback:r,onError:s=>n.annotateError(s,{origin:"react.shapeIndicator",willCrashApp:!1}),children:g.jsx(rse,{shape:t,util:n.getShapeUtil(t)},t.id)})}),Fj=P.memo(function({shapeId:e,className:t,color:r,hidden:s,opacity:i}){const o=te(),a=P.useRef(null);return Hl("indicator transform",()=>{const l=a.current;if(!l)return;const c=o.getShapePageTransform(e);c&&l.style.setProperty("transform",c.toCssString())},[o,e]),P.useLayoutEffect(()=>{const l=a.current;l&&l.style.setProperty("display",s?"none":"block")},[s]),g.jsx("svg",{ref:a,className:$e("tl-overlays__item",t),children:g.jsx("g",{className:"tl-shape-indicator",stroke:r??"var(--color-selected)",opacity:i,children:g.jsx(sse,{editor:o,id:e})})})}),ise=()=>g.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"}),pz=P.memo(function({hideAll:e,showAll:t}){const r=te();if(e&&t)throw Error("You cannot set both hideAll and showAll props to true, cmon now");const s=P.useRef(new Set),i=ie("should display selected ids",()=>{const l=s.current,c=new Set,u=r.getInstanceState(),h=u.isChangingStyle,p=r.isInAny("select.idle","select.editing_shape"),m=r.isInAny("select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","select.pointing_handle");if(h||!(p||m))return s.current=c,c;for(const S of r.getSelectedShapeIds())c.add(S);if(p&&u.isHoveringCanvas&&!u.isCoarsePointer){const S=r.getHoveredShapeId();S&&c.add(S)}if(l.size!==c.size)return s.current=c,c;for(const S of c)if(!l.has(S))return s.current=c,c;return l},[r]),o=ie("rendering shapes",()=>r.getRenderingShapes(),[r]),{ShapeIndicator:a}=Zt();return a?o.map(({id:l})=>g.jsx(a,{shapeId:l,hidden:!t&&(e||!i.has(l))},l+"_indicator")):null});function ose({points:n,zoom:e}){const t=2.5/e,r=n.reduce((p,m)=>Math.min(p,m.x),1/0),s=n.reduce((p,m)=>Math.max(p,m.x),-1/0),i=n.reduce((p,m)=>Math.min(p,m.y),1/0),o=n.reduce((p,m)=>Math.max(p,m.y),-1/0),a=n.some(p=>p.x===r&&p.y===i);let l,c,u,h;return a?(l=r,c=i,u=s,h=o):(l=r,c=o,u=s,h=i),g.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[g.jsx("line",{x1:l,y1:c,x2:u,y2:h}),n.map((p,m)=>g.jsx("g",{transform:`translate(${p.x},${p.y})`,children:g.jsx("path",{className:"tl-snap-point",d:`M ${-t},${-t} L ${t},${t} M ${-t},${t} L ${t},${-t}`})},m))]})}function ase({gaps:n,direction:e,zoom:t}){const r=3.5/t;let s=[-1/0,1/0],i=null;const o=e==="horizontal";for(const l of n){if(i=Ki(s[0],s[1],o?l.startEdge[0].y:l.startEdge[0].x,o?l.startEdge[1].y:l.startEdge[1].x),i)s=i;else continue;if(i=Ki(s[0],s[1],o?l.endEdge[0].y:l.endEdge[0].x,o?l.endEdge[1].y:l.endEdge[1].x),i)s=i;else continue}if(s===null)return null;const a=(s[0]+s[1])/2;return g.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:n.map(({startEdge:l,endEdge:c},u)=>g.jsx(P.Fragment,{children:o?g.jsxs(g.Fragment,{children:[g.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),g.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),g.jsx("line",{x1:l[0].x,y1:a,x2:c[0].x,y2:a}),g.jsx("line",{x1:(l[0].x+c[0].x)/2,y1:a-r,x2:(l[0].x+c[0].x)/2,y2:a+r})]}):g.jsxs(g.Fragment,{children:[g.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),g.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),g.jsx("line",{x1:a,y1:l[0].y,x2:a,y2:c[0].y}),g.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 lse({className:n,line:e,zoom:t}){return g.jsx("svg",{className:$e("tl-overlays__item",n),children:e.type==="points"?g.jsx(ose,{...e,zoom:t}):e.type==="gaps"?g.jsx(ase,{...e,zoom:t}):null})}function cse(){return g.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:g.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[g.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),g.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:g.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const use=()=>null;function gz(n,e){const t=P.useRef(n);return e(n,t.current)?t.current:(t.current=n,n)}const dse=(n,e)=>(n??(n=null),e??(e=null),n===e?!0:!n||!e?!1:Wy(n,e));function Ol(n){return gz(n,dse)}const hse=(n,e)=>(n??(n=null),e??(e=null),n===e?!0:!n||!e?!1:t3(n,e));function dh(n){return gz(n,hse)}const mz=P.createContext(null);function fse({overrides:n={},children:e}){const t=dh(n),r=P.useMemo(()=>({Background:Xte,SvgDefs:use,Brush:hC,ZoomBrush:hC,CollaboratorBrush:hC,Cursor:Lj,CollaboratorCursor:Lj,CollaboratorHint:Xre,CollaboratorShapeIndicator:Fj,Grid:Zre,Scribble:Nj,SnapIndicator:lse,Handles:Qre,Handle:Jre,CollaboratorScribble:Nj,ErrorFallback:Sz,ShapeErrorFallback:nse,ShapeIndicatorErrorFallback:ise,Spinner:cse,SelectionBackground:fz,SelectionForeground:tse,ShapeIndicators:pz,ShapeIndicator:Fj,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:Tre,LoadingScreen:ese,...t}),[t]);return g.jsx(mz.Provider,{value:r,children:e})}function Zt(){const n=P.useContext(mz);if(!n)throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return n}const J0={openWindow(n,e){window.open(n,e,"noopener noreferrer")},refreshPage(){window.location.reload()},async hardReset(){var n;return await((n=window.__tldraw__hardReset)==null?void 0:n.call(window))}};function yz(){J0.hardReset()}function pse(){J0.refreshPage()}const gse="https://github.com/tldraw/tldraw/issues/new",Sz=({error:n,editor:e})=>{const t=P.useRef(null),[r,s]=P.useState(!1),[i,o]=P.useState(!1),[a,l]=P.useState(!1);let c=null;try{c=Zt().Canvas??null}catch{}const u=n instanceof Error?n.message:String(n),h=n instanceof Error?n.stack:null,p=ie("isDarkMode",()=>{try{if(e)return e.user.getIsDarkMode()}catch{}return null},[e]),[m,S]=P.useState(null);P.useLayoutEffect(()=>{var T;p!==null&&S(p);let _=(T=t.current)==null?void 0:T.parentElement,E=!1;for(;_;){if(_.classList.contains("tl-theme__dark")||_.classList.contains("tl-theme__light")){E=!0;break}_=_.parentElement}if(E){S(null);return}typeof window<"u"&&"matchMedia"in window&&S(window.matchMedia("(prefers-color-scheme: dark)").matches)},[p]),P.useEffect(()=>{if(i){const _=e==null?void 0:e.timers.setTimeout(()=>{o(!1)},2e3);return()=>clearTimeout(_)}},[i,e]);const x=()=>{const _=document.createElement("textarea");_.value=h??u,document.body.appendChild(_),_.select(),document.execCommand("copy"),_.remove(),o(!0)},v=()=>{pse()},w=async()=>{yz()},C=new URL(gse);return C.searchParams.set("title",u),C.searchParams.set("labels","bug"),C.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
192
|
-
|
|
193
|
-
\`\`\`js
|
|
194
|
-
${h??u}
|
|
195
|
-
\`\`\`
|
|
196
|
-
|
|
197
|
-
My browser: ${navigator.userAgent}`),g.jsxs("div",{ref:t,className:$e("tl-container tl-error-boundary",m===null?"":m?"tl-theme__dark":"tl-theme__light"),children:[g.jsx("div",{className:"tl-error-boundary__overlay"}),e&&g.jsx(zE,{onError:np,fallback:()=>null,children:g.jsx(UE,{editor:e,children:g.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:c?g.jsx(c,{}):null})})}),g.jsx("div",{className:$e("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?g.jsxs(g.Fragment,{children:[g.jsx("h2",{children:"Are you sure?"}),g.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),g.jsxs("div",{className:"tl-error-boundary__content__actions",children:[g.jsx("button",{onClick:()=>l(!1),children:"Cancel"}),g.jsx("button",{className:"tl-error-boundary__reset",onClick:w,children:"Reset data"})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("h2",{children:"Something went wrong"}),g.jsx("p",{children:"Please refresh the page to continue."}),g.jsxs("p",{children:["If you keep seeing this screen, you can create a"," ",g.jsx("a",{href:C.toString(),children:"GitHub issue"})," or ask for help on"," ",g.jsx("a",{href:"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen",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&&g.jsxs(g.Fragment,{children:["Message:",g.jsx("h4",{children:g.jsx("code",{children:u})}),"Stack trace:",g.jsxs("div",{className:"tl-error-boundary__content__error",children:[g.jsx("pre",{children:g.jsx("code",{children:h??u})}),g.jsx("button",{onClick:x,children:i?"Copied!":"Copy"})]})]}),g.jsxs("div",{className:"tl-error-boundary__content__actions",children:[g.jsx("button",{onClick:()=>s(!r),children:r?"Hide details":"Show details"}),g.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[g.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>l(!0),children:"Reset data"}),g.jsx("button",{className:"tl-error-boundary__refresh",onClick:v,children:"Refresh Page"})]})]})]})})]})},vz="TLDRAW_USER_DATA_v3",xz=pt({id:st,name:st.nullable().optional(),color:st.nullable().optional(),locale:st.nullable().optional(),animationSpeed:Xe.nullable().optional(),edgeScrollSpeed:Xe.nullable().optional(),colorScheme:Hp("light","dark","system").optional(),isSnapMode:mt.nullable().optional(),isWrapMode:mt.nullable().optional(),isDynamicSizeMode:mt.nullable().optional(),isPasteAtCursorMode:mt.nullable().optional()}),ya={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8},ZE=Math.max(...Object.values(ya));function mse(n){n.version<ya.AddAnimationSpeed&&(n.user.animationSpeed=1),n.version<ya.AddIsSnapMode&&(n.user.isSnapMode=!1),n.version<ya.MakeFieldsNullable,n.version<ya.AddEdgeScrollSpeed&&(n.user.edgeScrollSpeed=1),n.version<ya.AddExcalidrawSelectMode&&(n.user.isWrapMode=!1),n.version<ya.AllowSystemColorScheme&&(n.user.isDarkMode===!0?n.user.colorScheme="dark":n.user.isDarkMode===!1&&(n.user.colorScheme="light"),delete n.user.isDarkMode),n.version<ya.AddDynamicSizeMode&&(n.user.isDynamicSizeMode=!1),n.version<ya.AddPasteAtCursor&&(n.user.isPasteAtCursorMode=!1),n.version=ZE}const yk=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function wz(){return yk[Math.floor(Math.random()*yk.length)]}function yse(){var n,e;return typeof window<"u"&&"matchMedia"in window?((e=(n=window.matchMedia)==null?void 0:n.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:e.matches)??!1:!1}const Io=Object.freeze({name:"",locale:Hte(),color:wz(),edgeScrollSpeed:1,animationSpeed:yse()?0:1,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,colorScheme:"light"});function yC(){return{id:_t(),color:wz()}}function bz(n){if(n===null||typeof n!="object"||!("version"in n)||!("user"in n)||typeof n.version!="number")return yC();const e=Xt(n);mse(e);try{return xz.validate(e.user)}catch{return yC()}}function Sse(){const n=JSON.parse(EI(vz)||"null")??null;return bz(n)}const Q0=Sn("globalUserData",null);function vse(){_I(vz,JSON.stringify({version:ZE,user:Q0.get()}))}function Cz(n){xz.validate(n),Q0.set(n),vse(),xse()}const Rd=typeof BroadcastChannel<"u"?new BroadcastChannel("tldraw-user-sync"):null;Rd==null||Rd.addEventListener("message",n=>{const e=n.data;(e==null?void 0:e.type)===kz&&(e==null?void 0:e.origin)!==Pz()&&Q0.set(bz(e.data))});let SC=null;function Pz(){return SC===null&&(SC=_t()),SC}const kz="tldraw-user-preferences-change";function xse(){Rd==null||Rd.postMessage({type:kz,origin:Pz(),data:{user:Iz(),version:ZE}})}function Iz(){let n=Q0.get();return n||(n=Sse(),Cz(n)),n}const wse=ce("defaultLocalStorageUserPrefs",()=>Iz());function Ez(n={}){return{userPreferences:n.userPreferences??wse,setUserPreferences:n.setUserPreferences??Cz}}var vC={exports:{}},zj;function bse(){return zj||(zj=1,function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function i(l,c,u,h,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new s(u,h||l,p),S=t?t+c:c;return l._events[S]?l._events[S].fn?l._events[S]=[l._events[S],m]:l._events[S].push(m):(l._events[S]=m,l._eventsCount++),l}function o(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(t?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=t?t+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,S=new Array(m);p<m;p++)S[p]=h[p].fn;return S},a.prototype.listenerCount=function(c){var u=t?t+c:c,h=this._events[u];return h?h.fn?1:h.length:0},a.prototype.emit=function(c,u,h,p,m,S){var x=t?t+c:c;if(!this._events[x])return!1;var v=this._events[x],w=arguments.length,C,_;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),w){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,p),!0;case 5:return v.fn.call(v.context,u,h,p,m),!0;case 6:return v.fn.call(v.context,u,h,p,m,S),!0}for(_=1,C=new Array(w-1);_<w;_++)C[_-1]=arguments[_];v.fn.apply(v.context,C)}else{var E=v.length,T;for(_=0;_<E;_++)switch(v[_].once&&this.removeListener(c,v[_].fn,void 0,!0),w){case 1:v[_].fn.call(v[_].context);break;case 2:v[_].fn.call(v[_].context,u);break;case 3:v[_].fn.call(v[_].context,u,h);break;case 4:v[_].fn.call(v[_].context,u,h,p);break;default:if(!C)for(T=1,C=new Array(w-1);T<w;T++)C[T-1]=arguments[T];v[_].fn.apply(v[_].context,C)}}return!0},a.prototype.on=function(c,u,h){return i(this,c,u,h,!1)},a.prototype.once=function(c,u,h){return i(this,c,u,h,!0)},a.prototype.removeListener=function(c,u,h,p){var m=t?t+c:c;if(!this._events[m])return this;if(!u)return o(this,m),this;var S=this._events[m];if(S.fn)S.fn===u&&(!p||S.once)&&(!h||S.context===h)&&o(this,m);else{for(var x=0,v=[],w=S.length;x<w;x++)(S[x].fn!==u||p&&!S[x].once||h&&S[x].context!==h)&&v.push(S[x]);v.length?this._events[m]=v.length===1?v[0]:v:o(this,m)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=t?t+c:c,this._events[u]&&o(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a}(vC)),vC.exports}var Cse=bse();const Pse=Ua(Cse),Dd="TLDRAW_TAB_ID_v2",Oa=globalThis.window;function kse(){return Oa?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(Oa.navigator.platform)||It.isDarwin&&"ontouchend"in document:!1}const IS=Oa?Oa[Dd]??p3(Dd)??"TLDRAW_INSTANCE_STATE_V1_"+_t():"<error>";Oa&&(Oa[Dd]=IS,kse()?TI(Dd,IS):g3(Dd));Oa==null||Oa.addEventListener("beforeunload",()=>{TI(Dd,IS)});const _z={Initial:0},ev=Math.max(...Object.values(_z));function Ise(n){n.version<_z.Initial,n.version=ev}const Tz=pt({version:Xe,currentPageId:gp.optional(),isFocusMode:mt.optional(),exportBackground:mt.optional(),isDebugMode:mt.optional(),isToolLocked:mt.optional(),isGridMode:mt.optional(),pageStates:Un(pt({pageId:gp,camera:pt({x:Xe,y:Xe,z:Xe}).optional(),selectedShapeIds:Un(yi).optional(),focusedGroupId:yi.nullable().optional()})).optional()});function Ese(n){if(!n||typeof n!="object")return console.warn("Invalid instance state"),null;if(!("version"in n)||typeof n.version!="number")return console.warn("No version in instance state"),null;n.version!==ev&&(n=Xt(n),Ise(n));try{return Tz.validate(n)}catch(e){return console.warn(e),null}}function JE(n){const e=n.query.ids("page");return ce("sessionStateSnapshot",()=>{const t=n.get($r);if(!t)return null;const r=[...e.get()];return{version:ev,currentPageId:t.currentPageId,exportBackground:t.exportBackground,isFocusMode:t.isFocusMode,isDebugMode:t.isDebugMode,isToolLocked:t.isToolLocked,isGridMode:t.isGridMode,pageStates:r.map(s=>{const i=n.get(Yi.createId(s)),o=n.get(jo.createId(s));return{pageId:s,camera:{x:(o==null?void 0:o.x)??0,y:(o==null?void 0:o.y)??0,z:(o==null?void 0:o.z)??1},selectedShapeIds:(i==null?void 0:i.selectedShapeIds)??[],focusedGroupId:(i==null?void 0:i.focusedGroupId)??null}})}},{isEqual:ch})}function Sk(n,e,t){const r=Ese(e);if(!r)return;const s=v4(n.get($r)),i=t!=null&&t.forceOverwrite?r:s,o=t!=null&&t.forceOverwrite?s:r,a=n.schema.types.instance.create({id:$r,...s,currentPageId:r.currentPageId,isDebugMode:(i==null?void 0:i.isDebugMode)??(o==null?void 0:o.isDebugMode),isFocusMode:(i==null?void 0:i.isFocusMode)??(o==null?void 0:o.isFocusMode),isToolLocked:(i==null?void 0:i.isToolLocked)??(o==null?void 0:o.isToolLocked),isGridMode:(i==null?void 0:i.isGridMode)??(o==null?void 0:o.isGridMode),exportBackground:(i==null?void 0:i.exportBackground)??(o==null?void 0:o.exportBackground)});n.atomic(()=>{var l,c,u;for(const h of r.pageStates??[]){if(!n.has(h.pageId))continue;const p=jo.createId(h.pageId),m=Yi.createId(h.pageId),S=n.get(p),x=n.get(m);n.put([jo.create({id:p,x:((l=h.camera)==null?void 0:l.x)??(S==null?void 0:S.x),y:((c=h.camera)==null?void 0:c.y)??(S==null?void 0:S.y),z:((u=h.camera)==null?void 0:u.z)??(S==null?void 0:S.z)}),Yi.create({id:m,pageId:h.pageId,selectedShapeIds:h.selectedShapeIds??(x==null?void 0:x.selectedShapeIds),focusedGroupId:h.focusedGroupId??(x==null?void 0:x.focusedGroupId)})])}n.put([a]),n.ensureStoreIsUsable()})}function _se(n){var s;const e=[];for(const i of Object.values(n))(s=i.typeName)!=null&&s.match(/^(instance.*|pointer|camera)$/)&&e.push(i);const t=e.filter(i=>i.typeName==="instance"&&i.id!==$r)[0];if(!t)return null;const r={version:ev,currentPageId:t.currentPageId,exportBackground:!!t.exportBackground,isFocusMode:!!t.isFocusMode,isDebugMode:!!t.isDebugMode,isToolLocked:!!t.isToolLocked,isGridMode:!1,pageStates:e.filter(i=>i.typeName==="instance_page_state"&&i.instanceId===t.id).map(i=>{const o=n[i.cameraId]??{x:0,y:0,z:1};return{pageId:i.pageId,camera:{x:o.x,y:o.y,z:o.z},selectedShapeIds:i.selectedShapeIds,focusedGroupId:i.focusedGroupId}})};try{return Tz.validate(r),r}catch{return null}}function Mz(n,e,t){let r={};if("store"in e){const o=n.schema.migrateStoreSnapshot(e);if(o.type!=="success")throw new Error("Failed to migrate store snapshot: "+o.reason);r.document={schema:n.schema.serialize(),store:Nf(o.value,(a,{typeName:l})=>n.scopedTypes.document.has(l))}}else r=e;const s=v4(n.get($r)),i=Az.get(n,JE).get();n.atomic(()=>{r.document&&n.loadStoreSnapshot(r.document),s&&n.update($r,o=>({...o,...s})),i&&Sk(n,i),r.session&&Sk(n,r.session,{forceOverwrite:t==null?void 0:t.forceOverwriteSessionState})})}const Az=new qo;function Tse(n){const t=Az.get(n,JE).get();if(!t)throw new Error("Session state is not ready yet");return{document:n.getStoreSnapshot(),session:t}}function Oz(n){const e=[],t=new Set;for(const r of n){if(t.has(r.type))throw new Error(`Binding type "${r.type}" is defined more than once`);e.push(r),t.add(r.type)}return e}function Gl({children:n,className:e="",...t}){return g.jsx("svg",{...t,className:$e("tl-svg-container",e),children:n})}class Ia extends qa{constructor(t){super({...t,isClosed:!1,isFilled:!1});R(this,"start");R(this,"end");R(this,"d");R(this,"u");R(this,"ul");const{start:r,end:s}=t;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(t){const{start:r,end:s,d:i,u:o,ul:a}=this;if(i.len()===0||a===0)return r;const l=k.Sub(t,r).dpr(o)/a,c=r.x+o.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+o.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 k(c,u)}hitTestLineSegment(t,r,s=0){return qE(t,r,this.start,this.end)||this.distanceToLineSegment(t,r)<=s}getSvgPathData(t=!0){const{start:r,end:s}=this;return`${t?`M${r.toFixed()}`:""} L${s.toFixed()}`}}class Yp extends qa{constructor(t){super({isClosed:!1,isFilled:!1,...t});R(this,"points");R(this,"_segments");const{points:r}=t;this.points=r}get segments(){if(!this._segments){this._segments=[];const{vertices:t}=this;for(let r=0,s=t.length-1;r<s;r++){const i=t[r],o=t[r+1];this._segments.push(new Ia({start:i,end:o}))}this.isClosed&&this._segments.push(new Ia({start:t[t.length-1],end:t[0]}))}return this._segments}getLength(){return this.segments.reduce((t,r)=>t+r.length,0)}getVertices(){return this.points}nearestPoint(t){const{segments:r}=this;let s=this.points[0],i=1/0,o,a;for(let l=0;l<r.length;l++)o=r[l].nearestPoint(t),a=k.Dist2(o,t),a<i&&(s=o,i=a);if(!s)throw Error("nearest point not found");return s}hitTestLineSegment(t,r,s=0){const{segments:i}=this;for(let o=0,a=i.length;o<a;o++)if(i[o].hitTestLineSegment(t,r,s))return!0;return!1}getSvgPathData(){const{vertices:t}=this;return t.length<2?"":t.reduce((r,s,i)=>i===0?`M ${s.x} ${s.y}`:`${r} L ${s.x} ${s.y}`,"")}}class Tn extends Yp{constructor(e){super({...e}),this.isClosed=!0}}class Ho extends Tn{constructor(t){const{x:r=0,y:s=0,width:i,height:o}=t;super({...t,points:[new k(r,s),new k(r+i,s),new k(r+i,s+o),new k(r,s+o)]});R(this,"x");R(this,"y");R(this,"w");R(this,"h");this.x=r,this.y=s,this.w=i,this.h=o}getBounds(){return new Se(this.x,this.y,this.w,this.h)}getSvgPathData(){const{x:t,y:r,w:s,h:i}=this;return`M${t},${r} h${s} v${i} h-${s}z`}}class eo{constructor(e){R(this,"options",{});this.editor=e}static configure(e){return class extends this{constructor(){super(...arguments);R(this,"options",{...this.options,...e})}}}getFontFaces(e){return kr}canSnap(e){return!0}canTabTo(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,t){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,t){return!1}canDropShapes(e,t){return!1}expandSelectionOutlinePx(e){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(e){return{}}getHandleSnapGeometry(e){return{}}getText(e){}getAriaDescriptor(e){}}R(eo,"props"),R(eo,"migrations"),R(eo,"type");function Wi(n,e,t={}){const{closed:r=!1,snap:s=1,start:i="outset",end:o="outset",lengthRatio:a=2,style:l="dashed",forceSolid:c=!1}=t;let u=0,h=0,p=1,m=0,S=0;if(c)return{strokeDasharray:"none",strokeDashoffset:"none"};switch(l){case"dashed":{p=1,u=Math.min(e*a,n/4);break}case"dotted":{p=100,u=e/p;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(i==="outset"?(n+=u/2,S+=u/2):i==="skip"&&(n-=u,S-=u),o==="outset"?n+=u/2:o==="skip"&&(n-=u)),h=Math.floor(n/u/(2*p)),h-=h%s,h<3&&l==="dashed"?n/e<4?(u=n,h=1,m=0):(u=n*(1/3),m=n*(1/3)):(u=n/h/(2*p),r?(S=u/2,m=(n-h*u)/h):m=(n-h*u)/Math.max(1,h-1)),{strokeDasharray:[u,m].join(" "),strokeDashoffset:S.toString()}}function $j({bounds:n,className:e}){const t=te(),r=ie("zoom level",()=>t.getZoomLevel(),[t]);return g.jsx("g",{className:e,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:n.sides.map((s,i)=>{const{strokeDasharray:o,strokeDashoffset:a}=Wi(s[0].dist(s[1]),1/r,{style:"dashed",lengthRatio:4});return g.jsx("line",{x1:s[0].x,y1:s[0].y,x2:s[1].x,y2:s[1].y,strokeDasharray:o,strokeDashoffset:a},i)})})}class yy extends eo{canTabTo(){return!1}hideSelectionBoundsFg(){return!0}canBind(){return!1}getDefaultProps(){return{}}getGeometry(e){const t=this.editor.getSortedChildIdsForParent(e.id);return t.length===0?new Ho({width:1,height:1,isFilled:!1}):new Js({children:t.map(r=>{const s=this.editor.getShape(r);return this.editor.getShapeGeometry(r).transform(this.editor.getShapeLocalTransform(s),{isLabel:!1})})})}component(e){const t=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")),i=this.editor.getCurrentPageState().focusedGroupId!==e.id;if(!t&&(i||s))return null;const o=this.editor.getShapeGeometry(e).bounds;return g.jsx(Gl,{children:g.jsx($j,{className:"tl-group",bounds:o})})}indicator(e){const t=this.editor.getShapeGeometry(e).bounds;return g.jsx($j,{className:"",bounds:t})}onChildrenChange(e){const t=this.editor.getSortedChildIdsForParent(e.id);if(t.length===0){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([e.id]);return}else if(t.length===1){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(t,e.parentId),this.editor.deleteShapes([e.id]);return}}}R(yy,"type","group"),R(yy,"props",A4),R(yy,"migrations",O4);const Rz=[yy],Mse=new Set(Rz.map(n=>n.type));function Dz(n){const e=[...Rz],t=new Set;for(const r of n){if(Mse.has(r.type))throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(t.has(r.type))throw new Error(`Shape type "${r.type}" is defined more than once`);e.push(r),t.add(r.type)}return e}var hh=KN();const Ase=Ua(hh);function jz(n,e){const t=new Map;return async function(s){const i=t.get(s);if(i)return i;const o=(async()=>{try{const a=await Zi(s,e);return Je(a.ok),await n(a)}catch(a){return console.error(a),null}})();return t.set(s,o),o}}const tv=jz(async n=>await Kr.blobToDataUrl(await n.blob())),Ose=/@import\s+(?:"([^"]+)"|'([^']+)'|url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\))([^;]+);/gi,Rse=/@font-face\s*{([^}]+)}/gi,Lz=/url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\)/gi,Dse=/(?:^|;)\s*font-family\s*:\s*(?:([^'"][^;\n]+)|"([^"]+)"|'([^']+)')\s*(?:;|$)/gi;function jse(n){return Array.from(n.matchAll(Ose),e=>({url:e[1]||e[2]||e[3]||e[4]||e[5],extras:e[6]}))}function Nz(n,e){return Array.from(n.matchAll(Rse),t=>{const r=t[1],s=Array.from(r.matchAll(Lz),o=>{var l;const a=o[1]||o[2]||o[3];return{original:a,resolved:((l=Ze(a,e))==null?void 0:l.href)??null}}),i=new Set(Array.from(r.matchAll(Dse),o=>(o[1]||o[2]||o[3]).toLowerCase()));return{fontFace:r,urls:s,fontFamilies:i}})}function Lse(n){const e=/\s*(?:([^'"][^;\n\s,]+)|"([^"]+)"|'([^']+)')\s*/gi,t=/\s*,\s*/gi,r=new Set;for(;;){const s=e.exec(n);if(!s)break;const i=s[1]||s[2]||s[3];if(r.add(i.toLowerCase()),t.lastIndex=e.lastIndex,!t.exec(n))break;e.lastIndex=t.lastIndex}return r}function Fz(n){return!(n.startsWith("-")||n.startsWith("animation")||n.startsWith("transition")||n==="cursor"||n==="pointer-events"||n==="user-select"||n==="touch-action")}function Nse(n,e){return{imports:jse(n),fontFaces:Nz(n,e)}}function Fse(n){return Array.from(n.matchAll(Lz),e=>({original:e[0],url:e[1]||e[2]||e[3]}))}var zse=Object.create,zz=Object.defineProperty,$se=Object.getOwnPropertyDescriptor,Bse=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),$z=n=>{throw TypeError(n)},Bz=(n,e,t)=>e in n?zz(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Use=n=>[,,,zse(null)],Uz=["class","method","getter","setter","accessor","field","value","get","set"],Hz=n=>n!==void 0&&typeof n!="function"?$z("Function expected"):n,Hse=(n,e,t,r,s)=>({kind:Uz[n],name:e,metadata:r,addInitializer:i=>t._?$z("Already initialized"):s.push(Hz(i||null))}),Kse=(n,e)=>Bz(e,Bse("metadata"),n[3]),Wse=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},Vse=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=Uz[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,$se(s,t)),w=r.length-1;w>=0;w--)l=Hse(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,Hz(o)&&(v[S]=o);return v&&zz(s,t,v),s},Rm=(n,e,t)=>Bz(n,typeof e!="symbol"?e+"":e,t),Kz,nv;const Wz="tldraw-svg-export";Kz=[ks];class QE{constructor(){Wse(nv,5,this),Rm(this,"fontFacesPromise",null),Rm(this,"foundFontNames",new Set),Rm(this,"fontFacesToEmbed",new Set),Rm(this,"pendingPromises",[])}startFindingCurrentDocumentFontFaces(){Je(!this.fontFacesPromise,"FontEmbedder already started"),this.fontFacesPromise=qse()}onFontFamilyValue(e){Je(this.fontFacesPromise,"FontEmbedder not started");const t=Lse(e);for(const r of t){if(this.foundFontNames.has(r))return;this.foundFontNames.add(r),this.pendingPromises.push(this.fontFacesPromise.then(s=>{const i=s.filter(o=>o.fontFamilies.has(r));for(const o of i)if(!this.fontFacesToEmbed.has(o)){this.fontFacesToEmbed.add(o);for(const a of o.urls)!a.resolved||a.embedded||(a.embedded=tv(a.resolved))}}))}}async createCss(){await Promise.all(this.pendingPromises);let e="";for(const t of this.fontFacesToEmbed){let r=`@font-face {${t.fontFace}}`;for(const s of t.urls){if(!s.embedded)continue;const i=await s.embedded;i&&(r=r.replace(s.original,i))}e+=r}return e}}nv=Use();Vse(nv,1,"onFontFamilyValue",Kz,QE);Kse(nv,QE);async function qse(){var t;const n=[],e=Array.from(document.styleSheets).filter(r=>{var s;return!((s=r.ownerNode)!=null&&s.closest(`.${Wz}`))});for(const r of e){let s;try{s=r.cssRules}catch{}if(s){for(const i of r.cssRules)if(i instanceof CSSFontFaceRule)n.push(Nz(i.cssText,r.href??document.baseURI));else if(i instanceof CSSImportRule){const o=new URL(i.href,((t=i.parentStyleSheet)==null?void 0:t.href)??document.baseURI);n.push(vk(o.href))}}else r.href&&n.push(vk(r.href))}return rt(await Promise.all(n)).flat()}const vk=jz(async n=>{const e=Nse(await n.text(),n.url),t=await Promise.all(e.imports.map(({url:r})=>vk(new URL(r,n.url).href)));return[...e.fontFaces,...rt(t).flat()]}),zs=(n,e,{currentColor:t})=>n==="currentColor"||n===t,dt=(n,e,{parentStyles:t})=>t[e]===n,an=n=>(e,t,{getStyle:r})=>{const s=r(`border-${n}-width`),i=r(`border-${n}-style`);return s==="0px"||i==="none"},Vz={"border-block-end-color":zs,"border-block-start-color":zs,"border-bottom-color":zs,"border-inline-end-color":zs,"border-inline-start-color":zs,"border-left-color":zs,"border-right-color":zs,"border-top-color":zs,"caret-color":zs,"column-rule-color":zs,"outline-color":zs,"text-decoration":(n,e,{currentColor:t})=>n==="none solid currentColor"||n==="none solid "+t,"text-decoration-color":zs,"text-emphasis-color":zs,"border-collapse":dt,"border-spacing":dt,"caption-side":dt,cursor:dt,direction:dt,"empty-cells":dt,"font-family":dt,"font-size":dt,"font-style":dt,"font-variant":dt,"font-weight":dt,"font-size-adjust":dt,"font-stretch":dt,font:dt,"letter-spacing":dt,"line-height":dt,"list-style-image":dt,"list-style-position":dt,"list-style-type":dt,"list-style":dt,orphans:dt,"overflow-wrap":dt,quotes:dt,"stroke-linecap":dt,"stroke-linejoin":dt,"tab-size":dt,"text-align":dt,"text-align-last":dt,"text-indent":dt,"text-justify":dt,"text-shadow":dt,"text-transform":dt,visibility:dt,"white-space":dt,"white-space-collapse":dt,widows:dt,"word-break":dt,"word-spacing":dt,"word-wrap":dt,"border-top":an("top"),"border-right":an("right"),"border-bottom":an("bottom"),"border-left":an("left"),"border-block-end":an("block-end"),"border-block-start":an("block-start"),"border-inline-end":an("inline-end"),"border-inline-start":an("inline-start"),"border-top-style":an("top"),"border-right-style":an("right"),"border-bottom-style":an("bottom"),"border-left-style":an("left"),"border-block-end-style":an("block-end"),"border-block-start-style":an("block-start"),"border-inline-end-style":an("inline-end"),"border-inline-start-style":an("inline-start"),"border-top-width":an("top"),"border-right-width":an("right"),"border-bottom-width":an("bottom"),"border-left-width":an("left"),"border-block-end-width":an("block-end"),"border-block-start-width":an("block-start"),"border-inline-end-width":an("inline-end")};function qz(n){if(n.shadowRoot)return n.shadowRoot.childNodes;if(Zse(n)){const e=n.assignedNodes();if(e!=null&&e.length)return e}return n.childNodes}function*xk(n){for(const e of qz(n))Gse(e)&&(yield e)}function rv(n){var e;return((e=n.ownerDocument)==null?void 0:e.defaultView)??globalThis}function Gse(n){return n instanceof rv(n).Element}function Yse(n){return n instanceof rv(n).ShadowRoot}function Xse(n){return"getRootNode"in n&&Yse(n.getRootNode())}function Zse(n){return Xse(n)&&n instanceof rv(n).HTMLSlotElement}function Jse(n){return n.style}function e_(n,e){return rv(n).getComputedStyle(n,e)}const Gd={};class Qse{constructor(e){R(this,"styles",new Map);R(this,"fonts",new QE);this.root=e}readRootElementStyles(e){this.readElementStyles(e,{shouldRespectDefaults:!1,shouldSkipInheritedParentStyles:!1});const t=Array.from(xk(e));for(;t.length;){const r=t.pop();t.push(...xk(r)),this.readElementStyles(r,{shouldRespectDefaults:!0,shouldSkipInheritedParentStyles:!0})}}readElementStyles(e,{shouldRespectDefaults:t=!0,shouldSkipInheritedParentStyles:r=!0}){var a;const s=t?rie(e.tagName.toLowerCase()):Gd,i=Object.assign({},Gd);if(r){let l=e.parentElement;for(;l;){const c=(a=this.styles.get(l))==null?void 0:a.self;for(const u in c)i[u]||(i[u]=c[u]);l=l.parentElement}}const o={self:eie(e,{defaultStyles:s,parentStyles:i}),before:Bj(e,"::before"),after:Bj(e,"::after")};this.styles.set(e,o)}fetchResources(){const e=[];for(const t of this.styles.values())for(const r of gn(t))if(r)for(const[s,i]of Object.entries(r)){if(!i)continue;s==="font-family"&&this.fonts.onFontFamilyValue(i);const o=Fse(i);o.length!==0&&e.push(...o.map(async({url:a,original:l})=>{const c=await tv(a)??"data:";r[s]=i.replace(l,`url("${c}")`)}))}return Promise.all(e)}unwrapCustomElements(){const e=new Set,t=(r,s)=>{if(e.has(r))return;e.add(r);const i=r.shadowRoot;if(i){const o=document.createElement("div");this.styles.set(o,this.styles.get(r)),o.setAttribute("data-tl-custom-element",r.tagName),(s??r.parentElement).appendChild(o);for(const a of i.childNodes)a instanceof Element?t(a,o):o.appendChild(a.cloneNode(!0));r.remove()}else if(s){if(r.tagName.toLowerCase()==="style")return;const o=r.cloneNode(!1);this.styles.set(o,this.styles.get(r)),s.appendChild(o);for(const a of qz(r))a instanceof Element?t(a,o):o.appendChild(a.cloneNode(!0))}};for(const r of this.styles.keys())t(r,null)}embedStyles(){let e="";for(const[t,r]of this.styles){if(r.after||r.before){const i=`pseudo-${_t()}`;t.classList.add(i),r.before&&(e+=`.${i}::before {${Uj(r.before)}}
|
|
198
|
-
`),r.after&&(e+=`.${i}::after {${Uj(r.after)}}
|
|
199
|
-
`)}const s=Jse(t);for(const[i,o]of Object.entries(r.self))o&&s.setProperty(i,o);s.fontKerning==="auto"&&(s.fontKerning="normal")}return e}async getFontFaceCss(){return await this.fonts.createCss()}dispose(){nie()}}function eie(n,{defaultStyles:e,parentStyles:t}){return n.computedStyleMap?Gz(n.computedStyleMap(),{defaultStyles:e,parentStyles:t}):t_(e_(n),{defaultStyles:e,parentStyles:t})}function Bj(n,e){const t=e_(n,e),r=t.getPropertyValue("content");if(!(r===""||r==="none"))return t_(t,{defaultStyles:Gd,parentStyles:Gd})}function Gz(n,{defaultStyles:e,parentStyles:t}){var o;const r={},i={currentColor:((o=n.get("color"))==null?void 0:o.toString())||"",parentStyles:t,defaultStyles:e,getStyle:a=>{var l;return((l=n.get(a))==null?void 0:l.toString())??""}};for(const a of n.keys()){if(!Fz(a))continue;const l=n.get(a).toString();if(e[a]===l)continue;const c=bn(Vz,a);c&&c(l,a,i)||(r[a]=l)}return r}function t_(n,{defaultStyles:e,parentStyles:t}){const r={},i={currentColor:n.color,parentStyles:t,defaultStyles:e,getStyle:o=>n.getPropertyValue(o)};for(const o in n){if(!Fz(o))continue;const a=n.getPropertyValue(o);if(e[o]===a)continue;const l=bn(Vz,o);l&&l(a,o,i)||(r[o]=a)}return r}function Uj(n){let e="";for(const[t,r]of Object.entries(n))e+=`${t}: ${r};`;return e}let jd;const Hj={};function tie(){if(!jd){const n=document.createElement("iframe");n.style.display="none",document.body.appendChild(n);const e=zr(n.contentDocument,"frame must have a document"),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");t.appendChild(r),e.body.appendChild(t),jd={iframe:n,foreignObject:r,document:e}}return jd}function nie(){jd&&(document.body.removeChild(jd.iframe),jd=void 0)}const Kj={defaultStyles:Gd,parentStyles:Gd};function rie(n){let e=Hj[n];if(!e){const{foreignObject:t,document:r}=tie(),s=r.createElement(n);t.appendChild(s),e=s.computedStyleMap?Gz(s.computedStyleMap(),Kj):t_(e_(s),Kj),t.removeChild(s),Hj[n]=e}return e}function sie(n,e){Array.from(n.attributes).forEach(r=>{e.setAttribute(r.name,r.value)})}function Wj(n,e){return n.replaceWith(e),e}async function Hf(n,e){const t=document.createElement("img");e&&sie(e,t),t.setAttribute("src",n??"data:"),t.setAttribute("decoding","sync"),t.setAttribute("loading","eager");try{await t.decode()}catch{}return t}async function iie(n){try{const e=n.toDataURL();return await Hf(e,n)}catch{return await Hf(null,n)}}async function oie(n){try{const e=await Hs.getVideoFrameAsDataUrl(n);return Hf(e,n)}catch(e){console.error("Could not get video frame",e)}if(n.poster){const e=await tv(n.poster);return Hf(e,n)}return Hf(null,n)}async function Yz(n){if(n instanceof HTMLCanvasElement)return Wj(n,await iie(n));if(n instanceof HTMLVideoElement)return Wj(n,await oie(n));if(n instanceof HTMLImageElement){const e=n.currentSrc||n.src,t=await tv(e);n.setAttribute("src",t??"data:"),n.setAttribute("decoding","sync"),n.setAttribute("loading","eager");try{await n.decode()}catch{}return n}else n instanceof HTMLInputElement?n.setAttribute("value",n.value):n instanceof HTMLTextAreaElement&&(n.textContent=n.value);await Promise.all(Array.from(xk(n),e=>Yz(e)))}function Pa(n){const e=P.useRef();return P.useLayoutEffect(()=>{e.current=n}),P.useDebugValue(n),P.useCallback((...t)=>{const r=e.current;return Je(r,"fn does not exist"),r(...t)},[])}const n_=P.createContext(null);function aie({context:n,editor:e,children:t}){const r=e.options.exportProvider;return g.jsx(UE,{editor:e,children:g.jsx(X4,{container:e.getContainer(),children:g.jsx(n_.Provider,{value:n,children:g.jsx(r,{children:t})})})})}function Xp(){return P.useContext(n_)}function lie(){const n=P.useContext(n_),[e]=P.useState(xI);return P.useEffect(()=>(n==null||n.waitUntil(e),()=>{e.resolve()}),[e,n]),Pa(()=>{e.resolve()})}var cie=Object.create,Xz=Object.defineProperty,uie=Object.getOwnPropertyDescriptor,die=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),Zz=n=>{throw TypeError(n)},Jz=(n,e,t)=>e in n?Xz(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,hie=n=>[,,,cie(null)],Qz=["class","method","getter","setter","accessor","field","value","get","set"],e$=n=>n!==void 0&&typeof n!="function"?Zz("Function expected"):n,fie=(n,e,t,r,s)=>({kind:Qz[n],name:e,metadata:r,addInitializer:i=>t._?Zz("Already initialized"):s.push(e$(i||null))}),pie=(n,e)=>Jz(e,die("metadata"),n[3]),gie=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},mie=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=Qz[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,uie(s,t)),w=r.length-1;w>=0;w--)l=fie(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,e$(o)&&(v[S]=o);return v&&Xz(s,t,v),s},Vj=(n,e,t)=>Jz(n,typeof e!="symbol"?e+"":e,t),t$,sv;t$=[ks];class r_{constructor(e){this.maxDelayTimeMs=e,gie(sv,5,this),Vj(this,"isResolved",!1),Vj(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(t=>console.error("Error while waiting for export:",t)))}async resolvePromises(){let e=null;for(;this.promisesToWaitFor.length!==e;)e=this.promisesToWaitFor.length,await Promise.allSettled(this.promisesToWaitFor),await TP(0)}async resolve(){const e=TP(this.maxDelayTimeMs).then(()=>"timeout"),t=this.resolvePromises().then(()=>"resolved");await Promise.race([e,t])==="timeout"&&console.warn("[tldraw] Export delay timed out after ${this.maxDelayTimeMs}ms"),this.isResolved=!0}}sv=hie();mie(sv,1,"waitUntil",t$,r_);pie(sv,r_);function yie(n,e,t={}){var w,C;if(!window.document)throw Error("No document");const{scale:r=1,background:s=n.getInstanceState().exportBackground,padding:i=n.options.defaultSvgPadding,preserveAspectRatio:o}=t,a=t.darkMode??n.user.getIsDarkMode(),l=n.getShapeAndDescendantIds(e),c=n.getUnorderedRenderingShapes(!1).filter(({id:_})=>l.has(_));let u=null;if(t.bounds)u=t.bounds;else for(const{id:_}of c){const E=n.getShapeMaskedPageBounds(_);E&&(u?u.union(E):u=E.clone())}if(!u)return;const h=e.length===1&&n.isShapeOfType(n.getShape(e[0]),"frame")?e[0]:null;h||u.expandBy(i);const p=u.width*r,m=u.height*r;try{(C=(w=document.body).focus)==null||C.call(w)}catch{}const S=new r_(n.options.maxExportDelayMs),x=xI();return S.waitUntil(x),{jsx:g.jsx(Sie,{editor:n,preserveAspectRatio:o,scale:r,pixelRatio:t.pixelRatio??null,bbox:u,background:s,singleFrameShapeId:h,isDarkMode:a,renderingShapes:c,onMount:x.resolve,waitUntil:S.waitUntil}),width:p,height:m,exportDelay:S}}function Sie({editor:n,preserveAspectRatio:e,scale:t,pixelRatio:r,bbox:s,background:i,singleFrameShapeId:o,isDarkMode:a,renderingShapes:l,onMount:c,waitUntil:u}){const h=vu(),p=Va({isDarkMode:a}),m=Np("export state",{defsById:{},shapeElements:null}),{defsById:S,shapeElements:x}=ie(m),v=Pa(_=>{m.update(E=>{if(Ci(E.defsById,_.key))return E;const T=Promise.resolve(_.getElement());return u(T.then(A=>{m.update(O=>({...O,defsById:{...O.defsById,[_.key]:{pending:!1,element:A}}}))})),{...E,defsById:{...E.defsById,[_.key]:{pending:!0,element:T}}}})}),w=P.useMemo(()=>({isDarkMode:a,waitUntil:u,addExportDef:v,scale:t,pixelRatio:r,async resolveAssetUrl(_,E){const T=n.getAsset(_);return!T||T.type!=="image"&&T.type!=="video"?null:await n.resolveAssetUrl(_,{screenScale:t*(E/T.props.w),shouldResolveToOriginal:r===null,dpr:r??void 0})}}),[a,u,v,t,r,n]),C=P.useRef(!1);return P.useLayoutEffect(()=>{if(C.current)throw new Error("SvgExport should only render once - do not use with react strict mode");C.current=!0,(async()=>{const _={},E=l.map(async({id:A,opacity:O,index:D,backgroundIndex:$})=>{var L,N;if(A===o)return[];const H=n.getShape(A);if(n.isShapeOfType(H,"group"))return[];const G=[],J=n.getShapeUtil(H);if(J.toSvg||J.toBackgroundSvg){const[U,Y]=await Promise.all([(L=J.toSvg)==null?void 0:L.call(J,H,w),(N=J.toBackgroundSvg)==null?void 0:N.call(J,H,w)]),W=n.getShapePageTransform(H);let z=W.toCssString(),V=1;"scale"in H.props&&H.props.scale!==1&&(V=H.props.scale,z=`${z} scale(${H.props.scale}, ${H.props.scale})`);const ee=n.getShapeMask(H.id),B=ee?he.From(he.Inverse(W)).applyToPoints(ee):null,Q=$E(h,H.id);B&&(_[Q]={pending:!1,element:g.jsx("clipPath",{id:Q,children:g.jsx("path",{d:`M${B.map(({x:me,y:Pe})=>`${me/V},${Pe/V}`).join("L")}Z`})})}),U&&G.push({zIndex:D,element:g.jsx("g",{transform:z,opacity:O,clipPath:ee?`url(#${Q})`:void 0,children:U},`fg_${H.id}`)}),Y&&G.push({zIndex:$,element:g.jsx("g",{transform:z,opacity:O,clipPath:ee?`url(#${Q})`:void 0,children:Y},`bg_${H.id}`)})}else G.push({zIndex:D,element:g.jsx(qj,{shape:H,util:J,component:dz,className:"tl-shape",bbox:s,opacity:O},`fg_${H.id}`)}),J.backgroundComponent&&G.push({zIndex:$,element:g.jsx(qj,{shape:H,util:J,component:hz,className:"tl-shape tl-shape-background",bbox:s,opacity:O},`bg_${H.id}`)});return G}),T=(await Promise.all(E)).flat();hh.flushSync(()=>{m.update(A=>({...A,shapeElements:T.sort((O,D)=>O.zIndex-D.zIndex).map(({element:O})=>O),defsById:{...A.defsById,..._}}))})})()},[s,n,w,h,l,o,m]),P.useEffect(()=>{const _=new Set;for(const{id:E}of l)for(const T of n.fonts.getShapeFontFaces(E))_.add(T);for(const E of _)v({key:_t(),getElement:async()=>{const T=await n.fonts.toEmbeddedCssDeclaration(E);return g.jsx("style",{nonce:n.options.nonce,children:T})}})},[n,l,v]),P.useEffect(()=>{x!==null&&c()},[c,x]),g.jsx(aie,{editor:n,context:w,children:g.jsxs("svg",{preserveAspectRatio:e,direction:"ltr",width:s.width*t,height:s.height*t,viewBox:`${s.minX} ${s.minY} ${s.width} ${s.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:i?o?p.solid:p.background:"transparent"},"data-color-mode":a?"dark":"light",className:`tl-container tl-theme__force-sRGB ${a?"tl-theme__dark":"tl-theme__light"}`,children:[g.jsx("defs",{children:Object.entries(S).map(([_,E])=>E.pending?null:g.jsx(P.Fragment,{children:E.element},_))}),x]})})}function qj({shape:n,util:e,className:t,component:r,bbox:s,opacity:i}){const o=te(),a=he.Translate(-s.minX,-s.minY).multiply(o.getShapePageTransform(n.id)),l=o.getShapeGeometry(n.id).bounds,c=Math.max(l.width,1),u=Math.max(l.height,1);return g.jsx(zE,{fallback:()=>null,children:g.jsx("foreignObject",{x:s.minX,y:s.minY,width:s.w,height:s.h,className:"tl-shape-foreign-object tl-export-embed-styles",children:g.jsx("div",{className:t,"data-shape-type":n.type,style:{clipPath:o.getShapeClipPath(n.id),transform:a.toCssString(),width:c,height:u,opacity:i},children:g.jsx(r,{shape:n,util:e})})})})}let vie=1;async function xie(n,e,t={}){const r=yie(n,e,t);if(!r)return;const s=n.getContainer(),i=document.createElement("div");i.className=Wz,i.inert=!0,i.tabIndex=-1,Object.assign(i.style,{position:"absolute",top:"0px",left:"0px",width:r.width+"px",height:r.height+"px",pointerEvents:"none",opacity:0}),s.appendChild(i);const o=WN.createRoot(i,{identifierPrefix:`export_${vie++}_`});try{await Promise.resolve(),hh.flushSync(()=>{o.render(r.jsx)}),await r.exportDelay.resolve();const a=i.firstElementChild;return Je(a instanceof SVGSVGElement,"Expected an SVG element"),await wie(a),{svg:a,width:r.width,height:r.height}}finally{setTimeout(()=>{o.unmount(),s.removeChild(i)},0)}}async function wie(n){const e=[...n.querySelectorAll("foreignObject.tl-export-embed-styles > *")];if(!e.length)return;const t=new Qse(n);try{t.fonts.startFindingCurrentDocumentFontFaces(),await Promise.all(e.map(i=>Yz(i)));for(const i of e)t.readRootElementStyles(i);await t.fetchResources();const r=await t.getFontFaceCss();t.unwrapCustomElements();const s=t.embedStyles();if(r||s){const i=document.createElementNS("http://www.w3.org/2000/svg","style");i.textContent=`${r}
|
|
200
|
-
${s}`,n.prepend(i)}}finally{t.dispose()}}let xC=null;function bie(){return xC||(xC={maxWidth:wC("width"),maxHeight:wC("height"),maxArea:wC("area")}),xC}/*!
|
|
201
|
-
* Extracted from https://github.com/jhildenbiddle/canvas-size
|
|
202
|
-
* MIT License: https://github.com/jhildenbiddle/canvas-size/blob/master/LICENSE
|
|
203
|
-
* Copyright (c) John Hildenbiddle
|
|
204
|
-
*/const Gj=8192,Cie=4096*4096,Pie={area:[16384,14188,11402,11180,10836,8192,4096],height:[8388607,65535,32767,16384,8192,4096],width:[4194303,65535,32767,16384,8192,4096]};function wC(n){const e=document.createElement("canvas");e.width=1,e.height=1;const t=e.getContext("2d");for(const r of Pie[n]){const s=n==="height"?1:r,i=n==="width"?1:r,o=document.createElement("canvas");o.width=s,o.height=i,o.getContext("2d").fillRect(s-1,i-1,1,1),t.drawImage(o,s-1,i-1,1,1,0,0,1,1);const l=t.getImageData(0,0,1,1).data[3]!==0;if(o.width=0,o.height=0,l)return e.width=0,e.height=0,n==="area"?r*r:r}throw e.width=0,e.height=0,Error("Failed to determine maximum canvas dimension")}function kie(n,e){if(n<=Gj&&e<=Gj&&n*e<=Cie)return[n,e];const{maxWidth:t,maxHeight:r,maxArea:s}=bie(),i=n/e;if(n>t&&(n=t,e=n/i),e>r&&(e=r,n=e*i),n*e>s){const o=Math.sqrt(s/(n*e));n*=o,e*=o}return[n,e]}async function Iie(n,e){const{type:t,width:r,height:s,quality:i=1,pixelRatio:o=2}=e;let[a,l]=kie(r*o,s*o);a=Math.floor(a),l=Math.floor(l);const c=a/r,u=await Kr.blobToDataUrl(new Blob([n],{type:"image/svg+xml"})),h=await new Promise(m=>{const S=rp();S.crossOrigin="anonymous",S.onload=async()=>{It.isSafari&&await TP(250);const x=document.createElement("canvas"),v=x.getContext("2d");x.width=a,x.height=l,v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",v.drawImage(S,0,0,a,l),URL.revokeObjectURL(u),m(x)},S.onerror=()=>{m(null)},S.src=u});if(!h)return null;const p=await new Promise(m=>h.toBlob(S=>{(!S||ln.throwToBlob.get())&&m(null),m(S)},"image/"+t,i));if(!p)return null;if(t==="png"){const m=new DataView(await p.arrayBuffer());return Ao.setPhysChunk(m,c,{type:"image/"+t})}else return p}const Br={menus:Sn("open menus",[]),getOpenMenus(n){return n?this.menus.get().filter(e=>e.endsWith("-"+n)):this.menus.get()},addOpenMenu(n,e=""){const t=e?`${n}-${e}`:n,r=new Set(this.menus.get());r.has(t)||(r.add(t),this.menus.set([...r]))},deleteOpenMenu(n,e=""){const t=e?`${n}-${e}`:n,r=new Set(this.menus.get());r.has(t)&&(r.delete(t),this.menus.set([...r]))},clearOpenMenus(n){this.menus.set(n?this.menus.get().filter(e=>!e.endsWith("-"+n)):[])},_hiddenMenus:[],hideOpenMenus(n){if(this._hiddenMenus=[...this.getOpenMenus(n)],this._hiddenMenus.length!==0)for(const e of this._hiddenMenus)this.deleteOpenMenu(e,n)},showOpenMenus(n){if(this._hiddenMenus.length!==0){for(const e of this._hiddenMenus)this.addOpenMenu(e,n);this._hiddenMenus=[]}},isMenuOpen(n,e){return this.getOpenMenus(e).includes(n)},hasOpenMenus(n){return this.getOpenMenus(n).length>0},hasAnyOpenMenus(){return this.getOpenMenus().length>0},forContext(n){return{getOpenMenus:()=>this.getOpenMenus(n),addOpenMenu:e=>this.addOpenMenu(e,n),deleteOpenMenu:e=>this.deleteOpenMenu(e,n),clearOpenMenus:()=>this.clearOpenMenus(n),isMenuOpen:e=>this.isMenuOpen(e,n),hasOpenMenus:()=>this.hasOpenMenus(n),hasAnyOpenMenus:()=>this.hasAnyOpenMenus()}}},ES=new uq,Eie={maxShapesPerPage:4e3,maxFilesAtOnce:100,maxPages:40,animationMediumMs:320,followChaseViewportSnap:2,doubleClickDurationMs:450,multiClickDurationMs:200,coarseDragDistanceSquared:36,dragDistanceSquared:16,defaultSvgPadding:32,cameraSlideFriction:.09,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:P.Fragment,enableToolbarKeyboardShortcuts:!0,maxFontsToLoadBeforeRender:1/0,nonce:void 0};function Yj(n,e){if(!e)return!1;switch(n.type){case"mixed":return e.type==="mixed";case"shared":return e.type==="shared"&&n.value===e.value;default:throw An(n)}}class _ie{constructor(e){R(this,"map");this.map=new Map(e)}get(e){return this.map.get(e)}getAsKnownValue(e){const t=this.get(e);if(t&&t.type!=="mixed")return t.value}get size(){return this.map.size}equals(e){if(this.size!==e.size)return!1;const t=new Set;for(const[r,s]of this){if(!Yj(s,e.get(r)))return!1;t.add(r)}for(const[r,s]of e)if(!t.has(r)&&!Yj(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 wk extends _ie{set(e,t){this.map.set(e,t)}applyValue(e,t){const r=this.get(e);if(!r){this.set(e,{type:"shared",value:t});return}switch(r.type){case"mixed":return;case"shared":r.value!==t&&this.set(e,{type:"mixed"});return;default:An(r,"type")}}}function Tie(n,e,t){return Zi(n).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],e,{type:t})})}const Mie="https://cdn.tldraw.com";function _n(){return`${Mie}/${W4}`}function Aie(n){switch(n.type){case"shapes":return`s${n.shapeIds.map(t=>bC(t.slice(6))).join(".")}`;case"page":return"p"+bC(Wr.parseId(n.pageId));case"viewport":{const{bounds:e,pageId:t}=n;let r=`v${Math.round(e.x)}.${Math.round(e.y)}.${Math.round(e.w)}.${Math.round(e.h)}`;return t&&(r+="."+bC(Wr.parseId(t))),r}default:An(n)}}function Oie(n){switch(n[0]){case"s":return{type:"shapes",shapeIds:n.slice(1).split(".").filter(Boolean).map(r=>Dt(decodeURIComponent(r)))};case"p":return{type:"page",pageId:Wr.createId(decodeURIComponent(n.slice(1)))};case"v":{const[t,r,s,i,o]=n.slice(1).split(".");return{type:"viewport",bounds:new Se(Number(t),Number(r),Number(s),Number(i)),pageId:o?Wr.createId(decodeURIComponent(o)):void 0}}default:throw Error("Invalid deep link string")}}function bC(n){return encodeURIComponent(n).replace(/\./g,"%2E")}function Rie(n,e){var s;let t=n;const r=new Set(e);for(;r.has(t);)t=(s=/^.*(\d+)$/.exec(t))!=null&&s[1]?t.replace(/(\d+)(?=\D?)$/,i=>(+i+1).toString()):`${t} 1`;return t}function Dm(n,e,t,r){if(t.length===0)return[];const s=new Map;for(const o of rt(t.map(a=>n.getShape(a)))){const{parentId:a}=o;s.has(a)||s.set(a,{children:rt(n.getSortedChildIdsForParent(a).map(l=>n.getShape(l))),moving:new Set}),s.get(a).moving.add(o)}const i=[];switch(e){case"toBack":{s.forEach(({moving:o,children:a})=>Die(o,a,i));break}case"toFront":{s.forEach(({moving:o,children:a})=>jie(o,a,i));break}case"forward":{s.forEach(({moving:o,children:a})=>Lie(n,o,a,i,r));break}case"backward":{s.forEach(({moving:o,children:a})=>Nie(n,o,a,i,r));break}}return i}function Die(n,e,t){const r=e.length;if(n.size===r)return;let s,i;for(let o=0;o<r;o++){const a=e[o];if(n.has(a))s=a.index,n.delete(a);else{i=a.index;break}}if(n.size!==0){const o=$d(s,i,n.size);t.push(...Array.from(n.values()).sort(nr).map((a,l)=>({...a,index:o[l]})))}}function jie(n,e,t){const r=e.length;if(n.size===r)return;let s,i;for(let o=r-1;o>-1;o--){const a=e[o];if(n.has(a))i=a.index,n.delete(a);else{s=a.index;break}}if(n.size!==0){const o=$d(s,i,n.size);t.push(...Array.from(n.values()).sort(nr).map((a,l)=>({...a,index:o[l]})))}}function n$(n,e){const t=Array.from(e).map(s=>{const i=n.getShapePageGeometry(s).vertices;return i?{shape:s,vertices:i}:null}).filter(Boolean);return s=>{const i=n.getShapePageGeometry(s).vertices;return i?t.some(o=>GE(o.vertices,i)):!1}}function Lie(n,e,t,r,s){var l;const i=n$(n,e),o=t.length;if(e.size===o)return;let a={name:"skipping"};for(let c=0;c<o;c++){const u=e.has(t[c]);switch(a.name){case"skipping":{if(!u)continue;a={name:"selecting",selectIndex:c};break}case"selecting":{if(u||!(s!=null&&s.considerAllShapes)&&!i(t[c]))continue;const{selectIndex:h}=a;$d(t[c].index,(l=t[c+1])==null?void 0:l.index,c-h).forEach((p,m)=>{const S=t[h+m];e.has(S)&&r.push({...S,index:p})}),a={name:"skipping"};break}}}}function Nie(n,e,t,r,s){var l;const i=n$(n,e),o=t.length;if(e.size===o)return;let a={name:"skipping"};for(let c=o-1;c>-1;c--){const u=e.has(t[c]);switch(a.name){case"skipping":{if(!u)continue;a={name:"selecting",selectIndex:c};break}case"selecting":{if(u||!(s!=null&&s.considerAllShapes)&&!i(t[c]))continue;$d((l=t[c-1])==null?void 0:l.index,t[c].index,a.selectIndex-c).forEach((h,p)=>{const m=t[c+p+1];e.has(m)&&r.push({...m,index:h})}),a={name:"skipping"};break}}}}function r$({editor:n,ids:e}){const t=rt(e.map(o=>n.getShape(o))),r=n.getShapesSharedRotation(e),s=n.getShapesRotatedPageBounds(e);if(!s)return null;const i=s.center.clone().rotWith(s.point,r);return{pageCenter:i,initialCursorAngle:i.angle(n.inputs.originPagePoint),initialShapesRotation:r,shapeSnapshots:t.map(o=>({shape:o,initialPagePoint:n.getShapePageTransform(o.id).point()}))}}function Sy({delta:n,editor:e,snapshot:t,stage:r,centerOverride:s}){const{pageCenter:i,shapeSnapshots:o}=t;e.updateShapes(o.map(({shape:l,initialPagePoint:c})=>{const u=ws(l.parentId)?e.getShapePageTransform(l.parentId):he.Identity(),h=k.RotWith(c,s??i,n),p=he.applyToPoint(he.Inverse(u),h),m=Hc(l.rotation+n);return{id:l.id,type:l.type,x:p.x,y:p.y,rotation:m}}));const a=[];o.forEach(({shape:l})=>{var p,m,S;const c=e.getShape(l.id);if(!c)return;const u=e.getShapeUtil(l);if(r==="start"||r==="one-off"){const x=(p=u.onRotateStart)==null?void 0:p.call(u,l);x&&a.push(x)}const h=(m=u.onRotate)==null?void 0:m.call(u,l,c);if(h&&a.push(h),r==="end"||r==="one-off"){const x=(S=u.onRotateEnd)==null?void 0:S.call(u,l,c);x&&a.push(x)}}),a.length>0&&e.updateShapes(a)}const Fie=n=>{const{store:e}=n,t=e.query.filterHistory("binding"),r=e.query.records("binding");function s(){const i=r.get(),o=new Map;for(const a of i){const{fromId:l,toId:c}=a,u=o.get(l);u?u.push(a):o.set(l,[a]);const h=o.get(c);h?h.push(a):o.set(c,[a])}return o}return ce("arrowBindingsIndex",(i,o)=>{if(Uc(i))return s();const a=i,l=t.getDiffSince(o);if(l===Ws)return s();let c;function u(m){c??(c=new Map(a));const S=c.get(m.fromId),x=S==null?void 0:S.filter(C=>C.id!==m.id);x!=null&&x.length?c.set(m.fromId,x):c.delete(m.fromId);const v=c.get(m.toId),w=v==null?void 0:v.filter(C=>C.id!==m.id);w!=null&&w.length?c.set(m.toId,w):c.delete(m.toId)}function h(m){c??(c=new Map(a));let S=c.get(m);return S?S===a.get(m)&&(S=S.slice(0),c.set(m,S)):(S=[],c.set(m,S)),S}function p(m){h(m.fromId).push(m),h(m.toId).push(m)}for(const m of l){for(const S of gn(m.added))p(S);for(const[S,x]of gn(m.updated))u(S),p(x);for(const S of gn(m.removed))u(S)}return c??a})};function zie(n,e,t){const r=n.getShapeMaskedPageBounds(e);return r===void 0?!0:!t.includes(r)}const $ie=n=>{function e(t){const r=t.getCurrentPageShapeIds(),s=t.getViewportPageBounds(),i=new Set;return r.forEach(o=>{zie(t,o,s)&&i.add(o)}),i}return ce("notVisibleShapes",t=>{if(Uc(t))return e(n);const r=e(n);if(t.size!==r.size)return r;for(const s of t)if(!r.has(s))return r;return t})},Bie=n=>{const e=n.query.ids("shape"),t=n.query.filterHistory("shape");function r(){const s={},i=e.get(),o=Array(i.size);return i.forEach(a=>o.push(n.get(a))),o.sort(nr),o.forEach(a=>{s[a.parentId]||(s[a.parentId]=[]),s[a.parentId].push(a.id)}),s}return ce("parentsToChildrenWithIndexes",(s,i)=>{if(Uc(s))return r();const o=t.getDiffSince(i);if(o===Ws)return r();if(o.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,p=o.length;h<p;h++){u=o[h];for(const m of Object.values(u.added))kd(m)&&(l(m.parentId),a[m.parentId].push(m.id),c.add(a[m.parentId]));for(const[m,S]of Object.values(u.updated))if(kd(S)&&kd(m)){if(m.parentId!==S.parentId)l(m.parentId),l(S.parentId),a[m.parentId].splice(a[m.parentId].indexOf(S.id),1),a[S.parentId].push(S.id),c.add(a[S.parentId]);else if(m.index!==S.index){l(S.parentId);const x=a[S.parentId].indexOf(S.id);a[S.parentId][x]=S.id,c.add(a[S.parentId])}}for(const m of Object.values(u.removed))kd(m)&&(l(m.parentId),a[m.parentId].splice(a[m.parentId].indexOf(m.id),1))}for(const h of c){const p=rt(h.map(m=>n.get(m)));p.sort(nr),h.splice(0,h.length,...p.map(m=>m.id))}return a??s})},CC=(n,e,t)=>{for(;!Ss(t.parentId);){const r=n.get(t.parentId);if(!r)return!1;t=r}return t.parentId===e},Uie=(n,e)=>{const t=n.query.ids("shape");let r=null;function s(){const i=e();return r=i,new Set([...t.get()].filter(o=>CC(n,i,n.get(o))))}return ce("_shapeIdsInCurrentPage",(i,o)=>{if(Uc(i))return s();const a=e();if(a!==r)return s();const l=n.history.getDiffSince(o);if(l===Ws)return s();const c=new fy(i);for(const h of l){for(const p of Object.values(h.added))kd(p)&&CC(n,a,p)&&c.add(p.id);for(const[p,m]of Object.values(h.updated))kd(m)&&(CC(n,a,m)?c.add(m.id):c.remove(m.id));for(const p of Object.keys(h.removed))ws(p)&&c.remove(p)}const u=c.get();return u?xf(u.value,u.diff):i})};var Hie=Object.create,s$=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,Wie=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),i$=n=>{throw TypeError(n)},o$=(n,e,t)=>e in n?s$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Vie=n=>[,,,Hie(null)],a$=["class","method","getter","setter","accessor","field","value","get","set"],l$=n=>n!==void 0&&typeof n!="function"?i$("Function expected"):n,qie=(n,e,t,r,s)=>({kind:a$[n],name:e,metadata:r,addInitializer:i=>t._?i$("Already initialized"):s.push(l$(i||null))}),Gie=(n,e)=>o$(e,Wie("metadata"),n[3]),Yie=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},c$=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=a$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,Kie(s,t)),w=r.length-1;w>=0;w--)l=qie(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,l$(o)&&(v[S]=o);return v&&s$(s,t,v),s},dd=(n,e,t)=>o$(n,typeof e!="symbol"?e+"":e,t),u$,d$,Zp;const Xie=40;d$=[ks],u$=[ks];class iv{constructor(e){this.editor=e,Yie(Zp,5,this),dd(this,"_clickId",""),dd(this,"_clickTimeout"),dd(this,"_clickScreenPoint"),dd(this,"_previousScreenPoint"),dd(this,"_clickState","idle"),dd(this,"lastPointerInfo",{})}_getClickTimeout(e,t=_t()){this._clickId=t,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.setTimeout(()=>{if(this._clickState===e&&this._clickId===t){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=k.From(e.point),this._previousScreenPoint&&k.Dist2(this._previousScreenPoint,this._clickScreenPoint)>Xie**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=k.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&&k.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"}}Zp=Vie();c$(Zp,1,"_getClickTimeout",d$,iv);c$(Zp,1,"cancelDoubleClickTimeout",u$,iv);Gie(Zp,iv);class Zie{constructor(e){R(this,"_isEdgeScrolling",!1);R(this,"_edgeScrollDuration",-1);this.editor=e}updateEdgeScrolling(e){const{editor:t}=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>t.options.edgeScrollDelay){const s=t.options.edgeScrollEaseDuration>0?Hn.easeInCubic(Math.min(1,this._edgeScrollDuration/(t.options.edgeScrollDelay+t.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:r.x*s,y:r.y*s})}}getEdgeProximityFactors(e,t,r,s,i){const{editor:o}=this,a=o.options.edgeScrollDistance,l=r?o.options.coarsePointerWidth:0,c=e-l,u=e+l,h=s?0:a,p=i?t:t-a;return c<h?Math.min(1,(h-c)/a):u>p?-Math.min(1,(u-p)/a):0}getEdgeScroll(){const{editor:e}=this,{inputs:{currentScreenPoint:{x:t,y:r}}}=e,s=e.getViewportScreenBounds(),{isCoarsePointer:i,insets:[o,a,l,c]}=e.getInstanceState(),u=this.getEdgeProximityFactors(t,s.w,i,c,a),h=this.getEdgeProximityFactors(r,s.h,i,o,l);return{x:u,y:h}}moveCameraWhenCloseToEdge(e){const{editor:t}=this;if(!t.inputs.isDragging||t.inputs.isPanning||t.getCameraOptions().isLocked||e.x===0&&e.y===0)return;const r=t.getViewportScreenBounds(),s=r.w<1e3?.612:1,i=r.h<1e3?.612:1,o=t.getZoomLevel(),a=t.user.getEdgeScrollSpeed()*t.options.edgeScrollSpeed,l=a*e.x*s/o,c=a*e.y*i/o,{x:u,y:h,z:p}=t.getCamera();t.setCamera(new k(u+l,h+c,p))}}class Jie{constructor(e,t){R(this,"disposeSideEffectListener");this.editor=e,this.disposeSideEffectListener=e.sideEffects.registerAfterChangeHandler("instance",(s,i)=>{s.isFocused!==i.isFocused&&this.updateContainerClass()});const r=e.getInstanceState().isFocused;t!==r&&e.updateInstanceState({isFocused:!!t}),this.updateContainerClass(),document.body.addEventListener("keydown",this.handleKeyDown.bind(this)),document.body.addEventListener("mousedown",this.handleMouseDown.bind(this))}updateContainerClass(){const e=this.editor.getContainer();this.editor.getInstanceState().isFocused?e.classList.add("tl-container__focused"):e.classList.remove("tl-container__focused"),e.classList.add("tl-container__no-focus-ring")}handleKeyDown(e){const t=this.editor.getContainer();["Tab","ArrowUp","ArrowDown"].includes(e.key)&&t.classList.remove("tl-container__no-focus-ring")}handleMouseDown(){this.editor.getContainer().classList.add("tl-container__no-focus-ring")}focus(){this.editor.getContainer().focus()}blur(){this.editor.complete(),this.editor.getContainer().blur()}dispose(){var e;document.body.removeEventListener("keydown",this.handleKeyDown.bind(this)),document.body.removeEventListener("mousedown",this.handleMouseDown.bind(this)),(e=this.disposeSideEffectListener)==null||e.call(this)}}class Qie{constructor(e,t){R(this,"shapeFontFacesCache");R(this,"shapeFontLoadStateCache");R(this,"fontStates",new lk("font states"));R(this,"fontsToLoad",new Set);this.editor=e,this.assetUrls=t,this.shapeFontFacesCache=e.store.createComputedCache("shape font faces",r=>this.editor.getShapeUtil(r).getFontFaces(r),{areResultsEqual:Wy,areRecordsEqual:(r,s)=>r.props===s.props}),this.shapeFontLoadStateCache=e.store.createCache(r=>{const s=ce("font faces",()=>this.getShapeFontFaces(r));return ce("font load state",()=>s.get().map(o=>this.getFontState(o)),{isEqual:Wy})})}getShapeFontFaces(e){const t=typeof e=="string"?e:e.id;return this.shapeFontFacesCache.get(t)??kr}trackFontsForShape(e){const t=typeof e=="string"?e:e.id;this.shapeFontLoadStateCache.get(t)}async loadRequiredFontsForCurrentPage(e=1/0){const t=new Set;for(const s of this.editor.getCurrentPageShapeIds())for(const i of this.getShapeFontFaces(this.editor.getShape(s)))t.add(i);if(t.size>e)return;const r=Array.from(t,s=>this.ensureFontIsLoaded(s));await Promise.all(r)}getFontState(e){return this.fontStates.get(e)??null}ensureFontIsLoaded(e){const t=this.getFontState(e);if(t)return t.loadingPromise;const r=this.findOrCreateFontFace(e),s={state:"loading",instance:r,loadingPromise:r.load().then(()=>{document.fonts.add(r),this.fontStates.update(e,i=>({...i,state:"ready"}))}).catch(i=>{console.error(i),this.fontStates.update(e,o=>({...o,state:"error"}))})};return this.fontStates.set(e,s),s.loadingPromise}requestFonts(e){this.fontsToLoad.size||queueMicrotask(()=>{if(this.editor.isDisposed)return;const t=this.fontsToLoad;this.fontsToLoad=new Set,Vs(()=>{for(const r of t)this.ensureFontIsLoaded(r)})});for(const t of e)this.fontsToLoad.add(t)}findOrCreateFontFace(e){var s;for(const i of document.fonts)if(i.family===e.family&&Is(Xj).every(([o,a])=>i[o]===(e[o]??a)))return i;const t=((s=this.assetUrls)==null?void 0:s[e.src.url])??e.src.url,r=new FontFace(e.family,`url(${JSON.stringify(t)})`,{...rh(Xj,i=>e[i]),display:"swap"});return document.fonts.add(r),r}async toEmbeddedCssDeclaration(e){var i;const t=((i=this.assetUrls)==null?void 0:i[e.src.url])??e.src.url,r=await Kr.urlToDataUrl(t),s=rt([`url("${r}")`,e.src.format?`format(${e.src.format})`:null,e.src.tech?`tech(${e.src.tech})`:null]).join(" ");return rt(["@font-face {",` font-family: "${e.family}";`,e.ascentOverride?` ascent-override: ${e.ascentOverride};`:null,e.descentOverride?` descent-override: ${e.descentOverride};`:null,e.stretch?` font-stretch: ${e.stretch};`:null,e.style?` font-style: ${e.style};`:null,e.weight?` font-weight: ${e.weight};`:null,e.featureSettings?` font-feature-settings: ${e.featureSettings};`:null,e.lineGapOverride?` line-gap-override: ${e.lineGapOverride};`:null,e.unicodeRange?` unicode-range: ${e.unicodeRange};`:null,` src: ${s};`,"}"]).join(`
|
|
205
|
-
`)}}const Xj={style:"normal",weight:"normal",stretch:"normal",unicodeRange:"U+0-10FFFF",featureSettings:"normal",ascentOverride:"normal",descentOverride:"normal",lineGapOverride:"normal"};function df(n){return toe}class eoe{constructor(){R(this,"length",0);R(this,"head",null);R(this,"tail",this)}push(e){return new s_(e,this)}toArray(){return kr}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const toe=new eoe;class s_{constructor(e,t){R(this,"length");this.head=e,this.tail=t,this.length=t.length+1}push(e){return new s_(e,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let e=this;return{next(){if(e.length){const t=e.head;return e=e.tail,{value:t,done:!1}}else return{value:void 0,done:!0}}}}}class noe{constructor(e){R(this,"store");R(this,"dispose");R(this,"state","recording");R(this,"pendingDiff",new soe);R(this,"stacks",Sn("HistoryManager.stacks",{undos:df(),redos:df()},{isEqual:(e,t)=>e.undos===t.undos&&e.redos===t.redos}));R(this,"annotateError");R(this,"_isInBatch",!1);this.store=e.store,this.annotateError=e.annotateError??np,this.dispose=this.store.addHistoryInterceptor((t,r)=>{if(r==="user")switch(this.state){case"recording":this.pendingDiff.apply(t.changes),this.stacks.update(({undos:s})=>({undos:s,redos:df()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(t.changes);break;case"paused":break;default:An(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const e=this.pendingDiff.clear();this.stacks.update(({undos:t,redos:r})=>({undos:t.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,t){const r=this.state;r!=="paused"&&(t!=null&&t.history)&&(this.state=roe[t.history]);try{if(this._isInBatch)return Vs(e),this;this._isInBatch=!0;try{Vs(e)}catch(s){throw this.annotateError(s),s}finally{this._isInBatch=!1}return this}finally{this.state=r}}_undo({pushToRedoStack:e,toMark:t=void 0}){var s;const r=this.state;this.state="paused";try{let{undos:i,redos:o}=this.stacks.get();const a=this.pendingDiff.clear(),l=r4(a),c=ck(a);e&&!l&&(o=o.push({type:"diff",diff:a}));let u=!1;if(l)for(;((s=i.head)==null?void 0:s.type)==="stop";){const h=i.head;if(i=i.tail,e&&(o=o.push(h)),h.id===t){u=!0;break}}if(!u)e:for(;i.head;){const h=i.head;switch(i=i.tail,e&&(o=o.push(h)),h.type){case"diff":Bf(c,[ck(h.diff)]);break;case"stop":if(!t)break e;if(h.id===t){u=!0;break e}break;default:An(h)}}if(!u&&t)return this;this.store.applyDiff(c,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:i,redos:o})}finally{this.state=r}return this}undo(){return this._undo({pushToRedoStack:!0}),this}redo(){var t;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(;((t=s.head)==null?void 0:t.type)==="stop";)r=r.push(s.head),s=s.tail;const i=hS();for(;s.head;){const o=s.head;if(r=r.push(o),s=s.tail,o.type==="diff")Bf(i,[o.diff]);else break}this.store.applyDiff(i,{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 i;let t=this.stacks.get().undos;const r=[];for(;t.head&&!(t.head.type==="stop"&&t.head.id===e);)t.head.type==="diff"&&r.push(t.head.diff),t=t.tail;if(!t.head||((i=t.head)==null?void 0:i.id)!==e)return console.error("Could not find mark to squash to: ",e),this;if(r.length===0)return this;const s=hS();return Bf(s,r.reverse()),this.stacks.update(({redos:o})=>({undos:t.push({type:"diff",diff:s}),redos:o})),this}_mark(e){Vs(()=>{this.flushPendingDiff(),this.stacks.update(({undos:t,redos:r})=>({undos:t.push({type:"stop",id:e}),redos:r}))})}clear(){this.stacks.set({undos:df(),redos:df()}),this.pendingDiff.clear()}getMarkIdMatching(e){let t=this.stacks.get().undos;for(;t.head;){if(t.head.type==="stop"&&t.head.id.includes(e))return t.head.id;t=t.tail}return null}debug(){const{undos:e,redos:t}=this.stacks.get();return{undos:e.toArray(),redos:t.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const roe={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class soe{constructor(){R(this,"diff",hS());R(this,"isEmptyAtom",Sn("PendingDiff.isEmpty",!0))}clear(){const e=this.diff;return this.diff=hS(),this.isEmptyAtom.set(!0),e}isEmpty(){return this.isEmptyAtom.get()}apply(e){Bf(this.diff,[e]),this.isEmptyAtom.set(r4(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class ioe{constructor(e){R(this,"scribbleItems",new Map);R(this,"state","paused");this.editor=e}addScribble(e,t=_t()){const r={id:t,scribble:{id:t,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(t,r),r}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}stop(e){const t=this.scribbleItems.get(e);if(!t)throw Error(`Scribble with id ${e} not found`);return t.delayRemaining=Math.min(t.delayRemaining,200),t.scribble.state="stopping",t}addPoint(e,t,r,s=.5){const i=this.scribbleItems.get(e);if(!i)throw Error(`Scribble with id ${e} not found`);const{prev:o}=i,a={x:t,y:r,z:s};return(!o||k.Dist(o,a)>=1)&&(i.next=a),i}tick(e){this.scribbleItems.size!==0&&this.editor.run(()=>{this.scribbleItems.forEach(t=>{if(t.scribble.state==="starting"){const{next:l,prev:c}=t;l&&l!==c&&(t.prev=l,t.scribble.points.push(l)),t.scribble.points.length>8&&(t.scribble.state="active");return}t.delayRemaining>0&&(t.delayRemaining=Math.max(0,t.delayRemaining-e)),t.timeoutMs+=e,t.timeoutMs>=16&&(t.timeoutMs=0);const{delayRemaining:r,timeoutMs:s,prev:i,next:o,scribble:a}=t;switch(a.state){case"active":{o&&o!==i?(t.prev=o,a.points.push(o),r===0&&a.points.length>8&&a.points.shift()):s===0&&(a.points.length>1?a.points.shift():t.delayRemaining=a.delay);break}case"stopping":{if(t.delayRemaining===0&&s===0){if(a.points.length===1){this.scribbleItems.delete(t.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:t})=>({...t,points:[...t.points]})).slice(-5)})})}}var ooe=Object.create,h$=Object.defineProperty,aoe=Object.getOwnPropertyDescriptor,loe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),f$=n=>{throw TypeError(n)},p$=(n,e,t)=>e in n?h$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,coe=n=>[,,,ooe(null)],g$=["class","method","getter","setter","accessor","field","value","get","set"],m$=n=>n!==void 0&&typeof n!="function"?f$("Function expected"):n,uoe=(n,e,t,r,s)=>({kind:g$[n],name:e,metadata:r,addInitializer:i=>t._?f$("Already initialized"):s.push(m$(i||null))}),doe=(n,e)=>p$(e,loe("metadata"),n[3]),hoe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},ov=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=g$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,aoe(s,t)),w=r.length-1;w>=0;w--)l=uoe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,m$(o)&&(v[S]=o);return v&&h$(s,t,v),s},foe=(n,e,t)=>p$(n,e+"",t),y$,S$,v$,x$,xu;const Ge=n=>Math.round(n*10**8)/10**8;function Sa(n,e,t,r,s){const i=n.filter(a=>(r==="forward"?a.startNode.id===e:a.endNode.id===e)&&Ge(a.length)===Ge(t)&&Ki(a.breadthIntersection[0],a.breadthIntersection[1],s[0],s[1]));if(i.length===0)return[];const o=new Set;return i.forEach(a=>{const l=r==="forward"?a.endNode.id:a.startNode.id;if(!o.has(l)){o.add(l);const c=Sa(n,l,t,r,Ki(a.breadthIntersection[0],a.breadthIntersection[1],s[0],s[1]));i.push(...c)}}),i}function poe(n){n.sort((e,t)=>t.gaps.length-e.gaps.length);for(let e=n.length-1;e>0;e--){const t=n[e];for(let r=e-1;r>=0;r--){const s=n[r];if(s.direction===t.direction&&t.gaps.every(i=>s.gaps.some(o=>Ge(i.startEdge[0].x)===Ge(o.startEdge[0].x)&&Ge(i.startEdge[0].y)===Ge(o.startEdge[0].y)&&Ge(i.startEdge[1].x)===Ge(o.startEdge[1].x)&&Ge(i.startEdge[1].y)===Ge(o.startEdge[1].y))&&s.gaps.some(o=>Ge(i.endEdge[0].x)===Ge(o.endEdge[0].x)&&Ge(i.endEdge[0].y)===Ge(o.endEdge[0].y)&&Ge(i.endEdge[1].x)===Ge(o.endEdge[1].x)&&Ge(i.endEdge[1].y)===Ge(o.endEdge[1].y)))){n.splice(e,1);break}}}}x$=[ce],v$=[ce],S$=[ce],y$=[ce];class fh{constructor(e){this.manager=e,hoe(xu,5,this),foe(this,"editor"),this.editor=e.editor}getSnapPointsCache(){const{editor:e}=this;return e.store.createComputedCache("snapPoints",t=>{const r=e.getShapePageTransform(t.id);if(!r)return;const i=e.getShapeUtil(t).getBoundsSnapGeometry(t).points??e.getShapeGeometry(t).bounds.cornersAndCenter;if(!(!r||!i))return i.map((o,a)=>{const{x:l,y:c}=he.applyToPoint(r,o);return{x:l,y:c,id:`${t.id}:${a}`}})})}getSnapPoints(e){return this.getSnapPointsCache().get(e)??[]}getSnappablePoints(){const e=this.getSnapPointsCache(),t=this.manager.getSnappableShapes(),r=[];for(const s of t){const i=e.get(s);i&&r.push(...i)}return r}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),e=>({id:e,pageBounds:zr(this.editor.getShapePageBounds(e))}))}getVisibleGaps(){const e=[],t=[];let r,s;const i=this.getSnappableGapNodes().sort((a,l)=>a.pageBounds.minX-l.pageBounds.minX);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.maxX<s.pageBounds.minX&&nf(r.pageBounds.minY,r.pageBounds.maxY,s.pageBounds.minY,s.pageBounds.maxY)&&e.push({startNode:r,endNode:s,startEdge:[new k(r.pageBounds.maxX,r.pageBounds.minY),new k(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new k(s.pageBounds.minX,s.pageBounds.minY),new k(s.pageBounds.minX,s.pageBounds.maxY)],length:s.pageBounds.minX-r.pageBounds.maxX,breadthIntersection:Ki(r.pageBounds.minY,r.pageBounds.maxY,s.pageBounds.minY,s.pageBounds.maxY)})}const o=i.sort((a,l)=>a.pageBounds.minY-l.pageBounds.minY);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.maxY<s.pageBounds.minY&&nf(r.pageBounds.minX,r.pageBounds.maxX,s.pageBounds.minX,s.pageBounds.maxX)&&t.push({startNode:r,endNode:s,startEdge:[new k(r.pageBounds.minX,r.pageBounds.maxY),new k(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new k(s.pageBounds.minX,s.pageBounds.minY),new k(s.pageBounds.maxX,s.pageBounds.minY)],length:s.pageBounds.minY-r.pageBounds.maxY,breadthIntersection:Ki(r.pageBounds.minX,r.pageBounds.maxX,s.pageBounds.minX,s.pageBounds.maxX)})}return{horizontal:e,vertical:t}}snapTranslateShapes({lockedAxis:e,initialSelectionPageBounds:t,initialSelectionSnapPoints:r,dragDelta:s}){var v,w;const i=this.manager.getSnapThreshold(),o=this.getSnappablePoints(),a=t.clone().translate(s),l=r.map(({x:C,y:_},E)=>({id:"selection:"+E,x:C+s.x,y:_+s.y})),c=o,u=[],h=[],p=new k(i,i);this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:p});const m=new k(e==="x"?0:((v=u[0])==null?void 0:v.nudge)??0,e==="y"?0:((w=h[0])==null?void 0:w.nudge)??0);p.x=0,p.y=0,u.length=0,h.length=0,l.forEach(C=>{C.x+=m.x,C.y+=m.y}),a.translate(m),this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:p});const S=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:h}),x=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h});return this.manager.setIndicators([...x,...S]),{nudge:m}}snapResizeShapes({initialSelectionPageBounds:e,dragDelta:t,handle:r,isAspectRatioLocked:s,isResizingFromCenter:i}){var O,D;const o=this.manager.getSnapThreshold(),{box:a,scaleX:l,scaleY:c}=Se.Resize(e,r,i?t.x*2:t.x,i?t.y*2:t.y,s);let u=r;l<0&&(u=gre(u)),c<0&&(u=pre(u)),i&&(a.center=e.center);const h=u==="top"||u==="bottom",p=u==="left"||u==="right",m=Zj(u,a),S=this.getSnappablePoints(),x=[],v=[],w=new k(o,o);this.collectPointSnaps({minOffset:w,nearestSnapsX:x,nearestSnapsY:v,otherNodeSnapPoints:S,selectionSnapPoints:m});const C=new k(h?0:((O=x[0])==null?void 0:O.nudge)??0,p?0:((D=v[0])==null?void 0:D.nudge)??0);if(s&&mre(u)&&C.len()!==0){const $=x.length&&v.length?Math.abs(C.x)<Math.abs(C.y)?"x":"y":x.length?"x":"y",H=e.aspectRatio;$==="x"?(v.length=0,C.y=C.x/H,(u==="bottom_left"||u==="top_right")&&(C.y=-C.y)):(x.length=0,C.x=C.y*H,(u==="bottom_left"||u==="top_right")&&(C.x=-C.x))}const _=k.Add(t,C),{box:E}=Se.Resize(e,r,i?_.x*2:_.x,i?_.y*2:_.y,s);i&&(E.center=e.center);const T=Zj("any",E);x.length=0,v.length=0,w.x=0,w.y=0,this.collectPointSnaps({minOffset:w,nearestSnapsX:x,nearestSnapsY:v,otherNodeSnapPoints:S,selectionSnapPoints:T});const A=this.getPointSnapLines({nearestSnapsX:x,nearestSnapsY:v});return this.manager.setIndicators([...A]),{nudge:C}}collectPointSnaps({selectionSnapPoints:e,otherNodeSnapPoints:t,minOffset:r,nearestSnapsX:s,nearestSnapsY:i}){for(const o of e)for(const a of t){const l=k.Sub(o,a),c=Math.abs(l.x),u=Math.abs(l.y);Ge(c)<=Ge(r.x)&&(Ge(c)<Ge(r.x)&&(s.length=0),s.push({type:"points",points:{thisPoint:o,otherPoint:a},nudge:a.x-o.x}),r.x=c),Ge(u)<=Ge(r.y)&&(Ge(u)<Ge(r.y)&&(i.length=0),i.push({type:"points",points:{thisPoint:o,otherPoint:a},nudge:a.y-o.y}),r.y=u)}}collectGapSnaps({selectionPageBounds:e,minOffset:t,nearestSnapsX:r,nearestSnapsY:s}){const{horizontal:i,vertical:o}=this.getVisibleGaps();for(const a of i){if(!nf(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&&Ge(Math.abs(c))<=Ge(t.x)){Ge(Math.abs(c))<Ge(t.x)&&(r.length=0),t.x=Math.abs(c);const w={type:"gap_center",gap:a,nudge:c},C=r.find(({type:E})=>E==="gap_center"),_=C&&Ki(a.breadthIntersection[0],a.breadthIntersection[1],C.gap.breadthIntersection[0],C.gap.breadthIntersection[1]);C&&C.gap.length>a.length&&_?r[r.indexOf(C)]=w:(!C||!_)&&r.push(w)}const h=a.startNode.pageBounds.minX-a.length,p=e.maxX,m=h-p;Ge(Math.abs(m))<=Ge(t.x)&&(Ge(Math.abs(m))<Ge(t.x)&&(r.length=0),t.x=Math.abs(m),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:m}));const S=a.endNode.pageBounds.maxX+a.length,x=e.minX,v=S-x;Ge(Math.abs(v))<=Ge(t.x)&&(Ge(Math.abs(v))<Ge(t.x)&&(r.length=0),t.x=Math.abs(v),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:v}))}for(const a of o){if(!nf(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&&Ge(Math.abs(c))<=Ge(t.y)){Ge(Math.abs(c))<Ge(t.y)&&(s.length=0),t.y=Math.abs(c);const w={type:"gap_center",gap:a,nudge:c},C=s.find(({type:E})=>E==="gap_center"),_=C&&nf(C.gap.breadthIntersection[0],C.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);C&&C.gap.length>a.length&&_?s[s.indexOf(C)]=w:(!C||!_)&&s.push(w);continue}const h=a.startNode.pageBounds.minY-a.length,p=e.maxY,m=h-p;Ge(Math.abs(m))<=Ge(t.y)&&(Ge(Math.abs(m))<Ge(t.y)&&(s.length=0),t.y=Math.abs(m),s.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:m}));const S=a.endNode.pageBounds.maxY+a.length,x=e.minY,v=S-x;Ge(Math.abs(v))<=Ge(t.y)&&(Ge(Math.abs(v))<Ge(t.y)&&(s.length=0),t.y=Math.abs(v),s.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:v}))}}getPointSnapLines({nearestSnapsX:e,nearestSnapsY:t}){const r={},s={};if(e.length>0){for(const i of e)if(i.type==="points"){const o=Ge(i.points.otherPoint.x);r[o]||(r[o]=[]),r[o].push(i.points)}}if(t.length>0){for(const i of t)if(i.type==="points"){const o=Ge(i.points.otherPoint.y);s[o]||(s[o]=[]),s[o].push(i.points)}}return Object.values(r).concat(Object.values(s)).map(i=>({id:_t(),type:"points",points:wI(i.map(o=>k.From(o.otherPoint)).concat(i.map(o=>k.From(o.thisPoint))),(o,a)=>o.equals(a))}))}getGapSnapLines({selectionPageBounds:e,nearestSnapsX:t,nearestSnapsY:r}){const{vertical:s,horizontal:i}=this.getVisibleGaps(),o={top:e.sides[0],right:e.sides[1],bottom:[e.corners[3],e.corners[2]],left:[e.corners[0],e.corners[3]]},a=[];if(t.length>0)for(const l of t){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:h,endNode:p,length:m,endEdge:S}}=l;switch(l.type){case"gap_center":{const x=(m-e.width)/2,v=Ki(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:_t(),gaps:[...Sa(i,h.id,x,"backward",v),{startEdge:u,endEdge:o.left},{startEdge:o.right,endEdge:S},...Sa(i,p.id,x,"forward",v)]});break}case"gap_duplicate":{const x=Ki(c[0],c[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:_t(),gaps:l.protrusionDirection==="left"?[{startEdge:o.right,endEdge:u.map(v=>v.clone().addXY(-h.pageBounds.width,0))},{startEdge:u,endEdge:S},...Sa(i,p.id,m,"forward",x)]:[...Sa(i,h.id,m,"backward",x),{startEdge:u,endEdge:S},{startEdge:S.map(v=>v.clone().addXY(l.gap.endNode.pageBounds.width,0)),endEdge:o.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:p,length:m,endEdge:S}}=l;switch(l.type){case"gap_center":{const x=(m-e.height)/2,v=Ki(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:_t(),gaps:[...Sa(s,h.id,x,"backward",v),{startEdge:u,endEdge:o.top},{startEdge:o.bottom,endEdge:S},...Sa(s,l.gap.endNode.id,x,"forward",v)]});break}case"gap_duplicate":{const x=Ki(c[0],c[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:_t(),gaps:l.protrusionDirection==="top"?[{startEdge:o.bottom,endEdge:u.map(v=>v.clone().addXY(0,-h.pageBounds.height))},{startEdge:u,endEdge:S},...Sa(s,p.id,m,"forward",x)]:[...Sa(s,h.id,m,"backward",x),{startEdge:u,endEdge:S},{startEdge:S.map(v=>v.clone().addXY(0,p.pageBounds.height)),endEdge:o.top}]})}break}}return poe(a),a}}xu=coe();ov(xu,1,"getSnapPointsCache",x$,fh);ov(xu,1,"getSnappablePoints",v$,fh);ov(xu,1,"getSnappableGapNodes",S$,fh);ov(xu,1,"getVisibleGaps",y$,fh);doe(xu,fh);function Zj(n,e){const{minX:t,maxX:r,minY:s,maxY:i}=e,o=[];switch(n){case"top":case"left":case"top_left":case"any":o.push({id:"top_left",handle:"top_left",x:t,y:s})}switch(n){case"top":case"right":case"top_right":case"any":o.push({id:"top_right",handle:"top_right",x:r,y:s})}switch(n){case"bottom":case"right":case"bottom_right":case"any":o.push({id:"bottom_right",handle:"bottom_right",x:r,y:i})}switch(n){case"bottom":case"left":case"bottom_left":case"any":o.push({id:"bottom_left",handle:"bottom_left",x:t,y:i})}return o}var goe=Object.create,w$=Object.defineProperty,moe=Object.getOwnPropertyDescriptor,yoe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),b$=n=>{throw TypeError(n)},C$=(n,e,t)=>e in n?w$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Soe=n=>[,,,goe(null)],P$=["class","method","getter","setter","accessor","field","value","get","set"],k$=n=>n!==void 0&&typeof n!="function"?b$("Function expected"):n,voe=(n,e,t,r,s)=>({kind:P$[n],name:e,metadata:r,addInitializer:i=>t._?b$("Already initialized"):s.push(k$(i||null))}),xoe=(n,e)=>C$(e,yoe("metadata"),n[3]),woe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},boe=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=P$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,moe(s,t)),w=r.length-1;w>=0;w--)l=voe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,k$(o)&&(v[S]=o);return v&&w$(s,t,v),s},Coe=(n,e,t)=>C$(n,e+"",t),I$,av;const Poe=()=>null,koe=()=>[];I$=[ce];class i_{constructor(e){this.manager=e,woe(av,5,this),Coe(this,"editor"),this.editor=e.editor}getSnapGeometryCache(){const{editor:e}=this;return e.store.createComputedCache("handle snap geometry",t=>{const r=e.getShapeUtil(t).getHandleSnapGeometry(t),s=r.getSelfSnapOutline?r.getSelfSnapOutline.bind(r):Poe,i=r.getSelfSnapPoints?r.getSelfSnapPoints.bind(r):koe;return{outline:r.outline===void 0?e.getShapeGeometry(t):r.outline,points:r.points??[],getSelfSnapOutline:s,getSelfSnapPoints:i}})}*iterateSnapPointsInPageSpace(e,t){var s,i;const r=(s=this.getSnapGeometryCache().get(e))==null?void 0:s.getSelfSnapPoints(t);if(r&&r.length){const o=zr(this.editor.getShapePageTransform(e));for(const a of r)yield o.applyToPoint(a)}for(const o of this.manager.getSnappableShapes()){if(o===e)continue;const a=(i=this.getSnapGeometryCache().get(o))==null?void 0:i.points;if(!a||!a.length)continue;const l=zr(this.editor.getShapePageTransform(o));for(const c of a)yield l.applyToPoint(c)}}*iterateSnapOutlines(e,t){var s,i;const r=(s=this.getSnapGeometryCache().get(e))==null?void 0:s.getSelfSnapOutline(t);r&&(yield{shapeId:e,outline:r});for(const o of this.manager.getSnappableShapes()){if(o===e)continue;const a=(i=this.getSnapGeometryCache().get(o))==null?void 0:i.outline;a&&(yield{shapeId:o,outline:a})}}getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:r}){const s=this.manager.getSnapThreshold();let i=s,o=null;for(const c of this.iterateSnapPointsInPageSpace(e,t))k.DistMin(r,c,i)&&(i=k.Dist(r,c),o=c);if(o)return o;let a=s,l=null;for(const{shapeId:c,outline:u}of this.iterateSnapOutlines(e,t)){const h=zr(this.editor.getShapePageTransform(c)),p=this.editor.getPointInShapeSpace(c,r),m=u.nearestPoint(p),S=h.applyToPoint(m);k.DistMin(r,S,a)&&(a=k.Dist(r,S),l=S)}return l||null}snapHandle({currentShapeId:e,handle:t}){const s=zr(this.editor.getShapePageTransform(e)).applyToPoint(t),i=this.getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:s});return i?(this.manager.setIndicators([{id:_t(),type:"points",points:[i]}]),{nudge:k.Sub(i,s)}):null}}av=Soe();boe(av,1,"getSnapGeometryCache",I$,i_);xoe(av,i_);var Ioe=Object.create,E$=Object.defineProperty,Eoe=Object.getOwnPropertyDescriptor,_oe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),_$=n=>{throw TypeError(n)},T$=(n,e,t)=>e in n?E$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Toe=n=>[,,,Ioe(null)],M$=["class","method","getter","setter","accessor","field","value","get","set"],A$=n=>n!==void 0&&typeof n!="function"?_$("Function expected"):n,Moe=(n,e,t,r,s)=>({kind:M$[n],name:e,metadata:r,addInitializer:i=>t._?_$("Already initialized"):s.push(A$(i||null))}),Aoe=(n,e)=>T$(e,_oe("metadata"),n[3]),Ooe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},o_=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=M$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,Eoe(s,t)),w=r.length-1;w>=0;w--)l=Moe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,A$(o)&&(v[S]=o);return v&&E$(s,t,v),s},PC=(n,e,t)=>T$(n,typeof e!="symbol"?e+"":e,t),O$,R$,D$,ph;D$=[ce],R$=[ce],O$=[ce];class Jp{constructor(e){this.editor=e,Ooe(ph,5,this),PC(this,"shapeBounds"),PC(this,"handles"),PC(this,"_snapIndicators",Sn("snapLines",void 0)),this.shapeBounds=new fh(this),this.handles=new i_(this)}getIndicators(){return this._snapIndicators.get()??kr}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,t=e.getViewportPageBounds(),r=e.getSelectedShapeIds(),s=new Set,i=o=>{if(ws(o)){const l=e.getShape(o);l&&e.isShapeOfType(l,"frame")&&s.add(o)}const a=e.getSortedChildIdsForParent(o);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&&t.includes(h)){if(e.isShapeOfType(c,"group")){i(l);continue}s.add(l)}}};return i(this.getCurrentCommonAncestor()??e.getCurrentPageId()),s}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}ph=Toe();o_(ph,1,"getSnapThreshold",D$,Jp);o_(ph,1,"getSnappableShapes",R$,Jp);o_(ph,1,"getCurrentCommonAncestor",O$,Jp);Aoe(ph,Jp);const Roe=/\r?\n|\r/g;function Jj(n){return n.replace(Roe,`
|
|
206
|
-
`).split(`
|
|
207
|
-
`).map(e=>e||" ").join(`
|
|
208
|
-
`)}const Doe={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},joe=/\s/;class Loe{constructor(e){R(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,t){const r=document.createElement("div");return r.textContent=Jj(e),this.measureHtml(r.innerHTML,t)}measureHtml(e,t){const r=this.baseElem.cloneNode();this.editor.getContainer().appendChild(r),r.innerHTML=e,this.baseElem.insertAdjacentElement("afterend",r),r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("font-family",t.fontFamily),r.style.setProperty("font-style",t.fontStyle),r.style.setProperty("font-weight",t.fontWeight),r.style.setProperty("font-size",t.fontSize+"px"),r.style.setProperty("line-height",t.lineHeight*t.fontSize+"px"),r.style.setProperty("max-width",t.maxWidth===null?null:t.maxWidth+"px"),r.style.setProperty("min-width",t.minWidth===null?null:t.minWidth+"px"),r.style.setProperty("padding",t.padding),r.style.setProperty("overflow-wrap",t.disableOverflowWrapBreaking?"normal":"break-word");const s=r.scrollWidth,i=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:i.width,h:i.height,scrollWidth:s}}measureElementTextNodeSpans(e,{shouldTruncateToFirstLine:t=!1}={}){const r=[],s=e.getBoundingClientRect(),i=-s.left,o=-s.top,a=new Range,l=e.childNodes[0];let c=0,u=null,h=null,p=0,m=0,S=!1;for(const x of e.childNodes)if(x.nodeType===Node.TEXT_NODE)for(const v of x.textContent??""){a.setStart(l,c),a.setEnd(l,c+v.length);const w=a.getClientRects(),C=w[w.length-1],_=C.top+o,E=C.left+i,T=C.right+i,A=E<m,O=joe.test(v);if(O!==h||_!==p||!u){if(u){if(t&&_!==p){S=!0;break}r.push(u)}u={box:{x:E,y:_,w:C.width,h:C.height},text:v},m=E}else A&&(u.box.x=E),u.box.w=A?u.box.w+C.width:T-u.box.x,u.text+=v;v===`
|
|
209
|
-
`&&(m=0),h=O,p=_,c+=v.length}return u&&r.push(u),{spans:r,didTruncate:S}}measureTextSpans(e,t){if(e==="")return[];const r=this.baseElem.cloneNode();this.editor.getContainer().appendChild(r);const s=Math.ceil(t.width-t.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",`${t.fontSize}px`),r.style.setProperty("font-family",t.fontFamily),r.style.setProperty("font-weight",t.fontWeight),r.style.setProperty("line-height",`${t.lineHeight*t.fontSize}px`),r.style.setProperty("text-align",Doe[t.textAlign]),r.style.setProperty("font-style",t.fontStyle);const i=t.overflow==="truncate-ellipsis"||t.overflow==="truncate-clip";i&&(r.style.setProperty("overflow-wrap","anywhere"),r.style.setProperty("word-break","break-all"));const o=Jj(e);r.textContent=o;const{spans:a,didTruncate:l}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:i});if(t.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=o;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,t.width-t.padding-c),y:h.box.y,w:c,h:h.box.h}}),u}return r.remove(),a}}var Noe=Object.create,j$=Object.defineProperty,Foe=Object.getOwnPropertyDescriptor,zoe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),L$=n=>{throw TypeError(n)},N$=(n,e,t)=>e in n?j$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,$oe=n=>[,,,Noe(null)],F$=["class","method","getter","setter","accessor","field","value","get","set"],z$=n=>n!==void 0&&typeof n!="function"?L$("Function expected"):n,Boe=(n,e,t,r,s)=>({kind:F$[n],name:e,metadata:r,addInitializer:i=>t._?L$("Already initialized"):s.push(z$(i||null))}),Uoe=(n,e)=>N$(e,zoe("metadata"),n[3]),Hoe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},$$=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=F$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,Foe(s,t)),w=r.length-1;w>=0;w--)l=Boe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,z$(o)&&(v[S]=o);return v&&j$(s,t,v),s},jm=(n,e,t)=>N$(n,typeof e!="symbol"?e+"":e,t),B$,U$,Qp;const Qj=y3;U$=[ks],B$=[ks];class lv{constructor(e){this.editor=e,Hoe(Qp,5,this),jm(this,"cancelRaf"),jm(this,"isPaused",!0),jm(this,"now",0),jm(this,"prevPoint",new k),this.editor.disposables.add(this.dispose),this.start()}start(){var e;this.isPaused=!1,(e=this.cancelRaf)==null||e.call(this),this.cancelRaf=Qj(this.tick),this.now=Date.now()}tick(){if(this.isPaused)return;const e=Date.now(),t=e-this.now;this.now=e,this.updatePointerVelocity(t),this.editor.emit("frame",t),this.editor.emit("tick",t),this.cancelRaf=Qj(this.tick)}dispose(){var e;this.isPaused=!0,(e=this.cancelRaf)==null||e.call(this)}updatePointerVelocity(e){const{prevPoint:t,editor:{inputs:{currentScreenPoint:r,pointerVelocity:s}}}=this;if(e===0)return;const i=k.Sub(r,t);this.prevPoint=r.clone();const o=i.len(),a=o?i.div(o):new k(0,0),l=s.clone().lrp(a.mul(o/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)}}Qp=$oe();$$(Qp,1,"tick",U$,lv);$$(Qp,1,"dispose",B$,lv);Uoe(Qp,lv);var Koe=Object.create,H$=Object.defineProperty,Woe=Object.getOwnPropertyDescriptor,Voe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),K$=n=>{throw TypeError(n)},W$=(n,e,t)=>e in n?H$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qoe=n=>[,,,Koe(null)],V$=["class","method","getter","setter","accessor","field","value","get","set"],q$=n=>n!==void 0&&typeof n!="function"?K$("Function expected"):n,Goe=(n,e,t,r,s)=>({kind:V$[n],name:e,metadata:r,addInitializer:i=>t._?K$("Already initialized"):s.push(q$(i||null))}),Yoe=(n,e)=>W$(e,Voe("metadata"),n[3]),Xoe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},Ti=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=V$[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,Woe(s,t)),w=r.length-1;w>=0;w--)l=Goe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,q$(o)&&(v[S]=o);return v&&H$(s,t,v),s},eL=(n,e,t)=>W$(n,typeof e!="symbol"?e+"":e,t),G$,Y$,X$,Z$,J$,Q$,eB,tB,nB,rB,sB,iB,ts;iB=[ce],sB=[ce],rB=[ce],nB=[ce],tB=[ce],eB=[ce],Q$=[ce],J$=[ce],Z$=[ce],X$=[ce],Y$=[ce],G$=[ce];class Ms{constructor(e,t){if(this.user=e,this.inferDarkMode=t,Xoe(ts,5,this),eL(this,"systemColorScheme",Sn("systemColorScheme","light")),eL(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=i=>{i.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??Io.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??Io.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){var e;return((e=this.user.userPreferences.get().name)==null?void 0:e.trim())??Io.name}getLocale(){return this.user.userPreferences.get().locale??Io.locale}getColor(){return this.user.userPreferences.get().color??Io.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??Io.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??Io.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??Io.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??Io.isPasteAtCursorMode}}ts=qoe();Ti(ts,1,"getUserPreferences",iB,Ms);Ti(ts,1,"getIsDarkMode",sB,Ms);Ti(ts,1,"getEdgeScrollSpeed",rB,Ms);Ti(ts,1,"getAnimationSpeed",nB,Ms);Ti(ts,1,"getId",tB,Ms);Ti(ts,1,"getName",eB,Ms);Ti(ts,1,"getLocale",Q$,Ms);Ti(ts,1,"getColor",J$,Ms);Ti(ts,1,"getIsSnapMode",Z$,Ms);Ti(ts,1,"getIsWrapMode",X$,Ms);Ti(ts,1,"getIsDynamicResizeMode",Y$,Ms);Ti(ts,1,"getIsPasteAtCursorMode",G$,Ms);Yoe(ts,Ms);const Zoe={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"},Joe=["brushing","cropping","dragging","dragging_handle","drawing","erasing","lasering","resizing","rotating","scribble_brushing","translating"];class De{constructor(e,t){R(this,"performanceTracker");R(this,"id");R(this,"type");R(this,"shapeType");R(this,"initial");R(this,"children");R(this,"isLockable");R(this,"useCoalescedEvents");R(this,"parent");R(this,"_path");R(this,"_current");R(this,"_isActive");R(this,"_currentToolIdMask",Sn("curent tool id mask",void 0));this.editor=e;const{id:r,children:s,initial:i,isLockable:o,useCoalescedEvents:a}=this.constructor;this.id=r,this._isActive=Sn("toolIsActive"+this.id,!1),this._current=Sn("toolState"+this.id,void 0),this._path=ce("toolPath"+this.id,()=>{const l=this.getCurrent();return this.id+(l?`.${l.getPath()}`:"")}),this.parent=t??{},this.parent?s&&i?(this.type="branch",this.initial=i,this.children=Object.fromEntries(s().map(l=>[l.id,new l(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",s&&i&&(this.initial=i,this.children=Object.fromEntries(s().map(l=>[l.id,new l(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=o,this.useCoalescedEvents=a,this.performanceTracker=new GN}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}transition(e,t={}){var i;const r=e.split(".");let s=this;for(let o=0;o<r.length;o++){const a=r[o],l=s.getCurrent(),c=(i=s.children)==null?void 0:i[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(t,a),s._current.set(c),c.enter(t,(l==null?void 0:l.id)||"initial"),!c.getIsActive()))break;s=c}return this}handleEvent(e){var s;const t=Zoe[e.name],r=this._current.__unsafe__getWithoutCapture();(s=this[t])==null||s.call(this,e),this._isActive.__unsafe__getWithoutCapture()&&r&&r===this._current.__unsafe__getWithoutCapture()&&r.handleEvent(e)}enter(e,t){var r;if(ln.measurePerformance.get()&&Joe.includes(this.id)&&this.performanceTracker.start(this.id),this._isActive.set(!0),(r=this.onEnter)==null||r.call(this,e,t),this.children&&this.initial&&this.getIsActive()){const s=this.children[this.initial];this._current.set(s),s.enter(e,t)}}exit(e,t){var r,s;ln.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this._isActive.set(!1),(r=this.onExit)==null||r.call(this,e,t),this.getIsActive()||(s=this.getCurrent())==null||s.exit(e,t)}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(e){this._currentToolIdMask.set(e)}}R(De,"id"),R(De,"initial"),R(De,"children"),R(De,"isLockable",!0),R(De,"useCoalescedEvents",!1);class bk extends De{static children(){return[]}onKeyDown(e){var t;switch(e.code){case"KeyZ":{if(!(e.shiftKey||e.ctrlKey)){const r=this.getCurrent();r&&((t=r.getCurrent())==null?void 0:t.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...e,onInteractionEnd:r.id})}break}}}}R(bk,"id","root"),R(bk,"initial","");var Qoe=Object.create,oB=Object.defineProperty,eae=Object.getOwnPropertyDescriptor,aB=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),lB=n=>{throw TypeError(n)},cB=(n,e,t)=>e in n?oB(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,tae=n=>[,,,Qoe((n==null?void 0:n[aB("metadata")])??null)],uB=["class","method","getter","setter","accessor","field","value","get","set"],dB=n=>n!==void 0&&typeof n!="function"?lB("Function expected"):n,nae=(n,e,t,r,s)=>({kind:uB[n],name:e,metadata:r,addInitializer:i=>t._?lB("Already initialized"):s.push(dB(i||null))}),rae=(n,e)=>cB(e,aB("metadata"),n[3]),sae=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},_e=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=uB[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,eae(s,t)),w=r.length-1;w>=0;w--)l=nae(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,dB(o)&&(v[S]=o);return v&&oB(s,t,v),s},Ue=(n,e,t)=>cB(n,typeof e!="symbol"?e+"":e,t),hB,fB,pB,gB,mB,yB,SB,vB,xB,wB,bB,CB,PB,kB,IB,EB,_B,TB,MB,AB,OB,RB,DB,jB,LB,NB,FB,zB,$B,BB,UB,HB,KB,WB,VB,qB,GB,YB,XB,ZB,JB,QB,e6,t6,n6,r6,s6,i6,o6,a6,l6,c6,u6,d6,h6,f6,p6,g6,m6,y6,S6,v6,x6,w6,b6,C6,P6,k6,I6,E6,_6,T6,M6,Ck,Ie;class ke extends(Ck=Pse,M6=[ce],T6=[ce],_6=[ce],E6=[ce],I6=[ce],k6=[ce],P6=[ce],C6=[ce],b6=[ce],w6=[ce],x6=[ce],v6=[ce],S6=[ce],y6=[ce],m6=[ce],g6=[ce],p6=[ce],f6=[ce],h6=[ce],d6=[ce],u6=[ce],c6=[ce],l6=[ce],a6=[ce],o6=[ce],i6=[ce],s6=[ce],r6=[ce],n6=[ce],t6=[ce],e6=[ce],QB=[ce],JB=[ce],ZB=[ce],XB=[ce],YB=[ce],GB=[ce],qB=[ce],VB=[ce],WB=[ce],KB=[ce],HB=[ce],UB=[ce],BB=[ce],$B=[ce],zB=[ce],FB=[ce],NB=[ce],LB=[ce],jB=[ce],DB=[ce],RB=[ce],OB=[ce],AB=[ce],MB=[ce],TB=[ce],_B=[ce],EB=[ce],IB=[ce],kB=[ce],PB=[ce],CB=[ce],bB=[ce],wB=[ce],xB=[ce],vB=[ce({isEqual:(e,t)=>e.equals(t)})],SB=[ce],yB=[ce],mB=[ce],gB=[ks],pB=[ks],fB=[ks],hB=[ks],Ck){constructor({store:e,user:t,shapeUtils:r,bindingUtils:s,tools:i,getContainer:o,cameraOptions:a,textOptions:l,initialState:c,autoFocus:u,inferDarkMode:h,options:p,isShapeHidden:m,getShapeVisibility:S,fontAssetUrls:x}){var J;super(),sae(Ie,5,this),Ue(this,"id",_t()),Ue(this,"_getShapeVisibility"),Ue(this,"options"),Ue(this,"contextId",_t()),Ue(this,"store"),Ue(this,"root"),Ue(this,"disposables",new Set),Ue(this,"isDisposed",!1),Ue(this,"_tickManager"),Ue(this,"snaps"),Ue(this,"timers",ES.forContext(this.contextId)),Ue(this,"user"),Ue(this,"textMeasure"),Ue(this,"fonts"),Ue(this,"environment",It),Ue(this,"scribbles"),Ue(this,"sideEffects"),Ue(this,"edgeScrollManager"),Ue(this,"focusManager"),Ue(this,"getContainer"),Ue(this,"shapeUtils"),Ue(this,"styleProps"),Ue(this,"bindingUtils"),Ue(this,"history"),Ue(this,"_shouldIgnoreShapeLock",!1),Ue(this,"_crashingError",null),Ue(this,"_isChangingStyleTimeout",-1),Ue(this,"menus",Br.forContext(this.contextId)),Ue(this,"_currentRichTextEditor",Sn("rich text editor",null)),Ue(this,"_textOptions"),Ue(this,"_cameraOptions",Sn("camera options",yj)),Ue(this,"_viewportAnimation",null),Ue(this,"_willSetInitialBounds",!0),Ue(this,"_isLockedOnFollowingUser",Sn("isLockedOnFollowingUser",!1)),Ue(this,"_cameraState",Sn("camera state","idle")),Ue(this,"_cameraStateTimeoutRemaining",0),Ue(this,"_currentPageShapeIds"),Ue(this,"_shapeGeometryCaches",{}),Ue(this,"_shapePageGeometryCaches",{}),Ue(this,"_parentIdsToChildIds"),Ue(this,"animatingShapes",new Map),Ue(this,"externalAssetContentHandlers",{file:null,url:null}),Ue(this,"temporaryAssetPreview",new Map),Ue(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null,tldraw:null,excalidraw:null}),Ue(this,"inputs",{originPagePoint:new k,originScreenPoint:new k,previousPagePoint:new k,previousScreenPoint:new k,currentPagePoint:new k,currentScreenPoint:new k,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 k}),Ue(this,"_clickManager",new iv(this)),Ue(this,"_prevCursor","default"),Ue(this,"_shiftKeyTimeout",-1),Ue(this,"_altKeyTimeout",-1),Ue(this,"_ctrlKeyTimeout",-1),Ue(this,"_metaKeyTimeout",-1),Ue(this,"_restoreToolId","select"),Ue(this,"_pinchStart",1),Ue(this,"_didPinch",!1),Ue(this,"_selectedShapeIdsAtPointerDown",[]),Ue(this,"_longPressTimeout",-1),Ue(this,"capturedPointerId",null),Ue(this,"performanceTracker"),Ue(this,"performanceTrackerTimeout",-1),Ue(this,"_pendingEventsForNextTick",[]),Je(!(m&&S),"Cannot use both isShapeHidden and getShapeVisibility"),this._getShapeVisibility=m?(L,N)=>m(L,N)?"hidden":"inherit":S,this.options={...Eie,...p},this.store=e,this.disposables.add(this.store.dispose.bind(this.store)),this.history=new noe({store:e,annotateError:L=>{this.annotateError(L,{origin:"history.batch",willCrashApp:!0}),this.crash(L)}}),this.snaps=new Jp(this),this.disposables.add(this.timers.dispose),this._cameraOptions.set({...yj,...a}),this._textOptions=Sn("text options",l??null),this.user=new Ms(t??Ez(),h??!1),this.disposables.add(()=>this.user.dispose()),this.getContainer=o,this.textMeasure=new Loe(this),this.fonts=new Qie(this,x),this._tickManager=new lv(this);class v extends bk{}R(v,"initial",c??""),this.root=new v(this),this.root.children={};const w=Dz(r),C={},_={},E=new Map;for(const L of w){const N=new L(this);C[L.type]=N;const U=l4(L.props??{});_[L.type]=U;for(const Y of U.keys())if(!E.has(Y.id))E.set(Y.id,Y);else if(E.get(Y.id)!==Y)throw Error(`Multiple style props with id "${Y.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=C,this.styleProps=_;const T=Oz(s),A={};for(const L of T){const N=new L(this);A[L.type]=N}this.bindingUtils=A;for(const L of[...i]){if(Ci(this.root.children,L.id))throw Error(`Can't override tool with id "${L.id}"`);this.root.children[L.id]=new L(this,this.root)}this.scribbles=new ioe(this);const O=(L,N)=>{let U=null;const Y=L.selectedShapeIds.filter(V=>!N.has(V));Y.length!==L.selectedShapeIds.length&&(U||(U={...L}),U.selectedShapeIds=Y);const W=L.erasingShapeIds.filter(V=>!N.has(V));W.length!==L.erasingShapeIds.length&&(U||(U={...L}),U.erasingShapeIds=W),L.hoveredShapeId&&N.has(L.hoveredShapeId)&&(U||(U={...L}),U.hoveredShapeId=null),L.editingShapeId&&N.has(L.editingShapeId)&&(U||(U={...L}),U.editingShapeId=null);const z=L.hintingShapeIds.filter(V=>!N.has(V));return z.length!==L.hintingShapeIds.length&&(U||(U={...L}),U.hintingShapeIds=z),L.focusedGroupId&&N.has(L.focusedGroupId)&&(U||(U={...L}),U.focusedGroupId=null),U};this.sideEffects=this.store.sideEffects;let D=new Map;const $=new Set,H=new Set;let G=new Set;if(this.disposables.add(this.sideEffects.registerOperationCompleteHandler(()=>{var L,N,U,Y;$.clear();for(const W of H){H.delete(W);const z=this.getShape(W);if(!z)continue;const V=this.getShapeUtil(z),ee=(L=V.onChildrenChange)==null?void 0:L.call(V,z);ee!=null&&ee.length&&this.updateShapes(ee)}if(G.size){const W=G;G=new Set;for(const z of W){const V=this.getBindingUtil(z);(N=V.onOperationComplete)==null||N.call(V)}}if(D.size){const W=D;D=new Map;for(const z of W.values())(Y=(U=this.getBindingUtil(z.binding)).onAfterDelete)==null||Y.call(U,z)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterChange:(L,N)=>{var U,Y,W,z;for(const V of this.getBindingsInvolvingShape(N))G.add(V.type),V.fromId===N.id&&((Y=(U=this.getBindingUtil(V)).onAfterChangeFromShape)==null||Y.call(U,{binding:V,shapeBefore:L,shapeAfter:N})),V.toId===N.id&&((z=(W=this.getBindingUtil(V)).onAfterChangeToShape)==null||z.call(W,{binding:V,shapeBefore:L,shapeAfter:N}));if(L.parentId!==N.parentId){const V=ee=>{var Q,me,Pe,ue;const B=this.getShape(ee);if(B)for(const Oe of this.getBindingsInvolvingShape(B))G.add(Oe.type),Oe.fromId===B.id&&((me=(Q=this.getBindingUtil(Oe)).onAfterChangeFromShape)==null||me.call(Q,{binding:Oe,shapeBefore:B,shapeAfter:B})),Oe.toId===B.id&&((ue=(Pe=this.getBindingUtil(Oe)).onAfterChangeToShape)==null||ue.call(Pe,{binding:Oe,shapeBefore:B,shapeAfter:B}))};V(N.id),this.visitDescendants(N.id,V)}if(L.parentId!==N.parentId&&Ss(N.parentId)){const V=new Set([L.id]);this.visitDescendants(L.id,ee=>{V.add(ee)});for(const ee of this.getPageStates()){if(ee.pageId===N.parentId)continue;const B=O(ee,V);B&&this.store.put([B])}}L.parentId&&ws(L.parentId)&&H.add(L.parentId),N.parentId!==L.parentId&&ws(N.parentId)&&H.add(N.parentId)},beforeDelete:L=>{var W,z,V,ee;if($.has(L.id))return;L.parentId&&ws(L.parentId)&&H.add(L.parentId),$.add(L.id);const N=[];for(const B of this.getBindingsInvolvingShape(L)){G.add(B.type),N.push(B.id);const Q=this.getBindingUtil(B);B.fromId===L.id?((W=Q.onBeforeIsolateToShape)==null||W.call(Q,{binding:B,removedShape:L}),(z=Q.onBeforeDeleteFromShape)==null||z.call(Q,{binding:B,shape:L})):((V=Q.onBeforeIsolateFromShape)==null||V.call(Q,{binding:B,removedShape:L}),(ee=Q.onBeforeDeleteToShape)==null||ee.call(Q,{binding:B,shape:L}))}N.length&&this.deleteBindings(N);const U=new Set([L.id]),Y=rt(this.getPageStates().map(B=>O(B,U)));Y.length&&this.store.put(Y)}},binding:{beforeCreate:L=>{var U,Y;const N=(Y=(U=this.getBindingUtil(L)).onBeforeCreate)==null?void 0:Y.call(U,{binding:L});return N||L},afterCreate:L=>{var N,U;G.add(L.type),(U=(N=this.getBindingUtil(L)).onAfterCreate)==null||U.call(N,{binding:L})},beforeChange:(L,N)=>{var Y,W;const U=(W=(Y=this.getBindingUtil(N)).onBeforeChange)==null?void 0:W.call(Y,{bindingBefore:L,bindingAfter:N});return U||N},afterChange:(L,N)=>{var U,Y;G.add(N.type),(Y=(U=this.getBindingUtil(N)).onAfterChange)==null||Y.call(U,{bindingBefore:L,bindingAfter:N})},beforeDelete:L=>{var N,U;(U=(N=this.getBindingUtil(L)).onBeforeDelete)==null||U.call(N,{binding:L})},afterDelete:L=>{var N,U;(U=(N=this.getBindingUtil(L)).onAfterDelete)==null||U.call(N,{binding:L}),G.add(L.type)}},page:{afterCreate:L=>{const N=jo.createId(L.id),U=Yi.createId(L.id);this.store.has(N)||this.store.put([jo.create({id:N})]),this.store.has(U)||this.store.put([Yi.create({id:U,pageId:L.id})])},afterDelete:(L,N)=>{var W,z;if(((W=this.getInstanceState())==null?void 0:W.currentPageId)===L.id){const V=(z=this.getPages().find(ee=>ee.id!==L.id))==null?void 0:z.id;V?this.store.put([{...this.getInstanceState(),currentPageId:V}]):N==="user"&&this.store.ensureStoreIsUsable()}const U=jo.createId(L.id),Y=Yi.createId(L.id);this.store.remove([U,Y])}},instance:{afterChange:(L,N,U)=>{var Y;if(!this.store.has(N.currentPageId)){const W=this.store.has(L.currentPageId)?L.currentPageId:(Y=this.getPages()[0])==null?void 0:Y.id;W?this.store.update(N.id,z=>({...z,currentPageId:W})):U==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(L,N)=>{if((L==null?void 0:L.selectedShapeIds)!==(N==null?void 0:N.selectedShapeIds)){const U=N.selectedShapeIds.filter(W=>{var V,ee;let z=(V=this.getShape(W))==null?void 0:V.parentId;for(;ws(z);){if(N.selectedShapeIds.includes(z))return!1;z=(ee=this.getShape(z))==null?void 0:ee.parentId}return!0});let Y=null;if(U.length>0){const W=this.findCommonAncestor(rt(U.map(z=>this.getShape(z))),z=>this.isShapeOfType(z,"group"));W&&(Y=W)}else N!=null&&N.focusedGroupId&&(Y=N.focusedGroupId);(U.length!==N.selectedShapeIds.length||Y!==N.focusedGroupId)&&this.store.put([{...N,selectedShapeIds:U,focusedGroupId:Y??null}])}}}})),this._currentPageShapeIds=Uie(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=Bie(this.store),this.disposables.add(this.store.listen(L=>{this.emit("change",L)})),this.disposables.add(this.history.dispose),this.run(()=>{this.store.ensureStoreIsUsable(),this._updateCurrentPageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]})},{history:"ignore"}),c&&this.root.children[c]===void 0)throw Error(`No state found for initialState "${c}".`);if(this.root.enter(void 0,"initial"),this.edgeScrollManager=new Zie(this),this.focusManager=new Jie(this,u),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 GN,(J=this.store.props.collaboration)!=null&&J.mode){const L=this.store.props.collaboration.mode;this.disposables.add(Pi("update collaboration mode",()=>{this.store.put([{...this.getInstanceState(),isReadonly:L.get()==="readonly"}])}))}}getIsShapeHiddenCache(){return this._getShapeVisibility?this.store.createComputedCache("isShapeHidden",e=>{const t=this._getShapeVisibility(e,this);return(Wr.isId(e.parentId)?!1:this.isShapeHidden(e.parentId))?t!=="visible":t==="hidden"}):null}isShapeHidden(e){return this._getShapeVisibility?!!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 t=typeof e=="string"?e:e.type,r=bn(this.shapeUtils,t);return Je(r,`No shape util found for type "${t}"`),r}hasShapeUtil(e){const t=typeof e=="string"?e:e.type;return Ci(this.shapeUtils,t)}getBindingUtil(e){const t=typeof e=="string"?e:e.type,r=bn(this.bindingUtils,t);return Je(r,`No binding util found for type "${t}"`),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??_t()),this}markHistoryStoppingPoint(e){const t=`[${e??"stop"}]_${_t()}`;return this.history._mark(t),t}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,t){const r=this._shouldIgnoreShapeLock;this._shouldIgnoreShapeLock=(t==null?void 0:t.ignoreShapeLock)??r;try{this.history.batch(e,t)}finally{this._shouldIgnoreShapeLock=r}return this}batch(e,t){return this.run(e,t)}annotateError(e,{origin:t,willCrashApp:r,tags:s,extras:i}){const o=this.createErrorAnnotations(t,r);return bI(e,{tags:{...o.tags,...s},extras:{...o.extras,...i}}),r&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(e,t){try{const r=this.getEditingShapeId();return{tags:{origin:e,willCrashApp:t},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes().map(s=>{const{props:i,...o}=s,{text:a,richText:l,...c}=i;return{...o,props:c}}),selectionCount:this.getSelectedShapes().length,editingShape:r?this.getShape(r):void 0,inputs:this.inputs,pageState:this.getCurrentPageState(),instanceState:this.getInstanceState(),collaboratorCount:this.getCollaboratorsOnCurrentPage().length}}}catch{return{tags:{origin:e,willCrashApp:t},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 t=e.split(".").reverse();let r=this.root;for(;t.length>0;){const s=t.pop();if(!s)return!0;const i=r.getCurrent();if((i==null?void 0:i.id)===s){if(t.length===0)return!0;r=i;continue}else return!1}return!1}isInAny(...e){return e.some(t=>this.isIn(t))}setCurrentTool(e,t={}){return this.root.transition(e,t),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const e=this.getCurrentTool();return e?e.getCurrentToolIdMask()??e.id:""}getStateDescendant(e){var s;const t=e.split(".").reverse();let r=this.root;for(;t.length>0;){const i=t.pop();if(!i)return r;const o=(s=r.children)==null?void 0:s[i];if(!o)return;r=o}return r}getDocumentSettings(){return this.store.get(hk)}updateDocumentSettings(e){return this.run(()=>{this.store.put([{...this.getDocumentSettings(),...e}])},{history:"ignore"}),this}getInstanceState(){return this.store.get($r)}updateInstanceState(e,t){return this._updateInstanceState(e,{history:"ignore",...t}),e.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),e.isChangingStyle===!0&&(this._isChangingStyleTimeout=this.timers.setTimeout(()=>{this._updateInstanceState({isChangingStyle:!1},{history:"ignore"})},1e3))),this}_updateInstanceState(e,t){this.run(()=>{this.store.put([{...this.getInstanceState(),...e}])},t)}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 Yi.createId(this.getCurrentPageId())}updateCurrentPageState(e){return this._updateCurrentPageState(e),this}_updateCurrentPageState(e){this.store.update(e.id??this.getCurrentPageState().id,t=>({...t,...e}))}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:e}=this.getCurrentPageState();return rt(e.map(t=>this.store.get(t)))}setSelectedShapes(e){return this.run(()=>{const t=e.map(i=>typeof i=="string"?i:i.id),{selectedShapeIds:r}=this.getCurrentPageState(),s=new Set(r);if(t.length===s.size&&t.every(i=>s.has(i)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:t}])},{history:"record-preserveRedoStack"})}isAncestorSelected(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null,r=this.getShape(t);if(!r)return!1;const s=this.getSelectedShapeIds();return!!this.findShapeAncestor(r,i=>s.includes(i.id))}select(...e){const t=typeof e[0]=="string"?e:e.map(r=>r.id);return this.setSelectedShapes(t),this}deselect(...e){const t=typeof e[0]=="string"?e:e.map(s=>s.id),r=this.getSelectedShapeIds();return r.length>0&&t.length>0&&this.setSelectedShapes(r.filter(s=>!t.includes(s))),this}selectAll(){const e=this.getSortedChildIdsForParent(this.getCurrentPageId());return e.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(e)),this)}selectAdjacentShape(e){var a;const t=this.getCurrentPageShapesInReadingOrder(),r=this.getSelectedShapeIds(),s=r.length===1?r[0]:(a=t.find(l=>r.includes(l.id)))==null?void 0:a.id;let i;if(e==="next"||e==="prev"){const l=t.map(h=>h.id),u=((s?l.indexOf(s):-1)+(e==="next"?1:-1)+l.length)%l.length;i=l[u]}else{if(!s)return;i=this.getNearestAdjacentShape(s,e)}const o=this.getShape(i);o&&(this.setSelectedShapes([o.id]),this.zoomToSelectionIfOffscreen(256,{animation:{duration:this.options.animationMediumMs},inset:0}))}getCurrentPageShapesInReadingOrder(){const s=this.getCurrentPageShapes().filter(a=>this.getShapeUtil(a).canTabTo(a));if(s.length<=1)return s;const i=s.map(a=>({shape:a,center:this.getShapePageBounds(a).center}));i.sort((a,l)=>a.center.y-l.center.y);const o=[];for(const a of i){let l=-1;for(let c=o.length-1;c>=0;c--){const u=o[c],h=u[u.length-1];if(Math.abs(a.center.y-h.center.y)<100){l=c;break}}l===-1?o.push([a]):o[l].push(a)}for(const a of o)a.sort((l,c)=>l.center.x-c.center.x);for(const a of o)if(!(a.length<=2))for(let l=0;l<a.length-2;l++){const c=a[l],u=a[l+1],h=a[l+2],p=k.Dist2(c.center,u.center);k.Dist2(c.center,h.center)<p*.9&&Math.abs(k.Angle(c.center,h.center)*(180/Math.PI))<=20&&([a[l+1],a[l+2]]=[a[l+2],a[l+1]])}return o.flat().map(a=>a.shape)}getNearestAdjacentShape(e,t){const r={right:0,left:180,down:90,up:270},s=this.getShape(e);if(!s)return e;const o=this.getCurrentPageShapes().filter(h=>this.getShapeUtil(h).canTabTo(h)&&h.id!==e);if(!o.length)return e;const a=this.getShapePageBounds(s).center,c=o.map(h=>({shape:h,center:this.getShapePageBounds(h).center})).filter(({center:h})=>{const p=h.x>a.x,m=h.y>a.y,S=h.x-a.x,x=h.y-a.y,v=Math.abs(x)<Math.abs(S)*2,w=Math.abs(S)<Math.abs(x)*2;if(t==="left"||t==="right")return v&&(t==="right"?p:!p);if(t==="up"||t==="down")return w&&(t==="down"?m:!m)});return c.length===0?e:YN(c,({center:h})=>{const p=k.Dist2(a,h),m=["left","right"].includes(t)?"x":"y",S=Math.abs(h[m]-a[m]),x=["left","right"].includes(t)?"y":"x",v=Math.abs(h[x]-a[x]),w=Math.abs(k.Angle(a,h)*(180/Math.PI)),C=Math.abs(w-r[t]);return p*1+v*2+(p-S)*1.5+C*.5}).shape.id}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 t=rt(e.map(r=>this.getShapePageBounds(r)));return t.length===0?null:Se.Common(t)}getSelectionPageBounds(){return this.getShapesPageBounds(this.getSelectedShapeIds())}getShapesSharedRotation(e){let t=!1,r=0;for(let s=0,i=e.length;s<i;s++){const o=this.getShapePageTransform(e[s]);if(o)if(t){if(o.rotation()!==r)return 0}else t=!0,r=o.rotation()}return r}getSelectionRotation(){return this.getShapesSharedRotation(this.getSelectedShapeIds())}getShapesRotatedPageBounds(e){if(e.length===0)return;const t=this.getShapesSharedRotation(e);if(t===0)return this.getShapesPageBounds(e)??void 0;if(e.length===1){const s=this.getShapeGeometry(e[0]).bounds.clone(),i=this.getShapePageTransform(e[0]);return s.point=i.applyToPoint(s.point),s}const r=Se.FromPoints(e.flatMap(s=>{const i=this.getShapePageTransform(s);return i?i.applyToPoints(this.getShapeGeometry(s).bounds.corners):[]}).map(s=>s.rot(-t)));return r.point=r.point.rot(t),r}getSelectionRotatedPageBounds(){return this.getShapesRotatedPageBounds(this.getSelectedShapeIds())}getSelectionRotatedScreenBounds(){const e=this.getSelectionRotatedPageBounds();if(!e)return;const{x:t,y:r}=this.pageToScreen(e.point),s=this.getZoomLevel();return new Se(t,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 t=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(t!==null){const r=this.getShape(t);if(!r)throw Error(`Editor.setFocusedGroup: Shape with id ${t} does not exist`);if(!this.isShapeOfType(r,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${r.type}`)}return t===this.getFocusedGroupId()?this:this.run(()=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:t}))},{history:"record-preserveRedoStack"})}popFocusedGroupId(){const e=this.getFocusedGroup();if(e){const t=this.findShapeAncestor(e,r=>this.isShapeOfType(r,"group"));this.setFocusedGroup((t==null?void 0:t.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 t=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(this.setRichTextEditor(null),t!==this.getEditingShapeId()){if(t){const r=this.getShape(t);if(r&&this.getShapeUtil(r).canEdit(r))return this.run(()=>{this._updateCurrentPageState({editingShapeId:t})},{history:"ignore"}),this}this.run(()=>{this._updateCurrentPageState({editingShapeId:null}),this._currentRichTextEditor.set(null)},{history:"ignore"})}return this}getRichTextEditor(){return this._currentRichTextEditor.get()}setRichTextEditor(e){return this._currentRichTextEditor.set(e),this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const e=this.getHoveredShapeId();return e?this.getShape(e):void 0}setHoveredShape(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;return t===this.getHoveredShapeId()?this:(this.run(()=>{this.updateCurrentPageState({hoveredShapeId:t})},{history:"ignore"}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const e=this.getHintingShapeIds();return rt(e.map(t=>this.getShape(t)))}setHintingShapes(e){const t=typeof e[0]=="string"?e:e.map(r=>r.id);return this.run(()=>{this._updateCurrentPageState({hintingShapeIds:wI(t)})},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const e=this.getErasingShapeIds();return rt(e.map(t=>this.getShape(t)))}setErasingShapes(e){const t=typeof e[0]=="string"?e:e.map(s=>s.id);t.sort();const r=this.getErasingShapeIds();return this.run(()=>{if(t.length===r.length){for(let s=0;s<t.length;s++)if(t[s]!==r[s]){this._updateCurrentPageState({erasingShapeIds:t});break}}else this._updateCurrentPageState({erasingShapeIds:t})},{history:"ignore"}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;return t!==this.getCroppingShapeId()&&this.run(()=>{if(!t)this.updateCurrentPageState({croppingShapeId:null});else{const r=this.getShape(t),s=this.getShapeUtil(r);r&&s.canCrop(r)&&this.updateCurrentPageState({croppingShapeId:t})}},{history:"ignore"}),this}getTextOptions(){return zr(this._textOptions.get(),"Cannot use text without setting textOptions")}_unsafe_getCameraId(){return jo.createId(this.getCurrentPageId())}getCamera(){const e=this.store.get(this._unsafe_getCameraId());if(this._isLockedOnFollowingUser.get()){const t=this.getCameraForFollowing();if(t)return{...e,...t}}return e}getViewportPageBoundsForFollowing(){const e=this.getInstanceState().followingUserId;if(!e)return null;const t=this.getCollaborators().find(h=>h.userId===e);if(!t||!t.camera||!t.screenBounds)return null;const{w:r,h:s}=t.screenBounds,{x:i,y:o,z:a}=t.camera,l=new Se(-i,-o,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:t,zy:r}=nL(this,e);switch(e.constraints.initialZoom){case"fit-min":return Math.max(t,r);case"fit-max":return Math.min(t,r);case"fit-x":return t;case"fit-y":return r;case"fit-min-100":return Math.min(1,Math.max(t,r));case"fit-max-100":return Math.min(1,Math.min(t,r));case"fit-x-100":return Math.min(1,t);case"fit-y-100":return Math.min(1,r);default:throw An(e.constraints.initialZoom)}}getBaseZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.baseZoom==="default")return 1;const{zx:t,zy:r}=nL(this,e);switch(e.constraints.baseZoom){case"fit-min":return Math.max(t,r);case"fit-max":return Math.min(t,r);case"fit-x":return t;case"fit-y":return r;case"fit-min-100":return Math.min(1,Math.max(t,r));case"fit-max-100":return Math.min(1,Math.min(t,r));case"fit-x-100":return Math.min(1,t);case"fit-y-100":return Math.min(1,r);default:throw An(e.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(e){var r;const t=Xt({...this._cameraOptions.__unsafe__getWithoutCapture(),...e});return((r=t.zoomSteps)==null?void 0:r.length)<1&&(t.zoomSteps=[1]),this._cameraOptions.set(t),this.setCamera(this.getCamera()),this}getConstrainedCamera(e,t){const r=this.getCamera();let{x:s,y:i,z:o=r.z}=e;if(!(t!=null&&t.force)){const a=this.getCameraOptions(),l=a.zoomSteps[0],c=tr(a.zoomSteps),u=this.getViewportScreenBounds();if(a.constraints){const{constraints:h}=a,p=Math.min(h.padding.y,u.w/2),m=Math.min(h.padding.x,u.h/2),S=Se.From(a.constraints.bounds),x=(u.w-m*2)/S.w,v=(u.h-p*2)/S.h,w=this.getBaseZoom(),C=c*w,_=l*w;if(t!=null&&t.reset&&(o=this.getInitialZoom()),o<_||o>C){const{x:J,y:L,z:N}=r,U=-J+u.w/N/2,Y=-L+u.h/N/2;o=Mn(o,_,C);const W=-J+u.w/o/2,z=-L+u.h/o/2;s=J+W-U,i=L+z-Y}const E=m/o-S.x,T=p/o-S.y,A=(u.w-m*2)/o-S.w,O=(u.h-p*2)/o-S.h,D=E+A*h.origin.x,$=T+O*h.origin.y,H=typeof h.behavior=="string"?h.behavior:h.behavior.x,G=typeof h.behavior=="string"?h.behavior:h.behavior.y;if(t!=null&&t.reset)s=D,i=$;else{switch(H){case"fixed":{s=D;break}case"contain":{o<x?s=D:s=Mn(s,E+A,E);break}case"inside":{o<x?s=Mn(s,E,(u.w-m)/o-S.w):s=Mn(s,E+A,E);break}case"outside":{s=Mn(s,m/o-S.w,(u.w-m)/o);break}case"free":break;default:throw An(H)}switch(G){case"fixed":{i=$;break}case"contain":{o<v?i=$:i=Mn(i,T+O,T);break}case"inside":{o<v?i=Mn(i,T,(u.h-p)/o-S.h):i=Mn(i,T+O,T);break}case"outside":{i=Mn(i,p/o-S.h,(u.h-p)/o);break}case"free":break;default:throw An(G)}}}else if(o>c||o<l){const{x:h,y:p,z:m}=r;o=Mn(o,l,c),s=h+(-h+u.w/o/2)-(-h+u.w/m/2),i=p+(-p+u.h/o/2)-(-p+u.h/m/2)}}return{x:s,y:i,z:o}}_setCamera(e,t){const r=this.getCamera(),{x:s,y:i,z:o}=this.getConstrainedCamera(e,t);return r.x===s&&r.y===i&&r.z===o?this:(Vs(()=>{const a={...r,x:s,y:i,z:o};this.run(()=>{this.store.put([a])},{history:"ignore"});const{currentScreenPoint:l,currentPagePoint:c}=this.inputs,{screenBounds:u}=this.store.unsafeGetWithoutCapture($r);if(l.x/o-s!==c.x||l.y/o-i!==c.y){const h={type:"pointer",target:"canvas",name:"pointer_move",point:k.AddXY(l,u.x,u.y),pointerId:Sj.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,metaKey:this.inputs.metaKey,accelKey:Pr(this.inputs),button:0,isPen:this.getInstanceState().isPenMode??!1};t!=null&&t.immediate?this._flushEventForTick(h):this.dispatch(h)}this._tickCameraState()}),this)}setCamera(e,t){const{isLocked:r}=this._cameraOptions.__unsafe__getWithoutCapture();if(r&&!(t!=null&&t.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const s=k.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 i=this.getConstrainedCamera(s,t);if(t!=null&&t.animation){const{width:o,height:a}=this.getViewportScreenBounds();this._animateToViewport(new Se(-i.x,-i.y,o/i.z,a/i.z),t)}else this._setCamera(i,{...t,force:!0});return this}centerOnPoint(e,t){const{isLocked:r}=this.getCameraOptions();if(r&&!(t!=null&&t.force))return this;const{width:s,height:i}=this.getViewportPageBounds();return this.setCamera(new k(-(e.x-s/2),-(e.y-i/2),this.getCamera().z),t),this}zoomToFit(e){const t=[...this.getCurrentPageShapeIds()];if(t.length<=0)return this;const r=Se.Common(rt(t.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(r,e),this}resetZoom(e=this.getViewportScreenCenter(),t){const{isLocked:r,constraints:s}=this.getCameraOptions();if(r&&!(t!=null&&t.force))return this;const i=this.getCamera(),{x:o,y:a,z:l}=i,{x:c,y:u}=e;let h=1;if(s){const p=this.getInitialZoom();l!==p&&(h=p)}return this.setCamera(new k(o+(c/h-c)-(c/l-c),a+(u/h-u)-(u/l-u),h),t),this}zoomIn(e=this.getViewportScreenCenter(),t){const{isLocked:r}=this.getCameraOptions();if(r&&!(t!=null&&t.force))return this;const{x:s,y:i,z:o}=this.getCamera(),{zoomSteps:a}=this.getCameraOptions();if(a!==null&&a.length>1){const l=this.getBaseZoom();let c=tr(a)*l;for(let u=1;u<a.length;u++){const h=a[u-1]*l,p=a[u]*l;if(!(p-o<=(p-h)/2)){c=p;break}}this.setCamera(new k(s+(e.x/c-e.x)-(e.x/o-e.x),i+(e.y/c-e.y)-(e.y/o-e.y),c),t)}return this}zoomOut(e=this.getViewportScreenCenter(),t){const{isLocked:r}=this.getCameraOptions();if(r&&!(t!=null&&t.force))return this;const{zoomSteps:s}=this.getCameraOptions();if(s!==null&&s.length>1){const i=this.getBaseZoom(),{x:o,y:a,z:l}=this.getCamera();let c=s[0]*i;for(let u=s.length-1;u>0;u--){const h=s[u-1]*i,p=s[u]*i;if(!(p-l>=(p-h)/2)){c=h;break}}this.setCamera(new k(o+(e.x/c-e.x)-(e.x/l-e.x),a+(e.y/c-e.y)-(e.y/l-e.y),c),t)}return this}zoomToSelection(e){const{isLocked:t}=this.getCameraOptions();if(t&&!(e!=null&&e.force))return this;const r=this.getSelectionPageBounds();return r&&this.zoomToBounds(r,{targetZoom:Math.max(1,this.getZoomLevel()),...e}),this}zoomToSelectionIfOffscreen(e=16,t){const r=this.getSelectionPageBounds(),s=this.getViewportPageBounds();if(r&&!s.contains(r)){const i=r.clone().expandBy(e/this.getZoomLevel()).expand(s),o=s.clone().translate({x:(i.center.x-s.center.x)*2,y:(i.center.y-s.center.y)*2});this.zoomToBounds(o,t)}}zoomToBounds(e,t){const r=this._cameraOptions.__unsafe__getWithoutCapture();if(r.isLocked&&!(t!=null&&t.force))return this;const s=this.getViewportScreenBounds(),i=(t==null?void 0:t.inset)??Math.min(Jte,s.width*.28),o=this.getBaseZoom(),a=r.zoomSteps[0],l=tr(r.zoomSteps);let c=Mn(Math.min((s.width-i)/e.w,(s.height-i)/e.h),a*o,l*o);return(t==null?void 0:t.targetZoom)!==void 0&&(c=Math.min(t.targetZoom,c)),this.setCamera(new k(-e.x+(s.width-e.w*c)/2/c,-e.y+(s.height-e.h*c)/2/c,c),t),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(e){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=e;const{elapsed:t,easing:r,duration:s,start:i,end:o}=this._viewportAnimation;if(t>s){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new k(-o.x,-o.y,this.getViewportScreenBounds().width/o.width));return}const a=s-t,l=r(1-a/s),c=i.minX+(o.minX-i.minX)*l,u=i.minY+(o.minY-i.minY)*l,h=i.maxX+(o.maxX-i.maxX)*l;this._setCamera(new k(-c,-u,this.getViewportScreenBounds().width/(h-c)),{force:!0})}_animateToViewport(e,t={animation:fC}){const{animation:r,...s}=t;if(!r)return;const{duration:i=0,easing:o=Hn.easeInOutCubic}=r,a=this.user.getAnimationSpeed(),l=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),i===0||a===0?this._setCamera(new k(-e.x,-e.y,this.getViewportScreenBounds().width/e.width),{...s}):(this._viewportAnimation={elapsed:0,duration:i/a,easing:o,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:t}=this.getCameraOptions();if(t&&!(e!=null&&e.force))return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:s,friction:i=this.options.cameraSlideFriction,direction:o,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:p,y:m,z:S}=this.getCamera(),x=k.Mul(o,l*h/S);l*=1-i,l<a?c():this._setCamera(new k(p+x.x,m+x.y,S))};return this.on("tick",u),this}zoomToUser(e,t={animation:{duration:500}}){const r=this.getCollaborators().find(i=>i.userId===e);if(!r)return this;const s=r.cursor;return s?(this.run(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const i=r.currentPageId===this.getCurrentPageId();i||this.setCurrentPage(r.currentPageId),t&&t.animation&&!i&&(t.animation=void 0),this.centerOnPoint(s,t);const{highlightedUserIds:o}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...o,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,t=!1){if(e instanceof HTMLElement){const a=e.getBoundingClientRect();e=new Se(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,!_a(document.body.scrollWidth,e.maxX,1),!_a(document.body.scrollHeight,e.maxY,1),e.minX!==0],{_willSetInitialBounds:s}=this;this._willSetInitialBounds=!1;const{screenBounds:i,insets:o}=this.getInstanceState();if(e.equals(i)&&r.every((a,l)=>a===o[l]))return this;if(s)this.updateInstanceState({screenBounds:e.toJson(),insets:r}),this.setCamera(this.getCamera());else if(t&&!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(k.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:e,y:t,w:r,h:s}=this.getInstanceState().screenBounds;return new Se(e,t,r,s)}getViewportScreenCenter(){const e=this.getViewportScreenBounds();return new k(e.midX-e.minX,e.midY-e.minY)}getViewportPageBounds(){const{w:e,h:t}=this.getViewportScreenBounds(),{x:r,y:s,z:i}=this.getCamera();return new Se(-r,-s,e/i,t/i)}screenToPage(e){const{screenBounds:t}=this.store.unsafeGetWithoutCapture($r),{x:r,y:s,z:i=1}=this.getCamera();return new k((e.x-t.x)/i-r,(e.y-t.y)/i-s,e.z??.5)}pageToScreen(e){const{screenBounds:t}=this.store.unsafeGetWithoutCapture($r),{x:r,y:s,z:i=1}=this.getCamera();return new k((e.x+r)*i+t.x,(e.y+s)*i+t.y,e.z??.5)}pageToViewport(e){const{x:t,y:r,z:s=1}=this.getCamera();return new k((e.x+t)*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=>EV(e.filter(i=>i.userId===r),i=>i.lastActivityTimestamp??0)):kr}getCollaboratorsOnCurrentPage(){const e=this.getCurrentPageId();return this.getCollaborators().filter(t=>t.currentPageId===e)}startFollowingUser(e){this.stopFollowingUser();const t=this._getCollaboratorsQuery().get().filter(i=>i.userId===e);if(!t.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"),t.some(i=>i.followingUserId===r))return this;const s=ce("latestLeaderPresence",()=>this.getCollaborators().find(i=>i.userId===e));return Vs(()=>{this.updateInstanceState({followingUserId:e},{history:"ignore"});const i=Pi("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"})}),o=()=>{i(),this._isLockedOnFollowingUser.set(!1),this.off("frame",a),this.off("stop-following",o)},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(),p=Math.abs(u.minX-h.minX)+Math.abs(u.maxX-h.maxX),m=Math.abs(u.minY-h.minY)+Math.abs(u.maxY-h.maxY);if(p<this.options.followChaseViewportSnap&&m<this.options.followChaseViewportSnap){this._isLockedOnFollowingUser.set(!0);return}const S=Mn(c*.5,.1,.8),x=new Se(yt(h.minX,u.minX,S),yt(h.minY,u.minY,S),yt(h.width,u.width,S),yt(h.height,u.height,S)),v=new k(-x.x,-x.y,this.getViewportScreenBounds().width/x.width);this.stopCameraAnimation(),this._setCamera(v)};this.once("stop-following",o),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 t=[];let r=this.options.maxShapesPerPage*2,s=this.options.maxShapesPerPage;const i=this.getErasingShapeIds(),o=(l,c,u)=>{const h=this.getShape(l);if(!h)return;if(this.isShapeHidden(h)){const v=u||i.includes(l);for(const w of this.getSortedChildIdsForParent(l))o(w,c,v);return}c*=h.opacity;let p=!1;const m=this.getShapeUtil(h);e&&(p=!u&&i.includes(l),p&&(c*=.32)),t.push({id:l,shape:h,util:m,index:r,backgroundIndex:s,opacity:c}),r+=1,s+=1;const S=this.getSortedChildIdsForParent(l);if(!S.length)return;let x=null;m.providesBackgroundForChildren(h)&&(x=s,s=r,r+=this.options.maxShapesPerPage);for(const v of S)o(v,c,u||p);x!==null&&(s=x)},a=e?[this.getCurrentPage()]:this.getPages();for(const l of a)for(const c of this.getSortedChildIdsForParent(l.id))o(c,1,!1);return t}_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(iq)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return Array.from(this._getAllPagesQuery().get()).sort(nr)}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 t=typeof e=="string"?e:e.id,r=this.store.query.exec("shape",{parentId:{eq:t}});return this.getShapeAndDescendantIds(r.map(s=>s.id))}setCurrentPage(e){const t=typeof e=="string"?e:e.id;return this.store.has(t)?(this.stopFollowingUser(),this.complete(),this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:t}]),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 t=this.getPages(),r=Rie(e.name??"Page 1",t.map(o=>o.name));let s=e.index;(!s||t.some(o=>o.index===s))&&(s=Ro(t[t.length-1].index));const i=Wr.create({meta:{},...e,name:r,index:s});this.store.put([i])}),this}deletePage(e){const t=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(t);if(s){if(t===this.getCurrentPageId()){const i=r.findIndex(a=>a.id===t),o=r[i-1]??r[i+1];this.setCurrentPage(o.id)}this.store.remove([s.id])}}),this}duplicatePage(e,t=Wr.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 i={...this.getCamera()},o=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(s.id));return this.run(()=>{var c;const a=this.getPages(),l=sp(s.index,(c=a[a.indexOf(s)+1])==null?void 0:c.index);if(this.createPage({name:s.name+" Copy",id:t,index:l}),this.setCurrentPage(t),this.setCamera(i),o)return this.putContentOntoCurrentPage(o)}),this}renamePage(e,t){const r=typeof e=="string"?e:e.id;return this.getIsReadonly()?this:(this.updatePage({id:r,name:t}),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(t=>({...this.store.get(t.id),...t})))},{history:"ignore"}),this)}deleteAssets(e){if(this.getIsReadonly())return this;const t=typeof e[0]=="string"?e:e.map(r=>r.id);return t.length<=0?this:(this.run(()=>{var r,s;(s=(r=this.store.props.assets).remove)==null||s.call(r,t),this.store.remove(t)},{history:"ignore"}),this)}getAsset(e){return this.store.get(typeof e=="string"?e:e.id)}async resolveAssetUrl(e,t){if(!e)return null;const r=this.getAsset(e);if(!r)return null;const{screenScale:s=1,shouldResolveToOriginal:i=!1,dpr:o=this.getInstanceState().devicePixelRatio}=t,l=(u=>Math.pow(2,Math.ceil(Math.log2(u))))(s),c="connection"in navigator?navigator.connection.effectiveType:null;return await this.store.props.assets.resolve(r,{screenScale:s||1,steppedScreenScale:l,dpr:o,networkEffectiveType:c,shouldResolveToOriginal:i})}async uploadAsset(e,t,r){return await this.store.props.assets.upload(e,t,r)}getShapeGeometry(e,t){const r=(t==null?void 0:t.context)??"none";return this._shapeGeometryCaches[r]||(this._shapeGeometryCaches[r]=this.store.createComputedCache("bounds",s=>(this.fonts.trackFontsForShape(s),this.getShapeUtil(s).getGeometry(s,t)),{areRecordsEqual:(s,i)=>s.props===i.props})),this._shapeGeometryCaches[r].get(typeof e=="string"?e:e.id)}getShapePageGeometry(e,t){const r=(t==null?void 0:t.context)??"none";return this._shapePageGeometryCaches[r]||(this._shapePageGeometryCaches[r]=this.store.createComputedCache("bounds",s=>{const i=this.getShapeGeometry(s.id,t),o=this.getShapePageTransform(s.id);return i.transform(o)},{areRecordsEqual:()=>!0})),this._shapePageGeometryCaches[r].get(typeof e=="string"?e:e.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",e=>{var t,r;return(r=(t=this.getShapeUtil(e)).getHandles)==null?void 0:r.call(t,e)})}getShapeHandles(e){return this._getShapeHandlesCache().get(typeof e=="string"?e:e.id)}getShapeLocalTransform(e){const t=typeof e=="string"?e:e.id,r=this.getShape(t);if(!r)throw Error("Editor.getTransform: shape not found");return he.Identity().translate(r.x,r.y).rotate(r.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",e=>{if(Ss(e.parentId))return this.getShapeLocalTransform(e);const t=this._getShapePageTransformCache().get(e.parentId)??he.Identity();return he.Compose(t,this.getShapeLocalTransform(e))})}getShapeParentTransform(e){const t=typeof e=="string"?e:e.id,r=this.getShape(t);return!r||Ss(r.parentId)?he.Identity():this._getShapePageTransformCache().get(r.parentId)??he.Identity()}getShapePageTransform(e){const t=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(t)??he.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",e=>this.getShapePageGeometry(e).bounds)}getShapePageBounds(e){return this._getShapePageBoundsCache().get(typeof e=="string"?e:e.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",e=>{const t=this._getShapeMaskCache().get(e.id);if(!t)return;if(t.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const r=this._getShapePageTransformCache().get(e.id);return r?`polygon(${he.applyToPoints(he.Inverse(r),t).map(i=>`${i.x}px ${i.y}px`).join(",")})`:void 0})}getShapeClipPath(e){return this._getShapeClipPathCache().get(typeof e=="string"?e:e.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",e=>{if(Ss(e.parentId))return;const t=this.getShapeAncestors(e.id).filter(s=>this.isShapeOfType(s,"frame"));return t.length===0?void 0:t.map(s=>this.getShapePageGeometry(s.id).vertices).reduce((s,i)=>{if(!(i&&s))return;const o=Rj(s,i);return o?o.map(k.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 t=this._getShapePageBoundsCache().get(e.id);if(!t)return;const r=this._getShapeMaskCache().get(e.id);if(r){if(r.length===0)return;const{corners:s}=t;if(s.every((o,a)=>o&&k.Equals(o,r[a])))return t.clone();const i=Rj(r,s);return i?Se.FromPoints(i):void 0}return t})}getShapeAncestors(e,t=[]){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return t;const i=s.parentId;if(Ss(i))return t.reverse(),t;const o=this.store.get(i);return o?(t.push(o),this.getShapeAncestors(o,t)):t}findShapeAncestor(e,t){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return;const i=s.parentId;if(Ss(i))return;const o=this.getShape(i);if(o)return t(o)?o:this.findShapeAncestor(o,t)}hasAncestor(e,t){const r=typeof e=="string"?e:e==null?void 0:e.id,s=r&&this.getShape(r);return s?s.parentId===t?!0:this.hasAncestor(this.getShapeParent(s),t):!1}findCommonAncestor(e,t){var l;if(e.length===0)return;const r=typeof e[0]=="string"?e:e.map(c=>c.id),s=rt(r.map(c=>this.getShape(c)));if(s.length===1){const c=s[0].parentId;return Ss(c)?void 0:t?(l=this.findShapeAncestor(s[0],t))==null?void 0:l.id:c}const[i,...o]=s;let a=this.getShapeParent(i);for(;a;){if(t&&!t(a)){a=this.getShapeParent(a);continue}if(o.every(c=>this.hasAncestor(c,a.id)))return a.id;a=this.getShapeParent(a)}}isShapeOrAncestorLocked(e){const t=typeof e=="string"?this.getShape(e):e;return t===void 0?!1:t.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(t))}_notVisibleShapes(){return $ie(this)}getCulledShapes(){const e=this._notVisibleShapes().get(),t=this.getSelectedShapeIds(),r=this.getEditingShapeId(),s=new Set(e);return r&&s.delete(r),t.forEach(i=>{s.delete(i)}),s}getCurrentPageBounds(){let e;return this.getCurrentPageShapeIdsSorted().forEach(t=>{const r=this.getShapeMaskedPageBounds(t);r&&(e?e=e.expand(r):e=r.clone())}),e}getSelectedShapeAtPoint(e){const t=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(r=>r.type!=="group"&&t.includes(r.id)).reverse().find(r=>this.isPointInShape(r,e,{hitInside:!0,margin:0}))}getShapeAtPoint(e,t={}){var v;const r=this.getZoomLevel(),s=this.getViewportPageBounds(),{filter:i,margin:o=0,hitLocked:a=!1,hitLabels:l=!1,hitInside:c=!1,hitFrameInside:u=!1}=t;let h=1/0,p=null,m=1/0,S=null;const x=(t.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(w=>{if(w.isLocked&&!a||this.isShapeHidden(w)||this.isShapeOfType(w,"group"))return!1;const C=this.getShapeMask(w);return C&&!qs(e,C)?!1:i?i(w):!0});for(let w=x.length-1;w>=0;w--){const C=x[w],_=this.getShapeGeometry(C),E=_ instanceof Js,T=this.getPointInShapeSpace(C,e);if(this.isShapeOfType(C,"frame")||this.isShapeOfType(C,"arrow")&&C.props.text.trim()||(this.isShapeOfType(C,"note")||this.isShapeOfType(C,"geo")&&C.props.fill==="none")&&((v=this.getShapeUtil(C).getText(C))!=null&&v.trim())){for(const O of _.children)if(O.isLabel&&O.isPointInBounds(T))return C}if(this.isShapeOfType(C,"frame")){const O=_.distanceToPoint(T,c);if(Math.abs(O)<=o)return S||C;if(_.hitTestPoint(T,0,!0))return S||p||(u?C:void 0);continue}let A;if(E){let O=1/0;for(const D of _.children){if(D.isLabel&&!l)continue;const $=D.distanceToPoint(T,c);$<O&&(O=$)}A=O}else o===0&&(_.bounds.w<1||_.bounds.h<1)||_.bounds.containsPoint(T,o)?A=_.distanceToPoint(T,c):A=1/0;if(_.isClosed){if(A<=o){if(_.isFilled||E&&_.children[0].isFilled)return S||C;if(this.getShapePageBounds(C).contains(s))continue;if(Math.abs(A)<o)Math.abs(A)<m&&(m=Math.abs(A),S=C);else if(!S){const{area:O}=_;O<h&&(h=O,p=C)}}}else if(A<this.options.hitTestMargin/r)return C}return S||p||void 0}getShapesAtPoint(e,t={}){return this.getCurrentPageShapes().filter(r=>!this.isShapeHidden(r)&&this.isPointInShape(r,e,t))}isPointInShape(e,t,r={}){const{hitInside:s=!1,margin:i=0}=r,o=typeof e=="string"?e:e.id,a=this.getShapeMask(o);return a&&!qs(t,a)?!1:this.getShapeGeometry(o).hitTestPoint(this.getPointInShapeSpace(e,t),i,s)}getPointInShapeSpace(e,t){const r=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(r).clone().invert().applyToPoint(t)}getPointInParentSpace(e,t){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return new k(0,0);if(Ss(s.parentId))return k.From(t);const i=this.getShapePageTransform(s.parentId);return i?i.clone().invert().applyToPoint(t):k.From(t)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),e=>this.store.get(e))}getCurrentPageShapesSorted(){const e=[],t=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let r=0,s=t.length;r<s;r++)A6(this,t[r],e);return e}getCurrentPageRenderingShapesSorted(){const e=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:t})=>!e.has(t)&&!this.isShapeHidden(t))}isShapeOfType(e,t){const r=typeof e=="string"?this.getShape(e):e;return r?r.type===t:!1}getShape(e){const t=typeof e=="string"?e:e.id;if(ws(t))return this.store.get(t)}getShapeParent(e){const t=typeof e=="string"?e:e==null?void 0:e.id;if(!t)return;const r=this.getShape(t);if(!(r===void 0||!ws(r.parentId)))return this.store.get(r.parentId)}getShapeNearestSibling(e,t){return t?t.parentId===e.parentId?t:this.findShapeAncestor(t,s=>s.parentId===e.parentId):void 0}isShapeInPage(e,t=this.getCurrentPageId()){const r=typeof e=="string"?e:e.id,s=this.getShape(r);if(!s)return!1;let i=!1;if(s.parentId===t)i=!0;else{let o=this.getShape(s.parentId);e:for(;o;){if(o.parentId===t){i=!0;break e}o=this.getShape(o.parentId)}}return i}getAncestorPageId(e){const t=typeof e=="string"?e:e==null?void 0:e.id,r=t&&this.getShape(t);if(r)return Ss(r.parentId)?r.parentId:this.getAncestorPageId(this.getShape(r.parentId))}reparentShapes(e,t,r){const s=typeof e[0]=="string"?e:e.map(p=>p.id);if(s.length===0)return this;const i=[],o=Ss(t)?he.Identity():this.getShapePageTransform(t),a=o.rotation();let l=[];const c=rt(this.getSortedChildIdsForParent(t).map(p=>this.getShape(p)));if(r){const p=c.find(m=>m.index===r);if(p){const m=c[c.indexOf(p)+1];m?l=$d(r,m.index,s.length):l=Fw(r,s.length)}else{const m=c.sort(nr).find(S=>S.index>r);m?l=$d(r,m.index,s.length):l=Fw(r,s.length)}}else{const p=c.length&&c[c.length-1];l=p?Fw(p.index,s.length):ip(s.length)}const u=o.clone().invert(),h=rt(s.map(p=>this.getShape(p))).sort(nr);return this.run(()=>{for(let p=0;p<h.length;p++){const m=h[p],S=this.getShapePageTransform(m);if(!S)continue;const x=S.point();if(!x)continue;const v=u.applyToPoint(x),w=S.rotation()-a;i.push({id:m.id,type:m.type,parentId:t,x:v.x,y:v.y,rotation:w,index:l[p]})}this.updateShapes(i)},{ignoreShapeLock:!0}),this}getHighestIndexForParent(e){const t=typeof e=="string"?e:e.id,r=this._parentIdsToChildIds.get()[t];if(!r||r.length===0)return"a1";const s=this.getShape(r[r.length-1]);return Ro(s.index)}getSortedChildIdsForParent(e){const t=typeof e=="string"?e:e.id,r=this._parentIdsToChildIds.get()[t];return r||kr}visitDescendants(e,t){const r=typeof e=="string"?e:e.id,s=this.getSortedChildIdsForParent(r);for(const i of s)t(i)!==!1&&this.visitDescendants(i,t);return this}getShapeAndDescendantIds(e){const t=new Set;for(const r of e.map(s=>this.getShape(s)).sort(nr))t.add(r.id),this.visitDescendants(r,s=>{t.add(s)});return t}getDroppingOverShape(e,t=[]){const r=this.getCurrentPageShapesSorted();for(let s=r.length-1;s>=0;s--){const i=r[s];if(this.isShapeHidden(i)||this.getSelectedShapeIds().includes(i.id)||!this.getShapeUtil(i).canDropShapes(i,t)||t.find(a=>a.id===i.id||this.hasAncestor(i,a.id)))continue;const o=this.getShapeMaskedPageBounds(i.id);if(o&&o.containsPoint(e)&&this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(i,e),0,!0))return i}}getOutermostSelectableShape(e,t){const r=typeof e=="string"?e:e.id,s=this.getShape(r);let i=s,o=s;const a=this.getFocusedGroup();for(;o;){if(this.isShapeOfType(o,"group")&&(a==null?void 0:a.id)!==o.id&&!this.hasAncestor(a,o.id)&&((t==null?void 0:t(o))??!0))i=o;else if((a==null?void 0:a.id)===o.id)break;o=this.getShapeParent(o)}return i}_getBindingsIndexCache(){const e=Fie(this);return this.store.createComputedCache("bindingsIndex",t=>e.get().get(t.id))}getBinding(e){return this.store.get(e)}getBindingsFromShape(e,t){const r=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(r).filter(s=>s.fromId===r&&s.type===t)}getBindingsToShape(e,t){const r=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(r).filter(s=>s.toId===r&&s.type===t)}getBindingsInvolvingShape(e,t){const r=typeof e=="string"?e:e.id,s=this._getBindingsIndexCache().get(r)??kr;return t?s.filter(i=>i.type===t):s}createBindings(e){const t=[];for(const r of e){const s=this.getShape(r.fromId),i=this.getShape(r.toId);if(!s||!i||!this.canBindShapes({fromShape:s,toShape:i,binding:r}))continue;const a=this.getBindingUtil(r.type).getDefaultProps(),l=this.store.schema.types.binding.create({...r,id:r.id??Gc(),props:{...a,...r.props}});t.push(l)}return this.store.put(t),this}createBinding(e){return this.createBindings([e])}updateBindings(e){const t=[];for(const r of e){if(!r)continue;const s=this.getBinding(r.id);if(!s)continue;const i=Po(s,r);if(i===s)continue;const o=this.getShape(i.fromId),a=this.getShape(i.toId);!o||!a||this.canBindShapes({fromShape:o,toShape:a,binding:i})&&t.push(i)}return this.store.put(t),this}updateBinding(e){return this.updateBindings([e])}deleteBindings(e,{isolateShapes:t=!1}={}){const r=e.map(s=>typeof s=="string"?s:s.id);return t?this.store.atomic(()=>{var s,i;for(const o of r){const a=this.getBinding(o);if(!a)continue;const l=this.getBindingUtil(a);(s=l.onBeforeIsolateFromShape)==null||s.call(l,{binding:a,removedShape:this.getShape(a.toId)}),(i=l.onBeforeIsolateToShape)==null||i.call(l,{binding:a,removedShape:this.getShape(a.fromId)}),this.store.remove([o])}}):this.store.remove(r),this}deleteBinding(e,t){return this.deleteBindings([e],t)}canBindShapes({fromShape:e,toShape:t,binding:r}){const s=typeof e=="string"?e:e.type,i=typeof t=="string"?t:t.type,o=typeof r=="string"?r:r.type,a={fromShapeType:s,toShapeType:i,bindingType:o};return s===i?this.getShapeUtil(s).canBind(a):this.getShapeUtil(s).canBind(a)&&this.getShapeUtil(i).canBind(a)}rotateShapesBy(e,t,r){const s=typeof e[0]=="string"?e:e.map(o=>o.id);if(s.length<=0)return this;const i=r$({editor:this,ids:s});return i?(Sy({delta:t,snapshot:i,editor:this,stage:"one-off",centerOverride:r==null?void 0:r.center}),this):this}getChangesToTranslateShape(e,t){var l,c,u;let r=e;const s=this.getShapeUtil(e),i=(l=s.onTranslateStart)==null?void 0:l.call(s,r);i&&(r=Po(r,i)),r=Po(r,{id:e.id,type:e.type,x:t.x,y:t.y});const o=(c=s.onTranslate)==null?void 0:c.call(s,e,r);o&&(r=Po(r,o));const a=(u=s.onTranslateEnd)==null?void 0:u.call(s,e,r);return a&&(r=Po(r,a)),r}nudgeShapes(e,t){const r=typeof e[0]=="string"?e:e.map(i=>i.id);if(r.length<=0)return this;const s=[];for(const i of r){const o=this.getShape(i),a=k.From(t),l=this.getShapeParentTransform(o);l&&a.rot(-l.rotation()),s.push(this.getChangesToTranslateShape(o,a.add(o)))}return this.updateShapes(s),this}duplicateShapes(e,t){return this.run(()=>{const r=typeof e[0]=="string"?e:e.map(p=>p.id);if(r.length<=0)return this;const s=new Set(r),i=this.getShapeAndDescendantIds(r),o=[...i].reverse(),a=new Map;for(const p of i)a.set(p,Dt());const{shapesToCreateWithOriginals:l,bindingsToCreate:c}=tL(this,i,p=>{const m=[];for(const x of p){const v=this.getBinding(x);if(!v)continue;const w=Gc();m.push({...v,id:w,fromId:zr(a.get(v.fromId)),toId:zr(a.get(v.toId))})}const S=[];for(const x of o){const v=zr(a.get(x)),w=this.getShape(x);if(!w)continue;let C=0,_=0;if(t&&s.has(x)){const E=this.getShapeParentTransform(w),T=new k(t.x,t.y).rot(-E.rotation());C=T.x,_=T.y}S.push({shape:{...w,id:v,x:w.x+C,y:w.y+_,index:"a1",parentId:a.get(w.parentId)??w.parentId},originalShape:w})}return{shapesToCreateWithOriginals:S,bindingsToCreate:m}});l.forEach(({shape:p,originalShape:m})=>{const S=m.parentId,x=this.getSortedChildIdsForParent(S),v=x.indexOf(m.id),w=x[v+1],C=w?this.getShape(w):void 0,_=sp(m.index,C==null?void 0:C.index);p.index=_});const u=l.map(({shape:p})=>p);if(u.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage){Lm(this);return}if(this.createShapes(u),this.createBindings(c),this.setSelectedShapes(rt(r.map(p=>a.get(p)))),t!==void 0){const p=this.getSelectionPageBounds(),m=this.getViewportPageBounds();p&&!m.contains(p)&&this.centerOnPoint(p.center,{animation:{duration:this.options.animationMediumMs}})}}),this}moveShapesToPage(e,t){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(t===s)return this;if(!this.store.has(t))return this;const i=this.getContentFromCurrentPage(r);if(!i)return this;if(this.getPageShapeIds(t).size+i.shapes.length>this.options.maxShapesPerPage)return Lm(this,t),this;const o=this.getCamera().z;return this.run(()=>{this.deleteShapes(r),this.setCurrentPage(t),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(i,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:o}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(e){const t=typeof e[0]=="string"?e:e.map(o=>o.id);if(this.getIsReadonly()||t.length===0)return this;let r=!0,s=!0;const i=[];for(const o of t){const a=this.getShape(o);a&&(i.push(a),a.isLocked?s=!1:r=!1)}return this.run(()=>{s?(this.updateShapes(i.map(o=>({id:o.id,type:o.type,isLocked:!0}))),this.setSelectedShapes([])):r?this.updateShapes(i.map(o=>({id:o.id,type:o.type,isLocked:!1}))):this.updateShapes(i.map(o=>({id:o.id,type:o.type,isLocked:!0})))}),this}sendToBack(e){const t=typeof e[0]=="string"?e:e.map(s=>s.id),r=Dm(this,"toBack",t,{considerAllShapes:!0});return r&&this.updateShapes(r),this}sendBackward(e,t={}){const r=typeof e[0]=="string"?e:e.map(i=>i.id),s=Dm(this,"backward",r,t);return s&&this.updateShapes(s),this}bringForward(e,t={}){const r=typeof e[0]=="string"?e:e.map(i=>i.id),s=Dm(this,"forward",r,t);return s&&this.updateShapes(s),this}bringToFront(e){const t=typeof e[0]=="string"?e:e.map(s=>s.id),r=Dm(this,"toFront",t);return r&&this.updateShapes(r),this}collectShapesViaArrowBindings(e){const{initialShapes:t,resultShapes:r,resultBounds:s,bindings:i,visited:o}=e;for(const a of i)for(const l of[a.fromId,a.toId])if(!o.has(l)){const c=t.find(u=>u.id===l);if(c&&!o.has(c.id)){o.add(c.id);const u=this.getShapePageBounds(c);if(!u)continue;r.push(c),s.push(u),this.collectShapesViaArrowBindings({...e,bindings:this.getBindingsInvolvingShape(c,"arrow")})}}}flipShapes(e,t){if(this.getIsReadonly())return this;const r=typeof e[0]=="string"?e:e.map(l=>l.id),s=rt(r.map(l=>this.getShape(l)));for(const l of s)if(this.isShapeOfType(l,"group")){const c=rt(this.getSortedChildIdsForParent(l.id).map(u=>this.getShape(u)));s.push(...c)}const i=[],o=[];for(const l of s){const c=this.getShapeUtil(l);if(!c.canBeLaidOut(l,{type:"flip",shapes:s}))continue;const u=this.getShapePageBounds(l),h=this.getShapeGeometry(l).bounds,p=this.getShapePageTransform(l.id);u&&h&&p&&(i.push({shape:l,localBounds:h,pageTransform:p,isAspectRatioLocked:c.isAspectRatioLocked(l)}),o.push(u))}if(!i.length)return this;const a=Se.Common(o).center;return this.run(()=>{for(const{shape:l,localBounds:c,pageTransform:u,isAspectRatioLocked:h}of i)this.resizeShape(l.id,{x:t==="horizontal"?-1:1,y:t==="vertical"?-1:1},{initialBounds:c,initialPageTransform:u,initialShape:l,isAspectRatioLocked:h,mode:"scale_shape",scaleOrigin:a,scaleAxisRotation:0})}),this}stackShapes(e,t,r){var w,C;const s=r??this.options.adjacentShapeMargin,i=typeof e[0]=="string"?e:e.map(_=>_.id);if(this.getIsReadonly())return this;const o=rt(i.map(_=>this.getShape(_))),a=[],l=new Set;for(const _ of o){if(l.has(_.id))continue;l.add(_.id);const E=this.getShapePageBounds(_);if(!E||!((C=(w=this.getShapeUtil(_)).canBeLaidOut)!=null&&C.call(w,_,{type:"stack",shapes:o})))continue;const T=[_],A=[E];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(_.id,"arrow"),initialShapes:o,resultShapes:T,resultBounds:A,visited:l});const O=Se.Common(A);O&&a.push({shapes:T,pageBounds:O})}const c=a.length;if(s===0&&c<3||c<2)return this;let u,h,p,m;t==="horizontal"?(u="x",h="minX",p="maxX",m="width"):(u="y",h="minY",p="maxY",m="height");let S=0;if(s===0){const _={};a.sort((T,A)=>T.pageBounds[h]-A.pageBounds[h]);for(let T=0;T<c-1;T++){const A=a[T],D=a[T+1].pageBounds[h]-A.pageBounds[p];_[D]||(_[D]=0),_[D]++}let E=1;for(const[T,A]of Object.entries(_))A>E&&(E=A,S=parseFloat(T));if(E===1){let T=0;for(const[A,O]of Object.entries(_))S+=parseFloat(A)*O,T+=O;S/=T}}else S=s;const x=[];let v=a[0].pageBounds[p];for(let _=1;_<a.length;_++){const{shapes:E,pageBounds:T}=a[_],A=new k;A[u]=v+S-T[u];for(const O of E){const D=A.clone(),$=this.getShapeParent(O);if($){const H=this.getShapePageTransform($);H&&D.rot(-H.rotation())}D.add(O),x.push(this.getChangesToTranslateShape(O,D))}v+=T[m]+S}return this.updateShapes(x),this}packShapes(e,t){var T,A;if(this.getIsReadonly())return this;const r=t??this.options.adjacentShapeMargin,s=typeof e[0]=="string"?e:e.map(O=>O.id),i=rt(s.map(O=>this.getShape(O))),o=[],a=[],l=new Set;for(const O of i){if(l.has(O.id))continue;l.add(O.id);const D=this.getShapePageBounds(O);if(!D||!((A=(T=this.getShapeUtil(O)).canBeLaidOut)!=null&&A.call(T,O,{type:"pack",shapes:i})))continue;const $=[O],H=[D];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(O.id,"arrow"),initialShapes:i,resultShapes:$,resultBounds:H,visited:l});const G=Se.Common(H);G&&(o.push({shapes:$,pageBounds:G,nextPageBounds:G.clone()}),a.push(G))}if(o.length<2)return this;let c=0;for(const{pageBounds:O}of o)c+=O.width*O.height;const u=Se.Common(a),h=u.width;o.sort((O,D)=>O.pageBounds.width-D.pageBounds.width).sort((O,D)=>O.pageBounds.height-D.pageBounds.height);const p=Math.max(Math.ceil(Math.sqrt(c/.95)),h),m=[new Se(u.x,u.y,p,1/0)];let S=0,x=0,v,w;for(const{nextPageBounds:O}of o)for(let D=m.length-1;D>=0;D--)if(v=m[D],!(O.width>v.width||O.height>v.height)){O.x=v.x,O.y=v.y,x=Math.max(x,O.maxY),S=Math.max(S,O.maxX),O.width===v.width&&O.height===v.height?(w=m.pop(),D<m.length&&(m[D]=w)):O.height===v.height?(v.x+=O.width+r,v.width-=O.width+r):O.width===v.width?(v.y+=O.height+r,v.height-=O.height+r):(m.push(new Se(v.x+(O.width+r),v.y,v.width-(O.width+r),O.height)),v.y+=O.height+r,v.height-=O.height+r);break}const C=Se.Common(o.map(O=>O.nextPageBounds)),_=k.Sub(u.center,C.center),E=[];for(const{shapes:O,pageBounds:D,nextPageBounds:$}of o){const H=k.Sub($.point,D.point).add(_);for(const G of O){const J=H.clone();if(this.getShapeParent(G)){const N=this.getShapeParentTransform(G);N&&J.rot(-N.rotation())}J.add(G),E.push(this.getChangesToTranslateShape(G,J))}}return E.length&&this.updateShapes(E),this}alignShapes(e,t){var u,h;if(this.getIsReadonly())return this;const r=typeof e[0]=="string"?e:e.map(p=>p.id),s=rt(r.map(p=>this.getShape(p))),i=[],o=[],a=new Set;for(const p of s){if(a.has(p.id))continue;a.add(p.id);const m=this.getShapePageBounds(p);if(!m||!((h=(u=this.getShapeUtil(p)).canBeLaidOut)!=null&&h.call(u,p,{type:"align",shapes:s})))continue;const S=[p],x=[m];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(p.id,"arrow"),initialShapes:s,resultShapes:S,resultBounds:x,visited:a});const v=Se.Common(x);v&&(i.push({shapes:S,pageBounds:v}),o.push(v))}if(i.length<2)return this;const l=Se.Common(o),c=[];return i.forEach(({shapes:p,pageBounds:m})=>{const S=new k;switch(t){case"top":{S.y=l.minY-m.minY;break}case"center-vertical":{S.y=l.midY-m.minY-m.height/2;break}case"bottom":{S.y=l.maxY-m.minY-m.height;break}case"left":{S.x=l.minX-m.minX;break}case"center-horizontal":{S.x=l.midX-m.minX-m.width/2;break}case"right":{S.x=l.maxX-m.minX-m.width;break}}for(const x of p){const v=S.clone(),w=this.getShapeParent(x);if(w){const C=this.getShapePageTransform(w);C&&v.rot(-C.rotation())}v.add(x),c.push(this.getChangesToTranslateShape(x,v))}}),this.updateShapes(c),this}distributeShapes(e,t){var _,E;if(this.getIsReadonly())return this;const r=typeof e[0]=="string"?e:e.map(T=>T.id),s=rt(r.map(T=>this.getShape(T))),i=[],o=new Set;for(const T of s){if(o.has(T.id))continue;o.add(T.id);const A=this.getShapePageBounds(T);if(!A||!((E=(_=this.getShapeUtil(T)).canBeLaidOut)!=null&&E.call(_,T,{type:"distribute",shapes:s})))continue;const O=[T],D=[A];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(T.id,"arrow"),initialShapes:s,resultShapes:O,resultBounds:D,visited:o});const $=Se.Common(D);$&&i.push({shapes:O,pageBounds:$})}if(i.length<3)return this;let a,l,c,u;t==="horizontal"?(a="x",l="minX",c="maxX",u="width"):(a="y",l="minY",c="maxY",u="height");const h=[],p=i.sort((T,A)=>T.pageBounds[l]-A.pageBounds[l])[0],m=i.sort((T,A)=>A.pageBounds[c]-T.pageBounds[c])[0];if(p===m){const T=new Set(p.shapes.map(A=>A.id));return this.distributeShapes(r.filter(A=>!T.has(A)),t)}const S=i.filter(T=>T!==p&&T!==m).sort((T,A)=>T.pageBounds[l]===A.pageBounds[l]?T.shapes[0].id<A.shapes[0].id?-1:1:T.pageBounds[l]-A.pageBounds[l]),x=p.pageBounds[c],v=m.pageBounds[l]-x,w=S.reduce((T,A)=>T+A.pageBounds[u],0),C=(v-w)/(S.length+1);for(let T=x+C,A=0;A<S.length;A++){const{shapes:O,pageBounds:D}=S[A],$=new k;$[a]=T-D[a],T+D[u]>m.pageBounds[c]-1&&($[a]=m.pageBounds[c]-D[c]-1);for(const H of O){const G=$.clone(),J=this.getShapeParent(H);if(J){const L=this.getShapePageTransform(J);L&&G.rot(-L.rotation())}G.add(H),h.push(this.getChangesToTranslateShape(H,G))}T+=D[u]+C}return this.updateShapes(h),this}stretchShapes(e,t){var p,m;const r=typeof e[0]=="string"?e:e.map(S=>S.id);if(this.getIsReadonly())return this;const s=rt(r.map(S=>this.getShape(S))).filter(S=>{var x;return((x=this.getShapePageTransform(S))==null?void 0:x.rotation())%(wt/2)===0}),i=[],o=[],a=new Set;for(const S of s){if(a.has(S.id))continue;a.add(S.id);const x=this.getShapePageBounds(S);if(!x)continue;const v=[S],w=[x];if(!((m=(p=this.getShapeUtil(S)).canBeLaidOut)!=null&&m.call(p,S,{type:"stretch",shapes:s})))continue;this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(S.id,"arrow"),initialShapes:s,resultShapes:v,resultBounds:w,visited:a});const C=Se.Common(w);C&&(i.push({shapes:v,pageBounds:C}),o.push(C))}if(i.length<2)return this;const l=Se.Common(o);let c,u,h;return t==="horizontal"?(c="x",u="minX",h="width"):(c="y",u="minY",h="height"),this.run(()=>{i.forEach(({shapes:S,pageBounds:x})=>{const v=new k;v[c]=l[u]-x[u];const w=x.center.clone();w[c]=l[u];const C=new k(1,1);C[c]=l[h]/x[h];for(const _ of S){const E=v.clone(),T=this.getShapeParentTransform(_);T&&v.rot(-T.rotation()),E.add(_);const A=this.getChangesToTranslateShape(_,E);this.updateShape(A),this.resizeShape(_.id,C,{initialBounds:this.getShapeGeometry(_).bounds,scaleOrigin:w,isAspectRatioLocked:this.getShapeUtil(_).isAspectRatioLocked(_),scaleAxisRotation:0})}})}),this}resizeShape(e,t,r={}){var S,x,v;const s=typeof e=="string"?e:e.id;if(this.getIsReadonly())return this;Number.isFinite(t.x)||(t=new k(1,t.y)),Number.isFinite(t.y)||(t=new k(t.x,1));const i=r.initialShape??this.getShape(s);if(!i)return this;const o=r.scaleOrigin??((S=this.getShapePageBounds(s))==null?void 0:S.center);if(!o)return this;const a=r.initialPageTransform?he.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(i).isAspectRatioLocked(i);if(!oF(l,c))return this._resizeUnalignedShape(s,t,{...r,initialBounds:u,scaleOrigin:o,scaleAxisRotation:c,initialPageTransform:a,isAspectRatioLocked:h,initialShape:i});const p=this.getShapeUtil(i);h&&(Math.abs(t.x)>Math.abs(t.y)?t=new k(t.x,Math.sign(t.y)*Math.abs(t.x)):t=new k(Math.sign(t.x)*Math.abs(t.y),t.y));let m=!1;if(p.onResize&&p.canResize(i)){const w=this._scalePagePoint(he.applyToPoint(a,new k(0,0)),o,t,c),C=this.getPointInParentSpace(i.id,w),_=new k(t.x,t.y),E=_a((l-c)%Math.PI,0);_.x=E?t.x:t.y,_.y=E?t.y:t.x;const T=he.applyToPoint(a,new k),{x:A,y:O}=this.getPointInParentSpace(i.id,T);let D=i;r.skipStartAndEndCallbacks||(D=Po(i,((x=p.onResizeStart)==null?void 0:x.call(p,i))??void 0));const $=p.onResize({...i,x:A,y:O},{newPoint:C,handle:r.dragHandle??"bottom_right",mode:r.mode??"scale_shape",scaleX:_.x,scaleY:_.y,initialBounds:u,initialShape:i});$&&(m=!0),D=Po(D,{id:s,type:i.type,x:C.x,y:C.y,...$}),r.skipStartAndEndCallbacks||(D=Po(D,((v=p.onResizeEnd)==null?void 0:v.call(p,i,D))??void 0)),this.updateShapes([D])}if(!m){const w=he.applyToPoint(a,u.center),C=this._scalePagePoint(w,o,t,c),_=this.getPointInParentSpace(i.id,w),E=this.getPointInParentSpace(i.id,C),T=k.Sub(E,_);this.updateShapes([{id:s,type:i.type,x:i.x+T.x,y:i.y+T.y}])}return this}_scalePagePoint(e,t,r,s){const i=k.RotWith(e,t,-s).sub(t),o=k.MulV(i,r);return k.Add(o,t).rotWith(t,s)}_resizeUnalignedShape(e,t,r){const{type:s}=r.initialShape,i=new k(t.x,t.y);if(Math.abs(t.x)>Math.abs(t.y)?i.x=Math.sign(t.x)*Math.abs(t.y):i.y=Math.sign(t.y)*Math.abs(t.x),this.resizeShape(e,i,{initialShape:r.initialShape,initialBounds:r.initialBounds,isAspectRatioLocked:r.isAspectRatioLocked}),Math.sign(t.x)*Math.sign(t.y)<0){let{rotation:v}=he.Decompose(r.initialPageTransform);v-=2*v,this.updateShapes([{id:e,type:s,rotation:v}])}const o=he.applyToPoint(r.initialPageTransform,r.initialBounds.center),a=this._scalePagePoint(o,r.scaleOrigin,t,r.scaleAxisRotation),l=this.getShapePageBounds(e),c=this.getShapePageTransform(e),u=l.center,h=c.point();if(!u||!h)return this;const p=k.Sub(a,u),m=k.Add(h,p),{x:S,y:x}=this.getPointInParentSpace(e,m);return this.updateShapes([{id:e,type:s,x:S,y:x}]),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 t=this.getCurrentPageShapeIds();if(e.length+t.size>this.options.maxShapesPerPage)return Lm(this),this;const s=this.getFocusedGroupId();return this.run(()=>{var u,h;const i=this.getCurrentPageShapesSorted(),o=e.map(p=>{if(p.id||(p={id:Dt(),...p}),!p.parentId||!(this.store.has(p.parentId)||e.some(m=>m.id===p.parentId))){let m=this.getFocusedGroupId();for(let x=i.length-1;x>=0;x--){const v=i[x];if(!this.isShapeHidden(v)&&this.getShapeUtil(v).canReceiveNewChildrenOfType(v,p.type)&&this.isPointInShape(v,{x:p.x??0,y:p.y??0},{margin:0,hitInside:!0})){m=v.id;break}}const S=p.parentId;if(m===p.id&&(m=s),m!==S&&(p={...p},p.parentId=m,ws(m))){const x=this.getPointInShapeSpace(this.getShape(m),{x:p.x??0,y:p.y??0});p.x=x.x,p.y=x.y,p.rotation=-this.getShapePageTransform(m).rotation()+(p.rotation??0)}}return p}),a=new Map,l=[],{opacityForNextShape:c}=this.getInstanceState();for(const p of o){const m=this.getShapeUtil(p);let S=p.index;if(!S){const C=p.parentId??s;a.has(C)||a.set(C,this.getHighestIndexForParent(C)),S=a.get(C),a.set(C,Ro(S))}const x=m.getDefaultProps();for(const[C,_]of this.styleProps[p.type])x[_]=this.getStyleForNextShape(C);let v=this.store.schema.types.shape.create({...p,index:S,opacity:p.opacity??c,parentId:p.parentId??s,props:"props"in p?{...x,...p.props}:x});if(v.index===void 0)throw Error("no index!");const w=(h=(u=this.getShapeUtil(v)).onBeforeCreate)==null?void 0:h.call(u,v);w&&(v=w),l.push(v)}l.forEach(p=>{p.meta={...this.getInitialMetaForShape(p),...p.meta}}),this.store.put(l)}),this}animateShape(e,t={animation:fC}){return this.animateShapes([e],t)}animateShapes(e,t={animation:fC}){if(!t.animation)return this;const{duration:r=500,easing:s=Hn.linear}=t.animation,i=_t();let o=r,a;const l=[];let c,u;for(let p=0,m=e.length;p<m;p++){if(c=e[p],!c)continue;const S=this.getShape(c.id);S&&(u={start:Xt(S),end:Po(Xt(S),c)},l.push(u),this.animatingShapes.set(S.id,i))}const h=p=>{var v,w;if(o-=p,o<0){const{animatingShapes:C}=this,_=e.filter(E=>E&&C.get(E.id)===i);_.length&&this.updateShapes(_),this.off("tick",h);return}a=s(1-o/r);const{animatingShapes:m}=this,S=[];let x;for(let C=0,_=l.length;C<_;C++){const{start:E,end:T}=l[C];x=m.get(E.id),x===i&&S.push({...T,x:E.x+(T.x-E.x)*a,y:E.y+(T.y-E.y)*a,opacity:E.opacity+(T.opacity-E.opacity)*a,rotation:E.rotation+(T.rotation-E.rotation)*a,props:((w=(v=this.getShapeUtil(T)).getInterpolatedProps)==null?void 0:w.call(v,E,T,a))??T.props})}this._updateShapes(S)};return this.on("tick",h),this}groupShapes(e,t={}){var S;const{groupId:r=Dt(),select:s=!0}=t;if(!Array.isArray(e))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getIsReadonly())return this;const i=typeof e[0]=="string"?e:e.map(x=>x.id);if(i.length<=1)return this;const o=rt((this._shouldIgnoreShapeLock?i:this._getUnlockedShapeIds(i)).map(x=>this.getShape(x))),a=o.sort(nr).map(x=>x.id),l=Se.Common(rt(o.map(x=>this.getShapePageBounds(x)))),{x:c,y:u}=l.point,h=this.findCommonAncestor(o)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const p=o.filter(x=>x.parentId===h).sort(nr),m=(S=p[p.length-1])==null?void 0:S.index;return this.run(()=>{this.createShapes([{id:r,type:"group",parentId:h,index:m,x:c,y:u,opacity:1,props:{}}]),this.reparentShapes(a,r),s&&this.select(r)}),this}ungroupShapes(e,t={}){if(this.getIsReadonly())return this;const{select:r=!0}=t,s=typeof e[0]=="string"?e:e.map(l=>l.id),i=rt((this._shouldIgnoreShapeLock?s:this._getUnlockedShapeIds(s)).map(l=>this.getShape(l)));if(i.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const o=new Set,a=[];return i.forEach(l=>{this.isShapeOfType(l,"group")?a.push(l):o.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 p=0,m=h.length;p<m;p++)o.add(h[p]);this.reparentShapes(h,l.parentId,l.index)}this.deleteShapes(a.map(c=>c.id)),r&&this.select(...o)}),this)}updateShape(e){return this.updateShapes([e]),this}updateShapes(e){const t=Array(e.length);for(let r=0,s=e.length;r<s;r++){const i=e[r];if(!i)continue;const o=this.getShape(i.id);if(o){if(!this._shouldIgnoreShapeLock){if(o.isLocked){if(!(Object.hasOwn(i,"isLocked")&&!i.isLocked))continue}else if(this.isShapeOrAncestorLocked(o))continue}this.animatingShapes.delete(i.id),t.push(i)}}return this._updateShapes(t),this}_updateShapes(e){this.getIsReadonly()||this.run(()=>{var i,o;const t=[];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=Po(r,c),s!==r&&(s=((o=(i=this.getShapeUtil(r)).onBeforeUpdate)==null?void 0:o.call(i,r,s))??s,t.push(s))))}this.store.put(t)})}_getUnlockedShapeIds(e){return e.filter(t=>{var r;return!((r=this.getShape(t))!=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 t=typeof e[0]=="string"?e:e.map(i=>i.id),r=this._shouldIgnoreShapeLock?t:this._getUnlockedShapeIds(t);if(r.length===0)return this;const s=new Set(r);for(const i of r)this.visitDescendants(i,o=>{s.add(o)});return this.run(()=>this.store.remove([...s]))}deleteShape(e){return this.deleteShapes([typeof e=="string"?e:e.id]),this}_extractSharedStyles(e,t){if(this.isShapeOfType(e,"group")){const r=this._parentIdsToChildIds.get()[e.id];if(!r)return;for(let s=0,i=r.length;s<i;s++)this._extractSharedStyles(this.getShape(r[s]),t)}else for(const[r,s]of this.styleProps[e.type])t.applyValue(r,bn(e.props,s))}_getSelectionSharedStyles(){const e=this.getSelectedShapes(),t=new wk;for(const r of e)this._extractSharedStyles(r,t);return t}getStyleForNextShape(e){const t=this.getInstanceState().stylesForNextShape[e.id];return t===void 0?e.defaultValue:t}getShapeStyleIfExists(e,t){const r=this.styleProps[e.type].get(t);if(r!==void 0)return bn(e.props,r)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const e=this.root.getCurrent(),t=new wk;if(!e)return t;if(e.shapeType)if(e.shapeType==="frame"&&!this.getShapeUtil("frame").options.showColors)for(const r of this.styleProps[e.shapeType].keys())r.id!=="tldraw:color"&&t.applyValue(r,this.getStyleForNextShape(r));else for(const r of this.styleProps[e.shapeType].keys())t.applyValue(r,this.getStyleForNextShape(r));return t}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const e=[],t=s=>{const i=this.getShape(s);if(i)if(this.isShapeOfType(i,"group"))for(const o of this.getSortedChildIdsForParent(i.id))t(o);else e.push(i)};for(const s of this.getSelectedShapeIds())t(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,t){return this.updateInstanceState({opacityForNextShape:e},t),this}setOpacityForSelectedShapes(e){const t=this.getSelectedShapes();if(t.length>0){const r=[],s=i=>{if(this.isShapeOfType(i,"group")){const o=this.getSortedChildIdsForParent(i);for(const a of o)s(this.getShape(a))}else r.push(i)};for(const i of t)s(i);this.updateShapes(r.map(i=>({id:i.id,type:i.type,opacity:e})))}return this}setStyleForNextShapes(e,t,r){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[e.id]:t}},r),this}setStyleForSelectedShapes(e,t){const r=this.getSelectedShapes();if(r.length>0){const s=[],i=o=>{if(this.isShapeOfType(o,"group")){const a=this.getSortedChildIdsForParent(o.id);for(const l of a)i(this.getShape(l))}else{const a=this.getShapeUtil(o),l=this.styleProps[o.type].get(e);if(l){const c={id:o.id,type:o.type,props:{[l]:t}};s.push({util:a,originalShape:o,updatePartial:c})}}};for(const o of r)i(o);this.updateShapes(s.map(({updatePartial:o})=>o))}return this}registerExternalAssetHandler(e,t){return this.externalAssetContentHandlers[e]=t,this}createTemporaryAssetPreview(e,t){if(this.temporaryAssetPreview.has(e))return this.temporaryAssetPreview.get(e);const r=URL.createObjectURL(t);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 t,r;return await((r=(t=this.externalAssetContentHandlers)[e.type])==null?void 0:r.call(t,e))}hasExternalAssetHandler(e){return!!this.externalAssetContentHandlers[e]}registerExternalContentHandler(e,t){return this.externalContentHandlers[e]=t,this}async putExternalContent(e){var t,r;return(r=(t=this.externalContentHandlers)[e.type])==null?void 0:r.call(t,e)}getContentFromCurrentPage(e){const t=typeof e[0]=="string"?e:e.map(s=>s.id);if(!t||t.length===0)return;const r=this.getShapeAndDescendantIds(t);return tL(this,r,s=>{const i=[];for(const u of s){const h=this.getBinding(u);h&&i.push(h)}const o=[],a=[];for(const u of r){const h=this.getShape(u);if(!h)continue;if(!r.has(h.parentId)){const m=this.getShapePageTransform(h.id),S=m.point();a.push({...h,x:S.x,y:S.y,rotation:m.rotation(),parentId:this.getCurrentPageId()}),o.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 p=this.getAsset(h);p&&l.push(p)}return{schema:this.store.schema.serialize(),shapes:a,rootShapeIds:o,bindings:i,assets:l}})}async resolveAssetsInContent(e){if(!e)return;const t=[];return await Promise.allSettled(e.assets.map(async r=>{var s,i,o;if((r.type==="image"||r.type==="video")&&!((s=r.props.src)!=null&&s.startsWith("data:image"))&&!((i=r.props.src)!=null&&i.startsWith("data:video"))&&!((o=r.props.src)!=null&&o.startsWith("http"))){const a=Xt(r),l=await this.store.props.assets.resolve(r,{screenScale:1,steppedScreenScale:1,dpr:1,networkEffectiveType:null,shouldResolveToOriginal:!0});a.props.src=await Kr.blobToDataUrl(await Zi(l).then(c=>c.blob())),t.push(a)}else t.push(r)})),e.assets=t,e}putContentOntoCurrentPage(e,t={}){var H,G,J;if(this.getIsReadonly())return this;if(!e.schema)throw Error(`Could not put content:
|
|
210
|
-
content is missing a schema.`);const{select:r=!1,preserveIds:s=!1,preservePosition:i=!1}=t;let{point:o=void 0}=t;const a=this.getCurrentPageId(),{rootShapeIds:l}=e,c=[],u=[],h=[],p={store:{...Object.fromEntries(e.assets.map(L=>[L.id,L])),...Object.fromEntries(e.shapes.map(L=>[L.id,L])),...Object.fromEntries(((H=e.bindings)==null?void 0:H.map(L=>[L.id,L]))??[])},schema:e.schema},m=this.store.schema.migrateStoreSnapshot(p);if(m.type==="error")throw Error("Could not put content: could not migrate content");for(const L of Object.values(m.value))switch(L.typeName){case"asset":{c.push(L);break}case"shape":{u.push(L);break}case"binding":{h.push(L);break}}const S=new Map(s?u.map(L=>[L.id,L.id]):u.map(L=>[L.id,Dt()])),x=new Map(s?h.map(L=>[L.id,L.id]):h.map(L=>[L.id,Gc()]));let v=this.getCurrentPageId(),w=1/0,C=[];for(const L of this.getSelectedShapes()){if(w===0)break;const N=this.isShapeOfType(L,"frame"),U=this.getShapeAncestors(L);N&&U.push(L);const Y=N?U.length+1:U.length;if(Y<w)w=Y,C=U,v=N?L.id:L.parentId;else if(Y===w){if(C.length!==U.length)throw Error(`Ancestors: ${C.length} !== ${U.length}`);if(C.length===0){v=a;break}else{v=a;for(let W=0;W<C.length&&U[W]===C[W];W++)v=U[W].id}}}let _=!1;if(!Ss(v)){const L=this.getShape(v);if(L){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(L)))v=a;else if(l.length===1){const N=u.find(U=>U.id===l[0]);this.isShapeOfType(L,"frame")&&this.isShapeOfType(N,"frame")&&N.props.w===(L==null?void 0:L.props.w)&&N.props.h===(L==null?void 0:L.props.h)&&(_=!0)}}else v=a}_||(_=S.has(v)),_&&(v=this.getShape(v).parentId);let E=this.getHighestIndexForParent(v);const T=[],A=u.map(L=>{const N=S.get(L.id),U={...L,id:N};return l.includes(L.id)&&(U.parentId=a,T.push(U)),S.has(U.parentId)?U.parentId=S.get(L.parentId):(l.push(U.id),U.index=E,E=Ro(E)),U});if(A.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage)return Lm(this),this;const O=h.map(L=>({...L,id:zr(x.get(L.id)),fromId:zr(S.get(L.fromId)),toId:zr(S.get(L.toId))})),D=[],$=[];for(const L of c)this.store.has(L.id)||((L.type==="image"&&((G=L.props.src)!=null&&G.startsWith("data:image"))||L.type==="video"&&((J=L.props.src)!=null&&J.startsWith("data:video")))&&($.push(Xt(L)),L.props.src=null),D.push(L));return Promise.allSettled($.map(async L=>{const N=await Tie(L.props.src,L.props.name,L.props.mimeType??"image/png"),U=await this.getAssetForExternalContent({type:"file",file:N,assetId:L.id});if(!U){this.deleteAssets([L.id]);return}this.updateAssets([{...U,id:L.id}])})),this.run(()=>{D.length>0&&this.createAssets(D),this.createShapes(A),this.createBindings(O),r&&this.select(...T.map(W=>W.id)),v!==a&&this.reparentShapes(T.map(W=>W.id),v);const L=A.map(W=>this.getShape(W.id)),N=Se.Common(L.map(W=>this.getShapePageBounds(W)));if(o===void 0)if(Ss(v)){const W=this.getViewportPageBounds();i||W.includes(Se.From(N))?o=N.center:o=W.center}else{const W=this.getShape(v);o=he.applyToPoint(this.getShapePageTransform(W),this.getShapeGeometry(W).bounds.center)}if(T.length===1){const W=T[0];if(this.isShapeOfType(W,"frame"))for(;this.getShapesAtPoint(o).some(z=>this.isShapeOfType(z,"frame")&&z.props.w===W.props.w&&z.props.h===W.props.h);)o.x+=N.w+16}const U=Se.Common(rt(T.map(({id:W})=>this.getShapePageBounds(W)))).center,Y=k.Sub(o,U);this.updateShapes(T.map(({id:W})=>{const z=this.getShape(W),V=this.getShapeParentTransform(W).decompose().rotation,ee=k.Rot(Y,-V);return{id:z.id,type:z.type,x:z.x+ee.x,y:z.y+ee.y}}))}),this}async getSvgElement(e,t={}){const r=e.length===0?this.getCurrentPageShapeIdsSorted():typeof e[0]=="string"?e:e.map(s=>s.id);if(r.length!==0)return xie(this,r,t)}async getSvgString(e,t={}){const r=await this.getSvgElement(e,t);return r?{svg:new XMLSerializer().serializeToString(r.svg),width:r.width,height:r.height}:void 0}async getSvg(e,t={}){const r=await this.getSvgElement(e,t);if(r)return r.svg}async toImage(e,t={}){const r={format:"png",scale:1,pixelRatio:t.format==="svg"?void 0:2,...t},s=await this.getSvgString(e,r);if(!s)throw new Error("Could not create SVG");switch(r.format){case"svg":return{blob:new Blob([s.svg],{type:"image/svg+xml"}),width:s.width,height:s.height};case"jpeg":case"png":case"webp":{const i=await Iie(s.svg,{type:r.format,quality:r.quality,pixelRatio:r.pixelRatio,width:s.width,height:s.height});if(!i)throw new Error("Could not construct image.");return{blob:i,width:s.width,height:s.height}}default:An(r.format)}}_updateInputsFromEvent(e){const{pointerVelocity:t,previousScreenPoint:r,previousPagePoint:s,currentScreenPoint:i,currentPagePoint:o}=this.inputs,{screenBounds:a}=this.store.unsafeGetWithoutCapture($r),{x:l,y:c,z:u}=xm(()=>this.getCamera()),h=e.point.x-a.x,p=e.point.y-a.y,m=e.point.z??.5;r.setTo(i),s.setTo(o),i.set(h,p);const S=h/u-l,x=p/u-c;isFinite(S)&&isFinite(x)&&o.set(S,x,m),this.inputs.isPen=e.type==="pointer"&&e.isPen,(e.name==="pointer_down"||this.inputs.isPinching)&&(t.set(0,0),this.inputs.originScreenPoint.setTo(i),this.inputs.originPagePoint.setTo(o)),this.run(()=>{var v;this.store.put([{id:xS,typeName:"pointer",x:o.x,y:o.y,lastActivityTimestamp:e.type==="pointer"&&e.pointerId===Sj.CAMERA_MOVE?((v=this.store.unsafeGetWithoutCapture(xS))==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 Tse(this.store)}loadSnapshot(e,t){return Mz(this.store,e,t),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 t=this.getPage(e.pageId);t&&this.setCurrentPage(t),this._zoomToFitPageContentAt100Percent();return}case"shapes":{const t=rt(e.shapeIds.map(o=>this.getShape(o))),r={};for(const o of t){const a=this.getAncestorPageId(o);a&&(r[a]??(r[a]=[]),r[a].push(o))}const[s,i]=Object.entries(r).sort(([o,a],[l,c])=>c.length-a.length)[0]??["",[]];if(!s||!i.length)this._zoomToFitPageContentAt100Percent();else{this.setCurrentPage(s);const o=Se.Common(i.map(a=>this.getShapePageBounds(a)));this.zoomToBounds(o,{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:An(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(Oie(r))}catch(s){console.warn(s),this._zoomToFitPageContentAt100Percent()}return this}createDeepLink(e){const t=new URL((e==null?void 0:e.url)??window.location.href);return t.searchParams.set((e==null?void 0:e.param)??"d",Aie((e==null?void 0:e.to)??{type:"viewport",pageId:this.options.maxPages===1?void 0:this.getCurrentPageId(),bounds:this.getViewportPageBounds()})),t}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 t=ce("url with state",()=>{var l,c;const o=((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:o,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 o=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,o.toString())}),s=x0(o=>o(),(e==null?void 0:e.debounceMs)??500),i=Pi("update url on state change",()=>r(new URL(t.get()),this),{scheduleEffect:s});return()=>{i(),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:Pr(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:Pr(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:Pr(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:Pr(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 t=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const r of t)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;this.emit("before-event",e);const{inputs:t}=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,t.shiftKey=!0):!e.shiftKey&&t.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=this.timers.setTimeout(this._setShiftKeyTimeout,150)),e.altKey?(clearTimeout(this._altKeyTimeout),this._altKeyTimeout=-1,t.altKey=!0):!e.altKey&&t.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=this.timers.setTimeout(this._setAltKeyTimeout,150)),e.ctrlKey?(clearTimeout(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,t.ctrlKey=!0):!e.ctrlKey&&t.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=this.timers.setTimeout(this._setCtrlKeyTimeout,150)),e.metaKey?(clearTimeout(this._metaKeyTimeout),this._metaKeyTimeout=-1,t.metaKey=!0):!e.metaKey&&t.metaKey&&this._metaKeyTimeout===-1&&(this._metaKeyTimeout=this.timers.setTimeout(this._setMetaKeyTimeout,150));const{originPagePoint:s,currentPagePoint:i}=t;t.isPointing||(t.isDragging=!1);const o=this.store.unsafeGetWithoutCapture($r),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(t.isPinching)return;t.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=[...a.selectedShapeIds]),this._didPinch=!0,t.isPinching=!0,this.interrupt());return}case"pinch":{if(!t.isPinching)return;const{point:{z:c=1},delta:{x:u,y:h}}=e,{x:p,y:m}=k.SubXY(e.point,o.screenBounds.x,o.screenBounds.y);this.stopCameraAnimation(),o.followingUserId&&this.stopFollowingUser();const{x:S,y:x,z:v}=xm(()=>this.getCamera()),{panSpeed:w}=l;this._setCamera(new k(S+u*w/v-p/v+p/c,x+h*w/v-m/v+m/c,c),{immediate:!0});return}case"pinch_end":{if(!t.isPinching)return this;t.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(),o.followingUserId&&this.stopFollowingUser();const{x:p,y:m,z:S}=xm(()=>this.getCamera()),{x,y:v,z:w=0}=e.delta;let C=h;switch(t.ctrlKey&&(C=h==="pan"?"zoom":"pan"),C){case"zoom":{const{x:_,y:E}=this.inputs.currentScreenPoint;let T=w;h==="zoom"&&(Math.abs(v)>10?T=10*Math.sign(v)/100:T=v/100);const A=S+(T??0)*u*S;this._setCamera(new k(p+_/A-_/S,m+E/A-E/S,A),{immediate:!0}),this.maybeTrackPerformance("Zooming");return}case"pan":{this._setCamera(new k(p+x*c/S,m+v*c/S,S),{immediate:!0}),this.maybeTrackPerformance("Panning");return}}}break}case"pointer":{if(t.isPinching)return;this._updateInputsFromEvent(e);const{isPen:c}=e,{isPenMode:u}=o;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===vj&&(this.capturedPointerId=e.pointerId),t.buttons.add(e.button),t.isPointing=!0,t.isDragging=!1,!u&&c&&this.updateInstanceState({isPenMode:!0}),e.button===xj?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):e.button===Am&&(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:p,z:m}=xm(()=>this.getCamera());if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:S,previousScreenPoint:x}=this.inputs,{panSpeed:v}=l,w=k.Sub(S,x);this.setCamera(new k(h+w.x*v/m,p+w.y*v/m,m),{immediate:!0}),this.maybeTrackPerformance("Panning");return}t.isPointing&&!t.isDragging&&k.Dist2(s,i)*this.getZoomLevel()>(o.isCoarsePointer?this.options.coarseDragDistanceSquared:this.options.dragDistanceSquared)/m&&(t.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(t.isDragging=!1,t.isPointing=!1,clearTimeout(this._longPressTimeout),t.buttons.delete(e.button),o.isPenMode&&!c)return;if(this.capturedPointerId===e.pointerId&&(this.capturedPointerId=null,e.button=0),t.isPanning){t.keys.has("Space")||(t.isPanning=!1,t.isSpacebarPanning=!1);const h=this.inputs.pointerVelocity,p=Math.min(2,h.len());switch(e.button){case vj:{this.setCursor({type:"grab",rotation:0});break}case Am:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}p>0&&this.slideCamera({speed:p,direction:h})}else e.button===xj&&(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(t.keys.add(e.code),e.code==="Space"&&!e.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=o.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 k(0,-1);break}case"ArrowRight":{c=new k(1,0);break}case"ArrowDown":{c=new k(0,1);break}case"ArrowLeft":{c=new k(-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":{t.keys.delete(e.code),e.code==="Space"&&(this.inputs.buttons.has(Am)||(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(e.type==="pointer"){e.button===Am?e.name="middle_click":e.button===HE&&(e.name="right_click");const{isPenMode:c}=this.store.unsafeGetWithoutCapture($r);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){ln.measurePerformance.get()&&(this.performanceTracker.isStarted()?clearTimeout(this.performanceTrackerTimeout):this.performanceTracker.start(e),this.performanceTrackerTimeout=this.timers.setTimeout(()=>{this.performanceTracker.stop()},50))}}Ie=tae(Ck);_e(Ie,1,"getIsShapeHiddenCache",M6,ke);_e(Ie,1,"getCanUndo",T6,ke);_e(Ie,1,"getCanRedo",_6,ke);_e(Ie,1,"getPath",E6,ke);_e(Ie,1,"getCurrentTool",I6,ke);_e(Ie,1,"getCurrentToolId",k6,ke);_e(Ie,1,"getDocumentSettings",P6,ke);_e(Ie,1,"getInstanceState",C6,ke);_e(Ie,1,"getOpenMenus",b6,ke);_e(Ie,1,"getIsMenuOpen",w6,ke);_e(Ie,1,"getPageStates",x6,ke);_e(Ie,1,"_getPageStatesQuery",v6,ke);_e(Ie,1,"getCurrentPageState",S6,ke);_e(Ie,1,"_getCurrentPageStateId",y6,ke);_e(Ie,1,"getSelectedShapeIds",m6,ke);_e(Ie,1,"getSelectedShapes",g6,ke);_e(Ie,1,"getCurrentPageShapesInReadingOrder",p6,ke);_e(Ie,1,"getOnlySelectedShapeId",f6,ke);_e(Ie,1,"getOnlySelectedShape",h6,ke);_e(Ie,1,"getSelectionPageBounds",d6,ke);_e(Ie,1,"getSelectionRotation",u6,ke);_e(Ie,1,"getSelectionRotatedPageBounds",c6,ke);_e(Ie,1,"getSelectionRotatedScreenBounds",l6,ke);_e(Ie,1,"getFocusedGroupId",a6,ke);_e(Ie,1,"getFocusedGroup",o6,ke);_e(Ie,1,"getEditingShapeId",i6,ke);_e(Ie,1,"getEditingShape",s6,ke);_e(Ie,1,"getRichTextEditor",r6,ke);_e(Ie,1,"getHoveredShapeId",n6,ke);_e(Ie,1,"getHoveredShape",t6,ke);_e(Ie,1,"getHintingShapeIds",e6,ke);_e(Ie,1,"getHintingShape",QB,ke);_e(Ie,1,"getErasingShapeIds",JB,ke);_e(Ie,1,"getErasingShapes",ZB,ke);_e(Ie,1,"_unsafe_getCameraId",XB,ke);_e(Ie,1,"getCamera",YB,ke);_e(Ie,1,"getViewportPageBoundsForFollowing",GB,ke);_e(Ie,1,"getCameraForFollowing",qB,ke);_e(Ie,1,"getZoomLevel",VB,ke);_e(Ie,1,"getViewportScreenBounds",WB,ke);_e(Ie,1,"getViewportScreenCenter",KB,ke);_e(Ie,1,"getViewportPageBounds",HB,ke);_e(Ie,1,"_getCollaboratorsQuery",UB,ke);_e(Ie,1,"getCollaborators",BB,ke);_e(Ie,1,"getCollaboratorsOnCurrentPage",$B,ke);_e(Ie,1,"getRenderingShapes",zB,ke);_e(Ie,1,"_getAllPagesQuery",FB,ke);_e(Ie,1,"getPages",NB,ke);_e(Ie,1,"getCurrentPageId",LB,ke);_e(Ie,1,"getCurrentPageShapeIdsSorted",jB,ke);_e(Ie,1,"_getAllAssetsQuery",DB,ke);_e(Ie,1,"_getShapeHandlesCache",RB,ke);_e(Ie,1,"_getShapePageTransformCache",OB,ke);_e(Ie,1,"_getShapePageBoundsCache",AB,ke);_e(Ie,1,"_getShapeClipPathCache",MB,ke);_e(Ie,1,"_getShapeMaskCache",TB,ke);_e(Ie,1,"_getShapeMaskedPageBoundsCache",_B,ke);_e(Ie,1,"_notVisibleShapes",EB,ke);_e(Ie,1,"getCulledShapes",IB,ke);_e(Ie,1,"getCurrentPageBounds",kB,ke);_e(Ie,1,"getCurrentPageShapes",PB,ke);_e(Ie,1,"getCurrentPageShapesSorted",CB,ke);_e(Ie,1,"getCurrentPageRenderingShapesSorted",bB,ke);_e(Ie,1,"_getBindingsIndexCache",wB,ke);_e(Ie,1,"_getSelectionSharedStyles",xB,ke);_e(Ie,1,"getSharedStyles",vB,ke);_e(Ie,1,"getSharedOpacity",SB,ke);_e(Ie,1,"getIsFocused",yB,ke);_e(Ie,1,"getIsReadonly",mB,ke);_e(Ie,1,"_setShiftKeyTimeout",gB,ke);_e(Ie,1,"_setAltKeyTimeout",pB,ke);_e(Ie,1,"_setCtrlKeyTimeout",fB,ke);_e(Ie,1,"_setMetaKeyTimeout",hB,ke);rae(Ie,ke);function Lm(n,e=n.getCurrentPageId()){const t=n.getPage(e).name;n.emit("max-shapes",{name:t,pageId:e,count:n.options.maxShapesPerPage})}function Po(n,e){if(!e)return n;let t=null;const r=Object.entries(e);for(let s=0,i=r.length;s<i;s++){const[o,a]=r[s];if(a!==void 0&&!(o==="id"||o==="type"||o==="typeName")&&a!==n[o]){if(t||(t={...n}),o==="props"||o==="meta"){t[o]={...n[o]};for(const[l,c]of Object.entries(a))t[o][l]=c;continue}t[o]=a}}return t||n}function A6(n,e,t){const r=n.getShape(e);if(!r)return;t.push(r);const s=n.getSortedChildIdsForParent(e);for(let i=0,o=s.length;i<o;i++)A6(n,s[i],t)}function tL(n,e,t){let r;if(n.run(()=>{const s=n.store.extractingChanges(()=>{const i=new Set,o=new Set;for(const a of e)if(n.getShape(a))for(const c of n.getBindingsInvolvingShape(a)){const u=e.has(c.fromId),h=e.has(c.toId);if(u&&h){i.add(c.id);continue}(!u||!h)&&o.add(c.id)}n.deleteBindings([...o],{isolateShapes:!0});try{r=Fr.ok(t(i))}catch(a){r=Fr.err(a)}});n.store.applyDiff(ck(s),{runCallbacks:!1})},{history:"ignore"}),r.ok)return r.value;throw r.error}function nL(n,e){if(!e.constraints)throw Error("Should have constraints here");const{padding:{x:t,y:r}}=e.constraints,s=n.getViewportScreenBounds(),i=Se.From(e.constraints.bounds),o=(s.w-t*2)/i.w,a=(s.h-r*2)/i.h;return{zx:o,zy:a}}function eg(){const n=te(),e=Xp();return ie("isDarkMode",()=>(e==null?void 0:e.isDarkMode)??n.user.getIsDarkMode(),[e,n])}const rL="<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'/>",sL="<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'/>",Nm='<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 vl(n,e,t,r,s,i=16,o=16){const a=(-t-e)*(wt/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+t} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+n.replaceAll('"',"'")+`</g></svg>") ${i} ${o}, pointer`}const iae=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],oae={none:()=>"none","ew-resize":(n,e,t)=>vl(sL,n,0,e,t),"ns-resize":(n,e,t)=>vl(sL,n,90,e,t),"nesw-resize":(n,e,t)=>vl(rL,n,0,e,t),"nwse-resize":(n,e,t)=>vl(rL,n,90,e,t),"nwse-rotate":(n,e,t)=>vl(Nm,n,0,e,t),"nesw-rotate":(n,e,t)=>vl(Nm,n,90,e,t),"senw-rotate":(n,e,t)=>vl(Nm,n,180,e,t),"swne-rotate":(n,e,t)=>vl(Nm,n,270,e,t)};function $s(n,e=0,t="black"){return oae[n](FG(e),!1,t)}function aae(){const n=te(),e=kn(),t=eg();Hl("useCursor",()=>{const{type:r,rotation:s}=n.getInstanceState().cursor;if(iae.includes(r)){e.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}e.style.setProperty("--tl-cursor",$s(r,s,t?"white":"black"))},[n,e,t])}function lae(){const n=te(),e=kn(),t=eg(),r=ie(ln.forceSrgb);at.useEffect(()=>{t?(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")},[n,e,r,t])}function cae(){const[n,e]=P.useState(0);P.useEffect(()=>e(t=>t+1),[])}const uae=n=>n.props.src,dae={upload:async(n,e)=>({src:await Kr.blobToDataUrl(e)})};function hae(n){return"schema"in n&&n.schema?n.schema:Ute({shapes:"shapeUtils"in n&&n.shapeUtils?iL(Dz(n.shapeUtils)):void 0,bindings:"bindingUtils"in n&&n.bindingUtils?iL(Oz(n.bindingUtils)):void 0,migrations:"migrations"in n?n.migrations:void 0})}function Sp({initialData:n,defaultName:e="",id:t,assets:r=dae,onMount:s,collaboration:i,...o}={}){const a=hae(o),l=new EE({id:t,schema:a,initialData:n,props:{defaultName:e,assets:{upload:r.upload,resolve:r.resolve??uae,remove:r.remove??(()=>Promise.resolve())},onMount:c=>{Je(c instanceof ke),s==null||s(c)},collaboration:i}});if(o.snapshot){if(n)throw new Error("Cannot provide both initialData and snapshot");Mz(l,o.snapshot,{forceOverwriteSessionState:!0})}return l}function iL(n){return Object.fromEntries(n.map(e=>[e.type,{props:e.props,migrations:e.migrations}]))}function fae(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
211
|
-
|
|
212
|
-
Keep seeing this message?
|
|
213
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
214
|
-
• If your hard disk is full, try clearing up some space and then reload the page.`)}function pae(){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.
|
|
215
|
-
|
|
216
|
-
Keep seeing this message?
|
|
217
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const gae=350,mae=1e4,oL=Symbol("UPDATE_INSTANCE_STATE"),yae=n=>n;class Sae{constructor(e){R(this,"onmessage")}postMessage(e){}close(){}}const vae=typeof BroadcastChannel>"u"?Sae:BroadcastChannel;class xae{constructor(e,{persistenceKey:t,sessionId:r=IS,onLoad:s,onLoadError:i},o=new vae(`tldraw-tab-sync-${t}`)){R(this,"disposables",new Set);R(this,"diffQueue",[]);R(this,"didDispose",!1);R(this,"shouldDoFullDBWrite",!0);R(this,"isReloading",!1);R(this,"persistenceKey");R(this,"sessionId");R(this,"serializedSchema");R(this,"isDebugging",!1);R(this,"documentTypes");R(this,"$sessionStateSnapshot");R(this,"db");R(this,"initTime",Date.now());R(this,"isPersisting",!1);R(this,"didLastWriteError",!1);R(this,"scheduledPersistTimeout",null);this.store=e,this.channel=o,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=t,this.sessionId=r,this.db=new dS(t),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=JE(this.store),this.disposables.add(e.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(yae({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(oL),this.schedulePersist()},{scope:"session"})),this.connect(s,i),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(a=>a.scope==="document").map(a=>a.typeName))}debug(...e){this.isDebugging&&console.debug(...e)}async connect(e,t){this.debug("connecting");let r;try{r=await this.db.load({sessionId:this.sessionId})}catch(s){t(s),pae();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])),i=r.sessionStateSnapshot??_se(s),o=this.store.schema.migrateStoreSnapshot({store:s,schema:r.schema??this.store.schema.serializeEarliestVersion()});if(o.type==="error"){console.error("failed to migrate store",o),t(new Error(`Failed to migrate store: ${o.reason}`));return}const a=Object.values(o.value).filter(l=>this.documentTypes.has(l.typeName));a.length>0&&this.store.mergeRemoteChanges(()=>{this.store.put(a,"initialize")}),i&&Sk(this.store,i,{forceOverwrite:!0})}this.channel.onmessage=({data:s})=>{var a,l;this.debug("got message",s);const i=s,o=this.store.schema.getMigrationsSince(i.schema);if(o.ok){if(o.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){t(new Error("Schema mismatch, please close other tabs and reload the page"));return}this.debug("reloading"),this.isReloading=!0,(l=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||l.call(a);return}i.type==="diff"&&(this.debug("applying diff"),Vs(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(i.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;t(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?mae:gae))}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(Je(!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 t=IE(e.filter(r=>r!==oL));await this.db.storeChanges({changes:t,schema:this.store.schema,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(t){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",t),fae(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function O6(n){const e=P.useRef(n),[t,r]=P.useState(n);t!==e.current&&r(e.current);const s=P.useCallback(i=>{typeof i=="function"?e.current=i(e.current):e.current=i,r(e.current)},[]);return[t,s]}function wae(n){const[e,t]=O6({status:"loading"});return n=dh(n),P.useEffect(()=>{const{persistenceKey:r,sessionId:s,...i}=n;if(!r){t({status:"not-synced",store:Sp(i)});return}t({status:"loading"});const o=new qo,a={upload:async(h,p)=>(await u.db.storeAsset(h.id,p),{src:h.id}),resolve:async h=>h.props.src?h.props.src.startsWith("asset:")?await o.get(h,async()=>{const p=await u.db.getAsset(h.id);return p?URL.createObjectURL(p):null}):h.props.src:null,remove:async h=>{await u.db.removeAssets(h)},...i.assets},l=Sp({...i,assets:a});let c=!1;const u=new xae(l,{sessionId:s,persistenceKey:r,onLoad(){c||t({store:l,status:"synced-local"})},onLoadError(h){c||t({status:"error",error:h})}});return()=>{c=!0,u.close()}},[n,t]),e}function bae(){const n=te(),e=kn();P.useEffect(()=>{const t=i=>e.style.setProperty("--tl-zoom",i.toString()),r=x0(t,100),s=new mu("useZoomCss",()=>{n.getCurrentPageShapeIds().size<300?t(n.getZoomLevel()):r(n.getZoomLevel())});return s.attach(),s.execute(),()=>{s.detach(),r.cancel()}},[n,e])}function Pk(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let r=0,s=n.length;r<s;r++)t[r]=n.charCodeAt(r);return e}function Cae(n){const e=atob(n),t=Pk(e);return crypto.subtle.importKey("spki",new Uint8Array(t),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}const Pae=5,If={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8},kae=Math.max(...Object.values(If)),Ef={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},Iae=Object.keys(Ef).length,kC="sales@tldraw.com",Eae=`${_n()}/watermarks/watermark-track.svg`;class cv{constructor(e,t,r){R(this,"publicKey","MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ");R(this,"isDevelopment");R(this,"isTest");R(this,"isCryptoAvailable");R(this,"state",Sn("license state","pending"));R(this,"verbose",!0);this.isTest=!1,this.isDevelopment=this.getIsDevelopment(r),this.publicKey=t||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(e).then(s=>{const i=_ae(s);!this.isDevelopment&&i&&Zi(Eae),i?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:"||window.location.hostname==="localhost"}async extractLicenseKey(e){const[t,r]=e.split("."),[s,i]=t.split("/");if(!s.startsWith("tldraw-"))throw new Error(`Unsupported prefix '${s}'`);const o=await Cae(this.publicKey);let a;try{a=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,new Uint8Array(Pk(atob(r))),new Uint8Array(Pk(atob(i))))}catch(c){throw console.error(c),new Error("Could not perform signature validation")}if(!a)throw new Error("Invalid signature");let l;try{l=JSON.parse(atob(i))}catch{throw new Error("Could not parse object")}return l.length>Iae&&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[Ef.ID],hosts:l[Ef.HOSTS],flags:l[Ef.FLAGS],expiryDate:l[Ef.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 t=e.replace(/[\u200B-\u200D\uFEFF]/g,"");t=t.replace(/\r?\n|\r/g,"");try{const r=await this.extractLicenseKey(t),s=new Date(r.expiryDate),i=this.isFlagEnabled(r.flags,If.ANNUAL_LICENSE),o=this.isFlagEnabled(r.flags,If.PERPETUAL_LICENSE),a={license:r,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(r),expiryDate:s,isAnnualLicense:i,isAnnualLicenseExpired:i&&this.isAnnualLicenseExpired(s),isPerpetualLicense:o,isPerpetualLicenseExpired:o&&this.isPerpetualLicenseExpired(s),isInternalLicense:this.isFlagEnabled(r.flags,If.INTERNAL_LICENSE),isLicensedWithWatermark:this.isFlagEnabled(r.flags,If.WITH_WATERMARK)};return this.outputLicenseInfoIfNeeded(a),a}catch(r){return this.outputInvalidLicenseKey(r.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(e){const t=window.location.hostname.toLowerCase();return e.hosts.some(r=>{const s=r.toLowerCase().trim();if(s===t||`www.${s}`===t||s===`www.${t}`||r==="*")return!0;if(r.includes("*")){const i=new RegExp(r.replace(/\*/g,".*?"));return i.test(t)||i.test(`www.${t}`)}return!1})}getExpirationDateWithoutGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}getExpirationDateWithGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+Pae+1)}isAnnualLicenseExpired(e){const t=this.getExpirationDateWithGracePeriod(e),r=new Date>=t;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 ${kC} if you would like to renew your license.`]),r}isPerpetualLicenseExpired(e){const t=this.getExpirationDateWithGracePeriod(e),r={major:new Date(mj.major),minor:new Date(mj.minor)};return r.major>=t||r.minor>=t}isFlagEnabled(e,t){return(e&t)===t}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 ${kC} to renew.`]),!e.isDomainValid&&!e.isDevelopment&&this.outputMessages(["This tldraw license key is not valid for this domain!",`Please reach out to ${kC} if you would like to use tldraw on other domains.`]),e.license.flags>=kae*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 t of e)console.log(`%c${t}`,"color: white; background: crimson; padding: 2px; border-radius: 3px;");this.outputDelimiter()}}outputDelimiter(){console.log("%c-------------------------------------------------------------------","color: white; background: crimson; padding: 2px; border-radius: 3px;")}}R(cv,"className","tl-watermark_SEE-LICENSE");function _ae(n){if(!n.isLicenseParseable||!n.isDomainValid&&!n.isDevelopment)return!0;if(n.isPerpetualLicenseExpired||n.isAnnualLicenseExpired){if(n.isInternalLicense)throw new Error("License: Internal license expired.");return!0}return!1}const R6=P.createContext({}),Tae=()=>P.useContext(R6);function Mae({licenseKey:n,children:e}){const[t]=P.useState(()=>new cv(n));return g.jsx(R6.Provider,{value:t,children:e})}function Ga(n){if(!n)throw Error("usePassThroughWheelEvents must be passed a ref");const e=kn();P.useEffect(()=>{function t(s){if(s.isSpecialRedispatchedEvent)return;const i=n.current;if(i&&i.scrollHeight>i.clientHeight)return;tt(s);const o=e.querySelector(".tl-canvas");if(!o)return;const a=new WheelEvent("wheel",s);a.isSpecialRedispatchedEvent=!0,o.dispatchEvent(a)}const r=n.current;if(r)return r.addEventListener("wheel",t,{passive:!1}),()=>{r.removeEventListener("wheel",t)}},[e,n])}const Aae='<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>',Oae='<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 Rae(n){return ie("watermarkState",()=>n.state.get(),[n])}const Dae=`data:image/svg+xml;utf8,${encodeURIComponent(Aae)}`,jae=`data:image/svg+xml;utf8,${encodeURIComponent(Oae)}`,Lae=P.memo(function(){const e=Tae(),t=te(),r=ie("is mobile",()=>t.getViewportScreenBounds().width<700,[t]),s=Rae(e);return["licensed-with-watermark","unlicensed"].includes(s)?g.jsxs(g.Fragment,{children:[g.jsx(Fae,{}),g.jsx(Nae,{src:r?jae:Dae})]}):null}),Nae=P.memo(function({src:e}){const t=te(),r=ie("debug mode",()=>t.getInstanceState().isDebugMode,[t]),s=ie("is mobile",()=>t.getViewportScreenBounds().width<700,[t]),i=KE(),o=P.useRef(null);Ga(o);const a=`url('${e}') center 100% / 100% no-repeat`,l="https://tldraw.dev/?utm_source=dotcom&utm_medium=organic&utm_campaign=watermark";return g.jsx("div",{ref:o,className:cv.className,"data-debug":r,"data-mobile":s,draggable:!1,...i,children:g.jsx("button",{draggable:!1,role:"button",onPointerDown:c=>{Wt(c),tt(c)},title:"made with tldraw",onClick:()=>J0.openWindow(l,"_blank"),style:{mask:a,WebkitMask:a}})})}),Fae=P.memo(function(){const e=te(),t=cv.className,r=`/* ------------------- SEE LICENSE -------------------
|
|
218
|
-
The tldraw watermark is part of tldraw's license. It is shown for unlicensed
|
|
219
|
-
or "licensed-with-watermark" users. By using this library, you agree to
|
|
220
|
-
preserve the watermark's behavior, keeping it visible, unobscured, and
|
|
221
|
-
available to user-interaction.
|
|
222
|
-
|
|
223
|
-
To remove the watermark, please purchase a license at tldraw.dev.
|
|
224
|
-
*/
|
|
225
|
-
|
|
226
|
-
.${t} {
|
|
227
|
-
position: absolute;
|
|
228
|
-
bottom: var(--space-2);
|
|
229
|
-
right: var(--space-2);
|
|
230
|
-
width: 96px;
|
|
231
|
-
height: 32px;
|
|
232
|
-
display: flex;
|
|
233
|
-
align-items: center;
|
|
234
|
-
justify-content: center;
|
|
235
|
-
z-index: var(--layer-watermark) !important;
|
|
236
|
-
background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
|
|
237
|
-
opacity: 1;
|
|
238
|
-
border-radius: 5px;
|
|
239
|
-
pointer-events: all;
|
|
240
|
-
padding: 2px;
|
|
241
|
-
box-sizing: content-box;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.${t} > button {
|
|
245
|
-
position: absolute;
|
|
246
|
-
width: 96px;
|
|
247
|
-
height: 32px;
|
|
248
|
-
pointer-events: all;
|
|
249
|
-
cursor: inherit;
|
|
250
|
-
color: var(--color-text);
|
|
251
|
-
opacity: .38;
|
|
252
|
-
border: 0;
|
|
253
|
-
padding: 0;
|
|
254
|
-
background-color: currentColor;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.${t}[data-debug='true'] {
|
|
258
|
-
bottom: 46px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.${t}[data-mobile='true'] {
|
|
262
|
-
border-radius: 4px 0px 0px 4px;
|
|
263
|
-
right: -2px;
|
|
264
|
-
width: 8px;
|
|
265
|
-
height: 48px;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.${t}[data-mobile='true'] > button {
|
|
269
|
-
width: 8px;
|
|
270
|
-
height: 32px;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
@media (hover: hover) {
|
|
274
|
-
.${t} > button {
|
|
275
|
-
pointer-events: none;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.${t}:hover {
|
|
279
|
-
background-color: var(--color-background);
|
|
280
|
-
transition: background-color 0.2s ease-in-out;
|
|
281
|
-
transition-delay: 0.32s;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.${t}:hover > button {
|
|
285
|
-
animation: delayed_link 0.2s forwards ease-in-out;
|
|
286
|
-
animation-delay: 0.32s;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.${t} > button:focus-visible {
|
|
290
|
-
opacity: 1;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
@keyframes delayed_link {
|
|
296
|
-
0% {
|
|
297
|
-
cursor: inherit;
|
|
298
|
-
opacity: .38;
|
|
299
|
-
pointer-events: none;
|
|
300
|
-
}
|
|
301
|
-
100% {
|
|
302
|
-
cursor: pointer;
|
|
303
|
-
opacity: 1;
|
|
304
|
-
pointer-events: all;
|
|
305
|
-
}
|
|
306
|
-
}`;return g.jsx("style",{nonce:e.options.nonce,children:r})}),zae=[],$ae=[],Bae=[],Uae="tl-container",Hae=P.memo(function({store:e,components:t,className:r,user:s,options:i,...o}){const[a,l]=P.useState(null),c=P.useMemo(()=>s??Ez(),[s]),u=(t==null?void 0:t.ErrorFallback)===void 0?Sz:t==null?void 0:t.ErrorFallback,h={...o,shapeUtils:o.shapeUtils??zae,bindingUtils:o.bindingUtils??$ae,tools:o.tools??Bae,components:t,options:dh(i)};return g.jsx("div",{ref:l,"data-tldraw":W4,draggable:!1,className:$e(`${Uae} tl-theme__light`,r),onPointerDown:Wt,tabIndex:-1,role:"application",children:g.jsx(yp,{fallback:u,onError:p=>bI(p,{tags:{origin:"react.tldraw-before-app"}}),children:a&&g.jsx(Mae,{licenseKey:o.licenseKey,children:g.jsx(X4,{container:a,children:g.jsx(fse,{overrides:t,children:e?e instanceof EE?g.jsx(j6,{...h,store:e,user:c}):g.jsx(D6,{...h,store:e,user:c}):g.jsx(Kae,{...h,store:e,user:c})})})})})})});function Kae(n){const{defaultName:e,snapshot:t,initialData:r,shapeUtils:s,bindingUtils:i,persistenceKey:o,sessionId:a,user:l,assets:c,migrations:u}=n,h=wae({shapeUtils:s,bindingUtils:i,initialData:r,persistenceKey:o,sessionId:a,defaultName:e,snapshot:t,assets:c,migrations:u});return g.jsx(D6,{...n,store:h,user:l})}const D6=P.memo(function({store:e,user:t,...r}){const s=kn();P.useLayoutEffect(()=>{t.userPreferences.get().colorScheme==="dark"&&(s.classList.remove("tl-theme__light"),s.classList.add("tl-theme__dark"))},[s,t]);const{LoadingScreen:i}=Zt();switch(e.status){case"error":throw e.error;case"loading":return i?g.jsx(i,{}):null}return g.jsx(j6,{...r,store:e.store,user:t})}),IC=()=>document.location.search.includes("tldraw_preserve_focus");function j6({onMount:n,children:e,store:t,tools:r,shapeUtils:s,bindingUtils:i,user:o,initialState:a,autoFocus:l=!0,inferDarkMode:c,cameraOptions:u,textOptions:h,options:p,licenseKey:m,deepLinks:S,isShapeHidden:x,getShapeVisibility:v,assetUrls:w}){const{ErrorFallback:C}=Zt(),_=kn(),[E,T]=O6(null),A=P.useRef(null),O=dh(S===!0?{}:S),D=P.useRef({autoFocus:l&&!IC(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:O});P.useLayoutEffect(()=>{D.current={autoFocus:l&&!IC(),inferDarkMode:c,initialState:a,cameraOptions:u,deepLinks:O}},[l,c,a,u,O]),P.useLayoutEffect(()=>{const{autoFocus:U,inferDarkMode:Y,initialState:W,cameraOptions:z,deepLinks:V}=D.current,ee=new ke({store:t,shapeUtils:s,bindingUtils:i,tools:r,getContainer:()=>_,user:o,initialState:W,autoFocus:U,inferDarkMode:Y,cameraOptions:z,textOptions:h,options:p,licenseKey:m,isShapeHidden:x,getShapeVisibility:v,fontAssetUrls:w==null?void 0:w.fonts});return ee.updateViewportScreenBounds(A.current??_),V&&(V!=null&&V.getUrl?ee.navigateToDeepLink({...V,url:V.getUrl(ee)}):ee.navigateToDeepLink(V)),T(ee),()=>{ee.dispose()}},[i,_,p,s,t,r,o,T,m,x,v,h,w]),P.useLayoutEffect(()=>{if(E&&O)return E.registerDeepLinkListener(O)},[E,O]),P.useLayoutEffect(()=>{E&&u&&E.setCameraOptions(u)},[E,u]);const $=P.useSyncExternalStore(P.useCallback(U=>E?(E.on("crash",U),()=>E.off("crash",U)):()=>{},[E]),()=>(E==null?void 0:E.getCrashingError())??null);P.useEffect(function(){if(!E)return;function Y(){E&&E.focus()}function W(){E&&E.blur()}if(l&&IC())return E.getContainer().addEventListener("pointerdown",Y),document.body.addEventListener("pointerdown",W),()=>{var z;(z=E.getContainer())==null||z.removeEventListener("pointerdown",Y),document.body.removeEventListener("pointerdown",W)}},[E,l]);const[H,G]=P.useState(null);let J=H;E!==(J==null?void 0:J.editor)&&(J=null),P.useEffect(()=>{if(!E)return;let U=!1;return G({editor:E,isLoaded:!1}),E.fonts.loadRequiredFontsForCurrentPage(E.options.maxFontsToLoadBeforeRender).finally(()=>{U||G({editor:E,isLoaded:!0})}),()=>{U=!0}},[E]);const{Canvas:L,LoadingScreen:N}=Zt();return!E||!(J!=null&&J.isLoaded)?g.jsxs(g.Fragment,{children:[N&&g.jsx(N,{}),g.jsx("div",{className:"tl-canvas",ref:A})]}):g.jsx(yp,{fallback:C,onError:U=>E.annotateError(U,{origin:"react.tldraw",willCrashApp:!0}),children:$?g.jsx(Vae,{crashingError:$}):g.jsx(UE,{editor:E,children:g.jsxs(Wae,{onMount:n,children:[e??(L?g.jsx(L,{},E.contextId):null),g.jsx(Lae,{})]})})})}function Wae({children:n,onMount:e}){return bae(),aae(),lae(),cae(),L6(t=>{const r=t.store.props.onMount(t),s=e==null?void 0:e(t);return()=>{r==null||r(),s==null||s()}}),n}function Vae({crashingError:n}){throw n}function qae({children:n}){return g.jsx("div",{className:"tl-loading",children:n})}function L6(n){const e=te(),t=Pa(r=>{let s;return r.run(()=>{s=n==null?void 0:n(r),r.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,s});at.useLayoutEffect(()=>{if(e)return t==null?void 0:t(e)},[e,t])}function Ul({children:n,className:e="",...t}){return g.jsx("div",{...t,className:$e("tl-html-container",e),children:n})}class vy{constructor(e){this.editor=e}}R(vy,"props"),R(vy,"migrations"),R(vy,"type");function uv(n,e,t={}){const{newPoint:r,handle:s,scaleX:i,scaleY:o}=e,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=t;let h=n.props.w*i,p=n.props.h*o;const m=new k(0,0);if(h>0){if(h<a){switch(s){case"top_left":case"left":case"bottom_left":{m.x=h-a;break}case"top":case"bottom":{m.x=(h-a)/2;break}default:m.x=0}h=a}}else if(m.x=h,h=-h,h<a){switch(s){case"top_left":case"left":case"bottom_left":{m.x=-h;break}default:m.x=-a}h=a}if(p>0){if(p<c){switch(s){case"top_left":case"top":case"top_right":{m.y=p-c;break}case"right":case"left":{m.y=(p-c)/2;break}default:m.y=0}p=c}}else if(m.y=p,p=-p,p<c){switch(s){case"top_left":case"top":case"top_right":{m.y=-p;break}default:m.y=-c}p=c}const{x:S,y:x}=m.rot(n.rotation).add(r);return{...n,x:S,y:x,props:{w:Math.min(l,h),h:Math.min(u,p)}}}class gh extends eo{getGeometry(e){return new Ho({width:e.props.w,height:e.props.h,isFilled:!0})}onResize(e,t){return uv(e,t)}getHandleSnapGeometry(e){return{points:this.getGeometry(e).bounds.cornersAndCenter}}getInterpolatedProps(e,t,r){return{...t.props,w:yt(e.props.w,t.props.w,r),h:yt(e.props.h,t.props.h,r)}}}var cP;let Gae=(cP=class extends De{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},R(cP,"id","idle"),cP);var uP;let Yae=(uP=class extends De{onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:t}=this.editor.inputs,r=this.parent.shapeType,s=Dt(),i=this.editor.markHistoryStoppingPoint(`creating_box:${s}`),o=ro(t,this.editor);this.editor.createShapes([{id:s,type:r,x:o.x,y:o.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:i,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,t=this.parent.shapeType,r=Dt();this.editor.markHistoryStoppingPoint(`creating_box:${r}`),this.editor.createShapes([{id:r,type:t,x:e.x,y:e.y}]);const s=this.editor.getShape(r);if(!s){this.cancel();return}let{w:i,h:o}=s.props;const a=new k(i/2,o/2),l=this.editor.getShapeParentTransform(s);l&&a.rot(-l.rotation());let c=1;this.editor.user.getIsDynamicResizeMode()&&(c=1/this.editor.getZoomLevel(),i*=c,o*=c,a.mul(c));const u=Xt(s),h=ro(new k(s.x-a.x,s.y-a.y),this.editor);u.x=h.x,u.y=h.y,u.props.w=i,u.props.h=o,"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")}},R(uP,"id","pointing"),uP);function ro(n,e){const t=e.getInstanceState().isGridMode,r=e.getDocumentSettings().gridSize;return t?n.clone().snapToGrid(r):n.clone()}class kk extends De{static children(){return[Gae,Yae]}}R(kk,"id","box"),R(kk,"initial","idle");function Xae(n,e,t){const r=P.useRef(!1),s=P.useCallback(o=>{r.current=o,o?Br.addOpenMenu(n):Br.deleteOpenMenu(n),e==null||e(o)},[n,e]),i=ie("is menu open",()=>Br.getOpenMenus().includes(n),[n]);return P.useEffect(()=>(r.current&&(t==null||t("open-menu"),Br.addOpenMenu(n)),()=>{r.current&&(Br.deleteOpenMenu(n),Br.getOpenMenus().forEach(o=>{o.startsWith(n)&&(t==null||t("close-menu"),Br.deleteOpenMenu(o))}),r.current=!1)}),[n,t]),[i,s]}function dv(n){const e=te();return ie("isEditing",()=>e.getEditingShapeId()===n,[e,n])}function Zae(n){if(!n)throw Error("usePassThroughWheelEvents must be passed a ref");const e=kn();P.useEffect(()=>{function t(s){if(s.isSpecialRedispatchedEvent)return;tt(s);const i=e.querySelector(".tl-canvas");if(!i)return;const o=new PointerEvent(s.type,s);o.isSpecialRedispatchedEvent=!0,i.dispatchEvent(o)}const r=n.current;if(r)return r.addEventListener("mouseover",t,{passive:!1}),()=>{r.removeEventListener("mouseover",t)}},[e,n])}function Eo(n){const e=te();return P.useMemo(function(){const s=c=>{if(c.isKilled)return;if(c.button===HE){e.dispatch({type:"pointer",target:"selection",handle:n,name:"right_click",...Ks(c)});return}if(c.button!==0)return;const u=PS(c.currentTarget);function h(){u.removeEventListener("pointerup",h),Wp(u,c)}Kp(u,c),u.addEventListener("pointerup",h),e.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:n,...Ks(c)}),Wt(c)};let i,o;function a(c){c.isKilled||c.button===0&&(c.clientX===i&&c.clientY===o||(i=c.clientX,o=c.clientY,e.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:n,...Ks(c)})))}return{onPointerDown:s,onPointerMove:a,onPointerUp:c=>{c.isKilled||c.button===0&&e.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:n,...Ks(c)})}}},[e,n])}function Jae(n){const[e,t]=P.useState(()=>({store:Sp(n),opts:n}));if(!t3(e.opts,n)){const r={store:Sp(n),opts:n};return t(r),r.store}return e.store}const Qae=20,ele=8;function a_(n,e=Qae){return Math.max(ele,Math.ceil(n/e))}class Id extends qa{constructor(t){super({...t,isFilled:!1,isClosed:!1});R(this,"_center");R(this,"radius");R(this,"start");R(this,"end");R(this,"largeArcFlag");R(this,"sweepFlag");R(this,"measure");R(this,"angleStart");R(this,"angleEnd");const{center:r,sweepFlag:s,largeArcFlag:i,start:o,end:a}=t;if(o.equals(a))throw Error("Arc must have different start and end points.");this.angleStart=k.Angle(r,o),this.angleEnd=k.Angle(r,a),this.radius=k.Dist(r,o),this.measure=zG(this.angleStart,this.angleEnd,s,i),this.start=o,this.end=a,this.sweepFlag=s,this.largeArcFlag=i,this._center=r}nearestPoint(t){const{_center:r,measure:s,radius:i,angleEnd:o,angleStart:a,start:l,end:c}=this,u=LP(s,a,o,r.angle(t));if(u<=0)return l;if(u>=1)return c;const h=r.clone().add(t.clone().sub(r).uni().mul(i));let p,m=1/0,S;for(const x of[l,c,h])S=k.Dist2(t,x),S<m&&(p=x,m=S);if(!p)throw Error("nearest point not found");return p}hitTestLineSegment(t,r){const{_center:s,radius:i,measure:o,angleStart:a,angleEnd:l}=this,c=Gp(t,r,s,i);return c===null?!1:c.some(u=>{const h=LP(o,a,l,s.angle(u));return h>=0&&h<=1})}getVertices(){const{_center:t,measure:r,length:s,radius:i,angleStart:o}=this,a=[];for(let l=0,c=a_(Math.abs(s));l<c+1;l++){const u=l/c*r,h=o+u;a.push(Xc(t,i,h))}return a}getSvgPathData(t=!0){const{start:r,end:s,radius:i,largeArcFlag:o,sweepFlag:a}=this;return`${t?`M${r.toFixed()}`:""} A${i} ${i} 0 ${o} ${a} ${s.toFixed()}`}getLength(){return this.measure*this.radius}}class l_ extends qa{constructor(t){super({isClosed:!0,...t});R(this,"_center");R(this,"radius");R(this,"x");R(this,"y");this.config=t;const{x:r=0,y:s=0,radius:i}=t;this.x=r,this.y=s,this._center=new k(i+r,i+s),this.radius=i}getBounds(){return new Se(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:t,radius:r}=this,s=Rt*r,i=[];for(let o=0,a=a_(s);o<a;o++){const l=o/a*Rt;i.push(Xc(t,r,l))}return i}nearestPoint(t){const{_center:r,radius:s}=this;return r.equals(t)?k.AddXY(r,s,0):r.clone().add(t.clone().sub(r).uni().mul(s))}hitTestLineSegment(t,r,s=0){const{_center:i,radius:o}=this;return Gp(t,r,i,o+s)!==null}getSvgPathData(){const{_center:t,radius:r}=this;return`M${t.x+r},${t.y} a${r},${r} 0 1,0 ${r*2},0a${r},${r} 0 1,0 -${r*2},0`}}class Cr extends Yp{constructor(t){const{start:r,cp1:s,cp2:i,end:o}=t;super({...t,points:[r,o]});R(this,"a");R(this,"b");R(this,"c");R(this,"d");this.a=r,this.b=s,this.c=i,this.d=o}getVertices(){const t=[],{a:r,b:s,c:i,d:o}=this;for(let a=0,l=10;a<=l;a++){const c=a/l;t.push(new k((1-c)*(1-c)*(1-c)*r.x+3*((1-c)*(1-c))*c*s.x+3*(1-c)*(c*c)*i.x+c*c*c*o.x,(1-c)*(1-c)*(1-c)*r.y+3*((1-c)*(1-c))*c*s.y+3*(1-c)*(c*c)*i.y+c*c*c*o.y))}return t}midPoint(){return Cr.GetAtT(this,.5)}nearestPoint(t){let r,s=1/0,i,o;for(const a of this.segments)o=a.nearestPoint(t),i=k.Dist2(o,t),i<s&&(r=o,s=i);if(!r)throw Error("nearest point not found");return r}getSvgPathData(t=!0){const{a:r,b:s,c:i,d:o}=this;return`${t?`M ${r.toFixed()} `:""} C${s.toFixed()} ${i.toFixed()} ${o.toFixed()}`}static GetAtT(t,r){const{a:s,b:i,c:o,d:a}=t;return new k((1-r)*(1-r)*(1-r)*s.x+3*((1-r)*(1-r))*r*i.x+3*(1-r)*(r*r)*o.x+r*r*r*a.x,(1-r)*(1-r)*(1-r)*s.y+3*((1-r)*(1-r))*r*i.y+3*(1-r)*(r*r)*o.y+r*r*r*a.y)}getLength(t=32){let r,s=this.a,i=0;for(let o=1;o<=t;o++)r=Cr.GetAtT(this,o/t),i+=k.Dist(s,r),s=r;return i}}class tle extends qa{constructor(t){super({...t,isClosed:!1,isFilled:!1});R(this,"points");R(this,"_segments");const{points:r}=t;this.points=r}get segments(){if(!this._segments){this._segments=[];const{points:t}=this,r=t.length,s=r-2,i=1.25;for(let o=0;o<r-1;o++){const a=o===0?t[0]:t[o-1],l=t[o],c=t[o+1],u=o===s?c:t[o+2],h=l,p=o===0?a:new k(l.x+(c.x-a.x)/6*i,l.y+(c.y-a.y)/6*i),m=o===s?c:new k(c.x-(u.x-l.x)/6*i,c.y-(u.y-l.y)/6*i),S=c;this._segments.push(new Cr({start:h,cp1:p,cp2:m,end:S}))}}return this._segments}getLength(){return this.segments.reduce((t,r)=>t+r.length,0)}getVertices(){const t=this.segments.reduce((r,s)=>r.concat(s.vertices),[]);return t.push(this.points[this.points.length-1]),t}nearestPoint(t){let r,s=1/0,i,o;for(const a of this.segments)o=a.nearestPoint(t),i=k.Dist2(o,t),i<s&&(r=o,s=i);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(t,r){return this.segments.some(s=>s.hitTestLineSegment(t,r))}getSvgPathData(){let t=this.segments.reduce((r,s,i)=>r+s.getSvgPathData(i===0),"");return this.isClosed&&(t+="Z"),t}}class nle extends qa{constructor(t){super({...t,isClosed:!0});R(this,"w");R(this,"h");R(this,"_edges");this.config=t;const{width:r,height:s}=t;this.w=r,this.h=s}get edges(){if(!this._edges){const{vertices:t}=this;this._edges=[];for(let r=0,s=t.length;r<s;r++){const i=t[r],o=t[(r+1)%s];this._edges.push(new Ia({start:i,end:o}))}}return this._edges}getVertices(){const t=Math.max(1,this.w),r=Math.max(1,this.h),s=t/2,i=r/2,o=Math.pow(s-i,2)/Math.pow(s+i,2),a=wt*(s+i)*(1+3*o/(10+Math.sqrt(4-3*o))),l=a_(a),c=Rt/l,u=Math.cos(c),h=Math.sin(c);let p=0,m=1,S=0,x=1;const v=Array(l);for(let w=0;w<l;w++)v[w]=new k(s+s*m,i+i*p),S=h*m+u*p,x=u*m-h*p,p=S,m=x;return v}nearestPoint(t){let r,s=1/0,i,o;for(const a of this.edges)o=a.nearestPoint(t),i=k.Dist2(o,t),i<s&&(r=o,s=i);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(t,r){return this.edges.some(s=>s.hitTestLineSegment(t,r))}getBounds(){return new Se(0,0,this.w,this.h)}getLength(){const{w:t,h:r}=this,s=t/2,i=r/2,o=Math.max(0,s),a=Math.max(0,i);return sF(o,a)}getSvgPathData(t=!1){const{w:r,h:s}=this,i=r/2,o=s/2,a=Math.max(0,i),l=Math.max(0,o);return`${t?`M${i-a},${o}`:""} a${a},${l},0,1,1,${a*2},0a${a},${l},0,1,1,-${a*2},0`}}class rle extends qa{constructor(t){super({...t,isClosed:!0});R(this,"w");R(this,"h");R(this,"a");R(this,"b");R(this,"c");R(this,"d");this.config=t;const{width:r,height:s}=t;if(this.w=r,this.h=s,s>r){const i=r/2;this.a=new Id({start:new k(0,i),end:new k(r,i),center:new k(r/2,i),sweepFlag:1,largeArcFlag:1}),this.b=new Ia({start:new k(r,i),end:new k(r,s-i)}),this.c=new Id({start:new k(r,s-i),end:new k(0,s-i),center:new k(r/2,s-i),sweepFlag:1,largeArcFlag:1}),this.d=new Ia({start:new k(0,s-i),end:new k(0,i)})}else{const i=s/2;this.a=new Id({start:new k(i,s),end:new k(i,0),center:new k(i,i),sweepFlag:1,largeArcFlag:1}),this.b=new Ia({start:new k(i,0),end:new k(r-i,0)}),this.c=new Id({start:new k(r-i,0),end:new k(r-i,s),center:new k(r-i,i),sweepFlag:1,largeArcFlag:1}),this.d=new Ia({start:new k(r-i,s),end:new k(i,s)})}}nearestPoint(t){let r,s=1/0,i,o;const{a,b:l,c,d:u}=this;for(const h of[a,l,c,u])o=h.nearestPoint(t),i=k.Dist2(o,t),i<s&&(r=o,s=i);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(t,r){const{a:s,b:i,c:o,d:a}=this;return[s,i,o,a].some(l=>l.hitTestLineSegment(t,r))}getVertices(){const{a:t,b:r,c:s,d:i}=this;return[t,r,s,i].reduce((o,a)=>(o.push(...a.vertices),o),[])}getBounds(){return new Se(0,0,this.w,this.h)}getLength(){const{h:t,w:r}=this;return t>r?(wt*(r/2)+(t-r))*2:(wt*(t/2)+(r-t))*2}getSvgPathData(){const{a:t,b:r,c:s,d:i}=this;return[t,r,s,i].map((o,a)=>o.getSvgPathData(a===0)).join(" ")+" Z"}}async function sle({shouldReload:n=!0}={}){aq();for(const e of dS.connectedInstances)await e.close();await Promise.all(yE().map(e=>Y5(e))),oq(),n&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=sle);function ile(n,e="_blank"){J0.openWindow(n,e)}Zl("@tldraw/editor","3.12.1","esm");function N6(){const[n,e]=P.useState(!1);return P.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{e(t.matches)};return r(),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),n}const Ik=P.createContext(null);function ole({children:n}){const e=Np("a11y",{msg:"",priority:"assertive"}),t=P.useContext(Ik),r=P.useMemo(()=>({currentMsg:e,announce(s){s&&e.set(s)}}),[e]);return t?g.jsx(g.Fragment,{children:n}):g.jsx(Ik.Provider,{value:r,children:n})}function hv(){const n=P.useContext(Ik);if(!n)throw new Error("useA11y must be used within a A11yContext.Provider");return n}const F6=P.createContext(null);function ale({assetUrls:n,children:e}){return P.useEffect(()=>{for(const t of Object.values(n.icons)){if(!t)continue;const r=rp();r.src=t,r.decode()}for(const t of Object.values(n.embedIcons)){if(!t)continue;const r=rp();r.src=t,r.decode()}},[n]),g.jsx(F6.Provider,{value:n,children:e})}function c_(){const n=P.useContext(F6);if(!n)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return n}const Ek={"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-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-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-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.files.amount-too-many":"Too many files","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.cloud":"Cloud","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.heart":"Heart","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","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.heart":"Heart","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.media":"Media","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","tool.pointer-down":"Pointer down","tool.rich-text-bold":"Bold","tool.rich-text-italic":"Italic","tool.rich-text-code":"Code","tool.rich-text-highlight":"Highlight","tool.rich-text-strikethrough":"Strikethrough","tool.rich-text-link":"Link","tool.rich-text-link-visit":"Visit link","tool.rich-text-link-remove":"Remove link","tool.rich-text-header":"Header","tool.rich-text-bulletList":"Bulleted list","tool.bookmark":"Bookmark","a11y.skip-to-main-content":"Move focus to canvas","a11y.shape-index":"{num} of {total}","a11y.shape-image":"Image","a11y.shape-video":"Video","a11y.multiple-shapes":"{num} shapes selected","a11y.select-shape":"Select next shape","a11y.select-shape-direction":"Select shape in direction","a11y.repeat-shape":"Repeat shape","a11y.move-shape":"Move shape","a11y.move-shape-faster":"Move shape faster","a11y.enlarge-shape":"Enlarge shape","a11y.shrink-shape":"Shrink shape","a11y.pan-camera":"Pan camera","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.view":"View","context-menu.title":"Context menu","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.copy-link":"Copy editor link","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","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","people-menu.anonymous-user":"New user","help-menu.import-tldr-file":"Import file…","help-menu.title":"Help and resources","help-menu.about":"About tldraw","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.","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","shortcuts-dialog.a11y":"Accessibility","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.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…"},lle=new Set(["ar","fa","he","ur","ku"]),hd={locale:"en",label:"English",messages:Ek,dir:"ltr"};async function cle(n,e){if(!(await Zi(e.translations.en)).ok)return console.warn("No main translations found."),hd;if(n==="en")return hd;const r=mp.find(o=>o.locale===n);if(!r)return console.warn(`No translation found for locale ${n}`),hd;const i=await(await Zi(e.translations[r.locale])).json();if(!i)return console.warn(`No messages found for locale ${n}`),hd;for(const o in hd.messages)i[o];return{locale:n,label:r.label,dir:lle.has(r.locale)?"rtl":"ltr",messages:{...hd.messages,...i}}}const z6=P.createContext(null);function $6(){const n=P.useContext(z6);if(!n)throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />");return n}function ule({overrides:n,locale:e,children:t}){const r=c_(),[s,i]=P.useState(()=>n&&n.en?{locale:"en",label:"English",dir:"ltr",messages:{...Ek,...n.en}}:{locale:"en",label:"English",dir:"ltr",messages:Ek});return P.useEffect(()=>{let o=!1;async function a(){const l=await cle(e,r);l&&!o&&(n&&n[e]?i({...l,messages:{...l.messages,...n[e]}}):i(l))}return a(),()=>{o=!0}},[r,e,n]),g.jsx(z6.Provider,{value:s,children:t})}function it(){const n=$6();return P.useCallback(function(t){return n.messages[t]??t},[n])}const He=P.forwardRef(function({children:e,type:t,isActive:r,...s},i){return g.jsx("button",{ref:i,type:"button",draggable:!1,"data-isactive":r,...s,className:$e("tlui-button",`tlui-button__${t}`,s.className),children:e})});function dle(){const n=te(),e=it(),t=P.useRef(null),r=P.useCallback(s=>{var o;Wt(s),(o=t.current)==null||o.blur();const i=n.getCurrentPageShapesInReadingOrder();i.length&&(n.setSelectedShapes([i[0].id]),n.zoomToSelectionIfOffscreen(256,{animation:{duration:n.options.animationMediumMs},inset:0}),n.timers.setTimeout(()=>n.getContainer().focus(),100))},[n]);return g.jsx(He,{ref:t,type:"low",tabIndex:0,className:"tl-skip-to-main-content",onClick:r,children:e("a11y.skip-to-main-content")})}const hle=P.memo(function(){const e=hv(),t=ie("a11y-msg",()=>e.currentMsg.get(),[]);return ple(t.msg),fle(),t.msg&&g.jsx("div",{"aria-live":t.priority||"assertive",role:"status","aria-hidden":"false",style:{position:"absolute",top:"-10000px",left:"-10000px"},children:t.msg})});function B6(n){const{editor:e,selectedShapeIds:t,msg:r}=n;let s="";const i=t.length;if(i>1)s=r("a11y.multiple-shapes").replace("{num}",i.toString());else if(i===1){const o=t[0],a=e.getShape(o);if(!a)return"";const l=e.getShapeUtil(a.type),c=["image","video"].includes(a.type);let u="";a.type==="geo"?u=r(`geo-style.${a.props.geo}`):c?u=r(`a11y.shape-${a.type}`):u=r(`tool.${a.type}`);const h=e.getCurrentPageShapesInReadingOrder(),p=(h.findIndex(v=>v.id===o)+1).toString(),m=h.length.toString(),S=r("a11y.shape-index").replace("{num}",p).replace("{total}",m),x=l.getAriaDescriptor(a)||l.getText(a)||"";s=(x?`${x}, `:"")+`${u}. ${S}`}return s}const fle=()=>{const n=dr(),e=hv(),t=it();P.useEffect(()=>{if(!n)return;const r=i=>{const o=B6({editor:n,selectedShapeIds:i,msg:t});o&&e.announce({msg:o})},s=Pi("useSelectedShapesAnnouncer",()=>{const i=n.getSelectedShapeIds();r(i)});return()=>{s()}},[n,e,t])},ple=n=>{const e=kn();P.useEffect(()=>{if(ln.a11y.get()){const t=s=>{console.debug(`%ca11y%c: ${s}`,"color: white; background: #40C057; padding: 2px;border-radius: 3px;","font-weight: normal")},r=s=>{const i=document.activeElement;if(s.key==="Tab"&&i&&i!==document.body&&!i.classList.contains("tl-container")){const o=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent;o&&t(o)}};return n&&t(n),document.addEventListener("keyup",r),()=>document.removeEventListener("keyup",r)}},[e,n])},U6=()=>{},H6=P.createContext(null);function gle({onEvent:n,children:e}){return g.jsx(H6.Provider,{value:n??U6,children:e})}function Ln(){return P.useContext(H6)??U6}function je(n,e,{checkForDefaultPrevented:t=!0}={}){return function(s){if(n==null||n(s),t===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function mle(n,e){const t=P.createContext(e),r=i=>{const{children:o,...a}=i,l=P.useMemo(()=>a,Object.values(a));return g.jsx(t.Provider,{value:l,children:o})};r.displayName=n+"Provider";function s(i){const o=P.useContext(t);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${n}\``)}return[r,s]}function Xo(n,e=[]){let t=[];function r(i,o){const a=P.createContext(o),l=t.length;t=[...t,o];const c=h=>{var w;const{scope:p,children:m,...S}=h,x=((w=p==null?void 0:p[n])==null?void 0:w[l])||a,v=P.useMemo(()=>S,Object.values(S));return g.jsx(x.Provider,{value:v,children:m})};c.displayName=i+"Provider";function u(h,p){var x;const m=((x=p==null?void 0:p[n])==null?void 0:x[l])||a,S=P.useContext(m);if(S)return S;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[c,u]}const s=()=>{const i=t.map(o=>P.createContext(o));return function(a){const l=(a==null?void 0:a[n])||i;return P.useMemo(()=>({[`__scope${n}`]:{...a,[n]:l}}),[a,l])}};return s.scopeName=n,[r,yle(s,...e)]}function yle(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const r=n.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(i)[`__scope${c}`];return{...a,...h}},{});return P.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return t.scopeName=e.scopeName,t}function aL(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function u_(...n){return e=>{let t=!1;const r=n.map(s=>{const i=aL(s,e);return!t&&typeof i=="function"&&(t=!0),i});if(t)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():aL(n[s],null)}}}}function jt(...n){return P.useCallback(u_(...n),n)}function Yd(n){const e=Sle(n),t=P.forwardRef((r,s)=>{const{children:i,...o}=r,a=P.Children.toArray(i),l=a.find(xle);if(l){const c=l.props.children,u=a.map(h=>h===l?P.Children.count(c)>1?P.Children.only(null):P.isValidElement(c)?c.props.children:null:h);return g.jsx(e,{...o,ref:s,children:P.isValidElement(c)?P.cloneElement(c,void 0,u):null})}return g.jsx(e,{...o,ref:s,children:i})});return t.displayName=`${n}.Slot`,t}function Sle(n){const e=P.forwardRef((t,r)=>{const{children:s,...i}=t,o=P.isValidElement(s)?ble(s):void 0,a=jt(o,r);if(P.isValidElement(s)){const l=wle(i,s.props);return s.type!==P.Fragment&&(l.ref=a),P.cloneElement(s,l)}return P.Children.count(s)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var vle=Symbol("radix.slottable");function xle(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===vle}function wle(n,e){const t={...e};for(const r in e){const s=n[r],i=e[r];/^on[A-Z]/.test(r)?s&&i?t[r]=(...a)=>{const l=i(...a);return s(...a),l}:s&&(t[r]=s):r==="style"?t[r]={...s,...i}:r==="className"&&(t[r]=[s,i].filter(Boolean).join(" "))}return{...n,...t}}function ble(n){var r,s;let e=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var Cle=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vt=Cle.reduce((n,e)=>{const t=Yd(`Primitive.${e}`),r=P.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${e}`,{...n,[e]:r}},{});function d_(n,e){n&&hh.flushSync(()=>n.dispatchEvent(e))}function fv(n){const e=n+"CollectionProvider",[t,r]=Xo(e),[s,i]=t(e,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:v,children:w}=x,C=at.useRef(null),_=at.useRef(new Map).current;return g.jsx(s,{scope:v,itemMap:_,collectionRef:C,children:w})};o.displayName=e;const a=n+"CollectionSlot",l=Yd(a),c=at.forwardRef((x,v)=>{const{scope:w,children:C}=x,_=i(a,w),E=jt(v,_.collectionRef);return g.jsx(l,{ref:E,children:C})});c.displayName=a;const u=n+"CollectionItemSlot",h="data-radix-collection-item",p=Yd(u),m=at.forwardRef((x,v)=>{const{scope:w,children:C,..._}=x,E=at.useRef(null),T=jt(v,E),A=i(u,w);return at.useEffect(()=>(A.itemMap.set(E,{ref:E,..._}),()=>void A.itemMap.delete(E))),g.jsx(p,{[h]:"",ref:T,children:C})});m.displayName=u;function S(x){const v=i(n+"CollectionConsumer",x);return at.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const _=Array.from(C.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((A,O)=>_.indexOf(A.ref.current)-_.indexOf(O.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:c,ItemSlot:m},S,r]}var Ple=P.createContext(void 0);function h_(n){const e=P.useContext(Ple);return n||e||"ltr"}function Xr(n){const e=P.useRef(n);return P.useEffect(()=>{e.current=n}),P.useMemo(()=>(...t)=>{var r;return(r=e.current)==null?void 0:r.call(e,...t)},[])}function kle(n,e=globalThis==null?void 0:globalThis.document){const t=Xr(n);P.useEffect(()=>{const r=s=>{s.key==="Escape"&&t(s)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[t,e])}var Ile="DismissableLayer",_k="dismissableLayer.update",Ele="dismissableLayer.pointerDownOutside",_le="dismissableLayer.focusOutside",lL,K6=P.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tg=P.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:o,onDismiss:a,...l}=n,c=P.useContext(K6),[u,h]=P.useState(null),p=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=P.useState({}),S=jt(e,O=>h(O)),x=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=x.indexOf(v),C=u?x.indexOf(u):-1,_=c.layersWithOutsidePointerEventsDisabled.size>0,E=C>=w,T=Mle(O=>{const D=O.target,$=[...c.branches].some(H=>H.contains(D));!E||$||(s==null||s(O),o==null||o(O),O.defaultPrevented||a==null||a())},p),A=Ale(O=>{const D=O.target;[...c.branches].some(H=>H.contains(D))||(i==null||i(O),o==null||o(O),O.defaultPrevented||a==null||a())},p);return kle(O=>{C===c.layers.size-1&&(r==null||r(O),!O.defaultPrevented&&a&&(O.preventDefault(),a()))},p),P.useEffect(()=>{if(u)return t&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(lL=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),cL(),()=>{t&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=lL)}},[u,p,t,c]),P.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),cL())},[u,c]),P.useEffect(()=>{const O=()=>m({});return document.addEventListener(_k,O),()=>document.removeEventListener(_k,O)},[]),g.jsx(vt.div,{...l,ref:S,style:{pointerEvents:_?E?"auto":"none":void 0,...n.style},onFocusCapture:je(n.onFocusCapture,A.onFocusCapture),onBlurCapture:je(n.onBlurCapture,A.onBlurCapture),onPointerDownCapture:je(n.onPointerDownCapture,T.onPointerDownCapture)})});tg.displayName=Ile;var Tle="DismissableLayerBranch",W6=P.forwardRef((n,e)=>{const t=P.useContext(K6),r=P.useRef(null),s=jt(e,r);return P.useEffect(()=>{const i=r.current;if(i)return t.branches.add(i),()=>{t.branches.delete(i)}},[t.branches]),g.jsx(vt.div,{...n,ref:s})});W6.displayName=Tle;function Mle(n,e=globalThis==null?void 0:globalThis.document){const t=Xr(n),r=P.useRef(!1),s=P.useRef(()=>{});return P.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){V6(Ele,t,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},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",s.current)}},[e,t]),{onPointerDownCapture:()=>r.current=!0}}function Ale(n,e=globalThis==null?void 0:globalThis.document){const t=Xr(n),r=P.useRef(!1);return P.useEffect(()=>{const s=i=>{i.target&&!r.current&&V6(_le,t,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function cL(){const n=new CustomEvent(_k);document.dispatchEvent(n)}function V6(n,e,t,{discrete:r}){const s=t.originalEvent.target,i=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&s.addEventListener(n,e,{once:!0}),r?d_(s,i):s.dispatchEvent(i)}var Ole=tg,Rle=W6,EC=0;function f_(){P.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??uL()),document.body.insertAdjacentElement("beforeend",n[1]??uL()),EC++,()=>{EC===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),EC--}},[])}function uL(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var _C="focusScope.autoFocusOnMount",TC="focusScope.autoFocusOnUnmount",dL={bubbles:!1,cancelable:!0},Dle="FocusScope",pv=P.forwardRef((n,e)=>{const{loop:t=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...o}=n,[a,l]=P.useState(null),c=Xr(s),u=Xr(i),h=P.useRef(null),p=jt(e,x=>l(x)),m=P.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;P.useEffect(()=>{if(r){let x=function(_){if(m.paused||!a)return;const E=_.target;a.contains(E)?h.current=E:kl(h.current,{select:!0})},v=function(_){if(m.paused||!a)return;const E=_.relatedTarget;E!==null&&(a.contains(E)||kl(h.current,{select:!0}))},w=function(_){if(document.activeElement===document.body)for(const T of _)T.removedNodes.length>0&&kl(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",v);const C=new MutationObserver(w);return a&&C.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",v),C.disconnect()}}},[r,a,m.paused]),P.useEffect(()=>{if(a){fL.add(m);const x=document.activeElement;if(!a.contains(x)){const w=new CustomEvent(_C,dL);a.addEventListener(_C,c),a.dispatchEvent(w),w.defaultPrevented||(jle($le(q6(a)),{select:!0}),document.activeElement===x&&kl(a))}return()=>{a.removeEventListener(_C,c),setTimeout(()=>{const w=new CustomEvent(TC,dL);a.addEventListener(TC,u),a.dispatchEvent(w),w.defaultPrevented||kl(x??document.body,{select:!0}),a.removeEventListener(TC,u),fL.remove(m)},0)}}},[a,c,u,m]);const S=P.useCallback(x=>{if(!t&&!r||m.paused)return;const v=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,w=document.activeElement;if(v&&w){const C=x.currentTarget,[_,E]=Lle(C);_&&E?!x.shiftKey&&w===E?(x.preventDefault(),t&&kl(_,{select:!0})):x.shiftKey&&w===_&&(x.preventDefault(),t&&kl(E,{select:!0})):w===C&&x.preventDefault()}},[t,r,m.paused]);return g.jsx(vt.div,{tabIndex:-1,...o,ref:p,onKeyDown:S})});pv.displayName=Dle;function jle(n,{select:e=!1}={}){const t=document.activeElement;for(const r of n)if(kl(r,{select:e}),document.activeElement!==t)return}function Lle(n){const e=q6(n),t=hL(e,n),r=hL(e.reverse(),n);return[t,r]}function q6(n){const e=[],t=document.createTreeWalker(n,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(;t.nextNode();)e.push(t.currentNode);return e}function hL(n,e){for(const t of n)if(!Nle(t,{upTo:e}))return t}function Nle(n,{upTo:e}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(e!==void 0&&n===e)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function Fle(n){return n instanceof HTMLInputElement&&"select"in n}function kl(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&Fle(n)&&e&&n.select()}}var fL=zle();function zle(){let n=[];return{add(e){const t=n[0];e!==t&&(t==null||t.pause()),n=pL(n,e),n.unshift(e)},remove(e){var t;n=pL(n,e),(t=n[0])==null||t.resume()}}}function pL(n,e){const t=[...n],r=t.indexOf(e);return r!==-1&&t.splice(r,1),t}function $le(n){return n.filter(e=>e.tagName!=="A")}var Fa=globalThis!=null&&globalThis.document?P.useLayoutEffect:()=>{},Ble=HN[" useId ".trim().toString()]||(()=>{}),Ule=0;function Ra(n){const[e,t]=P.useState(Ble());return Fa(()=>{t(r=>r??String(Ule++))},[n]),n||(e?`radix-${e}`:"")}const Hle=["top","right","bottom","left"],Yl=Math.min,Bs=Math.max,_S=Math.round,Fm=Math.floor,Fo=n=>({x:n,y:n}),Kle={left:"right",right:"left",bottom:"top",top:"bottom"},Wle={start:"end",end:"start"};function Tk(n,e,t){return Bs(n,Yl(e,t))}function za(n,e){return typeof n=="function"?n(e):n}function $a(n){return n.split("-")[0]}function mh(n){return n.split("-")[1]}function p_(n){return n==="x"?"y":"x"}function g_(n){return n==="y"?"height":"width"}function Da(n){return["top","bottom"].includes($a(n))?"y":"x"}function m_(n){return p_(Da(n))}function Vle(n,e,t){t===void 0&&(t=!1);const r=mh(n),s=m_(n),i=g_(s);let o=s==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=TS(o)),[o,TS(o)]}function qle(n){const e=TS(n);return[Mk(n),e,Mk(e)]}function Mk(n){return n.replace(/start|end/g,e=>Wle[e])}function Gle(n,e,t){const r=["left","right"],s=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?s:r:e?r:s;case"left":case"right":return e?i:o;default:return[]}}function Yle(n,e,t,r){const s=mh(n);let i=Gle($a(n),t==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(Mk)))),i}function TS(n){return n.replace(/left|right|bottom|top/g,e=>Kle[e])}function Xle(n){return{top:0,right:0,bottom:0,left:0,...n}}function G6(n){return typeof n!="number"?Xle(n):{top:n,right:n,bottom:n,left:n}}function MS(n){const{x:e,y:t,width:r,height:s}=n;return{width:r,height:s,top:t,left:e,right:e+r,bottom:t+s,x:e,y:t}}function gL(n,e,t){let{reference:r,floating:s}=n;const i=Da(e),o=m_(e),a=g_(o),l=$a(e),c=i==="y",u=r.x+r.width/2-s.width/2,h=r.y+r.height/2-s.height/2,p=r[a]/2-s[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-s.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:h};break;case"left":m={x:r.x-s.width,y:h};break;default:m={x:r.x,y:r.y}}switch(mh(e)){case"start":m[o]-=p*(t&&c?-1:1);break;case"end":m[o]+=p*(t&&c?-1:1);break}return m}const Zle=async(n,e,t)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:u,y:h}=gL(c,r,l),p=r,m={},S=0;for(let x=0;x<a.length;x++){const{name:v,fn:w}=a[x],{x:C,y:_,data:E,reset:T}=await w({x:u,y:h,initialPlacement:r,placement:p,strategy:s,middlewareData:m,rects:c,platform:o,elements:{reference:n,floating:e}});u=C??u,h=_??h,m={...m,[v]:{...m[v],...E}},T&&S<=50&&(S++,typeof T=="object"&&(T.placement&&(p=T.placement),T.rects&&(c=T.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:s}):T.rects),{x:u,y:h}=gL(c,p,l)),x=-1)}return{x:u,y:h,placement:p,strategy:s,middlewareData:m}};async function vp(n,e){var t;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:p=!1,padding:m=0}=za(e,n),S=G6(m),v=a[p?h==="floating"?"reference":"floating":h],w=MS(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(v)))==null||t?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),C=h==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),E=await(i.isElement==null?void 0:i.isElement(_))?await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1}:{x:1,y:1},T=MS(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:C,offsetParent:_,strategy:l}):C);return{top:(w.top-T.top+S.top)/E.y,bottom:(T.bottom-w.bottom+S.bottom)/E.y,left:(w.left-T.left+S.left)/E.x,right:(T.right-w.right+S.right)/E.x}}const Jle=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=za(n,e)||{};if(c==null)return{};const h=G6(u),p={x:t,y:r},m=m_(s),S=g_(m),x=await o.getDimensions(c),v=m==="y",w=v?"top":"left",C=v?"bottom":"right",_=v?"clientHeight":"clientWidth",E=i.reference[S]+i.reference[m]-p[m]-i.floating[S],T=p[m]-i.reference[m],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let O=A?A[_]:0;(!O||!await(o.isElement==null?void 0:o.isElement(A)))&&(O=a.floating[_]||i.floating[S]);const D=E/2-T/2,$=O/2-x[S]/2-1,H=Yl(h[w],$),G=Yl(h[C],$),J=H,L=O-x[S]-G,N=O/2-x[S]/2+D,U=Tk(J,N,L),Y=!l.arrow&&mh(s)!=null&&N!==U&&i.reference[S]/2-(N<J?H:G)-x[S]/2<0,W=Y?N<J?N-J:N-L:0;return{[m]:p[m]+W,data:{[m]:U,centerOffset:N-U-W,...Y&&{alignmentOffset:W}},reset:Y}}}),Qle=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:x=!0,...v}=za(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const w=$a(s),C=Da(a),_=$a(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(_||!x?[TS(a)]:qle(a)),A=S!=="none";!p&&A&&T.push(...Yle(a,x,S,E));const O=[a,...T],D=await vp(e,v),$=[];let H=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&$.push(D[w]),h){const U=Vle(s,o,E);$.push(D[U[0]],D[U[1]])}if(H=[...H,{placement:s,overflows:$}],!$.every(U=>U<=0)){var G,J;const U=(((G=i.flip)==null?void 0:G.index)||0)+1,Y=O[U];if(Y){var L;const z=h==="alignment"?C!==Da(Y):!1,V=((L=H[0])==null?void 0:L.overflows[0])>0;if(!z||V)return{data:{index:U,overflows:H},reset:{placement:Y}}}let W=(J=H.filter(z=>z.overflows[0]<=0).sort((z,V)=>z.overflows[1]-V.overflows[1])[0])==null?void 0:J.placement;if(!W)switch(m){case"bestFit":{var N;const z=(N=H.filter(V=>{if(A){const ee=Da(V.placement);return ee===C||ee==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(ee=>ee>0).reduce((ee,B)=>ee+B,0)]).sort((V,ee)=>V[1]-ee[1])[0])==null?void 0:N[0];z&&(W=z);break}case"initialPlacement":W=a;break}if(s!==W)return{reset:{placement:W}}}return{}}}};function mL(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function yL(n){return Hle.some(e=>n[e]>=0)}const ece=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...s}=za(n,e);switch(r){case"referenceHidden":{const i=await vp(e,{...s,elementContext:"reference"}),o=mL(i,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:yL(o)}}}case"escaped":{const i=await vp(e,{...s,altBoundary:!0}),o=mL(i,t.floating);return{data:{escapedOffsets:o,escaped:yL(o)}}}default:return{}}}}};async function tce(n,e){const{placement:t,platform:r,elements:s}=n,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=$a(t),a=mh(t),l=Da(t)==="y",c=["left","top"].includes(o)?-1:1,u=i&&l?-1:1,h=za(e,n);let{mainAxis:p,crossAxis:m,alignmentAxis:S}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof S=="number"&&(m=a==="end"?S*-1:S),l?{x:m*u,y:p*c}:{x:p*c,y:m*u}}const nce=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await tce(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},rce=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:v=>{let{x:w,y:C}=v;return{x:w,y:C}}},...l}=za(n,e),c={x:t,y:r},u=await vp(e,l),h=Da($a(s)),p=p_(h);let m=c[p],S=c[h];if(i){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=m+u[v],_=m-u[w];m=Tk(C,m,_)}if(o){const v=h==="y"?"top":"left",w=h==="y"?"bottom":"right",C=S+u[v],_=S-u[w];S=Tk(C,S,_)}const x=a.fn({...e,[p]:m,[h]:S});return{...x,data:{x:x.x-t,y:x.y-r,enabled:{[p]:i,[h]:o}}}}}},sce=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=za(n,e),u={x:t,y:r},h=Da(s),p=p_(h);let m=u[p],S=u[h];const x=za(a,e),v=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const _=p==="y"?"height":"width",E=i.reference[p]-i.floating[_]+v.mainAxis,T=i.reference[p]+i.reference[_]-v.mainAxis;m<E?m=E:m>T&&(m=T)}if(c){var w,C;const _=p==="y"?"width":"height",E=["top","left"].includes($a(s)),T=i.reference[h]-i.floating[_]+(E&&((w=o.offset)==null?void 0:w[h])||0)+(E?0:v.crossAxis),A=i.reference[h]+i.reference[_]+(E?0:((C=o.offset)==null?void 0:C[h])||0)-(E?v.crossAxis:0);S<T?S=T:S>A&&(S=A)}return{[p]:m,[h]:S}}}},ice=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,r;const{placement:s,rects:i,platform:o,elements:a}=e,{apply:l=()=>{},...c}=za(n,e),u=await vp(e,c),h=$a(s),p=mh(s),m=Da(s)==="y",{width:S,height:x}=i.floating;let v,w;h==="top"||h==="bottom"?(v=h,w=p===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(w=h,v=p==="end"?"top":"bottom");const C=x-u.top-u.bottom,_=S-u.left-u.right,E=Yl(x-u[v],C),T=Yl(S-u[w],_),A=!e.middlewareData.shift;let O=E,D=T;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(D=_),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(O=C),A&&!p){const H=Bs(u.left,0),G=Bs(u.right,0),J=Bs(u.top,0),L=Bs(u.bottom,0);m?D=S-2*(H!==0||G!==0?H+G:Bs(u.left,u.right)):O=x-2*(J!==0||L!==0?J+L:Bs(u.top,u.bottom))}await l({...e,availableWidth:D,availableHeight:O});const $=await o.getDimensions(a.floating);return S!==$.width||x!==$.height?{reset:{rects:!0}}:{}}}};function gv(){return typeof window<"u"}function yh(n){return Y6(n)?(n.nodeName||"").toLowerCase():"#document"}function Xs(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Zo(n){var e;return(e=(Y6(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Y6(n){return gv()?n instanceof Node||n instanceof Xs(n).Node:!1}function so(n){return gv()?n instanceof Element||n instanceof Xs(n).Element:!1}function Ko(n){return gv()?n instanceof HTMLElement||n instanceof Xs(n).HTMLElement:!1}function SL(n){return!gv()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Xs(n).ShadowRoot}function ng(n){const{overflow:e,overflowX:t,overflowY:r,display:s}=io(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(s)}function oce(n){return["table","td","th"].includes(yh(n))}function mv(n){return[":popover-open",":modal"].some(e=>{try{return n.matches(e)}catch{return!1}})}function y_(n){const e=S_(),t=so(n)?io(n):n;return["transform","translate","scale","rotate","perspective"].some(r=>t[r]?t[r]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function ace(n){let e=Xl(n);for(;Ko(e)&&!Xd(e);){if(y_(e))return e;if(mv(e))return null;e=Xl(e)}return null}function S_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Xd(n){return["html","body","#document"].includes(yh(n))}function io(n){return Xs(n).getComputedStyle(n)}function yv(n){return so(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Xl(n){if(yh(n)==="html")return n;const e=n.assignedSlot||n.parentNode||SL(n)&&n.host||Zo(n);return SL(e)?e.host:e}function X6(n){const e=Xl(n);return Xd(e)?n.ownerDocument?n.ownerDocument.body:n.body:Ko(e)&&ng(e)?e:X6(e)}function xp(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=X6(n),i=s===((r=n.ownerDocument)==null?void 0:r.body),o=Xs(s);if(i){const a=Ak(o);return e.concat(o,o.visualViewport||[],ng(s)?s:[],a&&t?xp(a):[])}return e.concat(s,xp(s,[],t))}function Ak(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Z6(n){const e=io(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Ko(n),i=s?n.offsetWidth:t,o=s?n.offsetHeight:r,a=_S(t)!==i||_S(r)!==o;return a&&(t=i,r=o),{width:t,height:r,$:a}}function v_(n){return so(n)?n:n.contextElement}function Ld(n){const e=v_(n);if(!Ko(e))return Fo(1);const t=e.getBoundingClientRect(),{width:r,height:s,$:i}=Z6(e);let o=(i?_S(t.width):t.width)/r,a=(i?_S(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const lce=Fo(0);function J6(n){const e=Xs(n);return!S_()||!e.visualViewport?lce:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function cce(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Xs(n)?!1:e}function au(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),i=v_(n);let o=Fo(1);e&&(r?so(r)&&(o=Ld(r)):o=Ld(n));const a=cce(i,t,r)?J6(i):Fo(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,h=s.height/o.y;if(i){const p=Xs(i),m=r&&so(r)?Xs(r):r;let S=p,x=Ak(S);for(;x&&r&&m!==S;){const v=Ld(x),w=x.getBoundingClientRect(),C=io(x),_=w.left+(x.clientLeft+parseFloat(C.paddingLeft))*v.x,E=w.top+(x.clientTop+parseFloat(C.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,h*=v.y,l+=_,c+=E,S=Xs(x),x=Ak(S)}}return MS({width:u,height:h,x:l,y:c})}function x_(n,e){const t=yv(n).scrollLeft;return e?e.left+t:au(Zo(n)).left+t}function Q6(n,e,t){t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=r.left+e.scrollLeft-(t?0:x_(n,r)),i=r.top+e.scrollTop;return{x:s,y:i}}function uce(n){let{elements:e,rect:t,offsetParent:r,strategy:s}=n;const i=s==="fixed",o=Zo(r),a=e?mv(e.floating):!1;if(r===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=Fo(1);const u=Fo(0),h=Ko(r);if((h||!h&&!i)&&((yh(r)!=="body"||ng(o))&&(l=yv(r)),Ko(r))){const m=au(r);c=Ld(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const p=o&&!h&&!i?Q6(o,l,!0):Fo(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+p.x,y:t.y*c.y-l.scrollTop*c.y+u.y+p.y}}function dce(n){return Array.from(n.getClientRects())}function hce(n){const e=Zo(n),t=yv(n),r=n.ownerDocument.body,s=Bs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Bs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+x_(n);const a=-t.scrollTop;return io(r).direction==="rtl"&&(o+=Bs(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:a}}function fce(n,e){const t=Xs(n),r=Zo(n),s=t.visualViewport;let i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=S_();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}function pce(n,e){const t=au(n,!0,e==="fixed"),r=t.top+n.clientTop,s=t.left+n.clientLeft,i=Ko(n)?Ld(n):Fo(1),o=n.clientWidth*i.x,a=n.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function vL(n,e,t){let r;if(e==="viewport")r=fce(n,t);else if(e==="document")r=hce(Zo(n));else if(so(e))r=pce(e,t);else{const s=J6(n);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return MS(r)}function e8(n,e){const t=Xl(n);return t===e||!so(t)||Xd(t)?!1:io(t).position==="fixed"||e8(t,e)}function gce(n,e){const t=e.get(n);if(t)return t;let r=xp(n,[],!1).filter(a=>so(a)&&yh(a)!=="body"),s=null;const i=io(n).position==="fixed";let o=i?Xl(n):n;for(;so(o)&&!Xd(o);){const a=io(o),l=y_(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ng(o)&&!l&&e8(n,o))?r=r.filter(u=>u!==o):s=a,o=Xl(o)}return e.set(n,r),r}function mce(n){let{element:e,boundary:t,rootBoundary:r,strategy:s}=n;const o=[...t==="clippingAncestors"?mv(e)?[]:gce(e,this._c):[].concat(t),r],a=o[0],l=o.reduce((c,u)=>{const h=vL(e,u,s);return c.top=Bs(h.top,c.top),c.right=Yl(h.right,c.right),c.bottom=Yl(h.bottom,c.bottom),c.left=Bs(h.left,c.left),c},vL(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function yce(n){const{width:e,height:t}=Z6(n);return{width:e,height:t}}function Sce(n,e,t){const r=Ko(e),s=Zo(e),i=t==="fixed",o=au(n,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=Fo(0);function c(){l.x=x_(s)}if(r||!r&&!i)if((yh(e)!=="body"||ng(s))&&(a=yv(e)),r){const m=au(e,!0,i,e);l.x=m.x+e.clientLeft,l.y=m.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?Q6(s,a):Fo(0),h=o.left+a.scrollLeft-l.x-u.x,p=o.top+a.scrollTop-l.y-u.y;return{x:h,y:p,width:o.width,height:o.height}}function MC(n){return io(n).position==="static"}function xL(n,e){if(!Ko(n)||io(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Zo(n)===t&&(t=t.ownerDocument.body),t}function t8(n,e){const t=Xs(n);if(mv(n))return t;if(!Ko(n)){let s=Xl(n);for(;s&&!Xd(s);){if(so(s)&&!MC(s))return s;s=Xl(s)}return t}let r=xL(n,e);for(;r&&oce(r)&&MC(r);)r=xL(r,e);return r&&Xd(r)&&MC(r)&&!y_(r)?t:r||ace(n)||t}const vce=async function(n){const e=this.getOffsetParent||t8,t=this.getDimensions,r=await t(n.floating);return{reference:Sce(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xce(n){return io(n).direction==="rtl"}const wce={convertOffsetParentRelativeRectToViewportRelativeRect:uce,getDocumentElement:Zo,getClippingRect:mce,getOffsetParent:t8,getElementRects:vce,getClientRects:dce,getDimensions:yce,getScale:Ld,isElement:so,isRTL:xce};function n8(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function bce(n,e){let t=null,r;const s=Zo(n);function i(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=n.getBoundingClientRect(),{left:u,top:h,width:p,height:m}=c;if(a||e(),!p||!m)return;const S=Fm(h),x=Fm(s.clientWidth-(u+p)),v=Fm(s.clientHeight-(h+m)),w=Fm(u),_={rootMargin:-S+"px "+-x+"px "+-v+"px "+-w+"px",threshold:Bs(0,Yl(1,l))||1};let E=!0;function T(A){const O=A[0].intersectionRatio;if(O!==l){if(!E)return o();O?o(!1,O):r=setTimeout(()=>{o(!1,1e-7)},1e3)}O===1&&!n8(c,n.getBoundingClientRect())&&o(),E=!1}try{t=new IntersectionObserver(T,{..._,root:s.ownerDocument})}catch{t=new IntersectionObserver(T,_)}t.observe(n)}return o(!0),i}function Cce(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=v_(n),u=s||i?[...c?xp(c):[],...xp(e)]:[];u.forEach(w=>{s&&w.addEventListener("scroll",t,{passive:!0}),i&&w.addEventListener("resize",t)});const h=c&&a?bce(c,t):null;let p=-1,m=null;o&&(m=new ResizeObserver(w=>{let[C]=w;C&&C.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var _;(_=m)==null||_.observe(e)})),t()}),c&&!l&&m.observe(c),m.observe(e));let S,x=l?au(n):null;l&&v();function v(){const w=au(n);x&&!n8(x,w)&&t(),x=w,S=requestAnimationFrame(v)}return t(),()=>{var w;u.forEach(C=>{s&&C.removeEventListener("scroll",t),i&&C.removeEventListener("resize",t)}),h==null||h(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(S)}}const Pce=nce,kce=rce,Ice=Qle,Ece=ice,_ce=ece,wL=Jle,Tce=sce,Mce=(n,e,t)=>{const r=new Map,s={platform:wce,...t},i={...s.platform,_c:r};return Zle(n,e,{...s,platform:i})};var xy=typeof document<"u"?P.useLayoutEffect:P.useEffect;function AS(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!AS(n[r],e[r]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=t;r--!==0;){const i=s[r];if(!(i==="_owner"&&n.$$typeof)&&!AS(n[i],e[i]))return!1}return!0}return n!==n&&e!==e}function r8(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function bL(n,e){const t=r8(n);return Math.round(e*t)/t}function AC(n){const e=P.useRef(n);return xy(()=>{e.current=n}),e}function Ace(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,h]=P.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[p,m]=P.useState(r);AS(p,r)||m(r);const[S,x]=P.useState(null),[v,w]=P.useState(null),C=P.useCallback(z=>{z!==A.current&&(A.current=z,x(z))},[]),_=P.useCallback(z=>{z!==O.current&&(O.current=z,w(z))},[]),E=i||S,T=o||v,A=P.useRef(null),O=P.useRef(null),D=P.useRef(u),$=l!=null,H=AC(l),G=AC(s),J=AC(c),L=P.useCallback(()=>{if(!A.current||!O.current)return;const z={placement:e,strategy:t,middleware:p};G.current&&(z.platform=G.current),Mce(A.current,O.current,z).then(V=>{const ee={...V,isPositioned:J.current!==!1};N.current&&!AS(D.current,ee)&&(D.current=ee,hh.flushSync(()=>{h(ee)}))})},[p,e,t,G,J]);xy(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,h(z=>({...z,isPositioned:!1})))},[c]);const N=P.useRef(!1);xy(()=>(N.current=!0,()=>{N.current=!1}),[]),xy(()=>{if(E&&(A.current=E),T&&(O.current=T),E&&T){if(H.current)return H.current(E,T,L);L()}},[E,T,L,H,$]);const U=P.useMemo(()=>({reference:A,floating:O,setReference:C,setFloating:_}),[C,_]),Y=P.useMemo(()=>({reference:E,floating:T}),[E,T]),W=P.useMemo(()=>{const z={position:t,left:0,top:0};if(!Y.floating)return z;const V=bL(Y.floating,u.x),ee=bL(Y.floating,u.y);return a?{...z,transform:"translate("+V+"px, "+ee+"px)",...r8(Y.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:V,top:ee}},[t,a,Y.floating,u.x,u.y]);return P.useMemo(()=>({...u,update:L,refs:U,elements:Y,floatingStyles:W}),[u,L,U,Y,W])}const Oce=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:s}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?wL({element:r.current,padding:s}).fn(t):{}:r?wL({element:r,padding:s}).fn(t):{}}}},Rce=(n,e)=>({...Pce(n),options:[n,e]}),Dce=(n,e)=>({...kce(n),options:[n,e]}),jce=(n,e)=>({...Tce(n),options:[n,e]}),Lce=(n,e)=>({...Ice(n),options:[n,e]}),Nce=(n,e)=>({...Ece(n),options:[n,e]}),Fce=(n,e)=>({..._ce(n),options:[n,e]}),zce=(n,e)=>({...Oce(n),options:[n,e]});var $ce="Arrow",s8=P.forwardRef((n,e)=>{const{children:t,width:r=10,height:s=5,...i}=n;return g.jsx(vt.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});s8.displayName=$ce;var Bce=s8;function i8(n){const[e,t]=P.useState(void 0);return Fa(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=n.offsetWidth,a=n.offsetHeight;t({width:o,height:a})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}var w_="Popper",[o8,Sv]=Xo(w_),[Uce,a8]=o8(w_),l8=n=>{const{__scopePopper:e,children:t}=n,[r,s]=P.useState(null);return g.jsx(Uce,{scope:e,anchor:r,onAnchorChange:s,children:t})};l8.displayName=w_;var c8="PopperAnchor",u8=P.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...s}=n,i=a8(c8,t),o=P.useRef(null),a=jt(e,o);return P.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:g.jsx(vt.div,{...s,ref:a})});u8.displayName=c8;var b_="PopperContent",[Hce,Kce]=o8(b_),d8=P.forwardRef((n,e)=>{var Ne,be,Ee,Ke,Lt,Jt;const{__scopePopper:t,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:S,...x}=n,v=a8(b_,t),[w,C]=P.useState(null),_=jt(e,Et=>C(Et)),[E,T]=P.useState(null),A=i8(E),O=(A==null?void 0:A.width)??0,D=(A==null?void 0:A.height)??0,$=r+(i!=="center"?"-"+i:""),H=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},G=Array.isArray(c)?c:[c],J=G.length>0,L={padding:H,boundary:G.filter(Vce),altBoundary:J},{refs:N,floatingStyles:U,placement:Y,isPositioned:W,middlewareData:z}=Ace({strategy:"fixed",placement:$,whileElementsMounted:(...Et)=>Cce(...Et,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[Rce({mainAxis:s+D,alignmentAxis:o}),l&&Dce({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?jce():void 0,...L}),l&&Lce({...L}),Nce({...L,apply:({elements:Et,rects:Tt,availableWidth:nn,availableHeight:In})=>{const{width:rs,height:ss}=Tt.reference,is=Et.floating.style;is.setProperty("--radix-popper-available-width",`${nn}px`),is.setProperty("--radix-popper-available-height",`${In}px`),is.setProperty("--radix-popper-anchor-width",`${rs}px`),is.setProperty("--radix-popper-anchor-height",`${ss}px`)}}),E&&zce({element:E,padding:a}),qce({arrowWidth:O,arrowHeight:D}),p&&Fce({strategy:"referenceHidden",...L})]}),[V,ee]=p8(Y),B=Xr(S);Fa(()=>{W&&(B==null||B())},[W,B]);const Q=(Ne=z.arrow)==null?void 0:Ne.x,me=(be=z.arrow)==null?void 0:be.y,Pe=((Ee=z.arrow)==null?void 0:Ee.centerOffset)!==0,[ue,Oe]=P.useState();return Fa(()=>{w&&Oe(window.getComputedStyle(w).zIndex)},[w]),g.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:W?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(Ke=z.transformOrigin)==null?void 0:Ke.x,(Lt=z.transformOrigin)==null?void 0:Lt.y].join(" "),...((Jt=z.hide)==null?void 0:Jt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:g.jsx(Hce,{scope:t,placedSide:V,onArrowChange:T,arrowX:Q,arrowY:me,shouldHideArrow:Pe,children:g.jsx(vt.div,{"data-side":V,"data-align":ee,...x,ref:_,style:{...x.style,animation:W?void 0:"none"}})})})});d8.displayName=b_;var h8="PopperArrow",Wce={top:"bottom",right:"left",bottom:"top",left:"right"},f8=P.forwardRef(function(e,t){const{__scopePopper:r,...s}=e,i=Kce(h8,r),o=Wce[i.placedSide];return g.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:g.jsx(Bce,{...s,ref:t,style:{...s.style,display:"block"}})})});f8.displayName=h8;function Vce(n){return n!==null}var qce=n=>({name:"transformOrigin",options:n,fn(e){var v,w,C;const{placement:t,rects:r,middlewareData:s}=e,o=((v=s.arrow)==null?void 0:v.centerOffset)!==0,a=o?0:n.arrowWidth,l=o?0:n.arrowHeight,[c,u]=p8(t),h={start:"0%",center:"50%",end:"100%"}[u],p=(((w=s.arrow)==null?void 0:w.x)??0)+a/2,m=(((C=s.arrow)==null?void 0:C.y)??0)+l/2;let S="",x="";return c==="bottom"?(S=o?h:`${p}px`,x=`${-l}px`):c==="top"?(S=o?h:`${p}px`,x=`${r.floating.height+l}px`):c==="right"?(S=`${-l}px`,x=o?h:`${m}px`):c==="left"&&(S=`${r.floating.width+l}px`,x=o?h:`${m}px`),{data:{x:S,y:x}}}});function p8(n){const[e,t="center"]=n.split("-");return[e,t]}var C_=l8,P_=u8,g8=d8,m8=f8,Gce="Portal",rg=P.forwardRef((n,e)=>{var a;const{container:t,...r}=n,[s,i]=P.useState(!1);Fa(()=>i(!0),[]);const o=t||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?Ase.createPortal(g.jsx(vt.div,{...r,ref:e}),o):null});rg.displayName=Gce;function Yce(n,e){return P.useReducer((t,r)=>e[t][r]??t,n)}var lo=n=>{const{present:e,children:t}=n,r=Xce(e),s=typeof t=="function"?t({present:r.isPresent}):P.Children.only(t),i=jt(r.ref,Zce(s));return typeof t=="function"||r.isPresent?P.cloneElement(s,{ref:i}):null};lo.displayName="Presence";function Xce(n){const[e,t]=P.useState(),r=P.useRef(null),s=P.useRef(n),i=P.useRef("none"),o=n?"mounted":"unmounted",[a,l]=Yce(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return P.useEffect(()=>{const c=zm(r.current);i.current=a==="mounted"?c:"none"},[a]),Fa(()=>{const c=r.current,u=s.current;if(u!==n){const p=i.current,m=zm(c);n?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=n}},[n,l]),Fa(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,h=m=>{const x=zm(r.current).includes(m.animationName);if(m.target===e&&x&&(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)})}},p=m=>{m.target===e&&(i.current=zm(r.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:P.useCallback(c=>{r.current=c?getComputedStyle(c):null,t(c)},[])}}function zm(n){return(n==null?void 0:n.animationName)||"none"}function Zce(n){var r,s;let e=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var Jce=HN[" useInsertionEffect ".trim().toString()]||Fa;function sc({prop:n,defaultProp:e,onChange:t=()=>{},caller:r}){const[s,i,o]=Qce({defaultProp:e,onChange:t}),a=n!==void 0,l=a?n:s;{const u=P.useRef(n!==void 0);P.useEffect(()=>{const h=u.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=P.useCallback(u=>{var h;if(a){const p=eue(u)?u(n):u;p!==n&&((h=o.current)==null||h.call(o,p))}else i(u)},[a,n,i,o]);return[l,c]}function Qce({defaultProp:n,onChange:e}){const[t,r]=P.useState(n),s=P.useRef(t),i=P.useRef(e);return Jce(()=>{i.current=e},[e]),P.useEffect(()=>{var o;s.current!==t&&((o=i.current)==null||o.call(i,t),s.current=t)},[t,s]),[t,r,i]}function eue(n){return typeof n=="function"}var OC="rovingFocusGroup.onEntryFocus",tue={bubbles:!1,cancelable:!0},sg="RovingFocusGroup",[Ok,y8,nue]=fv(sg),[rue,S8]=Xo(sg,[nue]),[sue,iue]=rue(sg),v8=P.forwardRef((n,e)=>g.jsx(Ok.Provider,{scope:n.__scopeRovingFocusGroup,children:g.jsx(Ok.Slot,{scope:n.__scopeRovingFocusGroup,children:g.jsx(oue,{...n,ref:e})})}));v8.displayName=sg;var oue=P.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,orientation:r,loop:s=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...h}=n,p=P.useRef(null),m=jt(e,p),S=h_(i),[x,v]=sc({prop:o,defaultProp:a??null,onChange:l,caller:sg}),[w,C]=P.useState(!1),_=Xr(c),E=y8(t),T=P.useRef(!1),[A,O]=P.useState(0);return P.useEffect(()=>{const D=p.current;if(D)return D.addEventListener(OC,_),()=>D.removeEventListener(OC,_)},[_]),g.jsx(sue,{scope:t,orientation:r,dir:S,loop:s,currentTabStopId:x,onItemFocus:P.useCallback(D=>v(D),[v]),onItemShiftTab:P.useCallback(()=>C(!0),[]),onFocusableItemAdd:P.useCallback(()=>O(D=>D+1),[]),onFocusableItemRemove:P.useCallback(()=>O(D=>D-1),[]),children:g.jsx(vt.div,{tabIndex:w||A===0?-1:0,"data-orientation":r,...h,ref:m,style:{outline:"none",...n.style},onMouseDown:je(n.onMouseDown,()=>{T.current=!0}),onFocus:je(n.onFocus,D=>{const $=!T.current;if(D.target===D.currentTarget&&$&&!w){const H=new CustomEvent(OC,tue);if(D.currentTarget.dispatchEvent(H),!H.defaultPrevented){const G=E().filter(Y=>Y.focusable),J=G.find(Y=>Y.active),L=G.find(Y=>Y.id===x),U=[J,L,...G].filter(Boolean).map(Y=>Y.ref.current);b8(U,u)}}T.current=!1}),onBlur:je(n.onBlur,()=>C(!1))})})}),x8="RovingFocusGroupItem",w8=P.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,focusable:r=!0,active:s=!1,tabStopId:i,children:o,...a}=n,l=Ra(),c=i||l,u=iue(x8,t),h=u.currentTabStopId===c,p=y8(t),{onFocusableItemAdd:m,onFocusableItemRemove:S,currentTabStopId:x}=u;return P.useEffect(()=>{if(r)return m(),()=>S()},[r,m,S]),g.jsx(Ok.ItemSlot,{scope:t,id:c,focusable:r,active:s,children:g.jsx(vt.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:je(n.onMouseDown,v=>{r?u.onItemFocus(c):v.preventDefault()}),onFocus:je(n.onFocus,()=>u.onItemFocus(c)),onKeyDown:je(n.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=cue(v,u.orientation,u.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let _=p().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")_.reverse();else if(w==="prev"||w==="next"){w==="prev"&&_.reverse();const E=_.indexOf(v.currentTarget);_=u.loop?uue(_,E+1):_.slice(E+1)}setTimeout(()=>b8(_))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});w8.displayName=x8;var aue={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lue(n,e){return e!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function cue(n,e,t){const r=lue(n.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return aue[r]}function b8(n,e=!1){const t=document.activeElement;for(const r of n)if(r===t||(r.focus({preventScroll:e}),document.activeElement!==t))return}function uue(n,e){return n.map((t,r)=>n[(e+r)%n.length])}var due=v8,hue=w8,fue=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},fd=new WeakMap,$m=new WeakMap,Bm={},RC=0,C8=function(n){return n&&(n.host||C8(n.parentNode))},pue=function(n,e){return e.map(function(t){if(n.contains(t))return t;var r=C8(t);return r&&n.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},gue=function(n,e,t,r){var s=pue(e,Array.isArray(n)?n:[n]);Bm[t]||(Bm[t]=new WeakMap);var i=Bm[t],o=[],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(p){if(a.has(p))u(p);else try{var m=p.getAttribute(r),S=m!==null&&m!=="false",x=(fd.get(p)||0)+1,v=(i.get(p)||0)+1;fd.set(p,x),i.set(p,v),o.push(p),x===1&&S&&$m.set(p,!0),v===1&&p.setAttribute(t,"true"),S||p.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return u(e),a.clear(),RC++,function(){o.forEach(function(h){var p=fd.get(h)-1,m=i.get(h)-1;fd.set(h,p),i.set(h,m),p||($m.has(h)||h.removeAttribute(r),$m.delete(h)),m||h.removeAttribute(t)}),RC--,RC||(fd=new WeakMap,fd=new WeakMap,$m=new WeakMap,Bm={})}},k_=function(n,e,t){t===void 0&&(t="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),s=fue(n);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live]"))),gue(r,s,t,"aria-hidden")):function(){return null}},Oo=function(){return Oo=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Oo.apply(this,arguments)};function P8(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function mue(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}var wy="right-scroll-bar-position",by="width-before-scroll-bar",yue="with-scroll-bars-hidden",Sue="--removed-body-scroll-bar-size";function DC(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function vue(n,e){var t=P.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(r){var s=t.value;s!==r&&(t.value=r,t.callback(r,s))}}}})[0];return t.callback=e,t.facade}var xue=typeof window<"u"?P.useLayoutEffect:P.useEffect,CL=new WeakMap;function wue(n,e){var t=vue(null,function(r){return n.forEach(function(s){return DC(s,r)})});return xue(function(){var r=CL.get(t);if(r){var s=new Set(r),i=new Set(n),o=t.current;s.forEach(function(a){i.has(a)||DC(a,null)}),i.forEach(function(a){s.has(a)||DC(a,o)})}CL.set(t,n)},[n]),t}function bue(n){return n}function Cue(n,e){e===void 0&&(e=bue);var t=[],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 t.length?t[t.length-1]:n},useMedium:function(i){var o=e(i,r);return t.push(o),function(){t=t.filter(function(a){return a!==o})}},assignSyncMedium:function(i){for(r=!0;t.length;){var o=t;t=[],o.forEach(i)}t={push:function(a){return i(a)},filter:function(){return t}}},assignMedium:function(i){r=!0;var o=[];if(t.length){var a=t;t=[],a.forEach(i),o=t}var l=function(){var u=o;o=[],u.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),t={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),t}}}};return s}function Pue(n){n===void 0&&(n={});var e=Cue(null);return e.options=Oo({async:!0,ssr:!1},n),e}var k8=function(n){var e=n.sideCar,t=P8(n,["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 P.createElement(r,Oo({},t))};k8.isSideCarExport=!0;function kue(n,e){return n.useMedium(e),k8}var I8=Pue(),jC=function(){},vv=P.forwardRef(function(n,e){var t=P.useRef(null),r=P.useState({onScrollCapture:jC,onWheelCapture:jC,onTouchMoveCapture:jC}),s=r[0],i=r[1],o=n.forwardProps,a=n.children,l=n.className,c=n.removeScrollBar,u=n.enabled,h=n.shards,p=n.sideCar,m=n.noIsolation,S=n.inert,x=n.allowPinchZoom,v=n.as,w=v===void 0?"div":v,C=n.gapMode,_=P8(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=p,T=wue([t,e]),A=Oo(Oo({},_),s);return P.createElement(P.Fragment,null,u&&P.createElement(E,{sideCar:I8,removeScrollBar:c,shards:h,noIsolation:m,inert:S,setCallbacks:i,allowPinchZoom:!!x,lockRef:t,gapMode:C}),o?P.cloneElement(P.Children.only(a),Oo(Oo({},A),{ref:T})):P.createElement(w,Oo({},A,{className:l,ref:T}),a))});vv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};vv.classNames={fullWidth:by,zeroRight:wy};var Iue=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Eue(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=Iue();return e&&n.setAttribute("nonce",e),n}function _ue(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function Tue(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var Mue=function(){var n=0,e=null;return{add:function(t){n==0&&(e=Eue())&&(_ue(e,t),Tue(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Aue=function(){var n=Mue();return function(e,t){P.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},E8=function(){var n=Aue(),e=function(t){var r=t.styles,s=t.dynamic;return n(r,s),null};return e},Oue={left:0,top:0,right:0,gap:0},LC=function(n){return parseInt(n||"",10)||0},Rue=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],r=e[n==="padding"?"paddingTop":"marginTop"],s=e[n==="padding"?"paddingRight":"marginRight"];return[LC(t),LC(r),LC(s)]},Due=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return Oue;var e=Rue(n),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-t+e[2]-e[0])}},jue=E8(),Nd="data-scroll-locked",Lue=function(n,e,t,r){var s=n.left,i=n.top,o=n.right,a=n.gap;return t===void 0&&(t="margin"),`
|
|
307
|
-
.`.concat(yue,` {
|
|
308
|
-
overflow: hidden `).concat(r,`;
|
|
309
|
-
padding-right: `).concat(a,"px ").concat(r,`;
|
|
310
|
-
}
|
|
311
|
-
body[`).concat(Nd,`] {
|
|
312
|
-
overflow: hidden `).concat(r,`;
|
|
313
|
-
overscroll-behavior: contain;
|
|
314
|
-
`).concat([e&&"position: relative ".concat(r,";"),t==="margin"&&`
|
|
315
|
-
padding-left: `.concat(s,`px;
|
|
316
|
-
padding-top: `).concat(i,`px;
|
|
317
|
-
padding-right: `).concat(o,`px;
|
|
318
|
-
margin-left:0;
|
|
319
|
-
margin-top:0;
|
|
320
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
321
|
-
`),t==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.`).concat(wy,` {
|
|
325
|
-
right: `).concat(a,"px ").concat(r,`;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.`).concat(by,` {
|
|
329
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.`).concat(wy," .").concat(wy,` {
|
|
333
|
-
right: 0 `).concat(r,`;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
.`).concat(by," .").concat(by,` {
|
|
337
|
-
margin-right: 0 `).concat(r,`;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
body[`).concat(Nd,`] {
|
|
341
|
-
`).concat(Sue,": ").concat(a,`px;
|
|
342
|
-
}
|
|
343
|
-
`)},PL=function(){var n=parseInt(document.body.getAttribute(Nd)||"0",10);return isFinite(n)?n:0},Nue=function(){P.useEffect(function(){return document.body.setAttribute(Nd,(PL()+1).toString()),function(){var n=PL()-1;n<=0?document.body.removeAttribute(Nd):document.body.setAttribute(Nd,n.toString())}},[])},Fue=function(n){var e=n.noRelative,t=n.noImportant,r=n.gapMode,s=r===void 0?"margin":r;Nue();var i=P.useMemo(function(){return Due(s)},[s]);return P.createElement(jue,{styles:Lue(i,!e,s,t?"":"!important")})},Rk=!1;if(typeof window<"u")try{var Um=Object.defineProperty({},"passive",{get:function(){return Rk=!0,!0}});window.addEventListener("test",Um,Um),window.removeEventListener("test",Um,Um)}catch{Rk=!1}var pd=Rk?{passive:!1}:!1,zue=function(n){return n.tagName==="TEXTAREA"},_8=function(n,e){if(!(n instanceof Element))return!1;var t=window.getComputedStyle(n);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!zue(n)&&t[e]==="visible")},$ue=function(n){return _8(n,"overflowY")},Bue=function(n){return _8(n,"overflowX")},kL=function(n,e){var t=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=T8(n,r);if(s){var i=M8(n,r),o=i[1],a=i[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==t.body);return!1},Uue=function(n){var e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;return[e,t,r]},Hue=function(n){var e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;return[e,t,r]},T8=function(n,e){return n==="v"?$ue(e):Bue(e)},M8=function(n,e){return n==="v"?Uue(e):Hue(e)},Kue=function(n,e){return n==="h"&&e==="rtl"?-1:1},Wue=function(n,e,t,r,s){var i=Kue(n,window.getComputedStyle(e).direction),o=i*r,a=t.target,l=e.contains(a),c=!1,u=o>0,h=0,p=0;do{var m=M8(n,a),S=m[0],x=m[1],v=m[2],w=x-v-i*S;(S||w)&&T8(n,a)&&(h+=w,p+=S),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(p)<1)&&(c=!0),c},Hm=function(n){return"changedTouches"in n?[n.changedTouches[0].clientX,n.changedTouches[0].clientY]:[0,0]},IL=function(n){return[n.deltaX,n.deltaY]},EL=function(n){return n&&"current"in n?n.current:n},Vue=function(n,e){return n[0]===e[0]&&n[1]===e[1]},que=function(n){return`
|
|
344
|
-
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
|
345
|
-
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
|
346
|
-
`)},Gue=0,gd=[];function Yue(n){var e=P.useRef([]),t=P.useRef([0,0]),r=P.useRef(),s=P.useState(Gue++)[0],i=P.useState(E8)[0],o=P.useRef(n);P.useEffect(function(){o.current=n},[n]),P.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(s));var x=mue([n.lockRef.current],(n.shards||[]).map(EL),!0).filter(Boolean);return x.forEach(function(v){return v.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),x.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(s))})}}},[n.inert,n.lockRef.current,n.shards]);var a=P.useCallback(function(x,v){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var w=Hm(x),C=t.current,_="deltaX"in x?x.deltaX:C[0]-w[0],E="deltaY"in x?x.deltaY:C[1]-w[1],T,A=x.target,O=Math.abs(_)>Math.abs(E)?"h":"v";if("touches"in x&&O==="h"&&A.type==="range")return!1;var D=kL(O,A);if(!D)return!0;if(D?T=O:(T=O==="v"?"h":"v",D=kL(O,A)),!D)return!1;if(!r.current&&"changedTouches"in x&&(_||E)&&(r.current=T),!T)return!0;var $=r.current||T;return Wue($,v,x,$==="h"?_:E)},[]),l=P.useCallback(function(x){var v=x;if(!(!gd.length||gd[gd.length-1]!==i)){var w="deltaY"in v?IL(v):Hm(v),C=e.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&Vue(T.delta,w)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var _=(o.current.shards||[]).map(EL).filter(Boolean).filter(function(T){return T.contains(v.target)}),E=_.length>0?a(v,_[0]):!o.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),c=P.useCallback(function(x,v,w,C){var _={name:x,delta:v,target:w,should:C,shadowParent:Xue(w)};e.current.push(_),setTimeout(function(){e.current=e.current.filter(function(E){return E!==_})},1)},[]),u=P.useCallback(function(x){t.current=Hm(x),r.current=void 0},[]),h=P.useCallback(function(x){c(x.type,IL(x),x.target,a(x,n.lockRef.current))},[]),p=P.useCallback(function(x){c(x.type,Hm(x),x.target,a(x,n.lockRef.current))},[]);P.useEffect(function(){return gd.push(i),n.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",l,pd),document.addEventListener("touchmove",l,pd),document.addEventListener("touchstart",u,pd),function(){gd=gd.filter(function(x){return x!==i}),document.removeEventListener("wheel",l,pd),document.removeEventListener("touchmove",l,pd),document.removeEventListener("touchstart",u,pd)}},[]);var m=n.removeScrollBar,S=n.inert;return P.createElement(P.Fragment,null,S?P.createElement(i,{styles:que(s)}):null,m?P.createElement(Fue,{gapMode:n.gapMode}):null)}function Xue(n){for(var e=null;n!==null;)n instanceof ShadowRoot&&(e=n.host,n=n.host),n=n.parentNode;return e}const Zue=kue(I8,Yue);var xv=P.forwardRef(function(n,e){return P.createElement(vv,Oo({},n,{ref:e,sideCar:Zue}))});xv.classNames=vv.classNames;var Dk=["Enter"," "],Jue=["ArrowDown","PageUp","Home"],A8=["ArrowUp","PageDown","End"],Que=[...Jue,...A8],ede={ltr:[...Dk,"ArrowRight"],rtl:[...Dk,"ArrowLeft"]},tde={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ig="Menu",[wp,nde,rde]=fv(ig),[wu,wv]=Xo(ig,[rde,Sv,S8]),og=Sv(),O8=S8(),[R8,ic]=wu(ig),[sde,ag]=wu(ig),D8=n=>{const{__scopeMenu:e,open:t=!1,children:r,dir:s,onOpenChange:i,modal:o=!0}=n,a=og(e),[l,c]=P.useState(null),u=P.useRef(!1),h=Xr(i),p=h_(s);return P.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),g.jsx(C_,{...a,children:g.jsx(R8,{scope:e,open:t,onOpenChange:h,content:l,onContentChange:c,children:g.jsx(sde,{scope:e,onClose:P.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:p,modal:o,children:r})})})};D8.displayName=ig;var ide="MenuAnchor",I_=P.forwardRef((n,e)=>{const{__scopeMenu:t,...r}=n,s=og(t);return g.jsx(P_,{...s,...r,ref:e})});I_.displayName=ide;var E_="MenuPortal",[ode,j8]=wu(E_,{forceMount:void 0}),L8=n=>{const{__scopeMenu:e,forceMount:t,children:r,container:s}=n,i=ic(E_,e);return g.jsx(ode,{scope:e,forceMount:t,children:g.jsx(lo,{present:t||i.open,children:g.jsx(rg,{asChild:!0,container:s,children:r})})})};L8.displayName=E_;var Ii="MenuContent",[ade,__]=wu(Ii),N8=P.forwardRef((n,e)=>{const t=j8(Ii,n.__scopeMenu),{forceMount:r=t.forceMount,...s}=n,i=ic(Ii,n.__scopeMenu),o=ag(Ii,n.__scopeMenu);return g.jsx(wp.Provider,{scope:n.__scopeMenu,children:g.jsx(lo,{present:r||i.open,children:g.jsx(wp.Slot,{scope:n.__scopeMenu,children:o.modal?g.jsx(lde,{...s,ref:e}):g.jsx(cde,{...s,ref:e})})})})}),lde=P.forwardRef((n,e)=>{const t=ic(Ii,n.__scopeMenu),r=P.useRef(null),s=jt(e,r);return P.useEffect(()=>{const i=r.current;if(i)return k_(i)},[]),g.jsx(T_,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:je(n.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)})}),cde=P.forwardRef((n,e)=>{const t=ic(Ii,n.__scopeMenu);return g.jsx(T_,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)})}),ude=Yd("MenuContent.ScrollLock"),T_=P.forwardRef((n,e)=>{const{__scopeMenu:t,loop:r=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:p,onDismiss:m,disableOutsideScroll:S,...x}=n,v=ic(Ii,t),w=ag(Ii,t),C=og(t),_=O8(t),E=nde(t),[T,A]=P.useState(null),O=P.useRef(null),D=jt(e,O,v.onContentChange),$=P.useRef(0),H=P.useRef(""),G=P.useRef(0),J=P.useRef(null),L=P.useRef("right"),N=P.useRef(0),U=S?xv:P.Fragment,Y=S?{as:ude,allowPinchZoom:!0}:void 0,W=V=>{var Ne,be;const ee=H.current+V,B=E().filter(Ee=>!Ee.disabled),Q=document.activeElement,me=(Ne=B.find(Ee=>Ee.ref.current===Q))==null?void 0:Ne.textValue,Pe=B.map(Ee=>Ee.textValue),ue=bde(Pe,ee,me),Oe=(be=B.find(Ee=>Ee.textValue===ue))==null?void 0:be.ref.current;(function Ee(Ke){H.current=Ke,window.clearTimeout($.current),Ke!==""&&($.current=window.setTimeout(()=>Ee(""),1e3))})(ee),Oe&&setTimeout(()=>Oe.focus())};P.useEffect(()=>()=>window.clearTimeout($.current),[]),f_();const z=P.useCallback(V=>{var B,Q;return L.current===((B=J.current)==null?void 0:B.side)&&Pde(V,(Q=J.current)==null?void 0:Q.area)},[]);return g.jsx(ade,{scope:t,searchRef:H,onItemEnter:P.useCallback(V=>{z(V)&&V.preventDefault()},[z]),onItemLeave:P.useCallback(V=>{var ee;z(V)||((ee=O.current)==null||ee.focus(),A(null))},[z]),onTriggerLeave:P.useCallback(V=>{z(V)&&V.preventDefault()},[z]),pointerGraceTimerRef:G,onPointerGraceIntentChange:P.useCallback(V=>{J.current=V},[]),children:g.jsx(U,{...Y,children:g.jsx(pv,{asChild:!0,trapped:s,onMountAutoFocus:je(i,V=>{var ee;V.preventDefault(),(ee=O.current)==null||ee.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx(tg,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:p,onDismiss:m,children:g.jsx(due,{asChild:!0,..._,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:A,onEntryFocus:je(l,V=>{w.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(g8,{role:"menu","aria-orientation":"vertical","data-state":e9(v.open),"data-radix-menu-content":"",dir:w.dir,...C,...x,ref:D,style:{outline:"none",...x.style},onKeyDown:je(x.onKeyDown,V=>{const B=V.target.closest("[data-radix-menu-content]")===V.currentTarget,Q=V.ctrlKey||V.altKey||V.metaKey,me=V.key.length===1;B&&(V.key==="Tab"&&V.preventDefault(),!Q&&me&&W(V.key));const Pe=O.current;if(V.target!==Pe||!Que.includes(V.key))return;V.preventDefault();const Oe=E().filter(Ne=>!Ne.disabled).map(Ne=>Ne.ref.current);A8.includes(V.key)&&Oe.reverse(),xde(Oe)}),onBlur:je(n.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout($.current),H.current="")}),onPointerMove:je(n.onPointerMove,bp(V=>{const ee=V.target,B=N.current!==V.clientX;if(V.currentTarget.contains(ee)&&B){const Q=V.clientX>N.current?"right":"left";L.current=Q,N.current=V.clientX}}))})})})})})})});N8.displayName=Ii;var dde="MenuGroup",M_=P.forwardRef((n,e)=>{const{__scopeMenu:t,...r}=n;return g.jsx(vt.div,{role:"group",...r,ref:e})});M_.displayName=dde;var hde="MenuLabel",F8=P.forwardRef((n,e)=>{const{__scopeMenu:t,...r}=n;return g.jsx(vt.div,{...r,ref:e})});F8.displayName=hde;var OS="MenuItem",_L="menu.itemSelect",bv=P.forwardRef((n,e)=>{const{disabled:t=!1,onSelect:r,...s}=n,i=P.useRef(null),o=ag(OS,n.__scopeMenu),a=__(OS,n.__scopeMenu),l=jt(e,i),c=P.useRef(!1),u=()=>{const h=i.current;if(!t&&h){const p=new CustomEvent(_L,{bubbles:!0,cancelable:!0});h.addEventListener(_L,m=>r==null?void 0:r(m),{once:!0}),d_(h,p),p.defaultPrevented?c.current=!1:o.onClose()}};return g.jsx(z8,{...s,ref:l,disabled:t,onClick:je(n.onClick,u),onPointerDown:h=>{var p;(p=n.onPointerDown)==null||p.call(n,h),c.current=!0},onPointerUp:je(n.onPointerUp,h=>{var p;c.current||(p=h.currentTarget)==null||p.click()}),onKeyDown:je(n.onKeyDown,h=>{const p=a.searchRef.current!=="";t||p&&h.key===" "||Dk.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});bv.displayName=OS;var z8=P.forwardRef((n,e)=>{const{__scopeMenu:t,disabled:r=!1,textValue:s,...i}=n,o=__(OS,t),a=O8(t),l=P.useRef(null),c=jt(e,l),[u,h]=P.useState(!1),[p,m]=P.useState("");return P.useEffect(()=>{const S=l.current;S&&m((S.textContent??"").trim())},[i.children]),g.jsx(wp.ItemSlot,{scope:t,disabled:r,textValue:s??p,children:g.jsx(hue,{asChild:!0,...a,focusable:!r,children:g.jsx(vt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:je(n.onPointerMove,bp(S=>{r?o.onItemLeave(S):(o.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:je(n.onPointerLeave,bp(S=>o.onItemLeave(S))),onFocus:je(n.onFocus,()=>h(!0)),onBlur:je(n.onBlur,()=>h(!1))})})})}),fde="MenuCheckboxItem",$8=P.forwardRef((n,e)=>{const{checked:t=!1,onCheckedChange:r,...s}=n;return g.jsx(W8,{scope:n.__scopeMenu,checked:t,children:g.jsx(bv,{role:"menuitemcheckbox","aria-checked":RS(t)?"mixed":t,...s,ref:e,"data-state":R_(t),onSelect:je(s.onSelect,()=>r==null?void 0:r(RS(t)?!0:!t),{checkForDefaultPrevented:!1})})})});$8.displayName=fde;var B8="MenuRadioGroup",[pde,gde]=wu(B8,{value:void 0,onValueChange:()=>{}}),U8=P.forwardRef((n,e)=>{const{value:t,onValueChange:r,...s}=n,i=Xr(r);return g.jsx(pde,{scope:n.__scopeMenu,value:t,onValueChange:i,children:g.jsx(M_,{...s,ref:e})})});U8.displayName=B8;var H8="MenuRadioItem",K8=P.forwardRef((n,e)=>{const{value:t,...r}=n,s=gde(H8,n.__scopeMenu),i=t===s.value;return g.jsx(W8,{scope:n.__scopeMenu,checked:i,children:g.jsx(bv,{role:"menuitemradio","aria-checked":i,...r,ref:e,"data-state":R_(i),onSelect:je(r.onSelect,()=>{var o;return(o=s.onValueChange)==null?void 0:o.call(s,t)},{checkForDefaultPrevented:!1})})})});K8.displayName=H8;var A_="MenuItemIndicator",[W8,mde]=wu(A_,{checked:!1}),V8=P.forwardRef((n,e)=>{const{__scopeMenu:t,forceMount:r,...s}=n,i=mde(A_,t);return g.jsx(lo,{present:r||RS(i.checked)||i.checked===!0,children:g.jsx(vt.span,{...s,ref:e,"data-state":R_(i.checked)})})});V8.displayName=A_;var yde="MenuSeparator",q8=P.forwardRef((n,e)=>{const{__scopeMenu:t,...r}=n;return g.jsx(vt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});q8.displayName=yde;var Sde="MenuArrow",G8=P.forwardRef((n,e)=>{const{__scopeMenu:t,...r}=n,s=og(t);return g.jsx(m8,{...s,...r,ref:e})});G8.displayName=Sde;var O_="MenuSub",[vde,Y8]=wu(O_),X8=n=>{const{__scopeMenu:e,children:t,open:r=!1,onOpenChange:s}=n,i=ic(O_,e),o=og(e),[a,l]=P.useState(null),[c,u]=P.useState(null),h=Xr(s);return P.useEffect(()=>(i.open===!1&&h(!1),()=>h(!1)),[i.open,h]),g.jsx(C_,{...o,children:g.jsx(R8,{scope:e,open:r,onOpenChange:h,content:c,onContentChange:u,children:g.jsx(vde,{scope:e,contentId:Ra(),triggerId:Ra(),trigger:a,onTriggerChange:l,children:t})})})};X8.displayName=O_;var _f="MenuSubTrigger",Z8=P.forwardRef((n,e)=>{const t=ic(_f,n.__scopeMenu),r=ag(_f,n.__scopeMenu),s=Y8(_f,n.__scopeMenu),i=__(_f,n.__scopeMenu),o=P.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=i,c={__scopeMenu:n.__scopeMenu},u=P.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return P.useEffect(()=>u,[u]),P.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),g.jsx(I_,{asChild:!0,...c,children:g.jsx(z8,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":s.contentId,"data-state":e9(t.open),...n,ref:u_(e,s.onTriggerChange),onClick:h=>{var p;(p=n.onClick)==null||p.call(n,h),!(n.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),t.open||t.onOpenChange(!0))},onPointerMove:je(n.onPointerMove,bp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!n.disabled&&!t.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{t.onOpenChange(!0),u()},100))})),onPointerLeave:je(n.onPointerLeave,bp(h=>{var m,S;u();const p=(m=t.content)==null?void 0:m.getBoundingClientRect();if(p){const x=(S=t.content)==null?void 0:S.dataset.side,v=x==="right",w=v?-5:5,C=p[v?"left":"right"],_=p[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:C,y:p.top},{x:_,y:p.top},{x:_,y:p.bottom},{x:C,y:p.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:je(n.onKeyDown,h=>{var m;const p=i.searchRef.current!=="";n.disabled||p&&h.key===" "||ede[r.dir].includes(h.key)&&(t.onOpenChange(!0),(m=t.content)==null||m.focus(),h.preventDefault())})})})});Z8.displayName=_f;var J8="MenuSubContent",Q8=P.forwardRef((n,e)=>{const t=j8(Ii,n.__scopeMenu),{forceMount:r=t.forceMount,...s}=n,i=ic(Ii,n.__scopeMenu),o=ag(Ii,n.__scopeMenu),a=Y8(J8,n.__scopeMenu),l=P.useRef(null),c=jt(e,l);return g.jsx(wp.Provider,{scope:n.__scopeMenu,children:g.jsx(lo,{present:r||i.open,children:g.jsx(wp.Slot,{scope:n.__scopeMenu,children:g.jsx(T_,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var h;o.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:je(n.onFocusOutside,u=>{u.target!==a.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:je(n.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:je(n.onKeyDown,u=>{var m;const h=u.currentTarget.contains(u.target),p=tde[o.dir].includes(u.key);h&&p&&(i.onOpenChange(!1),(m=a.trigger)==null||m.focus(),u.preventDefault())})})})})})});Q8.displayName=J8;function e9(n){return n?"open":"closed"}function RS(n){return n==="indeterminate"}function R_(n){return RS(n)?"indeterminate":n?"checked":"unchecked"}function xde(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}function wde(n,e){return n.map((t,r)=>n[(e+r)%n.length])}function bde(n,e,t){const s=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let o=wde(n,Math.max(i,0));s.length===1&&(o=o.filter(c=>c!==t));const l=o.find(c=>c.toLowerCase().startsWith(s.toLowerCase()));return l!==t?l:void 0}function Cde(n,e){const{x:t,y:r}=n;let s=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const a=e[i],l=e[o],c=a.x,u=a.y,h=l.x,p=l.y;u>r!=p>r&&t<(h-c)*(r-u)/(p-u)+c&&(s=!s)}return s}function Pde(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return Cde(t,e)}function bp(n){return e=>e.pointerType==="mouse"?n(e):void 0}var t9=D8,n9=I_,r9=L8,s9=N8,i9=M_,o9=F8,a9=bv,l9=$8,c9=U8,u9=K8,d9=V8,h9=q8,f9=G8,p9=X8,g9=Z8,m9=Q8,D_="ContextMenu",[kde,n1e]=Xo(D_,[wv]),Ar=wv(),[Ide,y9]=kde(D_),S9=n=>{const{__scopeContextMenu:e,children:t,onOpenChange:r,dir:s,modal:i=!0}=n,[o,a]=P.useState(!1),l=Ar(e),c=Xr(r),u=P.useCallback(h=>{a(h),c(h)},[c]);return g.jsx(Ide,{scope:e,open:o,onOpenChange:u,modal:i,children:g.jsx(t9,{...l,dir:s,open:o,onOpenChange:u,modal:i,children:t})})};S9.displayName=D_;var v9="ContextMenuTrigger",x9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,disabled:r=!1,...s}=n,i=y9(v9,t),o=Ar(t),a=P.useRef({x:0,y:0}),l=P.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=P.useRef(0),u=P.useCallback(()=>window.clearTimeout(c.current),[]),h=p=>{a.current={x:p.clientX,y:p.clientY},i.onOpenChange(!0)};return P.useEffect(()=>u,[u]),P.useEffect(()=>void(r&&u()),[r,u]),g.jsxs(g.Fragment,{children:[g.jsx(n9,{...o,virtualRef:l}),g.jsx(vt.span,{"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,...s,ref:e,style:{WebkitTouchCallout:"none",...n.style},onContextMenu:r?n.onContextMenu:je(n.onContextMenu,p=>{u(),h(p),p.preventDefault()}),onPointerDown:r?n.onPointerDown:je(n.onPointerDown,Km(p=>{u(),c.current=window.setTimeout(()=>h(p),700)})),onPointerMove:r?n.onPointerMove:je(n.onPointerMove,Km(u)),onPointerCancel:r?n.onPointerCancel:je(n.onPointerCancel,Km(u)),onPointerUp:r?n.onPointerUp:je(n.onPointerUp,Km(u))})]})});x9.displayName=v9;var Ede="ContextMenuPortal",j_=n=>{const{__scopeContextMenu:e,...t}=n,r=Ar(e);return g.jsx(r9,{...r,...t})};j_.displayName=Ede;var w9="ContextMenuContent",b9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=y9(w9,t),i=Ar(t),o=P.useRef(!1);return g.jsx(s9,{...i,...r,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=n.onCloseAutoFocus)==null||l.call(n,a),!a.defaultPrevented&&o.current&&a.preventDefault(),o.current=!1},onInteractOutside:a=>{var l;(l=n.onInteractOutside)==null||l.call(n,a),!a.defaultPrevented&&!s.modal&&(o.current=!0)},style:{...n.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)"}})});b9.displayName=w9;var _de="ContextMenuGroup",Tde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(i9,{...s,...r,ref:e})});Tde.displayName=_de;var Mde="ContextMenuLabel",Ade=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(o9,{...s,...r,ref:e})});Ade.displayName=Mde;var Ode="ContextMenuItem",C9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(a9,{...s,...r,ref:e})});C9.displayName=Ode;var Rde="ContextMenuCheckboxItem",P9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(l9,{...s,...r,ref:e})});P9.displayName=Rde;var Dde="ContextMenuRadioGroup",jde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(c9,{...s,...r,ref:e})});jde.displayName=Dde;var Lde="ContextMenuRadioItem",Nde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(u9,{...s,...r,ref:e})});Nde.displayName=Lde;var Fde="ContextMenuItemIndicator",zde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(d9,{...s,...r,ref:e})});zde.displayName=Fde;var $de="ContextMenuSeparator",Bde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(h9,{...s,...r,ref:e})});Bde.displayName=$de;var Ude="ContextMenuArrow",Hde=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(f9,{...s,...r,ref:e})});Hde.displayName=Ude;var k9="ContextMenuSub",I9=n=>{const{__scopeContextMenu:e,children:t,onOpenChange:r,open:s,defaultOpen:i}=n,o=Ar(e),[a,l]=sc({prop:s,defaultProp:i??!1,onChange:r,caller:k9});return g.jsx(p9,{...o,open:a,onOpenChange:l,children:t})};I9.displayName=k9;var Kde="ContextMenuSubTrigger",E9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(g9,{...s,...r,ref:e})});E9.displayName=Kde;var Wde="ContextMenuSubContent",_9=P.forwardRef((n,e)=>{const{__scopeContextMenu:t,...r}=n,s=Ar(t);return g.jsx(m9,{...s,...r,ref:e,style:{...n.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)"}})});_9.displayName=Wde;function Km(n){return e=>e.pointerType!=="mouse"?n(e):void 0}var Vde=S9,qde=x9,Gde=j_,Yde=b9,Xde=P9,Cv="DropdownMenu",[Zde,r1e]=Xo(Cv,[wv]),Or=wv(),[Jde,T9]=Zde(Cv),M9=n=>{const{__scopeDropdownMenu:e,children:t,dir:r,open:s,defaultOpen:i,onOpenChange:o,modal:a=!0}=n,l=Or(e),c=P.useRef(null),[u,h]=sc({prop:s,defaultProp:i??!1,onChange:o,caller:Cv});return g.jsx(Jde,{scope:e,triggerId:Ra(),triggerRef:c,contentId:Ra(),open:u,onOpenChange:h,onOpenToggle:P.useCallback(()=>h(p=>!p),[h]),modal:a,children:g.jsx(t9,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:t})})};M9.displayName=Cv;var A9="DropdownMenuTrigger",O9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,disabled:r=!1,...s}=n,i=T9(A9,t),o=Or(t);return g.jsx(n9,{asChild:!0,...o,children:g.jsx(vt.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:u_(e,i.triggerRef),onPointerDown:je(n.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(i.onOpenToggle(),i.open||a.preventDefault())}),onKeyDown:je(n.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&i.onOpenToggle(),a.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});O9.displayName=A9;var Qde="DropdownMenuPortal",R9=n=>{const{__scopeDropdownMenu:e,...t}=n,r=Or(e);return g.jsx(r9,{...r,...t})};R9.displayName=Qde;var D9="DropdownMenuContent",j9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=T9(D9,t),i=Or(t),o=P.useRef(!1);return g.jsx(s9,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...r,ref:e,onCloseAutoFocus:je(n.onCloseAutoFocus,a=>{var l;o.current||(l=s.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:je(n.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!s.modal||u)&&(o.current=!0)}),style:{...n.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)"}})});j9.displayName=D9;var ehe="DropdownMenuGroup",the=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(i9,{...s,...r,ref:e})});the.displayName=ehe;var nhe="DropdownMenuLabel",rhe=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(o9,{...s,...r,ref:e})});rhe.displayName=nhe;var she="DropdownMenuItem",L9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(a9,{...s,...r,ref:e})});L9.displayName=she;var ihe="DropdownMenuCheckboxItem",N9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(l9,{...s,...r,ref:e})});N9.displayName=ihe;var ohe="DropdownMenuRadioGroup",ahe=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(c9,{...s,...r,ref:e})});ahe.displayName=ohe;var lhe="DropdownMenuRadioItem",che=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(u9,{...s,...r,ref:e})});che.displayName=lhe;var uhe="DropdownMenuItemIndicator",dhe=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(d9,{...s,...r,ref:e})});dhe.displayName=uhe;var hhe="DropdownMenuSeparator",fhe=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(h9,{...s,...r,ref:e})});fhe.displayName=hhe;var phe="DropdownMenuArrow",ghe=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(f9,{...s,...r,ref:e})});ghe.displayName=phe;var mhe=n=>{const{__scopeDropdownMenu:e,children:t,open:r,onOpenChange:s,defaultOpen:i}=n,o=Or(e),[a,l]=sc({prop:r,defaultProp:i??!1,onChange:s,caller:"DropdownMenuSub"});return g.jsx(p9,{...o,open:a,onOpenChange:l,children:t})},yhe="DropdownMenuSubTrigger",F9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(g9,{...s,...r,ref:e})});F9.displayName=yhe;var She="DropdownMenuSubContent",z9=P.forwardRef((n,e)=>{const{__scopeDropdownMenu:t,...r}=n,s=Or(t);return g.jsx(m9,{...s,...r,ref:e,style:{...n.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)"}})});z9.displayName=She;var L_=M9,N_=O9,Pv=R9,F_=j9,vhe=L9,xhe=N9,whe=mhe,bhe=F9,Che=z9;function Ht(n,e){var s;const t=new Set;for(const i of e){const o=n.getShape(i);if(!o)continue;n.getShapeUtil(o).onDragShapesOut&&t.add(o);const a=n.getShape(o.parentId);a&&n.getShapeUtil(a).onDragShapesOut&&t.add(a)}const r=new Map;for(const i of t){const o=$9(n,i);o.length&&r.set(i,o)}for(const[i,o]of r){const a=n.getShapeUtil(i),l=rt(o.map(c=>n.getShape(c)));(s=a.onDragShapesOut)==null||s.call(a,i,l)}}function $9(n,e){const t=n.getSortedChildIdsForParent(e.id);if(t.length===0)return[];const r=n.getShapePageBounds(e);if(!r)return[];let s,i,o;const a=[];for(const l of t){const c=n.getShapePageBounds(l);if(!c)continue;if(!r.includes(c)){a.push(l);continue}s??(s=n.getShapeGeometry(e)),i??(i=n.getShapePageTransform(e)),o??(o=i.applyToPoints(s.vertices));const u=n.getShapePageTransform(l).clone().invert().applyToPoints(o),{vertices:h,isClosed:p}=n.getShapeGeometry(l);if(!h.some(m=>qs(m,u))){if(p){if(GE(u,h))continue}else if(wre(u,h))continue;a.push(l)}}return a}function DS(n,e,t=!1){n.select(e),n.setEditingShape(e),n.setCurrentTool("select.editing_shape",{target:"shape",shape:e}),t&&n.emit("select-all-text",{shapeId:e.id})}function Phe(n,e){const t=rt(e.map(s=>n.getShape(s)).filter(s=>s&&n.isShapeOfType(s,"frame")));if(!t.length)return;const r=[];n.run(()=>{t.map(s=>{const i=n.getSortedChildIdsForParent(s.id);i.length&&(n.reparentShapes(i,s.parentId,s.index),r.push(...i))}),n.setSelectedShapes(r),n.deleteShapes(e)})}const khe=50;function Ihe(n,e,t={}){const r=n.getShape(e);if(!r)return;const s=n.getSortedChildIdsForParent(r.id),i=rt(s.map(m=>n.getShape(m)));if(!i.length)return;const o=Se.FromPoints(i.flatMap(m=>{const S=n.getShapeGeometry(m.id);return n.getShapeLocalTransform(m).applyToPoints(S.vertices)})),{padding:a=khe}=t,l=o.w+2*a,c=o.h+2*a,u=a-o.minX,h=a-o.minY;if(u===0&&h===0&&r.props.w===l&&r.props.h===c)return;const p=new k(u,h).rot(r.rotation);n.run(()=>{const m=s.map(S=>{const x=n.getShape(S);return{id:x.id,type:x.type,x:x.x+u,y:x.y+h}});m.push({id:r.id,type:r.type,x:r.x-p.x,y:r.y-p.y,props:{w:l,h:c}}),n.updateShapes(m)})}function Cn({children:n}){return g.jsx("span",{className:"tlui-button__label",children:n})}var kv="Dialog",[B9,s1e]=Xo(kv),[Ehe,co]=B9(kv),U9=n=>{const{__scopeDialog:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!0}=n,a=P.useRef(null),l=P.useRef(null),[c,u]=sc({prop:r,defaultProp:s??!1,onChange:i,caller:kv});return g.jsx(Ehe,{scope:e,triggerRef:a,contentRef:l,contentId:Ra(),titleId:Ra(),descriptionId:Ra(),open:c,onOpenChange:u,onOpenToggle:P.useCallback(()=>u(h=>!h),[u]),modal:o,children:t})};U9.displayName=kv;var H9="DialogTrigger",_he=P.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,s=co(H9,t),i=jt(e,s.triggerRef);return g.jsx(vt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":B_(s.open),...r,ref:i,onClick:je(n.onClick,s.onOpenToggle)})});_he.displayName=H9;var z_="DialogPortal",[The,K9]=B9(z_,{forceMount:void 0}),W9=n=>{const{__scopeDialog:e,forceMount:t,children:r,container:s}=n,i=co(z_,e);return g.jsx(The,{scope:e,forceMount:t,children:P.Children.map(r,o=>g.jsx(lo,{present:t||i.open,children:g.jsx(rg,{asChild:!0,container:s,children:o})}))})};W9.displayName=z_;var jS="DialogOverlay",V9=P.forwardRef((n,e)=>{const t=K9(jS,n.__scopeDialog),{forceMount:r=t.forceMount,...s}=n,i=co(jS,n.__scopeDialog);return i.modal?g.jsx(lo,{present:r||i.open,children:g.jsx(Ahe,{...s,ref:e})}):null});V9.displayName=jS;var Mhe=Yd("DialogOverlay.RemoveScroll"),Ahe=P.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,s=co(jS,t);return g.jsx(xv,{as:Mhe,allowPinchZoom:!0,shards:[s.contentRef],children:g.jsx(vt.div,{"data-state":B_(s.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),lu="DialogContent",q9=P.forwardRef((n,e)=>{const t=K9(lu,n.__scopeDialog),{forceMount:r=t.forceMount,...s}=n,i=co(lu,n.__scopeDialog);return g.jsx(lo,{present:r||i.open,children:i.modal?g.jsx(Ohe,{...s,ref:e}):g.jsx(Rhe,{...s,ref:e})})});q9.displayName=lu;var Ohe=P.forwardRef((n,e)=>{const t=co(lu,n.__scopeDialog),r=P.useRef(null),s=jt(e,t.contentRef,r);return P.useEffect(()=>{const i=r.current;if(i)return k_(i)},[]),g.jsx(G9,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(n.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:je(n.onPointerDownOutside,i=>{const o=i.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&i.preventDefault()}),onFocusOutside:je(n.onFocusOutside,i=>i.preventDefault())})}),Rhe=P.forwardRef((n,e)=>{const t=co(lu,n.__scopeDialog),r=P.useRef(!1),s=P.useRef(!1);return g.jsx(G9,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),G9=P.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,...o}=n,a=co(lu,t),l=P.useRef(null),c=jt(e,l);return f_(),g.jsxs(g.Fragment,{children:[g.jsx(pv,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:g.jsx(tg,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":B_(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),g.jsxs(g.Fragment,{children:[g.jsx(jhe,{titleId:a.titleId}),g.jsx(Nhe,{contentRef:l,descriptionId:a.descriptionId})]})]})}),$_="DialogTitle",Y9=P.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,s=co($_,t);return g.jsx(vt.h2,{id:s.titleId,...r,ref:e})});Y9.displayName=$_;var X9="DialogDescription",Dhe=P.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,s=co(X9,t);return g.jsx(vt.p,{id:s.descriptionId,...r,ref:e})});Dhe.displayName=X9;var Z9="DialogClose",J9=P.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,s=co(Z9,t);return g.jsx(vt.button,{type:"button",...r,ref:e,onClick:je(n.onClick,()=>s.onOpenChange(!1))})});J9.displayName=Z9;function B_(n){return n?"open":"closed"}var Q9="DialogTitleWarning",[i1e,eU]=mle(Q9,{contentName:lu,titleName:$_,docsSlug:"dialog"}),jhe=({titleId:n})=>{const e=eU(Q9),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
347
|
-
|
|
348
|
-
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
349
|
-
|
|
350
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return P.useEffect(()=>{n&&(document.getElementById(n)||console.error(t))},[t,n]),null},Lhe="DialogDescriptionWarning",Nhe=({contentRef:n,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${eU(Lhe).contentName}}.`;return P.useEffect(()=>{var i;const s=(i=n.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,n,e]),null},Fhe=U9,zhe=W9,$he=V9,Bhe=q9,Uhe=Y9;const Wo=P.memo(function({small:e,invertIcon:t,icon:r,color:s,className:i,...o}){const a=c_(),l=a.icons[r]??a.icons["question-mark-circle"],c=P.useRef(null);return P.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"?g.jsx("div",{className:$e("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":e},i)}):g.jsx("div",{...o,ref:c,className:$e("tlui-icon",{"tlui-icon__small":e},i),style:{color:s,mask:`url(${l}) center 100% / 100% no-repeat`,transform:t?"scale(-1, 1)":void 0}})});function ct({icon:n,small:e,invertIcon:t}){return g.jsx(Wo,{className:"tlui-button__icon",icon:n,small:e,invertIcon:t})}function Iv({className:n,children:e}){return g.jsx("div",{className:$e("tlui-dialog__header",n),children:e})}function Ev({className:n,children:e,style:t}){return g.jsx(Uhe,{dir:"ltr",className:$e("tlui-dialog__header__title",n),style:t,children:e})}function _v(){return g.jsx("div",{className:"tlui-dialog__header__close",children:g.jsx(J9,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:g.jsx(He,{type:"icon","aria-label":"Close",onTouchEnd:n=>n.target.click(),children:g.jsx(ct,{small:!0,icon:"cross-2"})})})})}function Cp({className:n,children:e,style:t}){return g.jsx("div",{className:$e("tlui-dialog__body",n),style:t,children:e})}function U_({className:n,children:e}){return g.jsx("div",{className:$e("tlui-dialog__footer",n),children:e})}const lg=P.forwardRef(function({className:e,label:t,icon:r,iconLeft:s,autoSelect:i=!1,autoFocus:o=!1,defaultValue:a,placeholder:l,onComplete:c,onValueChange:u,onCancel:h,onFocus:p,onBlur:m,shouldManuallyMaintainScrollPositionWhenFocused:S=!1,children:x,value:v,"data-testid":w},C){const _=dr(),E=P.useRef(null);P.useImperativeHandle(C,()=>E.current);const T=it(),A=P.useRef(a??""),O=P.useRef(a??""),D=P.useRef(!1),[$,H]=P.useState(!1),G=P.useCallback(W=>{H(!0);const z=W.currentTarget;O.current=z.value,_?_.timers.requestAnimationFrame(()=>{i&&z.select()}):ES.requestAnimationFrame("anon",()=>{i&&z.select()}),p==null||p()},[i,_,p]),J=P.useCallback(W=>{const z=W.currentTarget.value;O.current=z,u==null||u(z)},[u]),L=P.useCallback(W=>{switch(W.key){case"Enter":{if(D.current)return;W.currentTarget.blur(),Wt(W),c==null||c(W.currentTarget.value);break}case"Escape":{W.currentTarget.value=A.current,h==null||h(W.currentTarget.value),W.currentTarget.blur(),Wt(W);break}}},[c,h]),N=P.useCallback(W=>{H(!1);const z=W.currentTarget.value;m==null||m(z)},[m]),U=P.useCallback(()=>D.current=!0,[]),Y=P.useCallback(()=>D.current=!1,[]);return P.useEffect(()=>{if(!It.isIos)return;const W=window.visualViewport;if($&&S&&W){const z=()=>{var V;(V=E.current)==null||V.scrollIntoView({block:"center"})};return W.addEventListener("resize",z),W.addEventListener("scroll",z),_?_.timers.requestAnimationFrame(()=>{var V;(V=E.current)==null||V.scrollIntoView({block:"center"})}):ES.requestAnimationFrame("anon",()=>{var V;(V=E.current)==null||V.scrollIntoView({block:"center"})}),()=>{W.removeEventListener("resize",z),W.removeEventListener("scroll",z)}}},[$,_,S]),g.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[x,t&&g.jsx("label",{children:T(t)}),s&&g.jsx(Wo,{icon:s,className:"tlui-icon-left",small:!0}),g.jsx("input",{ref:E,className:$e("tlui-input",e),type:"text",defaultValue:a,onKeyDownCapture:L,onChange:J,onFocus:G,onBlur:N,onCompositionStart:U,onCompositionEnd:Y,autoFocus:o,placeholder:l,value:v,"data-testid":w}),r&&g.jsx(Wo,{icon:r,small:!!t})]})});function TL(n){return Zs.isValid(n)?{isValid:!0,hasProtocol:!0}:Zs.isValid("https://"+n)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const Hhe=Yn(function({onClose:e}){const r=te().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?g.jsx(Khe,{onClose:e,selectedShape:r}):null}),Khe=Yn(function({onClose:e,selectedShape:t}){const r=te(),s=it(),i=P.useRef(null);P.useEffect(()=>{r.timers.requestAnimationFrame(()=>{var S;return(S=i.current)==null?void 0:S.focus()})},[r]);const o=P.useRef(t.props.url),[a,l]=P.useState(()=>{const S=TL(t.props.url),x=S.isValid===!0?S.hasProtocol?t.props.url:"https://"+t.props.url:"https://";return{actual:x,safe:x,valid:!0}}),c=P.useCallback(S=>{const x=S.replace(/https?:\/\/(https?:\/\/)/,(C,_)=>_),v=TL(x),w=v.isValid===!0?v.hasProtocol?x:"https://"+x:"https://";l({actual:x,safe:w,valid:v.isValid})},[]),u=P.useCallback(()=>{const S=r.getOnlySelectedShape();S&&(r.updateShapes([{id:S.id,type:S.type,props:{url:""}}]),e())},[r,e]),h=P.useCallback(()=>{const S=r.getOnlySelectedShape();S&&(S&&"url"in S.props&&S.props.url!==a.safe&&r.updateShapes([{id:S.id,type:S.type,props:{url:a.safe}}]),e())},[r,e,a]),p=P.useCallback(()=>{e()},[e]);if(!t)return e(),null;const m=o.current&&!a.valid;return g.jsxs(g.Fragment,{children:[g.jsxs(Iv,{children:[g.jsx(Ev,{children:s("edit-link-dialog.title")}),g.jsx(_v,{})]}),g.jsx(Cp,{children:g.jsxs("div",{className:"tlui-edit-link-dialog",children:[g.jsx(lg,{ref:i,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,value:a.actual,onValueChange:c,onComplete:h,onCancel:p}),g.jsx("div",{children:a.valid?s("edit-link-dialog.detail"):s("edit-link-dialog.invalid-url")})]})}),g.jsxs(U_,{className:"tlui-dialog__footer__actions",children:[g.jsx(He,{type:"normal",onClick:p,onTouchEnd:p,children:g.jsx(Cn,{children:s("edit-link-dialog.cancel")})}),m?g.jsx(He,{type:"danger",onTouchEnd:u,onClick:u,children:g.jsx(Cn,{children:s("edit-link-dialog.clear")})}):g.jsx(He,{type:"primary",disabled:!a.valid,onTouchEnd:h,onClick:h,children:g.jsx(Cn,{children:s("edit-link-dialog.save")})})]})]})});var Whe={};const ML=/(^\/[f|p|r|ro|s|v]\/[^/]+\/?$)/,H_=[{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:n=>{const e=Ze(n);if(e&&e.pathname.match(ML))return e.searchParams.append("embed","true"),n},fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(ML))return e.searchParams.delete("embed"),n}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:n=>{if(n.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!n.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${n}`},fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/embed\/?$/)){const t=e.searchParams.get("url");if(t)return t}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:n=>{if(n.includes("/maps/embed?"))return n;if(n.includes("/maps/")){const e=n.match(/@(.*?),(.*?),(.*?)(z|m)/);let t;if(e){const[,r,s,i,o]=e,a=o==="z"?"roadmap":"satellite",l=a==="roadmap"?i:-Math.log2(parseInt(i)/14772321)/.8;t=`https://${new URL(n).host.replace("www.","")}/maps/embed/v1/view?key=${Whe.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${s}&zoom=${l}&maptype=${a}`}else t="";return t}},fromEmbedUrl:n=>{const e=Ze(n);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")??"12",s=e.searchParams.get("maptype")??"roadmap",i=s==="roadmap"?r:14772321*Math.pow(2,parseInt(r)*-.8),[o,a]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${o},${a},${i}${s==="roadmap"?"z":"m"}`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/v\/(.+)\/?/);if(t)return`https://www.val.town/embed/${t[1]}`},fromEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(t)return`https://www.val.town/v/${t[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/s\/([^/]+)\/?/);if(t)return`https://codesandbox.io/embed/${t[1]}`},fromEmbedUrl:n=>{const e=Ze(n),t=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://codesandbox.io/s/${t[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:n=>{const e=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,t=n.match(e);if(t){const[r,s,i]=t;return`https://codepen.io/${s}/embed/${i}`}},fromEmbedUrl:n=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,t=n.match(e);if(t){const[r,s,i]=t;return`https://codepen.io/${s}/pen/${i}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:n=>{const e=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,t=n.match(e);if(t){const[r,s]=t;return`https://scratch.mit.edu/projects/embed/${s}`}},fromEmbedUrl:n=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,t=n.match(e);if(t){const[r,s]=t;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:n=>{const e=Ze(n);if(!e)return;const t=e.hostname.replace(/^www./,"");if(t==="youtu.be"){const r=e.pathname.split("/").filter(Boolean)[0],s=new URLSearchParams(e.search),i=s.get("t");i&&(s.set("start",i),s.delete("t"));const o=s.toString()?"?"+s.toString():"";return`https://www.youtube.com/embed/${r}${o}`}else if((t==="youtube.com"||t==="m.youtube.com")&&e.pathname.match(/^\/watch/)){const r=e.searchParams.get("v"),s=new URLSearchParams(e.search);s.delete("v");const i=s.get("t");i&&(s.set("start",i),s.delete("t"));const o=s.toString()?"?"+s.toString():"";return`https://www.youtube.com/embed/${r}${o}`}},fromEmbedUrl:n=>{const e=Ze(n);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const r=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(r){const s=new URLSearchParams(e.search);s.set("v",(r==null?void 0:r[1])??"");const i=s.get("start");return i&&(s.set("t",i),s.delete("start")),`https://www.youtube.com/watch?${s.toString()}`}}}},{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:n=>{const e=Ze(n),t=e==null?void 0:e.searchParams.get("cid");if(e!=null&&e.pathname.match(/\/calendar\/u\/0/)&&t){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",t),e.href}},fromEmbedUrl:n=>{const e=Ze(n),t=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&t){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",t),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:n=>{const e=Ze(n);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/pub\/?$/))){e.pathname=e.pathname.replace(/\/pub$/,"/embed");const t=Array.from(e.searchParams.keys());for(const r of t)e.searchParams.delete(r);return e.href}},fromEmbedUrl:n=>{const e=Ze(n);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const t=Array.from(e.searchParams.keys());for(const r of t)e.searchParams.delete(r);return e.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return n.split("/").pop()?n:void 0},fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return n.split("/").pop()?n:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${n}?embed=true`},fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/map\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/(artist|album)\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n);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:n=>{const e=Ze(n);if(e&&e.hostname==="player.vimeo.com"){const t=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(t)return"https://vimeo.com/"+t[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:n=>{const e=Ze(n);if(e&&e.hash.match(/#room=/))return n},fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.hash.match(/#room=/))return n}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:n=>{const e=Ze(n);if(e&&e.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}/embed${e.pathname}?cell=*`;if(e&&e.pathname.match(/^\/d\/([^/]+)\/?$/)){const t=e.pathname.replace(/^\/d/,"");return`${e.origin}/embed${t}?cell=*`}},fromEmbedUrl:n=>{const e=Ze(n);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:n=>{const e=Ze(n);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search===""&&e.hash==="")return`${n}?embed`},fromEmbedUrl:n=>{const e=Ze(n);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return n.replace("?embed","")}}],Vhe={"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},qhe=H_.map(n=>n.type);function Ghe(n){return qhe.includes(n)}function Yhe(n){return"icon"in n}function tU(){const n=dr();if(n&&n.hasShapeUtil("embed"))return n.getShapeUtil("embed")}function K_(){const n=tU();return e=>n?n.getEmbedDefinition(e):void 0}function Xhe(){const n=tU();return n?n.getEmbedDefinitions():[]}const nU=Yn(function({onClose:e}){const t=te(),r=it(),s=c_(),[i,o]=P.useState(null),[a,l]=P.useState(""),[c,u]=P.useState(null),[h,p]=P.useState(!1),m=P.useRef(-1),S=Xhe(),x=K_();return g.jsxs(g.Fragment,{children:[g.jsxs(Iv,{children:[g.jsx(Ev,{children:i?`${r("embed-dialog.title")} — ${i.title}`:r("embed-dialog.title")}),g.jsx(_v,{})]}),i?g.jsxs(g.Fragment,{children:[g.jsxs(Cp,{className:"tlui-embed-dialog__enter",children:[g.jsx(lg,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"https://example.com",autoFocus:!0,onValueChange:v=>{l(v);const w=x(v);u(w&&w.definition.type===i.type?w:null),p(!1),clearTimeout(m.current),m.current=t.timers.setTimeout(()=>p(!w),320)}}),a===""?g.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[g.jsx("span",{children:r("embed-dialog.instruction")})," ",i.instructionLink&&g.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:i.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",g.jsx(Wo,{icon:"external-link",small:!0})]})]}):g.jsx("div",{className:"tlui-embed-dialog__warning",children:h?r("embed-dialog.invalid-url"):" "})]}),g.jsxs(U_,{className:"tlui-dialog__footer__actions",children:[g.jsx(He,{type:"normal",onClick:()=>{o(null),u(null),l("")},children:g.jsx(Cn,{children:r("embed-dialog.back")})}),g.jsx("div",{className:"tlui-embed__spacer"}),g.jsx(He,{type:"normal",onClick:e,children:g.jsx(Cn,{children:r("embed-dialog.cancel")})}),g.jsx(He,{type:"primary",disabled:!c,onClick:()=>{c&&(t.putExternalContent({type:"embed",url:a,point:t.getViewportPageBounds().center,embed:c.definition}),e())},children:g.jsx(Cn,{children:r("embed-dialog.create")})})]})]}):g.jsx(g.Fragment,{children:g.jsx(Cp,{className:"tlui-embed-dialog__list",children:S.map(v=>{const w=Ghe(v.type)?s.embedIcons[v.type]:Yhe(v)?v.icon:void 0;return g.jsxs(He,{type:"menu",onClick:()=>o(v),children:[g.jsx(Cn,{children:v.title}),w&&g.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${w})`}})]},v.type)})})})]})});function Tv(){const n=dr();return(n==null?void 0:n.store.props.collaboration)!==void 0}function Zhe(){const n=dr();return ie("sync status",()=>{var e;return(e=n==null?void 0:n.store.props.collaboration)!=null&&e.status?n.store.props.collaboration.status.get():null},[n])}async function Jhe(n,e,t){const r=rt(e.map(a=>{const l=n.getShape(a);if(!(!l||n.getShapeUtil(l.type).toSvg===void 0))return l}));if(r.length===0)return;if(r.length===1){const a=r[0];if(!a||n.isShapeOfType(a,"image"))return}const s=[];if(t!==void 0){const a=r.map(l=>({shape:l,bounds:n.getShapeMaskedPageBounds(l).clone().expandBy(t)}));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=Se.Common(r.map(l=>n.getShapeMaskedPageBounds(l)));s.push({shapes:r,bounds:a})}const i=n.options.flattenImageBoundsPadding;for(const a of s){t!==void 0&&a.bounds.expandBy(-t);const l=await n.getSvgString(a.shapes,{padding:i});if(!(l!=null&&l.svg))continue;const c=await n.getAssetForExternalContent({type:"file",file:new File([l.svg],"asset.svg",{type:"image/svg+xml"})});c&&(a.asset=c)}const o=[];return Vs(()=>{for(const a of s){const{asset:l,bounds:c,shapes:u}=a;if(!l)continue;const h=n.findCommonAncestor(u)??n.getCurrentPageId();if(!h)continue;let p="a1";for(const w of u)if(w.parentId===h){w.index>p&&(p=w.index);break}let m,S,x;if(ws(h)){const w=n.getShape(h);if(!w)continue;const C=n.getPointInShapeSpace(w,{x:c.x,y:c.y});x=n.getShapePageTransform(h).rotation(),C.sub(new k(i,i).rot(-x)),m=C.x,S=C.y}else m=c.x-i,S=c.y-i,x=0;n.deleteShapes(u),n.createAssets([{...l,id:l.id}]);const v=Dt();n.createShape({id:v,type:"image",index:p,parentId:h,x:m,y:S,rotation:-x,props:{assetId:l.id,w:c.w+i*2,h:c.h+i*2}}),o.push(v)}}),o}const NC=[0,389,436,476,580,640,840,1023];var dn=(n=>(n[n.ZERO=0]="ZERO",n[n.MOBILE_XXS=1]="MOBILE_XXS",n[n.MOBILE_XS=2]="MOBILE_XS",n[n.MOBILE_SM=3]="MOBILE_SM",n[n.MOBILE=4]="MOBILE",n[n.TABLET_SM=5]="TABLET_SM",n[n.TABLET=6]="TABLET",n[n.DESKTOP=7]="DESKTOP",n))(dn||{});const rU=at.createContext(null);function Qhe({forceMobile:n=!1,children:e}){const t=dr(),r=ie("breakpoint",()=>{const{width:s}=(t==null?void 0:t.getViewportScreenBounds())??{width:window.innerWidth},i=n?dn.MOBILE_SM:NC.length-1;for(let o=0;o<i;o++)if(s>NC[o]&&s<=NC[o+1])return o;return i},[t]);return g.jsx(rU.Provider,{value:r,children:e})}function Rr(){const n=P.useContext(rU);if(n===null)throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return n}const jk=P.createContext(null);function efe({context:n,children:e}){const t=P.useContext(jk),r=Ln(),s=Np("dialogs",[]),i=P.useMemo(()=>({dialogs:s,addDialog(o){const a=o.id??_t();return s.update(l=>[...l.filter(c=>c.id!==o.id),{...o,id:a}]),r("open-menu",{source:"dialog",id:a}),Br.addOpenMenu(a,n),a},removeDialog(o){var l;const a=s.get().find(c=>c.id===o);return a&&((l=a.onClose)==null||l.call(a),r("close-menu",{source:"dialog",id:o}),Br.deleteOpenMenu(o,n),s.update(c=>c.filter(u=>u!==a))),o},clearDialogs(){const o=s.get();o.length!==0&&(o.forEach(a=>{var l;(l=a.onClose)==null||l.call(a),r("close-menu",{source:"dialog",id:a.id}),Br.deleteOpenMenu(a.id,n)}),s.set([]))}}),[r,s,n]);return t?g.jsx(g.Fragment,{children:e}):g.jsx(jk.Provider,{value:i,children:e})}function cg(){const n=P.useContext(jk);if(!n)throw new Error("useDialogs must be used within a DialogsProvider");return n}var tfe=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),nfe="VisuallyHidden",W_=P.forwardRef((n,e)=>g.jsx(vt.span,{...n,ref:e,style:{...tfe,...n.style}}));W_.displayName=nfe;var V_="ToastProvider",[q_,rfe,sfe]=fv("Toast"),[sU,o1e]=Xo("Toast",[sfe]),[ife,Mv]=sU(V_),iU=n=>{const{__scopeToast:e,label:t="Notification",duration:r=5e3,swipeDirection:s="right",swipeThreshold:i=50,children:o}=n,[a,l]=P.useState(null),[c,u]=P.useState(0),h=P.useRef(!1),p=P.useRef(!1);return t.trim()||console.error(`Invalid prop \`label\` supplied to \`${V_}\`. Expected non-empty \`string\`.`),g.jsx(q_.Provider,{scope:e,children:g.jsx(ife,{scope:e,label:t,duration:r,swipeDirection:s,swipeThreshold:i,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:P.useCallback(()=>u(m=>m+1),[]),onToastRemove:P.useCallback(()=>u(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:p,children:o})})};iU.displayName=V_;var oU="ToastViewport",ofe=["F8"],Lk="toast.viewportPause",Nk="toast.viewportResume",aU=P.forwardRef((n,e)=>{const{__scopeToast:t,hotkey:r=ofe,label:s="Notifications ({hotkey})",...i}=n,o=Mv(oU,t),a=rfe(t),l=P.useRef(null),c=P.useRef(null),u=P.useRef(null),h=P.useRef(null),p=jt(e,h,o.onViewportChange),m=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),S=o.toastCount>0;P.useEffect(()=>{const v=w=>{var _;r.length!==0&&r.every(E=>w[E]||w.code===E)&&((_=h.current)==null||_.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),P.useEffect(()=>{const v=l.current,w=h.current;if(S&&v&&w){const C=()=>{if(!o.isClosePausedRef.current){const A=new CustomEvent(Lk);w.dispatchEvent(A),o.isClosePausedRef.current=!0}},_=()=>{if(o.isClosePausedRef.current){const A=new CustomEvent(Nk);w.dispatchEvent(A),o.isClosePausedRef.current=!1}},E=A=>{!v.contains(A.relatedTarget)&&_()},T=()=>{v.contains(document.activeElement)||_()};return v.addEventListener("focusin",C),v.addEventListener("focusout",E),v.addEventListener("pointermove",C),v.addEventListener("pointerleave",T),window.addEventListener("blur",C),window.addEventListener("focus",_),()=>{v.removeEventListener("focusin",C),v.removeEventListener("focusout",E),v.removeEventListener("pointermove",C),v.removeEventListener("pointerleave",T),window.removeEventListener("blur",C),window.removeEventListener("focus",_)}}},[S,o.isClosePausedRef]);const x=P.useCallback(({tabbingDirection:v})=>{const C=a().map(_=>{const E=_.ref.current,T=[E,...vfe(E)];return v==="forwards"?T:T.reverse()});return(v==="forwards"?C.reverse():C).flat()},[a]);return P.useEffect(()=>{const v=h.current;if(v){const w=C=>{var T,A,O;const _=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!_){const D=document.activeElement,$=C.shiftKey;if(C.target===v&&$){(T=c.current)==null||T.focus();return}const J=x({tabbingDirection:$?"backwards":"forwards"}),L=J.findIndex(N=>N===D);FC(J.slice(L+1))?C.preventDefault():$?(A=c.current)==null||A.focus():(O=u.current)==null||O.focus()}};return v.addEventListener("keydown",w),()=>v.removeEventListener("keydown",w)}},[a,x]),g.jsxs(Rle,{ref:l,role:"region","aria-label":s.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:S?void 0:"none"},children:[S&&g.jsx(Fk,{ref:c,onFocusFromOutsideViewport:()=>{const v=x({tabbingDirection:"forwards"});FC(v)}}),g.jsx(q_.Slot,{scope:t,children:g.jsx(vt.ol,{tabIndex:-1,...i,ref:p})}),S&&g.jsx(Fk,{ref:u,onFocusFromOutsideViewport:()=>{const v=x({tabbingDirection:"backwards"});FC(v)}})]})});aU.displayName=oU;var lU="ToastFocusProxy",Fk=P.forwardRef((n,e)=>{const{__scopeToast:t,onFocusFromOutsideViewport:r,...s}=n,i=Mv(lU,t);return g.jsx(W_,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:o=>{var c;const a=o.relatedTarget;!((c=i.viewport)!=null&&c.contains(a))&&r()}})});Fk.displayName=lU;var ug="Toast",afe="toast.swipeStart",lfe="toast.swipeMove",cfe="toast.swipeCancel",ufe="toast.swipeEnd",cU=P.forwardRef((n,e)=>{const{forceMount:t,open:r,defaultOpen:s,onOpenChange:i,...o}=n,[a,l]=sc({prop:r,defaultProp:s??!0,onChange:i,caller:ug});return g.jsx(lo,{present:t||a,children:g.jsx(ffe,{open:a,...o,ref:e,onClose:()=>l(!1),onPause:Xr(n.onPause),onResume:Xr(n.onResume),onSwipeStart:je(n.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:je(n.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:je(n.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:je(n.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)})})})});cU.displayName=ug;var[dfe,hfe]=sU(ug,{onClose(){}}),ffe=P.forwardRef((n,e)=>{const{__scopeToast:t,type:r="foreground",duration:s,open:i,onClose:o,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:h,onSwipeCancel:p,onSwipeEnd:m,...S}=n,x=Mv(ug,t),[v,w]=P.useState(null),C=jt(e,N=>w(N)),_=P.useRef(null),E=P.useRef(null),T=s||x.duration,A=P.useRef(0),O=P.useRef(T),D=P.useRef(0),{onToastAdd:$,onToastRemove:H}=x,G=Xr(()=>{var U;(v==null?void 0:v.contains(document.activeElement))&&((U=x.viewport)==null||U.focus()),o()}),J=P.useCallback(N=>{!N||N===1/0||(window.clearTimeout(D.current),A.current=new Date().getTime(),D.current=window.setTimeout(G,N))},[G]);P.useEffect(()=>{const N=x.viewport;if(N){const U=()=>{J(O.current),c==null||c()},Y=()=>{const W=new Date().getTime()-A.current;O.current=O.current-W,window.clearTimeout(D.current),l==null||l()};return N.addEventListener(Lk,Y),N.addEventListener(Nk,U),()=>{N.removeEventListener(Lk,Y),N.removeEventListener(Nk,U)}}},[x.viewport,T,l,c,J]),P.useEffect(()=>{i&&!x.isClosePausedRef.current&&J(T)},[i,T,x.isClosePausedRef,J]),P.useEffect(()=>($(),()=>H()),[$,H]);const L=P.useMemo(()=>v?mU(v):null,[v]);return x.viewport?g.jsxs(g.Fragment,{children:[L&&g.jsx(pfe,{__scopeToast:t,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:L}),g.jsx(dfe,{scope:t,onClose:G,children:hh.createPortal(g.jsx(q_.ItemSlot,{scope:t,children:g.jsx(Ole,{asChild:!0,onEscapeKeyDown:je(a,()=>{x.isFocusedToastEscapeKeyDownRef.current||G(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:g.jsx(vt.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":x.swipeDirection,...S,ref:C,style:{userSelect:"none",touchAction:"none",...n.style},onKeyDown:je(n.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,G()))}),onPointerDown:je(n.onPointerDown,N=>{N.button===0&&(_.current={x:N.clientX,y:N.clientY})}),onPointerMove:je(n.onPointerMove,N=>{if(!_.current)return;const U=N.clientX-_.current.x,Y=N.clientY-_.current.y,W=!!E.current,z=["left","right"].includes(x.swipeDirection),V=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,ee=z?V(0,U):0,B=z?0:V(0,Y),Q=N.pointerType==="touch"?10:2,me={x:ee,y:B},Pe={originalEvent:N,delta:me};W?(E.current=me,Wm(lfe,h,Pe,{discrete:!1})):AL(me,x.swipeDirection,Q)?(E.current=me,Wm(afe,u,Pe,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(U)>Q||Math.abs(Y)>Q)&&(_.current=null)}),onPointerUp:je(n.onPointerUp,N=>{const U=E.current,Y=N.target;if(Y.hasPointerCapture(N.pointerId)&&Y.releasePointerCapture(N.pointerId),E.current=null,_.current=null,U){const W=N.currentTarget,z={originalEvent:N,delta:U};AL(U,x.swipeDirection,x.swipeThreshold)?Wm(ufe,m,z,{discrete:!0}):Wm(cfe,p,z,{discrete:!0}),W.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),pfe=n=>{const{__scopeToast:e,children:t,...r}=n,s=Mv(ug,e),[i,o]=P.useState(!1),[a,l]=P.useState(!1);return yfe(()=>o(!0)),P.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:g.jsx(rg,{asChild:!0,children:g.jsx(W_,{...r,children:i&&g.jsxs(g.Fragment,{children:[s.label," ",t]})})})},gfe="ToastTitle",uU=P.forwardRef((n,e)=>{const{__scopeToast:t,...r}=n;return g.jsx(vt.div,{...r,ref:e})});uU.displayName=gfe;var mfe="ToastDescription",dU=P.forwardRef((n,e)=>{const{__scopeToast:t,...r}=n;return g.jsx(vt.div,{...r,ref:e})});dU.displayName=mfe;var hU="ToastAction",fU=P.forwardRef((n,e)=>{const{altText:t,...r}=n;return t.trim()?g.jsx(gU,{altText:t,asChild:!0,children:g.jsx(G_,{...r,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${hU}\`. Expected non-empty \`string\`.`),null)});fU.displayName=hU;var pU="ToastClose",G_=P.forwardRef((n,e)=>{const{__scopeToast:t,...r}=n,s=hfe(pU,t);return g.jsx(gU,{asChild:!0,children:g.jsx(vt.button,{type:"button",...r,ref:e,onClick:je(n.onClick,s.onClose)})})});G_.displayName=pU;var gU=P.forwardRef((n,e)=>{const{__scopeToast:t,altText:r,...s}=n;return g.jsx(vt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...s,ref:e})});function mU(n){const e=[];return Array.from(n.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&e.push(r.textContent),Sfe(r)){const s=r.ariaHidden||r.hidden||r.style.display==="none",i=r.dataset.radixToastAnnounceExclude==="";if(!s)if(i){const o=r.dataset.radixToastAnnounceAlt;o&&e.push(o)}else e.push(...mU(r))}}),e}function Wm(n,e,t,{discrete:r}){const s=t.originalEvent.currentTarget,i=new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:t});e&&s.addEventListener(n,e,{once:!0}),r?d_(s,i):s.dispatchEvent(i)}var AL=(n,e,t=0)=>{const r=Math.abs(n.x),s=Math.abs(n.y),i=r>s;return e==="left"||e==="right"?i&&r>t:!i&&s>t};function yfe(n=()=>{}){const e=Xr(n);Fa(()=>{let t=0,r=0;return t=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(t),window.cancelAnimationFrame(r)}},[e])}function Sfe(n){return n.nodeType===n.ELEMENT_NODE}function vfe(n){const e=[],t=document.createTreeWalker(n,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(;t.nextNode();)e.push(t.currentNode);return e}function FC(n){const e=document.activeElement;return n.some(t=>t===e?!0:(t.focus(),document.activeElement!==e))}var xfe=cU,wfe=uU,bfe=dU,Cfe=fU,OL=G_;const zk=P.createContext(null);function Pfe({children:n}){const e=Np("toasts",[]),t=P.useContext(zk),r=P.useMemo(()=>({toasts:e,addToast(s){const i=s.id??_t();return e.update(o=>[...o.filter(a=>a.id!==s.id),{...s,id:i}]),i},removeToast(s){return e.update(i=>i.filter(o=>o.id!==s)),s},clearToasts(){e.set([])}}),[e]);return t?g.jsx(g.Fragment,{children:n}):g.jsx(iU,{children:g.jsx(zk.Provider,{value:r,children:n})})}function Ya(){const n=P.useContext(zk);if(!n)throw new Error("useToasts must be used within a ToastsProvider");return n}var zC={exports:{}},RL;function kfe(){return RL||(RL=1,function(n){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(l,c){if(!i[l]){i[l]={};for(var u=0;u<l.length;u++)i[l][l.charAt(u)]=u}return i[l][c]}var a={compressToBase64:function(l){if(l==null)return"";var c=a._compress(l,6,function(u){return 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 o(r,l.charAt(c))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(c){return t(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,p=c.length;h<p;h++){var m=c.charCodeAt(h);u[h*2]=m>>>8,u[h*2+1]=m%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 p=[];return c.forEach(function(m){p.push(t(m))}),a.decompress(p.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 o(s,l.charAt(c))}))},compress:function(l){return a._compress(l,16,function(c){return t(c)})},_compress:function(l,c,u){if(l==null)return"";var h,p,m={},S={},x="",v="",w="",C=2,_=3,E=2,T=[],A=0,O=0,D;for(D=0;D<l.length;D+=1)if(x=l.charAt(D),Object.prototype.hasOwnProperty.call(m,x)||(m[x]=_++,S[x]=!0),v=w+x,Object.prototype.hasOwnProperty.call(m,v))w=v;else{if(Object.prototype.hasOwnProperty.call(S,w)){if(w.charCodeAt(0)<256){for(h=0;h<E;h++)A=A<<1,O==c-1?(O=0,T.push(u(A)),A=0):O++;for(p=w.charCodeAt(0),h=0;h<8;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1}else{for(p=1,h=0;h<E;h++)A=A<<1|p,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=0;for(p=w.charCodeAt(0),h=0;h<16;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1}C--,C==0&&(C=Math.pow(2,E),E++),delete S[w]}else for(p=m[w],h=0;h<E;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1;C--,C==0&&(C=Math.pow(2,E),E++),m[v]=_++,w=String(x)}if(w!==""){if(Object.prototype.hasOwnProperty.call(S,w)){if(w.charCodeAt(0)<256){for(h=0;h<E;h++)A=A<<1,O==c-1?(O=0,T.push(u(A)),A=0):O++;for(p=w.charCodeAt(0),h=0;h<8;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1}else{for(p=1,h=0;h<E;h++)A=A<<1|p,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=0;for(p=w.charCodeAt(0),h=0;h<16;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1}C--,C==0&&(C=Math.pow(2,E),E++),delete S[w]}else for(p=m[w],h=0;h<E;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1;C--,C==0&&(C=Math.pow(2,E),E++)}for(p=2,h=0;h<E;h++)A=A<<1|p&1,O==c-1?(O=0,T.push(u(A)),A=0):O++,p=p>>1;for(;;)if(A=A<<1,O==c-1){T.push(u(A));break}else O++;return T.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=[],p=4,m=4,S=3,x="",v=[],w,C,_,E,T,A,O,D={val:u(0),position:c,index:1};for(w=0;w<3;w+=1)h[w]=w;for(_=0,T=Math.pow(2,2),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;switch(_){case 0:for(_=0,T=Math.pow(2,8),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;O=t(_);break;case 1:for(_=0,T=Math.pow(2,16),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;O=t(_);break;case 2:return""}for(h[3]=O,C=O,v.push(O);;){if(D.index>l)return"";for(_=0,T=Math.pow(2,S),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;switch(O=_){case 0:for(_=0,T=Math.pow(2,8),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;h[m++]=t(_),O=m-1,p--;break;case 1:for(_=0,T=Math.pow(2,16),A=1;A!=T;)E=D.val&D.position,D.position>>=1,D.position==0&&(D.position=c,D.val=u(D.index++)),_|=(E>0?1:0)*A,A<<=1;h[m++]=t(_),O=m-1,p--;break;case 2:return v.join("")}if(p==0&&(p=Math.pow(2,S),S++),h[O])x=h[O];else if(O===m)x=C+C.charAt(0);else return null;v.push(x),h[m++]=C+x.charAt(0),p--,C=x,p==0&&(p=Math.pow(2,S),S++)}}};return a}();n!=null?n.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(zC)),zC.exports}var Ife=kfe();const yU=Ua(Ife),Y_="web image/vnd.tldraw+png",Efe={png:Y_},_fe={[Y_]:"image/png"};function Tfe(n){return bn(Efe,n)??null}function Mfe(n){return bn(_fe,n)??n}function Afe(n){return typeof ClipboardItem<"u"&&"supports"in ClipboardItem&&ClipboardItem.supports(n)}function Ofe(n){const e=Object.entries(n);for(const[t,r]of e)r.catch(s=>console.error(s));return navigator.clipboard.write([new ClipboardItem(n)]).catch(t=>(console.error(t),Promise.all(e.map(async([r,s])=>[r,await s])).then(r=>{const s=e3(r);return navigator.clipboard.write([new ClipboardItem(s)])})))}async function Rfe(n,e,t,r){const s=e.map(i=>i instanceof File?i:new File([i],"tldrawFile",{type:i.type}));n.markHistoryStoppingPoint("paste"),await n.putExternalContent({type:"files",files:s,point:t,ignoreParent:!1,sources:r})}async function $k(n,e,t,r){return n.markHistoryStoppingPoint("paste"),await n.putExternalContent({type:"url",point:t,url:e,sources:r})}const Dfe=[Y_,"image/png","image/jpeg","image/webp","image/svg+xml"];function $C(n){const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=n.trim(),e.body.textContent||e.body.innerText||""}const jfe=n=>{try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},Lfe=n=>{const e=n.split(/[\n\s]/);for(const t of e)try{const r=new URL(t);if(!(r.protocol==="http:"||r.protocol==="https:"))return}catch{return}return lz(e)},Nfe=n=>/^<svg/.test(n),Ffe=["input","select","textarea"];function BC(n){const{activeElement:e}=document;return n.menus.hasAnyOpenMenus()||e&&(e.isContentEditable||Ffe.indexOf(e.tagName.toLowerCase())>-1)}const Vm=(n,e,t,r)=>{const s=Lfe(e);if(s)for(const i of s)$k(n,i,t);else jfe(e)?$k(n,e,t):Nfe(e)?(n.markHistoryStoppingPoint("paste"),n.putExternalContent({type:"svg-text",text:e,point:t,sources:r})):(n.markHistoryStoppingPoint("paste"),n.putExternalContent({type:"text",text:e,point:t,sources:r}))},zfe=async(n,e,t)=>{if(n.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(i=>i(s.getAsFile()))});break}case"string":{s.type==="text/html"?r.push({type:"html",source:new Promise(i=>s.getAsString(i))}):s.type==="text/plain"?r.push({type:"text",source:new Promise(i=>s.getAsString(i))}):r.push({type:s.type,source:new Promise(i=>s.getAsString(i))});break}}vU(n,r,t)},SU=async({editor:n,clipboardItems:e,point:t,fallbackFiles:r})=>{const s=[];for(const i of e){for(const o of Dfe)if(i.types.includes(o)){const a=i.getType(o).then(l=>Kr.rewriteMimeType(l,Mfe(o)));s.push({type:"blob",source:a});break}i.types.includes("text/html")&&s.push({type:"html",source:(async()=>{const o=await i.getType("text/html");return await Kr.blobToText(o)})()}),i.types.includes("text/uri-list")&&s.push({type:"url",source:(async()=>{const o=await i.getType("text/uri-list");return await Kr.blobToText(o)})()}),i.types.includes("text/plain")&&s.push({type:"text",source:(async()=>{const o=await i.getType("text/plain");return await Kr.blobToText(o)})()})}return r!=null&&r.length&&s.length===1&&s[0].type==="text"?(s.pop(),s.push(...r.map(i=>({type:"file",source:Promise.resolve(i)})))):r!=null&&r.length&&s.length===0&&s.push(...r.map(i=>({type:"file",source:Promise.resolve(i)}))),await vU(n,s,t)};async function vU(n,e,t){const r=e.filter(i=>(i.type==="file"||i.type==="blob")&&i.source!==null);if(r.length){if(r.length>n.options.maxFilesAtOnce)throw Error("Too many files");const i=rt(await Promise.all(r.map(o=>o.source)));return await Rfe(n,i,t)}const s=await Promise.all(e.filter(i=>i.type!=="file").map(i=>new Promise(o=>{const a=i;if(a.type==="file"){o({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=yU.decompressFromBase64(c);if(h===null){o({type:"error",data:h,reason:"found tldraw data comment but could not parse base64"});return}else{const p=JSON.parse(h);if(p.type!=="application/tldraw"&&o({type:"error",data:p,reason:`found tldraw data comment but JSON was of a different type: ${p.type}`}),typeof p.data=="string"){o({type:"error",data:p,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}o({type:"tldraw",data:p.data});return}}catch{o({type:"error",data:c,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){o({type:"text",data:l,subtype:"html"});return}if(a.type==="url"){o({type:"text",data:l,subtype:"url"});return}try{const h=JSON.parse(l);if(h.type==="excalidraw/clipboard"){o({type:"excalidraw",data:h});return}else{o({type:"text",data:l,subtype:"json"});return}}catch{o({type:"text",data:l,subtype:"text"});return}}o({type:"error",data:l,reason:"unhandled case"})})})));for(const i of s)if(i.type==="tldraw"){n.markHistoryStoppingPoint("paste"),n.putExternalContent({type:"tldraw",content:i.data,point:t});return}for(const i of s)if(i.type==="excalidraw"){n.markHistoryStoppingPoint("paste"),n.putExternalContent({type:"excalidraw",content:i.data,point:t});return}for(const i of s){if(i.type==="text"&&i.subtype==="html"){const a=new DOMParser().parseFromString(i.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(c=>c.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="A"&&a.firstElementChild.hasAttribute("href")&&a.firstElementChild.getAttribute("href")!==""){const c=a.firstElementChild.getAttribute("href");Vm(n,c,t,s);return}if(!s.some(c=>c.type==="text"&&c.subtype!=="html")&&i.data.trim()&&($C(i.data)??"")){Vm(n,$C(i.data),t,s);return}if(s.some(c=>c.type==="text"&&c.subtype!=="html")){const c=$C(i.data)??"";if(c){n.markHistoryStoppingPoint("paste"),n.putExternalContent({type:"text",text:c,html:i.data,point:t,sources:s});return}}}if(i.type==="text"&&i.subtype==="text"&&i.data.startsWith("<iframe ")){const a=new DOMParser().parseFromString(i.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(c=>c.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="IFRAME"&&a.firstElementChild.hasAttribute("src")&&a.firstElementChild.getAttribute("src")!==""){const c=a.firstElementChild.getAttribute("src");Vm(n,c,t,s);return}}}for(const i of s)if(i.type==="text"&&i.subtype==="url"){$k(n,i.data,t,s);return}for(const i of s)if(i.type==="text"&&i.subtype==="text"&&i.data.trim()){Vm(n,i.data,t,s);return}}const LS=async n=>{var r;const e=await n.resolveAssetsInContent(n.getContentFromCurrentPage(n.getSelectedShapeIds()));if(!e){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const t=yU.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:e}));if(!(typeof navigator>"u")){const s=e.shapes.map(i=>n.getShapeUtil(i).getText(i)).filter(dq);if((r=navigator.clipboard)!=null&&r.write){const i=new Blob([`<div data-tldraw>${t}</div>`],{type:"text/html"});let o=s.join(" ");o===""&&(o=" "),navigator.clipboard.write([new ClipboardItem({"text/html":i,"text/plain":new Blob([o],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<div data-tldraw>${t}</div>`)}};function $fe(){const n=dr(),e=Ln(),t=P.useCallback(async function(o){Je(n,"editor is required for copy"),n.getSelectedShapeIds().length!==0&&(await LS(n),e("copy",{source:o}))},[n,e]),r=P.useCallback(async function(o){n&&n.getSelectedShapeIds().length!==0&&(await LS(n),n.deleteShapes(n.getSelectedShapeIds()),e("cut",{source:o}))},[n,e]),s=P.useCallback(async function(o,a,l){n&&n.getEditingShapeId()===null&&(Array.isArray(o)&&o[0]instanceof ClipboardItem?(SU({editor:n,clipboardItems:o,point:l}),e("paste",{source:"menu"})):navigator.clipboard.read().then(c=>{s(c,a,l)}))},[n,e]);return{copy:t,cut:r,paste:s}}function Bfe(){const n=te(),e=Ln(),t=ie("editor.isFocused",()=>n.getInstanceState().isFocused,[n]);P.useEffect(()=>{if(!t)return;const r=async l=>{n.getSelectedShapeIds().length===0||n.getEditingShapeId()!==null||BC(n)||(tt(l),await LS(n),e("copy",{source:"kbd"}))};async function s(l){n.getSelectedShapeIds().length===0||n.getEditingShapeId()!==null||BC(n)||(tt(l),await LS(n),n.deleteShapes(n.getSelectedShapeIds()),e("cut",{source:"kbd"}))}let i=!1;const o=l=>{l.button===1&&(i=!0,n.timers.requestAnimationFrame(()=>{i=!1}))},a=l=>{var p,m;if(i){Wt(l);return}if(n.getEditingShapeId()!==null||BC(n))return;let c,u=!1;n.inputs.shiftKey&&(u=!0),n.user.getIsPasteAtCursorMode()&&(u=!u),u&&(c=n.inputs.currentPagePoint);const h=()=>{l.clipboardData&&zfe(n,l.clipboardData,c)};if((p=navigator.clipboard)!=null&&p.read){const S=Array.from(((m=l.clipboardData)==null?void 0:m.files)||[]);navigator.clipboard.read().then(x=>{Array.isArray(x)&&x[0]instanceof ClipboardItem&&SU({editor:n,clipboardItems:x,point:c,fallbackFiles:S})},()=>{h()})}else h();tt(l),e("paste",{source:"kbd"})};return document.addEventListener("copy",r),document.addEventListener("cut",s),document.addEventListener("paste",a),document.addEventListener("pointerup",o),()=>{document.removeEventListener("copy",r),document.removeEventListener("cut",s),document.removeEventListener("paste",a),document.removeEventListener("pointerup",o)}},[n,e,t])}const DL={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",svg:"text/plain"};function Ufe(n,e,t={}){const r=e!=null&&e.length?e:[...n.getCurrentPageShapeIds()],s=t.format??"png";return{blobPromise:n.toImage(r,t).then(i=>Kr.rewriteMimeType(i.blob,DL[s])),mimeType:DL[s]}}function Hfe(...n){const[e,t,r]=typeof n[2]=="string"?[n[0],n[1],{...n[3],format:n[2]}]:n;if(!navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(navigator.clipboard.write){const{blobPromise:s,mimeType:i}=Ufe(e,t,r),o={[i]:s},a=Tfe(r.format);return a&&Afe(a)&&(o[a]=s.then(l=>Kr.rewriteMimeType(l,a))),Ofe(o)}switch(r.format){case"svg":return Kfe(async()=>{const s=await e.getSvgString(t,r);if(!s)throw new Error("Failed to copy");return s.svg});case"png":throw new Error("Copy not supported");default:An(r.format)}}async function Kfe(n){var e,t;await((t=(e=navigator.clipboard)==null?void 0:e.writeText)==null?void 0:t.call(e,await n()))}function Wfe(){const n=dr(),{addToast:e}=Ya(),t=it();return P.useCallback((r,s="svg")=>{Je(n,"useCopyAs: editor is required"),Hfe(n,r,{format:s}).catch(()=>{e({id:"copy-fail",severity:"warning",title:t("toast.error.copy-fail.title"),description:t("toast.error.copy-fail.desc")})})},[n,e,t])}async function Vfe(...n){const[e,t,r]=typeof n[2]=="object"?n:[n[0],n[1],{...n[4],format:n[2]??"png",name:n[3]}];let s=r.name;if(!s&&(s=`shapes at ${jL()}`,t.length===1)){const a=e.getShape(t[0]);e.isShapeOfType(a,"frame")?s=a.props.name||"frame":s=`${Y0(a.id)} at ${jL()}`}s+=`.${r.format}`;const{blob:i}=await e.toImage(t,r),o=new File([i],s,{type:i.type});qfe(o)}function jL(){const n=new Date,e=String(n.getFullYear()).slice(2),t=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0"),s=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0"),o=String(n.getSeconds()).padStart(2,"0");return`${e}-${t}-${r} ${s}.${i}.${o}`}function qfe(n){const e=document.createElement("a"),t=URL.createObjectURL(n);e.href=t,e.download=n.name,e.click(),URL.revokeObjectURL(t)}function Gfe(){const n=dr(),{addToast:e}=Ya(),t=it();return P.useCallback((r,s="png",i)=>{Je(n,"useExportAs: editor is required"),Vfe(n,r,{format:s,name:i,scale:1}).catch(o=>{console.error(o.message),e({id:"export-fail",title:t("toast.error.export-fail.title"),description:t("toast.error.export-fail.desc"),severity:"error"})})},[n,e,t])}const xU=at.createContext([]);function Yfe(){const n=dr(),e=P.useRef(),t=Ol(at.useContext(xU));return P.useEffect(()=>{const r=n;if(!r)return;const s=window.document.createElement("input");s.type="file",s.accept=(t==null?void 0:t.join(","))??$V,s.multiple=!0,e.current=s;async function i(o){const a=o.target.files;!a||a.length===0||(r.markHistoryStoppingPoint("insert media"),await r.putExternalContent({type:"files",files:Array.from(a),point:r.getViewportPageBounds().center,ignoreParent:!1}),s.value="")}return s.addEventListener("change",i),()=>{e.current=void 0,s.removeEventListener("change",i)}},[n,t]),P.useCallback(()=>{var r;(r=e.current)==null||r.click()},[e])}function Xfe(){const n=dr(),e=P.useRef(null),t=P.useRef(null);return P.useCallback(async function(){Je(n,"usePrint: editor is required");const s=document.createElement("div"),i=document.createElement("style"),o=(w,C)=>{w&&(w.innerHTML=""),C&&document.head.contains(C)&&document.head.removeChild(C),w&&document.body.contains(w)&&document.body.removeChild(w)};o(e.current,t.current),e.current=s,t.current=i;const a=`tl-print-surface-${_t()}`;s.className=a,i.innerHTML=`
|
|
351
|
-
.${a} {
|
|
352
|
-
display: none;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.${a} svg {
|
|
356
|
-
max-width: 100%;
|
|
357
|
-
height: 100%;
|
|
358
|
-
display: block;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
@media print {
|
|
362
|
-
html, body {
|
|
363
|
-
min-height: 100%;
|
|
364
|
-
height: 100%;
|
|
365
|
-
margin: 0;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
body {
|
|
369
|
-
position: relative;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
body > * {
|
|
373
|
-
display: none;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.tldraw__editor {
|
|
377
|
-
display: none;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
.${a} {
|
|
381
|
-
display: block !important;
|
|
382
|
-
background: white;
|
|
383
|
-
min-height: 100%;
|
|
384
|
-
height: 100%;
|
|
385
|
-
max-width: 100%;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
.${a}__item {
|
|
389
|
-
padding: 10mm;
|
|
390
|
-
display: flex;
|
|
391
|
-
min-height: 100%;
|
|
392
|
-
flex-direction: column;
|
|
393
|
-
page-break-after: always;
|
|
394
|
-
position: relative;
|
|
395
|
-
overflow: hidden;
|
|
396
|
-
height: 100%;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
.${a}__item__main {
|
|
400
|
-
flex: 1;
|
|
401
|
-
display: flex;
|
|
402
|
-
align-items: center;
|
|
403
|
-
justify-content: center;
|
|
404
|
-
max-height: 100%;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.${a}__item__header {
|
|
408
|
-
display: none;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.${a}__item__footer {
|
|
412
|
-
display: none;
|
|
413
|
-
text-align: right;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
.${a}__item__footer__hide {
|
|
417
|
-
display: none;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
`;const l=()=>{document.head.appendChild(i),document.body.appendChild(s)},c=()=>{n.once("tick",()=>{o(s,i)})};window.addEventListener("beforeprint",l),window.addEventListener("afterprint",c);function u(w,C,_){try{s.innerHTML+=`<div class="${a}__item">
|
|
424
|
-
<div class="${a}__item__header">
|
|
425
|
-
${w.replace(/</g,"<").replace(/>/g,">")}
|
|
426
|
-
</div>
|
|
427
|
-
<div class="${a}__item__main">
|
|
428
|
-
${_}
|
|
429
|
-
</div>
|
|
430
|
-
<div class="${a}__item__footer ${a}__item__footer__${C?"":"hide"}">
|
|
431
|
-
${C??""}
|
|
432
|
-
</div>
|
|
433
|
-
</div>`}catch(E){console.error(E)}}function h(){It.isChromeForIos?(l(),window.print()):It.isSafari?(l(),document.execCommand("print",!1)):window.print()}const p=n.getSelectedShapeIds(),m=n.getCurrentPageId(),S=n.getPages(),v={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(n.getSelectedShapeIds().length>0){const w=await n.getSvgString(p,v);if(w){const C=S.find(_=>_.id===m);u(`tldraw — ${C==null?void 0:C.name}`,null,w.svg),h()}}else{const w=n.getCurrentPage(),C=await n.getSvgString(n.getSortedChildIdsForParent(w.id),v);C&&(u(`tldraw — ${w.name}`,null,C.svg),h())}window.removeEventListener("beforeprint",l),window.removeEventListener("afterprint",c)},[n])}function X_(){const{addToast:n,removeToast:e,clearToasts:t}=Ya(),{addDialog:r,clearDialogs:s,removeDialog:i}=cg(),o=it(),a=Yfe(),l=Xfe(),{cut:c,copy:u,paste:h}=$fe(),p=Wfe(),m=Gfe(),S=K_(),v=Rr()<dn.TABLET_SM;return P.useMemo(()=>({addToast:n,removeToast:e,clearToasts:t,addDialog:r,removeDialog:i,clearDialogs:s,msg:o,isMobile:v,insertMedia:a,printSelectionOrPages:l,cut:c,copy:u,paste:h,copyAs:p,exportAs:m,getEmbedDefinition:S}),[n,e,t,r,i,s,o,v,a,l,c,u,h,p,m,S])}function Zfe(n,e){const t={};for(const r of n)if(r.translations)for(const[s,i]of Is(r.translations)){let o=t[s];o||(o=t[s]={}),Object.assign(o,i)}return{actions:(r,s,i)=>{for(const o of n)o.actions&&(s=o.actions(r,s,i));return s},tools:(r,s,i)=>{for(const o of n)o.tools&&(s=o.tools(r,s,{...e,...i}));return s},translations:t}}function wU(n){return P.useMemo(()=>n,n)}function Jfe(n){const e=wU(n==null?[]:Array.isArray(n)?n:[n]);return P.useMemo(()=>{const t={};for(const r of e)if(r.translations)for(const[s,i]of Is(r.translations)){let o=t[s];o||(o=t[s]={}),Object.assign(o,i)}return t},[e])}function Qfe(n){const e=X_(),t=wU(n==null?[]:Array.isArray(n)?n:[n]);return P.useMemo(()=>Zfe(t,e),[t,e])}const bU=P.createContext(null);function epe(n){return Object.fromEntries(n.map(e=>[e.id,e]))}function qm(n,e){if(n.getSelectedShapes().length===0)return n.getDocumentSettings().name||e}function tpe({overrides:n,children:e}){const t=dr(),r=Tv(),s=X_(),i=Ln(),o=hv(),a=it(),l=s.msg("document.default-name"),c=P.useMemo(()=>{const u=t;if(!u)return{};function h(){return u.isIn("select")||(u.complete(),u.setCurrentTool("select")),!1}function p(){return u.isIn("select")&&u.getSelectedShapeIds().length>0}function m(v){if(!p()||h())return;u.markHistoryStoppingPoint("resize shapes");const w=u.getSelectedShapeIds();w.length!==0&&u.run(()=>{w.map(_=>u.getShape(_)).filter(Boolean).forEach(_=>{var E;u.resizeShape(_.id,new k(v,v),{scaleOrigin:(E=u.getSelectionPageBounds())==null?void 0:E.center})})})}const S=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(v){p()&&(h()||(i("edit-link",{source:v}),u.markHistoryStoppingPoint("edit-link"),s.addDialog({component:Hhe})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"cmd+i,ctrl+i",onSelect(v){i("insert-embed",{source:v}),s.addDialog({component:nU})}},{id:"insert-media",label:"action.insert-media",kbd:"cmd+u,ctrl+u",onSelect(v){i("insert-media",{source:v}),s.insertMedia()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"cmd+z,ctrl+z",onSelect(v){i("undo",{source:v}),u.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"cmd+shift+z,ctrl+shift+z",onSelect(v){i("redo",{source:v}),u.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(v){let w=u.getSelectedShapeIds();w.length===0&&(w=Array.from(u.getCurrentPageShapeIds().values())),w.length!==0&&(i("export-as",{format:"svg",source:v}),s.exportAs(w,"svg",qm(u,l)))}},{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(v){let w=u.getSelectedShapeIds();w.length===0&&(w=Array.from(u.getCurrentPageShapeIds().values())),w.length!==0&&(i("export-as",{format:"png",source:v}),s.exportAs(w,"png",qm(u,l)))}},{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(v){let w=u.getSelectedShapeIds();w.length===0&&(w=Array.from(u.getCurrentPageShapeIds().values())),w.length!==0&&(i("export-all-as",{format:"svg",source:v}),s.exportAs(Array.from(u.getCurrentPageShapeIds()),"svg",qm(u,l)))}},{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(v){const w=Array.from(u.getCurrentPageShapeIds().values());w.length!==0&&(i("export-all-as",{format:"png",source:v}),s.exportAs(w,"png",qm(u,l)))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},kbd:"cmd+shift+c,ctrl+shift+c",readonlyOk:!0,onSelect(v){let w=u.getSelectedShapeIds();w.length===0&&(w=Array.from(u.getCurrentPageShapeIds().values())),w.length!==0&&(i("copy-as",{format:"svg",source:v}),s.copyAs(w,"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(v){let w=u.getSelectedShapeIds();w.length===0&&(w=Array.from(u.getCurrentPageShapeIds().values())),w.length!==0&&(i("copy-as",{format:"png",source:v}),s.copyAs(w,"png"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(v){p()&&(h()||(i("toggle-auto-size",{source:v}),u.markHistoryStoppingPoint("toggling auto size"),u.run(()=>{const w=u.getSelectedShapes().filter(C=>u.isShapeOfType(C,"text")&&C.props.autoSize===!1);u.updateShapes(w.map(C=>({id:C.id,type:C.type,props:{...C.props,w:8,autoSize:!0}}))),Ht(u,w.map(C=>C.id))})))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(v){i("open-embed-link",{source:v});const w=u.getSelectedShapeIds(),C="No embed shapes selected";if(w.length!==1){console.error(C);return}const _=u.getShape(w[0]);if(!_||!u.isShapeOfType(_,"embed")){console.error(C);return}ile(_.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(v){var w,C;if(((w=u.root.getCurrent())==null?void 0:w.id)!=="zoom"&&(i("zoom-tool",{source:v}),!(u.inputs.shiftKey||u.inputs.ctrlKey))){const _=u.root.getCurrent();_&&((C=_.getCurrent())==null?void 0:C.id)==="idle"&&u.setCurrentTool("zoom",{onInteractionEnd:_.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(v){p()&&(h()||u.run(()=>{i("convert-to-bookmark",{source:v});const w=u.getSelectedShapes(),C=[],_=[];for(const E of w){if(!E||!u.isShapeOfType(E,"embed")||!E.props.url)continue;const T=new k(E.x,E.y);T.rot(-E.rotation),T.add(new k(E.props.w/2-300/2,E.props.h/2-320/2)),T.rot(E.rotation);const A={id:Dt(),type:"bookmark",rotation:E.rotation,x:T.x,y:T.y,opacity:1,props:{url:E.props.url}};C.push(A),_.push(E.id)}u.markHistoryStoppingPoint("convert shapes to bookmark"),u.deleteShapes(_),u.createShapes(C)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(v){p()&&(h()||(i("convert-to-embed",{source:v}),u.run(()=>{const w=u.getSelectedShapeIds(),C=rt(w.map(T=>u.getShape(T))),_=[],E=[];for(const T of C){if(!u.isShapeOfType(T,"bookmark"))continue;const{url:A}=T.props,O=s.getEmbedDefinition(A);if(!O||!O.definition)continue;const{width:D,height:$}=O.definition,H=new k(T.x,T.y);H.rot(-T.rotation),H.add(new k(T.props.w/2-D/2,T.props.h/2-$/2)),H.rot(T.rotation);const G={id:Dt(),type:"embed",x:H.x,y:H.y,rotation:T.rotation,props:{url:A,w:D,h:$}};_.push(G),E.push(T.id)}u.markHistoryStoppingPoint("convert shapes to embed"),u.deleteShapes(E),u.createShapes(_)})))}},{id:"duplicate",kbd:"cmd+d,ctrl+d",label:"action.duplicate",icon:"duplicate",onSelect(v){if(!p()||h())return;i("duplicate-shapes",{source:v});const w=u.getInstanceState();let C,_;if(w.duplicateProps)C=w.duplicateProps.shapeIds,_=w.duplicateProps.offset;else{C=u.getSelectedShapeIds();const E=Se.Common(rt(C.map(T=>u.getShapePageBounds(T))));_=u.getCameraOptions().isLocked?{x:u.options.adjacentShapeMargin,y:u.options.adjacentShapeMargin}:{x:E.width+u.options.adjacentShapeMargin,y:0}}u.markHistoryStoppingPoint("duplicate shapes"),u.duplicateShapes(C,_),w.duplicateProps&&u.updateInstanceState({duplicateProps:{...w.duplicateProps,shapeIds:u.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"cmd+shift+g,ctrl+shift+g",icon:"ungroup",onSelect(v){p()&&(h()||(i("ungroup-shapes",{source:v}),u.markHistoryStoppingPoint("ungroup"),u.ungroupShapes(u.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"cmd+g,ctrl+g",icon:"group",onSelect(v){if(!p()||h())return;i("group-shapes",{source:v});const w=u.getOnlySelectedShape();w&&u.isShapeOfType(w,"group")?(u.markHistoryStoppingPoint("ungroup"),u.ungroupShapes(u.getSelectedShapeIds())):(u.markHistoryStoppingPoint("group"),u.groupShapes(u.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"cmd+shift+f,ctrl+shift+f",onSelect(v){if(!p())return;i("remove-frame",{source:v});const w=u.getSelectedShapes();w.length>0&&w.every(C=>u.isShapeOfType(C,"frame"))&&(u.markHistoryStoppingPoint("remove-frame"),Phe(u,w.map(C=>C.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(v){if(!p())return;i("fit-frame-to-content",{source:v});const w=u.getOnlySelectedShape();w&&u.isShapeOfType(w,"frame")&&(u.markHistoryStoppingPoint("fit-frame-to-content"),Ihe(u,w.id))}},{id:"align-left",label:"action.align-left",kbd:"alt+A",icon:"align-left",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"left",source:v}),u.markHistoryStoppingPoint("align left"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"left"),Ht(u,w)})))}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"alt+H",icon:"align-center-horizontal",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"center-horizontal",source:v}),u.markHistoryStoppingPoint("align center horizontal"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"center-horizontal"),Ht(u,w)})))}},{id:"align-right",label:"action.align-right",kbd:"alt+D",icon:"align-right",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"right",source:v}),u.markHistoryStoppingPoint("align right"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"right"),Ht(u,w)})))}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"alt+V",icon:"align-center-vertical",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"center-vertical",source:v}),u.markHistoryStoppingPoint("align center vertical"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"center-vertical"),Ht(u,w)})))}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"alt+W",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"top",source:v}),u.markHistoryStoppingPoint("align top"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"top"),Ht(u,w)})))}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"alt+S",onSelect(v){p()&&(h()||(i("align-shapes",{operation:"bottom",source:v}),u.markHistoryStoppingPoint("align bottom"),u.run(()=>{const w=u.getSelectedShapeIds();u.alignShapes(w,"bottom"),Ht(u,w)})))}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"alt+shift+h",onSelect(v){p()&&(h()||(i("distribute-shapes",{operation:"horizontal",source:v}),u.markHistoryStoppingPoint("distribute horizontal"),u.run(()=>{const w=u.getSelectedShapeIds();u.distributeShapes(w,"horizontal"),Ht(u,w)})))}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"alt+shift+V",onSelect(v){p()&&(h()||(i("distribute-shapes",{operation:"vertical",source:v}),u.markHistoryStoppingPoint("distribute vertical"),u.run(()=>{const w=u.getSelectedShapeIds();u.distributeShapes(w,"vertical"),Ht(u,w)})))}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(v){p()&&(h()||(i("stretch-shapes",{operation:"horizontal",source:v}),u.markHistoryStoppingPoint("stretch horizontal"),u.run(()=>{const w=u.getSelectedShapeIds();u.stretchShapes(w,"horizontal"),Ht(u,w)})))}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(v){p()&&(h()||(i("stretch-shapes",{operation:"vertical",source:v}),u.markHistoryStoppingPoint("stretch vertical"),u.run(()=>{const w=u.getSelectedShapeIds();u.stretchShapes(w,"vertical"),Ht(u,w)})))}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"shift+h",onSelect(v){p()&&(h()||(i("flip-shapes",{operation:"horizontal",source:v}),u.markHistoryStoppingPoint("flip horizontal"),u.run(()=>{const w=u.getSelectedShapeIds();u.flipShapes(w,"horizontal"),Ht(u,w)})))}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"shift+v",onSelect(v){p()&&(h()||(i("flip-shapes",{operation:"vertical",source:v}),u.markHistoryStoppingPoint("flip vertical"),u.run(()=>{const w=u.getSelectedShapeIds();u.flipShapes(w,"vertical"),Ht(u,w)})))}},{id:"pack",label:"action.pack",icon:"pack",onSelect(v){p()&&(h()||(i("pack-shapes",{source:v}),u.markHistoryStoppingPoint("pack"),u.run(()=>{const w=u.getSelectedShapeIds();u.packShapes(w,u.options.adjacentShapeMargin),Ht(u,w)})))}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(v){p()&&(h()||(i("stack-shapes",{operation:"vertical",source:v}),u.markHistoryStoppingPoint("stack-vertical"),u.run(()=>{const w=u.getSelectedShapeIds();u.stackShapes(w,"vertical",u.options.adjacentShapeMargin),Ht(u,w)})))}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(v){p()&&(h()||(i("stack-shapes",{operation:"horizontal",source:v}),u.markHistoryStoppingPoint("stack-horizontal"),u.run(()=>{const w=u.getSelectedShapeIds();u.stackShapes(w,"horizontal",u.options.adjacentShapeMargin),Ht(u,w)})))}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(v){p()&&(h()||(i("reorder-shapes",{operation:"toFront",source:v}),u.markHistoryStoppingPoint("bring to front"),u.bringToFront(u.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"alt+]",onSelect(v){p()&&(h()||(i("reorder-shapes",{operation:"forward",source:v}),u.markHistoryStoppingPoint("bring forward"),u.bringForward(u.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"alt+[",onSelect(v){p()&&(h()||(i("reorder-shapes",{operation:"backward",source:v}),u.markHistoryStoppingPoint("send backward"),u.sendBackward(u.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(v){p()&&(h()||(i("reorder-shapes",{operation:"toBack",source:v}),u.markHistoryStoppingPoint("send to back"),u.sendToBack(u.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"cmd+x,ctrl+x",onSelect(v){p()&&(h()||(u.markHistoryStoppingPoint("cut"),s.cut(v)))}},{id:"copy",label:"action.copy",kbd:"cmd+c,ctrl+c",readonlyOk:!0,onSelect(v){p()&&(h()||s.copy(v))}},{id:"paste",label:"action.paste",kbd:"cmd+v,ctrl+v",onSelect(v){var w;(w=navigator.clipboard)==null||w.read().then(C=>{s.paste(C,v,v==="context-menu"?u.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:"cmd+a,ctrl+a",readonlyOk:!0,onSelect(v){u.run(()=>{h()||(i("select-all-shapes",{source:v}),u.markHistoryStoppingPoint("select all kbd"),u.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(v){p()&&(h()||(i("select-none-shapes",{source:v}),u.markHistoryStoppingPoint("select none"),u.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del",icon:"trash",onSelect(v){p()&&(h()||(i("delete-shapes",{source:v}),u.markHistoryStoppingPoint("delete"),u.deleteShapes(u.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(v){p()&&(h()||(i("rotate-cw",{source:v}),u.markHistoryStoppingPoint("rotate-cw"),u.run(()=>{const w=u.getSelectionRotation()%(Kt/2),C=_a(w,0)||_a(w,Kt/2),_=u.getSelectedShapeIds();u.rotateShapesBy(_,Kt/2-(C?0:w)),Ht(u,_)})))}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(v){p()&&(h()||(i("rotate-ccw",{source:v}),u.markHistoryStoppingPoint("rotate-ccw"),u.run(()=>{const w=u.getSelectionRotation()%(Kt/2),C=_a(w,0),_=u.getSelectedShapeIds();u.rotateShapesBy(_,C?-(Kt/2):-w),Ht(u,_)})))}},{id:"zoom-in",label:"action.zoom-in",kbd:"cmd+=,ctrl+=,=",readonlyOk:!0,onSelect(v){i("zoom-in",{source:v,towardsCursor:!1}),u.zoomIn(void 0,{animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-in-on-cursor",label:"action.zoom-in",kbd:"shift+cmd+=,shift+ctrl+=,shift+=",readonlyOk:!0,onSelect(v){i("zoom-in",{source:v,towardsCursor:!0}),u.zoomIn(u.inputs.currentScreenPoint,{animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"cmd+-,ctrl+-,-",readonlyOk:!0,onSelect(v){i("zoom-out",{source:v,towardsCursor:!1}),u.zoomOut(void 0,{animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-out-on-cursor",label:"action.zoom-out",kbd:"shift+cmd+-,shift+ctrl+-,shift+-",readonlyOk:!0,onSelect(v){i("zoom-out",{source:v,towardsCursor:!0}),u.zoomOut(u.inputs.currentScreenPoint,{animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"shift+0",readonlyOk:!0,onSelect(v){i("reset-zoom",{source:v}),u.resetZoom(void 0,{animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"shift+1",readonlyOk:!0,onSelect(v){i("zoom-to-fit",{source:v}),u.zoomToFit({animation:{duration:u.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"shift+2",readonlyOk:!0,onSelect(v){p()&&(h()||(i("zoom-to-selection",{source:v}),u.zoomToSelection({animation:{duration:u.options.animationMediumMs}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(v){i("toggle-snap-mode",{source:v}),u.user.updateUserPreferences({isSnapMode:!u.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"cmd+/,ctrl+/",readonlyOk:!0,onSelect(v){const w=u.user.getIsDarkMode()?"light":"dark";i("color-scheme",{source:v,value:w}),u.user.updateUserPreferences({colorScheme:w})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(v){i("toggle-wrap-mode",{source:v}),u.user.updateUserPreferences({isWrapMode:!u.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(v){i("toggle-dynamic-size-mode",{source:v}),u.user.updateUserPreferences({isDynamicSizeMode:!u.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(v){i("toggle-paste-at-cursor",{source:v}),u.user.updateUserPreferences({isPasteAtCursorMode:!u.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(v){i("toggle-reduce-motion",{source:v}),u.user.updateUserPreferences({animationSpeed:u.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(v){i("toggle-edge-scrolling",{source:v}),u.user.updateUserPreferences({edgeScrollSpeed:u.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(v){i("toggle-transparent",{source:v}),u.updateInstanceState({exportBackground:!u.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(v){i("toggle-tool-lock",{source:v}),u.updateInstanceState({isToolLocked:!u.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(v){i("unlock-all",{source:v});const w=[];for(const C of u.getCurrentPageShapes())C.isLocked&&w.push({id:C.id,type:C.type,isLocked:!1});w.length>0&&u.updateShapes(w)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"cmd+.,ctrl+.",checkbox:!0,onSelect(v){u.timers.requestAnimationFrame(()=>{u.run(()=>{i("toggle-focus-mode",{source:v}),s.clearDialogs(),s.clearToasts(),u.updateInstanceState({isFocusMode:!u.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"cmd+',ctrl+'",onSelect(v){i("toggle-grid-mode",{source:v}),u.updateInstanceState({isGridMode:!u.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(v){i("toggle-debug-mode",{source:v}),u.updateInstanceState({isDebugMode:!u.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"cmd+p,ctrl+p",readonlyOk:!0,onSelect(v){i("print",{source:v}),s.printSelectionOrPages()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(v){i("exit-pen-mode",{source:v}),u.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(v){i("stop-following",{source:v}),u.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(v){i("zoom-to-content",{source:v});const w=u.getSelectionPageBounds()??u.getCurrentPageBounds();w&&u.zoomToBounds(w,{targetZoom:Math.min(1,u.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"shift+l",onSelect(v){u.markHistoryStoppingPoint("locking"),i("toggle-lock",{source:v}),u.toggleLock(u.getSelectedShapeIds())}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(v){const w=Wr.createId(),C=u.getSelectedShapeIds();u.run(()=>{u.markHistoryStoppingPoint("move_shapes_to_page"),u.createPage({name:s.msg("page-menu.new-page-initial-name"),id:w}),u.moveShapesToPage(C,w)}),i("move-to-new-page",{source:v})}},{id:"select-white-color",label:"color-style.white",kbd:"alt+t",onSelect(v){const w=Yr;u.run(()=>{u.markHistoryStoppingPoint("change-color"),u.isIn("select")&&u.setStyleForSelectedShapes(w,"white"),u.setStyleForNextShapes(w,"white")}),i("set-style",{source:v,id:w.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"alt+f",onSelect(v){const w=ou;u.run(()=>{u.markHistoryStoppingPoint("change-fill"),u.isIn("select")&&u.setStyleForSelectedShapes(w,"fill"),u.setStyleForNextShapes(w,"fill")}),i("set-style",{source:v,id:w.id,value:"fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"shift+f",onSelect:async v=>{const w=u.getSelectedShapeIds();if(w.length===0)return;u.markHistoryStoppingPoint("flattening to image"),i("flatten-to-image",{source:v});const C=await Jhe(u,w,u.options.flattenImageBoundsExpand);C!=null&&C.length&&u.setSelectedShapes(C)}},{id:"select-geo-tool",kbd:"g",onSelect:async v=>{i("select-tool",{source:v,id:"geo-previous"}),u.setCurrentTool("geo")}},{id:"change-page-prev",kbd:"alt+left,alt+up",readonlyOk:!0,onSelect:async v=>{const w=u.getPages(),C=w.findIndex(_=>_.id===u.getCurrentPageId());C<1||(i("change-page",{source:v,direction:"prev"}),u.setCurrentPage(w[C-1].id))}},{id:"change-page-next",kbd:"alt+right,alt+down",readonlyOk:!0,onSelect:async v=>{const w=u.getPages(),C=w.findIndex(_=>_.id===u.getCurrentPageId());if(C===-1||C>=w.length-1){if(u.getCurrentPageShapes().length<=0||u.getIsReadonly())return;i("new-page",{source:v}),u.run(()=>{u.markHistoryStoppingPoint("creating page");const _=Wr.createId();u.createPage({name:s.msg("page-menu.new-page-initial-name"),id:_}),u.setCurrentPage(_)});return}u.setCurrentPage(w[C+1].id),i("change-page",{source:v,direction:"next"})}},{id:"enlarge-shapes",label:"a11y.enlarge-shape",kbd:"cmd+alt+shift+=,ctrl+alt+shift+=",onSelect:async v=>{m(1.1),i("enlarge-shapes",{source:v})}},{id:"shrink-shapes",label:"a11y.shrink-shape",kbd:"cmd+alt+shift+-,ctrl+alt+shift+-",onSelect:async v=>{m(1/1.1),i("shrink-shapes",{source:v})}},{id:"a11y-repeat-shape-announce",kbd:"alt+r",label:"a11y.repeat-shape",readonlyOk:!0,onSelect:async v=>{const w=u.getSelectedShapeIds();if(!w.length)return;const C=B6({editor:u,selectedShapeIds:w,msg:a});C&&(o.announce({msg:""}),u.timers.requestAnimationFrame(()=>{o.announce({msg:C})}),i("a11y-repeat-shape-announce",{source:v}))}}];r&&S.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(v){i("open-cursor-chat",{source:v}),!u.getInstanceState().isCoarsePointer&&u.timers.requestAnimationFrame(()=>{u.updateInstanceState({isChatting:!0})})}});const x=epe(S);return n?n(u,x,s):x},[s,t,i,n,l,r,a,o]);return g.jsx(bU.Provider,{value:c,children:e})}function bu(){const n=P.useContext(bU);if(!n)throw new Error("useTools must be used within a ToolProvider");return n}function Pp(n,e){return n?typeof n=="string"?n:e?n[e]??n.default:void 0:void 0}function ti(){const n=dr();return ie("isReadonlyMode",()=>!!(n!=null&&n.getIsReadonly()),[n])}const UC=It.isDarwin?"⌘":"Ctrl",LL=It.isDarwin?"⌥":"Alt";function CU(n){return n===","?[","]:n.split(",")[0].split(/(\[\[[^\]]+\]\])/g).map(e=>e.startsWith("[[")?e.replace(/[[\]]/g,""):e.replace(/cmd\+/g,UC).replace(/ctrl\+/g,UC).replace(/alt\+/g,LL).replace(/shift\+/g,"⇧").replace(/\$/g,UC).replace(/\?/g,LL).replace(/!/g,"⇧").split("")).flat().map(e=>e[0].toUpperCase()+e.slice(1))}function Bk(n){return"— "+CU(n).join(" ")}function Kf({children:n,visibleOnMobileLayout:e=!1}){const t=Rr();return!e&&t<dn.MOBILE?null:g.jsx("kbd",{className:"tlui-kbd",children:CU(n).map((r,s)=>g.jsx("span",{children:r},s))})}const PU=P.createContext(null);function Av(){const n=P.useContext(PU);if(!n)throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return n}function Zr({type:n,sourceId:e,children:t}){return g.jsx(PU.Provider,{value:{type:n,sourceId:e},children:t})}function Ov({id:n,kbd:e,label:t,readonlyOk:r,onSelect:s,toggle:i=!1,disabled:o=!1,checked:a=!1}){const{type:l,sourceId:c}=Av(),u=ti(),h=it();if(u&&!r)return null;const p=Pp(t,l),m=p?h(p):void 0;switch(l){case"menu":return g.jsxs(xhe,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:m,onSelect:S=>{s==null||s(c),tt(S)},disabled:o,checked:a,children:[g.jsx(Wo,{small:!0,icon:i?a?"toggle-on":"toggle-off":a?"check":"none"}),m&&g.jsx("span",{className:"tlui-button__label",draggable:!1,children:m}),e&&g.jsx(Kf,{children:e})]});case"context-menu":return g.jsxs(Xde,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:m,onSelect:S=>{s(c),tt(S)},disabled:o,checked:a,children:[g.jsx(Wo,{small:!0,icon:i?a?"toggle-on":"toggle-off":a?"check":"none"}),m&&g.jsx("span",{className:"tlui-button__label",draggable:!1,children:m}),e&&g.jsx(Kf,{children:e})]},n);default:return null}}function Xa(n,e){const t=dr(),r=P.useCallback(o=>{o&&(t==null||t.complete()),e==null||e(o)},[t,e]),s=Ln(),i=P.useCallback(o=>{s(o,{source:"unknown",id:n})},[n,s]);return Xae(t?`${n}-${t.contextId}`:n,r,i)}function Z_({id:n,children:e,modal:t=!1,debugOpen:r=!1}){const[s,i]=Xa(n);return g.jsx(L_,{open:r||s,dir:"ltr",modal:t,onOpenChange:i,children:e})}function J_({children:n,...e}){return g.jsx(N_,{dir:"ltr",asChild:!0,onTouchEnd:t=>tt(t),...e,children:n})}function Q_({className:n,side:e="bottom",align:t="start",sideOffset:r=8,alignOffset:s=8,children:i}){const o=kn();return g.jsx(Pv,{container:o,children:g.jsx(F_,{className:$e("tlui-menu",n),side:e,sideOffset:r,align:t,alignOffset:s,collisionPadding:4,children:i})})}function npe({id:n,children:e}){const[t,r]=Xa(n);return g.jsx(whe,{open:t,onOpenChange:r,children:e})}function rpe({id:n,label:e,title:t,disabled:r}){return g.jsx(bhe,{dir:"ltr",asChild:!0,disabled:r,children:g.jsxs(He,{"data-testid":n,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:t,children:[g.jsx(Cn,{children:e}),g.jsx(ct,{icon:"chevron-right",small:!0})]})})}function spe({id:n,alignOffset:e=-1,sideOffset:t=-6,size:r="small",children:s}){const i=kn();return g.jsx(Pv,{container:i,children:g.jsx(Che,{"data-testid":n,className:"tlui-menu tlui-menu__submenu__content",alignOffset:e,sideOffset:t,collisionPadding:4,"data-size":r,children:s})})}function ipe({children:n}){return g.jsx("div",{dir:"ltr",className:"tlui-menu__group",children:n})}function ope({noClose:n,children:e}){return g.jsx(vhe,{dir:"ltr",asChild:!0,onClick:n?tt:void 0,children:e})}function ot({id:n,label:e,children:t}){const{type:r,sourceId:s}=Av(),i=it(),o=Pp(e,r),a=o?i(o):void 0;switch(r){case"panel":return g.jsx("div",{className:"tlui-menu__group","data-testid":`${s}-group.${n}`,children:t});case"menu":return g.jsx(ipe,{"data-testid":`${s}-group.${n}`,children:t});case"context-menu":return g.jsx("div",{dir:"ltr",className:"tlui-menu__group","data-testid":`${s}-group.${n}`,children:t});case"keyboard-shortcuts":return g.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${s}-group.${n}`,children:[g.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),g.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:t})]});default:return t}}function As({id:n,disabled:e=!1,label:t,size:r="small",children:s}){const{type:i,sourceId:o}=Av(),a=kn(),l=it(),c=t?typeof t=="string"?t:t[i]??t.default:void 0,u=c?l(c):void 0;switch(i){case"menu":return g.jsxs(npe,{id:`${o}-sub.${n}`,children:[g.jsx(rpe,{id:`${o}-sub.${n}-button`,disabled:e,label:u,title:u}),g.jsx(spe,{id:`${o}-sub.${n}-content`,size:r,children:s})]});case"context-menu":return e?null:g.jsxs(ape,{id:`${o}-sub.${n}`,children:[g.jsx(E9,{dir:"ltr",disabled:e,asChild:!0,children:g.jsxs(He,{"data-testid":`${o}-sub.${n}-button`,type:"menu",className:"tlui-menu__submenu__trigger",children:[g.jsx(Cn,{children:u}),g.jsx(ct,{icon:"chevron-right",small:!0})]})}),g.jsx(j_,{container:a,children:g.jsx(_9,{"data-testid":`${o}-sub.${n}-content`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":r,children:s})})]});default:return s}}function ape({id:n,children:e}){const[t,r]=Xa(n);return g.jsx(I9,{open:t,onOpenChange:r,children:e})}const lpe=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function cpe(){const n=te(),e=Ln(),t=ie("colorScheme",()=>n.user.getUserPreferences().colorScheme??(n.user.getIsDarkMode()?"dark":"light"),[n]);return g.jsx(As,{id:"help menu color-scheme",label:"menu.theme",children:g.jsx(ot,{id:"theme",children:lpe.map(({colorScheme:r,label:s})=>g.jsx(Ov,{id:`color-scheme-${r}`,label:s,checked:r===t,readonlyOk:!0,onSelect:()=>{n.user.updateUserPreferences({colorScheme:r}),e("color-scheme",{source:"menu",value:r})}},r))})})}const upe=({id:n,component:e,onClose:t,preventBackgroundClose:r})=>{const{removeDialog:s}=cg(),i=P.useRef(!1),o=kn(),a=P.useCallback(l=>{if(!l){if(t)try{t()}catch(c){console.warn(c)}s(n)}},[n,t,s]);return g.jsx(Fhe,{onOpenChange:a,defaultOpen:!0,children:g.jsx(zhe,{container:o,children:g.jsx($he,{dir:"ltr",className:"tlui-dialog__overlay",onClick:l=>{i.current||!r&&l.target===l.currentTarget&&a(!1)},children:g.jsx(Bhe,{dir:"ltr",className:"tlui-dialog__content","aria-describedby":void 0,onMouseDown:()=>i.current=!0,onMouseUp:()=>i.current=!1,onInteractOutside:l=>{i.current=!1,r&&l.preventDefault()},children:g.jsx(e,{onClose:()=>{i.current=!1,a(!1)}})})})})})},dpe=P.memo(function(){const{dialogs:e}=cg();return ie("dialogs",()=>e.get(),[e]).map(r=>g.jsx(upe,{...r},r.id))}),hpe=4e3,fpe={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function ppe({toast:n}){const{removeToast:e}=Ya(),t=it(),r=o=>{o||e(n.id)},s=n.actions&&n.actions.length>0,i=n.icon||n.severity&&fpe[n.severity];return g.jsxs(xfe,{onOpenChange:r,className:"tlui-toast__container",duration:n.keepOpen?1/0:hpe,"data-severity":n.severity,children:[i&&g.jsx("div",{className:"tlui-toast__icon",children:g.jsx(Wo,{icon:i})}),g.jsxs("div",{className:"tlui-toast__main","data-title":!!n.title,"data-description":!!n.description,"data-actions":!!n.actions,children:[g.jsxs("div",{className:"tlui-toast__content",children:[n.title&&g.jsx(wfe,{className:"tlui-toast__title",children:n.title}),n.description&&g.jsx(bfe,{className:"tlui-toast__description",children:n.description})]}),n.actions&&g.jsxs("div",{className:"tlui-toast__actions",children:[n.actions.map((o,a)=>g.jsx(Cfe,{altText:o.label,asChild:!0,onClick:o.onClick,children:g.jsx(He,{type:o.type,children:g.jsx(Cn,{children:o.label})})},a)),g.jsx(OL,{asChild:!0,children:g.jsx(He,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:g.jsx(Cn,{children:n.closeLabel??t("toast.close")})})})]})]}),!s&&g.jsx(OL,{asChild:!0,children:g.jsx(He,{type:"normal",className:"tlui-toast__close",children:g.jsx(Cn,{children:n.closeLabel??t("toast.close")})})})]})}const gpe=P.memo(function(){const{toasts:e}=Ya(),t=ie("toasts",()=>e.get(),[]);return g.jsxs(g.Fragment,{children:[t.map(r=>g.jsx(ppe,{toast:r},r.id)),g.jsx(aU,{className:"tlui-toast__viewport"})]})});function uo({actionId:n="",...e}){const r=bu()[n];return r?g.jsx(Ov,{...r,...e}):null}function NL(n){return g.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...n,children:g.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[g.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),g.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:g.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}function yn({disabled:n=!1,spinner:e=!1,readonlyOk:t=!1,id:r,kbd:s,label:i,icon:o,onSelect:a,noClose:l,isSelected:c}){const{type:u,sourceId:h}=Av(),p=it(),[m,S]=P.useState(!1);if(ti()&&!t)return null;const v=Pp(i,u),w=s?Bk(s):void 0,C=v?p(v):void 0,_=C&&w?`${C} ${w}`:C;switch(u){case"menu":return g.jsx(ope,{children:g.jsxs(He,{type:"menu","data-testid":`${h}.${r}`,disabled:n,title:_,onClick:E=>{l&&tt(E),m?S(!1):a(h)},children:[g.jsx(Cn,{children:C}),s&&g.jsx(Kf,{children:s})]})});case"context-menu":return n?null:g.jsxs(C9,{dir:"ltr",title:_,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${h}.${r}`,onSelect:E=>{l&&tt(E),m?S(!1):a(h)},children:[g.jsx("span",{className:"tlui-button__label",draggable:!1,children:C}),s&&g.jsx(Kf,{children:s}),e&&g.jsx(NL,{})]});case"panel":return g.jsxs(He,{"data-testid":`${h}.${r}`,type:"menu",title:_,disabled:n,onClick:()=>a(h),children:[g.jsx(Cn,{children:C}),e?g.jsx(NL,{}):o&&g.jsx(ct,{icon:o})]});case"small-icons":case"icons":return g.jsx(He,{"data-testid":`${h}.${r}`,type:"icon",title:_,disabled:n,onClick:()=>a(h),children:g.jsx(ct,{icon:o,small:u==="small-icons"})});case"keyboard-shortcuts":return s?g.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${h}.${r}`,children:[g.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:C}),g.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:g.jsx(Kf,{visibleOnMobileLayout:!0,children:s})})]}):(console.warn(`Menu item '${i}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return g.jsxs(He,{type:"low",onClick:()=>a(h),children:[g.jsx(ct,{icon:o}),g.jsx(Cn,{children:C})]});case"toolbar":return g.jsx(He,{type:"tool","data-testid":`tools.${r}`,"aria-label":C,"data-value":r,onClick:()=>a("toolbar"),title:_,disabled:n,onTouchStart:E=>{tt(E),a("toolbar")},role:"radio","aria-checked":c?"true":"false",children:g.jsx(ct,{icon:o})});case"toolbar-overflow":return g.jsx(He,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"aria-label":C,"data-testid":`tools.more.${r}`,title:_,disabled:n,role:"radio","aria-checked":c?"true":"false","data-value":r,children:g.jsx(ct,{icon:o})});default:throw An(u)}}function le({actionId:n="",...e}){const r=bu()[n];return r?g.jsx(yn,{...r,...e}):null}const kU=P.createContext(null);function mpe({overrides:n,children:e}){const t=dr(),r=Ln(),s=hv(),i=it(),o=X_(),a=P.useCallback((c,u,h)=>{s.announce({msg:i(u.label)}),r("select-tool",{source:c,id:h??u.id})},[s,i,r]),l=P.useMemo(()=>{if(!t)return{};const c=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(h){if(t.isIn("select")){const p=t.root.getCurrent();p.exit({},p.id),p.enter({},p.id)}t.setCurrentTool("select"),a(h,this)}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(h){t.setCurrentTool("hand"),a(h,this)}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(h){t.setCurrentTool("eraser"),a(h,this)}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(h){t.setCurrentTool("draw"),a(h,this)}},...[...Xi.values].map(h=>({id:h,label:`tool.${h}`,meta:{geo:h},kbd:h==="rectangle"?"r":h==="ellipse"?"o":void 0,icon:"geo-"+h,onSelect(p){t.run(()=>{t.setStyleForNextShapes(Xi,h),t.setCurrentTool("geo"),a(p,this,`geo-${h}`)})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(h){t.setCurrentTool("arrow"),a(h,this)}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(h){t.setCurrentTool("line"),a(h,this)}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(h){t.setCurrentTool("frame"),a(h,this)}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(h){t.setCurrentTool("text"),a(h,this)}},{id:"asset",label:"tool.media",icon:"tool-media",kbd:"cmd+u,ctrl+u",onSelect(h){o.insertMedia(),a(h,this,"media")}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(h){t.setCurrentTool("note"),a(h,this)}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(h){t.setCurrentTool("laser"),a(h,this)}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(h){o.addDialog({component:nU}),a(h,this)}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"shift+d",onSelect(h){t.setCurrentTool("highlight"),a(h,this)}}];c.forEach(h=>h.onSelect=h.onSelect.bind(h));const u=Object.fromEntries(c.map(h=>[h.id,h]));return n?n(t,u,o):u},[n,t,o,a]);return g.jsx(kU.Provider,{value:l,children:e})}function eT(){const n=P.useContext(kU);if(!n)throw new Error("useTools must be used within a ToolProvider");return n}function vs({toolId:n="",...e}){const r=eT()[n];return r?g.jsx(yn,{...r,...e}):null}function ype({children:n}){const e=te();return ie("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])?g.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:n}):null}const{PI:Spe}=Math,Fd=Spe+1e-4;function IU(n,e={}){const{size:t=16,smoothing:r=.5}=e;if(n.length===0||t<=0)return{left:[],right:[]};const s=n[0],i=n[n.length-1],o=i.runningLength,a=Math.pow(t*r,2),l=[],c=[];let u=n[0].vector,h=n[0].point,p=h,m=h,S=p,x=!1,v;for(let w=0;w<n.length;w++){v=n[w];const{point:C,vector:_}=n[w],E=v.vector.dpr(u),T=(w<n.length-1?n[w+1]:n[w]).vector,A=w<n.length-1?T.dpr(v.vector):1,O=E<0&&!x,D=A!==null&&A<.2;if(O||D){if(A>-.62&&o-v.runningLength>v.radius){const H=u.clone().mul(v.radius);u.clone().cpr(T)<0?(m=k.Add(C,H),S=k.Sub(C,H)):(m=k.Sub(C,H),S=k.Add(C,H)),l.push(m),c.push(S)}else{const H=u.clone().mul(v.radius).per(),G=k.Sub(v.input,H);for(let J=1/13,L=0;L<1;L+=J)m=k.RotWith(G,v.input,Fd*L),l.push(m),S=k.RotWith(G,v.input,Fd+Fd*-L),c.push(S)}h=m,p=S,D&&(x=!0);continue}if(x=!1,v===s||v===i){const H=k.Per(_).mul(v.radius);l.push(k.Sub(C,H)),c.push(k.Add(C,H));continue}const $=k.Lrp(T,_,A).per().mul(v.radius);m=k.Sub(C,$),(w<=1||k.Dist2(h,m)>a)&&(l.push(m),h=m),S=k.Add(C,$),(w<=1||k.Dist2(p,S)>a)&&(c.push(S),p=S),u=_}return{left:l,right:c}}function tT(n,e={}){const{size:t=16,start:r={},end:s={},last:i=!1}=e,{cap:o=!0}=r,{cap:a=!0}=s;if(n.length===0||t<=0)return[];const l=n[0],c=n[n.length-1],u=c.runningLength,h=r.taper===!1?0:r.taper===!0?Math.max(t,u):r.taper,p=s.taper===!1?0:s.taper===!0?Math.max(t,u):s.taper,{left:m,right:S}=IU(n,e),x=l.point,v=n.length>1?n[n.length-1].point:k.AddXY(l.point,1,1);if(n.length===1&&(!(h||p)||i)){const E=k.Add(x,k.Sub(x,v).uni().per().mul(-l.radius)),T=[];for(let A=1/13,O=A;O<=1;O+=A)T.push(k.RotWith(E,x,Fd*2*O));return T}const w=[];if(!(h||p&&n.length===1))if(o)for(let E=1/8,T=E;T<=1;T+=E){const A=k.RotWith(S[0],x,Fd*T);w.push(A)}else{const E=k.Sub(m[0],S[0]),T=k.Mul(E,.5),A=k.Mul(E,.51);w.push(k.Sub(x,T),k.Sub(x,A),k.Add(x,A),k.Add(x,T))}const C=[],_=c.vector.clone().per().neg();if(p||h&&n.length===1)C.push(v);else if(a){const E=k.Add(v,k.Mul(_,c.radius));for(let T=1/29,A=T;A<1;A+=T)C.push(k.RotWith(E,v,Fd*3*A))}else C.push(k.Add(v,k.Mul(_,c.radius)),k.Add(v,k.Mul(_,c.radius*.99)),k.Sub(v,k.Mul(_,c.radius*.99)),k.Sub(v,k.Mul(_,c.radius)));return m.concat(C,S.reverse(),w)}const vpe=.025,xpe=.01;function Vo(n,e={}){var v;const{streamline:t=.5,size:r=16,simulatePressure:s=!1}=e;if(n.length===0)return[];const i=.15+(1-t)*.85;let o=n.map(k.From),a=0;if(!s){let w=o[0];for(;w&&!(w.z>=vpe);)o.shift(),w=o[0]}if(!s){let w=o[o.length-1];for(;w&&!(w.z>=xpe);)o.pop(),w=o[o.length-1]}if(o.length===0)return[{point:k.From(n[0]),input:k.From(n[0]),pressure:s?.5:.15,vector:new k(1,1),distance:0,runningLength:0,radius:1}];let l=o[1];for(;l&&!(k.Dist2(l,o[0])>(r/3)**2);)o[0].z=Math.max(o[0].z,l.z),o.splice(1,1),l=o[1];const c=o.pop();for(l=o[o.length-1];l&&!(k.Dist2(l,c)>(r/3)**2);)o.pop(),l=o[o.length-1],a++;o.push(c);const u=e.last||!e.simulatePressure||o.length>1&&k.Dist2(o[o.length-1],o[o.length-2])<r**2||a>0;if(o.length===2&&e.simulatePressure){const w=o[1];o=o.slice(0,-1);for(let C=1;C<5;C++){const _=k.Lrp(o[0],w,C/4);_.z=(o[0].z+(w.z-o[0].z))*C/4,o.push(_)}}const h=[{point:o[0],input:o[0],pressure:s?.5:o[0].z,vector:new k(1,1),distance:0,runningLength:0,radius:1}];let p=0,m=h[0],S,x;u&&t>0&&o.push(o[o.length-1].clone());for(let w=1,C=o.length;w<C;w++)S=!i||e.last&&w===C-1?o[w].clone():o[w].clone().lrp(m.point,1-i),!m.point.equals(S)&&(x=k.Dist(S,m.point),p+=x,!(w<4&&p<r)&&(m={input:o[w],point:S,pressure:s?.5:o[w].z,vector:k.Sub(m.point,S).uni(),distance:x,runningLength:p,radius:1},h.push(m)));if((v=h[1])!=null&&v.vector&&(h[0].vector=h[1].vector.clone()),p<1){const w=Math.max(.5,...h.map(C=>C.pressure));h.forEach(C=>C.pressure=w)}return h}const{min:xl}=Math,HC=.275;function Rv(n,e){const{size:t=16,thinning:r=.5,simulatePressure:s=!0,easing:i=v=>v,start:o={},end:a={}}=e,{easing:l=Hn.easeOutQuad}=o,{easing:c=Hn.easeOutCubic}=a,u=n[n.length-1].runningLength;let h,p=n[0].pressure,m;if(!s&&u<t){const v=n.reduce((w,C)=>Math.max(w,C.pressure),.5);return n.forEach(w=>{w.pressure=v,w.radius=t*i(.5-r*(.5-w.pressure))}),n}else{let v;for(let w=0,C=n.length;w<C&&(m=n[w],!(m.runningLength>t*5));w++){const _=xl(1,m.distance/t);if(s){const E=xl(1,1-_);v=xl(1,p+(E-p)*(_*HC))}else v=xl(1,p+(m.pressure-p)*.5);p=p+(v-p)*.5}for(let w=0;w<n.length;w++){if(m=n[w],r){let{pressure:C}=m;const _=xl(1,m.distance/t);if(s){const E=xl(1,1-_);C=xl(1,p+(E-p)*(_*HC))}else C=xl(1,p+(C-p)*(_*HC));m.radius=t*i(.5-r*(.5-C)),p=C}else m.radius=t/2;h===void 0&&(h=m.radius)}}const S=o.taper===!1?0:o.taper===!0?Math.max(t,u):o.taper,x=a.taper===!1?0:a.taper===!0?Math.max(t,u):a.taper;if(S||x)for(let v=0;v<n.length;v++){m=n[v];const{runningLength:w}=m,C=w<S?l(w/S):1,_=u-w<x?c((u-w)/x):1;m.radius=Math.max(.01,m.radius*Math.min(C,_))}return n}function wpe(n,e={}){return tT(Rv(Vo(n,e),e),e)}function FL({scribble:n,zoom:e,color:t,opacity:r,className:s}){if(!n.points.length)return null;const i=wpe(n.points,{size:n.size/e,start:{taper:n.taper,easing:Hn.linear},last:n.state==="stopping",simulatePressure:!1,streamline:.32});let o;if(i.length<4){const a=n.size/e/2,{x:l,y:c}=n.points[n.points.length-1];o=`M ${l-a},${c} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else o=XE(i);return g.jsx("svg",{className:s&&$e("tl-overlays__item",s),children:g.jsx("path",{className:"tl-scribble",d:o,fill:t??`var(--color-${n.color})`,opacity:r??n.opacity})})}const bpe=({bounds:n,rotation:e})=>{const t=te();return ie("should display",()=>t.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[t])?g.jsx(fz,{bounds:n,rotation:e}):null};function Cpe({size:n,width:e,height:t,hideAlternateHandles:r}){const s=re(n/3),i=s/2;return g.jsxs("svg",{className:"tl-overlays__item",children:[g.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
434
|
-
${re(0-i)},${re(n)}
|
|
435
|
-
${re(0-i)},${re(0-i)}
|
|
436
|
-
${re(n)},${re(0-i)}`,strokeWidth:s,"data-testid":"selection.crop.top_left",role:"button","aria-label":"top_left handle"}),g.jsx("line",{className:$e("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:re(e/2-n),y1:re(0-i),x2:re(e/2+n),y2:re(0-i),strokeWidth:s,"data-testid":"selection.crop.top",role:"button","aria-label":"top handle"}),g.jsx("polyline",{className:$e("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
437
|
-
${re(e-n)},${re(0-i)}
|
|
438
|
-
${re(e+i)},${re(0-i)}
|
|
439
|
-
${re(e+i)},${re(n)}`,strokeWidth:s,"data-testid":"selection.crop.top_right",role:"button","aria-label":"top_right handle"}),g.jsx("line",{className:$e("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:re(e+i),y1:re(t/2-n),x2:re(e+i),y2:re(t/2+n),strokeWidth:s,"data-testid":"selection.crop.right",role:"button","aria-label":"right handle"}),g.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
440
|
-
${re(e+i)},${re(t-n)}
|
|
441
|
-
${re(e+i)},${re(t+i)}
|
|
442
|
-
${re(e-n)},${re(t+i)}`,strokeWidth:s,"data-testid":"selection.crop.bottom_right",role:"button","aria-label":"bottom_right handle"}),g.jsx("line",{className:$e("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:re(e/2-n),y1:re(t+i),x2:re(e/2+n),y2:re(t+i),strokeWidth:s,"data-testid":"selection.crop.bottom",role:"button","aria-label":"bottom handle"}),g.jsx("polyline",{className:$e("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
443
|
-
${re(0+n)},${re(t+i)}
|
|
444
|
-
${re(0-i)},${re(t+i)}
|
|
445
|
-
${re(0-i)},${re(t-n)}`,strokeWidth:s,"data-testid":"selection.crop.bottom_left",role:"button","aria-label":"bottom_left handle"}),g.jsx("line",{className:$e("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:re(0-i),y1:re(t/2-n),x2:re(0-i),y2:re(t/2+n),strokeWidth:s,"data-testid":"selection.crop.left",role:"button","aria-label":"left handle"})]})}const Ppe=Yn(function({bounds:e,rotation:t}){const r=te(),s=P.useRef(null),i=ti(),o=Eo("top"),a=Eo("right"),l=Eo("bottom"),c=Eo("left"),u=Eo("top_left"),h=Eo("top_right"),p=Eo("bottom_right"),m=Eo("bottom_left"),S=r.getInstanceState().cursor.type==="default",x=r.getInstanceState().isCoarsePointer,v=r.getOnlySelectedShape(),w=v&&r.isShapeOrAncestorLocked(v),C=v?r.getShapeUtil(v).expandSelectionOutlinePx(v):0,_=C instanceof Se?e.clone().expand(C).zeroFix():e.clone().expandBy(C).zeroFix();if(uh(s,e==null?void 0:e.x,e==null?void 0:e.y,1,r.getSelectionRotation(),{x:_.x-e.x,y:_.y-e.y}),v&&r.isShapeHidden(v))return null;const E=r.getZoomLevel(),T=r.getInstanceState().isChangingStyle,A=_.width,O=_.height,D=8/E,$=A<D*2,H=O<D*2,G=A<D*4,J=O<D*4,L=A<D*5,N=O<D*5,U=x?1.75:1,Y=6/E*U,W=(G?Y/2:Y)*(U*.75),z=(J?Y/2:Y)*(U*.75),V=(v?!r.getShapeUtil(v).hideSelectionBoundsFg(v):!0)&&!T;let ee=V&&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")||V&&r.isIn("select.resizing")&&v&&r.isShapeOfType(v,"text");v&&ee&&It.isFirefox&&r.isShapeOfType(v,"embed")&&(ee=!1);const B=r.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!T&&!i,Q=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!T&&!i,me=!x&&!($||H)&&(Q||B)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!w,Pe=x&&(!G||!J)&&(Q||B)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!w,ue=Q&&(v?r.getShapeUtil(v).canResize(v)&&!r.getShapeUtil(v).hideResizeHandles(v):!0)&&!B&&!w,Oe=$||H,Ne=$&&H,be=L||N,Ee=ue||B,Ke=!me,Lt=!Q||!Pe,Jt=!Q||!Ee,Et=!Q||!Ee||Oe,Tt=!Q||!Ee||Oe,nn=!Q||!Ee||Ne&&!B;let In=!0,rs=!0;if(B)In=be,rs=be;else if(ue){In=Oe||Ne||x;const as=x&&v&&v.type==="text";rs=In&&!as}const ss=Math.min(24/E,O-z*3),is=Q&&x&&v&&r.isShapeOfType(v,"text")&&ss*E>=4;return g.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:g.jsxs("g",{ref:s,children:[ee&&g.jsx("rect",{className:"tl-selection__fg__outline",width:re(A),height:re(O)}),g.jsx(Gm,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:Y,corner:"top_left_rotate",cursor:S?$s("nwse-rotate",t):void 0,isHidden:Ke}),g.jsx(Gm,{"data-testid":"selection.rotate.top-right",cx:A+Y*3,cy:0,targetSize:Y,corner:"top_right_rotate",cursor:S?$s("nesw-rotate",t):void 0,isHidden:Ke}),g.jsx(Gm,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:O+Y*3,targetSize:Y,corner:"bottom_left_rotate",cursor:S?$s("swne-rotate",t):void 0,isHidden:Ke}),g.jsx(Gm,{"data-testid":"selection.rotate.bottom-right",cx:A+Y*3,cy:O+Y*3,targetSize:Y,corner:"bottom_right_rotate",cursor:S?$s("senw-rotate",t):void 0,isHidden:Ke}),g.jsx(Ipe,{"data-testid":"selection.rotate.mobile",cx:G?-Y*1.5:A/2,cy:G?O/2:-Y*1.5,size:D,isHidden:Lt}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":In}),"data-testid":"selection.resize.top",role:"button","aria-label":"top target",pointerEvents:"all",x:0,y:re(0-(J?z*2:z)),width:re(A),height:re(Math.max(1,z*2)),style:S?{cursor:$s("ns-resize",t)}:void 0,...o}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":rs}),"data-testid":"selection.resize.right",role:"button","aria-label":"right target",pointerEvents:"all",x:re(A-(G?0:W)),y:0,height:re(O),width:re(Math.max(1,W*2)),style:S?{cursor:$s("ew-resize",t)}:void 0,...a}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":In}),"data-testid":"selection.resize.bottom",role:"button","aria-label":"bottom target",pointerEvents:"all",x:0,y:re(O-(J?0:z)),width:re(A),height:re(Math.max(1,z*2)),style:S?{cursor:$s("ns-resize",t)}:void 0,...l}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":rs}),"data-testid":"selection.resize.left",role:"button","aria-label":"left target",pointerEvents:"all",x:re(0-(G?W*2:W)),y:0,height:re(O),width:re(Math.max(1,W*2)),style:S?{cursor:$s("ew-resize",t)}:void 0,...c}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":Jt}),"data-testid":"selection.target.top-left",role:"button","aria-label":"top-left target",pointerEvents:"all",x:re(0-(G?W*2:W*1.5)),y:re(0-(J?z*2:z*1.5)),width:re(W*3),height:re(z*3),style:S?{cursor:$s("nwse-resize",t)}:void 0,...u}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":Et}),"data-testid":"selection.target.top-right",role:"button","aria-label":"top-right target",pointerEvents:"all",x:re(A-(G?0:W*1.5)),y:re(0-(J?z*2:z*1.5)),width:re(W*3),height:re(z*3),style:S?{cursor:$s("nesw-resize",t)}:void 0,...h}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":nn}),"data-testid":"selection.target.bottom-right",role:"button","aria-label":"bottom-right target",pointerEvents:"all",x:re(A-(G?W:W*1.5)),y:re(O-(J?z:z*1.5)),width:re(W*3),height:re(z*3),style:S?{cursor:$s("nwse-resize",t)}:void 0,...p}),g.jsx("rect",{className:$e("tl-transparent",{"tl-hidden":Tt}),"data-testid":"selection.target.bottom-left",role:"button","aria-label":"bottom-left target",pointerEvents:"all",x:re(0-(G?W*3:W*1.5)),y:re(O-(J?0:z*1.5)),width:re(W*3),height:re(z*3),style:S?{cursor:$s("nesw-resize",t)}:void 0,...m}),ue&&g.jsxs(g.Fragment,{children:[g.jsx("rect",{"data-testid":"selection.resize.top-left",className:$e("tl-corner-handle",{"tl-hidden":Jt}),role:"button","aria-label":"top_left handle",x:re(0-D/2),y:re(0-D/2),width:re(D),height:re(D)}),g.jsx("rect",{"data-testid":"selection.resize.top-right",className:$e("tl-corner-handle",{"tl-hidden":Et}),role:"button","aria-label":"top_right handle",x:re(A-D/2),y:re(0-D/2),width:re(D),height:re(D)}),g.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:$e("tl-corner-handle",{"tl-hidden":nn}),role:"button","aria-label":"bottom_right handle",x:re(A-D/2),y:re(O-D/2),width:re(D),height:re(D)}),g.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:$e("tl-corner-handle",{"tl-hidden":Tt}),role:"button","aria-label":"bottom_left handle",x:re(0-D/2),y:re(O-D/2),width:re(D),height:re(D)})]}),is&&g.jsxs(g.Fragment,{children:[g.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle",role:"button","aria-label":"bottom_left handle",x:re(0-D/4),y:re(O/2-ss/2),rx:D/4,width:re(D/2),height:re(ss)}),g.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle",role:"button","aria-label":"bottom_left handle",rx:D/4,x:re(A-D/4),y:re(O/2-ss/2),width:re(D/2),height:re(ss)})]}),B&&g.jsx(Cpe,{size:D,width:A,height:O,hideAlternateHandles:be})]})})}),Gm=function({cx:e,cy:t,targetSize:r,corner:s,cursor:i,isHidden:o,"data-testid":a}){const l=Eo(s);return g.jsx("rect",{className:$e("tl-transparent","tl-rotate-corner",{"tl-hidden":o}),"data-testid":a,role:"button","aria-label":`${s} target`,pointerEvents:"all",x:re(e-r*3),y:re(t-r*3),width:re(Math.max(1,r*3)),height:re(Math.max(1,r*3)),cursor:i,...l})},kpe=Math.sqrt(Math.PI),Ipe=function({cx:e,cy:t,size:r,isHidden:s,"data-testid":i}){const o=Eo("mobile_rotate"),a=te(),l=ie("zoom level",()=>a.getZoomLevel(),[a]),c=Math.max(14*(1/l),20/Math.max(1,l));return g.jsxs("g",{children:[g.jsx("circle",{"data-testid":i,pointerEvents:"all",className:$e("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":s}),cx:e,cy:t,r:c,...o}),g.jsx("circle",{className:$e("tl-mobile-rotate__fg",{"tl-hidden":s}),cx:e,cy:t,r:r/kpe})]})};function Epe(){const n=te(),e=ie("is in a valid select state",()=>n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle"),[n]);return g.jsx(pz,{hideAll:!e})}function Uk(n,e,t){const{arrowheadStart:r,arrowheadEnd:s}=e.props,i=Ed(n,e,t),o=i.start.clone(),a=i.end.clone(),l=k.Med(o,a);if(k.Equals(o,a))return{bindings:t,isStraight:!0,start:{handle:o,point:o,arrowhead:e.props.arrowheadStart},end:{handle:a,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:!1,length:0};const c=k.Sub(a,o).uni(),u=NS(n,e,"start"),h=NS(n,e,"end"),p=n.getShapePageTransform(e);zL(a,i.start,p,h),zL(o,i.end,p,u);let m=0,S=0,x=0,v=0,w=Wf*e.props.scale;const C=u&&h&&u.shape===h.shape,_=u&&h?nT(n,u.shape.id,h.shape.id):"safe";_==="safe"&&u&&h&&!C&&!u.isExact&&!h.isExact&&(h.didIntersect&&!u.didIntersect?u.isClosed&&o.setTo(a.clone().add(c.clone().mul(Wf*e.props.scale))):h.didIntersect||h.isClosed&&a.setTo(o.clone().sub(c.clone().mul(Wf*e.props.scale))));const E=k.Sub(a,o),T=k.Len(E)?E.uni():k.From(E),A=!k.Equals(T,c);C||(_!=="start-contains-end"&&u&&r!=="none"&&!u.isExact&&(x=No[e.props.size]/2+("size"in u.shape.props?No[u.shape.props.size]/2:0),m=(FS+x)*e.props.scale,w+=x*e.props.scale),_!=="end-contains-start"&&h&&s!=="none"&&!h.isExact&&(v=No[e.props.size]/2+("size"in h.shape.props?No[h.shape.props.size]/2:0),S=(FS+v)*e.props.scale,w+=v*e.props.scale));const O=o.clone().add(T.clone().mul(m*(A?-1:1))),D=a.clone().sub(T.clone().mul(S*(A?-1:1)));k.DistMin(O,D,w)&&(m!==0&&S!==0?(m*=-1.5,S*=-1.5):m!==0?m*=-1:S!==0&&(S*=-1)),o.add(T.clone().mul(m*(A?-1:1))),a.sub(T.clone().mul(S*(A?-1:1))),A?(u&&h&&a.setTo(k.Add(o,T.clone().mul(-10*e.props.scale))),l.setTo(k.Med(i.start,i.end))):l.setTo(k.Med(o,a));const $=k.Dist(o,a);return{bindings:t,isStraight:!0,start:{handle:i.start,point:o,arrowhead:e.props.arrowheadStart},end:{handle:i.end,point:a,arrowhead:e.props.arrowheadEnd},middle:l,isValid:$>0,length:$}}function zL(n,e,t,r){if(r===void 0||r.isExact)return;const s=he.applyToPoint(t,e),i=he.applyToPoint(t,n),o=he.applyToPoint(he.Inverse(r.transform),s),a=he.applyToPoint(he.Inverse(r.transform),i),l=Array.from(r.geometry.intersectLineSegment(o,a,{includeLabels:!1,includeInternal:!1}));let c;if(l.length&&(c=l.sort((p,m)=>k.Dist2(p,o)-k.Dist2(m,o))[0]??(r.isClosed?void 0:a)),c===void 0)return;const u=he.applyToPoint(r.transform,c),h=he.applyToPoint(he.Inverse(t),u);n.setTo(h),r.didIntersect=!0}function _pe(n,e,t){const{arrowheadEnd:r,arrowheadStart:s}=e.props,i=e.props.bend;if(Math.abs(i)>Math.abs(e.props.bend*(Rpe*e.props.scale)))return Uk(n,e,t);const o=Ed(n,e,t),a=k.Med(o.start,o.end),l=k.Sub(o.end,o.start),c=k.Len(l)?l.uni():k.From(l),u=k.Add(a,c.per().mul(-i)),h=NS(n,e,"start"),p=NS(n,e,"end"),m=o.start.clone(),S=o.end.clone(),x=u.clone();if(k.Equals(m,S))return{bindings:t,isStraight:!0,start:{handle:m,point:m,arrowhead:e.props.arrowheadStart},end:{handle:S,point:S,arrowhead:e.props.arrowheadEnd},middle:x,isValid:!1,length:0};const v=e.props.bend<0,w=v?Fp:iF,C=$L(m,S,x),_=k.Angle(C.center,m),E=k.Angle(C.center,S),T=w(_,E);if(C.length===0||C.size===0||!NR(C.length)||!NR(C.size))return Uk(n,e,t);const A=m.clone(),O=S.clone(),D=x.clone(),$=n.getShapePageTransform(e);let H=0,G=0,J=Wf*e.props.scale;if(h&&!h.isExact){const ee=he.applyToPoint($,A),B=he.applyToPoint($,C.center),Q=he.applyToPoint($,O),me=he.Inverse(h.transform),Pe=he.applyToPoint(me,ee),ue=he.applyToPoint(me,B),Oe=he.applyToPoint(me,Q),{isClosed:Ne}=h;let be,Ee=Array.from(h.geometry.intersectCircle(ue,C.radius,{includeLabels:!1,includeInternal:!1}));if(Ee.length){const Ke=ue.angle(Pe),Lt=ue.angle(Oe),Jt=w(Ke,Lt);Ee=Ee.filter(Tt=>w(Ke,ue.angle(Tt))<=Jt);const Et=Jt*.25;Ee.sort(Ne?(Tt,nn)=>Math.abs(w(Ke,ue.angle(Tt))-Et)<Math.abs(w(Ke,ue.angle(nn))-Et)?-1:1:(Tt,nn)=>w(Ke,ue.angle(Tt))<w(Ke,ue.angle(nn))?-1:1),be=Ee[0]??(Ne?void 0:Pe)}else be=Ne?void 0:Pe;if(be&&(A.setTo(n.getPointInShapeSpace(e,he.applyToPoint(h.transform,be))),h.didIntersect=!0,s!=="none")){const Ke=No[e.props.size]/2+("size"in h.shape.props?No[h.shape.props.size]/2:0);H=(FS+Ke)*e.props.scale,J+=Ke*e.props.scale}}if(p&&!p.isExact){const ee=he.applyToPoint($,A),B=he.applyToPoint($,O),Q=he.applyToPoint($,C.center),me=he.Inverse(p.transform),Pe=he.applyToPoint(me,ee),ue=he.applyToPoint(me,Q),Oe=he.applyToPoint(me,B),Ne=p.isClosed;let be,Ee=Array.from(p.geometry.intersectCircle(ue,C.radius,{includeLabels:!1,includeInternal:!1}));if(Ee){const Ke=ue.angle(Pe),Lt=ue.angle(Oe),Jt=w(Ke,Lt),Et=Jt*.75;Ee=Ee.filter(Tt=>w(Ke,ue.angle(Tt))<=Jt),Ee.sort(Ne?(Tt,nn)=>Math.abs(w(Ke,ue.angle(Tt))-Et)<Math.abs(w(Ke,ue.angle(nn))-Et)?-1:1:(Tt,nn)=>w(Ke,ue.angle(Tt))<w(Ke,ue.angle(nn))?-1:1),Ee[0]?be=Ee[0]:be=Ne?void 0:Oe}else be=Ne?void 0:Oe;if(be&&(O.setTo(n.getPointInShapeSpace(e,he.applyToPoint(p.transform,be))),p.didIntersect=!0,r!=="none")){const Ke=No[e.props.size]/2+("size"in p.shape.props?No[p.shape.props.size]/2:0);G=(FS+Ke)*e.props.scale,J+=Ke*e.props.scale}}let L=k.Angle(C.center,A),N=k.Angle(C.center,O),U=w(L,N),Y=U*C.radius;const W=A.clone(),z=O.clone();if(H!==0&&W.setTo(C.center).add(k.FromAngle(L+U*(H/Y*(v?1:-1))).mul(C.radius)),G!==0&&z.setTo(C.center).add(k.FromAngle(N+U*(G/Y*(v?-1:1))).mul(C.radius)),k.DistMin(W,z,J)&&(H!==0&&G!==0?(H*=-1.5,G*=-1.5):H!==0?H*=-2:G!==0&&(G*=-2)),H!==0&&A.setTo(C.center).add(k.FromAngle(L+U*(H/Y*(v?1:-1))).mul(C.radius)),G!==0&&O.setTo(C.center).add(k.FromAngle(N+U*(G/Y*(v?-1:1))).mul(C.radius)),h&&p&&!h.isExact&&!p.isExact){L=k.Angle(C.center,A),N=k.Angle(C.center,O),U=w(L,N),Y=U*C.radius;const ee=nT(n,h.shape.id,p.shape.id);ee==="double-bound"&&Y<30?(A.setTo(m),O.setTo(S),D.setTo(x)):ee==="safe"&&(h&&!h.didIntersect&&A.setTo(m),(p&&!p.didIntersect||w(_,L)>w(_,N))&&O.setTo(C.center).add(k.FromAngle(L+U*(Math.min(.9,Wf*e.props.scale/Y)*(v?1:-1))).mul(C.radius)))}Tpe(C.center,C.radius,A,O,D,T,v),A.equals(O)&&(A.setTo(D.clone().addXY(1,1)),O.setTo(D.clone().subXY(1,1))),m.setTo(A),S.setTo(O),x.setTo(D);const V=$L(m,S,x);return{bindings:t,isStraight:!1,start:{point:m,handle:o.start,arrowhead:e.props.arrowheadStart},end:{point:S,handle:o.end,arrowhead:e.props.arrowheadEnd},middle:x,handleArc:C,bodyArc:V,isValid:V.length!==0&&isFinite(V.center.x)&&isFinite(V.center.y)}}function $L(n,e,t){const r=KI(n,e,t)??k.Med(n,e),s=k.Dist(r,n),i=+k.Clockwise(n,t,e),o=((n.y-e.y)**2+(n.x-e.x)**2)**.5,a=((e.y-t.y)**2+(e.x-t.x)**2)**.5,l=((t.y-n.y)**2+(t.x-n.x)**2)**.5,c=Math.acos((a*a+l*l-o*o)/(2*a*l))*2,u=+(wt>c),h=(Rt-c)*(i?1:-1),p=h*s;return{center:r,radius:s,size:h,length:p,largeArcFlag:u,sweepFlag:i}}function Tpe(n,e,t,r,s,i,o){const a=k.Angle(n,t),l=k.Angle(n,r);let c=Fp(a,l);if(o||(c=Rt-c),s.setTo(n).add(k.FromAngle(a+c*(.5*(o?1:-1))).mul(e)),c>i){s.rotWith(n,wt);const u=r.clone();r.setTo(t),t.setTo(u)}}const Mpe=8;function Ape(n){return Math.abs(n.props.bend)<Mpe*n.props.scale}function NS(n,e,t){const r=n.getBindingsFromShape(e,"arrow").find(a=>a.props.terminal===t);if(!r)return;const s=n.getShape(r.toId);if(!s)return;const i=n.getShapePageTransform(s),o=n.getShapeGeometry(s,t==="start"?{context:"@tldraw/arrow-start"}:void 0);return{shape:s,transform:i,isClosed:o.isClosed,isExact:r.props.isExact,didIntersect:!1,geometry:o}}function BL(n,e,t,r){const s=n.getShape(t.toId);if(s){const{point:i,size:o}=n.getShapeGeometry(s).bounds,a=k.Add(i,k.MulV(t.props.isPrecise||r?t.props.normalizedAnchor:{x:.5,y:.5},o)),l=he.applyToPoint(n.getShapePageTransform(s),a);return he.applyToPoint(he.Inverse(e),l)}else return new k(0,0)}function Hr(n,e){const t=n.getBindingsFromShape(e,"arrow");return{start:t.find(r=>r.props.terminal==="start"),end:t.find(r=>r.props.terminal==="end")}}const Ope=_E("arrow info",(n,e)=>{const t=Hr(n,e);return Ape(e)?Uk(n,e,t):_pe(n,e,t)});function Lo(n,e){const t=typeof e=="string"?e:e.id;return Ope.get(n,t)}function Ed(n,e,t){var a,l;const r=n.getShapePageTransform(e),s=nT(n,(a=t.start)==null?void 0:a.toId,(l=t.end)==null?void 0:l.toId),i=t.start?BL(n,r,t.start,s==="double-bound"||s==="start-contains-end"):k.From(e.props.start),o=t.end?BL(n,r,t.end,s==="double-bound"||s==="end-contains-start"):k.From(e.props.end);return{start:i,end:o}}function hf(n,e,t,r){const s=typeof e=="string"?e:e.id,i=typeof t=="string"?t:t.id,o=n.getBindingsFromShape(s,"arrow").filter(l=>l.props.terminal===r.terminal);o.length>1&&n.deleteBindings(o.slice(1));const a=o[0];a?n.updateBinding({...a,toId:i,props:r}):n.createBinding({type:"arrow",fromId:s,toId:i,props:r})}function Cy(n,e,t){const r=n.getBindingsFromShape(e,"arrow").filter(s=>s.props.terminal===t);n.deleteBindings(r)}const Wf=10,FS=10,Rpe=10,No={s:2,m:3.5,l:5,xl:10};function nT(n,e,t){if(!e||!t)return"safe";if(e===t)return"double-bound";const r=n.getShapePageBounds(e),s=n.getShapePageBounds(t);if(r&&s){if(r.contains(s))return"start-contains-end";if(s.contains(r))return"end-contains-start"}return"safe"}class Py extends vy{getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5}}}onAfterCreate({binding:e}){const t=this.editor.getShape(e.fromId);t&&KC(this.editor,t)}onAfterChange({bindingAfter:e}){const t=this.editor.getShape(e.fromId);t&&KC(this.editor,t)}onAfterChangeFromShape({shapeAfter:e}){KC(this.editor,e)}onAfterChangeToShape({binding:e}){EU(this.editor,e.fromId)}onBeforeIsolateFromShape({binding:e}){const t=this.editor.getShape(e.fromId);t&&zS({editor:this.editor,arrow:t,terminal:e.props.terminal})}}R(Py,"type","arrow"),R(Py,"props",g4),R(Py,"migrations",m4);function EU(n,e){var v;const t=n.getShape(e);if(!t)return;const r=Hr(n,t),{start:s,end:i}=r,o=s?n.getShape(s.toId):void 0,a=i?n.getShape(i.toId):void 0,l=n.getAncestorPageId(t);if(!l)return;let c;if(o&&a)c=n.findCommonAncestor([o,a])??l;else if(o||a){const w=(v=o||a)==null?void 0:v.parentId;w&&w===t.parentId?c=t.parentId:c=l}else return;c&&c!==t.parentId&&n.reparentShapes([e],c);const u=n.getShape(e);if(!u)throw Error("no reparented arrow");const h=n.getShapeNearestSibling(u,o),p=n.getShapeNearestSibling(u,a);let m;if(h&&p)m=h.index>p.index?h:p;else if(h&&!p)m=h;else if(p&&!h)m=p;else return;let S;const x=n.getSortedChildIdsForParent(m.parentId).map(w=>n.getShape(w)).filter(w=>w.index>m.index);if(x.length){const w=x.find(C=>C.type!=="arrow");if(u.index>m.index&&(!w||u.index<w.index))return;S=sp(m.index,x[0].index)}else S=Ro(m.index);S!==u.index&&n.updateShapes([{id:e,type:"arrow",index:S}])}function KC(n,e){const t=Hr(n,e);for(const r of["start","end"]){const s=t[r];if(!s)continue;const i=n.getShape(s.toId),o=n.getAncestorPageId(e)===n.getAncestorPageId(i);(!i||!o)&&zS({editor:n,arrow:e,terminal:r,unbind:!0})}EU(n,e.id)}function zS({editor:n,arrow:e,terminal:t,unbind:r=!1,useHandle:s=!1}){const i=Lo(n,e);if(!i)throw new Error("expected arrow info");const o=s?i.start.handle:i.start.point,a=s?i.end.handle:i.end.point,l=t==="start"?o:a,c={id:e.id,type:"arrow",props:{[t]:{x:l.x,y:l.y},bend:e.props.bend}};if(!i.isStraight){const u=t==="start"?o:i.start.handle,h=t==="end"?a:i.end.handle,p=k.Med(u,h),m=k.Sub(u,h).per().uni().mul(i.handleArc.radius*2*Math.sign(e.props.bend)),S=Gp(i.handleArc.center,k.Add(p,m),i.handleArc.center,i.handleArc.radius);Je((S==null?void 0:S.length)===1);const x=k.Dist(p,S[0])*Math.sign(e.props.bend);_a(x,c.props.bend)||(c.props.bend=x)}n.updateShape(c),r&&Cy(n,e,t)}const _U=[Py],ar={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Er={s:2,m:3.5,l:5,xl:10},Zd={s:18,m:24,l:36,xl:44},ja={s:18,m:22,l:26,xl:32},Dpe={s:18,m:20,l:24,xl:28},Ba={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},jpe=20,rT=4.25,Ur=16;function Lpe(n,e){const t=n.w/e.w,r=n.h/e.h;return t<=1&&r<=1?n:t>r?{w:n.w/t,h:n.h/t}:{w:n.w/r,h:n.h/r}}async function Npe(n,e,t){var w,C,_;const{elements:r,files:s}=e,i={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:n.store.schema.serialize()},o=new Map,a=new Map,l=n.getCurrentPageId(),c=new Map,u=[],h=new Set;r.forEach(E=>{if(c.set(E.id,Dt()),E.boundElements!==null)for(const T of E.boundElements)T.type==="text"&&h.add(T.id)});let p=f3;for(const E of r){if(h.has(E.id))continue;const T=c.get(E.id),A={id:T,typeName:"shape",parentId:l,index:p,x:E.x,y:E.y,rotation:0,isLocked:E.locked,opacity:Fpe(E.opacity),meta:{}};switch(E.angle!==0&&a.set(T,E.angle),E.groupIds&&E.groupIds.length>0?o.has(E.groupIds[0])?(w=o.get(E.groupIds[0]))==null||w.push(T):o.set(E.groupIds[0],[T]):u.push(T),E.type){case"rectangle":case"ellipse":case"diamond":{let O="",D="middle";if(E.boundElements!==null){for(const H of E.boundElements)if(H.type==="text"){const G=r.find(J=>J.id===H.id);G&&(O=G.text,D=Wpe[G.textAlign])}}const $=E.backgroundColor==="transparent"?E.strokeColor:E.backgroundColor;i.shapes.push({...A,type:"geo",props:{geo:E.type,url:E.link??"",w:E.width,h:E.height,size:Ym[E.strokeWidth]??"draw",color:ff[$]??"black",richText:Ei(O),align:D,dash:Xm(E),fill:Gpe(E)}});break}case"freedraw":{i.shapes.push({...A,type:"draw",props:{dash:Xm(E),size:Ym[E.strokeWidth],color:ff[E.strokeColor]??"black",segments:[{type:"free",points:E.points.map(([O,D,$=.5])=>({x:O,y:D,z:$}))}]}});break}case"line":{if(E.points.slice().length<2)break;const D=ip(E.points.length);i.shapes.push({...A,type:"line",props:{dash:Xm(E),size:Ym[E.strokeWidth],color:ff[E.strokeColor]??"black",spline:E.roundness?"cubic":"line",points:{...Object.fromEntries(E.points.map(([$,H],G)=>{const J=D[G];return[J,{id:J,index:J,x:$,y:H}]}))}}});break}case"arrow":{let O="";if(E.boundElements!==null){for(const J of E.boundElements)if(J.type==="text"){const L=r.find(N=>N.id===J.id);L&&(O=L.text)}}const D=E.points[0],$=E.points[E.points.length-1],H=c.get((C=E.startBinding)==null?void 0:C.elementId),G=c.get((_=E.endBinding)==null?void 0:_.elementId);i.shapes.push({...A,type:"arrow",props:{text:O,bend:qpe(E,D,$),dash:Xm(E),size:Ym[E.strokeWidth]??"m",color:ff[E.strokeColor]??"black",start:{x:D[0],y:D[1]},end:{x:$[0],y:$[1]},arrowheadEnd:UL[E.endArrowhead]??"none",arrowheadStart:UL[E.startArrowhead]??"none"}}),H&&i.bindings.push({id:Gc(),typeName:"binding",type:"arrow",fromId:T,toId:H,props:{terminal:"start",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),G&&i.bindings.push({id:Gc(),typeName:"binding",type:"arrow",fromId:T,toId:G,props:{terminal:"end",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{const{size:O,scale:D}=$pe(E.fontSize);i.shapes.push({...A,type:"text",props:{size:O,scale:D,font:Bpe[E.fontFamily]??"draw",color:ff[E.strokeColor]??"black",richText:Ei(E.text),textAlign:Vpe[E.textAlign]}});break}case"image":{const O=s[E.fileId];if(!O)break;const D=ql.createId();i.assets.push({id:D,typeName:"asset",type:"image",props:{w:E.width,h:E.height,fileSize:O.size,name:E.id??"Untitled",isAnimated:!1,mimeType:O.mimeType,src:O.dataURL},meta:{}}),i.shapes.push({...A,type:"image",props:{w:E.width,h:E.height,assetId:D}})}}p=Ro(p)}const m=t??(n.inputs.shiftKey?n.inputs.currentPagePoint:void 0);n.putContentOntoCurrentPage(i,{point:m,select:!1,preserveIds:!0});for(const E of o.values())if(E.length>1){n.groupShapes(E);const T=n.getShape(E[0]);T!=null&&T.parentId&&ws(T.parentId)&&u.push(T.parentId)}for(const[E,T]of a)n.select(E),n.rotateShapesBy([E],T);const S=rt(u.map(E=>n.getShape(E))),x=Se.Common(S.map(E=>n.getShapePageBounds(E))),v=n.getViewportPageBounds().center;n.updateShapes(S.map(E=>{const T={x:(E.x??0)-(x.x+x.w/2),y:(E.y??0)-(x.y+x.h/2)};return{id:E.id,type:E.type,x:v.x+T.x,y:v.y+T.y}})),n.setSelectedShapes(u)}const Fpe=n=>{const e=n/100;return e<.2?.1:e<.4?.25:e<.6?.5:e<.8?.75:1},Ym={1:"s",2:"m",3:"l",4:"xl"},zpe={16:"s",20:"m",28:"l",36:"xl"};function $pe(n){const e=zpe[n];return e?{size:e,scale:1}:n<16?{size:"s",scale:n/16}:n>36?{size:"xl",scale:n/36}:{size:"m",scale:1}}const Bpe={1:"draw",2:"sans",3:"mono"},Upe={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 ko(n,e,t){const r=[0,1,2,3,4].map(s=>Upe[n][s]);return Object.fromEntries(r.map((s,i)=>[s,i<3?e:t]))}const ff={...ko("gray","grey","black"),...ko("red","light-red","red"),...ko("pink","light-red","red"),...ko("grape","light-violet","violet"),...ko("blue","light-blue","blue"),...ko("cyan","light-blue","blue"),...ko("teal","light-green","green"),...ko("green","light-green","green"),...ko("yellow","yellow","orange"),...ko("orange","yellow","orange"),"#ffffff":"white","#000000":"black"},Hpe={solid:"draw",dashed:"dashed",dotted:"dotted"},Kpe={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},Wpe={left:"start",center:"middle",right:"end"},Vpe={left:"start",center:"middle",right:"end"},UL={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function qpe(n,e,t){let r=0;if(n.points.length>2){const s=new k(e[0],e[1]),i=new k(t[0],t[1]),o=new k(n.points[1][0],n.points[1][1]),a=k.Sub(i,s),l=k.Per(a),c=k.Med(i,s),u=k.Sub(c,l),h=k.Add(c,l),p=k.NearestPointOnLineSegment(u,h,o,!1);r=k.Dist(p,c),k.Clockwise(p,i,c)&&(r*=-1)}return r}const Xm=n=>{let e=Hpe[n.strokeStyle]??"draw";return e==="draw"&&n.roughness===0&&(e="solid"),e},Gpe=n=>n.backgroundColor==="transparent"?"none":Kpe[n.fillStyle]??"solid",Ype=/(^|[^`])`([^`]+)`(?!`)/,Xpe=/(^|[^`])`([^`]+)`(?!`)/g,TU=Bo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[tu({find:Ype,type:this.type})]},addPasteRules(){return[Wl({find:Xpe,type:this.type})]}}),Zpe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Jpe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,MU=Bo.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[tu({find:Zpe,type:this.type})]},addPasteRules(){return[Wl({find:Jpe,type:this.type})]}}),Qpe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ege="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Jd=(n,e)=>{for(const t in e)n[t]=e[t];return n},Hk="numeric",Kk="ascii",Wk="alpha",Vf="asciinumeric",Tf="alphanumeric",Vk="domain",AU="emoji",tge="scheme",nge="slashscheme",WC="whitespace";function rge(n,e){return n in e||(e[n]=[]),e[n]}function $c(n,e,t){e[Hk]&&(e[Vf]=!0,e[Tf]=!0),e[Kk]&&(e[Vf]=!0,e[Wk]=!0),e[Vf]&&(e[Tf]=!0),e[Wk]&&(e[Tf]=!0),e[Tf]&&(e[Vk]=!0),e[AU]&&(e[Vk]=!0);for(const r in e){const s=rge(r,t);s.indexOf(n)<0&&s.push(n)}}function sge(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Cs(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Cs.groups={};Cs.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Cs.groups;let s;return e&&e.j?s=e:(s=new Cs(e),t&&r&&$c(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||Cs.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,a=s.go(n);if(a?(o=new Cs,Jd(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Cs,i){if(r)if(o.t&&typeof o.t=="string"){const l=Jd(sge(o.t,r),t);$c(i,l,r)}else t&&$c(i,t,r);o.t=i}return s.j[n]=o,o}};const ut=(n,e,t,r,s)=>n.ta(e,t,r,s),pn=(n,e,t,r,s)=>n.tr(e,t,r,s),HL=(n,e,t,r,s)=>n.ts(e,t,r,s),ve=(n,e,t,r,s)=>n.tt(e,t,r,s),va="WORD",qk="UWORD",OU="ASCIINUMERICAL",RU="ALPHANUMERICAL",kp="LOCALHOST",Gk="TLD",Yk="UTLD",ky="SCHEME",vd="SLASH_SCHEME",sT="NUM",Xk="WS",iT="NL",qf="OPENBRACE",Gf="CLOSEBRACE",$S="OPENBRACKET",BS="CLOSEBRACKET",US="OPENPAREN",HS="CLOSEPAREN",KS="OPENANGLEBRACKET",WS="CLOSEANGLEBRACKET",VS="FULLWIDTHLEFTPAREN",qS="FULLWIDTHRIGHTPAREN",GS="LEFTCORNERBRACKET",YS="RIGHTCORNERBRACKET",XS="LEFTWHITECORNERBRACKET",ZS="RIGHTWHITECORNERBRACKET",JS="FULLWIDTHLESSTHAN",QS="FULLWIDTHGREATERTHAN",e0="AMPERSAND",t0="APOSTROPHE",n0="ASTERISK",_l="AT",r0="BACKSLASH",s0="BACKTICK",i0="CARET",Rl="COLON",oT="COMMA",o0="DOLLAR",_o="DOT",a0="EQUALS",aT="EXCLAMATION",gi="HYPHEN",Yf="PERCENT",l0="PIPE",c0="PLUS",u0="POUND",Xf="QUERY",lT="QUOTE",DU="FULLWIDTHMIDDLEDOT",cT="SEMI",To="SLASH",Zf="TILDE",d0="UNDERSCORE",jU="EMOJI",h0="SYM";var LU=Object.freeze({__proto__:null,ALPHANUMERICAL:RU,AMPERSAND:e0,APOSTROPHE:t0,ASCIINUMERICAL:OU,ASTERISK:n0,AT:_l,BACKSLASH:r0,BACKTICK:s0,CARET:i0,CLOSEANGLEBRACKET:WS,CLOSEBRACE:Gf,CLOSEBRACKET:BS,CLOSEPAREN:HS,COLON:Rl,COMMA:oT,DOLLAR:o0,DOT:_o,EMOJI:jU,EQUALS:a0,EXCLAMATION:aT,FULLWIDTHGREATERTHAN:QS,FULLWIDTHLEFTPAREN:VS,FULLWIDTHLESSTHAN:JS,FULLWIDTHMIDDLEDOT:DU,FULLWIDTHRIGHTPAREN:qS,HYPHEN:gi,LEFTCORNERBRACKET:GS,LEFTWHITECORNERBRACKET:XS,LOCALHOST:kp,NL:iT,NUM:sT,OPENANGLEBRACKET:KS,OPENBRACE:qf,OPENBRACKET:$S,OPENPAREN:US,PERCENT:Yf,PIPE:l0,PLUS:c0,POUND:u0,QUERY:Xf,QUOTE:lT,RIGHTCORNERBRACKET:YS,RIGHTWHITECORNERBRACKET:ZS,SCHEME:ky,SEMI:cT,SLASH:To,SLASH_SCHEME:vd,SYM:h0,TILDE:Zf,TLD:Gk,UNDERSCORE:d0,UTLD:Yk,UWORD:qk,WORD:va,WS:Xk});const pa=/[a-z]/,pf=new RegExp("\\p{L}","u"),VC=new RegExp("\\p{Emoji}","u"),ga=/\d/,qC=/\s/,KL="\r",GC=`
|
|
446
|
-
`,ige="️",oge="",YC="";let Zm=null,Jm=null;function age(n=[]){const e={};Cs.groups=e;const t=new Cs;Zm==null&&(Zm=WL(Qpe)),Jm==null&&(Jm=WL(ege)),ve(t,"'",t0),ve(t,"{",qf),ve(t,"}",Gf),ve(t,"[",$S),ve(t,"]",BS),ve(t,"(",US),ve(t,")",HS),ve(t,"<",KS),ve(t,">",WS),ve(t,"(",VS),ve(t,")",qS),ve(t,"「",GS),ve(t,"」",YS),ve(t,"『",XS),ve(t,"』",ZS),ve(t,"<",JS),ve(t,">",QS),ve(t,"&",e0),ve(t,"*",n0),ve(t,"@",_l),ve(t,"`",s0),ve(t,"^",i0),ve(t,":",Rl),ve(t,",",oT),ve(t,"$",o0),ve(t,".",_o),ve(t,"=",a0),ve(t,"!",aT),ve(t,"-",gi),ve(t,"%",Yf),ve(t,"|",l0),ve(t,"+",c0),ve(t,"#",u0),ve(t,"?",Xf),ve(t,'"',lT),ve(t,"/",To),ve(t,";",cT),ve(t,"~",Zf),ve(t,"_",d0),ve(t,"\\",r0),ve(t,"・",DU);const r=pn(t,ga,sT,{[Hk]:!0});pn(r,ga,r);const s=pn(r,pa,OU,{[Vf]:!0}),i=pn(r,pf,RU,{[Tf]:!0}),o=pn(t,pa,va,{[Kk]:!0});pn(o,ga,s),pn(o,pa,o),pn(s,ga,s),pn(s,pa,s);const a=pn(t,pf,qk,{[Wk]:!0});pn(a,pa),pn(a,ga,i),pn(a,pf,a),pn(i,ga,i),pn(i,pa),pn(i,pf,i);const l=ve(t,GC,iT,{[WC]:!0}),c=ve(t,KL,Xk,{[WC]:!0}),u=pn(t,qC,Xk,{[WC]:!0});ve(t,YC,u),ve(c,GC,l),ve(c,YC,u),pn(c,qC,u),ve(u,KL),ve(u,GC),pn(u,qC,u),ve(u,YC,u);const h=pn(t,VC,jU,{[AU]:!0});ve(h,"#"),pn(h,VC,h),ve(h,ige,h);const p=ve(h,oge);ve(p,"#"),pn(p,VC,h);const m=[[pa,o],[ga,s]],S=[[pa,null],[pf,a],[ga,i]];for(let x=0;x<Zm.length;x++)wl(t,Zm[x],Gk,va,m);for(let x=0;x<Jm.length;x++)wl(t,Jm[x],Yk,qk,S);$c(Gk,{tld:!0,ascii:!0},e),$c(Yk,{utld:!0,alpha:!0},e),wl(t,"file",ky,va,m),wl(t,"mailto",ky,va,m),wl(t,"http",vd,va,m),wl(t,"https",vd,va,m),wl(t,"ftp",vd,va,m),wl(t,"ftps",vd,va,m),$c(ky,{scheme:!0,ascii:!0},e),$c(vd,{slashscheme:!0,ascii:!0},e),n=n.sort((x,v)=>x[0]>v[0]?1:-1);for(let x=0;x<n.length;x++){const v=n[x][0],C=n[x][1]?{[tge]:!0}:{[nge]:!0};v.indexOf("-")>=0?C[Vk]=!0:pa.test(v)?ga.test(v)?C[Vf]=!0:C[Kk]=!0:C[Hk]=!0,HL(t,v,v,C)}return HL(t,"localhost",kp,{ascii:!0}),t.jd=new Cs(h0),{start:t,tokens:Jd({groups:e},LU)}}function NU(n,e){const t=lge(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let a=n,l=null,c=0,u=null,h=-1,p=-1;for(;o<r&&(l=a.go(t[o]));)a=l,a.accepts()?(h=0,p=0,u=a):h>=0&&(h+=t[o].length,p++),c+=t[o].length,i+=t[o].length,o++;i-=h,o-=p,c-=h,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function lge(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function wl(n,e,t,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];n.j[l]?i=n.j[l]:(i=new Cs(r),i.jr=s.slice(),n.j[l]=i),n=i}return i=new Cs(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function WL(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const Ip={defaultProtocol:"http",events:null,format:VL,formatHref:VL,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function uT(n,e=null){let t=Jd({},Ip);n&&(t=Jd(t,n instanceof uT?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}uT.prototype={o:Ip,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:Ip[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function VL(n){return n}function FU(n,e){this.t="token",this.v=n,this.tk=e}FU.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Ip.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),h=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&Jd(o,u),{tagName:s,attributes:o,content:i,eventListeners:h}}};function Dv(n,e){class t extends FU{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const qL=Dv("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),GL=Dv("text"),cge=Dv("nl"),Qm=Dv("url",{isLink:!0,toHref(n=Ip.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==kp&&n[1].t===Rl}}),pi=n=>new Cs(n);function uge({groups:n}){const e=n.domain.concat([e0,n0,_l,r0,s0,i0,o0,a0,gi,sT,Yf,l0,c0,u0,To,h0,Zf,d0]),t=[t0,Rl,oT,_o,aT,Yf,Xf,lT,cT,KS,WS,qf,Gf,BS,$S,US,HS,VS,qS,GS,YS,XS,ZS,JS,QS],r=[e0,t0,n0,r0,s0,i0,o0,a0,gi,qf,Gf,Yf,l0,c0,u0,Xf,To,h0,Zf,d0],s=pi(),i=ve(s,Zf);ut(i,r,i),ut(i,n.domain,i);const o=pi(),a=pi(),l=pi();ut(s,n.domain,o),ut(s,n.scheme,a),ut(s,n.slashscheme,l),ut(o,r,i),ut(o,n.domain,o);const c=ve(o,_l);ve(i,_l,c),ve(a,_l,c),ve(l,_l,c);const u=ve(i,_o);ut(u,r,i),ut(u,n.domain,i);const h=pi();ut(c,n.domain,h),ut(h,n.domain,h);const p=ve(h,_o);ut(p,n.domain,h);const m=pi(qL);ut(p,n.tld,m),ut(p,n.utld,m),ve(c,kp,m);const S=ve(h,gi);ve(S,gi,S),ut(S,n.domain,h),ut(m,n.domain,h),ve(m,_o,p),ve(m,gi,S);const x=ve(m,Rl);ut(x,n.numeric,qL);const v=ve(o,gi),w=ve(o,_o);ve(v,gi,v),ut(v,n.domain,o),ut(w,r,i),ut(w,n.domain,o);const C=pi(Qm);ut(w,n.tld,C),ut(w,n.utld,C),ut(C,n.domain,o),ut(C,r,i),ve(C,_o,w),ve(C,gi,v),ve(C,_l,c);const _=ve(C,Rl),E=pi(Qm);ut(_,n.numeric,E);const T=pi(Qm),A=pi();ut(T,e,T),ut(T,t,A),ut(A,e,T),ut(A,t,A),ve(C,To,T),ve(E,To,T);const O=ve(a,Rl),D=ve(l,Rl),$=ve(D,To),H=ve($,To);ut(a,n.domain,o),ve(a,_o,w),ve(a,gi,v),ut(l,n.domain,o),ve(l,_o,w),ve(l,gi,v),ut(O,n.domain,T),ve(O,To,T),ve(O,Xf,T),ut(H,n.domain,T),ut(H,e,T),ve(H,To,T);const G=[[qf,Gf],[$S,BS],[US,HS],[KS,WS],[VS,qS],[GS,YS],[XS,ZS],[JS,QS]];for(let J=0;J<G.length;J++){const[L,N]=G[J],U=ve(T,L);ve(A,L,U),ve(U,N,T);const Y=pi(Qm);ut(U,e,Y);const W=pi();ut(U,t),ut(Y,e,Y),ut(Y,t,W),ut(W,e,Y),ut(W,t,W),ve(Y,N,T),ve(W,N,T)}return ve(s,kp,C),ve(s,iT,cge),{start:s,tokens:LU}}function dge(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let a=n,l=null,c=null,u=0,h=null,p=-1;for(;s<r&&!(l=a.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=l||a.go(t[s].t));)l=null,a=c,a.accepts()?(p=0,h=a):p>=0&&p++,s++,u++;if(p<0)s-=u,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(XC(GL,e,o)),o=[]),s-=p,u-=p;const m=h.t,S=t.slice(s-u,s);i.push(XC(m,e,S))}}return o.length>0&&i.push(XC(GL,e,o)),i}function XC(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const hge=typeof console<"u"&&console&&console.warn||(()=>{}),fge="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Yt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function pge(){return Cs.groups={},Yt.scanner=null,Yt.parser=null,Yt.tokenQueue=[],Yt.pluginQueue=[],Yt.customSchemes=[],Yt.initialized=!1,Yt}function YL(n,e=!1){if(Yt.initialized&&hge(`linkifyjs: already initialized - will not register custom scheme "${n}" ${fge}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
447
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
448
|
-
2. Cannot start or end with "-"
|
|
449
|
-
3. "-" cannot repeat`);Yt.customSchemes.push([n,e])}function gge(){Yt.scanner=age(Yt.customSchemes);for(let n=0;n<Yt.tokenQueue.length;n++)Yt.tokenQueue[n][1]({scanner:Yt.scanner});Yt.parser=uge(Yt.scanner.tokens);for(let n=0;n<Yt.pluginQueue.length;n++)Yt.pluginQueue[n][1]({scanner:Yt.scanner,parser:Yt.parser});return Yt.initialized=!0,Yt}function dT(n){return Yt.initialized||gge(),dge(Yt.parser.start,n,NU(Yt.scanner.start,n))}dT.scan=NU;function zU(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new uT(t),s=dT(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}function mge(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function yge(n){return new cr({key:new Qs("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=ZJ(t.doc,[...e]);if(aQ(a).forEach(({newRange:c})=>{const u=QJ(r.doc,c,m=>m.isTextblock);let h,p;if(u.length>1?(h=u[0],p=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(h=u[0],p=r.doc.textBetween(h.pos,c.to,void 0," ")),h&&p){const m=p.split(" ").filter(w=>w!=="");if(m.length<=0)return!1;const S=m[m.length-1],x=h.pos+p.lastIndexOf(S);if(!S)return!1;const v=dT(S).map(w=>w.toObject(n.defaultProtocol));if(!mge(v))return!1;v.filter(w=>w.isLink).map(w=>({...w,from:x+w.start+1,to:x+w.end+1})).filter(w=>r.schema.marks.code?!r.doc.rangeHasMark(w.from,w.to,r.schema.marks.code):!0).filter(w=>n.validate(w.value)).filter(w=>n.shouldAutoLink(w.value)).forEach(w=>{fE(w.from,w.to,r.doc).some(C=>C.mark.type===n.type)||o.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function Sge(n){return new cr({key:new Qs("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(p=>p.nodeName==="A"))return!1;const l=W5(e.state,n.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,h=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,h),!0):!1}}})}function vge(n){return new cr({key:new Qs("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=zU(a,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:n.editor.commands.setMark(n.type,{href:l.href})}}})}const xge=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Ac(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(xge,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const wge=Bo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){YL(n);return}YL(n.scheme,n.optionalSlashes)})},onDestroy(){pge()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Ac(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Ac(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Ac(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",qn(this.options.HTMLAttributes,n),0]:["a",qn(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ac(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ac(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Wl({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=zU(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Ac(o,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(yge({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ac(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(Sge({type:this.type})),this.options.linkOnPaste&&n.push(vge({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),bge=/^\s*>\s$/,Cge=ao.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[pp({find:bge,type:this.type})]}}),Pge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,kge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ige=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ege=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_ge=Bo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[tu({find:Pge,type:this.type}),tu({find:Ige,type:this.type})]},addPasteRules(){return[Wl({find:kge,type:this.type}),Wl({find:Ege,type:this.type})]}}),Tge="listItem",XL="textStyle",ZL=/^\s*([-+*])\s$/,Mge=ao.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Tge,this.editor.getAttributes(XL)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=pp({find:ZL,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=pp({find:ZL,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(XL),editor:this.editor})),[n]}}),Age=/^```([a-z]+)?[\s\n]$/,Oge=/^~~~([a-z]+)?[\s\n]$/,Rge=ao.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",qn(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
450
|
-
|
|
451
|
-
`);return!i||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(lt.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[rk({find:Age,type:this.type,getAttributes:n=>({language:n[1]})}),rk({find:Oge,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new cr({key:new Qs("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!t||!i)return!1;const{tr:o,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
|
|
452
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(nt.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Dge=ao.create({name:"doc",topNode:!0,content:"block+"});function jge(n={}){return new cr({view(e){return new Lge(e,n)}})}class Lge{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,a=i.height/s.offsetHeight;if(t){let h=e.nodeBefore,p=e.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let S=m.getBoundingClientRect(),x=h?S.bottom:S.top;h&&p&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*a;r={left:S.left,right:S.right,top:x-v,bottom:x+v}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),p=h.width/l.offsetWidth,m=h.height/l.offsetHeight;c=h.left-l.scrollLeft*p,u=h.top-l.scrollTop*m}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=DF(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Nge=lr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[jge(this.options)]}});class mn extends lt{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return mn.valid(r)?new mn(r):lt.near(r)}content(){return Te.empty}eq(e){return e instanceof mn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new mn(e.resolve(t.pos))}getBookmark(){return new hT(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Fge(e)||!zge(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&mn.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>0?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let l=e.doc.resolve(s);if(mn.valid(l))return l}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!We.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let a=e.doc.resolve(s);if(mn.valid(a))return a}return null}}}mn.prototype.visible=!1;mn.findFrom=mn.findGapCursorFrom;lt.jsonID("gapcursor",mn);class hT{constructor(e){this.pos=e}map(e){return new hT(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return mn.valid(t)?new mn(t):lt.near(t)}}function Fge(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function zge(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function $ge(){return new cr({props:{decorations:Kge,createSelectionBetween(n,e,t){return e.pos==t.pos&&mn.valid(t)?new mn(t):null},handleClick:Uge,handleKeyDown:Bge,handleDOMEvents:{beforeinput:Hge}}})}const Bge=w5({ArrowLeft:ey("horiz",-1),ArrowRight:ey("horiz",1),ArrowUp:ey("vert",-1),ArrowDown:ey("vert",1)});function ey(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof nt){if(!i.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=mn.findGapCursorFrom(a,e,l);return c?(s&&s(r.tr.setSelection(new mn(c))),!0):!1}}function Uge(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!mn.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&We.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new mn(r))),!0)}function Hge(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof mn))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=ge.empty;for(let o=r.length-1;o>=0;o--)s=ge.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new Te(s,0,0));return i.setSelection(nt.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Kge(n){if(!(n.selection instanceof mn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",jn.create(n.doc,[xi.widget(n.selection.head,e,{key:"gapcursor"})])}const Wge=lr.create({name:"gapCursor",addProseMirrorPlugins(){return[$ge()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ft(Fe(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Vge=ao.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",qn(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
453
|
-
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){const h=l.filter(p=>a.includes(p.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),qge=ao.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,qn(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>rk({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var f0=200,Wn=function(){};Wn.prototype.append=function(e){return e.length?(e=Wn.from(e),!this.length&&e||e.length<f0&&this.leafAppend(e)||this.length<f0&&e.leafPrepend(this)||this.appendInner(e)):this};Wn.prototype.prepend=function(e){return e.length?Wn.from(e).append(this):this};Wn.prototype.appendInner=function(e){return new Gge(this,e)};Wn.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Wn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Wn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Wn.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};Wn.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};Wn.from=function(e){return e instanceof Wn?e:e&&e.length?new $U(e):Wn.empty};var $U=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=f0)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=f0)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Wn);Wn.empty=new $U([]);var Gge=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Wn);const Yge=500;class qi{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,a,l,c=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new Mo(h.map));let m=h.step.map(s.slice(i)),S;m&&o.maybeStep(m).doc&&(S=o.mapping.maps[o.mapping.maps.length-1],c.push(new Mo(S,void 0,void 0,c.length+u.length))),i--,S&&s.appendMap(S,i)}else o.maybeStep(h.step);if(h.selection)return a=s?h.selection.map(s.slice(i)):h.selection,l=new qi(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),p=new Mo(e.mapping.maps[u],h,t),m;(m=l&&l.merge(p))&&(p=m,u?i.pop():a=a.slice(0,a.length-1)),i.push(p),t&&(o++,t=void 0),s||(l=p)}let c=o-r.depth;return c>Zge&&(a=Xge(a,c),o-=c),new qi(a.append(i),o)}remapping(e,t){let r=new lp;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new qi(this.items.append(e.map(t=>new Mo(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},s);let l=t;this.items.forEach(p=>{let m=i.getMirror(--l);if(m==null)return;o=Math.min(o,m);let S=i.maps[m];if(p.step){let x=e.steps[m].invert(e.docs[m]),v=p.selection&&p.selection.map(i.slice(l+1,m));v&&a++,r.push(new Mo(S,x,v))}else r.push(new Mo(S))},s);let c=[];for(let p=t;p<o;p++)c.push(new Mo(i.maps[p]));let u=this.items.slice(0,s).append(c).append(r),h=new qi(u,a);return h.emptyItemCount()>Yge&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let h=new Mo(c.invert(),l,u),p,m=s.length-1;(p=s.length&&s[m].merge(h))?s[m]=p:s.push(h)}}else o.map&&r--},this.items.length,0),new qi(Wn.from(s.reverse()),i)}}qi.empty=new qi(Wn.empty,0);function Xge(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Mo{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Mo(t.getMap().invert(),t,this.selection)}}}class Tl{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Zge=20;function Jge(n,e,t,r){let s=t.getMeta(Yc),i;if(s)return s.historyState;t.getMeta(tme)&&(n=new Tl(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Yc))return o.getMeta(Yc).redo?new Tl(n.done.addTransform(t,void 0,r,Iy(e)),n.undone,JL(t.mapping.maps),n.prevTime,n.prevComposition):new Tl(n.done,n.undone.addTransform(t,void 0,r,Iy(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Qge(t,n.prevRanges)),c=o?ZC(n.prevRanges,t.mapping):JL(t.mapping.maps);return new Tl(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Iy(e)),qi.empty,c,t.time,a??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Tl(n.done.rebased(t,i),n.undone.rebased(t,i),ZC(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Tl(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ZC(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Qge(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function JL(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function ZC(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function eme(n,e,t){let r=Iy(e),s=Yc.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new Tl(t?a:i.remaining,t?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(Yc,{redo:t,historyState:l})}let JC=!1,QL=null;function Iy(n){let e=n.plugins;if(QL!=e){JC=!1,QL=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){JC=!0;break}}return JC}const Yc=new Qs("history"),tme=new Qs("closeHistory");function nme(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new cr({key:Yc,state:{init(){return new Tl(qi.empty,qi.empty,null,0,-1)},apply(e,t,r){return Jge(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?UU:r=="historyRedo"?HU:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function BU(n,e){return(t,r)=>{let s=Yc.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=eme(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const UU=BU(!1,!0),HU=BU(!0,!0),rme=lr.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>UU(n,e),redo:()=>({state:n,dispatch:e})=>HU(n,e)}},addProseMirrorPlugins(){return[nme(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),sme=ao.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",qn(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):cQ(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(nt.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(We.create(o.doc,c.pos)):o.setSelection(nt.create(o.doc,c.pos));else{const h=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();h&&(o.insert(u,h),o.setSelection(nt.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[BQ({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ime=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ome=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ame=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,lme=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,cme=Bo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[tu({find:ime,type:this.type}),tu({find:ame,type:this.type})]},addPasteRules(){return[Wl({find:ome,type:this.type}),Wl({find:lme,type:this.type})]}}),ume=ao.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",qn(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),dme="listItem",eN="textStyle",tN=/^(\d+)\.\s$/,hme=ao.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",qn(this.options.HTMLAttributes,t),0]:["ol",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dme,this.editor.getAttributes(eN)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=pp({find:tN,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=pp({find:tN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(eN)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),fme=ao.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),pme=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gme=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,mme=Bo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",qn(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[tu({find:pme,type:this.type})]},addPasteRules(){return[Wl({find:gme,type:this.type})]}}),yme=ao.create({name:"text",group:"inline"}),Sme=lr.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(_ge.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Cge.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Mge.configure(this.options.bulletList)),this.options.code!==!1&&n.push(TU.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(Rge.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Dge.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Nge.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(Wge.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(Vge.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(qge.configure(this.options.heading)),this.options.history!==!1&&n.push(rme.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(sme.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(cme.configure(this.options.italic)),this.options.listItem!==!1&&n.push(ume.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(hme.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(fme.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(mme.configure(this.options.strike)),this.options.text!==!1&&n.push(yme.configure(this.options.text)),n}}),fT={tldraw_draw:{normal:{normal:{family:"tldraw_draw",src:{url:"tldraw_draw",format:"woff2"},weight:"normal"},bold:{family:"tldraw_draw",src:{url:"tldraw_draw_bold",format:"woff2"},weight:"bold"}},italic:{normal:{family:"tldraw_draw",src:{url:"tldraw_draw_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_draw",src:{url:"tldraw_draw_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_sans:{normal:{normal:{family:"tldraw_sans",src:{url:"tldraw_sans",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_sans",src:{url:"tldraw_sans_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_sans",src:{url:"tldraw_sans_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_sans",src:{url:"tldraw_sans_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_serif:{normal:{normal:{family:"tldraw_serif",src:{url:"tldraw_serif",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_serif",src:{url:"tldraw_serif_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_serif",src:{url:"tldraw_serif_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_serif",src:{url:"tldraw_serif_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_mono:{normal:{normal:{family:"tldraw_mono",src:{url:"tldraw_mono",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_mono",src:{url:"tldraw_mono_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_mono",src:{url:"tldraw_mono_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_mono",src:{url:"tldraw_mono_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}}},vme=gn(fT).flatMap(n=>gn(n).flatMap(e=>Object.values(e))),xme=lr.create({name:"textDirection",addGlobalAttributes(){return[{types:["heading","paragraph"],attributes:{dir:{default:"auto",parseHTML:n=>{const e=n.getAttribute("dir");return e&&["ltr","rtl","auto"].includes(e)?e:"auto"},renderHTML:n=>({dir:n.dir})}}}]}}),wme=lr.create({name:"keyboardShiftEnterHandler",addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>n.commands.enter()}}});TU.config.excludes=void 0;MU.config.priority=1100;const dg=[Sme.configure({blockquote:!1,codeBlock:!1,horizontalRule:!1}),wge.configure({openOnClick:!1,autolink:!0}),MU,wme,xme];function pT(n,e){var s;const t=((s=n.getTextOptions().tipTapConfig)==null?void 0:s.extensions)??dg;return tQ(e,t).replaceAll('<p dir="auto"></p>',"<p><br /></p>")??""}function p0(n,e){return`<div class="tl-rich-text">${pT(n,e)}</div>`}const bme=new qo;function Vi(n){return n.content.length===1&&!n.content[0].content}function cu(n,e){return Vi(e)?"":bme.get(e,()=>{var r;const t=((r=n.getTextOptions().tipTapConfig)==null?void 0:r.extensions)??dg;return rQ(e,t,{blockSeparator:`
|
|
454
|
-
`})})}function Cme(n,e){var r;const t=((r=n.getTextOptions().tipTapConfig)==null?void 0:r.extensions)??dg;return nQ(e,t)}function KU(n,e,t){for(const o of n.marks)o.type.name==="bold"&&e.weight!=="bold"&&(e={...e,weight:"bold"}),o.type.name==="italic"&&e.style!=="italic"&&(e={...e,style:"italic"}),o.type.name==="code"&&e.family!=="tldraw_mono"&&(e={...e,family:"tldraw_mono"});const r=bn(fT,e.family);if(!r)return e;const s=bn(r,e.style);if(!s)return e;const i=bn(s,e.weight);return i&&t(i),e}const Pme=" ",tp=class tp{static normalizeText(e){return e.replace(tp.fixNewLines,`
|
|
455
|
-
`)}static normalizeTextForDom(e){return e.replace(tp.fixNewLines,`
|
|
456
|
-
`).split(`
|
|
457
|
-
`).map(t=>t||" ").join(`
|
|
458
|
-
`)}};R(tp,"fixNewLines",/\r?\n|\r/g);let g0=tp;const kme=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function WU(n){return kme.test(n)}function Ime(n){return n.replace(/\t/g,Pme)}function Eme(n){const e=n.split(`
|
|
459
|
-
`);for(;e[0]&&e[0].trim().length===0;)e.shift();let t=1/0;for(const r of e)if(r.trim().length>0){const s=r.length-r.trimStart().length;t=Math.min(t,s)}return e.map(r=>r.slice(t)).join(`
|
|
460
|
-
`)}const VU={"&":"&",""":'"',"'":"'","":"'",""":'"',"&":"&","'":"'","–":"–","—":"—","‘":"‘","’":"’","“":"“","”":"”","…":"…"},_me=new RegExp(Object.keys(VU).join("|"),"g");function qU(n){return n.replace(_me,e=>VU[e])}function Tme(n){return n.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Mme(n){return Tme(Eme(Ime(n)))}const GU=5e3,YU=10*1024*1024;function Ame(n,e){n.registerExternalAssetHandler("file",async t=>Ome(n,t,e)),n.registerExternalAssetHandler("url",async t=>Rme(n,t,e)),n.registerExternalContentHandler("svg-text",async t=>Dme(n,t)),n.registerExternalContentHandler("embed",t=>jme(n,t)),n.registerExternalContentHandler("files",async t=>Lme(n,t,e)),n.registerExternalContentHandler("text",async t=>Nme(n,t)),n.registerExternalContentHandler("url",async t=>Fme(n,t,e)),n.registerExternalContentHandler("tldraw",async t=>zme(n,t)),n.registerExternalContentHandler("excalidraw",async t=>$me(n,t))}async function Ome(n,{file:e,assetId:t},{acceptedImageMimeTypes:r=Mp,acceptedVideoMimeTypes:s=w0,maxAssetSize:i=YU,maxImageDimension:o=GU,toasts:a,msg:l}){const c=r.includes(e.type),u=s.includes(e.type);!c&&!u&&a.addToast({title:l("assets.files.type-not-allowed"),severity:"error"}),Je(c||u,`File type not allowed: ${e.type}`),e.size>i&&a.addToast({title:l("assets.files.size-too-big"),severity:"error"}),Je(e.size<=i,`File size too big: ${(e.size/1024).toFixed()}kb > ${(i/1024).toFixed()}kb`);const h=XN(await e.arrayBuffer());t=t??ql.createId(h);const p=await XU(e,t,c,u,o),m=await n.uploadAsset(p,e);return p.props.src=m.src,m.meta&&(p.meta={...p.meta,...m.meta}),ql.create(p)}async function Rme(n,{url:e},{toasts:t,msg:r}){var i,o,a,l,c;let s;try{const h=await(await Zi(e,{method:"GET",mode:"no-cors"})).text(),p=new DOMParser().parseFromString(h,"text/html");s={image:((i=p.head.querySelector('meta[property="og:image"]'))==null?void 0:i.getAttribute("content"))??"",favicon:((o=p.head.querySelector('link[rel="apple-touch-icon"]'))==null?void 0:o.getAttribute("href"))??((a=p.head.querySelector('link[rel="icon"]'))==null?void 0:a.getAttribute("href"))??"",title:((l=p.head.querySelector('meta[property="og:title"]'))==null?void 0:l.getAttribute("content"))??e,description:((c=p.head.querySelector('meta[property="og:description"]'))==null?void 0:c.getAttribute("content"))??""},s.image.startsWith("http")||(s.image=new URL(s.image,e).href),s.favicon.startsWith("http")||(s.favicon=new URL(s.favicon,e).href)}catch(u){console.error(u),t.addToast({title:r("assets.url.failed"),severity:"error"}),s={image:"",favicon:"",title:"",description:""}}return{id:ql.createId(CI(e)),typeName:"asset",type:"bookmark",props:{src:e,description:s.description,image:s.image,favicon:s.favicon,title:s.title},meta:{}}}async function Dme(n,{point:e,text:t}){const r=e??(n.inputs.shiftKey?n.inputs.currentPagePoint:n.getViewportPageBounds().center),s=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("svg");if(!s)throw new Error("No <svg/> element present");let i=parseFloat(s.getAttribute("width")||"0"),o=parseFloat(s.getAttribute("height")||"0");if(!(i&&o)){document.body.appendChild(s);const l=s.getBoundingClientRect();document.body.removeChild(s),i=l.width,o=l.height}const a=await n.getAssetForExternalContent({type:"file",file:new File([t],"asset.svg",{type:"image/svg+xml"})});if(!a)throw Error("Could not create an asset");ZU(n,[a],r)}function jme(n,{point:e,url:t,embed:r}){const s=e??(n.inputs.shiftKey?n.inputs.currentPagePoint:n.getViewportPageBounds().center),{width:i,height:o}=r,a=Dt(),l={id:a,type:"embed",x:s.x-(i||450)/2,y:s.y-(o||450)/2,props:{w:i,h:o,url:t}};n.createShapes([l]).select(a)}async function Lme(n,{point:e,files:t},{maxAssetSize:r=YU,maxImageDimension:s=GU,acceptedImageMimeTypes:i=Mp,acceptedVideoMimeTypes:o=w0,toasts:a,msg:l}){if(t.length>n.options.maxFilesAtOnce){a.addToast({title:l("assets.files.amount-too-big"),severity:"error"});return}const c=e??(n.inputs.shiftKey?n.inputs.currentPagePoint:n.getViewportPageBounds().center),u=new k(c.x,c.y),h=[],p=[];for(const m of t){if(m.size>r){a.addToast({title:l("assets.files.size-too-big"),severity:"error"}),console.warn(`File size too big: ${(m.size/1024).toFixed()}kb > ${(r/1024).toFixed()}kb`);continue}if(!m.type){a.addToast({title:l("assets.files.upload-failed"),severity:"error"}),console.error("No mime type");continue}if(![...i,...o].includes(m.type)){a.addToast({title:l("assets.files.type-not-allowed"),severity:"error"}),console.warn(`${m.name} not loaded - Mime type not allowed ${m.type}.`);continue}const x=i.includes(m.type),v=o.includes(m.type),w=XN(await m.arrayBuffer()),C=ql.createId(w),_=await XU(m,C,x,v,s);let E;x&&(E=n.createTemporaryAssetPreview(C,m)),h.push(_),p.push({asset:_,file:m,temporaryAssetPreview:E})}Promise.allSettled(p.map(async m=>{try{const S=await n.getAssetForExternalContent({type:"file",file:m.file});if(!S)throw Error("Could not create an asset");n.updateAssets([{...S,id:m.asset.id}])}catch(S){a.addToast({title:l("assets.files.upload-failed"),severity:"error"}),console.error(S),n.deleteAssets([m.asset.id]);return}})),ZU(n,h,u)}async function Nme(n,{point:e,text:t,html:r}){const s=e??(n.inputs.shiftKey?n.inputs.currentPagePoint:n.getViewportPageBounds().center),i=n.getShapeUtil("text").getDefaultProps(),o=Mme(t),a=r?Cme(n,r):Ei(o);let l,c,u,h="middle";const p=r??o.replace(/\n/g,"<br>"),m=r?a.content.length>1:o.split(`
|
|
461
|
-
`).length>1,S=WU(o);m&&(h=m?S?"end":"start":"middle");const x=n.textMeasure.measureHtml(p,{...ar,fontFamily:Ba[i.font],fontSize:Zd[i.size],maxWidth:null}),v=Math.min(m?n.getViewportPageBounds().width*.9:920,Math.max(200,n.getViewportPageBounds().width*.9));if(x.w>v){const w=n.textMeasure.measureHtml(p,{...ar,fontFamily:Ba[i.font],fontSize:Zd[i.size],maxWidth:v});l=w.w,c=w.h,u=!1,h=S?"end":"start"}else l=x.w,c=x.h,u=!0;s.y-c/2<n.getViewportPageBounds().minY+40&&(s.y=n.getViewportPageBounds().minY+40+c/2),n.createShapes([{id:Dt(),type:"text",x:s.x-l/2,y:s.y-c/2,props:{richText:a,textAlign:h,autoSize:u,w:l}}])}async function Fme(n,{point:e,url:t},{toasts:r,msg:s}){const i=n.getShapeUtil("embed"),o=i==null?void 0:i.getEmbedDefinition(t);if(o)return n.putExternalContent({type:"embed",url:o.url,point:e,embed:o.definition});const a=e??(n.inputs.shiftKey?n.inputs.currentPagePoint:n.getViewportPageBounds().center),l=ql.createId(CI(t)),c=Bme(n,t,a);let u=n.getAsset(l),h=!1;if(!u){h=!0;try{const p=await n.getAssetForExternalContent({type:"url",url:t});if(!p)throw Error("Could not create an asset");u=p}catch{r.addToast({title:s("assets.url.failed"),severity:"error"});return}}n.run(()=>{h&&n.createAssets([u]),n.updateShapes([{id:c.id,type:c.type,props:{assetId:u.id}}])})}async function zme(n,{point:e,content:t}){n.run(()=>{const r=n.getSelectionPageBounds();n.markHistoryStoppingPoint("paste"),n.putContentOntoCurrentPage(t,{point:e,select:!0});const s=n.getSelectionPageBounds();r&&s&&(r!=null&&r.collides(s))&&(n.updateInstanceState({isChangingStyle:!0}),n.timers.setTimeout(()=>{n.updateInstanceState({isChangingStyle:!1})},150))})}async function $me(n,{point:e,content:t}){n.run(()=>{Npe(n,t,e)})}async function XU(n,e,t,r,s){let i=n.type;n.type==="video/quicktime"&&(i="video/mp4");const o=t?await Hs.getImageSize(n):await Hs.getVideoSize(n),a=await Hs.isAnimated(n)||r,l={id:e,type:t?"image":"video",typeName:"asset",props:{name:n.name,src:"",w:o.w,h:o.h,fileSize:n.size,mimeType:i,isAnimated:a},meta:{}};if(s&&isFinite(s)){const c={w:l.props.w,h:l.props.h},u=Lpe(c,{w:s,h:s});c!==u&&Hs.isStaticImageType(n.type)&&(l.props.w=u.w,l.props.h=u.h)}return l}async function ZU(n,e,t){if(!e.length)return[];const r=k.From(t),s=[];for(let i=0;i<e.length;i++){const o=e[i];switch(o.type){case"image":{s.push({id:Dt(),type:"image",x:r.x,y:r.y,opacity:1,props:{assetId:o.id,w:o.props.w,h:o.props.h}}),r.x+=o.props.w;break}case"video":s.push({id:Dt(),type:"video",x:r.x,y:r.y,opacity:1,props:{assetId:o.id,w:o.props.w,h:o.props.h}}),r.x+=o.props.w}}return n.run(()=>{const i=e.filter(o=>!n.getAsset(o.id));n.store.atomic(()=>{i.length&&n.createAssets(i),n.createShapes(s).select(...s.map(o=>o.id)),JU(n,t)})}),s.map(i=>i.id)}function JU(n,e){const t=n.getViewportPageBounds();let r=n.getSelectionPageBounds();if(r){const s=r.center.sub(e);n.updateShapes(n.getSelectedShapes().map(i=>{const o=n.getShapeParentTransform(i).decompose().rotation,a=k.Rot(s,-o);return{id:i.id,type:i.type,x:i.x-a.x,y:i.y-a.y}}))}if(r=n.getSelectionPageBounds(),r&&n.getInstanceState().isGridMode){const s=n.getDocumentSettings().gridSize,i=new k(r.minX,r.minY),o=i.clone().snapToGrid(s),a=k.Sub(i,o);n.updateShapes(n.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=n.getSelectionPageBounds(),r&&!t.contains(r)&&n.zoomToSelection({animation:{duration:n.options.animationMediumMs}})}function Bme(n,e,t){const r={id:Dt(),type:"bookmark",x:t.x-150,y:t.y-160,opacity:1,props:{assetId:null,url:e}};return n.run(()=>{n.createShapes([r]).select(r.id),JU(n,t)}),n.getShape(r.id)}var dP;let Ume=(dP=class extends De{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}onKeyUp(e){var t;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),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:r}))}}},R(dP,"id","idle"),dP);var hP;let Hme=(hP=class extends De{constructor(){super(...arguments);R(this,"shape");R(this,"markId","");R(this,"preciseTimeout",-1);R(this,"didTimeout",!1)}onEnter(){this.markId="",this.didTimeout=!1;const t=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});t?this.editor.setHintingShapes([t.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:t}=this.editor.inputs,r=Dt();this.markId=this.editor.markHistoryStoppingPoint(`creating_arrow:${r}`);const s=ro(t,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 i=this.editor.getShape(r);if(!i)throw Error("expected shape");const o=this.editor.getShapeHandles(i);if(!o)throw Error("expected handles for arrow");const a=this.editor.getShapeUtil("arrow"),l=this.shape,c=o.find(p=>p.id==="start"),u=(h=a.onHandleDrag)==null?void 0:h.call(a,i,{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,i;const t=this.shape;if(!t)throw Error("expected shape");const r=this.editor.getShapeHandles(t);if(!r)throw Error("expected handles for arrow");{const o=this.editor.getShapeUtil("arrow"),a=this.shape,l=r.find(u=>u.id==="start"),c=(s=o.onHandleDrag)==null?void 0:s.call(o,t,{handle:{...l,x:0,y:0},isPrecise:this.didTimeout,initial:a});c&&this.editor.updateShapes([c])}{const o=this.editor.getShapeUtil("arrow"),a=this.shape,l=this.editor.getPointInShapeSpace(t,this.editor.inputs.currentPagePoint),c=r.find(h=>h.id==="end"),u=(i=o.onHandleDrag)==null?void 0:i.call(o,this.editor.getShape(t),{handle:{...c,x:l.x,y:l.y},isPrecise:!1,initial:a});u&&this.editor.updateShapes([u])}this.shape=this.editor.getShape(t.id)}startPreciseTimeout(){this.preciseTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},R(hP,"id","pointing"),hP);class Zk extends De{constructor(){super(...arguments);R(this,"shapeType","arrow")}static children(){return[Ume,Hme]}}R(Zk,"id","arrow"),R(Zk,"initial","idle");class gT extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"initialShape");R(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");R(this,"util",this.editor.getShapeUtil(this.shapeType));R(this,"isPen",!1);R(this,"isPenOrStylus",!1);R(this,"segmentMode","free");R(this,"didJustShiftClickToExtendPreviousShapeLine",!1);R(this,"pagePointWhereCurrentSegmentChanged",{});R(this,"pagePointWhereNextSegmentChanged",null);R(this,"lastRecordedPoint",{});R(this,"mergeNextPoint",!1);R(this,"currentLineLength",0);R(this,"markId",null)}onEnter(t){this.markId=null,this.info=t,this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.startShape()}onPointerMove(){const{inputs:t}=this.editor;if(this.isPen&&!t.isPen&&this.markId){this.editor.bailToMark(this.markId),this.startShape();return}this.isPenOrStylus?k.Dist(t.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=t.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape()}onKeyDown(t){if(t.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(t){if(t.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(t,r,s){if(!this.canClose())return!1;const i=Er[r],o=t[0].points[0],a=t[t.length-1],l=a.points[a.points.length-1];return o!==l&&this.currentLineLength>i*4*s&&k.DistMin(o,l,i*2*s)}startShape(){const{inputs:{originPagePoint:t,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 i=this.isPenOrStylus?s*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=t.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const l=tr(a.props.segments);if(!l)throw Error("Expected a previous segment!");const c=tr(l.points);if(!c)throw Error("Expected a previous point!");const{x:u,y:h}=this.editor.getPointInShapeSpace(a,t).toFixed(),p={type:this.segmentMode,points:[{x:c.x,y:c.y,z:+i.toFixed(2)},{x:u,y:h,z:+i.toFixed(2)}]},m=he.applyToPoint(this.editor.getShapePageTransform(a.id),c);this.pagePointWhereCurrentSegmentChanged=m,this.pagePointWhereNextSegmentChanged=null;const S=[...a.props.segments,p];this.currentLineLength<Er[a.props.size]*4&&(this.currentLineLength=this.getLineLength(S));const x={id:a.id,type:this.shapeType,props:{segments:S}};this.canClose()&&(x.props.isClosed=this.getIsClosed(S,a.props.size,a.props.scale)),this.editor.updateShapes([x]);return}}this.pagePointWhereCurrentSegmentChanged=t.clone();const o=Dt();this.editor.createShapes([{id:o,type:this.shapeType,x:t.x,y:t.y,props:{isPen:this.isPenOrStylus,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+i.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(o)}updateDrawingShape(){const{initialShape:t}=this,{inputs:r}=this.editor;if(!t)return;const{id:s,props:{size:i,scale:o}}=t,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(),p=this.isPenOrStylus?+(r.currentPagePoint.z*1.25).toFixed(2):.5,m={x:c,y:u,z:p};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:S}=this;if(S===null)throw Error("We should have a point where the segment changed");if(k.Dist2(S,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const v=tr(l);if(!v)throw Error("Expected a previous segment!");const w=tr(v.points);if(!w)throw Error("Expected a previous last point!");let C;const _=this.editor.getPointInShapeSpace(a,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(v.type==="straight"){this.currentLineLength+=k.Dist(w,_),C={type:"straight",points:[{...w},_]};const T=this.editor.getShapePageTransform(a);this.pagePointWhereCurrentSegmentChanged=he.applyToPoint(T,w)}else C={type:"straight",points:[_,m]};const E={id:s,type:this.shapeType,props:{segments:[...l,C]}};this.canClose()&&(E.props.isClosed=this.getIsClosed(l,i,o)),this.editor.updateShapes([E])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:S}=this;if(S===null)throw Error("We should have a point where the segment changed");if(k.Dist2(S,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const v=l.slice(),w=v[v.length-1],C=tr(w.points);if(!C)throw Error("No previous point!");const _={type:"free",points:[...k.PointsBetween(C,m,6).map(A=>({x:Ca(A.x),y:Ca(A.y),z:Ca(A.z)}))]},E=[...v,_];this.currentLineLength<Er[a.props.size]*4&&(this.currentLineLength=this.getLineLength(E));const T={id:s,type:this.shapeType,props:{segments:E}};this.canClose()&&(T.props.isClosed=this.getIsClosed(E,i,o)),this.editor.updateShapes([T])}break}case"straight":{const S=l.slice(),x=S[S.length-1],{pagePointWhereCurrentSegmentChanged:v}=this,{ctrlKey:w,currentPagePoint:C}=this.editor.inputs;if(!v)throw Error("We should have a point where the segment changed");let _,E=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(E=!w,this.didJustShiftClickToExtendPreviousShapeLine=!1):E=!w;let T=this.editor.getPointInShapeSpace(a,C).toFixed().toJson(),A=!1,O;if((this.editor.user.getIsSnapMode()?!w:w)&&S.length>2){let H,G=8/this.editor.getZoomLevel();for(let J=0,L=l.length-2;J<L;J++){const N=l[J];if(!N)break;if(N.type==="free")continue;const U=N.points[0],Y=tr(N.points);if(!(U&&Y))continue;const W=k.NearestPointOnLineSegment(U,Y,T);if(k.DistMin(W,T,G)){H=W.toFixed().toJson(),G=k.Dist(W,T),O=N;break}}H&&(A=!0,T=H)}if(A&&O){const H=this.editor.getShapePageTransform(a),G=O.points[0],J=tr(O.points);if(!J)throw Error("Expected a last point!");const L=he.applyToPoint(H,G),N=he.applyToPoint(H,J),U=he.applyToPoint(H,T);this.editor.snaps.setIndicators([{id:_t(),type:"points",points:[L,U,N]}])}else{if(this.editor.snaps.clearIndicators(),E){const H=k.Angle(v,C),J=Zy(H,24)-H;_=k.RotWith(C,v,J)}else _=C;T=this.editor.getPointInShapeSpace(a,_).toFixed().toJson()}this.currentLineLength+=k.Dist(x.points[0],T),S[S.length-1]={...x,type:"straight",points:[x.points[0],T]};const $={id:s,type:this.shapeType,props:{segments:S}};this.canClose()&&($.props.isClosed=this.getIsClosed(l,i,o)),this.editor.updateShapes([$]);break}case"free":{const S=l.slice(),x=S[S.length-1],v=[...x.points];if(v.length&&this.mergeNextPoint){const{z:C}=v[v.length-1];v[v.length-1]={x:m.x,y:m.y,z:C?Math.max(C,m.z):m.z}}else this.currentLineLength+=k.Dist(v[v.length-1],m),v.push(m);S[S.length-1]={...x,points:v},this.currentLineLength<Er[a.props.size]*4&&(this.currentLineLength=this.getLineLength(S));const w={id:s,type:this.shapeType,props:{segments:S}};if(this.canClose()&&(w.props.isClosed=this.getIsClosed(S,i,o)),this.editor.updateShapes([w]),v.length>this.util.options.maxPointsPerShape){this.editor.updateShapes([{id:s,type:this.shapeType,props:{isComplete:!0}}]);const C=Dt(),_=this.editor.getShape(s).props;this.editor.createShapes([{id:C,type:this.shapeType,x:Ca(r.currentPagePoint.x),y:Ca(r.currentPagePoint.y),props:{isPen:this.isPenOrStylus,scale:_.scale,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(h*1.25).toFixed():.5}]}]}}]),this.initialShape=Xt(this.editor.getShape(C)),this.mergeNextPoint=!1,this.lastRecordedPoint=r.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(t){let r=0;for(const s of t)for(let i=0;i<s.points.length-1;i++){const o=s.points[i],a=s.points[i+1];r+=k.Dist2(a,o)}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:t}=this;t&&(this.editor.updateShapes([{id:t.id,type:t.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}R(gT,"id","drawing");var fP;let QU=(fP=class extends De{onPointerDown(e){this.parent.transition("drawing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},R(fP,"id","idle"),fP);class Mf extends De{constructor(){super(...arguments);R(this,"shapeType","draw")}static children(){return[QU,gT]}onExit(){const t=this.children.drawing;t.initialShape=void 0}}R(Mf,"id","draw"),R(Mf,"initial","idle"),R(Mf,"isLockable",!1),R(Mf,"useCoalescedEvents",!0);class Jk extends kk{constructor(){super(...arguments);R(this,"shapeType","frame")}onCreate(t){if(!t)return;const r=this.editor.getShapePageBounds(t),s=[],i=this.editor.getShapeAncestors(t).map(o=>o.id);this.editor.getSortedChildIdsForParent(t.parentId).map(o=>{const a=this.editor.getShape(o);if(!a||a.id===t.id||a.isLocked)return;const l=this.editor.getShapePageBounds(a);l&&r.contains(l)&&Kme(a,i,t)&&s.push(a.id)}),this.editor.reparentShapes(s,t.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")}}R(Jk,"id","frame"),R(Jk,"initial","idle");function Kme(n,e,t){return e.includes(n.id)?!1:n.parentId===t.parentId}var pP;let Wme=(pP=class extends De{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onKeyUp(e){var t;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),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:r}))}}onCancel(){this.editor.setCurrentTool("select")}},R(pP,"id","idle"),pP);var gP;let Vme=(gP=class extends De{onPointerUp(){this.complete()}onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:t}=this.editor.inputs,r=Dt(),s=this.editor.markHistoryStoppingPoint(`creating_geo:${r}`),i=ro(t,this.editor);this.editor.createShapes([{id:r,type:"geo",x:i.x,y:i.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(Xi),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,t=Dt();this.editor.markHistoryStoppingPoint(`creating_geo:${t}`);const r=this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,s=this.editor.getStyleForNextShape(Xi),i=s==="star"?{w:200,h:190}:s==="cloud"?{w:300,h:180}:{w:200,h:200};this.editor.createShapes([{id:t,type:"geo",x:e.x,y:e.y,props:{geo:this.editor.getStyleForNextShape(Xi),scale:r,...i}}]);const o=this.editor.getShape(t);if(!o)return;const{w:a,h:l}=o.props,c=new k(a/2,l/2).mul(r),u=this.editor.getShapeParentTransform(o);u&&c.rot(-u.rotation());const h=ro(new k(o.x-c.x,o.y-c.y),this.editor);this.editor.select(t),this.editor.updateShape({id:o.id,type:"geo",x:h.x,y:h.y,props:{geo:this.editor.getStyleForNextShape(Xi),w:a*r,h:l*r}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},R(gP,"id","pointing"),gP);class Qk extends De{constructor(){super(...arguments);R(this,"shapeType","geo")}static children(){return[Wme,Vme]}}R(Qk,"id","geo"),R(Qk,"initial","idle");class Af extends De{constructor(){super(...arguments);R(this,"shapeType","highlight")}static children(){return[QU,gT]}onExit(){const t=this.children.drawing;t.initialShape=void 0}}R(Af,"id","highlight"),R(Af,"initial","idle"),R(Af,"useCoalescedEvents",!0),R(Af,"isLockable",!1);var mP;let qme=(mP=class extends De{constructor(){super(...arguments);R(this,"shapeId","")}onEnter(t){this.shapeId=t.shapeId,this.editor.setCursor({type:"cross",rotation:0})}onPointerDown(){this.parent.transition("pointing",{shapeId:this.shapeId})}onCancel(){this.editor.setCurrentTool("select")}},R(mP,"id","idle"),mP);const nN=2;var yP;let Gme=(yP=class extends De{constructor(){super(...arguments);R(this,"shape",{});R(this,"markId")}onEnter(t){const{inputs:r}=this.editor,{currentPagePoint:s}=r;this.markId=void 0;const i=t.shapeId&&this.editor.getShape(t.shapeId);if(i&&r.shiftKey){this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${i.id}`),this.shape=i;const o=this.editor.getShapeHandles(this.shape);if(!o)return;const a=o.filter(S=>S.type==="vertex").sort(nr),l=a[a.length-1],c=a[a.length-2],u=he.applyToPoint(this.editor.getShapeParentTransform(this.shape),new k(this.shape.x,this.shape.y)),h=k.Sub(s,u).addXY(.1,.1),p=ro(h,this.editor),m=Xt(this.shape.props.points);if(k.DistMin(l,c,nN)||k.DistMin(p,l,nN))m[l.id]={id:l.id,index:l.index,x:p.x,y:p.y};else{const S=Ro(l.index);m[S]={id:S,index:S,x:p.x,y:p.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:m}}])}else{const o=Dt();this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${o}`);const a=ro(s,this.editor);this.editor.createShapes([{id:o,type:"line",x:a.x,y:a.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]),this.editor.select(o),this.shape=this.editor.getShape(o)}}onPointerMove(){if(this.shape&&this.editor.inputs.isDragging){const t=this.editor.getShapeHandles(this.shape);if(!t)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const r=tr(t);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()}},R(yP,"id","pointing"),yP);class eI extends De{constructor(){super(...arguments);R(this,"shapeType","line")}static children(){return[qme,Gme]}}R(eI,"id","line"),R(eI,"initial","idle");var SP;let Yme=(SP=class extends De{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},R(SP,"id","idle"),SP);const Xme=0,Ot=200,jv=new k(Ot/2,Ot/2),e7=10,Zme=n=>[[["a1"],new k(Ot*.5,Ot*-.5-n.options.adjacentShapeMargin)],[["a2"],new k(Ot*1.5+n.options.adjacentShapeMargin,Ot*.5)],[["a3"],new k(Ot*.5,Ot*1.5+n.options.adjacentShapeMargin)],[["a4"],new k(Ot*-.5-n.options.adjacentShapeMargin,Ot*.5)]];function Jme(n,e){if(e===1)return Zme(n);const t=Ot*e,r=n.options.adjacentShapeMargin*e;return[[["a1"],new k(t*.5,t*-.5-r)],[["a2"],new k(t*1.5+r,t*.5)],[["a3"],new k(t*.5,t*1.5+r)],[["a4"],new k(t*-.5-r,t*.5)]]}function t7(n,e,t,r,s,i){return Object.fromEntries(Jme(n,i).map(([o,a],l)=>{const c=a.clone();return l===0&&s?c.y-=s:l===2&&r&&(c.y+=r),[o,c.rot(t).add(e)]}))}function n7(n,e,t,r){const s=new Set(n.getSelectedShapeIds()),i=(Ot+n.options.adjacentShapeMargin+r)**2,o=new Map,a=[];for(const u of n.getCurrentPageShapes()){if(!n.isShapeOfType(u,"note")||t!==u.props.scale||s.has(u.id))continue;const h=n.getShapePageTransform(u.id);e===h.rotation()&&(o.set(u,n.getShapePageBounds(u).center),a.push(...Object.values(t7(n,h.point(),e,u.props.growY,r,t))))}const l=a.length;let c;for(const[u,h]of o)for(let p=0;p<l;p++)c=a[p],c&&(k.Dist2(h,c)>i||n.isPointInShape(u,c)&&(a[p]=void 0));return rt(a)}function r7(n,e,t,r,s=!1){let i;const o=n.getCurrentPageShapesSorted(),a=(Ot+n.options.adjacentShapeMargin**2)**e.props.scale;for(let l=o.length-1;l>=0;l--){const c=o[l];if(c.type==="note"&&c.id!==e.id){const u=n.getShapePageBounds(c);if(u&&k.Dist2(u.center,t)<a&&n.isPointInShape(c,t)){i=c;break}}}if(n.complete(),!i||s){n.markHistoryStoppingPoint("creating note shape");const l=Dt();n.createShape({id:l,type:"note",x:t.x,y:t.y,rotation:r,opacity:e.opacity,props:{...e.props,richText:Ei(""),growY:0,fontSizeAdjustment:0,url:""}});const c=n.getShape(l);if(!c)return;const u=n.getPointInParentSpace(c,k.Sub(t,k.Rot(jv.clone().mul(c.props.scale),r)));n.updateShape({id:l,type:"note",x:u.x,y:u.y}),i=n.getShape(l)}return n.zoomToSelectionIfOffscreen(16,{animation:{duration:n.options.animationMediumMs},inset:0}),i}var vP;let Qme=(vP=class extends De{constructor(){super(...arguments);R(this,"dragged",!1);R(this,"info",{});R(this,"markId","");R(this,"shape",{})}onEnter(){const{editor:t}=this,r=Dt();this.markId=t.markHistoryStoppingPoint(`creating_note:${r}`);const s=this.editor.inputs.originPagePoint.clone(),i=eye(this.editor,s,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);i&&s.sub(i),this.shape=tye(this.editor,r,s)}onPointerMove(t){this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.translating",{...t,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)}},R(vP,"id","pointing"),vP);function eye(n,e,t){let r=e7/n.getZoomLevel(),s;for(const i of n7(n,0,t,0)){const o=k.Sub(e,i),a=o.len();a<r&&(r=a,s=o)}return s}function tye(n,e,t){n.createShape({id:e,type:"note",x:t.x,y:t.y,props:{scale:n.user.getIsDynamicResizeMode()?1/n.getZoomLevel():1}}).select(e);const r=n.getShape(e),s=n.getShapeGeometry(r).bounds,i=ro(new k(r.x-s.width/2,r.y-s.height/2),n);return n.updateShapes([{id:e,type:"note",x:i.x,y:i.y}]),n.getShape(e)}class tI extends De{constructor(){super(...arguments);R(this,"shapeType","note")}static children(){return[Yme,Qme]}}R(tI,"id","note"),R(tI,"initial","idle");function nye(n){const e=n.getShapeAtPoint(n.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:n.options.hitTestMargin/n.getZoomLevel(),renderingOnly:!0});if(!e)return n.setHoveredShape(null);let t;const r=n.getOutermostSelectableShape(e);return r===e||r.id===n.getFocusedGroupId()||n.getSelectedShapeIds().includes(r.id)?t=e:t=r,n.setHoveredShape(t.id)}const Ea=VN(nye,32);var xP;let rye=(xP=class extends De{onPointerMove(e){switch(e.target){case"shape":case"canvas":Ea(this.editor)}}onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){Ea.cancel()}onKeyDown(e){var t;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),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:r}))}}onCancel(){this.editor.setCurrentTool("select")}},R(xP,"id","idle"),xP);var wP;let sye=(wP=class extends De{constructor(){super(...arguments);R(this,"shape");R(this,"markId","");R(this,"enterTime",0)}onEnter(){this.enterTime=Date.now()}onExit(){this.editor.setHintingShapes([])}onPointerMove(t){if(Date.now()-this.enterTime<150)return;const{editor:r}=this,{isPointing:s}=r.inputs;if(!s)return;const{originPagePoint:i,currentPagePoint:o}=r.inputs,a=Math.abs(i.x-o.x),c=Math.sqrt(r.getInstanceState().isCoarsePointer?r.options.coarseDragDistanceSquared:r.options.dragDistanceSquared)*6/r.getZoomLevel();if(a>c){const u=Dt();this.markId=r.markHistoryStoppingPoint(`creating_text:${u}`);const h=this.createTextShape(u,i,!1,a);if(!h){this.cancel();return}this.shape=r.getShape(h),r.select(u),r.setCurrentTool("select.resizing",{...t,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 t=Dt(),{originPagePoint:r}=this.editor.inputs;this.createTextShape(t,r,!0,20)&&(this.editor.select(t),this.editor.setEditingShape(t))}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}createTextShape(t,r,s,i){this.editor.createShape({id:t,type:"text",x:r.x,y:r.y,props:{richText:Ei(""),autoSize:s,w:i,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const o=this.editor.getShape(t);if(!o){this.cancel();return}const a=this.editor.getShapePageBounds(o),l=new k;if(s)switch(o.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,ws(o.parentId)){const h=this.editor.getShapeParentTransform(o);l.rot(-h.rotation())}const c=o.x+l.x,u=o.y+l.y;if(this.editor.getInstanceState().isGridMode){const h=new k(c,u),p=ro(h,this.editor),m=k.Sub(h,p);this.editor.updateShape({...o,x:c-m.x,y:u-m.y})}else this.editor.updateShape({...o,x:c,y:u});return o}},R(wP,"id","pointing"),wP);class nI extends De{constructor(){super(...arguments);R(this,"shapeType","text")}static children(){return[rye,sye]}}R(nI,"id","text"),R(nI,"initial","idle");const iye=[nI,Mf,Qk,tI,eI,Jk,Zk,Af],oye=at.forwardRef(function({isEditing:e,text:t,handleFocus:r,handleChange:s,handleKeyDown:i,handleBlur:o,handleInputPointerDown:a,handleDoubleClick:l},c){const u=h=>{s({plaintext:h.target.value})};return g.jsx("textarea",{ref:c,className:"tl-text tl-text-input",name:"text",tabIndex:-1,disabled:!e,readOnly:!e,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:t,onFocus:r,onChange:u,onKeyDown:h=>i(h.nativeEvent),onBlur:o,onTouchEnd:Wt,onContextMenu:e?Wt:void 0,onPointerDown:a,onDoubleClick:l,onDragStart:tt})});function aye(n,e,t,r){if((n==="start-legacy"||n==="end-legacy")&&t.length!==0){const s=Se.From(t[0].box);for(const{box:i}of t)s.union(i);if(n==="start-legacy")return(r-2*e-s.width)/2;if(n==="end-legacy")return-(r-2*e-s.width)/2}}function s7(n){return n==="start-legacy"||n==="middle-legacy"||n==="end-legacy"}function lye(n,e,t){const r=i7(n),s=r.isEditing,i=te(),o=P.useRef(null),a=(t||"").trim().length===0;P.useEffect(()=>{function u(h){var p,m;h.shapeId===n&&((m=(p=o.current)==null?void 0:p.select)==null||m.call(p))}return i.on("select-all-text",u),()=>{i.off("select-all-text",u)}},[i,n,s]),P.useEffect(()=>{var u,h,p,m;s&&(document.activeElement!==o.current&&((u=o.current)==null||u.focus()),i.getInstanceState().isCoarsePointer&&((h=o.current)==null||h.select()),It.isSafari&&((p=o.current)==null||p.blur(),(m=o.current)==null||m.focus()))},[i,s]);const l=P.useCallback(u=>{if(i.getEditingShapeId()===n)switch(u.key){case"Enter":{(u.ctrlKey||u.metaKey)&&i.complete();break}}},[i,n]),c=P.useCallback(({plaintext:u})=>{if(i.getEditingShapeId()!==n)return;const h=g0.normalizeText(u||"");i.updateShape({id:n,type:e,props:{text:h}})},[i,n,e]);return{rInput:o,handleKeyDown:l,handleChange:c,isEmpty:a,...r}}function mT(n,e){return ie("isReadyForEditing",()=>{const t=n.getEditingShapeId();return t!==null&&(t===e||n.getHoveredShapeId()===e)},[n,e])}function i7(n){const e=te(),t=ie("isEditing",()=>e.getEditingShapeId()===n,[e]),r=mT(e,n),s=P.useCallback(i=>{e.dispatch({...Ks(i),type:"pointer",name:"pointer_down",target:"shape",shape:e.getShape(n)}),Wt(i)},[e,n]);return{handleFocus:np,handleBlur:np,handleInputPointerDown:s,handleDoubleClick:Wt,isEditing:t,isReadyForEditing:r}}const cye=at.memo(function({shapeId:e,type:t,text:r,labelColor:s,font:i,fontSize:o,lineHeight:a,align:l,verticalAlign:c,wrap:u,isSelected:h,padding:p=0,onKeyDown:m,classNamePrefix:S,style:x,textWidth:v,textHeight:w}){const{rInput:C,isEmpty:_,isEditing:E,isReadyForEditing:T,...A}=lye(e,t,r),O=g0.normalizeTextForDom(r||""),D=O.length>0,$=s7(l);if(!E&&!D)return null;const H=S||"tl-text";return g.jsx("div",{className:`${H}-label tl-text-wrapper tl-plain-text-wrapper`,"data-font":i,"data-align":l,"data-hastext":!_,"data-isediting":E,"data-is-ready-for-editing":T,"data-textwrap":!!u,"data-isselected":h,style:{justifyContent:l==="middle"||$?"center":l,alignItems:c==="middle"?"center":c,padding:p,...x},children:g.jsxs("div",{className:`${H}-label__inner tl-text-content__wrapper`,style:{fontSize:o,lineHeight:Math.floor(o*a)+"px",minHeight:Math.floor(o*a)+"px",minWidth:Math.ceil(v||0),color:s,width:v?Math.ceil(v):void 0,height:w?Math.ceil(w):void 0},children:[g.jsx("div",{className:`${H} tl-text tl-text-content`,dir:"auto",children:O.split(`
|
|
462
|
-
`).map((G,J)=>g.jsx("div",{dir:"auto",children:G},J))}),(T||h)&&g.jsx(oye,{ref:C,text:r,isEditing:E,shapeId:e,...A,handleKeyDown:m??A.handleKeyDown})]})})});function Mi(){return Va({isDarkMode:eg()})}function yT(n){return{key:`${Na.id}:${n}`,async getElement(){return n!=="pattern"?null:g.jsx(uye,{})}}}function uye(){const n=vT(),e=vu(),t=Mi(),r=8/12;return g.jsxs(g.Fragment,{children:[g.jsxs("mask",{id:e,children:[g.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),g.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[g.jsx("line",{x1:r*1,y1:r*3,x2:r*3,y2:r*1}),g.jsx("line",{x1:r*5,y1:r*7,x2:r*7,y2:r*5}),g.jsx("line",{x1:r*9,y1:r*11,x2:r*11,y2:r*9})]})]}),g.jsx("pattern",{id:n(1,t.id),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:g.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:t.solid,mask:`url(#${e})`})})]})}function ST(){return{key:`${Na.id}:pattern`,component:pye}}const Of=8,rN=(n,e,t)=>new Promise((r,s)=>{const i=Of*e*n,o=document.createElement("canvas");o.width=i,o.height=i;const a=o.getContext("2d");if(!a)return;a.fillStyle=t?yS.darkMode.solid:yS.lightMode.solid,a.fillRect(0,0,i,i),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*e*n;const l=8/12,c=u=>u*e*n;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(),o.toBlob(u=>{!u||ln.throwToBlob.get()?s():r(u)})}),sN=(n,e)=>{const t=document.createElement("canvas");t.width=n[0],t.height=n[1];const r=t.getContext("2d");return r?(e(r),t.toDataURL()):""};let QC=null;function dye(){return QC||(QC={white:sN([1,1],n=>{n.fillStyle="#f8f9fa",n.fillRect(0,0,1,1)}),black:sN([1,1],n=>{n.fillStyle="#212529",n.fillRect(0,0,1,1)})}),QC}function o7(n){return Math.ceil(Math.log2(Math.max(1,n)))}function vT(){const n=Qi("hash_pattern");return P.useCallback((e,t)=>{const r=o7(e);return $E(n,`${t}_${r}`)},[n])}function a7(n){const e=[],r=o7(n);for(let s=0;s<=r;s++)e.push(Math.pow(2,s));return e}function hye(n){const e=dye();return a7(n).flatMap(t=>[{zoom:t,url:e.white,theme:"light"},{zoom:t,url:e.black,theme:"dark"}])}function fye(){const n=te(),e=ie("devicePixelRatio",()=>n.getInstanceState().devicePixelRatio,[n]),t=ie("maxZoom",()=>Math.ceil(tr(n.getCameraOptions().zoomSteps)),[n]),[r,s]=P.useState(!1),[i,o]=P.useState(()=>hye(t)),a=vT();return P.useEffect(()=>{const c=Promise.all(a7(t).flatMap(h=>[rN(e,h,!1).then(p=>({zoom:h,theme:"light",url:URL.createObjectURL(p)})),rN(e,h,!0).then(p=>({zoom:h,theme:"dark",url:URL.createObjectURL(p)}))]));let u=!1;return c.then(h=>{u||(o(h),s(!0))}),()=>{u=!0,s(!1),c.then(h=>{for(const{url:p}of h)URL.revokeObjectURL(p)})}},[e,t]),{defs:g.jsx(g.Fragment,{children:i.map(c=>{const u=a(c.zoom,c.theme);return g.jsx("pattern",{id:u,width:Of,height:Of,patternUnits:"userSpaceOnUse",children:g.jsx("image",{href:c.url,width:Of,height:Of})},u)})}),isReady:r}}function pye(){const n=te(),e=P.useRef(null),{defs:t,isReady:r}=fye();return P.useEffect(()=>{if(r&&It.isSafari){const s=l7(e.current);s&&n.timers.requestAnimationFrame(()=>{s.style.display="none",n.timers.requestAnimationFrame(()=>{s.style.display=""})})}},[n,r]),g.jsx("g",{ref:e,"data-testid":r?"ready-pattern-fill-defs":void 0,children:t})}function l7(n){return n.classList.contains("tl-html-layer")?n:n.parentElement?l7(n.parentElement):null}const vr=at.memo(function({theme:e,d:t,color:r,fill:s,scale:i}){switch(s){case"none":return null;case"solid":return g.jsx("path",{fill:e[r].semi,d:t});case"semi":return g.jsx("path",{fill:e.solid,d:t});case"fill":return g.jsx("path",{fill:e[r].fill,d:t});case"pattern":return g.jsx(gye,{theme:e,color:r,fill:s,d:t,scale:i})}});function gye({d:n,color:e,theme:t}){const r=te(),s=Xp(),i=ie("zoomLevel",()=>r.getZoomLevel(),[r]),o=vT(),a=r.getZoomLevel()<=.18;return g.jsxs(g.Fragment,{children:[g.jsx("path",{fill:t[e].pattern,d:n}),g.jsx("path",{fill:s?`url(#${o(1,t.id)})`:a?t[e].semi:`url(#${o(i,t.id)})`,d:n})]})}function mye(n){return n.replace(/\s/g," ")}function rI(n,e,t){const{padding:r=0}=t;if(e.length===0)return null;const s=Se.From(e[0].box);for(const{box:c}of e)s.union(c);const i=r+(t.offsetX??0),o=(t.offsetY??0)+t.fontSize/2+(t.verticalTextAlign==="start"?r:t.verticalTextAlign==="end"?t.height-r-s.height:(Math.ceil(t.height)-s.height)/2);let a=null;const l=[];for(const{text:c,box:u}of e)a!==null&&u.y>a&&l.push(g.jsx("tspan",{alignmentBaseline:"mathematical",x:i,y:u.y+o,children:`
|
|
463
|
-
`},l.length)),l.push(g.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+i,y:u.y+o,unicodeBidi:"plaintext",children:mye(c)},l.length)),a=u.y;return g.jsx("text",{fontSize:t.fontSize,fontFamily:t.fontFamily,fontStyle:t.fontStyle,fontWeight:t.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,children:l})}function yye({fontSize:n,font:e,align:t,verticalAlign:r,text:s,labelColor:i,bounds:o,padding:a=16,stroke:l=!0}){const c=te(),u=Mi(),h={fontSize:n,fontFamily:d4[e],textAlign:t,verticalTextAlign:r,width:Math.ceil(o.width),height:Math.ceil(o.height),padding:a,lineHeight:ar.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:i,stroke:void 0,strokeWidth:void 0},p=c.textMeasure.measureTextSpans(s,h),m=aye(t,a,p,o.width);m&&(h.offsetX=m),h.offsetX+=o.x,h.offsetY+=o.y;const S=rI(c,p,h);let x=null;return l&&(h.fill=u.background,h.stroke=u.background,h.strokeWidth=2,x=rI(c,p,h)),g.jsxs(g.Fragment,{children:[x,S]})}const Sye=_E("arrow label size",(n,e)=>{n.fonts.trackFontsForShape(e);const t=Lo(n,e);let r=0,s=0;const i=t.isStraight?new Ia({start:k.From(t.start.point),end:k.From(t.end.point)}):new Id({center:k.Cast(t.handleArc.center),start:k.Cast(t.start.point),end:k.Cast(t.end.point),sweepFlag:t.bodyArc.sweepFlag,largeArcFlag:t.bodyArc.largeArcFlag});if(e.props.text.trim()){const o=i.bounds,a=sI(e),{w:l,h:c}=n.textMeasure.measureText(e.props.text,{...ar,fontFamily:Ba[e.props.font],fontSize:a,maxWidth:null});r=l,s=c;let u=!1;if(o.width>o.height?(r=Math.max(Math.min(l,64),Math.min(o.width-64,l)),u=!0):r>16*a&&(r=16*a,u=!0),u){const{w:h,h:p}=n.textMeasure.measureText(e.props.text,{...ar,fontFamily:Ba[e.props.font],fontSize:a,maxWidth:r});r=h,s=p}}return new k(r,s).addScalar(rT*2*e.props.scale)},{areRecordsEqual:(n,e)=>n.props===e.props});function xT(n,e){return e.props.text.trim()===""?new k(0,0).addScalar(rT*2*e.props.scale):Sye.get(n,e.id)??new k(0,0)}function c7(n){const e=Er[n.props.size];return(jpe+(e-Er.s)*2+(e===Er.xl?20:0))*n.props.scale}function vye(n,e,t){const r=xT(n,e),s=c7(e),i=k.Nudge(t.start.point,t.end.point,s),o=k.Nudge(t.end.point,t.start.point,s),a=VE(i,o,Se.FromCenter(t.middle,r).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[l,c]=a;k.Dist2(l,i)>k.Dist2(c,i)&&([c,l]=a);const u=i.add(k.Sub(t.middle,l)),h=o.add(k.Sub(t.middle,c)),p=k.Dist(t.start.point,u)/t.length,m=k.Dist(t.start.point,h)/t.length;return{start:p,end:m}}function xye(n,e,t){const r=xT(n,e),s=c7(e),i=Math.sign(e.props.bend),o=s/t.handleArc.radius*i,a=k.Angle(t.bodyArc.center,t.start.point)-o,l=k.Angle(t.bodyArc.center,t.end.point)+o,c=Xc(t.bodyArc.center,t.bodyArc.radius,a),u=Xc(t.bodyArc.center,t.bodyArc.radius,l),h=[],p=oN(t.bodyArc.center,t.bodyArc.radius,a,l,i,Se.FromCenter(c,r).corners);h.push(new Tn({points:Se.FromCenter(c,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const m=oN(t.bodyArc.center,t.bodyArc.radius,a,l,i,Se.FromCenter(u,r).corners);h.push(new Tn({points:Se.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const O of[...p??[],...m??[],c,u])h.push(new l_({x:O.x-3,y:O.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const S=(p&&aN(t.start.point,p))??t.middle,x=(m&&aN(t.end.point,m))??t.middle,v=k.Angle(t.bodyArc.center,t.start.point),w=k.Angle(t.bodyArc.center,t.end.point),C=k.Angle(t.bodyArc.center,S),_=k.Angle(t.bodyArc.center,x);if(Ml(v,C,i)>Ml(v,_,i))return{start:.5,end:.5,dbg:h};const E=Ml(v,w,i),T=Ml(v,C,i)/E,A=Ml(v,_,i)/E;return{start:T,end:A,dbg:h}}function Ey(n,e){let t;const r=[],s=Lo(n,e),i={hasStartBinding:!!s.bindings.start,hasEndBinding:!!s.bindings.end,hasStartArrowhead:s.start.arrowhead!=="none",hasEndArrowhead:s.end.arrowhead!=="none"};if(s.isStraight){const a=vye(n,e,s),l=iN(n,e,a,i);t=k.Lrp(s.start.point,s.end.point,l)}else{const a=xye(n,e,s);a.dbg&&r.push(...a.dbg);const l=iN(n,e,a,i),c=wye(k.Angle(s.bodyArc.center,s.start.point),k.Angle(s.bodyArc.center,s.end.point),Math.sign(e.props.bend),l);t=Xc(s.bodyArc.center,s.bodyArc.radius,c)}const o=xT(n,e);return{box:Se.FromCenter(t,o),debugGeom:r}}function iN(n,e,t,r){const{hasEndArrowhead:s,hasEndBinding:i,hasStartBinding:o,hasStartArrowhead:a}=r,l=f7(n,e);let c=Mn(e.props.labelPosition,a||o?t.start:0,s||i?t.end:1);const u=Math.min(.02,500/l*.02);return c=c>=.5-u&&c<=.5+u?.5:c,c}function oN(n,e,t,r,s,i){const o=oz(n,e,i),a=Ml(t,r,s);return o==null?void 0:o.filter(l=>{const c=Ml(t,k.Angle(n,l),s);return c>=0&&c<=a})}function aN(n,e){let t=null,r=-1/0;for(const s of e){const i=k.Dist2(n,s);i>r&&(t=s,r=i)}return t}function wye(n,e,t,r){const s=Ml(n,e,t);return n+s*r*t*-1}function sI(n){return Dpe[n.props.size]*n.props.scale}function bye(n,e,t){const r=e==="end"?n.end.point:n.start.point,s=e==="end"?n.start.point:n.end.point,i=n.isStraight?k.Dist(s,r):Math.abs(n.bodyArc.length),o=Math.max(Math.min(i/5,t*3),t);let a;if(n.isStraight)a=k.Nudge(r,s,o);else{const l=Sre(r,o,n.handleArc.center,n.handleArc.radius);a=e==="end"?n.handleArc.sweepFlag?l[0]:l[1]:n.handleArc.sweepFlag?l[1]:l[0]}return k.IsNaN(a)&&(a=n.start.point),{point:r,int:a}}function Cye({point:n,int:e}){const t=k.RotWith(e,n,wt/6),r=k.RotWith(e,n,-wt/6);return`M ${t.x} ${t.y} L ${n.x} ${n.y} L ${r.x} ${r.y}`}function Pye({point:n,int:e}){const t=k.RotWith(e,n,wt/6),r=k.RotWith(e,n,-wt/6);return`M ${t.x} ${t.y} L ${r.x} ${r.y} L ${n.x} ${n.y} Z`}function kye({point:n,int:e}){const t=k.Sub(e,n).div(2),r=k.Add(n,k.Rot(t,Kt)),s=k.Sub(n,k.Rot(t,Kt));return`M ${r.x} ${r.y} L ${e.x} ${e.y} L ${s.x} ${s.y} Z`}function Iye({point:n,int:e}){const t=k.Lrp(n,e,.45),r=k.Dist(t,n);return`M ${t.x-r},${t.y}
|
|
464
|
-
a ${r},${r} 0 1,0 ${r*2},0
|
|
465
|
-
a ${r},${r} 0 1,0 -${r*2},0 `}function Eye({point:n,int:e}){const t=k.Lrp(n,e,.75),r=k.RotWith(t,n,wt/4),s=k.RotWith(t,n,-wt/4),i=k.Lrp(r,s,.5);return i.add(k.Sub(i,n)),`M ${i.x} ${i.y} L ${s.x} ${s.y} ${n.x} ${n.y} L ${r.x} ${r.y} Z`}function _ye({int:n,point:e}){const t=k.Lrp(e,n,.85),r=k.Sub(t,e).div(2),s=k.Add(e,k.Rot(r,Kt)),i=k.Sub(e,k.Rot(r,Kt)),o=k.Add(t,k.Rot(r,Kt)),a=k.Sub(t,k.Rot(r,Kt));return`M ${s.x} ${s.y} L ${o.x} ${o.y} L ${a.x} ${a.y} L ${i.x} ${i.y} Z`}function Tye({int:n,point:e}){const t=k.Sub(n,e).div(2),r=k.Add(e,k.Rot(t,Kt)),s=k.Sub(e,k.Rot(t,Kt));return`M ${r.x} ${r.y} L ${s.x} ${s.y}`}function m0(n,e,t){const r=e==="end"?n.end.arrowhead:n.start.arrowhead;if(r==="none")return;const s=bye(n,e,t);if(s){switch(r){case"bar":return Tye(s);case"square":return _ye(s);case"diamond":return Eye(s);case"dot":return Iye(s);case"inverted":return kye(s);case"arrow":return Cye(s);case"triangle":return Pye(s)}return""}}function Mye(n){const{start:e,end:t,handleArc:{radius:r,largeArcFlag:s,sweepFlag:i}}=n;return`M${e.handle.x},${e.handle.y} A${r} ${r} 0 ${s} ${i} ${t.handle.x},${t.handle.y}`}function u7(n){const{start:e,end:t,bodyArc:{radius:r,largeArcFlag:s,sweepFlag:i}}=n;return`M${e.point.x},${e.point.y} A${r} ${r} 0 ${s} ${i} ${t.point.x},${t.point.y}`}function d7(n,e){return`M${n.x},${n.y}L${e.x},${e.y}`}function Aye(n){return d7(n.start.handle,n.end.handle)}function h7(n){return d7(n.start.point,n.end.point)}class _y extends eo{constructor(){super(...arguments);R(this,"_resizeInitialBindings",new qo)}canEdit(){return!0}canBind({toShapeType:t}){return t!=="arrow"}canSnap(){return!1}canTabTo(t){const r=Hr(this.editor,t);return!!(r.start||r.end||t.props.text)}hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsBg(){return!0}hideSelectionBoundsFg(){return!0}canBeLaidOut(t,r){if(r.type==="flip"){const s=Hr(this.editor,t),{start:i,end:o}=s,{shapes:a=[]}=r;if(i&&!a.find(l=>l.id===i.toId)||o&&!a.find(l=>l.id===o.toId))return!1}return!0}getFontFaces(t){return t.props.text?[fT[`tldraw_${t.props.font}`].normal.normal]:kr}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(t){const r=Lo(this.editor,t),s=[],i=r.isStraight?new Ia({start:k.From(r.start.point),end:k.From(r.end.point)}):new Id({center:k.Cast(r.handleArc.center),start:k.Cast(r.start.point),end:k.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});let o;if(t.props.text.trim()){const a=Ey(this.editor,t);ln.debugGeometry.get()&&s.push(...a.debugGeom),o=new Ho({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new Js({children:[...o?[i,o]:[i],...s]})}getHandles(t){const r=Lo(this.editor,t);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(t){return t.props.text}onHandleDrag(t,{handle:r,isPrecise:s}){const i=r.id,o=Hr(this.editor,t);if(i==="middle"){const{start:A,end:O}=Ed(this.editor,t,o),D=k.Sub(O,A),$=k.Per(D),H=k.Med(O,A),G=k.Sub(H,$),J=k.Add(H,$),L=k.NearestPointOnLineSegment(G,J,r,!1);let N=k.Dist(L,H);return k.Clockwise(L,O,H)&&(N*=-1),{id:t.id,type:t.type,props:{bend:N}}}const a={id:t.id,type:"arrow",props:{}},l=o[i],u=o[i==="start"?"end":"start"];if(this.editor.inputs.ctrlKey)return Cy(this.editor,t,i),a.props[i]={x:r.x,y:r.y},a;const h=this.editor.getShapePageTransform(t.id).applyToPoint(r),p=this.editor.getShapeAtPoint(h,{hitInside:!0,hitFrameInside:!0,margin:0,filter:A=>!A.isLocked&&this.editor.canBindShapes({fromShape:t,toShape:A,binding:"arrow"})});if(!p){Cy(this.editor,t,i);const A=ro(new k(r.x,r.y),this.editor);return a.props[i]={x:A.x,y:A.y},a}const m=this.editor.getShapeGeometry(p),S=Se.ZeroFix(m.bounds),v=this.editor.getShapePageTransform(a.id).applyToPoint(r),w=this.editor.getPointInShapeSpace(p,v);let C=s;C||(!l||l&&p.id!==l.toId)&&(C=this.editor.inputs.pointerVelocity.len()<.5),s||(m.isClosed||(C=!0),u&&p.id===u.toId&&u.props.isPrecise&&(C=!0));const _={x:(w.x-S.minX)/S.width,y:(w.y-S.minY)/S.height};C&&k.Dist(w,S.center)<Math.max(4,Math.min(Math.min(S.width,S.height)*.15,16))/this.editor.getZoomLevel()&&(_.x=.5,_.y=.5);const E={terminal:i,normalizedAnchor:_,isPrecise:C,isExact:this.editor.inputs.altKey};hf(this.editor,t,p.id,E),this.editor.setHintingShapes([p.id]);const T=Hr(this.editor,t);return T.start&&T.end&&T.start.toId===T.end.toId&&k.Equals(T.start.props.normalizedAnchor,T.end.props.normalizedAnchor)&&hf(this.editor,t,T.end.toId,{...T.end.props,normalizedAnchor:{x:T.end.props.normalizedAnchor.x+.05,y:T.end.props.normalizedAnchor.y}}),a}onTranslateStart(t){const r=Hr(this.editor,t),s=Ed(this.editor,t,r),i=this.editor.getShapePageTransform(t.id),o=this.editor.getSelectedShapeIds();if(!(r.start&&(o.includes(r.start.toId)||this.editor.isAncestorSelected(r.start.toId))||r.end&&(o.includes(r.end.toId)||this.editor.isAncestorSelected(r.end.toId)))){cN.set(t,{pagePosition:i.applyToPoint(t),terminalBindings:rh(s,(a,l)=>{const c=r[a];return c?{binding:c,shapePosition:l,pagePosition:i.applyToPoint(l)}:null})}),r.start&&(zS({editor:this.editor,arrow:t,terminal:"start",useHandle:!0}),t=this.editor.getShape(t.id)),r.end&&zS({editor:this.editor,arrow:t,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(t,r){const s=cN.get(t);if(!s)return;const i=this.editor.getShapePageTransform(r.id),o=k.Sub(i.applyToPoint(r),s.pagePosition);for(const a of Object.values(s.terminalBindings)){if(!a)continue;const l=k.Add(a.pagePosition,k.Mul(o,.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=Se.ZeroFix(this.editor.getShapeGeometry(c).bounds),h=this.editor.getPointInShapeSpace(c,l),p={x:(h.x-u.minX)/u.width,y:(h.y-u.minY)/u.height};hf(this.editor,r,c.id,{...a.binding.props,normalizedAnchor:p,isPrecise:!0})}else Cy(this.editor,r,a.binding.props.terminal)}}onResize(t,r){const{scaleX:s,scaleY:i}=r,o=this._resizeInitialBindings.get(t,()=>Hr(this.editor,t)),a=Ed(this.editor,t,o),{start:l,end:c}=Xt(t.props);let{bend:u}=t.props;o.start||(l.x=a.start.x*s,l.y=a.start.y*i),o.end||(c.x=a.end.x*s,c.y=a.end.y*i);const h=Math.abs(s),p=Math.abs(i),m=o!=null&&o.start?k.From(o.start.props.normalizedAnchor):null,S=o!=null&&o.end?k.From(o.end.props.normalizedAnchor):null;return s<0&&i>=0?(u!==0&&(u*=-1,u*=Math.max(h,p)),m&&(m.x=1-m.x),S&&(S.x=1-S.x)):s>=0&&i<0?(u!==0&&(u*=-1,u*=Math.max(h,p)),m&&(m.y=1-m.y),S&&(S.y=1-S.y)):s>=0&&i>=0?u!==0&&(u*=Math.max(h,p)):s<0&&i<0&&(u!==0&&(u*=Math.max(h,p)),m&&(m.x=1-m.x,m.y=1-m.y),S&&(S.x=1-S.x,S.y=1-S.y)),o.start&&m&&hf(this.editor,t,o.start.toId,{...o.start.props,normalizedAnchor:m.toJson()}),o.end&&S&&hf(this.editor,t,o.end.toId,{...o.end.props,normalizedAnchor:S.toJson()}),{props:{start:l,end:c,bend:u}}}onDoubleClickHandle(t,r){switch(r.id){case"start":return{id:t.id,type:t.type,props:{...t.props,arrowheadStart:t.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:t.id,type:t.type,props:{...t.props,arrowheadEnd:t.props.arrowheadEnd==="none"?"arrow":"none"}}}}component(t){const r=Mi(),s=this.editor.getOnlySelectedShape(),i=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getIsReadonly(),o=Lo(this.editor,t);if(!(o!=null&&o.isValid))return null;const a=Ey(this.editor,t),l=t.id===this.editor.getOnlySelectedShapeId(),u=this.editor.getEditingShapeId()===t.id||t.props.text;return g.jsxs(g.Fragment,{children:[g.jsx(Gl,{style:{minWidth:50,minHeight:50},children:g.jsx(lN,{shape:t,shouldDisplayHandles:i&&(s==null?void 0:s.id)===t.id})}),u&&g.jsx(cye,{shapeId:t.id,classNamePrefix:"tl-arrow",type:"arrow",font:t.props.font,fontSize:sI(t),lineHeight:ar.lineHeight,align:"middle",verticalAlign:"middle",text:t.props.text,labelColor:r[t.props.labelColor].solid,textWidth:a.box.w-rT*2*t.props.scale,isSelected:l,padding:0,style:{transform:`translate(${a.box.center.x}px, ${a.box.center.y}px)`}})]})}indicator(t){const r=dv(t.id),s=Qi(t.id+"_clip"),i=Lo(this.editor,t);if(!i)return null;const{start:o,end:a}=Ed(this.editor,t,i==null?void 0:i.bindings),l=this.editor.getShapeGeometry(t),c=l.bounds,u=t.props.text.trim()?l.children[1]:null;if(k.Equals(o,a))return null;const h=Er[t.props.size]*t.props.scale,p=i.start.arrowhead&&m0(i,"start",h),m=i.end.arrowhead&&m0(i,"end",h),S=i.isStraight?h7(i):u7(i),x=p&&i.start.arrowhead!=="arrow"||m&&i.end.arrowhead!=="arrow"||!!u;if(r&&u)return g.jsx("rect",{x:re(u.x),y:re(u.y),width:u.w,height:u.h,rx:3.5*t.props.scale,ry:3.5*t.props.scale});const v=!(i.start.arrowhead==="none"||i.start.arrowhead==="arrow"),w=!(i.end.arrowhead==="none"||i.end.arrowhead==="arrow");return g.jsxs("g",{children:[x&&g.jsx("defs",{children:g.jsx(p7,{hasText:t.props.text.trim().length>0,bounds:c,labelBounds:u?u.getBounds():new Se(0,0,0,0),as:v&&p?p:"",ae:w&&m?m:""})}),g.jsxs("g",{style:{clipPath:x?`url(#${s})`:void 0,WebkitClipPath:x?`url(#${s})`:void 0},children:[x&&g.jsx("rect",{x:c.minX-100,y:c.minY-100,width:c.width+200,height:c.height+200,opacity:0}),g.jsx("path",{d:S})]}),p&&g.jsx("path",{d:p}),m&&g.jsx("path",{d:m}),u&&g.jsx("rect",{x:re(u.x),y:re(u.y),width:u.w,height:u.h,rx:3.5,ry:3.5})]})}onEditEnd(t){const{id:r,type:s,props:{text:i}}=t;i.trimEnd()!==t.props.text&&this.editor.updateShapes([{id:r,type:s,props:{text:i.trimEnd()}}])}toSvg(t,r){r.addExportDef(yT(t.props.fill));const s=Va(r),i=1/t.props.scale;return g.jsxs("g",{transform:`scale(${i})`,children:[g.jsx(lN,{shape:t,shouldDisplayHandles:!1}),g.jsx(yye,{fontSize:sI(t),font:t.props.font,align:"middle",verticalAlign:"middle",text:t.props.text,labelColor:s[t.props.labelColor].solid,bounds:Ey(this.editor,t).box.clone().expandBy(-4.25*t.props.scale),padding:0})]})}getCanvasSvgDefs(){return[ST(),{key:"arrow:dot",component:Oye},{key:"arrow:cross",component:Rye}]}getInterpolatedProps(t,r,s){return{...s>.5?r.props:t.props,scale:yt(t.props.scale,r.props.scale,s),start:{x:yt(t.props.start.x,r.props.start.x,s),y:yt(t.props.start.y,r.props.start.y,s)},end:{x:yt(t.props.end.x,r.props.end.x,s),y:yt(t.props.end.y,r.props.end.y,s)},bend:yt(t.props.bend,r.props.bend,s),labelPosition:yt(t.props.labelPosition,r.props.labelPosition,s)}}}R(_y,"type","arrow"),R(_y,"props",f4),R(_y,"migrations",p4);function f7(n,e){const t=Lo(n,e);return t.isStraight?k.Dist(t.start.handle,t.end.handle):Math.abs(t.handleArc.length)}const lN=Yn(function({shape:e,shouldDisplayHandles:t}){const r=te(),s=Mi(),i=Lo(r,e),o=Se.ZeroFix(r.getShapeGeometry(e).bounds),a=Hr(r,e),l=ie("force solid",()=>r.getZoomLevel()<.2,[r]),c=Qi(e.id+"_clip"),u=Qi("arrowhead-dot"),h=Qi("arrowhead-cross");if(!(i!=null&&i.isValid))return null;const p=Er[e.props.size]*e.props.scale,m=i.start.arrowhead&&m0(i,"start",p),S=i.end.arrowhead&&m0(i,"end",p),x=i.isStraight?h7(i):u7(i);let v=null;if(t){const A=2/r.getZoomLevel(),{strokeDasharray:O,strokeDashoffset:D}=Wi(f7(r,e),A,{end:"skip",start:"skip",lengthRatio:2.5});v=a.start||a.end?g.jsx("path",{className:"tl-arrow-hint",d:i.isStraight?Aye(i):Mye(i),strokeDasharray:O,strokeDashoffset:D,strokeWidth:A,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:w,strokeDashoffset:C}=Wi(i.isStraight?i.length:Math.abs(i.bodyArc.length),p,{style:e.props.dash,forceSolid:l}),_=Ey(r,e),E=!(i.start.arrowhead==="none"||i.start.arrowhead==="arrow"),T=!(i.end.arrowhead==="none"||i.end.arrowhead==="arrow");return g.jsxs(g.Fragment,{children:[g.jsx("defs",{children:g.jsx("clipPath",{id:c,children:g.jsx(p7,{hasText:e.props.text.trim().length>0,bounds:o,labelBounds:_.box,as:E&&m?m:"",ae:T&&S?S:""})})}),g.jsxs("g",{fill:"none",stroke:s[e.props.color].solid,strokeWidth:p,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[v,g.jsxs("g",{style:{clipPath:`url(#${c})`,WebkitClipPath:`url(#${c})`},children:[g.jsx("rect",{x:re(o.minX-100),y:re(o.minY-100),width:re(o.width+200),height:re(o.height+200),opacity:0}),g.jsx("path",{d:x,strokeDasharray:w,strokeDashoffset:C})]}),m&&E&&e.props.fill!=="none"&&g.jsx(vr,{theme:s,d:m,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),S&&T&&e.props.fill!=="none"&&g.jsx(vr,{theme:s,d:S,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),m&&g.jsx("path",{d:m}),S&&g.jsx("path",{d:S})]})]})});function p7({hasText:n,bounds:e,labelBounds:t,as:r,ae:s}){const i=`M${re(e.minX-100)},${re(e.minY-100)} h${e.width+200} v${e.height+200} h-${e.width+200} Z`,o=`M${re(t.minX)},${re(t.minY)} v${t.height} h${t.width} v-${t.height} Z`;return g.jsx("path",{d:`${i}${n?o:""}${r}${s}`})}const cN=new WeakMap;function Oye(){const n=Qi("arrowhead-dot");return g.jsx("marker",{id:n,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:g.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function Rye(){const n=Qi("arrowhead-cross");return g.jsxs("marker",{id:n,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[g.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),g.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const uN="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 Qd({url:n}){const e=te(),t=ie("zoomLevel",()=>e.getZoomLevel()<.32,[e]);return g.jsx("a",{className:$e("tl-hyperlink-button",{"tl-hyperlink-button__hidden":t}),href:n,target:"_blank",rel:"noopener noreferrer",onPointerDown:Wt,onPointerUp:Wt,title:n,draggable:!1,children:g.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${uN}") center 100% / 100% no-repeat`,WebkitMask:`url("${uN}") center 100% / 100% no-repeat`}})})}const dN="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",Dye=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function y0(n){return Dye.map(t=>{const{offsetX:r,offsetY:s,blur:i,spread:o,color:a}=t,l=new k(r,s),{x:c,y:u}=l.rot(-n);return`${c}px ${u}px ${i}px ${o}px ${a}`}).join(", ")}const jye=300,g7=320,Lye=46,Nye=101;class Ty extends gh{canResize(){return!1}hideSelectionBoundsFg(){return!0}getText(e){return e.props.url}getAriaDescriptor(e){const t=e.props.assetId?this.editor.getAsset(e.props.assetId):null;if(t!=null&&t.props.title)return qU(t.props.title)+(t.props.description?", "+t.props.description:"")}getDefaultProps(){return{url:"",w:jye,h:g7,assetId:null}}component(e){return g.jsx(Fye,{shape:e,util:this})}indicator(e){return g.jsx("rect",{width:re(e.props.w),height:re(e.props.h),rx:"6",ry:"6"})}onBeforeCreate(e){return hN(this.editor,e)}onBeforeUpdate(e,t){if(e.props.url!==t.props.url)if(Zs.isValid(t.props.url))$ye(this.editor,t);else return{...t,props:{...t.props,url:e.props.url}};if(e.props.assetId!==t.props.assetId)return hN(this.editor,t)}getInterpolatedProps(e,t,r){return{...r>.5?t.props:e.props,w:yt(e.props.w,t.props.w,r),h:yt(e.props.h,t.props.h,r)}}}R(Ty,"type","bookmark"),R(Ty,"props",x4),R(Ty,"migrations",w4);function Fye({shape:n,util:e}){const t=n.props.assetId?e.editor.getAsset(n.props.assetId):null,r=!!Xp()&&It.isSafari,s=e.editor.getShapePageTransform(n).rotation(),i=zye(n),[o,a]=P.useState(!0),l=()=>a(!1);return g.jsx(Ul,{children:g.jsxs("div",{className:$e("tl-bookmark__container",r&&"tl-bookmark__container--safariExport"),style:{boxShadow:r?void 0:y0(s),maxHeight:n.props.h},children:[(!t||t.props.image)&&g.jsxs("div",{className:"tl-bookmark__image_container",children:[t?g.jsx("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:t==null?void 0:t.props.image,alt:(t==null?void 0:t.props.title)||""}):g.jsx("div",{className:"tl-bookmark__placeholder"}),(t==null?void 0:t.props.image)&&g.jsx(Qd,{url:n.props.url})]}),g.jsxs("div",{className:"tl-bookmark__copy_container",children:[t!=null&&t.props.title?g.jsx("h2",{className:"tl-bookmark__heading",children:qU(t.props.title)}):null,t!=null&&t.props.description&&(t!=null&&t.props.image)?g.jsx("p",{className:"tl-bookmark__description",children:t.props.description}):null,g.jsxs("a",{className:"tl-bookmark__link",href:n.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:Wt,onPointerUp:Wt,onClick:Wt,children:[o&&(t!=null&&t.props.favicon)?g.jsx("img",{className:"tl-bookmark__favicon",src:t==null?void 0:t.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",onError:l,alt:`favicon of ${i}`}):g.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${dN}") center 100% / 100% no-repeat`,WebkitMask:`url("${dN}") center 100% / 100% no-repeat`}}),g.jsx("span",{children:i})]})]})]})})}function hN(n,e){const t=e.props.assetId?n.getAsset(e.props.assetId):null;let r=g7;return t&&(t.props.image||(t.props.title?r=Nye:r=Lye)),{...e,props:{...e.props,h:r}}}const zye=n=>{try{return new URL(n.props.url).hostname.replace(/^www\./,"")}catch{return n.props.url}};function $ye(n,e){const{url:t}=e.props,r=ql.createId(CI(t));n.getAsset(r)?e.props.assetId!==r&&n.updateShapes([{id:e.id,type:e.type,props:{assetId:r}}]):(n.updateShapes([{id:e.id,type:e.type,props:{assetId:null}}]),Bye(n,e))}const Bye=x0(async(n,e)=>{if(n.isDisposed)return;const{url:t}=e.props,r=await n.getAssetForExternalContent({type:"url",url:t});r&&n.run(()=>{n.createAssets([r]),n.updateShapes([{id:e.id,type:e.type,props:{assetId:r.id}}])})},500);function uu(n,e=!1){const t=n.length;if(t<2)return"";let r=n[0].point,s=n[1].point;if(t===2)return`M${Ct(r)}L${Ct(s)}`;let i="";for(let o=2,a=t-1;o<a;o++)r=n[o].point,s=n[o+1].point,i+=bs(r,s);return e?`M${bs(n[0].point,n[1].point)}Q${Ct(n[1].point)}${bs(n[1].point,n[2].point)}T${i}${bs(n[t-1].point,n[0].point)}${bs(n[0].point,n[1].point)}Z`:`M${Ct(n[0].point)}Q${Ct(n[1].point)}${bs(n[1].point,n[2].point)}${n.length>3?"T":""}${i}L${Ct(n[t-1].point)}`}function Uye(n,e={}){const{start:t={},end:r={}}=e,{cap:s=!0}=t,{cap:i=!0}=r;Je(!t.taper&&!r.taper,"cap taper not supported here"),Je(!t.easing&&!r.easing,"cap easing not supported here"),Je(s&&i,"cap must be true");const o=Vo(n,e);Rv(o,e);const a=Hye(o);let l="";for(const c of a)l+=Wye(c,e);return l}function Hye(n){if(n.length<=2)return[n];const e=[];let t=[n[0]],r=k.Sub(n[1].point,n[0].point).uni(),s,i,o,a,l;for(let c=1,u=n.length;c<u-1;c++){if(o=n[c-1],a=n[c],l=n[c+1],s=k.Sub(l.point,a.point).uni(),i=k.Dpr(r,s),r=s,i<-.8){const h={...a,point:a.input};t.push(h),e.push(eP(t)),t=[h];continue}if(t.push(a),!(i>.7)&&(k.Dist2(o.point,a.point)+k.Dist2(a.point,l.point))/((o.radius+a.radius+l.radius)/3)**2<1.5){t.push(a),e.push(eP(t)),t=[a];continue}}return t.push(n[n.length-1]),e.push(eP(t)),e}function eP(n){const e=n[0];let t;for(;n.length>2&&(t=n[1],k.Dist2(e.point,t.point)<((e.radius+t.radius)/2*.5)**2);)n.splice(1,1);const r=n[n.length-1];let s;for(;n.length>2&&(s=n[n.length-2],k.Dist2(r.point,s.point)<((r.radius+s.radius)/2*.5)**2);)n.splice(n.length-2,1);return n.length>1&&(n[0]={...n[0],vector:k.Sub(n[0].point,n[1].point).uni()},n[n.length-1]={...n[n.length-1],vector:k.Sub(n[n.length-2].point,n[n.length-1].point).uni()}),n}function Kye(n,e,t){return"M "+n+" "+e+" m -"+t+", 0 a "+t+","+t+" 0 1,1 "+t*2+",0 a "+t+","+t+" 0 1,1 -"+t*2+",0"}function Wye(n,e={}){if(n.length===0)return"";if(n.length===1)return Kye(n[0].point.x,n[0].point.y,n[0].radius);const{left:t,right:r}=IU(n,e);r.reverse();let s=`M${Ct(t[0])}T`;for(let i=1;i<t.length;i++)s+=bs(t[i-1],t[i]);{const i=n[n.length-1],o=i.radius,a=i.vector.clone().per().neg(),l=k.Add(i.point,k.Mul(a,o)),c=k.Add(i.point,k.Mul(a,-o));s+=`${Ct(l)}A${re(o)},${re(o)} 0 0 1 ${Ct(c)}T`}for(let i=1;i<r.length;i++)s+=bs(r[i-1],r[i]);{const i=n[0],o=i.radius,a=i.vector.clone().per(),l=k.Add(i.point,k.Mul(a,o)),c=k.Add(i.point,k.Mul(a,-o));s+=`${Ct(l)}A${re(o)},${re(o)} 0 0 1 ${Ct(c)}Z`}return s}const m7=(n,e,t)=>{const r=[],s=[];n.forEach(c=>r.push(...c.points)),e.forEach(c=>s.push(...c.points));const i=Math.max(r.length,s.length),o=[],a=[];for(let c=0;c<i;c++)o.push(r[c]||r[r.length-1]),a.push(s[c]||s[s.length-1]);return[{type:"free",points:o.map((c,u)=>{let h=.5;return a[u].z!==void 0&&c.z!==void 0&&(h=yt(c.z,a[u].z,t)),{x:yt(c.x,a[u].x,t),y:yt(c.y,a[u].y,t),z:h}})}]},Vye=n=>n*.65+LG(n*wt/2)*.35,qye=n=>({size:n,thinning:.5,streamline:zd(n,[9,16],[.64,.74],!0),smoothing:.62,easing:Hn.easeOutSine,simulatePressure:!0}),Gye=n=>({size:1+n*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:Vye}),fN=n=>({size:n,thinning:0,streamline:zd(n,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:Hn.linear}),Yye=n=>({size:n,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:Hn.linear});function wT({strokeWidth:n,showAsComplete:e}){return{size:1+n,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:Hn.easeOutSine,last:e}}function iI(n,e,t,r){const s=n.isComplete||t;return r?n.isPen?{...Yye(e),last:s}:{...fN(e),last:s}:n.dash==="draw"?n.isPen?{...Gye(e),last:s}:{...qye(e),last:s}:{...fN(e),last:s}}function eh(n){const e=[];for(const t of n)if(t.type==="free"||t.points.length<2)e.push(...t.points.map(k.Cast));else{const r=Math.max(4,Math.floor(k.Dist(t.points[0],t.points[1])/16));e.push(...k.PointsBetween(t.points[0],t.points[1],r))}return e}function Xye(n,e,t){return{draw:"none",solid:"none",dotted:`${t} ${e*2}`,dashed:`${e*2} ${e*2}`}[n.props.dash]}class My extends eo{constructor(){super(...arguments);R(this,"options",{maxPointsPerShape:600})}canTabTo(){return!1}hideResizeHandles(t){return tP(t)}hideRotateHandle(t){return tP(t)}hideSelectionBoundsFg(t){return tP(t)}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1}}getGeometry(t){const r=eh(t.props.segments),s=(Er[t.props.size]+1)*t.props.scale;if(t.props.segments.length===1){const o=Se.FromPoints(r);if(o.width<s*2&&o.height<s*2)return new l_({x:-s,y:-s,radius:s,isFilled:!0})}const i=Vo(r,iI(t.props,s,t.props.isPen,!0)).map(o=>o.point);return t.props.isClosed?new Tn({points:i,isFilled:t.props.fill!=="none"}):new Yp({points:i})}component(t){return g.jsx(Gl,{children:g.jsx(pN,{shape:t})})}indicator(t){var u;const r=eh(t.props.segments);let s=(Er[t.props.size]+1)*t.props.scale;!ie("force solid",()=>{const h=this.editor.getZoomLevel();return h<.5&&h<1.5/s},[this.editor,s])&&!t.props.isPen&&t.props.dash==="draw"&&r.length===1&&(s+=oo(t.id)()*(s/6));const o=t.props.isComplete||((u=tr(t.props.segments))==null?void 0:u.type)==="straight",a=iI(t.props,s,o,!0),l=Vo(r,a),c=l.length>1?uu(l,t.props.isClosed):y7(r[0],s);return g.jsx("path",{d:c})}toSvg(t,r){r.addExportDef(yT(t.props.fill));const s=1/t.props.scale;return g.jsx("g",{transform:`scale(${s})`,children:g.jsx(pN,{shape:t,zoomOverride:1})})}getCanvasSvgDefs(){return[ST()]}onResize(t,r){const{scaleX:s,scaleY:i}=r,o=[];for(const a of t.props.segments)o.push({...a,points:a.points.map(({x:l,y:c,z:u})=>({x:Ca(s*l),y:Ca(i*c),z:u}))});return{props:{segments:o}}}expandSelectionOutlinePx(t){const r=t.props.dash==="draw"?1.6:1;return Er[t.props.size]*r/2*t.props.scale}getInterpolatedProps(t,r,s){return{...s>.5?r.props:t.props,segments:m7(t.props.segments,r.props.segments,s),scale:yt(t.props.scale,r.props.scale,s)}}}R(My,"type","draw"),R(My,"props",C4),R(My,"migrations",P4);function y7(n,e){const t=(e+1)*.5;return`M ${n.x} ${n.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function tP(n){return n.props.segments.length===1&&n.props.segments[0].points.length<2}function pN({shape:n,zoomOverride:e}){var m;const t=Mi(),r=te(),s=eh(n.props.segments),i=n.props.isComplete||((m=tr(n.props.segments))==null?void 0:m.type)==="straight";let o=(Er[n.props.size]+1)*n.props.scale;const a=ie("force solid",()=>{const S=e??r.getZoomLevel();return S<.5&&S<1.5/o},[r,o,e]),l=ie("dot adjustment",()=>(e??r.getZoomLevel())<.2?0:.1,[r,e]);!a&&!n.props.isPen&&n.props.dash==="draw"&&s.length===1&&(o+=oo(n.id)()*(o/6));const c=iI(n.props,o,i,a);if(!a&&n.props.dash==="draw")return g.jsxs(g.Fragment,{children:[n.props.isClosed&&n.props.fill&&s.length>1?g.jsx(vr,{d:uu(Vo(s,c),n.props.isClosed),theme:t,color:n.props.color,fill:n.props.isClosed?n.props.fill:"none",scale:n.props.scale}):null,g.jsx("path",{d:Uye(s,c),strokeLinecap:"round",fill:t[n.props.color].solid})]});const u=Vo(s,c),h=u.length<2,p=h?y7(s[0],0):uu(u,n.props.isClosed);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{d:p,theme:t,color:n.props.color,fill:h||n.props.isClosed?n.props.fill:"none",scale:n.props.scale}),g.jsx("path",{d:p,strokeLinecap:"round",fill:h?t[n.props.color].solid:"none",stroke:t[n.props.color].solid,strokeWidth:o,strokeDasharray:h?"none":Xye(n,o,l),strokeDashoffset:"0"})]})}function Zye(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Jye(n,e){const t=Ze(e);if(!t)return;const r=t.host.replace("www.","");for(const s of n)if(S7(s.hostnames,r)){const i=s.fromEmbedUrl(e);if(i)return{definition:s,url:i,embedUrl:e}}}const Qye=n=>n.split("*").map(e=>Zye(e)).join(".+"),S7=(n,e)=>!!n.find(t=>{const r=new RegExp(Qye(t));return e.match(r)});function eSe(n,e){const t=Ze(e);if(!t)return;const r=t.host.replace("www.","");for(const s of n)if(S7(s.hostnames,r)){const i=s.toEmbedUrl(e);if(i)return{definition:s,embedUrl:i,url:e}}}function tSe(n,e){try{return eSe(n,e)??Jye(n,e)}catch{return}}const nSe=n=>Object.entries(n).filter(([e,t])=>t).map(([e])=>e).join(" "),ba=class ba extends gh{static setEmbedDefinitions(e){ba.embedDefinitions=e}getEmbedDefinitions(){return ba.embedDefinitions}getEmbedDefinition(e){return tSe(ba.embedDefinitions,e)}getText(e){return e.props.url}getAriaDescriptor(e){const t=this.getEmbedDefinition(e.props.url);return t==null?void 0:t.definition.title}hideSelectionBoundsFg(e){return!this.canResize(e)}canEdit(){return!0}canResize(e){var t,r;return!!((r=(t=this.getEmbedDefinition(e.props.url))==null?void 0:t.definition)!=null&&r.doesResize)}canEditInReadOnly(){return!0}getDefaultProps(){return{w:300,h:300,url:""}}isAspectRatioLocked(e){const t=this.getEmbedDefinition(e.props.url);return(t==null?void 0:t.definition.isAspectRatioLocked)??!1}onResize(e,t){const r=this.isAspectRatioLocked(e),s=this.getEmbedDefinition(e.props.url);let i=(s==null?void 0:s.definition.minWidth)??200,o=(s==null?void 0:s.definition.minHeight)??200;if(r){const a=e.props.w/e.props.h;a>1?i*=a:o/=a}return uv(e,t,{minWidth:i,minHeight:o})}component(e){const t=Xp(),{w:r,h:s,url:i}=e.props,o=dv(e.id),a=this.getEmbedDefinition(i),l=ie("is hovering",()=>{const{editingShapeId:m,hoveredShapeId:S}=this.editor.getCurrentPageState();if(m&&S!==m){const x=this.editor.getShape(m);if(x&&this.editor.isShapeOfType(x,"embed"))return!0}return!1},[]),c=this.editor.getShapePageTransform(e).rotation();if(t)return g.jsx(Ul,{className:"tl-embed-container",id:e.id,children:g.jsx("div",{className:"tl-embed",style:{border:0,boxShadow:y0(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=o||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 m=a.url.split("/").pop();if(!m)throw Error("No gist id!");return g.jsx(Ul,{className:"tl-embed-container",id:e.id,children:g.jsx(rSe,{id:m,width:re(r),height:re(s),isInteractive:u,pageRotation:c})})}const p=nSe({...Vhe,...(a==null?void 0:a.definition.overridePermissions)??{}});return g.jsx(Ul,{className:"tl-embed-container",id:e.id,children:a!=null&&a.definition?g.jsx("iframe",{className:"tl-embed",sandbox:p,src:a.embedUrl,width:re(r),height:re(s),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:y0(c),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(e){const t=this.getEmbedDefinition(e.props.url);return g.jsx("rect",{width:re(e.props.w),height:re(e.props.h),rx:(t==null?void 0:t.definition.overrideOutlineRadius)??8,ry:(t==null?void 0:t.definition.overrideOutlineRadius)??8})}getInterpolatedProps(e,t,r){return{...r>.5?t.props:e.props,w:yt(e.props.w,t.props.w,r),h:yt(e.props.h,t.props.h,r)}}};R(ba,"type","embed"),R(ba,"props",k4),R(ba,"migrations",I4),R(ba,"embedDefinitions",H_);let S0=ba;function rSe({id:n,isInteractive:e,width:t,height:r,style:s,pageRotation:i}){if(!n.match(/^[0-9a-f]+$/))throw Error("No gist id!");return g.jsx("iframe",{className:"tl-embed",draggable:!1,width:re(t),height:re(r),frameBorder:"0",scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:e?"all":"none",zIndex:e?"":"-1",boxShadow:y0(i)},srcDoc:`
|
|
466
|
-
<html>
|
|
467
|
-
<head>
|
|
468
|
-
<base target="_blank">
|
|
469
|
-
</head>
|
|
470
|
-
<body>
|
|
471
|
-
<script src=${`https://gist.github.com/${n}.js`}><\/script>
|
|
472
|
-
<style type="text/css">
|
|
473
|
-
* { margin: 0px; }
|
|
474
|
-
table { height: 100%; background-color: red; }
|
|
475
|
-
.gist { background-color: none; height: 100%; }
|
|
476
|
-
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
477
|
-
</style>
|
|
478
|
-
</body>
|
|
479
|
-
</html>`})}function oI(n,e){const s=((Hc(n.getShapePageTransform(e.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4;return Math.floor(s)}const gN=new WeakMap;function mN(n,e,t){let r=gN.get(e.props);if(!r){const s=bT(e.props.name,"Frame")+"",i=n.textMeasure.measureTextSpans(s,t),o=i[0],a=tr(i);r=a.box.w+a.box.x-o.box.x,gN.set(e.props,r)}return new Se(0,-t.height,r,t.height)}function yN(n,e){return{fontSize:12,fontFamily:e?"Arial":"Inter, sans-serif",textAlign:"start",width:n,height:24,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle",offsetY:-34,offsetX:0}}function v7(n,e,t){const r=t?"":"px",s=t?"":"deg";let i;switch(e){case 0:i="";break;case 3:i=`translate(${re(n.props.w)}${r}, 0${r}) rotate(90${s})`;break;case 2:i=`translate(${re(n.props.w)}${r}, ${re(n.props.h)}${r}) rotate(180${s})`;break;case 1:i=`translate(0${r}, ${re(n.props.h)}${r}) rotate(270${s})`;break;default:throw Error("labelSide out of bounds")}return i}const sSe=P.forwardRef(({id:n,name:e,isEditing:t},r)=>{const s=te(),i=P.useCallback(l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(Wt(l),l.currentTarget.blur(),s.setEditingShape(null))},[s]),o=P.useCallback(l=>{const c=s.getShape(n);if(!c)return;const u=c.props.name,h=l.currentTarget.value.trim();u!==h&&s.updateShapes([{id:n,type:"frame",props:{name:h}}])},[n,s]),a=P.useCallback(l=>{const c=s.getShape(n);if(!c)return;const u=c.props.name,h=l.currentTarget.value;u!==h&&s.updateShapes([{id:n,type:"frame",props:{name:h}}])},[n,s]);return g.jsxs("div",{className:`tl-frame-label ${t?"tl-frame-label__editing":""}`,children:[g.jsx("input",{className:"tl-frame-name-input",ref:r,disabled:!t,readOnly:!t,style:{display:t?void 0:"none"},value:e,autoFocus:!0,onKeyDown:i,onBlur:o,onChange:a,onPointerDown:t?Wt:void 0,draggable:!1}),bT(e,"Frame")+""]})}),iSe=P.memo(function({id:e,name:t,width:r,height:s,fill:i,stroke:o,color:a,offsetX:l,showColors:c}){const u=te(),{side:h,translation:p}=ie("shape rotation",()=>{const x=u.getShape(e);if(!x)return{side:0,translation:"translate(0, 0)"};const v=oI(u,x);return{side:v,translation:v7(x,v,!1)}},[u,l,e]),m=P.useRef(null),S=dv(e);return P.useEffect(()=>{const x=m.current;x&&S&&(x.focus(),x.select())},[m,S]),g.jsx("div",{className:"tl-frame-heading",style:{overflow:S?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(h===0||h===2?r:s)}px + ${c?"0px":"var(--frame-offset-width)"})`,bottom:"100%",transform:`${p} scale(var(--tl-scale)) translateX(${l}px)`},children:g.jsx("div",{className:"tl-frame-heading-hit-area",style:{color:a,backgroundColor:i,boxShadow:`inset 0px 0px 0px 1px ${o}`},children:g.jsx(sSe,{ref:m,id:e,name:t,isEditing:S})})})}),oSe=12,aSe=32,lSe=-7,cSe=4;function bT(n,e){return n.match(/^\s*$/)?e:n}class Ay extends gh{constructor(){super(...arguments);R(this,"options",{showColors:!1})}static configure(t){const r=super.configure.call(this,t);return t.showColors&&(r.props={...r.props,color:Yr}),r}canEdit(){return!0}getDefaultProps(){return{w:160*2,h:90*2,name:"",color:"black"}}getAriaDescriptor(t){return t.props.name}getGeometry(t){const{editor:r}=this,s=r.getZoomLevel(),i=oI(r,t),o=i%2===1,a=o?t.props.h:t.props.w,l=yN(a,!1),c=mN(r,t,l),u=this.options.showColors,h=oSe/s,p=aSe/s,m=a+(u?1:h),S=c.w/s,x=c.h/s,v=Mn(S+h,p,m),w=(u?-1:lSe)/s,C=cSe/s,_=o?x:v,E=o?v:x;let T,A;switch(i){case 0:{T=w,A=-(x+C);break}case 1:{T=-(x+C),A=t.props.h-(w+v);break}case 2:{T=t.props.w-(w+v),A=t.props.h+C;break}case 3:{T=t.props.w+C,A=w;break}}return new Js({children:[new Ho({width:t.props.w,height:t.props.h,isFilled:!1}),new Ho({x:T,y:A,width:_,height:E,isFilled:!0,isLabel:!0})]})}getText(t){return t.props.name}component(t){const r=Mi(),s=ie("is creating this shape",()=>{const m=this.editor.getStateDescendant("select.resizing");if(!m||!m.getIsActive())return!1;const S=m==null?void 0:m.info;return S?S.isCreating&&this.editor.getOnlySelectedShapeId()===t.id:!1},[t.id]),i=ie("zoom level",()=>this.editor.getZoomLevel(),[this.editor]),o=this.options.showColors,a=r[t.props.color],l=o?a.frame.fill:r.black.frame.fill,c=o?a.frame.stroke:r.black.frame.stroke,u=o?a.frame.headingStroke:r.background,h=o?a.frame.headingFill:r.background,p=o?a.frame.text:r.text;return g.jsxs(g.Fragment,{children:[g.jsx(Gl,{children:g.jsx("rect",{className:$e("tl-frame__body",{"tl-frame__creating":s}),width:t.props.w+1/i,height:t.props.h+1/i,fill:l,stroke:c,y:-.5/i,x:-.5/i})}),s?null:g.jsx(iSe,{id:t.id,name:t.props.name,fill:h,stroke:u,color:p,width:t.props.w,height:t.props.h,offsetX:o?-1:-7,showColors:this.options.showColors})]})}toSvg(t,r){const s=Va({isDarkMode:r.isDarkMode}),i=oI(this.editor,t),a=i%2===1?t.props.h:t.props.w,l=v7(t,i,!0),c=yN(a-12,!0),u=bT(t.props.name,"Frame")+"",h=mN(this.editor,t,c),p=this.editor.textMeasure.measureTextSpans(u,c),m=rI(this.editor,p,c),S=this.options.showColors,x=s[t.props.color],v=S?x.frame.fill:s.black.frame.fill,w=S?x.frame.stroke:s.black.frame.stroke,C=S?x.frame.headingStroke:s.background,_=S?x.frame.headingFill:s.background,E=S?x.frame.text:s.text;return g.jsxs(g.Fragment,{children:[g.jsx("rect",{width:t.props.w,height:t.props.h,fill:v,stroke:w,strokeWidth:1,x:0,rx:0,ry:0}),g.jsxs("g",{fill:E,transform:l,children:[g.jsx("rect",{x:h.x-(S?0:6),y:h.y-6,width:Math.min(a,h.width+12),height:h.height,fill:_,stroke:C,rx:4,ry:4}),g.jsx("g",{transform:`translate(${S?8:0}, 4)`,children:m})]})]})}indicator(t){return g.jsx("rect",{width:re(t.props.w),height:re(t.props.h),className:"tl-frame-indicator"})}canReceiveNewChildrenOfType(t,r){return!t.isLocked}providesBackgroundForChildren(){return!0}canDropShapes(t,r){return!t.isLocked}onDragShapesOver(t,r){r.every(s=>s.parentId===t.id)||this.editor.reparentShapes(r,t.id)}onDragShapesOut(t,r){const s=this.editor.getShape(t.parentId);s&&this.editor.isShapeOfType(s,"group")?this.editor.reparentShapes(r,s.id):this.editor.reparentShapes(r,this.editor.getCurrentPageId())}onResize(t,r){return uv(t,r)}getInterpolatedProps(t,r,s){return{...s>.5?r.props:t.props,w:yt(t.props.w,r.props.w,s),h:yt(t.props.h,r.props.h,s)}}}R(Ay,"type","frame"),R(Ay,"props",E4),R(Ay,"migrations",_4);const uSe=at.forwardRef(function({shapeId:e,isEditing:t,richText:r,handleFocus:s,handleChange:i,handleBlur:o,handleKeyDown:a,handleDoubleClick:l},c){const u=te(),h=vu("tip-tap-editor"),p=u.getTextOptions().tipTapConfig,m=P.useRef(r),S=P.useRef(null),x=P.useRef(null);P.useLayoutEffect(()=>{S.current?m.current!==r&&S.current.commands.setContent(r):m.current=r},[r]);const v=P.useRef({selectAll:!1,caretPosition:null});P.useLayoutEffect(()=>{function A(D){D.shapeId===u.getEditingShapeId()&&(v.current.selectAll=!0)}function O(D){D.shapeId===u.getEditingShapeId()&&(v.current.caretPosition=D.point)}return u.on("select-all-text",A),u.on("place-caret",O),()=>{u.off("select-all-text",A),u.off("place-caret",O)}},[u,t]);const w=Pa(i),C=Pa(a),_=Pa(s),E=Pa(o),T=Pa(l);return P.useLayoutEffect(()=>{if(!t||!p||!x.current)return;const{editorProps:A,...O}=p,D=new $Q({element:x.current,autofocus:!0,editable:t,onUpdate:H=>{const G=H.editor.state.doc.toJSON();m.current=G,w({richText:G})},onFocus:_,onBlur:E,onCreate:H=>{var N;if(u.getEditingShapeId()!==e)return;const G=H.editor;u.setRichTextEditor(G);const{selectAll:J,caretPosition:L}=v.current;if(J)G.chain().focus().selectAll().run();else if(L){const U=(N=G.view.posAtCoords({left:L.x,top:L.y}))==null?void 0:N.pos;U?G.chain().focus().setTextSelection(U).run():G.chain().focus().selectAll().run()}},editorProps:{handleKeyDown:(H,G)=>{G.key==="Tab"&&dSe(u,H,G),C(G)},handleDoubleClick:(H,G,J)=>T(J),...A},coreExtensionOptions:{clipboardTextSerializer:{blockSeparator:`
|
|
480
|
-
`}},...O,content:m.current}),$=u.timers.setTimeout(()=>{v.current.caretPosition||v.current.selectAll?D.commands.focus():D.commands.focus("end"),v.current.selectAll=!1,v.current.caretPosition=null},100);return S.current=D,()=>{S.current=null,clearTimeout($),D.destroy()}},[t,p,_,E,T,w,C,u,e]),!t||!p?null:g.jsx("div",{id:h,ref:c,tabIndex:-1,"data-testid":"rich-text-area",className:"tl-rich-text tl-text tl-text-input",onContextMenu:t?Wt:void 0,onPointerDownCapture:Wt,onTouchEnd:Wt,onDragStart:tt,children:g.jsx("div",{className:"tl-rich-text",ref:x})})});function dSe(n,e,t){t.preventDefault();const r=n.getRichTextEditor();if(r!=null&&r.isActive("bulletList")||r!=null&&r.isActive("orderedList"))return;const{state:s,dispatch:i}=e,{$from:o,$to:a}=s.selection,l=t.shiftKey;let c=s.tr,u=a.end();for(;u>=o.start();){const p=s.doc.resolve(u).blockRange();if(!p)break;const m=p.start,S=p.end,x=s.doc.textBetween(m,S,`
|
|
481
|
-
`);let v=!1;s.doc.nodesBetween(m,S,w=>{if(w.type.name==="bulletList"||w.type.name==="orderedList")return v=!0,!1}),v||(l?x.startsWith(" ")&&(c=c.delete(m+1,m+2)):c=c.insertText(" ",m+1)),u=m-1}const h=s.selection.map(c.doc,c.mapping);c.setSelection(h),c.docChanged&&i(c)}function hSe(n,e,t){const r=i7(n),s=r.isEditing,i=te(),o=P.useRef(null),a=t&&Vi(t);P.useEffect(()=>{var h;if(!s)return;const u=(h=o.current)==null?void 0:h.querySelector("[contenteditable]");u&&document.activeElement!==o.current&&u.focus()},[i,s]);const l=P.useCallback(u=>{if(i.getEditingShapeId()===n)switch(u.key){case"Enter":{(u.ctrlKey||u.metaKey)&&i.complete();break}}},[i,n]),c=P.useCallback(({richText:u})=>{i.getEditingShapeId()===n&&i.updateShape({id:n,type:e,props:{richText:u}})},[i,n,e]);return{rInput:o,handleKeyDown:l,handleChange:c,isEmpty:a,...r}}const CT=at.memo(function({shapeId:e,type:t,richText:r,labelColor:s,font:i,fontSize:o,lineHeight:a,align:l,verticalAlign:c,wrap:u,isSelected:h,padding:p=0,onKeyDown:m,classNamePrefix:S,style:x,textWidth:v,textHeight:w}){const C=te(),_=at.useRef(!1),{rInput:E,isEmpty:T,isEditing:A,isReadyForEditing:O,...D}=hSe(e,t,r),$=P.useMemo(()=>{if(r)return pT(C,r)},[C,r]),H=ie("isSelectToolActive",()=>C.getCurrentToolId()==="select",[C]);HI("isDragging",()=>{C.getInstanceState(),_.current=C.inputs.isDragging},[C]);const G=s7(l),J=N=>{var U;if(N.target instanceof HTMLElement&&(N.target.tagName==="A"||N.target.closest("a"))){if(tt(N),!H)return;const Y=((U=N.target.closest("a"))==null?void 0:U.getAttribute("href"))??"",W=z=>{z.name==="pointer_up"&&(_.current||window.open(Y,"_blank","noopener, noreferrer"),C.off("event",W))};C.on("event",W)}};if(!A&&T)return null;const L=S||"tl-text";return g.jsx("div",{className:`${L}-label tl-text-wrapper tl-rich-text-wrapper`,"data-font":i,"data-align":l,"data-hastext":!T,"data-isediting":A,"data-textwrap":!!u,"data-isselected":h,style:{justifyContent:l==="middle"||G?"center":l,alignItems:c==="middle"?"center":c,padding:p,...x},children:g.jsxs("div",{className:`${L}-label__inner tl-text-content__wrapper`,style:{fontSize:o,lineHeight:Math.floor(o*a)+"px",minHeight:Math.floor(o*a)+"px",minWidth:Math.ceil(v||0),color:s,width:v?Math.ceil(v):void 0,height:w?Math.ceil(w):void 0},children:[g.jsx("div",{className:`${L} tl-text tl-text-content`,dir:"auto",children:r&&g.jsx("div",{className:"tl-rich-text","data-is-select-tool-active":H,dangerouslySetInnerHTML:{__html:$||""},onPointerDown:J,"data-is-ready-for-editing":O})}),(O||h)&&g.jsx(uSe,{ref:E,richText:r,isEditing:A,shapeId:e,...D,handleKeyDown:m??D.handleKeyDown})]})})});function PT({bounds:n,richText:e,fontSize:t,font:r,align:s,verticalAlign:i,wrap:o,labelColor:a,padding:l}){const c=te(),u=pT(c,e),h=s==="middle"?"center":s==="start"?"start":"end",p=s==="middle"?"center":s==="start"?"flex-start":"flex-end",m=i==="middle"?"center":i==="start"?"flex-start":"flex-end",S={display:"flex",fontFamily:d4[r],height:"100%",justifyContent:p,alignItems:m,padding:`${l}px`},x={fontSize:`${t}px`,wrap:o?"wrap":"nowrap",color:a,lineHeight:ar.lineHeight,textAlign:h,width:"100%",wordWrap:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap"};return g.jsx("foreignObject",{x:n.minX,y:n.minY,width:n.w,height:n.h,className:"tl-export-embed-styles tl-rich-text tl-rich-text-svg",children:g.jsx("div",{style:S,children:g.jsx("div",{dangerouslySetInnerHTML:{__html:u},style:x})})})}function SN(n,e){return n>e?(wt*(e/2)+(n-e))*2:(wt*(n/2)+(e-n))*2}function x7(n,e){return kT(n,e).map((t,r)=>t.getSvgPathData(r===0)).join(" ")+" Z"}function fSe(n,e,t,r){const s=n/4,i=e/4,o=oo(r),a=t*.75,l=C=>C.addXY(o()*a,o()*a),c=new k(n/2,e),u=new k(0,i*1.2),h=new k(n/2,i*.9),p=new k(n,i*1.2),m=l(new k(n/2,e)),S=l(new k(0,i*1.2)),x=l(new k(n/2,i*.9)),v=l(new k(n,i*1.2));return[new Cr({start:c,cp1:new k(s*1.5,i*3),cp2:new k(0,i*2.5),end:u}),new Cr({start:u,cp1:new k(0,-i*.32),cp2:new k(s*1.85,-i*.32),end:h}),new Cr({start:h,cp1:new k(s*2.15,-i*.32),cp2:new k(n,-i*.32),end:p}),new Cr({start:p,cp1:new k(n,i*2.5),cp2:new k(s*2.5,i*3),end:m}),new Cr({start:m,cp1:new k(s*1.5,i*3),cp2:new k(0,i*2.5),end:S}),new Cr({start:S,cp1:new k(0,-i*.32),cp2:new k(s*1.85,-i*.32),end:x}),new Cr({start:x,cp1:new k(s*2.15,-i*.32),cp2:new k(n,-i*.32),end:v}),new Cr({start:v,cp1:new k(n,i*2.5),cp2:new k(s*2.5,i*3),end:c})].map((C,_)=>C.getSvgPathData(_===0)).join(" ")+" Z"}function kT(n,e){const t=n/4,r=e/4;return[new Cr({start:new k(n/2,e),cp1:new k(t*1.5,r*3),cp2:new k(0,r*2.5),end:new k(0,r*1.2)}),new Cr({start:new k(0,r*1.2),cp1:new k(0,-r*.32),cp2:new k(t*1.85,-r*.32),end:new k(n/2,r*.9)}),new Cr({start:new k(n/2,r*.9),cp1:new k(t*2.15,-r*.32),cp2:new k(n,-r*.32),end:new k(n,r*1.2)}),new Cr({start:new k(n,r*1.2),cp1:new k(n,r*2.5),cp2:new k(t*2.5,r*3),end:new k(n/2,e)})]}function pSe(n){return{size:1+n,thinning:.25,end:{taper:n},start:{taper:n},streamline:0,smoothing:1,simulatePressure:!1}}function gSe(n,e,t,r){const s=oo(n),i=e/2,o=t/2,a=sF(i,o),l=[],c=Rt*s(),u=Rt+Kt/2+Math.abs(s())*Kt,h=Math.max(16,a/10);for(let p=0;p<h;p++){const m=p/(h-1),S=c+m*u,x=Math.cos(S),v=Math.sin(S);l.push(new k(i*x+e*.5+.05*s(),o*v+t/2+.05*s(),Math.min(1,.5+Math.abs(.5-(s()>0?Hn.easeInOutSine(m):Hn.easeInExpo(m)))/2)))}return Vo(l,pSe(r))}function mSe(n,e,t,r){return uu(gSe(n,e,t,r))}function aI(n){let e="M";const t=n.length;let r,s,i;for(let o=0,a=t;o<a;o+=3)r=n[o],s=n[o+1],i=n[o+2],e+=`${Ct(r)}L${Ct(s)}Q${Ct(i)}`;return e+=`${Ct(n[0])}`,e}function lI(n,e,t,r,s){const i=[],o=oo(n);let a=e[0],l;const c=e.length;for(let u=0,h=c*s;u<h;u++){l=k.AddXY(e[(u+1)%c],o()*t,o()*t);const p=k.Sub(l,a),m=k.Len(p),S=k.Div(p,m).mul(Math.min(m/4,r));i.push(k.Add(a,S),k.Add(l,S.neg()),l),a=l}return i}function ySe(n,e,t){const r=Math.min(n,e)/2,s=Math.max(n,e)-r*2,o=(Math.PI*(r*2)+2*s)/t,a=n>e?[{type:"straight",start:new k(r,0),delta:new k(1,0)},{type:"arc",center:new k(n-r,r),startAngle:-wt/2},{type:"straight",start:new k(n-r,e),delta:new k(-1,0)},{type:"arc",center:new k(r,r),startAngle:wt/2}]:[{type:"straight",start:new k(n,r),delta:new k(0,1)},{type:"arc",center:new k(r,e-r),startAngle:0},{type:"straight",start:new k(0,e-r),delta:new k(0,-1)},{type:"arc",center:new k(r,r),startAngle:wt}];let l=0;const c=[];for(let u=0;u<t;u++){const h=a[0];h.type==="straight"?c.push(k.Add(h.start,k.Mul(h.delta,l))):c.push(Xc(h.center,r,h.startAngle+l/r)),l+=o;let p=h.type==="straight"?s:wt*r;for(;l>p;)l-=p,a.push(a.shift()),p=a[0].type==="straight"?s:wt*r}return c}const SSe={s:50,m:70,l:100,xl:130},vSe=.2;function Lv(n,e,t,r,s){const i=oo(t),o=SN(n,e),a=Math.max(Math.ceil(o/SSe[r]),6,Math.ceil(o/Math.min(n,e))),l=o/a*vSe,c=Math.max(n-l*2,1),u=Math.max(e-l*2,1),p=SN(c,u)/a,m=(n-c)/2,S=(e-u)/2,x=ySe(c,u,a).map(E=>E.addXY(m,S)),v=n<20?0:l*.3,w=e<20?0:l*.3,C=x.slice(0);for(let E=0;E<Math.floor(a/2);E++)C[E]=k.AddXY(C[E],i()*v*s,i()*w*s),C[a-E-1]=k.AddXY(C[a-E-1],i()*v*s,i()*w*s);const _=[];for(let E=0;E<C.length;E++){const T=E===C.length-1?0:E+1,A=C[E],O=C[T],D=x[E],$=x[T],H=k.Dist(D,$),G=p-H,L=k.Dist(A,O)/H,N=(Math.max(m,S)+G)*L,U=k.Lrp(D,$,.5).add(k.Sub($,D).uni().per().mul(N));U.x<0?U.x=0:U.x>n&&(U.x=n),U.y<0?U.y=0:U.y>e&&(U.y=e);const Y=KI(A,O,U),W=k.Dist(Y||k.Average([A,O]),A);_.push({leftPoint:A,rightPoint:O,arcPoint:U,center:Y,radius:W})}return _}function xSe(n,e,t,r,s){const i=[],o=Lv(n,e,t,r,s);for(const{center:a,radius:l,leftPoint:c,rightPoint:u}of o)i.push(...$G(c,u,a,l,10));return i}function cI(n,e,t,r,s){const i=Lv(n,e,t,r,s);let o=`M${i[0].leftPoint.toFixed()}`;for(const{leftPoint:a,rightPoint:l,radius:c,center:u}of i){if(u===null){o+=` L${l.toFixed()}`;continue}const h=k.Clockwise(a,l,u)?"0":"1";o+=` A${re(c)},${re(c)} 0 ${h},1 ${l.toFixed()}`}return o+=" Z",o}const wSe={s:.5,m:.7,l:.9,xl:1.6};function bSe(n,e,t,r,s){const i=oo(t),o=wSe[r]*s,a=Lv(n,e,t,r,s),u=a.reduce((S,x)=>S+k.Dist2(x.leftPoint,x.rightPoint),0)/a.length>(o*15)**2?S=>k.AddXY(S,i()*o*2,i()*o*2):S=>S;let h=`M${a[0].leftPoint.toFixed()}`,p=u(a[0].leftPoint),m=`M${p.toFixed()}`;for(const{leftPoint:S,center:x,rightPoint:v,radius:w,arcPoint:C}of a){if(x===null){h+=` L${v.toFixed()}`;const D=u(v);m+=` L${D.toFixed()}`,p=D;continue}const _=k.Clockwise(S,v,x)?"0":"1";h+=` A${re(w)},${re(w)} 0 ${_},1 ${v.toFixed()}`;const E=u(v),T=u(C),A=KI(p,E,T);if(!A){m+=` L${E.toFixed()}`,p=E;continue}const O=Math.abs(k.Dist(A,p));m+=` A${re(O)},${re(O)} 0 ${_},1 ${E.toFixed()}`,p=E}return h+m+" Z"}function uI(n,e){switch(n.geo){case"x-box":return CSe(n.w,n.h,e,n.dash);case"check-box":return PSe(n.w,n.h);default:return}}function CSe(n,e,t,r){const s=r==="draw"?.62:0;if(r==="dashed")return[[new k(0,0),new k(n/2,e/2)],[new k(n,e),new k(n/2,e/2)],[new k(0,e),new k(n/2,e/2)],[new k(n,0),new k(n/2,e/2)]];const i=a=>Math.max(0,Math.min(n,a)),o=a=>Math.max(0,Math.min(e,a));return[[new k(i(t*s),o(t*s)),new k(i(n-t*s),o(e-t*s))],[new k(i(t*s),o(e-t*s)),new k(i(n-t*s),o(t*s))]]}function PSe(n,e){const t=Math.min(n,e)*.82,r=(n-t)/2,s=(e-t)/2,i=a=>Math.max(0,Math.min(n,a)),o=a=>Math.max(0,Math.min(e,a));return[[new k(i(r+t*.25),o(s+t*.52)),new k(i(r+t*.45),o(s+t*.82))],[new k(i(r+t*.45),o(s+t*.82)),new k(i(r+t*.82),o(s+t*.22))]]}function vN({shape:n,shouldScale:e,forceSolid:t}){const r=e?n.props.scale:1,s=te(),i=Mi(),{id:o,props:a}=n,{w:l,color:c,fill:u,dash:h,growY:p,size:m,scale:S}=a,x=Er[m]*r,v=a.h+p;switch(a.geo){case"cloud":if(h==="solid"){const w=cI(l,v,o,m,S);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:w,color:c,fill:u,scale:r}),g.jsx("path",{d:w,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}else if(h==="draw"){const w=bSe(l,v,o,m,S);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:w,color:c,fill:u,scale:r}),g.jsx("path",{d:w,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}else{const w=cI(l,v,o,m,S),C=Lv(l,v,o,m,S);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:w,color:c,fill:u,scale:r}),g.jsx("g",{strokeWidth:x,stroke:i[c].solid,fill:"none",pointerEvents:"all",children:C.map(({leftPoint:_,rightPoint:E,center:T,radius:A},O)=>{const D=T?A*Hc(Hc(k.Angle(T,E))-Hc(k.Angle(T,_))):k.Dist(_,E),{strokeDasharray:$,strokeDashoffset:H}=Wi(D,x,{style:h,start:"outset",end:"outset",forceSolid:t});return g.jsx("path",{d:T?`M${_.x},${_.y}A${A},${A},0,0,1,${E.x},${E.y}`:`M${_.x},${_.y}L${E.x},${E.y}`,strokeDasharray:$,strokeDashoffset:H},O)})})]})}case"ellipse":{const w=e?s.getShapeGeometry(n):s.getShapeUtil(n).getGeometry(n),C=w.getSvgPathData(!0);if(h==="dashed"||h==="dotted"){const _=w.length,{strokeDasharray:E,strokeDashoffset:T}=Wi(_<64?_*2:_,x,{style:h,snap:4,closed:!0,forceSolid:t});return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:C,color:c,fill:u,scale:r}),g.jsx("path",{d:C,strokeWidth:x,fill:"none",stroke:i[c].solid,strokeDasharray:E,strokeDashoffset:T})]})}else{const E=(e?s.getShapeGeometry(n):s.getShapeUtil(n).getGeometry(n)).getSvgPathData(!0);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:E,color:c,fill:u,scale:r}),g.jsx("path",{d:E,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}}case"oval":{const w=e?s.getShapeGeometry(n):s.getShapeUtil(n).getGeometry(n),C=w.getSvgPathData(!0);if(h==="dashed"||h==="dotted"){const _=w.getLength(),{strokeDasharray:E,strokeDashoffset:T}=Wi(_<64?_*2:_,x,{style:h,snap:4,start:"outset",end:"outset",closed:!0,forceSolid:t});return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:C,color:c,fill:u,scale:r}),g.jsx("path",{d:C,strokeWidth:x,fill:"none",stroke:i[c].solid,strokeDasharray:E,strokeDashoffset:T})]})}else return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:C,color:c,fill:u,scale:r}),g.jsx("path",{d:C,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}case"heart":if(h==="dashed"||h==="dotted"||h==="solid"){const w=x7(l,v),C=kT(l,v);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:w,color:c,fill:u,scale:r}),C.map((_,E)=>{const{strokeDasharray:T,strokeDashoffset:A}=Wi(_.length,x,{style:h,snap:1,start:"outset",end:"outset",closed:!0,forceSolid:t});return g.jsx("path",{d:_.getSvgPathData(),strokeWidth:x,fill:"none",stroke:i[c].solid,strokeDasharray:T,strokeDashoffset:A,pointerEvents:"all"},`curve_${E}`)})]})}else{const w=fSe(l,v,x,n.id);return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:w,color:c,fill:u,scale:r}),g.jsx("path",{d:w,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}default:{const w=e?s.getShapeGeometry(n):s.getShapeUtil(n).getGeometry(n),C=w instanceof Js?w.children[0].vertices:w.vertices,_=uI(n.props,x);if(h==="solid"){let E="M"+C[0]+"L"+C.slice(1)+"Z";if(_)for(const[T,A]of _)E+=`M${T.x},${T.y}L${A.x},${A.y}`;return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:E,color:c,fill:u,scale:r}),g.jsx("path",{d:E,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}else if(h==="dashed"||h==="dotted"){const E="M"+C[0]+"L"+C.slice(1)+"Z";return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:E,color:c,fill:u,scale:r}),g.jsxs("g",{strokeWidth:x,stroke:i[c].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(C.length)).map((T,A)=>{const O=k.ToFixed(C[A]),D=k.ToFixed(C[(A+1)%C.length]),$=k.Dist(O,D),{strokeDasharray:H,strokeDashoffset:G}=Wi($,x,{style:h,start:"outset",end:"outset",forceSolid:t});return g.jsx("line",{x1:O.x,y1:O.y,x2:D.x,y2:D.y,strokeDasharray:H,strokeDashoffset:G},A)}),_&&_.map(([T,A],O)=>{const D=k.Dist(T,A),{strokeDasharray:$,strokeDashoffset:H}=Wi(D,x,{style:h,start:"skip",end:"skip",snap:h==="dotted"?4:void 0,forceSolid:t});return g.jsx("path",{d:`M${T.x},${T.y}L${A.x},${A.y}`,stroke:i[c].solid,strokeWidth:x,fill:"none",strokeDasharray:$,strokeDashoffset:H},`line_fg_${O}`)})]})]})}else if(h==="draw"){let E=aI(lI(o,C,x/3,x*2,2));if(_)for(const[A,O]of _)E+=`M${A.toFixed()}L${O.toFixed()}`;const T=aI(lI(o,C,0,x*2,1));return g.jsxs(g.Fragment,{children:[g.jsx(vr,{theme:i,d:T,color:c,fill:u,scale:r}),g.jsx("path",{d:E,stroke:i[c].solid,strokeWidth:x,fill:"none"})]})}}}}const xN=17*3;class Oy extends gh{canEdit(){return!0}getDefaultProps(){return{w:100,h:100,geo:"rectangle",color:"black",labelColor:"black",fill:"none",dash:"draw",size:"m",font:"draw",align:"middle",verticalAlign:"middle",growY:0,url:"",scale:1,richText:Ei("")}}getGeometry(e){const t=Math.max(1,e.props.w),r=Math.max(1,e.props.h+e.props.growY),s=t/2,i=r/2,o=e.props.fill!=="none";let a;switch(e.props.geo){case"cloud":{a=new Tn({points:xSe(t,r,e.id,e.props.size,e.props.scale),isFilled:o});break}case"triangle":{a=new Tn({points:[new k(s,0),new k(t,r),new k(0,r)],isFilled:o});break}case"diamond":{a=new Tn({points:[new k(s,0),new k(t,i),new k(s,r),new k(0,i)],isFilled:o});break}case"pentagon":{a=new Tn({points:L1(t,r,5),isFilled:o});break}case"hexagon":{a=new Tn({points:L1(t,r,6),isFilled:o});break}case"octagon":{a=new Tn({points:L1(t,r,8),isFilled:o});break}case"ellipse":{a=new nle({width:t,height:r,isFilled:o});break}case"oval":{a=new rle({width:t,height:r,isFilled:o});break}case"star":{const C=Rt/5/2,_=Math.floor(5/4)*2,E=5*2-_,T=0,A=Math.floor(5/2)*2,O=Math.cos(-Kt+_*C)*t/2,D=Math.cos(-Kt+E*C)*t/2,$=Math.sin(-Kt+T*C)*r/2,H=Math.sin(-Kt+A*C)*r/2,G=t-Math.abs(O-D),J=r-Math.abs(H-$),L=t/2+D-(t/2-O),N=r/2+$-(r/2-H),U=1,Y=(t-L)/2,W=(r-N)/2,z=(t+G)/2,V=(r+J)/2,ee=z*U/2,B=V*U/2;a=new Tn({points:Array.from(Array(5*2)).map((Q,me)=>{const Pe=-Kt+me*C;return new k(Y+(me%2?ee:z)*Math.cos(Pe),W+(me%2?B:V)*Math.sin(Pe))}),isFilled:o});break}case"rhombus":{const w=Math.min(t*.38,r*.38);a=new Tn({points:[new k(w,0),new k(t,0),new k(t-w,r),new k(0,r)],isFilled:o});break}case"rhombus-2":{const w=Math.min(t*.38,r*.38);a=new Tn({points:[new k(0,0),new k(t-w,0),new k(t,r),new k(w,r)],isFilled:o});break}case"trapezoid":{const w=Math.min(t*.38,r*.38);a=new Tn({points:[new k(w,0),new k(t-w,0),new k(t,r),new k(0,r)],isFilled:o});break}case"arrow-right":{const w=Math.min(t,r)*.38,C=r*.16;a=new Tn({points:[new k(0,C),new k(t-w,C),new k(t-w,0),new k(t,r/2),new k(t-w,r),new k(t-w,r-C),new k(0,r-C)],isFilled:o});break}case"arrow-left":{const w=Math.min(t,r)*.38,C=r*.16;a=new Tn({points:[new k(w,0),new k(w,C),new k(t,C),new k(t,r-C),new k(w,r-C),new k(w,r),new k(0,r/2)],isFilled:o});break}case"arrow-up":{const w=t*.16,C=Math.min(t,r)*.38;a=new Tn({points:[new k(t/2,0),new k(t,C),new k(t-w,C),new k(t-w,r),new k(w,r),new k(w,C),new k(0,C)],isFilled:o});break}case"arrow-down":{const w=t*.16,C=Math.min(t,r)*.38;a=new Tn({points:[new k(w,0),new k(t-w,0),new k(t-w,r-C),new k(t,r-C),new k(t/2,r),new k(0,r-C),new k(w,r-C)],isFilled:o});break}case"check-box":case"x-box":case"rectangle":{a=new Ho({width:t,height:r,isFilled:o});break}case"heart":{const C=kT(t,r).reduce((_,E)=>(_.push(...E.vertices),_),[]);a=new Tn({points:C,isFilled:o});break}default:An(e.props.geo)}const l=ty(this.editor,e),c=t/e.props.scale,u=r/e.props.scale,h=Math.min(100,c/2),p=Math.min(ja[e.props.size]*ar.lineHeight+Ur*2,u/2),m=Math.min(c,Math.max(l.w,Math.min(h,Math.max(1,c-8)))),S=Math.min(u,Math.max(l.h,Math.min(p,Math.max(1,u-8)))),x=uI(e.props,Er[e.props.size]*e.props.scale),v=x?x.map(w=>new Yp({points:w})):[];return new Js({children:[a,new Ho({x:e.props.align==="start"?0:e.props.align==="end"?(c-m)*e.props.scale:(c-m)/2*e.props.scale,y:e.props.verticalAlign==="start"?0:e.props.verticalAlign==="end"?(u-S)*e.props.scale:(u-S)/2*e.props.scale,width:m*e.props.scale,height:S*e.props.scale,isFilled:!0,isLabel:!0}),...v]})}getHandleSnapGeometry(e){const t=this.getGeometry(e),r=t.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.vertices,t.bounds.center]};case"cloud":case"ellipse":case"heart":case"oval":return{outline:r,points:[t.bounds.center]};default:An(e.props.geo)}}getText(e){return cu(this.editor,e.props.richText)}getFontFaces(e){return gE(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"})}component(e){const{id:t,type:r,props:s}=e,{fill:i,font:o,align:a,verticalAlign:l,size:c,richText:u}=s,h=Mi(),{editor:p}=this,m=ie("isGeoOnlySelected",()=>e.id===p.getOnlySelectedShapeId(),[p]),S=mT(p,e.id),x=Vi(e.props.richText),v=S||!x,w=ie("force solid",()=>p.getZoomLevel()<.2,[p]);return g.jsxs(g.Fragment,{children:[g.jsx(Gl,{children:g.jsx(vN,{shape:e,shouldScale:!0,forceSolid:w})}),v&&g.jsx(Ul,{style:{overflow:"hidden",width:e.props.w,height:e.props.h+s.growY},children:g.jsx(CT,{shapeId:t,type:r,font:o,fontSize:ja[c]*e.props.scale,lineHeight:ar.lineHeight,padding:Ur*e.props.scale,fill:i,align:a,verticalAlign:l,richText:u,isSelected:m,labelColor:h[s.labelColor].solid,wrap:!0})}),e.props.url&&g.jsx(Qd,{url:e.props.url})]})}indicator(e){const{id:t,props:r}=e,{w:s,size:i}=r,o=r.h+r.growY,a=Er[i],l=this.editor.getShapeGeometry(e);switch(r.geo){case"ellipse":return r.dash==="draw"?g.jsx("path",{d:mSe(t,s,o,a)}):g.jsx("path",{d:l.getSvgPathData(!0)});case"heart":return g.jsx("path",{d:x7(s,o)});case"oval":return g.jsx("path",{d:l.getSvgPathData(!0)});case"cloud":return g.jsx("path",{d:cI(s,o,t,i,e.props.scale)});default:{const c=this.editor.getShapeGeometry(e),u=c instanceof Js?c.children[0].vertices:c.vertices;let h;if(r.dash==="draw"){const m=lI(t,u,0,a*2*e.props.scale,1);h=aI(m)}else h="M"+u[0]+"L"+u.slice(1)+"Z";const p=uI(e.props,a);if(p)for(const[m,S]of p)h+=`M${m.x},${m.y}L${S.x},${S.y}`;return g.jsx("path",{d:h})}}}toSvg(e,t){const r={...e,props:{...e.props,w:e.props.w/e.props.scale,h:e.props.h/e.props.scale}},s=r.props;t.addExportDef(yT(s.fill));let i;if(!Vi(s.richText)){const o=Va(t),a=new Se(0,0,s.w,s.h+s.growY);i=g.jsx(PT,{fontSize:ja[s.size],font:s.font,align:s.align,verticalAlign:s.verticalAlign,richText:s.richText,labelColor:o[s.labelColor].solid,bounds:a,padding:Ur*e.props.scale})}return g.jsxs(g.Fragment,{children:[g.jsx(vN,{shouldScale:!1,shape:r,forceSolid:!1}),i]})}getCanvasSvgDefs(){return[ST()]}onResize(e,{handle:t,newPoint:r,scaleX:s,scaleY:i,initialShape:o}){const a=o.props.w/o.props.scale,l=o.props.h/o.props.scale,c=o.props.growY/o.props.scale;let u=a*s,h=(l+c)*i,p=0,m=0;const S=xN;if(!Vi(e.props.richText)){let E=Math.max(Math.abs(u),S),T=Math.max(Math.abs(h),S);E<S&&T===S&&(E=S),E===S&&T<S&&(T=S);const A=ty(this.editor,{...e,props:{...e.props,w:E*e.props.scale,h:T*e.props.scale}}),O=Math.max(Math.abs(u),A.w)*Math.sign(u),D=Math.max(Math.abs(h),A.h)*Math.sign(h);p=Math.abs(O)-Math.abs(u),m=Math.abs(D)-Math.abs(h),u=O,h=D}const x=u*e.props.scale,v=h*e.props.scale,w=new k(0,0);s<0&&(w.x+=x),(t==="left"||t==="top_left"||t==="bottom_left")&&(w.x+=s<0?p:-p),i<0&&(w.y+=v),(t==="top"||t==="top_left"||t==="top_right")&&(w.y+=i<0?m:-m);const{x:C,y:_}=w.rot(e.rotation).add(r);return{x:C,y:_,props:{w:Math.max(Math.abs(x),1),h:Math.max(Math.abs(v),1),growY:0}}}onBeforeCreate(e){if(Vi(e.props.richText))return e.props.growY?{...e,props:{...e.props,growY:0}}:void 0;const t=e.props.h/e.props.scale,r=ty(this.editor,e).h;let s=null;if(r>t?s=r-t:e.props.growY&&(s=0),s!==null)return{...e,props:{...e.props,growY:s*e.props.scale}}}onBeforeUpdate(e,t){if(ch(e.props.richText,t.props.richText)&&e.props.font===t.props.font&&e.props.size===t.props.size)return;const r=Vi(e.props.richText),s=Vi(t.props.richText);if(!r&&s)return{...t,props:{...t.props,growY:0}};const i=e.props.w/e.props.scale,o=e.props.h/e.props.scale,a=e.props.growY/e.props.scale,l=ty(this.editor,t);if(r&&!s&&cu(this.editor,t.props.richText)){let u=Math.max(i,l.w),h=Math.max(o,l.h);const p=xN;return i<p&&o<p&&(u=Math.max(u,p),h=Math.max(h,p),u=Math.max(u,h),h=Math.max(u,h)),{...t,props:{...t.props,w:u*t.props.scale,h:h*t.props.scale,growY:0}}}let c=null;if(l.h>o?c=l.h-o:a&&(c=0),c!==null){const u=t.props.w/t.props.scale;return{...t,props:{...t.props,growY:c*t.props.scale,w:Math.max(u,l.w)*t.props.scale}}}if(l.w>i)return{...t,props:{...t.props,w:l.w*t.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,t,r){return{...r>.5?t.props:e.props,w:yt(e.props.w,t.props.w,r),h:yt(e.props.h,t.props.h,r),scale:yt(e.props.scale,t.props.scale,r)}}}R(Oy,"type","geo"),R(Oy,"props",T4),R(Oy,"migrations",M4);function ty(n,e){const{richText:t,font:r,size:s,w:i}=e.props;if(!t||Vi(t))return{w:0,h:0};const o=n.textMeasure.measureText("w",{...ar,fontFamily:Ba[r],fontSize:ja[s],maxWidth:100}),a={s:2,m:3.5,l:5,xl:10},l=p0(n,t),c=n.textMeasure.measureHtml(l,{...ar,fontFamily:Ba[r],fontSize:ja[s],minWidth:o.w,maxWidth:Math.max(0,Math.ceil(o.w+a[s]),Math.ceil(i/e.props.scale-Ur*2))});return{w:c.w+Ur*2,h:c.h+Ur*2}}function kSe(){const[n,e]=P.useState(!1);return P.useEffect(()=>{const r=CSS.supports("color","color(display-p3 1 1 1)"),s=matchMedia("(color-gamut: p3)");e(r&&s.matches);const i=()=>e(r&&s.matches);return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[]),ie(ln.forceSrgb)||!n?"srgb":"p3"}class Ry extends eo{constructor(){super(...arguments);R(this,"options",{maxPointsPerShape:600,underlayOpacity:.82,overlayOpacity:.35})}canTabTo(){return!1}hideResizeHandles(t){return ny(t)}hideRotateHandle(t){return ny(t)}hideSelectionBoundsFg(t){return ny(t)}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1}}getGeometry(t){const r=Rc(t);if(ny(t))return new l_({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:s,sw:i}=wN(t,r,!0),o=wT({strokeWidth:i,showAsComplete:!0});return Rv(s,o),new Tn({points:tT(s,o),isFilled:!0})}component(t){const r=nP(this.editor,t),s=Rc(t);return g.jsx(Gl,{children:g.jsx(ry,{shape:t,forceSolid:r,strokeWidth:s,opacity:this.options.overlayOpacity})})}backgroundComponent(t){const r=nP(this.editor,t),s=Rc(t);return g.jsx(Gl,{children:g.jsx(ry,{shape:t,forceSolid:r,strokeWidth:s,opacity:this.options.underlayOpacity})})}indicator(t){const r=nP(this.editor,t),s=Rc(t),{strokePoints:i,sw:o}=wN(t,s,r),a=eh(t.props.segments);let l;return i.length<2?l=ESe(a[0],o):l=uu(i,!1),g.jsx("path",{d:l})}toSvg(t){const r=Rc(t),s=r<1.5,i=1/t.props.scale;return g.jsx("g",{transform:`scale(${i})`,children:g.jsx(ry,{forceSolid:s,strokeWidth:r,shape:t,opacity:this.options.overlayOpacity})})}toBackgroundSvg(t){const r=Rc(t),s=r<1.5,i=1/t.props.scale;return g.jsx("g",{transform:`scale(${i})`,children:g.jsx(ry,{forceSolid:s,strokeWidth:r,shape:t,opacity:this.options.underlayOpacity})})}onResize(t,r){const{scaleX:s,scaleY:i}=r,o=[];for(const a of t.props.segments)o.push({...a,points:a.points.map(({x:l,y:c,z:u})=>({x:s*l,y:i*c,z:u}))});return{props:{segments:o}}}getInterpolatedProps(t,r,s){return{...s>.5?r.props:t.props,...r.props,segments:m7(t.props.segments,r.props.segments,s),scale:yt(t.props.scale,r.props.scale,s)}}}R(Ry,"type","highlight"),R(Ry,"props",R4),R(Ry,"migrations",D4);function ISe(n){return`M ${n.x} ${n.y} m -${.1}, 0 a ${.1},${.1} 0 1,0 ${.1*2},0 a ${.1},${.1} 0 1,0 -${.1*2},0`}function ESe(n,e){const t=e/2;return`M ${n.x} ${n.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function wN(n,e,t){var l;const r=eh(n.props.segments),s=n.props.isComplete||((l=tr(n.props.segments))==null?void 0:l.type)==="straight";let i=e;!t&&!n.props.isPen&&r.length===1&&(i+=oo(n.id)()*(e/6));const o=wT({strokeWidth:i,showAsComplete:s});return{strokePoints:Vo(r,o),sw:i}}function Rc(n){return Zd[n.props.size]*1.12*n.props.scale}function ny(n){return n.props.segments.length===1&&n.props.segments[0].points.length<2}function ry({strokeWidth:n,forceSolid:e,shape:t,opacity:r}){var p;const s=Mi(),i=eh(t.props.segments);let o=n;!e&&!t.props.isPen&&i.length===1&&(o+=oo(t.id)()*(o/6));const a=wT({strokeWidth:o,showAsComplete:t.props.isComplete||((p=tr(t.props.segments))==null?void 0:p.type)==="straight"}),l=Vo(i,a),c=l.length>1?uu(l,!1):ISe(t.props.segments[0].points[0]),u=kSe(),h=s[t.props.color].highlight[u];return g.jsx("path",{d:c,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:h,strokeWidth:o,opacity:r})}function nP(n,e){return ie("forceSolid",()=>{const t=Rc(e),r=n.getZoomLevel();return t/r<1.5},[n])}function w7(){return g.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:[g.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),g.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),g.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}const bN=8;function _Se(){return{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}}function Ep(n,e){if(!e)return{w:n.w,h:n.h};const t=n.w/(e.bottomRight.x-e.topLeft.x),r=n.h/(e.bottomRight.y-e.topLeft.y);return{w:t,h:r}}function TSe(n,e,t={}){const{handle:r,change:s,crop:i}=e,{w:o,h:a}=e.uncroppedSize,{minWidth:l=bN,minHeight:c=bN}=t,u=Xt(i),h=new k(n.x,n.y),p=new k(0,0);let m=!1;switch(r){case"top":case"top_left":case"top_right":{if(a<c)break;m=!0,u.topLeft.y=u.topLeft.y+s.y/a,a*(u.bottomRight.y-u.topLeft.y)<c?(u.topLeft.y=u.bottomRight.y-c/a,p.y=(u.topLeft.y-i.topLeft.y)*a):u.topLeft.y<=0?(u.topLeft.y=0,p.y=(u.topLeft.y-i.topLeft.y)*a):p.y=s.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(a<c)break;m=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+s.y/a),a*(u.bottomRight.y-u.topLeft.y)<c&&(u.bottomRight.y=u.topLeft.y+c/a);break}}switch(r){case"left":case"top_left":case"bottom_left":{if(o<l)break;m=!0,u.topLeft.x=u.topLeft.x+s.x/o,o*(u.bottomRight.x-u.topLeft.x)<l?(u.topLeft.x=u.bottomRight.x-l/o,p.x=(u.topLeft.x-i.topLeft.x)*o):u.topLeft.x<=0?(u.topLeft.x=0,p.x=(u.topLeft.x-i.topLeft.x)*o):p.x=s.x;break}case"right":case"top_right":case"bottom_right":{if(o<l)break;m=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+s.x/o),o*(u.bottomRight.x-u.topLeft.x)<l&&(u.bottomRight.x=u.topLeft.x+l/o);break}}if(m)return h.add(p.rot(n.rotation)),{id:n.id,type:n.type,x:h.x,y:h.y,props:{w:(u.bottomRight.x-u.topLeft.x)*o,h:(u.bottomRight.y-u.topLeft.y)*a,crop:u}}}function b7({shapeId:n,assetId:e,width:t}){const r=te(),s=Xp(),i=lie(),[o,a]=P.useState(()=>({asset:e?r.getAsset(e)??null:null,url:null})),l=P.useRef(!1),c=P.useRef(null);return P.useEffect(()=>{if(!e)return;let u=!1,h;const p=Pi("update state",()=>{if(!s&&n&&r.getCulledShapes().has(n))return;const m=r.getAsset(e);if(!m){a(v=>({...v,asset:null,url:null}));return}if(!m.props.src){const v=r.getTemporaryAssetPreview(m.id);if(v){c.current!==v&&(c.current=v,a(w=>({...w,isPlaceholder:!0,url:v})),i());return}}const S=s?s.scale*(t/m.props.w):r.getZoomLevel()*(t/m.props.w);function x(v,w){u||c.current!==w&&(l.current=!0,c.current=w,a({asset:v,url:w}),i())}if(l.current){let v=0;const w=()=>{v++,v>500/16&&(CN(r,e,S,s,C=>x(m,C)),h==null||h())};h==null||h(),r.on("tick",w),h=()=>r.off("tick",w)}else CN(r,e,S,s,v=>x(m,v))});return()=>{p(),h==null||h(),u=!0}},[r,e,s,i,n,t]),o}function CN(n,e,t,r,s){n.resolveAssetUrl(e,{screenScale:t,shouldResolveToOriginal:r?r.pixelRatio===null:!1,dpr:(r==null?void 0:r.pixelRatio)??void 0}).then(i=>{s(i)})}async function MSe(n){const t=await(await Zi(n)).blob();return Kr.blobToDataUrl(t)}const ASe=new qo;class Dy extends gh{isAspectRatioLocked(){return!0}canCrop(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null,flipX:!1,flipY:!1,altText:""}}getAriaDescriptor(e){return e.props.altText}onResize(e,t){let r=uv(e,t);const{flipX:s,flipY:i}=t.initialShape.props,{scaleX:o,scaleY:a,mode:l}=t;if(r={...r,props:{...r.props,flipX:o<0!==s,flipY:a<0!==i}},!e.props.crop)return r;const c=l==="scale_shape"&&o===-1||l==="resize_bounds"&&s!==r.props.flipX,u=l==="scale_shape"&&a===-1||l==="resize_bounds"&&i!==r.props.flipY,{topLeft:h,bottomRight:p}=e.props.crop;return r.props.crop={topLeft:{x:c?1-p.x:h.x,y:u?1-p.y:h.y},bottomRight:{x:c?1-h.x:p.x,y:u?1-h.y:p.y}},r}component(e){return g.jsx(OSe,{shape:e})}indicator(e){return this.editor.getCroppingShapeId()===e.id?null:g.jsx("rect",{width:re(e.props.w),height:re(e.props.h)})}async toSvg(e,t){if(!e.props.assetId)return null;const r=this.editor.getAsset(e.props.assetId);if(!r)return null;const{w:s}=Ep(e.props,e.props.crop),i=await ASe.get(r,async()=>{let o=await t.resolveAssetUrl(r.id,s);if(!o)return null;if((o.startsWith("blob:")||o.startsWith("http")||o.startsWith("/")||o.startsWith("./"))&&(o=await MSe(o)||""),C7(this.editor,r.id)){const{promise:a}=k7(o);o=await a}return o});return i?g.jsx(RSe,{shape:e,src:i}):null}onDoubleClickEdge(e){const t=e.props;if(!t||this.editor.getCroppingShapeId()!==e.id)return;const r=Xt(t.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},{w:s,h:i}=Ep(e.props,r),o=new k(r.topLeft.x*s,r.topLeft.y*i).rot(e.rotation),a={id:e.id,type:e.type,x:e.x-o.x,y:e.y-o.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:s,h:i}};this.editor.updateShapes([a])}getInterpolatedProps(e,t,r){function s(i,o){var h,p,m,S;if(i.props.crop===null&&o.props.crop===null)return null;const a=((h=i.props.crop)==null?void 0:h.topLeft)||{x:0,y:0},l=((p=i.props.crop)==null?void 0:p.bottomRight)||{x:1,y:1},c=((m=o.props.crop)==null?void 0:m.topLeft)||{x:0,y:0},u=((S=o.props.crop)==null?void 0:S.bottomRight)||{x:1,y:1};return{topLeft:{x:yt(a.x,c.x,r),y:yt(a.y,c.y,r)},bottomRight:{x:yt(l.x,u.x,r),y:yt(l.y,u.y,r)}}}return{...r>.5?t.props:e.props,w:yt(e.props.w,t.props.w,r),h:yt(e.props.h,t.props.h,r),crop:s(e,t)}}}R(Dy,"type","image"),R(Dy,"props",j4),R(Dy,"migrations",L4);const OSe=P.memo(function({shape:e}){var C;const t=te(),{w:r}=Ep(e.props,e.props.crop),{asset:s,url:i}=b7({shapeId:e.id,assetId:e.props.assetId,width:r}),o=N6(),[a,l]=P.useState(""),[c,u]=P.useState(null),h=s&&C7(t,s.id);P.useEffect(()=>{if(i&&h){const{promise:_,cancel:E}=k7(i);return _.then(T=>{l(T),u(i)}),()=>{E()}}},[t,h,o,i]);const p=ie("show crop preview",()=>e.id===t.getOnlySelectedShapeId()&&t.getCroppingShapeId()===e.id&&t.isIn("select.crop"),[t,e.id]),m=o&&(((C=s==null?void 0:s.props.mimeType)==null?void 0:C.includes("video"))||h),S=P7(e),x=i===c?null:i,v=m?a:c;if(!i&&!(s!=null&&s.props.src))return g.jsxs(Ul,{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:[g.jsx("div",{className:$e("tl-image-container",s&&"tl-image-container-loading"),style:S,children:s?null:g.jsx(w7,{})}),"url"in e.props&&e.props.url&&g.jsx(Qd,{url:e.props.url})]});const w=h?"anonymous":void 0;return g.jsxs(g.Fragment,{children:[p&&v&&g.jsx("div",{style:S,children:g.jsx("img",{className:"tl-image",style:{...Jf(e),opacity:.1},crossOrigin:w,src:v,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1})}),g.jsxs(Ul,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h},children:[g.jsxs("div",{className:$e("tl-image-container"),style:S,children:[v&&g.jsx("img",{className:"tl-image",style:Jf(e),crossOrigin:w,src:v,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1},v),x&&g.jsx("img",{className:"tl-image",style:Jf(e),crossOrigin:w,src:x,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,onLoad:()=>u(x)},x)]}),e.props.url&&g.jsx(Qd,{url:e.props.url})]})]})});function C7(n,e){const t=e?n.getAsset(e):void 0;return t?"mimeType"in t.props&&Hs.isAnimatedImageType(t==null?void 0:t.props.mimeType)||"isAnimated"in t.props&&t.props.isAnimated:!1}function P7(n){const e=n.props.crop,t=e==null?void 0:e.topLeft;if(!t)return{width:n.props.w,height:n.props.h};const{w:r,h:s}=Ep(n.props,e),i=-t.x*r,o=-t.y*s;return{transform:`translate(${i}px, ${o}px)`,width:r,height:s}}function Jf(n,e){const{flipX:t,flipY:r}=n.props;if(!t&&!r)return;const s=`scale(${t?-1:1}, ${r?-1:1})`;return{transform:`${e?`translate(${t?e.width:0}px, ${r?e.height:0}px)`:""} ${s}`,transformOrigin:e?"0 0":"center center"}}function RSe({shape:n,src:e}){const t=vu(),r=P7(n),s=n.props.crop;if(r.transform&&s){const{transform:i,width:o,height:a}=r,l=(s.bottomRight.x-s.topLeft.x)*o,c=(s.bottomRight.y-s.topLeft.y)*a,u=[new k(0,0),new k(l,0),new k(l,c),new k(0,c)],h=Jf(n,{width:o,height:a});return g.jsxs(g.Fragment,{children:[g.jsx("defs",{children:g.jsx("clipPath",{id:t,children:g.jsx("polygon",{points:u.map(p=>`${p.x},${p.y}`).join(" ")})})}),g.jsx("g",{clipPath:`url(#${t})`,children:g.jsx("image",{href:e,width:o,height:a,style:h?{...h,transform:`${i} ${h.transform}`}:{transform:i}})})]})}else return g.jsx("image",{href:e,width:n.props.w,height:n.props.h,style:Jf(n,{width:n.props.w,height:n.props.h})})}function k7(n){let e=!1;return{promise:new Promise(r=>{const s=rp();s.onload=()=>{if(e)return;const i=document.createElement("canvas");i.width=s.width,i.height=s.height;const o=i.getContext("2d");o&&(o.drawImage(s,0,0),r(i.toDataURL()))},s.crossOrigin="anonymous",s.src=n}),cancel:()=>e=!0}}function I7(n){return{size:n,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function E7(n,e,t){const r=e.vertices,s=I7(t);return Vo(r,s)}function DSe(n,e,t){const r=I7(t);return tT(Rv(E7(n,e,t),r),r)}function jSe(n,e,t){const r=DSe(n,e,t);return XE(r)}function LSe(n,e,t){if(n.props.dash==="draw"){const r=E7(n,e,t);return uu(r)}return e.getSvgPathData()}function _7(n,e,t){let r=`M ${Ct(e[0])}L`,s=`M ${Ct(e[0])}L`;const i=t/3,o=t*2,a=oo(n);let l=e[0],c,u=e[0],h;const p=e.length;for(let m=0,S=p-1;m<S;m++){c=e[m+1],h=k.AddXY(e[m+1],a()*i,a()*i);const x=k.Sub(c,l),v=k.Len(x),w=k.Div(x,v).mul(Math.min(v/4,o)),C=k.Add(l,w),_=k.Add(c,w.neg()),E=k.Sub(h,u),T=k.Len(E),A=k.Div(E,T).mul(Math.min(T/4,o)),O=k.Add(u,A),D=k.Add(h,A.neg());m===S-1?(r+=`${Ct(C)}L ${Ct(c)}`,s+=`${Ct(O)}L ${Ct(h)}`):(r+=`${Ct(C)}L ${Ct(_)}Q ${Ct(c)}`,s+=`${Ct(O)}L ${Ct(D)}Q ${Ct(h)}`,l=c,u=h)}return[r,r+s]}const NSe=new qo;class jy extends eo{canTabTo(){return!1}hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsFg(){return!0}hideSelectionBoundsBg(){return!0}getDefaultProps(){const[e,t]=ip(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[t]:{id:t,index:t,x:.1,y:.1}},scale:1}}getGeometry(e){return Df(e)}getHandles(e){return NSe.get(e.props,()=>{const t=Df(e),r=Rf(e),s=r.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<r.length-1;i++){const o=sp(r[i].index,r[i+1].index),l=t.segments[i].midPoint();s.push({id:o,type:"create",index:o,x:l.x,y:l.y,canSnap:!0})}return s.sort(nr)})}onResize(e,t){const{scaleX:r,scaleY:s}=t;return{props:{points:rh(e.props.points,(i,{id:o,index:a,x:l,y:c})=>({id:o,index:a,x:l*r,y:c*s}))}}}onBeforeCreate(e){const{props:{points:t}}=e,r=Object.keys(t);if(r.length<2)return;const s=t[r[0]];if(r.every(o=>{const a=t[o];return a.x===s.x&&a.y===s.y})){const o=r[r.length-1];return t[o]={...t[o],x:t[o].x+.1,y:t[o].y+.1},e}}onHandleDrag(e,{handle:t}){if(t.type!=="vertex")return;const r=ro(new k(t.x,t.y),this.editor);return{...e,props:{...e.props,points:{...e.props.points,[t.id]:{id:t.id,index:t.index,x:r.x,y:r.y}}}}}component(e){return g.jsx(Gl,{style:{minWidth:50,minHeight:50},children:g.jsx(PN,{shape:e})})}indicator(e){const t=No[e.props.size]*e.props.scale,r=Df(e),{dash:s}=e.props;let i;if(e.props.spline==="line"){const o=r.points;if(s==="solid"||s==="dotted"||s==="dashed")i="M"+o[0]+"L"+o.slice(1);else{const[a]=_7(e.id,o,t);i=a}}else i=LSe(e,r,t);return g.jsx("path",{d:i})}toSvg(e){return g.jsx(PN,{shouldScale:!0,shape:e})}getHandleSnapGeometry(e){const t=Rf(e);return{points:t,getSelfSnapPoints:r=>{const s=this.getHandles(e).filter(i=>i.type==="vertex").findIndex(i=>i.id===r.id);return t.filter((i,o)=>Math.abs(o-s)>1).map(k.From)},getSelfSnapOutline:r=>{const s=this.getHandles(e).filter(o=>o.type==="vertex").findIndex(o=>o.id===r.id),i=Df(e).segments.filter((o,a)=>a!==s-1&&a!==s);return i.length?new Js({children:i}):null}}}getInterpolatedProps(e,t,r){const s=Rf(e),i=Rf(t),o=[],a=[];let l=f3;if(s.length>i.length)for(let c=0;c<s.length;c++)o[c]={...s[c]},i[c]===void 0?a[c]={...i[i.length-1],id:l}:a[c]={...i[c],id:l},l=Ro(l);else if(i.length>s.length)for(let c=0;c<i.length;c++)a[c]={...i[c]},s[c]===void 0?o[c]={...s[s.length-1],id:l}:o[c]={...s[c],id:l},l=Ro(l);else for(let c=0;c<i.length;c++)o[c]=s[c],a[c]=i[c];return{...r>.5?t.props:e.props,points:Object.fromEntries(o.map((c,u)=>{const h=a[u];return[c.id,{...c,x:yt(c.x,h.x,r),y:yt(c.y,h.y,r)}]})),scale:yt(e.props.scale,t.props.scale,r)}}}R(jy,"type","line"),R(jy,"props",N4),R(jy,"migrations",F4);function Rf(n){return Object.values(n.props.points).sort(nr)}function Df(n){const e=Rf(n).map(k.From);switch(n.props.spline){case"cubic":return new tle({points:e});case"line":return new Yp({points:e})}}function PN({shape:n,shouldScale:e=!1,forceSolid:t=!1}){const r=Mi(),s=Df(n),{dash:i,color:o,size:a}=n.props,l=1/n.props.scale,c=e?l:1,u=No[a]*n.props.scale;if(n.props.spline==="line"){if(i==="solid"){const h=s.points,p="M"+h[0]+"L"+h.slice(1);return g.jsx("path",{d:p,stroke:r[o].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}if(i==="dashed"||i==="dotted")return g.jsx("g",{stroke:r[o].solid,strokeWidth:u,transform:`scale(${c})`,children:s.segments.map((h,p)=>{const{strokeDasharray:m,strokeDashoffset:S}=t?{strokeDasharray:"none",strokeDashoffset:"none"}:Wi(h.length,u,{style:i,start:p>0?"outset":"none",end:p<s.segments.length-1?"outset":"none"});return g.jsx("path",{strokeDasharray:m,strokeDashoffset:S,d:h.getSvgPathData(!0),fill:"none"},p)})});if(i==="draw"){const h=s.points,[p,m]=_7(n.id,h,u);return g.jsx("path",{d:m,stroke:r[o].solid,strokeWidth:u,fill:"none",transform:`scale(${c})`})}}if(n.props.spline==="cubic"){const h=s.getSvgPathData();if(i==="solid")return g.jsx("path",{strokeWidth:u,stroke:r[o].solid,fill:"none",d:h,transform:`scale(${c})`});if(i==="dashed"||i==="dotted")return g.jsx("g",{stroke:r[o].solid,strokeWidth:u,transform:`scale(${c})`,children:s.segments.map((p,m)=>{const{strokeDasharray:S,strokeDashoffset:x}=Wi(p.length,u,{style:i,start:m>0?"outset":"none",end:m<s.segments.length-1?"outset":"none",forceSolid:t});return g.jsx("path",{strokeDasharray:S,strokeDashoffset:x,d:p.getSvgPathData(),fill:"none"},m)})});if(i==="draw")return g.jsx("path",{d:jSe(n,s,u),strokeWidth:1,stroke:r[o].solid,fill:r[o].solid,transform:`scale(${c})`})}}class Ly extends eo{constructor(){super(...arguments);R(this,"options",{resizeMode:"none"})}canEdit(){return!0}hideResizeHandles(){const{resizeMode:t}=this.options;switch(t){case"none":return!0;case"scale":return!1;default:throw An(t)}}isAspectRatioLocked(){return this.options.resizeMode==="scale"}hideSelectionBoundsFg(){return!1}getDefaultProps(){return{color:"black",richText:Ei(""),size:"m",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:0,url:"",scale:1}}getGeometry(t){const{labelHeight:r,labelWidth:s}=T7(this.editor,t),{scale:i}=t.props,o=r*i,a=s*i,l=Ot*i,c=sy(t);return new Js({children:[new Ho({width:l,height:c,isFilled:!0}),new Ho({x:t.props.align==="start"?0:t.props.align==="end"?l-a:(l-a)/2,y:t.props.verticalAlign==="start"?0:t.props.verticalAlign==="end"?c-o:(c-o)/2,width:a,height:o,isFilled:!0,isLabel:!0})]})}getHandles(t){const{scale:r}=t.props;if(this.editor.getInstanceState().isCoarsePointer)return[];const i=this.editor.getZoomLevel();if(i*r<.25)return[];const o=sy(t),a=Ot*r,l=Xme/i*r;return i*r<.5?[{id:"bottom",index:"a3",type:"clone",x:a/2,y:o+l}]:[{id:"top",index:"a1",type:"clone",x:a/2,y:-l},{id:"right",index:"a2",type:"clone",x:a+l,y:o/2},{id:"bottom",index:"a3",type:"clone",x:a/2,y:o+l},{id:"left",index:"a4",type:"clone",x:-l,y:o/2}]}onResize(t,r){const{resizeMode:s}=this.options;switch(s){case"none":return;case"scale":return aF(t,r);default:throw An(s)}}getText(t){return cu(this.editor,t.props.richText)}getFontFaces(t){return gE(this.editor,t.props.richText,{family:`tldraw_${t.props.font}`,weight:"normal",style:"normal"})}component(t){const{id:r,type:s,props:{labelColor:i,scale:o,color:a,font:l,size:c,align:u,richText:h,verticalAlign:p,fontSizeAdjustment:m}}=t,S=$Se(r),x=Mi(),v=Ot*o,w=sy(t),C=ie("shape rotation",()=>{var D;return((D=this.editor.getShapePageTransform(r))==null?void 0:D.rotation())??0},[this.editor]),_=ie("zoom",()=>this.editor.getZoomLevel()<.35/o,[o,this.editor]),E=ie("dark mode",()=>this.editor.user.getIsDarkMode(),[this.editor]),T=t.id===this.editor.getOnlySelectedShapeId(),A=mT(this.editor,t.id),O=Vi(h);return g.jsxs(g.Fragment,{children:[g.jsx("div",{id:r,className:"tl-note__container",style:{width:v,height:w,backgroundColor:x[a].note.fill,borderBottom:_?E?`${2*o}px solid rgb(20, 20, 20)`:`${2*o}px solid rgb(144, 144, 144)`:"none",boxShadow:_?"none":BSe(t.id,C,o)},children:(T||A||!O)&&g.jsx(CT,{shapeId:r,type:s,font:l,fontSize:(m||ja[c])*o,lineHeight:ar.lineHeight,align:u,verticalAlign:p,richText:h,isSelected:T,labelColor:i==="black"?x[a].note.text:x[i].fill,wrap:!0,padding:Ur*o,onKeyDown:S})}),"url"in t.props&&t.props.url&&g.jsx(Qd,{url:t.props.url})]})}indicator(t){const{scale:r}=t.props;return g.jsx("rect",{rx:r,width:re(Ot*r),height:re(sy(t))})}toSvg(t,r){const s=Va({isDarkMode:r.isDarkMode}),i=USe(t),o=g.jsx(PT,{fontSize:t.props.fontSizeAdjustment||ja[t.props.size],font:t.props.font,align:t.props.align,verticalAlign:t.props.verticalAlign,richText:t.props.richText,labelColor:s[t.props.color].note.text,bounds:i,padding:Ur*t.props.scale});return g.jsxs(g.Fragment,{children:[g.jsx("rect",{x:5,y:5,rx:1,width:Ot-10,height:i.h,fill:"rgba(0,0,0,.1)"}),g.jsx("rect",{rx:1,width:Ot,height:i.h,fill:s[t.props.color].note.fill}),o]})}onBeforeCreate(t){return kN(this.editor,t)}onBeforeUpdate(t,r){if(!(ch(t.props.richText,r.props.richText)&&t.props.font===r.props.font&&t.props.size===r.props.size))return kN(this.editor,r)}getInterpolatedProps(t,r,s){return{...s>.5?r.props:t.props,scale:yt(t.props.scale,r.props.scale,s)}}}R(Ly,"type","note"),R(Ly,"props",z4),R(Ly,"migrations",$4);function kN(n,e){const{labelHeight:t,fontSizeAdjustment:r}=T7(n,e),s=Math.max(0,t-Ot);if(s!==e.props.growY||r!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:s,fontSizeAdjustment:r}}}function FSe(n,e){const{richText:t}=e.props;if(Vi(t))return{labelHeight:ja[e.props.size]*ar.lineHeight+Ur*2,labelWidth:100,fontSizeAdjustment:0};const r=ja[e.props.size];let s=0,i=0,o=Ot,a=Ot;const l=1;do{s=Math.min(r,r-i);const c=p0(n,t),u=n.textMeasure.measureHtml(c,{...ar,fontFamily:Ba[e.props.font],fontSize:s,maxWidth:Ot-Ur*2-l,disableOverflowWrapBreaking:!0});if(o=u.h+Ur*2,a=u.w+Ur*2,s<=14){const h=p0(n,t),p=n.textMeasure.measureHtml(h,{...ar,fontFamily:Ba[e.props.font],fontSize:s,maxWidth:Ot-Ur*2-l});o=p.h+Ur*2,a=p.w+Ur*2;break}if(u.scrollWidth.toFixed(0)===u.w.toFixed(0))break}while(i++<50);return{labelHeight:o,labelWidth:a,fontSizeAdjustment:s}}const zSe=new qo;function T7(n,e){return zSe.get(e,()=>FSe(n,e))}function $Se(n){const e=te(),t=$6();return P.useCallback(r=>{const s=e.getShape(n);if(!s)return;const i=r.key==="Tab",o=(r.metaKey||r.ctrlKey)&&r.key==="Enter";if(i||o){r.preventDefault();const a=e.getShapePageTransform(n),l=a.rotation(),c=!!(t.dir==="rtl"||WU(cu(e,s.props.richText))),u=(Ot+e.options.adjacentShapeMargin+(o&&!r.shiftKey?s.props.growY:0))*s.props.scale,h=new k(i?r.shiftKey!=c?-1:1:0,o?r.shiftKey?-1:1:0).mul(u).add(jv.clone().mul(s.props.scale)).rot(l).add(a.point()),p=r7(e,s,h,l);p&&(e.markHistoryStoppingPoint("editing adjacent shape"),DS(e,p,!0))}},[n,e,t.dir])}function sy(n){return(Ot+n.props.growY)*n.props.scale}function BSe(n,e,t){const r=oo(n),s=Math.abs(r())+.5,i=Math.cos(e),o=5*t,a=4*t,l=6*t,c=7*t;return`0px ${o-s}px ${o}px -${o}px rgba(15, 23, 31, .6),
|
|
482
|
-
0px ${(a+s*c)*Math.max(0,i)}px ${l+s*c}px -${a+s*l}px rgba(15, 23, 31, ${(.3+s*.1).toFixed(2)}),
|
|
483
|
-
0px ${48*t}px ${10*t}px -${10*t}px inset rgba(15, 23, 44, ${((.022+r()*.005)*((1+i)/2)).toFixed(2)})`}function USe(n){return new Se(0,0,Ot,Ot+n.props.growY)}const HSe=_E("text size",(n,e)=>(n.fonts.trackFontsForShape(e),M7(n,e.props)),{areRecordsEqual:(n,e)=>n.props===e.props});class Ny extends eo{constructor(){super(...arguments);R(this,"options",{extraArrowHorizontalPadding:10})}getDefaultProps(){return{color:"black",size:"m",w:8,font:"draw",textAlign:"start",autoSize:!0,scale:1,richText:Ei("")}}getMinDimensions(t){return HSe.get(this.editor,t.id)}getGeometry(t,r){const{scale:s}=t.props,{width:i,height:o}=this.getMinDimensions(t),a=(r==null?void 0:r.context)??"none";return new Ho({x:(a==="@tldraw/arrow-start"?-this.options.extraArrowHorizontalPadding:0)*s,width:(i+(a==="@tldraw/arrow-start"?this.options.extraArrowHorizontalPadding*2:0))*s,height:o*s,isFilled:!0,isLabel:!0})}getFontFaces(t){return gE(this.editor,t.props.richText,{family:`tldraw_${t.props.font}`,weight:"normal",style:"normal"})}getText(t){return cu(this.editor,t.props.richText)}canEdit(){return!0}isAspectRatioLocked(){return!0}component(t){const{id:r,props:{font:s,size:i,richText:o,color:a,scale:l,textAlign:c}}=t,{width:u,height:h}=this.getMinDimensions(t),p=t.id===this.editor.getOnlySelectedShapeId(),m=Mi(),S=KSe(r);return g.jsx(CT,{shapeId:r,classNamePrefix:"tl-text-shape",type:"text",font:s,fontSize:Zd[i],lineHeight:ar.lineHeight,align:c,verticalAlign:"middle",richText:o,labelColor:m[a].solid,isSelected:p,textWidth:u,textHeight:h,style:{transform:`scale(${l})`,transformOrigin:"top left"},wrap:!0,onKeyDown:S})}indicator(t){const r=this.editor.getShapeGeometry(t).bounds,s=te();return t.props.autoSize&&s.getEditingShapeId()===t.id?null:g.jsx("rect",{width:re(r.width),height:re(r.height)})}toSvg(t,r){const s=this.editor.getShapeGeometry(t).bounds,i=s.width/(t.props.scale??1),o=s.height/(t.props.scale??1),a=Va(r),l=new Se(0,0,i,o);return g.jsx(PT,{fontSize:Zd[t.props.size],font:t.props.font,align:t.props.textAlign,verticalAlign:"middle",richText:t.props.richText,labelColor:a[t.props.color].solid,bounds:l,padding:0})}onResize(t,r){const{newPoint:s,initialBounds:i,initialShape:o,scaleX:a,handle:l}=r;if(r.mode==="scale_shape"||l!=="right"&&l!=="left")return{id:t.id,type:t.type,...aF(t,r)};{const c=Math.max(1,Math.abs(i.width*a)),{x:u,y:h}=a<0?k.Sub(s,k.FromAngle(t.rotation).mul(c)):s;return{id:t.id,type:t.type,x:u,y:h,props:{w:c/o.props.scale,autoSize:!1}}}}onEditEnd(t){cu(this.editor,t.props.richText).trimEnd().length===0&&this.editor.deleteShapes([t.id])}onBeforeUpdate(t,r){if(!r.props.autoSize)return;const s=t.props.size!==r.props.size||t.props.textAlign!==r.props.textAlign||t.props.font!==r.props.font||t.props.scale!==1&&r.props.scale===1,i=!ch(t.props.richText,r.props.richText);if(!s&&!i)return;const o=this.getMinDimensions(t),a=M7(this.editor,r.props),l=o.width*t.props.scale,c=o.height*t.props.scale,u=a.width*r.props.scale,h=a.height*r.props.scale;let p;switch(r.props.textAlign){case"middle":{p=new k((u-l)/2,i?0:(h-c)/2);break}case"end":{p=new k(u-l,i?0:(h-c)/2);break}default:{if(i)break;p=new k(0,(h-c)/2);break}}if(p){p.rot(r.rotation);const{x:m,y:S}=r;return{...r,x:m-p.x,y:S-p.y,props:{...r.props,w:u}}}else return{...r,props:{...r.props,w:u}}}}R(Ny,"type","text"),R(Ny,"props",B4),R(Ny,"migrations",U4);function M7(n,e){const{font:t,richText:r,autoSize:s,size:i,w:o}=e,a=s?16:Math.max(16,o),l=Zd[i],c=s?null:Math.floor(Math.max(a,o)),u=p0(n,r),h=n.textMeasure.measureHtml(u,{...ar,fontFamily:Ba[t],fontSize:l,maxWidth:c});return s&&(h.w+=1),{width:Math.max(a,h.w),height:Math.max(l,h.h)}}function KSe(n){const e=te();return P.useCallback(t=>{if(e.getEditingShapeId()===n)switch(t.key){case"Enter":{(t.ctrlKey||t.metaKey)&&e.complete();break}}},[e,n])}const WSe=new qo;class Fy extends gh{canEdit(){return!0}isAspectRatioLocked(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:"",altText:""}}getAriaDescriptor(e){return e.props.altText}component(e){return g.jsx(VSe,{shape:e})}indicator(e){return g.jsx("rect",{width:re(e.props.w),height:re(e.props.h)})}async toSvg(e,t){if(!e.props.assetId)return null;const r=this.editor.getAsset(e.props.assetId);if(!r)return null;const s=await WSe.get(r,async()=>{const i=await t.resolveAssetUrl(r.id,e.props.w);if(!i)return null;const o=await Hs.loadVideo(i);return await Hs.getVideoFrameAsDataUrl(o,0)});return s?g.jsx("image",{href:s,width:e.props.w,height:e.props.h}):null}}R(Fy,"type","video"),R(Fy,"props",H4),R(Fy,"migrations",K4);const VSe=P.memo(function({shape:e}){const t=te(),r=t.getShapeGeometry(e).bounds.w*t.getZoomLevel()>=110,s=dv(e.id),i=N6(),{Spinner:o}=Zt(),{asset:a,url:l}=b7({shapeId:e.id,assetId:e.props.assetId,width:e.props.w}),c=P.useRef(null),[u,h]=P.useState(!1),[p,m]=P.useState(!1);P.useEffect(()=>{const x=()=>m(document.fullscreenElement===c.current);return document.addEventListener("fullscreenchange",x),()=>document.removeEventListener("fullscreenchange",x)});const S=P.useCallback(x=>{x.currentTarget&&h(!0)},[]);return P.useEffect(()=>{const x=c.current;x&&s&&document.activeElement!==x&&x.focus()},[s,u]),P.useEffect(()=>{if(i){const x=c.current;if(!x)return;x.pause(),x.currentTime=0}},[c,i]),g.jsxs(g.Fragment,{children:[g.jsx(Ul,{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:g.jsx("div",{className:"tl-counter-scaled",children:g.jsx("div",{className:"tl-video-container",children:a?o&&!a.props.src?g.jsx(o,{}):l?g.jsxs(g.Fragment,{children:[g.jsx("video",{ref:c,style:s?{pointerEvents:"all"}:u?void 0:{display:"none"},className:$e("tl-video",`tl-video-shape-${e.id.split(":")[1]}`,{"tl-video-is-fullscreen":p}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:s&&r,onLoadedData:S,hidden:!u,children:g.jsx("source",{src:l})}),!u&&o&&g.jsx(o,{})]}):null:g.jsx(w7,{})})})}),"url"in e.props&&e.props.url&&g.jsx(Qd,{url:e.props.url})]})}),A7=[Ny,Ty,My,Oy,Ly,jy,Ay,_y,Ry,S0,Dy,Fy];function qSe(n){return n.sideEffects.register({instance_page_state:{afterChange:(e,t)=>{if(e.croppingShapeId!==t.croppingShapeId){const r=n.isIn("select.crop");!e.croppingShapeId&&t.croppingShapeId?r||n.setCurrentTool("select.crop.idle"):e.croppingShapeId&&!t.croppingShapeId&&r&&n.setCurrentTool("select.idle")}if(e.editingShapeId!==t.editingShapeId)if(!e.editingShapeId&&t.editingShapeId){if(!n.isIn("select.editing_shape")){const r=n.getEditingShape();r&&r.type==="text"&&n.isInAny("text.pointing","select.resizing")&&n.getInstanceState().isToolLocked?n.setCurrentTool("select.editing_shape",{isCreatingTextWhileToolLocked:!0}):n.setCurrentTool("select.editing_shape")}}else e.editingShapeId&&!t.editingShapeId&&n.isIn("select.editing_shape")&&n.setCurrentTool("select.idle")}}})}class O7 extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"scribbleId","id");R(this,"markId","");R(this,"excludedShapeIds",new Set)}onEnter(t){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=t;const{originPagePoint:r}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(i=>{if(this.editor.isShapeOrAncestorLocked(i))return!0;if(this.editor.isShapeOfType(i,"group")||this.editor.isShapeOfType(i,"frame")){const o=this.editor.getPointInShapeSpace(i,r);return this.editor.getShapeGeometry(i).bounds.containsPoint(o)}return!1}).map(i=>i.id));const s=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=s.id,this.update()}pushPointToScribble(){const{x:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,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:t,excludedShapeIds:r}=this,s=t.getErasingShapeIds(),i=t.getZoomLevel(),o=t.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:a,previousPagePoint:l}}=t;this.pushPointToScribble();const c=new Set(s),u=this.editor.options.hitTestMargin/i;for(const h of o){if(t.isShapeOfType(h,"group"))continue;const p=t.getShapeMask(h.id);if(p&&!qs(a,p))continue;const m=t.getShapeGeometry(h),S=t.getShapePageTransform(h);if(!m||!S)continue;const x=S.clone().invert(),v=x.applyToPoint(l),w=x.applyToPoint(a),{bounds:C}=m;C.minX-u>Math.max(v.x,w.x)||C.minY-u>Math.max(v.y,w.y)||C.maxX+u<Math.min(v.x,w.x)||C.maxY+u<Math.min(v.y,w.y)||m.hitTestLineSegment(v,w,u)&&c.add(t.getOutermostSelectableShape(h).id)}this.editor.setErasingShapes([...c].filter(h=>!r.has(h)))}complete(){const{editor:t}=this;t.deleteShapes(t.getCurrentPageState().erasingShapeIds),this.parent.transition("idle")}cancel(){const{editor:t}=this;t.bailToMark(this.markId),this.parent.transition("idle",this.info)}}R(O7,"id","erasing");var bP;let GSe=(bP=class extends De{onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},R(bP,"id","idle"),bP);var CP;let YSe=(CP=class extends De{onEnter(){const e=this.editor.getZoomLevel(),t=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:r}}=this.editor,s=new Set,i=s.size;for(let o=t.length,a=o-1;a>=0;a--){const l=t[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>i)break;s.add(c.id)}}this.editor.setErasingShapes([...s])}onLongPress(e){this.startErasing(e)}onExit(e,t){t!=="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")}},R(CP,"id","pointing"),CP);class zy extends De{static children(){return[GSe,YSe,O7]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}R(zy,"id","eraser"),R(zy,"initial","idle"),R(zy,"isLockable",!1);class R7 extends De{constructor(){super(...arguments);R(this,"initialCamera",new k)}onEnter(){this.initialCamera=k.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){const{initialCamera:t,editor:r}=this,{currentScreenPoint:s,originScreenPoint:i}=r.inputs,o=k.Sub(s,i).div(r.getZoomLevel());o.len2()!==0&&r.setCamera(t.clone().add(o))}complete(){const{editor:t}=this,{pointerVelocity:r}=t.inputs,s=Math.min(r.len(),2);s>.1&&this.editor.slideCamera({speed:s,direction:r}),this.parent.transition("idle")}}R(R7,"id","dragging");var PP;let XSe=(PP=class extends De{onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},R(PP,"id","idle"),PP);var kP;let ZSe=(kP=class extends De{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")}},R(kP,"id","pointing"),kP);class $y extends De{static children(){return[XSe,ZSe,R7]}onDoubleClick(e){if(e.phase==="settle"){const{currentScreenPoint:t}=this.editor.inputs;this.editor.zoomIn(t,{animation:{duration:220,easing:Hn.easeOutQuint}})}}onTripleClick(e){if(e.phase==="settle"){const{currentScreenPoint:t}=this.editor.inputs;this.editor.zoomOut(t,{animation:{duration:320,easing:Hn.easeOutQuint}})}}onQuadrupleClick(e){if(e.phase==="settle"){const t=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:r}}=this.editor;t===1?this.editor.zoomToFit({animation:{duration:400,easing:Hn.easeOutQuint}}):this.editor.resetZoom(r,{animation:{duration:320,easing:Hn.easeOutQuint}})}}}R($y,"id","hand"),R($y,"initial","idle"),R($y,"isLockable",!1);var IP;let JSe=(IP=class extends De{onPointerDown(e){this.parent.transition("lasering",e)}},R(IP,"id","idle"),IP);class D7 extends De{constructor(){super(...arguments);R(this,"scribbleId","id")}onEnter(){const t=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:this.editor.options.laserDelayMs,shrink:.05,taper:!0});this.scribbleId=t.id,this.pushPointToScribble()}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.pushPointToScribble()}onPointerUp(){this.complete()}pushPointToScribble(){const{x:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,r)}onCancel(){this.cancel()}onComplete(){this.complete()}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}R(D7,"id","lasering");class By extends De{static children(){return[JSe,D7]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}R(By,"id","laser"),R(By,"initial","idle"),R(By,"isLockable",!1);class j7 extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"initialSelectedShapeIds",[]);R(this,"excludedShapeIds",new Set);R(this,"isWrapMode",!1);R(this,"initialStartShape",null)}onEnter(t){const{altKey:r,currentPagePoint:s}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),r){this.parent.transition("scribble_brushing",t);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(i=>this.editor.isShapeOfType(i,"group")||this.editor.isShapeOrAncestorLocked(i)).map(i=>i.id)),this.info=t,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:t}){const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(t)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(t){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",t)}onKeyDown(t){this.editor.inputs.altKey?this.parent.transition("scribble_brushing",t):this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:t,excludedShapeIds:r,isWrapMode:s}=this,{inputs:{originPagePoint:i,currentPagePoint:o,shiftKey:a,ctrlKey:l}}=t,c=new Set(a?this.initialSelectedShapeIds:[]),u=s?!l:l,h=Se.FromPoints([i,o]),{corners:p}=h;let m,S,x,v,w,C;const _=t.getCurrentPageRenderingShapesSorted(),E=t.getCurrentPageId();e:for(let O=0,D=_.length;O<D;O++){if(x=_[O],r.has(x.id)||c.has(x.id)||(v=t.getShapePageBounds(x),!v))continue e;if(h.contains(v)){this.handleHit(x,o,E,c,p);continue e}if(u||t.isShapeOfType(x,"frame"))continue e;if(h.collides(v)){if(w=t.getShapePageTransform(x),!w)continue e;C=w.clone().invert().applyToPoints(p);const $=t.getShapeGeometry(x);t:for(let H=0;H<4;H++)if(m=C[H],S=C[(H+1)%4],$.hitTestLineSegment(m,S,0)){this.handleHit(x,o,E,c,p);break t}}}const T=t.getInstanceState().brush;(!T||!h.equals(T))&&t.updateInstanceState({brush:{...h.toJson()}});const A=t.getSelectedShapeIds();(A.length!==c.size||A.some(O=>!c.has(O)))&&t.setSelectedShapes(Array.from(c))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(t,r,s,i,o){if(t.parentId===s){i.add(t.id);return}const a=this.editor.getOutermostSelectableShape(t),l=this.editor.getShapeMask(a.id);l&&!GE(l,o)&&!qs(r,l)||i.add(a.id)}}R(j7,"id","brushing");const th={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 L7 extends De{constructor(){super(...arguments);R(this,"info",{})}updateCursor(){const t=this.editor.getSelectedShapes(),r=th[this.info.handle];this.editor.setCursor({type:r,rotation:t.length===1?this.editor.getSelectionRotation():0})}onEnter(t){this.info=t,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")}}R(L7,"id","pointing_resize_handle");class IT extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"markId","");R(this,"snapshot",{})}onEnter(t){this.info=t,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=th[this.info.handle];this.editor.setCursor({type:r,rotation:this.editor.getSelectionRotation()})}updateShapes(){var p;const{shape:t,cursorHandleOffset:r}=this.snapshot;if(!t)return;const s=this.editor.getShapeUtil(t.type);if(!s)return;const i=this.editor.inputs.currentPagePoint.clone().sub(r),o=this.editor.inputs.originPagePoint.clone().sub(r),a=i.clone().sub(o).rot(-t.rotation),l=t.props.crop??_Se(),c={w:1/(l.bottomRight.x-l.topLeft.x)*t.props.w,h:1/(l.bottomRight.y-l.topLeft.y)*t.props.h},h=(((p=s.onCrop)==null?void 0:p.bind(s))??TSe)(t,{handle:this.info.handle,change:a,crop:l,uncroppedSize:c,initialShape:this.snapshot.shape});h&&(this.editor.updateShapes([{id:t.id,type:t.type,...h}]),this.updateCursor())}complete(){this.updateShapes(),Ht(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 t=this.editor.getSelectionRotation(),{inputs:{originPagePoint:r}}=this.editor,s=this.editor.getOnlySelectedShape(),i=this.editor.getSelectionRotatedPageBounds(),o=k.RotWith(i.getHandlePoint(this.info.handle),i.point,t),a=k.Sub(r,o);return{shape:s,cursorHandleOffset:a}}}R(IT,"id","cropping");function ET(n,e=!1){const t=n.getZoomLevel(),{inputs:{currentPagePoint:r}}=n;return n.getShapeAtPoint(r,{hitInside:!1,hitLabels:e,margin:n.options.hitTestMargin/t,renderingOnly:!0})??n.getSelectedShapeAtPoint(r)}function N7(n,e,t){if(!e)throw Error("Needs to translate a cropped shape!");const{crop:r}=e.props;if(!r)return;const s=n.inputs.shiftKey?Math.abs(t.x)<Math.abs(t.y)?"x":"y":null;s==="x"?t.x=0:s==="y"&&(t.y=0),t.rot(-e.rotation);const{w:i,h:o}=Ep(e.props,r),a=r.bottomRight.y-r.topLeft.y,l=r.bottomRight.x-r.topLeft.x,c=Xt(r);return c.topLeft.x=Math.min(1-l,Math.max(0,c.topLeft.x-t.x/i)),c.topLeft.y=Math.min(1-a,Math.max(0,c.topLeft.y-t.y/o)),c.bottomRight.x=c.topLeft.x+l,c.bottomRight.y=c.topLeft.y+a,{id:e.id,type:e.type,props:{crop:c}}}var EP;let QSe=(EP=class extends De{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 t;if(e.accelKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{const r=ET(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(t=this.editor.getShapeUtil(e.shape))!=null&&t.canCrop(e.shape)?(this.editor.setCroppingShape(e.shape.id),this.editor.setSelectedShapes([e.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",e)):(this.cancel(),this.editor.root.handleEvent(e));break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...e,onInteractionEnd:"select.crop.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...e,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}onDoubleClick(e){var i;if(this.editor.inputs.shiftKey||e.phase!=="up")return;const t=this.editor.getCroppingShapeId();if(!t)return;const r=this.editor.getShape(t);if(!r)return;const s=this.editor.getShapeUtil(r);if(s){if(e.target==="selection"){(i=s.onDoubleClickEdge)==null||i.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:t}}}=this,r=t.has("ShiftLeft"),s=new k(0,0);if(t.has("ArrowLeft")&&(s.x+=1),t.has("ArrowRight")&&(s.x-=1),t.has("ArrowUp")&&(s.y+=1),t.has("ArrowDown")&&(s.y-=1),s.equals(new k(0,0)))return;r&&s.mul(10);const i=this.editor.getShape(this.editor.getCroppingShapeId());if(!i)return;const o=N7(this.editor,i,s);o&&(e||this.editor.markHistoryStoppingPoint("translate crop"),this.editor.updateShapes([o]))}},R(EP,"id","idle"),EP);class F7 extends De{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)}}R(F7,"id","pointing_crop");class _T extends De{constructor(){super(...arguments);R(this,"info",{})}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];if(!r)return;const s=th[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"))}}R(_T,"id","pointing_crop_handle");class z7 extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"markId","");R(this,"snapshot",{})}onEnter(t){this.info=t,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(t){switch(t.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(t){switch(t.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 t=this.snapshot.shape;if(!t)return;const{originPagePoint:r,currentPagePoint:s}=this.editor.inputs,i=s.clone().sub(r),o=N7(this.editor,t,i);o&&this.editor.updateShapes([o])}}R(z7,"id","translating_crop");class dI extends De{constructor(){super(...arguments);R(this,"markId","");R(this,"didExit",!1)}static children(){return[QSe,z7,F7,_T,IT]}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))}}R(dI,"id","crop"),R(dI,"initial","idle");class $7 extends De{constructor(){super(...arguments);R(this,"shapeId","");R(this,"initialHandle",{});R(this,"initialAdjacentHandle",null);R(this,"initialPagePoint",{});R(this,"markId","");R(this,"initialPageTransform");R(this,"initialPageRotation");R(this,"info",{});R(this,"isPrecise",!1);R(this,"isPreciseId",null);R(this,"pointingId",null);R(this,"exactTimeout",-1)}onEnter(t){const{shape:r,isCreating:s,creatingMarkId:i,handle:o}=t;if(this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.shapeId=r.id,this.markId="",s)if(i)this.markId=i;else{const c=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);c&&(this.markId=c)}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");if(this.initialHandle=Xt(o),this.editor.isShapeOfType(r,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...r,props:{points:{...r.props.points,[o.index]:{id:o.index,index:o.index,x:o.x,y:o.y}}}});const u=this.editor.getShapeHandles(r).find(h=>h.index===o.index);this.initialHandle=Xt(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(nr),l=a.findIndex(c=>c.id===t.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!==t.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!==t.handle.id){this.initialAdjacentHandle=u;break}}if(this.editor.isShapeOfType(r,"arrow")){const c=Hr(this.editor,r)[t.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(),Ht(this.editor,[this.shapeId]);const{onInteractionEnd:t}=this.info;if(this.editor.getInstanceState().isToolLocked&&t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:t}=this.info;if(t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var O;const{editor:t,shapeId:r,initialPagePoint:s}=this,{initialHandle:i,initialPageRotation:o,initialAdjacentHandle:a}=this,l=this.editor.getHintingShapeIds(),c=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:h,shiftKey:p,ctrlKey:m,altKey:S,pointerVelocity:x}}=t,v=this.info.shape,w=t.getShape(r);if(!w)return;const C=t.getShapeUtil(w);let _=h.clone().sub(s).rot(-o).add(i);if(p&&a&&i.id!=="middle"){const D=k.Angle(a,_),H=Zy(D,24)-D;_=k.RotWith(_,a,H)}t.snaps.clearIndicators();let E={...i,x:_.x,y:_.y};if(i.canSnap&&(c?!m:m)){if(!t.getShapePageTransform(w.id))throw Error("Expected a page transform");const $=u.handles.snapHandle({currentShapeId:r,handle:E});$&&($.nudge.rot(-t.getShapeParentTransform(w).rotation()),_.add($.nudge),E={...i,x:_.x,y:_.y})}const T=(O=C.onHandleDrag)==null?void 0:O.call(C,w,{handle:E,isPrecise:this.isPrecise||S,initial:v}),A={id:w.id,type:w.type,...T};if(i.type==="vertex"&&this.editor.isShapeOfType(w,"arrow")){const D=Hr(t,w)[i.id];D?l[0]!==D.toId&&(t.setHintingShapes([D.toId]),this.pointingId=D.toId,this.isPrecise=x.len()<.5||S,this.isPreciseId=this.isPrecise?D.toId:null,this.resetExactTimeout()):l.length>0&&(t.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}T&&t.updateShapes([A])}}R($7,"id","dragging_handle");function B7(n){return n.isLabel?[n]:n instanceof Js?n.children.filter(e=>e.isLabel):[]}class U7 extends De{constructor(){super(...arguments);R(this,"hitShapeForPointerUp",null);R(this,"info",{})}onEnter(t){const r=this.editor.getEditingShape();if(!r)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,this.info=t,t.isCreatingTextWhileToolLocked&&this.parent.setCurrentToolIdMask("text"),Ea(this.editor),this.editor.select(r)}onExit(){var i;const{editingShapeId:t}=this.editor.getCurrentPageState();if(!t)return;this.editor.setEditingShape(null),Ea.cancel();const r=this.editor.getShape(t),s=this.editor.getShapeUtil(r);(i=s.onEditEnd)==null||i.call(s,r),this.info.isCreatingTextWhileToolLocked&&(this.parent.setCurrentToolIdMask(void 0),this.editor.setCurrentTool("text",{}))}onPointerMove(t){if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly()||this.hitShapeForPointerUp.isLocked)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",t),this.hitShapeForPointerUp=null;return}switch(t.target){case"shape":case"canvas":{Ea(this.editor);return}}}onPointerDown(t){switch(this.hitShapeForPointerUp=null,t.target){case"canvas":{const r=ET(this.editor,!0);if(r){this.onPointerDown({...t,shape:r,target:"shape"});return}break}case"shape":{const{shape:r}=t,s=this.editor.getEditingShape();if(!s)throw Error("Expected an editing shape!");const i=this.editor.getShapeUtil(r).getGeometry(r),o=B7(i),a=o.length===1?o[0]:void 0,l=this.editor.isShapeOfType(s,"text")&&cu(this.editor,s.props.richText).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",t));else{this.parent.transition("pointing_shape",t);return}return}break}}this.parent.transition("idle",t),this.editor.root.handleEvent(t)}onPointerUp(t){const r=this.hitShapeForPointerUp;if(!r)return;this.hitShapeForPointerUp=null;const s=this.editor.getShapeUtil(r);if(r.isLocked)return;if(this.editor.getIsReadonly()&&!s.canEditInReadOnly(r)){this.parent.transition("pointing_shape",t);return}this.editor.select(r.id);const i=this.editor.getEditingShape(),o=i&&i.id!==r.id;this.editor.setEditingShape(r.id);const a=It.isIos||It.isAndroid;!a||!o?this.editor.emit("place-caret",{shapeId:r.id,point:t.point}):a&&o&&this.editor.emit("select-all-text",{shapeId:r.id}),Ea(this.editor)}onComplete(t){this.parent.transition("idle",t)}onCancel(t){this.parent.transition("idle",t)}}R(U7,"id","editing_shape");function IN(n){const e=n.getOnlySelectedShape();return!!(e&&!n.isShapeOrAncestorLocked(e)&&n.getShapeUtil(e).canCrop(e))}function v0(n,e){const t=n.getSelectedShapeIds(),{currentPagePoint:r}=n.inputs,{shiftKey:s,altKey:i,accelKey:o}=e,a=s||o,l=n.getShapeAtPoint(r,{hitInside:!1,margin:n.options.hitTestMargin/n.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:c=>!c.isLocked});if(l){const c=n.getOutermostSelectableShape(l);if(a&&!i)n.cancelDoubleClick(),t.includes(c.id)?(n.markHistoryStoppingPoint("deselecting shape"),n.deselect(c)):(n.markHistoryStoppingPoint("shift selecting shape"),n.setSelectedShapes([...t,c.id]));else{let u;c===l||c.id===n.getFocusedGroupId()||t.includes(c.id)?u=l:u=c,u&&!t.includes(u.id)&&(n.markHistoryStoppingPoint("selecting shape"),n.select(u.id))}}else{if(a)return;{t.length>0&&(n.markHistoryStoppingPoint("selecting none"),n.selectNone());const c=n.getFocusedGroupId();if(ws(c)){const u=n.getShape(c);n.isPointInShape(u,r,{margin:0,hitInside:!0})||n.setFocusedGroup(null)}}}}const e0e=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var _P;let t0e=(_P=class extends De{onEnter(){this.parent.setCurrentToolIdMask(void 0),Ea(this.editor),this.editor.setCursor({type:"default",rotation:0})}onExit(){Ea.cancel()}onPointerMove(){Ea(this.editor)}onPointerDown(e){const t=e.ctrlKey&&IN(this.editor);switch(e.target){case"canvas":{const r=ET(this.editor);if(r&&!r.isLocked){this.onPointerDown({...e,shape:r,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:o}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&EN(this.editor,o)){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(t)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 t,r,s,i;if(!(this.editor.inputs.shiftKey||e.phase!=="up")&&!(e.ctrlKey||e.shiftKey))switch(e.target){case"canvas":{const o=this.editor.getHoveredShape(),a=o&&!this.editor.isShapeOfType(o,"group")?o: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")){v0(this.editor,e);return}else{const c=this.editor.getShape(a.parentId);if(c&&this.editor.isShapeOfType(c,"group")&&!(l&&c.id===l)){v0(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 o=this.editor.getOnlySelectedShape();if(o){const a=this.editor.getShapeUtil(o);if(!this.canInteractWithShapeInReadOnly(o))return;if(e.handle==="right"||e.handle==="left"||e.handle==="top"||e.handle==="bottom"){const l=(t=a.onDoubleClickEdge)==null?void 0:t.call(a,o);if(l){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([l]),Ht(this.editor,[o.id]);return}}if(a.canCrop(o)&&!this.editor.isShapeOrAncestorLocked(o)){this.parent.transition("crop",e);return}this.shouldStartEditingShape(o)&&this.startEditingShape(o,e,!0)}break}case"shape":{const{shape:o}=e,a=this.editor.getShapeUtil(o);if(o.type!=="video"&&o.type!=="embed"&&this.editor.getIsReadonly())break;if(a.onDoubleClick){const l=(r=a.onDoubleClick)==null?void 0:r.call(a,o);if(l){this.editor.updateShapes([l]);return}}if(a.canCrop(o)&&!this.editor.isShapeOrAncestorLocked(o)){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(o)?this.startEditingShape(o,e,!0):this.handleDoubleClickOnCanvas(e);break}case"handle":{if(this.editor.getIsReadonly())break;const{shape:o,handle:a}=e,l=this.editor.getShapeUtil(o),c=(i=l.onDoubleClickHandle)==null?void 0:i.call(l,o,a);c?this.editor.updateShapes([c]):this.shouldStartEditingShape(o)&&this.startEditingShape(o,e,!0)}}}onRightClick(e){switch(e.target){case"canvas":{const t=this.editor.getHoveredShape(),r=t&&!this.editor.isShapeOfType(t,"group")?t: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(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:o}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&EN(this.editor,o)){this.onRightClick({...e,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:t}=this.editor.getCurrentPageState(),{shape:r}=e,s=this.editor.getOutermostSelectableShape(r,i=>!t.includes(i.id));!t.includes(s.id)&&!this.editor.findShapeAncestor(s,i=>t.includes(i.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":{if(e.accelKey){this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(!1);return}}if(ln.editOnType.get()&&!e0e.includes(e.key)&&!e.altKey&&!e.ctrlKey){const t=this.editor.getOnlySelectedShape();if(t&&this.editor.isShapeOfType(t,"note")&&this.shouldStartEditingShape(t)){this.startEditingShape(t,{...e,target:"shape",shape:t},!0);return}}}onKeyRepeat(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(e.accelKey){this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(!0);break}case"Tab":{this.editor.getSelectedShapes().length&&this.editor.selectAdjacentShape(e.shiftKey?"prev":"next");break}}}onKeyUp(e){switch(e.code){case"Enter":{const t=this.editor.getSelectedShapes();if(t.every(s=>this.editor.isShapeOfType(s,"group"))){this.editor.setSelectedShapes(t.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}IN(this.editor)&&this.parent.transition("crop",e);break}case"Tab":{this.editor.getSelectedShapes().length&&this.editor.selectAdjacentShape(e.shiftKey?"prev":"next");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,t,r){this.editor.isShapeOrAncestorLocked(e)&&e.type!=="embed"||(this.editor.markHistoryStoppingPoint("editing shape"),DS(this.editor,e,r),this.parent.transition("editing_shape",t))}isOverArrowLabelTest(e){if(!e)return!1;const t=this.editor.getPointInShapeSpace(e,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(e,"arrow")){const r=this.editor.getShapeGeometry(e).children[1];if(r&&qs(t,r.vertices))return!0}return!1}handleDoubleClickOnCanvas(e){if(this.editor.getIsReadonly()||!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");const t=Dt(),{x:r,y:s}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:t,type:"text",x:r,y:s,props:{richText:Ei(""),autoSize:!0}}]);const i=this.editor.getShape(t);if(!i)return;const o=this.editor.getShapeUtil(i);this.editor.getIsReadonly()&&!o.canEditInReadOnly(i)||(this.editor.setEditingShape(t),this.editor.select(t),this.parent.transition("editing_shape",e))}nudgeSelectedShapes(e=!1){const{editor:{inputs:{keys:t}}}=this,r=t.has("ShiftLeft"),s=new k(0,0);if(t.has("ArrowLeft")&&(s.x-=1),t.has("ArrowRight")&&(s.x+=1),t.has("ArrowUp")&&(s.y-=1),t.has("ArrowDown")&&(s.y+=1),s.equals(new k(0,0)))return;e||this.editor.markHistoryStoppingPoint("nudge shapes");const{gridSize:i}=this.editor.getDocumentSettings(),o=this.editor.getInstanceState().isGridMode?r?i*s0e:i:r?n0e:r0e,a=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(a,s.mul(o)),Ht(this.editor,a)}canInteractWithShapeInReadOnly(e){return!!(!this.editor.getIsReadonly()||this.editor.getShapeUtil(e).canEditInReadOnly(e))}},R(_P,"id","idle"),_P);const n0e=10,r0e=1,s0e=5;function EN(n,e){const t=n.getSelectionRotatedPageBounds();if(!t)return!1;const r=n.getSelectionRotation();return r?qs(e,t.corners.map(s=>k.RotWith(s,t.point,r))):t.containsPoint(e)}class H7 extends De{constructor(){super(...arguments);R(this,"shapeId","");R(this,"markId","");R(this,"wasAlreadySelected",!1);R(this,"didDrag",!1);R(this,"didCtrlOnEnter",!1);R(this,"info",{});R(this,"_labelDragOffset",new k(0,0))}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(t){const{shape:r}=t;this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,this.shapeId=r.id,this.didDrag=!1,this.didCtrlOnEnter=t.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===r.id,this.updateCursor();const i=this.editor.getShapeGeometry(r).children[1];if(!i)throw Error(`Expected to find an arrow label geometry for shape: ${r.id}`);const{currentPagePoint:o}=this.editor.inputs,a=this.editor.getPointInShapeSpace(r,o);if(this._labelDragOffset=k.Sub(i.center,a),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),t.shiftKey||t.accelKey){const c=this.editor.getSelectedShapeIds();this.editor.setSelectedShapes([...c,this.shapeId]);return}this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){const{isDragging:t}=this.editor.inputs;if(!t)return;if(this.didCtrlOnEnter){this.parent.transition("brushing",this.info);return}const r=this.editor.getShape(this.shapeId);if(!r)return;const s=Lo(this.editor,r),i=this.editor.getShapeGeometry(r),o=i.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),l=o.nearestPoint(k.Add(a,this._labelDragOffset));let c;if(s.isStraight){const u=k.Dist(s.start.point,s.end.point);c=1-k.Dist(s.end.point,l)/u}else{const{_center:u,measure:h,angleEnd:p,angleStart:m}=i.children[0];c=LP(h,m,p,u.angle(l))}isNaN(c)&&(c=.5),this.didDrag=!0,this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:c}})}onPointerUp(){const t=this.editor.getShape(this.shapeId);t&&(this.didDrag||!this.wasAlreadySelected?this.complete():this.editor.getIsReadonly()||(this.editor.setEditingShape(t.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")}}R(H7,"id","pointing_arrow_label");class K7 extends De{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){v0(this.editor,e),this.complete()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}R(K7,"id","pointing_canvas");class W7 extends De{constructor(){super(...arguments);R(this,"didCtrlOnEnter",!1);R(this,"info",{})}onEnter(t){this.info=t,this.didCtrlOnEnter=t.accelKey;const{shape:r}=t;if(this.editor.isShapeOfType(r,"arrow")){const s=Hr(this.editor,r)[t.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:t,handle:r}=this.info;if(this.editor.isShapeOfType(t,"note")){const{editor:s}=this,i=_N(s,t,r,!1);if(i){DS(s,i,!0);return}}this.parent.transition("idle",this.info)}onPointerMove(t){const{editor:r}=this;r.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",t):this.startDraggingHandle())}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){const{editor:t}=this;if(t.getIsReadonly())return;const{shape:r,handle:s}=this.info;if(t.isShapeOfType(r,"note")){const i=_N(t,r,s,!0);if(i){const o=t.getPointInParentSpace(i,t.inputs.originPagePoint).sub(k.Rot(jv.clone().mul(r.props.scale),i.rotation));t.updateShape({...i,x:o.x,y:o.y}),t.setHoveredShape(i.id).select(i.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:t.getShape(i),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{DS(t,i,!0)}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}R(W7,"id","pointing_handle");function _N(n,e,t,r){const s=n.getShapePageTransform(e.id),i=s.point(),o=s.rotation(),l=t7(n,i,o,e.props.growY*e.props.scale,0,e.props.scale)[t.index];if(l)return r7(n,e,l,o,r)}class V7 extends De{constructor(){super(...arguments);R(this,"info",{})}updateCursor(){this.editor.setCursor({type:th[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(t){this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,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")}}R(V7,"id","pointing_rotate_handle");class q7 extends De{constructor(){super(...arguments);R(this,"info",{})}onEnter(t){this.info=t}onPointerUp(t){v0(this.editor,t),this.parent.transition("idle",t)}onPointerMove(t){this.editor.inputs.isDragging&&this.startTranslating(t)}onLongPress(t){this.startTranslating(t)}startTranslating(t){this.editor.getIsReadonly()||this.parent.transition("translating",t)}onDoubleClick(t){var i,o;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"),(o=(i=this.parent).onDoubleClick)==null||o.call(i,{...t,target:"shape",shape:this.editor.getShape(s)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}R(q7,"id","pointing_selection");class G7 extends De{constructor(){super(...arguments);R(this,"hitShape",{});R(this,"hitShapeForPointerUp",{});R(this,"isDoubleClick",!1);R(this,"didCtrlOnEnter",!1);R(this,"didSelectOnEnter",!1)}onEnter(t){const r=this.editor.getSelectedShapeIds(),s=this.editor.getSelectionRotatedPageBounds(),i=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:o}}=this.editor,{shiftKey:a,altKey:l,accelKey:c}=t;this.hitShape=t.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=c;const u=this.editor.getOutermostSelectableShape(t.shape),h=this.editor.findShapeAncestor(u,p=>r.includes(p.id));if(this.didCtrlOnEnter||this.editor.getShapeUtil(t.shape).onClick||u.id===i||r.includes(u.id)||h||r.length>1&&(s!=null&&s.containsPoint(o))){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(t){var u;const r=this.editor.getSelectedShapeIds(),s=this.editor.getFocusedGroupId(),i=this.editor.getZoomLevel(),{inputs:{currentPagePoint:o}}=this.editor,a=t.shiftKey||t.accelKey,l=this.editor.getShapeAtPoint(o,{margin:this.editor.options.hitTestMargin/i,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 p=(u=h.onClick)==null?void 0:u.call(h,c);if(p){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([p]),this.parent.transition("idle",t);return}}if(c.id===s){r.length>0?(this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",t);return}}if(!this.didSelectOnEnter){const h=this.editor.getOutermostSelectableShape(l,p=>!r.includes(p.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 p=this.editor.getShapeUtil(c).getGeometry(c),m=B7(p),S=m.length===1?m[0]:void 0;if(S){const x=this.editor.getPointInShapeSpace(c,o);if(S.bounds.containsPoint(x,0)&&S.hitTestPoint(x)){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}):this.editor.emit("place-caret",{shapeId:c.id,point:t.point}))});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 p=this.editor.getShapeAncestors(h);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(m=>!p.find(S=>S.id===m)),h.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([h.id])}this.parent.transition("idle",t)}onDoubleClick(){this.isDoubleClick=!0}onPointerMove(t){this.editor.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",t):this.startTranslating(t))}onLongPress(t){this.startTranslating(t)}startTranslating(t){this.editor.getIsReadonly()||(this.editor.focus(),this.parent.transition("translating",t))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}R(G7,"id","pointing_shape");class Y7 extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"markId","");R(this,"didHoldCommand",!1);R(this,"creationCursorOffset",{x:0,y:0});R(this,"snapshot",{})}onEnter(t){const{isCreating:r=!1,creatingMarkId:s,creationCursorOffset:i={x:0,y:0}}=t;this.info=t,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.creationCursorOffset=i;try{this.snapshot=this._createSnapshot()}catch(o){console.error(o),this.cancel();return}if(this.markId="",r)if(s)this.markId=s;else{const o=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);o&&(this.markId=o)}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");r&&this.editor.setCursor({type:"cross",rotation:0}),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:t}){const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(t)}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 t,r;if(Ht(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(r=(t=this.info).onCreate)==null||r.call(t,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:t}=this.snapshot,r=[];t.forEach(({shape:s})=>{var a;const i=this.editor.getShapeUtil(s),o=(a=i.onResizeStart)==null?void 0:a.call(i,s);o&&r.push(o)}),r.length>0&&this.editor.updateShapes(r)}handleResizeEnd(){const{shapeSnapshots:t}=this.snapshot,r=[];t.forEach(({shape:s})=>{var l;const i=this.editor.getShape(s.id),o=this.editor.getShapeUtil(s),a=(l=o.onResizeEnd)==null?void 0:l.call(o,s,i);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{altKey:t,shiftKey:r}=this.editor.inputs,{frames:s,shapeSnapshots:i,selectionBounds:o,cursorHandleOffset:a,selectedShapeIds:l,selectionRotation:c,canShapesDeform:u}=this.snapshot;let h=r||!u;if(i.size===1){const D=[...i.values()][0];this.editor.isShapeOfType(D.shape,"text")&&(h=!(this.info.handle==="left"||this.info.handle==="right"))}const{ctrlKey:p}=this.editor.inputs,m=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),S=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!p){const{gridSize:D}=this.editor.getDocumentSettings();m.snapToGrid(D)}const x=this.info.handle,v=TN(x,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!p:p)&&c%Kt===0){const{nudge:D}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:k.Sub(m,S),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:TN(x,c),isAspectRatioLocked:h,isResizingFromCenter:t});m.add(D)}const C=k.RotWith(t?o.center:o.getHandlePoint(v),o.point,c),_=k.Sub(m,C).rot(-c),E=k.Sub(S,C).rot(-c),T=k.DivV(_,E);Number.isFinite(T.x)||(T.x=1),Number.isFinite(T.y)||(T.y=1);const A=x==="top"||x==="bottom",O=x==="left"||x==="right";h?O?T.y=Math.abs(T.x):A?T.x=Math.abs(T.y):Math.abs(T.x)>Math.abs(T.y)?T.y=Math.abs(T.x)*(T.y<0?-1:1):T.x=Math.abs(T.y)*(T.x<0?-1:1):(A&&(T.x=1),O&&(T.y=1)),this.info.isCreating||this.updateCursor({dragHandle:x,isFlippedX:T.x<0,isFlippedY:T.y<0,rotation:c});for(const D of i.keys()){const $=i.get(D);this.editor.resizeShape(D,T,{initialShape:$.shape,initialBounds:$.bounds,initialPageTransform:$.pageTransform,dragHandle:x,mode:l.length===1&&D===l[0]?"resize_bounds":"scale_shape",scaleOrigin:C,isAspectRatioLocked:h,scaleAxisRotation:c,skipStartAndEndCallbacks:!0})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:D,children:$}of s){if(!$.length)continue;const H=i.get(D).shape,G=this.editor.getShape(D);if(!(H&&G))continue;const J=G.x-H.x,L=G.y-H.y,N=new k(J,L).rot(-H.rotation);if(N.x!==0||N.y!==0)for(const U of $)this.editor.updateShape({id:U.id,type:U.type,x:U.x-N.x,y:U.y-N.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:D}of s)if(D.length)for(const $ of D)this.editor.updateShape({id:$.id,type:$.type,x:$.x,y:$.y})}}updateCursor({dragHandle:t,isFlippedX:r,isFlippedY:s,rotation:i}){const o={...this.editor.getInstanceState().cursor};switch(t){case"top_left":case"bottom_right":{o.type="nwse-resize",r!==s&&(o.type="nesw-resize");break}case"top_right":case"bottom_left":{o.type="nesw-resize",r!==s&&(o.type="nwse-resize");break}}o.rotation=i,this.editor.setCursor(o)}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()}_createSnapshot(){const t=this.editor.getSelectedShapeIds(),r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:s}}=this.editor,i=this.editor.getSelectionRotatedPageBounds();if(!i)throw Error("Resizing but nothing is selected");const o=k.RotWith(i.getHandlePoint(this.info.handle),i.point,r),a=k.Sub(s,o),l=new Map,c=[];t.forEach(h=>{const p=this.editor.getShape(h);if(p){if(p.type==="frame"&&c.push({id:h,children:rt(this.editor.getSortedChildIdsForParent(p).map(m=>this.editor.getShape(m)))}),l.set(p.id,this._createShapeSnapshot(p)),this.editor.isShapeOfType(p,"frame")&&t.length===1)return;this.editor.visitDescendants(p.id,m=>{const S=this.editor.getShape(m);if(S&&(l.set(S.id,this._createShapeSnapshot(S)),this.editor.isShapeOfType(S,"frame")))return!1})}});const u=![...l.values()].some(h=>!oF(h.pageRotation,r)||h.isAspectRatioLocked);return{shapeSnapshots:l,selectionBounds:i,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:t,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:c}}_createShapeSnapshot(t){const r=this.editor.getShapePageTransform(t),s=this.editor.getShapeUtil(t);return{shape:t,bounds:this.editor.getShapeGeometry(t).bounds,pageTransform:r,pageRotation:he.Decompose(r).rotation,isAspectRatioLocked:s.isAspectRatioLocked(t)}}}R(Y7,"id","resizing");const rP=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function TN(n,e){e=e%Rt;const t=Math.round(e/(wt/4)),r=rP.indexOf(n);return rP[(r+t)%rP.length]}const MN=Math.PI/180;class X7 extends De{constructor(){super(...arguments);R(this,"snapshot",{});R(this,"info",{});R(this,"markId","")}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("rotate start");const r=r$({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});Sy({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:th[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 t=this._getRotationFromPointerPosition({snapToNearestDegree:!1});Sy({editor:this.editor,delta:t,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:th[this.info.handle],rotation:t+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(){Sy({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),Ht(this.editor,this.snapshot.shapeSnapshots.map(t=>t.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:t}){const r=this.editor.getSelectionRotation(),s=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:i,currentPagePoint:o}}=this.editor,{initialCursorAngle:a,initialShapesRotation:l}=this.snapshot;if(!s)return l;const u=s.center.clone().rotWith(s.point,r).angle(o)-a;let h=l+u;if(i)h=Zy(h,24);else if(t&&(h=Math.round(h/MN)*MN,this.editor.getInstanceState().isCoarsePointer)){const p=Zy(h,4),m=ly(h,p);Math.abs(m)<NG(5)&&(h=p)}return h-l}}R(X7,"id","rotating");class Z7 extends De{constructor(){super(...arguments);R(this,"hits",new Set);R(this,"size",0);R(this,"scribbleId","id");R(this,"initialSelectedShapeIds",new Set);R(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 t=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=t.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:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,r)}updateScribbleSelection(t){const{editor:r}=this,s=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{shiftKey:i,originPagePoint:o,previousPagePoint:a,currentPagePoint:l}}=this.editor,{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;t&&this.pushPointToScribble();const h=s;let p,m,S,x;const v=0;for(let _=0,E=h.length;_<E;_++){if(p=h[_],r.isShapeOfType(p,"group")||c.has(p.id)||r.isShapeOrAncestorLocked(p)||(m=r.getShapeGeometry(p),r.isShapeOfType(p,"frame")&&m.bounds.containsPoint(r.getPointInShapeSpace(p,o))))continue;const T=r.getShapePageTransform(p);if(!m||!T)continue;const A=T.clone().invert();S=A.applyToPoint(a),x=A.applyToPoint(l);const{bounds:O}=m;if(!(O.minX-v>Math.max(S.x,x.x)||O.minY-v>Math.max(S.y,x.y)||O.maxX+v<Math.min(S.x,x.x)||O.maxY+v<Math.min(S.y,x.y))&&m.hitTestLineSegment(S,x,v)){const D=this.editor.getOutermostSelectableShape(p),$=this.editor.getShapeMask(D.id);if($&&VE(a,l,$)!==null&&!qs(l,$))continue;c.add(D.id)}}const w=r.getSelectedShapeIds(),C=new Set(i?[...c,...u]:[...c]);(w.length!==C.size||w.some(_=>!C.has(_)))&&this.editor.setSelectedShapes(Array.from(C))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}R(Z7,"id","scribble_brushing");var i0e=Object.create,J7=Object.defineProperty,o0e=Object.getOwnPropertyDescriptor,a0e=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),Q7=n=>{throw TypeError(n)},eH=(n,e,t)=>e in n?J7(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,l0e=n=>[,,,i0e(null)],tH=["class","method","getter","setter","accessor","field","value","get","set"],nH=n=>n!==void 0&&typeof n!="function"?Q7("Function expected"):n,c0e=(n,e,t,r,s)=>({kind:tH[n],name:e,metadata:r,addInitializer:i=>t._?Q7("Already initialized"):s.push(nH(i||null))}),u0e=(n,e)=>eH(e,a0e("metadata"),n[3]),d0e=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},h0e=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=tH[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,o0e(s,t)),w=r.length-1;w>=0;w--)l=c0e(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,nH(o)&&(v[S]=o);return v&&J7(s,t,v),s},sP=(n,e,t)=>eH(n,typeof e!="symbol"?e+"":e,t),rH,Nv;const f0e=20,p0e=100;rH=[ks];class TT{constructor(e){this.editor=e,d0e(Nv,5,this),sP(this,"prevDroppingShapeId",null),sP(this,"droppingNodeTimer",null),sP(this,"first",!0),e.disposables.add(this.dispose)}updateDroppingNode(e,t){var r;this.first&&(this.editor.setHintingShapes(e.map(s=>this.editor.findShapeAncestor(s,i=>i.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,f0e,t):this.editor.inputs.pointerVelocity.len()>.5&&(clearTimeout(this.droppingNodeTimer),this.setDragTimer(e,p0e,t))}setDragTimer(e,t,r){this.droppingNodeTimer=this.editor.timers.setTimeout(()=>{this.editor.run(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,e,r)}),this.droppingNodeTimer=null},t)}handleDrag(e,t,r){var l,c,u,h,p;t=rt(t.map(m=>this.editor.getShape(m.id)));const s=((l=this.editor.getDroppingOverShape(e,t))==null?void 0:l.id)??null;if(s===this.prevDroppingShapeId){this.hintParents(t);return}const{prevDroppingShapeId:i}=this,o=i&&this.editor.getShape(i),a=s&&this.editor.getShape(s);o&&((u=(c=this.editor.getShapeUtil(o)).onDragShapesOut)==null||u.call(c,o,t)),a&&((p=(h=this.editor.getShapeUtil(a)).onDragShapesOver)==null||p.call(h,a,t)),this.hintParents(t),r==null||r(),this.prevDroppingShapeId=s}hintParents(e){const t=new Map;for(const s of e){const i=this.editor.findShapeAncestor(s,o=>o.type!=="group");i&&(t.has(i.id)||t.set(i.id,[]),t.get(i.id).push(s.id))}const r=[];for(const[s,i]of t){const o=this.editor.getShape(s);o&&$9(this.editor,o).length<i.length&&r.push(o.id)}this.editor.setHintingShapes(r)}dropShapes(e){var r,s;const{prevDroppingShapeId:t}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,e),t){const i=this.editor.getShape(t);if(!i)return;(s=(r=this.editor.getShapeUtil(i)).onDropShapesOver)==null||s.call(r,i,e)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearTimeout(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}dispose(){this.clear()}}Nv=l0e();h0e(Nv,1,"dispose",rH,TT);u0e(Nv,TT);var g0e=Object.create,sH=Object.defineProperty,m0e=Object.getOwnPropertyDescriptor,iH=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),oH=n=>{throw TypeError(n)},aH=(n,e,t)=>e in n?sH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y0e=n=>[,,,g0e((n==null?void 0:n[iH("metadata")])??null)],lH=["class","method","getter","setter","accessor","field","value","get","set"],cH=n=>n!==void 0&&typeof n!="function"?oH("Function expected"):n,S0e=(n,e,t,r,s)=>({kind:lH[n],name:e,metadata:r,addInitializer:i=>t._?oH("Already initialized"):s.push(cH(i||null))}),v0e=(n,e)=>aH(e,iH("metadata"),n[3]),x0e=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},w0e=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=lH[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,m0e(s,t)),w=r.length-1;w>=0;w--)l=S0e(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,cH(o)&&(v[S]=o);return v&&sH(s,t,v),s},Il=(n,e,t)=>aH(n,typeof e!="symbol"?e+"":e,t),uH,hI,Fv;class zv extends(hI=De,uH=[ks],hI){constructor(){super(...arguments),x0e(Fv,5,this),Il(this,"info",{}),Il(this,"selectionSnapshot",{}),Il(this,"snapshot",{}),Il(this,"markId",""),Il(this,"isCloning",!1),Il(this,"isCreating",!1),Il(this,"dragAndDropManager",new TT(this.editor))}onCreate(e){}onEnter(e){var i;const{isCreating:t=!1,creatingMarkId:r,onCreate:s=()=>{}}=e;if(!((i=this.editor.getSelectedShapeIds())!=null&&i.length)){this.parent.transition("idle");return}if(this.info=e,this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.isCreating=t,this.markId="",t)if(r)this.markId=r;else{const o=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);o&&(this.markId=o)}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=AN(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:t}=this;this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),t.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=AN(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),Ht(this.editor,this.snapshot.movingShapes.map(t=>t.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,t=[];e.forEach(r=>{var o;const s=this.editor.getShapeUtil(r),i=(o=s.onTranslateStart)==null?void 0:o.call(s,r);i&&t.push(i)}),t.length>0&&this.editor.updateShapes(t),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){const r=k.Average(e.map(i=>this.editor.getShapePageTransform(i.id).point())),s=k.Sub(r,this.selectionSnapshot.averagePagePoint);k.IsNaN(s)||this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map(i=>i.id),offset:{x:s.x,y:s.y}}})}const t=[];e.forEach(r=>{var a;const s=this.editor.getShape(r.id),i=this.editor.getShapeUtil(r),o=(a=i.onTranslateEnd)==null?void 0:a.call(i,r,s);o&&t.push(o)}),t.length>0&&this.editor.updateShapes(t)}updateShapes(){const{snapshot:e}=this;this.dragAndDropManager.updateDroppingNode(e.movingShapes,this.updateParentTransforms),b0e({editor:this.editor,snapshot:e});const{movingShapes:t}=e,r=[];t.forEach(s=>{var l;const i=this.editor.getShape(s.id),o=this.editor.getShapeUtil(s),a=(l=o.onTranslate)==null?void 0:l.call(o,s,i);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateParentTransforms(){const{editor:e,snapshot:{shapeSnapshots:t}}=this;t.forEach(r=>{const s=e.getShape(r.shape.id);if(!s)return null;const i=Ss(s.parentId)?null:he.Inverse(e.getShapePageTransform(s.parentId));r.parentTransform=i})}}Fv=y0e(hI);w0e(Fv,1,"updateParentTransforms",uH,zv);v0e(Fv,zv);Il(zv,"id","translating");function AN(n){var h;const e=[],t=[],r=n.getSelectedShapeIds(),s=rt(r.map(p=>{const m=n.getShape(p);if(!m)return null;e.push(m);const S=n.getShapePageTransform(p),x=S.point(),v=S.rotation();t.push(x);const w=Wr.isId(m.parentId)?null:he.Inverse(n.getShapePageTransform(m.parentId));return{shape:m,pagePoint:x,pageRotation:v,parentTransform:w}})),i=n.getOnlySelectedShape();let o=[];if(i)o=n.snaps.shapeBounds.getSnapPoints(i.id);else{const p=n.getSelectionPageBounds();p&&(o=p.cornersAndCenter.map((m,S)=>({id:"selection:"+S,x:m.x,y:m.y})))}let a,l;const{originPagePoint:c}=n.inputs,u=s.filter(p=>n.isShapeOfType(p.shape,"note")&&n.isPointInShape(p.shape,c));if(u.length!==0)if(u.length===1)l=u[0];else{const p=n.getCurrentPageShapesSorted();l=(h=u.map(m=>({snapshot:m,index:p.findIndex(S=>S.id===m.shape.id)})).sort((m,S)=>S.index-m.index)[0])==null?void 0:h.snapshot}return l&&(a=n7(n,l.pageRotation,l.shape.props.scale,l.shape.props.growY??0)),{averagePagePoint:k.Average(t),movingShapes:e,shapeSnapshots:s,initialPageBounds:n.getSelectionPageBounds(),initialSnapPoints:o,noteAdjacentPositions:a,noteSnapshot:l}}function b0e({editor:n,snapshot:e}){const{inputs:t}=n,{noteSnapshot:r,noteAdjacentPositions:s,initialPageBounds:i,initialSnapPoints:o,shapeSnapshots:a,averagePagePoint:l}=e,c=n.getInstanceState().isGridMode,u=n.getDocumentSettings().gridSize,h=k.Sub(t.currentPagePoint,t.originPagePoint),p=n.inputs.shiftKey?Math.abs(h.x)<Math.abs(h.y)?"x":"y":null;p==="x"?h.x=0:p==="y"&&(h.y=0),n.snaps.clearIndicators();const m=n.user.getIsSnapMode()?!t.ctrlKey:t.ctrlKey;let S=!1;if(m&&n.inputs.pointerVelocity.len()<.5){const{nudge:C}=n.snaps.shapeBounds.snapTranslateShapes({dragDelta:h,initialSelectionPageBounds:i,lockedAxis:p,initialSelectionSnapPoints:o});h.add(C)}else if(r&&s){const{scale:C}=r.shape.props,_=r.pagePoint.clone().add(h).add(jv.clone().mul(C).rot(r.pageRotation));let E=e7/n.getZoomLevel(),T=new k(0,0);for(const A of s){const O=k.Sub(_,A),D=O.len();D<E&&(S=!0,E=D,T=O)}h.sub(T)}const x=k.Add(l,h),v=n.snaps.getIndicators();c&&!t.ctrlKey&&!S&&v.length===0&&x.snapToGrid(u);const w=k.Sub(x,l);n.updateShapes(rt(a.map(({shape:C,pagePoint:_,parentTransform:E})=>{const T=k.Add(_,w),A=E?he.applyToPoint(E,T):T;return{id:C.id,type:C.type,x:A.x,y:A.y}})))}class Uy extends De{constructor(){super(...arguments);R(this,"reactor")}static children(){return[dI,IT,t0e,K7,G7,zv,j7,Z7,_T,q7,L7,U7,Y7,X7,V7,H7,W7,$7]}cleanUpDuplicateProps(){const t=this.editor.getSelectedShapeIds(),r=this.editor.getInstanceState();if(!r.duplicateProps)return;const s=new Set(r.duplicateProps.shapeIds);t.length===s.size&&t.every(i=>s.has(i))||this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=Pi("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(t){console.error(t)}})}onExit(){var t;(t=this.reactor)==null||t.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)}}R(Uy,"id","select"),R(Uy,"initial","idle"),R(Uy,"isLockable",!1);class dH extends De{constructor(){super(...arguments);R(this,"info",{})}onEnter(t){this.info=t}onPointerDown(){this.parent.transition("pointing",this.info)}}R(dH,"id","idle");class hH extends De{constructor(){super(...arguments);R(this,"info",{})}onEnter(t){this.info=t}onPointerUp(){this.complete()}onPointerMove(){this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){const{currentScreenPoint:t}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(t,{animation:{duration:220}}):this.editor.zoomIn(t,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}R(hH,"id","pointing");class fH extends De{constructor(){super(...arguments);R(this,"info",{});R(this,"zoomBrush",new Se)}onEnter(t){this.info=t,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){const{inputs:{originPagePoint:t,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(Se.FromPoints([t,r])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:t}=this,r=8/this.editor.getZoomLevel();if(t.width<r&&t.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(t,{targetZoom:s,animation:{duration:220}})}this.parent.transition("idle",this.info)}}R(fH,"id","zoom_brushing");class Hy extends De{constructor(){super(...arguments);R(this,"info",{})}static children(){return[dH,fH,hH]}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.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(t){this.updateCursor(),t.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})}}R(Hy,"id","zoom"),R(Hy,"initial","idle"),R(Hy,"isLockable",!1);const C0e=[zy,$y,By,Hy,Uy];function P0e(){const n=te(),e=ie("follow",()=>n.getInstanceState().followingUserId,[n]);return e?g.jsx(k0e,{userId:e}):null}function k0e({userId:n}){const e=Z0(n);return e?g.jsx("div",{className:"tlui-following-indicator",style:{borderColor:e.color}}):null}let fI={fonts:{tldraw_mono:`${_n()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${_n()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${_n()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${_n()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${_n()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${_n()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${_n()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${_n()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${_n()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${_n()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${_n()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${_n()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${_n()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${_n()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${_n()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${_n()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function I0e(n){return P.useMemo(()=>n?{fonts:{...fI.fonts,...n==null?void 0:n.fonts}}:fI,[n])}const E0e=["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","bold","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","code","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","heading","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","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","strike","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","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];let gf={...fI,icons:Object.fromEntries(E0e.map(n=>[n,`${_n()}/icons/icon/0_merged.svg#${n}`])),translations:Object.fromEntries(mp.map(n=>[n.locale,`${_n()}/translations/${n.locale}.json`])),embedIcons:Object.fromEntries(H_.map(n=>[n.type,`${_n()}/embed-icons/${n.type}.png`]))};function _0e(n){return n?{fonts:Object.assign({...gf.fonts},{...n==null?void 0:n.fonts}),icons:Object.assign({...gf.icons},{...n==null?void 0:n.icons}),embedIcons:Object.assign({...gf.embedIcons},{...n==null?void 0:n.embedIcons}),translations:Object.assign({...gf.translations},{...n==null?void 0:n.translations})}:gf}var $v="Popover",[pH,k1e]=Xo($v,[Sv]),hg=Sv(),[T0e,oc]=pH($v),gH=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=hg(e),l=P.useRef(null),[c,u]=P.useState(!1),[h,p]=sc({prop:r,defaultProp:s??!1,onChange:i,caller:$v});return g.jsx(C_,{...a,children:g.jsx(T0e,{scope:e,contentId:Ra(),triggerRef:l,open:h,onOpenChange:p,onOpenToggle:P.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:c,onCustomAnchorAdd:P.useCallback(()=>u(!0),[]),onCustomAnchorRemove:P.useCallback(()=>u(!1),[]),modal:o,children:t})})};gH.displayName=$v;var mH="PopoverAnchor",M0e=P.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=oc(mH,t),i=hg(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return P.useEffect(()=>(o(),()=>a()),[o,a]),g.jsx(P_,{...i,...r,ref:e})});M0e.displayName=mH;var yH="PopoverTrigger",SH=P.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=oc(yH,t),i=hg(t),o=jt(e,s.triggerRef),a=g.jsx(vt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":CH(s.open),...r,ref:o,onClick:je(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:g.jsx(P_,{asChild:!0,...i,children:a})});SH.displayName=yH;var MT="PopoverPortal",[A0e,O0e]=pH(MT,{forceMount:void 0}),vH=n=>{const{__scopePopover:e,forceMount:t,children:r,container:s}=n,i=oc(MT,e);return g.jsx(A0e,{scope:e,forceMount:t,children:g.jsx(lo,{present:t||i.open,children:g.jsx(rg,{asChild:!0,container:s,children:r})})})};vH.displayName=MT;var nh="PopoverContent",xH=P.forwardRef((n,e)=>{const t=O0e(nh,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=oc(nh,n.__scopePopover);return g.jsx(lo,{present:r||i.open,children:i.modal?g.jsx(D0e,{...s,ref:e}):g.jsx(j0e,{...s,ref:e})})});xH.displayName=nh;var R0e=Yd("PopoverContent.RemoveScroll"),D0e=P.forwardRef((n,e)=>{const t=oc(nh,n.__scopePopover),r=P.useRef(null),s=jt(e,r),i=P.useRef(!1);return P.useEffect(()=>{const o=r.current;if(o)return k_(o)},[]),g.jsx(xv,{as:R0e,allowPinchZoom:!0,children:g.jsx(wH,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:je(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:je(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),j0e=P.forwardRef((n,e)=>{const t=oc(nh,n.__scopePopover),r=P.useRef(!1),s=P.useRef(!1);return g.jsx(wH,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),wH=P.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...h}=n,p=oc(nh,t),m=hg(t);return f_(),g.jsx(pv,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:g.jsx(tg,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:g.jsx(g8,{"data-state":CH(p.open),role:"dialog",id:p.contentId,...m,...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)"}})})})}),bH="PopoverClose",L0e=P.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=oc(bH,t);return g.jsx(vt.button,{type:"button",...r,ref:e,onClick:je(n.onClick,()=>s.onOpenChange(!1))})});L0e.displayName=bH;var N0e="PopoverArrow",F0e=P.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=hg(t);return g.jsx(m8,{...s,...r,ref:e})});F0e.displayName=N0e;function CH(n){return n?"open":"closed"}var AT=gH,OT=SH,RT=vH,DT=xH;function du({id:n,children:e,onOpenChange:t,open:r}){const[s,i]=Xa(n,t);return g.jsx(AT,{onOpenChange:i,open:r||s,children:g.jsx("div",{className:"tlui-popover",children:e})})}function hu({children:n}){return g.jsx(OT,{asChild:!0,dir:"ltr",children:n})}function fu({side:n,children:e,align:t="center",sideOffset:r=8,alignOffset:s=0,disableEscapeKeyDown:i=!1}){const o=kn();return g.jsx(RT,{container:o,children:g.jsx(DT,{className:"tlui-popover__content",side:n,sideOffset:r,align:t,alignOffset:s,dir:"ltr",onEscapeKeyDown:a=>i&&a.preventDefault(),children:e})})}function z0e(n){return n.getSelectedShapeIds().map(r=>n.getShape(r)).filter(r=>{if(!r)return!1;if(n.isShapeOfType(r,"arrow")){const s=Hr(n,r);if(s.start||s.end)return!1}return!0})}const PH=()=>{const n=te();return ie("threeStackableItems",()=>z0e(n).length>2,[n])},Za=()=>{const n=te();return ie("isInSelectState",()=>n.isIn("select"),[n])},kH=()=>{const n=te();return ie("allow group",()=>{const e=n.getSelectedShapes();if(e.length<2)return!1;for(const t of e)if(n.isShapeOfType(t,"arrow")){const r=Hr(n,t);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},[n])},IH=()=>{const n=te();return ie("allowUngroup",()=>n.getSelectedShapeIds().some(e=>{var t;return((t=n.getShape(e))==null?void 0:t.type)==="group"}),[n])},$0e=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function EH(n,e){const t=te();return ie("selectedShapes",()=>t.getSelectedShapes().length>=n,[t,n,e])}function ns(n,e){const t=te();return ie("selectedShapes",()=>{const r=t.getSelectedShapes().filter(s=>!t.isShapeOrAncestorLocked(s)).length;return n===void 0?r:r>=n},[t])}function B0e(){const n=te();return ie("showAutoSizeToggle",()=>{const e=n.getSelectedShapes();return e.length===1&&n.isShapeOfType(e[0],"text")&&e[0].props.autoSize===!1},[n])}function _H(){const n=te();return ie("hasLinkShapeSelected",()=>{const e=n.getOnlySelectedShape();return!!(e&&e.type!=="embed"&&"url"in e.props&&!e.isLocked)},[n])}function U0e(){const n=te();return ie("onlyFlippableShape",()=>{const e=n.getOnlySelectedShape();return e&&(n.isShapeOfType(e,"group")||n.isShapeOfType(e,"image")||n.isShapeOfType(e,"arrow")||n.isShapeOfType(e,"line")||n.isShapeOfType(e,"draw"))},[n])}function TH(){const n=te();return ie("useCanRedo",()=>n.getCanRedo(),[n])}function MH(){const n=te();return ie("useCanUndo",()=>n.getCanUndo(),[n])}function H0e(){return g.jsxs(g.Fragment,{children:[g.jsx(K0e,{}),g.jsx(W0e,{}),g.jsx(V0e,{}),g.jsx(q0e,{}),g.jsx(G0e,{}),g.jsx(Z0e,{}),g.jsx(J0e,{}),g.jsx(Q0e,{})]})}function K0e(){const n=ns(2),e=Za(),t=n&&e;return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"align-left",disabled:!t}),g.jsx(le,{actionId:"align-center-horizontal",disabled:!t}),g.jsx(le,{actionId:"align-right",disabled:!t}),g.jsx(le,{actionId:"stretch-horizontal",disabled:!t}),g.jsx(le,{actionId:"align-top",disabled:!t}),g.jsx(le,{actionId:"align-center-vertical",disabled:!t}),g.jsx(le,{actionId:"align-bottom",disabled:!t}),g.jsx(le,{actionId:"stretch-vertical",disabled:!t})]})}function W0e(){const n=ns(3),e=Za(),t=n&&e;return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"distribute-horizontal",disabled:!t}),g.jsx(le,{actionId:"distribute-vertical",disabled:!t})]})}function V0e(){const n=PH(),e=Za(),t=n&&e;return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"stack-horizontal",disabled:!t}),g.jsx(le,{actionId:"stack-vertical",disabled:!t})]})}function q0e(){const n=ns(1),e=Za(),t=n&&e;return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"send-to-back",disabled:!t}),g.jsx(le,{actionId:"send-backward",disabled:!t}),g.jsx(le,{actionId:"bring-forward",disabled:!t}),g.jsx(le,{actionId:"bring-to-front",disabled:!t})]})}function G0e(){return Rr()<dn.TABLET_SM?g.jsx(Y0e,{}):g.jsx(X0e,{})}function Y0e(){const n=te(),e=ie("zoom is 1",()=>n.getZoomLevel()===1,[n]);return g.jsx(le,{actionId:"zoom-to-100",disabled:e})}function X0e(){const n=ns(1),e=Za(),t=n&&e;return g.jsx(le,{actionId:"rotate-ccw",disabled:!t})}function Z0e(){const n=ns(1),e=Za(),t=n&&e;return g.jsx(le,{actionId:"rotate-cw",disabled:!t})}function J0e(){const n=_H(),e=Za(),t=n&&e;return g.jsx(le,{actionId:"edit-link",disabled:!t})}function Q0e(){const n=kH(),e=IH();return n?g.jsx(ON,{}):e?g.jsx(eve,{}):g.jsx(ON,{})}function ON(){const n=ns(2),e=Za(),t=n&&e;return g.jsx(le,{actionId:"group",disabled:!t})}function eve(){return g.jsx(le,{actionId:"ungroup"})}const tve=P.memo(function({children:e}){const t=it(),r=Rr(),s=ti(),i=P.useRef(null);Ga(i);const o=te(),a=ie("should display quick actions when in readonly",()=>o.isInAny("hand","zoom"),[o]),l=e??g.jsx(H0e,{});if(!(s&&!a))return g.jsxs(du,{id:"actions-menu",children:[g.jsx(hu,{children:g.jsx(He,{type:"icon","data-testid":"actions-menu.button",title:t("actions-menu.title"),children:g.jsx(ct,{icon:"dots-vertical",small:!0})})}),g.jsx(fu,{side:r>=dn.TABLET?"bottom":"top",sideOffset:6,children:g.jsx("div",{ref:i,className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:g.jsx(Zr,{type:"icons",sourceId:"actions-menu",children:l})})})]})});function AH(){return B0e()?g.jsx(le,{actionId:"toggle-auto-size"}):null}function OH(){return _H()?g.jsx(le,{actionId:"edit-link"}):null}function nve(){return ns(1)?g.jsx(le,{actionId:"duplicate"}):null}function RH(){const n=te();return ie("should display flatten option",()=>{if(n.getSelectedShapeIds().length===0)return!1;const r=n.getOnlySelectedShape();return!(r&&n.isShapeOfType(r,"image"))},[n])?g.jsx(le,{actionId:"flatten-to-image"}):null}function DH(){return kH()?g.jsx(le,{actionId:"group"}):null}function jH(){return IH()?g.jsx(le,{actionId:"ungroup"}):null}function LH(){const n=te();return ie("allow unframe",()=>{const t=n.getSelectedShapes();return t.length===0?!1:t.every(r=>n.isShapeOfType(r,"frame"))},[n])?g.jsx(le,{actionId:"remove-frame"}):null}function NH(){const n=te();return ie("allow fit frame to content",()=>{const t=n.getOnlySelectedShape();return t?n.isShapeOfType(t,"frame")&&n.getSortedChildIdsForParent(t).length>0:!1},[n])?g.jsx(le,{actionId:"fit-frame-to-content"}):null}function FH(){const n=te();return ie("selected shapes",()=>n.getSelectedShapes().length>0,[n])?g.jsx(le,{actionId:"toggle-lock"}):null}function jT(){const n=te(),e=ie("isTransparentBg",()=>!n.getInstanceState().exportBackground,[n]);return g.jsx(uo,{actionId:"toggle-transparent",checked:e,toggle:!0})}function rve(){const n=te(),e=ie("any shapes",()=>n.getCurrentPageShapeIds().size>0,[n]);return g.jsx(le,{actionId:"unlock-all",disabled:!e})}function zH(){const n=te(),e=ie("zoomed to 100",()=>n.getZoomLevel()===1,[n]);return g.jsx(le,{actionId:"zoom-to-100",noClose:!0,disabled:e})}function $H(){const n=te(),e=ie("has shapes",()=>n.getCurrentPageShapeIds().size>0,[n]);return g.jsx(le,{actionId:"zoom-to-fit",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function BH(){const n=te(),e=ie("has shapes",()=>n.getSelectedShapeIds().length>0,[n]);return g.jsx(le,{actionId:"zoom-to-selection",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function UH(){return g.jsxs(ot,{id:"clipboard",children:[g.jsx(ive,{}),g.jsx(ove,{}),g.jsx(ave,{}),g.jsx(nve,{}),g.jsx(lve,{})]})}function sve(){var t;const n=te(),e=ie("atLeastOneShapeOnPage",()=>n.getCurrentPageShapeIds().size>0,[n]);return g.jsxs(As,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!e,children:[g.jsxs(ot,{id:"copy-as-group",children:[g.jsx(le,{actionId:"copy-as-svg"}),!!((t=window.navigator.clipboard)!=null&&t.write)&&g.jsx(le,{actionId:"copy-as-png"})]}),g.jsx(ot,{id:"copy-as-bg",children:g.jsx(jT,{})})]})}function ive(){const n=ns(1);return g.jsx(le,{actionId:"cut",disabled:!n})}function ove(){const n=EH(1);return g.jsx(le,{actionId:"copy",disabled:!n})}function ave(){const n=$0e;return g.jsx(le,{actionId:"paste",disabled:!n})}function HH(){const n=te();return ie("atLeastOneShapeOnPage",()=>n.getCurrentPageShapeIds().size>0,[n])?g.jsxs(ot,{id:"conversions",children:[g.jsx(sve,{}),g.jsxs(As,{id:"export-as",label:"context-menu.export-as",size:"small",children:[g.jsxs(ot,{id:"export-as-group",children:[g.jsx(le,{actionId:"export-as-svg"}),g.jsx(le,{actionId:"export-as-png"})]}),g.jsx(ot,{id:"export-as-bg",children:g.jsx(jT,{})})]})]}):null}function KH(){const n=te(),e=ie("atLeastOneShapeOnPage",()=>n.getCurrentPageShapeIds().size>0,[n]);return g.jsx(le,{actionId:"select-all",disabled:!e})}function lve(){const n=ns(1);return g.jsx(le,{actionId:"delete",disabled:!n})}function cve(){const n=ti();return!EH(1)||n?null:g.jsxs(As,{id:"edit",label:"context-menu.edit",size:"small",children:[g.jsx(DH,{}),g.jsx(jH,{}),g.jsx(RH,{}),g.jsx(OH,{}),g.jsx(NH,{}),g.jsx(LH,{}),g.jsx(VH,{}),g.jsx(WH,{}),g.jsx(AH,{}),g.jsx(FH,{})]})}function uve(){const n=ns(2),e=U0e();return ti()||!(n||e)?null:g.jsxs(As,{id:"arrange",label:"context-menu.arrange",size:"small",children:[n&&g.jsxs(ot,{id:"align",children:[g.jsx(le,{actionId:"align-left"}),g.jsx(le,{actionId:"align-center-horizontal"}),g.jsx(le,{actionId:"align-right"}),g.jsx(le,{actionId:"align-top"}),g.jsx(le,{actionId:"align-center-vertical"}),g.jsx(le,{actionId:"align-bottom"})]}),g.jsx(dve,{}),n&&g.jsxs(ot,{id:"stretch",children:[g.jsx(le,{actionId:"stretch-horizontal"}),g.jsx(le,{actionId:"stretch-vertical"})]}),(n||e)&&g.jsxs(ot,{id:"flip",children:[g.jsx(le,{actionId:"flip-horizontal"}),g.jsx(le,{actionId:"flip-vertical"})]}),g.jsx(hve,{})]})}function dve(){return ns(3)?g.jsxs(ot,{id:"distribute",children:[g.jsx(le,{actionId:"distribute-horizontal"}),g.jsx(le,{actionId:"distribute-vertical"})]}):null}function hve(){const n=ns(2),e=PH();return n?g.jsxs(ot,{id:"order",children:[g.jsx(le,{actionId:"pack"}),e&&g.jsx(le,{actionId:"stack-horizontal"}),e&&g.jsx(le,{actionId:"stack-vertical"})]}):null}function fve(){const n=ti(),e=ns(1);return n||!e?null:g.jsx(As,{id:"reorder",label:"context-menu.reorder",size:"small",children:g.jsxs(ot,{id:"reorder",children:[g.jsx(le,{actionId:"bring-to-front"}),g.jsx(le,{actionId:"bring-forward"}),g.jsx(le,{actionId:"send-backward"}),g.jsx(le,{actionId:"send-to-back"})]})})}function pve(){const n=te(),e=ie("pages",()=>n.getPages(),[n]),t=ie("current page id",()=>n.getCurrentPageId(),[n]),{addToast:r}=Ya(),s=Ln(),i=ti();return!ns(1)||i?null:g.jsxs(As,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[g.jsx(ot,{id:"pages",children:e.map(a=>g.jsx(yn,{id:a.id,disabled:t===a.id,label:a.name.length>30?`${a.name.slice(0,30)}…`:a.name,onSelect:()=>{n.markHistoryStoppingPoint("move_shapes_to_page"),n.moveShapesToPage(n.getSelectedShapeIds(),a.id);const l=n.getPage(a.id);l&&r({title:"Changed Page",description:`Moved to ${l.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{n.markHistoryStoppingPoint("change-page"),n.setCurrentPage(t)}}]}),s("move-to-page",{source:"context-menu"})}},a.id))}),g.jsx(ot,{id:"new-page",children:g.jsx(le,{actionId:"move-to-new-page"})})]})}function WH(){const n=te();return ie("oneEmbedSelected",()=>{const t=n.getOnlySelectedShape();return t?!!(n.isShapeOfType(t,"embed")&&t.props.url&&!n.isShapeOrAncestorLocked(t)):!1},[n])?g.jsx(le,{actionId:"convert-to-bookmark"}):null}function VH(){const n=te(),e=K_();return ie("oneEmbeddableBookmarkSelected",()=>{const r=n.getOnlySelectedShape();return r?!!(n.isShapeOfType(r,"bookmark")&&r.props.url&&e(r.props.url)&&!n.isShapeOrAncestorLocked(r)):!1},[n])?g.jsx(le,{actionId:"convert-to-embed"}):null}function gve(){const n=te(),e=ie("isSnapMode",()=>n.user.getIsSnapMode(),[n]);return g.jsx(uo,{actionId:"toggle-snap-mode",checked:e})}function mve(){const n=te(),e=ie("isToolLock",()=>n.getInstanceState().isToolLocked,[n]);return g.jsx(uo,{actionId:"toggle-tool-lock",checked:e})}function yve(){const n=te(),e=ie("isGridMode",()=>n.getInstanceState().isGridMode,[n]);return g.jsx(uo,{actionId:"toggle-grid",checked:e})}function Sve(){const n=te(),e=ie("isWrapMode",()=>n.user.getIsWrapMode(),[n]);return g.jsx(uo,{actionId:"toggle-wrap-mode",checked:e})}function vve(){const n=te(),e=ie("isFocusMode",()=>n.getInstanceState().isFocusMode,[n]);return g.jsx(uo,{actionId:"toggle-focus-mode",checked:e})}function xve(){const n=te(),e=ie("edgeScrollSpeed",()=>n.user.getEdgeScrollSpeed(),[n]);return g.jsx(uo,{actionId:"toggle-edge-scrolling",checked:e===1})}function wve(){const n=te(),e=ie("animationSpeed",()=>n.user.getAnimationSpeed(),[n]);return g.jsx(uo,{actionId:"toggle-reduce-motion",checked:e===0})}function bve(){const n=te(),e=ie("isDebugMode",()=>n.getInstanceState().isDebugMode,[n]);return g.jsx(uo,{actionId:"toggle-debug-mode",checked:e})}function Cve(){const n=te(),e=ie("dynamic resize",()=>n.user.getIsDynamicResizeMode(),[n]);return g.jsx(uo,{actionId:"toggle-dynamic-size-mode",checked:e})}function Pve(){const n=te(),e=ie("paste at cursor",()=>n.user.getIsPasteAtCursorMode(),[n]);return g.jsx(uo,{actionId:"toggle-paste-at-cursor",checked:e})}function kve(){const n=te();return ie("show cursor chat",()=>n.getCurrentToolId()==="select"&&!n.getInstanceState().isCoarsePointer,[n])?g.jsx(le,{actionId:"open-cursor-chat"}):null}function Ive(){const n=te(),e=Tv(),t=ie("isSelectToolActive",()=>n.getCurrentToolId()==="select",[n]),r=ie("isSinglePageMode",()=>n.options.maxPages<=1,[n]);return t?g.jsxs(g.Fragment,{children:[e&&g.jsx(kve,{}),g.jsxs(ot,{id:"modify",children:[g.jsx(cve,{}),g.jsx(uve,{}),g.jsx(fve,{}),!r&&g.jsx(pve,{})]}),g.jsx(UH,{}),g.jsx(HH,{}),g.jsx(ot,{id:"select-all",children:g.jsx(KH,{})})]}):null}const Eve=P.memo(function({children:e,disabled:t=!1}){const r=te(),s=it(),{Canvas:i}=Zt(),o=P.useCallback(h=>{if(h){if(r.getInstanceState().isCoarsePointer){const p=r.getSelectedShapes(),{inputs:{currentPagePoint:m}}=r,S=r.getShapesAtPoint(m);if(!r.getSelectedShapes().length||!S.some(x=>p.includes(x))){const x=S.filter(v=>r.isShapeOrAncestorLocked(v));x.length&&r.select(...x.map(v=>v.id))}}}else{const p=r.getOnlySelectedShape();p&&r.isShapeOrAncestorLocked(p)&&r.setSelectedShapes([])}},[r]),a=kn(),[l,c]=Xa("context menu",o),u=e??g.jsx(Ive,{});return g.jsxs(Vde,{dir:"ltr",onOpenChange:c,modal:!1,children:[g.jsx(qde,{onContextMenu:void 0,dir:"ltr",disabled:t,children:i?g.jsx(i,{}):null}),l&&g.jsx(Gde,{container:a,children:g.jsx(Yde,{className:"tlui-menu scrollable","data-testid":"context-menu","aria-label":s("context-menu.title"),alignOffset:-4,collisionPadding:4,onContextMenu:tt,children:g.jsx(Zr,{type:"context-menu",sourceId:"context-menu",children:u})})})]})}),_ve=2e3,Tve=5e3,Mve=Yn(function(){const e=te(),{isChatting:t,chatMessage:r}=e.getInstanceState(),s=P.useRef(-1),[i,o]=P.useState("");return P.useEffect(()=>{if(!t&&r||t){const l=t?Tve:_ve;s.current=e.timers.setTimeout(()=>{e.updateInstanceState({chatMessage:"",isChatting:!1}),o(""),e.focus()},l)}return()=>{clearTimeout(s.current)}},[e,r,t]),t?g.jsx(Ove,{value:i,setValue:o,chatMessage:r}):r.trim()?g.jsx(Ave,{chatMessage:r}):null});function qH(n){const e=te();P.useLayoutEffect(()=>{var o;if(!n.current)return;const{x:r,y:s}=e.inputs.currentScreenPoint;(o=n.current)==null||o.style.setProperty("transform",`translate(${r}px, ${s}px)`);function i(a){var u;const{minX:l,minY:c}=e.getViewportScreenBounds();(u=n.current)==null||u.style.setProperty("transform",`translate(${a.clientX-l}px, ${a.clientY-c}px)`)}return window.addEventListener("pointermove",i),()=>{window.removeEventListener("pointermove",i)}},[n,e])}const Ave=({chatMessage:n})=>{const e=te(),t=P.useRef(null);return qH(t),g.jsx("div",{ref:t,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:e.user.getColor()},children:n})},Ove=Yn(function({chatMessage:e,value:t,setValue:r}){const s=te(),i=it(),o=P.useRef(null),a=e||i("cursor-chat.type-to-chat");qH(o),P.useLayoutEffect(()=>{const p=o.current;if(!p)return;const m=s.textMeasure.measureText(t||a,{fontFamily:"var(--font-body)",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});p.style.setProperty("width",m.w+"px")},[s,t,a]),P.useLayoutEffect(()=>{const p=s.timers.requestAnimationFrame(()=>{var m;(m=o.current)==null||m.focus()});return()=>{cancelAnimationFrame(p)}},[s]);const l=P.useCallback(()=>{s.updateInstanceState({isChatting:!1}),s.focus()},[s]),c=P.useCallback(p=>{const{value:m}=p.target;r(m.slice(0,64)),s.updateInstanceState({chatMessage:m})},[s,r]),u=P.useCallback(p=>{const m=o.current;if(!m)return;const{value:S}=m;switch(p.key){case"Enter":{if(tt(p),p.stopPropagation(),!S){l();return}r("");break}case"Escape":{tt(p),p.stopPropagation(),l();break}}},[l,r]),h=P.useCallback(p=>{p.stopPropagation()},[]);return g.jsx("input",{ref:o,className:"tl-cursor-chat",style:{backgroundColor:s.user.getColor()},onBlur:l,onChange:c,onKeyDown:u,onPaste:h,value:t,placeholder:a,spellCheck:!1})});function pI({checked:n}){return g.jsx(Wo,{icon:n?"check":"none",className:"tlui-button__icon",small:!0})}function Rve(){const n=te(),{addToast:e}=Ya(),{addDialog:t}=cg(),[r,s]=at.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsxs(ot,{id:"items",children:[g.jsx(yn,{id:"hard-reset",onSelect:yz,label:"Hard reset"}),g.jsx(yn,{id:"add-toast",onSelect:()=>{e({id:_t(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),e({id:_t(),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:_t(),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:_t(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),g.jsx(yn,{id:"show-dialog",label:"Show dialog",onSelect:()=>{t({component:({onClose:i})=>g.jsx(Lve,{displayDontShowAgain:!0,onCancel:()=>i(),onContinue:()=>i()}),onClose:()=>{}})}}),g.jsx(yn,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>Nve(n,100)}),g.jsx(yn,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const i=n.getSelectedShapes(),o=i.length===0?n.getRenderingShapes():i;window.alert(`Shapes ${o.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(r)throw Error("oh no!");return null})(),g.jsx(yn,{id:"throw-error",onSelect:()=>s(!0),label:"Throw error"})]}),g.jsxs(ot,{id:"flags",children:[g.jsx(Dve,{}),g.jsx(jve,{})]})]})}function Dve(){const n=Object.values(ln);return n.length?g.jsx(As,{id:"debug flags",label:"Debug Flags",children:g.jsx(ot,{id:"debug flags",children:n.map(e=>g.jsx(GH,{flag:e},e.name))})}):null}function jve(){const n=Object.values(Qte);return n.length?g.jsx(As,{id:"feature flags",label:"Feature Flags",children:g.jsx(ot,{id:"feature flags",children:n.map(e=>g.jsx(GH,{flag:e},e.name))})}):null}function Lve({title:n="title",body:e="hello hello hello",cancel:t="Cancel",confirm:r="Continue",displayDontShowAgain:s=!1,maxWidth:i="350",onCancel:o,onContinue:a}){const[l,c]=at.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsxs(Iv,{children:[g.jsx(Ev,{children:n}),g.jsx(_v,{})]}),g.jsx(Cp,{style:{maxWidth:i},children:e}),g.jsxs(U_,{className:"tlui-dialog__footer__actions",children:[s&&g.jsxs(He,{type:"normal",onClick:()=>c(!l),style:{marginRight:"auto"},children:[g.jsx(pI,{checked:l}),g.jsx(Cn,{children:"Don’t show again"})]}),g.jsx(He,{type:"normal",onClick:o,children:g.jsx(Cn,{children:t})}),g.jsx(He,{type:"primary",onClick:async()=>a(),children:g.jsx(Cn,{children:r})})]})]})}const GH=Yn(function({flag:e,onChange:t}){const r=e.get();return g.jsx(Ov,{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),t==null||t(!r)}})});let RN=0;function Nve(n,e){const t=n.options.adjacentShapeMargin,r=Array(e),s=Math.floor(Math.sqrt(e));for(let i=0;i<e;i++)RN++,r[i]={id:Dt("box"+RN),type:"geo",x:i%s*(100+t),y:Math.floor(i/s)*(100+t)};n.run(()=>{n.createShapes(r).setSelectedShapes(r.map(i=>i.id))})}function Fve({children:n}){const e=n??g.jsx(Rve,{});return g.jsxs(Z_,{id:"debug",children:[g.jsx(J_,{children:g.jsx(He,{type:"icon",title:"Debug menu",children:g.jsx(ct,{icon:"dots-horizontal"})})}),g.jsx(Q_,{side:"top",align:"end",alignOffset:0,children:g.jsx(Zr,{type:"menu",sourceId:"debug-panel",children:e})})]})}const zve=P.memo(function(){const{DebugMenu:e}=ac(),t=P.useRef(null);return Ga(t),g.jsxs("footer",{ref:t,className:"tlui-debug-panel",children:[g.jsx(Bve,{}),g.jsx(Uve,{}),e&&g.jsx(e,{})]})});function $ve(n=!0){const[e,t]=P.useState(0),r=te();P.useEffect(()=>{if(!n)return;const s=()=>t(i=>i+1);return r.on("tick",s),()=>{r.off("tick",s)}},[r,n])}const Bve=Yn(function(){$ve();const e=te(),t=e.getPath(),r=e.getHoveredShape(),s=e.getOnlySelectedShape(),i=t==="select.idle"||!t.includes("select.")?r:s,o=i&&t.includes("select.")?` / ${i.type||""}${"geo"in i.props?" / "+i.props.geo:""} / [${k.ToInt(e.getPointInShapeSpace(i,e.inputs.currentPagePoint))}]`:"",a=t.startsWith("select.")&&!t.includes(".idle")?` / [${k.ToInt(e.inputs.originPagePoint)}] → [${k.ToInt(e.inputs.currentPagePoint)}] = ${k.Dist(e.inputs.originPagePoint,e.inputs.currentPagePoint).toFixed(0)}`:"";return g.jsx("div",{className:"tlui-debug-panel__current-state",children:`${t}${o}${a}`})});function Uve(){const n=te(),e=ie("show_fps",()=>ln.showFps.get(),[ln]),t=P.useRef(null);return P.useEffect(()=>{if(!e)return;const r=250;let s=0,i=-1,o=performance.now(),a=0,l=0,c=!1;function u(){if(l++,a=performance.now()-o,a>r){const h=Math.round(l*(r/a)*(1e3/r));h>s&&(s=h);const p=s*.75;(h<p&&!c||h>=p&&c)&&(c=!c),t.current.innerHTML=`FPS ${h.toString()}`,t.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),a-=r,l=0,o=performance.now()}i=n.timers.requestAnimationFrame(u)}return u(),()=>{cancelAnimationFrame(i)}},[e,n]),e?g.jsx("div",{ref:t}):null}const Hve=P.memo(function(){const e=Rr(),t=P.useRef(null);Ga(t);const{MainMenu:r,QuickActions:s,ActionsMenu:i,PageMenu:o}=ac(),a=te(),l=ie("isSinglePageMode",()=>a.options.maxPages<=1,[a]),c=a.options.actionShortcutsLocation==="menu"?!0:a.options.actionShortcutsLocation==="toolbar"?!1:e>=dn.TABLET;return!r&&!o&&!c?null:g.jsx("nav",{ref:t,className:"tlui-menu-zone",children:g.jsxs("div",{className:"tlui-buttons__horizontal",role:"toolbar",children:[r&&g.jsx(r,{}),o&&!l&&g.jsx(o,{}),c?g.jsxs(g.Fragment,{children:[s&&g.jsx(s,{}),i&&g.jsx(i,{})]}):null]})})});function Kve(){const n=te(),e=bu(),[t,r]=P.useState(!1),s=P.useRef(!1);return Hl("toggle showback to content",()=>{const i=s.current,o=n.getCurrentPageShapeIds();let a=!1;o.size&&(a=o.size===n.getCulledShapes().size),i!==a&&(r(a),s.current=a)},[n]),t?g.jsx(le,{actionId:"back-to-content",onSelect:()=>{e["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function Wve(){const n=te();return ie("is pen mode",()=>n.getInstanceState().isPenMode,[n])?g.jsx(le,{actionId:"exit-pen-mode"}):null}function Vve(){const n=te(),e=bu();return ie("is following user",()=>!!n.getInstanceState().followingUserId,[n])?g.jsx(yn,{...e["stop-following"]}):null}function qve(){return g.jsxs(g.Fragment,{children:[g.jsx(Wve,{}),g.jsx(Kve,{}),g.jsx(Vve,{})]})}function Gve({children:n}){const e=n??g.jsx(qve,{});return g.jsx("div",{className:"tlui-helper-buttons",children:g.jsx(Zr,{type:"helper-buttons",sourceId:"helper-buttons",children:e})})}function Yve(){const n=Tv();return g.jsxs(g.Fragment,{children:[g.jsxs(ot,{label:"shortcuts-dialog.tools",id:"tools",children:[g.jsx(le,{actionId:"toggle-tool-lock"}),g.jsx(le,{actionId:"insert-media"}),g.jsx(vs,{toolId:"select"}),g.jsx(vs,{toolId:"draw"}),g.jsx(vs,{toolId:"eraser"}),g.jsx(vs,{toolId:"hand"}),g.jsx(vs,{toolId:"rectangle"}),g.jsx(vs,{toolId:"ellipse"}),g.jsx(vs,{toolId:"arrow"}),g.jsx(vs,{toolId:"line"}),g.jsx(vs,{toolId:"text"}),g.jsx(vs,{toolId:"frame"}),g.jsx(vs,{toolId:"note"}),g.jsx(vs,{toolId:"laser"}),g.jsx(yn,{id:"pointer-down",label:"tool.pointer-down",kbd:",",onSelect:()=>{}})]}),g.jsxs(ot,{label:"shortcuts-dialog.preferences",id:"preferences",children:[g.jsx(le,{actionId:"toggle-dark-mode"}),g.jsx(le,{actionId:"toggle-focus-mode"}),g.jsx(le,{actionId:"toggle-grid"})]}),g.jsxs(ot,{label:"shortcuts-dialog.edit",id:"edit",children:[g.jsx(le,{actionId:"undo"}),g.jsx(le,{actionId:"redo"}),g.jsx(le,{actionId:"cut"}),g.jsx(le,{actionId:"copy"}),g.jsx(le,{actionId:"paste"}),g.jsx(le,{actionId:"select-all"}),g.jsx(le,{actionId:"delete"}),g.jsx(le,{actionId:"duplicate"})]}),g.jsxs(ot,{label:"shortcuts-dialog.view",id:"view",children:[g.jsx(le,{actionId:"zoom-in"}),g.jsx(le,{actionId:"zoom-out"}),g.jsx(le,{actionId:"zoom-to-100"}),g.jsx(le,{actionId:"zoom-to-fit"}),g.jsx(le,{actionId:"zoom-to-selection"})]}),g.jsxs(ot,{label:"shortcuts-dialog.transform",id:"transform",children:[g.jsx(le,{actionId:"bring-to-front"}),g.jsx(le,{actionId:"bring-forward"}),g.jsx(le,{actionId:"send-backward"}),g.jsx(le,{actionId:"send-to-back"}),g.jsx(le,{actionId:"group"}),g.jsx(le,{actionId:"ungroup"}),g.jsx(le,{actionId:"flip-horizontal"}),g.jsx(le,{actionId:"flip-vertical"}),g.jsx(le,{actionId:"align-top"}),g.jsx(le,{actionId:"align-center-vertical"}),g.jsx(le,{actionId:"align-bottom"}),g.jsx(le,{actionId:"align-left"}),g.jsx(le,{actionId:"align-center-horizontal"}),g.jsx(le,{actionId:"align-right"})]}),g.jsxs(ot,{label:"shortcuts-dialog.a11y",id:"a11y",children:[g.jsx(yn,{id:"a11y-select-next-shape",label:"a11y.select-shape",kbd:"[[Tab]]",onSelect:()=>{}}),g.jsx(yn,{id:"a11y-select-next-shape-direction",label:"a11y.select-shape-direction",kbd:"cmd+↑→↓←",onSelect:()=>{}}),g.jsx(yn,{id:"a11y-pan-camera",label:"a11y.pan-camera",kbd:"[[Space]]+↑→↓←",onSelect:()=>{}}),g.jsx(yn,{id:"a11y-move-shape",label:"a11y.move-shape",kbd:"↑→↓←",onSelect:()=>{}}),g.jsx(yn,{id:"a11y-move-shape-faster",label:"a11y.move-shape-faster",kbd:"shift+↑→↓←",onSelect:()=>{}}),g.jsx(le,{actionId:"enlarge-shapes"}),g.jsx(le,{actionId:"shrink-shapes"}),g.jsx(le,{actionId:"a11y-repeat-shape-announce"})]}),n&&g.jsx(ot,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:g.jsx(le,{actionId:"open-cursor-chat"})})]})}const Xve=P.memo(function({children:e}){const t=it(),r=Rr(),s=e??g.jsx(Yve,{});return g.jsxs(g.Fragment,{children:[g.jsxs(Iv,{className:"tlui-shortcuts-dialog__header",children:[g.jsx(Ev,{children:t("shortcuts-dialog.title")}),g.jsx(_v,{})]}),g.jsx(Cp,{className:$e("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=dn.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=dn.TABLET}),children:g.jsx(Zr,{type:"keyboard-shortcuts",sourceId:"kbd",children:s})}),g.jsx("div",{className:"tlui-dialog__scrim"})]})});function YH(){const n=dr(),e=Ln(),t=ie("locale",()=>n==null?void 0:n.user.getLocale(),[n]);return n?g.jsx(As,{id:"help menu language",label:"menu.language",children:g.jsx(ot,{id:"languages",children:mp.map(({locale:r,label:s})=>g.jsx(Ov,{id:`language-${r}`,title:r,label:s,checked:r===t,readonlyOk:!0,onSelect:()=>{n.user.updateUserPreferences({locale:r}),e("change-language",{source:"menu",locale:r})}},r))})}):null}function Zve(){return g.jsxs(g.Fragment,{children:[g.jsx(YH,{}),g.jsx(XH,{})]})}function XH(){const{KeyboardShortcutsDialog:n}=ac(),{addDialog:e}=cg(),t=P.useCallback(()=>{n&&e({component:n})},[e,n]);return n?g.jsx(yn,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:t}):null}function Jve(){return g.jsxs(g.Fragment,{children:[g.jsxs(ot,{id:"basic",children:[g.jsx(exe,{}),g.jsx(sxe,{}),g.jsx(Qve,{}),g.jsx(ixe,{})]}),g.jsx(oxe,{})]})}function Qve(){return g.jsxs(As,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[g.jsxs(ot,{id:"export-all-as-group",children:[g.jsx(le,{actionId:"export-all-as-svg"}),g.jsx(le,{actionId:"export-all-as-png"})]}),g.jsx(ot,{id:"export-all-as-bg",children:g.jsx(jT,{})})]})}function exe(){return g.jsxs(As,{id:"edit",label:"menu.edit",children:[g.jsx(rxe,{}),g.jsx(UH,{}),g.jsx(HH,{}),g.jsx(txe,{}),g.jsx(nxe,{}),g.jsx(ot,{id:"select-all",children:g.jsx(KH,{})})]})}function txe(){return g.jsxs(ot,{id:"misc",children:[g.jsx(DH,{}),g.jsx(jH,{}),g.jsx(OH,{}),g.jsx(AH,{}),g.jsx(LH,{}),g.jsx(NH,{}),g.jsx(VH,{}),g.jsx(WH,{}),g.jsx(RH,{})]})}function nxe(){return g.jsxs(ot,{id:"lock",children:[g.jsx(FH,{}),g.jsx(rve,{})]})}function rxe(){const n=MH(),e=TH();return g.jsxs(ot,{id:"undo-redo",children:[g.jsx(le,{actionId:"undo",disabled:!n}),g.jsx(le,{actionId:"redo",disabled:!e})]})}function sxe(){return g.jsx(As,{id:"view",label:"menu.view",children:g.jsxs(ot,{id:"view-actions",children:[g.jsx(le,{actionId:"zoom-in"}),g.jsx(le,{actionId:"zoom-out"}),g.jsx(zH,{}),g.jsx($H,{}),g.jsx(BH,{})]})})}function ixe(){return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"insert-embed"}),g.jsx(le,{actionId:"insert-media"})]})}function oxe(){return g.jsxs(ot,{id:"preferences",children:[g.jsxs(As,{id:"preferences",label:"menu.preferences",children:[g.jsxs(ot,{id:"preferences-actions",children:[g.jsx(gve,{}),g.jsx(mve,{}),g.jsx(yve,{}),g.jsx(Sve,{}),g.jsx(vve,{}),g.jsx(xve,{}),g.jsx(wve,{}),g.jsx(Cve,{}),g.jsx(Pve,{}),g.jsx(bve,{})]}),g.jsx(ot,{id:"color-scheme",children:g.jsx(cpe,{})})]}),g.jsx(YH,{}),g.jsx(XH,{})]})}const axe=P.memo(function({children:e}){const t=kn(),[r,s]=Xa("main menu"),i=it(),o=e??g.jsx(Jve,{});return g.jsxs(L_,{dir:"ltr",open:r,onOpenChange:s,modal:!1,children:[g.jsx(N_,{asChild:!0,dir:"ltr",children:g.jsx(He,{type:"icon","data-testid":"main-menu.button",title:i("menu.title"),children:g.jsx(ct,{icon:"menu",small:!0})})}),g.jsx(Pv,{container:t,children:g.jsx(F_,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:g.jsx(Zr,{type:"menu",sourceId:"main-menu",children:o})})})]})}),iP={};function mf(n){if(iP[n])return iP[n];const t=document.createElement("canvas").getContext("2d");t.fillStyle=n,t.fillRect(0,0,1,1);const[r,s,i,o]=t.getImageData(0,0,1,1).data,a=new Float32Array([r/255,s/255,i/255,o/255]);return iP[n]=a,a}const Ky=10,ZH=4*6*Ky+12+4*12;function xd(n,{center:e,radius:t,numArcSegments:r=20,startAngle:s=0,endAngle:i=Rt,offset:o=0}){const a=(i-s)/r;let l=o;for(let c=s;c<i;c+=a)n[l++]=e.x,n[l++]=e.y,n[l++]=e.x+Math.cos(c)*t,n[l++]=e.y+Math.sin(c)*t,n[l++]=e.x+Math.cos(c+a)*t,n[l++]=e.y+Math.sin(c+a)*t;return n}function wd(n,e,t,r,s,i){n[e++]=t,n[e++]=r,n[e++]=t,n[e++]=r+i,n[e++]=t+s,n[e++]=r,n[e++]=t+s,n[e++]=r,n[e++]=t,n[e++]=r+i,n[e++]=t+s,n[e++]=r+i}function lxe(n,e,t){const r=Ky;t=Math.min(t,Math.min(e.w,e.h)/2);const s=Se.ExpandBy(e,-t);if(s.w<=0||s.h<=0)return xd(n,{center:e.center,radius:t,numArcSegments:Ky*4}),Ky*4*6;let i=0;return wd(n,i,s.minX,s.minY,s.w,s.h),i+=12,wd(n,i,s.minX,e.minY,s.w,t),i+=12,wd(n,i,s.maxX,s.minY,t,s.h),i+=12,wd(n,i,s.minX,s.maxY,s.w,t),i+=12,wd(n,i,e.minX,s.minY,t,s.h),i+=12,xd(n,{numArcSegments:r,offset:i,center:s.point,radius:t,startAngle:wt,endAngle:wt*1.5}),i+=r*6,xd(n,{numArcSegments:r,offset:i,center:k.Add(s.point,new k(s.w,0)),radius:t,startAngle:wt*1.5,endAngle:Rt}),i+=r*6,xd(n,{numArcSegments:r,offset:i,center:k.Add(s.point,s.size),radius:t,startAngle:0,endAngle:Kt}),i+=r*6,xd(n,{numArcSegments:r,offset:i,center:k.Add(s.point,new k(0,s.h)),radius:t,startAngle:Kt,endAngle:wt}),ZH}function cxe(n){if(!n)throw new Error("Canvas element not found");const e=n.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Failed to get webgl2 context");const t=`#version 300 es
|
|
484
|
-
precision mediump float;
|
|
485
|
-
|
|
486
|
-
in vec2 shapeVertexPosition;
|
|
487
|
-
|
|
488
|
-
uniform vec4 canvasPageBounds;
|
|
489
|
-
|
|
490
|
-
// taken (with thanks) from
|
|
491
|
-
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
492
|
-
void main() {
|
|
493
|
-
// convert the position from pixels to 0.0 to 1.0
|
|
494
|
-
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
495
|
-
|
|
496
|
-
// convert from 0->1 to 0->2
|
|
497
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
498
|
-
|
|
499
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
500
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
501
|
-
|
|
502
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
503
|
-
}`,r=e.createShader(e.VERTEX_SHADER);if(!r)throw new Error("Failed to create vertex shader");if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const s=`#version 300 es
|
|
504
|
-
precision mediump float;
|
|
505
|
-
|
|
506
|
-
uniform vec4 fillColor;
|
|
507
|
-
out vec4 outputColor;
|
|
508
|
-
|
|
509
|
-
void main() {
|
|
510
|
-
outputColor = fillColor;
|
|
511
|
-
}`,i=e.createShader(e.FRAGMENT_SHADER);if(!i)throw new Error("Failed to create fragment shader");if(e.shaderSource(i,s),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const o=e.createProgram();if(!o)throw new Error("Failed to create program");if(e.attachShader(o,r),e.attachShader(o,i),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("Failed to link program");e.useProgram(o);const a=e.getAttribLocation(o,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");e.enableVertexAttribArray(a);const l=e.getUniformLocation(o,"canvasPageBounds"),c=e.getUniformLocation(o,"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:iy(e,1024),unselectedShapes:iy(e,4096),viewport:iy(e,ZH),collaborators:iy(e,1024),prepareTriangles(p,m){e.bindBuffer(e.ARRAY_BUFFER,p.buffer),e.bufferData(e.ARRAY_BUFFER,p.vertices,e.STATIC_DRAW,0,m),e.enableVertexAttribArray(a),e.vertexAttribPointer(a,2,e.FLOAT,!1,0,0)},drawTrianglesTransparently(p){e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLES,0,p/2),e.disable(e.BLEND)},drawTriangles(p){e.drawArrays(e.TRIANGLES,0,p/2)},setFillColor(p){e.uniform4fv(c,p)},setCanvasPageBounds(p){e.uniform4fv(l,p)}}}function iy(n,e){const t=n.createBuffer();if(!t)throw new Error("Failed to create buffer");return{buffer:t,vertices:new Float32Array(e)}}function DN(n,e,t){let r=n.vertices.length;for(;r<e+t.length;)r*=2;if(r!=n.vertices.length){const s=new Float32Array(r);s.set(n.vertices),n.vertices=s}n.vertices.set(t,e)}var uxe=Object.create,JH=Object.defineProperty,dxe=Object.getOwnPropertyDescriptor,hxe=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),QH=n=>{throw TypeError(n)},eK=(n,e,t)=>e in n?JH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,fxe=n=>[,,,uxe(null)],tK=["class","method","getter","setter","accessor","field","value","get","set"],nK=n=>n!==void 0&&typeof n!="function"?QH("Function expected"):n,pxe=(n,e,t,r,s)=>({kind:tK[n],name:e,metadata:r,addInitializer:i=>t._?QH("Already initialized"):s.push(nK(i||null))}),gxe=(n,e)=>eK(e,hxe("metadata"),n[3]),mxe=(n,e,t,r)=>{for(var s=0,i=n[e>>1],o=i&&i.length;s<o;s++)i[s].call(t);return r},Jo=(n,e,t,r,s,i)=>{for(var o,a,l,c,u=e&7,h=!1,p=!1,m=2,S=tK[u+5],x=n[m]||(n[m]=[]),v=(s=s.prototype,dxe(s,t)),w=r.length-1;w>=0;w--)l=pxe(u,t,a={},n[3],x),l.static=h,l.private=p,c=l.access={has:C=>t in C},c.get=C=>C[t],o=(0,r[w])(v[S],l),a._=1,nK(o)&&(v[S]=o);return v&&JH(s,t,v),s},ma=(n,e,t)=>eK(n,typeof e!="symbol"?e+"":e,t),rK,sK,iK,oK,aK,lK,cK,uK,dK,hK,ni;hK=[ks],dK=[ce],uK=[ce],cK=[ce],lK=[ce],aK=[ce],oK=[ce],iK=[ce],sK=[ce],rK=[ks];class Ai{constructor(e,t,r){this.editor=e,this.elem=t,this.container=r,mxe(ni,5,this),ma(this,"disposables",[]),ma(this,"gl"),ma(this,"shapeGeometryCache"),ma(this,"colors"),ma(this,"id",_t()),ma(this,"canvasBoundingClientRect",Sn("canvasBoundingClientRect",new Se)),ma(this,"originPagePoint",new k),ma(this,"originPageCenter",new k),ma(this,"isInViewport",!1),this.gl=cxe(t),this.shapeGeometryCache=e.store.createComputedCache("webgl-geometry",s=>{const i=e.getShapeMaskedPageBounds(s.id);if(!i)return null;const o=new Float32Array(12);return wd(o,0,i.x,i.y,i.w,i.h),o}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),Pi("minimap render",this.render))}close(){return this.disposables.forEach(e=>e())}_getColors(){const e=getComputedStyle(this.editor.getContainer());return{shapeFill:mf(e.getPropertyValue("--color-text-3").trim()),selectFill:mf(e.getPropertyValue("--color-selected").trim()),viewportFill:mf(e.getPropertyValue("--color-muted-1").trim()),background:mf(e.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const e=this.editor.getViewportPageBounds(),t=this.editor.getCurrentPageBounds();return t?Se.Expand(t,e):e}getContentScreenBounds(){const e=this.getContentPageBounds(),t=this.editor.pageToScreen(e.point),r=this.editor.pageToScreen(new k(e.maxX,e.maxY));return new Se(t.x,t.y,r.x-t.x,r.y-t.y)}_getCanvasBoundingRect(){const{x:e,y:t,width:r,height:s}=this.elem.getBoundingClientRect();return new Se(e,t,r,s)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const e=new ResizeObserver(()=>{const t=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(t)});return e.observe(this.elem),e.observe(this.container),()=>e.disconnect()}getCanvasSize(){const e=this.canvasBoundingClientRect.get(),t=this.getDpr();return new k(e.width*t,e.height*t)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const e=this.getCanvasScreenBounds(),t=this.getContentPageBounds(),r=e.width/e.height;let s=t.width,i=s/r;i<t.height&&(i=t.height,s=i*r);const o=new Se(0,0,s,i);return o.center=t.center,o}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:e,y:t,w:r,h:s}=this.getCanvasPageBounds();return new Float32Array([e,t,r,s])}getMinimapPagePoint(e,t){const r=this.getCanvasPageBounds(),s=this.getCanvasScreenBounds();let i=e-s.x,o=t-s.y;return i*=r.width/s.width,o*=r.height/s.height,i+=r.minX,o+=r.minY,new k(i,o,1)}minimapScreenPointToPagePoint(e,t,r=!1,s=!1){const{editor:i}=this,o=i.getViewportPageBounds();let{x:a,y:l}=this.getMinimapPagePoint(e,t);if(s){const c=this.editor.getCurrentPageBounds()??new Se,u=c.minX-o.width/2,h=c.maxX+o.width/2,p=c.minY-o.height/2,m=c.maxY+o.height/2,S=Math.max(0,u+o.width-a),x=Math.max(0,-(h-o.width-a)),v=Math.max(0,p+o.height-l),w=Math.max(0,-(m-o.height-l));a+=(S-x)/2,l+=(v-w)/2,a=Mn(a,u,h),l=Mn(l,p,m)}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 k(a,l)}render(){const e=this.gl.context,t=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=t.x,this.elem.height=t.y,e.viewport(0,0,t.x,t.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 i=0,o=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 p=h.length;r.has(u)?(DN(this.gl.selectedShapes,i,h),i+=p):(DN(this.gl.unselectedShapes,o,h),o+=p)}this.drawShapes(this.gl.unselectedShapes,o,s.shapeFill),this.drawShapes(this.gl.selectedShapes,i,s.selectFill),this.drawViewport(),this.drawCollaborators()}drawShapes(e,t,r){this.gl.prepareTriangles(e,t),this.gl.setFillColor(r),this.gl.drawTriangles(t)}drawViewport(){const e=this.editor.getViewportPageBounds(),t=lxe(this.gl.viewport.vertices,e,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,t),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(t),It.isSafari&&(this.gl.drawTrianglesTransparently(t),this.gl.drawTrianglesTransparently(t),this.gl.drawTrianglesTransparently(t))}drawCollaborators(){const e=this.editor.getCollaboratorsOnCurrentPage();if(!e.length)return;const t=20,r=t*6,s=r*e.length;this.gl.collaborators.vertices.length<s&&(this.gl.collaborators.vertices=new Float32Array(s));const i=this.gl.collaborators.vertices;let o=0;const a=this.getZoom();for(const{cursor:l}of e)l&&(xd(i,{center:k.From(l),radius:3*a,offset:o,numArcSegments:t}),o+=r);this.gl.prepareTriangles(this.gl.collaborators,s),o=0;for(const{color:l}of e)this.gl.setFillColor(mf(l)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,o/2,r/2),o+=r}}ni=fxe();Jo(ni,1,"close",hK,Ai);Jo(ni,1,"getDpr",dK,Ai);Jo(ni,1,"getContentPageBounds",uK,Ai);Jo(ni,1,"getContentScreenBounds",cK,Ai);Jo(ni,1,"getCanvasSize",lK,Ai);Jo(ni,1,"getCanvasClientPosition",aK,Ai);Jo(ni,1,"getCanvasPageBounds",oK,Ai);Jo(ni,1,"getZoom",iK,Ai);Jo(ni,1,"getCanvasPageBoundsArray",sK,Ai);Jo(ni,1,"render",rK,Ai);gxe(ni,Ai);function yxe(){const n=te(),e=kn(),t=P.useRef(null),r=P.useRef(!1),s=P.useRef();P.useEffect(()=>{try{const u=new Ai(n,t.current,e);return s.current=u,s.current.close}catch(u){n.annotateError(u,{origin:"minimap",willCrashApp:!1}),n.timers.setTimeout(()=>{throw u})}},[n,e]);const i=P.useCallback(u=>{if(!n.getCurrentPageShapeIds().size||!s.current)return;const h=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),p=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);s.current.originPagePoint.setTo(p),s.current.originPageCenter.setTo(n.getViewportPageBounds().center),n.centerOnPoint(h,{animation:{duration:n.options.animationMediumMs}})},[n]),o=P.useCallback(u=>{if(!s.current)return;const h=u.currentTarget;if(Kp(h,u),!n.getCurrentPageShapeIds().size)return;r.current=!0,s.current.isInViewport=!1;const p=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),m=n.getViewportPageBounds(),S=s.current.getContentPageBounds();if(new Se(S.x-m.width/2,S.y-m.height/2,S.width+m.width,S.height+m.height).containsPoint(p)&&!m.containsPoint(p)){s.current.isInViewport=m.containsPoint(p);const w=k.Sub(m.center,m.point),C=k.Add(p,w);s.current.originPagePoint.setTo(C),s.current.originPageCenter.setTo(p),n.centerOnPoint(p,{animation:{duration:n.options.animationMediumMs}})}else{const w=s.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);s.current.isInViewport=m.containsPoint(w),s.current.originPagePoint.setTo(w),s.current.originPageCenter.setTo(m.center)}function v(w){h&&Wp(h,w),r.current=!1,document.body.removeEventListener("pointerup",v)}document.body.addEventListener("pointerup",v)},[n]),a=P.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 x=s.current.originPagePoint.clone().sub(s.current.originPageCenter);n.centerOnPoint(k.Sub(h,x));return}n.centerOnPoint(h)}const p=s.current.getMinimapPagePoint(u.clientX,u.clientY),m=n.pageToScreen(p),S={type:"pointer",target:"canvas",name:"pointer_move",...Ks(u),point:m,isPen:n.getInstanceState().isPenMode};n.dispatch(S)},[n]),l=P.useCallback(u=>{const h=iz(u);n.dispatch({type:"wheel",name:"wheel",delta:h,point:new k(u.clientX,u.clientY),shiftKey:u.shiftKey,altKey:u.altKey,ctrlKey:u.metaKey||u.ctrlKey,metaKey:u.metaKey,accelKey:Pr(u)})},[n]),c=eg();return P.useEffect(()=>{n.timers.setTimeout(()=>{var u,h;(u=s.current)==null||u.updateColors(),(h=s.current)==null||h.render()})},[c,n]),g.jsx("div",{className:"tlui-minimap",children:g.jsx("canvas",{role:"img","aria-label":"minimap",ref:t,className:"tlui-minimap__canvas",onDoubleClick:i,onPointerMove:a,onPointerDown:o,onWheelCapture:l})})}function Sxe(n,e){const[t,r]=at.useState(e);at.useLayoutEffect(()=>{const i=EI(n);if(i)try{r(JSON.parse(i))}catch{console.error(`Could not restore value ${n} from local storage.`)}},[n]);const s=at.useCallback(i=>{r(o=>{const a=typeof i=="function"?i(o):i;return _I(n,JSON.stringify(a)),a})},[n]);return[t,s]}const vxe=P.memo(function(){const e=bu(),t=it(),r=Rr(),s=P.useRef(null);Ga(s);const[i,o]=Sxe("minimap",!0),a=P.useCallback(()=>{o(u=>!u)},[o]),{ZoomMenu:l,Minimap:c}=ac();return r<dn.MOBILE?null:g.jsxs("div",{ref:s,className:"tlui-navigation-panel",children:[g.jsx("div",{className:"tlui-buttons__horizontal",role:"toolbar",children:l&&r<dn.TABLET?g.jsx(l,{}):i?g.jsxs(g.Fragment,{children:[l&&g.jsx(l,{}),c&&g.jsx(He,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:g.jsx(ct,{icon:i?"chevrons-ne":"chevrons-sw"})})]}):g.jsxs(g.Fragment,{children:[g.jsx(He,{type:"icon","data-testid":"minimap.zoom-out",title:`${t(Pp(e["zoom-out"].label))} ${Bk(e["zoom-out"].kbd)}`,onClick:()=>e["zoom-out"].onSelect("navigation-zone"),children:g.jsx(ct,{icon:"minus"})}),l&&g.jsx(l,{}),g.jsx(He,{type:"icon","data-testid":"minimap.zoom-in",title:`${t(Pp(e["zoom-in"].label))} ${Bk(e["zoom-in"].kbd)}`,onClick:()=>e["zoom-in"].onSelect("navigation-zone"),children:g.jsx(ct,{icon:"plus"})}),c&&g.jsx(He,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:g.jsx(ct,{icon:i?"chevrons-ne":"chevrons-sw"})})]})}),c&&r>=dn.TABLET&&!i&&g.jsx(c,{})]})}),xxe=function({name:e,id:t,isCurrentPage:r,onCancel:s,onComplete:i}){const o=te(),a=Ln(),l=P.useRef(null),c=P.useRef(null),u=P.useCallback(()=>{c.current=o.markHistoryStoppingPoint("rename page")},[o]),h=P.useCallback(m=>{o.renamePage(t,m||"New Page"),a("rename-page",{source:"page-menu"})},[o,t,a]),p=P.useCallback(()=>{c.current&&o.bailToMark(c.current),s()},[o,s]);return g.jsx(lg,{className:"tlui-page-menu__item__input",ref:m=>l.current=m,defaultValue:e,onValueChange:h,onComplete:i,onCancel:p,onFocus:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:r,autoSelect:!0})},gI=(n,e,t,r,s)=>{let i;const o=n.getPages(),a=t>r?o[r-1]:o[r],l=t>r?o[r]:o[r+1];a&&!l?i=Ro(a.index):!a&&l?i=sq(o[0].index):i=sp(a.index,l.index),i!==o[t].index&&(n.markHistoryStoppingPoint("moving page"),n.updatePage({id:e,index:i}),s("move-page",{source:"page-menu"}))},jN=Yn(function({index:e,listSize:t,item:r,onRename:s}){const i=te(),o=it(),a=i.getPages(),l=Ln(),c=P.useCallback(()=>{i.markHistoryStoppingPoint("creating page");const m=Wr.createId();i.duplicatePage(r.id,m),l("duplicate-page",{source:"page-menu"})},[i,r,l]),u=P.useCallback(()=>{gI(i,r.id,e,e-1,l)},[i,r,e,l]),h=P.useCallback(()=>{gI(i,r.id,e,e+1,l)},[i,r,e,l]),p=P.useCallback(()=>{i.markHistoryStoppingPoint("deleting page"),i.deletePage(r.id),l("delete-page",{source:"page-menu"})},[i,r,l]);return g.jsxs(Z_,{id:`page item submenu ${e}`,children:[g.jsx(J_,{children:g.jsx(He,{type:"icon",title:o("page-menu.submenu.title"),children:g.jsx(ct,{icon:"dots-vertical",small:!0})})}),g.jsx(Q_,{alignOffset:0,side:"right",sideOffset:-4,children:g.jsxs(Zr,{type:"menu",sourceId:"page-menu",children:[g.jsxs(ot,{id:"modify",children:[s&&g.jsx(yn,{id:"rename",label:"page-menu.submenu.rename",onSelect:s}),g.jsx(yn,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=i.options.maxPages}),e>0&&g.jsx(yn,{id:"move-up",onSelect:u,label:"page-menu.submenu.move-up"}),e<t-1&&g.jsx(yn,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:h})]}),t>1&&g.jsx(ot,{id:"delete",children:g.jsx(yn,{id:"delete",onSelect:p,label:"page-menu.submenu.delete"})})]})})]})}),wxe=P.memo(function(){const e=te(),t=Ln(),r=it(),s=Rr(),i=P.useCallback(()=>w(!1),[]),[o,a]=Xa("page-menu",i),l=36,c=P.useRef(null),u=ie("pages",()=>e.getPages(),[e]),h=ie("currentPage",()=>e.getCurrentPage(),[e]),p=ie("currentPageId",()=>e.getCurrentPageId(),[e]),m=ti(),S=ie("maxPageCountReached",()=>e.getPages().length>=e.options.maxPages,[e]),x=ie("isCoarsePointer",()=>e.getInstanceState().isCoarsePointer,[e]),[v,w]=P.useState(!1),C=P.useCallback(()=>{m||w(L=>!L)},[m]),_=P.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[E,T]=P.useState(Object.fromEntries(u.map((L,N)=>[L.id,{y:N*l,offsetY:0,isSelected:!1}])));P.useLayoutEffect(()=>{T(Object.fromEntries(u.map((L,N)=>[L.id,{y:N*l,offsetY:0,isSelected:!1}])))},[l,u]),P.useEffect(()=>{o&&e.timers.requestAnimationFrame(()=>{const L=document.querySelector(`[data-testid="page-menu-item-${p}"]`);if(L){const N=c.current;if(!N)return;const U=L.offsetTop,Y=N.scrollTop;U<Y&&N.scrollTo({top:U});const W=U+l,z=N.scrollTop+N.offsetHeight;W>z&&N.scrollTo({top:W-N.offsetHeight})}})},[l,p,o,e]);const A=P.useCallback(L=>{const{clientY:N,currentTarget:U}=L,{dataset:{id:Y,index:W}}=U;if(!Y||!W)return;const z=_.current;Kp(L.currentTarget,L),z.status="pointing",z.pointing={id:Y,index:+W};const ee=E[Y].y;z.startY=N,z.startIndex=Math.max(0,Math.min(Math.round(ee/l),u.length-1))},[l,u.length,E]),O=P.useCallback(L=>{const N=_.current;if(N.status==="pointing"){const{clientY:U}=L,Y=U-N.startY;Math.abs(Y)>5&&(N.status="dragging")}if(N.status==="dragging"){const{clientY:U}=L,Y=U-N.startY,W=E[N.pointing.id],{startIndex:z,pointing:V}=N,ee=W.y+Y,B=Math.max(0,Math.min(Math.round(ee/l),u.length-1)),Q={...E};if(Q[V.id]={y:W.y,offsetY:Y,isSelected:!0},B!==N.dragIndex){N.dragIndex=B;for(let me=0;me<u.length;me++){const Pe=u[me];if(Pe.id===N.pointing.id)continue;let{y:ue}=Q[Pe.id];B===z?ue=me*l:B<z?B<=me&&me<z?ue=(me+1)*l:ue=me*l:B>z&&(B>=me&&me>z?ue=(me-1)*l:ue=me*l),ue!==Q[Pe.id].y&&(Q[Pe.id]={y:ue,offsetY:0,isSelected:!0})}}T(Q)}},[l,u,E]),D=P.useCallback(L=>{const N=_.current;if(N.status==="dragging"){const{id:U,index:Y}=N.pointing;gI(e,U,Y,N.dragIndex,t)}Wp(L.currentTarget,L),N.status="idle"},[e,t]),$=P.useCallback(L=>{const N=_.current;L.key==="Escape"&&(N.status==="dragging"&&T(Object.fromEntries(u.map((U,Y)=>[U.id,{y:Y*l,offsetY:0,isSelected:!1}]))),N.status="idle")},[l,u]),H=P.useCallback(()=>{m||(e.run(()=>{e.markHistoryStoppingPoint("creating page");const L=Wr.createId();e.createPage({name:r("page-menu.new-page-initial-name"),id:L}),e.setCurrentPage(L),w(!0)}),t("new-page",{source:"page-menu"}))},[e,r,m,t]),G=P.useCallback(L=>{e.setCurrentPage(L),t("change-page",{source:"page-menu"})},[e,t]),J=P.useCallback((L,N)=>{e.renamePage(L,N),t("rename-page",{source:"page-menu"})},[e,t]);return g.jsxs(du,{id:"pages",onOpenChange:a,open:o,children:[g.jsx(hu,{"data-testid":"main.page-menu",children:g.jsxs(He,{type:"menu",title:h.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[g.jsx("div",{className:"tlui-page-menu__name",children:h.name}),g.jsx(ct,{icon:"chevron-down",small:!0})]})}),g.jsx(fu,{side:"bottom",align:"start",sideOffset:6,disableEscapeKeyDown:v,children:g.jsxs("div",{className:"tlui-page-menu__wrapper",children:[g.jsxs("div",{className:"tlui-page-menu__header",children:[g.jsx("div",{className:"tlui-page-menu__header__title",children:r("page-menu.title")}),!m&&g.jsxs("div",{className:"tlui-buttons__horizontal",children:[g.jsx(He,{type:"icon","data-testid":"page-menu.edit",title:r(v?"page-menu.edit-done":"page-menu.edit-start"),onClick:C,children:g.jsx(ct,{icon:v?"check":"edit"})}),g.jsx(He,{type:"icon","data-testid":"page-menu.create",title:r(S?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:S,onClick:H,children:g.jsx(ct,{icon:"plus"})})]})]}),g.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((L,N)=>{const U=E[L.id]??{offsetY:0};return v?g.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:L.id===h.id?888:N,transform:`translate(0px, ${U.y+U.offsetY}px)`},children:[g.jsx(He,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:A,onPointerUp:D,onPointerMove:O,onKeyDown:$,"data-id":L.id,"data-index":N,children:g.jsx(ct,{icon:"drag-handle-dots"})}),s<dn.TABLET_SM&&x?g.jsxs(He,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const Y=window.prompt("Rename page",L.name);Y&&Y!==L.name&&J(L.id,Y)},onDoubleClick:C,children:[g.jsx(pI,{checked:L.id===h.id}),g.jsx(Cn,{children:L.name})]}):g.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:l},children:g.jsx(xxe,{id:L.id,name:L.name,isCurrentPage:L.id===h.id,onComplete:()=>{w(!1),e.menus.clearOpenMenus()},onCancel:()=>{w(!1),e.menus.clearOpenMenus()}})}),!m&&g.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":v,children:g.jsx(jN,{index:N,item:L,listSize:u.length})})]},L.id+"_editing"):g.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[g.jsxs(He,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>G(L.id),onDoubleClick:C,title:r("page-menu.go-to-page"),children:[g.jsx(pI,{checked:L.id===h.id}),g.jsx(Cn,{children:L.name})]}),!m&&g.jsx("div",{className:"tlui-page_menu__item__submenu",children:g.jsx(jN,{index:N,item:L,listSize:u.length,onRename:()=>{if(It.isIos){const Y=window.prompt("Rename page",L.name);Y&&Y!==L.name&&J(L.id,Y)}else w(!0),p!==L.id&&G(L.id)}})})]},L.id)})})]})})]})});function bxe(){const n=te(),e=ti(),t=ie("should display quick actions",()=>n.isInAny("select","hand","zoom"),[n]);if(!(e&&!t))return g.jsxs(g.Fragment,{children:[g.jsx(Pxe,{}),g.jsx(Cxe,{})]})}function Cxe(){const n=ns(1),e=Za(),t=n&&e;return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"delete",disabled:!t}),g.jsx(le,{actionId:"duplicate",disabled:!t})]})}function Pxe(){const n=MH(),e=TH();return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"undo",disabled:!n}),g.jsx(le,{actionId:"redo",disabled:!e})]})}const kxe=P.memo(function({children:e}){const t=e??g.jsx(bxe,{});return g.jsx(Zr,{type:"small-icons",sourceId:"quick-actions",children:t})});function Ixe({userId:n}){var t;const e=Z0(n);return e?g.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:e.color},children:((t=e.userName)==null?void 0:t[0])??""},n):null}const Exe=Yn(function({userId:e}){var c;const t=te(),r=it(),s=Ln(),i=Z0(e),o=P.useCallback(()=>{t.getInstanceState().followingUserId===e?(t.stopFollowingUser(),s("stop-following",{source:"people-menu"})):(t.startFollowingUser(e),s("start-following",{source:"people-menu"}))},[t,e,s]),a=(i==null?void 0:i.followingUserId)===t.user.getId(),l=t.getInstanceState().followingUserId===e;return i?g.jsxs("div",{className:"tlui-people-menu__item tlui-buttons__horizontal","data-follow":l||a,children:[g.jsxs(He,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>t.zoomToUser(e),onDoubleClick:o,children:[g.jsx(Wo,{icon:"color",color:i.color}),g.jsx("div",{className:"tlui-people-menu__name",children:((c=i.userName)==null?void 0:c.trim())||r("people-menu.anonymous-user")})]}),g.jsx(He,{type:"icon",className:"tlui-people-menu__item__follow",title:r(a?"people-menu.leading":l?"people-menu.following":"people-menu.follow"),onClick:o,disabled:a,children:g.jsx(ct,{icon:a?"leading":l?"following":"follow"})})]}):null});function _xe({count:n}){return g.jsx("div",{className:"tlui-people-menu__more",children:"+"+Math.abs(n)})}const Txe=Yn(function(){const e=te(),t=kn(),r=it(),s=Ln(),i=P.useRef(!1),[o,a]=P.useState(!1),l=P.useCallback(x=>{a(x)},[]),c=e.user.getColor(),u=P.useCallback(x=>{e.user.updateUserPreferences({color:x}),s("set-color",{source:"people-menu"})},[e,s]),{handleButtonClick:h,handleButtonPointerDown:p,handleButtonPointerEnter:m,handleButtonPointerUp:S}=at.useMemo(()=>{const x=()=>{i.current=!1,window.removeEventListener("pointerup",x)};return{handleButtonClick:E=>{const{id:T}=E.currentTarget.dataset;T&&c!==T&&u(T)},handleButtonPointerDown:E=>{const{id:T}=E.currentTarget.dataset;T&&(u(T),i.current=!0,window.addEventListener("pointerup",x))},handleButtonPointerEnter:E=>{if(!i.current)return;const{id:T}=E.currentTarget.dataset;T&&u(T)},handleButtonPointerUp:E=>{const{id:T}=E.currentTarget.dataset;T&&u(T)}}},[c,u]);return g.jsxs(AT,{onOpenChange:l,open:o,children:[g.jsx(OT,{dir:"ltr",asChild:!0,children:g.jsx(He,{type:"icon",className:"tlui-people-menu__user__color",style:{color:e.user.getColor()},title:r("people-menu.change-color"),children:g.jsx(ct,{icon:"color"})})}),g.jsx(RT,{container:t,children:g.jsx(DT,{dir:"ltr",className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:g.jsx("div",{className:"tlui-buttons__grid",children:yk.map(x=>g.jsx(He,{type:"icon","data-id":x,"data-testid":x,"aria-label":x,"data-state":c===x?"hinted":void 0,title:x,className:"tlui-button-grid__button",style:{color:x},onPointerEnter:m,onPointerDown:p,onPointerUp:S,onClick:h,children:g.jsx(ct,{icon:"color"})},x))})})})]})});function Mxe(){const n=te(),e=Ln(),t=ie("userName",()=>n.user.getName(),[]),r=it(),s=P.useRef(t),i=P.useRef(t),[o,a]=P.useState(!1),l=P.useCallback(()=>{a(p=>!p)},[]),c=P.useCallback(p=>{i.current=p,n.user.updateUserPreferences({name:p})},[n]),u=P.useCallback(()=>{s.current!==i.current&&(e("change-user-name",{source:"people-menu"}),s.current=i.current)},[e]),h=P.useCallback(()=>{a(!1),n.user.updateUserPreferences({name:s.current}),n.menus.clearOpenMenus()},[n]);return g.jsxs("div",{className:"tlui-people-menu__user",children:[g.jsx(Txe,{}),o?g.jsx(lg,{className:"tlui-people-menu__user__input",defaultValue:t,onValueChange:c,onComplete:l,onCancel:h,onBlur:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{o||a(!0)},children:t||r("people-menu.anonymous-user")}),t?null:g.jsx("div",{className:"tlui-people-menu__user__label",children:r("people-menu.user")})]}),g.jsx(He,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:r("people-menu.change-name"),onClick:l,children:g.jsx(ct,{icon:o?"check":"edit"})})]})}function Axe({children:n}){const e=it(),t=kn(),r=te(),s=cz(),i=ie("user",()=>r.user.getColor(),[r]),o=ie("user",()=>r.user.getName(),[r]),[a,l]=Xa("people menu");return s.length?g.jsxs(AT,{onOpenChange:l,open:a,children:[g.jsx(OT,{dir:"ltr",asChild:!0,children:g.jsxs("button",{className:"tlui-people-menu__avatars-button",title:e("people-menu.title"),children:[s.length>5&&g.jsx(_xe,{count:s.length-5}),g.jsxs("div",{className:"tlui-people-menu__avatars",children:[s.slice(-5).map(c=>g.jsx(Ixe,{userId:c},c)),s.length>0&&g.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:i},children:(o==null?void 0:o[0])??""})]})]})}),g.jsx(RT,{container:t,children:g.jsx(DT,{dir:"ltr",className:"tlui-menu",side:"bottom",sideOffset:2,collisionPadding:4,children:g.jsxs("div",{className:"tlui-people-menu__wrapper",children:[g.jsx("div",{className:"tlui-people-menu__section",children:g.jsx(Mxe,{})}),s.length>0&&g.jsx("div",{className:"tlui-people-menu__section",children:s.map(c=>g.jsx(Exe,{userId:c},c+"_presence"))}),n]})})})]}):null}function Oxe(){return g.jsx("div",{className:"tlui-share-zone",draggable:!1,children:g.jsx(Axe,{})})}const Rxe=Object.freeze([Yr,iu,ou,Uo]);function fK(n=Rxe){const e=te();return ie("getRelevantStyles",()=>{var i;const t=new wk(e.getSharedStyles()),r=!!((i=e.root.getCurrent())!=null&&i.shapeType),s=e.isIn("select")&&e.getSelectedShapeIds().length>0;if(t.size===0&&e.isIn("select")&&e.getSelectedShapeIds().length===0)for(const o of n)t.applyValue(o,e.getStyleForNextShape(o));return r||s||t.size>0?t:null},[e])}const wi={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"}]},Bc=P.memo(function(e){const{uiType:t,items:r,title:s,style:i,value:o,onValueChange:a,onHistoryMark:l,theme:c}=e,u=te(),h=it(),p=Rr(),m=P.useRef(!1),S=P.useRef(null),{handleButtonClick:x,handleButtonPointerDown:v,handleButtonPointerEnter:w,handleButtonPointerUp:C}=P.useMemo(()=>{const _=()=>{m.current=!1,window.removeEventListener("pointerup",_);const D=S.current;D&&(["TEXTAREA","INPUT"].includes(D.nodeName)||D.isContentEditable)?D.focus():p>=dn.TABLET_SM&&u.getContainer().focus(),S.current=null};return{handleButtonClick:D=>{const{id:$}=D.currentTarget.dataset;o.type==="shared"&&o.value===$||(l==null||l("point picker item"),a(i,$))},handleButtonPointerDown:D=>{const{id:$}=D.currentTarget.dataset;l==null||l("point picker item"),a(i,$),m.current=!0,S.current=document.activeElement,window.addEventListener("pointerup",_)},handleButtonPointerEnter:D=>{if(!m.current)return;const{id:$}=D.currentTarget.dataset;a(i,$)},handleButtonPointerUp:D=>{const{id:$}=D.currentTarget.dataset;o.type==="shared"&&o.value===$||a(i,$)}}},[u,p,o,l,a,i]);return g.jsx("div",{"data-testid":`style.${t}`,className:$e("tlui-buttons__grid"),children:r.map(_=>{const E=s+" — "+h(`${t}-style.${_.value}`);return g.jsx(He,{type:"icon","data-id":_.value,"data-testid":`style.${t}.${_.value}`,"aria-label":E,"data-state":o.type==="shared"&&o.value===_.value?"hinted":void 0,title:E,className:$e("tlui-button-grid__button"),style:i===Yr?{color:c[_.value].solid}:void 0,onPointerEnter:w,onPointerDown:v,onPointerUp:C,onClick:x,children:g.jsx(ct,{icon:_.icon})},_.value)})})});function pK(n,[e,t]){return Math.min(t,Math.max(e,n))}function Dxe(n){const e=P.useRef({value:n,previous:n});return P.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}var gK=["PageUp","PageDown"],mK=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],yK={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Sh="Slider",[mI,jxe,Lxe]=fv(Sh),[SK,I1e]=Xo(Sh,[Lxe]),[Nxe,Bv]=SK(Sh),vK=P.forwardRef((n,e)=>{const{name:t,min:r=0,max:s=100,step:i=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:u,onValueChange:h=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:S,...x}=n,v=P.useRef(new Set),w=P.useRef(0),_=o==="horizontal"?Fxe:zxe,[E=[],T]=sc({prop:u,defaultProp:c,onChange:G=>{var L;(L=[...v.current][w.current])==null||L.focus(),h(G)}}),A=P.useRef(E);function O(G){const J=Kxe(E,G);H(G,J)}function D(G){H(G,w.current)}function $(){const G=A.current[w.current];E[w.current]!==G&&p(E)}function H(G,J,{commit:L}={commit:!1}){const N=Gxe(i),U=Yxe(Math.round((G-r)/i)*i+r,N),Y=pK(U,[r,s]);T((W=[])=>{const z=Uxe(W,Y,J);if(qxe(z,l*i)){w.current=z.indexOf(Y);const V=String(z)!==String(W);return V&&L&&p(z),V?z:W}else return W})}return g.jsx(Nxe,{scope:n.__scopeSlider,name:t,disabled:a,min:r,max:s,valueIndexToChangeRef:w,thumbs:v.current,values:E,orientation:o,form:S,children:g.jsx(mI.Provider,{scope:n.__scopeSlider,children:g.jsx(mI.Slot,{scope:n.__scopeSlider,children:g.jsx(_,{"aria-disabled":a,"data-disabled":a?"":void 0,...x,ref:e,onPointerDown:je(x.onPointerDown,()=>{a||(A.current=E)}),min:r,max:s,inverted:m,onSlideStart:a?void 0:O,onSlideMove:a?void 0:D,onSlideEnd:a?void 0:$,onHomeKeyDown:()=>!a&&H(r,0,{commit:!0}),onEndKeyDown:()=>!a&&H(s,E.length-1,{commit:!0}),onStepKeyDown:({event:G,direction:J})=>{if(!a){const U=gK.includes(G.key)||G.shiftKey&&mK.includes(G.key)?10:1,Y=w.current,W=E[Y],z=i*U*J;H(W+z,Y,{commit:!0})}}})})})})});vK.displayName=Sh;var[xK,wK]=SK(Sh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Fxe=P.forwardRef((n,e)=>{const{min:t,max:r,dir:s,inverted:i,onSlideStart:o,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=n,[h,p]=P.useState(null),m=jt(e,_=>p(_)),S=P.useRef(void 0),x=h_(s),v=x==="ltr",w=v&&!i||!v&&i;function C(_){const E=S.current||h.getBoundingClientRect(),T=[0,E.width],O=LT(T,w?[t,r]:[r,t]);return S.current=E,O(_-E.left)}return g.jsx(xK,{scope:n.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:g.jsx(bK,{dir:x,"data-orientation":"horizontal",...u,ref:m,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const E=C(_.clientX);o==null||o(E)},onSlideMove:_=>{const E=C(_.clientX);a==null||a(E)},onSlideEnd:()=>{S.current=void 0,l==null||l()},onStepKeyDown:_=>{const T=yK[w?"from-left":"from-right"].includes(_.key);c==null||c({event:_,direction:T?-1:1})}})})}),zxe=P.forwardRef((n,e)=>{const{min:t,max:r,inverted:s,onSlideStart:i,onSlideMove:o,onSlideEnd:a,onStepKeyDown:l,...c}=n,u=P.useRef(null),h=jt(e,u),p=P.useRef(void 0),m=!s;function S(x){const v=p.current||u.current.getBoundingClientRect(),w=[0,v.height],_=LT(w,m?[r,t]:[t,r]);return p.current=v,_(x-v.top)}return g.jsx(xK,{scope:n.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:g.jsx(bK,{"data-orientation":"vertical",...c,ref:h,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const v=S(x.clientY);i==null||i(v)},onSlideMove:x=>{const v=S(x.clientY);o==null||o(v)},onSlideEnd:()=>{p.current=void 0,a==null||a()},onStepKeyDown:x=>{const w=yK[m?"from-bottom":"from-top"].includes(x.key);l==null||l({event:x,direction:w?-1:1})}})})}),bK=P.forwardRef((n,e)=>{const{__scopeSlider:t,onSlideStart:r,onSlideMove:s,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:l,...c}=n,u=Bv(Sh,t);return g.jsx(vt.span,{...c,ref:e,onKeyDown:je(n.onKeyDown,h=>{h.key==="Home"?(o(h),h.preventDefault()):h.key==="End"?(a(h),h.preventDefault()):gK.concat(mK).includes(h.key)&&(l(h),h.preventDefault())}),onPointerDown:je(n.onPointerDown,h=>{const p=h.target;p.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(p)?p.focus():r(h)}),onPointerMove:je(n.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&s(h)}),onPointerUp:je(n.onPointerUp,h=>{const p=h.target;p.hasPointerCapture(h.pointerId)&&(p.releasePointerCapture(h.pointerId),i(h))})})}),CK="SliderTrack",PK=P.forwardRef((n,e)=>{const{__scopeSlider:t,...r}=n,s=Bv(CK,t);return g.jsx(vt.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:e})});PK.displayName=CK;var yI="SliderRange",kK=P.forwardRef((n,e)=>{const{__scopeSlider:t,...r}=n,s=Bv(yI,t),i=wK(yI,t),o=P.useRef(null),a=jt(e,o),l=s.values.length,c=s.values.map(p=>_K(p,s.min,s.max)),u=l>1?Math.min(...c):0,h=100-Math.max(...c);return g.jsx(vt.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...n.style,[i.startEdge]:u+"%",[i.endEdge]:h+"%"}})});kK.displayName=yI;var SI="SliderThumb",IK=P.forwardRef((n,e)=>{const t=jxe(n.__scopeSlider),[r,s]=P.useState(null),i=jt(e,a=>s(a)),o=P.useMemo(()=>r?t().findIndex(a=>a.ref.current===r):-1,[t,r]);return g.jsx($xe,{...n,ref:i,index:o})}),$xe=P.forwardRef((n,e)=>{const{__scopeSlider:t,index:r,name:s,...i}=n,o=Bv(SI,t),a=wK(SI,t),[l,c]=P.useState(null),u=jt(e,C=>c(C)),h=l?o.form||!!l.closest("form"):!0,p=i8(l),m=o.values[r],S=m===void 0?0:_K(m,o.min,o.max),x=Hxe(r,o.values.length),v=p==null?void 0:p[a.size],w=v?Wxe(v,S,a.direction):0;return P.useEffect(()=>{if(l)return o.thumbs.add(l),()=>{o.thumbs.delete(l)}},[l,o.thumbs]),g.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${S}% + ${w}px)`},children:[g.jsx(mI.ItemSlot,{scope:n.__scopeSlider,children:g.jsx(vt.span,{role:"slider","aria-label":n["aria-label"]||x,"aria-valuemin":o.min,"aria-valuenow":m,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:u,style:m===void 0?{display:"none"}:n.style,onFocus:je(n.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),h&&g.jsx(EK,{name:s??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:m},r)]})});IK.displayName=SI;var Bxe="RadioBubbleInput",EK=P.forwardRef(({__scopeSlider:n,value:e,...t},r)=>{const s=P.useRef(null),i=jt(s,r),o=Dxe(e);return P.useEffect(()=>{const a=s.current;if(!a)return;const l=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==e&&u){const h=new Event("input",{bubbles:!0});u.call(a,e),a.dispatchEvent(h)}},[o,e]),g.jsx(vt.input,{style:{display:"none"},...t,ref:i,defaultValue:e})});EK.displayName=Bxe;function Uxe(n=[],e,t){const r=[...n];return r[t]=e,r.sort((s,i)=>s-i)}function _K(n,e,t){const i=100/(t-e)*(n-e);return pK(i,[0,100])}function Hxe(n,e){return e>2?`Value ${n+1} of ${e}`:e===2?["Minimum","Maximum"][n]:void 0}function Kxe(n,e){if(n.length===1)return 0;const t=n.map(s=>Math.abs(s-e)),r=Math.min(...t);return t.indexOf(r)}function Wxe(n,e,t){const r=n/2,i=LT([0,50],[0,r]);return(r-i(e)*t)*t}function Vxe(n){return n.slice(0,-1).map((e,t)=>n[t+1]-e)}function qxe(n,e){if(e>0){const t=Vxe(n);return Math.min(...t)>=e}return!0}function LT(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function Gxe(n){return(String(n).split(".")[1]||"").length}function Yxe(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}var Xxe=vK,Zxe=PK,Jxe=kK,Qxe=IK;const ewe=P.memo(function({onHistoryMark:e,title:t,steps:r,value:s,label:i,onValueChange:o,["data-testid"]:a}){const l=it(),c=P.useCallback(m=>{o(m[0])},[o]),u=P.useCallback(()=>{e("click slider")},[e]),h=P.useCallback(()=>{s&&o(s)},[s,o]),p=P.useCallback(m=>{m.key==="Tab"&&m.stopPropagation()},[]);return g.jsx("div",{className:"tlui-slider__container",children:g.jsxs(Xxe,{"data-testid":a,className:"tlui-slider",dir:"ltr",min:0,max:r,step:1,value:s?[s]:void 0,onPointerDown:u,onValueChange:c,onPointerUp:h,onKeyDownCapture:p,onKeyUpCapture:p,title:t+" — "+l(i),children:[g.jsx(Zxe,{className:"tlui-slider__track",dir:"ltr",children:s!==null&&g.jsx(Jxe,{className:"tlui-slider__range",dir:"ltr"})}),s!==null&&g.jsx(Qxe,{"aria-label":l("style-panel.opacity"),className:"tlui-slider__thumb",dir:"ltr"})]})})});function twe({label:n,uiTypeA:e,uiTypeB:t,labelA:r,labelB:s,itemsA:i,itemsB:o,styleA:a,styleB:l,valueA:c,valueB:u,onValueChange:h}){const p=te(),m=it(),[S,x]=P.useState(!1),[v,w]=P.useState(!1),C=P.useMemo(()=>{var A;return((A=i.find(O=>c.type==="shared"&&c.value===O.value))==null?void 0:A.icon)??"mixed"},[i,c]),_=P.useMemo(()=>{var A;return((A=o.find(O=>u.type==="shared"&&u.value===O.value))==null?void 0:A.icon)??"mixed"},[o,u]);if(c===void 0&&u===void 0)return null;const E=`style panel ${e} A`,T=`style panel ${t} B`;return g.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[g.jsx("div",{title:m(n),className:"tlui-style-panel__double-select-picker-label",children:m(n)}),g.jsxs("div",{className:"tlui-buttons__horizontal",children:[g.jsxs(du,{id:E,open:S,onOpenChange:x,children:[g.jsx(hu,{children:g.jsx(He,{type:"icon","data-testid":`style.${e}`,title:m(r)+" — "+(c===null||c.type==="mixed"?m("style-panel.mixed"):m(`${e}-style.${c.value}`)),children:g.jsx(ct,{icon:C,small:!0,invertIcon:!0})})}),g.jsx(fu,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:g.jsx("div",{className:"tlui-buttons__grid",children:i.map((A,O)=>g.jsx(Zr,{type:"icons",sourceId:"style-panel",children:g.jsx(He,{"data-testid":`style.${e}.${A.value}`,type:"icon",onClick:()=>{h(a,A.value),Br.deleteOpenMenu(E,p.contextId),x(!1)},title:`${m(r)} — ${m(`${e}-style.${A.value}`)}`,children:g.jsx(ct,{icon:A.icon,invertIcon:!0})},A.value)},O))})})]}),g.jsxs(du,{id:T,open:v,onOpenChange:w,children:[g.jsx(hu,{children:g.jsx(He,{type:"icon","data-testid":`style.${t}`,title:m(s)+" — "+(u===null||u.type==="mixed"?m("style-panel.mixed"):m(`${t}-style.${u.value}`)),children:g.jsx(ct,{icon:_,small:!0})})}),g.jsx(fu,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:g.jsx("div",{className:"tlui-buttons__grid",children:o.map(A=>g.jsx(Zr,{type:"icons",sourceId:"style-panel",children:g.jsx(He,{type:"icon",title:`${m(s)} — ${m(`${t}-style.${A.value}`)}`,"data-testid":`style.${t}.${A.value}`,onClick:()=>{h(l,A.value),Br.deleteOpenMenu(T,p.contextId),w(!1)},children:g.jsx(ct,{icon:A.icon})})},A.value))})})]})]})]})}const nwe=P.memo(twe);function rwe({id:n,label:e,uiType:t,stylePanelType:r,style:s,items:i,type:o,value:a,onValueChange:l}){const c=it(),u=te(),[h,p]=P.useState(!1),m=P.useMemo(()=>{var C;return(C=i.find(_=>a.type==="shared"&&_.value===a.value))==null?void 0:C.icon},[i,a]),S=c(`style-panel.${r}`),x=a.type==="mixed"?c("style-panel.mixed"):S+" — "+c(`${t}-style.${a.value}`),v=e?c(e):"",w=`style panel ${n}`;return g.jsxs(du,{id:w,open:h,onOpenChange:p,children:[g.jsx(hu,{children:g.jsxs(He,{type:o,"data-testid":`style.${t}`,title:x,children:[v&&g.jsx(Cn,{children:v}),g.jsx(ct,{icon:m??"mixed"})]})}),g.jsx(fu,{side:"left",align:"center",alignOffset:0,children:g.jsx("div",{className:$e("tlui-buttons__grid",`tlui-buttons__${r}`),children:g.jsx(Zr,{type:"icons",sourceId:"style-panel",children:i.map(C=>g.jsx(He,{type:"icon","data-testid":`style.${t}.${C.value}`,title:S+" — "+c(`${t}-style.${C.value}`),onClick:()=>{u.markHistoryStoppingPoint("select style dropdown item"),l(s,C.value),Br.deleteOpenMenu(w,u.contextId),p(!1)},children:g.jsx(ct,{icon:C.icon})},C.value))})})})]})}const NT=P.memo(rwe);function swe({styles:n}){const e=eg();if(!n)return null;const t=n.get(Xi),r=n.get(vS),s=n.get(SS),i=n.get(CS),o=n.get(Na),a=t===void 0,l=r===void 0&&s===void 0,c=i===void 0,u=o===void 0,h=Va({isDarkMode:e});return g.jsxs(g.Fragment,{children:[g.jsx(iwe,{theme:h,styles:n}),!u&&g.jsx(owe,{theme:h,styles:n}),!(a&&l&&c)&&g.jsxs("div",{className:"tlui-style-panel__section",children:[g.jsx(awe,{styles:n}),g.jsx(cwe,{styles:n}),g.jsx(lwe,{styles:n})]})]})}function fg(){const n=te(),e=Ln();return at.useMemo(()=>function(r,s){n.run(()=>{n.isIn("select")&&n.setStyleForSelectedShapes(r,s),n.setStyleForNextShapes(r,s),n.updateInstanceState({isChangingStyle:!0})}),e("set-style",{source:"style-panel",id:r.id,value:s})},[n,e])}function iwe({styles:n,theme:e}){const t=it(),r=te(),s=P.useCallback(h=>r.markHistoryStoppingPoint(h),[r]),i=fg(),o=n.get(Yr),a=n.get(ou),l=n.get(iu),c=n.get(Uo),u=a!==void 0||l!==void 0||c!==void 0;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","data-testid":"style.panel",children:[o===void 0?null:g.jsx(Bc,{title:t("style-panel.color"),uiType:"color",style:Yr,items:wi.color,value:o,onValueChange:i,theme:e,onHistoryMark:s}),g.jsx(uwe,{})]}),u&&g.jsxs("div",{className:"tlui-style-panel__section",children:[a===void 0?null:g.jsx(Bc,{title:t("style-panel.fill"),uiType:"fill",style:ou,items:wi.fill,value:a,onValueChange:i,theme:e,onHistoryMark:s}),l===void 0?null:g.jsx(Bc,{title:t("style-panel.dash"),uiType:"dash",style:iu,items:wi.dash,value:l,onValueChange:i,theme:e,onHistoryMark:s}),c===void 0?null:g.jsx(Bc,{title:t("style-panel.size"),uiType:"size",style:Uo,items:wi.size,value:c,onValueChange:(h,p)=>{i(h,p);const m=r.getSelectedShapeIds();m.length>0&&Ht(r,m)},theme:e,onHistoryMark:s})]})]})}function owe({theme:n,styles:e}){const t=it(),r=fg(),s=te(),i=P.useCallback(u=>s.markHistoryStoppingPoint(u),[s]),o=e.get(Na),a=e.get(fk),l=e.get(wS),c=e.get(bS);return o===void 0&&l===void 0?null:g.jsxs("div",{className:"tlui-style-panel__section",children:[o===void 0?null:g.jsx(Bc,{title:t("style-panel.font"),uiType:"font",style:Na,items:wi.font,value:o,onValueChange:r,theme:n,onHistoryMark:i}),a===void 0?null:g.jsxs("div",{className:"tlui-style-panel__row",children:[g.jsx(Bc,{title:t("style-panel.align"),uiType:"align",style:fk,items:wi.textAlign,value:a,onValueChange:r,theme:n,onHistoryMark:i}),g.jsx("div",{className:"tlui-style-panel__row__extra-button",children:g.jsx(He,{type:"icon",title:t("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:g.jsx(ct,{icon:"vertical-align-middle"})})})]}),l===void 0?null:g.jsxs("div",{className:"tlui-style-panel__row",children:[g.jsx(Bc,{title:t("style-panel.label-align"),uiType:"align",style:wS,items:wi.horizontalAlign,value:l,onValueChange:r,theme:n,onHistoryMark:i}),g.jsx("div",{className:"tlui-style-panel__row__extra-button",children:c===void 0?g.jsx(He,{type:"icon",title:t("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:g.jsx(ct,{icon:"vertical-align-middle"})}):g.jsx(NT,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",stylePanelType:"vertical-align",style:bS,items:wi.verticalAlign,value:c,onValueChange:r})})]})]})}function awe({styles:n}){const e=fg(),t=n.get(Xi);return t===void 0?null:g.jsx(NT,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",stylePanelType:"geo",style:Xi,items:wi.geo,value:t,onValueChange:e})}function lwe({styles:n}){const e=fg(),t=n.get(CS);return t===void 0?null:g.jsx(NT,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",stylePanelType:"spline",style:CS,items:wi.spline,value:t,onValueChange:e})}function cwe({styles:n}){const e=fg(),t=n.get(vS),r=n.get(SS);return!t||!r?null:g.jsx(nwe,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:SS,itemsA:wi.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:vS,itemsB:wi.arrowheadEnd,valueB:t,onValueChange:e,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const yf=[.1,.25,.5,.75,1];function uwe(){const n=te(),e=P.useCallback(a=>n.markHistoryStoppingPoint(a),[n]),t=ie("opacity",()=>n.getSharedOpacity(),[n]),r=Ln(),s=it(),i=at.useCallback(a=>{const l=yf[a];n.run(()=>{n.isIn("select")&&n.setOpacityForSelectedShapes(l),n.setOpacityForNextShapes(l),n.updateInstanceState({isChangingStyle:!0})}),r("set-style",{source:"style-panel",id:"opacity",value:a})},[n,r]);if(t===void 0)return null;const o=t.type==="mixed"?-1:yf.indexOf(YN(yf,a=>Math.abs(a-t.value)));return g.jsx(ewe,{"data-testid":"style.opacity",value:o>=0?o:yf.length-1,label:t.type==="mixed"?"style-panel.mixed":`opacity-style.${t.value}`,onValueChange:i,steps:yf.length-1,title:s("style-panel.opacity"),onHistoryMark:e})}const dwe=P.memo(function({isMobile:e,children:t}){const r=te(),s=P.useRef(null);Ga(s);const i=fK(),o=P.useCallback(()=>{e||r.updateInstanceState({isChangingStyle:!1})},[r,e]),a=t??g.jsx(swe,{styles:i});return g.jsx("div",{ref:s,className:$e("tlui-style-panel",{"tlui-style-panel__wrapper":!e}),"data-ismobile":e,onPointerLeave:o,role:"toolbar",children:a})}),hwe=at.forwardRef(function({children:e,className:t},r){return Ga(r),Zae(r),g.jsx("div",{ref:r,"data-testid":"contextual-toolbar",className:$e("tlui-contextual-toolbar",t),onPointerDown:Wt,children:g.jsx("div",{className:"tlui-menu tlui-buttons__horizontal",role:"toolbar",children:e})})});function fwe({textEditor:n,onEditLinkStart:e}){const t=Ln(),r=it(),s="rich-text-menu",[i,o]=P.useState(0);return P.useEffect(function(){function c(){o(u=>u+1)}n.on("update",c),n.on("selectionUpdate",c)},[n]),P.useMemo(()=>{function l(c,u){t("rich-text",{operation:c,source:s}),n.chain().focus()[u]().run()}return[{name:"bold",onSelect(){l("bold","toggleBold")}},{name:"italic",onSelect(){l("bold","toggleItalic")}},{name:"code",onSelect(){l("bold","toggleCode")}},e?{name:"link",onSelect(){e()}}:void 0,{name:"bulletList",onSelect(){l("bulletList","toggleBulletList")}},{name:"highlight",onSelect(){l("bulletList","toggleHighlight")}}].filter(Boolean)},[n,t,e]).map(({name:l,attrs:c,onSelect:u})=>g.jsx(He,{title:r(`tool.rich-text-${l}`),"data-testid":`rich-text.${l}`,type:"icon",isActive:n.isActive(l,c),onPointerDown:tt,onClick:u,children:g.jsx(ct,{small:!0,icon:l})},l))}function pwe({textEditor:n,value:e,onComplete:t}){const r=te(),[s,i]=P.useState(e),o=it(),a=P.useRef(null),l=Ln(),c="rich-text-menu",u=s.startsWith("http")?s:`https://${s}`,h=v=>i(v),p=v=>{l("rich-text",{operation:"link-edit",source:c}),!v.startsWith("http://")&&!v.startsWith("https://")&&(v=`https://${v}`),n.commands.setLink({href:v}),r.getInstanceState().isCoarsePointer?n.commands.blur():n.commands.focus(),t()},m=()=>{l("rich-text",{operation:"link-visit",source:c}),window.open(u,"_blank","noopener, noreferrer"),t()},S=()=>{l("rich-text",{operation:"link-remove",source:c}),n.chain().unsetLink().focus().run(),t()},x=()=>t();return P.useEffect(()=>{var v;s||(v=a.current)==null||v.focus()},[s]),P.useEffect(()=>{i(e)},[e]),g.jsxs(g.Fragment,{children:[g.jsx(lg,{ref:a,"data-testid":"rich-text.link-input",className:"tlui-rich-text__toolbar-link-input",value:s,onValueChange:h,onComplete:p,onCancel:x,placeholder:"example.com"}),g.jsx(He,{className:"tlui-rich-text__toolbar-link-visit",title:o("tool.rich-text-link-visit"),type:"icon",onPointerDown:tt,onClick:m,disabled:!s,children:g.jsx(ct,{small:!0,icon:"external-link"})}),g.jsx(He,{className:"tlui-rich-text__toolbar-link-remove",title:o("tool.rich-text-link-remove"),"data-testid":"rich-text.link-remove",type:"icon",onPointerDown:tt,onClick:S,children:g.jsx(ct,{small:!0,icon:"trash"})})]})}const gwe=150,mwe=16,ywe=16,Swe=8,bl=16,vwe=16**2,xwe=!0,wwe=Yn(function({children:e}){const t=te(),r=ie("textEditor",()=>t.getRichTextEditor(),[t]);return t.getInstanceState().isCoarsePointer||!r?null:g.jsx(bwe,{textEditor:r,children:e})});function bwe({textEditor:n,children:e}){const t=te(),r=P.useRef(null),{isVisible:s,isInteractive:i,hide:o,show:a,position:l,move:c}=Iwe(),{isEditingLink:u,onEditLinkStart:h,onEditLinkComplete:p}=Pwe(n),m=Np("force toolbar position update",0);P.useEffect(function(){function E(){m.update(T=>T+1)}return ES.requestAnimationFrame("first forced update",E),n.on("selectionUpdate",E),()=>{n.off("selectionUpdate",E)}},[n,m]),HI("shape change",function(){t.getEditingShape(),m.update(E=>E+1)},[t]);const S=P.useRef(!1),[x,v]=P.useState(!1);Hl("toolbar position",function(){const E=r.current;if(!E)return;t.getCamera(),m.get();const T=Cwe(t,E);if(!T){S.current&&(S.current=!1,v(!1));return}t.getCameraState()==="moving"?r.current.style.setProperty("transform",`translate(${T.x}px, ${T.y}px)`):c(T.x,T.y),S.current||(S.current=!0,v(!0))},[t,n,m]);const w=ie("camera state",()=>t.getCameraState(),[t]),C=Ewe(n);return P.useEffect(()=>{if(w==="moving"&&xwe){o(!0);return}if(C||!x){o();return}a()},[x,w,C,a,o]),P.useLayoutEffect(()=>{const _=r.current;_&&(_.dataset.visible=`${s}`)},[s,l]),P.useLayoutEffect(()=>{const _=r.current;_&&_.style.setProperty("transform",`translate(${l.x}px, ${l.y}px)`)},[l]),P.useLayoutEffect(()=>{const _=r.current;_&&(_.dataset.interactive=`${i}`)},[i]),g.jsx(hwe,{ref:r,className:"tlui-rich-text__toolbar","data-interactive":!1,"data-visible":!1,children:e||(u?g.jsx(pwe,{textEditor:n,value:n.isActive("link")?n.getAttributes("link").href:"",onComplete:p}):g.jsx(fwe,{textEditor:n,onEditLinkStart:h}))})}function LN(n){return new Se(n.x,n.y,n.width,n.height)}function Cwe(n,e){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;const r=[];for(let h=0;h<t.rangeCount;h++){const p=t.getRangeAt(h);r.push(LN(p.getBoundingClientRect()))}const s=Se.Common(r),i=n.getViewportScreenBounds();if(s.x-=i.x,s.y-=i.y,s.midY<bl||s.midY>i.h-bl||s.midX<bl||s.midX>i.w-bl)return;const o=LN(e.getBoundingClientRect());if(!o.width||!o.height)return;const{scrollLeft:a,scrollTop:l}=n.getContainer();let c=s.midX-o.w/2,u=s.y-o.h-Swe;return c=Mn(c,bl,i.w-o.w-bl),u=Mn(u,bl,i.h-o.h-bl),c+=a,u+=l,c=Math.round(c),u=Math.round(u),{x:c,y:u}}function Pwe(n){const[e,t]=P.useState(!1);P.useEffect(()=>{if(!n){t(!1);return}const o=()=>{const a=n.isActive("link");t(a)};return n.view.dom.addEventListener("click",o),()=>{n.view.dom.removeEventListener("click",o)}},[n,e]),P.useEffect(()=>{if(n&&n.isActive("link"))try{const{from:o,to:a}=$0(n.state.doc.resolve(n.state.selection.from),n.schema.marks.link);n.state.selection.empty&&n.commands.setTextSelection({from:o,to:a})}catch{}},[n,e]);const r=P.useCallback(()=>{t(!0)},[]),s=P.useCallback(()=>{t(!1)},[]),i=P.useCallback(()=>{if(t(!1),!n)return;const o=n.state.selection.from;n.commands.setTextSelection({from:o,to:o})},[n]);return{isEditingLink:e,onEditLinkStart:r,onEditLinkComplete:i,onEditLinkCancel:s}}function kwe(n,e){return k.Sub(e,n).y**2>=vwe}function Iwe(){const n=te(),e=P.useRef({name:"hidden"}),[t,r]=P.useState(!1),[s,i]=P.useState(!1),[o,a]=P.useState({x:-1e3,y:-1e3}),l=P.useRef(new k(-1e3,-1e3)),c=P.useRef(new k(-1e3,-1e3)),u=P.useRef(-1),h=P.useRef(-1),p=P.useCallback((x,v)=>{c.current.x=x,c.current.y=v,!(e.current.name==="hidden"||e.current.name==="showing")&&(clearTimeout(h.current),h.current=n.timers.setTimeout(()=>{if(e.current.name==="shown"&&kwe(c.current,l.current)){const{x:w,y:C}=c.current;l.current=new k(w,C),a({x:w,y:C})}},gwe))},[n]),m=P.useCallback((x=!1)=>{switch(e.current.name){case"showing":{clearTimeout(u.current),e.current={name:"hidden"};break}case"shown":{e.current={name:"hiding"},r(!1),x?(e.current={name:"hidden"},i(!1)):u.current=n.timers.setTimeout(()=>{e.current={name:"hidden"},i(!1)},mwe);break}}},[n]),S=P.useCallback(()=>{switch(e.current.name){case"hidden":{e.current={name:"showing"},u.current=n.timers.setTimeout(()=>{const{x,y:v}=c.current;l.current=new k(x,v),a({x,y:v}),e.current={name:"shown"},i(!0),r(!0)},ywe);break}case"hiding":{clearTimeout(u.current),e.current={name:"shown"},r(!0),p(c.current.x,c.current.y);break}}},[n,p]);return{isVisible:s,isInteractive:t,show:S,hide:m,move:p,position:o}}function Ewe(n){const[e,t]=P.useState(!1);return P.useEffect(()=>{if(!n)return;const r=x0(({isPointing:l})=>{t(l)},16),s=()=>r({isPointing:!0}),i=()=>r({isPointing:!1}),o=["touchstart","pointerdown","mousedown"],a=["touchend","pointerup","mouseup"];return o.forEach(l=>{n.view.dom.addEventListener(l,s)}),a.forEach(l=>{document.body.addEventListener(l,i)}),()=>{o.forEach(l=>{n.view.dom.removeEventListener(l,s)}),a.forEach(l=>{document.body.removeEventListener(l,i)})}},[n]),e}function _we(){const n=te(),e=it(),t=fK(),r=t==null?void 0:t.get(Yr),s=Va({isDarkMode:n.user.getIsDarkMode()}),i=((r==null?void 0:r.type)==="shared"?s[r.value]:s.black).solid,o=ie("disable style panel",()=>n.isInAny("hand","zoom","eraser","laser"),[n]),a=P.useCallback(c=>{c||n.updateInstanceState({isChangingStyle:!1})},[n]),{StylePanel:l}=ac();return l?g.jsxs(du,{id:"mobile style menu",onOpenChange:a,children:[g.jsx(hu,{children:g.jsx(He,{type:"tool","data-testid":"mobile-styles.button",style:{color:o?"var(--color-muted-1)":i},title:e("style-panel.title"),disabled:o,children:g.jsx(ct,{icon:o?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),g.jsx(fu,{side:"top",align:"end",children:l&&g.jsx(l,{isMobile:!0})})]}):null}function Twe(){return g.jsxs(g.Fragment,{children:[g.jsx(Awe,{}),g.jsx(Owe,{}),g.jsx(Rwe,{}),g.jsx(Dwe,{}),g.jsx(jwe,{}),g.jsx(Lwe,{}),g.jsx(Nwe,{}),g.jsx(Fwe,{}),g.jsx(zwe,{}),g.jsx($we,{}),g.jsx(Uwe,{}),g.jsx(Bwe,{}),g.jsx(Wwe,{}),g.jsx(Gwe,{}),g.jsx(Hwe,{}),g.jsx(qwe,{}),g.jsx(Vwe,{}),g.jsx(Kwe,{}),g.jsx(Ywe,{}),g.jsx(Xwe,{}),g.jsx(Zwe,{}),g.jsx(Jwe,{}),g.jsx(Qwe,{}),g.jsx(ebe,{}),g.jsx(tbe,{}),g.jsx(nbe,{}),g.jsx(sbe,{}),g.jsx(rbe,{})]})}function Mwe(n){var r;const e=te(),t=(r=n==null?void 0:n.meta)==null?void 0:r.geo;return ie("is tool selected",()=>{if(!n)return!1;const s=e.getCurrentToolId(),i=e.getSharedStyles().getAsKnownValue(Xi);return t?s==="geo"&&i===t:s===n.id},[e,n==null?void 0:n.id,t])}function zt({tool:n}){const e=eT(),t=Mwe(e[n]);return g.jsx(vs,{toolId:n,isSelected:t})}function Awe(){return g.jsx(zt,{tool:"select"})}function Owe(){return g.jsx(zt,{tool:"hand"})}function Rwe(){return g.jsx(zt,{tool:"draw"})}function Dwe(){return g.jsx(zt,{tool:"eraser"})}function jwe(){return g.jsx(zt,{tool:"arrow"})}function Lwe(){return g.jsx(zt,{tool:"text"})}function Nwe(){return g.jsx(zt,{tool:"note"})}function Fwe(){return g.jsx(vs,{toolId:"asset"})}function zwe(){return g.jsx(zt,{tool:"rectangle"})}function $we(){return g.jsx(zt,{tool:"ellipse"})}function Bwe(){return g.jsx(zt,{tool:"diamond"})}function Uwe(){return g.jsx(zt,{tool:"triangle"})}function Hwe(){return g.jsx(zt,{tool:"rhombus"})}function Kwe(){return g.jsx(zt,{tool:"heart"})}function Wwe(){return g.jsx(zt,{tool:"hexagon"})}function Vwe(){return g.jsx(zt,{tool:"cloud"})}function qwe(){return g.jsx(zt,{tool:"star"})}function Gwe(){return g.jsx(zt,{tool:"oval"})}function Ywe(){return g.jsx(zt,{tool:"x-box"})}function Xwe(){return g.jsx(zt,{tool:"check-box"})}function Zwe(){return g.jsx(zt,{tool:"arrow-left"})}function Jwe(){return g.jsx(zt,{tool:"arrow-up"})}function Qwe(){return g.jsx(zt,{tool:"arrow-down"})}function ebe(){return g.jsx(zt,{tool:"arrow-right"})}function tbe(){return g.jsx(zt,{tool:"line"})}function nbe(){return g.jsx(zt,{tool:"highlight"})}function rbe(){return g.jsx(zt,{tool:"frame"})}function sbe(){return g.jsx(zt,{tool:"laser"})}const oP=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function aP(n,e,t,r){n.addEventListener?n.addEventListener(e,t,r):n.attachEvent&&n.attachEvent("on".concat(e),t)}function Sf(n,e,t,r){n.removeEventListener?n.removeEventListener(e,t,r):n.detachEvent&&n.detachEvent("on".concat(e),t)}function TK(n,e){const t=e.slice(0,e.length-1);for(let r=0;r<t.length;r++)t[r]=n[t[r].toLowerCase()];return t}function MK(n){typeof n!="string"&&(n=""),n=n.replace(/\s/g,"");const e=n.split(",");let t=e.lastIndexOf("");for(;t>=0;)e[t-1]+=",",e.splice(t,1),t=e.lastIndexOf("");return e}function ibe(n,e){const t=n.length>=e.length?n:e,r=n.length>=e.length?e:n;let s=!0;for(let i=0;i<t.length;i++)r.indexOf(t[i])===-1&&(s=!1);return s}const _p={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,"-":oP?173:189,"=":oP?61:187,";":oP?59:186,"'":222,"[":219,"]":221,"\\":220},to={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},jf={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},er={16:!1,18:!1,17:!1,91:!1},un={};for(let n=1;n<20;n++)_p["f".concat(n)]=111+n;let tn=[],Qf=null,AK="all";const wa=new Map,pg=n=>_p[n.toLowerCase()]||to[n.toLowerCase()]||n.toUpperCase().charCodeAt(0),obe=n=>Object.keys(_p).find(e=>_p[e]===n),abe=n=>Object.keys(to).find(e=>to[e]===n);function OK(n){AK=n||"all"}function Tp(){return AK||"all"}function lbe(){return tn.slice(0)}function cbe(){return tn.map(n=>obe(n)||abe(n)||String.fromCharCode(n))}function ube(){const n=[];return Object.keys(un).forEach(e=>{un[e].forEach(t=>{let{key:r,scope:s,mods:i,shortcut:o}=t;n.push({scope:s,shortcut:o,mods:i,keys:r.split("+").map(a=>pg(a))})})}),n}function dbe(n){const e=n.target||n.srcElement,{tagName:t}=e;let r=!0;const s=t==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return(e.isContentEditable||(s||t==="TEXTAREA"||t==="SELECT")&&!e.readOnly)&&(r=!1),r}function hbe(n){return typeof n=="string"&&(n=pg(n)),tn.indexOf(n)!==-1}function fbe(n,e){let t,r;n||(n=Tp());for(const s in un)if(Object.prototype.hasOwnProperty.call(un,s))for(t=un[s],r=0;r<t.length;)t[r].scope===n?t.splice(r,1).forEach(o=>{let{element:a}=o;return FT(a)}):r++;Tp()===n&&OK(e||"all")}function pbe(n){let e=n.keyCode||n.which||n.charCode;const t=tn.indexOf(e);if(t>=0&&tn.splice(t,1),n.key&&n.key.toLowerCase()==="meta"&&tn.splice(0,tn.length),(e===93||e===224)&&(e=91),e in er){er[e]=!1;for(const r in to)to[r]===e&&(bi[r]=!1)}}function RK(n){if(typeof n>"u")Object.keys(un).forEach(s=>{Array.isArray(un[s])&&un[s].forEach(i=>oy(i)),delete un[s]}),FT(null);else if(Array.isArray(n))n.forEach(s=>{s.key&&oy(s)});else if(typeof n=="object")n.key&&oy(n);else if(typeof n=="string"){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];let[s,i]=t;typeof s=="function"&&(i=s,s=""),oy({key:n,scope:s,method:i,splitKey:"+"})}}const oy=n=>{let{key:e,scope:t,method:r,splitKey:s="+"}=n;MK(e).forEach(o=>{const a=o.split(s),l=a.length,c=a[l-1],u=c==="*"?"*":pg(c);if(!un[u])return;t||(t=Tp());const h=l>1?TK(to,a):[],p=[];un[u]=un[u].filter(m=>{const x=(r?m.method===r:!0)&&m.scope===t&&ibe(m.mods,h);return x&&p.push(m.element),!x}),p.forEach(m=>FT(m))})};function NN(n,e,t,r){if(e.element!==r)return;let s;if(e.scope===t||e.scope==="all"){s=e.mods.length>0;for(const i in er)Object.prototype.hasOwnProperty.call(er,i)&&(!er[i]&&e.mods.indexOf(+i)>-1||er[i]&&e.mods.indexOf(+i)===-1)&&(s=!1);(e.mods.length===0&&!er[16]&&!er[18]&&!er[17]&&!er[91]||s||e.shortcut==="*")&&(e.keys=[],e.keys=e.keys.concat(tn),e.method(n,e)===!1&&(n.preventDefault?n.preventDefault():n.returnValue=!1,n.stopPropagation&&n.stopPropagation(),n.cancelBubble&&(n.cancelBubble=!0)))}}function FN(n,e){const t=un["*"];let r=n.keyCode||n.which||n.charCode;if(!bi.filter.call(this,n))return;if((r===93||r===224)&&(r=91),tn.indexOf(r)===-1&&r!==229&&tn.push(r),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=jf[a];n[a]&&tn.indexOf(l)===-1?tn.push(l):!n[a]&&tn.indexOf(l)>-1?tn.splice(tn.indexOf(l),1):a==="metaKey"&&n[a]&&(tn=tn.filter(c=>c in jf||c===r))}),r in er){er[r]=!0;for(const a in to)if(Object.prototype.hasOwnProperty.call(to,a)){const l=jf[to[a]];bi[a]=n[l]}if(!t)return}for(const a in er)Object.prototype.hasOwnProperty.call(er,a)&&(er[a]=n[jf[a]]);n.getModifierState&&!(n.altKey&&!n.ctrlKey)&&n.getModifierState("AltGraph")&&(tn.indexOf(17)===-1&&tn.push(17),tn.indexOf(18)===-1&&tn.push(18),er[17]=!0,er[18]=!0);const s=Tp();if(t)for(let a=0;a<t.length;a++)t[a].scope===s&&(n.type==="keydown"&&t[a].keydown||n.type==="keyup"&&t[a].keyup)&&NN(n,t[a],s,e);if(!(r in un))return;const i=un[r],o=i.length;for(let a=0;a<o;a++)if((n.type==="keydown"&&i[a].keydown||n.type==="keyup"&&i[a].keyup)&&i[a].key){const l=i[a],{splitKey:c}=l,u=l.key.split(c),h=[];for(let p=0;p<u.length;p++)h.push(pg(u[p]));h.sort().join("")===tn.sort().join("")&&NN(n,l,s,e)}}function bi(n,e,t){tn=[];const r=MK(n);let s=[],i="all",o=document,a=0,l=!1,c=!0,u="+",h=!1,p=!1;for(t===void 0&&typeof e=="function"&&(t=e),Object.prototype.toString.call(e)==="[object Object]"&&(e.scope&&(i=e.scope),e.element&&(o=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&&(p=!0)),typeof e=="string"&&(i=e),p&&RK(n,i);a<r.length;a++)n=r[a].split(u),s=[],n.length>1&&(s=TK(to,n)),n=n[n.length-1],n=n==="*"?"*":pg(n),n in un||(un[n]=[]),un[n].push({keyup:l,keydown:c,scope:i,mods:s,shortcut:r[a],method:t,key:r[a],splitKey:u,element:o});if(typeof o<"u"&&window){if(!wa.has(o)){const m=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return FN(x,o)},S=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;FN(x,o),pbe(x)};wa.set(o,{keydownListener:m,keyupListenr:S,capture:h}),aP(o,"keydown",m,h),aP(o,"keyup",S,h)}if(!Qf){const m=()=>{tn=[]};Qf={listener:m,capture:h},aP(window,"focus",m,h)}}}function gbe(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(un).forEach(t=>{un[t].filter(s=>s.scope===e&&s.shortcut===n).forEach(s=>{s&&s.method&&s.method()})})}function FT(n){const e=Object.values(un).flat();if(e.findIndex(r=>{let{element:s}=r;return s===n})<0){const{keydownListener:r,keyupListenr:s,capture:i}=wa.get(n)||{};r&&s&&(Sf(n,"keyup",s,i),Sf(n,"keydown",r,i),wa.delete(n))}if((e.length<=0||wa.size<=0)&&(Object.keys(wa).forEach(s=>{const{keydownListener:i,keyupListenr:o,capture:a}=wa.get(s)||{};i&&o&&(Sf(s,"keyup",o,a),Sf(s,"keydown",i,a),wa.delete(s))}),wa.clear(),Object.keys(un).forEach(s=>delete un[s]),Qf)){const{listener:s,capture:i}=Qf;Sf(window,"focus",s,i),Qf=null}}const lP={getPressedKeyString:cbe,setScope:OK,getScope:Tp,deleteScope:fbe,getPressedKeyCodes:lbe,getAllKeyCodes:ube,isPressed:hbe,filter:dbe,trigger:gbe,unbind:RK,keyMap:_p,modifier:to,modifierMap:jf};for(const n in lP)Object.prototype.hasOwnProperty.call(lP,n)&&(bi[n]=lP[n]);if(typeof window<"u"){const n=window.hotkeys;bi.noConflict=e=>(e&&window.hotkeys===bi&&(window.hotkeys=n),bi),window.hotkeys=bi}const zN=["copy","cut","paste","asset"];function mbe(){const n=te(),e=ti(),t=bu(),r=eT(),s=ie("is focused",()=>n.getInstanceState().isFocused,[n]);P.useEffect(()=>{if(!s)return;const i=new Array,o=(l,c)=>{bi(l,{element:document.body},c),i.push(()=>{bi.unbind(l,c)})},a=(l,c)=>{bi(l,{element:document.body,keyup:!0,keydown:!1},c),i.push(()=>{bi.unbind(l,c)})};for(const l of Object.values(t))l.kbd&&(e&&!l.readonlyOk||zN.includes(l.id)||o($N(l.kbd),c=>{Lf(n)||(tt(c),l.onSelect("kbd"))}));for(const l of Object.values(r))!l.kbd||!l.readonlyOk&&n.getIsReadonly()||zN.includes(l.id)||o($N(l.kbd),c=>{Lf(n)||(tt(c),l.onSelect("kbd"))});return o(",",l=>{if(Lf(n)||n.inputs.keys.has("Comma"))return;tt(l),n.focus(),n.inputs.keys.add("Comma");const{x:c,y:u,z:h}=n.inputs.currentPagePoint,p=n.pageToScreen({x:c,y:u}),m={type:"pointer",name:"pointer_down",point:{x:p.x,y:p.y,z:h},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,metaKey:l.metaKey,accelKey:Pr(l),pointerId:0,button:0,isPen:n.getInstanceState().isPenMode,target:"canvas"};n.dispatch(m)}),a(",",l=>{if(Lf(n)||!n.inputs.keys.has("Comma"))return;n.inputs.keys.delete("Comma");const{x:c,y:u,z:h}=n.inputs.currentScreenPoint,p={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:Pr(l),pointerId:0,button:0,isPen:n.getInstanceState().isPenMode,target:"canvas"};n.dispatch(p)}),()=>{i.forEach(l=>l())}},[t,r,e,n,s])}function Lf(n){return n.menus.hasAnyOpenMenus()||n.getEditingShapeId()!==null||n.getCrashingError()}function $N(n){return ybe(n).map(e=>{let t="";const r=e.includes("!"),s=e.includes("?"),i=e.includes("$"),o=e.replace(/[!?$]/g,"");return r&&s&&i?t=`cmd+shift+alt+${o},ctrl+shift+alt+${o}`:r&&i?t=`cmd+shift+${o},ctrl+shift+${o}`:s&&i?t=`cmd+alt+${o},ctrl+alt+${o}`:s&&r?t=`shift+alt+${o}`:r?t=`shift+${o}`:s?t=`alt+${o}`:i?t=`cmd+${o},ctrl+${o}`:t=o,t}).join(",")}function ybe(n){typeof n!="string"&&(n=""),n=n.replace(/\s/g,"");const e=n.split(",");let t=e.lastIndexOf("");for(;t>=0;)e[t-1]+=",",e.splice(t,1),t=e.lastIndexOf("");return e}const Sbe=P.createContext(!1),vbe={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,0:9};function xbe({children:n}){const e=te(),t=vu(),r=Rr(),s=it(),i=P.useRef([]),[o,a]=P.useState(!1),l=Math.min(8,5+r),[c,u]=P.useState(0),h=P.useRef(null),[p,m]=P.useState(null),S=P.useMemo(()=>{const w=p?`:not([data-value="${p}"])`:"";return`
|
|
512
|
-
#${t}_main > *:nth-child(n + ${l+(p?1:2)})${w} {
|
|
513
|
-
display: none;
|
|
514
|
-
}
|
|
515
|
-
#${t}_more > *:nth-child(-n + ${l}) {
|
|
516
|
-
display: none;
|
|
517
|
-
}
|
|
518
|
-
#${t}_more > *:nth-child(-n + ${l+4}) {
|
|
519
|
-
margin-top: 0;
|
|
520
|
-
}
|
|
521
|
-
`},[p,t,l]),x=Pa(()=>{var E;if(!h.current)return;const w=Array.from(h.current.children);u(w.length),w.findIndex(T=>T.getAttribute("data-value")===p)<=l&&m(null);const _=Array.from(h.current.children).findIndex(T=>T.getAttribute("aria-checked")==="true");_!==-1&&(_>=l&&m(w[_].getAttribute("data-value")),i.current=Array.from(((E=h.current)==null?void 0:E.children)??[]).filter(T=>!(T instanceof HTMLElement)||T.tagName.toLowerCase()!=="button"?!1:!!(T.offsetWidth||T.offsetHeight)))});P.useLayoutEffect(()=>{x()}),P.useLayoutEffect(()=>{if(!h.current)return;const w=new MutationObserver(x);return w.observe(h.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{w.disconnect()}},[x]),P.useEffect(()=>{if(!e.options.enableToolbarKeyboardShortcuts)return;function w(C){var E;if(Lf(e)||G4()||C.ctrlKey||C.metaKey||C.altKey||C.shiftKey)return;const _=vbe[C.key];typeof _=="number"&&(tt(C),(E=i.current[_])==null||E.click())}return document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",w)}},[e]);const v="toolbar overflow";return g.jsxs(g.Fragment,{children:[g.jsx("style",{nonce:e.options.nonce,children:S}),g.jsxs("div",{className:$e("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<dn.TABLET_SM}),role:"toolbar",children:[g.jsx("div",{id:`${t}_main`,ref:h,className:"tlui-toolbar__tools__list",children:g.jsx(Zr,{type:"toolbar",sourceId:"toolbar",children:n})}),c>l+1&&g.jsx(Sbe.Provider,{value:!0,children:g.jsxs(du,{id:v,open:o,onOpenChange:a,children:[g.jsx(hu,{children:g.jsx(He,{title:s("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:g.jsx(ct,{icon:"chevron-up"})})}),g.jsx(fu,{side:"top",align:"center",children:g.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${t}_more`,onClick:()=>{Br.deleteOpenMenu(v,e.contextId),a(!1)},children:g.jsx(Zr,{type:"toolbar-overflow",sourceId:"toolbar",children:n})})})]})})]})]})}function wbe({activeToolId:n}){const e=te(),t=Rr(),r=it(),s=ie("is tool locked",()=>e.getInstanceState().isToolLocked,[e]),i=ie("current tool",()=>e.getCurrentTool(),[e]);return!n||!i.isLockable?null:g.jsx(He,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:$e("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":t<dn.TABLET_SM}),onClick:()=>e.updateInstanceState({isToolLocked:!s}),children:g.jsx(ct,{icon:s?"lock":"unlock",small:!0})})}const bbe=P.memo(function({children:e}){const t=te(),r=Rr(),s=ti(),i=ie("current tool id",()=>t.getCurrentToolId(),[t]),o=P.useRef(null);Ga(o);const{ActionsMenu:a,QuickActions:l}=ac(),c=t.options.actionShortcutsLocation==="menu"?!1:t.options.actionShortcutsLocation==="toolbar"?!0:r<dn.TABLET;return g.jsx("div",{ref:o,className:"tlui-toolbar",children:g.jsxs("div",{className:"tlui-toolbar__inner",children:[g.jsxs("div",{className:"tlui-toolbar__left",children:[!s&&g.jsxs("div",{className:"tlui-toolbar__extras",children:[c&&g.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",role:"toolbar",children:[l&&g.jsx(l,{}),a&&g.jsx(a,{})]}),g.jsx(wbe,{activeToolId:i})]}),g.jsx(xbe,{children:e??g.jsx(Twe,{})})]}),r<dn.TABLET_SM&&!s&&g.jsx("div",{className:"tlui-toolbar__tools",children:g.jsx(_we,{})})]})})});function Cbe(){const n=it();return g.jsxs("div",{className:$e("tlui-offline-indicator"),children:[n("status.offline"),g.jsx(Wo,{"aria-label":"offline",icon:"status-offline",small:!0})]})}function Pbe({maxWidth:n=420,ignoreRightWidth:e=0,stylePanelWidth:t=148,marginBetweenZones:r=12,squeezeAmount:s=52,children:i}){const o=P.useRef(null),a=Rr(),l=P.useCallback(()=>{const c=o.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),p=u.querySelector(".tlui-layout__top__right"),m=u.offsetWidth,S=h.offsetWidth,x=p.offsetWidth,v=c.offsetWidth-e;let w=(m-v)/2;m%2!==0&&(w-=.5);const C=S+r,_=c.offsetLeft,E=Math.min(m-x-S-2*r,n),T=Math.max(w,C)-_;p.offsetWidth>t&&a<=6?c.style.setProperty("max-width",E-s+"px"):c.style.setProperty("max-width",E+"px"),c.style.setProperty("transform",`translate(${T}px, 0px)`)},[a,e,r,n,s,t]);return P.useLayoutEffect(()=>{const c=o.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),p=u.querySelector(".tlui-layout__top__right"),m=new ResizeObserver(l);return m.observe(h),m.observe(p),m.observe(u),m.observe(c),l(),()=>{m.disconnect()}},[l]),P.useLayoutEffect(()=>{l()}),g.jsx("div",{ref:o,className:"tlui-top-panel__container",children:i})}function kbe(){const n=Zhe()==="offline";return g.jsx(Pbe,{children:n&&g.jsx(Cbe,{})})}function Ibe(){return g.jsxs(g.Fragment,{children:[g.jsx(le,{actionId:"zoom-in",noClose:!0}),g.jsx(le,{actionId:"zoom-out",noClose:!0}),g.jsx(zH,{}),g.jsx($H,{}),g.jsx(BH,{})]})}const Ebe=P.memo(function({children:e}){const t=kn(),[r,s]=Xa("zoom menu"),i=e??g.jsx(Ibe,{});return g.jsxs(L_,{dir:"ltr",open:r,onOpenChange:s,modal:!1,children:[g.jsx(N_,{asChild:!0,dir:"ltr",children:g.jsx(_be,{})}),g.jsx(Pv,{container:t,children:g.jsx(F_,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:g.jsx(Zr,{type:"menu",sourceId:"zoom-menu",children:i})})})]})}),_be=P.forwardRef(function(e,t){const r=te(),s=Rr(),i=ie("zoom",()=>r.getZoomLevel(),[r]),o=it(),a=P.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{animation:{duration:r.options.animationMediumMs}})},[r]);return g.jsx(He,{ref:t,...e,type:"icon",title:`${o("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:s<dn.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,children:s<dn.MOBILE?null:g.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(i*100),"%"]})})}),DK=P.createContext(null);function Tbe({overrides:n={},children:e}){const t=dh(n),r=Tv();return g.jsx(DK.Provider,{value:P.useMemo(()=>({ContextMenu:Eve,ActionsMenu:tve,HelpMenu:null,ZoomMenu:Ebe,MainMenu:axe,Minimap:yxe,StylePanel:dwe,PageMenu:wxe,NavigationPanel:vxe,Toolbar:bbe,RichTextToolbar:wwe,KeyboardShortcutsDialog:Xve,QuickActions:kxe,HelperButtons:Gve,DebugPanel:zve,DebugMenu:Fve,MenuPanel:Hve,SharePanel:r?Oxe:null,CursorChatBubble:r?Mve:null,TopPanel:r?kbe:null,Dialogs:dpe,Toasts:gpe,A11y:hle,...t}),[t,r]),children:e})}function ac(){const n=P.useContext(DK);if(!n)throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return n}const Mbe=Yn(function({overrides:e,components:t,assetUrls:r,onUiEvent:s,forceMobile:i,mediaMimeTypes:o,children:a}){const l=dr();return g.jsx(xU.Provider,{value:o,children:g.jsx(ale,{assetUrls:_0e(r),children:g.jsx(ule,{overrides:Jfe(e),locale:(l==null?void 0:l.user.getLocale())??Io.locale,children:g.jsx(gle,{onEvent:s,children:g.jsx(Pfe,{children:g.jsx(efe,{context:"tla",children:g.jsx(ole,{children:g.jsx(Qhe,{forceMobile:i,children:g.jsx(Tbe,{overrides:t,children:g.jsx(Abe,{overrides:e,children:a})})})})})})})})})})});function Abe({overrides:n,children:e}){const t=Qfe(n);return g.jsx(tpe,{overrides:t.actions,children:g.jsx(mpe,{overrides:t.tools,children:e})})}function Obe(){const n=te(),{addToast:e}=Ya();P.useEffect(()=>{function t({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 n.addListener("max-shapes",t),()=>{n.removeListener("max-shapes",t)}},[n,e])}const Rbe=at.memo(function({renderDebugMenuItems:e,children:t,hideUi:r,components:s,...i}){return g.jsx(Mbe,{...i,components:s,children:g.jsx(Dbe,{hideUi:r,renderDebugMenuItems:e,children:t})})}),Dbe=at.memo(function({children:e,hideUi:t,...r}){return g.jsxs(g.Fragment,{children:[e,t?null:g.jsx(jbe,{...r})]})}),jbe=at.memo(function(){const e=te(),t=it(),r=Rr(),s=ti(),i=ie("focus",()=>e.getInstanceState().isFocusMode,[e]),o=ie("debug",()=>e.getInstanceState().isDebugMode,[e]),{SharePanel:a,TopPanel:l,MenuPanel:c,StylePanel:u,Toolbar:h,HelpMenu:p,NavigationPanel:m,HelperButtons:S,DebugPanel:x,CursorChatBubble:v,RichTextToolbar:w,Toasts:C,Dialogs:_,A11y:E}=ac();mbe(),Bfe(),Obe();const T=P.useRef(!1),A=P.useRef(-1),[O,D]=P.useState(!1);HI("update hide toolbar while delayed",()=>{if(!(It.isIos||It.isAndroid))return;if(e.getEditingShapeId()===null){T.current&&(T.current=!1,clearTimeout(A.current),It.isAndroid?A.current=e.timers.setTimeout(()=>{D(!1)},150):D(!1));return}T.current||(T.current=!0,clearTimeout(A.current),D(!0))},[]);const{"toggle-focus-mode":$}=bu();return g.jsxs("div",{className:$e("tlui-layout",{"tlui-layout__mobile":r<dn.TABLET_SM}),"data-iseditinganything":O,"data-breakpoint":r,children:[g.jsx(dle,{}),i?g.jsx("div",{className:"tlui-layout__top",children:g.jsx(He,{type:"icon",className:"tlui-focus-button",title:t("focus-mode.toggle-focus-mode"),onClick:()=>$.onSelect("menu"),children:g.jsx(ct,{icon:"dot"})})}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"tlui-layout__top",children:[g.jsxs("div",{className:"tlui-layout__top__left",children:[c&&g.jsx(c,{}),S&&g.jsx(S,{})]}),g.jsx("div",{className:"tlui-layout__top__center",children:l&&g.jsx(l,{})}),g.jsxs("div",{className:"tlui-layout__top__right",children:[a&&g.jsx(a,{}),u&&r>=dn.TABLET_SM&&!s&&g.jsx(u,{})]})]}),g.jsxs("div",{className:"tlui-layout__bottom",children:[g.jsxs("div",{className:"tlui-layout__bottom__main",children:[m&&g.jsx(m,{}),h&&g.jsx(h,{}),p&&g.jsx(p,{})]}),o&&x&&g.jsx(x,{}),E&&g.jsx(E,{})]})]}),w&&g.jsx(w,{}),C&&g.jsx(C,{}),_&&g.jsx(_,{}),g.jsx(P0e,{}),v&&g.jsx(v,{})]})}),Lbe=[...C0e,...iye];function Nbe(n){const{children:e,maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:s,acceptedVideoMimeTypes:i,onMount:o,components:a={},shapeUtils:l=[],bindingUtils:c=[],tools:u=[],embeds:h,textOptions:p,...m}=n,S=dh(a),x=P.useMemo(()=>({Scribble:FL,ShapeIndicators:Epe,CollaboratorScribble:FL,SelectionForeground:Ppe,SelectionBackground:bpe,Handles:ype,...S}),[S]),v=Ol(l),w=P.useMemo(()=>Lw("type",v,A7),[v]),C=Ol(c),_=P.useMemo(()=>Lw("type",C,_U),[C]),E=Ol(u),T=P.useMemo(()=>Lw("id",Lbe,E),[E]),A=Ol(s??Mp),O=Ol(i??w0),D=P.useMemo(()=>({addFontsFromNode:KU,...p,tipTapConfig:{extensions:dg,...p==null?void 0:p.tipTapConfig}}),[p]),$=P.useMemo(()=>[...A,...O],[A,O]),H=I0e(m.assetUrls);return w.find(J=>J.type==="embed")&&h&&S0.setEmbedDefinitions(h),g.jsx(Hae,{initialState:"select",...m,components:x,shapeUtils:w,bindingUtils:_,tools:T,textOptions:D,assetUrls:H,children:g.jsxs(Rbe,{...m,components:x,mediaMimeTypes:$,children:[g.jsx(Fbe,{maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:A,acceptedVideoMimeTypes:O,onMount:o}),e]})})}function Fbe({maxImageDimension:n,maxAssetSize:e,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:r,onMount:s}){const i=te(),o=Ya(),a=it();L6(()=>{const u=[];return u.push(qSe(i)),i.fonts.requestFonts(vme),Ame(i,{maxImageDimension:n,maxAssetSize:e,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:r,toasts:o,msg:a}),u.push(i.store.props.onMount(i)),u.push(s==null?void 0:s(i)),()=>{u.forEach(h=>h==null?void 0:h())}});const{Canvas:l}=Zt(),{ContextMenu:c}=ac();return c?g.jsx(c,{}):l?g.jsx(l,{}):null}const zbe={tipTapConfig:{extensions:dg},addFontsFromNode:KU};P.memo(function(e){const[t,r]=P.useState(null),[s,i]=P.useState(null),o=Ol(e.shapeUtils??[]),a=P.useMemo(()=>[...A7,...o],[o]),l=Ol(e.bindingUtils??[]),c=P.useMemo(()=>[..._U,...l],[l]),u=Jae({snapshot:e.snapshot,shapeUtils:a}),{pageId:h,bounds:p,scale:m,pixelRatio:S,background:x,padding:v,darkMode:w,preserveAspectRatio:C,format:_="svg",licenseKey:E,assetUrls:T,textOptions:A=zbe}=e;return P.useLayoutEffect(()=>{if(!s||!u)return;let O=!1;const D=document.createElement("div");s.appendChild(D),s.classList.add("tl-container","tl-theme__light");const $=new ke({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>D,licenseKey:E,fontAssetUrls:T==null?void 0:T.fonts,textOptions:A});h&&$.setCurrentPage(h);const H=$.getCurrentPageShapeIds();async function G(){const J=await $.toImage([...H],{bounds:p,scale:m,background:x,padding:v,darkMode:w,preserveAspectRatio:C,format:_});if(!J||O)return;const L=URL.createObjectURL(J.blob);r(L),$.dispose()}return G(),()=>{O=!0}},[_,s,u,a,c,h,p,m,x,v,w,C,E,S,T,A]),P.useEffect(()=>()=>{t&&URL.revokeObjectURL(t)},[t]),g.jsx("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:t&&g.jsx("img",{src:t,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});P.memo(function({children:e}){const t=it(),r=Rr(),s=P.useRef(null);Ga(s);const i=e??g.jsx(Zve,{});return r<dn.MOBILE?null:g.jsx("div",{ref:s,className:"tlui-help-menu",children:g.jsxs(Z_,{id:"help menu",children:[g.jsx(J_,{children:g.jsx(He,{type:"help",title:t("help-menu.title"),"data-testid":"help-menu.button",children:g.jsx(ct,{icon:"question-mark",small:!0})})}),g.jsx(Q_,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:g.jsx(Zr,{type:"menu",sourceId:"help-menu",children:i})})]})})});const $be=1,Bbe=pt({schemaVersion:_r(1),storeVersion:py,recordVersions:mS(st,pt({version:py,subTypeVersions:mS(st,py).optional(),subTypeKey:st.optional()}))}),Ube=pt({schemaVersion:_r(2),sequences:mS(st,py)}),Hbe=pt({tldrawFileFormatVersion:Nee,schema:Fee("schemaVersion",{1:Bbe,2:Ube}),records:Un(pt({id:st,typeName:st}).allowUnknownProperties())});function Kbe(n){var e;try{return!!((e=n.document)!=null&&e.version)}catch{return!1}}function Wbe({json:n,schema:e}){let t;try{t=Hbe.validate(JSON.parse(n))}catch(i){try{if(t=JSON.parse(n),Kbe(t))return Fr.err({type:"v1File",data:t})}catch{}return Fr.err({type:"notATldrawFile",cause:i})}if(t.tldrawFileFormatVersion>$be)return Fr.err({type:"fileFormatVersionTooNew",version:t.tldrawFileFormatVersion});let r,s;try{const i=Vbe(t.records);s=Object.fromEntries(i.map(o=>[o.id,o])),r=e.migrateStoreSnapshot({store:s,schema:t.schema})}catch(i){return Fr.err({type:"invalidRecords",cause:i})}if(r.type==="error")return Fr.err({type:"migrationFailed",reason:r.reason});try{return Fr.ok(Sp({snapshot:{store:s,schema:t.schema},schema:e}))}catch(i){return Fr.err({type:"invalidRecords",cause:i})}}function Vbe(n){const e=new Set;for(const t of n)t.typeName==="shape"&&"assetId"in t.props&&t.props.assetId&&e.add(t.props.assetId);return n.filter(t=>t.typeName!=="asset"||e.has(t.id))}Zl("tldraw","3.12.1","esm");function qbe(){const[n,e]=P.useState();function t(r){globalThis.editor=r,n===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 i=Wbe({json:s,schema:r.store.schema});i.ok?(console.log("Loaded tldr file from local endpoint"),e(i.value)):console.error(`Couldn't parse tldr file: ${String(i.error.type)}`)}).catch(s=>{console.error("Couldn't fetch data:",s)}):(r.zoomToFit(),r.menus.clearOpenMenus())}return g.jsx("div",{style:{inset:0,position:"fixed"},children:g.jsx(Nbe,{assetUrls:SV(),onMount:t,store:n})})}yV.createRoot(document.querySelector("#root")).render(g.jsx(at.StrictMode,{children:g.jsx(qbe,{})}));
|